From 4f4b1cf5e145bcb43fca7e1ae716fe17010f56d5 Mon Sep 17 00:00:00 2001 From: "Jakub A. W" Date: Fri, 7 Aug 2026 00:53:22 +0200 Subject: [PATCH 01/19] feat(dashboard): improve audit log interactions --- cmd/gomodel/docs/docs.go | 122 ++------- docs/openapi.json | 122 ++------- .../static/dist/assets/index-BFUCi3g4.js | 67 ----- ...{index-Cz8GQupq.css => index-BbSfRjie.css} | 2 +- .../static/dist/assets/index-TuUpNQjY.js | 67 +++++ .../admin/dashboard/static/dist/index.html | 4 +- internal/admin/handler.go | 9 + internal/admin/handler_audit.go | 25 +- internal/admin/handler_test.go | 48 ++++ .../src/pages/audit-logs/ChatMessage.svelte | 152 ++++++++++- .../audit-logs/ConversationDrawer.svelte | 85 +++++- .../pages/audit-logs/conversation-helpers.js | 252 ++++++++++++++++-- .../tests/conversation-drawer.test.js | 221 +++++++++++++++ 13 files changed, 858 insertions(+), 318 deletions(-) delete mode 100644 internal/admin/dashboard/static/dist/assets/index-BFUCi3g4.js rename internal/admin/dashboard/static/dist/assets/{index-Cz8GQupq.css => index-BbSfRjie.css} (92%) create mode 100644 internal/admin/dashboard/static/dist/assets/index-TuUpNQjY.js diff --git a/cmd/gomodel/docs/docs.go b/cmd/gomodel/docs/docs.go index 6c1329d8f..541d4e6d5 100644 --- a/cmd/gomodel/docs/docs.go +++ b/cmd/gomodel/docs/docs.go @@ -18,7 +18,7 @@ const docTemplate = `{ "paths": { "/admin/audit/conversation": { "get": { - "description": "Thread entries carry the request/response bodies the\ntranscript is built from; attempts, request revisions, and\nresponse headers are omitted; redacted request headers are\nretained so the dashboard can continue the same session.", + "description": "Thread entries carry the request/response bodies the\ntranscript is built from; attempts, request revisions, and\nresponse headers are omitted; redacted request headers and\nper-request usage summaries are retained for continuation\nand prompt-cache visualization.", "produces": [ "application/json" ], @@ -45,7 +45,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/auditlog.ConversationResult" + "$ref": "#/definitions/admin.auditConversationResponse" } }, "400": { @@ -6860,6 +6860,24 @@ const docTemplate = `{ } } }, + "admin.auditConversationResponse": { + "type": "object", + "properties": { + "anchor_id": { + "type": "string" + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/admin.auditLogEntryResponse" + } + }, + "truncated": { + "description": "Truncated reports that more session or linkage entries exist than were\nreturned.", + "type": "boolean" + } + } + }, "admin.auditLogEntryResponse": { "type": "object", "properties": { @@ -8259,24 +8277,6 @@ const docTemplate = `{ } } }, - "auditlog.ConversationResult": { - "type": "object", - "properties": { - "anchor_id": { - "type": "string" - }, - "entries": { - "type": "array", - "items": { - "$ref": "#/definitions/auditlog.LogEntry" - } - }, - "truncated": { - "description": "Truncated reports that the thread walk stopped early because the\ncaller's deadline expired; the entries collected up to that point are\nreturned rather than failing the whole request.", - "type": "boolean" - } - } - }, "auditlog.FailoverSnapshot": { "type": "object", "properties": { @@ -8372,88 +8372,6 @@ const docTemplate = `{ } } }, - "auditlog.LogEntry": { - "type": "object", - "properties": { - "alias_used": { - "type": "boolean" - }, - "auth_key_id": { - "type": "string" - }, - "auth_method": { - "type": "string" - }, - "cache_type": { - "type": "string" - }, - "client_ip": { - "type": "string" - }, - "data": { - "description": "Data contains flexible request/response information as JSON", - "allOf": [ - { - "$ref": "#/definitions/auditlog.LogData" - } - ] - }, - "duration_ns": { - "description": "DurationNs is the request duration in nanoseconds", - "type": "integer" - }, - "error_type": { - "type": "string" - }, - "id": { - "description": "ID is a unique identifier for this log entry (UUID)", - "type": "string" - }, - "method": { - "type": "string" - }, - "path": { - "type": "string" - }, - "provider": { - "description": "canonical provider type used for routing and filters", - "type": "string" - }, - "provider_name": { - "type": "string" - }, - "request_id": { - "description": "Extracted fields for efficient filtering (indexed in relational DBs)", - "type": "string" - }, - "requested_model": { - "description": "Core fields (indexed for queries)", - "type": "string" - }, - "resolved_model": { - "type": "string" - }, - "session_id": { - "type": "string" - }, - "status_code": { - "type": "integer" - }, - "stream": { - "type": "boolean" - }, - "timestamp": { - "description": "Timestamp is when the request started", - "type": "string" - }, - "user_path": { - "type": "string" - }, - "workflow_version_id": { - "type": "string" - } - } - }, "auditlog.ProviderLatencySeries": { "type": "object", "properties": { diff --git a/docs/openapi.json b/docs/openapi.json index 8a38eba88..a97d6988f 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -9,7 +9,7 @@ "paths": { "/admin/audit/conversation": { "get": { - "description": "Thread entries carry the request/response bodies the\ntranscript is built from; attempts, request revisions, and\nresponse headers are omitted; redacted request headers are\nretained so the dashboard can continue the same session.", + "description": "Thread entries carry the request/response bodies the\ntranscript is built from; attempts, request revisions, and\nresponse headers are omitted; redacted request headers and\nper-request usage summaries are retained for continuation\nand prompt-cache visualization.", "tags": [ "admin" ], @@ -39,7 +39,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/auditlog.ConversationResult" + "$ref": "#/components/schemas/admin.auditConversationResponse" } } } @@ -10044,6 +10044,24 @@ } } }, + "admin.auditConversationResponse": { + "type": "object", + "properties": { + "anchor_id": { + "type": "string" + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/admin.auditLogEntryResponse" + } + }, + "truncated": { + "description": "Truncated reports that more session or linkage entries exist than were\nreturned.", + "type": "boolean" + } + } + }, "admin.auditLogEntryResponse": { "type": "object", "properties": { @@ -11472,24 +11490,6 @@ } } }, - "auditlog.ConversationResult": { - "type": "object", - "properties": { - "anchor_id": { - "type": "string" - }, - "entries": { - "type": "array", - "items": { - "$ref": "#/components/schemas/auditlog.LogEntry" - } - }, - "truncated": { - "description": "Truncated reports that the thread walk stopped early because the\ncaller's deadline expired; the entries collected up to that point are\nreturned rather than failing the whole request.", - "type": "boolean" - } - } - }, "auditlog.FailoverSnapshot": { "type": "object", "properties": { @@ -11585,88 +11585,6 @@ } } }, - "auditlog.LogEntry": { - "type": "object", - "properties": { - "alias_used": { - "type": "boolean" - }, - "auth_key_id": { - "type": "string" - }, - "auth_method": { - "type": "string" - }, - "cache_type": { - "type": "string" - }, - "client_ip": { - "type": "string" - }, - "data": { - "description": "Data contains flexible request/response information as JSON", - "allOf": [ - { - "$ref": "#/components/schemas/auditlog.LogData" - } - ] - }, - "duration_ns": { - "description": "DurationNs is the request duration in nanoseconds", - "type": "integer" - }, - "error_type": { - "type": "string" - }, - "id": { - "description": "ID is a unique identifier for this log entry (UUID)", - "type": "string" - }, - "method": { - "type": "string" - }, - "path": { - "type": "string" - }, - "provider": { - "description": "canonical provider type used for routing and filters", - "type": "string" - }, - "provider_name": { - "type": "string" - }, - "request_id": { - "description": "Extracted fields for efficient filtering (indexed in relational DBs)", - "type": "string" - }, - "requested_model": { - "description": "Core fields (indexed for queries)", - "type": "string" - }, - "resolved_model": { - "type": "string" - }, - "session_id": { - "type": "string" - }, - "status_code": { - "type": "integer" - }, - "stream": { - "type": "boolean" - }, - "timestamp": { - "description": "Timestamp is when the request started", - "type": "string" - }, - "user_path": { - "type": "string" - }, - "workflow_version_id": { - "type": "string" - } - } - }, "auditlog.ProviderLatencySeries": { "type": "object", "properties": { diff --git a/internal/admin/dashboard/static/dist/assets/index-BFUCi3g4.js b/internal/admin/dashboard/static/dist/assets/index-BFUCi3g4.js deleted file mode 100644 index 7499c6367..000000000 --- a/internal/admin/dashboard/static/dist/assets/index-BFUCi3g4.js +++ /dev/null @@ -1,67 +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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`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){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function h(e,t,n=!1){return e===void 0?n?t():t:e}function g(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 _=1<<24,v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,ee=65536,te=1<<19,ne=1<<20,re=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(`legacy props`),ue=Symbol(``),de=Symbol(`attributes`),fe=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),he=Symbol(`form reset`),ge=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},_e=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(`uninitialized`),je=`http://www.w3.org/1999/xhtml`,Me=`http://www.w3.org/2000/svg`,Ne=`http://www.w3.org/1998/Math/MathML`;function Pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Fe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ie(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Le(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Re=!1;function ze(e){Re=e}var Be;function Ve(e){if(e===null)throw Fe(),ke;return Be=e}function He(){return Ve(bn(Be))}function T(e){if(Re){if(bn(Be)!==null)throw Fe(),ke;Be=e}}function Ue(e=1){if(Re){for(var t=e,n=Be;t--;)n=bn(n);Be=n}}function We(e=!0){for(var t=0,n=Be;;){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=bn(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Fe(),ke;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=null;function Xe(e){Ye=e}function E(e,t=!1,n){Ye={p:Ye,i:!1,c:null,e:null,s:e,x:null,r:ir,l:null}}function D(e){var t=Ye,n=t.e;if(n!==null){t.e=null;for(var r of n)jn(r)}return e!==void 0&&(t.x=e),t.i=!0,Ye=t.p,e??{}}function Ze(){return!0}var Qe=[];function $e(){var e=Qe;Qe=[],p(e)}function et(e){if(Qe.length===0&&!zt){var t=Qe;queueMicrotask(()=>{t===Qe&&$e()})}Qe.push(e)}function tt(){for(;Qe.length>0;)$e()}function nt(e){var t=ir;if(t===null)return tr.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;rt(e,t)}function rt(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var it=~(y|b|v);function at(e,t){e.f=e.f&it|t}function ot(e){e.f&512||e.deps===null?at(e,v):at(e,b)}function st(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,st(t.deps))}function ct(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),st(e.deps),at(e,v)}var lt=!1;function ut(e){var t=lt;try{return lt=!1,[e(),lt]}finally{lt=t}}function dt(e,t){if(t){let t=document.body;e.autofocus=!0,et(()=>{document.activeElement===t&&e.focus()})}}function ft(e){Re&&yn(e)!==null&&xn(e)}var pt=!1;function mt(){pt||(pt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[he]?.()})},{capture:!0}))}function ht(e){var t=tr,n=ir;rr(null),ar(null);try{return e()}finally{rr(t),ar(n)}}function gt(e,t,n,r=n){e.addEventListener(t,()=>ht(n));let i=e[he];i?e[he]=()=>{i(),r(!0)}:e[he]=()=>r(!0),mt()}function _t(e){let t=0,n=an(0),r;return()=>{On()&&(I(n),In(()=>(t===0&&(r=Er(()=>e(()=>ln(n)))),t+=1,()=>{et(()=>{--t,t===0&&(r?.(),r=void 0,ln(n))})})))}}var vt=ee|te;function yt(e,t,n,r){new bt(e,t,n,r)}var bt=class{parent;is_pending=!1;transform_error;#e;#t=Re?Be: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=_t(()=>(this.#m=an(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=ir;t.b=this,t.f|=128,n(e)},this.parent=ir.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Ln(()=>{if(Re){let e=this.#t;He();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},vt),Re&&(this.#e=Be)}#g(){try{this.#a=zn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=zn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=zn(()=>e(this.#e)),et(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>zn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Kn(this.#o,()=>{this.#o=null}),this.#b(Ft))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=zn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Xn(this.#a,e);let t=this.#n.pending;this.#o=zn(()=>t(this.#e))}else this.#b(Ft)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){ct(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=ir,n=tr,r=Ye;ar(this.#i),rr(this.#i),Xe(this.#i.ctx);try{return Gt.ensure(),e()}catch(e){return nt(e),null}finally{ar(t),rr(n),Xe(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Kn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,et(()=>{this.#d=!1,this.#m&&sn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),I(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Ft?.is_fork?(this.#a&&Ft.skip_effect(this.#a),this.#o&&Ft.skip_effect(this.#o),this.#s&&Ft.skip_effect(this.#s),Ft.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Un(this.#a),null),this.#o&&=(Un(this.#o),null),this.#s&&=(Un(this.#s),null),Re&&(Ve(this.#t),Ue(),Ve(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Le();return}r=!0,i&&Oe(),this.#s!==null&&Kn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){rt(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return zn(()=>{var t=ir;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return rt(e,this.#i.parent),null}}))};et(()=>{var t;try{t=this.transform_error(e)}catch(e){rt(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>rt(e,this.#i&&this.#i.parent)):o(t)})}};function xt(e,t,n,r){let i=Ze()?Tt:Ot;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=ir,c=St(),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){rt(e,s)}Ct()}}var d=wt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Dt(e))).then(u).catch(e=>rt(e,s)).finally(d)}l?l.then(()=>{c(),f(),Ct()}):f()}function St(){var e=ir,t=tr,n=Ye,r=Ft;return function(i=!0){ar(e),rr(t),Xe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ct(e=!0){ar(null),rr(null),Xe(null),e&&Ft?.deactivate()}function wt(){var e=ir,t=e.b,n=Ft,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 Tt(e){var t=2|y;return ir!==null&&(ir.f|=te),{ctx:Ye,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:ir,ac:null}}var Et=Symbol(`obsolete`);function Dt(e,t,n){let r=ir;r===null&&ve();var i=void 0,a=an(Ae),o=!tr,s=new Set;return Fn(()=>{var t=ir,n=m();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ge&&n.reject(e)}).finally(Ct)}catch(e){n.reject(e),Ct()}var c=Ft;if(o){if(t.f&32768)var l=wt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Et);else for(let e of s.values())e.reject(Et);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Et&&(c.activate(),t?(a.f|=se,sn(a,t)):(a.f&8388608&&(a.f^=se),sn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),kn(()=>{for(let e of s)e.reject(Et)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function O(e){let t=Tt(e);return sr(t),t}function Ot(e){let t=Tt(e);return t.equals=Je,t}function kt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(ge),t.ac=null}),t.fn!==null&&(t.teardown=f),xr(t,0),Vn(t))}function Nt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Sr(t)}var Pt=null,Ft=null,It=null,Lt=null,Rt=null,zt=!1,Bt=!1,Vt=null,Ht=null,Ut=0,Wt=1,Gt=class e{id=Wt++;#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(){Pt===null?Pt=this:(Pt.#n=this,this.#t=Pt),Pt=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)at(r,y),t(r);for(r of n.m)at(r,b),t(r)}this.#p.add(e)}#g(){this.#e=!0,Ut++>1e3&&(this.#x(),qt());for(let e of this.#u)this.#d.delete(e),at(e,y),this.schedule(e);for(let e of this.#d)at(e,b),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Vt=[],r=[],i=Ht=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw en(e),this.#h()||this.discard(),t}if(Ft=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Vt=null,Ht=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)$t(e,t);i.length>0&&Ft.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),It=this,Yt(r),Yt(n),It=null,this.#s?.resolve();var s=Ft;if(this.#a===0&&(this.#c.length===0||s!==null)&&this.#x(),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):_r(r)&&(i&16&&this.#d.add(r),Sr(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}}}#v(){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}#y(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),at(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#x(),Ft=this,this.#g()}#b(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??=m()).promise}static ensure(){if(Ft===null){let t=Ft=new e;!Bt&&!zt&&et(()=>{t.#e||t.flush()})}return Ft}apply(){Lt=null}schedule(e){if(Rt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Vt!==null&&t===ir&&(tr===null||!(tr.f&2)))return;if(n&96){if(!(n&1024))return;t.f^=v}}this.#c.push(t)}#x(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?Pt=e:t.#t=e,this.linked=!1}}};function Kt(e){var t=zt;zt=!0;try{var n;for(e&&(Ft!==null&&!Ft.is_fork&&Ft.flush(),n=e());;){if(tt(),Ft===null)return n;Ft.flush()}}finally{zt=t}}function qt(){try{Ce()}catch(e){rt(e,Rt)}}var Jt=null;function Yt(e){var t=e.length;if(t!==0){for(var n=0;n0)){nn.clear();for(let e of Jt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Jt.has(n)&&(Jt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sr(n)}}Jt.clear()}}Jt=null}}function Xt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Xt(i,t,n,r):e&4194320&&!(e&2048)&&Zt(i,t,r)&&(at(i,y),Qt(i))}}function Zt(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(e.deps!==null)for(let i of e.deps){if(n.call(t,i))return!0;if(i.f&2&&Zt(i,t,r))return r.set(i,!0),!0}return r.set(e,!1),!1}function Qt(e){Ft.schedule(e)}function $t(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),at(e,v);for(var n=e.first;n!==null;)$t(n,t),n=n.next}}function en(e){at(e,v);for(var t=e.first;t!==null;)en(t),t=t.next}var tn=new Set,nn=new Map,rn=!1;function an(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function k(e,t){let n=an(e,t);return sr(n),n}function on(e,t=!1,n=!0){let r=an(e);return t||(r.equals=Je),r}function A(e,t,n=!1){return tr!==null&&(!nr||tr.f&131072)&&Ze()&&tr.f&4325394&&(or===null||!or.has(e))&&De(),sn(e,n?j(t):t,Ht)}function sn(e,t,n=null){if(!e.equals(t)){nn.set(e,$n?t:e.v);var r=Gt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&At(t),Lt===null&&ot(t)}e.wv=gr(),un(e,y,n),Ze()&&ir!==null&&ir.f&1024&&!(ir.f&96)&&(ur===null?dr([e]):ur.push(e)),!r.is_fork&&tn.size>0&&!rn&&cn()}return t}function cn(){rn=!1;for(let e of tn){e.f&1024&&at(e,b);let t;try{t=_r(e)}catch{t=!0}t&&Sr(e)}tn.clear()}function ln(e){A(e,e.v+1)}function un(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ze(),a=r.length,o=0;o{if(mr===d)return e();var t=tr,n=mr;rr(null),hr(d);var r=e();return rr(t),hr(n),r};return i&&r.set(`length`,k(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Te();var i=r.get(t);return i===void 0?f(()=>{var e=k(n.value,u);return r.set(t,e),e}):A(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>k(Ae,u));r.set(t,e),ln(o)}}else A(n,Ae),ln(o);return!0},get(e,n,i){if(n===ce)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>k(j(s?e[n]:Ae),u)),r.set(n,o)),o!==void 0){var c=I(o);return c===Ae?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=I(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===ce)return!0;var n=r.get(t),i=n!==void 0&&n.v!==Ae||Reflect.has(e,t);return(n!==void 0||ir!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>k(i?j(e[t]):Ae,u)),r.set(t,n)),I(n)===Ae)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dk(Ae,u)),r.set(d+``,p)):A(p,Ae)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>k(void 0,u)),A(c,j(n)),r.set(t,c));else{l=c.v!==Ae;var m=f(()=>j(n));A(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&&A(g,_+1)}ln(o)}return!0},ownKeys(e){I(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==Ae});for(var[n,i]of r)i.v!==Ae&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ee()}})}function dn(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=a(t,`firstChild`).get,gn=a(t,`nextSibling`).get,u(e)&&(e[fe]=void 0,e[de]=null,e[pe]=void 0,e.__e=void 0),u(n)&&(n[me]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function M(e,t){if(!Re)return yn(e);var n=yn(Be);if(n===null)n=Be.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),Ve(r),r}return t&&wn(n),Ve(n),n}function N(e,t=!1){if(!Re){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Be?.nodeType!==3){var r=vn();return Be?.before(r),Ve(r),r}wn(Be)}return Be}function P(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=bn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),Ve(a),a}wn(r)}return Ve(r),r}function xn(e){e.textContent=``}function Sn(){return!1}function Cn(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 wn(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 Tn(e){ir===null&&(tr===null&&Se(e),xe()),$n&&be(e)}function En(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Dn(e,t){var n=ir;n!==null&&n.f&8192&&(e|=x);var r={ctx:Ye,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};Ft?.register_created_effect(r);var i=r;if(e&4)Vt===null?Gt.ensure().schedule(r):Vt.push(r);else if(t!==null){try{Sr(r)}catch(e){throw Un(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|=ee))}if(i!==null&&(i.parent=n,n!==null&&En(i,n),tr!==null&&tr.f&2&&!(e&64))){var a=tr;(a.effects??=[]).push(i)}return r}function On(){return tr!==null&&!nr}function kn(e){let t=Dn(8,null);return at(t,v),t.teardown=e,t}function An(e){Tn(`$effect`);var t=ir.f;if(!tr&&t&32&&Ye!==null&&!Ye.i){var n=Ye;(n.e??=[]).push(e)}else return jn(e)}function jn(e){return Dn(4|ne,e)}function Mn(e){Gt.ensure();let t=Dn(64|te,e);return()=>{Un(t)}}function Nn(e){Gt.ensure();let t=Dn(64|te,e);return(e={})=>new Promise(n=>{e.outro?Kn(t,()=>{Un(t),n(void 0)}):(Un(t),n(void 0))})}function Pn(e){return Dn(4,e)}function Fn(e){return Dn(oe|te,e)}function In(e,t=0){return Dn(8|t,e)}function F(e,t=[],n=[],r=[]){xt(r,t,n,t=>{Dn(8,()=>{e(...t.map(I))})})}function Ln(e,t=0){return Dn(16|t,e)}function Rn(e,t=0){return Dn(_|t,e)}function zn(e){return Dn(32|te,e)}function Bn(e){var t=e.teardown;if(t!==null){let e=$n,n=tr;er(!0),rr(null);try{t.call(null)}finally{er(e),rr(n)}}}function Vn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ht(()=>{e.abort(ge)});var r=n.next;n.f&64?n.parent=null:Un(n,t),n=r}}function Hn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Un(t),t=n}}function Un(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Wn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,Vn(e,t&&!n),xr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Bn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Gn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Wn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Gn(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 Kn(e,t,n=!0){var r=[];qn(e,r,!0);var i=()=>{n&&Un(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function qn(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)!=0||(i.f&32)!=0&&(e.f&16)!=0;qn(i,t,o?n:!1)}i=a}}}function Jn(e){Yn(e,!0)}function Yn(e,t){if(e.f&8192){e.f^=x,e.f&1024||(at(e,y),Gt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Yn(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 Xn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var Zn=null,Qn=!1,$n=!1;function er(e){$n=e}var tr=null,nr=!1;function rr(e){tr=e}var ir=null;function ar(e){ir=e}var or=null;function sr(e){tr!==null&&(or??=new Set).add(e)}var cr=null,lr=0,ur=null;function dr(e){ur=e}var fr=1,pr=0,mr=pr;function hr(e){mr=e}function gr(){return++fr}function _r(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Lt===null&&at(e,v)}return!1}function vr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(or!==null&&or.has(e)))for(var i=0;i{e.ac.abort(ge)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=C;var f=e.deps,p=Ft?.is_fork;if(cr!==null){var m;if(p||xr(e,lr),f!==null&&lr>0)for(f.length=lr+cr.length,m=0;m{s.ac.abort(ge),s.ac=null,at(s,y)}),Mt(s),xr(s,0)}}function xr(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`?et(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Vr(e,t,n,r,i){var a={capture:r,passive:i},o=Br(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&kn(()=>{t.removeEventListener(e,o,a)})}function L(e,t,n){(t[Lr]??={})[e]=n}function Hr(e){for(var t=0;t{throw e});throw p}}finally{e[Lr]=t,delete e.currentTarget,rr(d),ar(f)}}}var Gr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Kr(e){return Gr?.createHTML(e)??e}function qr(e){var t=Cn(`template`);return t.innerHTML=Kr(e.replaceAll(``,``)),t.content}function Jr(e,t){var n=ir;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function R(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Re)return Jr(Be,null),Be;i===void 0&&(i=qr(a?e:``+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;Jr(o,s)}else Jr(t,t);return t}}function Yr(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}`,o;return()=>{if(Re)return Jr(Be,null),Be;if(!o){var e=yn(qr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;Jr(n,r)}else Jr(t,t);return t}}function Xr(e,t){return Yr(e,t,`svg`)}function Zr(e=``){if(!Re){var t=vn(e+``);return Jr(t,t),t}var n=Be;return n.nodeType===3?wn(n):(n.before(n=vn()),Ve(n)),Jr(n,n),n}function Qr(){if(Re)return Jr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),Jr(t,n),e}function z(e,t){if(Re){var n=ir;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Be),He();return}e!==null&&e.before(t)}var $r=!0;function ei(e){$r=e}function B(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function ti(e,t){return ri(e,t)}var ni=new Map;function ri(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=Nn(()=>{var u=n??t.appendChild(vn());yt(u,{pending:()=>{}},t=>{E({});var n=Ye;if(o&&(n.c=o),a&&(i.$$events=a),Re&&Jr(t,null),$r=s,l=e(t,i)||{},$r=!0,Re&&(ir.nodes.end=Be,Be===null||Be.nodeType!==8||Be.data!==`]`))throw Fe(),ke;D()},c);var d=new Set,f=e=>{for(var n=0;n{for(var e of d)for(let n of[t,document]){var r=ni.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Wr),r.delete(e),r.size===0&&ni.delete(n)):r.set(e,i)}zr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ii.set(l,u),l}var ii=new WeakMap,ai=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)Jn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Jn(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&&(Un(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();Xn(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else Un(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Kn(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)||(Un(n.effect),this.#n.delete(e))};ensure(e,t){var n=Ft,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:zn(()=>t(a)),fragment:i})}else this.#t.set(e,zn(()=>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 Re&&(this.anchor=Be),this.#a(n)}};function V(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ai(e),a=n?ee:0;function o(e,t){if(Re){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}Ln(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function oi(e,t){return t}function si(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;ci(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;if(l){var u=n,d=u.parentNode;xn(d),d.append(u),e.items.clear()}ci(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function ci(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,di(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=re,pi(d,null,c)):Jn(d):Kn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Ln(()=>{p=I(f);var e=p.length;let t=!1;Re&&Ge(c)===`[!`!=(e===0)&&(c=We(),Ve(c),ze(!1),t=!0);for(var r=new Set,u=Ft,v=Sn(),y=0;ys(c)):(d=zn(()=>s(li??=vn())),d.f|=re)),e>r.size&&ye(``,``,``),Re&&e>0&&Ve(We()),!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&&ze(!0),I(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Re&&(c=Be)}function ui(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function di(e,t,n,i,a){var o=(i&8)!=0,s=t.length,c=e.items,l=ui(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var te=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function fi(e,t,n,r,i,a,o,s){var c=o&1?o&16?an(n):on(n,!1,!1):null,l=o&2?an(i):null;return{v:c,i:l,e:zn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function pi(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=bn(r);if(a.before(r),r===i)return;r=o}}function mi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function hi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Re&&(o=Ve(yn(c)))}F(()=>{var e=ir;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&Jr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Wn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Re){for(var a=Be.data,l=He(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Fe(),ke;Jr(Be,u),o=Ve(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Jr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function gi(e,t,...n){var r=new ai(e);Ln(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},ee)}function _i(e,t,n){var r;Re&&(r=Be,He());var i=new ai(e);Ln(()=>{var e=t()??null;if(Re&&Ge(r)===`[`!=(e!==null)){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,e&&(t=>n(t,e))),ze(!0);return}i.ensure(e,e&&(t=>n(t,e)))},ee)}var vi=()=>performance.now(),yi={tick:e=>requestAnimationFrame(e),now:()=>vi(),tasks:new Set};function bi(){let e=yi.now();yi.tasks.forEach(t=>{t.c(e)||(yi.tasks.delete(t),t.f())}),yi.tasks.size!==0&&yi.tick(bi)}function xi(e){let t;return yi.tasks.size===0&&yi.tick(bi),{promise:new Promise(n=>{yi.tasks.add(t={c:e,f:n})}),abort(){yi.tasks.delete(t)}}}function Si(e,t){ht(()=>{e.dispatchEvent(new CustomEvent(t))})}function Ci(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function wi(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Ci(n.trim());t[i]=r.trim()}return t}var Ti=e=>e,Ei=null;function Di(e){Ei=e}function Oi(e,t,n){var r=(Ei??ir).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Ai(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function ki(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return ht(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Ai(t,m(),p,1,()=>{Si(t,`introstart`)},()=>{Si(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Ai(t,m(),f,0,()=>{Si(t,`outrostart`)},()=>{Si(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=ir;if((g.nodes.t??=[]).push(h),i&&$r){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Pn(()=>{Er(()=>h.in())})}}function Ai(e,t,n,r,i,a){var o=r===1;if(d(t)){var s,c=!1;return et(()=>{c||(s=Ai(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:f,deactivate:f,reset:f,t:()=>r};let{delay:l=0,css:u,tick:p,easing:m=Ti}=t;var h=[];if(o&&n===void 0&&(p&&p(0,1),u)){var g=wi(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var d=!1;if(u)for(var f=Math.ceil(c/(1e3/60)),h=0;h<=f;h+=1){var g=o+s*m(h/f),y=wi(u(g,1-g));l.push(y),d||=y.overflow===`hidden`}d&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*m(e/c)},p&&xi(()=>{if(v.playState!==`running`)return!1;var e=_();return p(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,p?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=f)},deactivate:()=>{a=f},reset:()=>{r===0&&p?.(1,0)},t:()=>_()}}function ji(e,t,n,r,i,a){let o=Re;Re&&He();var s=null;Re&&Be.nodeType===1&&(s=Be,He());var c=Re?Be:e,l=ir,u=new ai(c,!1);Ln(()=>{let e=t()||null;var a=i?i():n||e===`svg`?Me:void 0;if(e===null){u.ensure(null,null),ei(!0);return}return u.ensure(e,t=>{if(e){if(s=Re?s:Cn(e,a),Jr(s,s),r){var n=null;Re&&Ir(e)&&s.append(n=document.createComment(``));var i=Re?yn(s):s.appendChild(vn());Re&&(i===null?ze(!1):Ve(i)),Di(l),r(s,i),n?.remove(),Di(null)}ir.nodes.end=s,t.before(s)}Re&&Ve(t)}),ei(!0),()=>{e&&ei(!1)}},ee),kn(()=>{ei(!0)}),o&&(ze(!0),Ve(c))}function Mi(e,t){var n=void 0,r;Rn(()=>{n!==(n=t())&&(r&&=(Un(r),null),n&&(r=zn(()=>{Pn(()=>n(e))})))})}function Ni(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||Ii.includes(r[o-1]))&&(s===r.length||Ii.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Ri(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 zi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Bi(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(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(zi)),i&&c.push(...Object.keys(i).map(zi));var l=0,u=-1;let t=e.length;for(var d=0;d{Ui(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),kn(()=>{t.disconnect()})}function Gi(e,t,n=t){var r=new WeakSet,i=!0;gt(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ki);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ki(o)}n(a),e.__value=a,Ft!==null&&r.add(Ft)}),Pn(()=>{var a=t();if(e===document.activeElement){var o=Ft;if(r.has(o))return}if(Ui(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ki(s),n(a))}e.__value=a,i=!1}),Wi(e)}function Ki(e){return`__value`in e?e.__value:e.value}var qi=Symbol(`class`),Ji=Symbol(`style`),Yi=Symbol(`is custom element`),Xi=Symbol(`is html`),Zi=_e?`link`:`LINK`,Qi=_e?`input`:`INPUT`,$i=_e?`option`:`OPTION`,ea=_e?`select`:`SELECT`,ta=_e?`progress`:`PROGRESS`;function na(e){if(Re){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;W(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;W(e,`checked`,null),e.checked=r}}};e[he]=n,et(n),mt()}}function ra(e,t){var n=ca(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==ta)||(e.value=t??``)}function ia(e,t){var n=ca(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function aa(e,t){t?e.hasAttribute(`selected`)||e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}function W(e,t,n,r){var i=ca(e);Re&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Zi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ue]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ua(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function oa(e,t,n,r,i=!1,a=!1){if(Re&&i&&e.nodeName===Qi){var o=e;(o.type===`checkbox`?`defaultChecked`:`defaultValue`)in n||na(o)}var s=ca(e),c=s[Yi],l=!s[Xi];let u=Re&&c;u&&ze(!1);var d=t||{},f=e.nodeName===$i;for(var p in t)p in n||(n[p]=null);n.class?n.class=Fi(n.class):(r||n[qi])&&(n.class=null),n[Ji]&&(n.style??=null);var m=ua(e);if(e.nodeName===Qi&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==d.type||h===void 0&&e.hasAttribute(`type`))&&(d.type=h,W(e,`type`,h,a))}for(let i in n){let o=n[i];if(f&&i===`value`&&o==null){e.value=e.__value=``,d[i]=o;continue}if(i===`class`){U(e,e.namespaceURI===`http://www.w3.org/1999/xhtml`,o,r,t?.[qi],n[qi]),d[i]=o,d[qi]=n[qi];continue}if(i===`style`){Hi(e,o,t?.[Ji],n[Ji]),d[i]=o,d[Ji]=n[Ji];continue}var g=d[i];if(!(o===g&&!(o===void 0&&e.hasAttribute(i)))){d[i]=o;var _=i[0]+i[1];if(_!==`$$`)if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=kr(r);if(Dr(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(o!=null)continue;e.removeEventListener(r,d[n],t),d[n]=null}if(v)L(r,e,o),Hr([r]);else if(o!=null){function a(e){d[i].call(this,e)}d[n]=Br(r,e,a,t)}}else if(i===`style`)W(e,i,o);else if(i===`autofocus`)dt(e,!!o);else if(!c&&(i===`__value`||i===`value`&&o!=null))e.value=e.__value=o;else if(i===`selected`&&f)aa(e,o);else{var y=i;l||(y=Mr(y));var b=y===`defaultValue`||y===`defaultChecked`;if(o==null&&!c&&!b)if(s[i]=null,y===`value`||y===`checked`){let n=e,r=t===void 0;if(y===`value`){let e=n.defaultValue;n.removeAttribute(y),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(y),n.defaultChecked=e,n.checked=r?e:!1}}else e.removeAttribute(i);else b||m.includes(y)&&(c||typeof o!=`string`)?(e[y]=o,y in s&&(s[y]=Ae)):typeof o!=`function`&&W(e,y,o,a)}}}return u&&ze(!0),d}function sa(e,t,n=[],r=[],i=[],a,o=!1,s=!1){xt(i,n,r,n=>{var r=void 0,i={},c=e.nodeName===ea,l=!1;if(Rn(()=>{var u=t(...n.map(I)),d=oa(e,r,u,a,o,s);l&&c&&`value`in u&&Ui(e,u.value);for(let e of Object.getOwnPropertySymbols(i))u[e]||Un(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var f=u[t];t.description===`@attach`&&(!r||f!==r[t])&&(i[t]&&Un(i[t]),i[t]=zn(()=>Mi(e,()=>f))),d[t]=f}r=d}),c){var u=e;Pn(()=>{Ui(u,r.value,!0),Wi(u)})}l=!0})}function ca(e){return e[de]??={[Yi]:e.nodeName.includes(`-`),[Xi]:e.namespaceURI===je}}var la=new Map;function ua(e){var t=e.getAttribute(`is`)||e.nodeName,n=la.get(t);if(n)return n;la.set(t,n=[]);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.push(s);i=l(i)}return n}function da(e,t,n=t){var r=new WeakSet;gt(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=pa(e)?ma(a):a,n(a),Ft!==null&&r.add(Ft),await Cr(),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))}}}),(Re&&e.defaultValue!==e.value||Er(t)==null&&e.value)&&(n(pa(e)?ma(e.value):e.value),Ft!==null&&r.add(Ft)),In(()=>{var n=t();if(e===document.activeElement){var i=Ft;if(r.has(i))return}pa(e)&&n===ma(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function fa(e,t,n=t){gt(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Re&&e.defaultChecked!==e.checked||Er(t)==null)&&n(e.checked),In(()=>{e.checked=!!t()})}function pa(e){var t=e.type;return t===`number`||t===`range`}function ma(e){return e===``?null:+e}function ha(e,t){return e===t||e?.[ce]===t}function ga(e={},t,n,r){var i=Ye.r,a=ir;return Pn(()=>{var o,s;return In(()=>{o=s,s=r?.()||[],Er(()=>{ha(n(...s),e)||(t(e,...s),o&&ha(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&&ha(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var _a={get(e,t){if(!e.exclude.has(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return!e.exclude.has(t)&&t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))}};function va(e,t,n){return new Proxy({props:e,exclude:t},_a)}function ya(e,t,n,r){var i=!0,o=(n&8)!=0,s=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>s&&i?(u??=Tt(r),I(u)):(l&&(l=!1,c=s?Er(r):r),c);let f;if(o){var p=ce in e||le in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=ut(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&we(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?Tt:Ot)(()=>(v=!1,g()));o&&I(y);var b=ir;return(function(e,t){if(arguments.length>0){let n=t?I(y):i&&o?j(e):e;return A(y,n),v=!0,c!==void 0&&(c=n),e}return $n&&v||b.f&16384?y.v:I(y)})}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var ba=new Set([`$$slots`,`$$events`,`$$legacy`,`icon`,`class`]),xa=Xr(``);function G(e,t){let n=ya(t,`icon`,19,()=>[]),r=ya(t,`class`,3,``),i=va(t,ba);var a=xa();sa(a,()=>({xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:r(),"aria-hidden":`true`,focusable:`false`,...i}));{let e=(t,n=f)=>{var r=Qr();H(N(r),17,n,oi,(t,n)=>{var r=O(()=>g(I(n),3));let i=()=>I(r)[0],a=()=>I(r)[1],o=()=>I(r)[2];var s=Qr();ji(N(s),i,!0,(t,n)=>{sa(t,()=>({xmlns:`http://www.w3.org/2000/svg`,...a()}));var r=Qr(),i=N(r),s=t=>{e(t,o)},c=O(()=>Array.isArray(o()));V(i,e=>{I(c)&&e(s)}),z(n,r)}),z(t,s)}),z(t,r)};e(M(a),n),T(a)}z(e,a)}var Sa=Xr(``);function Ca(e){z(e,Sa())}function wa(){try{return typeof localStorage>`u`?null:localStorage}catch{return null}}function Ta(e,t=null){let n=wa();if(!n)return t;try{return n.getItem(e)??t}catch{return t}}function Ea(e,t){let n=wa();if(n)try{n.setItem(e,String(t))}catch{}}function Da(e){let t=Number(e);return Number.isFinite(t)?Math.min(240,Math.max(60,Math.round(t))):240}function Oa(e,t,n){return Da(Number(e)+Number(n)-Number(t))}var ka=new class{#e=k(`system`);get theme(){return I(this.#e)}set theme(e){A(this.#e,e,!0)}#t=k(0);get tick(){return I(this.#t)}set tick(e){A(this.#t,e,!0)}init(){this.theme=Ta(`gomodel_theme`,`system`),this.apply(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{this.theme===`system`&&this.tick++})}set(e){this.theme=e,Ea(`gomodel_theme`,e),this.apply(),this.tick++}toggle(){let e=[`light`,`system`,`dark`];this.set(e[(e.indexOf(this.theme)+1)%e.length])}apply(){let e=document.documentElement;this.theme===`system`?e.removeAttribute(`data-theme`):e.setAttribute(`data-theme`,this.theme)}},Aa=new class{#e=k(j(240));get width(){return I(this.#e)}set width(e){A(this.#e,e,!0)}get collapsed(){return this.width===60}init(){let e=Ta(`gomodel_sidebar_width`),t=Ta(`gomodel_sidebar_collapsed`)===`true`;this.setWidth(e??(t?60:240))}toggle(){this.setWidth(this.collapsed?240:60,!0)}setWidth(e,t=!1){this.width=Da(e),typeof document<`u`&&document.documentElement.style.setProperty(`--sidebar-width`,`${this.width}px`),t&&(Ea(`gomodel_sidebar_width`,this.width),Ea(`gomodel_sidebar_collapsed`,this.collapsed))}},ja=new class{#e=k(j([]));get stack(){return I(this.#e)}set stack(e){A(this.#e,e,!0)}#t=1;opened(){let e=this.#t++;return this.stack=[...this.stack,e],e}closed(e){this.stack=this.stack.filter(t=>t!==e)}isTop(e){return this.stack.length>0&&this.stack[this.stack.length-1]===e}get openCount(){return this.stack.length}get anyOpen(){return this.stack.length>0}},Ma=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],Na=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],Pa=[[`path`,{d:`M5 12h14`}],[`path`,{d:`m12 5 7 7-7 7`}]],Fa=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]],Ia=[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`}],[`path`,{d:`M16 10h.01`}],[`path`,{d:`M12 10h.01`}],[`path`,{d:`M8 10h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M8 18h.01`}]],La=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M16 14h.01`}],[`path`,{d:`M8 18h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M16 18h.01`}]],Ra=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}]],za=[[`path`,{d:`M13 17V9`}],[`path`,{d:`M18 17V5`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M8 17v-3`}]],Ba=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M18 17V9`}],[`path`,{d:`M13 17V5`}],[`path`,{d:`M8 17v-3`}]],Va=[[`path`,{d:`M20 6 9 17l-5-5`}]],Ha=[[`path`,{d:`m6 9 6 6 6-6`}]],Ua=[[`path`,{d:`m15 18-6-6 6-6`}]],Wa=[[`path`,{d:`m9 18 6-6-6-6`}]],Ga=[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`}],[`path`,{d:`m9 11 3 3L22 4`}]],Ka=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m9 12 2 2 4-4`}]],qa=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}],[`path`,{d:`M12 18V6`}]],Ja=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],Ya=[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`}]],Xa=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`}],[`path`,{d:`M21 5V8`}],[`path`,{d:`M21 12L18 17H22L19 22`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`}]],Za=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`}]],Qa=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],$a=[[`path`,{d:`m12 14 4-4`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`}]],eo=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}],[`path`,{d:`M12 7v5l4 2`}]],to=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 16v-4`}],[`path`,{d:`M12 8h.01`}]],no=[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],ro=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],io=[[`path`,{d:`M3 5h.01`}],[`path`,{d:`M3 12h.01`}],[`path`,{d:`M3 19h.01`}],[`path`,{d:`M8 5h13`}],[`path`,{d:`M8 12h13`}],[`path`,{d:`M8 19h13`}]],ao=[[`circle`,{cx:`12`,cy:`16`,r:`1`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`}]],oo=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]],so=[[`path`,{d:`m14 10 7-7`}],[`path`,{d:`M20 10h-6V4`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M4 14h6v6`}]],co=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],lo=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],uo=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],fo=[[`path`,{d:`M12 22v-5`}],[`path`,{d:`M15 8V2`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`}],[`path`,{d:`M9 8V2`}]],po=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],mo=[[`path`,{d:`M12 2v10`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`}]],ho=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],go=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],_o=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],vo=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],yo=[[`path`,{d:`m10.852 14.772-.383.923`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`}],[`path`,{d:`m13.148 9.228.383-.923`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`}],[`path`,{d:`m14.772 10.852.923-.383`}],[`path`,{d:`m14.772 13.148.923.383`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`}],[`path`,{d:`M6 18h.01`}],[`path`,{d:`M6 6h.01`}],[`path`,{d:`m9.228 10.852-.923-.383`}],[`path`,{d:`m9.228 13.148-.923.383`}]],bo=[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`}]],xo=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]],So=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],Co=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}],[`path`,{d:`m9 12 2 2 4-4`}]],wo=[[`path`,{d:`m2 2 20 20`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`}]],To=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}]],Eo=[[`path`,{d:`m18 14 4 4-4 4`}],[`path`,{d:`m18 2 4 4-4 4`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`}]],Do=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],Oo=[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],ko=[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`}],[`circle`,{cx:`12`,cy:`14`,r:`8`}]],Ao=[[`path`,{d:`M10 11v6`}],[`path`,{d:`M14 11v6`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]],jo=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]],Mo=[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}],[`circle`,{cx:`12`,cy:`7`,r:`4`}]],No=[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`}]],Po=[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`}],[`path`,{d:`m14 7 3 3`}],[`path`,{d:`M5 6v4`}],[`path`,{d:`M19 14v4`}],[`path`,{d:`M10 2v2`}],[`path`,{d:`M7 8H3`}],[`path`,{d:`M21 16h-4`}],[`path`,{d:`M11 3H9`}]],Fo=[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`}]],Io=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],Lo=R(``),Ro=R(`
`,1);function zo(e,t){E(t,!0);let n=ya(t,`compact`,3,!1),r=[{value:`light`,icon:Do,label:`Light theme`},{value:`system`,icon:co,label:`System theme`},{value:`dark`,icon:lo,label:`Dark theme`}],i=O(()=>r.find(e=>e.value===ka.theme)||r[1]),a=O(()=>`Change theme (currently `+I(i).label+`)`);var o=Ro(),s=N(o);let c;H(s,21,()=>r,e=>e.value,(e,t)=>{var n=Lo();let r;G(M(n),{get icon(){return I(t).icon},class:`theme-icon`}),T(n),F(()=>{r=U(n,1,`theme-btn svelte-1keql7b`,null,r,{active:ka.theme===I(t).value}),W(n,`aria-pressed`,ka.theme===I(t).value),W(n,`title`,I(t).label),W(n,`aria-label`,I(t).label)}),L(`click`,n,()=>ka.set(I(t).value)),z(e,n)}),T(s);var l=P(s,2);let u;G(M(l),{get icon(){return I(i).icon},class:`theme-icon`}),T(l),F(()=>{c=U(s,1,`theme-toggle svelte-1keql7b`,null,c,{"is-compact":n()}),u=U(l,1,`theme-toggle-mobile svelte-1keql7b`,null,u,{"is-compact":n()}),W(l,`title`,I(a)),W(l,`aria-label`,I(a))}),L(`click`,l,()=>ka.toggle()),z(e,o),D()}Hr([`click`]);function Bo(){return typeof window>`u`?`/`:window.GOMODEL_BASE_PATH||`/`}function Vo(e){let t=Bo();return!e||e.charAt(0)!==`/`||e.indexOf(`//`)===0||t===`/`||e===t||e.indexOf(t+`/`)===0?e:t+e}function Ho(e){let t=Bo();return t===`/`||!e?e:e===t?`/`:e.indexOf(t+`/`)===0?e.slice(t.length)||`/`:e}function Uo(){return typeof window>`u`?``:window.GOMODEL_VERSION||``}function Wo(){return typeof window>`u`?!1:window.GOMODEL_DEMO_MODE===!0}var Go=[`overview`,`usage`,`budgets`,`rate-limits`,`models`,`workflows`,`audit-logs`,`guardrails`,`mcp-servers`,`providers-config`,`auth-keys`,`settings`];function Ko(e){return e.startsWith(`/admin/static/`)?`/`+e.slice(14).replace(/^\/+/,``):e}function qo(e){let t=Ko(Ho(e)).replace(/\/$/,``).replace(`/admin/dashboard`,``).replace(/^\//,``).split(`/`),n=t[0];n===`audit`&&(n=`audit-logs`);let r=t[1]||null;return n===`settings`&&r===`guardrails`?{page:`guardrails`,sub:null}:(n=Go.includes(n)?n:`overview`,{page:n,sub:r})}var Jo=new class{#e=k(`overview`);get page(){return I(this.#e)}set page(e){A(this.#e,e,!0)}#t=k(null);get sub(){return I(this.#t)}set sub(e){A(this.#t,e,!0)}init(){let{page:e,sub:t}=qo(window.location.pathname);this.page=e,this.sub=t,window.addEventListener(`popstate`,()=>{let{page:e,sub:t}=qo(window.location.pathname);this.page=e,this.sub=t})}navigate(e,t=null){let n=t?`/`+t:``;history.pushState(null,``,Vo(`/admin/dashboard/`+e+n)),this.page=e,this.sub=t}},Yo=`gomodel_api_key`;function Xo(e){let t=String(e||``).trim();if(/^Bearer\s*$/i.test(t))return``;let n=t.match(/^Bearer\s+(.+)$/i);return n?n[1].trim():t}var K=new class{#e=k(``);get apiKey(){return I(this.#e)}set apiKey(e){A(this.#e,e,!0)}#t=k(!1);get needsAuth(){return I(this.#t)}set needsAuth(e){A(this.#t,e,!0)}#n=k(!1);get authError(){return I(this.#n)}set authError(e){A(this.#n,e,!0)}#r=k(``);get authErrorMessage(){return I(this.#r)}set authErrorMessage(e){A(this.#r,e,!0)}#i=k(!1);get dialogOpen(){return I(this.#i)}set dialogOpen(e){A(this.#i,e,!0)}#a=k(0);get generation(){return I(this.#a)}set generation(e){A(this.#a,e,!0)}#o=k(0);get refreshTick(){return I(this.#o)}set refreshTick(e){A(this.#o,e,!0)}init(){try{this.apiKey=Xo(localStorage.getItem(Yo)||``)}catch{this.apiKey=``}}hasApiKey(){return Xo(this.apiKey)!==``}save(){this.apiKey=Xo(this.apiKey);try{localStorage.setItem(Yo,this.apiKey)}catch{}}openDialog(){this.dialogOpen=!0}closeDialog(){this.dialogOpen=!1}submit(){let e=Xo(this.apiKey);return e?(this.apiKey=e,this.save(),this.generation++,this.authError=!1,this.authErrorMessage=``,this.needsAuth=!1,this.closeDialog(),this.refresh(),!0):(this.apiKey=``,this.authError=!0,this.authErrorMessage=``,this.needsAuth=!0,this.openDialog(),!1)}refresh(){this.refreshTick++}handleUnauthorized(e,t=``){return typeof e==`number`&&e{r[e.type]=e.value}),r.year+`-`+r.month+`-`+r.day}formatTimestampInTimeZone(e,t){if(e==null)return`-`;let n=new Date(e);if(Number.isNaN(n.getTime()))return`-`;let r=ss(`en-CA`,{timeZone:cs(t)?t:rs,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(n),i={};return r.forEach(e=>{i[e.type]=e.value}),i.year+`-`+i.month+`-`+i.day+` `+i.hour+`:`+i.minute+`:`+i.second}formatTimestamp(e){return this.formatTimestampInTimeZone(e,this.effectiveTimezone())}currentDateKey(e){return this.dateKeyInTimeZone(e||new Date,this.effectiveTimezone())}dateKeyToDate(e){return Qo(e)}dateToDateKey(e){return $o(e)}addDaysToDateKey(e,t){return es(e,t)}todayDate(){return this.dateKeyToDate(this.currentDateKey())}startOfMonthDate(e){let t=e instanceof Date?e:this.todayDate();return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1))}timeZoneOffsetLabel(e,t){let n=cs(e)?e:rs;try{let e=ss(`en-US`,{timeZone:n,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`,timeZoneName:`longOffset`}).formatToParts(t||new Date).find(e=>e.type===`timeZoneName`);if(!e||!e.value)return`UTC+00:00`;let r=e.value.replace(`GMT`,`UTC`);return r===`UTC`?`UTC+00:00`:r}catch{return`UTC+00:00`}}timeZoneOffsetMinutes(e,t){let n=/^UTC([+-])(\d{2}):(\d{2})$/.exec(this.timeZoneOffsetLabel(e,t));if(!n)return 0;let r=Number(n[2])*60+Number(n[3]);return n[1]===`-`?-r:r}timeZoneOptionLabel(e,t){return e+` (`+this.timeZoneOffsetLabel(e,t)+`)`}detectedTimeZoneLabel(){return this.timeZoneOptionLabel(this.detectedTimezone)}effectiveTimeZoneLabel(){return this.timeZoneOptionLabel(this.effectiveTimezone())}ensureOptions(){if(this.optionsLoaded)return;let e=new Date,t=[];try{typeof Intl.supportedValuesOf==`function`&&(t=Intl.supportedValuesOf(`timeZone`))}catch{t=[]}[rs,this.detectedTimezone,this.override].forEach(e=>{e&&t.indexOf(e)===-1&&cs(e)&&t.push(e)}),t=t.filter(e=>cs(e)),t.sort((t,n)=>{let r=this.timeZoneOffsetMinutes(t,e)-this.timeZoneOffsetMinutes(n,e);return r===0?t.localeCompare(n):r}),this.options=t.map(t=>({value:t,label:this.timeZoneOptionLabel(t,e)})),this.optionsLoaded=!0}saveOverride(){let e=wa();if(e)if(this.override&&cs(this.override))try{e.setItem(is,this.override)}catch{}else{try{e.removeItem(is)}catch{}this.override=``}this.optionsLoaded=!1,this.ensureOptions()}clearOverride(){let e=wa();if(e)try{e.removeItem(is)}catch{}this.override=``}calendarTimeZoneText(){let e=this.override?`manual override`:`auto-detected`;return`Activity grouped by `+this.effectiveTimeZoneLabel()+` (`+e+`)`}};function fs(e,t){let n=e&&typeof e==`object`&&e.error&&e.error.message;return(typeof n==`string`?n.trim():``)||t}function ps(e,t){let n=e&&e.data;if(n&&typeof n==`object`){let e=[n.message,n.error,n.error&&typeof n.error==`object`?n.error.message:null];for(let t of e)if(typeof t==`string`&&t.trim())return t.trim()}return t}function ms(){let e={"Content-Type":`application/json`},t=Xo(K.apiKey);return t&&(e.Authorization=`Bearer `+t),e[`X-GoModel-Timezone`]=ds.effectiveTimezone(),e}function hs(e,t={}){return fetch(Vo(e),{...t,headers:{...ms(),...t.headers||{}}})}async function gs(e,t,{label:n=e,parse:r=!0}={}){let i=K.generation,a=await hs(e,t);if(a.status===401)return K.handleUnauthorized(i),{ok:!1,stale:ie.trim()).filter(Boolean);return e.length>0?e:xs}cacheVisible(){if(this.flag(`CACHE_ENABLED`)!==``)return this.booleanFlag(`CACHE_ENABLED`,!1);let e=this.flag(`REDIS_URL`),t=this.flag(`SEMANTIC_CACHE_ENABLED`);return e===``&&t===``||this.booleanFlag(`REDIS_URL`,!1)||this.booleanFlag(`SEMANTIC_CACHE_ENABLED`,!1)}auditVisible(){return this.booleanFlag(`LOGGING_ENABLED`,!0)}usageVisible(){return this.booleanFlag(`USAGE_ENABLED`,!0)}budgetsVisible(){return this.booleanFlag(`BUDGETS_ENABLED`,!0)}rateLimitsVisible(){return this.booleanFlag(`RATE_LIMITS_ENABLED`,!0)}guardrailsVisible(){return this.booleanFlag(`GUARDRAILS_ENABLED`,!0)}mcpVisible(){return this.booleanFlag(`MCP_ENABLED`,!0)}liveLogsVisible(){return this.booleanFlag(`DASHBOARD_LIVE_LOGS_ENABLED`,!0)}fetch(){return this.#n||=this.#r().finally(()=>{this.#n=null}),this.#n}async ensureLoaded(){if(this.#n){await this.#n;return}this.loaded||await this.fetch()}async#r(){let e=typeof AbortController==`function`?new AbortController:null,t=e?setTimeout(()=>e.abort(),1e4):null;try{let t=await _s(`/admin/runtime/config`,{label:`dashboard config`,signal:e?e.signal:void 0});if(t.stale)return;if(!t.ok){this.config={},this.loaded=!1;return}let n=t.data,r={};for(let e of bs)n&&typeof n==`object`&&!Array.isArray(n)&&n[e]!==void 0&&n[e]!==null&&(r[e]=String(n[e]).trim());this.config=r,this.loaded=!0}catch(e){console.error(`Failed to fetch dashboard config:`,e),this.config={},this.loaded=!1}finally{t!==null&&clearTimeout(t)}}},Cs=[{page:`overview`,label:`Overview`,icon:ro},{page:`providers-config`,label:`Providers`,icon:yo},{page:`models`,label:`Models`,icon:Fa},{page:`audit-logs`,label:`Audit Logs`,icon:eo},{page:`usage`,label:`Usage`,icon:Ba},{page:`budgets`,label:`Budgets`,icon:No,visible:()=>Ss.budgetsVisible()},{page:`rate-limits`,label:`Rate Limits`,icon:$a,visible:()=>Ss.rateLimitsVisible()},{page:`auth-keys`,label:`API Keys`,icon:no},{page:`workflows`,label:`Workflows`,icon:Fo},{page:`guardrails`,label:`Guardrails (experimental)`,icon:Co,visible:()=>Ss.guardrailsVisible()},{page:`mcp-servers`,label:`MCP Servers`,icon:fo,visible:()=>Ss.mcpVisible()},{page:`settings`,label:`Settings`,icon:So}],ws=R(` `),Ts=R(`
`),Es=R(` `,1);function Ds(e,t){E(t,!0);let n=O(()=>Cs.filter(e=>!e.visible||e.visible())),r=k(null),i=0,a=0,o=!1;function s(e){e.button===0&&(e.preventDefault(),A(r,e.pointerId,!0),i=e.clientX,a=Aa.width,o=!1,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`sidebar-resizing`))}function c(e){e.pointerId===I(r)&&(!o&&Math.abs(e.clientX-i)<=4||(o=!0,Aa.setWidth(Oa(a,i,e.clientX))))}function l(e){I(r)===null||e.pointerId!==void 0&&e.pointerId!==I(r)||(A(r,null),document.body.classList.remove(`sidebar-resizing`),Aa.setWidth(Aa.width,!0))}function u(){if(o){o=!1;return}Aa.toggle()}function d(e){let t;if(e.key===`ArrowLeft`)t=Aa.width-12;else if(e.key===`ArrowRight`)t=Aa.width+12;else if(e.key===`Home`)t=60;else if(e.key===`End`)t=240;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),Aa.toggle();return}else return;e.preventDefault(),Aa.setWidth(t,!0)}var f=Es(),p=N(f);let m;var h=M(p),g=M(h);Ca(M(g),{}),T(g),Ue(4),T(h);var _=P(h,2);H(_,21,()=>I(n),e=>e.page,(e,t)=>{var n=ws();let r;var i=M(n);G(i,{get icon(){return I(t).icon},class:`nav-icon`});var a=P(i,2),o=M(a,!0);T(a),T(n),F(e=>{W(n,`href`,e),r=U(n,1,`nav-item svelte-1nwtzae`,null,r,{active:Jo.page===I(t).page}),W(n,`title`,I(t).label),B(o,I(t).label)},[()=>Vo(`/admin/dashboard/`+I(t).page)]),L(`click`,n,e=>{e.preventDefault(),Jo.navigate(I(t).page)}),z(e,n)}),T(_);var v=P(_,2),y=M(v);zo(y,{get compact(){return Aa.collapsed}});var b=P(y,2),x=e=>{var t=Ts(),n=M(t),r=M(n);G(r,{get icon(){return ao},class:`api-key-open-icon`});var i=P(r,2),a=M(i,!0);T(i),T(n),T(t),F(()=>{W(n,`aria-label`,K.needsAuth?`Enter API key`:`Change API key`),B(a,K.needsAuth?`Enter API key`:`Change API key`)}),L(`click`,n,()=>K.openDialog()),z(e,t)},S=O(()=>K.needsAuth||K.hasApiKey());V(b,e=>{I(S)&&e(x)}),T(v),T(p);var C=P(p,2);F(()=>{m=U(p,1,`sidebar svelte-1nwtzae`,null,m,{"sidebar-collapsed":Aa.collapsed,"sidebar-resizing":I(r)!==null}),W(C,`aria-valuemin`,60),W(C,`aria-valuemax`,240),W(C,`aria-valuenow`,Aa.width)}),L(`pointerdown`,C,s),L(`pointermove`,C,c),L(`pointerup`,C,l),Vr(`pointercancel`,C,l),Vr(`lostpointercapture`,C,l),L(`keydown`,C,d),L(`click`,C,u),z(e,f),D()}Hr([`click`,`pointerdown`,`pointermove`,`pointerup`,`keydown`]);var Os=R(``);function ks(e,t){E(t,!0);let n=ya(t,`label`,3,`Close`),r=ya(t,`class`,3,``),i=ya(t,`iconClass`,3,`table-icon-svg`),a=ya(t,`disabled`,3,!1),o=ya(t,`el`,15,null);var s=Os();G(M(s),{get icon(){return Io},get class(){return i()}}),T(s),ga(s,e=>o(e),()=>o()),F(()=>{U(s,1,Fi([`dialog-close-btn`,r()]),`svelte-11l1bb5`),W(s,`aria-label`,n()),s.disabled=a()}),L(`click`,s,function(...e){t.onclick?.apply(this,e)}),z(e,s),D()}Hr([`click`]);function As(e){return t=>{let n=n=>{t.contains(n.target)||e()},r=t=>{t.key===`Escape`&&e()};return document.addEventListener(`click`,n,!0),window.addEventListener(`keydown`,r),()=>{document.removeEventListener(`click`,n,!0),window.removeEventListener(`keydown`,r)}}}function js(e=`[data-modal-autofocus]`){return t=>{let n=t.querySelector(e);n&&typeof n.focus==`function`&&n.focus()}}var Ms=R(`
`,1);function Ns(e,t){E(t,!0);let n=ya(t,`open`,3,!1),r=ya(t,`variant`,3,`editor`),i=ya(t,`closeOnBackdrop`,3,!0),a=O(()=>r()===`auth`?`auth-dialog-backdrop`:`editor-modal-backdrop`),o=O(()=>r()===`auth`?`auth-dialog-shell`:`editor-modal-shell`);An(()=>{if(!n())return;let e=Er(()=>ja.opened()),r=n=>{n.key===`Escape`&&ja.isTop(e)&&t.onclose?.()};return window.addEventListener(`keydown`,r),()=>{ja.closed(e),window.removeEventListener(`keydown`,r)}});function s(e){i()&&e.target===e.currentTarget&&t.onclose?.()}var c=Qr(),l=N(c),u=e=>{var n=Ms(),r=N(n),i=P(r,2);gi(M(i),()=>t.children??f),T(i),Mi(i,js),F(()=>{U(r,1,Fi(I(a)),`svelte-17e0w4c`),U(i,1,Fi(I(o)),`svelte-17e0w4c`)}),L(`click`,i,s),z(e,n)};V(l,e=>{n()&&e(u)}),z(e,c),D()}Hr([`click`]);var Ps=R(``),Fs=R(``);function Is(e,t){E(t,!0),Ns(e,{get open(){return K.dialogOpen},variant:`auth`,onclose:()=>K.closeDialog(),children:(e,t)=>{var n=Fs(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a),T(i),ks(P(i,2),{label:`Close authentication dialog`,onclick:()=>K.closeDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var s=P(r,2),c=M(s),l=M(c);G(l,{get icon(){return ao},class:`auth-dialog-input-icon`});var u=P(l,2);na(u),T(c);var d=P(c,2),f=e=>{var t=Ps(),n=M(t,!0);T(t),F(()=>B(n,K.authErrorMessage||`Enter a valid API key to continue.`)),z(e,t)};V(d,e=>{K.authError&&e(f)});var p=P(d,4),m=M(p),h=M(m);G(h,{get icon(){return Va},class:`auth-dialog-submit-icon`});var g=P(h,2),_=M(g,!0);T(g),T(m),T(p),T(s),T(n),F(()=>{B(o,K.needsAuth?`Dashboard locked`:`Change API key`),B(_,K.needsAuth?`Unlock dashboard`:`Save API key`)}),Vr(`submit`,s,e=>{e.preventDefault(),K.submit()}),da(u,()=>K.apiKey,e=>K.apiKey=e),z(e,n)},$$slots:{default:!0}}),D()}function Ls(){return{open:!1,title:``,titleId:`typedConfirmationDialogTitle`,inputId:`typed-confirmation-input`,message:``,requiredText:``,value:``,confirmLabel:`Confirm`,icon:jo,dialogClass:``,loading:!1,onConfirm:null,onClose:null}}var Rs=new class{#e=k(j(Ls()));get state(){return I(this.#e)}set state(e){A(this.#e,e,!0)}#t=k(``);get error(){return I(this.#t)}set error(e){A(this.#t,e,!0)}open(e){this.error=``,this.state={...Ls(),open:!0,...e||{}}}close(){let e=this.state;typeof e.onClose==`function`&&e.onClose(),this.state=Ls(),this.error=``}ready(){return String(this.state.value||``).trim().toLowerCase()===String(this.state.requiredText||``).trim().toLowerCase()}inputLabel(){return`Type `+String(this.state.requiredText||``).trim()+` to confirm`}async submit(){if(!this.ready()){this.error=this.inputLabel()+`.`;return}if(typeof this.state.onConfirm==`function`){this.state.loading=!0;try{await this.state.onConfirm()}finally{this.state.loading=!1}}}},zs=R(`

`),Bs=R(``),Vs=R(`

`);function Hs(e,t){E(t,!0);let n=O(()=>Rs.state);Ns(e,{get open(){return I(n).open},variant:`auth`,onclose:()=>Rs.close(),children:(e,t)=>{var r=Vs(),i=M(r),a=M(i),o=M(a,!0);T(a),ks(P(a,2),{label:`Close confirmation dialog`,onclick:()=>Rs.close(),class:`auth-dialog-close`,iconClass:``}),T(i);var s=P(i,2),c=M(s),l=e=>{var t=zs(),r=M(t,!0);T(t),F(()=>B(r,I(n).message)),z(e,t)};V(c,e=>{I(n).message&&e(l)});var u=P(c,2),d=M(u),f=M(d,!0);T(d);var p=P(d,2);na(p),T(u);var m=P(u,2),h=e=>{var t=Bs(),n=M(t,!0);T(t),F(()=>B(n,Rs.error)),z(e,t)};V(m,e=>{Rs.error&&e(h)});var g=P(m,2),_=M(g),v=P(_,2),y=M(v);G(y,{get icon(){return I(n).icon},class:`form-action-icon`});var b=P(y,2),x=M(b,!0);T(b),T(v),T(g),T(s),T(r),F((e,t)=>{U(r,1,`auth-dialog ${I(n).dialogClass??``}`),W(r,`aria-labelledby`,I(n).titleId),W(a,`id`,I(n).titleId),B(o,I(n).title),W(d,`for`,I(n).inputId),B(f,e),W(p,`id`,I(n).inputId),v.disabled=t,B(x,I(n).confirmLabel)},[()=>Rs.inputLabel(),()=>I(n).loading||!Rs.ready()]),Vr(`submit`,s,e=>{e.preventDefault(),Rs.submit()}),da(p,()=>Rs.state.value,e=>Rs.state.value=e),L(`click`,_,()=>Rs.close()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var Us=e=>e;function Ws(e){let t=e-1;return t*t*t+1}function Gs(e){let t=typeof e==`string`&&e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);return t?[parseFloat(t[1]),t[2]||`px`]:[e,`px`]}function Ks(e,{delay:t=0,duration:n=400,easing:r=Us}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}function qs(e,{delay:t=0,duration:n=400,easing:r=Ws,x:i=0,y:a=0,opacity:o=0}={}){let s=getComputedStyle(e),c=+s.opacity,l=s.transform===`none`?``:s.transform,u=c*(1-o),[d,f]=Gs(i),[p,m]=Gs(a);return{delay:t,duration:n,easing:r,css:(e,t)=>` - transform: ${l} translate(${(1-e)*d}${f}, ${(1-e)*p}${m}); - opacity: ${c-u*t}`}}function Js(e,{delay:t=0,duration:n=400,easing:r=Ws,axis:i=`y`}={}){let a=getComputedStyle(e),o=+a.opacity,s=i===`y`?`height`:`width`,c=parseFloat(a[s]),l=i===`y`?[`top`,`bottom`]:[`left`,`right`],u=l.map(e=>`${e[0].toUpperCase()}${e.slice(1)}`),d=parseFloat(a[`padding${u[0]}`]),f=parseFloat(a[`padding${u[1]}`]),p=parseFloat(a[`margin${u[0]}`]),m=parseFloat(a[`margin${u[1]}`]),h=parseFloat(a[`border${u[0]}Width`]),g=parseFloat(a[`border${u[1]}Width`]);return{delay:t,duration:n,easing:r,css:e=>`overflow: hidden;opacity: ${Math.min(e*20,1)*o};${s}: ${e*c}px;padding-${l[0]}: ${e*d}px;padding-${l[1]}: ${e*f}px;margin-${l[0]}: ${e*p}px;margin-${l[1]}: ${e*m}px;border-${l[0]}-width: ${e*h}px;border-${l[1]}-width: ${e*g}px;min-${s}: 0`}}function Ys(e){return--e*e*(2.70158*e+1.70158)+1}function Xs(e){let t=e-1;return t*t*t+1}var Zs=5e3,Qs=8e3,q=new class{#e=k(j([]));get toasts(){return I(this.#e)}set toasts(e){A(this.#e,e,!0)}#t=0;#n=new Map;success(e){this.#r(`success`,e,Zs)}error(e){this.#r(`error`,e,Qs)}dismiss(e){let t=this.#n.get(e);t&&(clearTimeout(t),this.#n.delete(e)),this.toasts=this.toasts.filter(t=>t.id!==e)}#r(e,t,n){let r=String(t||``).trim();if(!r)return;let i=this.toasts.find(t=>t.kind===e&&t.text===r);i&&this.dismiss(i.id);let a=++this.#t;this.toasts=[...this.toasts,{id:a,kind:e,text:r}],this.#n.set(a,setTimeout(()=>this.dismiss(a),n))}},$s=R(`
`),ec=R(`
`);function tc(e,t){E(t,!0);var n=ec();H(n,21,()=>q.toasts,e=>e.id,(e,t)=>{var n=$s();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2);T(n),F(()=>{r=U(n,1,`flash-toast svelte-1i257xg`,null,r,{"flash-toast-success":I(t).kind===`success`,"flash-toast-error":I(t).kind===`error`}),W(n,`role`,I(t).kind===`error`?`alert`:`status`),W(n,`aria-live`,I(t).kind===`error`?`assertive`:`polite`),B(a,I(t).text)}),L(`click`,o,()=>q.dismiss(I(t).id)),ki(1,n,()=>qs,()=>({y:-24,duration:360,easing:Ys})),ki(2,n,()=>Ks,()=>({duration:150})),z(e,n)}),T(n),z(e,n),D()}Hr([`click`]);var nc=R(``);function rc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{z(e,nc())},a=O(()=>Wo());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}function ic(e){return String(e||``).split(`,`).map(e=>e.trim()).filter(e=>e)}function ac(e){if(e==null||e===``)return`Not captured`;if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function oc(e){return e==null||e===void 0?`-`:e.toLocaleString()}function sc(e){if(e==null)return`---`;let t=Number(e);return Number.isFinite(t)?t>0&&t<1e-4?`<$0.0001`:`$`+t.toFixed(4).replace(/(\.\d{2}\d*?)0+$/,`$1`):`---`}function cc(e){return e==null||e===void 0?`—`:`$`+e.toFixed(2)}function lc(e){return e==null||e===void 0?`—`:e<.01?`$`+e.toFixed(6):`$`+e.toFixed(4)}function uc(e){if(e==null||e===``)return`-`;let t=Number(e);if(!Number.isFinite(t))return`-`;let n=Math.abs(t),r=[{threshold:1e9,suffix:`B`},{threshold:1e6,suffix:`M`},{threshold:1e3,suffix:`K`}];for(let e=0;e=i.threshold){let n=t/i.threshold;return Math.abs(Number(n.toFixed(1)))>=1e3&&e>0&&(i=r[e-1],n=t/i.threshold),n.toFixed(1).replace(/\.0$/,``)+i.suffix}}return String(t)}function dc(e,t){let n=t==null||t===``?NaN:Number(t),r=Number.isFinite(n)?oc(n):`-`;return String(e||`Tokens`)+`: `+r}function fc(e){return e?typeof e==`string`?e:e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`):``}function pc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)}function mc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)+` `+String(t.getUTCHours()).padStart(2,`0`)+`:`+String(t.getUTCMinutes()).padStart(2,`0`)+`:`+String(t.getUTCSeconds()).padStart(2,`0`)+` UTC`}function hc(e){return String(e&&e.provider||``).trim()}function gc(e){return String(e&&e.provider_name||``).trim()||hc(e)}function _c(e,t){let n=String(t||``).trim();if(!n)return`-`;let r=gc(e);return!r||n===r||n.startsWith(r+`/`)?n:r+`/`+n}function vc(e){return _c(e,e&&e.model)}function yc(e){return _c(e,e&&e.resolved_model)}function bc(e){let t=String(e&&(e.requested_model||e.model)||``).trim();if(!e)return t;let n=String(e.data&&e.data.failover&&e.data.failover.target_model||``).trim();if(n&&n!==t)return t+` ⮕ `+n;if(e.alias_used&&e.resolved_model){let n=yc(e);if(n&&n!==`-`&&n!==t)return t+` ⮕ `+n}return t}var xc=`gomodel_date_range`,Sc=1;function Cc(e){return/^[1-9]\d*$/.test(String(e??``))}var wc=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Tc({selectedPreset:e,startKey:t,endKey:n,followsToday:r}){return e&&Cc(e)?{v:Sc,mode:`preset`,days:String(e)}:e?null:ts(t)&&ts(n)?{v:Sc,mode:`custom`,start:t,end:n,follow:r===!0}:null}function Ec(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return null}return!t||typeof t!=`object`?null:t.mode===`preset`?Cc(t.days)?{mode:`preset`,days:String(t.days)}:null:t.mode===`custom`&&ts(t.start)&&ts(t.end)&&t.start<=t.end?{mode:`custom`,start:t.start,end:t.end,follow:t.follow===!0}:null}function Dc(e,t,n){let r=ns(e,t);return r<1||!ts(n)?{start:e,end:t}:{start:es(n,-(r-1)),end:n}}function Oc(e,t){if(e===t)return`Today`;let[n,r,i]=e.split(`-`);return wc[Number(r)-1]+` `+Number(i)+`, `+n}function kc({selectedPreset:e,startKey:t,endKey:n,followsToday:r,todayKey:i}){if(e)return`Last `+e+` days`;if(!ts(t)||!ts(n))return``;let a=ns(t,n);return r||n===i?a===1?`Today`:`Last `+a+` days`:a===1?`1 day`:a+` days`}function Ac({selectedPreset:e,startKey:t,endKey:n,todayKey:r}){if(e)return`Last `+e+` days`;let i=e=>Oc(e,r);return ts(t)&&ts(n)?t===n?i(t):i(t)+` – `+i(n):ts(t)?i(t)+` – ...`:`Last 30 days`}var jc=6e4,Mc=new class{#e=k(j(`30`));get days(){return I(this.#e)}set days(e){A(this.#e,e,!0)}#t=k(j(`30`));get selectedPreset(){return I(this.#t)}set selectedPreset(e){A(this.#t,e,!0)}#n=k(null);get customStartDate(){return I(this.#n)}set customStartDate(e){A(this.#n,e,!0)}#r=k(null);get customEndDate(){return I(this.#r)}set customEndDate(e){A(this.#r,e,!0)}#i=k(!1);get followsToday(){return I(this.#i)}set followsToday(e){A(this.#i,e,!0)}#a=k(`daily`);get interval(){return I(this.#a)}set interval(e){A(this.#a,e,!0)}#o=k(0);get syncTick(){return I(this.#o)}set syncTick(e){A(this.#o,e,!0)}init(){this.restore(),this.syncToToday(),typeof setInterval==`function`&&setInterval(()=>this.syncToToday(),jc)}queryStr(){return this.customStartDate&&this.customEndDate?`start_date=`+fc(this.customStartDate)+`&end_date=`+fc(this.customEndDate):`days=`+this.days}selectPreset(e){this.selectedPreset=e,this.customStartDate=null,this.customEndDate=null,this.followsToday=!1,this.days=e,this.persist()}selectStart(e){this.selectedPreset=null,this.customStartDate=e,this.customEndDate&&this.customEndDatet.category===e);return t?t.count:0}get filteredModels(){if(!this.filter)return this.models;let e=this.filter.toLowerCase();return this.models.filter(t=>(t.model?.id??``).toLowerCase().includes(e)||(t.provider_name??``).toLowerCase().includes(e)||(t.provider_type??``).toLowerCase().includes(e)||(t.selector??``).toLowerCase().includes(e)||(t.model?.owned_by??``).toLowerCase().includes(e)||(t.model?.metadata?.modes??[]).join(`,`).toLowerCase().includes(e)||(t.model?.metadata?.categories??[]).join(`,`).toLowerCase().includes(e))}},Pc=R(``);function Fc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Pc(),n=P(M(t),2);T(t),L(`click`,n,()=>K.openDialog()),z(e,t)};V(r,e=>{K.authError&&e(i)}),z(e,n),D()}Hr([`click`]);function Ic(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null}}function Lc(){return{summary:{total_hits:0,exact_hits:0,semantic_hits:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_saved_cost:null},daily:[]}}var Rc=new class{#e=k(j(Ic()));get summary(){return I(this.#e)}set summary(e){A(this.#e,e,!0)}#t=k(j([]));get daily(){return I(this.#t)}set daily(e){A(this.#t,e,!0)}#n=k(j(Lc()));get cacheOverview(){return I(this.#n)}set cacheOverview(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=null;#a=null;cacheAnalyticsEnabled(){return Ss.cacheVisible()}async fetchUsage(){this.#i&&this.#i.abort();let e=new AbortController;this.#i=e,this.loading=!0;try{let t=Mc.queryStr()+`&interval=`+Mc.interval,[n,r]=await Promise.all([_s(`/admin/usage/summary?`+t,{label:`usage summary`,signal:e.signal}),_s(`/admin/usage/daily?`+t,{label:`usage daily`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.summary=Ic(),this.daily=[],this.cacheOverview=Lc();return}this.summary=n.data||Ic(),this.daily=Array.isArray(r.data)?r.data:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch usage:`,e),this.summary=Ic(),this.daily=[]}finally{this.#i===e&&(this.#i=null,this.loading=!1)}}async fetchCacheOverview(e=``){if(await Ss.ensureLoaded(),!this.cacheAnalyticsEnabled()){this.cacheOverview=Lc();return}this.#a&&this.#a.abort();let t=new AbortController;this.#a=t;try{let n=await _s(`/admin/cache/overview?`+(Mc.queryStr()+`&interval=`+Mc.interval+e),{label:`cache overview`,signal:t.signal});if(n.stale||t.signal.aborted)return;if(!n.ok){this.cacheOverview=Lc();return}let r=n.data&&typeof n.data==`object`?n.data:Lc();r.summary||=Lc().summary,Array.isArray(r.daily)||(r.daily=[]),this.cacheOverview=r}catch(e){if(ys(e))return;console.error(`Failed to fetch cache overview:`,e),this.cacheOverview=Lc()}finally{this.#a===t&&(this.#a=null)}}},zc=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Bc(e,t){let n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return zc[n.getUTCMonth()]+` `+n.getUTCFullYear()}function Vc(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth()+t,a=new Date(Date.UTC(r,i,1)),o=new Date(Date.UTC(r,i+1,0)),s=(a.getUTCDay()+6)%7,c=[],l=new Date(Date.UTC(r,i,0));for(let e=s-1;e>=0;e--){let t=l.getUTCDate()-e,a=new Date(Date.UTC(r,i-1,t));c.push({day:t,date:a,current:!1,key:`p-`+n(a)})}for(let e=1;e<=o.getUTCDate();e++){let t=new Date(Date.UTC(r,i,e));c.push({day:e,date:t,current:!0,key:`c-`+n(t)})}let u=42-c.length;for(let e=1;e<=u;e++){let t=new Date(Date.UTC(r,i+1,e));c.push({day:e,date:t,current:!1,key:`n-`+n(t)})}return c}function Hc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return n&&r.getTime()>n.getTime()?e:r}function Uc(e,t){return e.getUTCFullYear()===t.getUTCFullYear()&&e.getUTCMonth()===t.getUTCMonth()}var Wc=R(``),Gc=R(``),Kc=R(``),qc=R(`
MoTuWeThFrSaSu
`);function Jc(e,t){E(t,!0);let n=ya(t,`offset`,3,0),r=O(()=>Vc(t.calendarMonth,n(),e=>ds.dateToDateKey(e))),i=O(()=>Uc(t.calendarMonth,ds.todayDate())),a=e=>ds.dateToDateKey(e.date),o=e=>a(e)>ds.currentDateKey(),s=e=>e.current&&a(e)===ds.currentDateKey();function c(e,t){let n=t===`start`?Mc.rangeStart():Mc.rangeEnd();return e.current&&!!n&&a(e)===ds.dateToDateKey(n)}function l(e){let t=Mc.rangeStart(),n=Mc.rangeEnd();return!e.current||!t||!n?!1:a(e)>=ds.dateToDateKey(t)&&a(e)<=ds.dateToDateKey(n)}var u=qc(),d=M(u),f=M(d);let p;var m=P(f,2),h=M(m,!0);T(m);var g=P(m,2),_=e=>{z(e,Wc())},v=e=>{var n=Gc();F(()=>n.disabled=I(i)),L(`click`,n,function(...e){t.onnext?.apply(this,e)}),z(e,n)};V(g,e=>{n()===-1?e(_):e(v,-1)}),T(d);var y=P(d,4);H(y,21,()=>I(r),e=>e.key,(e,n)=>{var r=Kc(),i=M(r,!0);T(r),F((e,t)=>{U(r,1,e,`svelte-g7ga4u`),r.disabled=t,B(i,I(n).day)},[()=>Fi([`dp-day`,{"other-month":!I(n).current,today:s(I(n)),"range-start":c(I(n),`start`),"range-end":c(I(n),`end`),"in-range":l(I(n)),disabled:o(I(n))}]),()=>o(I(n))||!I(n).current]),L(`click`,r,()=>t.onselect?.(I(n))),z(e,r)}),T(y),T(u),F(e=>{p=U(f,1,`dp-nav-btn svelte-g7ga4u`,null,p,{"dp-nav-prev-mobile":n()!==-1}),B(h,e)},[()=>Bc(t.calendarMonth,n())]),L(`click`,f,function(...e){t.onprev?.apply(this,e)}),z(e,u),D()}Hr([`click`]);var Yc=R(``),Xc=R(`
`),Zc=Xr(``),Qc=Xr(``),$c=R(`
`),el=R(`
`);function tl(e,t){E(t,!0);let n=[`3`,`7`,`14`,`30`,`90`],r=k(!1),i=k(`start`),a=k(j(new Date)),o=k(j({show:!1,x:0,y:0}));function s(){A(r,!I(r)),I(r)&&(Mc.syncToToday(),A(a,ds.startOfMonthDate(Mc.customEndDate||ds.todayDate()),!0),A(i,`start`))}function c(){A(r,!1),A(o,{show:!1,x:0,y:0},!0)}let l=Mc.syncTick;An(()=>{let e=Mc.syncTick;e!==l&&(l=e,t.onchange?.())});function u(e){Mc.selectPreset(e),A(i,`start`),t.onchange?.(),c()}let d=()=>A(a,Hc(I(a),-1),!0),f=()=>A(a,Hc(I(a),1,ds.startOfMonthDate(ds.todayDate())),!0);function p(e){let n=new Date(e.date);if(I(i)===`start`){Mc.selectStart(n),A(i,`end`),t.onchange?.();return}Mc.selectEnd(n),A(i,`start`),t.onchange?.(),c()}var m=el(),h=M(m),g=P(M(h),2),_=M(g,!0);T(g);var v=P(g,2);let y;T(h);var b=P(h,2),x=e=>{var t=Xc(),r=M(t);H(r,20,()=>n,e=>e,(e,t)=>{var n=Yc();let r;var i=M(n);T(n),F(()=>{r=U(n,1,`preset-btn svelte-ax7ma4`,null,r,{active:Mc.selectedPreset===t}),B(i,`Last ${t??``} days`)}),L(`click`,n,()=>u(t)),z(e,n)}),T(r);var i=P(r,2);H(i,20,()=>[-1,0],e=>e,(e,t)=>{Jc(e,{get calendarMonth(){return I(a)},get offset(){return t},onprev:d,onnext:f,onselect:p})}),T(i),T(t),L(`mousemove`,i,e=>A(o,{show:!0,x:e.clientX,y:e.clientY},!0)),Vr(`mouseleave`,i,()=>A(o,{show:!1,x:0,y:0},!0)),z(e,t)};V(b,e=>{I(r)&&e(x)});var S=P(b,2),C=e=>{var t=$c(),n=M(t),r=e=>{z(e,Zc())},a=e=>{z(e,Qc())};V(n,e=>{I(i)===`start`?e(r):e(a,-1)});var s=P(n,2),c=M(s,!0);T(s),T(t),F(()=>{Hi(t,`left:${I(o).x??``}px;top:${I(o).y??``}px`),B(c,I(i)===`end`?`Select end date`:`Select start date`)}),z(e,t)};V(S,e=>{I(o).show&&e(C)}),T(m),Mi(m,()=>I(r)?As(c):void 0),F((e,t)=>{W(h,`title`,e),B(_,t),y=U(v,0,`date-picker-chevron svelte-ax7ma4`,null,y,{open:I(r)})},[()=>Mc.dateRangeSpanLabel(),()=>Mc.dateRangeLabel()]),L(`click`,h,s),z(e,m),D()}Hr([`click`,`mousemove`]);function nl(e){return e+.5|0}var rl=(e,t,n)=>Math.max(Math.min(e,n),t);function il(e){return rl(nl(e*2.55),0,255)}function al(e){return rl(nl(e*255),0,255)}function ol(e){return rl(nl(e/2.55)/100,0,1)}function sl(e){return rl(nl(e*100),0,100)}var cl={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},ll=[...`0123456789ABCDEF`],ul=e=>ll[e&15],dl=e=>ll[(e&240)>>4]+ll[e&15],fl=e=>(e&240)>>4==(e&15),pl=e=>fl(e.r)&&fl(e.g)&&fl(e.b)&&fl(e.a);function ml(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&cl[e[1]]*17,g:255&cl[e[2]]*17,b:255&cl[e[3]]*17,a:t===5?cl[e[4]]*17:255}:(t===7||t===9)&&(n={r:cl[e[1]]<<4|cl[e[2]],g:cl[e[3]]<<4|cl[e[4]],b:cl[e[5]]<<4|cl[e[6]],a:t===9?cl[e[7]]<<4|cl[e[8]]:255})),n}var hl=(e,t)=>e<255?t(e):``;function gl(e){var t=pl(e)?ul:dl;return e?`#`+t(e.r)+t(e.g)+t(e.b)+hl(e.a,t):void 0}var _l=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function vl(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function yl(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function bl(e,t,n){let r=vl(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function xl(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=xl(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function Cl(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(al)}function wl(e,t,n){return Cl(vl,e,t,n)}function Tl(e,t,n){return Cl(bl,e,t,n)}function El(e,t,n){return Cl(yl,e,t,n)}function Dl(e){return(e%360+360)%360}function Ol(e){let t=_l.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?il(+t[5]):al(+t[5]));let i=Dl(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?Tl(i,a,o):t[1]===`hsv`?El(i,a,o):wl(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function kl(e,t){var n=Sl(e);n[0]=Dl(n[0]+t),n=wl(n),e.r=n[0],e.g=n[1],e.b=n[2]}function Al(e){if(!e)return;let t=Sl(e),n=t[0],r=sl(t[1]),i=sl(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${ol(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var jl={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},Ml={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function Nl(){let e={},t=Object.keys(Ml),n=Object.keys(jl),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var Pl;function Fl(e){Pl||(Pl=Nl(),Pl.transparent=[0,0,0,0]);let t=Pl[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var Il=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Ll(e){let t=Il.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?il(e):rl(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?il(r):rl(r,0,255)),i=255&(t[4]?il(i):rl(i,0,255)),a=255&(t[6]?il(a):rl(a,0,255)),{r,g:i,b:a,a:n}}}function Rl(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${ol(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var zl=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,Bl=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Vl(e,t,n){let r=Bl(ol(e.r)),i=Bl(ol(e.g)),a=Bl(ol(e.b));return{r:al(zl(r+n*(Bl(ol(t.r))-r))),g:al(zl(i+n*(Bl(ol(t.g))-i))),b:al(zl(a+n*(Bl(ol(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Hl(e,t,n){if(e){let r=Sl(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=wl(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Ul(e,t){return e&&Object.assign(t||{},e)}function Wl(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=al(e[3]))):(t=Ul(e,{r:0,g:0,b:0,a:1}),t.a=al(t.a)),t}function Gl(e){return e.charAt(0)===`r`?Ll(e):Ol(e)}var Kl=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Wl(t):n===`string`&&(r=ml(t)||Fl(t)||Gl(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Ul(this._rgb);return e&&(e.a=ol(e.a)),e}set rgb(e){this._rgb=Wl(e)}rgbString(){return this._valid?Rl(this._rgb):void 0}hexString(){return this._valid?gl(this._rgb):void 0}hslString(){return this._valid?Al(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Vl(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=al(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=nl(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Hl(this._rgb,2,e),this}darken(e){return Hl(this._rgb,2,-e),this}saturate(e){return Hl(this._rgb,1,e),this}desaturate(e){return Hl(this._rgb,1,-e),this}rotate(e){return kl(this._rgb,e),this}};function ql(){}var Jl=(()=>{let e=0;return()=>e++})();function Yl(e){return e==null}function Xl(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function Zl(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function Ql(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function $l(e,t){return Ql(e)?e:t}function eu(e,t){return e===void 0?t:e}var tu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,nu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function ru(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function iu(e,t,n,r){let i,a,o;if(Xl(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function pu(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function mu(e){let t=pu(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function hu(e,t){return(fu[t]||(fu[t]=mu(t)))(e)}function gu(e){return e.charAt(0).toUpperCase()+e.slice(1)}var _u=e=>e!==void 0,vu=e=>typeof e==`function`,yu=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function bu(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var xu=Math.PI,Su=2*xu,Cu=Su+xu,wu=1/0,Tu=xu/180,Eu=xu/2,Du=xu/4,Ou=xu*2/3,ku=Math.log10,Au=Math.sign;function ju(e,t,n){return Math.abs(e-t)e-t).pop(),t}function Pu(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Fu(e){return!Pu(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Iu(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Lu(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Yu(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var Xu=(e,t,n,r)=>Yu(e,n,r?r=>{let i=e[r][t];return ie[r][t]Yu(e,n,r=>e[r][t]>=n);function Qu(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+gu(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function td(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&($u.forEach(t=>{delete e[t]}),delete e._chartjs)}function nd(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var rd=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function id(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,rd.call(window,()=>{r=!1,e.apply(t,n)}))}}function ad(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var od=e=>e===`start`?`left`:e===`end`?`right`:`center`,sd=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,cd=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function ld(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(Xu(c,u,d).lo,n?r:Xu(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!Yl(e[s.axis]));i-=Math.max(0,e)}i=Ku(i,0,r-1)}if(m){let e=Math.max(Xu(c,o.axis,f,!0).hi+1,n?0:Xu(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!Yl(e[s.axis]));e+=Math.max(0,t)}a=Ku(e,i,r)-i}else a=r-i}return{start:i,count:a}}function ud(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var dd=e=>e===0||e===1,fd=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*Su/n)),pd=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*Su/n)+1,md={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Eu)+1,easeOutSine:e=>Math.sin(e*Eu),easeInOutSine:e=>-.5*(Math.cos(xu*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>dd(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>dd(e)?e:fd(e,.075,.3),easeOutElastic:e=>dd(e)?e:pd(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return dd(e)?e:e<.5?.5*fd(e*2,t,n):.5+.5*pd(e*2-1,t,n)},easeInBack(e){return e*e*(2.70158*e-1.70158)},easeOutBack(e){return--e*e*(2.70158*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-md.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?md.easeInBounce(e*2)*.5:md.easeOutBounce(e*2-1)*.5+.5};function hd(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function gd(e){return hd(e)?e:new Kl(e)}function _d(e){return hd(e)?e:new Kl(e).saturate(.5).darken(.1).hexString()}var vd=[`x`,`y`,`borderWidth`,`radius`,`tension`],yd=[`color`,`borderColor`,`backgroundColor`];function bd(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:yd},numbers:{type:`number`,properties:vd}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function xd(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var Sd=new Map;function Cd(e,t){t||={};let n=e+JSON.stringify(t),r=Sd.get(n);return r||(r=new Intl.NumberFormat(e,t),Sd.set(n,r)),r}function wd(e,t,n){return Cd(t,n).format(e)}var Td={values(e){return Xl(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Ed(e,n)}let o=ku(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),wd(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(ku(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?Td.numeric.call(this,e,t,n):``}};function Ed(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Dd={formatters:Td};function Od(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Dd.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var kd=Object.create(null),Ad=Object.create(null);function jd(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>_d(t.backgroundColor),this.hoverBorderColor=(e,t)=>_d(t.borderColor),this.hoverColor=(e,t)=>_d(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return Md(this,e,t)}get(e){return jd(this,e)}describe(e,t){return Md(Ad,e,t)}override(e,t){return Md(kd,e,t)}route(e,t,n,r){let i=jd(this,e),a=jd(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return Zl(e)?Object.assign({},t,e):eu(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[bd,xd,Od]);function Pd(e){return!e||Yl(e.size)||Yl(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Fd(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Id(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function Vd(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Kd(e,a),c=0;c+e||0;function tf(e,t){let n={},r=Zl(t),i=r?Object.keys(t):t,a=Zl(e)?r?n=>eu(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=ef(a(e));return n}function nf(e){return tf(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function rf(e){return tf(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function af(e){let t=nf(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function of(e,t){e||={},t||=Nd.font;let n=eu(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=eu(e.style,t.style);r&&!(``+r).match(Qd)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:eu(e.family,t.family),lineHeight:$d(eu(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:eu(e.weight,t.weight),string:``};return i.string=Pd(i),i}function sf(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function lf(e,t){return Object.assign(Object.create(e),t)}function uf(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Ef(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>uf([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return hf(n,r,()=>Tf(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Df(e).includes(t)},ownKeys(e){return Df(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function df(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:ff(e,r),setContext:t=>df(e,t,n,r),override:i=>df(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return hf(e,t,()=>gf(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function ff(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:vu(n)?n:()=>n,isIndexable:vu(r)?r:()=>r}}var pf=(e,t)=>e?e+gu(t):t,mf=(e,t)=>Zl(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function hf(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function gf(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return vu(s)&&o.isScriptable(t)&&(s=_f(t,s,e,n)),Xl(s)&&s.length&&(s=vf(t,s,e,o.isIndexable)),mf(t,s)&&(s=df(s,i,a&&a[t],o)),s}function _f(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),mf(e,c)&&(c=Sf(i._scopes,i,e,c)),c}function vf(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(Zl(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=Sf(r,i,e,c);t.push(df(n,a,o&&o[e],s))}}return t}function yf(e,t,n){return vu(e)?e(t,n):e}var bf=(e,t)=>e===!0?t:typeof e==`string`?hu(t,e):void 0;function xf(e,t,n,r,i){for(let a of t){let t=bf(n,a);if(t){e.add(t);let a=yf(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function Sf(e,t,n,r){let i=t._rootScopes,a=yf(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=Cf(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=Cf(s,o,a,c,r),c===null)?!1:uf(Array.from(s),[``],i,a,()=>wf(t,n,r))}function Cf(e,t,n,r,i){for(;n;)n=xf(e,t,n,r,i);return n}function wf(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Xl(i)&&Zl(n)?n:i||{}}function Tf(e,t,n,r){let i;for(let a of t)if(i=Ef(pf(a,e),n),i!==void 0)return mf(e,i)?Sf(n,r,e,i):i}function Ef(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Df(e){let t=e._keys;return t||=e._keys=Of(e._scopes),t}function Of(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function kf(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;ste===`x`?`y`:`x`;function Nf(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=Hu(a,i),c=Hu(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Pf(e,t,n){let r=e.length,i,a,o,s,c,l=jf(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)If(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function Wf(e,t){return Uf(e).getPropertyValue(t)}var Gf=[`top`,`right`,`bottom`,`left`];function Kf(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Gf[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var qf=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Jf(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(qf(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Yf(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Uf(n),a=i.boxSizing===`border-box`,o=Kf(i,`padding`),s=Kf(i,`border`,`width`),{x:c,y:l,box:u}=Jf(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function Xf(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Vf(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Uf(a),s=Kf(o,`border`,`width`),c=Kf(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=Hf(o.maxWidth,a,`clientWidth`),i=Hf(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||wu,maxHeight:i||wu}}var Zf=e=>Math.round(e*10)/10;function Qf(e,t,n,r){let i=Uf(e),a=Kf(i,`margin`),o=Hf(i.maxWidth,e,`clientWidth`)||wu,s=Hf(i.maxHeight,e,`clientHeight`)||wu,c=Xf(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Kf(i,`border`,`width`),t=Kf(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=Zf(Math.min(l,o,c.maxWidth)),u=Zf(Math.min(u,s,c.maxHeight)),l&&!u&&(u=Zf(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=Zf(Math.floor(u*r))),{width:l,height:u}}function $f(e,t,n){let r=t||1,i=Zf(e.height*r),a=Zf(e.width*r);e.height=Zf(e.height),e.width=Zf(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var ep=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Bf()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function tp(e,t){let n=Wf(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function np(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function rp(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function ip(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=np(e,i,n),s=np(i,a,n),c=np(a,t,n);return np(np(o,s,n),np(s,c,n),n)}var ap=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},op=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function sp(e,t,n){return e?ap(t,n):op()}function cp(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function lp(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function up(e){return e===`angle`?{between:Gu,compare:Uu,normalize:Wu}:{between:Ju,compare:(e,t)=>e-t,normalize:e=>e}}function dp({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function fp(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=up(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(dp({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(dp({start:g,end:d,loop:f,count:o,style:p})),m}function mp(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function gp(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function _p(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=hp(n,i,a,r);return r===!0?vp(e,[{start:o,end:s,loop:a}],n,t):vp(e,gp(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,rd.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Ep=`transparent`,Dp={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=gd(e||Ep),i=r.valid&&gd(t||Ep);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},Op=class{constructor(e,t,n,r){let i=t[n];r=sf([e.to,r,i,e.from]);let a=sf([e.from,i,r]);this._active=!0,this._fn=e.fn||Dp[e.type||typeof a],this._easing=md[e.easing]||md.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=sf([e.to,t,r,e.from]),this._from=sf([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!Zl(i))return;let a={};for(let e of t)a[e]=i[e];(Xl(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=jp(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&Ap(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new Op(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return Tp.add(this._chart,n),!0}};function Ap(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function Up(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=zp(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function Gp(e,t){return lf(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Kp(e,t,n){return lf(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function qp(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var Jp=e=>e===`reset`||e===`none`,Yp=(e,t)=>t?e:Object.assign({},e),Xp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Fp(n,!0),values:null},Zp=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Rp(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&qp(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=eu(n.xAxisID,Wp(e,`x`)),a=t.yAxisID=eu(n.yAxisID,Wp(e,`y`)),o=t.rAxisID=eu(n.rAxisID,Wp(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&td(this._data,this),e._stacked&&qp(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(Zl(t)){let e=this._cachedMeta;this._data=Lp(t,e)}else if(n!==t){if(n){td(n,this);let e=this._cachedMeta;qp(e),e._parsed=[]}t&&Object.isExtensible(t)&&ed(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Rp(t.vScale,t),t.stack!==n.stack&&(r=!0,qp(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Up(this,t._parsed),t._stacked=Rp(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length||n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=Xl(r[e])?this.parseArrayData(n,r,e,t):Zl(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Yp(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new kp(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||Jp(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){Jp(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!Jp(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function $p(e){let t=e.iScale,n=Qp(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(_u(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function rm(e,t,n,r){return Xl(e)?nm(e,t,n,r):t[n.axis]=n.parse(e,r),t}function im(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):Au(e)}function sm(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(Yl(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[eu(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;dGu(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>Gu(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(Eu,u,f),_=m(xu,l,d),v=m(xu+Eu,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var gm=class extends Zp{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(Zl(n[e])){let{key:e=`value`}=this._parsing;i=t=>+hu(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*Su:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=wd(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=Yl(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},vm=class extends Zp{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=wd(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return kf.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(rt.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*xu,d=u,f,p=360/this.countVisibleElements();for(f=0;f{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?Ru(this.resolveDataElementOptions(e,t).angle||n):0}},ym=Object.freeze({__proto__:null,BarController:pm,BubbleController:mm,DoughnutController:gm,LineController:_m,PieController:class extends gm{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:vm,RadarController:class extends Zp{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return kf.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function bm(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var xm={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return bm()}parse(){return bm()}format(){return bm()}add(){return bm()}diff(){return bm()}startOf(){return bm()}endOf(){return bm()}}};function Sm(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?Zu:Xu;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!Yl(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!Yl(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function Cm(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var Am={evaluateInteractionItems:Cm,modes:{index(e,t,n,r){let i=Yf(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Tm(e,i,a,r,o):Om(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Yf(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Tm(e,i,a,r,o):Om(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Nm(e,t){return e.filter(e=>jm.indexOf(e.pos)===-1&&e.box.axis===t)}function Pm(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Fm(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=Pm(Mm(t,`left`),!0),i=Pm(Mm(t,`right`)),a=Pm(Mm(t,`top`),!0),o=Pm(Mm(t,`bottom`)),s=Nm(t,`x`),c=Nm(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Mm(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function zm(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Bm(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Vm(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!Zl(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&Bm(o,a.getPadding());let s=Math.max(0,t.outerWidth-zm(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-zm(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function Hm(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Um(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Wm(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);Bm(f,af(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Lm(c.concat(l),d);Wm(s.fullSize,p,d,m),Wm(c,p,d,m),Wm(l,p,d,m)&&Wm(c,p,d,m),Hm(p),Km(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,Km(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},iu(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},Jm=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},Ym=class extends Jm{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},Xm=`$chartjs`,Zm={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},Qm=e=>e===null||e===``;function $m(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[Xm]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,Qm(i)){let t=tp(e,`width`);t!==void 0&&(e.width=t)}if(Qm(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=tp(e,`height`);t!==void 0&&(e.height=t)}return e}var eh=ep?{passive:!0}:!1;function th(e,t,n){e&&e.addEventListener(t,n,eh)}function nh(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,eh)}function rh(e,t){let n=Zm[e.type]||e.type,{x:r,y:i}=Yf(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function ih(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function ah(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ih(n.addedNodes,r),t&&=!ih(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function oh(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ih(n.removedNodes,r),t&&=!ih(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var sh=new Map,ch=0;function lh(){let e=window.devicePixelRatio;e!==ch&&(ch=e,sh.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function uh(e,t){sh.size||window.addEventListener(`resize`,lh),sh.set(e,t)}function dh(e){sh.delete(e),sh.size||window.removeEventListener(`resize`,lh)}function fh(e,t,n){let r=e.canvas,i=r&&Vf(r);if(!i)return;let a=id((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),uh(e,a),o}function ph(e,t,n){n&&n.disconnect(),t===`resize`&&dh(e)}function mh(e,t,n){let r=e.canvas,i=id(t=>{e.ctx!==null&&n(rh(t,e))},e);return th(r,t,i),i}var hh=class extends Jm{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?($m(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[Xm])return!1;let n=t[Xm].initial;[`height`,`width`].forEach(e=>{let r=n[e];Yl(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[Xm],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:ah,detach:oh,resize:fh}[t]||mh)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:ph,detach:ph,resize:ph}[t]||nh)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return Qf(e,t,n,r)}isAttached(e){let t=e&&Vf(e);return!!(t&&t.isConnected)}};function gh(e){return!Bf()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?Ym:hh}var _h=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Fu(this.x)&&Fu(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function vh(e,t){let n=e.options.ticks,r=yh(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?xh(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return Sh(t,l,a,o/i),l;let u=bh(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Ch(t,l,u,Yl(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function xh(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Eh=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,Dh=(e,t)=>Math.min(t||e,e);function Oh(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function Ah(e,t){iu(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:$l(t,$l(n,t)),max:$l(n,$l(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){ru(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=cf(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=Ku(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-jh(e.grid)-t.padding-Mh(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=zu(Math.min(Math.asin(Ku((l.highest.height+6)/o,-1,1)),Math.asin(Ku(s/c,-1,1))-Math.asin(Ku(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){ru(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){ru(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=Mh(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=jh(i)+a):(e.height=this.maxHeight,e.width=jh(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Ru(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){ru(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return qu(this._alignToPixels?Ld(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=jh(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Ld(n,e,p)},g,_,v,y,b,x,S,C,w,ee,te,ne;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,ee=h(e.top)+m,ne=e.bottom;else if(a===`bottom`)g=h(this.top),ee=e.top,ne=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,te=e.right;else if(a===`right`)g=h(this.left),w=e.left,te=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(Zl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}ee=e.top,ne=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(Zl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,te=e.right}let re=eu(r.ticks.maxTicksLimit,l),ie=Math.max(1,Math.ceil(l/re));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:ne,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:re,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Ru(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Nd.route(a,i,c,s)})}function Vh(e){return`id`in e&&`defaults`in e}var Hh=new class{constructor(){this.controllers=new Rh(Zp,`datasets`,!0),this.elements=new Rh(_h,`elements`),this.plugins=new Rh(Object,`plugins`),this.scales=new Rh(Lh,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):iu(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=gu(e);ru(n[`before`+r],[],n),t[e](n),ru(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Wh(e){let t={},n=[],r=Object.keys(Hh.plugins.items);for(let e=0;e1&&Zh(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function eg(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function tg(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return eg(e,`x`,n[0])||eg(e,`y`,n[0])}return{}}function ng(e,t){let n=kd[e.type]||{scales:{}},r=t.scales||{},i=Jh(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!Zl(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=$h(t,o,tg(t,e),Nd.scales[o.type]),c=Xh(s,i),l=n.scales||{};a[t]=uu(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||Jh(i,t),s=(kd[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=Yh(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),uu(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];uu(t,[Nd.scales[t.type],Nd.scale])}),a}function rg(e){let t=e.options||={};t.plugins=eu(t.plugins,{}),t.scales=ng(e,t)}function ig(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function ag(e){return e||={},e.data=ig(e.data),rg(e),e}var og=new Map,sg=new Set;function cg(e,t){let n=og.get(e);return n||(n=t(),og.set(e,n),sg.add(n)),n}var lg=(e,t,n)=>{let r=hu(t,n);r!==void 0&&e.add(r)},ug=class{constructor(e){this._config=ag(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=ig(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),rg(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return cg(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return cg(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return cg(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return cg(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>lg(s,e,t))),t.forEach(e=>lg(s,r,e)),t.forEach(e=>lg(s,kd[i]||{},e)),t.forEach(e=>lg(s,Nd,e)),t.forEach(e=>lg(s,Ad,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),sg.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,kd[t]||{},Nd.datasets[t]||{},{type:t},Nd,Ad]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=dg(this._resolverCache,e,r),s=a;if(pg(a,t)){i.$shared=!1,n=vu(n)?n():n;let t=this.createResolver(e,n,o);s=df(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=dg(this._resolverCache,e,n);return Zl(t)?df(i,t,void 0,r):i}};function dg(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:uf(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var fg=e=>Zl(e)&&Object.getOwnPropertyNames(e).some(t=>vu(e[t]));function pg(e,t){let{isScriptable:n,isIndexable:r}=ff(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(vu(o)||fg(o))||a&&Xl(o))return!0}return!1}var mg=`4.5.1`,hg=[`top`,`bottom`,`left`,`right`,`chartArea`];function gg(e,t){return e===`top`||e===`bottom`||hg.indexOf(e)===-1&&t===`x`}function _g(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function vg(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),ru(n&&n.onComplete,[e],t)}function yg(e){let t=e.chart,n=t.options.animation;ru(n&&n.onProgress,[e],t)}function bg(e){return Bf()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var xg={},Sg=e=>{let t=bg(e);return Object.values(xg).filter(e=>e.canvas===t).pop()};function Cg(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function wg(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var Tg=class{static defaults=Nd;static instances=xg;static overrides=kd;static registry=Hh;static version=mg;static getChart=Sg;static register(...e){Hh.add(...e),Eg()}static unregister(...e){Hh.remove(...e),Eg()}constructor(e,t){let n=this.config=new ug(t),r=bg(e),i=Sg(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(gh(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=Jl(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Uh,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=ad(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],xg[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}Tp.listen(this,`complete`,vg),Tp.listen(this,`progress`,yg),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return Yl(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Hh}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():$f(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Rd(this.canvas,this.ctx),this}stop(){return Tp.stop(this),this}resize(e,t){Tp.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,$f(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),ru(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){iu(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=$h(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),iu(i,t=>{let i=t.options,a=i.id,o=$h(a,i),s=eu(i.type,t.dtype);(i.position===void 0||gg(i.position,o)!==gg(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(Hh.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),iu(r,(e,t)=>{e||delete n[t]}),iu(n,e=>{qm.configure(this,e,e.options),qm.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(_g(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){iu(this.scales,e=>{qm.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!yu(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)Cg(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;qm.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],iu(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=wp(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&Hd(t,r),e.controller.draw(),r&&Ud(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return Vd(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=Am.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=lf(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);_u(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),Tp.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};iu(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){iu(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},iu(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});au(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=bu(e),c=wg(e,this._lastEvent,n,s);n&&(this._lastEvent=null,ru(i.onHover,[e,o,this],this),s&&ru(i.onClick,[e,o,this],this));let l=!au(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Eg(){return iu(Tg.instances,e=>e._plugins.invalidate())}function Dg(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,Wu(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,Wu(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*Wu(r-n));if(u===`round`)e.arc(i,a,t,n-xu/2,r+xu/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+xu/2)+i,c=-o*Math.sin(n+xu/2)+a,l=o*Math.cos(r+xu/2)+i,u=o*Math.sin(r+xu/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Og(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+Eu,r-Eu),e.closePath(),e.clip()}function kg(e){return tf(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function Ag(e,t,n,r){let i=kg(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return Ku(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:Ku(i.innerStart,0,o),innerEnd:Ku(i.innerEnd,0,o)}}function jg(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Mg(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/xu)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=Ag(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,ee=_-y/C,te=f+b,ne=f+x,re=g+b/te,ie=_-x/ne;if(e.beginPath(),a){let t=(w+ee)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,ee),y>0){let t=jg(C,ee,o,s);e.arc(t.x,t.y,y,ee,_+Eu)}let n=jg(ne,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=jg(ne,ie,o,s);e.arc(t.x,t.y,x,_+Eu,ie+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=jg(te,re,o,s);e.arc(t.x,t.y,b,re+Math.PI,g-Eu)}let i=jg(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=jg(S,w,o,s);e.arc(t.x,t.y,v,g-Eu,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(ee)*d+o,i=Math.sin(ee)*d+s;e.lineTo(r,i)}e.closePath()}function Ng(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){Mg(e,t,n,r,c,i);for(let t=0;t=xu&&p===0&&u!==`miter`&&Dg(e,t,h),a||(Mg(e,t,n,r,h,i),e.stroke())}var Fg=class extends _h{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=Vu(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=eu(l,o-a),f=Gu(r,a,o)&&a!==o,p=d>=Su||f,m=Ju(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>Su?Math.floor(n/Su):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(xu,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Ng(e,this,s,i,a),Pg(e,this,s,i,a),e.restore()}};function Ig(e,t,n=t){e.lineCap=eu(n.borderCapStyle,t.borderCapStyle),e.setLineDash(eu(n.borderDash,t.borderDash)),e.lineDashOffset=eu(n.borderDashOffset,t.borderDashOffset),e.lineJoin=eu(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=eu(n.borderWidth,t.borderWidth),e.strokeStyle=eu(n.borderColor,t.borderColor)}function Lg(e,t,n){e.lineTo(n.x,n.y)}function Rg(e){return e.stepped?Wd:e.tension||e.cubicInterpolationMode===`monotone`?Gd:Lg}function zg(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function Hg(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?Vg:Bg}function Ug(e){return e.stepped?rp:e.tension||e.cubicInterpolationMode===`monotone`?ip:np}function Wg(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Ig(e,t.options),e.stroke(i)}function Gg(e,t,n,r){let{segments:i,options:a}=t,o=Hg(t);for(let s of i)Ig(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var Kg=typeof Path2D==`function`;function qg(e,t,n,r){Kg&&!t.options.segment?Wg(e,t,n,r):Gg(e,t,n,r)}var Jg=class extends _h{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;zf(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=_p(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=mp(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Ug(n),c,l;for(c=0,l=a.length;ce.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function l_(e){return s_[e%s_.length]}function u_(e){return c_[e%c_.length]}function d_(e,t){return e.borderColor=l_(t),e.backgroundColor=u_(t),++t}function f_(e,t){return e.backgroundColor=e.data.map(()=>l_(t++)),t}function p_(e,t){return e.backgroundColor=e.data.map(()=>u_(t++)),t}function m_(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof gm?t=f_(n,t):i instanceof vm?t=p_(n,t):i&&(t=d_(n,t))}}function h_(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function g_(e){return e&&(e.borderColor||e.backgroundColor)}function __(){return Nd.borderColor!==`rgba(0,0,0,0.1)`||Nd.backgroundColor!==`rgba(0,0,0,0.1)`}var v_={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=h_(r)||g_(i)||a&&h_(a)||__();if(!n.forceOverride&&o)return;let s=m_(e);r.forEach(s)}};function y_(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;dp&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function b_(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;oh&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!Yl(d)&&!Yl(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function x_(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function S_(e){e.data.datasets.forEach(e=>{x_(e)})}function C_(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=Ku(Xu(t,a.axis,o).lo,0,n-1)),i=l?Ku(Xu(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var w_={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){S_(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(sf([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=C_(s,c);if(d<=(n.threshold||4*r)){x_(t);return}Yl(a)&&(t._data=c,delete t.data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=y_(c,u,d,r,n);break;case`min-max`:f=b_(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){S_(e)}};function T_(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=O_(r,s,i);let c=E_(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=mp(t,c);for(let t of l){let r=E_(n,a[t.start],a[t.end],t.loop),s=pp(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:k_(c,r,`start`,Math.max)},end:{[n]:k_(c,r,`end`,Math.min)}})}}return o}function E_(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=Wu(i),a=Wu(a)),{property:e,start:i,end:a}}function D_(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=O_(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function O_(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function k_(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function A_(e,t){let n=[],r=!1;return Xl(e)?(r=!0,n=e):n=D_(e,t),n.length?new Jg({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function j_(e){return e&&e.fill!==!1}function M_(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!Ql(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function N_(e,t,n){let r=L_(e);if(Zl(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return Ql(i)&&Math.floor(i)===i?P_(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function P_(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function F_(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:Zl(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function I_(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:Zl(e)?e.value:t.getBaseValue(),r}function L_(e){let t=e.options,n=t.fill,r=eu(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function R_(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=z_(t,n);s.push(A_({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&J_(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;j_(n)&&J_(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!j_(r)||n.drawTime!==`beforeDatasetDraw`||J_(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},nv=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},rv=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,iv=class extends _h{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=ru(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=of(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=nv(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=av(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=sp(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=sd(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=sd(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=sd(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=sd(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;Hd(e,this),this._draw(),Ud(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Nd.color,s=sp(e.rtl,this.left,this.width),c=of(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=nv(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=eu(n.lineWidth,1);if(r.fillStyle=eu(n.fillStyle,o),r.lineCap=eu(n.lineCap,`butt`),r.lineDashOffset=eu(n.lineDashOffset,0),r.lineJoin=eu(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=eu(n.strokeStyle,o),r.setLineDash(eu(n.lineDash,[])),a.usePointStyle){let o={radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},c=s.xPlus(e,p/2),l=t+d;Bd(r,o,c,l,a.pointStyleWidth&&p)}else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=rf(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?Xd(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){Yd(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:sd(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:sd(i,this.top+y+l,this.bottom-t[0].height),line:0},cp(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=sd(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=sd(i,this.top+y+l,this.bottom-t[f.line].height));let w=s.x(S);if(g(w,C,o),S=cd(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=cv(o,e)+l}else f.y+=b}),lp(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=of(t.font),r=af(t.padding);if(!t.display)return;let i=sp(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=sd(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+sd(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=sd(o,u,u+d);a.textAlign=i.textAlign(od(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,Yd(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=of(e.font),n=af(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(Ju(e,this.left,this.right)&&Ju(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function sv(e,t,n){let r=e;return typeof t.text!=`string`&&(r=cv(t,n)),r}function cv(e,t){return t*(e.text?e.text.length:0)}function lv(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var uv={id:`legend`,_element:iv,start(e,t,n){let r=e.legend=new iv({ctx:e.ctx,options:n,chart:e});qm.configure(e,r,n),qm.addBox(e,r)},stop(e){qm.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;qm.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=af(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},dv=class extends _h{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=Xl(n.text)?n.text.length:1;this._padding=af(n.padding);let i=r*of(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=sd(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=sd(o,r,t),s=xu*-.5):(l=i-e,u=sd(o,t,r),s=xu*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=of(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);Yd(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:od(t.align),textBaseline:`middle`,translation:[i,a]})}};function fv(e,t){let n=new dv({ctx:e.ctx,options:t,chart:e});qm.configure(e,n,t),qm.addBox(e,n),e.titleBlock=n}var pv={id:`title`,_element:dv,start(e,t,n){fv(e,n)},stop(e){let t=e.titleBlock;qm.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;qm.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},mv=new WeakMap,hv={id:`subtitle`,start(e,t,n){let r=new dv({ctx:e.ctx,options:n,chart:e});qm.configure(e,r,n),qm.addBox(e,r),mv.set(e,r)},stop(e){qm.removeBox(e,mv.get(e)),mv.delete(e)},beforeUpdate(e,t,n){let r=mv.get(e);qm.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`normal`},fullSize:!0,padding:0,position:`top`,text:``,weight:1500},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},gv={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` -`):e}function yv(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function bv(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=of(t.bodyFont),l=of(t.titleFont),u=of(t.footerFont),d=a.length,f=i.length,p=r.length,m=af(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,iu(e.title,y),n.font=c.string,iu(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,iu(r,e=>{iu(e.before,y),iu(e.lines,y),iu(e.after,y)}),v=0,n.font=u.string,iu(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function xv(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function Sv(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function Cv(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),Sv(l,e,t,n)&&(l=`center`),l}function wv(e,t,n){let r=n.yAlign||t.yAlign||xv(e,n);return{xAlign:n.xAlign||t.xAlign||Cv(e,t,n,r),yAlign:r}}function Tv(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Ev(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function Dv(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=rf(o),m=Tv(t,s),h=Ev(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:Ku(m,0,r.width-t.width),y:Ku(h,0,r.height-t.height)}}function Ov(e,t,n){let r=af(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function kv(e){return _v([],vv(e))}function Av(e,t,n){return lf(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function jv(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var Mv={beforeTitle:ql,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=jv(n,e);_v(t.before,vv(Nv(i,`beforeLabel`,this,e))),_v(t.lines,Nv(i,`label`,this,e)),_v(t.after,vv(Nv(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return kv(Nv(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Nv(n,`beforeFooter`,this,e),i=Nv(n,`footer`,this,e),a=Nv(n,`afterFooter`,this,e),o=[];return o=_v(o,vv(r)),o=_v(o,vv(i)),o=_v(o,vv(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),iu(o,t=>{let n=jv(e.callbacks,t);r.push(Nv(n,`labelColor`,this,t)),i.push(Nv(n,`labelPointStyle`,this,t)),a.push(Nv(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=gv[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=bv(this,n),o=Object.assign({},e,t),s=wv(this.chart,n,o),c=Dv(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=rf(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=sp(n.rtl,this.x,this.width);for(e.x=Ov(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=of(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,Xd(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),Xd(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=of(n.bodyFont),d=u.lineHeight,f=0,p=sp(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=Ov(this,h,n),t.fillStyle=n.bodyColor,iu(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=gv[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=bv(this,e),o=Object.assign({},n,this._size),s=wv(t,e,o),c=Dv(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=af(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),cp(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),lp(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!au(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!au(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=gv[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Fv=Object.freeze({__proto__:null,Colors:v_,Decimation:w_,Filler:tv,Legend:uv,SubTitle:hv,Title:pv,Tooltip:{id:`tooltip`,_element:Pv,positioners:gv,afterInit(e,t,n){n&&(e.tooltip=new Pv({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:Mv},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Iv=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Lv(e,t,n,r){let i=e.indexOf(t);return i===-1?Iv(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Rv=(e,t)=>e===null?null:Ku(Math.round(e),0,t);function zv(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function Vv(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!Yl(a),_=!Yl(o),v=!Yl(c),y=(h-m)/(u+1),b=Mu((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=Mu(w*b/p/f)*f),Yl(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Iu((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=ju(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let ee=Math.max(Bu(b),Bu(S));x=10**(Yl(s)?ee:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let te=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&ju(n[n.length-1].value,o,Hv(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Hv(e,t,{horizontal:n,minRotation:r}){let i=Ru(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Uv=class extends Lh{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return Yl(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=Au(r),t=Au(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=Vv({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Lu(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return wd(e,this.chart.options.locale,this.options.ticks.format)}},Wv=class extends Uv{static id=`linear`;static defaults={ticks:{callback:Dd.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Ql(e)?e:0,this.max=Ql(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Ru(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Gv=e=>Math.floor(ku(e)),Kv=(e,t)=>10**(Gv(e)+t);function qv(e){return e/10**Gv(e)==1}function Jv(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Yv(e,t){let n=Gv(t-e);for(;Jv(e,t,n)>10;)n++;for(;Jv(e,t,n)<10;)n--;return Math.min(n,Gv(e))}function Xv(e,{min:t,max:n}){t=$l(e.min,t);let r=[],i=Gv(t),a=Yv(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=$l(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=$l(e.max,f);return r.push({value:p,major:qv(p),significand:d}),r}var Zv=class extends Lh{static id=`logarithmic`;static defaults={ticks:{callback:Dd.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Uv.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return Ql(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Ql(e)?Math.max(0,e):null,this.max=Ql(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Ql(this._userMin)&&(this.min=e===Kv(this.min,0)?Kv(this.min,-1):Kv(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Kv(n,-1)),a(Kv(r,1)))),n<=0&&i(Kv(r,-1)),r<=0&&a(Kv(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Xv({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Lu(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:wd(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=ku(e),this._valueRange=ku(this.max)-ku(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(ku(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function Qv(e){let t=e.ticks;if(t.display&&e.display){let e=af(t.backdropPadding);return eu(t.font&&t.font.size,Nd.font.size)+e.height}return 0}function $v(e,t,n){return n=Xl(n)?n:[n],{w:Id(e,t.string,n),h:n.length*t.lineHeight}}function ey(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function ty(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?xu/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function ry(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(zu(Wu(c.angle+Eu))),u=cy(c.y,s.h,l),d=oy(l),f=sy(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function iy(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(Vd({x:n,y:r},t)||Vd({x:n,y:a},t)||Vd({x:i,y:r},t)||Vd({x:i,y:a},t))}function ay(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Qv(a)/2,additionalAngle:o?xu/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function ly(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!Yl(s)){let n=rf(t.borderRadius),c=af(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),Xd(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function uy(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));ly(n,a,t);let o=of(a.font),{x:s,y:c,textAlign:l}=t;Yd(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function dy(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,Su);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=ru(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?ty(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=Su/(this._pointLabels.length||1),n=this.options.startAngle||0;return Wu(e*t+Ru(n))}getDistanceFromCenterForValue(e){if(Yl(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(Yl(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);fy(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=of(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=af(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}Yd(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},hy={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},gy=Object.keys(hy);function _y(e,t){return e-t}function vy(e,t){if(Yl(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),Ql(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Fu(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function yy(e,t,n,r){let i=gy.length;for(let a=gy.indexOf(e);a=gy.indexOf(n);a--){let n=gy[a];if(hy[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return gy[n?gy.indexOf(n):0]}function xy(e){for(let t=gy.indexOf(e)+1,n=gy.length;t=t?n[r]:n[i];e[a]=!0}}function Cy(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function wy(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=Ku(t,0,a),n=Ku(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||yy(i.minUnit,t,n,this._getLabelCapacity(t)),o=eu(r.ticks.stepSize,1),s=a===`week`&&i.isoWeekday,c=Fu(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return ru(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=Xu(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=Xu(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var Dy=class extends Ty{static id=`timeseries`;static defaults=Ty.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=Ey(t,this.min),this._tableRange=Ey(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(Ey(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return Ey(this._table,n*this._tableRange+this._minPos,!0)}},Oy=[ym,o_,Fv,Object.freeze({__proto__:null,CategoryScale:Bv,LinearScale:Wv,LogarithmicScale:Zv,RadialLinearScale:my,TimeScale:Ty,TimeSeriesScale:Dy})];Tg.register(...Oy);var ky=Tg,Ay=R(``);function jy(e,t){E(t,!0);let n=ya(t,`class`,3,``),r=ya(t,`ariaLabel`,3,``);function i(e){if(ka.tick,typeof t.build!=`function`)return;let n=t.build();if(!n)return;let r=new ky(e.getContext(`2d`),n);return()=>r.destroy()}var a=Ay();Mi(a,()=>i),F(()=>{U(a,1,Fi(n())),W(a,`aria-label`,r())}),z(e,a),D()}var My=R(``),Ny=R(`
`);function Py(e,t){E(t,!0);let n=ya(t,`options`,19,()=>[]),r=ya(t,`ariaLabel`,3,``),i=ya(t,`class`,3,``);var a=Ny();H(a,21,n,e=>e.value,(e,n)=>{var r=My();let i;var a=M(r,!0);T(r),F(()=>{i=U(r,1,`segmented-btn svelte-92fh5i`,null,i,{active:t.value===I(n).value}),W(r,`aria-pressed`,t.value===I(n).value),B(a,I(n).label)}),L(`click`,r,()=>t.onchange?.(I(n).value)),z(e,r)}),T(a),F(()=>{U(a,1,Fi([`segmented-control`,i()]),`svelte-92fh5i`),W(a,`aria-label`,r())}),z(e,a),D()}Hr([`click`]);function Fy(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Iy(){return{grid:Fy(`--chart-grid`),text:Fy(`--chart-text`),dayMarker:Fy(`--chart-day-marker`),tooltipBg:Fy(`--chart-tooltip-bg`),tooltipBorder:Fy(`--chart-tooltip-border`),tooltipText:Fy(`--chart-tooltip-text`)}}function Ly(){return{size:11,family:`'SF Mono', Menlo, Consolas, monospace`}}function Ry(e,t){return{backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,borderWidth:1,titleColor:e.tooltipText,bodyColor:e.tooltipText,callbacks:t}}function zy(e){if(typeof document>`u`||!document.body)return e;let t=document.createElement(`span`);t.style.display=`none`,t.style.color=e,document.body.appendChild(t);let n=getComputedStyle(t).color;return document.body.removeChild(t),n||e}var By=[`#c2845a`,`#7a9e7e`,`#d4a574`,`#b8a98e`,`#8b9e6b`,`#7d8a97`,`#c47a5a`,`#6b8e6b`,`#a09486`,`#9b7ea4`,`#c49a6c`];function Vy(){return[...By]}function Hy(e){let t=5381,n=String(e||``);for(let e=0;euc(e)}}var Jy={seconds:{apiName:`second`,windowLabel:`Last 60 seconds`,refreshMs:2e3},minutes:{apiName:`minute`,windowLabel:`Last 60 minutes`,refreshMs:5e3},hours:{apiName:`hour`,windowLabel:`Last 24 hours`,refreshMs:2e4},days:{apiName:`day`,windowLabel:`Last 30 days`,refreshMs:6e4}},Yy=[{value:`seconds`,label:`Seconds`},{value:`minutes`,label:`Minutes`},{value:`hours`,label:`Hours`},{value:`days`,label:`Days`}];function Xy(){return{input:0,output:0,prompt:0,local:0}}function Zy(e){return String(e).padStart(2,`0`)}function Qy(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function $y(e,t){if(!Number.isFinite(t))return``;let n=new Date(t);switch(e){case`seconds`:return Zy(n.getHours())+`:`+Zy(n.getMinutes())+`:`+Zy(n.getSeconds());case`minutes`:return Zy(n.getHours())+`:`+Zy(n.getMinutes());case`hours`:return Zy(n.getHours())+`:00`;default:return Zy(n.getMonth()+1)+`-`+Zy(n.getDate())}}function eb(e,t){let n=[],r=[],i={input:[],output:[],prompt:[],local:[]},a=Xy();for(let o of e||[]){let e=Date.parse(o&&o.start),s=Qy(o&&o.input_tokens),c=Qy(o&&o.output_tokens),l=Qy(o&&o.prompt_cached_tokens),u=Qy(o&&o.locally_cached_tokens);n.push($y(t,e)),r.push(Number.isFinite(e)?e:null),i.input.push(s),i.output.push(c),i.prompt.push(l),i.local.push(u),a.input+=s,a.output+=c,a.prompt+=l,a.local+=u}return{labels:n,stamps:r,cols:i,totals:a}}function tb(e){let t=e||Xy();return t.input+t.output+t.prompt+t.local>0}function nb(e,t){return uc(Math.max(0,Math.round(e&&e[t]||0)))}function rb(e){return(Jy[e]||Jy.minutes).windowLabel}function ib(e,t){return`Live token throughput, `+rb(t).toLowerCase()+`. Input `+nb(e,`input`)+`, output `+nb(e,`output`)+`, prompt cached `+nb(e,`prompt`)+`, locally cached `+nb(e,`local`)+` tokens.`}function ab(e,t,n,r){let i=e=>uc(Math.max(0,Math.round(e))),a=n.stamps,o=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderWidth:0,borderRadius:0,categoryPercentage:1,barPercentage:1,stack:`tokens`});return{type:`bar`,plugins:[{id:`liveTokensDayMarks`,afterDatasetsDraw:t=>{if(r===`days`)return;let n=t.getDatasetMeta(0),i=t.chartArea;if(!n||!n.data||!i)return;let o=t.ctx;o.save(),o.font=`10px 'SF Mono', Menlo, Consolas, monospace`;let s=null;for(let t=0;t{if(!e.length)return``;let t=a[e[0].dataIndex];if(!t)return e[0].label;let n=new Date(t);return r===`days`?n.toLocaleDateString():n.toLocaleString()},label:e=>e.dataset.label+`: `+i(e.parsed.y),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+i(t)}})}}}}var ob=900,sb=new class{#e=k(`minutes`);get granularity(){return I(this.#e)}set granularity(e){A(this.#e,e,!0)}#t=k(j([]));get buckets(){return I(this.#t)}set buckets(e){A(this.#t,e,!0)}#n=k(!1);get active(){return I(this.#n)}set active(e){A(this.#n,e,!0)}#r=null;#i=null;#a=null;#o=0;#s=null;#c=!1;start(){this.stop(),this.active=!0,this.fetch(),this.#l(),this.#u()}stop(){this.active=!1,this.#r&&=(clearInterval(this.#r),null),this.#i&&=(clearTimeout(this.#i),null),this.#a&&=(clearTimeout(this.#a),null),this.#o=0,this.#s&&=(this.#s.abort(),null),this.buckets=[]}setGranularity(e){!Jy[e]||e===this.granularity||(this.granularity=e,this.buckets=[],this.#l(),this.fetch())}#l(){this.#r&&=(clearInterval(this.#r),null);let e=Jy[this.granularity]||Jy.minutes;this.#r=setInterval(()=>{this.active&&this.fetch()},e.refreshMs)}noteUsageEvent(e){!this.active||e!==`usage.flushed`||(this.#i||=setTimeout(()=>{this.#i=null,this.fetch()},ob))}async fetch(){if(!this.active||this.#c)return;this.#c=!0;let e=this.granularity;try{let t=await _s(`/admin/usage/throughput?granularity=`+(Jy[e]||Jy.minutes).apiName,{label:`token throughput`});if(t.stale||!t.ok||this.granularity!==e)return;this.buckets=t.data&&Array.isArray(t.data.buckets)?t.data.buckets:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch token throughput:`,e)}finally{this.#c=!1,this.active&&this.granularity!==e&&this.fetch()}}async#u(){await Ss.ensureLoaded(),this.active&&Ss.liveLogsVisible()&&(typeof ReadableStream>`u`||(this.#s&&this.#s.abort(),this.#s=new AbortController,this.#d(this.#s)))}async#d(e){try{let t=await hs(`/admin/live/logs?types=usage`,{signal:e.signal});if(!t.ok||!t.body||typeof t.body.getReader!=`function`){this.#p();return}this.#o=0,await Wy(t.body.getReader(),e=>this.#f(e)),this.#p()}catch(e){if(ys(e))return;console.error(`Live usage stream failed:`,e),this.#p()}}#f(e){if(!e||typeof e!=`object`)return;let t=String(e.type||``).trim();t.indexOf(`usage.`)===0&&this.noteUsageEvent(t)}#p(){if(!this.active||this.#a)return;let{attempt:e,delay:t}=Ky(this.#o);this.#o=e,this.#a=setTimeout(()=>{this.#a=null,this.#u()},t)}},cb=R(`
`),lb=R(`
Waiting for live requests…
`),ub=R(`

Live Token Throughput

`);function db(e,t){E(t,!0);let n=O(()=>eb(sb.buckets,sb.granularity)),r=O(()=>I(n).totals);function i(){return{input:zy(`var(--token-input)`),output:zy(`var(--token-output)`),prompt:zy(`var(--token-prompt)`),local:zy(`var(--token-local)`)}}let a=[{metric:`input`,label:`Input Tokens`,colorVar:`--token-input`},{metric:`output`,label:`Output Tokens`,colorVar:`--token-output`},{metric:`prompt`,label:`Prompt (Input) Cached`,colorVar:`--token-prompt`},{metric:`local`,label:`Locally Cached`,colorVar:`--token-local`}];var o=ub(),s=M(o),c=M(s),l=P(M(c),2),u=M(l);let d;var f=P(u,2),p=M(f,!0);T(f),T(l),T(c),Py(P(c,2),{ariaLabel:`Live token throughput granularity`,get options(){return Yy},get value(){return sb.granularity},onchange:e=>sb.setGranularity(e)}),T(s);var m=P(s,2);H(m,21,()=>a,e=>e.metric,(e,t)=>{var n=cb(),i=M(n),a=P(i,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{Hi(i,`background: var(${I(t).colorVar??``})`),B(o,I(t).label),B(c,e)},[()=>nb(I(r),I(t).metric)]),z(e,n)}),T(m);var h=P(m,2),g=M(h);{let e=O(()=>ib(I(r),sb.granularity));jy(g,{get ariaLabel(){return I(e)},build:()=>ab(Iy(),i(),I(n),sb.granularity)})}var _=P(g,2),v=e=>{z(e,lb())},y=O(()=>!tb(I(r)));V(_,e=>{I(y)&&e(v)}),T(h),T(o),F(e=>{d=U(u,1,`live-dot`,null,d,{"is-streaming":sb.active}),B(p,e)},[()=>rb(sb.granularity)]),z(e,o),D()}function fb(e){let t=e||{};if(t.total_tokens!==null&&t.total_tokens!==void 0){let e=Number(t.total_tokens);if(Number.isFinite(e))return e}let n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function pb(e,t){if(!t)return 0;let n=e&&e.summary?e.summary:{},r=Number(n.total_hits||0);return Number.isFinite(r)&&r>0?r:0}function mb(e,t,n){let r=Number(e&&e.total_requests||0);return(Number.isFinite(r)?r:0)+pb(t,n)}function hb(e,t,n){let r=pb(t,n);return r<=0?``:oc(mb(e,t,n)-r)+` to providers + `+oc(r)+` from cache`}function gb(e){let t=e&&e.summary?e.summary:{},n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function _b(e,t,n){let r=e=>{let t=Number(e||0);return Number.isFinite(t)&&t>0?t:0},i=e||{},a=r(i.uncached_input_tokens),o=r(i.cached_input_tokens),s=r(i.cache_write_input_tokens),c=t&&t.summary?t.summary:{},l=n?r(c.total_input_tokens):0;return[{key:`uncached`,label:`Regular`,tokens:a+s,colorVar:`--cache-meter-uncached`,note:s>0?`Includes `+oc(s)+` cache-write tokens`:``},{key:`prompt`,label:`Prompt cached`,tokens:o,colorVar:`--cache-meter-prompt`,note:`Provider prompt-cache reads`},{key:`local`,label:`Locally cached`,tokens:l,colorVar:`--cache-meter-local`,note:`Served from GoModel response cache`}]}function vb(e,t,n){return _b(e,t,n).reduce((e,t)=>e+t.tokens,0)}function yb(e,t,n){return vb(e,t,n)>0}function bb(e,t,n){let r=_b(e,t,n),i=r.reduce((e,t)=>e+t.tokens,0);if(i<=0)return r.map(e=>Object.assign({},e,{pct:0}));let a=r.map(e=>{let t=e.tokens/i*100,n=Math.floor(t);return Object.assign({},e,{pct:n,remainder:t-n})}),o=100-a.reduce((e,t)=>e+t.pct,0);return a.map((e,t)=>({index:t,remainder:e.remainder,tokens:e.tokens})).filter(e=>e.tokens>0).sort((e,t)=>t.remainder-e.remainder).forEach(e=>{o>0&&(a[e.index].pct+=1,--o)}),a}function xb(e,t,n){return bb(e,t,n).filter(e=>e.tokens>0)}function Sb(e){let t=[e.label+`: `+oc(e.tokens)+` input tokens (`+e.pct+`%)`];return e.note&&t.push(e.note),t.join(` -`)}function Cb(e){let t=(e||[]).map(e=>e.label+` `+e.pct+`%`);return`Cache breakdown of input tokens — `+(t.length?t.join(`, `):`no data`)}function wb(e){return e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`)}function Tb(e,t,n,r){if(t!==`daily`||!n||!r)return e;let i={};(e||[]).forEach(e=>{i[e.date]=e});let a=[];for(let e=new Date(n);e<=r;e.setUTCDate(e.getUTCDate()+1)){let t=wb(e);a.push(i[t]||{date:t,input_tokens:0,output_tokens:0,total_tokens:0,requests:0,input_cost:null,output_cost:null,total_cost:null})}return a}function Eb(e,t){let n=e=>Number(e)||0,r=e.map(e=>e.date),i=e.map(e=>n(e.uncached_input_tokens)+n(e.cache_write_input_tokens)+n(e.cached_input_tokens)>0?n(e.uncached_input_tokens)+n(e.cache_write_input_tokens):n(e.input_tokens)),a=e.map(e=>n(e.output_tokens)),o=e.map(e=>n(e.cached_input_tokens)),s={};return(t||[]).forEach(e=>{s[e.date]=e}),{labels:r,inputPaid:i,output:a,prompt:o,local:r.map(e=>{let t=s[e];return t?n(t.input_tokens)+n(t.output_tokens):0})}}function Db(e){let t=e||{},n=Math.max(0,Number(t.uncached_input_tokens)||0),r=Math.max(0,Number(t.cached_input_tokens)||0),i=Math.max(0,Number(t.cache_write_input_tokens)||0),a=n+r+i;return a>0?r/a*100:0}function Ob(e){let t=e||{};return(Number(t.uncached_input_tokens)||0)+(Number(t.cached_input_tokens)||0)+(Number(t.cache_write_input_tokens)||0)>0}function kb(e){return Ob(e)?Math.round(Db(e))+`%`:`—`}function Ab(e,t,n={}){let r=!!n.cacheEnabled,i=n.resolve||(e=>e),a=(e,t)=>i(`color-mix(in srgb, `+e+` `+t+`%, transparent)`),o=(e,t,n,r)=>Object.assign({label:e,data:t,borderColor:n,backgroundColor:n,fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4},r||{}),s=[o(`Input Tokens`,t.inputPaid,i(`var(--token-input)`),{fill:`origin`}),o(`Output Tokens`,t.output,i(`var(--token-output)`),{fill:`-1`}),o(`Prompt (Input) Cached`,t.prompt,i(`var(--token-prompt)`),{fill:`-1`,borderDash:[6,4]})];return r&&s.push(o(`Locally Cached`,t.local,a(`var(--info)`,35),{fill:`-1`,borderDash:[2,3]})),{type:`line`,data:{labels:t.labels,datasets:s},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:10}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:qy(e)}}}}}function jb(e,t,n){let r=Math.max(0,Math.min(100,e));return{type:`doughnut`,data:{datasets:[{data:[r,100-r],backgroundColor:[t,n],borderWidth:0,spacing:0}]},options:{rotation:-90,circumference:180,cutout:`84%`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:1},events:[],plugins:{legend:{display:!1},tooltip:{enabled:!1}}}}}var Mb=`gomodel_provider_status_details_expanded`,Nb=`gomodel_provider_card_expanded_overrides`,Pb=3e3,Fb=`https://gomodel.enterpilot.io/docs/providers/`,Ib={anthropic:`anthropic`,azure:`azure`,bailian:`bailian`,bedrock:`bedrock`,"bedrock-mantle":`bedrock-mantle`,cohere:`cohere`,deepseek:`deepseek`,gemini:`gemini`,opencode_go:`opencode-go`,oracle:`oracle`,vertex:`vertex`,vllm:`vllm`,xiaomi:`xiaomi`};function Lb(){return{summary:{total:0,healthy:0,degraded:0,unhealthy:0,overall_status:`degraded`},providers:[]}}function Rb(e){let t={detailsExpanded:!1,cardOverrides:{}};try{if(e){let n=e.getItem(Mb);n===`true`||n===`false`?t.detailsExpanded=n===`true`:e.setItem(Mb,`false`);let r=JSON.parse(e.getItem(Nb)||`{}`);r&&typeof r==`object`&&!Array.isArray(r)&&(t.cardOverrides=r)}}catch{}return t}function zb(e,t){if(e)try{e.setItem(Mb,t?`true`:`false`)}catch{}}function Bb(e,t){if(e)try{e.setItem(Nb,JSON.stringify(t))}catch{}}function Vb(e,t,n){let r=n&&n.name?String(n.name):``;return r&&Object.prototype.hasOwnProperty.call(e,r)?e[r]===!0:t}function Hb(e){return`is-`+(String(e&&e.overall_status||`degraded`).trim()||`degraded`)}function Ub(e){return`is-`+(String(e||`degraded`).trim()||`degraded`)}function Wb(e){let t=e||{};return String(t.healthy||0)+`/`+String(t.total||0)}function Gb(e){let t=e||{},n=Number(t.total||0),r=Number(t.healthy||0);return n>0&&rString(e&&e.status_label||``).trim().toLowerCase()===`starting`)}function Jb(e){if(!e||!e.runtime)return``;let t=e.runtime.last_model_fetch_at||``,n=e.runtime.last_availability_check_at||``;return t?n&&Date.parse(n)>Date.parse(t)?n:t:n}function Yb(e,t){let n=Jb(e);if(!n||typeof t!=`function`)return`-`;let r=t(n);if(!r||r===`-`)return`-`;let i=String(r).split(` `);return i.length>1?i.slice(1).join(` `):r}function Xb(e,t){let n=Jb(e);return n?typeof t==`function`?t(n):String(n):``}function Zb(e){if(!e)return``;let t=String(e.name||``).trim(),n=String(e.type||e.config&&e.config.type||``).trim();return!n||n===t?``:n}function Qb(e){let t=String(e&&(e.type||e.config&&e.config.type)||``).trim().toLowerCase(),n=t?Ib[t]:``;return n?Fb+n+`?utm_source=gomodel_dashboard`:``}function $b(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.retry:null;return t?String(t.max_retries)+` retries, `+t.initial_backoff+` initial, `+t.max_backoff+` max, factor `+t.backoff_factor+`, jitter `+t.jitter_factor:`-`}function ex(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.circuit_breaker:null;return t?String(t.failure_threshold)+` fail, `+String(t.success_threshold)+` success, `+t.timeout+` timeout`:`-`}function tx(e){let t=e&&e.config&&Array.isArray(e.config.models)?e.config.models.filter(Boolean):[];return t.length===0?`Automatic`:t.join(`, `)}function nx(e){if(!e)return``;let t=[];return e.status_reason&&t.push(String(e.status_reason)),e.last_error&&t.push(`Last error: `+String(e.last_error)),t.join(` - -`)}function rx(e){let t=e&&e.request_health;return t&&typeof t==`object`?t:null}function ix(e){let t=rx(e);return t?String(t.circuit_state||``).trim():``}function ax(e){let t=ix(e);return t?t.charAt(0).toUpperCase()+t.slice(1):``}function ox(e){let t=ix(e);return t===`open`?`is-unhealthy`:t===`half-open`?`is-degraded`:`is-healthy`}function sx(e){let t=rx(e);if(!t)return``;let n=Number(t.requests||0),r=Number(t.errors||0),i=Math.round(Number(t.window_seconds||0)/60),a=i>0?`last `+i+` min`:`recent`;return String(n)+` request`+(n===1?``:`s`)+` · `+String(r)+` error`+(r===1?``:`s`)+` (`+a+`)`}function cx(e){let t=rx(e);return t&&Array.isArray(t.models)?t.models:[]}function lx(e){return e?String(Number(e.errors||0))+`/`+String(Number(e.requests||0))+` failed`:``}function ux(e){let t=e&&e.last_error;return!t||!t.message?``:(t.status_code?`HTTP `+String(t.status_code)+`: `:``)+t.message}function dx(){return{name:``,slug:``,url:``,transport:`http`,description:``,enabled:!0,headers:[],allowed_tools:``,disallowed_tools:``,user_paths:``,tool_timeout_seconds:``}}function fx(){return{server:``,status:``,instructions:``,tools:[],prompts:[],resources:[],templates:[]}}function px(e){return String(e&&(e.slug||e.name)||``).trim()}function mx(e){return String(e&&e.status||``).trim()||`connecting`}function hx(e){switch(mx(e)){case`connected`:return`status-success`;case`degraded`:return String(e&&e.last_error||``).trim()?`status-error`:`status-warning`;case`connecting`:return`status-neutral`;default:return`status-unknown`}}function gx(e,t){let n=mx(e),r=String(e&&e.last_error||``).trim();return r&&n!==`connected`?r:n===`connected`&&e&&e.connected_at?`Connected since `+(typeof t==`function`?t:String)(e.connected_at):``}function _x(e){return String(e&&e.transport||``)===`stdio`?`local command`:String(e&&e.url||``).trim()||`—`}function vx(e){let t=Number(e&&e.prompt_count||0),n=Number(e&&e.resource_count||0);return t+` prompts · `+n+` resources`}function yx(e){let t=String(e||``).normalize(`NFKD`).toLowerCase(),n=t.replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/-+$/g,``);if(n)return n;let r=2166136261;for(let e of t)r=Math.imul((r^e.codePointAt(0))>>>0,16777619)>>>0;return`mcp-`+r.toString(16).padStart(8,`0`)}function bx(e){return String(e||``).split(` -`).map(e=>e.trim()).filter(e=>e)}function xx(e){return!e||typeof e!=`object`||Array.isArray(e)?[]:Object.keys(e).sort().map(t=>({name:t,value:String(e[t]||``)}))}function Sx(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=String(e&&e.name||``).trim();n&&(t[n]=String(e&&e.value||``))}),t}function Cx(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.slug,e.url,e.transport,e.description,e.status].some(e=>String(e||``).toLowerCase().includes(r)))}function wx(e){return{name:String(e.name||``).trim(),slug:px(e),url:String(e.url||``).trim(),transport:e.transport===`sse`?`sse`:`http`,description:String(e.description||``).trim(),enabled:e.enabled!==!1,headers:xx(e.headers),allowed_tools:(Array.isArray(e.allowed_tools)?e.allowed_tools:[]).join(`, `),disallowed_tools:(Array.isArray(e.disallowed_tools)?e.disallowed_tools:[]).join(`, `),user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` -`),tool_timeout_seconds:e.tool_timeout_seconds?String(e.tool_timeout_seconds):``}}function Tx(e,t,n){let r=String(e.name||``).trim(),i=String(e.slug||yx(r)).trim().toLowerCase(),a=String(e.url||``).trim(),o=e.transport===`sse`?`sse`:`http`;if(!r)return{error:`Name is required.`};if(!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(i))return{error:`Slug must use 1–64 lowercase ASCII letters, numbers, hyphens, or underscores.`};if(t===`create`&&(n||[]).some(e=>px(e)===i))return{error:`Slug "`+i+`" is already in use.`};if(!a)return{error:`URL is required.`};let s,c=String(e.tool_timeout_seconds||``).trim();if(c!==``){let e=Number(c);if(!Number.isSafeInteger(e)||e<0)return{error:`Tool timeout must be a non-negative whole number of seconds.`};s=e}return{payload:{name:r,slug:i,url:a,transport:o,headers:Sx(e.headers),description:String(e.description||``).trim(),enabled:!!e.enabled,allowed_tools:ic(e.allowed_tools),disallowed_tools:ic(e.disallowed_tools),user_paths:bx(e.user_paths),tool_timeout_seconds:s}}}function Ex(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=e=>(Array.isArray(e)?e:[]).filter(e=>e&&typeof e==`object`);return{server:String(n.server||e||``).trim(),status:String(n.status||``).trim(),instructions:String(n.instructions||``).trim(),tools:r(n.tools),prompts:r(n.prompts),resources:r(n.resources),templates:r(n.templates)}}function Dx(e,t){return String(e&&e.server||``)+`_`+String(t||``)}function Ox(e){let t=e||fx(),n=(e,t)=>{let n=String(e||``).trim(),r=String(t||``).trim();return n&&r?n+` — `+r:r||n},r=e=>n=>({key:e+`:`+String(n.name||``),name:String(n.name||``),aggregated:Dx(t,n.name),description:String(n.description||``).trim()});return[{key:`tools`,title:`Tools`,items:(t.tools||[]).map(r(`tool`))},{key:`prompts`,title:`Prompts`,items:(t.prompts||[]).map(r(`prompt`))},{key:`resources`,title:`Resources`,items:(t.resources||[]).map(e=>({key:`resource:`+String(e.uri||``),name:String(e.uri||``),aggregated:``,description:n(e.name,e.description)}))},{key:`templates`,title:`Resource templates`,items:(t.templates||[]).map(e=>({key:`template:`+String(e.uri_template||``),name:String(e.uri_template||``),aggregated:``,description:n(e.name,e.description)}))}].filter(e=>e.items.length>0)}function kx(e){return Ox(e).length===0}function Ax(e){return(e||[]).length}function jx(e){return(e||[]).filter(e=>mx(e)===`connected`).length}function Mx(e){return(e||[]).filter(e=>e&&e.enabled!==!1&&mx(e)===`degraded`).length}function Nx(e,t){return!!e&&Ax(t)>0}function Px(e){return String(jx(e))+`/`+String(Ax(e))}function Fx(e){return Mx(e)>0?`is-degraded`:`is-healthy`}function Ix(e){let t=Mx(e);if(t>0)return String(t)+` server`+(t===1?``:`s`)+` need`+(t===1?`s`:``)+` attention`;let n=Ax(e),r=jx(e);return n>0&&r===n?`All MCP servers connected`:String(r)+` of `+String(n)+` server`+(n===1?``:`s`)+` connected`}function Lx(){return{interval:`day`,buckets:[],summary:{requests:0},provider_latency:[]}}function Rx(e){let t=e&&typeof e==`object`?e:{};return{interval:t.interval===`hour`?`hour`:`day`,buckets:Array.isArray(t.buckets)?t.buckets:[],summary:t.summary&&typeof t.summary==`object`?t.summary:{requests:0},provider_latency:Array.isArray(t.provider_latency)?t.provider_latency:[]}}function zx(e){return Number(e&&e.summary&&e.summary.requests||0)>0}function Bx(e){return(e&&Array.isArray(e.provider_latency)?e.provider_latency:[]).length>0}function Vx(e){let t=e&&e.summary?e.summary.success_rate:null;return t==null?`—`:(Math.round(Number(t)*1e3)/10).toFixed(1)+`%`}function Hx(e,t){return Number(e&&e.summary&&e.summary[t]||0)}function Ux(e){let t=Number(e);return Number.isFinite(t)?t>=6e4?(t/6e4).toFixed(1)+` min`:t>=1e3?(t/1e3).toFixed(2)+` s`:Math.round(t)+` ms`:`-`}function Wx(e){let t=e&&e.summary?e.summary.avg_duration_ms:null;return t==null?`—`:Ux(Number(t))}function Gx(e,t){try{let n={};return new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,hourCycle:`h23`}).formatToParts(e).forEach(e=>{n[e.type]=e.value}),{year:n.year,month:n.month,day:n.day,hour:Number(n.hour)}}catch{return{year:String(e.getFullYear()),month:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()],day:String(e.getDate()),hour:e.getHours()}}}function Kx(e,t,n){let r=new Date(e.start);if(Number.isNaN(r.getTime()))return String(e.start||``);let i=Gx(r,n),a=i.month+` `+i.day;return t!==`hour`||i.hour===0?a:String(i.hour).padStart(2,`0`)+`:00`}function qx(e,t,n,r){let i=new Date(e.start);if(Number.isNaN(i.getTime()))return String(e.start||``);if(t===`hour`)return r(e.start);let a=Gx(i,n);return a.month+` `+a.day+`, `+a.year}function Jx(e){return{ok:e(`var(--success)`),clientError:e(`var(--warning)`),serverError:e(`var(--danger)`),other:e(`color-mix(in srgb, var(--text-muted) 55%, transparent)`)}}function Yx(e,t,n={}){let r=n.interval===`hour`?`hour`:`day`,i=n.zone,a=n.resolve||(e=>e),o=n.formatTimestamp||(e=>String(e)),s=t.map(e=>Kx(e,r,i)),c=Jx(a),l=a(`var(--bg-surface)`),u=e=>Number(e)||0,d=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:l,borderWidth:1,borderSkipped:!1,borderRadius:2,maxBarThickness:28}),f=[d(`2xx`,t.map(e=>u(e.status_2xx)),c.ok),d(`4xx`,t.map(e=>u(e.status_4xx)),c.clientError),d(`5xx`,t.map(e=>u(e.status_5xx)),c.serverError)];return t.some(e=>u(e.status_other)>0)&&f.push(d(`Other`,t.map(e=>u(e.status_other)),c.other)),{type:`bar`,data:{labels:s,datasets:f},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{title:e=>e.length?qx(t[e[0].dataIndex],r,i,o):``,label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),precision:0,callback:e=>uc(e)}}}}}}function Xx(e=Vy()){let t={};return function(n){return n in t||(t[n]=e[Object.keys(t).length%e.length]),t[n]}}function Zx(e,t,n,r={}){let i=r.interval===`hour`?`hour`:`day`,a=r.zone,o=r.formatTimestamp||(e=>String(e)),s=r.providerColor||Xx();return{type:`line`,data:{labels:t.map(e=>Kx(e,i,a)),datasets:n.map(e=>({label:e.provider,data:(e.avg_duration_ms||[]).map(e=>e==null?null:Number(e)),borderColor:s(e.provider),backgroundColor:s(e.provider),fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4,spanGaps:i===`hour`&&2}))},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{title:e=>e.length?qx(t[e[0].dataIndex],i,a,o):``,label:e=>{let t=(n[e.datasetIndex]&&n[e.datasetIndex].requests||[])[e.dataIndex],r=Number(t)||0;return e.dataset.label+`: `+Ux(e.parsed.y)+(r>0?` (`+r.toLocaleString()+` req)`:``)}})},scales:{x:{grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),callback:e=>Ux(e)}}}}}}var Qx=class{#e=k(j(Lb()));get status(){return I(this.#e)}set status(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=k(!1);get loadedOnce(){return I(this.#n)}set loadedOnce(e){A(this.#n,e,!0)}#r=k(!1);get detailsExpanded(){return I(this.#r)}set detailsExpanded(e){A(this.#r,e,!0)}#i=k(j({}));get cardOverrides(){return I(this.#i)}set cardOverrides(e){A(this.#i,e,!0)}#a=null;#o=null;#s=!1;initPreferences(){if(this.#s)return;this.#s=!0;let e=Rb(wa());this.detailsExpanded=e.detailsExpanded,this.cardOverrides=e.cardOverrides}cardExpanded(e){return Vb(this.cardOverrides,this.detailsExpanded,e)}toggleCard(e){let t=e&&e.name?String(e.name):``;if(!t)return;let n={...this.cardOverrides};n[t]=!this.cardExpanded(e),this.cardOverrides=n,Bb(wa(),this.cardOverrides)}toggleDetails(){this.detailsExpanded=!this.detailsExpanded,this.cardOverrides={},zb(wa(),this.detailsExpanded),Bb(wa(),this.cardOverrides)}detailsToggleLabel(){return this.detailsExpanded?`Show Details`:`Hide Details`}async fetch(){this.initPreferences(),this.#a&&this.#a.abort();let e=new AbortController;this.#a=e,this.loading=!0;try{let t=await _s(`/admin/providers/status`,{label:`provider status`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.status=Lb(),this.#l();return}let n=t.data&&typeof t.data==`object`?t.data:Lb();n.summary||=Lb().summary,Array.isArray(n.providers)||(n.providers=[]),this.status=n,this.#c()}catch(e){if(ys(e))return;console.error(`Failed to fetch provider status:`,e),this.status=Lb(),this.#l()}finally{this.#a===e&&(this.#a=null,this.loading=!1,this.loadedOnce=!0)}}#c(){this.#l(),qb(this.status.providers)&&(this.#o=setTimeout(()=>{this.#o=null,this.fetch()},Pb))}#l(){this.#o&&=(clearTimeout(this.#o),null)}stopPolling(){this.#l()}},$x=class{#e=k(j(Lx()));get stats(){return I(this.#e)}set stats(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=0;async fetch(){let e=++this.#n;this.loading=!0;try{let t=await _s(`/admin/audit/stats?`+Mc.queryStr(),{label:`audit stats`});if(t.stale||e!==this.#n)return;if(!t.ok){this.stats=Lx();return}this.stats=Rx(t.data)}catch(t){if(console.error(`Failed to fetch audit stats:`,t),e!==this.#n)return;this.stats=Lx()}finally{e===this.#n&&(this.loading=!1)}}},eS=class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!1);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}async fetch(){if(await Ss.ensureLoaded(),!Ss.mcpVisible()){this.available=!1,this.servers=[];return}this.loading=!0;try{let e=await _s(`/admin/mcp-servers`,{label:`mcp servers`});if(e.stale)return;if(e.status===503||e.status===404){this.available=!1,this.servers=[];return}if(this.available=!0,!e.ok){this.servers=[];return}this.servers=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch MCP servers:`,e),this.servers=[]}finally{this.loading=!1}}},tS=class{#e=k(j([]));get data(){return I(this.#e)}set data(e){A(this.#e,e,!0)}#t=k(`tokens`);get mode(){return I(this.#t)}set mode(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=null;async fetch(){this.#r&&this.#r.abort();let e=new AbortController;this.#r=e,this.loading=!0;try{let t=await _s(`/admin/usage/daily?days=365&interval=daily`,{label:`calendar`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.data=[];return}this.data=Array.isArray(t.data)?t.data:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch calendar data:`,e),this.data=[]}finally{this.#r===e&&(this.#r=null,this.loading=!1)}}},nS=new Qx,rS=new $x,iS=new eS,aS=new tS,oS=(e,t=f,n=f,r=f,i=f)=>{var a=cS(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=M(c),u=M(l),d=M(u,!0);T(u),Ue(),T(l);var p=P(l,4),m=M(p),h=M(m,!0);T(m),Ue(),T(p);var g=P(p,4),_=M(g,!0);T(g),T(c),T(a),F((e,n,r,i,a,o)=>{B(s,t()),W(l,`title`,e),B(d,n),W(p,`title`,r),B(h,i),W(g,`title`,a),B(_,o)},[()=>dc(`Input tokens`,n()),()=>uc(n()),()=>dc(`Output tokens`,r()),()=>uc(r()),()=>dc(`Total tokens`,i()),()=>uc(i())]),z(e,a)},sS=(e,t=f,n=f,r=f,i=f,a=f,o=f)=>{var s=dS(),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u);var p=P(u,2),m=e=>{var t=lS(),n=M(t,!0);T(t),F(()=>{W(t,`aria-label`,o().title),W(t,`title`,o().title),B(n,a())}),L(`click`,t,function(...e){o().onclick?.apply(this,e)}),z(e,t)},h=e=>{var t=uS(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(p,e=>{o()?e(m):e(h,-1)}),T(s),F(()=>{U(s,1,`card provider-status-flag ${t()??``} ${n()??``}`,`svelte-6tr9cf`),B(l,r()),B(d,i())}),z(e,s)},cS=R(`
i + o =
`),lS=R(``),uS=R(` `),dS=R(`
`),fS=R(`
Cache Hits
`),pS=R(`
Total Requests
Estimated Cost
Prompt Cache Rate
`);function mS(e,t){E(t,!0);let n=O(()=>Rc.summary),r=O(()=>Rc.cacheOverview),i=O(()=>Rc.cacheAnalyticsEnabled()),a=O(()=>nS.status.summary);function o(){let e=document.getElementById(`provider-status-section`);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),e.focus({preventScroll:!0}))}var s=pS(),c=M(s);{let e=O(()=>fb(I(n)));oS(c,()=>`Tokens`,()=>I(n).total_input_tokens,()=>I(n).total_output_tokens,()=>I(e))}var l=P(c,2),u=P(M(l),2),d=M(u,!0);T(u),T(l);var f=P(l,2),p=e=>{var t=fS(),n=P(M(t),2),i=M(n,!0);T(n),T(t),F(e=>B(i,e),[()=>oc(I(r).summary.total_hits)]),z(e,t)};V(f,e=>{I(i)&&e(p)});var m=P(f,2),h=P(M(m),2),g=M(h,!0);T(h),T(m);var _=P(m,2),v=e=>{{let t=O(()=>gb(I(r)));oS(e,()=>`Local Cache`,()=>I(r).summary.total_input_tokens,()=>I(r).summary.total_output_tokens,()=>I(t))}};V(_,e=>{I(i)&&e(v)});var y=P(_,2),b=P(M(y),2),x=M(b);jy(x,{build:()=>jb(Db(I(n)),zy(`var(--token-prompt)`),zy(`var(--bg-surface-hover)`))});var S=P(x,2),C=M(S,!0);T(S),T(b),T(y);var w=P(y,2),ee=e=>{{let t=O(()=>Hb(I(a))),n=O(()=>Wb(I(a))),r=O(()=>Kb(I(a))),i=O(()=>Gb(I(a))?{title:`View providers overview`,onclick:o}:null);sS(e,()=>`provider-status-overview-card`,()=>I(t),()=>`Provider Status`,()=>I(n),()=>I(r),()=>I(i))}};V(w,e=>{I(a).total>0&&e(ee)});var te=P(w,2),ne=e=>{{let t=O(()=>Fx(iS.servers)),n=O(()=>Px(iS.servers)),r=O(()=>Ix(iS.servers));sS(e,()=>`mcp-servers-flag`,()=>I(t),()=>`MCP Servers`,()=>I(n),()=>I(r),()=>({title:`View MCP servers`,onclick:()=>Jo.navigate(`mcp-servers`)}))}},re=O(()=>Nx(iS.available,iS.servers));V(te,e=>{I(re)&&e(ne)}),T(s),F((e,t,n,r,i)=>{W(u,`title`,e),B(d,t),B(g,n),W(b,`aria-label`,r),B(C,i)},[()=>hb(I(n),I(r),I(i)),()=>oc(mb(I(n),I(r),I(i))),()=>sc(I(n).total_cost),()=>`Prompt cache rate `+kb(I(n)),()=>kb(I(n))]),z(e,s),D()}Hr([`click`]);var hS=R(` `),gS=R(`
`),_S=R(`No usage in the selected period yet`),vS=R(`
`),yS=R(`

Tokens

Share of input tokens over the selected period
`);function bS(e,t){E(t,!0);let n=O(()=>Rc.cacheAnalyticsEnabled()),r=O(()=>bb(Rc.summary,Rc.cacheOverview,I(n))),i=O(()=>xb(Rc.summary,Rc.cacheOverview,I(n))),a=O(()=>yb(Rc.summary,Rc.cacheOverview,I(n)));var o=yS(),s=P(M(o),2);let c;var l=M(s);H(l,17,()=>I(i),e=>e.key,(e,t)=>{var n=gS(),r=M(n),i=e=>{var n=hS(),r=M(n);T(n),F(()=>B(r,`${I(t).pct??``}%`)),z(e,n)};V(r,e=>{I(t).pct>=8&&e(i)}),T(n),F(e=>{Hi(n,`width: ${I(t).pct??``}%; background: var(${I(t).colorVar??``})`),W(n,`title`,e)},[()=>Sb(I(t))]),z(e,n)});var u=P(l,2),d=e=>{z(e,_S())};V(u,e=>{I(a)||e(d)}),T(s);var f=P(s,2);H(f,21,()=>I(r),e=>e.key,(e,t)=>{var n=vS(),r=M(n),i=P(r,2),a=M(i,!0);T(i);var o=P(i,2),s=M(o);T(o);var c=P(o,2),l=M(c,!0);T(c),T(n),F((e,i)=>{W(n,`title`,e),Hi(r,`background: var(${I(t).colorVar??``})`),B(a,I(t).label),B(s,`${I(t).pct??``}%`),B(l,i)},[()=>Sb(I(t)),()=>oc(I(t).tokens)]),z(e,n)}),T(f),T(o),F(e=>{c=U(s,1,`cache-meter-bar svelte-1yzecxj`,null,c,{"is-empty":!I(a)}),W(s,`aria-label`,e)},[()=>Cb(I(i))]),z(e,o),D()}var xS=R(``);function SS(e,t){let n=ya(t,`size`,3,16),r=ya(t,`label`,3,`Loading`),i=ya(t,`class`,3,``);var a=xS();F(()=>{U(a,1,Fi([`spinner`,i()]),`svelte-b54l9o`),Hi(a,`--spinner-size: ${n()??``}px`),W(a,`aria-label`,r())}),z(e,a)}var CS=Xr(` `),wS=Xr(``);function TS(e,t){let n=ya(t,`label`,3,`No data`);var r=wS(),i=P(M(r),9),a=e=>{var t=CS(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(i,e=>{n()&&e(a)}),T(r),F(()=>{W(r,`role`,n()?`img`:void 0),W(r,`aria-label`,n()||void 0),W(r,`aria-hidden`,n()?void 0:`true`)}),z(e,r)}var ES=R(`
`),DS=R(`

`);function OS(e,t){E(t,!0);let n=[`daily`,`weekly`,`monthly`,`yearly`];function r(e){Mc.interval=e,t.onintervalchange?.()}function i(){let e=Rc.daily;if(e.length===0)return null;let t=Mc.rangeStart(),n=Mc.rangeEnd(),r=Eb(Tb(e,Mc.interval,t,n),Tb(Array.isArray(Rc.cacheOverview.daily)?Rc.cacheOverview.daily:[],Mc.interval,t,n));return Ab(Iy(),r,{cacheEnabled:Rc.cacheAnalyticsEnabled(),resolve:zy})}var a=DS(),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2);{let e=O(()=>n.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})));Py(l,{ariaLabel:`Usage chart interval`,get options(){return I(e)},get value(){return Mc.interval},onchange:r})}T(o);var u=P(o,2),d=M(u);jy(d,{build:i});var f=P(d,2),p=e=>{var t=ES();SS(M(t),{size:24,label:`Loading usage`}),T(t),z(e,t)},m=e=>{var t=ES();TS(M(t),{}),T(t),z(e,t)};V(f,e=>{Rc.daily.length===0&&Rc.loading?e(p):Rc.daily.length===0&&!K.authError&&e(m,1)}),T(u),T(a),F(e=>B(c,e),[()=>Mc.chartTitle()]),z(e,a),D()}var kS=10,AS=.7;function jS(e,t){if(e<=0||t<=0)return 0;let n=(e/t)**+AS,r=Math.ceil(n*kS);return r<1?1:r>kS?kS:r}function MS(){let e=[];for(let t=0;t<=kS;t++)e.push(t);return e}function NS(e,t,n){let r={};(e||[]).forEach(e=>{r[e.date]=e});let i=Qo(es(n,-364)),a=i.getUTCDay();i.setUTCDate(i.getUTCDate()-a);let o=[];for(let e=new Date(i);$o(e)<=n;e.setUTCDate(e.getUTCDate()+1)){let n=$o(e),i=r[n],a=0;i&&(a=t===`costs`?i.total_cost==null?0:i.total_cost:i.total_tokens||0),o.push({dateStr:n,value:a,level:0,empty:!1})}let s=0;for(let e=0;es&&(s=o[e].value);for(let e=0;e0){for(;l.length<7;)l.push({dateStr:``,value:0,level:0,empty:!0});c.push(l)}return c}function PS(e){let t=Qo(es(e,-364)),n=t.getUTCDay();t.setUTCDate(t.getUTCDate()-n);let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],i=[],a={},o=0;for(let n=new Date(t);$o(n)<=e;n.setUTCDate(n.getUTCDate()+7),o++){let t=null;if(o===0)t=new Date(n);else for(let r=0;r<7;r++){let i=new Date(n);if(i.setUTCDate(n.getUTCDate()+r),$o(i)>e)break;if(i.getUTCDate()===1){t=i;break}}if(!t)continue;let s=t.getUTCFullYear()+`-`+t.getUTCMonth();a[s]||(i.push({label:r[t.getUTCMonth()],col:o,key:s}),a[s]=!0)}for(let e=0;e `),RS=R(`
`),zS=R(`
`),BS=R(`
`),VS=R(`
`),HS=R(`

Activity

Mon Wed Fri
`,1);function US(e,t){E(t,!0);let n=k(j({show:!1,x:0,y:0,text:``})),r=O(()=>ds.currentDateKey()),i=O(()=>NS(aS.data,aS.mode,I(r))),a=O(()=>PS(I(r)));function o(e,t){t.empty||A(n,{show:!0,x:e.clientX,y:e.clientY,text:IS(t,aS.mode)},!0)}function s(){A(n,{show:!1,x:0,y:0,text:``},!0)}var c=HS(),l=N(c),u=M(l),d=P(M(u),2),f=e=>{SS(e,{size:14,label:`Loading activity`})};V(d,e=>{aS.loading&&aS.data.length===0&&e(f)}),Py(P(d,2),{ariaLabel:`Activity calendar mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return aS.mode},onchange:e=>aS.mode=e}),T(u);var p=P(u,2),m=P(M(p),2),h=M(m);H(h,21,()=>I(a),e=>e.key,(e,t)=>{var n=LS(),r=M(n,!0);T(n),F(()=>{Hi(n,`grid-column: ${I(t).col+1} / span ${I(t).span??``}`),B(r,I(t).label)}),z(e,n)}),T(h);var g=P(h,2);H(g,21,()=>I(i),oi,(e,t,n)=>{var r=zS();H(r,23,()=>I(t),(e,t)=>n+`-`+t,(e,t)=>{var n=RS();F(()=>U(n,1,Fi([`contribution-calendar-cell`,I(t).empty?`empty`:`level-${I(t).level}`]),`svelte-3hfxuq`)),Vr(`mouseenter`,n,e=>o(e,I(t))),Vr(`mouseleave`,n,s),z(e,n)}),T(r),z(e,r)}),T(g),T(m),T(p);var _=P(p,2),v=M(_),y=M(v),b=M(y,!0);T(y),T(v);var x=P(v,2);H(P(M(x),2),16,MS,e=>e,(e,t)=>{var n=BS();F(()=>U(n,1,`contribution-calendar-cell level-${t??``}`,`svelte-3hfxuq`)),z(e,n)}),Ue(2),T(x),T(_),T(l);var S=P(l,2),C=e=>{var t=VS(),r=M(t,!0);T(t),F(()=>{Hi(t,`left: ${I(n).x??``}px; top: ${I(n).y-40}px`),B(r,I(n).text)}),z(e,t)};V(S,e=>{I(n).show&&e(C)}),F(e=>B(b,e),[()=>FS(aS.data,aS.mode)]),z(e,c),D()}var WS=R(``),GS=R(`

`),KS=R(`
`);function qS(e,t){E(t,!0);let n=ya(t,`label`,3,`help`),r=ya(t,`text`,3,``),i=ya(t,`open`,15,!1),a=ya(t,`external`,3,!1),o=O(()=>!!r()||!!t.help||a());var s=KS(),c=M(s),l=M(c);gi(l,()=>t.title??f);var u=P(l,2),d=e=>{var r=WS();let a;F(()=>{a=U(r,1,`inline-help-toggle svelte-y40or3`,null,a,{"is-open":i()}),W(r,`aria-label`,(i()?`Hide `:`Show `)+n()),W(r,`aria-expanded`,i()),W(r,`aria-controls`,t.copyId)}),L(`click`,r,()=>i(!i())),z(e,r)};V(u,e=>{I(o)&&e(d)}),gi(P(u,2),()=>t.extra??f),T(c);var p=P(c,2),m=e=>{var n=GS(),i=M(n),a=e=>{var n=Qr();gi(N(n),()=>t.help),z(e,n)},o=e=>{var t=Zr();F(()=>B(t,r())),z(e,t)};V(i,e=>{t.help?e(a):e(o,-1)}),T(n),F(()=>W(n,`id`,t.copyId)),z(e,n)};V(p,e=>{i()&&I(o)&&!a()&&e(m)}),T(s),z(e,s),D()}Hr([`click`]);var JS=R(`

Provider Latency

`),YS=R(`
Avg
`),XS=R(`

Requests by Status

Success 2xx 4xx 5xx
`,1);function ZS(e,t){E(t,!0);let n=Xx(),r=O(()=>rS.stats);function i(){return{interval:I(r).interval,zone:ds.effectiveTimezone(),resolve:zy,formatTimestamp:e=>ds.formatTimestamp(e)}}var a=Qr(),o=N(a),s=e=>{var t=XS(),a=N(t),o=M(a),s=P(M(o),2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c);var d=P(c,2),f=P(M(d),4),p=M(f,!0);T(f),T(d);var m=P(d,2),h=P(M(m),4),g=M(h,!0);T(h),T(m);var _=P(m,2),v=P(M(_),4),y=M(v,!0);T(v),T(_),T(s),T(o);var b=P(o,2);jy(M(b),{build:()=>Yx(Iy(),I(r).buckets,i())}),T(b),T(a);var x=P(a,2),S=e=>{var t=YS(),a=M(t),o=M(a);qS(o,{copyId:`audit-latency-help-copy`,label:`provider latency help`,text:`Average duration of successful requests as measured at the gateway, per provider. Local cache hits and failed requests are excluded; streamed responses count until the stream completes.`,title:e=>{z(e,JS())},$$slots:{title:!0}});var s=P(o,2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c),T(s),T(a);var d=P(a,2);jy(M(d),{build:()=>Zx(Iy(),I(r).buckets,I(r).provider_latency,{...i(),providerColor:n})}),T(d),T(t),F(e=>B(u,e),[()=>Wx(I(r))]),z(e,t)},C=O(()=>Bx(I(r)));V(x,e=>{I(C)&&e(S)}),F((e,t,n,r)=>{B(u,e),B(p,t),B(g,n),B(y,r)},[()=>Vx(I(r)),()=>oc(Hx(I(r),`status_2xx`)),()=>oc(Hx(I(r),`status_4xx`)),()=>oc(Hx(I(r),`status_5xx`))]),z(e,t)},c=O(()=>zx(I(r)));V(o,e=>{I(c)&&e(s)}),z(e,a),D()}var QS=(e,t=f,n=f,r)=>{let i=Ot(()=>h(r?.(),!1));var a=tC(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=e=>{var t=$S(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)},u=e=>{var t=eC(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(c,e=>{I(i)?e(l):e(u,-1)}),T(a),F(()=>B(s,t())),z(e,a)},$S=R(` `),eC=R(` `),tC=R(`
`),nC=R(`

`),rC=R(`
Breaker State
`),iC=R(`
`),aC=R(`
Models (Recent Traffic)
`),oC=R(`
`),sC=R(`

`);function cC(e,t){E(t,!0);let n=O(()=>ox(t.provider)),r=O(()=>[[`Base URL`,t.provider.config?.base_url],[`API Version`,t.provider.config?.api_version]].filter(([,e])=>!!e));var i=sC();let a;var o=M(i),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{var n=nC(),r=M(n,!0);T(n),F(()=>B(r,t.provider.last_error)),z(e,n)};V(l,e=>{t.provider.last_error&&e(u)});var d=P(l,2),f=e=>{var r=oC(),i=M(r);{let e=O(()=>sx(t.provider));QS(i,()=>`Recent Requests`,()=>I(e))}var a=P(i,2),o=e=>{var r=rC(),i=P(M(r),2),a=M(i),o=M(a,!0);T(a),T(i),T(r),F(e=>{U(a,1,Fi([`provider-status-health-state`,I(n)]),`svelte-6y9wjv`),B(o,e)},[()=>ax(t.provider)]),z(e,r)},s=O(()=>ix(t.provider));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{var n=aC(),r=P(M(n),2);H(r,21,()=>cx(t.provider),e=>e.model,(e,t)=>{var n=iC();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F((e,i)=>{r=U(n,1,`provider-status-health-model svelte-6y9wjv`,null,r,{"is-flagged":I(t).flagged}),W(n,`title`,e),B(a,I(t).model),B(s,i)},[()=>ux(I(t)),()=>lx(I(t))]),z(e,n)}),T(r),T(n),z(e,n)},u=O(()=>cx(t.provider).length>0);V(c,e=>{I(u)&&e(l)}),T(r),z(e,r)},p=O(()=>rx(t.provider));V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=M(m);H(h,17,()=>I(r),([e,t])=>e,(e,t)=>{var n=O(()=>g(I(t),2));QS(e,()=>I(n)[0],()=>I(n)[1],()=>!0)});var _=P(h,2);{let e=O(()=>tx(t.provider));QS(_,()=>`Configured Models`,()=>I(e))}var v=P(_,2);{let e=O(()=>$b(t.provider));QS(v,()=>`Retry`,()=>I(e))}var y=P(v,2);{let e=O(()=>ex(t.provider));QS(y,()=>`Circuit Breaker`,()=>I(e))}T(m),T(o),T(i),F(()=>{a=U(i,1,`provider-status-details svelte-6y9wjv`,null,a,{"is-expanded":t.expanded,"is-collapsed":!t.expanded}),W(i,`aria-hidden`,!t.expanded),B(c,t.provider.status_reason)}),z(e,i),D()}var lC=R(` `),uC=R(``),dC=R(`

Models Available
Last Checked
`);function fC(e,t){E(t,!0);let n=O(()=>nS.cardExpanded(t.provider)),r=e=>ds.formatTimestamp(e);var i=dC(),a=M(i),o=M(a),s=M(o),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=e=>{var n=lC(),r=M(n);T(n),F(e=>B(r,`(${e??``})`),[()=>Zb(t.provider)]),z(e,n)},f=O(()=>Zb(t.provider));V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var n=uC();F((e,t,r)=>{W(n,`href`,e),W(n,`aria-label`,t),W(n,`title`,r)},[()=>Qb(t.provider),()=>`View `+(Zb(t.provider)||t.provider.name)+` provider docs`,()=>`View `+(Zb(t.provider)||t.provider.name)+` provider docs`]),z(e,n)},h=O(()=>Qb(t.provider));V(p,e=>{I(h)&&e(m)}),T(s),T(o);var g=P(o,2),_=M(g,!0);T(g),T(a);var v=P(a,2),y=M(v),b=P(M(y),2),x=M(b,!0);T(b),T(y);var S=P(y,2),C=P(M(S),2),w=M(C,!0);T(C),T(S),T(v);var ee=P(v,2);cC(ee,{get provider(){return t.provider},get expanded(){return I(n)}});var te=P(ee,2);let ne;G(M(te),{get icon(){return Ha},class:`provider-status-card-toggle-icon`}),T(te),T(i),F((e,r,i,a,o)=>{B(l,t.provider.name),U(g,1,`provider-status-pill ${e??``}`,`svelte-nopjmh`),W(g,`title`,r),B(_,t.provider.status_label),B(x,i),W(C,`title`,a),B(w,o),ne=U(te,1,`provider-status-card-toggle svelte-nopjmh`,null,ne,{"is-expanded":I(n)}),W(te,`aria-expanded`,I(n)),W(te,`aria-label`,(I(n)?`Collapse `:`Expand `)+t.provider.name+` details`),W(te,`title`,I(n)?`Collapse details`:`Expand details`)},[()=>Ub(t.provider.status),()=>nx(t.provider),()=>oc(t.provider.runtime?.discovered_model_count),()=>Xb(t.provider,r),()=>Yb(t.provider,r)]),L(`click`,te,()=>nS.toggleCard(t.provider)),z(e,i),D()}Hr([`click`]);var pC=R(`

Providers Overview

`),mC=R(`
`);function hC(e,t){E(t,!0);let n=O(()=>nS.status.providers);var r=Qr(),i=N(r),a=e=>{var t=pC(),r=M(t),i=P(M(r),2),a=M(i),o=M(a,!0);T(a);var s=P(a,2);let c;T(i),T(r);var l=P(r,2);H(l,21,()=>I(n),e=>e.name,(e,t)=>{fC(e,{get provider(){return I(t)}})}),T(l),T(t),F((e,t)=>{W(i,`aria-checked`,nS.detailsExpanded),W(i,`title`,e),B(o,t),c=U(s,1,`provider-status-toggle-track svelte-1kx3uw4`,null,c,{"is-active":nS.detailsExpanded})},[()=>nS.detailsToggleLabel(),()=>nS.detailsToggleLabel()]),L(`click`,i,()=>nS.toggleDetails()),z(e,t)},o=e=>{var t=mC();SS(M(t),{size:18,label:`Loading provider status`}),T(t),z(e,t)};V(i,e=>{I(n).length>0?e(a):nS.loading&&!nS.loadedOnce&&e(o,1)}),z(e,r),D()}Hr([`click`]);var gC=R(`
`);function _C(e,t){E(t,!0);function n(){Rc.fetchUsage(),Rc.fetchCacheOverview(``),rS.fetch(),nS.fetch(),iS.fetch(),aS.fetch()}function r(){Rc.fetchUsage(),Rc.fetchCacheOverview(``),rS.fetch()}function i(){r(),aS.fetch()}An(()=>{if(K.refreshTick,Jo.page===`overview`)return Er(()=>{n(),sb.start()}),()=>{sb.stop(),nS.stopPolling()}});var a=gC(),o=M(a);db(o,{});var s=P(o,4);tl(M(s),{onchange:i}),T(s);var c=P(s,2);Fc(c,{});var l=P(c,2);mS(l,{});var u=P(l,2);bS(u,{});var d=P(u,2);OS(d,{onintervalchange:r});var f=P(d,2);US(f,{});var p=P(f,2);ZS(p,{}),hC(P(p,2),{}),T(a),z(e,a),D()}var vC=`/admin/live/logs?types=audit,usage`;function yC(e,t,n){return!!t&&String(e&&e.id||``).trim()===t||!!n&&String(e&&e.request_id||``).trim()===n}function bC(e){switch(e){case`date_range`:return`Live paused — the selected date range does not include today. Set it to today to resume.`;case`filters`:return`Live paused while filters are active. Clear them to resume.`;case`pagination`:return`Live paused on later pages. Go to the first page to resume.`;default:return``}}function xC(e){let t=vC,n=Number(e||0);return Number.isFinite(n)&&n>0&&(t+=`&cursor=`+encodeURIComponent(String(n))),t}function SC(){return{async consumeLiveLogsBody(e){await Wy(e,e=>this.applyLiveLogEvent(e))},applyLiveLogEvent(e){if(!e||typeof e!=`object`)return;let t=Number(e.seq||0);Number.isFinite(t)&&t>this.liveLogsLastSeq&&(this.liveLogsLastSeq=t);let n=String(e.type||``).trim();if(n!==`heartbeat`){if(n===`reset`){this.reloadLiveLogSources();return}if(n===`audit.removed`){this.removeLiveAuditEntry(e.data);return}if(n.indexOf(`audit.`)===0){this.mergeLiveAuditEntry(e.data||{},n);return}n.indexOf(`usage.`)===0&&(this.mergeLiveUsageEntry(e.data||{},n),typeof this.noteLiveTokenUsage==`function`&&this.noteLiveTokenUsage(n))}},reloadLiveLogSources(){typeof this.fetchUsage==`function`&&this.fetchUsage(),this.page===`audit-logs`&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},auditLivePauseReason(){return!this.auditLog||this.auditLog.offset!==0?`pagination`:this.auditSearch||this.auditMethod||this.auditStatusCode||this.auditStream?`filters`:!this.followsToday&&(this.customStartDate||this.customEndDate)?`date_range`:null},auditLiveInsertAllowed(){return!this.auditLivePauseReason()},usageLiveInsertAllowed(){return this.usageLog&&this.usageLog.offset===0&&!this.usageLogSearch&&!this.usageFilterModel&&!this.usageFilterProvider&&!this.usageFilterLabel&&!this.usageFilterUserPath},mergeLiveAuditEntry(e,t){if(!e||typeof e!=`object`)return;let n=String(e.id||e.request_id||``).trim();if(!n)return;let r=String(e.request_id||``).trim(),i=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],a=i.findIndex(e=>yC(e,n,r)),o=a>=0&&i[a]||{},s=t===`audit.detail`,c=s?{...e,_detail_loaded:!0,_response_partial:!1,bodies_omitted:!1}:this.liveAuditPatch(o,e,t);if(a>=0){let e=this.mergeLiveAuditPatch(o,c);return i.splice(a,1,e),this.auditLog.entries=[...i],this.regroupLiveAuditHead(e),s||this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}let l=this.mergeLiveAuditChild(e,c);if(l)return s||this.fetchExpandedAuditDetailIfReady(l),this.cacheMergedAuditRecord(l,t),l;if(!this.auditLiveInsertAllowed()){this.cacheMergedAuditRecord(c,t);return}if(!s&&this.auditGroupSessions){let e=this.foldLiveAuditIntoThread(c);if(e)return this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}this.auditLog.entries=[this.mergeLiveAuditUsagePatch(c),...i].slice(0,this.auditLog.limit||25),this.auditLog.total=Number(this.auditLog.total||0)+1;let u=this.auditLog.entries[0];return s||this.fetchExpandedAuditDetailIfReady(u),this.cacheMergedAuditRecord(u,t),u},liveAuditPatch(e,t,n){let r=this.liveAuditStateAfter(e._live_state,n),i=this.liveAuditEventFlushed(e._live_state)||this.liveAuditEventFlushed(r),a={...t,_live:!0,_live_state:r,_audit_flushed:i,_live_pending:!i};return n===`audit.stream`?a._response_partial=!0:this.liveAuditStateSettled(n)&&(a._response_partial=!1),a},mergeLiveAuditChild(e,t){let n=this.auditThreadChildren;if(!n||typeof n!=`object`)return null;let r=String(e.id||``).trim(),i=String(e.request_id||``).trim(),a=Object.keys(n);for(let e=0;eyC(e,r,i));if(c<0)continue;let l=this.mergeLiveAuditPatch(s[c]||{},t),u=[...s];return u.splice(c,1,l),this.auditThreadChildren={...n,[a[e]]:{...o,entries:u}},l}return null},regroupLiveAuditHead(e){if(!this.auditGroupSessions)return null;let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=String(e.id||``).trim(),i=n.findIndex(e=>String(e.id||``).trim()===r);if(i<0)return null;let a=n.findIndex((e,n)=>n!==i&&String(e.session_id||``).trim()===t);if(a<0)return null;let o=n[a],s=Date.parse(o&&o.timestamp),c=Date.parse(e&&e.timestamp),l=Number.isFinite(s)&&Number.isFinite(c)&&s>c,u=l?o:e,d=l?e:o,f={...u,session_count:Math.max(1,Number(o.session_count||1))+Math.max(1,Number(e.session_count||1))},p=n.filter((e,t)=>t!==i&&t!==a);return p.unshift(f),this.auditLog.entries=p,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-1),this.prependLiveAuditThreadChild(t,d),f},foldLiveAuditIntoThread(e){let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(e=>String(e.session_id||``).trim()===t);if(r<0)return null;let i=n[r],a=Number(i.session_count),o=this.mergeLiveAuditUsagePatch({...e,session_count:(Number.isFinite(a)&&a>0?a:1)+1}),s=[...n];return s.splice(r,1),s.unshift(o),this.auditLog.entries=s,this.prependLiveAuditThreadChild(t,i),o},prependLiveAuditThreadChild(e,t){let n=this.auditThreadChildren||{},r=n[e],i={...t};delete i.session_count;let a=r&&Array.isArray(r.entries)?{...r,entries:[i,...r.entries],total:Number(r.total||r.entries.length)+1}:{loading:!1,loaded:!1,entries:[i],total:1};this.auditThreadChildren={...n,[e]:a}},removeLiveAuditThreadChild(e,t){let n=this.auditThreadChildren;!n||typeof n!=`object`||Object.keys(n).forEach(r=>{let i=n[r],a=i&&Array.isArray(i.entries)?i.entries:[],o=a.filter(n=>!yC(n,e,t)),s=a.length-o.length;s!==0&&(this.auditThreadChildren={...this.auditThreadChildren,[r]:{...i,entries:o,total:Math.max(0,Number(i.total||a.length)-s)}},this.decrementLiveAuditThreadCount(r,s))})},decrementLiveAuditThreadCount(e,t){let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(t=>String(t.session_id||``).trim()===e);if(r<0)return;let i=n[r],a=[...n];a.splice(r,1,{...i,session_count:Math.max(1,Number(i.session_count||1)-t)}),this.auditLog.entries=a},mergeLiveAuditPatch(e,t){let n={...e,...t};return t.data===void 0&&e.data!==void 0?n.data=e.data:e.data&&t.data&&typeof e.data==`object`&&typeof t.data==`object`&&!Array.isArray(e.data)&&!Array.isArray(t.data)&&(n.data={...e.data,...t.data}),this.mergeLiveAuditUsagePatch(n)},mergeLiveAuditUsagePatch(e){let t=this.liveUsageEntryForAudit(e);if(!t)return e;let n=this.auditEntryWithLiveUsage(e,t);return this.removeSkippedLiveUsage(t),n},liveUsageEntryForAudit(e){let t=String(e&&e.request_id||``).trim();return t&&((this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[]).find(e=>String(e&&e.request_id||``).trim()===t)||this.skippedLiveUsageByRequestId&&this.skippedLiveUsageByRequestId[t])||null},cacheMergedAuditRecord(e,t){return e&&typeof this.cacheAuditRecord==`function`?this.cacheAuditRecord(e,t):e},fetchExpandedAuditDetailIfReady(e){!e||!this.isAuditEntryExpanded||!this.isAuditEntryExpanded(e)||String(e._live_state||``).trim()!==`audit.flushed`&&!e._audit_flushed||typeof this.fetchAuditEntryDetail==`function`&&this.fetchAuditEntryDetail(e)},liveAuditStateRank(e){switch(String(e||``).trim()){case`audit.started`:return 10;case`audit.updated`:case`audit.stream`:return 20;case`audit.completed`:return 30;case`audit.failed`:case`audit.flushed`:case`audit.detail`:return 40;default:return 0}},liveAuditStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveAuditStateRank(n)>this.liveAuditStateRank(r)?n:r},liveAuditStateSettled(e){return this.liveAuditStateRank(e)>=this.liveAuditStateRank(`audit.completed`)},liveAuditEventFlushed(e){let t=String(e||``).trim();return t===`audit.failed`||t===`audit.flushed`||t===`audit.detail`},removeLiveAuditEntry(e){if(!e||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim();if(!t&&!n)return;let r=this.auditLog.entries,i=[],a=0,o=0,s=!1;r.forEach(e=>{if(!yC(e,t,n)){i.push(e);return}a++;let r=String(e.session_id||``).trim(),c=Math.max(1,Number(e.session_count||1));if(!this.auditGroupSessions||!r||c<=1)return;o++;let l=this.auditThreadChildren&&this.auditThreadChildren[r],u=l&&Array.isArray(l.entries)?l.entries.filter(e=>!yC(e,t,n)):[];if(u.length===0){s=!0;return}let d={...u[0],session_id:r,session_count:c-1};i.push(d),this.auditThreadChildren={...this.auditThreadChildren,[r]:{...l,entries:u.slice(1),total:Math.max(0,Number(l.total||c)-1)}}}),a>0&&(this.auditLog.entries=i,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-a+o)),this.removeLiveAuditThreadChild(t,n),s&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},mergeLiveUsageEntry(e,t){if(!e||typeof e!=`object`)return;e={...e,_live_state:t||e._live_state||`usage.completed`};let n=String(e.id||``).trim();if(!n)return;let r=this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[],i=r.findIndex(e=>String(e.id||``).trim()===n);if(i>=0){let t=r[i]||{},n=this.mergeLiveUsagePatch(t,e);if(this.applyLiveUsageToAudit(n),this.liveUsageShouldSkip(n)){r.splice(i,1),this.usageLog.entries=[...r],this.usageLog.total=Math.max(0,Number(this.usageLog.total||0)-1),this.storeSkippedLiveUsage(n);return}r.splice(i,1,n),this.usageLog.entries=[...r],this.removeSkippedLiveUsage(n);return}let a=this.mergeLiveUsagePatch(this.liveUsageSeedForEntry(e),e);if(this.applyLiveUsageToAudit(a),this.liveUsageShouldSkip(a)){this.storeSkippedLiveUsage(a);return}this.removeSkippedLiveUsage(a),this.usageLog.entries=[a,...r].slice(0,this.usageLog.limit||50),this.usageLog.total=Number(this.usageLog.total||0)+1},mergeLiveUsagePatch(e,t){e=e&&typeof e==`object`?e:{};let n=this.liveUsageStateAfter(e._live_state,t&&t._live_state),r=this.liveUsageEventFlushed(e)||this.liveUsageEventFlushed({...t,_live_state:n});return{...e,...t,_live:!0,_live_state:n||`usage.completed`,_live_pending:!r,_usage_flushed:r}},liveUsageShouldSkip(e){return!!(this.usageLogHideCached&&this.liveUsageEntryCached(e))||!this.usageLiveInsertAllowed()},liveUsageSeedForEntry(e){return this.skippedLiveUsageForEntry(e)||this.auditLiveUsageForEntry(e)},skippedLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();return t&&this.skippedLiveUsageByRequestId?this.skippedLiveUsageByRequestId[t]:null},auditLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return null;let n=this.auditLog.entries.find(e=>String(e&&e.request_id||``).trim()===t),r=n&&n.usage&&typeof n.usage==`object`&&!Array.isArray(n.usage)?n.usage:null;return r?{id:e&&e.id,request_id:t,entries:r.entries,input_tokens:r.input_tokens,uncached_input_tokens:r.uncached_input_tokens,cached_input_tokens:r.cached_input_tokens,cache_write_input_tokens:r.cache_write_input_tokens,output_tokens:r.output_tokens,total_tokens:r.total_tokens,cached_input_ratio:r.cached_input_ratio,estimated_cached_characters:r.estimated_cached_characters,_live_state:n._usage_live_state,_live_pending:n._usage_live_pending,_usage_flushed:n._usage_flushed}:null},storeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&((!this.skippedLiveUsageByRequestId||typeof this.skippedLiveUsageByRequestId!=`object`||Array.isArray(this.skippedLiveUsageByRequestId))&&(this.skippedLiveUsageByRequestId={}),this.skippedLiveUsageByRequestId[t]=e)},removeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&this.skippedLiveUsageByRequestId&&delete this.skippedLiveUsageByRequestId[t]},liveUsageEntryCached(e){let t=String(e&&e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`||!!(e&&e.cache_hit)},liveUsageEventFlushed(e){let t=String(e&&e._live_state||``).trim();return!!(e&&e._usage_flushed)||t===`usage.failed`||t===`usage.flushed`},liveUsageStateRank(e){switch(String(e||``).trim()){case`usage.completed`:return 10;case`usage.failed`:case`usage.flushed`:return 20;default:return 0}},liveUsageStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveUsageStateRank(n)>this.liveUsageStateRank(r)?n:r},applyLiveUsageToAudit(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let n=this.auditLog.entries.findIndex(e=>String(e.request_id||``).trim()===t);if(n>=0){let t=this.auditLog.entries[n];this.auditLog.entries.splice(n,1,this.auditEntryWithLiveUsage(t,e)),this.auditLog.entries=[...this.auditLog.entries]}let r=this.auditThreadChildren;if(!r||typeof r!=`object`)return;let i=r,a=!1;Object.keys(r).forEach(n=>{let r=i[n],o=r&&Array.isArray(r.entries)?r.entries:[],s=o.findIndex(e=>String(e.request_id||``).trim()===t);if(s<0)return;let c=[...o];c.splice(s,1,this.auditEntryWithLiveUsage(o[s],e)),i={...i,[n]:{...r,entries:c}},a=!0}),a&&(this.auditThreadChildren=i)},auditEntryWithLiveUsage(e,t){let n=this.liveUsageStateAfter(e._usage_live_state,t._live_state||`usage.completed`),r=this.liveUsageEventFlushed({_live_state:n,_usage_flushed:e._usage_flushed||t._usage_flushed});return{...e,usage:this.liveUsageSummary(t,e.usage),_usage_live_state:n||`usage.completed`,_usage_live_pending:!r,_usage_flushed:r}},liveUsageSummary(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=this.liveNumber(e.input_tokens,this.liveNumber(n.input_tokens,0)),i=this.liveNumber(e.output_tokens,this.liveNumber(n.output_tokens,0)),a=this.liveNumber(e.uncached_input_tokens,this.liveNumber(n.uncached_input_tokens,0)),o=this.liveNumber(e.cached_input_tokens,this.liveNumber(n.cached_input_tokens,0)),s=this.liveNumber(e.cache_write_input_tokens,this.liveNumber(n.cache_write_input_tokens,0));r>0&&a+o+s===0&&(a=r);let c=a+o+s||r,l=c+i||this.liveNumber(e.total_tokens,this.liveNumber(n.total_tokens,0)),u=this.liveNumber(e.cached_input_ratio,this.liveNumber(n.cached_input_ratio,c>0?o/c:0));return{entries:Math.max(1,this.liveNumber(e.entries,this.liveNumber(n.entries,1))),input_tokens:c,uncached_input_tokens:a,cached_input_tokens:o,cache_write_input_tokens:s,output_tokens:i,total_tokens:l,cached_input_ratio:u,estimated_cached_characters:this.liveNumber(e.estimated_cached_characters,this.liveNumber(n.estimated_cached_characters,o*4))}},liveNumber(e,t){let n=Number(e);return Number.isFinite(n)?n:t},auditEntryShouldFetchDetail(e){return!e||e._detail_loading||e._detail_loaded||this.auditEntryLiveDetailPending(e)?!1:this.auditEntryNeedsPersistedLiveDetail(e)||e.bodies_omitted?!0:!this.auditEntryHasDetailData(e)},auditEntryLiveDetailPending(e){if(!e||!e._live)return!1;let t=String(e._live_state||``).trim();return t===`audit.failed`||!e._audit_flushed&&t!==`audit.flushed`&&t!==`audit.detail`},auditEntryNeedsPersistedLiveDetail(e){return!!(e&&e._live&&!e._detail_loaded)},auditEntryHasDetailData(e){let t=e&&e.data;return!t||typeof t!=`object`?!1:t.request_headers!==void 0||t.response_headers!==void 0||t.request_body!==void 0||t.response_body!==void 0||t.request_body_too_big_to_handle!==void 0||t.response_body_too_big_to_handle!==void 0||t.user_agent!==void 0||t.api_key_hash!==void 0||t.temperature!==void 0||t.max_tokens!==void 0||t.error_message!==void 0||t.error_code!==void 0},clearAuditDetailLoading(e){if(!e)return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim(),r=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],i=r.find(e=>t&&String(e.id||``).trim()===t?!0:!!(n&&String(e.request_id||``).trim()===n)),a=i||e;a._detail_loading=!1,i&&(this.auditLog.entries=[...r])}}}var CC={"audit.started":10,"audit.updated":20,"audit.stream":20,"audit.completed":30,"audit.failed":40,"audit.flushed":40,"audit.detail":40},wC=new Set(Object.keys(CC));function TC(e){return String(e&&(e.id||e.request_id)||``).trim()}function EC(e,t){let n=e&&typeof e==`object`?e:{},r=t&&typeof t==`object`?t:{},i={...n,...r};r.data==null&&n.data!=null?i.data=n.data:kC(n.data)&&kC(r.data)&&(i.data={...n.data,...r.data});let a=String(n._live_state||``).trim(),o=String(r._live_state||``).trim();return(CC[a]||0)>(CC[o]||0)&&(i._live_state=a),n._audit_flushed&&(i._audit_flushed=!0),i._audit_flushed&&(i._live_pending=!1),n._detail_loaded&&!r._detail_loaded&&(i._detail_loaded=!0,i.bodies_omitted=!1),i.bodies_omitted&&kC(i.data)&&(i.data.request_body!==void 0||i.data.response_body!==void 0)&&(i.bodies_omitted=!1),i}function DC(e,t){let n=Number(t||0);return(Array.isArray(e)?e:[]).filter(e=>Number(e&&e.version||0)>n)}function OC(e){return wC.has(String(e&&e.eventType||``).trim())}function kC(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var AC=200,jC=class{#e=k(j({entries:[],total:0,limit:25,offset:0}));get auditLog(){return I(this.#e)}set auditLog(e){A(this.#e,e,!0)}#t=k(j({entries:[],total:0,limit:50,offset:0}));get usageLog(){return I(this.#t)}set usageLog(e){A(this.#t,e,!0)}#n=k(j({}));get auditRecords(){return I(this.#n)}set auditRecords(e){A(this.#n,e,!0)}#r=k(j([]));get auditRecordChanges(){return I(this.#r)}set auditRecordChanges(e){A(this.#r,e,!0)}auditRecordVersion=0;auditRecordPins=new Set;#i=k(``);get auditSearch(){return I(this.#i)}set auditSearch(e){A(this.#i,e,!0)}#a=k(``);get auditMethod(){return I(this.#a)}set auditMethod(e){A(this.#a,e,!0)}#o=k(``);get auditStatusCode(){return I(this.#o)}set auditStatusCode(e){A(this.#o,e,!0)}#s=k(``);get auditStream(){return I(this.#s)}set auditStream(e){A(this.#s,e,!0)}#c=k(Ta(`gomodel_audit_group_sessions`,`true`)!==`false`);get auditGroupSessions(){return I(this.#c)}set auditGroupSessions(e){A(this.#c,e,!0)}#l=k(j({}));get auditThreadChildren(){return I(this.#l)}set auditThreadChildren(e){A(this.#l,e,!0)}#u=k(``);get usageLogSearch(){return I(this.#u)}set usageLogSearch(e){A(this.#u,e,!0)}#d=k(``);get usageFilterModel(){return I(this.#d)}set usageFilterModel(e){A(this.#d,e,!0)}#f=k(``);get usageFilterProvider(){return I(this.#f)}set usageFilterProvider(e){A(this.#f,e,!0)}#p=k(``);get usageFilterLabel(){return I(this.#p)}set usageFilterLabel(e){A(this.#p,e,!0)}#m=k(``);get usageFilterUserPath(){return I(this.#m)}set usageFilterUserPath(e){A(this.#m,e,!0)}#h=k(!1);get usageLogHideCached(){return I(this.#h)}set usageLogHideCached(e){A(this.#h,e,!0)}#g=k(!1);get liveLogsStreaming(){return I(this.#g)}set liveLogsStreaming(e){A(this.#g,e,!0)}liveLogsLastSeq=0;liveLogsReconnectAttempts=0;liveLogsReconnectTimer=null;liveLogsController=null;skippedLiveUsageByRequestId=null;fetchUsage=null;fetchAuditLog=null;isAuditEntryExpanded=null;noteLiveTokenUsage=null;upsertAuditRecord(e,t=``){let n=TC(e);if(!n)return e;let r=EC(this.auditRecords[n],e);return this.auditRecords={...this.auditRecords,[n]:r},this.pruneAuditRecords(),this.auditRecordVersion++,this.auditRecordChanges=[...this.auditRecordChanges,{version:this.auditRecordVersion,key:n,eventType:t}].slice(-512),r}upsertAuditRecords(e,t=``){return(Array.isArray(e)?e:[]).map(e=>this.upsertAuditRecord(e,t))}auditRecord(e){let t=typeof e==`string`?String(e).trim():TC(e);return t&&this.auditRecords[t]||null}cacheAuditRecord(e,t){return this.upsertAuditRecord(e,t)}pinAuditRecords(e){this.auditRecordPins=new Set((Array.isArray(e)?e:[]).map(String))}pruneAuditRecords(){let e=Object.keys(this.auditRecords);if(e.length<=AC)return;let t={...this.auditRecords},n=e.length-AC;for(let r of e){if(n<=0)break;this.auditRecordPins.has(r)||(delete t[r],n--)}this.auditRecords=t}get page(){return Jo.page}get customStartDate(){return Mc.customStartDate}get customEndDate(){return Mc.customEndDate}get followsToday(){return Mc.followsToday}liveLogsEnabled(){return Ss.liveLogsVisible()}async startLiveLogs(){typeof fetch!=`function`||typeof ReadableStream>`u`||(await Ss.ensureLoaded(),this.liveLogsEnabled()&&(this.stopLiveLogs(),this.liveLogsController=typeof AbortController==`function`?new AbortController:null,this.readLiveLogsStream(this.liveLogsController)))}stopLiveLogs(){this.liveLogsStreaming=!1,this.liveLogsReconnectTimer&&=(clearTimeout(this.liveLogsReconnectTimer),null),this.liveLogsController&&typeof this.liveLogsController.abort==`function`&&this.liveLogsController.abort(),this.liveLogsController=null}ensureLiveLogs(){this.liveLogsController||this.liveLogsReconnectTimer||this.startLiveLogs()}async readLiveLogsStream(e){let t={};e&&(t.signal=e.signal);let n=xC(this.liveLogsLastSeq),r=K.generation;try{let i=await hs(n,t);if(i.status===401){if(K.handleUnauthorized(r),r{this.liveLogsReconnectTimer=null,this.startLiveLogs()},t)}async fetchAuditEntryDetail(e){if(!this.auditEntryShouldFetchDetail(e))return;let t=String(e.id||``).trim();if(!t)return;e._detail_loading=!0;let n=e;try{let e=await _s(`/admin/audit/detail?log_id=`+encodeURIComponent(t),{label:`audit detail`});if(e.stale||!e.ok)return;n=this.mergeLiveAuditEntry(e.data,`audit.detail`)||n}catch(e){console.error(`Failed to fetch audit detail:`,e)}finally{this.clearAuditDetailLoading(n)}}};Object.assign(jC.prototype,SC());var MC=new jC;if(typeof window<`u`){let e=!1;window.addEventListener(`pagehide`,()=>{e=!!MC.liveLogsController,MC.stopLiveLogs()}),window.addEventListener(`pageshow`,t=>{t.persisted&&e&&MC.ensureLiveLogs()})}var NC=null;Mn(()=>{An(()=>{let e=K.refreshTick;if(NC===null){NC=e;return}e!==NC&&(NC=e,Er(()=>{MC.stopLiveLogs(),MC.startLiveLogs()}))})});function PC(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,uncached_input_tokens:0,cached_input_tokens:0,cache_write_input_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null,rewrite_tokens_saved:0,rewrite_cost_saved:null}}function FC(){return{entries:[],total:0,limit:50,offset:0}}function IC(e,t){let n=[[`model`,e&&e.model],[`provider`,e&&e.provider],[`label`,e&&e.label],[`user_path`,e&&e.user_path]],r=``;for(let[e,i]of n)!i||e===t||(r+=`&`+e+`=`+encodeURIComponent(i));return r}function LC({limit:e,offset:t,hideCached:n,search:r}){let i=`&limit=`+e+`&offset=`+t;return i+=`&cache_mode=`+(n?`uncached`:`all`),r&&(i+=`&search=`+encodeURIComponent(r)),i}function RC(e,t){let n=new Set(e||[]);return t&&n.add(t),[...n].sort()}function zC(e,t){let n=Number(t&&t.total_requests||0)-Number(e&&e.total_requests||0);return Number.isFinite(n)&&n>0?n:0}function BC(e,t,n){let r=n?e:t,i=Number(r&&r.total_requests||0);return Number.isFinite(i)?i:0}function VC(e,t,n){let r=zC(e,t);return r<=0?``:n?oc(r)+` cached requests hidden`:oc(Number(e&&e.total_requests||0))+` to providers + `+oc(r)+` from cache`}function HC(e){let t=e||{};return t.total_input_cost===null||t.total_input_cost===void 0?``:sc(t.total_input_cost)+` input + `+sc(t.total_output_cost)+` output`}function UC(e){let t=Number(e&&e.rewrite_tokens_saved||0);return Number.isFinite(t)&&t>0?t:0}function WC(e){return UC(e)>0}function GC(e){let t=e||{};return t.rewrite_cost_saved===void 0?null:t.rewrite_cost_saved}function KC(){return`Estimated at 4 net characters removed per token`}function qC(e,t){return t===`costs`?sc(GC(e)):uc(UC(e))}function JC(e,t){let n=t===`costs`,r=n?Number(GC(e)):UC(e);if(!Number.isFinite(r)||r<=0)return null;let i=e&&(n?e.total_cost:e.total_input_tokens);if(i==null)return null;let a=Number(i);return!Number.isFinite(a)||a<0?null:r/(a+r)*100}function YC(e,t){let n=JC(e,t);return n===null?``:(n<.1?`<0.1`:n.toFixed(1))+`% less`}function XC(e,t){let n=UC(e);if(n<=0)return``;let r=[oc(n)+` estimated prompt token-transmissions removed across provider requests`,KC(),`Savings are summed per provider request; resent conversation history is counted again`],i=GC(e);i!=null&&(r.push(sc(i)+` estimated gross input cost avoided`),r.push(`Prompt-cache changes caused by rewriting are not included`));let a=YC(e,t);return a&&r.push(a+` than the same traffic without rewriting (`+(t===`costs`?`cost`:`tokens`)+`)`),r.join(` -`)}function ZC(e){return String(e&&e.cost_source||``).trim()}function QC(e){let t=ZC(e);return t===`openrouter_credits`||t===`xai_cost_in_usd_ticks`}function $C(e){switch(ZC(e)){case`openrouter_credits`:return`Costs from OpenRouter USD-based credits.`;case`xai_cost_in_usd_ticks`:return`Costs from xAI usage.cost_in_usd_ticks.`;default:return``}}function ew(e){return String(e&&e.cache_type||``).trim().toLowerCase()}function tw(e){let t=ew(e);return t===`exact`||t===`semantic`}function nw(e){let t=ew(e);return t===`exact`?`Exact`:t===`semantic`?`Semantic`:`-`}function rw(e,t){let n=t?String(t):``;return tw(e)?n?`Saved by cache — not charged -`+n:`Saved by cache — not charged`:n}function iw(e){let t=Number(e&&e.cached_input_ratio);return!Number.isFinite(t)||t<=0?0:Math.min(1,t)}function aw(e){return Number(e&&e.cached_input_tokens||0)>0}function ow(e){return aw(e)?(iw(e)*100).toFixed(1)+`%`:``}function sw(e){if(!aw(e))return``;let t=Number(e.cached_input_tokens||0),n=Number(e.uncached_input_tokens||0),r=Number(e.cache_write_input_tokens||0),i=t+n+r,a=[oc(t)+` cached / `+oc(i)+` input tokens`];return r>0&&a.push(oc(r)+` cache write`),a.join(` -`)}function cw(e){let t=[];if($C(e)&&(t.push($C(e)),t.push(``)),t.push(`Input: `+sc(e.input_cost)),t.push(`Output: `+sc(e.output_cost)),e.raw_data){t.push(``);for(let[n,r]of Object.entries(e.raw_data)){let e=n.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),i=r&&typeof r==`object`?JSON.stringify(r):oc(r);t.push(e+`: `+i)}}return t.join(` -`)}function lw(e){return Array.isArray(e&&e.labels)?e.labels:[]}function uw(e,t,n){return(e||[]).length>0||t?!0:(n||[]).some(e=>lw(e).length>0)}function dw(e){return e&&typeof e.total_tokens==`number`?e.total_tokens:(e&&e.input_tokens||0)+(e&&e.output_tokens||0)}function fw(e,t){return t?e.total_cost||0:dw(e)}function pw(e,t){return[...e||[]].sort((e,n)=>t?(n.total_cost||0)-(e.total_cost||0):fw(n,t)-fw(e,t))}function mw(e){let t=Array.isArray(e)?e:[];if(t.length===0)return!1;if(t.length!==1)return!0;let n=String(t[0]&&t[0].user_path||``).trim();return n!==``&&n!==`/`}function hw(e){return(e||`chart`)===`chart`||e===`stacked`}function gw(e,t,n){let r=pw(e,n),i=e=>Number(e)||0,a=e=>n?Math.min(i(e.cached_input_cost),i(e.input_cost)):i(e.cached_input_tokens),o=e=>n?i(e.input_cost)-a(e):i(e.uncached_input_tokens)+i(e.cached_input_tokens)+i(e.cache_write_input_tokens)>0?i(e.uncached_input_tokens)+i(e.cache_write_input_tokens):i(e.input_tokens),s=e=>i(n?e.output_cost:e.output_tokens),c=e=>n?0:i(e.local_cached_input_tokens),l=e=>n?0:i(e.local_cached_output_tokens),u=r.slice(0,10),d=r.slice(10),f=u.map(t),p=u.map(o),m=u.map(s),h=u.map(a),g=u.map(c),_=u.map(l);if(d.length>0){f.push(`Other`);let e=e=>d.reduce((t,n)=>t+e(n),0);p.push(e(o)),m.push(e(s)),h.push(e(a)),g.push(e(c)),_.push(e(l))}return{labels:f,inputs:p,outputs:m,prompts:h,localIns:g,localOuts:_}}function _w(e){return Math.max(200,e*32+72)}var J=new class{#e=k(`tokens`);get usageMode(){return I(this.#e)}set usageMode(e){A(this.#e,e,!0)}get usageFilterModel(){return MC.usageFilterModel}set usageFilterModel(e){MC.usageFilterModel=e}get usageFilterProvider(){return MC.usageFilterProvider}set usageFilterProvider(e){MC.usageFilterProvider=e}get usageFilterLabel(){return MC.usageFilterLabel}set usageFilterLabel(e){MC.usageFilterLabel=e}get usageFilterUserPath(){return MC.usageFilterUserPath}set usageFilterUserPath(e){MC.usageFilterUserPath=e}#t=k(j({models:[],providers:[],labels:[]}));get usageFacetOptions(){return I(this.#t)}set usageFacetOptions(e){A(this.#t,e,!0)}#n=k(j(PC()));get usageSummary(){return I(this.#n)}set usageSummary(e){A(this.#n,e,!0)}#r=k(j(PC()));get usageSummaryAll(){return I(this.#r)}set usageSummaryAll(e){A(this.#r,e,!0)}#i=k(j([]));get modelUsage(){return I(this.#i)}set modelUsage(e){A(this.#i,e,!0)}#a=k(j([]));get userPathUsage(){return I(this.#a)}set userPathUsage(e){A(this.#a,e,!0)}#o=k(j([]));get labelUsage(){return I(this.#o)}set labelUsage(e){A(this.#o,e,!0)}get usageLog(){return MC.usageLog}set usageLog(e){MC.usageLog=e}get usageLogSearch(){return MC.usageLogSearch}set usageLogSearch(e){MC.usageLogSearch=e}get usageLogHideCached(){return MC.usageLogHideCached}set usageLogHideCached(e){MC.usageLogHideCached=e}#s=k(`chart`);get modelUsageView(){return I(this.#s)}set modelUsageView(e){A(this.#s,e,!0)}#c=k(`chart`);get userPathUsageView(){return I(this.#c)}set userPathUsageView(e){A(this.#c,e,!0)}#l=k(`chart`);get labelUsageView(){return I(this.#l)}set labelUsageView(e){A(this.#l,e,!0)}#u=k(!1);get summaryLoading(){return I(this.#u)}set summaryLoading(e){A(this.#u,e,!0)}#d=k(!1);get modelUsageLoading(){return I(this.#d)}set modelUsageLoading(e){A(this.#d,e,!0)}#f=k(!1);get userPathUsageLoading(){return I(this.#f)}set userPathUsageLoading(e){A(this.#f,e,!0)}#p=k(!1);get labelUsageLoading(){return I(this.#p)}set labelUsageLoading(e){A(this.#p,e,!0)}#m=k(!1);get usageLogLoading(){return I(this.#m)}set usageLogLoading(e){A(this.#m,e,!0)}#h={};#g(e){this.#h[e]&&this.#h[e].abort();let t=new AbortController;return this.#h[e]=t,t}#_(e,t){this.#h[e]===t&&(this.#h[e]=null)}filterQueryStr(e){return IC({model:this.usageFilterModel,provider:this.usageFilterProvider,label:this.usageFilterLabel,user_path:this.usageFilterUserPath},e)}onUsageFilterChanged(){this.fetchUsagePage()}toggleUsageLabelFilter(e){this.usageFilterLabel=this.usageFilterLabel===e?``:e,this.onUsageFilterChanged()}usageLabelChipTitle(e){return this.usageFilterLabel===e?`Clear label filter`:`Filter usage by "`+e+`"`}toggleUsageMode(e){this.usageMode=e,Jo.navigate(`usage`,e===`costs`?`costs`:null)}toggleUsageChartView(e,t){e===`model`&&(this.modelUsageView=t),e===`userPath`&&(this.userPathUsageView=t),e===`label`&&(this.labelUsageView=t)}usageFilterModelOptions(){return RC(this.usageFacetOptions.models,this.usageFilterModel)}usageFilterProviderOptions(){return RC(this.usageFacetOptions.providers,this.usageFilterProvider)}usageFilterLabelOptions(){return RC(this.usageFacetOptions.labels,this.usageFilterLabel)}async fetchUsagePage(){await Ss.ensureLoaded();let e=[this.fetchUsagePageSummary(),this.fetchUsageFacetOptions(),this.fetchModelUsage(),this.fetchUserPathUsage(),this.fetchLabelUsage(),this.fetchUsageLog(!0)];Rc.cacheAnalyticsEnabled()&&e.push(Rc.fetchCacheOverview(this.filterQueryStr())),await Promise.all(e)}async fetchUsagePageSummary(){let e=this.#g(`summary`);this.summaryLoading=!0;try{let t=Mc.queryStr()+this.filterQueryStr(),[n,r]=await Promise.all([_s(`/admin/usage/summary?`+t+`&cache_mode=uncached`,{label:`usage page summary`,signal:e.signal}),_s(`/admin/usage/summary?`+t+`&cache_mode=all`,{label:`usage page summary (all)`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.usageSummary=PC(),this.usageSummaryAll=PC();return}this.usageSummary=n.data&&typeof n.data==`object`?n.data:PC(),this.usageSummaryAll=r.data&&typeof r.data==`object`?r.data:PC()}catch(e){if(ys(e))return;console.error(`Failed to fetch usage page summary:`,e),this.usageSummary=PC(),this.usageSummaryAll=PC()}finally{this.#_(`summary`,e),this.#h.summary===null&&(this.summaryLoading=!1)}}async fetchUsageFacetOptions(){let e=this.#g(`facets`);try{let t=async(t,n)=>{let r=await _s(t+`?`+Mc.queryStr()+this.filterQueryStr(n),{label:`usage facet options`,signal:e.signal});return r.stale?null:r.ok&&Array.isArray(r.data)?r.data:[]},n=t(`/admin/usage/models`,`model`),r=!this.usageFilterModel&&!this.usageFilterProvider,[i,a,o]=await Promise.all([n,r?n:t(`/admin/usage/models`,`provider`),t(`/admin/usage/labels`,`label`)]);if(e.signal.aborted||i===null||a===null||o===null)return;this.usageFacetOptions={models:i.map(e=>e&&e.model).filter(Boolean),providers:a.map(e=>gc(e)).filter(Boolean),labels:o.map(e=>e&&e.label).filter(Boolean)}}catch(e){if(ys(e))return;console.error(`Failed to fetch usage facet options:`,e),this.usageFacetOptions={models:[],providers:[],labels:[]}}finally{this.#_(`facets`,e)}}async#v(e,t,n,r,i){let a=this.#g(e);i(!0);try{let e=await _s(t+`?`+Mc.queryStr()+this.filterQueryStr(),{label:n,signal:a.signal});if(e.stale||a.signal.aborted)return;if(!e.ok){r([]);return}r(Array.isArray(e.data)?e.data:[])}catch(e){if(ys(e))return;console.error(`Failed to fetch `+n+`:`,e),r([])}finally{this.#_(e,a),this.#h[e]===null&&i(!1)}}fetchModelUsage(){return this.#v(`modelUsage`,`/admin/usage/models`,`usage models`,e=>this.modelUsage=e,e=>this.modelUsageLoading=e)}fetchUserPathUsage(){return this.#v(`userPathUsage`,`/admin/usage/user-paths`,`usage user paths`,e=>this.userPathUsage=e,e=>this.userPathUsageLoading=e)}fetchLabelUsage(){return this.#v(`labelUsage`,`/admin/usage/labels`,`usage labels`,e=>this.labelUsage=e,e=>this.labelUsageLoading=e)}async fetchUsageLog(e){let t=this.#g(`usageLog`);this.usageLogLoading=!0;try{e&&(this.usageLog.offset=0);let n=Mc.queryStr()+this.filterQueryStr();n+=LC({limit:this.usageLog.limit,offset:this.usageLog.offset,hideCached:this.usageLogHideCached,search:this.usageLogSearch});let r=await _s(`/admin/usage/log?`+n,{label:`usage log`,signal:t.signal});if(r.stale||t.signal.aborted)return;if(!r.ok){this.usageLog=FC();return}let i=r.data&&typeof r.data==`object`?r.data:FC();i.entries||=[],this.usageLog=i}catch(e){if(ys(e))return;console.error(`Failed to fetch usage log:`,e),this.usageLog=FC()}finally{this.#_(`usageLog`,t),this.#h.usageLog===null&&(this.usageLogLoading=!1)}}usageLogNextPage(){this.usageLog.offset+this.usageLog.limit0&&(this.usageLog.offset=Math.max(0,this.usageLog.offset-this.usageLog.limit),this.fetchUsageLog(!1))}};MC.fetchUsage=()=>{Jo.page===`usage`&&J.fetchUsagePage()};var vw=R(`
`);function yw(e,t){E(t,!0);let n=ya(t,`value`,15,``),r=ya(t,`placeholder`,3,``),i=ya(t,`label`,3,``),a=ya(t,`id`,3,void 0),o=ya(t,`oninput`,3,void 0),s=ya(t,`class`,3,``);var c=vw(),l=M(c);G(l,{get icon(){return vo},class:`filter-input-icon`});var u=P(l,2);na(u),T(c),F(()=>{U(c,1,Fi([`filter-input-wrap`,s()]),`svelte-30xz1k`),W(u,`id`,a()),W(u,`placeholder`,r()),W(u,`aria-label`,i())}),L(`input`,u,function(...e){o()?.apply(this,e)}),da(u,n),z(e,c),D()}Hr([`input`]);function bw(e,t=300){let n=null,r=(...r)=>{clearTimeout(n),n=setTimeout(()=>{n=null,e(...r)},t)};return r.cancel=()=>{clearTimeout(n),n=null},r}var xw=R(``),Sw=R(``),Cw=R(`
`);function ww(e,t){E(t,!0);let n=bw(()=>J.onUsageFilterChanged());An(()=>n.cancel);var r=Cw(),i=M(r),a=M(i);a.value=a.__value=``,H(P(a),16,()=>J.usageFilterModelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(i);var o=P(i,2),s=M(o);s.value=s.__value=``,H(P(s),16,()=>J.usageFilterProviderOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(o);var c=P(o,2),l=e=>{var t=Sw(),n=M(t);n.value=n.__value=``,H(P(n),16,()=>J.usageFilterLabelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(t),L(`change`,t,()=>J.onUsageFilterChanged()),Gi(t,()=>J.usageFilterLabel,e=>J.usageFilterLabel=e),z(e,t)},u=O(()=>J.usageFilterLabelOptions().length>0);V(c,e=>{I(u)&&e(l)}),yw(P(c,2),{class:`usage-page-filters-user-path`,placeholder:`User path /team/alpha`,label:`Filter by user path`,get oninput(){return n},get value(){return J.usageFilterUserPath},set value(e){J.usageFilterUserPath=e}}),T(r),L(`change`,i,()=>J.onUsageFilterChanged()),Gi(i,()=>J.usageFilterModel,e=>J.usageFilterModel=e),L(`change`,o,()=>J.onUsageFilterChanged()),Gi(o,()=>J.usageFilterProvider,e=>J.usageFilterProvider=e),z(e,r),D()}Hr([`change`]);var Tw=R(`
Cache Saved
Cache Hits
`,1);function Ew(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Tw(),n=N(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var a=P(n,2),o=P(M(a),2),s=M(o,!0);T(o),T(a),F((e,t)=>{B(i,e),B(s,t)},[()=>sc(Rc.cacheOverview.summary.total_saved_cost),()=>oc(Rc.cacheOverview.summary.total_hits)]),z(e,t)},a=O(()=>Rc.cacheAnalyticsEnabled());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}var Dw=R(` `),Ow=R(`
Pro Saved
`),kw=R(`
Total Requests
Estimated Cost
`);function Aw(e,t){E(t,!0);let n=O(()=>WC(J.usageSummary)),r=O(()=>qC(J.usageSummary,J.usageMode)),i=O(()=>YC(J.usageSummary,J.usageMode));var a=kw(),o=M(a),s=P(M(o),2),c=M(s),l=e=>{SS(e,{size:18,label:`Loading usage summary`})},u=e=>{var t=Zr();F(e=>B(t,e),[()=>oc(BC(J.usageSummary,J.usageSummaryAll,J.usageLogHideCached))]),z(e,t)};V(c,e=>{J.summaryLoading?e(l):e(u,-1)}),T(s),T(o);var d=P(o,2),f=P(M(d),2),p=M(f),m=e=>{SS(e,{size:18,label:`Loading usage summary`})},h=e=>{var t=Zr();F(e=>B(t,e),[()=>sc(J.usageSummary.total_cost)]),z(e,t)};V(p,e=>{J.summaryLoading?e(m):e(h,-1)}),T(f),T(d);var g=P(d,2),_=e=>{var t=Ow(),n=P(M(t),2),a=M(n),o=M(a,!0);T(a);var s=P(a,2),c=e=>{var t=Dw(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)};V(s,e=>{I(i)&&e(c)}),T(n),T(t),F(e=>{W(n,`title`,e),B(o,I(r))},[()=>XC(J.usageSummary,J.usageMode)]),z(e,t)};V(g,e=>{I(n)&&e(_)}),Ew(P(g,2),{}),T(a),F((e,t)=>{W(s,`title`,e),W(f,`title`,t)},[()=>VC(J.usageSummary,J.usageSummaryAll,J.usageLogHideCached),()=>HC(J.usageSummary)]),z(e,a),D()}function jw(e,t,n,r){let{stacked:i=!1,costs:a=!1,resolve:o=e=>e}=r||{},s=e=>a?`$`+Math.abs(e).toFixed(2):uc(Math.abs(e)),c=e=>a?`$`+Math.abs(e).toFixed(4):Math.abs(e).toLocaleString(),l=e=>e.map(e=>i?Math.abs(e):-Math.abs(e)),u=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:`transparent`,borderWidth:0,borderRadius:4,maxBarThickness:22}),d=e=>(e||[]).some(e=>Math.abs(e)>0),f=[u(a?`Input Cost`:`Input Tokens`,l(n.inputs),o(`var(--token-input)`)),u(a?`Output Cost`:`Output Tokens`,n.outputs,o(`var(--token-output)`))];return d(n.prompts)&&f.push(u(a?`Prompt Cached Cost`:`Prompt Cached`,l(n.prompts),o(`var(--token-prompt)`))),!a&&d(n.localIns)&&f.push(u(`Locally Cached (Input)`,l(n.localIns),o(`var(--token-local)`))),!a&&d(n.localOuts)&&f.push(u(`Locally Cached (Output)`,n.localOuts,o(`var(--token-local)`))),{type:`bar`,data:{labels:t,datasets:f},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:{top:8}},scales:{x:{stacked:!0,beginAtZero:!0,grid:i?{color:e.grid}:{color:t=>t.tick&&t.tick.value===0?e.text:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),callback:e=>s(e)}},y:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Ly(),autoSkip:!1}}},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{label:e=>e.dataset.label+`: `+c(e.parsed.x),footer:e=>{let t=0;return e.forEach(e=>{t+=Math.abs(Number(e.parsed.x))||0}),`Total: `+c(t)}})}}}}var Mw=R(`
`),Nw=R(`

`),Pw=R(`

`,1),Fw=R(`
`),Iw=R(`Model Provider`,1),Lw=R(`User Path`),Rw=R(`Label Requests`,1),zw=R(` `,1),Bw=R(` `),Vw=R(` `,1),Hw=R(` `),Uw=R(`
Input TokensOutput TokensPrompt CachedLocal CachedTotal TokensInput CostOutput CostTotal Cost
`),Ww=R(`
`),Gw=R(`
`);function Kw(e,t){E(t,!0);let n=e=>{var n=Mw(),r=M(n);let a;var o=P(r,2);let s;var l=P(o,2);let u;T(n),F(()=>{W(n,`aria-label`,I(i).group),a=U(r,1,`chart-view-btn svelte-1kee4g8`,null,a,{active:I(c)===`chart`}),W(r,`aria-pressed`,I(c)===`chart`),W(r,`aria-label`,`Show ${I(i).noun??``} chart`),s=U(o,1,`chart-view-btn svelte-1kee4g8`,null,s,{active:I(c)===`stacked`}),W(o,`aria-pressed`,I(c)===`stacked`),W(o,`aria-label`,`Show ${I(i).noun??``} stacked chart`),u=U(l,1,`chart-view-btn svelte-1kee4g8`,null,u,{active:I(c)===`table`}),W(l,`aria-pressed`,I(c)===`table`),W(l,`aria-label`,`Show ${I(i).noun??``} table`)}),L(`click`,r,()=>J.toggleUsageChartView(t.kind,`chart`)),L(`click`,o,()=>J.toggleUsageChartView(t.kind,`stacked`)),L(`click`,l,()=>J.toggleUsageChartView(t.kind,`table`)),z(e,n)},r={model:{group:`Model usage view`,noun:`model usage`,tokensTitle:`Token Usage by Model`,costsTitle:`Cost by Model`},userPath:{group:`User path usage view`,noun:`user path usage`,tokensTitle:`Usage by User Path`,costsTitle:`Cost by User Path`},label:{group:`Label usage view`,noun:`label usage`,tokensTitle:`Usage by Label`,costsTitle:`Cost by Label`}},i=O(()=>r[t.kind]),a=O(()=>t.kind===`model`?e=>vc(e):t.kind===`userPath`?e=>e.user_path||`/`:e=>e.label);function o(e){return t.kind===`model`?(e.provider_name||e.provider||`-`)+`/`+e.model:t.kind===`userPath`?e.user_path||`/`:e.label}let s=O(()=>t.kind===`model`?J.modelUsage:t.kind===`userPath`?J.userPathUsage:J.labelUsage),c=O(()=>t.kind===`model`?J.modelUsageView:t.kind===`userPath`?J.userPathUsageView:J.labelUsageView),l=O(()=>t.kind===`model`?J.modelUsageLoading:t.kind===`userPath`?J.userPathUsageLoading:J.labelUsageLoading),u=O(()=>J.usageMode===`costs`),d=O(()=>t.kind===`userPath`?mw(I(s)):I(s).length>0),f=O(()=>I(u)?I(i).costsTitle:I(i).tokensTitle),p=O(()=>gw(I(s),I(a),I(u))),m=O(()=>pw(I(s),I(u)));function h(){return hw(I(c))?jw(Iy(),I(p).labels,I(p),{stacked:I(c)===`stacked`,costs:I(u),resolve:zy}):null}var g=Qr(),_=N(g),v=e=>{var r=Ww(),a=M(r),s=M(a),u=e=>{qS(e,{copyId:`label-usage-help-copy`,label:`label usage help`,text:`One request can have multiple labels. Such a request counts once under each of its labels, so label rows can overlap and add up to more than the period totals.`,title:e=>{var t=Nw(),n=M(t,!0);T(t),F(()=>B(n,I(f))),z(e,t)},extra:e=>{var t=Qr(),n=N(t),r=e=>{SS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(n,e=>{I(l)&&e(r)}),z(e,t)},$$slots:{title:!0,extra:!0}})},d=e=>{var t=Pw(),n=N(t),r=M(n,!0);T(n);var a=P(n,2),o=e=>{SS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(a,e=>{I(l)&&e(o)}),F(()=>B(r,I(f))),z(e,t)};V(s,e=>{t.kind===`label`?e(u):e(d,-1)});var g=P(s,2);n(g),T(a);var _=P(a,2),v=e=>{var t=Fw();let n;jy(M(t),{build:h}),T(t),F(e=>n=Hi(t,``,n,e),[()=>({height:`${_w(I(p).labels.length)??``}px`})]),z(e,t)},y=O(()=>hw(I(c))),b=e=>{var n=Uw(),r=M(n),i=M(r),a=M(i),s=M(a),c=e=>{var t=Iw();Ue(2),z(e,t)},l=e=>{z(e,Lw())},u=e=>{var t=Rw();Ue(2),z(e,t)};V(s,e=>{t.kind===`model`?e(c):t.kind===`userPath`?e(l,1):e(u,-1)}),Ue(8),T(a),T(i);var d=P(i);H(d,21,()=>I(m),e=>o(e),(e,n)=>{var r=Hw(),i=M(r),a=e=>{var t=zw(),r=N(t),i=M(r,!0);T(r);var a=P(r,2),o=M(a),s=M(o,!0);T(o),T(a),F(e=>{B(i,I(n).model||`-`),B(s,e)},[()=>gc(I(n))||`-`]),z(e,t)},o=e=>{var t=Bw(),r=M(t,!0);T(t),F(()=>B(r,I(n).user_path||`/`)),z(e,t)},s=e=>{var t=Vw(),r=N(t),i=M(r);let a;var o=M(i,!0);T(i),T(r);var s=P(r,2),c=M(s,!0);T(s),F((e,t,r)=>{a=U(i,1,`usage-label-chip`,null,a,{active:J.usageFilterLabel===I(n).label}),Hi(i,`--label-color: ${e??``}`),W(i,`title`,t),B(o,I(n).label),B(c,r)},[()=>Hy(I(n).label),()=>J.usageLabelChipTitle(I(n).label),()=>oc(I(n).requests)]),L(`click`,i,()=>J.toggleUsageLabelFilter(I(n).label)),z(e,t)};V(i,e=>{t.kind===`model`?e(a):t.kind===`userPath`?e(o,1):e(s,-1)});var c=P(i),l=M(c,!0);T(c);var u=P(c),d=M(u,!0);T(u);var f=P(u),p=M(f,!0);T(f);var m=P(f),h=M(m,!0);T(m);var g=P(m),_=M(g,!0);T(g);var v=P(g),y=M(v,!0);T(v);var b=P(v),x=M(b,!0);T(b);var S=P(b),C=M(S,!0);T(S),T(r),F((e,t,n,r,i,a,o,s,c,u,g)=>{B(l,e),B(d,t),W(f,`title`,n),B(p,r),W(m,`title`,`${i??``} input + ${a??``} output`),B(h,o),B(_,s),B(y,c),B(x,u),B(C,g)},[()=>oc(I(n).input_tokens),()=>oc(I(n).output_tokens),()=>I(n).cached_input_cost==null?``:`~`+sc(I(n).cached_input_cost)+` at current cached-input pricing`,()=>oc(I(n).cached_input_tokens||0),()=>oc(I(n).local_cached_input_tokens||0),()=>oc(I(n).local_cached_output_tokens||0),()=>oc((I(n).local_cached_input_tokens||0)+(I(n).local_cached_output_tokens||0)),()=>oc(dw(I(n))),()=>sc(I(n).input_cost),()=>sc(I(n).output_cost),()=>sc(I(n).total_cost)]),z(e,r)}),T(d),T(r),T(n),z(e,n)};V(_,e=>{I(y)?e(v):e(b,-1)}),T(r),z(e,r)},y=e=>{var t=Gw();SS(M(t),{size:20,get label(){return`Loading ${I(i).noun??``}`}}),T(t),z(e,t)};V(_,e=>{I(d)?e(v):I(l)&&e(y,1)}),z(e,g),D()}Hr([`click`]);var qw=R(``);function Jw(e,t){E(t,!0);let n=ya(t,`total`,3,0),r=ya(t,`offset`,3,0),i=ya(t,`limit`,3,25);var a=Qr(),o=N(a),s=e=>{var a=qw(),o=M(a),s=M(o);T(o);var c=P(o,2),l=M(c),u=P(l,2);T(c),T(a),F(e=>{B(s,`Showing ${r()+1}-${e??``} of ${n()??``}`),l.disabled=r()===0,u.disabled=r()+i()>=n()},[()=>Math.min(r()+i(),n())]),L(`click`,l,()=>t.onprev?.()),L(`click`,u,()=>t.onnext?.()),z(e,a)};V(o,e=>{n()>0&&e(s)}),z(e,a),D()}Hr([`click`]);var Yw=(e,t=f)=>{var n=Qr(),r=N(n),i=e=>{var n=Zw();H(n,20,()=>lw(t()),e=>e,(e,t)=>{var n=Xw();let r;var i=M(n,!0);T(n),F((e,a)=>{r=U(n,1,`usage-label-chip`,null,r,{active:J.usageFilterLabel===t}),Hi(n,`--label-color: ${e??``}`),W(n,`title`,a),B(i,t)},[()=>Hy(t),()=>J.usageLabelChipTitle(t)]),L(`click`,n,()=>J.toggleUsageLabelFilter(t)),z(e,n)}),T(n),z(e,n)},a=O(()=>lw(t()).length>0),o=e=>{z(e,Qw())};V(r,e=>{I(a)?e(i):e(o,-1)}),z(e,n)},Xw=R(``),Zw=R(`
`),Qw=R(`-`),$w=R(`Labels`),eT=R(`Cost`),tT=R(``),nT=R(` `),rT=R(``),iT=R(` `),aT=R(` `),oT=R(`
TimestampProviderModelUser PathCacheProvider Cache
`),sT=R(`
`),cT=R(`
`),lT=R(`

Request Log

`);function uT(e,t){E(t,!0);let n=O(()=>J.usageMode===`costs`),r=O(()=>uw(J.labelUsage,J.usageFilterLabel,J.usageLog.entries)),i=bw(()=>J.fetchUsageLog(!0));An(()=>i.cancel);var a=lT(),o=P(M(a),2),s=M(o);yw(M(s),{placeholder:`Search by request ID, model, provider...`,label:`Search by request ID, model, provider`,get oninput(){return i},get value(){return J.usageLogSearch},set value(e){J.usageLogSearch=e}}),T(s);var c=P(s,2),l=M(c),u=M(l);na(u),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=e=>{var t=oT(),i=M(t),a=M(i),o=M(a),s=P(M(o),4),c=e=>{z(e,$w())};V(s,e=>{I(r)&&e(c)});var l=P(s,3),u=M(l,!0);T(l);var d=P(l),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{z(e,eT())};V(h,e=>{I(n)||e(g)}),T(o),T(a);var _=P(a);H(_,21,()=>J.usageLog.entries,e=>e.id,(e,t)=>{var i=aT();let a;var o=M(i),s=M(o,!0);T(o);var c=P(o),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{var n=tT();Yw(M(n),()=>I(t)),T(n),z(e,n)};V(h,e=>{I(r)&&e(g)});var _=P(h),v=M(_,!0);T(_);var y=P(_),b=M(y),x=e=>{var n=nT(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>ow(I(t))]),z(e,n)},S=O(()=>aw(I(t))),C=e=>{z(e,Qw())};V(b,e=>{I(S)?e(x):e(C,-1)}),T(y);var w=P(y),ee=M(w,!0);T(w);var te=P(w),ne=M(te,!0);T(te);var re=P(te),ie=M(re),ae=M(ie,!0);T(ie);var oe=P(ie,2),se=e=>{{let n=O(()=>$C(I(t)));G(e,{get icon(){return qa},class:`cost-source-icon`,get title(){return I(n)}})}},ce=O(()=>I(n)&&QC(I(t)));V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{G(e,{get icon(){return Xa},class:`cache-savings-icon`})},de=O(()=>I(n)&&tw(I(t)));V(le,e=>{I(de)&&e(ue)});var fe=P(le,2),pe=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(fe,e=>{I(n)&&I(t).costs_calculation_caveat&&e(pe)}),T(re);var me=P(re),he=e=>{var n=iT(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{{let n=O(()=>$C(I(t)));G(e,{get icon(){return qa},class:`cost-source-icon`,get title(){return I(n)}})}},s=O(()=>QC(I(t)));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{G(e,{get icon(){return Xa},class:`cache-savings-icon`})},u=O(()=>tw(I(t)));V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(d,e=>{I(t).costs_calculation_caveat&&e(f)}),T(n),F((e,t)=>{W(n,`title`,e),B(i,t)},[()=>rw(I(t),cw(I(t))),()=>sc(I(t).total_cost)]),z(e,n)};V(me,e=>{I(n)||e(he)}),T(i),F((e,n,r,c,l,d,p,h,g,_,b,x,S)=>{a=U(i,1,`svelte-hg4ill`,null,a,e),W(o,`title`,n),B(s,r),B(u,c),B(f,I(t).model),B(m,I(t).user_path||`-`),B(v,l),W(y,`title`,d),W(w,`title`,p),B(ee,h),W(te,`title`,g),B(ne,_),W(re,`title`,b),W(ie,`title`,x),B(ae,S)},[()=>({"usage-log-row-cached":tw(I(t))}),()=>mc(I(t).timestamp),()=>ds.formatTimestamp(I(t).timestamp),()=>gc(I(t))||`-`,()=>nw(I(t)),()=>sw(I(t)),()=>I(n)?oc(I(t).input_tokens)+` tokens`:``,()=>I(n)?sc(I(t).input_cost):oc(I(t).input_tokens),()=>I(n)?oc(I(t).output_tokens)+` tokens`:``,()=>I(n)?sc(I(t).output_cost):oc(I(t).output_tokens),()=>I(n)?rw(I(t),``):``,()=>I(n)?rw(I(t),oc(I(t).total_tokens)+` tokens -`+cw(I(t))):``,()=>I(n)?sc(I(t).total_cost):oc(I(t).total_tokens)]),z(e,i)}),T(_),T(i),T(t),F(()=>{B(u,I(n)?`Input Cost`:`Input`),B(f,I(n)?`Output Cost`:`Output`),B(m,I(n)?`Total Cost`:`Total`)}),z(e,t)},p=e=>{var t=sT();SS(M(t),{size:20,label:`Loading request log`}),T(t),z(e,t)},m=e=>{var t=cT();TS(M(t),{}),T(t),z(e,t)};V(d,e=>{J.usageLog.entries.length>0?e(f):J.usageLogLoading?e(p,1):e(m,-1)}),Jw(P(d,2),{get total(){return J.usageLog.total},get offset(){return J.usageLog.offset},get limit(){return J.usageLog.limit},onprev:()=>J.usageLogPrevPage(),onnext:()=>J.usageLogNextPage()}),T(a),L(`change`,u,()=>J.fetchUsageLog(!0)),fa(u,()=>J.usageLogHideCached,e=>J.usageLogHideCached=e),z(e,a),D()}Hr([`click`,`change`]);var dT=R(`
`);function fT(e,t){E(t,!0);let n=`usage`;An(()=>{K.refreshTick,Jo.page===n&&(J.fetchUsagePage(),MC.ensureLiveLogs())}),An(()=>{Jo.page===n&&(J.usageMode=Jo.sub===`costs`?`costs`:`tokens`)});var r=dT(),i=P(M(r),2),a=M(i);Py(a,{ariaLabel:`Usage mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return J.usageMode},onchange:e=>J.toggleUsageMode(e)}),tl(P(a,2),{onchange:()=>J.fetchUsagePage()}),T(i);var o=P(i,2);ww(o,{});var s=P(o,2);Aw(s,{});var c=P(s,2),l=M(c);Kw(l,{kind:`model`});var u=P(l,2);Kw(u,{kind:`userPath`}),Kw(P(u,2),{kind:`label`}),T(c),uT(P(c,2),{}),T(r),z(e,r),D()}var pT=R(`
`);function mT(e,t){let n=ya(t,`label`,3,`Loading...`),r=ya(t,`class`,3,``);var i=pT(),a=P(M(i),2),o=M(a,!0);T(a),T(i),F(()=>{U(i,1,Fi([`loading-state`,r()]),`svelte-hzxv1d`),B(o,n())}),z(e,i)}var hT=R(``);function gT(e,t){let n=ya(t,`label`,3,``),r=ya(t,`class`,3,``),i=ya(t,`disabled`,3,!1);var a=hT();gi(M(a),()=>t.children??f),T(a),F(()=>{U(a,1,Fi([`table-action-btn`,r()])),W(a,`aria-label`,n()),W(a,`title`,n()),a.disabled=i()}),L(`click`,a,function(...e){t.onclick?.apply(this,e)}),z(e,a)}Hr([`click`]);async function _T(e,{label:t,errorFallback:n=`Unable to load ${t}.`,unavailableStatuses:r=[503],normalize:i=e=>Array.isArray(e)?e:[],options:a}){let o;try{o=await _s(e,{...a||{},label:t})}catch(e){return ys(e)||console.error(`Failed to fetch ${t}:`,e),{status:`error`,items:[],error:n,result:null}}return o.stale?{status:`stale`,items:[],error:``,result:o}:r.includes(o.status)?{status:`unavailable`,items:[],error:``,result:o}:o.ok?{status:`ok`,items:i(o.data),error:``,result:o}:{status:`error`,items:[],error:o.status===401?``:fs(o.data,n),result:o}}async function vT(e,t,n,{label:r,errorFallback:i=`Unable to ${r}.`,unavailableStatuses:a=[503],unavailableMessage:o=`This feature is unavailable on the gateway.`,options:s}){let c;try{c=await vs(e,t,n,{...s||{},label:r})}catch(e){return ys(e)||console.error(`Failed to ${r}:`,e),{status:`error`,error:i,result:null}}return c.stale?{status:`stale`,error:``,result:c}:a.includes(c.status)?{status:`unavailable`,error:o,result:c}:c.ok?{status:`ok`,error:``,result:c}:{status:`error`,error:c.status===401?`Authentication required.`:fs(c.data,i),result:c}}function yT(){return{scope:`user_path`,subject:`/`,period:`daily`,period_seconds:86400,amount:``,source:`manual`}}function bT(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},label:{label:`Label`,chip:`label`,fieldLabel:`Label`,placeholder:`Mobile-App-iOS`}};return t[e]||t.user_path}function xT(){return[`user_path`,`label`].map(e=>({value:e,label:bT(e).label}))}function ST(e){return String(e&&e.scope||``).trim()||`user_path`}function CT(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function wT(e){return bT(ST(e)).chip}function TT(e){return ST(e)===`label`?`budget-label`:`budget-user-path`}function ET(e){return bT(String(e&&e.scope||``)).fieldLabel}function DT(e){return bT(String(e&&e.scope||``)).placeholder}function OT(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function kT(){return[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`},{value:`custom`,label:`Custom seconds`}]}function AT(e){switch(String(e||``).trim().toLowerCase()){case`hourly`:return 3600;case`daily`:return 86400;case`weekly`:return 604800;case`monthly`:return 2592e3;default:return 0}}function jT(e){switch(Number(e||0)){case 3600:return`hourly`;case 86400:return`daily`;case 604800:return`weekly`;case 2592e3:return`monthly`;default:return`custom`}}function MT(e){return ST(e)+`:`+CT(e)+`:`+String(e&&e.period_seconds||``)}function NT(e,t){if(!t||!Array.isArray(e))return null;let n=MT(t);return e.find(e=>MT(e)===n)||null}function PT(e){let t=String(e||``).trim();if(!t)return`User path is required.`;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function FT(e){if(PT(e))return``;let t=String(e||``).trim(),n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function IT(e){return`/`+String(e||``).trimStart().replace(/^\/+/,``)}function LT(e){return Array.isArray(e)?e:e&&Array.isArray(e.budgets)?e.budgets:[]}function RT(e){let t=Number(e&&e.period_seconds||0);return[CT(e),wT(e),tE(e),jT(t),t?String(t)+`s`:``,t?String(t)+` seconds`:``].join(` `).toLowerCase()}var zT={user_path:0,label:1};function BT(e,t){let n=Array.isArray(e)?e.slice():[],r=String(t||`subject`);return n.sort((e,t)=>{let n=(zT[ST(e)]||0)-(zT[ST(t)]||0),i=CT(e).localeCompare(CT(t)),a=Number(t&&t.period_seconds||0)-Number(e&&e.period_seconds||0);return r===`period`?a||n||i:n||i||a}),n}function VT(e,t,n){let r=Array.isArray(e)?e:[],i=String(t||``).trim().toLowerCase();return BT(i?r.filter(e=>RT(e).includes(i)):r.slice(),n)}function HT(e){let t=e||{},n=ST(t),r=String(t.subject||``).trim();if(n===`user_path`){let e=PT(r);if(e)return{payload:null,error:e}}else if(!r)return{payload:null,error:`Label is required.`};let i=Number(t.amount);if(!Number.isFinite(i)||i<=0)return{payload:null,error:`Amount must be greater than 0.`};let a=String(t.period||``).trim(),o=AT(a);return a===`custom`&&(o=Number(t.period_seconds)),!Number.isFinite(o)||o<=0?{payload:null,error:`Period seconds must be greater than 0.`}:{payload:{scope:n,subject:n===`user_path`?FT(r):r,period_seconds:Math.trunc(o),amount:i,source:String(t.source||`manual`).trim()||`manual`},error:``}}function UT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds},amount:e.amount}}function WT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds}}}function GT(e){return{scope:ST(e),subject:CT(e),period_seconds:e.period_seconds}}function KT(e){return sc(e)}function qT(e,t){let n=e||{},r=t||{};return`A budget for "`+((CT(n)||CT(r))+` `+tE({period_seconds:n.period_seconds||r.period_seconds,period_label:r.period_label}))+`" already exists. Saving will override the current `+KT(r.amount)+` limit with `+KT(n.amount)+`.`}function JT(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:t}function YT(e,t){let n=JT(e);return Math.round((t?Math.min(n,1):n)*1e3)/10}function XT(e){return JT(e&&e.usage_ratio)}function ZT(e){return YT(XT(e),!0)}function QT(e){return YT(e&&e.period_ratio,!0)}function $T(e){return YT(XT(e),!1).toFixed(1).replace(/\.0$/,``)+`%`}function eE(e){return QT(e).toFixed(1).replace(/\.0$/,``)+`%`}function tE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`Hourly`;case 86400:return`Daily`;case 604800:return`Weekly`;case 2592e3:return`Monthly`;default:{let n=String(e&&e.period_label||``).trim();return n?`Custom `+n:`Custom `+String(t||``)+`s`}}}function nE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return`budget-period-label-hourly`;case 86400:return`budget-period-label-daily`;case 604800:return`budget-period-label-weekly`;case 2592e3:return`budget-period-label-monthly`;default:return`budget-period-label-custom`}}function rE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-fill-period-`)}function iE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-track-period-`)}function aE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return Ja;case 86400:return Do;case 604800:return La;case 2592e3:return Ra;default:return xo}}function oE(e){let t=Math.max(0,Math.trunc(Number(e||0)));return t+` `+(t===1?`second`:`seconds`)}function sE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`1 hour`;case 86400:return`1 day`;case 604800:return`1 week`;case 2592e3:return`1 month`;default:return oE(t)}}function cE(e){return String(e&&e.source||``).trim()||`manual`}function lE(e){let t=cE(e).toLowerCase();return t===`manual`?`Created from the dashboard.`:t===`config`?`Loaded from configuration.`:`Budget source: `+t}function uE(e){let t=Number(e&&e.remaining);return Number.isFinite(t)?t<0?sc(Math.abs(t))+` over`:sc(t)+` remaining`:``}var Y=new class{#e=k(j([]));get budgets(){return I(this.#e)}set budgets(e){A(this.#e,e,!0)}#t=k(!0);get budgetsAvailable(){return I(this.#t)}set budgetsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get filter(){return I(this.#r)}set filter(e){A(this.#r,e,!0)}#i=k(`subject`);get sortBy(){return I(this.#i)}set sortBy(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(!1);get formOpen(){return I(this.#o)}set formOpen(e){A(this.#o,e,!0)}#s=k(!1);get formSubmitting(){return I(this.#s)}set formSubmitting(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get editing(){return I(this.#l)}set editing(e){A(this.#l,e,!0)}#u=k(j(yT()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(!1);get overrideDialogOpen(){return I(this.#d)}set overrideDialogOpen(e){A(this.#d,e,!0)}#f=k(null);get overridePendingPayload(){return I(this.#f)}set overridePendingPayload(e){A(this.#f,e,!0)}#p=k(null);get overrideExistingBudget(){return I(this.#p)}set overrideExistingBudget(e){A(this.#p,e,!0)}#m=k(``);get resettingKey(){return I(this.#m)}set resettingKey(e){A(this.#m,e,!0)}#h=k(``);get deletingKey(){return I(this.#h)}set deletingKey(e){A(this.#h,e,!0)}#g=k(!1);get resetAllLoading(){return I(this.#g)}set resetAllLoading(e){A(this.#g,e,!0)}#_=null;managementEnabled(){return Ss.budgetsVisible()}filteredBudgets(){return VT(this.budgets,this.filter,this.sortBy)}async fetchBudgetsPage(){if(await Ss.ensureLoaded(),!this.managementEnabled()){this.budgets=[],this.budgetsAvailable=!1,this.error=``;return}return this.#_||=this.fetchBudgets().finally(()=>{this.#_=null}),this.#_}async fetchBudgets(){this.loading=!0,this.error=``;let e=await _T(`/admin/budgets`,{label:`budgets`,errorFallback:`Unable to load budgets.`,normalize:LT});if(this.loading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.budgetsAvailable=!1,this.budgets=[];return}if(!e.result){this.budgets=[],this.error=e.error;return}if(this.budgetsAvailable=!0,e.status===`error`){this.error=e.error;return}this.budgets=e.items}}openForm(e){if(this.editing=!!e,this.formError=``,e){let t=Number(e.period_seconds||0);this.form={scope:ST(e),subject:CT(e),period:jT(t),period_seconds:t,amount:String(e.amount||``),source:String(e.source||`manual`)}}else this.form=yT();this.formOpen=!0}syncPeriodSeconds(){let e=AT(String(this.form.period||``).trim());e>0&&(this.form.period_seconds=e)}setFormSubject(e){this.form.subject=this.form.scope===`label`?String(e??``):IT(e)}syncScope(){OT(this.form)}closeForm(){this.closeOverrideDialog(),this.formOpen=!1,this.formSubmitting=!1,this.formError=``,this.editing=!1,this.form=yT()}async submitForm(){if(this.formSubmitting)return;let{payload:e,error:t}=HT(this.form);if(!e){this.formError=t;return}if(!this.editing){let t=NT(this.budgets,e);if(t){this.openOverrideDialog(t,e);return}}await this.saveBudgetPayload(e)}async saveBudgetPayload(e){if(this.formSubmitting||!e)return;this.formSubmitting=!0,this.formError=``;let t=await vT(`/admin/budgets`,`PUT`,UT(e),{label:`save budget`,errorFallback:`Unable to save budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.formSubmitting=!1,t.status!==`stale`){if(t.status===`unavailable`){this.budgetsAvailable=!1,this.formError=t.error;return}if(t.status===`error`){this.formError=t.error;return}this.closeForm(),q.success(`Budget saved.`),this.fetchBudgets()}}openOverrideDialog(e,t){this.overrideExistingBudget=e||null,this.overridePendingPayload=t||null,this.overrideDialogOpen=!0}closeOverrideDialog(){this.overrideDialogOpen=!1,this.overridePendingPayload=null,this.overrideExistingBudget=null}async confirmOverride(){if(!this.overridePendingPayload){this.closeOverrideDialog();return}let e=this.overridePendingPayload;this.closeOverrideDialog(),await this.saveBudgetPayload(e)}async resetBudget(e){if(!e)return;let t=MT(e);if(this.resettingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Reset budget "`+n+`"?`))return;this.resettingKey=t;let r=await vT(`/admin/budgets/reset-one`,`POST`,GT(e),{label:`reset budget`,errorFallback:`Unable to reset budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.resettingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,q.error(r.error);return}if(r.status===`error`){q.error(r.error);return}q.success(`Budget reset.`),this.fetchBudgets()}}async deleteBudget(e){if(!e)return;let t=MT(e);if(this.deletingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Delete budget "`+n+`"? This cannot be undone.`))return;this.deletingKey=t;let r=await vT(`/admin/budgets`,`DELETE`,WT(e),{label:`delete budget`,errorFallback:`Unable to delete budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.deletingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,q.error(r.error);return}if(r.status===`error`){q.error(r.error);return}this.budgets=LT(r.result.data),q.success(`Budget deleted.`)}}openResetDialog(){Rs.open({title:`Reset Budgets`,titleId:`budgetResetDialogTitle`,inputId:`budget-reset-confirmation`,requiredText:`reset`,confirmLabel:`Reset All Budgets`,icon:go,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.resetAllBudgets()})}async resetAllBudgets(){if(this.resetAllLoading)return;this.resetAllLoading=!0;let e=await vT(`/admin/budgets/reset`,`POST`,{confirmation:`reset`},{label:`reset budgets`,errorFallback:`Unable to reset budgets.`,unavailableStatuses:[]});if(this.resetAllLoading=!1,e.status!==`stale`){if(e.status!==`ok`){Rs.error=e.error;return}Rs.close(),q.success(`Budgets reset.`),Jo.page===`budgets`&&this.fetchBudgets()}}},dE=R(` Edit`,1),fE=R(` `,1),pE=R(`
Usage
Period
`),mE=R(`
`);function hE(e,t){E(t,!0);let n=ya(t,`budgets`,19,()=>[]);function r(e){if(!e)return``;let t=ds.formatTimestamp(e);return!t||t===`-`?``:t+` `+ds.effectiveTimeZoneLabel()}var i=mE();H(i,21,n,e=>MT(e),(e,t)=>{var n=pE(),i=M(n),a=M(i),o=M(a),s=M(o),c=e=>{G(e,{get icon(){return Oo},class:`budget-scope-icon`})},l=O(()=>ST(I(t))===`label`);V(s,e=>{I(l)&&e(c)});var u=P(s);T(o);var d=P(o,2),f=M(d),p=M(f);{let e=O(()=>aE(I(t)));G(p,{get icon(){return I(e)},class:`budget-period-icon`})}var m=P(p,2),h=M(m,!0);T(m),T(f),T(d);var g=P(d,2),_=M(g),v=M(_),y=M(v,!0);T(v),T(_);var b=P(_,2),x=M(b);gT(x,{label:`Edit budget`,class:`budget-action-btn`,onclick:()=>Y.openForm(I(t)),children:(e,t)=>{var n=dE();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}});var S=P(x,2);{let e=O(()=>Y.resettingKey===MT(I(t))?`Resetting budget`:`Reset budget`),n=O(()=>Y.resettingKey===MT(I(t)));gT(S,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>Y.resetBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);G(i,{get icon(){return go},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.resettingKey===MT(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var C=P(S,2);{let e=O(()=>Y.deletingKey===MT(I(t))?`Deleting budget`:`Delete budget`),n=O(()=>Y.deletingKey===MT(I(t)));gT(C,{get label(){return I(e)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>Y.deleteBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);G(i,{get icon(){return Ao},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.deletingKey===MT(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}T(b),T(g),T(a);var w=P(a,2),ee=M(w),te=M(ee),ne=P(M(te),2),re=M(ne,!0);T(ne),T(te);var ie=P(te,2),ae=M(ie);let oe;var se=P(ae,2),ce=M(se),le=M(ce,!0);T(ce);var ue=P(ce,2),de=M(ue,!0);T(ue),T(se);var fe=P(se,2),pe=M(fe),me=M(pe,!0);T(pe);var he=P(pe,2),ge=M(he,!0);T(he),T(fe),T(ie),T(ee);var _e=P(ee,2),ve=M(_e),ye=P(M(ve),2),be=M(ye,!0);T(ye),T(ve);var xe=P(ve,2),Se=M(xe),Ce=P(Se,2),we=M(Ce),Te=M(we,!0);T(we);var Ee=P(we,2),De=M(Ee,!0);T(Ee);var Oe=P(Ee,2),ke=M(Oe,!0);T(Oe),T(Ce);var Ae=P(Ce,2),je=M(Ae),Me=M(je,!0);T(je);var Ne=P(je,2),Pe=M(Ne,!0);T(Ne);var Fe=P(Ne,2),Ie=M(Fe,!0);T(Fe),T(Ae),T(xe),T(_e),T(w),T(i),T(n),F((e,t,n,r,i,a,s,c,l,d,p,m,g,_,b,x,S,C,w,ee,te,ne,se,ce,ue,fe,pe,he,_e,ve)=>{U(o,1,`budget-scope-value ${e??``}`,`svelte-1jm56wo`),Hi(o,t),W(o,`title`,n),B(u,` ${r??``}`),U(f,1,`budget-period-label ${i??``}`,`svelte-1jm56wo`),B(h,a),W(v,`title`,s),B(y,c),B(re,l),W(ie,`aria-valuenow`,d),W(ie,`aria-label`,p),Hi(ie,`--budget-progress: ${m??``}%`),oe=U(ae,1,`budget-bar-fill budget-bar-fill-usage`,null,oe,g),B(le,_),B(de,b),B(me,x),B(ge,S),B(be,C),U(xe,1,`budget-bar-track ${w??``}`,`svelte-1jm56wo`),W(xe,`aria-valuenow`,ee),Hi(xe,`--budget-progress: ${te??``}%`),U(Se,1,`budget-bar-fill budget-bar-fill-period ${ne??``}`,`svelte-1jm56wo`),W(we,`title`,se),B(Te,ce),B(De,ue),W(Oe,`title`,fe),B(ke,pe),B(Me,he),B(Pe,_e),B(Ie,ve)},[()=>TT(I(t)),()=>ST(I(t))===`label`?`--label-color: `+Hy(CT(I(t))):void 0,()=>wT(I(t))+`: `+CT(I(t)),()=>CT(I(t)),()=>nE(I(t)),()=>tE(I(t)),()=>lE(I(t)),()=>cE(I(t)),()=>$T(I(t)),()=>ZT(I(t)),()=>`Budget usage: `+sc(I(t).spent)+` of `+sc(I(t).amount)+`, `+uE(I(t)),()=>ZT(I(t)),()=>({"budget-bar-fill-danger":XT(I(t))>=1}),()=>sc(I(t).spent)+` of `+sc(I(t).amount),()=>uE(I(t)),()=>sc(I(t).spent)+` of `+sc(I(t).amount),()=>uE(I(t)),()=>eE(I(t)),()=>iE(I(t)),()=>QT(I(t)),()=>QT(I(t)),()=>rE(I(t)),()=>r(I(t).period_start),()=>ds.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>r(I(t).period_end),()=>ds.formatTimestamp(I(t).period_end),()=>ds.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>ds.formatTimestamp(I(t).period_end)]),z(e,n)}),T(i),z(e,i),D()}var gE=R(`

`,1),_E=R(``),vE=R(``),yE=R(`
`);function bE(e,t){E(t,!0);let n=ya(t,`open`,3,!1),r=ya(t,`title`,3,``),i=ya(t,`ariaLabel`,3,``),a=ya(t,`error`,3,``),o=ya(t,`submitting`,3,!1),s=ya(t,`submitDisabled`,3,!1),c=ya(t,`submitLabel`,3,`Save`),l=ya(t,`submittingLabel`,3,`Saving...`),u=ya(t,`submitIcon`,3,_o),d=ya(t,`cancel`,3,!0),p=ya(t,`dialogClass`,3,``),m=ya(t,`novalidate`,3,!1),h=ya(t,`canClose`,3,()=>!0);function g(){K.dialogOpen||h()()&&t.onclose?.()}Ns(e,{get open(){return n()},variant:`editor`,onclose:g,children:(e,n)=>{var h=yE(),g=M(h),_=M(g),v=M(_),y=M(v),b=e=>{var n=Qr();gi(N(n),()=>t.header),z(e,n)},x=e=>{var n=gE(),i=N(n),a=M(i,!0);T(i);var o=P(i,2),s=e=>{var n=Qr();gi(N(n),()=>t.headerHint),z(e,n)};V(o,e=>{t.headerHint&&e(s)}),F(()=>B(a,r())),z(e,n)};V(y,e=>{t.header?e(b):e(x,-1)}),T(v);var S=P(v,2);{let e=O(()=>`Close `+(i()||r()).toLowerCase());ks(S,{get label(){return I(e)},onclick:()=>t.onclose?.()})}T(_);var C=P(_,2);gi(C,()=>t.children??f);var w=P(C,2),ee=e=>{var t=_E(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(w,e=>{a()&&e(ee)});var te=P(w,2),ne=M(te),re=e=>{var n=vE();L(`click`,n,()=>t.onclose?.()),z(e,n)};V(ne,e=>{d()&&e(re)});var ie=P(ne,2),ae=e=>{var n=Qr();gi(N(n),()=>t.extraActions),z(e,n)};V(ie,e=>{t.extraActions&&e(ae)});var oe=P(ie,2),se=M(oe);G(se,{get icon(){return u()},class:`form-action-icon`});var ce=P(se,2),le=M(ce,!0);T(ce),T(oe),T(te),T(g),T(h),F(()=>{U(h,1,Fi([`model-editor`,p()])),W(h,`aria-label`,i()||r()),g.noValidate=m(),oe.disabled=o()||s(),B(le,o()?l():c())}),Vr(`submit`,g,e=>{e.preventDefault(),t.onsubmit?.()}),z(e,h)},$$slots:{default:!0}}),D()}Hr([`click`]);var xE=R(`
`);function SE(e,t){let n=ya(t,`label`,3,``);var r=xE(),i=M(r),a=M(i,!0);T(i),gi(P(i,2),()=>t.children??f),T(r),F(()=>{W(i,`for`,t.id),B(a,n())}),z(e,r)}var CE=R(``),wE=R(``),TE=R(``),EE=R(``),DE=R(``),OE=R(``),kE=R(`

Editing a budget updates its limit only. Use Reset to start a new - budget period.

`),AE=R(`
`,1),jE=R(``),ME=R(` `,1);function NE(e,t){E(t,!0);function n(e){Y.setFormSubject(e.target.value),e.target.value=Y.form.subject}var r=ME(),i=N(r);{let e=O(()=>Y.editing?`Edit Budget`:`Create Budget`);bE(i,{get open(){return Y.formOpen},get title(){return I(e)},ariaLabel:`Budget editor`,get error(){return Y.formError},get submitting(){return Y.formSubmitting},submitLabel:`Save Budget`,dialogClass:`budget-editor`,canClose:()=>!Y.overrideDialogOpen,onclose:()=>Y.closeForm(),onsubmit:()=>Y.submitForm(),children:(e,t)=>{var r=AE(),i=N(r),a=M(i);SE(a,{id:`budget-scope`,label:`Scope`,children:(e,t)=>{var n=wE();H(n,21,xT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncScope()),Gi(n,()=>Y.form.scope,e=>Y.form.scope=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);{let e=O(()=>ET(Y.form));SE(o,{id:`budget-subject`,get label(){return I(e)},children:(e,t)=>{var r=TE();na(r),F(e=>{W(r,`placeholder`,e),ra(r,Y.form.subject),r.disabled=Y.editing,W(r,`data-modal-autofocus`,!Y.editing||void 0)},[()=>DT(Y.form)]),L(`input`,r,n),z(e,r)},$$slots:{default:!0}})}var s=P(o,2);SE(s,{id:`budget-period`,label:`Period`,children:(e,t)=>{var n=EE();H(n,21,kT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncPeriodSeconds()),Gi(n,()=>Y.form.period,e=>Y.form.period=e),z(e,n)},$$slots:{default:!0}});var c=P(s,2),l=e=>{SE(e,{id:`budget-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=DE();na(n),F(()=>n.disabled=Y.editing),da(n,()=>Y.form.period_seconds,e=>Y.form.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(c,e=>{Y.form.period===`custom`&&e(l)}),SE(P(c,2),{id:`budget-amount`,label:`Amount`,children:(e,t)=>{var n=OE();na(n),F(()=>W(n,`data-modal-autofocus`,Y.editing||void 0)),da(n,()=>Y.form.amount,e=>Y.form.amount=e),z(e,n)},$$slots:{default:!0}}),T(i);var u=P(i,2),d=e=>{z(e,kE())};V(u,e=>{Y.editing&&e(d)}),z(e,r)},$$slots:{default:!0}})}Ns(P(i,2),{get open(){return Y.overrideDialogOpen},variant:`auth`,onclose:()=>Y.closeOverrideDialog(),children:(e,t)=>{var n=jE(),r=M(n);ks(P(M(r),2),{label:`Close budget override dialog`,onclick:()=>Y.closeOverrideDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=P(c,2),u=M(l);G(u,{get icon(){return _o},class:`form-action-icon`});var d=P(u,2),f=M(d,!0);T(d),T(l),T(s),T(i),T(n),F(e=>{B(o,e),l.disabled=Y.formSubmitting,B(f,Y.formSubmitting?`Saving...`:`Override Budget`)},[()=>qT(Y.overridePendingPayload,Y.overrideExistingBudget)]),Vr(`submit`,i,e=>{e.preventDefault(),Y.confirmOverride()}),L(`click`,c,()=>Y.closeOverrideDialog()),z(e,n)},$$slots:{default:!0}}),z(e,r),D()}Hr([`change`,`input`,`click`]);var PE=R(`

Budgets

`),FE=R(``),IE=R(`
Budget management is unavailable.
`),LE=R(``),RE=R(`
`),zE=R(`

No budgets configured yet.

`),BE=R(`

No budgets match your filter.

`),VE=R(`
`);function HE(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`budgets`&&Y.fetchBudgetsPage()});let n=O(()=>Y.filteredBudgets());var r=VE(),i=M(r),a=M(i);qS(M(a),{copyId:`budgets-help-copy`,label:`budgets help`,title:e=>{z(e,PE())},help:e=>{Ue(),z(e,Zr(`Budgets are evaluated from tracked usage cost records for each user - path subtree. Enforcement runs only when Budget is enabled for the - active workflow.`))},$$slots:{title:!0,help:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=FE();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Y.formSubmitting),L(`click`,t,()=>Y.openForm()),z(e,t)},l=O(()=>Y.managementEnabled()&&Y.budgetsAvailable&&!K.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Fc(u,{});var d=P(u,2),f=e=>{z(e,IE())},p=O(()=>(!Y.managementEnabled()||!Y.budgetsAvailable)&&!K.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=LE(),n=M(t,!0);T(t),F(()=>B(n,Y.error)),z(e,t)};V(m,e=>{Y.error&&!K.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading budgets...`})};V(g,e=>{Y.loading&&!K.authError&&e(_)});var v=P(g,2),y=e=>{var t=RE(),n=M(t);yw(M(n),{id:`budget-filter`,placeholder:`Filter by user path, label, or period...`,label:`Filter budgets by user path or period`,get value(){return Y.filter},set value(e){Y.filter=e}}),T(n);var r=P(n,2),i=P(M(r),2),a=M(i);a.value=a.__value=`subject`;var o=P(a);o.value=o.__value=`period`,T(i),T(r),T(t),Gi(i,()=>Y.sortBy,e=>Y.sortBy=e),z(e,t)};V(v,e=>{(Y.budgets.length>0||Y.filter)&&Y.budgetsAvailable&&!K.authError&&!Y.formOpen&&e(y)});var b=P(v,2);NE(b,{});var x=P(b,2),S=e=>{hE(e,{get budgets(){return I(n)}})};V(x,e=>{I(n).length>0&&Y.budgetsAvailable&&!K.authError&&e(S)});var C=P(x,2),w=e=>{z(e,zE())},ee=O(()=>Y.budgets.length===0&&!Y.filter&&!Y.loading&&!K.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,BE())},re=O(()=>Y.budgets.length>0&&I(n).length===0&&Y.filter&&!Y.loading&&!K.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function UE(){return{scope:`user_path`,subject:`/`,period:`minute`,period_seconds:60,max_requests:``,max_tokens:``,source:`manual`}}function WE(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},provider:{label:`Provider`,chip:`provider`,fieldLabel:`Provider Name`,placeholder:`openai`},model:{label:`Model`,chip:`model`,fieldLabel:`Model`,placeholder:`openai/gpt-4o`}};return t[e]||t.user_path}function GE(){return[`user_path`,`provider`,`model`].map(e=>({value:e,label:WE(e).label}))}function KE(e){return String(e&&e.scope||``).trim()||`user_path`}function qE(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function JE(e){return WE(KE(e)).chip}function YE(e){return WE(String(e&&e.scope||``)).fieldLabel}function XE(e){return WE(String(e&&e.scope||``)).placeholder}function ZE(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function QE(){return[{value:`minute`,label:`Per minute`},{value:`hour`,label:`Per hour`},{value:`day`,label:`Per day`},{value:`concurrent`,label:`Concurrent (in-flight)`},{value:`custom`,label:`Custom seconds`}]}function $E(e){switch(String(e||``).trim().toLowerCase()){case`minute`:return 60;case`hour`:return 3600;case`day`:return 86400;case`concurrent`:return 0;default:return-1}}function eD(e){switch(Number(e||0)){case 60:return`minute`;case 3600:return`hour`;case 86400:return`day`;case 0:return`concurrent`;default:return`custom`}}function tD(e){let t=String(e&&e.period||``).trim(),n=$E(t);n>=0&&(e.period_seconds=n),t===`concurrent`&&(e.max_tokens=``)}function nD(e){return KE(e)+`:`+qE(e)+`:`+String(e&&e.period_seconds||`0`)}function rD(e){return Number(e&&e.period_seconds||0)===0}function iD(e){return String(e&&e.period_label||``).trim()||eD(Number(e&&e.period_seconds||0))}function aD(e){return String(e&&e.source||``)===`config`?`config`:`manual`}function oD(e){return String(e&&e.source||``)===`config`}function sD(e){let t=Number(e);return Number.isFinite(t)?t.toLocaleString():`0`}function cD(e,t){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return 0;let i=Math.round(n/r*100);return Math.min(Math.max(i,0),100)}function lD(e,t){let n=String(t||``).trim().toLowerCase(),r=Array.isArray(e)?e.slice():[],i={user_path:0,provider:1,model:2};return r.sort((e,t)=>{let n=(i[KE(e)]||0)-(i[KE(t)]||0);if(n!==0)return n;let r=qE(e).localeCompare(qE(t));return r===0?Number(e.period_seconds||0)-Number(t.period_seconds||0):r}),n?r.filter(e=>{let t=qE(e).toLowerCase(),r=JE(e).toLowerCase(),i=iD(e).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)}):r}function uD(e){return!e||!Array.isArray(e.rate_limits)?[]:e.rate_limits}function dD(e,t,n){let r=String(t||``).trim();return r=e===`provider`||e===`model`?r.toLowerCase():`/`+r.split(`/`).map(e=>e.trim()).filter(Boolean).join(`/`),e+`:`+r+`:`+Number(n||0)}function fD(e,t){return e?dD(t.scope,t.subject,t.limit_key.period_seconds)!==dD(e.scope,e.subject,e.period_seconds):!1}function pD(e){let t=e||{},n=String(t.scope||`user_path`),r=String(t.subject||``).trim();if(n!==`user_path`&&!r)return{error:YE(t)+` is required.`};let i=String(t.period||``)===`concurrent`,a=t.period_seconds;if(a===``||a==null)return{error:`Period seconds is required.`};let o=Number(a);if(!Number.isInteger(o)||o<0||o===0&&!i)return{error:`Period seconds must be a positive integer (0 only for the concurrent period).`};let s=String(t.max_requests===void 0||t.max_requests===null?``:t.max_requests).trim(),c=String(t.max_tokens===void 0||t.max_tokens===null?``:t.max_tokens).trim();if(!s&&!c)return{error:`Set max requests, max tokens, or both.`};if(i&&c)return{error:`Token limits are not valid for the concurrent period.`};let l={scope:n,subject:r||`/`,limit_key:{period_seconds:o}};if(s){let e=Number(s);if(!Number.isInteger(e)||e<=0)return{error:`Max requests must be a positive integer.`};l.max_requests=e}if(c){let e=Number(c);if(!Number.isInteger(e)||e<=0)return{error:`Max tokens must be a positive integer.`};l.max_tokens=e}return{payload:l}}function mD(e,t,n){if(KE(e)!==`model`)return!1;let r=String(qE(e)).toLowerCase(),i=String(n||``).trim().toLowerCase();if(!i)return!1;if(r===i)return!0;let a=String(t||``).trim().toLowerCase();return a?r===a+`/`+i||i.startsWith(a+`/`)&&r===i.slice(a.length+1):!1}function hD(e,t){return KE(e)===`provider`&&String(qE(e)).toLowerCase()===String(t||``).trim().toLowerCase()}function gD(e){let t=e||{},n=String(t.model||``),r=String(t.provider||``);return!r||n.toLowerCase().startsWith(r+`/`)?n:r+`/`+n}function _D(e,t){let n=e||{},r=Array.isArray(t)?t:[],i=[];return n.kind===`model`&&i.push({key:`model`,title:`Model limits`,scope:`model`,subject:gD(n),hint:``,items:r.filter(e=>mD(e,n.provider,n.model))}),i.push({key:`provider`,title:`Provider limits (`+n.provider+`)`,scope:`provider`,subject:n.provider,hint:n.kind===`model`?`Shared by every model routed to this provider.`:``,items:r.filter(e=>hD(e,n.provider))}),i.push({key:`global`,title:`Global limits`,scope:`user_path`,subject:`/`,hint:`Root user-path rules throttle all traffic. Narrower user-path rules also apply, per consumer.`,items:r.filter(e=>KE(e)===`user_path`&&qE(e)===`/`)}),i}function vD(e){return rD(e)?cD(e.in_flight,e.max_requests):Math.max(cD(e.requests_used,e.max_requests),cD(e.tokens_used,e.max_tokens))}function yD(e){return`--rate-limit-pressure: `+vD(e)+`%`}function bD(e){let t=vD(e);return t>=100?`rate-limit-pressure-row rate-limit-pressure-full`:t>=75?`rate-limit-pressure-row rate-limit-pressure-high`:`rate-limit-pressure-row`}function xD(e){return(Array.isArray(e)?e:[]).some(e=>KE(e)===`user_path`&&qE(e)===`/`)}function SD(e,t,n){let r=Array.isArray(e)?e:[];return r.some(e=>mD(e,t,n))?`table-action-btn-active`:r.some(e=>hD(e,t))||xD(r)?`rate-limit-gauge-inherited`:``}function CD(e,t){let n=Array.isArray(e)?e:[];return n.some(e=>hD(e,t))?`table-action-btn-active`:xD(n)?`rate-limit-gauge-inherited`:``}function wD(e,t){let n=`Rate limits for `+e;return t===`table-action-btn-active`?n+` (direct limits configured)`:t?n+` (inherited limits apply)`:n}function TD(e){if(rD(e))return sD(e.in_flight)+` of `+sD(e.max_requests)+` in flight`;let t=[];return e.max_requests!==null&&e.max_requests!==void 0&&t.push(sD(e.requests_used)+`/`+sD(e.max_requests)+` req`),e.max_tokens!==null&&e.max_tokens!==void 0&&t.push(sD(e.tokens_used)+`/`+sD(e.max_tokens)+` tok`),t.join(` · `)}var X=new class{#e=k(j([]));get rateLimits(){return I(this.#e)}set rateLimits(e){A(this.#e,e,!0)}#t=k(!0);get rateLimitsAvailable(){return I(this.#t)}set rateLimitsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get rateLimitsLoading(){return I(this.#n)}set rateLimitsLoading(e){A(this.#n,e,!0)}rateLimitFetchPromise=null;#r=k(``);get rateLimitFilter(){return I(this.#r)}set rateLimitFilter(e){A(this.#r,e,!0)}#i=k(``);get rateLimitError(){return I(this.#i)}set rateLimitError(e){A(this.#i,e,!0)}#a=k(!1);get rateLimitFormOpen(){return I(this.#a)}set rateLimitFormOpen(e){A(this.#a,e,!0)}#o=k(!1);get rateLimitFormSubmitting(){return I(this.#o)}set rateLimitFormSubmitting(e){A(this.#o,e,!0)}#s=k(``);get rateLimitFormError(){return I(this.#s)}set rateLimitFormError(e){A(this.#s,e,!0)}#c=k(!1);get rateLimitEditing(){return I(this.#c)}set rateLimitEditing(e){A(this.#c,e,!0)}rateLimitEditingOriginal=null;rateLimitFormReturnToInspector=!1;#l=k(``);get rateLimitResettingKey(){return I(this.#l)}set rateLimitResettingKey(e){A(this.#l,e,!0)}#u=k(``);get rateLimitDeletingKey(){return I(this.#u)}set rateLimitDeletingKey(e){A(this.#u,e,!0)}#d=k(!1);get rateLimitInspectorOpen(){return I(this.#d)}set rateLimitInspectorOpen(e){A(this.#d,e,!0)}#f=k(j({kind:``,provider:``,model:``,title:``}));get rateLimitInspector(){return I(this.#f)}set rateLimitInspector(e){A(this.#f,e,!0)}#p=k(j(UE()));get rateLimitForm(){return I(this.#p)}set rateLimitForm(e){A(this.#p,e,!0)}rateLimitsEnabled(){return Ss.rateLimitsVisible()}defaultRateLimitForm(){return UE()}rateLimitScopeMeta(e){return WE(e)}rateLimitScopeOptions(){return GE()}rateLimitScope(e){return KE(e)}rateLimitSubject(e){return qE(e)}rateLimitScopeLabel(e){return JE(e)}rateLimitSubjectFieldLabel(){return YE(this.rateLimitForm)}rateLimitSubjectPlaceholder(){return XE(this.rateLimitForm)}syncRateLimitScope(){ZE(this.rateLimitForm)}rateLimitPeriodOptions(){return QE()}rateLimitPeriodSeconds(e){return $E(e)}rateLimitPeriodFromSeconds(e){return eD(e)}syncRateLimitPeriodSeconds(){tD(this.rateLimitForm)}rateLimitKey(e){return nD(e)}rateLimitIsConcurrent(e){return rD(e)}rateLimitPeriodLabel(e){return iD(e)}rateLimitSourceLabel(e){return aD(e)}rateLimitIsReadOnly(e){return oD(e)}formatRateLimitNumber(e){return sD(e)}rateLimitUsagePercent(e,t){return cD(e,t)}filteredRateLimits(){return lD(this.rateLimits,this.rateLimitFilter)}normalizeRateLimitListPayload(e){return uD(e)}async fetchRateLimitsPage(){if(await Ss.ensureLoaded(),!this.rateLimitsEnabled()){this.rateLimits=[],this.rateLimitsAvailable=!1,this.rateLimitError=``;return}return this.rateLimitFetchPromise||=this.fetchRateLimits().finally(()=>{this.rateLimitFetchPromise=null}),this.rateLimitFetchPromise}async fetchRateLimits(){this.rateLimitsLoading=!0,this.rateLimitError=``;let e=await _T(`/admin/rate-limits`,{label:`rate limits`,errorFallback:`Unable to load rate limits.`,normalize:uD});if(this.rateLimitsLoading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.rateLimitsAvailable=!1,this.rateLimits=[];return}if(!e.result){this.rateLimits=[],this.rateLimitError=e.error;return}if(this.rateLimitsAvailable=!0,e.status===`error`){this.rateLimitError=e.error;return}this.rateLimits=e.items}}openRateLimitForm(e){if(this.rateLimitEditing=!!e,this.rateLimitFormError=``,e){let t=Number(e.period_seconds||0);this.rateLimitEditingOriginal={scope:KE(e),subject:qE(e),period_seconds:t},this.rateLimitForm={scope:KE(e),subject:qE(e),period:eD(t),period_seconds:t,max_requests:e.max_requests===null||e.max_requests===void 0?``:String(e.max_requests),max_tokens:e.max_tokens===null||e.max_tokens===void 0?``:String(e.max_tokens),source:String(e.source||`manual`)}}else this.rateLimitEditingOriginal=null,this.rateLimitForm=UE();this.rateLimitFormOpen=!0}closeRateLimitForm(){this.rateLimitFormOpen=!1,this.rateLimitFormSubmitting=!1,this.rateLimitFormError=``,this.rateLimitEditing=!1,this.rateLimitEditingOriginal=null,this.rateLimitForm=UE(),this.rateLimitFormReturnToInspector&&(this.rateLimitFormReturnToInspector=!1,this.rateLimitInspectorOpen=!0)}rateLimitNormalizedIdentity(e,t,n){return dD(e,t,n)}rateLimitIdentityMoved(e){return fD(this.rateLimitEditingOriginal,e)}setRateLimitFormSubject(e){this.rateLimitForm.subject=String(e||``)}rateLimitFormPayload(){return pD(this.rateLimitForm)}async submitRateLimitForm(){if(this.rateLimitFormSubmitting)return;let{payload:e,error:t}=this.rateLimitFormPayload();if(t){this.rateLimitFormError=t;return}let n=this.rateLimitIdentityMoved(e),r=this.rateLimitEditingOriginal;this.rateLimitFormSubmitting=!0,this.rateLimitFormError=``;try{let t=await vT(`/admin/rate-limits`,`PUT`,e,{label:`save rate limit`,errorFallback:`Unable to save rate limit.`,unavailableStatuses:[]});if(t.status===`stale`)return;if(t.status!==`ok`){this.rateLimitFormError=t.error;return}if(this.rateLimits=uD(t.result.data),n&&!await this.deleteMovedRateLimitOriginal(r))return;this.closeRateLimitForm(),q.success(n?`Rate limit moved; live counters restarted.`:`Rate limit saved.`)}finally{this.rateLimitFormSubmitting=!1}}async deleteMovedRateLimitOriginal(e){let t=await vT(`/admin/rate-limits`,`DELETE`,{scope:e.scope,subject:e.subject,limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`remove the moved rate limit`,errorFallback:`The new rule was saved, but the previous one could not be removed. Delete it manually.`,unavailableStatuses:[]});return t.status===`stale`?!1:t.status===`ok`?(this.rateLimits=uD(t.result.data),!0):(this.rateLimitFormError=t.error,!1)}async deleteRateLimit(e){let t=nD(e);if(this.rateLimitDeletingKey===t)return;this.rateLimitDeletingKey=t;let n=await vT(`/admin/rate-limits`,`DELETE`,{scope:KE(e),subject:qE(e),limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`delete rate limit`,errorFallback:`Unable to delete rate limit.`,unavailableStatuses:[]});if(this.rateLimitDeletingKey=``,n.status!==`stale`){if(n.status!==`ok`){q.error(n.error);return}this.rateLimits=uD(n.result.data),q.success(`Rate limit deleted.`)}}async resetRateLimit(e){let t=nD(e);if(this.rateLimitResettingKey===t)return;this.rateLimitResettingKey=t;let n=await vT(`/admin/rate-limits/reset-one`,`POST`,{scope:KE(e),subject:qE(e),period_seconds:Number(e.period_seconds||0)},{label:`reset rate limit`,errorFallback:`Unable to reset rate limit.`,unavailableStatuses:[]});if(this.rateLimitResettingKey=``,n.status!==`stale`){if(n.status!==`ok`){q.error(n.error);return}this.rateLimits=uD(n.result.data),q.success(`Rate limit counters reset.`)}}rateLimitInspectorModelID(e){return String(e&&e.model&&e.model.id||``).trim()}openRateLimitInspectorForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`model`,provider:n,model:t,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}openRateLimitInspectorForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`provider`,provider:t,model:``,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}showRateLimitInspector(){this.rateLimitInspectorOpen=!0,this.fetchRateLimitsPage()}closeRateLimitInspector(){this.rateLimitInspectorOpen=!1}rateLimitRuleMatchesModel(e,t,n){return mD(e,t,n)}rateLimitRuleMatchesProvider(e,t){return hD(e,t)}rateLimitInspectorQualifiedModel(){return gD(this.rateLimitInspector)}rateLimitInspectorSections(){return _D(this.rateLimitInspector,this.rateLimits)}rateLimitPressurePercent(e){return vD(e)}rateLimitPressureStyle(e){return yD(e)}rateLimitPressureClass(e){return bD(e)}rateLimitGaugeCache={rules:null,states:{}};rateLimitGaugeMemo(e,t){this.rateLimitGaugeCache.rules!==this.rateLimits&&(this.rateLimitGaugeCache={rules:this.rateLimits,states:{}});let n=this.rateLimitGaugeCache.states;return e in n||(n[e]=t()),n[e]}rateLimitGaugeClassForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase(),r=this.rateLimits;return this.rateLimitGaugeMemo(`model:`+n+`/`+t,()=>SD(r,n,t))}rateLimitGaugeClassForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase(),n=this.rateLimits;return this.rateLimitGaugeMemo(`provider:`+t,()=>CD(n,t))}hasGlobalRateLimits(){let e=this.rateLimits;return this.rateLimitGaugeMemo(`global`,()=>xD(e))}rateLimitGaugeTitle(e,t){return wD(e,t)}rateLimitInspectorSummary(e){return TD(e)}openRateLimitFormFromInspector(e,t,n){this.rateLimitInspectorOpen=!1,this.rateLimitFormReturnToInspector=!0,this.openRateLimitForm(n||void 0),n||(this.rateLimitForm.scope=e,this.rateLimitForm.subject=t)}},ED=R(``),DD=R(``),OD=R(``),kD=R(``),AD=R(``),jD=R(``),MD=R(``),ND=R(`

Scope, subject, and period identify the rule: changing any of them - moves the rule to a new key and restarts its live counters.

`),PD=R(`

A user path rule limits the whole subtree; provider and model rules cap - all traffic routed there and make load balancing skip the target while - it is saturated. One shared counter per rule. Leave a field empty to - skip that limit. Token limits require usage tracking.

`,1);function FD(e,t){E(t,!0);{let t=O(()=>X.rateLimitEditing?`Edit Rate Limit`:`Create Rate Limit`);bE(e,{get open(){return X.rateLimitFormOpen},get title(){return I(t)},ariaLabel:`Rate limit editor`,get error(){return X.rateLimitFormError},get submitting(){return X.rateLimitFormSubmitting},submitLabel:`Save Rate Limit`,dialogClass:`budget-editor`,novalidate:!0,onclose:()=>X.closeRateLimitForm(),onsubmit:()=>X.submitRateLimitForm(),children:(e,t)=>{var n=PD(),r=N(n),i=M(r);SE(i,{id:`rate-limit-scope`,label:`Scope`,children:(e,t)=>{var n=DD();H(n,21,()=>X.rateLimitScopeOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitScope()),Gi(n,()=>X.rateLimitForm.scope,e=>X.rateLimitForm.scope=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);{let e=O(()=>X.rateLimitSubjectFieldLabel());SE(a,{id:`rate-limit-subject`,get label(){return I(e)},children:(e,t)=>{var n=OD();na(n),F(e=>{W(n,`placeholder`,e),W(n,`data-modal-autofocus`,!X.rateLimitEditing||void 0),ra(n,X.rateLimitForm.subject)},[()=>X.rateLimitSubjectPlaceholder()]),L(`input`,n,e=>X.setRateLimitFormSubject(e.currentTarget.value)),z(e,n)},$$slots:{default:!0}})}var o=P(a,2);SE(o,{id:`rate-limit-period`,label:`Period`,children:(e,t)=>{var n=kD();H(n,21,()=>X.rateLimitPeriodOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitPeriodSeconds()),Gi(n,()=>X.rateLimitForm.period,e=>X.rateLimitForm.period=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=e=>{SE(e,{id:`rate-limit-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=AD();na(n),da(n,()=>X.rateLimitForm.period_seconds,e=>X.rateLimitForm.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(s,e=>{X.rateLimitForm.period===`custom`&&e(c)});var l=P(s,2);{let e=O(()=>X.rateLimitForm.period===`concurrent`?`Max In-Flight Requests`:`Max Requests`);SE(l,{id:`rate-limit-max-requests`,get label(){return I(e)},children:(e,t)=>{var n=jD();na(n),F(()=>W(n,`data-modal-autofocus`,X.rateLimitEditing?!0:void 0)),da(n,()=>X.rateLimitForm.max_requests,e=>X.rateLimitForm.max_requests=e),z(e,n)},$$slots:{default:!0}})}var u=P(l,2),d=e=>{SE(e,{id:`rate-limit-max-tokens`,label:`Max Tokens`,children:(e,t)=>{var n=MD();na(n),da(n,()=>X.rateLimitForm.max_tokens,e=>X.rateLimitForm.max_tokens=e),z(e,n)},$$slots:{default:!0}})};V(u,e=>{X.rateLimitForm.period!==`concurrent`&&e(d)}),T(r);var f=P(r,4),p=e=>{z(e,ND())};V(f,e=>{X.rateLimitEditing&&e(p)}),z(e,n)},$$slots:{default:!0}})}D()}Hr([`change`,`input`]);var ID=R(` `),LD=R(` Edit`,1),RD=R(` `,1),zD=R(`
In-flight
`),BD=R(`
Requests
`),VD=R(`
Tokens
`),HD=R(`
`),UD=R(`
`);function WD(e,t){E(t,!0);var n=UD();H(n,21,()=>t.rules,e=>X.rateLimitKey(e),(e,t)=>{var n=HD(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=e=>{var n=ID(),r=M(n);{let e=O(()=>X.rateLimitScope(I(t))===`provider`?bo:Fa);G(r,{get icon(){return I(e)},class:`budget-period-icon`})}var i=P(r,2),a=M(i,!0);T(i),T(n),F((e,t)=>{W(n,`title`,e),B(a,t)},[()=>`Rule scope: `+X.rateLimitScopeLabel(I(t)),()=>X.rateLimitScopeLabel(I(t))]),z(e,n)},u=O(()=>X.rateLimitScope(I(t))!==`user_path`);V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=M(d);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?Ma:ko);G(f,{get icon(){return I(e)},class:`budget-period-icon`})}var p=P(f,2),m=M(p,!0);T(p),T(d),T(s);var h=P(s,2),g=M(h),_=M(g),v=M(_,!0);T(_),T(g);var y=P(g,2),b=M(y),x=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitForm(I(t)),children:(e,t)=>{var n=LD();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},S=O(()=>!X.rateLimitIsReadOnly(I(t)));V(b,e=>{I(S)&&e(x)});var C=P(b,2);{let e=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting counters`:`Reset counters`),n=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t)));gT(C,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>X.resetRateLimit(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=RD(),i=N(r);G(i,{get icon(){return go},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var w=P(C,2),ee=e=>{{let n=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting rate limit`:`Delete rate limit`),r=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>X.deleteRateLimit(I(t)),get disabled(){return I(r)},children:(e,n)=>{var r=RD(),i=N(r);G(i,{get icon(){return Ao},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}},te=O(()=>!X.rateLimitIsReadOnly(I(t)));V(w,e=>{I(te)&&e(ee)}),T(y),T(h),T(i);var ne=P(i,2),re=M(ne),ie=e=>{var n=zD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u),T(l),T(o),T(n),F((e,t,n,r,i,l)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l)},[()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests),()=>`In-flight requests: `+X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` in flight`]),z(e,n)},ae=O(()=>X.rateLimitIsConcurrent(I(t)));V(re,e=>{I(ae)&&e(ie)});var oe=P(re,2),se=e=>{var n=BD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests),()=>`Requests used: `+X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` requests`,()=>X.formatRateLimitNumber(I(t).requests_remaining)+` left`]),z(e,n)},ce=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_requests);V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{var n=VD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens),()=>`Tokens used: `+X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)>=100}),()=>X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens)+` tokens`,()=>X.formatRateLimitNumber(I(t).tokens_remaining)+` left`]),z(e,n)},de=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_tokens);V(le,e=>{I(de)&&e(ue)}),T(ne),T(r),T(n),F((e,t,n,r,i)=>{W(a,`title`,e),B(o,t),B(m,n),W(_,`title`,r),B(v,i)},[()=>X.rateLimitScopeLabel(I(t))+`: `+X.rateLimitSubject(I(t)),()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n),D()}var GD=R(`

Rate Limits

`),KD=R(``),qD=R(`
Rate limit management is unavailable.
`),JD=R(``),YD=R(`
`),XD=R(`

No rate limits configured yet.

`),ZD=R(`

No rate limits match your filter.

`),QD=R(`
`);function $D(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`rate-limits`&&X.fetchRateLimitsPage()});let n=O(()=>X.filteredRateLimits());var r=QD(),i=M(r),a=M(i);qS(M(a),{copyId:`rate-limits-help-copy`,label:`rate limits help`,text:`Rate limits cap requests, tokens, and in-flight concurrency for a user path subtree, a provider, or a model. Consumer (user path) breaches return 429 with Retry-After and x-ratelimit-* headers; saturated providers and models are skipped by load balancing and failover while capacity exists elsewhere. Counters are per gateway instance and reset on restart; token limits need usage tracking.`,title:e=>{z(e,GD())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=KD();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=X.rateLimitFormSubmitting),L(`click`,t,()=>X.openRateLimitForm()),z(e,t)},l=O(()=>X.rateLimitsEnabled()&&X.rateLimitsAvailable&&!K.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Fc(u,{});var d=P(u,2),f=e=>{z(e,qD())},p=O(()=>(!X.rateLimitsEnabled()||!X.rateLimitsAvailable)&&!K.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=JD(),n=M(t,!0);T(t),F(()=>B(n,X.rateLimitError)),z(e,t)};V(m,e=>{X.rateLimitError&&!K.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading rate limits...`})};V(g,e=>{X.rateLimitsLoading&&!K.authError&&e(_)});var v=P(g,2),y=e=>{var t=YD(),n=M(t);yw(M(n),{id:`rate-limit-filter`,placeholder:`Filter by subject, scope, or period...`,label:`Filter rate limits by subject, scope, or period`,get value(){return X.rateLimitFilter},set value(e){X.rateLimitFilter=e}}),T(n),T(t),z(e,t)};V(v,e=>{(X.rateLimits.length>0||X.rateLimitFilter)&&X.rateLimitsAvailable&&!K.authError&&!X.rateLimitFormOpen&&e(y)});var b=P(v,2);FD(b,{});var x=P(b,2),S=e=>{WD(e,{get rules(){return I(n)}})};V(x,e=>{I(n).length>0&&X.rateLimitsAvailable&&!K.authError&&e(S)});var C=P(x,2),w=e=>{z(e,XD())},ee=O(()=>X.rateLimits.length===0&&!X.rateLimitFilter&&!X.rateLimitsLoading&&!K.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,ZD())},re=O(()=>X.rateLimits.length>0&&I(n).length===0&&X.rateLimitFilter&&!X.rateLimitsLoading&&!K.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function eO(e){return String(e||``).trim().toLowerCase()}function tO(e){if(!e)return``;let t=String(e.selector||``).trim();if(t)return t;if(!e.model||!e.model.id)return``;let n=String(e.model.id||``).trim(),r=String(e.provider_name||``).trim();if(r)return r+`/`+n;let i=String(e.provider_type||``).trim();return!i||n.includes(`/`)?n:i+`/`+n}function nO(e,t,n,r){let i=new Set,a=String(e||``).trim().toLowerCase(),o=String(t||``).trim().toLowerCase(),s=String(n||``).trim().toLowerCase(),c=String(r||``).trim().toLowerCase();if(c&&i.add(c),!a)return i;i.add(a),s&&i.add(s+`/`+a),o&&!a.includes(`/`)&&i.add(o+`/`+a);let l=a.split(`/`);return l.length===2&&l[1]&&i.add(l[1]),i}function rO(e){return nO(e&&e.model?e.model.id:``,e?e.provider_type:``,e?e.provider_name:``,e?e.selector:``)}function iO(e){let t=new Set,n=String(e.resolved_model||``).trim().toLowerCase(),r=String(e.target_model||``).trim().toLowerCase(),i=String(e.target_provider||``).trim().toLowerCase();if(n){t.add(n);let e=n.split(`/`);e.length===2&&e[1]&&t.add(e[1])}if(r){t.add(r);let e=r.split(`/`);e.length===2&&e[1]&&t.add(e[1])}return r&&i&&t.add(i+`/`+r),t}function aO(e){if(!e)return``;let t=String(e.provider||``).trim(),n=String(e.model||``).trim();return!t||!n||n===t||n.startsWith(t+`/`)?n:t+`/`+n}function oO(e){if(e===``||e==null)return null;let t=Number(e);return!Number.isFinite(t)||t<=0?null:t}function sO(e,t){let n={model:e},r=oO(t);return r!==null&&(n.weight=r),n}function cO(e){let t=Array.isArray(e)?e:[],n=[];for(let e of t){let t=String(e&&e.model||``).trim();t&&n.push(sO(t,e&&e.weight))}return n}function lO(e){switch(String(e||``).toLowerCase()){case`cost`:return`lowest cost`;case`round_robin`:case``:return`round robin`;default:return e}}var uO={round_robin:`Round-robin (rotate across targets; honors weights)`,cost:`Lowest cost (cheapest target per request)`,adaptive:`Adaptive (target chosen by the registered routing extension)`};function dO(e,t){let n=Array.isArray(e)?[...e]:[],r=String(t||``).trim().toLowerCase();return r&&!n.includes(r)&&n.push(r),n.map(e=>({value:e,label:uO[e]||e}))}function fO(e){let t=Array.isArray(e.targets)?e.targets:[],n=t.length>0?t[0]:{},r=t.map(e=>{let t={provider:e.provider||``,model:e.model||``};return e.weight&&(t.weight=e.weight),t});return{name:e.source,target_provider:n.provider||``,target_model:n.model||``,targets:r,strategy:e.strategy||``,session_affinity:e.session_affinity!==!1,description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,valid:!!e.valid,resolved_model:e.resolved_model||``,provider_type:e.provider_type||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[]}}function pO(e){let t=Array.isArray(e)?e:[],n=[],r=[];for(let e of t)!e||typeof e!=`object`||(e.kind===`redirect`?n.push(fO(e)):e.kind===`policy`&&r.push({selector:e.source,provider_name:e.provider_name||``,model:e.model||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[],description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,scope_kind:e.scope_kind||``}));return{aliases:n,policies:r}}function mO(e){if(!e)return`—`;let t=Array.isArray(e.targets)?e.targets:[];return t.length>1?t.length+` targets · `+lO(e.strategy):e.resolved_model?e.resolved_model:e.target_provider?e.target_provider+`/`+e.target_model:e.target_model||`—`}function hO(e){return e?e.enabled===!1?`is-disabled`:e.valid?`is-valid`:`is-invalid`:`is-invalid`}function gO(e){return e?e.enabled===!1?`Disabled`:e.valid?`Active`:`Invalid`:`Invalid`}function _O(e){return Array.isArray(e)&&e.length>0&&e.indexOf(`/`)===-1}function vO(e,t){return!t||!e?``:e.effective_enabled===!1?`is-disabled`:_O(e.user_paths)?`is-restricted`:`is-enabled`}function yO(e){if(!e)return``;let t=[];e.effective_enabled===!1&&t.push(e.default_enabled===!1?`Disabled by default`:`Disabled`);let n=Array.isArray(e.user_paths)?e.user_paths:[];return n.length>0&&t.push(`Allowed for `+n.join(`, `)),t.join(` · `)}function bO({models:e,aliases:t,virtualModelsAvailable:n,activeCategory:r}){let i=Array.isArray(e)?e:[],a=Array.isArray(t)?t:[],o=new Map;if(n)for(let e of a){let t=eO(e&&e.name);!t||e.enabled===!1||!e.valid||o.set(t,e)}let s=new Map,c=i.map(e=>{let t=tO(e),n=null;for(let t of rO(e))s.has(t)||s.set(t,e),!n&&o.has(t)&&(n=o.get(t));let r=e&&e.access?e.access:null;return{key:`model:`+t,display_name:t,secondary_name:``,provider_name:e.provider_name||``,provider_type:e.provider_type||``,model:e.model,selector:e.selector||``,is_alias:!1,alias:null,access:r,masking_alias:n,has_virtual_model:!!(n||r&&r.override),alias_state_class:``,alias_state_text:``}});if(!n)return c;for(let e of a){let t=s.get(eO(e&&e.name));if(e&&e.enabled!==!1&&e.valid&&t)continue;let n=null;for(let t of iO(e))if(n=s.get(t)||null,n)break;!n&&r&&r!==`all`||c.push({key:`alias:`+e.name,display_name:e.name,secondary_name:mO(e),provider_name:n&&n.provider_name||``,provider_type:n?n.provider_type||e.provider_type||``:e.provider_type||``,model:n?n.model:{id:e.name,object:`model`},selector:``,is_alias:!0,alias:e,access:null,masking_alias:null,source_model_exists:!!t,has_virtual_model:!0,alias_state_class:hO(e),alias_state_text:gO(e)})}return c.sort((e,t)=>e.is_alias===t.is_alias?String(e.display_name||``).localeCompare(String(t.display_name||``)):e.is_alias?-1:1)}function xO(e,t){if(!t)return e;let n=String(t).toLowerCase();return e.filter(e=>[e.display_name,e.secondary_name,e.provider_name,e.provider_type,e.model&&e.model.owned_by,e.alias&&e.alias.description,e.alias&&e.alias_state_text,e.model&&e.model.metadata&&e.model.metadata.modes?e.model.metadata.modes.join(`,`):``,e.model&&e.model.metadata&&e.model.metadata.categories?e.model.metadata.categories.join(`,`):``].some(e=>String(e||``).toLowerCase().includes(n)))}function SO(e,t){return String(e||``).trim()||String(t||``).trim()||`Unassigned`}function CO(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!r||r===n?``:r}function wO(e){let t=String(e||``).trim();return t?t+`/`:``}function TO(e){let t=Array.isArray(e)?e:[],n=t.filter(e=>e&&!e.is_alias).length,r=t.filter(e=>e&&e.is_alias).length,i=[];return n>0&&i.push(n+(n===1?` model`:` models`)),r>0&&i.push(r+(r===1?` alias`:` aliases`)),i.join(` · `)}function EO(e,t,n){let r=String(t||``).trim(),i=String(n||``).trim();for(let t of Array.isArray(e)?e:[]){let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim();if(!(r&&e!==r)&&!(!r&&i&&n!==i)&&t&&t.access)return t.access.default_enabled!==!1}return!0}function DO(e){for(let t of Array.isArray(e)?e:[])if(t&&t.access)return t.access.default_enabled!==!1;return!0}function OO(e,t){let n=String(t||``).trim();if(!n)return null;for(let t of Array.isArray(e)?e:[])if(String(t&&t.selector||``).trim()===n)return t;return null}function kO(e,t,n,r){let i=wO(t),a=r&&r.get(`/`)||null,o=i&&r&&r.get(i)||null,s=EO(e,t,n),c=o||a,l=c&&Array.isArray(c.user_paths)?Array.from(new Set(c.user_paths)).sort():[];return{selector:i,default_enabled:s,effective_enabled:c?c.enabled!==!1:s,user_paths:l,override:o}}function AO(e,t,n){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let e of Array.isArray(n)?n:[]){let t=String(e&&e.selector||``).trim();t&&r.set(t,e)}let i=[],a=new Map;for(let t of e){if(t&&t.is_alias){i.push(t);continue}let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim(),r=`provider-group:`+(e||n||`unassigned`);a.has(r)||a.set(r,{key:r,provider_name:e,provider_type:n,display_name:SO(e,n),type_label:CO(e,n),rows:[]});let o=a.get(r);!o.provider_name&&e&&(o.provider_name=e),!o.provider_type&&n&&(o.provider_type=n),o.display_name=SO(o.provider_name,o.provider_type),o.type_label=CO(o.provider_name,o.provider_type),o.rows.push(t)}let o=Array.from(a.values()).map(e=>{let n=kO(t,e.provider_name,e.provider_type,r);return{...e,access:n,access_summary:yO(n),item_count_label:TO(e.rows)}}).sort((e,t)=>String(e.display_name||``).localeCompare(String(t.display_name||``)));return i.length>0&&o.unshift({key:`virtual-model-group`,is_virtual_models:!0,provider_name:``,provider_type:``,display_name:`Virtual models`,type_label:``,rows:i,access:{selector:``},access_summary:``,item_count_label:TO(i)}),o}function jO(e,t){let n=OO(t,`/`),r=DO(e),i=n&&Array.isArray(n.user_paths)?n.user_paths:[];return{key:`scope-global`,is_alias:!1,display_name:`all providers and models`,access:{selector:`/`,default_enabled:r,effective_enabled:n?n.enabled!==!1:r,user_paths:i,override:n}}}function MO(e){return e?String(e.access&&e.access.selector||``).trim()||String(e.override_selector||``).trim()||tO(e):``}function NO(e){if(!e)return[];let t=[];return e.is_alias?t.push(`alias-row`,hO(e.alias)):e.has_virtual_model&&t.push(`alias-row`,`is-valid`),!e.is_alias&&e.masking_alias&&t.push(`masked-model-row`),!e.is_alias&&e.access&&e.access.effective_enabled===!1&&t.push(`model-access-disabled-row`),t}function PO(e){return!!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)}function FO(e){return!!(e&&!e.is_alias&&e.masking_alias&&e.masking_alias.name&&!e.masking_alias.managed)}function IO(e){return e&&e.is_alias&&e.alias&&e.alias.name?`alias-row-`+String(e.alias.name).replace(/[^a-zA-Z0-9_-]+/g,`-`):``}function LO(e){return e?e.is_alias?!!(e.alias&&e.alias.managed):!!(e.access&&e.access.override&&e.access.override.managed||e.masking_alias&&e.masking_alias.managed):!1}function RO(e){return!!(e&&e.override)}function zO(e){return e?`table-action-btn-active`:``}function BO(e,t){let n=`Edit `+String(e||`model access`);return t?n+` (virtual model exists)`:n}function VO(){return{source:``,target_model:``,target_weight:1,targets:[],strategy:`round_robin`,session_affinity:!0,user_paths:``,description:``,enabled:!0}}function HO(e){return String(e&&e.target_model||``).trim()!==``}function UO(e){return String(e&&e.target_model||``).trim()?!0:cO(e&&e.targets).length>0}function WO(e){return!!e&&Array.isArray(e.targets)&&e.targets.length>0}function GO(e){return WO(e)&&String(e&&e.strategy||``).toLowerCase()!==`cost`}function KO(e){let t=Array.isArray(e.targets)?e.targets:[];if(t.length>0){let n=t.shift();e.target_model=n.model||``,e.target_weight=n.weight||1;return}e.target_model=``,e.target_weight=1}function qO(e){let t=Array.isArray(e&&e.targets)?e.targets:[];return t.length>0?{primaryModel:aO(t[0]),primaryWeight:t[0].weight||1,extraTargets:t.slice(1).map(e=>({model:aO(e),weight:e.weight||1}))}:{primaryModel:e&&e.target_provider?e.target_provider+`/`+e.target_model:e&&e.target_model||``,primaryWeight:1,extraTargets:[]}}function JO(e){return String(e||``).split(/\r?\n|,/).map(e=>String(e||``).trim()).filter(Boolean)}function YO(e,t,n){let r=String(e&&e.source||``).trim(),i=String(e&&e.target_model||``).trim(),a=cO(e&&e.targets),o=UO(e),s=String(t||``).trim(),c=n===`edit`&&!!s&&r!==s,l={source:r,user_paths:JO(e&&e.user_paths),description:String(e&&e.description||``).trim(),enabled:!!(e&&e.enabled)};if(c&&(l.old_source=s),o){let t=[];if(i&&t.push(sO(i,e.target_weight)),t.push(...a),t.length>1){let n=e.strategy||`round_robin`;l.targets=n===`cost`?t.map(e=>({model:e.model})):t,l.strategy=n,e&&e.session_affinity===!1&&(l.session_affinity=!1)}else l.target_model=t[0].model}return{payload:l,source:r,isRedirect:o,isRename:c}}function XO(e){let t={source:e.name,description:String(e.description||``).trim(),user_paths:Array.isArray(e.user_paths)?e.user_paths:[],enabled:e.enabled===!1},n=Array.isArray(e.targets)?e.targets:[];return n.length>1?(t.strategy=e.strategy||`round_robin`,e.session_affinity===!1&&(t.session_affinity=!1),t.targets=t.strategy===`cost`?n.map(e=>({model:aO(e)})):n.map(e=>sO(aO(e),e.weight))):n.length===1?t.target_model=aO(n[0]):t.target_model=e.target_provider?e.target_provider+`/`+e.target_model:e.target_model,t}function ZO(e,t,n){let r=n||{},i=r.effective_enabled===!1,a=t&&Array.isArray(t.user_paths)?t.user_paths:[],o=`PUT`,s;return i===!1?s={source:e,enabled:!1,user_paths:a}:t&&a.length===0&&r.default_enabled!==!1?(o=`DELETE`,s={source:e}):s={source:e,enabled:!0,user_paths:a},{method:o,payload:s,desired:i}}function QO(e,t,n){let r=Math.max(1,Number(t||75)),i=Math.min(n,e+r);return{limit:i,rendering:ibO({models:Nc.models,aliases:this.aliases,virtualModelsAvailable:this.virtualModelsAvailable,activeCategory:Nc.activeCategory}));get displayModels(){return I(this.#T)}set displayModels(e){A(this.#T,e)}#E=O(()=>AO(this.displayModels,Nc.models,this.modelOverrideViews));get displayModelGroups(){return I(this.#E)}set displayModelGroups(e){A(this.#E,e)}#D=O(()=>xO(this.displayModels,Nc.filter));get filteredDisplayModels(){return I(this.#D)}set filteredDisplayModels(e){A(this.#D,e)}#O=O(()=>{let e=this.filteredDisplayModels,t=Math.max(0,Math.min(Number(this.modelRenderLimit||0),e.length));return!Nc.filter&&t>=this.displayModels.length?this.displayModelGroups:AO(e.slice(0,t),Nc.models,this.modelOverrideViews)});get filteredDisplayModelGroups(){return I(this.#O)}set filteredDisplayModelGroups(e){A(this.#O,e)}#k=O(()=>jO(Nc.models,this.modelOverrideViews));get globalScopeRow(){return I(this.#k)}set globalScopeRow(e){A(this.#k,e)}modelsBusy(){return!!(Nc.loading||this.modelsRendering)}modelLoadingText(){if(Nc.loading)return this.displayModels.length>0?`Refreshing models...`:`Loading models...`;let e=this.filteredDisplayModels.length;return`Rendering models... `+Math.min(Number(this.modelRenderLimit||0),e)+` / `+e}restartModelRendering(e){let t=++this.#a,n=$O(this.modelRenderBatchSize,e);this.modelRenderLimit=n.limit,this.modelsRendering=n.rendering,n.rendering&&this.#A(t)}stopModelRendering(){this.#a++,this.modelsRendering=!1}#A(e){let t=()=>{if(e!==this.#a)return;let t=QO(this.modelRenderLimit,this.modelRenderBatchSize,this.filteredDisplayModels.length);this.modelRenderLimit=t.limit,this.modelsRendering=t.rendering,t.rendering&&this.#A(e)};typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>setTimeout(t,0)):setTimeout(t,0)}async fetchVirtualModels(){this.aliasLoading=!0,this.aliasError=``;try{let e=await _s(`/admin/virtual-models`,{label:`virtual models`});if(e.status===503){this.virtualModelsAvailable=!1,this.aliases=[],this.modelOverrideViews=[];return}if(e.stale)return;if(this.virtualModelsAvailable=!0,!e.ok){this.aliases=[],this.modelOverrideViews=[];return}let{aliases:t,policies:n}=pO(e.data);this.aliases=t,this.modelOverrideViews=n}catch(e){console.error(`Failed to fetch virtual models:`,e),this.aliases=[],this.modelOverrideViews=[],this.aliasError=`Unable to load virtual models.`}finally{this.aliasLoading=!1}}qualifiedModelName(e){return tO(e)}findModelOverrideView(e){return OO(this.modelOverrideViews,e)}hasGlobalModelOverride(){return!!this.findModelOverrideView(`/`)}findExistingAliasByName(e){let t=eO(e);if(!t)return null;for(let e of this.aliases)if(eO(e&&e.name)===t)return e;return null}findConcreteModelByName(e){let t=eO(e);if(!t)return null;for(let e of Nc.models)if(rO(e).has(t))return e;return null}rowToggleEnabled(e){return e?e.is_alias?e.alias&&e.alias.enabled!==!1:!!(e.access&&e.access.effective_enabled!==!1):!1}rowToggleLabel(e){return this.rowTogglingKey&&this.rowTogglingKey===e.key?`Updating...`:this.rowToggleRestricted(e)?`Restricted`:this.rowToggleEnabled(e)?`Enabled`:`Disabled`}rowToggleRestricted(e){return!!e&&!e.is_alias&&vO(e.access,this.virtualModelsAvailable)===`is-restricted`}rowToggleAriaLabel(e){if(!e)return``;let t=this.rowToggleEnabled(e)?`Disable `:`Enable `,n;return n=e.is_alias?`alias `+String(e.alias&&e.alias.name||``):String(e.display_name||e.access&&e.access.selector||`model`),t+n.trim()}async toggleRowEnabled(e){if(this.virtualModelsAvailable&&!(!e||this.rowTogglingKey===e.key)){if(LO(e)){q.success(`This virtual model is managed by configuration and is read-only.`);return}if(e.is_alias){await this.toggleAliasRow(e);return}await this.toggleModelRow(e)}}async toggleAliasRow(e){let t=e.alias;if(!t||!t.name)return;this.rowTogglingKey=e.key;let n=XO(t);try{let e=await vs(`/admin/virtual-models`,`PUT`,n,{label:`alias state`});if(e.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(e.stale)return;if(!e.ok){q.error(e.status===401?`Authentication required.`:ps(e,`Failed to update alias state.`));return}q.success(n.enabled?`Alias enabled.`:`Alias disabled.`),this.fetchVirtualModels()}catch(e){console.error(`Failed to toggle alias state:`,e),q.error(`Failed to update alias state.`)}finally{this.rowTogglingKey=``}}async toggleModelRow(e){let t=MO(e);if(!t)return;let{method:n,payload:r,desired:i}=ZO(t,this.findModelOverrideView(t),e.access||{});this.rowTogglingKey=e.key;try{let e=await vs(`/admin/virtual-models`,n,r,{label:`model access`});if(e.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(!(n===`DELETE`&&e.status===404)){if(e.stale)return;if(!e.ok){q.error(e.status===401?`Authentication required.`:ps(e,`Failed to update model access.`));return}}q.success(i?`Model enabled.`:`Model disabled.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to toggle model access:`,e),q.error(`Failed to update model access.`)}finally{this.rowTogglingKey=``}}async removeAliasRow(e){if(!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)||this.rowDeletingKey)return;let t=String(e.alias.name||``).trim();t&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the virtual model alias "`+t+`"?`,method:`DELETE`,payload:{source:t},operation:`virtual model`,failureMessage:`Failed to remove virtual model.`,notice:`Virtual model removed.`,ignoreNotFound:!0})}async removeRedirectRow(e){let t=e&&e.masking_alias;if(!(e&&!e.is_alias&&t&&t.name&&!t.managed)||this.rowDeletingKey)return;let n=String(t.name||``).trim();n&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the redirect for "`+n+`"? Other virtual model settings will be preserved.`,method:`PUT`,payload:{source:n,user_paths:Array.isArray(t.user_paths)?t.user_paths:[],description:String(t.description||``).trim(),enabled:t.enabled!==!1},operation:`virtual model redirect`,failureMessage:`Failed to remove redirect.`,notice:`Redirect removed. Other virtual model settings were preserved.`})}async mutateVirtualModelRow(e){if(!this.rowDeletingKey&&window.confirm(e.confirmMessage)){this.rowDeletingKey=e.rowKey;try{let t=await vs(`/admin/virtual-models`,e.method,e.payload,{label:e.operation});if(t.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(!(e.ignoreNotFound&&t.status===404)){if(t.stale)return;if(!t.ok){q.error(t.status===401?`Authentication required.`:ps(t,e.failureMessage));return}}this.virtualModelsAvailable=!0,q.success(e.notice),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(t){console.error(e.failureMessage,t),q.error(e.failureMessage)}finally{this.rowDeletingKey=``}}}addVmTarget(){Array.isArray(this.vmForm.targets)||(this.vmForm.targets=[]),this.vmForm.targets.push({model:``,weight:1})}removeVmTarget(e){Array.isArray(this.vmForm.targets)&&this.vmForm.targets.splice(e,1)}removePrimaryTarget(){KO(this.vmForm)}vmFormHasPrimaryTarget(){return HO(this.vmForm)}vmFormShowStrategy(){return WO(this.vmForm)}vmStrategyOptions(){return dO(Ss.virtualModelStrategies(),this.vmForm.strategy)}vmFormShowWeights(){return GO(this.vmForm)}vmFormToggleRestricted(){return!!(this.vmForm&&this.vmForm.enabled)&&_O(JO(this.vmForm.user_paths))}vmFormToggleLabel(){return!this.vmForm||!this.vmForm.enabled?`Disabled`:this.vmFormToggleRestricted()?`Restricted`:`Enabled`}resetVirtualModelForm(){this.vmFormError=``,this.vmFormHelpOpen=!1,this.vmFormUserPathsHelpOpen=!1,this.vmSubmitting=!1,this.vmDeleting=!1,this.vmFormHasExisting=!1,this.vmFormDefaultEnabled=!0,this.vmFormEffectiveEnabled=!0,this.vmFormDisplayName=``,this.vmFormSourceLocked=!1,this.vmFormOriginalSource=``,this.vmFormManaged=!1,this.vmForm=VO()}closeVirtualModelForm(){this.vmFormOpen=!1,this.resetVirtualModelForm()}openVirtualModelCreate(e){this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`create`,this.vmFormSourceLocked=!1,this.vmFormDisplayName=`New virtual model`,e&&e.model&&e.model.id&&(this.vmForm.target_model=tO(e))}openVirtualModelEditAlias(e){if(!e)return;this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!1,this.vmFormHasExisting=!0,this.vmFormManaged=!!e.managed,this.vmFormOriginalSource=e.name||``,this.vmFormDisplayName=e.name||``,this.vmFormDefaultEnabled=DO(Nc.models),this.vmFormEffectiveEnabled=e.enabled!==!1;let{primaryModel:t,primaryWeight:n,extraTargets:r}=qO(e);this.vmForm={source:e.name||``,target_model:t,target_weight:n,targets:r,strategy:e.strategy||`round_robin`,session_affinity:e.session_affinity!==!1,user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` -`),description:e.description||``,enabled:e.enabled!==!1}}openVirtualModelEditModel(e){if(!e||e.is_alias)return;let t=e.access||{},n=t.override||null,r=n&&Array.isArray(n.user_paths)?n.user_paths:Array.isArray(t.user_paths)?t.user_paths:[],i=MO(e);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!n,this.vmFormOriginalSource=i;let a=n?n.enabled!==!1:t.effective_enabled!==!1;this.vmFormDefaultEnabled=t.default_enabled!==!1,this.vmFormEffectiveEnabled=a,this.vmFormManaged=!!(n&&n.managed),this.vmFormDisplayName=e.access_display_name||e.display_name||i||``,this.vmForm={source:i,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:r.join(` -`),description:n&&n.description?n.description:``,enabled:a}}openGlobalModelOverrideEdit(){let e=this.findModelOverrideView(`/`),t=e&&Array.isArray(e.user_paths)?e.user_paths:[],n=DO(Nc.models);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!e,this.vmFormOriginalSource=`/`,this.vmFormDefaultEnabled=n,this.vmFormEffectiveEnabled=e?e.enabled!==!1:n,this.vmFormManaged=!!(e&&e.managed),this.vmFormDisplayName=`All providers and models`,this.vmForm={source:`/`,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:t.join(` -`),description:e&&e.description?e.description:``,enabled:e?e.enabled!==!1:n}}openProviderOverrideEdit(e){!e||!e.access||!e.access.selector||this.openVirtualModelEditModel({display_name:e.display_name,access_display_name:`All models in `+e.display_name,provider_name:e.provider_name,provider_type:e.provider_type,access:e.access,override_selector:e.access.selector,is_alias:!1})}async submitVirtualModelForm(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be edited here.`;return}let{payload:e,source:t,isRedirect:n,isRename:r}=YO(this.vmForm,this.vmFormOriginalSource,this.vmFormMode);if(!t){this.vmFormError=`Source is required.`;return}if(this.vmFormError=``,this.vmFormMode!==`edit`){let e=this.findExistingAliasByName(t),r=e?null:this.findModelOverrideView(t);if(e||r){let n=e?`A virtual model named "`+e.name+`" already exists. Saving will update that virtual model. Continue?`:`An access policy for "`+t+`" already exists. Saving will update that virtual model. Continue?`;if(!window.confirm(n)){this.vmFormError=`Choose a different source or edit the existing virtual model.`;return}}else if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Creating this alias will mask that model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}else if(r){let e=(this.aliases||[]).find(e=>e&&e.name===t)||null,r=e?null:this.findModelOverrideView(t);if(e||r){this.vmFormError=`A virtual model for "`+t+`" already exists. Choose a different source.`;return}if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Renaming to that name will mask the model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}this.vmSubmitting=!0;try{let t=await vs(`/admin/virtual-models`,`PUT`,e,{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:ps(t,`Failed to save virtual model.`);return}let r=!n&&t.status===204;this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),q.success(n?`Alias saved.`:r?`Model access reset to inherited/default.`:`Model access saved.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to save virtual model:`,e),this.vmFormError=`Failed to save virtual model.`}finally{this.vmSubmitting=!1}}async deleteVirtualModel(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be removed here.`;return}let e=String(this.vmForm.source||this.vmFormOriginalSource||``).trim();if(!(!e||!this.vmFormHasExisting)&&window.confirm(`Remove the virtual model for "`+e+`"? This reverts to inherited/default behavior.`)){this.vmDeleting=!0,this.vmFormError=``;try{let t=await vs(`/admin/virtual-models`,`DELETE`,{source:e},{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:ps(t,`Failed to remove virtual model.`);return}}this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),q.success(`Virtual model removed.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to delete virtual model:`,e),this.vmFormError=`Failed to remove virtual model.`}finally{this.vmDeleting=!1}}}},tk=[{value:`input_per_mtok`,label:`Input $/MTok`,group:`Tokens`},{value:`output_per_mtok`,label:`Output $/MTok`,group:`Tokens`},{value:`cached_input_per_mtok`,label:`Cached input $/MTok`,group:`Tokens`},{value:`cache_write_per_mtok`,label:`Cache write $/MTok`,group:`Tokens`},{value:`reasoning_output_per_mtok`,label:`Reasoning output $/MTok`,group:`Tokens`},{value:`batch_input_per_mtok`,label:`Batch input $/MTok`,group:`Batch`},{value:`batch_output_per_mtok`,label:`Batch output $/MTok`,group:`Batch`},{value:`audio_input_per_mtok`,label:`Audio input $/MTok`,group:`Audio`},{value:`audio_output_per_mtok`,label:`Audio output $/MTok`,group:`Audio`},{value:`per_image`,label:`$/Image`,group:`Image`},{value:`input_per_image`,label:`Input $/Image`,group:`Image`},{value:`per_second_input`,label:`Input $/Second`,group:`Audio/Video`},{value:`per_second_output`,label:`Output $/Second`,group:`Video`},{value:`per_character_input`,label:`$/Character`,group:`Audio`},{value:`per_page`,label:`$/Page`,group:`Utility`},{value:`per_request`,label:`$/Request`,group:`Utility`}];function nk(e){let t=tk.find(t=>t.value===e);return t?t.label:String(e||``).replace(/_/g,` `)}function rk(e){return e&&typeof e==`object`?JSON.parse(JSON.stringify(e)):{}}function ik(e,t){let n=rk(e),r=t&&t.pricing?t.pricing:t;if(!r||typeof r!=`object`)return n;for(let e of tk)r[e.value]!==null&&r[e.value]!==void 0&&(n[e.value]=Number(r[e.value]));return Array.isArray(r.tiers)&&r.tiers.length>0&&(n.tiers=rk(r.tiers)),n}function ak(e){switch(String(e||``).trim()){case`config_yaml`:return`config.yaml`;case`model_registry`:return`Model registry`;default:return e?String(e):`Unknown`}}function ok(e){let t=e&&e.pricing?e.pricing:{},n=e&&e.pricing_sources&&typeof e.pricing_sources==`object`?e.pricing_sources:{},r={};for(let e of tk)t[e.value]!==null&&t[e.value]!==void 0&&(r[e.value]=ak(n[e.value]||`model_registry`));return r}function sk(e){let t=String(e&&e.selector||``).trim();return t?`Dashboard/API override (`+t+`)`:`Dashboard/API override`}function ck(e){let t=String(e||``).trim();return t?t+`/`:``}function lk(e){return String(e&&e.model&&e.model.id||``).trim()}function uk(e){let t=String(e&&e.provider_name||``).trim(),n=lk(e);return t&&n?t+`/`+n:n}function dk(e){return lk(e)}function fk(e){let t=new Map;for(let n of Array.isArray(e)?e:[]){let e=String(n&&n.selector||``).trim();e&&t.set(e,n)}return t}function pk(e,t){let n=String(t||``).trim();return n&&fk(e).get(n)||null}function mk(e,t,n){let r=fk(e),i=uk(t),a=dk(t),o=ck(t&&t.provider_name),s=String(n||``).trim();for(let e of[i,a,o,`/`]){if(!e||e===s)continue;let t=r.get(e);if(t)return t}return null}function hk(e,t,n){let r=e&&e.model&&e.model.metadata?e.model.metadata:null,i=rk(r&&r.pricing),a=ok(r),o=mk(t,e,n),s=o&&o.pricing?o.pricing:null;if(s){let e=sk(o);for(let t of tk)s[t.value]!==null&&s[t.value]!==void 0&&(i[t.value]=Number(s[t.value]),a[t.value]=e);Array.isArray(s.tiers)&&s.tiers.length>0&&(i.tiers=rk(s.tiers),a.tiers=e)}return{pricing:i,sources:a}}function gk(e,t){let n=e&&e.pricing?e.pricing:{},r=[];for(let e of tk)n[e.value]!==null&&n[e.value]!==void 0&&r.push({id:t(),field:e.value,value:String(n[e.value])});return r}function _k(e,t){let n=new Set;for(let r of Array.isArray(e)?e:[]){if(t&&r.id===t)continue;let e=String(r.field||``).trim();e&&n.add(e)}return n}function vk(e,t){let n=_k(e,t&&t.id);return tk.filter(e=>e.value===(t&&t.field)||!n.has(e.value))}function yk(e,t){let n={},r=new Set;for(let t of Array.isArray(e)?e:[]){let e=String(t.field||``).trim();if(!e)return{error:`Choose a price type for every row.`};if(r.has(e))return{error:`Each price type can only be used once.`};r.add(e);let i=String(t.value||``).trim();if(i===``)return{error:`Enter a value for `+nk(e)+`.`};let a=Number(i);if(!Number.isFinite(a)||a<0)return{error:`Pricing values must be numbers greater than or equal to 0.`};n[e]=a}let i=Array.isArray(t)?t:[];return i.length>0&&(n.tiers=rk(i)),Object.keys(n).length===0?{error:`Add at least one pricing field before saving.`}:{pricing:n}}function bk(e,t,n){let r=e||{},i=t||{},a=n||{},o=ik(r,a);return tk.map(e=>{let t=a[e.value]!==null&&a[e.value]!==void 0,n=r[e.value]!==null&&r[e.value]!==void 0;return{field:e.value,label:e.label,value:o[e.value],source:t?`Form/API value`:n?i[e.value]||`Model registry`:`Unset`}}).filter(e=>e.source!==`Unset`||e.value!==void 0)}var xk=new class{#e=k(!0);get modelPricingOverridesAvailable(){return I(this.#e)}set modelPricingOverridesAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get modelPricingOverrideViews(){return I(this.#t)}set modelPricingOverrideViews(e){A(this.#t,e,!0)}#n=k(``);get modelPricingOverrideError(){return I(this.#n)}set modelPricingOverrideError(e){A(this.#n,e,!0)}#r=k(!1);get modelPricingOverrideFormOpen(){return I(this.#r)}set modelPricingOverrideFormOpen(e){A(this.#r,e,!0)}#i=k(!1);get modelPricingOverrideSubmitting(){return I(this.#i)}set modelPricingOverrideSubmitting(e){A(this.#i,e,!0)}#a=k(!1);get modelPricingOverrideFormHasExistingOverride(){return I(this.#a)}set modelPricingOverrideFormHasExistingOverride(e){A(this.#a,e,!0)}#o=k(``);get modelPricingOverrideFormDisplayName(){return I(this.#o)}set modelPricingOverrideFormDisplayName(e){A(this.#o,e,!0)}#s=k(``);get modelPricingOverrideFormScope(){return I(this.#s)}set modelPricingOverrideFormScope(e){A(this.#s,e,!0)}#c=k(j([]));get modelPricingOverrideFormScopeOptions(){return I(this.#c)}set modelPricingOverrideFormScopeOptions(e){A(this.#c,e,!0)}#l=k(null);get modelPricingOverrideFormRow(){return I(this.#l)}set modelPricingOverrideFormRow(e){A(this.#l,e,!0)}#u=k(null);get modelPricingOverrideFormBasePricing(){return I(this.#u)}set modelPricingOverrideFormBasePricing(e){A(this.#u,e,!0)}#d=k(null);get modelPricingOverrideFormBasePricingSources(){return I(this.#d)}set modelPricingOverrideFormBasePricingSources(e){A(this.#d,e,!0)}#f=k(j([]));get modelPricingOverrideFormPreservedTiers(){return I(this.#f)}set modelPricingOverrideFormPreservedTiers(e){A(this.#f,e,!0)}#p=k(j([]));get modelPricingOverrideRows(){return I(this.#p)}set modelPricingOverrideRows(e){A(this.#p,e,!0)}#m=k(j({selector:``}));get modelPricingOverrideForm(){return I(this.#m)}set modelPricingOverrideForm(e){A(this.#m,e,!0)}_modelPricingOverrideRowID=0;pricingFieldOptions(){return tk}pricingFieldLabel(e){return nk(e)}async fetchModelPricingOverrides(){this.modelPricingOverrideError=``;try{let e=await _s(`/admin/model-pricing-overrides`,{label:`model pricing overrides`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideViews=[];return}if(e.stale)return;if(this.modelPricingOverridesAvailable=!0,!e.ok){this.modelPricingOverrideViews=[];return}this.modelPricingOverrideViews=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch model pricing overrides:`,e),this.modelPricingOverrideViews=[],this.modelPricingOverrideError=`Unable to load model pricing overrides.`}}findModelPricingOverrideView(e){return pk(this.modelPricingOverrideViews,e)}hasGlobalPricingOverride(){return!!this.findModelPricingOverrideView(`/`)}hasProviderPricingOverride(e){return!!this.findModelPricingOverrideView(ck(e&&e.provider_name))}hasModelPricingOverride(e){return!!this.findModelPricingOverrideView(uk(e))}modelPricingButtonClass(e){return e?`table-action-btn-active`:``}modelPricingButtonLabel(e,t){let n=`Edit `+String(e||`model pricing`);return t?n+` (override exists)`:n}modelRowPricing(e){return hk(e,this.modelPricingOverrideViews).pricing}openGlobalPricingOverrideEdit(){this.openModelPricingOverrideForm({displayName:`All providers and models`,selector:`/`,scope:`global`,scopeOptions:[{value:`global`,label:`All providers and models`,selector:`/`}],row:null})}openProviderPricingOverrideEdit(e){let t=ck(e&&e.provider_name);t&&this.openModelPricingOverrideForm({displayName:`All models in `+(e.display_name||e.provider_name||t),selector:t,scope:`provider`,scopeOptions:[{value:`provider`,label:`Provider`,selector:t}],row:null})}openModelPricingOverrideEdit(e){if(!e||e.is_alias)return;let t=uk(e),n=dk(e),r=[{value:`exact`,label:`This provider and model`,selector:t}];n&&n!==t&&r.push({value:`model`,label:`This model across providers`,selector:n}),this.openModelPricingOverrideForm({displayName:e.display_name||t,selector:t,scope:`exact`,scopeOptions:r,row:e})}openModelPricingOverrideForm(e){let t=e||{};this.modelPricingOverrideFormOpen=!0,this.modelPricingOverrideError=``,this.modelPricingOverrideFormDisplayName=t.displayName||t.selector||`Pricing`,this.modelPricingOverrideFormScope=t.scope||``,this.modelPricingOverrideFormScopeOptions=Array.isArray(t.scopeOptions)?t.scopeOptions:[],this.modelPricingOverrideFormRow=t.row||null,this.modelPricingOverrideForm={selector:t.selector||``},this.loadModelPricingOverrideFormSelector(t.selector||``)}loadModelPricingOverrideFormSelector(e){e=String(e||``).trim();let t=this.findModelPricingOverrideView(e);this.modelPricingOverrideFormHasExistingOverride=!!t,this.modelPricingOverrideRows=gk(t,()=>this.nextModelPricingOverrideRowID()),this.modelPricingOverrideFormPreservedTiers=t&&t.pricing&&Array.isArray(t.pricing.tiers)?rk(t.pricing.tiers):[],this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow();let n=this.modelPricingOverrideFormRow,r=n?hk(n,this.modelPricingOverrideViews,e):{pricing:{},sources:{}};this.modelPricingOverrideFormBasePricing=r.pricing,this.modelPricingOverrideFormBasePricingSources=r.sources}setModelPricingOverrideScope(e){this.modelPricingOverrideFormScope=e;let t=this.modelPricingOverrideFormScopeOptions.find(t=>t.value===e);t&&(this.modelPricingOverrideForm.selector=t.selector,this.loadModelPricingOverrideFormSelector(t.selector))}nextModelPricingOverrideRowID(){return this._modelPricingOverrideRowID=(this._modelPricingOverrideRowID||0)+1,`pricing-row-`+this._modelPricingOverrideRowID}availablePricingFieldOptions(e){return vk(this.modelPricingOverrideRows,e)}addModelPricingOverrideRow(){let e=_k(this.modelPricingOverrideRows),t=tk.find(t=>!e.has(t.value))||tk[0];t&&this.modelPricingOverrideRows.push({id:this.nextModelPricingOverrideRowID(),field:t.value,value:``})}removeModelPricingOverrideRow(e){this.modelPricingOverrideRows=this.modelPricingOverrideRows.filter(t=>t.id!==e.id),this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow()}modelPricingOverridePayload(){return yk(this.modelPricingOverrideRows,this.modelPricingOverrideFormPreservedTiers)}modelPricingOverrideDraftPricing(){let e=this.modelPricingOverridePayload();return e&&e.pricing?e.pricing:{}}modelPricingEffectivePreviewRows(){return bk(this.modelPricingOverrideFormBasePricing,this.modelPricingOverrideFormBasePricingSources,this.modelPricingOverrideDraftPricing())}closeModelPricingOverrideForm(){this.modelPricingOverrideFormOpen=!1,this.modelPricingOverrideSubmitting=!1,this.modelPricingOverrideError=``,this.modelPricingOverrideFormHasExistingOverride=!1,this.modelPricingOverrideFormDisplayName=``,this.modelPricingOverrideFormScope=``,this.modelPricingOverrideFormScopeOptions=[],this.modelPricingOverrideFormRow=null,this.modelPricingOverrideFormBasePricing=null,this.modelPricingOverrideFormBasePricingSources=null,this.modelPricingOverrideFormPreservedTiers=[],this.modelPricingOverrideRows=[],this.modelPricingOverrideForm={selector:``}}async submitModelPricingOverrideForm(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!e){this.modelPricingOverrideError=`Model pricing selector is required.`;return}let t=this.modelPricingOverridePayload();if(t.error){this.modelPricingOverrideError=t.error;return}let n={selector:e,...t};this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let e=await vs(`/admin/model-pricing-overrides`,`PUT`,n,{label:`model pricing override`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(e.stale)return;if(!e.ok){this.modelPricingOverrideError=e.status===401?`Authentication required.`:ps(e,`Failed to save model pricing.`);return}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),q.success(`Model pricing saved.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to save model pricing override:`,e),this.modelPricingOverrideError=`Failed to save model pricing.`}finally{this.modelPricingOverrideSubmitting=!1}}async deleteModelPricingOverride(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!(!e||!this.modelPricingOverrideFormHasExistingOverride)&&window.confirm(`Remove the model pricing override for "`+e+`"?`)){this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let t=await vs(`/admin/model-pricing-overrides`,`DELETE`,{selector:e},{label:`model pricing override`});if(t.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.modelPricingOverrideError=t.status===401?`Authentication required.`:ps(t,`Failed to remove model pricing override.`);return}}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),q.success(`Model pricing override removed.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to delete model pricing override:`,e),this.modelPricingOverrideError=`Failed to remove model pricing override.`}finally{this.modelPricingOverrideSubmitting=!1}}}},Sk=R(``);function Ck(e,t){E(t,!0);var n=Sk();let r;var i=P(M(n),2),a=M(i,!0);T(i),T(n),F((e,i,o)=>{r=U(n,1,`alias-toggle`,null,r,e),n.disabled=ek.rowTogglingKey===t.row.key||!ek.virtualModelsAvailable,W(n,`aria-label`,i),B(a,o)},[()=>({enabled:ek.rowToggleEnabled(t.row),restricted:ek.rowToggleRestricted(t.row)}),()=>ek.rowToggleAriaLabel(t.row),()=>ek.rowToggleLabel(t.row)]),L(`click`,n,()=>ek.toggleRowEnabled(t.row)),z(e,n),D()}Hr([`click`]);var wk=R(`
`);function Tk(e,t){E(t,!0);var n=wk(),r=M(n),i=e=>{Ck(e,{get row(){return ek.globalScopeRow}})};V(r,e=>{ek.virtualModelsAvailable&&e(i)});var a=P(r,2),o=e=>{{let t=O(()=>xk.modelPricingButtonLabel(`global model pricing`,xk.hasGlobalPricingOverride())),n=O(()=>xk.modelPricingButtonClass(xk.hasGlobalPricingOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>xk.openGlobalPricingOverrideEdit(),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(a,e=>{xk.modelPricingOverridesAvailable&&e(o)});var s=P(a,2),c=e=>{{let t=O(()=>BO(`global model access`,ek.hasGlobalModelOverride())),n=O(()=>zO(ek.hasGlobalModelOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>ek.openGlobalModelOverrideEdit(),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n),D()}function Ek(e){return String(e&&(e.primary_model||e.source)||``).trim()}function Dk(e){return Array.isArray(e&&e.fallback_models)?e.fallback_models:Array.isArray(e&&e.targets)?e.targets:[]}function Ok(e){return Array.isArray(e)?e.map(e=>({...e,source:Ek(e),targets:Dk(e)})):[]}function kk(e){let t=Dk(e);return t.length===0?`-`:t.join(`, `)}function Ak(e){return e&&e.enabled===!1?`Off`:e&&e.managed?`Config`:`On`}function jk(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>Ek(e)===n)||null}function Mk(e,t){if(!t||t.is_alias)return!1;let n=jk(e,tO(t));return!!(n&&n.enabled!==!1&&Dk(n).length>0)}function Nk(e,t){return Mk(e,t)?`table-action-btn-failover-active`:``}function Pk(e,t){let n=`Edit failover for `+(t&&t.display_name?t.display_name:`model`);return Mk(e,t)?n+` (active)`:n}function Fk(e){let t=[e&&e.target_model];return(Array.isArray(e&&e.targets)?e.targets:[]).forEach(e=>t.push(e&&e.model)),t.map(e=>String(e||``).trim()).filter(Boolean)}function Ik(e){let t=Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(Boolean):[];return{target_model:t[0]||``,targets:t.slice(1).map(e=>({model:e}))}}function Lk(e){return{primary_model:String(e&&e.source||``).trim(),fallback_models:Fk(e),enabled:!(e&&e.enabled===!1)}}function Rk(e){return Ek(e)}function zk(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=Rk(e);n&&(t[n]=!0)}),t}function Bk(e,t){let n=Rk(t);return!!(n&&e&&e[n])}function Vk(e,t){return(Array.isArray(e)?e:[]).filter(e=>Bk(t,e))}function Hk(e,t){let n=Array.isArray(e)?e:[];return n.length>0&&Vk(n,t).length===n.length}function Uk(e){return[Ek(e),Dk(e).join(` `)].join(` `).toLowerCase()}function Wk(e,t){let n=Array.isArray(e)?e:[],r=String(t||``).trim().toLowerCase();return r?n.filter(e=>Uk(e).includes(r)):n}function Gk(e){return{primary_model:Ek(e),fallback_models:Dk(e).map(e=>String(e||``).trim()).filter(Boolean),enabled:!!(e&&e.enabled!==!1)}}function Kk(){return{source:``,target_model:``,targets:[],enabled:!0}}var Z=new class{#e=k(!0);get failoverAvailable(){return I(this.#e)}set failoverAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get failoverRules(){return I(this.#t)}set failoverRules(e){A(this.#t,e,!0)}#n=k(!1);get failoverLoading(){return I(this.#n)}set failoverLoading(e){A(this.#n,e,!0)}#r=k(!1);get failoverSaving(){return I(this.#r)}set failoverSaving(e){A(this.#r,e,!0)}#i=k(!1);get failoverGenerating(){return I(this.#i)}set failoverGenerating(e){A(this.#i,e,!0)}#a=k(``);get failoverError(){return I(this.#a)}set failoverError(e){A(this.#a,e,!0)}#o=k(j([]));get failoverGeneratedRules(){return I(this.#o)}set failoverGeneratedRules(e){A(this.#o,e,!0)}#s=k(!1);get failoverDraftsOpen(){return I(this.#s)}set failoverDraftsOpen(e){A(this.#s,e,!0)}#c=k(j({}));get failoverDraftSelections(){return I(this.#c)}set failoverDraftSelections(e){A(this.#c,e,!0)}#l=k(``);get failoverDraftFilter(){return I(this.#l)}set failoverDraftFilter(e){A(this.#l,e,!0)}#u=k(!1);get failoverDraftSaving(){return I(this.#u)}set failoverDraftSaving(e){A(this.#u,e,!0)}#d=k(!1);get failoverFormOpen(){return I(this.#d)}set failoverFormOpen(e){A(this.#d,e,!0)}#f=k(`create`);get failoverFormMode(){return I(this.#f)}set failoverFormMode(e){A(this.#f,e,!0)}#p=k(!1);get failoverFormManaged(){return I(this.#p)}set failoverFormManaged(e){A(this.#p,e,!0)}#m=k(j(Kk()));get failoverForm(){return I(this.#m)}set failoverForm(e){A(this.#m,e,!0)}failoverEnabled(){return Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}async fetchFailoverRules(){if(!this.failoverEnabled()){this.failoverAvailable=!1,this.failoverRules=[],this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,this.failoverError=``,this.failoverLoading=!1;return}this.failoverLoading=!0,this.failoverError=``;try{let e=await _s(`/admin/failover`,{label:`failover mappings`});if(e.status===503){this.failoverAvailable=!1,this.failoverRules=[];return}if(e.stale)return;if(this.failoverAvailable=!0,!e.ok){this.failoverRules=[];return}this.failoverRules=Ok(e.data)}catch(e){console.error(`Failed to fetch failover mappings:`,e),this.failoverRules=[],this.failoverError=`Unable to load failover mappings.`}finally{this.failoverLoading=!1}}resetFailoverForm(){this.failoverFormMode=`create`,this.failoverFormManaged=!1,this.failoverForm=Kk()}openFailoverCreate(){this.resetFailoverForm(),this.failoverFormOpen=!0,this.focusFailoverEditor()}openFailoverEdit(e){if(!e)return;this.resetFailoverForm(),this.failoverFormMode=`edit`,this.failoverFormOpen=!0,this.failoverFormManaged=!!e.managed;let t=this.failoverPrimaryModel(e),n=this.failoverTargets(e);this.failoverForm={source:t,target_model:n[0]||``,targets:n.slice(1).map(e=>({model:e})),enabled:e.enabled!==!1},this.focusFailoverEditor()}openFailoverForModel(e){if(!e||e.is_alias)return;let t=this.qualifiedModelName(e),n=this.failoverRules.find(e=>this.failoverPrimaryModel(e)===t);if(n){this.openFailoverEdit(n);return}this.resetFailoverForm(),this.failoverFormMode=`create`,this.failoverFormOpen=!0,this.failoverForm.source=t,this.focusFailoverEditor()}closeFailoverForm(){this.failoverFormOpen=!1}closeFailoverDraftsModal(){this.failoverDraftSaving||(this.failoverDraftsOpen=!1)}failoverFormTargets(){return Fk(this.failoverForm)}setFailoverFormTargets(e){let t=Ik(e);this.failoverForm.target_model=t.target_model,this.failoverForm.targets=t.targets}addFailoverTarget(){Array.isArray(this.failoverForm.targets)||(this.failoverForm.targets=[]),this.failoverForm.targets.push({model:``}),this.focusFailoverEditor()}removeFailoverTarget(e){if(!Array.isArray(this.failoverForm.targets)){this.failoverForm.targets=[];return}this.failoverForm.targets.splice(e,1)}removePrimaryFailoverTarget(){let e=Array.isArray(this.failoverForm.targets)?this.failoverForm.targets:[];if(e.length>0){let t=e.shift();this.failoverForm.target_model=t&&t.model?t.model:``,this.failoverForm.targets=e;return}this.failoverForm.target_model=``}failoverRulePayload(){return Lk(this.failoverForm)}async submitFailoverForm(){if(this.failoverSaving||this.failoverGenerating||this.failoverFormManaged)return;let e=this.failoverRulePayload();if(!e.primary_model){this.failoverError=`Primary model is required.`;return}if(e.enabled&&e.fallback_models.length===0){this.failoverError=`Add at least one failover target.`;return}this.failoverSaving=!0,this.failoverError=``;try{let t=await vs(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to save failover mapping.`;return}q.success(`Failover mapping saved.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to save failover mapping:`,e),this.failoverError=`Failed to save failover mapping.`}finally{this.failoverSaving=!1}}async deleteFailoverRule(e){let t=String(e&&this.failoverPrimaryModel(e)||this.failoverForm.source||``).trim();if(!(!t||this.failoverSaving||this.failoverGenerating)&&confirm(`Remove failover mapping for "`+t+`"?`)){this.failoverSaving=!0,this.failoverError=``;try{let e=await vs(`/admin/failover`,`DELETE`,{primary_model:t},{label:`failover mapping`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mapping.`;return}q.success(`Failover mapping removed.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to remove failover mapping:`,e),this.failoverError=`Failed to remove failover mapping.`}finally{this.failoverSaving=!1}}}async generateFailoverForForm(){if(this.failoverGenerating||this.failoverSaving||this.failoverFormManaged)return;let e=String(this.failoverForm.source||``).trim();if(!e){this.failoverError=`Primary model is required.`;return}this.failoverGenerating=!0,this.failoverError=``;try{let t=await vs(`/admin/failover/generate`,`POST`,{primary_model:e},{label:`failover generation`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to generate failover mapping.`;return}let n=Ok(t.data),r=n.find(t=>this.failoverPrimaryModel(t)===e)||n[0]||null,i=this.failoverTargets(r);if(i.length===0){this.failoverError=`No failover suggestions were generated for this model.`;return}this.setFailoverFormTargets(i),q.success(`Generated `+i.length+` fallback model`+(i.length===1?`.`:`s.`)),this.focusFailoverEditor()}catch(e){console.error(`Failed to generate failover mapping:`,e),this.failoverError=`Failed to generate failover mapping.`}finally{this.failoverGenerating=!1}}openFailoverResetDialog(){Rs.open({title:`Remove failover models`,titleId:`failoverResetDialogTitle`,inputId:`failover-reset-confirmation`,message:`Remove every dashboard-managed failover mapping. Configuration-managed mappings remain active.`,requiredText:`remove`,confirmLabel:`Remove Failover`,icon:Ao,dialogClass:`budget-reset-dialog`,onConfirm:async()=>{await this.resetFailoverRules(),this.failoverError&&(Rs.error=this.failoverError)}})}async resetFailoverRules(){if(!this.failoverSaving){this.failoverSaving=!0,this.failoverError=``;try{let e=await vs(`/admin/failover/reset`,`POST`,void 0,{label:`failover removal`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mappings.`;return}this.failoverRules=Ok(e.data),this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,q.success(`Dashboard-managed failover mappings removed.`),Rs.close()}catch(e){console.error(`Failed to remove failover mappings:`,e),this.failoverError=`Failed to remove failover mappings.`}finally{this.failoverSaving=!1}}}async generateFailoverRules(){if(!(this.failoverGenerating||this.failoverDraftSaving)){this.failoverGenerating=!0,this.failoverError=``,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!0;try{let e=await vs(`/admin/failover/generate`,`POST`,void 0,{label:`failover generation`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to generate failover mappings.`;return}this.failoverGeneratedRules=Ok(e.data),this.selectAllFailoverDrafts(this.failoverGeneratedRules)}catch(e){console.error(`Failed to generate failover mappings:`,e),this.failoverError=`Failed to generate failover mappings.`}finally{this.failoverGenerating=!1}}}failoverDraftKey(e){return Rk(e)}selectAllFailoverDrafts(e){this.failoverDraftSelections=zk(e)}failoverDraftSelected(e){return Bk(this.failoverDraftSelections,e)}setFailoverDraftSelected(e,t){let n=this.failoverDraftKey(e);n&&(this.failoverDraftSelections={...this.failoverDraftSelections,[n]:!!t})}selectedFailoverDrafts(){return Vk(this.failoverGeneratedRules,this.failoverDraftSelections)}selectedFailoverDraftCount(){return this.selectedFailoverDrafts().length}failoverDraftCountLabel(){return this.selectedFailoverDraftCount()+` / `+this.failoverGeneratedRules.length+` selected`}allFailoverDraftsSelected(){return Hk(this.failoverGeneratedRules,this.failoverDraftSelections)}toggleAllFailoverDrafts(){if(!(this.failoverDraftSaving||this.failoverGenerating||this.failoverGeneratedRules.length===0)){if(this.allFailoverDraftsSelected()){this.failoverDraftSelections={};return}this.selectAllFailoverDrafts(this.failoverGeneratedRules)}}failoverDraftSearchText(e){return Uk(e)}filteredFailoverDrafts(){return Wk(this.failoverGeneratedRules,this.failoverDraftFilter)}failoverDraftPayload(e){return Gk(e)}async saveSelectedFailoverDrafts(){if(this.failoverDraftSaving||this.failoverGenerating)return;let e=this.selectedFailoverDrafts();if(e.length===0){this.failoverError=`Select at least one failover draft.`;return}this.failoverDraftSaving=!0,this.failoverError=``;try{for(let t of e){let e=this.failoverDraftPayload(t);if(!e.primary_model||e.fallback_models.length===0){this.failoverError=`Generated failover draft is missing model data.`;return}let n=await vs(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(n.stale)return;if(!n.ok){this.failoverError=`Failed to save failover mapping.`;return}}q.success(`Saved `+e.length+` failover mapping`+(e.length===1?`.`:`s.`)),this.failoverDraftsOpen=!1,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.fetchFailoverRules()}catch(e){console.error(`Failed to save generated failover mappings:`,e),this.failoverError=`Failed to save failover mappings.`}finally{this.failoverDraftSaving=!1}}focusFailoverEditor(){setTimeout(()=>{let e=document.querySelector(`[data-failover-editor]`),t=e&&e.querySelector?e.querySelector(`[data-modal-autofocus], input:not([disabled]), textarea:not([disabled]), button:not([disabled])`):null;t&&typeof t.focus==`function`&&t.focus({preventScroll:!0})},0)}failoverTargetLabel(e){return kk(e)}failoverPrimaryModel(e){return Ek(e)}failoverTargets(e){return Dk(e)}findFailoverMapping(e){return jk(this.failoverRules,e)}hasActiveFailoverMapping(e){return Mk(this.failoverRules,e)}failoverButtonClass(e){return Nk(this.failoverRules,e)}failoverButtonLabel(e){return Pk(this.failoverRules,e)}normalizeFailoverRules(e){return Ok(e)}failoverRuleStatus(e){return Ak(e)}qualifiedModelName(e){return tO(e)}},qk=R(``),Jk=R(``),Yk=R(`Config`),Xk=R(`
Targets
`),Zk=R(``),Qk=R(`
Redirects to
`),$k=R(` `),eA=R(`
`),tA=R(`
`),nA=R(`
`);function rA(e,t){E(t,!0);let n=O(()=>xk.modelRowPricing(t.row));var r=nA(),i=M(r),a=M(i),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{z(e,qk())};V(l,e=>{t.row.is_alias&&e(u)});var d=P(l,2),f=e=>{z(e,Jk())};V(d,e=>{!t.row.is_alias&&t.row.masking_alias&&e(f)});var p=P(d,2),m=e=>{z(e,Yk())},h=O(()=>LO(t.row));V(p,e=>{I(h)&&e(m)}),T(o);var g=P(o,2),_=e=>{var n=Xk(),r=P(M(n)),i=M(r,!0);T(r),T(n),F(()=>B(i,t.row.secondary_name)),z(e,n)};V(g,e=>{t.row.is_alias&&e(_)});var v=P(g,2),y=e=>{var n=Qk(),r=P(M(n)),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=Zk();F(e=>{W(n,`aria-label`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),W(n,`title`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),n.disabled=e},[()=>!!ek.rowDeletingKey]),L(`click`,n,()=>ek.removeRedirectRow(t.row)),z(e,n)},s=O(()=>ek.virtualModelsAvailable&&FO(t.row));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>mO(t.row.masking_alias)]),z(e,n)};V(v,e=>{!t.row.is_alias&&t.row.masking_alias&&e(y)}),T(a),T(i);var b=P(i);H(b,17,()=>t.columns,oi,(e,r)=>{var i=$k(),a=M(i,!0);T(i),F(e=>{U(i,1,Fi(I(r).class),`svelte-1iynym`),B(a,e)},[()=>I(r).value(t.row,I(n))]),z(e,i)});var x=P(b),S=M(x),C=e=>{var n=eA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>ek.rowDeletingKey===t.row.key?`Removing alias `+t.row.alias.name:`Remove alias `+t.row.alias.name),r=O(()=>!!ek.rowDeletingKey);gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>ek.removeAliasRow(t.row),get disabled(){return I(r)},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})}},o=O(()=>ek.virtualModelsAvailable&&PO(t.row));V(i,e=>{I(o)&&e(a)});var s=P(i,2),c=e=>{{let n=O(()=>`Edit alias `+t.row.alias.name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.alias),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n)},w=e=>{var n=tA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`model pricing for `+t.row.display_name,xk.hasModelPricingOverride(t.row))),r=O(()=>xk.modelPricingButtonClass(xk.hasModelPricingOverride(t.row)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openModelPricingOverrideEdit(t.row),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(i,e=>{xk.modelPricingOverridesAvailable&&e(a)});var o=P(i,2),s=e=>{{let n=O(()=>Z.failoverButtonLabel(t.row)),r=O(()=>Z.failoverButtonClass(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>Z.openFailoverForModel(t.row),children:(e,t)=>{G(e,{get icon(){return Eo},class:`table-icon-svg`})},$$slots:{default:!0}})}},c=O(()=>Z.failoverAvailable&&Z.failoverEnabled());V(o,e=>{I(c)&&e(s)});var l=P(o,2),u=e=>{{let n=O(()=>X.rateLimitGaugeTitle(t.row.display_name,X.rateLimitGaugeClassForModel(t.row))),r=O(()=>X.rateLimitGaugeClassForModel(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForModel(t.row),children:(e,t)=>{G(e,{get icon(){return $a},class:`table-icon-svg`})},$$slots:{default:!0}})}},d=O(()=>X.rateLimitsEnabled()&&X.rateLimitInspectorModelID(t.row));V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{{let n=O(()=>`Edit redirect for `+t.row.display_name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.masking_alias),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(f,e=>{ek.virtualModelsAvailable&&t.row.masking_alias&&t.row.masking_alias.name&&e(p)});var m=P(f,2),h=e=>{{let n=O(()=>BO(`model access for `+t.row.display_name,RO(t.row.access))),r=O(()=>zO(RO(t.row.access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openVirtualModelEditModel(t.row),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(m,e=>{ek.virtualModelsAvailable&&!t.row.masking_alias&&e(h)}),T(n),z(e,n)};V(S,e=>{t.row.is_alias?e(C):e(w,-1)}),T(x),T(r),F((e,n)=>{W(r,`id`,e),U(r,1,n,`svelte-1iynym`),B(c,t.row.display_name)},[()=>IO(t.row)||void 0,()=>Fi(NO(t.row))]),z(e,r),D()}Hr([`click`]);var iA={headerLines:[`Modes`],value:e=>(e.model?.metadata?.modes??[]).join(`, `)||`-`};function aA(e,t){return{headerLines:e,class:`col-price`,value:t}}var oA=aA([`Input / Output ($/MTok)`],(e,t)=>cc(t?.input_per_mtok)+` / `+cc(t?.output_per_mtok)),sA={all:[oA],text_generation:[iA,oA,aA([`Cached $/MTok`],(e,t)=>cc(t?.cached_input_per_mtok))],embedding:[aA([`Input`,`$/MTok`],(e,t)=>cc(t?.input_per_mtok))],image:[aA([`$/Image`],(e,t)=>lc(t?.per_image))],audio:[aA([`$/Second`],(e,t)=>lc(t?.per_second_input)),aA([`$/Character`],(e,t)=>lc(t?.per_character_input))],video:[aA([`$/Second (In)`],(e,t)=>lc(t?.per_second_input)),aA([`$/Second (Out)`],(e,t)=>lc(t?.per_second_output))],utility:[aA([`$/Page`],(e,t)=>lc(t?.per_page)),aA([`$/Request`],(e,t)=>lc(t?.per_request))]};function cA(e){return sA[e]||sA.all}function lA(e){return cA(e).length+2}var uA=R(`
`),dA=R(` `,1),fA=R(``),pA=R(` `),mA=R(` `),hA=R(`
`),gA=R(`
`),_A=R(`
Model
`);function vA(e,t){E(t,!0);let n=O(()=>Nc.activeCategory||`all`),r=O(()=>cA(I(n))),i=O(()=>lA(I(n)));var a=_A(),o=M(a),s=M(o),c=M(s),l=P(M(c));H(l,17,()=>I(r),oi,(e,t)=>{var n=fA();H(n,21,()=>I(t).headerLines,oi,(e,t,n)=>{var r=dA(),i=N(r),a=e=>{z(e,uA())};V(i,e=>{n>0&&e(a)});var o=P(i,1,!0);F(()=>B(o,I(t))),z(e,r)}),T(n),F(()=>U(n,1,Fi(I(t).class),`svelte-1911hy6`)),z(e,n)});var u=P(l);Tk(M(u),{}),T(u),T(c),T(s),H(P(s),17,()=>ek.filteredDisplayModelGroups,e=>e.key,(e,t)=>{var n=gA(),a=M(n),o=M(a),s=M(o),c=M(s),l=M(c),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=e=>{var n=pA(),r=M(n,!0);T(n),F(()=>B(r,`(`+I(t).type_label+`)`)),z(e,n)};V(f,e=>{I(t).type_label&&e(p)});var m=P(f,2),h=e=>{var n=mA(),r=M(n,!0);T(n),F(()=>B(r,I(t).item_count_label)),z(e,n)};V(m,e=>{I(t).item_count_label&&e(h)}),T(l);var g=P(l,2),_=e=>{var n=hA(),r=M(n,!0);T(n),F(()=>B(r,I(t).access_summary)),z(e,n)};V(g,e=>{I(t).access_summary&&e(_)}),T(c);var v=P(c,2),y=M(v),b=e=>{Ck(e,{get row(){return I(t)}})};V(y,e=>{I(t).access.selector&&e(b)});var x=P(y,2),S=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`provider pricing for `+I(t).display_name,xk.hasProviderPricingOverride(I(t)))),r=O(()=>xk.modelPricingButtonClass(xk.hasProviderPricingOverride(I(t))));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openProviderPricingOverrideEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(x,e=>{xk.modelPricingOverridesAvailable&&I(t).provider_name&&e(S)});var C=P(x,2),w=e=>{{let n=O(()=>X.rateLimitGaugeTitle(`provider `+I(t).display_name,X.rateLimitGaugeClassForProvider(I(t)))),r=O(()=>X.rateLimitGaugeClassForProvider(I(t)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForProvider(I(t)),children:(e,t)=>{G(e,{get icon(){return $a},class:`table-icon-svg`})},$$slots:{default:!0}})}},ee=O(()=>X.rateLimitsEnabled()&&I(t).provider_name);V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{{let n=O(()=>BO(`provider access for `+I(t).display_name,RO(I(t).access))),r=O(()=>zO(RO(I(t).access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openProviderOverrideEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(te,e=>{ek.virtualModelsAvailable&&I(t).access.selector&&e(ne)}),T(v),T(s),T(o),T(a),H(P(a),17,()=>I(t).rows,e=>e.key,(e,t)=>{rA(e,{get row(){return I(t)},get columns(){return I(r)}})}),T(n),F(()=>{W(o,`colspan`,I(i)),B(d,I(t).display_name)}),z(e,n)}),T(o),T(a),z(e,a),D()}var yA=R(``);function bA(e,t){let n=ya(t,`enabled`,3,!1),r=ya(t,`label`,3,``),i=ya(t,`disabled`,3,!1),a=ya(t,`restricted`,3,!1);var o=yA();let s;var c=P(M(o),2),l=M(c,!0);T(c),T(o),F(()=>{s=U(o,1,`alias-toggle`,null,s,{enabled:n(),restricted:a()}),o.disabled=i(),W(o,`aria-label`,(n()?`Disable `:`Enable `)+r()),B(l,t.text??(n()?`Enabled`:`Disabled`))}),L(`click`,o,function(...e){t.onclick?.apply(this,e)}),z(e,o)}Hr([`click`]);var xA=R(``),SA=R(`
`);function CA(e,t){E(t,!0);let n=ya(t,`model`,15,``),r=ya(t,`weight`,15),i=ya(t,`id`,3,void 0),a=ya(t,`placeholder`,3,`openai/gpt-4o`),o=ya(t,`showRemove`,3,!0);var s=SA(),c=M(s);na(c);var l=P(c,2),u=e=>{var t=xA();na(t),F(()=>t.disabled=ek.vmFormManaged),da(t,r),z(e,t)},d=O(()=>ek.vmFormShowWeights());V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{gT(e,{label:`Remove target`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,get onclick(){return t.onremove},get disabled(){return ek.vmFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})};V(f,e=>{o()&&e(p)}),T(s),F(()=>{W(c,`id`,i()),W(c,`placeholder`,a()),c.disabled=ek.vmFormManaged}),da(c,n),z(e,s),D()}var wA=R(`

`),TA=R(`adaptive lets the registered routing extension pick the target per - request.`,1),EA=R(`Add one target to make this a redirect/alias, or two or more to load - balance across them, then pick a strategy: round_robin rotates across targets - (weight biases the share) and cost always routes to the cheapest available - target. Leave Targets empty to make it only an access policy on the Source selector. The selector uses / for all providers and - models, for one provider, or for one model. user_paths is - matched against the effective request user_path: the managed API key user_path when present, otherwise the configured user path request header.`,1),DA=R(``),OA=R(`

This virtual model is defined in configuration (config.yaml / VIRTUAL_MODELS) and is read-only here. Edit your configuration to change it.

`),kA=R(``),AA=R(``),jA=R(``),MA=R(`
`,1),NA=R(``),PA=R(`Use / to allow every user path. Use a team path to restrict to that - subtree, or an unused path to make the selector unavailable.`,1),FA=R(``),IA=R(` `),LA=R(`
Targets
`,1);function RA(e,t){E(t,!0);let n=ek;An(()=>{n.vmFormOpen&&Ss.ensureLoaded()});{let t=e=>{qS(e,{copyId:`virtual-model-help-copy`,label:`virtual model help`,get open(){return n.vmFormHelpOpen},set open(e){n.vmFormHelpOpen=e},title:e=>{var t=wA(),r=M(t,!0);T(t),F(()=>B(r,n.vmFormDisplayName||n.vmForm.source||`Virtual model`)),z(e,t)},help:e=>{Ue();var t=EA(),n=P(N(t),7),r=e=>{var t=TA();Ue(),z(e,t)},i=O(()=>Ss.virtualModelStrategies().includes(`adaptive`));V(n,e=>{I(i)&&e(r)});var a=P(n,8);a.textContent=`{provider_name}/`;var o=P(a,2);o.textContent=`{provider_name}/{model}`,Ue(7),z(e,t)},$$slots:{title:!0,help:!0}})},r=e=>{var t=Qr(),r=N(t),i=e=>{var t=DA();F(()=>t.disabled=n.vmDeleting||n.vmSubmitting),L(`click`,t,()=>n.deleteVirtualModel()),z(e,t)};V(r,e=>{n.vmFormHasExisting&&!n.vmFormManaged&&e(i)}),z(e,t)},i=O(()=>n.vmDeleting||n.vmFormManaged),a=O(()=>n.vmFormMode===`edit`?`Save`:`Create`),o=O(()=>n.vmFormMode===`edit`?_o:po);bE(e,{get open(){return n.vmFormOpen},ariaLabel:`Virtual model editor`,get error(){return n.vmFormError},get submitting(){return n.vmSubmitting},get submitDisabled(){return I(i)},get submitLabel(){return I(a)},get submitIcon(){return I(o)},onclose:()=>n.closeVirtualModelForm(),onsubmit:()=>n.submitVirtualModelForm(),header:t,extraActions:r,children:(e,t)=>{var r=LA(),i=N(r),a=e=>{z(e,OA())};V(i,e=>{n.vmFormManaged&&e(a)});var o=P(i,2);SE(o,{id:`virtual-model-source`,label:`Source`,children:(e,t)=>{var r=kA();na(r),F(()=>r.disabled=n.vmFormSourceLocked||n.vmFormManaged),da(r,()=>n.vmForm.source,e=>n.vmForm.source=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2);H(s,21,()=>Nc.models,e=>tO(e),(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(s);var c=P(s,2),l=P(M(c),2);{let e=O(()=>n.vmFormHasPrimaryTarget());CA(l,{id:`virtual-model-target`,get showRemove(){return I(e)},onremove:()=>n.removePrimaryTarget(),get model(){return n.vmForm.target_model},set model(e){n.vmForm.target_model=e},get weight(){return n.vmForm.target_weight},set weight(e){n.vmForm.target_weight=e}})}var u=P(l,2);H(u,17,()=>n.vmForm.targets,oi,(e,t,r)=>{CA(e,{placeholder:`groq/llama`,onremove:()=>n.removeVmTarget(r),get model(){return I(t).model},set model(e){I(t).model=e},get weight(){return I(t).weight},set weight(e){I(t).weight=e}})});var d=P(u,2),f=M(d);G(M(f),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(f),T(d),T(c);var p=P(c,2),m=e=>{var t=MA(),r=N(t);SE(r,{id:`virtual-model-strategy`,label:`Load-balancing strategy`,children:(e,t)=>{var r=jA();H(r,21,()=>n.vmStrategyOptions(),e=>e.value,(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),F(()=>r.disabled=n.vmFormManaged),Gi(r,()=>n.vmForm.strategy,e=>n.vmForm.strategy=e),z(e,r)},$$slots:{default:!0}});var i=P(r,2),a=M(i),o=M(a);na(o),Ue(2),T(a),T(i),F(()=>o.disabled=n.vmFormManaged),fa(o,()=>n.vmForm.session_affinity,e=>n.vmForm.session_affinity=e),z(e,t)},h=O(()=>n.vmFormShowStrategy());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=M(g);qS(_,{copyId:`virtual-model-user-paths-help`,label:`user paths help`,get open(){return n.vmFormUserPathsHelpOpen},set open(e){n.vmFormUserPathsHelpOpen=e},title:e=>{z(e,NA())},help:e=>{Ue();var t=PA();Ue(2),z(e,t)},$$slots:{title:!0,help:!0}});var v=P(_,2);ft(v),W(v,`placeholder`,`/ -/team/alpha -/non-existing`),T(g);var y=P(g,2);SE(y,{id:`virtual-model-description`,label:`Description`,children:(e,t)=>{var r=FA();ft(r),F(()=>r.disabled=n.vmFormManaged),da(r,()=>n.vmForm.description,e=>n.vmForm.description=e),z(e,r)},$$slots:{default:!0}});var b=P(y,2),x=M(b),S=e=>{var t=IA(),r=M(t,!0);T(t),F(()=>B(r,`Default enabled: `+(n.vmFormDefaultEnabled?`yes`:`no`)+` · Effective now: `+(n.vmFormEffectiveEnabled?`yes`:`no`))),z(e,t)};V(x,e=>{n.vmFormMode===`edit`&&e(S)});var C=P(x,2),w=M(C);{let e=O(()=>n.vmFormToggleRestricted()),t=O(()=>n.vmFormToggleLabel());bA(w,{get enabled(){return n.vmForm.enabled},get restricted(){return I(e)},label:`virtual model`,get disabled(){return n.vmFormManaged},get text(){return I(t)},onclick:()=>{n.vmFormManaged||(n.vmForm.enabled=!n.vmForm.enabled)}})}T(C),T(b),F(()=>{f.disabled=n.vmFormManaged,v.disabled=n.vmFormManaged}),L(`click`,f,()=>n.addVmTarget()),da(v,()=>n.vmForm.user_paths,e=>n.vmForm.user_paths=e),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var zA=R(`

Pricing override

`,1),BA=R(``),VA=R(``),HA=R(``),UA=R(``),WA=R(`
`),GA=R(`
Tiered pricing exists for this override and will be preserved. Tier editing can be added - without a database migration.
`),KA=R(`
No pricing fields set.
`),qA=R(`
`),JA=R(`

Currency is USD. Saved fields override model registry and config.yaml pricing for this - selector; unset fields continue to inherit.

Price Type USD Source
`,1);function YA(e,t){E(t,!0);let n=xk;bE(e,{get open(){return n.modelPricingOverrideFormOpen},ariaLabel:`Model pricing editor`,dialogClass:`model-pricing-editor`,get error(){return n.modelPricingOverrideError},get submitting(){return n.modelPricingOverrideSubmitting},submitLabel:`Save Pricing`,onclose:()=>n.closeModelPricingOverrideForm(),onsubmit:()=>n.submitModelPricingOverrideForm(),header:e=>{var t=zA(),r=P(N(t),2),i=M(r,!0);T(r),F(()=>B(i,n.modelPricingOverrideFormDisplayName||n.modelPricingOverrideForm.selector||`Pricing`)),z(e,t)},extraActions:e=>{var t=Qr(),r=N(t),i=e=>{var t=BA();F(()=>t.disabled=n.modelPricingOverrideSubmitting),L(`click`,t,()=>n.deleteModelPricingOverride()),z(e,t)};V(r,e=>{n.modelPricingOverrideFormHasExistingOverride&&e(i)}),z(e,t)},children:(e,t)=>{var r=JA(),i=N(r),a=M(i);SE(a,{id:`model-pricing-override-selector`,label:`Selector`,children:(e,t)=>{var r=VA();na(r),da(r,()=>n.modelPricingOverrideForm.selector,e=>n.modelPricingOverrideForm.selector=e),z(e,r)},$$slots:{default:!0}});var o=P(a,2),s=e=>{SE(e,{id:`model-pricing-override-scope`,label:`Scope`,children:(e,t)=>{var r=UA();H(r,21,()=>n.modelPricingOverrideFormScopeOptions,e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),L(`change`,r,()=>n.setModelPricingOverrideScope(n.modelPricingOverrideFormScope)),Gi(r,()=>n.modelPricingOverrideFormScope,e=>n.modelPricingOverrideFormScope=e),z(e,r)},$$slots:{default:!0}})};V(o,e=>{n.modelPricingOverrideFormScopeOptions.length>1&&e(s)}),T(i);var c=P(i,4);H(c,21,()=>n.modelPricingOverrideRows,e=>e.id,(e,t,r)=>{var i=WA(),a=M(i),o=M(a),s=P(o,2);H(s,21,()=>n.availablePricingFieldOptions(I(t)),e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).group+` - `+I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(s),T(a);var c=P(a,2),l=M(c),u=P(l,2);na(u),T(c);var d=P(c,2);{let e=O(()=>`Remove `+n.pricingFieldLabel(I(t).field));gT(d,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn pricing-override-remove-row`,onclick:()=>n.removeModelPricingOverrideRow(I(t)),children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}T(i),F(()=>{W(o,`for`,`pricing-type-`+I(t).id),W(s,`id`,`pricing-type-`+I(t).id),W(l,`for`,`pricing-value-`+I(t).id),W(u,`id`,`pricing-value-`+I(t).id)}),Gi(s,()=>I(t).field,e=>I(t).field=e),da(u,()=>I(t).value,e=>I(t).value=e),z(e,i)}),T(c);var l=P(c,2),u=M(l);G(M(u),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(u),T(l);var d=P(l,2),f=e=>{z(e,GA())};V(d,e=>{n.modelPricingOverrideFormPreservedTiers.length>0&&e(f)});var p=P(d,2),m=P(M(p),2),h=e=>{z(e,KA())},g=O(()=>n.modelPricingEffectivePreviewRows().length===0);V(m,e=>{I(g)&&e(h)}),H(P(m,2),17,()=>n.modelPricingEffectivePreviewRows(),e=>e.field,(e,t)=>{var n=qA(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{B(i,I(t).label),B(o,e),B(c,I(t).source)},[()=>I(t).value===null||I(t).value===void 0?`-`:lc(Number(I(t).value))]),z(e,n)}),T(p),L(`click`,u,()=>n.addModelPricingOverrideRow()),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}}),D()}Hr([`click`,`change`]);var XA=R(`

Failover mapping

`,1),ZA=R(``),QA=R(`

This failover mapping is defined in configuration and is read-only here.

`),$A=R(``),ej=R(`
`),tj=R(`
`,1),nj=R(`
`);function rj(e,t){E(t,!0);{let t=e=>{var t=XA(),n=P(N(t),2),r=M(n,!0);T(n),F(()=>B(r,Z.failoverForm.source||`Failover`)),z(e,t)},n=e=>{var t=Qr(),n=N(t),r=e=>{var t=ZA();F(()=>t.disabled=Z.failoverSaving||Z.failoverGenerating),L(`click`,t,()=>Z.deleteFailoverRule()),z(e,t)};V(n,e=>{Z.failoverFormMode===`edit`&&!Z.failoverFormManaged&&e(r)}),z(e,t)},r=O(()=>Z.failoverGenerating||Z.failoverFormManaged);bE(e,{get open(){return Z.failoverFormOpen},ariaLabel:`Failover editor`,get error(){return Z.failoverError},get submitting(){return Z.failoverSaving},get submitDisabled(){return I(r)},submitLabel:`Save`,onclose:()=>Z.closeFailoverForm(),onsubmit:()=>Z.submitFailoverForm(),header:t,extraActions:n,children:(e,t)=>{var n=nj(),r=M(n),i=e=>{z(e,QA())};V(r,e=>{Z.failoverFormManaged&&e(i)});var a=P(r,2);H(a,21,()=>Nc.models,oi,(e,t)=>{var n=$A(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(a);var o=P(a,2);SE(o,{id:`failover-target`,label:`Fallback models`,children:(e,t)=>{var n=tj(),r=N(n),i=M(r),a=M(i);na(a);var o=P(a,2),s=e=>{gT(e,{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removePrimaryFailoverTarget(),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})};V(o,e=>{Z.failoverForm.target_model&&e(s)}),T(i),H(P(i,2),17,()=>Z.failoverForm.targets,oi,(e,t,n)=>{var r=ej(),i=M(r);na(i),gT(P(i,2),{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removeFailoverTarget(n),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),F(()=>i.disabled=Z.failoverFormManaged),da(i,()=>I(t).model,e=>I(t).model=e),z(e,r)}),T(r);var c=P(r,2),l=M(c);G(M(l),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(l);var u=P(l,2),d=M(u);G(d,{get icon(){return Po},class:`form-action-icon`});var f=P(d,2),p=M(f,!0);T(f),T(u),T(c),F(e=>{a.disabled=Z.failoverFormManaged,l.disabled=Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving,u.disabled=e,B(p,Z.failoverGenerating?`Generating...`:`Generate automatically`)},[()=>Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving||!Z.failoverEnabled()]),da(a,()=>Z.failoverForm.target_model,e=>Z.failoverForm.target_model=e),L(`click`,l,()=>Z.addFailoverTarget()),L(`click`,u,()=>Z.generateFailoverForForm()),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=M(s);bA(M(c),{get enabled(){return Z.failoverForm.enabled},label:`failover mapping`,get disabled(){return Z.failoverFormManaged},onclick:()=>{Z.failoverFormManaged||(Z.failoverForm.enabled=!Z.failoverForm.enabled)}}),T(c),T(s),T(n),z(e,n)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var ij=R(` `),aj=R(`
`),oj=R(``),sj=R(`
`),cj=R(`

No failover suggestions were generated.

`),lj=R(`

No failover drafts match the filter.

`),uj=R(``),dj=R(``);function fj(e,t){E(t,!0),Ns(e,{get open(){return Z.failoverDraftsOpen},variant:`editor`,onclose:()=>Z.closeFailoverDraftsModal(),children:(e,t)=>{var n=dj(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=ij(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>Z.failoverDraftCountLabel()]),z(e,t)};V(a,e=>{Z.failoverGeneratedRules.length>0&&e(o)}),ks(P(a,2),{label:`Close failover drafts`,onclick:()=>Z.closeFailoverDraftsModal(),get disabled(){return Z.failoverDraftSaving}}),T(i),T(r);var s=P(r,2),c=e=>{mT(e,{label:`Generating failover drafts...`,class:`failover-drafts-loading`})};V(s,e=>{Z.failoverGenerating&&e(c)});var l=P(s,2),u=e=>{var t=aj(),n=M(t);yw(n,{placeholder:`Filter failover drafts...`,label:`Filter failover drafts`,get value(){return Z.failoverDraftFilter},set value(e){Z.failoverDraftFilter=e}});var r=P(n,2),i=M(r);G(i,{get icon(){return Va},class:`form-action-icon`});var a=P(i,2),o=M(a,!0);T(a),T(r),T(t),F(e=>{r.disabled=Z.failoverDraftSaving,B(o,e)},[()=>Z.allFailoverDraftsSelected()?`Deselect all`:`Select all`]),L(`click`,r,()=>Z.toggleAllFailoverDrafts()),z(e,t)};V(l,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&e(u)});var d=P(l,2),f=e=>{var t=sj();H(t,21,()=>Z.filteredFailoverDrafts(),e=>`failover-draft:`+Z.failoverPrimaryModel(e),(e,t)=>{var n=oj(),r=M(n);na(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(i),T(n),F((e,t,n,i)=>{ia(r,e),r.disabled=Z.failoverDraftSaving,W(r,`aria-label`,t),B(o,n),B(c,i)},[()=>Z.failoverDraftSelected(I(t)),()=>`Select failover draft for `+Z.failoverPrimaryModel(I(t)),()=>Z.failoverPrimaryModel(I(t)),()=>Z.failoverTargetLabel(I(t))]),L(`change`,r,e=>Z.setFailoverDraftSelected(I(t),e.currentTarget.checked)),z(e,n)}),T(t),z(e,t)},p=O(()=>!Z.failoverGenerating&&Z.filteredFailoverDrafts().length>0);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{z(e,cj())};V(m,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length===0&&!Z.failoverError&&e(h)});var g=P(m,2),_=e=>{z(e,lj())},v=O(()=>!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&Z.filteredFailoverDrafts().length===0);V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=uj(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(y,e=>{Z.failoverError&&e(b)});var x=P(y,2),S=M(x),C=P(S,2),w=M(C);G(w,{get icon(){return _o},class:`form-action-icon`});var ee=P(w,2),te=M(ee,!0);T(ee),T(C),T(x),T(n),F(e=>{S.disabled=Z.failoverDraftSaving,C.disabled=e,B(te,Z.failoverDraftSaving?`Saving...`:`Save selected`)},[()=>Z.failoverGenerating||Z.failoverDraftSaving||Z.selectedFailoverDraftCount()===0]),L(`click`,S,()=>Z.closeFailoverDraftsModal()),L(`click`,C,()=>Z.saveSelectedFailoverDrafts()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`,`change`]);var pj=R(`
Rate limit management is unavailable.
`),mj=R(` Add`,1),hj=R(`

`),gj=R(`

No rules.

`),_j=R(` Edit`,1),vj=R(`
`),yj=R(`
`),bj=R(`

`),xj=R(``),Sj=R(``);function Cj(e,t){E(t,!0);function n(){K.dialogOpen||X.closeRateLimitInspector()}Ns(e,{get open(){return X.rateLimitInspectorOpen},variant:`editor`,onclose:n,children:(e,t)=>{var n=Sj(),r=M(n),i=M(r),a=P(M(i),2),o=M(a),s=M(o,!0);T(o),T(a),T(i),ks(P(i,2),{label:`Close rate limits inspector`,onclick:()=>X.closeRateLimitInspector()}),T(r);var c=P(r,2),l=e=>{mT(e,{label:`Loading rate limits...`})},u=e=>{z(e,pj())},d=e=>{var t=Qr();H(N(t),17,()=>X.rateLimitInspectorSections(),e=>e.key,(e,t)=>{var n=bj(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2);{let e=O(()=>`Add `+I(t).title.toLowerCase());gT(o,{get label(){return I(e)},class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(I(t).scope,I(t).subject),children:(e,t)=>{var n=mj();G(N(n),{get icon(){return po},class:`table-icon-svg`}),Ue(2),z(e,n)},$$slots:{default:!0}})}T(r);var s=P(r,2),c=e=>{var n=hj(),r=M(n,!0);T(n),F(()=>B(r,I(t).hint)),z(e,n)};V(s,e=>{I(t).hint&&e(c)});var l=P(s,2),u=e=>{z(e,gj())},d=e=>{var n=yj();H(n,21,()=>I(t).items,e=>X.rateLimitKey(e),(e,t)=>{var n=vj(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=M(c);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?Ma:ko);G(l,{get icon(){return I(e)},class:`budget-period-icon`})}var u=P(l,2),d=M(u,!0);T(u),T(c),T(s);var f=P(s,2),p=M(f),m=M(p),h=M(m,!0);T(m);var g=P(m,2),_=M(g,!0);T(g),T(p);var v=P(p,2),y=M(v),b=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(null,null,I(t)),children:(e,t)=>{var n=_j();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},x=O(()=>!X.rateLimitIsReadOnly(I(t)));V(y,e=>{I(x)&&e(b)}),T(v),T(f),T(i),T(r),T(n),F((e,t,r,i,a,s,c,l)=>{U(n,1,`budget-row ${e??``}`),Hi(n,t),W(n,`title`,r),B(o,i),B(d,a),B(h,s),W(g,`title`,c),B(_,l)},[()=>X.rateLimitPressureClass(I(t)),()=>X.rateLimitPressureStyle(I(t)),()=>X.rateLimitPressurePercent(I(t))+`% of the most constrained cap used`,()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitInspectorSummary(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n)};V(l,e=>{I(t).items.length===0?e(u):e(d,-1)}),T(n),F(()=>B(a,I(t).title)),z(e,n)}),z(e,t)};V(c,e=>{X.rateLimitsLoading?e(l):X.rateLimitsAvailable?e(d,-1):e(u,1)});var f=P(c,2),p=M(f),m=P(p,2),h=e=>{var t=xj();L(`click`,t,()=>{X.closeRateLimitInspector(),Jo.navigate(`rate-limits`)}),z(e,t)},g=O(()=>X.rateLimitsEnabled());V(m,e=>{I(g)&&e(h)}),T(f),T(n),F(()=>B(s,X.rateLimitInspector.title)),L(`click`,p,()=>X.closeRateLimitInspector()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`]);var wj=R(`
models
`),Tj=R(`
Virtual models feature is unavailable.
`),Ej=R(`
`),Dj=R(``),Oj=R(`
`),kj=R(``),Aj=R(`
`),jj=R(`

No models registered.

`),Mj=R(`

No models in this category.

`),Nj=R(`

No models match your filter.

`),Pj=R(`
`);function Fj(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`models`&&(ek.fetchVirtualModels(),xk.fetchModelPricingOverrides(),Z.fetchFailoverRules(),X.fetchRateLimitsPage())}),An(()=>{let e=ek.filteredDisplayModels.length;return Er(()=>ek.restartModelRendering(e)),()=>ek.stopModelRendering()});let n=O(()=>K.needsAuth);var r=Pj(),i=M(r),a=P(M(i),2),o=e=>{var t=wj(),n=M(t),r=M(n,!0);T(n),Ue(),T(t),F(()=>B(r,Nc.filter?ek.filteredDisplayModels.length+` / `+ek.displayModels.length:ek.displayModels.length)),z(e,t)};V(a,e=>{ek.displayModels.length>0&&e(o)}),T(i);var s=P(i,2);Fc(s,{});var c=P(s,2),l=e=>{z(e,Tj())};V(c,e=>{!ek.virtualModelsAvailable&&!I(n)&&e(l)});var u=P(c,2),d=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,ek.aliasError)),z(e,t)};V(u,e=>{ek.aliasError&&!I(n)&&e(d)});var f=P(u,2),p=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,xk.modelPricingOverrideError)),z(e,t)};V(f,e=>{xk.modelPricingOverrideError&&!I(n)&&!xk.modelPricingOverrideFormOpen&&e(p)});var m=P(f,2),h=e=>{var t=Oj();H(t,21,()=>Nc.categories,e=>e.category,(e,t)=>{var n=Dj();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F(()=>{r=U(n,1,`category-tab svelte-scpjps`,null,r,{active:Nc.activeCategory===I(t).category}),B(a,I(t).display_name),B(s,I(t).count)}),L(`click`,n,()=>Nc.selectCategory(I(t).category)),z(e,n)}),T(t),z(e,t)};V(m,e=>{Nc.categories.length>0&&e(h)});var g=P(m,2),_=e=>{var t=Aj(),n=M(t);yw(M(n),{placeholder:`Filter by provider, provider/model, alias, or owner...`,label:`Filter models by provider, provider/model, alias, or owner`,get value(){return Nc.filter},set value(e){Nc.filter=e}}),T(n);var r=P(n,2),i=M(r),a=e=>{var t=kj();G(M(t),{get icon(){return po},class:`alias-create-icon`}),Ue(2),T(t),L(`click`,t,()=>ek.openVirtualModelCreate()),z(e,t)};V(i,e=>{ek.virtualModelsAvailable&&e(a)}),T(r),T(t),z(e,t)};V(g,e=>{(ek.displayModels.length>0||Nc.filter||ek.virtualModelsAvailable)&&e(_)});var v=P(g,2),y=e=>{{let t=O(()=>ek.modelLoadingText());mT(e,{get label(){return I(t)},class:`models-loading-state`})}},b=O(()=>ek.modelsBusy()&&!I(n));V(v,e=>{I(b)&&e(y)});var x=P(v,2);RA(x,{});var S=P(x,2);YA(S,{});var C=P(S,2),w=e=>{vA(e,{})};V(C,e=>{(ek.displayModels.length>0||Nc.filter)&&e(w)});var ee=P(C,2),te=e=>{z(e,jj())};V(ee,e=>{ek.displayModels.length===0&&!Nc.loading&&!I(n)&&!Nc.filter&&(Nc.activeCategory===`all`||!Nc.activeCategory)&&e(te)});var ne=P(ee,2),re=e=>{z(e,Mj())};V(ne,e=>{ek.displayModels.length===0&&!Nc.loading&&!I(n)&&!Nc.filter&&Nc.activeCategory&&Nc.activeCategory!==`all`&&e(re)});var ie=P(ne,2),ae=e=>{z(e,Nj())};V(ie,e=>{ek.displayModels.length>0&&ek.filteredDisplayModels.length===0&&Nc.filter&&e(ae)});var oe=P(ie,2);Cj(oe,{});var se=P(oe,2);FD(se,{});var ce=P(se,2);rj(ce,{}),fj(P(ce,2),{}),T(r),z(e,r),D()}Hr([`click`]);var Ij=`draft-workflow-preview`;function Lj(){return{scope_provider:``,scope_model:``,scope_user_path:``,name:``,description:``,features:{cache:!0,audit:!0,usage:!0,budget:!0,guardrails:!1,failover:!0},guardrails:[]}}function Rj(){return{scope_provider:``,scope_model:``,scope_user_path:``}}function zj(e){return{ref:``,step:Number.isFinite(e)?e:10}}function Bj(e){let t=e==null?``:String(e).trim();if(t===``)return NaN;let n=Number(t);return Number.isFinite(n)?n:NaN}function Vj(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=t.charAt(0).toUpperCase()+t.slice(1);for(let n of[t,r])if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==null&&e[n]!==void 0)return e[n];return n}function Hj(e,t){return!e||typeof e!=`object`||Array.isArray(e)?!1:[t,t.charAt(0).toUpperCase()+t.slice(1)].some(t=>Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==null&&e[t]!==void 0)}function Uj(e){return{cache:!!Vj(e,`cache`,!1),audit:!!Vj(e,`audit`,!1),usage:!!Vj(e,`usage`,!1),budget:Vj(e,`budget`,!0)!==!1,guardrails:!!Vj(e,`guardrails`,!1),failover:Vj(e,`failover`,!0)!==!1}}function Wj(e,t){let n=Uj(e),r=t||{},i=n.usage&&!!r.usage;return{cache:n.cache&&!!r.cache,audit:n.audit&&!!r.audit,usage:i,budget:i&&n.budget&&!!r.budget,guardrails:n.guardrails&&!!r.guardrails,failover:n.failover&&!!r.failover}}function Gj(e,t){let n=e&&e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:e&&e.features?e.features:{};return{...Wj((e&&e.effective_features&&typeof e.effective_features==`object`&&!Array.isArray(e.effective_features)?e.effective_features:null)||n,t),failover:Uj(n).failover}}function Kj(e,t){return Gj(e,t).failover?`On`:`Off`}function qj(e){return(Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:Array.isArray(e&&e.guardrails)?e.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0)}function Jj(e,t){return Gj(e,t).guardrails&&Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[]}function Yj(e){return String(e&&(e.scope_provider_name||e.scope_provider)||``).trim()}function Xj(e){return String(e&&(e.provider_name||e.provider_type)||``).trim()}function Zj(e,t){let n=new Set,r=String(t&&t.scope_provider||``).trim();return r&&n.add(r),(Array.isArray(e)?e:[]).forEach(e=>{let t=Xj(e);t&&n.add(t)}),[...n].sort()}function Qj(e,t,n){let r=String(t||``).trim(),i=new Set,a=String(n&&n.scope_provider||``).trim(),o=String(n&&n.scope_model||``).trim();return r&&r===a&&o&&i.add(o),(Array.isArray(e)?e:[]).forEach(e=>{if(r&&Xj(e)!==r)return;let t=String(e&&e.model&&e.model.id||``).trim();t&&i.add(t)}),[...i].sort()}function $j(e){let t=String(e&&e.scope_type||``).trim();return t===`provider_model`?`Provider Name + Model`:t===`provider_model_path`?`Provider Name + Model + Path`:t===`provider_path`?`Provider Name + Path`:t===`path`?`Path`:t===`provider`?`Provider Name`:`Global`}function eM(e){return String(e&&e.scope_display||`global`).trim()||`global`}function tM(e){let t=String(e&&e.name||``).trim();if(t)return t;let n=eM(e);return n===`global`?`All models`:n}function nM(e){let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function rM(e){if(nM(e))return``;let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function iM(e){let t=e||Lj(),n=String(t.scope_provider||``).trim(),r=rM(t.scope_user_path);return{scope_provider:n,scope_model:n?String(t.scope_model||``).trim():``,scope_user_path:r}}function aM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path);return!t&&!r?`global`:!t&&r?`path`:!n&&!r?`provider`:!n&&r?`provider_path`:r?`provider_model_path`:`provider_model`}function oM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path),i=aM({scope_provider:t,scope_model:n,scope_user_path:r});return i===`global`?`global`:i===`path`?r:i===`provider`?t:i===`provider_path`?t+` @ `+r:i===`provider_model_path`?t+`/`+n+` @ `+r:t+`/`+n}function sM(e,t){let n=t||Rj(),r=Yj(e&&e.scope),i=r?String(e&&e.scope&&e.scope.scope_model||``).trim():``,a=rM(e&&e.scope&&e.scope.scope_user_path);return r===String(n.scope_provider||``).trim()&&i===String(n.scope_model||``).trim()&&a===rM(n.scope_user_path)}function cM(e,t,n){let r=iM(t);return!(r.scope_provider!==``||r.scope_model!==``||r.scope_user_path!==``)&&!n?null:(Array.isArray(e)?e:[]).find(e=>sM(e,r))||null}function lM(e){return String(e&&e.scope_type||``).trim()!==`global`}function uM(e){let t=String(e||``).trim();return t?t.length<=14?t:t.slice(0,12)+`…`:`—`}function dM(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.description,e.scope_display,e.scope_type,Yj(e&&e.scope),e.scope&&e.scope.scope_model,e.scope&&e.scope.scope_user_path,e.workflow_hash,...Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>e.ref):[]].some(e=>String(e||``).toLowerCase().includes(r)))}function fM(e,t){let n=e||Lj(),r=iM(n),i=Uj(n.features||{}),a=Wj(i,t);a.failover=i.failover;let o=!!a.guardrails,s=o?qj(n):[];return{id:Ij,scope_type:aM(r),scope_display:oM(r),scope:{scope_provider_name:r.scope_provider,scope_model:r.scope_model,...r.scope_user_path?{scope_user_path:r.scope_user_path}:{}},name:String(n.name||``).trim(),description:String(n.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!a.cache,audit:!!a.audit,usage:!!a.usage,budget:!!a.budget,guardrails:o,failover:!!a.failover},guardrails:s}}}function pM({form:e,caps:t,workflows:n=[],formHydrated:r=!1,hydratedScope:i=null}){let a=e||Lj(),o=String(a.scope_provider||``).trim(),s=o?String(a.scope_model||``).trim():``,c=rM(a.scope_user_path),l=Uj(a.features||{}),u=Wj(l,t),d=cM(n,a,r),f=d&&d.workflow_payload&&d.workflow_payload.features,p=Hj(f,`failover`),m=p?Vj(f,`failover`,!0)!==!1:null,h=i||Rj(),g=String(h.scope_provider||``).trim()===o&&String(h.scope_model||``).trim()===s&&rM(h.scope_user_path)===rM(c),_=!!(t&&t.failover),v=_||!!r&&g&&Object.prototype.hasOwnProperty.call(l,`failover`)||!r&&!!d&&p,y=u.guardrails?(Array.isArray(a.guardrails)?a.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})):[],b={scope_provider_name:o,scope_model:s,...c?{scope_user_path:c}:{},name:String(a.name||``).trim(),description:String(a.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!u.cache,audit:!!u.audit,usage:!!u.usage,budget:!!u.budget,guardrails:!!u.guardrails},guardrails:y}};return v&&(b.workflow_payload.features.failover=!_&&!r&&d&&p?m:!!l.failover),b}function mM(e,{models:t=[],hydratedScope:n=null}={}){let r=n||Rj(),i=String(r.scope_provider||``).trim(),a=String(r.scope_model||``).trim(),o=String(e&&(e.scope_provider_name||e.scope_provider)||``).trim(),s=String(e&&e.scope_model||``).trim();if(o&&!Zj(t,r).includes(o)&&o!==i)return`Choose a registered provider name.`;if(s&&!o)return`Model selection requires a provider name.`;if(s){let e=Qj(t,o,r),n=o===i&&s===a;if(!e.includes(s)&&!n)return`Choose a registered model for the selected provider name.`}let c=nM(e.scope_user_path);if(c)return c;let l=e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:{},u=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[];if(!l.guardrails)return``;let d=new Set;for(let e of u){if(!e.ref)return`Each guardrail step needs a guardrail ref.`;if(!Number.isInteger(e.step)||e.step<0)return`Each guardrail step must use a non-negative integer step number.`;if(d.has(e.ref))return`Each guardrail ref may appear only once in a workflow.`;d.add(e.ref)}return``}var hM=new class{#e=k(j([]));get workflows(){return I(this.#e)}set workflows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get submitting(){return I(this.#o)}set submitting(e){A(this.#o,e,!0)}#s=k(``);get deactivatingID(){return I(this.#s)}set deactivatingID(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get formHydrated(){return I(this.#l)}set formHydrated(e){A(this.#l,e,!0)}#u=k(j(Rj()));get hydratedScope(){return I(this.#u)}set hydratedScope(e){A(this.#u,e,!0)}#d=k(j([]));get guardrailRefs(){return I(this.#d)}set guardrailRefs(e){A(this.#d,e,!0)}#f=k(j(Lj()));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}#p=null;failoverVisible(){return Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}featureCaps(){return{cache:Ss.cacheVisible(),audit:Ss.auditVisible(),usage:Ss.usageVisible(),budget:Ss.budgetsVisible(),guardrails:Ss.guardrailsVisible(),failover:this.failoverVisible()}}get filteredWorkflows(){return dM(this.workflows,this.filter)}providerOptions(){return Zj(Nc.models,this.hydratedScope)}modelOptions(e){return Qj(Nc.models,e,this.hydratedScope)}activeScopeMatch(){return cM(this.workflows,this.form,this.formHydrated)}submitMode(){return this.activeScopeMatch()?`save`:`create`}submitLabel(){return this.submitMode()===`save`?`Save`:`Create`}submittingLabel(){return this.submitMode()===`save`?`Saving...`:`Creating...`}preview(){return fM(this.form,this.featureCaps())}openCreate(e){if(this.formOpen=!0,this.submitting=!1,this.formError=``,!e){this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj();return}this.formHydrated=!0,this.hydratedScope={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``).trim(),scope_user_path:String(e.scope&&e.scope.scope_user_path||``).trim()};let t=e.workflow_payload&&e.workflow_payload.features?Uj(e.workflow_payload.features):Gj(e,this.featureCaps()),n=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0):qj(e);this.form={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``),scope_user_path:String(e.scope&&e.scope.scope_user_path||``),name:String(e.name||``),description:String(e.description||``),features:{cache:!!t.cache,audit:!!t.audit,usage:!!t.usage,budget:!!t.budget,guardrails:!!t.guardrails,failover:!!t.failover},guardrails:n.map(e=>({ref:String(e&&e.ref||``),step:Number.isFinite(e&&e.step)?e.step:10}))}}closeForm(){this.formOpen=!1,this.submitting=!1,this.formError=``,this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj()}setProvider(e){if(this.form.scope_provider=String(e||``).trim(),!this.form.scope_provider){this.form.scope_model=``;return}this.modelOptions(this.form.scope_provider).includes(String(this.form.scope_model||``).trim())||(this.form.scope_model=``)}addGuardrailStep(){let e=(Array.isArray(this.form.guardrails)?this.form.guardrails:[]).reduce((e,t)=>{let n=Number(t&&t.step);return Number.isFinite(n)?Math.max(e,n):e},0)+10;this.form.guardrails.push(zj(e))}removeGuardrailStep(e){Array.isArray(this.form.guardrails)&&this.form.guardrails.splice(e,1)}buildRequest(){return pM({form:this.form,caps:this.featureCaps(),workflows:this.workflows,formHydrated:this.formHydrated,hydratedScope:this.hydratedScope})}async fetchWorkflows(){this.#p&&this.#p.abort();let e=new AbortController;this.#p=e,this.loading=!0,this.error=``;let t=setTimeout(()=>e.abort(),1e4),n=await _T(`/admin/workflows`,{label:`workflows`,options:{signal:e.signal}});if(clearTimeout(t),this.#p===e&&(this.#p=null,this.loading=!1,n.status!==`stale`)){if(n.status===`unavailable`){this.available=!1,this.workflows=[];return}if(n.result&&(this.available=!0),n.status===`error`){this.workflows=[],this.error=e.signal.aborted?`Loading workflows timed out.`:n.error;return}this.workflows=n.items}}async fetchGuardrailRefs(){let e=await _T(`/admin/workflows/guardrails`,{label:`workflow guardrails`});e.status!==`stale`&&(this.guardrailRefs=e.items)}async fetchPage(){await Promise.all([Ss.ensureLoaded(),this.fetchWorkflows(),this.fetchGuardrailRefs()])}async submitForm(){if(this.submitting)return;this.formError=``;let e=this.buildRequest(),t=mM(e,{models:Nc.models,hydratedScope:this.hydratedScope});if(t){this.formError=t;return}this.submitting=!0;try{let t=await vT(`/admin/workflows`,`POST`,e,{label:`create workflow`,unavailableStatuses:[]});if(t.status===`stale`||t.result&&t.result.status===401)return;if(t.status===`error`){this.formError=t.error;return}q.success(`Workflow created and activated.`),this.closeForm(),this.fetchPage()}finally{this.submitting=!1}}async deactivate(e){let t=String(e&&e.id||``).trim();if(!t||this.deactivatingID||!lM(e))return;let n=tM(e);if(confirm(`Deactivate workflow "`+n+`"? Requests will fall back to the next active workflow for this scope.`)){this.deactivatingID=t;try{let e=await vT(`/admin/workflows/`+encodeURIComponent(t)+`/deactivate`,`POST`,void 0,{label:`deactivate workflow`,unavailableStatuses:[]});if(e.status===`stale`||e.result&&e.result.status===401)return;if(e.status===`error`){q.error(e.error);return}q.success(`Workflow deactivated.`),this.fetchPage()}finally{this.deactivatingID=``}}}};function gM(e){let t=String(e??``),n=typeof navigator<`u`?navigator.clipboard:null;if(n&&typeof n.writeText==`function`)return n.writeText(t);let r=typeof document<`u`?document:null;if(!r||!r.body||typeof r.execCommand!=`function`)return Promise.reject(Error(`Clipboard API unavailable`));let i=r.createElement(`textarea`);i.value=t,i.setAttribute(`readonly`,``),i.style.position=`fixed`,i.style.top=`0`,i.style.left=`0`,i.style.opacity=`0`;try{if(r.body.appendChild(i),i.focus(),i.select(),i.setSelectionRange(0,i.value.length),!r.execCommand(`copy`))throw Error(`execCommand copy returned false`)}finally{i.parentNode&&i.parentNode.removeChild(i)}return Promise.resolve()}function _M({resetDelayMs:e=2e3,logPrefix:t}={}){let n=j({copied:!1,error:!1}),r=null;function i(){r!==null&&clearTimeout(r),r=null}function a(){i(),r=setTimeout(()=>{n.copied=!1,n.error=!1,r=null},e)}return{get copied(){return n.copied},get error(){return n.error},reset(){i(),n.copied=!1,n.error=!1},async copy(e,r){if(!(e==null||e===``)){i(),n.copied=!1,n.error=!1;try{await gM(typeof r==`function`?r(e):String(e)),n.copied=!0,n.error=!1}catch(e){console.error(t||`Failed to copy text:`,e),n.copied=!1,n.error=!0}a()}}}}var vM=R(``);function yM(e,t){E(t,!0);let n=ya(t,`workflowID`,3,``),r=_M({logPrefix:`Failed to copy workflow ID:`});An(()=>{n(),r.reset()});let i=O(()=>r.error?`Unable to copy workflow ID`:r.copied?`Workflow ID copied`:`Copy workflow ID`),a=O(()=>n()?I(i)+` `+n():I(i));async function o(e){e.preventDefault(),n()&&await r.copy(n())}var s=vM();let c;var l=P(M(s),4),u=M(l,!0);T(l);var d=P(l,2);G(M(d),{get icon(){return Ya}}),T(d),T(s),F(()=>{c=U(s,1,`workflow-pipeline-meta mono svelte-1viff7o`,null,c,{"workflow-pipeline-meta-copied":r.copied,"workflow-pipeline-meta-error":r.error}),W(s,`title`,I(i)),W(s,`aria-label`,I(a)),B(u,n())}),L(`click`,s,o),z(e,s),D()}Hr([`click`]);var bM=(e,t)=>{let n=()=>(t?.()).icon,r=()=>(t?.()).label,i=Ot(()=>h((t?.()).variant,`workflow-node-feature`)),a=()=>(t?.()).state,o=()=>(t?.()).sub,s=()=>(t?.()).badge;var c=wM(),l=M(c),u=e=>{var t=xM();let r;G(M(t),{get icon(){return n()}}),T(t),F(()=>r=U(t,1,`workflow-node-icon svelte-nbptrg`,null,r,{"workflow-node-icon-endpoint":I(i)===`workflow-node-endpoint`})),z(e,t)};V(l,e=>{n()&&e(u)});var d=P(l,2),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var t=SM(),n=M(t,!0);T(t),F(()=>B(n,s())),z(e,t)};V(p,e=>{s()&&e(m)});var g=P(p,2),_=e=>{var t=CM(),n=M(t,!0);T(t),F(()=>B(n,o())),z(e,t)};V(g,e=>{o()&&e(_)}),T(c),F(()=>{U(c,1,Fi([`workflow-node`,I(i),a()]),`svelte-nbptrg`),B(f,r())}),z(e,c)},xM=R(`
`),SM=R(` `),CM=R(` `),wM=R(`
`),TM=R(`
`,1),EM=R(`
`,1),DM=R(`
`),OM=R(`
Async
`),kM=R(`
`);function AM(e,t){E(t,!0);let n=ya(t,`chart`,19,()=>({}));var r=kM();let i;var a=M(r),o=e=>{yM(e,{get workflowID(){return n().workflowID}})};V(a,e=>{n().workflowID&&e(o)});var s=P(a,2),c=M(s);bM(c,()=>({icon:Mo,label:`Client`,variant:`workflow-node-endpoint`}));var l=P(c,4);bM(l,()=>({icon:Za,label:`Auth`,state:n().authNodeClass,sub:n().authNodeSublabel}));var u=P(l,2),d=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:Za,label:`Cache`,state:n().cacheNodeClass,badge:n().cacheStatusLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().cacheConnClass]),`svelte-nbptrg`)),z(e,t)};V(u,e=>{n().showCache&&e(d)});var f=P(u,2),p=e=>{var t=EM();bM(P(N(t),2),()=>({icon:No,label:`Budget`,state:n().budgetNodeClass,badge:n().budgetStatusLabel})),z(e,t)};V(f,e=>{n().showBudget&&e(p)});var m=P(f,2),h=e=>{var t=EM();bM(P(N(t),2),()=>({icon:To,label:`Guardrails`,sub:n().guardrailLabel})),z(e,t)};V(m,e=>{n().showGuardrails&&e(h)});var g=P(m,2),_=P(g,2);bM(_,()=>({label:n().aiLabel,variant:`workflow-node-ai`,state:n().aiNodeClass,sub:n().aiSublabel}));var v=P(_,2),y=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:oo,label:`Failover`,state:n().failoverNodeClass,badge:n().failoverStatusLabel,sub:n().failoverTargetLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().failoverConnClass]),`svelte-nbptrg`)),z(e,t)};V(v,e=>{n().showFailover&&e(y)});var b=P(v,2);bM(P(b,2),()=>({icon:Ga,label:`Response`,variant:`workflow-node-endpoint`,state:n().responseNodeClass,sub:n().responseNodeSublabel})),T(s);var x=P(s,2),S=e=>{var t=OM(),r=M(t),i=M(r),a=e=>{bM(e,()=>({icon:za,label:`Usage`,variant:`workflow-node-feature workflow-node-async`,state:n().usageNodeClass}))};V(i,e=>{n().showUsage&&e(a)});var o=P(i,2),s=e=>{z(e,DM())};V(o,e=>{n().showUsage&&n().showAudit&&e(s)});var c=P(o,2),l=e=>{bM(e,()=>({icon:Qa,label:`Audit Log`,variant:`workflow-node-feature workflow-node-async`,state:n().auditNodeClass}))};V(c,e=>{n().showAudit&&e(l)}),T(r),Ue(4),T(t),z(e,t)};V(x,e=>{n().showAsync&&e(S)}),T(r),F(()=>{i=U(r,1,`workflow-pipeline svelte-nbptrg`,null,i,{"workflow-pipeline-has-meta":n().workflowID}),U(g,1,Fi([`workflow-conn`,n().aiConnClass]),`svelte-nbptrg`),U(b,1,Fi([`workflow-conn`,n().responseConnClass]),`svelte-nbptrg`)}),z(e,r),D()}function jM(e){let t=qj(e).length;return t===0?``:t===1?`1 step`:t+` steps`}function MM(e,t){return t&&t.provider?t.provider:Yj(e&&e.scope)||`AI`}function NM(e,t){return t&&t.model?t.model:e&&e.scope&&e.scope.scope_model||null}function PM(e,t){let n=String(e&&e.id||``).trim();if(n&&n!==`draft-workflow-preview`)return n;let r=String(t&&t.workflow_version_id||``).trim();return r&&r!==`draft-workflow-preview`?r:null}function FM(e){let t=e&&e.data&&e.data.workflow_features;return!t||typeof t!=`object`||Array.isArray(t)?null:Uj(t)}function IM(e){let t=e&&e.data&&e.data.failover;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=String(t.target_model||t.targetModel||``).trim()||null;return n?{targetModel:n}:null}function LM(e,t=0){if(t>4||e==null)return``;if(typeof e==`string`){let n=e.trim();if(!n||n[0]!==`{`&&n[0]!==`[`)return``;try{return LM(JSON.parse(n),t+1)}catch{return``}}if(Array.isArray(e)){for(let n of e){let e=LM(n,t+1);if(e)return e}return``}return typeof e==`object`?String(e.code||``).trim()||(e.error===void 0?``:LM(e.error,t+1)):``}function RM(e){let t=e&&e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{};return String(t.error_code||t.errorCode||``).trim()||LM(t.response_body)}function zM(e){let t=String(e||``).trim();if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{provider:t.slice(0,n),model:t.slice(n+1)}}function BM(e,t){let n=String(e&&(e.requested_model||e.model)||``).trim(),r=IM(e);if(!(r&&r.targetModel))return{provider:String(e&&e.provider||``).trim()||null,model:n||null};let i=zM(n);if(i)return i;let a=Yj(t&&t.scope),o=a?String(t&&t.scope&&t.scope.scope_model||``).trim():``;return a||o?{provider:a||null,model:o||n||null}:{provider:null,model:n||null}}function VM(e,t){if(!e)return null;let n=(()=>{let t=String(e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`?t:null})(),r=(()=>{if(e.status_code===void 0||e.status_code===null)return null;let t=String(e.status_code).trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null})(),i=n?!0:e.cache_hit!==void 0&&e.cache_hit!==null&&!!e.cache_hit,a=IM(e),o=BM(e,t),s=Number.isFinite(r)&&r>=200&&r<300,c=String(e.error_type||``).trim().toLowerCase()===`authentication_error`,l=String(e.auth_method||``).trim().toLowerCase()||null,u=RM(e).toLowerCase()===`budget_exceeded`;return{cacheHit:i,cacheType:n||null,failoverTarget:a&&a.targetModel?a.targetModel:null,provider:o.provider,model:o.model,statusCode:r,responseSuccess:s,aiSuccess:s&&!i,authError:c,authMethod:l,budgetExceeded:u}}function HM(e){return!!(e&&e.cacheHit)}function UM(e){return!!(e&&e.failoverTarget)}function WM(e){return!!(e&&e.budgetExceeded)}function GM(e,t){return t?`workflow-node-current`:e&&e.cacheHit?`workflow-node-success`:``}function KM(e){return e&&e.cacheHit?`workflow-conn-hit`:``}function qM(e){return!e||!e.cacheHit?null:e.cacheType===`semantic`?`Hit (Semantic)`:`Hit (Exact)`}function JM(e,t,n,r){return e?WM(t)?`workflow-node-error`:r?`workflow-node-current`:n?`workflow-node-success`:``:``}function YM(e){return WM(e)?`Exceeded`:null}function XM(e){return e&&e.cacheHit?`workflow-node-skipped`:e&&e.failoverTarget?`workflow-node-success`:``}function ZM(e){return e&&e.cacheHit?`workflow-conn-dim`:e&&e.failoverTarget?`workflow-conn-hit`:``}function QM(e){return e&&e.failoverTarget?`Redirected`:null}function $M(e){return e&&e.failoverTarget?e.failoverTarget:null}function eN(e){return e&&e.cacheHit?`workflow-conn-dim`:``}function tN(e,t){return e?e.cacheHit?`workflow-node-skipped`:t?`workflow-node-current`:e.aiSuccess?`workflow-node-success`:``:``}function nN(e,t){if(!e)return``;let n=e.statusCode;return!Number.isFinite(n)&&t?`workflow-node-current`:Number.isFinite(n)?n>=500?`workflow-node-error`:n>=400?`workflow-node-warning`:n>=300?`workflow-node-neutral`:n>=200?`workflow-node-success`:``:``}function rN(e){return!e||!Number.isFinite(e.statusCode)?null:String(e.statusCode)}function iN(e,t){return e?e.authError?`workflow-node-error`:t?`workflow-node-current`:e.authMethod===`api_key`||e.authMethod===`master_key`?`workflow-node-success`:``:``}function aN(e){return!e||!e.authMethod?null:e.authMethod}function oN(e,t,n){return e?n?`workflow-node-current`:t?`workflow-node-success`:``:``}function sN(e,t){if(!e||!e._live)return!!t;let n=String(e._live_state||``).trim();return!!e._audit_flushed||n===`audit.flushed`||n===`audit.detail`}function cN(e,t){if(!e)return!!t;let n=e.usage||{},r=Number(n.entries||0)>0;if(!e._live)return r;let i=String(e._usage_live_state||``).trim();return e._usage_flushed||i===`usage.flushed`?!0:!e._usage_live_pending&&r&&!e._live_pending}function lN(e){return!!(e&&e._live&&e._usage_live_pending&&!e._usage_flushed)}function uN(e,t){return!e||!e._live||sN(e,!1)?!1:String(e._live_state||``).trim()===`audit.completed`||!!(t&&Number.isFinite(t.statusCode))}function dN(e,t,n){return!e||!e._live?``:lN(e)?`usage`:uN(e,t)?`audit`:sN(e,!1)&&!e._live_pending?``:t&&t.cacheHit?`cache`:t&&(t.provider||t.model)?`ai`:n&&n.budget&&(e.workflow_version_id||e.requested_model)?`budget`:t&&t.authMethod?``:`auth`}function fN(e,t,n,r){let i=n||{},a=i.features&&typeof i.features==`object`&&!Array.isArray(i.features)?Uj(i.features):Gj(e,r),o=!!i.forceAudit,s=!!i.highlightAsyncPresent,c=!!a.budget||WM(t),l=!!a.guardrails,u=!!a.usage,d=o||!!a.audit,f=!!i.forceAsync||!!(u||d),p=!!a.failover||UM(t),m=PM(e,i.entry),h=dN(i.entry,t,a),g=lN(i.entry),_=uN(i.entry,t),v=sN(i.entry,s),y=cN(i.entry,s);return{showBudget:c,budgetNodeClass:JM(c,t,s,h===`budget`),budgetStatusLabel:YM(t),showGuardrails:l,guardrailLabel:l?jM(e):``,showCache:!!i.forceCache||!!a.cache||HM(t),cacheNodeClass:GM(t,h===`cache`),cacheConnClass:KM(t),cacheStatusLabel:qM(t),showFailover:p,failoverNodeClass:p?XM(t):``,failoverConnClass:p?ZM(t):``,failoverStatusLabel:p?QM(t):null,failoverTargetLabel:p?$M(t):null,aiLabel:MM(e,t),aiSublabel:NM(e,t),aiConnClass:eN(t),aiNodeClass:tN(t,h===`ai`),responseConnClass:eN(t),responseNodeClass:nN(t,h===`response`),responseNodeSublabel:rN(t),authNodeClass:iN(t,h===`auth`),authNodeSublabel:aN(t),usageNodeClass:oN(u,y,g),auditNodeClass:oN(d,v,_),showAsync:f,showUsage:u,showAudit:d,workflowID:m}}function pN(e,t){return fN(e,null,{forceCache:!1},t)}function mN(e,t,n){return fN(t,VM(e,t),{entry:e,features:FM(e)||(t?Gj(t,n):{cache:!1,audit:!1,usage:!1,budget:!1,guardrails:!1,failover:!1}),forceAudit:!0,forceAsync:!0,highlightAsyncPresent:!0},n)}var hN=R(`

`),gN=R(`

`),_N=R(`
`),vN=R(`
`),yN=R(`

No guardrails configured for this workflow.

`),bN=R(`

Guardrails

`),xN=R(``),SN=R(`

`);function CN(e,t){E(t,!0);let n=ya(t,`preview`,3,!1),r=O(()=>hM.featureCaps()),i=O(()=>tM(t.workflow)),a=O(()=>Jj(t.workflow,I(r))),o=O(()=>pN(t.workflow,I(r))),s=O(()=>n()?`draft-workflow-preview-guardrail-`:t.workflow.id+`-guardrail-`);var c=SN();let l;var u=M(c),d=M(u),f=M(d),p=M(f,!0);T(f);var m=P(f,2),h=M(m,!0);T(m),T(d);var g=P(d,2),_=M(g),v=M(_,!0);T(_),T(g),T(u);var y=P(u,2),b=e=>{var n=hN(),r=M(n,!0);T(n),F(()=>B(r,t.workflow.description)),z(e,n)};V(y,e=>{t.workflow.description&&e(b)});var x=P(y,2),S=e=>{var n=gN(),i=M(n);T(n),F(e=>B(i,`Failover: ${e??``}`),[()=>Kj(t.workflow,I(r))]),z(e,n)},C=O(()=>hM.failoverVisible());V(x,e=>{I(C)&&e(S)});var w=P(x,2);AM(w,{get chart(){return I(o)}});var ee=P(w,2),te=e=>{var t=bN(),n=M(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var o=P(n,2),c=e=>{var t=vN();H(t,23,()=>I(a),(e,t)=>I(s)+t,(e,t)=>{var n=_N(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a);T(a),T(n),F(()=>{B(i,I(t).ref),B(o,`step ${I(t).step??``}`)}),z(e,n)}),T(t),z(e,t)},l=e=>{z(e,yN())};V(o,e=>{I(a).length>0?e(c):e(l,-1)}),T(t),F(()=>B(i,I(a).length?I(a).length+` steps`:`None`)),z(e,t)},ne=O(()=>Ss.guardrailsVisible());V(ee,e=>{I(ne)&&e(te)});var re=P(ee,2),ie=e=>{var n=xN(),r=M(n),a=M(r),o=M(a,!0);T(a);var s=P(a,2);{let e=O(()=>`Edit workflow `+I(i));gT(s,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>hM.openCreate(t.workflow),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(r);var c=P(r,2),l=M(c),u=M(l);T(l);var d=P(l,2),f=M(d);T(d);var p=P(d,2),m=M(p);T(p),T(c),T(n),F((e,n,r,s)=>{a.disabled=e,W(a,`aria-label`,`Deactivate workflow `+I(i)),W(a,`title`,n),B(o,hM.deactivatingID===t.workflow.id?`Deactivating...`:`Deactivate`),B(u,`version: v${t.workflow.version??``}`),B(f,`created: ${r??``}`),B(m,`hash: ${s??``}`)},[()=>hM.deactivatingID===t.workflow.id||!lM(t.workflow),()=>lM(t.workflow)?`Deactivate active workflow`:`The global workflow cannot be deactivated.`,()=>ds.formatTimestamp(t.workflow.created_at),()=>uM(t.workflow.workflow_hash)]),L(`click`,a,()=>hM.deactivate(t.workflow)),z(e,n)};V(re,e=>{n()||e(ie)}),T(c),F((e,t)=>{l=U(c,1,`workflow-card svelte-1fo9fvq`,null,l,{"workflow-preview-card":n()}),B(p,e),B(h,I(i)),B(v,t)},[()=>$j(t.workflow),()=>eM(t.workflow)]),z(e,c),D()}Hr([`click`]);var wN=R(`

`),TN=R(``),EN=R(``),DN=R(``),ON=R(``),kN=R(``),AN=R(``),jN=R(``),MN=R(``),NN=R(``),PN=R(``),FN=R(``),IN=R(``),LN=R(`
No named guardrails are currently registered on this deployment. You can still draft a workflow, but guardrail-backed creation may be rejected.
`),RN=R(`
`),zN=R(`
`),BN=R(`

No guardrail steps configured yet.

`),VN=R(`

Guardrail Steps

Guardrails in the same numeric step run together. Later steps wait for earlier ones to finish.

`),HN=R(`

Leave provider name empty to target all providers and models. Select a provider name without a model to target all models for that configured provider.

Add a path to scope the workflow to that subtree. Leading slashes are optional and will be normalized; you can enter "team/alpha" or "/team/alpha". Matching checks the deepest user path first, then falls back toward the root.

If you leave the name empty, the workflow will display as the matched provider/model scope or “All models”.

Preview

Live
`,1);function UN(e,t){E(t,!0);{let t=e=>{qS(e,{copyId:`workflow-help-copy`,label:`workflow help`,text:`Create immutable version. Submitting activates it for the selected scope.`,title:e=>{var t=wN(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>hM.submitMode()===`save`?`Edit Workflow`:`Create Workflow`]),z(e,t)},$$slots:{title:!0}})},n=O(()=>hM.submitLabel()),r=O(()=>hM.submittingLabel()),i=O(()=>hM.submitMode()===`create`?po:_o);bE(e,{get open(){return hM.formOpen},ariaLabel:`Workflow editor`,get error(){return hM.formError},get submitting(){return hM.submitting},get submitLabel(){return I(n)},get submittingLabel(){return I(r)},get submitIcon(){return I(i)},dialogClass:`workflow-editor`,onclose:()=>hM.closeForm(),onsubmit:()=>hM.submitForm(),header:t,children:(e,t)=>{var n=HN(),r=N(n),i=M(r);SE(i,{id:`workflow-scope-provider`,label:`Provider Name`,children:(e,t)=>{var n=EN(),r=M(n);r.value=r.__value=``,H(P(r),16,()=>hM.providerOptions(),e=>e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(n),L(`change`,n,e=>hM.setProvider(e.currentTarget.value)),Gi(n,()=>hM.form.scope_provider,e=>hM.form.scope_provider=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2),o=e=>{SE(e,{id:`workflow-scope-model`,label:`Model`,children:(e,t)=>{var n=DN(),r=M(n);r.value=r.__value=``,H(P(r),17,()=>hM.modelOptions(hM.form.scope_provider),e=>hM.form.scope_provider+`-`+e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t)),i!==(i=I(t))&&(n.value=(n.__value=I(t))??``)}),z(e,n)}),T(n),Gi(n,()=>hM.form.scope_model,e=>hM.form.scope_model=e),z(e,n)},$$slots:{default:!0}})};V(a,e=>{hM.form.scope_provider&&e(o)});var s=P(a,2);SE(s,{id:`workflow-name`,label:`Name`,children:(e,t)=>{var n=ON();na(n),da(n,()=>hM.form.name,e=>hM.form.name=e),z(e,n)},$$slots:{default:!0}}),SE(P(s,2),{id:`workflow-user-path`,label:`User Path`,children:(e,t)=>{var n=kN();na(n),da(n,()=>hM.form.scope_user_path,e=>hM.form.scope_user_path=e),z(e,n)},$$slots:{default:!0}}),T(r);var c=P(r,8);SE(c,{id:`workflow-description`,label:`Description`,children:(e,t)=>{var n=AN();ft(n),da(n,()=>hM.form.description,e=>hM.form.description=e),z(e,n)},$$slots:{default:!0}});var l=P(c,2),u=M(l),d=e=>{var t=jN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.cache,e=>hM.form.features.cache=e),z(e,t)},f=O(()=>Ss.cacheVisible());V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var t=MN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.audit,e=>hM.form.features.audit=e),z(e,t)},h=O(()=>Ss.auditVisible());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=e=>{var t=NN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.usage,e=>hM.form.features.usage=e),z(e,t)},v=O(()=>Ss.usageVisible());V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=PN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.budget,e=>hM.form.features.budget=e),z(e,t)},x=O(()=>Ss.budgetsVisible());V(y,e=>{I(x)&&e(b)});var S=P(y,2),C=e=>{var t=FN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.guardrails,e=>hM.form.features.guardrails=e),z(e,t)},w=O(()=>Ss.guardrailsVisible());V(S,e=>{I(w)&&e(C)});var ee=P(S,2),te=e=>{var t=IN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.failover,e=>hM.form.features.failover=e),z(e,t)},ne=O(()=>hM.failoverVisible());V(ee,e=>{I(ne)&&e(te)}),T(l);var re=P(l,2),ie=P(M(re),2);{let e=O(()=>hM.preview());CN(ie,{get workflow(){return I(e)},preview:!0})}T(re);var ae=P(re,2),oe=e=>{var t=VN(),n=M(t),r=P(M(n),2);T(n);var i=P(n,2),a=e=>{var t=LN(),n=P(M(t),2);T(t),L(`click`,n,()=>Jo.navigate(`guardrails`)),z(e,t)};V(i,e=>{hM.guardrailRefs.length===0&&e(a)});var o=P(i,2),s=e=>{var t=zN();H(t,21,()=>hM.form.guardrails,oi,(e,t,n)=>{var r=RN(),i=M(r),a=M(i);W(a,`for`,`workflow-guardrail-ref-`+n);var o=P(a,2);na(o),W(o,`id`,`workflow-guardrail-ref-`+n),W(o,`aria-label`,`Guardrail reference `+(n+1)),T(i);var s=P(i,2),c=M(s);W(c,`for`,`workflow-guardrail-step-`+n);var l=P(c,2);na(l),W(l,`id`,`workflow-guardrail-step-`+n),W(l,`aria-label`,`Guardrail step `+(n+1)),T(s);var u=P(s,2);T(r),da(o,()=>I(t).ref,e=>I(t).ref=e),da(l,()=>I(t).step,e=>I(t).step=e),L(`click`,u,()=>hM.removeGuardrailStep(n)),z(e,r)}),T(t),z(e,t)},c=e=>{z(e,BN())};V(o,e=>{hM.form.guardrails.length>0?e(s):e(c,-1)}),T(t),L(`click`,r,()=>hM.addGuardrailStep()),z(e,t)},se=O(()=>hM.form.features.guardrails&&Ss.guardrailsVisible());V(ae,e=>{I(se)&&e(oe)}),z(e,n)},$$slots:{header:!0,default:!0}})}D()}Hr([`change`,`click`]);var WN=R(`

Loading workflows...

`),GN=R(`
`),KN=R(`

No active workflows found.

`),qN=R(`

No workflows match your filter.

`),JN=R(`
`);function YN(e,t){E(t,!0);var n=JN(),r=M(n),i=e=>{var t=WN();SS(M(t),{size:16,label:`Loading workflows`}),Ue(),T(t),z(e,t)};V(r,e=>{hM.loading&&!K.authError&&e(i)});var a=P(r,2),o=e=>{var t=GN();H(t,21,()=>hM.filteredWorkflows,e=>e.id,(e,t)=>{CN(e,{get workflow(){return I(t)}})}),T(t),z(e,t)};V(a,e=>{hM.filteredWorkflows.length>0&&e(o)});var s=P(a,2),c=e=>{z(e,KN())};V(s,e=>{hM.workflows.length===0&&!hM.loading&&!K.authError&&hM.available&&e(c)});var l=P(s,2),u=e=>{z(e,qN())};V(l,e=>{hM.workflows.length>0&&hM.filteredWorkflows.length===0&&!hM.loading&&e(u)}),T(n),z(e,n),D()}var XN=R(``),ZN=R(`
Workflows feature is unavailable.
`),QN=R(`
`),$N=R(`
`),eP=R(``),tP=R(`
`);function nP(e,t){E(t,!0),An(()=>{K.refreshTick,hM.fetchPage()});var n=tP(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=XN();G(M(t),{get icon(){return po},class:`form-action-icon`,"aria-hidden":`true`}),Ue(2),T(t),L(`click`,t,()=>hM.openCreate()),z(e,t)};V(a,e=>{hM.available&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,ZN())};V(s,e=>{!hM.available&&!K.authError&&e(c)});var l=P(s,2),u=e=>{var t=QN(),n=M(t,!0);T(t),F(()=>B(n,hM.error)),z(e,t)};V(l,e=>{hM.error&&!K.authError&&e(u)});var d=P(l,2),f=e=>{var t=$N(),n=M(t);yw(M(n),{placeholder:`Filter by scope, name, hash, or guardrail...`,label:`Filter workflows by scope, name, hash, or guardrail`,get value(){return hM.filter},set value(e){hM.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i,!0);T(i),T(r),T(t),F(()=>B(a,hM.filteredWorkflows.length+` active scopes`)),z(e,t)};V(d,e=>{hM.available&&e(f)});var p=P(d,2);UN(p,{});var m=P(p,2);YN(m,{});var h=P(m,2);H(h,20,()=>hM.guardrailRefs,e=>e,(e,t)=>{var n=eP(),r={};F(()=>{r!==(r=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(h),T(n),z(e,n),D()}Hr([`click`]);function rP(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=Xs}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=iP(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function iP(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}var aP=null;function oP(){return aP===null&&(aP=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`)),!!(aP&&aP.matches)}function sP(e){return oP()?0:e}function cP(e,t){return!t||!t.live?{duration:0}:Js(e,{duration:sP(150)})}var lP=new class{#e=k(j({}));get workflowVersionsByID(){return I(this.#e)}set workflowVersionsByID(e){A(this.#e,e,!0)}workflowVersionRequests={};workflowFeatureCaps(){return{cache:Ss.cacheVisible(),audit:Ss.auditVisible(),usage:Ss.usageVisible(),budget:Ss.budgetsVisible(),guardrails:Ss.guardrailsVisible(),failover:Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}}cacheWorkflowVersion(e){let t=String(e&&e.id||``).trim();return t?(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:e},e):null}cacheMissingWorkflowVersion(e){let t=String(e||``).trim();t&&(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:null})}workflowVersionCacheHas(e){return Object.prototype.hasOwnProperty.call(this.workflowVersionsByID||{},String(e||``).trim())}workflowVersionByID(e){let t=String(e||``).trim();return t&&this.workflowVersionCacheHas(t)?this.workflowVersionsByID[t]:null}async fetchWorkflowVersion(e){let t=String(e||``).trim();if(!t)return null;if(this.workflowVersionCacheHas(t))return this.workflowVersionsByID[t];if(this.workflowVersionRequests[t])return this.workflowVersionRequests[t];let n=(async()=>{let e=typeof AbortController==`function`?new AbortController:null,n=e?setTimeout(()=>e.abort(),1e4):null;try{let n=await _s(`/admin/workflows/`+encodeURIComponent(t),{label:`workflow`,signal:e?e.signal:void 0});if(n.stale)return null;if(n.status===404)return this.cacheMissingWorkflowVersion(t),null;if(!n.ok)return null;let r=n.data;return!r||typeof r!=`object`||Array.isArray(r)?(this.cacheMissingWorkflowVersion(t),null):this.cacheWorkflowVersion(r)}catch(e){return e&&e.name===`AbortError`||console.error(`Failed to fetch workflow version:`,e),null}finally{n!==null&&clearTimeout(n),delete this.workflowVersionRequests[t]}})();return this.workflowVersionRequests[t]=n,n}async prefetchAuditWorkflows(e){let t=[...new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.workflow_version_id||``).trim()).filter(Boolean))];t.length!==0&&await Promise.all(t.map(e=>this.fetchWorkflowVersion(e)))}auditEntryWorkflow(e){let t=String(e&&e.workflow_version_id||``).trim();return t?this.workflowVersionByID(t):null}},uP=6;function dP(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}function fP(e,t=0,n=null){let r=String(e||``).trim();if(!r)return``;if(t>uP)return r;let i=dP(r);return i==null?r:pP(i,t+1,n)||n&&n(i)||r}function pP(e,t=0,n=null,r=null){if(e==null||t>uP)return``;if(typeof e==`string`){let i=dP(e.trim());return i==null?``:pP(i,t+1,n,r)}if(typeof e!=`object`)return``;let i=r||new Set;if(i.has(e))return``;if(i.add(e),Array.isArray(e)){for(let r=0;r=400||gP(t&&t.response_body)}function vP(e){let t=e&&e.data?e.data:null;return t?mP(t.error_message)||(_P(e,t)?pP(t.response_body,0):``):``}function yP(e){if(e==null||String(e).trim()===``)return null;let t=Number(e);return!Number.isInteger(t)||t<0?null:t}function bP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained indefinitely.`:t===1?`Audit logs are retained for 1 day.`:`Audit logs are retained for `+t+` days.`}function xP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained `:`Audit logs are retained for `}function SP(e){let t=yP(e);return t===null?``:t===0?`indefinitely`:t===1?`1 day`:t+` days`}function CP({dateQuery:e,limit:t,offset:n,search:r,method:i,statusCode:a,stream:o}){let s=e;return s+=`&limit=`+t+`&offset=`+n,r&&(s+=`&search=`+encodeURIComponent(r)),i&&(s+=`&method=`+encodeURIComponent(i)),a&&(s+=`&status_code=`+encodeURIComponent(a)),o&&(s+=`&stream=`+encodeURIComponent(o)),s}function wP({sessionId:e,limit:t}){return`session_id=`+encodeURIComponent(e)+`&limit=`+(t||100)+`&offset=0`}function TP(e){return String(e&&e.session_id||``).trim()}function EP(e){let t=Number(e&&e.session_count);return Number.isFinite(t)&&t>1?t:1}function DP(e){return!!TP(e)&&EP(e)>1}function OP(e){return{entries:(Array.isArray(e&&e.sessions)?e.sessions:[]).filter(e=>e&&e.latest).map(e=>({...e.latest,session_id:TP(e.latest)||String(e.session_id||``).trim(),session_count:Number(e.count||1)})),total:Number(e&&e.total||0),limit:Number(e&&e.limit||25),offset:Number(e&&e.offset||0)}}function kP(e,t,n){let r=new Set((Array.isArray(n)?n:[]).flatMap(e=>NP(e))),i=(Array.isArray(t)?t:[]).filter(e=>!NP(e).some(e=>r.has(e))),a=new Set([...r,...i.flatMap(e=>NP(e))]),o=(e&&Array.isArray(e.entries)?e.entries:[]).filter(e=>e&&e._live&&!NP(e).some(e=>a.has(e)));return{entries:[...o,...i],preservedCount:o.length}}function AP(e,t){let n=e||{};if(!t)return n;if(n[t]){let e={...n};return delete e[t],e}return{...n,[t]:!0}}function jP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>TP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=n[e];return}a=!0}),a?i:n}function MP(e){return String(e&&e.id||``).trim()}function NP(e){if(!e)return[];let t=[],n=String(e.id||``).trim(),r=String(e.request_id||``).trim();return n&&t.push(`id:`+n),r&&t.push(`request:`+r),t}function PP(e){return!!(e&&e._live&&e._live_pending&&!e._audit_flushed)}function FP(e){let t=e&&e.customStartDate,n=e&&e.customEndDate;if(!t&&!n)return!0;let r=new Date;if(t){let e=new Date(t);if(e.setHours(0,0,0,0),Number.isFinite(e.getTime())&&re)return!1}return!0}function IP(e,t){return e&&Number(e.offset||0)===0&&!(t&&t.search)&&!(t&&t.method)&&!(t&&t.statusCode)&&!(t&&t.stream)&&FP(t)}function LP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=[];return a.forEach(e=>{let t=NP(e);t.length!==0&&(t.some(e=>o.has(e))||(t.forEach(e=>o.add(e)),s.push(e)))}),s.length===0?r:(r.entries=[...s,...i].slice(0,r.limit||25),r.total=Number(r.total||0)+s.length,r)}function RP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=new Map;i.forEach((e,t)=>{let n=TP(e);n&&!s.has(n)&&s.set(n,t)});let c=[],l=i;return a.forEach(e=>{let t=NP(e);if(t.length===0||t.some(e=>o.has(e)))return;let n=TP(e);if(n&&s.has(n)){let r=s.get(n);l===i&&(l=[...i]),l[r]={...e,session_count:Math.max(EP(l[r]),EP(e))},t.forEach(e=>o.add(e));return}t.forEach(e=>o.add(e)),c.push(e)}),r.entries=[...c,...l].slice(0,r.limit||25),r.total=Number(r.total||0)+c.length,r}function zP(e,t){let n=MP(t),r=e||{};return n?r[n]?{}:{[n]:!0}:r}function BP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>MP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=!0;return}a=!0}),a?i:n}function VP(e){if(e==null)return`-`;let t=Number(e);return Number.isFinite(t)?t<=0?`pending`:t<1e6?Math.round(t/1e3)+` µs`:t<1e9?(t/1e6).toFixed(2)+` ms`:(t/1e9).toFixed(2)+` s`:`-`}function HP(e){if(e==null||e===``)return`status-unknown`;let t=Number(e);return Number.isFinite(t)?t>=500?`status-error`:t>=400?`status-warning`:t>=300?`status-neutral`:`status-success`:`status-unknown`}function UP(e){if(!e||!e._live||!e._live_pending)return!1;let t=String(e._live_state||``).trim();if(t===`audit.completed`||t===`audit.flushed`||t===`audit.detail`)return!1;if(e._response_partial)return!0;if(e.status_code!==null&&e.status_code!==void 0&&e.status_code!==``||Number(e.duration_ns||0)>0||e.error_type||e.error_message)return!1;let n=e.data||{};return!(n.response_headers||n.response_body||n.error_message)}function WP(e){let t=e&&e.data&&e.data.failover;return!t||typeof t!=`object`||Array.isArray(t)?null:String(t.target_model||t.targetModel||``).trim()||null}function GP(e){return(e&&e.data&&Array.isArray(e.data.attempts)?e.data.attempts:[]).map((e,t)=>({...e,seq:Number(e&&e.seq||t+1)})).sort((e,t)=>e.seq-t.seq)}function KP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))}function qP(e){if(!e)return`-`;let t=e.status_code||e.status;return t?String(t):e.success?`ok`:`error`}function JP(e){return String(e&&e.kind||``).trim()||`attempt`}function YP(e){if(!e)return`-`;let t=String(e.provider_name||``).trim(),n=String(e.provider_type||e.provider||``).trim();return t&&n&&t!==n?t+` (`+n+`)`:t||n||`-`}function XP(e){return String(e&&e.model||``).trim()||`-`}function ZP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))?t:[]}function QP(e){return GP(e).length+`×`}function $P(e){let t=GP(e),n=t.filter(e=>!(e&&e.success)).length,r=t.length===1?`attempt`:`attempts`,i=t.length+` provider `+r;return n>0?i+` · `+n+` failed`:i}function eF(e){if(!e)return``;let t=[`#`+Number(e.seq||0)],n=JP(e);n&&n!==`attempt`&&t.push(n),t.push(qP(e));let r=YP(e);r&&r!==`-`&&t.push(r);let i=XP(e);return i&&i!==`-`&&t.push(i),t.push(e.success?`succeeded`:`failed`),t.join(` · `)}function tF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t&&t.response_body!=null?t.response_body:null}return t.response_body!=null&&t.response_body!==``?t.response_body:null}function nF(e){if(!e||e.success)return``;let t=String(e.error_message||``).trim(),n=String(e.error_code||``).trim(),r=String(e.error_type||``).trim();return t&&n?n+`: `+t:t||n||r||`Provider attempt failed`}function rF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t?t.response_headers:null}return t.response_headers||null}function iF(e){let t=Number(e&&e.status_code);return Number.isFinite(t)&&t>0?t:null}function aF(e,t){let n=!!(t&&t.success),r=e&&e.data?e.data:null,i=tF(e,t),a=rF(e,t),o=nF(t),s=i!=null&&i!==``,c=JP(t),l=GP(e).length<=1;return{title:`Response`,direction:`response`,seq:l?0:Number(t&&t.seq||0),kind:l||c===`attempt`?``:c,statusCode:l?null:iF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:i,showErrorMessage:!!o,errorMessage:o,showHeaders:!!a,headers:a,showBody:s,body:i,showEmpty:!o&&!s&&!a,emptyMessage:`No response was captured for this attempt.`,showTooLarge:!!(n&&r&&r.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function oF(e){return e&&e.data&&Array.isArray(e.data.request_revisions)?e.data.request_revisions:[]}function sF(e){return oF(e).filter(e=>!(e&&e.no_change))}function cF(e){return oF(e).filter(e=>e&&e.no_change).map(e=>{let t=String(e.rewriter||`rewriter`);return{id:`step-`+Number(e.seq||0),rewriter:t,label:t+`: no change`,title:t+` ran and forwarded the request unchanged`}})}function lF(e){let t=Number(e&&e.bytes_before),n=Number(e&&e.bytes_after);if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n>=t)return``;let r=(1-n/t)*100;return`-`+(r>=10?String(Math.round(r)):r.toFixed(1))+`%`}function uF(e,t){let n=t&&t.body,r=n!=null&&n!==``,i=sF(e).length<=1,a={rewriter:t&&t.rewriter||``,bytes:Number(t&&t.bytes_before||0)+` → `+Number(t&&t.bytes_after||0)};return t&&t.detail!=null&&(a.detail=t.detail),{title:`Rewritten`,direction:`request`,seq:i?0:Number(t&&t.seq||0),kind:t&&t.rewriter?String(t.rewriter):``,savingsLabel:lF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:n,showErrorMessage:!1,errorMessage:null,showHeaders:!0,headers:a,headersTitle:`What changed`,showBody:r,body:n,showEmpty:!1,emptyMessage:``,showTooLarge:!r,tooLargeMessage:`Rewritten body not captured (body logging disabled or body too large).`}}function dF(e){let t=e&&e.usage;return!t||typeof t!=`object`?null:t}function fF(e){let t=dF(e);return Number(t&&t.cached_input_tokens||0)>0}function pF(e){let t=dF(e),n=Number(t&&t.input_tokens||0),r=Number(t&&t.cached_input_tokens||0);return!Number.isFinite(n)||n<=0||!Number.isFinite(r)||r<=0?0:Math.max(0,Math.min(100,r/n*100))}function mF(e){let t=dF(e);if(!t)return``;let n=Number(t.input_tokens||0),r=Number(t.cached_input_tokens||0);return n<=0?oc(r)+` cached`:pF(e).toFixed(1)+`% cached`}function hF(e){return fF(e)?mF(e):``}function gF(e,t){let n=dF(e);if(!n||!e||!e.data||!e.data.request_body)return null;let r=Number(n.estimated_cached_characters||0);if(!Number.isFinite(r)||r<=0||typeof t!=`function`)return null;let i=t(e.data.request_body);return!Array.isArray(i)||i.length===0?null:{characters:r,segments:i}}function _F(e,t){let n=e&&e.data?e.data:null,r=!n||!n.request_headers&&!n.request_body,i=r&&UP(e);return{title:`Request`,direction:`request`,layout:`split`,entry:e,copyHeaders:n&&n.request_headers,copyBody:n&&n.request_body,showErrorMessage:!1,errorMessage:null,showHeaders:!!(n&&n.request_headers),headers:n&&n.request_headers,showBody:!!(n&&n.request_body),body:n&&n.request_body,bodyCacheRatioLabel:hF(e),promptCacheHighlight:gF(e,t),noChangeSteps:cF(e),showEmpty:r&&!i,emptyMessage:`Request details were not captured.`,showPending:i,pendingMessage:`Waiting for request data…`,showTooLarge:!!(n&&n.request_body_too_big_to_handle),tooLargeMessage:`Request body was too large to capture.`}}function vF(e){let t=e&&e.data?e.data:null,n=vP(e),r=!t||!n&&!t.response_headers&&!t.response_body,i=r&&UP(e);return{title:`Response`,direction:`response`,layout:`split`,entry:e,copyHeaders:t&&t.response_headers,copyBody:t&&t.response_body,showErrorMessage:!!n,errorMessage:n,showHeaders:!!(t&&t.response_headers),headers:t&&t.response_headers,showBody:!!(t&&t.response_body),body:t&&t.response_body,streaming:!!(e&&e._response_partial&&t&&t.response_body)&&UP(e),showEmpty:r&&!i,emptyMessage:`Response details were not captured.`,showPending:i,pendingMessage:`Response in progress…`,showTooLarge:!!(t&&t.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function yF(e,t){let n=[{id:`request`,pane:_F(e,t)}];return sF(e).forEach(t=>{n.push({id:`revision-`+Number(t&&t.seq||0),pane:uF(e,t)})}),KP(e)?GP(e).forEach(t=>{n.push({id:`response-`+Number(t&&t.seq||0),pane:aF(e,t)})}):n.push({id:`response`,pane:vF(e)}),n}function bF(e){if(!KP(e))return`response`;let t=GP(e),n=null;return t.forEach(e=>{e&&e.success&&(n=e)}),n||=t[t.length-1],n?`response-`+Number(n.seq||0):`request`}function xF(e,t,n){return e&&(Array.isArray(n)?n:yF(t)).some(t=>t.id===e)?e:bF(t)}function SF(e,t,n){if(!t||!t.length)return null;let r=t.indexOf(n);r<0&&(r=0);let i;switch(e){case`ArrowRight`:case`ArrowDown`:i=(r+1)%t.length;break;case`ArrowLeft`:case`ArrowUp`:i=(r-1+t.length)%t.length;break;case`Home`:i=0;break;case`End`:i=t.length-1;break;default:return null}return t[i]}var CF=100;function wF(){return{entries:[],total:0,limit:25,offset:0}}var TF=new class{#e=k(j({}));get auditExpandedEntries(){return I(this.#e)}set auditExpandedEntries(e){A(this.#e,e,!0)}#t=k(j({}));get auditExpandedThreads(){return I(this.#t)}set auditExpandedThreads(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}auditFetchToken=0;get auditLog(){return MC.auditLog}set auditLog(e){MC.auditLog=e}get auditSearch(){return MC.auditSearch}set auditSearch(e){MC.auditSearch=e}get auditMethod(){return MC.auditMethod}set auditMethod(e){MC.auditMethod=e}get auditStatusCode(){return MC.auditStatusCode}set auditStatusCode(e){MC.auditStatusCode=e}get auditStream(){return MC.auditStream}set auditStream(e){MC.auditStream=e}get auditGroupSessions(){return MC.auditGroupSessions}liveFilters(){return{search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream,customStartDate:Mc.customStartDate,customEndDate:Mc.customEndDate}}toggleAuditGroupSessions(){MC.auditGroupSessions=!MC.auditGroupSessions,Ea(`gomodel_audit_group_sessions`,MC.auditGroupSessions),this.auditExpandedThreads={},MC.auditThreadChildren={},this.fetchAuditLog(!0)}async fetchAuditLog(e){let t=++this.auditFetchToken;this.loading=!0;try{e&&(this.auditLog.offset=0);let n=this.auditGroupSessions,r=CP({dateQuery:Mc.queryStr(),limit:this.auditLog.limit,offset:this.auditLog.offset,search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream}),i=await _s((n?`/admin/audit/sessions?`:`/admin/audit/log?`)+r,{label:`audit log`});if(i.stale||t!==this.auditFetchToken)return;if(!i.ok){this.auditLog=wF();return}let a=n?OP(i.data):i.data,o=(n?RP:LP)(a,this.auditLog&&this.auditLog.entries,this.liveFilters());Array.isArray(o.entries)||(o.entries=[]),o.entries=MC.upsertAuditRecords(o.entries,`audit.list`),this.auditLog=o,this.auditExpandedThreads=jP(this.auditExpandedThreads,o.entries),MC.auditThreadChildren=jP(MC.auditThreadChildren,o.entries);let s=[...o.entries,...this.loadedThreadChildren()];this.auditExpandedEntries=BP(this.auditExpandedEntries,s);try{await lP.prefetchAuditWorkflows(s)}catch(e){console.error(`Failed to prefetch audit workflows:`,e)}}catch(e){if(console.error(`Failed to fetch audit log:`,e),t!==this.auditFetchToken)return;this.auditLog=wF()}finally{t===this.auditFetchToken&&(this.loading=!1)}}loadedThreadChildren(){let e=MC.auditThreadChildren||{};return Object.keys(e).flatMap(t=>Array.isArray(e[t]&&e[t].entries)?e[t].entries:[])}isThreadExpanded(e){return!!(e&&this.auditExpandedThreads[e])}threadChildren(e){return e&&MC.auditThreadChildren[e]||null}async toggleThread(e){let t=TP(e);if(!t)return;let n=!this.isThreadExpanded(t);this.auditExpandedThreads=AP(this.auditExpandedThreads,t);let r=MC.auditThreadChildren[t];n&&!(r&&(r.loaded||r.loading))&&await this.fetchThreadEntries(e)}async fetchThreadEntries(e){let t=TP(e);if(!t)return;let n=MC.auditThreadChildren[t];MC.auditThreadChildren={...MC.auditThreadChildren,[t]:{loading:!0,loaded:!1,entries:n&&Array.isArray(n.entries)?n.entries:[],total:Number(n&&n.total||0)}};let r=()=>{let e={...MC.auditThreadChildren},n=e[t],r=n&&Array.isArray(n.entries)?n.entries:[];r.length>0?e[t]={loading:!1,loaded:!1,entries:r,total:r.length}:(delete e[t],this.auditExpandedThreads[t]&&(this.auditExpandedThreads=AP(this.auditExpandedThreads,t))),MC.auditThreadChildren=e};try{let n=await _s(`/admin/audit/log?`+wP({sessionId:t,limit:CF}),{label:`audit session`});if(n.stale){r();return}if(!n.ok)throw Error(`audit session fetch failed`);let i=MC.auditThreadChildren[t],a=this.auditLog.entries.find(e=>TP(e)===t),o=kP(i,n.data.entries,a?[a]:[e]);o.entries=MC.upsertAuditRecords(o.entries,`audit.thread`),MC.auditThreadChildren={...MC.auditThreadChildren,[t]:{loading:!1,loaded:!0,entries:o.entries,total:Number(n.data.total||0)+o.preservedCount}}}catch(e){console.error(`Failed to fetch audit session entries:`,e),r()}}clearAuditFilters(){this.auditSearch=``,this.auditMethod=``,this.auditStatusCode=``,this.auditStream=``,this.fetchAuditLog(!0)}auditLogNextPage(){this.auditLog.offset+this.auditLog.limit0&&(this.auditLog.offset=Math.max(0,this.auditLog.offset-this.auditLog.limit),this.fetchAuditLog(!1))}isAuditEntryExpanded(e){let t=MP(e);return t?!!(this.auditExpandedEntries&&this.auditExpandedEntries[t]):!1}toggleAuditEntryExpanded(e){this.auditExpandedEntries=zP(this.auditExpandedEntries,e);let t=this.isAuditEntryExpanded(e);return t&&typeof MC.fetchAuditEntryDetail==`function`&&MC.fetchAuditEntryDetail(e),t}expandAuditEntry(e){this.isAuditEntryExpanded(e)||this.toggleAuditEntryExpanded(e)}};MC.fetchAuditLog=e=>TF.fetchAuditLog(e),MC.isAuditEntryExpanded=e=>TF.isAuditEntryExpanded(e);var EF=R(`
`);function DF(e,t){E(t,!0);let n=bw(()=>TF.fetchAuditLog(!0));An(()=>n.cancel);var r=EF(),i=M(r);yw(M(i),{id:`audit-filter-search`,placeholder:`Search by request ID, model, provider, path, user path, or error...`,label:`Search by request ID, model, provider, path, user path, or error`,get oninput(){return n},get value(){return TF.auditSearch},set value(e){TF.auditSearch=e}}),T(i);var a=P(i,2),o=M(a),s=M(o);s.value=s.__value=``;var c=P(s);c.value=c.__value=`GET`;var l=P(c);l.value=l.__value=`POST`;var u=P(l);u.value=u.__value=`PUT`;var d=P(u);d.value=d.__value=`PATCH`;var f=P(d);f.value=f.__value=`DELETE`,T(o);var p=P(o,2),m=M(p);m.value=m.__value=``;var h=P(m);h.value=h.__value=`200`;var g=P(h);g.value=g.__value=`201`;var _=P(g);_.value=_.__value=`400`;var v=P(_);v.value=v.__value=`401`;var y=P(v);y.value=y.__value=`403`;var b=P(y);b.value=b.__value=`404`;var x=P(b);x.value=x.__value=`429`;var S=P(x);S.value=S.__value=`500`;var C=P(S);C.value=C.__value=`502`;var w=P(C);w.value=w.__value=`503`;var ee=P(w);ee.value=ee.__value=`504`,T(p);var te=P(p,2),ne=M(te);ne.value=ne.__value=``;var re=P(ne);re.value=re.__value=`true`;var ie=P(re);ie.value=ie.__value=`false`,T(te);var ae=P(te,2);G(M(ae),{get icon(){return Io},class:`table-icon-svg`}),Ue(2),T(ae),T(a),T(r),L(`change`,o,()=>TF.fetchAuditLog(!0)),Gi(o,()=>TF.auditMethod,e=>TF.auditMethod=e),L(`change`,p,()=>TF.fetchAuditLog(!0)),Gi(p,()=>TF.auditStatusCode,e=>TF.auditStatusCode=e),L(`change`,te,()=>TF.fetchAuditLog(!0)),Gi(te,()=>TF.auditStream,e=>TF.auditStream=e),L(`click`,ae,()=>TF.clearAuditFilters()),z(e,r),D()}Hr([`change`,`click`]);var OF=R(`Live stream connecting…`),kF=R(` `),AF=R(`Live`),jF=R(` `);function MF(e,t){E(t,!0);let n=O(()=>MC.auditLivePauseReason()),r=O(()=>MC.liveLogsStreaming&&!I(n));var i=Qr(),a=N(i),o=e=>{var t=jF(),i=M(t);let a;var o=P(i,2),s=e=>{z(e,OF())},c=e=>{var t=kF(),r=M(t,!0);T(t),F(e=>B(r,e),[()=>bC(I(n))]),z(e,t)},l=e=>{z(e,AF())};V(o,e=>{MC.liveLogsStreaming?I(n)?e(c,1):e(l,-1):e(s)}),T(t),F(()=>a=U(i,1,`live-dot svelte-tve6yv`,null,a,{"is-streaming":I(r)})),z(e,t)},s=O(()=>Ss.liveLogsVisible());V(a,e=>{I(s)&&e(o)}),z(e,i),D()}var NF=R(` `),PF=R(``);function FF(e,t){E(t,!0);let n=O(()=>[{key:`provider`,text:gc(t.entry)||`-`},{key:`model`,text:t.entry.requested_model||t.entry.model||`-`,mono:!0},{key:`user_path`,text:t.entry.user_path,mono:!0},{key:`request_id`,text:`request_id: `+(t.entry.request_id||`-`),mono:!0},{key:`ip`,text:t.entry.client_ip&&`ip: `+t.entry.client_ip,mono:!0},{key:`auth_key_id`,text:t.entry.auth_key_id&&`auth_key_id: `+t.entry.auth_key_id,mono:!0},{key:`alias`,text:t.entry.alias_used&&`alias`,class:`audit-alias-badge`},{key:`resolved`,text:t.entry.alias_used&&t.entry.resolved_model&&`resolved: `+yc(t.entry),mono:!0},{key:`failover`,text:WP(t.entry)&&`failover: `+WP(t.entry),mono:!0},{key:`stream`,text:t.entry.stream&&`stream`},{key:`error_type`,text:t.entry.error_type}].filter(e=>!!e.text));var r=PF(),i=P(M(r),2);H(i,21,()=>I(n),e=>e.key,(e,t)=>{var n=NF(),r=M(n,!0);T(n),F(()=>{U(n,1,Fi([`provider-badge`,I(t).class,{mono:I(t).mono}]),`svelte-hyopt0`),B(r,I(t).text)}),z(e,n)}),T(i),T(r),z(e,r),D()}var IF=R(``),LF=R(` `);function RF(e,t){E(t,!0);let n=O(()=>ZP(t.entry)),r=O(()=>I(n).length>0?$P(t.entry):``),i=O(()=>I(n).length>0?QP(t.entry):``);var a=Qr(),o=N(a),s=e=>{var a=LF(),o=M(a);H(o,21,()=>I(n),e=>t.entry.id+`-pip-`+e.seq,(e,t)=>{var n=IF();let r;F(e=>{r=U(n,1,`audit-attempt-pip svelte-1eu22xn`,null,r,{"audit-attempt-success":!!(I(t)&&I(t).success),"audit-attempt-error":!(I(t)&&I(t).success)}),W(n,`title`,e)},[()=>eF(I(t))]),z(e,n)}),T(o);var s=P(o,2),c=M(s,!0);T(s),T(a),F(()=>{W(a,`title`,I(r)),W(a,`aria-label`,I(r)),B(c,I(i))}),z(e,a)};V(o,e=>{I(n).length>0&&e(s)}),z(e,a),D()}var zF=new Set([`instructions`,`messages`,`input`,`previous_response_id`,`choices`,`output`]);function BF(e){if(e==null)return``;if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:!e||typeof e!=`object`?``:typeof e.text==`string`?e.text:typeof e.output_text==`string`?e.output_text:``).filter(Boolean).join(` -`).trim();if(typeof e==`object`){if(typeof e.text==`string`)return e.text.trim();try{return JSON.stringify(e,null,2)}catch{return``}}return String(e).trim()}function VF(e){if(e==null)return[];if(typeof e==`string`)return e?[e]:[];if(Array.isArray(e))return e.flatMap(e=>typeof e==`string`?e?[e]:[]:!e||typeof e!=`object`?[]:typeof e.text==`string`?e.text?[e.text]:[]:typeof e.output_text==`string`&&e.output_text?[e.output_text]:[]);if(typeof e==`object`)return typeof e.text==`string`&&e.text?[e.text]:[];let t=String(e);return t?[t]:[]}function HF(e){if(e==null)return[];if(typeof e==`string`){let t=e.trim();return t?[{role:`user`,text:t}]:[]}if(!Array.isArray(e)){let t=BF(e);return t?[{role:`user`,text:t}]:[]}return e.map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e.role||`user`).toLowerCase(),n=BF(e.content);return n?{role:t,text:n}:null}).filter(Boolean)}function UF(e){return!e||typeof e!=`object`?``:Array.isArray(e.content)?e.content.map(e=>e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` -`).trim():BF(e.content)}function WF(e){if(!e||typeof e!=`object`)return[];let t=[];return t.push(...VF(e.instructions)),Array.isArray(e.messages)&&e.messages.forEach(e=>{!e||typeof e!=`object`||t.push(...VF(e.content))}),typeof e.input==`string`?t.push(e.input):Array.isArray(e.input)?e.input.forEach(e=>{!e||typeof e!=`object`||(t.push(...VF(e.content)),typeof e.text==`string`&&t.push(e.text))}):e.input&&typeof e.input==`object`&&(t.push(...VF(e.input.content)),typeof e.input.text==`string`&&t.push(e.input.text)),t.map(e=>String(e||``)).filter(e=>e.length>0)}var GF=e=>BF(e);function KF(e){if(!e||!e.data)return``;let t=pP(e.data.response_body,0,GF);if(t)return t;let n=e.data.error_message;if(n==null)return``;if(typeof n==`string`){let e=n.trim();return e?pP(dP(e),0,GF)||e:``}return pP(n,0,GF)||BF(n)}function qF(e){return Array.isArray(e)?e.some(e=>!e||typeof e!=`object`?!1:e.type===`message`||e.role===`assistant`||e.role===`user`||e.role===`system`?!0:Array.isArray(e.content)?e.content.some(e=>!e||typeof e!=`object`?!1:typeof e.text==`string`||e.type===`output_text`||e.type===`input_text`):!1):!1}function JF(e){if(!e)return!1;let t=String(e).toLowerCase();return t===`/v1/embeddings`||t===`/v1/embeddings/`||t.startsWith(`/v1/embeddings?`)||t.startsWith(`/v1/embeddings/`)}function YF(e){return e?!!ZF(e):!1}function XF(e){let t=String(e||``).trim().split(`?`)[0].replace(/\/+$/,``).toLowerCase();return t.startsWith(`/v1/`)?t.slice(3):t}function ZF(e){switch(XF(e)){case`/chat/completions`:return`chat`;case`/responses`:return`responses`;case`/messages`:return`messages`;default:return``}}function QF(e){if(!e||typeof e!=`object`)return null;try{return JSON.parse(JSON.stringify(e))}catch{return null}}function $F(e,t){if(!t||typeof t!=`object`)return;let n=e[e.length-1];try{if(n&&JSON.stringify(n)===JSON.stringify(t))return}catch{}e.push(t)}function eI(e){let t=ZF(e&&e.path),n=e&&e.data&&e.data.request_body;return!t||!n||typeof n!=`object`?!1:t!==`responses`||(e.data&&e.data.response_body&&typeof e.data.response_body.id==`string`?e.data.response_body.id.trim():``)!==``||FI(n)!==``}function tI(e,t){let n=String(t||``).trim(),r=ZF(e&&e.path),i=QF(e&&e.data&&e.data.request_body);if(!n||!r||!i)return null;let a=e&&e.data?e.data.response_body:null;if(r===`responses`){let e=a&&typeof a.id==`string`?a.id.trim():``,t=FI(i);return!e&&!t?null:(i.input=n,e&&!t?i.previous_response_id=e:delete i.previous_response_id,i)}let o=Array.isArray(i.messages)?i.messages:[];if(r===`chat`){let e=a&&Array.isArray(a.choices)?a.choices[0]:null;e&&e.message&&$F(o,QF(e.message)),o.push({role:`user`,content:n})}else a&&a.content!==void 0&&$F(o,{role:String(a.role||`assistant`),content:QF(a.content)||a.content}),o.push({role:`user`,content:n});return i.messages=o,i}var nI=new Set(`authorization.proxy-authorization.cookie.content-type.content-length.host.accept.connection.accept-encoding.content-encoding.transfer-encoding.user-agent.date.expect.upgrade.via.te.trailer.keep-alive.origin.referer.forwarded.x-real-ip.traceparent.tracestate.x-request-id.idempotency-key.x-idempotency-key.x-gomodel-timezone.x-gomodel-interaction-parent`.split(`.`));function rI(e,t,n=``){let r=e&&e.data&&e.data.request_headers,i={};return r&&typeof r==`object`&&Object.keys(r).forEach(e=>{let t=String(e).toLowerCase(),n=String(r[e]==null?``:r[e]);!e||!n||n===`[REDACTED]`||nI.has(t)||t.startsWith(`sec-`)||t.startsWith(`cf-`)||t.startsWith(`x-forwarded-`)||(i[e]=n)}),i[`X-GoModel-Interaction-Parent`]=String(t||e&&e.id||``).trim(),String(n||``).trim()&&(i[`X-Request-ID`]=String(n).trim()),i}function iI(e,t){let n=String(t||``).trim();return!n||!Array.isArray(e)?null:e.find(e=>String(e&&e.request_id||``).trim()===n)||null}function aI(e,t,n,r,i){let a=Array.isArray(e)?e:[],o=String(i&&i.id||``).trim(),s=String(i&&i.request_id||``).trim(),c=String(i&&i.session_id||``).trim(),l=String(r||``).trim(),u=oI(i),d=a.some(e=>o&&String(e&&e.id||``).trim()===o||s&&String(e&&e.request_id||``).trim()===s),f=!!l&&s===l,p=!!n&&c===String(n).trim(),m=!!u&&(u===String(t||``).trim()||a.some(e=>String(e&&e.id||``).trim()===u)),h=d||f||!l&&(p||m);return{accepted:h,submittedChild:f,followUpRequestID:h&&f&&o?``:l}}function oI(e){let t=e&&e.data&&e.data.request_headers;if(!t||typeof t!=`object`)return``;let n=Object.keys(t).find(e=>e.toLowerCase()===`x-gomodel-interaction-parent`);return n?String(t[n]||``).trim():``}function sI(e,t){return!Array.isArray(e)||!t?null:e.find(e=>String(e&&e.id||``)===String(t))||null}function cI(e){return!Array.isArray(e)||e.length===0?null:e.reduce((e,t)=>e?II(t,e)>=0?t:e:t,null)}function lI(e,t){let n=new Set(Array.isArray(t)?t.map(String):[]);return cI((Array.isArray(e)?e:[]).filter(e=>{let t=String(e&&e.id||``);return n.has(t)&&e&&e.data&&e.data.request_body!=null}))}function uI(e,t){let n=cI(e);return!!n&&String(n.id||``)===String(t||``)}function dI(e,t,n){return String(e||``).trim()===`audit.flushed`&&String(t||``).trim()!==``&&String(t||``).trim()===String(n||``).trim()}function fI(e,t){let n=Array.isArray(e)?e.filter(Boolean).map(String):[];return(Array.isArray(t)?t:[]).forEach(e=>{let t=String(e&&(e.id||e.request_id)||``).trim();t&&!n.includes(t)&&n.push(t)}),n}function pI(e){if(e&&e.conversation_payload)return!0;let t=e&&e.data?e.data.request_body:null,n=e&&e.data?e.data.response_body:null,r=t&&(Array.isArray(t.messages)||t.input!==void 0||typeof t.instructions==`string`||typeof t.previous_response_id==`string`),i=n&&(Array.isArray(n.choices)||qF(n.output));return!!(r||i)}function mI(e){return!e||JF(e.path)?!1:YF(e.path)||pI(e)}function hI(e){let t=0,n=!1,r=!1,i=String(e||``);for(let e=0;e0&&a+1`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function yI(e){return!!(e&&typeof e==`object`&&e.__audio__===!0)}function bI(e){let t=Number(e||0);if(!Number.isFinite(t)||t<=0)return`0 B`;let n=[`B`,`KB`,`MB`,`GB`],r=0,i=t;for(;i>=1024&&r`
`+vI(t)+``+vI(SI(e[t]))+`
`);return t.length?``:``}function wI(e){let t=xI(e.content_type),n=vI(t+` · `+bI(e.bytes)),r=CI(e.meta);if(e.stored&&e.encoding===`base64`&&e.data){let i=String(e.data).replace(/[^A-Za-z0-9+/=]/g,``);return`
`+n+`
`+r+`
`}let i=e.too_large?`Audio too large to store.`:`Audio not logged. Set LOGGING_LOG_AUDIO_BODIES=true to capture playable audio.`;return`
`+n+`
`+vI(i)+`
`+r+`
`}function TI(e){try{return JSON.stringify(String(e)).slice(1,-1)}catch{return``}}function EI(e){if(!e||typeof e!=`object`)return null;let t=Number(e.characters||0);if(!Number.isFinite(t)||t<=0)return null;let n=Array.isArray(e.segments)?e.segments.map(e=>String(e||``)).filter(Boolean):[];return n.length===0?null:{remaining:Math.floor(t),segments:n,segmentIndex:0}}function DI(e,t){if(!t||t.remaining<=0||t.segmentIndex>=t.segments.length)return vI(e);let n=``,r=0,i=0;for(;t.remaining>0&&t.segmentIndex`+vI(l)+``,r=s+l.length,i=s+o.length,t.remaining-=c,c>=a.length){t.segmentIndex++;continue}break}return n?n+vI(e.slice(r)):vI(e)}function OI(e,t,n){let r=n&&typeof n.formatJSON==`function`?n.formatJSON:e=>String(e),i=n&&typeof n.canShowConversation==`function`?n.canShowConversation:()=>!1,a=EI(n&&n.promptCacheHighlight),o=r(t);if(!o||o===`Not captured`)return vI(o);if(!i(e))return o.split(` -`).map(e=>DI(e,a)).join(` -`);let s=o.split(` -`),c=[],l=0;for(;lDI(e,a)).join(` -`);c.push(``+o+``),l=r+1;continue}c.push(DI(e,a)),l++}return c.join(` -`)}function kI(e){let t=String(e||``).toLowerCase();return t===`system`||t===`developer`?{role:`system`,label:`System Prompt`,className:`role-system`}:t===`assistant`?{role:`assistant`,label:`Agent`,className:`role-assistant`}:t===`error`?{role:`error`,label:`Error`,className:`role-error`}:t===`function_call`?{role:`function_call`,label:`Function Call`,className:`role-function-call`}:t===`function_result`?{role:`function_result`,label:`Function Result`,className:`role-function-result`}:{role:`user`,label:`User`,className:`role-user`}}function AI(e,t,{timestamp:n,entryID:r,isAnchor:i,isAfterAnchor:a,index:o,toolCalls:s,functionName:c}){let l=kI(e);return{uid:r+`-`+o,entryID:r,timestamp:n,text:t,role:l.role,roleLabel:l.label,roleClass:l.className,isAnchor:i,isAfterAnchor:a,toolCalls:Array.isArray(s)&&s.length>0?s:null,functionName:c||``}}function jI(e){return Array.isArray(e)?e.map(e=>{if(!e)return null;let t=e.function||e;return{name:t.name||e.name||``,arguments:t.arguments||e.arguments||``}}).filter(Boolean):[]}function MI(e,t,n){if(t&&Array.isArray(t.messages)&&t.messages.forEach(t=>{!t||!Array.isArray(t.tool_calls)||t.tool_calls.forEach(t=>{if(!t)return;let n=t.id||``,r=(t.function||t).name||t.name||``;n&&r&&(e[n]=r)})}),t&&Array.isArray(t.input)&&t.input.forEach(t=>{if(!t||typeof t!=`object`||t.type!==`function_call`)return;let n=t.id||t.call_id||``,r=t.name||``;n&&r&&(e[n]=r)}),n&&Array.isArray(n.choices)){let t=n.choices[0];t&&t.message&&Array.isArray(t.message.tool_calls)&&t.message.tool_calls.forEach(t=>{if(!t)return;let n=t.id||``,r=(t.function||t).name||t.name||``;n&&r&&(e[n]=r)})}n&&Array.isArray(n.output)&&n.output.forEach(t=>{if(!t||t.type!==`function_call`)return;let n=t.id||t.call_id||``,r=t.name||``;n&&r&&(e[n]=r)})}function NI(e){return Array.isArray(e)?`[`+e.map(NI).join(`,`)+`]`:e&&typeof e==`object`?`{`+Object.keys(e).sort().map(t=>JSON.stringify(t)+`:`+NI(e[t])).join(`,`)+`}`:JSON.stringify(e)}function PI(e){if(!e||typeof e!=`object`)return null;let t=[];if(e.system!==void 0&&t.push({system:e.system}),e.instructions!==void 0&&t.push({instructions:e.instructions}),Array.isArray(e.messages))t.push(...e.messages);else if(Array.isArray(e.input)&&e.previous_response_id==null&&e.conversation==null)t.push(...e.input);else return null;return t.map(NI)}function FI(e){let t=e&&e.conversation;return typeof t==`string`?t.trim():t&&typeof t.id==`string`?t.id.trim():``}function II(e,t){let n=new Date(e&&e.timestamp).getTime(),r=new Date(t&&t.timestamp).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r)return n-r;let i=String(e&&e.timestamp||``).localeCompare(String(t&&t.timestamp||``));if(i!==0)return i;let a=String(e&&e.id||``),o=String(t&&t.id||``);return ao)}function LI(e,t){if(!Array.isArray(e)||e.length===0)return{messages:[],entryIDs:[]};let n=[...e].sort(II),r={};n.forEach(e=>{let t=e.data&&e.data.request_body?e.data.request_body:null,n=e.data&&e.data.response_body?e.data.response_body:null;MI(r,t,n)});let i=[],a=new Set,o=new Set,s=new Set,c=[],l=null,u=0,d=n.findIndex(e=>e.id===t),f=e=>JSON.stringify({role:e.role,text:e.text,toolCalls:e.toolCalls,functionName:e.functionName});return n.forEach((e,n)=>{let p=e.id===t,m=d>=0&&n>d,h=e.timestamp,g=e.data&&e.data.request_body?e.data.request_body:null,_=e.data&&e.data.response_body?e.data.response_body:null,v=i.length,y=(t,n,{toolCalls:r,functionName:i}={})=>AI(t,n,{timestamp:h,entryID:e.id,isAnchor:p,isAfterAnchor:m,index:++u,toolCalls:r,functionName:i});if(g&&g.system!==void 0){let e=BF(g.system);e&&i.push(y(`system`,e))}if(g&&g.instructions!==void 0){let e=BF(g.instructions);e&&i.push(y(`system`,e))}g&&Array.isArray(g.messages)&&g.messages.forEach(e=>{if(!e)return;let t=(e.role||`user`).toLowerCase();if(t===`tool`){let t=BF(e.content),n=e.name||r[e.tool_call_id]||``;t&&i.push(y(`function_result`,t,{functionName:n}));return}if(t===`assistant`){let n=BF(e.content),r=jI(e.tool_calls);(n||r.length>0)&&i.push(y(t,n,{toolCalls:r}));return}let n=BF(e.content);n&&i.push(y(t,n))}),g&&g.input!==void 0&&(Array.isArray(g.input)?g.input.forEach(e=>{if(!(!e||typeof e!=`object`)){if(e.type===`function_call_output`){let t=typeof e.output==`string`?e.output:BF(e.output);t&&i.push(y(`function_result`,t,{functionName:r[e.call_id]||``}))}else if(e.type===`function_call`)i.push(y(`function_call`,``,{toolCalls:[{name:e.name||``,arguments:e.arguments||``}]}));else if(e.role){let t=String(e.role).toLowerCase(),n=BF(e.content);n&&i.push(y(t,n))}}}):HF(g.input).forEach(e=>{e.text&&i.push(y(e.role,e.text))}));let b=i.splice(v),x=b.map(f),S=PI(g),C=S!==null,w=oI(e),ee=!!w&&a.has(w),te=String(g&&g.previous_response_id||``).trim(),ne=FI(g),re=ee||!!te&&o.has(te)||!!ne&&s.has(ne);if(m){let e=C&&l&&l.length>0&&l.every((e,t)=>S[t]===e);if(C&&!e&&!ee||!C&&!re)return}p&&C&&(l=[...S]);let ie=String(e.id||``).trim();p&&(a.clear(),o.clear(),s.clear()),ie&&(p||m)&&a.add(ie),ne&&s.add(ne);let ae=0;for(;ae0;){let t=c.slice(-e),n=x.slice(0,e);if(t.every((e,t)=>e===n[t]))break;e--}i.push(...b.slice(e)),c.push(...x.slice(e))}if(_&&Array.isArray(_.choices)){let e=_.choices[0];if(e&&e.message){let t=(e.message.role||`assistant`).toLowerCase(),n=BF(e.message.content),r=jI(e.message.tool_calls);if(n||r.length>0){let e=y(t,n,{toolCalls:r});i.push(e),c.push(f(e))}}}if(_&&Array.isArray(_.output)&&_.output.forEach(e=>{if(!e)return;if(e.type===`function_call`){let t=y(`function_call`,``,{toolCalls:[{name:e.name||``,arguments:e.arguments||``}]});i.push(t),c.push(f(t));return}let t=(e.role||`assistant`).toLowerCase(),n=UF(e);if(n){let e=y(t,n);i.push(e),c.push(f(e))}}),_&&_.content!==void 0&&!Array.isArray(_.choices)&&!Array.isArray(_.output)){let e=String(_.role||`assistant`).toLowerCase(),t=BF(_.content);if(t){let n=y(e,t);i.push(n),c.push(f(n))}}let oe=KF(e);oe&&i.push(y(`error`,oe));let se=String(_&&_.id||``).trim();se&&o.add(se)}),{messages:i,entryIDs:[...a]}}function RI(e){return e.role===`function_call`?(e.toolCalls||[]).map(function(e){let t=e.arguments||``;try{t=JSON.stringify(JSON.parse(t),null,2)}catch{}return e.name+`(`+t+`)`}).join(` - -`):e.text||``}var zI=600*1e3,BI=15*1e3,VI=250,HI=class{#e=k(!1);get conversationOpen(){return I(this.#e)}set conversationOpen(e){A(this.#e,e,!0)}#t=k(!1);get conversationLoading(){return I(this.#t)}set conversationLoading(e){A(this.#t,e,!0)}#n=k(``);get conversationError(){return I(this.#n)}set conversationError(e){A(this.#n,e,!0)}#r=k(``);get conversationAnchorID(){return I(this.#r)}set conversationAnchorID(e){A(this.#r,e,!0)}#i=k(j([]));get conversationEntryIDs(){return I(this.#i)}set conversationEntryIDs(e){A(this.#i,e,!0)}#a=k(``);get conversationSessionID(){return I(this.#a)}set conversationSessionID(e){A(this.#a,e,!0)}#o=k(!1);get conversationTruncated(){return I(this.#o)}set conversationTruncated(e){A(this.#o,e,!0)}#s=k(!1);get conversationFollowLatest(){return I(this.#s)}set conversationFollowLatest(e){A(this.#s,e,!0)}#c=k(``);get conversationOpenedFromID(){return I(this.#c)}set conversationOpenedFromID(e){A(this.#c,e,!0)}#l=k(``);get followUpText(){return I(this.#l)}set followUpText(e){A(this.#l,e,!0)}#u=k(!1);get followUpSending(){return I(this.#u)}set followUpSending(e){A(this.#u,e,!0)}#d=k(``);get followUpError(){return I(this.#d)}set followUpError(e){A(this.#d,e,!0)}followUpRequestID=``;followUpAbort=null;conversationRequestToken=0;conversationReturnFocusEl=null;bodyPointerStart=null;#f=k(null);get conversationDialogEl(){return I(this.#f)}set conversationDialogEl(e){A(this.#f,e,!0)}#p=k(null);get conversationCloseBtnEl(){return I(this.#p)}set conversationCloseBtnEl(e){A(this.#p,e,!0)}#m=k(null);get conversationThreadEl(){return I(this.#m)}set conversationThreadEl(e){A(this.#m,e,!0)}get conversationEntries(){return(this.conversationEntryIDs||[]).map(e=>MC.auditRecord(e)).filter(Boolean)}#h=O(()=>LI(this.conversationEntries,this.conversationAnchorID));get conversationView(){return I(this.#h)}set conversationView(e){A(this.#h,e)}get conversationMessages(){return this.conversationView.messages}get conversationBranchEntryIDs(){return this.conversationView.entryIDs}_setConversationEntryIDs(e){this.conversationEntryIDs=[...new Set((Array.isArray(e)?e:[]).filter(Boolean))],MC.pinAuditRecords(this.conversationEntryIDs)}canShowConversation(e){return mI(e)}startBodyInteraction(e){this.bodyPointerStart={x:e.clientX,y:e.clientY}}_isBodyDrag(e){if(!this.bodyPointerStart)return!1;let t=Math.abs(e.clientX-this.bodyPointerStart.x),n=Math.abs(e.clientY-this.bodyPointerStart.y);return t>4||n>4}_hasActiveSelection(){let e=window.getSelection?window.getSelection():null;return!e||e.isCollapsed?!1:String(e.toString()||``).trim().length>0}handleBodyConversationClick(e,t){let n=this._isBodyDrag(e);if(this.bodyPointerStart=null,n||this._hasActiveSelection()||!this.canShowConversation(t))return;let r=e.target&&e.target.closest?e.target.closest(`[data-conversation-trigger="1"]`):null;r&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,r))}handleErrorConversationClick(e,t){let n=this._isBodyDrag(e);this.bodyPointerStart=null,!n&&(this._hasActiveSelection()||this.canShowConversation(t)&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,e.currentTarget)))}formatJSON(e){return ac(e)}renderBodyWithConversationHighlights(e,t,n){return OI(e,t,{formatJSON:e=>this.formatJSON(e),canShowConversation:e=>this.canShowConversation(e),promptCacheHighlight:n&&n.promptCacheHighlight})}async openConversation(e,t){if(!e||!e.id||!this.canShowConversation(e))return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null;t instanceof HTMLElement?this.conversationReturnFocusEl=t:n&&n!==document.body&&(this.conversationReturnFocusEl=n);let r=++this.conversationRequestToken;if(this.conversationOpen=!0,this.conversationError=``,this.conversationAnchorID=e.id,this.conversationOpenedFromID=e.id,this.conversationSessionID=String(e.session_id||``).trim(),this._setConversationEntryIDs([]),this.conversationTruncated=!1,this.conversationFollowLatest=!1,this.followUpText=``,this.followUpError=``,this.followUpRequestID=``,requestAnimationFrame(()=>this._focusConversationDrawer()),this._conversationEntryLivePending(e)){this.conversationFollowLatest=!0,this.conversationLoading=!1,this._addConversationRecord(MC.upsertAuditRecord(e,`conversation.live`));return}this.conversationLoading=!0,await this.fetchConversation(e.id,r,!0,!0)}_conversationEntryLivePending(e){return typeof MC.auditEntryLiveDetailPending==`function`&&MC.auditEntryLiveDetailPending(e)}_applyConversationView(){let e=this.conversationEntries,t=LI(e,this.conversationAnchorID);if(this.conversationFollowLatest){let n=lI(e,t.entryIDs);n&&n.id&&String(n.id)!==this.conversationAnchorID&&(this.conversationAnchorID=String(n.id))}}handleAuditRecordChange(e,t){if(!this.conversationOpen||!e)return;let n=String(e.id||``).trim(),r=aI(this.conversationEntries,this.conversationAnchorID,this.conversationSessionID,this.followUpRequestID,e);if(r.accepted&&(this.followUpRequestID=r.followUpRequestID,n&&r.submittedChild&&(this.conversationAnchorID=n,this.conversationFollowLatest=!0),this._addConversationRecord(e),dI(String(t||e._live_state||``).trim(),n,this.conversationAnchorID))){this.conversationMessages.length===0&&(this.conversationLoading=!0);let e=++this.conversationRequestToken;this.fetchConversation(n,e,!1)}}_addConversationRecord(e){let t=TC(e);t&&!this.conversationEntryIDs.includes(t)&&this._setConversationEntryIDs([...this.conversationEntryIDs,t]),!this.conversationSessionID&&e.session_id&&(this.conversationSessionID=String(e.session_id).trim()),this._applyConversationView(),this.conversationFollowLatest&&this._scheduleLatestScroll()}conversationLiveWaiting(){if(!this.conversationOpen)return!1;let e=new Set(this.conversationBranchEntryIDs||[]);return(this.conversationEntries||[]).some(t=>e.has(String(t&&t.id||``))&&t._live&&(typeof MC.liveAuditStateSettled!=`function`||!MC.liveAuditStateSettled(t._live_state)))}conversationLiveStatusText(){return(this.conversationMessages||[]).length>0?`Model is responding…`:`Waiting for request data…`}closeConversation(){this.followUpAbort&&this.followUpAbort.abort(),this.conversationOpen=!1,this.conversationRequestToken++,this.conversationSessionID=``,this._setConversationEntryIDs([]),this.conversationFollowLatest=!1,this.conversationOpenedFromID=``,this.followUpRequestID=``,this.followUpSending=!1;let e=this.conversationReturnFocusEl;this.conversationReturnFocusEl=null,e&&typeof e.focus==`function`&&document.contains(e)&&requestAnimationFrame(()=>e.focus())}_focusConversationDrawer(){if(!this.conversationOpen)return;let e=this.conversationCloseBtnEl;if(e&&typeof e.focus==`function`){e.focus();return}let t=this.conversationDialogEl;t&&typeof t.focus==`function`&&t.focus()}async fetchConversation(e,t,n=!0,r=!1){try{let i=await _s(`/admin/audit/conversation?`+(`log_id=`+encodeURIComponent(e)+`&limit=120`),{label:`audit conversation`});if(t!==this.conversationRequestToken||i.stale)return;if(!i.ok){this.conversationError=`Unable to load interactions.`;return}let a=i.data||{},o=a.anchor_id||e,s=Array.isArray(a.entries)?a.entries:[],c=MC.upsertAuditRecords(s,`conversation.hydrated`),l=fI(this.conversationEntryIDs,c);l.length>this.conversationEntryIDs.length&&this._setConversationEntryIDs(l),r&&(this.conversationFollowLatest=uI(c,o)),this.conversationAnchorID=o;let u=this.conversationEntries.find(e=>e.id===this.conversationAnchorID);u&&u.session_id&&(this.conversationSessionID=String(u.session_id).trim()),this.conversationTruncated=!!a.truncated,this._applyConversationView(),this.conversationFollowLatest?this._scheduleLatestScroll():n&&this._scheduleAnchorScroll()}catch(e){if(t!==this.conversationRequestToken)return;console.error(`Failed to fetch audit conversation:`,e),this.conversationError=`Failed to load interactions.`}finally{t===this.conversationRequestToken&&(this.conversationLoading=!1)}}selectedConversationEntry(){return sI(this.conversationEntries,this.conversationAnchorID)}followUpKind(){let e=this.selectedConversationEntry();return eI(e)?ZF(e.path):``}canSendFollowUp(){return!!this.followUpKind()&&!!String(this.followUpText||``).trim()&&!this.followUpSending&&!this.conversationLiveWaiting()}async sendFollowUp(){if(!this.canSendFollowUp())return;let e=this.selectedConversationEntry(),t=tI(e,this.followUpText);if(!e||!t)return;let n=this.conversationAnchorID,r=WI(),i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},zI);this.followUpSending=!0,this.followUpError=``,this.followUpRequestID=r,this.followUpAbort=i;try{let a=rI(e,n,r),o=await hs(e.path,{method:`POST`,headers:a,body:JSON.stringify(t),signal:i.signal}),s=String(o.headers.get(`X-Request-ID`)||``).trim();if(s&&this.followUpRequestID&&(this.followUpRequestID=s),!o.ok){let e=`Unable to send message.`;try{let t=await o.json();e=t&&t.error&&t.error.message||e}catch{}this.followUpError=e,(this.followUpRequestID===r||this.followUpRequestID===s)&&(this.followUpRequestID=``);return}if(this.followUpText=``,await UI(o),!MC.liveLogsStreaming&&this.conversationOpen){let e=++this.conversationRequestToken;await this._selectPersistedFollowUp(n,this.followUpRequestID,e,i.signal)}}catch(e){ys(e)||i.signal.aborted?a&&this.conversationOpen&&(this.followUpError=`The request timed out.`):(console.error(`Failed to send interaction follow-up:`,e),this.followUpError=`Failed to send message.`)}finally{clearTimeout(o),this.followUpAbort===i&&(this.followUpAbort=null,this.followUpSending=!1)}}async _selectPersistedFollowUp(e,t,n,r){let i=Date.now()+BI;for(;this.conversationOpen&&n===this.conversationRequestToken&&Date.now(){let e=this.conversationThreadEl;if(!e)return;let t=e.querySelectorAll(`[data-conversation-anchor="true"]`),n=t[t.length-1];n&&typeof n.scrollIntoView==`function`&&n.scrollIntoView({block:`center`})})}_scheduleLatestScroll(){requestAnimationFrame(()=>{let e=this.conversationThreadEl;if(!e)return;let t=e.lastElementChild;t&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`end`})})}};async function UI(e){let t=e&&e.body&&typeof e.body.getReader==`function`?e.body.getReader():null;if(!t){await e.text();return}for(;!(await t.read()).done;);}function WI(){return globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`?globalThis.crypto.randomUUID():`dashboard-`+Date.now().toString(36)+`-`+Math.random().toString(36).slice(2)}function GI(e,t){return new Promise((n,r)=>{let i,a=()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))};if(i=setTimeout(()=>{t&&t.removeEventListener(`abort`,a),n()},e),t){if(t.aborted){a();return}t.addEventListener(`abort`,a,{once:!0})}})}var KI=new HI,qI=0;Mn(()=>{An(()=>{let e=DC(MC.auditRecordChanges,qI);e.length!==0&&(qI=Number(e[e.length-1].version||0),Er(()=>{e.forEach(e=>{if(!OC(e))return;let t=MC.auditRecord(e.key);KI.handleAuditRecordChange(t,e.eventType)})}))})});var JI=R(``),YI=R(` `),XI=R(``),ZI=R(`
`);function QI(e,t){E(t,!0);let n=ya(t,`thread`,3,null),r=ya(t,`expanded`,3,!1),i=ya(t,`onactivate`,3,null),a=O(()=>ds.formatTimestamp(t.entry.timestamp)),o=O(()=>I(a)===`-`?I(a):I(a).slice(I(a).lastIndexOf(` `)+1)),s=O(()=>KI.conversationOpen&&String(KI.conversationAnchorID||``)===String(t.entry.id||``));function c(e){e.preventDefault(),i()&&i()()}function l(e){e.stopPropagation(),e.preventDefault(),n().ontoggle()}function u(e){if(e.stopPropagation(),e.preventDefault(),I(s)){KI.closeConversation();return}KI.openConversation(t.entry,e.currentTarget)}var d=ZI();let f;var p=M(d),m=M(p),h=e=>{var t=JI(),r=M(t);{let e=O(()=>n().expanded?Ha:Wa);G(r,{get icon(){return I(e)},class:`audit-thread-expander-svg`})}var i=P(r,2),a=M(i,!0);T(i),T(t),F(()=>{W(t,`aria-expanded`,n().expanded),W(t,`title`,`Session with `+n().count+` requests`),W(t,`aria-label`,`Session with `+n().count+` requests, `+(n().expanded?`collapse`:`expand`)),B(a,n().count)}),L(`click`,t,l),z(e,t)};V(m,e=>{n()&&e(h)});var g=P(m,2),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=M(y,!0);T(y),T(g);var x=P(g,2),S=e=>{var n=YI(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>bc(t.entry)]),z(e,n)};V(x,e=>{(t.entry.requested_model||t.entry.model)&&e(S)});var C=P(x,2),w=M(C,!0);T(C),T(p);var ee=P(p,2),te=M(ee);RF(te,{get entry(){return t.entry}});var ne=P(te,2),re=M(ne),ie=M(re,!0);T(re);var ae=P(re,2),oe=M(ae,!0);T(ae),T(ne);var se=P(ne,2),ce=M(se,!0);T(se);var le=P(se,2),ue=e=>{var t=XI();let n;var r=M(t);{let e=O(()=>I(s)?Ua:Wa);G(r,{get icon(){return I(e)},class:`audit-conversation-trigger-svg`})}T(t),F(()=>{n=U(t,1,`audit-conversation-trigger svelte-17mysgz`,null,n,{"audit-conversation-trigger-active":I(s)}),W(t,`title`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-label`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-pressed`,I(s))}),L(`click`,t,u),z(e,t)},de=O(()=>KI.canShowConversation(t.entry));V(le,e=>{I(de)&&e(ue)}),T(ee),T(d),F((e,n,i,s)=>{f=U(d,1,`audit-entry-summary svelte-17mysgz`,null,f,e),W(d,`aria-expanded`,r()),U(g,1,`audit-status-badge audit-request-badge ${n??``}`,`svelte-17mysgz`),W(g,`title`,`Status `+(t.entry.status_code||`-`)+` · `+(t.entry.method||`-`)),W(g,`aria-label`,(t.entry.status_code||`-`)+` `+(t.entry.method||`-`)),B(v,t.entry.status_code||`-`),B(b,t.entry.method||`-`),B(w,t.entry.path||`-`),W(ne,`title`,i),W(ne,`aria-label`,I(a)),B(ie,I(a)),B(oe,I(o)),B(ce,s)},[()=>({"audit-entry-summary-live-in-progress":UP(t.entry),"audit-entry-summary-has-interactions":KI.canShowConversation(t.entry)}),()=>HP(t.entry.status_code),()=>mc(t.entry.timestamp),()=>VP(t.entry.duration_ns)]),L(`click`,d,c),z(e,d),D()}Hr([`click`]);var $I=R(``);function eL(e,t){E(t,!0);let n=ya(t,`label`,3,`Copy`),r=ya(t,`copiedLabel`,3,`Copied`),i=ya(t,`errorLabel`,3,``),a=ya(t,`class`,3,`btn`),o=O(()=>t.state.error&&i()?i():t.state.copied?r():n());var s=$I();let c;var l=M(s),u=e=>{G(e,{get icon(){return Ka},width:`14`,height:`14`,"stroke-width":`2.5`})},d=e=>{G(e,{get icon(){return Ya},width:`14`,height:`14`})};V(l,e=>{t.state.copied?e(u):e(d,-1)});var f=P(l,2),p=M(f,!0);T(f),T(s),F(()=>{c=U(s,1,Fi([`copy-feedback-btn`,a()]),null,c,{"copy-feedback-btn-copied":t.state.copied}),B(p,I(o))}),L(`click`,s,e=>{e.preventDefault(),t.onclick?.(e)}),z(e,s),D()}Hr([`click`]);var tL=R(`
Error Message
 
`),nL=R(`
 
`),rL=R(` `),iL=R(` streaming`),aL=R(`
Body
`),oL=R(`

`),sL=R(`

`),cL=R(`

`),lL=R(`
`);function uL(e,t){E(t,!0);let n=_M({logPrefix:`Failed to copy audit payload:`}),r=_M({logPrefix:`Failed to copy audit payload:`}),i=O(()=>t.pane&&t.pane.showHeaders?ac(t.pane.headers):``),a=O(()=>!t.pane||!t.pane.showBody?``:yI(t.pane.body)?wI(t.pane.body):KI.renderBodyWithConversationHighlights(t.pane.entry,t.pane.body,{promptCacheHighlight:t.pane.promptCacheHighlight})),o=O(()=>!!(t.pane&&KI.canShowConversation(t.pane.entry)));function s(e){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),KI.handleErrorConversationClick(e,t.pane.entry))}var c=lL();let l;var u=M(c),d=e=>{var n=tL(),r=P(M(n),2);let i;var a=M(r,!0);T(r),T(n),F(()=>{i=U(r,1,`audit-json audit-pane-error-message svelte-1h5puht`,null,i,{"audit-pane-clickable-preview":I(o)}),W(r,`role`,I(o)?`button`:null),W(r,`tabindex`,I(o)?0:null),B(a,t.pane.errorMessage)}),L(`mousedown`,r,e=>KI.startBodyInteraction(e)),L(`keydown`,r,s),L(`click`,r,e=>KI.handleErrorConversationClick(e,t.pane.entry)),z(e,n)};V(u,e=>{t.pane.showErrorMessage&&e(d)});var f=P(u,2),p=e=>{var n=nL(),a=M(n),o=M(a),s=M(o,!0);T(o),eL(P(o,2),{get state(){return r},label:`Copy Headers`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>r.copy(t.pane.copyHeaders,ac)}),T(a);var c=P(a,2),l=M(c,!0);T(c),T(n),F(()=>{B(s,t.pane.headersTitle||`Headers`),B(l,I(i))}),z(e,n)};V(f,e=>{t.pane.showHeaders&&e(p)});var m=P(f,2),h=e=>{var r=aL(),i=M(r),o=M(i),s=P(M(o),2),c=e=>{var n=rL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.bodyCacheRatioLabel)),z(e,n)};V(s,e=>{t.pane.bodyCacheRatioLabel&&e(c)});var l=P(s,2),u=e=>{z(e,iL())};V(l,e=>{t.pane.streaming&&e(u)}),T(o),eL(P(o,2),{get state(){return n},label:`Copy Body`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>n.copy(t.pane.copyBody,ac)}),T(i);var d=P(i,2);hi(d,()=>I(a),!0),T(d),T(r),L(`mousedown`,d,e=>KI.startBodyInteraction(e)),L(`click`,d,e=>KI.handleBodyConversationClick(e,t.pane.entry)),z(e,r)};V(m,e=>{t.pane.showBody&&e(h)});var g=P(m,2),_=e=>{var n=oL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.emptyMessage)),z(e,n)};V(g,e=>{t.pane.showEmpty&&e(_)});var v=P(g,2),y=e=>{var n=sL(),r=P(M(n),2),i=M(r,!0);T(r),T(n),F(()=>B(i,t.pane.pendingMessage)),z(e,n)};V(v,e=>{t.pane.showPending&&e(y)});var b=P(v,2),x=e=>{var n=cL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.tooLargeMessage)),z(e,n)};V(b,e=>{t.pane.showTooLarge&&e(x)}),T(c),F(()=>l=U(c,1,`audit-pane svelte-1h5puht`,null,l,{"audit-pane-split":t.pane&&t.pane.layout===`split`,"audit-pane-split-single":t.pane&&t.pane.layout===`split`&&!(t.pane.showHeaders&&t.pane.showBody)})),z(e,c),D()}Hr([`mousedown`,`keydown`,`click`]);var dL=R(` `),fL=R(` `),pL=R(` `),mL=R(` `),hL=R(``),gL=R(`
`),_L=R(`
`);function vL(e,t){E(t,!0);let n=ya(t,`panes`,19,()=>[]),r=k(null),i=O(()=>xF(I(r),t.entry,n())),a=e=>`audit-tab-`+t.entry.id+`-`+e,o=e=>`audit-tabpanel-`+t.entry.id+`-`+e;function s(e,t){let i=n().map(e=>e.id),a=SF(e.key,i,t);a!=null&&(e.preventDefault(),((e.currentTarget?.closest?.(`.audit-pane-tablist`))?.querySelectorAll(`.audit-pane-tab`)[i.indexOf(a)])?.focus?.(),A(r,a,!0))}var c=_L(),l=M(c);H(l,21,n,e=>e.id,(e,t)=>{var n=hL();let c;var l=M(n),u=M(l),d=e=>{G(e,{get icon(){return Pa}})},f=e=>{G(e,{get icon(){return Na}})};V(u,e=>{I(t).pane.direction===`request`?e(d):I(t).pane.direction===`response`&&e(f,1)}),T(l);var p=P(l,2),m=M(p,!0);T(p);var h=P(p,2),g=e=>{var n=dL(),r=M(n);T(n),F(()=>B(r,`#${I(t).pane.seq??``}`)),z(e,n)};V(h,e=>{I(t).pane.seq&&e(g)});var _=P(h,2),v=e=>{var n=fL(),r=M(n,!0);T(n),F(()=>{U(n,1,`provider-badge audit-pane-kind audit-pane-kind-${I(t).pane.kind??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.kind)}),z(e,n)};V(_,e=>{I(t).pane.kind&&e(v)});var y=P(_,2);H(y,17,()=>I(t).pane.noChangeSteps||[],e=>e.id,(e,t)=>{var n=pL(),r=M(n,!0);T(n),F(()=>{W(n,`title`,I(t).title),B(r,I(t).label)}),z(e,n)});var b=P(y,2),x=e=>{var n=mL(),r=M(n,!0);T(n),F(()=>B(r,I(t).pane.savingsLabel)),z(e,n)};V(b,e=>{I(t).pane.savingsLabel&&e(x)});var S=P(b,2),C=e=>{var n=fL(),r=M(n,!0);T(n),F(e=>{U(n,1,`audit-status-badge ${e??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.statusCode)},[()=>HP(I(t).pane.statusCode)]),z(e,n)};V(S,e=>{I(t).pane.statusCode&&e(C)}),T(n),F((e,r)=>{c=U(n,1,`audit-pane-tab svelte-1bc5vi5`,null,c,{"audit-pane-tab-active":I(i)===I(t).id}),W(n,`aria-selected`,I(i)===I(t).id),W(n,`id`,e),W(n,`aria-controls`,r),W(n,`tabindex`,I(i)===I(t).id?0:-1),U(l,1,Fi([`audit-pane-icon`,I(t).pane.direction&&`audit-pane-icon-${I(t).pane.direction}`]),`svelte-1bc5vi5`),B(m,I(t).pane.title)},[()=>a(I(t).id),()=>o(I(t).id)]),L(`keydown`,n,e=>s(e,I(t).id)),L(`click`,n,()=>A(r,I(t).id,!0)),z(e,n)}),T(l),H(P(l,2),17,n,e=>e.id,(e,t)=>{var n=gL();let r;uL(M(n),{get pane(){return I(t).pane}}),T(n),F((e,a)=>{W(n,`id`,e),W(n,`aria-labelledby`,a),r=Hi(n,``,r,{display:I(i)===I(t).id?null:`none`})},[()=>o(I(t).id),()=>a(I(t).id)]),z(e,n)}),T(c),z(e,c),D()}Hr([`keydown`,`click`]);var yL=R(`
`),bL=R(`
`);function xL(e,t){E(t,!0);let n=ya(t,`thread`,3,null),r=O(()=>TF.isAuditEntryExpanded(t.entry)),i=O(()=>KI.conversationOpen&&String(KI.conversationAnchorID||``)===String(t.entry.id||``)),a=O(()=>I(r)?yF(t.entry,WF):[]),o=O(()=>I(r)?mN(t.entry,lP.auditEntryWorkflow(t.entry),lP.workflowFeatureCaps()):null);function s(){TF.toggleAuditEntryExpanded(t.entry)}var c=bL();let l;var u=M(c);QI(u,{get entry(){return t.entry},get thread(){return n()},get expanded(){return I(r)},onactivate:s});var d=P(u,2),f=e=>{var n=yL(),r=M(n),i=e=>{AM(e,{get chart(){return I(o)}})};V(r,e=>{I(o)&&e(i)});var s=P(r,2);vL(s,{get entry(){return t.entry},get panes(){return I(a)}}),FF(P(s,2),{get entry(){return t.entry}}),T(n),ki(3,n,()=>qs,()=>({y:-6,duration:sP(150)})),z(e,n)};V(d,e=>{I(r)&&e(f)}),T(c),F(()=>l=U(c,1,`audit-entry svelte-cmjgwr`,null,l,{"audit-entry-interactions-open":I(i)})),z(e,c),D()}var SL=R(`
`),CL=R(`
`),wL=R(`

`),TL=R(`
`),EL=R(`
`);function DL(e,t){E(t,!0);let n=O(()=>TP(t.entry)),r=O(()=>TF.isThreadExpanded(I(n))),i=O(()=>TF.threadChildren(I(n))),a=O(()=>I(i)&&!I(i).loading&&Number(I(i).total||0)>I(i).entries.length+1);var o=Qr(),s=N(o),c=e=>{xL(e,{get entry(){return t.entry}})},l=O(()=>!DP(t.entry)),u=e=>{var n=EL(),o=M(n);{let e=O(()=>({count:EP(t.entry),expanded:I(r),ontoggle:()=>TF.toggleThread(t.entry)}));xL(o,{get entry(){return t.entry},get thread(){return I(e)}})}var s=P(o,2),c=e=>{var t=TL(),n=M(t),r=e=>{var t=SL();SS(M(t),{size:14,label:`Loading session requests`}),T(t),z(e,t)};V(n,e=>{I(i)&&I(i).loading&&e(r)});var o=P(n,2);H(o,17,()=>I(i)&&I(i).entries||[],e=>e.id,(e,t)=>{var n=CL();xL(M(n),{get entry(){return I(t)}}),T(n),z(e,n)});var s=P(o,2),c=e=>{var t=wL(),n=M(t);T(t),F(()=>B(n,`Showing the latest ${I(i).entries.length+1} of ${I(i).total??``} - requests in this session.`)),z(e,t)};V(s,e=>{I(a)&&e(c)}),T(t),ki(3,t,()=>Js,()=>({duration:sP(150)})),z(e,t)};V(s,e=>{I(r)&&e(c)}),T(n),z(e,n)};V(s,e=>{I(l)?e(c):e(u,-1)}),z(e,o),D()}var OL=R(`

.

`),kL=R(`
Audit logging is off. Live entries are temporary and disappear after - refresh. Set LOGGING_ENABLED=true to persist them.
`),AL=R(`

`),jL=R(`
`),ML=R(`
`),NL=R(`
`),PL=R(`
`),FL=R(`
`);function IL(e,t){E(t,!0);let n=O(()=>Ss.config&&Ss.config.LOGGING_RETENTION_DAYS);An(()=>{if(K.refreshTick,Jo.page===`audit-logs`)return Er(()=>r())});function r(){let e=!1;return(async()=>{try{await Ss.ensureLoaded()}finally{await TF.fetchAuditLog(!0),!e&&Ss.liveLogsVisible()&&MC.ensureLiveLogs()}})(),()=>{e=!0,MC.stopLiveLogs()}}var i=FL(),a=M(i),o=M(a),s=P(M(o),2),c=e=>{qS(e,{copyId:`audit-retention-help-copy`,label:`retention help`,text:`If you want to change the retention period, set LOGGING_RETENTION_DAYS (env var) or logging.retention_days (config.yaml) and restart the gateway. Default is 30 days; 0 keeps audit logs forever.`,title:e=>{var t=OL(),r=M(t,!0),i=P(r),a=M(i,!0);T(i),Ue(),T(t),F((e,t)=>{B(r,e),B(a,t)},[()=>xP(I(n)),()=>SP(I(n))]),z(e,t)},$$slots:{title:!0}})},l=O(()=>bP(I(n)));V(s,e=>{I(l)&&e(c)}),T(o),T(a);var u=P(a,2);tl(M(u),{onchange:()=>TF.fetchAuditLog(!0)}),T(u);var d=P(u,2);Fc(d,{});var f=P(d,2),p=e=>{z(e,kL())},m=O(()=>Ss.loaded&&!Ss.auditVisible()&&!K.needsAuth);V(f,e=>{I(m)&&e(p)});var h=P(f,2),g=M(h);DF(g,{});var _=P(g,2),v=M(_),y=M(v),b=e=>{var t=AL(),n=M(t);T(t),F(e=>B(n,`Showing ${TF.auditLog.offset+1}-${e??``} of ${TF.auditLog.total??``} - ${TF.auditGroupSessions?`sessions`:`logs`}`),[()=>Math.min(TF.auditLog.offset+TF.auditLog.limit,TF.auditLog.total)]),z(e,t)};V(y,e=>{TF.auditLog.total>0&&e(b)});var x=P(y,2),S=M(x);na(S),Ue(2),T(x),T(v),MF(P(v,2),{}),T(_);var C=P(_,2),w=e=>{var t=jL();SS(M(t),{size:18,label:`Loading audit logs`}),T(t),z(e,t)},ee=e=>{var t=NL();H(t,29,()=>TF.auditLog.entries,e=>e.id,(e,t)=>{var n=ML(),r=M(n),i=e=>{DL(e,{get entry(){return I(t)}})},a=e=>{xL(e,{get entry(){return I(t)}})};V(r,e=>{TF.auditGroupSessions?e(i):e(a,-1)}),T(n),Oi(n,()=>rP,()=>({duration:sP(150)})),ki(1,n,()=>cP,()=>({live:I(t)._live})),z(e,n)}),T(t),z(e,t)};V(C,e=>{TF.loading&&TF.auditLog.entries.length===0?e(w):TF.auditLog.entries.length>0&&e(ee,1)});var te=P(C,2),ne=e=>{var t=PL();TS(M(t),{}),T(t),z(e,t)};V(te,e=>{TF.auditLog.entries.length===0&&!TF.loading&&!K.needsAuth&&e(ne)}),Jw(P(te,2),{get total(){return TF.auditLog.total},get offset(){return TF.auditLog.offset},get limit(){return TF.auditLog.limit},onprev:()=>TF.auditLogPrevPage(),onnext:()=>TF.auditLogNextPage()}),T(h),T(i),F(()=>ia(S,TF.auditGroupSessions)),L(`change`,S,()=>TF.toggleAuditGroupSessions()),z(e,i),D()}Hr([`change`]);function LL(e){try{let t=JSON.parse(JSON.stringify(e||{}));return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function RL(e){return Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(e=>e):e==null?[]:String(e).split(`,`).map(e=>e.trim()).filter(e=>e)}function zL(e,t){let n=String(t||``).trim();return(e||[]).find(e=>String(e&&e.type||``).trim()===n)||null}function BL(e){return Array.isArray(e)&&e.length>0&&String(e[0].type||``).trim()||`system_prompt`}function VL(e,t){let n=String(t||``).trim();return n&&zL(e,n)?n:BL(e)}function HL(e,t){let n=zL(e,t);return!n||!n.defaults?{}:LL(n.defaults)}function UL(e,t,n){return{...HL(e,n),...LL(t)}}function WL(e,t){let n=VL(e,t);return{name:``,type:n,description:``,user_path:``,config:HL(e,n)}}function GL(e,t){if(!t)return e||[];let n=String(t).toLowerCase();return(e||[]).filter(e=>[e.name,e.type,e.user_path,e.description,e.summary].some(e=>String(e||``).toLowerCase().includes(n)))}function KL(e,t){let n=zL(e,t);return n&&n.label?n.label:t||`Unknown`}function qL(e,t){let n=zL(e,t);return Array.isArray(n&&n.fields)?n.fields:[]}function JL(e,t){if(!t||!e)return t&&t.input===`checkboxes`?[]:``;let n=e[t.key];return n==null?t.input===`checkboxes`?[]:``:t.input===`checkboxes`?RL(n):n}function YL(e,t,n){if(!t)return e;let r=LL(e);if(t.input===`number`){let e=String(n||``).trim();if(e===``)delete r[t.key];else{let n=Number(e);r[t.key]=Number.isFinite(n)?n:e}}else t.input===`checkboxes`?r[t.key]=RL(n):r[t.key]=n;return r}function XL(e,t,n){return JL(e,t).includes(String(n||``).trim())}function ZL(e,t,n,r){let i=RL(JL(e,t)),a=String(n||``).trim();return a?YL(e,t,r?Array.from(new Set([...i,a])):i.filter(e=>e!==a)):e}function QL(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),description:String(e&&e.description||``).trim()||void 0,user_path:String(e&&e.user_path||``).trim()||void 0,config:LL(e&&e.config)}}var $L=new class{#e=k(j([]));get guardrails(){return I(this.#e)}set guardrails(e){A(this.#e,e,!0)}#t=k(j([]));get types(){return I(this.#t)}set types(e){A(this.#t,e,!0)}#n=k(!0);get available(){return I(this.#n)}set available(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=k(!1);get typesLoading(){return I(this.#i)}set typesLoading(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(``);get filter(){return I(this.#o)}set filter(e){A(this.#o,e,!0)}#s=k(!1);get formOpen(){return I(this.#s)}set formOpen(e){A(this.#s,e,!0)}#c=k(!1);get formSubmitting(){return I(this.#c)}set formSubmitting(e){A(this.#c,e,!0)}#l=k(``);get deletingName(){return I(this.#l)}set deletingName(e){A(this.#l,e,!0)}#u=k(`create`);get formMode(){return I(this.#u)}set formMode(e){A(this.#u,e,!0)}#d=k(``);get formOriginalName(){return I(this.#d)}set formOriginalName(e){A(this.#d,e,!0)}#f=k(j({name:``,type:``,description:``,user_path:``,config:{}}));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}get filtered(){return GL(this.guardrails,this.filter)}typeLabel(e){return KL(this.types,e)}typeFields(e){return qL(this.types,e)}fieldValue(e){return JL(this.form&&this.form.config,e)}setFieldValue(e,t){this.form={...this.form,config:YL(this.form.config,e,t)}}arrayFieldSelected(e,t){return XL(this.form&&this.form.config,e,t)}toggleArrayFieldValue(e,t,n){this.form={...this.form,config:ZL(this.form.config,e,t,n)}}openCreate(){this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=WL(this.types,BL(this.types)),this.formOpen=!0}openEdit(e){let t=VL(this.types,e&&e.type);this.formMode=`edit`,this.formOriginalName=String(e&&e.name||``).trim(),this.error=``,this.form={name:this.formOriginalName,type:t,description:String(e&&e.description||``).trim(),user_path:String(e&&e.user_path||``).trim(),config:UL(this.types,e&&e.config,t)},this.formOpen=!0}closeForm(){this.formOpen=!1,this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=WL(this.types,BL(this.types))}changeType(e){let t=VL(this.types,e);this.form={...this.form,type:t,config:HL(this.types,t)}}async fetchTypes(){this.typesLoading=!0;try{let e=await _T(`/admin/guardrails/types`,{label:`guardrail types`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.types=[];return}if(e.result&&(this.available=!0),this.types=e.items,e.status===`error`){this.error=e.error;return}let t=VL(this.types,this.form.type);this.form={...this.form,type:t,config:UL(this.types,this.form.config,t)}}finally{this.typesLoading=!1}}async fetchGuardrails(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/guardrails`,{label:`guardrails`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.guardrails=[];return}e.result&&(this.available=!0),this.guardrails=e.items,this.error=e.error}finally{this.loading=!1}}async fetchPage(){await Promise.all([this.fetchTypes(),this.fetchGuardrails()])}async submitForm(){let e=String(this.form.name||``).trim(),t=String(this.form.type||``).trim();if(!e){this.error=`Name is required.`;return}if(!t){this.error=`Type is required.`;return}this.error=``,this.formSubmitting=!0;let n=QL(this.form);try{let t=await vT(`/admin/guardrails`,`PUT`,n,{label:`save guardrail`,errorFallback:`Failed to save guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}q.success(`Guardrail "`+e+`" saved.`),this.closeForm(),this.fetchGuardrails()}finally{this.formSubmitting=!1}}async deleteGuardrail(e){let t=String(e&&e.name||``).trim();if(!(!t||this.deletingName)&&window.confirm(`Delete guardrail "`+t+`"? Workflows that still reference it must be updated first.`)){this.deletingName=t;try{let e=await vT(`/admin/guardrails`,`DELETE`,{name:t},{label:`delete guardrail`,errorFallback:`Failed to delete guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}q.success(`Guardrail "`+t+`" deleted.`),this.formOpen&&this.formOriginalName===t&&this.closeForm(),this.fetchGuardrails()}finally{this.deletingName=``}}}},eR=R(`
`),tR=R(`

Loading guardrails...

`),nR=R(`
`),rR=R(`
`),iR=R(`
NameTypeUser PathSummaryActions
`),aR=R(`

No guardrails defined yet.

`),oR=R(`

Instances

Each instance has a reusable name, a type, an optional user path for - future UI visibility scoping, and a JSON-backed config payload for - that type.

`);function sR(e,t){E(t,!0);var n=oR(),r=M(n),i=P(M(r),2);G(M(i),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(i),T(r);var a=P(r,2),o=e=>{var t=eR(),n=M(t);yw(M(n),{id:`guardrail-filter`,placeholder:`Filter by name, type, user path, summary...`,label:`Guardrail filter`,get value(){return $L.filter},set value(e){$L.filter=e}}),T(n),T(t),z(e,t)};V(a,e=>{$L.available&&e(o)});var s=P(a,2),c=e=>{var t=tR();SS(M(t),{size:16,label:`Loading guardrails`}),Ue(),T(t),z(e,t)};V(s,e=>{$L.loading&&$L.filtered.length===0&&e(c)});var l=P(s,2),u=e=>{var t=iR(),n=M(t),r=P(M(n));H(r,21,()=>$L.filtered,e=>e.name,(e,t)=>{var n=rR(),r=M(n),i=M(r,!0);T(r);var a=P(r),o=M(a),s=M(o,!0);T(o),T(a);var c=P(a),l=M(c,!0);T(c);var u=P(c),d=M(u),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var n=nR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(p,e=>{I(t).description&&e(m)}),T(u);var h=P(u),g=M(h),_=M(g);{let e=O(()=>`Edit guardrail `+I(t).name);gT(_,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>$L.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var v=P(_,2);{let e=O(()=>($L.deletingName===I(t).name?`Deleting guardrail `:`Delete guardrail `)+I(t).name),n=O(()=>$L.deletingName===I(t).name);gT(v,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>$L.deleteGuardrail(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}T(g),T(h),T(n),F(e=>{B(i,I(t).name),B(s,e),B(l,I(t).user_path||`—`),B(f,I(t).summary||I(t).description||`No summary yet.`)},[()=>$L.typeLabel(I(t).type)]),z(e,n)}),T(r),T(n),T(t),z(e,t)};V(l,e=>{$L.filtered.length>0&&e(u)});var d=P(l,2),f=e=>{z(e,aR())};V(d,e=>{$L.filtered.length===0&&!$L.loading&&$L.available&&!$L.error&&!K.authError&&e(f)}),T(n),F(()=>i.disabled=$L.typesLoading||$L.formSubmitting||!$L.available),L(`click`,i,()=>$L.openCreate()),z(e,n),D()}Hr([`click`]);var cR=R(`

Workflows reference these names directly, so renames are - intentionally avoided after creation.

`),lR=R(``),uR=R(``),dR=R(``),fR=R(``),pR=R(``),mR=R(``),hR=R(``),gR=R(``),_R=R(``),vR=R(`
`),yR=R(``),bR=R(` `),xR=R(`
`),SR=R(`
`);function CR(e,t){E(t,!0);let n=O(()=>$L.formMode===`edit`);{let t=e=>{z(e,cR())},r=O(()=>I(n)?`Edit Guardrail`:`Create Guardrail`);bE(e,{get open(){return $L.formOpen},get title(){return I(r)},ariaLabel:`Guardrail editor`,get error(){return $L.error},get submitting(){return $L.formSubmitting},submitLabel:`Save Guardrail`,dialogClass:`settings-guardrails-editor guardrails-editor-wide`,onclose:()=>$L.closeForm(),onsubmit:()=>$L.submitForm(),headerHint:t,children:(e,t)=>{var r=SR(),i=M(r);SE(i,{id:`guardrail-name`,label:`Name`,children:(e,t)=>{var r=lR();na(r),F(()=>{r.disabled=I(n),W(r,`data-modal-autofocus`,!I(n)||void 0)}),da(r,()=>$L.form.name,e=>$L.form.name=e),z(e,r)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`guardrail-type`,label:`Type`,children:(e,t)=>{var r=dR();H(r,21,()=>$L.types,e=>e.type,(e,t)=>{var n=uR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).type)&&(n.value=(n.__value=I(t).type)??``)}),z(e,n)}),T(r);var i;Wi(r),F(()=>{r.disabled=I(n),i!==(i=$L.form.type)&&(r.value=(r.__value=$L.form.type)??``,Ui(r,$L.form.type))}),L(`change`,r,e=>$L.changeType(e.currentTarget.value)),z(e,r)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`guardrail-description`,label:`Description`,children:(e,t)=>{var r=fR();na(r),F(()=>W(r,`data-modal-autofocus`,I(n)?!0:void 0)),da(r,()=>$L.form.description,e=>$L.form.description=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2),c=M(s);qS(c,{copyId:`guardrail-user-path-help-copy`,label:`guardrail user path help`,text:`Only used for auxiliary rewrite (llm_based_altering) guardrails; ignored for other guardrail types.`,title:e=>{z(e,pR())},$$slots:{title:!0}});var l=P(c,2);na(l),T(s),H(P(s,2),17,()=>$L.typeFields($L.form.type),e=>e.key,(e,t)=>{var n=Qr(),r=N(n),i=e=>{var n=vR(),r=M(n);{let e=e=>{var n=mR(),r=M(n,!0);T(n),F(()=>{W(n,`for`,`guardrail-field-`+I(t).key),B(r,I(t).label)}),z(e,n)},n=O(()=>`guardrail-field-help-`+I(t).key),i=O(()=>I(t).label+` help`),a=O(()=>I(t).help||``);qS(r,{get copyId(){return I(n)},get label(){return I(i)},get text(){return I(a)},title:e,$$slots:{title:!0}})}var i=P(r,2),a=e=>{var n=hR();H(n,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=uR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n);var r;Wi(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),r!==(r=e)&&(n.value=(n.__value=e)??``,Ui(n,e))},[()=>$L.fieldValue(I(t))]),L(`change`,n,e=>$L.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},o=e=>{var n=gR();ft(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>$L.fieldValue(I(t))]),L(`input`,n,e=>$L.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},s=e=>{var n=_R();na(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`type`,I(t).input||`text`),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>$L.fieldValue(I(t))]),L(`input`,n,e=>$L.setFieldValue(I(t),e.currentTarget.value)),z(e,n)};V(i,e=>{I(t).input===`select`?e(a):I(t).input===`textarea`?e(o,1):e(s,-1)}),T(n),z(e,n)},a=e=>{var n=xR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).options||[],e=>I(t).key+`-`+e.value,(e,n)=>{var r=yR(),i=M(r);na(i);var a=P(i,2),o=M(a,!0);T(a),T(r),F(e=>{ia(i,e),B(o,I(n).label)},[()=>$L.arrayFieldSelected(I(t),I(n).value)]),L(`change`,i,e=>$L.toggleArrayFieldValue(I(t),I(n).value,e.currentTarget.checked)),z(e,r)}),T(a);var o=P(a,2),s=e=>{var n=bR(),r=M(n,!0);T(n),F(()=>{W(n,`id`,`guardrail-field-help-`+I(t).key),B(r,I(t).help)}),z(e,n)};V(o,e=>{I(t).help&&e(s)}),T(n),F(()=>{W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),B(i,I(t).label)}),z(e,n)};V(r,e=>{I(t).input===`checkboxes`?e(a,-1):e(i)}),z(e,n)}),T(r),da(l,()=>$L.form.user_path,e=>$L.form.user_path=e),z(e,r)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var wR=R(`

Guardrails

`),TR=R(`
Runtime guardrail execution is currently off because GUARDRAILS_ENABLED is disabled. You can still manage - definitions here.
`),ER=R(`
Guardrails feature is unavailable.
`),DR=R(`
`),OR=R(`

Reusable Policy Objects

Guardrail Library

Store guardrails in the database, keep them hot in memory, and attach - them to workflows by reference.

Instances
Types
`);function kR(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`guardrails`&&(Ss.ensureLoaded(),$L.fetchPage())});var n=OR(),r=M(n),i=M(r);qS(M(i),{copyId:`guardrails-help-copy`,label:`guardrails help`,text:`Reusable policy objects stored in the database and kept hot in memory for workflow execution.`,title:e=>{z(e,wR())},$$slots:{title:!0}}),T(i),T(r);var a=P(r,2),o=P(M(a),2),s=M(o),c=P(M(s),2),l=M(c,!0);T(c),T(s);var u=P(s,2),d=P(M(u),2),f=M(d,!0);T(d),T(u),T(o),T(a);var p=P(a,2);Fc(p,{});var m=P(p,2),h=e=>{z(e,TR())},g=O(()=>!Ss.guardrailsVisible());V(m,e=>{I(g)&&e(h)});var _=P(m,2),v=e=>{z(e,ER())};V(_,e=>{!K.authError&&!$L.available&&e(v)});var y=P(_,2),b=e=>{var t=DR(),n=M(t,!0);T(t),F(()=>B(n,$L.error)),z(e,t)};V(y,e=>{!K.authError&&$L.error&&!$L.formOpen&&e(b)});var x=P(y,2);CR(x,{}),sR(P(x,2),{}),T(n),F((e,t)=>{B(l,e),B(f,t)},[()=>oc($L.guardrails.length),()=>oc($L.types.length)]),z(e,n),D()}var Q=new class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get slugEdited(){return I(this.#c)}set slugEdited(e){A(this.#c,e,!0)}#l=k(!1);get advancedOpen(){return I(this.#l)}set advancedOpen(e){A(this.#l,e,!0)}#u=k(j(dx()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(``);get deletingName(){return I(this.#d)}set deletingName(e){A(this.#d,e,!0)}#f=k(``);get reconnectingName(){return I(this.#f)}set reconnectingName(e){A(this.#f,e,!0)}#p=k(!1);get catalogOpen(){return I(this.#p)}set catalogOpen(e){A(this.#p,e,!0)}#m=k(!1);get catalogLoading(){return I(this.#m)}set catalogLoading(e){A(this.#m,e,!0)}#h=k(``);get catalogError(){return I(this.#h)}set catalogError(e){A(this.#h,e,!0)}#g=k(j(fx()));get catalog(){return I(this.#g)}set catalog(e){A(this.#g,e,!0)}#_=O(()=>Cx(this.servers,this.filter));get filtered(){return I(this.#_)}set filtered(e){A(this.#_,e)}async fetchServers(){if(await Ss.ensureLoaded(),!Ss.mcpVisible()){this.available=!1,this.servers=[],this.error=``,this.loading=!1;return}this.loading=!0,this.error=``;try{let e=await _T(`/admin/mcp-servers`,{label:`mcp servers`,errorFallback:`Failed to load MCP servers.`,unavailableStatuses:[503,404]});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.servers=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.servers=[],this.error=e.error;return}this.available=!0,this.servers=e.items}finally{this.loading=!1}}openCreate(){this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=dx(),this.formOpen=!0}openEdit(e){!e||e.managed||(this.formMode=`edit`,this.slugEdited=!0,this.advancedOpen=!1,this.error=``,this.form=wx(e),this.formOpen=!0)}closeForm(){this.formOpen=!1,this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=dx()}syncSlugFromName(){this.formMode===`create`&&!this.slugEdited&&(this.form.slug=yx(this.form.name))}markSlugEdited(){this.formMode===`create`&&(this.slugEdited=!0)}addHeader(){this.form.headers.push({name:``,value:``})}removeHeader(e){this.form.headers.splice(e,1)}async submitForm(){let e=Tx(this.form,this.formMode,this.servers);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/mcp-servers`,`PUT`,e.payload,{label:`save mcp server`,errorFallback:`Failed to save MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}q.success(`MCP server "`+e.payload.name+`" saved.`),this.closeForm(),this.fetchServers()}finally{this.formSubmitting=!1}}async deleteServer(e){let t=String(e&&e.name||``).trim(),n=px(e);if(!(!n||this.deletingName||e&&e.managed)&&confirm(`Delete MCP server "`+t+`"? Clients lose access to its tools immediately.`)){this.deletingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n),`DELETE`,void 0,{label:`delete mcp server`,errorFallback:`Failed to delete MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}q.success(`MCP server "`+t+`" deleted.`),this.formOpen&&this.form.slug===n&&this.closeForm(),this.fetchServers()}finally{this.deletingName=``}}}async reconnectServer(e){let t=String(e&&e.name||``).trim(),n=px(e);if(!(!n||this.reconnectingName)){this.reconnectingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n)+`/reconnect`,`POST`,void 0,{label:`reconnect mcp server`,errorFallback:`Failed to reconnect MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}let r=e.result.data,i=mx(r);i===`connected`?q.success(`MCP server "`+t+`" reconnected.`):i===`disabled`?q.success(`MCP server "`+t+`" is disabled; no connection was attempted.`):q.error(`Reconnect attempted, but MCP server "`+t+`" is still `+i+`.`),r&&r.name?this.servers=(this.servers||[]).map(e=>px(e)===px(r)?r:e):this.fetchServers()}finally{this.reconnectingName=``}}}async openCatalog(e){let t=String(e&&e.name||``).trim(),n=px(e);if(n){this.catalogOpen=!0,this.catalogLoading=!0,this.catalogError=``,this.catalog={...fx(),server:n,status:mx(e)};try{let e=await _s(`/admin/mcp-servers/`+encodeURIComponent(n)+`/catalog`,{label:`mcp server catalog`});if(e.stale)return;if(e.status===503){this.available=!1,this.catalogError=`MCP server management is unavailable.`;return}if(e.status===404){this.catalogError=`MCP server "`+t+`" was not found.`;return}if(!e.ok){this.catalogError=e.status===401?`Authentication required.`:fs(e.data,`Failed to load MCP server catalog.`);return}this.catalog=Ex(n,e.data)}catch(e){console.error(`Failed to load MCP server catalog:`,e),this.catalogError=`Failed to load MCP server catalog.`}finally{this.catalogLoading=!1}}}closeCatalog(){this.catalogOpen=!1,this.catalogLoading=!1,this.catalogError=``,this.catalog=fx()}},AR=R(``),jR=R(`

`),MR=R(`
`),NR=R(`

`),PR=R(`
  • `),FR=R(`

      `),IR=R(`

      No tools listed — the server may still be connecting or degraded.

      `),LR=R(` `,1),RR=R(``);function zR(e,t){E(t,!0);let n=O(()=>Ox(Q.catalog));Ns(e,{get open(){return Q.catalogOpen},variant:`editor`,onclose:()=>Q.closeCatalog(),children:(e,t)=>{var r=RR(),i=M(r),a=M(i),o=P(M(a),2),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l),T(o),T(a),ks(P(a,2),{label:`Close MCP server catalog`,onclick:()=>Q.closeCatalog()}),T(i);var d=P(i,2),f=e=>{mT(e,{label:`Loading catalog...`})},p=e=>{var t=AR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalogError)),z(e,t)},m=e=>{var t=LR(),r=N(t),i=e=>{var t=jR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalog.instructions)),z(e,t)};V(r,e=>{Q.catalog.instructions&&e(i)});var a=P(r,2);H(a,17,()=>I(n),e=>e.key,(e,t)=>{var n=FR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).items,e=>e.key,(e,t)=>{var n=PR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=MR(),r=M(n,!0);T(n),F(()=>{W(n,`title`,`Exposed on the aggregated /mcp endpoint as `+I(t).aggregated),B(r,I(t).aggregated)}),z(e,n)};V(a,e=>{I(t).aggregated&&e(o)});var s=P(a,2),c=e=>{var n=NR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(s,e=>{I(t).description&&e(c)}),T(n),F(()=>{W(r,`title`,I(t).aggregated||I(t).name),B(i,I(t).name)}),z(e,n)}),T(a),T(n),F(()=>B(i,I(t).title)),z(e,n)});var o=P(a,2),s=e=>{z(e,IR())},c=O(()=>kx(Q.catalog));V(o,e=>{I(c)&&e(s)}),z(e,t)};V(d,e=>{Q.catalogLoading?e(f):Q.catalogError?e(p,1):e(m,-1)});var h=P(d,2),g=M(h);T(h),T(r),F((e,t)=>{B(c,Q.catalog.server),U(l,1,`audit-status-badge ${e??``}`,`svelte-1xqrzco`),B(u,t)},[()=>hx(Q.catalog),()=>mx(Q.catalog)]),L(`click`,g,()=>Q.closeCatalog()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var BR=R(`

      The display name can change. The slug is the stable client-facing identity.

      `),VR=R(` Human-readable and Unicode-friendly. You can change it later.`,1),HR=R(`Derived from the name. You may edit it before saving.`),UR=R(`Immutable because it is used in URLs, scope headers, and aggregated tool names.`),WR=R(` `,1),GR=R(` stdio servers are config-only: declare them in config.yaml under mcp.servers.`,1),KR=R(``),qR=R(`
      `),JR=R(`
      Headers
      Sent only to the configured server origin. Saved values are shown as ***; leave *** unchanged to keep the stored value.
      Advanced settings Description, access rules, and timeout
      `,1);function YR(e,t){E(t,!0);{let t=e=>{z(e,BR())},n=O(()=>Q.formMode===`edit`?`Edit MCP Server`:`Add MCP Server`);bE(e,{get open(){return Q.formOpen},get title(){return I(n)},ariaLabel:`MCP server editor`,get error(){return Q.error},get submitting(){return Q.formSubmitting},onclose:()=>Q.closeForm(),onsubmit:()=>Q.submitForm(),headerHint:t,children:(e,t)=>{var n=JR(),r=N(n);SE(r,{id:`mcp-server-name`,label:`Name`,children:(e,t)=>{var n=VR(),r=N(n);na(r),Ue(2),L(`input`,r,()=>Q.syncSlugFromName()),da(r,()=>Q.form.name,e=>Q.form.name=e),z(e,n)},$$slots:{default:!0}});var i=P(r,2);SE(i,{id:`mcp-server-slug`,label:`Slug`,children:(e,t)=>{var n=WR(),r=N(n);na(r);var i=P(r,2),a=e=>{z(e,HR())},o=e=>{z(e,UR())};V(i,e=>{Q.formMode===`create`?e(a):e(o,-1)}),F(()=>r.disabled=Q.formMode===`edit`),L(`input`,r,()=>Q.markSlugEdited()),da(r,()=>Q.form.slug,e=>Q.form.slug=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`mcp-server-transport`,label:`Transport`,children:(e,t)=>{var n=GR(),r=N(n),i=M(r);i.value=i.__value=`http`;var a=P(i);a.value=a.__value=`sse`,T(r),Ue(2),Gi(r,()=>Q.form.transport,e=>Q.form.transport=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`mcp-server-url`,label:`URL`,children:(e,t)=>{var n=KR();na(n),da(n,()=>Q.form.url,e=>Q.form.url=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=P(M(s),2);H(c,21,()=>Q.form.headers,oi,(e,t,n)=>{var r=qR(),i=M(r);na(i);var a=P(i,2);na(a),gT(P(a,2),{label:`Remove header`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Q.removeHeader(n),children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),da(i,()=>I(t).name,e=>I(t).name=e),da(a,()=>I(t).value,e=>I(t).value=e),z(e,r)}),T(c);var l=P(c,2),u=M(l);G(M(u),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(u),T(l),Ue(2),T(s);var d=P(s,2),f=M(d);bA(M(f),{get enabled(){return Q.form.enabled},label:`MCP server`,onclick:()=>Q.form.enabled=!Q.form.enabled}),T(f),T(d);var p=P(d,2),m=P(M(p),2),h=M(m),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=P(M(y),2);na(b),T(y);var x=P(y,2),S=P(M(x),2);ft(S),W(S,`placeholder`,`/ -/team/alpha`),T(x);var C=P(x,2),w=P(M(C),2);na(w),T(C),T(m),T(p),F(()=>p.open=Q.advancedOpen),L(`click`,u,()=>Q.addHeader()),Vr(`toggle`,p,e=>Q.advancedOpen=e.currentTarget.open),da(g,()=>Q.form.description,e=>Q.form.description=e),da(v,()=>Q.form.allowed_tools,e=>Q.form.allowed_tools=e),da(b,()=>Q.form.disallowed_tools,e=>Q.form.disallowed_tools=e),da(S,()=>Q.form.user_paths,e=>Q.form.user_paths=e),da(w,()=>Q.form.tool_timeout_seconds,e=>Q.form.tool_timeout_seconds=e),z(e,n)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`input`,`click`]);var XR=R(`Config`),ZR=R(`
      `),QR=R(`
      `),$R=R(`
      NameTransportEndpointStatusToolsEnabledActions
      `);function ez(e,t){E(t,!0);function n(e){return gx(e,e=>ds.formatTimestamp(e))}var r=$R(),i=M(r),a=P(M(i));H(a,21,()=>Q.filtered,e=>px(e),(e,t)=>{var r=QR(),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=e=>{z(e,XR())};V(s,e=>{I(t).managed&&e(c)});var l=P(s,2),u=M(l,!0);T(l),T(i);var d=P(i),f=M(d),p=M(f,!0);T(f),T(d);var m=P(d),h=M(m,!0);T(m);var g=P(m),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=e=>{var n=ZR(),r=M(n,!0);T(n),F(()=>B(r,I(t).last_error)),z(e,n)},x=O(()=>mx(I(t))===`degraded`&&I(t).last_error);V(y,e=>{I(x)&&e(b)}),T(g);var S=P(g),C=M(S),w=M(C,!0);T(C);var ee=P(C,2),te=M(ee,!0);T(ee),T(S);var ne=P(S),re=M(ne),ie=M(re,!0);T(re),T(ne);var ae=P(ne),oe=M(ae),se=M(oe),ce=e=>{{let n=O(()=>`Edit MCP server `+I(t).name);gT(e,{get label(){return I(n)},class:`table-icon-btn`,onclick:()=>Q.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(se,e=>{I(t).managed||e(ce)});var le=P(se,2);{let e=O(()=>`Inspect catalog of MCP server `+I(t).name);gT(le,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.openCatalog(I(t)),children:(e,t)=>{G(e,{get icon(){return io},class:`form-action-icon`})},$$slots:{default:!0}})}var ue=P(le,2);{let e=O(()=>(Q.reconnectingName===px(I(t))?`Reconnecting MCP server `:`Reconnect MCP server `)+I(t).name),n=O(()=>Q.reconnectingName===px(I(t)));gT(ue,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.reconnectServer(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return ho},class:`form-action-icon`})},$$slots:{default:!0}})}var de=P(ue,2),fe=e=>{{let n=O(()=>(Q.deletingName===px(I(t))?`Deleting MCP server `:`Delete MCP server `)+I(t).name),r=O(()=>Q.deletingName===px(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>Q.deleteServer(I(t)),get disabled(){return I(r)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(de,e=>{I(t).managed||e(fe)}),T(oe),T(ae),T(r),F((e,n,r,i,a,s,c,l)=>{B(o,I(t).name),B(u,e),B(p,I(t).transport||`http`),W(m,`title`,n),B(h,r),U(_,1,`audit-status-badge ${i??``}`,`svelte-ah8nrt`),W(_,`title`,a),B(v,s),B(w,c),B(te,l),U(re,1,Fi([`auth-key-status-badge`,I(t).enabled?`auth-key-status-active`:`auth-key-status-inactive`])),B(ie,I(t).enabled?`Enabled`:`Disabled`)},[()=>px(I(t)),()=>_x(I(t)),()=>_x(I(t)),()=>hx(I(t)),()=>n(I(t)),()=>mx(I(t)),()=>oc(I(t).tool_count||0),()=>vx(I(t))]),z(e,r)}),T(a),T(i),T(r),z(e,r),D()}var tz=R(`

      MCP Servers

      `),nz=R(``),rz=R(`
      MCP server management is unavailable.
      `),iz=R(``),az=R(`
      `),oz=R(`

      No MCP servers yet. Add one here, or declare servers in config.yaml under mcp.servers.

      `),sz=R(`

      No MCP servers match your filter.

      `),cz=R(`
      `);function lz(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`mcp-servers`&&Q.fetchServers()});var n=cz(),r=M(n),i=M(r);qS(M(i),{copyId:`mcp-servers-help-copy`,label:`MCP servers help`,text:`Upstream Model Context Protocol servers whose tools, prompts, and resources the gateway exposes to clients. Servers added here connect over HTTP or SSE; stdio servers and rows marked Config are declared in config.yaml under mcp.servers and are read-only in the dashboard. Saved header values are masked in API and dashboard responses.`,title:e=>{z(e,tz())},$$slots:{title:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=nz();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Q.formSubmitting),L(`click`,t,()=>Q.openCreate()),z(e,t)};V(o,e=>{Q.available&&!K.authError&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,rz())};V(c,e=>{!Q.available&&!K.authError&&e(l)});var u=P(c,2),d=e=>{var t=iz(),n=M(t,!0);T(t),F(()=>B(n,Q.error)),z(e,t)};V(u,e=>{Q.error&&!K.authError&&!Q.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading MCP servers...`})};V(f,e=>{Q.loading&&!K.authError&&e(p)});var m=P(f,2),h=e=>{var t=az(),n=M(t);yw(M(n),{id:`mcp-server-filter`,placeholder:`Filter by name, slug, URL, transport, or status...`,label:`Filter MCP servers by name, slug, URL, transport, or status`,get value(){return Q.filter},set value(e){Q.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{(Q.servers.length>0||Q.filter)&&Q.available&&!K.authError&&e(h)});var g=P(m,2);YR(g,{});var _=P(g,2);zR(_,{});var v=P(_,2),y=e=>{ez(e,{})};V(v,e=>{Q.filtered.length>0&&Q.available&&!K.authError&&e(y)});var b=P(v,2),x=e=>{z(e,oz())};V(b,e=>{Q.servers.length===0&&!Q.filter&&!Q.loading&&!K.authError&&!Q.error&&Q.available&&e(x)});var S=P(b,2),C=e=>{z(e,sz())};V(S,e=>{Q.servers.length>0&&Q.filtered.length===0&&Q.filter&&!Q.loading&&!K.authError&&Q.available&&e(C)}),T(n),z(e,n),D()}Hr([`click`]);var uz=`api_keys`,dz=`session_sticky_keys`,fz=`base_url`,pz=`service_account_json`,mz=`models`,hz={[uz]:{label:`API Keys`,control:`keys`,hint:`Identified sessions stay on one key by default, improving provider prompt-cache hits. Saved values are shown as ***********; leave the asterisks unchanged to keep the stored key.`},[dz]:{label:`Session-sticky API keys`,control:`checkbox`,hint:`Keep each identified conversation on one API key to preserve provider prompt-cache affinity. Turn off to rotate keys round-robin on every request.`},[fz]:{label:`Base URL`,control:`text`},api_version:{label:`API Version`,control:`text`,placeholder:`e.g. 2024-10-01-preview`,hint:`Leave empty for the provider default. Realtime endpoints may need a newer version.`},backend:{label:`Backend`,control:`select`,hint:`Which Google surface to call. Vertex authenticates with Google credentials instead of an API key.`},auth_type:{label:`Auth Type`,control:`select`,hint:`How to obtain Google credentials. Leave on the default to use Application Default Credentials.`},api_mode:{label:`API Mode`,control:`select`,hint:`Which request shape to send upstream.`},vertex_project:{label:`Vertex Project`,control:`text`,placeholder:`my-gcp-project`},vertex_location:{label:`Vertex Location`,control:`text`,placeholder:`us-central1`},service_account_file:{label:`Service Account File`,control:`text`,placeholder:`/path/to/service-account.json`,hint:`Path readable by the gateway process.`},[pz]:{label:`Service Account JSON`,control:`textarea`,placeholder:`Paste service account JSON`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value, or clear it to remove.`},service_account_json_base64:{label:`Service Account JSON (base64)`,control:`text`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value.`},gcp_scope:{label:`GCP Scope`,control:`text`,placeholder:`https://www.googleapis.com/auth/cloud-platform`},[mz]:{label:`Models (comma-separated)`,control:`text`,placeholder:`gpt-4o, gpt-4o-mini`,hint:`Leave empty to auto-discover models from the provider's /models endpoint where supported.`}};function gz(e){return hz[e]||{label:String(e||``).split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),control:`text`}}function _z(){return{name:``,type:``,api_keys:[],session_sticky_keys:!0,base_url:``,api_version:``,backend:``,auth_type:``,api_mode:``,vertex_project:``,vertex_location:``,service_account_file:``,service_account_json:``,service_account_json_base64:``,gcp_scope:``,models:``,enabled:!0}}function vz(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.type,e.base_url].some(e=>String(e||``).toLowerCase().includes(r)))}function yz(e,t){let n=(Array.isArray(e)?e:[]).map(e=>String(e&&e.type||``).trim()).filter(Boolean),r=String(t||``).trim();return r&&!n.includes(r)&&n.push(r),n}function bz(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>String(e&&e.type||``).trim()===n)||null}function xz(e,t){let n=e&&Array.isArray(e.fields)&&e.fields.length>0?e.fields:Object.keys(hz).map(e=>({name:e,advanced:e!==uz})),r=t||e&&e.default_base_url||``,i=[],a=[];for(let e of n){let t=String(e&&e.name||``).trim();if(!t)continue;let n={...gz(t),name:t,required:!!(e&&e.required),options:Array.isArray(e&&e.options)?e.options:[]};t===`base_url`&&r&&(n.placeholder=r,n.hint=`Defaults to `+r),n.options.length>0&&(n.control=`select`),(e&&e.advanced?a:i).push(n)}return{primary:i,advanced:a}}var Sz=new Set([`name`,`type`,`enabled`]);function Cz(e,t){let n=new Set([...t.primary||[],...t.advanced||[]].map(e=>e.name)),r=_z(),i={...e};for(let e of Object.keys(r))!Sz.has(e)&&!n.has(e)&&(i[e]=r[e]);return i}function wz(e){let t=Array.isArray(e&&e.api_keys)?e.api_keys.length:0;return t>0?t+` key`+(t===1?``:`s`):String(e&&e.service_account_json||``).trim()||String(e&&e.service_account_json_base64||``).trim()||String(e&&e.service_account_file||``).trim()?`service account`:String(e&&e.vertex_project||``).trim()?`ADC`:`keyless`}function Tz(e){let t=Array.isArray(e&&e.models)?e.models:[];return t.length===0?`auto-discovered`:t.length+` model`+(t.length===1?``:`s`)}function Ez(e){return(Array.isArray(e)?e:[]).map(e=>({value:String(e||``)}))}function Dz(e){return(Array.isArray(e)?e:[]).map(e=>String(e&&e.value||``))}function Oz(e,t){let n=String(t||``).trim();if(!n)return``;let r=new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.name||``).trim()));if(!r.has(n))return n;let i=1;for(;r.has(n+`-`+i);)i+=1;return n+`-`+i}function kz(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),api_keys:Ez(e&&e.api_keys),session_sticky_keys:!e||e.session_sticky_keys!==!1,base_url:String(e&&e.base_url||``),api_version:String(e&&e.api_version||``),backend:String(e&&e.backend||``),auth_type:String(e&&e.auth_type||``),api_mode:String(e&&e.api_mode||``),vertex_project:String(e&&e.vertex_project||``),vertex_location:String(e&&e.vertex_location||``),service_account_file:String(e&&e.service_account_file||``),service_account_json:String(e&&e.service_account_json||``),service_account_json_base64:String(e&&e.service_account_json_base64||``),gcp_scope:String(e&&e.gcp_scope||``),models:(Array.isArray(e&&e.models)?e.models:[]).join(`, `),enabled:!e||e.enabled!==!1}}function Az(e){let t=String(e||``).trim();return t.length>=3&&/^\*+$/.test(t)}function jz(e,t,n,r){let i={},a=String(e&&e.name||``).trim();String(e&&e.type||``).trim()||(i.type=`Select a provider type.`),a?a.includes(`/`)?i.name=`Name cannot contain '/' — it separates the provider from the model.`:t===`create`&&(Array.isArray(n)?n:[]).some(e=>String(e&&e.name||``).trim()===a)&&(i.name=`Provider "`+a+`" already exists.`):i.name=`Name is required.`;let{primary:o,advanced:s}=xz(r);for(let t of[...o,...s]){let n=Mz(e,t);n&&(i[t.name]=n)}return i}function Mz(e,t){if(t.name===`api_keys`){let n=Dz(e&&e.api_keys);return t.required&&!n.some(e=>e.trim())?`At least one API key is required for this provider type.`:n.some(e=>!e.trim())?`Remove the empty row instead of leaving a key blank.`:``}let n=String(e&&e[t.name]||``).trim();if(t.required&&!n)return t.label+` is required for this provider type.`;if(!n)return``;if(t.name===`base_url`&&!n.includes(`://`)&&/[./]/.test(n))return`Include the scheme, e.g. https://`+n;if(t.name===`service_account_json`&&!Az(n))try{JSON.parse(n)}catch{return`Paste the service account JSON file's contents — this is not valid JSON.`}return``}function Nz(e,t){let n={name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),enabled:!!(e&&e.enabled)},{primary:r,advanced:i}=xz(t),a=!!(t&&Array.isArray(t.fields)&&t.fields.length>0),o=new Set;for(let t of[...r,...i])!a&&t.name===`session_sticky_keys`||(o.add(t.name),n[t.name]=Pz(e,t.name));for(let t of Object.keys(hz)){if(o.has(t)||t===`session_sticky_keys`)continue;let r=Pz(e,t);(Array.isArray(r)?r.length>0:String(r).trim()!==``)&&(n[t]=r)}return n}function Pz(e,t){switch(t){case uz:return Dz(e&&e.api_keys);case mz:return ic(e&&e.models);case dz:return!!(e&&e.session_sticky_keys);case pz:return e&&e.service_account_json||``;default:return String(e&&e[t]||``).trim()}}var $=new class{#e=k(j([]));get rows(){return I(this.#e)}set rows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get advancedOpen(){return I(this.#c)}set advancedOpen(e){A(this.#c,e,!0)}#l=k(j(_z()));get form(){return I(this.#l)}set form(e){A(this.#l,e,!0)}#u=k(j({}));get fieldErrors(){return I(this.#u)}set fieldErrors(e){A(this.#u,e,!0)}#d=k(``);get focusField(){return I(this.#d)}set focusField(e){A(this.#d,e,!0)}#f=k(``);get deletingName(){return I(this.#f)}set deletingName(e){A(this.#f,e,!0)}#p=k(!1);get deleteSubmitting(){return I(this.#p)}set deleteSubmitting(e){A(this.#p,e,!0)}#m=k(j([]));get types(){return I(this.#m)}set types(e){A(this.#m,e,!0)}#h=k(!1);get typesLoaded(){return I(this.#h)}set typesLoaded(e){A(this.#h,e,!0)}#g=null;get filteredRows(){return vz(this.rows,this.filter)}get schema(){return bz(this.types,this.form.type)}get formFields(){if(!String(this.form.type||``).trim())return{primary:[],advanced:[]};let e=this.schema;return xz(e,e&&e.default_base_url)}async fetchTypes(){let e=await _T(`/admin/provider-credentials/types`,{label:`provider credential types`});e.status===`ok`&&(this.types=e.items,this.typesLoaded=!0)}async fetchPage(){this.#g&&this.#g.abort();let e=new AbortController;this.#g=e,this.loading=!0,this.error=``;try{let t=await _T(`/admin/provider-credentials`,{label:`provider credentials`,errorFallback:`Failed to load provider credentials.`,unavailableStatuses:[503,404],options:{signal:e.signal}});if(t.status===`stale`||e.signal.aborted)return;if(t.status===`unavailable`){this.available=!1,this.rows=[];return}if(t.status===`error`){t.result&&(this.available=!0),this.rows=[],this.error=t.error;return}this.available=!0,this.rows=t.items,this.typesLoaded||await this.fetchTypes()}finally{this.#g===e&&(this.#g=null,this.loading=!1)}}#_(e,t){this.formMode=e,this.form=t,this.advancedOpen=!1,this.error=``,this.fieldErrors={},this.focusField=``}openCreate(){this.#_(`create`,_z()),this.formOpen=!0,this.typesLoaded||this.fetchTypes()}openEdit(e){!e||e.managed||(this.#_(`edit`,kz(e)),this.formOpen=!0,this.typesLoaded||this.fetchTypes())}closeForm(){this.formOpen=!1,this.#_(`create`,_z())}selectType(){this.fieldErrors={};let e=this.formFields;this.formMode===`create`&&(this.form=Cz(this.form,e));let t=e.primary.find(e=>e.name===`api_keys`);t&&t.required&&this.form.api_keys.length===0&&(this.form.api_keys=[{value:``}])}clearFieldError(e){if(this.fieldErrors[e]===void 0)return;let{[e]:t,...n}=this.fieldErrors;this.fieldErrors=n}addApiKeyRow(){this.form.api_keys.push({value:``}),this.clearFieldError(`api_keys`)}removeApiKeyRow(e){this.form.api_keys.splice(e,1),this.clearFieldError(`api_keys`)}#v(e){let t=fs(e,`Failed to save provider credential.`),n=String(e&&e.error&&typeof e.error==`object`&&e.error.param||``).trim();if(n&&this.#y(n)){this.fieldErrors={...this.fieldErrors,[n]:t},this.error=``,this.#b();return}this.error=t}#y(e){if(e===`name`||e===`type`)return!0;let{primary:t,advanced:n}=this.formFields;return[...t,...n].some(t=>t.name===e)}#b(){let e=Object.keys(this.fieldErrors);if(e.length===0)return;let{primary:t,advanced:n}=this.formFields;n.some(t=>e.includes(t.name))&&(this.advancedOpen=!0);let r=[`type`,`name`,...t.map(e=>e.name),...n.map(e=>e.name)];this.focusField=r.find(t=>e.includes(t))||e[0]}#x(){Nc.fetchModels(),Nc.fetchCategories()}async submitForm(){let e=this.schema,t=jz(this.form,this.formMode,this.rows,e);if(Object.keys(t).length>0){this.fieldErrors=t,this.error=``,this.#b();return}let n=Nz(this.form,e);this.error=``,this.fieldErrors={},this.formSubmitting=!0;try{let e=await vT(`/admin/provider-credentials`,`PUT`,n,{label:`save provider credential`,errorFallback:`Failed to save provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.error=e.error;return}if(e.status===`error`){e.result&&e.result.status!==401?this.#v(e.result.data):this.error=e.error;return}q.success(`Provider "`+n.name+`" saved.`),this.closeForm(),this.#x(),this.fetchPage()}finally{this.formSubmitting=!1}}async performDelete(e){this.deleteSubmitting=!0,this.deletingName=e;try{let t=await vT(`/admin/provider-credentials/`+encodeURIComponent(e),`DELETE`,void 0,{label:`delete provider credential`,errorFallback:`Failed to delete provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,Rs.error=t.error;return}if(t.status===`error`){Rs.error=t.error;return}q.success(`Provider "`+e+`" deleted.`),Rs.close(),this.formOpen&&this.form.name===e&&this.closeForm(),this.#x(),this.fetchPage()}finally{this.deleteSubmitting=!1,this.deletingName=``}}requestDelete(e){let t=String(e||``).trim();if(!t||this.deleteSubmitting)return;let n=(this.rows||[]).find(e=>String(e&&e.name||``).trim()===t);n&&n.managed||Rs.open({title:`Delete Provider`,titleId:`providerCredentialDeleteDialogTitle`,inputId:`provider-credential-delete-confirmation`,message:`Type "`+t+`" to permanently delete this provider credential. Requests routed to it will fail until it is reconfigured.`,requiredText:t,confirmLabel:`Delete Provider`,icon:Ao,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.performDelete(t)})}},Fz=R(`Config`),Iz=R(` `,1),Lz=R(`
      `),Rz=R(`
      NameTypeBase URLAuthModelsEnabledUpdatedActions
      `);function zz(e,t){E(t,!0);var n=Rz(),r=M(n),i=P(M(r));H(i,21,()=>$.filteredRows,e=>e.name,(e,t)=>{var n=Lz(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=e=>{z(e,Fz())};V(o,e=>{I(t).managed&&e(s)}),T(r);var c=P(r),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=M(h,!0);T(h);var _=P(h),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x,!0);T(x);var C=P(x),w=M(C),ee=M(w),te=e=>{var n=Iz(),r=N(n);{let e=O(()=>`Edit provider `+I(t).name);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>$.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>($.deletingName===I(t).name?`Deleting provider `:`Delete provider `)+I(t).name),n=O(()=>$.deletingName===I(t).name);gT(i,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>$.requestDelete(I(t).name),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)};V(ee,e=>{I(t).managed||e(te)}),T(w),T(C),T(n),F((e,n,r)=>{B(a,I(t).name),B(u,I(t).type),W(d,`title`,I(t).base_url||``),B(f,I(t).base_url||`—`),B(m,e),B(g,n),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).enabled,"auth-key-status-inactive":!I(t).enabled}),B(b,I(t).enabled?`Enabled`:`Disabled`),B(S,r)},[()=>wz(I(t)),()=>Tz(I(t)),()=>ds.formatTimestamp(I(t).updated_at)]),z(e,n)}),T(i),T(r),T(n),z(e,n),D()}var Bz=R(``),Vz=R(`
      `),Hz=R(`
      `,1),Uz=R(``),Wz=R(``),Gz=R(``),Kz=R(``),qz=R(``),Jz=R(` `),Yz=R(` `),Xz=R(`
      `);function Zz(e,t){E(t,!0);let n=O(()=>`provider-credential-`+t.field.name),r=O(()=>$.fieldErrors[t.field.name]||``),i=O(()=>I(r)?I(n)+`-error`:t.field.hint?I(n)+`-hint`:void 0),a=O(()=>{let e=String($.form[t.field.name]||``).trim();return!e||t.field.options.includes(e)?t.field.options:[...t.field.options,e]});function o(){$.clearFieldError(t.field.name)}var s=Xz(),c=M(s),l=M(c),u=P(l),d=e=>{z(e,Bz())};V(u,e=>{t.field.required&&e(d)}),T(c);var f=P(c,2),p=e=>{var t=Hz(),a=N(t);H(a,21,()=>$.form.api_keys,oi,(e,t,a)=>{var s=Vz(),c=M(s);na(c),W(c,`aria-label`,`API key `+(a+1)),gT(P(c,2),{label:`Remove API key `+(a+1),class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>$.removeApiKeyRow(a),children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(s),F(()=>{W(c,`id`,a===0?I(n):I(n)+`-`+a),W(c,`aria-invalid`,I(r)?`true`:void 0),W(c,`aria-describedby`,a===0?I(i):void 0)}),L(`input`,c,o),da(c,()=>I(t).value,e=>I(t).value=e),z(e,s)}),T(a);var s=P(a,2),c=M(s);G(M(c),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(c),T(s),F(()=>W(c,`id`,$.form.api_keys.length===0?I(n):void 0)),L(`click`,c,()=>$.addApiKeyRow()),z(e,t)},m=e=>{var s=Wz(),c=M(s);c.value=c.__value=``,H(P(c),16,()=>I(a),e=>e,(e,t)=>{var n=Uz(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(s),F(()=>{W(s,`id`,I(n)),W(s,`aria-invalid`,I(r)?`true`:void 0),W(s,`aria-describedby`,I(i))}),L(`change`,s,o),Gi(s,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,s)},h=e=>{var a=Gz();na(a),F(()=>{W(a,`id`,I(n)),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`change`,a,o),fa(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},g=e=>{var a=Kz();ft(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},_=e=>{var a=qz();na(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)};V(f,e=>{t.field.control===`keys`?e(p):t.field.control===`select`?e(m,1):t.field.control===`checkbox`?e(h,2):t.field.control===`textarea`?e(g,3):e(_,-1)});var v=P(f,2),y=e=>{var t=Jz(),i=M(t,!0);T(t),F(()=>{W(t,`id`,I(n)+`-error`),B(i,I(r))}),z(e,t)},b=e=>{var r=Yz(),i=M(r,!0);T(r),F(()=>{W(r,`id`,I(n)+`-hint`),B(i,t.field.hint)}),z(e,r)};V(v,e=>{I(r)?e(y):t.field.hint&&e(b,1)}),T(s),F(()=>{W(c,`for`,I(n)),B(l,`${t.field.label??``} `)}),z(e,s),D()}Hr([`input`,`click`,`change`]);var Qz=R(`

      The name is the stable identity used for routing and cannot change once created.

      `),$z=R(``),eB=R(` `),tB=R(`Determines which fields the gateway uses to build requests.`),nB=R(` `),rB=R(`Suggested from the selected type; used to route requests to this provider instance and editable before saving.`),iB=R(`Immutable once created.`),aB=R(`

      Pick a type to configure its credentials — each provider type asks for different settings.

      `),oB=R(`
      Advanced settings
      `),sB=R(`
      `,1);function cB(e,t){E(t,!0);let n=O(()=>yz($.types,$.form.type)),r=O(()=>$.formFields),i=O(()=>$.fieldErrors.name||``),a=O(()=>$.fieldErrors.type||``);function o(){$.selectType(),$.formMode===`create`&&($.form.name=Oz($.rows,$.form.type))}An(()=>{let e=$.focusField;if(!e)return;$.focusField=``;let t=document.getElementById(`provider-credential-`+e);t&&(t.scrollIntoView({block:`center`}),t.focus({preventScroll:!0}))});{let t=e=>{z(e,Qz())},s=O(()=>$.formMode===`edit`?`Edit Provider`:`Add Provider`);bE(e,{get open(){return $.formOpen},get title(){return I(s)},ariaLabel:`Provider credential editor`,get error(){return $.error},get submitting(){return $.formSubmitting},novalidate:!0,onclose:()=>$.closeForm(),onsubmit:()=>$.submitForm(),headerHint:t,children:(e,t)=>{var s=sB(),c=N(s),l=P(M(c),2),u=M(l);u.value=u.__value=``,H(P(u),16,()=>I(n),e=>e,(e,t)=>{var n=$z(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(l);var d=P(l,2),f=e=>{var t=eB(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)},p=e=>{z(e,tB())};V(d,e=>{I(a)?e(f):e(p,-1)}),T(c);var m=P(c,2),h=P(M(m),2);na(h);var g=P(h,2),_=e=>{var t=nB(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)},v=e=>{z(e,rB())},y=e=>{z(e,iB())};V(g,e=>{I(i)?e(_):$.formMode===`create`?e(v,1):e(y,-1)}),T(m);var b=P(m,2),x=e=>{z(e,aB())};V(b,e=>{$.form.type||e(x)});var S=P(b,2);H(S,17,()=>I(r).primary,e=>e.name,(e,t)=>{Zz(e,{get field(){return I(t)}})});var C=P(S,2),w=M(C);bA(M(w),{get enabled(){return $.form.enabled},label:`provider`,onclick:()=>$.form.enabled=!$.form.enabled}),T(w),T(C);var ee=P(C,2),te=e=>{var t=oB(),n=M(t),i=M(n),a=P(M(i),2),o=M(a,!0);T(a),T(i),T(n);var s=P(n,2);H(s,21,()=>I(r).advanced,e=>e.name,(e,t)=>{Zz(e,{get field(){return I(t)}})}),T(s),T(t),F(e=>{t.open=$.advancedOpen,B(o,e)},[()=>I(r).advanced.map(e=>e.label).join(`, `)]),Vr(`toggle`,t,e=>$.advancedOpen=e.currentTarget.open),z(e,t)};V(ee,e=>{I(r).advanced.length>0&&e(te)}),F(()=>{l.disabled=$.formMode===`edit`,W(l,`aria-invalid`,I(a)?`true`:void 0),W(l,`aria-describedby`,I(a)?`provider-credential-type-error`:`provider-credential-type-hint`),h.disabled=$.formMode===`edit`,W(h,`aria-invalid`,I(i)?`true`:void 0),W(h,`aria-describedby`,I(i)?`provider-credential-name-error`:`provider-credential-name-hint`)}),L(`change`,l,o),Gi(l,()=>$.form.type,e=>$.form.type=e),L(`input`,h,()=>$.clearFieldError(`name`)),da(h,()=>$.form.name,e=>$.form.name=e),z(e,s)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var lB=R(`

      Providers

      `),uB=R(``),dB=R(`
      Provider credential management is unavailable.
      `),fB=R(``),pB=R(`
      `),mB=R(`

      No dashboard-managed providers yet. Add one here, or declare providers in config.yaml / environment variables.

      `),hB=R(`

      No providers match your filter.

      `),gB=R(`
      `);function _B(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`providers-config`&&$.fetchPage()});var n=gB(),r=M(n),i=M(r);qS(M(i),{copyId:`providers-config-help-copy`,label:`model providers help`,title:e=>{z(e,lB())},help:e=>{Ue(),z(e,Zr(`Configure LLM provider credentials here instead of setting API keys as - environment variables. Providers declared in config.yaml or env vars - are read-only (Config badge) and cannot be edited or deleted from the - dashboard. Keys are masked after saving.`))},$$slots:{title:!0,help:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=uB();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=$.formSubmitting),L(`click`,t,()=>$.openCreate()),z(e,t)};V(o,e=>{$.available&&!K.needsAuth&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,dB())};V(c,e=>{!$.available&&!K.needsAuth&&e(l)});var u=P(c,2),d=e=>{var t=fB(),n=M(t,!0);T(t),F(()=>B(n,$.error)),z(e,t)};V(u,e=>{$.error&&!K.needsAuth&&!$.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading providers...`})};V(f,e=>{$.loading&&!K.needsAuth&&e(p)});var m=P(f,2),h=e=>{var t=pB(),n=M(t);yw(M(n),{id:`provider-credential-filter`,placeholder:`Filter by name, type, or base URL...`,label:`Filter providers by name, type, or base URL`,get value(){return $.filter},set value(e){$.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{($.rows.length>0||$.filter)&&$.available&&!K.needsAuth&&e(h)});var g=P(m,2);cB(g,{});var _=P(g,2),v=e=>{zz(e,{})};V(_,e=>{$.filteredRows.length>0&&$.available&&!K.needsAuth&&e(v)});var y=P(_,2),b=e=>{z(e,mB())};V(y,e=>{$.rows.length===0&&!$.filter&&!$.loading&&!K.needsAuth&&!$.error&&$.available&&e(b)});var x=P(y,2),S=e=>{z(e,hB())};V(x,e=>{$.rows.length>0&&$.filteredRows.length===0&&$.filter&&!$.loading&&!K.needsAuth&&$.available&&e(S)}),T(n),z(e,n),D()}Hr([`click`]);function vB(){return{name:``,description:``,user_path:``,labels:``,dashboard_access:!1,expires_at:``}}function yB(e){let t=[];for(let n of String(e||``).split(`,`)){let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function bB(e){let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t;for(let e of n.split(`/`)){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function xB(e){if(bB(e))return``;let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t,r=[];for(let e of n.split(`/`)){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function SB(e){let t=e||{},n=String(t.name||``).trim();if(!n)return{error:`Name is required.`};let r=bB(t.user_path);if(r)return{error:r};let i=xB(t.user_path),a=yB(t.labels),o={name:n,description:String(t.description||``).trim()||void 0,user_path:i||void 0,labels:a.length?a:void 0,dashboard_access:t.dashboard_access?!0:void 0};return t.expires_at&&(o.expires_at=t.expires_at+`T23:59:59Z`),{payload:o}}function CB(e,t=Date.now()){let n=e&&e.expires_at;if(!n)return!1;let r=Date.parse(n);return Number.isFinite(r)&&r<=t}function wB(e){return e?!!e.deactivated_at||e.enabled===!1:!1}function TB(e,t=Date.now()){return!e||e.active===!1||wB(e)?!1:!CB(e,t)}function EB(e){return[e.name,e.description,e.user_path,e.redacted_value,...e.labels||[]].filter(Boolean).join(` `).toLowerCase()}function DB(e,t={}){let{query:n=``,showInactive:r=!1,now:i=Date.now()}=t,a=String(n||``).trim().toLowerCase();return(Array.isArray(e)?e:[]).filter(e=>!r&&!TB(e,i)?!1:!a||EB(e).includes(a))}function OB(e,t){return wB(e)?2:+!TB(e,t)}function kB(e){let t=e&&e.expires_at;if(!t)return 1/0;let n=Date.parse(t);return Number.isFinite(n)?n:1/0}function AB(e){let t=Date.parse(e&&e.deactivated_at||``);return Number.isFinite(t)?t:-1/0}function jB(e,t=Date.now()){return(Array.isArray(e)?e.slice():[]).sort((e,n)=>{let r=OB(e,t),i=OB(n,t);if(r!==i)return r-i;let[a,o]=r===2?[AB(e),AB(n)]:[kB(e),kB(n)];return a===o?String(e.name||``).localeCompare(String(n.name||``)):a>o?-1:1})}function MB(e,t=Date.now()){return(Array.isArray(e)?e:[]).reduce((e,n)=>e+ +!TB(n,t),0)}function NB(){return{open:!1,id:``,name:``,value:``,submitting:!1,error:``}}var PB=new class{#e=k(j([]));get keys(){return I(this.#e)}set keys(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get showInactive(){return I(this.#a)}set showInactive(e){A(this.#a,e,!0)}#o=O(()=>jB(DB(this.keys,{query:this.filter,showInactive:this.showInactive})));get visibleKeys(){return I(this.#o)}set visibleKeys(e){A(this.#o,e)}#s=O(()=>MB(this.keys));get inactiveCount(){return I(this.#s)}set inactiveCount(e){A(this.#s,e)}#c=k(!1);get formOpen(){return I(this.#c)}set formOpen(e){A(this.#c,e,!0)}#l=k(!1);get formSubmitting(){return I(this.#l)}set formSubmitting(e){A(this.#l,e,!0)}#u=k(``);get issuedValue(){return I(this.#u)}set issuedValue(e){A(this.#u,e,!0)}#d=k(``);get deactivatingID(){return I(this.#d)}set deactivatingID(e){A(this.#d,e,!0)}#f=k(``);get dashboardAccessID(){return I(this.#f)}set dashboardAccessID(e){A(this.#f,e,!0)}#p=k(j(vB()));get form(){return I(this.#p)}set form(e){A(this.#p,e,!0)}#m=k(j(NB()));get labelsEditor(){return I(this.#m)}set labelsEditor(e){A(this.#m,e,!0)}copyState=_M({logPrefix:`Failed to copy auth key:`});async fetchKeys(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/auth-keys`,{label:`auth keys`,errorFallback:`Unable to load API keys.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.keys=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.error=e.error;return}this.available=!0,this.keys=e.items}finally{this.loading=!1}}openForm(){this.formSubmitting||this.formOpen||(this.formOpen=!0,this.error=``,this.issuedValue||(this.copyState.reset(),this.form=vB()))}closeForm(){this.formOpen&&(this.formOpen=!1,this.error=``,this.copyState.reset(),!this.formSubmitting&&!this.issuedValue&&(this.form=vB()))}copyIssuedValue(){return this.copyState.copy(this.issuedValue)}dismissIssuedKey(){this.issuedValue=``,this.copyState.reset(),this.form=vB()}async submitForm(){let e=SB(this.form);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/auth-keys`,`POST`,e.payload,{label:`create API key`,errorFallback:`Failed to create API key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error,t.result&&t.result.status!==401&&console.error(`Failed to create API key:`,t.result.status,this.error);return}let n=t.result.data||{};this.issuedValue=n.value||``,this.formOpen=!0,this.copyState.reset(),this.form=vB(),this.fetchKeys()}finally{this.formSubmitting=!1}}openLabelsEditor(e){!e||this.labelsEditor.submitting||(this.labelsEditor={open:!0,id:e.id,name:e.name||``,value:(e.labels||[]).join(`, `),submitting:!1,error:``})}closeLabelsEditor(){!this.labelsEditor.open||this.labelsEditor.submitting||(this.labelsEditor=NB())}async submitLabelsEditor(){let e=this.labelsEditor;if(!e.open||e.submitting||!e.id)return;e.submitting=!0,e.error=``;let t={labels:yB(e.value)};try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/labels`,`PUT`,t,{label:`update API key labels`,errorFallback:`Failed to update labels.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,e.error=n.error;return}if(n.status===`error`){e.error=n.error,n.result&&n.result.status!==401&&console.error(`Failed to update auth key labels:`,n.result.status,e.error);return}q.success(`Labels updated for key "`+e.name+`".`),e.submitting=!1,this.closeLabelsEditor(),this.fetchKeys()}finally{e.submitting=!1}}async toggleDashboardAccess(e){if(!e||!e.active||this.dashboardAccessID)return;let t=!e.dashboard_access;this.dashboardAccessID=e.id;try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/dashboard-access`,`PUT`,{dashboard_access:t},{label:`update API key dashboard access`,errorFallback:`Failed to update dashboard access.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,q.error(n.error);return}if(n.status===`error`){n.result&&n.result.status!==401&&console.error(`Failed to update auth key dashboard access:`,n.result.status,n.error),q.error(n.error);return}q.success(`Dashboard access `+(t?`granted to`:`revoked for`)+` key "`+e.name+`".`),this.fetchKeys()}finally{this.dashboardAccessID=``}}async deactivateKey(e){if(!(!e||!e.active)&&window.confirm(`Deactivate key "`+e.name+`"? This cannot be undone.`)){this.deactivatingID=e.id;try{let t=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/deactivate`,`POST`,void 0,{label:`deactivate API key`,errorFallback:`Failed to deactivate key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,q.error(t.error);return}if(t.status===`error`){t.result&&t.result.status!==401&&console.error(`Failed to deactivate auth key:`,t.result.status,t.error),q.error(t.error);return}q.success(`Key "`+e.name+`" deactivated.`),this.fetchKeys()}finally{this.deactivatingID=``}}}},FB=R(``),IB=R(`

      Store this key securely — it won’t be shown again.

      `),LB=R(``),RB=R(``),zB=R(``),BB=R(``),VB=R(`
      `);function HB(e,t){E(t,!0);{let t=O(()=>PB.issuedValue?``:PB.error),n=O(()=>PB.issuedValue?`Done, I’ve stored it`:`Create API Key`),r=O(()=>PB.issuedValue?Va:po);bE(e,{get open(){return PB.formOpen},title:`Create API Key`,ariaLabel:`API key editor`,get error(){return I(t)},get submitting(){return PB.formSubmitting},get submitLabel(){return I(n)},submittingLabel:`Creating...`,get submitIcon(){return I(r)},cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>PB.closeForm(),onsubmit:()=>PB.issuedValue?PB.dismissIssuedKey():PB.submitForm(),children:(e,t)=>{var n=Qr(),r=N(n),i=e=>{var t=IB(),n=P(M(t),2),r=M(n),i=M(r,!0);T(r),eL(P(r,2),{get state(){return PB.copyState},onclick:()=>PB.copyIssuedValue()}),T(n);var a=P(n,2),o=e=>{z(e,FB())};V(a,e=>{PB.copyState.error&&e(o)}),T(t),F(()=>B(i,PB.issuedValue)),z(e,t)},a=e=>{var t=VB(),n=M(t),r=M(n),i=P(M(r),2);na(i),T(r);var a=P(r,2),o=P(M(a),2);na(o),T(a),T(n);var s=P(n,2),c=M(s);qS(c,{copyId:`auth-key-user-path-help-copy`,label:`API key user path help`,title:e=>{z(e,LB())},help:e=>{Ue(),z(e,Zr(`When set, this key overrides the configured user path request - header for audit logging and downstream request context.`))},$$slots:{title:!0,help:!0}});var l=P(c,2);na(l),T(s);var u=P(s,2),d=M(u);qS(d,{copyId:`auth-key-labels-help-copy`,label:`API key labels help`,title:e=>{z(e,RB())},help:e=>{Ue(),z(e,Zr(`Every request authenticated with this key gets these labels, in - addition to any labels from tagging headers. Labels show up in - usage analytics, the request log, and audit logs.`))},$$slots:{title:!0,help:!0}});var f=P(d,2);na(f),T(u);var p=P(u,2),m=M(p);qS(m,{copyId:`auth-key-dashboard-access-help-copy`,label:`API key dashboard access help`,title:e=>{z(e,zB())},help:e=>{Ue(),z(e,Zr(`When off, this key is denied the dashboard and every /admin API - endpoint. Model endpoints and GET /v1/usage stay available to - the key. The master key always has dashboard access.`))},$$slots:{title:!0,help:!0}});var h=P(m,2),g=M(h);na(g),Ue(2),T(h),T(p),SE(P(p,2),{id:`auth-key-description`,label:`Description (optional)`,children:(e,t)=>{var n=BB();ft(n),da(n,()=>PB.form.description,e=>PB.form.description=e),z(e,n)},$$slots:{default:!0}}),T(t),da(i,()=>PB.form.name,e=>PB.form.name=e),da(o,()=>PB.form.expires_at,e=>PB.form.expires_at=e),da(l,()=>PB.form.user_path,e=>PB.form.user_path=e),da(f,()=>PB.form.labels,e=>PB.form.labels=e),fa(g,()=>PB.form.dashboard_access,e=>PB.form.dashboard_access=e),z(e,t)};V(r,e=>{PB.issuedValue?e(i):e(a,-1)}),z(e,n)},$$slots:{default:!0}})}D()}var UB=R(`

      `),WB=R(`

      Applies to new requests made with this key. Leave empty to remove all labels.

      `,1);function GB(e,t){E(t,!0),bE(e,{get open(){return PB.labelsEditor.open},title:`Edit Labels`,ariaLabel:`API key labels editor`,get error(){return PB.labelsEditor.error},get submitting(){return PB.labelsEditor.submitting},submitLabel:`Save Labels`,cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>PB.closeLabelsEditor(),onsubmit:()=>PB.submitLabelsEditor(),headerHint:e=>{var t=UB(),n=M(t,!0);T(t),F(()=>B(n,PB.labelsEditor.name)),z(e,t)},children:(e,t)=>{SE(e,{id:`auth-key-labels-edit`,label:`Labels (comma-separated)`,children:(e,t)=>{var n=WB(),r=N(n);na(r),Ue(2),da(r,()=>PB.labelsEditor.value,e=>PB.labelsEditor.value=e),z(e,n)},$$slots:{default:!0}})},$$slots:{headerHint:!0,default:!0}}),D()}var KB=R(` `),qB=R(`
      `),JB=R(``),YB=R(`Expired`),XB=R(` `),ZB=R(` `,1),QB=R(`Deactivated`),$B=R(`
      `),eV=R(`
      NameDescriptionUser PathLabelsTokenDashboard Access ExpiresCreated
      `);function tV(e,t){E(t,!0);var n=eV(),r=M(n),i=M(r),a=M(i),o=P(M(a),5),s=M(o);G(P(M(s)),{get icon(){return to},width:`13`,height:`13`}),T(s),T(o),Ue(3),T(a),T(i);var c=P(i);H(c,21,()=>PB.visibleKeys,e=>e.id,(e,t)=>{var n=$B();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i),s=M(o,!0);T(o);var c=P(o),l=M(c,!0);T(c);var u=P(c),d=M(u),f=e=>{var n=qB();H(n,20,()=>I(t).labels||[],e=>e,(e,t)=>{var n=KB(),r=M(n,!0);T(n),F(e=>{Hi(n,e),B(r,t)},[()=>Uy(t)]),z(e,n)}),T(n),z(e,n)},p=e=>{z(e,JB())};V(d,e=>{(I(t).labels||[]).length>0?e(f):e(p,-1)}),T(u);var m=P(u),h=M(m),g=M(h,!0);T(h),T(m);var _=P(m),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x),C=e=>{var n=XB(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{z(e,YB())},s=O(()=>CB(I(t)));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>pc(I(t).expires_at)]),z(e,n)},w=e=>{z(e,Zr(`—`))};V(S,e=>{I(t).expires_at?e(C):e(w,-1)}),T(x);var ee=P(x),te=M(ee,!0);T(ee);var ne=P(ee),re=M(ne),ie=M(re),ae=e=>{var n=ZB(),r=N(n);{let e=O(()=>(I(t).dashboard_access?`Revoke dashboard access for API key `:`Grant dashboard access to API key `)+I(t).name),n=O(()=>!!PB.dashboardAccessID);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>PB.toggleDashboardAccess(I(t)),get disabled(){return I(n)},children:(e,n)=>{{let n=O(()=>I(t).dashboard_access?wo:Co);G(e,{get icon(){return I(n)},class:`table-icon-svg`})}},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>`Edit labels for API key `+I(t).name);gT(i,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>PB.openLabelsEditor(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var a=P(i,2);{let e=O(()=>(PB.deactivatingID===I(t).id?`Deactivating API key `:`Deactivate API key `)+I(t).name),n=O(()=>PB.deactivatingID===I(t).id);gT(a,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>PB.deactivateKey(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return mo},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)},oe=e=>{var n=QB();F(e=>W(n,`title`,e),[()=>I(t).deactivated_at?`Deactivated on `+mc(I(t).deactivated_at):`Deactivated`]),z(e,n)},se=O(()=>wB(I(t)));V(ie,e=>{I(t).active?e(ae):I(se)&&e(oe,1)}),T(re),T(ne),T(n),F((e,i,o)=>{r=U(n,1,`svelte-nf0ldb`,null,r,e),B(a,I(t).name),B(s,I(t).description||`—`),B(l,I(t).user_path||`—`),B(g,I(t).redacted_value),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).dashboard_access,"auth-key-status-inactive":!I(t).dashboard_access}),B(b,I(t).dashboard_access?`Allowed`:`Denied`),W(x,`title`,i),B(te,o)},[()=>({"auth-key-row-deactivated":wB(I(t))}),()=>I(t).expires_at?mc(I(t).expires_at):``,()=>ds.formatTimestamp(I(t).created_at)]),z(e,n)}),T(c),T(r),T(n),z(e,n),D()}var nV=R(``),rV=R(`
      API key management is unavailable.
      `),iV=R(``),aV=R(`

      Managed API keys authenticate requests to the gateway. Deactivation is - permanent — create a new key if access needs to be restored.

      `),oV=R(`
      `),sV=R(`
      `),cV=R(`

      `),lV=R(`

      No API keys yet. Issue a key to get started.

      `),uV=R(`
      `);function dV(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`auth-keys`&&PB.fetchKeys()});var n=uV(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=nV();G(M(t),{get icon(){return po},class:`table-icon-svg`}),Ue(2),T(t),F(()=>t.disabled=PB.formSubmitting),L(`click`,t,()=>{PB.formSubmitting||PB.openForm()}),z(e,t)};V(a,e=>{PB.available&&!K.authError&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,rV())};V(s,e=>{!PB.available&&!K.authError&&e(c)});var l=P(s,2),u=e=>{var t=iV(),n=M(t,!0);T(t),F(()=>B(n,PB.error)),z(e,t)};V(l,e=>{PB.error&&!K.authError&&!PB.formOpen&&e(u)});var d=P(l,2),f=e=>{z(e,aV())};V(d,e=>{PB.available&&!K.authError&&e(f)});var p=P(d,2);HB(p,{});var m=P(p,2);GB(m,{});var h=P(m,2),g=e=>{var t=oV();SS(M(t),{size:18,label:`Loading API keys`}),T(t),z(e,t)};V(h,e=>{PB.loading&&PB.keys.length===0&&e(g)});var _=P(h,2),v=e=>{var t=sV(),n=M(t);yw(M(n),{placeholder:`Filter by name, description, user path, label, or token...`,label:`Filter API keys by name, description, user path, label, or token`,get value(){return PB.filter},set value(e){PB.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i);na(a);var o=P(a,2),s=P(M(o)),c=e=>{var t=Zr();F(()=>B(t,`(${PB.inactiveCount??``})`)),z(e,t)};V(s,e=>{PB.inactiveCount>0&&e(c)}),T(o),T(i),T(r),T(t),fa(a,()=>PB.showInactive,e=>PB.showInactive=e),z(e,t)};V(_,e=>{PB.keys.length>0&&PB.available&&e(v)});var y=P(_,2),b=e=>{tV(e,{})};V(y,e=>{PB.visibleKeys.length>0&&PB.available&&e(b)});var x=P(y,2),S=e=>{var t=cV(),n=M(t);T(t),F(()=>B(n,`No API keys match the current filter.${PB.inactiveCount>0&&!PB.showInactive?` `+PB.inactiveCount+` inactive `+(PB.inactiveCount===1?`key is`:`keys are`)+` hidden.`:``}`)),z(e,t)};V(x,e=>{PB.keys.length>0&&PB.visibleKeys.length===0&&PB.available&&e(S)});var C=P(x,2),w=e=>{z(e,lV())};V(C,e=>{PB.keys.length===0&&!PB.loading&&!K.authError&&!PB.error&&PB.available&&e(w)}),T(n),z(e,n),D()}Hr([`click`]);var fV=R(`

      Timezone

      `),pV=R(``),mV=R(``),hV=R(`
      `,1);function gV(e,t){E(t,!0);function n(){ds.saveOverride(),K.refresh()}function r(){ds.clearOverride(),K.refresh()}var i=hV(),a=N(i);qS(M(a),{copyId:`timezone-help-copy`,label:`timezone help`,text:`Day-based analytics, charts, and date filters use your effective timezone. Usage and audit logs keep UTC in the hover title while rendering row timestamps in your effective timezone.`,title:e=>{z(e,fV())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=P(M(s),2),l=M(c),u=M(l);T(l),l.value=l.__value=``,H(P(l),17,()=>ds.options,e=>e.value,(e,t)=>{var n=pV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(c),T(s),T(o);var d=P(o,2),f=M(d),p=e=>{var t=mV();L(`click`,t,r),z(e,t)};V(f,e=>{ds.override&&e(p)}),T(d),F(e=>B(u,`Automatic (${e??``})`),[()=>ds.detectedTimeZoneLabel()]),Vr(`focus`,c,()=>ds.ensureOptions()),L(`change`,c,n),Gi(c,()=>ds.override,e=>ds.override=e),z(e,i),D()}Hr([`change`,`click`]);var _V=R(``),vV=R(`

      Failover

      `,1);function yV(e,t){E(t,!0);let n=O(()=>Z.failoverSaving||Z.failoverGenerating||Z.failoverDraftSaving||!Z.failoverAvailable||!Z.failoverEnabled());var r=vV(),i=N(r),a=P(M(i),2),o=M(a),s=M(o);G(s,{get icon(){return Po},class:`form-action-icon`});var c=P(s,2),l=M(c,!0);T(c),T(o);var u=P(o,2);G(M(u),{get icon(){return Ao},class:`form-action-icon`}),Ue(2),T(u),T(a),T(i);var d=P(i,2),f=M(d),p=e=>{var t=_V(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(f,e=>{Z.failoverError&&e(p)}),T(d),fj(P(d,2),{}),F(()=>{o.disabled=I(n),B(l,Z.failoverGenerating?`Generating...`:`Generate failover models automatically`),u.disabled=I(n)}),L(`click`,o,()=>Z.generateFailoverRules()),L(`click`,u,()=>Z.openFailoverResetDialog()),z(e,r),D()}Hr([`click`]);function bV(){return{daily_reset_hour:0,daily_reset_minute:0,weekly_reset_weekday:1,weekly_reset_hour:0,weekly_reset_minute:0,monthly_reset_day:1,monthly_reset_hour:0,monthly_reset_minute:0}}function xV(e,t){let n=t||{},r=(e,t)=>{if(e===``)return t;let n=Number(e);return Number.isFinite(n)&&Number.isInteger(n)?Math.trunc(n):t},i=(e,t)=>r(n[e],t),a=(t,n)=>e?r(e[t],n):n;return{daily_reset_hour:a(`daily_reset_hour`,i(`daily_reset_hour`,0)),daily_reset_minute:a(`daily_reset_minute`,i(`daily_reset_minute`,0)),weekly_reset_weekday:a(`weekly_reset_weekday`,i(`weekly_reset_weekday`,1)),weekly_reset_hour:a(`weekly_reset_hour`,i(`weekly_reset_hour`,0)),weekly_reset_minute:a(`weekly_reset_minute`,i(`weekly_reset_minute`,0)),monthly_reset_day:a(`monthly_reset_day`,i(`monthly_reset_day`,1)),monthly_reset_hour:a(`monthly_reset_hour`,i(`monthly_reset_hour`,0)),monthly_reset_minute:a(`monthly_reset_minute`,i(`monthly_reset_minute`,0))}}function SV(){return[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}]}var CV=R(`

      Budget Resets

      `),wV=R(``),TV=R(`

      If the selected day does not exist in a month, the reset runs on - the last day of that month.

      `),EV=R(``),DV=R(``),OV=R(`
      Monthly
      Weekly
      Daily
      `,1);function kV(e,t){E(t,!0);let n=k(j(bV())),r=k(!1),i=k(!1),a=k(``),o=k(!1),s=O(()=>Ss.budgetsVisible());async function c(){if(await Ss.ensureLoaded(),!Ss.budgetsVisible()){A(a,``);return}A(r,!0),A(a,``);try{let e=await _s(`/admin/budgets/settings`,{label:`budget settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load budget settings.`);return}A(n,xV(e.data,I(n)),!0)}catch(e){console.error(`Failed to fetch budget settings:`,e),A(a,`Unable to load budget settings.`)}finally{A(r,!1)}}async function l(){if(!I(i)){A(i,!0);try{let e=await vs(`/admin/budgets/settings`,`PUT`,xV(I(n),I(n)),{label:`budget settings`});if(e.stale)return;if(!e.ok){q.error(`Unable to save budget settings.`);return}A(n,xV(e.data,I(n)),!0),A(a,``),q.success(`Budget settings saved.`)}catch(e){console.error(`Failed to save budget settings:`,e),q.error(`Unable to save budget settings.`)}finally{A(i,!1)}}}An(()=>{K.refreshTick,c()});var u=Qr(),d=N(u),f=e=>{var t=OV(),s=N(t),c=M(s);qS(c,{copyId:`budget-settings-help-copy`,label:`budget help`,text:`Budget reset anchors are stored in the database and evaluated in UTC. Hourly budgets reset at the top of each hour.`,title:e=>{z(e,CV())},$$slots:{title:!0}});var u=P(c,2),d=M(u),f=P(M(d),2),p=M(f);qS(p,{copyId:`budget-monthly-day-help-copy`,label:`day of month help`,external:!0,get open(){return I(o)},set open(e){A(o,e,!0)},title:e=>{z(e,wV())},$$slots:{title:!0}});var m=P(p,2);na(m),T(f);var h=P(f,2),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=M(y),x=e=>{z(e,TV())};V(b,e=>{I(o)&&e(x)}),T(y),T(d);var S=P(d,2),C=P(M(S),2),w=P(M(C),2);H(w,21,SV,e=>e.value,(e,t)=>{var n=EV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(w),T(C);var ee=P(C,2),te=P(M(ee),2);na(te),T(ee);var ne=P(ee,2),re=P(M(ne),2);na(re),T(ne),Ue(2),T(S);var ie=P(S,2),ae=P(M(ie),4),oe=P(M(ae),2);na(oe),T(ae);var se=P(ae,2),ce=P(M(se),2);na(ce),T(se),Ue(2),T(ie),T(u);var le=P(u,2),ue=M(le);G(M(ue),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(ue);var de=P(ue,2),fe=e=>{SS(e,{size:16,label:`Loading budget settings`})};V(de,e=>{I(r)&&e(fe)}),T(le),T(s);var pe=P(s,2),me=M(pe),he=e=>{var t=DV(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(me,e=>{I(a)&&e(he)}),T(pe),F(()=>{ue.disabled=I(i)||I(r),W(ue,`aria-busy`,I(i)?`true`:`false`)}),da(m,()=>I(n).monthly_reset_day,e=>I(n).monthly_reset_day=e),da(g,()=>I(n).monthly_reset_hour,e=>I(n).monthly_reset_hour=e),da(v,()=>I(n).monthly_reset_minute,e=>I(n).monthly_reset_minute=e),Gi(w,()=>I(n).weekly_reset_weekday,e=>I(n).weekly_reset_weekday=e),da(te,()=>I(n).weekly_reset_hour,e=>I(n).weekly_reset_hour=e),da(re,()=>I(n).weekly_reset_minute,e=>I(n).weekly_reset_minute=e),da(oe,()=>I(n).daily_reset_hour,e=>I(n).daily_reset_hour=e),da(ce,()=>I(n).daily_reset_minute,e=>I(n).daily_reset_minute=e),L(`click`,ue,l),z(e,t)};V(d,e=>{I(s)&&e(f)}),z(e,u),D()}Hr([`click`]);var AV=R(`

      Reset All Budgets

      Start new budget periods for every configured budget without changing - the limits.

      `);function jV(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=AV(),n=P(M(t),2),r=M(n);G(M(r),{get icon(){return go},class:`form-action-icon`}),Ue(2),T(r),T(n),T(t),F(()=>r.disabled=Y.resetAllLoading),L(`click`,r,()=>Y.openResetDialog()),z(e,t)},a=O(()=>Ss.budgetsVisible());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}Hr([`click`]);function MV(){return{header:``,prefix:``,do_not_pass:!1,delimiter:``,managed:!1}}function NV(e){return(e&&Array.isArray(e.headers)?e.headers:[]).map(e=>({header:typeof e.header==`string`?e.header:``,prefix:typeof e.prefix==`string`?e.prefix:``,do_not_pass:e.do_not_pass===!0,delimiter:typeof e.delimiter==`string`&&e.delimiter!==`,`?e.delimiter:``,managed:e.managed===!0}))}function PV(e){return{headers:(Array.isArray(e)?e:[]).filter(e=>!e.managed&&e.header.trim()!==``).map(e=>({header:e.header.trim(),prefix:e.prefix,do_not_pass:e.do_not_pass,delimiter:e.delimiter}))}}function FV(e){return e&&e.error&&e.error.message?e.error.message:``}var IV=R(`

      Tagging based on headers

      `),LV=R(`config`),RV=R(``),zV=R(`
      `),BV=R(`

      No tagging headers configured. Requests are not labelled.

      `),VV=R(``),HV=R(`
      `,1);function UV(e,t){E(t,!0);let n=k(j([])),r=k(!0),i=k(!1),a=k(!1),o=k(``);function s(){I(n).push(MV())}function c(e){let t=I(n)[e];!t||t.managed||I(n).splice(e,1)}async function l(){A(i,!0),A(o,``);try{let e=await _s(`/admin/tagging/settings`,{label:`tagging settings`});if(e.stale)return;if(!e.ok){A(o,`Unable to load tagging settings.`);return}A(n,NV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0)}catch(e){console.error(`Failed to fetch tagging settings:`,e),A(o,`Unable to load tagging settings.`)}finally{A(i,!1)}}async function u(){if(!(I(a)||!I(r))){A(a,!0);try{let e=await vs(`/admin/tagging/settings`,`PUT`,PV(I(n)),{label:`tagging settings`});if(e.stale)return;if(!e.ok){q.error(e.status!==401&&FV(e.data)||`Unable to save tagging settings.`);return}A(n,NV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0),A(o,``),q.success(`Tagging settings saved.`)}catch(e){console.error(`Failed to save tagging settings:`,e),q.error(`Unable to save tagging settings.`)}finally{A(a,!1)}}}An(()=>{K.refreshTick,l()});var d=HV(),f=N(d),p=M(f);qS(p,{copyId:`tagging-settings-help-copy`,label:`tagging help`,text:`Each request is labelled from the listed headers; labels land in usage tracking and audit logs. A header value can carry several labels split by the delimiter (default: comma). The prefix is trimmed from each label only — the header itself is forwarded unchanged unless 'Do not pass' is checked. Rows marked CONFIG come from config.yaml or TAGGING_HEADER_* env vars and are read-only here.`,title:e=>{z(e,IV())},$$slots:{title:!0}});var m=P(p,2),h=M(m);H(h,17,()=>I(n),oi,(e,t,n)=>{var i=zV(),a=M(i),o=M(a);W(o,`for`,`tagging-header-`+n);var s=P(o,2);na(s),W(s,`id`,`tagging-header-`+n),T(a);var l=P(a,2),u=M(l);W(u,`for`,`tagging-prefix-`+n);var d=P(u,2);na(d),W(d,`id`,`tagging-prefix-`+n),T(l);var f=P(l,2),p=M(f);W(p,`for`,`tagging-delimiter-`+n);var m=P(p,2);na(m),W(m,`id`,`tagging-delimiter-`+n),T(f);var h=P(f,2),g=M(h);na(g),Ue(2),T(h);var _=P(h,2),v=M(_),y=e=>{z(e,LV())},b=e=>{var i=RV();F(()=>{i.disabled=!I(r),W(i,`aria-label`,`Remove tagging header `+(I(t).header||n+1))}),L(`click`,i,()=>c(n)),z(e,i)};V(v,e=>{I(t).managed?e(y):e(b,-1)}),T(_),T(i),F(()=>{s.disabled=I(t).managed||!I(r),d.disabled=I(t).managed||!I(r),m.disabled=I(t).managed||!I(r),g.disabled=I(t).managed||!I(r)}),da(s,()=>I(t).header,e=>I(t).header=e),da(d,()=>I(t).prefix,e=>I(t).prefix=e),da(m,()=>I(t).delimiter,e=>I(t).delimiter=e),fa(g,()=>I(t).do_not_pass,e=>I(t).do_not_pass=e),z(e,i)});var g=P(h,2),_=e=>{SS(e,{size:16,label:`Loading tagging settings`})};V(g,e=>{I(i)&&e(_)});var v=P(g,2),y=e=>{z(e,BV())};V(v,e=>{!I(i)&&I(n).length===0&&e(y)}),T(m);var b=P(m,2),x=M(b);G(M(x),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(x);var S=P(x,2);G(M(S),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(S),T(b),T(f);var C=P(f,2),w=M(C),ee=e=>{var t=VV(),n=M(t,!0);T(t),F(()=>B(n,I(o))),z(e,t)};V(w,e=>{I(o)&&e(ee)}),T(C),F(()=>{x.disabled=!I(r)||I(a)||I(i),S.disabled=!I(r)||I(a)||I(i),W(S,`aria-busy`,I(a)?`true`:`false`)}),L(`click`,x,s),L(`click`,S,u),z(e,d),D()}Hr([`click`]);function WV(e){let t=e||{};if(t.selectedPreset)return{days:parseInt(t.selectedPreset,10)||30};let n=t.customStartDate?fc(t.customStartDate):``,r=t.customEndDate||t.today||null;return{start_date:n,end_date:r?fc(r):``}}function GV(e,t,n,r){return{...WV(e),user_path:String(t||``).trim(),selector:String(n||``).trim(),confirmation:r}}function KV(e){let t=Number(e&&e.matched||0),n=Number(e&&e.recalculated||0),r=Number(e&&e.without_pricing||0),i=`Pricing recalculated for `+n+` of `+t+` usage record`+(t===1?``:`s`)+`.`;return r>0&&(i+=` `+r+` usage record`+(r===1?` still lacks`:`s still lack`)+` pricing metadata.`),i}var qV=R(`

      Usage Pricing Recalculation

      `),JV=R(`
      `);function YV(e,t){E(t,!0);let n=k(``),r=k(``),i=k(!1),a=O(()=>Ss.booleanFlag(`USAGE_PRICING_RECALCULATION_ENABLED`,!1));function o(){if(!I(a)){q.error(`Usage pricing recalculation is unavailable.`);return}I(i)||Rs.open({title:`Recalculate Pricing`,titleId:`pricingRecalculateDialogTitle`,inputId:`pricing-recalculate-confirmation`,requiredText:`recalculate`,confirmLabel:`Recalculate Pricing`,icon:Ia,dialogClass:`pricing-recalculate-dialog`,message:`Stored usage cost fields matching the selected filters will be overwritten.`,onConfirm:()=>s()})}async function s(){if(!I(a)){q.error(`Usage pricing recalculation is unavailable.`);return}if(!I(i)){A(i,!0);try{let e=await vs(`/admin/usage/recalculate-pricing`,`POST`,GV({selectedPreset:Mc.selectedPreset,customStartDate:Mc.customStartDate,customEndDate:Mc.customEndDate,today:ds.todayDate()},I(n),I(r),`recalculate`),{label:`pricing recalculation`});if(e.stale)return;if(!e.ok){Rs.error=`Unable to recalculate pricing.`;return}Rs.close(),q.success(KV(e.data)),Rc.fetchUsage()}catch(e){console.error(`Failed to recalculate pricing:`,e),Rs.error=`Unable to recalculate pricing.`}finally{A(i,!1)}}}var c=Qr(),l=N(c),u=e=>{var t=JV(),s=M(t);qS(s,{copyId:`pricing-recalculate-help-copy`,label:`pricing recalculation help`,text:`Recalculate stored input, output, total, and Pro Saved costs from the current model pricing metadata. This overwrites matching historical cost fields. Filters are applied to the selected date range, user path subtree, and provider/model selector or alias.`,title:e=>{z(e,qV())},$$slots:{title:!0}});var c=P(s,2),l=M(c),u=P(M(l),2);tl(M(u),{}),T(u),T(l);var d=P(l,2),f=P(M(d),2);na(f),T(d);var p=P(d,2),m=P(M(p),2);na(m),T(p),T(c);var h=P(c,2),g=M(h);G(M(g),{get icon(){return Ia},class:`form-action-icon`}),Ue(2),T(g),T(h),T(t),F(()=>{g.disabled=I(i)||!I(a),W(g,`aria-busy`,I(i)?`true`:`false`)}),da(f,()=>I(n),e=>A(n,e)),da(m,()=>I(r),e=>A(r,e)),L(`click`,g,o),z(e,t)};V(l,e=>{I(a)&&e(u)}),z(e,c),D()}Hr([`click`]);function XV(e){return String(e&&e.status||`ok`).toLowerCase()}function ZV(e){if(!e||typeof e!=`object`)return`Runtime refresh completed.`;let t=Number(e.model_count||0),n=Number(e.provider_count||0),r=XV(e);return(r===`ok`?`Runtime refreshed.`:r===`partial`?`Runtime refresh completed with warnings.`:`Runtime refresh failed.`)+` `+t+` model`+(t===1?``:`s`)+` across `+n+` provider`+(n===1?``:`s`)+`.`}function QV(e){return!!e&&XV(e)===`ok`}function $V(e){let t=e&&e.steps;return Array.isArray(t)?t:[]}function eH(e){let t=String(e&&e.name||``).replace(/_/g,` `),n=String(e&&e.status||``).trim(),r=String(e&&(e.error||e.message)||``).trim();return t?r?t+`: `+n+` - `+r:t+`: `+n:r||n||``}var tH=R(`

      Runtime Refresh

      `),nH=R(`
    • `),rH=R(`
        `),iH=R(`
        `,1);function aH(e,t){E(t,!0);let n=k(!1),r=k(null);async function i(){if(!I(n)){A(n,!0),A(r,null);try{let e=await vs(`/admin/runtime/refresh`,`POST`,void 0,{label:`runtime refresh`});if(e.stale)return;if(!e.ok){q.error(`Runtime refresh failed.`);return}A(r,e.data&&typeof e.data==`object`?e.data:null,!0),QV(I(r))?q.success(ZV(I(r))):q.error(ZV(I(r))),K.refresh()}catch(e){console.error(`Failed to refresh runtime:`,e),q.error(`Runtime refresh failed.`)}finally{A(n,!1)}}}var a=iH(),o=N(a),s=M(o);qS(s,{copyId:`runtime-refresh-help-copy`,label:`runtime refresh help`,text:`Pull the latest model metadata, provider inventory, API keys, aliases, model access rules, guardrails, and workflows.`,title:e=>{z(e,tH())},$$slots:{title:!0}});var c=P(s,2),l=M(c);let u;G(M(l),{get icon(){return ho},class:`settings-refresh-icon`}),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=M(d),p=e=>{var t=rH();H(t,21,()=>$V(I(r)),e=>e.name,(e,t)=>{var n=nH(),r=M(n,!0);T(n),F(e=>{U(n,1,`runtime-refresh-step is-${I(t).status??``}`,`svelte-yeq2mp`),B(r,e)},[()=>eH(I(t))]),z(e,n)}),T(t),z(e,t)},m=O(()=>$V(I(r)).length>0);V(f,e=>{I(m)&&e(p)}),T(d),F(()=>{u=U(l,1,`btn btn-primary btn-with-icon settings-refresh-btn`,null,u,{"is-refreshing":I(n)}),l.disabled=I(n),W(l,`aria-busy`,I(n)?`true`:`false`)}),L(`click`,l,i),z(e,a),D()}Hr([`click`]);var oH=R(``),sH=R(`

        `),cH=R(`

        `),lH=R(``),uH=R(`
        `),dH=R(`

        AI Processing

        `);function fH(e,t){E(t,!0);let n=k(j([])),r=k(!1),i=k(``),a=k(``);async function o(){A(r,!0),A(a,``);try{let e=await _s(`/admin/runtime/settings`,{label:`runtime settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load runtime settings.`);return}A(n,Array.isArray(e.data?.settings)?e.data.settings:[],!0)}catch(e){console.error(`Failed to load runtime settings:`,e),A(a,`Unable to load runtime settings.`)}finally{A(r,!1)}}async function s(e,t,r){if(!(e.locked||I(i))){A(i,e.key,!0);try{let i=await vs(`/admin/runtime/settings/${encodeURIComponent(e.key)}`,`PUT`,{value:t},{label:`save ${e.label}`});if(i.stale){r.value=e.value;return}if(!i.ok){r.value=e.value,q.error(`Unable to save ${e.label}.`);return}A(n,I(n).map(t=>t.key===e.key?i.data:t),!0),q.success(`${e.label} saved.`)}catch(t){r.value=e.value,console.error(`Failed to save runtime setting:`,t),q.error(`Unable to save ${e.label}.`)}finally{A(i,``)}}}An(()=>{K.refreshTick,o()});var c=Qr(),l=N(c),u=e=>{var t=dH(),o=M(t),c=P(M(o),2),l=e=>{var t=oH(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(c,e=>{I(a)&&e(l)}),T(o);var u=P(o,2);H(u,21,()=>I(n),e=>e.key,(e,t)=>{var n=uH(),r=M(n),a=M(r),o=M(a,!0);T(a);var c=P(a,2),l=e=>{var n=sH(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(c,e=>{I(t).description&&e(l)});var u=P(c,2),d=e=>{var n=cH(),r=M(n);T(n),F(()=>B(r,`Managed by ${(I(t).managed_by||`environment`)??``}`)),z(e,n)};V(u,e=>{I(t).locked&&e(d)}),T(r);var f=P(r,2);H(f,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=lH(),r=M(n,!0);T(n);var i={};F(()=>{W(n,`title`,I(t).description||``),B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(f);var p;Wi(f),T(n),F(()=>{W(a,`for`,`runtime-setting-${I(t).key}`),B(o,I(t).label),W(f,`id`,`runtime-setting-${I(t).key}`),f.disabled=I(t).locked||I(i)!==``,p!==(p=I(t).value)&&(f.value=(f.__value=I(t).value)??``,Ui(f,I(t).value))}),L(`change`,f,e=>s(I(t),e.currentTarget.value,e.currentTarget)),z(e,n)}),T(u),T(t),F(()=>W(u,`aria-busy`,I(r)?`true`:`false`)),z(e,t)};V(l,e=>{(I(n).length>0||I(a))&&e(u)}),z(e,c),D()}Hr([`change`]);var pH=R(`
        `);function mH(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`settings`&&(ds.ensureOptions(),Ss.ensureLoaded())});var n=pH(),r=P(M(n),2),i=M(r);gV(i,{});var a=P(i,2);yV(a,{});var o=P(a,2);kV(o,{});var s=P(o,2);jV(s,{});var c=P(s,2);UV(c,{});var l=P(c,2);fH(l,{});var u=P(l,2);YV(u,{}),aH(P(u,2),{}),T(r);var d=P(r,2),f=M(d,!0);T(d),T(n),F(e=>B(f,e),[()=>Uo()]),z(e,n),D()}var hH=R(`
         
        `),gH=R(`
         
        `),_H=R(`
        `),vH=R(`
        `),yH=R(`
        `,1),bH=R(`
        `);function xH(e,t){E(t,!0);let n=O(()=>t.msg.role===`function_call`||t.msg.role===`function_result`);function r(e){return e.role===`function_call`?(e.toolCalls||[]).map(e=>e.name+`()`).join(`, `):(e.functionName?e.functionName+`: `:``)+e.text}var i=bH(),a=M(i),o=e=>{var n=hH(),i=M(n),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(i);var l=P(i,2),u=M(l,!0);T(l),T(n),F((e,n)=>{B(o,t.msg.roleLabel),B(c,e),B(u,n)},[()=>r(t.msg),()=>RI(t.msg)]),z(e,n)},s=e=>{var n=yH(),r=N(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(r);var c=P(r,2),l=e=>{var n=gH(),r=M(n,!0);T(n),F(()=>B(r,t.msg.text)),z(e,n)};V(c,e=>{t.msg.text&&e(l)});var u=P(c,2),d=e=>{var n=vH();H(n,23,()=>t.msg.toolCalls,(e,t)=>e.name+`-`+t,(e,t)=>{var n=_H(),r=M(n),i=M(r,!0);T(r),T(n),F(()=>B(i,I(t).name+`()`)),z(e,n)}),T(n),z(e,n)};V(u,e=>{t.msg.toolCalls&&e(d)}),F(e=>{B(a,t.msg.roleLabel),B(s,e)},[()=>ds.formatTimestamp(t.msg.timestamp)]),z(e,n)};V(a,e=>{I(n)?e(o):e(s,-1)}),T(i),F(()=>{U(i,1,Fi([I(n)?`chat-function-note`:`chat-message`,t.msg.roleClass,{"is-anchor":t.msg.isAnchor,"is-after-anchor":t.msg.isAfterAnchor}]),`svelte-12s99s5`),W(i,`data-conversation-anchor`,t.msg.isAnchor?`true`:void 0),W(i,`data-entry-id`,t.msg.entryID)}),z(e,i),D()}function SH(e,t=0){let n=Math.max(0,TH(e)-Math.max(0,TH(t))),r=Math.min(320,Math.max(180,Math.floor(n*.58))),i=Math.min(360,Math.max(128,Math.floor(n*.35)));return{min:r,max:Math.max(r,n-i)}}function CH(e,t,n=0){let r=SH(t,n),i=TH(e)||520;return Math.min(r.max,Math.max(r.min,Math.round(i)))}function wH(e,t,n=0){return CH(TH(t)-TH(e),t,n)}function TH(e){let t=Number(e);return Number.isFinite(t)?t:0}var EH=R(`
        `),DH=R(`

        Loading interactions...

        `),OH=R(`

        No interaction data available for this entry.

        `),kH=R(`
        `),AH=R(`

        Showing the newest part of this session and the selected log.

        `),jH=R(`
        `),MH=R(``),NH=R(`
        `),PH=R(``),FH=R(``);function IH(e,t){E(t,!0);let n=KI,r=Number(Ta(`gomodel_interactions_panel_width`)),i=Number.isFinite(r)&&r>0?r:520,a=k(j(i)),o=k(320),s=k(760),c=k(!1),l=null;function u(){return(document.querySelector(`.sidebar`)?.getBoundingClientRect().width||0)+(document.querySelector(`.sidebar-toggle`)?.getBoundingClientRect().width||0)}function d(){let e=u(),t=SH(window.innerWidth,e);A(o,t.min,!0),A(s,t.max,!0),A(a,CH(i,window.innerWidth,e),!0)}function f(e){A(a,wH(e,window.innerWidth,u()),!0),i=I(a)}function p(e){e.button===0&&(e.preventDefault(),l=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`conversation-panel-resizing`),f(e.clientX))}function m(e){e.pointerId===l&&f(e.clientX)}function h(e){l===null||e.pointerId!==void 0&&e.pointerId!==l||(l=null,document.body.classList.remove(`conversation-panel-resizing`),Ea(`gomodel_interactions_panel_width`,i))}function g(e){e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),i=I(a)+(e.key===`ArrowLeft`?24:-24),d(),i=I(a),Ea(`gomodel_interactions_panel_width`,i))}function _(){return[document.querySelector(`.sidebar`),document.querySelector(`.sidebar-toggle`),document.getElementById(`dashboard-content`)].filter(Boolean)}An(()=>{if(!n.conversationOpen)return;d();let e=document.querySelector(`.sidebar`),t=new ResizeObserver(d);e&&t.observe(e);let r=e=>{e.key===`Escape`&&!ja.anyOpen&&(I(c)?A(c,!1):n.closeConversation())};return window.addEventListener(`keydown`,r),window.addEventListener(`resize`,d),()=>{h({}),t.disconnect(),window.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,d)}}),An(()=>{n.conversationOpen||A(c,!1)}),An(()=>{if(!I(c))return;let e=_().map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));return e.forEach(({element:e})=>{e.inert=!0,e.setAttribute(`aria-hidden`,`true`)}),()=>{e.forEach(({element:e,inert:t,ariaHidden:n})=>{e.inert=t,n===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)})}}),An(()=>{Jo.page!==`audit-logs`&&n.conversationOpen&&n.closeConversation()});var v=Qr(),y=N(v),b=e=>{var t=FH();let r,i;var l=M(t),u=P(l,2),d=P(M(u),2),f=M(d),_=M(f);{let e=O(()=>I(c)?so:oo);G(_,{get icon(){return I(e)},class:`table-icon-svg`})}T(f),ks(P(f,2),{label:`Close interactions`,onclick:()=>n.closeConversation(),get el(){return n.conversationCloseBtnEl},set el(e){n.conversationCloseBtnEl=e}}),T(d),T(u);var v=P(u,2),y=M(v),b=e=>{var t=EH(),r=M(t,!0);T(t),F(()=>B(r,n.conversationError)),z(e,t)};V(y,e=>{n.conversationError&&e(b)});var x=P(y,2),S=e=>{z(e,DH())};V(x,e=>{n.conversationLoading&&e(S)});var C=P(x,2),w=e=>{z(e,OH())},ee=O(()=>!n.conversationLoading&&!n.followUpSending&&!n.conversationError&&n.conversationMessages.length===0&&!n.conversationLiveWaiting());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{var t=kH();H(t,21,()=>n.conversationMessages,e=>e.uid,(e,t)=>{xH(e,{get msg(){return I(t)}})}),T(t),ga(t,e=>n.conversationThreadEl=e,()=>n?.conversationThreadEl),z(e,t)};V(te,e=>{n.conversationMessages.length>0&&e(ne)});var re=P(te,2),ie=e=>{z(e,AH())};V(re,e=>{n.conversationTruncated&&e(ie)});var ae=P(re,2),oe=e=>{var t=jH(),r=P(M(t),2),i=M(r,!0);T(r),T(t),F(e=>B(i,e),[()=>n.conversationLiveStatusText()]),z(e,t)},se=O(()=>n.conversationLiveWaiting());V(ae,e=>{I(se)&&e(oe)}),T(v);var ce=P(v,2),le=e=>{var t=PH(),r=M(t),i=e=>{var t=NH(),r=P(M(t),2);ft(r);var i=P(r,2),a=e=>{var t=MH(),r=M(t,!0);T(t),F(()=>B(r,n.followUpError)),z(e,t)};V(i,e=>{n.followUpError&&e(a)});var o=P(i,2),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l),T(o),T(t),F((e,t,i)=>{r.disabled=e,B(c,t),l.disabled=i,B(u,n.followUpSending?`Sending…`:`Send`)},[()=>n.followUpSending||n.conversationLiveWaiting(),()=>n.selectedConversationEntry()?.path||``,()=>!n.canSendFollowUp()]),Vr(`submit`,t,e=>{e.preventDefault(),n.sendFollowUp()}),da(r,()=>n.followUpText,e=>n.followUpText=e),z(e,t)},a=O(()=>n.followUpKind());V(r,e=>{I(a)&&e(i)});var o=P(r,2),s=M(o,!0);T(o),T(t),F(()=>B(s,n.conversationFollowLatest?`Following latest interaction`:`Opened from log: `+n.conversationOpenedFromID)),z(e,t)};V(ce,e=>{n.conversationAnchorID&&e(le)}),T(t),ga(t,e=>n.conversationDialogEl=e,()=>n?.conversationDialogEl),F(()=>{r=U(t,1,`conversation-drawer svelte-ssrzja`,null,r,{"conversation-drawer-fullscreen":I(c)}),W(t,`role`,I(c)?`dialog`:void 0),W(t,`aria-modal`,I(c)?`true`:void 0),i=Hi(t,``,i,{"--conversation-panel-width":I(a)+`px`}),W(l,`aria-valuemin`,I(o)),W(l,`aria-valuemax`,I(s)),W(l,`aria-valuenow`,I(a)),W(f,`aria-label`,I(c)?`Exit fullscreen interactions`:`Show interactions fullscreen`),W(f,`title`,I(c)?`Exit fullscreen`:`Fullscreen`),W(f,`aria-pressed`,I(c))}),L(`pointerdown`,l,p),L(`pointermove`,l,m),L(`pointerup`,l,h),Vr(`pointercancel`,l,h),Vr(`lostpointercapture`,l,h),L(`keydown`,l,g),L(`click`,f,()=>A(c,!I(c))),z(e,t)};V(y,e=>{n.conversationOpen&&e(b)}),z(e,v),D()}Hr([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`click`]);var LH=R(`
        `,1);function RH(e,t){E(t,!0);let n={overview:_C,usage:fT,budgets:HE,"rate-limits":$D,models:Fj,workflows:nP,"audit-logs":IL,guardrails:kR,"mcp-servers":lz,"providers-config":_B,"auth-keys":dV,settings:mH};ds.init(),Mc.init(),K.init(),ka.init(),Aa.init(),Jo.init(),An(()=>{K.refreshTick,Ss.fetch(),Nc.fetchModels(),Nc.fetchCategories()}),An(()=>{document.body.classList.toggle(`dashboard-modal-open`,ja.anyOpen)});let r=O(()=>n[Jo.page]||_C);var i=LH(),a=N(i);Ds(a,{});var o=P(a,2);let s;var c=M(o);rc(c,{}),_i(P(c,2),()=>I(r),(e,t)=>{t(e,{})}),T(o);var l=P(o,2);IH(l,{});var u=P(l,2);Is(u,{});var d=P(u,2);Hs(d,{}),tc(P(d,2),{}),F(()=>s=U(o,1,`content`,null,s,{"interactions-open":KI.conversationOpen})),z(e,i),D()}ti(RH,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/admin/dashboard/static/dist/assets/index-Cz8GQupq.css b/internal/admin/dashboard/static/dist/assets/index-BbSfRjie.css similarity index 92% rename from internal/admin/dashboard/static/dist/assets/index-Cz8GQupq.css rename to internal/admin/dashboard/static/dist/assets/index-BbSfRjie.css index bae414a2e..276dd3b4c 100644 --- a/internal/admin/dashboard/static/dist/assets/index-Cz8GQupq.css +++ b/internal/admin/dashboard/static/dist/assets/index-BbSfRjie.css @@ -1 +1 @@ -:root{--bg:#111110;--bg-surface:#1e1d1c;--bg-surface-hover:#2a2420;--border:#2a2826;--text:#e8e0d6;--text-muted:#9a918a;--accent:#b8956e;--accent-hover:#d4b896;--success:#34d399;--info:#3b82f6;--warning:#f59e0b;--danger:#ef4444;--prompt-cache-color:color-mix(in srgb, var(--info) 72%, #fff);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 24%, var(--bg-surface));--cache-meter-uncached:var(--token-input);--cache-meter-local:var(--token-local);--cache-meter-prompt:var(--token-prompt);--token-input:#c0824a;--token-output:#ddb27a;--token-prompt:color-mix(in srgb, var(--info) 60%, transparent);--token-local:color-mix(in srgb, var(--info) 20%, transparent);--sidebar-width:240px;--radius:8px;--chart-grid:#2a2826;--chart-text:#9a918a;--chart-day-marker:var(--text);--chart-tooltip-bg:#1e1d1c;--chart-tooltip-border:#2a2826;--chart-tooltip-text:#e8e0d6;--cal-level-0:#161b22;--cal-level-1:color-mix(in srgb, var(--info) 15%, var(--bg-surface));--cal-level-2:color-mix(in srgb, var(--info) 25%, var(--bg-surface));--cal-level-3:color-mix(in srgb, var(--info) 36%, var(--bg-surface));--cal-level-4:color-mix(in srgb, var(--info) 48%, var(--bg-surface));--cal-level-5:color-mix(in srgb, var(--info) 60%, var(--bg-surface));--cal-level-6:color-mix(in srgb, var(--info) 73%, var(--bg-surface));--cal-level-7:color-mix(in srgb, var(--info) 87%, var(--bg-surface));--cal-level-8:var(--info);--cal-level-9:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-10:color-mix(in srgb, var(--info) 62%, #fff);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface-hover) 86%, #fff 14%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface-hover) 72%, #fff 28%);--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}[data-theme=light]{--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}@media (prefers-color-scheme:light){:root:not([data-theme=dark]){--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}}*{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;line-height:1.5}body.dashboard-modal-open{overflow:hidden}.app{height:100vh;min-height:0;display:flex;overflow:hidden}.badge{background:var(--accent);color:#fff;text-transform:uppercase;letter-spacing:.5px;border-radius:10px;padding:2px 8px;font-size:10px;font-weight:600}.auth-dialog{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:min(440px,100%);padding:22px;box-shadow:0 24px 70px #00000061}.auth-dialog-header{justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px;display:flex}.auth-dialog h2{margin-top:2px;font-size:22px;line-height:1.2}.auth-dialog-close{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.auth-dialog-close:hover{color:var(--text);background:var(--bg-surface-hover)}.auth-dialog-close:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-hint{color:var(--text-muted);font-size:13px}.auth-dialog-error{color:var(--danger);font-size:13px;font-weight:600}.auth-dialog-form{gap:10px;margin-top:18px;display:grid}.auth-dialog-actions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}.content{-webkit-overflow-scrolling:touch;flex:1 1 0;width:100%;min-width:0;min-height:0;padding:32px;transition:width .2s;overflow-y:auto;container:dashboard-content/inline-size}.content>*{width:100%;max-width:1336px;margin-inline:auto}body.dashboard-modal-open .content{overflow-y:hidden}.content.interactions-open>*{max-width:none}.page-header{justify-content:space-between;align-items:center;margin-bottom:24px;display:flex}.page-header h2{letter-spacing:-.3px;font-size:22px;font-weight:700}.page-header-controls{align-items:center;gap:12px;display:flex}.page-with-sticky-date{grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:12px;display:grid}.page-with-sticky-date>*{grid-column:1/-1}.page-with-sticky-date>.date-range-page-header{grid-column:1}.page-with-sticky-date>.sticky-date-range{z-index:8;grid-column:2;justify-self:end;position:sticky;top:16px}.model-count{color:var(--text-muted);font-size:14px}.provider-status-section{margin-top:28px;scroll-margin-top:24px}.cards{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:28px;display:grid}.card{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px}.card-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);margin-bottom:8px;font-size:12px;font-weight:600}.card-value{letter-spacing:-.5px;font-size:28px;font-weight:700}.cache-meter{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:28px;padding:24px}.chart-container{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.chart-container h3{margin-bottom:16px;font-size:16px;font-weight:600}.chart-container-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;display:flex}.chart-container-header h3{margin-bottom:0}.chart-wrapper{height:210px;position:relative}.live-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:8px;height:8px}.live-dot.is-streaming{background:var(--success);position:relative}.live-dot.is-streaming:after{content:"";z-index:-1;background:color-mix(in srgb, var(--success) 55%, transparent);border-radius:50%;animation:1.8s ease-out infinite live-dot-pulse;position:absolute;inset:0}@media (prefers-reduced-motion:reduce){.live-dot.is-streaming:after{opacity:0;animation:none}}@keyframes live-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(2.5)}to{opacity:0;transform:scale(2.5)}}.alert{border-radius:var(--radius);margin-bottom:20px;padding:12px 16px;font-size:14px}.alert-warning{color:var(--warning);background:#f59e0b1a;border:1px solid #f59e0b4d}.table-toolbar{align-items:center;gap:12px;margin-bottom:16px;display:flex}.table-toolbar-main{flex:1;min-width:0}.table-toolbar-actions{justify-content:flex-end;margin-left:auto;display:flex}input:is([type=text],[type=date],[type=number]){background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:8px 12px;font-family:inherit;font-size:13px}input:is([type=text],[type=date],[type=number]):focus{border-color:var(--accent)}input:is([type=text],[type=date],[type=number]):disabled,textarea:disabled,.form-input:disabled{opacity:.6;cursor:not-allowed}.table-wrapper{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}.data-table{border-collapse:collapse;width:100%;font-size:14px}.data-table th{text-align:left;text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);background:var(--bg);border-bottom:1px solid var(--border);padding:12px 16px;font-size:12px;font-weight:600}.data-table th.model-actions-header{text-align:right;white-space:nowrap;width:1%;min-width:156px}.data-table td{border-bottom:1px solid var(--border);padding:10px 16px}.data-table tr:last-child td{border-bottom:none}.data-table tr:hover td{background:var(--bg-surface-hover)}.mono{font-family:SF Mono,Menlo,Consolas,monospace}.font-size-md{font-size:13px}.col-price,.data-table th.col-price{text-align:right}td.col-price{color:var(--text-muted);white-space:nowrap;font-family:SF Mono,Menlo,Consolas,monospace;font-size:13px}.provider-badge{background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:2px 10px;font-size:12px;font-weight:500;display:inline-block}.empty-state{text-align:center;color:var(--text-muted);padding:48px 0;font-size:14px}.empty-state-icon{width:auto;height:auto;max-height:160px;color:var(--text-muted);margin:0 auto;display:block}.empty-state-icon text{fill:var(--text-muted);font-family:inherit;font-weight:600}.chart-empty-overlay{pointer-events:none;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.chart-empty-overlay .empty-state-icon{width:auto;max-width:90%;height:auto;max-height:195px}.loading-spinner{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:16px;height:16px;animation:.8s linear infinite loading-spin}@keyframes loading-spin{to{transform:rotate(360deg)}}.table-action-btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;gap:6px;padding:6px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:inline-flex}.table-action-btn:hover:not(:disabled){background:var(--bg-surface-hover)}.table-action-btn:disabled{opacity:.45;cursor:default}.table-action-btn-danger{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.table-action-btn-active{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 12%, var(--bg));border-color:color-mix(in srgb, var(--accent) 38%, var(--border))}.table-action-btn-active:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 18%, var(--bg-surface-hover))}.table-action-btn-failover-active{color:var(--info);background:color-mix(in srgb, var(--cache-meter-prompt) 35%, var(--bg));border-color:color-mix(in srgb, var(--info) 45%, var(--border));position:relative}.table-action-btn-failover-active:hover:not(:disabled){background:color-mix(in srgb, var(--cache-meter-prompt) 45%, var(--bg-surface-hover))}.table-icon-btn{border-radius:6px;gap:0;width:32px;min-width:32px;height:32px;padding:0}.table-icon-btn.table-action-btn-active{position:relative}.table-icon-btn.table-action-btn-active:after{content:"";background:var(--accent);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-btn.table-action-btn-failover-active:after{content:"";background:var(--info);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-svg{flex-shrink:0;width:14px;height:14px}.model-editor{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:16px;padding:24px}.alias-kind-badge{border:1px solid var(--border);background:var(--bg);min-height:24px;color:var(--accent);letter-spacing:.2px;text-transform:uppercase;border-color:color-mix(in srgb, var(--accent) 55%, var(--border));border-radius:999px;justify-content:center;align-items:center;gap:4px;padding:0 10px;font-size:11px;font-weight:600;display:inline-flex}.form h3{font-size:20px;font-weight:700}.form-kicker,.form-hint{color:var(--text-muted);font-size:13px}.alias-actions-cell{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.model-list-actions{white-space:nowrap;flex-wrap:nowrap}.model-list-actions .table-icon-btn{flex:0 0 32px}.model-list-actions .alias-toggle{flex:none}.alias-toggle{border:1px solid var(--border);background:var(--bg);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:8px;padding:6px 10px;font-family:inherit;font-size:12px;transition:all .15s;display:inline-flex}.alias-toggle:hover:not(:disabled){background:var(--bg-surface-hover)}.alias-toggle:disabled{opacity:.45;cursor:default}.alias-toggle-track{background:color-mix(in srgb, var(--border) 80%, var(--bg));border-radius:6px;width:34px;height:18px;transition:background .15s;position:relative}.alias-toggle-thumb{background:var(--text-muted);border-radius:6px;width:16px;height:16px;transition:transform .15s,background .15s;position:absolute;top:1px;left:2px}.alias-toggle.enabled{border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.alias-toggle.enabled .alias-toggle-track{background:color-mix(in srgb, var(--success) 55%, var(--bg))}.alias-toggle.enabled .alias-toggle-thumb{background:#fff;transform:translate(14px)}.alias-toggle.restricted{border-color:color-mix(in srgb, var(--accent) 50%, var(--border));color:color-mix(in srgb, var(--accent) 70%, var(--text))}.alias-toggle.restricted .alias-toggle-track{background:color-mix(in srgb, var(--accent) 55%, var(--bg))}.editor-header{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:20px;display:flex}.form{flex-direction:column;gap:16px;display:flex}.auth-key-editor{background:color-mix(in srgb, var(--bg-surface) 82%, var(--bg) 18%)}.form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.form-field{flex-direction:column;gap:8px;display:flex}.form-field-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);font-size:12px;font-weight:600;display:inline-block}.vm-target-row{align-items:center;gap:8px;display:flex}.vm-target-row .vm-target-model{flex:auto;min-width:0}.vm-target-row .vm-target-weight{flex:0 0 88px;width:88px}.vm-status-row{justify-content:space-between;align-items:center;gap:12px;display:flex}.vm-status-row .vm-status-toggle{margin-left:auto}.form-error{border:1px solid color-mix(in srgb, var(--danger) 42%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface));color:var(--danger);overflow-wrap:anywhere;margin:0;padding:10px 12px;font-size:13px;font-weight:600;line-height:1.4}.form-error:empty{display:none}.form-field-error{color:var(--danger);overflow-wrap:anywhere;font-size:13px;font-weight:500;line-height:1.4}.form-field-required{color:var(--danger);margin-left:3px}:is(input,textarea,select)[aria-invalid=true]{border-color:color-mix(in srgb, var(--danger) 60%, var(--border))}:is(input,textarea,select)[aria-invalid=true]:focus{border-color:var(--danger)}textarea{resize:vertical;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:60px;color:var(--text);outline:none;padding:10px 12px;font-family:inherit;font-size:13px}textarea:focus{border-color:var(--accent)}.form-input{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:38px;color:var(--text);outline:none;padding:8px 10px;font-family:inherit;font-size:13px}.form-input:focus{border-color:var(--accent)}.form-actions{flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:16px;display:flex}.failover-target-actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.data-table tr.alias-row.is-valid td{background:var(--alias-row-valid-bg)}.data-table tr.alias-row.is-valid:hover td{background:var(--alias-row-valid-bg-hover)}.data-table tr.alias-row:not(.is-valid) td{background:color-mix(in srgb, var(--accent) 10%, var(--bg-surface))}.data-table tr.alias-row:not(.is-valid):hover td{background:color-mix(in srgb, var(--accent) 16%, var(--bg-surface-hover))}.data-table tr.alias-row.is-disabled td{background:var(--bg-surface);opacity:.58}.data-table tr.alias-row.is-disabled:hover td{background:var(--bg-surface-hover);opacity:.72}.data-table tr.model-access-disabled-row td{background:color-mix(in srgb, var(--danger) 6%, var(--bg-surface))}.data-table tr.model-access-disabled-row:hover td{background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface-hover))}.workflow-section-head{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-section-head h4{font-size:14px;font-weight:700}.workflow-preview{flex-direction:column;gap:12px;display:flex}.workflow-feature-toggles{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.workflow-feature-toggle{border:1px solid var(--border);background:var(--bg);border-radius:10px;align-items:center;gap:10px;padding:10px 12px;font-size:14px;font-weight:500;display:flex}.workflow-feature-toggle input{width:16px;height:16px}.model-chart-section{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:24px;padding:24px}.model-chart-section h3{margin:0;font-size:16px;font-weight:600}.model-chart-header{justify-content:space-between;align-items:center;gap:16px;margin-bottom:16px;display:flex}.bar-chart-wrap{width:100%;height:180px;position:relative}.form-select,.usage-log-select{appearance:none;background-color:var(--bg);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 17px),calc(100% - 12px);background-repeat:no-repeat;background-size:5px 5px;outline:none;min-width:140px;padding:8px 34px 8px 12px;font-family:inherit;font-size:13px}.form-select:disabled,.usage-log-select:disabled{cursor:not-allowed;opacity:.6}.form-select:focus,.usage-log-select:focus{border-color:var(--accent)}.form-select{width:100%;min-width:0}.usage-label-chips{flex-wrap:wrap;gap:4px;max-width:280px;display:inline-flex}.usage-label-chip{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg));min-height:20px;color:var(--text);white-space:nowrap;cursor:pointer;border-radius:999px;align-items:center;padding:1px 9px;font-family:inherit;font-size:11px;font-style:normal;font-weight:600;line-height:1.4;transition:background .15s,border-color .15s;display:inline-flex}.usage-label-chip:hover{background:color-mix(in srgb, var(--label-color,var(--accent)) 26%, var(--bg))}.usage-label-chip.active{background:color-mix(in srgb, var(--label-color,var(--accent)) 32%, var(--bg));border-color:var(--label-color,var(--accent));box-shadow:0 0 0 1px color-mix(in srgb, var(--label-color,var(--accent)) 55%, transparent)}@keyframes audit-live-summary-stripe-blink{0%,to{opacity:.9}50%{opacity:.28}}.audit-status-badge{border:1px solid var(--border);letter-spacing:.2px;background:var(--bg-surface);border-radius:999px;justify-content:center;align-items:center;min-width:46px;height:24px;padding:0 10px;font-size:12px;font-weight:600;display:inline-flex}.audit-status-badge.status-success{color:var(--success);border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.audit-status-badge.status-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.audit-status-badge.status-error{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.audit-status-badge.status-neutral{color:var(--text-muted)}.audit-status-badge.status-unknown{color:var(--text-muted);border-color:color-mix(in srgb, var(--border) 75%, transparent)}.audit-pane{border:1px solid var(--border);background:var(--bg);border-top:0;border-radius:0 0 8px 8px;min-width:0;padding:12px}.audit-pane h5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:11px;font-weight:600}.audit-prompt-cache-pill{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);min-height:20px;color:var(--prompt-cache-color);letter-spacing:.02em;text-transform:none;border-radius:999px;align-items:center;padding:2px 8px;font-size:11px;font-weight:700;display:inline-flex}.audit-prompt-cache-highlight{color:var(--prompt-cache-color);font-weight:700}.audit-audio{white-space:normal;flex-direction:column;gap:8px;display:flex}.audit-audio-player{width:100%;max-width:420px;height:36px}.audit-audio-meta{color:var(--text-muted);font-size:12px}.audit-audio-empty{align-items:flex-start;padding:4px 0}.audit-audio-icon{font-size:20px;line-height:1}.audit-audio-note{color:var(--text-muted);font-size:12px}.audit-audio-metadata{flex-direction:column;gap:2px;margin-top:4px;font-size:12px;display:flex}.audit-audio-meta-row{gap:8px;display:flex}.audit-audio-meta-key{color:var(--text-muted);min-width:120px}.conversation-body-highlight{border-left:2px solid color-mix(in srgb, var(--accent) 70%, var(--border));background:color-mix(in srgb, var(--accent) 10%, transparent);cursor:pointer;line-height:inherit;border-radius:2px;margin:0 0 0 -2px;padding:0 0 0 2px;display:inline}.conversation-body-highlight:hover{background:color-mix(in srgb, var(--accent) 18%, transparent)}.conversation-body-highlight.conversation-system{border-left-color:color-mix(in srgb, var(--warning) 70%, var(--border));background:color-mix(in srgb, var(--warning) 10%, transparent)}.conversation-body-highlight.conversation-user{border-left-color:color-mix(in srgb, var(--accent) 75%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent)}.conversation-body-highlight.conversation-assistant{border-left-color:color-mix(in srgb, var(--success) 65%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}#interactions-drawer-content{flex:1;min-height:0;overflow-y:auto}.pagination{justify-content:space-between;align-items:center;padding:12px 0 0;display:flex}.btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;padding:6px 16px;font-family:inherit;font-size:13px;transition:all .15s}.btn:hover:not(:disabled){background:var(--bg-surface-hover)}.btn-primary{background:var(--accent);border-color:color-mix(in srgb, var(--accent) 70%, #000 10%);color:#fff;font-weight:600;box-shadow:0 10px 22px #3b82f62e}.btn-primary:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 90%, #fff 10%);border-color:color-mix(in srgb, var(--accent) 78%, #000 12%)}.btn-danger-outline{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:0 0;font-weight:600}.btn-danger-outline:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 75%, var(--border))}.btn-danger{color:#fff;border-color:color-mix(in srgb, var(--danger) 76%, #000 12%);background:var(--danger);box-shadow:0 10px 22px color-mix(in srgb, var(--danger) 20%, transparent);font-weight:600}.btn-danger:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 90%, #fff 10%);border-color:color-mix(in srgb, var(--danger) 82%, #000 14%)}.btn-with-icon{justify-content:center;align-items:center;gap:8px;display:inline-flex}.btn-with-icon .table-icon-svg{width:16px;height:16px}.btn:disabled{opacity:.4;cursor:default}.settings-panel{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.inline-help-section{flex-direction:column;gap:2px;display:flex}.inline-help-title-row{align-items:center;gap:10px;display:inline-flex}.inline-help-title-row h2,.inline-help-title-row h3{margin-bottom:0}.inline-help-title-row h2:empty,.inline-help-title-row h3:empty{display:none}.inline-help-toggle{border:1px solid color-mix(in srgb, var(--accent) 28%, var(--border));width:16px;height:16px;color:var(--accent);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border-radius:4px;justify-content:center;align-items:center;padding:0;transition:color .18s,border-color .18s;display:inline-flex;position:relative}.inline-help-toggle:before{content:"";pointer-events:auto;background:0 0;width:32px;height:32px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.inline-help-toggle:hover{border-color:color-mix(in srgb, var(--accent) 48%, var(--border));color:var(--text);background:0 0}.inline-help-toggle:active{background:0 0}.inline-help-toggle:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.inline-help-toggle-icon{justify-content:center;align-items:center;width:100%;height:100%;padding-bottom:1px;font-size:13px;font-weight:700;line-height:1;transition:transform .52s cubic-bezier(.22,.72,.12,1);display:inline-flex;transform:rotate(0)}.inline-help-copy{max-width:780px;color:var(--text-muted);margin-top:2px;font-size:14px}.settings-select{width:100%}.settings-refresh-section{border-top:1px solid var(--border);justify-items:start;gap:12px;margin-top:24px;padding-top:22px;display:grid}.settings-refresh-section h3{font-size:18px}.settings-refresh-section p{max-width:720px;color:var(--text-muted);font-size:14px;line-height:1.55}.budget-list{gap:10px;padding:10px 0;display:grid}.budget-row{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);grid-template-columns:minmax(0,1fr);align-items:center;gap:16px;padding:12px 14px;display:grid}.budget-row-main{min-width:0}.budget-row-head{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:10px;min-width:0;display:grid}.budget-scope-value{width:fit-content;max-width:100%;min-height:24px;color:var(--text);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;justify-self:start;align-items:center;gap:5px;padding:2px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;display:inline-flex;overflow:hidden}.budget-user-path{border:1px solid color-mix(in srgb, var(--accent) 32%, var(--border));background:color-mix(in srgb, var(--accent) 9%, var(--bg))}.budget-label{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.budget-scope-icon{stroke-width:2.2px;opacity:.85;flex:0 0 12px;width:12px;height:12px}.budget-row-meta{min-width:0;color:var(--text-muted);align-items:center;gap:8px;font-size:12px;display:inline-flex}.budget-source{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:999px;padding:2px 7px;font-size:11px}.budget-row-period{justify-content:center;min-width:0;display:flex}.budget-row-controls{justify-content:flex-end;align-items:center;gap:8px;min-width:0;display:flex}.budget-bars{gap:6px;margin-top:10px;display:grid}.budget-bar-line{grid-template-columns:118px minmax(0,1fr);align-items:center;gap:10px;display:grid}.budget-bar-label{color:var(--text-muted);justify-content:space-between;align-items:center;gap:6px;font-size:11px;line-height:1;display:flex}.budget-bar-percent{font-weight:700}.budget-bar-track{background:color-mix(in srgb, var(--border) 75%, var(--bg));border-radius:999px;height:16px;position:relative;overflow:hidden}.budget-bar-fill{border-radius:inherit;min-width:0;height:100%;transition:width .2s}.budget-bar-fill-usage{background:color-mix(in srgb, var(--success) 82%, var(--accent))}.budget-bar-fill-danger{background:var(--danger)}.budget-bar-text-row{z-index:1;pointer-events:none;color:var(--text);position:absolute;inset:0}.budget-bar-text{text-overflow:ellipsis;white-space:nowrap;max-width:min(44%,190px);font-size:11px;font-weight:700;line-height:12px;position:absolute;top:50%;overflow:hidden}.budget-bar-text-center{max-width:min(46%,240px);left:50%;transform:translate(-50%,-50%)}.budget-bar-text-end{text-align:right;max-width:min(34%,180px);right:8px;transform:translateY(-50%)}.budget-period-label{border:1px solid var(--border);color:var(--text);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;gap:5px;padding:2px 7px;font-size:11px;font-weight:600;display:inline-flex}.budget-period-icon{stroke-width:2.2px;flex:0 0 12px;width:12px;height:12px}.budget-period-label-monthly{border-color:color-mix(in srgb, #30302c 62%, var(--border));background:color-mix(in srgb, #30302c 12%, var(--bg));color:color-mix(in srgb, #30302c 34%, var(--text) 66%)}.budget-period-label-weekly{border-color:color-mix(in srgb, #68765c 62%, var(--border));background:color-mix(in srgb, #68765c 12%, var(--bg));color:color-mix(in srgb, #68765c 34%, var(--text) 66%)}.budget-period-label-daily{border-color:color-mix(in srgb, #b5652d 62%, var(--border));background:color-mix(in srgb, #b5652d 12%, var(--bg));color:color-mix(in srgb, #b5652d 34%, var(--text) 66%)}.budget-period-label-hourly{border-color:color-mix(in srgb, #783f22 62%, var(--border));background:color-mix(in srgb, #783f22 12%, var(--bg));color:color-mix(in srgb, #783f22 34%, var(--text) 66%)}.budget-period-label-custom{border-style:dashed;border-color:color-mix(in srgb, #bfa584 68%, var(--border));background:color-mix(in srgb, #bfa584 16%, var(--bg));color:color-mix(in srgb, #8b6f4f 34%, var(--text) 66%)}[data-theme=light] .budget-period-label-monthly{color:#30302c}[data-theme=light] .budget-period-label-weekly{color:#68765c}[data-theme=light] .budget-period-label-daily{color:#b5652d}[data-theme=light] .budget-period-label-hourly{color:#783f22}[data-theme=light] .budget-period-label-custom{color:#8b6f4f}@media (prefers-color-scheme:light){:root:not([data-theme=dark]) .budget-period-label-monthly{color:#30302c}:root:not([data-theme=dark]) .budget-period-label-weekly{color:#68765c}:root:not([data-theme=dark]) .budget-period-label-daily{color:#b5652d}:root:not([data-theme=dark]) .budget-period-label-hourly{color:#783f22}:root:not([data-theme=dark]) .budget-period-label-custom{color:#8b6f4f}}.budget-row-actions{flex-flow:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.budget-action-btn{white-space:nowrap;justify-content:center;gap:0;width:28px;min-width:0;height:28px;padding:0;transition:width .18s,border-color .15s,background .15s,color .15s;overflow:hidden}.budget-action-btn:hover,.budget-action-btn:focus-visible{gap:6px;width:82px;padding:0 9px}.budget-action-label{opacity:0;max-width:0;transition:max-width .18s,opacity .12s;overflow:hidden}.budget-action-btn:hover .budget-action-label,.budget-action-btn:focus-visible .budget-action-label{opacity:1;max-width:58px}.budget-action-btn-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.budget-action-icon{flex:0 0 14px;width:14px;height:14px}.budget-editor{background:color-mix(in srgb, var(--bg-surface) 86%, var(--bg) 14%)}.budget-settings-actions{flex-wrap:wrap;gap:10px;display:flex}.budget-reset-dialog{max-width:460px}.form-action-icon{flex:0 0 16px;width:16px;height:16px}.settings-refresh-alert{margin-top:16px;margin-bottom:0}@media (width<=768px){.badge{display:none}.content{width:100%;margin:0 auto;padding:20px}.auth-dialog{padding:18px}.auth-dialog-actions{flex-direction:column-reverse}.auth-dialog-actions .btn{width:100%}.cards{grid-template-columns:repeat(2,1fr)}.page-header{flex-wrap:wrap;gap:12px}.page-header h2{width:100%}.page-header-controls{flex-wrap:wrap;justify-content:space-between;width:100%}.page-with-sticky-date{grid-template-columns:minmax(0,1fr)}.page-with-sticky-date>.date-range-page-header,.page-with-sticky-date>.sticky-date-range{grid-column:1}.page-with-sticky-date>.date-range-page-header{margin-bottom:12px}.page-with-sticky-date>.sticky-date-range{width:100%;margin-bottom:24px;top:10px}.sticky-date-range .date-picker-trigger{justify-content:space-between;width:100%}.usage-log-select{min-width:0}.budget-row{grid-template-columns:1fr}.budget-row-controls{flex-wrap:wrap}.budget-bar-line{grid-template-columns:1fr;gap:5px}.form-grid,.workflow-feature-toggles{grid-template-columns:1fr}.workflow-section-head{flex-direction:column;align-items:flex-start}.table-toolbar{flex-direction:column;align-items:stretch}.table-toolbar-actions{justify-content:stretch;margin-left:0}.table-toolbar-actions .btn{width:100%}.model-editor{padding:16px}.alias-actions-cell,.editor-header{flex-direction:column;align-items:flex-start}.alias-actions-cell .table-action-btn,.editor-header .table-action-btn{width:100%}.alias-actions-cell .table-icon-btn,.editor-header .table-icon-btn{width:36px}.model-list-actions{flex-flow:row;align-items:center}.model-list-actions .table-action-btn{width:auto}.model-list-actions .table-icon-btn{flex-basis:32px;width:32px}.model-editor .editor-header{flex-direction:row;align-items:flex-start}.model-editor .editor-header>:first-child{flex:1;min-width:0}.model-editor .editor-header .dialog-close-btn{flex:0 0 32px;align-self:flex-start;width:32px;min-width:32px}.settings-panel{padding:18px}.budget-settings-actions,.budget-settings-actions .btn{width:100%}}.workflow-conn{background:color-mix(in srgb, var(--accent) 44%, var(--border));flex:1 1 0;width:auto;min-width:13px;height:2px;position:relative}.workflow-conn:after{content:"";background:color-mix(in srgb, var(--accent) 44%, var(--border));clip-path:polygon(0 0,100% 50%,0 100%);width:7px;height:9px;position:absolute;top:50%;right:-1px;transform:translateY(-50%)}.workflow-node{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg-surface);text-align:center;flex-direction:column;flex-shrink:0;justify-content:center;align-items:center;gap:4px;min-width:72px;padding:8px 12px;display:flex}.auth-key-description{color:var(--text-muted);max-width:220px;font-size:13px}.auth-key-status-badge{border-radius:999px;padding:2px 10px;font-size:12px;font-weight:600;display:inline-block}.auth-key-status-active{background:color-mix(in srgb, var(--success) 12%, var(--bg));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));color:var(--success)}.auth-key-status-inactive{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border:1px solid color-mix(in srgb, var(--danger) 30%, var(--border));color:var(--danger)}.mcp-server-advanced{border:1px solid var(--border);border-radius:var(--radius);background:color-mix(in srgb, var(--bg-surface) 72%, var(--bg) 28%);overflow:hidden}.mcp-server-advanced>summary{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;list-style:none;display:flex}.mcp-server-advanced>summary::-webkit-details-marker{display:none}.mcp-server-advanced>summary:after{border-right:2px solid var(--text-muted);border-bottom:2px solid var(--text-muted);content:"";flex:none;width:7px;height:7px;transition:transform .15s;transform:rotate(45deg)}.mcp-server-advanced[open]>summary:after{transform:rotate(225deg)}.mcp-server-advanced-summary-copy{flex-direction:column;gap:2px;min-width:0;display:flex}.mcp-server-advanced-title{font-size:13px;font-weight:600}.mcp-server-advanced-fields{border-top:1px solid var(--border);flex-direction:column;gap:16px;padding:14px;display:flex}.copy-feedback-btn{align-items:center;gap:6px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.rate-limit-pressure-row{background-image:linear-gradient(to right, color-mix(in srgb, var(--success) 16%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-high{background-image:linear-gradient(to right, color-mix(in srgb, var(--warning) 20%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-full{background-image:linear-gradient(to right, color-mix(in srgb, var(--danger) 22%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.table-icon-btn.rate-limit-gauge-inherited{color:var(--accent-strong,var(--accent));background:linear-gradient(to right, color-mix(in srgb, var(--accent) 22%, var(--bg)) 50%, var(--bg) 50%);border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.auth-dialog-input-icon{width:16px;height:16px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.auth-dialog-input-shell:focus-within .auth-dialog-input-icon{color:var(--accent)}.auth-dialog-submit-icon{flex:0 0 16px;width:16px;height:16px}.nav-icon{flex:0 0 18px;width:18px;height:18px}.api-key-open-icon{flex:0 0 15px;width:15px;height:15px}.theme-icon{flex:0 0 14px;width:14px;height:14px}.theme-toggle-mobile .theme-icon{flex-basis:16px;width:16px;height:16px}@media (width<=768px){.sidebar-footer .api-key-open-icon{flex-basis:16px;width:16px;height:16px}}.failover-drafts-loading{min-height:96px}.models-loading-state{top:16px;left:var(--sidebar-width);z-index:110;pointer-events:none;--loading-state-min-height:0;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-surface);width:fit-content;box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);margin:0 auto;padding:10px 14px;position:fixed;right:0}@media (width<=768px){.models-loading-state{left:60px}}.sidebar.sidebar-collapsed~.content .models-loading-state{left:60px}.alias-create-icon{flex:0 0 16px;width:16px;height:16px}.pricing-override-remove-row{margin-bottom:1px}@media (width<=768px){.pricing-override-remove-row{margin-bottom:0}}.pricing-recalculate-dialog{max-width:480px}.settings-refresh-btn.is-refreshing .settings-refresh-icon{transform-origin:50%;animation:.8s linear infinite loading-spin}.cost-source-icon{width:14px;height:14px;color:var(--success);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.cache-savings-icon{width:14px;height:14px;color:var(--accent);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.theme-toggle.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;margin-bottom:10px;padding:2px;display:inline-flex}.theme-btn.svelte-1keql7b{width:28px;height:24px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:flex}.theme-btn.svelte-1keql7b:hover{color:var(--text)}.theme-btn.active.svelte-1keql7b{background:var(--accent);color:#fff}.theme-btn.svelte-1keql7b:focus-visible,.theme-toggle-mobile.svelte-1keql7b:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.theme-toggle-mobile.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);width:36px;height:36px;color:var(--text-muted);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:none}.theme-toggle-mobile.svelte-1keql7b:hover{color:var(--text)}.theme-toggle.is-compact.svelte-1keql7b{display:none}.theme-toggle-mobile.is-compact.svelte-1keql7b{margin:0 auto;display:flex}@media (width<=768px){.theme-toggle.svelte-1keql7b{display:none}.theme-toggle-mobile.svelte-1keql7b{margin:0 auto;display:flex}}.sidebar.svelte-1nwtzae{flex:0 0 var(--sidebar-width);width:var(--sidebar-width);background:var(--bg-surface);border-right:1px solid var(--border);-webkit-overflow-scrolling:touch;z-index:10;flex-direction:column;max-height:100vh;transition:flex-basis .2s,width .2s;display:flex;position:sticky;top:0;overflow:hidden auto}.sidebar.sidebar-resizing.svelte-1nwtzae{transition:none}.sidebar-header.svelte-1nwtzae{border-bottom:1px solid var(--border);align-items:center;gap:10px;padding:20px;display:flex}.sidebar-logo.svelte-1nwtzae{width:28px;height:28px;color:var(--accent);flex-shrink:0}.sidebar-logo.svelte-1nwtzae svg{width:100%;height:100%}.sidebar-header.svelte-1nwtzae h1{letter-spacing:-.3px;font-size:18px;font-weight:700}.sidebar-nav.svelte-1nwtzae{flex-direction:column;flex:1;gap:4px;padding:12px;display:flex}.nav-item.svelte-1nwtzae{border-radius:var(--radius);color:var(--text-muted);align-items:center;gap:10px;padding:8px 12px;font-size:14px;font-weight:500;text-decoration:none;transition:all .15s;display:flex}.nav-item.svelte-1nwtzae:hover{background:var(--bg-surface-hover);color:var(--text)}.nav-item.active.svelte-1nwtzae{background:var(--accent);color:#fff}.nav-label.svelte-1nwtzae{white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;overflow:hidden}.sidebar-footer.svelte-1nwtzae{border-top:1px solid var(--border);padding:16px}.api-key-section.svelte-1nwtzae{gap:8px;display:grid}.api-key-open-btn.svelte-1nwtzae{border:1px solid var(--accent);border-radius:var(--radius);width:100%;color:var(--accent);cursor:pointer;background:0 0;justify-content:center;align-items:center;gap:8px;padding:8px 10px;font-family:inherit;font-size:13px;font-weight:600;transition:background-color .15s,border-color .15s;display:inline-flex}.api-key-open-btn.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);border-color:color-mix(in srgb, var(--accent) 78%, var(--text));color:color-mix(in srgb, var(--accent) 78%, var(--text))}.api-key-open-btn.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.sidebar-toggle.svelte-1nwtzae{cursor:ew-resize;z-index:11;background:0 0;border:none;flex:0 0 6px;width:6px;height:100vh;padding:0;transition:background .15s;position:sticky;top:0}.sidebar-toggle.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 15%, transparent)}.sidebar-toggle.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}body.sidebar-resizing{cursor:ew-resize;-webkit-user-select:none;user-select:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae){justify-content:center;padding:16px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae) h1,.sidebar.sidebar-collapsed.svelte-1nwtzae .badge{display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae){padding:8px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:none}@media (width<=768px){.sidebar.svelte-1nwtzae{flex-basis:60px;width:60px}.sidebar-header.svelte-1nwtzae{justify-content:center;padding:16px}.sidebar-header.svelte-1nwtzae h1{display:none}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar-footer.svelte-1nwtzae{gap:8px;padding:8px;display:grid}.sidebar-footer.svelte-1nwtzae .api-key-section:where(.svelte-1nwtzae),.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:grid}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae){justify-self:center;width:36px;height:36px;min-height:36px;padding:0}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae) span,.sidebar-toggle.svelte-1nwtzae{display:none}}.dialog-close-btn.svelte-11l1bb5{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.dialog-close-btn.svelte-11l1bb5:hover{color:var(--text);background:var(--bg-surface-hover)}.dialog-close-btn.svelte-11l1bb5:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-backdrop.svelte-17e0w4c,.editor-modal-backdrop.svelte-17e0w4c{z-index:80;background:#0000007a;position:fixed;inset:0}.auth-dialog-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0}.editor-modal-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0;overflow-y:auto}.editor-modal-shell.svelte-17e0w4c>*{overscroll-behavior:contain;width:min(760px,100%);max-height:min(100vh - 40px,960px);margin:0;overflow:auto;box-shadow:0 24px 70px #00000061}@media (width<=768px){.auth-dialog-shell.svelte-17e0w4c,.editor-modal-shell.svelte-17e0w4c{align-items:end;padding:12px}.editor-modal-shell.svelte-17e0w4c>*{max-height:calc(100vh - 24px)}}.auth-dialog-input-shell.svelte-1dsu6u0{position:relative}.auth-dialog-input.svelte-1dsu6u0{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:11px 12px 11px 38px;font-family:inherit;font-size:14px}.auth-dialog-input.svelte-1dsu6u0:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}.flash-region.svelte-1i257xg{top:16px;left:var(--sidebar-width);z-index:120;pointer-events:none;flex-direction:column;align-items:center;gap:10px;display:flex;position:fixed;right:0}.sidebar.sidebar-collapsed~.flash-region.svelte-1i257xg{left:60px}@media (width<=768px){.flash-region.svelte-1i257xg{left:60px}}.flash-toast.svelte-1i257xg{border-radius:var(--radius);pointer-events:auto;align-items:flex-start;gap:10px;width:max-content;max-width:min(480px,100% - 32px);padding:12px 12px 12px 16px;font-size:14px;animation:.9s ease-out svelte-1i257xg-flash-toast-glow;display:flex;box-shadow:0 10px 30px #00000059}@keyframes svelte-1i257xg-flash-toast-glow{0%{box-shadow:0 0 0 4px color-mix(in srgb, currentColor 45%, transparent), 0 10px 30px #00000059}to{box-shadow:0 0 0 4px #0000,0 10px 30px #00000059}}@media (prefers-reduced-motion:reduce){.flash-toast.svelte-1i257xg{animation:none}}.flash-toast-success.svelte-1i257xg{background:color-mix(in srgb, var(--success) 14%, var(--bg-surface));color:var(--success);border:1px solid #34d39959}.flash-toast-error.svelte-1i257xg{background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--warning);border:1px solid #f59e0b66}.flash-toast-text.svelte-1i257xg{overflow-wrap:anywhere;flex:1;min-width:0}.flash-toast-dismiss.svelte-1i257xg{color:inherit;cursor:pointer;opacity:.7;background:0 0;border:0;flex-shrink:0;padding:0 2px;font-size:18px;line-height:1}.flash-toast-dismiss.svelte-1i257xg:hover{opacity:1}.demo-mode-banner.svelte-1s3mcn8{border:1px solid color-mix(in srgb, var(--warning) 55%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--text);box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;margin-bottom:24px;padding:12px 16px;display:grid}.demo-mode-banner-icon.svelte-1s3mcn8{width:20px;height:20px;color:var(--warning);flex:0 0 20px}.demo-mode-banner-copy.svelte-1s3mcn8{align-items:baseline;gap:8px;min-width:0;font-size:13px;display:flex}.demo-mode-banner.svelte-1s3mcn8 strong{color:var(--warning);letter-spacing:.06em;text-transform:uppercase;flex-shrink:0;font-size:12px}.demo-mode-banner-links.svelte-1s3mcn8{justify-content:flex-end;align-items:center;gap:6px;display:flex}.demo-mode-banner-links.svelte-1s3mcn8 a{border:1px solid color-mix(in srgb, var(--warning) 42%, var(--border));border-radius:var(--radius);min-height:28px;color:var(--text);white-space:nowrap;align-items:center;padding:4px 8px;font-size:12px;font-weight:600;line-height:1;text-decoration:none;display:inline-flex}.demo-mode-banner-links.svelte-1s3mcn8 a:hover{border-color:var(--warning);background:color-mix(in srgb, var(--warning) 16%, transparent);color:var(--text)}.demo-mode-banner-links.svelte-1s3mcn8 a:focus-visible{outline:2px solid color-mix(in srgb, var(--warning) 42%, transparent);outline-offset:2px}@media (width<=768px){.demo-mode-banner.svelte-1s3mcn8{grid-template-columns:auto minmax(0,1fr);align-items:flex-start}.demo-mode-banner-copy.svelte-1s3mcn8{gap:2px;display:grid}.demo-mode-banner-links.svelte-1s3mcn8{flex-wrap:wrap;grid-column:2;justify-content:flex-start}}.auth-banner.svelte-1c5yh36{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.dp-calendar.svelte-g7ga4u{flex-shrink:0;width:224px}.dp-cal-header.svelte-g7ga4u{justify-content:space-between;align-items:center;margin-bottom:8px;padding:0 4px;display:flex}.dp-cal-title.svelte-g7ga4u{font-size:13px;font-weight:600}.dp-nav-btn.svelte-g7ga4u{width:28px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:flex}.dp-nav-btn.svelte-g7ga4u:hover{background:var(--bg-surface-hover);color:var(--text)}.dp-nav-btn.svelte-g7ga4u:disabled{opacity:.3;cursor:default;pointer-events:none}.dp-nav-prev-mobile.svelte-g7ga4u{display:none}.dp-weekdays.svelte-g7ga4u{text-align:center;grid-template-columns:repeat(7,1fr);margin-bottom:4px;display:grid}.dp-weekdays.svelte-g7ga4u span:where(.svelte-g7ga4u){color:var(--text-muted);padding:4px 0;font-size:11px;font-weight:600}.dp-days.svelte-g7ga4u{grid-template-columns:repeat(7,1fr);gap:1px;display:grid}.dp-day.svelte-g7ga4u{width:32px;height:32px;color:var(--text);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:inherit;font-size:12px;transition:all .1s;display:flex}.dp-day.svelte-g7ga4u:hover:not(.disabled):not(.other-month){background:var(--bg-surface-hover)}.dp-day.other-month.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default}.dp-day.today.svelte-g7ga4u{color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);font-weight:700}.dp-day.in-range.svelte-g7ga4u{background:color-mix(in srgb, var(--accent) 15%, transparent);border-radius:0}.dp-day.range-start.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:6px 0 0 6px;font-weight:600}.dp-day.range-end.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:0 6px 6px 0;font-weight:600}.dp-day.range-start.range-end.svelte-g7ga4u{border-radius:6px}.dp-day.range-start.today.svelte-g7ga4u,.dp-day.range-end.today.svelte-g7ga4u{box-shadow:none}.dp-day.disabled.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default;pointer-events:none}@media (width<=768px){.dp-nav-prev-mobile.svelte-g7ga4u{display:flex}}.date-picker.svelte-ax7ma4{position:relative}.date-picker-trigger.svelte-ax7ma4{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;white-space:nowrap;align-items:center;gap:8px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s;display:inline-flex}.date-picker-trigger.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.date-picker-trigger.svelte-ax7ma4 svg:where(.svelte-ax7ma4){color:var(--text-muted);flex-shrink:0}.date-picker-chevron.svelte-ax7ma4{transition:transform .15s}.date-picker-chevron.open.svelte-ax7ma4{transform:rotate(180deg)}.date-picker-dropdown.svelte-ax7ma4{z-index:100;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:hidden;box-shadow:0 8px 24px #00000040}.date-picker-presets.svelte-ax7ma4{border-right:1px solid var(--border);flex-direction:column;gap:2px;min-width:140px;padding:8px;display:flex}.preset-btn.svelte-ax7ma4{color:var(--text);text-align:left;cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s}.preset-btn.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.preset-btn.active.svelte-ax7ma4{background:var(--accent);color:#fff}.date-picker-calendars.svelte-ax7ma4{flex-wrap:nowrap;gap:16px;padding:12px;display:flex}.dp-cursor-hint.svelte-ax7ma4{pointer-events:none;z-index:101;background:var(--bg-surface);color:var(--text);border:1px solid var(--accent);white-space:nowrap;border-radius:4px;align-items:center;gap:5px;padding:3px 8px;font-size:11px;font-weight:500;display:flex;position:fixed;transform:translate(12px,-50%)}.dp-cursor-hint.svelte-ax7ma4 svg:where(.svelte-ax7ma4){width:12px;height:12px;color:var(--accent);flex-shrink:0}@media (width<=768px){.date-picker-dropdown.svelte-ax7ma4{border-radius:var(--radius) var(--radius) 0 0;flex-direction:column;max-height:80vh;position:fixed;inset:auto 0 0;overflow-y:auto}.date-picker-presets.svelte-ax7ma4{-webkit-overflow-scrolling:touch;border-right:none;border-bottom:1px solid var(--border);flex-flow:row;min-width:0;overflow-x:auto}.date-picker-calendars.svelte-ax7ma4{justify-content:center}.date-picker-calendars.svelte-ax7ma4>.dp-calendar:first-child{display:none}}.segmented-control.svelte-92fh5i{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.segmented-btn.svelte-92fh5i{color:var(--text-muted);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;padding:5px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:flex}.segmented-btn.svelte-92fh5i:hover{color:var(--text)}.segmented-btn.active.svelte-92fh5i{background:var(--accent);color:#fff}@media (width<=768px){.segmented-btn.svelte-92fh5i{padding:4px 8px;font-size:11px}}.live-tokens.svelte-17qr2ta{margin-bottom:28px}.live-tokens-heading.svelte-17qr2ta{flex-direction:column;gap:2px;display:flex}.live-tokens-subtitle.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:6px;font-size:12px;display:inline-flex}.live-tokens-legend.svelte-17qr2ta{flex-wrap:wrap;gap:8px 18px;margin-bottom:16px;display:flex}.live-tokens-legend-item.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:7px;font-size:12px;display:inline-flex}.live-tokens-swatch.svelte-17qr2ta{border-radius:2px;flex-shrink:0;width:10px;height:10px}.live-tokens-legend-value.svelte-17qr2ta{color:var(--text);font-weight:600}.live-tokens-empty.svelte-17qr2ta .live-tokens-empty-text:where(.svelte-17qr2ta){color:var(--text-muted);font-size:13px}.provider-status-flag.svelte-6tr9cf{grid-column:span 2}.provider-status-overview-card.svelte-6tr9cf{grid-column:span 1}.provider-status-flag.is-healthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, var(--bg-surface))}.provider-status-flag.is-degraded.svelte-6tr9cf{border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-flag.is-unhealthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface))}.provider-status-value.svelte-6tr9cf{margin-bottom:8px}.provider-status-card-link.svelte-6tr9cf{color:var(--accent-strong,var(--accent));font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;margin:0;padding:0;font-size:13px;font-weight:600}.provider-status-card-link.svelte-6tr9cf:hover{color:var(--text);text-decoration:underline}.provider-status-card-link.svelte-6tr9cf:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:3px;border-radius:4px}.provider-status-card-note.svelte-6tr9cf{color:var(--text-muted);font-size:13px;display:block}@media (width>=720px){.card-wide.svelte-6tr9cf{grid-column:span 2}}.cache-token-value.svelte-6tr9cf{flex-wrap:wrap;align-items:center;gap:6px;line-height:1;display:flex}.cache-token-part.svelte-6tr9cf{align-items:center;display:inline-flex}.cache-token-operator.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;font-size:24px;font-weight:600;line-height:1}.cache-token-marker.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;text-transform:uppercase;margin-left:2px;font-size:14px;font-weight:700}.prompt-cache-gauge.svelte-6tr9cf{width:120px;height:60px;margin:8px auto 0;position:relative;overflow:hidden}.prompt-cache-gauge.svelte-6tr9cf canvas{display:block}.prompt-cache-gauge-value.svelte-6tr9cf{text-align:center;color:var(--text);font-size:18px;font-weight:700;line-height:1;position:absolute;bottom:4px;left:0;right:0}@media (width<=768px){.provider-status-flag.svelte-6tr9cf{grid-column:span 1}}.mcp-servers-flag.svelte-6tr9cf{grid-column:span 1}.cache-meter-header.svelte-1yzecxj{flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:16px;display:flex}.cache-meter-header.svelte-1yzecxj h3{font-size:16px;font-weight:600}.cache-meter-subtitle.svelte-1yzecxj{color:var(--text-muted);font-size:13px}.cache-meter-bar.svelte-1yzecxj{background:var(--bg-surface-hover);border-radius:6px;width:100%;height:28px;display:flex;overflow:hidden}.cache-meter-segment.svelte-1yzecxj{justify-content:center;align-items:center;min-width:3px;height:100%;transition:width .3s;display:flex;overflow:hidden}.cache-meter-segment-label.svelte-1yzecxj{color:#fff;white-space:nowrap;text-shadow:0 1px 2px #00000073;font-size:12px;font-weight:600;line-height:1}.cache-meter-segment.svelte-1yzecxj+.cache-meter-segment:where(.svelte-1yzecxj){box-shadow:-1px 0 0 var(--bg-surface)}.cache-meter-bar.is-empty.svelte-1yzecxj{background:var(--bg-surface-hover);justify-content:center;align-items:center;height:auto;min-height:28px;padding:6px 12px}.cache-meter-legend.svelte-1yzecxj{flex-wrap:wrap;gap:10px 24px;margin-top:16px;display:flex}.cache-meter-legend-item.svelte-1yzecxj{align-items:center;gap:8px;font-size:13px;display:flex}.cache-meter-swatch.svelte-1yzecxj{border-radius:3px;flex-shrink:0;width:12px;height:12px}.cache-meter-legend-label.svelte-1yzecxj{color:var(--text)}.cache-meter-legend-pct.svelte-1yzecxj{color:var(--text);font-weight:600}.cache-meter-legend-tokens.svelte-1yzecxj{color:var(--text-muted)}.cache-meter-empty.svelte-1yzecxj{color:var(--text-muted);text-align:center;font-size:13px}.spinner.svelte-b54l9o{width:var(--spinner-size);height:var(--spinner-size);border:2px solid var(--border,#80808059);border-top-color:var(--accent,currentColor);border-radius:50%;flex:none;animation:.7s linear infinite svelte-b54l9o-spinner-rotate;display:inline-block}@keyframes svelte-b54l9o-spinner-rotate{to{transform:rotate(360deg)}}.contribution-calendar-section.svelte-3hfxuq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-top:24px;padding:24px}.contribution-calendar-header.svelte-3hfxuq{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.contribution-calendar-header.svelte-3hfxuq h3{font-size:16px;font-weight:600}.contribution-calendar-grid-wrapper.svelte-3hfxuq{gap:8px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq{flex-direction:column;gap:2px;padding-top:22px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq span{height:13px;color:var(--text-muted);text-align:right;min-width:28px;font-size:10px;line-height:13px}.contribution-calendar-scroll.svelte-3hfxuq{--contribution-week-size:13px;--contribution-week-gap:2px;flex:1;min-width:0;overflow-x:auto}.contribution-calendar-months.svelte-3hfxuq{grid-auto-columns:var(--contribution-week-size);gap:var(--contribution-week-gap);grid-auto-flow:column;height:16px;margin-bottom:6px;display:grid}.contribution-calendar-month-label.svelte-3hfxuq{color:var(--text-muted);white-space:nowrap;font-size:10px}.contribution-calendar-grid.svelte-3hfxuq{gap:var(--contribution-week-gap);display:flex}.contribution-calendar-week.svelte-3hfxuq{flex-direction:column;gap:2px;display:flex}.contribution-calendar-cell.svelte-3hfxuq{width:var(--contribution-week-size);height:var(--contribution-week-size);background:var(--cal-level-0);border-radius:2px}.contribution-calendar-cell.level-1.svelte-3hfxuq{background:var(--cal-level-1)}.contribution-calendar-cell.level-2.svelte-3hfxuq{background:var(--cal-level-2)}.contribution-calendar-cell.level-3.svelte-3hfxuq{background:var(--cal-level-3)}.contribution-calendar-cell.level-4.svelte-3hfxuq{background:var(--cal-level-4)}.contribution-calendar-cell.level-5.svelte-3hfxuq{background:var(--cal-level-5)}.contribution-calendar-cell.level-6.svelte-3hfxuq{background:var(--cal-level-6)}.contribution-calendar-cell.level-7.svelte-3hfxuq{background:var(--cal-level-7)}.contribution-calendar-cell.level-8.svelte-3hfxuq{background:var(--cal-level-8)}.contribution-calendar-cell.level-9.svelte-3hfxuq{background:var(--cal-level-9)}.contribution-calendar-cell.level-10.svelte-3hfxuq{background:var(--cal-level-10)}.contribution-calendar-cell.empty.svelte-3hfxuq{background:0 0}.contribution-calendar-footer.svelte-3hfxuq{justify-content:space-between;align-items:center;gap:12px;margin-top:12px;display:flex}.contribution-calendar-meta.svelte-3hfxuq{flex-direction:column;gap:4px;display:flex}.contribution-calendar-summary.svelte-3hfxuq{color:var(--text-muted);font-size:12px}.contribution-calendar-legend.svelte-3hfxuq{color:var(--text-muted);align-items:center;gap:4px;font-size:11px;display:flex}.contribution-calendar-legend.svelte-3hfxuq .contribution-calendar-cell:where(.svelte-3hfxuq){cursor:default;width:11px;height:11px}.contribution-calendar-tooltip.svelte-3hfxuq{z-index:200;background:var(--bg-surface);color:var(--text);border:1px solid var(--border);white-space:nowrap;pointer-events:none;border-radius:4px;padding:4px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;position:fixed;transform:translate(-50%);box-shadow:0 4px 12px #0003}@media (width<=768px){.contribution-calendar-day-labels.svelte-3hfxuq{display:none}.contribution-calendar-section.svelte-3hfxuq{padding:16px}.contribution-calendar-footer.svelte-3hfxuq{flex-direction:column;align-items:flex-start}}.inline-help-toggle.is-open.svelte-y40or3{color:var(--text);background:0 0}.inline-help-toggle.is-open.svelte-y40or3 .inline-help-toggle-icon{transform:rotate(540deg)}.audit-stats-section.svelte-14e9yan{margin-top:24px}.audit-stats-header.svelte-14e9yan{align-items:flex-start}.audit-stats-kpis.svelte-14e9yan{flex-wrap:wrap;align-items:center;gap:14px;display:flex}.audit-stats-kpi.svelte-14e9yan{color:var(--text-muted);white-space:nowrap;align-items:center;gap:6px;font-size:12px;display:inline-flex}.audit-stats-kpi-value.svelte-14e9yan{color:var(--text);font-size:13px}.audit-stats-kpi-dot.svelte-14e9yan{border-radius:2px;flex-shrink:0;width:8px;height:8px}.audit-stats-dot-2xx.svelte-14e9yan{background:var(--success)}.audit-stats-dot-4xx.svelte-14e9yan{background:var(--warning)}.audit-stats-dot-5xx.svelte-14e9yan{background:var(--danger)}.provider-status-details.svelte-6y9wjv{opacity:0;grid-template-rows:0fr;transition:grid-template-rows .28s,opacity .22s;display:grid}.provider-status-details.is-expanded.svelte-6y9wjv{opacity:1;grid-template-rows:1fr}.provider-status-details.is-collapsed.svelte-6y9wjv{pointer-events:none}.provider-status-details-inner.svelte-6y9wjv{flex-direction:column;gap:14px;min-height:0;display:flex;overflow:hidden}.provider-status-reason.svelte-6y9wjv{color:var(--text-muted);font-size:13px}.provider-status-error.svelte-6y9wjv{color:var(--danger);overflow-wrap:break-word;font-size:12px}.provider-status-config-label.svelte-6y9wjv{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-config.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;padding-top:12px;display:flex}.provider-status-config-row.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-config-value.svelte-6y9wjv{color:var(--text);overflow-wrap:break-word;font-size:13px;display:block}.provider-status-health.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;margin-bottom:12px;padding-top:12px;display:flex}.provider-status-health-state.svelte-6y9wjv{border:1px solid var(--border);border-radius:999px;align-items:center;padding:1px 8px;font-size:12px;font-weight:600;display:inline-flex}.provider-status-health-state.is-healthy.svelte-6y9wjv{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-health-state.is-degraded.svelte-6y9wjv{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-health-state.is-unhealthy.svelte-6y9wjv{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-health-models.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-health-model.svelte-6y9wjv{color:var(--text);justify-content:space-between;gap:8px;font-size:13px;display:flex}.provider-status-health-model.is-flagged.svelte-6y9wjv{color:var(--danger)}.provider-status-health-model-name.svelte-6y9wjv{overflow-wrap:anywhere}.provider-status-health-model-stats.svelte-6y9wjv{white-space:nowrap;color:var(--text-muted)}.provider-status-health-model.is-flagged.svelte-6y9wjv .provider-status-health-model-stats:where(.svelte-6y9wjv){color:var(--danger);font-weight:700}.provider-status-card.svelte-nopjmh{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:14px;padding:18px;display:flex}.provider-status-card-toggle.svelte-nopjmh{border:0;border-top:1px solid var(--border);border-radius:0 0 var(--radius) var(--radius);color:var(--text-muted);cursor:pointer;background:0 0;justify-content:center;align-items:center;margin:auto -18px -18px;padding:7px 0;transition:background .15s,color .15s;display:flex}.provider-status-card-toggle.svelte-nopjmh:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);color:var(--text)}.provider-status-card-toggle.svelte-nopjmh:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:-2px}.provider-status-card-toggle.svelte-nopjmh .provider-status-card-toggle-icon{width:16px;height:16px;transition:transform .28s;display:block}.provider-status-card-toggle.is-expanded.svelte-nopjmh .provider-status-card-toggle-icon{transform:rotate(180deg)}.provider-status-card-head.svelte-nopjmh{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.provider-status-name.svelte-nopjmh{letter-spacing:-.02em;flex-wrap:wrap;align-items:baseline;gap:6px;font-size:16px;font-weight:700;display:flex}.provider-doc-help.svelte-nopjmh{align-self:center;text-decoration:none}.provider-status-name-type.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-pill.svelte-nopjmh{border:1px solid var(--border);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;min-height:28px;padding:0 10px;font-size:12px;font-weight:700;display:inline-flex}.provider-status-pill.is-healthy.svelte-nopjmh{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-pill.is-degraded.svelte-nopjmh{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-pill.is-unhealthy.svelte-nopjmh{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-meta.svelte-nopjmh{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.provider-status-meta-item.svelte-nopjmh{background:var(--bg);border:1px solid var(--border);border-radius:6px;flex-direction:column;gap:4px;padding:10px 12px;display:flex}.provider-status-meta-label.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-meta-value.svelte-nopjmh{color:var(--text);font-size:14px}@media (width<=768px){.provider-status-meta.svelte-nopjmh{grid-template-columns:1fr}}.provider-status-section-loading.svelte-1kx3uw4{justify-content:center;padding:24px 0;display:flex}.provider-status-section-header.svelte-1kx3uw4{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px;display:flex}.provider-status-toggle.svelte-1kx3uw4{background:var(--bg-surface);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:10px;padding:8px 12px;font-family:inherit;font-size:12px;font-weight:600;transition:background-color .18s,border-color .18s,color .18s;display:inline-flex}.provider-status-toggle.svelte-1kx3uw4:hover{background:var(--bg-surface-hover)}.provider-status-toggle.svelte-1kx3uw4:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.provider-status-toggle-copy.svelte-1kx3uw4{white-space:nowrap}.provider-status-toggle-track.svelte-1kx3uw4{background:color-mix(in srgb, var(--text-muted) 35%, var(--border));border-radius:999px;flex-shrink:0;width:34px;height:20px;transition:background-color .2s;position:relative}.provider-status-toggle-track.is-active.svelte-1kx3uw4{background:color-mix(in srgb, var(--accent) 82%, var(--bg-surface))}.provider-status-toggle-thumb.svelte-1kx3uw4{background:#fff;border-radius:50%;width:16px;height:16px;transition:transform .2s;position:absolute;top:2px;left:2px;box-shadow:0 1px 3px #0000003d}.provider-status-toggle-track.is-active.svelte-1kx3uw4 .provider-status-toggle-thumb:where(.svelte-1kx3uw4){transform:translate(14px)}.provider-status-grid.svelte-1kx3uw4{grid-template-columns:repeat(auto-fit,minmax(280px,1fr));align-items:start;gap:16px;display:grid}@media (width<=768px){.provider-status-section-header.svelte-1kx3uw4{flex-direction:column;align-items:flex-start}.provider-status-toggle.svelte-1kx3uw4{justify-content:space-between;width:100%}}.filter-input-wrap.svelte-30xz1k{flex:1;width:100%;min-width:min(400px,100%);display:flex;position:relative}.filter-input.svelte-30xz1k{flex:1;width:100%;min-width:0;padding-left:34px}.filter-input-wrap.svelte-30xz1k .filter-input-icon{width:14px;height:14px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.usage-page-filters.svelte-1oi6ywk{flex-wrap:wrap;gap:10px;margin-bottom:20px;display:flex}.usage-page-filters.svelte-1oi6ywk .usage-log-select{flex:0 auto}.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:220px;min-width:180px;max-width:360px}@media (width<=768px){.usage-page-filters.svelte-1oi6ywk .usage-log-select,.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:100%;max-width:none}}.pro-saved-value.svelte-1qiwzdu{flex-wrap:wrap;align-items:baseline;gap:8px;display:flex}.pro-saved-delta.svelte-1qiwzdu{color:var(--success);letter-spacing:0;font-size:13px;font-weight:600}.usage-breakdown-loading.svelte-1kee4g8{justify-content:center;align-items:center;min-height:120px;display:flex}.chart-view-toggle.svelte-1kee4g8{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.chart-view-btn.svelte-1kee4g8{width:30px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:inline-flex}.chart-view-btn.svelte-1kee4g8:hover{color:var(--text)}.chart-view-btn.active.svelte-1kee4g8{background:var(--accent);color:#fff}.chart-view-btn.svelte-1kee4g8 svg{fill:none;stroke:currentColor;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:16px;height:16px}.usage-chart-table-wrapper.svelte-1kee4g8{-webkit-overflow-scrolling:touch;margin-top:0;overflow-x:auto}.usage-chart-data-table.svelte-1kee4g8{min-width:max-content}.usage-chart-data-table.svelte-1kee4g8 th,.usage-chart-data-table.svelte-1kee4g8 td{white-space:nowrap}.pagination-info.svelte-1imew3q{color:var(--text-muted);font-size:13px}.pagination-buttons.svelte-1imew3q{gap:8px;display:flex}.usage-log-loading.svelte-hg4ill{justify-content:center;align-items:center;min-height:120px;display:flex}.usage-log-section.svelte-hg4ill{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.usage-log-section.svelte-hg4ill h3{margin-bottom:16px;font-size:16px;font-weight:600}.usage-log-section.svelte-hg4ill .table-wrapper{overflow-x:auto}.usage-log-toolbar.svelte-hg4ill{gap:12px;margin-bottom:16px;display:grid}.usage-filter-row.svelte-hg4ill{grid-template-columns:repeat(12,minmax(0,1fr));align-items:center;gap:12px;display:grid}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1/-1}.usage-filter-row-options.svelte-hg4ill{grid-template-columns:1fr}.usage-log-checkbox.svelte-hg4ill{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.usage-log-checkbox.svelte-hg4ill input{cursor:pointer;width:16px;height:16px}.usage-ts.svelte-hg4ill{white-space:nowrap;font-size:12px}.usage-log-row-cached.svelte-hg4ill td{opacity:.75;font-style:italic}.usage-log-row-cached.svelte-hg4ill .usage-log-cache-cell:where(.svelte-hg4ill){font-weight:700}.caveat-icon.svelte-hg4ill{color:var(--warning);cursor:help;margin-left:4px;font-size:14px}@media (width<=768px){.usage-log-toolbar.svelte-hg4ill{gap:10px}.usage-filter-row.svelte-hg4ill{grid-template-columns:1fr}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1}.usage-log-table.svelte-hg4ill{display:block;overflow-x:auto}}.usage-sticky-controls.svelte-spwie6{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}.usage-charts-grid.svelte-spwie6{flex-wrap:wrap;gap:24px;margin-bottom:24px;display:flex}.usage-charts-grid.svelte-spwie6 .model-chart-section{flex:calc(50% - 24px);min-width:420px;margin-bottom:0}@media (width<=520px){.usage-charts-grid.svelte-spwie6 .model-chart-section{min-width:0}}.loading-state.svelte-hzxv1d{min-height:var(--loading-state-min-height,64px);color:var(--text-muted);justify-content:center;align-items:center;gap:10px;font-size:14px;display:flex}.budget-bar-text-row-on-fill.svelte-1jm56wo{color:#fff;clip-path:inset(0 calc(100% - var(--budget-progress,0%)) 0 0)}.budget-bar-text-start.svelte-1jm56wo{left:8px;transform:translateY(-50%)}.budget-bar-track-period-custom.svelte-1jm56wo .budget-bar-text-row-on-fill:where(.svelte-1jm56wo){color:#3f332a}.budget-override-dialog.svelte-13ryo7h{max-width:460px}.budget-sort-control.svelte-1752fqe{align-items:center;gap:8px}.budget-sort-control.svelte-1752fqe label{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.budget-sort-select.svelte-1752fqe{background-color:var(--bg-surface);min-width:132px}.budget-sort-select.svelte-1752fqe:hover{background-color:var(--bg-surface-hover)}.model-name-cell.svelte-1iynym{flex-direction:column;gap:8px;display:flex}.model-name-primary.svelte-1iynym{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.model-name-secondary.svelte-1iynym{color:var(--text-muted);font-size:12px}.model-redirect-remove-btn.svelte-1iynym{appearance:none;color:var(--danger);cursor:pointer;background:0 0;border:0;margin-left:4px;padding:0;font-size:11px}.model-redirect-remove-btn.svelte-1iynym:hover:not(:disabled){text-decoration:underline}.model-redirect-remove-btn.svelte-1iynym:disabled{opacity:.45;cursor:default}.model-kind-icon.svelte-1iynym{border:1px solid color-mix(in srgb, var(--accent) 55%, var(--border));background:var(--bg);width:24px;height:24px;color:var(--accent);border-radius:999px;flex:0 0 24px;justify-content:center;align-items:center;display:inline-flex}.model-kind-icon-svg.svelte-1iynym{width:14px;height:14px}.model-row-actions.svelte-1iynym{text-align:right;width:170px}@media (width<=768px){.model-name-primary.svelte-1iynym{flex-direction:column;align-items:flex-start}}.provider-group-row.svelte-1911hy6 td{background:color-mix(in srgb, var(--accent) 6%, var(--bg));padding-top:12px;padding-bottom:12px}.provider-group-row.svelte-1911hy6:hover td{background:color-mix(in srgb, var(--accent) 8%, var(--bg))}.provider-group-header.svelte-1911hy6{justify-content:space-between;align-items:center;gap:16px;display:flex}.provider-group-meta.svelte-1911hy6{flex-direction:column;gap:4px;min-width:0;display:flex}.provider-group-title.svelte-1911hy6{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.provider-group-type.svelte-1911hy6,.provider-group-count.svelte-1911hy6,.provider-group-summary.svelte-1911hy6{color:var(--text-muted);font-size:12px}@media (width<=768px){.provider-group-header.svelte-1911hy6{flex-direction:column;align-items:flex-start}}.vm-session-affinity-checkbox.svelte-d1j6xw{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.vm-session-affinity-checkbox.svelte-d1j6xw input:where(.svelte-d1j6xw){accent-color:var(--accent);cursor:pointer}.pricing-override-rows.svelte-u8snes{gap:12px;display:grid}.pricing-override-row.svelte-u8snes{grid-template-columns:minmax(220px,1fr) minmax(130px,180px) 32px;align-items:end;gap:12px;display:grid}.pricing-override-row-actions.svelte-u8snes{justify-content:flex-start;display:flex}.pricing-override-tier-note.svelte-u8snes{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:6px;padding:10px 12px;font-size:13px}.pricing-preview.svelte-u8snes{border:1px solid var(--border);border-radius:6px;overflow:hidden}.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:minmax(150px,1fr) minmax(90px,auto) minmax(130px,.8fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.pricing-preview-header.svelte-u8snes{background:var(--bg);color:var(--text-muted);text-transform:uppercase;font-size:12px;font-weight:600}.pricing-preview-row.svelte-u8snes{border-top:1px solid var(--border);font-size:13px}.pricing-preview-row-empty.svelte-u8snes{color:var(--text-muted);grid-template-columns:1fr}@media (width<=768px){.pricing-override-row.svelte-u8snes,.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:1fr}}.failover-drafts-editor.svelte-1n87bip{flex-direction:column;gap:16px;display:flex}.failover-draft-header-actions.svelte-1n87bip{flex:none;align-items:center;gap:10px;display:flex}.failover-draft-counter.svelte-1n87bip{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.failover-draft-toolbar.svelte-1n87bip{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.failover-draft-toolbar.svelte-1n87bip .filter-input-wrap,.failover-draft-toolbar.svelte-1n87bip .filter-input{min-width:0}.failover-draft-toggle-all.svelte-1n87bip{flex:none}.failover-draft-list.svelte-1n87bip{flex-direction:column;gap:8px;max-height:min(52vh,430px);padding-right:4px;display:flex;overflow-y:auto}.failover-draft-row.svelte-1n87bip{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);cursor:pointer;grid-template-columns:18px minmax(0,1fr);align-items:start;gap:10px;padding:10px;display:grid}.failover-draft-row.svelte-1n87bip:hover{border-color:color-mix(in srgb, var(--accent) 42%, var(--border));background:var(--bg-surface-hover)}.failover-draft-row.svelte-1n87bip input{width:16px;height:16px;margin-top:2px}.failover-draft-copy.svelte-1n87bip{gap:4px;min-width:0;display:grid}.failover-draft-source.svelte-1n87bip,.failover-draft-targets.svelte-1n87bip{overflow-wrap:anywhere}.failover-draft-targets.svelte-1n87bip{color:var(--text-muted);font-size:12px}.failover-drafts-empty.svelte-1n87bip{align-items:center;min-height:96px;display:flex}.failover-draft-actions.svelte-1n87bip{margin-top:0}.category-tabs.svelte-scpjps{-webkit-overflow-scrolling:touch;align-items:center;gap:4px;margin-bottom:16px;padding-bottom:2px;display:flex;overflow-x:auto}.category-tab.svelte-scpjps{background:var(--bg-surface);border:1px solid var(--border);color:var(--text-muted);cursor:pointer;white-space:nowrap;border-radius:6px;flex-shrink:0;align-items:center;gap:6px;padding:6px 14px;font-family:inherit;font-size:13px;font-weight:500;transition:all .15s;display:inline-flex}.category-tab.svelte-scpjps:hover{color:var(--text);background:var(--bg-surface-hover)}.category-tab.active.svelte-scpjps{background:var(--accent);color:#fff;border-color:var(--accent)}.category-tab.svelte-scpjps .tab-count:where(.svelte-scpjps){background:#ffffff26;border-radius:9px;justify-content:center;align-items:center;min-width:20px;height:18px;padding:0 5px;font-size:11px;font-weight:600;line-height:1;display:inline-flex}.category-tab.svelte-scpjps:not(.active) .tab-count:where(.svelte-scpjps){background:var(--bg)}@media (width<=768px){.category-tabs.svelte-scpjps{gap:4px}.category-tab.svelte-scpjps{padding:5px 10px;font-size:12px}}.workflow-pipeline-meta.svelte-1viff7o{border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 86%, transparent);min-width:0;max-width:calc(100% - 28px);color:var(--text-muted);white-space:nowrap;appearance:none;cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:0;padding:2px 10px;font-size:12px;font-weight:500;line-height:1.2;transition:background-color .15s,border-color .15s,color .15s,box-shadow .15s;display:inline-flex;position:absolute;top:12px;right:14px;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover,.workflow-pipeline-meta.svelte-1viff7o:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface));color:color-mix(in srgb, var(--accent) 74%, var(--text))}.workflow-pipeline-meta.svelte-1viff7o:focus-visible{box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);outline:none}.workflow-pipeline-meta-label.svelte-1viff7o{flex:none;font-weight:700}.workflow-pipeline-meta-placeholder.svelte-1viff7o{opacity:1;flex:none;max-width:3ch;margin-left:4px;transition:max-width .18s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta-value.svelte-1viff7o{opacity:0;text-overflow:clip;flex:0 auto;max-width:0;margin-left:0;transition:max-width .22s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o){opacity:0;max-width:0;margin-left:0}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o){opacity:1;max-width:42ch;margin-left:4px}.workflow-pipeline-meta-icon.svelte-1viff7o{opacity:0;flex:none;justify-content:center;align-items:center;width:0;height:14px;margin-left:0;line-height:0;transition:width .18s,margin-left .18s,opacity .15s,transform .18s;display:inline-flex;overflow:hidden;transform:translate(4px)translateY(1px)scale(.84)}.workflow-pipeline-meta-icon.svelte-1viff7o svg{width:14px;height:14px}.workflow-pipeline-meta-copied.svelte-1viff7o,.workflow-pipeline-meta-copied.svelte-1viff7o:hover,.workflow-pipeline-meta-copied.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-icon:where(.svelte-1viff7o){opacity:1;width:14px;margin-left:6px;transform:translateY(1px)}.workflow-pipeline-meta-error.svelte-1viff7o,.workflow-pipeline-meta-error.svelte-1viff7o:hover,.workflow-pipeline-meta-error.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 34%, var(--border));color:var(--danger)}.workflow-pipeline.svelte-nbptrg{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg);flex-direction:column;gap:0;margin-bottom:12px;padding:18px 20px 20px;display:flex;position:relative}.workflow-pipeline-has-meta.svelte-nbptrg{padding-top:42px}.workflow-pipeline-row.svelte-nbptrg{align-items:center;width:100%;min-width:0;display:flex;overflow-x:auto}.workflow-node-icon.svelte-nbptrg{border-radius:var(--radius);background:var(--bg);width:28px;height:28px;color:var(--text-muted);justify-content:center;align-items:center;display:flex}.workflow-node-icon.svelte-nbptrg svg{stroke:currentColor;fill:none;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:15px;height:15px}.workflow-node-label.svelte-nbptrg{letter-spacing:.03em;color:var(--text);white-space:nowrap;font-size:11px;font-weight:700;line-height:1.2}.workflow-node-sub.svelte-nbptrg{color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;max-width:120px;font-size:10px;font-weight:500;line-height:1.2;font-family:var(--font-mono,ui-monospace, monospace);overflow:hidden}.workflow-node-badge.svelte-nbptrg{border-radius:var(--radius);letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;border:1px solid var(--border);background:var(--bg);color:var(--text-muted);align-items:center;padding:2px 7px;font-size:9px;font-weight:800;line-height:1.5;display:inline-flex}.workflow-node-endpoint.svelte-nbptrg{border-radius:var(--radius);border-color:var(--border);background:var(--bg-surface);flex-direction:row;gap:7px;min-width:auto;padding:10px 14px}.workflow-node-icon-endpoint.svelte-nbptrg{border-radius:var(--radius);width:auto;height:auto;color:var(--text-muted);background:0 0;justify-content:flex-start;padding:0}.workflow-node-icon-endpoint.svelte-nbptrg svg{width:14px;height:14px}.workflow-node-endpoint.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted);font-size:11px;font-weight:600}.workflow-node-feature.svelte-nbptrg{border-color:color-mix(in srgb, var(--accent) 46%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface))}.workflow-node-feature.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--accent) 16%, var(--bg));color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--accent) 70%, var(--text-muted))}.workflow-node-ai.svelte-nbptrg{border-radius:var(--radius);gap:6px;min-width:96px;padding:12px 16px}.workflow-async-section.svelte-nbptrg{justify-content:flex-end;align-items:center;gap:0;width:100%;min-width:0;margin-top:10px;display:flex}.workflow-async-turn.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 60px;height:2px;position:relative}.workflow-async-turn.svelte-nbptrg:before{content:"";background:color-mix(in srgb, var(--text-muted) 40%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);width:7px;height:9px;position:absolute;top:50%;left:-7px;transform:translateY(-50%)}.workflow-async-turn.svelte-nbptrg:after{content:"";border-right:2px dashed color-mix(in srgb, var(--text-muted) 40%, var(--border));height:16px;position:absolute;bottom:1px;right:0}.workflow-async-row.svelte-nbptrg{align-items:center;min-width:0;margin-right:7px;display:flex}.workflow-conn-async.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 24px;width:24px}.workflow-conn-async.svelte-nbptrg:after{background:color-mix(in srgb, var(--text-muted) 45%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);left:-1px;right:auto}.workflow-node-async.svelte-nbptrg{border-radius:var(--radius);border-style:dashed;flex-direction:row;gap:7px;min-width:auto;padding:7px 12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){border-radius:var(--radius);width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg) svg{width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){font-size:10px;font-weight:700}.workflow-async-label.svelte-nbptrg{letter-spacing:.1em;text-transform:uppercase;color:var(--text-muted);opacity:.55;white-space:nowrap;flex-shrink:0;align-items:center;margin-left:8px;font-size:9px;font-weight:800;display:inline-flex}.workflow-node-success.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 18%, var(--bg));color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 85%, var(--text))}.workflow-node-success.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 74%, var(--text-muted))}.workflow-node-success.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 14%, var(--bg));border-color:color-mix(in srgb, var(--success) 38%, var(--border));color:var(--success)}.workflow-node-current.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 16%, var(--bg));color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 85%, var(--text))}.workflow-node-current.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 72%, var(--text-muted))}.workflow-node-current.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 13%, var(--bg));border-color:color-mix(in srgb, var(--info) 36%, var(--border));color:var(--info)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 85%, var(--text))}.workflow-node-warning.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 72%, var(--text-muted))}.workflow-node-warning.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 38%, var(--border));color:var(--warning)}.workflow-node-error.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--danger) 14%, var(--bg));color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 85%, var(--text))}.workflow-node-error.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 72%, var(--text-muted))}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 12%, var(--bg));color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg),.workflow-node-neutral.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--text-muted) 84%, var(--border))}.workflow-node-neutral.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 10%, var(--bg));border-color:color-mix(in srgb, var(--text-muted) 28%, var(--border));color:var(--text-muted)}.workflow-conn-hit.svelte-nbptrg,.workflow-conn-hit.svelte-nbptrg:after{background:color-mix(in srgb, var(--success) 58%, var(--border))}.workflow-conn-dim.svelte-nbptrg,.workflow-conn-dim.svelte-nbptrg:after{background:color-mix(in srgb, var(--border) 75%, transparent)}.workflow-node-success.svelte-nbptrg{border-color:color-mix(in srgb, var(--success) 52%, var(--border));background:color-mix(in srgb, var(--success) 9%, var(--bg-surface))}.workflow-node-current.svelte-nbptrg{border-color:color-mix(in srgb, var(--info) 56%, var(--border));background:color-mix(in srgb, var(--info) 10%, var(--bg-surface))}.workflow-node-warning.svelte-nbptrg{border-color:color-mix(in srgb, var(--warning) 52%, var(--border));background:color-mix(in srgb, var(--warning) 9%, var(--bg-surface))}.workflow-node-error.svelte-nbptrg{border-color:color-mix(in srgb, var(--danger) 52%, var(--border));background:color-mix(in srgb, var(--danger) 9%, var(--bg-surface))}.workflow-node-neutral.svelte-nbptrg{border-color:color-mix(in srgb, var(--text-muted) 40%, var(--border));background:color-mix(in srgb, var(--text-muted) 8%, var(--bg-surface))}.workflow-node-skipped.svelte-nbptrg{opacity:.28;position:relative}.workflow-card.svelte-1fo9fvq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:16px;padding:20px;display:flex}.workflow-card-head.svelte-1fo9fvq{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-card-footer.svelte-1fo9fvq{flex-direction:column;align-items:stretch;gap:10px;display:flex}.workflow-card-head.svelte-1fo9fvq h3{font-size:18px;font-weight:700}.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq{flex-wrap:wrap;justify-content:flex-end;gap:8px;display:flex}.workflow-card-meta-footer.svelte-1fo9fvq{justify-content:flex-start}.workflow-card-footer.svelte-1fo9fvq .alias-actions-cell{align-self:flex-end}.workflow-card-description.svelte-1fo9fvq{color:var(--text-muted);font-size:14px}.workflow-guardrails.svelte-1fo9fvq{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list.svelte-1fo9fvq{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-item.svelte-1fo9fvq{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;display:flex}@media (width<=768px){.workflow-card-head.svelte-1fo9fvq,.workflow-card-footer.svelte-1fo9fvq,.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq,.workflow-guardrail-item.svelte-1fo9fvq{flex-direction:column;align-items:flex-start}}.model-editor.workflow-editor{width:min(1080px,100%);margin-bottom:0}.alert-inline-actions.svelte-1bcpzh1{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.workflow-guardrail-editor.svelte-1bcpzh1{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list-editor.svelte-1bcpzh1{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-row.svelte-1bcpzh1{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:stretch;align-items:center;gap:12px;padding:10px 12px;display:flex}.workflow-guardrail-field.svelte-1bcpzh1{flex:auto;min-width:0}.workflow-guardrail-step-field.svelte-1bcpzh1{flex:0 0 120px}.workflow-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-step-input.svelte-1bcpzh1{max-width:120px}@media (width<=768px){.workflow-guardrail-row.svelte-1bcpzh1{flex-direction:column;align-items:flex-start}.workflow-step-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-guardrail-field.svelte-1bcpzh1,.workflow-guardrail-step-field.svelte-1bcpzh1{flex-basis:auto;width:100%}}.workflow-list-loading.svelte-ie2kfk{justify-content:center;align-items:center;gap:8px;display:flex}.workflows-list.svelte-ie2kfk{min-width:0}.workflow-card-grid.svelte-ie2kfk{grid-template-columns:1fr;gap:16px;display:grid}.workflow-page-note.svelte-l8kr26{color:var(--text-muted);margin-top:6px;font-size:14px}.audit-log-toolbar.svelte-1pwbpcm{flex-direction:column;gap:10px;margin-bottom:14px;display:flex}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:repeat(12,minmax(0,1fr));gap:10px;display:grid}.audit-filter-select.svelte-1pwbpcm{grid-column:span 2;min-width:0}.audit-filter-row-search.svelte-1pwbpcm .filter-input-wrap{grid-column:1/-1;max-width:none}.audit-filter-row-controls.svelte-1pwbpcm .audit-filter-select:where(.svelte-1pwbpcm){grid-column:span 2}.audit-filter-row-controls.svelte-1pwbpcm .btn{grid-column:11/-1;justify-self:end;min-width:108px}.audit-clear-btn.svelte-1pwbpcm{justify-content:center;align-items:center;gap:8px;font-weight:600;display:inline-flex}.audit-clear-btn.svelte-1pwbpcm .table-icon-svg{width:12px;height:12px}@media (width<=768px){.audit-log-toolbar.svelte-1pwbpcm{gap:8px}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:1fr}.audit-filter-row.svelte-1pwbpcm .filter-input-wrap,.audit-filter-row.svelte-1pwbpcm .filter-input,.audit-filter-select.svelte-1pwbpcm,.audit-filter-row.svelte-1pwbpcm .btn{grid-column:auto}}.audit-live-status.svelte-tve6yv{color:var(--text-muted);align-items:center;gap:10px;margin-left:16px;padding-left:6px;font-size:12px;display:inline-flex}.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:1.8s ease-out infinite svelte-tve6yv-audit-live-dot-throb}@keyframes svelte-tve6yv-audit-live-dot-throb{0%{transform:scale(1)}35%{transform:scale(1.35)}70%{transform:scale(1)}to{transform:scale(1)}}@media (prefers-reduced-motion:reduce){.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:none}}.audit-live-status-text.is-live.svelte-tve6yv{color:var(--success);font-weight:600}.audit-entry-metadata.svelte-hyopt0{border-top:1px solid var(--border);align-items:center;gap:10px;margin-top:12px;padding-top:12px;display:flex}.audit-entry-metadata-label.svelte-hyopt0{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;flex:none;font-size:12px;font-weight:700}.audit-entry-context.svelte-hyopt0{flex-wrap:wrap;flex:auto;gap:8px;display:flex}.audit-alias-badge.svelte-hyopt0{background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 28%, var(--border));color:var(--accent-strong,var(--accent))}@media (width<=768px){.audit-entry-metadata.svelte-hyopt0{flex-direction:column;align-items:flex-start;gap:8px}}.audit-attempt-track.svelte-1eu22xn{cursor:pointer;align-items:center;gap:6px;display:inline-flex}.audit-attempt-track-pips.svelte-1eu22xn{align-items:center;gap:3px;display:inline-flex}.audit-attempt-pip.svelte-1eu22xn{background:var(--text-muted);border-radius:2px;width:8px;height:8px}.audit-attempt-pip.audit-attempt-success.svelte-1eu22xn{background:var(--success)}.audit-attempt-pip.audit-attempt-error.svelte-1eu22xn{background:var(--danger)}.audit-attempt-track-count.svelte-1eu22xn{color:var(--text-muted);font-size:11px}.audit-entry-summary.svelte-17mysgz{cursor:pointer;justify-content:space-between;align-items:center;gap:12px;padding:5px 14px;list-style:none;display:flex;position:relative}.audit-entry-summary.svelte-17mysgz::-webkit-details-marker{display:none}.audit-entry-summary-live-in-progress.svelte-17mysgz{background:color-mix(in srgb, var(--info) 7%, var(--bg))}.audit-entry-summary-has-interactions.svelte-17mysgz{padding-right:44px}.audit-entry-summary-live-in-progress.svelte-17mysgz:before{content:"";background:var(--info);pointer-events:none;width:3px;animation:1.2s ease-in-out infinite audit-live-summary-stripe-blink;position:absolute;inset:0 auto 0 0}@media (prefers-reduced-motion:reduce){.audit-entry-summary-live-in-progress.svelte-17mysgz:before{opacity:.78;animation:none}}.audit-entry-left.svelte-17mysgz{align-items:center;gap:8px;min-width:0;display:flex}.audit-entry-right.svelte-17mysgz{color:var(--text-muted);flex-shrink:0;align-items:center;gap:10px;min-height:28px;display:inline-flex}.audit-thread-expander.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);min-width:28px;height:28px;color:var(--text-muted);cursor:pointer;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;gap:3px;padding:0 7px 0 4px;transition:background .1s ease-out,color .1s ease-out;display:inline-flex}.audit-thread-expander.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 12%, var(--bg));color:var(--accent)}.audit-thread-expander.svelte-17mysgz .audit-thread-expander-svg{width:14px;height:14px}.audit-thread-count.svelte-17mysgz{font-size:11px;font-weight:600}.audit-conversation-trigger.svelte-17mysgz{border:0;border-left:1px solid var(--border);background:color-mix(in srgb, var(--accent) 12%, var(--bg));width:32px;height:100%;color:var(--accent);cursor:pointer;border-radius:0;justify-content:center;align-items:center;margin:0;transition:background .1s ease-out,color .1s ease-out;display:inline-flex;position:absolute;inset:0 0 0 auto}.audit-conversation-trigger.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 20%, var(--bg))}.audit-conversation-trigger.svelte-17mysgz .audit-conversation-trigger-svg{stroke-linecap:butt;stroke-linejoin:miter;width:18px;height:18px}.audit-path.svelte-17mysgz{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.audit-request-badge.svelte-17mysgz{white-space:nowrap;gap:6px;min-width:0}.audit-timestamp-time.svelte-17mysgz{display:none}.audit-provider-model.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);height:24px;color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;border-radius:999px;align-items:center;max-width:420px;padding:0 10px;font-size:12px;display:inline-flex;overflow:hidden}@container dashboard-content (width<=699px){.audit-entry-summary.svelte-17mysgz{flex-direction:column;align-items:flex-start}.audit-entry-right.svelte-17mysgz{justify-content:space-between;width:100%}.audit-request-status.svelte-17mysgz,.audit-timestamp-full.svelte-17mysgz{display:none}.audit-timestamp-time.svelte-17mysgz{display:inline}}.audit-pane-split.svelte-1h5puht{grid-template-columns:1fr 2fr;align-items:start;gap:10px 14px;display:grid}.audit-pane-split-single.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}@container dashboard-content (width<=699px){.audit-pane-split.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}}.audit-pane-split.svelte-1h5puht .audit-pane-block-error:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-pane-empty:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-size-warning:where(.svelte-1h5puht){grid-column:1/-1}.audit-pane-block.svelte-1h5puht{min-width:0}.audit-pane-block.svelte-1h5puht>h5{margin-bottom:6px}.audit-pane-block-head.svelte-1h5puht{justify-content:space-between;align-items:center;gap:8px;margin-bottom:6px;display:flex}.audit-pane-block-title.svelte-1h5puht{align-items:center;gap:8px;min-width:0;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn{background-color:var(--bg-surface);border:1px solid color-mix(in srgb, var(--border) 70%, var(--text) 30%);color:var(--text);cursor:pointer;border-radius:6px;flex:none;align-items:center;gap:6px;padding:4px 8px;font-family:inherit;font-size:12px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn:hover:not(:disabled){background:color-mix(in srgb, var(--bg-surface) 80%, var(--text) 20%);border-color:color-mix(in srgb, var(--border) 45%, var(--text) 55%)}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 18%, var(--bg-surface))}.audit-json.svelte-1h5puht{background:var(--bg-surface);border:1px solid var(--border);box-sizing:border-box;white-space:pre;max-width:100%;max-height:220px;color:var(--text);border-radius:6px;padding:10px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;line-height:1.45;overflow:auto}.audit-pane-error-message.svelte-1h5puht{color:var(--danger)}.audit-pane-clickable-preview.svelte-1h5puht{cursor:pointer}.audit-pane-clickable-preview.svelte-1h5puht:hover{background:color-mix(in srgb, var(--danger) 8%, transparent)}.audit-json-body.svelte-1h5puht{white-space:pre;overflow-wrap:normal}.audit-pane-empty.svelte-1h5puht{text-align:left;padding:8px 0 0}.audit-pane-pending.svelte-1h5puht{align-items:center;gap:8px;display:flex}.audit-pane-streaming.svelte-1h5puht{letter-spacing:.02em;color:var(--text-muted);align-items:center;gap:7px;padding-left:4px;font-size:11px;font-weight:600;display:inline-flex}.audit-size-warning.svelte-1h5puht{color:var(--warning);margin-top:8px;font-size:12px}.audit-request-response.svelte-1bc5vi5{margin-top:4px}.audit-pane-tablist.svelte-1bc5vi5{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:2px;display:flex}.audit-pane-tab.svelte-1bc5vi5{border:1px solid var(--border);color:var(--text-muted);cursor:pointer;background:0 0;border-bottom-color:#0000;border-radius:6px 6px 0 0;align-items:center;gap:8px;margin-bottom:-1px;margin-right:12px;padding:8px 12px;font-family:inherit;font-size:13px;transition:color .15s,border-color .15s,background-color .15s;display:inline-flex}.audit-pane-tab.svelte-1bc5vi5:not(.audit-pane-tab-active):hover{color:var(--text);background:color-mix(in srgb, var(--text) 5%, transparent)}.audit-pane-tab-active.svelte-1bc5vi5{color:var(--text);border-color:var(--border);border-bottom-color:var(--bg);background:var(--bg)}.audit-pane-tab-label.svelte-1bc5vi5{font-weight:600}.audit-pane-tabpanel.svelte-1bc5vi5{min-width:0}.audit-pane-icon.svelte-1bc5vi5{color:var(--text-muted);flex:none;align-items:center;display:inline-flex}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-request{color:var(--accent)}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-response{color:var(--info)}.audit-pane-icon.svelte-1bc5vi5 svg{width:16px;height:16px}.audit-pane-seq.svelte-1bc5vi5{color:var(--text-muted);font-size:12px}.audit-pane-kind.svelte-1bc5vi5{text-transform:uppercase;letter-spacing:.04em;font-size:10px;font-weight:600}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-primary{color:var(--text-muted)}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-failover{color:var(--accent);background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-retry{color:var(--warning);background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 30%, var(--border))}.audit-savings-pill.svelte-1bc5vi5{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);color:var(--prompt-cache-color);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;font-weight:700;display:inline-flex}.audit-step-pill.svelte-1bc5vi5{border:1px dashed var(--border);color:var(--text-muted);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;display:inline-flex}.audit-entry.svelte-cmjgwr{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);transition:background .12s ease-out,border-color .12s ease-out;overflow:hidden}.audit-entry-interactions-open.svelte-cmjgwr{border-color:color-mix(in srgb, var(--prompt-cache-color) 38%, var(--border));background:color-mix(in srgb, var(--prompt-cache-color) 7%, var(--bg))}.audit-entry-details.svelte-cmjgwr{border-top:1px solid var(--border);background:var(--bg-surface);padding:12px;overflow:hidden}.audit-entry-interactions-open.svelte-cmjgwr .audit-entry-details:where(.svelte-cmjgwr){border-top-color:color-mix(in srgb, var(--prompt-cache-color) 24%, var(--border));background:color-mix(in srgb, var(--prompt-cache-color) 5%, var(--bg-surface))}.audit-thread.svelte-pneivi{flex-direction:column;gap:10px;display:flex}.audit-thread-children.svelte-pneivi{flex-direction:column;gap:10px;margin-left:26px;display:flex}.audit-thread-child.svelte-pneivi,.audit-thread-loading.svelte-pneivi{position:relative}.audit-thread-child.svelte-pneivi:before,.audit-thread-loading.svelte-pneivi:before{content:"";border-left:1px solid var(--border);border-bottom:1px solid var(--border);pointer-events:none;border-bottom-left-radius:6px;width:12px;height:calc(50% + 10px);position:absolute;top:-10px;left:-14px}.audit-thread-child.svelte-pneivi:not(:last-child):after{content:"";border-left:1px solid var(--border);pointer-events:none;position:absolute;top:50%;bottom:-10px;left:-14px}.audit-thread-loading.svelte-pneivi{padding:6px 0 6px 4px;display:flex}.audit-thread-more.svelte-pneivi{color:var(--text-muted);padding-left:4px;font-size:12px}.audit-log-loading.svelte-1nhcbov{justify-content:center;padding:2rem 0;display:flex}.audit-list-toolbar.svelte-1nhcbov{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;display:flex}.audit-list-toolbar-left.svelte-1nhcbov{flex-wrap:wrap;align-items:center;gap:16px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov{color:var(--text-muted);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:7px;font-size:13px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov input:where(.svelte-1nhcbov){accent-color:var(--accent);cursor:pointer}.audit-retention-note.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-retention-highlight.svelte-1nhcbov{color:var(--text);font-weight:600}.audit-log-section.svelte-1nhcbov{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.audit-log-summary.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-log-list.svelte-1nhcbov{flex-direction:column;gap:10px;display:flex}.settings-guardrails-list.svelte-1bvx512{min-width:0}.settings-guardrail-type-pill.svelte-1bvx512{border:1px solid color-mix(in srgb, var(--accent) 18%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent);color:var(--text);white-space:nowrap;border-radius:999px;align-items:center;padding:6px 10px;font-size:12px;font-weight:600;display:inline-flex}.settings-guardrail-summary.svelte-1bvx512{color:var(--text);font-size:14px;line-height:1.45}.settings-guardrail-description.svelte-1bvx512{color:var(--text-muted);margin-top:6px;font-size:12px}.model-editor.guardrails-editor-wide{width:min(1080px,100%)}.form-field-fieldset.svelte-s964s3{border:0;min-inline-size:0;margin:0;padding:0}.form-field-legend.svelte-s964s3{color:var(--text-muted);letter-spacing:.5px;text-transform:uppercase;padding:0;font-size:12px;font-weight:600}.model-editor.settings-guardrails-editor{min-width:0}.settings-guardrails-hero.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));border-radius:var(--radius);background:radial-gradient(circle at top right, color-mix(in srgb, var(--accent-hover) 18%, transparent), transparent 42%), radial-gradient(circle at bottom left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 40%), var(--bg-surface);justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:20px;padding:24px;display:flex}.settings-kicker.svelte-5x874c{color:var(--accent);letter-spacing:.08em;text-transform:uppercase;margin:0 0 10px;font-size:11px;font-weight:700}.settings-guardrails-hero.svelte-5x874c h3{margin-bottom:8px}.settings-guardrails-hero.svelte-5x874c p:last-child{color:var(--text-muted);margin-bottom:0}.settings-guardrails-meta.svelte-5x874c{gap:12px;display:flex}.settings-guardrails-stat.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));background:color-mix(in srgb, var(--bg-surface-hover) 76%, transparent);border-radius:16px;min-width:110px;padding:14px 16px}.settings-guardrails-stat-label.svelte-5x874c{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;margin-bottom:8px;font-size:11px;font-weight:700;display:block}.settings-guardrails-stat.svelte-5x874c strong{font-size:24px;font-weight:700}@media (width<=768px){.settings-guardrails-hero.svelte-5x874c{flex-direction:column}.settings-guardrails-meta.svelte-5x874c{width:100%}.settings-guardrails-stat.svelte-5x874c{flex:1 1 0}}.mcp-catalog-section.svelte-1xqrzco{margin-top:18px}.mcp-catalog-section.svelte-1xqrzco .form-field-label{margin-bottom:8px}.mcp-catalog-subtitle.svelte-1xqrzco{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.mcp-catalog-list.svelte-1xqrzco{flex-direction:column;gap:12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.mcp-catalog-item-name.svelte-1xqrzco{overflow-wrap:anywhere;font-size:13px}.mcp-catalog-item-aggregated.svelte-1xqrzco{color:var(--text-muted);overflow-wrap:anywhere;margin-top:2px;font-size:11px}.mcp-catalog-item-description.svelte-1xqrzco{color:var(--text-muted);margin:2px 0 0;font-size:13px;font-weight:400}.mcp-server-sub-counts.svelte-ah8nrt{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;max-width:280px;margin-top:4px;font-size:11px;overflow:hidden}.mcp-server-table-wrapper.svelte-ah8nrt{overflow-x:auto}.mcp-server-table-wrapper.svelte-ah8nrt .data-table{min-width:860px}.auth-key-form-fields.svelte-1gswxes>.form-field{margin-bottom:4px}.auth-key-dashboard-toggle.svelte-1gswxes{cursor:pointer;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-key-issued-banner.svelte-1gswxes{background:color-mix(in srgb, var(--success) 8%, var(--bg-surface));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));border-radius:var(--radius);margin-bottom:20px;padding:16px}.auth-key-issued-warning.svelte-1gswxes{color:color-mix(in srgb, var(--success) 80%, var(--text));margin-bottom:12px;font-size:13px;font-weight:600}.auth-key-issued-value-row.svelte-1gswxes{flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:12px;display:flex}.auth-key-issued-token.svelte-1gswxes{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);word-break:break-all;flex:1;min-width:0;padding:8px 12px;font-size:13px;overflow-x:auto}.usage-label-chip-static.svelte-nf0ldb,.usage-label-chip-static.svelte-nf0ldb:hover{cursor:default;background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.auth-key-redacted.svelte-nf0ldb{color:var(--text-muted);font-size:13px}.auth-key-actions-cell.svelte-nf0ldb{white-space:nowrap}.auth-key-row-deactivated.svelte-nf0ldb td:where(.svelte-nf0ldb):not(.auth-key-actions-cell){opacity:.55}.auth-key-expiry.svelte-nf0ldb{white-space:nowrap;align-items:center;gap:8px;display:inline-flex}.auth-key-th-help.svelte-nf0ldb{cursor:help;align-items:center;gap:4px;display:inline-flex}.auth-key-row-actions.svelte-nf0ldb{align-items:center;gap:6px;display:inline-flex}.auth-keys-loading.svelte-1xpdcqx{justify-content:center;align-items:center;padding:32px 0;display:flex}.auth-keys-help-notice.svelte-1xpdcqx{margin-bottom:20px}.auth-keys-inactive-toggle.svelte-1xpdcqx{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-keys-inactive-toggle.svelte-1xpdcqx input:where(.svelte-1xpdcqx){width:16px;height:16px;accent-color:var(--accent);cursor:pointer}.settings-panel-header.svelte-15kyv2y{justify-content:space-between;gap:16px;margin-bottom:20px;display:flex}.settings-panel-header.svelte-15kyv2y h3{font-size:18px}.settings-form-grid.svelte-15kyv2y{grid-template-columns:minmax(280px,420px);gap:16px;display:grid}@media (width<=768px){.settings-form-grid.svelte-15kyv2y{grid-template-columns:1fr}}.budget-settings-section.svelte-a747ys{width:100%}.budget-settings-grid.svelte-a747ys{gap:12px;display:grid}.budget-settings-row.svelte-a747ys{grid-template-columns:96px minmax(170px,1fr) minmax(110px,140px) minmax(110px,140px) minmax(220px,280px);align-items:start;gap:12px;display:grid}.budget-settings-period.svelte-a747ys{color:var(--text);letter-spacing:0;text-transform:uppercase;align-self:end;min-height:35px;padding-bottom:9px;font-size:12px;font-weight:700}.budget-settings-spacer.svelte-a747ys{min-height:1px}.budget-settings-help-cell.svelte-a747ys{align-self:start;min-width:0;min-height:35px}.budget-settings-help-cell.svelte-a747ys .inline-help-copy{max-width:280px;margin:22px 0 0;font-size:12px;line-height:1.35}@media (width<=768px){.budget-settings-grid.svelte-a747ys,.budget-settings-row.svelte-a747ys{grid-template-columns:1fr}.budget-settings-spacer.svelte-a747ys{display:none}}.tagging-settings-grid.svelte-18e8yem{gap:12px;display:grid}.tagging-settings-row.svelte-18e8yem{grid-template-columns:minmax(170px,1fr) minmax(150px,1fr) minmax(80px,110px) auto minmax(90px,auto);align-items:end;gap:12px;display:grid}.tagging-do-not-pass.svelte-18e8yem{color:var(--text);white-space:nowrap;align-items:center;gap:6px;min-height:35px;font-size:13px;display:flex}.tagging-row-trailer.svelte-18e8yem{align-items:center;gap:8px;min-height:35px;display:flex}.tagging-settings-empty.svelte-18e8yem{color:var(--text-muted);margin:0}.tagging-settings-actions.svelte-18e8yem{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.tagging-settings-row.svelte-18e8yem{grid-template-columns:1fr;align-items:stretch}.tagging-settings-actions.svelte-18e8yem,.tagging-settings-actions.svelte-18e8yem .btn{width:100%}}.pricing-recalculate-section.svelte-1cdxzyk{width:100%}.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:minmax(220px,320px) minmax(260px,360px);justify-content:start;align-items:end;gap:12px;width:100%;display:grid}.pricing-recalculate-date-field.svelte-1cdxzyk{grid-column:1/-1;width:100%;max-width:320px}.pricing-recalculate-filter-field.svelte-1cdxzyk{width:100%;max-width:360px}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker{width:100%}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-trigger{justify-content:space-between;width:100%}.pricing-recalculate-actions.svelte-1cdxzyk{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:1fr}.pricing-recalculate-actions.svelte-1cdxzyk,.pricing-recalculate-actions.svelte-1cdxzyk .btn{width:100%}}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-dropdown{inset:auto auto calc(100% + 6px) 0}.settings-refresh-icon.svelte-yeq2mp{flex:0 0 16px;width:16px;height:16px}.runtime-refresh-steps.svelte-yeq2mp{color:var(--text-muted);gap:8px;margin-top:14px;padding-left:18px;font-size:13px;display:grid}.runtime-refresh-step.is-ok.svelte-yeq2mp{color:var(--success)}.runtime-refresh-step.is-partial.svelte-yeq2mp{color:var(--warning)}.runtime-refresh-step.is-failed.svelte-yeq2mp{color:var(--danger)}.runtime-settings-copy.svelte-tldbe5{min-width:180px}.runtime-settings-fields.svelte-tldbe5{gap:16px;width:min(560px,100%);display:grid}.runtime-setting-row.svelte-tldbe5{grid-template-columns:minmax(220px,1fr) 180px;align-items:center;gap:20px;display:grid}.runtime-setting-description.svelte-tldbe5,.runtime-setting-managed.svelte-tldbe5{color:var(--text-muted);margin:4px 0 0;font-size:12px}.runtime-setting-managed.svelte-tldbe5{color:var(--warning)}@media (width<=720px){.runtime-setting-row.svelte-tldbe5{grid-template-columns:1fr;gap:8px}}.settings-version-footer.svelte-3naq7u{color:var(--text-muted);text-align:right;margin-top:24px;font-size:12px}.chat-message.svelte-12s99s5{border:1px solid var(--border);background:var(--bg);border-radius:10px;max-width:94%;padding:10px 12px}.chat-message.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border));box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent)}.chat-message.is-after-anchor.svelte-12s99s5,.chat-function-note.is-after-anchor.svelte-12s99s5{opacity:.46}.chat-message.role-user.svelte-12s99s5{align-self:flex-start}.chat-message.role-assistant.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 18%, var(--bg));align-self:flex-end}.chat-message.role-system.svelte-12s99s5{background:color-mix(in srgb, var(--warning) 10%, var(--bg));align-self:center;width:100%;max-width:100%}.chat-message.role-error.svelte-12s99s5{border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg));align-self:flex-end}.chat-message.role-error.svelte-12s99s5 .chat-role:where(.svelte-12s99s5){color:color-mix(in srgb, var(--danger) 75%, var(--text-muted))}.chat-message-meta.svelte-12s99s5{justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:6px;display:flex}.chat-role.svelte-12s99s5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:12px;font-weight:700}.chat-time.svelte-12s99s5{color:var(--text-muted);white-space:nowrap;font-size:11px}.chat-content.svelte-12s99s5{white-space:pre-wrap;overflow-wrap:break-word;color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:13px;line-height:1.5}.chat-tool-calls.svelte-12s99s5{border-top:1px solid var(--border);flex-direction:column;gap:3px;margin-top:8px;padding-top:6px;display:flex}.chat-tool-call.svelte-12s99s5{color:var(--text-muted);font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px}.chat-tool-call-name.svelte-12s99s5:before{content:"⚡"}.chat-function-note.svelte-12s99s5{max-width:94%;color:var(--text-muted);background:color-mix(in srgb, var(--border) 40%, transparent);border:1px dashed var(--border);border-radius:12px;align-self:center;padding:4px 12px;font-size:12px}.chat-function-note.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-inner.svelte-12s99s5{align-items:baseline;gap:6px;display:flex;overflow:hidden}.chat-function-label.svelte-12s99s5{text-transform:uppercase;letter-spacing:.3px;white-space:nowrap;flex-shrink:0;font-size:11px;font-weight:600}.chat-function-detail.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;overflow:hidden}.chat-function-note.role-function-call.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 8%, transparent);border-color:color-mix(in srgb, var(--accent) 30%, var(--border));align-self:flex-end}.chat-function-note.role-function-result.svelte-12s99s5{background:color-mix(in srgb, var(--success) 8%, transparent);border-color:color-mix(in srgb, var(--success) 30%, var(--border));align-self:flex-start}.chat-function-note.is-anchor.role-function-call.svelte-12s99s5,.chat-function-note.is-anchor.role-function-result.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-details.svelte-12s99s5{width:100%}.chat-function-note-details.svelte-12s99s5>summary{cursor:pointer;list-style:none}.chat-function-note-details.svelte-12s99s5>summary::-webkit-details-marker{display:none}.chat-function-expanded.svelte-12s99s5{border-top:1px solid var(--border);white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text);max-height:200px;margin-top:6px;padding-top:6px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;line-height:1.45;overflow:auto}@media (width<=768px){.chat-message.svelte-12s99s5{max-width:100%}}.conversation-drawer.svelte-ssrzja{flex:0 0 var(--conversation-panel-width);width:var(--conversation-panel-width);background:var(--bg-surface);border-left:1px solid var(--border);z-index:12;flex-direction:column;min-width:0;height:100vh;display:flex;position:sticky;top:0}.conversation-drawer-fullscreen.svelte-ssrzja{z-index:70;border-left:0;flex-basis:auto;width:100vw;height:100dvh;position:fixed;inset:0}.conversation-drawer-fullscreen.svelte-ssrzja .conversation-resize-handle:where(.svelte-ssrzja){display:none}.conversation-resize-handle.svelte-ssrzja{z-index:2;cursor:col-resize;touch-action:none;background:0 0;border:0;border-radius:0;outline:none;width:10px;padding:0;position:absolute;top:0;bottom:0;left:-5px}.conversation-resize-handle.svelte-ssrzja:after{content:"";background:0 0;width:2px;transition:background .15s;position:absolute;top:0;bottom:0;left:4px}.conversation-resize-handle.svelte-ssrzja:hover:after,.conversation-resize-handle.svelte-ssrzja:focus-visible:after{background:color-mix(in srgb, var(--accent) 70%, var(--border))}body.conversation-panel-resizing{cursor:col-resize;-webkit-user-select:none;user-select:none}.conversation-drawer-header.svelte-ssrzja{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:10px;padding:14px 16px;display:flex}.conversation-drawer-header-actions.svelte-ssrzja{align-items:center;gap:6px;display:flex}.conversation-drawer-header.svelte-ssrzja h3{font-size:16px;font-weight:700}.conversation-meta.svelte-ssrzja{color:var(--text-muted);font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px}.conversation-drawer-footer.svelte-ssrzja{border-top:1px solid var(--border);background:var(--bg-surface);flex-direction:column;flex-shrink:0;gap:9px;padding:10px 16px;display:flex}.conversation-composer.svelte-ssrzja{flex-direction:column;gap:7px;display:flex}.conversation-composer.svelte-ssrzja label:where(.svelte-ssrzja){font-size:12px;font-weight:700}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja){resize:vertical;border:1px solid var(--border);background:var(--bg);width:100%;min-height:70px;color:var(--text);font:inherit;border-radius:7px;padding:9px 10px;line-height:1.45}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):focus{outline:2px solid color-mix(in srgb, var(--accent) 38%, transparent);outline-offset:1px}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):disabled{opacity:.65}.conversation-composer-actions.svelte-ssrzja{justify-content:space-between;align-items:center;gap:10px;display:flex}.conversation-endpoint.svelte-ssrzja{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--text-muted);font-size:11px;overflow:hidden}.conversation-send-error.svelte-ssrzja{color:var(--danger);font-size:12px}.conversation-truncated.svelte-ssrzja{color:var(--text-muted);padding:0 16px 14px;font-size:12px}.conversation-thread.svelte-ssrzja{flex-direction:column;gap:10px;padding:14px 16px 20px;display:flex}.conversation-live-status.svelte-ssrzja{color:var(--text-muted);align-items:center;gap:10px;padding:4px 16px 20px;font-size:13px;display:flex} +:root{--bg:#111110;--bg-surface:#1e1d1c;--bg-surface-hover:#2a2420;--border:#2a2826;--text:#e8e0d6;--text-muted:#9a918a;--accent:#b8956e;--accent-hover:#d4b896;--success:#34d399;--info:#3b82f6;--warning:#f59e0b;--danger:#ef4444;--prompt-cache-color:color-mix(in srgb, var(--info) 72%, #fff);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 24%, var(--bg-surface));--cache-meter-uncached:var(--token-input);--cache-meter-local:var(--token-local);--cache-meter-prompt:var(--token-prompt);--token-input:#c0824a;--token-output:#ddb27a;--token-prompt:color-mix(in srgb, var(--info) 60%, transparent);--token-local:color-mix(in srgb, var(--info) 20%, transparent);--sidebar-width:240px;--radius:8px;--chart-grid:#2a2826;--chart-text:#9a918a;--chart-day-marker:var(--text);--chart-tooltip-bg:#1e1d1c;--chart-tooltip-border:#2a2826;--chart-tooltip-text:#e8e0d6;--cal-level-0:#161b22;--cal-level-1:color-mix(in srgb, var(--info) 15%, var(--bg-surface));--cal-level-2:color-mix(in srgb, var(--info) 25%, var(--bg-surface));--cal-level-3:color-mix(in srgb, var(--info) 36%, var(--bg-surface));--cal-level-4:color-mix(in srgb, var(--info) 48%, var(--bg-surface));--cal-level-5:color-mix(in srgb, var(--info) 60%, var(--bg-surface));--cal-level-6:color-mix(in srgb, var(--info) 73%, var(--bg-surface));--cal-level-7:color-mix(in srgb, var(--info) 87%, var(--bg-surface));--cal-level-8:var(--info);--cal-level-9:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-10:color-mix(in srgb, var(--info) 62%, #fff);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface-hover) 86%, #fff 14%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface-hover) 72%, #fff 28%);--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}[data-theme=light]{--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}@media (prefers-color-scheme:light){:root:not([data-theme=dark]){--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}}*{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;line-height:1.5}body.dashboard-modal-open{overflow:hidden}.app{height:100vh;min-height:0;display:flex;overflow:hidden}.badge{background:var(--accent);color:#fff;text-transform:uppercase;letter-spacing:.5px;border-radius:10px;padding:2px 8px;font-size:10px;font-weight:600}.auth-dialog{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:min(440px,100%);padding:22px;box-shadow:0 24px 70px #00000061}.auth-dialog-header{justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px;display:flex}.auth-dialog h2{margin-top:2px;font-size:22px;line-height:1.2}.auth-dialog-close{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.auth-dialog-close:hover{color:var(--text);background:var(--bg-surface-hover)}.auth-dialog-close:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-hint{color:var(--text-muted);font-size:13px}.auth-dialog-error{color:var(--danger);font-size:13px;font-weight:600}.auth-dialog-form{gap:10px;margin-top:18px;display:grid}.auth-dialog-actions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}.content{-webkit-overflow-scrolling:touch;flex:1 1 0;width:100%;min-width:0;min-height:0;padding:32px;transition:width .2s;overflow-y:auto;container:dashboard-content/inline-size}.content>*{width:100%;max-width:1336px;margin-inline:auto}body.dashboard-modal-open .content{overflow-y:hidden}.content.interactions-open>*{max-width:none}.page-header{justify-content:space-between;align-items:center;margin-bottom:24px;display:flex}.page-header h2{letter-spacing:-.3px;font-size:22px;font-weight:700}.page-header-controls{align-items:center;gap:12px;display:flex}.page-with-sticky-date{grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:12px;display:grid}.page-with-sticky-date>*{grid-column:1/-1}.page-with-sticky-date>.date-range-page-header{grid-column:1}.page-with-sticky-date>.sticky-date-range{z-index:8;grid-column:2;justify-self:end;position:sticky;top:16px}.model-count{color:var(--text-muted);font-size:14px}.provider-status-section{margin-top:28px;scroll-margin-top:24px}.cards{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:28px;display:grid}.card{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px}.card-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);margin-bottom:8px;font-size:12px;font-weight:600}.card-value{letter-spacing:-.5px;font-size:28px;font-weight:700}.cache-meter{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:28px;padding:24px}.chart-container{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.chart-container h3{margin-bottom:16px;font-size:16px;font-weight:600}.chart-container-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;display:flex}.chart-container-header h3{margin-bottom:0}.chart-wrapper{height:210px;position:relative}.live-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:8px;height:8px}.live-dot.is-streaming{background:var(--success);position:relative}.live-dot.is-streaming:after{content:"";z-index:-1;background:color-mix(in srgb, var(--success) 55%, transparent);border-radius:50%;animation:1.8s ease-out infinite live-dot-pulse;position:absolute;inset:0}@media (prefers-reduced-motion:reduce){.live-dot.is-streaming:after{opacity:0;animation:none}}@keyframes live-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(2.5)}to{opacity:0;transform:scale(2.5)}}.alert{border-radius:var(--radius);margin-bottom:20px;padding:12px 16px;font-size:14px}.alert-warning{color:var(--warning);background:#f59e0b1a;border:1px solid #f59e0b4d}.table-toolbar{align-items:center;gap:12px;margin-bottom:16px;display:flex}.table-toolbar-main{flex:1;min-width:0}.table-toolbar-actions{justify-content:flex-end;margin-left:auto;display:flex}input:is([type=text],[type=date],[type=number]){background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:8px 12px;font-family:inherit;font-size:13px}input:is([type=text],[type=date],[type=number]):focus{border-color:var(--accent)}input:is([type=text],[type=date],[type=number]):disabled,textarea:disabled,.form-input:disabled{opacity:.6;cursor:not-allowed}.table-wrapper{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}.data-table{border-collapse:collapse;width:100%;font-size:14px}.data-table th{text-align:left;text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);background:var(--bg);border-bottom:1px solid var(--border);padding:12px 16px;font-size:12px;font-weight:600}.data-table th.model-actions-header{text-align:right;white-space:nowrap;width:1%;min-width:156px}.data-table td{border-bottom:1px solid var(--border);padding:10px 16px}.data-table tr:last-child td{border-bottom:none}.data-table tr:hover td{background:var(--bg-surface-hover)}.mono{font-family:SF Mono,Menlo,Consolas,monospace}.font-size-md{font-size:13px}.col-price,.data-table th.col-price{text-align:right}td.col-price{color:var(--text-muted);white-space:nowrap;font-family:SF Mono,Menlo,Consolas,monospace;font-size:13px}.provider-badge{background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:2px 10px;font-size:12px;font-weight:500;display:inline-block}.empty-state{text-align:center;color:var(--text-muted);padding:48px 0;font-size:14px}.empty-state-icon{width:auto;height:auto;max-height:160px;color:var(--text-muted);margin:0 auto;display:block}.empty-state-icon text{fill:var(--text-muted);font-family:inherit;font-weight:600}.chart-empty-overlay{pointer-events:none;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.chart-empty-overlay .empty-state-icon{width:auto;max-width:90%;height:auto;max-height:195px}.loading-spinner{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:16px;height:16px;animation:.8s linear infinite loading-spin}@keyframes loading-spin{to{transform:rotate(360deg)}}.table-action-btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;gap:6px;padding:6px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:inline-flex}.table-action-btn:hover:not(:disabled){background:var(--bg-surface-hover)}.table-action-btn:disabled{opacity:.45;cursor:default}.table-action-btn-danger{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.table-action-btn-active{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 12%, var(--bg));border-color:color-mix(in srgb, var(--accent) 38%, var(--border))}.table-action-btn-active:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 18%, var(--bg-surface-hover))}.table-action-btn-failover-active{color:var(--info);background:color-mix(in srgb, var(--cache-meter-prompt) 35%, var(--bg));border-color:color-mix(in srgb, var(--info) 45%, var(--border));position:relative}.table-action-btn-failover-active:hover:not(:disabled){background:color-mix(in srgb, var(--cache-meter-prompt) 45%, var(--bg-surface-hover))}.table-icon-btn{border-radius:6px;gap:0;width:32px;min-width:32px;height:32px;padding:0}.table-icon-btn.table-action-btn-active{position:relative}.table-icon-btn.table-action-btn-active:after{content:"";background:var(--accent);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-btn.table-action-btn-failover-active:after{content:"";background:var(--info);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-svg{flex-shrink:0;width:14px;height:14px}.model-editor{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:16px;padding:24px}.alias-kind-badge{border:1px solid var(--border);background:var(--bg);min-height:24px;color:var(--accent);letter-spacing:.2px;text-transform:uppercase;border-color:color-mix(in srgb, var(--accent) 55%, var(--border));border-radius:999px;justify-content:center;align-items:center;gap:4px;padding:0 10px;font-size:11px;font-weight:600;display:inline-flex}.form h3{font-size:20px;font-weight:700}.form-kicker,.form-hint{color:var(--text-muted);font-size:13px}.alias-actions-cell{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.model-list-actions{white-space:nowrap;flex-wrap:nowrap}.model-list-actions .table-icon-btn{flex:0 0 32px}.model-list-actions .alias-toggle{flex:none}.alias-toggle{border:1px solid var(--border);background:var(--bg);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:8px;padding:6px 10px;font-family:inherit;font-size:12px;transition:all .15s;display:inline-flex}.alias-toggle:hover:not(:disabled){background:var(--bg-surface-hover)}.alias-toggle:disabled{opacity:.45;cursor:default}.alias-toggle-track{background:color-mix(in srgb, var(--border) 80%, var(--bg));border-radius:6px;width:34px;height:18px;transition:background .15s;position:relative}.alias-toggle-thumb{background:var(--text-muted);border-radius:6px;width:16px;height:16px;transition:transform .15s,background .15s;position:absolute;top:1px;left:2px}.alias-toggle.enabled{border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.alias-toggle.enabled .alias-toggle-track{background:color-mix(in srgb, var(--success) 55%, var(--bg))}.alias-toggle.enabled .alias-toggle-thumb{background:#fff;transform:translate(14px)}.alias-toggle.restricted{border-color:color-mix(in srgb, var(--accent) 50%, var(--border));color:color-mix(in srgb, var(--accent) 70%, var(--text))}.alias-toggle.restricted .alias-toggle-track{background:color-mix(in srgb, var(--accent) 55%, var(--bg))}.editor-header{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:20px;display:flex}.form{flex-direction:column;gap:16px;display:flex}.auth-key-editor{background:color-mix(in srgb, var(--bg-surface) 82%, var(--bg) 18%)}.form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.form-field{flex-direction:column;gap:8px;display:flex}.form-field-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);font-size:12px;font-weight:600;display:inline-block}.vm-target-row{align-items:center;gap:8px;display:flex}.vm-target-row .vm-target-model{flex:auto;min-width:0}.vm-target-row .vm-target-weight{flex:0 0 88px;width:88px}.vm-status-row{justify-content:space-between;align-items:center;gap:12px;display:flex}.vm-status-row .vm-status-toggle{margin-left:auto}.form-error{border:1px solid color-mix(in srgb, var(--danger) 42%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface));color:var(--danger);overflow-wrap:anywhere;margin:0;padding:10px 12px;font-size:13px;font-weight:600;line-height:1.4}.form-error:empty{display:none}.form-field-error{color:var(--danger);overflow-wrap:anywhere;font-size:13px;font-weight:500;line-height:1.4}.form-field-required{color:var(--danger);margin-left:3px}:is(input,textarea,select)[aria-invalid=true]{border-color:color-mix(in srgb, var(--danger) 60%, var(--border))}:is(input,textarea,select)[aria-invalid=true]:focus{border-color:var(--danger)}textarea{resize:vertical;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:60px;color:var(--text);outline:none;padding:10px 12px;font-family:inherit;font-size:13px}textarea:focus{border-color:var(--accent)}.form-input{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:38px;color:var(--text);outline:none;padding:8px 10px;font-family:inherit;font-size:13px}.form-input:focus{border-color:var(--accent)}.form-actions{flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:16px;display:flex}.failover-target-actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.data-table tr.alias-row.is-valid td{background:var(--alias-row-valid-bg)}.data-table tr.alias-row.is-valid:hover td{background:var(--alias-row-valid-bg-hover)}.data-table tr.alias-row:not(.is-valid) td{background:color-mix(in srgb, var(--accent) 10%, var(--bg-surface))}.data-table tr.alias-row:not(.is-valid):hover td{background:color-mix(in srgb, var(--accent) 16%, var(--bg-surface-hover))}.data-table tr.alias-row.is-disabled td{background:var(--bg-surface);opacity:.58}.data-table tr.alias-row.is-disabled:hover td{background:var(--bg-surface-hover);opacity:.72}.data-table tr.model-access-disabled-row td{background:color-mix(in srgb, var(--danger) 6%, var(--bg-surface))}.data-table tr.model-access-disabled-row:hover td{background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface-hover))}.workflow-section-head{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-section-head h4{font-size:14px;font-weight:700}.workflow-preview{flex-direction:column;gap:12px;display:flex}.workflow-feature-toggles{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.workflow-feature-toggle{border:1px solid var(--border);background:var(--bg);border-radius:10px;align-items:center;gap:10px;padding:10px 12px;font-size:14px;font-weight:500;display:flex}.workflow-feature-toggle input{width:16px;height:16px}.model-chart-section{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:24px;padding:24px}.model-chart-section h3{margin:0;font-size:16px;font-weight:600}.model-chart-header{justify-content:space-between;align-items:center;gap:16px;margin-bottom:16px;display:flex}.bar-chart-wrap{width:100%;height:180px;position:relative}.form-select,.usage-log-select{appearance:none;background-color:var(--bg);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 17px),calc(100% - 12px);background-repeat:no-repeat;background-size:5px 5px;outline:none;min-width:140px;padding:8px 34px 8px 12px;font-family:inherit;font-size:13px}.form-select:disabled,.usage-log-select:disabled{cursor:not-allowed;opacity:.6}.form-select:focus,.usage-log-select:focus{border-color:var(--accent)}.form-select{width:100%;min-width:0}.usage-label-chips{flex-wrap:wrap;gap:4px;max-width:280px;display:inline-flex}.usage-label-chip{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg));min-height:20px;color:var(--text);white-space:nowrap;cursor:pointer;border-radius:999px;align-items:center;padding:1px 9px;font-family:inherit;font-size:11px;font-style:normal;font-weight:600;line-height:1.4;transition:background .15s,border-color .15s;display:inline-flex}.usage-label-chip:hover{background:color-mix(in srgb, var(--label-color,var(--accent)) 26%, var(--bg))}.usage-label-chip.active{background:color-mix(in srgb, var(--label-color,var(--accent)) 32%, var(--bg));border-color:var(--label-color,var(--accent));box-shadow:0 0 0 1px color-mix(in srgb, var(--label-color,var(--accent)) 55%, transparent)}@keyframes audit-live-summary-stripe-blink{0%,to{opacity:.9}50%{opacity:.28}}.audit-status-badge{border:1px solid var(--border);letter-spacing:.2px;background:var(--bg-surface);border-radius:999px;justify-content:center;align-items:center;min-width:46px;height:24px;padding:0 10px;font-size:12px;font-weight:600;display:inline-flex}.audit-status-badge.status-success{color:var(--success);border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.audit-status-badge.status-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.audit-status-badge.status-error{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.audit-status-badge.status-neutral{color:var(--text-muted)}.audit-status-badge.status-unknown{color:var(--text-muted);border-color:color-mix(in srgb, var(--border) 75%, transparent)}.audit-pane{border:1px solid var(--border);background:var(--bg);border-top:0;border-radius:0 0 8px 8px;min-width:0;padding:12px}.audit-pane h5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:11px;font-weight:600}.audit-prompt-cache-pill{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);min-height:20px;color:var(--prompt-cache-color);letter-spacing:.02em;text-transform:none;border-radius:999px;align-items:center;padding:2px 8px;font-size:11px;font-weight:700;display:inline-flex}.audit-prompt-cache-highlight{color:var(--prompt-cache-color);font-weight:700}.audit-audio{white-space:normal;flex-direction:column;gap:8px;display:flex}.audit-audio-player{width:100%;max-width:420px;height:36px}.audit-audio-meta{color:var(--text-muted);font-size:12px}.audit-audio-empty{align-items:flex-start;padding:4px 0}.audit-audio-icon{font-size:20px;line-height:1}.audit-audio-note{color:var(--text-muted);font-size:12px}.audit-audio-metadata{flex-direction:column;gap:2px;margin-top:4px;font-size:12px;display:flex}.audit-audio-meta-row{gap:8px;display:flex}.audit-audio-meta-key{color:var(--text-muted);min-width:120px}.conversation-body-highlight{border-left:2px solid color-mix(in srgb, var(--accent) 70%, var(--border));background:color-mix(in srgb, var(--accent) 10%, transparent);cursor:pointer;line-height:inherit;border-radius:2px;margin:0 0 0 -2px;padding:0 0 0 2px;display:inline}.conversation-body-highlight:hover{background:color-mix(in srgb, var(--accent) 18%, transparent)}.conversation-body-highlight.conversation-system{border-left-color:color-mix(in srgb, var(--warning) 70%, var(--border));background:color-mix(in srgb, var(--warning) 10%, transparent)}.conversation-body-highlight.conversation-user{border-left-color:color-mix(in srgb, var(--accent) 75%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent)}.conversation-body-highlight.conversation-assistant{border-left-color:color-mix(in srgb, var(--success) 65%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}#interactions-drawer-content{flex:1;min-height:0;overflow-y:auto}.pagination{justify-content:space-between;align-items:center;padding:12px 0 0;display:flex}.btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;padding:6px 16px;font-family:inherit;font-size:13px;transition:all .15s}.btn:hover:not(:disabled){background:var(--bg-surface-hover)}.btn-primary{background:var(--accent);border-color:color-mix(in srgb, var(--accent) 70%, #000 10%);color:#fff;font-weight:600;box-shadow:0 10px 22px #3b82f62e}.btn-primary:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 90%, #fff 10%);border-color:color-mix(in srgb, var(--accent) 78%, #000 12%)}.btn-danger-outline{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:0 0;font-weight:600}.btn-danger-outline:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 75%, var(--border))}.btn-danger{color:#fff;border-color:color-mix(in srgb, var(--danger) 76%, #000 12%);background:var(--danger);box-shadow:0 10px 22px color-mix(in srgb, var(--danger) 20%, transparent);font-weight:600}.btn-danger:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 90%, #fff 10%);border-color:color-mix(in srgb, var(--danger) 82%, #000 14%)}.btn-with-icon{justify-content:center;align-items:center;gap:8px;display:inline-flex}.btn-with-icon .table-icon-svg{width:16px;height:16px}.btn:disabled{opacity:.4;cursor:default}.settings-panel{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.inline-help-section{flex-direction:column;gap:2px;display:flex}.inline-help-title-row{align-items:center;gap:10px;display:inline-flex}.inline-help-title-row h2,.inline-help-title-row h3{margin-bottom:0}.inline-help-title-row h2:empty,.inline-help-title-row h3:empty{display:none}.inline-help-toggle{border:1px solid color-mix(in srgb, var(--accent) 28%, var(--border));width:16px;height:16px;color:var(--accent);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border-radius:4px;justify-content:center;align-items:center;padding:0;transition:color .18s,border-color .18s;display:inline-flex;position:relative}.inline-help-toggle:before{content:"";pointer-events:auto;background:0 0;width:32px;height:32px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.inline-help-toggle:hover{border-color:color-mix(in srgb, var(--accent) 48%, var(--border));color:var(--text);background:0 0}.inline-help-toggle:active{background:0 0}.inline-help-toggle:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.inline-help-toggle-icon{justify-content:center;align-items:center;width:100%;height:100%;padding-bottom:1px;font-size:13px;font-weight:700;line-height:1;transition:transform .52s cubic-bezier(.22,.72,.12,1);display:inline-flex;transform:rotate(0)}.inline-help-copy{max-width:780px;color:var(--text-muted);margin-top:2px;font-size:14px}.settings-select{width:100%}.settings-refresh-section{border-top:1px solid var(--border);justify-items:start;gap:12px;margin-top:24px;padding-top:22px;display:grid}.settings-refresh-section h3{font-size:18px}.settings-refresh-section p{max-width:720px;color:var(--text-muted);font-size:14px;line-height:1.55}.budget-list{gap:10px;padding:10px 0;display:grid}.budget-row{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);grid-template-columns:minmax(0,1fr);align-items:center;gap:16px;padding:12px 14px;display:grid}.budget-row-main{min-width:0}.budget-row-head{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:10px;min-width:0;display:grid}.budget-scope-value{width:fit-content;max-width:100%;min-height:24px;color:var(--text);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;justify-self:start;align-items:center;gap:5px;padding:2px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;display:inline-flex;overflow:hidden}.budget-user-path{border:1px solid color-mix(in srgb, var(--accent) 32%, var(--border));background:color-mix(in srgb, var(--accent) 9%, var(--bg))}.budget-label{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.budget-scope-icon{stroke-width:2.2px;opacity:.85;flex:0 0 12px;width:12px;height:12px}.budget-row-meta{min-width:0;color:var(--text-muted);align-items:center;gap:8px;font-size:12px;display:inline-flex}.budget-source{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:999px;padding:2px 7px;font-size:11px}.budget-row-period{justify-content:center;min-width:0;display:flex}.budget-row-controls{justify-content:flex-end;align-items:center;gap:8px;min-width:0;display:flex}.budget-bars{gap:6px;margin-top:10px;display:grid}.budget-bar-line{grid-template-columns:118px minmax(0,1fr);align-items:center;gap:10px;display:grid}.budget-bar-label{color:var(--text-muted);justify-content:space-between;align-items:center;gap:6px;font-size:11px;line-height:1;display:flex}.budget-bar-percent{font-weight:700}.budget-bar-track{background:color-mix(in srgb, var(--border) 75%, var(--bg));border-radius:999px;height:16px;position:relative;overflow:hidden}.budget-bar-fill{border-radius:inherit;min-width:0;height:100%;transition:width .2s}.budget-bar-fill-usage{background:color-mix(in srgb, var(--success) 82%, var(--accent))}.budget-bar-fill-danger{background:var(--danger)}.budget-bar-text-row{z-index:1;pointer-events:none;color:var(--text);position:absolute;inset:0}.budget-bar-text{text-overflow:ellipsis;white-space:nowrap;max-width:min(44%,190px);font-size:11px;font-weight:700;line-height:12px;position:absolute;top:50%;overflow:hidden}.budget-bar-text-center{max-width:min(46%,240px);left:50%;transform:translate(-50%,-50%)}.budget-bar-text-end{text-align:right;max-width:min(34%,180px);right:8px;transform:translateY(-50%)}.budget-period-label{border:1px solid var(--border);color:var(--text);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;gap:5px;padding:2px 7px;font-size:11px;font-weight:600;display:inline-flex}.budget-period-icon{stroke-width:2.2px;flex:0 0 12px;width:12px;height:12px}.budget-period-label-monthly{border-color:color-mix(in srgb, #30302c 62%, var(--border));background:color-mix(in srgb, #30302c 12%, var(--bg));color:color-mix(in srgb, #30302c 34%, var(--text) 66%)}.budget-period-label-weekly{border-color:color-mix(in srgb, #68765c 62%, var(--border));background:color-mix(in srgb, #68765c 12%, var(--bg));color:color-mix(in srgb, #68765c 34%, var(--text) 66%)}.budget-period-label-daily{border-color:color-mix(in srgb, #b5652d 62%, var(--border));background:color-mix(in srgb, #b5652d 12%, var(--bg));color:color-mix(in srgb, #b5652d 34%, var(--text) 66%)}.budget-period-label-hourly{border-color:color-mix(in srgb, #783f22 62%, var(--border));background:color-mix(in srgb, #783f22 12%, var(--bg));color:color-mix(in srgb, #783f22 34%, var(--text) 66%)}.budget-period-label-custom{border-style:dashed;border-color:color-mix(in srgb, #bfa584 68%, var(--border));background:color-mix(in srgb, #bfa584 16%, var(--bg));color:color-mix(in srgb, #8b6f4f 34%, var(--text) 66%)}[data-theme=light] .budget-period-label-monthly{color:#30302c}[data-theme=light] .budget-period-label-weekly{color:#68765c}[data-theme=light] .budget-period-label-daily{color:#b5652d}[data-theme=light] .budget-period-label-hourly{color:#783f22}[data-theme=light] .budget-period-label-custom{color:#8b6f4f}@media (prefers-color-scheme:light){:root:not([data-theme=dark]) .budget-period-label-monthly{color:#30302c}:root:not([data-theme=dark]) .budget-period-label-weekly{color:#68765c}:root:not([data-theme=dark]) .budget-period-label-daily{color:#b5652d}:root:not([data-theme=dark]) .budget-period-label-hourly{color:#783f22}:root:not([data-theme=dark]) .budget-period-label-custom{color:#8b6f4f}}.budget-row-actions{flex-flow:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.budget-action-btn{white-space:nowrap;justify-content:center;gap:0;width:28px;min-width:0;height:28px;padding:0;transition:width .18s,border-color .15s,background .15s,color .15s;overflow:hidden}.budget-action-btn:hover,.budget-action-btn:focus-visible{gap:6px;width:82px;padding:0 9px}.budget-action-label{opacity:0;max-width:0;transition:max-width .18s,opacity .12s;overflow:hidden}.budget-action-btn:hover .budget-action-label,.budget-action-btn:focus-visible .budget-action-label{opacity:1;max-width:58px}.budget-action-btn-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.budget-action-icon{flex:0 0 14px;width:14px;height:14px}.budget-editor{background:color-mix(in srgb, var(--bg-surface) 86%, var(--bg) 14%)}.budget-settings-actions{flex-wrap:wrap;gap:10px;display:flex}.budget-reset-dialog{max-width:460px}.form-action-icon{flex:0 0 16px;width:16px;height:16px}.settings-refresh-alert{margin-top:16px;margin-bottom:0}@media (width<=768px){.badge{display:none}.content{width:100%;margin:0 auto;padding:20px}.auth-dialog{padding:18px}.auth-dialog-actions{flex-direction:column-reverse}.auth-dialog-actions .btn{width:100%}.cards{grid-template-columns:repeat(2,1fr)}.page-header{flex-wrap:wrap;gap:12px}.page-header h2{width:100%}.page-header-controls{flex-wrap:wrap;justify-content:space-between;width:100%}.page-with-sticky-date{grid-template-columns:minmax(0,1fr)}.page-with-sticky-date>.date-range-page-header,.page-with-sticky-date>.sticky-date-range{grid-column:1}.page-with-sticky-date>.date-range-page-header{margin-bottom:12px}.page-with-sticky-date>.sticky-date-range{width:100%;margin-bottom:24px;top:10px}.sticky-date-range .date-picker-trigger{justify-content:space-between;width:100%}.usage-log-select{min-width:0}.budget-row{grid-template-columns:1fr}.budget-row-controls{flex-wrap:wrap}.budget-bar-line{grid-template-columns:1fr;gap:5px}.form-grid,.workflow-feature-toggles{grid-template-columns:1fr}.workflow-section-head{flex-direction:column;align-items:flex-start}.table-toolbar{flex-direction:column;align-items:stretch}.table-toolbar-actions{justify-content:stretch;margin-left:0}.table-toolbar-actions .btn{width:100%}.model-editor{padding:16px}.alias-actions-cell,.editor-header{flex-direction:column;align-items:flex-start}.alias-actions-cell .table-action-btn,.editor-header .table-action-btn{width:100%}.alias-actions-cell .table-icon-btn,.editor-header .table-icon-btn{width:36px}.model-list-actions{flex-flow:row;align-items:center}.model-list-actions .table-action-btn{width:auto}.model-list-actions .table-icon-btn{flex-basis:32px;width:32px}.model-editor .editor-header{flex-direction:row;align-items:flex-start}.model-editor .editor-header>:first-child{flex:1;min-width:0}.model-editor .editor-header .dialog-close-btn{flex:0 0 32px;align-self:flex-start;width:32px;min-width:32px}.settings-panel{padding:18px}.budget-settings-actions,.budget-settings-actions .btn{width:100%}}.workflow-conn{background:color-mix(in srgb, var(--accent) 44%, var(--border));flex:1 1 0;width:auto;min-width:13px;height:2px;position:relative}.workflow-conn:after{content:"";background:color-mix(in srgb, var(--accent) 44%, var(--border));clip-path:polygon(0 0,100% 50%,0 100%);width:7px;height:9px;position:absolute;top:50%;right:-1px;transform:translateY(-50%)}.workflow-node{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg-surface);text-align:center;flex-direction:column;flex-shrink:0;justify-content:center;align-items:center;gap:4px;min-width:72px;padding:8px 12px;display:flex}.auth-key-description{color:var(--text-muted);max-width:220px;font-size:13px}.auth-key-status-badge{border-radius:999px;padding:2px 10px;font-size:12px;font-weight:600;display:inline-block}.auth-key-status-active{background:color-mix(in srgb, var(--success) 12%, var(--bg));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));color:var(--success)}.auth-key-status-inactive{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border:1px solid color-mix(in srgb, var(--danger) 30%, var(--border));color:var(--danger)}.mcp-server-advanced{border:1px solid var(--border);border-radius:var(--radius);background:color-mix(in srgb, var(--bg-surface) 72%, var(--bg) 28%);overflow:hidden}.mcp-server-advanced>summary{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;list-style:none;display:flex}.mcp-server-advanced>summary::-webkit-details-marker{display:none}.mcp-server-advanced>summary:after{border-right:2px solid var(--text-muted);border-bottom:2px solid var(--text-muted);content:"";flex:none;width:7px;height:7px;transition:transform .15s;transform:rotate(45deg)}.mcp-server-advanced[open]>summary:after{transform:rotate(225deg)}.mcp-server-advanced-summary-copy{flex-direction:column;gap:2px;min-width:0;display:flex}.mcp-server-advanced-title{font-size:13px;font-weight:600}.mcp-server-advanced-fields{border-top:1px solid var(--border);flex-direction:column;gap:16px;padding:14px;display:flex}.copy-feedback-btn{align-items:center;gap:6px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.rate-limit-pressure-row{background-image:linear-gradient(to right, color-mix(in srgb, var(--success) 16%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-high{background-image:linear-gradient(to right, color-mix(in srgb, var(--warning) 20%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-full{background-image:linear-gradient(to right, color-mix(in srgb, var(--danger) 22%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.table-icon-btn.rate-limit-gauge-inherited{color:var(--accent-strong,var(--accent));background:linear-gradient(to right, color-mix(in srgb, var(--accent) 22%, var(--bg)) 50%, var(--bg) 50%);border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.auth-dialog-input-icon{width:16px;height:16px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.auth-dialog-input-shell:focus-within .auth-dialog-input-icon{color:var(--accent)}.auth-dialog-submit-icon{flex:0 0 16px;width:16px;height:16px}.nav-icon{flex:0 0 18px;width:18px;height:18px}.api-key-open-icon{flex:0 0 15px;width:15px;height:15px}.theme-icon{flex:0 0 14px;width:14px;height:14px}.theme-toggle-mobile .theme-icon{flex-basis:16px;width:16px;height:16px}@media (width<=768px){.sidebar-footer .api-key-open-icon{flex-basis:16px;width:16px;height:16px}}.failover-drafts-loading{min-height:96px}.models-loading-state{top:16px;left:var(--sidebar-width);z-index:110;pointer-events:none;--loading-state-min-height:0;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-surface);width:fit-content;box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);margin:0 auto;padding:10px 14px;position:fixed;right:0}@media (width<=768px){.models-loading-state{left:60px}}.sidebar.sidebar-collapsed~.content .models-loading-state{left:60px}.alias-create-icon{flex:0 0 16px;width:16px;height:16px}.pricing-override-remove-row{margin-bottom:1px}@media (width<=768px){.pricing-override-remove-row{margin-bottom:0}}.pricing-recalculate-dialog{max-width:480px}.settings-refresh-btn.is-refreshing .settings-refresh-icon{transform-origin:50%;animation:.8s linear infinite loading-spin}.cost-source-icon{width:14px;height:14px;color:var(--success);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.cache-savings-icon{width:14px;height:14px;color:var(--accent);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.theme-toggle.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;margin-bottom:10px;padding:2px;display:inline-flex}.theme-btn.svelte-1keql7b{width:28px;height:24px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:flex}.theme-btn.svelte-1keql7b:hover{color:var(--text)}.theme-btn.active.svelte-1keql7b{background:var(--accent);color:#fff}.theme-btn.svelte-1keql7b:focus-visible,.theme-toggle-mobile.svelte-1keql7b:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.theme-toggle-mobile.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);width:36px;height:36px;color:var(--text-muted);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:none}.theme-toggle-mobile.svelte-1keql7b:hover{color:var(--text)}.theme-toggle.is-compact.svelte-1keql7b{display:none}.theme-toggle-mobile.is-compact.svelte-1keql7b{margin:0 auto;display:flex}@media (width<=768px){.theme-toggle.svelte-1keql7b{display:none}.theme-toggle-mobile.svelte-1keql7b{margin:0 auto;display:flex}}.sidebar.svelte-1nwtzae{flex:0 0 var(--sidebar-width);width:var(--sidebar-width);background:var(--bg-surface);border-right:1px solid var(--border);-webkit-overflow-scrolling:touch;z-index:10;flex-direction:column;max-height:100vh;transition:flex-basis .2s,width .2s;display:flex;position:sticky;top:0;overflow:hidden auto}.sidebar.sidebar-resizing.svelte-1nwtzae{transition:none}.sidebar-header.svelte-1nwtzae{border-bottom:1px solid var(--border);align-items:center;gap:10px;padding:20px;display:flex}.sidebar-logo.svelte-1nwtzae{width:28px;height:28px;color:var(--accent);flex-shrink:0}.sidebar-logo.svelte-1nwtzae svg{width:100%;height:100%}.sidebar-header.svelte-1nwtzae h1{letter-spacing:-.3px;font-size:18px;font-weight:700}.sidebar-nav.svelte-1nwtzae{flex-direction:column;flex:1;gap:4px;padding:12px;display:flex}.nav-item.svelte-1nwtzae{border-radius:var(--radius);color:var(--text-muted);align-items:center;gap:10px;padding:8px 12px;font-size:14px;font-weight:500;text-decoration:none;transition:all .15s;display:flex}.nav-item.svelte-1nwtzae:hover{background:var(--bg-surface-hover);color:var(--text)}.nav-item.active.svelte-1nwtzae{background:var(--accent);color:#fff}.nav-label.svelte-1nwtzae{white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;overflow:hidden}.sidebar-footer.svelte-1nwtzae{border-top:1px solid var(--border);padding:16px}.api-key-section.svelte-1nwtzae{gap:8px;display:grid}.api-key-open-btn.svelte-1nwtzae{border:1px solid var(--accent);border-radius:var(--radius);width:100%;color:var(--accent);cursor:pointer;background:0 0;justify-content:center;align-items:center;gap:8px;padding:8px 10px;font-family:inherit;font-size:13px;font-weight:600;transition:background-color .15s,border-color .15s;display:inline-flex}.api-key-open-btn.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);border-color:color-mix(in srgb, var(--accent) 78%, var(--text));color:color-mix(in srgb, var(--accent) 78%, var(--text))}.api-key-open-btn.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.sidebar-toggle.svelte-1nwtzae{cursor:ew-resize;z-index:11;background:0 0;border:none;flex:0 0 6px;width:6px;height:100vh;padding:0;transition:background .15s;position:sticky;top:0}.sidebar-toggle.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 15%, transparent)}.sidebar-toggle.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}body.sidebar-resizing{cursor:ew-resize;-webkit-user-select:none;user-select:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae){justify-content:center;padding:16px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae) h1,.sidebar.sidebar-collapsed.svelte-1nwtzae .badge{display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae){padding:8px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:none}@media (width<=768px){.sidebar.svelte-1nwtzae{flex-basis:60px;width:60px}.sidebar-header.svelte-1nwtzae{justify-content:center;padding:16px}.sidebar-header.svelte-1nwtzae h1{display:none}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar-footer.svelte-1nwtzae{gap:8px;padding:8px;display:grid}.sidebar-footer.svelte-1nwtzae .api-key-section:where(.svelte-1nwtzae),.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:grid}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae){justify-self:center;width:36px;height:36px;min-height:36px;padding:0}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae) span,.sidebar-toggle.svelte-1nwtzae{display:none}}.dialog-close-btn.svelte-11l1bb5{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.dialog-close-btn.svelte-11l1bb5:hover{color:var(--text);background:var(--bg-surface-hover)}.dialog-close-btn.svelte-11l1bb5:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-backdrop.svelte-17e0w4c,.editor-modal-backdrop.svelte-17e0w4c{z-index:80;background:#0000007a;position:fixed;inset:0}.auth-dialog-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0}.editor-modal-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0;overflow-y:auto}.editor-modal-shell.svelte-17e0w4c>*{overscroll-behavior:contain;width:min(760px,100%);max-height:min(100vh - 40px,960px);margin:0;overflow:auto;box-shadow:0 24px 70px #00000061}@media (width<=768px){.auth-dialog-shell.svelte-17e0w4c,.editor-modal-shell.svelte-17e0w4c{align-items:end;padding:12px}.editor-modal-shell.svelte-17e0w4c>*{max-height:calc(100vh - 24px)}}.auth-dialog-input-shell.svelte-1dsu6u0{position:relative}.auth-dialog-input.svelte-1dsu6u0{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:11px 12px 11px 38px;font-family:inherit;font-size:14px}.auth-dialog-input.svelte-1dsu6u0:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}.flash-region.svelte-1i257xg{top:16px;left:var(--sidebar-width);z-index:120;pointer-events:none;flex-direction:column;align-items:center;gap:10px;display:flex;position:fixed;right:0}.sidebar.sidebar-collapsed~.flash-region.svelte-1i257xg{left:60px}@media (width<=768px){.flash-region.svelte-1i257xg{left:60px}}.flash-toast.svelte-1i257xg{border-radius:var(--radius);pointer-events:auto;align-items:flex-start;gap:10px;width:max-content;max-width:min(480px,100% - 32px);padding:12px 12px 12px 16px;font-size:14px;animation:.9s ease-out svelte-1i257xg-flash-toast-glow;display:flex;box-shadow:0 10px 30px #00000059}@keyframes svelte-1i257xg-flash-toast-glow{0%{box-shadow:0 0 0 4px color-mix(in srgb, currentColor 45%, transparent), 0 10px 30px #00000059}to{box-shadow:0 0 0 4px #0000,0 10px 30px #00000059}}@media (prefers-reduced-motion:reduce){.flash-toast.svelte-1i257xg{animation:none}}.flash-toast-success.svelte-1i257xg{background:color-mix(in srgb, var(--success) 14%, var(--bg-surface));color:var(--success);border:1px solid #34d39959}.flash-toast-error.svelte-1i257xg{background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--warning);border:1px solid #f59e0b66}.flash-toast-text.svelte-1i257xg{overflow-wrap:anywhere;flex:1;min-width:0}.flash-toast-dismiss.svelte-1i257xg{color:inherit;cursor:pointer;opacity:.7;background:0 0;border:0;flex-shrink:0;padding:0 2px;font-size:18px;line-height:1}.flash-toast-dismiss.svelte-1i257xg:hover{opacity:1}.demo-mode-banner.svelte-1s3mcn8{border:1px solid color-mix(in srgb, var(--warning) 55%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--text);box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;margin-bottom:24px;padding:12px 16px;display:grid}.demo-mode-banner-icon.svelte-1s3mcn8{width:20px;height:20px;color:var(--warning);flex:0 0 20px}.demo-mode-banner-copy.svelte-1s3mcn8{align-items:baseline;gap:8px;min-width:0;font-size:13px;display:flex}.demo-mode-banner.svelte-1s3mcn8 strong{color:var(--warning);letter-spacing:.06em;text-transform:uppercase;flex-shrink:0;font-size:12px}.demo-mode-banner-links.svelte-1s3mcn8{justify-content:flex-end;align-items:center;gap:6px;display:flex}.demo-mode-banner-links.svelte-1s3mcn8 a{border:1px solid color-mix(in srgb, var(--warning) 42%, var(--border));border-radius:var(--radius);min-height:28px;color:var(--text);white-space:nowrap;align-items:center;padding:4px 8px;font-size:12px;font-weight:600;line-height:1;text-decoration:none;display:inline-flex}.demo-mode-banner-links.svelte-1s3mcn8 a:hover{border-color:var(--warning);background:color-mix(in srgb, var(--warning) 16%, transparent);color:var(--text)}.demo-mode-banner-links.svelte-1s3mcn8 a:focus-visible{outline:2px solid color-mix(in srgb, var(--warning) 42%, transparent);outline-offset:2px}@media (width<=768px){.demo-mode-banner.svelte-1s3mcn8{grid-template-columns:auto minmax(0,1fr);align-items:flex-start}.demo-mode-banner-copy.svelte-1s3mcn8{gap:2px;display:grid}.demo-mode-banner-links.svelte-1s3mcn8{flex-wrap:wrap;grid-column:2;justify-content:flex-start}}.auth-banner.svelte-1c5yh36{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.dp-calendar.svelte-g7ga4u{flex-shrink:0;width:224px}.dp-cal-header.svelte-g7ga4u{justify-content:space-between;align-items:center;margin-bottom:8px;padding:0 4px;display:flex}.dp-cal-title.svelte-g7ga4u{font-size:13px;font-weight:600}.dp-nav-btn.svelte-g7ga4u{width:28px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:flex}.dp-nav-btn.svelte-g7ga4u:hover{background:var(--bg-surface-hover);color:var(--text)}.dp-nav-btn.svelte-g7ga4u:disabled{opacity:.3;cursor:default;pointer-events:none}.dp-nav-prev-mobile.svelte-g7ga4u{display:none}.dp-weekdays.svelte-g7ga4u{text-align:center;grid-template-columns:repeat(7,1fr);margin-bottom:4px;display:grid}.dp-weekdays.svelte-g7ga4u span:where(.svelte-g7ga4u){color:var(--text-muted);padding:4px 0;font-size:11px;font-weight:600}.dp-days.svelte-g7ga4u{grid-template-columns:repeat(7,1fr);gap:1px;display:grid}.dp-day.svelte-g7ga4u{width:32px;height:32px;color:var(--text);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:inherit;font-size:12px;transition:all .1s;display:flex}.dp-day.svelte-g7ga4u:hover:not(.disabled):not(.other-month){background:var(--bg-surface-hover)}.dp-day.other-month.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default}.dp-day.today.svelte-g7ga4u{color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);font-weight:700}.dp-day.in-range.svelte-g7ga4u{background:color-mix(in srgb, var(--accent) 15%, transparent);border-radius:0}.dp-day.range-start.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:6px 0 0 6px;font-weight:600}.dp-day.range-end.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:0 6px 6px 0;font-weight:600}.dp-day.range-start.range-end.svelte-g7ga4u{border-radius:6px}.dp-day.range-start.today.svelte-g7ga4u,.dp-day.range-end.today.svelte-g7ga4u{box-shadow:none}.dp-day.disabled.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default;pointer-events:none}@media (width<=768px){.dp-nav-prev-mobile.svelte-g7ga4u{display:flex}}.date-picker.svelte-ax7ma4{position:relative}.date-picker-trigger.svelte-ax7ma4{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;white-space:nowrap;align-items:center;gap:8px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s;display:inline-flex}.date-picker-trigger.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.date-picker-trigger.svelte-ax7ma4 svg:where(.svelte-ax7ma4){color:var(--text-muted);flex-shrink:0}.date-picker-chevron.svelte-ax7ma4{transition:transform .15s}.date-picker-chevron.open.svelte-ax7ma4{transform:rotate(180deg)}.date-picker-dropdown.svelte-ax7ma4{z-index:100;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:hidden;box-shadow:0 8px 24px #00000040}.date-picker-presets.svelte-ax7ma4{border-right:1px solid var(--border);flex-direction:column;gap:2px;min-width:140px;padding:8px;display:flex}.preset-btn.svelte-ax7ma4{color:var(--text);text-align:left;cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s}.preset-btn.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.preset-btn.active.svelte-ax7ma4{background:var(--accent);color:#fff}.date-picker-calendars.svelte-ax7ma4{flex-wrap:nowrap;gap:16px;padding:12px;display:flex}.dp-cursor-hint.svelte-ax7ma4{pointer-events:none;z-index:101;background:var(--bg-surface);color:var(--text);border:1px solid var(--accent);white-space:nowrap;border-radius:4px;align-items:center;gap:5px;padding:3px 8px;font-size:11px;font-weight:500;display:flex;position:fixed;transform:translate(12px,-50%)}.dp-cursor-hint.svelte-ax7ma4 svg:where(.svelte-ax7ma4){width:12px;height:12px;color:var(--accent);flex-shrink:0}@media (width<=768px){.date-picker-dropdown.svelte-ax7ma4{border-radius:var(--radius) var(--radius) 0 0;flex-direction:column;max-height:80vh;position:fixed;inset:auto 0 0;overflow-y:auto}.date-picker-presets.svelte-ax7ma4{-webkit-overflow-scrolling:touch;border-right:none;border-bottom:1px solid var(--border);flex-flow:row;min-width:0;overflow-x:auto}.date-picker-calendars.svelte-ax7ma4{justify-content:center}.date-picker-calendars.svelte-ax7ma4>.dp-calendar:first-child{display:none}}.segmented-control.svelte-92fh5i{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.segmented-btn.svelte-92fh5i{color:var(--text-muted);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;padding:5px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:flex}.segmented-btn.svelte-92fh5i:hover{color:var(--text)}.segmented-btn.active.svelte-92fh5i{background:var(--accent);color:#fff}@media (width<=768px){.segmented-btn.svelte-92fh5i{padding:4px 8px;font-size:11px}}.live-tokens.svelte-17qr2ta{margin-bottom:28px}.live-tokens-heading.svelte-17qr2ta{flex-direction:column;gap:2px;display:flex}.live-tokens-subtitle.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:6px;font-size:12px;display:inline-flex}.live-tokens-legend.svelte-17qr2ta{flex-wrap:wrap;gap:8px 18px;margin-bottom:16px;display:flex}.live-tokens-legend-item.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:7px;font-size:12px;display:inline-flex}.live-tokens-swatch.svelte-17qr2ta{border-radius:2px;flex-shrink:0;width:10px;height:10px}.live-tokens-legend-value.svelte-17qr2ta{color:var(--text);font-weight:600}.live-tokens-empty.svelte-17qr2ta .live-tokens-empty-text:where(.svelte-17qr2ta){color:var(--text-muted);font-size:13px}.provider-status-flag.svelte-6tr9cf{grid-column:span 2}.provider-status-overview-card.svelte-6tr9cf{grid-column:span 1}.provider-status-flag.is-healthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, var(--bg-surface))}.provider-status-flag.is-degraded.svelte-6tr9cf{border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-flag.is-unhealthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface))}.provider-status-value.svelte-6tr9cf{margin-bottom:8px}.provider-status-card-link.svelte-6tr9cf{color:var(--accent-strong,var(--accent));font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;margin:0;padding:0;font-size:13px;font-weight:600}.provider-status-card-link.svelte-6tr9cf:hover{color:var(--text);text-decoration:underline}.provider-status-card-link.svelte-6tr9cf:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:3px;border-radius:4px}.provider-status-card-note.svelte-6tr9cf{color:var(--text-muted);font-size:13px;display:block}@media (width>=720px){.card-wide.svelte-6tr9cf{grid-column:span 2}}.cache-token-value.svelte-6tr9cf{flex-wrap:wrap;align-items:center;gap:6px;line-height:1;display:flex}.cache-token-part.svelte-6tr9cf{align-items:center;display:inline-flex}.cache-token-operator.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;font-size:24px;font-weight:600;line-height:1}.cache-token-marker.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;text-transform:uppercase;margin-left:2px;font-size:14px;font-weight:700}.prompt-cache-gauge.svelte-6tr9cf{width:120px;height:60px;margin:8px auto 0;position:relative;overflow:hidden}.prompt-cache-gauge.svelte-6tr9cf canvas{display:block}.prompt-cache-gauge-value.svelte-6tr9cf{text-align:center;color:var(--text);font-size:18px;font-weight:700;line-height:1;position:absolute;bottom:4px;left:0;right:0}@media (width<=768px){.provider-status-flag.svelte-6tr9cf{grid-column:span 1}}.mcp-servers-flag.svelte-6tr9cf{grid-column:span 1}.cache-meter-header.svelte-1yzecxj{flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:16px;display:flex}.cache-meter-header.svelte-1yzecxj h3{font-size:16px;font-weight:600}.cache-meter-subtitle.svelte-1yzecxj{color:var(--text-muted);font-size:13px}.cache-meter-bar.svelte-1yzecxj{background:var(--bg-surface-hover);border-radius:6px;width:100%;height:28px;display:flex;overflow:hidden}.cache-meter-segment.svelte-1yzecxj{justify-content:center;align-items:center;min-width:3px;height:100%;transition:width .3s;display:flex;overflow:hidden}.cache-meter-segment-label.svelte-1yzecxj{color:#fff;white-space:nowrap;text-shadow:0 1px 2px #00000073;font-size:12px;font-weight:600;line-height:1}.cache-meter-segment.svelte-1yzecxj+.cache-meter-segment:where(.svelte-1yzecxj){box-shadow:-1px 0 0 var(--bg-surface)}.cache-meter-bar.is-empty.svelte-1yzecxj{background:var(--bg-surface-hover);justify-content:center;align-items:center;height:auto;min-height:28px;padding:6px 12px}.cache-meter-legend.svelte-1yzecxj{flex-wrap:wrap;gap:10px 24px;margin-top:16px;display:flex}.cache-meter-legend-item.svelte-1yzecxj{align-items:center;gap:8px;font-size:13px;display:flex}.cache-meter-swatch.svelte-1yzecxj{border-radius:3px;flex-shrink:0;width:12px;height:12px}.cache-meter-legend-label.svelte-1yzecxj{color:var(--text)}.cache-meter-legend-pct.svelte-1yzecxj{color:var(--text);font-weight:600}.cache-meter-legend-tokens.svelte-1yzecxj{color:var(--text-muted)}.cache-meter-empty.svelte-1yzecxj{color:var(--text-muted);text-align:center;font-size:13px}.spinner.svelte-b54l9o{width:var(--spinner-size);height:var(--spinner-size);border:2px solid var(--border,#80808059);border-top-color:var(--accent,currentColor);border-radius:50%;flex:none;animation:.7s linear infinite svelte-b54l9o-spinner-rotate;display:inline-block}@keyframes svelte-b54l9o-spinner-rotate{to{transform:rotate(360deg)}}.contribution-calendar-section.svelte-3hfxuq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-top:24px;padding:24px}.contribution-calendar-header.svelte-3hfxuq{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.contribution-calendar-header.svelte-3hfxuq h3{font-size:16px;font-weight:600}.contribution-calendar-grid-wrapper.svelte-3hfxuq{gap:8px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq{flex-direction:column;gap:2px;padding-top:22px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq span{height:13px;color:var(--text-muted);text-align:right;min-width:28px;font-size:10px;line-height:13px}.contribution-calendar-scroll.svelte-3hfxuq{--contribution-week-size:13px;--contribution-week-gap:2px;flex:1;min-width:0;overflow-x:auto}.contribution-calendar-months.svelte-3hfxuq{grid-auto-columns:var(--contribution-week-size);gap:var(--contribution-week-gap);grid-auto-flow:column;height:16px;margin-bottom:6px;display:grid}.contribution-calendar-month-label.svelte-3hfxuq{color:var(--text-muted);white-space:nowrap;font-size:10px}.contribution-calendar-grid.svelte-3hfxuq{gap:var(--contribution-week-gap);display:flex}.contribution-calendar-week.svelte-3hfxuq{flex-direction:column;gap:2px;display:flex}.contribution-calendar-cell.svelte-3hfxuq{width:var(--contribution-week-size);height:var(--contribution-week-size);background:var(--cal-level-0);border-radius:2px}.contribution-calendar-cell.level-1.svelte-3hfxuq{background:var(--cal-level-1)}.contribution-calendar-cell.level-2.svelte-3hfxuq{background:var(--cal-level-2)}.contribution-calendar-cell.level-3.svelte-3hfxuq{background:var(--cal-level-3)}.contribution-calendar-cell.level-4.svelte-3hfxuq{background:var(--cal-level-4)}.contribution-calendar-cell.level-5.svelte-3hfxuq{background:var(--cal-level-5)}.contribution-calendar-cell.level-6.svelte-3hfxuq{background:var(--cal-level-6)}.contribution-calendar-cell.level-7.svelte-3hfxuq{background:var(--cal-level-7)}.contribution-calendar-cell.level-8.svelte-3hfxuq{background:var(--cal-level-8)}.contribution-calendar-cell.level-9.svelte-3hfxuq{background:var(--cal-level-9)}.contribution-calendar-cell.level-10.svelte-3hfxuq{background:var(--cal-level-10)}.contribution-calendar-cell.empty.svelte-3hfxuq{background:0 0}.contribution-calendar-footer.svelte-3hfxuq{justify-content:space-between;align-items:center;gap:12px;margin-top:12px;display:flex}.contribution-calendar-meta.svelte-3hfxuq{flex-direction:column;gap:4px;display:flex}.contribution-calendar-summary.svelte-3hfxuq{color:var(--text-muted);font-size:12px}.contribution-calendar-legend.svelte-3hfxuq{color:var(--text-muted);align-items:center;gap:4px;font-size:11px;display:flex}.contribution-calendar-legend.svelte-3hfxuq .contribution-calendar-cell:where(.svelte-3hfxuq){cursor:default;width:11px;height:11px}.contribution-calendar-tooltip.svelte-3hfxuq{z-index:200;background:var(--bg-surface);color:var(--text);border:1px solid var(--border);white-space:nowrap;pointer-events:none;border-radius:4px;padding:4px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;position:fixed;transform:translate(-50%);box-shadow:0 4px 12px #0003}@media (width<=768px){.contribution-calendar-day-labels.svelte-3hfxuq{display:none}.contribution-calendar-section.svelte-3hfxuq{padding:16px}.contribution-calendar-footer.svelte-3hfxuq{flex-direction:column;align-items:flex-start}}.inline-help-toggle.is-open.svelte-y40or3{color:var(--text);background:0 0}.inline-help-toggle.is-open.svelte-y40or3 .inline-help-toggle-icon{transform:rotate(540deg)}.audit-stats-section.svelte-14e9yan{margin-top:24px}.audit-stats-header.svelte-14e9yan{align-items:flex-start}.audit-stats-kpis.svelte-14e9yan{flex-wrap:wrap;align-items:center;gap:14px;display:flex}.audit-stats-kpi.svelte-14e9yan{color:var(--text-muted);white-space:nowrap;align-items:center;gap:6px;font-size:12px;display:inline-flex}.audit-stats-kpi-value.svelte-14e9yan{color:var(--text);font-size:13px}.audit-stats-kpi-dot.svelte-14e9yan{border-radius:2px;flex-shrink:0;width:8px;height:8px}.audit-stats-dot-2xx.svelte-14e9yan{background:var(--success)}.audit-stats-dot-4xx.svelte-14e9yan{background:var(--warning)}.audit-stats-dot-5xx.svelte-14e9yan{background:var(--danger)}.provider-status-details.svelte-6y9wjv{opacity:0;grid-template-rows:0fr;transition:grid-template-rows .28s,opacity .22s;display:grid}.provider-status-details.is-expanded.svelte-6y9wjv{opacity:1;grid-template-rows:1fr}.provider-status-details.is-collapsed.svelte-6y9wjv{pointer-events:none}.provider-status-details-inner.svelte-6y9wjv{flex-direction:column;gap:14px;min-height:0;display:flex;overflow:hidden}.provider-status-reason.svelte-6y9wjv{color:var(--text-muted);font-size:13px}.provider-status-error.svelte-6y9wjv{color:var(--danger);overflow-wrap:break-word;font-size:12px}.provider-status-config-label.svelte-6y9wjv{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-config.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;padding-top:12px;display:flex}.provider-status-config-row.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-config-value.svelte-6y9wjv{color:var(--text);overflow-wrap:break-word;font-size:13px;display:block}.provider-status-health.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;margin-bottom:12px;padding-top:12px;display:flex}.provider-status-health-state.svelte-6y9wjv{border:1px solid var(--border);border-radius:999px;align-items:center;padding:1px 8px;font-size:12px;font-weight:600;display:inline-flex}.provider-status-health-state.is-healthy.svelte-6y9wjv{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-health-state.is-degraded.svelte-6y9wjv{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-health-state.is-unhealthy.svelte-6y9wjv{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-health-models.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-health-model.svelte-6y9wjv{color:var(--text);justify-content:space-between;gap:8px;font-size:13px;display:flex}.provider-status-health-model.is-flagged.svelte-6y9wjv{color:var(--danger)}.provider-status-health-model-name.svelte-6y9wjv{overflow-wrap:anywhere}.provider-status-health-model-stats.svelte-6y9wjv{white-space:nowrap;color:var(--text-muted)}.provider-status-health-model.is-flagged.svelte-6y9wjv .provider-status-health-model-stats:where(.svelte-6y9wjv){color:var(--danger);font-weight:700}.provider-status-card.svelte-nopjmh{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:14px;padding:18px;display:flex}.provider-status-card-toggle.svelte-nopjmh{border:0;border-top:1px solid var(--border);border-radius:0 0 var(--radius) var(--radius);color:var(--text-muted);cursor:pointer;background:0 0;justify-content:center;align-items:center;margin:auto -18px -18px;padding:7px 0;transition:background .15s,color .15s;display:flex}.provider-status-card-toggle.svelte-nopjmh:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);color:var(--text)}.provider-status-card-toggle.svelte-nopjmh:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:-2px}.provider-status-card-toggle.svelte-nopjmh .provider-status-card-toggle-icon{width:16px;height:16px;transition:transform .28s;display:block}.provider-status-card-toggle.is-expanded.svelte-nopjmh .provider-status-card-toggle-icon{transform:rotate(180deg)}.provider-status-card-head.svelte-nopjmh{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.provider-status-name.svelte-nopjmh{letter-spacing:-.02em;flex-wrap:wrap;align-items:baseline;gap:6px;font-size:16px;font-weight:700;display:flex}.provider-doc-help.svelte-nopjmh{align-self:center;text-decoration:none}.provider-status-name-type.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-pill.svelte-nopjmh{border:1px solid var(--border);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;min-height:28px;padding:0 10px;font-size:12px;font-weight:700;display:inline-flex}.provider-status-pill.is-healthy.svelte-nopjmh{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-pill.is-degraded.svelte-nopjmh{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-pill.is-unhealthy.svelte-nopjmh{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-meta.svelte-nopjmh{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.provider-status-meta-item.svelte-nopjmh{background:var(--bg);border:1px solid var(--border);border-radius:6px;flex-direction:column;gap:4px;padding:10px 12px;display:flex}.provider-status-meta-label.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-meta-value.svelte-nopjmh{color:var(--text);font-size:14px}@media (width<=768px){.provider-status-meta.svelte-nopjmh{grid-template-columns:1fr}}.provider-status-section-loading.svelte-1kx3uw4{justify-content:center;padding:24px 0;display:flex}.provider-status-section-header.svelte-1kx3uw4{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px;display:flex}.provider-status-toggle.svelte-1kx3uw4{background:var(--bg-surface);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:10px;padding:8px 12px;font-family:inherit;font-size:12px;font-weight:600;transition:background-color .18s,border-color .18s,color .18s;display:inline-flex}.provider-status-toggle.svelte-1kx3uw4:hover{background:var(--bg-surface-hover)}.provider-status-toggle.svelte-1kx3uw4:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.provider-status-toggle-copy.svelte-1kx3uw4{white-space:nowrap}.provider-status-toggle-track.svelte-1kx3uw4{background:color-mix(in srgb, var(--text-muted) 35%, var(--border));border-radius:999px;flex-shrink:0;width:34px;height:20px;transition:background-color .2s;position:relative}.provider-status-toggle-track.is-active.svelte-1kx3uw4{background:color-mix(in srgb, var(--accent) 82%, var(--bg-surface))}.provider-status-toggle-thumb.svelte-1kx3uw4{background:#fff;border-radius:50%;width:16px;height:16px;transition:transform .2s;position:absolute;top:2px;left:2px;box-shadow:0 1px 3px #0000003d}.provider-status-toggle-track.is-active.svelte-1kx3uw4 .provider-status-toggle-thumb:where(.svelte-1kx3uw4){transform:translate(14px)}.provider-status-grid.svelte-1kx3uw4{grid-template-columns:repeat(auto-fit,minmax(280px,1fr));align-items:start;gap:16px;display:grid}@media (width<=768px){.provider-status-section-header.svelte-1kx3uw4{flex-direction:column;align-items:flex-start}.provider-status-toggle.svelte-1kx3uw4{justify-content:space-between;width:100%}}.filter-input-wrap.svelte-30xz1k{flex:1;width:100%;min-width:min(400px,100%);display:flex;position:relative}.filter-input.svelte-30xz1k{flex:1;width:100%;min-width:0;padding-left:34px}.filter-input-wrap.svelte-30xz1k .filter-input-icon{width:14px;height:14px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.usage-page-filters.svelte-1oi6ywk{flex-wrap:wrap;gap:10px;margin-bottom:20px;display:flex}.usage-page-filters.svelte-1oi6ywk .usage-log-select{flex:0 auto}.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:220px;min-width:180px;max-width:360px}@media (width<=768px){.usage-page-filters.svelte-1oi6ywk .usage-log-select,.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:100%;max-width:none}}.pro-saved-value.svelte-1qiwzdu{flex-wrap:wrap;align-items:baseline;gap:8px;display:flex}.pro-saved-delta.svelte-1qiwzdu{color:var(--success);letter-spacing:0;font-size:13px;font-weight:600}.usage-breakdown-loading.svelte-1kee4g8{justify-content:center;align-items:center;min-height:120px;display:flex}.chart-view-toggle.svelte-1kee4g8{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.chart-view-btn.svelte-1kee4g8{width:30px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:inline-flex}.chart-view-btn.svelte-1kee4g8:hover{color:var(--text)}.chart-view-btn.active.svelte-1kee4g8{background:var(--accent);color:#fff}.chart-view-btn.svelte-1kee4g8 svg{fill:none;stroke:currentColor;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:16px;height:16px}.usage-chart-table-wrapper.svelte-1kee4g8{-webkit-overflow-scrolling:touch;margin-top:0;overflow-x:auto}.usage-chart-data-table.svelte-1kee4g8{min-width:max-content}.usage-chart-data-table.svelte-1kee4g8 th,.usage-chart-data-table.svelte-1kee4g8 td{white-space:nowrap}.pagination-info.svelte-1imew3q{color:var(--text-muted);font-size:13px}.pagination-buttons.svelte-1imew3q{gap:8px;display:flex}.usage-log-loading.svelte-hg4ill{justify-content:center;align-items:center;min-height:120px;display:flex}.usage-log-section.svelte-hg4ill{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.usage-log-section.svelte-hg4ill h3{margin-bottom:16px;font-size:16px;font-weight:600}.usage-log-section.svelte-hg4ill .table-wrapper{overflow-x:auto}.usage-log-toolbar.svelte-hg4ill{gap:12px;margin-bottom:16px;display:grid}.usage-filter-row.svelte-hg4ill{grid-template-columns:repeat(12,minmax(0,1fr));align-items:center;gap:12px;display:grid}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1/-1}.usage-filter-row-options.svelte-hg4ill{grid-template-columns:1fr}.usage-log-checkbox.svelte-hg4ill{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.usage-log-checkbox.svelte-hg4ill input{cursor:pointer;width:16px;height:16px}.usage-ts.svelte-hg4ill{white-space:nowrap;font-size:12px}.usage-log-row-cached.svelte-hg4ill td{opacity:.75;font-style:italic}.usage-log-row-cached.svelte-hg4ill .usage-log-cache-cell:where(.svelte-hg4ill){font-weight:700}.caveat-icon.svelte-hg4ill{color:var(--warning);cursor:help;margin-left:4px;font-size:14px}@media (width<=768px){.usage-log-toolbar.svelte-hg4ill{gap:10px}.usage-filter-row.svelte-hg4ill{grid-template-columns:1fr}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1}.usage-log-table.svelte-hg4ill{display:block;overflow-x:auto}}.usage-sticky-controls.svelte-spwie6{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}.usage-charts-grid.svelte-spwie6{flex-wrap:wrap;gap:24px;margin-bottom:24px;display:flex}.usage-charts-grid.svelte-spwie6 .model-chart-section{flex:calc(50% - 24px);min-width:420px;margin-bottom:0}@media (width<=520px){.usage-charts-grid.svelte-spwie6 .model-chart-section{min-width:0}}.loading-state.svelte-hzxv1d{min-height:var(--loading-state-min-height,64px);color:var(--text-muted);justify-content:center;align-items:center;gap:10px;font-size:14px;display:flex}.budget-bar-text-row-on-fill.svelte-1jm56wo{color:#fff;clip-path:inset(0 calc(100% - var(--budget-progress,0%)) 0 0)}.budget-bar-text-start.svelte-1jm56wo{left:8px;transform:translateY(-50%)}.budget-bar-track-period-custom.svelte-1jm56wo .budget-bar-text-row-on-fill:where(.svelte-1jm56wo){color:#3f332a}.budget-override-dialog.svelte-13ryo7h{max-width:460px}.budget-sort-control.svelte-1752fqe{align-items:center;gap:8px}.budget-sort-control.svelte-1752fqe label{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.budget-sort-select.svelte-1752fqe{background-color:var(--bg-surface);min-width:132px}.budget-sort-select.svelte-1752fqe:hover{background-color:var(--bg-surface-hover)}.model-name-cell.svelte-1iynym{flex-direction:column;gap:8px;display:flex}.model-name-primary.svelte-1iynym{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.model-name-secondary.svelte-1iynym{color:var(--text-muted);font-size:12px}.model-redirect-remove-btn.svelte-1iynym{appearance:none;color:var(--danger);cursor:pointer;background:0 0;border:0;margin-left:4px;padding:0;font-size:11px}.model-redirect-remove-btn.svelte-1iynym:hover:not(:disabled){text-decoration:underline}.model-redirect-remove-btn.svelte-1iynym:disabled{opacity:.45;cursor:default}.model-kind-icon.svelte-1iynym{border:1px solid color-mix(in srgb, var(--accent) 55%, var(--border));background:var(--bg);width:24px;height:24px;color:var(--accent);border-radius:999px;flex:0 0 24px;justify-content:center;align-items:center;display:inline-flex}.model-kind-icon-svg.svelte-1iynym{width:14px;height:14px}.model-row-actions.svelte-1iynym{text-align:right;width:170px}@media (width<=768px){.model-name-primary.svelte-1iynym{flex-direction:column;align-items:flex-start}}.provider-group-row.svelte-1911hy6 td{background:color-mix(in srgb, var(--accent) 6%, var(--bg));padding-top:12px;padding-bottom:12px}.provider-group-row.svelte-1911hy6:hover td{background:color-mix(in srgb, var(--accent) 8%, var(--bg))}.provider-group-header.svelte-1911hy6{justify-content:space-between;align-items:center;gap:16px;display:flex}.provider-group-meta.svelte-1911hy6{flex-direction:column;gap:4px;min-width:0;display:flex}.provider-group-title.svelte-1911hy6{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.provider-group-type.svelte-1911hy6,.provider-group-count.svelte-1911hy6,.provider-group-summary.svelte-1911hy6{color:var(--text-muted);font-size:12px}@media (width<=768px){.provider-group-header.svelte-1911hy6{flex-direction:column;align-items:flex-start}}.vm-session-affinity-checkbox.svelte-d1j6xw{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.vm-session-affinity-checkbox.svelte-d1j6xw input:where(.svelte-d1j6xw){accent-color:var(--accent);cursor:pointer}.pricing-override-rows.svelte-u8snes{gap:12px;display:grid}.pricing-override-row.svelte-u8snes{grid-template-columns:minmax(220px,1fr) minmax(130px,180px) 32px;align-items:end;gap:12px;display:grid}.pricing-override-row-actions.svelte-u8snes{justify-content:flex-start;display:flex}.pricing-override-tier-note.svelte-u8snes{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:6px;padding:10px 12px;font-size:13px}.pricing-preview.svelte-u8snes{border:1px solid var(--border);border-radius:6px;overflow:hidden}.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:minmax(150px,1fr) minmax(90px,auto) minmax(130px,.8fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.pricing-preview-header.svelte-u8snes{background:var(--bg);color:var(--text-muted);text-transform:uppercase;font-size:12px;font-weight:600}.pricing-preview-row.svelte-u8snes{border-top:1px solid var(--border);font-size:13px}.pricing-preview-row-empty.svelte-u8snes{color:var(--text-muted);grid-template-columns:1fr}@media (width<=768px){.pricing-override-row.svelte-u8snes,.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:1fr}}.failover-drafts-editor.svelte-1n87bip{flex-direction:column;gap:16px;display:flex}.failover-draft-header-actions.svelte-1n87bip{flex:none;align-items:center;gap:10px;display:flex}.failover-draft-counter.svelte-1n87bip{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.failover-draft-toolbar.svelte-1n87bip{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.failover-draft-toolbar.svelte-1n87bip .filter-input-wrap,.failover-draft-toolbar.svelte-1n87bip .filter-input{min-width:0}.failover-draft-toggle-all.svelte-1n87bip{flex:none}.failover-draft-list.svelte-1n87bip{flex-direction:column;gap:8px;max-height:min(52vh,430px);padding-right:4px;display:flex;overflow-y:auto}.failover-draft-row.svelte-1n87bip{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);cursor:pointer;grid-template-columns:18px minmax(0,1fr);align-items:start;gap:10px;padding:10px;display:grid}.failover-draft-row.svelte-1n87bip:hover{border-color:color-mix(in srgb, var(--accent) 42%, var(--border));background:var(--bg-surface-hover)}.failover-draft-row.svelte-1n87bip input{width:16px;height:16px;margin-top:2px}.failover-draft-copy.svelte-1n87bip{gap:4px;min-width:0;display:grid}.failover-draft-source.svelte-1n87bip,.failover-draft-targets.svelte-1n87bip{overflow-wrap:anywhere}.failover-draft-targets.svelte-1n87bip{color:var(--text-muted);font-size:12px}.failover-drafts-empty.svelte-1n87bip{align-items:center;min-height:96px;display:flex}.failover-draft-actions.svelte-1n87bip{margin-top:0}.category-tabs.svelte-scpjps{-webkit-overflow-scrolling:touch;align-items:center;gap:4px;margin-bottom:16px;padding-bottom:2px;display:flex;overflow-x:auto}.category-tab.svelte-scpjps{background:var(--bg-surface);border:1px solid var(--border);color:var(--text-muted);cursor:pointer;white-space:nowrap;border-radius:6px;flex-shrink:0;align-items:center;gap:6px;padding:6px 14px;font-family:inherit;font-size:13px;font-weight:500;transition:all .15s;display:inline-flex}.category-tab.svelte-scpjps:hover{color:var(--text);background:var(--bg-surface-hover)}.category-tab.active.svelte-scpjps{background:var(--accent);color:#fff;border-color:var(--accent)}.category-tab.svelte-scpjps .tab-count:where(.svelte-scpjps){background:#ffffff26;border-radius:9px;justify-content:center;align-items:center;min-width:20px;height:18px;padding:0 5px;font-size:11px;font-weight:600;line-height:1;display:inline-flex}.category-tab.svelte-scpjps:not(.active) .tab-count:where(.svelte-scpjps){background:var(--bg)}@media (width<=768px){.category-tabs.svelte-scpjps{gap:4px}.category-tab.svelte-scpjps{padding:5px 10px;font-size:12px}}.workflow-pipeline-meta.svelte-1viff7o{border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 86%, transparent);min-width:0;max-width:calc(100% - 28px);color:var(--text-muted);white-space:nowrap;appearance:none;cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:0;padding:2px 10px;font-size:12px;font-weight:500;line-height:1.2;transition:background-color .15s,border-color .15s,color .15s,box-shadow .15s;display:inline-flex;position:absolute;top:12px;right:14px;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover,.workflow-pipeline-meta.svelte-1viff7o:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface));color:color-mix(in srgb, var(--accent) 74%, var(--text))}.workflow-pipeline-meta.svelte-1viff7o:focus-visible{box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);outline:none}.workflow-pipeline-meta-label.svelte-1viff7o{flex:none;font-weight:700}.workflow-pipeline-meta-placeholder.svelte-1viff7o{opacity:1;flex:none;max-width:3ch;margin-left:4px;transition:max-width .18s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta-value.svelte-1viff7o{opacity:0;text-overflow:clip;flex:0 auto;max-width:0;margin-left:0;transition:max-width .22s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o){opacity:0;max-width:0;margin-left:0}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o){opacity:1;max-width:42ch;margin-left:4px}.workflow-pipeline-meta-icon.svelte-1viff7o{opacity:0;flex:none;justify-content:center;align-items:center;width:0;height:14px;margin-left:0;line-height:0;transition:width .18s,margin-left .18s,opacity .15s,transform .18s;display:inline-flex;overflow:hidden;transform:translate(4px)translateY(1px)scale(.84)}.workflow-pipeline-meta-icon.svelte-1viff7o svg{width:14px;height:14px}.workflow-pipeline-meta-copied.svelte-1viff7o,.workflow-pipeline-meta-copied.svelte-1viff7o:hover,.workflow-pipeline-meta-copied.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-icon:where(.svelte-1viff7o){opacity:1;width:14px;margin-left:6px;transform:translateY(1px)}.workflow-pipeline-meta-error.svelte-1viff7o,.workflow-pipeline-meta-error.svelte-1viff7o:hover,.workflow-pipeline-meta-error.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 34%, var(--border));color:var(--danger)}.workflow-pipeline.svelte-nbptrg{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg);flex-direction:column;gap:0;margin-bottom:12px;padding:18px 20px 20px;display:flex;position:relative}.workflow-pipeline-has-meta.svelte-nbptrg{padding-top:42px}.workflow-pipeline-row.svelte-nbptrg{align-items:center;width:100%;min-width:0;display:flex;overflow-x:auto}.workflow-node-icon.svelte-nbptrg{border-radius:var(--radius);background:var(--bg);width:28px;height:28px;color:var(--text-muted);justify-content:center;align-items:center;display:flex}.workflow-node-icon.svelte-nbptrg svg{stroke:currentColor;fill:none;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:15px;height:15px}.workflow-node-label.svelte-nbptrg{letter-spacing:.03em;color:var(--text);white-space:nowrap;font-size:11px;font-weight:700;line-height:1.2}.workflow-node-sub.svelte-nbptrg{color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;max-width:120px;font-size:10px;font-weight:500;line-height:1.2;font-family:var(--font-mono,ui-monospace, monospace);overflow:hidden}.workflow-node-badge.svelte-nbptrg{border-radius:var(--radius);letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;border:1px solid var(--border);background:var(--bg);color:var(--text-muted);align-items:center;padding:2px 7px;font-size:9px;font-weight:800;line-height:1.5;display:inline-flex}.workflow-node-endpoint.svelte-nbptrg{border-radius:var(--radius);border-color:var(--border);background:var(--bg-surface);flex-direction:row;gap:7px;min-width:auto;padding:10px 14px}.workflow-node-icon-endpoint.svelte-nbptrg{border-radius:var(--radius);width:auto;height:auto;color:var(--text-muted);background:0 0;justify-content:flex-start;padding:0}.workflow-node-icon-endpoint.svelte-nbptrg svg{width:14px;height:14px}.workflow-node-endpoint.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted);font-size:11px;font-weight:600}.workflow-node-feature.svelte-nbptrg{border-color:color-mix(in srgb, var(--accent) 46%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface))}.workflow-node-feature.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--accent) 16%, var(--bg));color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--accent) 70%, var(--text-muted))}.workflow-node-ai.svelte-nbptrg{border-radius:var(--radius);gap:6px;min-width:96px;padding:12px 16px}.workflow-async-section.svelte-nbptrg{justify-content:flex-end;align-items:center;gap:0;width:100%;min-width:0;margin-top:10px;display:flex}.workflow-async-turn.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 60px;height:2px;position:relative}.workflow-async-turn.svelte-nbptrg:before{content:"";background:color-mix(in srgb, var(--text-muted) 40%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);width:7px;height:9px;position:absolute;top:50%;left:-7px;transform:translateY(-50%)}.workflow-async-turn.svelte-nbptrg:after{content:"";border-right:2px dashed color-mix(in srgb, var(--text-muted) 40%, var(--border));height:16px;position:absolute;bottom:1px;right:0}.workflow-async-row.svelte-nbptrg{align-items:center;min-width:0;margin-right:7px;display:flex}.workflow-conn-async.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 24px;width:24px}.workflow-conn-async.svelte-nbptrg:after{background:color-mix(in srgb, var(--text-muted) 45%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);left:-1px;right:auto}.workflow-node-async.svelte-nbptrg{border-radius:var(--radius);border-style:dashed;flex-direction:row;gap:7px;min-width:auto;padding:7px 12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){border-radius:var(--radius);width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg) svg{width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){font-size:10px;font-weight:700}.workflow-async-label.svelte-nbptrg{letter-spacing:.1em;text-transform:uppercase;color:var(--text-muted);opacity:.55;white-space:nowrap;flex-shrink:0;align-items:center;margin-left:8px;font-size:9px;font-weight:800;display:inline-flex}.workflow-node-success.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 18%, var(--bg));color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 85%, var(--text))}.workflow-node-success.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 74%, var(--text-muted))}.workflow-node-success.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 14%, var(--bg));border-color:color-mix(in srgb, var(--success) 38%, var(--border));color:var(--success)}.workflow-node-current.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 16%, var(--bg));color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 85%, var(--text))}.workflow-node-current.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 72%, var(--text-muted))}.workflow-node-current.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 13%, var(--bg));border-color:color-mix(in srgb, var(--info) 36%, var(--border));color:var(--info)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 85%, var(--text))}.workflow-node-warning.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 72%, var(--text-muted))}.workflow-node-warning.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 38%, var(--border));color:var(--warning)}.workflow-node-error.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--danger) 14%, var(--bg));color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 85%, var(--text))}.workflow-node-error.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 72%, var(--text-muted))}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 12%, var(--bg));color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg),.workflow-node-neutral.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--text-muted) 84%, var(--border))}.workflow-node-neutral.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 10%, var(--bg));border-color:color-mix(in srgb, var(--text-muted) 28%, var(--border));color:var(--text-muted)}.workflow-conn-hit.svelte-nbptrg,.workflow-conn-hit.svelte-nbptrg:after{background:color-mix(in srgb, var(--success) 58%, var(--border))}.workflow-conn-dim.svelte-nbptrg,.workflow-conn-dim.svelte-nbptrg:after{background:color-mix(in srgb, var(--border) 75%, transparent)}.workflow-node-success.svelte-nbptrg{border-color:color-mix(in srgb, var(--success) 52%, var(--border));background:color-mix(in srgb, var(--success) 9%, var(--bg-surface))}.workflow-node-current.svelte-nbptrg{border-color:color-mix(in srgb, var(--info) 56%, var(--border));background:color-mix(in srgb, var(--info) 10%, var(--bg-surface))}.workflow-node-warning.svelte-nbptrg{border-color:color-mix(in srgb, var(--warning) 52%, var(--border));background:color-mix(in srgb, var(--warning) 9%, var(--bg-surface))}.workflow-node-error.svelte-nbptrg{border-color:color-mix(in srgb, var(--danger) 52%, var(--border));background:color-mix(in srgb, var(--danger) 9%, var(--bg-surface))}.workflow-node-neutral.svelte-nbptrg{border-color:color-mix(in srgb, var(--text-muted) 40%, var(--border));background:color-mix(in srgb, var(--text-muted) 8%, var(--bg-surface))}.workflow-node-skipped.svelte-nbptrg{opacity:.28;position:relative}.workflow-card.svelte-1fo9fvq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:16px;padding:20px;display:flex}.workflow-card-head.svelte-1fo9fvq{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-card-footer.svelte-1fo9fvq{flex-direction:column;align-items:stretch;gap:10px;display:flex}.workflow-card-head.svelte-1fo9fvq h3{font-size:18px;font-weight:700}.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq{flex-wrap:wrap;justify-content:flex-end;gap:8px;display:flex}.workflow-card-meta-footer.svelte-1fo9fvq{justify-content:flex-start}.workflow-card-footer.svelte-1fo9fvq .alias-actions-cell{align-self:flex-end}.workflow-card-description.svelte-1fo9fvq{color:var(--text-muted);font-size:14px}.workflow-guardrails.svelte-1fo9fvq{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list.svelte-1fo9fvq{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-item.svelte-1fo9fvq{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;display:flex}@media (width<=768px){.workflow-card-head.svelte-1fo9fvq,.workflow-card-footer.svelte-1fo9fvq,.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq,.workflow-guardrail-item.svelte-1fo9fvq{flex-direction:column;align-items:flex-start}}.model-editor.workflow-editor{width:min(1080px,100%);margin-bottom:0}.alert-inline-actions.svelte-1bcpzh1{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.workflow-guardrail-editor.svelte-1bcpzh1{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list-editor.svelte-1bcpzh1{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-row.svelte-1bcpzh1{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:stretch;align-items:center;gap:12px;padding:10px 12px;display:flex}.workflow-guardrail-field.svelte-1bcpzh1{flex:auto;min-width:0}.workflow-guardrail-step-field.svelte-1bcpzh1{flex:0 0 120px}.workflow-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-step-input.svelte-1bcpzh1{max-width:120px}@media (width<=768px){.workflow-guardrail-row.svelte-1bcpzh1{flex-direction:column;align-items:flex-start}.workflow-step-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-guardrail-field.svelte-1bcpzh1,.workflow-guardrail-step-field.svelte-1bcpzh1{flex-basis:auto;width:100%}}.workflow-list-loading.svelte-ie2kfk{justify-content:center;align-items:center;gap:8px;display:flex}.workflows-list.svelte-ie2kfk{min-width:0}.workflow-card-grid.svelte-ie2kfk{grid-template-columns:1fr;gap:16px;display:grid}.workflow-page-note.svelte-l8kr26{color:var(--text-muted);margin-top:6px;font-size:14px}.audit-log-toolbar.svelte-1pwbpcm{flex-direction:column;gap:10px;margin-bottom:14px;display:flex}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:repeat(12,minmax(0,1fr));gap:10px;display:grid}.audit-filter-select.svelte-1pwbpcm{grid-column:span 2;min-width:0}.audit-filter-row-search.svelte-1pwbpcm .filter-input-wrap{grid-column:1/-1;max-width:none}.audit-filter-row-controls.svelte-1pwbpcm .audit-filter-select:where(.svelte-1pwbpcm){grid-column:span 2}.audit-filter-row-controls.svelte-1pwbpcm .btn{grid-column:11/-1;justify-self:end;min-width:108px}.audit-clear-btn.svelte-1pwbpcm{justify-content:center;align-items:center;gap:8px;font-weight:600;display:inline-flex}.audit-clear-btn.svelte-1pwbpcm .table-icon-svg{width:12px;height:12px}@media (width<=768px){.audit-log-toolbar.svelte-1pwbpcm{gap:8px}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:1fr}.audit-filter-row.svelte-1pwbpcm .filter-input-wrap,.audit-filter-row.svelte-1pwbpcm .filter-input,.audit-filter-select.svelte-1pwbpcm,.audit-filter-row.svelte-1pwbpcm .btn{grid-column:auto}}.audit-live-status.svelte-tve6yv{color:var(--text-muted);align-items:center;gap:10px;margin-left:16px;padding-left:6px;font-size:12px;display:inline-flex}.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:1.8s ease-out infinite svelte-tve6yv-audit-live-dot-throb}@keyframes svelte-tve6yv-audit-live-dot-throb{0%{transform:scale(1)}35%{transform:scale(1.35)}70%{transform:scale(1)}to{transform:scale(1)}}@media (prefers-reduced-motion:reduce){.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:none}}.audit-live-status-text.is-live.svelte-tve6yv{color:var(--success);font-weight:600}.audit-entry-metadata.svelte-hyopt0{border-top:1px solid var(--border);align-items:center;gap:10px;margin-top:12px;padding-top:12px;display:flex}.audit-entry-metadata-label.svelte-hyopt0{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;flex:none;font-size:12px;font-weight:700}.audit-entry-context.svelte-hyopt0{flex-wrap:wrap;flex:auto;gap:8px;display:flex}.audit-alias-badge.svelte-hyopt0{background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 28%, var(--border));color:var(--accent-strong,var(--accent))}@media (width<=768px){.audit-entry-metadata.svelte-hyopt0{flex-direction:column;align-items:flex-start;gap:8px}}.audit-attempt-track.svelte-1eu22xn{cursor:pointer;align-items:center;gap:6px;display:inline-flex}.audit-attempt-track-pips.svelte-1eu22xn{align-items:center;gap:3px;display:inline-flex}.audit-attempt-pip.svelte-1eu22xn{background:var(--text-muted);border-radius:2px;width:8px;height:8px}.audit-attempt-pip.audit-attempt-success.svelte-1eu22xn{background:var(--success)}.audit-attempt-pip.audit-attempt-error.svelte-1eu22xn{background:var(--danger)}.audit-attempt-track-count.svelte-1eu22xn{color:var(--text-muted);font-size:11px}.audit-entry-summary.svelte-17mysgz{cursor:pointer;justify-content:space-between;align-items:center;gap:12px;padding:5px 14px;list-style:none;display:flex;position:relative}.audit-entry-summary.svelte-17mysgz::-webkit-details-marker{display:none}.audit-entry-summary-live-in-progress.svelte-17mysgz{background:color-mix(in srgb, var(--info) 7%, var(--bg))}.audit-entry-summary-has-interactions.svelte-17mysgz{padding-right:44px}.audit-entry-summary-live-in-progress.svelte-17mysgz:before{content:"";background:var(--info);pointer-events:none;width:3px;animation:1.2s ease-in-out infinite audit-live-summary-stripe-blink;position:absolute;inset:0 auto 0 0}@media (prefers-reduced-motion:reduce){.audit-entry-summary-live-in-progress.svelte-17mysgz:before{opacity:.78;animation:none}}.audit-entry-left.svelte-17mysgz{align-items:center;gap:8px;min-width:0;display:flex}.audit-entry-right.svelte-17mysgz{color:var(--text-muted);flex-shrink:0;align-items:center;gap:10px;min-height:28px;display:inline-flex}.audit-thread-expander.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);min-width:28px;height:28px;color:var(--text-muted);cursor:pointer;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;gap:3px;padding:0 7px 0 4px;transition:background .1s ease-out,color .1s ease-out;display:inline-flex}.audit-thread-expander.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 12%, var(--bg));color:var(--accent)}.audit-thread-expander.svelte-17mysgz .audit-thread-expander-svg{width:14px;height:14px}.audit-thread-count.svelte-17mysgz{font-size:11px;font-weight:600}.audit-conversation-trigger.svelte-17mysgz{border:0;border-left:1px solid var(--border);background:color-mix(in srgb, var(--accent) 12%, var(--bg));width:32px;height:100%;color:var(--accent);cursor:pointer;border-radius:0;justify-content:center;align-items:center;margin:0;transition:background .1s ease-out,color .1s ease-out;display:inline-flex;position:absolute;inset:0 0 0 auto}.audit-conversation-trigger.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 20%, var(--bg))}.audit-conversation-trigger.svelte-17mysgz .audit-conversation-trigger-svg{stroke-linecap:butt;stroke-linejoin:miter;width:18px;height:18px}.audit-path.svelte-17mysgz{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.audit-request-badge.svelte-17mysgz{white-space:nowrap;gap:6px;min-width:0}.audit-timestamp-time.svelte-17mysgz{display:none}.audit-provider-model.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);height:24px;color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;border-radius:999px;align-items:center;max-width:420px;padding:0 10px;font-size:12px;display:inline-flex;overflow:hidden}@container dashboard-content (width<=699px){.audit-entry-summary.svelte-17mysgz{flex-direction:column;align-items:flex-start}.audit-entry-right.svelte-17mysgz{justify-content:space-between;width:100%}.audit-request-status.svelte-17mysgz,.audit-timestamp-full.svelte-17mysgz{display:none}.audit-timestamp-time.svelte-17mysgz{display:inline}}.audit-pane-split.svelte-1h5puht{grid-template-columns:1fr 2fr;align-items:start;gap:10px 14px;display:grid}.audit-pane-split-single.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}@container dashboard-content (width<=699px){.audit-pane-split.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}}.audit-pane-split.svelte-1h5puht .audit-pane-block-error:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-pane-empty:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-size-warning:where(.svelte-1h5puht){grid-column:1/-1}.audit-pane-block.svelte-1h5puht{min-width:0}.audit-pane-block.svelte-1h5puht>h5{margin-bottom:6px}.audit-pane-block-head.svelte-1h5puht{justify-content:space-between;align-items:center;gap:8px;margin-bottom:6px;display:flex}.audit-pane-block-title.svelte-1h5puht{align-items:center;gap:8px;min-width:0;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn{background-color:var(--bg-surface);border:1px solid color-mix(in srgb, var(--border) 70%, var(--text) 30%);color:var(--text);cursor:pointer;border-radius:6px;flex:none;align-items:center;gap:6px;padding:4px 8px;font-family:inherit;font-size:12px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn:hover:not(:disabled){background:color-mix(in srgb, var(--bg-surface) 80%, var(--text) 20%);border-color:color-mix(in srgb, var(--border) 45%, var(--text) 55%)}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 18%, var(--bg-surface))}.audit-json.svelte-1h5puht{background:var(--bg-surface);border:1px solid var(--border);box-sizing:border-box;white-space:pre;max-width:100%;max-height:220px;color:var(--text);border-radius:6px;padding:10px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;line-height:1.45;overflow:auto}.audit-pane-error-message.svelte-1h5puht{color:var(--danger)}.audit-pane-clickable-preview.svelte-1h5puht{cursor:pointer}.audit-pane-clickable-preview.svelte-1h5puht:hover{background:color-mix(in srgb, var(--danger) 8%, transparent)}.audit-json-body.svelte-1h5puht{white-space:pre;overflow-wrap:normal}.audit-pane-empty.svelte-1h5puht{text-align:left;padding:8px 0 0}.audit-pane-pending.svelte-1h5puht{align-items:center;gap:8px;display:flex}.audit-pane-streaming.svelte-1h5puht{letter-spacing:.02em;color:var(--text-muted);align-items:center;gap:7px;padding-left:4px;font-size:11px;font-weight:600;display:inline-flex}.audit-size-warning.svelte-1h5puht{color:var(--warning);margin-top:8px;font-size:12px}.audit-request-response.svelte-1bc5vi5{margin-top:4px}.audit-pane-tablist.svelte-1bc5vi5{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:2px;display:flex}.audit-pane-tab.svelte-1bc5vi5{border:1px solid var(--border);color:var(--text-muted);cursor:pointer;background:0 0;border-bottom-color:#0000;border-radius:6px 6px 0 0;align-items:center;gap:8px;margin-bottom:-1px;margin-right:12px;padding:8px 12px;font-family:inherit;font-size:13px;transition:color .15s,border-color .15s,background-color .15s;display:inline-flex}.audit-pane-tab.svelte-1bc5vi5:not(.audit-pane-tab-active):hover{color:var(--text);background:color-mix(in srgb, var(--text) 5%, transparent)}.audit-pane-tab-active.svelte-1bc5vi5{color:var(--text);border-color:var(--border);border-bottom-color:var(--bg);background:var(--bg)}.audit-pane-tab-label.svelte-1bc5vi5{font-weight:600}.audit-pane-tabpanel.svelte-1bc5vi5{min-width:0}.audit-pane-icon.svelte-1bc5vi5{color:var(--text-muted);flex:none;align-items:center;display:inline-flex}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-request{color:var(--accent)}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-response{color:var(--info)}.audit-pane-icon.svelte-1bc5vi5 svg{width:16px;height:16px}.audit-pane-seq.svelte-1bc5vi5{color:var(--text-muted);font-size:12px}.audit-pane-kind.svelte-1bc5vi5{text-transform:uppercase;letter-spacing:.04em;font-size:10px;font-weight:600}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-primary{color:var(--text-muted)}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-failover{color:var(--accent);background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-retry{color:var(--warning);background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 30%, var(--border))}.audit-savings-pill.svelte-1bc5vi5{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);color:var(--prompt-cache-color);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;font-weight:700;display:inline-flex}.audit-step-pill.svelte-1bc5vi5{border:1px dashed var(--border);color:var(--text-muted);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;display:inline-flex}.audit-entry.svelte-cmjgwr{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);transition:background .12s ease-out,border-color .12s ease-out;overflow:hidden}.audit-entry-interactions-open.svelte-cmjgwr{border-color:color-mix(in srgb, var(--prompt-cache-color) 38%, var(--border));background:color-mix(in srgb, var(--prompt-cache-color) 7%, var(--bg))}.audit-entry-details.svelte-cmjgwr{border-top:1px solid var(--border);background:var(--bg-surface);padding:12px;overflow:hidden}.audit-entry-interactions-open.svelte-cmjgwr .audit-entry-details:where(.svelte-cmjgwr){border-top-color:color-mix(in srgb, var(--prompt-cache-color) 24%, var(--border));background:color-mix(in srgb, var(--prompt-cache-color) 5%, var(--bg-surface))}.audit-thread.svelte-pneivi{flex-direction:column;gap:10px;display:flex}.audit-thread-children.svelte-pneivi{flex-direction:column;gap:10px;margin-left:26px;display:flex}.audit-thread-child.svelte-pneivi,.audit-thread-loading.svelte-pneivi{position:relative}.audit-thread-child.svelte-pneivi:before,.audit-thread-loading.svelte-pneivi:before{content:"";border-left:1px solid var(--border);border-bottom:1px solid var(--border);pointer-events:none;border-bottom-left-radius:6px;width:12px;height:calc(50% + 10px);position:absolute;top:-10px;left:-14px}.audit-thread-child.svelte-pneivi:not(:last-child):after{content:"";border-left:1px solid var(--border);pointer-events:none;position:absolute;top:50%;bottom:-10px;left:-14px}.audit-thread-loading.svelte-pneivi{padding:6px 0 6px 4px;display:flex}.audit-thread-more.svelte-pneivi{color:var(--text-muted);padding-left:4px;font-size:12px}.audit-log-loading.svelte-1nhcbov{justify-content:center;padding:2rem 0;display:flex}.audit-list-toolbar.svelte-1nhcbov{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;display:flex}.audit-list-toolbar-left.svelte-1nhcbov{flex-wrap:wrap;align-items:center;gap:16px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov{color:var(--text-muted);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:7px;font-size:13px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov input:where(.svelte-1nhcbov){accent-color:var(--accent);cursor:pointer}.audit-retention-note.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-retention-highlight.svelte-1nhcbov{color:var(--text);font-weight:600}.audit-log-section.svelte-1nhcbov{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.audit-log-summary.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-log-list.svelte-1nhcbov{flex-direction:column;gap:10px;display:flex}.settings-guardrails-list.svelte-1bvx512{min-width:0}.settings-guardrail-type-pill.svelte-1bvx512{border:1px solid color-mix(in srgb, var(--accent) 18%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent);color:var(--text);white-space:nowrap;border-radius:999px;align-items:center;padding:6px 10px;font-size:12px;font-weight:600;display:inline-flex}.settings-guardrail-summary.svelte-1bvx512{color:var(--text);font-size:14px;line-height:1.45}.settings-guardrail-description.svelte-1bvx512{color:var(--text-muted);margin-top:6px;font-size:12px}.model-editor.guardrails-editor-wide{width:min(1080px,100%)}.form-field-fieldset.svelte-s964s3{border:0;min-inline-size:0;margin:0;padding:0}.form-field-legend.svelte-s964s3{color:var(--text-muted);letter-spacing:.5px;text-transform:uppercase;padding:0;font-size:12px;font-weight:600}.model-editor.settings-guardrails-editor{min-width:0}.settings-guardrails-hero.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));border-radius:var(--radius);background:radial-gradient(circle at top right, color-mix(in srgb, var(--accent-hover) 18%, transparent), transparent 42%), radial-gradient(circle at bottom left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 40%), var(--bg-surface);justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:20px;padding:24px;display:flex}.settings-kicker.svelte-5x874c{color:var(--accent);letter-spacing:.08em;text-transform:uppercase;margin:0 0 10px;font-size:11px;font-weight:700}.settings-guardrails-hero.svelte-5x874c h3{margin-bottom:8px}.settings-guardrails-hero.svelte-5x874c p:last-child{color:var(--text-muted);margin-bottom:0}.settings-guardrails-meta.svelte-5x874c{gap:12px;display:flex}.settings-guardrails-stat.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));background:color-mix(in srgb, var(--bg-surface-hover) 76%, transparent);border-radius:16px;min-width:110px;padding:14px 16px}.settings-guardrails-stat-label.svelte-5x874c{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;margin-bottom:8px;font-size:11px;font-weight:700;display:block}.settings-guardrails-stat.svelte-5x874c strong{font-size:24px;font-weight:700}@media (width<=768px){.settings-guardrails-hero.svelte-5x874c{flex-direction:column}.settings-guardrails-meta.svelte-5x874c{width:100%}.settings-guardrails-stat.svelte-5x874c{flex:1 1 0}}.mcp-catalog-section.svelte-1xqrzco{margin-top:18px}.mcp-catalog-section.svelte-1xqrzco .form-field-label{margin-bottom:8px}.mcp-catalog-subtitle.svelte-1xqrzco{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.mcp-catalog-list.svelte-1xqrzco{flex-direction:column;gap:12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.mcp-catalog-item-name.svelte-1xqrzco{overflow-wrap:anywhere;font-size:13px}.mcp-catalog-item-aggregated.svelte-1xqrzco{color:var(--text-muted);overflow-wrap:anywhere;margin-top:2px;font-size:11px}.mcp-catalog-item-description.svelte-1xqrzco{color:var(--text-muted);margin:2px 0 0;font-size:13px;font-weight:400}.mcp-server-sub-counts.svelte-ah8nrt{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;max-width:280px;margin-top:4px;font-size:11px;overflow:hidden}.mcp-server-table-wrapper.svelte-ah8nrt{overflow-x:auto}.mcp-server-table-wrapper.svelte-ah8nrt .data-table{min-width:860px}.auth-key-form-fields.svelte-1gswxes>.form-field{margin-bottom:4px}.auth-key-dashboard-toggle.svelte-1gswxes{cursor:pointer;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-key-issued-banner.svelte-1gswxes{background:color-mix(in srgb, var(--success) 8%, var(--bg-surface));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));border-radius:var(--radius);margin-bottom:20px;padding:16px}.auth-key-issued-warning.svelte-1gswxes{color:color-mix(in srgb, var(--success) 80%, var(--text));margin-bottom:12px;font-size:13px;font-weight:600}.auth-key-issued-value-row.svelte-1gswxes{flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:12px;display:flex}.auth-key-issued-token.svelte-1gswxes{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);word-break:break-all;flex:1;min-width:0;padding:8px 12px;font-size:13px;overflow-x:auto}.usage-label-chip-static.svelte-nf0ldb,.usage-label-chip-static.svelte-nf0ldb:hover{cursor:default;background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.auth-key-redacted.svelte-nf0ldb{color:var(--text-muted);font-size:13px}.auth-key-actions-cell.svelte-nf0ldb{white-space:nowrap}.auth-key-row-deactivated.svelte-nf0ldb td:where(.svelte-nf0ldb):not(.auth-key-actions-cell){opacity:.55}.auth-key-expiry.svelte-nf0ldb{white-space:nowrap;align-items:center;gap:8px;display:inline-flex}.auth-key-th-help.svelte-nf0ldb{cursor:help;align-items:center;gap:4px;display:inline-flex}.auth-key-row-actions.svelte-nf0ldb{align-items:center;gap:6px;display:inline-flex}.auth-keys-loading.svelte-1xpdcqx{justify-content:center;align-items:center;padding:32px 0;display:flex}.auth-keys-help-notice.svelte-1xpdcqx{margin-bottom:20px}.auth-keys-inactive-toggle.svelte-1xpdcqx{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-keys-inactive-toggle.svelte-1xpdcqx input:where(.svelte-1xpdcqx){width:16px;height:16px;accent-color:var(--accent);cursor:pointer}.settings-panel-header.svelte-15kyv2y{justify-content:space-between;gap:16px;margin-bottom:20px;display:flex}.settings-panel-header.svelte-15kyv2y h3{font-size:18px}.settings-form-grid.svelte-15kyv2y{grid-template-columns:minmax(280px,420px);gap:16px;display:grid}@media (width<=768px){.settings-form-grid.svelte-15kyv2y{grid-template-columns:1fr}}.budget-settings-section.svelte-a747ys{width:100%}.budget-settings-grid.svelte-a747ys{gap:12px;display:grid}.budget-settings-row.svelte-a747ys{grid-template-columns:96px minmax(170px,1fr) minmax(110px,140px) minmax(110px,140px) minmax(220px,280px);align-items:start;gap:12px;display:grid}.budget-settings-period.svelte-a747ys{color:var(--text);letter-spacing:0;text-transform:uppercase;align-self:end;min-height:35px;padding-bottom:9px;font-size:12px;font-weight:700}.budget-settings-spacer.svelte-a747ys{min-height:1px}.budget-settings-help-cell.svelte-a747ys{align-self:start;min-width:0;min-height:35px}.budget-settings-help-cell.svelte-a747ys .inline-help-copy{max-width:280px;margin:22px 0 0;font-size:12px;line-height:1.35}@media (width<=768px){.budget-settings-grid.svelte-a747ys,.budget-settings-row.svelte-a747ys{grid-template-columns:1fr}.budget-settings-spacer.svelte-a747ys{display:none}}.tagging-settings-grid.svelte-18e8yem{gap:12px;display:grid}.tagging-settings-row.svelte-18e8yem{grid-template-columns:minmax(170px,1fr) minmax(150px,1fr) minmax(80px,110px) auto minmax(90px,auto);align-items:end;gap:12px;display:grid}.tagging-do-not-pass.svelte-18e8yem{color:var(--text);white-space:nowrap;align-items:center;gap:6px;min-height:35px;font-size:13px;display:flex}.tagging-row-trailer.svelte-18e8yem{align-items:center;gap:8px;min-height:35px;display:flex}.tagging-settings-empty.svelte-18e8yem{color:var(--text-muted);margin:0}.tagging-settings-actions.svelte-18e8yem{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.tagging-settings-row.svelte-18e8yem{grid-template-columns:1fr;align-items:stretch}.tagging-settings-actions.svelte-18e8yem,.tagging-settings-actions.svelte-18e8yem .btn{width:100%}}.pricing-recalculate-section.svelte-1cdxzyk{width:100%}.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:minmax(220px,320px) minmax(260px,360px);justify-content:start;align-items:end;gap:12px;width:100%;display:grid}.pricing-recalculate-date-field.svelte-1cdxzyk{grid-column:1/-1;width:100%;max-width:320px}.pricing-recalculate-filter-field.svelte-1cdxzyk{width:100%;max-width:360px}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker{width:100%}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-trigger{justify-content:space-between;width:100%}.pricing-recalculate-actions.svelte-1cdxzyk{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:1fr}.pricing-recalculate-actions.svelte-1cdxzyk,.pricing-recalculate-actions.svelte-1cdxzyk .btn{width:100%}}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-dropdown{inset:auto auto calc(100% + 6px) 0}.settings-refresh-icon.svelte-yeq2mp{flex:0 0 16px;width:16px;height:16px}.runtime-refresh-steps.svelte-yeq2mp{color:var(--text-muted);gap:8px;margin-top:14px;padding-left:18px;font-size:13px;display:grid}.runtime-refresh-step.is-ok.svelte-yeq2mp{color:var(--success)}.runtime-refresh-step.is-partial.svelte-yeq2mp{color:var(--warning)}.runtime-refresh-step.is-failed.svelte-yeq2mp{color:var(--danger)}.runtime-settings-copy.svelte-tldbe5{min-width:180px}.runtime-settings-fields.svelte-tldbe5{gap:16px;width:min(560px,100%);display:grid}.runtime-setting-row.svelte-tldbe5{grid-template-columns:minmax(220px,1fr) 180px;align-items:center;gap:20px;display:grid}.runtime-setting-description.svelte-tldbe5,.runtime-setting-managed.svelte-tldbe5{color:var(--text-muted);margin:4px 0 0;font-size:12px}.runtime-setting-managed.svelte-tldbe5{color:var(--warning)}@media (width<=720px){.runtime-setting-row.svelte-tldbe5{grid-template-columns:1fr;gap:8px}}.settings-version-footer.svelte-3naq7u{color:var(--text-muted);text-align:right;margin-top:24px;font-size:12px}.chat-message.svelte-12s99s5{border:1px solid var(--border);background:var(--bg);border-radius:10px;max-width:94%;padding:10px 12px;position:relative;overflow:hidden}.chat-message.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border));box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent)}.chat-message.is-after-anchor.svelte-12s99s5,.chat-function-note.is-after-anchor.svelte-12s99s5{opacity:.46}.chat-message.role-user.svelte-12s99s5{align-self:flex-start}.chat-message.role-assistant.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 18%, var(--bg));align-self:flex-end}.chat-message.role-system.svelte-12s99s5{background:color-mix(in srgb, var(--warning) 10%, var(--bg));align-self:center;width:100%;max-width:100%}.chat-message.role-error.svelte-12s99s5{border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg));align-self:flex-end}.chat-message.role-error.svelte-12s99s5 .chat-role:where(.svelte-12s99s5){color:color-mix(in srgb, var(--danger) 75%, var(--text-muted))}.chat-message-meta.svelte-12s99s5{justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:6px;display:flex}.chat-role.svelte-12s99s5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:12px;font-weight:700}.chat-time.svelte-12s99s5{color:var(--text-muted);white-space:nowrap;font-size:11px}.chat-content.svelte-12s99s5{white-space:pre-wrap;overflow-wrap:break-word;color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:13px;line-height:1.5}.chat-message.svelte-12s99s5:before,.chat-function-note.svelte-12s99s5:before{content:"";z-index:0;pointer-events:none;opacity:var(--prompt-cache-visibility);background:linear-gradient(90deg, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) 0, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) var(--prompt-cache-fill), transparent var(--prompt-cache-fill), transparent 100%);transition:opacity .15s;position:absolute;inset:0}.chat-message.svelte-12s99s5>:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5>:where(.svelte-12s99s5){z-index:1;position:relative}.chat-tool-calls.svelte-12s99s5{border-top:1px solid var(--border);flex-direction:column;gap:3px;margin-top:8px;padding-top:6px;display:flex}.chat-tool-call.svelte-12s99s5{color:var(--text-muted);border-radius:5px;min-width:0;padding:3px 5px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;position:relative;overflow:hidden}.chat-tool-call-summary.svelte-12s99s5{cursor:pointer;align-items:baseline;gap:6px;min-width:0;display:flex}.chat-tool-call-preview.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;opacity:.8;flex:1;min-width:0;overflow:hidden}.chat-tool-call-arguments.svelte-12s99s5{background:color-mix(in srgb, var(--border) 45%, transparent);color:var(--text);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;border-radius:6px;max-height:200px;margin-top:5px;padding:6px 8px;line-height:1.45;overflow:auto}.chat-tool-call-name.svelte-12s99s5:before{content:"⚡"}.chat-function-note.svelte-12s99s5{max-width:94%;color:var(--text-muted);background:color-mix(in srgb, var(--border) 40%, transparent);border:1px dashed var(--border);border-radius:12px;align-self:center;padding:4px 12px;font-size:12px;position:relative;overflow:hidden}.chat-function-note.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-inner.svelte-12s99s5{align-items:baseline;gap:6px;display:flex;overflow:hidden}.chat-function-note-inner.svelte-12s99s5 .chat-time:where(.svelte-12s99s5){flex-shrink:0;margin-left:auto}.chat-function-call-id.svelte-12s99s5{color:var(--text-muted);overflow-wrap:anywhere;margin-top:6px;font-size:10px}.chat-function-label.svelte-12s99s5{text-transform:uppercase;letter-spacing:.3px;white-space:nowrap;flex-shrink:0;font-size:11px;font-weight:600}.chat-function-label.svelte-12s99s5:before{content:"▸";margin-right:4px;transition:transform .12s;display:inline-block}.chat-function-note-details[open].svelte-12s99s5 .chat-function-label:where(.svelte-12s99s5):before{transform:rotate(90deg)}.chat-function-detail.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;overflow:hidden}.chat-function-note.role-function-call.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 8%, transparent);border-color:color-mix(in srgb, var(--accent) 30%, var(--border));align-self:flex-end}.chat-function-note.role-function-result.svelte-12s99s5{background:color-mix(in srgb, var(--success) 8%, transparent);border-color:color-mix(in srgb, var(--success) 30%, var(--border));align-self:flex-start}.chat-function-note.is-anchor.role-function-call.svelte-12s99s5,.chat-function-note.is-anchor.role-function-result.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-details.svelte-12s99s5{width:100%}.chat-function-note-details.svelte-12s99s5>summary{cursor:pointer;list-style:none}.chat-function-note-details.svelte-12s99s5>summary::-webkit-details-marker{display:none}.chat-function-expanded.svelte-12s99s5{border-top:1px solid var(--border);white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text);max-height:200px;margin-top:6px;padding-top:6px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;line-height:1.45;overflow:auto}@media (width<=768px){.chat-message.svelte-12s99s5{max-width:100%}}.conversation-drawer.svelte-ssrzja{flex:0 0 var(--conversation-panel-width);width:var(--conversation-panel-width);background:var(--bg-surface);border-left:1px solid var(--border);z-index:12;flex-direction:column;min-width:0;height:100vh;display:flex;position:sticky;top:0}.conversation-drawer-fullscreen.svelte-ssrzja{z-index:70;border-left:0;flex-basis:auto;width:100vw;height:100dvh;position:fixed;inset:0}.conversation-drawer-fullscreen.svelte-ssrzja .conversation-resize-handle:where(.svelte-ssrzja){display:none}.conversation-resize-handle.svelte-ssrzja{z-index:2;cursor:col-resize;touch-action:none;background:0 0;border:0;border-radius:0;outline:none;width:10px;padding:0;position:absolute;top:0;bottom:0;left:-5px}.conversation-resize-handle.svelte-ssrzja:after{content:"";background:0 0;width:2px;transition:background .15s;position:absolute;top:0;bottom:0;left:4px}.conversation-resize-handle.svelte-ssrzja:hover:after,.conversation-resize-handle.svelte-ssrzja:focus-visible:after{background:color-mix(in srgb, var(--accent) 70%, var(--border))}body.conversation-panel-resizing{cursor:col-resize;-webkit-user-select:none;user-select:none}.conversation-drawer-header.svelte-ssrzja{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:10px;padding:14px 16px;display:flex}.conversation-drawer-header-actions.svelte-ssrzja{align-items:center;gap:6px;display:flex}.conversation-drawer-header.svelte-ssrzja h3{font-size:16px;font-weight:700}.conversation-meta.svelte-ssrzja{color:var(--text-muted);font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px}.conversation-drawer-footer.svelte-ssrzja{border-top:1px solid var(--border);background:var(--bg-surface);flex-direction:column;flex-shrink:0;gap:9px;padding:10px 16px;display:flex}.conversation-composer.svelte-ssrzja{flex-direction:column;gap:7px;display:flex}.conversation-composer.svelte-ssrzja label:where(.svelte-ssrzja){font-size:12px;font-weight:700}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja){resize:vertical;border:1px solid var(--border);background:var(--bg);width:100%;min-height:70px;color:var(--text);font:inherit;border-radius:7px;padding:9px 10px;line-height:1.45}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):focus{outline:2px solid color-mix(in srgb, var(--accent) 38%, transparent);outline-offset:1px}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):disabled{opacity:.65}.conversation-composer-actions.svelte-ssrzja{justify-content:space-between;align-items:center;gap:10px;display:flex}.conversation-endpoint.svelte-ssrzja{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--text-muted);font-size:11px;overflow:hidden}.conversation-send-error.svelte-ssrzja{color:var(--danger);font-size:12px}.conversation-truncated.svelte-ssrzja{color:var(--text-muted);padding:0 16px 14px;font-size:12px}.conversation-cache-legend.svelte-ssrzja{color:var(--text-muted);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:7px;margin:12px 16px 0;padding:0;font-family:inherit;font-size:11px;display:flex}.conversation-cache-legend.svelte-ssrzja:hover{color:var(--text)}.conversation-cache-legend.svelte-ssrzja:focus-visible{outline:2px solid color-mix(in srgb, var(--prompt-cache-color) 35%, transparent);outline-offset:3px;border-radius:3px}.conversation-cache-switch.svelte-ssrzja{background:color-mix(in srgb, var(--text-muted) 30%, var(--border));border-radius:999px;flex:none;width:28px;height:16px;transition:background-color .15s;position:relative}.conversation-cache-switch.is-active.svelte-ssrzja{background:color-mix(in srgb, var(--prompt-cache-color) 80%, var(--bg))}.conversation-cache-switch-thumb.svelte-ssrzja{background:#fff;border-radius:50%;width:12px;height:12px;transition:transform .15s;position:absolute;top:2px;left:2px;box-shadow:0 1px 2px #0000003d}.conversation-cache-switch.is-active.svelte-ssrzja .conversation-cache-switch-thumb:where(.svelte-ssrzja){transform:translate(12px)}.conversation-cache-estimate.svelte-ssrzja{opacity:.75}.conversation-thread.svelte-ssrzja{flex-direction:column;gap:10px;padding:14px 16px 20px;display:flex}.conversation-live-status.svelte-ssrzja{color:var(--text-muted);align-items:center;gap:10px;padding:4px 16px 20px;font-size:13px;display:flex} diff --git a/internal/admin/dashboard/static/dist/assets/index-TuUpNQjY.js b/internal/admin/dashboard/static/dist/assets/index-TuUpNQjY.js new file mode 100644 index 000000000..d9947c266 --- /dev/null +++ b/internal/admin/dashboard/static/dist/assets/index-TuUpNQjY.js @@ -0,0 +1,67 @@ +(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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`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){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function h(e,t,n=!1){return e===void 0?n?t():t:e}function g(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 _=1<<24,v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,ee=65536,te=1<<19,ne=1<<20,re=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(`legacy props`),ue=Symbol(``),de=Symbol(`attributes`),fe=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),he=Symbol(`form reset`),ge=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},_e=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(`uninitialized`),je=`http://www.w3.org/1999/xhtml`,Me=`http://www.w3.org/2000/svg`,Ne=`http://www.w3.org/1998/Math/MathML`;function Pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Fe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ie(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Le(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Re=!1;function ze(e){Re=e}var Be;function Ve(e){if(e===null)throw Fe(),ke;return Be=e}function He(){return Ve(bn(Be))}function T(e){if(Re){if(bn(Be)!==null)throw Fe(),ke;Be=e}}function Ue(e=1){if(Re){for(var t=e,n=Be;t--;)n=bn(n);Be=n}}function We(e=!0){for(var t=0,n=Be;;){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=bn(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Fe(),ke;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=null;function Xe(e){Ye=e}function E(e,t=!1,n){Ye={p:Ye,i:!1,c:null,e:null,s:e,x:null,r:ir,l:null}}function D(e){var t=Ye,n=t.e;if(n!==null){t.e=null;for(var r of n)jn(r)}return e!==void 0&&(t.x=e),t.i=!0,Ye=t.p,e??{}}function Ze(){return!0}var Qe=[];function $e(){var e=Qe;Qe=[],p(e)}function et(e){if(Qe.length===0&&!zt){var t=Qe;queueMicrotask(()=>{t===Qe&&$e()})}Qe.push(e)}function tt(){for(;Qe.length>0;)$e()}function nt(e){var t=ir;if(t===null)return tr.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;rt(e,t)}function rt(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var it=~(y|b|v);function at(e,t){e.f=e.f&it|t}function ot(e){e.f&512||e.deps===null?at(e,v):at(e,b)}function st(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,st(t.deps))}function ct(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),st(e.deps),at(e,v)}var lt=!1;function ut(e){var t=lt;try{return lt=!1,[e(),lt]}finally{lt=t}}function dt(e,t){if(t){let t=document.body;e.autofocus=!0,et(()=>{document.activeElement===t&&e.focus()})}}function ft(e){Re&&yn(e)!==null&&xn(e)}var pt=!1;function mt(){pt||(pt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[he]?.()})},{capture:!0}))}function ht(e){var t=tr,n=ir;rr(null),ar(null);try{return e()}finally{rr(t),ar(n)}}function gt(e,t,n,r=n){e.addEventListener(t,()=>ht(n));let i=e[he];i?e[he]=()=>{i(),r(!0)}:e[he]=()=>r(!0),mt()}function _t(e){let t=0,n=an(0),r;return()=>{On()&&(I(n),In(()=>(t===0&&(r=Er(()=>e(()=>ln(n)))),t+=1,()=>{et(()=>{--t,t===0&&(r?.(),r=void 0,ln(n))})})))}}var vt=ee|te;function yt(e,t,n,r){new bt(e,t,n,r)}var bt=class{parent;is_pending=!1;transform_error;#e;#t=Re?Be: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=_t(()=>(this.#m=an(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=ir;t.b=this,t.f|=128,n(e)},this.parent=ir.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Ln(()=>{if(Re){let e=this.#t;He();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},vt),Re&&(this.#e=Be)}#g(){try{this.#a=zn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=zn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=zn(()=>e(this.#e)),et(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>zn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Kn(this.#o,()=>{this.#o=null}),this.#b(Ft))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=zn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Xn(this.#a,e);let t=this.#n.pending;this.#o=zn(()=>t(this.#e))}else this.#b(Ft)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){ct(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=ir,n=tr,r=Ye;ar(this.#i),rr(this.#i),Xe(this.#i.ctx);try{return Gt.ensure(),e()}catch(e){return nt(e),null}finally{ar(t),rr(n),Xe(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Kn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,et(()=>{this.#d=!1,this.#m&&sn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),I(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Ft?.is_fork?(this.#a&&Ft.skip_effect(this.#a),this.#o&&Ft.skip_effect(this.#o),this.#s&&Ft.skip_effect(this.#s),Ft.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Un(this.#a),null),this.#o&&=(Un(this.#o),null),this.#s&&=(Un(this.#s),null),Re&&(Ve(this.#t),Ue(),Ve(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Le();return}r=!0,i&&Oe(),this.#s!==null&&Kn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){rt(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return zn(()=>{var t=ir;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return rt(e,this.#i.parent),null}}))};et(()=>{var t;try{t=this.transform_error(e)}catch(e){rt(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>rt(e,this.#i&&this.#i.parent)):o(t)})}};function xt(e,t,n,r){let i=Ze()?Tt:Ot;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=ir,c=St(),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){rt(e,s)}Ct()}}var d=wt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Dt(e))).then(u).catch(e=>rt(e,s)).finally(d)}l?l.then(()=>{c(),f(),Ct()}):f()}function St(){var e=ir,t=tr,n=Ye,r=Ft;return function(i=!0){ar(e),rr(t),Xe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ct(e=!0){ar(null),rr(null),Xe(null),e&&Ft?.deactivate()}function wt(){var e=ir,t=e.b,n=Ft,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 Tt(e){var t=2|y;return ir!==null&&(ir.f|=te),{ctx:Ye,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:ir,ac:null}}var Et=Symbol(`obsolete`);function Dt(e,t,n){let r=ir;r===null&&ve();var i=void 0,a=an(Ae),o=!tr,s=new Set;return Fn(()=>{var t=ir,n=m();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ge&&n.reject(e)}).finally(Ct)}catch(e){n.reject(e),Ct()}var c=Ft;if(o){if(t.f&32768)var l=wt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Et);else for(let e of s.values())e.reject(Et);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Et&&(c.activate(),t?(a.f|=se,sn(a,t)):(a.f&8388608&&(a.f^=se),sn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),kn(()=>{for(let e of s)e.reject(Et)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function O(e){let t=Tt(e);return sr(t),t}function Ot(e){let t=Tt(e);return t.equals=Je,t}function kt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(ge),t.ac=null}),t.fn!==null&&(t.teardown=f),xr(t,0),Vn(t))}function Nt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Sr(t)}var Pt=null,Ft=null,It=null,Lt=null,Rt=null,zt=!1,Bt=!1,Vt=null,Ht=null,Ut=0,Wt=1,Gt=class e{id=Wt++;#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(){Pt===null?Pt=this:(Pt.#n=this,this.#t=Pt),Pt=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)at(r,y),t(r);for(r of n.m)at(r,b),t(r)}this.#p.add(e)}#g(){this.#e=!0,Ut++>1e3&&(this.#x(),qt());for(let e of this.#u)this.#d.delete(e),at(e,y),this.schedule(e);for(let e of this.#d)at(e,b),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Vt=[],r=[],i=Ht=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw en(e),this.#h()||this.discard(),t}if(Ft=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Vt=null,Ht=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)$t(e,t);i.length>0&&Ft.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),It=this,Yt(r),Yt(n),It=null,this.#s?.resolve();var s=Ft;if(this.#a===0&&(this.#c.length===0||s!==null)&&this.#x(),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):_r(r)&&(i&16&&this.#d.add(r),Sr(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}}}#v(){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}#y(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),at(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#x(),Ft=this,this.#g()}#b(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??=m()).promise}static ensure(){if(Ft===null){let t=Ft=new e;!Bt&&!zt&&et(()=>{t.#e||t.flush()})}return Ft}apply(){Lt=null}schedule(e){if(Rt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Vt!==null&&t===ir&&(tr===null||!(tr.f&2)))return;if(n&96){if(!(n&1024))return;t.f^=v}}this.#c.push(t)}#x(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?Pt=e:t.#t=e,this.linked=!1}}};function Kt(e){var t=zt;zt=!0;try{var n;for(e&&(Ft!==null&&!Ft.is_fork&&Ft.flush(),n=e());;){if(tt(),Ft===null)return n;Ft.flush()}}finally{zt=t}}function qt(){try{Ce()}catch(e){rt(e,Rt)}}var Jt=null;function Yt(e){var t=e.length;if(t!==0){for(var n=0;n0)){nn.clear();for(let e of Jt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Jt.has(n)&&(Jt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sr(n)}}Jt.clear()}}Jt=null}}function Xt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Xt(i,t,n,r):e&4194320&&!(e&2048)&&Zt(i,t,r)&&(at(i,y),Qt(i))}}function Zt(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(e.deps!==null)for(let i of e.deps){if(n.call(t,i))return!0;if(i.f&2&&Zt(i,t,r))return r.set(i,!0),!0}return r.set(e,!1),!1}function Qt(e){Ft.schedule(e)}function $t(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),at(e,v);for(var n=e.first;n!==null;)$t(n,t),n=n.next}}function en(e){at(e,v);for(var t=e.first;t!==null;)en(t),t=t.next}var tn=new Set,nn=new Map,rn=!1;function an(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function k(e,t){let n=an(e,t);return sr(n),n}function on(e,t=!1,n=!0){let r=an(e);return t||(r.equals=Je),r}function A(e,t,n=!1){return tr!==null&&(!nr||tr.f&131072)&&Ze()&&tr.f&4325394&&(or===null||!or.has(e))&&De(),sn(e,n?j(t):t,Ht)}function sn(e,t,n=null){if(!e.equals(t)){nn.set(e,$n?t:e.v);var r=Gt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&At(t),Lt===null&&ot(t)}e.wv=gr(),un(e,y,n),Ze()&&ir!==null&&ir.f&1024&&!(ir.f&96)&&(ur===null?dr([e]):ur.push(e)),!r.is_fork&&tn.size>0&&!rn&&cn()}return t}function cn(){rn=!1;for(let e of tn){e.f&1024&&at(e,b);let t;try{t=_r(e)}catch{t=!0}t&&Sr(e)}tn.clear()}function ln(e){A(e,e.v+1)}function un(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ze(),a=r.length,o=0;o{if(mr===d)return e();var t=tr,n=mr;rr(null),hr(d);var r=e();return rr(t),hr(n),r};return i&&r.set(`length`,k(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Te();var i=r.get(t);return i===void 0?f(()=>{var e=k(n.value,u);return r.set(t,e),e}):A(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>k(Ae,u));r.set(t,e),ln(o)}}else A(n,Ae),ln(o);return!0},get(e,n,i){if(n===ce)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>k(j(s?e[n]:Ae),u)),r.set(n,o)),o!==void 0){var c=I(o);return c===Ae?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=I(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===ce)return!0;var n=r.get(t),i=n!==void 0&&n.v!==Ae||Reflect.has(e,t);return(n!==void 0||ir!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>k(i?j(e[t]):Ae,u)),r.set(t,n)),I(n)===Ae)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dk(Ae,u)),r.set(d+``,p)):A(p,Ae)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>k(void 0,u)),A(c,j(n)),r.set(t,c));else{l=c.v!==Ae;var m=f(()=>j(n));A(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&&A(g,_+1)}ln(o)}return!0},ownKeys(e){I(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==Ae});for(var[n,i]of r)i.v!==Ae&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ee()}})}function dn(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=a(t,`firstChild`).get,gn=a(t,`nextSibling`).get,u(e)&&(e[fe]=void 0,e[de]=null,e[pe]=void 0,e.__e=void 0),u(n)&&(n[me]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function M(e,t){if(!Re)return yn(e);var n=yn(Be);if(n===null)n=Be.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),Ve(r),r}return t&&wn(n),Ve(n),n}function N(e,t=!1){if(!Re){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Be?.nodeType!==3){var r=vn();return Be?.before(r),Ve(r),r}wn(Be)}return Be}function P(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=bn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),Ve(a),a}wn(r)}return Ve(r),r}function xn(e){e.textContent=``}function Sn(){return!1}function Cn(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 wn(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 Tn(e){ir===null&&(tr===null&&Se(e),xe()),$n&&be(e)}function En(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Dn(e,t){var n=ir;n!==null&&n.f&8192&&(e|=x);var r={ctx:Ye,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};Ft?.register_created_effect(r);var i=r;if(e&4)Vt===null?Gt.ensure().schedule(r):Vt.push(r);else if(t!==null){try{Sr(r)}catch(e){throw Un(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|=ee))}if(i!==null&&(i.parent=n,n!==null&&En(i,n),tr!==null&&tr.f&2&&!(e&64))){var a=tr;(a.effects??=[]).push(i)}return r}function On(){return tr!==null&&!nr}function kn(e){let t=Dn(8,null);return at(t,v),t.teardown=e,t}function An(e){Tn(`$effect`);var t=ir.f;if(!tr&&t&32&&Ye!==null&&!Ye.i){var n=Ye;(n.e??=[]).push(e)}else return jn(e)}function jn(e){return Dn(4|ne,e)}function Mn(e){Gt.ensure();let t=Dn(64|te,e);return()=>{Un(t)}}function Nn(e){Gt.ensure();let t=Dn(64|te,e);return(e={})=>new Promise(n=>{e.outro?Kn(t,()=>{Un(t),n(void 0)}):(Un(t),n(void 0))})}function Pn(e){return Dn(4,e)}function Fn(e){return Dn(oe|te,e)}function In(e,t=0){return Dn(8|t,e)}function F(e,t=[],n=[],r=[]){xt(r,t,n,t=>{Dn(8,()=>{e(...t.map(I))})})}function Ln(e,t=0){return Dn(16|t,e)}function Rn(e,t=0){return Dn(_|t,e)}function zn(e){return Dn(32|te,e)}function Bn(e){var t=e.teardown;if(t!==null){let e=$n,n=tr;er(!0),rr(null);try{t.call(null)}finally{er(e),rr(n)}}}function Vn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ht(()=>{e.abort(ge)});var r=n.next;n.f&64?n.parent=null:Un(n,t),n=r}}function Hn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Un(t),t=n}}function Un(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Wn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,Vn(e,t&&!n),xr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Bn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Gn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Wn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Gn(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 Kn(e,t,n=!0){var r=[];qn(e,r,!0);var i=()=>{n&&Un(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function qn(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)!=0||(i.f&32)!=0&&(e.f&16)!=0;qn(i,t,o?n:!1)}i=a}}}function Jn(e){Yn(e,!0)}function Yn(e,t){if(e.f&8192){e.f^=x,e.f&1024||(at(e,y),Gt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Yn(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 Xn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var Zn=null,Qn=!1,$n=!1;function er(e){$n=e}var tr=null,nr=!1;function rr(e){tr=e}var ir=null;function ar(e){ir=e}var or=null;function sr(e){tr!==null&&(or??=new Set).add(e)}var cr=null,lr=0,ur=null;function dr(e){ur=e}var fr=1,pr=0,mr=pr;function hr(e){mr=e}function gr(){return++fr}function _r(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Lt===null&&at(e,v)}return!1}function vr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(or!==null&&or.has(e)))for(var i=0;i{e.ac.abort(ge)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=C;var f=e.deps,p=Ft?.is_fork;if(cr!==null){var m;if(p||xr(e,lr),f!==null&&lr>0)for(f.length=lr+cr.length,m=0;m{s.ac.abort(ge),s.ac=null,at(s,y)}),Mt(s),xr(s,0)}}function xr(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`?et(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Vr(e,t,n,r,i){var a={capture:r,passive:i},o=Br(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&kn(()=>{t.removeEventListener(e,o,a)})}function L(e,t,n){(t[Lr]??={})[e]=n}function Hr(e){for(var t=0;t{throw e});throw p}}finally{e[Lr]=t,delete e.currentTarget,rr(d),ar(f)}}}var Gr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Kr(e){return Gr?.createHTML(e)??e}function qr(e){var t=Cn(`template`);return t.innerHTML=Kr(e.replaceAll(``,``)),t.content}function Jr(e,t){var n=ir;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function R(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Re)return Jr(Be,null),Be;i===void 0&&(i=qr(a?e:``+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;Jr(o,s)}else Jr(t,t);return t}}function Yr(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}`,o;return()=>{if(Re)return Jr(Be,null),Be;if(!o){var e=yn(qr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;Jr(n,r)}else Jr(t,t);return t}}function Xr(e,t){return Yr(e,t,`svg`)}function Zr(e=``){if(!Re){var t=vn(e+``);return Jr(t,t),t}var n=Be;return n.nodeType===3?wn(n):(n.before(n=vn()),Ve(n)),Jr(n,n),n}function Qr(){if(Re)return Jr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),Jr(t,n),e}function z(e,t){if(Re){var n=ir;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Be),He();return}e!==null&&e.before(t)}var $r=!0;function ei(e){$r=e}function B(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function ti(e,t){return ri(e,t)}var ni=new Map;function ri(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=Nn(()=>{var u=n??t.appendChild(vn());yt(u,{pending:()=>{}},t=>{E({});var n=Ye;if(o&&(n.c=o),a&&(i.$$events=a),Re&&Jr(t,null),$r=s,l=e(t,i)||{},$r=!0,Re&&(ir.nodes.end=Be,Be===null||Be.nodeType!==8||Be.data!==`]`))throw Fe(),ke;D()},c);var d=new Set,f=e=>{for(var n=0;n{for(var e of d)for(let n of[t,document]){var r=ni.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Wr),r.delete(e),r.size===0&&ni.delete(n)):r.set(e,i)}zr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ii.set(l,u),l}var ii=new WeakMap,ai=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)Jn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Jn(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&&(Un(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();Xn(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else Un(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Kn(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)||(Un(n.effect),this.#n.delete(e))};ensure(e,t){var n=Ft,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:zn(()=>t(a)),fragment:i})}else this.#t.set(e,zn(()=>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 Re&&(this.anchor=Be),this.#a(n)}};function V(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ai(e),a=n?ee:0;function o(e,t){if(Re){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}Ln(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function oi(e,t){return t}function si(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;ci(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;if(l){var u=n,d=u.parentNode;xn(d),d.append(u),e.items.clear()}ci(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function ci(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,di(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=re,pi(d,null,c)):Jn(d):Kn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Ln(()=>{p=I(f);var e=p.length;let t=!1;Re&&Ge(c)===`[!`!=(e===0)&&(c=We(),Ve(c),ze(!1),t=!0);for(var r=new Set,u=Ft,v=Sn(),y=0;ys(c)):(d=zn(()=>s(li??=vn())),d.f|=re)),e>r.size&&ye(``,``,``),Re&&e>0&&Ve(We()),!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&&ze(!0),I(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Re&&(c=Be)}function ui(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function di(e,t,n,i,a){var o=(i&8)!=0,s=t.length,c=e.items,l=ui(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var te=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function fi(e,t,n,r,i,a,o,s){var c=o&1?o&16?an(n):on(n,!1,!1):null,l=o&2?an(i):null;return{v:c,i:l,e:zn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function pi(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=bn(r);if(a.before(r),r===i)return;r=o}}function mi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function hi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Re&&(o=Ve(yn(c)))}F(()=>{var e=ir;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&Jr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Wn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Re){for(var a=Be.data,l=He(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Fe(),ke;Jr(Be,u),o=Ve(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Jr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function gi(e,t,...n){var r=new ai(e);Ln(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},ee)}function _i(e,t,n){var r;Re&&(r=Be,He());var i=new ai(e);Ln(()=>{var e=t()??null;if(Re&&Ge(r)===`[`!=(e!==null)){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,e&&(t=>n(t,e))),ze(!0);return}i.ensure(e,e&&(t=>n(t,e)))},ee)}var vi=()=>performance.now(),yi={tick:e=>requestAnimationFrame(e),now:()=>vi(),tasks:new Set};function bi(){let e=yi.now();yi.tasks.forEach(t=>{t.c(e)||(yi.tasks.delete(t),t.f())}),yi.tasks.size!==0&&yi.tick(bi)}function xi(e){let t;return yi.tasks.size===0&&yi.tick(bi),{promise:new Promise(n=>{yi.tasks.add(t={c:e,f:n})}),abort(){yi.tasks.delete(t)}}}function Si(e,t){ht(()=>{e.dispatchEvent(new CustomEvent(t))})}function Ci(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function wi(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Ci(n.trim());t[i]=r.trim()}return t}var Ti=e=>e,Ei=null;function Di(e){Ei=e}function Oi(e,t,n){var r=(Ei??ir).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Ai(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function ki(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return ht(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Ai(t,m(),p,1,()=>{Si(t,`introstart`)},()=>{Si(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Ai(t,m(),f,0,()=>{Si(t,`outrostart`)},()=>{Si(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=ir;if((g.nodes.t??=[]).push(h),i&&$r){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Pn(()=>{Er(()=>h.in())})}}function Ai(e,t,n,r,i,a){var o=r===1;if(d(t)){var s,c=!1;return et(()=>{c||(s=Ai(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:f,deactivate:f,reset:f,t:()=>r};let{delay:l=0,css:u,tick:p,easing:m=Ti}=t;var h=[];if(o&&n===void 0&&(p&&p(0,1),u)){var g=wi(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var d=!1;if(u)for(var f=Math.ceil(c/(1e3/60)),h=0;h<=f;h+=1){var g=o+s*m(h/f),y=wi(u(g,1-g));l.push(y),d||=y.overflow===`hidden`}d&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*m(e/c)},p&&xi(()=>{if(v.playState!==`running`)return!1;var e=_();return p(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,p?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=f)},deactivate:()=>{a=f},reset:()=>{r===0&&p?.(1,0)},t:()=>_()}}function ji(e,t,n,r,i,a){let o=Re;Re&&He();var s=null;Re&&Be.nodeType===1&&(s=Be,He());var c=Re?Be:e,l=ir,u=new ai(c,!1);Ln(()=>{let e=t()||null;var a=i?i():n||e===`svg`?Me:void 0;if(e===null){u.ensure(null,null),ei(!0);return}return u.ensure(e,t=>{if(e){if(s=Re?s:Cn(e,a),Jr(s,s),r){var n=null;Re&&Ir(e)&&s.append(n=document.createComment(``));var i=Re?yn(s):s.appendChild(vn());Re&&(i===null?ze(!1):Ve(i)),Di(l),r(s,i),n?.remove(),Di(null)}ir.nodes.end=s,t.before(s)}Re&&Ve(t)}),ei(!0),()=>{e&&ei(!1)}},ee),kn(()=>{ei(!0)}),o&&(ze(!0),Ve(c))}function Mi(e,t){var n=void 0,r;Rn(()=>{n!==(n=t())&&(r&&=(Un(r),null),n&&(r=zn(()=>{Pn(()=>n(e))})))})}function Ni(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||Ii.includes(r[o-1]))&&(s===r.length||Ii.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Ri(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 zi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Bi(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(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(zi)),i&&c.push(...Object.keys(i).map(zi));var l=0,u=-1;let t=e.length;for(var d=0;d{Ui(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),kn(()=>{t.disconnect()})}function Gi(e,t,n=t){var r=new WeakSet,i=!0;gt(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ki);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ki(o)}n(a),e.__value=a,Ft!==null&&r.add(Ft)}),Pn(()=>{var a=t();if(e===document.activeElement){var o=Ft;if(r.has(o))return}if(Ui(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ki(s),n(a))}e.__value=a,i=!1}),Wi(e)}function Ki(e){return`__value`in e?e.__value:e.value}var qi=Symbol(`class`),Ji=Symbol(`style`),Yi=Symbol(`is custom element`),Xi=Symbol(`is html`),Zi=_e?`link`:`LINK`,Qi=_e?`input`:`INPUT`,$i=_e?`option`:`OPTION`,ea=_e?`select`:`SELECT`,ta=_e?`progress`:`PROGRESS`;function na(e){if(Re){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;W(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;W(e,`checked`,null),e.checked=r}}};e[he]=n,et(n),mt()}}function ra(e,t){var n=ca(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==ta)||(e.value=t??``)}function ia(e,t){var n=ca(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function aa(e,t){t?e.hasAttribute(`selected`)||e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}function W(e,t,n,r){var i=ca(e);Re&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Zi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ue]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ua(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function oa(e,t,n,r,i=!1,a=!1){if(Re&&i&&e.nodeName===Qi){var o=e;(o.type===`checkbox`?`defaultChecked`:`defaultValue`)in n||na(o)}var s=ca(e),c=s[Yi],l=!s[Xi];let u=Re&&c;u&&ze(!1);var d=t||{},f=e.nodeName===$i;for(var p in t)p in n||(n[p]=null);n.class?n.class=Fi(n.class):(r||n[qi])&&(n.class=null),n[Ji]&&(n.style??=null);var m=ua(e);if(e.nodeName===Qi&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==d.type||h===void 0&&e.hasAttribute(`type`))&&(d.type=h,W(e,`type`,h,a))}for(let i in n){let o=n[i];if(f&&i===`value`&&o==null){e.value=e.__value=``,d[i]=o;continue}if(i===`class`){U(e,e.namespaceURI===`http://www.w3.org/1999/xhtml`,o,r,t?.[qi],n[qi]),d[i]=o,d[qi]=n[qi];continue}if(i===`style`){Hi(e,o,t?.[Ji],n[Ji]),d[i]=o,d[Ji]=n[Ji];continue}var g=d[i];if(!(o===g&&!(o===void 0&&e.hasAttribute(i)))){d[i]=o;var _=i[0]+i[1];if(_!==`$$`)if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=kr(r);if(Dr(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(o!=null)continue;e.removeEventListener(r,d[n],t),d[n]=null}if(v)L(r,e,o),Hr([r]);else if(o!=null){function a(e){d[i].call(this,e)}d[n]=Br(r,e,a,t)}}else if(i===`style`)W(e,i,o);else if(i===`autofocus`)dt(e,!!o);else if(!c&&(i===`__value`||i===`value`&&o!=null))e.value=e.__value=o;else if(i===`selected`&&f)aa(e,o);else{var y=i;l||(y=Mr(y));var b=y===`defaultValue`||y===`defaultChecked`;if(o==null&&!c&&!b)if(s[i]=null,y===`value`||y===`checked`){let n=e,r=t===void 0;if(y===`value`){let e=n.defaultValue;n.removeAttribute(y),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(y),n.defaultChecked=e,n.checked=r?e:!1}}else e.removeAttribute(i);else b||m.includes(y)&&(c||typeof o!=`string`)?(e[y]=o,y in s&&(s[y]=Ae)):typeof o!=`function`&&W(e,y,o,a)}}}return u&&ze(!0),d}function sa(e,t,n=[],r=[],i=[],a,o=!1,s=!1){xt(i,n,r,n=>{var r=void 0,i={},c=e.nodeName===ea,l=!1;if(Rn(()=>{var u=t(...n.map(I)),d=oa(e,r,u,a,o,s);l&&c&&`value`in u&&Ui(e,u.value);for(let e of Object.getOwnPropertySymbols(i))u[e]||Un(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var f=u[t];t.description===`@attach`&&(!r||f!==r[t])&&(i[t]&&Un(i[t]),i[t]=zn(()=>Mi(e,()=>f))),d[t]=f}r=d}),c){var u=e;Pn(()=>{Ui(u,r.value,!0),Wi(u)})}l=!0})}function ca(e){return e[de]??={[Yi]:e.nodeName.includes(`-`),[Xi]:e.namespaceURI===je}}var la=new Map;function ua(e){var t=e.getAttribute(`is`)||e.nodeName,n=la.get(t);if(n)return n;la.set(t,n=[]);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.push(s);i=l(i)}return n}function da(e,t,n=t){var r=new WeakSet;gt(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=pa(e)?ma(a):a,n(a),Ft!==null&&r.add(Ft),await Cr(),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))}}}),(Re&&e.defaultValue!==e.value||Er(t)==null&&e.value)&&(n(pa(e)?ma(e.value):e.value),Ft!==null&&r.add(Ft)),In(()=>{var n=t();if(e===document.activeElement){var i=Ft;if(r.has(i))return}pa(e)&&n===ma(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function fa(e,t,n=t){gt(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Re&&e.defaultChecked!==e.checked||Er(t)==null)&&n(e.checked),In(()=>{e.checked=!!t()})}function pa(e){var t=e.type;return t===`number`||t===`range`}function ma(e){return e===``?null:+e}function ha(e,t){return e===t||e?.[ce]===t}function ga(e={},t,n,r){var i=Ye.r,a=ir;return Pn(()=>{var o,s;return In(()=>{o=s,s=r?.()||[],Er(()=>{ha(n(...s),e)||(t(e,...s),o&&ha(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&&ha(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var _a={get(e,t){if(!e.exclude.has(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return!e.exclude.has(t)&&t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))}};function va(e,t,n){return new Proxy({props:e,exclude:t},_a)}function G(e,t,n,r){var i=!0,o=(n&8)!=0,s=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>s&&i?(u??=Tt(r),I(u)):(l&&(l=!1,c=s?Er(r):r),c);let f;if(o){var p=ce in e||le in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=ut(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&we(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?Tt:Ot)(()=>(v=!1,g()));o&&I(y);var b=ir;return(function(e,t){if(arguments.length>0){let n=t?I(y):i&&o?j(e):e;return A(y,n),v=!0,c!==void 0&&(c=n),e}return $n&&v||b.f&16384?y.v:I(y)})}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var ya=new Set([`$$slots`,`$$events`,`$$legacy`,`icon`,`class`]),ba=Xr(``);function K(e,t){let n=G(t,`icon`,19,()=>[]),r=G(t,`class`,3,``),i=va(t,ya);var a=ba();sa(a,()=>({xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:r(),"aria-hidden":`true`,focusable:`false`,...i}));{let e=(t,n=f)=>{var r=Qr();H(N(r),17,n,oi,(t,n)=>{var r=O(()=>g(I(n),3));let i=()=>I(r)[0],a=()=>I(r)[1],o=()=>I(r)[2];var s=Qr();ji(N(s),i,!0,(t,n)=>{sa(t,()=>({xmlns:`http://www.w3.org/2000/svg`,...a()}));var r=Qr(),i=N(r),s=t=>{e(t,o)},c=O(()=>Array.isArray(o()));V(i,e=>{I(c)&&e(s)}),z(n,r)}),z(t,s)}),z(t,r)};e(M(a),n),T(a)}z(e,a)}var xa=Xr(``);function Sa(e){z(e,xa())}function Ca(){try{return typeof localStorage>`u`?null:localStorage}catch{return null}}function wa(e,t=null){let n=Ca();if(!n)return t;try{return n.getItem(e)??t}catch{return t}}function Ta(e,t){let n=Ca();if(n)try{n.setItem(e,String(t))}catch{}}function Ea(e){let t=Number(e);return Number.isFinite(t)?Math.min(240,Math.max(60,Math.round(t))):240}function Da(e,t,n){return Ea(Number(e)+Number(n)-Number(t))}var Oa=new class{#e=k(`system`);get theme(){return I(this.#e)}set theme(e){A(this.#e,e,!0)}#t=k(0);get tick(){return I(this.#t)}set tick(e){A(this.#t,e,!0)}init(){this.theme=wa(`gomodel_theme`,`system`),this.apply(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{this.theme===`system`&&this.tick++})}set(e){this.theme=e,Ta(`gomodel_theme`,e),this.apply(),this.tick++}toggle(){let e=[`light`,`system`,`dark`];this.set(e[(e.indexOf(this.theme)+1)%e.length])}apply(){let e=document.documentElement;this.theme===`system`?e.removeAttribute(`data-theme`):e.setAttribute(`data-theme`,this.theme)}},ka=new class{#e=k(j(240));get width(){return I(this.#e)}set width(e){A(this.#e,e,!0)}get collapsed(){return this.width===60}init(){let e=wa(`gomodel_sidebar_width`),t=wa(`gomodel_sidebar_collapsed`)===`true`;this.setWidth(e??(t?60:240))}toggle(){this.setWidth(this.collapsed?240:60,!0)}setWidth(e,t=!1){this.width=Ea(e),typeof document<`u`&&document.documentElement.style.setProperty(`--sidebar-width`,`${this.width}px`),t&&(Ta(`gomodel_sidebar_width`,this.width),Ta(`gomodel_sidebar_collapsed`,this.collapsed))}},Aa=new class{#e=k(j([]));get stack(){return I(this.#e)}set stack(e){A(this.#e,e,!0)}#t=1;opened(){let e=this.#t++;return this.stack=[...this.stack,e],e}closed(e){this.stack=this.stack.filter(t=>t!==e)}isTop(e){return this.stack.length>0&&this.stack[this.stack.length-1]===e}get openCount(){return this.stack.length}get anyOpen(){return this.stack.length>0}},ja=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],Ma=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],Na=[[`path`,{d:`M5 12h14`}],[`path`,{d:`m12 5 7 7-7 7`}]],Pa=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]],Fa=[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`}],[`path`,{d:`M16 10h.01`}],[`path`,{d:`M12 10h.01`}],[`path`,{d:`M8 10h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M8 18h.01`}]],Ia=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M16 14h.01`}],[`path`,{d:`M8 18h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M16 18h.01`}]],La=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}]],Ra=[[`path`,{d:`M13 17V9`}],[`path`,{d:`M18 17V5`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M8 17v-3`}]],za=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M18 17V9`}],[`path`,{d:`M13 17V5`}],[`path`,{d:`M8 17v-3`}]],Ba=[[`path`,{d:`M20 6 9 17l-5-5`}]],Va=[[`path`,{d:`m6 9 6 6 6-6`}]],Ha=[[`path`,{d:`m15 18-6-6 6-6`}]],Ua=[[`path`,{d:`m9 18 6-6-6-6`}]],Wa=[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`}],[`path`,{d:`m9 11 3 3L22 4`}]],Ga=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m9 12 2 2 4-4`}]],Ka=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}],[`path`,{d:`M12 18V6`}]],qa=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],Ja=[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`}]],Ya=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`}],[`path`,{d:`M21 5V8`}],[`path`,{d:`M21 12L18 17H22L19 22`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`}]],Xa=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`}]],Za=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],Qa=[[`path`,{d:`m12 14 4-4`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`}]],$a=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}],[`path`,{d:`M12 7v5l4 2`}]],eo=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 16v-4`}],[`path`,{d:`M12 8h.01`}]],to=[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],no=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],ro=[[`path`,{d:`M3 5h.01`}],[`path`,{d:`M3 12h.01`}],[`path`,{d:`M3 19h.01`}],[`path`,{d:`M8 5h13`}],[`path`,{d:`M8 12h13`}],[`path`,{d:`M8 19h13`}]],io=[[`circle`,{cx:`12`,cy:`16`,r:`1`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`}]],ao=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]],oo=[[`path`,{d:`m14 10 7-7`}],[`path`,{d:`M20 10h-6V4`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M4 14h6v6`}]],so=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],co=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],lo=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],uo=[[`path`,{d:`M12 22v-5`}],[`path`,{d:`M15 8V2`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`}],[`path`,{d:`M9 8V2`}]],fo=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],po=[[`path`,{d:`M12 2v10`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`}]],mo=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],ho=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],go=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],_o=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],vo=[[`path`,{d:`m10.852 14.772-.383.923`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`}],[`path`,{d:`m13.148 9.228.383-.923`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`}],[`path`,{d:`m14.772 10.852.923-.383`}],[`path`,{d:`m14.772 13.148.923.383`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`}],[`path`,{d:`M6 18h.01`}],[`path`,{d:`M6 6h.01`}],[`path`,{d:`m9.228 10.852-.923-.383`}],[`path`,{d:`m9.228 13.148-.923.383`}]],yo=[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`}]],bo=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]],xo=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],So=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}],[`path`,{d:`m9 12 2 2 4-4`}]],Co=[[`path`,{d:`m2 2 20 20`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`}]],wo=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}]],To=[[`path`,{d:`m18 14 4 4-4 4`}],[`path`,{d:`m18 2 4 4-4 4`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`}]],Eo=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],Do=[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],Oo=[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`}],[`circle`,{cx:`12`,cy:`14`,r:`8`}]],ko=[[`path`,{d:`M10 11v6`}],[`path`,{d:`M14 11v6`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]],Ao=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]],jo=[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}],[`circle`,{cx:`12`,cy:`7`,r:`4`}]],Mo=[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`}]],No=[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`}],[`path`,{d:`m14 7 3 3`}],[`path`,{d:`M5 6v4`}],[`path`,{d:`M19 14v4`}],[`path`,{d:`M10 2v2`}],[`path`,{d:`M7 8H3`}],[`path`,{d:`M21 16h-4`}],[`path`,{d:`M11 3H9`}]],Po=[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`}]],Fo=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],Io=R(``),Lo=R(`
        `,1);function Ro(e,t){E(t,!0);let n=G(t,`compact`,3,!1),r=[{value:`light`,icon:Eo,label:`Light theme`},{value:`system`,icon:so,label:`System theme`},{value:`dark`,icon:co,label:`Dark theme`}],i=O(()=>r.find(e=>e.value===Oa.theme)||r[1]),a=O(()=>`Change theme (currently `+I(i).label+`)`);var o=Lo(),s=N(o);let c;H(s,21,()=>r,e=>e.value,(e,t)=>{var n=Io();let r;K(M(n),{get icon(){return I(t).icon},class:`theme-icon`}),T(n),F(()=>{r=U(n,1,`theme-btn svelte-1keql7b`,null,r,{active:Oa.theme===I(t).value}),W(n,`aria-pressed`,Oa.theme===I(t).value),W(n,`title`,I(t).label),W(n,`aria-label`,I(t).label)}),L(`click`,n,()=>Oa.set(I(t).value)),z(e,n)}),T(s);var l=P(s,2);let u;K(M(l),{get icon(){return I(i).icon},class:`theme-icon`}),T(l),F(()=>{c=U(s,1,`theme-toggle svelte-1keql7b`,null,c,{"is-compact":n()}),u=U(l,1,`theme-toggle-mobile svelte-1keql7b`,null,u,{"is-compact":n()}),W(l,`title`,I(a)),W(l,`aria-label`,I(a))}),L(`click`,l,()=>Oa.toggle()),z(e,o),D()}Hr([`click`]);function zo(){return typeof window>`u`?`/`:window.GOMODEL_BASE_PATH||`/`}function Bo(e){let t=zo();return!e||e.charAt(0)!==`/`||e.indexOf(`//`)===0||t===`/`||e===t||e.indexOf(t+`/`)===0?e:t+e}function Vo(e){let t=zo();return t===`/`||!e?e:e===t?`/`:e.indexOf(t+`/`)===0?e.slice(t.length)||`/`:e}function Ho(){return typeof window>`u`?``:window.GOMODEL_VERSION||``}function Uo(){return typeof window>`u`?!1:window.GOMODEL_DEMO_MODE===!0}var Wo=[`overview`,`usage`,`budgets`,`rate-limits`,`models`,`workflows`,`audit-logs`,`guardrails`,`mcp-servers`,`providers-config`,`auth-keys`,`settings`];function Go(e){return e.startsWith(`/admin/static/`)?`/`+e.slice(14).replace(/^\/+/,``):e}function Ko(e){let t=Go(Vo(e)).replace(/\/$/,``).replace(`/admin/dashboard`,``).replace(/^\//,``).split(`/`),n=t[0];n===`audit`&&(n=`audit-logs`);let r=t[1]||null;return n===`settings`&&r===`guardrails`?{page:`guardrails`,sub:null}:(n=Wo.includes(n)?n:`overview`,{page:n,sub:r})}var qo=new class{#e=k(`overview`);get page(){return I(this.#e)}set page(e){A(this.#e,e,!0)}#t=k(null);get sub(){return I(this.#t)}set sub(e){A(this.#t,e,!0)}init(){let{page:e,sub:t}=Ko(window.location.pathname);this.page=e,this.sub=t,window.addEventListener(`popstate`,()=>{let{page:e,sub:t}=Ko(window.location.pathname);this.page=e,this.sub=t})}navigate(e,t=null){let n=t?`/`+t:``;history.pushState(null,``,Bo(`/admin/dashboard/`+e+n)),this.page=e,this.sub=t}},Jo=`gomodel_api_key`;function Yo(e){let t=String(e||``).trim();if(/^Bearer\s*$/i.test(t))return``;let n=t.match(/^Bearer\s+(.+)$/i);return n?n[1].trim():t}var q=new class{#e=k(``);get apiKey(){return I(this.#e)}set apiKey(e){A(this.#e,e,!0)}#t=k(!1);get needsAuth(){return I(this.#t)}set needsAuth(e){A(this.#t,e,!0)}#n=k(!1);get authError(){return I(this.#n)}set authError(e){A(this.#n,e,!0)}#r=k(``);get authErrorMessage(){return I(this.#r)}set authErrorMessage(e){A(this.#r,e,!0)}#i=k(!1);get dialogOpen(){return I(this.#i)}set dialogOpen(e){A(this.#i,e,!0)}#a=k(0);get generation(){return I(this.#a)}set generation(e){A(this.#a,e,!0)}#o=k(0);get refreshTick(){return I(this.#o)}set refreshTick(e){A(this.#o,e,!0)}init(){try{this.apiKey=Yo(localStorage.getItem(Jo)||``)}catch{this.apiKey=``}}hasApiKey(){return Yo(this.apiKey)!==``}save(){this.apiKey=Yo(this.apiKey);try{localStorage.setItem(Jo,this.apiKey)}catch{}}openDialog(){this.dialogOpen=!0}closeDialog(){this.dialogOpen=!1}submit(){let e=Yo(this.apiKey);return e?(this.apiKey=e,this.save(),this.generation++,this.authError=!1,this.authErrorMessage=``,this.needsAuth=!1,this.closeDialog(),this.refresh(),!0):(this.apiKey=``,this.authError=!0,this.authErrorMessage=``,this.needsAuth=!0,this.openDialog(),!1)}refresh(){this.refreshTick++}handleUnauthorized(e,t=``){return typeof e==`number`&&e{r[e.type]=e.value}),r.year+`-`+r.month+`-`+r.day}formatTimestampInTimeZone(e,t){if(e==null)return`-`;let n=new Date(e);if(Number.isNaN(n.getTime()))return`-`;let r=os(`en-CA`,{timeZone:ss(t)?t:ns,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(n),i={};return r.forEach(e=>{i[e.type]=e.value}),i.year+`-`+i.month+`-`+i.day+` `+i.hour+`:`+i.minute+`:`+i.second}formatTimestamp(e){return this.formatTimestampInTimeZone(e,this.effectiveTimezone())}currentDateKey(e){return this.dateKeyInTimeZone(e||new Date,this.effectiveTimezone())}dateKeyToDate(e){return Zo(e)}dateToDateKey(e){return Qo(e)}addDaysToDateKey(e,t){return $o(e,t)}todayDate(){return this.dateKeyToDate(this.currentDateKey())}startOfMonthDate(e){let t=e instanceof Date?e:this.todayDate();return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1))}timeZoneOffsetLabel(e,t){let n=ss(e)?e:ns;try{let e=os(`en-US`,{timeZone:n,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`,timeZoneName:`longOffset`}).formatToParts(t||new Date).find(e=>e.type===`timeZoneName`);if(!e||!e.value)return`UTC+00:00`;let r=e.value.replace(`GMT`,`UTC`);return r===`UTC`?`UTC+00:00`:r}catch{return`UTC+00:00`}}timeZoneOffsetMinutes(e,t){let n=/^UTC([+-])(\d{2}):(\d{2})$/.exec(this.timeZoneOffsetLabel(e,t));if(!n)return 0;let r=Number(n[2])*60+Number(n[3]);return n[1]===`-`?-r:r}timeZoneOptionLabel(e,t){return e+` (`+this.timeZoneOffsetLabel(e,t)+`)`}detectedTimeZoneLabel(){return this.timeZoneOptionLabel(this.detectedTimezone)}effectiveTimeZoneLabel(){return this.timeZoneOptionLabel(this.effectiveTimezone())}ensureOptions(){if(this.optionsLoaded)return;let e=new Date,t=[];try{typeof Intl.supportedValuesOf==`function`&&(t=Intl.supportedValuesOf(`timeZone`))}catch{t=[]}[ns,this.detectedTimezone,this.override].forEach(e=>{e&&t.indexOf(e)===-1&&ss(e)&&t.push(e)}),t=t.filter(e=>ss(e)),t.sort((t,n)=>{let r=this.timeZoneOffsetMinutes(t,e)-this.timeZoneOffsetMinutes(n,e);return r===0?t.localeCompare(n):r}),this.options=t.map(t=>({value:t,label:this.timeZoneOptionLabel(t,e)})),this.optionsLoaded=!0}saveOverride(){let e=Ca();if(e)if(this.override&&ss(this.override))try{e.setItem(rs,this.override)}catch{}else{try{e.removeItem(rs)}catch{}this.override=``}this.optionsLoaded=!1,this.ensureOptions()}clearOverride(){let e=Ca();if(e)try{e.removeItem(rs)}catch{}this.override=``}calendarTimeZoneText(){let e=this.override?`manual override`:`auto-detected`;return`Activity grouped by `+this.effectiveTimeZoneLabel()+` (`+e+`)`}};function ds(e,t){let n=e&&typeof e==`object`&&e.error&&e.error.message;return(typeof n==`string`?n.trim():``)||t}function fs(e,t){let n=e&&e.data;if(n&&typeof n==`object`){let e=[n.message,n.error,n.error&&typeof n.error==`object`?n.error.message:null];for(let t of e)if(typeof t==`string`&&t.trim())return t.trim()}return t}function ps(){let e={"Content-Type":`application/json`},t=Yo(q.apiKey);return t&&(e.Authorization=`Bearer `+t),e[`X-GoModel-Timezone`]=us.effectiveTimezone(),e}function ms(e,t={}){return fetch(Bo(e),{...t,headers:{...ps(),...t.headers||{}}})}async function hs(e,t,{label:n=e,parse:r=!0}={}){let i=q.generation,a=await ms(e,t);if(a.status===401)return q.handleUnauthorized(i),{ok:!1,stale:ie.trim()).filter(Boolean);return e.length>0?e:bs}cacheVisible(){if(this.flag(`CACHE_ENABLED`)!==``)return this.booleanFlag(`CACHE_ENABLED`,!1);let e=this.flag(`REDIS_URL`),t=this.flag(`SEMANTIC_CACHE_ENABLED`);return e===``&&t===``||this.booleanFlag(`REDIS_URL`,!1)||this.booleanFlag(`SEMANTIC_CACHE_ENABLED`,!1)}auditVisible(){return this.booleanFlag(`LOGGING_ENABLED`,!0)}usageVisible(){return this.booleanFlag(`USAGE_ENABLED`,!0)}budgetsVisible(){return this.booleanFlag(`BUDGETS_ENABLED`,!0)}rateLimitsVisible(){return this.booleanFlag(`RATE_LIMITS_ENABLED`,!0)}guardrailsVisible(){return this.booleanFlag(`GUARDRAILS_ENABLED`,!0)}mcpVisible(){return this.booleanFlag(`MCP_ENABLED`,!0)}liveLogsVisible(){return this.booleanFlag(`DASHBOARD_LIVE_LOGS_ENABLED`,!0)}fetch(){return this.#n||=this.#r().finally(()=>{this.#n=null}),this.#n}async ensureLoaded(){if(this.#n){await this.#n;return}this.loaded||await this.fetch()}async#r(){let e=typeof AbortController==`function`?new AbortController:null,t=e?setTimeout(()=>e.abort(),1e4):null;try{let t=await gs(`/admin/runtime/config`,{label:`dashboard config`,signal:e?e.signal:void 0});if(t.stale)return;if(!t.ok){this.config={},this.loaded=!1;return}let n=t.data,r={};for(let e of ys)n&&typeof n==`object`&&!Array.isArray(n)&&n[e]!==void 0&&n[e]!==null&&(r[e]=String(n[e]).trim());this.config=r,this.loaded=!0}catch(e){console.error(`Failed to fetch dashboard config:`,e),this.config={},this.loaded=!1}finally{t!==null&&clearTimeout(t)}}},Ss=[{page:`overview`,label:`Overview`,icon:no},{page:`providers-config`,label:`Providers`,icon:vo},{page:`models`,label:`Models`,icon:Pa},{page:`audit-logs`,label:`Audit Logs`,icon:$a},{page:`usage`,label:`Usage`,icon:za},{page:`budgets`,label:`Budgets`,icon:Mo,visible:()=>xs.budgetsVisible()},{page:`rate-limits`,label:`Rate Limits`,icon:Qa,visible:()=>xs.rateLimitsVisible()},{page:`auth-keys`,label:`API Keys`,icon:to},{page:`workflows`,label:`Workflows`,icon:Po},{page:`guardrails`,label:`Guardrails (experimental)`,icon:So,visible:()=>xs.guardrailsVisible()},{page:`mcp-servers`,label:`MCP Servers`,icon:uo,visible:()=>xs.mcpVisible()},{page:`settings`,label:`Settings`,icon:xo}],Cs=R(` `),ws=R(`
        `),Ts=R(` `,1);function Es(e,t){E(t,!0);let n=O(()=>Ss.filter(e=>!e.visible||e.visible())),r=k(null),i=0,a=0,o=!1;function s(e){e.button===0&&(e.preventDefault(),A(r,e.pointerId,!0),i=e.clientX,a=ka.width,o=!1,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`sidebar-resizing`))}function c(e){e.pointerId===I(r)&&(!o&&Math.abs(e.clientX-i)<=4||(o=!0,ka.setWidth(Da(a,i,e.clientX))))}function l(e){I(r)===null||e.pointerId!==void 0&&e.pointerId!==I(r)||(A(r,null),document.body.classList.remove(`sidebar-resizing`),ka.setWidth(ka.width,!0))}function u(){if(o){o=!1;return}ka.toggle()}function d(e){let t;if(e.key===`ArrowLeft`)t=ka.width-12;else if(e.key===`ArrowRight`)t=ka.width+12;else if(e.key===`Home`)t=60;else if(e.key===`End`)t=240;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),ka.toggle();return}else return;e.preventDefault(),ka.setWidth(t,!0)}var f=Ts(),p=N(f);let m;var h=M(p),g=M(h);Sa(M(g),{}),T(g),Ue(4),T(h);var _=P(h,2);H(_,21,()=>I(n),e=>e.page,(e,t)=>{var n=Cs();let r;var i=M(n);K(i,{get icon(){return I(t).icon},class:`nav-icon`});var a=P(i,2),o=M(a,!0);T(a),T(n),F(e=>{W(n,`href`,e),r=U(n,1,`nav-item svelte-1nwtzae`,null,r,{active:qo.page===I(t).page}),W(n,`title`,I(t).label),B(o,I(t).label)},[()=>Bo(`/admin/dashboard/`+I(t).page)]),L(`click`,n,e=>{e.preventDefault(),qo.navigate(I(t).page)}),z(e,n)}),T(_);var v=P(_,2),y=M(v);Ro(y,{get compact(){return ka.collapsed}});var b=P(y,2),x=e=>{var t=ws(),n=M(t),r=M(n);K(r,{get icon(){return io},class:`api-key-open-icon`});var i=P(r,2),a=M(i,!0);T(i),T(n),T(t),F(()=>{W(n,`aria-label`,q.needsAuth?`Enter API key`:`Change API key`),B(a,q.needsAuth?`Enter API key`:`Change API key`)}),L(`click`,n,()=>q.openDialog()),z(e,t)},S=O(()=>q.needsAuth||q.hasApiKey());V(b,e=>{I(S)&&e(x)}),T(v),T(p);var C=P(p,2);F(()=>{m=U(p,1,`sidebar svelte-1nwtzae`,null,m,{"sidebar-collapsed":ka.collapsed,"sidebar-resizing":I(r)!==null}),W(C,`aria-valuemin`,60),W(C,`aria-valuemax`,240),W(C,`aria-valuenow`,ka.width)}),L(`pointerdown`,C,s),L(`pointermove`,C,c),L(`pointerup`,C,l),Vr(`pointercancel`,C,l),Vr(`lostpointercapture`,C,l),L(`keydown`,C,d),L(`click`,C,u),z(e,f),D()}Hr([`click`,`pointerdown`,`pointermove`,`pointerup`,`keydown`]);var Ds=R(``);function Os(e,t){E(t,!0);let n=G(t,`label`,3,`Close`),r=G(t,`class`,3,``),i=G(t,`iconClass`,3,`table-icon-svg`),a=G(t,`disabled`,3,!1),o=G(t,`el`,15,null);var s=Ds();K(M(s),{get icon(){return Fo},get class(){return i()}}),T(s),ga(s,e=>o(e),()=>o()),F(()=>{U(s,1,Fi([`dialog-close-btn`,r()]),`svelte-11l1bb5`),W(s,`aria-label`,n()),s.disabled=a()}),L(`click`,s,function(...e){t.onclick?.apply(this,e)}),z(e,s),D()}Hr([`click`]);function ks(e){return t=>{let n=n=>{t.contains(n.target)||e()},r=t=>{t.key===`Escape`&&e()};return document.addEventListener(`click`,n,!0),window.addEventListener(`keydown`,r),()=>{document.removeEventListener(`click`,n,!0),window.removeEventListener(`keydown`,r)}}}function As(e=`[data-modal-autofocus]`){return t=>{let n=t.querySelector(e);n&&typeof n.focus==`function`&&n.focus()}}var js=R(`
        `,1);function Ms(e,t){E(t,!0);let n=G(t,`open`,3,!1),r=G(t,`variant`,3,`editor`),i=G(t,`closeOnBackdrop`,3,!0),a=O(()=>r()===`auth`?`auth-dialog-backdrop`:`editor-modal-backdrop`),o=O(()=>r()===`auth`?`auth-dialog-shell`:`editor-modal-shell`);An(()=>{if(!n())return;let e=Er(()=>Aa.opened()),r=n=>{n.key===`Escape`&&Aa.isTop(e)&&t.onclose?.()};return window.addEventListener(`keydown`,r),()=>{Aa.closed(e),window.removeEventListener(`keydown`,r)}});function s(e){i()&&e.target===e.currentTarget&&t.onclose?.()}var c=Qr(),l=N(c),u=e=>{var n=js(),r=N(n),i=P(r,2);gi(M(i),()=>t.children??f),T(i),Mi(i,As),F(()=>{U(r,1,Fi(I(a)),`svelte-17e0w4c`),U(i,1,Fi(I(o)),`svelte-17e0w4c`)}),L(`click`,i,s),z(e,n)};V(l,e=>{n()&&e(u)}),z(e,c),D()}Hr([`click`]);var Ns=R(``),Ps=R(``);function Fs(e,t){E(t,!0),Ms(e,{get open(){return q.dialogOpen},variant:`auth`,onclose:()=>q.closeDialog(),children:(e,t)=>{var n=Ps(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a),T(i),Os(P(i,2),{label:`Close authentication dialog`,onclick:()=>q.closeDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var s=P(r,2),c=M(s),l=M(c);K(l,{get icon(){return io},class:`auth-dialog-input-icon`});var u=P(l,2);na(u),T(c);var d=P(c,2),f=e=>{var t=Ns(),n=M(t,!0);T(t),F(()=>B(n,q.authErrorMessage||`Enter a valid API key to continue.`)),z(e,t)};V(d,e=>{q.authError&&e(f)});var p=P(d,4),m=M(p),h=M(m);K(h,{get icon(){return Ba},class:`auth-dialog-submit-icon`});var g=P(h,2),_=M(g,!0);T(g),T(m),T(p),T(s),T(n),F(()=>{B(o,q.needsAuth?`Dashboard locked`:`Change API key`),B(_,q.needsAuth?`Unlock dashboard`:`Save API key`)}),Vr(`submit`,s,e=>{e.preventDefault(),q.submit()}),da(u,()=>q.apiKey,e=>q.apiKey=e),z(e,n)},$$slots:{default:!0}}),D()}function Is(){return{open:!1,title:``,titleId:`typedConfirmationDialogTitle`,inputId:`typed-confirmation-input`,message:``,requiredText:``,value:``,confirmLabel:`Confirm`,icon:Ao,dialogClass:``,loading:!1,onConfirm:null,onClose:null}}var Ls=new class{#e=k(j(Is()));get state(){return I(this.#e)}set state(e){A(this.#e,e,!0)}#t=k(``);get error(){return I(this.#t)}set error(e){A(this.#t,e,!0)}open(e){this.error=``,this.state={...Is(),open:!0,...e||{}}}close(){let e=this.state;typeof e.onClose==`function`&&e.onClose(),this.state=Is(),this.error=``}ready(){return String(this.state.value||``).trim().toLowerCase()===String(this.state.requiredText||``).trim().toLowerCase()}inputLabel(){return`Type `+String(this.state.requiredText||``).trim()+` to confirm`}async submit(){if(!this.ready()){this.error=this.inputLabel()+`.`;return}if(typeof this.state.onConfirm==`function`){this.state.loading=!0;try{await this.state.onConfirm()}finally{this.state.loading=!1}}}},Rs=R(`

        `),zs=R(``),Bs=R(`

        `);function Vs(e,t){E(t,!0);let n=O(()=>Ls.state);Ms(e,{get open(){return I(n).open},variant:`auth`,onclose:()=>Ls.close(),children:(e,t)=>{var r=Bs(),i=M(r),a=M(i),o=M(a,!0);T(a),Os(P(a,2),{label:`Close confirmation dialog`,onclick:()=>Ls.close(),class:`auth-dialog-close`,iconClass:``}),T(i);var s=P(i,2),c=M(s),l=e=>{var t=Rs(),r=M(t,!0);T(t),F(()=>B(r,I(n).message)),z(e,t)};V(c,e=>{I(n).message&&e(l)});var u=P(c,2),d=M(u),f=M(d,!0);T(d);var p=P(d,2);na(p),T(u);var m=P(u,2),h=e=>{var t=zs(),n=M(t,!0);T(t),F(()=>B(n,Ls.error)),z(e,t)};V(m,e=>{Ls.error&&e(h)});var g=P(m,2),_=M(g),v=P(_,2),y=M(v);K(y,{get icon(){return I(n).icon},class:`form-action-icon`});var b=P(y,2),x=M(b,!0);T(b),T(v),T(g),T(s),T(r),F((e,t)=>{U(r,1,`auth-dialog ${I(n).dialogClass??``}`),W(r,`aria-labelledby`,I(n).titleId),W(a,`id`,I(n).titleId),B(o,I(n).title),W(d,`for`,I(n).inputId),B(f,e),W(p,`id`,I(n).inputId),v.disabled=t,B(x,I(n).confirmLabel)},[()=>Ls.inputLabel(),()=>I(n).loading||!Ls.ready()]),Vr(`submit`,s,e=>{e.preventDefault(),Ls.submit()}),da(p,()=>Ls.state.value,e=>Ls.state.value=e),L(`click`,_,()=>Ls.close()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var Hs=e=>e;function Us(e){let t=e-1;return t*t*t+1}function Ws(e){let t=typeof e==`string`&&e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);return t?[parseFloat(t[1]),t[2]||`px`]:[e,`px`]}function Gs(e,{delay:t=0,duration:n=400,easing:r=Hs}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}function Ks(e,{delay:t=0,duration:n=400,easing:r=Us,x:i=0,y:a=0,opacity:o=0}={}){let s=getComputedStyle(e),c=+s.opacity,l=s.transform===`none`?``:s.transform,u=c*(1-o),[d,f]=Ws(i),[p,m]=Ws(a);return{delay:t,duration:n,easing:r,css:(e,t)=>` + transform: ${l} translate(${(1-e)*d}${f}, ${(1-e)*p}${m}); + opacity: ${c-u*t}`}}function qs(e,{delay:t=0,duration:n=400,easing:r=Us,axis:i=`y`}={}){let a=getComputedStyle(e),o=+a.opacity,s=i===`y`?`height`:`width`,c=parseFloat(a[s]),l=i===`y`?[`top`,`bottom`]:[`left`,`right`],u=l.map(e=>`${e[0].toUpperCase()}${e.slice(1)}`),d=parseFloat(a[`padding${u[0]}`]),f=parseFloat(a[`padding${u[1]}`]),p=parseFloat(a[`margin${u[0]}`]),m=parseFloat(a[`margin${u[1]}`]),h=parseFloat(a[`border${u[0]}Width`]),g=parseFloat(a[`border${u[1]}Width`]);return{delay:t,duration:n,easing:r,css:e=>`overflow: hidden;opacity: ${Math.min(e*20,1)*o};${s}: ${e*c}px;padding-${l[0]}: ${e*d}px;padding-${l[1]}: ${e*f}px;margin-${l[0]}: ${e*p}px;margin-${l[1]}: ${e*m}px;border-${l[0]}-width: ${e*h}px;border-${l[1]}-width: ${e*g}px;min-${s}: 0`}}function Js(e){return--e*e*(2.70158*e+1.70158)+1}function Ys(e){let t=e-1;return t*t*t+1}var Xs=5e3,Zs=8e3,J=new class{#e=k(j([]));get toasts(){return I(this.#e)}set toasts(e){A(this.#e,e,!0)}#t=0;#n=new Map;success(e){this.#r(`success`,e,Xs)}error(e){this.#r(`error`,e,Zs)}dismiss(e){let t=this.#n.get(e);t&&(clearTimeout(t),this.#n.delete(e)),this.toasts=this.toasts.filter(t=>t.id!==e)}#r(e,t,n){let r=String(t||``).trim();if(!r)return;let i=this.toasts.find(t=>t.kind===e&&t.text===r);i&&this.dismiss(i.id);let a=++this.#t;this.toasts=[...this.toasts,{id:a,kind:e,text:r}],this.#n.set(a,setTimeout(()=>this.dismiss(a),n))}},Qs=R(`
        `),$s=R(`
        `);function ec(e,t){E(t,!0);var n=$s();H(n,21,()=>J.toasts,e=>e.id,(e,t)=>{var n=Qs();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2);T(n),F(()=>{r=U(n,1,`flash-toast svelte-1i257xg`,null,r,{"flash-toast-success":I(t).kind===`success`,"flash-toast-error":I(t).kind===`error`}),W(n,`role`,I(t).kind===`error`?`alert`:`status`),W(n,`aria-live`,I(t).kind===`error`?`assertive`:`polite`),B(a,I(t).text)}),L(`click`,o,()=>J.dismiss(I(t).id)),ki(1,n,()=>Ks,()=>({y:-24,duration:360,easing:Js})),ki(2,n,()=>Gs,()=>({duration:150})),z(e,n)}),T(n),z(e,n),D()}Hr([`click`]);var tc=R(``);function nc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{z(e,tc())},a=O(()=>Uo());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}function rc(e){return String(e||``).split(`,`).map(e=>e.trim()).filter(e=>e)}function ic(e){if(e==null||e===``)return`Not captured`;if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ac(e){return e==null||e===void 0?`-`:e.toLocaleString()}function oc(e){if(e==null)return`---`;let t=Number(e);return Number.isFinite(t)?t>0&&t<1e-4?`<$0.0001`:`$`+t.toFixed(4).replace(/(\.\d{2}\d*?)0+$/,`$1`):`---`}function sc(e){return e==null||e===void 0?`—`:`$`+e.toFixed(2)}function cc(e){return e==null||e===void 0?`—`:e<.01?`$`+e.toFixed(6):`$`+e.toFixed(4)}function lc(e){if(e==null||e===``)return`-`;let t=Number(e);if(!Number.isFinite(t))return`-`;let n=Math.abs(t),r=[{threshold:1e9,suffix:`B`},{threshold:1e6,suffix:`M`},{threshold:1e3,suffix:`K`}];for(let e=0;e=i.threshold){let n=t/i.threshold;return Math.abs(Number(n.toFixed(1)))>=1e3&&e>0&&(i=r[e-1],n=t/i.threshold),n.toFixed(1).replace(/\.0$/,``)+i.suffix}}return String(t)}function uc(e,t){let n=t==null||t===``?NaN:Number(t),r=Number.isFinite(n)?ac(n):`-`;return String(e||`Tokens`)+`: `+r}function dc(e){return e?typeof e==`string`?e:e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`):``}function fc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)}function pc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)+` `+String(t.getUTCHours()).padStart(2,`0`)+`:`+String(t.getUTCMinutes()).padStart(2,`0`)+`:`+String(t.getUTCSeconds()).padStart(2,`0`)+` UTC`}function mc(e){return String(e&&e.provider||``).trim()}function hc(e){return String(e&&e.provider_name||``).trim()||mc(e)}function gc(e,t){let n=String(t||``).trim();if(!n)return`-`;let r=hc(e);return!r||n===r||n.startsWith(r+`/`)?n:r+`/`+n}function _c(e){return gc(e,e&&e.model)}function vc(e){return gc(e,e&&e.resolved_model)}function yc(e){let t=String(e&&(e.requested_model||e.model)||``).trim();if(!e)return t;let n=String(e.data&&e.data.failover&&e.data.failover.target_model||``).trim();if(n&&n!==t)return t+` ⮕ `+n;if(e.alias_used&&e.resolved_model){let n=vc(e);if(n&&n!==`-`&&n!==t)return t+` ⮕ `+n}return t}var bc=`gomodel_date_range`,xc=1;function Sc(e){return/^[1-9]\d*$/.test(String(e??``))}var Cc=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function wc({selectedPreset:e,startKey:t,endKey:n,followsToday:r}){return e&&Sc(e)?{v:xc,mode:`preset`,days:String(e)}:e?null:es(t)&&es(n)?{v:xc,mode:`custom`,start:t,end:n,follow:r===!0}:null}function Tc(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return null}return!t||typeof t!=`object`?null:t.mode===`preset`?Sc(t.days)?{mode:`preset`,days:String(t.days)}:null:t.mode===`custom`&&es(t.start)&&es(t.end)&&t.start<=t.end?{mode:`custom`,start:t.start,end:t.end,follow:t.follow===!0}:null}function Ec(e,t,n){let r=ts(e,t);return r<1||!es(n)?{start:e,end:t}:{start:$o(n,-(r-1)),end:n}}function Dc(e,t){if(e===t)return`Today`;let[n,r,i]=e.split(`-`);return Cc[Number(r)-1]+` `+Number(i)+`, `+n}function Oc({selectedPreset:e,startKey:t,endKey:n,followsToday:r,todayKey:i}){if(e)return`Last `+e+` days`;if(!es(t)||!es(n))return``;let a=ts(t,n);return r||n===i?a===1?`Today`:`Last `+a+` days`:a===1?`1 day`:a+` days`}function kc({selectedPreset:e,startKey:t,endKey:n,todayKey:r}){if(e)return`Last `+e+` days`;let i=e=>Dc(e,r);return es(t)&&es(n)?t===n?i(t):i(t)+` – `+i(n):es(t)?i(t)+` – ...`:`Last 30 days`}var Ac=6e4,jc=new class{#e=k(j(`30`));get days(){return I(this.#e)}set days(e){A(this.#e,e,!0)}#t=k(j(`30`));get selectedPreset(){return I(this.#t)}set selectedPreset(e){A(this.#t,e,!0)}#n=k(null);get customStartDate(){return I(this.#n)}set customStartDate(e){A(this.#n,e,!0)}#r=k(null);get customEndDate(){return I(this.#r)}set customEndDate(e){A(this.#r,e,!0)}#i=k(!1);get followsToday(){return I(this.#i)}set followsToday(e){A(this.#i,e,!0)}#a=k(`daily`);get interval(){return I(this.#a)}set interval(e){A(this.#a,e,!0)}#o=k(0);get syncTick(){return I(this.#o)}set syncTick(e){A(this.#o,e,!0)}init(){this.restore(),this.syncToToday(),typeof setInterval==`function`&&setInterval(()=>this.syncToToday(),Ac)}queryStr(){return this.customStartDate&&this.customEndDate?`start_date=`+dc(this.customStartDate)+`&end_date=`+dc(this.customEndDate):`days=`+this.days}selectPreset(e){this.selectedPreset=e,this.customStartDate=null,this.customEndDate=null,this.followsToday=!1,this.days=e,this.persist()}selectStart(e){this.selectedPreset=null,this.customStartDate=e,this.customEndDate&&this.customEndDatet.category===e);return t?t.count:0}get filteredModels(){if(!this.filter)return this.models;let e=this.filter.toLowerCase();return this.models.filter(t=>(t.model?.id??``).toLowerCase().includes(e)||(t.provider_name??``).toLowerCase().includes(e)||(t.provider_type??``).toLowerCase().includes(e)||(t.selector??``).toLowerCase().includes(e)||(t.model?.owned_by??``).toLowerCase().includes(e)||(t.model?.metadata?.modes??[]).join(`,`).toLowerCase().includes(e)||(t.model?.metadata?.categories??[]).join(`,`).toLowerCase().includes(e))}},Nc=R(``);function Pc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Nc(),n=P(M(t),2);T(t),L(`click`,n,()=>q.openDialog()),z(e,t)};V(r,e=>{q.authError&&e(i)}),z(e,n),D()}Hr([`click`]);function Fc(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null}}function Ic(){return{summary:{total_hits:0,exact_hits:0,semantic_hits:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_saved_cost:null},daily:[]}}var Lc=new class{#e=k(j(Fc()));get summary(){return I(this.#e)}set summary(e){A(this.#e,e,!0)}#t=k(j([]));get daily(){return I(this.#t)}set daily(e){A(this.#t,e,!0)}#n=k(j(Ic()));get cacheOverview(){return I(this.#n)}set cacheOverview(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=null;#a=null;cacheAnalyticsEnabled(){return xs.cacheVisible()}async fetchUsage(){this.#i&&this.#i.abort();let e=new AbortController;this.#i=e,this.loading=!0;try{let t=jc.queryStr()+`&interval=`+jc.interval,[n,r]=await Promise.all([gs(`/admin/usage/summary?`+t,{label:`usage summary`,signal:e.signal}),gs(`/admin/usage/daily?`+t,{label:`usage daily`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.summary=Fc(),this.daily=[],this.cacheOverview=Ic();return}this.summary=n.data||Fc(),this.daily=Array.isArray(r.data)?r.data:[]}catch(e){if(vs(e))return;console.error(`Failed to fetch usage:`,e),this.summary=Fc(),this.daily=[]}finally{this.#i===e&&(this.#i=null,this.loading=!1)}}async fetchCacheOverview(e=``){if(await xs.ensureLoaded(),!this.cacheAnalyticsEnabled()){this.cacheOverview=Ic();return}this.#a&&this.#a.abort();let t=new AbortController;this.#a=t;try{let n=await gs(`/admin/cache/overview?`+(jc.queryStr()+`&interval=`+jc.interval+e),{label:`cache overview`,signal:t.signal});if(n.stale||t.signal.aborted)return;if(!n.ok){this.cacheOverview=Ic();return}let r=n.data&&typeof n.data==`object`?n.data:Ic();r.summary||=Ic().summary,Array.isArray(r.daily)||(r.daily=[]),this.cacheOverview=r}catch(e){if(vs(e))return;console.error(`Failed to fetch cache overview:`,e),this.cacheOverview=Ic()}finally{this.#a===t&&(this.#a=null)}}},Rc=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function zc(e,t){let n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return Rc[n.getUTCMonth()]+` `+n.getUTCFullYear()}function Bc(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth()+t,a=new Date(Date.UTC(r,i,1)),o=new Date(Date.UTC(r,i+1,0)),s=(a.getUTCDay()+6)%7,c=[],l=new Date(Date.UTC(r,i,0));for(let e=s-1;e>=0;e--){let t=l.getUTCDate()-e,a=new Date(Date.UTC(r,i-1,t));c.push({day:t,date:a,current:!1,key:`p-`+n(a)})}for(let e=1;e<=o.getUTCDate();e++){let t=new Date(Date.UTC(r,i,e));c.push({day:e,date:t,current:!0,key:`c-`+n(t)})}let u=42-c.length;for(let e=1;e<=u;e++){let t=new Date(Date.UTC(r,i+1,e));c.push({day:e,date:t,current:!1,key:`n-`+n(t)})}return c}function Vc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return n&&r.getTime()>n.getTime()?e:r}function Hc(e,t){return e.getUTCFullYear()===t.getUTCFullYear()&&e.getUTCMonth()===t.getUTCMonth()}var Uc=R(``),Wc=R(``),Gc=R(``),Kc=R(`
        MoTuWeThFrSaSu
        `);function qc(e,t){E(t,!0);let n=G(t,`offset`,3,0),r=O(()=>Bc(t.calendarMonth,n(),e=>us.dateToDateKey(e))),i=O(()=>Hc(t.calendarMonth,us.todayDate())),a=e=>us.dateToDateKey(e.date),o=e=>a(e)>us.currentDateKey(),s=e=>e.current&&a(e)===us.currentDateKey();function c(e,t){let n=t===`start`?jc.rangeStart():jc.rangeEnd();return e.current&&!!n&&a(e)===us.dateToDateKey(n)}function l(e){let t=jc.rangeStart(),n=jc.rangeEnd();return!e.current||!t||!n?!1:a(e)>=us.dateToDateKey(t)&&a(e)<=us.dateToDateKey(n)}var u=Kc(),d=M(u),f=M(d);let p;var m=P(f,2),h=M(m,!0);T(m);var g=P(m,2),_=e=>{z(e,Uc())},v=e=>{var n=Wc();F(()=>n.disabled=I(i)),L(`click`,n,function(...e){t.onnext?.apply(this,e)}),z(e,n)};V(g,e=>{n()===-1?e(_):e(v,-1)}),T(d);var y=P(d,4);H(y,21,()=>I(r),e=>e.key,(e,n)=>{var r=Gc(),i=M(r,!0);T(r),F((e,t)=>{U(r,1,e,`svelte-g7ga4u`),r.disabled=t,B(i,I(n).day)},[()=>Fi([`dp-day`,{"other-month":!I(n).current,today:s(I(n)),"range-start":c(I(n),`start`),"range-end":c(I(n),`end`),"in-range":l(I(n)),disabled:o(I(n))}]),()=>o(I(n))||!I(n).current]),L(`click`,r,()=>t.onselect?.(I(n))),z(e,r)}),T(y),T(u),F(e=>{p=U(f,1,`dp-nav-btn svelte-g7ga4u`,null,p,{"dp-nav-prev-mobile":n()!==-1}),B(h,e)},[()=>zc(t.calendarMonth,n())]),L(`click`,f,function(...e){t.onprev?.apply(this,e)}),z(e,u),D()}Hr([`click`]);var Jc=R(``),Yc=R(`
        `),Xc=Xr(``),Zc=Xr(``),Qc=R(`
        `),$c=R(`
        `);function el(e,t){E(t,!0);let n=[`3`,`7`,`14`,`30`,`90`],r=k(!1),i=k(`start`),a=k(j(new Date)),o=k(j({show:!1,x:0,y:0}));function s(){A(r,!I(r)),I(r)&&(jc.syncToToday(),A(a,us.startOfMonthDate(jc.customEndDate||us.todayDate()),!0),A(i,`start`))}function c(){A(r,!1),A(o,{show:!1,x:0,y:0},!0)}let l=jc.syncTick;An(()=>{let e=jc.syncTick;e!==l&&(l=e,t.onchange?.())});function u(e){jc.selectPreset(e),A(i,`start`),t.onchange?.(),c()}let d=()=>A(a,Vc(I(a),-1),!0),f=()=>A(a,Vc(I(a),1,us.startOfMonthDate(us.todayDate())),!0);function p(e){let n=new Date(e.date);if(I(i)===`start`){jc.selectStart(n),A(i,`end`),t.onchange?.();return}jc.selectEnd(n),A(i,`start`),t.onchange?.(),c()}var m=$c(),h=M(m),g=P(M(h),2),_=M(g,!0);T(g);var v=P(g,2);let y;T(h);var b=P(h,2),x=e=>{var t=Yc(),r=M(t);H(r,20,()=>n,e=>e,(e,t)=>{var n=Jc();let r;var i=M(n);T(n),F(()=>{r=U(n,1,`preset-btn svelte-ax7ma4`,null,r,{active:jc.selectedPreset===t}),B(i,`Last ${t??``} days`)}),L(`click`,n,()=>u(t)),z(e,n)}),T(r);var i=P(r,2);H(i,20,()=>[-1,0],e=>e,(e,t)=>{qc(e,{get calendarMonth(){return I(a)},get offset(){return t},onprev:d,onnext:f,onselect:p})}),T(i),T(t),L(`mousemove`,i,e=>A(o,{show:!0,x:e.clientX,y:e.clientY},!0)),Vr(`mouseleave`,i,()=>A(o,{show:!1,x:0,y:0},!0)),z(e,t)};V(b,e=>{I(r)&&e(x)});var S=P(b,2),C=e=>{var t=Qc(),n=M(t),r=e=>{z(e,Xc())},a=e=>{z(e,Zc())};V(n,e=>{I(i)===`start`?e(r):e(a,-1)});var s=P(n,2),c=M(s,!0);T(s),T(t),F(()=>{Hi(t,`left:${I(o).x??``}px;top:${I(o).y??``}px`),B(c,I(i)===`end`?`Select end date`:`Select start date`)}),z(e,t)};V(S,e=>{I(o).show&&e(C)}),T(m),Mi(m,()=>I(r)?ks(c):void 0),F((e,t)=>{W(h,`title`,e),B(_,t),y=U(v,0,`date-picker-chevron svelte-ax7ma4`,null,y,{open:I(r)})},[()=>jc.dateRangeSpanLabel(),()=>jc.dateRangeLabel()]),L(`click`,h,s),z(e,m),D()}Hr([`click`,`mousemove`]);function tl(e){return e+.5|0}var nl=(e,t,n)=>Math.max(Math.min(e,n),t);function rl(e){return nl(tl(e*2.55),0,255)}function il(e){return nl(tl(e*255),0,255)}function al(e){return nl(tl(e/2.55)/100,0,1)}function ol(e){return nl(tl(e*100),0,100)}var sl={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},cl=[...`0123456789ABCDEF`],ll=e=>cl[e&15],ul=e=>cl[(e&240)>>4]+cl[e&15],dl=e=>(e&240)>>4==(e&15),fl=e=>dl(e.r)&&dl(e.g)&&dl(e.b)&&dl(e.a);function pl(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&sl[e[1]]*17,g:255&sl[e[2]]*17,b:255&sl[e[3]]*17,a:t===5?sl[e[4]]*17:255}:(t===7||t===9)&&(n={r:sl[e[1]]<<4|sl[e[2]],g:sl[e[3]]<<4|sl[e[4]],b:sl[e[5]]<<4|sl[e[6]],a:t===9?sl[e[7]]<<4|sl[e[8]]:255})),n}var ml=(e,t)=>e<255?t(e):``;function hl(e){var t=fl(e)?ll:ul;return e?`#`+t(e.r)+t(e.g)+t(e.b)+ml(e.a,t):void 0}var gl=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function _l(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function vl(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function yl(e,t,n){let r=_l(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function bl(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=bl(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function Sl(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(il)}function Cl(e,t,n){return Sl(_l,e,t,n)}function wl(e,t,n){return Sl(yl,e,t,n)}function Tl(e,t,n){return Sl(vl,e,t,n)}function El(e){return(e%360+360)%360}function Dl(e){let t=gl.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?rl(+t[5]):il(+t[5]));let i=El(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?wl(i,a,o):t[1]===`hsv`?Tl(i,a,o):Cl(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function Ol(e,t){var n=xl(e);n[0]=El(n[0]+t),n=Cl(n),e.r=n[0],e.g=n[1],e.b=n[2]}function kl(e){if(!e)return;let t=xl(e),n=t[0],r=ol(t[1]),i=ol(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${al(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var Al={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},jl={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function Ml(){let e={},t=Object.keys(jl),n=Object.keys(Al),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var Nl;function Pl(e){Nl||(Nl=Ml(),Nl.transparent=[0,0,0,0]);let t=Nl[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var Fl=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Il(e){let t=Fl.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?rl(e):nl(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?rl(r):nl(r,0,255)),i=255&(t[4]?rl(i):nl(i,0,255)),a=255&(t[6]?rl(a):nl(a,0,255)),{r,g:i,b:a,a:n}}}function Ll(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${al(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var Rl=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,zl=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Bl(e,t,n){let r=zl(al(e.r)),i=zl(al(e.g)),a=zl(al(e.b));return{r:il(Rl(r+n*(zl(al(t.r))-r))),g:il(Rl(i+n*(zl(al(t.g))-i))),b:il(Rl(a+n*(zl(al(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Vl(e,t,n){if(e){let r=xl(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=Cl(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Hl(e,t){return e&&Object.assign(t||{},e)}function Ul(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=il(e[3]))):(t=Hl(e,{r:0,g:0,b:0,a:1}),t.a=il(t.a)),t}function Wl(e){return e.charAt(0)===`r`?Il(e):Dl(e)}var Gl=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Ul(t):n===`string`&&(r=pl(t)||Pl(t)||Wl(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Hl(this._rgb);return e&&(e.a=al(e.a)),e}set rgb(e){this._rgb=Ul(e)}rgbString(){return this._valid?Ll(this._rgb):void 0}hexString(){return this._valid?hl(this._rgb):void 0}hslString(){return this._valid?kl(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Bl(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=il(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=tl(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Vl(this._rgb,2,e),this}darken(e){return Vl(this._rgb,2,-e),this}saturate(e){return Vl(this._rgb,1,e),this}desaturate(e){return Vl(this._rgb,1,-e),this}rotate(e){return Ol(this._rgb,e),this}};function Kl(){}var ql=(()=>{let e=0;return()=>e++})();function Jl(e){return e==null}function Yl(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function Xl(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function Zl(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function Ql(e,t){return Zl(e)?e:t}function $l(e,t){return e===void 0?t:e}var eu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,tu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function nu(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function ru(e,t,n,r){let i,a,o;if(Yl(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function fu(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function pu(e){let t=fu(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function mu(e,t){return(du[t]||(du[t]=pu(t)))(e)}function hu(e){return e.charAt(0).toUpperCase()+e.slice(1)}var gu=e=>e!==void 0,_u=e=>typeof e==`function`,vu=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function yu(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var bu=Math.PI,xu=2*bu,Su=xu+bu,Cu=1/0,wu=bu/180,Tu=bu/2,Eu=bu/4,Du=bu*2/3,Ou=Math.log10,ku=Math.sign;function Au(e,t,n){return Math.abs(e-t)e-t).pop(),t}function Nu(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Pu(e){return!Nu(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Fu(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Iu(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Ju(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var Yu=(e,t,n,r)=>Ju(e,n,r?r=>{let i=e[r][t];return ie[r][t]Ju(e,n,r=>e[r][t]>=n);function Zu(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+hu(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function ed(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(Qu.forEach(t=>{delete e[t]}),delete e._chartjs)}function td(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var nd=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function rd(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,nd.call(window,()=>{r=!1,e.apply(t,n)}))}}function id(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var ad=e=>e===`start`?`left`:e===`end`?`right`:`center`,od=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,sd=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function cd(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(Yu(c,u,d).lo,n?r:Yu(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!Jl(e[s.axis]));i-=Math.max(0,e)}i=Gu(i,0,r-1)}if(m){let e=Math.max(Yu(c,o.axis,f,!0).hi+1,n?0:Yu(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!Jl(e[s.axis]));e+=Math.max(0,t)}a=Gu(e,i,r)-i}else a=r-i}return{start:i,count:a}}function ld(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var ud=e=>e===0||e===1,dd=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*xu/n)),fd=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*xu/n)+1,pd={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Tu)+1,easeOutSine:e=>Math.sin(e*Tu),easeInOutSine:e=>-.5*(Math.cos(bu*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>ud(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>ud(e)?e:dd(e,.075,.3),easeOutElastic:e=>ud(e)?e:fd(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return ud(e)?e:e<.5?.5*dd(e*2,t,n):.5+.5*fd(e*2-1,t,n)},easeInBack(e){return e*e*(2.70158*e-1.70158)},easeOutBack(e){return--e*e*(2.70158*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-pd.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?pd.easeInBounce(e*2)*.5:pd.easeOutBounce(e*2-1)*.5+.5};function md(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function hd(e){return md(e)?e:new Gl(e)}function gd(e){return md(e)?e:new Gl(e).saturate(.5).darken(.1).hexString()}var _d=[`x`,`y`,`borderWidth`,`radius`,`tension`],vd=[`color`,`borderColor`,`backgroundColor`];function yd(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:vd},numbers:{type:`number`,properties:_d}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function bd(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var xd=new Map;function Sd(e,t){t||={};let n=e+JSON.stringify(t),r=xd.get(n);return r||(r=new Intl.NumberFormat(e,t),xd.set(n,r)),r}function Cd(e,t,n){return Sd(t,n).format(e)}var wd={values(e){return Yl(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Td(e,n)}let o=Ou(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),Cd(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(Ou(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?wd.numeric.call(this,e,t,n):``}};function Td(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Ed={formatters:wd};function Dd(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Ed.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var Od=Object.create(null),kd=Object.create(null);function Ad(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>gd(t.backgroundColor),this.hoverBorderColor=(e,t)=>gd(t.borderColor),this.hoverColor=(e,t)=>gd(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return jd(this,e,t)}get(e){return Ad(this,e)}describe(e,t){return jd(kd,e,t)}override(e,t){return jd(Od,e,t)}route(e,t,n,r){let i=Ad(this,e),a=Ad(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return Xl(e)?Object.assign({},t,e):$l(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[yd,bd,Dd]);function Nd(e){return!e||Jl(e.size)||Jl(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Pd(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Fd(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function Bd(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Gd(e,a),c=0;c+e||0;function ef(e,t){let n={},r=Xl(t),i=r?Object.keys(t):t,a=Xl(e)?r?n=>$l(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=$d(a(e));return n}function tf(e){return ef(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function nf(e){return ef(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function rf(e){let t=tf(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function af(e,t){e||={},t||=Md.font;let n=$l(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=$l(e.style,t.style);r&&!(``+r).match(Zd)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:$l(e.family,t.family),lineHeight:Qd($l(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:$l(e.weight,t.weight),string:``};return i.string=Nd(i),i}function of(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function cf(e,t){return Object.assign(Object.create(e),t)}function lf(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Tf(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>lf([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return mf(n,r,()=>wf(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Ef(e).includes(t)},ownKeys(e){return Ef(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function uf(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:df(e,r),setContext:t=>uf(e,t,n,r),override:i=>uf(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return mf(e,t,()=>hf(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function df(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:_u(n)?n:()=>n,isIndexable:_u(r)?r:()=>r}}var ff=(e,t)=>e?e+hu(t):t,pf=(e,t)=>Xl(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function mf(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function hf(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return _u(s)&&o.isScriptable(t)&&(s=gf(t,s,e,n)),Yl(s)&&s.length&&(s=_f(t,s,e,o.isIndexable)),pf(t,s)&&(s=uf(s,i,a&&a[t],o)),s}function gf(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),pf(e,c)&&(c=xf(i._scopes,i,e,c)),c}function _f(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(Xl(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=xf(r,i,e,c);t.push(uf(n,a,o&&o[e],s))}}return t}function vf(e,t,n){return _u(e)?e(t,n):e}var yf=(e,t)=>e===!0?t:typeof e==`string`?mu(t,e):void 0;function bf(e,t,n,r,i){for(let a of t){let t=yf(n,a);if(t){e.add(t);let a=vf(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function xf(e,t,n,r){let i=t._rootScopes,a=vf(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=Sf(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=Sf(s,o,a,c,r),c===null)?!1:lf(Array.from(s),[``],i,a,()=>Cf(t,n,r))}function Sf(e,t,n,r,i){for(;n;)n=bf(e,t,n,r,i);return n}function Cf(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Yl(i)&&Xl(n)?n:i||{}}function wf(e,t,n,r){let i;for(let a of t)if(i=Tf(ff(a,e),n),i!==void 0)return pf(e,i)?xf(n,r,e,i):i}function Tf(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Ef(e){let t=e._keys;return t||=e._keys=Df(e._scopes),t}function Df(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function Of(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;ste===`x`?`y`:`x`;function Mf(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=Vu(a,i),c=Vu(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Nf(e,t,n){let r=e.length,i,a,o,s,c,l=Af(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)Ff(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function Uf(e,t){return Hf(e).getPropertyValue(t)}var Wf=[`top`,`right`,`bottom`,`left`];function Gf(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Wf[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var Kf=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function qf(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(Kf(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Jf(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Hf(n),a=i.boxSizing===`border-box`,o=Gf(i,`padding`),s=Gf(i,`border`,`width`),{x:c,y:l,box:u}=qf(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function Yf(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Bf(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Hf(a),s=Gf(o,`border`,`width`),c=Gf(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=Vf(o.maxWidth,a,`clientWidth`),i=Vf(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||Cu,maxHeight:i||Cu}}var Xf=e=>Math.round(e*10)/10;function Zf(e,t,n,r){let i=Hf(e),a=Gf(i,`margin`),o=Vf(i.maxWidth,e,`clientWidth`)||Cu,s=Vf(i.maxHeight,e,`clientHeight`)||Cu,c=Yf(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Gf(i,`border`,`width`),t=Gf(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=Xf(Math.min(l,o,c.maxWidth)),u=Xf(Math.min(u,s,c.maxHeight)),l&&!u&&(u=Xf(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=Xf(Math.floor(u*r))),{width:l,height:u}}function Qf(e,t,n){let r=t||1,i=Xf(e.height*r),a=Xf(e.width*r);e.height=Xf(e.height),e.width=Xf(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var $f=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};zf()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function ep(e,t){let n=Uf(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function tp(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function np(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function rp(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=tp(e,i,n),s=tp(i,a,n),c=tp(a,t,n);return tp(tp(o,s,n),tp(s,c,n),n)}var ip=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},ap=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function op(e,t,n){return e?ip(t,n):ap()}function sp(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function cp(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function lp(e){return e===`angle`?{between:Wu,compare:Hu,normalize:Uu}:{between:qu,compare:(e,t)=>e-t,normalize:e=>e}}function up({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function dp(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=lp(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(up({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(up({start:g,end:d,loop:f,count:o,style:p})),m}function pp(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function hp(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function gp(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=mp(n,i,a,r);return r===!0?_p(e,[{start:o,end:s,loop:a}],n,t):_p(e,hp(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,nd.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Tp=`transparent`,Ep={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=hd(e||Tp),i=r.valid&&hd(t||Tp);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},Dp=class{constructor(e,t,n,r){let i=t[n];r=of([e.to,r,i,e.from]);let a=of([e.from,i,r]);this._active=!0,this._fn=e.fn||Ep[e.type||typeof a],this._easing=pd[e.easing]||pd.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=of([e.to,t,r,e.from]),this._from=of([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!Xl(i))return;let a={};for(let e of t)a[e]=i[e];(Yl(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=Ap(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&kp(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new Dp(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return wp.add(this._chart,n),!0}};function kp(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function Hp(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=Rp(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function Wp(e,t){return cf(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Gp(e,t,n){return cf(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function Kp(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var qp=e=>e===`reset`||e===`none`,Jp=(e,t)=>t?e:Object.assign({},e),Yp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Pp(n,!0),values:null},Xp=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Lp(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&Kp(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=$l(n.xAxisID,Up(e,`x`)),a=t.yAxisID=$l(n.yAxisID,Up(e,`y`)),o=t.rAxisID=$l(n.rAxisID,Up(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&ed(this._data,this),e._stacked&&Kp(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(Xl(t)){let e=this._cachedMeta;this._data=Ip(t,e)}else if(n!==t){if(n){ed(n,this);let e=this._cachedMeta;Kp(e),e._parsed=[]}t&&Object.isExtensible(t)&&$u(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Lp(t.vScale,t),t.stack!==n.stack&&(r=!0,Kp(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Hp(this,t._parsed),t._stacked=Lp(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length||n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=Yl(r[e])?this.parseArrayData(n,r,e,t):Xl(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Jp(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new Op(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||qp(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){qp(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!qp(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function Qp(e){let t=e.iScale,n=Zp(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(gu(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function nm(e,t,n,r){return Yl(e)?tm(e,t,n,r):t[n.axis]=n.parse(e,r),t}function rm(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):ku(e)}function om(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(Jl(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[$l(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;dWu(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>Wu(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(Tu,u,f),_=m(bu,l,d),v=m(bu+Tu,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var hm=class extends Xp{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(Xl(n[e])){let{key:e=`value`}=this._parsing;i=t=>+mu(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*xu:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Cd(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=Jl(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},_m=class extends Xp{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Cd(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return Of.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(rt.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*bu,d=u,f,p=360/this.countVisibleElements();for(f=0;f{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?Lu(this.resolveDataElementOptions(e,t).angle||n):0}},vm=Object.freeze({__proto__:null,BarController:fm,BubbleController:pm,DoughnutController:hm,LineController:gm,PieController:class extends hm{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:_m,RadarController:class extends Xp{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return Of.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function ym(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var bm={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return ym()}parse(){return ym()}format(){return ym()}add(){return ym()}diff(){return ym()}startOf(){return ym()}endOf(){return ym()}}};function xm(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?Xu:Yu;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!Jl(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!Jl(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function Sm(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var km={evaluateInteractionItems:Sm,modes:{index(e,t,n,r){let i=Jf(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?wm(e,i,a,r,o):Dm(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Jf(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?wm(e,i,a,r,o):Dm(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Mm(e,t){return e.filter(e=>Am.indexOf(e.pos)===-1&&e.box.axis===t)}function Nm(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Pm(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=Nm(jm(t,`left`),!0),i=Nm(jm(t,`right`)),a=Nm(jm(t,`top`),!0),o=Nm(jm(t,`bottom`)),s=Mm(t,`x`),c=Mm(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:jm(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function Rm(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function zm(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Bm(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!Xl(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&zm(o,a.getPadding());let s=Math.max(0,t.outerWidth-Rm(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-Rm(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function Vm(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Hm(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Um(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);zm(f,rf(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Im(c.concat(l),d);Um(s.fullSize,p,d,m),Um(c,p,d,m),Um(l,p,d,m)&&Um(c,p,d,m),Vm(p),Gm(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,Gm(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},ru(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},qm=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},Jm=class extends qm{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},Ym=`$chartjs`,Xm={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},Zm=e=>e===null||e===``;function Qm(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[Ym]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,Zm(i)){let t=ep(e,`width`);t!==void 0&&(e.width=t)}if(Zm(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=ep(e,`height`);t!==void 0&&(e.height=t)}return e}var $m=$f?{passive:!0}:!1;function eh(e,t,n){e&&e.addEventListener(t,n,$m)}function th(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,$m)}function nh(e,t){let n=Xm[e.type]||e.type,{x:r,y:i}=Jf(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function rh(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function ih(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=rh(n.addedNodes,r),t&&=!rh(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function ah(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=rh(n.removedNodes,r),t&&=!rh(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var oh=new Map,sh=0;function ch(){let e=window.devicePixelRatio;e!==sh&&(sh=e,oh.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function lh(e,t){oh.size||window.addEventListener(`resize`,ch),oh.set(e,t)}function uh(e){oh.delete(e),oh.size||window.removeEventListener(`resize`,ch)}function dh(e,t,n){let r=e.canvas,i=r&&Bf(r);if(!i)return;let a=rd((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),lh(e,a),o}function fh(e,t,n){n&&n.disconnect(),t===`resize`&&uh(e)}function ph(e,t,n){let r=e.canvas,i=rd(t=>{e.ctx!==null&&n(nh(t,e))},e);return eh(r,t,i),i}var mh=class extends qm{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(Qm(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[Ym])return!1;let n=t[Ym].initial;[`height`,`width`].forEach(e=>{let r=n[e];Jl(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[Ym],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:ih,detach:ah,resize:dh}[t]||ph)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:fh,detach:fh,resize:fh}[t]||th)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return Zf(e,t,n,r)}isAttached(e){let t=e&&Bf(e);return!!(t&&t.isConnected)}};function hh(e){return!zf()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?Jm:mh}var gh=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Pu(this.x)&&Pu(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function _h(e,t){let n=e.options.ticks,r=vh(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?bh(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return xh(t,l,a,o/i),l;let u=yh(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Sh(t,l,u,Jl(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function bh(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Th=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,Eh=(e,t)=>Math.min(t||e,e);function Dh(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function kh(e,t){ru(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:Ql(t,Ql(n,t)),max:Ql(n,Ql(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){nu(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=sf(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=Gu(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-Ah(e.grid)-t.padding-jh(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=Ru(Math.min(Math.asin(Gu((l.highest.height+6)/o,-1,1)),Math.asin(Gu(s/c,-1,1))-Math.asin(Gu(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){nu(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){nu(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=jh(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=Ah(i)+a):(e.height=this.maxHeight,e.width=Ah(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Lu(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){nu(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return Ku(this._alignToPixels?Id(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=Ah(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Id(n,e,p)},g,_,v,y,b,x,S,C,w,ee,te,ne;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,ee=h(e.top)+m,ne=e.bottom;else if(a===`bottom`)g=h(this.top),ee=e.top,ne=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,te=e.right;else if(a===`right`)g=h(this.left),w=e.left,te=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(Xl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}ee=e.top,ne=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(Xl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,te=e.right}let re=$l(r.ticks.maxTicksLimit,l),ie=Math.max(1,Math.ceil(l/re));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:ne,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:re,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Lu(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Md.route(a,i,c,s)})}function Bh(e){return`id`in e&&`defaults`in e}var Vh=new class{constructor(){this.controllers=new Lh(Xp,`datasets`,!0),this.elements=new Lh(gh,`elements`),this.plugins=new Lh(Object,`plugins`),this.scales=new Lh(Ih,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):ru(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=hu(e);nu(n[`before`+r],[],n),t[e](n),nu(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Uh(e){let t={},n=[],r=Object.keys(Vh.plugins.items);for(let e=0;e1&&Xh(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function $h(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function eg(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return $h(e,`x`,n[0])||$h(e,`y`,n[0])}return{}}function tg(e,t){let n=Od[e.type]||{scales:{}},r=t.scales||{},i=qh(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!Xl(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=Qh(t,o,eg(t,e),Md.scales[o.type]),c=Yh(s,i),l=n.scales||{};a[t]=lu(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||qh(i,t),s=(Od[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=Jh(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),lu(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];lu(t,[Md.scales[t.type],Md.scale])}),a}function ng(e){let t=e.options||={};t.plugins=$l(t.plugins,{}),t.scales=tg(e,t)}function rg(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function ig(e){return e||={},e.data=rg(e.data),ng(e),e}var ag=new Map,og=new Set;function sg(e,t){let n=ag.get(e);return n||(n=t(),ag.set(e,n),og.add(n)),n}var cg=(e,t,n)=>{let r=mu(t,n);r!==void 0&&e.add(r)},lg=class{constructor(e){this._config=ig(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=rg(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),ng(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return sg(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return sg(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return sg(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return sg(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>cg(s,e,t))),t.forEach(e=>cg(s,r,e)),t.forEach(e=>cg(s,Od[i]||{},e)),t.forEach(e=>cg(s,Md,e)),t.forEach(e=>cg(s,kd,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),og.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,Od[t]||{},Md.datasets[t]||{},{type:t},Md,kd]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=ug(this._resolverCache,e,r),s=a;if(fg(a,t)){i.$shared=!1,n=_u(n)?n():n;let t=this.createResolver(e,n,o);s=uf(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=ug(this._resolverCache,e,n);return Xl(t)?uf(i,t,void 0,r):i}};function ug(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:lf(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var dg=e=>Xl(e)&&Object.getOwnPropertyNames(e).some(t=>_u(e[t]));function fg(e,t){let{isScriptable:n,isIndexable:r}=df(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(_u(o)||dg(o))||a&&Yl(o))return!0}return!1}var pg=`4.5.1`,mg=[`top`,`bottom`,`left`,`right`,`chartArea`];function hg(e,t){return e===`top`||e===`bottom`||mg.indexOf(e)===-1&&t===`x`}function gg(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function _g(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),nu(n&&n.onComplete,[e],t)}function vg(e){let t=e.chart,n=t.options.animation;nu(n&&n.onProgress,[e],t)}function yg(e){return zf()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var bg={},xg=e=>{let t=yg(e);return Object.values(bg).filter(e=>e.canvas===t).pop()};function Sg(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function Cg(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var wg=class{static defaults=Md;static instances=bg;static overrides=Od;static registry=Vh;static version=pg;static getChart=xg;static register(...e){Vh.add(...e),Tg()}static unregister(...e){Vh.remove(...e),Tg()}constructor(e,t){let n=this.config=new lg(t),r=yg(e),i=xg(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(hh(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=ql(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Hh,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=id(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],bg[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}wp.listen(this,`complete`,_g),wp.listen(this,`progress`,vg),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return Jl(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Vh}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():Qf(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Ld(this.canvas,this.ctx),this}stop(){return wp.stop(this),this}resize(e,t){wp.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,Qf(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),nu(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){ru(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=Qh(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),ru(i,t=>{let i=t.options,a=i.id,o=Qh(a,i),s=$l(i.type,t.dtype);(i.position===void 0||hg(i.position,o)!==hg(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(Vh.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),ru(r,(e,t)=>{e||delete n[t]}),ru(n,e=>{Km.configure(this,e,e.options),Km.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(gg(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){ru(this.scales,e=>{Km.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!vu(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)Sg(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;Km.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],ru(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=Cp(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&Vd(t,r),e.controller.draw(),r&&Hd(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return Bd(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=km.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=cf(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);gu(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),wp.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};ru(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){ru(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},ru(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});iu(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=yu(e),c=Cg(e,this._lastEvent,n,s);n&&(this._lastEvent=null,nu(i.onHover,[e,o,this],this),s&&nu(i.onClick,[e,o,this],this));let l=!iu(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Tg(){return ru(wg.instances,e=>e._plugins.invalidate())}function Eg(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,Uu(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,Uu(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*Uu(r-n));if(u===`round`)e.arc(i,a,t,n-bu/2,r+bu/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+bu/2)+i,c=-o*Math.sin(n+bu/2)+a,l=o*Math.cos(r+bu/2)+i,u=o*Math.sin(r+bu/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Dg(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+Tu,r-Tu),e.closePath(),e.clip()}function Og(e){return ef(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function kg(e,t,n,r){let i=Og(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return Gu(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:Gu(i.innerStart,0,o),innerEnd:Gu(i.innerEnd,0,o)}}function Ag(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function jg(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/bu)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=kg(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,ee=_-y/C,te=f+b,ne=f+x,re=g+b/te,ie=_-x/ne;if(e.beginPath(),a){let t=(w+ee)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,ee),y>0){let t=Ag(C,ee,o,s);e.arc(t.x,t.y,y,ee,_+Tu)}let n=Ag(ne,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=Ag(ne,ie,o,s);e.arc(t.x,t.y,x,_+Tu,ie+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=Ag(te,re,o,s);e.arc(t.x,t.y,b,re+Math.PI,g-Tu)}let i=Ag(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=Ag(S,w,o,s);e.arc(t.x,t.y,v,g-Tu,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(ee)*d+o,i=Math.sin(ee)*d+s;e.lineTo(r,i)}e.closePath()}function Mg(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){jg(e,t,n,r,c,i);for(let t=0;t=bu&&p===0&&u!==`miter`&&Eg(e,t,h),a||(jg(e,t,n,r,h,i),e.stroke())}var Pg=class extends gh{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=Bu(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=$l(l,o-a),f=Wu(r,a,o)&&a!==o,p=d>=xu||f,m=qu(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>xu?Math.floor(n/xu):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(bu,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Mg(e,this,s,i,a),Ng(e,this,s,i,a),e.restore()}};function Fg(e,t,n=t){e.lineCap=$l(n.borderCapStyle,t.borderCapStyle),e.setLineDash($l(n.borderDash,t.borderDash)),e.lineDashOffset=$l(n.borderDashOffset,t.borderDashOffset),e.lineJoin=$l(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=$l(n.borderWidth,t.borderWidth),e.strokeStyle=$l(n.borderColor,t.borderColor)}function Ig(e,t,n){e.lineTo(n.x,n.y)}function Lg(e){return e.stepped?Ud:e.tension||e.cubicInterpolationMode===`monotone`?Wd:Ig}function Rg(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function Vg(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?Bg:zg}function Hg(e){return e.stepped?np:e.tension||e.cubicInterpolationMode===`monotone`?rp:tp}function Ug(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Fg(e,t.options),e.stroke(i)}function Wg(e,t,n,r){let{segments:i,options:a}=t,o=Vg(t);for(let s of i)Fg(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var Gg=typeof Path2D==`function`;function Kg(e,t,n,r){Gg&&!t.options.segment?Ug(e,t,n,r):Wg(e,t,n,r)}var qg=class extends gh{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;Rf(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=gp(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=pp(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Hg(n),c,l;for(c=0,l=a.length;ce.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function c_(e){return o_[e%o_.length]}function l_(e){return s_[e%s_.length]}function u_(e,t){return e.borderColor=c_(t),e.backgroundColor=l_(t),++t}function d_(e,t){return e.backgroundColor=e.data.map(()=>c_(t++)),t}function f_(e,t){return e.backgroundColor=e.data.map(()=>l_(t++)),t}function p_(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof hm?t=d_(n,t):i instanceof _m?t=f_(n,t):i&&(t=u_(n,t))}}function m_(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function h_(e){return e&&(e.borderColor||e.backgroundColor)}function g_(){return Md.borderColor!==`rgba(0,0,0,0.1)`||Md.backgroundColor!==`rgba(0,0,0,0.1)`}var __={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=m_(r)||h_(i)||a&&m_(a)||g_();if(!n.forceOverride&&o)return;let s=p_(e);r.forEach(s)}};function v_(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;dp&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function y_(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;oh&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!Jl(d)&&!Jl(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function b_(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function x_(e){e.data.datasets.forEach(e=>{b_(e)})}function S_(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=Gu(Yu(t,a.axis,o).lo,0,n-1)),i=l?Gu(Yu(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var C_={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){x_(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(of([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=S_(s,c);if(d<=(n.threshold||4*r)){b_(t);return}Jl(a)&&(t._data=c,delete t.data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=v_(c,u,d,r,n);break;case`min-max`:f=y_(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){x_(e)}};function w_(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=D_(r,s,i);let c=T_(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=pp(t,c);for(let t of l){let r=T_(n,a[t.start],a[t.end],t.loop),s=fp(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:O_(c,r,`start`,Math.max)},end:{[n]:O_(c,r,`end`,Math.min)}})}}return o}function T_(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=Uu(i),a=Uu(a)),{property:e,start:i,end:a}}function E_(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=D_(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function D_(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function O_(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function k_(e,t){let n=[],r=!1;return Yl(e)?(r=!0,n=e):n=E_(e,t),n.length?new qg({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function A_(e){return e&&e.fill!==!1}function j_(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!Zl(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function M_(e,t,n){let r=I_(e);if(Xl(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return Zl(i)&&Math.floor(i)===i?N_(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function N_(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function P_(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:Xl(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function F_(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:Xl(e)?e.value:t.getBaseValue(),r}function I_(e){let t=e.options,n=t.fill,r=$l(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function L_(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=R_(t,n);s.push(k_({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&q_(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;A_(n)&&q_(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!A_(r)||n.drawTime!==`beforeDatasetDraw`||q_(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},tv=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},nv=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,rv=class extends gh{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=nu(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=af(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=tv(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=iv(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=op(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=od(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=od(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=od(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=od(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;Vd(e,this),this._draw(),Hd(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Md.color,s=op(e.rtl,this.left,this.width),c=af(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=tv(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=$l(n.lineWidth,1);if(r.fillStyle=$l(n.fillStyle,o),r.lineCap=$l(n.lineCap,`butt`),r.lineDashOffset=$l(n.lineDashOffset,0),r.lineJoin=$l(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=$l(n.strokeStyle,o),r.setLineDash($l(n.lineDash,[])),a.usePointStyle){let o={radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},c=s.xPlus(e,p/2),l=t+d;zd(r,o,c,l,a.pointStyleWidth&&p)}else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=nf(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?Yd(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){Jd(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:od(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:od(i,this.top+y+l,this.bottom-t[0].height),line:0},sp(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=od(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=od(i,this.top+y+l,this.bottom-t[f.line].height));let w=s.x(S);if(g(w,C,o),S=sd(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=sv(o,e)+l}else f.y+=b}),cp(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=af(t.font),r=rf(t.padding);if(!t.display)return;let i=op(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=od(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+od(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=od(o,u,u+d);a.textAlign=i.textAlign(ad(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,Jd(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=af(e.font),n=rf(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(qu(e,this.left,this.right)&&qu(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function ov(e,t,n){let r=e;return typeof t.text!=`string`&&(r=sv(t,n)),r}function sv(e,t){return t*(e.text?e.text.length:0)}function cv(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var lv={id:`legend`,_element:rv,start(e,t,n){let r=e.legend=new rv({ctx:e.ctx,options:n,chart:e});Km.configure(e,r,n),Km.addBox(e,r)},stop(e){Km.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;Km.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=rf(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},uv=class extends gh{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=Yl(n.text)?n.text.length:1;this._padding=rf(n.padding);let i=r*af(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=od(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=od(o,r,t),s=bu*-.5):(l=i-e,u=od(o,t,r),s=bu*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=af(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);Jd(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:ad(t.align),textBaseline:`middle`,translation:[i,a]})}};function dv(e,t){let n=new uv({ctx:e.ctx,options:t,chart:e});Km.configure(e,n,t),Km.addBox(e,n),e.titleBlock=n}var fv={id:`title`,_element:uv,start(e,t,n){dv(e,n)},stop(e){let t=e.titleBlock;Km.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;Km.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},pv=new WeakMap,mv={id:`subtitle`,start(e,t,n){let r=new uv({ctx:e.ctx,options:n,chart:e});Km.configure(e,r,n),Km.addBox(e,r),pv.set(e,r)},stop(e){Km.removeBox(e,pv.get(e)),pv.delete(e)},beforeUpdate(e,t,n){let r=pv.get(e);Km.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`normal`},fullSize:!0,padding:0,position:`top`,text:``,weight:1500},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},hv={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` +`):e}function vv(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function yv(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=af(t.bodyFont),l=af(t.titleFont),u=af(t.footerFont),d=a.length,f=i.length,p=r.length,m=rf(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,ru(e.title,y),n.font=c.string,ru(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,ru(r,e=>{ru(e.before,y),ru(e.lines,y),ru(e.after,y)}),v=0,n.font=u.string,ru(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function bv(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function xv(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function Sv(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),xv(l,e,t,n)&&(l=`center`),l}function Cv(e,t,n){let r=n.yAlign||t.yAlign||bv(e,n);return{xAlign:n.xAlign||t.xAlign||Sv(e,t,n,r),yAlign:r}}function wv(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Tv(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function Ev(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=nf(o),m=wv(t,s),h=Tv(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:Gu(m,0,r.width-t.width),y:Gu(h,0,r.height-t.height)}}function Dv(e,t,n){let r=rf(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function Ov(e){return gv([],_v(e))}function kv(e,t,n){return cf(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function Av(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var jv={beforeTitle:Kl,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=Av(n,e);gv(t.before,_v(Mv(i,`beforeLabel`,this,e))),gv(t.lines,Mv(i,`label`,this,e)),gv(t.after,_v(Mv(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return Ov(Mv(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Mv(n,`beforeFooter`,this,e),i=Mv(n,`footer`,this,e),a=Mv(n,`afterFooter`,this,e),o=[];return o=gv(o,_v(r)),o=gv(o,_v(i)),o=gv(o,_v(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),ru(o,t=>{let n=Av(e.callbacks,t);r.push(Mv(n,`labelColor`,this,t)),i.push(Mv(n,`labelPointStyle`,this,t)),a.push(Mv(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=hv[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=yv(this,n),o=Object.assign({},e,t),s=Cv(this.chart,n,o),c=Ev(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=nf(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=op(n.rtl,this.x,this.width);for(e.x=Dv(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=af(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,Yd(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),Yd(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=af(n.bodyFont),d=u.lineHeight,f=0,p=op(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=Dv(this,h,n),t.fillStyle=n.bodyColor,ru(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=hv[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=yv(this,e),o=Object.assign({},n,this._size),s=Cv(t,e,o),c=Ev(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=rf(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),sp(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),cp(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!iu(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!iu(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=hv[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Pv=Object.freeze({__proto__:null,Colors:__,Decimation:C_,Filler:ev,Legend:lv,SubTitle:mv,Title:fv,Tooltip:{id:`tooltip`,_element:Nv,positioners:hv,afterInit(e,t,n){n&&(e.tooltip=new Nv({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:jv},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Fv=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Iv(e,t,n,r){let i=e.indexOf(t);return i===-1?Fv(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Lv=(e,t)=>e===null?null:Gu(Math.round(e),0,t);function Rv(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function Bv(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!Jl(a),_=!Jl(o),v=!Jl(c),y=(h-m)/(u+1),b=ju((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=ju(w*b/p/f)*f),Jl(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Fu((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=Au(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let ee=Math.max(zu(b),zu(S));x=10**(Jl(s)?ee:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let te=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&Au(n[n.length-1].value,o,Vv(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Vv(e,t,{horizontal:n,minRotation:r}){let i=Lu(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Hv=class extends Ih{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return Jl(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=ku(r),t=ku(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=Bv({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Iu(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return Cd(e,this.chart.options.locale,this.options.ticks.format)}},Uv=class extends Hv{static id=`linear`;static defaults={ticks:{callback:Ed.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Zl(e)?e:0,this.max=Zl(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Lu(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Wv=e=>Math.floor(Ou(e)),Gv=(e,t)=>10**(Wv(e)+t);function Kv(e){return e/10**Wv(e)==1}function qv(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Jv(e,t){let n=Wv(t-e);for(;qv(e,t,n)>10;)n++;for(;qv(e,t,n)<10;)n--;return Math.min(n,Wv(e))}function Yv(e,{min:t,max:n}){t=Ql(e.min,t);let r=[],i=Wv(t),a=Jv(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=Ql(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=Ql(e.max,f);return r.push({value:p,major:Kv(p),significand:d}),r}var Xv=class extends Ih{static id=`logarithmic`;static defaults={ticks:{callback:Ed.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Hv.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return Zl(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Zl(e)?Math.max(0,e):null,this.max=Zl(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Zl(this._userMin)&&(this.min=e===Gv(this.min,0)?Gv(this.min,-1):Gv(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Gv(n,-1)),a(Gv(r,1)))),n<=0&&i(Gv(r,-1)),r<=0&&a(Gv(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Yv({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Iu(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:Cd(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=Ou(e),this._valueRange=Ou(this.max)-Ou(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(Ou(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function Zv(e){let t=e.ticks;if(t.display&&e.display){let e=rf(t.backdropPadding);return $l(t.font&&t.font.size,Md.font.size)+e.height}return 0}function Qv(e,t,n){return n=Yl(n)?n:[n],{w:Fd(e,t.string,n),h:n.length*t.lineHeight}}function $v(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function ey(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?bu/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function ny(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(Ru(Uu(c.angle+Tu))),u=sy(c.y,s.h,l),d=ay(l),f=oy(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function ry(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(Bd({x:n,y:r},t)||Bd({x:n,y:a},t)||Bd({x:i,y:r},t)||Bd({x:i,y:a},t))}function iy(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Zv(a)/2,additionalAngle:o?bu/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function cy(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!Jl(s)){let n=nf(t.borderRadius),c=rf(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),Yd(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function ly(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));cy(n,a,t);let o=af(a.font),{x:s,y:c,textAlign:l}=t;Jd(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function uy(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,xu);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=nu(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?ey(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=xu/(this._pointLabels.length||1),n=this.options.startAngle||0;return Uu(e*t+Lu(n))}getDistanceFromCenterForValue(e){if(Jl(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(Jl(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);dy(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=af(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=rf(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}Jd(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},my={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},hy=Object.keys(my);function gy(e,t){return e-t}function _y(e,t){if(Jl(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),Zl(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Pu(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function vy(e,t,n,r){let i=hy.length;for(let a=hy.indexOf(e);a=hy.indexOf(n);a--){let n=hy[a];if(my[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return hy[n?hy.indexOf(n):0]}function by(e){for(let t=hy.indexOf(e)+1,n=hy.length;t=t?n[r]:n[i];e[a]=!0}}function Sy(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function Cy(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=Gu(t,0,a),n=Gu(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||vy(i.minUnit,t,n,this._getLabelCapacity(t)),o=$l(r.ticks.stepSize,1),s=a===`week`&&i.isoWeekday,c=Pu(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return nu(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=Yu(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=Yu(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var Ey=class extends wy{static id=`timeseries`;static defaults=wy.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=Ty(t,this.min),this._tableRange=Ty(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(Ty(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return Ty(this._table,n*this._tableRange+this._minPos,!0)}},Dy=[vm,a_,Pv,Object.freeze({__proto__:null,CategoryScale:zv,LinearScale:Uv,LogarithmicScale:Xv,RadialLinearScale:py,TimeScale:wy,TimeSeriesScale:Ey})];wg.register(...Dy);var Oy=wg,ky=R(``);function Ay(e,t){E(t,!0);let n=G(t,`class`,3,``),r=G(t,`ariaLabel`,3,``);function i(e){if(Oa.tick,typeof t.build!=`function`)return;let n=t.build();if(!n)return;let r=new Oy(e.getContext(`2d`),n);return()=>r.destroy()}var a=ky();Mi(a,()=>i),F(()=>{U(a,1,Fi(n())),W(a,`aria-label`,r())}),z(e,a),D()}var jy=R(``),My=R(`
        `);function Ny(e,t){E(t,!0);let n=G(t,`options`,19,()=>[]),r=G(t,`ariaLabel`,3,``),i=G(t,`class`,3,``);var a=My();H(a,21,n,e=>e.value,(e,n)=>{var r=jy();let i;var a=M(r,!0);T(r),F(()=>{i=U(r,1,`segmented-btn svelte-92fh5i`,null,i,{active:t.value===I(n).value}),W(r,`aria-pressed`,t.value===I(n).value),B(a,I(n).label)}),L(`click`,r,()=>t.onchange?.(I(n).value)),z(e,r)}),T(a),F(()=>{U(a,1,Fi([`segmented-control`,i()]),`svelte-92fh5i`),W(a,`aria-label`,r())}),z(e,a),D()}Hr([`click`]);function Py(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Fy(){return{grid:Py(`--chart-grid`),text:Py(`--chart-text`),dayMarker:Py(`--chart-day-marker`),tooltipBg:Py(`--chart-tooltip-bg`),tooltipBorder:Py(`--chart-tooltip-border`),tooltipText:Py(`--chart-tooltip-text`)}}function Iy(){return{size:11,family:`'SF Mono', Menlo, Consolas, monospace`}}function Ly(e,t){return{backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,borderWidth:1,titleColor:e.tooltipText,bodyColor:e.tooltipText,callbacks:t}}function Ry(e){if(typeof document>`u`||!document.body)return e;let t=document.createElement(`span`);t.style.display=`none`,t.style.color=e,document.body.appendChild(t);let n=getComputedStyle(t).color;return document.body.removeChild(t),n||e}var zy=[`#c2845a`,`#7a9e7e`,`#d4a574`,`#b8a98e`,`#8b9e6b`,`#7d8a97`,`#c47a5a`,`#6b8e6b`,`#a09486`,`#9b7ea4`,`#c49a6c`];function By(){return[...zy]}function Vy(e){let t=5381,n=String(e||``);for(let e=0;elc(e)}}var qy={seconds:{apiName:`second`,windowLabel:`Last 60 seconds`,refreshMs:2e3},minutes:{apiName:`minute`,windowLabel:`Last 60 minutes`,refreshMs:5e3},hours:{apiName:`hour`,windowLabel:`Last 24 hours`,refreshMs:2e4},days:{apiName:`day`,windowLabel:`Last 30 days`,refreshMs:6e4}},Jy=[{value:`seconds`,label:`Seconds`},{value:`minutes`,label:`Minutes`},{value:`hours`,label:`Hours`},{value:`days`,label:`Days`}];function Yy(){return{input:0,output:0,prompt:0,local:0}}function Xy(e){return String(e).padStart(2,`0`)}function Zy(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function Qy(e,t){if(!Number.isFinite(t))return``;let n=new Date(t);switch(e){case`seconds`:return Xy(n.getHours())+`:`+Xy(n.getMinutes())+`:`+Xy(n.getSeconds());case`minutes`:return Xy(n.getHours())+`:`+Xy(n.getMinutes());case`hours`:return Xy(n.getHours())+`:00`;default:return Xy(n.getMonth()+1)+`-`+Xy(n.getDate())}}function $y(e,t){let n=[],r=[],i={input:[],output:[],prompt:[],local:[]},a=Yy();for(let o of e||[]){let e=Date.parse(o&&o.start),s=Zy(o&&o.input_tokens),c=Zy(o&&o.output_tokens),l=Zy(o&&o.prompt_cached_tokens),u=Zy(o&&o.locally_cached_tokens);n.push(Qy(t,e)),r.push(Number.isFinite(e)?e:null),i.input.push(s),i.output.push(c),i.prompt.push(l),i.local.push(u),a.input+=s,a.output+=c,a.prompt+=l,a.local+=u}return{labels:n,stamps:r,cols:i,totals:a}}function eb(e){let t=e||Yy();return t.input+t.output+t.prompt+t.local>0}function tb(e,t){return lc(Math.max(0,Math.round(e&&e[t]||0)))}function nb(e){return(qy[e]||qy.minutes).windowLabel}function rb(e,t){return`Live token throughput, `+nb(t).toLowerCase()+`. Input `+tb(e,`input`)+`, output `+tb(e,`output`)+`, prompt cached `+tb(e,`prompt`)+`, locally cached `+tb(e,`local`)+` tokens.`}function ib(e,t,n,r){let i=e=>lc(Math.max(0,Math.round(e))),a=n.stamps,o=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderWidth:0,borderRadius:0,categoryPercentage:1,barPercentage:1,stack:`tokens`});return{type:`bar`,plugins:[{id:`liveTokensDayMarks`,afterDatasetsDraw:t=>{if(r===`days`)return;let n=t.getDatasetMeta(0),i=t.chartArea;if(!n||!n.data||!i)return;let o=t.ctx;o.save(),o.font=`10px 'SF Mono', Menlo, Consolas, monospace`;let s=null;for(let t=0;t{if(!e.length)return``;let t=a[e[0].dataIndex];if(!t)return e[0].label;let n=new Date(t);return r===`days`?n.toLocaleDateString():n.toLocaleString()},label:e=>e.dataset.label+`: `+i(e.parsed.y),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+i(t)}})}}}}var ab=900,ob=new class{#e=k(`minutes`);get granularity(){return I(this.#e)}set granularity(e){A(this.#e,e,!0)}#t=k(j([]));get buckets(){return I(this.#t)}set buckets(e){A(this.#t,e,!0)}#n=k(!1);get active(){return I(this.#n)}set active(e){A(this.#n,e,!0)}#r=null;#i=null;#a=null;#o=0;#s=null;#c=!1;start(){this.stop(),this.active=!0,this.fetch(),this.#l(),this.#u()}stop(){this.active=!1,this.#r&&=(clearInterval(this.#r),null),this.#i&&=(clearTimeout(this.#i),null),this.#a&&=(clearTimeout(this.#a),null),this.#o=0,this.#s&&=(this.#s.abort(),null),this.buckets=[]}setGranularity(e){!qy[e]||e===this.granularity||(this.granularity=e,this.buckets=[],this.#l(),this.fetch())}#l(){this.#r&&=(clearInterval(this.#r),null);let e=qy[this.granularity]||qy.minutes;this.#r=setInterval(()=>{this.active&&this.fetch()},e.refreshMs)}noteUsageEvent(e){!this.active||e!==`usage.flushed`||(this.#i||=setTimeout(()=>{this.#i=null,this.fetch()},ab))}async fetch(){if(!this.active||this.#c)return;this.#c=!0;let e=this.granularity;try{let t=await gs(`/admin/usage/throughput?granularity=`+(qy[e]||qy.minutes).apiName,{label:`token throughput`});if(t.stale||!t.ok||this.granularity!==e)return;this.buckets=t.data&&Array.isArray(t.data.buckets)?t.data.buckets:[]}catch(e){if(vs(e))return;console.error(`Failed to fetch token throughput:`,e)}finally{this.#c=!1,this.active&&this.granularity!==e&&this.fetch()}}async#u(){await xs.ensureLoaded(),this.active&&xs.liveLogsVisible()&&(typeof ReadableStream>`u`||(this.#s&&this.#s.abort(),this.#s=new AbortController,this.#d(this.#s)))}async#d(e){try{let t=await ms(`/admin/live/logs?types=usage`,{signal:e.signal});if(!t.ok||!t.body||typeof t.body.getReader!=`function`){this.#p();return}this.#o=0,await Uy(t.body.getReader(),e=>this.#f(e)),this.#p()}catch(e){if(vs(e))return;console.error(`Live usage stream failed:`,e),this.#p()}}#f(e){if(!e||typeof e!=`object`)return;let t=String(e.type||``).trim();t.indexOf(`usage.`)===0&&this.noteUsageEvent(t)}#p(){if(!this.active||this.#a)return;let{attempt:e,delay:t}=Gy(this.#o);this.#o=e,this.#a=setTimeout(()=>{this.#a=null,this.#u()},t)}},sb=R(`
        `),cb=R(`
        Waiting for live requests…
        `),lb=R(`

        Live Token Throughput

        `);function ub(e,t){E(t,!0);let n=O(()=>$y(ob.buckets,ob.granularity)),r=O(()=>I(n).totals);function i(){return{input:Ry(`var(--token-input)`),output:Ry(`var(--token-output)`),prompt:Ry(`var(--token-prompt)`),local:Ry(`var(--token-local)`)}}let a=[{metric:`input`,label:`Input Tokens`,colorVar:`--token-input`},{metric:`output`,label:`Output Tokens`,colorVar:`--token-output`},{metric:`prompt`,label:`Prompt (Input) Cached`,colorVar:`--token-prompt`},{metric:`local`,label:`Locally Cached`,colorVar:`--token-local`}];var o=lb(),s=M(o),c=M(s),l=P(M(c),2),u=M(l);let d;var f=P(u,2),p=M(f,!0);T(f),T(l),T(c),Ny(P(c,2),{ariaLabel:`Live token throughput granularity`,get options(){return Jy},get value(){return ob.granularity},onchange:e=>ob.setGranularity(e)}),T(s);var m=P(s,2);H(m,21,()=>a,e=>e.metric,(e,t)=>{var n=sb(),i=M(n),a=P(i,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{Hi(i,`background: var(${I(t).colorVar??``})`),B(o,I(t).label),B(c,e)},[()=>tb(I(r),I(t).metric)]),z(e,n)}),T(m);var h=P(m,2),g=M(h);{let e=O(()=>rb(I(r),ob.granularity));Ay(g,{get ariaLabel(){return I(e)},build:()=>ib(Fy(),i(),I(n),ob.granularity)})}var _=P(g,2),v=e=>{z(e,cb())},y=O(()=>!eb(I(r)));V(_,e=>{I(y)&&e(v)}),T(h),T(o),F(e=>{d=U(u,1,`live-dot`,null,d,{"is-streaming":ob.active}),B(p,e)},[()=>nb(ob.granularity)]),z(e,o),D()}function db(e){let t=e||{};if(t.total_tokens!==null&&t.total_tokens!==void 0){let e=Number(t.total_tokens);if(Number.isFinite(e))return e}let n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function fb(e,t){if(!t)return 0;let n=e&&e.summary?e.summary:{},r=Number(n.total_hits||0);return Number.isFinite(r)&&r>0?r:0}function pb(e,t,n){let r=Number(e&&e.total_requests||0);return(Number.isFinite(r)?r:0)+fb(t,n)}function mb(e,t,n){let r=fb(t,n);return r<=0?``:ac(pb(e,t,n)-r)+` to providers + `+ac(r)+` from cache`}function hb(e){let t=e&&e.summary?e.summary:{},n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function gb(e,t,n){let r=e=>{let t=Number(e||0);return Number.isFinite(t)&&t>0?t:0},i=e||{},a=r(i.uncached_input_tokens),o=r(i.cached_input_tokens),s=r(i.cache_write_input_tokens),c=t&&t.summary?t.summary:{},l=n?r(c.total_input_tokens):0;return[{key:`uncached`,label:`Regular`,tokens:a+s,colorVar:`--cache-meter-uncached`,note:s>0?`Includes `+ac(s)+` cache-write tokens`:``},{key:`prompt`,label:`Prompt cached`,tokens:o,colorVar:`--cache-meter-prompt`,note:`Provider prompt-cache reads`},{key:`local`,label:`Locally cached`,tokens:l,colorVar:`--cache-meter-local`,note:`Served from GoModel response cache`}]}function _b(e,t,n){return gb(e,t,n).reduce((e,t)=>e+t.tokens,0)}function vb(e,t,n){return _b(e,t,n)>0}function yb(e,t,n){let r=gb(e,t,n),i=r.reduce((e,t)=>e+t.tokens,0);if(i<=0)return r.map(e=>Object.assign({},e,{pct:0}));let a=r.map(e=>{let t=e.tokens/i*100,n=Math.floor(t);return Object.assign({},e,{pct:n,remainder:t-n})}),o=100-a.reduce((e,t)=>e+t.pct,0);return a.map((e,t)=>({index:t,remainder:e.remainder,tokens:e.tokens})).filter(e=>e.tokens>0).sort((e,t)=>t.remainder-e.remainder).forEach(e=>{o>0&&(a[e.index].pct+=1,--o)}),a}function bb(e,t,n){return yb(e,t,n).filter(e=>e.tokens>0)}function xb(e){let t=[e.label+`: `+ac(e.tokens)+` input tokens (`+e.pct+`%)`];return e.note&&t.push(e.note),t.join(` +`)}function Sb(e){let t=(e||[]).map(e=>e.label+` `+e.pct+`%`);return`Cache breakdown of input tokens — `+(t.length?t.join(`, `):`no data`)}function Cb(e){return e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`)}function wb(e,t,n,r){if(t!==`daily`||!n||!r)return e;let i={};(e||[]).forEach(e=>{i[e.date]=e});let a=[];for(let e=new Date(n);e<=r;e.setUTCDate(e.getUTCDate()+1)){let t=Cb(e);a.push(i[t]||{date:t,input_tokens:0,output_tokens:0,total_tokens:0,requests:0,input_cost:null,output_cost:null,total_cost:null})}return a}function Tb(e,t){let n=e=>Number(e)||0,r=e.map(e=>e.date),i=e.map(e=>n(e.uncached_input_tokens)+n(e.cache_write_input_tokens)+n(e.cached_input_tokens)>0?n(e.uncached_input_tokens)+n(e.cache_write_input_tokens):n(e.input_tokens)),a=e.map(e=>n(e.output_tokens)),o=e.map(e=>n(e.cached_input_tokens)),s={};return(t||[]).forEach(e=>{s[e.date]=e}),{labels:r,inputPaid:i,output:a,prompt:o,local:r.map(e=>{let t=s[e];return t?n(t.input_tokens)+n(t.output_tokens):0})}}function Eb(e){let t=e||{},n=Math.max(0,Number(t.uncached_input_tokens)||0),r=Math.max(0,Number(t.cached_input_tokens)||0),i=Math.max(0,Number(t.cache_write_input_tokens)||0),a=n+r+i;return a>0?r/a*100:0}function Db(e){let t=e||{};return(Number(t.uncached_input_tokens)||0)+(Number(t.cached_input_tokens)||0)+(Number(t.cache_write_input_tokens)||0)>0}function Ob(e){return Db(e)?Math.round(Eb(e))+`%`:`—`}function kb(e,t,n={}){let r=!!n.cacheEnabled,i=n.resolve||(e=>e),a=(e,t)=>i(`color-mix(in srgb, `+e+` `+t+`%, transparent)`),o=(e,t,n,r)=>Object.assign({label:e,data:t,borderColor:n,backgroundColor:n,fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4},r||{}),s=[o(`Input Tokens`,t.inputPaid,i(`var(--token-input)`),{fill:`origin`}),o(`Output Tokens`,t.output,i(`var(--token-output)`),{fill:`-1`}),o(`Prompt (Input) Cached`,t.prompt,i(`var(--token-prompt)`),{fill:`-1`,borderDash:[6,4]})];return r&&s.push(o(`Locally Cached`,t.local,a(`var(--info)`,35),{fill:`-1`,borderDash:[2,3]})),{type:`line`,data:{labels:t.labels,datasets:s},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ly(e,{label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),maxRotation:0,autoSkip:!0,maxTicksLimit:10}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:Ky(e)}}}}}function Ab(e,t,n){let r=Math.max(0,Math.min(100,e));return{type:`doughnut`,data:{datasets:[{data:[r,100-r],backgroundColor:[t,n],borderWidth:0,spacing:0}]},options:{rotation:-90,circumference:180,cutout:`84%`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:1},events:[],plugins:{legend:{display:!1},tooltip:{enabled:!1}}}}}var jb=`gomodel_provider_status_details_expanded`,Mb=`gomodel_provider_card_expanded_overrides`,Nb=3e3,Pb=`https://gomodel.enterpilot.io/docs/providers/`,Fb={anthropic:`anthropic`,azure:`azure`,bailian:`bailian`,bedrock:`bedrock`,"bedrock-mantle":`bedrock-mantle`,cohere:`cohere`,deepseek:`deepseek`,gemini:`gemini`,opencode_go:`opencode-go`,oracle:`oracle`,vertex:`vertex`,vllm:`vllm`,xiaomi:`xiaomi`};function Ib(){return{summary:{total:0,healthy:0,degraded:0,unhealthy:0,overall_status:`degraded`},providers:[]}}function Lb(e){let t={detailsExpanded:!1,cardOverrides:{}};try{if(e){let n=e.getItem(jb);n===`true`||n===`false`?t.detailsExpanded=n===`true`:e.setItem(jb,`false`);let r=JSON.parse(e.getItem(Mb)||`{}`);r&&typeof r==`object`&&!Array.isArray(r)&&(t.cardOverrides=r)}}catch{}return t}function Rb(e,t){if(e)try{e.setItem(jb,t?`true`:`false`)}catch{}}function zb(e,t){if(e)try{e.setItem(Mb,JSON.stringify(t))}catch{}}function Bb(e,t,n){let r=n&&n.name?String(n.name):``;return r&&Object.prototype.hasOwnProperty.call(e,r)?e[r]===!0:t}function Vb(e){return`is-`+(String(e&&e.overall_status||`degraded`).trim()||`degraded`)}function Hb(e){return`is-`+(String(e||`degraded`).trim()||`degraded`)}function Ub(e){let t=e||{};return String(t.healthy||0)+`/`+String(t.total||0)}function Wb(e){let t=e||{},n=Number(t.total||0),r=Number(t.healthy||0);return n>0&&rString(e&&e.status_label||``).trim().toLowerCase()===`starting`)}function qb(e){if(!e||!e.runtime)return``;let t=e.runtime.last_model_fetch_at||``,n=e.runtime.last_availability_check_at||``;return t?n&&Date.parse(n)>Date.parse(t)?n:t:n}function Jb(e,t){let n=qb(e);if(!n||typeof t!=`function`)return`-`;let r=t(n);if(!r||r===`-`)return`-`;let i=String(r).split(` `);return i.length>1?i.slice(1).join(` `):r}function Yb(e,t){let n=qb(e);return n?typeof t==`function`?t(n):String(n):``}function Xb(e){if(!e)return``;let t=String(e.name||``).trim(),n=String(e.type||e.config&&e.config.type||``).trim();return!n||n===t?``:n}function Zb(e){let t=String(e&&(e.type||e.config&&e.config.type)||``).trim().toLowerCase(),n=t?Fb[t]:``;return n?Pb+n+`?utm_source=gomodel_dashboard`:``}function Qb(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.retry:null;return t?String(t.max_retries)+` retries, `+t.initial_backoff+` initial, `+t.max_backoff+` max, factor `+t.backoff_factor+`, jitter `+t.jitter_factor:`-`}function $b(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.circuit_breaker:null;return t?String(t.failure_threshold)+` fail, `+String(t.success_threshold)+` success, `+t.timeout+` timeout`:`-`}function ex(e){let t=e&&e.config&&Array.isArray(e.config.models)?e.config.models.filter(Boolean):[];return t.length===0?`Automatic`:t.join(`, `)}function tx(e){if(!e)return``;let t=[];return e.status_reason&&t.push(String(e.status_reason)),e.last_error&&t.push(`Last error: `+String(e.last_error)),t.join(` + +`)}function nx(e){let t=e&&e.request_health;return t&&typeof t==`object`?t:null}function rx(e){let t=nx(e);return t?String(t.circuit_state||``).trim():``}function ix(e){let t=rx(e);return t?t.charAt(0).toUpperCase()+t.slice(1):``}function ax(e){let t=rx(e);return t===`open`?`is-unhealthy`:t===`half-open`?`is-degraded`:`is-healthy`}function ox(e){let t=nx(e);if(!t)return``;let n=Number(t.requests||0),r=Number(t.errors||0),i=Math.round(Number(t.window_seconds||0)/60),a=i>0?`last `+i+` min`:`recent`;return String(n)+` request`+(n===1?``:`s`)+` · `+String(r)+` error`+(r===1?``:`s`)+` (`+a+`)`}function sx(e){let t=nx(e);return t&&Array.isArray(t.models)?t.models:[]}function cx(e){return e?String(Number(e.errors||0))+`/`+String(Number(e.requests||0))+` failed`:``}function lx(e){let t=e&&e.last_error;return!t||!t.message?``:(t.status_code?`HTTP `+String(t.status_code)+`: `:``)+t.message}function ux(){return{name:``,slug:``,url:``,transport:`http`,description:``,enabled:!0,headers:[],allowed_tools:``,disallowed_tools:``,user_paths:``,tool_timeout_seconds:``}}function dx(){return{server:``,status:``,instructions:``,tools:[],prompts:[],resources:[],templates:[]}}function fx(e){return String(e&&(e.slug||e.name)||``).trim()}function px(e){return String(e&&e.status||``).trim()||`connecting`}function mx(e){switch(px(e)){case`connected`:return`status-success`;case`degraded`:return String(e&&e.last_error||``).trim()?`status-error`:`status-warning`;case`connecting`:return`status-neutral`;default:return`status-unknown`}}function hx(e,t){let n=px(e),r=String(e&&e.last_error||``).trim();return r&&n!==`connected`?r:n===`connected`&&e&&e.connected_at?`Connected since `+(typeof t==`function`?t:String)(e.connected_at):``}function gx(e){return String(e&&e.transport||``)===`stdio`?`local command`:String(e&&e.url||``).trim()||`—`}function _x(e){let t=Number(e&&e.prompt_count||0),n=Number(e&&e.resource_count||0);return t+` prompts · `+n+` resources`}function vx(e){let t=String(e||``).normalize(`NFKD`).toLowerCase(),n=t.replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/-+$/g,``);if(n)return n;let r=2166136261;for(let e of t)r=Math.imul((r^e.codePointAt(0))>>>0,16777619)>>>0;return`mcp-`+r.toString(16).padStart(8,`0`)}function yx(e){return String(e||``).split(` +`).map(e=>e.trim()).filter(e=>e)}function bx(e){return!e||typeof e!=`object`||Array.isArray(e)?[]:Object.keys(e).sort().map(t=>({name:t,value:String(e[t]||``)}))}function xx(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=String(e&&e.name||``).trim();n&&(t[n]=String(e&&e.value||``))}),t}function Sx(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.slug,e.url,e.transport,e.description,e.status].some(e=>String(e||``).toLowerCase().includes(r)))}function Cx(e){return{name:String(e.name||``).trim(),slug:fx(e),url:String(e.url||``).trim(),transport:e.transport===`sse`?`sse`:`http`,description:String(e.description||``).trim(),enabled:e.enabled!==!1,headers:bx(e.headers),allowed_tools:(Array.isArray(e.allowed_tools)?e.allowed_tools:[]).join(`, `),disallowed_tools:(Array.isArray(e.disallowed_tools)?e.disallowed_tools:[]).join(`, `),user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` +`),tool_timeout_seconds:e.tool_timeout_seconds?String(e.tool_timeout_seconds):``}}function wx(e,t,n){let r=String(e.name||``).trim(),i=String(e.slug||vx(r)).trim().toLowerCase(),a=String(e.url||``).trim(),o=e.transport===`sse`?`sse`:`http`;if(!r)return{error:`Name is required.`};if(!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(i))return{error:`Slug must use 1–64 lowercase ASCII letters, numbers, hyphens, or underscores.`};if(t===`create`&&(n||[]).some(e=>fx(e)===i))return{error:`Slug "`+i+`" is already in use.`};if(!a)return{error:`URL is required.`};let s,c=String(e.tool_timeout_seconds||``).trim();if(c!==``){let e=Number(c);if(!Number.isSafeInteger(e)||e<0)return{error:`Tool timeout must be a non-negative whole number of seconds.`};s=e}return{payload:{name:r,slug:i,url:a,transport:o,headers:xx(e.headers),description:String(e.description||``).trim(),enabled:!!e.enabled,allowed_tools:rc(e.allowed_tools),disallowed_tools:rc(e.disallowed_tools),user_paths:yx(e.user_paths),tool_timeout_seconds:s}}}function Tx(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=e=>(Array.isArray(e)?e:[]).filter(e=>e&&typeof e==`object`);return{server:String(n.server||e||``).trim(),status:String(n.status||``).trim(),instructions:String(n.instructions||``).trim(),tools:r(n.tools),prompts:r(n.prompts),resources:r(n.resources),templates:r(n.templates)}}function Ex(e,t){return String(e&&e.server||``)+`_`+String(t||``)}function Dx(e){let t=e||dx(),n=(e,t)=>{let n=String(e||``).trim(),r=String(t||``).trim();return n&&r?n+` — `+r:r||n},r=e=>n=>({key:e+`:`+String(n.name||``),name:String(n.name||``),aggregated:Ex(t,n.name),description:String(n.description||``).trim()});return[{key:`tools`,title:`Tools`,items:(t.tools||[]).map(r(`tool`))},{key:`prompts`,title:`Prompts`,items:(t.prompts||[]).map(r(`prompt`))},{key:`resources`,title:`Resources`,items:(t.resources||[]).map(e=>({key:`resource:`+String(e.uri||``),name:String(e.uri||``),aggregated:``,description:n(e.name,e.description)}))},{key:`templates`,title:`Resource templates`,items:(t.templates||[]).map(e=>({key:`template:`+String(e.uri_template||``),name:String(e.uri_template||``),aggregated:``,description:n(e.name,e.description)}))}].filter(e=>e.items.length>0)}function Ox(e){return Dx(e).length===0}function kx(e){return(e||[]).length}function Ax(e){return(e||[]).filter(e=>px(e)===`connected`).length}function jx(e){return(e||[]).filter(e=>e&&e.enabled!==!1&&px(e)===`degraded`).length}function Mx(e,t){return!!e&&kx(t)>0}function Nx(e){return String(Ax(e))+`/`+String(kx(e))}function Px(e){return jx(e)>0?`is-degraded`:`is-healthy`}function Fx(e){let t=jx(e);if(t>0)return String(t)+` server`+(t===1?``:`s`)+` need`+(t===1?`s`:``)+` attention`;let n=kx(e),r=Ax(e);return n>0&&r===n?`All MCP servers connected`:String(r)+` of `+String(n)+` server`+(n===1?``:`s`)+` connected`}function Ix(){return{interval:`day`,buckets:[],summary:{requests:0},provider_latency:[]}}function Lx(e){let t=e&&typeof e==`object`?e:{};return{interval:t.interval===`hour`?`hour`:`day`,buckets:Array.isArray(t.buckets)?t.buckets:[],summary:t.summary&&typeof t.summary==`object`?t.summary:{requests:0},provider_latency:Array.isArray(t.provider_latency)?t.provider_latency:[]}}function Rx(e){return Number(e&&e.summary&&e.summary.requests||0)>0}function zx(e){return(e&&Array.isArray(e.provider_latency)?e.provider_latency:[]).length>0}function Bx(e){let t=e&&e.summary?e.summary.success_rate:null;return t==null?`—`:(Math.round(Number(t)*1e3)/10).toFixed(1)+`%`}function Vx(e,t){return Number(e&&e.summary&&e.summary[t]||0)}function Hx(e){let t=Number(e);return Number.isFinite(t)?t>=6e4?(t/6e4).toFixed(1)+` min`:t>=1e3?(t/1e3).toFixed(2)+` s`:Math.round(t)+` ms`:`-`}function Ux(e){let t=e&&e.summary?e.summary.avg_duration_ms:null;return t==null?`—`:Hx(Number(t))}function Wx(e,t){try{let n={};return new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,hourCycle:`h23`}).formatToParts(e).forEach(e=>{n[e.type]=e.value}),{year:n.year,month:n.month,day:n.day,hour:Number(n.hour)}}catch{return{year:String(e.getFullYear()),month:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()],day:String(e.getDate()),hour:e.getHours()}}}function Gx(e,t,n){let r=new Date(e.start);if(Number.isNaN(r.getTime()))return String(e.start||``);let i=Wx(r,n),a=i.month+` `+i.day;return t!==`hour`||i.hour===0?a:String(i.hour).padStart(2,`0`)+`:00`}function Kx(e,t,n,r){let i=new Date(e.start);if(Number.isNaN(i.getTime()))return String(e.start||``);if(t===`hour`)return r(e.start);let a=Wx(i,n);return a.month+` `+a.day+`, `+a.year}function qx(e){return{ok:e(`var(--success)`),clientError:e(`var(--warning)`),serverError:e(`var(--danger)`),other:e(`color-mix(in srgb, var(--text-muted) 55%, transparent)`)}}function Jx(e,t,n={}){let r=n.interval===`hour`?`hour`:`day`,i=n.zone,a=n.resolve||(e=>e),o=n.formatTimestamp||(e=>String(e)),s=t.map(e=>Gx(e,r,i)),c=qx(a),l=a(`var(--bg-surface)`),u=e=>Number(e)||0,d=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:l,borderWidth:1,borderSkipped:!1,borderRadius:2,maxBarThickness:28}),f=[d(`2xx`,t.map(e=>u(e.status_2xx)),c.ok),d(`4xx`,t.map(e=>u(e.status_4xx)),c.clientError),d(`5xx`,t.map(e=>u(e.status_5xx)),c.serverError)];return t.some(e=>u(e.status_other)>0)&&f.push(d(`Other`,t.map(e=>u(e.status_other)),c.other)),{type:`bar`,data:{labels:s,datasets:f},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ly(e,{title:e=>e.length?Kx(t[e[0].dataIndex],r,i,o):``,label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Iy(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),precision:0,callback:e=>lc(e)}}}}}}function Yx(e=By()){let t={};return function(n){return n in t||(t[n]=e[Object.keys(t).length%e.length]),t[n]}}function Xx(e,t,n,r={}){let i=r.interval===`hour`?`hour`:`day`,a=r.zone,o=r.formatTimestamp||(e=>String(e)),s=r.providerColor||Yx();return{type:`line`,data:{labels:t.map(e=>Gx(e,i,a)),datasets:n.map(e=>({label:e.provider,data:(e.avg_duration_ms||[]).map(e=>e==null?null:Number(e)),borderColor:s(e.provider),backgroundColor:s(e.provider),fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4,spanGaps:i===`hour`&&2}))},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ly(e,{title:e=>e.length?Kx(t[e[0].dataIndex],i,a,o):``,label:e=>{let t=(n[e.datasetIndex]&&n[e.datasetIndex].requests||[])[e.dataIndex],r=Number(t)||0;return e.dataset.label+`: `+Hx(e.parsed.y)+(r>0?` (`+r.toLocaleString()+` req)`:``)}})},scales:{x:{grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),callback:e=>Hx(e)}}}}}}var Zx=class{#e=k(j(Ib()));get status(){return I(this.#e)}set status(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=k(!1);get loadedOnce(){return I(this.#n)}set loadedOnce(e){A(this.#n,e,!0)}#r=k(!1);get detailsExpanded(){return I(this.#r)}set detailsExpanded(e){A(this.#r,e,!0)}#i=k(j({}));get cardOverrides(){return I(this.#i)}set cardOverrides(e){A(this.#i,e,!0)}#a=null;#o=null;#s=!1;initPreferences(){if(this.#s)return;this.#s=!0;let e=Lb(Ca());this.detailsExpanded=e.detailsExpanded,this.cardOverrides=e.cardOverrides}cardExpanded(e){return Bb(this.cardOverrides,this.detailsExpanded,e)}toggleCard(e){let t=e&&e.name?String(e.name):``;if(!t)return;let n={...this.cardOverrides};n[t]=!this.cardExpanded(e),this.cardOverrides=n,zb(Ca(),this.cardOverrides)}toggleDetails(){this.detailsExpanded=!this.detailsExpanded,this.cardOverrides={},Rb(Ca(),this.detailsExpanded),zb(Ca(),this.cardOverrides)}detailsToggleLabel(){return this.detailsExpanded?`Show Details`:`Hide Details`}async fetch(){this.initPreferences(),this.#a&&this.#a.abort();let e=new AbortController;this.#a=e,this.loading=!0;try{let t=await gs(`/admin/providers/status`,{label:`provider status`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.status=Ib(),this.#l();return}let n=t.data&&typeof t.data==`object`?t.data:Ib();n.summary||=Ib().summary,Array.isArray(n.providers)||(n.providers=[]),this.status=n,this.#c()}catch(e){if(vs(e))return;console.error(`Failed to fetch provider status:`,e),this.status=Ib(),this.#l()}finally{this.#a===e&&(this.#a=null,this.loading=!1,this.loadedOnce=!0)}}#c(){this.#l(),Kb(this.status.providers)&&(this.#o=setTimeout(()=>{this.#o=null,this.fetch()},Nb))}#l(){this.#o&&=(clearTimeout(this.#o),null)}stopPolling(){this.#l()}},Qx=class{#e=k(j(Ix()));get stats(){return I(this.#e)}set stats(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=0;async fetch(){let e=++this.#n;this.loading=!0;try{let t=await gs(`/admin/audit/stats?`+jc.queryStr(),{label:`audit stats`});if(t.stale||e!==this.#n)return;if(!t.ok){this.stats=Ix();return}this.stats=Lx(t.data)}catch(t){if(console.error(`Failed to fetch audit stats:`,t),e!==this.#n)return;this.stats=Ix()}finally{e===this.#n&&(this.loading=!1)}}},$x=class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!1);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}async fetch(){if(await xs.ensureLoaded(),!xs.mcpVisible()){this.available=!1,this.servers=[];return}this.loading=!0;try{let e=await gs(`/admin/mcp-servers`,{label:`mcp servers`});if(e.stale)return;if(e.status===503||e.status===404){this.available=!1,this.servers=[];return}if(this.available=!0,!e.ok){this.servers=[];return}this.servers=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch MCP servers:`,e),this.servers=[]}finally{this.loading=!1}}},eS=class{#e=k(j([]));get data(){return I(this.#e)}set data(e){A(this.#e,e,!0)}#t=k(`tokens`);get mode(){return I(this.#t)}set mode(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=null;async fetch(){this.#r&&this.#r.abort();let e=new AbortController;this.#r=e,this.loading=!0;try{let t=await gs(`/admin/usage/daily?days=365&interval=daily`,{label:`calendar`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.data=[];return}this.data=Array.isArray(t.data)?t.data:[]}catch(e){if(vs(e))return;console.error(`Failed to fetch calendar data:`,e),this.data=[]}finally{this.#r===e&&(this.#r=null,this.loading=!1)}}},tS=new Zx,nS=new Qx,rS=new $x,iS=new eS,aS=(e,t=f,n=f,r=f,i=f)=>{var a=sS(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=M(c),u=M(l),d=M(u,!0);T(u),Ue(),T(l);var p=P(l,4),m=M(p),h=M(m,!0);T(m),Ue(),T(p);var g=P(p,4),_=M(g,!0);T(g),T(c),T(a),F((e,n,r,i,a,o)=>{B(s,t()),W(l,`title`,e),B(d,n),W(p,`title`,r),B(h,i),W(g,`title`,a),B(_,o)},[()=>uc(`Input tokens`,n()),()=>lc(n()),()=>uc(`Output tokens`,r()),()=>lc(r()),()=>uc(`Total tokens`,i()),()=>lc(i())]),z(e,a)},oS=(e,t=f,n=f,r=f,i=f,a=f,o=f)=>{var s=uS(),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u);var p=P(u,2),m=e=>{var t=cS(),n=M(t,!0);T(t),F(()=>{W(t,`aria-label`,o().title),W(t,`title`,o().title),B(n,a())}),L(`click`,t,function(...e){o().onclick?.apply(this,e)}),z(e,t)},h=e=>{var t=lS(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(p,e=>{o()?e(m):e(h,-1)}),T(s),F(()=>{U(s,1,`card provider-status-flag ${t()??``} ${n()??``}`,`svelte-6tr9cf`),B(l,r()),B(d,i())}),z(e,s)},sS=R(`
        i + o =
        `),cS=R(``),lS=R(` `),uS=R(`
        `),dS=R(`
        Cache Hits
        `),fS=R(`
        Total Requests
        Estimated Cost
        Prompt Cache Rate
        `);function pS(e,t){E(t,!0);let n=O(()=>Lc.summary),r=O(()=>Lc.cacheOverview),i=O(()=>Lc.cacheAnalyticsEnabled()),a=O(()=>tS.status.summary);function o(){let e=document.getElementById(`provider-status-section`);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),e.focus({preventScroll:!0}))}var s=fS(),c=M(s);{let e=O(()=>db(I(n)));aS(c,()=>`Tokens`,()=>I(n).total_input_tokens,()=>I(n).total_output_tokens,()=>I(e))}var l=P(c,2),u=P(M(l),2),d=M(u,!0);T(u),T(l);var f=P(l,2),p=e=>{var t=dS(),n=P(M(t),2),i=M(n,!0);T(n),T(t),F(e=>B(i,e),[()=>ac(I(r).summary.total_hits)]),z(e,t)};V(f,e=>{I(i)&&e(p)});var m=P(f,2),h=P(M(m),2),g=M(h,!0);T(h),T(m);var _=P(m,2),v=e=>{{let t=O(()=>hb(I(r)));aS(e,()=>`Local Cache`,()=>I(r).summary.total_input_tokens,()=>I(r).summary.total_output_tokens,()=>I(t))}};V(_,e=>{I(i)&&e(v)});var y=P(_,2),b=P(M(y),2),x=M(b);Ay(x,{build:()=>Ab(Eb(I(n)),Ry(`var(--token-prompt)`),Ry(`var(--bg-surface-hover)`))});var S=P(x,2),C=M(S,!0);T(S),T(b),T(y);var w=P(y,2),ee=e=>{{let t=O(()=>Vb(I(a))),n=O(()=>Ub(I(a))),r=O(()=>Gb(I(a))),i=O(()=>Wb(I(a))?{title:`View providers overview`,onclick:o}:null);oS(e,()=>`provider-status-overview-card`,()=>I(t),()=>`Provider Status`,()=>I(n),()=>I(r),()=>I(i))}};V(w,e=>{I(a).total>0&&e(ee)});var te=P(w,2),ne=e=>{{let t=O(()=>Px(rS.servers)),n=O(()=>Nx(rS.servers)),r=O(()=>Fx(rS.servers));oS(e,()=>`mcp-servers-flag`,()=>I(t),()=>`MCP Servers`,()=>I(n),()=>I(r),()=>({title:`View MCP servers`,onclick:()=>qo.navigate(`mcp-servers`)}))}},re=O(()=>Mx(rS.available,rS.servers));V(te,e=>{I(re)&&e(ne)}),T(s),F((e,t,n,r,i)=>{W(u,`title`,e),B(d,t),B(g,n),W(b,`aria-label`,r),B(C,i)},[()=>mb(I(n),I(r),I(i)),()=>ac(pb(I(n),I(r),I(i))),()=>oc(I(n).total_cost),()=>`Prompt cache rate `+Ob(I(n)),()=>Ob(I(n))]),z(e,s),D()}Hr([`click`]);var mS=R(` `),hS=R(`
        `),gS=R(`No usage in the selected period yet`),_S=R(`
        `),vS=R(`

        Tokens

        Share of input tokens over the selected period
        `);function yS(e,t){E(t,!0);let n=O(()=>Lc.cacheAnalyticsEnabled()),r=O(()=>yb(Lc.summary,Lc.cacheOverview,I(n))),i=O(()=>bb(Lc.summary,Lc.cacheOverview,I(n))),a=O(()=>vb(Lc.summary,Lc.cacheOverview,I(n)));var o=vS(),s=P(M(o),2);let c;var l=M(s);H(l,17,()=>I(i),e=>e.key,(e,t)=>{var n=hS(),r=M(n),i=e=>{var n=mS(),r=M(n);T(n),F(()=>B(r,`${I(t).pct??``}%`)),z(e,n)};V(r,e=>{I(t).pct>=8&&e(i)}),T(n),F(e=>{Hi(n,`width: ${I(t).pct??``}%; background: var(${I(t).colorVar??``})`),W(n,`title`,e)},[()=>xb(I(t))]),z(e,n)});var u=P(l,2),d=e=>{z(e,gS())};V(u,e=>{I(a)||e(d)}),T(s);var f=P(s,2);H(f,21,()=>I(r),e=>e.key,(e,t)=>{var n=_S(),r=M(n),i=P(r,2),a=M(i,!0);T(i);var o=P(i,2),s=M(o);T(o);var c=P(o,2),l=M(c,!0);T(c),T(n),F((e,i)=>{W(n,`title`,e),Hi(r,`background: var(${I(t).colorVar??``})`),B(a,I(t).label),B(s,`${I(t).pct??``}%`),B(l,i)},[()=>xb(I(t)),()=>ac(I(t).tokens)]),z(e,n)}),T(f),T(o),F(e=>{c=U(s,1,`cache-meter-bar svelte-1yzecxj`,null,c,{"is-empty":!I(a)}),W(s,`aria-label`,e)},[()=>Sb(I(i))]),z(e,o),D()}var bS=R(``);function xS(e,t){let n=G(t,`size`,3,16),r=G(t,`label`,3,`Loading`),i=G(t,`class`,3,``);var a=bS();F(()=>{U(a,1,Fi([`spinner`,i()]),`svelte-b54l9o`),Hi(a,`--spinner-size: ${n()??``}px`),W(a,`aria-label`,r())}),z(e,a)}var SS=Xr(` `),CS=Xr(``);function wS(e,t){let n=G(t,`label`,3,`No data`);var r=CS(),i=P(M(r),9),a=e=>{var t=SS(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(i,e=>{n()&&e(a)}),T(r),F(()=>{W(r,`role`,n()?`img`:void 0),W(r,`aria-label`,n()||void 0),W(r,`aria-hidden`,n()?void 0:`true`)}),z(e,r)}var TS=R(`
        `),ES=R(`

        `);function DS(e,t){E(t,!0);let n=[`daily`,`weekly`,`monthly`,`yearly`];function r(e){jc.interval=e,t.onintervalchange?.()}function i(){let e=Lc.daily;if(e.length===0)return null;let t=jc.rangeStart(),n=jc.rangeEnd(),r=Tb(wb(e,jc.interval,t,n),wb(Array.isArray(Lc.cacheOverview.daily)?Lc.cacheOverview.daily:[],jc.interval,t,n));return kb(Fy(),r,{cacheEnabled:Lc.cacheAnalyticsEnabled(),resolve:Ry})}var a=ES(),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2);{let e=O(()=>n.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})));Ny(l,{ariaLabel:`Usage chart interval`,get options(){return I(e)},get value(){return jc.interval},onchange:r})}T(o);var u=P(o,2),d=M(u);Ay(d,{build:i});var f=P(d,2),p=e=>{var t=TS();xS(M(t),{size:24,label:`Loading usage`}),T(t),z(e,t)},m=e=>{var t=TS();wS(M(t),{}),T(t),z(e,t)};V(f,e=>{Lc.daily.length===0&&Lc.loading?e(p):Lc.daily.length===0&&!q.authError&&e(m,1)}),T(u),T(a),F(e=>B(c,e),[()=>jc.chartTitle()]),z(e,a),D()}var OS=10,kS=.7;function AS(e,t){if(e<=0||t<=0)return 0;let n=(e/t)**+kS,r=Math.ceil(n*OS);return r<1?1:r>OS?OS:r}function jS(){let e=[];for(let t=0;t<=OS;t++)e.push(t);return e}function MS(e,t,n){let r={};(e||[]).forEach(e=>{r[e.date]=e});let i=Zo($o(n,-364)),a=i.getUTCDay();i.setUTCDate(i.getUTCDate()-a);let o=[];for(let e=new Date(i);Qo(e)<=n;e.setUTCDate(e.getUTCDate()+1)){let n=Qo(e),i=r[n],a=0;i&&(a=t===`costs`?i.total_cost==null?0:i.total_cost:i.total_tokens||0),o.push({dateStr:n,value:a,level:0,empty:!1})}let s=0;for(let e=0;es&&(s=o[e].value);for(let e=0;e0){for(;l.length<7;)l.push({dateStr:``,value:0,level:0,empty:!0});c.push(l)}return c}function NS(e){let t=Zo($o(e,-364)),n=t.getUTCDay();t.setUTCDate(t.getUTCDate()-n);let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],i=[],a={},o=0;for(let n=new Date(t);Qo(n)<=e;n.setUTCDate(n.getUTCDate()+7),o++){let t=null;if(o===0)t=new Date(n);else for(let r=0;r<7;r++){let i=new Date(n);if(i.setUTCDate(n.getUTCDate()+r),Qo(i)>e)break;if(i.getUTCDate()===1){t=i;break}}if(!t)continue;let s=t.getUTCFullYear()+`-`+t.getUTCMonth();a[s]||(i.push({label:r[t.getUTCMonth()],col:o,key:s}),a[s]=!0)}for(let e=0;e `),LS=R(`
        `),RS=R(`
        `),zS=R(`
        `),BS=R(`
        `),VS=R(`

        Activity

        Mon Wed Fri
        `,1);function HS(e,t){E(t,!0);let n=k(j({show:!1,x:0,y:0,text:``})),r=O(()=>us.currentDateKey()),i=O(()=>MS(iS.data,iS.mode,I(r))),a=O(()=>NS(I(r)));function o(e,t){t.empty||A(n,{show:!0,x:e.clientX,y:e.clientY,text:FS(t,iS.mode)},!0)}function s(){A(n,{show:!1,x:0,y:0,text:``},!0)}var c=VS(),l=N(c),u=M(l),d=P(M(u),2),f=e=>{xS(e,{size:14,label:`Loading activity`})};V(d,e=>{iS.loading&&iS.data.length===0&&e(f)}),Ny(P(d,2),{ariaLabel:`Activity calendar mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return iS.mode},onchange:e=>iS.mode=e}),T(u);var p=P(u,2),m=P(M(p),2),h=M(m);H(h,21,()=>I(a),e=>e.key,(e,t)=>{var n=IS(),r=M(n,!0);T(n),F(()=>{Hi(n,`grid-column: ${I(t).col+1} / span ${I(t).span??``}`),B(r,I(t).label)}),z(e,n)}),T(h);var g=P(h,2);H(g,21,()=>I(i),oi,(e,t,n)=>{var r=RS();H(r,23,()=>I(t),(e,t)=>n+`-`+t,(e,t)=>{var n=LS();F(()=>U(n,1,Fi([`contribution-calendar-cell`,I(t).empty?`empty`:`level-${I(t).level}`]),`svelte-3hfxuq`)),Vr(`mouseenter`,n,e=>o(e,I(t))),Vr(`mouseleave`,n,s),z(e,n)}),T(r),z(e,r)}),T(g),T(m),T(p);var _=P(p,2),v=M(_),y=M(v),b=M(y,!0);T(y),T(v);var x=P(v,2);H(P(M(x),2),16,jS,e=>e,(e,t)=>{var n=zS();F(()=>U(n,1,`contribution-calendar-cell level-${t??``}`,`svelte-3hfxuq`)),z(e,n)}),Ue(2),T(x),T(_),T(l);var S=P(l,2),C=e=>{var t=BS(),r=M(t,!0);T(t),F(()=>{Hi(t,`left: ${I(n).x??``}px; top: ${I(n).y-40}px`),B(r,I(n).text)}),z(e,t)};V(S,e=>{I(n).show&&e(C)}),F(e=>B(b,e),[()=>PS(iS.data,iS.mode)]),z(e,c),D()}var US=R(``),WS=R(`

        `),GS=R(`
        `);function KS(e,t){E(t,!0);let n=G(t,`label`,3,`help`),r=G(t,`text`,3,``),i=G(t,`open`,15,!1),a=G(t,`external`,3,!1),o=O(()=>!!r()||!!t.help||a());var s=GS(),c=M(s),l=M(c);gi(l,()=>t.title??f);var u=P(l,2),d=e=>{var r=US();let a;F(()=>{a=U(r,1,`inline-help-toggle svelte-y40or3`,null,a,{"is-open":i()}),W(r,`aria-label`,(i()?`Hide `:`Show `)+n()),W(r,`aria-expanded`,i()),W(r,`aria-controls`,t.copyId)}),L(`click`,r,()=>i(!i())),z(e,r)};V(u,e=>{I(o)&&e(d)}),gi(P(u,2),()=>t.extra??f),T(c);var p=P(c,2),m=e=>{var n=WS(),i=M(n),a=e=>{var n=Qr();gi(N(n),()=>t.help),z(e,n)},o=e=>{var t=Zr();F(()=>B(t,r())),z(e,t)};V(i,e=>{t.help?e(a):e(o,-1)}),T(n),F(()=>W(n,`id`,t.copyId)),z(e,n)};V(p,e=>{i()&&I(o)&&!a()&&e(m)}),T(s),z(e,s),D()}Hr([`click`]);var qS=R(`

        Provider Latency

        `),JS=R(`
        Avg
        `),YS=R(`

        Requests by Status

        Success 2xx 4xx 5xx
        `,1);function XS(e,t){E(t,!0);let n=Yx(),r=O(()=>nS.stats);function i(){return{interval:I(r).interval,zone:us.effectiveTimezone(),resolve:Ry,formatTimestamp:e=>us.formatTimestamp(e)}}var a=Qr(),o=N(a),s=e=>{var t=YS(),a=N(t),o=M(a),s=P(M(o),2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c);var d=P(c,2),f=P(M(d),4),p=M(f,!0);T(f),T(d);var m=P(d,2),h=P(M(m),4),g=M(h,!0);T(h),T(m);var _=P(m,2),v=P(M(_),4),y=M(v,!0);T(v),T(_),T(s),T(o);var b=P(o,2);Ay(M(b),{build:()=>Jx(Fy(),I(r).buckets,i())}),T(b),T(a);var x=P(a,2),S=e=>{var t=JS(),a=M(t),o=M(a);KS(o,{copyId:`audit-latency-help-copy`,label:`provider latency help`,text:`Average duration of successful requests as measured at the gateway, per provider. Local cache hits and failed requests are excluded; streamed responses count until the stream completes.`,title:e=>{z(e,qS())},$$slots:{title:!0}});var s=P(o,2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c),T(s),T(a);var d=P(a,2);Ay(M(d),{build:()=>Xx(Fy(),I(r).buckets,I(r).provider_latency,{...i(),providerColor:n})}),T(d),T(t),F(e=>B(u,e),[()=>Ux(I(r))]),z(e,t)},C=O(()=>zx(I(r)));V(x,e=>{I(C)&&e(S)}),F((e,t,n,r)=>{B(u,e),B(p,t),B(g,n),B(y,r)},[()=>Bx(I(r)),()=>ac(Vx(I(r),`status_2xx`)),()=>ac(Vx(I(r),`status_4xx`)),()=>ac(Vx(I(r),`status_5xx`))]),z(e,t)},c=O(()=>Rx(I(r)));V(o,e=>{I(c)&&e(s)}),z(e,a),D()}var ZS=(e,t=f,n=f,r)=>{let i=Ot(()=>h(r?.(),!1));var a=eC(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=e=>{var t=QS(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)},u=e=>{var t=$S(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(c,e=>{I(i)?e(l):e(u,-1)}),T(a),F(()=>B(s,t())),z(e,a)},QS=R(` `),$S=R(` `),eC=R(`
        `),tC=R(`

        `),nC=R(`
        Breaker State
        `),rC=R(`
        `),iC=R(`
        Models (Recent Traffic)
        `),aC=R(`
        `),oC=R(`

        `);function sC(e,t){E(t,!0);let n=O(()=>ax(t.provider)),r=O(()=>[[`Base URL`,t.provider.config?.base_url],[`API Version`,t.provider.config?.api_version]].filter(([,e])=>!!e));var i=oC();let a;var o=M(i),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{var n=tC(),r=M(n,!0);T(n),F(()=>B(r,t.provider.last_error)),z(e,n)};V(l,e=>{t.provider.last_error&&e(u)});var d=P(l,2),f=e=>{var r=aC(),i=M(r);{let e=O(()=>ox(t.provider));ZS(i,()=>`Recent Requests`,()=>I(e))}var a=P(i,2),o=e=>{var r=nC(),i=P(M(r),2),a=M(i),o=M(a,!0);T(a),T(i),T(r),F(e=>{U(a,1,Fi([`provider-status-health-state`,I(n)]),`svelte-6y9wjv`),B(o,e)},[()=>ix(t.provider)]),z(e,r)},s=O(()=>rx(t.provider));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{var n=iC(),r=P(M(n),2);H(r,21,()=>sx(t.provider),e=>e.model,(e,t)=>{var n=rC();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F((e,i)=>{r=U(n,1,`provider-status-health-model svelte-6y9wjv`,null,r,{"is-flagged":I(t).flagged}),W(n,`title`,e),B(a,I(t).model),B(s,i)},[()=>lx(I(t)),()=>cx(I(t))]),z(e,n)}),T(r),T(n),z(e,n)},u=O(()=>sx(t.provider).length>0);V(c,e=>{I(u)&&e(l)}),T(r),z(e,r)},p=O(()=>nx(t.provider));V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=M(m);H(h,17,()=>I(r),([e,t])=>e,(e,t)=>{var n=O(()=>g(I(t),2));ZS(e,()=>I(n)[0],()=>I(n)[1],()=>!0)});var _=P(h,2);{let e=O(()=>ex(t.provider));ZS(_,()=>`Configured Models`,()=>I(e))}var v=P(_,2);{let e=O(()=>Qb(t.provider));ZS(v,()=>`Retry`,()=>I(e))}var y=P(v,2);{let e=O(()=>$b(t.provider));ZS(y,()=>`Circuit Breaker`,()=>I(e))}T(m),T(o),T(i),F(()=>{a=U(i,1,`provider-status-details svelte-6y9wjv`,null,a,{"is-expanded":t.expanded,"is-collapsed":!t.expanded}),W(i,`aria-hidden`,!t.expanded),B(c,t.provider.status_reason)}),z(e,i),D()}var cC=R(` `),lC=R(``),uC=R(`

        Models Available
        Last Checked
        `);function dC(e,t){E(t,!0);let n=O(()=>tS.cardExpanded(t.provider)),r=e=>us.formatTimestamp(e);var i=uC(),a=M(i),o=M(a),s=M(o),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=e=>{var n=cC(),r=M(n);T(n),F(e=>B(r,`(${e??``})`),[()=>Xb(t.provider)]),z(e,n)},f=O(()=>Xb(t.provider));V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var n=lC();F((e,t,r)=>{W(n,`href`,e),W(n,`aria-label`,t),W(n,`title`,r)},[()=>Zb(t.provider),()=>`View `+(Xb(t.provider)||t.provider.name)+` provider docs`,()=>`View `+(Xb(t.provider)||t.provider.name)+` provider docs`]),z(e,n)},h=O(()=>Zb(t.provider));V(p,e=>{I(h)&&e(m)}),T(s),T(o);var g=P(o,2),_=M(g,!0);T(g),T(a);var v=P(a,2),y=M(v),b=P(M(y),2),x=M(b,!0);T(b),T(y);var S=P(y,2),C=P(M(S),2),w=M(C,!0);T(C),T(S),T(v);var ee=P(v,2);sC(ee,{get provider(){return t.provider},get expanded(){return I(n)}});var te=P(ee,2);let ne;K(M(te),{get icon(){return Va},class:`provider-status-card-toggle-icon`}),T(te),T(i),F((e,r,i,a,o)=>{B(l,t.provider.name),U(g,1,`provider-status-pill ${e??``}`,`svelte-nopjmh`),W(g,`title`,r),B(_,t.provider.status_label),B(x,i),W(C,`title`,a),B(w,o),ne=U(te,1,`provider-status-card-toggle svelte-nopjmh`,null,ne,{"is-expanded":I(n)}),W(te,`aria-expanded`,I(n)),W(te,`aria-label`,(I(n)?`Collapse `:`Expand `)+t.provider.name+` details`),W(te,`title`,I(n)?`Collapse details`:`Expand details`)},[()=>Hb(t.provider.status),()=>tx(t.provider),()=>ac(t.provider.runtime?.discovered_model_count),()=>Yb(t.provider,r),()=>Jb(t.provider,r)]),L(`click`,te,()=>tS.toggleCard(t.provider)),z(e,i),D()}Hr([`click`]);var fC=R(`

        Providers Overview

        `),pC=R(`
        `);function mC(e,t){E(t,!0);let n=O(()=>tS.status.providers);var r=Qr(),i=N(r),a=e=>{var t=fC(),r=M(t),i=P(M(r),2),a=M(i),o=M(a,!0);T(a);var s=P(a,2);let c;T(i),T(r);var l=P(r,2);H(l,21,()=>I(n),e=>e.name,(e,t)=>{dC(e,{get provider(){return I(t)}})}),T(l),T(t),F((e,t)=>{W(i,`aria-checked`,tS.detailsExpanded),W(i,`title`,e),B(o,t),c=U(s,1,`provider-status-toggle-track svelte-1kx3uw4`,null,c,{"is-active":tS.detailsExpanded})},[()=>tS.detailsToggleLabel(),()=>tS.detailsToggleLabel()]),L(`click`,i,()=>tS.toggleDetails()),z(e,t)},o=e=>{var t=pC();xS(M(t),{size:18,label:`Loading provider status`}),T(t),z(e,t)};V(i,e=>{I(n).length>0?e(a):tS.loading&&!tS.loadedOnce&&e(o,1)}),z(e,r),D()}Hr([`click`]);var hC=R(`
        `);function gC(e,t){E(t,!0);function n(){Lc.fetchUsage(),Lc.fetchCacheOverview(``),nS.fetch(),tS.fetch(),rS.fetch(),iS.fetch()}function r(){Lc.fetchUsage(),Lc.fetchCacheOverview(``),nS.fetch()}function i(){r(),iS.fetch()}An(()=>{if(q.refreshTick,qo.page===`overview`)return Er(()=>{n(),ob.start()}),()=>{ob.stop(),tS.stopPolling()}});var a=hC(),o=M(a);ub(o,{});var s=P(o,4);el(M(s),{onchange:i}),T(s);var c=P(s,2);Pc(c,{});var l=P(c,2);pS(l,{});var u=P(l,2);yS(u,{});var d=P(u,2);DS(d,{onintervalchange:r});var f=P(d,2);HS(f,{});var p=P(f,2);XS(p,{}),mC(P(p,2),{}),T(a),z(e,a),D()}var _C=`/admin/live/logs?types=audit,usage`;function vC(e,t,n){return!!t&&String(e&&e.id||``).trim()===t||!!n&&String(e&&e.request_id||``).trim()===n}function yC(e){switch(e){case`date_range`:return`Live paused — the selected date range does not include today. Set it to today to resume.`;case`filters`:return`Live paused while filters are active. Clear them to resume.`;case`pagination`:return`Live paused on later pages. Go to the first page to resume.`;default:return``}}function bC(e){let t=_C,n=Number(e||0);return Number.isFinite(n)&&n>0&&(t+=`&cursor=`+encodeURIComponent(String(n))),t}function xC(){return{async consumeLiveLogsBody(e){await Uy(e,e=>this.applyLiveLogEvent(e))},applyLiveLogEvent(e){if(!e||typeof e!=`object`)return;let t=Number(e.seq||0);Number.isFinite(t)&&t>this.liveLogsLastSeq&&(this.liveLogsLastSeq=t);let n=String(e.type||``).trim();if(n!==`heartbeat`){if(n===`reset`){this.reloadLiveLogSources();return}if(n===`audit.removed`){this.removeLiveAuditEntry(e.data);return}if(n.indexOf(`audit.`)===0){this.mergeLiveAuditEntry(e.data||{},n);return}n.indexOf(`usage.`)===0&&(this.mergeLiveUsageEntry(e.data||{},n),typeof this.noteLiveTokenUsage==`function`&&this.noteLiveTokenUsage(n))}},reloadLiveLogSources(){typeof this.fetchUsage==`function`&&this.fetchUsage(),this.page===`audit-logs`&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},auditLivePauseReason(){return!this.auditLog||this.auditLog.offset!==0?`pagination`:this.auditSearch||this.auditMethod||this.auditStatusCode||this.auditStream?`filters`:!this.followsToday&&(this.customStartDate||this.customEndDate)?`date_range`:null},auditLiveInsertAllowed(){return!this.auditLivePauseReason()},usageLiveInsertAllowed(){return this.usageLog&&this.usageLog.offset===0&&!this.usageLogSearch&&!this.usageFilterModel&&!this.usageFilterProvider&&!this.usageFilterLabel&&!this.usageFilterUserPath},mergeLiveAuditEntry(e,t){if(!e||typeof e!=`object`)return;let n=String(e.id||e.request_id||``).trim();if(!n)return;let r=String(e.request_id||``).trim(),i=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],a=i.findIndex(e=>vC(e,n,r)),o=a>=0&&i[a]||{},s=t===`audit.detail`,c=s?{...e,_detail_loaded:!0,_response_partial:!1,bodies_omitted:!1}:this.liveAuditPatch(o,e,t);if(a>=0){let e=this.mergeLiveAuditPatch(o,c);return i.splice(a,1,e),this.auditLog.entries=[...i],this.regroupLiveAuditHead(e),s||this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}let l=this.mergeLiveAuditChild(e,c);if(l)return s||this.fetchExpandedAuditDetailIfReady(l),this.cacheMergedAuditRecord(l,t),l;if(!this.auditLiveInsertAllowed()){this.cacheMergedAuditRecord(c,t);return}if(!s&&this.auditGroupSessions){let e=this.foldLiveAuditIntoThread(c);if(e)return this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}this.auditLog.entries=[this.mergeLiveAuditUsagePatch(c),...i].slice(0,this.auditLog.limit||25),this.auditLog.total=Number(this.auditLog.total||0)+1;let u=this.auditLog.entries[0];return s||this.fetchExpandedAuditDetailIfReady(u),this.cacheMergedAuditRecord(u,t),u},liveAuditPatch(e,t,n){let r=this.liveAuditStateAfter(e._live_state,n),i=this.liveAuditEventFlushed(e._live_state)||this.liveAuditEventFlushed(r),a={...t,_live:!0,_live_state:r,_audit_flushed:i,_live_pending:!i};return n===`audit.stream`?a._response_partial=!0:this.liveAuditStateSettled(n)&&(a._response_partial=!1),a},mergeLiveAuditChild(e,t){let n=this.auditThreadChildren;if(!n||typeof n!=`object`)return null;let r=String(e.id||``).trim(),i=String(e.request_id||``).trim(),a=Object.keys(n);for(let e=0;evC(e,r,i));if(c<0)continue;let l=this.mergeLiveAuditPatch(s[c]||{},t),u=[...s];return u.splice(c,1,l),this.auditThreadChildren={...n,[a[e]]:{...o,entries:u}},l}return null},regroupLiveAuditHead(e){if(!this.auditGroupSessions)return null;let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=String(e.id||``).trim(),i=n.findIndex(e=>String(e.id||``).trim()===r);if(i<0)return null;let a=n.findIndex((e,n)=>n!==i&&String(e.session_id||``).trim()===t);if(a<0)return null;let o=n[a],s=Date.parse(o&&o.timestamp),c=Date.parse(e&&e.timestamp),l=Number.isFinite(s)&&Number.isFinite(c)&&s>c,u=l?o:e,d=l?e:o,f={...u,session_count:Math.max(1,Number(o.session_count||1))+Math.max(1,Number(e.session_count||1))},p=n.filter((e,t)=>t!==i&&t!==a);return p.unshift(f),this.auditLog.entries=p,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-1),this.prependLiveAuditThreadChild(t,d),f},foldLiveAuditIntoThread(e){let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(e=>String(e.session_id||``).trim()===t);if(r<0)return null;let i=n[r],a=Number(i.session_count),o=this.mergeLiveAuditUsagePatch({...e,session_count:(Number.isFinite(a)&&a>0?a:1)+1}),s=[...n];return s.splice(r,1),s.unshift(o),this.auditLog.entries=s,this.prependLiveAuditThreadChild(t,i),o},prependLiveAuditThreadChild(e,t){let n=this.auditThreadChildren||{},r=n[e],i={...t};delete i.session_count;let a=r&&Array.isArray(r.entries)?{...r,entries:[i,...r.entries],total:Number(r.total||r.entries.length)+1}:{loading:!1,loaded:!1,entries:[i],total:1};this.auditThreadChildren={...n,[e]:a}},removeLiveAuditThreadChild(e,t){let n=this.auditThreadChildren;!n||typeof n!=`object`||Object.keys(n).forEach(r=>{let i=n[r],a=i&&Array.isArray(i.entries)?i.entries:[],o=a.filter(n=>!vC(n,e,t)),s=a.length-o.length;s!==0&&(this.auditThreadChildren={...this.auditThreadChildren,[r]:{...i,entries:o,total:Math.max(0,Number(i.total||a.length)-s)}},this.decrementLiveAuditThreadCount(r,s))})},decrementLiveAuditThreadCount(e,t){let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(t=>String(t.session_id||``).trim()===e);if(r<0)return;let i=n[r],a=[...n];a.splice(r,1,{...i,session_count:Math.max(1,Number(i.session_count||1)-t)}),this.auditLog.entries=a},mergeLiveAuditPatch(e,t){let n={...e,...t};return t.data===void 0&&e.data!==void 0?n.data=e.data:e.data&&t.data&&typeof e.data==`object`&&typeof t.data==`object`&&!Array.isArray(e.data)&&!Array.isArray(t.data)&&(n.data={...e.data,...t.data}),this.mergeLiveAuditUsagePatch(n)},mergeLiveAuditUsagePatch(e){let t=this.liveUsageEntryForAudit(e);if(!t)return e;let n=this.auditEntryWithLiveUsage(e,t);return this.removeSkippedLiveUsage(t),n},liveUsageEntryForAudit(e){let t=String(e&&e.request_id||``).trim();return t&&((this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[]).find(e=>String(e&&e.request_id||``).trim()===t)||this.skippedLiveUsageByRequestId&&this.skippedLiveUsageByRequestId[t])||null},cacheMergedAuditRecord(e,t){return e&&typeof this.cacheAuditRecord==`function`?this.cacheAuditRecord(e,t):e},fetchExpandedAuditDetailIfReady(e){!e||!this.isAuditEntryExpanded||!this.isAuditEntryExpanded(e)||String(e._live_state||``).trim()!==`audit.flushed`&&!e._audit_flushed||typeof this.fetchAuditEntryDetail==`function`&&this.fetchAuditEntryDetail(e)},liveAuditStateRank(e){switch(String(e||``).trim()){case`audit.started`:return 10;case`audit.updated`:case`audit.stream`:return 20;case`audit.completed`:return 30;case`audit.failed`:case`audit.flushed`:case`audit.detail`:return 40;default:return 0}},liveAuditStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveAuditStateRank(n)>this.liveAuditStateRank(r)?n:r},liveAuditStateSettled(e){return this.liveAuditStateRank(e)>=this.liveAuditStateRank(`audit.completed`)},liveAuditEventFlushed(e){let t=String(e||``).trim();return t===`audit.failed`||t===`audit.flushed`||t===`audit.detail`},removeLiveAuditEntry(e){if(!e||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim();if(!t&&!n)return;let r=this.auditLog.entries,i=[],a=0,o=0,s=!1;r.forEach(e=>{if(!vC(e,t,n)){i.push(e);return}a++;let r=String(e.session_id||``).trim(),c=Math.max(1,Number(e.session_count||1));if(!this.auditGroupSessions||!r||c<=1)return;o++;let l=this.auditThreadChildren&&this.auditThreadChildren[r],u=l&&Array.isArray(l.entries)?l.entries.filter(e=>!vC(e,t,n)):[];if(u.length===0){s=!0;return}let d={...u[0],session_id:r,session_count:c-1};i.push(d),this.auditThreadChildren={...this.auditThreadChildren,[r]:{...l,entries:u.slice(1),total:Math.max(0,Number(l.total||c)-1)}}}),a>0&&(this.auditLog.entries=i,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-a+o)),this.removeLiveAuditThreadChild(t,n),s&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},mergeLiveUsageEntry(e,t){if(!e||typeof e!=`object`)return;e={...e,_live_state:t||e._live_state||`usage.completed`};let n=String(e.id||``).trim();if(!n)return;let r=this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[],i=r.findIndex(e=>String(e.id||``).trim()===n);if(i>=0){let t=r[i]||{},n=this.mergeLiveUsagePatch(t,e);if(this.applyLiveUsageToAudit(n),this.liveUsageShouldSkip(n)){r.splice(i,1),this.usageLog.entries=[...r],this.usageLog.total=Math.max(0,Number(this.usageLog.total||0)-1),this.storeSkippedLiveUsage(n);return}r.splice(i,1,n),this.usageLog.entries=[...r],this.removeSkippedLiveUsage(n);return}let a=this.mergeLiveUsagePatch(this.liveUsageSeedForEntry(e),e);if(this.applyLiveUsageToAudit(a),this.liveUsageShouldSkip(a)){this.storeSkippedLiveUsage(a);return}this.removeSkippedLiveUsage(a),this.usageLog.entries=[a,...r].slice(0,this.usageLog.limit||50),this.usageLog.total=Number(this.usageLog.total||0)+1},mergeLiveUsagePatch(e,t){e=e&&typeof e==`object`?e:{};let n=this.liveUsageStateAfter(e._live_state,t&&t._live_state),r=this.liveUsageEventFlushed(e)||this.liveUsageEventFlushed({...t,_live_state:n});return{...e,...t,_live:!0,_live_state:n||`usage.completed`,_live_pending:!r,_usage_flushed:r}},liveUsageShouldSkip(e){return!!(this.usageLogHideCached&&this.liveUsageEntryCached(e))||!this.usageLiveInsertAllowed()},liveUsageSeedForEntry(e){return this.skippedLiveUsageForEntry(e)||this.auditLiveUsageForEntry(e)},skippedLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();return t&&this.skippedLiveUsageByRequestId?this.skippedLiveUsageByRequestId[t]:null},auditLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return null;let n=this.auditLog.entries.find(e=>String(e&&e.request_id||``).trim()===t),r=n&&n.usage&&typeof n.usage==`object`&&!Array.isArray(n.usage)?n.usage:null;return r?{id:e&&e.id,request_id:t,entries:r.entries,input_tokens:r.input_tokens,uncached_input_tokens:r.uncached_input_tokens,cached_input_tokens:r.cached_input_tokens,cache_write_input_tokens:r.cache_write_input_tokens,output_tokens:r.output_tokens,total_tokens:r.total_tokens,cached_input_ratio:r.cached_input_ratio,estimated_cached_characters:r.estimated_cached_characters,_live_state:n._usage_live_state,_live_pending:n._usage_live_pending,_usage_flushed:n._usage_flushed}:null},storeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&((!this.skippedLiveUsageByRequestId||typeof this.skippedLiveUsageByRequestId!=`object`||Array.isArray(this.skippedLiveUsageByRequestId))&&(this.skippedLiveUsageByRequestId={}),this.skippedLiveUsageByRequestId[t]=e)},removeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&this.skippedLiveUsageByRequestId&&delete this.skippedLiveUsageByRequestId[t]},liveUsageEntryCached(e){let t=String(e&&e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`||!!(e&&e.cache_hit)},liveUsageEventFlushed(e){let t=String(e&&e._live_state||``).trim();return!!(e&&e._usage_flushed)||t===`usage.failed`||t===`usage.flushed`},liveUsageStateRank(e){switch(String(e||``).trim()){case`usage.completed`:return 10;case`usage.failed`:case`usage.flushed`:return 20;default:return 0}},liveUsageStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveUsageStateRank(n)>this.liveUsageStateRank(r)?n:r},applyLiveUsageToAudit(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let n=this.auditLog.entries.findIndex(e=>String(e.request_id||``).trim()===t);if(n>=0){let t=this.auditLog.entries[n];this.auditLog.entries.splice(n,1,this.auditEntryWithLiveUsage(t,e)),this.auditLog.entries=[...this.auditLog.entries]}let r=this.auditThreadChildren;if(!r||typeof r!=`object`)return;let i=r,a=!1;Object.keys(r).forEach(n=>{let r=i[n],o=r&&Array.isArray(r.entries)?r.entries:[],s=o.findIndex(e=>String(e.request_id||``).trim()===t);if(s<0)return;let c=[...o];c.splice(s,1,this.auditEntryWithLiveUsage(o[s],e)),i={...i,[n]:{...r,entries:c}},a=!0}),a&&(this.auditThreadChildren=i)},auditEntryWithLiveUsage(e,t){let n=this.liveUsageStateAfter(e._usage_live_state,t._live_state||`usage.completed`),r=this.liveUsageEventFlushed({_live_state:n,_usage_flushed:e._usage_flushed||t._usage_flushed});return{...e,usage:this.liveUsageSummary(t,e.usage),_usage_live_state:n||`usage.completed`,_usage_live_pending:!r,_usage_flushed:r}},liveUsageSummary(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=this.liveNumber(e.input_tokens,this.liveNumber(n.input_tokens,0)),i=this.liveNumber(e.output_tokens,this.liveNumber(n.output_tokens,0)),a=this.liveNumber(e.uncached_input_tokens,this.liveNumber(n.uncached_input_tokens,0)),o=this.liveNumber(e.cached_input_tokens,this.liveNumber(n.cached_input_tokens,0)),s=this.liveNumber(e.cache_write_input_tokens,this.liveNumber(n.cache_write_input_tokens,0));r>0&&a+o+s===0&&(a=r);let c=a+o+s||r,l=c+i||this.liveNumber(e.total_tokens,this.liveNumber(n.total_tokens,0)),u=this.liveNumber(e.cached_input_ratio,this.liveNumber(n.cached_input_ratio,c>0?o/c:0));return{entries:Math.max(1,this.liveNumber(e.entries,this.liveNumber(n.entries,1))),input_tokens:c,uncached_input_tokens:a,cached_input_tokens:o,cache_write_input_tokens:s,output_tokens:i,total_tokens:l,cached_input_ratio:u,estimated_cached_characters:this.liveNumber(e.estimated_cached_characters,this.liveNumber(n.estimated_cached_characters,o*4))}},liveNumber(e,t){let n=Number(e);return Number.isFinite(n)?n:t},auditEntryShouldFetchDetail(e){return!e||e._detail_loading||e._detail_loaded||this.auditEntryLiveDetailPending(e)?!1:this.auditEntryNeedsPersistedLiveDetail(e)||e.bodies_omitted?!0:!this.auditEntryHasDetailData(e)},auditEntryLiveDetailPending(e){if(!e||!e._live)return!1;let t=String(e._live_state||``).trim();return t===`audit.failed`||!e._audit_flushed&&t!==`audit.flushed`&&t!==`audit.detail`},auditEntryNeedsPersistedLiveDetail(e){return!!(e&&e._live&&!e._detail_loaded)},auditEntryHasDetailData(e){let t=e&&e.data;return!t||typeof t!=`object`?!1:t.request_headers!==void 0||t.response_headers!==void 0||t.request_body!==void 0||t.response_body!==void 0||t.request_body_too_big_to_handle!==void 0||t.response_body_too_big_to_handle!==void 0||t.user_agent!==void 0||t.api_key_hash!==void 0||t.temperature!==void 0||t.max_tokens!==void 0||t.error_message!==void 0||t.error_code!==void 0},clearAuditDetailLoading(e){if(!e)return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim(),r=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],i=r.find(e=>t&&String(e.id||``).trim()===t?!0:!!(n&&String(e.request_id||``).trim()===n)),a=i||e;a._detail_loading=!1,i&&(this.auditLog.entries=[...r])}}}var SC={"audit.started":10,"audit.updated":20,"audit.stream":20,"audit.completed":30,"audit.failed":40,"audit.flushed":40,"audit.detail":40},CC=new Set(Object.keys(SC));function wC(e){return String(e&&(e.id||e.request_id)||``).trim()}function TC(e,t){let n=e&&typeof e==`object`?e:{},r=t&&typeof t==`object`?t:{},i={...n,...r};r.data==null&&n.data!=null?i.data=n.data:OC(n.data)&&OC(r.data)&&(i.data={...n.data,...r.data});let a=String(n._live_state||``).trim(),o=String(r._live_state||``).trim();return(SC[a]||0)>(SC[o]||0)&&(i._live_state=a),n._audit_flushed&&(i._audit_flushed=!0),i._audit_flushed&&(i._live_pending=!1),n._detail_loaded&&!r._detail_loaded&&(i._detail_loaded=!0,i.bodies_omitted=!1),i.bodies_omitted&&OC(i.data)&&(i.data.request_body!==void 0||i.data.response_body!==void 0)&&(i.bodies_omitted=!1),i}function EC(e,t){let n=Number(t||0);return(Array.isArray(e)?e:[]).filter(e=>Number(e&&e.version||0)>n)}function DC(e){return CC.has(String(e&&e.eventType||``).trim())}function OC(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var kC=200,AC=class{#e=k(j({entries:[],total:0,limit:25,offset:0}));get auditLog(){return I(this.#e)}set auditLog(e){A(this.#e,e,!0)}#t=k(j({entries:[],total:0,limit:50,offset:0}));get usageLog(){return I(this.#t)}set usageLog(e){A(this.#t,e,!0)}#n=k(j({}));get auditRecords(){return I(this.#n)}set auditRecords(e){A(this.#n,e,!0)}#r=k(j([]));get auditRecordChanges(){return I(this.#r)}set auditRecordChanges(e){A(this.#r,e,!0)}auditRecordVersion=0;auditRecordPins=new Set;#i=k(``);get auditSearch(){return I(this.#i)}set auditSearch(e){A(this.#i,e,!0)}#a=k(``);get auditMethod(){return I(this.#a)}set auditMethod(e){A(this.#a,e,!0)}#o=k(``);get auditStatusCode(){return I(this.#o)}set auditStatusCode(e){A(this.#o,e,!0)}#s=k(``);get auditStream(){return I(this.#s)}set auditStream(e){A(this.#s,e,!0)}#c=k(wa(`gomodel_audit_group_sessions`,`true`)!==`false`);get auditGroupSessions(){return I(this.#c)}set auditGroupSessions(e){A(this.#c,e,!0)}#l=k(j({}));get auditThreadChildren(){return I(this.#l)}set auditThreadChildren(e){A(this.#l,e,!0)}#u=k(``);get usageLogSearch(){return I(this.#u)}set usageLogSearch(e){A(this.#u,e,!0)}#d=k(``);get usageFilterModel(){return I(this.#d)}set usageFilterModel(e){A(this.#d,e,!0)}#f=k(``);get usageFilterProvider(){return I(this.#f)}set usageFilterProvider(e){A(this.#f,e,!0)}#p=k(``);get usageFilterLabel(){return I(this.#p)}set usageFilterLabel(e){A(this.#p,e,!0)}#m=k(``);get usageFilterUserPath(){return I(this.#m)}set usageFilterUserPath(e){A(this.#m,e,!0)}#h=k(!1);get usageLogHideCached(){return I(this.#h)}set usageLogHideCached(e){A(this.#h,e,!0)}#g=k(!1);get liveLogsStreaming(){return I(this.#g)}set liveLogsStreaming(e){A(this.#g,e,!0)}liveLogsLastSeq=0;liveLogsReconnectAttempts=0;liveLogsReconnectTimer=null;liveLogsController=null;skippedLiveUsageByRequestId=null;fetchUsage=null;fetchAuditLog=null;isAuditEntryExpanded=null;noteLiveTokenUsage=null;upsertAuditRecord(e,t=``){let n=wC(e);if(!n)return e;let r=TC(this.auditRecords[n],e);return this.auditRecords={...this.auditRecords,[n]:r},this.pruneAuditRecords(),this.auditRecordVersion++,this.auditRecordChanges=[...this.auditRecordChanges,{version:this.auditRecordVersion,key:n,eventType:t}].slice(-512),r}upsertAuditRecords(e,t=``){return(Array.isArray(e)?e:[]).map(e=>this.upsertAuditRecord(e,t))}auditRecord(e){let t=typeof e==`string`?String(e).trim():wC(e);return t&&this.auditRecords[t]||null}cacheAuditRecord(e,t){return this.upsertAuditRecord(e,t)}pinAuditRecords(e){this.auditRecordPins=new Set((Array.isArray(e)?e:[]).map(String))}pruneAuditRecords(){let e=Object.keys(this.auditRecords);if(e.length<=kC)return;let t={...this.auditRecords},n=e.length-kC;for(let r of e){if(n<=0)break;this.auditRecordPins.has(r)||(delete t[r],n--)}this.auditRecords=t}get page(){return qo.page}get customStartDate(){return jc.customStartDate}get customEndDate(){return jc.customEndDate}get followsToday(){return jc.followsToday}liveLogsEnabled(){return xs.liveLogsVisible()}async startLiveLogs(){typeof fetch!=`function`||typeof ReadableStream>`u`||(await xs.ensureLoaded(),this.liveLogsEnabled()&&(this.stopLiveLogs(),this.liveLogsController=typeof AbortController==`function`?new AbortController:null,this.readLiveLogsStream(this.liveLogsController)))}stopLiveLogs(){this.liveLogsStreaming=!1,this.liveLogsReconnectTimer&&=(clearTimeout(this.liveLogsReconnectTimer),null),this.liveLogsController&&typeof this.liveLogsController.abort==`function`&&this.liveLogsController.abort(),this.liveLogsController=null}ensureLiveLogs(){this.liveLogsController||this.liveLogsReconnectTimer||this.startLiveLogs()}async readLiveLogsStream(e){let t={};e&&(t.signal=e.signal);let n=bC(this.liveLogsLastSeq),r=q.generation;try{let i=await ms(n,t);if(i.status===401){if(q.handleUnauthorized(r),r{this.liveLogsReconnectTimer=null,this.startLiveLogs()},t)}async fetchAuditEntryDetail(e){if(!this.auditEntryShouldFetchDetail(e))return;let t=String(e.id||``).trim();if(!t)return;e._detail_loading=!0;let n=e;try{let e=await gs(`/admin/audit/detail?log_id=`+encodeURIComponent(t),{label:`audit detail`});if(e.stale||!e.ok)return;n=this.mergeLiveAuditEntry(e.data,`audit.detail`)||n}catch(e){console.error(`Failed to fetch audit detail:`,e)}finally{this.clearAuditDetailLoading(n)}}};Object.assign(AC.prototype,xC());var jC=new AC;if(typeof window<`u`){let e=!1;window.addEventListener(`pagehide`,()=>{e=!!jC.liveLogsController,jC.stopLiveLogs()}),window.addEventListener(`pageshow`,t=>{t.persisted&&e&&jC.ensureLiveLogs()})}var MC=null;Mn(()=>{An(()=>{let e=q.refreshTick;if(MC===null){MC=e;return}e!==MC&&(MC=e,Er(()=>{jC.stopLiveLogs(),jC.startLiveLogs()}))})});function NC(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,uncached_input_tokens:0,cached_input_tokens:0,cache_write_input_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null,rewrite_tokens_saved:0,rewrite_cost_saved:null}}function PC(){return{entries:[],total:0,limit:50,offset:0}}function FC(e,t){let n=[[`model`,e&&e.model],[`provider`,e&&e.provider],[`label`,e&&e.label],[`user_path`,e&&e.user_path]],r=``;for(let[e,i]of n)!i||e===t||(r+=`&`+e+`=`+encodeURIComponent(i));return r}function IC({limit:e,offset:t,hideCached:n,search:r}){let i=`&limit=`+e+`&offset=`+t;return i+=`&cache_mode=`+(n?`uncached`:`all`),r&&(i+=`&search=`+encodeURIComponent(r)),i}function LC(e,t){let n=new Set(e||[]);return t&&n.add(t),[...n].sort()}function RC(e,t){let n=Number(t&&t.total_requests||0)-Number(e&&e.total_requests||0);return Number.isFinite(n)&&n>0?n:0}function zC(e,t,n){let r=n?e:t,i=Number(r&&r.total_requests||0);return Number.isFinite(i)?i:0}function BC(e,t,n){let r=RC(e,t);return r<=0?``:n?ac(r)+` cached requests hidden`:ac(Number(e&&e.total_requests||0))+` to providers + `+ac(r)+` from cache`}function VC(e){let t=e||{};return t.total_input_cost===null||t.total_input_cost===void 0?``:oc(t.total_input_cost)+` input + `+oc(t.total_output_cost)+` output`}function HC(e){let t=Number(e&&e.rewrite_tokens_saved||0);return Number.isFinite(t)&&t>0?t:0}function UC(e){return HC(e)>0}function WC(e){let t=e||{};return t.rewrite_cost_saved===void 0?null:t.rewrite_cost_saved}function GC(){return`Estimated at 4 net characters removed per token`}function KC(e,t){return t===`costs`?oc(WC(e)):lc(HC(e))}function qC(e,t){let n=t===`costs`,r=n?Number(WC(e)):HC(e);if(!Number.isFinite(r)||r<=0)return null;let i=e&&(n?e.total_cost:e.total_input_tokens);if(i==null)return null;let a=Number(i);return!Number.isFinite(a)||a<0?null:r/(a+r)*100}function JC(e,t){let n=qC(e,t);return n===null?``:(n<.1?`<0.1`:n.toFixed(1))+`% less`}function YC(e,t){let n=HC(e);if(n<=0)return``;let r=[ac(n)+` estimated prompt token-transmissions removed across provider requests`,GC(),`Savings are summed per provider request; resent conversation history is counted again`],i=WC(e);i!=null&&(r.push(oc(i)+` estimated gross input cost avoided`),r.push(`Prompt-cache changes caused by rewriting are not included`));let a=JC(e,t);return a&&r.push(a+` than the same traffic without rewriting (`+(t===`costs`?`cost`:`tokens`)+`)`),r.join(` +`)}function XC(e){return String(e&&e.cost_source||``).trim()}function ZC(e){let t=XC(e);return t===`openrouter_credits`||t===`xai_cost_in_usd_ticks`}function QC(e){switch(XC(e)){case`openrouter_credits`:return`Costs from OpenRouter USD-based credits.`;case`xai_cost_in_usd_ticks`:return`Costs from xAI usage.cost_in_usd_ticks.`;default:return``}}function $C(e){return String(e&&e.cache_type||``).trim().toLowerCase()}function ew(e){let t=$C(e);return t===`exact`||t===`semantic`}function tw(e){let t=$C(e);return t===`exact`?`Exact`:t===`semantic`?`Semantic`:`-`}function nw(e,t){let n=t?String(t):``;return ew(e)?n?`Saved by cache — not charged +`+n:`Saved by cache — not charged`:n}function rw(e){let t=Number(e&&e.cached_input_ratio);return!Number.isFinite(t)||t<=0?0:Math.min(1,t)}function iw(e){return Number(e&&e.cached_input_tokens||0)>0}function aw(e){return iw(e)?(rw(e)*100).toFixed(1)+`%`:``}function ow(e){if(!iw(e))return``;let t=Number(e.cached_input_tokens||0),n=Number(e.uncached_input_tokens||0),r=Number(e.cache_write_input_tokens||0),i=t+n+r,a=[ac(t)+` cached / `+ac(i)+` input tokens`];return r>0&&a.push(ac(r)+` cache write`),a.join(` +`)}function sw(e){let t=[];if(QC(e)&&(t.push(QC(e)),t.push(``)),t.push(`Input: `+oc(e.input_cost)),t.push(`Output: `+oc(e.output_cost)),e.raw_data){t.push(``);for(let[n,r]of Object.entries(e.raw_data)){let e=n.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),i=r&&typeof r==`object`?JSON.stringify(r):ac(r);t.push(e+`: `+i)}}return t.join(` +`)}function cw(e){return Array.isArray(e&&e.labels)?e.labels:[]}function lw(e,t,n){return(e||[]).length>0||t?!0:(n||[]).some(e=>cw(e).length>0)}function uw(e){return e&&typeof e.total_tokens==`number`?e.total_tokens:(e&&e.input_tokens||0)+(e&&e.output_tokens||0)}function dw(e,t){return t?e.total_cost||0:uw(e)}function fw(e,t){return[...e||[]].sort((e,n)=>t?(n.total_cost||0)-(e.total_cost||0):dw(n,t)-dw(e,t))}function pw(e){let t=Array.isArray(e)?e:[];if(t.length===0)return!1;if(t.length!==1)return!0;let n=String(t[0]&&t[0].user_path||``).trim();return n!==``&&n!==`/`}function mw(e){return(e||`chart`)===`chart`||e===`stacked`}function hw(e,t,n){let r=fw(e,n),i=e=>Number(e)||0,a=e=>n?Math.min(i(e.cached_input_cost),i(e.input_cost)):i(e.cached_input_tokens),o=e=>n?i(e.input_cost)-a(e):i(e.uncached_input_tokens)+i(e.cached_input_tokens)+i(e.cache_write_input_tokens)>0?i(e.uncached_input_tokens)+i(e.cache_write_input_tokens):i(e.input_tokens),s=e=>i(n?e.output_cost:e.output_tokens),c=e=>n?0:i(e.local_cached_input_tokens),l=e=>n?0:i(e.local_cached_output_tokens),u=r.slice(0,10),d=r.slice(10),f=u.map(t),p=u.map(o),m=u.map(s),h=u.map(a),g=u.map(c),_=u.map(l);if(d.length>0){f.push(`Other`);let e=e=>d.reduce((t,n)=>t+e(n),0);p.push(e(o)),m.push(e(s)),h.push(e(a)),g.push(e(c)),_.push(e(l))}return{labels:f,inputs:p,outputs:m,prompts:h,localIns:g,localOuts:_}}function gw(e){return Math.max(200,e*32+72)}var _w=new class{#e=k(`tokens`);get usageMode(){return I(this.#e)}set usageMode(e){A(this.#e,e,!0)}get usageFilterModel(){return jC.usageFilterModel}set usageFilterModel(e){jC.usageFilterModel=e}get usageFilterProvider(){return jC.usageFilterProvider}set usageFilterProvider(e){jC.usageFilterProvider=e}get usageFilterLabel(){return jC.usageFilterLabel}set usageFilterLabel(e){jC.usageFilterLabel=e}get usageFilterUserPath(){return jC.usageFilterUserPath}set usageFilterUserPath(e){jC.usageFilterUserPath=e}#t=k(j({models:[],providers:[],labels:[]}));get usageFacetOptions(){return I(this.#t)}set usageFacetOptions(e){A(this.#t,e,!0)}#n=k(j(NC()));get usageSummary(){return I(this.#n)}set usageSummary(e){A(this.#n,e,!0)}#r=k(j(NC()));get usageSummaryAll(){return I(this.#r)}set usageSummaryAll(e){A(this.#r,e,!0)}#i=k(j([]));get modelUsage(){return I(this.#i)}set modelUsage(e){A(this.#i,e,!0)}#a=k(j([]));get userPathUsage(){return I(this.#a)}set userPathUsage(e){A(this.#a,e,!0)}#o=k(j([]));get labelUsage(){return I(this.#o)}set labelUsage(e){A(this.#o,e,!0)}get usageLog(){return jC.usageLog}set usageLog(e){jC.usageLog=e}get usageLogSearch(){return jC.usageLogSearch}set usageLogSearch(e){jC.usageLogSearch=e}get usageLogHideCached(){return jC.usageLogHideCached}set usageLogHideCached(e){jC.usageLogHideCached=e}#s=k(`chart`);get modelUsageView(){return I(this.#s)}set modelUsageView(e){A(this.#s,e,!0)}#c=k(`chart`);get userPathUsageView(){return I(this.#c)}set userPathUsageView(e){A(this.#c,e,!0)}#l=k(`chart`);get labelUsageView(){return I(this.#l)}set labelUsageView(e){A(this.#l,e,!0)}#u=k(!1);get summaryLoading(){return I(this.#u)}set summaryLoading(e){A(this.#u,e,!0)}#d=k(!1);get modelUsageLoading(){return I(this.#d)}set modelUsageLoading(e){A(this.#d,e,!0)}#f=k(!1);get userPathUsageLoading(){return I(this.#f)}set userPathUsageLoading(e){A(this.#f,e,!0)}#p=k(!1);get labelUsageLoading(){return I(this.#p)}set labelUsageLoading(e){A(this.#p,e,!0)}#m=k(!1);get usageLogLoading(){return I(this.#m)}set usageLogLoading(e){A(this.#m,e,!0)}#h={};#g(e){this.#h[e]&&this.#h[e].abort();let t=new AbortController;return this.#h[e]=t,t}#_(e,t){this.#h[e]===t&&(this.#h[e]=null)}filterQueryStr(e){return FC({model:this.usageFilterModel,provider:this.usageFilterProvider,label:this.usageFilterLabel,user_path:this.usageFilterUserPath},e)}onUsageFilterChanged(){this.fetchUsagePage()}toggleUsageLabelFilter(e){this.usageFilterLabel=this.usageFilterLabel===e?``:e,this.onUsageFilterChanged()}usageLabelChipTitle(e){return this.usageFilterLabel===e?`Clear label filter`:`Filter usage by "`+e+`"`}toggleUsageMode(e){this.usageMode=e,qo.navigate(`usage`,e===`costs`?`costs`:null)}toggleUsageChartView(e,t){e===`model`&&(this.modelUsageView=t),e===`userPath`&&(this.userPathUsageView=t),e===`label`&&(this.labelUsageView=t)}usageFilterModelOptions(){return LC(this.usageFacetOptions.models,this.usageFilterModel)}usageFilterProviderOptions(){return LC(this.usageFacetOptions.providers,this.usageFilterProvider)}usageFilterLabelOptions(){return LC(this.usageFacetOptions.labels,this.usageFilterLabel)}async fetchUsagePage(){await xs.ensureLoaded();let e=[this.fetchUsagePageSummary(),this.fetchUsageFacetOptions(),this.fetchModelUsage(),this.fetchUserPathUsage(),this.fetchLabelUsage(),this.fetchUsageLog(!0)];Lc.cacheAnalyticsEnabled()&&e.push(Lc.fetchCacheOverview(this.filterQueryStr())),await Promise.all(e)}async fetchUsagePageSummary(){let e=this.#g(`summary`);this.summaryLoading=!0;try{let t=jc.queryStr()+this.filterQueryStr(),[n,r]=await Promise.all([gs(`/admin/usage/summary?`+t+`&cache_mode=uncached`,{label:`usage page summary`,signal:e.signal}),gs(`/admin/usage/summary?`+t+`&cache_mode=all`,{label:`usage page summary (all)`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.usageSummary=NC(),this.usageSummaryAll=NC();return}this.usageSummary=n.data&&typeof n.data==`object`?n.data:NC(),this.usageSummaryAll=r.data&&typeof r.data==`object`?r.data:NC()}catch(e){if(vs(e))return;console.error(`Failed to fetch usage page summary:`,e),this.usageSummary=NC(),this.usageSummaryAll=NC()}finally{this.#_(`summary`,e),this.#h.summary===null&&(this.summaryLoading=!1)}}async fetchUsageFacetOptions(){let e=this.#g(`facets`);try{let t=async(t,n)=>{let r=await gs(t+`?`+jc.queryStr()+this.filterQueryStr(n),{label:`usage facet options`,signal:e.signal});return r.stale?null:r.ok&&Array.isArray(r.data)?r.data:[]},n=t(`/admin/usage/models`,`model`),r=!this.usageFilterModel&&!this.usageFilterProvider,[i,a,o]=await Promise.all([n,r?n:t(`/admin/usage/models`,`provider`),t(`/admin/usage/labels`,`label`)]);if(e.signal.aborted||i===null||a===null||o===null)return;this.usageFacetOptions={models:i.map(e=>e&&e.model).filter(Boolean),providers:a.map(e=>hc(e)).filter(Boolean),labels:o.map(e=>e&&e.label).filter(Boolean)}}catch(e){if(vs(e))return;console.error(`Failed to fetch usage facet options:`,e),this.usageFacetOptions={models:[],providers:[],labels:[]}}finally{this.#_(`facets`,e)}}async#v(e,t,n,r,i){let a=this.#g(e);i(!0);try{let e=await gs(t+`?`+jc.queryStr()+this.filterQueryStr(),{label:n,signal:a.signal});if(e.stale||a.signal.aborted)return;if(!e.ok){r([]);return}r(Array.isArray(e.data)?e.data:[])}catch(e){if(vs(e))return;console.error(`Failed to fetch `+n+`:`,e),r([])}finally{this.#_(e,a),this.#h[e]===null&&i(!1)}}fetchModelUsage(){return this.#v(`modelUsage`,`/admin/usage/models`,`usage models`,e=>this.modelUsage=e,e=>this.modelUsageLoading=e)}fetchUserPathUsage(){return this.#v(`userPathUsage`,`/admin/usage/user-paths`,`usage user paths`,e=>this.userPathUsage=e,e=>this.userPathUsageLoading=e)}fetchLabelUsage(){return this.#v(`labelUsage`,`/admin/usage/labels`,`usage labels`,e=>this.labelUsage=e,e=>this.labelUsageLoading=e)}async fetchUsageLog(e){let t=this.#g(`usageLog`);this.usageLogLoading=!0;try{e&&(this.usageLog.offset=0);let n=jc.queryStr()+this.filterQueryStr();n+=IC({limit:this.usageLog.limit,offset:this.usageLog.offset,hideCached:this.usageLogHideCached,search:this.usageLogSearch});let r=await gs(`/admin/usage/log?`+n,{label:`usage log`,signal:t.signal});if(r.stale||t.signal.aborted)return;if(!r.ok){this.usageLog=PC();return}let i=r.data&&typeof r.data==`object`?r.data:PC();i.entries||=[],this.usageLog=i}catch(e){if(vs(e))return;console.error(`Failed to fetch usage log:`,e),this.usageLog=PC()}finally{this.#_(`usageLog`,t),this.#h.usageLog===null&&(this.usageLogLoading=!1)}}usageLogNextPage(){this.usageLog.offset+this.usageLog.limit0&&(this.usageLog.offset=Math.max(0,this.usageLog.offset-this.usageLog.limit),this.fetchUsageLog(!1))}};jC.fetchUsage=()=>{qo.page===`usage`&&_w.fetchUsagePage()};var vw=R(`
        `);function yw(e,t){E(t,!0);let n=G(t,`value`,15,``),r=G(t,`placeholder`,3,``),i=G(t,`label`,3,``),a=G(t,`id`,3,void 0),o=G(t,`oninput`,3,void 0),s=G(t,`class`,3,``);var c=vw(),l=M(c);K(l,{get icon(){return _o},class:`filter-input-icon`});var u=P(l,2);na(u),T(c),F(()=>{U(c,1,Fi([`filter-input-wrap`,s()]),`svelte-30xz1k`),W(u,`id`,a()),W(u,`placeholder`,r()),W(u,`aria-label`,i())}),L(`input`,u,function(...e){o()?.apply(this,e)}),da(u,n),z(e,c),D()}Hr([`input`]);function bw(e,t=300){let n=null,r=(...r)=>{clearTimeout(n),n=setTimeout(()=>{n=null,e(...r)},t)};return r.cancel=()=>{clearTimeout(n),n=null},r}var xw=R(``),Sw=R(``),Cw=R(`
        `);function ww(e,t){E(t,!0);let n=bw(()=>_w.onUsageFilterChanged());An(()=>n.cancel);var r=Cw(),i=M(r),a=M(i);a.value=a.__value=``,H(P(a),16,()=>_w.usageFilterModelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(i);var o=P(i,2),s=M(o);s.value=s.__value=``,H(P(s),16,()=>_w.usageFilterProviderOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(o);var c=P(o,2),l=e=>{var t=Sw(),n=M(t);n.value=n.__value=``,H(P(n),16,()=>_w.usageFilterLabelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(t),L(`change`,t,()=>_w.onUsageFilterChanged()),Gi(t,()=>_w.usageFilterLabel,e=>_w.usageFilterLabel=e),z(e,t)},u=O(()=>_w.usageFilterLabelOptions().length>0);V(c,e=>{I(u)&&e(l)}),yw(P(c,2),{class:`usage-page-filters-user-path`,placeholder:`User path /team/alpha`,label:`Filter by user path`,get oninput(){return n},get value(){return _w.usageFilterUserPath},set value(e){_w.usageFilterUserPath=e}}),T(r),L(`change`,i,()=>_w.onUsageFilterChanged()),Gi(i,()=>_w.usageFilterModel,e=>_w.usageFilterModel=e),L(`change`,o,()=>_w.onUsageFilterChanged()),Gi(o,()=>_w.usageFilterProvider,e=>_w.usageFilterProvider=e),z(e,r),D()}Hr([`change`]);var Tw=R(`
        Cache Saved
        Cache Hits
        `,1);function Ew(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Tw(),n=N(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var a=P(n,2),o=P(M(a),2),s=M(o,!0);T(o),T(a),F((e,t)=>{B(i,e),B(s,t)},[()=>oc(Lc.cacheOverview.summary.total_saved_cost),()=>ac(Lc.cacheOverview.summary.total_hits)]),z(e,t)},a=O(()=>Lc.cacheAnalyticsEnabled());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}var Dw=R(` `),Ow=R(`
        Pro Saved
        `),kw=R(`
        Total Requests
        Estimated Cost
        `);function Aw(e,t){E(t,!0);let n=O(()=>UC(_w.usageSummary)),r=O(()=>KC(_w.usageSummary,_w.usageMode)),i=O(()=>JC(_w.usageSummary,_w.usageMode));var a=kw(),o=M(a),s=P(M(o),2),c=M(s),l=e=>{xS(e,{size:18,label:`Loading usage summary`})},u=e=>{var t=Zr();F(e=>B(t,e),[()=>ac(zC(_w.usageSummary,_w.usageSummaryAll,_w.usageLogHideCached))]),z(e,t)};V(c,e=>{_w.summaryLoading?e(l):e(u,-1)}),T(s),T(o);var d=P(o,2),f=P(M(d),2),p=M(f),m=e=>{xS(e,{size:18,label:`Loading usage summary`})},h=e=>{var t=Zr();F(e=>B(t,e),[()=>oc(_w.usageSummary.total_cost)]),z(e,t)};V(p,e=>{_w.summaryLoading?e(m):e(h,-1)}),T(f),T(d);var g=P(d,2),_=e=>{var t=Ow(),n=P(M(t),2),a=M(n),o=M(a,!0);T(a);var s=P(a,2),c=e=>{var t=Dw(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)};V(s,e=>{I(i)&&e(c)}),T(n),T(t),F(e=>{W(n,`title`,e),B(o,I(r))},[()=>YC(_w.usageSummary,_w.usageMode)]),z(e,t)};V(g,e=>{I(n)&&e(_)}),Ew(P(g,2),{}),T(a),F((e,t)=>{W(s,`title`,e),W(f,`title`,t)},[()=>BC(_w.usageSummary,_w.usageSummaryAll,_w.usageLogHideCached),()=>VC(_w.usageSummary)]),z(e,a),D()}function jw(e,t,n,r){let{stacked:i=!1,costs:a=!1,resolve:o=e=>e}=r||{},s=e=>a?`$`+Math.abs(e).toFixed(2):lc(Math.abs(e)),c=e=>a?`$`+Math.abs(e).toFixed(4):Math.abs(e).toLocaleString(),l=e=>e.map(e=>i?Math.abs(e):-Math.abs(e)),u=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:`transparent`,borderWidth:0,borderRadius:4,maxBarThickness:22}),d=e=>(e||[]).some(e=>Math.abs(e)>0),f=[u(a?`Input Cost`:`Input Tokens`,l(n.inputs),o(`var(--token-input)`)),u(a?`Output Cost`:`Output Tokens`,n.outputs,o(`var(--token-output)`))];return d(n.prompts)&&f.push(u(a?`Prompt Cached Cost`:`Prompt Cached`,l(n.prompts),o(`var(--token-prompt)`))),!a&&d(n.localIns)&&f.push(u(`Locally Cached (Input)`,l(n.localIns),o(`var(--token-local)`))),!a&&d(n.localOuts)&&f.push(u(`Locally Cached (Output)`,n.localOuts,o(`var(--token-local)`))),{type:`bar`,data:{labels:t,datasets:f},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:{top:8}},scales:{x:{stacked:!0,beginAtZero:!0,grid:i?{color:e.grid}:{color:t=>t.tick&&t.tick.value===0?e.text:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),callback:e=>s(e)}},y:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Iy(),autoSkip:!1}}},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ly(e,{label:e=>e.dataset.label+`: `+c(e.parsed.x),footer:e=>{let t=0;return e.forEach(e=>{t+=Math.abs(Number(e.parsed.x))||0}),`Total: `+c(t)}})}}}}var Mw=R(`
        `),Nw=R(`

        `),Pw=R(`

        `,1),Fw=R(`
        `),Iw=R(`Model Provider`,1),Lw=R(`User Path`),Rw=R(`Label Requests`,1),zw=R(` `,1),Bw=R(` `),Vw=R(` `,1),Hw=R(` `),Uw=R(`
        Input TokensOutput TokensPrompt CachedLocal CachedTotal TokensInput CostOutput CostTotal Cost
        `),Ww=R(`
        `),Gw=R(`
        `);function Kw(e,t){E(t,!0);let n=e=>{var n=Mw(),r=M(n);let a;var o=P(r,2);let s;var l=P(o,2);let u;T(n),F(()=>{W(n,`aria-label`,I(i).group),a=U(r,1,`chart-view-btn svelte-1kee4g8`,null,a,{active:I(c)===`chart`}),W(r,`aria-pressed`,I(c)===`chart`),W(r,`aria-label`,`Show ${I(i).noun??``} chart`),s=U(o,1,`chart-view-btn svelte-1kee4g8`,null,s,{active:I(c)===`stacked`}),W(o,`aria-pressed`,I(c)===`stacked`),W(o,`aria-label`,`Show ${I(i).noun??``} stacked chart`),u=U(l,1,`chart-view-btn svelte-1kee4g8`,null,u,{active:I(c)===`table`}),W(l,`aria-pressed`,I(c)===`table`),W(l,`aria-label`,`Show ${I(i).noun??``} table`)}),L(`click`,r,()=>_w.toggleUsageChartView(t.kind,`chart`)),L(`click`,o,()=>_w.toggleUsageChartView(t.kind,`stacked`)),L(`click`,l,()=>_w.toggleUsageChartView(t.kind,`table`)),z(e,n)},r={model:{group:`Model usage view`,noun:`model usage`,tokensTitle:`Token Usage by Model`,costsTitle:`Cost by Model`},userPath:{group:`User path usage view`,noun:`user path usage`,tokensTitle:`Usage by User Path`,costsTitle:`Cost by User Path`},label:{group:`Label usage view`,noun:`label usage`,tokensTitle:`Usage by Label`,costsTitle:`Cost by Label`}},i=O(()=>r[t.kind]),a=O(()=>t.kind===`model`?e=>_c(e):t.kind===`userPath`?e=>e.user_path||`/`:e=>e.label);function o(e){return t.kind===`model`?(e.provider_name||e.provider||`-`)+`/`+e.model:t.kind===`userPath`?e.user_path||`/`:e.label}let s=O(()=>t.kind===`model`?_w.modelUsage:t.kind===`userPath`?_w.userPathUsage:_w.labelUsage),c=O(()=>t.kind===`model`?_w.modelUsageView:t.kind===`userPath`?_w.userPathUsageView:_w.labelUsageView),l=O(()=>t.kind===`model`?_w.modelUsageLoading:t.kind===`userPath`?_w.userPathUsageLoading:_w.labelUsageLoading),u=O(()=>_w.usageMode===`costs`),d=O(()=>t.kind===`userPath`?pw(I(s)):I(s).length>0),f=O(()=>I(u)?I(i).costsTitle:I(i).tokensTitle),p=O(()=>hw(I(s),I(a),I(u))),m=O(()=>fw(I(s),I(u)));function h(){return mw(I(c))?jw(Fy(),I(p).labels,I(p),{stacked:I(c)===`stacked`,costs:I(u),resolve:Ry}):null}var g=Qr(),_=N(g),v=e=>{var r=Ww(),a=M(r),s=M(a),u=e=>{KS(e,{copyId:`label-usage-help-copy`,label:`label usage help`,text:`One request can have multiple labels. Such a request counts once under each of its labels, so label rows can overlap and add up to more than the period totals.`,title:e=>{var t=Nw(),n=M(t,!0);T(t),F(()=>B(n,I(f))),z(e,t)},extra:e=>{var t=Qr(),n=N(t),r=e=>{xS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(n,e=>{I(l)&&e(r)}),z(e,t)},$$slots:{title:!0,extra:!0}})},d=e=>{var t=Pw(),n=N(t),r=M(n,!0);T(n);var a=P(n,2),o=e=>{xS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(a,e=>{I(l)&&e(o)}),F(()=>B(r,I(f))),z(e,t)};V(s,e=>{t.kind===`label`?e(u):e(d,-1)});var g=P(s,2);n(g),T(a);var _=P(a,2),v=e=>{var t=Fw();let n;Ay(M(t),{build:h}),T(t),F(e=>n=Hi(t,``,n,e),[()=>({height:`${gw(I(p).labels.length)??``}px`})]),z(e,t)},y=O(()=>mw(I(c))),b=e=>{var n=Uw(),r=M(n),i=M(r),a=M(i),s=M(a),c=e=>{var t=Iw();Ue(2),z(e,t)},l=e=>{z(e,Lw())},u=e=>{var t=Rw();Ue(2),z(e,t)};V(s,e=>{t.kind===`model`?e(c):t.kind===`userPath`?e(l,1):e(u,-1)}),Ue(8),T(a),T(i);var d=P(i);H(d,21,()=>I(m),e=>o(e),(e,n)=>{var r=Hw(),i=M(r),a=e=>{var t=zw(),r=N(t),i=M(r,!0);T(r);var a=P(r,2),o=M(a),s=M(o,!0);T(o),T(a),F(e=>{B(i,I(n).model||`-`),B(s,e)},[()=>hc(I(n))||`-`]),z(e,t)},o=e=>{var t=Bw(),r=M(t,!0);T(t),F(()=>B(r,I(n).user_path||`/`)),z(e,t)},s=e=>{var t=Vw(),r=N(t),i=M(r);let a;var o=M(i,!0);T(i),T(r);var s=P(r,2),c=M(s,!0);T(s),F((e,t,r)=>{a=U(i,1,`usage-label-chip`,null,a,{active:_w.usageFilterLabel===I(n).label}),Hi(i,`--label-color: ${e??``}`),W(i,`title`,t),B(o,I(n).label),B(c,r)},[()=>Vy(I(n).label),()=>_w.usageLabelChipTitle(I(n).label),()=>ac(I(n).requests)]),L(`click`,i,()=>_w.toggleUsageLabelFilter(I(n).label)),z(e,t)};V(i,e=>{t.kind===`model`?e(a):t.kind===`userPath`?e(o,1):e(s,-1)});var c=P(i),l=M(c,!0);T(c);var u=P(c),d=M(u,!0);T(u);var f=P(u),p=M(f,!0);T(f);var m=P(f),h=M(m,!0);T(m);var g=P(m),_=M(g,!0);T(g);var v=P(g),y=M(v,!0);T(v);var b=P(v),x=M(b,!0);T(b);var S=P(b),C=M(S,!0);T(S),T(r),F((e,t,n,r,i,a,o,s,c,u,g)=>{B(l,e),B(d,t),W(f,`title`,n),B(p,r),W(m,`title`,`${i??``} input + ${a??``} output`),B(h,o),B(_,s),B(y,c),B(x,u),B(C,g)},[()=>ac(I(n).input_tokens),()=>ac(I(n).output_tokens),()=>I(n).cached_input_cost==null?``:`~`+oc(I(n).cached_input_cost)+` at current cached-input pricing`,()=>ac(I(n).cached_input_tokens||0),()=>ac(I(n).local_cached_input_tokens||0),()=>ac(I(n).local_cached_output_tokens||0),()=>ac((I(n).local_cached_input_tokens||0)+(I(n).local_cached_output_tokens||0)),()=>ac(uw(I(n))),()=>oc(I(n).input_cost),()=>oc(I(n).output_cost),()=>oc(I(n).total_cost)]),z(e,r)}),T(d),T(r),T(n),z(e,n)};V(_,e=>{I(y)?e(v):e(b,-1)}),T(r),z(e,r)},y=e=>{var t=Gw();xS(M(t),{size:20,get label(){return`Loading ${I(i).noun??``}`}}),T(t),z(e,t)};V(_,e=>{I(d)?e(v):I(l)&&e(y,1)}),z(e,g),D()}Hr([`click`]);var qw=R(``);function Jw(e,t){E(t,!0);let n=G(t,`total`,3,0),r=G(t,`offset`,3,0),i=G(t,`limit`,3,25);var a=Qr(),o=N(a),s=e=>{var a=qw(),o=M(a),s=M(o);T(o);var c=P(o,2),l=M(c),u=P(l,2);T(c),T(a),F(e=>{B(s,`Showing ${r()+1}-${e??``} of ${n()??``}`),l.disabled=r()===0,u.disabled=r()+i()>=n()},[()=>Math.min(r()+i(),n())]),L(`click`,l,()=>t.onprev?.()),L(`click`,u,()=>t.onnext?.()),z(e,a)};V(o,e=>{n()>0&&e(s)}),z(e,a),D()}Hr([`click`]);var Yw=(e,t=f)=>{var n=Qr(),r=N(n),i=e=>{var n=Zw();H(n,20,()=>cw(t()),e=>e,(e,t)=>{var n=Xw();let r;var i=M(n,!0);T(n),F((e,a)=>{r=U(n,1,`usage-label-chip`,null,r,{active:_w.usageFilterLabel===t}),Hi(n,`--label-color: ${e??``}`),W(n,`title`,a),B(i,t)},[()=>Vy(t),()=>_w.usageLabelChipTitle(t)]),L(`click`,n,()=>_w.toggleUsageLabelFilter(t)),z(e,n)}),T(n),z(e,n)},a=O(()=>cw(t()).length>0),o=e=>{z(e,Qw())};V(r,e=>{I(a)?e(i):e(o,-1)}),z(e,n)},Xw=R(``),Zw=R(`
        `),Qw=R(`-`),$w=R(`Labels`),eT=R(`Cost`),tT=R(``),nT=R(` `),rT=R(``),iT=R(` `),aT=R(` `),oT=R(`
        TimestampProviderModelUser PathCacheProvider Cache
        `),sT=R(`
        `),cT=R(`
        `),lT=R(`

        Request Log

        `);function uT(e,t){E(t,!0);let n=O(()=>_w.usageMode===`costs`),r=O(()=>lw(_w.labelUsage,_w.usageFilterLabel,_w.usageLog.entries)),i=bw(()=>_w.fetchUsageLog(!0));An(()=>i.cancel);var a=lT(),o=P(M(a),2),s=M(o);yw(M(s),{placeholder:`Search by request ID, model, provider...`,label:`Search by request ID, model, provider`,get oninput(){return i},get value(){return _w.usageLogSearch},set value(e){_w.usageLogSearch=e}}),T(s);var c=P(s,2),l=M(c),u=M(l);na(u),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=e=>{var t=oT(),i=M(t),a=M(i),o=M(a),s=P(M(o),4),c=e=>{z(e,$w())};V(s,e=>{I(r)&&e(c)});var l=P(s,3),u=M(l,!0);T(l);var d=P(l),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{z(e,eT())};V(h,e=>{I(n)||e(g)}),T(o),T(a);var _=P(a);H(_,21,()=>_w.usageLog.entries,e=>e.id,(e,t)=>{var i=aT();let a;var o=M(i),s=M(o,!0);T(o);var c=P(o),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{var n=tT();Yw(M(n),()=>I(t)),T(n),z(e,n)};V(h,e=>{I(r)&&e(g)});var _=P(h),v=M(_,!0);T(_);var y=P(_),b=M(y),x=e=>{var n=nT(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>aw(I(t))]),z(e,n)},S=O(()=>iw(I(t))),C=e=>{z(e,Qw())};V(b,e=>{I(S)?e(x):e(C,-1)}),T(y);var w=P(y),ee=M(w,!0);T(w);var te=P(w),ne=M(te,!0);T(te);var re=P(te),ie=M(re),ae=M(ie,!0);T(ie);var oe=P(ie,2),se=e=>{{let n=O(()=>QC(I(t)));K(e,{get icon(){return Ka},class:`cost-source-icon`,get title(){return I(n)}})}},ce=O(()=>I(n)&&ZC(I(t)));V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{K(e,{get icon(){return Ya},class:`cache-savings-icon`})},de=O(()=>I(n)&&ew(I(t)));V(le,e=>{I(de)&&e(ue)});var fe=P(le,2),pe=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(fe,e=>{I(n)&&I(t).costs_calculation_caveat&&e(pe)}),T(re);var me=P(re),he=e=>{var n=iT(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{{let n=O(()=>QC(I(t)));K(e,{get icon(){return Ka},class:`cost-source-icon`,get title(){return I(n)}})}},s=O(()=>ZC(I(t)));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{K(e,{get icon(){return Ya},class:`cache-savings-icon`})},u=O(()=>ew(I(t)));V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(d,e=>{I(t).costs_calculation_caveat&&e(f)}),T(n),F((e,t)=>{W(n,`title`,e),B(i,t)},[()=>nw(I(t),sw(I(t))),()=>oc(I(t).total_cost)]),z(e,n)};V(me,e=>{I(n)||e(he)}),T(i),F((e,n,r,c,l,d,p,h,g,_,b,x,S)=>{a=U(i,1,`svelte-hg4ill`,null,a,e),W(o,`title`,n),B(s,r),B(u,c),B(f,I(t).model),B(m,I(t).user_path||`-`),B(v,l),W(y,`title`,d),W(w,`title`,p),B(ee,h),W(te,`title`,g),B(ne,_),W(re,`title`,b),W(ie,`title`,x),B(ae,S)},[()=>({"usage-log-row-cached":ew(I(t))}),()=>pc(I(t).timestamp),()=>us.formatTimestamp(I(t).timestamp),()=>hc(I(t))||`-`,()=>tw(I(t)),()=>ow(I(t)),()=>I(n)?ac(I(t).input_tokens)+` tokens`:``,()=>I(n)?oc(I(t).input_cost):ac(I(t).input_tokens),()=>I(n)?ac(I(t).output_tokens)+` tokens`:``,()=>I(n)?oc(I(t).output_cost):ac(I(t).output_tokens),()=>I(n)?nw(I(t),``):``,()=>I(n)?nw(I(t),ac(I(t).total_tokens)+` tokens +`+sw(I(t))):``,()=>I(n)?oc(I(t).total_cost):ac(I(t).total_tokens)]),z(e,i)}),T(_),T(i),T(t),F(()=>{B(u,I(n)?`Input Cost`:`Input`),B(f,I(n)?`Output Cost`:`Output`),B(m,I(n)?`Total Cost`:`Total`)}),z(e,t)},p=e=>{var t=sT();xS(M(t),{size:20,label:`Loading request log`}),T(t),z(e,t)},m=e=>{var t=cT();wS(M(t),{}),T(t),z(e,t)};V(d,e=>{_w.usageLog.entries.length>0?e(f):_w.usageLogLoading?e(p,1):e(m,-1)}),Jw(P(d,2),{get total(){return _w.usageLog.total},get offset(){return _w.usageLog.offset},get limit(){return _w.usageLog.limit},onprev:()=>_w.usageLogPrevPage(),onnext:()=>_w.usageLogNextPage()}),T(a),L(`change`,u,()=>_w.fetchUsageLog(!0)),fa(u,()=>_w.usageLogHideCached,e=>_w.usageLogHideCached=e),z(e,a),D()}Hr([`click`,`change`]);var dT=R(`
        `);function fT(e,t){E(t,!0);let n=`usage`;An(()=>{q.refreshTick,qo.page===n&&(_w.fetchUsagePage(),jC.ensureLiveLogs())}),An(()=>{qo.page===n&&(_w.usageMode=qo.sub===`costs`?`costs`:`tokens`)});var r=dT(),i=P(M(r),2),a=M(i);Ny(a,{ariaLabel:`Usage mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return _w.usageMode},onchange:e=>_w.toggleUsageMode(e)}),el(P(a,2),{onchange:()=>_w.fetchUsagePage()}),T(i);var o=P(i,2);ww(o,{});var s=P(o,2);Aw(s,{});var c=P(s,2),l=M(c);Kw(l,{kind:`model`});var u=P(l,2);Kw(u,{kind:`userPath`}),Kw(P(u,2),{kind:`label`}),T(c),uT(P(c,2),{}),T(r),z(e,r),D()}var pT=R(`
        `);function mT(e,t){let n=G(t,`label`,3,`Loading...`),r=G(t,`class`,3,``);var i=pT(),a=P(M(i),2),o=M(a,!0);T(a),T(i),F(()=>{U(i,1,Fi([`loading-state`,r()]),`svelte-hzxv1d`),B(o,n())}),z(e,i)}var hT=R(``);function gT(e,t){let n=G(t,`label`,3,``),r=G(t,`class`,3,``),i=G(t,`disabled`,3,!1);var a=hT();gi(M(a),()=>t.children??f),T(a),F(()=>{U(a,1,Fi([`table-action-btn`,r()])),W(a,`aria-label`,n()),W(a,`title`,n()),a.disabled=i()}),L(`click`,a,function(...e){t.onclick?.apply(this,e)}),z(e,a)}Hr([`click`]);async function _T(e,{label:t,errorFallback:n=`Unable to load ${t}.`,unavailableStatuses:r=[503],normalize:i=e=>Array.isArray(e)?e:[],options:a}){let o;try{o=await gs(e,{...a||{},label:t})}catch(e){return vs(e)||console.error(`Failed to fetch ${t}:`,e),{status:`error`,items:[],error:n,result:null}}return o.stale?{status:`stale`,items:[],error:``,result:o}:r.includes(o.status)?{status:`unavailable`,items:[],error:``,result:o}:o.ok?{status:`ok`,items:i(o.data),error:``,result:o}:{status:`error`,items:[],error:o.status===401?``:ds(o.data,n),result:o}}async function vT(e,t,n,{label:r,errorFallback:i=`Unable to ${r}.`,unavailableStatuses:a=[503],unavailableMessage:o=`This feature is unavailable on the gateway.`,options:s}){let c;try{c=await _s(e,t,n,{...s||{},label:r})}catch(e){return vs(e)||console.error(`Failed to ${r}:`,e),{status:`error`,error:i,result:null}}return c.stale?{status:`stale`,error:``,result:c}:a.includes(c.status)?{status:`unavailable`,error:o,result:c}:c.ok?{status:`ok`,error:``,result:c}:{status:`error`,error:c.status===401?`Authentication required.`:ds(c.data,i),result:c}}function yT(){return{scope:`user_path`,subject:`/`,period:`daily`,period_seconds:86400,amount:``,source:`manual`}}function bT(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},label:{label:`Label`,chip:`label`,fieldLabel:`Label`,placeholder:`Mobile-App-iOS`}};return t[e]||t.user_path}function xT(){return[`user_path`,`label`].map(e=>({value:e,label:bT(e).label}))}function ST(e){return String(e&&e.scope||``).trim()||`user_path`}function CT(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function wT(e){return bT(ST(e)).chip}function TT(e){return ST(e)===`label`?`budget-label`:`budget-user-path`}function ET(e){return bT(String(e&&e.scope||``)).fieldLabel}function DT(e){return bT(String(e&&e.scope||``)).placeholder}function OT(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function kT(){return[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`},{value:`custom`,label:`Custom seconds`}]}function AT(e){switch(String(e||``).trim().toLowerCase()){case`hourly`:return 3600;case`daily`:return 86400;case`weekly`:return 604800;case`monthly`:return 2592e3;default:return 0}}function jT(e){switch(Number(e||0)){case 3600:return`hourly`;case 86400:return`daily`;case 604800:return`weekly`;case 2592e3:return`monthly`;default:return`custom`}}function MT(e){return ST(e)+`:`+CT(e)+`:`+String(e&&e.period_seconds||``)}function NT(e,t){if(!t||!Array.isArray(e))return null;let n=MT(t);return e.find(e=>MT(e)===n)||null}function PT(e){let t=String(e||``).trim();if(!t)return`User path is required.`;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function FT(e){if(PT(e))return``;let t=String(e||``).trim(),n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function IT(e){return`/`+String(e||``).trimStart().replace(/^\/+/,``)}function LT(e){return Array.isArray(e)?e:e&&Array.isArray(e.budgets)?e.budgets:[]}function RT(e){let t=Number(e&&e.period_seconds||0);return[CT(e),wT(e),tE(e),jT(t),t?String(t)+`s`:``,t?String(t)+` seconds`:``].join(` `).toLowerCase()}var zT={user_path:0,label:1};function BT(e,t){let n=Array.isArray(e)?e.slice():[],r=String(t||`subject`);return n.sort((e,t)=>{let n=(zT[ST(e)]||0)-(zT[ST(t)]||0),i=CT(e).localeCompare(CT(t)),a=Number(t&&t.period_seconds||0)-Number(e&&e.period_seconds||0);return r===`period`?a||n||i:n||i||a}),n}function VT(e,t,n){let r=Array.isArray(e)?e:[],i=String(t||``).trim().toLowerCase();return BT(i?r.filter(e=>RT(e).includes(i)):r.slice(),n)}function HT(e){let t=e||{},n=ST(t),r=String(t.subject||``).trim();if(n===`user_path`){let e=PT(r);if(e)return{payload:null,error:e}}else if(!r)return{payload:null,error:`Label is required.`};let i=Number(t.amount);if(!Number.isFinite(i)||i<=0)return{payload:null,error:`Amount must be greater than 0.`};let a=String(t.period||``).trim(),o=AT(a);return a===`custom`&&(o=Number(t.period_seconds)),!Number.isFinite(o)||o<=0?{payload:null,error:`Period seconds must be greater than 0.`}:{payload:{scope:n,subject:n===`user_path`?FT(r):r,period_seconds:Math.trunc(o),amount:i,source:String(t.source||`manual`).trim()||`manual`},error:``}}function UT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds},amount:e.amount}}function WT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds}}}function GT(e){return{scope:ST(e),subject:CT(e),period_seconds:e.period_seconds}}function KT(e){return oc(e)}function qT(e,t){let n=e||{},r=t||{};return`A budget for "`+((CT(n)||CT(r))+` `+tE({period_seconds:n.period_seconds||r.period_seconds,period_label:r.period_label}))+`" already exists. Saving will override the current `+KT(r.amount)+` limit with `+KT(n.amount)+`.`}function JT(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:t}function YT(e,t){let n=JT(e);return Math.round((t?Math.min(n,1):n)*1e3)/10}function XT(e){return JT(e&&e.usage_ratio)}function ZT(e){return YT(XT(e),!0)}function QT(e){return YT(e&&e.period_ratio,!0)}function $T(e){return YT(XT(e),!1).toFixed(1).replace(/\.0$/,``)+`%`}function eE(e){return QT(e).toFixed(1).replace(/\.0$/,``)+`%`}function tE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`Hourly`;case 86400:return`Daily`;case 604800:return`Weekly`;case 2592e3:return`Monthly`;default:{let n=String(e&&e.period_label||``).trim();return n?`Custom `+n:`Custom `+String(t||``)+`s`}}}function nE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return`budget-period-label-hourly`;case 86400:return`budget-period-label-daily`;case 604800:return`budget-period-label-weekly`;case 2592e3:return`budget-period-label-monthly`;default:return`budget-period-label-custom`}}function rE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-fill-period-`)}function iE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-track-period-`)}function aE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return qa;case 86400:return Eo;case 604800:return Ia;case 2592e3:return La;default:return bo}}function oE(e){let t=Math.max(0,Math.trunc(Number(e||0)));return t+` `+(t===1?`second`:`seconds`)}function sE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`1 hour`;case 86400:return`1 day`;case 604800:return`1 week`;case 2592e3:return`1 month`;default:return oE(t)}}function cE(e){return String(e&&e.source||``).trim()||`manual`}function lE(e){let t=cE(e).toLowerCase();return t===`manual`?`Created from the dashboard.`:t===`config`?`Loaded from configuration.`:`Budget source: `+t}function uE(e){let t=Number(e&&e.remaining);return Number.isFinite(t)?t<0?oc(Math.abs(t))+` over`:oc(t)+` remaining`:``}var Y=new class{#e=k(j([]));get budgets(){return I(this.#e)}set budgets(e){A(this.#e,e,!0)}#t=k(!0);get budgetsAvailable(){return I(this.#t)}set budgetsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get filter(){return I(this.#r)}set filter(e){A(this.#r,e,!0)}#i=k(`subject`);get sortBy(){return I(this.#i)}set sortBy(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(!1);get formOpen(){return I(this.#o)}set formOpen(e){A(this.#o,e,!0)}#s=k(!1);get formSubmitting(){return I(this.#s)}set formSubmitting(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get editing(){return I(this.#l)}set editing(e){A(this.#l,e,!0)}#u=k(j(yT()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(!1);get overrideDialogOpen(){return I(this.#d)}set overrideDialogOpen(e){A(this.#d,e,!0)}#f=k(null);get overridePendingPayload(){return I(this.#f)}set overridePendingPayload(e){A(this.#f,e,!0)}#p=k(null);get overrideExistingBudget(){return I(this.#p)}set overrideExistingBudget(e){A(this.#p,e,!0)}#m=k(``);get resettingKey(){return I(this.#m)}set resettingKey(e){A(this.#m,e,!0)}#h=k(``);get deletingKey(){return I(this.#h)}set deletingKey(e){A(this.#h,e,!0)}#g=k(!1);get resetAllLoading(){return I(this.#g)}set resetAllLoading(e){A(this.#g,e,!0)}#_=null;managementEnabled(){return xs.budgetsVisible()}filteredBudgets(){return VT(this.budgets,this.filter,this.sortBy)}async fetchBudgetsPage(){if(await xs.ensureLoaded(),!this.managementEnabled()){this.budgets=[],this.budgetsAvailable=!1,this.error=``;return}return this.#_||=this.fetchBudgets().finally(()=>{this.#_=null}),this.#_}async fetchBudgets(){this.loading=!0,this.error=``;let e=await _T(`/admin/budgets`,{label:`budgets`,errorFallback:`Unable to load budgets.`,normalize:LT});if(this.loading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.budgetsAvailable=!1,this.budgets=[];return}if(!e.result){this.budgets=[],this.error=e.error;return}if(this.budgetsAvailable=!0,e.status===`error`){this.error=e.error;return}this.budgets=e.items}}openForm(e){if(this.editing=!!e,this.formError=``,e){let t=Number(e.period_seconds||0);this.form={scope:ST(e),subject:CT(e),period:jT(t),period_seconds:t,amount:String(e.amount||``),source:String(e.source||`manual`)}}else this.form=yT();this.formOpen=!0}syncPeriodSeconds(){let e=AT(String(this.form.period||``).trim());e>0&&(this.form.period_seconds=e)}setFormSubject(e){this.form.subject=this.form.scope===`label`?String(e??``):IT(e)}syncScope(){OT(this.form)}closeForm(){this.closeOverrideDialog(),this.formOpen=!1,this.formSubmitting=!1,this.formError=``,this.editing=!1,this.form=yT()}async submitForm(){if(this.formSubmitting)return;let{payload:e,error:t}=HT(this.form);if(!e){this.formError=t;return}if(!this.editing){let t=NT(this.budgets,e);if(t){this.openOverrideDialog(t,e);return}}await this.saveBudgetPayload(e)}async saveBudgetPayload(e){if(this.formSubmitting||!e)return;this.formSubmitting=!0,this.formError=``;let t=await vT(`/admin/budgets`,`PUT`,UT(e),{label:`save budget`,errorFallback:`Unable to save budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.formSubmitting=!1,t.status!==`stale`){if(t.status===`unavailable`){this.budgetsAvailable=!1,this.formError=t.error;return}if(t.status===`error`){this.formError=t.error;return}this.closeForm(),J.success(`Budget saved.`),this.fetchBudgets()}}openOverrideDialog(e,t){this.overrideExistingBudget=e||null,this.overridePendingPayload=t||null,this.overrideDialogOpen=!0}closeOverrideDialog(){this.overrideDialogOpen=!1,this.overridePendingPayload=null,this.overrideExistingBudget=null}async confirmOverride(){if(!this.overridePendingPayload){this.closeOverrideDialog();return}let e=this.overridePendingPayload;this.closeOverrideDialog(),await this.saveBudgetPayload(e)}async resetBudget(e){if(!e)return;let t=MT(e);if(this.resettingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Reset budget "`+n+`"?`))return;this.resettingKey=t;let r=await vT(`/admin/budgets/reset-one`,`POST`,GT(e),{label:`reset budget`,errorFallback:`Unable to reset budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.resettingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,J.error(r.error);return}if(r.status===`error`){J.error(r.error);return}J.success(`Budget reset.`),this.fetchBudgets()}}async deleteBudget(e){if(!e)return;let t=MT(e);if(this.deletingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Delete budget "`+n+`"? This cannot be undone.`))return;this.deletingKey=t;let r=await vT(`/admin/budgets`,`DELETE`,WT(e),{label:`delete budget`,errorFallback:`Unable to delete budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.deletingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,J.error(r.error);return}if(r.status===`error`){J.error(r.error);return}this.budgets=LT(r.result.data),J.success(`Budget deleted.`)}}openResetDialog(){Ls.open({title:`Reset Budgets`,titleId:`budgetResetDialogTitle`,inputId:`budget-reset-confirmation`,requiredText:`reset`,confirmLabel:`Reset All Budgets`,icon:ho,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.resetAllBudgets()})}async resetAllBudgets(){if(this.resetAllLoading)return;this.resetAllLoading=!0;let e=await vT(`/admin/budgets/reset`,`POST`,{confirmation:`reset`},{label:`reset budgets`,errorFallback:`Unable to reset budgets.`,unavailableStatuses:[]});if(this.resetAllLoading=!1,e.status!==`stale`){if(e.status!==`ok`){Ls.error=e.error;return}Ls.close(),J.success(`Budgets reset.`),qo.page===`budgets`&&this.fetchBudgets()}}},dE=R(` Edit`,1),fE=R(` `,1),pE=R(`
        Usage
        Period
        `),mE=R(`
        `);function hE(e,t){E(t,!0);let n=G(t,`budgets`,19,()=>[]);function r(e){if(!e)return``;let t=us.formatTimestamp(e);return!t||t===`-`?``:t+` `+us.effectiveTimeZoneLabel()}var i=mE();H(i,21,n,e=>MT(e),(e,t)=>{var n=pE(),i=M(n),a=M(i),o=M(a),s=M(o),c=e=>{K(e,{get icon(){return Do},class:`budget-scope-icon`})},l=O(()=>ST(I(t))===`label`);V(s,e=>{I(l)&&e(c)});var u=P(s);T(o);var d=P(o,2),f=M(d),p=M(f);{let e=O(()=>aE(I(t)));K(p,{get icon(){return I(e)},class:`budget-period-icon`})}var m=P(p,2),h=M(m,!0);T(m),T(f),T(d);var g=P(d,2),_=M(g),v=M(_),y=M(v,!0);T(v),T(_);var b=P(_,2),x=M(b);gT(x,{label:`Edit budget`,class:`budget-action-btn`,onclick:()=>Y.openForm(I(t)),children:(e,t)=>{var n=dE();K(N(n),{get icon(){return lo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}});var S=P(x,2);{let e=O(()=>Y.resettingKey===MT(I(t))?`Resetting budget`:`Reset budget`),n=O(()=>Y.resettingKey===MT(I(t)));gT(S,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>Y.resetBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);K(i,{get icon(){return ho},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.resettingKey===MT(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var C=P(S,2);{let e=O(()=>Y.deletingKey===MT(I(t))?`Deleting budget`:`Delete budget`),n=O(()=>Y.deletingKey===MT(I(t)));gT(C,{get label(){return I(e)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>Y.deleteBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);K(i,{get icon(){return ko},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.deletingKey===MT(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}T(b),T(g),T(a);var w=P(a,2),ee=M(w),te=M(ee),ne=P(M(te),2),re=M(ne,!0);T(ne),T(te);var ie=P(te,2),ae=M(ie);let oe;var se=P(ae,2),ce=M(se),le=M(ce,!0);T(ce);var ue=P(ce,2),de=M(ue,!0);T(ue),T(se);var fe=P(se,2),pe=M(fe),me=M(pe,!0);T(pe);var he=P(pe,2),ge=M(he,!0);T(he),T(fe),T(ie),T(ee);var _e=P(ee,2),ve=M(_e),ye=P(M(ve),2),be=M(ye,!0);T(ye),T(ve);var xe=P(ve,2),Se=M(xe),Ce=P(Se,2),we=M(Ce),Te=M(we,!0);T(we);var Ee=P(we,2),De=M(Ee,!0);T(Ee);var Oe=P(Ee,2),ke=M(Oe,!0);T(Oe),T(Ce);var Ae=P(Ce,2),je=M(Ae),Me=M(je,!0);T(je);var Ne=P(je,2),Pe=M(Ne,!0);T(Ne);var Fe=P(Ne,2),Ie=M(Fe,!0);T(Fe),T(Ae),T(xe),T(_e),T(w),T(i),T(n),F((e,t,n,r,i,a,s,c,l,d,p,m,g,_,b,x,S,C,w,ee,te,ne,se,ce,ue,fe,pe,he,_e,ve)=>{U(o,1,`budget-scope-value ${e??``}`,`svelte-1jm56wo`),Hi(o,t),W(o,`title`,n),B(u,` ${r??``}`),U(f,1,`budget-period-label ${i??``}`,`svelte-1jm56wo`),B(h,a),W(v,`title`,s),B(y,c),B(re,l),W(ie,`aria-valuenow`,d),W(ie,`aria-label`,p),Hi(ie,`--budget-progress: ${m??``}%`),oe=U(ae,1,`budget-bar-fill budget-bar-fill-usage`,null,oe,g),B(le,_),B(de,b),B(me,x),B(ge,S),B(be,C),U(xe,1,`budget-bar-track ${w??``}`,`svelte-1jm56wo`),W(xe,`aria-valuenow`,ee),Hi(xe,`--budget-progress: ${te??``}%`),U(Se,1,`budget-bar-fill budget-bar-fill-period ${ne??``}`,`svelte-1jm56wo`),W(we,`title`,se),B(Te,ce),B(De,ue),W(Oe,`title`,fe),B(ke,pe),B(Me,he),B(Pe,_e),B(Ie,ve)},[()=>TT(I(t)),()=>ST(I(t))===`label`?`--label-color: `+Vy(CT(I(t))):void 0,()=>wT(I(t))+`: `+CT(I(t)),()=>CT(I(t)),()=>nE(I(t)),()=>tE(I(t)),()=>lE(I(t)),()=>cE(I(t)),()=>$T(I(t)),()=>ZT(I(t)),()=>`Budget usage: `+oc(I(t).spent)+` of `+oc(I(t).amount)+`, `+uE(I(t)),()=>ZT(I(t)),()=>({"budget-bar-fill-danger":XT(I(t))>=1}),()=>oc(I(t).spent)+` of `+oc(I(t).amount),()=>uE(I(t)),()=>oc(I(t).spent)+` of `+oc(I(t).amount),()=>uE(I(t)),()=>eE(I(t)),()=>iE(I(t)),()=>QT(I(t)),()=>QT(I(t)),()=>rE(I(t)),()=>r(I(t).period_start),()=>us.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>r(I(t).period_end),()=>us.formatTimestamp(I(t).period_end),()=>us.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>us.formatTimestamp(I(t).period_end)]),z(e,n)}),T(i),z(e,i),D()}var gE=R(`

        `,1),_E=R(``),vE=R(``),yE=R(`
        `);function bE(e,t){E(t,!0);let n=G(t,`open`,3,!1),r=G(t,`title`,3,``),i=G(t,`ariaLabel`,3,``),a=G(t,`error`,3,``),o=G(t,`submitting`,3,!1),s=G(t,`submitDisabled`,3,!1),c=G(t,`submitLabel`,3,`Save`),l=G(t,`submittingLabel`,3,`Saving...`),u=G(t,`submitIcon`,3,go),d=G(t,`cancel`,3,!0),p=G(t,`dialogClass`,3,``),m=G(t,`novalidate`,3,!1),h=G(t,`canClose`,3,()=>!0);function g(){q.dialogOpen||h()()&&t.onclose?.()}Ms(e,{get open(){return n()},variant:`editor`,onclose:g,children:(e,n)=>{var h=yE(),g=M(h),_=M(g),v=M(_),y=M(v),b=e=>{var n=Qr();gi(N(n),()=>t.header),z(e,n)},x=e=>{var n=gE(),i=N(n),a=M(i,!0);T(i);var o=P(i,2),s=e=>{var n=Qr();gi(N(n),()=>t.headerHint),z(e,n)};V(o,e=>{t.headerHint&&e(s)}),F(()=>B(a,r())),z(e,n)};V(y,e=>{t.header?e(b):e(x,-1)}),T(v);var S=P(v,2);{let e=O(()=>`Close `+(i()||r()).toLowerCase());Os(S,{get label(){return I(e)},onclick:()=>t.onclose?.()})}T(_);var C=P(_,2);gi(C,()=>t.children??f);var w=P(C,2),ee=e=>{var t=_E(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(w,e=>{a()&&e(ee)});var te=P(w,2),ne=M(te),re=e=>{var n=vE();L(`click`,n,()=>t.onclose?.()),z(e,n)};V(ne,e=>{d()&&e(re)});var ie=P(ne,2),ae=e=>{var n=Qr();gi(N(n),()=>t.extraActions),z(e,n)};V(ie,e=>{t.extraActions&&e(ae)});var oe=P(ie,2),se=M(oe);K(se,{get icon(){return u()},class:`form-action-icon`});var ce=P(se,2),le=M(ce,!0);T(ce),T(oe),T(te),T(g),T(h),F(()=>{U(h,1,Fi([`model-editor`,p()])),W(h,`aria-label`,i()||r()),g.noValidate=m(),oe.disabled=o()||s(),B(le,o()?l():c())}),Vr(`submit`,g,e=>{e.preventDefault(),t.onsubmit?.()}),z(e,h)},$$slots:{default:!0}}),D()}Hr([`click`]);var xE=R(`
        `);function SE(e,t){let n=G(t,`label`,3,``);var r=xE(),i=M(r),a=M(i,!0);T(i),gi(P(i,2),()=>t.children??f),T(r),F(()=>{W(i,`for`,t.id),B(a,n())}),z(e,r)}var CE=R(``),wE=R(``),TE=R(``),EE=R(``),DE=R(``),OE=R(``),kE=R(`

        Editing a budget updates its limit only. Use Reset to start a new + budget period.

        `),AE=R(`
        `,1),jE=R(``),ME=R(` `,1);function NE(e,t){E(t,!0);function n(e){Y.setFormSubject(e.target.value),e.target.value=Y.form.subject}var r=ME(),i=N(r);{let e=O(()=>Y.editing?`Edit Budget`:`Create Budget`);bE(i,{get open(){return Y.formOpen},get title(){return I(e)},ariaLabel:`Budget editor`,get error(){return Y.formError},get submitting(){return Y.formSubmitting},submitLabel:`Save Budget`,dialogClass:`budget-editor`,canClose:()=>!Y.overrideDialogOpen,onclose:()=>Y.closeForm(),onsubmit:()=>Y.submitForm(),children:(e,t)=>{var r=AE(),i=N(r),a=M(i);SE(a,{id:`budget-scope`,label:`Scope`,children:(e,t)=>{var n=wE();H(n,21,xT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncScope()),Gi(n,()=>Y.form.scope,e=>Y.form.scope=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);{let e=O(()=>ET(Y.form));SE(o,{id:`budget-subject`,get label(){return I(e)},children:(e,t)=>{var r=TE();na(r),F(e=>{W(r,`placeholder`,e),ra(r,Y.form.subject),r.disabled=Y.editing,W(r,`data-modal-autofocus`,!Y.editing||void 0)},[()=>DT(Y.form)]),L(`input`,r,n),z(e,r)},$$slots:{default:!0}})}var s=P(o,2);SE(s,{id:`budget-period`,label:`Period`,children:(e,t)=>{var n=EE();H(n,21,kT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncPeriodSeconds()),Gi(n,()=>Y.form.period,e=>Y.form.period=e),z(e,n)},$$slots:{default:!0}});var c=P(s,2),l=e=>{SE(e,{id:`budget-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=DE();na(n),F(()=>n.disabled=Y.editing),da(n,()=>Y.form.period_seconds,e=>Y.form.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(c,e=>{Y.form.period===`custom`&&e(l)}),SE(P(c,2),{id:`budget-amount`,label:`Amount`,children:(e,t)=>{var n=OE();na(n),F(()=>W(n,`data-modal-autofocus`,Y.editing||void 0)),da(n,()=>Y.form.amount,e=>Y.form.amount=e),z(e,n)},$$slots:{default:!0}}),T(i);var u=P(i,2),d=e=>{z(e,kE())};V(u,e=>{Y.editing&&e(d)}),z(e,r)},$$slots:{default:!0}})}Ms(P(i,2),{get open(){return Y.overrideDialogOpen},variant:`auth`,onclose:()=>Y.closeOverrideDialog(),children:(e,t)=>{var n=jE(),r=M(n);Os(P(M(r),2),{label:`Close budget override dialog`,onclick:()=>Y.closeOverrideDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=P(c,2),u=M(l);K(u,{get icon(){return go},class:`form-action-icon`});var d=P(u,2),f=M(d,!0);T(d),T(l),T(s),T(i),T(n),F(e=>{B(o,e),l.disabled=Y.formSubmitting,B(f,Y.formSubmitting?`Saving...`:`Override Budget`)},[()=>qT(Y.overridePendingPayload,Y.overrideExistingBudget)]),Vr(`submit`,i,e=>{e.preventDefault(),Y.confirmOverride()}),L(`click`,c,()=>Y.closeOverrideDialog()),z(e,n)},$$slots:{default:!0}}),z(e,r),D()}Hr([`change`,`input`,`click`]);var PE=R(`

        Budgets

        `),FE=R(``),IE=R(`
        Budget management is unavailable.
        `),LE=R(``),RE=R(`
        `),zE=R(`

        No budgets configured yet.

        `),BE=R(`

        No budgets match your filter.

        `),VE=R(`
        `);function HE(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`budgets`&&Y.fetchBudgetsPage()});let n=O(()=>Y.filteredBudgets());var r=VE(),i=M(r),a=M(i);KS(M(a),{copyId:`budgets-help-copy`,label:`budgets help`,title:e=>{z(e,PE())},help:e=>{Ue(),z(e,Zr(`Budgets are evaluated from tracked usage cost records for each user + path subtree. Enforcement runs only when Budget is enabled for the + active workflow.`))},$$slots:{title:!0,help:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=FE();K(M(t),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Y.formSubmitting),L(`click`,t,()=>Y.openForm()),z(e,t)},l=O(()=>Y.managementEnabled()&&Y.budgetsAvailable&&!q.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Pc(u,{});var d=P(u,2),f=e=>{z(e,IE())},p=O(()=>(!Y.managementEnabled()||!Y.budgetsAvailable)&&!q.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=LE(),n=M(t,!0);T(t),F(()=>B(n,Y.error)),z(e,t)};V(m,e=>{Y.error&&!q.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading budgets...`})};V(g,e=>{Y.loading&&!q.authError&&e(_)});var v=P(g,2),y=e=>{var t=RE(),n=M(t);yw(M(n),{id:`budget-filter`,placeholder:`Filter by user path, label, or period...`,label:`Filter budgets by user path or period`,get value(){return Y.filter},set value(e){Y.filter=e}}),T(n);var r=P(n,2),i=P(M(r),2),a=M(i);a.value=a.__value=`subject`;var o=P(a);o.value=o.__value=`period`,T(i),T(r),T(t),Gi(i,()=>Y.sortBy,e=>Y.sortBy=e),z(e,t)};V(v,e=>{(Y.budgets.length>0||Y.filter)&&Y.budgetsAvailable&&!q.authError&&!Y.formOpen&&e(y)});var b=P(v,2);NE(b,{});var x=P(b,2),S=e=>{hE(e,{get budgets(){return I(n)}})};V(x,e=>{I(n).length>0&&Y.budgetsAvailable&&!q.authError&&e(S)});var C=P(x,2),w=e=>{z(e,zE())},ee=O(()=>Y.budgets.length===0&&!Y.filter&&!Y.loading&&!q.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,BE())},re=O(()=>Y.budgets.length>0&&I(n).length===0&&Y.filter&&!Y.loading&&!q.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function UE(){return{scope:`user_path`,subject:`/`,period:`minute`,period_seconds:60,max_requests:``,max_tokens:``,source:`manual`}}function WE(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},provider:{label:`Provider`,chip:`provider`,fieldLabel:`Provider Name`,placeholder:`openai`},model:{label:`Model`,chip:`model`,fieldLabel:`Model`,placeholder:`openai/gpt-4o`}};return t[e]||t.user_path}function GE(){return[`user_path`,`provider`,`model`].map(e=>({value:e,label:WE(e).label}))}function KE(e){return String(e&&e.scope||``).trim()||`user_path`}function qE(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function JE(e){return WE(KE(e)).chip}function YE(e){return WE(String(e&&e.scope||``)).fieldLabel}function XE(e){return WE(String(e&&e.scope||``)).placeholder}function ZE(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function QE(){return[{value:`minute`,label:`Per minute`},{value:`hour`,label:`Per hour`},{value:`day`,label:`Per day`},{value:`concurrent`,label:`Concurrent (in-flight)`},{value:`custom`,label:`Custom seconds`}]}function $E(e){switch(String(e||``).trim().toLowerCase()){case`minute`:return 60;case`hour`:return 3600;case`day`:return 86400;case`concurrent`:return 0;default:return-1}}function eD(e){switch(Number(e||0)){case 60:return`minute`;case 3600:return`hour`;case 86400:return`day`;case 0:return`concurrent`;default:return`custom`}}function tD(e){let t=String(e&&e.period||``).trim(),n=$E(t);n>=0&&(e.period_seconds=n),t===`concurrent`&&(e.max_tokens=``)}function nD(e){return KE(e)+`:`+qE(e)+`:`+String(e&&e.period_seconds||`0`)}function rD(e){return Number(e&&e.period_seconds||0)===0}function iD(e){return String(e&&e.period_label||``).trim()||eD(Number(e&&e.period_seconds||0))}function aD(e){return String(e&&e.source||``)===`config`?`config`:`manual`}function oD(e){return String(e&&e.source||``)===`config`}function sD(e){let t=Number(e);return Number.isFinite(t)?t.toLocaleString():`0`}function cD(e,t){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return 0;let i=Math.round(n/r*100);return Math.min(Math.max(i,0),100)}function lD(e,t){let n=String(t||``).trim().toLowerCase(),r=Array.isArray(e)?e.slice():[],i={user_path:0,provider:1,model:2};return r.sort((e,t)=>{let n=(i[KE(e)]||0)-(i[KE(t)]||0);if(n!==0)return n;let r=qE(e).localeCompare(qE(t));return r===0?Number(e.period_seconds||0)-Number(t.period_seconds||0):r}),n?r.filter(e=>{let t=qE(e).toLowerCase(),r=JE(e).toLowerCase(),i=iD(e).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)}):r}function uD(e){return!e||!Array.isArray(e.rate_limits)?[]:e.rate_limits}function dD(e,t,n){let r=String(t||``).trim();return r=e===`provider`||e===`model`?r.toLowerCase():`/`+r.split(`/`).map(e=>e.trim()).filter(Boolean).join(`/`),e+`:`+r+`:`+Number(n||0)}function fD(e,t){return e?dD(t.scope,t.subject,t.limit_key.period_seconds)!==dD(e.scope,e.subject,e.period_seconds):!1}function pD(e){let t=e||{},n=String(t.scope||`user_path`),r=String(t.subject||``).trim();if(n!==`user_path`&&!r)return{error:YE(t)+` is required.`};let i=String(t.period||``)===`concurrent`,a=t.period_seconds;if(a===``||a==null)return{error:`Period seconds is required.`};let o=Number(a);if(!Number.isInteger(o)||o<0||o===0&&!i)return{error:`Period seconds must be a positive integer (0 only for the concurrent period).`};let s=String(t.max_requests===void 0||t.max_requests===null?``:t.max_requests).trim(),c=String(t.max_tokens===void 0||t.max_tokens===null?``:t.max_tokens).trim();if(!s&&!c)return{error:`Set max requests, max tokens, or both.`};if(i&&c)return{error:`Token limits are not valid for the concurrent period.`};let l={scope:n,subject:r||`/`,limit_key:{period_seconds:o}};if(s){let e=Number(s);if(!Number.isInteger(e)||e<=0)return{error:`Max requests must be a positive integer.`};l.max_requests=e}if(c){let e=Number(c);if(!Number.isInteger(e)||e<=0)return{error:`Max tokens must be a positive integer.`};l.max_tokens=e}return{payload:l}}function mD(e,t,n){if(KE(e)!==`model`)return!1;let r=String(qE(e)).toLowerCase(),i=String(n||``).trim().toLowerCase();if(!i)return!1;if(r===i)return!0;let a=String(t||``).trim().toLowerCase();return a?r===a+`/`+i||i.startsWith(a+`/`)&&r===i.slice(a.length+1):!1}function hD(e,t){return KE(e)===`provider`&&String(qE(e)).toLowerCase()===String(t||``).trim().toLowerCase()}function gD(e){let t=e||{},n=String(t.model||``),r=String(t.provider||``);return!r||n.toLowerCase().startsWith(r+`/`)?n:r+`/`+n}function _D(e,t){let n=e||{},r=Array.isArray(t)?t:[],i=[];return n.kind===`model`&&i.push({key:`model`,title:`Model limits`,scope:`model`,subject:gD(n),hint:``,items:r.filter(e=>mD(e,n.provider,n.model))}),i.push({key:`provider`,title:`Provider limits (`+n.provider+`)`,scope:`provider`,subject:n.provider,hint:n.kind===`model`?`Shared by every model routed to this provider.`:``,items:r.filter(e=>hD(e,n.provider))}),i.push({key:`global`,title:`Global limits`,scope:`user_path`,subject:`/`,hint:`Root user-path rules throttle all traffic. Narrower user-path rules also apply, per consumer.`,items:r.filter(e=>KE(e)===`user_path`&&qE(e)===`/`)}),i}function vD(e){return rD(e)?cD(e.in_flight,e.max_requests):Math.max(cD(e.requests_used,e.max_requests),cD(e.tokens_used,e.max_tokens))}function yD(e){return`--rate-limit-pressure: `+vD(e)+`%`}function bD(e){let t=vD(e);return t>=100?`rate-limit-pressure-row rate-limit-pressure-full`:t>=75?`rate-limit-pressure-row rate-limit-pressure-high`:`rate-limit-pressure-row`}function xD(e){return(Array.isArray(e)?e:[]).some(e=>KE(e)===`user_path`&&qE(e)===`/`)}function SD(e,t,n){let r=Array.isArray(e)?e:[];return r.some(e=>mD(e,t,n))?`table-action-btn-active`:r.some(e=>hD(e,t))||xD(r)?`rate-limit-gauge-inherited`:``}function CD(e,t){let n=Array.isArray(e)?e:[];return n.some(e=>hD(e,t))?`table-action-btn-active`:xD(n)?`rate-limit-gauge-inherited`:``}function wD(e,t){let n=`Rate limits for `+e;return t===`table-action-btn-active`?n+` (direct limits configured)`:t?n+` (inherited limits apply)`:n}function TD(e){if(rD(e))return sD(e.in_flight)+` of `+sD(e.max_requests)+` in flight`;let t=[];return e.max_requests!==null&&e.max_requests!==void 0&&t.push(sD(e.requests_used)+`/`+sD(e.max_requests)+` req`),e.max_tokens!==null&&e.max_tokens!==void 0&&t.push(sD(e.tokens_used)+`/`+sD(e.max_tokens)+` tok`),t.join(` · `)}var X=new class{#e=k(j([]));get rateLimits(){return I(this.#e)}set rateLimits(e){A(this.#e,e,!0)}#t=k(!0);get rateLimitsAvailable(){return I(this.#t)}set rateLimitsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get rateLimitsLoading(){return I(this.#n)}set rateLimitsLoading(e){A(this.#n,e,!0)}rateLimitFetchPromise=null;#r=k(``);get rateLimitFilter(){return I(this.#r)}set rateLimitFilter(e){A(this.#r,e,!0)}#i=k(``);get rateLimitError(){return I(this.#i)}set rateLimitError(e){A(this.#i,e,!0)}#a=k(!1);get rateLimitFormOpen(){return I(this.#a)}set rateLimitFormOpen(e){A(this.#a,e,!0)}#o=k(!1);get rateLimitFormSubmitting(){return I(this.#o)}set rateLimitFormSubmitting(e){A(this.#o,e,!0)}#s=k(``);get rateLimitFormError(){return I(this.#s)}set rateLimitFormError(e){A(this.#s,e,!0)}#c=k(!1);get rateLimitEditing(){return I(this.#c)}set rateLimitEditing(e){A(this.#c,e,!0)}rateLimitEditingOriginal=null;rateLimitFormReturnToInspector=!1;#l=k(``);get rateLimitResettingKey(){return I(this.#l)}set rateLimitResettingKey(e){A(this.#l,e,!0)}#u=k(``);get rateLimitDeletingKey(){return I(this.#u)}set rateLimitDeletingKey(e){A(this.#u,e,!0)}#d=k(!1);get rateLimitInspectorOpen(){return I(this.#d)}set rateLimitInspectorOpen(e){A(this.#d,e,!0)}#f=k(j({kind:``,provider:``,model:``,title:``}));get rateLimitInspector(){return I(this.#f)}set rateLimitInspector(e){A(this.#f,e,!0)}#p=k(j(UE()));get rateLimitForm(){return I(this.#p)}set rateLimitForm(e){A(this.#p,e,!0)}rateLimitsEnabled(){return xs.rateLimitsVisible()}defaultRateLimitForm(){return UE()}rateLimitScopeMeta(e){return WE(e)}rateLimitScopeOptions(){return GE()}rateLimitScope(e){return KE(e)}rateLimitSubject(e){return qE(e)}rateLimitScopeLabel(e){return JE(e)}rateLimitSubjectFieldLabel(){return YE(this.rateLimitForm)}rateLimitSubjectPlaceholder(){return XE(this.rateLimitForm)}syncRateLimitScope(){ZE(this.rateLimitForm)}rateLimitPeriodOptions(){return QE()}rateLimitPeriodSeconds(e){return $E(e)}rateLimitPeriodFromSeconds(e){return eD(e)}syncRateLimitPeriodSeconds(){tD(this.rateLimitForm)}rateLimitKey(e){return nD(e)}rateLimitIsConcurrent(e){return rD(e)}rateLimitPeriodLabel(e){return iD(e)}rateLimitSourceLabel(e){return aD(e)}rateLimitIsReadOnly(e){return oD(e)}formatRateLimitNumber(e){return sD(e)}rateLimitUsagePercent(e,t){return cD(e,t)}filteredRateLimits(){return lD(this.rateLimits,this.rateLimitFilter)}normalizeRateLimitListPayload(e){return uD(e)}async fetchRateLimitsPage(){if(await xs.ensureLoaded(),!this.rateLimitsEnabled()){this.rateLimits=[],this.rateLimitsAvailable=!1,this.rateLimitError=``;return}return this.rateLimitFetchPromise||=this.fetchRateLimits().finally(()=>{this.rateLimitFetchPromise=null}),this.rateLimitFetchPromise}async fetchRateLimits(){this.rateLimitsLoading=!0,this.rateLimitError=``;let e=await _T(`/admin/rate-limits`,{label:`rate limits`,errorFallback:`Unable to load rate limits.`,normalize:uD});if(this.rateLimitsLoading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.rateLimitsAvailable=!1,this.rateLimits=[];return}if(!e.result){this.rateLimits=[],this.rateLimitError=e.error;return}if(this.rateLimitsAvailable=!0,e.status===`error`){this.rateLimitError=e.error;return}this.rateLimits=e.items}}openRateLimitForm(e){if(this.rateLimitEditing=!!e,this.rateLimitFormError=``,e){let t=Number(e.period_seconds||0);this.rateLimitEditingOriginal={scope:KE(e),subject:qE(e),period_seconds:t},this.rateLimitForm={scope:KE(e),subject:qE(e),period:eD(t),period_seconds:t,max_requests:e.max_requests===null||e.max_requests===void 0?``:String(e.max_requests),max_tokens:e.max_tokens===null||e.max_tokens===void 0?``:String(e.max_tokens),source:String(e.source||`manual`)}}else this.rateLimitEditingOriginal=null,this.rateLimitForm=UE();this.rateLimitFormOpen=!0}closeRateLimitForm(){this.rateLimitFormOpen=!1,this.rateLimitFormSubmitting=!1,this.rateLimitFormError=``,this.rateLimitEditing=!1,this.rateLimitEditingOriginal=null,this.rateLimitForm=UE(),this.rateLimitFormReturnToInspector&&(this.rateLimitFormReturnToInspector=!1,this.rateLimitInspectorOpen=!0)}rateLimitNormalizedIdentity(e,t,n){return dD(e,t,n)}rateLimitIdentityMoved(e){return fD(this.rateLimitEditingOriginal,e)}setRateLimitFormSubject(e){this.rateLimitForm.subject=String(e||``)}rateLimitFormPayload(){return pD(this.rateLimitForm)}async submitRateLimitForm(){if(this.rateLimitFormSubmitting)return;let{payload:e,error:t}=this.rateLimitFormPayload();if(t){this.rateLimitFormError=t;return}let n=this.rateLimitIdentityMoved(e),r=this.rateLimitEditingOriginal;this.rateLimitFormSubmitting=!0,this.rateLimitFormError=``;try{let t=await vT(`/admin/rate-limits`,`PUT`,e,{label:`save rate limit`,errorFallback:`Unable to save rate limit.`,unavailableStatuses:[]});if(t.status===`stale`)return;if(t.status!==`ok`){this.rateLimitFormError=t.error;return}if(this.rateLimits=uD(t.result.data),n&&!await this.deleteMovedRateLimitOriginal(r))return;this.closeRateLimitForm(),J.success(n?`Rate limit moved; live counters restarted.`:`Rate limit saved.`)}finally{this.rateLimitFormSubmitting=!1}}async deleteMovedRateLimitOriginal(e){let t=await vT(`/admin/rate-limits`,`DELETE`,{scope:e.scope,subject:e.subject,limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`remove the moved rate limit`,errorFallback:`The new rule was saved, but the previous one could not be removed. Delete it manually.`,unavailableStatuses:[]});return t.status===`stale`?!1:t.status===`ok`?(this.rateLimits=uD(t.result.data),!0):(this.rateLimitFormError=t.error,!1)}async deleteRateLimit(e){let t=nD(e);if(this.rateLimitDeletingKey===t)return;this.rateLimitDeletingKey=t;let n=await vT(`/admin/rate-limits`,`DELETE`,{scope:KE(e),subject:qE(e),limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`delete rate limit`,errorFallback:`Unable to delete rate limit.`,unavailableStatuses:[]});if(this.rateLimitDeletingKey=``,n.status!==`stale`){if(n.status!==`ok`){J.error(n.error);return}this.rateLimits=uD(n.result.data),J.success(`Rate limit deleted.`)}}async resetRateLimit(e){let t=nD(e);if(this.rateLimitResettingKey===t)return;this.rateLimitResettingKey=t;let n=await vT(`/admin/rate-limits/reset-one`,`POST`,{scope:KE(e),subject:qE(e),period_seconds:Number(e.period_seconds||0)},{label:`reset rate limit`,errorFallback:`Unable to reset rate limit.`,unavailableStatuses:[]});if(this.rateLimitResettingKey=``,n.status!==`stale`){if(n.status!==`ok`){J.error(n.error);return}this.rateLimits=uD(n.result.data),J.success(`Rate limit counters reset.`)}}rateLimitInspectorModelID(e){return String(e&&e.model&&e.model.id||``).trim()}openRateLimitInspectorForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`model`,provider:n,model:t,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}openRateLimitInspectorForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`provider`,provider:t,model:``,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}showRateLimitInspector(){this.rateLimitInspectorOpen=!0,this.fetchRateLimitsPage()}closeRateLimitInspector(){this.rateLimitInspectorOpen=!1}rateLimitRuleMatchesModel(e,t,n){return mD(e,t,n)}rateLimitRuleMatchesProvider(e,t){return hD(e,t)}rateLimitInspectorQualifiedModel(){return gD(this.rateLimitInspector)}rateLimitInspectorSections(){return _D(this.rateLimitInspector,this.rateLimits)}rateLimitPressurePercent(e){return vD(e)}rateLimitPressureStyle(e){return yD(e)}rateLimitPressureClass(e){return bD(e)}rateLimitGaugeCache={rules:null,states:{}};rateLimitGaugeMemo(e,t){this.rateLimitGaugeCache.rules!==this.rateLimits&&(this.rateLimitGaugeCache={rules:this.rateLimits,states:{}});let n=this.rateLimitGaugeCache.states;return e in n||(n[e]=t()),n[e]}rateLimitGaugeClassForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase(),r=this.rateLimits;return this.rateLimitGaugeMemo(`model:`+n+`/`+t,()=>SD(r,n,t))}rateLimitGaugeClassForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase(),n=this.rateLimits;return this.rateLimitGaugeMemo(`provider:`+t,()=>CD(n,t))}hasGlobalRateLimits(){let e=this.rateLimits;return this.rateLimitGaugeMemo(`global`,()=>xD(e))}rateLimitGaugeTitle(e,t){return wD(e,t)}rateLimitInspectorSummary(e){return TD(e)}openRateLimitFormFromInspector(e,t,n){this.rateLimitInspectorOpen=!1,this.rateLimitFormReturnToInspector=!0,this.openRateLimitForm(n||void 0),n||(this.rateLimitForm.scope=e,this.rateLimitForm.subject=t)}},ED=R(``),DD=R(``),OD=R(``),kD=R(``),AD=R(``),jD=R(``),MD=R(``),ND=R(`

        Scope, subject, and period identify the rule: changing any of them + moves the rule to a new key and restarts its live counters.

        `),PD=R(`

        A user path rule limits the whole subtree; provider and model rules cap + all traffic routed there and make load balancing skip the target while + it is saturated. One shared counter per rule. Leave a field empty to + skip that limit. Token limits require usage tracking.

        `,1);function FD(e,t){E(t,!0);{let t=O(()=>X.rateLimitEditing?`Edit Rate Limit`:`Create Rate Limit`);bE(e,{get open(){return X.rateLimitFormOpen},get title(){return I(t)},ariaLabel:`Rate limit editor`,get error(){return X.rateLimitFormError},get submitting(){return X.rateLimitFormSubmitting},submitLabel:`Save Rate Limit`,dialogClass:`budget-editor`,novalidate:!0,onclose:()=>X.closeRateLimitForm(),onsubmit:()=>X.submitRateLimitForm(),children:(e,t)=>{var n=PD(),r=N(n),i=M(r);SE(i,{id:`rate-limit-scope`,label:`Scope`,children:(e,t)=>{var n=DD();H(n,21,()=>X.rateLimitScopeOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitScope()),Gi(n,()=>X.rateLimitForm.scope,e=>X.rateLimitForm.scope=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);{let e=O(()=>X.rateLimitSubjectFieldLabel());SE(a,{id:`rate-limit-subject`,get label(){return I(e)},children:(e,t)=>{var n=OD();na(n),F(e=>{W(n,`placeholder`,e),W(n,`data-modal-autofocus`,!X.rateLimitEditing||void 0),ra(n,X.rateLimitForm.subject)},[()=>X.rateLimitSubjectPlaceholder()]),L(`input`,n,e=>X.setRateLimitFormSubject(e.currentTarget.value)),z(e,n)},$$slots:{default:!0}})}var o=P(a,2);SE(o,{id:`rate-limit-period`,label:`Period`,children:(e,t)=>{var n=kD();H(n,21,()=>X.rateLimitPeriodOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitPeriodSeconds()),Gi(n,()=>X.rateLimitForm.period,e=>X.rateLimitForm.period=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=e=>{SE(e,{id:`rate-limit-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=AD();na(n),da(n,()=>X.rateLimitForm.period_seconds,e=>X.rateLimitForm.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(s,e=>{X.rateLimitForm.period===`custom`&&e(c)});var l=P(s,2);{let e=O(()=>X.rateLimitForm.period===`concurrent`?`Max In-Flight Requests`:`Max Requests`);SE(l,{id:`rate-limit-max-requests`,get label(){return I(e)},children:(e,t)=>{var n=jD();na(n),F(()=>W(n,`data-modal-autofocus`,X.rateLimitEditing?!0:void 0)),da(n,()=>X.rateLimitForm.max_requests,e=>X.rateLimitForm.max_requests=e),z(e,n)},$$slots:{default:!0}})}var u=P(l,2),d=e=>{SE(e,{id:`rate-limit-max-tokens`,label:`Max Tokens`,children:(e,t)=>{var n=MD();na(n),da(n,()=>X.rateLimitForm.max_tokens,e=>X.rateLimitForm.max_tokens=e),z(e,n)},$$slots:{default:!0}})};V(u,e=>{X.rateLimitForm.period!==`concurrent`&&e(d)}),T(r);var f=P(r,4),p=e=>{z(e,ND())};V(f,e=>{X.rateLimitEditing&&e(p)}),z(e,n)},$$slots:{default:!0}})}D()}Hr([`change`,`input`]);var ID=R(` `),LD=R(` Edit`,1),RD=R(` `,1),zD=R(`
        In-flight
        `),BD=R(`
        Requests
        `),VD=R(`
        Tokens
        `),HD=R(`
        `),UD=R(`
        `);function WD(e,t){E(t,!0);var n=UD();H(n,21,()=>t.rules,e=>X.rateLimitKey(e),(e,t)=>{var n=HD(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=e=>{var n=ID(),r=M(n);{let e=O(()=>X.rateLimitScope(I(t))===`provider`?yo:Pa);K(r,{get icon(){return I(e)},class:`budget-period-icon`})}var i=P(r,2),a=M(i,!0);T(i),T(n),F((e,t)=>{W(n,`title`,e),B(a,t)},[()=>`Rule scope: `+X.rateLimitScopeLabel(I(t)),()=>X.rateLimitScopeLabel(I(t))]),z(e,n)},u=O(()=>X.rateLimitScope(I(t))!==`user_path`);V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=M(d);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?ja:Oo);K(f,{get icon(){return I(e)},class:`budget-period-icon`})}var p=P(f,2),m=M(p,!0);T(p),T(d),T(s);var h=P(s,2),g=M(h),_=M(g),v=M(_,!0);T(_),T(g);var y=P(g,2),b=M(y),x=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitForm(I(t)),children:(e,t)=>{var n=LD();K(N(n),{get icon(){return lo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},S=O(()=>!X.rateLimitIsReadOnly(I(t)));V(b,e=>{I(S)&&e(x)});var C=P(b,2);{let e=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting counters`:`Reset counters`),n=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t)));gT(C,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>X.resetRateLimit(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=RD(),i=N(r);K(i,{get icon(){return ho},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var w=P(C,2),ee=e=>{{let n=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting rate limit`:`Delete rate limit`),r=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>X.deleteRateLimit(I(t)),get disabled(){return I(r)},children:(e,n)=>{var r=RD(),i=N(r);K(i,{get icon(){return ko},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}},te=O(()=>!X.rateLimitIsReadOnly(I(t)));V(w,e=>{I(te)&&e(ee)}),T(y),T(h),T(i);var ne=P(i,2),re=M(ne),ie=e=>{var n=zD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u),T(l),T(o),T(n),F((e,t,n,r,i,l)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l)},[()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests),()=>`In-flight requests: `+X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` in flight`]),z(e,n)},ae=O(()=>X.rateLimitIsConcurrent(I(t)));V(re,e=>{I(ae)&&e(ie)});var oe=P(re,2),se=e=>{var n=BD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests),()=>`Requests used: `+X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` requests`,()=>X.formatRateLimitNumber(I(t).requests_remaining)+` left`]),z(e,n)},ce=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_requests);V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{var n=VD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens),()=>`Tokens used: `+X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)>=100}),()=>X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens)+` tokens`,()=>X.formatRateLimitNumber(I(t).tokens_remaining)+` left`]),z(e,n)},de=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_tokens);V(le,e=>{I(de)&&e(ue)}),T(ne),T(r),T(n),F((e,t,n,r,i)=>{W(a,`title`,e),B(o,t),B(m,n),W(_,`title`,r),B(v,i)},[()=>X.rateLimitScopeLabel(I(t))+`: `+X.rateLimitSubject(I(t)),()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n),D()}var GD=R(`

        Rate Limits

        `),KD=R(``),qD=R(`
        Rate limit management is unavailable.
        `),JD=R(``),YD=R(`
        `),XD=R(`

        No rate limits configured yet.

        `),ZD=R(`

        No rate limits match your filter.

        `),QD=R(`
        `);function $D(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`rate-limits`&&X.fetchRateLimitsPage()});let n=O(()=>X.filteredRateLimits());var r=QD(),i=M(r),a=M(i);KS(M(a),{copyId:`rate-limits-help-copy`,label:`rate limits help`,text:`Rate limits cap requests, tokens, and in-flight concurrency for a user path subtree, a provider, or a model. Consumer (user path) breaches return 429 with Retry-After and x-ratelimit-* headers; saturated providers and models are skipped by load balancing and failover while capacity exists elsewhere. Counters are per gateway instance and reset on restart; token limits need usage tracking.`,title:e=>{z(e,GD())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=KD();K(M(t),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=X.rateLimitFormSubmitting),L(`click`,t,()=>X.openRateLimitForm()),z(e,t)},l=O(()=>X.rateLimitsEnabled()&&X.rateLimitsAvailable&&!q.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Pc(u,{});var d=P(u,2),f=e=>{z(e,qD())},p=O(()=>(!X.rateLimitsEnabled()||!X.rateLimitsAvailable)&&!q.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=JD(),n=M(t,!0);T(t),F(()=>B(n,X.rateLimitError)),z(e,t)};V(m,e=>{X.rateLimitError&&!q.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading rate limits...`})};V(g,e=>{X.rateLimitsLoading&&!q.authError&&e(_)});var v=P(g,2),y=e=>{var t=YD(),n=M(t);yw(M(n),{id:`rate-limit-filter`,placeholder:`Filter by subject, scope, or period...`,label:`Filter rate limits by subject, scope, or period`,get value(){return X.rateLimitFilter},set value(e){X.rateLimitFilter=e}}),T(n),T(t),z(e,t)};V(v,e=>{(X.rateLimits.length>0||X.rateLimitFilter)&&X.rateLimitsAvailable&&!q.authError&&!X.rateLimitFormOpen&&e(y)});var b=P(v,2);FD(b,{});var x=P(b,2),S=e=>{WD(e,{get rules(){return I(n)}})};V(x,e=>{I(n).length>0&&X.rateLimitsAvailable&&!q.authError&&e(S)});var C=P(x,2),w=e=>{z(e,XD())},ee=O(()=>X.rateLimits.length===0&&!X.rateLimitFilter&&!X.rateLimitsLoading&&!q.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,ZD())},re=O(()=>X.rateLimits.length>0&&I(n).length===0&&X.rateLimitFilter&&!X.rateLimitsLoading&&!q.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function eO(e){return String(e||``).trim().toLowerCase()}function tO(e){if(!e)return``;let t=String(e.selector||``).trim();if(t)return t;if(!e.model||!e.model.id)return``;let n=String(e.model.id||``).trim(),r=String(e.provider_name||``).trim();if(r)return r+`/`+n;let i=String(e.provider_type||``).trim();return!i||n.includes(`/`)?n:i+`/`+n}function nO(e,t,n,r){let i=new Set,a=String(e||``).trim().toLowerCase(),o=String(t||``).trim().toLowerCase(),s=String(n||``).trim().toLowerCase(),c=String(r||``).trim().toLowerCase();if(c&&i.add(c),!a)return i;i.add(a),s&&i.add(s+`/`+a),o&&!a.includes(`/`)&&i.add(o+`/`+a);let l=a.split(`/`);return l.length===2&&l[1]&&i.add(l[1]),i}function rO(e){return nO(e&&e.model?e.model.id:``,e?e.provider_type:``,e?e.provider_name:``,e?e.selector:``)}function iO(e){let t=new Set,n=String(e.resolved_model||``).trim().toLowerCase(),r=String(e.target_model||``).trim().toLowerCase(),i=String(e.target_provider||``).trim().toLowerCase();if(n){t.add(n);let e=n.split(`/`);e.length===2&&e[1]&&t.add(e[1])}if(r){t.add(r);let e=r.split(`/`);e.length===2&&e[1]&&t.add(e[1])}return r&&i&&t.add(i+`/`+r),t}function aO(e){if(!e)return``;let t=String(e.provider||``).trim(),n=String(e.model||``).trim();return!t||!n||n===t||n.startsWith(t+`/`)?n:t+`/`+n}function oO(e){if(e===``||e==null)return null;let t=Number(e);return!Number.isFinite(t)||t<=0?null:t}function sO(e,t){let n={model:e},r=oO(t);return r!==null&&(n.weight=r),n}function cO(e){let t=Array.isArray(e)?e:[],n=[];for(let e of t){let t=String(e&&e.model||``).trim();t&&n.push(sO(t,e&&e.weight))}return n}function lO(e){switch(String(e||``).toLowerCase()){case`cost`:return`lowest cost`;case`round_robin`:case``:return`round robin`;default:return e}}var uO={round_robin:`Round-robin (rotate across targets; honors weights)`,cost:`Lowest cost (cheapest target per request)`,adaptive:`Adaptive (target chosen by the registered routing extension)`};function dO(e,t){let n=Array.isArray(e)?[...e]:[],r=String(t||``).trim().toLowerCase();return r&&!n.includes(r)&&n.push(r),n.map(e=>({value:e,label:uO[e]||e}))}function fO(e){let t=Array.isArray(e.targets)?e.targets:[],n=t.length>0?t[0]:{},r=t.map(e=>{let t={provider:e.provider||``,model:e.model||``};return e.weight&&(t.weight=e.weight),t});return{name:e.source,target_provider:n.provider||``,target_model:n.model||``,targets:r,strategy:e.strategy||``,session_affinity:e.session_affinity!==!1,description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,valid:!!e.valid,resolved_model:e.resolved_model||``,provider_type:e.provider_type||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[]}}function pO(e){let t=Array.isArray(e)?e:[],n=[],r=[];for(let e of t)!e||typeof e!=`object`||(e.kind===`redirect`?n.push(fO(e)):e.kind===`policy`&&r.push({selector:e.source,provider_name:e.provider_name||``,model:e.model||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[],description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,scope_kind:e.scope_kind||``}));return{aliases:n,policies:r}}function mO(e){if(!e)return`—`;let t=Array.isArray(e.targets)?e.targets:[];return t.length>1?t.length+` targets · `+lO(e.strategy):e.resolved_model?e.resolved_model:e.target_provider?e.target_provider+`/`+e.target_model:e.target_model||`—`}function hO(e){return e?e.enabled===!1?`is-disabled`:e.valid?`is-valid`:`is-invalid`:`is-invalid`}function gO(e){return e?e.enabled===!1?`Disabled`:e.valid?`Active`:`Invalid`:`Invalid`}function _O(e){return Array.isArray(e)&&e.length>0&&e.indexOf(`/`)===-1}function vO(e,t){return!t||!e?``:e.effective_enabled===!1?`is-disabled`:_O(e.user_paths)?`is-restricted`:`is-enabled`}function yO(e){if(!e)return``;let t=[];e.effective_enabled===!1&&t.push(e.default_enabled===!1?`Disabled by default`:`Disabled`);let n=Array.isArray(e.user_paths)?e.user_paths:[];return n.length>0&&t.push(`Allowed for `+n.join(`, `)),t.join(` · `)}function bO({models:e,aliases:t,virtualModelsAvailable:n,activeCategory:r}){let i=Array.isArray(e)?e:[],a=Array.isArray(t)?t:[],o=new Map;if(n)for(let e of a){let t=eO(e&&e.name);!t||e.enabled===!1||!e.valid||o.set(t,e)}let s=new Map,c=i.map(e=>{let t=tO(e),n=null;for(let t of rO(e))s.has(t)||s.set(t,e),!n&&o.has(t)&&(n=o.get(t));let r=e&&e.access?e.access:null;return{key:`model:`+t,display_name:t,secondary_name:``,provider_name:e.provider_name||``,provider_type:e.provider_type||``,model:e.model,selector:e.selector||``,is_alias:!1,alias:null,access:r,masking_alias:n,has_virtual_model:!!(n||r&&r.override),alias_state_class:``,alias_state_text:``}});if(!n)return c;for(let e of a){let t=s.get(eO(e&&e.name));if(e&&e.enabled!==!1&&e.valid&&t)continue;let n=null;for(let t of iO(e))if(n=s.get(t)||null,n)break;!n&&r&&r!==`all`||c.push({key:`alias:`+e.name,display_name:e.name,secondary_name:mO(e),provider_name:n&&n.provider_name||``,provider_type:n?n.provider_type||e.provider_type||``:e.provider_type||``,model:n?n.model:{id:e.name,object:`model`},selector:``,is_alias:!0,alias:e,access:null,masking_alias:null,source_model_exists:!!t,has_virtual_model:!0,alias_state_class:hO(e),alias_state_text:gO(e)})}return c.sort((e,t)=>e.is_alias===t.is_alias?String(e.display_name||``).localeCompare(String(t.display_name||``)):e.is_alias?-1:1)}function xO(e,t){if(!t)return e;let n=String(t).toLowerCase();return e.filter(e=>[e.display_name,e.secondary_name,e.provider_name,e.provider_type,e.model&&e.model.owned_by,e.alias&&e.alias.description,e.alias&&e.alias_state_text,e.model&&e.model.metadata&&e.model.metadata.modes?e.model.metadata.modes.join(`,`):``,e.model&&e.model.metadata&&e.model.metadata.categories?e.model.metadata.categories.join(`,`):``].some(e=>String(e||``).toLowerCase().includes(n)))}function SO(e,t){return String(e||``).trim()||String(t||``).trim()||`Unassigned`}function CO(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!r||r===n?``:r}function wO(e){let t=String(e||``).trim();return t?t+`/`:``}function TO(e){let t=Array.isArray(e)?e:[],n=t.filter(e=>e&&!e.is_alias).length,r=t.filter(e=>e&&e.is_alias).length,i=[];return n>0&&i.push(n+(n===1?` model`:` models`)),r>0&&i.push(r+(r===1?` alias`:` aliases`)),i.join(` · `)}function EO(e,t,n){let r=String(t||``).trim(),i=String(n||``).trim();for(let t of Array.isArray(e)?e:[]){let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim();if(!(r&&e!==r)&&!(!r&&i&&n!==i)&&t&&t.access)return t.access.default_enabled!==!1}return!0}function DO(e){for(let t of Array.isArray(e)?e:[])if(t&&t.access)return t.access.default_enabled!==!1;return!0}function OO(e,t){let n=String(t||``).trim();if(!n)return null;for(let t of Array.isArray(e)?e:[])if(String(t&&t.selector||``).trim()===n)return t;return null}function kO(e,t,n,r){let i=wO(t),a=r&&r.get(`/`)||null,o=i&&r&&r.get(i)||null,s=EO(e,t,n),c=o||a,l=c&&Array.isArray(c.user_paths)?Array.from(new Set(c.user_paths)).sort():[];return{selector:i,default_enabled:s,effective_enabled:c?c.enabled!==!1:s,user_paths:l,override:o}}function AO(e,t,n){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let e of Array.isArray(n)?n:[]){let t=String(e&&e.selector||``).trim();t&&r.set(t,e)}let i=[],a=new Map;for(let t of e){if(t&&t.is_alias){i.push(t);continue}let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim(),r=`provider-group:`+(e||n||`unassigned`);a.has(r)||a.set(r,{key:r,provider_name:e,provider_type:n,display_name:SO(e,n),type_label:CO(e,n),rows:[]});let o=a.get(r);!o.provider_name&&e&&(o.provider_name=e),!o.provider_type&&n&&(o.provider_type=n),o.display_name=SO(o.provider_name,o.provider_type),o.type_label=CO(o.provider_name,o.provider_type),o.rows.push(t)}let o=Array.from(a.values()).map(e=>{let n=kO(t,e.provider_name,e.provider_type,r);return{...e,access:n,access_summary:yO(n),item_count_label:TO(e.rows)}}).sort((e,t)=>String(e.display_name||``).localeCompare(String(t.display_name||``)));return i.length>0&&o.unshift({key:`virtual-model-group`,is_virtual_models:!0,provider_name:``,provider_type:``,display_name:`Virtual models`,type_label:``,rows:i,access:{selector:``},access_summary:``,item_count_label:TO(i)}),o}function jO(e,t){let n=OO(t,`/`),r=DO(e),i=n&&Array.isArray(n.user_paths)?n.user_paths:[];return{key:`scope-global`,is_alias:!1,display_name:`all providers and models`,access:{selector:`/`,default_enabled:r,effective_enabled:n?n.enabled!==!1:r,user_paths:i,override:n}}}function MO(e){return e?String(e.access&&e.access.selector||``).trim()||String(e.override_selector||``).trim()||tO(e):``}function NO(e){if(!e)return[];let t=[];return e.is_alias?t.push(`alias-row`,hO(e.alias)):e.has_virtual_model&&t.push(`alias-row`,`is-valid`),!e.is_alias&&e.masking_alias&&t.push(`masked-model-row`),!e.is_alias&&e.access&&e.access.effective_enabled===!1&&t.push(`model-access-disabled-row`),t}function PO(e){return!!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)}function FO(e){return!!(e&&!e.is_alias&&e.masking_alias&&e.masking_alias.name&&!e.masking_alias.managed)}function IO(e){return e&&e.is_alias&&e.alias&&e.alias.name?`alias-row-`+String(e.alias.name).replace(/[^a-zA-Z0-9_-]+/g,`-`):``}function LO(e){return e?e.is_alias?!!(e.alias&&e.alias.managed):!!(e.access&&e.access.override&&e.access.override.managed||e.masking_alias&&e.masking_alias.managed):!1}function RO(e){return!!(e&&e.override)}function zO(e){return e?`table-action-btn-active`:``}function BO(e,t){let n=`Edit `+String(e||`model access`);return t?n+` (virtual model exists)`:n}function VO(){return{source:``,target_model:``,target_weight:1,targets:[],strategy:`round_robin`,session_affinity:!0,user_paths:``,description:``,enabled:!0}}function HO(e){return String(e&&e.target_model||``).trim()!==``}function UO(e){return String(e&&e.target_model||``).trim()?!0:cO(e&&e.targets).length>0}function WO(e){return!!e&&Array.isArray(e.targets)&&e.targets.length>0}function GO(e){return WO(e)&&String(e&&e.strategy||``).toLowerCase()!==`cost`}function KO(e){let t=Array.isArray(e.targets)?e.targets:[];if(t.length>0){let n=t.shift();e.target_model=n.model||``,e.target_weight=n.weight||1;return}e.target_model=``,e.target_weight=1}function qO(e){let t=Array.isArray(e&&e.targets)?e.targets:[];return t.length>0?{primaryModel:aO(t[0]),primaryWeight:t[0].weight||1,extraTargets:t.slice(1).map(e=>({model:aO(e),weight:e.weight||1}))}:{primaryModel:e&&e.target_provider?e.target_provider+`/`+e.target_model:e&&e.target_model||``,primaryWeight:1,extraTargets:[]}}function JO(e){return String(e||``).split(/\r?\n|,/).map(e=>String(e||``).trim()).filter(Boolean)}function YO(e,t,n){let r=String(e&&e.source||``).trim(),i=String(e&&e.target_model||``).trim(),a=cO(e&&e.targets),o=UO(e),s=String(t||``).trim(),c=n===`edit`&&!!s&&r!==s,l={source:r,user_paths:JO(e&&e.user_paths),description:String(e&&e.description||``).trim(),enabled:!!(e&&e.enabled)};if(c&&(l.old_source=s),o){let t=[];if(i&&t.push(sO(i,e.target_weight)),t.push(...a),t.length>1){let n=e.strategy||`round_robin`;l.targets=n===`cost`?t.map(e=>({model:e.model})):t,l.strategy=n,e&&e.session_affinity===!1&&(l.session_affinity=!1)}else l.target_model=t[0].model}return{payload:l,source:r,isRedirect:o,isRename:c}}function XO(e){let t={source:e.name,description:String(e.description||``).trim(),user_paths:Array.isArray(e.user_paths)?e.user_paths:[],enabled:e.enabled===!1},n=Array.isArray(e.targets)?e.targets:[];return n.length>1?(t.strategy=e.strategy||`round_robin`,e.session_affinity===!1&&(t.session_affinity=!1),t.targets=t.strategy===`cost`?n.map(e=>({model:aO(e)})):n.map(e=>sO(aO(e),e.weight))):n.length===1?t.target_model=aO(n[0]):t.target_model=e.target_provider?e.target_provider+`/`+e.target_model:e.target_model,t}function ZO(e,t,n){let r=n||{},i=r.effective_enabled===!1,a=t&&Array.isArray(t.user_paths)?t.user_paths:[],o=`PUT`,s;return i===!1?s={source:e,enabled:!1,user_paths:a}:t&&a.length===0&&r.default_enabled!==!1?(o=`DELETE`,s={source:e}):s={source:e,enabled:!0,user_paths:a},{method:o,payload:s,desired:i}}function QO(e,t,n){let r=Math.max(1,Number(t||75)),i=Math.min(n,e+r);return{limit:i,rendering:ibO({models:Mc.models,aliases:this.aliases,virtualModelsAvailable:this.virtualModelsAvailable,activeCategory:Mc.activeCategory}));get displayModels(){return I(this.#T)}set displayModels(e){A(this.#T,e)}#E=O(()=>AO(this.displayModels,Mc.models,this.modelOverrideViews));get displayModelGroups(){return I(this.#E)}set displayModelGroups(e){A(this.#E,e)}#D=O(()=>xO(this.displayModels,Mc.filter));get filteredDisplayModels(){return I(this.#D)}set filteredDisplayModels(e){A(this.#D,e)}#O=O(()=>{let e=this.filteredDisplayModels,t=Math.max(0,Math.min(Number(this.modelRenderLimit||0),e.length));return!Mc.filter&&t>=this.displayModels.length?this.displayModelGroups:AO(e.slice(0,t),Mc.models,this.modelOverrideViews)});get filteredDisplayModelGroups(){return I(this.#O)}set filteredDisplayModelGroups(e){A(this.#O,e)}#k=O(()=>jO(Mc.models,this.modelOverrideViews));get globalScopeRow(){return I(this.#k)}set globalScopeRow(e){A(this.#k,e)}modelsBusy(){return!!(Mc.loading||this.modelsRendering)}modelLoadingText(){if(Mc.loading)return this.displayModels.length>0?`Refreshing models...`:`Loading models...`;let e=this.filteredDisplayModels.length;return`Rendering models... `+Math.min(Number(this.modelRenderLimit||0),e)+` / `+e}restartModelRendering(e){let t=++this.#a,n=$O(this.modelRenderBatchSize,e);this.modelRenderLimit=n.limit,this.modelsRendering=n.rendering,n.rendering&&this.#A(t)}stopModelRendering(){this.#a++,this.modelsRendering=!1}#A(e){let t=()=>{if(e!==this.#a)return;let t=QO(this.modelRenderLimit,this.modelRenderBatchSize,this.filteredDisplayModels.length);this.modelRenderLimit=t.limit,this.modelsRendering=t.rendering,t.rendering&&this.#A(e)};typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>setTimeout(t,0)):setTimeout(t,0)}async fetchVirtualModels(){this.aliasLoading=!0,this.aliasError=``;try{let e=await gs(`/admin/virtual-models`,{label:`virtual models`});if(e.status===503){this.virtualModelsAvailable=!1,this.aliases=[],this.modelOverrideViews=[];return}if(e.stale)return;if(this.virtualModelsAvailable=!0,!e.ok){this.aliases=[],this.modelOverrideViews=[];return}let{aliases:t,policies:n}=pO(e.data);this.aliases=t,this.modelOverrideViews=n}catch(e){console.error(`Failed to fetch virtual models:`,e),this.aliases=[],this.modelOverrideViews=[],this.aliasError=`Unable to load virtual models.`}finally{this.aliasLoading=!1}}qualifiedModelName(e){return tO(e)}findModelOverrideView(e){return OO(this.modelOverrideViews,e)}hasGlobalModelOverride(){return!!this.findModelOverrideView(`/`)}findExistingAliasByName(e){let t=eO(e);if(!t)return null;for(let e of this.aliases)if(eO(e&&e.name)===t)return e;return null}findConcreteModelByName(e){let t=eO(e);if(!t)return null;for(let e of Mc.models)if(rO(e).has(t))return e;return null}rowToggleEnabled(e){return e?e.is_alias?e.alias&&e.alias.enabled!==!1:!!(e.access&&e.access.effective_enabled!==!1):!1}rowToggleLabel(e){return this.rowTogglingKey&&this.rowTogglingKey===e.key?`Updating...`:this.rowToggleRestricted(e)?`Restricted`:this.rowToggleEnabled(e)?`Enabled`:`Disabled`}rowToggleRestricted(e){return!!e&&!e.is_alias&&vO(e.access,this.virtualModelsAvailable)===`is-restricted`}rowToggleAriaLabel(e){if(!e)return``;let t=this.rowToggleEnabled(e)?`Disable `:`Enable `,n;return n=e.is_alias?`alias `+String(e.alias&&e.alias.name||``):String(e.display_name||e.access&&e.access.selector||`model`),t+n.trim()}async toggleRowEnabled(e){if(this.virtualModelsAvailable&&!(!e||this.rowTogglingKey===e.key)){if(LO(e)){J.success(`This virtual model is managed by configuration and is read-only.`);return}if(e.is_alias){await this.toggleAliasRow(e);return}await this.toggleModelRow(e)}}async toggleAliasRow(e){let t=e.alias;if(!t||!t.name)return;this.rowTogglingKey=e.key;let n=XO(t);try{let e=await _s(`/admin/virtual-models`,`PUT`,n,{label:`alias state`});if(e.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(e.stale)return;if(!e.ok){J.error(e.status===401?`Authentication required.`:fs(e,`Failed to update alias state.`));return}J.success(n.enabled?`Alias enabled.`:`Alias disabled.`),this.fetchVirtualModels()}catch(e){console.error(`Failed to toggle alias state:`,e),J.error(`Failed to update alias state.`)}finally{this.rowTogglingKey=``}}async toggleModelRow(e){let t=MO(e);if(!t)return;let{method:n,payload:r,desired:i}=ZO(t,this.findModelOverrideView(t),e.access||{});this.rowTogglingKey=e.key;try{let e=await _s(`/admin/virtual-models`,n,r,{label:`model access`});if(e.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(!(n===`DELETE`&&e.status===404)){if(e.stale)return;if(!e.ok){J.error(e.status===401?`Authentication required.`:fs(e,`Failed to update model access.`));return}}J.success(i?`Model enabled.`:`Model disabled.`),Promise.all([Mc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to toggle model access:`,e),J.error(`Failed to update model access.`)}finally{this.rowTogglingKey=``}}async removeAliasRow(e){if(!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)||this.rowDeletingKey)return;let t=String(e.alias.name||``).trim();t&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the virtual model alias "`+t+`"?`,method:`DELETE`,payload:{source:t},operation:`virtual model`,failureMessage:`Failed to remove virtual model.`,notice:`Virtual model removed.`,ignoreNotFound:!0})}async removeRedirectRow(e){let t=e&&e.masking_alias;if(!(e&&!e.is_alias&&t&&t.name&&!t.managed)||this.rowDeletingKey)return;let n=String(t.name||``).trim();n&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the redirect for "`+n+`"? Other virtual model settings will be preserved.`,method:`PUT`,payload:{source:n,user_paths:Array.isArray(t.user_paths)?t.user_paths:[],description:String(t.description||``).trim(),enabled:t.enabled!==!1},operation:`virtual model redirect`,failureMessage:`Failed to remove redirect.`,notice:`Redirect removed. Other virtual model settings were preserved.`})}async mutateVirtualModelRow(e){if(!this.rowDeletingKey&&window.confirm(e.confirmMessage)){this.rowDeletingKey=e.rowKey;try{let t=await _s(`/admin/virtual-models`,e.method,e.payload,{label:e.operation});if(t.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(!(e.ignoreNotFound&&t.status===404)){if(t.stale)return;if(!t.ok){J.error(t.status===401?`Authentication required.`:fs(t,e.failureMessage));return}}this.virtualModelsAvailable=!0,J.success(e.notice),Promise.all([Mc.fetchModels(),this.fetchVirtualModels()])}catch(t){console.error(e.failureMessage,t),J.error(e.failureMessage)}finally{this.rowDeletingKey=``}}}addVmTarget(){Array.isArray(this.vmForm.targets)||(this.vmForm.targets=[]),this.vmForm.targets.push({model:``,weight:1})}removeVmTarget(e){Array.isArray(this.vmForm.targets)&&this.vmForm.targets.splice(e,1)}removePrimaryTarget(){KO(this.vmForm)}vmFormHasPrimaryTarget(){return HO(this.vmForm)}vmFormShowStrategy(){return WO(this.vmForm)}vmStrategyOptions(){return dO(xs.virtualModelStrategies(),this.vmForm.strategy)}vmFormShowWeights(){return GO(this.vmForm)}vmFormToggleRestricted(){return!!(this.vmForm&&this.vmForm.enabled)&&_O(JO(this.vmForm.user_paths))}vmFormToggleLabel(){return!this.vmForm||!this.vmForm.enabled?`Disabled`:this.vmFormToggleRestricted()?`Restricted`:`Enabled`}resetVirtualModelForm(){this.vmFormError=``,this.vmFormHelpOpen=!1,this.vmFormUserPathsHelpOpen=!1,this.vmSubmitting=!1,this.vmDeleting=!1,this.vmFormHasExisting=!1,this.vmFormDefaultEnabled=!0,this.vmFormEffectiveEnabled=!0,this.vmFormDisplayName=``,this.vmFormSourceLocked=!1,this.vmFormOriginalSource=``,this.vmFormManaged=!1,this.vmForm=VO()}closeVirtualModelForm(){this.vmFormOpen=!1,this.resetVirtualModelForm()}openVirtualModelCreate(e){this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`create`,this.vmFormSourceLocked=!1,this.vmFormDisplayName=`New virtual model`,e&&e.model&&e.model.id&&(this.vmForm.target_model=tO(e))}openVirtualModelEditAlias(e){if(!e)return;this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!1,this.vmFormHasExisting=!0,this.vmFormManaged=!!e.managed,this.vmFormOriginalSource=e.name||``,this.vmFormDisplayName=e.name||``,this.vmFormDefaultEnabled=DO(Mc.models),this.vmFormEffectiveEnabled=e.enabled!==!1;let{primaryModel:t,primaryWeight:n,extraTargets:r}=qO(e);this.vmForm={source:e.name||``,target_model:t,target_weight:n,targets:r,strategy:e.strategy||`round_robin`,session_affinity:e.session_affinity!==!1,user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` +`),description:e.description||``,enabled:e.enabled!==!1}}openVirtualModelEditModel(e){if(!e||e.is_alias)return;let t=e.access||{},n=t.override||null,r=n&&Array.isArray(n.user_paths)?n.user_paths:Array.isArray(t.user_paths)?t.user_paths:[],i=MO(e);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!n,this.vmFormOriginalSource=i;let a=n?n.enabled!==!1:t.effective_enabled!==!1;this.vmFormDefaultEnabled=t.default_enabled!==!1,this.vmFormEffectiveEnabled=a,this.vmFormManaged=!!(n&&n.managed),this.vmFormDisplayName=e.access_display_name||e.display_name||i||``,this.vmForm={source:i,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:r.join(` +`),description:n&&n.description?n.description:``,enabled:a}}openGlobalModelOverrideEdit(){let e=this.findModelOverrideView(`/`),t=e&&Array.isArray(e.user_paths)?e.user_paths:[],n=DO(Mc.models);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!e,this.vmFormOriginalSource=`/`,this.vmFormDefaultEnabled=n,this.vmFormEffectiveEnabled=e?e.enabled!==!1:n,this.vmFormManaged=!!(e&&e.managed),this.vmFormDisplayName=`All providers and models`,this.vmForm={source:`/`,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:t.join(` +`),description:e&&e.description?e.description:``,enabled:e?e.enabled!==!1:n}}openProviderOverrideEdit(e){!e||!e.access||!e.access.selector||this.openVirtualModelEditModel({display_name:e.display_name,access_display_name:`All models in `+e.display_name,provider_name:e.provider_name,provider_type:e.provider_type,access:e.access,override_selector:e.access.selector,is_alias:!1})}async submitVirtualModelForm(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be edited here.`;return}let{payload:e,source:t,isRedirect:n,isRename:r}=YO(this.vmForm,this.vmFormOriginalSource,this.vmFormMode);if(!t){this.vmFormError=`Source is required.`;return}if(this.vmFormError=``,this.vmFormMode!==`edit`){let e=this.findExistingAliasByName(t),r=e?null:this.findModelOverrideView(t);if(e||r){let n=e?`A virtual model named "`+e.name+`" already exists. Saving will update that virtual model. Continue?`:`An access policy for "`+t+`" already exists. Saving will update that virtual model. Continue?`;if(!window.confirm(n)){this.vmFormError=`Choose a different source or edit the existing virtual model.`;return}}else if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Creating this alias will mask that model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}else if(r){let e=(this.aliases||[]).find(e=>e&&e.name===t)||null,r=e?null:this.findModelOverrideView(t);if(e||r){this.vmFormError=`A virtual model for "`+t+`" already exists. Choose a different source.`;return}if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Renaming to that name will mask the model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}this.vmSubmitting=!0;try{let t=await _s(`/admin/virtual-models`,`PUT`,e,{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:fs(t,`Failed to save virtual model.`);return}let r=!n&&t.status===204;this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),J.success(n?`Alias saved.`:r?`Model access reset to inherited/default.`:`Model access saved.`),Promise.all([Mc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to save virtual model:`,e),this.vmFormError=`Failed to save virtual model.`}finally{this.vmSubmitting=!1}}async deleteVirtualModel(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be removed here.`;return}let e=String(this.vmForm.source||this.vmFormOriginalSource||``).trim();if(!(!e||!this.vmFormHasExisting)&&window.confirm(`Remove the virtual model for "`+e+`"? This reverts to inherited/default behavior.`)){this.vmDeleting=!0,this.vmFormError=``;try{let t=await _s(`/admin/virtual-models`,`DELETE`,{source:e},{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:fs(t,`Failed to remove virtual model.`);return}}this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),J.success(`Virtual model removed.`),Promise.all([Mc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to delete virtual model:`,e),this.vmFormError=`Failed to remove virtual model.`}finally{this.vmDeleting=!1}}}},tk=[{value:`input_per_mtok`,label:`Input $/MTok`,group:`Tokens`},{value:`output_per_mtok`,label:`Output $/MTok`,group:`Tokens`},{value:`cached_input_per_mtok`,label:`Cached input $/MTok`,group:`Tokens`},{value:`cache_write_per_mtok`,label:`Cache write $/MTok`,group:`Tokens`},{value:`reasoning_output_per_mtok`,label:`Reasoning output $/MTok`,group:`Tokens`},{value:`batch_input_per_mtok`,label:`Batch input $/MTok`,group:`Batch`},{value:`batch_output_per_mtok`,label:`Batch output $/MTok`,group:`Batch`},{value:`audio_input_per_mtok`,label:`Audio input $/MTok`,group:`Audio`},{value:`audio_output_per_mtok`,label:`Audio output $/MTok`,group:`Audio`},{value:`per_image`,label:`$/Image`,group:`Image`},{value:`input_per_image`,label:`Input $/Image`,group:`Image`},{value:`per_second_input`,label:`Input $/Second`,group:`Audio/Video`},{value:`per_second_output`,label:`Output $/Second`,group:`Video`},{value:`per_character_input`,label:`$/Character`,group:`Audio`},{value:`per_page`,label:`$/Page`,group:`Utility`},{value:`per_request`,label:`$/Request`,group:`Utility`}];function nk(e){let t=tk.find(t=>t.value===e);return t?t.label:String(e||``).replace(/_/g,` `)}function rk(e){return e&&typeof e==`object`?JSON.parse(JSON.stringify(e)):{}}function ik(e,t){let n=rk(e),r=t&&t.pricing?t.pricing:t;if(!r||typeof r!=`object`)return n;for(let e of tk)r[e.value]!==null&&r[e.value]!==void 0&&(n[e.value]=Number(r[e.value]));return Array.isArray(r.tiers)&&r.tiers.length>0&&(n.tiers=rk(r.tiers)),n}function ak(e){switch(String(e||``).trim()){case`config_yaml`:return`config.yaml`;case`model_registry`:return`Model registry`;default:return e?String(e):`Unknown`}}function ok(e){let t=e&&e.pricing?e.pricing:{},n=e&&e.pricing_sources&&typeof e.pricing_sources==`object`?e.pricing_sources:{},r={};for(let e of tk)t[e.value]!==null&&t[e.value]!==void 0&&(r[e.value]=ak(n[e.value]||`model_registry`));return r}function sk(e){let t=String(e&&e.selector||``).trim();return t?`Dashboard/API override (`+t+`)`:`Dashboard/API override`}function ck(e){let t=String(e||``).trim();return t?t+`/`:``}function lk(e){return String(e&&e.model&&e.model.id||``).trim()}function uk(e){let t=String(e&&e.provider_name||``).trim(),n=lk(e);return t&&n?t+`/`+n:n}function dk(e){return lk(e)}function fk(e){let t=new Map;for(let n of Array.isArray(e)?e:[]){let e=String(n&&n.selector||``).trim();e&&t.set(e,n)}return t}function pk(e,t){let n=String(t||``).trim();return n&&fk(e).get(n)||null}function mk(e,t,n){let r=fk(e),i=uk(t),a=dk(t),o=ck(t&&t.provider_name),s=String(n||``).trim();for(let e of[i,a,o,`/`]){if(!e||e===s)continue;let t=r.get(e);if(t)return t}return null}function hk(e,t,n){let r=e&&e.model&&e.model.metadata?e.model.metadata:null,i=rk(r&&r.pricing),a=ok(r),o=mk(t,e,n),s=o&&o.pricing?o.pricing:null;if(s){let e=sk(o);for(let t of tk)s[t.value]!==null&&s[t.value]!==void 0&&(i[t.value]=Number(s[t.value]),a[t.value]=e);Array.isArray(s.tiers)&&s.tiers.length>0&&(i.tiers=rk(s.tiers),a.tiers=e)}return{pricing:i,sources:a}}function gk(e,t){let n=e&&e.pricing?e.pricing:{},r=[];for(let e of tk)n[e.value]!==null&&n[e.value]!==void 0&&r.push({id:t(),field:e.value,value:String(n[e.value])});return r}function _k(e,t){let n=new Set;for(let r of Array.isArray(e)?e:[]){if(t&&r.id===t)continue;let e=String(r.field||``).trim();e&&n.add(e)}return n}function vk(e,t){let n=_k(e,t&&t.id);return tk.filter(e=>e.value===(t&&t.field)||!n.has(e.value))}function yk(e,t){let n={},r=new Set;for(let t of Array.isArray(e)?e:[]){let e=String(t.field||``).trim();if(!e)return{error:`Choose a price type for every row.`};if(r.has(e))return{error:`Each price type can only be used once.`};r.add(e);let i=String(t.value||``).trim();if(i===``)return{error:`Enter a value for `+nk(e)+`.`};let a=Number(i);if(!Number.isFinite(a)||a<0)return{error:`Pricing values must be numbers greater than or equal to 0.`};n[e]=a}let i=Array.isArray(t)?t:[];return i.length>0&&(n.tiers=rk(i)),Object.keys(n).length===0?{error:`Add at least one pricing field before saving.`}:{pricing:n}}function bk(e,t,n){let r=e||{},i=t||{},a=n||{},o=ik(r,a);return tk.map(e=>{let t=a[e.value]!==null&&a[e.value]!==void 0,n=r[e.value]!==null&&r[e.value]!==void 0;return{field:e.value,label:e.label,value:o[e.value],source:t?`Form/API value`:n?i[e.value]||`Model registry`:`Unset`}}).filter(e=>e.source!==`Unset`||e.value!==void 0)}var xk=new class{#e=k(!0);get modelPricingOverridesAvailable(){return I(this.#e)}set modelPricingOverridesAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get modelPricingOverrideViews(){return I(this.#t)}set modelPricingOverrideViews(e){A(this.#t,e,!0)}#n=k(``);get modelPricingOverrideError(){return I(this.#n)}set modelPricingOverrideError(e){A(this.#n,e,!0)}#r=k(!1);get modelPricingOverrideFormOpen(){return I(this.#r)}set modelPricingOverrideFormOpen(e){A(this.#r,e,!0)}#i=k(!1);get modelPricingOverrideSubmitting(){return I(this.#i)}set modelPricingOverrideSubmitting(e){A(this.#i,e,!0)}#a=k(!1);get modelPricingOverrideFormHasExistingOverride(){return I(this.#a)}set modelPricingOverrideFormHasExistingOverride(e){A(this.#a,e,!0)}#o=k(``);get modelPricingOverrideFormDisplayName(){return I(this.#o)}set modelPricingOverrideFormDisplayName(e){A(this.#o,e,!0)}#s=k(``);get modelPricingOverrideFormScope(){return I(this.#s)}set modelPricingOverrideFormScope(e){A(this.#s,e,!0)}#c=k(j([]));get modelPricingOverrideFormScopeOptions(){return I(this.#c)}set modelPricingOverrideFormScopeOptions(e){A(this.#c,e,!0)}#l=k(null);get modelPricingOverrideFormRow(){return I(this.#l)}set modelPricingOverrideFormRow(e){A(this.#l,e,!0)}#u=k(null);get modelPricingOverrideFormBasePricing(){return I(this.#u)}set modelPricingOverrideFormBasePricing(e){A(this.#u,e,!0)}#d=k(null);get modelPricingOverrideFormBasePricingSources(){return I(this.#d)}set modelPricingOverrideFormBasePricingSources(e){A(this.#d,e,!0)}#f=k(j([]));get modelPricingOverrideFormPreservedTiers(){return I(this.#f)}set modelPricingOverrideFormPreservedTiers(e){A(this.#f,e,!0)}#p=k(j([]));get modelPricingOverrideRows(){return I(this.#p)}set modelPricingOverrideRows(e){A(this.#p,e,!0)}#m=k(j({selector:``}));get modelPricingOverrideForm(){return I(this.#m)}set modelPricingOverrideForm(e){A(this.#m,e,!0)}_modelPricingOverrideRowID=0;pricingFieldOptions(){return tk}pricingFieldLabel(e){return nk(e)}async fetchModelPricingOverrides(){this.modelPricingOverrideError=``;try{let e=await gs(`/admin/model-pricing-overrides`,{label:`model pricing overrides`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideViews=[];return}if(e.stale)return;if(this.modelPricingOverridesAvailable=!0,!e.ok){this.modelPricingOverrideViews=[];return}this.modelPricingOverrideViews=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch model pricing overrides:`,e),this.modelPricingOverrideViews=[],this.modelPricingOverrideError=`Unable to load model pricing overrides.`}}findModelPricingOverrideView(e){return pk(this.modelPricingOverrideViews,e)}hasGlobalPricingOverride(){return!!this.findModelPricingOverrideView(`/`)}hasProviderPricingOverride(e){return!!this.findModelPricingOverrideView(ck(e&&e.provider_name))}hasModelPricingOverride(e){return!!this.findModelPricingOverrideView(uk(e))}modelPricingButtonClass(e){return e?`table-action-btn-active`:``}modelPricingButtonLabel(e,t){let n=`Edit `+String(e||`model pricing`);return t?n+` (override exists)`:n}modelRowPricing(e){return hk(e,this.modelPricingOverrideViews).pricing}openGlobalPricingOverrideEdit(){this.openModelPricingOverrideForm({displayName:`All providers and models`,selector:`/`,scope:`global`,scopeOptions:[{value:`global`,label:`All providers and models`,selector:`/`}],row:null})}openProviderPricingOverrideEdit(e){let t=ck(e&&e.provider_name);t&&this.openModelPricingOverrideForm({displayName:`All models in `+(e.display_name||e.provider_name||t),selector:t,scope:`provider`,scopeOptions:[{value:`provider`,label:`Provider`,selector:t}],row:null})}openModelPricingOverrideEdit(e){if(!e||e.is_alias)return;let t=uk(e),n=dk(e),r=[{value:`exact`,label:`This provider and model`,selector:t}];n&&n!==t&&r.push({value:`model`,label:`This model across providers`,selector:n}),this.openModelPricingOverrideForm({displayName:e.display_name||t,selector:t,scope:`exact`,scopeOptions:r,row:e})}openModelPricingOverrideForm(e){let t=e||{};this.modelPricingOverrideFormOpen=!0,this.modelPricingOverrideError=``,this.modelPricingOverrideFormDisplayName=t.displayName||t.selector||`Pricing`,this.modelPricingOverrideFormScope=t.scope||``,this.modelPricingOverrideFormScopeOptions=Array.isArray(t.scopeOptions)?t.scopeOptions:[],this.modelPricingOverrideFormRow=t.row||null,this.modelPricingOverrideForm={selector:t.selector||``},this.loadModelPricingOverrideFormSelector(t.selector||``)}loadModelPricingOverrideFormSelector(e){e=String(e||``).trim();let t=this.findModelPricingOverrideView(e);this.modelPricingOverrideFormHasExistingOverride=!!t,this.modelPricingOverrideRows=gk(t,()=>this.nextModelPricingOverrideRowID()),this.modelPricingOverrideFormPreservedTiers=t&&t.pricing&&Array.isArray(t.pricing.tiers)?rk(t.pricing.tiers):[],this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow();let n=this.modelPricingOverrideFormRow,r=n?hk(n,this.modelPricingOverrideViews,e):{pricing:{},sources:{}};this.modelPricingOverrideFormBasePricing=r.pricing,this.modelPricingOverrideFormBasePricingSources=r.sources}setModelPricingOverrideScope(e){this.modelPricingOverrideFormScope=e;let t=this.modelPricingOverrideFormScopeOptions.find(t=>t.value===e);t&&(this.modelPricingOverrideForm.selector=t.selector,this.loadModelPricingOverrideFormSelector(t.selector))}nextModelPricingOverrideRowID(){return this._modelPricingOverrideRowID=(this._modelPricingOverrideRowID||0)+1,`pricing-row-`+this._modelPricingOverrideRowID}availablePricingFieldOptions(e){return vk(this.modelPricingOverrideRows,e)}addModelPricingOverrideRow(){let e=_k(this.modelPricingOverrideRows),t=tk.find(t=>!e.has(t.value))||tk[0];t&&this.modelPricingOverrideRows.push({id:this.nextModelPricingOverrideRowID(),field:t.value,value:``})}removeModelPricingOverrideRow(e){this.modelPricingOverrideRows=this.modelPricingOverrideRows.filter(t=>t.id!==e.id),this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow()}modelPricingOverridePayload(){return yk(this.modelPricingOverrideRows,this.modelPricingOverrideFormPreservedTiers)}modelPricingOverrideDraftPricing(){let e=this.modelPricingOverridePayload();return e&&e.pricing?e.pricing:{}}modelPricingEffectivePreviewRows(){return bk(this.modelPricingOverrideFormBasePricing,this.modelPricingOverrideFormBasePricingSources,this.modelPricingOverrideDraftPricing())}closeModelPricingOverrideForm(){this.modelPricingOverrideFormOpen=!1,this.modelPricingOverrideSubmitting=!1,this.modelPricingOverrideError=``,this.modelPricingOverrideFormHasExistingOverride=!1,this.modelPricingOverrideFormDisplayName=``,this.modelPricingOverrideFormScope=``,this.modelPricingOverrideFormScopeOptions=[],this.modelPricingOverrideFormRow=null,this.modelPricingOverrideFormBasePricing=null,this.modelPricingOverrideFormBasePricingSources=null,this.modelPricingOverrideFormPreservedTiers=[],this.modelPricingOverrideRows=[],this.modelPricingOverrideForm={selector:``}}async submitModelPricingOverrideForm(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!e){this.modelPricingOverrideError=`Model pricing selector is required.`;return}let t=this.modelPricingOverridePayload();if(t.error){this.modelPricingOverrideError=t.error;return}let n={selector:e,...t};this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let e=await _s(`/admin/model-pricing-overrides`,`PUT`,n,{label:`model pricing override`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(e.stale)return;if(!e.ok){this.modelPricingOverrideError=e.status===401?`Authentication required.`:fs(e,`Failed to save model pricing.`);return}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),J.success(`Model pricing saved.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to save model pricing override:`,e),this.modelPricingOverrideError=`Failed to save model pricing.`}finally{this.modelPricingOverrideSubmitting=!1}}async deleteModelPricingOverride(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!(!e||!this.modelPricingOverrideFormHasExistingOverride)&&window.confirm(`Remove the model pricing override for "`+e+`"?`)){this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let t=await _s(`/admin/model-pricing-overrides`,`DELETE`,{selector:e},{label:`model pricing override`});if(t.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.modelPricingOverrideError=t.status===401?`Authentication required.`:fs(t,`Failed to remove model pricing override.`);return}}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),J.success(`Model pricing override removed.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to delete model pricing override:`,e),this.modelPricingOverrideError=`Failed to remove model pricing override.`}finally{this.modelPricingOverrideSubmitting=!1}}}},Sk=R(``);function Ck(e,t){E(t,!0);var n=Sk();let r;var i=P(M(n),2),a=M(i,!0);T(i),T(n),F((e,i,o)=>{r=U(n,1,`alias-toggle`,null,r,e),n.disabled=ek.rowTogglingKey===t.row.key||!ek.virtualModelsAvailable,W(n,`aria-label`,i),B(a,o)},[()=>({enabled:ek.rowToggleEnabled(t.row),restricted:ek.rowToggleRestricted(t.row)}),()=>ek.rowToggleAriaLabel(t.row),()=>ek.rowToggleLabel(t.row)]),L(`click`,n,()=>ek.toggleRowEnabled(t.row)),z(e,n),D()}Hr([`click`]);var wk=R(`
        `);function Tk(e,t){E(t,!0);var n=wk(),r=M(n),i=e=>{Ck(e,{get row(){return ek.globalScopeRow}})};V(r,e=>{ek.virtualModelsAvailable&&e(i)});var a=P(r,2),o=e=>{{let t=O(()=>xk.modelPricingButtonLabel(`global model pricing`,xk.hasGlobalPricingOverride())),n=O(()=>xk.modelPricingButtonClass(xk.hasGlobalPricingOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>xk.openGlobalPricingOverrideEdit(),children:(e,t)=>{K(e,{get icon(){return Ka},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(a,e=>{xk.modelPricingOverridesAvailable&&e(o)});var s=P(a,2),c=e=>{{let t=O(()=>BO(`global model access`,ek.hasGlobalModelOverride())),n=O(()=>zO(ek.hasGlobalModelOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>ek.openGlobalModelOverrideEdit(),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n),D()}function Ek(e){return String(e&&(e.primary_model||e.source)||``).trim()}function Dk(e){return Array.isArray(e&&e.fallback_models)?e.fallback_models:Array.isArray(e&&e.targets)?e.targets:[]}function Ok(e){return Array.isArray(e)?e.map(e=>({...e,source:Ek(e),targets:Dk(e)})):[]}function kk(e){let t=Dk(e);return t.length===0?`-`:t.join(`, `)}function Ak(e){return e&&e.enabled===!1?`Off`:e&&e.managed?`Config`:`On`}function jk(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>Ek(e)===n)||null}function Mk(e,t){if(!t||t.is_alias)return!1;let n=jk(e,tO(t));return!!(n&&n.enabled!==!1&&Dk(n).length>0)}function Nk(e,t){return Mk(e,t)?`table-action-btn-failover-active`:``}function Pk(e,t){let n=`Edit failover for `+(t&&t.display_name?t.display_name:`model`);return Mk(e,t)?n+` (active)`:n}function Fk(e){let t=[e&&e.target_model];return(Array.isArray(e&&e.targets)?e.targets:[]).forEach(e=>t.push(e&&e.model)),t.map(e=>String(e||``).trim()).filter(Boolean)}function Ik(e){let t=Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(Boolean):[];return{target_model:t[0]||``,targets:t.slice(1).map(e=>({model:e}))}}function Lk(e){return{primary_model:String(e&&e.source||``).trim(),fallback_models:Fk(e),enabled:!(e&&e.enabled===!1)}}function Rk(e){return Ek(e)}function zk(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=Rk(e);n&&(t[n]=!0)}),t}function Bk(e,t){let n=Rk(t);return!!(n&&e&&e[n])}function Vk(e,t){return(Array.isArray(e)?e:[]).filter(e=>Bk(t,e))}function Hk(e,t){let n=Array.isArray(e)?e:[];return n.length>0&&Vk(n,t).length===n.length}function Uk(e){return[Ek(e),Dk(e).join(` `)].join(` `).toLowerCase()}function Wk(e,t){let n=Array.isArray(e)?e:[],r=String(t||``).trim().toLowerCase();return r?n.filter(e=>Uk(e).includes(r)):n}function Gk(e){return{primary_model:Ek(e),fallback_models:Dk(e).map(e=>String(e||``).trim()).filter(Boolean),enabled:!!(e&&e.enabled!==!1)}}function Kk(){return{source:``,target_model:``,targets:[],enabled:!0}}var Z=new class{#e=k(!0);get failoverAvailable(){return I(this.#e)}set failoverAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get failoverRules(){return I(this.#t)}set failoverRules(e){A(this.#t,e,!0)}#n=k(!1);get failoverLoading(){return I(this.#n)}set failoverLoading(e){A(this.#n,e,!0)}#r=k(!1);get failoverSaving(){return I(this.#r)}set failoverSaving(e){A(this.#r,e,!0)}#i=k(!1);get failoverGenerating(){return I(this.#i)}set failoverGenerating(e){A(this.#i,e,!0)}#a=k(``);get failoverError(){return I(this.#a)}set failoverError(e){A(this.#a,e,!0)}#o=k(j([]));get failoverGeneratedRules(){return I(this.#o)}set failoverGeneratedRules(e){A(this.#o,e,!0)}#s=k(!1);get failoverDraftsOpen(){return I(this.#s)}set failoverDraftsOpen(e){A(this.#s,e,!0)}#c=k(j({}));get failoverDraftSelections(){return I(this.#c)}set failoverDraftSelections(e){A(this.#c,e,!0)}#l=k(``);get failoverDraftFilter(){return I(this.#l)}set failoverDraftFilter(e){A(this.#l,e,!0)}#u=k(!1);get failoverDraftSaving(){return I(this.#u)}set failoverDraftSaving(e){A(this.#u,e,!0)}#d=k(!1);get failoverFormOpen(){return I(this.#d)}set failoverFormOpen(e){A(this.#d,e,!0)}#f=k(`create`);get failoverFormMode(){return I(this.#f)}set failoverFormMode(e){A(this.#f,e,!0)}#p=k(!1);get failoverFormManaged(){return I(this.#p)}set failoverFormManaged(e){A(this.#p,e,!0)}#m=k(j(Kk()));get failoverForm(){return I(this.#m)}set failoverForm(e){A(this.#m,e,!0)}failoverEnabled(){return xs.booleanFlag(`FAILOVER_ENABLED`,!0)}async fetchFailoverRules(){if(!this.failoverEnabled()){this.failoverAvailable=!1,this.failoverRules=[],this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,this.failoverError=``,this.failoverLoading=!1;return}this.failoverLoading=!0,this.failoverError=``;try{let e=await gs(`/admin/failover`,{label:`failover mappings`});if(e.status===503){this.failoverAvailable=!1,this.failoverRules=[];return}if(e.stale)return;if(this.failoverAvailable=!0,!e.ok){this.failoverRules=[];return}this.failoverRules=Ok(e.data)}catch(e){console.error(`Failed to fetch failover mappings:`,e),this.failoverRules=[],this.failoverError=`Unable to load failover mappings.`}finally{this.failoverLoading=!1}}resetFailoverForm(){this.failoverFormMode=`create`,this.failoverFormManaged=!1,this.failoverForm=Kk()}openFailoverCreate(){this.resetFailoverForm(),this.failoverFormOpen=!0,this.focusFailoverEditor()}openFailoverEdit(e){if(!e)return;this.resetFailoverForm(),this.failoverFormMode=`edit`,this.failoverFormOpen=!0,this.failoverFormManaged=!!e.managed;let t=this.failoverPrimaryModel(e),n=this.failoverTargets(e);this.failoverForm={source:t,target_model:n[0]||``,targets:n.slice(1).map(e=>({model:e})),enabled:e.enabled!==!1},this.focusFailoverEditor()}openFailoverForModel(e){if(!e||e.is_alias)return;let t=this.qualifiedModelName(e),n=this.failoverRules.find(e=>this.failoverPrimaryModel(e)===t);if(n){this.openFailoverEdit(n);return}this.resetFailoverForm(),this.failoverFormMode=`create`,this.failoverFormOpen=!0,this.failoverForm.source=t,this.focusFailoverEditor()}closeFailoverForm(){this.failoverFormOpen=!1}closeFailoverDraftsModal(){this.failoverDraftSaving||(this.failoverDraftsOpen=!1)}failoverFormTargets(){return Fk(this.failoverForm)}setFailoverFormTargets(e){let t=Ik(e);this.failoverForm.target_model=t.target_model,this.failoverForm.targets=t.targets}addFailoverTarget(){Array.isArray(this.failoverForm.targets)||(this.failoverForm.targets=[]),this.failoverForm.targets.push({model:``}),this.focusFailoverEditor()}removeFailoverTarget(e){if(!Array.isArray(this.failoverForm.targets)){this.failoverForm.targets=[];return}this.failoverForm.targets.splice(e,1)}removePrimaryFailoverTarget(){let e=Array.isArray(this.failoverForm.targets)?this.failoverForm.targets:[];if(e.length>0){let t=e.shift();this.failoverForm.target_model=t&&t.model?t.model:``,this.failoverForm.targets=e;return}this.failoverForm.target_model=``}failoverRulePayload(){return Lk(this.failoverForm)}async submitFailoverForm(){if(this.failoverSaving||this.failoverGenerating||this.failoverFormManaged)return;let e=this.failoverRulePayload();if(!e.primary_model){this.failoverError=`Primary model is required.`;return}if(e.enabled&&e.fallback_models.length===0){this.failoverError=`Add at least one failover target.`;return}this.failoverSaving=!0,this.failoverError=``;try{let t=await _s(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to save failover mapping.`;return}J.success(`Failover mapping saved.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to save failover mapping:`,e),this.failoverError=`Failed to save failover mapping.`}finally{this.failoverSaving=!1}}async deleteFailoverRule(e){let t=String(e&&this.failoverPrimaryModel(e)||this.failoverForm.source||``).trim();if(!(!t||this.failoverSaving||this.failoverGenerating)&&confirm(`Remove failover mapping for "`+t+`"?`)){this.failoverSaving=!0,this.failoverError=``;try{let e=await _s(`/admin/failover`,`DELETE`,{primary_model:t},{label:`failover mapping`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mapping.`;return}J.success(`Failover mapping removed.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to remove failover mapping:`,e),this.failoverError=`Failed to remove failover mapping.`}finally{this.failoverSaving=!1}}}async generateFailoverForForm(){if(this.failoverGenerating||this.failoverSaving||this.failoverFormManaged)return;let e=String(this.failoverForm.source||``).trim();if(!e){this.failoverError=`Primary model is required.`;return}this.failoverGenerating=!0,this.failoverError=``;try{let t=await _s(`/admin/failover/generate`,`POST`,{primary_model:e},{label:`failover generation`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to generate failover mapping.`;return}let n=Ok(t.data),r=n.find(t=>this.failoverPrimaryModel(t)===e)||n[0]||null,i=this.failoverTargets(r);if(i.length===0){this.failoverError=`No failover suggestions were generated for this model.`;return}this.setFailoverFormTargets(i),J.success(`Generated `+i.length+` fallback model`+(i.length===1?`.`:`s.`)),this.focusFailoverEditor()}catch(e){console.error(`Failed to generate failover mapping:`,e),this.failoverError=`Failed to generate failover mapping.`}finally{this.failoverGenerating=!1}}openFailoverResetDialog(){Ls.open({title:`Remove failover models`,titleId:`failoverResetDialogTitle`,inputId:`failover-reset-confirmation`,message:`Remove every dashboard-managed failover mapping. Configuration-managed mappings remain active.`,requiredText:`remove`,confirmLabel:`Remove Failover`,icon:ko,dialogClass:`budget-reset-dialog`,onConfirm:async()=>{await this.resetFailoverRules(),this.failoverError&&(Ls.error=this.failoverError)}})}async resetFailoverRules(){if(!this.failoverSaving){this.failoverSaving=!0,this.failoverError=``;try{let e=await _s(`/admin/failover/reset`,`POST`,void 0,{label:`failover removal`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mappings.`;return}this.failoverRules=Ok(e.data),this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,J.success(`Dashboard-managed failover mappings removed.`),Ls.close()}catch(e){console.error(`Failed to remove failover mappings:`,e),this.failoverError=`Failed to remove failover mappings.`}finally{this.failoverSaving=!1}}}async generateFailoverRules(){if(!(this.failoverGenerating||this.failoverDraftSaving)){this.failoverGenerating=!0,this.failoverError=``,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!0;try{let e=await _s(`/admin/failover/generate`,`POST`,void 0,{label:`failover generation`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to generate failover mappings.`;return}this.failoverGeneratedRules=Ok(e.data),this.selectAllFailoverDrafts(this.failoverGeneratedRules)}catch(e){console.error(`Failed to generate failover mappings:`,e),this.failoverError=`Failed to generate failover mappings.`}finally{this.failoverGenerating=!1}}}failoverDraftKey(e){return Rk(e)}selectAllFailoverDrafts(e){this.failoverDraftSelections=zk(e)}failoverDraftSelected(e){return Bk(this.failoverDraftSelections,e)}setFailoverDraftSelected(e,t){let n=this.failoverDraftKey(e);n&&(this.failoverDraftSelections={...this.failoverDraftSelections,[n]:!!t})}selectedFailoverDrafts(){return Vk(this.failoverGeneratedRules,this.failoverDraftSelections)}selectedFailoverDraftCount(){return this.selectedFailoverDrafts().length}failoverDraftCountLabel(){return this.selectedFailoverDraftCount()+` / `+this.failoverGeneratedRules.length+` selected`}allFailoverDraftsSelected(){return Hk(this.failoverGeneratedRules,this.failoverDraftSelections)}toggleAllFailoverDrafts(){if(!(this.failoverDraftSaving||this.failoverGenerating||this.failoverGeneratedRules.length===0)){if(this.allFailoverDraftsSelected()){this.failoverDraftSelections={};return}this.selectAllFailoverDrafts(this.failoverGeneratedRules)}}failoverDraftSearchText(e){return Uk(e)}filteredFailoverDrafts(){return Wk(this.failoverGeneratedRules,this.failoverDraftFilter)}failoverDraftPayload(e){return Gk(e)}async saveSelectedFailoverDrafts(){if(this.failoverDraftSaving||this.failoverGenerating)return;let e=this.selectedFailoverDrafts();if(e.length===0){this.failoverError=`Select at least one failover draft.`;return}this.failoverDraftSaving=!0,this.failoverError=``;try{for(let t of e){let e=this.failoverDraftPayload(t);if(!e.primary_model||e.fallback_models.length===0){this.failoverError=`Generated failover draft is missing model data.`;return}let n=await _s(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(n.stale)return;if(!n.ok){this.failoverError=`Failed to save failover mapping.`;return}}J.success(`Saved `+e.length+` failover mapping`+(e.length===1?`.`:`s.`)),this.failoverDraftsOpen=!1,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.fetchFailoverRules()}catch(e){console.error(`Failed to save generated failover mappings:`,e),this.failoverError=`Failed to save failover mappings.`}finally{this.failoverDraftSaving=!1}}focusFailoverEditor(){setTimeout(()=>{let e=document.querySelector(`[data-failover-editor]`),t=e&&e.querySelector?e.querySelector(`[data-modal-autofocus], input:not([disabled]), textarea:not([disabled]), button:not([disabled])`):null;t&&typeof t.focus==`function`&&t.focus({preventScroll:!0})},0)}failoverTargetLabel(e){return kk(e)}failoverPrimaryModel(e){return Ek(e)}failoverTargets(e){return Dk(e)}findFailoverMapping(e){return jk(this.failoverRules,e)}hasActiveFailoverMapping(e){return Mk(this.failoverRules,e)}failoverButtonClass(e){return Nk(this.failoverRules,e)}failoverButtonLabel(e){return Pk(this.failoverRules,e)}normalizeFailoverRules(e){return Ok(e)}failoverRuleStatus(e){return Ak(e)}qualifiedModelName(e){return tO(e)}},qk=R(``),Jk=R(``),Yk=R(`Config`),Xk=R(`
        Targets
        `),Zk=R(``),Qk=R(`
        Redirects to
        `),$k=R(` `),eA=R(`
        `),tA=R(`
        `),nA=R(`
        `);function rA(e,t){E(t,!0);let n=O(()=>xk.modelRowPricing(t.row));var r=nA(),i=M(r),a=M(i),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{z(e,qk())};V(l,e=>{t.row.is_alias&&e(u)});var d=P(l,2),f=e=>{z(e,Jk())};V(d,e=>{!t.row.is_alias&&t.row.masking_alias&&e(f)});var p=P(d,2),m=e=>{z(e,Yk())},h=O(()=>LO(t.row));V(p,e=>{I(h)&&e(m)}),T(o);var g=P(o,2),_=e=>{var n=Xk(),r=P(M(n)),i=M(r,!0);T(r),T(n),F(()=>B(i,t.row.secondary_name)),z(e,n)};V(g,e=>{t.row.is_alias&&e(_)});var v=P(g,2),y=e=>{var n=Qk(),r=P(M(n)),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=Zk();F(e=>{W(n,`aria-label`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),W(n,`title`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),n.disabled=e},[()=>!!ek.rowDeletingKey]),L(`click`,n,()=>ek.removeRedirectRow(t.row)),z(e,n)},s=O(()=>ek.virtualModelsAvailable&&FO(t.row));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>mO(t.row.masking_alias)]),z(e,n)};V(v,e=>{!t.row.is_alias&&t.row.masking_alias&&e(y)}),T(a),T(i);var b=P(i);H(b,17,()=>t.columns,oi,(e,r)=>{var i=$k(),a=M(i,!0);T(i),F(e=>{U(i,1,Fi(I(r).class),`svelte-1iynym`),B(a,e)},[()=>I(r).value(t.row,I(n))]),z(e,i)});var x=P(b),S=M(x),C=e=>{var n=eA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>ek.rowDeletingKey===t.row.key?`Removing alias `+t.row.alias.name:`Remove alias `+t.row.alias.name),r=O(()=>!!ek.rowDeletingKey);gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>ek.removeAliasRow(t.row),get disabled(){return I(r)},children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}})}},o=O(()=>ek.virtualModelsAvailable&&PO(t.row));V(i,e=>{I(o)&&e(a)});var s=P(i,2),c=e=>{{let n=O(()=>`Edit alias `+t.row.alias.name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.alias),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n)},w=e=>{var n=tA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`model pricing for `+t.row.display_name,xk.hasModelPricingOverride(t.row))),r=O(()=>xk.modelPricingButtonClass(xk.hasModelPricingOverride(t.row)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openModelPricingOverrideEdit(t.row),children:(e,t)=>{K(e,{get icon(){return Ka},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(i,e=>{xk.modelPricingOverridesAvailable&&e(a)});var o=P(i,2),s=e=>{{let n=O(()=>Z.failoverButtonLabel(t.row)),r=O(()=>Z.failoverButtonClass(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>Z.openFailoverForModel(t.row),children:(e,t)=>{K(e,{get icon(){return To},class:`table-icon-svg`})},$$slots:{default:!0}})}},c=O(()=>Z.failoverAvailable&&Z.failoverEnabled());V(o,e=>{I(c)&&e(s)});var l=P(o,2),u=e=>{{let n=O(()=>X.rateLimitGaugeTitle(t.row.display_name,X.rateLimitGaugeClassForModel(t.row))),r=O(()=>X.rateLimitGaugeClassForModel(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForModel(t.row),children:(e,t)=>{K(e,{get icon(){return Qa},class:`table-icon-svg`})},$$slots:{default:!0}})}},d=O(()=>X.rateLimitsEnabled()&&X.rateLimitInspectorModelID(t.row));V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{{let n=O(()=>`Edit redirect for `+t.row.display_name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.masking_alias),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(f,e=>{ek.virtualModelsAvailable&&t.row.masking_alias&&t.row.masking_alias.name&&e(p)});var m=P(f,2),h=e=>{{let n=O(()=>BO(`model access for `+t.row.display_name,RO(t.row.access))),r=O(()=>zO(RO(t.row.access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openVirtualModelEditModel(t.row),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(m,e=>{ek.virtualModelsAvailable&&!t.row.masking_alias&&e(h)}),T(n),z(e,n)};V(S,e=>{t.row.is_alias?e(C):e(w,-1)}),T(x),T(r),F((e,n)=>{W(r,`id`,e),U(r,1,n,`svelte-1iynym`),B(c,t.row.display_name)},[()=>IO(t.row)||void 0,()=>Fi(NO(t.row))]),z(e,r),D()}Hr([`click`]);var iA={headerLines:[`Modes`],value:e=>(e.model?.metadata?.modes??[]).join(`, `)||`-`};function aA(e,t){return{headerLines:e,class:`col-price`,value:t}}var oA=aA([`Input / Output ($/MTok)`],(e,t)=>sc(t?.input_per_mtok)+` / `+sc(t?.output_per_mtok)),sA={all:[oA],text_generation:[iA,oA,aA([`Cached $/MTok`],(e,t)=>sc(t?.cached_input_per_mtok))],embedding:[aA([`Input`,`$/MTok`],(e,t)=>sc(t?.input_per_mtok))],image:[aA([`$/Image`],(e,t)=>cc(t?.per_image))],audio:[aA([`$/Second`],(e,t)=>cc(t?.per_second_input)),aA([`$/Character`],(e,t)=>cc(t?.per_character_input))],video:[aA([`$/Second (In)`],(e,t)=>cc(t?.per_second_input)),aA([`$/Second (Out)`],(e,t)=>cc(t?.per_second_output))],utility:[aA([`$/Page`],(e,t)=>cc(t?.per_page)),aA([`$/Request`],(e,t)=>cc(t?.per_request))]};function cA(e){return sA[e]||sA.all}function lA(e){return cA(e).length+2}var uA=R(`
        `),dA=R(` `,1),fA=R(``),pA=R(` `),mA=R(` `),hA=R(`
        `),gA=R(`
        `),_A=R(`
        Model
        `);function vA(e,t){E(t,!0);let n=O(()=>Mc.activeCategory||`all`),r=O(()=>cA(I(n))),i=O(()=>lA(I(n)));var a=_A(),o=M(a),s=M(o),c=M(s),l=P(M(c));H(l,17,()=>I(r),oi,(e,t)=>{var n=fA();H(n,21,()=>I(t).headerLines,oi,(e,t,n)=>{var r=dA(),i=N(r),a=e=>{z(e,uA())};V(i,e=>{n>0&&e(a)});var o=P(i,1,!0);F(()=>B(o,I(t))),z(e,r)}),T(n),F(()=>U(n,1,Fi(I(t).class),`svelte-1911hy6`)),z(e,n)});var u=P(l);Tk(M(u),{}),T(u),T(c),T(s),H(P(s),17,()=>ek.filteredDisplayModelGroups,e=>e.key,(e,t)=>{var n=gA(),a=M(n),o=M(a),s=M(o),c=M(s),l=M(c),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=e=>{var n=pA(),r=M(n,!0);T(n),F(()=>B(r,`(`+I(t).type_label+`)`)),z(e,n)};V(f,e=>{I(t).type_label&&e(p)});var m=P(f,2),h=e=>{var n=mA(),r=M(n,!0);T(n),F(()=>B(r,I(t).item_count_label)),z(e,n)};V(m,e=>{I(t).item_count_label&&e(h)}),T(l);var g=P(l,2),_=e=>{var n=hA(),r=M(n,!0);T(n),F(()=>B(r,I(t).access_summary)),z(e,n)};V(g,e=>{I(t).access_summary&&e(_)}),T(c);var v=P(c,2),y=M(v),b=e=>{Ck(e,{get row(){return I(t)}})};V(y,e=>{I(t).access.selector&&e(b)});var x=P(y,2),S=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`provider pricing for `+I(t).display_name,xk.hasProviderPricingOverride(I(t)))),r=O(()=>xk.modelPricingButtonClass(xk.hasProviderPricingOverride(I(t))));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openProviderPricingOverrideEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return Ka},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(x,e=>{xk.modelPricingOverridesAvailable&&I(t).provider_name&&e(S)});var C=P(x,2),w=e=>{{let n=O(()=>X.rateLimitGaugeTitle(`provider `+I(t).display_name,X.rateLimitGaugeClassForProvider(I(t)))),r=O(()=>X.rateLimitGaugeClassForProvider(I(t)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForProvider(I(t)),children:(e,t)=>{K(e,{get icon(){return Qa},class:`table-icon-svg`})},$$slots:{default:!0}})}},ee=O(()=>X.rateLimitsEnabled()&&I(t).provider_name);V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{{let n=O(()=>BO(`provider access for `+I(t).display_name,RO(I(t).access))),r=O(()=>zO(RO(I(t).access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openProviderOverrideEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(te,e=>{ek.virtualModelsAvailable&&I(t).access.selector&&e(ne)}),T(v),T(s),T(o),T(a),H(P(a),17,()=>I(t).rows,e=>e.key,(e,t)=>{rA(e,{get row(){return I(t)},get columns(){return I(r)}})}),T(n),F(()=>{W(o,`colspan`,I(i)),B(d,I(t).display_name)}),z(e,n)}),T(o),T(a),z(e,a),D()}var yA=R(``);function bA(e,t){let n=G(t,`enabled`,3,!1),r=G(t,`label`,3,``),i=G(t,`disabled`,3,!1),a=G(t,`restricted`,3,!1);var o=yA();let s;var c=P(M(o),2),l=M(c,!0);T(c),T(o),F(()=>{s=U(o,1,`alias-toggle`,null,s,{enabled:n(),restricted:a()}),o.disabled=i(),W(o,`aria-label`,(n()?`Disable `:`Enable `)+r()),B(l,t.text??(n()?`Enabled`:`Disabled`))}),L(`click`,o,function(...e){t.onclick?.apply(this,e)}),z(e,o)}Hr([`click`]);var xA=R(``),SA=R(`
        `);function CA(e,t){E(t,!0);let n=G(t,`model`,15,``),r=G(t,`weight`,15),i=G(t,`id`,3,void 0),a=G(t,`placeholder`,3,`openai/gpt-4o`),o=G(t,`showRemove`,3,!0);var s=SA(),c=M(s);na(c);var l=P(c,2),u=e=>{var t=xA();na(t),F(()=>t.disabled=ek.vmFormManaged),da(t,r),z(e,t)},d=O(()=>ek.vmFormShowWeights());V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{gT(e,{label:`Remove target`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,get onclick(){return t.onremove},get disabled(){return ek.vmFormManaged},children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}})};V(f,e=>{o()&&e(p)}),T(s),F(()=>{W(c,`id`,i()),W(c,`placeholder`,a()),c.disabled=ek.vmFormManaged}),da(c,n),z(e,s),D()}var wA=R(`

        `),TA=R(`adaptive lets the registered routing extension pick the target per + request.`,1),EA=R(`Add one target to make this a redirect/alias, or two or more to load + balance across them, then pick a strategy: round_robin rotates across targets + (weight biases the share) and cost always routes to the cheapest available + target. Leave Targets empty to make it only an access policy on the Source selector. The selector uses / for all providers and + models, for one provider, or for one model. user_paths is + matched against the effective request user_path: the managed API key user_path when present, otherwise the configured user path request header.`,1),DA=R(``),OA=R(`

        This virtual model is defined in configuration (config.yaml / VIRTUAL_MODELS) and is read-only here. Edit your configuration to change it.

        `),kA=R(``),AA=R(``),jA=R(``),MA=R(`
        `,1),NA=R(``),PA=R(`Use / to allow every user path. Use a team path to restrict to that + subtree, or an unused path to make the selector unavailable.`,1),FA=R(``),IA=R(` `),LA=R(`
        Targets
        `,1);function RA(e,t){E(t,!0);let n=ek;An(()=>{n.vmFormOpen&&xs.ensureLoaded()});{let t=e=>{KS(e,{copyId:`virtual-model-help-copy`,label:`virtual model help`,get open(){return n.vmFormHelpOpen},set open(e){n.vmFormHelpOpen=e},title:e=>{var t=wA(),r=M(t,!0);T(t),F(()=>B(r,n.vmFormDisplayName||n.vmForm.source||`Virtual model`)),z(e,t)},help:e=>{Ue();var t=EA(),n=P(N(t),7),r=e=>{var t=TA();Ue(),z(e,t)},i=O(()=>xs.virtualModelStrategies().includes(`adaptive`));V(n,e=>{I(i)&&e(r)});var a=P(n,8);a.textContent=`{provider_name}/`;var o=P(a,2);o.textContent=`{provider_name}/{model}`,Ue(7),z(e,t)},$$slots:{title:!0,help:!0}})},r=e=>{var t=Qr(),r=N(t),i=e=>{var t=DA();F(()=>t.disabled=n.vmDeleting||n.vmSubmitting),L(`click`,t,()=>n.deleteVirtualModel()),z(e,t)};V(r,e=>{n.vmFormHasExisting&&!n.vmFormManaged&&e(i)}),z(e,t)},i=O(()=>n.vmDeleting||n.vmFormManaged),a=O(()=>n.vmFormMode===`edit`?`Save`:`Create`),o=O(()=>n.vmFormMode===`edit`?go:fo);bE(e,{get open(){return n.vmFormOpen},ariaLabel:`Virtual model editor`,get error(){return n.vmFormError},get submitting(){return n.vmSubmitting},get submitDisabled(){return I(i)},get submitLabel(){return I(a)},get submitIcon(){return I(o)},onclose:()=>n.closeVirtualModelForm(),onsubmit:()=>n.submitVirtualModelForm(),header:t,extraActions:r,children:(e,t)=>{var r=LA(),i=N(r),a=e=>{z(e,OA())};V(i,e=>{n.vmFormManaged&&e(a)});var o=P(i,2);SE(o,{id:`virtual-model-source`,label:`Source`,children:(e,t)=>{var r=kA();na(r),F(()=>r.disabled=n.vmFormSourceLocked||n.vmFormManaged),da(r,()=>n.vmForm.source,e=>n.vmForm.source=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2);H(s,21,()=>Mc.models,e=>tO(e),(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(s);var c=P(s,2),l=P(M(c),2);{let e=O(()=>n.vmFormHasPrimaryTarget());CA(l,{id:`virtual-model-target`,get showRemove(){return I(e)},onremove:()=>n.removePrimaryTarget(),get model(){return n.vmForm.target_model},set model(e){n.vmForm.target_model=e},get weight(){return n.vmForm.target_weight},set weight(e){n.vmForm.target_weight=e}})}var u=P(l,2);H(u,17,()=>n.vmForm.targets,oi,(e,t,r)=>{CA(e,{placeholder:`groq/llama`,onremove:()=>n.removeVmTarget(r),get model(){return I(t).model},set model(e){I(t).model=e},get weight(){return I(t).weight},set weight(e){I(t).weight=e}})});var d=P(u,2),f=M(d);K(M(f),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(f),T(d),T(c);var p=P(c,2),m=e=>{var t=MA(),r=N(t);SE(r,{id:`virtual-model-strategy`,label:`Load-balancing strategy`,children:(e,t)=>{var r=jA();H(r,21,()=>n.vmStrategyOptions(),e=>e.value,(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),F(()=>r.disabled=n.vmFormManaged),Gi(r,()=>n.vmForm.strategy,e=>n.vmForm.strategy=e),z(e,r)},$$slots:{default:!0}});var i=P(r,2),a=M(i),o=M(a);na(o),Ue(2),T(a),T(i),F(()=>o.disabled=n.vmFormManaged),fa(o,()=>n.vmForm.session_affinity,e=>n.vmForm.session_affinity=e),z(e,t)},h=O(()=>n.vmFormShowStrategy());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=M(g);KS(_,{copyId:`virtual-model-user-paths-help`,label:`user paths help`,get open(){return n.vmFormUserPathsHelpOpen},set open(e){n.vmFormUserPathsHelpOpen=e},title:e=>{z(e,NA())},help:e=>{Ue();var t=PA();Ue(2),z(e,t)},$$slots:{title:!0,help:!0}});var v=P(_,2);ft(v),W(v,`placeholder`,`/ +/team/alpha +/non-existing`),T(g);var y=P(g,2);SE(y,{id:`virtual-model-description`,label:`Description`,children:(e,t)=>{var r=FA();ft(r),F(()=>r.disabled=n.vmFormManaged),da(r,()=>n.vmForm.description,e=>n.vmForm.description=e),z(e,r)},$$slots:{default:!0}});var b=P(y,2),x=M(b),S=e=>{var t=IA(),r=M(t,!0);T(t),F(()=>B(r,`Default enabled: `+(n.vmFormDefaultEnabled?`yes`:`no`)+` · Effective now: `+(n.vmFormEffectiveEnabled?`yes`:`no`))),z(e,t)};V(x,e=>{n.vmFormMode===`edit`&&e(S)});var C=P(x,2),w=M(C);{let e=O(()=>n.vmFormToggleRestricted()),t=O(()=>n.vmFormToggleLabel());bA(w,{get enabled(){return n.vmForm.enabled},get restricted(){return I(e)},label:`virtual model`,get disabled(){return n.vmFormManaged},get text(){return I(t)},onclick:()=>{n.vmFormManaged||(n.vmForm.enabled=!n.vmForm.enabled)}})}T(C),T(b),F(()=>{f.disabled=n.vmFormManaged,v.disabled=n.vmFormManaged}),L(`click`,f,()=>n.addVmTarget()),da(v,()=>n.vmForm.user_paths,e=>n.vmForm.user_paths=e),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var zA=R(`

        Pricing override

        `,1),BA=R(``),VA=R(``),HA=R(``),UA=R(``),WA=R(`
        `),GA=R(`
        Tiered pricing exists for this override and will be preserved. Tier editing can be added + without a database migration.
        `),KA=R(`
        No pricing fields set.
        `),qA=R(`
        `),JA=R(`

        Currency is USD. Saved fields override model registry and config.yaml pricing for this + selector; unset fields continue to inherit.

        Price Type USD Source
        `,1);function YA(e,t){E(t,!0);let n=xk;bE(e,{get open(){return n.modelPricingOverrideFormOpen},ariaLabel:`Model pricing editor`,dialogClass:`model-pricing-editor`,get error(){return n.modelPricingOverrideError},get submitting(){return n.modelPricingOverrideSubmitting},submitLabel:`Save Pricing`,onclose:()=>n.closeModelPricingOverrideForm(),onsubmit:()=>n.submitModelPricingOverrideForm(),header:e=>{var t=zA(),r=P(N(t),2),i=M(r,!0);T(r),F(()=>B(i,n.modelPricingOverrideFormDisplayName||n.modelPricingOverrideForm.selector||`Pricing`)),z(e,t)},extraActions:e=>{var t=Qr(),r=N(t),i=e=>{var t=BA();F(()=>t.disabled=n.modelPricingOverrideSubmitting),L(`click`,t,()=>n.deleteModelPricingOverride()),z(e,t)};V(r,e=>{n.modelPricingOverrideFormHasExistingOverride&&e(i)}),z(e,t)},children:(e,t)=>{var r=JA(),i=N(r),a=M(i);SE(a,{id:`model-pricing-override-selector`,label:`Selector`,children:(e,t)=>{var r=VA();na(r),da(r,()=>n.modelPricingOverrideForm.selector,e=>n.modelPricingOverrideForm.selector=e),z(e,r)},$$slots:{default:!0}});var o=P(a,2),s=e=>{SE(e,{id:`model-pricing-override-scope`,label:`Scope`,children:(e,t)=>{var r=UA();H(r,21,()=>n.modelPricingOverrideFormScopeOptions,e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),L(`change`,r,()=>n.setModelPricingOverrideScope(n.modelPricingOverrideFormScope)),Gi(r,()=>n.modelPricingOverrideFormScope,e=>n.modelPricingOverrideFormScope=e),z(e,r)},$$slots:{default:!0}})};V(o,e=>{n.modelPricingOverrideFormScopeOptions.length>1&&e(s)}),T(i);var c=P(i,4);H(c,21,()=>n.modelPricingOverrideRows,e=>e.id,(e,t,r)=>{var i=WA(),a=M(i),o=M(a),s=P(o,2);H(s,21,()=>n.availablePricingFieldOptions(I(t)),e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).group+` - `+I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(s),T(a);var c=P(a,2),l=M(c),u=P(l,2);na(u),T(c);var d=P(c,2);{let e=O(()=>`Remove `+n.pricingFieldLabel(I(t).field));gT(d,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn pricing-override-remove-row`,onclick:()=>n.removeModelPricingOverrideRow(I(t)),children:(e,t)=>{K(e,{get icon(){return Fo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(i),F(()=>{W(o,`for`,`pricing-type-`+I(t).id),W(s,`id`,`pricing-type-`+I(t).id),W(l,`for`,`pricing-value-`+I(t).id),W(u,`id`,`pricing-value-`+I(t).id)}),Gi(s,()=>I(t).field,e=>I(t).field=e),da(u,()=>I(t).value,e=>I(t).value=e),z(e,i)}),T(c);var l=P(c,2),u=M(l);K(M(u),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(u),T(l);var d=P(l,2),f=e=>{z(e,GA())};V(d,e=>{n.modelPricingOverrideFormPreservedTiers.length>0&&e(f)});var p=P(d,2),m=P(M(p),2),h=e=>{z(e,KA())},g=O(()=>n.modelPricingEffectivePreviewRows().length===0);V(m,e=>{I(g)&&e(h)}),H(P(m,2),17,()=>n.modelPricingEffectivePreviewRows(),e=>e.field,(e,t)=>{var n=qA(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{B(i,I(t).label),B(o,e),B(c,I(t).source)},[()=>I(t).value===null||I(t).value===void 0?`-`:cc(Number(I(t).value))]),z(e,n)}),T(p),L(`click`,u,()=>n.addModelPricingOverrideRow()),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}}),D()}Hr([`click`,`change`]);var XA=R(`

        Failover mapping

        `,1),ZA=R(``),QA=R(`

        This failover mapping is defined in configuration and is read-only here.

        `),$A=R(``),ej=R(`
        `),tj=R(`
        `,1),nj=R(`
        `);function rj(e,t){E(t,!0);{let t=e=>{var t=XA(),n=P(N(t),2),r=M(n,!0);T(n),F(()=>B(r,Z.failoverForm.source||`Failover`)),z(e,t)},n=e=>{var t=Qr(),n=N(t),r=e=>{var t=ZA();F(()=>t.disabled=Z.failoverSaving||Z.failoverGenerating),L(`click`,t,()=>Z.deleteFailoverRule()),z(e,t)};V(n,e=>{Z.failoverFormMode===`edit`&&!Z.failoverFormManaged&&e(r)}),z(e,t)},r=O(()=>Z.failoverGenerating||Z.failoverFormManaged);bE(e,{get open(){return Z.failoverFormOpen},ariaLabel:`Failover editor`,get error(){return Z.failoverError},get submitting(){return Z.failoverSaving},get submitDisabled(){return I(r)},submitLabel:`Save`,onclose:()=>Z.closeFailoverForm(),onsubmit:()=>Z.submitFailoverForm(),header:t,extraActions:n,children:(e,t)=>{var n=nj(),r=M(n),i=e=>{z(e,QA())};V(r,e=>{Z.failoverFormManaged&&e(i)});var a=P(r,2);H(a,21,()=>Mc.models,oi,(e,t)=>{var n=$A(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(a);var o=P(a,2);SE(o,{id:`failover-target`,label:`Fallback models`,children:(e,t)=>{var n=tj(),r=N(n),i=M(r),a=M(i);na(a);var o=P(a,2),s=e=>{gT(e,{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removePrimaryFailoverTarget(),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}})};V(o,e=>{Z.failoverForm.target_model&&e(s)}),T(i),H(P(i,2),17,()=>Z.failoverForm.targets,oi,(e,t,n)=>{var r=ej(),i=M(r);na(i),gT(P(i,2),{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removeFailoverTarget(n),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),F(()=>i.disabled=Z.failoverFormManaged),da(i,()=>I(t).model,e=>I(t).model=e),z(e,r)}),T(r);var c=P(r,2),l=M(c);K(M(l),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(l);var u=P(l,2),d=M(u);K(d,{get icon(){return No},class:`form-action-icon`});var f=P(d,2),p=M(f,!0);T(f),T(u),T(c),F(e=>{a.disabled=Z.failoverFormManaged,l.disabled=Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving,u.disabled=e,B(p,Z.failoverGenerating?`Generating...`:`Generate automatically`)},[()=>Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving||!Z.failoverEnabled()]),da(a,()=>Z.failoverForm.target_model,e=>Z.failoverForm.target_model=e),L(`click`,l,()=>Z.addFailoverTarget()),L(`click`,u,()=>Z.generateFailoverForForm()),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=M(s);bA(M(c),{get enabled(){return Z.failoverForm.enabled},label:`failover mapping`,get disabled(){return Z.failoverFormManaged},onclick:()=>{Z.failoverFormManaged||(Z.failoverForm.enabled=!Z.failoverForm.enabled)}}),T(c),T(s),T(n),z(e,n)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var ij=R(` `),aj=R(`
        `),oj=R(``),sj=R(`
        `),cj=R(`

        No failover suggestions were generated.

        `),lj=R(`

        No failover drafts match the filter.

        `),uj=R(``),dj=R(``);function fj(e,t){E(t,!0),Ms(e,{get open(){return Z.failoverDraftsOpen},variant:`editor`,onclose:()=>Z.closeFailoverDraftsModal(),children:(e,t)=>{var n=dj(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=ij(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>Z.failoverDraftCountLabel()]),z(e,t)};V(a,e=>{Z.failoverGeneratedRules.length>0&&e(o)}),Os(P(a,2),{label:`Close failover drafts`,onclick:()=>Z.closeFailoverDraftsModal(),get disabled(){return Z.failoverDraftSaving}}),T(i),T(r);var s=P(r,2),c=e=>{mT(e,{label:`Generating failover drafts...`,class:`failover-drafts-loading`})};V(s,e=>{Z.failoverGenerating&&e(c)});var l=P(s,2),u=e=>{var t=aj(),n=M(t);yw(n,{placeholder:`Filter failover drafts...`,label:`Filter failover drafts`,get value(){return Z.failoverDraftFilter},set value(e){Z.failoverDraftFilter=e}});var r=P(n,2),i=M(r);K(i,{get icon(){return Ba},class:`form-action-icon`});var a=P(i,2),o=M(a,!0);T(a),T(r),T(t),F(e=>{r.disabled=Z.failoverDraftSaving,B(o,e)},[()=>Z.allFailoverDraftsSelected()?`Deselect all`:`Select all`]),L(`click`,r,()=>Z.toggleAllFailoverDrafts()),z(e,t)};V(l,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&e(u)});var d=P(l,2),f=e=>{var t=sj();H(t,21,()=>Z.filteredFailoverDrafts(),e=>`failover-draft:`+Z.failoverPrimaryModel(e),(e,t)=>{var n=oj(),r=M(n);na(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(i),T(n),F((e,t,n,i)=>{ia(r,e),r.disabled=Z.failoverDraftSaving,W(r,`aria-label`,t),B(o,n),B(c,i)},[()=>Z.failoverDraftSelected(I(t)),()=>`Select failover draft for `+Z.failoverPrimaryModel(I(t)),()=>Z.failoverPrimaryModel(I(t)),()=>Z.failoverTargetLabel(I(t))]),L(`change`,r,e=>Z.setFailoverDraftSelected(I(t),e.currentTarget.checked)),z(e,n)}),T(t),z(e,t)},p=O(()=>!Z.failoverGenerating&&Z.filteredFailoverDrafts().length>0);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{z(e,cj())};V(m,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length===0&&!Z.failoverError&&e(h)});var g=P(m,2),_=e=>{z(e,lj())},v=O(()=>!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&Z.filteredFailoverDrafts().length===0);V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=uj(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(y,e=>{Z.failoverError&&e(b)});var x=P(y,2),S=M(x),C=P(S,2),w=M(C);K(w,{get icon(){return go},class:`form-action-icon`});var ee=P(w,2),te=M(ee,!0);T(ee),T(C),T(x),T(n),F(e=>{S.disabled=Z.failoverDraftSaving,C.disabled=e,B(te,Z.failoverDraftSaving?`Saving...`:`Save selected`)},[()=>Z.failoverGenerating||Z.failoverDraftSaving||Z.selectedFailoverDraftCount()===0]),L(`click`,S,()=>Z.closeFailoverDraftsModal()),L(`click`,C,()=>Z.saveSelectedFailoverDrafts()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`,`change`]);var pj=R(`
        Rate limit management is unavailable.
        `),mj=R(` Add`,1),hj=R(`

        `),gj=R(`

        No rules.

        `),_j=R(` Edit`,1),vj=R(`
        `),yj=R(`
        `),bj=R(`

        `),xj=R(``),Sj=R(``);function Cj(e,t){E(t,!0);function n(){q.dialogOpen||X.closeRateLimitInspector()}Ms(e,{get open(){return X.rateLimitInspectorOpen},variant:`editor`,onclose:n,children:(e,t)=>{var n=Sj(),r=M(n),i=M(r),a=P(M(i),2),o=M(a),s=M(o,!0);T(o),T(a),T(i),Os(P(i,2),{label:`Close rate limits inspector`,onclick:()=>X.closeRateLimitInspector()}),T(r);var c=P(r,2),l=e=>{mT(e,{label:`Loading rate limits...`})},u=e=>{z(e,pj())},d=e=>{var t=Qr();H(N(t),17,()=>X.rateLimitInspectorSections(),e=>e.key,(e,t)=>{var n=bj(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2);{let e=O(()=>`Add `+I(t).title.toLowerCase());gT(o,{get label(){return I(e)},class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(I(t).scope,I(t).subject),children:(e,t)=>{var n=mj();K(N(n),{get icon(){return fo},class:`table-icon-svg`}),Ue(2),z(e,n)},$$slots:{default:!0}})}T(r);var s=P(r,2),c=e=>{var n=hj(),r=M(n,!0);T(n),F(()=>B(r,I(t).hint)),z(e,n)};V(s,e=>{I(t).hint&&e(c)});var l=P(s,2),u=e=>{z(e,gj())},d=e=>{var n=yj();H(n,21,()=>I(t).items,e=>X.rateLimitKey(e),(e,t)=>{var n=vj(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=M(c);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?ja:Oo);K(l,{get icon(){return I(e)},class:`budget-period-icon`})}var u=P(l,2),d=M(u,!0);T(u),T(c),T(s);var f=P(s,2),p=M(f),m=M(p),h=M(m,!0);T(m);var g=P(m,2),_=M(g,!0);T(g),T(p);var v=P(p,2),y=M(v),b=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(null,null,I(t)),children:(e,t)=>{var n=_j();K(N(n),{get icon(){return lo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},x=O(()=>!X.rateLimitIsReadOnly(I(t)));V(y,e=>{I(x)&&e(b)}),T(v),T(f),T(i),T(r),T(n),F((e,t,r,i,a,s,c,l)=>{U(n,1,`budget-row ${e??``}`),Hi(n,t),W(n,`title`,r),B(o,i),B(d,a),B(h,s),W(g,`title`,c),B(_,l)},[()=>X.rateLimitPressureClass(I(t)),()=>X.rateLimitPressureStyle(I(t)),()=>X.rateLimitPressurePercent(I(t))+`% of the most constrained cap used`,()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitInspectorSummary(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n)};V(l,e=>{I(t).items.length===0?e(u):e(d,-1)}),T(n),F(()=>B(a,I(t).title)),z(e,n)}),z(e,t)};V(c,e=>{X.rateLimitsLoading?e(l):X.rateLimitsAvailable?e(d,-1):e(u,1)});var f=P(c,2),p=M(f),m=P(p,2),h=e=>{var t=xj();L(`click`,t,()=>{X.closeRateLimitInspector(),qo.navigate(`rate-limits`)}),z(e,t)},g=O(()=>X.rateLimitsEnabled());V(m,e=>{I(g)&&e(h)}),T(f),T(n),F(()=>B(s,X.rateLimitInspector.title)),L(`click`,p,()=>X.closeRateLimitInspector()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`]);var wj=R(`
        models
        `),Tj=R(`
        Virtual models feature is unavailable.
        `),Ej=R(`
        `),Dj=R(``),Oj=R(`
        `),kj=R(``),Aj=R(`
        `),jj=R(`

        No models registered.

        `),Mj=R(`

        No models in this category.

        `),Nj=R(`

        No models match your filter.

        `),Pj=R(`
        `);function Fj(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`models`&&(ek.fetchVirtualModels(),xk.fetchModelPricingOverrides(),Z.fetchFailoverRules(),X.fetchRateLimitsPage())}),An(()=>{let e=ek.filteredDisplayModels.length;return Er(()=>ek.restartModelRendering(e)),()=>ek.stopModelRendering()});let n=O(()=>q.needsAuth);var r=Pj(),i=M(r),a=P(M(i),2),o=e=>{var t=wj(),n=M(t),r=M(n,!0);T(n),Ue(),T(t),F(()=>B(r,Mc.filter?ek.filteredDisplayModels.length+` / `+ek.displayModels.length:ek.displayModels.length)),z(e,t)};V(a,e=>{ek.displayModels.length>0&&e(o)}),T(i);var s=P(i,2);Pc(s,{});var c=P(s,2),l=e=>{z(e,Tj())};V(c,e=>{!ek.virtualModelsAvailable&&!I(n)&&e(l)});var u=P(c,2),d=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,ek.aliasError)),z(e,t)};V(u,e=>{ek.aliasError&&!I(n)&&e(d)});var f=P(u,2),p=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,xk.modelPricingOverrideError)),z(e,t)};V(f,e=>{xk.modelPricingOverrideError&&!I(n)&&!xk.modelPricingOverrideFormOpen&&e(p)});var m=P(f,2),h=e=>{var t=Oj();H(t,21,()=>Mc.categories,e=>e.category,(e,t)=>{var n=Dj();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F(()=>{r=U(n,1,`category-tab svelte-scpjps`,null,r,{active:Mc.activeCategory===I(t).category}),B(a,I(t).display_name),B(s,I(t).count)}),L(`click`,n,()=>Mc.selectCategory(I(t).category)),z(e,n)}),T(t),z(e,t)};V(m,e=>{Mc.categories.length>0&&e(h)});var g=P(m,2),_=e=>{var t=Aj(),n=M(t);yw(M(n),{placeholder:`Filter by provider, provider/model, alias, or owner...`,label:`Filter models by provider, provider/model, alias, or owner`,get value(){return Mc.filter},set value(e){Mc.filter=e}}),T(n);var r=P(n,2),i=M(r),a=e=>{var t=kj();K(M(t),{get icon(){return fo},class:`alias-create-icon`}),Ue(2),T(t),L(`click`,t,()=>ek.openVirtualModelCreate()),z(e,t)};V(i,e=>{ek.virtualModelsAvailable&&e(a)}),T(r),T(t),z(e,t)};V(g,e=>{(ek.displayModels.length>0||Mc.filter||ek.virtualModelsAvailable)&&e(_)});var v=P(g,2),y=e=>{{let t=O(()=>ek.modelLoadingText());mT(e,{get label(){return I(t)},class:`models-loading-state`})}},b=O(()=>ek.modelsBusy()&&!I(n));V(v,e=>{I(b)&&e(y)});var x=P(v,2);RA(x,{});var S=P(x,2);YA(S,{});var C=P(S,2),w=e=>{vA(e,{})};V(C,e=>{(ek.displayModels.length>0||Mc.filter)&&e(w)});var ee=P(C,2),te=e=>{z(e,jj())};V(ee,e=>{ek.displayModels.length===0&&!Mc.loading&&!I(n)&&!Mc.filter&&(Mc.activeCategory===`all`||!Mc.activeCategory)&&e(te)});var ne=P(ee,2),re=e=>{z(e,Mj())};V(ne,e=>{ek.displayModels.length===0&&!Mc.loading&&!I(n)&&!Mc.filter&&Mc.activeCategory&&Mc.activeCategory!==`all`&&e(re)});var ie=P(ne,2),ae=e=>{z(e,Nj())};V(ie,e=>{ek.displayModels.length>0&&ek.filteredDisplayModels.length===0&&Mc.filter&&e(ae)});var oe=P(ie,2);Cj(oe,{});var se=P(oe,2);FD(se,{});var ce=P(se,2);rj(ce,{}),fj(P(ce,2),{}),T(r),z(e,r),D()}Hr([`click`]);var Ij=`draft-workflow-preview`;function Lj(){return{scope_provider:``,scope_model:``,scope_user_path:``,name:``,description:``,features:{cache:!0,audit:!0,usage:!0,budget:!0,guardrails:!1,failover:!0},guardrails:[]}}function Rj(){return{scope_provider:``,scope_model:``,scope_user_path:``}}function zj(e){return{ref:``,step:Number.isFinite(e)?e:10}}function Bj(e){let t=e==null?``:String(e).trim();if(t===``)return NaN;let n=Number(t);return Number.isFinite(n)?n:NaN}function Vj(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=t.charAt(0).toUpperCase()+t.slice(1);for(let n of[t,r])if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==null&&e[n]!==void 0)return e[n];return n}function Hj(e,t){return!e||typeof e!=`object`||Array.isArray(e)?!1:[t,t.charAt(0).toUpperCase()+t.slice(1)].some(t=>Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==null&&e[t]!==void 0)}function Uj(e){return{cache:!!Vj(e,`cache`,!1),audit:!!Vj(e,`audit`,!1),usage:!!Vj(e,`usage`,!1),budget:Vj(e,`budget`,!0)!==!1,guardrails:!!Vj(e,`guardrails`,!1),failover:Vj(e,`failover`,!0)!==!1}}function Wj(e,t){let n=Uj(e),r=t||{},i=n.usage&&!!r.usage;return{cache:n.cache&&!!r.cache,audit:n.audit&&!!r.audit,usage:i,budget:i&&n.budget&&!!r.budget,guardrails:n.guardrails&&!!r.guardrails,failover:n.failover&&!!r.failover}}function Gj(e,t){let n=e&&e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:e&&e.features?e.features:{};return{...Wj((e&&e.effective_features&&typeof e.effective_features==`object`&&!Array.isArray(e.effective_features)?e.effective_features:null)||n,t),failover:Uj(n).failover}}function Kj(e,t){return Gj(e,t).failover?`On`:`Off`}function qj(e){return(Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:Array.isArray(e&&e.guardrails)?e.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0)}function Jj(e,t){return Gj(e,t).guardrails&&Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[]}function Yj(e){return String(e&&(e.scope_provider_name||e.scope_provider)||``).trim()}function Xj(e){return String(e&&(e.provider_name||e.provider_type)||``).trim()}function Zj(e,t){let n=new Set,r=String(t&&t.scope_provider||``).trim();return r&&n.add(r),(Array.isArray(e)?e:[]).forEach(e=>{let t=Xj(e);t&&n.add(t)}),[...n].sort()}function Qj(e,t,n){let r=String(t||``).trim(),i=new Set,a=String(n&&n.scope_provider||``).trim(),o=String(n&&n.scope_model||``).trim();return r&&r===a&&o&&i.add(o),(Array.isArray(e)?e:[]).forEach(e=>{if(r&&Xj(e)!==r)return;let t=String(e&&e.model&&e.model.id||``).trim();t&&i.add(t)}),[...i].sort()}function $j(e){let t=String(e&&e.scope_type||``).trim();return t===`provider_model`?`Provider Name + Model`:t===`provider_model_path`?`Provider Name + Model + Path`:t===`provider_path`?`Provider Name + Path`:t===`path`?`Path`:t===`provider`?`Provider Name`:`Global`}function eM(e){return String(e&&e.scope_display||`global`).trim()||`global`}function tM(e){let t=String(e&&e.name||``).trim();if(t)return t;let n=eM(e);return n===`global`?`All models`:n}function nM(e){let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function rM(e){if(nM(e))return``;let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function iM(e){let t=e||Lj(),n=String(t.scope_provider||``).trim(),r=rM(t.scope_user_path);return{scope_provider:n,scope_model:n?String(t.scope_model||``).trim():``,scope_user_path:r}}function aM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path);return!t&&!r?`global`:!t&&r?`path`:!n&&!r?`provider`:!n&&r?`provider_path`:r?`provider_model_path`:`provider_model`}function oM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path),i=aM({scope_provider:t,scope_model:n,scope_user_path:r});return i===`global`?`global`:i===`path`?r:i===`provider`?t:i===`provider_path`?t+` @ `+r:i===`provider_model_path`?t+`/`+n+` @ `+r:t+`/`+n}function sM(e,t){let n=t||Rj(),r=Yj(e&&e.scope),i=r?String(e&&e.scope&&e.scope.scope_model||``).trim():``,a=rM(e&&e.scope&&e.scope.scope_user_path);return r===String(n.scope_provider||``).trim()&&i===String(n.scope_model||``).trim()&&a===rM(n.scope_user_path)}function cM(e,t,n){let r=iM(t);return!(r.scope_provider!==``||r.scope_model!==``||r.scope_user_path!==``)&&!n?null:(Array.isArray(e)?e:[]).find(e=>sM(e,r))||null}function lM(e){return String(e&&e.scope_type||``).trim()!==`global`}function uM(e){let t=String(e||``).trim();return t?t.length<=14?t:t.slice(0,12)+`…`:`—`}function dM(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.description,e.scope_display,e.scope_type,Yj(e&&e.scope),e.scope&&e.scope.scope_model,e.scope&&e.scope.scope_user_path,e.workflow_hash,...Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>e.ref):[]].some(e=>String(e||``).toLowerCase().includes(r)))}function fM(e,t){let n=e||Lj(),r=iM(n),i=Uj(n.features||{}),a=Wj(i,t);a.failover=i.failover;let o=!!a.guardrails,s=o?qj(n):[];return{id:Ij,scope_type:aM(r),scope_display:oM(r),scope:{scope_provider_name:r.scope_provider,scope_model:r.scope_model,...r.scope_user_path?{scope_user_path:r.scope_user_path}:{}},name:String(n.name||``).trim(),description:String(n.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!a.cache,audit:!!a.audit,usage:!!a.usage,budget:!!a.budget,guardrails:o,failover:!!a.failover},guardrails:s}}}function pM({form:e,caps:t,workflows:n=[],formHydrated:r=!1,hydratedScope:i=null}){let a=e||Lj(),o=String(a.scope_provider||``).trim(),s=o?String(a.scope_model||``).trim():``,c=rM(a.scope_user_path),l=Uj(a.features||{}),u=Wj(l,t),d=cM(n,a,r),f=d&&d.workflow_payload&&d.workflow_payload.features,p=Hj(f,`failover`),m=p?Vj(f,`failover`,!0)!==!1:null,h=i||Rj(),g=String(h.scope_provider||``).trim()===o&&String(h.scope_model||``).trim()===s&&rM(h.scope_user_path)===rM(c),_=!!(t&&t.failover),v=_||!!r&&g&&Object.prototype.hasOwnProperty.call(l,`failover`)||!r&&!!d&&p,y=u.guardrails?(Array.isArray(a.guardrails)?a.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})):[],b={scope_provider_name:o,scope_model:s,...c?{scope_user_path:c}:{},name:String(a.name||``).trim(),description:String(a.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!u.cache,audit:!!u.audit,usage:!!u.usage,budget:!!u.budget,guardrails:!!u.guardrails},guardrails:y}};return v&&(b.workflow_payload.features.failover=!_&&!r&&d&&p?m:!!l.failover),b}function mM(e,{models:t=[],hydratedScope:n=null}={}){let r=n||Rj(),i=String(r.scope_provider||``).trim(),a=String(r.scope_model||``).trim(),o=String(e&&(e.scope_provider_name||e.scope_provider)||``).trim(),s=String(e&&e.scope_model||``).trim();if(o&&!Zj(t,r).includes(o)&&o!==i)return`Choose a registered provider name.`;if(s&&!o)return`Model selection requires a provider name.`;if(s){let e=Qj(t,o,r),n=o===i&&s===a;if(!e.includes(s)&&!n)return`Choose a registered model for the selected provider name.`}let c=nM(e.scope_user_path);if(c)return c;let l=e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:{},u=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[];if(!l.guardrails)return``;let d=new Set;for(let e of u){if(!e.ref)return`Each guardrail step needs a guardrail ref.`;if(!Number.isInteger(e.step)||e.step<0)return`Each guardrail step must use a non-negative integer step number.`;if(d.has(e.ref))return`Each guardrail ref may appear only once in a workflow.`;d.add(e.ref)}return``}var hM=new class{#e=k(j([]));get workflows(){return I(this.#e)}set workflows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get submitting(){return I(this.#o)}set submitting(e){A(this.#o,e,!0)}#s=k(``);get deactivatingID(){return I(this.#s)}set deactivatingID(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get formHydrated(){return I(this.#l)}set formHydrated(e){A(this.#l,e,!0)}#u=k(j(Rj()));get hydratedScope(){return I(this.#u)}set hydratedScope(e){A(this.#u,e,!0)}#d=k(j([]));get guardrailRefs(){return I(this.#d)}set guardrailRefs(e){A(this.#d,e,!0)}#f=k(j(Lj()));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}#p=null;failoverVisible(){return xs.booleanFlag(`FAILOVER_ENABLED`,!0)}featureCaps(){return{cache:xs.cacheVisible(),audit:xs.auditVisible(),usage:xs.usageVisible(),budget:xs.budgetsVisible(),guardrails:xs.guardrailsVisible(),failover:this.failoverVisible()}}get filteredWorkflows(){return dM(this.workflows,this.filter)}providerOptions(){return Zj(Mc.models,this.hydratedScope)}modelOptions(e){return Qj(Mc.models,e,this.hydratedScope)}activeScopeMatch(){return cM(this.workflows,this.form,this.formHydrated)}submitMode(){return this.activeScopeMatch()?`save`:`create`}submitLabel(){return this.submitMode()===`save`?`Save`:`Create`}submittingLabel(){return this.submitMode()===`save`?`Saving...`:`Creating...`}preview(){return fM(this.form,this.featureCaps())}openCreate(e){if(this.formOpen=!0,this.submitting=!1,this.formError=``,!e){this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj();return}this.formHydrated=!0,this.hydratedScope={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``).trim(),scope_user_path:String(e.scope&&e.scope.scope_user_path||``).trim()};let t=e.workflow_payload&&e.workflow_payload.features?Uj(e.workflow_payload.features):Gj(e,this.featureCaps()),n=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0):qj(e);this.form={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``),scope_user_path:String(e.scope&&e.scope.scope_user_path||``),name:String(e.name||``),description:String(e.description||``),features:{cache:!!t.cache,audit:!!t.audit,usage:!!t.usage,budget:!!t.budget,guardrails:!!t.guardrails,failover:!!t.failover},guardrails:n.map(e=>({ref:String(e&&e.ref||``),step:Number.isFinite(e&&e.step)?e.step:10}))}}closeForm(){this.formOpen=!1,this.submitting=!1,this.formError=``,this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj()}setProvider(e){if(this.form.scope_provider=String(e||``).trim(),!this.form.scope_provider){this.form.scope_model=``;return}this.modelOptions(this.form.scope_provider).includes(String(this.form.scope_model||``).trim())||(this.form.scope_model=``)}addGuardrailStep(){let e=(Array.isArray(this.form.guardrails)?this.form.guardrails:[]).reduce((e,t)=>{let n=Number(t&&t.step);return Number.isFinite(n)?Math.max(e,n):e},0)+10;this.form.guardrails.push(zj(e))}removeGuardrailStep(e){Array.isArray(this.form.guardrails)&&this.form.guardrails.splice(e,1)}buildRequest(){return pM({form:this.form,caps:this.featureCaps(),workflows:this.workflows,formHydrated:this.formHydrated,hydratedScope:this.hydratedScope})}async fetchWorkflows(){this.#p&&this.#p.abort();let e=new AbortController;this.#p=e,this.loading=!0,this.error=``;let t=setTimeout(()=>e.abort(),1e4),n=await _T(`/admin/workflows`,{label:`workflows`,options:{signal:e.signal}});if(clearTimeout(t),this.#p===e&&(this.#p=null,this.loading=!1,n.status!==`stale`)){if(n.status===`unavailable`){this.available=!1,this.workflows=[];return}if(n.result&&(this.available=!0),n.status===`error`){this.workflows=[],this.error=e.signal.aborted?`Loading workflows timed out.`:n.error;return}this.workflows=n.items}}async fetchGuardrailRefs(){let e=await _T(`/admin/workflows/guardrails`,{label:`workflow guardrails`});e.status!==`stale`&&(this.guardrailRefs=e.items)}async fetchPage(){await Promise.all([xs.ensureLoaded(),this.fetchWorkflows(),this.fetchGuardrailRefs()])}async submitForm(){if(this.submitting)return;this.formError=``;let e=this.buildRequest(),t=mM(e,{models:Mc.models,hydratedScope:this.hydratedScope});if(t){this.formError=t;return}this.submitting=!0;try{let t=await vT(`/admin/workflows`,`POST`,e,{label:`create workflow`,unavailableStatuses:[]});if(t.status===`stale`||t.result&&t.result.status===401)return;if(t.status===`error`){this.formError=t.error;return}J.success(`Workflow created and activated.`),this.closeForm(),this.fetchPage()}finally{this.submitting=!1}}async deactivate(e){let t=String(e&&e.id||``).trim();if(!t||this.deactivatingID||!lM(e))return;let n=tM(e);if(confirm(`Deactivate workflow "`+n+`"? Requests will fall back to the next active workflow for this scope.`)){this.deactivatingID=t;try{let e=await vT(`/admin/workflows/`+encodeURIComponent(t)+`/deactivate`,`POST`,void 0,{label:`deactivate workflow`,unavailableStatuses:[]});if(e.status===`stale`||e.result&&e.result.status===401)return;if(e.status===`error`){J.error(e.error);return}J.success(`Workflow deactivated.`),this.fetchPage()}finally{this.deactivatingID=``}}}};function gM(e){let t=String(e??``),n=typeof navigator<`u`?navigator.clipboard:null;if(n&&typeof n.writeText==`function`)return n.writeText(t);let r=typeof document<`u`?document:null;if(!r||!r.body||typeof r.execCommand!=`function`)return Promise.reject(Error(`Clipboard API unavailable`));let i=r.createElement(`textarea`);i.value=t,i.setAttribute(`readonly`,``),i.style.position=`fixed`,i.style.top=`0`,i.style.left=`0`,i.style.opacity=`0`;try{if(r.body.appendChild(i),i.focus(),i.select(),i.setSelectionRange(0,i.value.length),!r.execCommand(`copy`))throw Error(`execCommand copy returned false`)}finally{i.parentNode&&i.parentNode.removeChild(i)}return Promise.resolve()}function _M({resetDelayMs:e=2e3,logPrefix:t}={}){let n=j({copied:!1,error:!1}),r=null;function i(){r!==null&&clearTimeout(r),r=null}function a(){i(),r=setTimeout(()=>{n.copied=!1,n.error=!1,r=null},e)}return{get copied(){return n.copied},get error(){return n.error},reset(){i(),n.copied=!1,n.error=!1},async copy(e,r){if(!(e==null||e===``)){i(),n.copied=!1,n.error=!1;try{await gM(typeof r==`function`?r(e):String(e)),n.copied=!0,n.error=!1}catch(e){console.error(t||`Failed to copy text:`,e),n.copied=!1,n.error=!0}a()}}}}var vM=R(``);function yM(e,t){E(t,!0);let n=G(t,`workflowID`,3,``),r=_M({logPrefix:`Failed to copy workflow ID:`});An(()=>{n(),r.reset()});let i=O(()=>r.error?`Unable to copy workflow ID`:r.copied?`Workflow ID copied`:`Copy workflow ID`),a=O(()=>n()?I(i)+` `+n():I(i));async function o(e){e.preventDefault(),n()&&await r.copy(n())}var s=vM();let c;var l=P(M(s),4),u=M(l,!0);T(l);var d=P(l,2);K(M(d),{get icon(){return Ja}}),T(d),T(s),F(()=>{c=U(s,1,`workflow-pipeline-meta mono svelte-1viff7o`,null,c,{"workflow-pipeline-meta-copied":r.copied,"workflow-pipeline-meta-error":r.error}),W(s,`title`,I(i)),W(s,`aria-label`,I(a)),B(u,n())}),L(`click`,s,o),z(e,s),D()}Hr([`click`]);var bM=(e,t)=>{let n=()=>(t?.()).icon,r=()=>(t?.()).label,i=Ot(()=>h((t?.()).variant,`workflow-node-feature`)),a=()=>(t?.()).state,o=()=>(t?.()).sub,s=()=>(t?.()).badge;var c=wM(),l=M(c),u=e=>{var t=xM();let r;K(M(t),{get icon(){return n()}}),T(t),F(()=>r=U(t,1,`workflow-node-icon svelte-nbptrg`,null,r,{"workflow-node-icon-endpoint":I(i)===`workflow-node-endpoint`})),z(e,t)};V(l,e=>{n()&&e(u)});var d=P(l,2),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var t=SM(),n=M(t,!0);T(t),F(()=>B(n,s())),z(e,t)};V(p,e=>{s()&&e(m)});var g=P(p,2),_=e=>{var t=CM(),n=M(t,!0);T(t),F(()=>B(n,o())),z(e,t)};V(g,e=>{o()&&e(_)}),T(c),F(()=>{U(c,1,Fi([`workflow-node`,I(i),a()]),`svelte-nbptrg`),B(f,r())}),z(e,c)},xM=R(`
        `),SM=R(` `),CM=R(` `),wM=R(`
        `),TM=R(`
        `,1),EM=R(`
        `,1),DM=R(`
        `),OM=R(`
        Async
        `),kM=R(`
        `);function AM(e,t){E(t,!0);let n=G(t,`chart`,19,()=>({}));var r=kM();let i;var a=M(r),o=e=>{yM(e,{get workflowID(){return n().workflowID}})};V(a,e=>{n().workflowID&&e(o)});var s=P(a,2),c=M(s);bM(c,()=>({icon:jo,label:`Client`,variant:`workflow-node-endpoint`}));var l=P(c,4);bM(l,()=>({icon:Xa,label:`Auth`,state:n().authNodeClass,sub:n().authNodeSublabel}));var u=P(l,2),d=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:Xa,label:`Cache`,state:n().cacheNodeClass,badge:n().cacheStatusLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().cacheConnClass]),`svelte-nbptrg`)),z(e,t)};V(u,e=>{n().showCache&&e(d)});var f=P(u,2),p=e=>{var t=EM();bM(P(N(t),2),()=>({icon:Mo,label:`Budget`,state:n().budgetNodeClass,badge:n().budgetStatusLabel})),z(e,t)};V(f,e=>{n().showBudget&&e(p)});var m=P(f,2),h=e=>{var t=EM();bM(P(N(t),2),()=>({icon:wo,label:`Guardrails`,sub:n().guardrailLabel})),z(e,t)};V(m,e=>{n().showGuardrails&&e(h)});var g=P(m,2),_=P(g,2);bM(_,()=>({label:n().aiLabel,variant:`workflow-node-ai`,state:n().aiNodeClass,sub:n().aiSublabel}));var v=P(_,2),y=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:ao,label:`Failover`,state:n().failoverNodeClass,badge:n().failoverStatusLabel,sub:n().failoverTargetLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().failoverConnClass]),`svelte-nbptrg`)),z(e,t)};V(v,e=>{n().showFailover&&e(y)});var b=P(v,2);bM(P(b,2),()=>({icon:Wa,label:`Response`,variant:`workflow-node-endpoint`,state:n().responseNodeClass,sub:n().responseNodeSublabel})),T(s);var x=P(s,2),S=e=>{var t=OM(),r=M(t),i=M(r),a=e=>{bM(e,()=>({icon:Ra,label:`Usage`,variant:`workflow-node-feature workflow-node-async`,state:n().usageNodeClass}))};V(i,e=>{n().showUsage&&e(a)});var o=P(i,2),s=e=>{z(e,DM())};V(o,e=>{n().showUsage&&n().showAudit&&e(s)});var c=P(o,2),l=e=>{bM(e,()=>({icon:Za,label:`Audit Log`,variant:`workflow-node-feature workflow-node-async`,state:n().auditNodeClass}))};V(c,e=>{n().showAudit&&e(l)}),T(r),Ue(4),T(t),z(e,t)};V(x,e=>{n().showAsync&&e(S)}),T(r),F(()=>{i=U(r,1,`workflow-pipeline svelte-nbptrg`,null,i,{"workflow-pipeline-has-meta":n().workflowID}),U(g,1,Fi([`workflow-conn`,n().aiConnClass]),`svelte-nbptrg`),U(b,1,Fi([`workflow-conn`,n().responseConnClass]),`svelte-nbptrg`)}),z(e,r),D()}function jM(e){let t=qj(e).length;return t===0?``:t===1?`1 step`:t+` steps`}function MM(e,t){return t&&t.provider?t.provider:Yj(e&&e.scope)||`AI`}function NM(e,t){return t&&t.model?t.model:e&&e.scope&&e.scope.scope_model||null}function PM(e,t){let n=String(e&&e.id||``).trim();if(n&&n!==`draft-workflow-preview`)return n;let r=String(t&&t.workflow_version_id||``).trim();return r&&r!==`draft-workflow-preview`?r:null}function FM(e){let t=e&&e.data&&e.data.workflow_features;return!t||typeof t!=`object`||Array.isArray(t)?null:Uj(t)}function IM(e){let t=e&&e.data&&e.data.failover;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=String(t.target_model||t.targetModel||``).trim()||null;return n?{targetModel:n}:null}function LM(e,t=0){if(t>4||e==null)return``;if(typeof e==`string`){let n=e.trim();if(!n||n[0]!==`{`&&n[0]!==`[`)return``;try{return LM(JSON.parse(n),t+1)}catch{return``}}if(Array.isArray(e)){for(let n of e){let e=LM(n,t+1);if(e)return e}return``}return typeof e==`object`?String(e.code||``).trim()||(e.error===void 0?``:LM(e.error,t+1)):``}function RM(e){let t=e&&e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{};return String(t.error_code||t.errorCode||``).trim()||LM(t.response_body)}function zM(e){let t=String(e||``).trim();if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{provider:t.slice(0,n),model:t.slice(n+1)}}function BM(e,t){let n=String(e&&(e.requested_model||e.model)||``).trim(),r=IM(e);if(!(r&&r.targetModel))return{provider:String(e&&e.provider||``).trim()||null,model:n||null};let i=zM(n);if(i)return i;let a=Yj(t&&t.scope),o=a?String(t&&t.scope&&t.scope.scope_model||``).trim():``;return a||o?{provider:a||null,model:o||n||null}:{provider:null,model:n||null}}function VM(e,t){if(!e)return null;let n=(()=>{let t=String(e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`?t:null})(),r=(()=>{if(e.status_code===void 0||e.status_code===null)return null;let t=String(e.status_code).trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null})(),i=n?!0:e.cache_hit!==void 0&&e.cache_hit!==null&&!!e.cache_hit,a=IM(e),o=BM(e,t),s=Number.isFinite(r)&&r>=200&&r<300,c=String(e.error_type||``).trim().toLowerCase()===`authentication_error`,l=String(e.auth_method||``).trim().toLowerCase()||null,u=RM(e).toLowerCase()===`budget_exceeded`;return{cacheHit:i,cacheType:n||null,failoverTarget:a&&a.targetModel?a.targetModel:null,provider:o.provider,model:o.model,statusCode:r,responseSuccess:s,aiSuccess:s&&!i,authError:c,authMethod:l,budgetExceeded:u}}function HM(e){return!!(e&&e.cacheHit)}function UM(e){return!!(e&&e.failoverTarget)}function WM(e){return!!(e&&e.budgetExceeded)}function GM(e,t){return t?`workflow-node-current`:e&&e.cacheHit?`workflow-node-success`:``}function KM(e){return e&&e.cacheHit?`workflow-conn-hit`:``}function qM(e){return!e||!e.cacheHit?null:e.cacheType===`semantic`?`Hit (Semantic)`:`Hit (Exact)`}function JM(e,t,n,r){return e?WM(t)?`workflow-node-error`:r?`workflow-node-current`:n?`workflow-node-success`:``:``}function YM(e){return WM(e)?`Exceeded`:null}function XM(e){return e&&e.cacheHit?`workflow-node-skipped`:e&&e.failoverTarget?`workflow-node-success`:``}function ZM(e){return e&&e.cacheHit?`workflow-conn-dim`:e&&e.failoverTarget?`workflow-conn-hit`:``}function QM(e){return e&&e.failoverTarget?`Redirected`:null}function $M(e){return e&&e.failoverTarget?e.failoverTarget:null}function eN(e){return e&&e.cacheHit?`workflow-conn-dim`:``}function tN(e,t){return e?e.cacheHit?`workflow-node-skipped`:t?`workflow-node-current`:e.aiSuccess?`workflow-node-success`:``:``}function nN(e,t){if(!e)return``;let n=e.statusCode;return!Number.isFinite(n)&&t?`workflow-node-current`:Number.isFinite(n)?n>=500?`workflow-node-error`:n>=400?`workflow-node-warning`:n>=300?`workflow-node-neutral`:n>=200?`workflow-node-success`:``:``}function rN(e){return!e||!Number.isFinite(e.statusCode)?null:String(e.statusCode)}function iN(e,t){return e?e.authError?`workflow-node-error`:t?`workflow-node-current`:e.authMethod===`api_key`||e.authMethod===`master_key`?`workflow-node-success`:``:``}function aN(e){return!e||!e.authMethod?null:e.authMethod}function oN(e,t,n){return e?n?`workflow-node-current`:t?`workflow-node-success`:``:``}function sN(e,t){if(!e||!e._live)return!!t;let n=String(e._live_state||``).trim();return!!e._audit_flushed||n===`audit.flushed`||n===`audit.detail`}function cN(e,t){if(!e)return!!t;let n=e.usage||{},r=Number(n.entries||0)>0;if(!e._live)return r;let i=String(e._usage_live_state||``).trim();return e._usage_flushed||i===`usage.flushed`?!0:!e._usage_live_pending&&r&&!e._live_pending}function lN(e){return!!(e&&e._live&&e._usage_live_pending&&!e._usage_flushed)}function uN(e,t){return!e||!e._live||sN(e,!1)?!1:String(e._live_state||``).trim()===`audit.completed`||!!(t&&Number.isFinite(t.statusCode))}function dN(e,t,n){return!e||!e._live?``:lN(e)?`usage`:uN(e,t)?`audit`:sN(e,!1)&&!e._live_pending?``:t&&t.cacheHit?`cache`:t&&(t.provider||t.model)?`ai`:n&&n.budget&&(e.workflow_version_id||e.requested_model)?`budget`:t&&t.authMethod?``:`auth`}function fN(e,t,n,r){let i=n||{},a=i.features&&typeof i.features==`object`&&!Array.isArray(i.features)?Uj(i.features):Gj(e,r),o=!!i.forceAudit,s=!!i.highlightAsyncPresent,c=!!a.budget||WM(t),l=!!a.guardrails,u=!!a.usage,d=o||!!a.audit,f=!!i.forceAsync||!!(u||d),p=!!a.failover||UM(t),m=PM(e,i.entry),h=dN(i.entry,t,a),g=lN(i.entry),_=uN(i.entry,t),v=sN(i.entry,s),y=cN(i.entry,s);return{showBudget:c,budgetNodeClass:JM(c,t,s,h===`budget`),budgetStatusLabel:YM(t),showGuardrails:l,guardrailLabel:l?jM(e):``,showCache:!!i.forceCache||!!a.cache||HM(t),cacheNodeClass:GM(t,h===`cache`),cacheConnClass:KM(t),cacheStatusLabel:qM(t),showFailover:p,failoverNodeClass:p?XM(t):``,failoverConnClass:p?ZM(t):``,failoverStatusLabel:p?QM(t):null,failoverTargetLabel:p?$M(t):null,aiLabel:MM(e,t),aiSublabel:NM(e,t),aiConnClass:eN(t),aiNodeClass:tN(t,h===`ai`),responseConnClass:eN(t),responseNodeClass:nN(t,h===`response`),responseNodeSublabel:rN(t),authNodeClass:iN(t,h===`auth`),authNodeSublabel:aN(t),usageNodeClass:oN(u,y,g),auditNodeClass:oN(d,v,_),showAsync:f,showUsage:u,showAudit:d,workflowID:m}}function pN(e,t){return fN(e,null,{forceCache:!1},t)}function mN(e,t,n){return fN(t,VM(e,t),{entry:e,features:FM(e)||(t?Gj(t,n):{cache:!1,audit:!1,usage:!1,budget:!1,guardrails:!1,failover:!1}),forceAudit:!0,forceAsync:!0,highlightAsyncPresent:!0},n)}var hN=R(`

        `),gN=R(`

        `),_N=R(`
        `),vN=R(`
        `),yN=R(`

        No guardrails configured for this workflow.

        `),bN=R(`

        Guardrails

        `),xN=R(``),SN=R(`

        `);function CN(e,t){E(t,!0);let n=G(t,`preview`,3,!1),r=O(()=>hM.featureCaps()),i=O(()=>tM(t.workflow)),a=O(()=>Jj(t.workflow,I(r))),o=O(()=>pN(t.workflow,I(r))),s=O(()=>n()?`draft-workflow-preview-guardrail-`:t.workflow.id+`-guardrail-`);var c=SN();let l;var u=M(c),d=M(u),f=M(d),p=M(f,!0);T(f);var m=P(f,2),h=M(m,!0);T(m),T(d);var g=P(d,2),_=M(g),v=M(_,!0);T(_),T(g),T(u);var y=P(u,2),b=e=>{var n=hN(),r=M(n,!0);T(n),F(()=>B(r,t.workflow.description)),z(e,n)};V(y,e=>{t.workflow.description&&e(b)});var x=P(y,2),S=e=>{var n=gN(),i=M(n);T(n),F(e=>B(i,`Failover: ${e??``}`),[()=>Kj(t.workflow,I(r))]),z(e,n)},C=O(()=>hM.failoverVisible());V(x,e=>{I(C)&&e(S)});var w=P(x,2);AM(w,{get chart(){return I(o)}});var ee=P(w,2),te=e=>{var t=bN(),n=M(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var o=P(n,2),c=e=>{var t=vN();H(t,23,()=>I(a),(e,t)=>I(s)+t,(e,t)=>{var n=_N(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a);T(a),T(n),F(()=>{B(i,I(t).ref),B(o,`step ${I(t).step??``}`)}),z(e,n)}),T(t),z(e,t)},l=e=>{z(e,yN())};V(o,e=>{I(a).length>0?e(c):e(l,-1)}),T(t),F(()=>B(i,I(a).length?I(a).length+` steps`:`None`)),z(e,t)},ne=O(()=>xs.guardrailsVisible());V(ee,e=>{I(ne)&&e(te)});var re=P(ee,2),ie=e=>{var n=xN(),r=M(n),a=M(r),o=M(a,!0);T(a);var s=P(a,2);{let e=O(()=>`Edit workflow `+I(i));gT(s,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>hM.openCreate(t.workflow),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(r);var c=P(r,2),l=M(c),u=M(l);T(l);var d=P(l,2),f=M(d);T(d);var p=P(d,2),m=M(p);T(p),T(c),T(n),F((e,n,r,s)=>{a.disabled=e,W(a,`aria-label`,`Deactivate workflow `+I(i)),W(a,`title`,n),B(o,hM.deactivatingID===t.workflow.id?`Deactivating...`:`Deactivate`),B(u,`version: v${t.workflow.version??``}`),B(f,`created: ${r??``}`),B(m,`hash: ${s??``}`)},[()=>hM.deactivatingID===t.workflow.id||!lM(t.workflow),()=>lM(t.workflow)?`Deactivate active workflow`:`The global workflow cannot be deactivated.`,()=>us.formatTimestamp(t.workflow.created_at),()=>uM(t.workflow.workflow_hash)]),L(`click`,a,()=>hM.deactivate(t.workflow)),z(e,n)};V(re,e=>{n()||e(ie)}),T(c),F((e,t)=>{l=U(c,1,`workflow-card svelte-1fo9fvq`,null,l,{"workflow-preview-card":n()}),B(p,e),B(h,I(i)),B(v,t)},[()=>$j(t.workflow),()=>eM(t.workflow)]),z(e,c),D()}Hr([`click`]);var wN=R(`

        `),TN=R(``),EN=R(``),DN=R(``),ON=R(``),kN=R(``),AN=R(``),jN=R(``),MN=R(``),NN=R(``),PN=R(``),FN=R(``),IN=R(``),LN=R(`
        No named guardrails are currently registered on this deployment. You can still draft a workflow, but guardrail-backed creation may be rejected.
        `),RN=R(`
        `),zN=R(`
        `),BN=R(`

        No guardrail steps configured yet.

        `),VN=R(`

        Guardrail Steps

        Guardrails in the same numeric step run together. Later steps wait for earlier ones to finish.

        `),HN=R(`

        Leave provider name empty to target all providers and models. Select a provider name without a model to target all models for that configured provider.

        Add a path to scope the workflow to that subtree. Leading slashes are optional and will be normalized; you can enter "team/alpha" or "/team/alpha". Matching checks the deepest user path first, then falls back toward the root.

        If you leave the name empty, the workflow will display as the matched provider/model scope or “All models”.

        Preview

        Live
        `,1);function UN(e,t){E(t,!0);{let t=e=>{KS(e,{copyId:`workflow-help-copy`,label:`workflow help`,text:`Create immutable version. Submitting activates it for the selected scope.`,title:e=>{var t=wN(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>hM.submitMode()===`save`?`Edit Workflow`:`Create Workflow`]),z(e,t)},$$slots:{title:!0}})},n=O(()=>hM.submitLabel()),r=O(()=>hM.submittingLabel()),i=O(()=>hM.submitMode()===`create`?fo:go);bE(e,{get open(){return hM.formOpen},ariaLabel:`Workflow editor`,get error(){return hM.formError},get submitting(){return hM.submitting},get submitLabel(){return I(n)},get submittingLabel(){return I(r)},get submitIcon(){return I(i)},dialogClass:`workflow-editor`,onclose:()=>hM.closeForm(),onsubmit:()=>hM.submitForm(),header:t,children:(e,t)=>{var n=HN(),r=N(n),i=M(r);SE(i,{id:`workflow-scope-provider`,label:`Provider Name`,children:(e,t)=>{var n=EN(),r=M(n);r.value=r.__value=``,H(P(r),16,()=>hM.providerOptions(),e=>e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(n),L(`change`,n,e=>hM.setProvider(e.currentTarget.value)),Gi(n,()=>hM.form.scope_provider,e=>hM.form.scope_provider=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2),o=e=>{SE(e,{id:`workflow-scope-model`,label:`Model`,children:(e,t)=>{var n=DN(),r=M(n);r.value=r.__value=``,H(P(r),17,()=>hM.modelOptions(hM.form.scope_provider),e=>hM.form.scope_provider+`-`+e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t)),i!==(i=I(t))&&(n.value=(n.__value=I(t))??``)}),z(e,n)}),T(n),Gi(n,()=>hM.form.scope_model,e=>hM.form.scope_model=e),z(e,n)},$$slots:{default:!0}})};V(a,e=>{hM.form.scope_provider&&e(o)});var s=P(a,2);SE(s,{id:`workflow-name`,label:`Name`,children:(e,t)=>{var n=ON();na(n),da(n,()=>hM.form.name,e=>hM.form.name=e),z(e,n)},$$slots:{default:!0}}),SE(P(s,2),{id:`workflow-user-path`,label:`User Path`,children:(e,t)=>{var n=kN();na(n),da(n,()=>hM.form.scope_user_path,e=>hM.form.scope_user_path=e),z(e,n)},$$slots:{default:!0}}),T(r);var c=P(r,8);SE(c,{id:`workflow-description`,label:`Description`,children:(e,t)=>{var n=AN();ft(n),da(n,()=>hM.form.description,e=>hM.form.description=e),z(e,n)},$$slots:{default:!0}});var l=P(c,2),u=M(l),d=e=>{var t=jN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.cache,e=>hM.form.features.cache=e),z(e,t)},f=O(()=>xs.cacheVisible());V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var t=MN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.audit,e=>hM.form.features.audit=e),z(e,t)},h=O(()=>xs.auditVisible());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=e=>{var t=NN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.usage,e=>hM.form.features.usage=e),z(e,t)},v=O(()=>xs.usageVisible());V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=PN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.budget,e=>hM.form.features.budget=e),z(e,t)},x=O(()=>xs.budgetsVisible());V(y,e=>{I(x)&&e(b)});var S=P(y,2),C=e=>{var t=FN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.guardrails,e=>hM.form.features.guardrails=e),z(e,t)},w=O(()=>xs.guardrailsVisible());V(S,e=>{I(w)&&e(C)});var ee=P(S,2),te=e=>{var t=IN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.failover,e=>hM.form.features.failover=e),z(e,t)},ne=O(()=>hM.failoverVisible());V(ee,e=>{I(ne)&&e(te)}),T(l);var re=P(l,2),ie=P(M(re),2);{let e=O(()=>hM.preview());CN(ie,{get workflow(){return I(e)},preview:!0})}T(re);var ae=P(re,2),oe=e=>{var t=VN(),n=M(t),r=P(M(n),2);T(n);var i=P(n,2),a=e=>{var t=LN(),n=P(M(t),2);T(t),L(`click`,n,()=>qo.navigate(`guardrails`)),z(e,t)};V(i,e=>{hM.guardrailRefs.length===0&&e(a)});var o=P(i,2),s=e=>{var t=zN();H(t,21,()=>hM.form.guardrails,oi,(e,t,n)=>{var r=RN(),i=M(r),a=M(i);W(a,`for`,`workflow-guardrail-ref-`+n);var o=P(a,2);na(o),W(o,`id`,`workflow-guardrail-ref-`+n),W(o,`aria-label`,`Guardrail reference `+(n+1)),T(i);var s=P(i,2),c=M(s);W(c,`for`,`workflow-guardrail-step-`+n);var l=P(c,2);na(l),W(l,`id`,`workflow-guardrail-step-`+n),W(l,`aria-label`,`Guardrail step `+(n+1)),T(s);var u=P(s,2);T(r),da(o,()=>I(t).ref,e=>I(t).ref=e),da(l,()=>I(t).step,e=>I(t).step=e),L(`click`,u,()=>hM.removeGuardrailStep(n)),z(e,r)}),T(t),z(e,t)},c=e=>{z(e,BN())};V(o,e=>{hM.form.guardrails.length>0?e(s):e(c,-1)}),T(t),L(`click`,r,()=>hM.addGuardrailStep()),z(e,t)},se=O(()=>hM.form.features.guardrails&&xs.guardrailsVisible());V(ae,e=>{I(se)&&e(oe)}),z(e,n)},$$slots:{header:!0,default:!0}})}D()}Hr([`change`,`click`]);var WN=R(`

        Loading workflows...

        `),GN=R(`
        `),KN=R(`

        No active workflows found.

        `),qN=R(`

        No workflows match your filter.

        `),JN=R(`
        `);function YN(e,t){E(t,!0);var n=JN(),r=M(n),i=e=>{var t=WN();xS(M(t),{size:16,label:`Loading workflows`}),Ue(),T(t),z(e,t)};V(r,e=>{hM.loading&&!q.authError&&e(i)});var a=P(r,2),o=e=>{var t=GN();H(t,21,()=>hM.filteredWorkflows,e=>e.id,(e,t)=>{CN(e,{get workflow(){return I(t)}})}),T(t),z(e,t)};V(a,e=>{hM.filteredWorkflows.length>0&&e(o)});var s=P(a,2),c=e=>{z(e,KN())};V(s,e=>{hM.workflows.length===0&&!hM.loading&&!q.authError&&hM.available&&e(c)});var l=P(s,2),u=e=>{z(e,qN())};V(l,e=>{hM.workflows.length>0&&hM.filteredWorkflows.length===0&&!hM.loading&&e(u)}),T(n),z(e,n),D()}var XN=R(``),ZN=R(`
        Workflows feature is unavailable.
        `),QN=R(`
        `),$N=R(`
        `),eP=R(``),tP=R(`
        `);function nP(e,t){E(t,!0),An(()=>{q.refreshTick,hM.fetchPage()});var n=tP(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=XN();K(M(t),{get icon(){return fo},class:`form-action-icon`,"aria-hidden":`true`}),Ue(2),T(t),L(`click`,t,()=>hM.openCreate()),z(e,t)};V(a,e=>{hM.available&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,ZN())};V(s,e=>{!hM.available&&!q.authError&&e(c)});var l=P(s,2),u=e=>{var t=QN(),n=M(t,!0);T(t),F(()=>B(n,hM.error)),z(e,t)};V(l,e=>{hM.error&&!q.authError&&e(u)});var d=P(l,2),f=e=>{var t=$N(),n=M(t);yw(M(n),{placeholder:`Filter by scope, name, hash, or guardrail...`,label:`Filter workflows by scope, name, hash, or guardrail`,get value(){return hM.filter},set value(e){hM.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i,!0);T(i),T(r),T(t),F(()=>B(a,hM.filteredWorkflows.length+` active scopes`)),z(e,t)};V(d,e=>{hM.available&&e(f)});var p=P(d,2);UN(p,{});var m=P(p,2);YN(m,{});var h=P(m,2);H(h,20,()=>hM.guardrailRefs,e=>e,(e,t)=>{var n=eP(),r={};F(()=>{r!==(r=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(h),T(n),z(e,n),D()}Hr([`click`]);function rP(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=Ys}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=iP(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function iP(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}var aP=null;function oP(){return aP===null&&(aP=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`)),!!(aP&&aP.matches)}function sP(e){return oP()?0:e}function cP(e,t){return!t||!t.live?{duration:0}:qs(e,{duration:sP(150)})}var lP=new class{#e=k(j({}));get workflowVersionsByID(){return I(this.#e)}set workflowVersionsByID(e){A(this.#e,e,!0)}workflowVersionRequests={};workflowFeatureCaps(){return{cache:xs.cacheVisible(),audit:xs.auditVisible(),usage:xs.usageVisible(),budget:xs.budgetsVisible(),guardrails:xs.guardrailsVisible(),failover:xs.booleanFlag(`FAILOVER_ENABLED`,!0)}}cacheWorkflowVersion(e){let t=String(e&&e.id||``).trim();return t?(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:e},e):null}cacheMissingWorkflowVersion(e){let t=String(e||``).trim();t&&(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:null})}workflowVersionCacheHas(e){return Object.prototype.hasOwnProperty.call(this.workflowVersionsByID||{},String(e||``).trim())}workflowVersionByID(e){let t=String(e||``).trim();return t&&this.workflowVersionCacheHas(t)?this.workflowVersionsByID[t]:null}async fetchWorkflowVersion(e){let t=String(e||``).trim();if(!t)return null;if(this.workflowVersionCacheHas(t))return this.workflowVersionsByID[t];if(this.workflowVersionRequests[t])return this.workflowVersionRequests[t];let n=(async()=>{let e=typeof AbortController==`function`?new AbortController:null,n=e?setTimeout(()=>e.abort(),1e4):null;try{let n=await gs(`/admin/workflows/`+encodeURIComponent(t),{label:`workflow`,signal:e?e.signal:void 0});if(n.stale)return null;if(n.status===404)return this.cacheMissingWorkflowVersion(t),null;if(!n.ok)return null;let r=n.data;return!r||typeof r!=`object`||Array.isArray(r)?(this.cacheMissingWorkflowVersion(t),null):this.cacheWorkflowVersion(r)}catch(e){return e&&e.name===`AbortError`||console.error(`Failed to fetch workflow version:`,e),null}finally{n!==null&&clearTimeout(n),delete this.workflowVersionRequests[t]}})();return this.workflowVersionRequests[t]=n,n}async prefetchAuditWorkflows(e){let t=[...new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.workflow_version_id||``).trim()).filter(Boolean))];t.length!==0&&await Promise.all(t.map(e=>this.fetchWorkflowVersion(e)))}auditEntryWorkflow(e){let t=String(e&&e.workflow_version_id||``).trim();return t?this.workflowVersionByID(t):null}},uP=6;function dP(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}function fP(e,t=0,n=null){let r=String(e||``).trim();if(!r)return``;if(t>uP)return r;let i=dP(r);return i==null?r:pP(i,t+1,n)||n&&n(i)||r}function pP(e,t=0,n=null,r=null){if(e==null||t>uP)return``;if(typeof e==`string`){let i=dP(e.trim());return i==null?``:pP(i,t+1,n,r)}if(typeof e!=`object`)return``;let i=r||new Set;if(i.has(e))return``;if(i.add(e),Array.isArray(e)){for(let r=0;r=400||gP(t&&t.response_body)}function vP(e){let t=e&&e.data?e.data:null;return t?mP(t.error_message)||(_P(e,t)?pP(t.response_body,0):``):``}function yP(e){if(e==null||String(e).trim()===``)return null;let t=Number(e);return!Number.isInteger(t)||t<0?null:t}function bP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained indefinitely.`:t===1?`Audit logs are retained for 1 day.`:`Audit logs are retained for `+t+` days.`}function xP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained `:`Audit logs are retained for `}function SP(e){let t=yP(e);return t===null?``:t===0?`indefinitely`:t===1?`1 day`:t+` days`}function CP({dateQuery:e,limit:t,offset:n,search:r,method:i,statusCode:a,stream:o}){let s=e;return s+=`&limit=`+t+`&offset=`+n,r&&(s+=`&search=`+encodeURIComponent(r)),i&&(s+=`&method=`+encodeURIComponent(i)),a&&(s+=`&status_code=`+encodeURIComponent(a)),o&&(s+=`&stream=`+encodeURIComponent(o)),s}function wP({sessionId:e,limit:t}){return`session_id=`+encodeURIComponent(e)+`&limit=`+(t||100)+`&offset=0`}function TP(e){return String(e&&e.session_id||``).trim()}function EP(e){let t=Number(e&&e.session_count);return Number.isFinite(t)&&t>1?t:1}function DP(e){return!!TP(e)&&EP(e)>1}function OP(e){return{entries:(Array.isArray(e&&e.sessions)?e.sessions:[]).filter(e=>e&&e.latest).map(e=>({...e.latest,session_id:TP(e.latest)||String(e.session_id||``).trim(),session_count:Number(e.count||1)})),total:Number(e&&e.total||0),limit:Number(e&&e.limit||25),offset:Number(e&&e.offset||0)}}function kP(e,t,n){let r=new Set((Array.isArray(n)?n:[]).flatMap(e=>NP(e))),i=(Array.isArray(t)?t:[]).filter(e=>!NP(e).some(e=>r.has(e))),a=new Set([...r,...i.flatMap(e=>NP(e))]),o=(e&&Array.isArray(e.entries)?e.entries:[]).filter(e=>e&&e._live&&!NP(e).some(e=>a.has(e)));return{entries:[...o,...i],preservedCount:o.length}}function AP(e,t){let n=e||{};if(!t)return n;if(n[t]){let e={...n};return delete e[t],e}return{...n,[t]:!0}}function jP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>TP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=n[e];return}a=!0}),a?i:n}function MP(e){return String(e&&e.id||``).trim()}function NP(e){if(!e)return[];let t=[],n=String(e.id||``).trim(),r=String(e.request_id||``).trim();return n&&t.push(`id:`+n),r&&t.push(`request:`+r),t}function PP(e){return!!(e&&e._live&&e._live_pending&&!e._audit_flushed)}function FP(e){let t=e&&e.customStartDate,n=e&&e.customEndDate;if(!t&&!n)return!0;let r=new Date;if(t){let e=new Date(t);if(e.setHours(0,0,0,0),Number.isFinite(e.getTime())&&re)return!1}return!0}function IP(e,t){return e&&Number(e.offset||0)===0&&!(t&&t.search)&&!(t&&t.method)&&!(t&&t.statusCode)&&!(t&&t.stream)&&FP(t)}function LP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=[];return a.forEach(e=>{let t=NP(e);t.length!==0&&(t.some(e=>o.has(e))||(t.forEach(e=>o.add(e)),s.push(e)))}),s.length===0?r:(r.entries=[...s,...i].slice(0,r.limit||25),r.total=Number(r.total||0)+s.length,r)}function RP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=new Map;i.forEach((e,t)=>{let n=TP(e);n&&!s.has(n)&&s.set(n,t)});let c=[],l=i;return a.forEach(e=>{let t=NP(e);if(t.length===0||t.some(e=>o.has(e)))return;let n=TP(e);if(n&&s.has(n)){let r=s.get(n);l===i&&(l=[...i]),l[r]={...e,session_count:Math.max(EP(l[r]),EP(e))},t.forEach(e=>o.add(e));return}t.forEach(e=>o.add(e)),c.push(e)}),r.entries=[...c,...l].slice(0,r.limit||25),r.total=Number(r.total||0)+c.length,r}function zP(e,t){let n=MP(t),r=e||{};return n?r[n]?{}:{[n]:!0}:r}function BP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>MP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=!0;return}a=!0}),a?i:n}function VP(e){if(e==null)return`-`;let t=Number(e);return Number.isFinite(t)?t<=0?`pending`:t<1e6?Math.round(t/1e3)+` µs`:t<1e9?(t/1e6).toFixed(2)+` ms`:(t/1e9).toFixed(2)+` s`:`-`}function HP(e){if(e==null||e===``)return`status-unknown`;let t=Number(e);return Number.isFinite(t)?t>=500?`status-error`:t>=400?`status-warning`:t>=300?`status-neutral`:`status-success`:`status-unknown`}function UP(e){if(!e||!e._live||!e._live_pending)return!1;let t=String(e._live_state||``).trim();if(t===`audit.completed`||t===`audit.flushed`||t===`audit.detail`)return!1;if(e._response_partial)return!0;if(e.status_code!==null&&e.status_code!==void 0&&e.status_code!==``||Number(e.duration_ns||0)>0||e.error_type||e.error_message)return!1;let n=e.data||{};return!(n.response_headers||n.response_body||n.error_message)}function WP(e){let t=e&&e.data&&e.data.failover;return!t||typeof t!=`object`||Array.isArray(t)?null:String(t.target_model||t.targetModel||``).trim()||null}function GP(e){return(e&&e.data&&Array.isArray(e.data.attempts)?e.data.attempts:[]).map((e,t)=>({...e,seq:Number(e&&e.seq||t+1)})).sort((e,t)=>e.seq-t.seq)}function KP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))}function qP(e){if(!e)return`-`;let t=e.status_code||e.status;return t?String(t):e.success?`ok`:`error`}function JP(e){return String(e&&e.kind||``).trim()||`attempt`}function YP(e){if(!e)return`-`;let t=String(e.provider_name||``).trim(),n=String(e.provider_type||e.provider||``).trim();return t&&n&&t!==n?t+` (`+n+`)`:t||n||`-`}function XP(e){return String(e&&e.model||``).trim()||`-`}function ZP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))?t:[]}function QP(e){return GP(e).length+`×`}function $P(e){let t=GP(e),n=t.filter(e=>!(e&&e.success)).length,r=t.length===1?`attempt`:`attempts`,i=t.length+` provider `+r;return n>0?i+` · `+n+` failed`:i}function eF(e){if(!e)return``;let t=[`#`+Number(e.seq||0)],n=JP(e);n&&n!==`attempt`&&t.push(n),t.push(qP(e));let r=YP(e);r&&r!==`-`&&t.push(r);let i=XP(e);return i&&i!==`-`&&t.push(i),t.push(e.success?`succeeded`:`failed`),t.join(` · `)}function tF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t&&t.response_body!=null?t.response_body:null}return t.response_body!=null&&t.response_body!==``?t.response_body:null}function nF(e){if(!e||e.success)return``;let t=String(e.error_message||``).trim(),n=String(e.error_code||``).trim(),r=String(e.error_type||``).trim();return t&&n?n+`: `+t:t||n||r||`Provider attempt failed`}function rF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t?t.response_headers:null}return t.response_headers||null}function iF(e){let t=Number(e&&e.status_code);return Number.isFinite(t)&&t>0?t:null}function aF(e,t){let n=!!(t&&t.success),r=e&&e.data?e.data:null,i=tF(e,t),a=rF(e,t),o=nF(t),s=i!=null&&i!==``,c=JP(t),l=GP(e).length<=1;return{title:`Response`,direction:`response`,seq:l?0:Number(t&&t.seq||0),kind:l||c===`attempt`?``:c,statusCode:l?null:iF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:i,showErrorMessage:!!o,errorMessage:o,showHeaders:!!a,headers:a,showBody:s,body:i,showEmpty:!o&&!s&&!a,emptyMessage:`No response was captured for this attempt.`,showTooLarge:!!(n&&r&&r.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function oF(e){return e&&e.data&&Array.isArray(e.data.request_revisions)?e.data.request_revisions:[]}function sF(e){return oF(e).filter(e=>!(e&&e.no_change))}function cF(e){return oF(e).filter(e=>e&&e.no_change).map(e=>{let t=String(e.rewriter||`rewriter`);return{id:`step-`+Number(e.seq||0),rewriter:t,label:t+`: no change`,title:t+` ran and forwarded the request unchanged`}})}function lF(e){let t=Number(e&&e.bytes_before),n=Number(e&&e.bytes_after);if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n>=t)return``;let r=(1-n/t)*100;return`-`+(r>=10?String(Math.round(r)):r.toFixed(1))+`%`}function uF(e,t){let n=t&&t.body,r=n!=null&&n!==``,i=sF(e).length<=1,a={rewriter:t&&t.rewriter||``,bytes:Number(t&&t.bytes_before||0)+` → `+Number(t&&t.bytes_after||0)};return t&&t.detail!=null&&(a.detail=t.detail),{title:`Rewritten`,direction:`request`,seq:i?0:Number(t&&t.seq||0),kind:t&&t.rewriter?String(t.rewriter):``,savingsLabel:lF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:n,showErrorMessage:!1,errorMessage:null,showHeaders:!0,headers:a,headersTitle:`What changed`,showBody:r,body:n,showEmpty:!1,emptyMessage:``,showTooLarge:!r,tooLargeMessage:`Rewritten body not captured (body logging disabled or body too large).`}}function dF(e){let t=e&&e.usage;return!t||typeof t!=`object`?null:t}function fF(e){let t=dF(e);return Number(t&&t.cached_input_tokens||0)>0}function pF(e){let t=dF(e),n=Number(t&&t.input_tokens||0),r=Number(t&&t.cached_input_tokens||0);return!Number.isFinite(n)||n<=0||!Number.isFinite(r)||r<=0?0:Math.max(0,Math.min(100,r/n*100))}function mF(e){let t=dF(e);if(!t)return``;let n=Number(t.input_tokens||0),r=Number(t.cached_input_tokens||0);return n<=0?ac(r)+` cached`:pF(e).toFixed(1)+`% cached`}function hF(e){return fF(e)?mF(e):``}function gF(e,t){let n=dF(e);if(!n||!e||!e.data||!e.data.request_body)return null;let r=Number(n.estimated_cached_characters||0);if(!Number.isFinite(r)||r<=0||typeof t!=`function`)return null;let i=t(e.data.request_body);return!Array.isArray(i)||i.length===0?null:{characters:r,segments:i}}function _F(e,t){let n=e&&e.data?e.data:null,r=!n||!n.request_headers&&!n.request_body,i=r&&UP(e);return{title:`Request`,direction:`request`,layout:`split`,entry:e,copyHeaders:n&&n.request_headers,copyBody:n&&n.request_body,showErrorMessage:!1,errorMessage:null,showHeaders:!!(n&&n.request_headers),headers:n&&n.request_headers,showBody:!!(n&&n.request_body),body:n&&n.request_body,bodyCacheRatioLabel:hF(e),promptCacheHighlight:gF(e,t),noChangeSteps:cF(e),showEmpty:r&&!i,emptyMessage:`Request details were not captured.`,showPending:i,pendingMessage:`Waiting for request data…`,showTooLarge:!!(n&&n.request_body_too_big_to_handle),tooLargeMessage:`Request body was too large to capture.`}}function vF(e){let t=e&&e.data?e.data:null,n=vP(e),r=!t||!n&&!t.response_headers&&!t.response_body,i=r&&UP(e);return{title:`Response`,direction:`response`,layout:`split`,entry:e,copyHeaders:t&&t.response_headers,copyBody:t&&t.response_body,showErrorMessage:!!n,errorMessage:n,showHeaders:!!(t&&t.response_headers),headers:t&&t.response_headers,showBody:!!(t&&t.response_body),body:t&&t.response_body,streaming:!!(e&&e._response_partial&&t&&t.response_body)&&UP(e),showEmpty:r&&!i,emptyMessage:`Response details were not captured.`,showPending:i,pendingMessage:`Response in progress…`,showTooLarge:!!(t&&t.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function yF(e,t){let n=[{id:`request`,pane:_F(e,t)}];return sF(e).forEach(t=>{n.push({id:`revision-`+Number(t&&t.seq||0),pane:uF(e,t)})}),KP(e)?GP(e).forEach(t=>{n.push({id:`response-`+Number(t&&t.seq||0),pane:aF(e,t)})}):n.push({id:`response`,pane:vF(e)}),n}function bF(e){if(!KP(e))return`response`;let t=GP(e),n=null;return t.forEach(e=>{e&&e.success&&(n=e)}),n||=t[t.length-1],n?`response-`+Number(n.seq||0):`request`}function xF(e,t,n){return e&&(Array.isArray(n)?n:yF(t)).some(t=>t.id===e)?e:bF(t)}function SF(e,t,n){if(!t||!t.length)return null;let r=t.indexOf(n);r<0&&(r=0);let i;switch(e){case`ArrowRight`:case`ArrowDown`:i=(r+1)%t.length;break;case`ArrowLeft`:case`ArrowUp`:i=(r-1+t.length)%t.length;break;case`Home`:i=0;break;case`End`:i=t.length-1;break;default:return null}return t[i]}var CF=100;function wF(){return{entries:[],total:0,limit:25,offset:0}}var TF=new class{#e=k(j({}));get auditExpandedEntries(){return I(this.#e)}set auditExpandedEntries(e){A(this.#e,e,!0)}#t=k(j({}));get auditExpandedThreads(){return I(this.#t)}set auditExpandedThreads(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}auditFetchToken=0;get auditLog(){return jC.auditLog}set auditLog(e){jC.auditLog=e}get auditSearch(){return jC.auditSearch}set auditSearch(e){jC.auditSearch=e}get auditMethod(){return jC.auditMethod}set auditMethod(e){jC.auditMethod=e}get auditStatusCode(){return jC.auditStatusCode}set auditStatusCode(e){jC.auditStatusCode=e}get auditStream(){return jC.auditStream}set auditStream(e){jC.auditStream=e}get auditGroupSessions(){return jC.auditGroupSessions}liveFilters(){return{search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream,customStartDate:jc.customStartDate,customEndDate:jc.customEndDate}}toggleAuditGroupSessions(){jC.auditGroupSessions=!jC.auditGroupSessions,Ta(`gomodel_audit_group_sessions`,jC.auditGroupSessions),this.auditExpandedThreads={},jC.auditThreadChildren={},this.fetchAuditLog(!0)}async fetchAuditLog(e){let t=++this.auditFetchToken;this.loading=!0;try{e&&(this.auditLog.offset=0);let n=this.auditGroupSessions,r=CP({dateQuery:jc.queryStr(),limit:this.auditLog.limit,offset:this.auditLog.offset,search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream}),i=await gs((n?`/admin/audit/sessions?`:`/admin/audit/log?`)+r,{label:`audit log`});if(i.stale||t!==this.auditFetchToken)return;if(!i.ok){this.auditLog=wF();return}let a=n?OP(i.data):i.data,o=(n?RP:LP)(a,this.auditLog&&this.auditLog.entries,this.liveFilters());Array.isArray(o.entries)||(o.entries=[]),o.entries=jC.upsertAuditRecords(o.entries,`audit.list`),this.auditLog=o,this.auditExpandedThreads=jP(this.auditExpandedThreads,o.entries),jC.auditThreadChildren=jP(jC.auditThreadChildren,o.entries);let s=[...o.entries,...this.loadedThreadChildren()];this.auditExpandedEntries=BP(this.auditExpandedEntries,s);try{await lP.prefetchAuditWorkflows(s)}catch(e){console.error(`Failed to prefetch audit workflows:`,e)}}catch(e){if(console.error(`Failed to fetch audit log:`,e),t!==this.auditFetchToken)return;this.auditLog=wF()}finally{t===this.auditFetchToken&&(this.loading=!1)}}loadedThreadChildren(){let e=jC.auditThreadChildren||{};return Object.keys(e).flatMap(t=>Array.isArray(e[t]&&e[t].entries)?e[t].entries:[])}isThreadExpanded(e){return!!(e&&this.auditExpandedThreads[e])}threadChildren(e){return e&&jC.auditThreadChildren[e]||null}async toggleThread(e){let t=TP(e);if(!t)return;let n=!this.isThreadExpanded(t);this.auditExpandedThreads=AP(this.auditExpandedThreads,t);let r=jC.auditThreadChildren[t];n&&!(r&&(r.loaded||r.loading))&&await this.fetchThreadEntries(e)}async fetchThreadEntries(e){let t=TP(e);if(!t)return;let n=jC.auditThreadChildren[t];jC.auditThreadChildren={...jC.auditThreadChildren,[t]:{loading:!0,loaded:!1,entries:n&&Array.isArray(n.entries)?n.entries:[],total:Number(n&&n.total||0)}};let r=()=>{let e={...jC.auditThreadChildren},n=e[t],r=n&&Array.isArray(n.entries)?n.entries:[];r.length>0?e[t]={loading:!1,loaded:!1,entries:r,total:r.length}:(delete e[t],this.auditExpandedThreads[t]&&(this.auditExpandedThreads=AP(this.auditExpandedThreads,t))),jC.auditThreadChildren=e};try{let n=await gs(`/admin/audit/log?`+wP({sessionId:t,limit:CF}),{label:`audit session`});if(n.stale){r();return}if(!n.ok)throw Error(`audit session fetch failed`);let i=jC.auditThreadChildren[t],a=this.auditLog.entries.find(e=>TP(e)===t),o=kP(i,n.data.entries,a?[a]:[e]);o.entries=jC.upsertAuditRecords(o.entries,`audit.thread`),jC.auditThreadChildren={...jC.auditThreadChildren,[t]:{loading:!1,loaded:!0,entries:o.entries,total:Number(n.data.total||0)+o.preservedCount}}}catch(e){console.error(`Failed to fetch audit session entries:`,e),r()}}clearAuditFilters(){this.auditSearch=``,this.auditMethod=``,this.auditStatusCode=``,this.auditStream=``,this.fetchAuditLog(!0)}auditLogNextPage(){this.auditLog.offset+this.auditLog.limit0&&(this.auditLog.offset=Math.max(0,this.auditLog.offset-this.auditLog.limit),this.fetchAuditLog(!1))}isAuditEntryExpanded(e){let t=MP(e);return t?!!(this.auditExpandedEntries&&this.auditExpandedEntries[t]):!1}toggleAuditEntryExpanded(e){this.auditExpandedEntries=zP(this.auditExpandedEntries,e);let t=this.isAuditEntryExpanded(e);return t&&typeof jC.fetchAuditEntryDetail==`function`&&jC.fetchAuditEntryDetail(e),t}expandAuditEntry(e){this.isAuditEntryExpanded(e)||this.toggleAuditEntryExpanded(e)}};jC.fetchAuditLog=e=>TF.fetchAuditLog(e),jC.isAuditEntryExpanded=e=>TF.isAuditEntryExpanded(e);var EF=R(`
        `);function DF(e,t){E(t,!0);let n=bw(()=>TF.fetchAuditLog(!0));An(()=>n.cancel);var r=EF(),i=M(r);yw(M(i),{id:`audit-filter-search`,placeholder:`Search by request ID, model, provider, path, user path, or error...`,label:`Search by request ID, model, provider, path, user path, or error`,get oninput(){return n},get value(){return TF.auditSearch},set value(e){TF.auditSearch=e}}),T(i);var a=P(i,2),o=M(a),s=M(o);s.value=s.__value=``;var c=P(s);c.value=c.__value=`GET`;var l=P(c);l.value=l.__value=`POST`;var u=P(l);u.value=u.__value=`PUT`;var d=P(u);d.value=d.__value=`PATCH`;var f=P(d);f.value=f.__value=`DELETE`,T(o);var p=P(o,2),m=M(p);m.value=m.__value=``;var h=P(m);h.value=h.__value=`200`;var g=P(h);g.value=g.__value=`201`;var _=P(g);_.value=_.__value=`400`;var v=P(_);v.value=v.__value=`401`;var y=P(v);y.value=y.__value=`403`;var b=P(y);b.value=b.__value=`404`;var x=P(b);x.value=x.__value=`429`;var S=P(x);S.value=S.__value=`500`;var C=P(S);C.value=C.__value=`502`;var w=P(C);w.value=w.__value=`503`;var ee=P(w);ee.value=ee.__value=`504`,T(p);var te=P(p,2),ne=M(te);ne.value=ne.__value=``;var re=P(ne);re.value=re.__value=`true`;var ie=P(re);ie.value=ie.__value=`false`,T(te);var ae=P(te,2);K(M(ae),{get icon(){return Fo},class:`table-icon-svg`}),Ue(2),T(ae),T(a),T(r),L(`change`,o,()=>TF.fetchAuditLog(!0)),Gi(o,()=>TF.auditMethod,e=>TF.auditMethod=e),L(`change`,p,()=>TF.fetchAuditLog(!0)),Gi(p,()=>TF.auditStatusCode,e=>TF.auditStatusCode=e),L(`change`,te,()=>TF.fetchAuditLog(!0)),Gi(te,()=>TF.auditStream,e=>TF.auditStream=e),L(`click`,ae,()=>TF.clearAuditFilters()),z(e,r),D()}Hr([`change`,`click`]);var OF=R(`Live stream connecting…`),kF=R(` `),AF=R(`Live`),jF=R(` `);function MF(e,t){E(t,!0);let n=O(()=>jC.auditLivePauseReason()),r=O(()=>jC.liveLogsStreaming&&!I(n));var i=Qr(),a=N(i),o=e=>{var t=jF(),i=M(t);let a;var o=P(i,2),s=e=>{z(e,OF())},c=e=>{var t=kF(),r=M(t,!0);T(t),F(e=>B(r,e),[()=>yC(I(n))]),z(e,t)},l=e=>{z(e,AF())};V(o,e=>{jC.liveLogsStreaming?I(n)?e(c,1):e(l,-1):e(s)}),T(t),F(()=>a=U(i,1,`live-dot svelte-tve6yv`,null,a,{"is-streaming":I(r)})),z(e,t)},s=O(()=>xs.liveLogsVisible());V(a,e=>{I(s)&&e(o)}),z(e,i),D()}var NF=R(` `),PF=R(``);function FF(e,t){E(t,!0);let n=O(()=>[{key:`provider`,text:hc(t.entry)||`-`},{key:`model`,text:t.entry.requested_model||t.entry.model||`-`,mono:!0},{key:`user_path`,text:t.entry.user_path,mono:!0},{key:`request_id`,text:`request_id: `+(t.entry.request_id||`-`),mono:!0},{key:`ip`,text:t.entry.client_ip&&`ip: `+t.entry.client_ip,mono:!0},{key:`auth_key_id`,text:t.entry.auth_key_id&&`auth_key_id: `+t.entry.auth_key_id,mono:!0},{key:`alias`,text:t.entry.alias_used&&`alias`,class:`audit-alias-badge`},{key:`resolved`,text:t.entry.alias_used&&t.entry.resolved_model&&`resolved: `+vc(t.entry),mono:!0},{key:`failover`,text:WP(t.entry)&&`failover: `+WP(t.entry),mono:!0},{key:`stream`,text:t.entry.stream&&`stream`},{key:`error_type`,text:t.entry.error_type}].filter(e=>!!e.text));var r=PF(),i=P(M(r),2);H(i,21,()=>I(n),e=>e.key,(e,t)=>{var n=NF(),r=M(n,!0);T(n),F(()=>{U(n,1,Fi([`provider-badge`,I(t).class,{mono:I(t).mono}]),`svelte-hyopt0`),B(r,I(t).text)}),z(e,n)}),T(i),T(r),z(e,r),D()}var IF=R(``),LF=R(` `);function RF(e,t){E(t,!0);let n=O(()=>ZP(t.entry)),r=O(()=>I(n).length>0?$P(t.entry):``),i=O(()=>I(n).length>0?QP(t.entry):``);var a=Qr(),o=N(a),s=e=>{var a=LF(),o=M(a);H(o,21,()=>I(n),e=>t.entry.id+`-pip-`+e.seq,(e,t)=>{var n=IF();let r;F(e=>{r=U(n,1,`audit-attempt-pip svelte-1eu22xn`,null,r,{"audit-attempt-success":!!(I(t)&&I(t).success),"audit-attempt-error":!(I(t)&&I(t).success)}),W(n,`title`,e)},[()=>eF(I(t))]),z(e,n)}),T(o);var s=P(o,2),c=M(s,!0);T(s),T(a),F(()=>{W(a,`title`,I(r)),W(a,`aria-label`,I(r)),B(c,I(i))}),z(e,a)};V(o,e=>{I(n).length>0&&e(s)}),z(e,a),D()}var zF=new Set([`instructions`,`messages`,`input`,`previous_response_id`,`choices`,`output`]);function BF(e){if(!e||typeof e!=`object`)return``;let t=String(e.type||``).toLowerCase();if(t===`image`||t===`image_url`||t===`input_image`||t===`output_image`)return`[Image]`;if(t===`audio`||t===`input_audio`||t===`output_audio`)return`[Audio]`;if(t===`file`||t===`input_file`||t===`output_file`){let t=String(e.filename||e.name||``).trim();return t?`[File: `+t+`]`:`[File]`}return typeof e.refusal==`string`?e.refusal:``}function VF(e){if(e==null)return``;if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:!e||typeof e!=`object`?``:typeof e.text==`string`?e.text:typeof e.output_text==`string`?e.output_text:BF(e)).filter(Boolean).join(` +`).trim();if(typeof e==`object`){if(typeof e.text==`string`)return e.text.trim();try{return JSON.stringify(e,null,2)}catch{return``}}return String(e).trim()}function HF(e){return!e||typeof e!=`object`?``:VF(e.content)||(typeof e.refusal==`string`?e.refusal.trim():``)}function UF(e){if(e==null)return[];if(typeof e==`string`)return e?[e]:[];if(Array.isArray(e))return e.flatMap(e=>typeof e==`string`?e?[e]:[]:!e||typeof e!=`object`?[]:typeof e.text==`string`?e.text?[e.text]:[]:typeof e.output_text==`string`&&e.output_text?[e.output_text]:[]);if(typeof e==`object`)return typeof e.text==`string`&&e.text?[e.text]:[];let t=String(e);return t?[t]:[]}function WF(e){let t=Number(e&&e.usage&&e.usage.estimated_cached_characters||0);return Number.isFinite(t)&&t>0?Math.floor(t):0}function GF(e,t){if(!e)return null;let n=(Array.isArray(t)?t:[]).reduce((e,t)=>e+String(t||``).length,0),r=Math.min(String(e).length,n);return r>0?{total:r}:null}function KF(e){return{characters:(Array.isArray(e)?e:[]).map(e=>(String(e&&e.name||``)+`(`+qI(e)+`)`).length)}}function qF(e,t){let n=Math.max(0,Number(t||0));return e.map(e=>{if(!e||e.role===`error`)return e;let t=Math.max(0,Number(e._promptTextCharacters||0)),r=Math.min(n,t);n-=r;let i=0;(Array.isArray(e._toolPromptCharacters)?e._toolPromptCharacters:[]).forEach(e=>{let t=Math.max(0,Number(e||0)),r=Math.min(n,t);n-=r,i+=r});let a=t+(e._toolPromptCharacters||[]).reduce((e,t)=>e+Math.max(0,Number(t||0)),0);return{...e,promptCacheRatio:a>0?(r+i)/a:0}})}function JF(e){if(e==null)return[];if(typeof e==`string`){let t=e.trim();return t?[{role:`user`,text:t}]:[]}if(!Array.isArray(e)){let t=VF(e);return t?[{role:`user`,text:t}]:[]}return e.map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e.role||`user`).toLowerCase(),n=VF(e.content);return n?{role:t,text:n}:null}).filter(Boolean)}function YF(e){return!e||typeof e!=`object`?``:Array.isArray(e.content)?e.content.map(e=>e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` +`).trim():VF(e.content)}function XF(e){if(!e||typeof e!=`object`)return[];let t=[];return t.push(...UF(e.instructions)),Array.isArray(e.messages)&&e.messages.forEach(e=>{!e||typeof e!=`object`||t.push(...UF(e.content))}),typeof e.input==`string`?t.push(e.input):Array.isArray(e.input)?e.input.forEach(e=>{!e||typeof e!=`object`||(t.push(...UF(e.content)),typeof e.text==`string`&&t.push(e.text))}):e.input&&typeof e.input==`object`&&(t.push(...UF(e.input.content)),typeof e.input.text==`string`&&t.push(e.input.text)),t.map(e=>String(e||``)).filter(e=>e.length>0)}var ZF=e=>VF(e);function QF(e){if(!e||!e.data)return``;let t=pP(e.data.response_body,0,ZF);if(t)return t;let n=e.data.error_message;if(n==null)return``;if(typeof n==`string`){let e=n.trim();return e?pP(dP(e),0,ZF)||e:``}return pP(n,0,ZF)||VF(n)}function $F(e){return Array.isArray(e)?e.some(e=>!e||typeof e!=`object`?!1:e.type===`message`||e.role===`assistant`||e.role===`user`||e.role===`system`?!0:Array.isArray(e.content)?e.content.some(e=>!e||typeof e!=`object`?!1:typeof e.text==`string`||e.type===`output_text`||e.type===`input_text`):!1):!1}function eI(e){if(!e)return!1;let t=String(e).toLowerCase();return t===`/v1/embeddings`||t===`/v1/embeddings/`||t.startsWith(`/v1/embeddings?`)||t.startsWith(`/v1/embeddings/`)}function tI(e){return e?!!rI(e):!1}function nI(e){let t=String(e||``).trim().split(`?`)[0].replace(/\/+$/,``).toLowerCase();return t.startsWith(`/v1/`)?t.slice(3):t}function rI(e){switch(nI(e)){case`/chat/completions`:return`chat`;case`/responses`:return`responses`;case`/messages`:return`messages`;default:return``}}function iI(e){if(!e||typeof e!=`object`)return null;try{return JSON.parse(JSON.stringify(e))}catch{return null}}function aI(e,t){if(!t||typeof t!=`object`)return;let n=e[e.length-1];try{if(n&&JSON.stringify(n)===JSON.stringify(t))return}catch{}e.push(t)}function oI(e){let t=rI(e&&e.path),n=e&&e.data&&e.data.request_body;return!t||!n||typeof n!=`object`?!1:t!==`responses`||(e.data&&e.data.response_body&&typeof e.data.response_body.id==`string`?e.data.response_body.id.trim():``)!==``||UI(n)!==``}function sI(e,t){let n=String(t||``).trim(),r=rI(e&&e.path),i=iI(e&&e.data&&e.data.request_body);if(!n||!r||!i)return null;let a=e&&e.data?e.data.response_body:null;if(r===`responses`){let e=a&&typeof a.id==`string`?a.id.trim():``,t=UI(i);return!e&&!t?null:(i.input=n,e&&!t?i.previous_response_id=e:delete i.previous_response_id,i)}let o=Array.isArray(i.messages)?i.messages:[];if(r===`chat`){let e=a&&Array.isArray(a.choices)?a.choices[0]:null;e&&e.message&&aI(o,iI(e.message)),o.push({role:`user`,content:n})}else a&&a.content!==void 0&&aI(o,{role:String(a.role||`assistant`),content:iI(a.content)||a.content}),o.push({role:`user`,content:n});return i.messages=o,i}var cI=new Set(`authorization.proxy-authorization.cookie.content-type.content-length.host.accept.connection.accept-encoding.content-encoding.transfer-encoding.user-agent.date.expect.upgrade.via.te.trailer.keep-alive.origin.referer.forwarded.x-real-ip.traceparent.tracestate.x-request-id.idempotency-key.x-idempotency-key.x-gomodel-timezone.x-gomodel-interaction-parent`.split(`.`));function lI(e,t,n=``){let r=e&&e.data&&e.data.request_headers,i={};return r&&typeof r==`object`&&Object.keys(r).forEach(e=>{let t=String(e).toLowerCase(),n=String(r[e]==null?``:r[e]);!e||!n||n===`[REDACTED]`||cI.has(t)||t.startsWith(`sec-`)||t.startsWith(`cf-`)||t.startsWith(`x-forwarded-`)||(i[e]=n)}),i[`X-GoModel-Interaction-Parent`]=String(t||e&&e.id||``).trim(),String(n||``).trim()&&(i[`X-Request-ID`]=String(n).trim()),i}function uI(e,t){let n=String(t||``).trim();return!n||!Array.isArray(e)?null:e.find(e=>String(e&&e.request_id||``).trim()===n)||null}function dI(e,t,n,r,i){let a=Array.isArray(e)?e:[],o=String(i&&i.id||``).trim(),s=String(i&&i.request_id||``).trim(),c=String(i&&i.session_id||``).trim(),l=String(r||``).trim(),u=fI(i),d=a.some(e=>o&&String(e&&e.id||``).trim()===o||s&&String(e&&e.request_id||``).trim()===s),f=!!l&&s===l,p=!!n&&c===String(n).trim(),m=!!u&&(u===String(t||``).trim()||a.some(e=>String(e&&e.id||``).trim()===u)),h=d||f||!l&&(p||m);return{accepted:h,submittedChild:f,followUpRequestID:h&&f&&o?``:l}}function fI(e){let t=e&&e.data&&e.data.request_headers;if(!t||typeof t!=`object`)return``;let n=Object.keys(t).find(e=>e.toLowerCase()===`x-gomodel-interaction-parent`);return n?String(t[n]||``).trim():``}function pI(e,t){return!Array.isArray(e)||!t?null:e.find(e=>String(e&&e.id||``)===String(t))||null}function mI(e){return!Array.isArray(e)||e.length===0?null:e.reduce((e,t)=>e?WI(t,e)>=0?t:e:t,null)}function hI(e,t){let n=new Set(Array.isArray(t)?t.map(String):[]);return mI((Array.isArray(e)?e:[]).filter(e=>{let t=String(e&&e.id||``);return n.has(t)&&e&&e.data&&e.data.request_body!=null}))}function gI(e,t){let n=mI(e);return!!n&&String(n.id||``)===String(t||``)}function _I(e,t,n){return String(e||``).trim()===`audit.flushed`&&String(t||``).trim()!==``&&String(t||``).trim()===String(n||``).trim()}function vI(e,t){let n=Array.isArray(e)?e.filter(Boolean).map(String):[];return(Array.isArray(t)?t:[]).forEach(e=>{let t=String(e&&(e.id||e.request_id)||``).trim();t&&!n.includes(t)&&n.push(t)}),n}function yI(e){if(e&&e.conversation_payload)return!0;let t=e&&e.data?e.data.request_body:null,n=e&&e.data?e.data.response_body:null,r=t&&(Array.isArray(t.messages)||t.input!==void 0||typeof t.instructions==`string`||typeof t.previous_response_id==`string`),i=n&&(Array.isArray(n.choices)||$F(n.output));return!!(r||i)}function bI(e){return!e||eI(e.path)?!1:tI(e.path)||yI(e)}function xI(e){let t=0,n=!1,r=!1,i=String(e||``);for(let e=0;e0&&a+1`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function TI(e){return!!(e&&typeof e==`object`&&e.__audio__===!0)}function EI(e){let t=Number(e||0);if(!Number.isFinite(t)||t<=0)return`0 B`;let n=[`B`,`KB`,`MB`,`GB`],r=0,i=t;for(;i>=1024&&r`
        `+wI(t)+``+wI(OI(e[t]))+`
        `);return t.length?``:``}function AI(e){let t=DI(e.content_type),n=wI(t+` · `+EI(e.bytes)),r=kI(e.meta);if(e.stored&&e.encoding===`base64`&&e.data){let i=String(e.data).replace(/[^A-Za-z0-9+/=]/g,``);return`
        `+n+`
        `+r+`
        `}let i=e.too_large?`Audio too large to store.`:`Audio not logged. Set LOGGING_LOG_AUDIO_BODIES=true to capture playable audio.`;return`
        `+n+`
        `+wI(i)+`
        `+r+`
        `}function jI(e){try{return JSON.stringify(String(e)).slice(1,-1)}catch{return``}}function MI(e){if(!e||typeof e!=`object`)return null;let t=Number(e.characters||0);if(!Number.isFinite(t)||t<=0)return null;let n=Array.isArray(e.segments)?e.segments.map(e=>String(e||``)).filter(Boolean):[];return n.length===0?null:{remaining:Math.floor(t),segments:n,segmentIndex:0}}function NI(e,t){if(!t||t.remaining<=0||t.segmentIndex>=t.segments.length)return wI(e);let n=``,r=0,i=0;for(;t.remaining>0&&t.segmentIndex`+wI(l)+``,r=s+l.length,i=s+o.length,t.remaining-=c,c>=a.length){t.segmentIndex++;continue}break}return n?n+wI(e.slice(r)):wI(e)}function PI(e,t,n){let r=n&&typeof n.formatJSON==`function`?n.formatJSON:e=>String(e),i=n&&typeof n.canShowConversation==`function`?n.canShowConversation:()=>!1,a=MI(n&&n.promptCacheHighlight),o=r(t);if(!o||o===`Not captured`)return wI(o);if(!i(e))return o.split(` +`).map(e=>NI(e,a)).join(` +`);let s=o.split(` +`),c=[],l=0;for(;lNI(e,a)).join(` +`);c.push(``+o+``),l=r+1;continue}c.push(NI(e,a)),l++}return c.join(` +`)}function FI(e){let t=String(e||``).toLowerCase();return t===`system`||t===`developer`?{role:`system`,label:`System Prompt`,className:`role-system`}:t===`assistant`?{role:`assistant`,label:`Agent`,className:`role-assistant`}:t===`error`?{role:`error`,label:`Error`,className:`role-error`}:t===`function_call`?{role:`function_call`,label:`Function Call`,className:`role-function-call`}:t===`function_result`?{role:`function_result`,label:`Function Result`,className:`role-function-result`}:{role:`user`,label:`User`,className:`role-user`}}function II(e,t,{timestamp:n,entryID:r,isAnchor:i,isAfterAnchor:a,index:o,toolCalls:s,functionName:c,functionCallID:l,promptCache:u,toolPromptCache:d}){let f=FI(e),p=u&&Number.isFinite(Number(u.total))?Math.max(0,Number(u.total)):String(t||``).length,m=d&&Array.isArray(d.characters)?d.characters:KF(s).characters;return{uid:r+`-`+o,entryID:r,timestamp:n,text:t,role:f.role,roleLabel:f.label,roleClass:f.className,isAnchor:i,isAfterAnchor:a,toolCalls:Array.isArray(s)&&s.length>0?s:null,functionName:c||``,functionCallID:l||``,promptCacheRatio:0,_promptTextCharacters:p,_toolPromptCharacters:m}}function LI(e){return Array.isArray(e)?e.map(e=>{if(!e)return null;let t=e.function||e,n=``;return t.arguments===void 0?e.arguments===void 0?t.input===void 0?e.input!==void 0&&(n=e.input):n=t.input:n=e.arguments:n=t.arguments,{name:t.name||e.name||``,arguments:n,id:e.id||e.call_id||``}}).filter(Boolean):[]}function RI(e){return Array.isArray(e)?LI(e.filter(e=>e&&typeof e==`object`&&e.type===`tool_use`)):[]}function zI(e){return Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`tool_result`).map(e=>({id:e.tool_use_id||e.call_id||``,text:VF(e.content)})):[]}function BI(e,t,n){if(t&&Array.isArray(t.messages)&&t.messages.forEach(t=>{t&&[...Array.isArray(t.tool_calls)?t.tool_calls:[],...Array.isArray(t.content)?t.content.filter(e=>e&&e.type===`tool_use`):[]].forEach(t=>{if(!t)return;let n=t.id||t.call_id||``,r=(t.function||t).name||t.name||``;n&&r&&(e[n]=r)})}),t&&Array.isArray(t.input)&&t.input.forEach(t=>{if(!t||typeof t!=`object`||t.type!==`function_call`)return;let n=t.id||t.call_id||``,r=t.name||``;n&&r&&(e[n]=r)}),n&&Array.isArray(n.choices)){let t=n.choices[0];t&&t.message&&Array.isArray(t.message.tool_calls)&&t.message.tool_calls.forEach(t=>{if(!t)return;let n=t.id||``,r=(t.function||t).name||t.name||``;n&&r&&(e[n]=r)})}n&&Array.isArray(n.output)&&n.output.forEach(t=>{if(!t||t.type!==`function_call`)return;let n=t.id||t.call_id||``,r=t.name||``;n&&r&&(e[n]=r)}),n&&Array.isArray(n.content)&&n.content.forEach(t=>{if(!t||t.type!==`tool_use`)return;let n=t.id||t.call_id||``,r=t.name||``;n&&r&&(e[n]=r)})}function VI(e){return Array.isArray(e)?`[`+e.map(VI).join(`,`)+`]`:e&&typeof e==`object`?`{`+Object.keys(e).sort().map(t=>JSON.stringify(t)+`:`+VI(e[t])).join(`,`)+`}`:JSON.stringify(e)}function HI(e){if(!e||typeof e!=`object`)return null;let t=[];if(e.system!==void 0&&t.push({system:e.system}),e.instructions!==void 0&&t.push({instructions:e.instructions}),Array.isArray(e.messages))t.push(...e.messages);else if(Array.isArray(e.input)&&e.previous_response_id==null&&e.conversation==null)t.push(...e.input);else return null;return t.map(VI)}function UI(e){let t=e&&e.conversation;return typeof t==`string`?t.trim():t&&typeof t.id==`string`?t.id.trim():``}function WI(e,t){let n=new Date(e&&e.timestamp).getTime(),r=new Date(t&&t.timestamp).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r)return n-r;let i=String(e&&e.timestamp||``).localeCompare(String(t&&t.timestamp||``));if(i!==0)return i;let a=String(e&&e.id||``),o=String(t&&t.id||``);return ao)}function GI(e,t){if(!Array.isArray(e)||e.length===0)return{messages:[],entryIDs:[]};let n=[...e].sort(WI),r={};n.forEach(e=>{let t=e.data&&e.data.request_body?e.data.request_body:null,n=e.data&&e.data.response_body?e.data.response_body:null;BI(r,t,n)});let i=[],a=new Set,o=new Set,s=new Set,c=[],l=null,u=0,d=n.findIndex(e=>e.id===t),f=e=>JSON.stringify({role:e.role,text:e.text,toolCalls:e.toolCalls,functionName:e.functionName,functionCallID:e.functionCallID});return n.forEach((e,n)=>{let p=e.id===t,m=d>=0&&n>d,h=e.timestamp,g=e.data&&e.data.request_body?e.data.request_body:null,_=e.data&&e.data.response_body?e.data.response_body:null,v=i.length,y=(e,t)=>GF(e,t),b=e=>KF(e),x=(t,n,{toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s}={})=>II(t,n,{timestamp:h,entryID:e.id,isAnchor:p,isAfterAnchor:m,index:++u,toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s});if(g&&g.system!==void 0){let e=VF(g.system);e&&i.push(x(`system`,e,{promptCache:y(e,UF(g.system))}))}if(g&&g.instructions!==void 0){let e=VF(g.instructions);e&&i.push(x(`system`,e,{promptCache:y(e,UF(g.instructions))}))}g&&Array.isArray(g.messages)&&g.messages.forEach(e=>{if(!e)return;let t=(e.role||`user`).toLowerCase();if(t===`tool`){let t=VF(e.content),n=e.name||r[e.tool_call_id]||``;t&&i.push(x(`function_result`,t,{functionName:n,functionCallID:e.tool_call_id||``,promptCache:y(t,UF(e.content))}));return}if(t===`assistant`){let n=HF(e),r=[...LI(e.tool_calls),...RI(e.content)];if(n||r.length>0){let a=y(n,UF(e.content));i.push(x(t,n,{toolCalls:r,promptCache:a,toolPromptCache:b(r)}))}return}zI(e.content).forEach(e=>{e.text&&i.push(x(`function_result`,e.text,{functionName:r[e.id]||``,functionCallID:e.id,promptCache:y(e.text,[e.text])}))});let n=HF(e);n&&i.push(x(t,n,{promptCache:y(n,UF(e.content))}))}),g&&g.input!==void 0&&(Array.isArray(g.input)?g.input.forEach(e=>{if(!(!e||typeof e!=`object`)){if(e.type===`function_call_output`){let t=typeof e.output==`string`?e.output:VF(e.output);t&&i.push(x(`function_result`,t,{functionName:r[e.call_id]||e.name||``,functionCallID:e.call_id||``,promptCache:y(t,[t])}))}else if(e.type===`function_call`){let t=LI([e]);i.push(x(`function_call`,``,{toolCalls:t,toolPromptCache:b(t)}))}else if(e.role){let t=String(e.role).toLowerCase(),n=VF(e.content);n&&i.push(x(t,n,{promptCache:y(n,UF(e.content))}))}}}):JF(g.input).forEach(e=>{if(!e.text)return;let t=[];typeof g.input==`string`?t=[g.input]:g.input&&typeof g.input==`object`&&(t=UF(g.input.content),typeof g.input.text==`string`&&t.push(g.input.text)),i.push(x(e.role,e.text,{promptCache:y(e.text,t)}))}));let S=i.splice(v),C=S.map(f),w=HI(g),ee=w!==null,te=fI(e),ne=!!te&&a.has(te),re=String(g&&g.previous_response_id||``).trim(),ie=UI(g),ae=ne||!!re&&o.has(re)||!!ie&&s.has(ie);if(m){let e=ee&&l&&l.length>0&&l.every((e,t)=>w[t]===e);if(ee&&!e&&!ne||!ee&&!ae)return}p&&ee&&(l=[...w]);let oe=String(e.id||``).trim();p&&(a.clear(),o.clear(),s.clear()),oe&&(p||m)&&a.add(oe),ie&&s.add(ie);let se=0;for(;se0;){let t=c.slice(-e),n=C.slice(0,e);if(t.every((e,t)=>e===n[t]))break;e--}i.push(...S.slice(e)),c.push(...C.slice(e))}if(g&&i.splice(0,i.length,...qF(i,WF(e))),_&&Array.isArray(_.choices)){let e=_.choices[0];if(e&&e.message){let t=(e.message.role||`assistant`).toLowerCase(),n=HF(e.message),r=LI(e.message.tool_calls);if(n||r.length>0){let e=x(t,n,{toolCalls:r});i.push(e),c.push(f(e))}}}if(_&&Array.isArray(_.output)&&_.output.forEach(e=>{if(!e)return;if(e.type===`function_call`){let t=x(`function_call`,``,{toolCalls:LI([e])});i.push(t),c.push(f(t));return}let t=(e.role||`assistant`).toLowerCase(),n=YF(e);if(n){let e=x(t,n);i.push(e),c.push(f(e))}}),_&&_.content!==void 0&&!Array.isArray(_.choices)&&!Array.isArray(_.output)){let e=String(_.role||`assistant`).toLowerCase(),t=VF(_.content),n=RI(_.content);if(t||n.length>0){let r=x(e,t,{toolCalls:n});i.push(r),c.push(f(r))}}let ce=QF(e);ce&&i.push(x(`error`,ce));let le=String(_&&_.id||``).trim();le&&o.add(le)}),{messages:i,entryIDs:[...a]}}function KI(e){return e.role===`function_call`?(e.toolCalls||[]).map(function(e){return e.name+`(`+qI(e)+`)`}).join(` + +`):e.text||``}function qI(e){let t=e&&e.arguments!==void 0?e.arguments:``;if(typeof t!=`string`)try{return JSON.stringify(t,null,2)}catch{return String(t)}try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var JI=600*1e3,YI=15*1e3,XI=250,ZI=class{#e=k(!1);get conversationOpen(){return I(this.#e)}set conversationOpen(e){A(this.#e,e,!0)}#t=k(!1);get conversationLoading(){return I(this.#t)}set conversationLoading(e){A(this.#t,e,!0)}#n=k(``);get conversationError(){return I(this.#n)}set conversationError(e){A(this.#n,e,!0)}#r=k(``);get conversationAnchorID(){return I(this.#r)}set conversationAnchorID(e){A(this.#r,e,!0)}#i=k(j([]));get conversationEntryIDs(){return I(this.#i)}set conversationEntryIDs(e){A(this.#i,e,!0)}#a=k(``);get conversationSessionID(){return I(this.#a)}set conversationSessionID(e){A(this.#a,e,!0)}#o=k(!1);get conversationTruncated(){return I(this.#o)}set conversationTruncated(e){A(this.#o,e,!0)}#s=k(!1);get conversationFollowLatest(){return I(this.#s)}set conversationFollowLatest(e){A(this.#s,e,!0)}#c=k(``);get conversationOpenedFromID(){return I(this.#c)}set conversationOpenedFromID(e){A(this.#c,e,!0)}#l=k(``);get followUpText(){return I(this.#l)}set followUpText(e){A(this.#l,e,!0)}#u=k(!1);get followUpSending(){return I(this.#u)}set followUpSending(e){A(this.#u,e,!0)}#d=k(``);get followUpError(){return I(this.#d)}set followUpError(e){A(this.#d,e,!0)}followUpRequestID=``;followUpAbort=null;conversationRequestToken=0;conversationReturnFocusEl=null;bodyPointerStart=null;#f=k(null);get conversationDialogEl(){return I(this.#f)}set conversationDialogEl(e){A(this.#f,e,!0)}#p=k(null);get conversationCloseBtnEl(){return I(this.#p)}set conversationCloseBtnEl(e){A(this.#p,e,!0)}#m=k(null);get conversationThreadEl(){return I(this.#m)}set conversationThreadEl(e){A(this.#m,e,!0)}get conversationEntries(){return(this.conversationEntryIDs||[]).map(e=>jC.auditRecord(e)).filter(Boolean)}#h=O(()=>GI(this.conversationEntries,this.conversationAnchorID));get conversationView(){return I(this.#h)}set conversationView(e){A(this.#h,e)}get conversationMessages(){return this.conversationView.messages}get conversationBranchEntryIDs(){return this.conversationView.entryIDs}_setConversationEntryIDs(e){this.conversationEntryIDs=[...new Set((Array.isArray(e)?e:[]).filter(Boolean))],jC.pinAuditRecords(this.conversationEntryIDs)}canShowConversation(e){return bI(e)}startBodyInteraction(e){this.bodyPointerStart={x:e.clientX,y:e.clientY}}_isBodyDrag(e){if(!this.bodyPointerStart)return!1;let t=Math.abs(e.clientX-this.bodyPointerStart.x),n=Math.abs(e.clientY-this.bodyPointerStart.y);return t>4||n>4}_hasActiveSelection(){let e=window.getSelection?window.getSelection():null;return!e||e.isCollapsed?!1:String(e.toString()||``).trim().length>0}handleBodyConversationClick(e,t){let n=this._isBodyDrag(e);if(this.bodyPointerStart=null,n||this._hasActiveSelection()||!this.canShowConversation(t))return;let r=e.target&&e.target.closest?e.target.closest(`[data-conversation-trigger="1"]`):null;r&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,r))}handleErrorConversationClick(e,t){let n=this._isBodyDrag(e);this.bodyPointerStart=null,!n&&(this._hasActiveSelection()||this.canShowConversation(t)&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,e.currentTarget)))}formatJSON(e){return ic(e)}renderBodyWithConversationHighlights(e,t,n){return PI(e,t,{formatJSON:e=>this.formatJSON(e),canShowConversation:e=>this.canShowConversation(e),promptCacheHighlight:n&&n.promptCacheHighlight})}async openConversation(e,t){if(!e||!e.id||!this.canShowConversation(e))return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null;t instanceof HTMLElement?this.conversationReturnFocusEl=t:n&&n!==document.body&&(this.conversationReturnFocusEl=n);let r=++this.conversationRequestToken;if(this.conversationOpen=!0,this.conversationError=``,this.conversationAnchorID=e.id,this.conversationOpenedFromID=e.id,this.conversationSessionID=String(e.session_id||``).trim(),this._setConversationEntryIDs([]),this.conversationTruncated=!1,this.conversationFollowLatest=!1,this.followUpText=``,this.followUpError=``,this.followUpRequestID=``,requestAnimationFrame(()=>this._focusConversationDrawer()),this._conversationEntryLivePending(e)){this.conversationFollowLatest=!0,this.conversationLoading=!1,this._addConversationRecord(jC.upsertAuditRecord(e,`conversation.live`));return}this.conversationLoading=!0,await this.fetchConversation(e.id,r,!0,!0)}_conversationEntryLivePending(e){return typeof jC.auditEntryLiveDetailPending==`function`&&jC.auditEntryLiveDetailPending(e)}_applyConversationView(){let e=this.conversationEntries,t=GI(e,this.conversationAnchorID);if(this.conversationFollowLatest){let n=hI(e,t.entryIDs);n&&n.id&&String(n.id)!==this.conversationAnchorID&&(this.conversationAnchorID=String(n.id))}}handleAuditRecordChange(e,t){if(!this.conversationOpen||!e)return;let n=String(e.id||``).trim(),r=dI(this.conversationEntries,this.conversationAnchorID,this.conversationSessionID,this.followUpRequestID,e);if(r.accepted&&(this.followUpRequestID=r.followUpRequestID,n&&r.submittedChild&&(this.conversationAnchorID=n,this.conversationFollowLatest=!0),this._addConversationRecord(e),_I(String(t||e._live_state||``).trim(),n,this.conversationAnchorID))){this.conversationMessages.length===0&&(this.conversationLoading=!0);let e=++this.conversationRequestToken;this.fetchConversation(n,e,!1)}}_addConversationRecord(e){let t=wC(e);t&&!this.conversationEntryIDs.includes(t)&&this._setConversationEntryIDs([...this.conversationEntryIDs,t]),!this.conversationSessionID&&e.session_id&&(this.conversationSessionID=String(e.session_id).trim()),this._applyConversationView(),this.conversationFollowLatest&&this._scheduleLatestScroll()}conversationLiveWaiting(){if(!this.conversationOpen)return!1;let e=new Set(this.conversationBranchEntryIDs||[]);return(this.conversationEntries||[]).some(t=>e.has(String(t&&t.id||``))&&t._live&&(typeof jC.liveAuditStateSettled!=`function`||!jC.liveAuditStateSettled(t._live_state)))}conversationLiveStatusText(){return(this.conversationMessages||[]).length>0?`Model is responding…`:`Waiting for request data…`}closeConversation(){this.followUpAbort&&this.followUpAbort.abort(),this.conversationOpen=!1,this.conversationRequestToken++,this.conversationSessionID=``,this._setConversationEntryIDs([]),this.conversationFollowLatest=!1,this.conversationOpenedFromID=``,this.followUpRequestID=``,this.followUpSending=!1;let e=this.conversationReturnFocusEl;this.conversationReturnFocusEl=null,e&&typeof e.focus==`function`&&document.contains(e)&&requestAnimationFrame(()=>e.focus())}_focusConversationDrawer(){if(!this.conversationOpen)return;let e=this.conversationCloseBtnEl;if(e&&typeof e.focus==`function`){e.focus();return}let t=this.conversationDialogEl;t&&typeof t.focus==`function`&&t.focus()}async fetchConversation(e,t,n=!0,r=!1){try{let i=await gs(`/admin/audit/conversation?`+(`log_id=`+encodeURIComponent(e)+`&limit=120`),{label:`audit conversation`});if(t!==this.conversationRequestToken||i.stale)return;if(!i.ok){this.conversationError=`Unable to load interactions.`;return}let a=i.data||{},o=a.anchor_id||e,s=Array.isArray(a.entries)?a.entries:[],c=jC.upsertAuditRecords(s,`conversation.hydrated`),l=vI(this.conversationEntryIDs,c);l.length>this.conversationEntryIDs.length&&this._setConversationEntryIDs(l),r&&(this.conversationFollowLatest=gI(c,o)),this.conversationAnchorID=o;let u=this.conversationEntries.find(e=>e.id===this.conversationAnchorID);u&&u.session_id&&(this.conversationSessionID=String(u.session_id).trim()),this.conversationTruncated=!!a.truncated,this._applyConversationView(),this.conversationFollowLatest?this._scheduleLatestScroll():n&&this._scheduleAnchorScroll()}catch(e){if(t!==this.conversationRequestToken)return;console.error(`Failed to fetch audit conversation:`,e),this.conversationError=`Failed to load interactions.`}finally{t===this.conversationRequestToken&&(this.conversationLoading=!1)}}selectedConversationEntry(){return pI(this.conversationEntries,this.conversationAnchorID)}followUpKind(){let e=this.selectedConversationEntry();return oI(e)?rI(e.path):``}canSendFollowUp(){return!!this.followUpKind()&&!!String(this.followUpText||``).trim()&&!this.followUpSending&&!this.conversationLiveWaiting()}async sendFollowUp(){if(!this.canSendFollowUp())return;let e=this.selectedConversationEntry(),t=sI(e,this.followUpText);if(!e||!t)return;let n=this.conversationAnchorID,r=$I(),i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},JI);this.followUpSending=!0,this.followUpError=``,this.followUpRequestID=r,this.followUpAbort=i;try{let a=lI(e,n,r),o=await ms(e.path,{method:`POST`,headers:a,body:JSON.stringify(t),signal:i.signal}),s=String(o.headers.get(`X-Request-ID`)||``).trim();if(s&&this.followUpRequestID&&(this.followUpRequestID=s),!o.ok){let e=`Unable to send message.`;try{let t=await o.json();e=t&&t.error&&t.error.message||e}catch{}this.followUpError=e,(this.followUpRequestID===r||this.followUpRequestID===s)&&(this.followUpRequestID=``);return}if(this.followUpText=``,await QI(o),!jC.liveLogsStreaming&&this.conversationOpen){let e=++this.conversationRequestToken;await this._selectPersistedFollowUp(n,this.followUpRequestID,e,i.signal)}}catch(e){vs(e)||i.signal.aborted?a&&this.conversationOpen&&(this.followUpError=`The request timed out.`):(console.error(`Failed to send interaction follow-up:`,e),this.followUpError=`Failed to send message.`)}finally{clearTimeout(o),this.followUpAbort===i&&(this.followUpAbort=null,this.followUpSending=!1)}}async _selectPersistedFollowUp(e,t,n,r){let i=Date.now()+YI;for(;this.conversationOpen&&n===this.conversationRequestToken&&Date.now(){let e=this.conversationThreadEl;if(!e)return;let t=e.querySelectorAll(`[data-conversation-anchor="true"]`),n=t[t.length-1];n&&typeof n.scrollIntoView==`function`&&n.scrollIntoView({block:`center`})})}_scheduleLatestScroll(){requestAnimationFrame(()=>{let e=this.conversationThreadEl;if(!e)return;let t=e.lastElementChild;t&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`end`})})}};async function QI(e){let t=e&&e.body&&typeof e.body.getReader==`function`?e.body.getReader():null;if(!t){await e.text();return}for(;!(await t.read()).done;);}function $I(){return globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`?globalThis.crypto.randomUUID():`dashboard-`+Date.now().toString(36)+`-`+Math.random().toString(36).slice(2)}function eL(e,t){return new Promise((n,r)=>{let i,a=()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))};if(i=setTimeout(()=>{t&&t.removeEventListener(`abort`,a),n()},e),t){if(t.aborted){a();return}t.addEventListener(`abort`,a,{once:!0})}})}var tL=new ZI,nL=0;Mn(()=>{An(()=>{let e=EC(jC.auditRecordChanges,nL);e.length!==0&&(nL=Number(e[e.length-1].version||0),Er(()=>{e.forEach(e=>{if(!DC(e))return;let t=jC.auditRecord(e.key);tL.handleAuditRecordChange(t,e.eventType)})}))})});var rL=R(``),iL=R(` `),aL=R(``),oL=R(`
        `);function sL(e,t){E(t,!0);let n=G(t,`thread`,3,null),r=G(t,`expanded`,3,!1),i=G(t,`onactivate`,3,null),a=O(()=>us.formatTimestamp(t.entry.timestamp)),o=O(()=>I(a)===`-`?I(a):I(a).slice(I(a).lastIndexOf(` `)+1)),s=O(()=>tL.conversationOpen&&String(tL.conversationAnchorID||``)===String(t.entry.id||``));function c(e){e.preventDefault(),i()&&i()()}function l(e){e.stopPropagation(),e.preventDefault(),n().ontoggle()}function u(e){if(e.stopPropagation(),e.preventDefault(),I(s)){tL.closeConversation();return}tL.openConversation(t.entry,e.currentTarget)}var d=oL();let f;var p=M(d),m=M(p),h=e=>{var t=rL(),r=M(t);{let e=O(()=>n().expanded?Va:Ua);K(r,{get icon(){return I(e)},class:`audit-thread-expander-svg`})}var i=P(r,2),a=M(i,!0);T(i),T(t),F(()=>{W(t,`aria-expanded`,n().expanded),W(t,`title`,`Session with `+n().count+` requests`),W(t,`aria-label`,`Session with `+n().count+` requests, `+(n().expanded?`collapse`:`expand`)),B(a,n().count)}),L(`click`,t,l),z(e,t)};V(m,e=>{n()&&e(h)});var g=P(m,2),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=M(y,!0);T(y),T(g);var x=P(g,2),S=e=>{var n=iL(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>yc(t.entry)]),z(e,n)};V(x,e=>{(t.entry.requested_model||t.entry.model)&&e(S)});var C=P(x,2),w=M(C,!0);T(C),T(p);var ee=P(p,2),te=M(ee);RF(te,{get entry(){return t.entry}});var ne=P(te,2),re=M(ne),ie=M(re,!0);T(re);var ae=P(re,2),oe=M(ae,!0);T(ae),T(ne);var se=P(ne,2),ce=M(se,!0);T(se);var le=P(se,2),ue=e=>{var t=aL();let n;var r=M(t);{let e=O(()=>I(s)?Ha:Ua);K(r,{get icon(){return I(e)},class:`audit-conversation-trigger-svg`})}T(t),F(()=>{n=U(t,1,`audit-conversation-trigger svelte-17mysgz`,null,n,{"audit-conversation-trigger-active":I(s)}),W(t,`title`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-label`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-pressed`,I(s))}),L(`click`,t,u),z(e,t)},de=O(()=>tL.canShowConversation(t.entry));V(le,e=>{I(de)&&e(ue)}),T(ee),T(d),F((e,n,i,s)=>{f=U(d,1,`audit-entry-summary svelte-17mysgz`,null,f,e),W(d,`aria-expanded`,r()),U(g,1,`audit-status-badge audit-request-badge ${n??``}`,`svelte-17mysgz`),W(g,`title`,`Status `+(t.entry.status_code||`-`)+` · `+(t.entry.method||`-`)),W(g,`aria-label`,(t.entry.status_code||`-`)+` `+(t.entry.method||`-`)),B(v,t.entry.status_code||`-`),B(b,t.entry.method||`-`),B(w,t.entry.path||`-`),W(ne,`title`,i),W(ne,`aria-label`,I(a)),B(ie,I(a)),B(oe,I(o)),B(ce,s)},[()=>({"audit-entry-summary-live-in-progress":UP(t.entry),"audit-entry-summary-has-interactions":tL.canShowConversation(t.entry)}),()=>HP(t.entry.status_code),()=>pc(t.entry.timestamp),()=>VP(t.entry.duration_ns)]),L(`click`,d,c),z(e,d),D()}Hr([`click`]);var cL=R(``);function lL(e,t){E(t,!0);let n=G(t,`label`,3,`Copy`),r=G(t,`copiedLabel`,3,`Copied`),i=G(t,`errorLabel`,3,``),a=G(t,`class`,3,`btn`),o=O(()=>t.state.error&&i()?i():t.state.copied?r():n());var s=cL();let c;var l=M(s),u=e=>{K(e,{get icon(){return Ga},width:`14`,height:`14`,"stroke-width":`2.5`})},d=e=>{K(e,{get icon(){return Ja},width:`14`,height:`14`})};V(l,e=>{t.state.copied?e(u):e(d,-1)});var f=P(l,2),p=M(f,!0);T(f),T(s),F(()=>{c=U(s,1,Fi([`copy-feedback-btn`,a()]),null,c,{"copy-feedback-btn-copied":t.state.copied}),B(p,I(o))}),L(`click`,s,e=>{e.preventDefault(),t.onclick?.(e)}),z(e,s),D()}Hr([`click`]);var uL=R(`
        Error Message
         
        `),dL=R(`
         
        `),fL=R(` `),pL=R(` streaming`),mL=R(`
        Body
        `),hL=R(`

        `),gL=R(`

        `),_L=R(`

        `),vL=R(`
        `);function yL(e,t){E(t,!0);let n=_M({logPrefix:`Failed to copy audit payload:`}),r=_M({logPrefix:`Failed to copy audit payload:`}),i=O(()=>t.pane&&t.pane.showHeaders?ic(t.pane.headers):``),a=O(()=>!t.pane||!t.pane.showBody?``:TI(t.pane.body)?AI(t.pane.body):tL.renderBodyWithConversationHighlights(t.pane.entry,t.pane.body,{promptCacheHighlight:t.pane.promptCacheHighlight})),o=O(()=>!!(t.pane&&tL.canShowConversation(t.pane.entry)));function s(e){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),tL.handleErrorConversationClick(e,t.pane.entry))}var c=vL();let l;var u=M(c),d=e=>{var n=uL(),r=P(M(n),2);let i;var a=M(r,!0);T(r),T(n),F(()=>{i=U(r,1,`audit-json audit-pane-error-message svelte-1h5puht`,null,i,{"audit-pane-clickable-preview":I(o)}),W(r,`role`,I(o)?`button`:null),W(r,`tabindex`,I(o)?0:null),B(a,t.pane.errorMessage)}),L(`mousedown`,r,e=>tL.startBodyInteraction(e)),L(`keydown`,r,s),L(`click`,r,e=>tL.handleErrorConversationClick(e,t.pane.entry)),z(e,n)};V(u,e=>{t.pane.showErrorMessage&&e(d)});var f=P(u,2),p=e=>{var n=dL(),a=M(n),o=M(a),s=M(o,!0);T(o),lL(P(o,2),{get state(){return r},label:`Copy Headers`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>r.copy(t.pane.copyHeaders,ic)}),T(a);var c=P(a,2),l=M(c,!0);T(c),T(n),F(()=>{B(s,t.pane.headersTitle||`Headers`),B(l,I(i))}),z(e,n)};V(f,e=>{t.pane.showHeaders&&e(p)});var m=P(f,2),h=e=>{var r=mL(),i=M(r),o=M(i),s=P(M(o),2),c=e=>{var n=fL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.bodyCacheRatioLabel)),z(e,n)};V(s,e=>{t.pane.bodyCacheRatioLabel&&e(c)});var l=P(s,2),u=e=>{z(e,pL())};V(l,e=>{t.pane.streaming&&e(u)}),T(o),lL(P(o,2),{get state(){return n},label:`Copy Body`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>n.copy(t.pane.copyBody,ic)}),T(i);var d=P(i,2);hi(d,()=>I(a),!0),T(d),T(r),L(`mousedown`,d,e=>tL.startBodyInteraction(e)),L(`click`,d,e=>tL.handleBodyConversationClick(e,t.pane.entry)),z(e,r)};V(m,e=>{t.pane.showBody&&e(h)});var g=P(m,2),_=e=>{var n=hL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.emptyMessage)),z(e,n)};V(g,e=>{t.pane.showEmpty&&e(_)});var v=P(g,2),y=e=>{var n=gL(),r=P(M(n),2),i=M(r,!0);T(r),T(n),F(()=>B(i,t.pane.pendingMessage)),z(e,n)};V(v,e=>{t.pane.showPending&&e(y)});var b=P(v,2),x=e=>{var n=_L(),r=M(n,!0);T(n),F(()=>B(r,t.pane.tooLargeMessage)),z(e,n)};V(b,e=>{t.pane.showTooLarge&&e(x)}),T(c),F(()=>l=U(c,1,`audit-pane svelte-1h5puht`,null,l,{"audit-pane-split":t.pane&&t.pane.layout===`split`,"audit-pane-split-single":t.pane&&t.pane.layout===`split`&&!(t.pane.showHeaders&&t.pane.showBody)})),z(e,c),D()}Hr([`mousedown`,`keydown`,`click`]);var bL=R(` `),xL=R(` `),SL=R(` `),CL=R(` `),wL=R(``),TL=R(`
        `),EL=R(`
        `);function DL(e,t){E(t,!0);let n=G(t,`panes`,19,()=>[]),r=k(null),i=O(()=>xF(I(r),t.entry,n())),a=e=>`audit-tab-`+t.entry.id+`-`+e,o=e=>`audit-tabpanel-`+t.entry.id+`-`+e;function s(e,t){let i=n().map(e=>e.id),a=SF(e.key,i,t);a!=null&&(e.preventDefault(),((e.currentTarget?.closest?.(`.audit-pane-tablist`))?.querySelectorAll(`.audit-pane-tab`)[i.indexOf(a)])?.focus?.(),A(r,a,!0))}var c=EL(),l=M(c);H(l,21,n,e=>e.id,(e,t)=>{var n=wL();let c;var l=M(n),u=M(l),d=e=>{K(e,{get icon(){return Na}})},f=e=>{K(e,{get icon(){return Ma}})};V(u,e=>{I(t).pane.direction===`request`?e(d):I(t).pane.direction===`response`&&e(f,1)}),T(l);var p=P(l,2),m=M(p,!0);T(p);var h=P(p,2),g=e=>{var n=bL(),r=M(n);T(n),F(()=>B(r,`#${I(t).pane.seq??``}`)),z(e,n)};V(h,e=>{I(t).pane.seq&&e(g)});var _=P(h,2),v=e=>{var n=xL(),r=M(n,!0);T(n),F(()=>{U(n,1,`provider-badge audit-pane-kind audit-pane-kind-${I(t).pane.kind??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.kind)}),z(e,n)};V(_,e=>{I(t).pane.kind&&e(v)});var y=P(_,2);H(y,17,()=>I(t).pane.noChangeSteps||[],e=>e.id,(e,t)=>{var n=SL(),r=M(n,!0);T(n),F(()=>{W(n,`title`,I(t).title),B(r,I(t).label)}),z(e,n)});var b=P(y,2),x=e=>{var n=CL(),r=M(n,!0);T(n),F(()=>B(r,I(t).pane.savingsLabel)),z(e,n)};V(b,e=>{I(t).pane.savingsLabel&&e(x)});var S=P(b,2),C=e=>{var n=xL(),r=M(n,!0);T(n),F(e=>{U(n,1,`audit-status-badge ${e??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.statusCode)},[()=>HP(I(t).pane.statusCode)]),z(e,n)};V(S,e=>{I(t).pane.statusCode&&e(C)}),T(n),F((e,r)=>{c=U(n,1,`audit-pane-tab svelte-1bc5vi5`,null,c,{"audit-pane-tab-active":I(i)===I(t).id}),W(n,`aria-selected`,I(i)===I(t).id),W(n,`id`,e),W(n,`aria-controls`,r),W(n,`tabindex`,I(i)===I(t).id?0:-1),U(l,1,Fi([`audit-pane-icon`,I(t).pane.direction&&`audit-pane-icon-${I(t).pane.direction}`]),`svelte-1bc5vi5`),B(m,I(t).pane.title)},[()=>a(I(t).id),()=>o(I(t).id)]),L(`keydown`,n,e=>s(e,I(t).id)),L(`click`,n,()=>A(r,I(t).id,!0)),z(e,n)}),T(l),H(P(l,2),17,n,e=>e.id,(e,t)=>{var n=TL();let r;yL(M(n),{get pane(){return I(t).pane}}),T(n),F((e,a)=>{W(n,`id`,e),W(n,`aria-labelledby`,a),r=Hi(n,``,r,{display:I(i)===I(t).id?null:`none`})},[()=>o(I(t).id),()=>a(I(t).id)]),z(e,n)}),T(c),z(e,c),D()}Hr([`keydown`,`click`]);var OL=R(`
        `),kL=R(`
        `);function AL(e,t){E(t,!0);let n=G(t,`thread`,3,null),r=O(()=>TF.isAuditEntryExpanded(t.entry)),i=O(()=>tL.conversationOpen&&String(tL.conversationAnchorID||``)===String(t.entry.id||``)),a=O(()=>I(r)?yF(t.entry,XF):[]),o=O(()=>I(r)?mN(t.entry,lP.auditEntryWorkflow(t.entry),lP.workflowFeatureCaps()):null);function s(){TF.toggleAuditEntryExpanded(t.entry)}var c=kL();let l;var u=M(c);sL(u,{get entry(){return t.entry},get thread(){return n()},get expanded(){return I(r)},onactivate:s});var d=P(u,2),f=e=>{var n=OL(),r=M(n),i=e=>{AM(e,{get chart(){return I(o)}})};V(r,e=>{I(o)&&e(i)});var s=P(r,2);DL(s,{get entry(){return t.entry},get panes(){return I(a)}}),FF(P(s,2),{get entry(){return t.entry}}),T(n),ki(3,n,()=>Ks,()=>({y:-6,duration:sP(150)})),z(e,n)};V(d,e=>{I(r)&&e(f)}),T(c),F(()=>l=U(c,1,`audit-entry svelte-cmjgwr`,null,l,{"audit-entry-interactions-open":I(i)})),z(e,c),D()}var jL=R(`
        `),ML=R(`
        `),NL=R(`

        `),PL=R(`
        `),FL=R(`
        `);function IL(e,t){E(t,!0);let n=O(()=>TP(t.entry)),r=O(()=>TF.isThreadExpanded(I(n))),i=O(()=>TF.threadChildren(I(n))),a=O(()=>I(i)&&!I(i).loading&&Number(I(i).total||0)>I(i).entries.length+1);var o=Qr(),s=N(o),c=e=>{AL(e,{get entry(){return t.entry}})},l=O(()=>!DP(t.entry)),u=e=>{var n=FL(),o=M(n);{let e=O(()=>({count:EP(t.entry),expanded:I(r),ontoggle:()=>TF.toggleThread(t.entry)}));AL(o,{get entry(){return t.entry},get thread(){return I(e)}})}var s=P(o,2),c=e=>{var t=PL(),n=M(t),r=e=>{var t=jL();xS(M(t),{size:14,label:`Loading session requests`}),T(t),z(e,t)};V(n,e=>{I(i)&&I(i).loading&&e(r)});var o=P(n,2);H(o,17,()=>I(i)&&I(i).entries||[],e=>e.id,(e,t)=>{var n=ML();AL(M(n),{get entry(){return I(t)}}),T(n),z(e,n)});var s=P(o,2),c=e=>{var t=NL(),n=M(t);T(t),F(()=>B(n,`Showing the latest ${I(i).entries.length+1} of ${I(i).total??``} + requests in this session.`)),z(e,t)};V(s,e=>{I(a)&&e(c)}),T(t),ki(3,t,()=>qs,()=>({duration:sP(150)})),z(e,t)};V(s,e=>{I(r)&&e(c)}),T(n),z(e,n)};V(s,e=>{I(l)?e(c):e(u,-1)}),z(e,o),D()}var LL=R(`

        .

        `),RL=R(`
        Audit logging is off. Live entries are temporary and disappear after + refresh. Set LOGGING_ENABLED=true to persist them.
        `),zL=R(`

        `),BL=R(`
        `),VL=R(`
        `),HL=R(`
        `),UL=R(`
        `),WL=R(`
        `);function GL(e,t){E(t,!0);let n=O(()=>xs.config&&xs.config.LOGGING_RETENTION_DAYS);An(()=>{if(q.refreshTick,qo.page===`audit-logs`)return Er(()=>r())});function r(){let e=!1;return(async()=>{try{await xs.ensureLoaded()}finally{await TF.fetchAuditLog(!0),!e&&xs.liveLogsVisible()&&jC.ensureLiveLogs()}})(),()=>{e=!0,jC.stopLiveLogs()}}var i=WL(),a=M(i),o=M(a),s=P(M(o),2),c=e=>{KS(e,{copyId:`audit-retention-help-copy`,label:`retention help`,text:`If you want to change the retention period, set LOGGING_RETENTION_DAYS (env var) or logging.retention_days (config.yaml) and restart the gateway. Default is 30 days; 0 keeps audit logs forever.`,title:e=>{var t=LL(),r=M(t,!0),i=P(r),a=M(i,!0);T(i),Ue(),T(t),F((e,t)=>{B(r,e),B(a,t)},[()=>xP(I(n)),()=>SP(I(n))]),z(e,t)},$$slots:{title:!0}})},l=O(()=>bP(I(n)));V(s,e=>{I(l)&&e(c)}),T(o),T(a);var u=P(a,2);el(M(u),{onchange:()=>TF.fetchAuditLog(!0)}),T(u);var d=P(u,2);Pc(d,{});var f=P(d,2),p=e=>{z(e,RL())},m=O(()=>xs.loaded&&!xs.auditVisible()&&!q.needsAuth);V(f,e=>{I(m)&&e(p)});var h=P(f,2),g=M(h);DF(g,{});var _=P(g,2),v=M(_),y=M(v),b=e=>{var t=zL(),n=M(t);T(t),F(e=>B(n,`Showing ${TF.auditLog.offset+1}-${e??``} of ${TF.auditLog.total??``} + ${TF.auditGroupSessions?`sessions`:`logs`}`),[()=>Math.min(TF.auditLog.offset+TF.auditLog.limit,TF.auditLog.total)]),z(e,t)};V(y,e=>{TF.auditLog.total>0&&e(b)});var x=P(y,2),S=M(x);na(S),Ue(2),T(x),T(v),MF(P(v,2),{}),T(_);var C=P(_,2),w=e=>{var t=BL();xS(M(t),{size:18,label:`Loading audit logs`}),T(t),z(e,t)},ee=e=>{var t=HL();H(t,29,()=>TF.auditLog.entries,e=>e.id,(e,t)=>{var n=VL(),r=M(n),i=e=>{IL(e,{get entry(){return I(t)}})},a=e=>{AL(e,{get entry(){return I(t)}})};V(r,e=>{TF.auditGroupSessions?e(i):e(a,-1)}),T(n),Oi(n,()=>rP,()=>({duration:sP(150)})),ki(1,n,()=>cP,()=>({live:I(t)._live})),z(e,n)}),T(t),z(e,t)};V(C,e=>{TF.loading&&TF.auditLog.entries.length===0?e(w):TF.auditLog.entries.length>0&&e(ee,1)});var te=P(C,2),ne=e=>{var t=UL();wS(M(t),{}),T(t),z(e,t)};V(te,e=>{TF.auditLog.entries.length===0&&!TF.loading&&!q.needsAuth&&e(ne)}),Jw(P(te,2),{get total(){return TF.auditLog.total},get offset(){return TF.auditLog.offset},get limit(){return TF.auditLog.limit},onprev:()=>TF.auditLogPrevPage(),onnext:()=>TF.auditLogNextPage()}),T(h),T(i),F(()=>ia(S,TF.auditGroupSessions)),L(`change`,S,()=>TF.toggleAuditGroupSessions()),z(e,i),D()}Hr([`change`]);function KL(e){try{let t=JSON.parse(JSON.stringify(e||{}));return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function qL(e){return Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(e=>e):e==null?[]:String(e).split(`,`).map(e=>e.trim()).filter(e=>e)}function JL(e,t){let n=String(t||``).trim();return(e||[]).find(e=>String(e&&e.type||``).trim()===n)||null}function YL(e){return Array.isArray(e)&&e.length>0&&String(e[0].type||``).trim()||`system_prompt`}function XL(e,t){let n=String(t||``).trim();return n&&JL(e,n)?n:YL(e)}function ZL(e,t){let n=JL(e,t);return!n||!n.defaults?{}:KL(n.defaults)}function QL(e,t,n){return{...ZL(e,n),...KL(t)}}function $L(e,t){let n=XL(e,t);return{name:``,type:n,description:``,user_path:``,config:ZL(e,n)}}function eR(e,t){if(!t)return e||[];let n=String(t).toLowerCase();return(e||[]).filter(e=>[e.name,e.type,e.user_path,e.description,e.summary].some(e=>String(e||``).toLowerCase().includes(n)))}function tR(e,t){let n=JL(e,t);return n&&n.label?n.label:t||`Unknown`}function nR(e,t){let n=JL(e,t);return Array.isArray(n&&n.fields)?n.fields:[]}function rR(e,t){if(!t||!e)return t&&t.input===`checkboxes`?[]:``;let n=e[t.key];return n==null?t.input===`checkboxes`?[]:``:t.input===`checkboxes`?qL(n):n}function iR(e,t,n){if(!t)return e;let r=KL(e);if(t.input===`number`){let e=String(n||``).trim();if(e===``)delete r[t.key];else{let n=Number(e);r[t.key]=Number.isFinite(n)?n:e}}else t.input===`checkboxes`?r[t.key]=qL(n):r[t.key]=n;return r}function aR(e,t,n){return rR(e,t).includes(String(n||``).trim())}function oR(e,t,n,r){let i=qL(rR(e,t)),a=String(n||``).trim();return a?iR(e,t,r?Array.from(new Set([...i,a])):i.filter(e=>e!==a)):e}function sR(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),description:String(e&&e.description||``).trim()||void 0,user_path:String(e&&e.user_path||``).trim()||void 0,config:KL(e&&e.config)}}var cR=new class{#e=k(j([]));get guardrails(){return I(this.#e)}set guardrails(e){A(this.#e,e,!0)}#t=k(j([]));get types(){return I(this.#t)}set types(e){A(this.#t,e,!0)}#n=k(!0);get available(){return I(this.#n)}set available(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=k(!1);get typesLoading(){return I(this.#i)}set typesLoading(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(``);get filter(){return I(this.#o)}set filter(e){A(this.#o,e,!0)}#s=k(!1);get formOpen(){return I(this.#s)}set formOpen(e){A(this.#s,e,!0)}#c=k(!1);get formSubmitting(){return I(this.#c)}set formSubmitting(e){A(this.#c,e,!0)}#l=k(``);get deletingName(){return I(this.#l)}set deletingName(e){A(this.#l,e,!0)}#u=k(`create`);get formMode(){return I(this.#u)}set formMode(e){A(this.#u,e,!0)}#d=k(``);get formOriginalName(){return I(this.#d)}set formOriginalName(e){A(this.#d,e,!0)}#f=k(j({name:``,type:``,description:``,user_path:``,config:{}}));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}get filtered(){return eR(this.guardrails,this.filter)}typeLabel(e){return tR(this.types,e)}typeFields(e){return nR(this.types,e)}fieldValue(e){return rR(this.form&&this.form.config,e)}setFieldValue(e,t){this.form={...this.form,config:iR(this.form.config,e,t)}}arrayFieldSelected(e,t){return aR(this.form&&this.form.config,e,t)}toggleArrayFieldValue(e,t,n){this.form={...this.form,config:oR(this.form.config,e,t,n)}}openCreate(){this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=$L(this.types,YL(this.types)),this.formOpen=!0}openEdit(e){let t=XL(this.types,e&&e.type);this.formMode=`edit`,this.formOriginalName=String(e&&e.name||``).trim(),this.error=``,this.form={name:this.formOriginalName,type:t,description:String(e&&e.description||``).trim(),user_path:String(e&&e.user_path||``).trim(),config:QL(this.types,e&&e.config,t)},this.formOpen=!0}closeForm(){this.formOpen=!1,this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=$L(this.types,YL(this.types))}changeType(e){let t=XL(this.types,e);this.form={...this.form,type:t,config:ZL(this.types,t)}}async fetchTypes(){this.typesLoading=!0;try{let e=await _T(`/admin/guardrails/types`,{label:`guardrail types`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.types=[];return}if(e.result&&(this.available=!0),this.types=e.items,e.status===`error`){this.error=e.error;return}let t=XL(this.types,this.form.type);this.form={...this.form,type:t,config:QL(this.types,this.form.config,t)}}finally{this.typesLoading=!1}}async fetchGuardrails(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/guardrails`,{label:`guardrails`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.guardrails=[];return}e.result&&(this.available=!0),this.guardrails=e.items,this.error=e.error}finally{this.loading=!1}}async fetchPage(){await Promise.all([this.fetchTypes(),this.fetchGuardrails()])}async submitForm(){let e=String(this.form.name||``).trim(),t=String(this.form.type||``).trim();if(!e){this.error=`Name is required.`;return}if(!t){this.error=`Type is required.`;return}this.error=``,this.formSubmitting=!0;let n=sR(this.form);try{let t=await vT(`/admin/guardrails`,`PUT`,n,{label:`save guardrail`,errorFallback:`Failed to save guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}J.success(`Guardrail "`+e+`" saved.`),this.closeForm(),this.fetchGuardrails()}finally{this.formSubmitting=!1}}async deleteGuardrail(e){let t=String(e&&e.name||``).trim();if(!(!t||this.deletingName)&&window.confirm(`Delete guardrail "`+t+`"? Workflows that still reference it must be updated first.`)){this.deletingName=t;try{let e=await vT(`/admin/guardrails`,`DELETE`,{name:t},{label:`delete guardrail`,errorFallback:`Failed to delete guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}J.success(`Guardrail "`+t+`" deleted.`),this.formOpen&&this.formOriginalName===t&&this.closeForm(),this.fetchGuardrails()}finally{this.deletingName=``}}}},lR=R(`
        `),uR=R(`

        Loading guardrails...

        `),dR=R(`
        `),fR=R(`
        `),pR=R(`
        NameTypeUser PathSummaryActions
        `),mR=R(`

        No guardrails defined yet.

        `),hR=R(`

        Instances

        Each instance has a reusable name, a type, an optional user path for + future UI visibility scoping, and a JSON-backed config payload for + that type.

        `);function gR(e,t){E(t,!0);var n=hR(),r=M(n),i=P(M(r),2);K(M(i),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(i),T(r);var a=P(r,2),o=e=>{var t=lR(),n=M(t);yw(M(n),{id:`guardrail-filter`,placeholder:`Filter by name, type, user path, summary...`,label:`Guardrail filter`,get value(){return cR.filter},set value(e){cR.filter=e}}),T(n),T(t),z(e,t)};V(a,e=>{cR.available&&e(o)});var s=P(a,2),c=e=>{var t=uR();xS(M(t),{size:16,label:`Loading guardrails`}),Ue(),T(t),z(e,t)};V(s,e=>{cR.loading&&cR.filtered.length===0&&e(c)});var l=P(s,2),u=e=>{var t=pR(),n=M(t),r=P(M(n));H(r,21,()=>cR.filtered,e=>e.name,(e,t)=>{var n=fR(),r=M(n),i=M(r,!0);T(r);var a=P(r),o=M(a),s=M(o,!0);T(o),T(a);var c=P(a),l=M(c,!0);T(c);var u=P(c),d=M(u),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var n=dR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(p,e=>{I(t).description&&e(m)}),T(u);var h=P(u),g=M(h),_=M(g);{let e=O(()=>`Edit guardrail `+I(t).name);gT(_,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>cR.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}var v=P(_,2);{let e=O(()=>(cR.deletingName===I(t).name?`Deleting guardrail `:`Delete guardrail `)+I(t).name),n=O(()=>cR.deletingName===I(t).name);gT(v,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>cR.deleteGuardrail(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return Fo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(g),T(h),T(n),F(e=>{B(i,I(t).name),B(s,e),B(l,I(t).user_path||`—`),B(f,I(t).summary||I(t).description||`No summary yet.`)},[()=>cR.typeLabel(I(t).type)]),z(e,n)}),T(r),T(n),T(t),z(e,t)};V(l,e=>{cR.filtered.length>0&&e(u)});var d=P(l,2),f=e=>{z(e,mR())};V(d,e=>{cR.filtered.length===0&&!cR.loading&&cR.available&&!cR.error&&!q.authError&&e(f)}),T(n),F(()=>i.disabled=cR.typesLoading||cR.formSubmitting||!cR.available),L(`click`,i,()=>cR.openCreate()),z(e,n),D()}Hr([`click`]);var _R=R(`

        Workflows reference these names directly, so renames are + intentionally avoided after creation.

        `),vR=R(``),yR=R(``),bR=R(``),xR=R(``),SR=R(``),CR=R(``),wR=R(``),TR=R(``),ER=R(``),DR=R(`
        `),OR=R(``),kR=R(` `),AR=R(`
        `),jR=R(`
        `);function MR(e,t){E(t,!0);let n=O(()=>cR.formMode===`edit`);{let t=e=>{z(e,_R())},r=O(()=>I(n)?`Edit Guardrail`:`Create Guardrail`);bE(e,{get open(){return cR.formOpen},get title(){return I(r)},ariaLabel:`Guardrail editor`,get error(){return cR.error},get submitting(){return cR.formSubmitting},submitLabel:`Save Guardrail`,dialogClass:`settings-guardrails-editor guardrails-editor-wide`,onclose:()=>cR.closeForm(),onsubmit:()=>cR.submitForm(),headerHint:t,children:(e,t)=>{var r=jR(),i=M(r);SE(i,{id:`guardrail-name`,label:`Name`,children:(e,t)=>{var r=vR();na(r),F(()=>{r.disabled=I(n),W(r,`data-modal-autofocus`,!I(n)||void 0)}),da(r,()=>cR.form.name,e=>cR.form.name=e),z(e,r)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`guardrail-type`,label:`Type`,children:(e,t)=>{var r=bR();H(r,21,()=>cR.types,e=>e.type,(e,t)=>{var n=yR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).type)&&(n.value=(n.__value=I(t).type)??``)}),z(e,n)}),T(r);var i;Wi(r),F(()=>{r.disabled=I(n),i!==(i=cR.form.type)&&(r.value=(r.__value=cR.form.type)??``,Ui(r,cR.form.type))}),L(`change`,r,e=>cR.changeType(e.currentTarget.value)),z(e,r)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`guardrail-description`,label:`Description`,children:(e,t)=>{var r=xR();na(r),F(()=>W(r,`data-modal-autofocus`,I(n)?!0:void 0)),da(r,()=>cR.form.description,e=>cR.form.description=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2),c=M(s);KS(c,{copyId:`guardrail-user-path-help-copy`,label:`guardrail user path help`,text:`Only used for auxiliary rewrite (llm_based_altering) guardrails; ignored for other guardrail types.`,title:e=>{z(e,SR())},$$slots:{title:!0}});var l=P(c,2);na(l),T(s),H(P(s,2),17,()=>cR.typeFields(cR.form.type),e=>e.key,(e,t)=>{var n=Qr(),r=N(n),i=e=>{var n=DR(),r=M(n);{let e=e=>{var n=CR(),r=M(n,!0);T(n),F(()=>{W(n,`for`,`guardrail-field-`+I(t).key),B(r,I(t).label)}),z(e,n)},n=O(()=>`guardrail-field-help-`+I(t).key),i=O(()=>I(t).label+` help`),a=O(()=>I(t).help||``);KS(r,{get copyId(){return I(n)},get label(){return I(i)},get text(){return I(a)},title:e,$$slots:{title:!0}})}var i=P(r,2),a=e=>{var n=wR();H(n,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=yR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n);var r;Wi(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),r!==(r=e)&&(n.value=(n.__value=e)??``,Ui(n,e))},[()=>cR.fieldValue(I(t))]),L(`change`,n,e=>cR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},o=e=>{var n=TR();ft(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>cR.fieldValue(I(t))]),L(`input`,n,e=>cR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},s=e=>{var n=ER();na(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`type`,I(t).input||`text`),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>cR.fieldValue(I(t))]),L(`input`,n,e=>cR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)};V(i,e=>{I(t).input===`select`?e(a):I(t).input===`textarea`?e(o,1):e(s,-1)}),T(n),z(e,n)},a=e=>{var n=AR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).options||[],e=>I(t).key+`-`+e.value,(e,n)=>{var r=OR(),i=M(r);na(i);var a=P(i,2),o=M(a,!0);T(a),T(r),F(e=>{ia(i,e),B(o,I(n).label)},[()=>cR.arrayFieldSelected(I(t),I(n).value)]),L(`change`,i,e=>cR.toggleArrayFieldValue(I(t),I(n).value,e.currentTarget.checked)),z(e,r)}),T(a);var o=P(a,2),s=e=>{var n=kR(),r=M(n,!0);T(n),F(()=>{W(n,`id`,`guardrail-field-help-`+I(t).key),B(r,I(t).help)}),z(e,n)};V(o,e=>{I(t).help&&e(s)}),T(n),F(()=>{W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),B(i,I(t).label)}),z(e,n)};V(r,e=>{I(t).input===`checkboxes`?e(a,-1):e(i)}),z(e,n)}),T(r),da(l,()=>cR.form.user_path,e=>cR.form.user_path=e),z(e,r)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var NR=R(`

        Guardrails

        `),PR=R(`
        Runtime guardrail execution is currently off because GUARDRAILS_ENABLED is disabled. You can still manage + definitions here.
        `),FR=R(`
        Guardrails feature is unavailable.
        `),IR=R(`
        `),LR=R(`

        Reusable Policy Objects

        Guardrail Library

        Store guardrails in the database, keep them hot in memory, and attach + them to workflows by reference.

        Instances
        Types
        `);function RR(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`guardrails`&&(xs.ensureLoaded(),cR.fetchPage())});var n=LR(),r=M(n),i=M(r);KS(M(i),{copyId:`guardrails-help-copy`,label:`guardrails help`,text:`Reusable policy objects stored in the database and kept hot in memory for workflow execution.`,title:e=>{z(e,NR())},$$slots:{title:!0}}),T(i),T(r);var a=P(r,2),o=P(M(a),2),s=M(o),c=P(M(s),2),l=M(c,!0);T(c),T(s);var u=P(s,2),d=P(M(u),2),f=M(d,!0);T(d),T(u),T(o),T(a);var p=P(a,2);Pc(p,{});var m=P(p,2),h=e=>{z(e,PR())},g=O(()=>!xs.guardrailsVisible());V(m,e=>{I(g)&&e(h)});var _=P(m,2),v=e=>{z(e,FR())};V(_,e=>{!q.authError&&!cR.available&&e(v)});var y=P(_,2),b=e=>{var t=IR(),n=M(t,!0);T(t),F(()=>B(n,cR.error)),z(e,t)};V(y,e=>{!q.authError&&cR.error&&!cR.formOpen&&e(b)});var x=P(y,2);MR(x,{}),gR(P(x,2),{}),T(n),F((e,t)=>{B(l,e),B(f,t)},[()=>ac(cR.guardrails.length),()=>ac(cR.types.length)]),z(e,n),D()}var Q=new class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get slugEdited(){return I(this.#c)}set slugEdited(e){A(this.#c,e,!0)}#l=k(!1);get advancedOpen(){return I(this.#l)}set advancedOpen(e){A(this.#l,e,!0)}#u=k(j(ux()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(``);get deletingName(){return I(this.#d)}set deletingName(e){A(this.#d,e,!0)}#f=k(``);get reconnectingName(){return I(this.#f)}set reconnectingName(e){A(this.#f,e,!0)}#p=k(!1);get catalogOpen(){return I(this.#p)}set catalogOpen(e){A(this.#p,e,!0)}#m=k(!1);get catalogLoading(){return I(this.#m)}set catalogLoading(e){A(this.#m,e,!0)}#h=k(``);get catalogError(){return I(this.#h)}set catalogError(e){A(this.#h,e,!0)}#g=k(j(dx()));get catalog(){return I(this.#g)}set catalog(e){A(this.#g,e,!0)}#_=O(()=>Sx(this.servers,this.filter));get filtered(){return I(this.#_)}set filtered(e){A(this.#_,e)}async fetchServers(){if(await xs.ensureLoaded(),!xs.mcpVisible()){this.available=!1,this.servers=[],this.error=``,this.loading=!1;return}this.loading=!0,this.error=``;try{let e=await _T(`/admin/mcp-servers`,{label:`mcp servers`,errorFallback:`Failed to load MCP servers.`,unavailableStatuses:[503,404]});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.servers=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.servers=[],this.error=e.error;return}this.available=!0,this.servers=e.items}finally{this.loading=!1}}openCreate(){this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=ux(),this.formOpen=!0}openEdit(e){!e||e.managed||(this.formMode=`edit`,this.slugEdited=!0,this.advancedOpen=!1,this.error=``,this.form=Cx(e),this.formOpen=!0)}closeForm(){this.formOpen=!1,this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=ux()}syncSlugFromName(){this.formMode===`create`&&!this.slugEdited&&(this.form.slug=vx(this.form.name))}markSlugEdited(){this.formMode===`create`&&(this.slugEdited=!0)}addHeader(){this.form.headers.push({name:``,value:``})}removeHeader(e){this.form.headers.splice(e,1)}async submitForm(){let e=wx(this.form,this.formMode,this.servers);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/mcp-servers`,`PUT`,e.payload,{label:`save mcp server`,errorFallback:`Failed to save MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}J.success(`MCP server "`+e.payload.name+`" saved.`),this.closeForm(),this.fetchServers()}finally{this.formSubmitting=!1}}async deleteServer(e){let t=String(e&&e.name||``).trim(),n=fx(e);if(!(!n||this.deletingName||e&&e.managed)&&confirm(`Delete MCP server "`+t+`"? Clients lose access to its tools immediately.`)){this.deletingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n),`DELETE`,void 0,{label:`delete mcp server`,errorFallback:`Failed to delete MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}J.success(`MCP server "`+t+`" deleted.`),this.formOpen&&this.form.slug===n&&this.closeForm(),this.fetchServers()}finally{this.deletingName=``}}}async reconnectServer(e){let t=String(e&&e.name||``).trim(),n=fx(e);if(!(!n||this.reconnectingName)){this.reconnectingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n)+`/reconnect`,`POST`,void 0,{label:`reconnect mcp server`,errorFallback:`Failed to reconnect MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}let r=e.result.data,i=px(r);i===`connected`?J.success(`MCP server "`+t+`" reconnected.`):i===`disabled`?J.success(`MCP server "`+t+`" is disabled; no connection was attempted.`):J.error(`Reconnect attempted, but MCP server "`+t+`" is still `+i+`.`),r&&r.name?this.servers=(this.servers||[]).map(e=>fx(e)===fx(r)?r:e):this.fetchServers()}finally{this.reconnectingName=``}}}async openCatalog(e){let t=String(e&&e.name||``).trim(),n=fx(e);if(n){this.catalogOpen=!0,this.catalogLoading=!0,this.catalogError=``,this.catalog={...dx(),server:n,status:px(e)};try{let e=await gs(`/admin/mcp-servers/`+encodeURIComponent(n)+`/catalog`,{label:`mcp server catalog`});if(e.stale)return;if(e.status===503){this.available=!1,this.catalogError=`MCP server management is unavailable.`;return}if(e.status===404){this.catalogError=`MCP server "`+t+`" was not found.`;return}if(!e.ok){this.catalogError=e.status===401?`Authentication required.`:ds(e.data,`Failed to load MCP server catalog.`);return}this.catalog=Tx(n,e.data)}catch(e){console.error(`Failed to load MCP server catalog:`,e),this.catalogError=`Failed to load MCP server catalog.`}finally{this.catalogLoading=!1}}}closeCatalog(){this.catalogOpen=!1,this.catalogLoading=!1,this.catalogError=``,this.catalog=dx()}},zR=R(``),BR=R(`

        `),VR=R(`
        `),HR=R(`

        `),UR=R(`
      • `),WR=R(`

          `),GR=R(`

          No tools listed — the server may still be connecting or degraded.

          `),KR=R(` `,1),qR=R(``);function JR(e,t){E(t,!0);let n=O(()=>Dx(Q.catalog));Ms(e,{get open(){return Q.catalogOpen},variant:`editor`,onclose:()=>Q.closeCatalog(),children:(e,t)=>{var r=qR(),i=M(r),a=M(i),o=P(M(a),2),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l),T(o),T(a),Os(P(a,2),{label:`Close MCP server catalog`,onclick:()=>Q.closeCatalog()}),T(i);var d=P(i,2),f=e=>{mT(e,{label:`Loading catalog...`})},p=e=>{var t=zR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalogError)),z(e,t)},m=e=>{var t=KR(),r=N(t),i=e=>{var t=BR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalog.instructions)),z(e,t)};V(r,e=>{Q.catalog.instructions&&e(i)});var a=P(r,2);H(a,17,()=>I(n),e=>e.key,(e,t)=>{var n=WR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).items,e=>e.key,(e,t)=>{var n=UR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=VR(),r=M(n,!0);T(n),F(()=>{W(n,`title`,`Exposed on the aggregated /mcp endpoint as `+I(t).aggregated),B(r,I(t).aggregated)}),z(e,n)};V(a,e=>{I(t).aggregated&&e(o)});var s=P(a,2),c=e=>{var n=HR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(s,e=>{I(t).description&&e(c)}),T(n),F(()=>{W(r,`title`,I(t).aggregated||I(t).name),B(i,I(t).name)}),z(e,n)}),T(a),T(n),F(()=>B(i,I(t).title)),z(e,n)});var o=P(a,2),s=e=>{z(e,GR())},c=O(()=>Ox(Q.catalog));V(o,e=>{I(c)&&e(s)}),z(e,t)};V(d,e=>{Q.catalogLoading?e(f):Q.catalogError?e(p,1):e(m,-1)});var h=P(d,2),g=M(h);T(h),T(r),F((e,t)=>{B(c,Q.catalog.server),U(l,1,`audit-status-badge ${e??``}`,`svelte-1xqrzco`),B(u,t)},[()=>mx(Q.catalog),()=>px(Q.catalog)]),L(`click`,g,()=>Q.closeCatalog()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var YR=R(`

          The display name can change. The slug is the stable client-facing identity.

          `),XR=R(` Human-readable and Unicode-friendly. You can change it later.`,1),ZR=R(`Derived from the name. You may edit it before saving.`),QR=R(`Immutable because it is used in URLs, scope headers, and aggregated tool names.`),$R=R(` `,1),ez=R(` stdio servers are config-only: declare them in config.yaml under mcp.servers.`,1),tz=R(``),nz=R(`
          `),rz=R(`
          Headers
          Sent only to the configured server origin. Saved values are shown as ***; leave *** unchanged to keep the stored value.
          Advanced settings Description, access rules, and timeout
          `,1);function iz(e,t){E(t,!0);{let t=e=>{z(e,YR())},n=O(()=>Q.formMode===`edit`?`Edit MCP Server`:`Add MCP Server`);bE(e,{get open(){return Q.formOpen},get title(){return I(n)},ariaLabel:`MCP server editor`,get error(){return Q.error},get submitting(){return Q.formSubmitting},onclose:()=>Q.closeForm(),onsubmit:()=>Q.submitForm(),headerHint:t,children:(e,t)=>{var n=rz(),r=N(n);SE(r,{id:`mcp-server-name`,label:`Name`,children:(e,t)=>{var n=XR(),r=N(n);na(r),Ue(2),L(`input`,r,()=>Q.syncSlugFromName()),da(r,()=>Q.form.name,e=>Q.form.name=e),z(e,n)},$$slots:{default:!0}});var i=P(r,2);SE(i,{id:`mcp-server-slug`,label:`Slug`,children:(e,t)=>{var n=$R(),r=N(n);na(r);var i=P(r,2),a=e=>{z(e,ZR())},o=e=>{z(e,QR())};V(i,e=>{Q.formMode===`create`?e(a):e(o,-1)}),F(()=>r.disabled=Q.formMode===`edit`),L(`input`,r,()=>Q.markSlugEdited()),da(r,()=>Q.form.slug,e=>Q.form.slug=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`mcp-server-transport`,label:`Transport`,children:(e,t)=>{var n=ez(),r=N(n),i=M(r);i.value=i.__value=`http`;var a=P(i);a.value=a.__value=`sse`,T(r),Ue(2),Gi(r,()=>Q.form.transport,e=>Q.form.transport=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`mcp-server-url`,label:`URL`,children:(e,t)=>{var n=tz();na(n),da(n,()=>Q.form.url,e=>Q.form.url=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=P(M(s),2);H(c,21,()=>Q.form.headers,oi,(e,t,n)=>{var r=nz(),i=M(r);na(i);var a=P(i,2);na(a),gT(P(a,2),{label:`Remove header`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Q.removeHeader(n),children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),da(i,()=>I(t).name,e=>I(t).name=e),da(a,()=>I(t).value,e=>I(t).value=e),z(e,r)}),T(c);var l=P(c,2),u=M(l);K(M(u),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(u),T(l),Ue(2),T(s);var d=P(s,2),f=M(d);bA(M(f),{get enabled(){return Q.form.enabled},label:`MCP server`,onclick:()=>Q.form.enabled=!Q.form.enabled}),T(f),T(d);var p=P(d,2),m=P(M(p),2),h=M(m),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=P(M(y),2);na(b),T(y);var x=P(y,2),S=P(M(x),2);ft(S),W(S,`placeholder`,`/ +/team/alpha`),T(x);var C=P(x,2),w=P(M(C),2);na(w),T(C),T(m),T(p),F(()=>p.open=Q.advancedOpen),L(`click`,u,()=>Q.addHeader()),Vr(`toggle`,p,e=>Q.advancedOpen=e.currentTarget.open),da(g,()=>Q.form.description,e=>Q.form.description=e),da(v,()=>Q.form.allowed_tools,e=>Q.form.allowed_tools=e),da(b,()=>Q.form.disallowed_tools,e=>Q.form.disallowed_tools=e),da(S,()=>Q.form.user_paths,e=>Q.form.user_paths=e),da(w,()=>Q.form.tool_timeout_seconds,e=>Q.form.tool_timeout_seconds=e),z(e,n)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`input`,`click`]);var az=R(`Config`),oz=R(`
          `),sz=R(`
          `),cz=R(`
          NameTransportEndpointStatusToolsEnabledActions
          `);function lz(e,t){E(t,!0);function n(e){return hx(e,e=>us.formatTimestamp(e))}var r=cz(),i=M(r),a=P(M(i));H(a,21,()=>Q.filtered,e=>fx(e),(e,t)=>{var r=sz(),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=e=>{z(e,az())};V(s,e=>{I(t).managed&&e(c)});var l=P(s,2),u=M(l,!0);T(l),T(i);var d=P(i),f=M(d),p=M(f,!0);T(f),T(d);var m=P(d),h=M(m,!0);T(m);var g=P(m),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=e=>{var n=oz(),r=M(n,!0);T(n),F(()=>B(r,I(t).last_error)),z(e,n)},x=O(()=>px(I(t))===`degraded`&&I(t).last_error);V(y,e=>{I(x)&&e(b)}),T(g);var S=P(g),C=M(S),w=M(C,!0);T(C);var ee=P(C,2),te=M(ee,!0);T(ee),T(S);var ne=P(S),re=M(ne),ie=M(re,!0);T(re),T(ne);var ae=P(ne),oe=M(ae),se=M(oe),ce=e=>{{let n=O(()=>`Edit MCP server `+I(t).name);gT(e,{get label(){return I(n)},class:`table-icon-btn`,onclick:()=>Q.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(se,e=>{I(t).managed||e(ce)});var le=P(se,2);{let e=O(()=>`Inspect catalog of MCP server `+I(t).name);gT(le,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.openCatalog(I(t)),children:(e,t)=>{K(e,{get icon(){return ro},class:`form-action-icon`})},$$slots:{default:!0}})}var ue=P(le,2);{let e=O(()=>(Q.reconnectingName===fx(I(t))?`Reconnecting MCP server `:`Reconnect MCP server `)+I(t).name),n=O(()=>Q.reconnectingName===fx(I(t)));gT(ue,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.reconnectServer(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return mo},class:`form-action-icon`})},$$slots:{default:!0}})}var de=P(ue,2),fe=e=>{{let n=O(()=>(Q.deletingName===fx(I(t))?`Deleting MCP server `:`Delete MCP server `)+I(t).name),r=O(()=>Q.deletingName===fx(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>Q.deleteServer(I(t)),get disabled(){return I(r)},children:(e,t)=>{K(e,{get icon(){return Fo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(de,e=>{I(t).managed||e(fe)}),T(oe),T(ae),T(r),F((e,n,r,i,a,s,c,l)=>{B(o,I(t).name),B(u,e),B(p,I(t).transport||`http`),W(m,`title`,n),B(h,r),U(_,1,`audit-status-badge ${i??``}`,`svelte-ah8nrt`),W(_,`title`,a),B(v,s),B(w,c),B(te,l),U(re,1,Fi([`auth-key-status-badge`,I(t).enabled?`auth-key-status-active`:`auth-key-status-inactive`])),B(ie,I(t).enabled?`Enabled`:`Disabled`)},[()=>fx(I(t)),()=>gx(I(t)),()=>gx(I(t)),()=>mx(I(t)),()=>n(I(t)),()=>px(I(t)),()=>ac(I(t).tool_count||0),()=>_x(I(t))]),z(e,r)}),T(a),T(i),T(r),z(e,r),D()}var uz=R(`

          MCP Servers

          `),dz=R(``),fz=R(`
          MCP server management is unavailable.
          `),pz=R(``),mz=R(`
          `),hz=R(`

          No MCP servers yet. Add one here, or declare servers in config.yaml under mcp.servers.

          `),gz=R(`

          No MCP servers match your filter.

          `),_z=R(`
          `);function vz(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`mcp-servers`&&Q.fetchServers()});var n=_z(),r=M(n),i=M(r);KS(M(i),{copyId:`mcp-servers-help-copy`,label:`MCP servers help`,text:`Upstream Model Context Protocol servers whose tools, prompts, and resources the gateway exposes to clients. Servers added here connect over HTTP or SSE; stdio servers and rows marked Config are declared in config.yaml under mcp.servers and are read-only in the dashboard. Saved header values are masked in API and dashboard responses.`,title:e=>{z(e,uz())},$$slots:{title:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=dz();K(M(t),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Q.formSubmitting),L(`click`,t,()=>Q.openCreate()),z(e,t)};V(o,e=>{Q.available&&!q.authError&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,fz())};V(c,e=>{!Q.available&&!q.authError&&e(l)});var u=P(c,2),d=e=>{var t=pz(),n=M(t,!0);T(t),F(()=>B(n,Q.error)),z(e,t)};V(u,e=>{Q.error&&!q.authError&&!Q.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading MCP servers...`})};V(f,e=>{Q.loading&&!q.authError&&e(p)});var m=P(f,2),h=e=>{var t=mz(),n=M(t);yw(M(n),{id:`mcp-server-filter`,placeholder:`Filter by name, slug, URL, transport, or status...`,label:`Filter MCP servers by name, slug, URL, transport, or status`,get value(){return Q.filter},set value(e){Q.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{(Q.servers.length>0||Q.filter)&&Q.available&&!q.authError&&e(h)});var g=P(m,2);iz(g,{});var _=P(g,2);JR(_,{});var v=P(_,2),y=e=>{lz(e,{})};V(v,e=>{Q.filtered.length>0&&Q.available&&!q.authError&&e(y)});var b=P(v,2),x=e=>{z(e,hz())};V(b,e=>{Q.servers.length===0&&!Q.filter&&!Q.loading&&!q.authError&&!Q.error&&Q.available&&e(x)});var S=P(b,2),C=e=>{z(e,gz())};V(S,e=>{Q.servers.length>0&&Q.filtered.length===0&&Q.filter&&!Q.loading&&!q.authError&&Q.available&&e(C)}),T(n),z(e,n),D()}Hr([`click`]);var yz=`api_keys`,bz=`session_sticky_keys`,xz=`base_url`,Sz=`service_account_json`,Cz=`models`,wz={[yz]:{label:`API Keys`,control:`keys`,hint:`Identified sessions stay on one key by default, improving provider prompt-cache hits. Saved values are shown as ***********; leave the asterisks unchanged to keep the stored key.`},[bz]:{label:`Session-sticky API keys`,control:`checkbox`,hint:`Keep each identified conversation on one API key to preserve provider prompt-cache affinity. Turn off to rotate keys round-robin on every request.`},[xz]:{label:`Base URL`,control:`text`},api_version:{label:`API Version`,control:`text`,placeholder:`e.g. 2024-10-01-preview`,hint:`Leave empty for the provider default. Realtime endpoints may need a newer version.`},backend:{label:`Backend`,control:`select`,hint:`Which Google surface to call. Vertex authenticates with Google credentials instead of an API key.`},auth_type:{label:`Auth Type`,control:`select`,hint:`How to obtain Google credentials. Leave on the default to use Application Default Credentials.`},api_mode:{label:`API Mode`,control:`select`,hint:`Which request shape to send upstream.`},vertex_project:{label:`Vertex Project`,control:`text`,placeholder:`my-gcp-project`},vertex_location:{label:`Vertex Location`,control:`text`,placeholder:`us-central1`},service_account_file:{label:`Service Account File`,control:`text`,placeholder:`/path/to/service-account.json`,hint:`Path readable by the gateway process.`},[Sz]:{label:`Service Account JSON`,control:`textarea`,placeholder:`Paste service account JSON`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value, or clear it to remove.`},service_account_json_base64:{label:`Service Account JSON (base64)`,control:`text`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value.`},gcp_scope:{label:`GCP Scope`,control:`text`,placeholder:`https://www.googleapis.com/auth/cloud-platform`},[Cz]:{label:`Models (comma-separated)`,control:`text`,placeholder:`gpt-4o, gpt-4o-mini`,hint:`Leave empty to auto-discover models from the provider's /models endpoint where supported.`}};function Tz(e){return wz[e]||{label:String(e||``).split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),control:`text`}}function Ez(){return{name:``,type:``,api_keys:[],session_sticky_keys:!0,base_url:``,api_version:``,backend:``,auth_type:``,api_mode:``,vertex_project:``,vertex_location:``,service_account_file:``,service_account_json:``,service_account_json_base64:``,gcp_scope:``,models:``,enabled:!0}}function Dz(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.type,e.base_url].some(e=>String(e||``).toLowerCase().includes(r)))}function Oz(e,t){let n=(Array.isArray(e)?e:[]).map(e=>String(e&&e.type||``).trim()).filter(Boolean),r=String(t||``).trim();return r&&!n.includes(r)&&n.push(r),n}function kz(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>String(e&&e.type||``).trim()===n)||null}function Az(e,t){let n=e&&Array.isArray(e.fields)&&e.fields.length>0?e.fields:Object.keys(wz).map(e=>({name:e,advanced:e!==yz})),r=t||e&&e.default_base_url||``,i=[],a=[];for(let e of n){let t=String(e&&e.name||``).trim();if(!t)continue;let n={...Tz(t),name:t,required:!!(e&&e.required),options:Array.isArray(e&&e.options)?e.options:[]};t===`base_url`&&r&&(n.placeholder=r,n.hint=`Defaults to `+r),n.options.length>0&&(n.control=`select`),(e&&e.advanced?a:i).push(n)}return{primary:i,advanced:a}}var jz=new Set([`name`,`type`,`enabled`]);function Mz(e,t){let n=new Set([...t.primary||[],...t.advanced||[]].map(e=>e.name)),r=Ez(),i={...e};for(let e of Object.keys(r))!jz.has(e)&&!n.has(e)&&(i[e]=r[e]);return i}function Nz(e){let t=Array.isArray(e&&e.api_keys)?e.api_keys.length:0;return t>0?t+` key`+(t===1?``:`s`):String(e&&e.service_account_json||``).trim()||String(e&&e.service_account_json_base64||``).trim()||String(e&&e.service_account_file||``).trim()?`service account`:String(e&&e.vertex_project||``).trim()?`ADC`:`keyless`}function Pz(e){let t=Array.isArray(e&&e.models)?e.models:[];return t.length===0?`auto-discovered`:t.length+` model`+(t.length===1?``:`s`)}function Fz(e){return(Array.isArray(e)?e:[]).map(e=>({value:String(e||``)}))}function Iz(e){return(Array.isArray(e)?e:[]).map(e=>String(e&&e.value||``))}function Lz(e,t){let n=String(t||``).trim();if(!n)return``;let r=new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.name||``).trim()));if(!r.has(n))return n;let i=1;for(;r.has(n+`-`+i);)i+=1;return n+`-`+i}function Rz(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),api_keys:Fz(e&&e.api_keys),session_sticky_keys:!e||e.session_sticky_keys!==!1,base_url:String(e&&e.base_url||``),api_version:String(e&&e.api_version||``),backend:String(e&&e.backend||``),auth_type:String(e&&e.auth_type||``),api_mode:String(e&&e.api_mode||``),vertex_project:String(e&&e.vertex_project||``),vertex_location:String(e&&e.vertex_location||``),service_account_file:String(e&&e.service_account_file||``),service_account_json:String(e&&e.service_account_json||``),service_account_json_base64:String(e&&e.service_account_json_base64||``),gcp_scope:String(e&&e.gcp_scope||``),models:(Array.isArray(e&&e.models)?e.models:[]).join(`, `),enabled:!e||e.enabled!==!1}}function zz(e){let t=String(e||``).trim();return t.length>=3&&/^\*+$/.test(t)}function Bz(e,t,n,r){let i={},a=String(e&&e.name||``).trim();String(e&&e.type||``).trim()||(i.type=`Select a provider type.`),a?a.includes(`/`)?i.name=`Name cannot contain '/' — it separates the provider from the model.`:t===`create`&&(Array.isArray(n)?n:[]).some(e=>String(e&&e.name||``).trim()===a)&&(i.name=`Provider "`+a+`" already exists.`):i.name=`Name is required.`;let{primary:o,advanced:s}=Az(r);for(let t of[...o,...s]){let n=Vz(e,t);n&&(i[t.name]=n)}return i}function Vz(e,t){if(t.name===`api_keys`){let n=Iz(e&&e.api_keys);return t.required&&!n.some(e=>e.trim())?`At least one API key is required for this provider type.`:n.some(e=>!e.trim())?`Remove the empty row instead of leaving a key blank.`:``}let n=String(e&&e[t.name]||``).trim();if(t.required&&!n)return t.label+` is required for this provider type.`;if(!n)return``;if(t.name===`base_url`&&!n.includes(`://`)&&/[./]/.test(n))return`Include the scheme, e.g. https://`+n;if(t.name===`service_account_json`&&!zz(n))try{JSON.parse(n)}catch{return`Paste the service account JSON file's contents — this is not valid JSON.`}return``}function Hz(e,t){let n={name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),enabled:!!(e&&e.enabled)},{primary:r,advanced:i}=Az(t),a=!!(t&&Array.isArray(t.fields)&&t.fields.length>0),o=new Set;for(let t of[...r,...i])!a&&t.name===`session_sticky_keys`||(o.add(t.name),n[t.name]=Uz(e,t.name));for(let t of Object.keys(wz)){if(o.has(t)||t===`session_sticky_keys`)continue;let r=Uz(e,t);(Array.isArray(r)?r.length>0:String(r).trim()!==``)&&(n[t]=r)}return n}function Uz(e,t){switch(t){case yz:return Iz(e&&e.api_keys);case Cz:return rc(e&&e.models);case bz:return!!(e&&e.session_sticky_keys);case Sz:return e&&e.service_account_json||``;default:return String(e&&e[t]||``).trim()}}var $=new class{#e=k(j([]));get rows(){return I(this.#e)}set rows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get advancedOpen(){return I(this.#c)}set advancedOpen(e){A(this.#c,e,!0)}#l=k(j(Ez()));get form(){return I(this.#l)}set form(e){A(this.#l,e,!0)}#u=k(j({}));get fieldErrors(){return I(this.#u)}set fieldErrors(e){A(this.#u,e,!0)}#d=k(``);get focusField(){return I(this.#d)}set focusField(e){A(this.#d,e,!0)}#f=k(``);get deletingName(){return I(this.#f)}set deletingName(e){A(this.#f,e,!0)}#p=k(!1);get deleteSubmitting(){return I(this.#p)}set deleteSubmitting(e){A(this.#p,e,!0)}#m=k(j([]));get types(){return I(this.#m)}set types(e){A(this.#m,e,!0)}#h=k(!1);get typesLoaded(){return I(this.#h)}set typesLoaded(e){A(this.#h,e,!0)}#g=null;get filteredRows(){return Dz(this.rows,this.filter)}get schema(){return kz(this.types,this.form.type)}get formFields(){if(!String(this.form.type||``).trim())return{primary:[],advanced:[]};let e=this.schema;return Az(e,e&&e.default_base_url)}async fetchTypes(){let e=await _T(`/admin/provider-credentials/types`,{label:`provider credential types`});e.status===`ok`&&(this.types=e.items,this.typesLoaded=!0)}async fetchPage(){this.#g&&this.#g.abort();let e=new AbortController;this.#g=e,this.loading=!0,this.error=``;try{let t=await _T(`/admin/provider-credentials`,{label:`provider credentials`,errorFallback:`Failed to load provider credentials.`,unavailableStatuses:[503,404],options:{signal:e.signal}});if(t.status===`stale`||e.signal.aborted)return;if(t.status===`unavailable`){this.available=!1,this.rows=[];return}if(t.status===`error`){t.result&&(this.available=!0),this.rows=[],this.error=t.error;return}this.available=!0,this.rows=t.items,this.typesLoaded||await this.fetchTypes()}finally{this.#g===e&&(this.#g=null,this.loading=!1)}}#_(e,t){this.formMode=e,this.form=t,this.advancedOpen=!1,this.error=``,this.fieldErrors={},this.focusField=``}openCreate(){this.#_(`create`,Ez()),this.formOpen=!0,this.typesLoaded||this.fetchTypes()}openEdit(e){!e||e.managed||(this.#_(`edit`,Rz(e)),this.formOpen=!0,this.typesLoaded||this.fetchTypes())}closeForm(){this.formOpen=!1,this.#_(`create`,Ez())}selectType(){this.fieldErrors={};let e=this.formFields;this.formMode===`create`&&(this.form=Mz(this.form,e));let t=e.primary.find(e=>e.name===`api_keys`);t&&t.required&&this.form.api_keys.length===0&&(this.form.api_keys=[{value:``}])}clearFieldError(e){if(this.fieldErrors[e]===void 0)return;let{[e]:t,...n}=this.fieldErrors;this.fieldErrors=n}addApiKeyRow(){this.form.api_keys.push({value:``}),this.clearFieldError(`api_keys`)}removeApiKeyRow(e){this.form.api_keys.splice(e,1),this.clearFieldError(`api_keys`)}#v(e){let t=ds(e,`Failed to save provider credential.`),n=String(e&&e.error&&typeof e.error==`object`&&e.error.param||``).trim();if(n&&this.#y(n)){this.fieldErrors={...this.fieldErrors,[n]:t},this.error=``,this.#b();return}this.error=t}#y(e){if(e===`name`||e===`type`)return!0;let{primary:t,advanced:n}=this.formFields;return[...t,...n].some(t=>t.name===e)}#b(){let e=Object.keys(this.fieldErrors);if(e.length===0)return;let{primary:t,advanced:n}=this.formFields;n.some(t=>e.includes(t.name))&&(this.advancedOpen=!0);let r=[`type`,`name`,...t.map(e=>e.name),...n.map(e=>e.name)];this.focusField=r.find(t=>e.includes(t))||e[0]}#x(){Mc.fetchModels(),Mc.fetchCategories()}async submitForm(){let e=this.schema,t=Bz(this.form,this.formMode,this.rows,e);if(Object.keys(t).length>0){this.fieldErrors=t,this.error=``,this.#b();return}let n=Hz(this.form,e);this.error=``,this.fieldErrors={},this.formSubmitting=!0;try{let e=await vT(`/admin/provider-credentials`,`PUT`,n,{label:`save provider credential`,errorFallback:`Failed to save provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.error=e.error;return}if(e.status===`error`){e.result&&e.result.status!==401?this.#v(e.result.data):this.error=e.error;return}J.success(`Provider "`+n.name+`" saved.`),this.closeForm(),this.#x(),this.fetchPage()}finally{this.formSubmitting=!1}}async performDelete(e){this.deleteSubmitting=!0,this.deletingName=e;try{let t=await vT(`/admin/provider-credentials/`+encodeURIComponent(e),`DELETE`,void 0,{label:`delete provider credential`,errorFallback:`Failed to delete provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,Ls.error=t.error;return}if(t.status===`error`){Ls.error=t.error;return}J.success(`Provider "`+e+`" deleted.`),Ls.close(),this.formOpen&&this.form.name===e&&this.closeForm(),this.#x(),this.fetchPage()}finally{this.deleteSubmitting=!1,this.deletingName=``}}requestDelete(e){let t=String(e||``).trim();if(!t||this.deleteSubmitting)return;let n=(this.rows||[]).find(e=>String(e&&e.name||``).trim()===t);n&&n.managed||Ls.open({title:`Delete Provider`,titleId:`providerCredentialDeleteDialogTitle`,inputId:`provider-credential-delete-confirmation`,message:`Type "`+t+`" to permanently delete this provider credential. Requests routed to it will fail until it is reconfigured.`,requiredText:t,confirmLabel:`Delete Provider`,icon:ko,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.performDelete(t)})}},Wz=R(`Config`),Gz=R(` `,1),Kz=R(`
          `),qz=R(`
          NameTypeBase URLAuthModelsEnabledUpdatedActions
          `);function Jz(e,t){E(t,!0);var n=qz(),r=M(n),i=P(M(r));H(i,21,()=>$.filteredRows,e=>e.name,(e,t)=>{var n=Kz(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=e=>{z(e,Wz())};V(o,e=>{I(t).managed&&e(s)}),T(r);var c=P(r),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=M(h,!0);T(h);var _=P(h),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x,!0);T(x);var C=P(x),w=M(C),ee=M(w),te=e=>{var n=Gz(),r=N(n);{let e=O(()=>`Edit provider `+I(t).name);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>$.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>($.deletingName===I(t).name?`Deleting provider `:`Delete provider `)+I(t).name),n=O(()=>$.deletingName===I(t).name);gT(i,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>$.requestDelete(I(t).name),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return Fo},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)};V(ee,e=>{I(t).managed||e(te)}),T(w),T(C),T(n),F((e,n,r)=>{B(a,I(t).name),B(u,I(t).type),W(d,`title`,I(t).base_url||``),B(f,I(t).base_url||`—`),B(m,e),B(g,n),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).enabled,"auth-key-status-inactive":!I(t).enabled}),B(b,I(t).enabled?`Enabled`:`Disabled`),B(S,r)},[()=>Nz(I(t)),()=>Pz(I(t)),()=>us.formatTimestamp(I(t).updated_at)]),z(e,n)}),T(i),T(r),T(n),z(e,n),D()}var Yz=R(``),Xz=R(`
          `),Zz=R(`
          `,1),Qz=R(``),$z=R(``),eB=R(``),tB=R(``),nB=R(``),rB=R(` `),iB=R(` `),aB=R(`
          `);function oB(e,t){E(t,!0);let n=O(()=>`provider-credential-`+t.field.name),r=O(()=>$.fieldErrors[t.field.name]||``),i=O(()=>I(r)?I(n)+`-error`:t.field.hint?I(n)+`-hint`:void 0),a=O(()=>{let e=String($.form[t.field.name]||``).trim();return!e||t.field.options.includes(e)?t.field.options:[...t.field.options,e]});function o(){$.clearFieldError(t.field.name)}var s=aB(),c=M(s),l=M(c),u=P(l),d=e=>{z(e,Yz())};V(u,e=>{t.field.required&&e(d)}),T(c);var f=P(c,2),p=e=>{var t=Zz(),a=N(t);H(a,21,()=>$.form.api_keys,oi,(e,t,a)=>{var s=Xz(),c=M(s);na(c),W(c,`aria-label`,`API key `+(a+1)),gT(P(c,2),{label:`Remove API key `+(a+1),class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>$.removeApiKeyRow(a),children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}}),T(s),F(()=>{W(c,`id`,a===0?I(n):I(n)+`-`+a),W(c,`aria-invalid`,I(r)?`true`:void 0),W(c,`aria-describedby`,a===0?I(i):void 0)}),L(`input`,c,o),da(c,()=>I(t).value,e=>I(t).value=e),z(e,s)}),T(a);var s=P(a,2),c=M(s);K(M(c),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(c),T(s),F(()=>W(c,`id`,$.form.api_keys.length===0?I(n):void 0)),L(`click`,c,()=>$.addApiKeyRow()),z(e,t)},m=e=>{var s=$z(),c=M(s);c.value=c.__value=``,H(P(c),16,()=>I(a),e=>e,(e,t)=>{var n=Qz(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(s),F(()=>{W(s,`id`,I(n)),W(s,`aria-invalid`,I(r)?`true`:void 0),W(s,`aria-describedby`,I(i))}),L(`change`,s,o),Gi(s,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,s)},h=e=>{var a=eB();na(a),F(()=>{W(a,`id`,I(n)),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`change`,a,o),fa(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},g=e=>{var a=tB();ft(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},_=e=>{var a=nB();na(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)};V(f,e=>{t.field.control===`keys`?e(p):t.field.control===`select`?e(m,1):t.field.control===`checkbox`?e(h,2):t.field.control===`textarea`?e(g,3):e(_,-1)});var v=P(f,2),y=e=>{var t=rB(),i=M(t,!0);T(t),F(()=>{W(t,`id`,I(n)+`-error`),B(i,I(r))}),z(e,t)},b=e=>{var r=iB(),i=M(r,!0);T(r),F(()=>{W(r,`id`,I(n)+`-hint`),B(i,t.field.hint)}),z(e,r)};V(v,e=>{I(r)?e(y):t.field.hint&&e(b,1)}),T(s),F(()=>{W(c,`for`,I(n)),B(l,`${t.field.label??``} `)}),z(e,s),D()}Hr([`input`,`click`,`change`]);var sB=R(`

          The name is the stable identity used for routing and cannot change once created.

          `),cB=R(``),lB=R(` `),uB=R(`Determines which fields the gateway uses to build requests.`),dB=R(` `),fB=R(`Suggested from the selected type; used to route requests to this provider instance and editable before saving.`),pB=R(`Immutable once created.`),mB=R(`

          Pick a type to configure its credentials — each provider type asks for different settings.

          `),hB=R(`
          Advanced settings
          `),gB=R(`
          `,1);function _B(e,t){E(t,!0);let n=O(()=>Oz($.types,$.form.type)),r=O(()=>$.formFields),i=O(()=>$.fieldErrors.name||``),a=O(()=>$.fieldErrors.type||``);function o(){$.selectType(),$.formMode===`create`&&($.form.name=Lz($.rows,$.form.type))}An(()=>{let e=$.focusField;if(!e)return;$.focusField=``;let t=document.getElementById(`provider-credential-`+e);t&&(t.scrollIntoView({block:`center`}),t.focus({preventScroll:!0}))});{let t=e=>{z(e,sB())},s=O(()=>$.formMode===`edit`?`Edit Provider`:`Add Provider`);bE(e,{get open(){return $.formOpen},get title(){return I(s)},ariaLabel:`Provider credential editor`,get error(){return $.error},get submitting(){return $.formSubmitting},novalidate:!0,onclose:()=>$.closeForm(),onsubmit:()=>$.submitForm(),headerHint:t,children:(e,t)=>{var s=gB(),c=N(s),l=P(M(c),2),u=M(l);u.value=u.__value=``,H(P(u),16,()=>I(n),e=>e,(e,t)=>{var n=cB(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(l);var d=P(l,2),f=e=>{var t=lB(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)},p=e=>{z(e,uB())};V(d,e=>{I(a)?e(f):e(p,-1)}),T(c);var m=P(c,2),h=P(M(m),2);na(h);var g=P(h,2),_=e=>{var t=dB(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)},v=e=>{z(e,fB())},y=e=>{z(e,pB())};V(g,e=>{I(i)?e(_):$.formMode===`create`?e(v,1):e(y,-1)}),T(m);var b=P(m,2),x=e=>{z(e,mB())};V(b,e=>{$.form.type||e(x)});var S=P(b,2);H(S,17,()=>I(r).primary,e=>e.name,(e,t)=>{oB(e,{get field(){return I(t)}})});var C=P(S,2),w=M(C);bA(M(w),{get enabled(){return $.form.enabled},label:`provider`,onclick:()=>$.form.enabled=!$.form.enabled}),T(w),T(C);var ee=P(C,2),te=e=>{var t=hB(),n=M(t),i=M(n),a=P(M(i),2),o=M(a,!0);T(a),T(i),T(n);var s=P(n,2);H(s,21,()=>I(r).advanced,e=>e.name,(e,t)=>{oB(e,{get field(){return I(t)}})}),T(s),T(t),F(e=>{t.open=$.advancedOpen,B(o,e)},[()=>I(r).advanced.map(e=>e.label).join(`, `)]),Vr(`toggle`,t,e=>$.advancedOpen=e.currentTarget.open),z(e,t)};V(ee,e=>{I(r).advanced.length>0&&e(te)}),F(()=>{l.disabled=$.formMode===`edit`,W(l,`aria-invalid`,I(a)?`true`:void 0),W(l,`aria-describedby`,I(a)?`provider-credential-type-error`:`provider-credential-type-hint`),h.disabled=$.formMode===`edit`,W(h,`aria-invalid`,I(i)?`true`:void 0),W(h,`aria-describedby`,I(i)?`provider-credential-name-error`:`provider-credential-name-hint`)}),L(`change`,l,o),Gi(l,()=>$.form.type,e=>$.form.type=e),L(`input`,h,()=>$.clearFieldError(`name`)),da(h,()=>$.form.name,e=>$.form.name=e),z(e,s)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var vB=R(`

          Providers

          `),yB=R(``),bB=R(`
          Provider credential management is unavailable.
          `),xB=R(``),SB=R(`
          `),CB=R(`

          No dashboard-managed providers yet. Add one here, or declare providers in config.yaml / environment variables.

          `),wB=R(`

          No providers match your filter.

          `),TB=R(`
          `);function EB(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`providers-config`&&$.fetchPage()});var n=TB(),r=M(n),i=M(r);KS(M(i),{copyId:`providers-config-help-copy`,label:`model providers help`,title:e=>{z(e,vB())},help:e=>{Ue(),z(e,Zr(`Configure LLM provider credentials here instead of setting API keys as + environment variables. Providers declared in config.yaml or env vars + are read-only (Config badge) and cannot be edited or deleted from the + dashboard. Keys are masked after saving.`))},$$slots:{title:!0,help:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=yB();K(M(t),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=$.formSubmitting),L(`click`,t,()=>$.openCreate()),z(e,t)};V(o,e=>{$.available&&!q.needsAuth&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,bB())};V(c,e=>{!$.available&&!q.needsAuth&&e(l)});var u=P(c,2),d=e=>{var t=xB(),n=M(t,!0);T(t),F(()=>B(n,$.error)),z(e,t)};V(u,e=>{$.error&&!q.needsAuth&&!$.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading providers...`})};V(f,e=>{$.loading&&!q.needsAuth&&e(p)});var m=P(f,2),h=e=>{var t=SB(),n=M(t);yw(M(n),{id:`provider-credential-filter`,placeholder:`Filter by name, type, or base URL...`,label:`Filter providers by name, type, or base URL`,get value(){return $.filter},set value(e){$.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{($.rows.length>0||$.filter)&&$.available&&!q.needsAuth&&e(h)});var g=P(m,2);_B(g,{});var _=P(g,2),v=e=>{Jz(e,{})};V(_,e=>{$.filteredRows.length>0&&$.available&&!q.needsAuth&&e(v)});var y=P(_,2),b=e=>{z(e,CB())};V(y,e=>{$.rows.length===0&&!$.filter&&!$.loading&&!q.needsAuth&&!$.error&&$.available&&e(b)});var x=P(y,2),S=e=>{z(e,wB())};V(x,e=>{$.rows.length>0&&$.filteredRows.length===0&&$.filter&&!$.loading&&!q.needsAuth&&$.available&&e(S)}),T(n),z(e,n),D()}Hr([`click`]);function DB(){return{name:``,description:``,user_path:``,labels:``,dashboard_access:!1,expires_at:``}}function OB(e){let t=[];for(let n of String(e||``).split(`,`)){let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function kB(e){let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t;for(let e of n.split(`/`)){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function AB(e){if(kB(e))return``;let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t,r=[];for(let e of n.split(`/`)){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function jB(e){let t=e||{},n=String(t.name||``).trim();if(!n)return{error:`Name is required.`};let r=kB(t.user_path);if(r)return{error:r};let i=AB(t.user_path),a=OB(t.labels),o={name:n,description:String(t.description||``).trim()||void 0,user_path:i||void 0,labels:a.length?a:void 0,dashboard_access:t.dashboard_access?!0:void 0};return t.expires_at&&(o.expires_at=t.expires_at+`T23:59:59Z`),{payload:o}}function MB(e,t=Date.now()){let n=e&&e.expires_at;if(!n)return!1;let r=Date.parse(n);return Number.isFinite(r)&&r<=t}function NB(e){return e?!!e.deactivated_at||e.enabled===!1:!1}function PB(e,t=Date.now()){return!e||e.active===!1||NB(e)?!1:!MB(e,t)}function FB(e){return[e.name,e.description,e.user_path,e.redacted_value,...e.labels||[]].filter(Boolean).join(` `).toLowerCase()}function IB(e,t={}){let{query:n=``,showInactive:r=!1,now:i=Date.now()}=t,a=String(n||``).trim().toLowerCase();return(Array.isArray(e)?e:[]).filter(e=>!r&&!PB(e,i)?!1:!a||FB(e).includes(a))}function LB(e,t){return NB(e)?2:+!PB(e,t)}function RB(e){let t=e&&e.expires_at;if(!t)return 1/0;let n=Date.parse(t);return Number.isFinite(n)?n:1/0}function zB(e){let t=Date.parse(e&&e.deactivated_at||``);return Number.isFinite(t)?t:-1/0}function BB(e,t=Date.now()){return(Array.isArray(e)?e.slice():[]).sort((e,n)=>{let r=LB(e,t),i=LB(n,t);if(r!==i)return r-i;let[a,o]=r===2?[zB(e),zB(n)]:[RB(e),RB(n)];return a===o?String(e.name||``).localeCompare(String(n.name||``)):a>o?-1:1})}function VB(e,t=Date.now()){return(Array.isArray(e)?e:[]).reduce((e,n)=>e+ +!PB(n,t),0)}function HB(){return{open:!1,id:``,name:``,value:``,submitting:!1,error:``}}var UB=new class{#e=k(j([]));get keys(){return I(this.#e)}set keys(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get showInactive(){return I(this.#a)}set showInactive(e){A(this.#a,e,!0)}#o=O(()=>BB(IB(this.keys,{query:this.filter,showInactive:this.showInactive})));get visibleKeys(){return I(this.#o)}set visibleKeys(e){A(this.#o,e)}#s=O(()=>VB(this.keys));get inactiveCount(){return I(this.#s)}set inactiveCount(e){A(this.#s,e)}#c=k(!1);get formOpen(){return I(this.#c)}set formOpen(e){A(this.#c,e,!0)}#l=k(!1);get formSubmitting(){return I(this.#l)}set formSubmitting(e){A(this.#l,e,!0)}#u=k(``);get issuedValue(){return I(this.#u)}set issuedValue(e){A(this.#u,e,!0)}#d=k(``);get deactivatingID(){return I(this.#d)}set deactivatingID(e){A(this.#d,e,!0)}#f=k(``);get dashboardAccessID(){return I(this.#f)}set dashboardAccessID(e){A(this.#f,e,!0)}#p=k(j(DB()));get form(){return I(this.#p)}set form(e){A(this.#p,e,!0)}#m=k(j(HB()));get labelsEditor(){return I(this.#m)}set labelsEditor(e){A(this.#m,e,!0)}copyState=_M({logPrefix:`Failed to copy auth key:`});async fetchKeys(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/auth-keys`,{label:`auth keys`,errorFallback:`Unable to load API keys.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.keys=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.error=e.error;return}this.available=!0,this.keys=e.items}finally{this.loading=!1}}openForm(){this.formSubmitting||this.formOpen||(this.formOpen=!0,this.error=``,this.issuedValue||(this.copyState.reset(),this.form=DB()))}closeForm(){this.formOpen&&(this.formOpen=!1,this.error=``,this.copyState.reset(),!this.formSubmitting&&!this.issuedValue&&(this.form=DB()))}copyIssuedValue(){return this.copyState.copy(this.issuedValue)}dismissIssuedKey(){this.issuedValue=``,this.copyState.reset(),this.form=DB()}async submitForm(){let e=jB(this.form);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/auth-keys`,`POST`,e.payload,{label:`create API key`,errorFallback:`Failed to create API key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error,t.result&&t.result.status!==401&&console.error(`Failed to create API key:`,t.result.status,this.error);return}let n=t.result.data||{};this.issuedValue=n.value||``,this.formOpen=!0,this.copyState.reset(),this.form=DB(),this.fetchKeys()}finally{this.formSubmitting=!1}}openLabelsEditor(e){!e||this.labelsEditor.submitting||(this.labelsEditor={open:!0,id:e.id,name:e.name||``,value:(e.labels||[]).join(`, `),submitting:!1,error:``})}closeLabelsEditor(){!this.labelsEditor.open||this.labelsEditor.submitting||(this.labelsEditor=HB())}async submitLabelsEditor(){let e=this.labelsEditor;if(!e.open||e.submitting||!e.id)return;e.submitting=!0,e.error=``;let t={labels:OB(e.value)};try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/labels`,`PUT`,t,{label:`update API key labels`,errorFallback:`Failed to update labels.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,e.error=n.error;return}if(n.status===`error`){e.error=n.error,n.result&&n.result.status!==401&&console.error(`Failed to update auth key labels:`,n.result.status,e.error);return}J.success(`Labels updated for key "`+e.name+`".`),e.submitting=!1,this.closeLabelsEditor(),this.fetchKeys()}finally{e.submitting=!1}}async toggleDashboardAccess(e){if(!e||!e.active||this.dashboardAccessID)return;let t=!e.dashboard_access;this.dashboardAccessID=e.id;try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/dashboard-access`,`PUT`,{dashboard_access:t},{label:`update API key dashboard access`,errorFallback:`Failed to update dashboard access.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,J.error(n.error);return}if(n.status===`error`){n.result&&n.result.status!==401&&console.error(`Failed to update auth key dashboard access:`,n.result.status,n.error),J.error(n.error);return}J.success(`Dashboard access `+(t?`granted to`:`revoked for`)+` key "`+e.name+`".`),this.fetchKeys()}finally{this.dashboardAccessID=``}}async deactivateKey(e){if(!(!e||!e.active)&&window.confirm(`Deactivate key "`+e.name+`"? This cannot be undone.`)){this.deactivatingID=e.id;try{let t=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/deactivate`,`POST`,void 0,{label:`deactivate API key`,errorFallback:`Failed to deactivate key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,J.error(t.error);return}if(t.status===`error`){t.result&&t.result.status!==401&&console.error(`Failed to deactivate auth key:`,t.result.status,t.error),J.error(t.error);return}J.success(`Key "`+e.name+`" deactivated.`),this.fetchKeys()}finally{this.deactivatingID=``}}}},WB=R(``),GB=R(`

          Store this key securely — it won’t be shown again.

          `),KB=R(``),qB=R(``),JB=R(``),YB=R(``),XB=R(`
          `);function ZB(e,t){E(t,!0);{let t=O(()=>UB.issuedValue?``:UB.error),n=O(()=>UB.issuedValue?`Done, I’ve stored it`:`Create API Key`),r=O(()=>UB.issuedValue?Ba:fo);bE(e,{get open(){return UB.formOpen},title:`Create API Key`,ariaLabel:`API key editor`,get error(){return I(t)},get submitting(){return UB.formSubmitting},get submitLabel(){return I(n)},submittingLabel:`Creating...`,get submitIcon(){return I(r)},cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>UB.closeForm(),onsubmit:()=>UB.issuedValue?UB.dismissIssuedKey():UB.submitForm(),children:(e,t)=>{var n=Qr(),r=N(n),i=e=>{var t=GB(),n=P(M(t),2),r=M(n),i=M(r,!0);T(r),lL(P(r,2),{get state(){return UB.copyState},onclick:()=>UB.copyIssuedValue()}),T(n);var a=P(n,2),o=e=>{z(e,WB())};V(a,e=>{UB.copyState.error&&e(o)}),T(t),F(()=>B(i,UB.issuedValue)),z(e,t)},a=e=>{var t=XB(),n=M(t),r=M(n),i=P(M(r),2);na(i),T(r);var a=P(r,2),o=P(M(a),2);na(o),T(a),T(n);var s=P(n,2),c=M(s);KS(c,{copyId:`auth-key-user-path-help-copy`,label:`API key user path help`,title:e=>{z(e,KB())},help:e=>{Ue(),z(e,Zr(`When set, this key overrides the configured user path request + header for audit logging and downstream request context.`))},$$slots:{title:!0,help:!0}});var l=P(c,2);na(l),T(s);var u=P(s,2),d=M(u);KS(d,{copyId:`auth-key-labels-help-copy`,label:`API key labels help`,title:e=>{z(e,qB())},help:e=>{Ue(),z(e,Zr(`Every request authenticated with this key gets these labels, in + addition to any labels from tagging headers. Labels show up in + usage analytics, the request log, and audit logs.`))},$$slots:{title:!0,help:!0}});var f=P(d,2);na(f),T(u);var p=P(u,2),m=M(p);KS(m,{copyId:`auth-key-dashboard-access-help-copy`,label:`API key dashboard access help`,title:e=>{z(e,JB())},help:e=>{Ue(),z(e,Zr(`When off, this key is denied the dashboard and every /admin API + endpoint. Model endpoints and GET /v1/usage stay available to + the key. The master key always has dashboard access.`))},$$slots:{title:!0,help:!0}});var h=P(m,2),g=M(h);na(g),Ue(2),T(h),T(p),SE(P(p,2),{id:`auth-key-description`,label:`Description (optional)`,children:(e,t)=>{var n=YB();ft(n),da(n,()=>UB.form.description,e=>UB.form.description=e),z(e,n)},$$slots:{default:!0}}),T(t),da(i,()=>UB.form.name,e=>UB.form.name=e),da(o,()=>UB.form.expires_at,e=>UB.form.expires_at=e),da(l,()=>UB.form.user_path,e=>UB.form.user_path=e),da(f,()=>UB.form.labels,e=>UB.form.labels=e),fa(g,()=>UB.form.dashboard_access,e=>UB.form.dashboard_access=e),z(e,t)};V(r,e=>{UB.issuedValue?e(i):e(a,-1)}),z(e,n)},$$slots:{default:!0}})}D()}var QB=R(`

          `),$B=R(`

          Applies to new requests made with this key. Leave empty to remove all labels.

          `,1);function eV(e,t){E(t,!0),bE(e,{get open(){return UB.labelsEditor.open},title:`Edit Labels`,ariaLabel:`API key labels editor`,get error(){return UB.labelsEditor.error},get submitting(){return UB.labelsEditor.submitting},submitLabel:`Save Labels`,cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>UB.closeLabelsEditor(),onsubmit:()=>UB.submitLabelsEditor(),headerHint:e=>{var t=QB(),n=M(t,!0);T(t),F(()=>B(n,UB.labelsEditor.name)),z(e,t)},children:(e,t)=>{SE(e,{id:`auth-key-labels-edit`,label:`Labels (comma-separated)`,children:(e,t)=>{var n=$B(),r=N(n);na(r),Ue(2),da(r,()=>UB.labelsEditor.value,e=>UB.labelsEditor.value=e),z(e,n)},$$slots:{default:!0}})},$$slots:{headerHint:!0,default:!0}}),D()}var tV=R(` `),nV=R(`
          `),rV=R(``),iV=R(`Expired`),aV=R(` `),oV=R(` `,1),sV=R(`Deactivated`),cV=R(`
          `),lV=R(`
          NameDescriptionUser PathLabelsTokenDashboard Access ExpiresCreated
          `);function uV(e,t){E(t,!0);var n=lV(),r=M(n),i=M(r),a=M(i),o=P(M(a),5),s=M(o);K(P(M(s)),{get icon(){return eo},width:`13`,height:`13`}),T(s),T(o),Ue(3),T(a),T(i);var c=P(i);H(c,21,()=>UB.visibleKeys,e=>e.id,(e,t)=>{var n=cV();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i),s=M(o,!0);T(o);var c=P(o),l=M(c,!0);T(c);var u=P(c),d=M(u),f=e=>{var n=nV();H(n,20,()=>I(t).labels||[],e=>e,(e,t)=>{var n=tV(),r=M(n,!0);T(n),F(e=>{Hi(n,e),B(r,t)},[()=>Hy(t)]),z(e,n)}),T(n),z(e,n)},p=e=>{z(e,rV())};V(d,e=>{(I(t).labels||[]).length>0?e(f):e(p,-1)}),T(u);var m=P(u),h=M(m),g=M(h,!0);T(h),T(m);var _=P(m),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x),C=e=>{var n=aV(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{z(e,iV())},s=O(()=>MB(I(t)));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>fc(I(t).expires_at)]),z(e,n)},w=e=>{z(e,Zr(`—`))};V(S,e=>{I(t).expires_at?e(C):e(w,-1)}),T(x);var ee=P(x),te=M(ee,!0);T(ee);var ne=P(ee),re=M(ne),ie=M(re),ae=e=>{var n=oV(),r=N(n);{let e=O(()=>(I(t).dashboard_access?`Revoke dashboard access for API key `:`Grant dashboard access to API key `)+I(t).name),n=O(()=>!!UB.dashboardAccessID);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>UB.toggleDashboardAccess(I(t)),get disabled(){return I(n)},children:(e,n)=>{{let n=O(()=>I(t).dashboard_access?Co:So);K(e,{get icon(){return I(n)},class:`table-icon-svg`})}},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>`Edit labels for API key `+I(t).name);gT(i,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>UB.openLabelsEditor(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}var a=P(i,2);{let e=O(()=>(UB.deactivatingID===I(t).id?`Deactivating API key `:`Deactivate API key `)+I(t).name),n=O(()=>UB.deactivatingID===I(t).id);gT(a,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>UB.deactivateKey(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return po},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)},oe=e=>{var n=sV();F(e=>W(n,`title`,e),[()=>I(t).deactivated_at?`Deactivated on `+pc(I(t).deactivated_at):`Deactivated`]),z(e,n)},se=O(()=>NB(I(t)));V(ie,e=>{I(t).active?e(ae):I(se)&&e(oe,1)}),T(re),T(ne),T(n),F((e,i,o)=>{r=U(n,1,`svelte-nf0ldb`,null,r,e),B(a,I(t).name),B(s,I(t).description||`—`),B(l,I(t).user_path||`—`),B(g,I(t).redacted_value),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).dashboard_access,"auth-key-status-inactive":!I(t).dashboard_access}),B(b,I(t).dashboard_access?`Allowed`:`Denied`),W(x,`title`,i),B(te,o)},[()=>({"auth-key-row-deactivated":NB(I(t))}),()=>I(t).expires_at?pc(I(t).expires_at):``,()=>us.formatTimestamp(I(t).created_at)]),z(e,n)}),T(c),T(r),T(n),z(e,n),D()}var dV=R(``),fV=R(`
          API key management is unavailable.
          `),pV=R(``),mV=R(`

          Managed API keys authenticate requests to the gateway. Deactivation is + permanent — create a new key if access needs to be restored.

          `),hV=R(`
          `),gV=R(`
          `),_V=R(`

          `),vV=R(`

          No API keys yet. Issue a key to get started.

          `),yV=R(`
          `);function bV(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`auth-keys`&&UB.fetchKeys()});var n=yV(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=dV();K(M(t),{get icon(){return fo},class:`table-icon-svg`}),Ue(2),T(t),F(()=>t.disabled=UB.formSubmitting),L(`click`,t,()=>{UB.formSubmitting||UB.openForm()}),z(e,t)};V(a,e=>{UB.available&&!q.authError&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,fV())};V(s,e=>{!UB.available&&!q.authError&&e(c)});var l=P(s,2),u=e=>{var t=pV(),n=M(t,!0);T(t),F(()=>B(n,UB.error)),z(e,t)};V(l,e=>{UB.error&&!q.authError&&!UB.formOpen&&e(u)});var d=P(l,2),f=e=>{z(e,mV())};V(d,e=>{UB.available&&!q.authError&&e(f)});var p=P(d,2);ZB(p,{});var m=P(p,2);eV(m,{});var h=P(m,2),g=e=>{var t=hV();xS(M(t),{size:18,label:`Loading API keys`}),T(t),z(e,t)};V(h,e=>{UB.loading&&UB.keys.length===0&&e(g)});var _=P(h,2),v=e=>{var t=gV(),n=M(t);yw(M(n),{placeholder:`Filter by name, description, user path, label, or token...`,label:`Filter API keys by name, description, user path, label, or token`,get value(){return UB.filter},set value(e){UB.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i);na(a);var o=P(a,2),s=P(M(o)),c=e=>{var t=Zr();F(()=>B(t,`(${UB.inactiveCount??``})`)),z(e,t)};V(s,e=>{UB.inactiveCount>0&&e(c)}),T(o),T(i),T(r),T(t),fa(a,()=>UB.showInactive,e=>UB.showInactive=e),z(e,t)};V(_,e=>{UB.keys.length>0&&UB.available&&e(v)});var y=P(_,2),b=e=>{uV(e,{})};V(y,e=>{UB.visibleKeys.length>0&&UB.available&&e(b)});var x=P(y,2),S=e=>{var t=_V(),n=M(t);T(t),F(()=>B(n,`No API keys match the current filter.${UB.inactiveCount>0&&!UB.showInactive?` `+UB.inactiveCount+` inactive `+(UB.inactiveCount===1?`key is`:`keys are`)+` hidden.`:``}`)),z(e,t)};V(x,e=>{UB.keys.length>0&&UB.visibleKeys.length===0&&UB.available&&e(S)});var C=P(x,2),w=e=>{z(e,vV())};V(C,e=>{UB.keys.length===0&&!UB.loading&&!q.authError&&!UB.error&&UB.available&&e(w)}),T(n),z(e,n),D()}Hr([`click`]);var xV=R(`

          Timezone

          `),SV=R(``),CV=R(``),wV=R(`
          `,1);function TV(e,t){E(t,!0);function n(){us.saveOverride(),q.refresh()}function r(){us.clearOverride(),q.refresh()}var i=wV(),a=N(i);KS(M(a),{copyId:`timezone-help-copy`,label:`timezone help`,text:`Day-based analytics, charts, and date filters use your effective timezone. Usage and audit logs keep UTC in the hover title while rendering row timestamps in your effective timezone.`,title:e=>{z(e,xV())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=P(M(s),2),l=M(c),u=M(l);T(l),l.value=l.__value=``,H(P(l),17,()=>us.options,e=>e.value,(e,t)=>{var n=SV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(c),T(s),T(o);var d=P(o,2),f=M(d),p=e=>{var t=CV();L(`click`,t,r),z(e,t)};V(f,e=>{us.override&&e(p)}),T(d),F(e=>B(u,`Automatic (${e??``})`),[()=>us.detectedTimeZoneLabel()]),Vr(`focus`,c,()=>us.ensureOptions()),L(`change`,c,n),Gi(c,()=>us.override,e=>us.override=e),z(e,i),D()}Hr([`change`,`click`]);var EV=R(``),DV=R(`

          Failover

          `,1);function OV(e,t){E(t,!0);let n=O(()=>Z.failoverSaving||Z.failoverGenerating||Z.failoverDraftSaving||!Z.failoverAvailable||!Z.failoverEnabled());var r=DV(),i=N(r),a=P(M(i),2),o=M(a),s=M(o);K(s,{get icon(){return No},class:`form-action-icon`});var c=P(s,2),l=M(c,!0);T(c),T(o);var u=P(o,2);K(M(u),{get icon(){return ko},class:`form-action-icon`}),Ue(2),T(u),T(a),T(i);var d=P(i,2),f=M(d),p=e=>{var t=EV(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(f,e=>{Z.failoverError&&e(p)}),T(d),fj(P(d,2),{}),F(()=>{o.disabled=I(n),B(l,Z.failoverGenerating?`Generating...`:`Generate failover models automatically`),u.disabled=I(n)}),L(`click`,o,()=>Z.generateFailoverRules()),L(`click`,u,()=>Z.openFailoverResetDialog()),z(e,r),D()}Hr([`click`]);function kV(){return{daily_reset_hour:0,daily_reset_minute:0,weekly_reset_weekday:1,weekly_reset_hour:0,weekly_reset_minute:0,monthly_reset_day:1,monthly_reset_hour:0,monthly_reset_minute:0}}function AV(e,t){let n=t||{},r=(e,t)=>{if(e===``)return t;let n=Number(e);return Number.isFinite(n)&&Number.isInteger(n)?Math.trunc(n):t},i=(e,t)=>r(n[e],t),a=(t,n)=>e?r(e[t],n):n;return{daily_reset_hour:a(`daily_reset_hour`,i(`daily_reset_hour`,0)),daily_reset_minute:a(`daily_reset_minute`,i(`daily_reset_minute`,0)),weekly_reset_weekday:a(`weekly_reset_weekday`,i(`weekly_reset_weekday`,1)),weekly_reset_hour:a(`weekly_reset_hour`,i(`weekly_reset_hour`,0)),weekly_reset_minute:a(`weekly_reset_minute`,i(`weekly_reset_minute`,0)),monthly_reset_day:a(`monthly_reset_day`,i(`monthly_reset_day`,1)),monthly_reset_hour:a(`monthly_reset_hour`,i(`monthly_reset_hour`,0)),monthly_reset_minute:a(`monthly_reset_minute`,i(`monthly_reset_minute`,0))}}function jV(){return[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}]}var MV=R(`

          Budget Resets

          `),NV=R(``),PV=R(`

          If the selected day does not exist in a month, the reset runs on + the last day of that month.

          `),FV=R(``),IV=R(``),LV=R(`
          Monthly
          Weekly
          Daily
          `,1);function RV(e,t){E(t,!0);let n=k(j(kV())),r=k(!1),i=k(!1),a=k(``),o=k(!1),s=O(()=>xs.budgetsVisible());async function c(){if(await xs.ensureLoaded(),!xs.budgetsVisible()){A(a,``);return}A(r,!0),A(a,``);try{let e=await gs(`/admin/budgets/settings`,{label:`budget settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load budget settings.`);return}A(n,AV(e.data,I(n)),!0)}catch(e){console.error(`Failed to fetch budget settings:`,e),A(a,`Unable to load budget settings.`)}finally{A(r,!1)}}async function l(){if(!I(i)){A(i,!0);try{let e=await _s(`/admin/budgets/settings`,`PUT`,AV(I(n),I(n)),{label:`budget settings`});if(e.stale)return;if(!e.ok){J.error(`Unable to save budget settings.`);return}A(n,AV(e.data,I(n)),!0),A(a,``),J.success(`Budget settings saved.`)}catch(e){console.error(`Failed to save budget settings:`,e),J.error(`Unable to save budget settings.`)}finally{A(i,!1)}}}An(()=>{q.refreshTick,c()});var u=Qr(),d=N(u),f=e=>{var t=LV(),s=N(t),c=M(s);KS(c,{copyId:`budget-settings-help-copy`,label:`budget help`,text:`Budget reset anchors are stored in the database and evaluated in UTC. Hourly budgets reset at the top of each hour.`,title:e=>{z(e,MV())},$$slots:{title:!0}});var u=P(c,2),d=M(u),f=P(M(d),2),p=M(f);KS(p,{copyId:`budget-monthly-day-help-copy`,label:`day of month help`,external:!0,get open(){return I(o)},set open(e){A(o,e,!0)},title:e=>{z(e,NV())},$$slots:{title:!0}});var m=P(p,2);na(m),T(f);var h=P(f,2),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=M(y),x=e=>{z(e,PV())};V(b,e=>{I(o)&&e(x)}),T(y),T(d);var S=P(d,2),C=P(M(S),2),w=P(M(C),2);H(w,21,jV,e=>e.value,(e,t)=>{var n=FV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(w),T(C);var ee=P(C,2),te=P(M(ee),2);na(te),T(ee);var ne=P(ee,2),re=P(M(ne),2);na(re),T(ne),Ue(2),T(S);var ie=P(S,2),ae=P(M(ie),4),oe=P(M(ae),2);na(oe),T(ae);var se=P(ae,2),ce=P(M(se),2);na(ce),T(se),Ue(2),T(ie),T(u);var le=P(u,2),ue=M(le);K(M(ue),{get icon(){return go},class:`form-action-icon`}),Ue(2),T(ue);var de=P(ue,2),fe=e=>{xS(e,{size:16,label:`Loading budget settings`})};V(de,e=>{I(r)&&e(fe)}),T(le),T(s);var pe=P(s,2),me=M(pe),he=e=>{var t=IV(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(me,e=>{I(a)&&e(he)}),T(pe),F(()=>{ue.disabled=I(i)||I(r),W(ue,`aria-busy`,I(i)?`true`:`false`)}),da(m,()=>I(n).monthly_reset_day,e=>I(n).monthly_reset_day=e),da(g,()=>I(n).monthly_reset_hour,e=>I(n).monthly_reset_hour=e),da(v,()=>I(n).monthly_reset_minute,e=>I(n).monthly_reset_minute=e),Gi(w,()=>I(n).weekly_reset_weekday,e=>I(n).weekly_reset_weekday=e),da(te,()=>I(n).weekly_reset_hour,e=>I(n).weekly_reset_hour=e),da(re,()=>I(n).weekly_reset_minute,e=>I(n).weekly_reset_minute=e),da(oe,()=>I(n).daily_reset_hour,e=>I(n).daily_reset_hour=e),da(ce,()=>I(n).daily_reset_minute,e=>I(n).daily_reset_minute=e),L(`click`,ue,l),z(e,t)};V(d,e=>{I(s)&&e(f)}),z(e,u),D()}Hr([`click`]);var zV=R(`

          Reset All Budgets

          Start new budget periods for every configured budget without changing + the limits.

          `);function BV(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=zV(),n=P(M(t),2),r=M(n);K(M(r),{get icon(){return ho},class:`form-action-icon`}),Ue(2),T(r),T(n),T(t),F(()=>r.disabled=Y.resetAllLoading),L(`click`,r,()=>Y.openResetDialog()),z(e,t)},a=O(()=>xs.budgetsVisible());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}Hr([`click`]);function VV(){return{header:``,prefix:``,do_not_pass:!1,delimiter:``,managed:!1}}function HV(e){return(e&&Array.isArray(e.headers)?e.headers:[]).map(e=>({header:typeof e.header==`string`?e.header:``,prefix:typeof e.prefix==`string`?e.prefix:``,do_not_pass:e.do_not_pass===!0,delimiter:typeof e.delimiter==`string`&&e.delimiter!==`,`?e.delimiter:``,managed:e.managed===!0}))}function UV(e){return{headers:(Array.isArray(e)?e:[]).filter(e=>!e.managed&&e.header.trim()!==``).map(e=>({header:e.header.trim(),prefix:e.prefix,do_not_pass:e.do_not_pass,delimiter:e.delimiter}))}}function WV(e){return e&&e.error&&e.error.message?e.error.message:``}var GV=R(`

          Tagging based on headers

          `),KV=R(`config`),qV=R(``),JV=R(`
          `),YV=R(`

          No tagging headers configured. Requests are not labelled.

          `),XV=R(``),ZV=R(`
          `,1);function QV(e,t){E(t,!0);let n=k(j([])),r=k(!0),i=k(!1),a=k(!1),o=k(``);function s(){I(n).push(VV())}function c(e){let t=I(n)[e];!t||t.managed||I(n).splice(e,1)}async function l(){A(i,!0),A(o,``);try{let e=await gs(`/admin/tagging/settings`,{label:`tagging settings`});if(e.stale)return;if(!e.ok){A(o,`Unable to load tagging settings.`);return}A(n,HV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0)}catch(e){console.error(`Failed to fetch tagging settings:`,e),A(o,`Unable to load tagging settings.`)}finally{A(i,!1)}}async function u(){if(!(I(a)||!I(r))){A(a,!0);try{let e=await _s(`/admin/tagging/settings`,`PUT`,UV(I(n)),{label:`tagging settings`});if(e.stale)return;if(!e.ok){J.error(e.status!==401&&WV(e.data)||`Unable to save tagging settings.`);return}A(n,HV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0),A(o,``),J.success(`Tagging settings saved.`)}catch(e){console.error(`Failed to save tagging settings:`,e),J.error(`Unable to save tagging settings.`)}finally{A(a,!1)}}}An(()=>{q.refreshTick,l()});var d=ZV(),f=N(d),p=M(f);KS(p,{copyId:`tagging-settings-help-copy`,label:`tagging help`,text:`Each request is labelled from the listed headers; labels land in usage tracking and audit logs. A header value can carry several labels split by the delimiter (default: comma). The prefix is trimmed from each label only — the header itself is forwarded unchanged unless 'Do not pass' is checked. Rows marked CONFIG come from config.yaml or TAGGING_HEADER_* env vars and are read-only here.`,title:e=>{z(e,GV())},$$slots:{title:!0}});var m=P(p,2),h=M(m);H(h,17,()=>I(n),oi,(e,t,n)=>{var i=JV(),a=M(i),o=M(a);W(o,`for`,`tagging-header-`+n);var s=P(o,2);na(s),W(s,`id`,`tagging-header-`+n),T(a);var l=P(a,2),u=M(l);W(u,`for`,`tagging-prefix-`+n);var d=P(u,2);na(d),W(d,`id`,`tagging-prefix-`+n),T(l);var f=P(l,2),p=M(f);W(p,`for`,`tagging-delimiter-`+n);var m=P(p,2);na(m),W(m,`id`,`tagging-delimiter-`+n),T(f);var h=P(f,2),g=M(h);na(g),Ue(2),T(h);var _=P(h,2),v=M(_),y=e=>{z(e,KV())},b=e=>{var i=qV();F(()=>{i.disabled=!I(r),W(i,`aria-label`,`Remove tagging header `+(I(t).header||n+1))}),L(`click`,i,()=>c(n)),z(e,i)};V(v,e=>{I(t).managed?e(y):e(b,-1)}),T(_),T(i),F(()=>{s.disabled=I(t).managed||!I(r),d.disabled=I(t).managed||!I(r),m.disabled=I(t).managed||!I(r),g.disabled=I(t).managed||!I(r)}),da(s,()=>I(t).header,e=>I(t).header=e),da(d,()=>I(t).prefix,e=>I(t).prefix=e),da(m,()=>I(t).delimiter,e=>I(t).delimiter=e),fa(g,()=>I(t).do_not_pass,e=>I(t).do_not_pass=e),z(e,i)});var g=P(h,2),_=e=>{xS(e,{size:16,label:`Loading tagging settings`})};V(g,e=>{I(i)&&e(_)});var v=P(g,2),y=e=>{z(e,YV())};V(v,e=>{!I(i)&&I(n).length===0&&e(y)}),T(m);var b=P(m,2),x=M(b);K(M(x),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(x);var S=P(x,2);K(M(S),{get icon(){return go},class:`form-action-icon`}),Ue(2),T(S),T(b),T(f);var C=P(f,2),w=M(C),ee=e=>{var t=XV(),n=M(t,!0);T(t),F(()=>B(n,I(o))),z(e,t)};V(w,e=>{I(o)&&e(ee)}),T(C),F(()=>{x.disabled=!I(r)||I(a)||I(i),S.disabled=!I(r)||I(a)||I(i),W(S,`aria-busy`,I(a)?`true`:`false`)}),L(`click`,x,s),L(`click`,S,u),z(e,d),D()}Hr([`click`]);function $V(e){let t=e||{};if(t.selectedPreset)return{days:parseInt(t.selectedPreset,10)||30};let n=t.customStartDate?dc(t.customStartDate):``,r=t.customEndDate||t.today||null;return{start_date:n,end_date:r?dc(r):``}}function eH(e,t,n,r){return{...$V(e),user_path:String(t||``).trim(),selector:String(n||``).trim(),confirmation:r}}function tH(e){let t=Number(e&&e.matched||0),n=Number(e&&e.recalculated||0),r=Number(e&&e.without_pricing||0),i=`Pricing recalculated for `+n+` of `+t+` usage record`+(t===1?``:`s`)+`.`;return r>0&&(i+=` `+r+` usage record`+(r===1?` still lacks`:`s still lack`)+` pricing metadata.`),i}var nH=R(`

          Usage Pricing Recalculation

          `),rH=R(`
          `);function iH(e,t){E(t,!0);let n=k(``),r=k(``),i=k(!1),a=O(()=>xs.booleanFlag(`USAGE_PRICING_RECALCULATION_ENABLED`,!1));function o(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}I(i)||Ls.open({title:`Recalculate Pricing`,titleId:`pricingRecalculateDialogTitle`,inputId:`pricing-recalculate-confirmation`,requiredText:`recalculate`,confirmLabel:`Recalculate Pricing`,icon:Fa,dialogClass:`pricing-recalculate-dialog`,message:`Stored usage cost fields matching the selected filters will be overwritten.`,onConfirm:()=>s()})}async function s(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}if(!I(i)){A(i,!0);try{let e=await _s(`/admin/usage/recalculate-pricing`,`POST`,eH({selectedPreset:jc.selectedPreset,customStartDate:jc.customStartDate,customEndDate:jc.customEndDate,today:us.todayDate()},I(n),I(r),`recalculate`),{label:`pricing recalculation`});if(e.stale)return;if(!e.ok){Ls.error=`Unable to recalculate pricing.`;return}Ls.close(),J.success(tH(e.data)),Lc.fetchUsage()}catch(e){console.error(`Failed to recalculate pricing:`,e),Ls.error=`Unable to recalculate pricing.`}finally{A(i,!1)}}}var c=Qr(),l=N(c),u=e=>{var t=rH(),s=M(t);KS(s,{copyId:`pricing-recalculate-help-copy`,label:`pricing recalculation help`,text:`Recalculate stored input, output, total, and Pro Saved costs from the current model pricing metadata. This overwrites matching historical cost fields. Filters are applied to the selected date range, user path subtree, and provider/model selector or alias.`,title:e=>{z(e,nH())},$$slots:{title:!0}});var c=P(s,2),l=M(c),u=P(M(l),2);el(M(u),{}),T(u),T(l);var d=P(l,2),f=P(M(d),2);na(f),T(d);var p=P(d,2),m=P(M(p),2);na(m),T(p),T(c);var h=P(c,2),g=M(h);K(M(g),{get icon(){return Fa},class:`form-action-icon`}),Ue(2),T(g),T(h),T(t),F(()=>{g.disabled=I(i)||!I(a),W(g,`aria-busy`,I(i)?`true`:`false`)}),da(f,()=>I(n),e=>A(n,e)),da(m,()=>I(r),e=>A(r,e)),L(`click`,g,o),z(e,t)};V(l,e=>{I(a)&&e(u)}),z(e,c),D()}Hr([`click`]);function aH(e){return String(e&&e.status||`ok`).toLowerCase()}function oH(e){if(!e||typeof e!=`object`)return`Runtime refresh completed.`;let t=Number(e.model_count||0),n=Number(e.provider_count||0),r=aH(e);return(r===`ok`?`Runtime refreshed.`:r===`partial`?`Runtime refresh completed with warnings.`:`Runtime refresh failed.`)+` `+t+` model`+(t===1?``:`s`)+` across `+n+` provider`+(n===1?``:`s`)+`.`}function sH(e){return!!e&&aH(e)===`ok`}function cH(e){let t=e&&e.steps;return Array.isArray(t)?t:[]}function lH(e){let t=String(e&&e.name||``).replace(/_/g,` `),n=String(e&&e.status||``).trim(),r=String(e&&(e.error||e.message)||``).trim();return t?r?t+`: `+n+` - `+r:t+`: `+n:r||n||``}var uH=R(`

          Runtime Refresh

          `),dH=R(`
        • `),fH=R(`
            `),pH=R(`
            `,1);function mH(e,t){E(t,!0);let n=k(!1),r=k(null);async function i(){if(!I(n)){A(n,!0),A(r,null);try{let e=await _s(`/admin/runtime/refresh`,`POST`,void 0,{label:`runtime refresh`});if(e.stale)return;if(!e.ok){J.error(`Runtime refresh failed.`);return}A(r,e.data&&typeof e.data==`object`?e.data:null,!0),sH(I(r))?J.success(oH(I(r))):J.error(oH(I(r))),q.refresh()}catch(e){console.error(`Failed to refresh runtime:`,e),J.error(`Runtime refresh failed.`)}finally{A(n,!1)}}}var a=pH(),o=N(a),s=M(o);KS(s,{copyId:`runtime-refresh-help-copy`,label:`runtime refresh help`,text:`Pull the latest model metadata, provider inventory, API keys, aliases, model access rules, guardrails, and workflows.`,title:e=>{z(e,uH())},$$slots:{title:!0}});var c=P(s,2),l=M(c);let u;K(M(l),{get icon(){return mo},class:`settings-refresh-icon`}),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=M(d),p=e=>{var t=fH();H(t,21,()=>cH(I(r)),e=>e.name,(e,t)=>{var n=dH(),r=M(n,!0);T(n),F(e=>{U(n,1,`runtime-refresh-step is-${I(t).status??``}`,`svelte-yeq2mp`),B(r,e)},[()=>lH(I(t))]),z(e,n)}),T(t),z(e,t)},m=O(()=>cH(I(r)).length>0);V(f,e=>{I(m)&&e(p)}),T(d),F(()=>{u=U(l,1,`btn btn-primary btn-with-icon settings-refresh-btn`,null,u,{"is-refreshing":I(n)}),l.disabled=I(n),W(l,`aria-busy`,I(n)?`true`:`false`)}),L(`click`,l,i),z(e,a),D()}Hr([`click`]);var hH=R(``),gH=R(`

            `),_H=R(`

            `),vH=R(``),yH=R(`
            `),bH=R(`

            AI Processing

            `);function xH(e,t){E(t,!0);let n=k(j([])),r=k(!1),i=k(``),a=k(``);async function o(){A(r,!0),A(a,``);try{let e=await gs(`/admin/runtime/settings`,{label:`runtime settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load runtime settings.`);return}A(n,Array.isArray(e.data?.settings)?e.data.settings:[],!0)}catch(e){console.error(`Failed to load runtime settings:`,e),A(a,`Unable to load runtime settings.`)}finally{A(r,!1)}}async function s(e,t,r){if(!(e.locked||I(i))){A(i,e.key,!0);try{let i=await _s(`/admin/runtime/settings/${encodeURIComponent(e.key)}`,`PUT`,{value:t},{label:`save ${e.label}`});if(i.stale){r.value=e.value;return}if(!i.ok){r.value=e.value,J.error(`Unable to save ${e.label}.`);return}A(n,I(n).map(t=>t.key===e.key?i.data:t),!0),J.success(`${e.label} saved.`)}catch(t){r.value=e.value,console.error(`Failed to save runtime setting:`,t),J.error(`Unable to save ${e.label}.`)}finally{A(i,``)}}}An(()=>{q.refreshTick,o()});var c=Qr(),l=N(c),u=e=>{var t=bH(),o=M(t),c=P(M(o),2),l=e=>{var t=hH(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(c,e=>{I(a)&&e(l)}),T(o);var u=P(o,2);H(u,21,()=>I(n),e=>e.key,(e,t)=>{var n=yH(),r=M(n),a=M(r),o=M(a,!0);T(a);var c=P(a,2),l=e=>{var n=gH(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(c,e=>{I(t).description&&e(l)});var u=P(c,2),d=e=>{var n=_H(),r=M(n);T(n),F(()=>B(r,`Managed by ${(I(t).managed_by||`environment`)??``}`)),z(e,n)};V(u,e=>{I(t).locked&&e(d)}),T(r);var f=P(r,2);H(f,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=vH(),r=M(n,!0);T(n);var i={};F(()=>{W(n,`title`,I(t).description||``),B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(f);var p;Wi(f),T(n),F(()=>{W(a,`for`,`runtime-setting-${I(t).key}`),B(o,I(t).label),W(f,`id`,`runtime-setting-${I(t).key}`),f.disabled=I(t).locked||I(i)!==``,p!==(p=I(t).value)&&(f.value=(f.__value=I(t).value)??``,Ui(f,I(t).value))}),L(`change`,f,e=>s(I(t),e.currentTarget.value,e.currentTarget)),z(e,n)}),T(u),T(t),F(()=>W(u,`aria-busy`,I(r)?`true`:`false`)),z(e,t)};V(l,e=>{(I(n).length>0||I(a))&&e(u)}),z(e,c),D()}Hr([`change`]);var SH=R(`
            `);function CH(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`settings`&&(us.ensureOptions(),xs.ensureLoaded())});var n=SH(),r=P(M(n),2),i=M(r);TV(i,{});var a=P(i,2);OV(a,{});var o=P(a,2);RV(o,{});var s=P(o,2);BV(s,{});var c=P(s,2);QV(c,{});var l=P(c,2);xH(l,{});var u=P(l,2);iH(u,{}),mH(P(u,2),{}),T(r);var d=P(r,2),f=M(d,!0);T(d),T(n),F(e=>B(f,e),[()=>Ho()]),z(e,n),D()}var wH=R(`
            `),TH=R(`
             
            `),EH=R(`
             
            `),DH=R(`
             
            `),OH=R(`
            `),kH=R(`
            `,1),AH=R(`
            `);function jH(e,t){E(t,!0);let n=G(t,`showPromptCache`,3,!0),r=O(()=>t.msg.role===`function_call`||t.msg.role===`function_result`);function i(e){return(Math.max(0,Math.min(1,Number(e||0)))*100).toFixed(1)+`%`}function a(e){let t=Math.max(0,Math.min(1,Number(e||0)));return t>0?Math.round(t*100)+`% of this visible prompt item is estimated provider-cached`:void 0}function o(e){return e.role===`function_call`?(e.toolCalls||[]).map(e=>e.name+`()`).join(`, `):(e.functionName?e.functionName+`: `:``)+e.text}var s=AH();let c;var l=M(s),u=e=>{var r=TH(),i=M(r),s=M(i),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l);var d=P(l,2),f=M(d,!0);T(d),T(i);var p=P(i,2),m=e=>{var n=wH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${t.msg.functionCallID??``}`)),z(e,n)};V(p,e=>{t.msg.functionCallID&&e(m)});var h=P(p,2),g=e=>{var n=Qr();H(N(n),17,()=>t.msg.toolCalls,oi,(e,n)=>{var r=Qr(),i=N(r),a=e=>{var r=wH(),i=M(r);T(r),F(()=>B(i,`Call ID${t.msg.toolCalls.length>1?` (`+I(n).name+`)`:``}: ${I(n).id??``}`)),z(e,r)};V(i,e=>{I(n).id&&e(a)}),z(e,r)}),z(e,n)};V(h,e=>{t.msg.role===`function_call`&&t.msg.toolCalls&&e(g)});var _=P(h,2),v=M(_,!0);T(_),T(r),F((e,n,i,a)=>{W(r,`title`,e),B(c,t.msg.roleLabel),B(u,n),B(f,i),B(v,a)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>o(t.msg),()=>us.formatTimestamp(t.msg.timestamp),()=>KI(t.msg)]),z(e,r)},d=e=>{var r=kH(),i=N(r),o=M(i),s=M(o,!0);T(o);var c=P(o,2),l=M(c,!0);T(c),T(i);var u=P(i,2),d=e=>{var r=EH(),i=M(r,!0);T(r),F(e=>{W(r,`title`,e),B(i,t.msg.text)},[()=>n()?a(t.msg.promptCacheRatio):void 0]),z(e,r)};V(u,e=>{t.msg.text&&e(d)});var f=P(u,2),p=e=>{var n=OH();H(n,23,()=>t.msg.toolCalls,(e,t)=>e.name+`-`+t,(e,t)=>{var n=DH(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(r);var c=P(r,2),l=e=>{var n=wH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${I(t).id??``}`)),z(e,n)};V(c,e=>{I(t).id&&e(l)});var u=P(c,2),d=M(u,!0);T(u),T(n),F((e,n)=>{B(a,I(t).name+`()`),B(s,e),B(d,n)},[()=>qI(I(t))||`No arguments`,()=>qI(I(t))||`No arguments`]),z(e,n)}),T(n),z(e,n)};V(f,e=>{t.msg.toolCalls&&e(p)}),F((e,n)=>{W(i,`title`,e),B(s,t.msg.roleLabel),B(l,n)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>us.formatTimestamp(t.msg.timestamp)]),z(e,r)};V(l,e=>{I(r)?e(u):e(d,-1)}),T(s),F(e=>{U(s,1,Fi([I(r)?`chat-function-note`:`chat-message`,t.msg.roleClass,{"is-anchor":t.msg.isAnchor,"is-after-anchor":t.msg.isAfterAnchor}]),`svelte-12s99s5`),W(s,`data-conversation-anchor`,t.msg.isAnchor?`true`:void 0),W(s,`data-entry-id`,t.msg.entryID),c=Hi(s,``,c,e)},[()=>({"--prompt-cache-fill":i(t.msg.promptCacheRatio),"--prompt-cache-visibility":n()&&t.msg.promptCacheRatio>0?`1`:`0`})]),z(e,s),D()}function MH(e,t=0){let n=Math.max(0,FH(e)-Math.max(0,FH(t))),r=Math.min(320,Math.max(180,Math.floor(n*.58))),i=Math.min(360,Math.max(128,Math.floor(n*.35)));return{min:r,max:Math.max(r,n-i)}}function NH(e,t,n=0){let r=MH(t,n),i=FH(e)||520;return Math.min(r.max,Math.max(r.min,Math.round(i)))}function PH(e,t,n=0){return NH(FH(t)-FH(e),t,n)}function FH(e){let t=Number(e);return Number.isFinite(t)?t:0}var IH=R(`
            `),LH=R(`

            Loading interactions...

            `),RH=R(`

            No interaction data available for this entry.

            `),zH=R(``),BH=R(`
            `,1),VH=R(`

            Showing the newest part of this session and the selected log.

            `),HH=R(`
            `),UH=R(``),WH=R(`
            `),GH=R(``),KH=R(``);function qH(e,t){E(t,!0);let n=tL,r=Number(wa(`gomodel_interactions_panel_width`)),i=`gomodel_interactions_prompt_cache_fill`,a=Number.isFinite(r)&&r>0?r:520,o=k(j(a)),s=k(320),c=k(760),l=k(!1),u=k(wa(i,`true`)!==`false`),d=null;function f(){A(u,!I(u)),Ta(i,I(u))}function p(){return(document.querySelector(`.sidebar`)?.getBoundingClientRect().width||0)+(document.querySelector(`.sidebar-toggle`)?.getBoundingClientRect().width||0)}function m(){let e=p(),t=MH(window.innerWidth,e);A(s,t.min,!0),A(c,t.max,!0),A(o,NH(a,window.innerWidth,e),!0)}function h(e){A(o,PH(e,window.innerWidth,p()),!0),a=I(o)}function g(e){e.button===0&&(e.preventDefault(),d=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`conversation-panel-resizing`),h(e.clientX))}function _(e){e.pointerId===d&&h(e.clientX)}function v(e){d===null||e.pointerId!==void 0&&e.pointerId!==d||(d=null,document.body.classList.remove(`conversation-panel-resizing`),Ta(`gomodel_interactions_panel_width`,a))}function y(e){e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a=I(o)+(e.key===`ArrowLeft`?24:-24),m(),a=I(o),Ta(`gomodel_interactions_panel_width`,a))}function b(){return[document.querySelector(`.sidebar`),document.querySelector(`.sidebar-toggle`),document.getElementById(`dashboard-content`)].filter(Boolean)}An(()=>{if(!n.conversationOpen)return;m();let e=document.querySelector(`.sidebar`),t=new ResizeObserver(m);e&&t.observe(e);let r=e=>{e.key===`Escape`&&!Aa.anyOpen&&(I(l)?A(l,!1):n.closeConversation())};return window.addEventListener(`keydown`,r),window.addEventListener(`resize`,m),()=>{v({}),t.disconnect(),window.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,m)}}),An(()=>{n.conversationOpen||A(l,!1)}),An(()=>{if(!I(l))return;let e=b().map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));return e.forEach(({element:e})=>{e.inert=!0,e.setAttribute(`aria-hidden`,`true`)}),()=>{e.forEach(({element:e,inert:t,ariaHidden:n})=>{e.inert=t,n===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)})}}),An(()=>{qo.page!==`audit-logs`&&n.conversationOpen&&n.closeConversation()});var x=Qr(),S=N(x),C=e=>{var t=KH();let r,i;var a=M(t),d=P(a,2),p=P(M(d),2),m=M(p),h=M(m);{let e=O(()=>I(l)?oo:ao);K(h,{get icon(){return I(e)},class:`table-icon-svg`})}T(m),Os(P(m,2),{label:`Close interactions`,onclick:()=>n.closeConversation(),get el(){return n.conversationCloseBtnEl},set el(e){n.conversationCloseBtnEl=e}}),T(p),T(d);var b=P(d,2),x=M(b),S=e=>{var t=IH(),r=M(t,!0);T(t),F(()=>B(r,n.conversationError)),z(e,t)};V(x,e=>{n.conversationError&&e(S)});var C=P(x,2),w=e=>{z(e,LH())};V(C,e=>{n.conversationLoading&&e(w)});var ee=P(C,2),te=e=>{z(e,RH())},ne=O(()=>!n.conversationLoading&&!n.followUpSending&&!n.conversationError&&n.conversationMessages.length===0&&!n.conversationLiveWaiting());V(ee,e=>{I(ne)&&e(te)});var re=P(ee,2),ie=e=>{var t=BH(),r=N(t),i=e=>{var t=zH(),n=M(t);let r;Ue(2),T(t),F(()=>{W(t,`aria-checked`,I(u)),W(t,`title`,(I(u)?`Hide`:`Show`)+` estimated provider prompt-cache fill`),r=U(n,1,`conversation-cache-switch svelte-ssrzja`,null,r,{"is-active":I(u)})}),L(`click`,t,f),z(e,t)},a=O(()=>n.conversationMessages.some(e=>Number(e.promptCacheRatio||0)>0));V(r,e=>{I(a)&&e(i)});var o=P(r,2);H(o,21,()=>n.conversationMessages,e=>e.uid,(e,t)=>{jH(e,{get msg(){return I(t)},get showPromptCache(){return I(u)}})}),T(o),ga(o,e=>n.conversationThreadEl=e,()=>n?.conversationThreadEl),z(e,t)};V(re,e=>{n.conversationMessages.length>0&&e(ie)});var ae=P(re,2),oe=e=>{z(e,VH())};V(ae,e=>{n.conversationTruncated&&e(oe)});var se=P(ae,2),ce=e=>{var t=HH(),r=P(M(t),2),i=M(r,!0);T(r),T(t),F(e=>B(i,e),[()=>n.conversationLiveStatusText()]),z(e,t)},le=O(()=>n.conversationLiveWaiting());V(se,e=>{I(le)&&e(ce)}),T(b);var ue=P(b,2),de=e=>{var t=GH(),r=M(t),i=e=>{var t=WH(),r=P(M(t),2);ft(r);var i=P(r,2),a=e=>{var t=UH(),r=M(t,!0);T(t),F(()=>B(r,n.followUpError)),z(e,t)};V(i,e=>{n.followUpError&&e(a)});var o=P(i,2),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l),T(o),T(t),F((e,t,i)=>{r.disabled=e,B(c,t),l.disabled=i,B(u,n.followUpSending?`Sending…`:`Send`)},[()=>n.followUpSending||n.conversationLiveWaiting(),()=>n.selectedConversationEntry()?.path||``,()=>!n.canSendFollowUp()]),Vr(`submit`,t,e=>{e.preventDefault(),n.sendFollowUp()}),da(r,()=>n.followUpText,e=>n.followUpText=e),z(e,t)},a=O(()=>n.followUpKind());V(r,e=>{I(a)&&e(i)});var o=P(r,2),s=M(o,!0);T(o),T(t),F(()=>B(s,n.conversationFollowLatest?`Following latest interaction`:`Opened from log: `+n.conversationOpenedFromID)),z(e,t)};V(ue,e=>{n.conversationAnchorID&&e(de)}),T(t),ga(t,e=>n.conversationDialogEl=e,()=>n?.conversationDialogEl),F(()=>{r=U(t,1,`conversation-drawer svelte-ssrzja`,null,r,{"conversation-drawer-fullscreen":I(l)}),W(t,`role`,I(l)?`dialog`:void 0),W(t,`aria-modal`,I(l)?`true`:void 0),i=Hi(t,``,i,{"--conversation-panel-width":I(o)+`px`}),W(a,`aria-valuemin`,I(s)),W(a,`aria-valuemax`,I(c)),W(a,`aria-valuenow`,I(o)),W(m,`aria-label`,I(l)?`Exit fullscreen interactions`:`Show interactions fullscreen`),W(m,`title`,I(l)?`Exit fullscreen`:`Fullscreen`),W(m,`aria-pressed`,I(l))}),L(`pointerdown`,a,g),L(`pointermove`,a,_),L(`pointerup`,a,v),Vr(`pointercancel`,a,v),Vr(`lostpointercapture`,a,v),L(`keydown`,a,y),L(`click`,m,()=>A(l,!I(l))),z(e,t)};V(S,e=>{n.conversationOpen&&e(C)}),z(e,x),D()}Hr([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`click`]);var JH=R(`
            `,1);function YH(e,t){E(t,!0);let n={overview:gC,usage:fT,budgets:HE,"rate-limits":$D,models:Fj,workflows:nP,"audit-logs":GL,guardrails:RR,"mcp-servers":vz,"providers-config":EB,"auth-keys":bV,settings:CH};us.init(),jc.init(),q.init(),Oa.init(),ka.init(),qo.init(),An(()=>{q.refreshTick,xs.fetch(),Mc.fetchModels(),Mc.fetchCategories()}),An(()=>{document.body.classList.toggle(`dashboard-modal-open`,Aa.anyOpen)});let r=O(()=>n[qo.page]||gC);var i=JH(),a=N(i);Es(a,{});var o=P(a,2);let s;var c=M(o);nc(c,{}),_i(P(c,2),()=>I(r),(e,t)=>{t(e,{})}),T(o);var l=P(o,2);qH(l,{});var u=P(l,2);Fs(u,{});var d=P(u,2);Vs(d,{}),ec(P(d,2),{}),F(()=>s=U(o,1,`content`,null,s,{"interactions-open":tL.conversationOpen})),z(e,i),D()}ti(YH,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/admin/dashboard/static/dist/index.html b/internal/admin/dashboard/static/dist/index.html index 0c1b91a47..470526004 100644 --- a/internal/admin/dashboard/static/dist/index.html +++ b/internal/admin/dashboard/static/dist/index.html @@ -7,8 +7,8 @@ GoModel Dashboard - - + +
            diff --git a/internal/admin/handler.go b/internal/admin/handler.go index 0f8e88027..1bf85443c 100644 --- a/internal/admin/handler.go +++ b/internal/admin/handler.go @@ -159,6 +159,15 @@ type auditLogListResponse struct { Offset int `json:"offset"` } +type auditConversationResponse struct { + AnchorID string `json:"anchor_id"` + Entries []auditLogEntryResponse `json:"entries"` + + // Truncated reports that more session or linkage entries exist than were + // returned. + Truncated bool `json:"truncated,omitempty"` +} + type auditSessionResponse struct { SessionID string `json:"session_id,omitempty"` Count int `json:"count"` diff --git a/internal/admin/handler_audit.go b/internal/admin/handler_audit.go index ac78dd7c6..66225135e 100644 --- a/internal/admin/handler_audit.go +++ b/internal/admin/handler_audit.go @@ -420,14 +420,15 @@ func (h *Handler) AuditLogDetail(c *echo.Context) error { // @Summary Get the interaction session containing an audit log entry // @Description Thread entries carry the request/response bodies the // @Description transcript is built from; attempts, request revisions, and -// @Description response headers are omitted; redacted request headers are -// @Description retained so the dashboard can continue the same session. +// @Description response headers are omitted; redacted request headers and +// @Description per-request usage summaries are retained for continuation +// @Description and prompt-cache visualization. // @Tags admin // @Produce json // @Security BearerAuth // @Param log_id query string true "Anchor audit log entry ID" // @Param limit query int false "Max entries in thread (default 40, max 200)" -// @Success 200 {object} auditlog.ConversationResult +// @Success 200 {object} auditConversationResponse // @Failure 400 {object} core.GatewayError // @Failure 401 {object} core.GatewayError // @Router /admin/audit/conversation [get] @@ -453,9 +454,9 @@ func (h *Handler) AuditConversation(c *echo.Context) error { } if h.auditReader == nil { - return c.JSON(http.StatusOK, auditlog.ConversationResult{ + return c.JSON(http.StatusOK, auditConversationResponse{ AnchorID: logID, - Entries: []auditlog.LogEntry{}, + Entries: []auditLogEntryResponse{}, }) } @@ -478,9 +479,17 @@ func (h *Handler) AuditConversation(c *echo.Context) error { if result.Entries == nil { result.Entries = []auditlog.LogEntry{} } - for i := range result.Entries { - slimConversationEntry(&result.Entries[i]) + enriched, err := h.auditLogResponse(ctx, &auditlog.LogListResult{Entries: result.Entries}) + if err != nil { + return handleError(c, err) + } + for i := range enriched.Entries { + slimConversationEntry(&enriched.Entries[i].LogEntry) } - return c.JSON(http.StatusOK, result) + return c.JSON(http.StatusOK, auditConversationResponse{ + AnchorID: result.AnchorID, + Entries: enriched.Entries, + Truncated: result.Truncated, + }) } diff --git a/internal/admin/handler_test.go b/internal/admin/handler_test.go index 9072a3440..d86e70cb3 100644 --- a/internal/admin/handler_test.go +++ b/internal/admin/handler_test.go @@ -1519,6 +1519,54 @@ func TestAuditConversation_Success(t *testing.T) { } } +func TestAuditConversation_EnrichesEntriesWithPromptCacheUsage(t *testing.T) { + now := time.Now().UTC() + usageReader := &mockUsageReader{ + usageByRequestID: map[string][]usage.UsageLogEntry{ + "req-cached": { + { + RequestID: "req-cached", + InputTokens: 100, + RawData: map[string]any{ + "prompt_cached_tokens": 25, + }, + }, + }, + }, + } + reader := &mockAuditReader{ + conversationResult: &auditlog.ConversationResult{ + AnchorID: "log-cached", + Entries: []auditlog.LogEntry{ + {ID: "log-cached", RequestID: "req-cached", Timestamp: now, Path: "/v1/chat/completions"}, + }, + }, + } + h := NewHandler(usageReader, nil, WithAuditReader(reader)) + c, rec := newHandlerContext("/admin/audit/conversation?log_id=log-cached") + + if err := h.AuditConversation(c); err != nil { + t.Fatalf("unexpected error: %v", err) + } + if rec.Code != http.StatusOK { + t.Fatalf("expected 200, got %d", rec.Code) + } + + var result auditConversationResponse + if err := json.Unmarshal(rec.Body.Bytes(), &result); err != nil { + t.Fatalf("failed to unmarshal: %v", err) + } + if len(result.Entries) != 1 || result.Entries[0].Usage == nil { + t.Fatalf("expected one usage-enriched entry, got %+v", result.Entries) + } + if result.Entries[0].Usage.CachedInputTokens != 25 { + t.Fatalf("CachedInputTokens = %d, want 25", result.Entries[0].Usage.CachedInputTokens) + } + if result.Entries[0].Usage.EstimatedCachedCharacters != 100 { + t.Fatalf("EstimatedCachedCharacters = %d, want 100", result.Entries[0].Usage.EstimatedCachedCharacters) + } +} + func TestAuditConversation_PreservesProviderName(t *testing.T) { now := time.Now().UTC() reader := &mockAuditReader{ diff --git a/web/dashboard/src/pages/audit-logs/ChatMessage.svelte b/web/dashboard/src/pages/audit-logs/ChatMessage.svelte index d7d9038b9..aa228ca27 100644 --- a/web/dashboard/src/pages/audit-logs/ChatMessage.svelte +++ b/web/dashboard/src/pages/audit-logs/ChatMessage.svelte @@ -5,12 +5,27 @@ // role selectors below — those rules must live here, next to the element // they scope to (CONVENTIONS rule 3). import { timezone } from "$lib/stores/timezone.svelte.js"; - import { functionExpandedContent } from "./conversation-helpers.js"; + import { + formatFunctionArguments, + functionExpandedContent, + } from "./conversation-helpers.js"; - let { msg } = $props(); + let { msg, showPromptCache = true } = $props(); const isFunctionNote = $derived(msg.role === "function_call" || msg.role === "function_result"); + function cacheFill(ratio) { + const value = Math.max(0, Math.min(1, Number(ratio || 0))); + return (value * 100).toFixed(1) + "%"; + } + + function cacheTitle(ratio) { + const value = Math.max(0, Math.min(1, Number(ratio || 0))); + return value > 0 + ? Math.round(value * 100) + "% of this visible prompt item is estimated provider-cached" + : undefined; + } + function functionDetailText(m) { if (m.role === "function_call") { return (m.toolCalls || []).map((tc) => tc.name + "()").join(", "); @@ -23,33 +38,65 @@ class={[ isFunctionNote ? "chat-function-note" : "chat-message", msg.roleClass, - { "is-anchor": msg.isAnchor, "is-after-anchor": msg.isAfterAnchor }, + { + "is-anchor": msg.isAnchor, + "is-after-anchor": msg.isAfterAnchor, + }, ]} + style:--prompt-cache-fill={cacheFill(msg.promptCacheRatio)} + style:--prompt-cache-visibility={showPromptCache && msg.promptCacheRatio > 0 ? "1" : "0"} data-conversation-anchor={msg.isAnchor ? "true" : undefined} data-entry-id={msg.entryID} > {#if isFunctionNote} -
            +
            {msg.roleLabel} {functionDetailText(msg)} + {timezone.formatTimestamp(msg.timestamp)} + {#if msg.functionCallID} +
            Call ID: {msg.functionCallID}
            + {/if} + {#if msg.role === "function_call" && msg.toolCalls} + {#each msg.toolCalls as tc} + {#if tc.id} +
            Call ID{msg.toolCalls.length > 1 ? " (" + tc.name + ")" : ""}: {tc.id}
            + {/if} + {/each} + {/if}
            {functionExpandedContent(msg)}
            {:else} -
            +
            {msg.roleLabel} {timezone.formatTimestamp(msg.timestamp)}
            {#if msg.text} -
            {msg.text}
            +
            {msg.text}
            {/if} {#if msg.toolCalls}
            {#each msg.toolCalls as tc, tcIdx (tc.name + "-" + tcIdx)} -
            - {tc.name + "()"} -
            +
            + + {tc.name + "()"} + {formatFunctionArguments(tc) || "No arguments"} + + {#if tc.id} +
            Call ID: {tc.id}
            + {/if} +
            {formatFunctionArguments(tc) || "No arguments"}
            +
            {/each}
            {/if} @@ -58,6 +105,8 @@ diff --git a/web/dashboard/src/pages/audit-logs/AuditEntrySummary.svelte b/web/dashboard/src/pages/audit-logs/AuditEntrySummary.svelte index 243f1792a..d874a38c7 100644 --- a/web/dashboard/src/pages/audit-logs/AuditEntrySummary.svelte +++ b/web/dashboard/src/pages/audit-logs/AuditEntrySummary.svelte @@ -247,6 +247,16 @@ background: color-mix(in srgb, var(--accent) 20%, var(--bg)); } + .audit-conversation-trigger-active { + color: var(--accent-strong, var(--accent)); + background: color-mix(in srgb, var(--accent) 28%, var(--bg)); + box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 60%, transparent); + } + + .audit-conversation-trigger-active:hover { + background: color-mix(in srgb, var(--accent) 34%, var(--bg)); + } + /* The Icon atom hard-codes lucide's round caps and 24px attribute size; these CSS declarations win over presentation attributes, keeping the chevron rendered exactly like the previous hand-rolled SVG (butt caps, From 1ff3e95f672848c8ce4ac070e5e0189de736da39 Mon Sep 17 00:00:00 2001 From: "Jakub A. W" Date: Fri, 7 Aug 2026 11:15:24 +0200 Subject: [PATCH 05/19] fix(dashboard): correlate response call aliases --- .../static/dist/assets/index-CPs3WU5V.js | 67 ------------------- .../static/dist/assets/index-ayXqZ3cf.js | 67 +++++++++++++++++++ .../admin/dashboard/static/dist/index.html | 2 +- .../pages/audit-logs/conversation-helpers.js | 29 ++++---- .../tests/conversation-drawer.test.js | 4 +- 5 files changed, 87 insertions(+), 82 deletions(-) delete mode 100644 internal/admin/dashboard/static/dist/assets/index-CPs3WU5V.js create mode 100644 internal/admin/dashboard/static/dist/assets/index-ayXqZ3cf.js diff --git a/internal/admin/dashboard/static/dist/assets/index-CPs3WU5V.js b/internal/admin/dashboard/static/dist/assets/index-CPs3WU5V.js deleted file mode 100644 index 32739800e..000000000 --- a/internal/admin/dashboard/static/dist/assets/index-CPs3WU5V.js +++ /dev/null @@ -1,67 +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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`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){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function h(e,t,n=!1){return e===void 0?n?t():t:e}function g(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 _=1<<24,v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,ee=65536,te=1<<19,ne=1<<20,re=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(`legacy props`),ue=Symbol(``),de=Symbol(`attributes`),fe=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),he=Symbol(`form reset`),ge=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},_e=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(`uninitialized`),je=`http://www.w3.org/1999/xhtml`,Me=`http://www.w3.org/2000/svg`,Ne=`http://www.w3.org/1998/Math/MathML`;function Pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Fe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ie(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Le(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Re=!1;function ze(e){Re=e}var Be;function Ve(e){if(e===null)throw Fe(),ke;return Be=e}function He(){return Ve(bn(Be))}function T(e){if(Re){if(bn(Be)!==null)throw Fe(),ke;Be=e}}function Ue(e=1){if(Re){for(var t=e,n=Be;t--;)n=bn(n);Be=n}}function We(e=!0){for(var t=0,n=Be;;){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=bn(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Fe(),ke;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=null;function Xe(e){Ye=e}function E(e,t=!1,n){Ye={p:Ye,i:!1,c:null,e:null,s:e,x:null,r:ir,l:null}}function D(e){var t=Ye,n=t.e;if(n!==null){t.e=null;for(var r of n)jn(r)}return e!==void 0&&(t.x=e),t.i=!0,Ye=t.p,e??{}}function Ze(){return!0}var Qe=[];function $e(){var e=Qe;Qe=[],p(e)}function et(e){if(Qe.length===0&&!zt){var t=Qe;queueMicrotask(()=>{t===Qe&&$e()})}Qe.push(e)}function tt(){for(;Qe.length>0;)$e()}function nt(e){var t=ir;if(t===null)return tr.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;rt(e,t)}function rt(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var it=~(y|b|v);function at(e,t){e.f=e.f&it|t}function ot(e){e.f&512||e.deps===null?at(e,v):at(e,b)}function st(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,st(t.deps))}function ct(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),st(e.deps),at(e,v)}var lt=!1;function ut(e){var t=lt;try{return lt=!1,[e(),lt]}finally{lt=t}}function dt(e,t){if(t){let t=document.body;e.autofocus=!0,et(()=>{document.activeElement===t&&e.focus()})}}function ft(e){Re&&yn(e)!==null&&xn(e)}var pt=!1;function mt(){pt||(pt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[he]?.()})},{capture:!0}))}function ht(e){var t=tr,n=ir;rr(null),ar(null);try{return e()}finally{rr(t),ar(n)}}function gt(e,t,n,r=n){e.addEventListener(t,()=>ht(n));let i=e[he];i?e[he]=()=>{i(),r(!0)}:e[he]=()=>r(!0),mt()}function _t(e){let t=0,n=an(0),r;return()=>{On()&&(I(n),In(()=>(t===0&&(r=Er(()=>e(()=>ln(n)))),t+=1,()=>{et(()=>{--t,t===0&&(r?.(),r=void 0,ln(n))})})))}}var vt=ee|te;function yt(e,t,n,r){new bt(e,t,n,r)}var bt=class{parent;is_pending=!1;transform_error;#e;#t=Re?Be: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=_t(()=>(this.#m=an(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=ir;t.b=this,t.f|=128,n(e)},this.parent=ir.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Ln(()=>{if(Re){let e=this.#t;He();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},vt),Re&&(this.#e=Be)}#g(){try{this.#a=zn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=zn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=zn(()=>e(this.#e)),et(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>zn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Kn(this.#o,()=>{this.#o=null}),this.#b(Ft))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=zn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Xn(this.#a,e);let t=this.#n.pending;this.#o=zn(()=>t(this.#e))}else this.#b(Ft)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){ct(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=ir,n=tr,r=Ye;ar(this.#i),rr(this.#i),Xe(this.#i.ctx);try{return Gt.ensure(),e()}catch(e){return nt(e),null}finally{ar(t),rr(n),Xe(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Kn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,et(()=>{this.#d=!1,this.#m&&sn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),I(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Ft?.is_fork?(this.#a&&Ft.skip_effect(this.#a),this.#o&&Ft.skip_effect(this.#o),this.#s&&Ft.skip_effect(this.#s),Ft.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Un(this.#a),null),this.#o&&=(Un(this.#o),null),this.#s&&=(Un(this.#s),null),Re&&(Ve(this.#t),Ue(),Ve(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Le();return}r=!0,i&&Oe(),this.#s!==null&&Kn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){rt(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return zn(()=>{var t=ir;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return rt(e,this.#i.parent),null}}))};et(()=>{var t;try{t=this.transform_error(e)}catch(e){rt(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>rt(e,this.#i&&this.#i.parent)):o(t)})}};function xt(e,t,n,r){let i=Ze()?Tt:Ot;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=ir,c=St(),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){rt(e,s)}Ct()}}var d=wt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Dt(e))).then(u).catch(e=>rt(e,s)).finally(d)}l?l.then(()=>{c(),f(),Ct()}):f()}function St(){var e=ir,t=tr,n=Ye,r=Ft;return function(i=!0){ar(e),rr(t),Xe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ct(e=!0){ar(null),rr(null),Xe(null),e&&Ft?.deactivate()}function wt(){var e=ir,t=e.b,n=Ft,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 Tt(e){var t=2|y;return ir!==null&&(ir.f|=te),{ctx:Ye,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:ir,ac:null}}var Et=Symbol(`obsolete`);function Dt(e,t,n){let r=ir;r===null&&ve();var i=void 0,a=an(Ae),o=!tr,s=new Set;return Fn(()=>{var t=ir,n=m();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ge&&n.reject(e)}).finally(Ct)}catch(e){n.reject(e),Ct()}var c=Ft;if(o){if(t.f&32768)var l=wt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Et);else for(let e of s.values())e.reject(Et);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Et&&(c.activate(),t?(a.f|=se,sn(a,t)):(a.f&8388608&&(a.f^=se),sn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),kn(()=>{for(let e of s)e.reject(Et)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function O(e){let t=Tt(e);return sr(t),t}function Ot(e){let t=Tt(e);return t.equals=Je,t}function kt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(ge),t.ac=null}),t.fn!==null&&(t.teardown=f),xr(t,0),Vn(t))}function Nt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Sr(t)}var Pt=null,Ft=null,It=null,Lt=null,Rt=null,zt=!1,Bt=!1,Vt=null,Ht=null,Ut=0,Wt=1,Gt=class e{id=Wt++;#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(){Pt===null?Pt=this:(Pt.#n=this,this.#t=Pt),Pt=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)at(r,y),t(r);for(r of n.m)at(r,b),t(r)}this.#p.add(e)}#g(){this.#e=!0,Ut++>1e3&&(this.#x(),qt());for(let e of this.#u)this.#d.delete(e),at(e,y),this.schedule(e);for(let e of this.#d)at(e,b),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Vt=[],r=[],i=Ht=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw en(e),this.#h()||this.discard(),t}if(Ft=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Vt=null,Ht=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)$t(e,t);i.length>0&&Ft.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),It=this,Yt(r),Yt(n),It=null,this.#s?.resolve();var s=Ft;if(this.#a===0&&(this.#c.length===0||s!==null)&&this.#x(),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):_r(r)&&(i&16&&this.#d.add(r),Sr(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}}}#v(){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}#y(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),at(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#x(),Ft=this,this.#g()}#b(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??=m()).promise}static ensure(){if(Ft===null){let t=Ft=new e;!Bt&&!zt&&et(()=>{t.#e||t.flush()})}return Ft}apply(){Lt=null}schedule(e){if(Rt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Vt!==null&&t===ir&&(tr===null||!(tr.f&2)))return;if(n&96){if(!(n&1024))return;t.f^=v}}this.#c.push(t)}#x(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?Pt=e:t.#t=e,this.linked=!1}}};function Kt(e){var t=zt;zt=!0;try{var n;for(e&&(Ft!==null&&!Ft.is_fork&&Ft.flush(),n=e());;){if(tt(),Ft===null)return n;Ft.flush()}}finally{zt=t}}function qt(){try{Ce()}catch(e){rt(e,Rt)}}var Jt=null;function Yt(e){var t=e.length;if(t!==0){for(var n=0;n0)){nn.clear();for(let e of Jt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Jt.has(n)&&(Jt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sr(n)}}Jt.clear()}}Jt=null}}function Xt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Xt(i,t,n,r):e&4194320&&!(e&2048)&&Zt(i,t,r)&&(at(i,y),Qt(i))}}function Zt(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(e.deps!==null)for(let i of e.deps){if(n.call(t,i))return!0;if(i.f&2&&Zt(i,t,r))return r.set(i,!0),!0}return r.set(e,!1),!1}function Qt(e){Ft.schedule(e)}function $t(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),at(e,v);for(var n=e.first;n!==null;)$t(n,t),n=n.next}}function en(e){at(e,v);for(var t=e.first;t!==null;)en(t),t=t.next}var tn=new Set,nn=new Map,rn=!1;function an(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function k(e,t){let n=an(e,t);return sr(n),n}function on(e,t=!1,n=!0){let r=an(e);return t||(r.equals=Je),r}function A(e,t,n=!1){return tr!==null&&(!nr||tr.f&131072)&&Ze()&&tr.f&4325394&&(or===null||!or.has(e))&&De(),sn(e,n?j(t):t,Ht)}function sn(e,t,n=null){if(!e.equals(t)){nn.set(e,$n?t:e.v);var r=Gt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&At(t),Lt===null&&ot(t)}e.wv=gr(),un(e,y,n),Ze()&&ir!==null&&ir.f&1024&&!(ir.f&96)&&(ur===null?dr([e]):ur.push(e)),!r.is_fork&&tn.size>0&&!rn&&cn()}return t}function cn(){rn=!1;for(let e of tn){e.f&1024&&at(e,b);let t;try{t=_r(e)}catch{t=!0}t&&Sr(e)}tn.clear()}function ln(e){A(e,e.v+1)}function un(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ze(),a=r.length,o=0;o{if(mr===d)return e();var t=tr,n=mr;rr(null),hr(d);var r=e();return rr(t),hr(n),r};return i&&r.set(`length`,k(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Te();var i=r.get(t);return i===void 0?f(()=>{var e=k(n.value,u);return r.set(t,e),e}):A(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>k(Ae,u));r.set(t,e),ln(o)}}else A(n,Ae),ln(o);return!0},get(e,n,i){if(n===ce)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>k(j(s?e[n]:Ae),u)),r.set(n,o)),o!==void 0){var c=I(o);return c===Ae?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=I(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===ce)return!0;var n=r.get(t),i=n!==void 0&&n.v!==Ae||Reflect.has(e,t);return(n!==void 0||ir!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>k(i?j(e[t]):Ae,u)),r.set(t,n)),I(n)===Ae)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dk(Ae,u)),r.set(d+``,p)):A(p,Ae)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>k(void 0,u)),A(c,j(n)),r.set(t,c));else{l=c.v!==Ae;var m=f(()=>j(n));A(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&&A(g,_+1)}ln(o)}return!0},ownKeys(e){I(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==Ae});for(var[n,i]of r)i.v!==Ae&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ee()}})}function dn(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=a(t,`firstChild`).get,gn=a(t,`nextSibling`).get,u(e)&&(e[fe]=void 0,e[de]=null,e[pe]=void 0,e.__e=void 0),u(n)&&(n[me]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function M(e,t){if(!Re)return yn(e);var n=yn(Be);if(n===null)n=Be.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),Ve(r),r}return t&&wn(n),Ve(n),n}function N(e,t=!1){if(!Re){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Be?.nodeType!==3){var r=vn();return Be?.before(r),Ve(r),r}wn(Be)}return Be}function P(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=bn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),Ve(a),a}wn(r)}return Ve(r),r}function xn(e){e.textContent=``}function Sn(){return!1}function Cn(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 wn(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 Tn(e){ir===null&&(tr===null&&Se(e),xe()),$n&&be(e)}function En(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Dn(e,t){var n=ir;n!==null&&n.f&8192&&(e|=x);var r={ctx:Ye,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};Ft?.register_created_effect(r);var i=r;if(e&4)Vt===null?Gt.ensure().schedule(r):Vt.push(r);else if(t!==null){try{Sr(r)}catch(e){throw Un(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|=ee))}if(i!==null&&(i.parent=n,n!==null&&En(i,n),tr!==null&&tr.f&2&&!(e&64))){var a=tr;(a.effects??=[]).push(i)}return r}function On(){return tr!==null&&!nr}function kn(e){let t=Dn(8,null);return at(t,v),t.teardown=e,t}function An(e){Tn(`$effect`);var t=ir.f;if(!tr&&t&32&&Ye!==null&&!Ye.i){var n=Ye;(n.e??=[]).push(e)}else return jn(e)}function jn(e){return Dn(4|ne,e)}function Mn(e){Gt.ensure();let t=Dn(64|te,e);return()=>{Un(t)}}function Nn(e){Gt.ensure();let t=Dn(64|te,e);return(e={})=>new Promise(n=>{e.outro?Kn(t,()=>{Un(t),n(void 0)}):(Un(t),n(void 0))})}function Pn(e){return Dn(4,e)}function Fn(e){return Dn(oe|te,e)}function In(e,t=0){return Dn(8|t,e)}function F(e,t=[],n=[],r=[]){xt(r,t,n,t=>{Dn(8,()=>{e(...t.map(I))})})}function Ln(e,t=0){return Dn(16|t,e)}function Rn(e,t=0){return Dn(_|t,e)}function zn(e){return Dn(32|te,e)}function Bn(e){var t=e.teardown;if(t!==null){let e=$n,n=tr;er(!0),rr(null);try{t.call(null)}finally{er(e),rr(n)}}}function Vn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ht(()=>{e.abort(ge)});var r=n.next;n.f&64?n.parent=null:Un(n,t),n=r}}function Hn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Un(t),t=n}}function Un(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Wn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,Vn(e,t&&!n),xr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Bn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Gn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Wn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Gn(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 Kn(e,t,n=!0){var r=[];qn(e,r,!0);var i=()=>{n&&Un(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function qn(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)!=0||(i.f&32)!=0&&(e.f&16)!=0;qn(i,t,o?n:!1)}i=a}}}function Jn(e){Yn(e,!0)}function Yn(e,t){if(e.f&8192){e.f^=x,e.f&1024||(at(e,y),Gt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Yn(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 Xn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var Zn=null,Qn=!1,$n=!1;function er(e){$n=e}var tr=null,nr=!1;function rr(e){tr=e}var ir=null;function ar(e){ir=e}var or=null;function sr(e){tr!==null&&(or??=new Set).add(e)}var cr=null,lr=0,ur=null;function dr(e){ur=e}var fr=1,pr=0,mr=pr;function hr(e){mr=e}function gr(){return++fr}function _r(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Lt===null&&at(e,v)}return!1}function vr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(or!==null&&or.has(e)))for(var i=0;i{e.ac.abort(ge)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=C;var f=e.deps,p=Ft?.is_fork;if(cr!==null){var m;if(p||xr(e,lr),f!==null&&lr>0)for(f.length=lr+cr.length,m=0;m{s.ac.abort(ge),s.ac=null,at(s,y)}),Mt(s),xr(s,0)}}function xr(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`?et(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Vr(e,t,n,r,i){var a={capture:r,passive:i},o=Br(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&kn(()=>{t.removeEventListener(e,o,a)})}function L(e,t,n){(t[Lr]??={})[e]=n}function Hr(e){for(var t=0;t{throw e});throw p}}finally{e[Lr]=t,delete e.currentTarget,rr(d),ar(f)}}}var Gr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Kr(e){return Gr?.createHTML(e)??e}function qr(e){var t=Cn(`template`);return t.innerHTML=Kr(e.replaceAll(``,``)),t.content}function Jr(e,t){var n=ir;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function R(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Re)return Jr(Be,null),Be;i===void 0&&(i=qr(a?e:``+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;Jr(o,s)}else Jr(t,t);return t}}function Yr(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}`,o;return()=>{if(Re)return Jr(Be,null),Be;if(!o){var e=yn(qr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;Jr(n,r)}else Jr(t,t);return t}}function Xr(e,t){return Yr(e,t,`svg`)}function Zr(e=``){if(!Re){var t=vn(e+``);return Jr(t,t),t}var n=Be;return n.nodeType===3?wn(n):(n.before(n=vn()),Ve(n)),Jr(n,n),n}function Qr(){if(Re)return Jr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),Jr(t,n),e}function z(e,t){if(Re){var n=ir;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Be),He();return}e!==null&&e.before(t)}var $r=!0;function ei(e){$r=e}function B(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function ti(e,t){return ri(e,t)}var ni=new Map;function ri(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=Nn(()=>{var u=n??t.appendChild(vn());yt(u,{pending:()=>{}},t=>{E({});var n=Ye;if(o&&(n.c=o),a&&(i.$$events=a),Re&&Jr(t,null),$r=s,l=e(t,i)||{},$r=!0,Re&&(ir.nodes.end=Be,Be===null||Be.nodeType!==8||Be.data!==`]`))throw Fe(),ke;D()},c);var d=new Set,f=e=>{for(var n=0;n{for(var e of d)for(let n of[t,document]){var r=ni.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Wr),r.delete(e),r.size===0&&ni.delete(n)):r.set(e,i)}zr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ii.set(l,u),l}var ii=new WeakMap,ai=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)Jn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Jn(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&&(Un(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();Xn(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else Un(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Kn(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)||(Un(n.effect),this.#n.delete(e))};ensure(e,t){var n=Ft,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:zn(()=>t(a)),fragment:i})}else this.#t.set(e,zn(()=>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 Re&&(this.anchor=Be),this.#a(n)}};function V(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ai(e),a=n?ee:0;function o(e,t){if(Re){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}Ln(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function oi(e,t){return t}function si(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;ci(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;if(l){var u=n,d=u.parentNode;xn(d),d.append(u),e.items.clear()}ci(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function ci(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,di(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=re,pi(d,null,c)):Jn(d):Kn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Ln(()=>{p=I(f);var e=p.length;let t=!1;Re&&Ge(c)===`[!`!=(e===0)&&(c=We(),Ve(c),ze(!1),t=!0);for(var r=new Set,u=Ft,v=Sn(),y=0;ys(c)):(d=zn(()=>s(li??=vn())),d.f|=re)),e>r.size&&ye(``,``,``),Re&&e>0&&Ve(We()),!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&&ze(!0),I(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Re&&(c=Be)}function ui(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function di(e,t,n,i,a){var o=(i&8)!=0,s=t.length,c=e.items,l=ui(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var te=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function fi(e,t,n,r,i,a,o,s){var c=o&1?o&16?an(n):on(n,!1,!1):null,l=o&2?an(i):null;return{v:c,i:l,e:zn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function pi(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=bn(r);if(a.before(r),r===i)return;r=o}}function mi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function hi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Re&&(o=Ve(yn(c)))}F(()=>{var e=ir;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&Jr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Wn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Re){for(var a=Be.data,l=He(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Fe(),ke;Jr(Be,u),o=Ve(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Jr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function gi(e,t,...n){var r=new ai(e);Ln(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},ee)}function _i(e,t,n){var r;Re&&(r=Be,He());var i=new ai(e);Ln(()=>{var e=t()??null;if(Re&&Ge(r)===`[`!=(e!==null)){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,e&&(t=>n(t,e))),ze(!0);return}i.ensure(e,e&&(t=>n(t,e)))},ee)}var vi=()=>performance.now(),yi={tick:e=>requestAnimationFrame(e),now:()=>vi(),tasks:new Set};function bi(){let e=yi.now();yi.tasks.forEach(t=>{t.c(e)||(yi.tasks.delete(t),t.f())}),yi.tasks.size!==0&&yi.tick(bi)}function xi(e){let t;return yi.tasks.size===0&&yi.tick(bi),{promise:new Promise(n=>{yi.tasks.add(t={c:e,f:n})}),abort(){yi.tasks.delete(t)}}}function Si(e,t){ht(()=>{e.dispatchEvent(new CustomEvent(t))})}function Ci(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function wi(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Ci(n.trim());t[i]=r.trim()}return t}var Ti=e=>e,Ei=null;function Di(e){Ei=e}function Oi(e,t,n){var r=(Ei??ir).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Ai(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function ki(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return ht(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Ai(t,m(),p,1,()=>{Si(t,`introstart`)},()=>{Si(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Ai(t,m(),f,0,()=>{Si(t,`outrostart`)},()=>{Si(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=ir;if((g.nodes.t??=[]).push(h),i&&$r){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Pn(()=>{Er(()=>h.in())})}}function Ai(e,t,n,r,i,a){var o=r===1;if(d(t)){var s,c=!1;return et(()=>{c||(s=Ai(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:f,deactivate:f,reset:f,t:()=>r};let{delay:l=0,css:u,tick:p,easing:m=Ti}=t;var h=[];if(o&&n===void 0&&(p&&p(0,1),u)){var g=wi(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var d=!1;if(u)for(var f=Math.ceil(c/(1e3/60)),h=0;h<=f;h+=1){var g=o+s*m(h/f),y=wi(u(g,1-g));l.push(y),d||=y.overflow===`hidden`}d&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*m(e/c)},p&&xi(()=>{if(v.playState!==`running`)return!1;var e=_();return p(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,p?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=f)},deactivate:()=>{a=f},reset:()=>{r===0&&p?.(1,0)},t:()=>_()}}function ji(e,t,n,r,i,a){let o=Re;Re&&He();var s=null;Re&&Be.nodeType===1&&(s=Be,He());var c=Re?Be:e,l=ir,u=new ai(c,!1);Ln(()=>{let e=t()||null;var a=i?i():n||e===`svg`?Me:void 0;if(e===null){u.ensure(null,null),ei(!0);return}return u.ensure(e,t=>{if(e){if(s=Re?s:Cn(e,a),Jr(s,s),r){var n=null;Re&&Ir(e)&&s.append(n=document.createComment(``));var i=Re?yn(s):s.appendChild(vn());Re&&(i===null?ze(!1):Ve(i)),Di(l),r(s,i),n?.remove(),Di(null)}ir.nodes.end=s,t.before(s)}Re&&Ve(t)}),ei(!0),()=>{e&&ei(!1)}},ee),kn(()=>{ei(!0)}),o&&(ze(!0),Ve(c))}function Mi(e,t){var n=void 0,r;Rn(()=>{n!==(n=t())&&(r&&=(Un(r),null),n&&(r=zn(()=>{Pn(()=>n(e))})))})}function Ni(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||Ii.includes(r[o-1]))&&(s===r.length||Ii.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Ri(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 zi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Bi(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(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(zi)),i&&c.push(...Object.keys(i).map(zi));var l=0,u=-1;let t=e.length;for(var d=0;d{Ui(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),kn(()=>{t.disconnect()})}function Gi(e,t,n=t){var r=new WeakSet,i=!0;gt(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ki);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ki(o)}n(a),e.__value=a,Ft!==null&&r.add(Ft)}),Pn(()=>{var a=t();if(e===document.activeElement){var o=Ft;if(r.has(o))return}if(Ui(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ki(s),n(a))}e.__value=a,i=!1}),Wi(e)}function Ki(e){return`__value`in e?e.__value:e.value}var qi=Symbol(`class`),Ji=Symbol(`style`),Yi=Symbol(`is custom element`),Xi=Symbol(`is html`),Zi=_e?`link`:`LINK`,Qi=_e?`input`:`INPUT`,$i=_e?`option`:`OPTION`,ea=_e?`select`:`SELECT`,ta=_e?`progress`:`PROGRESS`;function na(e){if(Re){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;W(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;W(e,`checked`,null),e.checked=r}}};e[he]=n,et(n),mt()}}function ra(e,t){var n=ca(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==ta)||(e.value=t??``)}function ia(e,t){var n=ca(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function aa(e,t){t?e.hasAttribute(`selected`)||e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}function W(e,t,n,r){var i=ca(e);Re&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Zi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ue]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ua(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function oa(e,t,n,r,i=!1,a=!1){if(Re&&i&&e.nodeName===Qi){var o=e;(o.type===`checkbox`?`defaultChecked`:`defaultValue`)in n||na(o)}var s=ca(e),c=s[Yi],l=!s[Xi];let u=Re&&c;u&&ze(!1);var d=t||{},f=e.nodeName===$i;for(var p in t)p in n||(n[p]=null);n.class?n.class=Fi(n.class):(r||n[qi])&&(n.class=null),n[Ji]&&(n.style??=null);var m=ua(e);if(e.nodeName===Qi&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==d.type||h===void 0&&e.hasAttribute(`type`))&&(d.type=h,W(e,`type`,h,a))}for(let i in n){let o=n[i];if(f&&i===`value`&&o==null){e.value=e.__value=``,d[i]=o;continue}if(i===`class`){U(e,e.namespaceURI===`http://www.w3.org/1999/xhtml`,o,r,t?.[qi],n[qi]),d[i]=o,d[qi]=n[qi];continue}if(i===`style`){Hi(e,o,t?.[Ji],n[Ji]),d[i]=o,d[Ji]=n[Ji];continue}var g=d[i];if(!(o===g&&!(o===void 0&&e.hasAttribute(i)))){d[i]=o;var _=i[0]+i[1];if(_!==`$$`)if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=kr(r);if(Dr(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(o!=null)continue;e.removeEventListener(r,d[n],t),d[n]=null}if(v)L(r,e,o),Hr([r]);else if(o!=null){function a(e){d[i].call(this,e)}d[n]=Br(r,e,a,t)}}else if(i===`style`)W(e,i,o);else if(i===`autofocus`)dt(e,!!o);else if(!c&&(i===`__value`||i===`value`&&o!=null))e.value=e.__value=o;else if(i===`selected`&&f)aa(e,o);else{var y=i;l||(y=Mr(y));var b=y===`defaultValue`||y===`defaultChecked`;if(o==null&&!c&&!b)if(s[i]=null,y===`value`||y===`checked`){let n=e,r=t===void 0;if(y===`value`){let e=n.defaultValue;n.removeAttribute(y),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(y),n.defaultChecked=e,n.checked=r?e:!1}}else e.removeAttribute(i);else b||m.includes(y)&&(c||typeof o!=`string`)?(e[y]=o,y in s&&(s[y]=Ae)):typeof o!=`function`&&W(e,y,o,a)}}}return u&&ze(!0),d}function sa(e,t,n=[],r=[],i=[],a,o=!1,s=!1){xt(i,n,r,n=>{var r=void 0,i={},c=e.nodeName===ea,l=!1;if(Rn(()=>{var u=t(...n.map(I)),d=oa(e,r,u,a,o,s);l&&c&&`value`in u&&Ui(e,u.value);for(let e of Object.getOwnPropertySymbols(i))u[e]||Un(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var f=u[t];t.description===`@attach`&&(!r||f!==r[t])&&(i[t]&&Un(i[t]),i[t]=zn(()=>Mi(e,()=>f))),d[t]=f}r=d}),c){var u=e;Pn(()=>{Ui(u,r.value,!0),Wi(u)})}l=!0})}function ca(e){return e[de]??={[Yi]:e.nodeName.includes(`-`),[Xi]:e.namespaceURI===je}}var la=new Map;function ua(e){var t=e.getAttribute(`is`)||e.nodeName,n=la.get(t);if(n)return n;la.set(t,n=[]);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.push(s);i=l(i)}return n}function da(e,t,n=t){var r=new WeakSet;gt(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=pa(e)?ma(a):a,n(a),Ft!==null&&r.add(Ft),await Cr(),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))}}}),(Re&&e.defaultValue!==e.value||Er(t)==null&&e.value)&&(n(pa(e)?ma(e.value):e.value),Ft!==null&&r.add(Ft)),In(()=>{var n=t();if(e===document.activeElement){var i=Ft;if(r.has(i))return}pa(e)&&n===ma(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function fa(e,t,n=t){gt(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Re&&e.defaultChecked!==e.checked||Er(t)==null)&&n(e.checked),In(()=>{e.checked=!!t()})}function pa(e){var t=e.type;return t===`number`||t===`range`}function ma(e){return e===``?null:+e}function ha(e,t){return e===t||e?.[ce]===t}function ga(e={},t,n,r){var i=Ye.r,a=ir;return Pn(()=>{var o,s;return In(()=>{o=s,s=r?.()||[],Er(()=>{ha(n(...s),e)||(t(e,...s),o&&ha(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&&ha(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var _a={get(e,t){if(!e.exclude.has(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return!e.exclude.has(t)&&t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))}};function va(e,t,n){return new Proxy({props:e,exclude:t},_a)}function G(e,t,n,r){var i=!0,o=(n&8)!=0,s=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>s&&i?(u??=Tt(r),I(u)):(l&&(l=!1,c=s?Er(r):r),c);let f;if(o){var p=ce in e||le in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=ut(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&we(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?Tt:Ot)(()=>(v=!1,g()));o&&I(y);var b=ir;return(function(e,t){if(arguments.length>0){let n=t?I(y):i&&o?j(e):e;return A(y,n),v=!0,c!==void 0&&(c=n),e}return $n&&v||b.f&16384?y.v:I(y)})}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var ya=new Set([`$$slots`,`$$events`,`$$legacy`,`icon`,`class`]),ba=Xr(``);function K(e,t){let n=G(t,`icon`,19,()=>[]),r=G(t,`class`,3,``),i=va(t,ya);var a=ba();sa(a,()=>({xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:r(),"aria-hidden":`true`,focusable:`false`,...i}));{let e=(t,n=f)=>{var r=Qr();H(N(r),17,n,oi,(t,n)=>{var r=O(()=>g(I(n),3));let i=()=>I(r)[0],a=()=>I(r)[1],o=()=>I(r)[2];var s=Qr();ji(N(s),i,!0,(t,n)=>{sa(t,()=>({xmlns:`http://www.w3.org/2000/svg`,...a()}));var r=Qr(),i=N(r),s=t=>{e(t,o)},c=O(()=>Array.isArray(o()));V(i,e=>{I(c)&&e(s)}),z(n,r)}),z(t,s)}),z(t,r)};e(M(a),n),T(a)}z(e,a)}var xa=Xr(``);function Sa(e){z(e,xa())}function Ca(){try{return typeof localStorage>`u`?null:localStorage}catch{return null}}function wa(e,t=null){let n=Ca();if(!n)return t;try{return n.getItem(e)??t}catch{return t}}function Ta(e,t){let n=Ca();if(n)try{n.setItem(e,String(t))}catch{}}function Ea(e){let t=Number(e);return Number.isFinite(t)?Math.min(240,Math.max(60,Math.round(t))):240}function Da(e,t,n){return Ea(Number(e)+Number(n)-Number(t))}var Oa=new class{#e=k(`system`);get theme(){return I(this.#e)}set theme(e){A(this.#e,e,!0)}#t=k(0);get tick(){return I(this.#t)}set tick(e){A(this.#t,e,!0)}init(){this.theme=wa(`gomodel_theme`,`system`),this.apply(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{this.theme===`system`&&this.tick++})}set(e){this.theme=e,Ta(`gomodel_theme`,e),this.apply(),this.tick++}toggle(){let e=[`light`,`system`,`dark`];this.set(e[(e.indexOf(this.theme)+1)%e.length])}apply(){let e=document.documentElement;this.theme===`system`?e.removeAttribute(`data-theme`):e.setAttribute(`data-theme`,this.theme)}},ka=new class{#e=k(j(240));get width(){return I(this.#e)}set width(e){A(this.#e,e,!0)}get collapsed(){return this.width===60}init(){let e=wa(`gomodel_sidebar_width`),t=wa(`gomodel_sidebar_collapsed`)===`true`;this.setWidth(e??(t?60:240))}toggle(){this.setWidth(this.collapsed?240:60,!0)}setWidth(e,t=!1){this.width=Ea(e),typeof document<`u`&&document.documentElement.style.setProperty(`--sidebar-width`,`${this.width}px`),t&&(Ta(`gomodel_sidebar_width`,this.width),Ta(`gomodel_sidebar_collapsed`,this.collapsed))}},Aa=new class{#e=k(j([]));get stack(){return I(this.#e)}set stack(e){A(this.#e,e,!0)}#t=1;opened(){let e=this.#t++;return this.stack=[...this.stack,e],e}closed(e){this.stack=this.stack.filter(t=>t!==e)}isTop(e){return this.stack.length>0&&this.stack[this.stack.length-1]===e}get openCount(){return this.stack.length}get anyOpen(){return this.stack.length>0}},ja=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],Ma=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],Na=[[`path`,{d:`M5 12h14`}],[`path`,{d:`m12 5 7 7-7 7`}]],Pa=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]],Fa=[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`}],[`path`,{d:`M16 10h.01`}],[`path`,{d:`M12 10h.01`}],[`path`,{d:`M8 10h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M8 18h.01`}]],Ia=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M16 14h.01`}],[`path`,{d:`M8 18h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M16 18h.01`}]],La=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}]],Ra=[[`path`,{d:`M13 17V9`}],[`path`,{d:`M18 17V5`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M8 17v-3`}]],za=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M18 17V9`}],[`path`,{d:`M13 17V5`}],[`path`,{d:`M8 17v-3`}]],Ba=[[`path`,{d:`M20 6 9 17l-5-5`}]],Va=[[`path`,{d:`m6 9 6 6 6-6`}]],Ha=[[`path`,{d:`m15 18-6-6 6-6`}]],Ua=[[`path`,{d:`m9 18 6-6-6-6`}]],Wa=[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`}],[`path`,{d:`m9 11 3 3L22 4`}]],Ga=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m9 12 2 2 4-4`}]],Ka=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}],[`path`,{d:`M12 18V6`}]],qa=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],Ja=[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`}]],Ya=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`}],[`path`,{d:`M21 5V8`}],[`path`,{d:`M21 12L18 17H22L19 22`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`}]],Xa=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`}]],Za=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],Qa=[[`path`,{d:`m12 14 4-4`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`}]],$a=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}],[`path`,{d:`M12 7v5l4 2`}]],eo=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 16v-4`}],[`path`,{d:`M12 8h.01`}]],to=[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],no=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],ro=[[`path`,{d:`M3 5h.01`}],[`path`,{d:`M3 12h.01`}],[`path`,{d:`M3 19h.01`}],[`path`,{d:`M8 5h13`}],[`path`,{d:`M8 12h13`}],[`path`,{d:`M8 19h13`}]],io=[[`circle`,{cx:`12`,cy:`16`,r:`1`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`}]],ao=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]],oo=[[`path`,{d:`m14 10 7-7`}],[`path`,{d:`M20 10h-6V4`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M4 14h6v6`}]],so=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],co=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],lo=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],uo=[[`path`,{d:`M12 22v-5`}],[`path`,{d:`M15 8V2`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`}],[`path`,{d:`M9 8V2`}]],fo=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],po=[[`path`,{d:`M12 2v10`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`}]],mo=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],ho=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],go=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],_o=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],vo=[[`path`,{d:`m10.852 14.772-.383.923`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`}],[`path`,{d:`m13.148 9.228.383-.923`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`}],[`path`,{d:`m14.772 10.852.923-.383`}],[`path`,{d:`m14.772 13.148.923.383`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`}],[`path`,{d:`M6 18h.01`}],[`path`,{d:`M6 6h.01`}],[`path`,{d:`m9.228 10.852-.923-.383`}],[`path`,{d:`m9.228 13.148-.923.383`}]],yo=[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`}]],bo=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]],xo=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],So=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}],[`path`,{d:`m9 12 2 2 4-4`}]],Co=[[`path`,{d:`m2 2 20 20`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`}]],wo=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}]],To=[[`path`,{d:`m18 14 4 4-4 4`}],[`path`,{d:`m18 2 4 4-4 4`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`}]],Eo=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],Do=[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],Oo=[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`}],[`circle`,{cx:`12`,cy:`14`,r:`8`}]],ko=[[`path`,{d:`M10 11v6`}],[`path`,{d:`M14 11v6`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]],Ao=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]],jo=[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}],[`circle`,{cx:`12`,cy:`7`,r:`4`}]],Mo=[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`}]],No=[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`}],[`path`,{d:`m14 7 3 3`}],[`path`,{d:`M5 6v4`}],[`path`,{d:`M19 14v4`}],[`path`,{d:`M10 2v2`}],[`path`,{d:`M7 8H3`}],[`path`,{d:`M21 16h-4`}],[`path`,{d:`M11 3H9`}]],Po=[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`}]],Fo=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],Io=R(``),Lo=R(`
            `,1);function Ro(e,t){E(t,!0);let n=G(t,`compact`,3,!1),r=[{value:`light`,icon:Eo,label:`Light theme`},{value:`system`,icon:so,label:`System theme`},{value:`dark`,icon:co,label:`Dark theme`}],i=O(()=>r.find(e=>e.value===Oa.theme)||r[1]),a=O(()=>`Change theme (currently `+I(i).label+`)`);var o=Lo(),s=N(o);let c;H(s,21,()=>r,e=>e.value,(e,t)=>{var n=Io();let r;K(M(n),{get icon(){return I(t).icon},class:`theme-icon`}),T(n),F(()=>{r=U(n,1,`theme-btn svelte-1keql7b`,null,r,{active:Oa.theme===I(t).value}),W(n,`aria-pressed`,Oa.theme===I(t).value),W(n,`title`,I(t).label),W(n,`aria-label`,I(t).label)}),L(`click`,n,()=>Oa.set(I(t).value)),z(e,n)}),T(s);var l=P(s,2);let u;K(M(l),{get icon(){return I(i).icon},class:`theme-icon`}),T(l),F(()=>{c=U(s,1,`theme-toggle svelte-1keql7b`,null,c,{"is-compact":n()}),u=U(l,1,`theme-toggle-mobile svelte-1keql7b`,null,u,{"is-compact":n()}),W(l,`title`,I(a)),W(l,`aria-label`,I(a))}),L(`click`,l,()=>Oa.toggle()),z(e,o),D()}Hr([`click`]);function zo(){return typeof window>`u`?`/`:window.GOMODEL_BASE_PATH||`/`}function Bo(e){let t=zo();return!e||e.charAt(0)!==`/`||e.indexOf(`//`)===0||t===`/`||e===t||e.indexOf(t+`/`)===0?e:t+e}function Vo(e){let t=zo();return t===`/`||!e?e:e===t?`/`:e.indexOf(t+`/`)===0?e.slice(t.length)||`/`:e}function Ho(){return typeof window>`u`?``:window.GOMODEL_VERSION||``}function Uo(){return typeof window>`u`?!1:window.GOMODEL_DEMO_MODE===!0}var Wo=[`overview`,`usage`,`budgets`,`rate-limits`,`models`,`workflows`,`audit-logs`,`guardrails`,`mcp-servers`,`providers-config`,`auth-keys`,`settings`];function Go(e){return e.startsWith(`/admin/static/`)?`/`+e.slice(14).replace(/^\/+/,``):e}function Ko(e){let t=Go(Vo(e)).replace(/\/$/,``).replace(`/admin/dashboard`,``).replace(/^\//,``).split(`/`),n=t[0];n===`audit`&&(n=`audit-logs`);let r=t[1]||null;return n===`settings`&&r===`guardrails`?{page:`guardrails`,sub:null}:(n=Wo.includes(n)?n:`overview`,{page:n,sub:r})}var qo=new class{#e=k(`overview`);get page(){return I(this.#e)}set page(e){A(this.#e,e,!0)}#t=k(null);get sub(){return I(this.#t)}set sub(e){A(this.#t,e,!0)}init(){let{page:e,sub:t}=Ko(window.location.pathname);this.page=e,this.sub=t,window.addEventListener(`popstate`,()=>{let{page:e,sub:t}=Ko(window.location.pathname);this.page=e,this.sub=t})}navigate(e,t=null){let n=t?`/`+t:``;history.pushState(null,``,Bo(`/admin/dashboard/`+e+n)),this.page=e,this.sub=t}},Jo=`gomodel_api_key`;function Yo(e){let t=String(e||``).trim();if(/^Bearer\s*$/i.test(t))return``;let n=t.match(/^Bearer\s+(.+)$/i);return n?n[1].trim():t}var q=new class{#e=k(``);get apiKey(){return I(this.#e)}set apiKey(e){A(this.#e,e,!0)}#t=k(!1);get needsAuth(){return I(this.#t)}set needsAuth(e){A(this.#t,e,!0)}#n=k(!1);get authError(){return I(this.#n)}set authError(e){A(this.#n,e,!0)}#r=k(``);get authErrorMessage(){return I(this.#r)}set authErrorMessage(e){A(this.#r,e,!0)}#i=k(!1);get dialogOpen(){return I(this.#i)}set dialogOpen(e){A(this.#i,e,!0)}#a=k(0);get generation(){return I(this.#a)}set generation(e){A(this.#a,e,!0)}#o=k(0);get refreshTick(){return I(this.#o)}set refreshTick(e){A(this.#o,e,!0)}init(){try{this.apiKey=Yo(localStorage.getItem(Jo)||``)}catch{this.apiKey=``}}hasApiKey(){return Yo(this.apiKey)!==``}save(){this.apiKey=Yo(this.apiKey);try{localStorage.setItem(Jo,this.apiKey)}catch{}}openDialog(){this.dialogOpen=!0}closeDialog(){this.dialogOpen=!1}submit(){let e=Yo(this.apiKey);return e?(this.apiKey=e,this.save(),this.generation++,this.authError=!1,this.authErrorMessage=``,this.needsAuth=!1,this.closeDialog(),this.refresh(),!0):(this.apiKey=``,this.authError=!0,this.authErrorMessage=``,this.needsAuth=!0,this.openDialog(),!1)}refresh(){this.refreshTick++}handleUnauthorized(e,t=``){return typeof e==`number`&&e{r[e.type]=e.value}),r.year+`-`+r.month+`-`+r.day}formatTimestampInTimeZone(e,t){if(e==null)return`-`;let n=new Date(e);if(Number.isNaN(n.getTime()))return`-`;let r=os(`en-CA`,{timeZone:ss(t)?t:ns,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(n),i={};return r.forEach(e=>{i[e.type]=e.value}),i.year+`-`+i.month+`-`+i.day+` `+i.hour+`:`+i.minute+`:`+i.second}formatTimestamp(e){return this.formatTimestampInTimeZone(e,this.effectiveTimezone())}currentDateKey(e){return this.dateKeyInTimeZone(e||new Date,this.effectiveTimezone())}dateKeyToDate(e){return Zo(e)}dateToDateKey(e){return Qo(e)}addDaysToDateKey(e,t){return $o(e,t)}todayDate(){return this.dateKeyToDate(this.currentDateKey())}startOfMonthDate(e){let t=e instanceof Date?e:this.todayDate();return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1))}timeZoneOffsetLabel(e,t){let n=ss(e)?e:ns;try{let e=os(`en-US`,{timeZone:n,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`,timeZoneName:`longOffset`}).formatToParts(t||new Date).find(e=>e.type===`timeZoneName`);if(!e||!e.value)return`UTC+00:00`;let r=e.value.replace(`GMT`,`UTC`);return r===`UTC`?`UTC+00:00`:r}catch{return`UTC+00:00`}}timeZoneOffsetMinutes(e,t){let n=/^UTC([+-])(\d{2}):(\d{2})$/.exec(this.timeZoneOffsetLabel(e,t));if(!n)return 0;let r=Number(n[2])*60+Number(n[3]);return n[1]===`-`?-r:r}timeZoneOptionLabel(e,t){return e+` (`+this.timeZoneOffsetLabel(e,t)+`)`}detectedTimeZoneLabel(){return this.timeZoneOptionLabel(this.detectedTimezone)}effectiveTimeZoneLabel(){return this.timeZoneOptionLabel(this.effectiveTimezone())}ensureOptions(){if(this.optionsLoaded)return;let e=new Date,t=[];try{typeof Intl.supportedValuesOf==`function`&&(t=Intl.supportedValuesOf(`timeZone`))}catch{t=[]}[ns,this.detectedTimezone,this.override].forEach(e=>{e&&t.indexOf(e)===-1&&ss(e)&&t.push(e)}),t=t.filter(e=>ss(e)),t.sort((t,n)=>{let r=this.timeZoneOffsetMinutes(t,e)-this.timeZoneOffsetMinutes(n,e);return r===0?t.localeCompare(n):r}),this.options=t.map(t=>({value:t,label:this.timeZoneOptionLabel(t,e)})),this.optionsLoaded=!0}saveOverride(){let e=Ca();if(e)if(this.override&&ss(this.override))try{e.setItem(rs,this.override)}catch{}else{try{e.removeItem(rs)}catch{}this.override=``}this.optionsLoaded=!1,this.ensureOptions()}clearOverride(){let e=Ca();if(e)try{e.removeItem(rs)}catch{}this.override=``}calendarTimeZoneText(){let e=this.override?`manual override`:`auto-detected`;return`Activity grouped by `+this.effectiveTimeZoneLabel()+` (`+e+`)`}};function ds(e,t){let n=e&&typeof e==`object`&&e.error&&e.error.message;return(typeof n==`string`?n.trim():``)||t}function fs(e,t){let n=e&&e.data;if(n&&typeof n==`object`){let e=[n.message,n.error,n.error&&typeof n.error==`object`?n.error.message:null];for(let t of e)if(typeof t==`string`&&t.trim())return t.trim()}return t}function ps(){let e={"Content-Type":`application/json`},t=Yo(q.apiKey);return t&&(e.Authorization=`Bearer `+t),e[`X-GoModel-Timezone`]=us.effectiveTimezone(),e}function ms(e,t={}){return fetch(Bo(e),{...t,headers:{...ps(),...t.headers||{}}})}async function hs(e,t,{label:n=e,parse:r=!0}={}){let i=q.generation,a=await ms(e,t);if(a.status===401)return q.handleUnauthorized(i),{ok:!1,stale:ie.trim()).filter(Boolean);return e.length>0?e:bs}cacheVisible(){if(this.flag(`CACHE_ENABLED`)!==``)return this.booleanFlag(`CACHE_ENABLED`,!1);let e=this.flag(`REDIS_URL`),t=this.flag(`SEMANTIC_CACHE_ENABLED`);return e===``&&t===``||this.booleanFlag(`REDIS_URL`,!1)||this.booleanFlag(`SEMANTIC_CACHE_ENABLED`,!1)}auditVisible(){return this.booleanFlag(`LOGGING_ENABLED`,!0)}usageVisible(){return this.booleanFlag(`USAGE_ENABLED`,!0)}budgetsVisible(){return this.booleanFlag(`BUDGETS_ENABLED`,!0)}rateLimitsVisible(){return this.booleanFlag(`RATE_LIMITS_ENABLED`,!0)}guardrailsVisible(){return this.booleanFlag(`GUARDRAILS_ENABLED`,!0)}mcpVisible(){return this.booleanFlag(`MCP_ENABLED`,!0)}liveLogsVisible(){return this.booleanFlag(`DASHBOARD_LIVE_LOGS_ENABLED`,!0)}fetch(){return this.#n||=this.#r().finally(()=>{this.#n=null}),this.#n}async ensureLoaded(){if(this.#n){await this.#n;return}this.loaded||await this.fetch()}async#r(){let e=typeof AbortController==`function`?new AbortController:null,t=e?setTimeout(()=>e.abort(),1e4):null;try{let t=await gs(`/admin/runtime/config`,{label:`dashboard config`,signal:e?e.signal:void 0});if(t.stale)return;if(!t.ok){this.config={},this.loaded=!1;return}let n=t.data,r={};for(let e of ys)n&&typeof n==`object`&&!Array.isArray(n)&&n[e]!==void 0&&n[e]!==null&&(r[e]=String(n[e]).trim());this.config=r,this.loaded=!0}catch(e){console.error(`Failed to fetch dashboard config:`,e),this.config={},this.loaded=!1}finally{t!==null&&clearTimeout(t)}}},Ss=[{page:`overview`,label:`Overview`,icon:no},{page:`providers-config`,label:`Providers`,icon:vo},{page:`models`,label:`Models`,icon:Pa},{page:`audit-logs`,label:`Audit Logs`,icon:$a},{page:`usage`,label:`Usage`,icon:za},{page:`budgets`,label:`Budgets`,icon:Mo,visible:()=>xs.budgetsVisible()},{page:`rate-limits`,label:`Rate Limits`,icon:Qa,visible:()=>xs.rateLimitsVisible()},{page:`auth-keys`,label:`API Keys`,icon:to},{page:`workflows`,label:`Workflows`,icon:Po},{page:`guardrails`,label:`Guardrails (experimental)`,icon:So,visible:()=>xs.guardrailsVisible()},{page:`mcp-servers`,label:`MCP Servers`,icon:uo,visible:()=>xs.mcpVisible()},{page:`settings`,label:`Settings`,icon:xo}],Cs=R(` `),ws=R(`
            `),Ts=R(` `,1);function Es(e,t){E(t,!0);let n=O(()=>Ss.filter(e=>!e.visible||e.visible())),r=k(null),i=0,a=0,o=!1;function s(e){e.button===0&&(e.preventDefault(),A(r,e.pointerId,!0),i=e.clientX,a=ka.width,o=!1,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`sidebar-resizing`))}function c(e){e.pointerId===I(r)&&(!o&&Math.abs(e.clientX-i)<=4||(o=!0,ka.setWidth(Da(a,i,e.clientX))))}function l(e){I(r)===null||e.pointerId!==void 0&&e.pointerId!==I(r)||(A(r,null),document.body.classList.remove(`sidebar-resizing`),ka.setWidth(ka.width,!0))}function u(){if(o){o=!1;return}ka.toggle()}function d(e){let t;if(e.key===`ArrowLeft`)t=ka.width-12;else if(e.key===`ArrowRight`)t=ka.width+12;else if(e.key===`Home`)t=60;else if(e.key===`End`)t=240;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),ka.toggle();return}else return;e.preventDefault(),ka.setWidth(t,!0)}var f=Ts(),p=N(f);let m;var h=M(p),g=M(h);Sa(M(g),{}),T(g),Ue(4),T(h);var _=P(h,2);H(_,21,()=>I(n),e=>e.page,(e,t)=>{var n=Cs();let r;var i=M(n);K(i,{get icon(){return I(t).icon},class:`nav-icon`});var a=P(i,2),o=M(a,!0);T(a),T(n),F(e=>{W(n,`href`,e),r=U(n,1,`nav-item svelte-1nwtzae`,null,r,{active:qo.page===I(t).page}),W(n,`title`,I(t).label),B(o,I(t).label)},[()=>Bo(`/admin/dashboard/`+I(t).page)]),L(`click`,n,e=>{e.preventDefault(),qo.navigate(I(t).page)}),z(e,n)}),T(_);var v=P(_,2),y=M(v);Ro(y,{get compact(){return ka.collapsed}});var b=P(y,2),x=e=>{var t=ws(),n=M(t),r=M(n);K(r,{get icon(){return io},class:`api-key-open-icon`});var i=P(r,2),a=M(i,!0);T(i),T(n),T(t),F(()=>{W(n,`aria-label`,q.needsAuth?`Enter API key`:`Change API key`),B(a,q.needsAuth?`Enter API key`:`Change API key`)}),L(`click`,n,()=>q.openDialog()),z(e,t)},S=O(()=>q.needsAuth||q.hasApiKey());V(b,e=>{I(S)&&e(x)}),T(v),T(p);var C=P(p,2);F(()=>{m=U(p,1,`sidebar svelte-1nwtzae`,null,m,{"sidebar-collapsed":ka.collapsed,"sidebar-resizing":I(r)!==null}),W(C,`aria-valuemin`,60),W(C,`aria-valuemax`,240),W(C,`aria-valuenow`,ka.width)}),L(`pointerdown`,C,s),L(`pointermove`,C,c),L(`pointerup`,C,l),Vr(`pointercancel`,C,l),Vr(`lostpointercapture`,C,l),L(`keydown`,C,d),L(`click`,C,u),z(e,f),D()}Hr([`click`,`pointerdown`,`pointermove`,`pointerup`,`keydown`]);var Ds=R(``);function Os(e,t){E(t,!0);let n=G(t,`label`,3,`Close`),r=G(t,`class`,3,``),i=G(t,`iconClass`,3,`table-icon-svg`),a=G(t,`disabled`,3,!1),o=G(t,`el`,15,null);var s=Ds();K(M(s),{get icon(){return Fo},get class(){return i()}}),T(s),ga(s,e=>o(e),()=>o()),F(()=>{U(s,1,Fi([`dialog-close-btn`,r()]),`svelte-11l1bb5`),W(s,`aria-label`,n()),s.disabled=a()}),L(`click`,s,function(...e){t.onclick?.apply(this,e)}),z(e,s),D()}Hr([`click`]);function ks(e){return t=>{let n=n=>{t.contains(n.target)||e()},r=t=>{t.key===`Escape`&&e()};return document.addEventListener(`click`,n,!0),window.addEventListener(`keydown`,r),()=>{document.removeEventListener(`click`,n,!0),window.removeEventListener(`keydown`,r)}}}function As(e=`[data-modal-autofocus]`){return t=>{let n=t.querySelector(e);n&&typeof n.focus==`function`&&n.focus()}}var js=R(`
            `,1);function Ms(e,t){E(t,!0);let n=G(t,`open`,3,!1),r=G(t,`variant`,3,`editor`),i=G(t,`closeOnBackdrop`,3,!0),a=O(()=>r()===`auth`?`auth-dialog-backdrop`:`editor-modal-backdrop`),o=O(()=>r()===`auth`?`auth-dialog-shell`:`editor-modal-shell`);An(()=>{if(!n())return;let e=Er(()=>Aa.opened()),r=n=>{n.key===`Escape`&&Aa.isTop(e)&&t.onclose?.()};return window.addEventListener(`keydown`,r),()=>{Aa.closed(e),window.removeEventListener(`keydown`,r)}});function s(e){i()&&e.target===e.currentTarget&&t.onclose?.()}var c=Qr(),l=N(c),u=e=>{var n=js(),r=N(n),i=P(r,2);gi(M(i),()=>t.children??f),T(i),Mi(i,As),F(()=>{U(r,1,Fi(I(a)),`svelte-17e0w4c`),U(i,1,Fi(I(o)),`svelte-17e0w4c`)}),L(`click`,i,s),z(e,n)};V(l,e=>{n()&&e(u)}),z(e,c),D()}Hr([`click`]);var Ns=R(``),Ps=R(``);function Fs(e,t){E(t,!0),Ms(e,{get open(){return q.dialogOpen},variant:`auth`,onclose:()=>q.closeDialog(),children:(e,t)=>{var n=Ps(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a),T(i),Os(P(i,2),{label:`Close authentication dialog`,onclick:()=>q.closeDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var s=P(r,2),c=M(s),l=M(c);K(l,{get icon(){return io},class:`auth-dialog-input-icon`});var u=P(l,2);na(u),T(c);var d=P(c,2),f=e=>{var t=Ns(),n=M(t,!0);T(t),F(()=>B(n,q.authErrorMessage||`Enter a valid API key to continue.`)),z(e,t)};V(d,e=>{q.authError&&e(f)});var p=P(d,4),m=M(p),h=M(m);K(h,{get icon(){return Ba},class:`auth-dialog-submit-icon`});var g=P(h,2),_=M(g,!0);T(g),T(m),T(p),T(s),T(n),F(()=>{B(o,q.needsAuth?`Dashboard locked`:`Change API key`),B(_,q.needsAuth?`Unlock dashboard`:`Save API key`)}),Vr(`submit`,s,e=>{e.preventDefault(),q.submit()}),da(u,()=>q.apiKey,e=>q.apiKey=e),z(e,n)},$$slots:{default:!0}}),D()}function Is(){return{open:!1,title:``,titleId:`typedConfirmationDialogTitle`,inputId:`typed-confirmation-input`,message:``,requiredText:``,value:``,confirmLabel:`Confirm`,icon:Ao,dialogClass:``,loading:!1,onConfirm:null,onClose:null}}var Ls=new class{#e=k(j(Is()));get state(){return I(this.#e)}set state(e){A(this.#e,e,!0)}#t=k(``);get error(){return I(this.#t)}set error(e){A(this.#t,e,!0)}open(e){this.error=``,this.state={...Is(),open:!0,...e||{}}}close(){let e=this.state;typeof e.onClose==`function`&&e.onClose(),this.state=Is(),this.error=``}ready(){return String(this.state.value||``).trim().toLowerCase()===String(this.state.requiredText||``).trim().toLowerCase()}inputLabel(){return`Type `+String(this.state.requiredText||``).trim()+` to confirm`}async submit(){if(!this.ready()){this.error=this.inputLabel()+`.`;return}if(typeof this.state.onConfirm==`function`){this.state.loading=!0;try{await this.state.onConfirm()}finally{this.state.loading=!1}}}},Rs=R(`

            `),zs=R(``),Bs=R(`

            `);function Vs(e,t){E(t,!0);let n=O(()=>Ls.state);Ms(e,{get open(){return I(n).open},variant:`auth`,onclose:()=>Ls.close(),children:(e,t)=>{var r=Bs(),i=M(r),a=M(i),o=M(a,!0);T(a),Os(P(a,2),{label:`Close confirmation dialog`,onclick:()=>Ls.close(),class:`auth-dialog-close`,iconClass:``}),T(i);var s=P(i,2),c=M(s),l=e=>{var t=Rs(),r=M(t,!0);T(t),F(()=>B(r,I(n).message)),z(e,t)};V(c,e=>{I(n).message&&e(l)});var u=P(c,2),d=M(u),f=M(d,!0);T(d);var p=P(d,2);na(p),T(u);var m=P(u,2),h=e=>{var t=zs(),n=M(t,!0);T(t),F(()=>B(n,Ls.error)),z(e,t)};V(m,e=>{Ls.error&&e(h)});var g=P(m,2),_=M(g),v=P(_,2),y=M(v);K(y,{get icon(){return I(n).icon},class:`form-action-icon`});var b=P(y,2),x=M(b,!0);T(b),T(v),T(g),T(s),T(r),F((e,t)=>{U(r,1,`auth-dialog ${I(n).dialogClass??``}`),W(r,`aria-labelledby`,I(n).titleId),W(a,`id`,I(n).titleId),B(o,I(n).title),W(d,`for`,I(n).inputId),B(f,e),W(p,`id`,I(n).inputId),v.disabled=t,B(x,I(n).confirmLabel)},[()=>Ls.inputLabel(),()=>I(n).loading||!Ls.ready()]),Vr(`submit`,s,e=>{e.preventDefault(),Ls.submit()}),da(p,()=>Ls.state.value,e=>Ls.state.value=e),L(`click`,_,()=>Ls.close()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var Hs=e=>e;function Us(e){let t=e-1;return t*t*t+1}function Ws(e){let t=typeof e==`string`&&e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);return t?[parseFloat(t[1]),t[2]||`px`]:[e,`px`]}function Gs(e,{delay:t=0,duration:n=400,easing:r=Hs}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}function Ks(e,{delay:t=0,duration:n=400,easing:r=Us,x:i=0,y:a=0,opacity:o=0}={}){let s=getComputedStyle(e),c=+s.opacity,l=s.transform===`none`?``:s.transform,u=c*(1-o),[d,f]=Ws(i),[p,m]=Ws(a);return{delay:t,duration:n,easing:r,css:(e,t)=>` - transform: ${l} translate(${(1-e)*d}${f}, ${(1-e)*p}${m}); - opacity: ${c-u*t}`}}function qs(e,{delay:t=0,duration:n=400,easing:r=Us,axis:i=`y`}={}){let a=getComputedStyle(e),o=+a.opacity,s=i===`y`?`height`:`width`,c=parseFloat(a[s]),l=i===`y`?[`top`,`bottom`]:[`left`,`right`],u=l.map(e=>`${e[0].toUpperCase()}${e.slice(1)}`),d=parseFloat(a[`padding${u[0]}`]),f=parseFloat(a[`padding${u[1]}`]),p=parseFloat(a[`margin${u[0]}`]),m=parseFloat(a[`margin${u[1]}`]),h=parseFloat(a[`border${u[0]}Width`]),g=parseFloat(a[`border${u[1]}Width`]);return{delay:t,duration:n,easing:r,css:e=>`overflow: hidden;opacity: ${Math.min(e*20,1)*o};${s}: ${e*c}px;padding-${l[0]}: ${e*d}px;padding-${l[1]}: ${e*f}px;margin-${l[0]}: ${e*p}px;margin-${l[1]}: ${e*m}px;border-${l[0]}-width: ${e*h}px;border-${l[1]}-width: ${e*g}px;min-${s}: 0`}}function Js(e){return--e*e*(2.70158*e+1.70158)+1}function Ys(e){let t=e-1;return t*t*t+1}var Xs=5e3,Zs=8e3,J=new class{#e=k(j([]));get toasts(){return I(this.#e)}set toasts(e){A(this.#e,e,!0)}#t=0;#n=new Map;success(e){this.#r(`success`,e,Xs)}error(e){this.#r(`error`,e,Zs)}dismiss(e){let t=this.#n.get(e);t&&(clearTimeout(t),this.#n.delete(e)),this.toasts=this.toasts.filter(t=>t.id!==e)}#r(e,t,n){let r=String(t||``).trim();if(!r)return;let i=this.toasts.find(t=>t.kind===e&&t.text===r);i&&this.dismiss(i.id);let a=++this.#t;this.toasts=[...this.toasts,{id:a,kind:e,text:r}],this.#n.set(a,setTimeout(()=>this.dismiss(a),n))}},Qs=R(`
            `),$s=R(`
            `);function ec(e,t){E(t,!0);var n=$s();H(n,21,()=>J.toasts,e=>e.id,(e,t)=>{var n=Qs();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2);T(n),F(()=>{r=U(n,1,`flash-toast svelte-1i257xg`,null,r,{"flash-toast-success":I(t).kind===`success`,"flash-toast-error":I(t).kind===`error`}),W(n,`role`,I(t).kind===`error`?`alert`:`status`),W(n,`aria-live`,I(t).kind===`error`?`assertive`:`polite`),B(a,I(t).text)}),L(`click`,o,()=>J.dismiss(I(t).id)),ki(1,n,()=>Ks,()=>({y:-24,duration:360,easing:Js})),ki(2,n,()=>Gs,()=>({duration:150})),z(e,n)}),T(n),z(e,n),D()}Hr([`click`]);var tc=R(``);function nc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{z(e,tc())},a=O(()=>Uo());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}function rc(e){return String(e||``).split(`,`).map(e=>e.trim()).filter(e=>e)}function ic(e){if(e==null||e===``)return`Not captured`;if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ac(e){return e==null||e===void 0?`-`:e.toLocaleString()}function oc(e){if(e==null)return`---`;let t=Number(e);return Number.isFinite(t)?t>0&&t<1e-4?`<$0.0001`:`$`+t.toFixed(4).replace(/(\.\d{2}\d*?)0+$/,`$1`):`---`}function sc(e){return e==null||e===void 0?`—`:`$`+e.toFixed(2)}function cc(e){return e==null||e===void 0?`—`:e<.01?`$`+e.toFixed(6):`$`+e.toFixed(4)}function lc(e){if(e==null||e===``)return`-`;let t=Number(e);if(!Number.isFinite(t))return`-`;let n=Math.abs(t),r=[{threshold:1e9,suffix:`B`},{threshold:1e6,suffix:`M`},{threshold:1e3,suffix:`K`}];for(let e=0;e=i.threshold){let n=t/i.threshold;return Math.abs(Number(n.toFixed(1)))>=1e3&&e>0&&(i=r[e-1],n=t/i.threshold),n.toFixed(1).replace(/\.0$/,``)+i.suffix}}return String(t)}function uc(e,t){let n=t==null||t===``?NaN:Number(t),r=Number.isFinite(n)?ac(n):`-`;return String(e||`Tokens`)+`: `+r}function dc(e){return e?typeof e==`string`?e:e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`):``}function fc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)}function pc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)+` `+String(t.getUTCHours()).padStart(2,`0`)+`:`+String(t.getUTCMinutes()).padStart(2,`0`)+`:`+String(t.getUTCSeconds()).padStart(2,`0`)+` UTC`}function mc(e){return String(e&&e.provider||``).trim()}function hc(e){return String(e&&e.provider_name||``).trim()||mc(e)}function gc(e,t){let n=String(t||``).trim();if(!n)return`-`;let r=hc(e);return!r||n===r||n.startsWith(r+`/`)?n:r+`/`+n}function _c(e){return gc(e,e&&e.model)}function vc(e){return gc(e,e&&e.resolved_model)}function yc(e){let t=String(e&&(e.requested_model||e.model)||``).trim();if(!e)return t;let n=String(e.data&&e.data.failover&&e.data.failover.target_model||``).trim();if(n&&n!==t)return t+` ⮕ `+n;if(e.alias_used&&e.resolved_model){let n=vc(e);if(n&&n!==`-`&&n!==t)return t+` ⮕ `+n}return t}var bc=`gomodel_date_range`,xc=1;function Sc(e){return/^[1-9]\d*$/.test(String(e??``))}var Cc=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function wc({selectedPreset:e,startKey:t,endKey:n,followsToday:r}){return e&&Sc(e)?{v:xc,mode:`preset`,days:String(e)}:e?null:es(t)&&es(n)?{v:xc,mode:`custom`,start:t,end:n,follow:r===!0}:null}function Tc(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return null}return!t||typeof t!=`object`?null:t.mode===`preset`?Sc(t.days)?{mode:`preset`,days:String(t.days)}:null:t.mode===`custom`&&es(t.start)&&es(t.end)&&t.start<=t.end?{mode:`custom`,start:t.start,end:t.end,follow:t.follow===!0}:null}function Ec(e,t,n){let r=ts(e,t);return r<1||!es(n)?{start:e,end:t}:{start:$o(n,-(r-1)),end:n}}function Dc(e,t){if(e===t)return`Today`;let[n,r,i]=e.split(`-`);return Cc[Number(r)-1]+` `+Number(i)+`, `+n}function Oc({selectedPreset:e,startKey:t,endKey:n,followsToday:r,todayKey:i}){if(e)return`Last `+e+` days`;if(!es(t)||!es(n))return``;let a=ts(t,n);return r||n===i?a===1?`Today`:`Last `+a+` days`:a===1?`1 day`:a+` days`}function kc({selectedPreset:e,startKey:t,endKey:n,todayKey:r}){if(e)return`Last `+e+` days`;let i=e=>Dc(e,r);return es(t)&&es(n)?t===n?i(t):i(t)+` – `+i(n):es(t)?i(t)+` – ...`:`Last 30 days`}var Ac=6e4,jc=new class{#e=k(j(`30`));get days(){return I(this.#e)}set days(e){A(this.#e,e,!0)}#t=k(j(`30`));get selectedPreset(){return I(this.#t)}set selectedPreset(e){A(this.#t,e,!0)}#n=k(null);get customStartDate(){return I(this.#n)}set customStartDate(e){A(this.#n,e,!0)}#r=k(null);get customEndDate(){return I(this.#r)}set customEndDate(e){A(this.#r,e,!0)}#i=k(!1);get followsToday(){return I(this.#i)}set followsToday(e){A(this.#i,e,!0)}#a=k(`daily`);get interval(){return I(this.#a)}set interval(e){A(this.#a,e,!0)}#o=k(0);get syncTick(){return I(this.#o)}set syncTick(e){A(this.#o,e,!0)}init(){this.restore(),this.syncToToday(),typeof setInterval==`function`&&setInterval(()=>this.syncToToday(),Ac)}queryStr(){return this.customStartDate&&this.customEndDate?`start_date=`+dc(this.customStartDate)+`&end_date=`+dc(this.customEndDate):`days=`+this.days}selectPreset(e){this.selectedPreset=e,this.customStartDate=null,this.customEndDate=null,this.followsToday=!1,this.days=e,this.persist()}selectStart(e){this.selectedPreset=null,this.customStartDate=e,this.customEndDate&&this.customEndDatet.category===e);return t?t.count:0}get filteredModels(){if(!this.filter)return this.models;let e=this.filter.toLowerCase();return this.models.filter(t=>(t.model?.id??``).toLowerCase().includes(e)||(t.provider_name??``).toLowerCase().includes(e)||(t.provider_type??``).toLowerCase().includes(e)||(t.selector??``).toLowerCase().includes(e)||(t.model?.owned_by??``).toLowerCase().includes(e)||(t.model?.metadata?.modes??[]).join(`,`).toLowerCase().includes(e)||(t.model?.metadata?.categories??[]).join(`,`).toLowerCase().includes(e))}},Nc=R(``);function Pc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Nc(),n=P(M(t),2);T(t),L(`click`,n,()=>q.openDialog()),z(e,t)};V(r,e=>{q.authError&&e(i)}),z(e,n),D()}Hr([`click`]);function Fc(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null}}function Ic(){return{summary:{total_hits:0,exact_hits:0,semantic_hits:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_saved_cost:null},daily:[]}}var Lc=new class{#e=k(j(Fc()));get summary(){return I(this.#e)}set summary(e){A(this.#e,e,!0)}#t=k(j([]));get daily(){return I(this.#t)}set daily(e){A(this.#t,e,!0)}#n=k(j(Ic()));get cacheOverview(){return I(this.#n)}set cacheOverview(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=null;#a=null;cacheAnalyticsEnabled(){return xs.cacheVisible()}async fetchUsage(){this.#i&&this.#i.abort();let e=new AbortController;this.#i=e,this.loading=!0;try{let t=jc.queryStr()+`&interval=`+jc.interval,[n,r]=await Promise.all([gs(`/admin/usage/summary?`+t,{label:`usage summary`,signal:e.signal}),gs(`/admin/usage/daily?`+t,{label:`usage daily`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.summary=Fc(),this.daily=[],this.cacheOverview=Ic();return}this.summary=n.data||Fc(),this.daily=Array.isArray(r.data)?r.data:[]}catch(e){if(vs(e))return;console.error(`Failed to fetch usage:`,e),this.summary=Fc(),this.daily=[]}finally{this.#i===e&&(this.#i=null,this.loading=!1)}}async fetchCacheOverview(e=``){if(await xs.ensureLoaded(),!this.cacheAnalyticsEnabled()){this.cacheOverview=Ic();return}this.#a&&this.#a.abort();let t=new AbortController;this.#a=t;try{let n=await gs(`/admin/cache/overview?`+(jc.queryStr()+`&interval=`+jc.interval+e),{label:`cache overview`,signal:t.signal});if(n.stale||t.signal.aborted)return;if(!n.ok){this.cacheOverview=Ic();return}let r=n.data&&typeof n.data==`object`?n.data:Ic();r.summary||=Ic().summary,Array.isArray(r.daily)||(r.daily=[]),this.cacheOverview=r}catch(e){if(vs(e))return;console.error(`Failed to fetch cache overview:`,e),this.cacheOverview=Ic()}finally{this.#a===t&&(this.#a=null)}}},Rc=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function zc(e,t){let n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return Rc[n.getUTCMonth()]+` `+n.getUTCFullYear()}function Bc(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth()+t,a=new Date(Date.UTC(r,i,1)),o=new Date(Date.UTC(r,i+1,0)),s=(a.getUTCDay()+6)%7,c=[],l=new Date(Date.UTC(r,i,0));for(let e=s-1;e>=0;e--){let t=l.getUTCDate()-e,a=new Date(Date.UTC(r,i-1,t));c.push({day:t,date:a,current:!1,key:`p-`+n(a)})}for(let e=1;e<=o.getUTCDate();e++){let t=new Date(Date.UTC(r,i,e));c.push({day:e,date:t,current:!0,key:`c-`+n(t)})}let u=42-c.length;for(let e=1;e<=u;e++){let t=new Date(Date.UTC(r,i+1,e));c.push({day:e,date:t,current:!1,key:`n-`+n(t)})}return c}function Vc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return n&&r.getTime()>n.getTime()?e:r}function Hc(e,t){return e.getUTCFullYear()===t.getUTCFullYear()&&e.getUTCMonth()===t.getUTCMonth()}var Uc=R(``),Wc=R(``),Gc=R(``),Kc=R(`
            MoTuWeThFrSaSu
            `);function qc(e,t){E(t,!0);let n=G(t,`offset`,3,0),r=O(()=>Bc(t.calendarMonth,n(),e=>us.dateToDateKey(e))),i=O(()=>Hc(t.calendarMonth,us.todayDate())),a=e=>us.dateToDateKey(e.date),o=e=>a(e)>us.currentDateKey(),s=e=>e.current&&a(e)===us.currentDateKey();function c(e,t){let n=t===`start`?jc.rangeStart():jc.rangeEnd();return e.current&&!!n&&a(e)===us.dateToDateKey(n)}function l(e){let t=jc.rangeStart(),n=jc.rangeEnd();return!e.current||!t||!n?!1:a(e)>=us.dateToDateKey(t)&&a(e)<=us.dateToDateKey(n)}var u=Kc(),d=M(u),f=M(d);let p;var m=P(f,2),h=M(m,!0);T(m);var g=P(m,2),_=e=>{z(e,Uc())},v=e=>{var n=Wc();F(()=>n.disabled=I(i)),L(`click`,n,function(...e){t.onnext?.apply(this,e)}),z(e,n)};V(g,e=>{n()===-1?e(_):e(v,-1)}),T(d);var y=P(d,4);H(y,21,()=>I(r),e=>e.key,(e,n)=>{var r=Gc(),i=M(r,!0);T(r),F((e,t)=>{U(r,1,e,`svelte-g7ga4u`),r.disabled=t,B(i,I(n).day)},[()=>Fi([`dp-day`,{"other-month":!I(n).current,today:s(I(n)),"range-start":c(I(n),`start`),"range-end":c(I(n),`end`),"in-range":l(I(n)),disabled:o(I(n))}]),()=>o(I(n))||!I(n).current]),L(`click`,r,()=>t.onselect?.(I(n))),z(e,r)}),T(y),T(u),F(e=>{p=U(f,1,`dp-nav-btn svelte-g7ga4u`,null,p,{"dp-nav-prev-mobile":n()!==-1}),B(h,e)},[()=>zc(t.calendarMonth,n())]),L(`click`,f,function(...e){t.onprev?.apply(this,e)}),z(e,u),D()}Hr([`click`]);var Jc=R(``),Yc=R(`
            `),Xc=Xr(``),Zc=Xr(``),Qc=R(`
            `),$c=R(`
            `);function el(e,t){E(t,!0);let n=[`3`,`7`,`14`,`30`,`90`],r=k(!1),i=k(`start`),a=k(j(new Date)),o=k(j({show:!1,x:0,y:0}));function s(){A(r,!I(r)),I(r)&&(jc.syncToToday(),A(a,us.startOfMonthDate(jc.customEndDate||us.todayDate()),!0),A(i,`start`))}function c(){A(r,!1),A(o,{show:!1,x:0,y:0},!0)}let l=jc.syncTick;An(()=>{let e=jc.syncTick;e!==l&&(l=e,t.onchange?.())});function u(e){jc.selectPreset(e),A(i,`start`),t.onchange?.(),c()}let d=()=>A(a,Vc(I(a),-1),!0),f=()=>A(a,Vc(I(a),1,us.startOfMonthDate(us.todayDate())),!0);function p(e){let n=new Date(e.date);if(I(i)===`start`){jc.selectStart(n),A(i,`end`),t.onchange?.();return}jc.selectEnd(n),A(i,`start`),t.onchange?.(),c()}var m=$c(),h=M(m),g=P(M(h),2),_=M(g,!0);T(g);var v=P(g,2);let y;T(h);var b=P(h,2),x=e=>{var t=Yc(),r=M(t);H(r,20,()=>n,e=>e,(e,t)=>{var n=Jc();let r;var i=M(n);T(n),F(()=>{r=U(n,1,`preset-btn svelte-ax7ma4`,null,r,{active:jc.selectedPreset===t}),B(i,`Last ${t??``} days`)}),L(`click`,n,()=>u(t)),z(e,n)}),T(r);var i=P(r,2);H(i,20,()=>[-1,0],e=>e,(e,t)=>{qc(e,{get calendarMonth(){return I(a)},get offset(){return t},onprev:d,onnext:f,onselect:p})}),T(i),T(t),L(`mousemove`,i,e=>A(o,{show:!0,x:e.clientX,y:e.clientY},!0)),Vr(`mouseleave`,i,()=>A(o,{show:!1,x:0,y:0},!0)),z(e,t)};V(b,e=>{I(r)&&e(x)});var S=P(b,2),C=e=>{var t=Qc(),n=M(t),r=e=>{z(e,Xc())},a=e=>{z(e,Zc())};V(n,e=>{I(i)===`start`?e(r):e(a,-1)});var s=P(n,2),c=M(s,!0);T(s),T(t),F(()=>{Hi(t,`left:${I(o).x??``}px;top:${I(o).y??``}px`),B(c,I(i)===`end`?`Select end date`:`Select start date`)}),z(e,t)};V(S,e=>{I(o).show&&e(C)}),T(m),Mi(m,()=>I(r)?ks(c):void 0),F((e,t)=>{W(h,`title`,e),B(_,t),y=U(v,0,`date-picker-chevron svelte-ax7ma4`,null,y,{open:I(r)})},[()=>jc.dateRangeSpanLabel(),()=>jc.dateRangeLabel()]),L(`click`,h,s),z(e,m),D()}Hr([`click`,`mousemove`]);function tl(e){return e+.5|0}var nl=(e,t,n)=>Math.max(Math.min(e,n),t);function rl(e){return nl(tl(e*2.55),0,255)}function il(e){return nl(tl(e*255),0,255)}function al(e){return nl(tl(e/2.55)/100,0,1)}function ol(e){return nl(tl(e*100),0,100)}var sl={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},cl=[...`0123456789ABCDEF`],ll=e=>cl[e&15],ul=e=>cl[(e&240)>>4]+cl[e&15],dl=e=>(e&240)>>4==(e&15),fl=e=>dl(e.r)&&dl(e.g)&&dl(e.b)&&dl(e.a);function pl(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&sl[e[1]]*17,g:255&sl[e[2]]*17,b:255&sl[e[3]]*17,a:t===5?sl[e[4]]*17:255}:(t===7||t===9)&&(n={r:sl[e[1]]<<4|sl[e[2]],g:sl[e[3]]<<4|sl[e[4]],b:sl[e[5]]<<4|sl[e[6]],a:t===9?sl[e[7]]<<4|sl[e[8]]:255})),n}var ml=(e,t)=>e<255?t(e):``;function hl(e){var t=fl(e)?ll:ul;return e?`#`+t(e.r)+t(e.g)+t(e.b)+ml(e.a,t):void 0}var gl=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function _l(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function vl(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function yl(e,t,n){let r=_l(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function bl(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=bl(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function Sl(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(il)}function Cl(e,t,n){return Sl(_l,e,t,n)}function wl(e,t,n){return Sl(yl,e,t,n)}function Tl(e,t,n){return Sl(vl,e,t,n)}function El(e){return(e%360+360)%360}function Dl(e){let t=gl.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?rl(+t[5]):il(+t[5]));let i=El(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?wl(i,a,o):t[1]===`hsv`?Tl(i,a,o):Cl(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function Ol(e,t){var n=xl(e);n[0]=El(n[0]+t),n=Cl(n),e.r=n[0],e.g=n[1],e.b=n[2]}function kl(e){if(!e)return;let t=xl(e),n=t[0],r=ol(t[1]),i=ol(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${al(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var Al={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},jl={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function Ml(){let e={},t=Object.keys(jl),n=Object.keys(Al),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var Nl;function Pl(e){Nl||(Nl=Ml(),Nl.transparent=[0,0,0,0]);let t=Nl[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var Fl=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Il(e){let t=Fl.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?rl(e):nl(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?rl(r):nl(r,0,255)),i=255&(t[4]?rl(i):nl(i,0,255)),a=255&(t[6]?rl(a):nl(a,0,255)),{r,g:i,b:a,a:n}}}function Ll(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${al(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var Rl=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,zl=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Bl(e,t,n){let r=zl(al(e.r)),i=zl(al(e.g)),a=zl(al(e.b));return{r:il(Rl(r+n*(zl(al(t.r))-r))),g:il(Rl(i+n*(zl(al(t.g))-i))),b:il(Rl(a+n*(zl(al(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Vl(e,t,n){if(e){let r=xl(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=Cl(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Hl(e,t){return e&&Object.assign(t||{},e)}function Ul(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=il(e[3]))):(t=Hl(e,{r:0,g:0,b:0,a:1}),t.a=il(t.a)),t}function Wl(e){return e.charAt(0)===`r`?Il(e):Dl(e)}var Gl=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Ul(t):n===`string`&&(r=pl(t)||Pl(t)||Wl(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Hl(this._rgb);return e&&(e.a=al(e.a)),e}set rgb(e){this._rgb=Ul(e)}rgbString(){return this._valid?Ll(this._rgb):void 0}hexString(){return this._valid?hl(this._rgb):void 0}hslString(){return this._valid?kl(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Bl(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=il(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=tl(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Vl(this._rgb,2,e),this}darken(e){return Vl(this._rgb,2,-e),this}saturate(e){return Vl(this._rgb,1,e),this}desaturate(e){return Vl(this._rgb,1,-e),this}rotate(e){return Ol(this._rgb,e),this}};function Kl(){}var ql=(()=>{let e=0;return()=>e++})();function Jl(e){return e==null}function Yl(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function Xl(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function Zl(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function Ql(e,t){return Zl(e)?e:t}function $l(e,t){return e===void 0?t:e}var eu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,tu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function nu(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function ru(e,t,n,r){let i,a,o;if(Yl(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function fu(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function pu(e){let t=fu(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function mu(e,t){return(du[t]||(du[t]=pu(t)))(e)}function hu(e){return e.charAt(0).toUpperCase()+e.slice(1)}var gu=e=>e!==void 0,_u=e=>typeof e==`function`,vu=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function yu(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var bu=Math.PI,xu=2*bu,Su=xu+bu,Cu=1/0,wu=bu/180,Tu=bu/2,Eu=bu/4,Du=bu*2/3,Ou=Math.log10,ku=Math.sign;function Au(e,t,n){return Math.abs(e-t)e-t).pop(),t}function Nu(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Pu(e){return!Nu(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Fu(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Iu(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Ju(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var Yu=(e,t,n,r)=>Ju(e,n,r?r=>{let i=e[r][t];return ie[r][t]Ju(e,n,r=>e[r][t]>=n);function Zu(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+hu(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function ed(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(Qu.forEach(t=>{delete e[t]}),delete e._chartjs)}function td(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var nd=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function rd(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,nd.call(window,()=>{r=!1,e.apply(t,n)}))}}function id(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var ad=e=>e===`start`?`left`:e===`end`?`right`:`center`,od=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,sd=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function cd(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(Yu(c,u,d).lo,n?r:Yu(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!Jl(e[s.axis]));i-=Math.max(0,e)}i=Gu(i,0,r-1)}if(m){let e=Math.max(Yu(c,o.axis,f,!0).hi+1,n?0:Yu(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!Jl(e[s.axis]));e+=Math.max(0,t)}a=Gu(e,i,r)-i}else a=r-i}return{start:i,count:a}}function ld(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var ud=e=>e===0||e===1,dd=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*xu/n)),fd=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*xu/n)+1,pd={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Tu)+1,easeOutSine:e=>Math.sin(e*Tu),easeInOutSine:e=>-.5*(Math.cos(bu*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>ud(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>ud(e)?e:dd(e,.075,.3),easeOutElastic:e=>ud(e)?e:fd(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return ud(e)?e:e<.5?.5*dd(e*2,t,n):.5+.5*fd(e*2-1,t,n)},easeInBack(e){return e*e*(2.70158*e-1.70158)},easeOutBack(e){return--e*e*(2.70158*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-pd.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?pd.easeInBounce(e*2)*.5:pd.easeOutBounce(e*2-1)*.5+.5};function md(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function hd(e){return md(e)?e:new Gl(e)}function gd(e){return md(e)?e:new Gl(e).saturate(.5).darken(.1).hexString()}var _d=[`x`,`y`,`borderWidth`,`radius`,`tension`],vd=[`color`,`borderColor`,`backgroundColor`];function yd(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:vd},numbers:{type:`number`,properties:_d}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function bd(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var xd=new Map;function Sd(e,t){t||={};let n=e+JSON.stringify(t),r=xd.get(n);return r||(r=new Intl.NumberFormat(e,t),xd.set(n,r)),r}function Cd(e,t,n){return Sd(t,n).format(e)}var wd={values(e){return Yl(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Td(e,n)}let o=Ou(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),Cd(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(Ou(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?wd.numeric.call(this,e,t,n):``}};function Td(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Ed={formatters:wd};function Dd(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Ed.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var Od=Object.create(null),kd=Object.create(null);function Ad(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>gd(t.backgroundColor),this.hoverBorderColor=(e,t)=>gd(t.borderColor),this.hoverColor=(e,t)=>gd(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return jd(this,e,t)}get(e){return Ad(this,e)}describe(e,t){return jd(kd,e,t)}override(e,t){return jd(Od,e,t)}route(e,t,n,r){let i=Ad(this,e),a=Ad(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return Xl(e)?Object.assign({},t,e):$l(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[yd,bd,Dd]);function Nd(e){return!e||Jl(e.size)||Jl(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Pd(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Fd(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function Bd(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Gd(e,a),c=0;c+e||0;function ef(e,t){let n={},r=Xl(t),i=r?Object.keys(t):t,a=Xl(e)?r?n=>$l(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=$d(a(e));return n}function tf(e){return ef(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function nf(e){return ef(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function rf(e){let t=tf(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function af(e,t){e||={},t||=Md.font;let n=$l(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=$l(e.style,t.style);r&&!(``+r).match(Zd)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:$l(e.family,t.family),lineHeight:Qd($l(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:$l(e.weight,t.weight),string:``};return i.string=Nd(i),i}function of(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function cf(e,t){return Object.assign(Object.create(e),t)}function lf(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Tf(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>lf([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return mf(n,r,()=>wf(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Ef(e).includes(t)},ownKeys(e){return Ef(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function uf(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:df(e,r),setContext:t=>uf(e,t,n,r),override:i=>uf(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return mf(e,t,()=>hf(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function df(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:_u(n)?n:()=>n,isIndexable:_u(r)?r:()=>r}}var ff=(e,t)=>e?e+hu(t):t,pf=(e,t)=>Xl(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function mf(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function hf(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return _u(s)&&o.isScriptable(t)&&(s=gf(t,s,e,n)),Yl(s)&&s.length&&(s=_f(t,s,e,o.isIndexable)),pf(t,s)&&(s=uf(s,i,a&&a[t],o)),s}function gf(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),pf(e,c)&&(c=xf(i._scopes,i,e,c)),c}function _f(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(Xl(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=xf(r,i,e,c);t.push(uf(n,a,o&&o[e],s))}}return t}function vf(e,t,n){return _u(e)?e(t,n):e}var yf=(e,t)=>e===!0?t:typeof e==`string`?mu(t,e):void 0;function bf(e,t,n,r,i){for(let a of t){let t=yf(n,a);if(t){e.add(t);let a=vf(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function xf(e,t,n,r){let i=t._rootScopes,a=vf(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=Sf(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=Sf(s,o,a,c,r),c===null)?!1:lf(Array.from(s),[``],i,a,()=>Cf(t,n,r))}function Sf(e,t,n,r,i){for(;n;)n=bf(e,t,n,r,i);return n}function Cf(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Yl(i)&&Xl(n)?n:i||{}}function wf(e,t,n,r){let i;for(let a of t)if(i=Tf(ff(a,e),n),i!==void 0)return pf(e,i)?xf(n,r,e,i):i}function Tf(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Ef(e){let t=e._keys;return t||=e._keys=Df(e._scopes),t}function Df(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function Of(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;ste===`x`?`y`:`x`;function Mf(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=Vu(a,i),c=Vu(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Nf(e,t,n){let r=e.length,i,a,o,s,c,l=Af(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)Ff(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function Uf(e,t){return Hf(e).getPropertyValue(t)}var Wf=[`top`,`right`,`bottom`,`left`];function Gf(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Wf[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var Kf=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function qf(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(Kf(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Jf(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Hf(n),a=i.boxSizing===`border-box`,o=Gf(i,`padding`),s=Gf(i,`border`,`width`),{x:c,y:l,box:u}=qf(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function Yf(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Bf(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Hf(a),s=Gf(o,`border`,`width`),c=Gf(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=Vf(o.maxWidth,a,`clientWidth`),i=Vf(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||Cu,maxHeight:i||Cu}}var Xf=e=>Math.round(e*10)/10;function Zf(e,t,n,r){let i=Hf(e),a=Gf(i,`margin`),o=Vf(i.maxWidth,e,`clientWidth`)||Cu,s=Vf(i.maxHeight,e,`clientHeight`)||Cu,c=Yf(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Gf(i,`border`,`width`),t=Gf(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=Xf(Math.min(l,o,c.maxWidth)),u=Xf(Math.min(u,s,c.maxHeight)),l&&!u&&(u=Xf(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=Xf(Math.floor(u*r))),{width:l,height:u}}function Qf(e,t,n){let r=t||1,i=Xf(e.height*r),a=Xf(e.width*r);e.height=Xf(e.height),e.width=Xf(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var $f=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};zf()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function ep(e,t){let n=Uf(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function tp(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function np(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function rp(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=tp(e,i,n),s=tp(i,a,n),c=tp(a,t,n);return tp(tp(o,s,n),tp(s,c,n),n)}var ip=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},ap=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function op(e,t,n){return e?ip(t,n):ap()}function sp(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function cp(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function lp(e){return e===`angle`?{between:Wu,compare:Hu,normalize:Uu}:{between:qu,compare:(e,t)=>e-t,normalize:e=>e}}function up({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function dp(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=lp(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(up({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(up({start:g,end:d,loop:f,count:o,style:p})),m}function pp(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function hp(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function gp(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=mp(n,i,a,r);return r===!0?_p(e,[{start:o,end:s,loop:a}],n,t):_p(e,hp(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,nd.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Tp=`transparent`,Ep={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=hd(e||Tp),i=r.valid&&hd(t||Tp);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},Dp=class{constructor(e,t,n,r){let i=t[n];r=of([e.to,r,i,e.from]);let a=of([e.from,i,r]);this._active=!0,this._fn=e.fn||Ep[e.type||typeof a],this._easing=pd[e.easing]||pd.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=of([e.to,t,r,e.from]),this._from=of([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!Xl(i))return;let a={};for(let e of t)a[e]=i[e];(Yl(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=Ap(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&kp(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new Dp(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return wp.add(this._chart,n),!0}};function kp(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function Hp(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=Rp(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function Wp(e,t){return cf(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Gp(e,t,n){return cf(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function Kp(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var qp=e=>e===`reset`||e===`none`,Jp=(e,t)=>t?e:Object.assign({},e),Yp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Pp(n,!0),values:null},Xp=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Lp(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&Kp(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=$l(n.xAxisID,Up(e,`x`)),a=t.yAxisID=$l(n.yAxisID,Up(e,`y`)),o=t.rAxisID=$l(n.rAxisID,Up(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&ed(this._data,this),e._stacked&&Kp(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(Xl(t)){let e=this._cachedMeta;this._data=Ip(t,e)}else if(n!==t){if(n){ed(n,this);let e=this._cachedMeta;Kp(e),e._parsed=[]}t&&Object.isExtensible(t)&&$u(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Lp(t.vScale,t),t.stack!==n.stack&&(r=!0,Kp(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Hp(this,t._parsed),t._stacked=Lp(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length||n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=Yl(r[e])?this.parseArrayData(n,r,e,t):Xl(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Jp(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new Op(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||qp(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){qp(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!qp(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function Qp(e){let t=e.iScale,n=Zp(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(gu(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function nm(e,t,n,r){return Yl(e)?tm(e,t,n,r):t[n.axis]=n.parse(e,r),t}function rm(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):ku(e)}function om(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(Jl(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[$l(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;dWu(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>Wu(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(Tu,u,f),_=m(bu,l,d),v=m(bu+Tu,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var hm=class extends Xp{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(Xl(n[e])){let{key:e=`value`}=this._parsing;i=t=>+mu(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*xu:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Cd(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=Jl(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},_m=class extends Xp{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Cd(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return Of.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(rt.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*bu,d=u,f,p=360/this.countVisibleElements();for(f=0;f{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?Lu(this.resolveDataElementOptions(e,t).angle||n):0}},vm=Object.freeze({__proto__:null,BarController:fm,BubbleController:pm,DoughnutController:hm,LineController:gm,PieController:class extends hm{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:_m,RadarController:class extends Xp{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return Of.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function ym(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var bm={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return ym()}parse(){return ym()}format(){return ym()}add(){return ym()}diff(){return ym()}startOf(){return ym()}endOf(){return ym()}}};function xm(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?Xu:Yu;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!Jl(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!Jl(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function Sm(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var km={evaluateInteractionItems:Sm,modes:{index(e,t,n,r){let i=Jf(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?wm(e,i,a,r,o):Dm(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Jf(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?wm(e,i,a,r,o):Dm(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Mm(e,t){return e.filter(e=>Am.indexOf(e.pos)===-1&&e.box.axis===t)}function Nm(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Pm(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=Nm(jm(t,`left`),!0),i=Nm(jm(t,`right`)),a=Nm(jm(t,`top`),!0),o=Nm(jm(t,`bottom`)),s=Mm(t,`x`),c=Mm(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:jm(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function Rm(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function zm(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Bm(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!Xl(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&zm(o,a.getPadding());let s=Math.max(0,t.outerWidth-Rm(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-Rm(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function Vm(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Hm(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Um(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);zm(f,rf(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Im(c.concat(l),d);Um(s.fullSize,p,d,m),Um(c,p,d,m),Um(l,p,d,m)&&Um(c,p,d,m),Vm(p),Gm(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,Gm(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},ru(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},qm=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},Jm=class extends qm{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},Ym=`$chartjs`,Xm={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},Zm=e=>e===null||e===``;function Qm(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[Ym]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,Zm(i)){let t=ep(e,`width`);t!==void 0&&(e.width=t)}if(Zm(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=ep(e,`height`);t!==void 0&&(e.height=t)}return e}var $m=$f?{passive:!0}:!1;function eh(e,t,n){e&&e.addEventListener(t,n,$m)}function th(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,$m)}function nh(e,t){let n=Xm[e.type]||e.type,{x:r,y:i}=Jf(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function rh(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function ih(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=rh(n.addedNodes,r),t&&=!rh(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function ah(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=rh(n.removedNodes,r),t&&=!rh(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var oh=new Map,sh=0;function ch(){let e=window.devicePixelRatio;e!==sh&&(sh=e,oh.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function lh(e,t){oh.size||window.addEventListener(`resize`,ch),oh.set(e,t)}function uh(e){oh.delete(e),oh.size||window.removeEventListener(`resize`,ch)}function dh(e,t,n){let r=e.canvas,i=r&&Bf(r);if(!i)return;let a=rd((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),lh(e,a),o}function fh(e,t,n){n&&n.disconnect(),t===`resize`&&uh(e)}function ph(e,t,n){let r=e.canvas,i=rd(t=>{e.ctx!==null&&n(nh(t,e))},e);return eh(r,t,i),i}var mh=class extends qm{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(Qm(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[Ym])return!1;let n=t[Ym].initial;[`height`,`width`].forEach(e=>{let r=n[e];Jl(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[Ym],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:ih,detach:ah,resize:dh}[t]||ph)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:fh,detach:fh,resize:fh}[t]||th)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return Zf(e,t,n,r)}isAttached(e){let t=e&&Bf(e);return!!(t&&t.isConnected)}};function hh(e){return!zf()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?Jm:mh}var gh=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Pu(this.x)&&Pu(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function _h(e,t){let n=e.options.ticks,r=vh(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?bh(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return xh(t,l,a,o/i),l;let u=yh(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Sh(t,l,u,Jl(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function bh(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Th=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,Eh=(e,t)=>Math.min(t||e,e);function Dh(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function kh(e,t){ru(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:Ql(t,Ql(n,t)),max:Ql(n,Ql(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){nu(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=sf(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=Gu(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-Ah(e.grid)-t.padding-jh(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=Ru(Math.min(Math.asin(Gu((l.highest.height+6)/o,-1,1)),Math.asin(Gu(s/c,-1,1))-Math.asin(Gu(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){nu(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){nu(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=jh(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=Ah(i)+a):(e.height=this.maxHeight,e.width=Ah(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Lu(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){nu(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return Ku(this._alignToPixels?Id(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=Ah(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Id(n,e,p)},g,_,v,y,b,x,S,C,w,ee,te,ne;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,ee=h(e.top)+m,ne=e.bottom;else if(a===`bottom`)g=h(this.top),ee=e.top,ne=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,te=e.right;else if(a===`right`)g=h(this.left),w=e.left,te=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(Xl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}ee=e.top,ne=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(Xl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,te=e.right}let re=$l(r.ticks.maxTicksLimit,l),ie=Math.max(1,Math.ceil(l/re));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:ne,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:re,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Lu(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Md.route(a,i,c,s)})}function Bh(e){return`id`in e&&`defaults`in e}var Vh=new class{constructor(){this.controllers=new Lh(Xp,`datasets`,!0),this.elements=new Lh(gh,`elements`),this.plugins=new Lh(Object,`plugins`),this.scales=new Lh(Ih,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):ru(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=hu(e);nu(n[`before`+r],[],n),t[e](n),nu(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Uh(e){let t={},n=[],r=Object.keys(Vh.plugins.items);for(let e=0;e1&&Xh(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function $h(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function eg(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return $h(e,`x`,n[0])||$h(e,`y`,n[0])}return{}}function tg(e,t){let n=Od[e.type]||{scales:{}},r=t.scales||{},i=qh(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!Xl(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=Qh(t,o,eg(t,e),Md.scales[o.type]),c=Yh(s,i),l=n.scales||{};a[t]=lu(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||qh(i,t),s=(Od[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=Jh(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),lu(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];lu(t,[Md.scales[t.type],Md.scale])}),a}function ng(e){let t=e.options||={};t.plugins=$l(t.plugins,{}),t.scales=tg(e,t)}function rg(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function ig(e){return e||={},e.data=rg(e.data),ng(e),e}var ag=new Map,og=new Set;function sg(e,t){let n=ag.get(e);return n||(n=t(),ag.set(e,n),og.add(n)),n}var cg=(e,t,n)=>{let r=mu(t,n);r!==void 0&&e.add(r)},lg=class{constructor(e){this._config=ig(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=rg(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),ng(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return sg(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return sg(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return sg(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return sg(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>cg(s,e,t))),t.forEach(e=>cg(s,r,e)),t.forEach(e=>cg(s,Od[i]||{},e)),t.forEach(e=>cg(s,Md,e)),t.forEach(e=>cg(s,kd,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),og.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,Od[t]||{},Md.datasets[t]||{},{type:t},Md,kd]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=ug(this._resolverCache,e,r),s=a;if(fg(a,t)){i.$shared=!1,n=_u(n)?n():n;let t=this.createResolver(e,n,o);s=uf(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=ug(this._resolverCache,e,n);return Xl(t)?uf(i,t,void 0,r):i}};function ug(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:lf(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var dg=e=>Xl(e)&&Object.getOwnPropertyNames(e).some(t=>_u(e[t]));function fg(e,t){let{isScriptable:n,isIndexable:r}=df(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(_u(o)||dg(o))||a&&Yl(o))return!0}return!1}var pg=`4.5.1`,mg=[`top`,`bottom`,`left`,`right`,`chartArea`];function hg(e,t){return e===`top`||e===`bottom`||mg.indexOf(e)===-1&&t===`x`}function gg(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function _g(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),nu(n&&n.onComplete,[e],t)}function vg(e){let t=e.chart,n=t.options.animation;nu(n&&n.onProgress,[e],t)}function yg(e){return zf()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var bg={},xg=e=>{let t=yg(e);return Object.values(bg).filter(e=>e.canvas===t).pop()};function Sg(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function Cg(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var wg=class{static defaults=Md;static instances=bg;static overrides=Od;static registry=Vh;static version=pg;static getChart=xg;static register(...e){Vh.add(...e),Tg()}static unregister(...e){Vh.remove(...e),Tg()}constructor(e,t){let n=this.config=new lg(t),r=yg(e),i=xg(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(hh(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=ql(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Hh,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=id(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],bg[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}wp.listen(this,`complete`,_g),wp.listen(this,`progress`,vg),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return Jl(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Vh}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():Qf(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Ld(this.canvas,this.ctx),this}stop(){return wp.stop(this),this}resize(e,t){wp.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,Qf(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),nu(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){ru(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=Qh(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),ru(i,t=>{let i=t.options,a=i.id,o=Qh(a,i),s=$l(i.type,t.dtype);(i.position===void 0||hg(i.position,o)!==hg(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(Vh.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),ru(r,(e,t)=>{e||delete n[t]}),ru(n,e=>{Km.configure(this,e,e.options),Km.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(gg(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){ru(this.scales,e=>{Km.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!vu(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)Sg(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;Km.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],ru(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=Cp(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&Vd(t,r),e.controller.draw(),r&&Hd(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return Bd(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=km.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=cf(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);gu(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),wp.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};ru(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){ru(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},ru(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});iu(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=yu(e),c=Cg(e,this._lastEvent,n,s);n&&(this._lastEvent=null,nu(i.onHover,[e,o,this],this),s&&nu(i.onClick,[e,o,this],this));let l=!iu(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Tg(){return ru(wg.instances,e=>e._plugins.invalidate())}function Eg(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,Uu(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,Uu(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*Uu(r-n));if(u===`round`)e.arc(i,a,t,n-bu/2,r+bu/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+bu/2)+i,c=-o*Math.sin(n+bu/2)+a,l=o*Math.cos(r+bu/2)+i,u=o*Math.sin(r+bu/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Dg(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+Tu,r-Tu),e.closePath(),e.clip()}function Og(e){return ef(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function kg(e,t,n,r){let i=Og(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return Gu(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:Gu(i.innerStart,0,o),innerEnd:Gu(i.innerEnd,0,o)}}function Ag(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function jg(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/bu)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=kg(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,ee=_-y/C,te=f+b,ne=f+x,re=g+b/te,ie=_-x/ne;if(e.beginPath(),a){let t=(w+ee)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,ee),y>0){let t=Ag(C,ee,o,s);e.arc(t.x,t.y,y,ee,_+Tu)}let n=Ag(ne,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=Ag(ne,ie,o,s);e.arc(t.x,t.y,x,_+Tu,ie+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=Ag(te,re,o,s);e.arc(t.x,t.y,b,re+Math.PI,g-Tu)}let i=Ag(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=Ag(S,w,o,s);e.arc(t.x,t.y,v,g-Tu,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(ee)*d+o,i=Math.sin(ee)*d+s;e.lineTo(r,i)}e.closePath()}function Mg(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){jg(e,t,n,r,c,i);for(let t=0;t=bu&&p===0&&u!==`miter`&&Eg(e,t,h),a||(jg(e,t,n,r,h,i),e.stroke())}var Pg=class extends gh{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=Bu(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=$l(l,o-a),f=Wu(r,a,o)&&a!==o,p=d>=xu||f,m=qu(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>xu?Math.floor(n/xu):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(bu,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Mg(e,this,s,i,a),Ng(e,this,s,i,a),e.restore()}};function Fg(e,t,n=t){e.lineCap=$l(n.borderCapStyle,t.borderCapStyle),e.setLineDash($l(n.borderDash,t.borderDash)),e.lineDashOffset=$l(n.borderDashOffset,t.borderDashOffset),e.lineJoin=$l(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=$l(n.borderWidth,t.borderWidth),e.strokeStyle=$l(n.borderColor,t.borderColor)}function Ig(e,t,n){e.lineTo(n.x,n.y)}function Lg(e){return e.stepped?Ud:e.tension||e.cubicInterpolationMode===`monotone`?Wd:Ig}function Rg(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function Vg(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?Bg:zg}function Hg(e){return e.stepped?np:e.tension||e.cubicInterpolationMode===`monotone`?rp:tp}function Ug(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Fg(e,t.options),e.stroke(i)}function Wg(e,t,n,r){let{segments:i,options:a}=t,o=Vg(t);for(let s of i)Fg(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var Gg=typeof Path2D==`function`;function Kg(e,t,n,r){Gg&&!t.options.segment?Ug(e,t,n,r):Wg(e,t,n,r)}var qg=class extends gh{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;Rf(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=gp(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=pp(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Hg(n),c,l;for(c=0,l=a.length;ce.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function c_(e){return o_[e%o_.length]}function l_(e){return s_[e%s_.length]}function u_(e,t){return e.borderColor=c_(t),e.backgroundColor=l_(t),++t}function d_(e,t){return e.backgroundColor=e.data.map(()=>c_(t++)),t}function f_(e,t){return e.backgroundColor=e.data.map(()=>l_(t++)),t}function p_(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof hm?t=d_(n,t):i instanceof _m?t=f_(n,t):i&&(t=u_(n,t))}}function m_(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function h_(e){return e&&(e.borderColor||e.backgroundColor)}function g_(){return Md.borderColor!==`rgba(0,0,0,0.1)`||Md.backgroundColor!==`rgba(0,0,0,0.1)`}var __={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=m_(r)||h_(i)||a&&m_(a)||g_();if(!n.forceOverride&&o)return;let s=p_(e);r.forEach(s)}};function v_(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;dp&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function y_(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;oh&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!Jl(d)&&!Jl(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function b_(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function x_(e){e.data.datasets.forEach(e=>{b_(e)})}function S_(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=Gu(Yu(t,a.axis,o).lo,0,n-1)),i=l?Gu(Yu(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var C_={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){x_(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(of([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=S_(s,c);if(d<=(n.threshold||4*r)){b_(t);return}Jl(a)&&(t._data=c,delete t.data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=v_(c,u,d,r,n);break;case`min-max`:f=y_(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){x_(e)}};function w_(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=D_(r,s,i);let c=T_(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=pp(t,c);for(let t of l){let r=T_(n,a[t.start],a[t.end],t.loop),s=fp(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:O_(c,r,`start`,Math.max)},end:{[n]:O_(c,r,`end`,Math.min)}})}}return o}function T_(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=Uu(i),a=Uu(a)),{property:e,start:i,end:a}}function E_(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=D_(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function D_(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function O_(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function k_(e,t){let n=[],r=!1;return Yl(e)?(r=!0,n=e):n=E_(e,t),n.length?new qg({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function A_(e){return e&&e.fill!==!1}function j_(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!Zl(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function M_(e,t,n){let r=I_(e);if(Xl(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return Zl(i)&&Math.floor(i)===i?N_(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function N_(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function P_(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:Xl(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function F_(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:Xl(e)?e.value:t.getBaseValue(),r}function I_(e){let t=e.options,n=t.fill,r=$l(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function L_(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=R_(t,n);s.push(k_({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&q_(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;A_(n)&&q_(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!A_(r)||n.drawTime!==`beforeDatasetDraw`||q_(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},tv=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},nv=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,rv=class extends gh{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=nu(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=af(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=tv(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=iv(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=op(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=od(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=od(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=od(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=od(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;Vd(e,this),this._draw(),Hd(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Md.color,s=op(e.rtl,this.left,this.width),c=af(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=tv(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=$l(n.lineWidth,1);if(r.fillStyle=$l(n.fillStyle,o),r.lineCap=$l(n.lineCap,`butt`),r.lineDashOffset=$l(n.lineDashOffset,0),r.lineJoin=$l(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=$l(n.strokeStyle,o),r.setLineDash($l(n.lineDash,[])),a.usePointStyle){let o={radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},c=s.xPlus(e,p/2),l=t+d;zd(r,o,c,l,a.pointStyleWidth&&p)}else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=nf(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?Yd(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){Jd(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:od(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:od(i,this.top+y+l,this.bottom-t[0].height),line:0},sp(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=od(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=od(i,this.top+y+l,this.bottom-t[f.line].height));let w=s.x(S);if(g(w,C,o),S=sd(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=sv(o,e)+l}else f.y+=b}),cp(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=af(t.font),r=rf(t.padding);if(!t.display)return;let i=op(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=od(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+od(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=od(o,u,u+d);a.textAlign=i.textAlign(ad(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,Jd(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=af(e.font),n=rf(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(qu(e,this.left,this.right)&&qu(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function ov(e,t,n){let r=e;return typeof t.text!=`string`&&(r=sv(t,n)),r}function sv(e,t){return t*(e.text?e.text.length:0)}function cv(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var lv={id:`legend`,_element:rv,start(e,t,n){let r=e.legend=new rv({ctx:e.ctx,options:n,chart:e});Km.configure(e,r,n),Km.addBox(e,r)},stop(e){Km.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;Km.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=rf(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},uv=class extends gh{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=Yl(n.text)?n.text.length:1;this._padding=rf(n.padding);let i=r*af(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=od(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=od(o,r,t),s=bu*-.5):(l=i-e,u=od(o,t,r),s=bu*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=af(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);Jd(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:ad(t.align),textBaseline:`middle`,translation:[i,a]})}};function dv(e,t){let n=new uv({ctx:e.ctx,options:t,chart:e});Km.configure(e,n,t),Km.addBox(e,n),e.titleBlock=n}var fv={id:`title`,_element:uv,start(e,t,n){dv(e,n)},stop(e){let t=e.titleBlock;Km.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;Km.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},pv=new WeakMap,mv={id:`subtitle`,start(e,t,n){let r=new uv({ctx:e.ctx,options:n,chart:e});Km.configure(e,r,n),Km.addBox(e,r),pv.set(e,r)},stop(e){Km.removeBox(e,pv.get(e)),pv.delete(e)},beforeUpdate(e,t,n){let r=pv.get(e);Km.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`normal`},fullSize:!0,padding:0,position:`top`,text:``,weight:1500},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},hv={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` -`):e}function vv(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function yv(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=af(t.bodyFont),l=af(t.titleFont),u=af(t.footerFont),d=a.length,f=i.length,p=r.length,m=rf(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,ru(e.title,y),n.font=c.string,ru(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,ru(r,e=>{ru(e.before,y),ru(e.lines,y),ru(e.after,y)}),v=0,n.font=u.string,ru(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function bv(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function xv(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function Sv(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),xv(l,e,t,n)&&(l=`center`),l}function Cv(e,t,n){let r=n.yAlign||t.yAlign||bv(e,n);return{xAlign:n.xAlign||t.xAlign||Sv(e,t,n,r),yAlign:r}}function wv(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Tv(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function Ev(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=nf(o),m=wv(t,s),h=Tv(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:Gu(m,0,r.width-t.width),y:Gu(h,0,r.height-t.height)}}function Dv(e,t,n){let r=rf(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function Ov(e){return gv([],_v(e))}function kv(e,t,n){return cf(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function Av(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var jv={beforeTitle:Kl,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=Av(n,e);gv(t.before,_v(Mv(i,`beforeLabel`,this,e))),gv(t.lines,Mv(i,`label`,this,e)),gv(t.after,_v(Mv(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return Ov(Mv(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Mv(n,`beforeFooter`,this,e),i=Mv(n,`footer`,this,e),a=Mv(n,`afterFooter`,this,e),o=[];return o=gv(o,_v(r)),o=gv(o,_v(i)),o=gv(o,_v(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),ru(o,t=>{let n=Av(e.callbacks,t);r.push(Mv(n,`labelColor`,this,t)),i.push(Mv(n,`labelPointStyle`,this,t)),a.push(Mv(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=hv[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=yv(this,n),o=Object.assign({},e,t),s=Cv(this.chart,n,o),c=Ev(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=nf(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=op(n.rtl,this.x,this.width);for(e.x=Dv(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=af(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,Yd(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),Yd(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=af(n.bodyFont),d=u.lineHeight,f=0,p=op(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=Dv(this,h,n),t.fillStyle=n.bodyColor,ru(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=hv[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=yv(this,e),o=Object.assign({},n,this._size),s=Cv(t,e,o),c=Ev(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=rf(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),sp(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),cp(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!iu(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!iu(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=hv[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Pv=Object.freeze({__proto__:null,Colors:__,Decimation:C_,Filler:ev,Legend:lv,SubTitle:mv,Title:fv,Tooltip:{id:`tooltip`,_element:Nv,positioners:hv,afterInit(e,t,n){n&&(e.tooltip=new Nv({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:jv},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Fv=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Iv(e,t,n,r){let i=e.indexOf(t);return i===-1?Fv(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Lv=(e,t)=>e===null?null:Gu(Math.round(e),0,t);function Rv(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function Bv(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!Jl(a),_=!Jl(o),v=!Jl(c),y=(h-m)/(u+1),b=ju((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=ju(w*b/p/f)*f),Jl(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Fu((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=Au(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let ee=Math.max(zu(b),zu(S));x=10**(Jl(s)?ee:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let te=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&Au(n[n.length-1].value,o,Vv(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Vv(e,t,{horizontal:n,minRotation:r}){let i=Lu(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Hv=class extends Ih{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return Jl(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=ku(r),t=ku(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=Bv({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Iu(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return Cd(e,this.chart.options.locale,this.options.ticks.format)}},Uv=class extends Hv{static id=`linear`;static defaults={ticks:{callback:Ed.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Zl(e)?e:0,this.max=Zl(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Lu(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Wv=e=>Math.floor(Ou(e)),Gv=(e,t)=>10**(Wv(e)+t);function Kv(e){return e/10**Wv(e)==1}function qv(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Jv(e,t){let n=Wv(t-e);for(;qv(e,t,n)>10;)n++;for(;qv(e,t,n)<10;)n--;return Math.min(n,Wv(e))}function Yv(e,{min:t,max:n}){t=Ql(e.min,t);let r=[],i=Wv(t),a=Jv(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=Ql(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=Ql(e.max,f);return r.push({value:p,major:Kv(p),significand:d}),r}var Xv=class extends Ih{static id=`logarithmic`;static defaults={ticks:{callback:Ed.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Hv.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return Zl(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Zl(e)?Math.max(0,e):null,this.max=Zl(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Zl(this._userMin)&&(this.min=e===Gv(this.min,0)?Gv(this.min,-1):Gv(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Gv(n,-1)),a(Gv(r,1)))),n<=0&&i(Gv(r,-1)),r<=0&&a(Gv(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Yv({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Iu(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:Cd(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=Ou(e),this._valueRange=Ou(this.max)-Ou(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(Ou(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function Zv(e){let t=e.ticks;if(t.display&&e.display){let e=rf(t.backdropPadding);return $l(t.font&&t.font.size,Md.font.size)+e.height}return 0}function Qv(e,t,n){return n=Yl(n)?n:[n],{w:Fd(e,t.string,n),h:n.length*t.lineHeight}}function $v(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function ey(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?bu/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function ny(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(Ru(Uu(c.angle+Tu))),u=sy(c.y,s.h,l),d=ay(l),f=oy(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function ry(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(Bd({x:n,y:r},t)||Bd({x:n,y:a},t)||Bd({x:i,y:r},t)||Bd({x:i,y:a},t))}function iy(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Zv(a)/2,additionalAngle:o?bu/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function cy(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!Jl(s)){let n=nf(t.borderRadius),c=rf(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),Yd(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function ly(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));cy(n,a,t);let o=af(a.font),{x:s,y:c,textAlign:l}=t;Jd(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function uy(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,xu);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=nu(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?ey(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=xu/(this._pointLabels.length||1),n=this.options.startAngle||0;return Uu(e*t+Lu(n))}getDistanceFromCenterForValue(e){if(Jl(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(Jl(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);dy(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=af(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=rf(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}Jd(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},my={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},hy=Object.keys(my);function gy(e,t){return e-t}function _y(e,t){if(Jl(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),Zl(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Pu(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function vy(e,t,n,r){let i=hy.length;for(let a=hy.indexOf(e);a=hy.indexOf(n);a--){let n=hy[a];if(my[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return hy[n?hy.indexOf(n):0]}function by(e){for(let t=hy.indexOf(e)+1,n=hy.length;t=t?n[r]:n[i];e[a]=!0}}function Sy(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function Cy(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=Gu(t,0,a),n=Gu(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||vy(i.minUnit,t,n,this._getLabelCapacity(t)),o=$l(r.ticks.stepSize,1),s=a===`week`&&i.isoWeekday,c=Pu(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return nu(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=Yu(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=Yu(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var Ey=class extends wy{static id=`timeseries`;static defaults=wy.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=Ty(t,this.min),this._tableRange=Ty(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(Ty(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return Ty(this._table,n*this._tableRange+this._minPos,!0)}},Dy=[vm,a_,Pv,Object.freeze({__proto__:null,CategoryScale:zv,LinearScale:Uv,LogarithmicScale:Xv,RadialLinearScale:py,TimeScale:wy,TimeSeriesScale:Ey})];wg.register(...Dy);var Oy=wg,ky=R(``);function Ay(e,t){E(t,!0);let n=G(t,`class`,3,``),r=G(t,`ariaLabel`,3,``);function i(e){if(Oa.tick,typeof t.build!=`function`)return;let n=t.build();if(!n)return;let r=new Oy(e.getContext(`2d`),n);return()=>r.destroy()}var a=ky();Mi(a,()=>i),F(()=>{U(a,1,Fi(n())),W(a,`aria-label`,r())}),z(e,a),D()}var jy=R(``),My=R(`
            `);function Ny(e,t){E(t,!0);let n=G(t,`options`,19,()=>[]),r=G(t,`ariaLabel`,3,``),i=G(t,`class`,3,``);var a=My();H(a,21,n,e=>e.value,(e,n)=>{var r=jy();let i;var a=M(r,!0);T(r),F(()=>{i=U(r,1,`segmented-btn svelte-92fh5i`,null,i,{active:t.value===I(n).value}),W(r,`aria-pressed`,t.value===I(n).value),B(a,I(n).label)}),L(`click`,r,()=>t.onchange?.(I(n).value)),z(e,r)}),T(a),F(()=>{U(a,1,Fi([`segmented-control`,i()]),`svelte-92fh5i`),W(a,`aria-label`,r())}),z(e,a),D()}Hr([`click`]);function Py(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Fy(){return{grid:Py(`--chart-grid`),text:Py(`--chart-text`),dayMarker:Py(`--chart-day-marker`),tooltipBg:Py(`--chart-tooltip-bg`),tooltipBorder:Py(`--chart-tooltip-border`),tooltipText:Py(`--chart-tooltip-text`)}}function Iy(){return{size:11,family:`'SF Mono', Menlo, Consolas, monospace`}}function Ly(e,t){return{backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,borderWidth:1,titleColor:e.tooltipText,bodyColor:e.tooltipText,callbacks:t}}function Ry(e){if(typeof document>`u`||!document.body)return e;let t=document.createElement(`span`);t.style.display=`none`,t.style.color=e,document.body.appendChild(t);let n=getComputedStyle(t).color;return document.body.removeChild(t),n||e}var zy=[`#c2845a`,`#7a9e7e`,`#d4a574`,`#b8a98e`,`#8b9e6b`,`#7d8a97`,`#c47a5a`,`#6b8e6b`,`#a09486`,`#9b7ea4`,`#c49a6c`];function By(){return[...zy]}function Vy(e){let t=5381,n=String(e||``);for(let e=0;elc(e)}}var qy={seconds:{apiName:`second`,windowLabel:`Last 60 seconds`,refreshMs:2e3},minutes:{apiName:`minute`,windowLabel:`Last 60 minutes`,refreshMs:5e3},hours:{apiName:`hour`,windowLabel:`Last 24 hours`,refreshMs:2e4},days:{apiName:`day`,windowLabel:`Last 30 days`,refreshMs:6e4}},Jy=[{value:`seconds`,label:`Seconds`},{value:`minutes`,label:`Minutes`},{value:`hours`,label:`Hours`},{value:`days`,label:`Days`}];function Yy(){return{input:0,output:0,prompt:0,local:0}}function Xy(e){return String(e).padStart(2,`0`)}function Zy(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function Qy(e,t){if(!Number.isFinite(t))return``;let n=new Date(t);switch(e){case`seconds`:return Xy(n.getHours())+`:`+Xy(n.getMinutes())+`:`+Xy(n.getSeconds());case`minutes`:return Xy(n.getHours())+`:`+Xy(n.getMinutes());case`hours`:return Xy(n.getHours())+`:00`;default:return Xy(n.getMonth()+1)+`-`+Xy(n.getDate())}}function $y(e,t){let n=[],r=[],i={input:[],output:[],prompt:[],local:[]},a=Yy();for(let o of e||[]){let e=Date.parse(o&&o.start),s=Zy(o&&o.input_tokens),c=Zy(o&&o.output_tokens),l=Zy(o&&o.prompt_cached_tokens),u=Zy(o&&o.locally_cached_tokens);n.push(Qy(t,e)),r.push(Number.isFinite(e)?e:null),i.input.push(s),i.output.push(c),i.prompt.push(l),i.local.push(u),a.input+=s,a.output+=c,a.prompt+=l,a.local+=u}return{labels:n,stamps:r,cols:i,totals:a}}function eb(e){let t=e||Yy();return t.input+t.output+t.prompt+t.local>0}function tb(e,t){return lc(Math.max(0,Math.round(e&&e[t]||0)))}function nb(e){return(qy[e]||qy.minutes).windowLabel}function rb(e,t){return`Live token throughput, `+nb(t).toLowerCase()+`. Input `+tb(e,`input`)+`, output `+tb(e,`output`)+`, prompt cached `+tb(e,`prompt`)+`, locally cached `+tb(e,`local`)+` tokens.`}function ib(e,t,n,r){let i=e=>lc(Math.max(0,Math.round(e))),a=n.stamps,o=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderWidth:0,borderRadius:0,categoryPercentage:1,barPercentage:1,stack:`tokens`});return{type:`bar`,plugins:[{id:`liveTokensDayMarks`,afterDatasetsDraw:t=>{if(r===`days`)return;let n=t.getDatasetMeta(0),i=t.chartArea;if(!n||!n.data||!i)return;let o=t.ctx;o.save(),o.font=`10px 'SF Mono', Menlo, Consolas, monospace`;let s=null;for(let t=0;t{if(!e.length)return``;let t=a[e[0].dataIndex];if(!t)return e[0].label;let n=new Date(t);return r===`days`?n.toLocaleDateString():n.toLocaleString()},label:e=>e.dataset.label+`: `+i(e.parsed.y),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+i(t)}})}}}}var ab=900,ob=new class{#e=k(`minutes`);get granularity(){return I(this.#e)}set granularity(e){A(this.#e,e,!0)}#t=k(j([]));get buckets(){return I(this.#t)}set buckets(e){A(this.#t,e,!0)}#n=k(!1);get active(){return I(this.#n)}set active(e){A(this.#n,e,!0)}#r=null;#i=null;#a=null;#o=0;#s=null;#c=!1;start(){this.stop(),this.active=!0,this.fetch(),this.#l(),this.#u()}stop(){this.active=!1,this.#r&&=(clearInterval(this.#r),null),this.#i&&=(clearTimeout(this.#i),null),this.#a&&=(clearTimeout(this.#a),null),this.#o=0,this.#s&&=(this.#s.abort(),null),this.buckets=[]}setGranularity(e){!qy[e]||e===this.granularity||(this.granularity=e,this.buckets=[],this.#l(),this.fetch())}#l(){this.#r&&=(clearInterval(this.#r),null);let e=qy[this.granularity]||qy.minutes;this.#r=setInterval(()=>{this.active&&this.fetch()},e.refreshMs)}noteUsageEvent(e){!this.active||e!==`usage.flushed`||(this.#i||=setTimeout(()=>{this.#i=null,this.fetch()},ab))}async fetch(){if(!this.active||this.#c)return;this.#c=!0;let e=this.granularity;try{let t=await gs(`/admin/usage/throughput?granularity=`+(qy[e]||qy.minutes).apiName,{label:`token throughput`});if(t.stale||!t.ok||this.granularity!==e)return;this.buckets=t.data&&Array.isArray(t.data.buckets)?t.data.buckets:[]}catch(e){if(vs(e))return;console.error(`Failed to fetch token throughput:`,e)}finally{this.#c=!1,this.active&&this.granularity!==e&&this.fetch()}}async#u(){await xs.ensureLoaded(),this.active&&xs.liveLogsVisible()&&(typeof ReadableStream>`u`||(this.#s&&this.#s.abort(),this.#s=new AbortController,this.#d(this.#s)))}async#d(e){try{let t=await ms(`/admin/live/logs?types=usage`,{signal:e.signal});if(!t.ok||!t.body||typeof t.body.getReader!=`function`){this.#p();return}this.#o=0,await Uy(t.body.getReader(),e=>this.#f(e)),this.#p()}catch(e){if(vs(e))return;console.error(`Live usage stream failed:`,e),this.#p()}}#f(e){if(!e||typeof e!=`object`)return;let t=String(e.type||``).trim();t.indexOf(`usage.`)===0&&this.noteUsageEvent(t)}#p(){if(!this.active||this.#a)return;let{attempt:e,delay:t}=Gy(this.#o);this.#o=e,this.#a=setTimeout(()=>{this.#a=null,this.#u()},t)}},sb=R(`
            `),cb=R(`
            Waiting for live requests…
            `),lb=R(`

            Live Token Throughput

            `);function ub(e,t){E(t,!0);let n=O(()=>$y(ob.buckets,ob.granularity)),r=O(()=>I(n).totals);function i(){return{input:Ry(`var(--token-input)`),output:Ry(`var(--token-output)`),prompt:Ry(`var(--token-prompt)`),local:Ry(`var(--token-local)`)}}let a=[{metric:`input`,label:`Input Tokens`,colorVar:`--token-input`},{metric:`output`,label:`Output Tokens`,colorVar:`--token-output`},{metric:`prompt`,label:`Prompt (Input) Cached`,colorVar:`--token-prompt`},{metric:`local`,label:`Locally Cached`,colorVar:`--token-local`}];var o=lb(),s=M(o),c=M(s),l=P(M(c),2),u=M(l);let d;var f=P(u,2),p=M(f,!0);T(f),T(l),T(c),Ny(P(c,2),{ariaLabel:`Live token throughput granularity`,get options(){return Jy},get value(){return ob.granularity},onchange:e=>ob.setGranularity(e)}),T(s);var m=P(s,2);H(m,21,()=>a,e=>e.metric,(e,t)=>{var n=sb(),i=M(n),a=P(i,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{Hi(i,`background: var(${I(t).colorVar??``})`),B(o,I(t).label),B(c,e)},[()=>tb(I(r),I(t).metric)]),z(e,n)}),T(m);var h=P(m,2),g=M(h);{let e=O(()=>rb(I(r),ob.granularity));Ay(g,{get ariaLabel(){return I(e)},build:()=>ib(Fy(),i(),I(n),ob.granularity)})}var _=P(g,2),v=e=>{z(e,cb())},y=O(()=>!eb(I(r)));V(_,e=>{I(y)&&e(v)}),T(h),T(o),F(e=>{d=U(u,1,`live-dot`,null,d,{"is-streaming":ob.active}),B(p,e)},[()=>nb(ob.granularity)]),z(e,o),D()}function db(e){let t=e||{};if(t.total_tokens!==null&&t.total_tokens!==void 0){let e=Number(t.total_tokens);if(Number.isFinite(e))return e}let n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function fb(e,t){if(!t)return 0;let n=e&&e.summary?e.summary:{},r=Number(n.total_hits||0);return Number.isFinite(r)&&r>0?r:0}function pb(e,t,n){let r=Number(e&&e.total_requests||0);return(Number.isFinite(r)?r:0)+fb(t,n)}function mb(e,t,n){let r=fb(t,n);return r<=0?``:ac(pb(e,t,n)-r)+` to providers + `+ac(r)+` from cache`}function hb(e){let t=e&&e.summary?e.summary:{},n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function gb(e,t,n){let r=e=>{let t=Number(e||0);return Number.isFinite(t)&&t>0?t:0},i=e||{},a=r(i.uncached_input_tokens),o=r(i.cached_input_tokens),s=r(i.cache_write_input_tokens),c=t&&t.summary?t.summary:{},l=n?r(c.total_input_tokens):0;return[{key:`uncached`,label:`Regular`,tokens:a+s,colorVar:`--cache-meter-uncached`,note:s>0?`Includes `+ac(s)+` cache-write tokens`:``},{key:`prompt`,label:`Prompt cached`,tokens:o,colorVar:`--cache-meter-prompt`,note:`Provider prompt-cache reads`},{key:`local`,label:`Locally cached`,tokens:l,colorVar:`--cache-meter-local`,note:`Served from GoModel response cache`}]}function _b(e,t,n){return gb(e,t,n).reduce((e,t)=>e+t.tokens,0)}function vb(e,t,n){return _b(e,t,n)>0}function yb(e,t,n){let r=gb(e,t,n),i=r.reduce((e,t)=>e+t.tokens,0);if(i<=0)return r.map(e=>Object.assign({},e,{pct:0}));let a=r.map(e=>{let t=e.tokens/i*100,n=Math.floor(t);return Object.assign({},e,{pct:n,remainder:t-n})}),o=100-a.reduce((e,t)=>e+t.pct,0);return a.map((e,t)=>({index:t,remainder:e.remainder,tokens:e.tokens})).filter(e=>e.tokens>0).sort((e,t)=>t.remainder-e.remainder).forEach(e=>{o>0&&(a[e.index].pct+=1,--o)}),a}function bb(e,t,n){return yb(e,t,n).filter(e=>e.tokens>0)}function xb(e){let t=[e.label+`: `+ac(e.tokens)+` input tokens (`+e.pct+`%)`];return e.note&&t.push(e.note),t.join(` -`)}function Sb(e){let t=(e||[]).map(e=>e.label+` `+e.pct+`%`);return`Cache breakdown of input tokens — `+(t.length?t.join(`, `):`no data`)}function Cb(e){return e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`)}function wb(e,t,n,r){if(t!==`daily`||!n||!r)return e;let i={};(e||[]).forEach(e=>{i[e.date]=e});let a=[];for(let e=new Date(n);e<=r;e.setUTCDate(e.getUTCDate()+1)){let t=Cb(e);a.push(i[t]||{date:t,input_tokens:0,output_tokens:0,total_tokens:0,requests:0,input_cost:null,output_cost:null,total_cost:null})}return a}function Tb(e,t){let n=e=>Number(e)||0,r=e.map(e=>e.date),i=e.map(e=>n(e.uncached_input_tokens)+n(e.cache_write_input_tokens)+n(e.cached_input_tokens)>0?n(e.uncached_input_tokens)+n(e.cache_write_input_tokens):n(e.input_tokens)),a=e.map(e=>n(e.output_tokens)),o=e.map(e=>n(e.cached_input_tokens)),s={};return(t||[]).forEach(e=>{s[e.date]=e}),{labels:r,inputPaid:i,output:a,prompt:o,local:r.map(e=>{let t=s[e];return t?n(t.input_tokens)+n(t.output_tokens):0})}}function Eb(e){let t=e||{},n=Math.max(0,Number(t.uncached_input_tokens)||0),r=Math.max(0,Number(t.cached_input_tokens)||0),i=Math.max(0,Number(t.cache_write_input_tokens)||0),a=n+r+i;return a>0?r/a*100:0}function Db(e){let t=e||{};return(Number(t.uncached_input_tokens)||0)+(Number(t.cached_input_tokens)||0)+(Number(t.cache_write_input_tokens)||0)>0}function Ob(e){return Db(e)?Math.round(Eb(e))+`%`:`—`}function kb(e,t,n={}){let r=!!n.cacheEnabled,i=n.resolve||(e=>e),a=(e,t)=>i(`color-mix(in srgb, `+e+` `+t+`%, transparent)`),o=(e,t,n,r)=>Object.assign({label:e,data:t,borderColor:n,backgroundColor:n,fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4},r||{}),s=[o(`Input Tokens`,t.inputPaid,i(`var(--token-input)`),{fill:`origin`}),o(`Output Tokens`,t.output,i(`var(--token-output)`),{fill:`-1`}),o(`Prompt (Input) Cached`,t.prompt,i(`var(--token-prompt)`),{fill:`-1`,borderDash:[6,4]})];return r&&s.push(o(`Locally Cached`,t.local,a(`var(--info)`,35),{fill:`-1`,borderDash:[2,3]})),{type:`line`,data:{labels:t.labels,datasets:s},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ly(e,{label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),maxRotation:0,autoSkip:!0,maxTicksLimit:10}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:Ky(e)}}}}}function Ab(e,t,n){let r=Math.max(0,Math.min(100,e));return{type:`doughnut`,data:{datasets:[{data:[r,100-r],backgroundColor:[t,n],borderWidth:0,spacing:0}]},options:{rotation:-90,circumference:180,cutout:`84%`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:1},events:[],plugins:{legend:{display:!1},tooltip:{enabled:!1}}}}}var jb=`gomodel_provider_status_details_expanded`,Mb=`gomodel_provider_card_expanded_overrides`,Nb=3e3,Pb=`https://gomodel.enterpilot.io/docs/providers/`,Fb={anthropic:`anthropic`,azure:`azure`,bailian:`bailian`,bedrock:`bedrock`,"bedrock-mantle":`bedrock-mantle`,cohere:`cohere`,deepseek:`deepseek`,gemini:`gemini`,opencode_go:`opencode-go`,oracle:`oracle`,vertex:`vertex`,vllm:`vllm`,xiaomi:`xiaomi`};function Ib(){return{summary:{total:0,healthy:0,degraded:0,unhealthy:0,overall_status:`degraded`},providers:[]}}function Lb(e){let t={detailsExpanded:!1,cardOverrides:{}};try{if(e){let n=e.getItem(jb);n===`true`||n===`false`?t.detailsExpanded=n===`true`:e.setItem(jb,`false`);let r=JSON.parse(e.getItem(Mb)||`{}`);r&&typeof r==`object`&&!Array.isArray(r)&&(t.cardOverrides=r)}}catch{}return t}function Rb(e,t){if(e)try{e.setItem(jb,t?`true`:`false`)}catch{}}function zb(e,t){if(e)try{e.setItem(Mb,JSON.stringify(t))}catch{}}function Bb(e,t,n){let r=n&&n.name?String(n.name):``;return r&&Object.prototype.hasOwnProperty.call(e,r)?e[r]===!0:t}function Vb(e){return`is-`+(String(e&&e.overall_status||`degraded`).trim()||`degraded`)}function Hb(e){return`is-`+(String(e||`degraded`).trim()||`degraded`)}function Ub(e){let t=e||{};return String(t.healthy||0)+`/`+String(t.total||0)}function Wb(e){let t=e||{},n=Number(t.total||0),r=Number(t.healthy||0);return n>0&&rString(e&&e.status_label||``).trim().toLowerCase()===`starting`)}function qb(e){if(!e||!e.runtime)return``;let t=e.runtime.last_model_fetch_at||``,n=e.runtime.last_availability_check_at||``;return t?n&&Date.parse(n)>Date.parse(t)?n:t:n}function Jb(e,t){let n=qb(e);if(!n||typeof t!=`function`)return`-`;let r=t(n);if(!r||r===`-`)return`-`;let i=String(r).split(` `);return i.length>1?i.slice(1).join(` `):r}function Yb(e,t){let n=qb(e);return n?typeof t==`function`?t(n):String(n):``}function Xb(e){if(!e)return``;let t=String(e.name||``).trim(),n=String(e.type||e.config&&e.config.type||``).trim();return!n||n===t?``:n}function Zb(e){let t=String(e&&(e.type||e.config&&e.config.type)||``).trim().toLowerCase(),n=t?Fb[t]:``;return n?Pb+n+`?utm_source=gomodel_dashboard`:``}function Qb(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.retry:null;return t?String(t.max_retries)+` retries, `+t.initial_backoff+` initial, `+t.max_backoff+` max, factor `+t.backoff_factor+`, jitter `+t.jitter_factor:`-`}function $b(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.circuit_breaker:null;return t?String(t.failure_threshold)+` fail, `+String(t.success_threshold)+` success, `+t.timeout+` timeout`:`-`}function ex(e){let t=e&&e.config&&Array.isArray(e.config.models)?e.config.models.filter(Boolean):[];return t.length===0?`Automatic`:t.join(`, `)}function tx(e){if(!e)return``;let t=[];return e.status_reason&&t.push(String(e.status_reason)),e.last_error&&t.push(`Last error: `+String(e.last_error)),t.join(` - -`)}function nx(e){let t=e&&e.request_health;return t&&typeof t==`object`?t:null}function rx(e){let t=nx(e);return t?String(t.circuit_state||``).trim():``}function ix(e){let t=rx(e);return t?t.charAt(0).toUpperCase()+t.slice(1):``}function ax(e){let t=rx(e);return t===`open`?`is-unhealthy`:t===`half-open`?`is-degraded`:`is-healthy`}function ox(e){let t=nx(e);if(!t)return``;let n=Number(t.requests||0),r=Number(t.errors||0),i=Math.round(Number(t.window_seconds||0)/60),a=i>0?`last `+i+` min`:`recent`;return String(n)+` request`+(n===1?``:`s`)+` · `+String(r)+` error`+(r===1?``:`s`)+` (`+a+`)`}function sx(e){let t=nx(e);return t&&Array.isArray(t.models)?t.models:[]}function cx(e){return e?String(Number(e.errors||0))+`/`+String(Number(e.requests||0))+` failed`:``}function lx(e){let t=e&&e.last_error;return!t||!t.message?``:(t.status_code?`HTTP `+String(t.status_code)+`: `:``)+t.message}function ux(){return{name:``,slug:``,url:``,transport:`http`,description:``,enabled:!0,headers:[],allowed_tools:``,disallowed_tools:``,user_paths:``,tool_timeout_seconds:``}}function dx(){return{server:``,status:``,instructions:``,tools:[],prompts:[],resources:[],templates:[]}}function fx(e){return String(e&&(e.slug||e.name)||``).trim()}function px(e){return String(e&&e.status||``).trim()||`connecting`}function mx(e){switch(px(e)){case`connected`:return`status-success`;case`degraded`:return String(e&&e.last_error||``).trim()?`status-error`:`status-warning`;case`connecting`:return`status-neutral`;default:return`status-unknown`}}function hx(e,t){let n=px(e),r=String(e&&e.last_error||``).trim();return r&&n!==`connected`?r:n===`connected`&&e&&e.connected_at?`Connected since `+(typeof t==`function`?t:String)(e.connected_at):``}function gx(e){return String(e&&e.transport||``)===`stdio`?`local command`:String(e&&e.url||``).trim()||`—`}function _x(e){let t=Number(e&&e.prompt_count||0),n=Number(e&&e.resource_count||0);return t+` prompts · `+n+` resources`}function vx(e){let t=String(e||``).normalize(`NFKD`).toLowerCase(),n=t.replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/-+$/g,``);if(n)return n;let r=2166136261;for(let e of t)r=Math.imul((r^e.codePointAt(0))>>>0,16777619)>>>0;return`mcp-`+r.toString(16).padStart(8,`0`)}function yx(e){return String(e||``).split(` -`).map(e=>e.trim()).filter(e=>e)}function bx(e){return!e||typeof e!=`object`||Array.isArray(e)?[]:Object.keys(e).sort().map(t=>({name:t,value:String(e[t]||``)}))}function xx(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=String(e&&e.name||``).trim();n&&(t[n]=String(e&&e.value||``))}),t}function Sx(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.slug,e.url,e.transport,e.description,e.status].some(e=>String(e||``).toLowerCase().includes(r)))}function Cx(e){return{name:String(e.name||``).trim(),slug:fx(e),url:String(e.url||``).trim(),transport:e.transport===`sse`?`sse`:`http`,description:String(e.description||``).trim(),enabled:e.enabled!==!1,headers:bx(e.headers),allowed_tools:(Array.isArray(e.allowed_tools)?e.allowed_tools:[]).join(`, `),disallowed_tools:(Array.isArray(e.disallowed_tools)?e.disallowed_tools:[]).join(`, `),user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` -`),tool_timeout_seconds:e.tool_timeout_seconds?String(e.tool_timeout_seconds):``}}function wx(e,t,n){let r=String(e.name||``).trim(),i=String(e.slug||vx(r)).trim().toLowerCase(),a=String(e.url||``).trim(),o=e.transport===`sse`?`sse`:`http`;if(!r)return{error:`Name is required.`};if(!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(i))return{error:`Slug must use 1–64 lowercase ASCII letters, numbers, hyphens, or underscores.`};if(t===`create`&&(n||[]).some(e=>fx(e)===i))return{error:`Slug "`+i+`" is already in use.`};if(!a)return{error:`URL is required.`};let s,c=String(e.tool_timeout_seconds||``).trim();if(c!==``){let e=Number(c);if(!Number.isSafeInteger(e)||e<0)return{error:`Tool timeout must be a non-negative whole number of seconds.`};s=e}return{payload:{name:r,slug:i,url:a,transport:o,headers:xx(e.headers),description:String(e.description||``).trim(),enabled:!!e.enabled,allowed_tools:rc(e.allowed_tools),disallowed_tools:rc(e.disallowed_tools),user_paths:yx(e.user_paths),tool_timeout_seconds:s}}}function Tx(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=e=>(Array.isArray(e)?e:[]).filter(e=>e&&typeof e==`object`);return{server:String(n.server||e||``).trim(),status:String(n.status||``).trim(),instructions:String(n.instructions||``).trim(),tools:r(n.tools),prompts:r(n.prompts),resources:r(n.resources),templates:r(n.templates)}}function Ex(e,t){return String(e&&e.server||``)+`_`+String(t||``)}function Dx(e){let t=e||dx(),n=(e,t)=>{let n=String(e||``).trim(),r=String(t||``).trim();return n&&r?n+` — `+r:r||n},r=e=>n=>({key:e+`:`+String(n.name||``),name:String(n.name||``),aggregated:Ex(t,n.name),description:String(n.description||``).trim()});return[{key:`tools`,title:`Tools`,items:(t.tools||[]).map(r(`tool`))},{key:`prompts`,title:`Prompts`,items:(t.prompts||[]).map(r(`prompt`))},{key:`resources`,title:`Resources`,items:(t.resources||[]).map(e=>({key:`resource:`+String(e.uri||``),name:String(e.uri||``),aggregated:``,description:n(e.name,e.description)}))},{key:`templates`,title:`Resource templates`,items:(t.templates||[]).map(e=>({key:`template:`+String(e.uri_template||``),name:String(e.uri_template||``),aggregated:``,description:n(e.name,e.description)}))}].filter(e=>e.items.length>0)}function Ox(e){return Dx(e).length===0}function kx(e){return(e||[]).length}function Ax(e){return(e||[]).filter(e=>px(e)===`connected`).length}function jx(e){return(e||[]).filter(e=>e&&e.enabled!==!1&&px(e)===`degraded`).length}function Mx(e,t){return!!e&&kx(t)>0}function Nx(e){return String(Ax(e))+`/`+String(kx(e))}function Px(e){return jx(e)>0?`is-degraded`:`is-healthy`}function Fx(e){let t=jx(e);if(t>0)return String(t)+` server`+(t===1?``:`s`)+` need`+(t===1?`s`:``)+` attention`;let n=kx(e),r=Ax(e);return n>0&&r===n?`All MCP servers connected`:String(r)+` of `+String(n)+` server`+(n===1?``:`s`)+` connected`}function Ix(){return{interval:`day`,buckets:[],summary:{requests:0},provider_latency:[]}}function Lx(e){let t=e&&typeof e==`object`?e:{};return{interval:t.interval===`hour`?`hour`:`day`,buckets:Array.isArray(t.buckets)?t.buckets:[],summary:t.summary&&typeof t.summary==`object`?t.summary:{requests:0},provider_latency:Array.isArray(t.provider_latency)?t.provider_latency:[]}}function Rx(e){return Number(e&&e.summary&&e.summary.requests||0)>0}function zx(e){return(e&&Array.isArray(e.provider_latency)?e.provider_latency:[]).length>0}function Bx(e){let t=e&&e.summary?e.summary.success_rate:null;return t==null?`—`:(Math.round(Number(t)*1e3)/10).toFixed(1)+`%`}function Vx(e,t){return Number(e&&e.summary&&e.summary[t]||0)}function Hx(e){let t=Number(e);return Number.isFinite(t)?t>=6e4?(t/6e4).toFixed(1)+` min`:t>=1e3?(t/1e3).toFixed(2)+` s`:Math.round(t)+` ms`:`-`}function Ux(e){let t=e&&e.summary?e.summary.avg_duration_ms:null;return t==null?`—`:Hx(Number(t))}function Wx(e,t){try{let n={};return new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,hourCycle:`h23`}).formatToParts(e).forEach(e=>{n[e.type]=e.value}),{year:n.year,month:n.month,day:n.day,hour:Number(n.hour)}}catch{return{year:String(e.getFullYear()),month:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()],day:String(e.getDate()),hour:e.getHours()}}}function Gx(e,t,n){let r=new Date(e.start);if(Number.isNaN(r.getTime()))return String(e.start||``);let i=Wx(r,n),a=i.month+` `+i.day;return t!==`hour`||i.hour===0?a:String(i.hour).padStart(2,`0`)+`:00`}function Kx(e,t,n,r){let i=new Date(e.start);if(Number.isNaN(i.getTime()))return String(e.start||``);if(t===`hour`)return r(e.start);let a=Wx(i,n);return a.month+` `+a.day+`, `+a.year}function qx(e){return{ok:e(`var(--success)`),clientError:e(`var(--warning)`),serverError:e(`var(--danger)`),other:e(`color-mix(in srgb, var(--text-muted) 55%, transparent)`)}}function Jx(e,t,n={}){let r=n.interval===`hour`?`hour`:`day`,i=n.zone,a=n.resolve||(e=>e),o=n.formatTimestamp||(e=>String(e)),s=t.map(e=>Gx(e,r,i)),c=qx(a),l=a(`var(--bg-surface)`),u=e=>Number(e)||0,d=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:l,borderWidth:1,borderSkipped:!1,borderRadius:2,maxBarThickness:28}),f=[d(`2xx`,t.map(e=>u(e.status_2xx)),c.ok),d(`4xx`,t.map(e=>u(e.status_4xx)),c.clientError),d(`5xx`,t.map(e=>u(e.status_5xx)),c.serverError)];return t.some(e=>u(e.status_other)>0)&&f.push(d(`Other`,t.map(e=>u(e.status_other)),c.other)),{type:`bar`,data:{labels:s,datasets:f},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ly(e,{title:e=>e.length?Kx(t[e[0].dataIndex],r,i,o):``,label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Iy(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),precision:0,callback:e=>lc(e)}}}}}}function Yx(e=By()){let t={};return function(n){return n in t||(t[n]=e[Object.keys(t).length%e.length]),t[n]}}function Xx(e,t,n,r={}){let i=r.interval===`hour`?`hour`:`day`,a=r.zone,o=r.formatTimestamp||(e=>String(e)),s=r.providerColor||Yx();return{type:`line`,data:{labels:t.map(e=>Gx(e,i,a)),datasets:n.map(e=>({label:e.provider,data:(e.avg_duration_ms||[]).map(e=>e==null?null:Number(e)),borderColor:s(e.provider),backgroundColor:s(e.provider),fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4,spanGaps:i===`hour`&&2}))},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ly(e,{title:e=>e.length?Kx(t[e[0].dataIndex],i,a,o):``,label:e=>{let t=(n[e.datasetIndex]&&n[e.datasetIndex].requests||[])[e.dataIndex],r=Number(t)||0;return e.dataset.label+`: `+Hx(e.parsed.y)+(r>0?` (`+r.toLocaleString()+` req)`:``)}})},scales:{x:{grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),callback:e=>Hx(e)}}}}}}var Zx=class{#e=k(j(Ib()));get status(){return I(this.#e)}set status(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=k(!1);get loadedOnce(){return I(this.#n)}set loadedOnce(e){A(this.#n,e,!0)}#r=k(!1);get detailsExpanded(){return I(this.#r)}set detailsExpanded(e){A(this.#r,e,!0)}#i=k(j({}));get cardOverrides(){return I(this.#i)}set cardOverrides(e){A(this.#i,e,!0)}#a=null;#o=null;#s=!1;initPreferences(){if(this.#s)return;this.#s=!0;let e=Lb(Ca());this.detailsExpanded=e.detailsExpanded,this.cardOverrides=e.cardOverrides}cardExpanded(e){return Bb(this.cardOverrides,this.detailsExpanded,e)}toggleCard(e){let t=e&&e.name?String(e.name):``;if(!t)return;let n={...this.cardOverrides};n[t]=!this.cardExpanded(e),this.cardOverrides=n,zb(Ca(),this.cardOverrides)}toggleDetails(){this.detailsExpanded=!this.detailsExpanded,this.cardOverrides={},Rb(Ca(),this.detailsExpanded),zb(Ca(),this.cardOverrides)}detailsToggleLabel(){return this.detailsExpanded?`Show Details`:`Hide Details`}async fetch(){this.initPreferences(),this.#a&&this.#a.abort();let e=new AbortController;this.#a=e,this.loading=!0;try{let t=await gs(`/admin/providers/status`,{label:`provider status`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.status=Ib(),this.#l();return}let n=t.data&&typeof t.data==`object`?t.data:Ib();n.summary||=Ib().summary,Array.isArray(n.providers)||(n.providers=[]),this.status=n,this.#c()}catch(e){if(vs(e))return;console.error(`Failed to fetch provider status:`,e),this.status=Ib(),this.#l()}finally{this.#a===e&&(this.#a=null,this.loading=!1,this.loadedOnce=!0)}}#c(){this.#l(),Kb(this.status.providers)&&(this.#o=setTimeout(()=>{this.#o=null,this.fetch()},Nb))}#l(){this.#o&&=(clearTimeout(this.#o),null)}stopPolling(){this.#l()}},Qx=class{#e=k(j(Ix()));get stats(){return I(this.#e)}set stats(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=0;async fetch(){let e=++this.#n;this.loading=!0;try{let t=await gs(`/admin/audit/stats?`+jc.queryStr(),{label:`audit stats`});if(t.stale||e!==this.#n)return;if(!t.ok){this.stats=Ix();return}this.stats=Lx(t.data)}catch(t){if(console.error(`Failed to fetch audit stats:`,t),e!==this.#n)return;this.stats=Ix()}finally{e===this.#n&&(this.loading=!1)}}},$x=class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!1);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}async fetch(){if(await xs.ensureLoaded(),!xs.mcpVisible()){this.available=!1,this.servers=[];return}this.loading=!0;try{let e=await gs(`/admin/mcp-servers`,{label:`mcp servers`});if(e.stale)return;if(e.status===503||e.status===404){this.available=!1,this.servers=[];return}if(this.available=!0,!e.ok){this.servers=[];return}this.servers=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch MCP servers:`,e),this.servers=[]}finally{this.loading=!1}}},eS=class{#e=k(j([]));get data(){return I(this.#e)}set data(e){A(this.#e,e,!0)}#t=k(`tokens`);get mode(){return I(this.#t)}set mode(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=null;async fetch(){this.#r&&this.#r.abort();let e=new AbortController;this.#r=e,this.loading=!0;try{let t=await gs(`/admin/usage/daily?days=365&interval=daily`,{label:`calendar`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.data=[];return}this.data=Array.isArray(t.data)?t.data:[]}catch(e){if(vs(e))return;console.error(`Failed to fetch calendar data:`,e),this.data=[]}finally{this.#r===e&&(this.#r=null,this.loading=!1)}}},tS=new Zx,nS=new Qx,rS=new $x,iS=new eS,aS=(e,t=f,n=f,r=f,i=f)=>{var a=sS(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=M(c),u=M(l),d=M(u,!0);T(u),Ue(),T(l);var p=P(l,4),m=M(p),h=M(m,!0);T(m),Ue(),T(p);var g=P(p,4),_=M(g,!0);T(g),T(c),T(a),F((e,n,r,i,a,o)=>{B(s,t()),W(l,`title`,e),B(d,n),W(p,`title`,r),B(h,i),W(g,`title`,a),B(_,o)},[()=>uc(`Input tokens`,n()),()=>lc(n()),()=>uc(`Output tokens`,r()),()=>lc(r()),()=>uc(`Total tokens`,i()),()=>lc(i())]),z(e,a)},oS=(e,t=f,n=f,r=f,i=f,a=f,o=f)=>{var s=uS(),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u);var p=P(u,2),m=e=>{var t=cS(),n=M(t,!0);T(t),F(()=>{W(t,`aria-label`,o().title),W(t,`title`,o().title),B(n,a())}),L(`click`,t,function(...e){o().onclick?.apply(this,e)}),z(e,t)},h=e=>{var t=lS(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(p,e=>{o()?e(m):e(h,-1)}),T(s),F(()=>{U(s,1,`card provider-status-flag ${t()??``} ${n()??``}`,`svelte-6tr9cf`),B(l,r()),B(d,i())}),z(e,s)},sS=R(`
            i + o =
            `),cS=R(``),lS=R(` `),uS=R(`
            `),dS=R(`
            Cache Hits
            `),fS=R(`
            Total Requests
            Estimated Cost
            Prompt Cache Rate
            `);function pS(e,t){E(t,!0);let n=O(()=>Lc.summary),r=O(()=>Lc.cacheOverview),i=O(()=>Lc.cacheAnalyticsEnabled()),a=O(()=>tS.status.summary);function o(){let e=document.getElementById(`provider-status-section`);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),e.focus({preventScroll:!0}))}var s=fS(),c=M(s);{let e=O(()=>db(I(n)));aS(c,()=>`Tokens`,()=>I(n).total_input_tokens,()=>I(n).total_output_tokens,()=>I(e))}var l=P(c,2),u=P(M(l),2),d=M(u,!0);T(u),T(l);var f=P(l,2),p=e=>{var t=dS(),n=P(M(t),2),i=M(n,!0);T(n),T(t),F(e=>B(i,e),[()=>ac(I(r).summary.total_hits)]),z(e,t)};V(f,e=>{I(i)&&e(p)});var m=P(f,2),h=P(M(m),2),g=M(h,!0);T(h),T(m);var _=P(m,2),v=e=>{{let t=O(()=>hb(I(r)));aS(e,()=>`Local Cache`,()=>I(r).summary.total_input_tokens,()=>I(r).summary.total_output_tokens,()=>I(t))}};V(_,e=>{I(i)&&e(v)});var y=P(_,2),b=P(M(y),2),x=M(b);Ay(x,{build:()=>Ab(Eb(I(n)),Ry(`var(--token-prompt)`),Ry(`var(--bg-surface-hover)`))});var S=P(x,2),C=M(S,!0);T(S),T(b),T(y);var w=P(y,2),ee=e=>{{let t=O(()=>Vb(I(a))),n=O(()=>Ub(I(a))),r=O(()=>Gb(I(a))),i=O(()=>Wb(I(a))?{title:`View providers overview`,onclick:o}:null);oS(e,()=>`provider-status-overview-card`,()=>I(t),()=>`Provider Status`,()=>I(n),()=>I(r),()=>I(i))}};V(w,e=>{I(a).total>0&&e(ee)});var te=P(w,2),ne=e=>{{let t=O(()=>Px(rS.servers)),n=O(()=>Nx(rS.servers)),r=O(()=>Fx(rS.servers));oS(e,()=>`mcp-servers-flag`,()=>I(t),()=>`MCP Servers`,()=>I(n),()=>I(r),()=>({title:`View MCP servers`,onclick:()=>qo.navigate(`mcp-servers`)}))}},re=O(()=>Mx(rS.available,rS.servers));V(te,e=>{I(re)&&e(ne)}),T(s),F((e,t,n,r,i)=>{W(u,`title`,e),B(d,t),B(g,n),W(b,`aria-label`,r),B(C,i)},[()=>mb(I(n),I(r),I(i)),()=>ac(pb(I(n),I(r),I(i))),()=>oc(I(n).total_cost),()=>`Prompt cache rate `+Ob(I(n)),()=>Ob(I(n))]),z(e,s),D()}Hr([`click`]);var mS=R(` `),hS=R(`
            `),gS=R(`No usage in the selected period yet`),_S=R(`
            `),vS=R(`

            Tokens

            Share of input tokens over the selected period
            `);function yS(e,t){E(t,!0);let n=O(()=>Lc.cacheAnalyticsEnabled()),r=O(()=>yb(Lc.summary,Lc.cacheOverview,I(n))),i=O(()=>bb(Lc.summary,Lc.cacheOverview,I(n))),a=O(()=>vb(Lc.summary,Lc.cacheOverview,I(n)));var o=vS(),s=P(M(o),2);let c;var l=M(s);H(l,17,()=>I(i),e=>e.key,(e,t)=>{var n=hS(),r=M(n),i=e=>{var n=mS(),r=M(n);T(n),F(()=>B(r,`${I(t).pct??``}%`)),z(e,n)};V(r,e=>{I(t).pct>=8&&e(i)}),T(n),F(e=>{Hi(n,`width: ${I(t).pct??``}%; background: var(${I(t).colorVar??``})`),W(n,`title`,e)},[()=>xb(I(t))]),z(e,n)});var u=P(l,2),d=e=>{z(e,gS())};V(u,e=>{I(a)||e(d)}),T(s);var f=P(s,2);H(f,21,()=>I(r),e=>e.key,(e,t)=>{var n=_S(),r=M(n),i=P(r,2),a=M(i,!0);T(i);var o=P(i,2),s=M(o);T(o);var c=P(o,2),l=M(c,!0);T(c),T(n),F((e,i)=>{W(n,`title`,e),Hi(r,`background: var(${I(t).colorVar??``})`),B(a,I(t).label),B(s,`${I(t).pct??``}%`),B(l,i)},[()=>xb(I(t)),()=>ac(I(t).tokens)]),z(e,n)}),T(f),T(o),F(e=>{c=U(s,1,`cache-meter-bar svelte-1yzecxj`,null,c,{"is-empty":!I(a)}),W(s,`aria-label`,e)},[()=>Sb(I(i))]),z(e,o),D()}var bS=R(``);function xS(e,t){let n=G(t,`size`,3,16),r=G(t,`label`,3,`Loading`),i=G(t,`class`,3,``);var a=bS();F(()=>{U(a,1,Fi([`spinner`,i()]),`svelte-b54l9o`),Hi(a,`--spinner-size: ${n()??``}px`),W(a,`aria-label`,r())}),z(e,a)}var SS=Xr(` `),CS=Xr(``);function wS(e,t){let n=G(t,`label`,3,`No data`);var r=CS(),i=P(M(r),9),a=e=>{var t=SS(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(i,e=>{n()&&e(a)}),T(r),F(()=>{W(r,`role`,n()?`img`:void 0),W(r,`aria-label`,n()||void 0),W(r,`aria-hidden`,n()?void 0:`true`)}),z(e,r)}var TS=R(`
            `),ES=R(`

            `);function DS(e,t){E(t,!0);let n=[`daily`,`weekly`,`monthly`,`yearly`];function r(e){jc.interval=e,t.onintervalchange?.()}function i(){let e=Lc.daily;if(e.length===0)return null;let t=jc.rangeStart(),n=jc.rangeEnd(),r=Tb(wb(e,jc.interval,t,n),wb(Array.isArray(Lc.cacheOverview.daily)?Lc.cacheOverview.daily:[],jc.interval,t,n));return kb(Fy(),r,{cacheEnabled:Lc.cacheAnalyticsEnabled(),resolve:Ry})}var a=ES(),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2);{let e=O(()=>n.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})));Ny(l,{ariaLabel:`Usage chart interval`,get options(){return I(e)},get value(){return jc.interval},onchange:r})}T(o);var u=P(o,2),d=M(u);Ay(d,{build:i});var f=P(d,2),p=e=>{var t=TS();xS(M(t),{size:24,label:`Loading usage`}),T(t),z(e,t)},m=e=>{var t=TS();wS(M(t),{}),T(t),z(e,t)};V(f,e=>{Lc.daily.length===0&&Lc.loading?e(p):Lc.daily.length===0&&!q.authError&&e(m,1)}),T(u),T(a),F(e=>B(c,e),[()=>jc.chartTitle()]),z(e,a),D()}var OS=10,kS=.7;function AS(e,t){if(e<=0||t<=0)return 0;let n=(e/t)**+kS,r=Math.ceil(n*OS);return r<1?1:r>OS?OS:r}function jS(){let e=[];for(let t=0;t<=OS;t++)e.push(t);return e}function MS(e,t,n){let r={};(e||[]).forEach(e=>{r[e.date]=e});let i=Zo($o(n,-364)),a=i.getUTCDay();i.setUTCDate(i.getUTCDate()-a);let o=[];for(let e=new Date(i);Qo(e)<=n;e.setUTCDate(e.getUTCDate()+1)){let n=Qo(e),i=r[n],a=0;i&&(a=t===`costs`?i.total_cost==null?0:i.total_cost:i.total_tokens||0),o.push({dateStr:n,value:a,level:0,empty:!1})}let s=0;for(let e=0;es&&(s=o[e].value);for(let e=0;e0){for(;l.length<7;)l.push({dateStr:``,value:0,level:0,empty:!0});c.push(l)}return c}function NS(e){let t=Zo($o(e,-364)),n=t.getUTCDay();t.setUTCDate(t.getUTCDate()-n);let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],i=[],a={},o=0;for(let n=new Date(t);Qo(n)<=e;n.setUTCDate(n.getUTCDate()+7),o++){let t=null;if(o===0)t=new Date(n);else for(let r=0;r<7;r++){let i=new Date(n);if(i.setUTCDate(n.getUTCDate()+r),Qo(i)>e)break;if(i.getUTCDate()===1){t=i;break}}if(!t)continue;let s=t.getUTCFullYear()+`-`+t.getUTCMonth();a[s]||(i.push({label:r[t.getUTCMonth()],col:o,key:s}),a[s]=!0)}for(let e=0;e `),LS=R(`
            `),RS=R(`
            `),zS=R(`
            `),BS=R(`
            `),VS=R(`

            Activity

            Mon Wed Fri
            `,1);function HS(e,t){E(t,!0);let n=k(j({show:!1,x:0,y:0,text:``})),r=O(()=>us.currentDateKey()),i=O(()=>MS(iS.data,iS.mode,I(r))),a=O(()=>NS(I(r)));function o(e,t){t.empty||A(n,{show:!0,x:e.clientX,y:e.clientY,text:FS(t,iS.mode)},!0)}function s(){A(n,{show:!1,x:0,y:0,text:``},!0)}var c=VS(),l=N(c),u=M(l),d=P(M(u),2),f=e=>{xS(e,{size:14,label:`Loading activity`})};V(d,e=>{iS.loading&&iS.data.length===0&&e(f)}),Ny(P(d,2),{ariaLabel:`Activity calendar mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return iS.mode},onchange:e=>iS.mode=e}),T(u);var p=P(u,2),m=P(M(p),2),h=M(m);H(h,21,()=>I(a),e=>e.key,(e,t)=>{var n=IS(),r=M(n,!0);T(n),F(()=>{Hi(n,`grid-column: ${I(t).col+1} / span ${I(t).span??``}`),B(r,I(t).label)}),z(e,n)}),T(h);var g=P(h,2);H(g,21,()=>I(i),oi,(e,t,n)=>{var r=RS();H(r,23,()=>I(t),(e,t)=>n+`-`+t,(e,t)=>{var n=LS();F(()=>U(n,1,Fi([`contribution-calendar-cell`,I(t).empty?`empty`:`level-${I(t).level}`]),`svelte-3hfxuq`)),Vr(`mouseenter`,n,e=>o(e,I(t))),Vr(`mouseleave`,n,s),z(e,n)}),T(r),z(e,r)}),T(g),T(m),T(p);var _=P(p,2),v=M(_),y=M(v),b=M(y,!0);T(y),T(v);var x=P(v,2);H(P(M(x),2),16,jS,e=>e,(e,t)=>{var n=zS();F(()=>U(n,1,`contribution-calendar-cell level-${t??``}`,`svelte-3hfxuq`)),z(e,n)}),Ue(2),T(x),T(_),T(l);var S=P(l,2),C=e=>{var t=BS(),r=M(t,!0);T(t),F(()=>{Hi(t,`left: ${I(n).x??``}px; top: ${I(n).y-40}px`),B(r,I(n).text)}),z(e,t)};V(S,e=>{I(n).show&&e(C)}),F(e=>B(b,e),[()=>PS(iS.data,iS.mode)]),z(e,c),D()}var US=R(``),WS=R(`

            `),GS=R(`
            `);function KS(e,t){E(t,!0);let n=G(t,`label`,3,`help`),r=G(t,`text`,3,``),i=G(t,`open`,15,!1),a=G(t,`external`,3,!1),o=O(()=>!!r()||!!t.help||a());var s=GS(),c=M(s),l=M(c);gi(l,()=>t.title??f);var u=P(l,2),d=e=>{var r=US();let a;F(()=>{a=U(r,1,`inline-help-toggle svelte-y40or3`,null,a,{"is-open":i()}),W(r,`aria-label`,(i()?`Hide `:`Show `)+n()),W(r,`aria-expanded`,i()),W(r,`aria-controls`,t.copyId)}),L(`click`,r,()=>i(!i())),z(e,r)};V(u,e=>{I(o)&&e(d)}),gi(P(u,2),()=>t.extra??f),T(c);var p=P(c,2),m=e=>{var n=WS(),i=M(n),a=e=>{var n=Qr();gi(N(n),()=>t.help),z(e,n)},o=e=>{var t=Zr();F(()=>B(t,r())),z(e,t)};V(i,e=>{t.help?e(a):e(o,-1)}),T(n),F(()=>W(n,`id`,t.copyId)),z(e,n)};V(p,e=>{i()&&I(o)&&!a()&&e(m)}),T(s),z(e,s),D()}Hr([`click`]);var qS=R(`

            Provider Latency

            `),JS=R(`
            Avg
            `),YS=R(`

            Requests by Status

            Success 2xx 4xx 5xx
            `,1);function XS(e,t){E(t,!0);let n=Yx(),r=O(()=>nS.stats);function i(){return{interval:I(r).interval,zone:us.effectiveTimezone(),resolve:Ry,formatTimestamp:e=>us.formatTimestamp(e)}}var a=Qr(),o=N(a),s=e=>{var t=YS(),a=N(t),o=M(a),s=P(M(o),2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c);var d=P(c,2),f=P(M(d),4),p=M(f,!0);T(f),T(d);var m=P(d,2),h=P(M(m),4),g=M(h,!0);T(h),T(m);var _=P(m,2),v=P(M(_),4),y=M(v,!0);T(v),T(_),T(s),T(o);var b=P(o,2);Ay(M(b),{build:()=>Jx(Fy(),I(r).buckets,i())}),T(b),T(a);var x=P(a,2),S=e=>{var t=JS(),a=M(t),o=M(a);KS(o,{copyId:`audit-latency-help-copy`,label:`provider latency help`,text:`Average duration of successful requests as measured at the gateway, per provider. Local cache hits and failed requests are excluded; streamed responses count until the stream completes.`,title:e=>{z(e,qS())},$$slots:{title:!0}});var s=P(o,2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c),T(s),T(a);var d=P(a,2);Ay(M(d),{build:()=>Xx(Fy(),I(r).buckets,I(r).provider_latency,{...i(),providerColor:n})}),T(d),T(t),F(e=>B(u,e),[()=>Ux(I(r))]),z(e,t)},C=O(()=>zx(I(r)));V(x,e=>{I(C)&&e(S)}),F((e,t,n,r)=>{B(u,e),B(p,t),B(g,n),B(y,r)},[()=>Bx(I(r)),()=>ac(Vx(I(r),`status_2xx`)),()=>ac(Vx(I(r),`status_4xx`)),()=>ac(Vx(I(r),`status_5xx`))]),z(e,t)},c=O(()=>Rx(I(r)));V(o,e=>{I(c)&&e(s)}),z(e,a),D()}var ZS=(e,t=f,n=f,r)=>{let i=Ot(()=>h(r?.(),!1));var a=eC(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=e=>{var t=QS(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)},u=e=>{var t=$S(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(c,e=>{I(i)?e(l):e(u,-1)}),T(a),F(()=>B(s,t())),z(e,a)},QS=R(` `),$S=R(` `),eC=R(`
            `),tC=R(`

            `),nC=R(`
            Breaker State
            `),rC=R(`
            `),iC=R(`
            Models (Recent Traffic)
            `),aC=R(`
            `),oC=R(`

            `);function sC(e,t){E(t,!0);let n=O(()=>ax(t.provider)),r=O(()=>[[`Base URL`,t.provider.config?.base_url],[`API Version`,t.provider.config?.api_version]].filter(([,e])=>!!e));var i=oC();let a;var o=M(i),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{var n=tC(),r=M(n,!0);T(n),F(()=>B(r,t.provider.last_error)),z(e,n)};V(l,e=>{t.provider.last_error&&e(u)});var d=P(l,2),f=e=>{var r=aC(),i=M(r);{let e=O(()=>ox(t.provider));ZS(i,()=>`Recent Requests`,()=>I(e))}var a=P(i,2),o=e=>{var r=nC(),i=P(M(r),2),a=M(i),o=M(a,!0);T(a),T(i),T(r),F(e=>{U(a,1,Fi([`provider-status-health-state`,I(n)]),`svelte-6y9wjv`),B(o,e)},[()=>ix(t.provider)]),z(e,r)},s=O(()=>rx(t.provider));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{var n=iC(),r=P(M(n),2);H(r,21,()=>sx(t.provider),e=>e.model,(e,t)=>{var n=rC();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F((e,i)=>{r=U(n,1,`provider-status-health-model svelte-6y9wjv`,null,r,{"is-flagged":I(t).flagged}),W(n,`title`,e),B(a,I(t).model),B(s,i)},[()=>lx(I(t)),()=>cx(I(t))]),z(e,n)}),T(r),T(n),z(e,n)},u=O(()=>sx(t.provider).length>0);V(c,e=>{I(u)&&e(l)}),T(r),z(e,r)},p=O(()=>nx(t.provider));V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=M(m);H(h,17,()=>I(r),([e,t])=>e,(e,t)=>{var n=O(()=>g(I(t),2));ZS(e,()=>I(n)[0],()=>I(n)[1],()=>!0)});var _=P(h,2);{let e=O(()=>ex(t.provider));ZS(_,()=>`Configured Models`,()=>I(e))}var v=P(_,2);{let e=O(()=>Qb(t.provider));ZS(v,()=>`Retry`,()=>I(e))}var y=P(v,2);{let e=O(()=>$b(t.provider));ZS(y,()=>`Circuit Breaker`,()=>I(e))}T(m),T(o),T(i),F(()=>{a=U(i,1,`provider-status-details svelte-6y9wjv`,null,a,{"is-expanded":t.expanded,"is-collapsed":!t.expanded}),W(i,`aria-hidden`,!t.expanded),B(c,t.provider.status_reason)}),z(e,i),D()}var cC=R(` `),lC=R(``),uC=R(`

            Models Available
            Last Checked
            `);function dC(e,t){E(t,!0);let n=O(()=>tS.cardExpanded(t.provider)),r=e=>us.formatTimestamp(e);var i=uC(),a=M(i),o=M(a),s=M(o),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=e=>{var n=cC(),r=M(n);T(n),F(e=>B(r,`(${e??``})`),[()=>Xb(t.provider)]),z(e,n)},f=O(()=>Xb(t.provider));V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var n=lC();F((e,t,r)=>{W(n,`href`,e),W(n,`aria-label`,t),W(n,`title`,r)},[()=>Zb(t.provider),()=>`View `+(Xb(t.provider)||t.provider.name)+` provider docs`,()=>`View `+(Xb(t.provider)||t.provider.name)+` provider docs`]),z(e,n)},h=O(()=>Zb(t.provider));V(p,e=>{I(h)&&e(m)}),T(s),T(o);var g=P(o,2),_=M(g,!0);T(g),T(a);var v=P(a,2),y=M(v),b=P(M(y),2),x=M(b,!0);T(b),T(y);var S=P(y,2),C=P(M(S),2),w=M(C,!0);T(C),T(S),T(v);var ee=P(v,2);sC(ee,{get provider(){return t.provider},get expanded(){return I(n)}});var te=P(ee,2);let ne;K(M(te),{get icon(){return Va},class:`provider-status-card-toggle-icon`}),T(te),T(i),F((e,r,i,a,o)=>{B(l,t.provider.name),U(g,1,`provider-status-pill ${e??``}`,`svelte-nopjmh`),W(g,`title`,r),B(_,t.provider.status_label),B(x,i),W(C,`title`,a),B(w,o),ne=U(te,1,`provider-status-card-toggle svelte-nopjmh`,null,ne,{"is-expanded":I(n)}),W(te,`aria-expanded`,I(n)),W(te,`aria-label`,(I(n)?`Collapse `:`Expand `)+t.provider.name+` details`),W(te,`title`,I(n)?`Collapse details`:`Expand details`)},[()=>Hb(t.provider.status),()=>tx(t.provider),()=>ac(t.provider.runtime?.discovered_model_count),()=>Yb(t.provider,r),()=>Jb(t.provider,r)]),L(`click`,te,()=>tS.toggleCard(t.provider)),z(e,i),D()}Hr([`click`]);var fC=R(`

            Providers Overview

            `),pC=R(`
            `);function mC(e,t){E(t,!0);let n=O(()=>tS.status.providers);var r=Qr(),i=N(r),a=e=>{var t=fC(),r=M(t),i=P(M(r),2),a=M(i),o=M(a,!0);T(a);var s=P(a,2);let c;T(i),T(r);var l=P(r,2);H(l,21,()=>I(n),e=>e.name,(e,t)=>{dC(e,{get provider(){return I(t)}})}),T(l),T(t),F((e,t)=>{W(i,`aria-checked`,tS.detailsExpanded),W(i,`title`,e),B(o,t),c=U(s,1,`provider-status-toggle-track svelte-1kx3uw4`,null,c,{"is-active":tS.detailsExpanded})},[()=>tS.detailsToggleLabel(),()=>tS.detailsToggleLabel()]),L(`click`,i,()=>tS.toggleDetails()),z(e,t)},o=e=>{var t=pC();xS(M(t),{size:18,label:`Loading provider status`}),T(t),z(e,t)};V(i,e=>{I(n).length>0?e(a):tS.loading&&!tS.loadedOnce&&e(o,1)}),z(e,r),D()}Hr([`click`]);var hC=R(`
            `);function gC(e,t){E(t,!0);function n(){Lc.fetchUsage(),Lc.fetchCacheOverview(``),nS.fetch(),tS.fetch(),rS.fetch(),iS.fetch()}function r(){Lc.fetchUsage(),Lc.fetchCacheOverview(``),nS.fetch()}function i(){r(),iS.fetch()}An(()=>{if(q.refreshTick,qo.page===`overview`)return Er(()=>{n(),ob.start()}),()=>{ob.stop(),tS.stopPolling()}});var a=hC(),o=M(a);ub(o,{});var s=P(o,4);el(M(s),{onchange:i}),T(s);var c=P(s,2);Pc(c,{});var l=P(c,2);pS(l,{});var u=P(l,2);yS(u,{});var d=P(u,2);DS(d,{onintervalchange:r});var f=P(d,2);HS(f,{});var p=P(f,2);XS(p,{}),mC(P(p,2),{}),T(a),z(e,a),D()}var _C=`/admin/live/logs?types=audit,usage`;function vC(e,t,n){return!!t&&String(e&&e.id||``).trim()===t||!!n&&String(e&&e.request_id||``).trim()===n}function yC(e){switch(e){case`date_range`:return`Live paused — the selected date range does not include today. Set it to today to resume.`;case`filters`:return`Live paused while filters are active. Clear them to resume.`;case`pagination`:return`Live paused on later pages. Go to the first page to resume.`;default:return``}}function bC(e){let t=_C,n=Number(e||0);return Number.isFinite(n)&&n>0&&(t+=`&cursor=`+encodeURIComponent(String(n))),t}function xC(){return{async consumeLiveLogsBody(e){await Uy(e,e=>this.applyLiveLogEvent(e))},applyLiveLogEvent(e){if(!e||typeof e!=`object`)return;let t=Number(e.seq||0);Number.isFinite(t)&&t>this.liveLogsLastSeq&&(this.liveLogsLastSeq=t);let n=String(e.type||``).trim();if(n!==`heartbeat`){if(n===`reset`){this.reloadLiveLogSources();return}if(n===`audit.removed`){this.removeLiveAuditEntry(e.data);return}if(n.indexOf(`audit.`)===0){this.mergeLiveAuditEntry(e.data||{},n);return}n.indexOf(`usage.`)===0&&(this.mergeLiveUsageEntry(e.data||{},n),typeof this.noteLiveTokenUsage==`function`&&this.noteLiveTokenUsage(n))}},reloadLiveLogSources(){typeof this.fetchUsage==`function`&&this.fetchUsage(),this.page===`audit-logs`&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},auditLivePauseReason(){return!this.auditLog||this.auditLog.offset!==0?`pagination`:this.auditSearch||this.auditMethod||this.auditStatusCode||this.auditStream?`filters`:!this.followsToday&&(this.customStartDate||this.customEndDate)?`date_range`:null},auditLiveInsertAllowed(){return!this.auditLivePauseReason()},usageLiveInsertAllowed(){return this.usageLog&&this.usageLog.offset===0&&!this.usageLogSearch&&!this.usageFilterModel&&!this.usageFilterProvider&&!this.usageFilterLabel&&!this.usageFilterUserPath},mergeLiveAuditEntry(e,t){if(!e||typeof e!=`object`)return;let n=String(e.id||e.request_id||``).trim();if(!n)return;let r=String(e.request_id||``).trim(),i=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],a=i.findIndex(e=>vC(e,n,r)),o=a>=0&&i[a]||{},s=t===`audit.detail`,c=s?{...e,_detail_loaded:!0,_response_partial:!1,bodies_omitted:!1}:this.liveAuditPatch(o,e,t);if(a>=0){let e=this.mergeLiveAuditPatch(o,c);return i.splice(a,1,e),this.auditLog.entries=[...i],this.regroupLiveAuditHead(e),s||this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}let l=this.mergeLiveAuditChild(e,c);if(l)return s||this.fetchExpandedAuditDetailIfReady(l),this.cacheMergedAuditRecord(l,t),l;if(!this.auditLiveInsertAllowed()){this.cacheMergedAuditRecord(c,t);return}if(!s&&this.auditGroupSessions){let e=this.foldLiveAuditIntoThread(c);if(e)return this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}this.auditLog.entries=[this.mergeLiveAuditUsagePatch(c),...i].slice(0,this.auditLog.limit||25),this.auditLog.total=Number(this.auditLog.total||0)+1;let u=this.auditLog.entries[0];return s||this.fetchExpandedAuditDetailIfReady(u),this.cacheMergedAuditRecord(u,t),u},liveAuditPatch(e,t,n){let r=this.liveAuditStateAfter(e._live_state,n),i=this.liveAuditEventFlushed(e._live_state)||this.liveAuditEventFlushed(r),a={...t,_live:!0,_live_state:r,_audit_flushed:i,_live_pending:!i};return n===`audit.stream`?a._response_partial=!0:this.liveAuditStateSettled(n)&&(a._response_partial=!1),a},mergeLiveAuditChild(e,t){let n=this.auditThreadChildren;if(!n||typeof n!=`object`)return null;let r=String(e.id||``).trim(),i=String(e.request_id||``).trim(),a=Object.keys(n);for(let e=0;evC(e,r,i));if(c<0)continue;let l=this.mergeLiveAuditPatch(s[c]||{},t),u=[...s];return u.splice(c,1,l),this.auditThreadChildren={...n,[a[e]]:{...o,entries:u}},l}return null},regroupLiveAuditHead(e){if(!this.auditGroupSessions)return null;let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=String(e.id||``).trim(),i=n.findIndex(e=>String(e.id||``).trim()===r);if(i<0)return null;let a=n.findIndex((e,n)=>n!==i&&String(e.session_id||``).trim()===t);if(a<0)return null;let o=n[a],s=Date.parse(o&&o.timestamp),c=Date.parse(e&&e.timestamp),l=Number.isFinite(s)&&Number.isFinite(c)&&s>c,u=l?o:e,d=l?e:o,f={...u,session_count:Math.max(1,Number(o.session_count||1))+Math.max(1,Number(e.session_count||1))},p=n.filter((e,t)=>t!==i&&t!==a);return p.unshift(f),this.auditLog.entries=p,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-1),this.prependLiveAuditThreadChild(t,d),f},foldLiveAuditIntoThread(e){let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(e=>String(e.session_id||``).trim()===t);if(r<0)return null;let i=n[r],a=Number(i.session_count),o=this.mergeLiveAuditUsagePatch({...e,session_count:(Number.isFinite(a)&&a>0?a:1)+1}),s=[...n];return s.splice(r,1),s.unshift(o),this.auditLog.entries=s,this.prependLiveAuditThreadChild(t,i),o},prependLiveAuditThreadChild(e,t){let n=this.auditThreadChildren||{},r=n[e],i={...t};delete i.session_count;let a=r&&Array.isArray(r.entries)?{...r,entries:[i,...r.entries],total:Number(r.total||r.entries.length)+1}:{loading:!1,loaded:!1,entries:[i],total:1};this.auditThreadChildren={...n,[e]:a}},removeLiveAuditThreadChild(e,t){let n=this.auditThreadChildren;!n||typeof n!=`object`||Object.keys(n).forEach(r=>{let i=n[r],a=i&&Array.isArray(i.entries)?i.entries:[],o=a.filter(n=>!vC(n,e,t)),s=a.length-o.length;s!==0&&(this.auditThreadChildren={...this.auditThreadChildren,[r]:{...i,entries:o,total:Math.max(0,Number(i.total||a.length)-s)}},this.decrementLiveAuditThreadCount(r,s))})},decrementLiveAuditThreadCount(e,t){let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(t=>String(t.session_id||``).trim()===e);if(r<0)return;let i=n[r],a=[...n];a.splice(r,1,{...i,session_count:Math.max(1,Number(i.session_count||1)-t)}),this.auditLog.entries=a},mergeLiveAuditPatch(e,t){let n={...e,...t};return t.data===void 0&&e.data!==void 0?n.data=e.data:e.data&&t.data&&typeof e.data==`object`&&typeof t.data==`object`&&!Array.isArray(e.data)&&!Array.isArray(t.data)&&(n.data={...e.data,...t.data}),this.mergeLiveAuditUsagePatch(n)},mergeLiveAuditUsagePatch(e){let t=this.liveUsageEntryForAudit(e);if(!t)return e;let n=this.auditEntryWithLiveUsage(e,t);return this.removeSkippedLiveUsage(t),n},liveUsageEntryForAudit(e){let t=String(e&&e.request_id||``).trim();return t&&((this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[]).find(e=>String(e&&e.request_id||``).trim()===t)||this.skippedLiveUsageByRequestId&&this.skippedLiveUsageByRequestId[t])||null},cacheMergedAuditRecord(e,t){return e&&typeof this.cacheAuditRecord==`function`?this.cacheAuditRecord(e,t):e},fetchExpandedAuditDetailIfReady(e){!e||!this.isAuditEntryExpanded||!this.isAuditEntryExpanded(e)||String(e._live_state||``).trim()!==`audit.flushed`&&!e._audit_flushed||typeof this.fetchAuditEntryDetail==`function`&&this.fetchAuditEntryDetail(e)},liveAuditStateRank(e){switch(String(e||``).trim()){case`audit.started`:return 10;case`audit.updated`:case`audit.stream`:return 20;case`audit.completed`:return 30;case`audit.failed`:case`audit.flushed`:case`audit.detail`:return 40;default:return 0}},liveAuditStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveAuditStateRank(n)>this.liveAuditStateRank(r)?n:r},liveAuditStateSettled(e){return this.liveAuditStateRank(e)>=this.liveAuditStateRank(`audit.completed`)},liveAuditEventFlushed(e){let t=String(e||``).trim();return t===`audit.failed`||t===`audit.flushed`||t===`audit.detail`},removeLiveAuditEntry(e){if(!e||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim();if(!t&&!n)return;let r=this.auditLog.entries,i=[],a=0,o=0,s=!1;r.forEach(e=>{if(!vC(e,t,n)){i.push(e);return}a++;let r=String(e.session_id||``).trim(),c=Math.max(1,Number(e.session_count||1));if(!this.auditGroupSessions||!r||c<=1)return;o++;let l=this.auditThreadChildren&&this.auditThreadChildren[r],u=l&&Array.isArray(l.entries)?l.entries.filter(e=>!vC(e,t,n)):[];if(u.length===0){s=!0;return}let d={...u[0],session_id:r,session_count:c-1};i.push(d),this.auditThreadChildren={...this.auditThreadChildren,[r]:{...l,entries:u.slice(1),total:Math.max(0,Number(l.total||c)-1)}}}),a>0&&(this.auditLog.entries=i,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-a+o)),this.removeLiveAuditThreadChild(t,n),s&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},mergeLiveUsageEntry(e,t){if(!e||typeof e!=`object`)return;e={...e,_live_state:t||e._live_state||`usage.completed`};let n=String(e.id||``).trim();if(!n)return;let r=this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[],i=r.findIndex(e=>String(e.id||``).trim()===n);if(i>=0){let t=r[i]||{},n=this.mergeLiveUsagePatch(t,e);if(this.applyLiveUsageToAudit(n),this.liveUsageShouldSkip(n)){r.splice(i,1),this.usageLog.entries=[...r],this.usageLog.total=Math.max(0,Number(this.usageLog.total||0)-1),this.storeSkippedLiveUsage(n);return}r.splice(i,1,n),this.usageLog.entries=[...r],this.removeSkippedLiveUsage(n);return}let a=this.mergeLiveUsagePatch(this.liveUsageSeedForEntry(e),e);if(this.applyLiveUsageToAudit(a),this.liveUsageShouldSkip(a)){this.storeSkippedLiveUsage(a);return}this.removeSkippedLiveUsage(a),this.usageLog.entries=[a,...r].slice(0,this.usageLog.limit||50),this.usageLog.total=Number(this.usageLog.total||0)+1},mergeLiveUsagePatch(e,t){e=e&&typeof e==`object`?e:{};let n=this.liveUsageStateAfter(e._live_state,t&&t._live_state),r=this.liveUsageEventFlushed(e)||this.liveUsageEventFlushed({...t,_live_state:n});return{...e,...t,_live:!0,_live_state:n||`usage.completed`,_live_pending:!r,_usage_flushed:r}},liveUsageShouldSkip(e){return!!(this.usageLogHideCached&&this.liveUsageEntryCached(e))||!this.usageLiveInsertAllowed()},liveUsageSeedForEntry(e){return this.skippedLiveUsageForEntry(e)||this.auditLiveUsageForEntry(e)},skippedLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();return t&&this.skippedLiveUsageByRequestId?this.skippedLiveUsageByRequestId[t]:null},auditLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return null;let n=this.auditLog.entries.find(e=>String(e&&e.request_id||``).trim()===t),r=n&&n.usage&&typeof n.usage==`object`&&!Array.isArray(n.usage)?n.usage:null;return r?{id:e&&e.id,request_id:t,entries:r.entries,input_tokens:r.input_tokens,uncached_input_tokens:r.uncached_input_tokens,cached_input_tokens:r.cached_input_tokens,cache_write_input_tokens:r.cache_write_input_tokens,output_tokens:r.output_tokens,total_tokens:r.total_tokens,cached_input_ratio:r.cached_input_ratio,estimated_cached_characters:r.estimated_cached_characters,_live_state:n._usage_live_state,_live_pending:n._usage_live_pending,_usage_flushed:n._usage_flushed}:null},storeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&((!this.skippedLiveUsageByRequestId||typeof this.skippedLiveUsageByRequestId!=`object`||Array.isArray(this.skippedLiveUsageByRequestId))&&(this.skippedLiveUsageByRequestId={}),this.skippedLiveUsageByRequestId[t]=e)},removeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&this.skippedLiveUsageByRequestId&&delete this.skippedLiveUsageByRequestId[t]},liveUsageEntryCached(e){let t=String(e&&e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`||!!(e&&e.cache_hit)},liveUsageEventFlushed(e){let t=String(e&&e._live_state||``).trim();return!!(e&&e._usage_flushed)||t===`usage.failed`||t===`usage.flushed`},liveUsageStateRank(e){switch(String(e||``).trim()){case`usage.completed`:return 10;case`usage.failed`:case`usage.flushed`:return 20;default:return 0}},liveUsageStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveUsageStateRank(n)>this.liveUsageStateRank(r)?n:r},applyLiveUsageToAudit(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let n=this.auditLog.entries.findIndex(e=>String(e.request_id||``).trim()===t);if(n>=0){let t=this.auditLog.entries[n];this.auditLog.entries.splice(n,1,this.auditEntryWithLiveUsage(t,e)),this.auditLog.entries=[...this.auditLog.entries]}let r=this.auditThreadChildren;if(!r||typeof r!=`object`)return;let i=r,a=!1;Object.keys(r).forEach(n=>{let r=i[n],o=r&&Array.isArray(r.entries)?r.entries:[],s=o.findIndex(e=>String(e.request_id||``).trim()===t);if(s<0)return;let c=[...o];c.splice(s,1,this.auditEntryWithLiveUsage(o[s],e)),i={...i,[n]:{...r,entries:c}},a=!0}),a&&(this.auditThreadChildren=i)},auditEntryWithLiveUsage(e,t){let n=this.liveUsageStateAfter(e._usage_live_state,t._live_state||`usage.completed`),r=this.liveUsageEventFlushed({_live_state:n,_usage_flushed:e._usage_flushed||t._usage_flushed});return{...e,usage:this.liveUsageSummary(t,e.usage),_usage_live_state:n||`usage.completed`,_usage_live_pending:!r,_usage_flushed:r}},liveUsageSummary(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=this.liveNumber(e.input_tokens,this.liveNumber(n.input_tokens,0)),i=this.liveNumber(e.output_tokens,this.liveNumber(n.output_tokens,0)),a=this.liveNumber(e.uncached_input_tokens,this.liveNumber(n.uncached_input_tokens,0)),o=this.liveNumber(e.cached_input_tokens,this.liveNumber(n.cached_input_tokens,0)),s=this.liveNumber(e.cache_write_input_tokens,this.liveNumber(n.cache_write_input_tokens,0));r>0&&a+o+s===0&&(a=r);let c=a+o+s||r,l=c+i||this.liveNumber(e.total_tokens,this.liveNumber(n.total_tokens,0)),u=this.liveNumber(e.cached_input_ratio,this.liveNumber(n.cached_input_ratio,c>0?o/c:0));return{entries:Math.max(1,this.liveNumber(e.entries,this.liveNumber(n.entries,1))),input_tokens:c,uncached_input_tokens:a,cached_input_tokens:o,cache_write_input_tokens:s,output_tokens:i,total_tokens:l,cached_input_ratio:u,estimated_cached_characters:this.liveNumber(e.estimated_cached_characters,this.liveNumber(n.estimated_cached_characters,o*4))}},liveNumber(e,t){let n=Number(e);return Number.isFinite(n)?n:t},auditEntryShouldFetchDetail(e){return!e||e._detail_loading||e._detail_loaded||this.auditEntryLiveDetailPending(e)?!1:this.auditEntryNeedsPersistedLiveDetail(e)||e.bodies_omitted?!0:!this.auditEntryHasDetailData(e)},auditEntryLiveDetailPending(e){if(!e||!e._live)return!1;let t=String(e._live_state||``).trim();return t===`audit.failed`||!e._audit_flushed&&t!==`audit.flushed`&&t!==`audit.detail`},auditEntryNeedsPersistedLiveDetail(e){return!!(e&&e._live&&!e._detail_loaded)},auditEntryHasDetailData(e){let t=e&&e.data;return!t||typeof t!=`object`?!1:t.request_headers!==void 0||t.response_headers!==void 0||t.request_body!==void 0||t.response_body!==void 0||t.request_body_too_big_to_handle!==void 0||t.response_body_too_big_to_handle!==void 0||t.user_agent!==void 0||t.api_key_hash!==void 0||t.temperature!==void 0||t.max_tokens!==void 0||t.error_message!==void 0||t.error_code!==void 0},clearAuditDetailLoading(e){if(!e)return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim(),r=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],i=r.find(e=>t&&String(e.id||``).trim()===t?!0:!!(n&&String(e.request_id||``).trim()===n)),a=i||e;a._detail_loading=!1,i&&(this.auditLog.entries=[...r])}}}var SC={"audit.started":10,"audit.updated":20,"audit.stream":20,"audit.completed":30,"audit.failed":40,"audit.flushed":40,"audit.detail":40},CC=new Set(Object.keys(SC));function wC(e){return String(e&&(e.id||e.request_id)||``).trim()}function TC(e,t){let n=e&&typeof e==`object`?e:{},r=t&&typeof t==`object`?t:{},i={...n,...r};r.data==null&&n.data!=null?i.data=n.data:OC(n.data)&&OC(r.data)&&(i.data={...n.data,...r.data});let a=String(n._live_state||``).trim(),o=String(r._live_state||``).trim();return(SC[a]||0)>(SC[o]||0)&&(i._live_state=a),n._audit_flushed&&(i._audit_flushed=!0),i._audit_flushed&&(i._live_pending=!1),n._detail_loaded&&!r._detail_loaded&&(i._detail_loaded=!0,i.bodies_omitted=!1),i.bodies_omitted&&OC(i.data)&&(i.data.request_body!==void 0||i.data.response_body!==void 0)&&(i.bodies_omitted=!1),i}function EC(e,t){let n=Number(t||0);return(Array.isArray(e)?e:[]).filter(e=>Number(e&&e.version||0)>n)}function DC(e){return CC.has(String(e&&e.eventType||``).trim())}function OC(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var kC=200,AC=class{#e=k(j({entries:[],total:0,limit:25,offset:0}));get auditLog(){return I(this.#e)}set auditLog(e){A(this.#e,e,!0)}#t=k(j({entries:[],total:0,limit:50,offset:0}));get usageLog(){return I(this.#t)}set usageLog(e){A(this.#t,e,!0)}#n=k(j({}));get auditRecords(){return I(this.#n)}set auditRecords(e){A(this.#n,e,!0)}#r=k(j([]));get auditRecordChanges(){return I(this.#r)}set auditRecordChanges(e){A(this.#r,e,!0)}auditRecordVersion=0;auditRecordPins=new Set;#i=k(``);get auditSearch(){return I(this.#i)}set auditSearch(e){A(this.#i,e,!0)}#a=k(``);get auditMethod(){return I(this.#a)}set auditMethod(e){A(this.#a,e,!0)}#o=k(``);get auditStatusCode(){return I(this.#o)}set auditStatusCode(e){A(this.#o,e,!0)}#s=k(``);get auditStream(){return I(this.#s)}set auditStream(e){A(this.#s,e,!0)}#c=k(wa(`gomodel_audit_group_sessions`,`true`)!==`false`);get auditGroupSessions(){return I(this.#c)}set auditGroupSessions(e){A(this.#c,e,!0)}#l=k(j({}));get auditThreadChildren(){return I(this.#l)}set auditThreadChildren(e){A(this.#l,e,!0)}#u=k(``);get usageLogSearch(){return I(this.#u)}set usageLogSearch(e){A(this.#u,e,!0)}#d=k(``);get usageFilterModel(){return I(this.#d)}set usageFilterModel(e){A(this.#d,e,!0)}#f=k(``);get usageFilterProvider(){return I(this.#f)}set usageFilterProvider(e){A(this.#f,e,!0)}#p=k(``);get usageFilterLabel(){return I(this.#p)}set usageFilterLabel(e){A(this.#p,e,!0)}#m=k(``);get usageFilterUserPath(){return I(this.#m)}set usageFilterUserPath(e){A(this.#m,e,!0)}#h=k(!1);get usageLogHideCached(){return I(this.#h)}set usageLogHideCached(e){A(this.#h,e,!0)}#g=k(!1);get liveLogsStreaming(){return I(this.#g)}set liveLogsStreaming(e){A(this.#g,e,!0)}liveLogsLastSeq=0;liveLogsReconnectAttempts=0;liveLogsReconnectTimer=null;liveLogsController=null;skippedLiveUsageByRequestId=null;fetchUsage=null;fetchAuditLog=null;isAuditEntryExpanded=null;noteLiveTokenUsage=null;upsertAuditRecord(e,t=``){let n=wC(e);if(!n)return e;let r=TC(this.auditRecords[n],e);return this.auditRecords={...this.auditRecords,[n]:r},this.pruneAuditRecords(),this.auditRecordVersion++,this.auditRecordChanges=[...this.auditRecordChanges,{version:this.auditRecordVersion,key:n,eventType:t}].slice(-512),r}upsertAuditRecords(e,t=``){return(Array.isArray(e)?e:[]).map(e=>this.upsertAuditRecord(e,t))}auditRecord(e){let t=typeof e==`string`?String(e).trim():wC(e);return t&&this.auditRecords[t]||null}cacheAuditRecord(e,t){return this.upsertAuditRecord(e,t)}pinAuditRecords(e){this.auditRecordPins=new Set((Array.isArray(e)?e:[]).map(String))}pruneAuditRecords(){let e=Object.keys(this.auditRecords);if(e.length<=kC)return;let t={...this.auditRecords},n=e.length-kC;for(let r of e){if(n<=0)break;this.auditRecordPins.has(r)||(delete t[r],n--)}this.auditRecords=t}get page(){return qo.page}get customStartDate(){return jc.customStartDate}get customEndDate(){return jc.customEndDate}get followsToday(){return jc.followsToday}liveLogsEnabled(){return xs.liveLogsVisible()}async startLiveLogs(){typeof fetch!=`function`||typeof ReadableStream>`u`||(await xs.ensureLoaded(),this.liveLogsEnabled()&&(this.stopLiveLogs(),this.liveLogsController=typeof AbortController==`function`?new AbortController:null,this.readLiveLogsStream(this.liveLogsController)))}stopLiveLogs(){this.liveLogsStreaming=!1,this.liveLogsReconnectTimer&&=(clearTimeout(this.liveLogsReconnectTimer),null),this.liveLogsController&&typeof this.liveLogsController.abort==`function`&&this.liveLogsController.abort(),this.liveLogsController=null}ensureLiveLogs(){this.liveLogsController||this.liveLogsReconnectTimer||this.startLiveLogs()}async readLiveLogsStream(e){let t={};e&&(t.signal=e.signal);let n=bC(this.liveLogsLastSeq),r=q.generation;try{let i=await ms(n,t);if(i.status===401){if(q.handleUnauthorized(r),r{this.liveLogsReconnectTimer=null,this.startLiveLogs()},t)}async fetchAuditEntryDetail(e){if(!this.auditEntryShouldFetchDetail(e))return;let t=String(e.id||``).trim();if(!t)return;e._detail_loading=!0;let n=e;try{let e=await gs(`/admin/audit/detail?log_id=`+encodeURIComponent(t),{label:`audit detail`});if(e.stale||!e.ok)return;n=this.mergeLiveAuditEntry(e.data,`audit.detail`)||n}catch(e){console.error(`Failed to fetch audit detail:`,e)}finally{this.clearAuditDetailLoading(n)}}};Object.assign(AC.prototype,xC());var jC=new AC;if(typeof window<`u`){let e=!1;window.addEventListener(`pagehide`,()=>{e=!!jC.liveLogsController,jC.stopLiveLogs()}),window.addEventListener(`pageshow`,t=>{t.persisted&&e&&jC.ensureLiveLogs()})}var MC=null;Mn(()=>{An(()=>{let e=q.refreshTick;if(MC===null){MC=e;return}e!==MC&&(MC=e,Er(()=>{jC.stopLiveLogs(),jC.startLiveLogs()}))})});function NC(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,uncached_input_tokens:0,cached_input_tokens:0,cache_write_input_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null,rewrite_tokens_saved:0,rewrite_cost_saved:null}}function PC(){return{entries:[],total:0,limit:50,offset:0}}function FC(e,t){let n=[[`model`,e&&e.model],[`provider`,e&&e.provider],[`label`,e&&e.label],[`user_path`,e&&e.user_path]],r=``;for(let[e,i]of n)!i||e===t||(r+=`&`+e+`=`+encodeURIComponent(i));return r}function IC({limit:e,offset:t,hideCached:n,search:r}){let i=`&limit=`+e+`&offset=`+t;return i+=`&cache_mode=`+(n?`uncached`:`all`),r&&(i+=`&search=`+encodeURIComponent(r)),i}function LC(e,t){let n=new Set(e||[]);return t&&n.add(t),[...n].sort()}function RC(e,t){let n=Number(t&&t.total_requests||0)-Number(e&&e.total_requests||0);return Number.isFinite(n)&&n>0?n:0}function zC(e,t,n){let r=n?e:t,i=Number(r&&r.total_requests||0);return Number.isFinite(i)?i:0}function BC(e,t,n){let r=RC(e,t);return r<=0?``:n?ac(r)+` cached requests hidden`:ac(Number(e&&e.total_requests||0))+` to providers + `+ac(r)+` from cache`}function VC(e){let t=e||{};return t.total_input_cost===null||t.total_input_cost===void 0?``:oc(t.total_input_cost)+` input + `+oc(t.total_output_cost)+` output`}function HC(e){let t=Number(e&&e.rewrite_tokens_saved||0);return Number.isFinite(t)&&t>0?t:0}function UC(e){return HC(e)>0}function WC(e){let t=e||{};return t.rewrite_cost_saved===void 0?null:t.rewrite_cost_saved}function GC(){return`Estimated at 4 net characters removed per token`}function KC(e,t){return t===`costs`?oc(WC(e)):lc(HC(e))}function qC(e,t){let n=t===`costs`,r=n?Number(WC(e)):HC(e);if(!Number.isFinite(r)||r<=0)return null;let i=e&&(n?e.total_cost:e.total_input_tokens);if(i==null)return null;let a=Number(i);return!Number.isFinite(a)||a<0?null:r/(a+r)*100}function JC(e,t){let n=qC(e,t);return n===null?``:(n<.1?`<0.1`:n.toFixed(1))+`% less`}function YC(e,t){let n=HC(e);if(n<=0)return``;let r=[ac(n)+` estimated prompt token-transmissions removed across provider requests`,GC(),`Savings are summed per provider request; resent conversation history is counted again`],i=WC(e);i!=null&&(r.push(oc(i)+` estimated gross input cost avoided`),r.push(`Prompt-cache changes caused by rewriting are not included`));let a=JC(e,t);return a&&r.push(a+` than the same traffic without rewriting (`+(t===`costs`?`cost`:`tokens`)+`)`),r.join(` -`)}function XC(e){return String(e&&e.cost_source||``).trim()}function ZC(e){let t=XC(e);return t===`openrouter_credits`||t===`xai_cost_in_usd_ticks`}function QC(e){switch(XC(e)){case`openrouter_credits`:return`Costs from OpenRouter USD-based credits.`;case`xai_cost_in_usd_ticks`:return`Costs from xAI usage.cost_in_usd_ticks.`;default:return``}}function $C(e){return String(e&&e.cache_type||``).trim().toLowerCase()}function ew(e){let t=$C(e);return t===`exact`||t===`semantic`}function tw(e){let t=$C(e);return t===`exact`?`Exact`:t===`semantic`?`Semantic`:`-`}function nw(e,t){let n=t?String(t):``;return ew(e)?n?`Saved by cache — not charged -`+n:`Saved by cache — not charged`:n}function rw(e){let t=Number(e&&e.cached_input_ratio);return!Number.isFinite(t)||t<=0?0:Math.min(1,t)}function iw(e){return Number(e&&e.cached_input_tokens||0)>0}function aw(e){return iw(e)?(rw(e)*100).toFixed(1)+`%`:``}function ow(e){if(!iw(e))return``;let t=Number(e.cached_input_tokens||0),n=Number(e.uncached_input_tokens||0),r=Number(e.cache_write_input_tokens||0),i=t+n+r,a=[ac(t)+` cached / `+ac(i)+` input tokens`];return r>0&&a.push(ac(r)+` cache write`),a.join(` -`)}function sw(e){let t=[];if(QC(e)&&(t.push(QC(e)),t.push(``)),t.push(`Input: `+oc(e.input_cost)),t.push(`Output: `+oc(e.output_cost)),e.raw_data){t.push(``);for(let[n,r]of Object.entries(e.raw_data)){let e=n.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),i=r&&typeof r==`object`?JSON.stringify(r):ac(r);t.push(e+`: `+i)}}return t.join(` -`)}function cw(e){return Array.isArray(e&&e.labels)?e.labels:[]}function lw(e,t,n){return(e||[]).length>0||t?!0:(n||[]).some(e=>cw(e).length>0)}function uw(e){return e&&typeof e.total_tokens==`number`?e.total_tokens:(e&&e.input_tokens||0)+(e&&e.output_tokens||0)}function dw(e,t){return t?e.total_cost||0:uw(e)}function fw(e,t){return[...e||[]].sort((e,n)=>t?(n.total_cost||0)-(e.total_cost||0):dw(n,t)-dw(e,t))}function pw(e){let t=Array.isArray(e)?e:[];if(t.length===0)return!1;if(t.length!==1)return!0;let n=String(t[0]&&t[0].user_path||``).trim();return n!==``&&n!==`/`}function mw(e){return(e||`chart`)===`chart`||e===`stacked`}function hw(e,t,n){let r=fw(e,n),i=e=>Number(e)||0,a=e=>n?Math.min(i(e.cached_input_cost),i(e.input_cost)):i(e.cached_input_tokens),o=e=>n?i(e.input_cost)-a(e):i(e.uncached_input_tokens)+i(e.cached_input_tokens)+i(e.cache_write_input_tokens)>0?i(e.uncached_input_tokens)+i(e.cache_write_input_tokens):i(e.input_tokens),s=e=>i(n?e.output_cost:e.output_tokens),c=e=>n?0:i(e.local_cached_input_tokens),l=e=>n?0:i(e.local_cached_output_tokens),u=r.slice(0,10),d=r.slice(10),f=u.map(t),p=u.map(o),m=u.map(s),h=u.map(a),g=u.map(c),_=u.map(l);if(d.length>0){f.push(`Other`);let e=e=>d.reduce((t,n)=>t+e(n),0);p.push(e(o)),m.push(e(s)),h.push(e(a)),g.push(e(c)),_.push(e(l))}return{labels:f,inputs:p,outputs:m,prompts:h,localIns:g,localOuts:_}}function gw(e){return Math.max(200,e*32+72)}var _w=new class{#e=k(`tokens`);get usageMode(){return I(this.#e)}set usageMode(e){A(this.#e,e,!0)}get usageFilterModel(){return jC.usageFilterModel}set usageFilterModel(e){jC.usageFilterModel=e}get usageFilterProvider(){return jC.usageFilterProvider}set usageFilterProvider(e){jC.usageFilterProvider=e}get usageFilterLabel(){return jC.usageFilterLabel}set usageFilterLabel(e){jC.usageFilterLabel=e}get usageFilterUserPath(){return jC.usageFilterUserPath}set usageFilterUserPath(e){jC.usageFilterUserPath=e}#t=k(j({models:[],providers:[],labels:[]}));get usageFacetOptions(){return I(this.#t)}set usageFacetOptions(e){A(this.#t,e,!0)}#n=k(j(NC()));get usageSummary(){return I(this.#n)}set usageSummary(e){A(this.#n,e,!0)}#r=k(j(NC()));get usageSummaryAll(){return I(this.#r)}set usageSummaryAll(e){A(this.#r,e,!0)}#i=k(j([]));get modelUsage(){return I(this.#i)}set modelUsage(e){A(this.#i,e,!0)}#a=k(j([]));get userPathUsage(){return I(this.#a)}set userPathUsage(e){A(this.#a,e,!0)}#o=k(j([]));get labelUsage(){return I(this.#o)}set labelUsage(e){A(this.#o,e,!0)}get usageLog(){return jC.usageLog}set usageLog(e){jC.usageLog=e}get usageLogSearch(){return jC.usageLogSearch}set usageLogSearch(e){jC.usageLogSearch=e}get usageLogHideCached(){return jC.usageLogHideCached}set usageLogHideCached(e){jC.usageLogHideCached=e}#s=k(`chart`);get modelUsageView(){return I(this.#s)}set modelUsageView(e){A(this.#s,e,!0)}#c=k(`chart`);get userPathUsageView(){return I(this.#c)}set userPathUsageView(e){A(this.#c,e,!0)}#l=k(`chart`);get labelUsageView(){return I(this.#l)}set labelUsageView(e){A(this.#l,e,!0)}#u=k(!1);get summaryLoading(){return I(this.#u)}set summaryLoading(e){A(this.#u,e,!0)}#d=k(!1);get modelUsageLoading(){return I(this.#d)}set modelUsageLoading(e){A(this.#d,e,!0)}#f=k(!1);get userPathUsageLoading(){return I(this.#f)}set userPathUsageLoading(e){A(this.#f,e,!0)}#p=k(!1);get labelUsageLoading(){return I(this.#p)}set labelUsageLoading(e){A(this.#p,e,!0)}#m=k(!1);get usageLogLoading(){return I(this.#m)}set usageLogLoading(e){A(this.#m,e,!0)}#h={};#g(e){this.#h[e]&&this.#h[e].abort();let t=new AbortController;return this.#h[e]=t,t}#_(e,t){this.#h[e]===t&&(this.#h[e]=null)}filterQueryStr(e){return FC({model:this.usageFilterModel,provider:this.usageFilterProvider,label:this.usageFilterLabel,user_path:this.usageFilterUserPath},e)}onUsageFilterChanged(){this.fetchUsagePage()}toggleUsageLabelFilter(e){this.usageFilterLabel=this.usageFilterLabel===e?``:e,this.onUsageFilterChanged()}usageLabelChipTitle(e){return this.usageFilterLabel===e?`Clear label filter`:`Filter usage by "`+e+`"`}toggleUsageMode(e){this.usageMode=e,qo.navigate(`usage`,e===`costs`?`costs`:null)}toggleUsageChartView(e,t){e===`model`&&(this.modelUsageView=t),e===`userPath`&&(this.userPathUsageView=t),e===`label`&&(this.labelUsageView=t)}usageFilterModelOptions(){return LC(this.usageFacetOptions.models,this.usageFilterModel)}usageFilterProviderOptions(){return LC(this.usageFacetOptions.providers,this.usageFilterProvider)}usageFilterLabelOptions(){return LC(this.usageFacetOptions.labels,this.usageFilterLabel)}async fetchUsagePage(){await xs.ensureLoaded();let e=[this.fetchUsagePageSummary(),this.fetchUsageFacetOptions(),this.fetchModelUsage(),this.fetchUserPathUsage(),this.fetchLabelUsage(),this.fetchUsageLog(!0)];Lc.cacheAnalyticsEnabled()&&e.push(Lc.fetchCacheOverview(this.filterQueryStr())),await Promise.all(e)}async fetchUsagePageSummary(){let e=this.#g(`summary`);this.summaryLoading=!0;try{let t=jc.queryStr()+this.filterQueryStr(),[n,r]=await Promise.all([gs(`/admin/usage/summary?`+t+`&cache_mode=uncached`,{label:`usage page summary`,signal:e.signal}),gs(`/admin/usage/summary?`+t+`&cache_mode=all`,{label:`usage page summary (all)`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.usageSummary=NC(),this.usageSummaryAll=NC();return}this.usageSummary=n.data&&typeof n.data==`object`?n.data:NC(),this.usageSummaryAll=r.data&&typeof r.data==`object`?r.data:NC()}catch(e){if(vs(e))return;console.error(`Failed to fetch usage page summary:`,e),this.usageSummary=NC(),this.usageSummaryAll=NC()}finally{this.#_(`summary`,e),this.#h.summary===null&&(this.summaryLoading=!1)}}async fetchUsageFacetOptions(){let e=this.#g(`facets`);try{let t=async(t,n)=>{let r=await gs(t+`?`+jc.queryStr()+this.filterQueryStr(n),{label:`usage facet options`,signal:e.signal});return r.stale?null:r.ok&&Array.isArray(r.data)?r.data:[]},n=t(`/admin/usage/models`,`model`),r=!this.usageFilterModel&&!this.usageFilterProvider,[i,a,o]=await Promise.all([n,r?n:t(`/admin/usage/models`,`provider`),t(`/admin/usage/labels`,`label`)]);if(e.signal.aborted||i===null||a===null||o===null)return;this.usageFacetOptions={models:i.map(e=>e&&e.model).filter(Boolean),providers:a.map(e=>hc(e)).filter(Boolean),labels:o.map(e=>e&&e.label).filter(Boolean)}}catch(e){if(vs(e))return;console.error(`Failed to fetch usage facet options:`,e),this.usageFacetOptions={models:[],providers:[],labels:[]}}finally{this.#_(`facets`,e)}}async#v(e,t,n,r,i){let a=this.#g(e);i(!0);try{let e=await gs(t+`?`+jc.queryStr()+this.filterQueryStr(),{label:n,signal:a.signal});if(e.stale||a.signal.aborted)return;if(!e.ok){r([]);return}r(Array.isArray(e.data)?e.data:[])}catch(e){if(vs(e))return;console.error(`Failed to fetch `+n+`:`,e),r([])}finally{this.#_(e,a),this.#h[e]===null&&i(!1)}}fetchModelUsage(){return this.#v(`modelUsage`,`/admin/usage/models`,`usage models`,e=>this.modelUsage=e,e=>this.modelUsageLoading=e)}fetchUserPathUsage(){return this.#v(`userPathUsage`,`/admin/usage/user-paths`,`usage user paths`,e=>this.userPathUsage=e,e=>this.userPathUsageLoading=e)}fetchLabelUsage(){return this.#v(`labelUsage`,`/admin/usage/labels`,`usage labels`,e=>this.labelUsage=e,e=>this.labelUsageLoading=e)}async fetchUsageLog(e){let t=this.#g(`usageLog`);this.usageLogLoading=!0;try{e&&(this.usageLog.offset=0);let n=jc.queryStr()+this.filterQueryStr();n+=IC({limit:this.usageLog.limit,offset:this.usageLog.offset,hideCached:this.usageLogHideCached,search:this.usageLogSearch});let r=await gs(`/admin/usage/log?`+n,{label:`usage log`,signal:t.signal});if(r.stale||t.signal.aborted)return;if(!r.ok){this.usageLog=PC();return}let i=r.data&&typeof r.data==`object`?r.data:PC();i.entries||=[],this.usageLog=i}catch(e){if(vs(e))return;console.error(`Failed to fetch usage log:`,e),this.usageLog=PC()}finally{this.#_(`usageLog`,t),this.#h.usageLog===null&&(this.usageLogLoading=!1)}}usageLogNextPage(){this.usageLog.offset+this.usageLog.limit0&&(this.usageLog.offset=Math.max(0,this.usageLog.offset-this.usageLog.limit),this.fetchUsageLog(!1))}};jC.fetchUsage=()=>{qo.page===`usage`&&_w.fetchUsagePage()};var vw=R(`
            `);function yw(e,t){E(t,!0);let n=G(t,`value`,15,``),r=G(t,`placeholder`,3,``),i=G(t,`label`,3,``),a=G(t,`id`,3,void 0),o=G(t,`oninput`,3,void 0),s=G(t,`class`,3,``);var c=vw(),l=M(c);K(l,{get icon(){return _o},class:`filter-input-icon`});var u=P(l,2);na(u),T(c),F(()=>{U(c,1,Fi([`filter-input-wrap`,s()]),`svelte-30xz1k`),W(u,`id`,a()),W(u,`placeholder`,r()),W(u,`aria-label`,i())}),L(`input`,u,function(...e){o()?.apply(this,e)}),da(u,n),z(e,c),D()}Hr([`input`]);function bw(e,t=300){let n=null,r=(...r)=>{clearTimeout(n),n=setTimeout(()=>{n=null,e(...r)},t)};return r.cancel=()=>{clearTimeout(n),n=null},r}var xw=R(``),Sw=R(``),Cw=R(`
            `);function ww(e,t){E(t,!0);let n=bw(()=>_w.onUsageFilterChanged());An(()=>n.cancel);var r=Cw(),i=M(r),a=M(i);a.value=a.__value=``,H(P(a),16,()=>_w.usageFilterModelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(i);var o=P(i,2),s=M(o);s.value=s.__value=``,H(P(s),16,()=>_w.usageFilterProviderOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(o);var c=P(o,2),l=e=>{var t=Sw(),n=M(t);n.value=n.__value=``,H(P(n),16,()=>_w.usageFilterLabelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(t),L(`change`,t,()=>_w.onUsageFilterChanged()),Gi(t,()=>_w.usageFilterLabel,e=>_w.usageFilterLabel=e),z(e,t)},u=O(()=>_w.usageFilterLabelOptions().length>0);V(c,e=>{I(u)&&e(l)}),yw(P(c,2),{class:`usage-page-filters-user-path`,placeholder:`User path /team/alpha`,label:`Filter by user path`,get oninput(){return n},get value(){return _w.usageFilterUserPath},set value(e){_w.usageFilterUserPath=e}}),T(r),L(`change`,i,()=>_w.onUsageFilterChanged()),Gi(i,()=>_w.usageFilterModel,e=>_w.usageFilterModel=e),L(`change`,o,()=>_w.onUsageFilterChanged()),Gi(o,()=>_w.usageFilterProvider,e=>_w.usageFilterProvider=e),z(e,r),D()}Hr([`change`]);var Tw=R(`
            Cache Saved
            Cache Hits
            `,1);function Ew(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Tw(),n=N(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var a=P(n,2),o=P(M(a),2),s=M(o,!0);T(o),T(a),F((e,t)=>{B(i,e),B(s,t)},[()=>oc(Lc.cacheOverview.summary.total_saved_cost),()=>ac(Lc.cacheOverview.summary.total_hits)]),z(e,t)},a=O(()=>Lc.cacheAnalyticsEnabled());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}var Dw=R(` `),Ow=R(`
            Pro Saved
            `),kw=R(`
            Total Requests
            Estimated Cost
            `);function Aw(e,t){E(t,!0);let n=O(()=>UC(_w.usageSummary)),r=O(()=>KC(_w.usageSummary,_w.usageMode)),i=O(()=>JC(_w.usageSummary,_w.usageMode));var a=kw(),o=M(a),s=P(M(o),2),c=M(s),l=e=>{xS(e,{size:18,label:`Loading usage summary`})},u=e=>{var t=Zr();F(e=>B(t,e),[()=>ac(zC(_w.usageSummary,_w.usageSummaryAll,_w.usageLogHideCached))]),z(e,t)};V(c,e=>{_w.summaryLoading?e(l):e(u,-1)}),T(s),T(o);var d=P(o,2),f=P(M(d),2),p=M(f),m=e=>{xS(e,{size:18,label:`Loading usage summary`})},h=e=>{var t=Zr();F(e=>B(t,e),[()=>oc(_w.usageSummary.total_cost)]),z(e,t)};V(p,e=>{_w.summaryLoading?e(m):e(h,-1)}),T(f),T(d);var g=P(d,2),_=e=>{var t=Ow(),n=P(M(t),2),a=M(n),o=M(a,!0);T(a);var s=P(a,2),c=e=>{var t=Dw(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)};V(s,e=>{I(i)&&e(c)}),T(n),T(t),F(e=>{W(n,`title`,e),B(o,I(r))},[()=>YC(_w.usageSummary,_w.usageMode)]),z(e,t)};V(g,e=>{I(n)&&e(_)}),Ew(P(g,2),{}),T(a),F((e,t)=>{W(s,`title`,e),W(f,`title`,t)},[()=>BC(_w.usageSummary,_w.usageSummaryAll,_w.usageLogHideCached),()=>VC(_w.usageSummary)]),z(e,a),D()}function jw(e,t,n,r){let{stacked:i=!1,costs:a=!1,resolve:o=e=>e}=r||{},s=e=>a?`$`+Math.abs(e).toFixed(2):lc(Math.abs(e)),c=e=>a?`$`+Math.abs(e).toFixed(4):Math.abs(e).toLocaleString(),l=e=>e.map(e=>i?Math.abs(e):-Math.abs(e)),u=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:`transparent`,borderWidth:0,borderRadius:4,maxBarThickness:22}),d=e=>(e||[]).some(e=>Math.abs(e)>0),f=[u(a?`Input Cost`:`Input Tokens`,l(n.inputs),o(`var(--token-input)`)),u(a?`Output Cost`:`Output Tokens`,n.outputs,o(`var(--token-output)`))];return d(n.prompts)&&f.push(u(a?`Prompt Cached Cost`:`Prompt Cached`,l(n.prompts),o(`var(--token-prompt)`))),!a&&d(n.localIns)&&f.push(u(`Locally Cached (Input)`,l(n.localIns),o(`var(--token-local)`))),!a&&d(n.localOuts)&&f.push(u(`Locally Cached (Output)`,n.localOuts,o(`var(--token-local)`))),{type:`bar`,data:{labels:t,datasets:f},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:{top:8}},scales:{x:{stacked:!0,beginAtZero:!0,grid:i?{color:e.grid}:{color:t=>t.tick&&t.tick.value===0?e.text:e.grid},border:{display:!1},ticks:{color:e.text,font:Iy(),callback:e=>s(e)}},y:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Iy(),autoSkip:!1}}},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ly(e,{label:e=>e.dataset.label+`: `+c(e.parsed.x),footer:e=>{let t=0;return e.forEach(e=>{t+=Math.abs(Number(e.parsed.x))||0}),`Total: `+c(t)}})}}}}var Mw=R(`
            `),Nw=R(`

            `),Pw=R(`

            `,1),Fw=R(`
            `),Iw=R(`Model Provider`,1),Lw=R(`User Path`),Rw=R(`Label Requests`,1),zw=R(` `,1),Bw=R(` `),Vw=R(` `,1),Hw=R(` `),Uw=R(`
            Input TokensOutput TokensPrompt CachedLocal CachedTotal TokensInput CostOutput CostTotal Cost
            `),Ww=R(`
            `),Gw=R(`
            `);function Kw(e,t){E(t,!0);let n=e=>{var n=Mw(),r=M(n);let a;var o=P(r,2);let s;var l=P(o,2);let u;T(n),F(()=>{W(n,`aria-label`,I(i).group),a=U(r,1,`chart-view-btn svelte-1kee4g8`,null,a,{active:I(c)===`chart`}),W(r,`aria-pressed`,I(c)===`chart`),W(r,`aria-label`,`Show ${I(i).noun??``} chart`),s=U(o,1,`chart-view-btn svelte-1kee4g8`,null,s,{active:I(c)===`stacked`}),W(o,`aria-pressed`,I(c)===`stacked`),W(o,`aria-label`,`Show ${I(i).noun??``} stacked chart`),u=U(l,1,`chart-view-btn svelte-1kee4g8`,null,u,{active:I(c)===`table`}),W(l,`aria-pressed`,I(c)===`table`),W(l,`aria-label`,`Show ${I(i).noun??``} table`)}),L(`click`,r,()=>_w.toggleUsageChartView(t.kind,`chart`)),L(`click`,o,()=>_w.toggleUsageChartView(t.kind,`stacked`)),L(`click`,l,()=>_w.toggleUsageChartView(t.kind,`table`)),z(e,n)},r={model:{group:`Model usage view`,noun:`model usage`,tokensTitle:`Token Usage by Model`,costsTitle:`Cost by Model`},userPath:{group:`User path usage view`,noun:`user path usage`,tokensTitle:`Usage by User Path`,costsTitle:`Cost by User Path`},label:{group:`Label usage view`,noun:`label usage`,tokensTitle:`Usage by Label`,costsTitle:`Cost by Label`}},i=O(()=>r[t.kind]),a=O(()=>t.kind===`model`?e=>_c(e):t.kind===`userPath`?e=>e.user_path||`/`:e=>e.label);function o(e){return t.kind===`model`?(e.provider_name||e.provider||`-`)+`/`+e.model:t.kind===`userPath`?e.user_path||`/`:e.label}let s=O(()=>t.kind===`model`?_w.modelUsage:t.kind===`userPath`?_w.userPathUsage:_w.labelUsage),c=O(()=>t.kind===`model`?_w.modelUsageView:t.kind===`userPath`?_w.userPathUsageView:_w.labelUsageView),l=O(()=>t.kind===`model`?_w.modelUsageLoading:t.kind===`userPath`?_w.userPathUsageLoading:_w.labelUsageLoading),u=O(()=>_w.usageMode===`costs`),d=O(()=>t.kind===`userPath`?pw(I(s)):I(s).length>0),f=O(()=>I(u)?I(i).costsTitle:I(i).tokensTitle),p=O(()=>hw(I(s),I(a),I(u))),m=O(()=>fw(I(s),I(u)));function h(){return mw(I(c))?jw(Fy(),I(p).labels,I(p),{stacked:I(c)===`stacked`,costs:I(u),resolve:Ry}):null}var g=Qr(),_=N(g),v=e=>{var r=Ww(),a=M(r),s=M(a),u=e=>{KS(e,{copyId:`label-usage-help-copy`,label:`label usage help`,text:`One request can have multiple labels. Such a request counts once under each of its labels, so label rows can overlap and add up to more than the period totals.`,title:e=>{var t=Nw(),n=M(t,!0);T(t),F(()=>B(n,I(f))),z(e,t)},extra:e=>{var t=Qr(),n=N(t),r=e=>{xS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(n,e=>{I(l)&&e(r)}),z(e,t)},$$slots:{title:!0,extra:!0}})},d=e=>{var t=Pw(),n=N(t),r=M(n,!0);T(n);var a=P(n,2),o=e=>{xS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(a,e=>{I(l)&&e(o)}),F(()=>B(r,I(f))),z(e,t)};V(s,e=>{t.kind===`label`?e(u):e(d,-1)});var g=P(s,2);n(g),T(a);var _=P(a,2),v=e=>{var t=Fw();let n;Ay(M(t),{build:h}),T(t),F(e=>n=Hi(t,``,n,e),[()=>({height:`${gw(I(p).labels.length)??``}px`})]),z(e,t)},y=O(()=>mw(I(c))),b=e=>{var n=Uw(),r=M(n),i=M(r),a=M(i),s=M(a),c=e=>{var t=Iw();Ue(2),z(e,t)},l=e=>{z(e,Lw())},u=e=>{var t=Rw();Ue(2),z(e,t)};V(s,e=>{t.kind===`model`?e(c):t.kind===`userPath`?e(l,1):e(u,-1)}),Ue(8),T(a),T(i);var d=P(i);H(d,21,()=>I(m),e=>o(e),(e,n)=>{var r=Hw(),i=M(r),a=e=>{var t=zw(),r=N(t),i=M(r,!0);T(r);var a=P(r,2),o=M(a),s=M(o,!0);T(o),T(a),F(e=>{B(i,I(n).model||`-`),B(s,e)},[()=>hc(I(n))||`-`]),z(e,t)},o=e=>{var t=Bw(),r=M(t,!0);T(t),F(()=>B(r,I(n).user_path||`/`)),z(e,t)},s=e=>{var t=Vw(),r=N(t),i=M(r);let a;var o=M(i,!0);T(i),T(r);var s=P(r,2),c=M(s,!0);T(s),F((e,t,r)=>{a=U(i,1,`usage-label-chip`,null,a,{active:_w.usageFilterLabel===I(n).label}),Hi(i,`--label-color: ${e??``}`),W(i,`title`,t),B(o,I(n).label),B(c,r)},[()=>Vy(I(n).label),()=>_w.usageLabelChipTitle(I(n).label),()=>ac(I(n).requests)]),L(`click`,i,()=>_w.toggleUsageLabelFilter(I(n).label)),z(e,t)};V(i,e=>{t.kind===`model`?e(a):t.kind===`userPath`?e(o,1):e(s,-1)});var c=P(i),l=M(c,!0);T(c);var u=P(c),d=M(u,!0);T(u);var f=P(u),p=M(f,!0);T(f);var m=P(f),h=M(m,!0);T(m);var g=P(m),_=M(g,!0);T(g);var v=P(g),y=M(v,!0);T(v);var b=P(v),x=M(b,!0);T(b);var S=P(b),C=M(S,!0);T(S),T(r),F((e,t,n,r,i,a,o,s,c,u,g)=>{B(l,e),B(d,t),W(f,`title`,n),B(p,r),W(m,`title`,`${i??``} input + ${a??``} output`),B(h,o),B(_,s),B(y,c),B(x,u),B(C,g)},[()=>ac(I(n).input_tokens),()=>ac(I(n).output_tokens),()=>I(n).cached_input_cost==null?``:`~`+oc(I(n).cached_input_cost)+` at current cached-input pricing`,()=>ac(I(n).cached_input_tokens||0),()=>ac(I(n).local_cached_input_tokens||0),()=>ac(I(n).local_cached_output_tokens||0),()=>ac((I(n).local_cached_input_tokens||0)+(I(n).local_cached_output_tokens||0)),()=>ac(uw(I(n))),()=>oc(I(n).input_cost),()=>oc(I(n).output_cost),()=>oc(I(n).total_cost)]),z(e,r)}),T(d),T(r),T(n),z(e,n)};V(_,e=>{I(y)?e(v):e(b,-1)}),T(r),z(e,r)},y=e=>{var t=Gw();xS(M(t),{size:20,get label(){return`Loading ${I(i).noun??``}`}}),T(t),z(e,t)};V(_,e=>{I(d)?e(v):I(l)&&e(y,1)}),z(e,g),D()}Hr([`click`]);var qw=R(``);function Jw(e,t){E(t,!0);let n=G(t,`total`,3,0),r=G(t,`offset`,3,0),i=G(t,`limit`,3,25);var a=Qr(),o=N(a),s=e=>{var a=qw(),o=M(a),s=M(o);T(o);var c=P(o,2),l=M(c),u=P(l,2);T(c),T(a),F(e=>{B(s,`Showing ${r()+1}-${e??``} of ${n()??``}`),l.disabled=r()===0,u.disabled=r()+i()>=n()},[()=>Math.min(r()+i(),n())]),L(`click`,l,()=>t.onprev?.()),L(`click`,u,()=>t.onnext?.()),z(e,a)};V(o,e=>{n()>0&&e(s)}),z(e,a),D()}Hr([`click`]);var Yw=(e,t=f)=>{var n=Qr(),r=N(n),i=e=>{var n=Zw();H(n,20,()=>cw(t()),e=>e,(e,t)=>{var n=Xw();let r;var i=M(n,!0);T(n),F((e,a)=>{r=U(n,1,`usage-label-chip`,null,r,{active:_w.usageFilterLabel===t}),Hi(n,`--label-color: ${e??``}`),W(n,`title`,a),B(i,t)},[()=>Vy(t),()=>_w.usageLabelChipTitle(t)]),L(`click`,n,()=>_w.toggleUsageLabelFilter(t)),z(e,n)}),T(n),z(e,n)},a=O(()=>cw(t()).length>0),o=e=>{z(e,Qw())};V(r,e=>{I(a)?e(i):e(o,-1)}),z(e,n)},Xw=R(``),Zw=R(`
            `),Qw=R(`-`),$w=R(`Labels`),eT=R(`Cost`),tT=R(``),nT=R(` `),rT=R(``),iT=R(` `),aT=R(` `),oT=R(`
            TimestampProviderModelUser PathCacheProvider Cache
            `),sT=R(`
            `),cT=R(`
            `),lT=R(`

            Request Log

            `);function uT(e,t){E(t,!0);let n=O(()=>_w.usageMode===`costs`),r=O(()=>lw(_w.labelUsage,_w.usageFilterLabel,_w.usageLog.entries)),i=bw(()=>_w.fetchUsageLog(!0));An(()=>i.cancel);var a=lT(),o=P(M(a),2),s=M(o);yw(M(s),{placeholder:`Search by request ID, model, provider...`,label:`Search by request ID, model, provider`,get oninput(){return i},get value(){return _w.usageLogSearch},set value(e){_w.usageLogSearch=e}}),T(s);var c=P(s,2),l=M(c),u=M(l);na(u),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=e=>{var t=oT(),i=M(t),a=M(i),o=M(a),s=P(M(o),4),c=e=>{z(e,$w())};V(s,e=>{I(r)&&e(c)});var l=P(s,3),u=M(l,!0);T(l);var d=P(l),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{z(e,eT())};V(h,e=>{I(n)||e(g)}),T(o),T(a);var _=P(a);H(_,21,()=>_w.usageLog.entries,e=>e.id,(e,t)=>{var i=aT();let a;var o=M(i),s=M(o,!0);T(o);var c=P(o),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{var n=tT();Yw(M(n),()=>I(t)),T(n),z(e,n)};V(h,e=>{I(r)&&e(g)});var _=P(h),v=M(_,!0);T(_);var y=P(_),b=M(y),x=e=>{var n=nT(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>aw(I(t))]),z(e,n)},S=O(()=>iw(I(t))),C=e=>{z(e,Qw())};V(b,e=>{I(S)?e(x):e(C,-1)}),T(y);var w=P(y),ee=M(w,!0);T(w);var te=P(w),ne=M(te,!0);T(te);var re=P(te),ie=M(re),ae=M(ie,!0);T(ie);var oe=P(ie,2),se=e=>{{let n=O(()=>QC(I(t)));K(e,{get icon(){return Ka},class:`cost-source-icon`,get title(){return I(n)}})}},ce=O(()=>I(n)&&ZC(I(t)));V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{K(e,{get icon(){return Ya},class:`cache-savings-icon`})},de=O(()=>I(n)&&ew(I(t)));V(le,e=>{I(de)&&e(ue)});var fe=P(le,2),pe=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(fe,e=>{I(n)&&I(t).costs_calculation_caveat&&e(pe)}),T(re);var me=P(re),he=e=>{var n=iT(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{{let n=O(()=>QC(I(t)));K(e,{get icon(){return Ka},class:`cost-source-icon`,get title(){return I(n)}})}},s=O(()=>ZC(I(t)));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{K(e,{get icon(){return Ya},class:`cache-savings-icon`})},u=O(()=>ew(I(t)));V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(d,e=>{I(t).costs_calculation_caveat&&e(f)}),T(n),F((e,t)=>{W(n,`title`,e),B(i,t)},[()=>nw(I(t),sw(I(t))),()=>oc(I(t).total_cost)]),z(e,n)};V(me,e=>{I(n)||e(he)}),T(i),F((e,n,r,c,l,d,p,h,g,_,b,x,S)=>{a=U(i,1,`svelte-hg4ill`,null,a,e),W(o,`title`,n),B(s,r),B(u,c),B(f,I(t).model),B(m,I(t).user_path||`-`),B(v,l),W(y,`title`,d),W(w,`title`,p),B(ee,h),W(te,`title`,g),B(ne,_),W(re,`title`,b),W(ie,`title`,x),B(ae,S)},[()=>({"usage-log-row-cached":ew(I(t))}),()=>pc(I(t).timestamp),()=>us.formatTimestamp(I(t).timestamp),()=>hc(I(t))||`-`,()=>tw(I(t)),()=>ow(I(t)),()=>I(n)?ac(I(t).input_tokens)+` tokens`:``,()=>I(n)?oc(I(t).input_cost):ac(I(t).input_tokens),()=>I(n)?ac(I(t).output_tokens)+` tokens`:``,()=>I(n)?oc(I(t).output_cost):ac(I(t).output_tokens),()=>I(n)?nw(I(t),``):``,()=>I(n)?nw(I(t),ac(I(t).total_tokens)+` tokens -`+sw(I(t))):``,()=>I(n)?oc(I(t).total_cost):ac(I(t).total_tokens)]),z(e,i)}),T(_),T(i),T(t),F(()=>{B(u,I(n)?`Input Cost`:`Input`),B(f,I(n)?`Output Cost`:`Output`),B(m,I(n)?`Total Cost`:`Total`)}),z(e,t)},p=e=>{var t=sT();xS(M(t),{size:20,label:`Loading request log`}),T(t),z(e,t)},m=e=>{var t=cT();wS(M(t),{}),T(t),z(e,t)};V(d,e=>{_w.usageLog.entries.length>0?e(f):_w.usageLogLoading?e(p,1):e(m,-1)}),Jw(P(d,2),{get total(){return _w.usageLog.total},get offset(){return _w.usageLog.offset},get limit(){return _w.usageLog.limit},onprev:()=>_w.usageLogPrevPage(),onnext:()=>_w.usageLogNextPage()}),T(a),L(`change`,u,()=>_w.fetchUsageLog(!0)),fa(u,()=>_w.usageLogHideCached,e=>_w.usageLogHideCached=e),z(e,a),D()}Hr([`click`,`change`]);var dT=R(`
            `);function fT(e,t){E(t,!0);let n=`usage`;An(()=>{q.refreshTick,qo.page===n&&(_w.fetchUsagePage(),jC.ensureLiveLogs())}),An(()=>{qo.page===n&&(_w.usageMode=qo.sub===`costs`?`costs`:`tokens`)});var r=dT(),i=P(M(r),2),a=M(i);Ny(a,{ariaLabel:`Usage mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return _w.usageMode},onchange:e=>_w.toggleUsageMode(e)}),el(P(a,2),{onchange:()=>_w.fetchUsagePage()}),T(i);var o=P(i,2);ww(o,{});var s=P(o,2);Aw(s,{});var c=P(s,2),l=M(c);Kw(l,{kind:`model`});var u=P(l,2);Kw(u,{kind:`userPath`}),Kw(P(u,2),{kind:`label`}),T(c),uT(P(c,2),{}),T(r),z(e,r),D()}var pT=R(`
            `);function mT(e,t){let n=G(t,`label`,3,`Loading...`),r=G(t,`class`,3,``);var i=pT(),a=P(M(i),2),o=M(a,!0);T(a),T(i),F(()=>{U(i,1,Fi([`loading-state`,r()]),`svelte-hzxv1d`),B(o,n())}),z(e,i)}var hT=R(``);function gT(e,t){let n=G(t,`label`,3,``),r=G(t,`class`,3,``),i=G(t,`disabled`,3,!1);var a=hT();gi(M(a),()=>t.children??f),T(a),F(()=>{U(a,1,Fi([`table-action-btn`,r()])),W(a,`aria-label`,n()),W(a,`title`,n()),a.disabled=i()}),L(`click`,a,function(...e){t.onclick?.apply(this,e)}),z(e,a)}Hr([`click`]);async function _T(e,{label:t,errorFallback:n=`Unable to load ${t}.`,unavailableStatuses:r=[503],normalize:i=e=>Array.isArray(e)?e:[],options:a}){let o;try{o=await gs(e,{...a||{},label:t})}catch(e){return vs(e)||console.error(`Failed to fetch ${t}:`,e),{status:`error`,items:[],error:n,result:null}}return o.stale?{status:`stale`,items:[],error:``,result:o}:r.includes(o.status)?{status:`unavailable`,items:[],error:``,result:o}:o.ok?{status:`ok`,items:i(o.data),error:``,result:o}:{status:`error`,items:[],error:o.status===401?``:ds(o.data,n),result:o}}async function vT(e,t,n,{label:r,errorFallback:i=`Unable to ${r}.`,unavailableStatuses:a=[503],unavailableMessage:o=`This feature is unavailable on the gateway.`,options:s}){let c;try{c=await _s(e,t,n,{...s||{},label:r})}catch(e){return vs(e)||console.error(`Failed to ${r}:`,e),{status:`error`,error:i,result:null}}return c.stale?{status:`stale`,error:``,result:c}:a.includes(c.status)?{status:`unavailable`,error:o,result:c}:c.ok?{status:`ok`,error:``,result:c}:{status:`error`,error:c.status===401?`Authentication required.`:ds(c.data,i),result:c}}function yT(){return{scope:`user_path`,subject:`/`,period:`daily`,period_seconds:86400,amount:``,source:`manual`}}function bT(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},label:{label:`Label`,chip:`label`,fieldLabel:`Label`,placeholder:`Mobile-App-iOS`}};return t[e]||t.user_path}function xT(){return[`user_path`,`label`].map(e=>({value:e,label:bT(e).label}))}function ST(e){return String(e&&e.scope||``).trim()||`user_path`}function CT(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function wT(e){return bT(ST(e)).chip}function TT(e){return ST(e)===`label`?`budget-label`:`budget-user-path`}function ET(e){return bT(String(e&&e.scope||``)).fieldLabel}function DT(e){return bT(String(e&&e.scope||``)).placeholder}function OT(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function kT(){return[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`},{value:`custom`,label:`Custom seconds`}]}function AT(e){switch(String(e||``).trim().toLowerCase()){case`hourly`:return 3600;case`daily`:return 86400;case`weekly`:return 604800;case`monthly`:return 2592e3;default:return 0}}function jT(e){switch(Number(e||0)){case 3600:return`hourly`;case 86400:return`daily`;case 604800:return`weekly`;case 2592e3:return`monthly`;default:return`custom`}}function MT(e){return ST(e)+`:`+CT(e)+`:`+String(e&&e.period_seconds||``)}function NT(e,t){if(!t||!Array.isArray(e))return null;let n=MT(t);return e.find(e=>MT(e)===n)||null}function PT(e){let t=String(e||``).trim();if(!t)return`User path is required.`;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function FT(e){if(PT(e))return``;let t=String(e||``).trim(),n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function IT(e){return`/`+String(e||``).trimStart().replace(/^\/+/,``)}function LT(e){return Array.isArray(e)?e:e&&Array.isArray(e.budgets)?e.budgets:[]}function RT(e){let t=Number(e&&e.period_seconds||0);return[CT(e),wT(e),tE(e),jT(t),t?String(t)+`s`:``,t?String(t)+` seconds`:``].join(` `).toLowerCase()}var zT={user_path:0,label:1};function BT(e,t){let n=Array.isArray(e)?e.slice():[],r=String(t||`subject`);return n.sort((e,t)=>{let n=(zT[ST(e)]||0)-(zT[ST(t)]||0),i=CT(e).localeCompare(CT(t)),a=Number(t&&t.period_seconds||0)-Number(e&&e.period_seconds||0);return r===`period`?a||n||i:n||i||a}),n}function VT(e,t,n){let r=Array.isArray(e)?e:[],i=String(t||``).trim().toLowerCase();return BT(i?r.filter(e=>RT(e).includes(i)):r.slice(),n)}function HT(e){let t=e||{},n=ST(t),r=String(t.subject||``).trim();if(n===`user_path`){let e=PT(r);if(e)return{payload:null,error:e}}else if(!r)return{payload:null,error:`Label is required.`};let i=Number(t.amount);if(!Number.isFinite(i)||i<=0)return{payload:null,error:`Amount must be greater than 0.`};let a=String(t.period||``).trim(),o=AT(a);return a===`custom`&&(o=Number(t.period_seconds)),!Number.isFinite(o)||o<=0?{payload:null,error:`Period seconds must be greater than 0.`}:{payload:{scope:n,subject:n===`user_path`?FT(r):r,period_seconds:Math.trunc(o),amount:i,source:String(t.source||`manual`).trim()||`manual`},error:``}}function UT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds},amount:e.amount}}function WT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds}}}function GT(e){return{scope:ST(e),subject:CT(e),period_seconds:e.period_seconds}}function KT(e){return oc(e)}function qT(e,t){let n=e||{},r=t||{};return`A budget for "`+((CT(n)||CT(r))+` `+tE({period_seconds:n.period_seconds||r.period_seconds,period_label:r.period_label}))+`" already exists. Saving will override the current `+KT(r.amount)+` limit with `+KT(n.amount)+`.`}function JT(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:t}function YT(e,t){let n=JT(e);return Math.round((t?Math.min(n,1):n)*1e3)/10}function XT(e){return JT(e&&e.usage_ratio)}function ZT(e){return YT(XT(e),!0)}function QT(e){return YT(e&&e.period_ratio,!0)}function $T(e){return YT(XT(e),!1).toFixed(1).replace(/\.0$/,``)+`%`}function eE(e){return QT(e).toFixed(1).replace(/\.0$/,``)+`%`}function tE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`Hourly`;case 86400:return`Daily`;case 604800:return`Weekly`;case 2592e3:return`Monthly`;default:{let n=String(e&&e.period_label||``).trim();return n?`Custom `+n:`Custom `+String(t||``)+`s`}}}function nE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return`budget-period-label-hourly`;case 86400:return`budget-period-label-daily`;case 604800:return`budget-period-label-weekly`;case 2592e3:return`budget-period-label-monthly`;default:return`budget-period-label-custom`}}function rE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-fill-period-`)}function iE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-track-period-`)}function aE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return qa;case 86400:return Eo;case 604800:return Ia;case 2592e3:return La;default:return bo}}function oE(e){let t=Math.max(0,Math.trunc(Number(e||0)));return t+` `+(t===1?`second`:`seconds`)}function sE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`1 hour`;case 86400:return`1 day`;case 604800:return`1 week`;case 2592e3:return`1 month`;default:return oE(t)}}function cE(e){return String(e&&e.source||``).trim()||`manual`}function lE(e){let t=cE(e).toLowerCase();return t===`manual`?`Created from the dashboard.`:t===`config`?`Loaded from configuration.`:`Budget source: `+t}function uE(e){let t=Number(e&&e.remaining);return Number.isFinite(t)?t<0?oc(Math.abs(t))+` over`:oc(t)+` remaining`:``}var Y=new class{#e=k(j([]));get budgets(){return I(this.#e)}set budgets(e){A(this.#e,e,!0)}#t=k(!0);get budgetsAvailable(){return I(this.#t)}set budgetsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get filter(){return I(this.#r)}set filter(e){A(this.#r,e,!0)}#i=k(`subject`);get sortBy(){return I(this.#i)}set sortBy(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(!1);get formOpen(){return I(this.#o)}set formOpen(e){A(this.#o,e,!0)}#s=k(!1);get formSubmitting(){return I(this.#s)}set formSubmitting(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get editing(){return I(this.#l)}set editing(e){A(this.#l,e,!0)}#u=k(j(yT()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(!1);get overrideDialogOpen(){return I(this.#d)}set overrideDialogOpen(e){A(this.#d,e,!0)}#f=k(null);get overridePendingPayload(){return I(this.#f)}set overridePendingPayload(e){A(this.#f,e,!0)}#p=k(null);get overrideExistingBudget(){return I(this.#p)}set overrideExistingBudget(e){A(this.#p,e,!0)}#m=k(``);get resettingKey(){return I(this.#m)}set resettingKey(e){A(this.#m,e,!0)}#h=k(``);get deletingKey(){return I(this.#h)}set deletingKey(e){A(this.#h,e,!0)}#g=k(!1);get resetAllLoading(){return I(this.#g)}set resetAllLoading(e){A(this.#g,e,!0)}#_=null;managementEnabled(){return xs.budgetsVisible()}filteredBudgets(){return VT(this.budgets,this.filter,this.sortBy)}async fetchBudgetsPage(){if(await xs.ensureLoaded(),!this.managementEnabled()){this.budgets=[],this.budgetsAvailable=!1,this.error=``;return}return this.#_||=this.fetchBudgets().finally(()=>{this.#_=null}),this.#_}async fetchBudgets(){this.loading=!0,this.error=``;let e=await _T(`/admin/budgets`,{label:`budgets`,errorFallback:`Unable to load budgets.`,normalize:LT});if(this.loading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.budgetsAvailable=!1,this.budgets=[];return}if(!e.result){this.budgets=[],this.error=e.error;return}if(this.budgetsAvailable=!0,e.status===`error`){this.error=e.error;return}this.budgets=e.items}}openForm(e){if(this.editing=!!e,this.formError=``,e){let t=Number(e.period_seconds||0);this.form={scope:ST(e),subject:CT(e),period:jT(t),period_seconds:t,amount:String(e.amount||``),source:String(e.source||`manual`)}}else this.form=yT();this.formOpen=!0}syncPeriodSeconds(){let e=AT(String(this.form.period||``).trim());e>0&&(this.form.period_seconds=e)}setFormSubject(e){this.form.subject=this.form.scope===`label`?String(e??``):IT(e)}syncScope(){OT(this.form)}closeForm(){this.closeOverrideDialog(),this.formOpen=!1,this.formSubmitting=!1,this.formError=``,this.editing=!1,this.form=yT()}async submitForm(){if(this.formSubmitting)return;let{payload:e,error:t}=HT(this.form);if(!e){this.formError=t;return}if(!this.editing){let t=NT(this.budgets,e);if(t){this.openOverrideDialog(t,e);return}}await this.saveBudgetPayload(e)}async saveBudgetPayload(e){if(this.formSubmitting||!e)return;this.formSubmitting=!0,this.formError=``;let t=await vT(`/admin/budgets`,`PUT`,UT(e),{label:`save budget`,errorFallback:`Unable to save budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.formSubmitting=!1,t.status!==`stale`){if(t.status===`unavailable`){this.budgetsAvailable=!1,this.formError=t.error;return}if(t.status===`error`){this.formError=t.error;return}this.closeForm(),J.success(`Budget saved.`),this.fetchBudgets()}}openOverrideDialog(e,t){this.overrideExistingBudget=e||null,this.overridePendingPayload=t||null,this.overrideDialogOpen=!0}closeOverrideDialog(){this.overrideDialogOpen=!1,this.overridePendingPayload=null,this.overrideExistingBudget=null}async confirmOverride(){if(!this.overridePendingPayload){this.closeOverrideDialog();return}let e=this.overridePendingPayload;this.closeOverrideDialog(),await this.saveBudgetPayload(e)}async resetBudget(e){if(!e)return;let t=MT(e);if(this.resettingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Reset budget "`+n+`"?`))return;this.resettingKey=t;let r=await vT(`/admin/budgets/reset-one`,`POST`,GT(e),{label:`reset budget`,errorFallback:`Unable to reset budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.resettingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,J.error(r.error);return}if(r.status===`error`){J.error(r.error);return}J.success(`Budget reset.`),this.fetchBudgets()}}async deleteBudget(e){if(!e)return;let t=MT(e);if(this.deletingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Delete budget "`+n+`"? This cannot be undone.`))return;this.deletingKey=t;let r=await vT(`/admin/budgets`,`DELETE`,WT(e),{label:`delete budget`,errorFallback:`Unable to delete budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.deletingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,J.error(r.error);return}if(r.status===`error`){J.error(r.error);return}this.budgets=LT(r.result.data),J.success(`Budget deleted.`)}}openResetDialog(){Ls.open({title:`Reset Budgets`,titleId:`budgetResetDialogTitle`,inputId:`budget-reset-confirmation`,requiredText:`reset`,confirmLabel:`Reset All Budgets`,icon:ho,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.resetAllBudgets()})}async resetAllBudgets(){if(this.resetAllLoading)return;this.resetAllLoading=!0;let e=await vT(`/admin/budgets/reset`,`POST`,{confirmation:`reset`},{label:`reset budgets`,errorFallback:`Unable to reset budgets.`,unavailableStatuses:[]});if(this.resetAllLoading=!1,e.status!==`stale`){if(e.status!==`ok`){Ls.error=e.error;return}Ls.close(),J.success(`Budgets reset.`),qo.page===`budgets`&&this.fetchBudgets()}}},dE=R(` Edit`,1),fE=R(` `,1),pE=R(`
            Usage
            Period
            `),mE=R(`
            `);function hE(e,t){E(t,!0);let n=G(t,`budgets`,19,()=>[]);function r(e){if(!e)return``;let t=us.formatTimestamp(e);return!t||t===`-`?``:t+` `+us.effectiveTimeZoneLabel()}var i=mE();H(i,21,n,e=>MT(e),(e,t)=>{var n=pE(),i=M(n),a=M(i),o=M(a),s=M(o),c=e=>{K(e,{get icon(){return Do},class:`budget-scope-icon`})},l=O(()=>ST(I(t))===`label`);V(s,e=>{I(l)&&e(c)});var u=P(s);T(o);var d=P(o,2),f=M(d),p=M(f);{let e=O(()=>aE(I(t)));K(p,{get icon(){return I(e)},class:`budget-period-icon`})}var m=P(p,2),h=M(m,!0);T(m),T(f),T(d);var g=P(d,2),_=M(g),v=M(_),y=M(v,!0);T(v),T(_);var b=P(_,2),x=M(b);gT(x,{label:`Edit budget`,class:`budget-action-btn`,onclick:()=>Y.openForm(I(t)),children:(e,t)=>{var n=dE();K(N(n),{get icon(){return lo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}});var S=P(x,2);{let e=O(()=>Y.resettingKey===MT(I(t))?`Resetting budget`:`Reset budget`),n=O(()=>Y.resettingKey===MT(I(t)));gT(S,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>Y.resetBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);K(i,{get icon(){return ho},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.resettingKey===MT(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var C=P(S,2);{let e=O(()=>Y.deletingKey===MT(I(t))?`Deleting budget`:`Delete budget`),n=O(()=>Y.deletingKey===MT(I(t)));gT(C,{get label(){return I(e)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>Y.deleteBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);K(i,{get icon(){return ko},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.deletingKey===MT(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}T(b),T(g),T(a);var w=P(a,2),ee=M(w),te=M(ee),ne=P(M(te),2),re=M(ne,!0);T(ne),T(te);var ie=P(te,2),ae=M(ie);let oe;var se=P(ae,2),ce=M(se),le=M(ce,!0);T(ce);var ue=P(ce,2),de=M(ue,!0);T(ue),T(se);var fe=P(se,2),pe=M(fe),me=M(pe,!0);T(pe);var he=P(pe,2),ge=M(he,!0);T(he),T(fe),T(ie),T(ee);var _e=P(ee,2),ve=M(_e),ye=P(M(ve),2),be=M(ye,!0);T(ye),T(ve);var xe=P(ve,2),Se=M(xe),Ce=P(Se,2),we=M(Ce),Te=M(we,!0);T(we);var Ee=P(we,2),De=M(Ee,!0);T(Ee);var Oe=P(Ee,2),ke=M(Oe,!0);T(Oe),T(Ce);var Ae=P(Ce,2),je=M(Ae),Me=M(je,!0);T(je);var Ne=P(je,2),Pe=M(Ne,!0);T(Ne);var Fe=P(Ne,2),Ie=M(Fe,!0);T(Fe),T(Ae),T(xe),T(_e),T(w),T(i),T(n),F((e,t,n,r,i,a,s,c,l,d,p,m,g,_,b,x,S,C,w,ee,te,ne,se,ce,ue,fe,pe,he,_e,ve)=>{U(o,1,`budget-scope-value ${e??``}`,`svelte-1jm56wo`),Hi(o,t),W(o,`title`,n),B(u,` ${r??``}`),U(f,1,`budget-period-label ${i??``}`,`svelte-1jm56wo`),B(h,a),W(v,`title`,s),B(y,c),B(re,l),W(ie,`aria-valuenow`,d),W(ie,`aria-label`,p),Hi(ie,`--budget-progress: ${m??``}%`),oe=U(ae,1,`budget-bar-fill budget-bar-fill-usage`,null,oe,g),B(le,_),B(de,b),B(me,x),B(ge,S),B(be,C),U(xe,1,`budget-bar-track ${w??``}`,`svelte-1jm56wo`),W(xe,`aria-valuenow`,ee),Hi(xe,`--budget-progress: ${te??``}%`),U(Se,1,`budget-bar-fill budget-bar-fill-period ${ne??``}`,`svelte-1jm56wo`),W(we,`title`,se),B(Te,ce),B(De,ue),W(Oe,`title`,fe),B(ke,pe),B(Me,he),B(Pe,_e),B(Ie,ve)},[()=>TT(I(t)),()=>ST(I(t))===`label`?`--label-color: `+Vy(CT(I(t))):void 0,()=>wT(I(t))+`: `+CT(I(t)),()=>CT(I(t)),()=>nE(I(t)),()=>tE(I(t)),()=>lE(I(t)),()=>cE(I(t)),()=>$T(I(t)),()=>ZT(I(t)),()=>`Budget usage: `+oc(I(t).spent)+` of `+oc(I(t).amount)+`, `+uE(I(t)),()=>ZT(I(t)),()=>({"budget-bar-fill-danger":XT(I(t))>=1}),()=>oc(I(t).spent)+` of `+oc(I(t).amount),()=>uE(I(t)),()=>oc(I(t).spent)+` of `+oc(I(t).amount),()=>uE(I(t)),()=>eE(I(t)),()=>iE(I(t)),()=>QT(I(t)),()=>QT(I(t)),()=>rE(I(t)),()=>r(I(t).period_start),()=>us.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>r(I(t).period_end),()=>us.formatTimestamp(I(t).period_end),()=>us.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>us.formatTimestamp(I(t).period_end)]),z(e,n)}),T(i),z(e,i),D()}var gE=R(`

            `,1),_E=R(``),vE=R(``),yE=R(`
            `);function bE(e,t){E(t,!0);let n=G(t,`open`,3,!1),r=G(t,`title`,3,``),i=G(t,`ariaLabel`,3,``),a=G(t,`error`,3,``),o=G(t,`submitting`,3,!1),s=G(t,`submitDisabled`,3,!1),c=G(t,`submitLabel`,3,`Save`),l=G(t,`submittingLabel`,3,`Saving...`),u=G(t,`submitIcon`,3,go),d=G(t,`cancel`,3,!0),p=G(t,`dialogClass`,3,``),m=G(t,`novalidate`,3,!1),h=G(t,`canClose`,3,()=>!0);function g(){q.dialogOpen||h()()&&t.onclose?.()}Ms(e,{get open(){return n()},variant:`editor`,onclose:g,children:(e,n)=>{var h=yE(),g=M(h),_=M(g),v=M(_),y=M(v),b=e=>{var n=Qr();gi(N(n),()=>t.header),z(e,n)},x=e=>{var n=gE(),i=N(n),a=M(i,!0);T(i);var o=P(i,2),s=e=>{var n=Qr();gi(N(n),()=>t.headerHint),z(e,n)};V(o,e=>{t.headerHint&&e(s)}),F(()=>B(a,r())),z(e,n)};V(y,e=>{t.header?e(b):e(x,-1)}),T(v);var S=P(v,2);{let e=O(()=>`Close `+(i()||r()).toLowerCase());Os(S,{get label(){return I(e)},onclick:()=>t.onclose?.()})}T(_);var C=P(_,2);gi(C,()=>t.children??f);var w=P(C,2),ee=e=>{var t=_E(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(w,e=>{a()&&e(ee)});var te=P(w,2),ne=M(te),re=e=>{var n=vE();L(`click`,n,()=>t.onclose?.()),z(e,n)};V(ne,e=>{d()&&e(re)});var ie=P(ne,2),ae=e=>{var n=Qr();gi(N(n),()=>t.extraActions),z(e,n)};V(ie,e=>{t.extraActions&&e(ae)});var oe=P(ie,2),se=M(oe);K(se,{get icon(){return u()},class:`form-action-icon`});var ce=P(se,2),le=M(ce,!0);T(ce),T(oe),T(te),T(g),T(h),F(()=>{U(h,1,Fi([`model-editor`,p()])),W(h,`aria-label`,i()||r()),g.noValidate=m(),oe.disabled=o()||s(),B(le,o()?l():c())}),Vr(`submit`,g,e=>{e.preventDefault(),t.onsubmit?.()}),z(e,h)},$$slots:{default:!0}}),D()}Hr([`click`]);var xE=R(`
            `);function SE(e,t){let n=G(t,`label`,3,``);var r=xE(),i=M(r),a=M(i,!0);T(i),gi(P(i,2),()=>t.children??f),T(r),F(()=>{W(i,`for`,t.id),B(a,n())}),z(e,r)}var CE=R(``),wE=R(``),TE=R(``),EE=R(``),DE=R(``),OE=R(``),kE=R(`

            Editing a budget updates its limit only. Use Reset to start a new - budget period.

            `),AE=R(`
            `,1),jE=R(``),ME=R(` `,1);function NE(e,t){E(t,!0);function n(e){Y.setFormSubject(e.target.value),e.target.value=Y.form.subject}var r=ME(),i=N(r);{let e=O(()=>Y.editing?`Edit Budget`:`Create Budget`);bE(i,{get open(){return Y.formOpen},get title(){return I(e)},ariaLabel:`Budget editor`,get error(){return Y.formError},get submitting(){return Y.formSubmitting},submitLabel:`Save Budget`,dialogClass:`budget-editor`,canClose:()=>!Y.overrideDialogOpen,onclose:()=>Y.closeForm(),onsubmit:()=>Y.submitForm(),children:(e,t)=>{var r=AE(),i=N(r),a=M(i);SE(a,{id:`budget-scope`,label:`Scope`,children:(e,t)=>{var n=wE();H(n,21,xT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncScope()),Gi(n,()=>Y.form.scope,e=>Y.form.scope=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);{let e=O(()=>ET(Y.form));SE(o,{id:`budget-subject`,get label(){return I(e)},children:(e,t)=>{var r=TE();na(r),F(e=>{W(r,`placeholder`,e),ra(r,Y.form.subject),r.disabled=Y.editing,W(r,`data-modal-autofocus`,!Y.editing||void 0)},[()=>DT(Y.form)]),L(`input`,r,n),z(e,r)},$$slots:{default:!0}})}var s=P(o,2);SE(s,{id:`budget-period`,label:`Period`,children:(e,t)=>{var n=EE();H(n,21,kT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncPeriodSeconds()),Gi(n,()=>Y.form.period,e=>Y.form.period=e),z(e,n)},$$slots:{default:!0}});var c=P(s,2),l=e=>{SE(e,{id:`budget-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=DE();na(n),F(()=>n.disabled=Y.editing),da(n,()=>Y.form.period_seconds,e=>Y.form.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(c,e=>{Y.form.period===`custom`&&e(l)}),SE(P(c,2),{id:`budget-amount`,label:`Amount`,children:(e,t)=>{var n=OE();na(n),F(()=>W(n,`data-modal-autofocus`,Y.editing||void 0)),da(n,()=>Y.form.amount,e=>Y.form.amount=e),z(e,n)},$$slots:{default:!0}}),T(i);var u=P(i,2),d=e=>{z(e,kE())};V(u,e=>{Y.editing&&e(d)}),z(e,r)},$$slots:{default:!0}})}Ms(P(i,2),{get open(){return Y.overrideDialogOpen},variant:`auth`,onclose:()=>Y.closeOverrideDialog(),children:(e,t)=>{var n=jE(),r=M(n);Os(P(M(r),2),{label:`Close budget override dialog`,onclick:()=>Y.closeOverrideDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=P(c,2),u=M(l);K(u,{get icon(){return go},class:`form-action-icon`});var d=P(u,2),f=M(d,!0);T(d),T(l),T(s),T(i),T(n),F(e=>{B(o,e),l.disabled=Y.formSubmitting,B(f,Y.formSubmitting?`Saving...`:`Override Budget`)},[()=>qT(Y.overridePendingPayload,Y.overrideExistingBudget)]),Vr(`submit`,i,e=>{e.preventDefault(),Y.confirmOverride()}),L(`click`,c,()=>Y.closeOverrideDialog()),z(e,n)},$$slots:{default:!0}}),z(e,r),D()}Hr([`change`,`input`,`click`]);var PE=R(`

            Budgets

            `),FE=R(``),IE=R(`
            Budget management is unavailable.
            `),LE=R(``),RE=R(`
            `),zE=R(`

            No budgets configured yet.

            `),BE=R(`

            No budgets match your filter.

            `),VE=R(`
            `);function HE(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`budgets`&&Y.fetchBudgetsPage()});let n=O(()=>Y.filteredBudgets());var r=VE(),i=M(r),a=M(i);KS(M(a),{copyId:`budgets-help-copy`,label:`budgets help`,title:e=>{z(e,PE())},help:e=>{Ue(),z(e,Zr(`Budgets are evaluated from tracked usage cost records for each user - path subtree. Enforcement runs only when Budget is enabled for the - active workflow.`))},$$slots:{title:!0,help:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=FE();K(M(t),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Y.formSubmitting),L(`click`,t,()=>Y.openForm()),z(e,t)},l=O(()=>Y.managementEnabled()&&Y.budgetsAvailable&&!q.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Pc(u,{});var d=P(u,2),f=e=>{z(e,IE())},p=O(()=>(!Y.managementEnabled()||!Y.budgetsAvailable)&&!q.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=LE(),n=M(t,!0);T(t),F(()=>B(n,Y.error)),z(e,t)};V(m,e=>{Y.error&&!q.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading budgets...`})};V(g,e=>{Y.loading&&!q.authError&&e(_)});var v=P(g,2),y=e=>{var t=RE(),n=M(t);yw(M(n),{id:`budget-filter`,placeholder:`Filter by user path, label, or period...`,label:`Filter budgets by user path or period`,get value(){return Y.filter},set value(e){Y.filter=e}}),T(n);var r=P(n,2),i=P(M(r),2),a=M(i);a.value=a.__value=`subject`;var o=P(a);o.value=o.__value=`period`,T(i),T(r),T(t),Gi(i,()=>Y.sortBy,e=>Y.sortBy=e),z(e,t)};V(v,e=>{(Y.budgets.length>0||Y.filter)&&Y.budgetsAvailable&&!q.authError&&!Y.formOpen&&e(y)});var b=P(v,2);NE(b,{});var x=P(b,2),S=e=>{hE(e,{get budgets(){return I(n)}})};V(x,e=>{I(n).length>0&&Y.budgetsAvailable&&!q.authError&&e(S)});var C=P(x,2),w=e=>{z(e,zE())},ee=O(()=>Y.budgets.length===0&&!Y.filter&&!Y.loading&&!q.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,BE())},re=O(()=>Y.budgets.length>0&&I(n).length===0&&Y.filter&&!Y.loading&&!q.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function UE(){return{scope:`user_path`,subject:`/`,period:`minute`,period_seconds:60,max_requests:``,max_tokens:``,source:`manual`}}function WE(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},provider:{label:`Provider`,chip:`provider`,fieldLabel:`Provider Name`,placeholder:`openai`},model:{label:`Model`,chip:`model`,fieldLabel:`Model`,placeholder:`openai/gpt-4o`}};return t[e]||t.user_path}function GE(){return[`user_path`,`provider`,`model`].map(e=>({value:e,label:WE(e).label}))}function KE(e){return String(e&&e.scope||``).trim()||`user_path`}function qE(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function JE(e){return WE(KE(e)).chip}function YE(e){return WE(String(e&&e.scope||``)).fieldLabel}function XE(e){return WE(String(e&&e.scope||``)).placeholder}function ZE(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function QE(){return[{value:`minute`,label:`Per minute`},{value:`hour`,label:`Per hour`},{value:`day`,label:`Per day`},{value:`concurrent`,label:`Concurrent (in-flight)`},{value:`custom`,label:`Custom seconds`}]}function $E(e){switch(String(e||``).trim().toLowerCase()){case`minute`:return 60;case`hour`:return 3600;case`day`:return 86400;case`concurrent`:return 0;default:return-1}}function eD(e){switch(Number(e||0)){case 60:return`minute`;case 3600:return`hour`;case 86400:return`day`;case 0:return`concurrent`;default:return`custom`}}function tD(e){let t=String(e&&e.period||``).trim(),n=$E(t);n>=0&&(e.period_seconds=n),t===`concurrent`&&(e.max_tokens=``)}function nD(e){return KE(e)+`:`+qE(e)+`:`+String(e&&e.period_seconds||`0`)}function rD(e){return Number(e&&e.period_seconds||0)===0}function iD(e){return String(e&&e.period_label||``).trim()||eD(Number(e&&e.period_seconds||0))}function aD(e){return String(e&&e.source||``)===`config`?`config`:`manual`}function oD(e){return String(e&&e.source||``)===`config`}function sD(e){let t=Number(e);return Number.isFinite(t)?t.toLocaleString():`0`}function cD(e,t){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return 0;let i=Math.round(n/r*100);return Math.min(Math.max(i,0),100)}function lD(e,t){let n=String(t||``).trim().toLowerCase(),r=Array.isArray(e)?e.slice():[],i={user_path:0,provider:1,model:2};return r.sort((e,t)=>{let n=(i[KE(e)]||0)-(i[KE(t)]||0);if(n!==0)return n;let r=qE(e).localeCompare(qE(t));return r===0?Number(e.period_seconds||0)-Number(t.period_seconds||0):r}),n?r.filter(e=>{let t=qE(e).toLowerCase(),r=JE(e).toLowerCase(),i=iD(e).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)}):r}function uD(e){return!e||!Array.isArray(e.rate_limits)?[]:e.rate_limits}function dD(e,t,n){let r=String(t||``).trim();return r=e===`provider`||e===`model`?r.toLowerCase():`/`+r.split(`/`).map(e=>e.trim()).filter(Boolean).join(`/`),e+`:`+r+`:`+Number(n||0)}function fD(e,t){return e?dD(t.scope,t.subject,t.limit_key.period_seconds)!==dD(e.scope,e.subject,e.period_seconds):!1}function pD(e){let t=e||{},n=String(t.scope||`user_path`),r=String(t.subject||``).trim();if(n!==`user_path`&&!r)return{error:YE(t)+` is required.`};let i=String(t.period||``)===`concurrent`,a=t.period_seconds;if(a===``||a==null)return{error:`Period seconds is required.`};let o=Number(a);if(!Number.isInteger(o)||o<0||o===0&&!i)return{error:`Period seconds must be a positive integer (0 only for the concurrent period).`};let s=String(t.max_requests===void 0||t.max_requests===null?``:t.max_requests).trim(),c=String(t.max_tokens===void 0||t.max_tokens===null?``:t.max_tokens).trim();if(!s&&!c)return{error:`Set max requests, max tokens, or both.`};if(i&&c)return{error:`Token limits are not valid for the concurrent period.`};let l={scope:n,subject:r||`/`,limit_key:{period_seconds:o}};if(s){let e=Number(s);if(!Number.isInteger(e)||e<=0)return{error:`Max requests must be a positive integer.`};l.max_requests=e}if(c){let e=Number(c);if(!Number.isInteger(e)||e<=0)return{error:`Max tokens must be a positive integer.`};l.max_tokens=e}return{payload:l}}function mD(e,t,n){if(KE(e)!==`model`)return!1;let r=String(qE(e)).toLowerCase(),i=String(n||``).trim().toLowerCase();if(!i)return!1;if(r===i)return!0;let a=String(t||``).trim().toLowerCase();return a?r===a+`/`+i||i.startsWith(a+`/`)&&r===i.slice(a.length+1):!1}function hD(e,t){return KE(e)===`provider`&&String(qE(e)).toLowerCase()===String(t||``).trim().toLowerCase()}function gD(e){let t=e||{},n=String(t.model||``),r=String(t.provider||``);return!r||n.toLowerCase().startsWith(r+`/`)?n:r+`/`+n}function _D(e,t){let n=e||{},r=Array.isArray(t)?t:[],i=[];return n.kind===`model`&&i.push({key:`model`,title:`Model limits`,scope:`model`,subject:gD(n),hint:``,items:r.filter(e=>mD(e,n.provider,n.model))}),i.push({key:`provider`,title:`Provider limits (`+n.provider+`)`,scope:`provider`,subject:n.provider,hint:n.kind===`model`?`Shared by every model routed to this provider.`:``,items:r.filter(e=>hD(e,n.provider))}),i.push({key:`global`,title:`Global limits`,scope:`user_path`,subject:`/`,hint:`Root user-path rules throttle all traffic. Narrower user-path rules also apply, per consumer.`,items:r.filter(e=>KE(e)===`user_path`&&qE(e)===`/`)}),i}function vD(e){return rD(e)?cD(e.in_flight,e.max_requests):Math.max(cD(e.requests_used,e.max_requests),cD(e.tokens_used,e.max_tokens))}function yD(e){return`--rate-limit-pressure: `+vD(e)+`%`}function bD(e){let t=vD(e);return t>=100?`rate-limit-pressure-row rate-limit-pressure-full`:t>=75?`rate-limit-pressure-row rate-limit-pressure-high`:`rate-limit-pressure-row`}function xD(e){return(Array.isArray(e)?e:[]).some(e=>KE(e)===`user_path`&&qE(e)===`/`)}function SD(e,t,n){let r=Array.isArray(e)?e:[];return r.some(e=>mD(e,t,n))?`table-action-btn-active`:r.some(e=>hD(e,t))||xD(r)?`rate-limit-gauge-inherited`:``}function CD(e,t){let n=Array.isArray(e)?e:[];return n.some(e=>hD(e,t))?`table-action-btn-active`:xD(n)?`rate-limit-gauge-inherited`:``}function wD(e,t){let n=`Rate limits for `+e;return t===`table-action-btn-active`?n+` (direct limits configured)`:t?n+` (inherited limits apply)`:n}function TD(e){if(rD(e))return sD(e.in_flight)+` of `+sD(e.max_requests)+` in flight`;let t=[];return e.max_requests!==null&&e.max_requests!==void 0&&t.push(sD(e.requests_used)+`/`+sD(e.max_requests)+` req`),e.max_tokens!==null&&e.max_tokens!==void 0&&t.push(sD(e.tokens_used)+`/`+sD(e.max_tokens)+` tok`),t.join(` · `)}var X=new class{#e=k(j([]));get rateLimits(){return I(this.#e)}set rateLimits(e){A(this.#e,e,!0)}#t=k(!0);get rateLimitsAvailable(){return I(this.#t)}set rateLimitsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get rateLimitsLoading(){return I(this.#n)}set rateLimitsLoading(e){A(this.#n,e,!0)}rateLimitFetchPromise=null;#r=k(``);get rateLimitFilter(){return I(this.#r)}set rateLimitFilter(e){A(this.#r,e,!0)}#i=k(``);get rateLimitError(){return I(this.#i)}set rateLimitError(e){A(this.#i,e,!0)}#a=k(!1);get rateLimitFormOpen(){return I(this.#a)}set rateLimitFormOpen(e){A(this.#a,e,!0)}#o=k(!1);get rateLimitFormSubmitting(){return I(this.#o)}set rateLimitFormSubmitting(e){A(this.#o,e,!0)}#s=k(``);get rateLimitFormError(){return I(this.#s)}set rateLimitFormError(e){A(this.#s,e,!0)}#c=k(!1);get rateLimitEditing(){return I(this.#c)}set rateLimitEditing(e){A(this.#c,e,!0)}rateLimitEditingOriginal=null;rateLimitFormReturnToInspector=!1;#l=k(``);get rateLimitResettingKey(){return I(this.#l)}set rateLimitResettingKey(e){A(this.#l,e,!0)}#u=k(``);get rateLimitDeletingKey(){return I(this.#u)}set rateLimitDeletingKey(e){A(this.#u,e,!0)}#d=k(!1);get rateLimitInspectorOpen(){return I(this.#d)}set rateLimitInspectorOpen(e){A(this.#d,e,!0)}#f=k(j({kind:``,provider:``,model:``,title:``}));get rateLimitInspector(){return I(this.#f)}set rateLimitInspector(e){A(this.#f,e,!0)}#p=k(j(UE()));get rateLimitForm(){return I(this.#p)}set rateLimitForm(e){A(this.#p,e,!0)}rateLimitsEnabled(){return xs.rateLimitsVisible()}defaultRateLimitForm(){return UE()}rateLimitScopeMeta(e){return WE(e)}rateLimitScopeOptions(){return GE()}rateLimitScope(e){return KE(e)}rateLimitSubject(e){return qE(e)}rateLimitScopeLabel(e){return JE(e)}rateLimitSubjectFieldLabel(){return YE(this.rateLimitForm)}rateLimitSubjectPlaceholder(){return XE(this.rateLimitForm)}syncRateLimitScope(){ZE(this.rateLimitForm)}rateLimitPeriodOptions(){return QE()}rateLimitPeriodSeconds(e){return $E(e)}rateLimitPeriodFromSeconds(e){return eD(e)}syncRateLimitPeriodSeconds(){tD(this.rateLimitForm)}rateLimitKey(e){return nD(e)}rateLimitIsConcurrent(e){return rD(e)}rateLimitPeriodLabel(e){return iD(e)}rateLimitSourceLabel(e){return aD(e)}rateLimitIsReadOnly(e){return oD(e)}formatRateLimitNumber(e){return sD(e)}rateLimitUsagePercent(e,t){return cD(e,t)}filteredRateLimits(){return lD(this.rateLimits,this.rateLimitFilter)}normalizeRateLimitListPayload(e){return uD(e)}async fetchRateLimitsPage(){if(await xs.ensureLoaded(),!this.rateLimitsEnabled()){this.rateLimits=[],this.rateLimitsAvailable=!1,this.rateLimitError=``;return}return this.rateLimitFetchPromise||=this.fetchRateLimits().finally(()=>{this.rateLimitFetchPromise=null}),this.rateLimitFetchPromise}async fetchRateLimits(){this.rateLimitsLoading=!0,this.rateLimitError=``;let e=await _T(`/admin/rate-limits`,{label:`rate limits`,errorFallback:`Unable to load rate limits.`,normalize:uD});if(this.rateLimitsLoading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.rateLimitsAvailable=!1,this.rateLimits=[];return}if(!e.result){this.rateLimits=[],this.rateLimitError=e.error;return}if(this.rateLimitsAvailable=!0,e.status===`error`){this.rateLimitError=e.error;return}this.rateLimits=e.items}}openRateLimitForm(e){if(this.rateLimitEditing=!!e,this.rateLimitFormError=``,e){let t=Number(e.period_seconds||0);this.rateLimitEditingOriginal={scope:KE(e),subject:qE(e),period_seconds:t},this.rateLimitForm={scope:KE(e),subject:qE(e),period:eD(t),period_seconds:t,max_requests:e.max_requests===null||e.max_requests===void 0?``:String(e.max_requests),max_tokens:e.max_tokens===null||e.max_tokens===void 0?``:String(e.max_tokens),source:String(e.source||`manual`)}}else this.rateLimitEditingOriginal=null,this.rateLimitForm=UE();this.rateLimitFormOpen=!0}closeRateLimitForm(){this.rateLimitFormOpen=!1,this.rateLimitFormSubmitting=!1,this.rateLimitFormError=``,this.rateLimitEditing=!1,this.rateLimitEditingOriginal=null,this.rateLimitForm=UE(),this.rateLimitFormReturnToInspector&&(this.rateLimitFormReturnToInspector=!1,this.rateLimitInspectorOpen=!0)}rateLimitNormalizedIdentity(e,t,n){return dD(e,t,n)}rateLimitIdentityMoved(e){return fD(this.rateLimitEditingOriginal,e)}setRateLimitFormSubject(e){this.rateLimitForm.subject=String(e||``)}rateLimitFormPayload(){return pD(this.rateLimitForm)}async submitRateLimitForm(){if(this.rateLimitFormSubmitting)return;let{payload:e,error:t}=this.rateLimitFormPayload();if(t){this.rateLimitFormError=t;return}let n=this.rateLimitIdentityMoved(e),r=this.rateLimitEditingOriginal;this.rateLimitFormSubmitting=!0,this.rateLimitFormError=``;try{let t=await vT(`/admin/rate-limits`,`PUT`,e,{label:`save rate limit`,errorFallback:`Unable to save rate limit.`,unavailableStatuses:[]});if(t.status===`stale`)return;if(t.status!==`ok`){this.rateLimitFormError=t.error;return}if(this.rateLimits=uD(t.result.data),n&&!await this.deleteMovedRateLimitOriginal(r))return;this.closeRateLimitForm(),J.success(n?`Rate limit moved; live counters restarted.`:`Rate limit saved.`)}finally{this.rateLimitFormSubmitting=!1}}async deleteMovedRateLimitOriginal(e){let t=await vT(`/admin/rate-limits`,`DELETE`,{scope:e.scope,subject:e.subject,limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`remove the moved rate limit`,errorFallback:`The new rule was saved, but the previous one could not be removed. Delete it manually.`,unavailableStatuses:[]});return t.status===`stale`?!1:t.status===`ok`?(this.rateLimits=uD(t.result.data),!0):(this.rateLimitFormError=t.error,!1)}async deleteRateLimit(e){let t=nD(e);if(this.rateLimitDeletingKey===t)return;this.rateLimitDeletingKey=t;let n=await vT(`/admin/rate-limits`,`DELETE`,{scope:KE(e),subject:qE(e),limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`delete rate limit`,errorFallback:`Unable to delete rate limit.`,unavailableStatuses:[]});if(this.rateLimitDeletingKey=``,n.status!==`stale`){if(n.status!==`ok`){J.error(n.error);return}this.rateLimits=uD(n.result.data),J.success(`Rate limit deleted.`)}}async resetRateLimit(e){let t=nD(e);if(this.rateLimitResettingKey===t)return;this.rateLimitResettingKey=t;let n=await vT(`/admin/rate-limits/reset-one`,`POST`,{scope:KE(e),subject:qE(e),period_seconds:Number(e.period_seconds||0)},{label:`reset rate limit`,errorFallback:`Unable to reset rate limit.`,unavailableStatuses:[]});if(this.rateLimitResettingKey=``,n.status!==`stale`){if(n.status!==`ok`){J.error(n.error);return}this.rateLimits=uD(n.result.data),J.success(`Rate limit counters reset.`)}}rateLimitInspectorModelID(e){return String(e&&e.model&&e.model.id||``).trim()}openRateLimitInspectorForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`model`,provider:n,model:t,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}openRateLimitInspectorForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`provider`,provider:t,model:``,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}showRateLimitInspector(){this.rateLimitInspectorOpen=!0,this.fetchRateLimitsPage()}closeRateLimitInspector(){this.rateLimitInspectorOpen=!1}rateLimitRuleMatchesModel(e,t,n){return mD(e,t,n)}rateLimitRuleMatchesProvider(e,t){return hD(e,t)}rateLimitInspectorQualifiedModel(){return gD(this.rateLimitInspector)}rateLimitInspectorSections(){return _D(this.rateLimitInspector,this.rateLimits)}rateLimitPressurePercent(e){return vD(e)}rateLimitPressureStyle(e){return yD(e)}rateLimitPressureClass(e){return bD(e)}rateLimitGaugeCache={rules:null,states:{}};rateLimitGaugeMemo(e,t){this.rateLimitGaugeCache.rules!==this.rateLimits&&(this.rateLimitGaugeCache={rules:this.rateLimits,states:{}});let n=this.rateLimitGaugeCache.states;return e in n||(n[e]=t()),n[e]}rateLimitGaugeClassForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase(),r=this.rateLimits;return this.rateLimitGaugeMemo(`model:`+n+`/`+t,()=>SD(r,n,t))}rateLimitGaugeClassForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase(),n=this.rateLimits;return this.rateLimitGaugeMemo(`provider:`+t,()=>CD(n,t))}hasGlobalRateLimits(){let e=this.rateLimits;return this.rateLimitGaugeMemo(`global`,()=>xD(e))}rateLimitGaugeTitle(e,t){return wD(e,t)}rateLimitInspectorSummary(e){return TD(e)}openRateLimitFormFromInspector(e,t,n){this.rateLimitInspectorOpen=!1,this.rateLimitFormReturnToInspector=!0,this.openRateLimitForm(n||void 0),n||(this.rateLimitForm.scope=e,this.rateLimitForm.subject=t)}},ED=R(``),DD=R(``),OD=R(``),kD=R(``),AD=R(``),jD=R(``),MD=R(``),ND=R(`

            Scope, subject, and period identify the rule: changing any of them - moves the rule to a new key and restarts its live counters.

            `),PD=R(`

            A user path rule limits the whole subtree; provider and model rules cap - all traffic routed there and make load balancing skip the target while - it is saturated. One shared counter per rule. Leave a field empty to - skip that limit. Token limits require usage tracking.

            `,1);function FD(e,t){E(t,!0);{let t=O(()=>X.rateLimitEditing?`Edit Rate Limit`:`Create Rate Limit`);bE(e,{get open(){return X.rateLimitFormOpen},get title(){return I(t)},ariaLabel:`Rate limit editor`,get error(){return X.rateLimitFormError},get submitting(){return X.rateLimitFormSubmitting},submitLabel:`Save Rate Limit`,dialogClass:`budget-editor`,novalidate:!0,onclose:()=>X.closeRateLimitForm(),onsubmit:()=>X.submitRateLimitForm(),children:(e,t)=>{var n=PD(),r=N(n),i=M(r);SE(i,{id:`rate-limit-scope`,label:`Scope`,children:(e,t)=>{var n=DD();H(n,21,()=>X.rateLimitScopeOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitScope()),Gi(n,()=>X.rateLimitForm.scope,e=>X.rateLimitForm.scope=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);{let e=O(()=>X.rateLimitSubjectFieldLabel());SE(a,{id:`rate-limit-subject`,get label(){return I(e)},children:(e,t)=>{var n=OD();na(n),F(e=>{W(n,`placeholder`,e),W(n,`data-modal-autofocus`,!X.rateLimitEditing||void 0),ra(n,X.rateLimitForm.subject)},[()=>X.rateLimitSubjectPlaceholder()]),L(`input`,n,e=>X.setRateLimitFormSubject(e.currentTarget.value)),z(e,n)},$$slots:{default:!0}})}var o=P(a,2);SE(o,{id:`rate-limit-period`,label:`Period`,children:(e,t)=>{var n=kD();H(n,21,()=>X.rateLimitPeriodOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitPeriodSeconds()),Gi(n,()=>X.rateLimitForm.period,e=>X.rateLimitForm.period=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=e=>{SE(e,{id:`rate-limit-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=AD();na(n),da(n,()=>X.rateLimitForm.period_seconds,e=>X.rateLimitForm.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(s,e=>{X.rateLimitForm.period===`custom`&&e(c)});var l=P(s,2);{let e=O(()=>X.rateLimitForm.period===`concurrent`?`Max In-Flight Requests`:`Max Requests`);SE(l,{id:`rate-limit-max-requests`,get label(){return I(e)},children:(e,t)=>{var n=jD();na(n),F(()=>W(n,`data-modal-autofocus`,X.rateLimitEditing?!0:void 0)),da(n,()=>X.rateLimitForm.max_requests,e=>X.rateLimitForm.max_requests=e),z(e,n)},$$slots:{default:!0}})}var u=P(l,2),d=e=>{SE(e,{id:`rate-limit-max-tokens`,label:`Max Tokens`,children:(e,t)=>{var n=MD();na(n),da(n,()=>X.rateLimitForm.max_tokens,e=>X.rateLimitForm.max_tokens=e),z(e,n)},$$slots:{default:!0}})};V(u,e=>{X.rateLimitForm.period!==`concurrent`&&e(d)}),T(r);var f=P(r,4),p=e=>{z(e,ND())};V(f,e=>{X.rateLimitEditing&&e(p)}),z(e,n)},$$slots:{default:!0}})}D()}Hr([`change`,`input`]);var ID=R(` `),LD=R(` Edit`,1),RD=R(` `,1),zD=R(`
            In-flight
            `),BD=R(`
            Requests
            `),VD=R(`
            Tokens
            `),HD=R(`
            `),UD=R(`
            `);function WD(e,t){E(t,!0);var n=UD();H(n,21,()=>t.rules,e=>X.rateLimitKey(e),(e,t)=>{var n=HD(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=e=>{var n=ID(),r=M(n);{let e=O(()=>X.rateLimitScope(I(t))===`provider`?yo:Pa);K(r,{get icon(){return I(e)},class:`budget-period-icon`})}var i=P(r,2),a=M(i,!0);T(i),T(n),F((e,t)=>{W(n,`title`,e),B(a,t)},[()=>`Rule scope: `+X.rateLimitScopeLabel(I(t)),()=>X.rateLimitScopeLabel(I(t))]),z(e,n)},u=O(()=>X.rateLimitScope(I(t))!==`user_path`);V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=M(d);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?ja:Oo);K(f,{get icon(){return I(e)},class:`budget-period-icon`})}var p=P(f,2),m=M(p,!0);T(p),T(d),T(s);var h=P(s,2),g=M(h),_=M(g),v=M(_,!0);T(_),T(g);var y=P(g,2),b=M(y),x=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitForm(I(t)),children:(e,t)=>{var n=LD();K(N(n),{get icon(){return lo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},S=O(()=>!X.rateLimitIsReadOnly(I(t)));V(b,e=>{I(S)&&e(x)});var C=P(b,2);{let e=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting counters`:`Reset counters`),n=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t)));gT(C,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>X.resetRateLimit(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=RD(),i=N(r);K(i,{get icon(){return ho},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var w=P(C,2),ee=e=>{{let n=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting rate limit`:`Delete rate limit`),r=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>X.deleteRateLimit(I(t)),get disabled(){return I(r)},children:(e,n)=>{var r=RD(),i=N(r);K(i,{get icon(){return ko},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}},te=O(()=>!X.rateLimitIsReadOnly(I(t)));V(w,e=>{I(te)&&e(ee)}),T(y),T(h),T(i);var ne=P(i,2),re=M(ne),ie=e=>{var n=zD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u),T(l),T(o),T(n),F((e,t,n,r,i,l)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l)},[()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests),()=>`In-flight requests: `+X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` in flight`]),z(e,n)},ae=O(()=>X.rateLimitIsConcurrent(I(t)));V(re,e=>{I(ae)&&e(ie)});var oe=P(re,2),se=e=>{var n=BD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests),()=>`Requests used: `+X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` requests`,()=>X.formatRateLimitNumber(I(t).requests_remaining)+` left`]),z(e,n)},ce=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_requests);V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{var n=VD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens),()=>`Tokens used: `+X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)>=100}),()=>X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens)+` tokens`,()=>X.formatRateLimitNumber(I(t).tokens_remaining)+` left`]),z(e,n)},de=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_tokens);V(le,e=>{I(de)&&e(ue)}),T(ne),T(r),T(n),F((e,t,n,r,i)=>{W(a,`title`,e),B(o,t),B(m,n),W(_,`title`,r),B(v,i)},[()=>X.rateLimitScopeLabel(I(t))+`: `+X.rateLimitSubject(I(t)),()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n),D()}var GD=R(`

            Rate Limits

            `),KD=R(``),qD=R(`
            Rate limit management is unavailable.
            `),JD=R(``),YD=R(`
            `),XD=R(`

            No rate limits configured yet.

            `),ZD=R(`

            No rate limits match your filter.

            `),QD=R(`
            `);function $D(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`rate-limits`&&X.fetchRateLimitsPage()});let n=O(()=>X.filteredRateLimits());var r=QD(),i=M(r),a=M(i);KS(M(a),{copyId:`rate-limits-help-copy`,label:`rate limits help`,text:`Rate limits cap requests, tokens, and in-flight concurrency for a user path subtree, a provider, or a model. Consumer (user path) breaches return 429 with Retry-After and x-ratelimit-* headers; saturated providers and models are skipped by load balancing and failover while capacity exists elsewhere. Counters are per gateway instance and reset on restart; token limits need usage tracking.`,title:e=>{z(e,GD())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=KD();K(M(t),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=X.rateLimitFormSubmitting),L(`click`,t,()=>X.openRateLimitForm()),z(e,t)},l=O(()=>X.rateLimitsEnabled()&&X.rateLimitsAvailable&&!q.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Pc(u,{});var d=P(u,2),f=e=>{z(e,qD())},p=O(()=>(!X.rateLimitsEnabled()||!X.rateLimitsAvailable)&&!q.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=JD(),n=M(t,!0);T(t),F(()=>B(n,X.rateLimitError)),z(e,t)};V(m,e=>{X.rateLimitError&&!q.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading rate limits...`})};V(g,e=>{X.rateLimitsLoading&&!q.authError&&e(_)});var v=P(g,2),y=e=>{var t=YD(),n=M(t);yw(M(n),{id:`rate-limit-filter`,placeholder:`Filter by subject, scope, or period...`,label:`Filter rate limits by subject, scope, or period`,get value(){return X.rateLimitFilter},set value(e){X.rateLimitFilter=e}}),T(n),T(t),z(e,t)};V(v,e=>{(X.rateLimits.length>0||X.rateLimitFilter)&&X.rateLimitsAvailable&&!q.authError&&!X.rateLimitFormOpen&&e(y)});var b=P(v,2);FD(b,{});var x=P(b,2),S=e=>{WD(e,{get rules(){return I(n)}})};V(x,e=>{I(n).length>0&&X.rateLimitsAvailable&&!q.authError&&e(S)});var C=P(x,2),w=e=>{z(e,XD())},ee=O(()=>X.rateLimits.length===0&&!X.rateLimitFilter&&!X.rateLimitsLoading&&!q.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,ZD())},re=O(()=>X.rateLimits.length>0&&I(n).length===0&&X.rateLimitFilter&&!X.rateLimitsLoading&&!q.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function eO(e){return String(e||``).trim().toLowerCase()}function tO(e){if(!e)return``;let t=String(e.selector||``).trim();if(t)return t;if(!e.model||!e.model.id)return``;let n=String(e.model.id||``).trim(),r=String(e.provider_name||``).trim();if(r)return r+`/`+n;let i=String(e.provider_type||``).trim();return!i||n.includes(`/`)?n:i+`/`+n}function nO(e,t,n,r){let i=new Set,a=String(e||``).trim().toLowerCase(),o=String(t||``).trim().toLowerCase(),s=String(n||``).trim().toLowerCase(),c=String(r||``).trim().toLowerCase();if(c&&i.add(c),!a)return i;i.add(a),s&&i.add(s+`/`+a),o&&!a.includes(`/`)&&i.add(o+`/`+a);let l=a.split(`/`);return l.length===2&&l[1]&&i.add(l[1]),i}function rO(e){return nO(e&&e.model?e.model.id:``,e?e.provider_type:``,e?e.provider_name:``,e?e.selector:``)}function iO(e){let t=new Set,n=String(e.resolved_model||``).trim().toLowerCase(),r=String(e.target_model||``).trim().toLowerCase(),i=String(e.target_provider||``).trim().toLowerCase();if(n){t.add(n);let e=n.split(`/`);e.length===2&&e[1]&&t.add(e[1])}if(r){t.add(r);let e=r.split(`/`);e.length===2&&e[1]&&t.add(e[1])}return r&&i&&t.add(i+`/`+r),t}function aO(e){if(!e)return``;let t=String(e.provider||``).trim(),n=String(e.model||``).trim();return!t||!n||n===t||n.startsWith(t+`/`)?n:t+`/`+n}function oO(e){if(e===``||e==null)return null;let t=Number(e);return!Number.isFinite(t)||t<=0?null:t}function sO(e,t){let n={model:e},r=oO(t);return r!==null&&(n.weight=r),n}function cO(e){let t=Array.isArray(e)?e:[],n=[];for(let e of t){let t=String(e&&e.model||``).trim();t&&n.push(sO(t,e&&e.weight))}return n}function lO(e){switch(String(e||``).toLowerCase()){case`cost`:return`lowest cost`;case`round_robin`:case``:return`round robin`;default:return e}}var uO={round_robin:`Round-robin (rotate across targets; honors weights)`,cost:`Lowest cost (cheapest target per request)`,adaptive:`Adaptive (target chosen by the registered routing extension)`};function dO(e,t){let n=Array.isArray(e)?[...e]:[],r=String(t||``).trim().toLowerCase();return r&&!n.includes(r)&&n.push(r),n.map(e=>({value:e,label:uO[e]||e}))}function fO(e){let t=Array.isArray(e.targets)?e.targets:[],n=t.length>0?t[0]:{},r=t.map(e=>{let t={provider:e.provider||``,model:e.model||``};return e.weight&&(t.weight=e.weight),t});return{name:e.source,target_provider:n.provider||``,target_model:n.model||``,targets:r,strategy:e.strategy||``,session_affinity:e.session_affinity!==!1,description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,valid:!!e.valid,resolved_model:e.resolved_model||``,provider_type:e.provider_type||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[]}}function pO(e){let t=Array.isArray(e)?e:[],n=[],r=[];for(let e of t)!e||typeof e!=`object`||(e.kind===`redirect`?n.push(fO(e)):e.kind===`policy`&&r.push({selector:e.source,provider_name:e.provider_name||``,model:e.model||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[],description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,scope_kind:e.scope_kind||``}));return{aliases:n,policies:r}}function mO(e){if(!e)return`—`;let t=Array.isArray(e.targets)?e.targets:[];return t.length>1?t.length+` targets · `+lO(e.strategy):e.resolved_model?e.resolved_model:e.target_provider?e.target_provider+`/`+e.target_model:e.target_model||`—`}function hO(e){return e?e.enabled===!1?`is-disabled`:e.valid?`is-valid`:`is-invalid`:`is-invalid`}function gO(e){return e?e.enabled===!1?`Disabled`:e.valid?`Active`:`Invalid`:`Invalid`}function _O(e){return Array.isArray(e)&&e.length>0&&e.indexOf(`/`)===-1}function vO(e,t){return!t||!e?``:e.effective_enabled===!1?`is-disabled`:_O(e.user_paths)?`is-restricted`:`is-enabled`}function yO(e){if(!e)return``;let t=[];e.effective_enabled===!1&&t.push(e.default_enabled===!1?`Disabled by default`:`Disabled`);let n=Array.isArray(e.user_paths)?e.user_paths:[];return n.length>0&&t.push(`Allowed for `+n.join(`, `)),t.join(` · `)}function bO({models:e,aliases:t,virtualModelsAvailable:n,activeCategory:r}){let i=Array.isArray(e)?e:[],a=Array.isArray(t)?t:[],o=new Map;if(n)for(let e of a){let t=eO(e&&e.name);!t||e.enabled===!1||!e.valid||o.set(t,e)}let s=new Map,c=i.map(e=>{let t=tO(e),n=null;for(let t of rO(e))s.has(t)||s.set(t,e),!n&&o.has(t)&&(n=o.get(t));let r=e&&e.access?e.access:null;return{key:`model:`+t,display_name:t,secondary_name:``,provider_name:e.provider_name||``,provider_type:e.provider_type||``,model:e.model,selector:e.selector||``,is_alias:!1,alias:null,access:r,masking_alias:n,has_virtual_model:!!(n||r&&r.override),alias_state_class:``,alias_state_text:``}});if(!n)return c;for(let e of a){let t=s.get(eO(e&&e.name));if(e&&e.enabled!==!1&&e.valid&&t)continue;let n=null;for(let t of iO(e))if(n=s.get(t)||null,n)break;!n&&r&&r!==`all`||c.push({key:`alias:`+e.name,display_name:e.name,secondary_name:mO(e),provider_name:n&&n.provider_name||``,provider_type:n?n.provider_type||e.provider_type||``:e.provider_type||``,model:n?n.model:{id:e.name,object:`model`},selector:``,is_alias:!0,alias:e,access:null,masking_alias:null,source_model_exists:!!t,has_virtual_model:!0,alias_state_class:hO(e),alias_state_text:gO(e)})}return c.sort((e,t)=>e.is_alias===t.is_alias?String(e.display_name||``).localeCompare(String(t.display_name||``)):e.is_alias?-1:1)}function xO(e,t){if(!t)return e;let n=String(t).toLowerCase();return e.filter(e=>[e.display_name,e.secondary_name,e.provider_name,e.provider_type,e.model&&e.model.owned_by,e.alias&&e.alias.description,e.alias&&e.alias_state_text,e.model&&e.model.metadata&&e.model.metadata.modes?e.model.metadata.modes.join(`,`):``,e.model&&e.model.metadata&&e.model.metadata.categories?e.model.metadata.categories.join(`,`):``].some(e=>String(e||``).toLowerCase().includes(n)))}function SO(e,t){return String(e||``).trim()||String(t||``).trim()||`Unassigned`}function CO(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!r||r===n?``:r}function wO(e){let t=String(e||``).trim();return t?t+`/`:``}function TO(e){let t=Array.isArray(e)?e:[],n=t.filter(e=>e&&!e.is_alias).length,r=t.filter(e=>e&&e.is_alias).length,i=[];return n>0&&i.push(n+(n===1?` model`:` models`)),r>0&&i.push(r+(r===1?` alias`:` aliases`)),i.join(` · `)}function EO(e,t,n){let r=String(t||``).trim(),i=String(n||``).trim();for(let t of Array.isArray(e)?e:[]){let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim();if(!(r&&e!==r)&&!(!r&&i&&n!==i)&&t&&t.access)return t.access.default_enabled!==!1}return!0}function DO(e){for(let t of Array.isArray(e)?e:[])if(t&&t.access)return t.access.default_enabled!==!1;return!0}function OO(e,t){let n=String(t||``).trim();if(!n)return null;for(let t of Array.isArray(e)?e:[])if(String(t&&t.selector||``).trim()===n)return t;return null}function kO(e,t,n,r){let i=wO(t),a=r&&r.get(`/`)||null,o=i&&r&&r.get(i)||null,s=EO(e,t,n),c=o||a,l=c&&Array.isArray(c.user_paths)?Array.from(new Set(c.user_paths)).sort():[];return{selector:i,default_enabled:s,effective_enabled:c?c.enabled!==!1:s,user_paths:l,override:o}}function AO(e,t,n){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let e of Array.isArray(n)?n:[]){let t=String(e&&e.selector||``).trim();t&&r.set(t,e)}let i=[],a=new Map;for(let t of e){if(t&&t.is_alias){i.push(t);continue}let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim(),r=`provider-group:`+(e||n||`unassigned`);a.has(r)||a.set(r,{key:r,provider_name:e,provider_type:n,display_name:SO(e,n),type_label:CO(e,n),rows:[]});let o=a.get(r);!o.provider_name&&e&&(o.provider_name=e),!o.provider_type&&n&&(o.provider_type=n),o.display_name=SO(o.provider_name,o.provider_type),o.type_label=CO(o.provider_name,o.provider_type),o.rows.push(t)}let o=Array.from(a.values()).map(e=>{let n=kO(t,e.provider_name,e.provider_type,r);return{...e,access:n,access_summary:yO(n),item_count_label:TO(e.rows)}}).sort((e,t)=>String(e.display_name||``).localeCompare(String(t.display_name||``)));return i.length>0&&o.unshift({key:`virtual-model-group`,is_virtual_models:!0,provider_name:``,provider_type:``,display_name:`Virtual models`,type_label:``,rows:i,access:{selector:``},access_summary:``,item_count_label:TO(i)}),o}function jO(e,t){let n=OO(t,`/`),r=DO(e),i=n&&Array.isArray(n.user_paths)?n.user_paths:[];return{key:`scope-global`,is_alias:!1,display_name:`all providers and models`,access:{selector:`/`,default_enabled:r,effective_enabled:n?n.enabled!==!1:r,user_paths:i,override:n}}}function MO(e){return e?String(e.access&&e.access.selector||``).trim()||String(e.override_selector||``).trim()||tO(e):``}function NO(e){if(!e)return[];let t=[];return e.is_alias?t.push(`alias-row`,hO(e.alias)):e.has_virtual_model&&t.push(`alias-row`,`is-valid`),!e.is_alias&&e.masking_alias&&t.push(`masked-model-row`),!e.is_alias&&e.access&&e.access.effective_enabled===!1&&t.push(`model-access-disabled-row`),t}function PO(e){return!!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)}function FO(e){return!!(e&&!e.is_alias&&e.masking_alias&&e.masking_alias.name&&!e.masking_alias.managed)}function IO(e){return e&&e.is_alias&&e.alias&&e.alias.name?`alias-row-`+String(e.alias.name).replace(/[^a-zA-Z0-9_-]+/g,`-`):``}function LO(e){return e?e.is_alias?!!(e.alias&&e.alias.managed):!!(e.access&&e.access.override&&e.access.override.managed||e.masking_alias&&e.masking_alias.managed):!1}function RO(e){return!!(e&&e.override)}function zO(e){return e?`table-action-btn-active`:``}function BO(e,t){let n=`Edit `+String(e||`model access`);return t?n+` (virtual model exists)`:n}function VO(){return{source:``,target_model:``,target_weight:1,targets:[],strategy:`round_robin`,session_affinity:!0,user_paths:``,description:``,enabled:!0}}function HO(e){return String(e&&e.target_model||``).trim()!==``}function UO(e){return String(e&&e.target_model||``).trim()?!0:cO(e&&e.targets).length>0}function WO(e){return!!e&&Array.isArray(e.targets)&&e.targets.length>0}function GO(e){return WO(e)&&String(e&&e.strategy||``).toLowerCase()!==`cost`}function KO(e){let t=Array.isArray(e.targets)?e.targets:[];if(t.length>0){let n=t.shift();e.target_model=n.model||``,e.target_weight=n.weight||1;return}e.target_model=``,e.target_weight=1}function qO(e){let t=Array.isArray(e&&e.targets)?e.targets:[];return t.length>0?{primaryModel:aO(t[0]),primaryWeight:t[0].weight||1,extraTargets:t.slice(1).map(e=>({model:aO(e),weight:e.weight||1}))}:{primaryModel:e&&e.target_provider?e.target_provider+`/`+e.target_model:e&&e.target_model||``,primaryWeight:1,extraTargets:[]}}function JO(e){return String(e||``).split(/\r?\n|,/).map(e=>String(e||``).trim()).filter(Boolean)}function YO(e,t,n){let r=String(e&&e.source||``).trim(),i=String(e&&e.target_model||``).trim(),a=cO(e&&e.targets),o=UO(e),s=String(t||``).trim(),c=n===`edit`&&!!s&&r!==s,l={source:r,user_paths:JO(e&&e.user_paths),description:String(e&&e.description||``).trim(),enabled:!!(e&&e.enabled)};if(c&&(l.old_source=s),o){let t=[];if(i&&t.push(sO(i,e.target_weight)),t.push(...a),t.length>1){let n=e.strategy||`round_robin`;l.targets=n===`cost`?t.map(e=>({model:e.model})):t,l.strategy=n,e&&e.session_affinity===!1&&(l.session_affinity=!1)}else l.target_model=t[0].model}return{payload:l,source:r,isRedirect:o,isRename:c}}function XO(e){let t={source:e.name,description:String(e.description||``).trim(),user_paths:Array.isArray(e.user_paths)?e.user_paths:[],enabled:e.enabled===!1},n=Array.isArray(e.targets)?e.targets:[];return n.length>1?(t.strategy=e.strategy||`round_robin`,e.session_affinity===!1&&(t.session_affinity=!1),t.targets=t.strategy===`cost`?n.map(e=>({model:aO(e)})):n.map(e=>sO(aO(e),e.weight))):n.length===1?t.target_model=aO(n[0]):t.target_model=e.target_provider?e.target_provider+`/`+e.target_model:e.target_model,t}function ZO(e,t,n){let r=n||{},i=r.effective_enabled===!1,a=t&&Array.isArray(t.user_paths)?t.user_paths:[],o=`PUT`,s;return i===!1?s={source:e,enabled:!1,user_paths:a}:t&&a.length===0&&r.default_enabled!==!1?(o=`DELETE`,s={source:e}):s={source:e,enabled:!0,user_paths:a},{method:o,payload:s,desired:i}}function QO(e,t,n){let r=Math.max(1,Number(t||75)),i=Math.min(n,e+r);return{limit:i,rendering:ibO({models:Mc.models,aliases:this.aliases,virtualModelsAvailable:this.virtualModelsAvailable,activeCategory:Mc.activeCategory}));get displayModels(){return I(this.#T)}set displayModels(e){A(this.#T,e)}#E=O(()=>AO(this.displayModels,Mc.models,this.modelOverrideViews));get displayModelGroups(){return I(this.#E)}set displayModelGroups(e){A(this.#E,e)}#D=O(()=>xO(this.displayModels,Mc.filter));get filteredDisplayModels(){return I(this.#D)}set filteredDisplayModels(e){A(this.#D,e)}#O=O(()=>{let e=this.filteredDisplayModels,t=Math.max(0,Math.min(Number(this.modelRenderLimit||0),e.length));return!Mc.filter&&t>=this.displayModels.length?this.displayModelGroups:AO(e.slice(0,t),Mc.models,this.modelOverrideViews)});get filteredDisplayModelGroups(){return I(this.#O)}set filteredDisplayModelGroups(e){A(this.#O,e)}#k=O(()=>jO(Mc.models,this.modelOverrideViews));get globalScopeRow(){return I(this.#k)}set globalScopeRow(e){A(this.#k,e)}modelsBusy(){return!!(Mc.loading||this.modelsRendering)}modelLoadingText(){if(Mc.loading)return this.displayModels.length>0?`Refreshing models...`:`Loading models...`;let e=this.filteredDisplayModels.length;return`Rendering models... `+Math.min(Number(this.modelRenderLimit||0),e)+` / `+e}restartModelRendering(e){let t=++this.#a,n=$O(this.modelRenderBatchSize,e);this.modelRenderLimit=n.limit,this.modelsRendering=n.rendering,n.rendering&&this.#A(t)}stopModelRendering(){this.#a++,this.modelsRendering=!1}#A(e){let t=()=>{if(e!==this.#a)return;let t=QO(this.modelRenderLimit,this.modelRenderBatchSize,this.filteredDisplayModels.length);this.modelRenderLimit=t.limit,this.modelsRendering=t.rendering,t.rendering&&this.#A(e)};typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>setTimeout(t,0)):setTimeout(t,0)}async fetchVirtualModels(){this.aliasLoading=!0,this.aliasError=``;try{let e=await gs(`/admin/virtual-models`,{label:`virtual models`});if(e.status===503){this.virtualModelsAvailable=!1,this.aliases=[],this.modelOverrideViews=[];return}if(e.stale)return;if(this.virtualModelsAvailable=!0,!e.ok){this.aliases=[],this.modelOverrideViews=[];return}let{aliases:t,policies:n}=pO(e.data);this.aliases=t,this.modelOverrideViews=n}catch(e){console.error(`Failed to fetch virtual models:`,e),this.aliases=[],this.modelOverrideViews=[],this.aliasError=`Unable to load virtual models.`}finally{this.aliasLoading=!1}}qualifiedModelName(e){return tO(e)}findModelOverrideView(e){return OO(this.modelOverrideViews,e)}hasGlobalModelOverride(){return!!this.findModelOverrideView(`/`)}findExistingAliasByName(e){let t=eO(e);if(!t)return null;for(let e of this.aliases)if(eO(e&&e.name)===t)return e;return null}findConcreteModelByName(e){let t=eO(e);if(!t)return null;for(let e of Mc.models)if(rO(e).has(t))return e;return null}rowToggleEnabled(e){return e?e.is_alias?e.alias&&e.alias.enabled!==!1:!!(e.access&&e.access.effective_enabled!==!1):!1}rowToggleLabel(e){return this.rowTogglingKey&&this.rowTogglingKey===e.key?`Updating...`:this.rowToggleRestricted(e)?`Restricted`:this.rowToggleEnabled(e)?`Enabled`:`Disabled`}rowToggleRestricted(e){return!!e&&!e.is_alias&&vO(e.access,this.virtualModelsAvailable)===`is-restricted`}rowToggleAriaLabel(e){if(!e)return``;let t=this.rowToggleEnabled(e)?`Disable `:`Enable `,n;return n=e.is_alias?`alias `+String(e.alias&&e.alias.name||``):String(e.display_name||e.access&&e.access.selector||`model`),t+n.trim()}async toggleRowEnabled(e){if(this.virtualModelsAvailable&&!(!e||this.rowTogglingKey===e.key)){if(LO(e)){J.success(`This virtual model is managed by configuration and is read-only.`);return}if(e.is_alias){await this.toggleAliasRow(e);return}await this.toggleModelRow(e)}}async toggleAliasRow(e){let t=e.alias;if(!t||!t.name)return;this.rowTogglingKey=e.key;let n=XO(t);try{let e=await _s(`/admin/virtual-models`,`PUT`,n,{label:`alias state`});if(e.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(e.stale)return;if(!e.ok){J.error(e.status===401?`Authentication required.`:fs(e,`Failed to update alias state.`));return}J.success(n.enabled?`Alias enabled.`:`Alias disabled.`),this.fetchVirtualModels()}catch(e){console.error(`Failed to toggle alias state:`,e),J.error(`Failed to update alias state.`)}finally{this.rowTogglingKey=``}}async toggleModelRow(e){let t=MO(e);if(!t)return;let{method:n,payload:r,desired:i}=ZO(t,this.findModelOverrideView(t),e.access||{});this.rowTogglingKey=e.key;try{let e=await _s(`/admin/virtual-models`,n,r,{label:`model access`});if(e.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(!(n===`DELETE`&&e.status===404)){if(e.stale)return;if(!e.ok){J.error(e.status===401?`Authentication required.`:fs(e,`Failed to update model access.`));return}}J.success(i?`Model enabled.`:`Model disabled.`),Promise.all([Mc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to toggle model access:`,e),J.error(`Failed to update model access.`)}finally{this.rowTogglingKey=``}}async removeAliasRow(e){if(!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)||this.rowDeletingKey)return;let t=String(e.alias.name||``).trim();t&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the virtual model alias "`+t+`"?`,method:`DELETE`,payload:{source:t},operation:`virtual model`,failureMessage:`Failed to remove virtual model.`,notice:`Virtual model removed.`,ignoreNotFound:!0})}async removeRedirectRow(e){let t=e&&e.masking_alias;if(!(e&&!e.is_alias&&t&&t.name&&!t.managed)||this.rowDeletingKey)return;let n=String(t.name||``).trim();n&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the redirect for "`+n+`"? Other virtual model settings will be preserved.`,method:`PUT`,payload:{source:n,user_paths:Array.isArray(t.user_paths)?t.user_paths:[],description:String(t.description||``).trim(),enabled:t.enabled!==!1},operation:`virtual model redirect`,failureMessage:`Failed to remove redirect.`,notice:`Redirect removed. Other virtual model settings were preserved.`})}async mutateVirtualModelRow(e){if(!this.rowDeletingKey&&window.confirm(e.confirmMessage)){this.rowDeletingKey=e.rowKey;try{let t=await _s(`/admin/virtual-models`,e.method,e.payload,{label:e.operation});if(t.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(!(e.ignoreNotFound&&t.status===404)){if(t.stale)return;if(!t.ok){J.error(t.status===401?`Authentication required.`:fs(t,e.failureMessage));return}}this.virtualModelsAvailable=!0,J.success(e.notice),Promise.all([Mc.fetchModels(),this.fetchVirtualModels()])}catch(t){console.error(e.failureMessage,t),J.error(e.failureMessage)}finally{this.rowDeletingKey=``}}}addVmTarget(){Array.isArray(this.vmForm.targets)||(this.vmForm.targets=[]),this.vmForm.targets.push({model:``,weight:1})}removeVmTarget(e){Array.isArray(this.vmForm.targets)&&this.vmForm.targets.splice(e,1)}removePrimaryTarget(){KO(this.vmForm)}vmFormHasPrimaryTarget(){return HO(this.vmForm)}vmFormShowStrategy(){return WO(this.vmForm)}vmStrategyOptions(){return dO(xs.virtualModelStrategies(),this.vmForm.strategy)}vmFormShowWeights(){return GO(this.vmForm)}vmFormToggleRestricted(){return!!(this.vmForm&&this.vmForm.enabled)&&_O(JO(this.vmForm.user_paths))}vmFormToggleLabel(){return!this.vmForm||!this.vmForm.enabled?`Disabled`:this.vmFormToggleRestricted()?`Restricted`:`Enabled`}resetVirtualModelForm(){this.vmFormError=``,this.vmFormHelpOpen=!1,this.vmFormUserPathsHelpOpen=!1,this.vmSubmitting=!1,this.vmDeleting=!1,this.vmFormHasExisting=!1,this.vmFormDefaultEnabled=!0,this.vmFormEffectiveEnabled=!0,this.vmFormDisplayName=``,this.vmFormSourceLocked=!1,this.vmFormOriginalSource=``,this.vmFormManaged=!1,this.vmForm=VO()}closeVirtualModelForm(){this.vmFormOpen=!1,this.resetVirtualModelForm()}openVirtualModelCreate(e){this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`create`,this.vmFormSourceLocked=!1,this.vmFormDisplayName=`New virtual model`,e&&e.model&&e.model.id&&(this.vmForm.target_model=tO(e))}openVirtualModelEditAlias(e){if(!e)return;this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!1,this.vmFormHasExisting=!0,this.vmFormManaged=!!e.managed,this.vmFormOriginalSource=e.name||``,this.vmFormDisplayName=e.name||``,this.vmFormDefaultEnabled=DO(Mc.models),this.vmFormEffectiveEnabled=e.enabled!==!1;let{primaryModel:t,primaryWeight:n,extraTargets:r}=qO(e);this.vmForm={source:e.name||``,target_model:t,target_weight:n,targets:r,strategy:e.strategy||`round_robin`,session_affinity:e.session_affinity!==!1,user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` -`),description:e.description||``,enabled:e.enabled!==!1}}openVirtualModelEditModel(e){if(!e||e.is_alias)return;let t=e.access||{},n=t.override||null,r=n&&Array.isArray(n.user_paths)?n.user_paths:Array.isArray(t.user_paths)?t.user_paths:[],i=MO(e);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!n,this.vmFormOriginalSource=i;let a=n?n.enabled!==!1:t.effective_enabled!==!1;this.vmFormDefaultEnabled=t.default_enabled!==!1,this.vmFormEffectiveEnabled=a,this.vmFormManaged=!!(n&&n.managed),this.vmFormDisplayName=e.access_display_name||e.display_name||i||``,this.vmForm={source:i,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:r.join(` -`),description:n&&n.description?n.description:``,enabled:a}}openGlobalModelOverrideEdit(){let e=this.findModelOverrideView(`/`),t=e&&Array.isArray(e.user_paths)?e.user_paths:[],n=DO(Mc.models);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!e,this.vmFormOriginalSource=`/`,this.vmFormDefaultEnabled=n,this.vmFormEffectiveEnabled=e?e.enabled!==!1:n,this.vmFormManaged=!!(e&&e.managed),this.vmFormDisplayName=`All providers and models`,this.vmForm={source:`/`,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:t.join(` -`),description:e&&e.description?e.description:``,enabled:e?e.enabled!==!1:n}}openProviderOverrideEdit(e){!e||!e.access||!e.access.selector||this.openVirtualModelEditModel({display_name:e.display_name,access_display_name:`All models in `+e.display_name,provider_name:e.provider_name,provider_type:e.provider_type,access:e.access,override_selector:e.access.selector,is_alias:!1})}async submitVirtualModelForm(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be edited here.`;return}let{payload:e,source:t,isRedirect:n,isRename:r}=YO(this.vmForm,this.vmFormOriginalSource,this.vmFormMode);if(!t){this.vmFormError=`Source is required.`;return}if(this.vmFormError=``,this.vmFormMode!==`edit`){let e=this.findExistingAliasByName(t),r=e?null:this.findModelOverrideView(t);if(e||r){let n=e?`A virtual model named "`+e.name+`" already exists. Saving will update that virtual model. Continue?`:`An access policy for "`+t+`" already exists. Saving will update that virtual model. Continue?`;if(!window.confirm(n)){this.vmFormError=`Choose a different source or edit the existing virtual model.`;return}}else if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Creating this alias will mask that model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}else if(r){let e=(this.aliases||[]).find(e=>e&&e.name===t)||null,r=e?null:this.findModelOverrideView(t);if(e||r){this.vmFormError=`A virtual model for "`+t+`" already exists. Choose a different source.`;return}if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Renaming to that name will mask the model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}this.vmSubmitting=!0;try{let t=await _s(`/admin/virtual-models`,`PUT`,e,{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:fs(t,`Failed to save virtual model.`);return}let r=!n&&t.status===204;this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),J.success(n?`Alias saved.`:r?`Model access reset to inherited/default.`:`Model access saved.`),Promise.all([Mc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to save virtual model:`,e),this.vmFormError=`Failed to save virtual model.`}finally{this.vmSubmitting=!1}}async deleteVirtualModel(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be removed here.`;return}let e=String(this.vmForm.source||this.vmFormOriginalSource||``).trim();if(!(!e||!this.vmFormHasExisting)&&window.confirm(`Remove the virtual model for "`+e+`"? This reverts to inherited/default behavior.`)){this.vmDeleting=!0,this.vmFormError=``;try{let t=await _s(`/admin/virtual-models`,`DELETE`,{source:e},{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:fs(t,`Failed to remove virtual model.`);return}}this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),J.success(`Virtual model removed.`),Promise.all([Mc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to delete virtual model:`,e),this.vmFormError=`Failed to remove virtual model.`}finally{this.vmDeleting=!1}}}},tk=[{value:`input_per_mtok`,label:`Input $/MTok`,group:`Tokens`},{value:`output_per_mtok`,label:`Output $/MTok`,group:`Tokens`},{value:`cached_input_per_mtok`,label:`Cached input $/MTok`,group:`Tokens`},{value:`cache_write_per_mtok`,label:`Cache write $/MTok`,group:`Tokens`},{value:`reasoning_output_per_mtok`,label:`Reasoning output $/MTok`,group:`Tokens`},{value:`batch_input_per_mtok`,label:`Batch input $/MTok`,group:`Batch`},{value:`batch_output_per_mtok`,label:`Batch output $/MTok`,group:`Batch`},{value:`audio_input_per_mtok`,label:`Audio input $/MTok`,group:`Audio`},{value:`audio_output_per_mtok`,label:`Audio output $/MTok`,group:`Audio`},{value:`per_image`,label:`$/Image`,group:`Image`},{value:`input_per_image`,label:`Input $/Image`,group:`Image`},{value:`per_second_input`,label:`Input $/Second`,group:`Audio/Video`},{value:`per_second_output`,label:`Output $/Second`,group:`Video`},{value:`per_character_input`,label:`$/Character`,group:`Audio`},{value:`per_page`,label:`$/Page`,group:`Utility`},{value:`per_request`,label:`$/Request`,group:`Utility`}];function nk(e){let t=tk.find(t=>t.value===e);return t?t.label:String(e||``).replace(/_/g,` `)}function rk(e){return e&&typeof e==`object`?JSON.parse(JSON.stringify(e)):{}}function ik(e,t){let n=rk(e),r=t&&t.pricing?t.pricing:t;if(!r||typeof r!=`object`)return n;for(let e of tk)r[e.value]!==null&&r[e.value]!==void 0&&(n[e.value]=Number(r[e.value]));return Array.isArray(r.tiers)&&r.tiers.length>0&&(n.tiers=rk(r.tiers)),n}function ak(e){switch(String(e||``).trim()){case`config_yaml`:return`config.yaml`;case`model_registry`:return`Model registry`;default:return e?String(e):`Unknown`}}function ok(e){let t=e&&e.pricing?e.pricing:{},n=e&&e.pricing_sources&&typeof e.pricing_sources==`object`?e.pricing_sources:{},r={};for(let e of tk)t[e.value]!==null&&t[e.value]!==void 0&&(r[e.value]=ak(n[e.value]||`model_registry`));return r}function sk(e){let t=String(e&&e.selector||``).trim();return t?`Dashboard/API override (`+t+`)`:`Dashboard/API override`}function ck(e){let t=String(e||``).trim();return t?t+`/`:``}function lk(e){return String(e&&e.model&&e.model.id||``).trim()}function uk(e){let t=String(e&&e.provider_name||``).trim(),n=lk(e);return t&&n?t+`/`+n:n}function dk(e){return lk(e)}function fk(e){let t=new Map;for(let n of Array.isArray(e)?e:[]){let e=String(n&&n.selector||``).trim();e&&t.set(e,n)}return t}function pk(e,t){let n=String(t||``).trim();return n&&fk(e).get(n)||null}function mk(e,t,n){let r=fk(e),i=uk(t),a=dk(t),o=ck(t&&t.provider_name),s=String(n||``).trim();for(let e of[i,a,o,`/`]){if(!e||e===s)continue;let t=r.get(e);if(t)return t}return null}function hk(e,t,n){let r=e&&e.model&&e.model.metadata?e.model.metadata:null,i=rk(r&&r.pricing),a=ok(r),o=mk(t,e,n),s=o&&o.pricing?o.pricing:null;if(s){let e=sk(o);for(let t of tk)s[t.value]!==null&&s[t.value]!==void 0&&(i[t.value]=Number(s[t.value]),a[t.value]=e);Array.isArray(s.tiers)&&s.tiers.length>0&&(i.tiers=rk(s.tiers),a.tiers=e)}return{pricing:i,sources:a}}function gk(e,t){let n=e&&e.pricing?e.pricing:{},r=[];for(let e of tk)n[e.value]!==null&&n[e.value]!==void 0&&r.push({id:t(),field:e.value,value:String(n[e.value])});return r}function _k(e,t){let n=new Set;for(let r of Array.isArray(e)?e:[]){if(t&&r.id===t)continue;let e=String(r.field||``).trim();e&&n.add(e)}return n}function vk(e,t){let n=_k(e,t&&t.id);return tk.filter(e=>e.value===(t&&t.field)||!n.has(e.value))}function yk(e,t){let n={},r=new Set;for(let t of Array.isArray(e)?e:[]){let e=String(t.field||``).trim();if(!e)return{error:`Choose a price type for every row.`};if(r.has(e))return{error:`Each price type can only be used once.`};r.add(e);let i=String(t.value||``).trim();if(i===``)return{error:`Enter a value for `+nk(e)+`.`};let a=Number(i);if(!Number.isFinite(a)||a<0)return{error:`Pricing values must be numbers greater than or equal to 0.`};n[e]=a}let i=Array.isArray(t)?t:[];return i.length>0&&(n.tiers=rk(i)),Object.keys(n).length===0?{error:`Add at least one pricing field before saving.`}:{pricing:n}}function bk(e,t,n){let r=e||{},i=t||{},a=n||{},o=ik(r,a);return tk.map(e=>{let t=a[e.value]!==null&&a[e.value]!==void 0,n=r[e.value]!==null&&r[e.value]!==void 0;return{field:e.value,label:e.label,value:o[e.value],source:t?`Form/API value`:n?i[e.value]||`Model registry`:`Unset`}}).filter(e=>e.source!==`Unset`||e.value!==void 0)}var xk=new class{#e=k(!0);get modelPricingOverridesAvailable(){return I(this.#e)}set modelPricingOverridesAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get modelPricingOverrideViews(){return I(this.#t)}set modelPricingOverrideViews(e){A(this.#t,e,!0)}#n=k(``);get modelPricingOverrideError(){return I(this.#n)}set modelPricingOverrideError(e){A(this.#n,e,!0)}#r=k(!1);get modelPricingOverrideFormOpen(){return I(this.#r)}set modelPricingOverrideFormOpen(e){A(this.#r,e,!0)}#i=k(!1);get modelPricingOverrideSubmitting(){return I(this.#i)}set modelPricingOverrideSubmitting(e){A(this.#i,e,!0)}#a=k(!1);get modelPricingOverrideFormHasExistingOverride(){return I(this.#a)}set modelPricingOverrideFormHasExistingOverride(e){A(this.#a,e,!0)}#o=k(``);get modelPricingOverrideFormDisplayName(){return I(this.#o)}set modelPricingOverrideFormDisplayName(e){A(this.#o,e,!0)}#s=k(``);get modelPricingOverrideFormScope(){return I(this.#s)}set modelPricingOverrideFormScope(e){A(this.#s,e,!0)}#c=k(j([]));get modelPricingOverrideFormScopeOptions(){return I(this.#c)}set modelPricingOverrideFormScopeOptions(e){A(this.#c,e,!0)}#l=k(null);get modelPricingOverrideFormRow(){return I(this.#l)}set modelPricingOverrideFormRow(e){A(this.#l,e,!0)}#u=k(null);get modelPricingOverrideFormBasePricing(){return I(this.#u)}set modelPricingOverrideFormBasePricing(e){A(this.#u,e,!0)}#d=k(null);get modelPricingOverrideFormBasePricingSources(){return I(this.#d)}set modelPricingOverrideFormBasePricingSources(e){A(this.#d,e,!0)}#f=k(j([]));get modelPricingOverrideFormPreservedTiers(){return I(this.#f)}set modelPricingOverrideFormPreservedTiers(e){A(this.#f,e,!0)}#p=k(j([]));get modelPricingOverrideRows(){return I(this.#p)}set modelPricingOverrideRows(e){A(this.#p,e,!0)}#m=k(j({selector:``}));get modelPricingOverrideForm(){return I(this.#m)}set modelPricingOverrideForm(e){A(this.#m,e,!0)}_modelPricingOverrideRowID=0;pricingFieldOptions(){return tk}pricingFieldLabel(e){return nk(e)}async fetchModelPricingOverrides(){this.modelPricingOverrideError=``;try{let e=await gs(`/admin/model-pricing-overrides`,{label:`model pricing overrides`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideViews=[];return}if(e.stale)return;if(this.modelPricingOverridesAvailable=!0,!e.ok){this.modelPricingOverrideViews=[];return}this.modelPricingOverrideViews=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch model pricing overrides:`,e),this.modelPricingOverrideViews=[],this.modelPricingOverrideError=`Unable to load model pricing overrides.`}}findModelPricingOverrideView(e){return pk(this.modelPricingOverrideViews,e)}hasGlobalPricingOverride(){return!!this.findModelPricingOverrideView(`/`)}hasProviderPricingOverride(e){return!!this.findModelPricingOverrideView(ck(e&&e.provider_name))}hasModelPricingOverride(e){return!!this.findModelPricingOverrideView(uk(e))}modelPricingButtonClass(e){return e?`table-action-btn-active`:``}modelPricingButtonLabel(e,t){let n=`Edit `+String(e||`model pricing`);return t?n+` (override exists)`:n}modelRowPricing(e){return hk(e,this.modelPricingOverrideViews).pricing}openGlobalPricingOverrideEdit(){this.openModelPricingOverrideForm({displayName:`All providers and models`,selector:`/`,scope:`global`,scopeOptions:[{value:`global`,label:`All providers and models`,selector:`/`}],row:null})}openProviderPricingOverrideEdit(e){let t=ck(e&&e.provider_name);t&&this.openModelPricingOverrideForm({displayName:`All models in `+(e.display_name||e.provider_name||t),selector:t,scope:`provider`,scopeOptions:[{value:`provider`,label:`Provider`,selector:t}],row:null})}openModelPricingOverrideEdit(e){if(!e||e.is_alias)return;let t=uk(e),n=dk(e),r=[{value:`exact`,label:`This provider and model`,selector:t}];n&&n!==t&&r.push({value:`model`,label:`This model across providers`,selector:n}),this.openModelPricingOverrideForm({displayName:e.display_name||t,selector:t,scope:`exact`,scopeOptions:r,row:e})}openModelPricingOverrideForm(e){let t=e||{};this.modelPricingOverrideFormOpen=!0,this.modelPricingOverrideError=``,this.modelPricingOverrideFormDisplayName=t.displayName||t.selector||`Pricing`,this.modelPricingOverrideFormScope=t.scope||``,this.modelPricingOverrideFormScopeOptions=Array.isArray(t.scopeOptions)?t.scopeOptions:[],this.modelPricingOverrideFormRow=t.row||null,this.modelPricingOverrideForm={selector:t.selector||``},this.loadModelPricingOverrideFormSelector(t.selector||``)}loadModelPricingOverrideFormSelector(e){e=String(e||``).trim();let t=this.findModelPricingOverrideView(e);this.modelPricingOverrideFormHasExistingOverride=!!t,this.modelPricingOverrideRows=gk(t,()=>this.nextModelPricingOverrideRowID()),this.modelPricingOverrideFormPreservedTiers=t&&t.pricing&&Array.isArray(t.pricing.tiers)?rk(t.pricing.tiers):[],this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow();let n=this.modelPricingOverrideFormRow,r=n?hk(n,this.modelPricingOverrideViews,e):{pricing:{},sources:{}};this.modelPricingOverrideFormBasePricing=r.pricing,this.modelPricingOverrideFormBasePricingSources=r.sources}setModelPricingOverrideScope(e){this.modelPricingOverrideFormScope=e;let t=this.modelPricingOverrideFormScopeOptions.find(t=>t.value===e);t&&(this.modelPricingOverrideForm.selector=t.selector,this.loadModelPricingOverrideFormSelector(t.selector))}nextModelPricingOverrideRowID(){return this._modelPricingOverrideRowID=(this._modelPricingOverrideRowID||0)+1,`pricing-row-`+this._modelPricingOverrideRowID}availablePricingFieldOptions(e){return vk(this.modelPricingOverrideRows,e)}addModelPricingOverrideRow(){let e=_k(this.modelPricingOverrideRows),t=tk.find(t=>!e.has(t.value))||tk[0];t&&this.modelPricingOverrideRows.push({id:this.nextModelPricingOverrideRowID(),field:t.value,value:``})}removeModelPricingOverrideRow(e){this.modelPricingOverrideRows=this.modelPricingOverrideRows.filter(t=>t.id!==e.id),this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow()}modelPricingOverridePayload(){return yk(this.modelPricingOverrideRows,this.modelPricingOverrideFormPreservedTiers)}modelPricingOverrideDraftPricing(){let e=this.modelPricingOverridePayload();return e&&e.pricing?e.pricing:{}}modelPricingEffectivePreviewRows(){return bk(this.modelPricingOverrideFormBasePricing,this.modelPricingOverrideFormBasePricingSources,this.modelPricingOverrideDraftPricing())}closeModelPricingOverrideForm(){this.modelPricingOverrideFormOpen=!1,this.modelPricingOverrideSubmitting=!1,this.modelPricingOverrideError=``,this.modelPricingOverrideFormHasExistingOverride=!1,this.modelPricingOverrideFormDisplayName=``,this.modelPricingOverrideFormScope=``,this.modelPricingOverrideFormScopeOptions=[],this.modelPricingOverrideFormRow=null,this.modelPricingOverrideFormBasePricing=null,this.modelPricingOverrideFormBasePricingSources=null,this.modelPricingOverrideFormPreservedTiers=[],this.modelPricingOverrideRows=[],this.modelPricingOverrideForm={selector:``}}async submitModelPricingOverrideForm(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!e){this.modelPricingOverrideError=`Model pricing selector is required.`;return}let t=this.modelPricingOverridePayload();if(t.error){this.modelPricingOverrideError=t.error;return}let n={selector:e,...t};this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let e=await _s(`/admin/model-pricing-overrides`,`PUT`,n,{label:`model pricing override`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(e.stale)return;if(!e.ok){this.modelPricingOverrideError=e.status===401?`Authentication required.`:fs(e,`Failed to save model pricing.`);return}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),J.success(`Model pricing saved.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to save model pricing override:`,e),this.modelPricingOverrideError=`Failed to save model pricing.`}finally{this.modelPricingOverrideSubmitting=!1}}async deleteModelPricingOverride(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!(!e||!this.modelPricingOverrideFormHasExistingOverride)&&window.confirm(`Remove the model pricing override for "`+e+`"?`)){this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let t=await _s(`/admin/model-pricing-overrides`,`DELETE`,{selector:e},{label:`model pricing override`});if(t.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.modelPricingOverrideError=t.status===401?`Authentication required.`:fs(t,`Failed to remove model pricing override.`);return}}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),J.success(`Model pricing override removed.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to delete model pricing override:`,e),this.modelPricingOverrideError=`Failed to remove model pricing override.`}finally{this.modelPricingOverrideSubmitting=!1}}}},Sk=R(``);function Ck(e,t){E(t,!0);var n=Sk();let r;var i=P(M(n),2),a=M(i,!0);T(i),T(n),F((e,i,o)=>{r=U(n,1,`alias-toggle`,null,r,e),n.disabled=ek.rowTogglingKey===t.row.key||!ek.virtualModelsAvailable,W(n,`aria-label`,i),B(a,o)},[()=>({enabled:ek.rowToggleEnabled(t.row),restricted:ek.rowToggleRestricted(t.row)}),()=>ek.rowToggleAriaLabel(t.row),()=>ek.rowToggleLabel(t.row)]),L(`click`,n,()=>ek.toggleRowEnabled(t.row)),z(e,n),D()}Hr([`click`]);var wk=R(`
            `);function Tk(e,t){E(t,!0);var n=wk(),r=M(n),i=e=>{Ck(e,{get row(){return ek.globalScopeRow}})};V(r,e=>{ek.virtualModelsAvailable&&e(i)});var a=P(r,2),o=e=>{{let t=O(()=>xk.modelPricingButtonLabel(`global model pricing`,xk.hasGlobalPricingOverride())),n=O(()=>xk.modelPricingButtonClass(xk.hasGlobalPricingOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>xk.openGlobalPricingOverrideEdit(),children:(e,t)=>{K(e,{get icon(){return Ka},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(a,e=>{xk.modelPricingOverridesAvailable&&e(o)});var s=P(a,2),c=e=>{{let t=O(()=>BO(`global model access`,ek.hasGlobalModelOverride())),n=O(()=>zO(ek.hasGlobalModelOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>ek.openGlobalModelOverrideEdit(),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n),D()}function Ek(e){return String(e&&(e.primary_model||e.source)||``).trim()}function Dk(e){return Array.isArray(e&&e.fallback_models)?e.fallback_models:Array.isArray(e&&e.targets)?e.targets:[]}function Ok(e){return Array.isArray(e)?e.map(e=>({...e,source:Ek(e),targets:Dk(e)})):[]}function kk(e){let t=Dk(e);return t.length===0?`-`:t.join(`, `)}function Ak(e){return e&&e.enabled===!1?`Off`:e&&e.managed?`Config`:`On`}function jk(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>Ek(e)===n)||null}function Mk(e,t){if(!t||t.is_alias)return!1;let n=jk(e,tO(t));return!!(n&&n.enabled!==!1&&Dk(n).length>0)}function Nk(e,t){return Mk(e,t)?`table-action-btn-failover-active`:``}function Pk(e,t){let n=`Edit failover for `+(t&&t.display_name?t.display_name:`model`);return Mk(e,t)?n+` (active)`:n}function Fk(e){let t=[e&&e.target_model];return(Array.isArray(e&&e.targets)?e.targets:[]).forEach(e=>t.push(e&&e.model)),t.map(e=>String(e||``).trim()).filter(Boolean)}function Ik(e){let t=Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(Boolean):[];return{target_model:t[0]||``,targets:t.slice(1).map(e=>({model:e}))}}function Lk(e){return{primary_model:String(e&&e.source||``).trim(),fallback_models:Fk(e),enabled:!(e&&e.enabled===!1)}}function Rk(e){return Ek(e)}function zk(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=Rk(e);n&&(t[n]=!0)}),t}function Bk(e,t){let n=Rk(t);return!!(n&&e&&e[n])}function Vk(e,t){return(Array.isArray(e)?e:[]).filter(e=>Bk(t,e))}function Hk(e,t){let n=Array.isArray(e)?e:[];return n.length>0&&Vk(n,t).length===n.length}function Uk(e){return[Ek(e),Dk(e).join(` `)].join(` `).toLowerCase()}function Wk(e,t){let n=Array.isArray(e)?e:[],r=String(t||``).trim().toLowerCase();return r?n.filter(e=>Uk(e).includes(r)):n}function Gk(e){return{primary_model:Ek(e),fallback_models:Dk(e).map(e=>String(e||``).trim()).filter(Boolean),enabled:!!(e&&e.enabled!==!1)}}function Kk(){return{source:``,target_model:``,targets:[],enabled:!0}}var Z=new class{#e=k(!0);get failoverAvailable(){return I(this.#e)}set failoverAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get failoverRules(){return I(this.#t)}set failoverRules(e){A(this.#t,e,!0)}#n=k(!1);get failoverLoading(){return I(this.#n)}set failoverLoading(e){A(this.#n,e,!0)}#r=k(!1);get failoverSaving(){return I(this.#r)}set failoverSaving(e){A(this.#r,e,!0)}#i=k(!1);get failoverGenerating(){return I(this.#i)}set failoverGenerating(e){A(this.#i,e,!0)}#a=k(``);get failoverError(){return I(this.#a)}set failoverError(e){A(this.#a,e,!0)}#o=k(j([]));get failoverGeneratedRules(){return I(this.#o)}set failoverGeneratedRules(e){A(this.#o,e,!0)}#s=k(!1);get failoverDraftsOpen(){return I(this.#s)}set failoverDraftsOpen(e){A(this.#s,e,!0)}#c=k(j({}));get failoverDraftSelections(){return I(this.#c)}set failoverDraftSelections(e){A(this.#c,e,!0)}#l=k(``);get failoverDraftFilter(){return I(this.#l)}set failoverDraftFilter(e){A(this.#l,e,!0)}#u=k(!1);get failoverDraftSaving(){return I(this.#u)}set failoverDraftSaving(e){A(this.#u,e,!0)}#d=k(!1);get failoverFormOpen(){return I(this.#d)}set failoverFormOpen(e){A(this.#d,e,!0)}#f=k(`create`);get failoverFormMode(){return I(this.#f)}set failoverFormMode(e){A(this.#f,e,!0)}#p=k(!1);get failoverFormManaged(){return I(this.#p)}set failoverFormManaged(e){A(this.#p,e,!0)}#m=k(j(Kk()));get failoverForm(){return I(this.#m)}set failoverForm(e){A(this.#m,e,!0)}failoverEnabled(){return xs.booleanFlag(`FAILOVER_ENABLED`,!0)}async fetchFailoverRules(){if(!this.failoverEnabled()){this.failoverAvailable=!1,this.failoverRules=[],this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,this.failoverError=``,this.failoverLoading=!1;return}this.failoverLoading=!0,this.failoverError=``;try{let e=await gs(`/admin/failover`,{label:`failover mappings`});if(e.status===503){this.failoverAvailable=!1,this.failoverRules=[];return}if(e.stale)return;if(this.failoverAvailable=!0,!e.ok){this.failoverRules=[];return}this.failoverRules=Ok(e.data)}catch(e){console.error(`Failed to fetch failover mappings:`,e),this.failoverRules=[],this.failoverError=`Unable to load failover mappings.`}finally{this.failoverLoading=!1}}resetFailoverForm(){this.failoverFormMode=`create`,this.failoverFormManaged=!1,this.failoverForm=Kk()}openFailoverCreate(){this.resetFailoverForm(),this.failoverFormOpen=!0,this.focusFailoverEditor()}openFailoverEdit(e){if(!e)return;this.resetFailoverForm(),this.failoverFormMode=`edit`,this.failoverFormOpen=!0,this.failoverFormManaged=!!e.managed;let t=this.failoverPrimaryModel(e),n=this.failoverTargets(e);this.failoverForm={source:t,target_model:n[0]||``,targets:n.slice(1).map(e=>({model:e})),enabled:e.enabled!==!1},this.focusFailoverEditor()}openFailoverForModel(e){if(!e||e.is_alias)return;let t=this.qualifiedModelName(e),n=this.failoverRules.find(e=>this.failoverPrimaryModel(e)===t);if(n){this.openFailoverEdit(n);return}this.resetFailoverForm(),this.failoverFormMode=`create`,this.failoverFormOpen=!0,this.failoverForm.source=t,this.focusFailoverEditor()}closeFailoverForm(){this.failoverFormOpen=!1}closeFailoverDraftsModal(){this.failoverDraftSaving||(this.failoverDraftsOpen=!1)}failoverFormTargets(){return Fk(this.failoverForm)}setFailoverFormTargets(e){let t=Ik(e);this.failoverForm.target_model=t.target_model,this.failoverForm.targets=t.targets}addFailoverTarget(){Array.isArray(this.failoverForm.targets)||(this.failoverForm.targets=[]),this.failoverForm.targets.push({model:``}),this.focusFailoverEditor()}removeFailoverTarget(e){if(!Array.isArray(this.failoverForm.targets)){this.failoverForm.targets=[];return}this.failoverForm.targets.splice(e,1)}removePrimaryFailoverTarget(){let e=Array.isArray(this.failoverForm.targets)?this.failoverForm.targets:[];if(e.length>0){let t=e.shift();this.failoverForm.target_model=t&&t.model?t.model:``,this.failoverForm.targets=e;return}this.failoverForm.target_model=``}failoverRulePayload(){return Lk(this.failoverForm)}async submitFailoverForm(){if(this.failoverSaving||this.failoverGenerating||this.failoverFormManaged)return;let e=this.failoverRulePayload();if(!e.primary_model){this.failoverError=`Primary model is required.`;return}if(e.enabled&&e.fallback_models.length===0){this.failoverError=`Add at least one failover target.`;return}this.failoverSaving=!0,this.failoverError=``;try{let t=await _s(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to save failover mapping.`;return}J.success(`Failover mapping saved.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to save failover mapping:`,e),this.failoverError=`Failed to save failover mapping.`}finally{this.failoverSaving=!1}}async deleteFailoverRule(e){let t=String(e&&this.failoverPrimaryModel(e)||this.failoverForm.source||``).trim();if(!(!t||this.failoverSaving||this.failoverGenerating)&&confirm(`Remove failover mapping for "`+t+`"?`)){this.failoverSaving=!0,this.failoverError=``;try{let e=await _s(`/admin/failover`,`DELETE`,{primary_model:t},{label:`failover mapping`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mapping.`;return}J.success(`Failover mapping removed.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to remove failover mapping:`,e),this.failoverError=`Failed to remove failover mapping.`}finally{this.failoverSaving=!1}}}async generateFailoverForForm(){if(this.failoverGenerating||this.failoverSaving||this.failoverFormManaged)return;let e=String(this.failoverForm.source||``).trim();if(!e){this.failoverError=`Primary model is required.`;return}this.failoverGenerating=!0,this.failoverError=``;try{let t=await _s(`/admin/failover/generate`,`POST`,{primary_model:e},{label:`failover generation`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to generate failover mapping.`;return}let n=Ok(t.data),r=n.find(t=>this.failoverPrimaryModel(t)===e)||n[0]||null,i=this.failoverTargets(r);if(i.length===0){this.failoverError=`No failover suggestions were generated for this model.`;return}this.setFailoverFormTargets(i),J.success(`Generated `+i.length+` fallback model`+(i.length===1?`.`:`s.`)),this.focusFailoverEditor()}catch(e){console.error(`Failed to generate failover mapping:`,e),this.failoverError=`Failed to generate failover mapping.`}finally{this.failoverGenerating=!1}}openFailoverResetDialog(){Ls.open({title:`Remove failover models`,titleId:`failoverResetDialogTitle`,inputId:`failover-reset-confirmation`,message:`Remove every dashboard-managed failover mapping. Configuration-managed mappings remain active.`,requiredText:`remove`,confirmLabel:`Remove Failover`,icon:ko,dialogClass:`budget-reset-dialog`,onConfirm:async()=>{await this.resetFailoverRules(),this.failoverError&&(Ls.error=this.failoverError)}})}async resetFailoverRules(){if(!this.failoverSaving){this.failoverSaving=!0,this.failoverError=``;try{let e=await _s(`/admin/failover/reset`,`POST`,void 0,{label:`failover removal`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mappings.`;return}this.failoverRules=Ok(e.data),this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,J.success(`Dashboard-managed failover mappings removed.`),Ls.close()}catch(e){console.error(`Failed to remove failover mappings:`,e),this.failoverError=`Failed to remove failover mappings.`}finally{this.failoverSaving=!1}}}async generateFailoverRules(){if(!(this.failoverGenerating||this.failoverDraftSaving)){this.failoverGenerating=!0,this.failoverError=``,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!0;try{let e=await _s(`/admin/failover/generate`,`POST`,void 0,{label:`failover generation`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to generate failover mappings.`;return}this.failoverGeneratedRules=Ok(e.data),this.selectAllFailoverDrafts(this.failoverGeneratedRules)}catch(e){console.error(`Failed to generate failover mappings:`,e),this.failoverError=`Failed to generate failover mappings.`}finally{this.failoverGenerating=!1}}}failoverDraftKey(e){return Rk(e)}selectAllFailoverDrafts(e){this.failoverDraftSelections=zk(e)}failoverDraftSelected(e){return Bk(this.failoverDraftSelections,e)}setFailoverDraftSelected(e,t){let n=this.failoverDraftKey(e);n&&(this.failoverDraftSelections={...this.failoverDraftSelections,[n]:!!t})}selectedFailoverDrafts(){return Vk(this.failoverGeneratedRules,this.failoverDraftSelections)}selectedFailoverDraftCount(){return this.selectedFailoverDrafts().length}failoverDraftCountLabel(){return this.selectedFailoverDraftCount()+` / `+this.failoverGeneratedRules.length+` selected`}allFailoverDraftsSelected(){return Hk(this.failoverGeneratedRules,this.failoverDraftSelections)}toggleAllFailoverDrafts(){if(!(this.failoverDraftSaving||this.failoverGenerating||this.failoverGeneratedRules.length===0)){if(this.allFailoverDraftsSelected()){this.failoverDraftSelections={};return}this.selectAllFailoverDrafts(this.failoverGeneratedRules)}}failoverDraftSearchText(e){return Uk(e)}filteredFailoverDrafts(){return Wk(this.failoverGeneratedRules,this.failoverDraftFilter)}failoverDraftPayload(e){return Gk(e)}async saveSelectedFailoverDrafts(){if(this.failoverDraftSaving||this.failoverGenerating)return;let e=this.selectedFailoverDrafts();if(e.length===0){this.failoverError=`Select at least one failover draft.`;return}this.failoverDraftSaving=!0,this.failoverError=``;try{for(let t of e){let e=this.failoverDraftPayload(t);if(!e.primary_model||e.fallback_models.length===0){this.failoverError=`Generated failover draft is missing model data.`;return}let n=await _s(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(n.stale)return;if(!n.ok){this.failoverError=`Failed to save failover mapping.`;return}}J.success(`Saved `+e.length+` failover mapping`+(e.length===1?`.`:`s.`)),this.failoverDraftsOpen=!1,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.fetchFailoverRules()}catch(e){console.error(`Failed to save generated failover mappings:`,e),this.failoverError=`Failed to save failover mappings.`}finally{this.failoverDraftSaving=!1}}focusFailoverEditor(){setTimeout(()=>{let e=document.querySelector(`[data-failover-editor]`),t=e&&e.querySelector?e.querySelector(`[data-modal-autofocus], input:not([disabled]), textarea:not([disabled]), button:not([disabled])`):null;t&&typeof t.focus==`function`&&t.focus({preventScroll:!0})},0)}failoverTargetLabel(e){return kk(e)}failoverPrimaryModel(e){return Ek(e)}failoverTargets(e){return Dk(e)}findFailoverMapping(e){return jk(this.failoverRules,e)}hasActiveFailoverMapping(e){return Mk(this.failoverRules,e)}failoverButtonClass(e){return Nk(this.failoverRules,e)}failoverButtonLabel(e){return Pk(this.failoverRules,e)}normalizeFailoverRules(e){return Ok(e)}failoverRuleStatus(e){return Ak(e)}qualifiedModelName(e){return tO(e)}},qk=R(``),Jk=R(``),Yk=R(`Config`),Xk=R(`
            Targets
            `),Zk=R(``),Qk=R(`
            Redirects to
            `),$k=R(` `),eA=R(`
            `),tA=R(`
            `),nA=R(`
            `);function rA(e,t){E(t,!0);let n=O(()=>xk.modelRowPricing(t.row));var r=nA(),i=M(r),a=M(i),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{z(e,qk())};V(l,e=>{t.row.is_alias&&e(u)});var d=P(l,2),f=e=>{z(e,Jk())};V(d,e=>{!t.row.is_alias&&t.row.masking_alias&&e(f)});var p=P(d,2),m=e=>{z(e,Yk())},h=O(()=>LO(t.row));V(p,e=>{I(h)&&e(m)}),T(o);var g=P(o,2),_=e=>{var n=Xk(),r=P(M(n)),i=M(r,!0);T(r),T(n),F(()=>B(i,t.row.secondary_name)),z(e,n)};V(g,e=>{t.row.is_alias&&e(_)});var v=P(g,2),y=e=>{var n=Qk(),r=P(M(n)),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=Zk();F(e=>{W(n,`aria-label`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),W(n,`title`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),n.disabled=e},[()=>!!ek.rowDeletingKey]),L(`click`,n,()=>ek.removeRedirectRow(t.row)),z(e,n)},s=O(()=>ek.virtualModelsAvailable&&FO(t.row));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>mO(t.row.masking_alias)]),z(e,n)};V(v,e=>{!t.row.is_alias&&t.row.masking_alias&&e(y)}),T(a),T(i);var b=P(i);H(b,17,()=>t.columns,oi,(e,r)=>{var i=$k(),a=M(i,!0);T(i),F(e=>{U(i,1,Fi(I(r).class),`svelte-1iynym`),B(a,e)},[()=>I(r).value(t.row,I(n))]),z(e,i)});var x=P(b),S=M(x),C=e=>{var n=eA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>ek.rowDeletingKey===t.row.key?`Removing alias `+t.row.alias.name:`Remove alias `+t.row.alias.name),r=O(()=>!!ek.rowDeletingKey);gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>ek.removeAliasRow(t.row),get disabled(){return I(r)},children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}})}},o=O(()=>ek.virtualModelsAvailable&&PO(t.row));V(i,e=>{I(o)&&e(a)});var s=P(i,2),c=e=>{{let n=O(()=>`Edit alias `+t.row.alias.name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.alias),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n)},w=e=>{var n=tA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`model pricing for `+t.row.display_name,xk.hasModelPricingOverride(t.row))),r=O(()=>xk.modelPricingButtonClass(xk.hasModelPricingOverride(t.row)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openModelPricingOverrideEdit(t.row),children:(e,t)=>{K(e,{get icon(){return Ka},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(i,e=>{xk.modelPricingOverridesAvailable&&e(a)});var o=P(i,2),s=e=>{{let n=O(()=>Z.failoverButtonLabel(t.row)),r=O(()=>Z.failoverButtonClass(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>Z.openFailoverForModel(t.row),children:(e,t)=>{K(e,{get icon(){return To},class:`table-icon-svg`})},$$slots:{default:!0}})}},c=O(()=>Z.failoverAvailable&&Z.failoverEnabled());V(o,e=>{I(c)&&e(s)});var l=P(o,2),u=e=>{{let n=O(()=>X.rateLimitGaugeTitle(t.row.display_name,X.rateLimitGaugeClassForModel(t.row))),r=O(()=>X.rateLimitGaugeClassForModel(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForModel(t.row),children:(e,t)=>{K(e,{get icon(){return Qa},class:`table-icon-svg`})},$$slots:{default:!0}})}},d=O(()=>X.rateLimitsEnabled()&&X.rateLimitInspectorModelID(t.row));V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{{let n=O(()=>`Edit redirect for `+t.row.display_name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.masking_alias),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(f,e=>{ek.virtualModelsAvailable&&t.row.masking_alias&&t.row.masking_alias.name&&e(p)});var m=P(f,2),h=e=>{{let n=O(()=>BO(`model access for `+t.row.display_name,RO(t.row.access))),r=O(()=>zO(RO(t.row.access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openVirtualModelEditModel(t.row),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(m,e=>{ek.virtualModelsAvailable&&!t.row.masking_alias&&e(h)}),T(n),z(e,n)};V(S,e=>{t.row.is_alias?e(C):e(w,-1)}),T(x),T(r),F((e,n)=>{W(r,`id`,e),U(r,1,n,`svelte-1iynym`),B(c,t.row.display_name)},[()=>IO(t.row)||void 0,()=>Fi(NO(t.row))]),z(e,r),D()}Hr([`click`]);var iA={headerLines:[`Modes`],value:e=>(e.model?.metadata?.modes??[]).join(`, `)||`-`};function aA(e,t){return{headerLines:e,class:`col-price`,value:t}}var oA=aA([`Input / Output ($/MTok)`],(e,t)=>sc(t?.input_per_mtok)+` / `+sc(t?.output_per_mtok)),sA={all:[oA],text_generation:[iA,oA,aA([`Cached $/MTok`],(e,t)=>sc(t?.cached_input_per_mtok))],embedding:[aA([`Input`,`$/MTok`],(e,t)=>sc(t?.input_per_mtok))],image:[aA([`$/Image`],(e,t)=>cc(t?.per_image))],audio:[aA([`$/Second`],(e,t)=>cc(t?.per_second_input)),aA([`$/Character`],(e,t)=>cc(t?.per_character_input))],video:[aA([`$/Second (In)`],(e,t)=>cc(t?.per_second_input)),aA([`$/Second (Out)`],(e,t)=>cc(t?.per_second_output))],utility:[aA([`$/Page`],(e,t)=>cc(t?.per_page)),aA([`$/Request`],(e,t)=>cc(t?.per_request))]};function cA(e){return sA[e]||sA.all}function lA(e){return cA(e).length+2}var uA=R(`
            `),dA=R(` `,1),fA=R(``),pA=R(` `),mA=R(` `),hA=R(`
            `),gA=R(`
            `),_A=R(`
            Model
            `);function vA(e,t){E(t,!0);let n=O(()=>Mc.activeCategory||`all`),r=O(()=>cA(I(n))),i=O(()=>lA(I(n)));var a=_A(),o=M(a),s=M(o),c=M(s),l=P(M(c));H(l,17,()=>I(r),oi,(e,t)=>{var n=fA();H(n,21,()=>I(t).headerLines,oi,(e,t,n)=>{var r=dA(),i=N(r),a=e=>{z(e,uA())};V(i,e=>{n>0&&e(a)});var o=P(i,1,!0);F(()=>B(o,I(t))),z(e,r)}),T(n),F(()=>U(n,1,Fi(I(t).class),`svelte-1911hy6`)),z(e,n)});var u=P(l);Tk(M(u),{}),T(u),T(c),T(s),H(P(s),17,()=>ek.filteredDisplayModelGroups,e=>e.key,(e,t)=>{var n=gA(),a=M(n),o=M(a),s=M(o),c=M(s),l=M(c),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=e=>{var n=pA(),r=M(n,!0);T(n),F(()=>B(r,`(`+I(t).type_label+`)`)),z(e,n)};V(f,e=>{I(t).type_label&&e(p)});var m=P(f,2),h=e=>{var n=mA(),r=M(n,!0);T(n),F(()=>B(r,I(t).item_count_label)),z(e,n)};V(m,e=>{I(t).item_count_label&&e(h)}),T(l);var g=P(l,2),_=e=>{var n=hA(),r=M(n,!0);T(n),F(()=>B(r,I(t).access_summary)),z(e,n)};V(g,e=>{I(t).access_summary&&e(_)}),T(c);var v=P(c,2),y=M(v),b=e=>{Ck(e,{get row(){return I(t)}})};V(y,e=>{I(t).access.selector&&e(b)});var x=P(y,2),S=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`provider pricing for `+I(t).display_name,xk.hasProviderPricingOverride(I(t)))),r=O(()=>xk.modelPricingButtonClass(xk.hasProviderPricingOverride(I(t))));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openProviderPricingOverrideEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return Ka},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(x,e=>{xk.modelPricingOverridesAvailable&&I(t).provider_name&&e(S)});var C=P(x,2),w=e=>{{let n=O(()=>X.rateLimitGaugeTitle(`provider `+I(t).display_name,X.rateLimitGaugeClassForProvider(I(t)))),r=O(()=>X.rateLimitGaugeClassForProvider(I(t)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForProvider(I(t)),children:(e,t)=>{K(e,{get icon(){return Qa},class:`table-icon-svg`})},$$slots:{default:!0}})}},ee=O(()=>X.rateLimitsEnabled()&&I(t).provider_name);V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{{let n=O(()=>BO(`provider access for `+I(t).display_name,RO(I(t).access))),r=O(()=>zO(RO(I(t).access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openProviderOverrideEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(te,e=>{ek.virtualModelsAvailable&&I(t).access.selector&&e(ne)}),T(v),T(s),T(o),T(a),H(P(a),17,()=>I(t).rows,e=>e.key,(e,t)=>{rA(e,{get row(){return I(t)},get columns(){return I(r)}})}),T(n),F(()=>{W(o,`colspan`,I(i)),B(d,I(t).display_name)}),z(e,n)}),T(o),T(a),z(e,a),D()}var yA=R(``);function bA(e,t){let n=G(t,`enabled`,3,!1),r=G(t,`label`,3,``),i=G(t,`disabled`,3,!1),a=G(t,`restricted`,3,!1);var o=yA();let s;var c=P(M(o),2),l=M(c,!0);T(c),T(o),F(()=>{s=U(o,1,`alias-toggle`,null,s,{enabled:n(),restricted:a()}),o.disabled=i(),W(o,`aria-label`,(n()?`Disable `:`Enable `)+r()),B(l,t.text??(n()?`Enabled`:`Disabled`))}),L(`click`,o,function(...e){t.onclick?.apply(this,e)}),z(e,o)}Hr([`click`]);var xA=R(``),SA=R(`
            `);function CA(e,t){E(t,!0);let n=G(t,`model`,15,``),r=G(t,`weight`,15),i=G(t,`id`,3,void 0),a=G(t,`placeholder`,3,`openai/gpt-4o`),o=G(t,`showRemove`,3,!0);var s=SA(),c=M(s);na(c);var l=P(c,2),u=e=>{var t=xA();na(t),F(()=>t.disabled=ek.vmFormManaged),da(t,r),z(e,t)},d=O(()=>ek.vmFormShowWeights());V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{gT(e,{label:`Remove target`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,get onclick(){return t.onremove},get disabled(){return ek.vmFormManaged},children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}})};V(f,e=>{o()&&e(p)}),T(s),F(()=>{W(c,`id`,i()),W(c,`placeholder`,a()),c.disabled=ek.vmFormManaged}),da(c,n),z(e,s),D()}var wA=R(`

            `),TA=R(`adaptive lets the registered routing extension pick the target per - request.`,1),EA=R(`Add one target to make this a redirect/alias, or two or more to load - balance across them, then pick a strategy: round_robin rotates across targets - (weight biases the share) and cost always routes to the cheapest available - target. Leave Targets empty to make it only an access policy on the Source selector. The selector uses / for all providers and - models, for one provider, or for one model. user_paths is - matched against the effective request user_path: the managed API key user_path when present, otherwise the configured user path request header.`,1),DA=R(``),OA=R(`

            This virtual model is defined in configuration (config.yaml / VIRTUAL_MODELS) and is read-only here. Edit your configuration to change it.

            `),kA=R(``),AA=R(``),jA=R(``),MA=R(`
            `,1),NA=R(``),PA=R(`Use / to allow every user path. Use a team path to restrict to that - subtree, or an unused path to make the selector unavailable.`,1),FA=R(``),IA=R(` `),LA=R(`
            Targets
            `,1);function RA(e,t){E(t,!0);let n=ek;An(()=>{n.vmFormOpen&&xs.ensureLoaded()});{let t=e=>{KS(e,{copyId:`virtual-model-help-copy`,label:`virtual model help`,get open(){return n.vmFormHelpOpen},set open(e){n.vmFormHelpOpen=e},title:e=>{var t=wA(),r=M(t,!0);T(t),F(()=>B(r,n.vmFormDisplayName||n.vmForm.source||`Virtual model`)),z(e,t)},help:e=>{Ue();var t=EA(),n=P(N(t),7),r=e=>{var t=TA();Ue(),z(e,t)},i=O(()=>xs.virtualModelStrategies().includes(`adaptive`));V(n,e=>{I(i)&&e(r)});var a=P(n,8);a.textContent=`{provider_name}/`;var o=P(a,2);o.textContent=`{provider_name}/{model}`,Ue(7),z(e,t)},$$slots:{title:!0,help:!0}})},r=e=>{var t=Qr(),r=N(t),i=e=>{var t=DA();F(()=>t.disabled=n.vmDeleting||n.vmSubmitting),L(`click`,t,()=>n.deleteVirtualModel()),z(e,t)};V(r,e=>{n.vmFormHasExisting&&!n.vmFormManaged&&e(i)}),z(e,t)},i=O(()=>n.vmDeleting||n.vmFormManaged),a=O(()=>n.vmFormMode===`edit`?`Save`:`Create`),o=O(()=>n.vmFormMode===`edit`?go:fo);bE(e,{get open(){return n.vmFormOpen},ariaLabel:`Virtual model editor`,get error(){return n.vmFormError},get submitting(){return n.vmSubmitting},get submitDisabled(){return I(i)},get submitLabel(){return I(a)},get submitIcon(){return I(o)},onclose:()=>n.closeVirtualModelForm(),onsubmit:()=>n.submitVirtualModelForm(),header:t,extraActions:r,children:(e,t)=>{var r=LA(),i=N(r),a=e=>{z(e,OA())};V(i,e=>{n.vmFormManaged&&e(a)});var o=P(i,2);SE(o,{id:`virtual-model-source`,label:`Source`,children:(e,t)=>{var r=kA();na(r),F(()=>r.disabled=n.vmFormSourceLocked||n.vmFormManaged),da(r,()=>n.vmForm.source,e=>n.vmForm.source=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2);H(s,21,()=>Mc.models,e=>tO(e),(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(s);var c=P(s,2),l=P(M(c),2);{let e=O(()=>n.vmFormHasPrimaryTarget());CA(l,{id:`virtual-model-target`,get showRemove(){return I(e)},onremove:()=>n.removePrimaryTarget(),get model(){return n.vmForm.target_model},set model(e){n.vmForm.target_model=e},get weight(){return n.vmForm.target_weight},set weight(e){n.vmForm.target_weight=e}})}var u=P(l,2);H(u,17,()=>n.vmForm.targets,oi,(e,t,r)=>{CA(e,{placeholder:`groq/llama`,onremove:()=>n.removeVmTarget(r),get model(){return I(t).model},set model(e){I(t).model=e},get weight(){return I(t).weight},set weight(e){I(t).weight=e}})});var d=P(u,2),f=M(d);K(M(f),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(f),T(d),T(c);var p=P(c,2),m=e=>{var t=MA(),r=N(t);SE(r,{id:`virtual-model-strategy`,label:`Load-balancing strategy`,children:(e,t)=>{var r=jA();H(r,21,()=>n.vmStrategyOptions(),e=>e.value,(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),F(()=>r.disabled=n.vmFormManaged),Gi(r,()=>n.vmForm.strategy,e=>n.vmForm.strategy=e),z(e,r)},$$slots:{default:!0}});var i=P(r,2),a=M(i),o=M(a);na(o),Ue(2),T(a),T(i),F(()=>o.disabled=n.vmFormManaged),fa(o,()=>n.vmForm.session_affinity,e=>n.vmForm.session_affinity=e),z(e,t)},h=O(()=>n.vmFormShowStrategy());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=M(g);KS(_,{copyId:`virtual-model-user-paths-help`,label:`user paths help`,get open(){return n.vmFormUserPathsHelpOpen},set open(e){n.vmFormUserPathsHelpOpen=e},title:e=>{z(e,NA())},help:e=>{Ue();var t=PA();Ue(2),z(e,t)},$$slots:{title:!0,help:!0}});var v=P(_,2);ft(v),W(v,`placeholder`,`/ -/team/alpha -/non-existing`),T(g);var y=P(g,2);SE(y,{id:`virtual-model-description`,label:`Description`,children:(e,t)=>{var r=FA();ft(r),F(()=>r.disabled=n.vmFormManaged),da(r,()=>n.vmForm.description,e=>n.vmForm.description=e),z(e,r)},$$slots:{default:!0}});var b=P(y,2),x=M(b),S=e=>{var t=IA(),r=M(t,!0);T(t),F(()=>B(r,`Default enabled: `+(n.vmFormDefaultEnabled?`yes`:`no`)+` · Effective now: `+(n.vmFormEffectiveEnabled?`yes`:`no`))),z(e,t)};V(x,e=>{n.vmFormMode===`edit`&&e(S)});var C=P(x,2),w=M(C);{let e=O(()=>n.vmFormToggleRestricted()),t=O(()=>n.vmFormToggleLabel());bA(w,{get enabled(){return n.vmForm.enabled},get restricted(){return I(e)},label:`virtual model`,get disabled(){return n.vmFormManaged},get text(){return I(t)},onclick:()=>{n.vmFormManaged||(n.vmForm.enabled=!n.vmForm.enabled)}})}T(C),T(b),F(()=>{f.disabled=n.vmFormManaged,v.disabled=n.vmFormManaged}),L(`click`,f,()=>n.addVmTarget()),da(v,()=>n.vmForm.user_paths,e=>n.vmForm.user_paths=e),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var zA=R(`

            Pricing override

            `,1),BA=R(``),VA=R(``),HA=R(``),UA=R(``),WA=R(`
            `),GA=R(`
            Tiered pricing exists for this override and will be preserved. Tier editing can be added - without a database migration.
            `),KA=R(`
            No pricing fields set.
            `),qA=R(`
            `),JA=R(`

            Currency is USD. Saved fields override model registry and config.yaml pricing for this - selector; unset fields continue to inherit.

            Price Type USD Source
            `,1);function YA(e,t){E(t,!0);let n=xk;bE(e,{get open(){return n.modelPricingOverrideFormOpen},ariaLabel:`Model pricing editor`,dialogClass:`model-pricing-editor`,get error(){return n.modelPricingOverrideError},get submitting(){return n.modelPricingOverrideSubmitting},submitLabel:`Save Pricing`,onclose:()=>n.closeModelPricingOverrideForm(),onsubmit:()=>n.submitModelPricingOverrideForm(),header:e=>{var t=zA(),r=P(N(t),2),i=M(r,!0);T(r),F(()=>B(i,n.modelPricingOverrideFormDisplayName||n.modelPricingOverrideForm.selector||`Pricing`)),z(e,t)},extraActions:e=>{var t=Qr(),r=N(t),i=e=>{var t=BA();F(()=>t.disabled=n.modelPricingOverrideSubmitting),L(`click`,t,()=>n.deleteModelPricingOverride()),z(e,t)};V(r,e=>{n.modelPricingOverrideFormHasExistingOverride&&e(i)}),z(e,t)},children:(e,t)=>{var r=JA(),i=N(r),a=M(i);SE(a,{id:`model-pricing-override-selector`,label:`Selector`,children:(e,t)=>{var r=VA();na(r),da(r,()=>n.modelPricingOverrideForm.selector,e=>n.modelPricingOverrideForm.selector=e),z(e,r)},$$slots:{default:!0}});var o=P(a,2),s=e=>{SE(e,{id:`model-pricing-override-scope`,label:`Scope`,children:(e,t)=>{var r=UA();H(r,21,()=>n.modelPricingOverrideFormScopeOptions,e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),L(`change`,r,()=>n.setModelPricingOverrideScope(n.modelPricingOverrideFormScope)),Gi(r,()=>n.modelPricingOverrideFormScope,e=>n.modelPricingOverrideFormScope=e),z(e,r)},$$slots:{default:!0}})};V(o,e=>{n.modelPricingOverrideFormScopeOptions.length>1&&e(s)}),T(i);var c=P(i,4);H(c,21,()=>n.modelPricingOverrideRows,e=>e.id,(e,t,r)=>{var i=WA(),a=M(i),o=M(a),s=P(o,2);H(s,21,()=>n.availablePricingFieldOptions(I(t)),e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).group+` - `+I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(s),T(a);var c=P(a,2),l=M(c),u=P(l,2);na(u),T(c);var d=P(c,2);{let e=O(()=>`Remove `+n.pricingFieldLabel(I(t).field));gT(d,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn pricing-override-remove-row`,onclick:()=>n.removeModelPricingOverrideRow(I(t)),children:(e,t)=>{K(e,{get icon(){return Fo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(i),F(()=>{W(o,`for`,`pricing-type-`+I(t).id),W(s,`id`,`pricing-type-`+I(t).id),W(l,`for`,`pricing-value-`+I(t).id),W(u,`id`,`pricing-value-`+I(t).id)}),Gi(s,()=>I(t).field,e=>I(t).field=e),da(u,()=>I(t).value,e=>I(t).value=e),z(e,i)}),T(c);var l=P(c,2),u=M(l);K(M(u),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(u),T(l);var d=P(l,2),f=e=>{z(e,GA())};V(d,e=>{n.modelPricingOverrideFormPreservedTiers.length>0&&e(f)});var p=P(d,2),m=P(M(p),2),h=e=>{z(e,KA())},g=O(()=>n.modelPricingEffectivePreviewRows().length===0);V(m,e=>{I(g)&&e(h)}),H(P(m,2),17,()=>n.modelPricingEffectivePreviewRows(),e=>e.field,(e,t)=>{var n=qA(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{B(i,I(t).label),B(o,e),B(c,I(t).source)},[()=>I(t).value===null||I(t).value===void 0?`-`:cc(Number(I(t).value))]),z(e,n)}),T(p),L(`click`,u,()=>n.addModelPricingOverrideRow()),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}}),D()}Hr([`click`,`change`]);var XA=R(`

            Failover mapping

            `,1),ZA=R(``),QA=R(`

            This failover mapping is defined in configuration and is read-only here.

            `),$A=R(``),ej=R(`
            `),tj=R(`
            `,1),nj=R(`
            `);function rj(e,t){E(t,!0);{let t=e=>{var t=XA(),n=P(N(t),2),r=M(n,!0);T(n),F(()=>B(r,Z.failoverForm.source||`Failover`)),z(e,t)},n=e=>{var t=Qr(),n=N(t),r=e=>{var t=ZA();F(()=>t.disabled=Z.failoverSaving||Z.failoverGenerating),L(`click`,t,()=>Z.deleteFailoverRule()),z(e,t)};V(n,e=>{Z.failoverFormMode===`edit`&&!Z.failoverFormManaged&&e(r)}),z(e,t)},r=O(()=>Z.failoverGenerating||Z.failoverFormManaged);bE(e,{get open(){return Z.failoverFormOpen},ariaLabel:`Failover editor`,get error(){return Z.failoverError},get submitting(){return Z.failoverSaving},get submitDisabled(){return I(r)},submitLabel:`Save`,onclose:()=>Z.closeFailoverForm(),onsubmit:()=>Z.submitFailoverForm(),header:t,extraActions:n,children:(e,t)=>{var n=nj(),r=M(n),i=e=>{z(e,QA())};V(r,e=>{Z.failoverFormManaged&&e(i)});var a=P(r,2);H(a,21,()=>Mc.models,oi,(e,t)=>{var n=$A(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(a);var o=P(a,2);SE(o,{id:`failover-target`,label:`Fallback models`,children:(e,t)=>{var n=tj(),r=N(n),i=M(r),a=M(i);na(a);var o=P(a,2),s=e=>{gT(e,{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removePrimaryFailoverTarget(),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}})};V(o,e=>{Z.failoverForm.target_model&&e(s)}),T(i),H(P(i,2),17,()=>Z.failoverForm.targets,oi,(e,t,n)=>{var r=ej(),i=M(r);na(i),gT(P(i,2),{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removeFailoverTarget(n),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),F(()=>i.disabled=Z.failoverFormManaged),da(i,()=>I(t).model,e=>I(t).model=e),z(e,r)}),T(r);var c=P(r,2),l=M(c);K(M(l),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(l);var u=P(l,2),d=M(u);K(d,{get icon(){return No},class:`form-action-icon`});var f=P(d,2),p=M(f,!0);T(f),T(u),T(c),F(e=>{a.disabled=Z.failoverFormManaged,l.disabled=Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving,u.disabled=e,B(p,Z.failoverGenerating?`Generating...`:`Generate automatically`)},[()=>Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving||!Z.failoverEnabled()]),da(a,()=>Z.failoverForm.target_model,e=>Z.failoverForm.target_model=e),L(`click`,l,()=>Z.addFailoverTarget()),L(`click`,u,()=>Z.generateFailoverForForm()),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=M(s);bA(M(c),{get enabled(){return Z.failoverForm.enabled},label:`failover mapping`,get disabled(){return Z.failoverFormManaged},onclick:()=>{Z.failoverFormManaged||(Z.failoverForm.enabled=!Z.failoverForm.enabled)}}),T(c),T(s),T(n),z(e,n)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var ij=R(` `),aj=R(`
            `),oj=R(``),sj=R(`
            `),cj=R(`

            No failover suggestions were generated.

            `),lj=R(`

            No failover drafts match the filter.

            `),uj=R(``),dj=R(``);function fj(e,t){E(t,!0),Ms(e,{get open(){return Z.failoverDraftsOpen},variant:`editor`,onclose:()=>Z.closeFailoverDraftsModal(),children:(e,t)=>{var n=dj(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=ij(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>Z.failoverDraftCountLabel()]),z(e,t)};V(a,e=>{Z.failoverGeneratedRules.length>0&&e(o)}),Os(P(a,2),{label:`Close failover drafts`,onclick:()=>Z.closeFailoverDraftsModal(),get disabled(){return Z.failoverDraftSaving}}),T(i),T(r);var s=P(r,2),c=e=>{mT(e,{label:`Generating failover drafts...`,class:`failover-drafts-loading`})};V(s,e=>{Z.failoverGenerating&&e(c)});var l=P(s,2),u=e=>{var t=aj(),n=M(t);yw(n,{placeholder:`Filter failover drafts...`,label:`Filter failover drafts`,get value(){return Z.failoverDraftFilter},set value(e){Z.failoverDraftFilter=e}});var r=P(n,2),i=M(r);K(i,{get icon(){return Ba},class:`form-action-icon`});var a=P(i,2),o=M(a,!0);T(a),T(r),T(t),F(e=>{r.disabled=Z.failoverDraftSaving,B(o,e)},[()=>Z.allFailoverDraftsSelected()?`Deselect all`:`Select all`]),L(`click`,r,()=>Z.toggleAllFailoverDrafts()),z(e,t)};V(l,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&e(u)});var d=P(l,2),f=e=>{var t=sj();H(t,21,()=>Z.filteredFailoverDrafts(),e=>`failover-draft:`+Z.failoverPrimaryModel(e),(e,t)=>{var n=oj(),r=M(n);na(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(i),T(n),F((e,t,n,i)=>{ia(r,e),r.disabled=Z.failoverDraftSaving,W(r,`aria-label`,t),B(o,n),B(c,i)},[()=>Z.failoverDraftSelected(I(t)),()=>`Select failover draft for `+Z.failoverPrimaryModel(I(t)),()=>Z.failoverPrimaryModel(I(t)),()=>Z.failoverTargetLabel(I(t))]),L(`change`,r,e=>Z.setFailoverDraftSelected(I(t),e.currentTarget.checked)),z(e,n)}),T(t),z(e,t)},p=O(()=>!Z.failoverGenerating&&Z.filteredFailoverDrafts().length>0);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{z(e,cj())};V(m,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length===0&&!Z.failoverError&&e(h)});var g=P(m,2),_=e=>{z(e,lj())},v=O(()=>!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&Z.filteredFailoverDrafts().length===0);V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=uj(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(y,e=>{Z.failoverError&&e(b)});var x=P(y,2),S=M(x),C=P(S,2),w=M(C);K(w,{get icon(){return go},class:`form-action-icon`});var ee=P(w,2),te=M(ee,!0);T(ee),T(C),T(x),T(n),F(e=>{S.disabled=Z.failoverDraftSaving,C.disabled=e,B(te,Z.failoverDraftSaving?`Saving...`:`Save selected`)},[()=>Z.failoverGenerating||Z.failoverDraftSaving||Z.selectedFailoverDraftCount()===0]),L(`click`,S,()=>Z.closeFailoverDraftsModal()),L(`click`,C,()=>Z.saveSelectedFailoverDrafts()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`,`change`]);var pj=R(`
            Rate limit management is unavailable.
            `),mj=R(` Add`,1),hj=R(`

            `),gj=R(`

            No rules.

            `),_j=R(` Edit`,1),vj=R(`
            `),yj=R(`
            `),bj=R(`

            `),xj=R(``),Sj=R(``);function Cj(e,t){E(t,!0);function n(){q.dialogOpen||X.closeRateLimitInspector()}Ms(e,{get open(){return X.rateLimitInspectorOpen},variant:`editor`,onclose:n,children:(e,t)=>{var n=Sj(),r=M(n),i=M(r),a=P(M(i),2),o=M(a),s=M(o,!0);T(o),T(a),T(i),Os(P(i,2),{label:`Close rate limits inspector`,onclick:()=>X.closeRateLimitInspector()}),T(r);var c=P(r,2),l=e=>{mT(e,{label:`Loading rate limits...`})},u=e=>{z(e,pj())},d=e=>{var t=Qr();H(N(t),17,()=>X.rateLimitInspectorSections(),e=>e.key,(e,t)=>{var n=bj(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2);{let e=O(()=>`Add `+I(t).title.toLowerCase());gT(o,{get label(){return I(e)},class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(I(t).scope,I(t).subject),children:(e,t)=>{var n=mj();K(N(n),{get icon(){return fo},class:`table-icon-svg`}),Ue(2),z(e,n)},$$slots:{default:!0}})}T(r);var s=P(r,2),c=e=>{var n=hj(),r=M(n,!0);T(n),F(()=>B(r,I(t).hint)),z(e,n)};V(s,e=>{I(t).hint&&e(c)});var l=P(s,2),u=e=>{z(e,gj())},d=e=>{var n=yj();H(n,21,()=>I(t).items,e=>X.rateLimitKey(e),(e,t)=>{var n=vj(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=M(c);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?ja:Oo);K(l,{get icon(){return I(e)},class:`budget-period-icon`})}var u=P(l,2),d=M(u,!0);T(u),T(c),T(s);var f=P(s,2),p=M(f),m=M(p),h=M(m,!0);T(m);var g=P(m,2),_=M(g,!0);T(g),T(p);var v=P(p,2),y=M(v),b=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(null,null,I(t)),children:(e,t)=>{var n=_j();K(N(n),{get icon(){return lo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},x=O(()=>!X.rateLimitIsReadOnly(I(t)));V(y,e=>{I(x)&&e(b)}),T(v),T(f),T(i),T(r),T(n),F((e,t,r,i,a,s,c,l)=>{U(n,1,`budget-row ${e??``}`),Hi(n,t),W(n,`title`,r),B(o,i),B(d,a),B(h,s),W(g,`title`,c),B(_,l)},[()=>X.rateLimitPressureClass(I(t)),()=>X.rateLimitPressureStyle(I(t)),()=>X.rateLimitPressurePercent(I(t))+`% of the most constrained cap used`,()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitInspectorSummary(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n)};V(l,e=>{I(t).items.length===0?e(u):e(d,-1)}),T(n),F(()=>B(a,I(t).title)),z(e,n)}),z(e,t)};V(c,e=>{X.rateLimitsLoading?e(l):X.rateLimitsAvailable?e(d,-1):e(u,1)});var f=P(c,2),p=M(f),m=P(p,2),h=e=>{var t=xj();L(`click`,t,()=>{X.closeRateLimitInspector(),qo.navigate(`rate-limits`)}),z(e,t)},g=O(()=>X.rateLimitsEnabled());V(m,e=>{I(g)&&e(h)}),T(f),T(n),F(()=>B(s,X.rateLimitInspector.title)),L(`click`,p,()=>X.closeRateLimitInspector()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`]);var wj=R(`
            models
            `),Tj=R(`
            Virtual models feature is unavailable.
            `),Ej=R(`
            `),Dj=R(``),Oj=R(`
            `),kj=R(``),Aj=R(`
            `),jj=R(`

            No models registered.

            `),Mj=R(`

            No models in this category.

            `),Nj=R(`

            No models match your filter.

            `),Pj=R(`
            `);function Fj(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`models`&&(ek.fetchVirtualModels(),xk.fetchModelPricingOverrides(),Z.fetchFailoverRules(),X.fetchRateLimitsPage())}),An(()=>{let e=ek.filteredDisplayModels.length;return Er(()=>ek.restartModelRendering(e)),()=>ek.stopModelRendering()});let n=O(()=>q.needsAuth);var r=Pj(),i=M(r),a=P(M(i),2),o=e=>{var t=wj(),n=M(t),r=M(n,!0);T(n),Ue(),T(t),F(()=>B(r,Mc.filter?ek.filteredDisplayModels.length+` / `+ek.displayModels.length:ek.displayModels.length)),z(e,t)};V(a,e=>{ek.displayModels.length>0&&e(o)}),T(i);var s=P(i,2);Pc(s,{});var c=P(s,2),l=e=>{z(e,Tj())};V(c,e=>{!ek.virtualModelsAvailable&&!I(n)&&e(l)});var u=P(c,2),d=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,ek.aliasError)),z(e,t)};V(u,e=>{ek.aliasError&&!I(n)&&e(d)});var f=P(u,2),p=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,xk.modelPricingOverrideError)),z(e,t)};V(f,e=>{xk.modelPricingOverrideError&&!I(n)&&!xk.modelPricingOverrideFormOpen&&e(p)});var m=P(f,2),h=e=>{var t=Oj();H(t,21,()=>Mc.categories,e=>e.category,(e,t)=>{var n=Dj();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F(()=>{r=U(n,1,`category-tab svelte-scpjps`,null,r,{active:Mc.activeCategory===I(t).category}),B(a,I(t).display_name),B(s,I(t).count)}),L(`click`,n,()=>Mc.selectCategory(I(t).category)),z(e,n)}),T(t),z(e,t)};V(m,e=>{Mc.categories.length>0&&e(h)});var g=P(m,2),_=e=>{var t=Aj(),n=M(t);yw(M(n),{placeholder:`Filter by provider, provider/model, alias, or owner...`,label:`Filter models by provider, provider/model, alias, or owner`,get value(){return Mc.filter},set value(e){Mc.filter=e}}),T(n);var r=P(n,2),i=M(r),a=e=>{var t=kj();K(M(t),{get icon(){return fo},class:`alias-create-icon`}),Ue(2),T(t),L(`click`,t,()=>ek.openVirtualModelCreate()),z(e,t)};V(i,e=>{ek.virtualModelsAvailable&&e(a)}),T(r),T(t),z(e,t)};V(g,e=>{(ek.displayModels.length>0||Mc.filter||ek.virtualModelsAvailable)&&e(_)});var v=P(g,2),y=e=>{{let t=O(()=>ek.modelLoadingText());mT(e,{get label(){return I(t)},class:`models-loading-state`})}},b=O(()=>ek.modelsBusy()&&!I(n));V(v,e=>{I(b)&&e(y)});var x=P(v,2);RA(x,{});var S=P(x,2);YA(S,{});var C=P(S,2),w=e=>{vA(e,{})};V(C,e=>{(ek.displayModels.length>0||Mc.filter)&&e(w)});var ee=P(C,2),te=e=>{z(e,jj())};V(ee,e=>{ek.displayModels.length===0&&!Mc.loading&&!I(n)&&!Mc.filter&&(Mc.activeCategory===`all`||!Mc.activeCategory)&&e(te)});var ne=P(ee,2),re=e=>{z(e,Mj())};V(ne,e=>{ek.displayModels.length===0&&!Mc.loading&&!I(n)&&!Mc.filter&&Mc.activeCategory&&Mc.activeCategory!==`all`&&e(re)});var ie=P(ne,2),ae=e=>{z(e,Nj())};V(ie,e=>{ek.displayModels.length>0&&ek.filteredDisplayModels.length===0&&Mc.filter&&e(ae)});var oe=P(ie,2);Cj(oe,{});var se=P(oe,2);FD(se,{});var ce=P(se,2);rj(ce,{}),fj(P(ce,2),{}),T(r),z(e,r),D()}Hr([`click`]);var Ij=`draft-workflow-preview`;function Lj(){return{scope_provider:``,scope_model:``,scope_user_path:``,name:``,description:``,features:{cache:!0,audit:!0,usage:!0,budget:!0,guardrails:!1,failover:!0},guardrails:[]}}function Rj(){return{scope_provider:``,scope_model:``,scope_user_path:``}}function zj(e){return{ref:``,step:Number.isFinite(e)?e:10}}function Bj(e){let t=e==null?``:String(e).trim();if(t===``)return NaN;let n=Number(t);return Number.isFinite(n)?n:NaN}function Vj(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=t.charAt(0).toUpperCase()+t.slice(1);for(let n of[t,r])if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==null&&e[n]!==void 0)return e[n];return n}function Hj(e,t){return!e||typeof e!=`object`||Array.isArray(e)?!1:[t,t.charAt(0).toUpperCase()+t.slice(1)].some(t=>Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==null&&e[t]!==void 0)}function Uj(e){return{cache:!!Vj(e,`cache`,!1),audit:!!Vj(e,`audit`,!1),usage:!!Vj(e,`usage`,!1),budget:Vj(e,`budget`,!0)!==!1,guardrails:!!Vj(e,`guardrails`,!1),failover:Vj(e,`failover`,!0)!==!1}}function Wj(e,t){let n=Uj(e),r=t||{},i=n.usage&&!!r.usage;return{cache:n.cache&&!!r.cache,audit:n.audit&&!!r.audit,usage:i,budget:i&&n.budget&&!!r.budget,guardrails:n.guardrails&&!!r.guardrails,failover:n.failover&&!!r.failover}}function Gj(e,t){let n=e&&e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:e&&e.features?e.features:{};return{...Wj((e&&e.effective_features&&typeof e.effective_features==`object`&&!Array.isArray(e.effective_features)?e.effective_features:null)||n,t),failover:Uj(n).failover}}function Kj(e,t){return Gj(e,t).failover?`On`:`Off`}function qj(e){return(Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:Array.isArray(e&&e.guardrails)?e.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0)}function Jj(e,t){return Gj(e,t).guardrails&&Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[]}function Yj(e){return String(e&&(e.scope_provider_name||e.scope_provider)||``).trim()}function Xj(e){return String(e&&(e.provider_name||e.provider_type)||``).trim()}function Zj(e,t){let n=new Set,r=String(t&&t.scope_provider||``).trim();return r&&n.add(r),(Array.isArray(e)?e:[]).forEach(e=>{let t=Xj(e);t&&n.add(t)}),[...n].sort()}function Qj(e,t,n){let r=String(t||``).trim(),i=new Set,a=String(n&&n.scope_provider||``).trim(),o=String(n&&n.scope_model||``).trim();return r&&r===a&&o&&i.add(o),(Array.isArray(e)?e:[]).forEach(e=>{if(r&&Xj(e)!==r)return;let t=String(e&&e.model&&e.model.id||``).trim();t&&i.add(t)}),[...i].sort()}function $j(e){let t=String(e&&e.scope_type||``).trim();return t===`provider_model`?`Provider Name + Model`:t===`provider_model_path`?`Provider Name + Model + Path`:t===`provider_path`?`Provider Name + Path`:t===`path`?`Path`:t===`provider`?`Provider Name`:`Global`}function eM(e){return String(e&&e.scope_display||`global`).trim()||`global`}function tM(e){let t=String(e&&e.name||``).trim();if(t)return t;let n=eM(e);return n===`global`?`All models`:n}function nM(e){let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function rM(e){if(nM(e))return``;let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function iM(e){let t=e||Lj(),n=String(t.scope_provider||``).trim(),r=rM(t.scope_user_path);return{scope_provider:n,scope_model:n?String(t.scope_model||``).trim():``,scope_user_path:r}}function aM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path);return!t&&!r?`global`:!t&&r?`path`:!n&&!r?`provider`:!n&&r?`provider_path`:r?`provider_model_path`:`provider_model`}function oM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path),i=aM({scope_provider:t,scope_model:n,scope_user_path:r});return i===`global`?`global`:i===`path`?r:i===`provider`?t:i===`provider_path`?t+` @ `+r:i===`provider_model_path`?t+`/`+n+` @ `+r:t+`/`+n}function sM(e,t){let n=t||Rj(),r=Yj(e&&e.scope),i=r?String(e&&e.scope&&e.scope.scope_model||``).trim():``,a=rM(e&&e.scope&&e.scope.scope_user_path);return r===String(n.scope_provider||``).trim()&&i===String(n.scope_model||``).trim()&&a===rM(n.scope_user_path)}function cM(e,t,n){let r=iM(t);return!(r.scope_provider!==``||r.scope_model!==``||r.scope_user_path!==``)&&!n?null:(Array.isArray(e)?e:[]).find(e=>sM(e,r))||null}function lM(e){return String(e&&e.scope_type||``).trim()!==`global`}function uM(e){let t=String(e||``).trim();return t?t.length<=14?t:t.slice(0,12)+`…`:`—`}function dM(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.description,e.scope_display,e.scope_type,Yj(e&&e.scope),e.scope&&e.scope.scope_model,e.scope&&e.scope.scope_user_path,e.workflow_hash,...Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>e.ref):[]].some(e=>String(e||``).toLowerCase().includes(r)))}function fM(e,t){let n=e||Lj(),r=iM(n),i=Uj(n.features||{}),a=Wj(i,t);a.failover=i.failover;let o=!!a.guardrails,s=o?qj(n):[];return{id:Ij,scope_type:aM(r),scope_display:oM(r),scope:{scope_provider_name:r.scope_provider,scope_model:r.scope_model,...r.scope_user_path?{scope_user_path:r.scope_user_path}:{}},name:String(n.name||``).trim(),description:String(n.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!a.cache,audit:!!a.audit,usage:!!a.usage,budget:!!a.budget,guardrails:o,failover:!!a.failover},guardrails:s}}}function pM({form:e,caps:t,workflows:n=[],formHydrated:r=!1,hydratedScope:i=null}){let a=e||Lj(),o=String(a.scope_provider||``).trim(),s=o?String(a.scope_model||``).trim():``,c=rM(a.scope_user_path),l=Uj(a.features||{}),u=Wj(l,t),d=cM(n,a,r),f=d&&d.workflow_payload&&d.workflow_payload.features,p=Hj(f,`failover`),m=p?Vj(f,`failover`,!0)!==!1:null,h=i||Rj(),g=String(h.scope_provider||``).trim()===o&&String(h.scope_model||``).trim()===s&&rM(h.scope_user_path)===rM(c),_=!!(t&&t.failover),v=_||!!r&&g&&Object.prototype.hasOwnProperty.call(l,`failover`)||!r&&!!d&&p,y=u.guardrails?(Array.isArray(a.guardrails)?a.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})):[],b={scope_provider_name:o,scope_model:s,...c?{scope_user_path:c}:{},name:String(a.name||``).trim(),description:String(a.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!u.cache,audit:!!u.audit,usage:!!u.usage,budget:!!u.budget,guardrails:!!u.guardrails},guardrails:y}};return v&&(b.workflow_payload.features.failover=!_&&!r&&d&&p?m:!!l.failover),b}function mM(e,{models:t=[],hydratedScope:n=null}={}){let r=n||Rj(),i=String(r.scope_provider||``).trim(),a=String(r.scope_model||``).trim(),o=String(e&&(e.scope_provider_name||e.scope_provider)||``).trim(),s=String(e&&e.scope_model||``).trim();if(o&&!Zj(t,r).includes(o)&&o!==i)return`Choose a registered provider name.`;if(s&&!o)return`Model selection requires a provider name.`;if(s){let e=Qj(t,o,r),n=o===i&&s===a;if(!e.includes(s)&&!n)return`Choose a registered model for the selected provider name.`}let c=nM(e.scope_user_path);if(c)return c;let l=e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:{},u=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[];if(!l.guardrails)return``;let d=new Set;for(let e of u){if(!e.ref)return`Each guardrail step needs a guardrail ref.`;if(!Number.isInteger(e.step)||e.step<0)return`Each guardrail step must use a non-negative integer step number.`;if(d.has(e.ref))return`Each guardrail ref may appear only once in a workflow.`;d.add(e.ref)}return``}var hM=new class{#e=k(j([]));get workflows(){return I(this.#e)}set workflows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get submitting(){return I(this.#o)}set submitting(e){A(this.#o,e,!0)}#s=k(``);get deactivatingID(){return I(this.#s)}set deactivatingID(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get formHydrated(){return I(this.#l)}set formHydrated(e){A(this.#l,e,!0)}#u=k(j(Rj()));get hydratedScope(){return I(this.#u)}set hydratedScope(e){A(this.#u,e,!0)}#d=k(j([]));get guardrailRefs(){return I(this.#d)}set guardrailRefs(e){A(this.#d,e,!0)}#f=k(j(Lj()));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}#p=null;failoverVisible(){return xs.booleanFlag(`FAILOVER_ENABLED`,!0)}featureCaps(){return{cache:xs.cacheVisible(),audit:xs.auditVisible(),usage:xs.usageVisible(),budget:xs.budgetsVisible(),guardrails:xs.guardrailsVisible(),failover:this.failoverVisible()}}get filteredWorkflows(){return dM(this.workflows,this.filter)}providerOptions(){return Zj(Mc.models,this.hydratedScope)}modelOptions(e){return Qj(Mc.models,e,this.hydratedScope)}activeScopeMatch(){return cM(this.workflows,this.form,this.formHydrated)}submitMode(){return this.activeScopeMatch()?`save`:`create`}submitLabel(){return this.submitMode()===`save`?`Save`:`Create`}submittingLabel(){return this.submitMode()===`save`?`Saving...`:`Creating...`}preview(){return fM(this.form,this.featureCaps())}openCreate(e){if(this.formOpen=!0,this.submitting=!1,this.formError=``,!e){this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj();return}this.formHydrated=!0,this.hydratedScope={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``).trim(),scope_user_path:String(e.scope&&e.scope.scope_user_path||``).trim()};let t=e.workflow_payload&&e.workflow_payload.features?Uj(e.workflow_payload.features):Gj(e,this.featureCaps()),n=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0):qj(e);this.form={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``),scope_user_path:String(e.scope&&e.scope.scope_user_path||``),name:String(e.name||``),description:String(e.description||``),features:{cache:!!t.cache,audit:!!t.audit,usage:!!t.usage,budget:!!t.budget,guardrails:!!t.guardrails,failover:!!t.failover},guardrails:n.map(e=>({ref:String(e&&e.ref||``),step:Number.isFinite(e&&e.step)?e.step:10}))}}closeForm(){this.formOpen=!1,this.submitting=!1,this.formError=``,this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj()}setProvider(e){if(this.form.scope_provider=String(e||``).trim(),!this.form.scope_provider){this.form.scope_model=``;return}this.modelOptions(this.form.scope_provider).includes(String(this.form.scope_model||``).trim())||(this.form.scope_model=``)}addGuardrailStep(){let e=(Array.isArray(this.form.guardrails)?this.form.guardrails:[]).reduce((e,t)=>{let n=Number(t&&t.step);return Number.isFinite(n)?Math.max(e,n):e},0)+10;this.form.guardrails.push(zj(e))}removeGuardrailStep(e){Array.isArray(this.form.guardrails)&&this.form.guardrails.splice(e,1)}buildRequest(){return pM({form:this.form,caps:this.featureCaps(),workflows:this.workflows,formHydrated:this.formHydrated,hydratedScope:this.hydratedScope})}async fetchWorkflows(){this.#p&&this.#p.abort();let e=new AbortController;this.#p=e,this.loading=!0,this.error=``;let t=setTimeout(()=>e.abort(),1e4),n=await _T(`/admin/workflows`,{label:`workflows`,options:{signal:e.signal}});if(clearTimeout(t),this.#p===e&&(this.#p=null,this.loading=!1,n.status!==`stale`)){if(n.status===`unavailable`){this.available=!1,this.workflows=[];return}if(n.result&&(this.available=!0),n.status===`error`){this.workflows=[],this.error=e.signal.aborted?`Loading workflows timed out.`:n.error;return}this.workflows=n.items}}async fetchGuardrailRefs(){let e=await _T(`/admin/workflows/guardrails`,{label:`workflow guardrails`});e.status!==`stale`&&(this.guardrailRefs=e.items)}async fetchPage(){await Promise.all([xs.ensureLoaded(),this.fetchWorkflows(),this.fetchGuardrailRefs()])}async submitForm(){if(this.submitting)return;this.formError=``;let e=this.buildRequest(),t=mM(e,{models:Mc.models,hydratedScope:this.hydratedScope});if(t){this.formError=t;return}this.submitting=!0;try{let t=await vT(`/admin/workflows`,`POST`,e,{label:`create workflow`,unavailableStatuses:[]});if(t.status===`stale`||t.result&&t.result.status===401)return;if(t.status===`error`){this.formError=t.error;return}J.success(`Workflow created and activated.`),this.closeForm(),this.fetchPage()}finally{this.submitting=!1}}async deactivate(e){let t=String(e&&e.id||``).trim();if(!t||this.deactivatingID||!lM(e))return;let n=tM(e);if(confirm(`Deactivate workflow "`+n+`"? Requests will fall back to the next active workflow for this scope.`)){this.deactivatingID=t;try{let e=await vT(`/admin/workflows/`+encodeURIComponent(t)+`/deactivate`,`POST`,void 0,{label:`deactivate workflow`,unavailableStatuses:[]});if(e.status===`stale`||e.result&&e.result.status===401)return;if(e.status===`error`){J.error(e.error);return}J.success(`Workflow deactivated.`),this.fetchPage()}finally{this.deactivatingID=``}}}};function gM(e){let t=String(e??``),n=typeof navigator<`u`?navigator.clipboard:null;if(n&&typeof n.writeText==`function`)return n.writeText(t);let r=typeof document<`u`?document:null;if(!r||!r.body||typeof r.execCommand!=`function`)return Promise.reject(Error(`Clipboard API unavailable`));let i=r.createElement(`textarea`);i.value=t,i.setAttribute(`readonly`,``),i.style.position=`fixed`,i.style.top=`0`,i.style.left=`0`,i.style.opacity=`0`;try{if(r.body.appendChild(i),i.focus(),i.select(),i.setSelectionRange(0,i.value.length),!r.execCommand(`copy`))throw Error(`execCommand copy returned false`)}finally{i.parentNode&&i.parentNode.removeChild(i)}return Promise.resolve()}function _M({resetDelayMs:e=2e3,logPrefix:t}={}){let n=j({copied:!1,error:!1}),r=null;function i(){r!==null&&clearTimeout(r),r=null}function a(){i(),r=setTimeout(()=>{n.copied=!1,n.error=!1,r=null},e)}return{get copied(){return n.copied},get error(){return n.error},reset(){i(),n.copied=!1,n.error=!1},async copy(e,r){if(!(e==null||e===``)){i(),n.copied=!1,n.error=!1;try{await gM(typeof r==`function`?r(e):String(e)),n.copied=!0,n.error=!1}catch(e){console.error(t||`Failed to copy text:`,e),n.copied=!1,n.error=!0}a()}}}}var vM=R(``);function yM(e,t){E(t,!0);let n=G(t,`workflowID`,3,``),r=_M({logPrefix:`Failed to copy workflow ID:`});An(()=>{n(),r.reset()});let i=O(()=>r.error?`Unable to copy workflow ID`:r.copied?`Workflow ID copied`:`Copy workflow ID`),a=O(()=>n()?I(i)+` `+n():I(i));async function o(e){e.preventDefault(),n()&&await r.copy(n())}var s=vM();let c;var l=P(M(s),4),u=M(l,!0);T(l);var d=P(l,2);K(M(d),{get icon(){return Ja}}),T(d),T(s),F(()=>{c=U(s,1,`workflow-pipeline-meta mono svelte-1viff7o`,null,c,{"workflow-pipeline-meta-copied":r.copied,"workflow-pipeline-meta-error":r.error}),W(s,`title`,I(i)),W(s,`aria-label`,I(a)),B(u,n())}),L(`click`,s,o),z(e,s),D()}Hr([`click`]);var bM=(e,t)=>{let n=()=>(t?.()).icon,r=()=>(t?.()).label,i=Ot(()=>h((t?.()).variant,`workflow-node-feature`)),a=()=>(t?.()).state,o=()=>(t?.()).sub,s=()=>(t?.()).badge;var c=wM(),l=M(c),u=e=>{var t=xM();let r;K(M(t),{get icon(){return n()}}),T(t),F(()=>r=U(t,1,`workflow-node-icon svelte-nbptrg`,null,r,{"workflow-node-icon-endpoint":I(i)===`workflow-node-endpoint`})),z(e,t)};V(l,e=>{n()&&e(u)});var d=P(l,2),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var t=SM(),n=M(t,!0);T(t),F(()=>B(n,s())),z(e,t)};V(p,e=>{s()&&e(m)});var g=P(p,2),_=e=>{var t=CM(),n=M(t,!0);T(t),F(()=>B(n,o())),z(e,t)};V(g,e=>{o()&&e(_)}),T(c),F(()=>{U(c,1,Fi([`workflow-node`,I(i),a()]),`svelte-nbptrg`),B(f,r())}),z(e,c)},xM=R(`
            `),SM=R(` `),CM=R(` `),wM=R(`
            `),TM=R(`
            `,1),EM=R(`
            `,1),DM=R(`
            `),OM=R(`
            Async
            `),kM=R(`
            `);function AM(e,t){E(t,!0);let n=G(t,`chart`,19,()=>({}));var r=kM();let i;var a=M(r),o=e=>{yM(e,{get workflowID(){return n().workflowID}})};V(a,e=>{n().workflowID&&e(o)});var s=P(a,2),c=M(s);bM(c,()=>({icon:jo,label:`Client`,variant:`workflow-node-endpoint`}));var l=P(c,4);bM(l,()=>({icon:Xa,label:`Auth`,state:n().authNodeClass,sub:n().authNodeSublabel}));var u=P(l,2),d=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:Xa,label:`Cache`,state:n().cacheNodeClass,badge:n().cacheStatusLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().cacheConnClass]),`svelte-nbptrg`)),z(e,t)};V(u,e=>{n().showCache&&e(d)});var f=P(u,2),p=e=>{var t=EM();bM(P(N(t),2),()=>({icon:Mo,label:`Budget`,state:n().budgetNodeClass,badge:n().budgetStatusLabel})),z(e,t)};V(f,e=>{n().showBudget&&e(p)});var m=P(f,2),h=e=>{var t=EM();bM(P(N(t),2),()=>({icon:wo,label:`Guardrails`,sub:n().guardrailLabel})),z(e,t)};V(m,e=>{n().showGuardrails&&e(h)});var g=P(m,2),_=P(g,2);bM(_,()=>({label:n().aiLabel,variant:`workflow-node-ai`,state:n().aiNodeClass,sub:n().aiSublabel}));var v=P(_,2),y=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:ao,label:`Failover`,state:n().failoverNodeClass,badge:n().failoverStatusLabel,sub:n().failoverTargetLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().failoverConnClass]),`svelte-nbptrg`)),z(e,t)};V(v,e=>{n().showFailover&&e(y)});var b=P(v,2);bM(P(b,2),()=>({icon:Wa,label:`Response`,variant:`workflow-node-endpoint`,state:n().responseNodeClass,sub:n().responseNodeSublabel})),T(s);var x=P(s,2),S=e=>{var t=OM(),r=M(t),i=M(r),a=e=>{bM(e,()=>({icon:Ra,label:`Usage`,variant:`workflow-node-feature workflow-node-async`,state:n().usageNodeClass}))};V(i,e=>{n().showUsage&&e(a)});var o=P(i,2),s=e=>{z(e,DM())};V(o,e=>{n().showUsage&&n().showAudit&&e(s)});var c=P(o,2),l=e=>{bM(e,()=>({icon:Za,label:`Audit Log`,variant:`workflow-node-feature workflow-node-async`,state:n().auditNodeClass}))};V(c,e=>{n().showAudit&&e(l)}),T(r),Ue(4),T(t),z(e,t)};V(x,e=>{n().showAsync&&e(S)}),T(r),F(()=>{i=U(r,1,`workflow-pipeline svelte-nbptrg`,null,i,{"workflow-pipeline-has-meta":n().workflowID}),U(g,1,Fi([`workflow-conn`,n().aiConnClass]),`svelte-nbptrg`),U(b,1,Fi([`workflow-conn`,n().responseConnClass]),`svelte-nbptrg`)}),z(e,r),D()}function jM(e){let t=qj(e).length;return t===0?``:t===1?`1 step`:t+` steps`}function MM(e,t){return t&&t.provider?t.provider:Yj(e&&e.scope)||`AI`}function NM(e,t){return t&&t.model?t.model:e&&e.scope&&e.scope.scope_model||null}function PM(e,t){let n=String(e&&e.id||``).trim();if(n&&n!==`draft-workflow-preview`)return n;let r=String(t&&t.workflow_version_id||``).trim();return r&&r!==`draft-workflow-preview`?r:null}function FM(e){let t=e&&e.data&&e.data.workflow_features;return!t||typeof t!=`object`||Array.isArray(t)?null:Uj(t)}function IM(e){let t=e&&e.data&&e.data.failover;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=String(t.target_model||t.targetModel||``).trim()||null;return n?{targetModel:n}:null}function LM(e,t=0){if(t>4||e==null)return``;if(typeof e==`string`){let n=e.trim();if(!n||n[0]!==`{`&&n[0]!==`[`)return``;try{return LM(JSON.parse(n),t+1)}catch{return``}}if(Array.isArray(e)){for(let n of e){let e=LM(n,t+1);if(e)return e}return``}return typeof e==`object`?String(e.code||``).trim()||(e.error===void 0?``:LM(e.error,t+1)):``}function RM(e){let t=e&&e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{};return String(t.error_code||t.errorCode||``).trim()||LM(t.response_body)}function zM(e){let t=String(e||``).trim();if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{provider:t.slice(0,n),model:t.slice(n+1)}}function BM(e,t){let n=String(e&&(e.requested_model||e.model)||``).trim(),r=IM(e);if(!(r&&r.targetModel))return{provider:String(e&&e.provider||``).trim()||null,model:n||null};let i=zM(n);if(i)return i;let a=Yj(t&&t.scope),o=a?String(t&&t.scope&&t.scope.scope_model||``).trim():``;return a||o?{provider:a||null,model:o||n||null}:{provider:null,model:n||null}}function VM(e,t){if(!e)return null;let n=(()=>{let t=String(e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`?t:null})(),r=(()=>{if(e.status_code===void 0||e.status_code===null)return null;let t=String(e.status_code).trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null})(),i=n?!0:e.cache_hit!==void 0&&e.cache_hit!==null&&!!e.cache_hit,a=IM(e),o=BM(e,t),s=Number.isFinite(r)&&r>=200&&r<300,c=String(e.error_type||``).trim().toLowerCase()===`authentication_error`,l=String(e.auth_method||``).trim().toLowerCase()||null,u=RM(e).toLowerCase()===`budget_exceeded`;return{cacheHit:i,cacheType:n||null,failoverTarget:a&&a.targetModel?a.targetModel:null,provider:o.provider,model:o.model,statusCode:r,responseSuccess:s,aiSuccess:s&&!i,authError:c,authMethod:l,budgetExceeded:u}}function HM(e){return!!(e&&e.cacheHit)}function UM(e){return!!(e&&e.failoverTarget)}function WM(e){return!!(e&&e.budgetExceeded)}function GM(e,t){return t?`workflow-node-current`:e&&e.cacheHit?`workflow-node-success`:``}function KM(e){return e&&e.cacheHit?`workflow-conn-hit`:``}function qM(e){return!e||!e.cacheHit?null:e.cacheType===`semantic`?`Hit (Semantic)`:`Hit (Exact)`}function JM(e,t,n,r){return e?WM(t)?`workflow-node-error`:r?`workflow-node-current`:n?`workflow-node-success`:``:``}function YM(e){return WM(e)?`Exceeded`:null}function XM(e){return e&&e.cacheHit?`workflow-node-skipped`:e&&e.failoverTarget?`workflow-node-success`:``}function ZM(e){return e&&e.cacheHit?`workflow-conn-dim`:e&&e.failoverTarget?`workflow-conn-hit`:``}function QM(e){return e&&e.failoverTarget?`Redirected`:null}function $M(e){return e&&e.failoverTarget?e.failoverTarget:null}function eN(e){return e&&e.cacheHit?`workflow-conn-dim`:``}function tN(e,t){return e?e.cacheHit?`workflow-node-skipped`:t?`workflow-node-current`:e.aiSuccess?`workflow-node-success`:``:``}function nN(e,t){if(!e)return``;let n=e.statusCode;return!Number.isFinite(n)&&t?`workflow-node-current`:Number.isFinite(n)?n>=500?`workflow-node-error`:n>=400?`workflow-node-warning`:n>=300?`workflow-node-neutral`:n>=200?`workflow-node-success`:``:``}function rN(e){return!e||!Number.isFinite(e.statusCode)?null:String(e.statusCode)}function iN(e,t){return e?e.authError?`workflow-node-error`:t?`workflow-node-current`:e.authMethod===`api_key`||e.authMethod===`master_key`?`workflow-node-success`:``:``}function aN(e){return!e||!e.authMethod?null:e.authMethod}function oN(e,t,n){return e?n?`workflow-node-current`:t?`workflow-node-success`:``:``}function sN(e,t){if(!e||!e._live)return!!t;let n=String(e._live_state||``).trim();return!!e._audit_flushed||n===`audit.flushed`||n===`audit.detail`}function cN(e,t){if(!e)return!!t;let n=e.usage||{},r=Number(n.entries||0)>0;if(!e._live)return r;let i=String(e._usage_live_state||``).trim();return e._usage_flushed||i===`usage.flushed`?!0:!e._usage_live_pending&&r&&!e._live_pending}function lN(e){return!!(e&&e._live&&e._usage_live_pending&&!e._usage_flushed)}function uN(e,t){return!e||!e._live||sN(e,!1)?!1:String(e._live_state||``).trim()===`audit.completed`||!!(t&&Number.isFinite(t.statusCode))}function dN(e,t,n){return!e||!e._live?``:lN(e)?`usage`:uN(e,t)?`audit`:sN(e,!1)&&!e._live_pending?``:t&&t.cacheHit?`cache`:t&&(t.provider||t.model)?`ai`:n&&n.budget&&(e.workflow_version_id||e.requested_model)?`budget`:t&&t.authMethod?``:`auth`}function fN(e,t,n,r){let i=n||{},a=i.features&&typeof i.features==`object`&&!Array.isArray(i.features)?Uj(i.features):Gj(e,r),o=!!i.forceAudit,s=!!i.highlightAsyncPresent,c=!!a.budget||WM(t),l=!!a.guardrails,u=!!a.usage,d=o||!!a.audit,f=!!i.forceAsync||!!(u||d),p=!!a.failover||UM(t),m=PM(e,i.entry),h=dN(i.entry,t,a),g=lN(i.entry),_=uN(i.entry,t),v=sN(i.entry,s),y=cN(i.entry,s);return{showBudget:c,budgetNodeClass:JM(c,t,s,h===`budget`),budgetStatusLabel:YM(t),showGuardrails:l,guardrailLabel:l?jM(e):``,showCache:!!i.forceCache||!!a.cache||HM(t),cacheNodeClass:GM(t,h===`cache`),cacheConnClass:KM(t),cacheStatusLabel:qM(t),showFailover:p,failoverNodeClass:p?XM(t):``,failoverConnClass:p?ZM(t):``,failoverStatusLabel:p?QM(t):null,failoverTargetLabel:p?$M(t):null,aiLabel:MM(e,t),aiSublabel:NM(e,t),aiConnClass:eN(t),aiNodeClass:tN(t,h===`ai`),responseConnClass:eN(t),responseNodeClass:nN(t,h===`response`),responseNodeSublabel:rN(t),authNodeClass:iN(t,h===`auth`),authNodeSublabel:aN(t),usageNodeClass:oN(u,y,g),auditNodeClass:oN(d,v,_),showAsync:f,showUsage:u,showAudit:d,workflowID:m}}function pN(e,t){return fN(e,null,{forceCache:!1},t)}function mN(e,t,n){return fN(t,VM(e,t),{entry:e,features:FM(e)||(t?Gj(t,n):{cache:!1,audit:!1,usage:!1,budget:!1,guardrails:!1,failover:!1}),forceAudit:!0,forceAsync:!0,highlightAsyncPresent:!0},n)}var hN=R(`

            `),gN=R(`

            `),_N=R(`
            `),vN=R(`
            `),yN=R(`

            No guardrails configured for this workflow.

            `),bN=R(`

            Guardrails

            `),xN=R(``),SN=R(`

            `);function CN(e,t){E(t,!0);let n=G(t,`preview`,3,!1),r=O(()=>hM.featureCaps()),i=O(()=>tM(t.workflow)),a=O(()=>Jj(t.workflow,I(r))),o=O(()=>pN(t.workflow,I(r))),s=O(()=>n()?`draft-workflow-preview-guardrail-`:t.workflow.id+`-guardrail-`);var c=SN();let l;var u=M(c),d=M(u),f=M(d),p=M(f,!0);T(f);var m=P(f,2),h=M(m,!0);T(m),T(d);var g=P(d,2),_=M(g),v=M(_,!0);T(_),T(g),T(u);var y=P(u,2),b=e=>{var n=hN(),r=M(n,!0);T(n),F(()=>B(r,t.workflow.description)),z(e,n)};V(y,e=>{t.workflow.description&&e(b)});var x=P(y,2),S=e=>{var n=gN(),i=M(n);T(n),F(e=>B(i,`Failover: ${e??``}`),[()=>Kj(t.workflow,I(r))]),z(e,n)},C=O(()=>hM.failoverVisible());V(x,e=>{I(C)&&e(S)});var w=P(x,2);AM(w,{get chart(){return I(o)}});var ee=P(w,2),te=e=>{var t=bN(),n=M(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var o=P(n,2),c=e=>{var t=vN();H(t,23,()=>I(a),(e,t)=>I(s)+t,(e,t)=>{var n=_N(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a);T(a),T(n),F(()=>{B(i,I(t).ref),B(o,`step ${I(t).step??``}`)}),z(e,n)}),T(t),z(e,t)},l=e=>{z(e,yN())};V(o,e=>{I(a).length>0?e(c):e(l,-1)}),T(t),F(()=>B(i,I(a).length?I(a).length+` steps`:`None`)),z(e,t)},ne=O(()=>xs.guardrailsVisible());V(ee,e=>{I(ne)&&e(te)});var re=P(ee,2),ie=e=>{var n=xN(),r=M(n),a=M(r),o=M(a,!0);T(a);var s=P(a,2);{let e=O(()=>`Edit workflow `+I(i));gT(s,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>hM.openCreate(t.workflow),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(r);var c=P(r,2),l=M(c),u=M(l);T(l);var d=P(l,2),f=M(d);T(d);var p=P(d,2),m=M(p);T(p),T(c),T(n),F((e,n,r,s)=>{a.disabled=e,W(a,`aria-label`,`Deactivate workflow `+I(i)),W(a,`title`,n),B(o,hM.deactivatingID===t.workflow.id?`Deactivating...`:`Deactivate`),B(u,`version: v${t.workflow.version??``}`),B(f,`created: ${r??``}`),B(m,`hash: ${s??``}`)},[()=>hM.deactivatingID===t.workflow.id||!lM(t.workflow),()=>lM(t.workflow)?`Deactivate active workflow`:`The global workflow cannot be deactivated.`,()=>us.formatTimestamp(t.workflow.created_at),()=>uM(t.workflow.workflow_hash)]),L(`click`,a,()=>hM.deactivate(t.workflow)),z(e,n)};V(re,e=>{n()||e(ie)}),T(c),F((e,t)=>{l=U(c,1,`workflow-card svelte-1fo9fvq`,null,l,{"workflow-preview-card":n()}),B(p,e),B(h,I(i)),B(v,t)},[()=>$j(t.workflow),()=>eM(t.workflow)]),z(e,c),D()}Hr([`click`]);var wN=R(`

            `),TN=R(``),EN=R(``),DN=R(``),ON=R(``),kN=R(``),AN=R(``),jN=R(``),MN=R(``),NN=R(``),PN=R(``),FN=R(``),IN=R(``),LN=R(`
            No named guardrails are currently registered on this deployment. You can still draft a workflow, but guardrail-backed creation may be rejected.
            `),RN=R(`
            `),zN=R(`
            `),BN=R(`

            No guardrail steps configured yet.

            `),VN=R(`

            Guardrail Steps

            Guardrails in the same numeric step run together. Later steps wait for earlier ones to finish.

            `),HN=R(`

            Leave provider name empty to target all providers and models. Select a provider name without a model to target all models for that configured provider.

            Add a path to scope the workflow to that subtree. Leading slashes are optional and will be normalized; you can enter "team/alpha" or "/team/alpha". Matching checks the deepest user path first, then falls back toward the root.

            If you leave the name empty, the workflow will display as the matched provider/model scope or “All models”.

            Preview

            Live
            `,1);function UN(e,t){E(t,!0);{let t=e=>{KS(e,{copyId:`workflow-help-copy`,label:`workflow help`,text:`Create immutable version. Submitting activates it for the selected scope.`,title:e=>{var t=wN(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>hM.submitMode()===`save`?`Edit Workflow`:`Create Workflow`]),z(e,t)},$$slots:{title:!0}})},n=O(()=>hM.submitLabel()),r=O(()=>hM.submittingLabel()),i=O(()=>hM.submitMode()===`create`?fo:go);bE(e,{get open(){return hM.formOpen},ariaLabel:`Workflow editor`,get error(){return hM.formError},get submitting(){return hM.submitting},get submitLabel(){return I(n)},get submittingLabel(){return I(r)},get submitIcon(){return I(i)},dialogClass:`workflow-editor`,onclose:()=>hM.closeForm(),onsubmit:()=>hM.submitForm(),header:t,children:(e,t)=>{var n=HN(),r=N(n),i=M(r);SE(i,{id:`workflow-scope-provider`,label:`Provider Name`,children:(e,t)=>{var n=EN(),r=M(n);r.value=r.__value=``,H(P(r),16,()=>hM.providerOptions(),e=>e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(n),L(`change`,n,e=>hM.setProvider(e.currentTarget.value)),Gi(n,()=>hM.form.scope_provider,e=>hM.form.scope_provider=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2),o=e=>{SE(e,{id:`workflow-scope-model`,label:`Model`,children:(e,t)=>{var n=DN(),r=M(n);r.value=r.__value=``,H(P(r),17,()=>hM.modelOptions(hM.form.scope_provider),e=>hM.form.scope_provider+`-`+e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t)),i!==(i=I(t))&&(n.value=(n.__value=I(t))??``)}),z(e,n)}),T(n),Gi(n,()=>hM.form.scope_model,e=>hM.form.scope_model=e),z(e,n)},$$slots:{default:!0}})};V(a,e=>{hM.form.scope_provider&&e(o)});var s=P(a,2);SE(s,{id:`workflow-name`,label:`Name`,children:(e,t)=>{var n=ON();na(n),da(n,()=>hM.form.name,e=>hM.form.name=e),z(e,n)},$$slots:{default:!0}}),SE(P(s,2),{id:`workflow-user-path`,label:`User Path`,children:(e,t)=>{var n=kN();na(n),da(n,()=>hM.form.scope_user_path,e=>hM.form.scope_user_path=e),z(e,n)},$$slots:{default:!0}}),T(r);var c=P(r,8);SE(c,{id:`workflow-description`,label:`Description`,children:(e,t)=>{var n=AN();ft(n),da(n,()=>hM.form.description,e=>hM.form.description=e),z(e,n)},$$slots:{default:!0}});var l=P(c,2),u=M(l),d=e=>{var t=jN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.cache,e=>hM.form.features.cache=e),z(e,t)},f=O(()=>xs.cacheVisible());V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var t=MN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.audit,e=>hM.form.features.audit=e),z(e,t)},h=O(()=>xs.auditVisible());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=e=>{var t=NN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.usage,e=>hM.form.features.usage=e),z(e,t)},v=O(()=>xs.usageVisible());V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=PN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.budget,e=>hM.form.features.budget=e),z(e,t)},x=O(()=>xs.budgetsVisible());V(y,e=>{I(x)&&e(b)});var S=P(y,2),C=e=>{var t=FN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.guardrails,e=>hM.form.features.guardrails=e),z(e,t)},w=O(()=>xs.guardrailsVisible());V(S,e=>{I(w)&&e(C)});var ee=P(S,2),te=e=>{var t=IN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.failover,e=>hM.form.features.failover=e),z(e,t)},ne=O(()=>hM.failoverVisible());V(ee,e=>{I(ne)&&e(te)}),T(l);var re=P(l,2),ie=P(M(re),2);{let e=O(()=>hM.preview());CN(ie,{get workflow(){return I(e)},preview:!0})}T(re);var ae=P(re,2),oe=e=>{var t=VN(),n=M(t),r=P(M(n),2);T(n);var i=P(n,2),a=e=>{var t=LN(),n=P(M(t),2);T(t),L(`click`,n,()=>qo.navigate(`guardrails`)),z(e,t)};V(i,e=>{hM.guardrailRefs.length===0&&e(a)});var o=P(i,2),s=e=>{var t=zN();H(t,21,()=>hM.form.guardrails,oi,(e,t,n)=>{var r=RN(),i=M(r),a=M(i);W(a,`for`,`workflow-guardrail-ref-`+n);var o=P(a,2);na(o),W(o,`id`,`workflow-guardrail-ref-`+n),W(o,`aria-label`,`Guardrail reference `+(n+1)),T(i);var s=P(i,2),c=M(s);W(c,`for`,`workflow-guardrail-step-`+n);var l=P(c,2);na(l),W(l,`id`,`workflow-guardrail-step-`+n),W(l,`aria-label`,`Guardrail step `+(n+1)),T(s);var u=P(s,2);T(r),da(o,()=>I(t).ref,e=>I(t).ref=e),da(l,()=>I(t).step,e=>I(t).step=e),L(`click`,u,()=>hM.removeGuardrailStep(n)),z(e,r)}),T(t),z(e,t)},c=e=>{z(e,BN())};V(o,e=>{hM.form.guardrails.length>0?e(s):e(c,-1)}),T(t),L(`click`,r,()=>hM.addGuardrailStep()),z(e,t)},se=O(()=>hM.form.features.guardrails&&xs.guardrailsVisible());V(ae,e=>{I(se)&&e(oe)}),z(e,n)},$$slots:{header:!0,default:!0}})}D()}Hr([`change`,`click`]);var WN=R(`

            Loading workflows...

            `),GN=R(`
            `),KN=R(`

            No active workflows found.

            `),qN=R(`

            No workflows match your filter.

            `),JN=R(`
            `);function YN(e,t){E(t,!0);var n=JN(),r=M(n),i=e=>{var t=WN();xS(M(t),{size:16,label:`Loading workflows`}),Ue(),T(t),z(e,t)};V(r,e=>{hM.loading&&!q.authError&&e(i)});var a=P(r,2),o=e=>{var t=GN();H(t,21,()=>hM.filteredWorkflows,e=>e.id,(e,t)=>{CN(e,{get workflow(){return I(t)}})}),T(t),z(e,t)};V(a,e=>{hM.filteredWorkflows.length>0&&e(o)});var s=P(a,2),c=e=>{z(e,KN())};V(s,e=>{hM.workflows.length===0&&!hM.loading&&!q.authError&&hM.available&&e(c)});var l=P(s,2),u=e=>{z(e,qN())};V(l,e=>{hM.workflows.length>0&&hM.filteredWorkflows.length===0&&!hM.loading&&e(u)}),T(n),z(e,n),D()}var XN=R(``),ZN=R(`
            Workflows feature is unavailable.
            `),QN=R(`
            `),$N=R(`
            `),eP=R(``),tP=R(`
            `);function nP(e,t){E(t,!0),An(()=>{q.refreshTick,hM.fetchPage()});var n=tP(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=XN();K(M(t),{get icon(){return fo},class:`form-action-icon`,"aria-hidden":`true`}),Ue(2),T(t),L(`click`,t,()=>hM.openCreate()),z(e,t)};V(a,e=>{hM.available&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,ZN())};V(s,e=>{!hM.available&&!q.authError&&e(c)});var l=P(s,2),u=e=>{var t=QN(),n=M(t,!0);T(t),F(()=>B(n,hM.error)),z(e,t)};V(l,e=>{hM.error&&!q.authError&&e(u)});var d=P(l,2),f=e=>{var t=$N(),n=M(t);yw(M(n),{placeholder:`Filter by scope, name, hash, or guardrail...`,label:`Filter workflows by scope, name, hash, or guardrail`,get value(){return hM.filter},set value(e){hM.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i,!0);T(i),T(r),T(t),F(()=>B(a,hM.filteredWorkflows.length+` active scopes`)),z(e,t)};V(d,e=>{hM.available&&e(f)});var p=P(d,2);UN(p,{});var m=P(p,2);YN(m,{});var h=P(m,2);H(h,20,()=>hM.guardrailRefs,e=>e,(e,t)=>{var n=eP(),r={};F(()=>{r!==(r=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(h),T(n),z(e,n),D()}Hr([`click`]);function rP(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=Ys}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=iP(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function iP(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}var aP=null;function oP(){return aP===null&&(aP=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`)),!!(aP&&aP.matches)}function sP(e){return oP()?0:e}function cP(e,t){return!t||!t.live?{duration:0}:qs(e,{duration:sP(150)})}var lP=new class{#e=k(j({}));get workflowVersionsByID(){return I(this.#e)}set workflowVersionsByID(e){A(this.#e,e,!0)}workflowVersionRequests={};workflowFeatureCaps(){return{cache:xs.cacheVisible(),audit:xs.auditVisible(),usage:xs.usageVisible(),budget:xs.budgetsVisible(),guardrails:xs.guardrailsVisible(),failover:xs.booleanFlag(`FAILOVER_ENABLED`,!0)}}cacheWorkflowVersion(e){let t=String(e&&e.id||``).trim();return t?(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:e},e):null}cacheMissingWorkflowVersion(e){let t=String(e||``).trim();t&&(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:null})}workflowVersionCacheHas(e){return Object.prototype.hasOwnProperty.call(this.workflowVersionsByID||{},String(e||``).trim())}workflowVersionByID(e){let t=String(e||``).trim();return t&&this.workflowVersionCacheHas(t)?this.workflowVersionsByID[t]:null}async fetchWorkflowVersion(e){let t=String(e||``).trim();if(!t)return null;if(this.workflowVersionCacheHas(t))return this.workflowVersionsByID[t];if(this.workflowVersionRequests[t])return this.workflowVersionRequests[t];let n=(async()=>{let e=typeof AbortController==`function`?new AbortController:null,n=e?setTimeout(()=>e.abort(),1e4):null;try{let n=await gs(`/admin/workflows/`+encodeURIComponent(t),{label:`workflow`,signal:e?e.signal:void 0});if(n.stale)return null;if(n.status===404)return this.cacheMissingWorkflowVersion(t),null;if(!n.ok)return null;let r=n.data;return!r||typeof r!=`object`||Array.isArray(r)?(this.cacheMissingWorkflowVersion(t),null):this.cacheWorkflowVersion(r)}catch(e){return e&&e.name===`AbortError`||console.error(`Failed to fetch workflow version:`,e),null}finally{n!==null&&clearTimeout(n),delete this.workflowVersionRequests[t]}})();return this.workflowVersionRequests[t]=n,n}async prefetchAuditWorkflows(e){let t=[...new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.workflow_version_id||``).trim()).filter(Boolean))];t.length!==0&&await Promise.all(t.map(e=>this.fetchWorkflowVersion(e)))}auditEntryWorkflow(e){let t=String(e&&e.workflow_version_id||``).trim();return t?this.workflowVersionByID(t):null}},uP=6;function dP(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}function fP(e,t=0,n=null){let r=String(e||``).trim();if(!r)return``;if(t>uP)return r;let i=dP(r);return i==null?r:pP(i,t+1,n)||n&&n(i)||r}function pP(e,t=0,n=null,r=null){if(e==null||t>uP)return``;if(typeof e==`string`){let i=dP(e.trim());return i==null?``:pP(i,t+1,n,r)}if(typeof e!=`object`)return``;let i=r||new Set;if(i.has(e))return``;if(i.add(e),Array.isArray(e)){for(let r=0;r=400||gP(t&&t.response_body)}function vP(e){let t=e&&e.data?e.data:null;return t?mP(t.error_message)||(_P(e,t)?pP(t.response_body,0):``):``}function yP(e){if(e==null||String(e).trim()===``)return null;let t=Number(e);return!Number.isInteger(t)||t<0?null:t}function bP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained indefinitely.`:t===1?`Audit logs are retained for 1 day.`:`Audit logs are retained for `+t+` days.`}function xP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained `:`Audit logs are retained for `}function SP(e){let t=yP(e);return t===null?``:t===0?`indefinitely`:t===1?`1 day`:t+` days`}function CP({dateQuery:e,limit:t,offset:n,search:r,method:i,statusCode:a,stream:o}){let s=e;return s+=`&limit=`+t+`&offset=`+n,r&&(s+=`&search=`+encodeURIComponent(r)),i&&(s+=`&method=`+encodeURIComponent(i)),a&&(s+=`&status_code=`+encodeURIComponent(a)),o&&(s+=`&stream=`+encodeURIComponent(o)),s}function wP({sessionId:e,limit:t}){return`session_id=`+encodeURIComponent(e)+`&limit=`+(t||100)+`&offset=0`}function TP(e){return String(e&&e.session_id||``).trim()}function EP(e){let t=Number(e&&e.session_count);return Number.isFinite(t)&&t>1?t:1}function DP(e){return!!TP(e)&&EP(e)>1}function OP(e){return{entries:(Array.isArray(e&&e.sessions)?e.sessions:[]).filter(e=>e&&e.latest).map(e=>({...e.latest,session_id:TP(e.latest)||String(e.session_id||``).trim(),session_count:Number(e.count||1)})),total:Number(e&&e.total||0),limit:Number(e&&e.limit||25),offset:Number(e&&e.offset||0)}}function kP(e,t,n){let r=new Set((Array.isArray(n)?n:[]).flatMap(e=>NP(e))),i=(Array.isArray(t)?t:[]).filter(e=>!NP(e).some(e=>r.has(e))),a=new Set([...r,...i.flatMap(e=>NP(e))]),o=(e&&Array.isArray(e.entries)?e.entries:[]).filter(e=>e&&e._live&&!NP(e).some(e=>a.has(e)));return{entries:[...o,...i],preservedCount:o.length}}function AP(e,t){let n=e||{};if(!t)return n;if(n[t]){let e={...n};return delete e[t],e}return{...n,[t]:!0}}function jP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>TP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=n[e];return}a=!0}),a?i:n}function MP(e){return String(e&&e.id||``).trim()}function NP(e){if(!e)return[];let t=[],n=String(e.id||``).trim(),r=String(e.request_id||``).trim();return n&&t.push(`id:`+n),r&&t.push(`request:`+r),t}function PP(e){return!!(e&&e._live&&e._live_pending&&!e._audit_flushed)}function FP(e){let t=e&&e.customStartDate,n=e&&e.customEndDate;if(!t&&!n)return!0;let r=new Date;if(t){let e=new Date(t);if(e.setHours(0,0,0,0),Number.isFinite(e.getTime())&&re)return!1}return!0}function IP(e,t){return e&&Number(e.offset||0)===0&&!(t&&t.search)&&!(t&&t.method)&&!(t&&t.statusCode)&&!(t&&t.stream)&&FP(t)}function LP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=[];return a.forEach(e=>{let t=NP(e);t.length!==0&&(t.some(e=>o.has(e))||(t.forEach(e=>o.add(e)),s.push(e)))}),s.length===0?r:(r.entries=[...s,...i].slice(0,r.limit||25),r.total=Number(r.total||0)+s.length,r)}function RP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=new Map;i.forEach((e,t)=>{let n=TP(e);n&&!s.has(n)&&s.set(n,t)});let c=[],l=i;return a.forEach(e=>{let t=NP(e);if(t.length===0||t.some(e=>o.has(e)))return;let n=TP(e);if(n&&s.has(n)){let r=s.get(n);l===i&&(l=[...i]),l[r]={...e,session_count:Math.max(EP(l[r]),EP(e))},t.forEach(e=>o.add(e));return}t.forEach(e=>o.add(e)),c.push(e)}),r.entries=[...c,...l].slice(0,r.limit||25),r.total=Number(r.total||0)+c.length,r}function zP(e,t){let n=MP(t),r=e||{};return n?r[n]?{}:{[n]:!0}:r}function BP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>MP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=!0;return}a=!0}),a?i:n}function VP(e){if(e==null)return`-`;let t=Number(e);return Number.isFinite(t)?t<=0?`pending`:t<1e6?Math.round(t/1e3)+` µs`:t<1e9?(t/1e6).toFixed(2)+` ms`:(t/1e9).toFixed(2)+` s`:`-`}function HP(e){if(e==null||e===``)return`status-unknown`;let t=Number(e);return Number.isFinite(t)?t>=500?`status-error`:t>=400?`status-warning`:t>=300?`status-neutral`:`status-success`:`status-unknown`}function UP(e){if(!e||!e._live||!e._live_pending)return!1;let t=String(e._live_state||``).trim();if(t===`audit.completed`||t===`audit.flushed`||t===`audit.detail`)return!1;if(e._response_partial)return!0;if(e.status_code!==null&&e.status_code!==void 0&&e.status_code!==``||Number(e.duration_ns||0)>0||e.error_type||e.error_message)return!1;let n=e.data||{};return!(n.response_headers||n.response_body||n.error_message)}function WP(e){let t=e&&e.data&&e.data.failover;return!t||typeof t!=`object`||Array.isArray(t)?null:String(t.target_model||t.targetModel||``).trim()||null}function GP(e){return(e&&e.data&&Array.isArray(e.data.attempts)?e.data.attempts:[]).map((e,t)=>({...e,seq:Number(e&&e.seq||t+1)})).sort((e,t)=>e.seq-t.seq)}function KP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))}function qP(e){if(!e)return`-`;let t=e.status_code||e.status;return t?String(t):e.success?`ok`:`error`}function JP(e){return String(e&&e.kind||``).trim()||`attempt`}function YP(e){if(!e)return`-`;let t=String(e.provider_name||``).trim(),n=String(e.provider_type||e.provider||``).trim();return t&&n&&t!==n?t+` (`+n+`)`:t||n||`-`}function XP(e){return String(e&&e.model||``).trim()||`-`}function ZP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))?t:[]}function QP(e){return GP(e).length+`×`}function $P(e){let t=GP(e),n=t.filter(e=>!(e&&e.success)).length,r=t.length===1?`attempt`:`attempts`,i=t.length+` provider `+r;return n>0?i+` · `+n+` failed`:i}function eF(e){if(!e)return``;let t=[`#`+Number(e.seq||0)],n=JP(e);n&&n!==`attempt`&&t.push(n),t.push(qP(e));let r=YP(e);r&&r!==`-`&&t.push(r);let i=XP(e);return i&&i!==`-`&&t.push(i),t.push(e.success?`succeeded`:`failed`),t.join(` · `)}function tF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t&&t.response_body!=null?t.response_body:null}return t.response_body!=null&&t.response_body!==``?t.response_body:null}function nF(e){if(!e||e.success)return``;let t=String(e.error_message||``).trim(),n=String(e.error_code||``).trim(),r=String(e.error_type||``).trim();return t&&n?n+`: `+t:t||n||r||`Provider attempt failed`}function rF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t?t.response_headers:null}return t.response_headers||null}function iF(e){let t=Number(e&&e.status_code);return Number.isFinite(t)&&t>0?t:null}function aF(e,t){let n=!!(t&&t.success),r=e&&e.data?e.data:null,i=tF(e,t),a=rF(e,t),o=nF(t),s=i!=null&&i!==``,c=JP(t),l=GP(e).length<=1;return{title:`Response`,direction:`response`,seq:l?0:Number(t&&t.seq||0),kind:l||c===`attempt`?``:c,statusCode:l?null:iF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:i,showErrorMessage:!!o,errorMessage:o,showHeaders:!!a,headers:a,showBody:s,body:i,showEmpty:!o&&!s&&!a,emptyMessage:`No response was captured for this attempt.`,showTooLarge:!!(n&&r&&r.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function oF(e){return e&&e.data&&Array.isArray(e.data.request_revisions)?e.data.request_revisions:[]}function sF(e){return oF(e).filter(e=>!(e&&e.no_change))}function cF(e){return oF(e).filter(e=>e&&e.no_change).map(e=>{let t=String(e.rewriter||`rewriter`);return{id:`step-`+Number(e.seq||0),rewriter:t,label:t+`: no change`,title:t+` ran and forwarded the request unchanged`}})}function lF(e){let t=Number(e&&e.bytes_before),n=Number(e&&e.bytes_after);if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n>=t)return``;let r=(1-n/t)*100;return`-`+(r>=10?String(Math.round(r)):r.toFixed(1))+`%`}function uF(e,t){let n=t&&t.body,r=n!=null&&n!==``,i=sF(e).length<=1,a={rewriter:t&&t.rewriter||``,bytes:Number(t&&t.bytes_before||0)+` → `+Number(t&&t.bytes_after||0)};return t&&t.detail!=null&&(a.detail=t.detail),{title:`Rewritten`,direction:`request`,seq:i?0:Number(t&&t.seq||0),kind:t&&t.rewriter?String(t.rewriter):``,savingsLabel:lF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:n,showErrorMessage:!1,errorMessage:null,showHeaders:!0,headers:a,headersTitle:`What changed`,showBody:r,body:n,showEmpty:!1,emptyMessage:``,showTooLarge:!r,tooLargeMessage:`Rewritten body not captured (body logging disabled or body too large).`}}function dF(e){let t=e&&e.usage;return!t||typeof t!=`object`?null:t}function fF(e){let t=dF(e);return Number(t&&t.cached_input_tokens||0)>0}function pF(e){let t=dF(e),n=Number(t&&t.input_tokens||0),r=Number(t&&t.cached_input_tokens||0);return!Number.isFinite(n)||n<=0||!Number.isFinite(r)||r<=0?0:Math.max(0,Math.min(100,r/n*100))}function mF(e){let t=dF(e);if(!t)return``;let n=Number(t.input_tokens||0),r=Number(t.cached_input_tokens||0);return n<=0?ac(r)+` cached`:pF(e).toFixed(1)+`% cached`}function hF(e){return fF(e)?mF(e):``}function gF(e,t){let n=dF(e);if(!n||!e||!e.data||!e.data.request_body)return null;let r=Number(n.estimated_cached_characters||0);if(!Number.isFinite(r)||r<=0||typeof t!=`function`)return null;let i=t(e.data.request_body);return!Array.isArray(i)||i.length===0?null:{characters:r,segments:i}}function _F(e,t){let n=e&&e.data?e.data:null,r=!n||!n.request_headers&&!n.request_body,i=r&&UP(e);return{title:`Request`,direction:`request`,layout:`split`,entry:e,copyHeaders:n&&n.request_headers,copyBody:n&&n.request_body,showErrorMessage:!1,errorMessage:null,showHeaders:!!(n&&n.request_headers),headers:n&&n.request_headers,showBody:!!(n&&n.request_body),body:n&&n.request_body,bodyCacheRatioLabel:hF(e),promptCacheHighlight:gF(e,t),noChangeSteps:cF(e),showEmpty:r&&!i,emptyMessage:`Request details were not captured.`,showPending:i,pendingMessage:`Waiting for request data…`,showTooLarge:!!(n&&n.request_body_too_big_to_handle),tooLargeMessage:`Request body was too large to capture.`}}function vF(e){let t=e&&e.data?e.data:null,n=vP(e),r=!t||!n&&!t.response_headers&&!t.response_body,i=r&&UP(e);return{title:`Response`,direction:`response`,layout:`split`,entry:e,copyHeaders:t&&t.response_headers,copyBody:t&&t.response_body,showErrorMessage:!!n,errorMessage:n,showHeaders:!!(t&&t.response_headers),headers:t&&t.response_headers,showBody:!!(t&&t.response_body),body:t&&t.response_body,streaming:!!(e&&e._response_partial&&t&&t.response_body)&&UP(e),showEmpty:r&&!i,emptyMessage:`Response details were not captured.`,showPending:i,pendingMessage:`Response in progress…`,showTooLarge:!!(t&&t.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function yF(e,t){let n=[{id:`request`,pane:_F(e,t)}];return sF(e).forEach(t=>{n.push({id:`revision-`+Number(t&&t.seq||0),pane:uF(e,t)})}),KP(e)?GP(e).forEach(t=>{n.push({id:`response-`+Number(t&&t.seq||0),pane:aF(e,t)})}):n.push({id:`response`,pane:vF(e)}),n}function bF(e){if(!KP(e))return`response`;let t=GP(e),n=null;return t.forEach(e=>{e&&e.success&&(n=e)}),n||=t[t.length-1],n?`response-`+Number(n.seq||0):`request`}function xF(e,t,n){return e&&(Array.isArray(n)?n:yF(t)).some(t=>t.id===e)?e:bF(t)}function SF(e,t,n){if(!t||!t.length)return null;let r=t.indexOf(n);r<0&&(r=0);let i;switch(e){case`ArrowRight`:case`ArrowDown`:i=(r+1)%t.length;break;case`ArrowLeft`:case`ArrowUp`:i=(r-1+t.length)%t.length;break;case`Home`:i=0;break;case`End`:i=t.length-1;break;default:return null}return t[i]}var CF=100;function wF(){return{entries:[],total:0,limit:25,offset:0}}var TF=new class{#e=k(j({}));get auditExpandedEntries(){return I(this.#e)}set auditExpandedEntries(e){A(this.#e,e,!0)}#t=k(j({}));get auditExpandedThreads(){return I(this.#t)}set auditExpandedThreads(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}auditFetchToken=0;get auditLog(){return jC.auditLog}set auditLog(e){jC.auditLog=e}get auditSearch(){return jC.auditSearch}set auditSearch(e){jC.auditSearch=e}get auditMethod(){return jC.auditMethod}set auditMethod(e){jC.auditMethod=e}get auditStatusCode(){return jC.auditStatusCode}set auditStatusCode(e){jC.auditStatusCode=e}get auditStream(){return jC.auditStream}set auditStream(e){jC.auditStream=e}get auditGroupSessions(){return jC.auditGroupSessions}liveFilters(){return{search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream,customStartDate:jc.customStartDate,customEndDate:jc.customEndDate}}toggleAuditGroupSessions(){jC.auditGroupSessions=!jC.auditGroupSessions,Ta(`gomodel_audit_group_sessions`,jC.auditGroupSessions),this.auditExpandedThreads={},jC.auditThreadChildren={},this.fetchAuditLog(!0)}async fetchAuditLog(e){let t=++this.auditFetchToken;this.loading=!0;try{e&&(this.auditLog.offset=0);let n=this.auditGroupSessions,r=CP({dateQuery:jc.queryStr(),limit:this.auditLog.limit,offset:this.auditLog.offset,search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream}),i=await gs((n?`/admin/audit/sessions?`:`/admin/audit/log?`)+r,{label:`audit log`});if(i.stale||t!==this.auditFetchToken)return;if(!i.ok){this.auditLog=wF();return}let a=n?OP(i.data):i.data,o=(n?RP:LP)(a,this.auditLog&&this.auditLog.entries,this.liveFilters());Array.isArray(o.entries)||(o.entries=[]),o.entries=jC.upsertAuditRecords(o.entries,`audit.list`),this.auditLog=o,this.auditExpandedThreads=jP(this.auditExpandedThreads,o.entries),jC.auditThreadChildren=jP(jC.auditThreadChildren,o.entries);let s=[...o.entries,...this.loadedThreadChildren()];this.auditExpandedEntries=BP(this.auditExpandedEntries,s);try{await lP.prefetchAuditWorkflows(s)}catch(e){console.error(`Failed to prefetch audit workflows:`,e)}}catch(e){if(console.error(`Failed to fetch audit log:`,e),t!==this.auditFetchToken)return;this.auditLog=wF()}finally{t===this.auditFetchToken&&(this.loading=!1)}}loadedThreadChildren(){let e=jC.auditThreadChildren||{};return Object.keys(e).flatMap(t=>Array.isArray(e[t]&&e[t].entries)?e[t].entries:[])}isThreadExpanded(e){return!!(e&&this.auditExpandedThreads[e])}threadChildren(e){return e&&jC.auditThreadChildren[e]||null}async toggleThread(e){let t=TP(e);if(!t)return;let n=!this.isThreadExpanded(t);this.auditExpandedThreads=AP(this.auditExpandedThreads,t);let r=jC.auditThreadChildren[t];n&&!(r&&(r.loaded||r.loading))&&await this.fetchThreadEntries(e)}async fetchThreadEntries(e){let t=TP(e);if(!t)return;let n=jC.auditThreadChildren[t];jC.auditThreadChildren={...jC.auditThreadChildren,[t]:{loading:!0,loaded:!1,entries:n&&Array.isArray(n.entries)?n.entries:[],total:Number(n&&n.total||0)}};let r=()=>{let e={...jC.auditThreadChildren},n=e[t],r=n&&Array.isArray(n.entries)?n.entries:[];r.length>0?e[t]={loading:!1,loaded:!1,entries:r,total:r.length}:(delete e[t],this.auditExpandedThreads[t]&&(this.auditExpandedThreads=AP(this.auditExpandedThreads,t))),jC.auditThreadChildren=e};try{let n=await gs(`/admin/audit/log?`+wP({sessionId:t,limit:CF}),{label:`audit session`});if(n.stale){r();return}if(!n.ok)throw Error(`audit session fetch failed`);let i=jC.auditThreadChildren[t],a=this.auditLog.entries.find(e=>TP(e)===t),o=kP(i,n.data.entries,a?[a]:[e]);o.entries=jC.upsertAuditRecords(o.entries,`audit.thread`),jC.auditThreadChildren={...jC.auditThreadChildren,[t]:{loading:!1,loaded:!0,entries:o.entries,total:Number(n.data.total||0)+o.preservedCount}}}catch(e){console.error(`Failed to fetch audit session entries:`,e),r()}}clearAuditFilters(){this.auditSearch=``,this.auditMethod=``,this.auditStatusCode=``,this.auditStream=``,this.fetchAuditLog(!0)}auditLogNextPage(){this.auditLog.offset+this.auditLog.limit0&&(this.auditLog.offset=Math.max(0,this.auditLog.offset-this.auditLog.limit),this.fetchAuditLog(!1))}isAuditEntryExpanded(e){let t=MP(e);return t?!!(this.auditExpandedEntries&&this.auditExpandedEntries[t]):!1}toggleAuditEntryExpanded(e){this.auditExpandedEntries=zP(this.auditExpandedEntries,e);let t=this.isAuditEntryExpanded(e);return t&&typeof jC.fetchAuditEntryDetail==`function`&&jC.fetchAuditEntryDetail(e),t}expandAuditEntry(e){this.isAuditEntryExpanded(e)||this.toggleAuditEntryExpanded(e)}};jC.fetchAuditLog=e=>TF.fetchAuditLog(e),jC.isAuditEntryExpanded=e=>TF.isAuditEntryExpanded(e);var EF=R(`
            `);function DF(e,t){E(t,!0);let n=bw(()=>TF.fetchAuditLog(!0));An(()=>n.cancel);var r=EF(),i=M(r);yw(M(i),{id:`audit-filter-search`,placeholder:`Search by request ID, model, provider, path, user path, or error...`,label:`Search by request ID, model, provider, path, user path, or error`,get oninput(){return n},get value(){return TF.auditSearch},set value(e){TF.auditSearch=e}}),T(i);var a=P(i,2),o=M(a),s=M(o);s.value=s.__value=``;var c=P(s);c.value=c.__value=`GET`;var l=P(c);l.value=l.__value=`POST`;var u=P(l);u.value=u.__value=`PUT`;var d=P(u);d.value=d.__value=`PATCH`;var f=P(d);f.value=f.__value=`DELETE`,T(o);var p=P(o,2),m=M(p);m.value=m.__value=``;var h=P(m);h.value=h.__value=`200`;var g=P(h);g.value=g.__value=`201`;var _=P(g);_.value=_.__value=`400`;var v=P(_);v.value=v.__value=`401`;var y=P(v);y.value=y.__value=`403`;var b=P(y);b.value=b.__value=`404`;var x=P(b);x.value=x.__value=`429`;var S=P(x);S.value=S.__value=`500`;var C=P(S);C.value=C.__value=`502`;var w=P(C);w.value=w.__value=`503`;var ee=P(w);ee.value=ee.__value=`504`,T(p);var te=P(p,2),ne=M(te);ne.value=ne.__value=``;var re=P(ne);re.value=re.__value=`true`;var ie=P(re);ie.value=ie.__value=`false`,T(te);var ae=P(te,2);K(M(ae),{get icon(){return Fo},class:`table-icon-svg`}),Ue(2),T(ae),T(a),T(r),L(`change`,o,()=>TF.fetchAuditLog(!0)),Gi(o,()=>TF.auditMethod,e=>TF.auditMethod=e),L(`change`,p,()=>TF.fetchAuditLog(!0)),Gi(p,()=>TF.auditStatusCode,e=>TF.auditStatusCode=e),L(`change`,te,()=>TF.fetchAuditLog(!0)),Gi(te,()=>TF.auditStream,e=>TF.auditStream=e),L(`click`,ae,()=>TF.clearAuditFilters()),z(e,r),D()}Hr([`change`,`click`]);var OF=R(`Live stream connecting…`),kF=R(` `),AF=R(`Live`),jF=R(` `);function MF(e,t){E(t,!0);let n=O(()=>jC.auditLivePauseReason()),r=O(()=>jC.liveLogsStreaming&&!I(n));var i=Qr(),a=N(i),o=e=>{var t=jF(),i=M(t);let a;var o=P(i,2),s=e=>{z(e,OF())},c=e=>{var t=kF(),r=M(t,!0);T(t),F(e=>B(r,e),[()=>yC(I(n))]),z(e,t)},l=e=>{z(e,AF())};V(o,e=>{jC.liveLogsStreaming?I(n)?e(c,1):e(l,-1):e(s)}),T(t),F(()=>a=U(i,1,`live-dot svelte-tve6yv`,null,a,{"is-streaming":I(r)})),z(e,t)},s=O(()=>xs.liveLogsVisible());V(a,e=>{I(s)&&e(o)}),z(e,i),D()}var NF=R(` `),PF=R(``);function FF(e,t){E(t,!0);let n=O(()=>[{key:`provider`,text:hc(t.entry)||`-`},{key:`model`,text:t.entry.requested_model||t.entry.model||`-`,mono:!0},{key:`user_path`,text:t.entry.user_path,mono:!0},{key:`request_id`,text:`request_id: `+(t.entry.request_id||`-`),mono:!0},{key:`ip`,text:t.entry.client_ip&&`ip: `+t.entry.client_ip,mono:!0},{key:`auth_key_id`,text:t.entry.auth_key_id&&`auth_key_id: `+t.entry.auth_key_id,mono:!0},{key:`alias`,text:t.entry.alias_used&&`alias`,class:`audit-alias-badge`},{key:`resolved`,text:t.entry.alias_used&&t.entry.resolved_model&&`resolved: `+vc(t.entry),mono:!0},{key:`failover`,text:WP(t.entry)&&`failover: `+WP(t.entry),mono:!0},{key:`stream`,text:t.entry.stream&&`stream`},{key:`error_type`,text:t.entry.error_type}].filter(e=>!!e.text));var r=PF(),i=P(M(r),2);H(i,21,()=>I(n),e=>e.key,(e,t)=>{var n=NF(),r=M(n,!0);T(n),F(()=>{U(n,1,Fi([`provider-badge`,I(t).class,{mono:I(t).mono}]),`svelte-hyopt0`),B(r,I(t).text)}),z(e,n)}),T(i),T(r),z(e,r),D()}var IF=R(``),LF=R(` `);function RF(e,t){E(t,!0);let n=O(()=>ZP(t.entry)),r=O(()=>I(n).length>0?$P(t.entry):``),i=O(()=>I(n).length>0?QP(t.entry):``);var a=Qr(),o=N(a),s=e=>{var a=LF(),o=M(a);H(o,21,()=>I(n),e=>t.entry.id+`-pip-`+e.seq,(e,t)=>{var n=IF();let r;F(e=>{r=U(n,1,`audit-attempt-pip svelte-1eu22xn`,null,r,{"audit-attempt-success":!!(I(t)&&I(t).success),"audit-attempt-error":!(I(t)&&I(t).success)}),W(n,`title`,e)},[()=>eF(I(t))]),z(e,n)}),T(o);var s=P(o,2),c=M(s,!0);T(s),T(a),F(()=>{W(a,`title`,I(r)),W(a,`aria-label`,I(r)),B(c,I(i))}),z(e,a)};V(o,e=>{I(n).length>0&&e(s)}),z(e,a),D()}var zF=new Set([`instructions`,`messages`,`input`,`previous_response_id`,`choices`,`output`]);function BF(e){if(!e||typeof e!=`object`)return``;let t=String(e.type||``).toLowerCase();if(t===`image`||t===`image_url`||t===`input_image`||t===`output_image`)return`[Image]`;if(t===`audio`||t===`input_audio`||t===`output_audio`)return`[Audio]`;if(t===`file`||t===`input_file`||t===`output_file`){let t=String(e.filename||e.name||``).trim();return t?`[File: `+t+`]`:`[File]`}return typeof e.refusal==`string`?e.refusal:``}function VF(e){if(e==null)return``;if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:!e||typeof e!=`object`?``:typeof e.text==`string`?e.text:typeof e.output_text==`string`?e.output_text:BF(e)).filter(Boolean).join(` -`).trim();if(typeof e==`object`){if(typeof e.text==`string`)return e.text.trim();try{return JSON.stringify(e,null,2)}catch{return``}}return String(e).trim()}function HF(e){return!e||typeof e!=`object`?``:VF(e.content)||(typeof e.refusal==`string`?e.refusal.trim():``)}function UF(e){if(e==null)return[];if(typeof e==`string`)return e?[e]:[];if(Array.isArray(e))return e.flatMap(e=>typeof e==`string`?e?[e]:[]:!e||typeof e!=`object`?[]:typeof e.text==`string`?e.text?[e.text]:[]:typeof e.output_text==`string`&&e.output_text?[e.output_text]:[]);if(typeof e==`object`)return typeof e.text==`string`&&e.text?[e.text]:[];let t=String(e);return t?[t]:[]}function WF(e){let t=Number(e&&e.usage&&e.usage.estimated_cached_characters||0);return Number.isFinite(t)&&t>0?Math.floor(t):0}function GF(e,t){if(!e)return null;let n=(Array.isArray(t)?t:[]).reduce((e,t)=>e+String(t||``).length,0),r=Math.min(String(e).length,n);return r>0?{total:r}:null}function KF(e){let t=e&&e.arguments!==void 0?e.arguments:``,n=``;if(typeof t==`string`)n=t;else try{n=JSON.stringify(t)}catch{n=String(t)}return(String(e&&e.name||``)+`(`+n+`)`).length}function qF(e){return{characters:(Array.isArray(e)?e:[]).map(KF)}}function JF(e,t){let n=Math.max(0,Number(t||0));return e.map(e=>{if(!e||e.role===`error`)return e;let t=Math.max(0,Number(e._promptTextCharacters||0)),r=Math.min(n,t);n-=r;let i=0;(Array.isArray(e._toolPromptCharacters)?e._toolPromptCharacters:[]).forEach(e=>{let t=Math.max(0,Number(e||0)),r=Math.min(n,t);n-=r,i+=r});let a=t+(e._toolPromptCharacters||[]).reduce((e,t)=>e+Math.max(0,Number(t||0)),0);return{...e,promptCacheRatio:a>0?(r+i)/a:0}})}function YF(e){if(e==null)return[];if(typeof e==`string`){let t=e.trim();return t?[{role:`user`,text:t}]:[]}if(!Array.isArray(e)){let t=VF(e);return t?[{role:`user`,text:t}]:[]}return e.map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e.role||`user`).toLowerCase(),n=VF(e.content);return n?{role:t,text:n}:null}).filter(Boolean)}function XF(e){return!e||typeof e!=`object`?``:Array.isArray(e.content)?e.content.map(e=>e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` -`).trim():VF(e.content)}function ZF(e){if(!e||typeof e!=`object`)return[];let t=[];return t.push(...UF(e.instructions)),Array.isArray(e.messages)&&e.messages.forEach(e=>{!e||typeof e!=`object`||t.push(...UF(e.content))}),typeof e.input==`string`?t.push(e.input):Array.isArray(e.input)?e.input.forEach(e=>{!e||typeof e!=`object`||(t.push(...UF(e.content)),typeof e.text==`string`&&t.push(e.text))}):e.input&&typeof e.input==`object`&&(t.push(...UF(e.input.content)),typeof e.input.text==`string`&&t.push(e.input.text)),t.map(e=>String(e||``)).filter(e=>e.length>0)}var QF=e=>VF(e);function $F(e){if(!e||!e.data)return``;let t=pP(e.data.response_body,0,QF);if(t)return t;let n=e.data.error_message;if(n==null)return``;if(typeof n==`string`){let e=n.trim();return e?pP(dP(e),0,QF)||e:``}return pP(n,0,QF)||VF(n)}function eI(e){return Array.isArray(e)?e.some(e=>!e||typeof e!=`object`?!1:e.type===`message`||e.role===`assistant`||e.role===`user`||e.role===`system`?!0:Array.isArray(e.content)?e.content.some(e=>!e||typeof e!=`object`?!1:typeof e.text==`string`||e.type===`output_text`||e.type===`input_text`):!1):!1}function tI(e){if(!e)return!1;let t=String(e).toLowerCase();return t===`/v1/embeddings`||t===`/v1/embeddings/`||t.startsWith(`/v1/embeddings?`)||t.startsWith(`/v1/embeddings/`)}function nI(e){return e?!!iI(e):!1}function rI(e){let t=String(e||``).trim().split(`?`)[0].replace(/\/+$/,``).toLowerCase();return t.startsWith(`/v1/`)?t.slice(3):t}function iI(e){switch(rI(e)){case`/chat/completions`:return`chat`;case`/responses`:return`responses`;case`/messages`:return`messages`;default:return``}}function aI(e){if(!e||typeof e!=`object`)return null;try{return JSON.parse(JSON.stringify(e))}catch{return null}}function oI(e,t){if(!t||typeof t!=`object`)return;let n=e[e.length-1];try{if(n&&JSON.stringify(n)===JSON.stringify(t))return}catch{}e.push(t)}function sI(e){let t=iI(e&&e.path),n=e&&e.data&&e.data.request_body;return!t||!n||typeof n!=`object`?!1:t!==`responses`||(e.data&&e.data.response_body&&typeof e.data.response_body.id==`string`?e.data.response_body.id.trim():``)!==``||WI(n)!==``}function cI(e,t){let n=String(t||``).trim(),r=iI(e&&e.path),i=aI(e&&e.data&&e.data.request_body);if(!n||!r||!i)return null;let a=e&&e.data?e.data.response_body:null;if(r===`responses`){let e=a&&typeof a.id==`string`?a.id.trim():``,t=WI(i);return!e&&!t?null:(i.input=n,e&&!t?i.previous_response_id=e:delete i.previous_response_id,i)}let o=Array.isArray(i.messages)?i.messages:[];if(r===`chat`){let e=a&&Array.isArray(a.choices)?a.choices[0]:null;e&&e.message&&oI(o,aI(e.message)),o.push({role:`user`,content:n})}else a&&a.content!==void 0&&oI(o,{role:String(a.role||`assistant`),content:aI(a.content)||a.content}),o.push({role:`user`,content:n});return i.messages=o,i}var lI=new Set(`authorization.proxy-authorization.cookie.content-type.content-length.host.accept.connection.accept-encoding.content-encoding.transfer-encoding.user-agent.date.expect.upgrade.via.te.trailer.keep-alive.origin.referer.forwarded.x-real-ip.traceparent.tracestate.x-request-id.idempotency-key.x-idempotency-key.x-gomodel-timezone.x-gomodel-interaction-parent`.split(`.`));function uI(e,t,n=``){let r=e&&e.data&&e.data.request_headers,i={};return r&&typeof r==`object`&&Object.keys(r).forEach(e=>{let t=String(e).toLowerCase(),n=String(r[e]==null?``:r[e]);!e||!n||n===`[REDACTED]`||lI.has(t)||t.startsWith(`sec-`)||t.startsWith(`cf-`)||t.startsWith(`x-forwarded-`)||(i[e]=n)}),i[`X-GoModel-Interaction-Parent`]=String(t||e&&e.id||``).trim(),String(n||``).trim()&&(i[`X-Request-ID`]=String(n).trim()),i}function dI(e,t){let n=String(t||``).trim();return!n||!Array.isArray(e)?null:e.find(e=>String(e&&e.request_id||``).trim()===n)||null}function fI(e,t,n,r,i){let a=Array.isArray(e)?e:[],o=String(i&&i.id||``).trim(),s=String(i&&i.request_id||``).trim(),c=String(i&&i.session_id||``).trim(),l=String(r||``).trim(),u=pI(i),d=a.some(e=>o&&String(e&&e.id||``).trim()===o||s&&String(e&&e.request_id||``).trim()===s),f=!!l&&s===l,p=!!n&&c===String(n).trim(),m=!!u&&(u===String(t||``).trim()||a.some(e=>String(e&&e.id||``).trim()===u)),h=d||f||!l&&(p||m);return{accepted:h,submittedChild:f,followUpRequestID:h&&f&&o?``:l}}function pI(e){let t=e&&e.data&&e.data.request_headers;if(!t||typeof t!=`object`)return``;let n=Object.keys(t).find(e=>e.toLowerCase()===`x-gomodel-interaction-parent`);return n?String(t[n]||``).trim():``}function mI(e,t){return!Array.isArray(e)||!t?null:e.find(e=>String(e&&e.id||``)===String(t))||null}function hI(e){return!Array.isArray(e)||e.length===0?null:e.reduce((e,t)=>e?GI(t,e)>=0?t:e:t,null)}function gI(e,t){let n=new Set(Array.isArray(t)?t.map(String):[]);return hI((Array.isArray(e)?e:[]).filter(e=>{let t=String(e&&e.id||``);return n.has(t)&&e&&e.data&&e.data.request_body!=null}))}function _I(e,t){let n=hI(e);return!!n&&String(n.id||``)===String(t||``)}function vI(e,t,n){return String(e||``).trim()===`audit.flushed`&&String(t||``).trim()!==``&&String(t||``).trim()===String(n||``).trim()}function yI(e,t){let n=Array.isArray(e)?e.filter(Boolean).map(String):[];return(Array.isArray(t)?t:[]).forEach(e=>{let t=String(e&&(e.id||e.request_id)||``).trim();t&&!n.includes(t)&&n.push(t)}),n}function bI(e){if(e&&e.conversation_payload)return!0;let t=e&&e.data?e.data.request_body:null,n=e&&e.data?e.data.response_body:null,r=t&&(Array.isArray(t.messages)||t.input!==void 0||typeof t.instructions==`string`||typeof t.previous_response_id==`string`),i=n&&(Array.isArray(n.choices)||eI(n.output));return!!(r||i)}function xI(e){return!e||tI(e.path)?!1:nI(e.path)||bI(e)}function SI(e){let t=0,n=!1,r=!1,i=String(e||``);for(let e=0;e0&&a+1`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function EI(e){return!!(e&&typeof e==`object`&&e.__audio__===!0)}function DI(e){let t=Number(e||0);if(!Number.isFinite(t)||t<=0)return`0 B`;let n=[`B`,`KB`,`MB`,`GB`],r=0,i=t;for(;i>=1024&&r`
            `+TI(t)+``+TI(kI(e[t]))+`
            `);return t.length?``:``}function jI(e){let t=OI(e.content_type),n=TI(t+` · `+DI(e.bytes)),r=AI(e.meta);if(e.stored&&e.encoding===`base64`&&e.data){let i=String(e.data).replace(/[^A-Za-z0-9+/=]/g,``);return`
            `+n+`
            `+r+`
            `}let i=e.too_large?`Audio too large to store.`:`Audio not logged. Set LOGGING_LOG_AUDIO_BODIES=true to capture playable audio.`;return`
            `+n+`
            `+TI(i)+`
            `+r+`
            `}function MI(e){try{return JSON.stringify(String(e)).slice(1,-1)}catch{return``}}function NI(e){if(!e||typeof e!=`object`)return null;let t=Number(e.characters||0);if(!Number.isFinite(t)||t<=0)return null;let n=Array.isArray(e.segments)?e.segments.map(e=>String(e||``)).filter(Boolean):[];return n.length===0?null:{remaining:Math.floor(t),segments:n,segmentIndex:0}}function PI(e,t){if(!t||t.remaining<=0||t.segmentIndex>=t.segments.length)return TI(e);let n=``,r=0,i=0;for(;t.remaining>0&&t.segmentIndex`+TI(l)+``,r=s+l.length,i=s+o.length,t.remaining-=c,c>=a.length){t.segmentIndex++;continue}break}return n?n+TI(e.slice(r)):TI(e)}function FI(e,t,n){let r=n&&typeof n.formatJSON==`function`?n.formatJSON:e=>String(e),i=n&&typeof n.canShowConversation==`function`?n.canShowConversation:()=>!1,a=NI(n&&n.promptCacheHighlight),o=r(t);if(!o||o===`Not captured`)return TI(o);if(!i(e))return o.split(` -`).map(e=>PI(e,a)).join(` -`);let s=o.split(` -`),c=[],l=0;for(;lPI(e,a)).join(` -`);c.push(``+o+``),l=r+1;continue}c.push(PI(e,a)),l++}return c.join(` -`)}function II(e){let t=String(e||``).toLowerCase();return t===`system`||t===`developer`?{role:`system`,label:`System Prompt`,className:`role-system`}:t===`assistant`?{role:`assistant`,label:`Agent`,className:`role-assistant`}:t===`error`?{role:`error`,label:`Error`,className:`role-error`}:t===`function_call`?{role:`function_call`,label:`Function Call`,className:`role-function-call`}:t===`function_result`?{role:`function_result`,label:`Function Result`,className:`role-function-result`}:{role:`user`,label:`User`,className:`role-user`}}function LI(e,t,{timestamp:n,entryID:r,isAnchor:i,isAfterAnchor:a,index:o,toolCalls:s,functionName:c,functionCallID:l,promptCache:u,toolPromptCache:d}){let f=II(e),p=u&&Number.isFinite(Number(u.total))?Math.max(0,Number(u.total)):u===null?0:String(t||``).length,m=d&&Array.isArray(d.characters)?d.characters:qF(s).characters;return{uid:r+`-`+o,entryID:r,timestamp:n,text:t,role:f.role,roleLabel:f.label,roleClass:f.className,isAnchor:i,isAfterAnchor:a,toolCalls:Array.isArray(s)&&s.length>0?s:null,functionName:c||``,functionCallID:l||``,promptCacheRatio:0,_promptTextCharacters:p,_toolPromptCharacters:m}}function RI(e){return Array.isArray(e)?e.map(e=>{if(!e)return null;let t=e.function||e,n=``;return t.arguments===void 0?e.arguments===void 0?t.input===void 0?e.input!==void 0&&(n=e.input):n=t.input:n=e.arguments:n=t.arguments,{name:t.name||e.name||``,arguments:n,id:e.id||e.call_id||``}}).filter(Boolean):[]}function zI(e){return Array.isArray(e)?RI(e.filter(e=>e&&typeof e==`object`&&e.type===`tool_use`)):[]}function BI(e){return Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`tool_result`).map(e=>({id:e.tool_use_id||e.call_id||``,text:VF(e.content)})):[]}function VI(e,t,n){if(t&&Array.isArray(t.messages)&&t.messages.forEach(t=>{t&&[...Array.isArray(t.tool_calls)?t.tool_calls:[],...Array.isArray(t.content)?t.content.filter(e=>e&&e.type===`tool_use`):[]].forEach(t=>{if(!t)return;let n=t.id||t.call_id||``,r=(t.function||t).name||t.name||``;n&&r&&(e[n]=r)})}),t&&Array.isArray(t.input)&&t.input.forEach(t=>{if(!t||typeof t!=`object`||t.type!==`function_call`)return;let n=t.id||t.call_id||``,r=t.name||``;n&&r&&(e[n]=r)}),n&&Array.isArray(n.choices)){let t=n.choices[0];t&&t.message&&Array.isArray(t.message.tool_calls)&&t.message.tool_calls.forEach(t=>{if(!t)return;let n=t.id||``,r=(t.function||t).name||t.name||``;n&&r&&(e[n]=r)})}n&&Array.isArray(n.output)&&n.output.forEach(t=>{if(!t||t.type!==`function_call`)return;let n=t.id||t.call_id||``,r=t.name||``;n&&r&&(e[n]=r)}),n&&Array.isArray(n.content)&&n.content.forEach(t=>{if(!t||t.type!==`tool_use`)return;let n=t.id||t.call_id||``,r=t.name||``;n&&r&&(e[n]=r)})}function HI(e){return Array.isArray(e)?`[`+e.map(HI).join(`,`)+`]`:e&&typeof e==`object`?`{`+Object.keys(e).sort().map(t=>JSON.stringify(t)+`:`+HI(e[t])).join(`,`)+`}`:JSON.stringify(e)}function UI(e){if(!e||typeof e!=`object`)return null;let t=[];if(e.system!==void 0&&t.push({system:e.system}),e.instructions!==void 0&&t.push({instructions:e.instructions}),Array.isArray(e.messages))t.push(...e.messages);else if(Array.isArray(e.input)&&e.previous_response_id==null&&e.conversation==null)t.push(...e.input);else return null;return t.map(HI)}function WI(e){let t=e&&e.conversation;return typeof t==`string`?t.trim():t&&typeof t.id==`string`?t.id.trim():``}function GI(e,t){let n=new Date(e&&e.timestamp).getTime(),r=new Date(t&&t.timestamp).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r)return n-r;let i=String(e&&e.timestamp||``).localeCompare(String(t&&t.timestamp||``));if(i!==0)return i;let a=String(e&&e.id||``),o=String(t&&t.id||``);return ao)}function KI(e,t){if(!Array.isArray(e)||e.length===0)return{messages:[],entryIDs:[]};let n=[...e].sort(GI),r={};n.forEach(e=>{let t=e.data&&e.data.request_body?e.data.request_body:null,n=e.data&&e.data.response_body?e.data.response_body:null;VI(r,t,n)});let i=[],a=new Set,o=new Set,s=new Set,c=[],l=null,u=0,d=n.findIndex(e=>e.id===t),f=e=>JSON.stringify({role:e.role,text:e.text,toolCalls:e.toolCalls,functionName:e.functionName,functionCallID:e.functionCallID});return n.forEach((e,n)=>{let p=e.id===t,m=d>=0&&n>d,h=e.timestamp,g=e.data&&e.data.request_body?e.data.request_body:null,_=e.data&&e.data.response_body?e.data.response_body:null,v=i.length,y=(e,t)=>GF(e,t),b=e=>qF(e),x=(t,n,{toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s}={})=>LI(t,n,{timestamp:h,entryID:e.id,isAnchor:p,isAfterAnchor:m,index:++u,toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s});if(g&&g.system!==void 0){let e=VF(g.system);e&&i.push(x(`system`,e,{promptCache:y(e,UF(g.system))}))}if(g&&g.instructions!==void 0){let e=VF(g.instructions);e&&i.push(x(`system`,e,{promptCache:y(e,UF(g.instructions))}))}g&&Array.isArray(g.messages)&&g.messages.forEach(e=>{if(!e)return;let t=(e.role||`user`).toLowerCase();if(t===`tool`){let t=VF(e.content),n=e.name||r[e.tool_call_id]||``;t&&i.push(x(`function_result`,t,{functionName:n,functionCallID:e.tool_call_id||``,promptCache:y(t,UF(e.content))}));return}if(t===`assistant`){let n=HF(e),r=[...RI(e.tool_calls),...zI(e.content)];if(n||r.length>0){let a=y(n,UF(e.content));i.push(x(t,n,{toolCalls:r,promptCache:a,toolPromptCache:b(r)}))}return}BI(e.content).forEach(e=>{e.text&&i.push(x(`function_result`,e.text,{functionName:r[e.id]||``,functionCallID:e.id,promptCache:y(e.text,[e.text])}))});let n=HF(e);n&&i.push(x(t,n,{promptCache:y(n,UF(e.content))}))}),g&&g.input!==void 0&&(Array.isArray(g.input)?g.input.forEach(e=>{if(!(!e||typeof e!=`object`)){if(e.type===`function_call_output`){let t=typeof e.output==`string`?e.output:VF(e.output);t&&i.push(x(`function_result`,t,{functionName:r[e.call_id]||e.name||``,functionCallID:e.call_id||``,promptCache:y(t,[t])}))}else if(e.type===`function_call`){let t=RI([e]);i.push(x(`function_call`,``,{toolCalls:t,toolPromptCache:b(t)}))}else if(e.role){let t=String(e.role).toLowerCase(),n=VF(e.content);n&&i.push(x(t,n,{promptCache:y(n,UF(e.content))}))}}}):YF(g.input).forEach(e=>{if(!e.text)return;let t=[];typeof g.input==`string`?t=[g.input]:g.input&&typeof g.input==`object`&&(t=UF(g.input.content),typeof g.input.text==`string`&&t.push(g.input.text)),i.push(x(e.role,e.text,{promptCache:y(e.text,t)}))}));let S=i.splice(v),C=S.map(f),w=UI(g),ee=w!==null,te=pI(e),ne=!!te&&a.has(te),re=String(g&&g.previous_response_id||``).trim(),ie=WI(g),ae=ne||!!re&&o.has(re)||!!ie&&s.has(ie);if(m){let e=ee&&l&&l.length>0&&l.every((e,t)=>w[t]===e);if(ee&&!e&&!ne||!ee&&!ae)return}p&&ee&&(l=[...w]);let oe=String(e.id||``).trim();p&&(a.clear(),o.clear(),s.clear()),oe&&(p||m)&&a.add(oe),ie&&s.add(ie);let se=0;for(;se0;){let t=c.slice(-e),n=C.slice(0,e);if(t.every((e,t)=>e===n[t]))break;e--}i.push(...S.slice(e)),c.push(...C.slice(e))}if(g&&i.splice(0,i.length,...JF(i,WF(e))),_&&Array.isArray(_.choices)){let e=_.choices[0];if(e&&e.message){let t=(e.message.role||`assistant`).toLowerCase(),n=HF(e.message),r=RI(e.message.tool_calls);if(n||r.length>0){let e=x(t,n,{toolCalls:r});i.push(e),c.push(f(e))}}}if(_&&Array.isArray(_.output)&&_.output.forEach(e=>{if(!e)return;if(e.type===`function_call`){let t=x(`function_call`,``,{toolCalls:RI([e])});i.push(t),c.push(f(t));return}let t=(e.role||`assistant`).toLowerCase(),n=XF(e);if(n){let e=x(t,n);i.push(e),c.push(f(e))}}),_&&_.content!==void 0&&!Array.isArray(_.choices)&&!Array.isArray(_.output)){let e=String(_.role||`assistant`).toLowerCase(),t=VF(_.content),n=zI(_.content);if(t||n.length>0){let r=x(e,t,{toolCalls:n});i.push(r),c.push(f(r))}}let ce=$F(e);ce&&i.push(x(`error`,ce));let le=String(_&&_.id||``).trim();le&&o.add(le)}),{messages:i,entryIDs:[...a]}}function qI(e){return e.role===`function_call`?(e.toolCalls||[]).map(function(e){return e.name+`(`+JI(e)+`)`}).join(` - -`):e.text||``}function JI(e){let t=e&&e.arguments!==void 0?e.arguments:``;if(typeof t!=`string`)try{return JSON.stringify(t,null,2)}catch{return String(t)}try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var YI=600*1e3,XI=15*1e3,ZI=250,QI=class{#e=k(!1);get conversationOpen(){return I(this.#e)}set conversationOpen(e){A(this.#e,e,!0)}#t=k(!1);get conversationLoading(){return I(this.#t)}set conversationLoading(e){A(this.#t,e,!0)}#n=k(``);get conversationError(){return I(this.#n)}set conversationError(e){A(this.#n,e,!0)}#r=k(``);get conversationAnchorID(){return I(this.#r)}set conversationAnchorID(e){A(this.#r,e,!0)}#i=k(j([]));get conversationEntryIDs(){return I(this.#i)}set conversationEntryIDs(e){A(this.#i,e,!0)}#a=k(``);get conversationSessionID(){return I(this.#a)}set conversationSessionID(e){A(this.#a,e,!0)}#o=k(!1);get conversationTruncated(){return I(this.#o)}set conversationTruncated(e){A(this.#o,e,!0)}#s=k(!1);get conversationFollowLatest(){return I(this.#s)}set conversationFollowLatest(e){A(this.#s,e,!0)}#c=k(``);get conversationOpenedFromID(){return I(this.#c)}set conversationOpenedFromID(e){A(this.#c,e,!0)}#l=k(``);get followUpText(){return I(this.#l)}set followUpText(e){A(this.#l,e,!0)}#u=k(!1);get followUpSending(){return I(this.#u)}set followUpSending(e){A(this.#u,e,!0)}#d=k(``);get followUpError(){return I(this.#d)}set followUpError(e){A(this.#d,e,!0)}followUpRequestID=``;followUpAbort=null;conversationRequestToken=0;conversationReturnFocusEl=null;bodyPointerStart=null;#f=k(null);get conversationDialogEl(){return I(this.#f)}set conversationDialogEl(e){A(this.#f,e,!0)}#p=k(null);get conversationCloseBtnEl(){return I(this.#p)}set conversationCloseBtnEl(e){A(this.#p,e,!0)}#m=k(null);get conversationThreadEl(){return I(this.#m)}set conversationThreadEl(e){A(this.#m,e,!0)}get conversationEntries(){return(this.conversationEntryIDs||[]).map(e=>jC.auditRecord(e)).filter(Boolean)}#h=O(()=>KI(this.conversationEntries,this.conversationAnchorID));get conversationView(){return I(this.#h)}set conversationView(e){A(this.#h,e)}get conversationMessages(){return this.conversationView.messages}get conversationBranchEntryIDs(){return this.conversationView.entryIDs}_setConversationEntryIDs(e){this.conversationEntryIDs=[...new Set((Array.isArray(e)?e:[]).filter(Boolean))],jC.pinAuditRecords(this.conversationEntryIDs)}canShowConversation(e){return xI(e)}startBodyInteraction(e){this.bodyPointerStart={x:e.clientX,y:e.clientY}}_isBodyDrag(e){if(!this.bodyPointerStart)return!1;let t=Math.abs(e.clientX-this.bodyPointerStart.x),n=Math.abs(e.clientY-this.bodyPointerStart.y);return t>4||n>4}_hasActiveSelection(){let e=window.getSelection?window.getSelection():null;return!e||e.isCollapsed?!1:String(e.toString()||``).trim().length>0}handleBodyConversationClick(e,t){let n=this._isBodyDrag(e);if(this.bodyPointerStart=null,n||this._hasActiveSelection()||!this.canShowConversation(t))return;let r=e.target&&e.target.closest?e.target.closest(`[data-conversation-trigger="1"]`):null;r&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,r))}handleErrorConversationClick(e,t){let n=this._isBodyDrag(e);this.bodyPointerStart=null,!n&&(this._hasActiveSelection()||this.canShowConversation(t)&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,e.currentTarget)))}formatJSON(e){return ic(e)}renderBodyWithConversationHighlights(e,t,n){return FI(e,t,{formatJSON:e=>this.formatJSON(e),canShowConversation:e=>this.canShowConversation(e),promptCacheHighlight:n&&n.promptCacheHighlight})}async openConversation(e,t){if(!e||!e.id||!this.canShowConversation(e))return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null;t instanceof HTMLElement?this.conversationReturnFocusEl=t:n&&n!==document.body&&(this.conversationReturnFocusEl=n);let r=++this.conversationRequestToken;if(this.conversationOpen=!0,this.conversationError=``,this.conversationAnchorID=e.id,this.conversationOpenedFromID=e.id,this.conversationSessionID=String(e.session_id||``).trim(),this._setConversationEntryIDs([]),this.conversationTruncated=!1,this.conversationFollowLatest=!1,this.followUpText=``,this.followUpError=``,this.followUpRequestID=``,requestAnimationFrame(()=>this._focusConversationDrawer()),this._conversationEntryLivePending(e)){this.conversationFollowLatest=!0,this.conversationLoading=!1,this._addConversationRecord(jC.upsertAuditRecord(e,`conversation.live`));return}this.conversationLoading=!0,await this.fetchConversation(e.id,r,!0,!0)}_conversationEntryLivePending(e){return typeof jC.auditEntryLiveDetailPending==`function`&&jC.auditEntryLiveDetailPending(e)}_applyConversationView(){let e=this.conversationEntries,t=KI(e,this.conversationAnchorID);if(this.conversationFollowLatest){let n=gI(e,t.entryIDs);n&&n.id&&String(n.id)!==this.conversationAnchorID&&(this.conversationAnchorID=String(n.id))}}handleAuditRecordChange(e,t){if(!this.conversationOpen||!e)return;let n=String(e.id||``).trim(),r=fI(this.conversationEntries,this.conversationAnchorID,this.conversationSessionID,this.followUpRequestID,e);if(r.accepted&&(this.followUpRequestID=r.followUpRequestID,n&&r.submittedChild&&(this.conversationAnchorID=n,this.conversationFollowLatest=!0),this._addConversationRecord(e),vI(String(t||e._live_state||``).trim(),n,this.conversationAnchorID))){this.conversationMessages.length===0&&(this.conversationLoading=!0);let e=++this.conversationRequestToken;this.fetchConversation(n,e,!1)}}_addConversationRecord(e){let t=wC(e);t&&!this.conversationEntryIDs.includes(t)&&this._setConversationEntryIDs([...this.conversationEntryIDs,t]),!this.conversationSessionID&&e.session_id&&(this.conversationSessionID=String(e.session_id).trim()),this._applyConversationView(),this.conversationFollowLatest&&this._scheduleLatestScroll()}conversationLiveWaiting(){if(!this.conversationOpen)return!1;let e=new Set(this.conversationBranchEntryIDs||[]);return(this.conversationEntries||[]).some(t=>e.has(String(t&&t.id||``))&&t._live&&(typeof jC.liveAuditStateSettled!=`function`||!jC.liveAuditStateSettled(t._live_state)))}conversationLiveStatusText(){return(this.conversationMessages||[]).length>0?`Model is responding…`:`Waiting for request data…`}closeConversation(){this.followUpAbort&&this.followUpAbort.abort(),this.conversationOpen=!1,this.conversationRequestToken++,this.conversationSessionID=``,this._setConversationEntryIDs([]),this.conversationFollowLatest=!1,this.conversationOpenedFromID=``,this.followUpRequestID=``,this.followUpSending=!1;let e=this.conversationReturnFocusEl;this.conversationReturnFocusEl=null,e&&typeof e.focus==`function`&&document.contains(e)&&requestAnimationFrame(()=>e.focus())}_focusConversationDrawer(){if(!this.conversationOpen)return;let e=this.conversationCloseBtnEl;if(e&&typeof e.focus==`function`){e.focus();return}let t=this.conversationDialogEl;t&&typeof t.focus==`function`&&t.focus()}async fetchConversation(e,t,n=!0,r=!1){try{let i=await gs(`/admin/audit/conversation?`+(`log_id=`+encodeURIComponent(e)+`&limit=120`),{label:`audit conversation`});if(t!==this.conversationRequestToken||i.stale)return;if(!i.ok){this.conversationError=`Unable to load interactions.`;return}let a=i.data||{},o=a.anchor_id||e,s=Array.isArray(a.entries)?a.entries:[],c=jC.upsertAuditRecords(s,`conversation.hydrated`),l=yI(this.conversationEntryIDs,c);l.length>this.conversationEntryIDs.length&&this._setConversationEntryIDs(l),r&&(this.conversationFollowLatest=_I(c,o)),this.conversationAnchorID=o;let u=this.conversationEntries.find(e=>e.id===this.conversationAnchorID);u&&u.session_id&&(this.conversationSessionID=String(u.session_id).trim()),this.conversationTruncated=!!a.truncated,this._applyConversationView(),this.conversationFollowLatest?this._scheduleLatestScroll():n&&this._scheduleAnchorScroll()}catch(e){if(t!==this.conversationRequestToken)return;console.error(`Failed to fetch audit conversation:`,e),this.conversationError=`Failed to load interactions.`}finally{t===this.conversationRequestToken&&(this.conversationLoading=!1)}}selectedConversationEntry(){return mI(this.conversationEntries,this.conversationAnchorID)}followUpKind(){let e=this.selectedConversationEntry();return sI(e)?iI(e.path):``}canSendFollowUp(){return!!this.followUpKind()&&!!String(this.followUpText||``).trim()&&!this.followUpSending&&!this.conversationLiveWaiting()}async sendFollowUp(){if(!this.canSendFollowUp())return;let e=this.selectedConversationEntry(),t=cI(e,this.followUpText);if(!e||!t)return;let n=this.conversationAnchorID,r=eL(),i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},YI);this.followUpSending=!0,this.followUpError=``,this.followUpRequestID=r,this.followUpAbort=i;try{let a=uI(e,n,r),o=await ms(e.path,{method:`POST`,headers:a,body:JSON.stringify(t),signal:i.signal}),s=String(o.headers.get(`X-Request-ID`)||``).trim();if(s&&this.followUpRequestID&&(this.followUpRequestID=s),!o.ok){let e=`Unable to send message.`;try{let t=await o.json();e=t&&t.error&&t.error.message||e}catch{}this.followUpError=e,(this.followUpRequestID===r||this.followUpRequestID===s)&&(this.followUpRequestID=``);return}if(this.followUpText=``,await $I(o),!jC.liveLogsStreaming&&this.conversationOpen){let e=++this.conversationRequestToken;await this._selectPersistedFollowUp(n,this.followUpRequestID,e,i.signal)}}catch(e){vs(e)||i.signal.aborted?a&&this.conversationOpen&&(this.followUpError=`The request timed out.`):(console.error(`Failed to send interaction follow-up:`,e),this.followUpError=`Failed to send message.`)}finally{clearTimeout(o),this.followUpAbort===i&&(this.followUpAbort=null,this.followUpSending=!1)}}async _selectPersistedFollowUp(e,t,n,r){let i=Date.now()+XI;for(;this.conversationOpen&&n===this.conversationRequestToken&&Date.now(){let e=this.conversationThreadEl;if(!e)return;let t=e.querySelectorAll(`[data-conversation-anchor="true"]`),n=t[t.length-1];n&&typeof n.scrollIntoView==`function`&&n.scrollIntoView({block:`center`})})}_scheduleLatestScroll(){requestAnimationFrame(()=>{let e=this.conversationThreadEl;if(!e)return;let t=e.lastElementChild;t&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`end`})})}};async function $I(e){let t=e&&e.body&&typeof e.body.getReader==`function`?e.body.getReader():null;if(!t){await e.text();return}for(;!(await t.read()).done;);}function eL(){return globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`?globalThis.crypto.randomUUID():`dashboard-`+Date.now().toString(36)+`-`+Math.random().toString(36).slice(2)}function tL(e,t){return new Promise((n,r)=>{let i,a=()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))};if(i=setTimeout(()=>{t&&t.removeEventListener(`abort`,a),n()},e),t){if(t.aborted){a();return}t.addEventListener(`abort`,a,{once:!0})}})}var nL=new QI,rL=0;Mn(()=>{An(()=>{let e=EC(jC.auditRecordChanges,rL);e.length!==0&&(rL=Number(e[e.length-1].version||0),Er(()=>{e.forEach(e=>{if(!DC(e))return;let t=jC.auditRecord(e.key);nL.handleAuditRecordChange(t,e.eventType)})}))})});var iL=R(``),aL=R(` `),oL=R(``),sL=R(`
            `);function cL(e,t){E(t,!0);let n=G(t,`thread`,3,null),r=G(t,`expanded`,3,!1),i=G(t,`onactivate`,3,null),a=O(()=>us.formatTimestamp(t.entry.timestamp)),o=O(()=>I(a)===`-`?I(a):I(a).slice(I(a).lastIndexOf(` `)+1)),s=O(()=>nL.conversationOpen&&String(nL.conversationAnchorID||``)===String(t.entry.id||``));function c(e){e.preventDefault(),i()&&i()()}function l(e){e.stopPropagation(),e.preventDefault(),n().ontoggle()}function u(e){if(e.stopPropagation(),e.preventDefault(),I(s)){nL.closeConversation();return}nL.openConversation(t.entry,e.currentTarget)}var d=sL();let f;var p=M(d),m=M(p),h=e=>{var t=iL(),r=M(t);{let e=O(()=>n().expanded?Va:Ua);K(r,{get icon(){return I(e)},class:`audit-thread-expander-svg`})}var i=P(r,2),a=M(i,!0);T(i),T(t),F(()=>{W(t,`aria-expanded`,n().expanded),W(t,`title`,`Session with `+n().count+` requests`),W(t,`aria-label`,`Session with `+n().count+` requests, `+(n().expanded?`collapse`:`expand`)),B(a,n().count)}),L(`click`,t,l),z(e,t)};V(m,e=>{n()&&e(h)});var g=P(m,2),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=M(y,!0);T(y),T(g);var x=P(g,2),S=e=>{var n=aL(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>yc(t.entry)]),z(e,n)};V(x,e=>{(t.entry.requested_model||t.entry.model)&&e(S)});var C=P(x,2),w=M(C,!0);T(C),T(p);var ee=P(p,2),te=M(ee);RF(te,{get entry(){return t.entry}});var ne=P(te,2),re=M(ne),ie=M(re,!0);T(re);var ae=P(re,2),oe=M(ae,!0);T(ae),T(ne);var se=P(ne,2),ce=M(se,!0);T(se);var le=P(se,2),ue=e=>{var t=oL();let n;var r=M(t);{let e=O(()=>I(s)?Ha:Ua);K(r,{get icon(){return I(e)},class:`audit-conversation-trigger-svg`})}T(t),F(()=>{n=U(t,1,`audit-conversation-trigger svelte-17mysgz`,null,n,{"audit-conversation-trigger-active":I(s)}),W(t,`title`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-label`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-pressed`,I(s))}),L(`click`,t,u),z(e,t)},de=O(()=>nL.canShowConversation(t.entry));V(le,e=>{I(de)&&e(ue)}),T(ee),T(d),F((e,n,i,s)=>{f=U(d,1,`audit-entry-summary svelte-17mysgz`,null,f,e),W(d,`aria-expanded`,r()),U(g,1,`audit-status-badge audit-request-badge ${n??``}`,`svelte-17mysgz`),W(g,`title`,`Status `+(t.entry.status_code||`-`)+` · `+(t.entry.method||`-`)),W(g,`aria-label`,(t.entry.status_code||`-`)+` `+(t.entry.method||`-`)),B(v,t.entry.status_code||`-`),B(b,t.entry.method||`-`),B(w,t.entry.path||`-`),W(ne,`title`,i),W(ne,`aria-label`,I(a)),B(ie,I(a)),B(oe,I(o)),B(ce,s)},[()=>({"audit-entry-summary-live-in-progress":UP(t.entry),"audit-entry-summary-has-interactions":nL.canShowConversation(t.entry)}),()=>HP(t.entry.status_code),()=>pc(t.entry.timestamp),()=>VP(t.entry.duration_ns)]),L(`click`,d,c),z(e,d),D()}Hr([`click`]);var lL=R(``);function uL(e,t){E(t,!0);let n=G(t,`label`,3,`Copy`),r=G(t,`copiedLabel`,3,`Copied`),i=G(t,`errorLabel`,3,``),a=G(t,`class`,3,`btn`),o=O(()=>t.state.error&&i()?i():t.state.copied?r():n());var s=lL();let c;var l=M(s),u=e=>{K(e,{get icon(){return Ga},width:`14`,height:`14`,"stroke-width":`2.5`})},d=e=>{K(e,{get icon(){return Ja},width:`14`,height:`14`})};V(l,e=>{t.state.copied?e(u):e(d,-1)});var f=P(l,2),p=M(f,!0);T(f),T(s),F(()=>{c=U(s,1,Fi([`copy-feedback-btn`,a()]),null,c,{"copy-feedback-btn-copied":t.state.copied}),B(p,I(o))}),L(`click`,s,e=>{e.preventDefault(),t.onclick?.(e)}),z(e,s),D()}Hr([`click`]);var dL=R(`
            Error Message
             
            `),fL=R(`
             
            `),pL=R(` `),mL=R(` streaming`),hL=R(`
            Body
            `),gL=R(`

            `),_L=R(`

            `),vL=R(`

            `),yL=R(`
            `);function bL(e,t){E(t,!0);let n=_M({logPrefix:`Failed to copy audit payload:`}),r=_M({logPrefix:`Failed to copy audit payload:`}),i=O(()=>t.pane&&t.pane.showHeaders?ic(t.pane.headers):``),a=O(()=>!t.pane||!t.pane.showBody?``:EI(t.pane.body)?jI(t.pane.body):nL.renderBodyWithConversationHighlights(t.pane.entry,t.pane.body,{promptCacheHighlight:t.pane.promptCacheHighlight})),o=O(()=>!!(t.pane&&nL.canShowConversation(t.pane.entry)));function s(e){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),nL.handleErrorConversationClick(e,t.pane.entry))}var c=yL();let l;var u=M(c),d=e=>{var n=dL(),r=P(M(n),2);let i;var a=M(r,!0);T(r),T(n),F(()=>{i=U(r,1,`audit-json audit-pane-error-message svelte-1h5puht`,null,i,{"audit-pane-clickable-preview":I(o)}),W(r,`role`,I(o)?`button`:null),W(r,`tabindex`,I(o)?0:null),B(a,t.pane.errorMessage)}),L(`mousedown`,r,e=>nL.startBodyInteraction(e)),L(`keydown`,r,s),L(`click`,r,e=>nL.handleErrorConversationClick(e,t.pane.entry)),z(e,n)};V(u,e=>{t.pane.showErrorMessage&&e(d)});var f=P(u,2),p=e=>{var n=fL(),a=M(n),o=M(a),s=M(o,!0);T(o),uL(P(o,2),{get state(){return r},label:`Copy Headers`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>r.copy(t.pane.copyHeaders,ic)}),T(a);var c=P(a,2),l=M(c,!0);T(c),T(n),F(()=>{B(s,t.pane.headersTitle||`Headers`),B(l,I(i))}),z(e,n)};V(f,e=>{t.pane.showHeaders&&e(p)});var m=P(f,2),h=e=>{var r=hL(),i=M(r),o=M(i),s=P(M(o),2),c=e=>{var n=pL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.bodyCacheRatioLabel)),z(e,n)};V(s,e=>{t.pane.bodyCacheRatioLabel&&e(c)});var l=P(s,2),u=e=>{z(e,mL())};V(l,e=>{t.pane.streaming&&e(u)}),T(o),uL(P(o,2),{get state(){return n},label:`Copy Body`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>n.copy(t.pane.copyBody,ic)}),T(i);var d=P(i,2);hi(d,()=>I(a),!0),T(d),T(r),L(`mousedown`,d,e=>nL.startBodyInteraction(e)),L(`click`,d,e=>nL.handleBodyConversationClick(e,t.pane.entry)),z(e,r)};V(m,e=>{t.pane.showBody&&e(h)});var g=P(m,2),_=e=>{var n=gL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.emptyMessage)),z(e,n)};V(g,e=>{t.pane.showEmpty&&e(_)});var v=P(g,2),y=e=>{var n=_L(),r=P(M(n),2),i=M(r,!0);T(r),T(n),F(()=>B(i,t.pane.pendingMessage)),z(e,n)};V(v,e=>{t.pane.showPending&&e(y)});var b=P(v,2),x=e=>{var n=vL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.tooLargeMessage)),z(e,n)};V(b,e=>{t.pane.showTooLarge&&e(x)}),T(c),F(()=>l=U(c,1,`audit-pane svelte-1h5puht`,null,l,{"audit-pane-split":t.pane&&t.pane.layout===`split`,"audit-pane-split-single":t.pane&&t.pane.layout===`split`&&!(t.pane.showHeaders&&t.pane.showBody)})),z(e,c),D()}Hr([`mousedown`,`keydown`,`click`]);var xL=R(` `),SL=R(` `),CL=R(` `),wL=R(` `),TL=R(``),EL=R(`
            `),DL=R(`
            `);function OL(e,t){E(t,!0);let n=G(t,`panes`,19,()=>[]),r=k(null),i=O(()=>xF(I(r),t.entry,n())),a=e=>`audit-tab-`+t.entry.id+`-`+e,o=e=>`audit-tabpanel-`+t.entry.id+`-`+e;function s(e,t){let i=n().map(e=>e.id),a=SF(e.key,i,t);a!=null&&(e.preventDefault(),((e.currentTarget?.closest?.(`.audit-pane-tablist`))?.querySelectorAll(`.audit-pane-tab`)[i.indexOf(a)])?.focus?.(),A(r,a,!0))}var c=DL(),l=M(c);H(l,21,n,e=>e.id,(e,t)=>{var n=TL();let c;var l=M(n),u=M(l),d=e=>{K(e,{get icon(){return Na}})},f=e=>{K(e,{get icon(){return Ma}})};V(u,e=>{I(t).pane.direction===`request`?e(d):I(t).pane.direction===`response`&&e(f,1)}),T(l);var p=P(l,2),m=M(p,!0);T(p);var h=P(p,2),g=e=>{var n=xL(),r=M(n);T(n),F(()=>B(r,`#${I(t).pane.seq??``}`)),z(e,n)};V(h,e=>{I(t).pane.seq&&e(g)});var _=P(h,2),v=e=>{var n=SL(),r=M(n,!0);T(n),F(()=>{U(n,1,`provider-badge audit-pane-kind audit-pane-kind-${I(t).pane.kind??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.kind)}),z(e,n)};V(_,e=>{I(t).pane.kind&&e(v)});var y=P(_,2);H(y,17,()=>I(t).pane.noChangeSteps||[],e=>e.id,(e,t)=>{var n=CL(),r=M(n,!0);T(n),F(()=>{W(n,`title`,I(t).title),B(r,I(t).label)}),z(e,n)});var b=P(y,2),x=e=>{var n=wL(),r=M(n,!0);T(n),F(()=>B(r,I(t).pane.savingsLabel)),z(e,n)};V(b,e=>{I(t).pane.savingsLabel&&e(x)});var S=P(b,2),C=e=>{var n=SL(),r=M(n,!0);T(n),F(e=>{U(n,1,`audit-status-badge ${e??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.statusCode)},[()=>HP(I(t).pane.statusCode)]),z(e,n)};V(S,e=>{I(t).pane.statusCode&&e(C)}),T(n),F((e,r)=>{c=U(n,1,`audit-pane-tab svelte-1bc5vi5`,null,c,{"audit-pane-tab-active":I(i)===I(t).id}),W(n,`aria-selected`,I(i)===I(t).id),W(n,`id`,e),W(n,`aria-controls`,r),W(n,`tabindex`,I(i)===I(t).id?0:-1),U(l,1,Fi([`audit-pane-icon`,I(t).pane.direction&&`audit-pane-icon-${I(t).pane.direction}`]),`svelte-1bc5vi5`),B(m,I(t).pane.title)},[()=>a(I(t).id),()=>o(I(t).id)]),L(`keydown`,n,e=>s(e,I(t).id)),L(`click`,n,()=>A(r,I(t).id,!0)),z(e,n)}),T(l),H(P(l,2),17,n,e=>e.id,(e,t)=>{var n=EL();let r;bL(M(n),{get pane(){return I(t).pane}}),T(n),F((e,a)=>{W(n,`id`,e),W(n,`aria-labelledby`,a),r=Hi(n,``,r,{display:I(i)===I(t).id?null:`none`})},[()=>o(I(t).id),()=>a(I(t).id)]),z(e,n)}),T(c),z(e,c),D()}Hr([`keydown`,`click`]);var kL=R(`
            `),AL=R(`
            `);function jL(e,t){E(t,!0);let n=G(t,`thread`,3,null),r=O(()=>TF.isAuditEntryExpanded(t.entry)),i=O(()=>nL.conversationOpen&&String(nL.conversationAnchorID||``)===String(t.entry.id||``)),a=O(()=>I(r)?yF(t.entry,ZF):[]),o=O(()=>I(r)?mN(t.entry,lP.auditEntryWorkflow(t.entry),lP.workflowFeatureCaps()):null);function s(){TF.toggleAuditEntryExpanded(t.entry)}var c=AL();let l;var u=M(c);cL(u,{get entry(){return t.entry},get thread(){return n()},get expanded(){return I(r)},onactivate:s});var d=P(u,2),f=e=>{var n=kL(),r=M(n),i=e=>{AM(e,{get chart(){return I(o)}})};V(r,e=>{I(o)&&e(i)});var s=P(r,2);OL(s,{get entry(){return t.entry},get panes(){return I(a)}}),FF(P(s,2),{get entry(){return t.entry}}),T(n),ki(3,n,()=>Ks,()=>({y:-6,duration:sP(150)})),z(e,n)};V(d,e=>{I(r)&&e(f)}),T(c),F(()=>l=U(c,1,`audit-entry svelte-cmjgwr`,null,l,{"audit-entry-interactions-open":I(i)})),z(e,c),D()}var ML=R(`
            `),NL=R(`
            `),PL=R(`

            `),FL=R(`
            `),IL=R(`
            `);function LL(e,t){E(t,!0);let n=O(()=>TP(t.entry)),r=O(()=>TF.isThreadExpanded(I(n))),i=O(()=>TF.threadChildren(I(n))),a=O(()=>I(i)&&!I(i).loading&&Number(I(i).total||0)>I(i).entries.length+1);var o=Qr(),s=N(o),c=e=>{jL(e,{get entry(){return t.entry}})},l=O(()=>!DP(t.entry)),u=e=>{var n=IL(),o=M(n);{let e=O(()=>({count:EP(t.entry),expanded:I(r),ontoggle:()=>TF.toggleThread(t.entry)}));jL(o,{get entry(){return t.entry},get thread(){return I(e)}})}var s=P(o,2),c=e=>{var t=FL(),n=M(t),r=e=>{var t=ML();xS(M(t),{size:14,label:`Loading session requests`}),T(t),z(e,t)};V(n,e=>{I(i)&&I(i).loading&&e(r)});var o=P(n,2);H(o,17,()=>I(i)&&I(i).entries||[],e=>e.id,(e,t)=>{var n=NL();jL(M(n),{get entry(){return I(t)}}),T(n),z(e,n)});var s=P(o,2),c=e=>{var t=PL(),n=M(t);T(t),F(()=>B(n,`Showing the latest ${I(i).entries.length+1} of ${I(i).total??``} - requests in this session.`)),z(e,t)};V(s,e=>{I(a)&&e(c)}),T(t),ki(3,t,()=>qs,()=>({duration:sP(150)})),z(e,t)};V(s,e=>{I(r)&&e(c)}),T(n),z(e,n)};V(s,e=>{I(l)?e(c):e(u,-1)}),z(e,o),D()}var RL=R(`

            .

            `),zL=R(`
            Audit logging is off. Live entries are temporary and disappear after - refresh. Set LOGGING_ENABLED=true to persist them.
            `),BL=R(`

            `),VL=R(`
            `),HL=R(`
            `),UL=R(`
            `),WL=R(`
            `),GL=R(`
            `);function KL(e,t){E(t,!0);let n=O(()=>xs.config&&xs.config.LOGGING_RETENTION_DAYS);An(()=>{if(q.refreshTick,qo.page===`audit-logs`)return Er(()=>r())});function r(){let e=!1;return(async()=>{try{await xs.ensureLoaded()}finally{await TF.fetchAuditLog(!0),!e&&xs.liveLogsVisible()&&jC.ensureLiveLogs()}})(),()=>{e=!0,jC.stopLiveLogs()}}var i=GL(),a=M(i),o=M(a),s=P(M(o),2),c=e=>{KS(e,{copyId:`audit-retention-help-copy`,label:`retention help`,text:`If you want to change the retention period, set LOGGING_RETENTION_DAYS (env var) or logging.retention_days (config.yaml) and restart the gateway. Default is 30 days; 0 keeps audit logs forever.`,title:e=>{var t=RL(),r=M(t,!0),i=P(r),a=M(i,!0);T(i),Ue(),T(t),F((e,t)=>{B(r,e),B(a,t)},[()=>xP(I(n)),()=>SP(I(n))]),z(e,t)},$$slots:{title:!0}})},l=O(()=>bP(I(n)));V(s,e=>{I(l)&&e(c)}),T(o),T(a);var u=P(a,2);el(M(u),{onchange:()=>TF.fetchAuditLog(!0)}),T(u);var d=P(u,2);Pc(d,{});var f=P(d,2),p=e=>{z(e,zL())},m=O(()=>xs.loaded&&!xs.auditVisible()&&!q.needsAuth);V(f,e=>{I(m)&&e(p)});var h=P(f,2),g=M(h);DF(g,{});var _=P(g,2),v=M(_),y=M(v),b=e=>{var t=BL(),n=M(t);T(t),F(e=>B(n,`Showing ${TF.auditLog.offset+1}-${e??``} of ${TF.auditLog.total??``} - ${TF.auditGroupSessions?`sessions`:`logs`}`),[()=>Math.min(TF.auditLog.offset+TF.auditLog.limit,TF.auditLog.total)]),z(e,t)};V(y,e=>{TF.auditLog.total>0&&e(b)});var x=P(y,2),S=M(x);na(S),Ue(2),T(x),T(v),MF(P(v,2),{}),T(_);var C=P(_,2),w=e=>{var t=VL();xS(M(t),{size:18,label:`Loading audit logs`}),T(t),z(e,t)},ee=e=>{var t=UL();H(t,29,()=>TF.auditLog.entries,e=>e.id,(e,t)=>{var n=HL(),r=M(n),i=e=>{LL(e,{get entry(){return I(t)}})},a=e=>{jL(e,{get entry(){return I(t)}})};V(r,e=>{TF.auditGroupSessions?e(i):e(a,-1)}),T(n),Oi(n,()=>rP,()=>({duration:sP(150)})),ki(1,n,()=>cP,()=>({live:I(t)._live})),z(e,n)}),T(t),z(e,t)};V(C,e=>{TF.loading&&TF.auditLog.entries.length===0?e(w):TF.auditLog.entries.length>0&&e(ee,1)});var te=P(C,2),ne=e=>{var t=WL();wS(M(t),{}),T(t),z(e,t)};V(te,e=>{TF.auditLog.entries.length===0&&!TF.loading&&!q.needsAuth&&e(ne)}),Jw(P(te,2),{get total(){return TF.auditLog.total},get offset(){return TF.auditLog.offset},get limit(){return TF.auditLog.limit},onprev:()=>TF.auditLogPrevPage(),onnext:()=>TF.auditLogNextPage()}),T(h),T(i),F(()=>ia(S,TF.auditGroupSessions)),L(`change`,S,()=>TF.toggleAuditGroupSessions()),z(e,i),D()}Hr([`change`]);function qL(e){try{let t=JSON.parse(JSON.stringify(e||{}));return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function JL(e){return Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(e=>e):e==null?[]:String(e).split(`,`).map(e=>e.trim()).filter(e=>e)}function YL(e,t){let n=String(t||``).trim();return(e||[]).find(e=>String(e&&e.type||``).trim()===n)||null}function XL(e){return Array.isArray(e)&&e.length>0&&String(e[0].type||``).trim()||`system_prompt`}function ZL(e,t){let n=String(t||``).trim();return n&&YL(e,n)?n:XL(e)}function QL(e,t){let n=YL(e,t);return!n||!n.defaults?{}:qL(n.defaults)}function $L(e,t,n){return{...QL(e,n),...qL(t)}}function eR(e,t){let n=ZL(e,t);return{name:``,type:n,description:``,user_path:``,config:QL(e,n)}}function tR(e,t){if(!t)return e||[];let n=String(t).toLowerCase();return(e||[]).filter(e=>[e.name,e.type,e.user_path,e.description,e.summary].some(e=>String(e||``).toLowerCase().includes(n)))}function nR(e,t){let n=YL(e,t);return n&&n.label?n.label:t||`Unknown`}function rR(e,t){let n=YL(e,t);return Array.isArray(n&&n.fields)?n.fields:[]}function iR(e,t){if(!t||!e)return t&&t.input===`checkboxes`?[]:``;let n=e[t.key];return n==null?t.input===`checkboxes`?[]:``:t.input===`checkboxes`?JL(n):n}function aR(e,t,n){if(!t)return e;let r=qL(e);if(t.input===`number`){let e=String(n||``).trim();if(e===``)delete r[t.key];else{let n=Number(e);r[t.key]=Number.isFinite(n)?n:e}}else t.input===`checkboxes`?r[t.key]=JL(n):r[t.key]=n;return r}function oR(e,t,n){return iR(e,t).includes(String(n||``).trim())}function sR(e,t,n,r){let i=JL(iR(e,t)),a=String(n||``).trim();return a?aR(e,t,r?Array.from(new Set([...i,a])):i.filter(e=>e!==a)):e}function cR(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),description:String(e&&e.description||``).trim()||void 0,user_path:String(e&&e.user_path||``).trim()||void 0,config:qL(e&&e.config)}}var lR=new class{#e=k(j([]));get guardrails(){return I(this.#e)}set guardrails(e){A(this.#e,e,!0)}#t=k(j([]));get types(){return I(this.#t)}set types(e){A(this.#t,e,!0)}#n=k(!0);get available(){return I(this.#n)}set available(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=k(!1);get typesLoading(){return I(this.#i)}set typesLoading(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(``);get filter(){return I(this.#o)}set filter(e){A(this.#o,e,!0)}#s=k(!1);get formOpen(){return I(this.#s)}set formOpen(e){A(this.#s,e,!0)}#c=k(!1);get formSubmitting(){return I(this.#c)}set formSubmitting(e){A(this.#c,e,!0)}#l=k(``);get deletingName(){return I(this.#l)}set deletingName(e){A(this.#l,e,!0)}#u=k(`create`);get formMode(){return I(this.#u)}set formMode(e){A(this.#u,e,!0)}#d=k(``);get formOriginalName(){return I(this.#d)}set formOriginalName(e){A(this.#d,e,!0)}#f=k(j({name:``,type:``,description:``,user_path:``,config:{}}));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}get filtered(){return tR(this.guardrails,this.filter)}typeLabel(e){return nR(this.types,e)}typeFields(e){return rR(this.types,e)}fieldValue(e){return iR(this.form&&this.form.config,e)}setFieldValue(e,t){this.form={...this.form,config:aR(this.form.config,e,t)}}arrayFieldSelected(e,t){return oR(this.form&&this.form.config,e,t)}toggleArrayFieldValue(e,t,n){this.form={...this.form,config:sR(this.form.config,e,t,n)}}openCreate(){this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=eR(this.types,XL(this.types)),this.formOpen=!0}openEdit(e){let t=ZL(this.types,e&&e.type);this.formMode=`edit`,this.formOriginalName=String(e&&e.name||``).trim(),this.error=``,this.form={name:this.formOriginalName,type:t,description:String(e&&e.description||``).trim(),user_path:String(e&&e.user_path||``).trim(),config:$L(this.types,e&&e.config,t)},this.formOpen=!0}closeForm(){this.formOpen=!1,this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=eR(this.types,XL(this.types))}changeType(e){let t=ZL(this.types,e);this.form={...this.form,type:t,config:QL(this.types,t)}}async fetchTypes(){this.typesLoading=!0;try{let e=await _T(`/admin/guardrails/types`,{label:`guardrail types`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.types=[];return}if(e.result&&(this.available=!0),this.types=e.items,e.status===`error`){this.error=e.error;return}let t=ZL(this.types,this.form.type);this.form={...this.form,type:t,config:$L(this.types,this.form.config,t)}}finally{this.typesLoading=!1}}async fetchGuardrails(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/guardrails`,{label:`guardrails`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.guardrails=[];return}e.result&&(this.available=!0),this.guardrails=e.items,this.error=e.error}finally{this.loading=!1}}async fetchPage(){await Promise.all([this.fetchTypes(),this.fetchGuardrails()])}async submitForm(){let e=String(this.form.name||``).trim(),t=String(this.form.type||``).trim();if(!e){this.error=`Name is required.`;return}if(!t){this.error=`Type is required.`;return}this.error=``,this.formSubmitting=!0;let n=cR(this.form);try{let t=await vT(`/admin/guardrails`,`PUT`,n,{label:`save guardrail`,errorFallback:`Failed to save guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}J.success(`Guardrail "`+e+`" saved.`),this.closeForm(),this.fetchGuardrails()}finally{this.formSubmitting=!1}}async deleteGuardrail(e){let t=String(e&&e.name||``).trim();if(!(!t||this.deletingName)&&window.confirm(`Delete guardrail "`+t+`"? Workflows that still reference it must be updated first.`)){this.deletingName=t;try{let e=await vT(`/admin/guardrails`,`DELETE`,{name:t},{label:`delete guardrail`,errorFallback:`Failed to delete guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}J.success(`Guardrail "`+t+`" deleted.`),this.formOpen&&this.formOriginalName===t&&this.closeForm(),this.fetchGuardrails()}finally{this.deletingName=``}}}},uR=R(`
            `),dR=R(`

            Loading guardrails...

            `),fR=R(`
            `),pR=R(`
            `),mR=R(`
            NameTypeUser PathSummaryActions
            `),hR=R(`

            No guardrails defined yet.

            `),gR=R(`

            Instances

            Each instance has a reusable name, a type, an optional user path for - future UI visibility scoping, and a JSON-backed config payload for - that type.

            `);function _R(e,t){E(t,!0);var n=gR(),r=M(n),i=P(M(r),2);K(M(i),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(i),T(r);var a=P(r,2),o=e=>{var t=uR(),n=M(t);yw(M(n),{id:`guardrail-filter`,placeholder:`Filter by name, type, user path, summary...`,label:`Guardrail filter`,get value(){return lR.filter},set value(e){lR.filter=e}}),T(n),T(t),z(e,t)};V(a,e=>{lR.available&&e(o)});var s=P(a,2),c=e=>{var t=dR();xS(M(t),{size:16,label:`Loading guardrails`}),Ue(),T(t),z(e,t)};V(s,e=>{lR.loading&&lR.filtered.length===0&&e(c)});var l=P(s,2),u=e=>{var t=mR(),n=M(t),r=P(M(n));H(r,21,()=>lR.filtered,e=>e.name,(e,t)=>{var n=pR(),r=M(n),i=M(r,!0);T(r);var a=P(r),o=M(a),s=M(o,!0);T(o),T(a);var c=P(a),l=M(c,!0);T(c);var u=P(c),d=M(u),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var n=fR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(p,e=>{I(t).description&&e(m)}),T(u);var h=P(u),g=M(h),_=M(g);{let e=O(()=>`Edit guardrail `+I(t).name);gT(_,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>lR.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}var v=P(_,2);{let e=O(()=>(lR.deletingName===I(t).name?`Deleting guardrail `:`Delete guardrail `)+I(t).name),n=O(()=>lR.deletingName===I(t).name);gT(v,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>lR.deleteGuardrail(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return Fo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(g),T(h),T(n),F(e=>{B(i,I(t).name),B(s,e),B(l,I(t).user_path||`—`),B(f,I(t).summary||I(t).description||`No summary yet.`)},[()=>lR.typeLabel(I(t).type)]),z(e,n)}),T(r),T(n),T(t),z(e,t)};V(l,e=>{lR.filtered.length>0&&e(u)});var d=P(l,2),f=e=>{z(e,hR())};V(d,e=>{lR.filtered.length===0&&!lR.loading&&lR.available&&!lR.error&&!q.authError&&e(f)}),T(n),F(()=>i.disabled=lR.typesLoading||lR.formSubmitting||!lR.available),L(`click`,i,()=>lR.openCreate()),z(e,n),D()}Hr([`click`]);var vR=R(`

            Workflows reference these names directly, so renames are - intentionally avoided after creation.

            `),yR=R(``),bR=R(``),xR=R(``),SR=R(``),CR=R(``),wR=R(``),TR=R(``),ER=R(``),DR=R(``),OR=R(`
            `),kR=R(``),AR=R(` `),jR=R(`
            `),MR=R(`
            `);function NR(e,t){E(t,!0);let n=O(()=>lR.formMode===`edit`);{let t=e=>{z(e,vR())},r=O(()=>I(n)?`Edit Guardrail`:`Create Guardrail`);bE(e,{get open(){return lR.formOpen},get title(){return I(r)},ariaLabel:`Guardrail editor`,get error(){return lR.error},get submitting(){return lR.formSubmitting},submitLabel:`Save Guardrail`,dialogClass:`settings-guardrails-editor guardrails-editor-wide`,onclose:()=>lR.closeForm(),onsubmit:()=>lR.submitForm(),headerHint:t,children:(e,t)=>{var r=MR(),i=M(r);SE(i,{id:`guardrail-name`,label:`Name`,children:(e,t)=>{var r=yR();na(r),F(()=>{r.disabled=I(n),W(r,`data-modal-autofocus`,!I(n)||void 0)}),da(r,()=>lR.form.name,e=>lR.form.name=e),z(e,r)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`guardrail-type`,label:`Type`,children:(e,t)=>{var r=xR();H(r,21,()=>lR.types,e=>e.type,(e,t)=>{var n=bR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).type)&&(n.value=(n.__value=I(t).type)??``)}),z(e,n)}),T(r);var i;Wi(r),F(()=>{r.disabled=I(n),i!==(i=lR.form.type)&&(r.value=(r.__value=lR.form.type)??``,Ui(r,lR.form.type))}),L(`change`,r,e=>lR.changeType(e.currentTarget.value)),z(e,r)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`guardrail-description`,label:`Description`,children:(e,t)=>{var r=SR();na(r),F(()=>W(r,`data-modal-autofocus`,I(n)?!0:void 0)),da(r,()=>lR.form.description,e=>lR.form.description=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2),c=M(s);KS(c,{copyId:`guardrail-user-path-help-copy`,label:`guardrail user path help`,text:`Only used for auxiliary rewrite (llm_based_altering) guardrails; ignored for other guardrail types.`,title:e=>{z(e,CR())},$$slots:{title:!0}});var l=P(c,2);na(l),T(s),H(P(s,2),17,()=>lR.typeFields(lR.form.type),e=>e.key,(e,t)=>{var n=Qr(),r=N(n),i=e=>{var n=OR(),r=M(n);{let e=e=>{var n=wR(),r=M(n,!0);T(n),F(()=>{W(n,`for`,`guardrail-field-`+I(t).key),B(r,I(t).label)}),z(e,n)},n=O(()=>`guardrail-field-help-`+I(t).key),i=O(()=>I(t).label+` help`),a=O(()=>I(t).help||``);KS(r,{get copyId(){return I(n)},get label(){return I(i)},get text(){return I(a)},title:e,$$slots:{title:!0}})}var i=P(r,2),a=e=>{var n=TR();H(n,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=bR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n);var r;Wi(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),r!==(r=e)&&(n.value=(n.__value=e)??``,Ui(n,e))},[()=>lR.fieldValue(I(t))]),L(`change`,n,e=>lR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},o=e=>{var n=ER();ft(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>lR.fieldValue(I(t))]),L(`input`,n,e=>lR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},s=e=>{var n=DR();na(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`type`,I(t).input||`text`),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>lR.fieldValue(I(t))]),L(`input`,n,e=>lR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)};V(i,e=>{I(t).input===`select`?e(a):I(t).input===`textarea`?e(o,1):e(s,-1)}),T(n),z(e,n)},a=e=>{var n=jR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).options||[],e=>I(t).key+`-`+e.value,(e,n)=>{var r=kR(),i=M(r);na(i);var a=P(i,2),o=M(a,!0);T(a),T(r),F(e=>{ia(i,e),B(o,I(n).label)},[()=>lR.arrayFieldSelected(I(t),I(n).value)]),L(`change`,i,e=>lR.toggleArrayFieldValue(I(t),I(n).value,e.currentTarget.checked)),z(e,r)}),T(a);var o=P(a,2),s=e=>{var n=AR(),r=M(n,!0);T(n),F(()=>{W(n,`id`,`guardrail-field-help-`+I(t).key),B(r,I(t).help)}),z(e,n)};V(o,e=>{I(t).help&&e(s)}),T(n),F(()=>{W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),B(i,I(t).label)}),z(e,n)};V(r,e=>{I(t).input===`checkboxes`?e(a,-1):e(i)}),z(e,n)}),T(r),da(l,()=>lR.form.user_path,e=>lR.form.user_path=e),z(e,r)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var PR=R(`

            Guardrails

            `),FR=R(`
            Runtime guardrail execution is currently off because GUARDRAILS_ENABLED is disabled. You can still manage - definitions here.
            `),IR=R(`
            Guardrails feature is unavailable.
            `),LR=R(`
            `),RR=R(`

            Reusable Policy Objects

            Guardrail Library

            Store guardrails in the database, keep them hot in memory, and attach - them to workflows by reference.

            Instances
            Types
            `);function zR(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`guardrails`&&(xs.ensureLoaded(),lR.fetchPage())});var n=RR(),r=M(n),i=M(r);KS(M(i),{copyId:`guardrails-help-copy`,label:`guardrails help`,text:`Reusable policy objects stored in the database and kept hot in memory for workflow execution.`,title:e=>{z(e,PR())},$$slots:{title:!0}}),T(i),T(r);var a=P(r,2),o=P(M(a),2),s=M(o),c=P(M(s),2),l=M(c,!0);T(c),T(s);var u=P(s,2),d=P(M(u),2),f=M(d,!0);T(d),T(u),T(o),T(a);var p=P(a,2);Pc(p,{});var m=P(p,2),h=e=>{z(e,FR())},g=O(()=>!xs.guardrailsVisible());V(m,e=>{I(g)&&e(h)});var _=P(m,2),v=e=>{z(e,IR())};V(_,e=>{!q.authError&&!lR.available&&e(v)});var y=P(_,2),b=e=>{var t=LR(),n=M(t,!0);T(t),F(()=>B(n,lR.error)),z(e,t)};V(y,e=>{!q.authError&&lR.error&&!lR.formOpen&&e(b)});var x=P(y,2);NR(x,{}),_R(P(x,2),{}),T(n),F((e,t)=>{B(l,e),B(f,t)},[()=>ac(lR.guardrails.length),()=>ac(lR.types.length)]),z(e,n),D()}var Q=new class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get slugEdited(){return I(this.#c)}set slugEdited(e){A(this.#c,e,!0)}#l=k(!1);get advancedOpen(){return I(this.#l)}set advancedOpen(e){A(this.#l,e,!0)}#u=k(j(ux()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(``);get deletingName(){return I(this.#d)}set deletingName(e){A(this.#d,e,!0)}#f=k(``);get reconnectingName(){return I(this.#f)}set reconnectingName(e){A(this.#f,e,!0)}#p=k(!1);get catalogOpen(){return I(this.#p)}set catalogOpen(e){A(this.#p,e,!0)}#m=k(!1);get catalogLoading(){return I(this.#m)}set catalogLoading(e){A(this.#m,e,!0)}#h=k(``);get catalogError(){return I(this.#h)}set catalogError(e){A(this.#h,e,!0)}#g=k(j(dx()));get catalog(){return I(this.#g)}set catalog(e){A(this.#g,e,!0)}#_=O(()=>Sx(this.servers,this.filter));get filtered(){return I(this.#_)}set filtered(e){A(this.#_,e)}async fetchServers(){if(await xs.ensureLoaded(),!xs.mcpVisible()){this.available=!1,this.servers=[],this.error=``,this.loading=!1;return}this.loading=!0,this.error=``;try{let e=await _T(`/admin/mcp-servers`,{label:`mcp servers`,errorFallback:`Failed to load MCP servers.`,unavailableStatuses:[503,404]});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.servers=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.servers=[],this.error=e.error;return}this.available=!0,this.servers=e.items}finally{this.loading=!1}}openCreate(){this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=ux(),this.formOpen=!0}openEdit(e){!e||e.managed||(this.formMode=`edit`,this.slugEdited=!0,this.advancedOpen=!1,this.error=``,this.form=Cx(e),this.formOpen=!0)}closeForm(){this.formOpen=!1,this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=ux()}syncSlugFromName(){this.formMode===`create`&&!this.slugEdited&&(this.form.slug=vx(this.form.name))}markSlugEdited(){this.formMode===`create`&&(this.slugEdited=!0)}addHeader(){this.form.headers.push({name:``,value:``})}removeHeader(e){this.form.headers.splice(e,1)}async submitForm(){let e=wx(this.form,this.formMode,this.servers);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/mcp-servers`,`PUT`,e.payload,{label:`save mcp server`,errorFallback:`Failed to save MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}J.success(`MCP server "`+e.payload.name+`" saved.`),this.closeForm(),this.fetchServers()}finally{this.formSubmitting=!1}}async deleteServer(e){let t=String(e&&e.name||``).trim(),n=fx(e);if(!(!n||this.deletingName||e&&e.managed)&&confirm(`Delete MCP server "`+t+`"? Clients lose access to its tools immediately.`)){this.deletingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n),`DELETE`,void 0,{label:`delete mcp server`,errorFallback:`Failed to delete MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}J.success(`MCP server "`+t+`" deleted.`),this.formOpen&&this.form.slug===n&&this.closeForm(),this.fetchServers()}finally{this.deletingName=``}}}async reconnectServer(e){let t=String(e&&e.name||``).trim(),n=fx(e);if(!(!n||this.reconnectingName)){this.reconnectingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n)+`/reconnect`,`POST`,void 0,{label:`reconnect mcp server`,errorFallback:`Failed to reconnect MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}let r=e.result.data,i=px(r);i===`connected`?J.success(`MCP server "`+t+`" reconnected.`):i===`disabled`?J.success(`MCP server "`+t+`" is disabled; no connection was attempted.`):J.error(`Reconnect attempted, but MCP server "`+t+`" is still `+i+`.`),r&&r.name?this.servers=(this.servers||[]).map(e=>fx(e)===fx(r)?r:e):this.fetchServers()}finally{this.reconnectingName=``}}}async openCatalog(e){let t=String(e&&e.name||``).trim(),n=fx(e);if(n){this.catalogOpen=!0,this.catalogLoading=!0,this.catalogError=``,this.catalog={...dx(),server:n,status:px(e)};try{let e=await gs(`/admin/mcp-servers/`+encodeURIComponent(n)+`/catalog`,{label:`mcp server catalog`});if(e.stale)return;if(e.status===503){this.available=!1,this.catalogError=`MCP server management is unavailable.`;return}if(e.status===404){this.catalogError=`MCP server "`+t+`" was not found.`;return}if(!e.ok){this.catalogError=e.status===401?`Authentication required.`:ds(e.data,`Failed to load MCP server catalog.`);return}this.catalog=Tx(n,e.data)}catch(e){console.error(`Failed to load MCP server catalog:`,e),this.catalogError=`Failed to load MCP server catalog.`}finally{this.catalogLoading=!1}}}closeCatalog(){this.catalogOpen=!1,this.catalogLoading=!1,this.catalogError=``,this.catalog=dx()}},BR=R(``),VR=R(`

            `),HR=R(`
            `),UR=R(`

            `),WR=R(`
          • `),GR=R(`

              `),KR=R(`

              No tools listed — the server may still be connecting or degraded.

              `),qR=R(` `,1),JR=R(``);function YR(e,t){E(t,!0);let n=O(()=>Dx(Q.catalog));Ms(e,{get open(){return Q.catalogOpen},variant:`editor`,onclose:()=>Q.closeCatalog(),children:(e,t)=>{var r=JR(),i=M(r),a=M(i),o=P(M(a),2),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l),T(o),T(a),Os(P(a,2),{label:`Close MCP server catalog`,onclick:()=>Q.closeCatalog()}),T(i);var d=P(i,2),f=e=>{mT(e,{label:`Loading catalog...`})},p=e=>{var t=BR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalogError)),z(e,t)},m=e=>{var t=qR(),r=N(t),i=e=>{var t=VR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalog.instructions)),z(e,t)};V(r,e=>{Q.catalog.instructions&&e(i)});var a=P(r,2);H(a,17,()=>I(n),e=>e.key,(e,t)=>{var n=GR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).items,e=>e.key,(e,t)=>{var n=WR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=HR(),r=M(n,!0);T(n),F(()=>{W(n,`title`,`Exposed on the aggregated /mcp endpoint as `+I(t).aggregated),B(r,I(t).aggregated)}),z(e,n)};V(a,e=>{I(t).aggregated&&e(o)});var s=P(a,2),c=e=>{var n=UR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(s,e=>{I(t).description&&e(c)}),T(n),F(()=>{W(r,`title`,I(t).aggregated||I(t).name),B(i,I(t).name)}),z(e,n)}),T(a),T(n),F(()=>B(i,I(t).title)),z(e,n)});var o=P(a,2),s=e=>{z(e,KR())},c=O(()=>Ox(Q.catalog));V(o,e=>{I(c)&&e(s)}),z(e,t)};V(d,e=>{Q.catalogLoading?e(f):Q.catalogError?e(p,1):e(m,-1)});var h=P(d,2),g=M(h);T(h),T(r),F((e,t)=>{B(c,Q.catalog.server),U(l,1,`audit-status-badge ${e??``}`,`svelte-1xqrzco`),B(u,t)},[()=>mx(Q.catalog),()=>px(Q.catalog)]),L(`click`,g,()=>Q.closeCatalog()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var XR=R(`

              The display name can change. The slug is the stable client-facing identity.

              `),ZR=R(` Human-readable and Unicode-friendly. You can change it later.`,1),QR=R(`Derived from the name. You may edit it before saving.`),$R=R(`Immutable because it is used in URLs, scope headers, and aggregated tool names.`),ez=R(` `,1),tz=R(` stdio servers are config-only: declare them in config.yaml under mcp.servers.`,1),nz=R(``),rz=R(`
              `),iz=R(`
              Headers
              Sent only to the configured server origin. Saved values are shown as ***; leave *** unchanged to keep the stored value.
              Advanced settings Description, access rules, and timeout
              `,1);function az(e,t){E(t,!0);{let t=e=>{z(e,XR())},n=O(()=>Q.formMode===`edit`?`Edit MCP Server`:`Add MCP Server`);bE(e,{get open(){return Q.formOpen},get title(){return I(n)},ariaLabel:`MCP server editor`,get error(){return Q.error},get submitting(){return Q.formSubmitting},onclose:()=>Q.closeForm(),onsubmit:()=>Q.submitForm(),headerHint:t,children:(e,t)=>{var n=iz(),r=N(n);SE(r,{id:`mcp-server-name`,label:`Name`,children:(e,t)=>{var n=ZR(),r=N(n);na(r),Ue(2),L(`input`,r,()=>Q.syncSlugFromName()),da(r,()=>Q.form.name,e=>Q.form.name=e),z(e,n)},$$slots:{default:!0}});var i=P(r,2);SE(i,{id:`mcp-server-slug`,label:`Slug`,children:(e,t)=>{var n=ez(),r=N(n);na(r);var i=P(r,2),a=e=>{z(e,QR())},o=e=>{z(e,$R())};V(i,e=>{Q.formMode===`create`?e(a):e(o,-1)}),F(()=>r.disabled=Q.formMode===`edit`),L(`input`,r,()=>Q.markSlugEdited()),da(r,()=>Q.form.slug,e=>Q.form.slug=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`mcp-server-transport`,label:`Transport`,children:(e,t)=>{var n=tz(),r=N(n),i=M(r);i.value=i.__value=`http`;var a=P(i);a.value=a.__value=`sse`,T(r),Ue(2),Gi(r,()=>Q.form.transport,e=>Q.form.transport=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`mcp-server-url`,label:`URL`,children:(e,t)=>{var n=nz();na(n),da(n,()=>Q.form.url,e=>Q.form.url=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=P(M(s),2);H(c,21,()=>Q.form.headers,oi,(e,t,n)=>{var r=rz(),i=M(r);na(i);var a=P(i,2);na(a),gT(P(a,2),{label:`Remove header`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Q.removeHeader(n),children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),da(i,()=>I(t).name,e=>I(t).name=e),da(a,()=>I(t).value,e=>I(t).value=e),z(e,r)}),T(c);var l=P(c,2),u=M(l);K(M(u),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(u),T(l),Ue(2),T(s);var d=P(s,2),f=M(d);bA(M(f),{get enabled(){return Q.form.enabled},label:`MCP server`,onclick:()=>Q.form.enabled=!Q.form.enabled}),T(f),T(d);var p=P(d,2),m=P(M(p),2),h=M(m),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=P(M(y),2);na(b),T(y);var x=P(y,2),S=P(M(x),2);ft(S),W(S,`placeholder`,`/ -/team/alpha`),T(x);var C=P(x,2),w=P(M(C),2);na(w),T(C),T(m),T(p),F(()=>p.open=Q.advancedOpen),L(`click`,u,()=>Q.addHeader()),Vr(`toggle`,p,e=>Q.advancedOpen=e.currentTarget.open),da(g,()=>Q.form.description,e=>Q.form.description=e),da(v,()=>Q.form.allowed_tools,e=>Q.form.allowed_tools=e),da(b,()=>Q.form.disallowed_tools,e=>Q.form.disallowed_tools=e),da(S,()=>Q.form.user_paths,e=>Q.form.user_paths=e),da(w,()=>Q.form.tool_timeout_seconds,e=>Q.form.tool_timeout_seconds=e),z(e,n)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`input`,`click`]);var oz=R(`Config`),sz=R(`
              `),cz=R(`
              `),lz=R(`
              NameTransportEndpointStatusToolsEnabledActions
              `);function uz(e,t){E(t,!0);function n(e){return hx(e,e=>us.formatTimestamp(e))}var r=lz(),i=M(r),a=P(M(i));H(a,21,()=>Q.filtered,e=>fx(e),(e,t)=>{var r=cz(),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=e=>{z(e,oz())};V(s,e=>{I(t).managed&&e(c)});var l=P(s,2),u=M(l,!0);T(l),T(i);var d=P(i),f=M(d),p=M(f,!0);T(f),T(d);var m=P(d),h=M(m,!0);T(m);var g=P(m),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=e=>{var n=sz(),r=M(n,!0);T(n),F(()=>B(r,I(t).last_error)),z(e,n)},x=O(()=>px(I(t))===`degraded`&&I(t).last_error);V(y,e=>{I(x)&&e(b)}),T(g);var S=P(g),C=M(S),w=M(C,!0);T(C);var ee=P(C,2),te=M(ee,!0);T(ee),T(S);var ne=P(S),re=M(ne),ie=M(re,!0);T(re),T(ne);var ae=P(ne),oe=M(ae),se=M(oe),ce=e=>{{let n=O(()=>`Edit MCP server `+I(t).name);gT(e,{get label(){return I(n)},class:`table-icon-btn`,onclick:()=>Q.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(se,e=>{I(t).managed||e(ce)});var le=P(se,2);{let e=O(()=>`Inspect catalog of MCP server `+I(t).name);gT(le,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.openCatalog(I(t)),children:(e,t)=>{K(e,{get icon(){return ro},class:`form-action-icon`})},$$slots:{default:!0}})}var ue=P(le,2);{let e=O(()=>(Q.reconnectingName===fx(I(t))?`Reconnecting MCP server `:`Reconnect MCP server `)+I(t).name),n=O(()=>Q.reconnectingName===fx(I(t)));gT(ue,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.reconnectServer(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return mo},class:`form-action-icon`})},$$slots:{default:!0}})}var de=P(ue,2),fe=e=>{{let n=O(()=>(Q.deletingName===fx(I(t))?`Deleting MCP server `:`Delete MCP server `)+I(t).name),r=O(()=>Q.deletingName===fx(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>Q.deleteServer(I(t)),get disabled(){return I(r)},children:(e,t)=>{K(e,{get icon(){return Fo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(de,e=>{I(t).managed||e(fe)}),T(oe),T(ae),T(r),F((e,n,r,i,a,s,c,l)=>{B(o,I(t).name),B(u,e),B(p,I(t).transport||`http`),W(m,`title`,n),B(h,r),U(_,1,`audit-status-badge ${i??``}`,`svelte-ah8nrt`),W(_,`title`,a),B(v,s),B(w,c),B(te,l),U(re,1,Fi([`auth-key-status-badge`,I(t).enabled?`auth-key-status-active`:`auth-key-status-inactive`])),B(ie,I(t).enabled?`Enabled`:`Disabled`)},[()=>fx(I(t)),()=>gx(I(t)),()=>gx(I(t)),()=>mx(I(t)),()=>n(I(t)),()=>px(I(t)),()=>ac(I(t).tool_count||0),()=>_x(I(t))]),z(e,r)}),T(a),T(i),T(r),z(e,r),D()}var dz=R(`

              MCP Servers

              `),fz=R(``),pz=R(`
              MCP server management is unavailable.
              `),mz=R(``),hz=R(`
              `),gz=R(`

              No MCP servers yet. Add one here, or declare servers in config.yaml under mcp.servers.

              `),_z=R(`

              No MCP servers match your filter.

              `),vz=R(`
              `);function yz(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`mcp-servers`&&Q.fetchServers()});var n=vz(),r=M(n),i=M(r);KS(M(i),{copyId:`mcp-servers-help-copy`,label:`MCP servers help`,text:`Upstream Model Context Protocol servers whose tools, prompts, and resources the gateway exposes to clients. Servers added here connect over HTTP or SSE; stdio servers and rows marked Config are declared in config.yaml under mcp.servers and are read-only in the dashboard. Saved header values are masked in API and dashboard responses.`,title:e=>{z(e,dz())},$$slots:{title:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=fz();K(M(t),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Q.formSubmitting),L(`click`,t,()=>Q.openCreate()),z(e,t)};V(o,e=>{Q.available&&!q.authError&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,pz())};V(c,e=>{!Q.available&&!q.authError&&e(l)});var u=P(c,2),d=e=>{var t=mz(),n=M(t,!0);T(t),F(()=>B(n,Q.error)),z(e,t)};V(u,e=>{Q.error&&!q.authError&&!Q.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading MCP servers...`})};V(f,e=>{Q.loading&&!q.authError&&e(p)});var m=P(f,2),h=e=>{var t=hz(),n=M(t);yw(M(n),{id:`mcp-server-filter`,placeholder:`Filter by name, slug, URL, transport, or status...`,label:`Filter MCP servers by name, slug, URL, transport, or status`,get value(){return Q.filter},set value(e){Q.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{(Q.servers.length>0||Q.filter)&&Q.available&&!q.authError&&e(h)});var g=P(m,2);az(g,{});var _=P(g,2);YR(_,{});var v=P(_,2),y=e=>{uz(e,{})};V(v,e=>{Q.filtered.length>0&&Q.available&&!q.authError&&e(y)});var b=P(v,2),x=e=>{z(e,gz())};V(b,e=>{Q.servers.length===0&&!Q.filter&&!Q.loading&&!q.authError&&!Q.error&&Q.available&&e(x)});var S=P(b,2),C=e=>{z(e,_z())};V(S,e=>{Q.servers.length>0&&Q.filtered.length===0&&Q.filter&&!Q.loading&&!q.authError&&Q.available&&e(C)}),T(n),z(e,n),D()}Hr([`click`]);var bz=`api_keys`,xz=`session_sticky_keys`,Sz=`base_url`,Cz=`service_account_json`,wz=`models`,Tz={[bz]:{label:`API Keys`,control:`keys`,hint:`Identified sessions stay on one key by default, improving provider prompt-cache hits. Saved values are shown as ***********; leave the asterisks unchanged to keep the stored key.`},[xz]:{label:`Session-sticky API keys`,control:`checkbox`,hint:`Keep each identified conversation on one API key to preserve provider prompt-cache affinity. Turn off to rotate keys round-robin on every request.`},[Sz]:{label:`Base URL`,control:`text`},api_version:{label:`API Version`,control:`text`,placeholder:`e.g. 2024-10-01-preview`,hint:`Leave empty for the provider default. Realtime endpoints may need a newer version.`},backend:{label:`Backend`,control:`select`,hint:`Which Google surface to call. Vertex authenticates with Google credentials instead of an API key.`},auth_type:{label:`Auth Type`,control:`select`,hint:`How to obtain Google credentials. Leave on the default to use Application Default Credentials.`},api_mode:{label:`API Mode`,control:`select`,hint:`Which request shape to send upstream.`},vertex_project:{label:`Vertex Project`,control:`text`,placeholder:`my-gcp-project`},vertex_location:{label:`Vertex Location`,control:`text`,placeholder:`us-central1`},service_account_file:{label:`Service Account File`,control:`text`,placeholder:`/path/to/service-account.json`,hint:`Path readable by the gateway process.`},[Cz]:{label:`Service Account JSON`,control:`textarea`,placeholder:`Paste service account JSON`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value, or clear it to remove.`},service_account_json_base64:{label:`Service Account JSON (base64)`,control:`text`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value.`},gcp_scope:{label:`GCP Scope`,control:`text`,placeholder:`https://www.googleapis.com/auth/cloud-platform`},[wz]:{label:`Models (comma-separated)`,control:`text`,placeholder:`gpt-4o, gpt-4o-mini`,hint:`Leave empty to auto-discover models from the provider's /models endpoint where supported.`}};function Ez(e){return Tz[e]||{label:String(e||``).split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),control:`text`}}function Dz(){return{name:``,type:``,api_keys:[],session_sticky_keys:!0,base_url:``,api_version:``,backend:``,auth_type:``,api_mode:``,vertex_project:``,vertex_location:``,service_account_file:``,service_account_json:``,service_account_json_base64:``,gcp_scope:``,models:``,enabled:!0}}function Oz(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.type,e.base_url].some(e=>String(e||``).toLowerCase().includes(r)))}function kz(e,t){let n=(Array.isArray(e)?e:[]).map(e=>String(e&&e.type||``).trim()).filter(Boolean),r=String(t||``).trim();return r&&!n.includes(r)&&n.push(r),n}function Az(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>String(e&&e.type||``).trim()===n)||null}function jz(e,t){let n=e&&Array.isArray(e.fields)&&e.fields.length>0?e.fields:Object.keys(Tz).map(e=>({name:e,advanced:e!==bz})),r=t||e&&e.default_base_url||``,i=[],a=[];for(let e of n){let t=String(e&&e.name||``).trim();if(!t)continue;let n={...Ez(t),name:t,required:!!(e&&e.required),options:Array.isArray(e&&e.options)?e.options:[]};t===`base_url`&&r&&(n.placeholder=r,n.hint=`Defaults to `+r),n.options.length>0&&(n.control=`select`),(e&&e.advanced?a:i).push(n)}return{primary:i,advanced:a}}var Mz=new Set([`name`,`type`,`enabled`]);function Nz(e,t){let n=new Set([...t.primary||[],...t.advanced||[]].map(e=>e.name)),r=Dz(),i={...e};for(let e of Object.keys(r))!Mz.has(e)&&!n.has(e)&&(i[e]=r[e]);return i}function Pz(e){let t=Array.isArray(e&&e.api_keys)?e.api_keys.length:0;return t>0?t+` key`+(t===1?``:`s`):String(e&&e.service_account_json||``).trim()||String(e&&e.service_account_json_base64||``).trim()||String(e&&e.service_account_file||``).trim()?`service account`:String(e&&e.vertex_project||``).trim()?`ADC`:`keyless`}function Fz(e){let t=Array.isArray(e&&e.models)?e.models:[];return t.length===0?`auto-discovered`:t.length+` model`+(t.length===1?``:`s`)}function Iz(e){return(Array.isArray(e)?e:[]).map(e=>({value:String(e||``)}))}function Lz(e){return(Array.isArray(e)?e:[]).map(e=>String(e&&e.value||``))}function Rz(e,t){let n=String(t||``).trim();if(!n)return``;let r=new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.name||``).trim()));if(!r.has(n))return n;let i=1;for(;r.has(n+`-`+i);)i+=1;return n+`-`+i}function zz(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),api_keys:Iz(e&&e.api_keys),session_sticky_keys:!e||e.session_sticky_keys!==!1,base_url:String(e&&e.base_url||``),api_version:String(e&&e.api_version||``),backend:String(e&&e.backend||``),auth_type:String(e&&e.auth_type||``),api_mode:String(e&&e.api_mode||``),vertex_project:String(e&&e.vertex_project||``),vertex_location:String(e&&e.vertex_location||``),service_account_file:String(e&&e.service_account_file||``),service_account_json:String(e&&e.service_account_json||``),service_account_json_base64:String(e&&e.service_account_json_base64||``),gcp_scope:String(e&&e.gcp_scope||``),models:(Array.isArray(e&&e.models)?e.models:[]).join(`, `),enabled:!e||e.enabled!==!1}}function Bz(e){let t=String(e||``).trim();return t.length>=3&&/^\*+$/.test(t)}function Vz(e,t,n,r){let i={},a=String(e&&e.name||``).trim();String(e&&e.type||``).trim()||(i.type=`Select a provider type.`),a?a.includes(`/`)?i.name=`Name cannot contain '/' — it separates the provider from the model.`:t===`create`&&(Array.isArray(n)?n:[]).some(e=>String(e&&e.name||``).trim()===a)&&(i.name=`Provider "`+a+`" already exists.`):i.name=`Name is required.`;let{primary:o,advanced:s}=jz(r);for(let t of[...o,...s]){let n=Hz(e,t);n&&(i[t.name]=n)}return i}function Hz(e,t){if(t.name===`api_keys`){let n=Lz(e&&e.api_keys);return t.required&&!n.some(e=>e.trim())?`At least one API key is required for this provider type.`:n.some(e=>!e.trim())?`Remove the empty row instead of leaving a key blank.`:``}let n=String(e&&e[t.name]||``).trim();if(t.required&&!n)return t.label+` is required for this provider type.`;if(!n)return``;if(t.name===`base_url`&&!n.includes(`://`)&&/[./]/.test(n))return`Include the scheme, e.g. https://`+n;if(t.name===`service_account_json`&&!Bz(n))try{JSON.parse(n)}catch{return`Paste the service account JSON file's contents — this is not valid JSON.`}return``}function Uz(e,t){let n={name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),enabled:!!(e&&e.enabled)},{primary:r,advanced:i}=jz(t),a=!!(t&&Array.isArray(t.fields)&&t.fields.length>0),o=new Set;for(let t of[...r,...i])!a&&t.name===`session_sticky_keys`||(o.add(t.name),n[t.name]=Wz(e,t.name));for(let t of Object.keys(Tz)){if(o.has(t)||t===`session_sticky_keys`)continue;let r=Wz(e,t);(Array.isArray(r)?r.length>0:String(r).trim()!==``)&&(n[t]=r)}return n}function Wz(e,t){switch(t){case bz:return Lz(e&&e.api_keys);case wz:return rc(e&&e.models);case xz:return!!(e&&e.session_sticky_keys);case Cz:return e&&e.service_account_json||``;default:return String(e&&e[t]||``).trim()}}var $=new class{#e=k(j([]));get rows(){return I(this.#e)}set rows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get advancedOpen(){return I(this.#c)}set advancedOpen(e){A(this.#c,e,!0)}#l=k(j(Dz()));get form(){return I(this.#l)}set form(e){A(this.#l,e,!0)}#u=k(j({}));get fieldErrors(){return I(this.#u)}set fieldErrors(e){A(this.#u,e,!0)}#d=k(``);get focusField(){return I(this.#d)}set focusField(e){A(this.#d,e,!0)}#f=k(``);get deletingName(){return I(this.#f)}set deletingName(e){A(this.#f,e,!0)}#p=k(!1);get deleteSubmitting(){return I(this.#p)}set deleteSubmitting(e){A(this.#p,e,!0)}#m=k(j([]));get types(){return I(this.#m)}set types(e){A(this.#m,e,!0)}#h=k(!1);get typesLoaded(){return I(this.#h)}set typesLoaded(e){A(this.#h,e,!0)}#g=null;get filteredRows(){return Oz(this.rows,this.filter)}get schema(){return Az(this.types,this.form.type)}get formFields(){if(!String(this.form.type||``).trim())return{primary:[],advanced:[]};let e=this.schema;return jz(e,e&&e.default_base_url)}async fetchTypes(){let e=await _T(`/admin/provider-credentials/types`,{label:`provider credential types`});e.status===`ok`&&(this.types=e.items,this.typesLoaded=!0)}async fetchPage(){this.#g&&this.#g.abort();let e=new AbortController;this.#g=e,this.loading=!0,this.error=``;try{let t=await _T(`/admin/provider-credentials`,{label:`provider credentials`,errorFallback:`Failed to load provider credentials.`,unavailableStatuses:[503,404],options:{signal:e.signal}});if(t.status===`stale`||e.signal.aborted)return;if(t.status===`unavailable`){this.available=!1,this.rows=[];return}if(t.status===`error`){t.result&&(this.available=!0),this.rows=[],this.error=t.error;return}this.available=!0,this.rows=t.items,this.typesLoaded||await this.fetchTypes()}finally{this.#g===e&&(this.#g=null,this.loading=!1)}}#_(e,t){this.formMode=e,this.form=t,this.advancedOpen=!1,this.error=``,this.fieldErrors={},this.focusField=``}openCreate(){this.#_(`create`,Dz()),this.formOpen=!0,this.typesLoaded||this.fetchTypes()}openEdit(e){!e||e.managed||(this.#_(`edit`,zz(e)),this.formOpen=!0,this.typesLoaded||this.fetchTypes())}closeForm(){this.formOpen=!1,this.#_(`create`,Dz())}selectType(){this.fieldErrors={};let e=this.formFields;this.formMode===`create`&&(this.form=Nz(this.form,e));let t=e.primary.find(e=>e.name===`api_keys`);t&&t.required&&this.form.api_keys.length===0&&(this.form.api_keys=[{value:``}])}clearFieldError(e){if(this.fieldErrors[e]===void 0)return;let{[e]:t,...n}=this.fieldErrors;this.fieldErrors=n}addApiKeyRow(){this.form.api_keys.push({value:``}),this.clearFieldError(`api_keys`)}removeApiKeyRow(e){this.form.api_keys.splice(e,1),this.clearFieldError(`api_keys`)}#v(e){let t=ds(e,`Failed to save provider credential.`),n=String(e&&e.error&&typeof e.error==`object`&&e.error.param||``).trim();if(n&&this.#y(n)){this.fieldErrors={...this.fieldErrors,[n]:t},this.error=``,this.#b();return}this.error=t}#y(e){if(e===`name`||e===`type`)return!0;let{primary:t,advanced:n}=this.formFields;return[...t,...n].some(t=>t.name===e)}#b(){let e=Object.keys(this.fieldErrors);if(e.length===0)return;let{primary:t,advanced:n}=this.formFields;n.some(t=>e.includes(t.name))&&(this.advancedOpen=!0);let r=[`type`,`name`,...t.map(e=>e.name),...n.map(e=>e.name)];this.focusField=r.find(t=>e.includes(t))||e[0]}#x(){Mc.fetchModels(),Mc.fetchCategories()}async submitForm(){let e=this.schema,t=Vz(this.form,this.formMode,this.rows,e);if(Object.keys(t).length>0){this.fieldErrors=t,this.error=``,this.#b();return}let n=Uz(this.form,e);this.error=``,this.fieldErrors={},this.formSubmitting=!0;try{let e=await vT(`/admin/provider-credentials`,`PUT`,n,{label:`save provider credential`,errorFallback:`Failed to save provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.error=e.error;return}if(e.status===`error`){e.result&&e.result.status!==401?this.#v(e.result.data):this.error=e.error;return}J.success(`Provider "`+n.name+`" saved.`),this.closeForm(),this.#x(),this.fetchPage()}finally{this.formSubmitting=!1}}async performDelete(e){this.deleteSubmitting=!0,this.deletingName=e;try{let t=await vT(`/admin/provider-credentials/`+encodeURIComponent(e),`DELETE`,void 0,{label:`delete provider credential`,errorFallback:`Failed to delete provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,Ls.error=t.error;return}if(t.status===`error`){Ls.error=t.error;return}J.success(`Provider "`+e+`" deleted.`),Ls.close(),this.formOpen&&this.form.name===e&&this.closeForm(),this.#x(),this.fetchPage()}finally{this.deleteSubmitting=!1,this.deletingName=``}}requestDelete(e){let t=String(e||``).trim();if(!t||this.deleteSubmitting)return;let n=(this.rows||[]).find(e=>String(e&&e.name||``).trim()===t);n&&n.managed||Ls.open({title:`Delete Provider`,titleId:`providerCredentialDeleteDialogTitle`,inputId:`provider-credential-delete-confirmation`,message:`Type "`+t+`" to permanently delete this provider credential. Requests routed to it will fail until it is reconfigured.`,requiredText:t,confirmLabel:`Delete Provider`,icon:ko,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.performDelete(t)})}},Gz=R(`Config`),Kz=R(` `,1),qz=R(`
              `),Jz=R(`
              NameTypeBase URLAuthModelsEnabledUpdatedActions
              `);function Yz(e,t){E(t,!0);var n=Jz(),r=M(n),i=P(M(r));H(i,21,()=>$.filteredRows,e=>e.name,(e,t)=>{var n=qz(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=e=>{z(e,Gz())};V(o,e=>{I(t).managed&&e(s)}),T(r);var c=P(r),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=M(h,!0);T(h);var _=P(h),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x,!0);T(x);var C=P(x),w=M(C),ee=M(w),te=e=>{var n=Kz(),r=N(n);{let e=O(()=>`Edit provider `+I(t).name);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>$.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>($.deletingName===I(t).name?`Deleting provider `:`Delete provider `)+I(t).name),n=O(()=>$.deletingName===I(t).name);gT(i,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>$.requestDelete(I(t).name),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return Fo},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)};V(ee,e=>{I(t).managed||e(te)}),T(w),T(C),T(n),F((e,n,r)=>{B(a,I(t).name),B(u,I(t).type),W(d,`title`,I(t).base_url||``),B(f,I(t).base_url||`—`),B(m,e),B(g,n),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).enabled,"auth-key-status-inactive":!I(t).enabled}),B(b,I(t).enabled?`Enabled`:`Disabled`),B(S,r)},[()=>Pz(I(t)),()=>Fz(I(t)),()=>us.formatTimestamp(I(t).updated_at)]),z(e,n)}),T(i),T(r),T(n),z(e,n),D()}var Xz=R(``),Zz=R(`
              `),Qz=R(`
              `,1),$z=R(``),eB=R(``),tB=R(``),nB=R(``),rB=R(``),iB=R(` `),aB=R(` `),oB=R(`
              `);function sB(e,t){E(t,!0);let n=O(()=>`provider-credential-`+t.field.name),r=O(()=>$.fieldErrors[t.field.name]||``),i=O(()=>I(r)?I(n)+`-error`:t.field.hint?I(n)+`-hint`:void 0),a=O(()=>{let e=String($.form[t.field.name]||``).trim();return!e||t.field.options.includes(e)?t.field.options:[...t.field.options,e]});function o(){$.clearFieldError(t.field.name)}var s=oB(),c=M(s),l=M(c),u=P(l),d=e=>{z(e,Xz())};V(u,e=>{t.field.required&&e(d)}),T(c);var f=P(c,2),p=e=>{var t=Qz(),a=N(t);H(a,21,()=>$.form.api_keys,oi,(e,t,a)=>{var s=Zz(),c=M(s);na(c),W(c,`aria-label`,`API key `+(a+1)),gT(P(c,2),{label:`Remove API key `+(a+1),class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>$.removeApiKeyRow(a),children:(e,t)=>{K(e,{get icon(){return ko},class:`table-icon-svg`})},$$slots:{default:!0}}),T(s),F(()=>{W(c,`id`,a===0?I(n):I(n)+`-`+a),W(c,`aria-invalid`,I(r)?`true`:void 0),W(c,`aria-describedby`,a===0?I(i):void 0)}),L(`input`,c,o),da(c,()=>I(t).value,e=>I(t).value=e),z(e,s)}),T(a);var s=P(a,2),c=M(s);K(M(c),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(c),T(s),F(()=>W(c,`id`,$.form.api_keys.length===0?I(n):void 0)),L(`click`,c,()=>$.addApiKeyRow()),z(e,t)},m=e=>{var s=eB(),c=M(s);c.value=c.__value=``,H(P(c),16,()=>I(a),e=>e,(e,t)=>{var n=$z(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(s),F(()=>{W(s,`id`,I(n)),W(s,`aria-invalid`,I(r)?`true`:void 0),W(s,`aria-describedby`,I(i))}),L(`change`,s,o),Gi(s,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,s)},h=e=>{var a=tB();na(a),F(()=>{W(a,`id`,I(n)),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`change`,a,o),fa(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},g=e=>{var a=nB();ft(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},_=e=>{var a=rB();na(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)};V(f,e=>{t.field.control===`keys`?e(p):t.field.control===`select`?e(m,1):t.field.control===`checkbox`?e(h,2):t.field.control===`textarea`?e(g,3):e(_,-1)});var v=P(f,2),y=e=>{var t=iB(),i=M(t,!0);T(t),F(()=>{W(t,`id`,I(n)+`-error`),B(i,I(r))}),z(e,t)},b=e=>{var r=aB(),i=M(r,!0);T(r),F(()=>{W(r,`id`,I(n)+`-hint`),B(i,t.field.hint)}),z(e,r)};V(v,e=>{I(r)?e(y):t.field.hint&&e(b,1)}),T(s),F(()=>{W(c,`for`,I(n)),B(l,`${t.field.label??``} `)}),z(e,s),D()}Hr([`input`,`click`,`change`]);var cB=R(`

              The name is the stable identity used for routing and cannot change once created.

              `),lB=R(``),uB=R(` `),dB=R(`Determines which fields the gateway uses to build requests.`),fB=R(` `),pB=R(`Suggested from the selected type; used to route requests to this provider instance and editable before saving.`),mB=R(`Immutable once created.`),hB=R(`

              Pick a type to configure its credentials — each provider type asks for different settings.

              `),gB=R(`
              Advanced settings
              `),_B=R(`
              `,1);function vB(e,t){E(t,!0);let n=O(()=>kz($.types,$.form.type)),r=O(()=>$.formFields),i=O(()=>$.fieldErrors.name||``),a=O(()=>$.fieldErrors.type||``);function o(){$.selectType(),$.formMode===`create`&&($.form.name=Rz($.rows,$.form.type))}An(()=>{let e=$.focusField;if(!e)return;$.focusField=``;let t=document.getElementById(`provider-credential-`+e);t&&(t.scrollIntoView({block:`center`}),t.focus({preventScroll:!0}))});{let t=e=>{z(e,cB())},s=O(()=>$.formMode===`edit`?`Edit Provider`:`Add Provider`);bE(e,{get open(){return $.formOpen},get title(){return I(s)},ariaLabel:`Provider credential editor`,get error(){return $.error},get submitting(){return $.formSubmitting},novalidate:!0,onclose:()=>$.closeForm(),onsubmit:()=>$.submitForm(),headerHint:t,children:(e,t)=>{var s=_B(),c=N(s),l=P(M(c),2),u=M(l);u.value=u.__value=``,H(P(u),16,()=>I(n),e=>e,(e,t)=>{var n=lB(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(l);var d=P(l,2),f=e=>{var t=uB(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)},p=e=>{z(e,dB())};V(d,e=>{I(a)?e(f):e(p,-1)}),T(c);var m=P(c,2),h=P(M(m),2);na(h);var g=P(h,2),_=e=>{var t=fB(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)},v=e=>{z(e,pB())},y=e=>{z(e,mB())};V(g,e=>{I(i)?e(_):$.formMode===`create`?e(v,1):e(y,-1)}),T(m);var b=P(m,2),x=e=>{z(e,hB())};V(b,e=>{$.form.type||e(x)});var S=P(b,2);H(S,17,()=>I(r).primary,e=>e.name,(e,t)=>{sB(e,{get field(){return I(t)}})});var C=P(S,2),w=M(C);bA(M(w),{get enabled(){return $.form.enabled},label:`provider`,onclick:()=>$.form.enabled=!$.form.enabled}),T(w),T(C);var ee=P(C,2),te=e=>{var t=gB(),n=M(t),i=M(n),a=P(M(i),2),o=M(a,!0);T(a),T(i),T(n);var s=P(n,2);H(s,21,()=>I(r).advanced,e=>e.name,(e,t)=>{sB(e,{get field(){return I(t)}})}),T(s),T(t),F(e=>{t.open=$.advancedOpen,B(o,e)},[()=>I(r).advanced.map(e=>e.label).join(`, `)]),Vr(`toggle`,t,e=>$.advancedOpen=e.currentTarget.open),z(e,t)};V(ee,e=>{I(r).advanced.length>0&&e(te)}),F(()=>{l.disabled=$.formMode===`edit`,W(l,`aria-invalid`,I(a)?`true`:void 0),W(l,`aria-describedby`,I(a)?`provider-credential-type-error`:`provider-credential-type-hint`),h.disabled=$.formMode===`edit`,W(h,`aria-invalid`,I(i)?`true`:void 0),W(h,`aria-describedby`,I(i)?`provider-credential-name-error`:`provider-credential-name-hint`)}),L(`change`,l,o),Gi(l,()=>$.form.type,e=>$.form.type=e),L(`input`,h,()=>$.clearFieldError(`name`)),da(h,()=>$.form.name,e=>$.form.name=e),z(e,s)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var yB=R(`

              Providers

              `),bB=R(``),xB=R(`
              Provider credential management is unavailable.
              `),SB=R(``),CB=R(`
              `),wB=R(`

              No dashboard-managed providers yet. Add one here, or declare providers in config.yaml / environment variables.

              `),TB=R(`

              No providers match your filter.

              `),EB=R(`
              `);function DB(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`providers-config`&&$.fetchPage()});var n=EB(),r=M(n),i=M(r);KS(M(i),{copyId:`providers-config-help-copy`,label:`model providers help`,title:e=>{z(e,yB())},help:e=>{Ue(),z(e,Zr(`Configure LLM provider credentials here instead of setting API keys as - environment variables. Providers declared in config.yaml or env vars - are read-only (Config badge) and cannot be edited or deleted from the - dashboard. Keys are masked after saving.`))},$$slots:{title:!0,help:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=bB();K(M(t),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=$.formSubmitting),L(`click`,t,()=>$.openCreate()),z(e,t)};V(o,e=>{$.available&&!q.needsAuth&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,xB())};V(c,e=>{!$.available&&!q.needsAuth&&e(l)});var u=P(c,2),d=e=>{var t=SB(),n=M(t,!0);T(t),F(()=>B(n,$.error)),z(e,t)};V(u,e=>{$.error&&!q.needsAuth&&!$.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading providers...`})};V(f,e=>{$.loading&&!q.needsAuth&&e(p)});var m=P(f,2),h=e=>{var t=CB(),n=M(t);yw(M(n),{id:`provider-credential-filter`,placeholder:`Filter by name, type, or base URL...`,label:`Filter providers by name, type, or base URL`,get value(){return $.filter},set value(e){$.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{($.rows.length>0||$.filter)&&$.available&&!q.needsAuth&&e(h)});var g=P(m,2);vB(g,{});var _=P(g,2),v=e=>{Yz(e,{})};V(_,e=>{$.filteredRows.length>0&&$.available&&!q.needsAuth&&e(v)});var y=P(_,2),b=e=>{z(e,wB())};V(y,e=>{$.rows.length===0&&!$.filter&&!$.loading&&!q.needsAuth&&!$.error&&$.available&&e(b)});var x=P(y,2),S=e=>{z(e,TB())};V(x,e=>{$.rows.length>0&&$.filteredRows.length===0&&$.filter&&!$.loading&&!q.needsAuth&&$.available&&e(S)}),T(n),z(e,n),D()}Hr([`click`]);function OB(){return{name:``,description:``,user_path:``,labels:``,dashboard_access:!1,expires_at:``}}function kB(e){let t=[];for(let n of String(e||``).split(`,`)){let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function AB(e){let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t;for(let e of n.split(`/`)){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function jB(e){if(AB(e))return``;let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t,r=[];for(let e of n.split(`/`)){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function MB(e){let t=e||{},n=String(t.name||``).trim();if(!n)return{error:`Name is required.`};let r=AB(t.user_path);if(r)return{error:r};let i=jB(t.user_path),a=kB(t.labels),o={name:n,description:String(t.description||``).trim()||void 0,user_path:i||void 0,labels:a.length?a:void 0,dashboard_access:t.dashboard_access?!0:void 0};return t.expires_at&&(o.expires_at=t.expires_at+`T23:59:59Z`),{payload:o}}function NB(e,t=Date.now()){let n=e&&e.expires_at;if(!n)return!1;let r=Date.parse(n);return Number.isFinite(r)&&r<=t}function PB(e){return e?!!e.deactivated_at||e.enabled===!1:!1}function FB(e,t=Date.now()){return!e||e.active===!1||PB(e)?!1:!NB(e,t)}function IB(e){return[e.name,e.description,e.user_path,e.redacted_value,...e.labels||[]].filter(Boolean).join(` `).toLowerCase()}function LB(e,t={}){let{query:n=``,showInactive:r=!1,now:i=Date.now()}=t,a=String(n||``).trim().toLowerCase();return(Array.isArray(e)?e:[]).filter(e=>!r&&!FB(e,i)?!1:!a||IB(e).includes(a))}function RB(e,t){return PB(e)?2:+!FB(e,t)}function zB(e){let t=e&&e.expires_at;if(!t)return 1/0;let n=Date.parse(t);return Number.isFinite(n)?n:1/0}function BB(e){let t=Date.parse(e&&e.deactivated_at||``);return Number.isFinite(t)?t:-1/0}function VB(e,t=Date.now()){return(Array.isArray(e)?e.slice():[]).sort((e,n)=>{let r=RB(e,t),i=RB(n,t);if(r!==i)return r-i;let[a,o]=r===2?[BB(e),BB(n)]:[zB(e),zB(n)];return a===o?String(e.name||``).localeCompare(String(n.name||``)):a>o?-1:1})}function HB(e,t=Date.now()){return(Array.isArray(e)?e:[]).reduce((e,n)=>e+ +!FB(n,t),0)}function UB(){return{open:!1,id:``,name:``,value:``,submitting:!1,error:``}}var WB=new class{#e=k(j([]));get keys(){return I(this.#e)}set keys(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get showInactive(){return I(this.#a)}set showInactive(e){A(this.#a,e,!0)}#o=O(()=>VB(LB(this.keys,{query:this.filter,showInactive:this.showInactive})));get visibleKeys(){return I(this.#o)}set visibleKeys(e){A(this.#o,e)}#s=O(()=>HB(this.keys));get inactiveCount(){return I(this.#s)}set inactiveCount(e){A(this.#s,e)}#c=k(!1);get formOpen(){return I(this.#c)}set formOpen(e){A(this.#c,e,!0)}#l=k(!1);get formSubmitting(){return I(this.#l)}set formSubmitting(e){A(this.#l,e,!0)}#u=k(``);get issuedValue(){return I(this.#u)}set issuedValue(e){A(this.#u,e,!0)}#d=k(``);get deactivatingID(){return I(this.#d)}set deactivatingID(e){A(this.#d,e,!0)}#f=k(``);get dashboardAccessID(){return I(this.#f)}set dashboardAccessID(e){A(this.#f,e,!0)}#p=k(j(OB()));get form(){return I(this.#p)}set form(e){A(this.#p,e,!0)}#m=k(j(UB()));get labelsEditor(){return I(this.#m)}set labelsEditor(e){A(this.#m,e,!0)}copyState=_M({logPrefix:`Failed to copy auth key:`});async fetchKeys(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/auth-keys`,{label:`auth keys`,errorFallback:`Unable to load API keys.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.keys=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.error=e.error;return}this.available=!0,this.keys=e.items}finally{this.loading=!1}}openForm(){this.formSubmitting||this.formOpen||(this.formOpen=!0,this.error=``,this.issuedValue||(this.copyState.reset(),this.form=OB()))}closeForm(){this.formOpen&&(this.formOpen=!1,this.error=``,this.copyState.reset(),!this.formSubmitting&&!this.issuedValue&&(this.form=OB()))}copyIssuedValue(){return this.copyState.copy(this.issuedValue)}dismissIssuedKey(){this.issuedValue=``,this.copyState.reset(),this.form=OB()}async submitForm(){let e=MB(this.form);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/auth-keys`,`POST`,e.payload,{label:`create API key`,errorFallback:`Failed to create API key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error,t.result&&t.result.status!==401&&console.error(`Failed to create API key:`,t.result.status,this.error);return}let n=t.result.data||{};this.issuedValue=n.value||``,this.formOpen=!0,this.copyState.reset(),this.form=OB(),this.fetchKeys()}finally{this.formSubmitting=!1}}openLabelsEditor(e){!e||this.labelsEditor.submitting||(this.labelsEditor={open:!0,id:e.id,name:e.name||``,value:(e.labels||[]).join(`, `),submitting:!1,error:``})}closeLabelsEditor(){!this.labelsEditor.open||this.labelsEditor.submitting||(this.labelsEditor=UB())}async submitLabelsEditor(){let e=this.labelsEditor;if(!e.open||e.submitting||!e.id)return;e.submitting=!0,e.error=``;let t={labels:kB(e.value)};try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/labels`,`PUT`,t,{label:`update API key labels`,errorFallback:`Failed to update labels.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,e.error=n.error;return}if(n.status===`error`){e.error=n.error,n.result&&n.result.status!==401&&console.error(`Failed to update auth key labels:`,n.result.status,e.error);return}J.success(`Labels updated for key "`+e.name+`".`),e.submitting=!1,this.closeLabelsEditor(),this.fetchKeys()}finally{e.submitting=!1}}async toggleDashboardAccess(e){if(!e||!e.active||this.dashboardAccessID)return;let t=!e.dashboard_access;this.dashboardAccessID=e.id;try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/dashboard-access`,`PUT`,{dashboard_access:t},{label:`update API key dashboard access`,errorFallback:`Failed to update dashboard access.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,J.error(n.error);return}if(n.status===`error`){n.result&&n.result.status!==401&&console.error(`Failed to update auth key dashboard access:`,n.result.status,n.error),J.error(n.error);return}J.success(`Dashboard access `+(t?`granted to`:`revoked for`)+` key "`+e.name+`".`),this.fetchKeys()}finally{this.dashboardAccessID=``}}async deactivateKey(e){if(!(!e||!e.active)&&window.confirm(`Deactivate key "`+e.name+`"? This cannot be undone.`)){this.deactivatingID=e.id;try{let t=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/deactivate`,`POST`,void 0,{label:`deactivate API key`,errorFallback:`Failed to deactivate key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,J.error(t.error);return}if(t.status===`error`){t.result&&t.result.status!==401&&console.error(`Failed to deactivate auth key:`,t.result.status,t.error),J.error(t.error);return}J.success(`Key "`+e.name+`" deactivated.`),this.fetchKeys()}finally{this.deactivatingID=``}}}},GB=R(``),KB=R(`

              Store this key securely — it won’t be shown again.

              `),qB=R(``),JB=R(``),YB=R(``),XB=R(``),ZB=R(`
              `);function QB(e,t){E(t,!0);{let t=O(()=>WB.issuedValue?``:WB.error),n=O(()=>WB.issuedValue?`Done, I’ve stored it`:`Create API Key`),r=O(()=>WB.issuedValue?Ba:fo);bE(e,{get open(){return WB.formOpen},title:`Create API Key`,ariaLabel:`API key editor`,get error(){return I(t)},get submitting(){return WB.formSubmitting},get submitLabel(){return I(n)},submittingLabel:`Creating...`,get submitIcon(){return I(r)},cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>WB.closeForm(),onsubmit:()=>WB.issuedValue?WB.dismissIssuedKey():WB.submitForm(),children:(e,t)=>{var n=Qr(),r=N(n),i=e=>{var t=KB(),n=P(M(t),2),r=M(n),i=M(r,!0);T(r),uL(P(r,2),{get state(){return WB.copyState},onclick:()=>WB.copyIssuedValue()}),T(n);var a=P(n,2),o=e=>{z(e,GB())};V(a,e=>{WB.copyState.error&&e(o)}),T(t),F(()=>B(i,WB.issuedValue)),z(e,t)},a=e=>{var t=ZB(),n=M(t),r=M(n),i=P(M(r),2);na(i),T(r);var a=P(r,2),o=P(M(a),2);na(o),T(a),T(n);var s=P(n,2),c=M(s);KS(c,{copyId:`auth-key-user-path-help-copy`,label:`API key user path help`,title:e=>{z(e,qB())},help:e=>{Ue(),z(e,Zr(`When set, this key overrides the configured user path request - header for audit logging and downstream request context.`))},$$slots:{title:!0,help:!0}});var l=P(c,2);na(l),T(s);var u=P(s,2),d=M(u);KS(d,{copyId:`auth-key-labels-help-copy`,label:`API key labels help`,title:e=>{z(e,JB())},help:e=>{Ue(),z(e,Zr(`Every request authenticated with this key gets these labels, in - addition to any labels from tagging headers. Labels show up in - usage analytics, the request log, and audit logs.`))},$$slots:{title:!0,help:!0}});var f=P(d,2);na(f),T(u);var p=P(u,2),m=M(p);KS(m,{copyId:`auth-key-dashboard-access-help-copy`,label:`API key dashboard access help`,title:e=>{z(e,YB())},help:e=>{Ue(),z(e,Zr(`When off, this key is denied the dashboard and every /admin API - endpoint. Model endpoints and GET /v1/usage stay available to - the key. The master key always has dashboard access.`))},$$slots:{title:!0,help:!0}});var h=P(m,2),g=M(h);na(g),Ue(2),T(h),T(p),SE(P(p,2),{id:`auth-key-description`,label:`Description (optional)`,children:(e,t)=>{var n=XB();ft(n),da(n,()=>WB.form.description,e=>WB.form.description=e),z(e,n)},$$slots:{default:!0}}),T(t),da(i,()=>WB.form.name,e=>WB.form.name=e),da(o,()=>WB.form.expires_at,e=>WB.form.expires_at=e),da(l,()=>WB.form.user_path,e=>WB.form.user_path=e),da(f,()=>WB.form.labels,e=>WB.form.labels=e),fa(g,()=>WB.form.dashboard_access,e=>WB.form.dashboard_access=e),z(e,t)};V(r,e=>{WB.issuedValue?e(i):e(a,-1)}),z(e,n)},$$slots:{default:!0}})}D()}var $B=R(`

              `),eV=R(`

              Applies to new requests made with this key. Leave empty to remove all labels.

              `,1);function tV(e,t){E(t,!0),bE(e,{get open(){return WB.labelsEditor.open},title:`Edit Labels`,ariaLabel:`API key labels editor`,get error(){return WB.labelsEditor.error},get submitting(){return WB.labelsEditor.submitting},submitLabel:`Save Labels`,cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>WB.closeLabelsEditor(),onsubmit:()=>WB.submitLabelsEditor(),headerHint:e=>{var t=$B(),n=M(t,!0);T(t),F(()=>B(n,WB.labelsEditor.name)),z(e,t)},children:(e,t)=>{SE(e,{id:`auth-key-labels-edit`,label:`Labels (comma-separated)`,children:(e,t)=>{var n=eV(),r=N(n);na(r),Ue(2),da(r,()=>WB.labelsEditor.value,e=>WB.labelsEditor.value=e),z(e,n)},$$slots:{default:!0}})},$$slots:{headerHint:!0,default:!0}}),D()}var nV=R(` `),rV=R(`
              `),iV=R(``),aV=R(`Expired`),oV=R(` `),sV=R(` `,1),cV=R(`Deactivated`),lV=R(`
              `),uV=R(`
              NameDescriptionUser PathLabelsTokenDashboard Access ExpiresCreated
              `);function dV(e,t){E(t,!0);var n=uV(),r=M(n),i=M(r),a=M(i),o=P(M(a),5),s=M(o);K(P(M(s)),{get icon(){return eo},width:`13`,height:`13`}),T(s),T(o),Ue(3),T(a),T(i);var c=P(i);H(c,21,()=>WB.visibleKeys,e=>e.id,(e,t)=>{var n=lV();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i),s=M(o,!0);T(o);var c=P(o),l=M(c,!0);T(c);var u=P(c),d=M(u),f=e=>{var n=rV();H(n,20,()=>I(t).labels||[],e=>e,(e,t)=>{var n=nV(),r=M(n,!0);T(n),F(e=>{Hi(n,e),B(r,t)},[()=>Hy(t)]),z(e,n)}),T(n),z(e,n)},p=e=>{z(e,iV())};V(d,e=>{(I(t).labels||[]).length>0?e(f):e(p,-1)}),T(u);var m=P(u),h=M(m),g=M(h,!0);T(h),T(m);var _=P(m),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x),C=e=>{var n=oV(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{z(e,aV())},s=O(()=>NB(I(t)));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>fc(I(t).expires_at)]),z(e,n)},w=e=>{z(e,Zr(`—`))};V(S,e=>{I(t).expires_at?e(C):e(w,-1)}),T(x);var ee=P(x),te=M(ee,!0);T(ee);var ne=P(ee),re=M(ne),ie=M(re),ae=e=>{var n=sV(),r=N(n);{let e=O(()=>(I(t).dashboard_access?`Revoke dashboard access for API key `:`Grant dashboard access to API key `)+I(t).name),n=O(()=>!!WB.dashboardAccessID);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>WB.toggleDashboardAccess(I(t)),get disabled(){return I(n)},children:(e,n)=>{{let n=O(()=>I(t).dashboard_access?Co:So);K(e,{get icon(){return I(n)},class:`table-icon-svg`})}},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>`Edit labels for API key `+I(t).name);gT(i,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>WB.openLabelsEditor(I(t)),children:(e,t)=>{K(e,{get icon(){return lo},class:`table-icon-svg`})},$$slots:{default:!0}})}var a=P(i,2);{let e=O(()=>(WB.deactivatingID===I(t).id?`Deactivating API key `:`Deactivate API key `)+I(t).name),n=O(()=>WB.deactivatingID===I(t).id);gT(a,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>WB.deactivateKey(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return po},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)},oe=e=>{var n=cV();F(e=>W(n,`title`,e),[()=>I(t).deactivated_at?`Deactivated on `+pc(I(t).deactivated_at):`Deactivated`]),z(e,n)},se=O(()=>PB(I(t)));V(ie,e=>{I(t).active?e(ae):I(se)&&e(oe,1)}),T(re),T(ne),T(n),F((e,i,o)=>{r=U(n,1,`svelte-nf0ldb`,null,r,e),B(a,I(t).name),B(s,I(t).description||`—`),B(l,I(t).user_path||`—`),B(g,I(t).redacted_value),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).dashboard_access,"auth-key-status-inactive":!I(t).dashboard_access}),B(b,I(t).dashboard_access?`Allowed`:`Denied`),W(x,`title`,i),B(te,o)},[()=>({"auth-key-row-deactivated":PB(I(t))}),()=>I(t).expires_at?pc(I(t).expires_at):``,()=>us.formatTimestamp(I(t).created_at)]),z(e,n)}),T(c),T(r),T(n),z(e,n),D()}var fV=R(``),pV=R(`
              API key management is unavailable.
              `),mV=R(``),hV=R(`

              Managed API keys authenticate requests to the gateway. Deactivation is - permanent — create a new key if access needs to be restored.

              `),gV=R(`
              `),_V=R(`
              `),vV=R(`

              `),yV=R(`

              No API keys yet. Issue a key to get started.

              `),bV=R(`
              `);function xV(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`auth-keys`&&WB.fetchKeys()});var n=bV(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=fV();K(M(t),{get icon(){return fo},class:`table-icon-svg`}),Ue(2),T(t),F(()=>t.disabled=WB.formSubmitting),L(`click`,t,()=>{WB.formSubmitting||WB.openForm()}),z(e,t)};V(a,e=>{WB.available&&!q.authError&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,pV())};V(s,e=>{!WB.available&&!q.authError&&e(c)});var l=P(s,2),u=e=>{var t=mV(),n=M(t,!0);T(t),F(()=>B(n,WB.error)),z(e,t)};V(l,e=>{WB.error&&!q.authError&&!WB.formOpen&&e(u)});var d=P(l,2),f=e=>{z(e,hV())};V(d,e=>{WB.available&&!q.authError&&e(f)});var p=P(d,2);QB(p,{});var m=P(p,2);tV(m,{});var h=P(m,2),g=e=>{var t=gV();xS(M(t),{size:18,label:`Loading API keys`}),T(t),z(e,t)};V(h,e=>{WB.loading&&WB.keys.length===0&&e(g)});var _=P(h,2),v=e=>{var t=_V(),n=M(t);yw(M(n),{placeholder:`Filter by name, description, user path, label, or token...`,label:`Filter API keys by name, description, user path, label, or token`,get value(){return WB.filter},set value(e){WB.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i);na(a);var o=P(a,2),s=P(M(o)),c=e=>{var t=Zr();F(()=>B(t,`(${WB.inactiveCount??``})`)),z(e,t)};V(s,e=>{WB.inactiveCount>0&&e(c)}),T(o),T(i),T(r),T(t),fa(a,()=>WB.showInactive,e=>WB.showInactive=e),z(e,t)};V(_,e=>{WB.keys.length>0&&WB.available&&e(v)});var y=P(_,2),b=e=>{dV(e,{})};V(y,e=>{WB.visibleKeys.length>0&&WB.available&&e(b)});var x=P(y,2),S=e=>{var t=vV(),n=M(t);T(t),F(()=>B(n,`No API keys match the current filter.${WB.inactiveCount>0&&!WB.showInactive?` `+WB.inactiveCount+` inactive `+(WB.inactiveCount===1?`key is`:`keys are`)+` hidden.`:``}`)),z(e,t)};V(x,e=>{WB.keys.length>0&&WB.visibleKeys.length===0&&WB.available&&e(S)});var C=P(x,2),w=e=>{z(e,yV())};V(C,e=>{WB.keys.length===0&&!WB.loading&&!q.authError&&!WB.error&&WB.available&&e(w)}),T(n),z(e,n),D()}Hr([`click`]);var SV=R(`

              Timezone

              `),CV=R(``),wV=R(``),TV=R(`
              `,1);function EV(e,t){E(t,!0);function n(){us.saveOverride(),q.refresh()}function r(){us.clearOverride(),q.refresh()}var i=TV(),a=N(i);KS(M(a),{copyId:`timezone-help-copy`,label:`timezone help`,text:`Day-based analytics, charts, and date filters use your effective timezone. Usage and audit logs keep UTC in the hover title while rendering row timestamps in your effective timezone.`,title:e=>{z(e,SV())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=P(M(s),2),l=M(c),u=M(l);T(l),l.value=l.__value=``,H(P(l),17,()=>us.options,e=>e.value,(e,t)=>{var n=CV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(c),T(s),T(o);var d=P(o,2),f=M(d),p=e=>{var t=wV();L(`click`,t,r),z(e,t)};V(f,e=>{us.override&&e(p)}),T(d),F(e=>B(u,`Automatic (${e??``})`),[()=>us.detectedTimeZoneLabel()]),Vr(`focus`,c,()=>us.ensureOptions()),L(`change`,c,n),Gi(c,()=>us.override,e=>us.override=e),z(e,i),D()}Hr([`change`,`click`]);var DV=R(``),OV=R(`

              Failover

              `,1);function kV(e,t){E(t,!0);let n=O(()=>Z.failoverSaving||Z.failoverGenerating||Z.failoverDraftSaving||!Z.failoverAvailable||!Z.failoverEnabled());var r=OV(),i=N(r),a=P(M(i),2),o=M(a),s=M(o);K(s,{get icon(){return No},class:`form-action-icon`});var c=P(s,2),l=M(c,!0);T(c),T(o);var u=P(o,2);K(M(u),{get icon(){return ko},class:`form-action-icon`}),Ue(2),T(u),T(a),T(i);var d=P(i,2),f=M(d),p=e=>{var t=DV(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(f,e=>{Z.failoverError&&e(p)}),T(d),fj(P(d,2),{}),F(()=>{o.disabled=I(n),B(l,Z.failoverGenerating?`Generating...`:`Generate failover models automatically`),u.disabled=I(n)}),L(`click`,o,()=>Z.generateFailoverRules()),L(`click`,u,()=>Z.openFailoverResetDialog()),z(e,r),D()}Hr([`click`]);function AV(){return{daily_reset_hour:0,daily_reset_minute:0,weekly_reset_weekday:1,weekly_reset_hour:0,weekly_reset_minute:0,monthly_reset_day:1,monthly_reset_hour:0,monthly_reset_minute:0}}function jV(e,t){let n=t||{},r=(e,t)=>{if(e===``)return t;let n=Number(e);return Number.isFinite(n)&&Number.isInteger(n)?Math.trunc(n):t},i=(e,t)=>r(n[e],t),a=(t,n)=>e?r(e[t],n):n;return{daily_reset_hour:a(`daily_reset_hour`,i(`daily_reset_hour`,0)),daily_reset_minute:a(`daily_reset_minute`,i(`daily_reset_minute`,0)),weekly_reset_weekday:a(`weekly_reset_weekday`,i(`weekly_reset_weekday`,1)),weekly_reset_hour:a(`weekly_reset_hour`,i(`weekly_reset_hour`,0)),weekly_reset_minute:a(`weekly_reset_minute`,i(`weekly_reset_minute`,0)),monthly_reset_day:a(`monthly_reset_day`,i(`monthly_reset_day`,1)),monthly_reset_hour:a(`monthly_reset_hour`,i(`monthly_reset_hour`,0)),monthly_reset_minute:a(`monthly_reset_minute`,i(`monthly_reset_minute`,0))}}function MV(){return[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}]}var NV=R(`

              Budget Resets

              `),PV=R(``),FV=R(`

              If the selected day does not exist in a month, the reset runs on - the last day of that month.

              `),IV=R(``),LV=R(``),RV=R(`
              Monthly
              Weekly
              Daily
              `,1);function zV(e,t){E(t,!0);let n=k(j(AV())),r=k(!1),i=k(!1),a=k(``),o=k(!1),s=O(()=>xs.budgetsVisible());async function c(){if(await xs.ensureLoaded(),!xs.budgetsVisible()){A(a,``);return}A(r,!0),A(a,``);try{let e=await gs(`/admin/budgets/settings`,{label:`budget settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load budget settings.`);return}A(n,jV(e.data,I(n)),!0)}catch(e){console.error(`Failed to fetch budget settings:`,e),A(a,`Unable to load budget settings.`)}finally{A(r,!1)}}async function l(){if(!I(i)){A(i,!0);try{let e=await _s(`/admin/budgets/settings`,`PUT`,jV(I(n),I(n)),{label:`budget settings`});if(e.stale)return;if(!e.ok){J.error(`Unable to save budget settings.`);return}A(n,jV(e.data,I(n)),!0),A(a,``),J.success(`Budget settings saved.`)}catch(e){console.error(`Failed to save budget settings:`,e),J.error(`Unable to save budget settings.`)}finally{A(i,!1)}}}An(()=>{q.refreshTick,c()});var u=Qr(),d=N(u),f=e=>{var t=RV(),s=N(t),c=M(s);KS(c,{copyId:`budget-settings-help-copy`,label:`budget help`,text:`Budget reset anchors are stored in the database and evaluated in UTC. Hourly budgets reset at the top of each hour.`,title:e=>{z(e,NV())},$$slots:{title:!0}});var u=P(c,2),d=M(u),f=P(M(d),2),p=M(f);KS(p,{copyId:`budget-monthly-day-help-copy`,label:`day of month help`,external:!0,get open(){return I(o)},set open(e){A(o,e,!0)},title:e=>{z(e,PV())},$$slots:{title:!0}});var m=P(p,2);na(m),T(f);var h=P(f,2),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=M(y),x=e=>{z(e,FV())};V(b,e=>{I(o)&&e(x)}),T(y),T(d);var S=P(d,2),C=P(M(S),2),w=P(M(C),2);H(w,21,MV,e=>e.value,(e,t)=>{var n=IV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(w),T(C);var ee=P(C,2),te=P(M(ee),2);na(te),T(ee);var ne=P(ee,2),re=P(M(ne),2);na(re),T(ne),Ue(2),T(S);var ie=P(S,2),ae=P(M(ie),4),oe=P(M(ae),2);na(oe),T(ae);var se=P(ae,2),ce=P(M(se),2);na(ce),T(se),Ue(2),T(ie),T(u);var le=P(u,2),ue=M(le);K(M(ue),{get icon(){return go},class:`form-action-icon`}),Ue(2),T(ue);var de=P(ue,2),fe=e=>{xS(e,{size:16,label:`Loading budget settings`})};V(de,e=>{I(r)&&e(fe)}),T(le),T(s);var pe=P(s,2),me=M(pe),he=e=>{var t=LV(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(me,e=>{I(a)&&e(he)}),T(pe),F(()=>{ue.disabled=I(i)||I(r),W(ue,`aria-busy`,I(i)?`true`:`false`)}),da(m,()=>I(n).monthly_reset_day,e=>I(n).monthly_reset_day=e),da(g,()=>I(n).monthly_reset_hour,e=>I(n).monthly_reset_hour=e),da(v,()=>I(n).monthly_reset_minute,e=>I(n).monthly_reset_minute=e),Gi(w,()=>I(n).weekly_reset_weekday,e=>I(n).weekly_reset_weekday=e),da(te,()=>I(n).weekly_reset_hour,e=>I(n).weekly_reset_hour=e),da(re,()=>I(n).weekly_reset_minute,e=>I(n).weekly_reset_minute=e),da(oe,()=>I(n).daily_reset_hour,e=>I(n).daily_reset_hour=e),da(ce,()=>I(n).daily_reset_minute,e=>I(n).daily_reset_minute=e),L(`click`,ue,l),z(e,t)};V(d,e=>{I(s)&&e(f)}),z(e,u),D()}Hr([`click`]);var BV=R(`

              Reset All Budgets

              Start new budget periods for every configured budget without changing - the limits.

              `);function VV(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=BV(),n=P(M(t),2),r=M(n);K(M(r),{get icon(){return ho},class:`form-action-icon`}),Ue(2),T(r),T(n),T(t),F(()=>r.disabled=Y.resetAllLoading),L(`click`,r,()=>Y.openResetDialog()),z(e,t)},a=O(()=>xs.budgetsVisible());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}Hr([`click`]);function HV(){return{header:``,prefix:``,do_not_pass:!1,delimiter:``,managed:!1}}function UV(e){return(e&&Array.isArray(e.headers)?e.headers:[]).map(e=>({header:typeof e.header==`string`?e.header:``,prefix:typeof e.prefix==`string`?e.prefix:``,do_not_pass:e.do_not_pass===!0,delimiter:typeof e.delimiter==`string`&&e.delimiter!==`,`?e.delimiter:``,managed:e.managed===!0}))}function WV(e){return{headers:(Array.isArray(e)?e:[]).filter(e=>!e.managed&&e.header.trim()!==``).map(e=>({header:e.header.trim(),prefix:e.prefix,do_not_pass:e.do_not_pass,delimiter:e.delimiter}))}}function GV(e){return e&&e.error&&e.error.message?e.error.message:``}var KV=R(`

              Tagging based on headers

              `),qV=R(`config`),JV=R(``),YV=R(`
              `),XV=R(`

              No tagging headers configured. Requests are not labelled.

              `),ZV=R(``),QV=R(`
              `,1);function $V(e,t){E(t,!0);let n=k(j([])),r=k(!0),i=k(!1),a=k(!1),o=k(``);function s(){I(n).push(HV())}function c(e){let t=I(n)[e];!t||t.managed||I(n).splice(e,1)}async function l(){A(i,!0),A(o,``);try{let e=await gs(`/admin/tagging/settings`,{label:`tagging settings`});if(e.stale)return;if(!e.ok){A(o,`Unable to load tagging settings.`);return}A(n,UV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0)}catch(e){console.error(`Failed to fetch tagging settings:`,e),A(o,`Unable to load tagging settings.`)}finally{A(i,!1)}}async function u(){if(!(I(a)||!I(r))){A(a,!0);try{let e=await _s(`/admin/tagging/settings`,`PUT`,WV(I(n)),{label:`tagging settings`});if(e.stale)return;if(!e.ok){J.error(e.status!==401&&GV(e.data)||`Unable to save tagging settings.`);return}A(n,UV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0),A(o,``),J.success(`Tagging settings saved.`)}catch(e){console.error(`Failed to save tagging settings:`,e),J.error(`Unable to save tagging settings.`)}finally{A(a,!1)}}}An(()=>{q.refreshTick,l()});var d=QV(),f=N(d),p=M(f);KS(p,{copyId:`tagging-settings-help-copy`,label:`tagging help`,text:`Each request is labelled from the listed headers; labels land in usage tracking and audit logs. A header value can carry several labels split by the delimiter (default: comma). The prefix is trimmed from each label only — the header itself is forwarded unchanged unless 'Do not pass' is checked. Rows marked CONFIG come from config.yaml or TAGGING_HEADER_* env vars and are read-only here.`,title:e=>{z(e,KV())},$$slots:{title:!0}});var m=P(p,2),h=M(m);H(h,17,()=>I(n),oi,(e,t,n)=>{var i=YV(),a=M(i),o=M(a);W(o,`for`,`tagging-header-`+n);var s=P(o,2);na(s),W(s,`id`,`tagging-header-`+n),T(a);var l=P(a,2),u=M(l);W(u,`for`,`tagging-prefix-`+n);var d=P(u,2);na(d),W(d,`id`,`tagging-prefix-`+n),T(l);var f=P(l,2),p=M(f);W(p,`for`,`tagging-delimiter-`+n);var m=P(p,2);na(m),W(m,`id`,`tagging-delimiter-`+n),T(f);var h=P(f,2),g=M(h);na(g),Ue(2),T(h);var _=P(h,2),v=M(_),y=e=>{z(e,qV())},b=e=>{var i=JV();F(()=>{i.disabled=!I(r),W(i,`aria-label`,`Remove tagging header `+(I(t).header||n+1))}),L(`click`,i,()=>c(n)),z(e,i)};V(v,e=>{I(t).managed?e(y):e(b,-1)}),T(_),T(i),F(()=>{s.disabled=I(t).managed||!I(r),d.disabled=I(t).managed||!I(r),m.disabled=I(t).managed||!I(r),g.disabled=I(t).managed||!I(r)}),da(s,()=>I(t).header,e=>I(t).header=e),da(d,()=>I(t).prefix,e=>I(t).prefix=e),da(m,()=>I(t).delimiter,e=>I(t).delimiter=e),fa(g,()=>I(t).do_not_pass,e=>I(t).do_not_pass=e),z(e,i)});var g=P(h,2),_=e=>{xS(e,{size:16,label:`Loading tagging settings`})};V(g,e=>{I(i)&&e(_)});var v=P(g,2),y=e=>{z(e,XV())};V(v,e=>{!I(i)&&I(n).length===0&&e(y)}),T(m);var b=P(m,2),x=M(b);K(M(x),{get icon(){return fo},class:`form-action-icon`}),Ue(2),T(x);var S=P(x,2);K(M(S),{get icon(){return go},class:`form-action-icon`}),Ue(2),T(S),T(b),T(f);var C=P(f,2),w=M(C),ee=e=>{var t=ZV(),n=M(t,!0);T(t),F(()=>B(n,I(o))),z(e,t)};V(w,e=>{I(o)&&e(ee)}),T(C),F(()=>{x.disabled=!I(r)||I(a)||I(i),S.disabled=!I(r)||I(a)||I(i),W(S,`aria-busy`,I(a)?`true`:`false`)}),L(`click`,x,s),L(`click`,S,u),z(e,d),D()}Hr([`click`]);function eH(e){let t=e||{};if(t.selectedPreset)return{days:parseInt(t.selectedPreset,10)||30};let n=t.customStartDate?dc(t.customStartDate):``,r=t.customEndDate||t.today||null;return{start_date:n,end_date:r?dc(r):``}}function tH(e,t,n,r){return{...eH(e),user_path:String(t||``).trim(),selector:String(n||``).trim(),confirmation:r}}function nH(e){let t=Number(e&&e.matched||0),n=Number(e&&e.recalculated||0),r=Number(e&&e.without_pricing||0),i=`Pricing recalculated for `+n+` of `+t+` usage record`+(t===1?``:`s`)+`.`;return r>0&&(i+=` `+r+` usage record`+(r===1?` still lacks`:`s still lack`)+` pricing metadata.`),i}var rH=R(`

              Usage Pricing Recalculation

              `),iH=R(`
              `);function aH(e,t){E(t,!0);let n=k(``),r=k(``),i=k(!1),a=O(()=>xs.booleanFlag(`USAGE_PRICING_RECALCULATION_ENABLED`,!1));function o(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}I(i)||Ls.open({title:`Recalculate Pricing`,titleId:`pricingRecalculateDialogTitle`,inputId:`pricing-recalculate-confirmation`,requiredText:`recalculate`,confirmLabel:`Recalculate Pricing`,icon:Fa,dialogClass:`pricing-recalculate-dialog`,message:`Stored usage cost fields matching the selected filters will be overwritten.`,onConfirm:()=>s()})}async function s(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}if(!I(i)){A(i,!0);try{let e=await _s(`/admin/usage/recalculate-pricing`,`POST`,tH({selectedPreset:jc.selectedPreset,customStartDate:jc.customStartDate,customEndDate:jc.customEndDate,today:us.todayDate()},I(n),I(r),`recalculate`),{label:`pricing recalculation`});if(e.stale)return;if(!e.ok){Ls.error=`Unable to recalculate pricing.`;return}Ls.close(),J.success(nH(e.data)),Lc.fetchUsage()}catch(e){console.error(`Failed to recalculate pricing:`,e),Ls.error=`Unable to recalculate pricing.`}finally{A(i,!1)}}}var c=Qr(),l=N(c),u=e=>{var t=iH(),s=M(t);KS(s,{copyId:`pricing-recalculate-help-copy`,label:`pricing recalculation help`,text:`Recalculate stored input, output, total, and Pro Saved costs from the current model pricing metadata. This overwrites matching historical cost fields. Filters are applied to the selected date range, user path subtree, and provider/model selector or alias.`,title:e=>{z(e,rH())},$$slots:{title:!0}});var c=P(s,2),l=M(c),u=P(M(l),2);el(M(u),{}),T(u),T(l);var d=P(l,2),f=P(M(d),2);na(f),T(d);var p=P(d,2),m=P(M(p),2);na(m),T(p),T(c);var h=P(c,2),g=M(h);K(M(g),{get icon(){return Fa},class:`form-action-icon`}),Ue(2),T(g),T(h),T(t),F(()=>{g.disabled=I(i)||!I(a),W(g,`aria-busy`,I(i)?`true`:`false`)}),da(f,()=>I(n),e=>A(n,e)),da(m,()=>I(r),e=>A(r,e)),L(`click`,g,o),z(e,t)};V(l,e=>{I(a)&&e(u)}),z(e,c),D()}Hr([`click`]);function oH(e){return String(e&&e.status||`ok`).toLowerCase()}function sH(e){if(!e||typeof e!=`object`)return`Runtime refresh completed.`;let t=Number(e.model_count||0),n=Number(e.provider_count||0),r=oH(e);return(r===`ok`?`Runtime refreshed.`:r===`partial`?`Runtime refresh completed with warnings.`:`Runtime refresh failed.`)+` `+t+` model`+(t===1?``:`s`)+` across `+n+` provider`+(n===1?``:`s`)+`.`}function cH(e){return!!e&&oH(e)===`ok`}function lH(e){let t=e&&e.steps;return Array.isArray(t)?t:[]}function uH(e){let t=String(e&&e.name||``).replace(/_/g,` `),n=String(e&&e.status||``).trim(),r=String(e&&(e.error||e.message)||``).trim();return t?r?t+`: `+n+` - `+r:t+`: `+n:r||n||``}var dH=R(`

              Runtime Refresh

              `),fH=R(`
            • `),pH=R(`
                `),mH=R(`
                `,1);function hH(e,t){E(t,!0);let n=k(!1),r=k(null);async function i(){if(!I(n)){A(n,!0),A(r,null);try{let e=await _s(`/admin/runtime/refresh`,`POST`,void 0,{label:`runtime refresh`});if(e.stale)return;if(!e.ok){J.error(`Runtime refresh failed.`);return}A(r,e.data&&typeof e.data==`object`?e.data:null,!0),cH(I(r))?J.success(sH(I(r))):J.error(sH(I(r))),q.refresh()}catch(e){console.error(`Failed to refresh runtime:`,e),J.error(`Runtime refresh failed.`)}finally{A(n,!1)}}}var a=mH(),o=N(a),s=M(o);KS(s,{copyId:`runtime-refresh-help-copy`,label:`runtime refresh help`,text:`Pull the latest model metadata, provider inventory, API keys, aliases, model access rules, guardrails, and workflows.`,title:e=>{z(e,dH())},$$slots:{title:!0}});var c=P(s,2),l=M(c);let u;K(M(l),{get icon(){return mo},class:`settings-refresh-icon`}),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=M(d),p=e=>{var t=pH();H(t,21,()=>lH(I(r)),e=>e.name,(e,t)=>{var n=fH(),r=M(n,!0);T(n),F(e=>{U(n,1,`runtime-refresh-step is-${I(t).status??``}`,`svelte-yeq2mp`),B(r,e)},[()=>uH(I(t))]),z(e,n)}),T(t),z(e,t)},m=O(()=>lH(I(r)).length>0);V(f,e=>{I(m)&&e(p)}),T(d),F(()=>{u=U(l,1,`btn btn-primary btn-with-icon settings-refresh-btn`,null,u,{"is-refreshing":I(n)}),l.disabled=I(n),W(l,`aria-busy`,I(n)?`true`:`false`)}),L(`click`,l,i),z(e,a),D()}Hr([`click`]);var gH=R(``),_H=R(`

                `),vH=R(`

                `),yH=R(``),bH=R(`
                `),xH=R(`

                AI Processing

                `);function SH(e,t){E(t,!0);let n=k(j([])),r=k(!1),i=k(``),a=k(``);async function o(){A(r,!0),A(a,``);try{let e=await gs(`/admin/runtime/settings`,{label:`runtime settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load runtime settings.`);return}A(n,Array.isArray(e.data?.settings)?e.data.settings:[],!0)}catch(e){console.error(`Failed to load runtime settings:`,e),A(a,`Unable to load runtime settings.`)}finally{A(r,!1)}}async function s(e,t,r){if(!(e.locked||I(i))){A(i,e.key,!0);try{let i=await _s(`/admin/runtime/settings/${encodeURIComponent(e.key)}`,`PUT`,{value:t},{label:`save ${e.label}`});if(i.stale){r.value=e.value;return}if(!i.ok){r.value=e.value,J.error(`Unable to save ${e.label}.`);return}A(n,I(n).map(t=>t.key===e.key?i.data:t),!0),J.success(`${e.label} saved.`)}catch(t){r.value=e.value,console.error(`Failed to save runtime setting:`,t),J.error(`Unable to save ${e.label}.`)}finally{A(i,``)}}}An(()=>{q.refreshTick,o()});var c=Qr(),l=N(c),u=e=>{var t=xH(),o=M(t),c=P(M(o),2),l=e=>{var t=gH(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(c,e=>{I(a)&&e(l)}),T(o);var u=P(o,2);H(u,21,()=>I(n),e=>e.key,(e,t)=>{var n=bH(),r=M(n),a=M(r),o=M(a,!0);T(a);var c=P(a,2),l=e=>{var n=_H(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(c,e=>{I(t).description&&e(l)});var u=P(c,2),d=e=>{var n=vH(),r=M(n);T(n),F(()=>B(r,`Managed by ${(I(t).managed_by||`environment`)??``}`)),z(e,n)};V(u,e=>{I(t).locked&&e(d)}),T(r);var f=P(r,2);H(f,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=yH(),r=M(n,!0);T(n);var i={};F(()=>{W(n,`title`,I(t).description||``),B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(f);var p;Wi(f),T(n),F(()=>{W(a,`for`,`runtime-setting-${I(t).key}`),B(o,I(t).label),W(f,`id`,`runtime-setting-${I(t).key}`),f.disabled=I(t).locked||I(i)!==``,p!==(p=I(t).value)&&(f.value=(f.__value=I(t).value)??``,Ui(f,I(t).value))}),L(`change`,f,e=>s(I(t),e.currentTarget.value,e.currentTarget)),z(e,n)}),T(u),T(t),F(()=>W(u,`aria-busy`,I(r)?`true`:`false`)),z(e,t)};V(l,e=>{(I(n).length>0||I(a))&&e(u)}),z(e,c),D()}Hr([`change`]);var CH=R(`
                `);function wH(e,t){E(t,!0),An(()=>{q.refreshTick,qo.page===`settings`&&(us.ensureOptions(),xs.ensureLoaded())});var n=CH(),r=P(M(n),2),i=M(r);EV(i,{});var a=P(i,2);kV(a,{});var o=P(a,2);zV(o,{});var s=P(o,2);VV(s,{});var c=P(s,2);$V(c,{});var l=P(c,2);SH(l,{});var u=P(l,2);aH(u,{}),hH(P(u,2),{}),T(r);var d=P(r,2),f=M(d,!0);T(d),T(n),F(e=>B(f,e),[()=>Ho()]),z(e,n),D()}var TH=R(`
                `),EH=R(`
                 
                `),DH=R(`
                 
                `),OH=R(`
                 
                `),kH=R(`
                `),AH=R(`
                `,1),jH=R(`
                `);function MH(e,t){E(t,!0);let n=G(t,`showPromptCache`,3,!0),r=O(()=>t.msg.role===`function_call`||t.msg.role===`function_result`);function i(e){return(Math.max(0,Math.min(1,Number(e||0)))*100).toFixed(1)+`%`}function a(e){let t=Math.max(0,Math.min(1,Number(e||0)));return t>0?Math.round(t*100)+`% of this visible prompt item is estimated provider-cached`:void 0}function o(e){return e.role===`function_call`?(e.toolCalls||[]).map(e=>e.name+`()`).join(`, `):(e.functionName?e.functionName+`: `:``)+e.text}var s=jH();let c;var l=M(s),u=e=>{var r=EH(),i=M(r),s=M(i),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l);var d=P(l,2),f=M(d,!0);T(d),T(i);var p=P(i,2),m=e=>{var n=TH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${t.msg.functionCallID??``}`)),z(e,n)};V(p,e=>{t.msg.functionCallID&&e(m)});var h=P(p,2),g=e=>{var n=Qr();H(N(n),17,()=>t.msg.toolCalls,oi,(e,n)=>{var r=Qr(),i=N(r),a=e=>{var r=TH(),i=M(r);T(r),F(()=>B(i,`Call ID${t.msg.toolCalls.length>1?` (`+I(n).name+`)`:``}: ${I(n).id??``}`)),z(e,r)};V(i,e=>{I(n).id&&e(a)}),z(e,r)}),z(e,n)};V(h,e=>{t.msg.role===`function_call`&&t.msg.toolCalls&&e(g)});var _=P(h,2),v=M(_,!0);T(_),T(r),F((e,n,i,a)=>{W(r,`title`,e),B(c,t.msg.roleLabel),B(u,n),B(f,i),B(v,a)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>o(t.msg),()=>us.formatTimestamp(t.msg.timestamp),()=>qI(t.msg)]),z(e,r)},d=e=>{var r=AH(),i=N(r),o=M(i),s=M(o,!0);T(o);var c=P(o,2),l=M(c,!0);T(c),T(i);var u=P(i,2),d=e=>{var r=DH(),i=M(r,!0);T(r),F(e=>{W(r,`title`,e),B(i,t.msg.text)},[()=>n()?a(t.msg.promptCacheRatio):void 0]),z(e,r)};V(u,e=>{t.msg.text&&e(d)});var f=P(u,2),p=e=>{var n=kH();H(n,23,()=>t.msg.toolCalls,(e,t)=>e.name+`-`+t,(e,t)=>{var n=OH(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(r);var c=P(r,2),l=e=>{var n=TH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${I(t).id??``}`)),z(e,n)};V(c,e=>{I(t).id&&e(l)});var u=P(c,2),d=M(u,!0);T(u),T(n),F((e,n)=>{B(a,I(t).name+`()`),B(s,e),B(d,n)},[()=>JI(I(t))||`No arguments`,()=>JI(I(t))||`No arguments`]),z(e,n)}),T(n),z(e,n)};V(f,e=>{t.msg.toolCalls&&e(p)}),F((e,n)=>{W(i,`title`,e),B(s,t.msg.roleLabel),B(l,n)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>us.formatTimestamp(t.msg.timestamp)]),z(e,r)};V(l,e=>{I(r)?e(u):e(d,-1)}),T(s),F(e=>{U(s,1,Fi([I(r)?`chat-function-note`:`chat-message`,t.msg.roleClass,{"is-anchor":t.msg.isAnchor,"is-after-anchor":t.msg.isAfterAnchor}]),`svelte-12s99s5`),W(s,`data-conversation-anchor`,t.msg.isAnchor?`true`:void 0),W(s,`data-entry-id`,t.msg.entryID),c=Hi(s,``,c,e)},[()=>({"--prompt-cache-fill":i(t.msg.promptCacheRatio),"--prompt-cache-visibility":n()&&t.msg.promptCacheRatio>0?`1`:`0`})]),z(e,s),D()}function NH(e,t=0){let n=Math.max(0,IH(e)-Math.max(0,IH(t))),r=Math.min(320,Math.max(180,Math.floor(n*.58))),i=Math.min(360,Math.max(128,Math.floor(n*.35)));return{min:r,max:Math.max(r,n-i)}}function PH(e,t,n=0){let r=NH(t,n),i=IH(e)||520;return Math.min(r.max,Math.max(r.min,Math.round(i)))}function FH(e,t,n=0){return PH(IH(t)-IH(e),t,n)}function IH(e){let t=Number(e);return Number.isFinite(t)?t:0}var LH=R(`
                `),RH=R(`

                Loading interactions...

                `),zH=R(`

                No interaction data available for this entry.

                `),BH=R(``),VH=R(`
                `,1),HH=R(`

                Showing the newest part of this session and the selected log.

                `),UH=R(`
                `),WH=R(``),GH=R(``),KH=R(``);function qH(e,t){E(t,!0);let n=nL,r=Number(wa(`gomodel_interactions_panel_width`)),i=`gomodel_interactions_prompt_cache_fill`,a=Number.isFinite(r)&&r>0?r:520,o=k(j(a)),s=k(320),c=k(760),l=k(!1),u=k(wa(i,`true`)!==`false`),d=null;function f(){A(u,!I(u)),Ta(i,I(u))}function p(){return(document.querySelector(`.sidebar`)?.getBoundingClientRect().width||0)+(document.querySelector(`.sidebar-toggle`)?.getBoundingClientRect().width||0)}function m(){let e=p(),t=NH(window.innerWidth,e);A(s,t.min,!0),A(c,t.max,!0),A(o,PH(a,window.innerWidth,e),!0)}function h(e){A(o,FH(e,window.innerWidth,p()),!0),a=I(o)}function g(e){e.button===0&&(e.preventDefault(),d=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`conversation-panel-resizing`),h(e.clientX))}function _(e){e.pointerId===d&&h(e.clientX)}function v(e){d===null||e.pointerId!==void 0&&e.pointerId!==d||(d=null,document.body.classList.remove(`conversation-panel-resizing`),Ta(`gomodel_interactions_panel_width`,a))}function y(e){e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a=I(o)+(e.key===`ArrowLeft`?24:-24),m(),a=I(o),Ta(`gomodel_interactions_panel_width`,a))}function b(){return[document.querySelector(`.sidebar`),document.querySelector(`.sidebar-toggle`),document.getElementById(`dashboard-content`)].filter(Boolean)}An(()=>{if(!n.conversationOpen)return;m();let e=document.querySelector(`.sidebar`),t=new ResizeObserver(m);e&&t.observe(e);let r=e=>{e.key===`Escape`&&!Aa.anyOpen&&(I(l)?A(l,!1):n.closeConversation())};return window.addEventListener(`keydown`,r),window.addEventListener(`resize`,m),()=>{v({}),t.disconnect(),window.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,m)}}),An(()=>{n.conversationOpen||A(l,!1)}),An(()=>{if(!I(l))return;let e=b().map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));return e.forEach(({element:e})=>{e.inert=!0,e.setAttribute(`aria-hidden`,`true`)}),()=>{e.forEach(({element:e,inert:t,ariaHidden:n})=>{e.inert=t,n===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)})}}),An(()=>{qo.page!==`audit-logs`&&n.conversationOpen&&n.closeConversation()});var x=Qr(),S=N(x),C=e=>{var t=KH();let r,i;var a=M(t),d=P(a,2),p=M(d),m=P(M(p),2),h=M(m);let b;T(m),T(p);var x=P(p,2),S=M(x),C=M(S);{let e=O(()=>I(l)?oo:ao);K(C,{get icon(){return I(e)},class:`table-icon-svg`})}T(S),Os(P(S,2),{label:`Close interactions`,onclick:()=>n.closeConversation(),get el(){return n.conversationCloseBtnEl},set el(e){n.conversationCloseBtnEl=e}}),T(x),T(d);var w=P(d,2),ee=M(w),te=e=>{var t=LH(),r=M(t,!0);T(t),F(()=>B(r,n.conversationError)),z(e,t)};V(ee,e=>{n.conversationError&&e(te)});var ne=P(ee,2),re=e=>{z(e,RH())};V(ne,e=>{n.conversationLoading&&e(re)});var ie=P(ne,2),ae=e=>{z(e,zH())},oe=O(()=>!n.conversationLoading&&!n.followUpSending&&!n.conversationError&&n.conversationMessages.length===0&&!n.conversationLiveWaiting());V(ie,e=>{I(oe)&&e(ae)});var se=P(ie,2),ce=e=>{var t=VH(),r=N(t),i=e=>{var t=BH(),n=M(t);let r;Ue(2),T(t),F(()=>{W(t,`aria-checked`,I(u)),W(t,`title`,(I(u)?`Hide`:`Show`)+` estimated provider prompt-cache fill`),r=U(n,1,`conversation-cache-switch svelte-ssrzja`,null,r,{"is-active":I(u)})}),L(`click`,t,f),z(e,t)},a=O(()=>n.conversationMessages.some(e=>Number(e.promptCacheRatio||0)>0));V(r,e=>{I(a)&&e(i)});var o=P(r,2);H(o,21,()=>n.conversationMessages,e=>e.uid,(e,t)=>{MH(e,{get msg(){return I(t)},get showPromptCache(){return I(u)}})}),T(o),ga(o,e=>n.conversationThreadEl=e,()=>n?.conversationThreadEl),z(e,t)};V(se,e=>{n.conversationMessages.length>0&&e(ce)});var le=P(se,2),ue=e=>{z(e,HH())};V(le,e=>{n.conversationTruncated&&e(ue)});var de=P(le,2),fe=e=>{var t=UH(),r=P(M(t),2),i=M(r,!0);T(r),T(t),F(e=>B(i,e),[()=>n.conversationLiveStatusText()]),z(e,t)},pe=O(()=>n.conversationLiveWaiting());V(de,e=>{I(pe)&&e(fe)}),T(w);var me=P(w,2),he=e=>{var t=GH(),r=M(t),i=M(r);ft(i);var a=P(i,2),o=e=>{var t=WH(),r=M(t,!0);T(t),F(()=>B(r,n.followUpError)),z(e,t)};V(a,e=>{n.followUpError&&e(o)});var s=P(a,2),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u),T(s),T(r),T(t),F((e,t,r)=>{i.disabled=e,B(l,t),u.disabled=r,B(d,n.followUpSending?`Sending…`:`Send`)},[()=>n.followUpSending||n.conversationLiveWaiting(),()=>n.selectedConversationEntry()?.path||``,()=>!n.canSendFollowUp()]),Vr(`submit`,r,e=>{e.preventDefault(),n.sendFollowUp()}),da(i,()=>n.followUpText,e=>n.followUpText=e),z(e,t)},ge=O(()=>n.conversationAnchorID&&n.followUpKind());V(me,e=>{I(ge)&&e(he)}),T(t),ga(t,e=>n.conversationDialogEl=e,()=>n?.conversationDialogEl),F(()=>{r=U(t,1,`conversation-drawer svelte-ssrzja`,null,r,{"conversation-drawer-fullscreen":I(l)}),W(t,`role`,I(l)?`dialog`:void 0),W(t,`aria-modal`,I(l)?`true`:void 0),i=Hi(t,``,i,{"--conversation-panel-width":I(o)+`px`}),W(a,`aria-valuemin`,I(s)),W(a,`aria-valuemax`,I(c)),W(a,`aria-valuenow`,I(o)),W(m,`aria-label`,n.conversationFollowLatest?`Following the latest interaction`:`Viewing a historical interaction`),W(m,`title`,n.conversationFollowLatest?`Following the latest interaction as new events arrive`:`Viewing a historical interaction; live updates are not followed`),b=U(h,1,`live-dot`,null,b,{"is-streaming":n.conversationFollowLatest}),W(S,`aria-label`,I(l)?`Exit fullscreen interactions`:`Show interactions fullscreen`),W(S,`title`,I(l)?`Exit fullscreen`:`Fullscreen`),W(S,`aria-pressed`,I(l))}),L(`pointerdown`,a,g),L(`pointermove`,a,_),L(`pointerup`,a,v),Vr(`pointercancel`,a,v),Vr(`lostpointercapture`,a,v),L(`keydown`,a,y),L(`click`,S,()=>A(l,!I(l))),z(e,t)};V(S,e=>{n.conversationOpen&&e(C)}),z(e,x),D()}Hr([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`click`]);var JH=R(`
                `,1);function YH(e,t){E(t,!0);let n={overview:gC,usage:fT,budgets:HE,"rate-limits":$D,models:Fj,workflows:nP,"audit-logs":KL,guardrails:zR,"mcp-servers":yz,"providers-config":DB,"auth-keys":xV,settings:wH};us.init(),jc.init(),q.init(),Oa.init(),ka.init(),qo.init(),An(()=>{q.refreshTick,xs.fetch(),Mc.fetchModels(),Mc.fetchCategories()}),An(()=>{document.body.classList.toggle(`dashboard-modal-open`,Aa.anyOpen)});let r=O(()=>n[qo.page]||gC);var i=JH(),a=N(i);Es(a,{});var o=P(a,2);let s;var c=M(o);nc(c,{}),_i(P(c,2),()=>I(r),(e,t)=>{t(e,{})}),T(o);var l=P(o,2);qH(l,{});var u=P(l,2);Fs(u,{});var d=P(u,2);Vs(d,{}),ec(P(d,2),{}),F(()=>s=U(o,1,`content`,null,s,{"interactions-open":nL.conversationOpen})),z(e,i),D()}ti(YH,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/admin/dashboard/static/dist/assets/index-ayXqZ3cf.js b/internal/admin/dashboard/static/dist/assets/index-ayXqZ3cf.js new file mode 100644 index 000000000..53662aa18 --- /dev/null +++ b/internal/admin/dashboard/static/dist/assets/index-ayXqZ3cf.js @@ -0,0 +1,67 @@ +(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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`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){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function h(e,t,n=!1){return e===void 0?n?t():t:e}function g(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 _=1<<24,v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,ee=65536,te=1<<19,ne=1<<20,re=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(`legacy props`),ue=Symbol(``),de=Symbol(`attributes`),fe=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),he=Symbol(`form reset`),ge=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},_e=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(`uninitialized`),je=`http://www.w3.org/1999/xhtml`,Me=`http://www.w3.org/2000/svg`,Ne=`http://www.w3.org/1998/Math/MathML`;function Pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Fe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ie(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Le(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Re=!1;function ze(e){Re=e}var Be;function Ve(e){if(e===null)throw Fe(),ke;return Be=e}function He(){return Ve(bn(Be))}function T(e){if(Re){if(bn(Be)!==null)throw Fe(),ke;Be=e}}function Ue(e=1){if(Re){for(var t=e,n=Be;t--;)n=bn(n);Be=n}}function We(e=!0){for(var t=0,n=Be;;){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=bn(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Fe(),ke;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=null;function Xe(e){Ye=e}function E(e,t=!1,n){Ye={p:Ye,i:!1,c:null,e:null,s:e,x:null,r:ir,l:null}}function D(e){var t=Ye,n=t.e;if(n!==null){t.e=null;for(var r of n)jn(r)}return e!==void 0&&(t.x=e),t.i=!0,Ye=t.p,e??{}}function Ze(){return!0}var Qe=[];function $e(){var e=Qe;Qe=[],p(e)}function et(e){if(Qe.length===0&&!zt){var t=Qe;queueMicrotask(()=>{t===Qe&&$e()})}Qe.push(e)}function tt(){for(;Qe.length>0;)$e()}function nt(e){var t=ir;if(t===null)return tr.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;rt(e,t)}function rt(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var it=~(y|b|v);function at(e,t){e.f=e.f&it|t}function ot(e){e.f&512||e.deps===null?at(e,v):at(e,b)}function st(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,st(t.deps))}function ct(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),st(e.deps),at(e,v)}var lt=!1;function ut(e){var t=lt;try{return lt=!1,[e(),lt]}finally{lt=t}}function dt(e,t){if(t){let t=document.body;e.autofocus=!0,et(()=>{document.activeElement===t&&e.focus()})}}function ft(e){Re&&yn(e)!==null&&xn(e)}var pt=!1;function mt(){pt||(pt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[he]?.()})},{capture:!0}))}function ht(e){var t=tr,n=ir;rr(null),ar(null);try{return e()}finally{rr(t),ar(n)}}function gt(e,t,n,r=n){e.addEventListener(t,()=>ht(n));let i=e[he];i?e[he]=()=>{i(),r(!0)}:e[he]=()=>r(!0),mt()}function _t(e){let t=0,n=an(0),r;return()=>{On()&&(I(n),In(()=>(t===0&&(r=Er(()=>e(()=>ln(n)))),t+=1,()=>{et(()=>{--t,t===0&&(r?.(),r=void 0,ln(n))})})))}}var vt=ee|te;function yt(e,t,n,r){new bt(e,t,n,r)}var bt=class{parent;is_pending=!1;transform_error;#e;#t=Re?Be: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=_t(()=>(this.#m=an(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=ir;t.b=this,t.f|=128,n(e)},this.parent=ir.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Ln(()=>{if(Re){let e=this.#t;He();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},vt),Re&&(this.#e=Be)}#g(){try{this.#a=zn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=zn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=zn(()=>e(this.#e)),et(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>zn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Kn(this.#o,()=>{this.#o=null}),this.#b(Ft))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=zn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Xn(this.#a,e);let t=this.#n.pending;this.#o=zn(()=>t(this.#e))}else this.#b(Ft)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){ct(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=ir,n=tr,r=Ye;ar(this.#i),rr(this.#i),Xe(this.#i.ctx);try{return Gt.ensure(),e()}catch(e){return nt(e),null}finally{ar(t),rr(n),Xe(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Kn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,et(()=>{this.#d=!1,this.#m&&sn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),I(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Ft?.is_fork?(this.#a&&Ft.skip_effect(this.#a),this.#o&&Ft.skip_effect(this.#o),this.#s&&Ft.skip_effect(this.#s),Ft.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Un(this.#a),null),this.#o&&=(Un(this.#o),null),this.#s&&=(Un(this.#s),null),Re&&(Ve(this.#t),Ue(),Ve(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Le();return}r=!0,i&&Oe(),this.#s!==null&&Kn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){rt(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return zn(()=>{var t=ir;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return rt(e,this.#i.parent),null}}))};et(()=>{var t;try{t=this.transform_error(e)}catch(e){rt(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>rt(e,this.#i&&this.#i.parent)):o(t)})}};function xt(e,t,n,r){let i=Ze()?Tt:Ot;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=ir,c=St(),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){rt(e,s)}Ct()}}var d=wt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Dt(e))).then(u).catch(e=>rt(e,s)).finally(d)}l?l.then(()=>{c(),f(),Ct()}):f()}function St(){var e=ir,t=tr,n=Ye,r=Ft;return function(i=!0){ar(e),rr(t),Xe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ct(e=!0){ar(null),rr(null),Xe(null),e&&Ft?.deactivate()}function wt(){var e=ir,t=e.b,n=Ft,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 Tt(e){var t=2|y;return ir!==null&&(ir.f|=te),{ctx:Ye,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:ir,ac:null}}var Et=Symbol(`obsolete`);function Dt(e,t,n){let r=ir;r===null&&ve();var i=void 0,a=an(Ae),o=!tr,s=new Set;return Fn(()=>{var t=ir,n=m();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ge&&n.reject(e)}).finally(Ct)}catch(e){n.reject(e),Ct()}var c=Ft;if(o){if(t.f&32768)var l=wt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Et);else for(let e of s.values())e.reject(Et);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Et&&(c.activate(),t?(a.f|=se,sn(a,t)):(a.f&8388608&&(a.f^=se),sn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),kn(()=>{for(let e of s)e.reject(Et)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function O(e){let t=Tt(e);return sr(t),t}function Ot(e){let t=Tt(e);return t.equals=Je,t}function kt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(ge),t.ac=null}),t.fn!==null&&(t.teardown=f),xr(t,0),Vn(t))}function Nt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Sr(t)}var Pt=null,Ft=null,It=null,Lt=null,Rt=null,zt=!1,Bt=!1,Vt=null,Ht=null,Ut=0,Wt=1,Gt=class e{id=Wt++;#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(){Pt===null?Pt=this:(Pt.#n=this,this.#t=Pt),Pt=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)at(r,y),t(r);for(r of n.m)at(r,b),t(r)}this.#p.add(e)}#g(){this.#e=!0,Ut++>1e3&&(this.#x(),qt());for(let e of this.#u)this.#d.delete(e),at(e,y),this.schedule(e);for(let e of this.#d)at(e,b),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Vt=[],r=[],i=Ht=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw en(e),this.#h()||this.discard(),t}if(Ft=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Vt=null,Ht=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)$t(e,t);i.length>0&&Ft.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),It=this,Yt(r),Yt(n),It=null,this.#s?.resolve();var s=Ft;if(this.#a===0&&(this.#c.length===0||s!==null)&&this.#x(),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):_r(r)&&(i&16&&this.#d.add(r),Sr(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}}}#v(){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}#y(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),at(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#x(),Ft=this,this.#g()}#b(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??=m()).promise}static ensure(){if(Ft===null){let t=Ft=new e;!Bt&&!zt&&et(()=>{t.#e||t.flush()})}return Ft}apply(){Lt=null}schedule(e){if(Rt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Vt!==null&&t===ir&&(tr===null||!(tr.f&2)))return;if(n&96){if(!(n&1024))return;t.f^=v}}this.#c.push(t)}#x(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?Pt=e:t.#t=e,this.linked=!1}}};function Kt(e){var t=zt;zt=!0;try{var n;for(e&&(Ft!==null&&!Ft.is_fork&&Ft.flush(),n=e());;){if(tt(),Ft===null)return n;Ft.flush()}}finally{zt=t}}function qt(){try{Ce()}catch(e){rt(e,Rt)}}var Jt=null;function Yt(e){var t=e.length;if(t!==0){for(var n=0;n0)){nn.clear();for(let e of Jt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Jt.has(n)&&(Jt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sr(n)}}Jt.clear()}}Jt=null}}function Xt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Xt(i,t,n,r):e&4194320&&!(e&2048)&&Zt(i,t,r)&&(at(i,y),Qt(i))}}function Zt(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(e.deps!==null)for(let i of e.deps){if(n.call(t,i))return!0;if(i.f&2&&Zt(i,t,r))return r.set(i,!0),!0}return r.set(e,!1),!1}function Qt(e){Ft.schedule(e)}function $t(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),at(e,v);for(var n=e.first;n!==null;)$t(n,t),n=n.next}}function en(e){at(e,v);for(var t=e.first;t!==null;)en(t),t=t.next}var tn=new Set,nn=new Map,rn=!1;function an(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function k(e,t){let n=an(e,t);return sr(n),n}function on(e,t=!1,n=!0){let r=an(e);return t||(r.equals=Je),r}function A(e,t,n=!1){return tr!==null&&(!nr||tr.f&131072)&&Ze()&&tr.f&4325394&&(or===null||!or.has(e))&&De(),sn(e,n?j(t):t,Ht)}function sn(e,t,n=null){if(!e.equals(t)){nn.set(e,$n?t:e.v);var r=Gt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&At(t),Lt===null&&ot(t)}e.wv=gr(),un(e,y,n),Ze()&&ir!==null&&ir.f&1024&&!(ir.f&96)&&(ur===null?dr([e]):ur.push(e)),!r.is_fork&&tn.size>0&&!rn&&cn()}return t}function cn(){rn=!1;for(let e of tn){e.f&1024&&at(e,b);let t;try{t=_r(e)}catch{t=!0}t&&Sr(e)}tn.clear()}function ln(e){A(e,e.v+1)}function un(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ze(),a=r.length,o=0;o{if(mr===d)return e();var t=tr,n=mr;rr(null),hr(d);var r=e();return rr(t),hr(n),r};return i&&r.set(`length`,k(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Te();var i=r.get(t);return i===void 0?f(()=>{var e=k(n.value,u);return r.set(t,e),e}):A(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>k(Ae,u));r.set(t,e),ln(o)}}else A(n,Ae),ln(o);return!0},get(e,n,i){if(n===ce)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>k(j(s?e[n]:Ae),u)),r.set(n,o)),o!==void 0){var c=I(o);return c===Ae?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=I(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===ce)return!0;var n=r.get(t),i=n!==void 0&&n.v!==Ae||Reflect.has(e,t);return(n!==void 0||ir!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>k(i?j(e[t]):Ae,u)),r.set(t,n)),I(n)===Ae)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dk(Ae,u)),r.set(d+``,p)):A(p,Ae)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>k(void 0,u)),A(c,j(n)),r.set(t,c));else{l=c.v!==Ae;var m=f(()=>j(n));A(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&&A(g,_+1)}ln(o)}return!0},ownKeys(e){I(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==Ae});for(var[n,i]of r)i.v!==Ae&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ee()}})}function dn(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=a(t,`firstChild`).get,gn=a(t,`nextSibling`).get,u(e)&&(e[fe]=void 0,e[de]=null,e[pe]=void 0,e.__e=void 0),u(n)&&(n[me]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function M(e,t){if(!Re)return yn(e);var n=yn(Be);if(n===null)n=Be.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),Ve(r),r}return t&&wn(n),Ve(n),n}function N(e,t=!1){if(!Re){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Be?.nodeType!==3){var r=vn();return Be?.before(r),Ve(r),r}wn(Be)}return Be}function P(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=bn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),Ve(a),a}wn(r)}return Ve(r),r}function xn(e){e.textContent=``}function Sn(){return!1}function Cn(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 wn(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 Tn(e){ir===null&&(tr===null&&Se(e),xe()),$n&&be(e)}function En(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Dn(e,t){var n=ir;n!==null&&n.f&8192&&(e|=x);var r={ctx:Ye,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};Ft?.register_created_effect(r);var i=r;if(e&4)Vt===null?Gt.ensure().schedule(r):Vt.push(r);else if(t!==null){try{Sr(r)}catch(e){throw Un(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|=ee))}if(i!==null&&(i.parent=n,n!==null&&En(i,n),tr!==null&&tr.f&2&&!(e&64))){var a=tr;(a.effects??=[]).push(i)}return r}function On(){return tr!==null&&!nr}function kn(e){let t=Dn(8,null);return at(t,v),t.teardown=e,t}function An(e){Tn(`$effect`);var t=ir.f;if(!tr&&t&32&&Ye!==null&&!Ye.i){var n=Ye;(n.e??=[]).push(e)}else return jn(e)}function jn(e){return Dn(4|ne,e)}function Mn(e){Gt.ensure();let t=Dn(64|te,e);return()=>{Un(t)}}function Nn(e){Gt.ensure();let t=Dn(64|te,e);return(e={})=>new Promise(n=>{e.outro?Kn(t,()=>{Un(t),n(void 0)}):(Un(t),n(void 0))})}function Pn(e){return Dn(4,e)}function Fn(e){return Dn(oe|te,e)}function In(e,t=0){return Dn(8|t,e)}function F(e,t=[],n=[],r=[]){xt(r,t,n,t=>{Dn(8,()=>{e(...t.map(I))})})}function Ln(e,t=0){return Dn(16|t,e)}function Rn(e,t=0){return Dn(_|t,e)}function zn(e){return Dn(32|te,e)}function Bn(e){var t=e.teardown;if(t!==null){let e=$n,n=tr;er(!0),rr(null);try{t.call(null)}finally{er(e),rr(n)}}}function Vn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ht(()=>{e.abort(ge)});var r=n.next;n.f&64?n.parent=null:Un(n,t),n=r}}function Hn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Un(t),t=n}}function Un(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Wn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,Vn(e,t&&!n),xr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Bn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Gn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Wn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Gn(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 Kn(e,t,n=!0){var r=[];qn(e,r,!0);var i=()=>{n&&Un(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function qn(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)!=0||(i.f&32)!=0&&(e.f&16)!=0;qn(i,t,o?n:!1)}i=a}}}function Jn(e){Yn(e,!0)}function Yn(e,t){if(e.f&8192){e.f^=x,e.f&1024||(at(e,y),Gt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Yn(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 Xn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var Zn=null,Qn=!1,$n=!1;function er(e){$n=e}var tr=null,nr=!1;function rr(e){tr=e}var ir=null;function ar(e){ir=e}var or=null;function sr(e){tr!==null&&(or??=new Set).add(e)}var cr=null,lr=0,ur=null;function dr(e){ur=e}var fr=1,pr=0,mr=pr;function hr(e){mr=e}function gr(){return++fr}function _r(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Lt===null&&at(e,v)}return!1}function vr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(or!==null&&or.has(e)))for(var i=0;i{e.ac.abort(ge)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=C;var f=e.deps,p=Ft?.is_fork;if(cr!==null){var m;if(p||xr(e,lr),f!==null&&lr>0)for(f.length=lr+cr.length,m=0;m{s.ac.abort(ge),s.ac=null,at(s,y)}),Mt(s),xr(s,0)}}function xr(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`?et(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Vr(e,t,n,r,i){var a={capture:r,passive:i},o=Br(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&kn(()=>{t.removeEventListener(e,o,a)})}function L(e,t,n){(t[Lr]??={})[e]=n}function Hr(e){for(var t=0;t{throw e});throw p}}finally{e[Lr]=t,delete e.currentTarget,rr(d),ar(f)}}}var Gr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Kr(e){return Gr?.createHTML(e)??e}function qr(e){var t=Cn(`template`);return t.innerHTML=Kr(e.replaceAll(``,``)),t.content}function Jr(e,t){var n=ir;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function R(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Re)return Jr(Be,null),Be;i===void 0&&(i=qr(a?e:``+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;Jr(o,s)}else Jr(t,t);return t}}function Yr(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}`,o;return()=>{if(Re)return Jr(Be,null),Be;if(!o){var e=yn(qr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;Jr(n,r)}else Jr(t,t);return t}}function Xr(e,t){return Yr(e,t,`svg`)}function Zr(e=``){if(!Re){var t=vn(e+``);return Jr(t,t),t}var n=Be;return n.nodeType===3?wn(n):(n.before(n=vn()),Ve(n)),Jr(n,n),n}function Qr(){if(Re)return Jr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),Jr(t,n),e}function z(e,t){if(Re){var n=ir;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Be),He();return}e!==null&&e.before(t)}var $r=!0;function ei(e){$r=e}function B(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function ti(e,t){return ri(e,t)}var ni=new Map;function ri(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=Nn(()=>{var u=n??t.appendChild(vn());yt(u,{pending:()=>{}},t=>{E({});var n=Ye;if(o&&(n.c=o),a&&(i.$$events=a),Re&&Jr(t,null),$r=s,l=e(t,i)||{},$r=!0,Re&&(ir.nodes.end=Be,Be===null||Be.nodeType!==8||Be.data!==`]`))throw Fe(),ke;D()},c);var d=new Set,f=e=>{for(var n=0;n{for(var e of d)for(let n of[t,document]){var r=ni.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Wr),r.delete(e),r.size===0&&ni.delete(n)):r.set(e,i)}zr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ii.set(l,u),l}var ii=new WeakMap,ai=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)Jn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Jn(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&&(Un(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();Xn(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else Un(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Kn(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)||(Un(n.effect),this.#n.delete(e))};ensure(e,t){var n=Ft,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:zn(()=>t(a)),fragment:i})}else this.#t.set(e,zn(()=>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 Re&&(this.anchor=Be),this.#a(n)}};function V(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ai(e),a=n?ee:0;function o(e,t){if(Re){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}Ln(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function oi(e,t){return t}function si(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;ci(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;if(l){var u=n,d=u.parentNode;xn(d),d.append(u),e.items.clear()}ci(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function ci(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,di(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=re,pi(d,null,c)):Jn(d):Kn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Ln(()=>{p=I(f);var e=p.length;let t=!1;Re&&Ge(c)===`[!`!=(e===0)&&(c=We(),Ve(c),ze(!1),t=!0);for(var r=new Set,u=Ft,v=Sn(),y=0;ys(c)):(d=zn(()=>s(li??=vn())),d.f|=re)),e>r.size&&ye(``,``,``),Re&&e>0&&Ve(We()),!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&&ze(!0),I(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Re&&(c=Be)}function ui(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function di(e,t,n,i,a){var o=(i&8)!=0,s=t.length,c=e.items,l=ui(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var te=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function fi(e,t,n,r,i,a,o,s){var c=o&1?o&16?an(n):on(n,!1,!1):null,l=o&2?an(i):null;return{v:c,i:l,e:zn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function pi(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=bn(r);if(a.before(r),r===i)return;r=o}}function mi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function hi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Re&&(o=Ve(yn(c)))}F(()=>{var e=ir;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&Jr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Wn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Re){for(var a=Be.data,l=He(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Fe(),ke;Jr(Be,u),o=Ve(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Jr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function gi(e,t,...n){var r=new ai(e);Ln(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},ee)}function _i(e,t,n){var r;Re&&(r=Be,He());var i=new ai(e);Ln(()=>{var e=t()??null;if(Re&&Ge(r)===`[`!=(e!==null)){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,e&&(t=>n(t,e))),ze(!0);return}i.ensure(e,e&&(t=>n(t,e)))},ee)}var vi=()=>performance.now(),yi={tick:e=>requestAnimationFrame(e),now:()=>vi(),tasks:new Set};function bi(){let e=yi.now();yi.tasks.forEach(t=>{t.c(e)||(yi.tasks.delete(t),t.f())}),yi.tasks.size!==0&&yi.tick(bi)}function xi(e){let t;return yi.tasks.size===0&&yi.tick(bi),{promise:new Promise(n=>{yi.tasks.add(t={c:e,f:n})}),abort(){yi.tasks.delete(t)}}}function Si(e,t){ht(()=>{e.dispatchEvent(new CustomEvent(t))})}function Ci(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function wi(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Ci(n.trim());t[i]=r.trim()}return t}var Ti=e=>e,Ei=null;function Di(e){Ei=e}function Oi(e,t,n){var r=(Ei??ir).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Ai(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function ki(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return ht(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Ai(t,m(),p,1,()=>{Si(t,`introstart`)},()=>{Si(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Ai(t,m(),f,0,()=>{Si(t,`outrostart`)},()=>{Si(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=ir;if((g.nodes.t??=[]).push(h),i&&$r){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Pn(()=>{Er(()=>h.in())})}}function Ai(e,t,n,r,i,a){var o=r===1;if(d(t)){var s,c=!1;return et(()=>{c||(s=Ai(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:f,deactivate:f,reset:f,t:()=>r};let{delay:l=0,css:u,tick:p,easing:m=Ti}=t;var h=[];if(o&&n===void 0&&(p&&p(0,1),u)){var g=wi(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var d=!1;if(u)for(var f=Math.ceil(c/(1e3/60)),h=0;h<=f;h+=1){var g=o+s*m(h/f),y=wi(u(g,1-g));l.push(y),d||=y.overflow===`hidden`}d&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*m(e/c)},p&&xi(()=>{if(v.playState!==`running`)return!1;var e=_();return p(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,p?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=f)},deactivate:()=>{a=f},reset:()=>{r===0&&p?.(1,0)},t:()=>_()}}function ji(e,t,n,r,i,a){let o=Re;Re&&He();var s=null;Re&&Be.nodeType===1&&(s=Be,He());var c=Re?Be:e,l=ir,u=new ai(c,!1);Ln(()=>{let e=t()||null;var a=i?i():n||e===`svg`?Me:void 0;if(e===null){u.ensure(null,null),ei(!0);return}return u.ensure(e,t=>{if(e){if(s=Re?s:Cn(e,a),Jr(s,s),r){var n=null;Re&&Ir(e)&&s.append(n=document.createComment(``));var i=Re?yn(s):s.appendChild(vn());Re&&(i===null?ze(!1):Ve(i)),Di(l),r(s,i),n?.remove(),Di(null)}ir.nodes.end=s,t.before(s)}Re&&Ve(t)}),ei(!0),()=>{e&&ei(!1)}},ee),kn(()=>{ei(!0)}),o&&(ze(!0),Ve(c))}function Mi(e,t){var n=void 0,r;Rn(()=>{n!==(n=t())&&(r&&=(Un(r),null),n&&(r=zn(()=>{Pn(()=>n(e))})))})}function Ni(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||Ii.includes(r[o-1]))&&(s===r.length||Ii.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Ri(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 zi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Bi(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(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(zi)),i&&c.push(...Object.keys(i).map(zi));var l=0,u=-1;let t=e.length;for(var d=0;d{Ui(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),kn(()=>{t.disconnect()})}function Gi(e,t,n=t){var r=new WeakSet,i=!0;gt(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ki);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ki(o)}n(a),e.__value=a,Ft!==null&&r.add(Ft)}),Pn(()=>{var a=t();if(e===document.activeElement){var o=Ft;if(r.has(o))return}if(Ui(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ki(s),n(a))}e.__value=a,i=!1}),Wi(e)}function Ki(e){return`__value`in e?e.__value:e.value}var qi=Symbol(`class`),Ji=Symbol(`style`),Yi=Symbol(`is custom element`),Xi=Symbol(`is html`),Zi=_e?`link`:`LINK`,Qi=_e?`input`:`INPUT`,$i=_e?`option`:`OPTION`,ea=_e?`select`:`SELECT`,ta=_e?`progress`:`PROGRESS`;function na(e){if(Re){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;W(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;W(e,`checked`,null),e.checked=r}}};e[he]=n,et(n),mt()}}function ra(e,t){var n=ca(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==ta)||(e.value=t??``)}function ia(e,t){var n=ca(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function aa(e,t){t?e.hasAttribute(`selected`)||e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}function W(e,t,n,r){var i=ca(e);Re&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Zi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ue]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ua(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function oa(e,t,n,r,i=!1,a=!1){if(Re&&i&&e.nodeName===Qi){var o=e;(o.type===`checkbox`?`defaultChecked`:`defaultValue`)in n||na(o)}var s=ca(e),c=s[Yi],l=!s[Xi];let u=Re&&c;u&&ze(!1);var d=t||{},f=e.nodeName===$i;for(var p in t)p in n||(n[p]=null);n.class?n.class=Fi(n.class):(r||n[qi])&&(n.class=null),n[Ji]&&(n.style??=null);var m=ua(e);if(e.nodeName===Qi&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==d.type||h===void 0&&e.hasAttribute(`type`))&&(d.type=h,W(e,`type`,h,a))}for(let i in n){let o=n[i];if(f&&i===`value`&&o==null){e.value=e.__value=``,d[i]=o;continue}if(i===`class`){U(e,e.namespaceURI===`http://www.w3.org/1999/xhtml`,o,r,t?.[qi],n[qi]),d[i]=o,d[qi]=n[qi];continue}if(i===`style`){Hi(e,o,t?.[Ji],n[Ji]),d[i]=o,d[Ji]=n[Ji];continue}var g=d[i];if(!(o===g&&!(o===void 0&&e.hasAttribute(i)))){d[i]=o;var _=i[0]+i[1];if(_!==`$$`)if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=kr(r);if(Dr(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(o!=null)continue;e.removeEventListener(r,d[n],t),d[n]=null}if(v)L(r,e,o),Hr([r]);else if(o!=null){function a(e){d[i].call(this,e)}d[n]=Br(r,e,a,t)}}else if(i===`style`)W(e,i,o);else if(i===`autofocus`)dt(e,!!o);else if(!c&&(i===`__value`||i===`value`&&o!=null))e.value=e.__value=o;else if(i===`selected`&&f)aa(e,o);else{var y=i;l||(y=Mr(y));var b=y===`defaultValue`||y===`defaultChecked`;if(o==null&&!c&&!b)if(s[i]=null,y===`value`||y===`checked`){let n=e,r=t===void 0;if(y===`value`){let e=n.defaultValue;n.removeAttribute(y),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(y),n.defaultChecked=e,n.checked=r?e:!1}}else e.removeAttribute(i);else b||m.includes(y)&&(c||typeof o!=`string`)?(e[y]=o,y in s&&(s[y]=Ae)):typeof o!=`function`&&W(e,y,o,a)}}}return u&&ze(!0),d}function sa(e,t,n=[],r=[],i=[],a,o=!1,s=!1){xt(i,n,r,n=>{var r=void 0,i={},c=e.nodeName===ea,l=!1;if(Rn(()=>{var u=t(...n.map(I)),d=oa(e,r,u,a,o,s);l&&c&&`value`in u&&Ui(e,u.value);for(let e of Object.getOwnPropertySymbols(i))u[e]||Un(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var f=u[t];t.description===`@attach`&&(!r||f!==r[t])&&(i[t]&&Un(i[t]),i[t]=zn(()=>Mi(e,()=>f))),d[t]=f}r=d}),c){var u=e;Pn(()=>{Ui(u,r.value,!0),Wi(u)})}l=!0})}function ca(e){return e[de]??={[Yi]:e.nodeName.includes(`-`),[Xi]:e.namespaceURI===je}}var la=new Map;function ua(e){var t=e.getAttribute(`is`)||e.nodeName,n=la.get(t);if(n)return n;la.set(t,n=[]);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.push(s);i=l(i)}return n}function da(e,t,n=t){var r=new WeakSet;gt(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=pa(e)?ma(a):a,n(a),Ft!==null&&r.add(Ft),await Cr(),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))}}}),(Re&&e.defaultValue!==e.value||Er(t)==null&&e.value)&&(n(pa(e)?ma(e.value):e.value),Ft!==null&&r.add(Ft)),In(()=>{var n=t();if(e===document.activeElement){var i=Ft;if(r.has(i))return}pa(e)&&n===ma(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function fa(e,t,n=t){gt(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Re&&e.defaultChecked!==e.checked||Er(t)==null)&&n(e.checked),In(()=>{e.checked=!!t()})}function pa(e){var t=e.type;return t===`number`||t===`range`}function ma(e){return e===``?null:+e}function ha(e,t){return e===t||e?.[ce]===t}function ga(e={},t,n,r){var i=Ye.r,a=ir;return Pn(()=>{var o,s;return In(()=>{o=s,s=r?.()||[],Er(()=>{ha(n(...s),e)||(t(e,...s),o&&ha(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&&ha(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var _a={get(e,t){if(!e.exclude.has(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return!e.exclude.has(t)&&t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))}};function va(e,t,n){return new Proxy({props:e,exclude:t},_a)}function ya(e,t,n,r){var i=!0,o=(n&8)!=0,s=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>s&&i?(u??=Tt(r),I(u)):(l&&(l=!1,c=s?Er(r):r),c);let f;if(o){var p=ce in e||le in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=ut(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&we(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?Tt:Ot)(()=>(v=!1,g()));o&&I(y);var b=ir;return(function(e,t){if(arguments.length>0){let n=t?I(y):i&&o?j(e):e;return A(y,n),v=!0,c!==void 0&&(c=n),e}return $n&&v||b.f&16384?y.v:I(y)})}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var ba=new Set([`$$slots`,`$$events`,`$$legacy`,`icon`,`class`]),xa=Xr(``);function G(e,t){let n=ya(t,`icon`,19,()=>[]),r=ya(t,`class`,3,``),i=va(t,ba);var a=xa();sa(a,()=>({xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:r(),"aria-hidden":`true`,focusable:`false`,...i}));{let e=(t,n=f)=>{var r=Qr();H(N(r),17,n,oi,(t,n)=>{var r=O(()=>g(I(n),3));let i=()=>I(r)[0],a=()=>I(r)[1],o=()=>I(r)[2];var s=Qr();ji(N(s),i,!0,(t,n)=>{sa(t,()=>({xmlns:`http://www.w3.org/2000/svg`,...a()}));var r=Qr(),i=N(r),s=t=>{e(t,o)},c=O(()=>Array.isArray(o()));V(i,e=>{I(c)&&e(s)}),z(n,r)}),z(t,s)}),z(t,r)};e(M(a),n),T(a)}z(e,a)}var Sa=Xr(``);function Ca(e){z(e,Sa())}function wa(){try{return typeof localStorage>`u`?null:localStorage}catch{return null}}function Ta(e,t=null){let n=wa();if(!n)return t;try{return n.getItem(e)??t}catch{return t}}function Ea(e,t){let n=wa();if(n)try{n.setItem(e,String(t))}catch{}}function Da(e){let t=Number(e);return Number.isFinite(t)?Math.min(240,Math.max(60,Math.round(t))):240}function Oa(e,t,n){return Da(Number(e)+Number(n)-Number(t))}var ka=new class{#e=k(`system`);get theme(){return I(this.#e)}set theme(e){A(this.#e,e,!0)}#t=k(0);get tick(){return I(this.#t)}set tick(e){A(this.#t,e,!0)}init(){this.theme=Ta(`gomodel_theme`,`system`),this.apply(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{this.theme===`system`&&this.tick++})}set(e){this.theme=e,Ea(`gomodel_theme`,e),this.apply(),this.tick++}toggle(){let e=[`light`,`system`,`dark`];this.set(e[(e.indexOf(this.theme)+1)%e.length])}apply(){let e=document.documentElement;this.theme===`system`?e.removeAttribute(`data-theme`):e.setAttribute(`data-theme`,this.theme)}},Aa=new class{#e=k(j(240));get width(){return I(this.#e)}set width(e){A(this.#e,e,!0)}get collapsed(){return this.width===60}init(){let e=Ta(`gomodel_sidebar_width`),t=Ta(`gomodel_sidebar_collapsed`)===`true`;this.setWidth(e??(t?60:240))}toggle(){this.setWidth(this.collapsed?240:60,!0)}setWidth(e,t=!1){this.width=Da(e),typeof document<`u`&&document.documentElement.style.setProperty(`--sidebar-width`,`${this.width}px`),t&&(Ea(`gomodel_sidebar_width`,this.width),Ea(`gomodel_sidebar_collapsed`,this.collapsed))}},ja=new class{#e=k(j([]));get stack(){return I(this.#e)}set stack(e){A(this.#e,e,!0)}#t=1;opened(){let e=this.#t++;return this.stack=[...this.stack,e],e}closed(e){this.stack=this.stack.filter(t=>t!==e)}isTop(e){return this.stack.length>0&&this.stack[this.stack.length-1]===e}get openCount(){return this.stack.length}get anyOpen(){return this.stack.length>0}},Ma=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],Na=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],Pa=[[`path`,{d:`M5 12h14`}],[`path`,{d:`m12 5 7 7-7 7`}]],Fa=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]],Ia=[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`}],[`path`,{d:`M16 10h.01`}],[`path`,{d:`M12 10h.01`}],[`path`,{d:`M8 10h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M8 18h.01`}]],La=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M16 14h.01`}],[`path`,{d:`M8 18h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M16 18h.01`}]],Ra=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}]],za=[[`path`,{d:`M13 17V9`}],[`path`,{d:`M18 17V5`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M8 17v-3`}]],Ba=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M18 17V9`}],[`path`,{d:`M13 17V5`}],[`path`,{d:`M8 17v-3`}]],Va=[[`path`,{d:`M20 6 9 17l-5-5`}]],Ha=[[`path`,{d:`m6 9 6 6 6-6`}]],Ua=[[`path`,{d:`m15 18-6-6 6-6`}]],Wa=[[`path`,{d:`m9 18 6-6-6-6`}]],Ga=[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`}],[`path`,{d:`m9 11 3 3L22 4`}]],Ka=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m9 12 2 2 4-4`}]],qa=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}],[`path`,{d:`M12 18V6`}]],Ja=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],Ya=[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`}]],Xa=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`}],[`path`,{d:`M21 5V8`}],[`path`,{d:`M21 12L18 17H22L19 22`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`}]],Za=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`}]],Qa=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],$a=[[`path`,{d:`m12 14 4-4`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`}]],eo=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}],[`path`,{d:`M12 7v5l4 2`}]],to=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 16v-4`}],[`path`,{d:`M12 8h.01`}]],no=[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],ro=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],io=[[`path`,{d:`M3 5h.01`}],[`path`,{d:`M3 12h.01`}],[`path`,{d:`M3 19h.01`}],[`path`,{d:`M8 5h13`}],[`path`,{d:`M8 12h13`}],[`path`,{d:`M8 19h13`}]],ao=[[`circle`,{cx:`12`,cy:`16`,r:`1`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`}]],oo=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]],so=[[`path`,{d:`m14 10 7-7`}],[`path`,{d:`M20 10h-6V4`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M4 14h6v6`}]],co=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],lo=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],uo=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],fo=[[`path`,{d:`M12 22v-5`}],[`path`,{d:`M15 8V2`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`}],[`path`,{d:`M9 8V2`}]],po=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],mo=[[`path`,{d:`M12 2v10`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`}]],ho=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],go=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],_o=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],vo=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],yo=[[`path`,{d:`m10.852 14.772-.383.923`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`}],[`path`,{d:`m13.148 9.228.383-.923`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`}],[`path`,{d:`m14.772 10.852.923-.383`}],[`path`,{d:`m14.772 13.148.923.383`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`}],[`path`,{d:`M6 18h.01`}],[`path`,{d:`M6 6h.01`}],[`path`,{d:`m9.228 10.852-.923-.383`}],[`path`,{d:`m9.228 13.148-.923.383`}]],bo=[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`}]],xo=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]],So=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],Co=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}],[`path`,{d:`m9 12 2 2 4-4`}]],wo=[[`path`,{d:`m2 2 20 20`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`}]],To=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}]],Eo=[[`path`,{d:`m18 14 4 4-4 4`}],[`path`,{d:`m18 2 4 4-4 4`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`}]],Do=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],Oo=[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],ko=[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`}],[`circle`,{cx:`12`,cy:`14`,r:`8`}]],Ao=[[`path`,{d:`M10 11v6`}],[`path`,{d:`M14 11v6`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]],jo=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]],Mo=[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}],[`circle`,{cx:`12`,cy:`7`,r:`4`}]],No=[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`}]],Po=[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`}],[`path`,{d:`m14 7 3 3`}],[`path`,{d:`M5 6v4`}],[`path`,{d:`M19 14v4`}],[`path`,{d:`M10 2v2`}],[`path`,{d:`M7 8H3`}],[`path`,{d:`M21 16h-4`}],[`path`,{d:`M11 3H9`}]],Fo=[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`}]],Io=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],Lo=R(``),Ro=R(`
                `,1);function zo(e,t){E(t,!0);let n=ya(t,`compact`,3,!1),r=[{value:`light`,icon:Do,label:`Light theme`},{value:`system`,icon:co,label:`System theme`},{value:`dark`,icon:lo,label:`Dark theme`}],i=O(()=>r.find(e=>e.value===ka.theme)||r[1]),a=O(()=>`Change theme (currently `+I(i).label+`)`);var o=Ro(),s=N(o);let c;H(s,21,()=>r,e=>e.value,(e,t)=>{var n=Lo();let r;G(M(n),{get icon(){return I(t).icon},class:`theme-icon`}),T(n),F(()=>{r=U(n,1,`theme-btn svelte-1keql7b`,null,r,{active:ka.theme===I(t).value}),W(n,`aria-pressed`,ka.theme===I(t).value),W(n,`title`,I(t).label),W(n,`aria-label`,I(t).label)}),L(`click`,n,()=>ka.set(I(t).value)),z(e,n)}),T(s);var l=P(s,2);let u;G(M(l),{get icon(){return I(i).icon},class:`theme-icon`}),T(l),F(()=>{c=U(s,1,`theme-toggle svelte-1keql7b`,null,c,{"is-compact":n()}),u=U(l,1,`theme-toggle-mobile svelte-1keql7b`,null,u,{"is-compact":n()}),W(l,`title`,I(a)),W(l,`aria-label`,I(a))}),L(`click`,l,()=>ka.toggle()),z(e,o),D()}Hr([`click`]);function Bo(){return typeof window>`u`?`/`:window.GOMODEL_BASE_PATH||`/`}function Vo(e){let t=Bo();return!e||e.charAt(0)!==`/`||e.indexOf(`//`)===0||t===`/`||e===t||e.indexOf(t+`/`)===0?e:t+e}function Ho(e){let t=Bo();return t===`/`||!e?e:e===t?`/`:e.indexOf(t+`/`)===0?e.slice(t.length)||`/`:e}function Uo(){return typeof window>`u`?``:window.GOMODEL_VERSION||``}function Wo(){return typeof window>`u`?!1:window.GOMODEL_DEMO_MODE===!0}var Go=[`overview`,`usage`,`budgets`,`rate-limits`,`models`,`workflows`,`audit-logs`,`guardrails`,`mcp-servers`,`providers-config`,`auth-keys`,`settings`];function Ko(e){return e.startsWith(`/admin/static/`)?`/`+e.slice(14).replace(/^\/+/,``):e}function qo(e){let t=Ko(Ho(e)).replace(/\/$/,``).replace(`/admin/dashboard`,``).replace(/^\//,``).split(`/`),n=t[0];n===`audit`&&(n=`audit-logs`);let r=t[1]||null;return n===`settings`&&r===`guardrails`?{page:`guardrails`,sub:null}:(n=Go.includes(n)?n:`overview`,{page:n,sub:r})}var Jo=new class{#e=k(`overview`);get page(){return I(this.#e)}set page(e){A(this.#e,e,!0)}#t=k(null);get sub(){return I(this.#t)}set sub(e){A(this.#t,e,!0)}init(){let{page:e,sub:t}=qo(window.location.pathname);this.page=e,this.sub=t,window.addEventListener(`popstate`,()=>{let{page:e,sub:t}=qo(window.location.pathname);this.page=e,this.sub=t})}navigate(e,t=null){let n=t?`/`+t:``;history.pushState(null,``,Vo(`/admin/dashboard/`+e+n)),this.page=e,this.sub=t}},Yo=`gomodel_api_key`;function Xo(e){let t=String(e||``).trim();if(/^Bearer\s*$/i.test(t))return``;let n=t.match(/^Bearer\s+(.+)$/i);return n?n[1].trim():t}var K=new class{#e=k(``);get apiKey(){return I(this.#e)}set apiKey(e){A(this.#e,e,!0)}#t=k(!1);get needsAuth(){return I(this.#t)}set needsAuth(e){A(this.#t,e,!0)}#n=k(!1);get authError(){return I(this.#n)}set authError(e){A(this.#n,e,!0)}#r=k(``);get authErrorMessage(){return I(this.#r)}set authErrorMessage(e){A(this.#r,e,!0)}#i=k(!1);get dialogOpen(){return I(this.#i)}set dialogOpen(e){A(this.#i,e,!0)}#a=k(0);get generation(){return I(this.#a)}set generation(e){A(this.#a,e,!0)}#o=k(0);get refreshTick(){return I(this.#o)}set refreshTick(e){A(this.#o,e,!0)}init(){try{this.apiKey=Xo(localStorage.getItem(Yo)||``)}catch{this.apiKey=``}}hasApiKey(){return Xo(this.apiKey)!==``}save(){this.apiKey=Xo(this.apiKey);try{localStorage.setItem(Yo,this.apiKey)}catch{}}openDialog(){this.dialogOpen=!0}closeDialog(){this.dialogOpen=!1}submit(){let e=Xo(this.apiKey);return e?(this.apiKey=e,this.save(),this.generation++,this.authError=!1,this.authErrorMessage=``,this.needsAuth=!1,this.closeDialog(),this.refresh(),!0):(this.apiKey=``,this.authError=!0,this.authErrorMessage=``,this.needsAuth=!0,this.openDialog(),!1)}refresh(){this.refreshTick++}handleUnauthorized(e,t=``){return typeof e==`number`&&e{r[e.type]=e.value}),r.year+`-`+r.month+`-`+r.day}formatTimestampInTimeZone(e,t){if(e==null)return`-`;let n=new Date(e);if(Number.isNaN(n.getTime()))return`-`;let r=ss(`en-CA`,{timeZone:cs(t)?t:rs,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(n),i={};return r.forEach(e=>{i[e.type]=e.value}),i.year+`-`+i.month+`-`+i.day+` `+i.hour+`:`+i.minute+`:`+i.second}formatTimestamp(e){return this.formatTimestampInTimeZone(e,this.effectiveTimezone())}currentDateKey(e){return this.dateKeyInTimeZone(e||new Date,this.effectiveTimezone())}dateKeyToDate(e){return Qo(e)}dateToDateKey(e){return $o(e)}addDaysToDateKey(e,t){return es(e,t)}todayDate(){return this.dateKeyToDate(this.currentDateKey())}startOfMonthDate(e){let t=e instanceof Date?e:this.todayDate();return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1))}timeZoneOffsetLabel(e,t){let n=cs(e)?e:rs;try{let e=ss(`en-US`,{timeZone:n,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`,timeZoneName:`longOffset`}).formatToParts(t||new Date).find(e=>e.type===`timeZoneName`);if(!e||!e.value)return`UTC+00:00`;let r=e.value.replace(`GMT`,`UTC`);return r===`UTC`?`UTC+00:00`:r}catch{return`UTC+00:00`}}timeZoneOffsetMinutes(e,t){let n=/^UTC([+-])(\d{2}):(\d{2})$/.exec(this.timeZoneOffsetLabel(e,t));if(!n)return 0;let r=Number(n[2])*60+Number(n[3]);return n[1]===`-`?-r:r}timeZoneOptionLabel(e,t){return e+` (`+this.timeZoneOffsetLabel(e,t)+`)`}detectedTimeZoneLabel(){return this.timeZoneOptionLabel(this.detectedTimezone)}effectiveTimeZoneLabel(){return this.timeZoneOptionLabel(this.effectiveTimezone())}ensureOptions(){if(this.optionsLoaded)return;let e=new Date,t=[];try{typeof Intl.supportedValuesOf==`function`&&(t=Intl.supportedValuesOf(`timeZone`))}catch{t=[]}[rs,this.detectedTimezone,this.override].forEach(e=>{e&&t.indexOf(e)===-1&&cs(e)&&t.push(e)}),t=t.filter(e=>cs(e)),t.sort((t,n)=>{let r=this.timeZoneOffsetMinutes(t,e)-this.timeZoneOffsetMinutes(n,e);return r===0?t.localeCompare(n):r}),this.options=t.map(t=>({value:t,label:this.timeZoneOptionLabel(t,e)})),this.optionsLoaded=!0}saveOverride(){let e=wa();if(e)if(this.override&&cs(this.override))try{e.setItem(is,this.override)}catch{}else{try{e.removeItem(is)}catch{}this.override=``}this.optionsLoaded=!1,this.ensureOptions()}clearOverride(){let e=wa();if(e)try{e.removeItem(is)}catch{}this.override=``}calendarTimeZoneText(){let e=this.override?`manual override`:`auto-detected`;return`Activity grouped by `+this.effectiveTimeZoneLabel()+` (`+e+`)`}};function fs(e,t){let n=e&&typeof e==`object`&&e.error&&e.error.message;return(typeof n==`string`?n.trim():``)||t}function ps(e,t){let n=e&&e.data;if(n&&typeof n==`object`){let e=[n.message,n.error,n.error&&typeof n.error==`object`?n.error.message:null];for(let t of e)if(typeof t==`string`&&t.trim())return t.trim()}return t}function ms(){let e={"Content-Type":`application/json`},t=Xo(K.apiKey);return t&&(e.Authorization=`Bearer `+t),e[`X-GoModel-Timezone`]=ds.effectiveTimezone(),e}function hs(e,t={}){return fetch(Vo(e),{...t,headers:{...ms(),...t.headers||{}}})}async function gs(e,t,{label:n=e,parse:r=!0}={}){let i=K.generation,a=await hs(e,t);if(a.status===401)return K.handleUnauthorized(i),{ok:!1,stale:ie.trim()).filter(Boolean);return e.length>0?e:xs}cacheVisible(){if(this.flag(`CACHE_ENABLED`)!==``)return this.booleanFlag(`CACHE_ENABLED`,!1);let e=this.flag(`REDIS_URL`),t=this.flag(`SEMANTIC_CACHE_ENABLED`);return e===``&&t===``||this.booleanFlag(`REDIS_URL`,!1)||this.booleanFlag(`SEMANTIC_CACHE_ENABLED`,!1)}auditVisible(){return this.booleanFlag(`LOGGING_ENABLED`,!0)}usageVisible(){return this.booleanFlag(`USAGE_ENABLED`,!0)}budgetsVisible(){return this.booleanFlag(`BUDGETS_ENABLED`,!0)}rateLimitsVisible(){return this.booleanFlag(`RATE_LIMITS_ENABLED`,!0)}guardrailsVisible(){return this.booleanFlag(`GUARDRAILS_ENABLED`,!0)}mcpVisible(){return this.booleanFlag(`MCP_ENABLED`,!0)}liveLogsVisible(){return this.booleanFlag(`DASHBOARD_LIVE_LOGS_ENABLED`,!0)}fetch(){return this.#n||=this.#r().finally(()=>{this.#n=null}),this.#n}async ensureLoaded(){if(this.#n){await this.#n;return}this.loaded||await this.fetch()}async#r(){let e=typeof AbortController==`function`?new AbortController:null,t=e?setTimeout(()=>e.abort(),1e4):null;try{let t=await _s(`/admin/runtime/config`,{label:`dashboard config`,signal:e?e.signal:void 0});if(t.stale)return;if(!t.ok){this.config={},this.loaded=!1;return}let n=t.data,r={};for(let e of bs)n&&typeof n==`object`&&!Array.isArray(n)&&n[e]!==void 0&&n[e]!==null&&(r[e]=String(n[e]).trim());this.config=r,this.loaded=!0}catch(e){console.error(`Failed to fetch dashboard config:`,e),this.config={},this.loaded=!1}finally{t!==null&&clearTimeout(t)}}},Cs=[{page:`overview`,label:`Overview`,icon:ro},{page:`providers-config`,label:`Providers`,icon:yo},{page:`models`,label:`Models`,icon:Fa},{page:`audit-logs`,label:`Audit Logs`,icon:eo},{page:`usage`,label:`Usage`,icon:Ba},{page:`budgets`,label:`Budgets`,icon:No,visible:()=>Ss.budgetsVisible()},{page:`rate-limits`,label:`Rate Limits`,icon:$a,visible:()=>Ss.rateLimitsVisible()},{page:`auth-keys`,label:`API Keys`,icon:no},{page:`workflows`,label:`Workflows`,icon:Fo},{page:`guardrails`,label:`Guardrails (experimental)`,icon:Co,visible:()=>Ss.guardrailsVisible()},{page:`mcp-servers`,label:`MCP Servers`,icon:fo,visible:()=>Ss.mcpVisible()},{page:`settings`,label:`Settings`,icon:So}],ws=R(` `),Ts=R(`
                `),Es=R(` `,1);function Ds(e,t){E(t,!0);let n=O(()=>Cs.filter(e=>!e.visible||e.visible())),r=k(null),i=0,a=0,o=!1;function s(e){e.button===0&&(e.preventDefault(),A(r,e.pointerId,!0),i=e.clientX,a=Aa.width,o=!1,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`sidebar-resizing`))}function c(e){e.pointerId===I(r)&&(!o&&Math.abs(e.clientX-i)<=4||(o=!0,Aa.setWidth(Oa(a,i,e.clientX))))}function l(e){I(r)===null||e.pointerId!==void 0&&e.pointerId!==I(r)||(A(r,null),document.body.classList.remove(`sidebar-resizing`),Aa.setWidth(Aa.width,!0))}function u(){if(o){o=!1;return}Aa.toggle()}function d(e){let t;if(e.key===`ArrowLeft`)t=Aa.width-12;else if(e.key===`ArrowRight`)t=Aa.width+12;else if(e.key===`Home`)t=60;else if(e.key===`End`)t=240;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),Aa.toggle();return}else return;e.preventDefault(),Aa.setWidth(t,!0)}var f=Es(),p=N(f);let m;var h=M(p),g=M(h);Ca(M(g),{}),T(g),Ue(4),T(h);var _=P(h,2);H(_,21,()=>I(n),e=>e.page,(e,t)=>{var n=ws();let r;var i=M(n);G(i,{get icon(){return I(t).icon},class:`nav-icon`});var a=P(i,2),o=M(a,!0);T(a),T(n),F(e=>{W(n,`href`,e),r=U(n,1,`nav-item svelte-1nwtzae`,null,r,{active:Jo.page===I(t).page}),W(n,`title`,I(t).label),B(o,I(t).label)},[()=>Vo(`/admin/dashboard/`+I(t).page)]),L(`click`,n,e=>{e.preventDefault(),Jo.navigate(I(t).page)}),z(e,n)}),T(_);var v=P(_,2),y=M(v);zo(y,{get compact(){return Aa.collapsed}});var b=P(y,2),x=e=>{var t=Ts(),n=M(t),r=M(n);G(r,{get icon(){return ao},class:`api-key-open-icon`});var i=P(r,2),a=M(i,!0);T(i),T(n),T(t),F(()=>{W(n,`aria-label`,K.needsAuth?`Enter API key`:`Change API key`),B(a,K.needsAuth?`Enter API key`:`Change API key`)}),L(`click`,n,()=>K.openDialog()),z(e,t)},S=O(()=>K.needsAuth||K.hasApiKey());V(b,e=>{I(S)&&e(x)}),T(v),T(p);var C=P(p,2);F(()=>{m=U(p,1,`sidebar svelte-1nwtzae`,null,m,{"sidebar-collapsed":Aa.collapsed,"sidebar-resizing":I(r)!==null}),W(C,`aria-valuemin`,60),W(C,`aria-valuemax`,240),W(C,`aria-valuenow`,Aa.width)}),L(`pointerdown`,C,s),L(`pointermove`,C,c),L(`pointerup`,C,l),Vr(`pointercancel`,C,l),Vr(`lostpointercapture`,C,l),L(`keydown`,C,d),L(`click`,C,u),z(e,f),D()}Hr([`click`,`pointerdown`,`pointermove`,`pointerup`,`keydown`]);var Os=R(``);function ks(e,t){E(t,!0);let n=ya(t,`label`,3,`Close`),r=ya(t,`class`,3,``),i=ya(t,`iconClass`,3,`table-icon-svg`),a=ya(t,`disabled`,3,!1),o=ya(t,`el`,15,null);var s=Os();G(M(s),{get icon(){return Io},get class(){return i()}}),T(s),ga(s,e=>o(e),()=>o()),F(()=>{U(s,1,Fi([`dialog-close-btn`,r()]),`svelte-11l1bb5`),W(s,`aria-label`,n()),s.disabled=a()}),L(`click`,s,function(...e){t.onclick?.apply(this,e)}),z(e,s),D()}Hr([`click`]);function As(e){return t=>{let n=n=>{t.contains(n.target)||e()},r=t=>{t.key===`Escape`&&e()};return document.addEventListener(`click`,n,!0),window.addEventListener(`keydown`,r),()=>{document.removeEventListener(`click`,n,!0),window.removeEventListener(`keydown`,r)}}}function js(e=`[data-modal-autofocus]`){return t=>{let n=t.querySelector(e);n&&typeof n.focus==`function`&&n.focus()}}var Ms=R(`
                `,1);function Ns(e,t){E(t,!0);let n=ya(t,`open`,3,!1),r=ya(t,`variant`,3,`editor`),i=ya(t,`closeOnBackdrop`,3,!0),a=O(()=>r()===`auth`?`auth-dialog-backdrop`:`editor-modal-backdrop`),o=O(()=>r()===`auth`?`auth-dialog-shell`:`editor-modal-shell`);An(()=>{if(!n())return;let e=Er(()=>ja.opened()),r=n=>{n.key===`Escape`&&ja.isTop(e)&&t.onclose?.()};return window.addEventListener(`keydown`,r),()=>{ja.closed(e),window.removeEventListener(`keydown`,r)}});function s(e){i()&&e.target===e.currentTarget&&t.onclose?.()}var c=Qr(),l=N(c),u=e=>{var n=Ms(),r=N(n),i=P(r,2);gi(M(i),()=>t.children??f),T(i),Mi(i,js),F(()=>{U(r,1,Fi(I(a)),`svelte-17e0w4c`),U(i,1,Fi(I(o)),`svelte-17e0w4c`)}),L(`click`,i,s),z(e,n)};V(l,e=>{n()&&e(u)}),z(e,c),D()}Hr([`click`]);var Ps=R(``),Fs=R(``);function Is(e,t){E(t,!0),Ns(e,{get open(){return K.dialogOpen},variant:`auth`,onclose:()=>K.closeDialog(),children:(e,t)=>{var n=Fs(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a),T(i),ks(P(i,2),{label:`Close authentication dialog`,onclick:()=>K.closeDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var s=P(r,2),c=M(s),l=M(c);G(l,{get icon(){return ao},class:`auth-dialog-input-icon`});var u=P(l,2);na(u),T(c);var d=P(c,2),f=e=>{var t=Ps(),n=M(t,!0);T(t),F(()=>B(n,K.authErrorMessage||`Enter a valid API key to continue.`)),z(e,t)};V(d,e=>{K.authError&&e(f)});var p=P(d,4),m=M(p),h=M(m);G(h,{get icon(){return Va},class:`auth-dialog-submit-icon`});var g=P(h,2),_=M(g,!0);T(g),T(m),T(p),T(s),T(n),F(()=>{B(o,K.needsAuth?`Dashboard locked`:`Change API key`),B(_,K.needsAuth?`Unlock dashboard`:`Save API key`)}),Vr(`submit`,s,e=>{e.preventDefault(),K.submit()}),da(u,()=>K.apiKey,e=>K.apiKey=e),z(e,n)},$$slots:{default:!0}}),D()}function Ls(){return{open:!1,title:``,titleId:`typedConfirmationDialogTitle`,inputId:`typed-confirmation-input`,message:``,requiredText:``,value:``,confirmLabel:`Confirm`,icon:jo,dialogClass:``,loading:!1,onConfirm:null,onClose:null}}var Rs=new class{#e=k(j(Ls()));get state(){return I(this.#e)}set state(e){A(this.#e,e,!0)}#t=k(``);get error(){return I(this.#t)}set error(e){A(this.#t,e,!0)}open(e){this.error=``,this.state={...Ls(),open:!0,...e||{}}}close(){let e=this.state;typeof e.onClose==`function`&&e.onClose(),this.state=Ls(),this.error=``}ready(){return String(this.state.value||``).trim().toLowerCase()===String(this.state.requiredText||``).trim().toLowerCase()}inputLabel(){return`Type `+String(this.state.requiredText||``).trim()+` to confirm`}async submit(){if(!this.ready()){this.error=this.inputLabel()+`.`;return}if(typeof this.state.onConfirm==`function`){this.state.loading=!0;try{await this.state.onConfirm()}finally{this.state.loading=!1}}}},zs=R(`

                `),Bs=R(``),Vs=R(`

                `);function Hs(e,t){E(t,!0);let n=O(()=>Rs.state);Ns(e,{get open(){return I(n).open},variant:`auth`,onclose:()=>Rs.close(),children:(e,t)=>{var r=Vs(),i=M(r),a=M(i),o=M(a,!0);T(a),ks(P(a,2),{label:`Close confirmation dialog`,onclick:()=>Rs.close(),class:`auth-dialog-close`,iconClass:``}),T(i);var s=P(i,2),c=M(s),l=e=>{var t=zs(),r=M(t,!0);T(t),F(()=>B(r,I(n).message)),z(e,t)};V(c,e=>{I(n).message&&e(l)});var u=P(c,2),d=M(u),f=M(d,!0);T(d);var p=P(d,2);na(p),T(u);var m=P(u,2),h=e=>{var t=Bs(),n=M(t,!0);T(t),F(()=>B(n,Rs.error)),z(e,t)};V(m,e=>{Rs.error&&e(h)});var g=P(m,2),_=M(g),v=P(_,2),y=M(v);G(y,{get icon(){return I(n).icon},class:`form-action-icon`});var b=P(y,2),x=M(b,!0);T(b),T(v),T(g),T(s),T(r),F((e,t)=>{U(r,1,`auth-dialog ${I(n).dialogClass??``}`),W(r,`aria-labelledby`,I(n).titleId),W(a,`id`,I(n).titleId),B(o,I(n).title),W(d,`for`,I(n).inputId),B(f,e),W(p,`id`,I(n).inputId),v.disabled=t,B(x,I(n).confirmLabel)},[()=>Rs.inputLabel(),()=>I(n).loading||!Rs.ready()]),Vr(`submit`,s,e=>{e.preventDefault(),Rs.submit()}),da(p,()=>Rs.state.value,e=>Rs.state.value=e),L(`click`,_,()=>Rs.close()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var Us=e=>e;function Ws(e){let t=e-1;return t*t*t+1}function Gs(e){let t=typeof e==`string`&&e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);return t?[parseFloat(t[1]),t[2]||`px`]:[e,`px`]}function Ks(e,{delay:t=0,duration:n=400,easing:r=Us}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}function qs(e,{delay:t=0,duration:n=400,easing:r=Ws,x:i=0,y:a=0,opacity:o=0}={}){let s=getComputedStyle(e),c=+s.opacity,l=s.transform===`none`?``:s.transform,u=c*(1-o),[d,f]=Gs(i),[p,m]=Gs(a);return{delay:t,duration:n,easing:r,css:(e,t)=>` + transform: ${l} translate(${(1-e)*d}${f}, ${(1-e)*p}${m}); + opacity: ${c-u*t}`}}function Js(e,{delay:t=0,duration:n=400,easing:r=Ws,axis:i=`y`}={}){let a=getComputedStyle(e),o=+a.opacity,s=i===`y`?`height`:`width`,c=parseFloat(a[s]),l=i===`y`?[`top`,`bottom`]:[`left`,`right`],u=l.map(e=>`${e[0].toUpperCase()}${e.slice(1)}`),d=parseFloat(a[`padding${u[0]}`]),f=parseFloat(a[`padding${u[1]}`]),p=parseFloat(a[`margin${u[0]}`]),m=parseFloat(a[`margin${u[1]}`]),h=parseFloat(a[`border${u[0]}Width`]),g=parseFloat(a[`border${u[1]}Width`]);return{delay:t,duration:n,easing:r,css:e=>`overflow: hidden;opacity: ${Math.min(e*20,1)*o};${s}: ${e*c}px;padding-${l[0]}: ${e*d}px;padding-${l[1]}: ${e*f}px;margin-${l[0]}: ${e*p}px;margin-${l[1]}: ${e*m}px;border-${l[0]}-width: ${e*h}px;border-${l[1]}-width: ${e*g}px;min-${s}: 0`}}function Ys(e){return--e*e*(2.70158*e+1.70158)+1}function Xs(e){let t=e-1;return t*t*t+1}var Zs=5e3,Qs=8e3,q=new class{#e=k(j([]));get toasts(){return I(this.#e)}set toasts(e){A(this.#e,e,!0)}#t=0;#n=new Map;success(e){this.#r(`success`,e,Zs)}error(e){this.#r(`error`,e,Qs)}dismiss(e){let t=this.#n.get(e);t&&(clearTimeout(t),this.#n.delete(e)),this.toasts=this.toasts.filter(t=>t.id!==e)}#r(e,t,n){let r=String(t||``).trim();if(!r)return;let i=this.toasts.find(t=>t.kind===e&&t.text===r);i&&this.dismiss(i.id);let a=++this.#t;this.toasts=[...this.toasts,{id:a,kind:e,text:r}],this.#n.set(a,setTimeout(()=>this.dismiss(a),n))}},$s=R(`
                `),ec=R(`
                `);function tc(e,t){E(t,!0);var n=ec();H(n,21,()=>q.toasts,e=>e.id,(e,t)=>{var n=$s();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2);T(n),F(()=>{r=U(n,1,`flash-toast svelte-1i257xg`,null,r,{"flash-toast-success":I(t).kind===`success`,"flash-toast-error":I(t).kind===`error`}),W(n,`role`,I(t).kind===`error`?`alert`:`status`),W(n,`aria-live`,I(t).kind===`error`?`assertive`:`polite`),B(a,I(t).text)}),L(`click`,o,()=>q.dismiss(I(t).id)),ki(1,n,()=>qs,()=>({y:-24,duration:360,easing:Ys})),ki(2,n,()=>Ks,()=>({duration:150})),z(e,n)}),T(n),z(e,n),D()}Hr([`click`]);var nc=R(``);function rc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{z(e,nc())},a=O(()=>Wo());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}function ic(e){return String(e||``).split(`,`).map(e=>e.trim()).filter(e=>e)}function ac(e){if(e==null||e===``)return`Not captured`;if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function oc(e){return e==null||e===void 0?`-`:e.toLocaleString()}function sc(e){if(e==null)return`---`;let t=Number(e);return Number.isFinite(t)?t>0&&t<1e-4?`<$0.0001`:`$`+t.toFixed(4).replace(/(\.\d{2}\d*?)0+$/,`$1`):`---`}function cc(e){return e==null||e===void 0?`—`:`$`+e.toFixed(2)}function lc(e){return e==null||e===void 0?`—`:e<.01?`$`+e.toFixed(6):`$`+e.toFixed(4)}function uc(e){if(e==null||e===``)return`-`;let t=Number(e);if(!Number.isFinite(t))return`-`;let n=Math.abs(t),r=[{threshold:1e9,suffix:`B`},{threshold:1e6,suffix:`M`},{threshold:1e3,suffix:`K`}];for(let e=0;e=i.threshold){let n=t/i.threshold;return Math.abs(Number(n.toFixed(1)))>=1e3&&e>0&&(i=r[e-1],n=t/i.threshold),n.toFixed(1).replace(/\.0$/,``)+i.suffix}}return String(t)}function dc(e,t){let n=t==null||t===``?NaN:Number(t),r=Number.isFinite(n)?oc(n):`-`;return String(e||`Tokens`)+`: `+r}function fc(e){return e?typeof e==`string`?e:e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`):``}function pc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)}function mc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)+` `+String(t.getUTCHours()).padStart(2,`0`)+`:`+String(t.getUTCMinutes()).padStart(2,`0`)+`:`+String(t.getUTCSeconds()).padStart(2,`0`)+` UTC`}function hc(e){return String(e&&e.provider||``).trim()}function gc(e){return String(e&&e.provider_name||``).trim()||hc(e)}function _c(e,t){let n=String(t||``).trim();if(!n)return`-`;let r=gc(e);return!r||n===r||n.startsWith(r+`/`)?n:r+`/`+n}function vc(e){return _c(e,e&&e.model)}function yc(e){return _c(e,e&&e.resolved_model)}function bc(e){let t=String(e&&(e.requested_model||e.model)||``).trim();if(!e)return t;let n=String(e.data&&e.data.failover&&e.data.failover.target_model||``).trim();if(n&&n!==t)return t+` ⮕ `+n;if(e.alias_used&&e.resolved_model){let n=yc(e);if(n&&n!==`-`&&n!==t)return t+` ⮕ `+n}return t}var xc=`gomodel_date_range`,Sc=1;function Cc(e){return/^[1-9]\d*$/.test(String(e??``))}var wc=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Tc({selectedPreset:e,startKey:t,endKey:n,followsToday:r}){return e&&Cc(e)?{v:Sc,mode:`preset`,days:String(e)}:e?null:ts(t)&&ts(n)?{v:Sc,mode:`custom`,start:t,end:n,follow:r===!0}:null}function Ec(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return null}return!t||typeof t!=`object`?null:t.mode===`preset`?Cc(t.days)?{mode:`preset`,days:String(t.days)}:null:t.mode===`custom`&&ts(t.start)&&ts(t.end)&&t.start<=t.end?{mode:`custom`,start:t.start,end:t.end,follow:t.follow===!0}:null}function Dc(e,t,n){let r=ns(e,t);return r<1||!ts(n)?{start:e,end:t}:{start:es(n,-(r-1)),end:n}}function Oc(e,t){if(e===t)return`Today`;let[n,r,i]=e.split(`-`);return wc[Number(r)-1]+` `+Number(i)+`, `+n}function kc({selectedPreset:e,startKey:t,endKey:n,followsToday:r,todayKey:i}){if(e)return`Last `+e+` days`;if(!ts(t)||!ts(n))return``;let a=ns(t,n);return r||n===i?a===1?`Today`:`Last `+a+` days`:a===1?`1 day`:a+` days`}function Ac({selectedPreset:e,startKey:t,endKey:n,todayKey:r}){if(e)return`Last `+e+` days`;let i=e=>Oc(e,r);return ts(t)&&ts(n)?t===n?i(t):i(t)+` – `+i(n):ts(t)?i(t)+` – ...`:`Last 30 days`}var jc=6e4,Mc=new class{#e=k(j(`30`));get days(){return I(this.#e)}set days(e){A(this.#e,e,!0)}#t=k(j(`30`));get selectedPreset(){return I(this.#t)}set selectedPreset(e){A(this.#t,e,!0)}#n=k(null);get customStartDate(){return I(this.#n)}set customStartDate(e){A(this.#n,e,!0)}#r=k(null);get customEndDate(){return I(this.#r)}set customEndDate(e){A(this.#r,e,!0)}#i=k(!1);get followsToday(){return I(this.#i)}set followsToday(e){A(this.#i,e,!0)}#a=k(`daily`);get interval(){return I(this.#a)}set interval(e){A(this.#a,e,!0)}#o=k(0);get syncTick(){return I(this.#o)}set syncTick(e){A(this.#o,e,!0)}init(){this.restore(),this.syncToToday(),typeof setInterval==`function`&&setInterval(()=>this.syncToToday(),jc)}queryStr(){return this.customStartDate&&this.customEndDate?`start_date=`+fc(this.customStartDate)+`&end_date=`+fc(this.customEndDate):`days=`+this.days}selectPreset(e){this.selectedPreset=e,this.customStartDate=null,this.customEndDate=null,this.followsToday=!1,this.days=e,this.persist()}selectStart(e){this.selectedPreset=null,this.customStartDate=e,this.customEndDate&&this.customEndDatet.category===e);return t?t.count:0}get filteredModels(){if(!this.filter)return this.models;let e=this.filter.toLowerCase();return this.models.filter(t=>(t.model?.id??``).toLowerCase().includes(e)||(t.provider_name??``).toLowerCase().includes(e)||(t.provider_type??``).toLowerCase().includes(e)||(t.selector??``).toLowerCase().includes(e)||(t.model?.owned_by??``).toLowerCase().includes(e)||(t.model?.metadata?.modes??[]).join(`,`).toLowerCase().includes(e)||(t.model?.metadata?.categories??[]).join(`,`).toLowerCase().includes(e))}},Pc=R(``);function Fc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Pc(),n=P(M(t),2);T(t),L(`click`,n,()=>K.openDialog()),z(e,t)};V(r,e=>{K.authError&&e(i)}),z(e,n),D()}Hr([`click`]);function Ic(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null}}function Lc(){return{summary:{total_hits:0,exact_hits:0,semantic_hits:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_saved_cost:null},daily:[]}}var Rc=new class{#e=k(j(Ic()));get summary(){return I(this.#e)}set summary(e){A(this.#e,e,!0)}#t=k(j([]));get daily(){return I(this.#t)}set daily(e){A(this.#t,e,!0)}#n=k(j(Lc()));get cacheOverview(){return I(this.#n)}set cacheOverview(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=null;#a=null;cacheAnalyticsEnabled(){return Ss.cacheVisible()}async fetchUsage(){this.#i&&this.#i.abort();let e=new AbortController;this.#i=e,this.loading=!0;try{let t=Mc.queryStr()+`&interval=`+Mc.interval,[n,r]=await Promise.all([_s(`/admin/usage/summary?`+t,{label:`usage summary`,signal:e.signal}),_s(`/admin/usage/daily?`+t,{label:`usage daily`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.summary=Ic(),this.daily=[],this.cacheOverview=Lc();return}this.summary=n.data||Ic(),this.daily=Array.isArray(r.data)?r.data:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch usage:`,e),this.summary=Ic(),this.daily=[]}finally{this.#i===e&&(this.#i=null,this.loading=!1)}}async fetchCacheOverview(e=``){if(await Ss.ensureLoaded(),!this.cacheAnalyticsEnabled()){this.cacheOverview=Lc();return}this.#a&&this.#a.abort();let t=new AbortController;this.#a=t;try{let n=await _s(`/admin/cache/overview?`+(Mc.queryStr()+`&interval=`+Mc.interval+e),{label:`cache overview`,signal:t.signal});if(n.stale||t.signal.aborted)return;if(!n.ok){this.cacheOverview=Lc();return}let r=n.data&&typeof n.data==`object`?n.data:Lc();r.summary||=Lc().summary,Array.isArray(r.daily)||(r.daily=[]),this.cacheOverview=r}catch(e){if(ys(e))return;console.error(`Failed to fetch cache overview:`,e),this.cacheOverview=Lc()}finally{this.#a===t&&(this.#a=null)}}},zc=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Bc(e,t){let n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return zc[n.getUTCMonth()]+` `+n.getUTCFullYear()}function Vc(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth()+t,a=new Date(Date.UTC(r,i,1)),o=new Date(Date.UTC(r,i+1,0)),s=(a.getUTCDay()+6)%7,c=[],l=new Date(Date.UTC(r,i,0));for(let e=s-1;e>=0;e--){let t=l.getUTCDate()-e,a=new Date(Date.UTC(r,i-1,t));c.push({day:t,date:a,current:!1,key:`p-`+n(a)})}for(let e=1;e<=o.getUTCDate();e++){let t=new Date(Date.UTC(r,i,e));c.push({day:e,date:t,current:!0,key:`c-`+n(t)})}let u=42-c.length;for(let e=1;e<=u;e++){let t=new Date(Date.UTC(r,i+1,e));c.push({day:e,date:t,current:!1,key:`n-`+n(t)})}return c}function Hc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return n&&r.getTime()>n.getTime()?e:r}function Uc(e,t){return e.getUTCFullYear()===t.getUTCFullYear()&&e.getUTCMonth()===t.getUTCMonth()}var Wc=R(``),Gc=R(``),Kc=R(``),qc=R(`
                MoTuWeThFrSaSu
                `);function Jc(e,t){E(t,!0);let n=ya(t,`offset`,3,0),r=O(()=>Vc(t.calendarMonth,n(),e=>ds.dateToDateKey(e))),i=O(()=>Uc(t.calendarMonth,ds.todayDate())),a=e=>ds.dateToDateKey(e.date),o=e=>a(e)>ds.currentDateKey(),s=e=>e.current&&a(e)===ds.currentDateKey();function c(e,t){let n=t===`start`?Mc.rangeStart():Mc.rangeEnd();return e.current&&!!n&&a(e)===ds.dateToDateKey(n)}function l(e){let t=Mc.rangeStart(),n=Mc.rangeEnd();return!e.current||!t||!n?!1:a(e)>=ds.dateToDateKey(t)&&a(e)<=ds.dateToDateKey(n)}var u=qc(),d=M(u),f=M(d);let p;var m=P(f,2),h=M(m,!0);T(m);var g=P(m,2),_=e=>{z(e,Wc())},v=e=>{var n=Gc();F(()=>n.disabled=I(i)),L(`click`,n,function(...e){t.onnext?.apply(this,e)}),z(e,n)};V(g,e=>{n()===-1?e(_):e(v,-1)}),T(d);var y=P(d,4);H(y,21,()=>I(r),e=>e.key,(e,n)=>{var r=Kc(),i=M(r,!0);T(r),F((e,t)=>{U(r,1,e,`svelte-g7ga4u`),r.disabled=t,B(i,I(n).day)},[()=>Fi([`dp-day`,{"other-month":!I(n).current,today:s(I(n)),"range-start":c(I(n),`start`),"range-end":c(I(n),`end`),"in-range":l(I(n)),disabled:o(I(n))}]),()=>o(I(n))||!I(n).current]),L(`click`,r,()=>t.onselect?.(I(n))),z(e,r)}),T(y),T(u),F(e=>{p=U(f,1,`dp-nav-btn svelte-g7ga4u`,null,p,{"dp-nav-prev-mobile":n()!==-1}),B(h,e)},[()=>Bc(t.calendarMonth,n())]),L(`click`,f,function(...e){t.onprev?.apply(this,e)}),z(e,u),D()}Hr([`click`]);var Yc=R(``),Xc=R(`
                `),Zc=Xr(``),Qc=Xr(``),$c=R(`
                `),el=R(`
                `);function tl(e,t){E(t,!0);let n=[`3`,`7`,`14`,`30`,`90`],r=k(!1),i=k(`start`),a=k(j(new Date)),o=k(j({show:!1,x:0,y:0}));function s(){A(r,!I(r)),I(r)&&(Mc.syncToToday(),A(a,ds.startOfMonthDate(Mc.customEndDate||ds.todayDate()),!0),A(i,`start`))}function c(){A(r,!1),A(o,{show:!1,x:0,y:0},!0)}let l=Mc.syncTick;An(()=>{let e=Mc.syncTick;e!==l&&(l=e,t.onchange?.())});function u(e){Mc.selectPreset(e),A(i,`start`),t.onchange?.(),c()}let d=()=>A(a,Hc(I(a),-1),!0),f=()=>A(a,Hc(I(a),1,ds.startOfMonthDate(ds.todayDate())),!0);function p(e){let n=new Date(e.date);if(I(i)===`start`){Mc.selectStart(n),A(i,`end`),t.onchange?.();return}Mc.selectEnd(n),A(i,`start`),t.onchange?.(),c()}var m=el(),h=M(m),g=P(M(h),2),_=M(g,!0);T(g);var v=P(g,2);let y;T(h);var b=P(h,2),x=e=>{var t=Xc(),r=M(t);H(r,20,()=>n,e=>e,(e,t)=>{var n=Yc();let r;var i=M(n);T(n),F(()=>{r=U(n,1,`preset-btn svelte-ax7ma4`,null,r,{active:Mc.selectedPreset===t}),B(i,`Last ${t??``} days`)}),L(`click`,n,()=>u(t)),z(e,n)}),T(r);var i=P(r,2);H(i,20,()=>[-1,0],e=>e,(e,t)=>{Jc(e,{get calendarMonth(){return I(a)},get offset(){return t},onprev:d,onnext:f,onselect:p})}),T(i),T(t),L(`mousemove`,i,e=>A(o,{show:!0,x:e.clientX,y:e.clientY},!0)),Vr(`mouseleave`,i,()=>A(o,{show:!1,x:0,y:0},!0)),z(e,t)};V(b,e=>{I(r)&&e(x)});var S=P(b,2),C=e=>{var t=$c(),n=M(t),r=e=>{z(e,Zc())},a=e=>{z(e,Qc())};V(n,e=>{I(i)===`start`?e(r):e(a,-1)});var s=P(n,2),c=M(s,!0);T(s),T(t),F(()=>{Hi(t,`left:${I(o).x??``}px;top:${I(o).y??``}px`),B(c,I(i)===`end`?`Select end date`:`Select start date`)}),z(e,t)};V(S,e=>{I(o).show&&e(C)}),T(m),Mi(m,()=>I(r)?As(c):void 0),F((e,t)=>{W(h,`title`,e),B(_,t),y=U(v,0,`date-picker-chevron svelte-ax7ma4`,null,y,{open:I(r)})},[()=>Mc.dateRangeSpanLabel(),()=>Mc.dateRangeLabel()]),L(`click`,h,s),z(e,m),D()}Hr([`click`,`mousemove`]);function nl(e){return e+.5|0}var rl=(e,t,n)=>Math.max(Math.min(e,n),t);function il(e){return rl(nl(e*2.55),0,255)}function al(e){return rl(nl(e*255),0,255)}function ol(e){return rl(nl(e/2.55)/100,0,1)}function sl(e){return rl(nl(e*100),0,100)}var cl={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},ll=[...`0123456789ABCDEF`],ul=e=>ll[e&15],dl=e=>ll[(e&240)>>4]+ll[e&15],fl=e=>(e&240)>>4==(e&15),pl=e=>fl(e.r)&&fl(e.g)&&fl(e.b)&&fl(e.a);function ml(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&cl[e[1]]*17,g:255&cl[e[2]]*17,b:255&cl[e[3]]*17,a:t===5?cl[e[4]]*17:255}:(t===7||t===9)&&(n={r:cl[e[1]]<<4|cl[e[2]],g:cl[e[3]]<<4|cl[e[4]],b:cl[e[5]]<<4|cl[e[6]],a:t===9?cl[e[7]]<<4|cl[e[8]]:255})),n}var hl=(e,t)=>e<255?t(e):``;function gl(e){var t=pl(e)?ul:dl;return e?`#`+t(e.r)+t(e.g)+t(e.b)+hl(e.a,t):void 0}var _l=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function vl(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function yl(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function bl(e,t,n){let r=vl(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function xl(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=xl(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function Cl(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(al)}function wl(e,t,n){return Cl(vl,e,t,n)}function Tl(e,t,n){return Cl(bl,e,t,n)}function El(e,t,n){return Cl(yl,e,t,n)}function Dl(e){return(e%360+360)%360}function Ol(e){let t=_l.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?il(+t[5]):al(+t[5]));let i=Dl(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?Tl(i,a,o):t[1]===`hsv`?El(i,a,o):wl(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function kl(e,t){var n=Sl(e);n[0]=Dl(n[0]+t),n=wl(n),e.r=n[0],e.g=n[1],e.b=n[2]}function Al(e){if(!e)return;let t=Sl(e),n=t[0],r=sl(t[1]),i=sl(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${ol(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var jl={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},Ml={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function Nl(){let e={},t=Object.keys(Ml),n=Object.keys(jl),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var Pl;function Fl(e){Pl||(Pl=Nl(),Pl.transparent=[0,0,0,0]);let t=Pl[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var Il=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Ll(e){let t=Il.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?il(e):rl(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?il(r):rl(r,0,255)),i=255&(t[4]?il(i):rl(i,0,255)),a=255&(t[6]?il(a):rl(a,0,255)),{r,g:i,b:a,a:n}}}function Rl(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${ol(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var zl=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,Bl=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Vl(e,t,n){let r=Bl(ol(e.r)),i=Bl(ol(e.g)),a=Bl(ol(e.b));return{r:al(zl(r+n*(Bl(ol(t.r))-r))),g:al(zl(i+n*(Bl(ol(t.g))-i))),b:al(zl(a+n*(Bl(ol(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Hl(e,t,n){if(e){let r=Sl(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=wl(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Ul(e,t){return e&&Object.assign(t||{},e)}function Wl(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=al(e[3]))):(t=Ul(e,{r:0,g:0,b:0,a:1}),t.a=al(t.a)),t}function Gl(e){return e.charAt(0)===`r`?Ll(e):Ol(e)}var Kl=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Wl(t):n===`string`&&(r=ml(t)||Fl(t)||Gl(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Ul(this._rgb);return e&&(e.a=ol(e.a)),e}set rgb(e){this._rgb=Wl(e)}rgbString(){return this._valid?Rl(this._rgb):void 0}hexString(){return this._valid?gl(this._rgb):void 0}hslString(){return this._valid?Al(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Vl(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=al(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=nl(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Hl(this._rgb,2,e),this}darken(e){return Hl(this._rgb,2,-e),this}saturate(e){return Hl(this._rgb,1,e),this}desaturate(e){return Hl(this._rgb,1,-e),this}rotate(e){return kl(this._rgb,e),this}};function ql(){}var Jl=(()=>{let e=0;return()=>e++})();function Yl(e){return e==null}function Xl(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function Zl(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function Ql(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function $l(e,t){return Ql(e)?e:t}function eu(e,t){return e===void 0?t:e}var tu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,nu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function ru(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function iu(e,t,n,r){let i,a,o;if(Xl(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function pu(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function mu(e){let t=pu(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function hu(e,t){return(fu[t]||(fu[t]=mu(t)))(e)}function gu(e){return e.charAt(0).toUpperCase()+e.slice(1)}var _u=e=>e!==void 0,vu=e=>typeof e==`function`,yu=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function bu(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var xu=Math.PI,Su=2*xu,Cu=Su+xu,wu=1/0,Tu=xu/180,Eu=xu/2,Du=xu/4,Ou=xu*2/3,ku=Math.log10,Au=Math.sign;function ju(e,t,n){return Math.abs(e-t)e-t).pop(),t}function Pu(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Fu(e){return!Pu(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Iu(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Lu(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Yu(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var Xu=(e,t,n,r)=>Yu(e,n,r?r=>{let i=e[r][t];return ie[r][t]Yu(e,n,r=>e[r][t]>=n);function Qu(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+gu(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function td(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&($u.forEach(t=>{delete e[t]}),delete e._chartjs)}function nd(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var rd=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function id(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,rd.call(window,()=>{r=!1,e.apply(t,n)}))}}function ad(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var od=e=>e===`start`?`left`:e===`end`?`right`:`center`,sd=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,cd=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function ld(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(Xu(c,u,d).lo,n?r:Xu(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!Yl(e[s.axis]));i-=Math.max(0,e)}i=Ku(i,0,r-1)}if(m){let e=Math.max(Xu(c,o.axis,f,!0).hi+1,n?0:Xu(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!Yl(e[s.axis]));e+=Math.max(0,t)}a=Ku(e,i,r)-i}else a=r-i}return{start:i,count:a}}function ud(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var dd=e=>e===0||e===1,fd=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*Su/n)),pd=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*Su/n)+1,md={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Eu)+1,easeOutSine:e=>Math.sin(e*Eu),easeInOutSine:e=>-.5*(Math.cos(xu*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>dd(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>dd(e)?e:fd(e,.075,.3),easeOutElastic:e=>dd(e)?e:pd(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return dd(e)?e:e<.5?.5*fd(e*2,t,n):.5+.5*pd(e*2-1,t,n)},easeInBack(e){return e*e*(2.70158*e-1.70158)},easeOutBack(e){return--e*e*(2.70158*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-md.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?md.easeInBounce(e*2)*.5:md.easeOutBounce(e*2-1)*.5+.5};function hd(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function gd(e){return hd(e)?e:new Kl(e)}function _d(e){return hd(e)?e:new Kl(e).saturate(.5).darken(.1).hexString()}var vd=[`x`,`y`,`borderWidth`,`radius`,`tension`],yd=[`color`,`borderColor`,`backgroundColor`];function bd(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:yd},numbers:{type:`number`,properties:vd}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function xd(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var Sd=new Map;function Cd(e,t){t||={};let n=e+JSON.stringify(t),r=Sd.get(n);return r||(r=new Intl.NumberFormat(e,t),Sd.set(n,r)),r}function wd(e,t,n){return Cd(t,n).format(e)}var Td={values(e){return Xl(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Ed(e,n)}let o=ku(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),wd(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(ku(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?Td.numeric.call(this,e,t,n):``}};function Ed(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Dd={formatters:Td};function Od(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Dd.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var kd=Object.create(null),Ad=Object.create(null);function jd(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>_d(t.backgroundColor),this.hoverBorderColor=(e,t)=>_d(t.borderColor),this.hoverColor=(e,t)=>_d(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return Md(this,e,t)}get(e){return jd(this,e)}describe(e,t){return Md(Ad,e,t)}override(e,t){return Md(kd,e,t)}route(e,t,n,r){let i=jd(this,e),a=jd(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return Zl(e)?Object.assign({},t,e):eu(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[bd,xd,Od]);function Pd(e){return!e||Yl(e.size)||Yl(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Fd(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Id(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function Vd(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Kd(e,a),c=0;c+e||0;function tf(e,t){let n={},r=Zl(t),i=r?Object.keys(t):t,a=Zl(e)?r?n=>eu(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=ef(a(e));return n}function nf(e){return tf(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function rf(e){return tf(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function af(e){let t=nf(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function of(e,t){e||={},t||=Nd.font;let n=eu(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=eu(e.style,t.style);r&&!(``+r).match(Qd)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:eu(e.family,t.family),lineHeight:$d(eu(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:eu(e.weight,t.weight),string:``};return i.string=Pd(i),i}function sf(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function lf(e,t){return Object.assign(Object.create(e),t)}function uf(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Ef(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>uf([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return hf(n,r,()=>Tf(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Df(e).includes(t)},ownKeys(e){return Df(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function df(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:ff(e,r),setContext:t=>df(e,t,n,r),override:i=>df(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return hf(e,t,()=>gf(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function ff(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:vu(n)?n:()=>n,isIndexable:vu(r)?r:()=>r}}var pf=(e,t)=>e?e+gu(t):t,mf=(e,t)=>Zl(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function hf(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function gf(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return vu(s)&&o.isScriptable(t)&&(s=_f(t,s,e,n)),Xl(s)&&s.length&&(s=vf(t,s,e,o.isIndexable)),mf(t,s)&&(s=df(s,i,a&&a[t],o)),s}function _f(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),mf(e,c)&&(c=Sf(i._scopes,i,e,c)),c}function vf(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(Zl(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=Sf(r,i,e,c);t.push(df(n,a,o&&o[e],s))}}return t}function yf(e,t,n){return vu(e)?e(t,n):e}var bf=(e,t)=>e===!0?t:typeof e==`string`?hu(t,e):void 0;function xf(e,t,n,r,i){for(let a of t){let t=bf(n,a);if(t){e.add(t);let a=yf(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function Sf(e,t,n,r){let i=t._rootScopes,a=yf(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=Cf(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=Cf(s,o,a,c,r),c===null)?!1:uf(Array.from(s),[``],i,a,()=>wf(t,n,r))}function Cf(e,t,n,r,i){for(;n;)n=xf(e,t,n,r,i);return n}function wf(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Xl(i)&&Zl(n)?n:i||{}}function Tf(e,t,n,r){let i;for(let a of t)if(i=Ef(pf(a,e),n),i!==void 0)return mf(e,i)?Sf(n,r,e,i):i}function Ef(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Df(e){let t=e._keys;return t||=e._keys=Of(e._scopes),t}function Of(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function kf(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;ste===`x`?`y`:`x`;function Nf(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=Hu(a,i),c=Hu(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Pf(e,t,n){let r=e.length,i,a,o,s,c,l=jf(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)If(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function Wf(e,t){return Uf(e).getPropertyValue(t)}var Gf=[`top`,`right`,`bottom`,`left`];function Kf(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Gf[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var qf=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Jf(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(qf(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Yf(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Uf(n),a=i.boxSizing===`border-box`,o=Kf(i,`padding`),s=Kf(i,`border`,`width`),{x:c,y:l,box:u}=Jf(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function Xf(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Vf(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Uf(a),s=Kf(o,`border`,`width`),c=Kf(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=Hf(o.maxWidth,a,`clientWidth`),i=Hf(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||wu,maxHeight:i||wu}}var Zf=e=>Math.round(e*10)/10;function Qf(e,t,n,r){let i=Uf(e),a=Kf(i,`margin`),o=Hf(i.maxWidth,e,`clientWidth`)||wu,s=Hf(i.maxHeight,e,`clientHeight`)||wu,c=Xf(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Kf(i,`border`,`width`),t=Kf(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=Zf(Math.min(l,o,c.maxWidth)),u=Zf(Math.min(u,s,c.maxHeight)),l&&!u&&(u=Zf(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=Zf(Math.floor(u*r))),{width:l,height:u}}function $f(e,t,n){let r=t||1,i=Zf(e.height*r),a=Zf(e.width*r);e.height=Zf(e.height),e.width=Zf(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var ep=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Bf()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function tp(e,t){let n=Wf(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function np(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function rp(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function ip(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=np(e,i,n),s=np(i,a,n),c=np(a,t,n);return np(np(o,s,n),np(s,c,n),n)}var ap=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},op=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function sp(e,t,n){return e?ap(t,n):op()}function cp(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function lp(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function up(e){return e===`angle`?{between:Gu,compare:Uu,normalize:Wu}:{between:Ju,compare:(e,t)=>e-t,normalize:e=>e}}function dp({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function fp(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=up(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(dp({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(dp({start:g,end:d,loop:f,count:o,style:p})),m}function mp(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function gp(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function _p(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=hp(n,i,a,r);return r===!0?vp(e,[{start:o,end:s,loop:a}],n,t):vp(e,gp(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,rd.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Ep=`transparent`,Dp={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=gd(e||Ep),i=r.valid&&gd(t||Ep);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},Op=class{constructor(e,t,n,r){let i=t[n];r=sf([e.to,r,i,e.from]);let a=sf([e.from,i,r]);this._active=!0,this._fn=e.fn||Dp[e.type||typeof a],this._easing=md[e.easing]||md.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=sf([e.to,t,r,e.from]),this._from=sf([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!Zl(i))return;let a={};for(let e of t)a[e]=i[e];(Xl(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=jp(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&Ap(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new Op(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return Tp.add(this._chart,n),!0}};function Ap(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function Up(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=zp(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function Gp(e,t){return lf(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Kp(e,t,n){return lf(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function qp(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var Jp=e=>e===`reset`||e===`none`,Yp=(e,t)=>t?e:Object.assign({},e),Xp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Fp(n,!0),values:null},Zp=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Rp(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&qp(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=eu(n.xAxisID,Wp(e,`x`)),a=t.yAxisID=eu(n.yAxisID,Wp(e,`y`)),o=t.rAxisID=eu(n.rAxisID,Wp(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&td(this._data,this),e._stacked&&qp(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(Zl(t)){let e=this._cachedMeta;this._data=Lp(t,e)}else if(n!==t){if(n){td(n,this);let e=this._cachedMeta;qp(e),e._parsed=[]}t&&Object.isExtensible(t)&&ed(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Rp(t.vScale,t),t.stack!==n.stack&&(r=!0,qp(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Up(this,t._parsed),t._stacked=Rp(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length||n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=Xl(r[e])?this.parseArrayData(n,r,e,t):Zl(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Yp(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new kp(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||Jp(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){Jp(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!Jp(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function $p(e){let t=e.iScale,n=Qp(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(_u(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function rm(e,t,n,r){return Xl(e)?nm(e,t,n,r):t[n.axis]=n.parse(e,r),t}function im(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):Au(e)}function sm(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(Yl(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[eu(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;dGu(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>Gu(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(Eu,u,f),_=m(xu,l,d),v=m(xu+Eu,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var gm=class extends Zp{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(Zl(n[e])){let{key:e=`value`}=this._parsing;i=t=>+hu(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*Su:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=wd(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=Yl(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},vm=class extends Zp{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=wd(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return kf.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(rt.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*xu,d=u,f,p=360/this.countVisibleElements();for(f=0;f{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?Ru(this.resolveDataElementOptions(e,t).angle||n):0}},ym=Object.freeze({__proto__:null,BarController:pm,BubbleController:mm,DoughnutController:gm,LineController:_m,PieController:class extends gm{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:vm,RadarController:class extends Zp{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return kf.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function bm(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var xm={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return bm()}parse(){return bm()}format(){return bm()}add(){return bm()}diff(){return bm()}startOf(){return bm()}endOf(){return bm()}}};function Sm(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?Zu:Xu;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!Yl(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!Yl(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function Cm(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var Am={evaluateInteractionItems:Cm,modes:{index(e,t,n,r){let i=Yf(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Tm(e,i,a,r,o):Om(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Yf(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Tm(e,i,a,r,o):Om(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Nm(e,t){return e.filter(e=>jm.indexOf(e.pos)===-1&&e.box.axis===t)}function Pm(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Fm(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=Pm(Mm(t,`left`),!0),i=Pm(Mm(t,`right`)),a=Pm(Mm(t,`top`),!0),o=Pm(Mm(t,`bottom`)),s=Nm(t,`x`),c=Nm(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Mm(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function zm(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Bm(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Vm(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!Zl(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&Bm(o,a.getPadding());let s=Math.max(0,t.outerWidth-zm(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-zm(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function Hm(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Um(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Wm(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);Bm(f,af(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Lm(c.concat(l),d);Wm(s.fullSize,p,d,m),Wm(c,p,d,m),Wm(l,p,d,m)&&Wm(c,p,d,m),Hm(p),Km(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,Km(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},iu(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},Jm=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},Ym=class extends Jm{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},Xm=`$chartjs`,Zm={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},Qm=e=>e===null||e===``;function $m(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[Xm]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,Qm(i)){let t=tp(e,`width`);t!==void 0&&(e.width=t)}if(Qm(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=tp(e,`height`);t!==void 0&&(e.height=t)}return e}var eh=ep?{passive:!0}:!1;function th(e,t,n){e&&e.addEventListener(t,n,eh)}function nh(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,eh)}function rh(e,t){let n=Zm[e.type]||e.type,{x:r,y:i}=Yf(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function ih(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function ah(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ih(n.addedNodes,r),t&&=!ih(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function oh(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ih(n.removedNodes,r),t&&=!ih(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var sh=new Map,ch=0;function lh(){let e=window.devicePixelRatio;e!==ch&&(ch=e,sh.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function uh(e,t){sh.size||window.addEventListener(`resize`,lh),sh.set(e,t)}function dh(e){sh.delete(e),sh.size||window.removeEventListener(`resize`,lh)}function fh(e,t,n){let r=e.canvas,i=r&&Vf(r);if(!i)return;let a=id((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),uh(e,a),o}function ph(e,t,n){n&&n.disconnect(),t===`resize`&&dh(e)}function mh(e,t,n){let r=e.canvas,i=id(t=>{e.ctx!==null&&n(rh(t,e))},e);return th(r,t,i),i}var hh=class extends Jm{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?($m(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[Xm])return!1;let n=t[Xm].initial;[`height`,`width`].forEach(e=>{let r=n[e];Yl(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[Xm],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:ah,detach:oh,resize:fh}[t]||mh)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:ph,detach:ph,resize:ph}[t]||nh)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return Qf(e,t,n,r)}isAttached(e){let t=e&&Vf(e);return!!(t&&t.isConnected)}};function gh(e){return!Bf()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?Ym:hh}var _h=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Fu(this.x)&&Fu(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function vh(e,t){let n=e.options.ticks,r=yh(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?xh(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return Sh(t,l,a,o/i),l;let u=bh(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Ch(t,l,u,Yl(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function xh(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Eh=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,Dh=(e,t)=>Math.min(t||e,e);function Oh(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function Ah(e,t){iu(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:$l(t,$l(n,t)),max:$l(n,$l(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){ru(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=cf(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=Ku(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-jh(e.grid)-t.padding-Mh(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=zu(Math.min(Math.asin(Ku((l.highest.height+6)/o,-1,1)),Math.asin(Ku(s/c,-1,1))-Math.asin(Ku(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){ru(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){ru(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=Mh(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=jh(i)+a):(e.height=this.maxHeight,e.width=jh(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Ru(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){ru(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return qu(this._alignToPixels?Ld(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=jh(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Ld(n,e,p)},g,_,v,y,b,x,S,C,w,ee,te,ne;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,ee=h(e.top)+m,ne=e.bottom;else if(a===`bottom`)g=h(this.top),ee=e.top,ne=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,te=e.right;else if(a===`right`)g=h(this.left),w=e.left,te=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(Zl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}ee=e.top,ne=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(Zl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,te=e.right}let re=eu(r.ticks.maxTicksLimit,l),ie=Math.max(1,Math.ceil(l/re));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:ne,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:re,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Ru(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Nd.route(a,i,c,s)})}function Vh(e){return`id`in e&&`defaults`in e}var Hh=new class{constructor(){this.controllers=new Rh(Zp,`datasets`,!0),this.elements=new Rh(_h,`elements`),this.plugins=new Rh(Object,`plugins`),this.scales=new Rh(Lh,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):iu(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=gu(e);ru(n[`before`+r],[],n),t[e](n),ru(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Wh(e){let t={},n=[],r=Object.keys(Hh.plugins.items);for(let e=0;e1&&Zh(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function eg(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function tg(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return eg(e,`x`,n[0])||eg(e,`y`,n[0])}return{}}function ng(e,t){let n=kd[e.type]||{scales:{}},r=t.scales||{},i=Jh(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!Zl(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=$h(t,o,tg(t,e),Nd.scales[o.type]),c=Xh(s,i),l=n.scales||{};a[t]=uu(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||Jh(i,t),s=(kd[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=Yh(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),uu(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];uu(t,[Nd.scales[t.type],Nd.scale])}),a}function rg(e){let t=e.options||={};t.plugins=eu(t.plugins,{}),t.scales=ng(e,t)}function ig(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function ag(e){return e||={},e.data=ig(e.data),rg(e),e}var og=new Map,sg=new Set;function cg(e,t){let n=og.get(e);return n||(n=t(),og.set(e,n),sg.add(n)),n}var lg=(e,t,n)=>{let r=hu(t,n);r!==void 0&&e.add(r)},ug=class{constructor(e){this._config=ag(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=ig(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),rg(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return cg(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return cg(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return cg(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return cg(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>lg(s,e,t))),t.forEach(e=>lg(s,r,e)),t.forEach(e=>lg(s,kd[i]||{},e)),t.forEach(e=>lg(s,Nd,e)),t.forEach(e=>lg(s,Ad,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),sg.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,kd[t]||{},Nd.datasets[t]||{},{type:t},Nd,Ad]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=dg(this._resolverCache,e,r),s=a;if(pg(a,t)){i.$shared=!1,n=vu(n)?n():n;let t=this.createResolver(e,n,o);s=df(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=dg(this._resolverCache,e,n);return Zl(t)?df(i,t,void 0,r):i}};function dg(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:uf(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var fg=e=>Zl(e)&&Object.getOwnPropertyNames(e).some(t=>vu(e[t]));function pg(e,t){let{isScriptable:n,isIndexable:r}=ff(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(vu(o)||fg(o))||a&&Xl(o))return!0}return!1}var mg=`4.5.1`,hg=[`top`,`bottom`,`left`,`right`,`chartArea`];function gg(e,t){return e===`top`||e===`bottom`||hg.indexOf(e)===-1&&t===`x`}function _g(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function vg(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),ru(n&&n.onComplete,[e],t)}function yg(e){let t=e.chart,n=t.options.animation;ru(n&&n.onProgress,[e],t)}function bg(e){return Bf()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var xg={},Sg=e=>{let t=bg(e);return Object.values(xg).filter(e=>e.canvas===t).pop()};function Cg(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function wg(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var Tg=class{static defaults=Nd;static instances=xg;static overrides=kd;static registry=Hh;static version=mg;static getChart=Sg;static register(...e){Hh.add(...e),Eg()}static unregister(...e){Hh.remove(...e),Eg()}constructor(e,t){let n=this.config=new ug(t),r=bg(e),i=Sg(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(gh(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=Jl(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Uh,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=ad(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],xg[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}Tp.listen(this,`complete`,vg),Tp.listen(this,`progress`,yg),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return Yl(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Hh}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():$f(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Rd(this.canvas,this.ctx),this}stop(){return Tp.stop(this),this}resize(e,t){Tp.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,$f(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),ru(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){iu(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=$h(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),iu(i,t=>{let i=t.options,a=i.id,o=$h(a,i),s=eu(i.type,t.dtype);(i.position===void 0||gg(i.position,o)!==gg(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(Hh.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),iu(r,(e,t)=>{e||delete n[t]}),iu(n,e=>{qm.configure(this,e,e.options),qm.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(_g(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){iu(this.scales,e=>{qm.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!yu(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)Cg(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;qm.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],iu(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=wp(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&Hd(t,r),e.controller.draw(),r&&Ud(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return Vd(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=Am.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=lf(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);_u(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),Tp.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};iu(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){iu(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},iu(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});au(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=bu(e),c=wg(e,this._lastEvent,n,s);n&&(this._lastEvent=null,ru(i.onHover,[e,o,this],this),s&&ru(i.onClick,[e,o,this],this));let l=!au(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Eg(){return iu(Tg.instances,e=>e._plugins.invalidate())}function Dg(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,Wu(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,Wu(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*Wu(r-n));if(u===`round`)e.arc(i,a,t,n-xu/2,r+xu/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+xu/2)+i,c=-o*Math.sin(n+xu/2)+a,l=o*Math.cos(r+xu/2)+i,u=o*Math.sin(r+xu/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Og(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+Eu,r-Eu),e.closePath(),e.clip()}function kg(e){return tf(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function Ag(e,t,n,r){let i=kg(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return Ku(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:Ku(i.innerStart,0,o),innerEnd:Ku(i.innerEnd,0,o)}}function jg(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Mg(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/xu)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=Ag(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,ee=_-y/C,te=f+b,ne=f+x,re=g+b/te,ie=_-x/ne;if(e.beginPath(),a){let t=(w+ee)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,ee),y>0){let t=jg(C,ee,o,s);e.arc(t.x,t.y,y,ee,_+Eu)}let n=jg(ne,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=jg(ne,ie,o,s);e.arc(t.x,t.y,x,_+Eu,ie+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=jg(te,re,o,s);e.arc(t.x,t.y,b,re+Math.PI,g-Eu)}let i=jg(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=jg(S,w,o,s);e.arc(t.x,t.y,v,g-Eu,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(ee)*d+o,i=Math.sin(ee)*d+s;e.lineTo(r,i)}e.closePath()}function Ng(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){Mg(e,t,n,r,c,i);for(let t=0;t=xu&&p===0&&u!==`miter`&&Dg(e,t,h),a||(Mg(e,t,n,r,h,i),e.stroke())}var Fg=class extends _h{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=Vu(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=eu(l,o-a),f=Gu(r,a,o)&&a!==o,p=d>=Su||f,m=Ju(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>Su?Math.floor(n/Su):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(xu,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Ng(e,this,s,i,a),Pg(e,this,s,i,a),e.restore()}};function Ig(e,t,n=t){e.lineCap=eu(n.borderCapStyle,t.borderCapStyle),e.setLineDash(eu(n.borderDash,t.borderDash)),e.lineDashOffset=eu(n.borderDashOffset,t.borderDashOffset),e.lineJoin=eu(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=eu(n.borderWidth,t.borderWidth),e.strokeStyle=eu(n.borderColor,t.borderColor)}function Lg(e,t,n){e.lineTo(n.x,n.y)}function Rg(e){return e.stepped?Wd:e.tension||e.cubicInterpolationMode===`monotone`?Gd:Lg}function zg(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function Hg(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?Vg:Bg}function Ug(e){return e.stepped?rp:e.tension||e.cubicInterpolationMode===`monotone`?ip:np}function Wg(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Ig(e,t.options),e.stroke(i)}function Gg(e,t,n,r){let{segments:i,options:a}=t,o=Hg(t);for(let s of i)Ig(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var Kg=typeof Path2D==`function`;function qg(e,t,n,r){Kg&&!t.options.segment?Wg(e,t,n,r):Gg(e,t,n,r)}var Jg=class extends _h{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;zf(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=_p(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=mp(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Ug(n),c,l;for(c=0,l=a.length;ce.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function l_(e){return s_[e%s_.length]}function u_(e){return c_[e%c_.length]}function d_(e,t){return e.borderColor=l_(t),e.backgroundColor=u_(t),++t}function f_(e,t){return e.backgroundColor=e.data.map(()=>l_(t++)),t}function p_(e,t){return e.backgroundColor=e.data.map(()=>u_(t++)),t}function m_(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof gm?t=f_(n,t):i instanceof vm?t=p_(n,t):i&&(t=d_(n,t))}}function h_(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function g_(e){return e&&(e.borderColor||e.backgroundColor)}function __(){return Nd.borderColor!==`rgba(0,0,0,0.1)`||Nd.backgroundColor!==`rgba(0,0,0,0.1)`}var v_={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=h_(r)||g_(i)||a&&h_(a)||__();if(!n.forceOverride&&o)return;let s=m_(e);r.forEach(s)}};function y_(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;dp&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function b_(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;oh&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!Yl(d)&&!Yl(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function x_(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function S_(e){e.data.datasets.forEach(e=>{x_(e)})}function C_(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=Ku(Xu(t,a.axis,o).lo,0,n-1)),i=l?Ku(Xu(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var w_={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){S_(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(sf([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=C_(s,c);if(d<=(n.threshold||4*r)){x_(t);return}Yl(a)&&(t._data=c,delete t.data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=y_(c,u,d,r,n);break;case`min-max`:f=b_(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){S_(e)}};function T_(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=O_(r,s,i);let c=E_(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=mp(t,c);for(let t of l){let r=E_(n,a[t.start],a[t.end],t.loop),s=pp(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:k_(c,r,`start`,Math.max)},end:{[n]:k_(c,r,`end`,Math.min)}})}}return o}function E_(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=Wu(i),a=Wu(a)),{property:e,start:i,end:a}}function D_(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=O_(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function O_(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function k_(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function A_(e,t){let n=[],r=!1;return Xl(e)?(r=!0,n=e):n=D_(e,t),n.length?new Jg({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function j_(e){return e&&e.fill!==!1}function M_(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!Ql(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function N_(e,t,n){let r=L_(e);if(Zl(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return Ql(i)&&Math.floor(i)===i?P_(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function P_(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function F_(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:Zl(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function I_(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:Zl(e)?e.value:t.getBaseValue(),r}function L_(e){let t=e.options,n=t.fill,r=eu(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function R_(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=z_(t,n);s.push(A_({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&J_(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;j_(n)&&J_(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!j_(r)||n.drawTime!==`beforeDatasetDraw`||J_(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},nv=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},rv=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,iv=class extends _h{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=ru(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=of(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=nv(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=av(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=sp(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=sd(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=sd(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=sd(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=sd(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;Hd(e,this),this._draw(),Ud(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Nd.color,s=sp(e.rtl,this.left,this.width),c=of(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=nv(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=eu(n.lineWidth,1);if(r.fillStyle=eu(n.fillStyle,o),r.lineCap=eu(n.lineCap,`butt`),r.lineDashOffset=eu(n.lineDashOffset,0),r.lineJoin=eu(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=eu(n.strokeStyle,o),r.setLineDash(eu(n.lineDash,[])),a.usePointStyle){let o={radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},c=s.xPlus(e,p/2),l=t+d;Bd(r,o,c,l,a.pointStyleWidth&&p)}else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=rf(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?Xd(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){Yd(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:sd(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:sd(i,this.top+y+l,this.bottom-t[0].height),line:0},cp(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=sd(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=sd(i,this.top+y+l,this.bottom-t[f.line].height));let w=s.x(S);if(g(w,C,o),S=cd(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=cv(o,e)+l}else f.y+=b}),lp(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=of(t.font),r=af(t.padding);if(!t.display)return;let i=sp(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=sd(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+sd(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=sd(o,u,u+d);a.textAlign=i.textAlign(od(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,Yd(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=of(e.font),n=af(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(Ju(e,this.left,this.right)&&Ju(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function sv(e,t,n){let r=e;return typeof t.text!=`string`&&(r=cv(t,n)),r}function cv(e,t){return t*(e.text?e.text.length:0)}function lv(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var uv={id:`legend`,_element:iv,start(e,t,n){let r=e.legend=new iv({ctx:e.ctx,options:n,chart:e});qm.configure(e,r,n),qm.addBox(e,r)},stop(e){qm.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;qm.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=af(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},dv=class extends _h{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=Xl(n.text)?n.text.length:1;this._padding=af(n.padding);let i=r*of(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=sd(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=sd(o,r,t),s=xu*-.5):(l=i-e,u=sd(o,t,r),s=xu*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=of(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);Yd(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:od(t.align),textBaseline:`middle`,translation:[i,a]})}};function fv(e,t){let n=new dv({ctx:e.ctx,options:t,chart:e});qm.configure(e,n,t),qm.addBox(e,n),e.titleBlock=n}var pv={id:`title`,_element:dv,start(e,t,n){fv(e,n)},stop(e){let t=e.titleBlock;qm.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;qm.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},mv=new WeakMap,hv={id:`subtitle`,start(e,t,n){let r=new dv({ctx:e.ctx,options:n,chart:e});qm.configure(e,r,n),qm.addBox(e,r),mv.set(e,r)},stop(e){qm.removeBox(e,mv.get(e)),mv.delete(e)},beforeUpdate(e,t,n){let r=mv.get(e);qm.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`normal`},fullSize:!0,padding:0,position:`top`,text:``,weight:1500},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},gv={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` +`):e}function yv(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function bv(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=of(t.bodyFont),l=of(t.titleFont),u=of(t.footerFont),d=a.length,f=i.length,p=r.length,m=af(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,iu(e.title,y),n.font=c.string,iu(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,iu(r,e=>{iu(e.before,y),iu(e.lines,y),iu(e.after,y)}),v=0,n.font=u.string,iu(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function xv(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function Sv(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function Cv(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),Sv(l,e,t,n)&&(l=`center`),l}function wv(e,t,n){let r=n.yAlign||t.yAlign||xv(e,n);return{xAlign:n.xAlign||t.xAlign||Cv(e,t,n,r),yAlign:r}}function Tv(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Ev(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function Dv(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=rf(o),m=Tv(t,s),h=Ev(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:Ku(m,0,r.width-t.width),y:Ku(h,0,r.height-t.height)}}function Ov(e,t,n){let r=af(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function kv(e){return _v([],vv(e))}function Av(e,t,n){return lf(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function jv(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var Mv={beforeTitle:ql,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=jv(n,e);_v(t.before,vv(Nv(i,`beforeLabel`,this,e))),_v(t.lines,Nv(i,`label`,this,e)),_v(t.after,vv(Nv(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return kv(Nv(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Nv(n,`beforeFooter`,this,e),i=Nv(n,`footer`,this,e),a=Nv(n,`afterFooter`,this,e),o=[];return o=_v(o,vv(r)),o=_v(o,vv(i)),o=_v(o,vv(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),iu(o,t=>{let n=jv(e.callbacks,t);r.push(Nv(n,`labelColor`,this,t)),i.push(Nv(n,`labelPointStyle`,this,t)),a.push(Nv(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=gv[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=bv(this,n),o=Object.assign({},e,t),s=wv(this.chart,n,o),c=Dv(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=rf(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=sp(n.rtl,this.x,this.width);for(e.x=Ov(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=of(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,Xd(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),Xd(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=of(n.bodyFont),d=u.lineHeight,f=0,p=sp(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=Ov(this,h,n),t.fillStyle=n.bodyColor,iu(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=gv[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=bv(this,e),o=Object.assign({},n,this._size),s=wv(t,e,o),c=Dv(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=af(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),cp(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),lp(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!au(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!au(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=gv[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Fv=Object.freeze({__proto__:null,Colors:v_,Decimation:w_,Filler:tv,Legend:uv,SubTitle:hv,Title:pv,Tooltip:{id:`tooltip`,_element:Pv,positioners:gv,afterInit(e,t,n){n&&(e.tooltip=new Pv({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:Mv},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Iv=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Lv(e,t,n,r){let i=e.indexOf(t);return i===-1?Iv(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Rv=(e,t)=>e===null?null:Ku(Math.round(e),0,t);function zv(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function Vv(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!Yl(a),_=!Yl(o),v=!Yl(c),y=(h-m)/(u+1),b=Mu((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=Mu(w*b/p/f)*f),Yl(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Iu((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=ju(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let ee=Math.max(Bu(b),Bu(S));x=10**(Yl(s)?ee:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let te=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&ju(n[n.length-1].value,o,Hv(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Hv(e,t,{horizontal:n,minRotation:r}){let i=Ru(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Uv=class extends Lh{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return Yl(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=Au(r),t=Au(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=Vv({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Lu(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return wd(e,this.chart.options.locale,this.options.ticks.format)}},Wv=class extends Uv{static id=`linear`;static defaults={ticks:{callback:Dd.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Ql(e)?e:0,this.max=Ql(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Ru(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Gv=e=>Math.floor(ku(e)),Kv=(e,t)=>10**(Gv(e)+t);function qv(e){return e/10**Gv(e)==1}function Jv(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Yv(e,t){let n=Gv(t-e);for(;Jv(e,t,n)>10;)n++;for(;Jv(e,t,n)<10;)n--;return Math.min(n,Gv(e))}function Xv(e,{min:t,max:n}){t=$l(e.min,t);let r=[],i=Gv(t),a=Yv(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=$l(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=$l(e.max,f);return r.push({value:p,major:qv(p),significand:d}),r}var Zv=class extends Lh{static id=`logarithmic`;static defaults={ticks:{callback:Dd.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Uv.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return Ql(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Ql(e)?Math.max(0,e):null,this.max=Ql(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Ql(this._userMin)&&(this.min=e===Kv(this.min,0)?Kv(this.min,-1):Kv(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Kv(n,-1)),a(Kv(r,1)))),n<=0&&i(Kv(r,-1)),r<=0&&a(Kv(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Xv({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Lu(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:wd(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=ku(e),this._valueRange=ku(this.max)-ku(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(ku(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function Qv(e){let t=e.ticks;if(t.display&&e.display){let e=af(t.backdropPadding);return eu(t.font&&t.font.size,Nd.font.size)+e.height}return 0}function $v(e,t,n){return n=Xl(n)?n:[n],{w:Id(e,t.string,n),h:n.length*t.lineHeight}}function ey(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function ty(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?xu/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function ry(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(zu(Wu(c.angle+Eu))),u=cy(c.y,s.h,l),d=oy(l),f=sy(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function iy(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(Vd({x:n,y:r},t)||Vd({x:n,y:a},t)||Vd({x:i,y:r},t)||Vd({x:i,y:a},t))}function ay(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Qv(a)/2,additionalAngle:o?xu/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function ly(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!Yl(s)){let n=rf(t.borderRadius),c=af(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),Xd(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function uy(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));ly(n,a,t);let o=of(a.font),{x:s,y:c,textAlign:l}=t;Yd(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function dy(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,Su);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=ru(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?ty(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=Su/(this._pointLabels.length||1),n=this.options.startAngle||0;return Wu(e*t+Ru(n))}getDistanceFromCenterForValue(e){if(Yl(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(Yl(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);fy(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=of(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=af(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}Yd(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},hy={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},gy=Object.keys(hy);function _y(e,t){return e-t}function vy(e,t){if(Yl(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),Ql(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Fu(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function yy(e,t,n,r){let i=gy.length;for(let a=gy.indexOf(e);a=gy.indexOf(n);a--){let n=gy[a];if(hy[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return gy[n?gy.indexOf(n):0]}function xy(e){for(let t=gy.indexOf(e)+1,n=gy.length;t=t?n[r]:n[i];e[a]=!0}}function Cy(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function wy(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=Ku(t,0,a),n=Ku(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||yy(i.minUnit,t,n,this._getLabelCapacity(t)),o=eu(r.ticks.stepSize,1),s=a===`week`&&i.isoWeekday,c=Fu(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return ru(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=Xu(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=Xu(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var Dy=class extends Ty{static id=`timeseries`;static defaults=Ty.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=Ey(t,this.min),this._tableRange=Ey(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(Ey(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return Ey(this._table,n*this._tableRange+this._minPos,!0)}},Oy=[ym,o_,Fv,Object.freeze({__proto__:null,CategoryScale:Bv,LinearScale:Wv,LogarithmicScale:Zv,RadialLinearScale:my,TimeScale:Ty,TimeSeriesScale:Dy})];Tg.register(...Oy);var ky=Tg,Ay=R(``);function jy(e,t){E(t,!0);let n=ya(t,`class`,3,``),r=ya(t,`ariaLabel`,3,``);function i(e){if(ka.tick,typeof t.build!=`function`)return;let n=t.build();if(!n)return;let r=new ky(e.getContext(`2d`),n);return()=>r.destroy()}var a=Ay();Mi(a,()=>i),F(()=>{U(a,1,Fi(n())),W(a,`aria-label`,r())}),z(e,a),D()}var My=R(``),Ny=R(`
                `);function Py(e,t){E(t,!0);let n=ya(t,`options`,19,()=>[]),r=ya(t,`ariaLabel`,3,``),i=ya(t,`class`,3,``);var a=Ny();H(a,21,n,e=>e.value,(e,n)=>{var r=My();let i;var a=M(r,!0);T(r),F(()=>{i=U(r,1,`segmented-btn svelte-92fh5i`,null,i,{active:t.value===I(n).value}),W(r,`aria-pressed`,t.value===I(n).value),B(a,I(n).label)}),L(`click`,r,()=>t.onchange?.(I(n).value)),z(e,r)}),T(a),F(()=>{U(a,1,Fi([`segmented-control`,i()]),`svelte-92fh5i`),W(a,`aria-label`,r())}),z(e,a),D()}Hr([`click`]);function Fy(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Iy(){return{grid:Fy(`--chart-grid`),text:Fy(`--chart-text`),dayMarker:Fy(`--chart-day-marker`),tooltipBg:Fy(`--chart-tooltip-bg`),tooltipBorder:Fy(`--chart-tooltip-border`),tooltipText:Fy(`--chart-tooltip-text`)}}function Ly(){return{size:11,family:`'SF Mono', Menlo, Consolas, monospace`}}function Ry(e,t){return{backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,borderWidth:1,titleColor:e.tooltipText,bodyColor:e.tooltipText,callbacks:t}}function zy(e){if(typeof document>`u`||!document.body)return e;let t=document.createElement(`span`);t.style.display=`none`,t.style.color=e,document.body.appendChild(t);let n=getComputedStyle(t).color;return document.body.removeChild(t),n||e}var By=[`#c2845a`,`#7a9e7e`,`#d4a574`,`#b8a98e`,`#8b9e6b`,`#7d8a97`,`#c47a5a`,`#6b8e6b`,`#a09486`,`#9b7ea4`,`#c49a6c`];function Vy(){return[...By]}function Hy(e){let t=5381,n=String(e||``);for(let e=0;euc(e)}}var Jy={seconds:{apiName:`second`,windowLabel:`Last 60 seconds`,refreshMs:2e3},minutes:{apiName:`minute`,windowLabel:`Last 60 minutes`,refreshMs:5e3},hours:{apiName:`hour`,windowLabel:`Last 24 hours`,refreshMs:2e4},days:{apiName:`day`,windowLabel:`Last 30 days`,refreshMs:6e4}},Yy=[{value:`seconds`,label:`Seconds`},{value:`minutes`,label:`Minutes`},{value:`hours`,label:`Hours`},{value:`days`,label:`Days`}];function Xy(){return{input:0,output:0,prompt:0,local:0}}function Zy(e){return String(e).padStart(2,`0`)}function Qy(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function $y(e,t){if(!Number.isFinite(t))return``;let n=new Date(t);switch(e){case`seconds`:return Zy(n.getHours())+`:`+Zy(n.getMinutes())+`:`+Zy(n.getSeconds());case`minutes`:return Zy(n.getHours())+`:`+Zy(n.getMinutes());case`hours`:return Zy(n.getHours())+`:00`;default:return Zy(n.getMonth()+1)+`-`+Zy(n.getDate())}}function eb(e,t){let n=[],r=[],i={input:[],output:[],prompt:[],local:[]},a=Xy();for(let o of e||[]){let e=Date.parse(o&&o.start),s=Qy(o&&o.input_tokens),c=Qy(o&&o.output_tokens),l=Qy(o&&o.prompt_cached_tokens),u=Qy(o&&o.locally_cached_tokens);n.push($y(t,e)),r.push(Number.isFinite(e)?e:null),i.input.push(s),i.output.push(c),i.prompt.push(l),i.local.push(u),a.input+=s,a.output+=c,a.prompt+=l,a.local+=u}return{labels:n,stamps:r,cols:i,totals:a}}function tb(e){let t=e||Xy();return t.input+t.output+t.prompt+t.local>0}function nb(e,t){return uc(Math.max(0,Math.round(e&&e[t]||0)))}function rb(e){return(Jy[e]||Jy.minutes).windowLabel}function ib(e,t){return`Live token throughput, `+rb(t).toLowerCase()+`. Input `+nb(e,`input`)+`, output `+nb(e,`output`)+`, prompt cached `+nb(e,`prompt`)+`, locally cached `+nb(e,`local`)+` tokens.`}function ab(e,t,n,r){let i=e=>uc(Math.max(0,Math.round(e))),a=n.stamps,o=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderWidth:0,borderRadius:0,categoryPercentage:1,barPercentage:1,stack:`tokens`});return{type:`bar`,plugins:[{id:`liveTokensDayMarks`,afterDatasetsDraw:t=>{if(r===`days`)return;let n=t.getDatasetMeta(0),i=t.chartArea;if(!n||!n.data||!i)return;let o=t.ctx;o.save(),o.font=`10px 'SF Mono', Menlo, Consolas, monospace`;let s=null;for(let t=0;t{if(!e.length)return``;let t=a[e[0].dataIndex];if(!t)return e[0].label;let n=new Date(t);return r===`days`?n.toLocaleDateString():n.toLocaleString()},label:e=>e.dataset.label+`: `+i(e.parsed.y),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+i(t)}})}}}}var ob=900,sb=new class{#e=k(`minutes`);get granularity(){return I(this.#e)}set granularity(e){A(this.#e,e,!0)}#t=k(j([]));get buckets(){return I(this.#t)}set buckets(e){A(this.#t,e,!0)}#n=k(!1);get active(){return I(this.#n)}set active(e){A(this.#n,e,!0)}#r=null;#i=null;#a=null;#o=0;#s=null;#c=!1;start(){this.stop(),this.active=!0,this.fetch(),this.#l(),this.#u()}stop(){this.active=!1,this.#r&&=(clearInterval(this.#r),null),this.#i&&=(clearTimeout(this.#i),null),this.#a&&=(clearTimeout(this.#a),null),this.#o=0,this.#s&&=(this.#s.abort(),null),this.buckets=[]}setGranularity(e){!Jy[e]||e===this.granularity||(this.granularity=e,this.buckets=[],this.#l(),this.fetch())}#l(){this.#r&&=(clearInterval(this.#r),null);let e=Jy[this.granularity]||Jy.minutes;this.#r=setInterval(()=>{this.active&&this.fetch()},e.refreshMs)}noteUsageEvent(e){!this.active||e!==`usage.flushed`||(this.#i||=setTimeout(()=>{this.#i=null,this.fetch()},ob))}async fetch(){if(!this.active||this.#c)return;this.#c=!0;let e=this.granularity;try{let t=await _s(`/admin/usage/throughput?granularity=`+(Jy[e]||Jy.minutes).apiName,{label:`token throughput`});if(t.stale||!t.ok||this.granularity!==e)return;this.buckets=t.data&&Array.isArray(t.data.buckets)?t.data.buckets:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch token throughput:`,e)}finally{this.#c=!1,this.active&&this.granularity!==e&&this.fetch()}}async#u(){await Ss.ensureLoaded(),this.active&&Ss.liveLogsVisible()&&(typeof ReadableStream>`u`||(this.#s&&this.#s.abort(),this.#s=new AbortController,this.#d(this.#s)))}async#d(e){try{let t=await hs(`/admin/live/logs?types=usage`,{signal:e.signal});if(!t.ok||!t.body||typeof t.body.getReader!=`function`){this.#p();return}this.#o=0,await Wy(t.body.getReader(),e=>this.#f(e)),this.#p()}catch(e){if(ys(e))return;console.error(`Live usage stream failed:`,e),this.#p()}}#f(e){if(!e||typeof e!=`object`)return;let t=String(e.type||``).trim();t.indexOf(`usage.`)===0&&this.noteUsageEvent(t)}#p(){if(!this.active||this.#a)return;let{attempt:e,delay:t}=Ky(this.#o);this.#o=e,this.#a=setTimeout(()=>{this.#a=null,this.#u()},t)}},cb=R(`
                `),lb=R(`
                Waiting for live requests…
                `),ub=R(`

                Live Token Throughput

                `);function db(e,t){E(t,!0);let n=O(()=>eb(sb.buckets,sb.granularity)),r=O(()=>I(n).totals);function i(){return{input:zy(`var(--token-input)`),output:zy(`var(--token-output)`),prompt:zy(`var(--token-prompt)`),local:zy(`var(--token-local)`)}}let a=[{metric:`input`,label:`Input Tokens`,colorVar:`--token-input`},{metric:`output`,label:`Output Tokens`,colorVar:`--token-output`},{metric:`prompt`,label:`Prompt (Input) Cached`,colorVar:`--token-prompt`},{metric:`local`,label:`Locally Cached`,colorVar:`--token-local`}];var o=ub(),s=M(o),c=M(s),l=P(M(c),2),u=M(l);let d;var f=P(u,2),p=M(f,!0);T(f),T(l),T(c),Py(P(c,2),{ariaLabel:`Live token throughput granularity`,get options(){return Yy},get value(){return sb.granularity},onchange:e=>sb.setGranularity(e)}),T(s);var m=P(s,2);H(m,21,()=>a,e=>e.metric,(e,t)=>{var n=cb(),i=M(n),a=P(i,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{Hi(i,`background: var(${I(t).colorVar??``})`),B(o,I(t).label),B(c,e)},[()=>nb(I(r),I(t).metric)]),z(e,n)}),T(m);var h=P(m,2),g=M(h);{let e=O(()=>ib(I(r),sb.granularity));jy(g,{get ariaLabel(){return I(e)},build:()=>ab(Iy(),i(),I(n),sb.granularity)})}var _=P(g,2),v=e=>{z(e,lb())},y=O(()=>!tb(I(r)));V(_,e=>{I(y)&&e(v)}),T(h),T(o),F(e=>{d=U(u,1,`live-dot`,null,d,{"is-streaming":sb.active}),B(p,e)},[()=>rb(sb.granularity)]),z(e,o),D()}function fb(e){let t=e||{};if(t.total_tokens!==null&&t.total_tokens!==void 0){let e=Number(t.total_tokens);if(Number.isFinite(e))return e}let n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function pb(e,t){if(!t)return 0;let n=e&&e.summary?e.summary:{},r=Number(n.total_hits||0);return Number.isFinite(r)&&r>0?r:0}function mb(e,t,n){let r=Number(e&&e.total_requests||0);return(Number.isFinite(r)?r:0)+pb(t,n)}function hb(e,t,n){let r=pb(t,n);return r<=0?``:oc(mb(e,t,n)-r)+` to providers + `+oc(r)+` from cache`}function gb(e){let t=e&&e.summary?e.summary:{},n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function _b(e,t,n){let r=e=>{let t=Number(e||0);return Number.isFinite(t)&&t>0?t:0},i=e||{},a=r(i.uncached_input_tokens),o=r(i.cached_input_tokens),s=r(i.cache_write_input_tokens),c=t&&t.summary?t.summary:{},l=n?r(c.total_input_tokens):0;return[{key:`uncached`,label:`Regular`,tokens:a+s,colorVar:`--cache-meter-uncached`,note:s>0?`Includes `+oc(s)+` cache-write tokens`:``},{key:`prompt`,label:`Prompt cached`,tokens:o,colorVar:`--cache-meter-prompt`,note:`Provider prompt-cache reads`},{key:`local`,label:`Locally cached`,tokens:l,colorVar:`--cache-meter-local`,note:`Served from GoModel response cache`}]}function vb(e,t,n){return _b(e,t,n).reduce((e,t)=>e+t.tokens,0)}function yb(e,t,n){return vb(e,t,n)>0}function bb(e,t,n){let r=_b(e,t,n),i=r.reduce((e,t)=>e+t.tokens,0);if(i<=0)return r.map(e=>Object.assign({},e,{pct:0}));let a=r.map(e=>{let t=e.tokens/i*100,n=Math.floor(t);return Object.assign({},e,{pct:n,remainder:t-n})}),o=100-a.reduce((e,t)=>e+t.pct,0);return a.map((e,t)=>({index:t,remainder:e.remainder,tokens:e.tokens})).filter(e=>e.tokens>0).sort((e,t)=>t.remainder-e.remainder).forEach(e=>{o>0&&(a[e.index].pct+=1,--o)}),a}function xb(e,t,n){return bb(e,t,n).filter(e=>e.tokens>0)}function Sb(e){let t=[e.label+`: `+oc(e.tokens)+` input tokens (`+e.pct+`%)`];return e.note&&t.push(e.note),t.join(` +`)}function Cb(e){let t=(e||[]).map(e=>e.label+` `+e.pct+`%`);return`Cache breakdown of input tokens — `+(t.length?t.join(`, `):`no data`)}function wb(e){return e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`)}function Tb(e,t,n,r){if(t!==`daily`||!n||!r)return e;let i={};(e||[]).forEach(e=>{i[e.date]=e});let a=[];for(let e=new Date(n);e<=r;e.setUTCDate(e.getUTCDate()+1)){let t=wb(e);a.push(i[t]||{date:t,input_tokens:0,output_tokens:0,total_tokens:0,requests:0,input_cost:null,output_cost:null,total_cost:null})}return a}function Eb(e,t){let n=e=>Number(e)||0,r=e.map(e=>e.date),i=e.map(e=>n(e.uncached_input_tokens)+n(e.cache_write_input_tokens)+n(e.cached_input_tokens)>0?n(e.uncached_input_tokens)+n(e.cache_write_input_tokens):n(e.input_tokens)),a=e.map(e=>n(e.output_tokens)),o=e.map(e=>n(e.cached_input_tokens)),s={};return(t||[]).forEach(e=>{s[e.date]=e}),{labels:r,inputPaid:i,output:a,prompt:o,local:r.map(e=>{let t=s[e];return t?n(t.input_tokens)+n(t.output_tokens):0})}}function Db(e){let t=e||{},n=Math.max(0,Number(t.uncached_input_tokens)||0),r=Math.max(0,Number(t.cached_input_tokens)||0),i=Math.max(0,Number(t.cache_write_input_tokens)||0),a=n+r+i;return a>0?r/a*100:0}function Ob(e){let t=e||{};return(Number(t.uncached_input_tokens)||0)+(Number(t.cached_input_tokens)||0)+(Number(t.cache_write_input_tokens)||0)>0}function kb(e){return Ob(e)?Math.round(Db(e))+`%`:`—`}function Ab(e,t,n={}){let r=!!n.cacheEnabled,i=n.resolve||(e=>e),a=(e,t)=>i(`color-mix(in srgb, `+e+` `+t+`%, transparent)`),o=(e,t,n,r)=>Object.assign({label:e,data:t,borderColor:n,backgroundColor:n,fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4},r||{}),s=[o(`Input Tokens`,t.inputPaid,i(`var(--token-input)`),{fill:`origin`}),o(`Output Tokens`,t.output,i(`var(--token-output)`),{fill:`-1`}),o(`Prompt (Input) Cached`,t.prompt,i(`var(--token-prompt)`),{fill:`-1`,borderDash:[6,4]})];return r&&s.push(o(`Locally Cached`,t.local,a(`var(--info)`,35),{fill:`-1`,borderDash:[2,3]})),{type:`line`,data:{labels:t.labels,datasets:s},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:10}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:qy(e)}}}}}function jb(e,t,n){let r=Math.max(0,Math.min(100,e));return{type:`doughnut`,data:{datasets:[{data:[r,100-r],backgroundColor:[t,n],borderWidth:0,spacing:0}]},options:{rotation:-90,circumference:180,cutout:`84%`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:1},events:[],plugins:{legend:{display:!1},tooltip:{enabled:!1}}}}}var Mb=`gomodel_provider_status_details_expanded`,Nb=`gomodel_provider_card_expanded_overrides`,Pb=3e3,Fb=`https://gomodel.enterpilot.io/docs/providers/`,Ib={anthropic:`anthropic`,azure:`azure`,bailian:`bailian`,bedrock:`bedrock`,"bedrock-mantle":`bedrock-mantle`,cohere:`cohere`,deepseek:`deepseek`,gemini:`gemini`,opencode_go:`opencode-go`,oracle:`oracle`,vertex:`vertex`,vllm:`vllm`,xiaomi:`xiaomi`};function Lb(){return{summary:{total:0,healthy:0,degraded:0,unhealthy:0,overall_status:`degraded`},providers:[]}}function Rb(e){let t={detailsExpanded:!1,cardOverrides:{}};try{if(e){let n=e.getItem(Mb);n===`true`||n===`false`?t.detailsExpanded=n===`true`:e.setItem(Mb,`false`);let r=JSON.parse(e.getItem(Nb)||`{}`);r&&typeof r==`object`&&!Array.isArray(r)&&(t.cardOverrides=r)}}catch{}return t}function zb(e,t){if(e)try{e.setItem(Mb,t?`true`:`false`)}catch{}}function Bb(e,t){if(e)try{e.setItem(Nb,JSON.stringify(t))}catch{}}function Vb(e,t,n){let r=n&&n.name?String(n.name):``;return r&&Object.prototype.hasOwnProperty.call(e,r)?e[r]===!0:t}function Hb(e){return`is-`+(String(e&&e.overall_status||`degraded`).trim()||`degraded`)}function Ub(e){return`is-`+(String(e||`degraded`).trim()||`degraded`)}function Wb(e){let t=e||{};return String(t.healthy||0)+`/`+String(t.total||0)}function Gb(e){let t=e||{},n=Number(t.total||0),r=Number(t.healthy||0);return n>0&&rString(e&&e.status_label||``).trim().toLowerCase()===`starting`)}function Jb(e){if(!e||!e.runtime)return``;let t=e.runtime.last_model_fetch_at||``,n=e.runtime.last_availability_check_at||``;return t?n&&Date.parse(n)>Date.parse(t)?n:t:n}function Yb(e,t){let n=Jb(e);if(!n||typeof t!=`function`)return`-`;let r=t(n);if(!r||r===`-`)return`-`;let i=String(r).split(` `);return i.length>1?i.slice(1).join(` `):r}function Xb(e,t){let n=Jb(e);return n?typeof t==`function`?t(n):String(n):``}function Zb(e){if(!e)return``;let t=String(e.name||``).trim(),n=String(e.type||e.config&&e.config.type||``).trim();return!n||n===t?``:n}function Qb(e){let t=String(e&&(e.type||e.config&&e.config.type)||``).trim().toLowerCase(),n=t?Ib[t]:``;return n?Fb+n+`?utm_source=gomodel_dashboard`:``}function $b(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.retry:null;return t?String(t.max_retries)+` retries, `+t.initial_backoff+` initial, `+t.max_backoff+` max, factor `+t.backoff_factor+`, jitter `+t.jitter_factor:`-`}function ex(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.circuit_breaker:null;return t?String(t.failure_threshold)+` fail, `+String(t.success_threshold)+` success, `+t.timeout+` timeout`:`-`}function tx(e){let t=e&&e.config&&Array.isArray(e.config.models)?e.config.models.filter(Boolean):[];return t.length===0?`Automatic`:t.join(`, `)}function nx(e){if(!e)return``;let t=[];return e.status_reason&&t.push(String(e.status_reason)),e.last_error&&t.push(`Last error: `+String(e.last_error)),t.join(` + +`)}function rx(e){let t=e&&e.request_health;return t&&typeof t==`object`?t:null}function ix(e){let t=rx(e);return t?String(t.circuit_state||``).trim():``}function ax(e){let t=ix(e);return t?t.charAt(0).toUpperCase()+t.slice(1):``}function ox(e){let t=ix(e);return t===`open`?`is-unhealthy`:t===`half-open`?`is-degraded`:`is-healthy`}function sx(e){let t=rx(e);if(!t)return``;let n=Number(t.requests||0),r=Number(t.errors||0),i=Math.round(Number(t.window_seconds||0)/60),a=i>0?`last `+i+` min`:`recent`;return String(n)+` request`+(n===1?``:`s`)+` · `+String(r)+` error`+(r===1?``:`s`)+` (`+a+`)`}function cx(e){let t=rx(e);return t&&Array.isArray(t.models)?t.models:[]}function lx(e){return e?String(Number(e.errors||0))+`/`+String(Number(e.requests||0))+` failed`:``}function ux(e){let t=e&&e.last_error;return!t||!t.message?``:(t.status_code?`HTTP `+String(t.status_code)+`: `:``)+t.message}function dx(){return{name:``,slug:``,url:``,transport:`http`,description:``,enabled:!0,headers:[],allowed_tools:``,disallowed_tools:``,user_paths:``,tool_timeout_seconds:``}}function fx(){return{server:``,status:``,instructions:``,tools:[],prompts:[],resources:[],templates:[]}}function px(e){return String(e&&(e.slug||e.name)||``).trim()}function mx(e){return String(e&&e.status||``).trim()||`connecting`}function hx(e){switch(mx(e)){case`connected`:return`status-success`;case`degraded`:return String(e&&e.last_error||``).trim()?`status-error`:`status-warning`;case`connecting`:return`status-neutral`;default:return`status-unknown`}}function gx(e,t){let n=mx(e),r=String(e&&e.last_error||``).trim();return r&&n!==`connected`?r:n===`connected`&&e&&e.connected_at?`Connected since `+(typeof t==`function`?t:String)(e.connected_at):``}function _x(e){return String(e&&e.transport||``)===`stdio`?`local command`:String(e&&e.url||``).trim()||`—`}function vx(e){let t=Number(e&&e.prompt_count||0),n=Number(e&&e.resource_count||0);return t+` prompts · `+n+` resources`}function yx(e){let t=String(e||``).normalize(`NFKD`).toLowerCase(),n=t.replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/-+$/g,``);if(n)return n;let r=2166136261;for(let e of t)r=Math.imul((r^e.codePointAt(0))>>>0,16777619)>>>0;return`mcp-`+r.toString(16).padStart(8,`0`)}function bx(e){return String(e||``).split(` +`).map(e=>e.trim()).filter(e=>e)}function xx(e){return!e||typeof e!=`object`||Array.isArray(e)?[]:Object.keys(e).sort().map(t=>({name:t,value:String(e[t]||``)}))}function Sx(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=String(e&&e.name||``).trim();n&&(t[n]=String(e&&e.value||``))}),t}function Cx(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.slug,e.url,e.transport,e.description,e.status].some(e=>String(e||``).toLowerCase().includes(r)))}function wx(e){return{name:String(e.name||``).trim(),slug:px(e),url:String(e.url||``).trim(),transport:e.transport===`sse`?`sse`:`http`,description:String(e.description||``).trim(),enabled:e.enabled!==!1,headers:xx(e.headers),allowed_tools:(Array.isArray(e.allowed_tools)?e.allowed_tools:[]).join(`, `),disallowed_tools:(Array.isArray(e.disallowed_tools)?e.disallowed_tools:[]).join(`, `),user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` +`),tool_timeout_seconds:e.tool_timeout_seconds?String(e.tool_timeout_seconds):``}}function Tx(e,t,n){let r=String(e.name||``).trim(),i=String(e.slug||yx(r)).trim().toLowerCase(),a=String(e.url||``).trim(),o=e.transport===`sse`?`sse`:`http`;if(!r)return{error:`Name is required.`};if(!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(i))return{error:`Slug must use 1–64 lowercase ASCII letters, numbers, hyphens, or underscores.`};if(t===`create`&&(n||[]).some(e=>px(e)===i))return{error:`Slug "`+i+`" is already in use.`};if(!a)return{error:`URL is required.`};let s,c=String(e.tool_timeout_seconds||``).trim();if(c!==``){let e=Number(c);if(!Number.isSafeInteger(e)||e<0)return{error:`Tool timeout must be a non-negative whole number of seconds.`};s=e}return{payload:{name:r,slug:i,url:a,transport:o,headers:Sx(e.headers),description:String(e.description||``).trim(),enabled:!!e.enabled,allowed_tools:ic(e.allowed_tools),disallowed_tools:ic(e.disallowed_tools),user_paths:bx(e.user_paths),tool_timeout_seconds:s}}}function Ex(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=e=>(Array.isArray(e)?e:[]).filter(e=>e&&typeof e==`object`);return{server:String(n.server||e||``).trim(),status:String(n.status||``).trim(),instructions:String(n.instructions||``).trim(),tools:r(n.tools),prompts:r(n.prompts),resources:r(n.resources),templates:r(n.templates)}}function Dx(e,t){return String(e&&e.server||``)+`_`+String(t||``)}function Ox(e){let t=e||fx(),n=(e,t)=>{let n=String(e||``).trim(),r=String(t||``).trim();return n&&r?n+` — `+r:r||n},r=e=>n=>({key:e+`:`+String(n.name||``),name:String(n.name||``),aggregated:Dx(t,n.name),description:String(n.description||``).trim()});return[{key:`tools`,title:`Tools`,items:(t.tools||[]).map(r(`tool`))},{key:`prompts`,title:`Prompts`,items:(t.prompts||[]).map(r(`prompt`))},{key:`resources`,title:`Resources`,items:(t.resources||[]).map(e=>({key:`resource:`+String(e.uri||``),name:String(e.uri||``),aggregated:``,description:n(e.name,e.description)}))},{key:`templates`,title:`Resource templates`,items:(t.templates||[]).map(e=>({key:`template:`+String(e.uri_template||``),name:String(e.uri_template||``),aggregated:``,description:n(e.name,e.description)}))}].filter(e=>e.items.length>0)}function kx(e){return Ox(e).length===0}function Ax(e){return(e||[]).length}function jx(e){return(e||[]).filter(e=>mx(e)===`connected`).length}function Mx(e){return(e||[]).filter(e=>e&&e.enabled!==!1&&mx(e)===`degraded`).length}function Nx(e,t){return!!e&&Ax(t)>0}function Px(e){return String(jx(e))+`/`+String(Ax(e))}function Fx(e){return Mx(e)>0?`is-degraded`:`is-healthy`}function Ix(e){let t=Mx(e);if(t>0)return String(t)+` server`+(t===1?``:`s`)+` need`+(t===1?`s`:``)+` attention`;let n=Ax(e),r=jx(e);return n>0&&r===n?`All MCP servers connected`:String(r)+` of `+String(n)+` server`+(n===1?``:`s`)+` connected`}function Lx(){return{interval:`day`,buckets:[],summary:{requests:0},provider_latency:[]}}function Rx(e){let t=e&&typeof e==`object`?e:{};return{interval:t.interval===`hour`?`hour`:`day`,buckets:Array.isArray(t.buckets)?t.buckets:[],summary:t.summary&&typeof t.summary==`object`?t.summary:{requests:0},provider_latency:Array.isArray(t.provider_latency)?t.provider_latency:[]}}function zx(e){return Number(e&&e.summary&&e.summary.requests||0)>0}function Bx(e){return(e&&Array.isArray(e.provider_latency)?e.provider_latency:[]).length>0}function Vx(e){let t=e&&e.summary?e.summary.success_rate:null;return t==null?`—`:(Math.round(Number(t)*1e3)/10).toFixed(1)+`%`}function Hx(e,t){return Number(e&&e.summary&&e.summary[t]||0)}function Ux(e){let t=Number(e);return Number.isFinite(t)?t>=6e4?(t/6e4).toFixed(1)+` min`:t>=1e3?(t/1e3).toFixed(2)+` s`:Math.round(t)+` ms`:`-`}function Wx(e){let t=e&&e.summary?e.summary.avg_duration_ms:null;return t==null?`—`:Ux(Number(t))}function Gx(e,t){try{let n={};return new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,hourCycle:`h23`}).formatToParts(e).forEach(e=>{n[e.type]=e.value}),{year:n.year,month:n.month,day:n.day,hour:Number(n.hour)}}catch{return{year:String(e.getFullYear()),month:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()],day:String(e.getDate()),hour:e.getHours()}}}function Kx(e,t,n){let r=new Date(e.start);if(Number.isNaN(r.getTime()))return String(e.start||``);let i=Gx(r,n),a=i.month+` `+i.day;return t!==`hour`||i.hour===0?a:String(i.hour).padStart(2,`0`)+`:00`}function qx(e,t,n,r){let i=new Date(e.start);if(Number.isNaN(i.getTime()))return String(e.start||``);if(t===`hour`)return r(e.start);let a=Gx(i,n);return a.month+` `+a.day+`, `+a.year}function Jx(e){return{ok:e(`var(--success)`),clientError:e(`var(--warning)`),serverError:e(`var(--danger)`),other:e(`color-mix(in srgb, var(--text-muted) 55%, transparent)`)}}function Yx(e,t,n={}){let r=n.interval===`hour`?`hour`:`day`,i=n.zone,a=n.resolve||(e=>e),o=n.formatTimestamp||(e=>String(e)),s=t.map(e=>Kx(e,r,i)),c=Jx(a),l=a(`var(--bg-surface)`),u=e=>Number(e)||0,d=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:l,borderWidth:1,borderSkipped:!1,borderRadius:2,maxBarThickness:28}),f=[d(`2xx`,t.map(e=>u(e.status_2xx)),c.ok),d(`4xx`,t.map(e=>u(e.status_4xx)),c.clientError),d(`5xx`,t.map(e=>u(e.status_5xx)),c.serverError)];return t.some(e=>u(e.status_other)>0)&&f.push(d(`Other`,t.map(e=>u(e.status_other)),c.other)),{type:`bar`,data:{labels:s,datasets:f},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{title:e=>e.length?qx(t[e[0].dataIndex],r,i,o):``,label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),precision:0,callback:e=>uc(e)}}}}}}function Xx(e=Vy()){let t={};return function(n){return n in t||(t[n]=e[Object.keys(t).length%e.length]),t[n]}}function Zx(e,t,n,r={}){let i=r.interval===`hour`?`hour`:`day`,a=r.zone,o=r.formatTimestamp||(e=>String(e)),s=r.providerColor||Xx();return{type:`line`,data:{labels:t.map(e=>Kx(e,i,a)),datasets:n.map(e=>({label:e.provider,data:(e.avg_duration_ms||[]).map(e=>e==null?null:Number(e)),borderColor:s(e.provider),backgroundColor:s(e.provider),fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4,spanGaps:i===`hour`&&2}))},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{title:e=>e.length?qx(t[e[0].dataIndex],i,a,o):``,label:e=>{let t=(n[e.datasetIndex]&&n[e.datasetIndex].requests||[])[e.dataIndex],r=Number(t)||0;return e.dataset.label+`: `+Ux(e.parsed.y)+(r>0?` (`+r.toLocaleString()+` req)`:``)}})},scales:{x:{grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),callback:e=>Ux(e)}}}}}}var Qx=class{#e=k(j(Lb()));get status(){return I(this.#e)}set status(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=k(!1);get loadedOnce(){return I(this.#n)}set loadedOnce(e){A(this.#n,e,!0)}#r=k(!1);get detailsExpanded(){return I(this.#r)}set detailsExpanded(e){A(this.#r,e,!0)}#i=k(j({}));get cardOverrides(){return I(this.#i)}set cardOverrides(e){A(this.#i,e,!0)}#a=null;#o=null;#s=!1;initPreferences(){if(this.#s)return;this.#s=!0;let e=Rb(wa());this.detailsExpanded=e.detailsExpanded,this.cardOverrides=e.cardOverrides}cardExpanded(e){return Vb(this.cardOverrides,this.detailsExpanded,e)}toggleCard(e){let t=e&&e.name?String(e.name):``;if(!t)return;let n={...this.cardOverrides};n[t]=!this.cardExpanded(e),this.cardOverrides=n,Bb(wa(),this.cardOverrides)}toggleDetails(){this.detailsExpanded=!this.detailsExpanded,this.cardOverrides={},zb(wa(),this.detailsExpanded),Bb(wa(),this.cardOverrides)}detailsToggleLabel(){return this.detailsExpanded?`Show Details`:`Hide Details`}async fetch(){this.initPreferences(),this.#a&&this.#a.abort();let e=new AbortController;this.#a=e,this.loading=!0;try{let t=await _s(`/admin/providers/status`,{label:`provider status`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.status=Lb(),this.#l();return}let n=t.data&&typeof t.data==`object`?t.data:Lb();n.summary||=Lb().summary,Array.isArray(n.providers)||(n.providers=[]),this.status=n,this.#c()}catch(e){if(ys(e))return;console.error(`Failed to fetch provider status:`,e),this.status=Lb(),this.#l()}finally{this.#a===e&&(this.#a=null,this.loading=!1,this.loadedOnce=!0)}}#c(){this.#l(),qb(this.status.providers)&&(this.#o=setTimeout(()=>{this.#o=null,this.fetch()},Pb))}#l(){this.#o&&=(clearTimeout(this.#o),null)}stopPolling(){this.#l()}},$x=class{#e=k(j(Lx()));get stats(){return I(this.#e)}set stats(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=0;async fetch(){let e=++this.#n;this.loading=!0;try{let t=await _s(`/admin/audit/stats?`+Mc.queryStr(),{label:`audit stats`});if(t.stale||e!==this.#n)return;if(!t.ok){this.stats=Lx();return}this.stats=Rx(t.data)}catch(t){if(console.error(`Failed to fetch audit stats:`,t),e!==this.#n)return;this.stats=Lx()}finally{e===this.#n&&(this.loading=!1)}}},eS=class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!1);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}async fetch(){if(await Ss.ensureLoaded(),!Ss.mcpVisible()){this.available=!1,this.servers=[];return}this.loading=!0;try{let e=await _s(`/admin/mcp-servers`,{label:`mcp servers`});if(e.stale)return;if(e.status===503||e.status===404){this.available=!1,this.servers=[];return}if(this.available=!0,!e.ok){this.servers=[];return}this.servers=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch MCP servers:`,e),this.servers=[]}finally{this.loading=!1}}},tS=class{#e=k(j([]));get data(){return I(this.#e)}set data(e){A(this.#e,e,!0)}#t=k(`tokens`);get mode(){return I(this.#t)}set mode(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=null;async fetch(){this.#r&&this.#r.abort();let e=new AbortController;this.#r=e,this.loading=!0;try{let t=await _s(`/admin/usage/daily?days=365&interval=daily`,{label:`calendar`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.data=[];return}this.data=Array.isArray(t.data)?t.data:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch calendar data:`,e),this.data=[]}finally{this.#r===e&&(this.#r=null,this.loading=!1)}}},nS=new Qx,rS=new $x,iS=new eS,aS=new tS,oS=(e,t=f,n=f,r=f,i=f)=>{var a=cS(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=M(c),u=M(l),d=M(u,!0);T(u),Ue(),T(l);var p=P(l,4),m=M(p),h=M(m,!0);T(m),Ue(),T(p);var g=P(p,4),_=M(g,!0);T(g),T(c),T(a),F((e,n,r,i,a,o)=>{B(s,t()),W(l,`title`,e),B(d,n),W(p,`title`,r),B(h,i),W(g,`title`,a),B(_,o)},[()=>dc(`Input tokens`,n()),()=>uc(n()),()=>dc(`Output tokens`,r()),()=>uc(r()),()=>dc(`Total tokens`,i()),()=>uc(i())]),z(e,a)},sS=(e,t=f,n=f,r=f,i=f,a=f,o=f)=>{var s=dS(),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u);var p=P(u,2),m=e=>{var t=lS(),n=M(t,!0);T(t),F(()=>{W(t,`aria-label`,o().title),W(t,`title`,o().title),B(n,a())}),L(`click`,t,function(...e){o().onclick?.apply(this,e)}),z(e,t)},h=e=>{var t=uS(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(p,e=>{o()?e(m):e(h,-1)}),T(s),F(()=>{U(s,1,`card provider-status-flag ${t()??``} ${n()??``}`,`svelte-6tr9cf`),B(l,r()),B(d,i())}),z(e,s)},cS=R(`
                i + o =
                `),lS=R(``),uS=R(` `),dS=R(`
                `),fS=R(`
                Cache Hits
                `),pS=R(`
                Total Requests
                Estimated Cost
                Prompt Cache Rate
                `);function mS(e,t){E(t,!0);let n=O(()=>Rc.summary),r=O(()=>Rc.cacheOverview),i=O(()=>Rc.cacheAnalyticsEnabled()),a=O(()=>nS.status.summary);function o(){let e=document.getElementById(`provider-status-section`);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),e.focus({preventScroll:!0}))}var s=pS(),c=M(s);{let e=O(()=>fb(I(n)));oS(c,()=>`Tokens`,()=>I(n).total_input_tokens,()=>I(n).total_output_tokens,()=>I(e))}var l=P(c,2),u=P(M(l),2),d=M(u,!0);T(u),T(l);var f=P(l,2),p=e=>{var t=fS(),n=P(M(t),2),i=M(n,!0);T(n),T(t),F(e=>B(i,e),[()=>oc(I(r).summary.total_hits)]),z(e,t)};V(f,e=>{I(i)&&e(p)});var m=P(f,2),h=P(M(m),2),g=M(h,!0);T(h),T(m);var _=P(m,2),v=e=>{{let t=O(()=>gb(I(r)));oS(e,()=>`Local Cache`,()=>I(r).summary.total_input_tokens,()=>I(r).summary.total_output_tokens,()=>I(t))}};V(_,e=>{I(i)&&e(v)});var y=P(_,2),b=P(M(y),2),x=M(b);jy(x,{build:()=>jb(Db(I(n)),zy(`var(--token-prompt)`),zy(`var(--bg-surface-hover)`))});var S=P(x,2),C=M(S,!0);T(S),T(b),T(y);var w=P(y,2),ee=e=>{{let t=O(()=>Hb(I(a))),n=O(()=>Wb(I(a))),r=O(()=>Kb(I(a))),i=O(()=>Gb(I(a))?{title:`View providers overview`,onclick:o}:null);sS(e,()=>`provider-status-overview-card`,()=>I(t),()=>`Provider Status`,()=>I(n),()=>I(r),()=>I(i))}};V(w,e=>{I(a).total>0&&e(ee)});var te=P(w,2),ne=e=>{{let t=O(()=>Fx(iS.servers)),n=O(()=>Px(iS.servers)),r=O(()=>Ix(iS.servers));sS(e,()=>`mcp-servers-flag`,()=>I(t),()=>`MCP Servers`,()=>I(n),()=>I(r),()=>({title:`View MCP servers`,onclick:()=>Jo.navigate(`mcp-servers`)}))}},re=O(()=>Nx(iS.available,iS.servers));V(te,e=>{I(re)&&e(ne)}),T(s),F((e,t,n,r,i)=>{W(u,`title`,e),B(d,t),B(g,n),W(b,`aria-label`,r),B(C,i)},[()=>hb(I(n),I(r),I(i)),()=>oc(mb(I(n),I(r),I(i))),()=>sc(I(n).total_cost),()=>`Prompt cache rate `+kb(I(n)),()=>kb(I(n))]),z(e,s),D()}Hr([`click`]);var hS=R(` `),gS=R(`
                `),_S=R(`No usage in the selected period yet`),vS=R(`
                `),yS=R(`

                Tokens

                Share of input tokens over the selected period
                `);function bS(e,t){E(t,!0);let n=O(()=>Rc.cacheAnalyticsEnabled()),r=O(()=>bb(Rc.summary,Rc.cacheOverview,I(n))),i=O(()=>xb(Rc.summary,Rc.cacheOverview,I(n))),a=O(()=>yb(Rc.summary,Rc.cacheOverview,I(n)));var o=yS(),s=P(M(o),2);let c;var l=M(s);H(l,17,()=>I(i),e=>e.key,(e,t)=>{var n=gS(),r=M(n),i=e=>{var n=hS(),r=M(n);T(n),F(()=>B(r,`${I(t).pct??``}%`)),z(e,n)};V(r,e=>{I(t).pct>=8&&e(i)}),T(n),F(e=>{Hi(n,`width: ${I(t).pct??``}%; background: var(${I(t).colorVar??``})`),W(n,`title`,e)},[()=>Sb(I(t))]),z(e,n)});var u=P(l,2),d=e=>{z(e,_S())};V(u,e=>{I(a)||e(d)}),T(s);var f=P(s,2);H(f,21,()=>I(r),e=>e.key,(e,t)=>{var n=vS(),r=M(n),i=P(r,2),a=M(i,!0);T(i);var o=P(i,2),s=M(o);T(o);var c=P(o,2),l=M(c,!0);T(c),T(n),F((e,i)=>{W(n,`title`,e),Hi(r,`background: var(${I(t).colorVar??``})`),B(a,I(t).label),B(s,`${I(t).pct??``}%`),B(l,i)},[()=>Sb(I(t)),()=>oc(I(t).tokens)]),z(e,n)}),T(f),T(o),F(e=>{c=U(s,1,`cache-meter-bar svelte-1yzecxj`,null,c,{"is-empty":!I(a)}),W(s,`aria-label`,e)},[()=>Cb(I(i))]),z(e,o),D()}var xS=R(``);function SS(e,t){let n=ya(t,`size`,3,16),r=ya(t,`label`,3,`Loading`),i=ya(t,`class`,3,``);var a=xS();F(()=>{U(a,1,Fi([`spinner`,i()]),`svelte-b54l9o`),Hi(a,`--spinner-size: ${n()??``}px`),W(a,`aria-label`,r())}),z(e,a)}var CS=Xr(` `),wS=Xr(``);function TS(e,t){let n=ya(t,`label`,3,`No data`);var r=wS(),i=P(M(r),9),a=e=>{var t=CS(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(i,e=>{n()&&e(a)}),T(r),F(()=>{W(r,`role`,n()?`img`:void 0),W(r,`aria-label`,n()||void 0),W(r,`aria-hidden`,n()?void 0:`true`)}),z(e,r)}var ES=R(`
                `),DS=R(`

                `);function OS(e,t){E(t,!0);let n=[`daily`,`weekly`,`monthly`,`yearly`];function r(e){Mc.interval=e,t.onintervalchange?.()}function i(){let e=Rc.daily;if(e.length===0)return null;let t=Mc.rangeStart(),n=Mc.rangeEnd(),r=Eb(Tb(e,Mc.interval,t,n),Tb(Array.isArray(Rc.cacheOverview.daily)?Rc.cacheOverview.daily:[],Mc.interval,t,n));return Ab(Iy(),r,{cacheEnabled:Rc.cacheAnalyticsEnabled(),resolve:zy})}var a=DS(),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2);{let e=O(()=>n.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})));Py(l,{ariaLabel:`Usage chart interval`,get options(){return I(e)},get value(){return Mc.interval},onchange:r})}T(o);var u=P(o,2),d=M(u);jy(d,{build:i});var f=P(d,2),p=e=>{var t=ES();SS(M(t),{size:24,label:`Loading usage`}),T(t),z(e,t)},m=e=>{var t=ES();TS(M(t),{}),T(t),z(e,t)};V(f,e=>{Rc.daily.length===0&&Rc.loading?e(p):Rc.daily.length===0&&!K.authError&&e(m,1)}),T(u),T(a),F(e=>B(c,e),[()=>Mc.chartTitle()]),z(e,a),D()}var kS=10,AS=.7;function jS(e,t){if(e<=0||t<=0)return 0;let n=(e/t)**+AS,r=Math.ceil(n*kS);return r<1?1:r>kS?kS:r}function MS(){let e=[];for(let t=0;t<=kS;t++)e.push(t);return e}function NS(e,t,n){let r={};(e||[]).forEach(e=>{r[e.date]=e});let i=Qo(es(n,-364)),a=i.getUTCDay();i.setUTCDate(i.getUTCDate()-a);let o=[];for(let e=new Date(i);$o(e)<=n;e.setUTCDate(e.getUTCDate()+1)){let n=$o(e),i=r[n],a=0;i&&(a=t===`costs`?i.total_cost==null?0:i.total_cost:i.total_tokens||0),o.push({dateStr:n,value:a,level:0,empty:!1})}let s=0;for(let e=0;es&&(s=o[e].value);for(let e=0;e0){for(;l.length<7;)l.push({dateStr:``,value:0,level:0,empty:!0});c.push(l)}return c}function PS(e){let t=Qo(es(e,-364)),n=t.getUTCDay();t.setUTCDate(t.getUTCDate()-n);let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],i=[],a={},o=0;for(let n=new Date(t);$o(n)<=e;n.setUTCDate(n.getUTCDate()+7),o++){let t=null;if(o===0)t=new Date(n);else for(let r=0;r<7;r++){let i=new Date(n);if(i.setUTCDate(n.getUTCDate()+r),$o(i)>e)break;if(i.getUTCDate()===1){t=i;break}}if(!t)continue;let s=t.getUTCFullYear()+`-`+t.getUTCMonth();a[s]||(i.push({label:r[t.getUTCMonth()],col:o,key:s}),a[s]=!0)}for(let e=0;e `),RS=R(`
                `),zS=R(`
                `),BS=R(`
                `),VS=R(`
                `),HS=R(`

                Activity

                Mon Wed Fri
                `,1);function US(e,t){E(t,!0);let n=k(j({show:!1,x:0,y:0,text:``})),r=O(()=>ds.currentDateKey()),i=O(()=>NS(aS.data,aS.mode,I(r))),a=O(()=>PS(I(r)));function o(e,t){t.empty||A(n,{show:!0,x:e.clientX,y:e.clientY,text:IS(t,aS.mode)},!0)}function s(){A(n,{show:!1,x:0,y:0,text:``},!0)}var c=HS(),l=N(c),u=M(l),d=P(M(u),2),f=e=>{SS(e,{size:14,label:`Loading activity`})};V(d,e=>{aS.loading&&aS.data.length===0&&e(f)}),Py(P(d,2),{ariaLabel:`Activity calendar mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return aS.mode},onchange:e=>aS.mode=e}),T(u);var p=P(u,2),m=P(M(p),2),h=M(m);H(h,21,()=>I(a),e=>e.key,(e,t)=>{var n=LS(),r=M(n,!0);T(n),F(()=>{Hi(n,`grid-column: ${I(t).col+1} / span ${I(t).span??``}`),B(r,I(t).label)}),z(e,n)}),T(h);var g=P(h,2);H(g,21,()=>I(i),oi,(e,t,n)=>{var r=zS();H(r,23,()=>I(t),(e,t)=>n+`-`+t,(e,t)=>{var n=RS();F(()=>U(n,1,Fi([`contribution-calendar-cell`,I(t).empty?`empty`:`level-${I(t).level}`]),`svelte-3hfxuq`)),Vr(`mouseenter`,n,e=>o(e,I(t))),Vr(`mouseleave`,n,s),z(e,n)}),T(r),z(e,r)}),T(g),T(m),T(p);var _=P(p,2),v=M(_),y=M(v),b=M(y,!0);T(y),T(v);var x=P(v,2);H(P(M(x),2),16,MS,e=>e,(e,t)=>{var n=BS();F(()=>U(n,1,`contribution-calendar-cell level-${t??``}`,`svelte-3hfxuq`)),z(e,n)}),Ue(2),T(x),T(_),T(l);var S=P(l,2),C=e=>{var t=VS(),r=M(t,!0);T(t),F(()=>{Hi(t,`left: ${I(n).x??``}px; top: ${I(n).y-40}px`),B(r,I(n).text)}),z(e,t)};V(S,e=>{I(n).show&&e(C)}),F(e=>B(b,e),[()=>FS(aS.data,aS.mode)]),z(e,c),D()}var WS=R(``),GS=R(`

                `),KS=R(`
                `);function qS(e,t){E(t,!0);let n=ya(t,`label`,3,`help`),r=ya(t,`text`,3,``),i=ya(t,`open`,15,!1),a=ya(t,`external`,3,!1),o=O(()=>!!r()||!!t.help||a());var s=KS(),c=M(s),l=M(c);gi(l,()=>t.title??f);var u=P(l,2),d=e=>{var r=WS();let a;F(()=>{a=U(r,1,`inline-help-toggle svelte-y40or3`,null,a,{"is-open":i()}),W(r,`aria-label`,(i()?`Hide `:`Show `)+n()),W(r,`aria-expanded`,i()),W(r,`aria-controls`,t.copyId)}),L(`click`,r,()=>i(!i())),z(e,r)};V(u,e=>{I(o)&&e(d)}),gi(P(u,2),()=>t.extra??f),T(c);var p=P(c,2),m=e=>{var n=GS(),i=M(n),a=e=>{var n=Qr();gi(N(n),()=>t.help),z(e,n)},o=e=>{var t=Zr();F(()=>B(t,r())),z(e,t)};V(i,e=>{t.help?e(a):e(o,-1)}),T(n),F(()=>W(n,`id`,t.copyId)),z(e,n)};V(p,e=>{i()&&I(o)&&!a()&&e(m)}),T(s),z(e,s),D()}Hr([`click`]);var JS=R(`

                Provider Latency

                `),YS=R(`
                Avg
                `),XS=R(`

                Requests by Status

                Success 2xx 4xx 5xx
                `,1);function ZS(e,t){E(t,!0);let n=Xx(),r=O(()=>rS.stats);function i(){return{interval:I(r).interval,zone:ds.effectiveTimezone(),resolve:zy,formatTimestamp:e=>ds.formatTimestamp(e)}}var a=Qr(),o=N(a),s=e=>{var t=XS(),a=N(t),o=M(a),s=P(M(o),2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c);var d=P(c,2),f=P(M(d),4),p=M(f,!0);T(f),T(d);var m=P(d,2),h=P(M(m),4),g=M(h,!0);T(h),T(m);var _=P(m,2),v=P(M(_),4),y=M(v,!0);T(v),T(_),T(s),T(o);var b=P(o,2);jy(M(b),{build:()=>Yx(Iy(),I(r).buckets,i())}),T(b),T(a);var x=P(a,2),S=e=>{var t=YS(),a=M(t),o=M(a);qS(o,{copyId:`audit-latency-help-copy`,label:`provider latency help`,text:`Average duration of successful requests as measured at the gateway, per provider. Local cache hits and failed requests are excluded; streamed responses count until the stream completes.`,title:e=>{z(e,JS())},$$slots:{title:!0}});var s=P(o,2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c),T(s),T(a);var d=P(a,2);jy(M(d),{build:()=>Zx(Iy(),I(r).buckets,I(r).provider_latency,{...i(),providerColor:n})}),T(d),T(t),F(e=>B(u,e),[()=>Wx(I(r))]),z(e,t)},C=O(()=>Bx(I(r)));V(x,e=>{I(C)&&e(S)}),F((e,t,n,r)=>{B(u,e),B(p,t),B(g,n),B(y,r)},[()=>Vx(I(r)),()=>oc(Hx(I(r),`status_2xx`)),()=>oc(Hx(I(r),`status_4xx`)),()=>oc(Hx(I(r),`status_5xx`))]),z(e,t)},c=O(()=>zx(I(r)));V(o,e=>{I(c)&&e(s)}),z(e,a),D()}var QS=(e,t=f,n=f,r)=>{let i=Ot(()=>h(r?.(),!1));var a=tC(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=e=>{var t=$S(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)},u=e=>{var t=eC(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(c,e=>{I(i)?e(l):e(u,-1)}),T(a),F(()=>B(s,t())),z(e,a)},$S=R(` `),eC=R(` `),tC=R(`
                `),nC=R(`

                `),rC=R(`
                Breaker State
                `),iC=R(`
                `),aC=R(`
                Models (Recent Traffic)
                `),oC=R(`
                `),sC=R(`

                `);function cC(e,t){E(t,!0);let n=O(()=>ox(t.provider)),r=O(()=>[[`Base URL`,t.provider.config?.base_url],[`API Version`,t.provider.config?.api_version]].filter(([,e])=>!!e));var i=sC();let a;var o=M(i),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{var n=nC(),r=M(n,!0);T(n),F(()=>B(r,t.provider.last_error)),z(e,n)};V(l,e=>{t.provider.last_error&&e(u)});var d=P(l,2),f=e=>{var r=oC(),i=M(r);{let e=O(()=>sx(t.provider));QS(i,()=>`Recent Requests`,()=>I(e))}var a=P(i,2),o=e=>{var r=rC(),i=P(M(r),2),a=M(i),o=M(a,!0);T(a),T(i),T(r),F(e=>{U(a,1,Fi([`provider-status-health-state`,I(n)]),`svelte-6y9wjv`),B(o,e)},[()=>ax(t.provider)]),z(e,r)},s=O(()=>ix(t.provider));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{var n=aC(),r=P(M(n),2);H(r,21,()=>cx(t.provider),e=>e.model,(e,t)=>{var n=iC();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F((e,i)=>{r=U(n,1,`provider-status-health-model svelte-6y9wjv`,null,r,{"is-flagged":I(t).flagged}),W(n,`title`,e),B(a,I(t).model),B(s,i)},[()=>ux(I(t)),()=>lx(I(t))]),z(e,n)}),T(r),T(n),z(e,n)},u=O(()=>cx(t.provider).length>0);V(c,e=>{I(u)&&e(l)}),T(r),z(e,r)},p=O(()=>rx(t.provider));V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=M(m);H(h,17,()=>I(r),([e,t])=>e,(e,t)=>{var n=O(()=>g(I(t),2));QS(e,()=>I(n)[0],()=>I(n)[1],()=>!0)});var _=P(h,2);{let e=O(()=>tx(t.provider));QS(_,()=>`Configured Models`,()=>I(e))}var v=P(_,2);{let e=O(()=>$b(t.provider));QS(v,()=>`Retry`,()=>I(e))}var y=P(v,2);{let e=O(()=>ex(t.provider));QS(y,()=>`Circuit Breaker`,()=>I(e))}T(m),T(o),T(i),F(()=>{a=U(i,1,`provider-status-details svelte-6y9wjv`,null,a,{"is-expanded":t.expanded,"is-collapsed":!t.expanded}),W(i,`aria-hidden`,!t.expanded),B(c,t.provider.status_reason)}),z(e,i),D()}var lC=R(` `),uC=R(``),dC=R(`

                Models Available
                Last Checked
                `);function fC(e,t){E(t,!0);let n=O(()=>nS.cardExpanded(t.provider)),r=e=>ds.formatTimestamp(e);var i=dC(),a=M(i),o=M(a),s=M(o),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=e=>{var n=lC(),r=M(n);T(n),F(e=>B(r,`(${e??``})`),[()=>Zb(t.provider)]),z(e,n)},f=O(()=>Zb(t.provider));V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var n=uC();F((e,t,r)=>{W(n,`href`,e),W(n,`aria-label`,t),W(n,`title`,r)},[()=>Qb(t.provider),()=>`View `+(Zb(t.provider)||t.provider.name)+` provider docs`,()=>`View `+(Zb(t.provider)||t.provider.name)+` provider docs`]),z(e,n)},h=O(()=>Qb(t.provider));V(p,e=>{I(h)&&e(m)}),T(s),T(o);var g=P(o,2),_=M(g,!0);T(g),T(a);var v=P(a,2),y=M(v),b=P(M(y),2),x=M(b,!0);T(b),T(y);var S=P(y,2),C=P(M(S),2),w=M(C,!0);T(C),T(S),T(v);var ee=P(v,2);cC(ee,{get provider(){return t.provider},get expanded(){return I(n)}});var te=P(ee,2);let ne;G(M(te),{get icon(){return Ha},class:`provider-status-card-toggle-icon`}),T(te),T(i),F((e,r,i,a,o)=>{B(l,t.provider.name),U(g,1,`provider-status-pill ${e??``}`,`svelte-nopjmh`),W(g,`title`,r),B(_,t.provider.status_label),B(x,i),W(C,`title`,a),B(w,o),ne=U(te,1,`provider-status-card-toggle svelte-nopjmh`,null,ne,{"is-expanded":I(n)}),W(te,`aria-expanded`,I(n)),W(te,`aria-label`,(I(n)?`Collapse `:`Expand `)+t.provider.name+` details`),W(te,`title`,I(n)?`Collapse details`:`Expand details`)},[()=>Ub(t.provider.status),()=>nx(t.provider),()=>oc(t.provider.runtime?.discovered_model_count),()=>Xb(t.provider,r),()=>Yb(t.provider,r)]),L(`click`,te,()=>nS.toggleCard(t.provider)),z(e,i),D()}Hr([`click`]);var pC=R(`

                Providers Overview

                `),mC=R(`
                `);function hC(e,t){E(t,!0);let n=O(()=>nS.status.providers);var r=Qr(),i=N(r),a=e=>{var t=pC(),r=M(t),i=P(M(r),2),a=M(i),o=M(a,!0);T(a);var s=P(a,2);let c;T(i),T(r);var l=P(r,2);H(l,21,()=>I(n),e=>e.name,(e,t)=>{fC(e,{get provider(){return I(t)}})}),T(l),T(t),F((e,t)=>{W(i,`aria-checked`,nS.detailsExpanded),W(i,`title`,e),B(o,t),c=U(s,1,`provider-status-toggle-track svelte-1kx3uw4`,null,c,{"is-active":nS.detailsExpanded})},[()=>nS.detailsToggleLabel(),()=>nS.detailsToggleLabel()]),L(`click`,i,()=>nS.toggleDetails()),z(e,t)},o=e=>{var t=mC();SS(M(t),{size:18,label:`Loading provider status`}),T(t),z(e,t)};V(i,e=>{I(n).length>0?e(a):nS.loading&&!nS.loadedOnce&&e(o,1)}),z(e,r),D()}Hr([`click`]);var gC=R(`
                `);function _C(e,t){E(t,!0);function n(){Rc.fetchUsage(),Rc.fetchCacheOverview(``),rS.fetch(),nS.fetch(),iS.fetch(),aS.fetch()}function r(){Rc.fetchUsage(),Rc.fetchCacheOverview(``),rS.fetch()}function i(){r(),aS.fetch()}An(()=>{if(K.refreshTick,Jo.page===`overview`)return Er(()=>{n(),sb.start()}),()=>{sb.stop(),nS.stopPolling()}});var a=gC(),o=M(a);db(o,{});var s=P(o,4);tl(M(s),{onchange:i}),T(s);var c=P(s,2);Fc(c,{});var l=P(c,2);mS(l,{});var u=P(l,2);bS(u,{});var d=P(u,2);OS(d,{onintervalchange:r});var f=P(d,2);US(f,{});var p=P(f,2);ZS(p,{}),hC(P(p,2),{}),T(a),z(e,a),D()}var vC=`/admin/live/logs?types=audit,usage`;function yC(e,t,n){return!!t&&String(e&&e.id||``).trim()===t||!!n&&String(e&&e.request_id||``).trim()===n}function bC(e){switch(e){case`date_range`:return`Live paused — the selected date range does not include today. Set it to today to resume.`;case`filters`:return`Live paused while filters are active. Clear them to resume.`;case`pagination`:return`Live paused on later pages. Go to the first page to resume.`;default:return``}}function xC(e){let t=vC,n=Number(e||0);return Number.isFinite(n)&&n>0&&(t+=`&cursor=`+encodeURIComponent(String(n))),t}function SC(){return{async consumeLiveLogsBody(e){await Wy(e,e=>this.applyLiveLogEvent(e))},applyLiveLogEvent(e){if(!e||typeof e!=`object`)return;let t=Number(e.seq||0);Number.isFinite(t)&&t>this.liveLogsLastSeq&&(this.liveLogsLastSeq=t);let n=String(e.type||``).trim();if(n!==`heartbeat`){if(n===`reset`){this.reloadLiveLogSources();return}if(n===`audit.removed`){this.removeLiveAuditEntry(e.data);return}if(n.indexOf(`audit.`)===0){this.mergeLiveAuditEntry(e.data||{},n);return}n.indexOf(`usage.`)===0&&(this.mergeLiveUsageEntry(e.data||{},n),typeof this.noteLiveTokenUsage==`function`&&this.noteLiveTokenUsage(n))}},reloadLiveLogSources(){typeof this.fetchUsage==`function`&&this.fetchUsage(),this.page===`audit-logs`&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},auditLivePauseReason(){return!this.auditLog||this.auditLog.offset!==0?`pagination`:this.auditSearch||this.auditMethod||this.auditStatusCode||this.auditStream?`filters`:!this.followsToday&&(this.customStartDate||this.customEndDate)?`date_range`:null},auditLiveInsertAllowed(){return!this.auditLivePauseReason()},usageLiveInsertAllowed(){return this.usageLog&&this.usageLog.offset===0&&!this.usageLogSearch&&!this.usageFilterModel&&!this.usageFilterProvider&&!this.usageFilterLabel&&!this.usageFilterUserPath},mergeLiveAuditEntry(e,t){if(!e||typeof e!=`object`)return;let n=String(e.id||e.request_id||``).trim();if(!n)return;let r=String(e.request_id||``).trim(),i=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],a=i.findIndex(e=>yC(e,n,r)),o=a>=0&&i[a]||{},s=t===`audit.detail`,c=s?{...e,_detail_loaded:!0,_response_partial:!1,bodies_omitted:!1}:this.liveAuditPatch(o,e,t);if(a>=0){let e=this.mergeLiveAuditPatch(o,c);return i.splice(a,1,e),this.auditLog.entries=[...i],this.regroupLiveAuditHead(e),s||this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}let l=this.mergeLiveAuditChild(e,c);if(l)return s||this.fetchExpandedAuditDetailIfReady(l),this.cacheMergedAuditRecord(l,t),l;if(!this.auditLiveInsertAllowed()){this.cacheMergedAuditRecord(c,t);return}if(!s&&this.auditGroupSessions){let e=this.foldLiveAuditIntoThread(c);if(e)return this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}this.auditLog.entries=[this.mergeLiveAuditUsagePatch(c),...i].slice(0,this.auditLog.limit||25),this.auditLog.total=Number(this.auditLog.total||0)+1;let u=this.auditLog.entries[0];return s||this.fetchExpandedAuditDetailIfReady(u),this.cacheMergedAuditRecord(u,t),u},liveAuditPatch(e,t,n){let r=this.liveAuditStateAfter(e._live_state,n),i=this.liveAuditEventFlushed(e._live_state)||this.liveAuditEventFlushed(r),a={...t,_live:!0,_live_state:r,_audit_flushed:i,_live_pending:!i};return n===`audit.stream`?a._response_partial=!0:this.liveAuditStateSettled(n)&&(a._response_partial=!1),a},mergeLiveAuditChild(e,t){let n=this.auditThreadChildren;if(!n||typeof n!=`object`)return null;let r=String(e.id||``).trim(),i=String(e.request_id||``).trim(),a=Object.keys(n);for(let e=0;eyC(e,r,i));if(c<0)continue;let l=this.mergeLiveAuditPatch(s[c]||{},t),u=[...s];return u.splice(c,1,l),this.auditThreadChildren={...n,[a[e]]:{...o,entries:u}},l}return null},regroupLiveAuditHead(e){if(!this.auditGroupSessions)return null;let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=String(e.id||``).trim(),i=n.findIndex(e=>String(e.id||``).trim()===r);if(i<0)return null;let a=n.findIndex((e,n)=>n!==i&&String(e.session_id||``).trim()===t);if(a<0)return null;let o=n[a],s=Date.parse(o&&o.timestamp),c=Date.parse(e&&e.timestamp),l=Number.isFinite(s)&&Number.isFinite(c)&&s>c,u=l?o:e,d=l?e:o,f={...u,session_count:Math.max(1,Number(o.session_count||1))+Math.max(1,Number(e.session_count||1))},p=n.filter((e,t)=>t!==i&&t!==a);return p.unshift(f),this.auditLog.entries=p,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-1),this.prependLiveAuditThreadChild(t,d),f},foldLiveAuditIntoThread(e){let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(e=>String(e.session_id||``).trim()===t);if(r<0)return null;let i=n[r],a=Number(i.session_count),o=this.mergeLiveAuditUsagePatch({...e,session_count:(Number.isFinite(a)&&a>0?a:1)+1}),s=[...n];return s.splice(r,1),s.unshift(o),this.auditLog.entries=s,this.prependLiveAuditThreadChild(t,i),o},prependLiveAuditThreadChild(e,t){let n=this.auditThreadChildren||{},r=n[e],i={...t};delete i.session_count;let a=r&&Array.isArray(r.entries)?{...r,entries:[i,...r.entries],total:Number(r.total||r.entries.length)+1}:{loading:!1,loaded:!1,entries:[i],total:1};this.auditThreadChildren={...n,[e]:a}},removeLiveAuditThreadChild(e,t){let n=this.auditThreadChildren;!n||typeof n!=`object`||Object.keys(n).forEach(r=>{let i=n[r],a=i&&Array.isArray(i.entries)?i.entries:[],o=a.filter(n=>!yC(n,e,t)),s=a.length-o.length;s!==0&&(this.auditThreadChildren={...this.auditThreadChildren,[r]:{...i,entries:o,total:Math.max(0,Number(i.total||a.length)-s)}},this.decrementLiveAuditThreadCount(r,s))})},decrementLiveAuditThreadCount(e,t){let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(t=>String(t.session_id||``).trim()===e);if(r<0)return;let i=n[r],a=[...n];a.splice(r,1,{...i,session_count:Math.max(1,Number(i.session_count||1)-t)}),this.auditLog.entries=a},mergeLiveAuditPatch(e,t){let n={...e,...t};return t.data===void 0&&e.data!==void 0?n.data=e.data:e.data&&t.data&&typeof e.data==`object`&&typeof t.data==`object`&&!Array.isArray(e.data)&&!Array.isArray(t.data)&&(n.data={...e.data,...t.data}),this.mergeLiveAuditUsagePatch(n)},mergeLiveAuditUsagePatch(e){let t=this.liveUsageEntryForAudit(e);if(!t)return e;let n=this.auditEntryWithLiveUsage(e,t);return this.removeSkippedLiveUsage(t),n},liveUsageEntryForAudit(e){let t=String(e&&e.request_id||``).trim();return t&&((this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[]).find(e=>String(e&&e.request_id||``).trim()===t)||this.skippedLiveUsageByRequestId&&this.skippedLiveUsageByRequestId[t])||null},cacheMergedAuditRecord(e,t){return e&&typeof this.cacheAuditRecord==`function`?this.cacheAuditRecord(e,t):e},fetchExpandedAuditDetailIfReady(e){!e||!this.isAuditEntryExpanded||!this.isAuditEntryExpanded(e)||String(e._live_state||``).trim()!==`audit.flushed`&&!e._audit_flushed||typeof this.fetchAuditEntryDetail==`function`&&this.fetchAuditEntryDetail(e)},liveAuditStateRank(e){switch(String(e||``).trim()){case`audit.started`:return 10;case`audit.updated`:case`audit.stream`:return 20;case`audit.completed`:return 30;case`audit.failed`:case`audit.flushed`:case`audit.detail`:return 40;default:return 0}},liveAuditStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveAuditStateRank(n)>this.liveAuditStateRank(r)?n:r},liveAuditStateSettled(e){return this.liveAuditStateRank(e)>=this.liveAuditStateRank(`audit.completed`)},liveAuditEventFlushed(e){let t=String(e||``).trim();return t===`audit.failed`||t===`audit.flushed`||t===`audit.detail`},removeLiveAuditEntry(e){if(!e||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim();if(!t&&!n)return;let r=this.auditLog.entries,i=[],a=0,o=0,s=!1;r.forEach(e=>{if(!yC(e,t,n)){i.push(e);return}a++;let r=String(e.session_id||``).trim(),c=Math.max(1,Number(e.session_count||1));if(!this.auditGroupSessions||!r||c<=1)return;o++;let l=this.auditThreadChildren&&this.auditThreadChildren[r],u=l&&Array.isArray(l.entries)?l.entries.filter(e=>!yC(e,t,n)):[];if(u.length===0){s=!0;return}let d={...u[0],session_id:r,session_count:c-1};i.push(d),this.auditThreadChildren={...this.auditThreadChildren,[r]:{...l,entries:u.slice(1),total:Math.max(0,Number(l.total||c)-1)}}}),a>0&&(this.auditLog.entries=i,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-a+o)),this.removeLiveAuditThreadChild(t,n),s&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},mergeLiveUsageEntry(e,t){if(!e||typeof e!=`object`)return;e={...e,_live_state:t||e._live_state||`usage.completed`};let n=String(e.id||``).trim();if(!n)return;let r=this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[],i=r.findIndex(e=>String(e.id||``).trim()===n);if(i>=0){let t=r[i]||{},n=this.mergeLiveUsagePatch(t,e);if(this.applyLiveUsageToAudit(n),this.liveUsageShouldSkip(n)){r.splice(i,1),this.usageLog.entries=[...r],this.usageLog.total=Math.max(0,Number(this.usageLog.total||0)-1),this.storeSkippedLiveUsage(n);return}r.splice(i,1,n),this.usageLog.entries=[...r],this.removeSkippedLiveUsage(n);return}let a=this.mergeLiveUsagePatch(this.liveUsageSeedForEntry(e),e);if(this.applyLiveUsageToAudit(a),this.liveUsageShouldSkip(a)){this.storeSkippedLiveUsage(a);return}this.removeSkippedLiveUsage(a),this.usageLog.entries=[a,...r].slice(0,this.usageLog.limit||50),this.usageLog.total=Number(this.usageLog.total||0)+1},mergeLiveUsagePatch(e,t){e=e&&typeof e==`object`?e:{};let n=this.liveUsageStateAfter(e._live_state,t&&t._live_state),r=this.liveUsageEventFlushed(e)||this.liveUsageEventFlushed({...t,_live_state:n});return{...e,...t,_live:!0,_live_state:n||`usage.completed`,_live_pending:!r,_usage_flushed:r}},liveUsageShouldSkip(e){return!!(this.usageLogHideCached&&this.liveUsageEntryCached(e))||!this.usageLiveInsertAllowed()},liveUsageSeedForEntry(e){return this.skippedLiveUsageForEntry(e)||this.auditLiveUsageForEntry(e)},skippedLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();return t&&this.skippedLiveUsageByRequestId?this.skippedLiveUsageByRequestId[t]:null},auditLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return null;let n=this.auditLog.entries.find(e=>String(e&&e.request_id||``).trim()===t),r=n&&n.usage&&typeof n.usage==`object`&&!Array.isArray(n.usage)?n.usage:null;return r?{id:e&&e.id,request_id:t,entries:r.entries,input_tokens:r.input_tokens,uncached_input_tokens:r.uncached_input_tokens,cached_input_tokens:r.cached_input_tokens,cache_write_input_tokens:r.cache_write_input_tokens,output_tokens:r.output_tokens,total_tokens:r.total_tokens,cached_input_ratio:r.cached_input_ratio,estimated_cached_characters:r.estimated_cached_characters,_live_state:n._usage_live_state,_live_pending:n._usage_live_pending,_usage_flushed:n._usage_flushed}:null},storeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&((!this.skippedLiveUsageByRequestId||typeof this.skippedLiveUsageByRequestId!=`object`||Array.isArray(this.skippedLiveUsageByRequestId))&&(this.skippedLiveUsageByRequestId={}),this.skippedLiveUsageByRequestId[t]=e)},removeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&this.skippedLiveUsageByRequestId&&delete this.skippedLiveUsageByRequestId[t]},liveUsageEntryCached(e){let t=String(e&&e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`||!!(e&&e.cache_hit)},liveUsageEventFlushed(e){let t=String(e&&e._live_state||``).trim();return!!(e&&e._usage_flushed)||t===`usage.failed`||t===`usage.flushed`},liveUsageStateRank(e){switch(String(e||``).trim()){case`usage.completed`:return 10;case`usage.failed`:case`usage.flushed`:return 20;default:return 0}},liveUsageStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveUsageStateRank(n)>this.liveUsageStateRank(r)?n:r},applyLiveUsageToAudit(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let n=this.auditLog.entries.findIndex(e=>String(e.request_id||``).trim()===t);if(n>=0){let t=this.auditLog.entries[n];this.auditLog.entries.splice(n,1,this.auditEntryWithLiveUsage(t,e)),this.auditLog.entries=[...this.auditLog.entries]}let r=this.auditThreadChildren;if(!r||typeof r!=`object`)return;let i=r,a=!1;Object.keys(r).forEach(n=>{let r=i[n],o=r&&Array.isArray(r.entries)?r.entries:[],s=o.findIndex(e=>String(e.request_id||``).trim()===t);if(s<0)return;let c=[...o];c.splice(s,1,this.auditEntryWithLiveUsage(o[s],e)),i={...i,[n]:{...r,entries:c}},a=!0}),a&&(this.auditThreadChildren=i)},auditEntryWithLiveUsage(e,t){let n=this.liveUsageStateAfter(e._usage_live_state,t._live_state||`usage.completed`),r=this.liveUsageEventFlushed({_live_state:n,_usage_flushed:e._usage_flushed||t._usage_flushed});return{...e,usage:this.liveUsageSummary(t,e.usage),_usage_live_state:n||`usage.completed`,_usage_live_pending:!r,_usage_flushed:r}},liveUsageSummary(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=this.liveNumber(e.input_tokens,this.liveNumber(n.input_tokens,0)),i=this.liveNumber(e.output_tokens,this.liveNumber(n.output_tokens,0)),a=this.liveNumber(e.uncached_input_tokens,this.liveNumber(n.uncached_input_tokens,0)),o=this.liveNumber(e.cached_input_tokens,this.liveNumber(n.cached_input_tokens,0)),s=this.liveNumber(e.cache_write_input_tokens,this.liveNumber(n.cache_write_input_tokens,0));r>0&&a+o+s===0&&(a=r);let c=a+o+s||r,l=c+i||this.liveNumber(e.total_tokens,this.liveNumber(n.total_tokens,0)),u=this.liveNumber(e.cached_input_ratio,this.liveNumber(n.cached_input_ratio,c>0?o/c:0));return{entries:Math.max(1,this.liveNumber(e.entries,this.liveNumber(n.entries,1))),input_tokens:c,uncached_input_tokens:a,cached_input_tokens:o,cache_write_input_tokens:s,output_tokens:i,total_tokens:l,cached_input_ratio:u,estimated_cached_characters:this.liveNumber(e.estimated_cached_characters,this.liveNumber(n.estimated_cached_characters,o*4))}},liveNumber(e,t){let n=Number(e);return Number.isFinite(n)?n:t},auditEntryShouldFetchDetail(e){return!e||e._detail_loading||e._detail_loaded||this.auditEntryLiveDetailPending(e)?!1:this.auditEntryNeedsPersistedLiveDetail(e)||e.bodies_omitted?!0:!this.auditEntryHasDetailData(e)},auditEntryLiveDetailPending(e){if(!e||!e._live)return!1;let t=String(e._live_state||``).trim();return t===`audit.failed`||!e._audit_flushed&&t!==`audit.flushed`&&t!==`audit.detail`},auditEntryNeedsPersistedLiveDetail(e){return!!(e&&e._live&&!e._detail_loaded)},auditEntryHasDetailData(e){let t=e&&e.data;return!t||typeof t!=`object`?!1:t.request_headers!==void 0||t.response_headers!==void 0||t.request_body!==void 0||t.response_body!==void 0||t.request_body_too_big_to_handle!==void 0||t.response_body_too_big_to_handle!==void 0||t.user_agent!==void 0||t.api_key_hash!==void 0||t.temperature!==void 0||t.max_tokens!==void 0||t.error_message!==void 0||t.error_code!==void 0},clearAuditDetailLoading(e){if(!e)return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim(),r=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],i=r.find(e=>t&&String(e.id||``).trim()===t?!0:!!(n&&String(e.request_id||``).trim()===n)),a=i||e;a._detail_loading=!1,i&&(this.auditLog.entries=[...r])}}}var CC={"audit.started":10,"audit.updated":20,"audit.stream":20,"audit.completed":30,"audit.failed":40,"audit.flushed":40,"audit.detail":40},wC=new Set(Object.keys(CC));function TC(e){return String(e&&(e.id||e.request_id)||``).trim()}function EC(e,t){let n=e&&typeof e==`object`?e:{},r=t&&typeof t==`object`?t:{},i={...n,...r};r.data==null&&n.data!=null?i.data=n.data:kC(n.data)&&kC(r.data)&&(i.data={...n.data,...r.data});let a=String(n._live_state||``).trim(),o=String(r._live_state||``).trim();return(CC[a]||0)>(CC[o]||0)&&(i._live_state=a),n._audit_flushed&&(i._audit_flushed=!0),i._audit_flushed&&(i._live_pending=!1),n._detail_loaded&&!r._detail_loaded&&(i._detail_loaded=!0,i.bodies_omitted=!1),i.bodies_omitted&&kC(i.data)&&(i.data.request_body!==void 0||i.data.response_body!==void 0)&&(i.bodies_omitted=!1),i}function DC(e,t){let n=Number(t||0);return(Array.isArray(e)?e:[]).filter(e=>Number(e&&e.version||0)>n)}function OC(e){return wC.has(String(e&&e.eventType||``).trim())}function kC(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var AC=200,jC=class{#e=k(j({entries:[],total:0,limit:25,offset:0}));get auditLog(){return I(this.#e)}set auditLog(e){A(this.#e,e,!0)}#t=k(j({entries:[],total:0,limit:50,offset:0}));get usageLog(){return I(this.#t)}set usageLog(e){A(this.#t,e,!0)}#n=k(j({}));get auditRecords(){return I(this.#n)}set auditRecords(e){A(this.#n,e,!0)}#r=k(j([]));get auditRecordChanges(){return I(this.#r)}set auditRecordChanges(e){A(this.#r,e,!0)}auditRecordVersion=0;auditRecordPins=new Set;#i=k(``);get auditSearch(){return I(this.#i)}set auditSearch(e){A(this.#i,e,!0)}#a=k(``);get auditMethod(){return I(this.#a)}set auditMethod(e){A(this.#a,e,!0)}#o=k(``);get auditStatusCode(){return I(this.#o)}set auditStatusCode(e){A(this.#o,e,!0)}#s=k(``);get auditStream(){return I(this.#s)}set auditStream(e){A(this.#s,e,!0)}#c=k(Ta(`gomodel_audit_group_sessions`,`true`)!==`false`);get auditGroupSessions(){return I(this.#c)}set auditGroupSessions(e){A(this.#c,e,!0)}#l=k(j({}));get auditThreadChildren(){return I(this.#l)}set auditThreadChildren(e){A(this.#l,e,!0)}#u=k(``);get usageLogSearch(){return I(this.#u)}set usageLogSearch(e){A(this.#u,e,!0)}#d=k(``);get usageFilterModel(){return I(this.#d)}set usageFilterModel(e){A(this.#d,e,!0)}#f=k(``);get usageFilterProvider(){return I(this.#f)}set usageFilterProvider(e){A(this.#f,e,!0)}#p=k(``);get usageFilterLabel(){return I(this.#p)}set usageFilterLabel(e){A(this.#p,e,!0)}#m=k(``);get usageFilterUserPath(){return I(this.#m)}set usageFilterUserPath(e){A(this.#m,e,!0)}#h=k(!1);get usageLogHideCached(){return I(this.#h)}set usageLogHideCached(e){A(this.#h,e,!0)}#g=k(!1);get liveLogsStreaming(){return I(this.#g)}set liveLogsStreaming(e){A(this.#g,e,!0)}liveLogsLastSeq=0;liveLogsReconnectAttempts=0;liveLogsReconnectTimer=null;liveLogsController=null;skippedLiveUsageByRequestId=null;fetchUsage=null;fetchAuditLog=null;isAuditEntryExpanded=null;noteLiveTokenUsage=null;upsertAuditRecord(e,t=``){let n=TC(e);if(!n)return e;let r=EC(this.auditRecords[n],e);return this.auditRecords={...this.auditRecords,[n]:r},this.pruneAuditRecords(),this.auditRecordVersion++,this.auditRecordChanges=[...this.auditRecordChanges,{version:this.auditRecordVersion,key:n,eventType:t}].slice(-512),r}upsertAuditRecords(e,t=``){return(Array.isArray(e)?e:[]).map(e=>this.upsertAuditRecord(e,t))}auditRecord(e){let t=typeof e==`string`?String(e).trim():TC(e);return t&&this.auditRecords[t]||null}cacheAuditRecord(e,t){return this.upsertAuditRecord(e,t)}pinAuditRecords(e){this.auditRecordPins=new Set((Array.isArray(e)?e:[]).map(String))}pruneAuditRecords(){let e=Object.keys(this.auditRecords);if(e.length<=AC)return;let t={...this.auditRecords},n=e.length-AC;for(let r of e){if(n<=0)break;this.auditRecordPins.has(r)||(delete t[r],n--)}this.auditRecords=t}get page(){return Jo.page}get customStartDate(){return Mc.customStartDate}get customEndDate(){return Mc.customEndDate}get followsToday(){return Mc.followsToday}liveLogsEnabled(){return Ss.liveLogsVisible()}async startLiveLogs(){typeof fetch!=`function`||typeof ReadableStream>`u`||(await Ss.ensureLoaded(),this.liveLogsEnabled()&&(this.stopLiveLogs(),this.liveLogsController=typeof AbortController==`function`?new AbortController:null,this.readLiveLogsStream(this.liveLogsController)))}stopLiveLogs(){this.liveLogsStreaming=!1,this.liveLogsReconnectTimer&&=(clearTimeout(this.liveLogsReconnectTimer),null),this.liveLogsController&&typeof this.liveLogsController.abort==`function`&&this.liveLogsController.abort(),this.liveLogsController=null}ensureLiveLogs(){this.liveLogsController||this.liveLogsReconnectTimer||this.startLiveLogs()}async readLiveLogsStream(e){let t={};e&&(t.signal=e.signal);let n=xC(this.liveLogsLastSeq),r=K.generation;try{let i=await hs(n,t);if(i.status===401){if(K.handleUnauthorized(r),r{this.liveLogsReconnectTimer=null,this.startLiveLogs()},t)}async fetchAuditEntryDetail(e){if(!this.auditEntryShouldFetchDetail(e))return;let t=String(e.id||``).trim();if(!t)return;e._detail_loading=!0;let n=e;try{let e=await _s(`/admin/audit/detail?log_id=`+encodeURIComponent(t),{label:`audit detail`});if(e.stale||!e.ok)return;n=this.mergeLiveAuditEntry(e.data,`audit.detail`)||n}catch(e){console.error(`Failed to fetch audit detail:`,e)}finally{this.clearAuditDetailLoading(n)}}};Object.assign(jC.prototype,SC());var MC=new jC;if(typeof window<`u`){let e=!1;window.addEventListener(`pagehide`,()=>{e=!!MC.liveLogsController,MC.stopLiveLogs()}),window.addEventListener(`pageshow`,t=>{t.persisted&&e&&MC.ensureLiveLogs()})}var NC=null;Mn(()=>{An(()=>{let e=K.refreshTick;if(NC===null){NC=e;return}e!==NC&&(NC=e,Er(()=>{MC.stopLiveLogs(),MC.startLiveLogs()}))})});function PC(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,uncached_input_tokens:0,cached_input_tokens:0,cache_write_input_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null,rewrite_tokens_saved:0,rewrite_cost_saved:null}}function FC(){return{entries:[],total:0,limit:50,offset:0}}function IC(e,t){let n=[[`model`,e&&e.model],[`provider`,e&&e.provider],[`label`,e&&e.label],[`user_path`,e&&e.user_path]],r=``;for(let[e,i]of n)!i||e===t||(r+=`&`+e+`=`+encodeURIComponent(i));return r}function LC({limit:e,offset:t,hideCached:n,search:r}){let i=`&limit=`+e+`&offset=`+t;return i+=`&cache_mode=`+(n?`uncached`:`all`),r&&(i+=`&search=`+encodeURIComponent(r)),i}function RC(e,t){let n=new Set(e||[]);return t&&n.add(t),[...n].sort()}function zC(e,t){let n=Number(t&&t.total_requests||0)-Number(e&&e.total_requests||0);return Number.isFinite(n)&&n>0?n:0}function BC(e,t,n){let r=n?e:t,i=Number(r&&r.total_requests||0);return Number.isFinite(i)?i:0}function VC(e,t,n){let r=zC(e,t);return r<=0?``:n?oc(r)+` cached requests hidden`:oc(Number(e&&e.total_requests||0))+` to providers + `+oc(r)+` from cache`}function HC(e){let t=e||{};return t.total_input_cost===null||t.total_input_cost===void 0?``:sc(t.total_input_cost)+` input + `+sc(t.total_output_cost)+` output`}function UC(e){let t=Number(e&&e.rewrite_tokens_saved||0);return Number.isFinite(t)&&t>0?t:0}function WC(e){return UC(e)>0}function GC(e){let t=e||{};return t.rewrite_cost_saved===void 0?null:t.rewrite_cost_saved}function KC(){return`Estimated at 4 net characters removed per token`}function qC(e,t){return t===`costs`?sc(GC(e)):uc(UC(e))}function JC(e,t){let n=t===`costs`,r=n?Number(GC(e)):UC(e);if(!Number.isFinite(r)||r<=0)return null;let i=e&&(n?e.total_cost:e.total_input_tokens);if(i==null)return null;let a=Number(i);return!Number.isFinite(a)||a<0?null:r/(a+r)*100}function YC(e,t){let n=JC(e,t);return n===null?``:(n<.1?`<0.1`:n.toFixed(1))+`% less`}function XC(e,t){let n=UC(e);if(n<=0)return``;let r=[oc(n)+` estimated prompt token-transmissions removed across provider requests`,KC(),`Savings are summed per provider request; resent conversation history is counted again`],i=GC(e);i!=null&&(r.push(sc(i)+` estimated gross input cost avoided`),r.push(`Prompt-cache changes caused by rewriting are not included`));let a=YC(e,t);return a&&r.push(a+` than the same traffic without rewriting (`+(t===`costs`?`cost`:`tokens`)+`)`),r.join(` +`)}function ZC(e){return String(e&&e.cost_source||``).trim()}function QC(e){let t=ZC(e);return t===`openrouter_credits`||t===`xai_cost_in_usd_ticks`}function $C(e){switch(ZC(e)){case`openrouter_credits`:return`Costs from OpenRouter USD-based credits.`;case`xai_cost_in_usd_ticks`:return`Costs from xAI usage.cost_in_usd_ticks.`;default:return``}}function ew(e){return String(e&&e.cache_type||``).trim().toLowerCase()}function tw(e){let t=ew(e);return t===`exact`||t===`semantic`}function nw(e){let t=ew(e);return t===`exact`?`Exact`:t===`semantic`?`Semantic`:`-`}function rw(e,t){let n=t?String(t):``;return tw(e)?n?`Saved by cache — not charged +`+n:`Saved by cache — not charged`:n}function iw(e){let t=Number(e&&e.cached_input_ratio);return!Number.isFinite(t)||t<=0?0:Math.min(1,t)}function aw(e){return Number(e&&e.cached_input_tokens||0)>0}function ow(e){return aw(e)?(iw(e)*100).toFixed(1)+`%`:``}function sw(e){if(!aw(e))return``;let t=Number(e.cached_input_tokens||0),n=Number(e.uncached_input_tokens||0),r=Number(e.cache_write_input_tokens||0),i=t+n+r,a=[oc(t)+` cached / `+oc(i)+` input tokens`];return r>0&&a.push(oc(r)+` cache write`),a.join(` +`)}function cw(e){let t=[];if($C(e)&&(t.push($C(e)),t.push(``)),t.push(`Input: `+sc(e.input_cost)),t.push(`Output: `+sc(e.output_cost)),e.raw_data){t.push(``);for(let[n,r]of Object.entries(e.raw_data)){let e=n.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),i=r&&typeof r==`object`?JSON.stringify(r):oc(r);t.push(e+`: `+i)}}return t.join(` +`)}function lw(e){return Array.isArray(e&&e.labels)?e.labels:[]}function uw(e,t,n){return(e||[]).length>0||t?!0:(n||[]).some(e=>lw(e).length>0)}function dw(e){return e&&typeof e.total_tokens==`number`?e.total_tokens:(e&&e.input_tokens||0)+(e&&e.output_tokens||0)}function fw(e,t){return t?e.total_cost||0:dw(e)}function pw(e,t){return[...e||[]].sort((e,n)=>t?(n.total_cost||0)-(e.total_cost||0):fw(n,t)-fw(e,t))}function mw(e){let t=Array.isArray(e)?e:[];if(t.length===0)return!1;if(t.length!==1)return!0;let n=String(t[0]&&t[0].user_path||``).trim();return n!==``&&n!==`/`}function hw(e){return(e||`chart`)===`chart`||e===`stacked`}function gw(e,t,n){let r=pw(e,n),i=e=>Number(e)||0,a=e=>n?Math.min(i(e.cached_input_cost),i(e.input_cost)):i(e.cached_input_tokens),o=e=>n?i(e.input_cost)-a(e):i(e.uncached_input_tokens)+i(e.cached_input_tokens)+i(e.cache_write_input_tokens)>0?i(e.uncached_input_tokens)+i(e.cache_write_input_tokens):i(e.input_tokens),s=e=>i(n?e.output_cost:e.output_tokens),c=e=>n?0:i(e.local_cached_input_tokens),l=e=>n?0:i(e.local_cached_output_tokens),u=r.slice(0,10),d=r.slice(10),f=u.map(t),p=u.map(o),m=u.map(s),h=u.map(a),g=u.map(c),_=u.map(l);if(d.length>0){f.push(`Other`);let e=e=>d.reduce((t,n)=>t+e(n),0);p.push(e(o)),m.push(e(s)),h.push(e(a)),g.push(e(c)),_.push(e(l))}return{labels:f,inputs:p,outputs:m,prompts:h,localIns:g,localOuts:_}}function _w(e){return Math.max(200,e*32+72)}var J=new class{#e=k(`tokens`);get usageMode(){return I(this.#e)}set usageMode(e){A(this.#e,e,!0)}get usageFilterModel(){return MC.usageFilterModel}set usageFilterModel(e){MC.usageFilterModel=e}get usageFilterProvider(){return MC.usageFilterProvider}set usageFilterProvider(e){MC.usageFilterProvider=e}get usageFilterLabel(){return MC.usageFilterLabel}set usageFilterLabel(e){MC.usageFilterLabel=e}get usageFilterUserPath(){return MC.usageFilterUserPath}set usageFilterUserPath(e){MC.usageFilterUserPath=e}#t=k(j({models:[],providers:[],labels:[]}));get usageFacetOptions(){return I(this.#t)}set usageFacetOptions(e){A(this.#t,e,!0)}#n=k(j(PC()));get usageSummary(){return I(this.#n)}set usageSummary(e){A(this.#n,e,!0)}#r=k(j(PC()));get usageSummaryAll(){return I(this.#r)}set usageSummaryAll(e){A(this.#r,e,!0)}#i=k(j([]));get modelUsage(){return I(this.#i)}set modelUsage(e){A(this.#i,e,!0)}#a=k(j([]));get userPathUsage(){return I(this.#a)}set userPathUsage(e){A(this.#a,e,!0)}#o=k(j([]));get labelUsage(){return I(this.#o)}set labelUsage(e){A(this.#o,e,!0)}get usageLog(){return MC.usageLog}set usageLog(e){MC.usageLog=e}get usageLogSearch(){return MC.usageLogSearch}set usageLogSearch(e){MC.usageLogSearch=e}get usageLogHideCached(){return MC.usageLogHideCached}set usageLogHideCached(e){MC.usageLogHideCached=e}#s=k(`chart`);get modelUsageView(){return I(this.#s)}set modelUsageView(e){A(this.#s,e,!0)}#c=k(`chart`);get userPathUsageView(){return I(this.#c)}set userPathUsageView(e){A(this.#c,e,!0)}#l=k(`chart`);get labelUsageView(){return I(this.#l)}set labelUsageView(e){A(this.#l,e,!0)}#u=k(!1);get summaryLoading(){return I(this.#u)}set summaryLoading(e){A(this.#u,e,!0)}#d=k(!1);get modelUsageLoading(){return I(this.#d)}set modelUsageLoading(e){A(this.#d,e,!0)}#f=k(!1);get userPathUsageLoading(){return I(this.#f)}set userPathUsageLoading(e){A(this.#f,e,!0)}#p=k(!1);get labelUsageLoading(){return I(this.#p)}set labelUsageLoading(e){A(this.#p,e,!0)}#m=k(!1);get usageLogLoading(){return I(this.#m)}set usageLogLoading(e){A(this.#m,e,!0)}#h={};#g(e){this.#h[e]&&this.#h[e].abort();let t=new AbortController;return this.#h[e]=t,t}#_(e,t){this.#h[e]===t&&(this.#h[e]=null)}filterQueryStr(e){return IC({model:this.usageFilterModel,provider:this.usageFilterProvider,label:this.usageFilterLabel,user_path:this.usageFilterUserPath},e)}onUsageFilterChanged(){this.fetchUsagePage()}toggleUsageLabelFilter(e){this.usageFilterLabel=this.usageFilterLabel===e?``:e,this.onUsageFilterChanged()}usageLabelChipTitle(e){return this.usageFilterLabel===e?`Clear label filter`:`Filter usage by "`+e+`"`}toggleUsageMode(e){this.usageMode=e,Jo.navigate(`usage`,e===`costs`?`costs`:null)}toggleUsageChartView(e,t){e===`model`&&(this.modelUsageView=t),e===`userPath`&&(this.userPathUsageView=t),e===`label`&&(this.labelUsageView=t)}usageFilterModelOptions(){return RC(this.usageFacetOptions.models,this.usageFilterModel)}usageFilterProviderOptions(){return RC(this.usageFacetOptions.providers,this.usageFilterProvider)}usageFilterLabelOptions(){return RC(this.usageFacetOptions.labels,this.usageFilterLabel)}async fetchUsagePage(){await Ss.ensureLoaded();let e=[this.fetchUsagePageSummary(),this.fetchUsageFacetOptions(),this.fetchModelUsage(),this.fetchUserPathUsage(),this.fetchLabelUsage(),this.fetchUsageLog(!0)];Rc.cacheAnalyticsEnabled()&&e.push(Rc.fetchCacheOverview(this.filterQueryStr())),await Promise.all(e)}async fetchUsagePageSummary(){let e=this.#g(`summary`);this.summaryLoading=!0;try{let t=Mc.queryStr()+this.filterQueryStr(),[n,r]=await Promise.all([_s(`/admin/usage/summary?`+t+`&cache_mode=uncached`,{label:`usage page summary`,signal:e.signal}),_s(`/admin/usage/summary?`+t+`&cache_mode=all`,{label:`usage page summary (all)`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.usageSummary=PC(),this.usageSummaryAll=PC();return}this.usageSummary=n.data&&typeof n.data==`object`?n.data:PC(),this.usageSummaryAll=r.data&&typeof r.data==`object`?r.data:PC()}catch(e){if(ys(e))return;console.error(`Failed to fetch usage page summary:`,e),this.usageSummary=PC(),this.usageSummaryAll=PC()}finally{this.#_(`summary`,e),this.#h.summary===null&&(this.summaryLoading=!1)}}async fetchUsageFacetOptions(){let e=this.#g(`facets`);try{let t=async(t,n)=>{let r=await _s(t+`?`+Mc.queryStr()+this.filterQueryStr(n),{label:`usage facet options`,signal:e.signal});return r.stale?null:r.ok&&Array.isArray(r.data)?r.data:[]},n=t(`/admin/usage/models`,`model`),r=!this.usageFilterModel&&!this.usageFilterProvider,[i,a,o]=await Promise.all([n,r?n:t(`/admin/usage/models`,`provider`),t(`/admin/usage/labels`,`label`)]);if(e.signal.aborted||i===null||a===null||o===null)return;this.usageFacetOptions={models:i.map(e=>e&&e.model).filter(Boolean),providers:a.map(e=>gc(e)).filter(Boolean),labels:o.map(e=>e&&e.label).filter(Boolean)}}catch(e){if(ys(e))return;console.error(`Failed to fetch usage facet options:`,e),this.usageFacetOptions={models:[],providers:[],labels:[]}}finally{this.#_(`facets`,e)}}async#v(e,t,n,r,i){let a=this.#g(e);i(!0);try{let e=await _s(t+`?`+Mc.queryStr()+this.filterQueryStr(),{label:n,signal:a.signal});if(e.stale||a.signal.aborted)return;if(!e.ok){r([]);return}r(Array.isArray(e.data)?e.data:[])}catch(e){if(ys(e))return;console.error(`Failed to fetch `+n+`:`,e),r([])}finally{this.#_(e,a),this.#h[e]===null&&i(!1)}}fetchModelUsage(){return this.#v(`modelUsage`,`/admin/usage/models`,`usage models`,e=>this.modelUsage=e,e=>this.modelUsageLoading=e)}fetchUserPathUsage(){return this.#v(`userPathUsage`,`/admin/usage/user-paths`,`usage user paths`,e=>this.userPathUsage=e,e=>this.userPathUsageLoading=e)}fetchLabelUsage(){return this.#v(`labelUsage`,`/admin/usage/labels`,`usage labels`,e=>this.labelUsage=e,e=>this.labelUsageLoading=e)}async fetchUsageLog(e){let t=this.#g(`usageLog`);this.usageLogLoading=!0;try{e&&(this.usageLog.offset=0);let n=Mc.queryStr()+this.filterQueryStr();n+=LC({limit:this.usageLog.limit,offset:this.usageLog.offset,hideCached:this.usageLogHideCached,search:this.usageLogSearch});let r=await _s(`/admin/usage/log?`+n,{label:`usage log`,signal:t.signal});if(r.stale||t.signal.aborted)return;if(!r.ok){this.usageLog=FC();return}let i=r.data&&typeof r.data==`object`?r.data:FC();i.entries||=[],this.usageLog=i}catch(e){if(ys(e))return;console.error(`Failed to fetch usage log:`,e),this.usageLog=FC()}finally{this.#_(`usageLog`,t),this.#h.usageLog===null&&(this.usageLogLoading=!1)}}usageLogNextPage(){this.usageLog.offset+this.usageLog.limit0&&(this.usageLog.offset=Math.max(0,this.usageLog.offset-this.usageLog.limit),this.fetchUsageLog(!1))}};MC.fetchUsage=()=>{Jo.page===`usage`&&J.fetchUsagePage()};var vw=R(`
                `);function yw(e,t){E(t,!0);let n=ya(t,`value`,15,``),r=ya(t,`placeholder`,3,``),i=ya(t,`label`,3,``),a=ya(t,`id`,3,void 0),o=ya(t,`oninput`,3,void 0),s=ya(t,`class`,3,``);var c=vw(),l=M(c);G(l,{get icon(){return vo},class:`filter-input-icon`});var u=P(l,2);na(u),T(c),F(()=>{U(c,1,Fi([`filter-input-wrap`,s()]),`svelte-30xz1k`),W(u,`id`,a()),W(u,`placeholder`,r()),W(u,`aria-label`,i())}),L(`input`,u,function(...e){o()?.apply(this,e)}),da(u,n),z(e,c),D()}Hr([`input`]);function bw(e,t=300){let n=null,r=(...r)=>{clearTimeout(n),n=setTimeout(()=>{n=null,e(...r)},t)};return r.cancel=()=>{clearTimeout(n),n=null},r}var xw=R(``),Sw=R(``),Cw=R(`
                `);function ww(e,t){E(t,!0);let n=bw(()=>J.onUsageFilterChanged());An(()=>n.cancel);var r=Cw(),i=M(r),a=M(i);a.value=a.__value=``,H(P(a),16,()=>J.usageFilterModelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(i);var o=P(i,2),s=M(o);s.value=s.__value=``,H(P(s),16,()=>J.usageFilterProviderOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(o);var c=P(o,2),l=e=>{var t=Sw(),n=M(t);n.value=n.__value=``,H(P(n),16,()=>J.usageFilterLabelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(t),L(`change`,t,()=>J.onUsageFilterChanged()),Gi(t,()=>J.usageFilterLabel,e=>J.usageFilterLabel=e),z(e,t)},u=O(()=>J.usageFilterLabelOptions().length>0);V(c,e=>{I(u)&&e(l)}),yw(P(c,2),{class:`usage-page-filters-user-path`,placeholder:`User path /team/alpha`,label:`Filter by user path`,get oninput(){return n},get value(){return J.usageFilterUserPath},set value(e){J.usageFilterUserPath=e}}),T(r),L(`change`,i,()=>J.onUsageFilterChanged()),Gi(i,()=>J.usageFilterModel,e=>J.usageFilterModel=e),L(`change`,o,()=>J.onUsageFilterChanged()),Gi(o,()=>J.usageFilterProvider,e=>J.usageFilterProvider=e),z(e,r),D()}Hr([`change`]);var Tw=R(`
                Cache Saved
                Cache Hits
                `,1);function Ew(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Tw(),n=N(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var a=P(n,2),o=P(M(a),2),s=M(o,!0);T(o),T(a),F((e,t)=>{B(i,e),B(s,t)},[()=>sc(Rc.cacheOverview.summary.total_saved_cost),()=>oc(Rc.cacheOverview.summary.total_hits)]),z(e,t)},a=O(()=>Rc.cacheAnalyticsEnabled());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}var Dw=R(` `),Ow=R(`
                Pro Saved
                `),kw=R(`
                Total Requests
                Estimated Cost
                `);function Aw(e,t){E(t,!0);let n=O(()=>WC(J.usageSummary)),r=O(()=>qC(J.usageSummary,J.usageMode)),i=O(()=>YC(J.usageSummary,J.usageMode));var a=kw(),o=M(a),s=P(M(o),2),c=M(s),l=e=>{SS(e,{size:18,label:`Loading usage summary`})},u=e=>{var t=Zr();F(e=>B(t,e),[()=>oc(BC(J.usageSummary,J.usageSummaryAll,J.usageLogHideCached))]),z(e,t)};V(c,e=>{J.summaryLoading?e(l):e(u,-1)}),T(s),T(o);var d=P(o,2),f=P(M(d),2),p=M(f),m=e=>{SS(e,{size:18,label:`Loading usage summary`})},h=e=>{var t=Zr();F(e=>B(t,e),[()=>sc(J.usageSummary.total_cost)]),z(e,t)};V(p,e=>{J.summaryLoading?e(m):e(h,-1)}),T(f),T(d);var g=P(d,2),_=e=>{var t=Ow(),n=P(M(t),2),a=M(n),o=M(a,!0);T(a);var s=P(a,2),c=e=>{var t=Dw(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)};V(s,e=>{I(i)&&e(c)}),T(n),T(t),F(e=>{W(n,`title`,e),B(o,I(r))},[()=>XC(J.usageSummary,J.usageMode)]),z(e,t)};V(g,e=>{I(n)&&e(_)}),Ew(P(g,2),{}),T(a),F((e,t)=>{W(s,`title`,e),W(f,`title`,t)},[()=>VC(J.usageSummary,J.usageSummaryAll,J.usageLogHideCached),()=>HC(J.usageSummary)]),z(e,a),D()}function jw(e,t,n,r){let{stacked:i=!1,costs:a=!1,resolve:o=e=>e}=r||{},s=e=>a?`$`+Math.abs(e).toFixed(2):uc(Math.abs(e)),c=e=>a?`$`+Math.abs(e).toFixed(4):Math.abs(e).toLocaleString(),l=e=>e.map(e=>i?Math.abs(e):-Math.abs(e)),u=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:`transparent`,borderWidth:0,borderRadius:4,maxBarThickness:22}),d=e=>(e||[]).some(e=>Math.abs(e)>0),f=[u(a?`Input Cost`:`Input Tokens`,l(n.inputs),o(`var(--token-input)`)),u(a?`Output Cost`:`Output Tokens`,n.outputs,o(`var(--token-output)`))];return d(n.prompts)&&f.push(u(a?`Prompt Cached Cost`:`Prompt Cached`,l(n.prompts),o(`var(--token-prompt)`))),!a&&d(n.localIns)&&f.push(u(`Locally Cached (Input)`,l(n.localIns),o(`var(--token-local)`))),!a&&d(n.localOuts)&&f.push(u(`Locally Cached (Output)`,n.localOuts,o(`var(--token-local)`))),{type:`bar`,data:{labels:t,datasets:f},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:{top:8}},scales:{x:{stacked:!0,beginAtZero:!0,grid:i?{color:e.grid}:{color:t=>t.tick&&t.tick.value===0?e.text:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),callback:e=>s(e)}},y:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Ly(),autoSkip:!1}}},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{label:e=>e.dataset.label+`: `+c(e.parsed.x),footer:e=>{let t=0;return e.forEach(e=>{t+=Math.abs(Number(e.parsed.x))||0}),`Total: `+c(t)}})}}}}var Mw=R(`
                `),Nw=R(`

                `),Pw=R(`

                `,1),Fw=R(`
                `),Iw=R(`Model Provider`,1),Lw=R(`User Path`),Rw=R(`Label Requests`,1),zw=R(` `,1),Bw=R(` `),Vw=R(` `,1),Hw=R(` `),Uw=R(`
                Input TokensOutput TokensPrompt CachedLocal CachedTotal TokensInput CostOutput CostTotal Cost
                `),Ww=R(`
                `),Gw=R(`
                `);function Kw(e,t){E(t,!0);let n=e=>{var n=Mw(),r=M(n);let a;var o=P(r,2);let s;var l=P(o,2);let u;T(n),F(()=>{W(n,`aria-label`,I(i).group),a=U(r,1,`chart-view-btn svelte-1kee4g8`,null,a,{active:I(c)===`chart`}),W(r,`aria-pressed`,I(c)===`chart`),W(r,`aria-label`,`Show ${I(i).noun??``} chart`),s=U(o,1,`chart-view-btn svelte-1kee4g8`,null,s,{active:I(c)===`stacked`}),W(o,`aria-pressed`,I(c)===`stacked`),W(o,`aria-label`,`Show ${I(i).noun??``} stacked chart`),u=U(l,1,`chart-view-btn svelte-1kee4g8`,null,u,{active:I(c)===`table`}),W(l,`aria-pressed`,I(c)===`table`),W(l,`aria-label`,`Show ${I(i).noun??``} table`)}),L(`click`,r,()=>J.toggleUsageChartView(t.kind,`chart`)),L(`click`,o,()=>J.toggleUsageChartView(t.kind,`stacked`)),L(`click`,l,()=>J.toggleUsageChartView(t.kind,`table`)),z(e,n)},r={model:{group:`Model usage view`,noun:`model usage`,tokensTitle:`Token Usage by Model`,costsTitle:`Cost by Model`},userPath:{group:`User path usage view`,noun:`user path usage`,tokensTitle:`Usage by User Path`,costsTitle:`Cost by User Path`},label:{group:`Label usage view`,noun:`label usage`,tokensTitle:`Usage by Label`,costsTitle:`Cost by Label`}},i=O(()=>r[t.kind]),a=O(()=>t.kind===`model`?e=>vc(e):t.kind===`userPath`?e=>e.user_path||`/`:e=>e.label);function o(e){return t.kind===`model`?(e.provider_name||e.provider||`-`)+`/`+e.model:t.kind===`userPath`?e.user_path||`/`:e.label}let s=O(()=>t.kind===`model`?J.modelUsage:t.kind===`userPath`?J.userPathUsage:J.labelUsage),c=O(()=>t.kind===`model`?J.modelUsageView:t.kind===`userPath`?J.userPathUsageView:J.labelUsageView),l=O(()=>t.kind===`model`?J.modelUsageLoading:t.kind===`userPath`?J.userPathUsageLoading:J.labelUsageLoading),u=O(()=>J.usageMode===`costs`),d=O(()=>t.kind===`userPath`?mw(I(s)):I(s).length>0),f=O(()=>I(u)?I(i).costsTitle:I(i).tokensTitle),p=O(()=>gw(I(s),I(a),I(u))),m=O(()=>pw(I(s),I(u)));function h(){return hw(I(c))?jw(Iy(),I(p).labels,I(p),{stacked:I(c)===`stacked`,costs:I(u),resolve:zy}):null}var g=Qr(),_=N(g),v=e=>{var r=Ww(),a=M(r),s=M(a),u=e=>{qS(e,{copyId:`label-usage-help-copy`,label:`label usage help`,text:`One request can have multiple labels. Such a request counts once under each of its labels, so label rows can overlap and add up to more than the period totals.`,title:e=>{var t=Nw(),n=M(t,!0);T(t),F(()=>B(n,I(f))),z(e,t)},extra:e=>{var t=Qr(),n=N(t),r=e=>{SS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(n,e=>{I(l)&&e(r)}),z(e,t)},$$slots:{title:!0,extra:!0}})},d=e=>{var t=Pw(),n=N(t),r=M(n,!0);T(n);var a=P(n,2),o=e=>{SS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(a,e=>{I(l)&&e(o)}),F(()=>B(r,I(f))),z(e,t)};V(s,e=>{t.kind===`label`?e(u):e(d,-1)});var g=P(s,2);n(g),T(a);var _=P(a,2),v=e=>{var t=Fw();let n;jy(M(t),{build:h}),T(t),F(e=>n=Hi(t,``,n,e),[()=>({height:`${_w(I(p).labels.length)??``}px`})]),z(e,t)},y=O(()=>hw(I(c))),b=e=>{var n=Uw(),r=M(n),i=M(r),a=M(i),s=M(a),c=e=>{var t=Iw();Ue(2),z(e,t)},l=e=>{z(e,Lw())},u=e=>{var t=Rw();Ue(2),z(e,t)};V(s,e=>{t.kind===`model`?e(c):t.kind===`userPath`?e(l,1):e(u,-1)}),Ue(8),T(a),T(i);var d=P(i);H(d,21,()=>I(m),e=>o(e),(e,n)=>{var r=Hw(),i=M(r),a=e=>{var t=zw(),r=N(t),i=M(r,!0);T(r);var a=P(r,2),o=M(a),s=M(o,!0);T(o),T(a),F(e=>{B(i,I(n).model||`-`),B(s,e)},[()=>gc(I(n))||`-`]),z(e,t)},o=e=>{var t=Bw(),r=M(t,!0);T(t),F(()=>B(r,I(n).user_path||`/`)),z(e,t)},s=e=>{var t=Vw(),r=N(t),i=M(r);let a;var o=M(i,!0);T(i),T(r);var s=P(r,2),c=M(s,!0);T(s),F((e,t,r)=>{a=U(i,1,`usage-label-chip`,null,a,{active:J.usageFilterLabel===I(n).label}),Hi(i,`--label-color: ${e??``}`),W(i,`title`,t),B(o,I(n).label),B(c,r)},[()=>Hy(I(n).label),()=>J.usageLabelChipTitle(I(n).label),()=>oc(I(n).requests)]),L(`click`,i,()=>J.toggleUsageLabelFilter(I(n).label)),z(e,t)};V(i,e=>{t.kind===`model`?e(a):t.kind===`userPath`?e(o,1):e(s,-1)});var c=P(i),l=M(c,!0);T(c);var u=P(c),d=M(u,!0);T(u);var f=P(u),p=M(f,!0);T(f);var m=P(f),h=M(m,!0);T(m);var g=P(m),_=M(g,!0);T(g);var v=P(g),y=M(v,!0);T(v);var b=P(v),x=M(b,!0);T(b);var S=P(b),C=M(S,!0);T(S),T(r),F((e,t,n,r,i,a,o,s,c,u,g)=>{B(l,e),B(d,t),W(f,`title`,n),B(p,r),W(m,`title`,`${i??``} input + ${a??``} output`),B(h,o),B(_,s),B(y,c),B(x,u),B(C,g)},[()=>oc(I(n).input_tokens),()=>oc(I(n).output_tokens),()=>I(n).cached_input_cost==null?``:`~`+sc(I(n).cached_input_cost)+` at current cached-input pricing`,()=>oc(I(n).cached_input_tokens||0),()=>oc(I(n).local_cached_input_tokens||0),()=>oc(I(n).local_cached_output_tokens||0),()=>oc((I(n).local_cached_input_tokens||0)+(I(n).local_cached_output_tokens||0)),()=>oc(dw(I(n))),()=>sc(I(n).input_cost),()=>sc(I(n).output_cost),()=>sc(I(n).total_cost)]),z(e,r)}),T(d),T(r),T(n),z(e,n)};V(_,e=>{I(y)?e(v):e(b,-1)}),T(r),z(e,r)},y=e=>{var t=Gw();SS(M(t),{size:20,get label(){return`Loading ${I(i).noun??``}`}}),T(t),z(e,t)};V(_,e=>{I(d)?e(v):I(l)&&e(y,1)}),z(e,g),D()}Hr([`click`]);var qw=R(``);function Jw(e,t){E(t,!0);let n=ya(t,`total`,3,0),r=ya(t,`offset`,3,0),i=ya(t,`limit`,3,25);var a=Qr(),o=N(a),s=e=>{var a=qw(),o=M(a),s=M(o);T(o);var c=P(o,2),l=M(c),u=P(l,2);T(c),T(a),F(e=>{B(s,`Showing ${r()+1}-${e??``} of ${n()??``}`),l.disabled=r()===0,u.disabled=r()+i()>=n()},[()=>Math.min(r()+i(),n())]),L(`click`,l,()=>t.onprev?.()),L(`click`,u,()=>t.onnext?.()),z(e,a)};V(o,e=>{n()>0&&e(s)}),z(e,a),D()}Hr([`click`]);var Yw=(e,t=f)=>{var n=Qr(),r=N(n),i=e=>{var n=Zw();H(n,20,()=>lw(t()),e=>e,(e,t)=>{var n=Xw();let r;var i=M(n,!0);T(n),F((e,a)=>{r=U(n,1,`usage-label-chip`,null,r,{active:J.usageFilterLabel===t}),Hi(n,`--label-color: ${e??``}`),W(n,`title`,a),B(i,t)},[()=>Hy(t),()=>J.usageLabelChipTitle(t)]),L(`click`,n,()=>J.toggleUsageLabelFilter(t)),z(e,n)}),T(n),z(e,n)},a=O(()=>lw(t()).length>0),o=e=>{z(e,Qw())};V(r,e=>{I(a)?e(i):e(o,-1)}),z(e,n)},Xw=R(``),Zw=R(`
                `),Qw=R(`-`),$w=R(`Labels`),eT=R(`Cost`),tT=R(``),nT=R(` `),rT=R(``),iT=R(` `),aT=R(` `),oT=R(`
                TimestampProviderModelUser PathCacheProvider Cache
                `),sT=R(`
                `),cT=R(`
                `),lT=R(`

                Request Log

                `);function uT(e,t){E(t,!0);let n=O(()=>J.usageMode===`costs`),r=O(()=>uw(J.labelUsage,J.usageFilterLabel,J.usageLog.entries)),i=bw(()=>J.fetchUsageLog(!0));An(()=>i.cancel);var a=lT(),o=P(M(a),2),s=M(o);yw(M(s),{placeholder:`Search by request ID, model, provider...`,label:`Search by request ID, model, provider`,get oninput(){return i},get value(){return J.usageLogSearch},set value(e){J.usageLogSearch=e}}),T(s);var c=P(s,2),l=M(c),u=M(l);na(u),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=e=>{var t=oT(),i=M(t),a=M(i),o=M(a),s=P(M(o),4),c=e=>{z(e,$w())};V(s,e=>{I(r)&&e(c)});var l=P(s,3),u=M(l,!0);T(l);var d=P(l),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{z(e,eT())};V(h,e=>{I(n)||e(g)}),T(o),T(a);var _=P(a);H(_,21,()=>J.usageLog.entries,e=>e.id,(e,t)=>{var i=aT();let a;var o=M(i),s=M(o,!0);T(o);var c=P(o),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{var n=tT();Yw(M(n),()=>I(t)),T(n),z(e,n)};V(h,e=>{I(r)&&e(g)});var _=P(h),v=M(_,!0);T(_);var y=P(_),b=M(y),x=e=>{var n=nT(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>ow(I(t))]),z(e,n)},S=O(()=>aw(I(t))),C=e=>{z(e,Qw())};V(b,e=>{I(S)?e(x):e(C,-1)}),T(y);var w=P(y),ee=M(w,!0);T(w);var te=P(w),ne=M(te,!0);T(te);var re=P(te),ie=M(re),ae=M(ie,!0);T(ie);var oe=P(ie,2),se=e=>{{let n=O(()=>$C(I(t)));G(e,{get icon(){return qa},class:`cost-source-icon`,get title(){return I(n)}})}},ce=O(()=>I(n)&&QC(I(t)));V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{G(e,{get icon(){return Xa},class:`cache-savings-icon`})},de=O(()=>I(n)&&tw(I(t)));V(le,e=>{I(de)&&e(ue)});var fe=P(le,2),pe=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(fe,e=>{I(n)&&I(t).costs_calculation_caveat&&e(pe)}),T(re);var me=P(re),he=e=>{var n=iT(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{{let n=O(()=>$C(I(t)));G(e,{get icon(){return qa},class:`cost-source-icon`,get title(){return I(n)}})}},s=O(()=>QC(I(t)));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{G(e,{get icon(){return Xa},class:`cache-savings-icon`})},u=O(()=>tw(I(t)));V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(d,e=>{I(t).costs_calculation_caveat&&e(f)}),T(n),F((e,t)=>{W(n,`title`,e),B(i,t)},[()=>rw(I(t),cw(I(t))),()=>sc(I(t).total_cost)]),z(e,n)};V(me,e=>{I(n)||e(he)}),T(i),F((e,n,r,c,l,d,p,h,g,_,b,x,S)=>{a=U(i,1,`svelte-hg4ill`,null,a,e),W(o,`title`,n),B(s,r),B(u,c),B(f,I(t).model),B(m,I(t).user_path||`-`),B(v,l),W(y,`title`,d),W(w,`title`,p),B(ee,h),W(te,`title`,g),B(ne,_),W(re,`title`,b),W(ie,`title`,x),B(ae,S)},[()=>({"usage-log-row-cached":tw(I(t))}),()=>mc(I(t).timestamp),()=>ds.formatTimestamp(I(t).timestamp),()=>gc(I(t))||`-`,()=>nw(I(t)),()=>sw(I(t)),()=>I(n)?oc(I(t).input_tokens)+` tokens`:``,()=>I(n)?sc(I(t).input_cost):oc(I(t).input_tokens),()=>I(n)?oc(I(t).output_tokens)+` tokens`:``,()=>I(n)?sc(I(t).output_cost):oc(I(t).output_tokens),()=>I(n)?rw(I(t),``):``,()=>I(n)?rw(I(t),oc(I(t).total_tokens)+` tokens +`+cw(I(t))):``,()=>I(n)?sc(I(t).total_cost):oc(I(t).total_tokens)]),z(e,i)}),T(_),T(i),T(t),F(()=>{B(u,I(n)?`Input Cost`:`Input`),B(f,I(n)?`Output Cost`:`Output`),B(m,I(n)?`Total Cost`:`Total`)}),z(e,t)},p=e=>{var t=sT();SS(M(t),{size:20,label:`Loading request log`}),T(t),z(e,t)},m=e=>{var t=cT();TS(M(t),{}),T(t),z(e,t)};V(d,e=>{J.usageLog.entries.length>0?e(f):J.usageLogLoading?e(p,1):e(m,-1)}),Jw(P(d,2),{get total(){return J.usageLog.total},get offset(){return J.usageLog.offset},get limit(){return J.usageLog.limit},onprev:()=>J.usageLogPrevPage(),onnext:()=>J.usageLogNextPage()}),T(a),L(`change`,u,()=>J.fetchUsageLog(!0)),fa(u,()=>J.usageLogHideCached,e=>J.usageLogHideCached=e),z(e,a),D()}Hr([`click`,`change`]);var dT=R(`
                `);function fT(e,t){E(t,!0);let n=`usage`;An(()=>{K.refreshTick,Jo.page===n&&(J.fetchUsagePage(),MC.ensureLiveLogs())}),An(()=>{Jo.page===n&&(J.usageMode=Jo.sub===`costs`?`costs`:`tokens`)});var r=dT(),i=P(M(r),2),a=M(i);Py(a,{ariaLabel:`Usage mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return J.usageMode},onchange:e=>J.toggleUsageMode(e)}),tl(P(a,2),{onchange:()=>J.fetchUsagePage()}),T(i);var o=P(i,2);ww(o,{});var s=P(o,2);Aw(s,{});var c=P(s,2),l=M(c);Kw(l,{kind:`model`});var u=P(l,2);Kw(u,{kind:`userPath`}),Kw(P(u,2),{kind:`label`}),T(c),uT(P(c,2),{}),T(r),z(e,r),D()}var pT=R(`
                `);function mT(e,t){let n=ya(t,`label`,3,`Loading...`),r=ya(t,`class`,3,``);var i=pT(),a=P(M(i),2),o=M(a,!0);T(a),T(i),F(()=>{U(i,1,Fi([`loading-state`,r()]),`svelte-hzxv1d`),B(o,n())}),z(e,i)}var hT=R(``);function gT(e,t){let n=ya(t,`label`,3,``),r=ya(t,`class`,3,``),i=ya(t,`disabled`,3,!1);var a=hT();gi(M(a),()=>t.children??f),T(a),F(()=>{U(a,1,Fi([`table-action-btn`,r()])),W(a,`aria-label`,n()),W(a,`title`,n()),a.disabled=i()}),L(`click`,a,function(...e){t.onclick?.apply(this,e)}),z(e,a)}Hr([`click`]);async function _T(e,{label:t,errorFallback:n=`Unable to load ${t}.`,unavailableStatuses:r=[503],normalize:i=e=>Array.isArray(e)?e:[],options:a}){let o;try{o=await _s(e,{...a||{},label:t})}catch(e){return ys(e)||console.error(`Failed to fetch ${t}:`,e),{status:`error`,items:[],error:n,result:null}}return o.stale?{status:`stale`,items:[],error:``,result:o}:r.includes(o.status)?{status:`unavailable`,items:[],error:``,result:o}:o.ok?{status:`ok`,items:i(o.data),error:``,result:o}:{status:`error`,items:[],error:o.status===401?``:fs(o.data,n),result:o}}async function vT(e,t,n,{label:r,errorFallback:i=`Unable to ${r}.`,unavailableStatuses:a=[503],unavailableMessage:o=`This feature is unavailable on the gateway.`,options:s}){let c;try{c=await vs(e,t,n,{...s||{},label:r})}catch(e){return ys(e)||console.error(`Failed to ${r}:`,e),{status:`error`,error:i,result:null}}return c.stale?{status:`stale`,error:``,result:c}:a.includes(c.status)?{status:`unavailable`,error:o,result:c}:c.ok?{status:`ok`,error:``,result:c}:{status:`error`,error:c.status===401?`Authentication required.`:fs(c.data,i),result:c}}function yT(){return{scope:`user_path`,subject:`/`,period:`daily`,period_seconds:86400,amount:``,source:`manual`}}function bT(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},label:{label:`Label`,chip:`label`,fieldLabel:`Label`,placeholder:`Mobile-App-iOS`}};return t[e]||t.user_path}function xT(){return[`user_path`,`label`].map(e=>({value:e,label:bT(e).label}))}function ST(e){return String(e&&e.scope||``).trim()||`user_path`}function CT(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function wT(e){return bT(ST(e)).chip}function TT(e){return ST(e)===`label`?`budget-label`:`budget-user-path`}function ET(e){return bT(String(e&&e.scope||``)).fieldLabel}function DT(e){return bT(String(e&&e.scope||``)).placeholder}function OT(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function kT(){return[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`},{value:`custom`,label:`Custom seconds`}]}function AT(e){switch(String(e||``).trim().toLowerCase()){case`hourly`:return 3600;case`daily`:return 86400;case`weekly`:return 604800;case`monthly`:return 2592e3;default:return 0}}function jT(e){switch(Number(e||0)){case 3600:return`hourly`;case 86400:return`daily`;case 604800:return`weekly`;case 2592e3:return`monthly`;default:return`custom`}}function MT(e){return ST(e)+`:`+CT(e)+`:`+String(e&&e.period_seconds||``)}function NT(e,t){if(!t||!Array.isArray(e))return null;let n=MT(t);return e.find(e=>MT(e)===n)||null}function PT(e){let t=String(e||``).trim();if(!t)return`User path is required.`;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function FT(e){if(PT(e))return``;let t=String(e||``).trim(),n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function IT(e){return`/`+String(e||``).trimStart().replace(/^\/+/,``)}function LT(e){return Array.isArray(e)?e:e&&Array.isArray(e.budgets)?e.budgets:[]}function RT(e){let t=Number(e&&e.period_seconds||0);return[CT(e),wT(e),tE(e),jT(t),t?String(t)+`s`:``,t?String(t)+` seconds`:``].join(` `).toLowerCase()}var zT={user_path:0,label:1};function BT(e,t){let n=Array.isArray(e)?e.slice():[],r=String(t||`subject`);return n.sort((e,t)=>{let n=(zT[ST(e)]||0)-(zT[ST(t)]||0),i=CT(e).localeCompare(CT(t)),a=Number(t&&t.period_seconds||0)-Number(e&&e.period_seconds||0);return r===`period`?a||n||i:n||i||a}),n}function VT(e,t,n){let r=Array.isArray(e)?e:[],i=String(t||``).trim().toLowerCase();return BT(i?r.filter(e=>RT(e).includes(i)):r.slice(),n)}function HT(e){let t=e||{},n=ST(t),r=String(t.subject||``).trim();if(n===`user_path`){let e=PT(r);if(e)return{payload:null,error:e}}else if(!r)return{payload:null,error:`Label is required.`};let i=Number(t.amount);if(!Number.isFinite(i)||i<=0)return{payload:null,error:`Amount must be greater than 0.`};let a=String(t.period||``).trim(),o=AT(a);return a===`custom`&&(o=Number(t.period_seconds)),!Number.isFinite(o)||o<=0?{payload:null,error:`Period seconds must be greater than 0.`}:{payload:{scope:n,subject:n===`user_path`?FT(r):r,period_seconds:Math.trunc(o),amount:i,source:String(t.source||`manual`).trim()||`manual`},error:``}}function UT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds},amount:e.amount}}function WT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds}}}function GT(e){return{scope:ST(e),subject:CT(e),period_seconds:e.period_seconds}}function KT(e){return sc(e)}function qT(e,t){let n=e||{},r=t||{};return`A budget for "`+((CT(n)||CT(r))+` `+tE({period_seconds:n.period_seconds||r.period_seconds,period_label:r.period_label}))+`" already exists. Saving will override the current `+KT(r.amount)+` limit with `+KT(n.amount)+`.`}function JT(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:t}function YT(e,t){let n=JT(e);return Math.round((t?Math.min(n,1):n)*1e3)/10}function XT(e){return JT(e&&e.usage_ratio)}function ZT(e){return YT(XT(e),!0)}function QT(e){return YT(e&&e.period_ratio,!0)}function $T(e){return YT(XT(e),!1).toFixed(1).replace(/\.0$/,``)+`%`}function eE(e){return QT(e).toFixed(1).replace(/\.0$/,``)+`%`}function tE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`Hourly`;case 86400:return`Daily`;case 604800:return`Weekly`;case 2592e3:return`Monthly`;default:{let n=String(e&&e.period_label||``).trim();return n?`Custom `+n:`Custom `+String(t||``)+`s`}}}function nE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return`budget-period-label-hourly`;case 86400:return`budget-period-label-daily`;case 604800:return`budget-period-label-weekly`;case 2592e3:return`budget-period-label-monthly`;default:return`budget-period-label-custom`}}function rE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-fill-period-`)}function iE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-track-period-`)}function aE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return Ja;case 86400:return Do;case 604800:return La;case 2592e3:return Ra;default:return xo}}function oE(e){let t=Math.max(0,Math.trunc(Number(e||0)));return t+` `+(t===1?`second`:`seconds`)}function sE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`1 hour`;case 86400:return`1 day`;case 604800:return`1 week`;case 2592e3:return`1 month`;default:return oE(t)}}function cE(e){return String(e&&e.source||``).trim()||`manual`}function lE(e){let t=cE(e).toLowerCase();return t===`manual`?`Created from the dashboard.`:t===`config`?`Loaded from configuration.`:`Budget source: `+t}function uE(e){let t=Number(e&&e.remaining);return Number.isFinite(t)?t<0?sc(Math.abs(t))+` over`:sc(t)+` remaining`:``}var Y=new class{#e=k(j([]));get budgets(){return I(this.#e)}set budgets(e){A(this.#e,e,!0)}#t=k(!0);get budgetsAvailable(){return I(this.#t)}set budgetsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get filter(){return I(this.#r)}set filter(e){A(this.#r,e,!0)}#i=k(`subject`);get sortBy(){return I(this.#i)}set sortBy(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(!1);get formOpen(){return I(this.#o)}set formOpen(e){A(this.#o,e,!0)}#s=k(!1);get formSubmitting(){return I(this.#s)}set formSubmitting(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get editing(){return I(this.#l)}set editing(e){A(this.#l,e,!0)}#u=k(j(yT()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(!1);get overrideDialogOpen(){return I(this.#d)}set overrideDialogOpen(e){A(this.#d,e,!0)}#f=k(null);get overridePendingPayload(){return I(this.#f)}set overridePendingPayload(e){A(this.#f,e,!0)}#p=k(null);get overrideExistingBudget(){return I(this.#p)}set overrideExistingBudget(e){A(this.#p,e,!0)}#m=k(``);get resettingKey(){return I(this.#m)}set resettingKey(e){A(this.#m,e,!0)}#h=k(``);get deletingKey(){return I(this.#h)}set deletingKey(e){A(this.#h,e,!0)}#g=k(!1);get resetAllLoading(){return I(this.#g)}set resetAllLoading(e){A(this.#g,e,!0)}#_=null;managementEnabled(){return Ss.budgetsVisible()}filteredBudgets(){return VT(this.budgets,this.filter,this.sortBy)}async fetchBudgetsPage(){if(await Ss.ensureLoaded(),!this.managementEnabled()){this.budgets=[],this.budgetsAvailable=!1,this.error=``;return}return this.#_||=this.fetchBudgets().finally(()=>{this.#_=null}),this.#_}async fetchBudgets(){this.loading=!0,this.error=``;let e=await _T(`/admin/budgets`,{label:`budgets`,errorFallback:`Unable to load budgets.`,normalize:LT});if(this.loading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.budgetsAvailable=!1,this.budgets=[];return}if(!e.result){this.budgets=[],this.error=e.error;return}if(this.budgetsAvailable=!0,e.status===`error`){this.error=e.error;return}this.budgets=e.items}}openForm(e){if(this.editing=!!e,this.formError=``,e){let t=Number(e.period_seconds||0);this.form={scope:ST(e),subject:CT(e),period:jT(t),period_seconds:t,amount:String(e.amount||``),source:String(e.source||`manual`)}}else this.form=yT();this.formOpen=!0}syncPeriodSeconds(){let e=AT(String(this.form.period||``).trim());e>0&&(this.form.period_seconds=e)}setFormSubject(e){this.form.subject=this.form.scope===`label`?String(e??``):IT(e)}syncScope(){OT(this.form)}closeForm(){this.closeOverrideDialog(),this.formOpen=!1,this.formSubmitting=!1,this.formError=``,this.editing=!1,this.form=yT()}async submitForm(){if(this.formSubmitting)return;let{payload:e,error:t}=HT(this.form);if(!e){this.formError=t;return}if(!this.editing){let t=NT(this.budgets,e);if(t){this.openOverrideDialog(t,e);return}}await this.saveBudgetPayload(e)}async saveBudgetPayload(e){if(this.formSubmitting||!e)return;this.formSubmitting=!0,this.formError=``;let t=await vT(`/admin/budgets`,`PUT`,UT(e),{label:`save budget`,errorFallback:`Unable to save budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.formSubmitting=!1,t.status!==`stale`){if(t.status===`unavailable`){this.budgetsAvailable=!1,this.formError=t.error;return}if(t.status===`error`){this.formError=t.error;return}this.closeForm(),q.success(`Budget saved.`),this.fetchBudgets()}}openOverrideDialog(e,t){this.overrideExistingBudget=e||null,this.overridePendingPayload=t||null,this.overrideDialogOpen=!0}closeOverrideDialog(){this.overrideDialogOpen=!1,this.overridePendingPayload=null,this.overrideExistingBudget=null}async confirmOverride(){if(!this.overridePendingPayload){this.closeOverrideDialog();return}let e=this.overridePendingPayload;this.closeOverrideDialog(),await this.saveBudgetPayload(e)}async resetBudget(e){if(!e)return;let t=MT(e);if(this.resettingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Reset budget "`+n+`"?`))return;this.resettingKey=t;let r=await vT(`/admin/budgets/reset-one`,`POST`,GT(e),{label:`reset budget`,errorFallback:`Unable to reset budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.resettingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,q.error(r.error);return}if(r.status===`error`){q.error(r.error);return}q.success(`Budget reset.`),this.fetchBudgets()}}async deleteBudget(e){if(!e)return;let t=MT(e);if(this.deletingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Delete budget "`+n+`"? This cannot be undone.`))return;this.deletingKey=t;let r=await vT(`/admin/budgets`,`DELETE`,WT(e),{label:`delete budget`,errorFallback:`Unable to delete budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.deletingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,q.error(r.error);return}if(r.status===`error`){q.error(r.error);return}this.budgets=LT(r.result.data),q.success(`Budget deleted.`)}}openResetDialog(){Rs.open({title:`Reset Budgets`,titleId:`budgetResetDialogTitle`,inputId:`budget-reset-confirmation`,requiredText:`reset`,confirmLabel:`Reset All Budgets`,icon:go,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.resetAllBudgets()})}async resetAllBudgets(){if(this.resetAllLoading)return;this.resetAllLoading=!0;let e=await vT(`/admin/budgets/reset`,`POST`,{confirmation:`reset`},{label:`reset budgets`,errorFallback:`Unable to reset budgets.`,unavailableStatuses:[]});if(this.resetAllLoading=!1,e.status!==`stale`){if(e.status!==`ok`){Rs.error=e.error;return}Rs.close(),q.success(`Budgets reset.`),Jo.page===`budgets`&&this.fetchBudgets()}}},dE=R(` Edit`,1),fE=R(` `,1),pE=R(`
                Usage
                Period
                `),mE=R(`
                `);function hE(e,t){E(t,!0);let n=ya(t,`budgets`,19,()=>[]);function r(e){if(!e)return``;let t=ds.formatTimestamp(e);return!t||t===`-`?``:t+` `+ds.effectiveTimeZoneLabel()}var i=mE();H(i,21,n,e=>MT(e),(e,t)=>{var n=pE(),i=M(n),a=M(i),o=M(a),s=M(o),c=e=>{G(e,{get icon(){return Oo},class:`budget-scope-icon`})},l=O(()=>ST(I(t))===`label`);V(s,e=>{I(l)&&e(c)});var u=P(s);T(o);var d=P(o,2),f=M(d),p=M(f);{let e=O(()=>aE(I(t)));G(p,{get icon(){return I(e)},class:`budget-period-icon`})}var m=P(p,2),h=M(m,!0);T(m),T(f),T(d);var g=P(d,2),_=M(g),v=M(_),y=M(v,!0);T(v),T(_);var b=P(_,2),x=M(b);gT(x,{label:`Edit budget`,class:`budget-action-btn`,onclick:()=>Y.openForm(I(t)),children:(e,t)=>{var n=dE();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}});var S=P(x,2);{let e=O(()=>Y.resettingKey===MT(I(t))?`Resetting budget`:`Reset budget`),n=O(()=>Y.resettingKey===MT(I(t)));gT(S,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>Y.resetBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);G(i,{get icon(){return go},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.resettingKey===MT(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var C=P(S,2);{let e=O(()=>Y.deletingKey===MT(I(t))?`Deleting budget`:`Delete budget`),n=O(()=>Y.deletingKey===MT(I(t)));gT(C,{get label(){return I(e)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>Y.deleteBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);G(i,{get icon(){return Ao},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.deletingKey===MT(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}T(b),T(g),T(a);var w=P(a,2),ee=M(w),te=M(ee),ne=P(M(te),2),re=M(ne,!0);T(ne),T(te);var ie=P(te,2),ae=M(ie);let oe;var se=P(ae,2),ce=M(se),le=M(ce,!0);T(ce);var ue=P(ce,2),de=M(ue,!0);T(ue),T(se);var fe=P(se,2),pe=M(fe),me=M(pe,!0);T(pe);var he=P(pe,2),ge=M(he,!0);T(he),T(fe),T(ie),T(ee);var _e=P(ee,2),ve=M(_e),ye=P(M(ve),2),be=M(ye,!0);T(ye),T(ve);var xe=P(ve,2),Se=M(xe),Ce=P(Se,2),we=M(Ce),Te=M(we,!0);T(we);var Ee=P(we,2),De=M(Ee,!0);T(Ee);var Oe=P(Ee,2),ke=M(Oe,!0);T(Oe),T(Ce);var Ae=P(Ce,2),je=M(Ae),Me=M(je,!0);T(je);var Ne=P(je,2),Pe=M(Ne,!0);T(Ne);var Fe=P(Ne,2),Ie=M(Fe,!0);T(Fe),T(Ae),T(xe),T(_e),T(w),T(i),T(n),F((e,t,n,r,i,a,s,c,l,d,p,m,g,_,b,x,S,C,w,ee,te,ne,se,ce,ue,fe,pe,he,_e,ve)=>{U(o,1,`budget-scope-value ${e??``}`,`svelte-1jm56wo`),Hi(o,t),W(o,`title`,n),B(u,` ${r??``}`),U(f,1,`budget-period-label ${i??``}`,`svelte-1jm56wo`),B(h,a),W(v,`title`,s),B(y,c),B(re,l),W(ie,`aria-valuenow`,d),W(ie,`aria-label`,p),Hi(ie,`--budget-progress: ${m??``}%`),oe=U(ae,1,`budget-bar-fill budget-bar-fill-usage`,null,oe,g),B(le,_),B(de,b),B(me,x),B(ge,S),B(be,C),U(xe,1,`budget-bar-track ${w??``}`,`svelte-1jm56wo`),W(xe,`aria-valuenow`,ee),Hi(xe,`--budget-progress: ${te??``}%`),U(Se,1,`budget-bar-fill budget-bar-fill-period ${ne??``}`,`svelte-1jm56wo`),W(we,`title`,se),B(Te,ce),B(De,ue),W(Oe,`title`,fe),B(ke,pe),B(Me,he),B(Pe,_e),B(Ie,ve)},[()=>TT(I(t)),()=>ST(I(t))===`label`?`--label-color: `+Hy(CT(I(t))):void 0,()=>wT(I(t))+`: `+CT(I(t)),()=>CT(I(t)),()=>nE(I(t)),()=>tE(I(t)),()=>lE(I(t)),()=>cE(I(t)),()=>$T(I(t)),()=>ZT(I(t)),()=>`Budget usage: `+sc(I(t).spent)+` of `+sc(I(t).amount)+`, `+uE(I(t)),()=>ZT(I(t)),()=>({"budget-bar-fill-danger":XT(I(t))>=1}),()=>sc(I(t).spent)+` of `+sc(I(t).amount),()=>uE(I(t)),()=>sc(I(t).spent)+` of `+sc(I(t).amount),()=>uE(I(t)),()=>eE(I(t)),()=>iE(I(t)),()=>QT(I(t)),()=>QT(I(t)),()=>rE(I(t)),()=>r(I(t).period_start),()=>ds.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>r(I(t).period_end),()=>ds.formatTimestamp(I(t).period_end),()=>ds.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>ds.formatTimestamp(I(t).period_end)]),z(e,n)}),T(i),z(e,i),D()}var gE=R(`

                `,1),_E=R(``),vE=R(``),yE=R(`
                `);function bE(e,t){E(t,!0);let n=ya(t,`open`,3,!1),r=ya(t,`title`,3,``),i=ya(t,`ariaLabel`,3,``),a=ya(t,`error`,3,``),o=ya(t,`submitting`,3,!1),s=ya(t,`submitDisabled`,3,!1),c=ya(t,`submitLabel`,3,`Save`),l=ya(t,`submittingLabel`,3,`Saving...`),u=ya(t,`submitIcon`,3,_o),d=ya(t,`cancel`,3,!0),p=ya(t,`dialogClass`,3,``),m=ya(t,`novalidate`,3,!1),h=ya(t,`canClose`,3,()=>!0);function g(){K.dialogOpen||h()()&&t.onclose?.()}Ns(e,{get open(){return n()},variant:`editor`,onclose:g,children:(e,n)=>{var h=yE(),g=M(h),_=M(g),v=M(_),y=M(v),b=e=>{var n=Qr();gi(N(n),()=>t.header),z(e,n)},x=e=>{var n=gE(),i=N(n),a=M(i,!0);T(i);var o=P(i,2),s=e=>{var n=Qr();gi(N(n),()=>t.headerHint),z(e,n)};V(o,e=>{t.headerHint&&e(s)}),F(()=>B(a,r())),z(e,n)};V(y,e=>{t.header?e(b):e(x,-1)}),T(v);var S=P(v,2);{let e=O(()=>`Close `+(i()||r()).toLowerCase());ks(S,{get label(){return I(e)},onclick:()=>t.onclose?.()})}T(_);var C=P(_,2);gi(C,()=>t.children??f);var w=P(C,2),ee=e=>{var t=_E(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(w,e=>{a()&&e(ee)});var te=P(w,2),ne=M(te),re=e=>{var n=vE();L(`click`,n,()=>t.onclose?.()),z(e,n)};V(ne,e=>{d()&&e(re)});var ie=P(ne,2),ae=e=>{var n=Qr();gi(N(n),()=>t.extraActions),z(e,n)};V(ie,e=>{t.extraActions&&e(ae)});var oe=P(ie,2),se=M(oe);G(se,{get icon(){return u()},class:`form-action-icon`});var ce=P(se,2),le=M(ce,!0);T(ce),T(oe),T(te),T(g),T(h),F(()=>{U(h,1,Fi([`model-editor`,p()])),W(h,`aria-label`,i()||r()),g.noValidate=m(),oe.disabled=o()||s(),B(le,o()?l():c())}),Vr(`submit`,g,e=>{e.preventDefault(),t.onsubmit?.()}),z(e,h)},$$slots:{default:!0}}),D()}Hr([`click`]);var xE=R(`
                `);function SE(e,t){let n=ya(t,`label`,3,``);var r=xE(),i=M(r),a=M(i,!0);T(i),gi(P(i,2),()=>t.children??f),T(r),F(()=>{W(i,`for`,t.id),B(a,n())}),z(e,r)}var CE=R(``),wE=R(``),TE=R(``),EE=R(``),DE=R(``),OE=R(``),kE=R(`

                Editing a budget updates its limit only. Use Reset to start a new + budget period.

                `),AE=R(`
                `,1),jE=R(``),ME=R(` `,1);function NE(e,t){E(t,!0);function n(e){Y.setFormSubject(e.target.value),e.target.value=Y.form.subject}var r=ME(),i=N(r);{let e=O(()=>Y.editing?`Edit Budget`:`Create Budget`);bE(i,{get open(){return Y.formOpen},get title(){return I(e)},ariaLabel:`Budget editor`,get error(){return Y.formError},get submitting(){return Y.formSubmitting},submitLabel:`Save Budget`,dialogClass:`budget-editor`,canClose:()=>!Y.overrideDialogOpen,onclose:()=>Y.closeForm(),onsubmit:()=>Y.submitForm(),children:(e,t)=>{var r=AE(),i=N(r),a=M(i);SE(a,{id:`budget-scope`,label:`Scope`,children:(e,t)=>{var n=wE();H(n,21,xT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncScope()),Gi(n,()=>Y.form.scope,e=>Y.form.scope=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);{let e=O(()=>ET(Y.form));SE(o,{id:`budget-subject`,get label(){return I(e)},children:(e,t)=>{var r=TE();na(r),F(e=>{W(r,`placeholder`,e),ra(r,Y.form.subject),r.disabled=Y.editing,W(r,`data-modal-autofocus`,!Y.editing||void 0)},[()=>DT(Y.form)]),L(`input`,r,n),z(e,r)},$$slots:{default:!0}})}var s=P(o,2);SE(s,{id:`budget-period`,label:`Period`,children:(e,t)=>{var n=EE();H(n,21,kT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncPeriodSeconds()),Gi(n,()=>Y.form.period,e=>Y.form.period=e),z(e,n)},$$slots:{default:!0}});var c=P(s,2),l=e=>{SE(e,{id:`budget-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=DE();na(n),F(()=>n.disabled=Y.editing),da(n,()=>Y.form.period_seconds,e=>Y.form.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(c,e=>{Y.form.period===`custom`&&e(l)}),SE(P(c,2),{id:`budget-amount`,label:`Amount`,children:(e,t)=>{var n=OE();na(n),F(()=>W(n,`data-modal-autofocus`,Y.editing||void 0)),da(n,()=>Y.form.amount,e=>Y.form.amount=e),z(e,n)},$$slots:{default:!0}}),T(i);var u=P(i,2),d=e=>{z(e,kE())};V(u,e=>{Y.editing&&e(d)}),z(e,r)},$$slots:{default:!0}})}Ns(P(i,2),{get open(){return Y.overrideDialogOpen},variant:`auth`,onclose:()=>Y.closeOverrideDialog(),children:(e,t)=>{var n=jE(),r=M(n);ks(P(M(r),2),{label:`Close budget override dialog`,onclick:()=>Y.closeOverrideDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=P(c,2),u=M(l);G(u,{get icon(){return _o},class:`form-action-icon`});var d=P(u,2),f=M(d,!0);T(d),T(l),T(s),T(i),T(n),F(e=>{B(o,e),l.disabled=Y.formSubmitting,B(f,Y.formSubmitting?`Saving...`:`Override Budget`)},[()=>qT(Y.overridePendingPayload,Y.overrideExistingBudget)]),Vr(`submit`,i,e=>{e.preventDefault(),Y.confirmOverride()}),L(`click`,c,()=>Y.closeOverrideDialog()),z(e,n)},$$slots:{default:!0}}),z(e,r),D()}Hr([`change`,`input`,`click`]);var PE=R(`

                Budgets

                `),FE=R(``),IE=R(`
                Budget management is unavailable.
                `),LE=R(``),RE=R(`
                `),zE=R(`

                No budgets configured yet.

                `),BE=R(`

                No budgets match your filter.

                `),VE=R(`
                `);function HE(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`budgets`&&Y.fetchBudgetsPage()});let n=O(()=>Y.filteredBudgets());var r=VE(),i=M(r),a=M(i);qS(M(a),{copyId:`budgets-help-copy`,label:`budgets help`,title:e=>{z(e,PE())},help:e=>{Ue(),z(e,Zr(`Budgets are evaluated from tracked usage cost records for each user + path subtree. Enforcement runs only when Budget is enabled for the + active workflow.`))},$$slots:{title:!0,help:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=FE();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Y.formSubmitting),L(`click`,t,()=>Y.openForm()),z(e,t)},l=O(()=>Y.managementEnabled()&&Y.budgetsAvailable&&!K.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Fc(u,{});var d=P(u,2),f=e=>{z(e,IE())},p=O(()=>(!Y.managementEnabled()||!Y.budgetsAvailable)&&!K.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=LE(),n=M(t,!0);T(t),F(()=>B(n,Y.error)),z(e,t)};V(m,e=>{Y.error&&!K.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading budgets...`})};V(g,e=>{Y.loading&&!K.authError&&e(_)});var v=P(g,2),y=e=>{var t=RE(),n=M(t);yw(M(n),{id:`budget-filter`,placeholder:`Filter by user path, label, or period...`,label:`Filter budgets by user path or period`,get value(){return Y.filter},set value(e){Y.filter=e}}),T(n);var r=P(n,2),i=P(M(r),2),a=M(i);a.value=a.__value=`subject`;var o=P(a);o.value=o.__value=`period`,T(i),T(r),T(t),Gi(i,()=>Y.sortBy,e=>Y.sortBy=e),z(e,t)};V(v,e=>{(Y.budgets.length>0||Y.filter)&&Y.budgetsAvailable&&!K.authError&&!Y.formOpen&&e(y)});var b=P(v,2);NE(b,{});var x=P(b,2),S=e=>{hE(e,{get budgets(){return I(n)}})};V(x,e=>{I(n).length>0&&Y.budgetsAvailable&&!K.authError&&e(S)});var C=P(x,2),w=e=>{z(e,zE())},ee=O(()=>Y.budgets.length===0&&!Y.filter&&!Y.loading&&!K.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,BE())},re=O(()=>Y.budgets.length>0&&I(n).length===0&&Y.filter&&!Y.loading&&!K.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function UE(){return{scope:`user_path`,subject:`/`,period:`minute`,period_seconds:60,max_requests:``,max_tokens:``,source:`manual`}}function WE(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},provider:{label:`Provider`,chip:`provider`,fieldLabel:`Provider Name`,placeholder:`openai`},model:{label:`Model`,chip:`model`,fieldLabel:`Model`,placeholder:`openai/gpt-4o`}};return t[e]||t.user_path}function GE(){return[`user_path`,`provider`,`model`].map(e=>({value:e,label:WE(e).label}))}function KE(e){return String(e&&e.scope||``).trim()||`user_path`}function qE(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function JE(e){return WE(KE(e)).chip}function YE(e){return WE(String(e&&e.scope||``)).fieldLabel}function XE(e){return WE(String(e&&e.scope||``)).placeholder}function ZE(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function QE(){return[{value:`minute`,label:`Per minute`},{value:`hour`,label:`Per hour`},{value:`day`,label:`Per day`},{value:`concurrent`,label:`Concurrent (in-flight)`},{value:`custom`,label:`Custom seconds`}]}function $E(e){switch(String(e||``).trim().toLowerCase()){case`minute`:return 60;case`hour`:return 3600;case`day`:return 86400;case`concurrent`:return 0;default:return-1}}function eD(e){switch(Number(e||0)){case 60:return`minute`;case 3600:return`hour`;case 86400:return`day`;case 0:return`concurrent`;default:return`custom`}}function tD(e){let t=String(e&&e.period||``).trim(),n=$E(t);n>=0&&(e.period_seconds=n),t===`concurrent`&&(e.max_tokens=``)}function nD(e){return KE(e)+`:`+qE(e)+`:`+String(e&&e.period_seconds||`0`)}function rD(e){return Number(e&&e.period_seconds||0)===0}function iD(e){return String(e&&e.period_label||``).trim()||eD(Number(e&&e.period_seconds||0))}function aD(e){return String(e&&e.source||``)===`config`?`config`:`manual`}function oD(e){return String(e&&e.source||``)===`config`}function sD(e){let t=Number(e);return Number.isFinite(t)?t.toLocaleString():`0`}function cD(e,t){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return 0;let i=Math.round(n/r*100);return Math.min(Math.max(i,0),100)}function lD(e,t){let n=String(t||``).trim().toLowerCase(),r=Array.isArray(e)?e.slice():[],i={user_path:0,provider:1,model:2};return r.sort((e,t)=>{let n=(i[KE(e)]||0)-(i[KE(t)]||0);if(n!==0)return n;let r=qE(e).localeCompare(qE(t));return r===0?Number(e.period_seconds||0)-Number(t.period_seconds||0):r}),n?r.filter(e=>{let t=qE(e).toLowerCase(),r=JE(e).toLowerCase(),i=iD(e).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)}):r}function uD(e){return!e||!Array.isArray(e.rate_limits)?[]:e.rate_limits}function dD(e,t,n){let r=String(t||``).trim();return r=e===`provider`||e===`model`?r.toLowerCase():`/`+r.split(`/`).map(e=>e.trim()).filter(Boolean).join(`/`),e+`:`+r+`:`+Number(n||0)}function fD(e,t){return e?dD(t.scope,t.subject,t.limit_key.period_seconds)!==dD(e.scope,e.subject,e.period_seconds):!1}function pD(e){let t=e||{},n=String(t.scope||`user_path`),r=String(t.subject||``).trim();if(n!==`user_path`&&!r)return{error:YE(t)+` is required.`};let i=String(t.period||``)===`concurrent`,a=t.period_seconds;if(a===``||a==null)return{error:`Period seconds is required.`};let o=Number(a);if(!Number.isInteger(o)||o<0||o===0&&!i)return{error:`Period seconds must be a positive integer (0 only for the concurrent period).`};let s=String(t.max_requests===void 0||t.max_requests===null?``:t.max_requests).trim(),c=String(t.max_tokens===void 0||t.max_tokens===null?``:t.max_tokens).trim();if(!s&&!c)return{error:`Set max requests, max tokens, or both.`};if(i&&c)return{error:`Token limits are not valid for the concurrent period.`};let l={scope:n,subject:r||`/`,limit_key:{period_seconds:o}};if(s){let e=Number(s);if(!Number.isInteger(e)||e<=0)return{error:`Max requests must be a positive integer.`};l.max_requests=e}if(c){let e=Number(c);if(!Number.isInteger(e)||e<=0)return{error:`Max tokens must be a positive integer.`};l.max_tokens=e}return{payload:l}}function mD(e,t,n){if(KE(e)!==`model`)return!1;let r=String(qE(e)).toLowerCase(),i=String(n||``).trim().toLowerCase();if(!i)return!1;if(r===i)return!0;let a=String(t||``).trim().toLowerCase();return a?r===a+`/`+i||i.startsWith(a+`/`)&&r===i.slice(a.length+1):!1}function hD(e,t){return KE(e)===`provider`&&String(qE(e)).toLowerCase()===String(t||``).trim().toLowerCase()}function gD(e){let t=e||{},n=String(t.model||``),r=String(t.provider||``);return!r||n.toLowerCase().startsWith(r+`/`)?n:r+`/`+n}function _D(e,t){let n=e||{},r=Array.isArray(t)?t:[],i=[];return n.kind===`model`&&i.push({key:`model`,title:`Model limits`,scope:`model`,subject:gD(n),hint:``,items:r.filter(e=>mD(e,n.provider,n.model))}),i.push({key:`provider`,title:`Provider limits (`+n.provider+`)`,scope:`provider`,subject:n.provider,hint:n.kind===`model`?`Shared by every model routed to this provider.`:``,items:r.filter(e=>hD(e,n.provider))}),i.push({key:`global`,title:`Global limits`,scope:`user_path`,subject:`/`,hint:`Root user-path rules throttle all traffic. Narrower user-path rules also apply, per consumer.`,items:r.filter(e=>KE(e)===`user_path`&&qE(e)===`/`)}),i}function vD(e){return rD(e)?cD(e.in_flight,e.max_requests):Math.max(cD(e.requests_used,e.max_requests),cD(e.tokens_used,e.max_tokens))}function yD(e){return`--rate-limit-pressure: `+vD(e)+`%`}function bD(e){let t=vD(e);return t>=100?`rate-limit-pressure-row rate-limit-pressure-full`:t>=75?`rate-limit-pressure-row rate-limit-pressure-high`:`rate-limit-pressure-row`}function xD(e){return(Array.isArray(e)?e:[]).some(e=>KE(e)===`user_path`&&qE(e)===`/`)}function SD(e,t,n){let r=Array.isArray(e)?e:[];return r.some(e=>mD(e,t,n))?`table-action-btn-active`:r.some(e=>hD(e,t))||xD(r)?`rate-limit-gauge-inherited`:``}function CD(e,t){let n=Array.isArray(e)?e:[];return n.some(e=>hD(e,t))?`table-action-btn-active`:xD(n)?`rate-limit-gauge-inherited`:``}function wD(e,t){let n=`Rate limits for `+e;return t===`table-action-btn-active`?n+` (direct limits configured)`:t?n+` (inherited limits apply)`:n}function TD(e){if(rD(e))return sD(e.in_flight)+` of `+sD(e.max_requests)+` in flight`;let t=[];return e.max_requests!==null&&e.max_requests!==void 0&&t.push(sD(e.requests_used)+`/`+sD(e.max_requests)+` req`),e.max_tokens!==null&&e.max_tokens!==void 0&&t.push(sD(e.tokens_used)+`/`+sD(e.max_tokens)+` tok`),t.join(` · `)}var X=new class{#e=k(j([]));get rateLimits(){return I(this.#e)}set rateLimits(e){A(this.#e,e,!0)}#t=k(!0);get rateLimitsAvailable(){return I(this.#t)}set rateLimitsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get rateLimitsLoading(){return I(this.#n)}set rateLimitsLoading(e){A(this.#n,e,!0)}rateLimitFetchPromise=null;#r=k(``);get rateLimitFilter(){return I(this.#r)}set rateLimitFilter(e){A(this.#r,e,!0)}#i=k(``);get rateLimitError(){return I(this.#i)}set rateLimitError(e){A(this.#i,e,!0)}#a=k(!1);get rateLimitFormOpen(){return I(this.#a)}set rateLimitFormOpen(e){A(this.#a,e,!0)}#o=k(!1);get rateLimitFormSubmitting(){return I(this.#o)}set rateLimitFormSubmitting(e){A(this.#o,e,!0)}#s=k(``);get rateLimitFormError(){return I(this.#s)}set rateLimitFormError(e){A(this.#s,e,!0)}#c=k(!1);get rateLimitEditing(){return I(this.#c)}set rateLimitEditing(e){A(this.#c,e,!0)}rateLimitEditingOriginal=null;rateLimitFormReturnToInspector=!1;#l=k(``);get rateLimitResettingKey(){return I(this.#l)}set rateLimitResettingKey(e){A(this.#l,e,!0)}#u=k(``);get rateLimitDeletingKey(){return I(this.#u)}set rateLimitDeletingKey(e){A(this.#u,e,!0)}#d=k(!1);get rateLimitInspectorOpen(){return I(this.#d)}set rateLimitInspectorOpen(e){A(this.#d,e,!0)}#f=k(j({kind:``,provider:``,model:``,title:``}));get rateLimitInspector(){return I(this.#f)}set rateLimitInspector(e){A(this.#f,e,!0)}#p=k(j(UE()));get rateLimitForm(){return I(this.#p)}set rateLimitForm(e){A(this.#p,e,!0)}rateLimitsEnabled(){return Ss.rateLimitsVisible()}defaultRateLimitForm(){return UE()}rateLimitScopeMeta(e){return WE(e)}rateLimitScopeOptions(){return GE()}rateLimitScope(e){return KE(e)}rateLimitSubject(e){return qE(e)}rateLimitScopeLabel(e){return JE(e)}rateLimitSubjectFieldLabel(){return YE(this.rateLimitForm)}rateLimitSubjectPlaceholder(){return XE(this.rateLimitForm)}syncRateLimitScope(){ZE(this.rateLimitForm)}rateLimitPeriodOptions(){return QE()}rateLimitPeriodSeconds(e){return $E(e)}rateLimitPeriodFromSeconds(e){return eD(e)}syncRateLimitPeriodSeconds(){tD(this.rateLimitForm)}rateLimitKey(e){return nD(e)}rateLimitIsConcurrent(e){return rD(e)}rateLimitPeriodLabel(e){return iD(e)}rateLimitSourceLabel(e){return aD(e)}rateLimitIsReadOnly(e){return oD(e)}formatRateLimitNumber(e){return sD(e)}rateLimitUsagePercent(e,t){return cD(e,t)}filteredRateLimits(){return lD(this.rateLimits,this.rateLimitFilter)}normalizeRateLimitListPayload(e){return uD(e)}async fetchRateLimitsPage(){if(await Ss.ensureLoaded(),!this.rateLimitsEnabled()){this.rateLimits=[],this.rateLimitsAvailable=!1,this.rateLimitError=``;return}return this.rateLimitFetchPromise||=this.fetchRateLimits().finally(()=>{this.rateLimitFetchPromise=null}),this.rateLimitFetchPromise}async fetchRateLimits(){this.rateLimitsLoading=!0,this.rateLimitError=``;let e=await _T(`/admin/rate-limits`,{label:`rate limits`,errorFallback:`Unable to load rate limits.`,normalize:uD});if(this.rateLimitsLoading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.rateLimitsAvailable=!1,this.rateLimits=[];return}if(!e.result){this.rateLimits=[],this.rateLimitError=e.error;return}if(this.rateLimitsAvailable=!0,e.status===`error`){this.rateLimitError=e.error;return}this.rateLimits=e.items}}openRateLimitForm(e){if(this.rateLimitEditing=!!e,this.rateLimitFormError=``,e){let t=Number(e.period_seconds||0);this.rateLimitEditingOriginal={scope:KE(e),subject:qE(e),period_seconds:t},this.rateLimitForm={scope:KE(e),subject:qE(e),period:eD(t),period_seconds:t,max_requests:e.max_requests===null||e.max_requests===void 0?``:String(e.max_requests),max_tokens:e.max_tokens===null||e.max_tokens===void 0?``:String(e.max_tokens),source:String(e.source||`manual`)}}else this.rateLimitEditingOriginal=null,this.rateLimitForm=UE();this.rateLimitFormOpen=!0}closeRateLimitForm(){this.rateLimitFormOpen=!1,this.rateLimitFormSubmitting=!1,this.rateLimitFormError=``,this.rateLimitEditing=!1,this.rateLimitEditingOriginal=null,this.rateLimitForm=UE(),this.rateLimitFormReturnToInspector&&(this.rateLimitFormReturnToInspector=!1,this.rateLimitInspectorOpen=!0)}rateLimitNormalizedIdentity(e,t,n){return dD(e,t,n)}rateLimitIdentityMoved(e){return fD(this.rateLimitEditingOriginal,e)}setRateLimitFormSubject(e){this.rateLimitForm.subject=String(e||``)}rateLimitFormPayload(){return pD(this.rateLimitForm)}async submitRateLimitForm(){if(this.rateLimitFormSubmitting)return;let{payload:e,error:t}=this.rateLimitFormPayload();if(t){this.rateLimitFormError=t;return}let n=this.rateLimitIdentityMoved(e),r=this.rateLimitEditingOriginal;this.rateLimitFormSubmitting=!0,this.rateLimitFormError=``;try{let t=await vT(`/admin/rate-limits`,`PUT`,e,{label:`save rate limit`,errorFallback:`Unable to save rate limit.`,unavailableStatuses:[]});if(t.status===`stale`)return;if(t.status!==`ok`){this.rateLimitFormError=t.error;return}if(this.rateLimits=uD(t.result.data),n&&!await this.deleteMovedRateLimitOriginal(r))return;this.closeRateLimitForm(),q.success(n?`Rate limit moved; live counters restarted.`:`Rate limit saved.`)}finally{this.rateLimitFormSubmitting=!1}}async deleteMovedRateLimitOriginal(e){let t=await vT(`/admin/rate-limits`,`DELETE`,{scope:e.scope,subject:e.subject,limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`remove the moved rate limit`,errorFallback:`The new rule was saved, but the previous one could not be removed. Delete it manually.`,unavailableStatuses:[]});return t.status===`stale`?!1:t.status===`ok`?(this.rateLimits=uD(t.result.data),!0):(this.rateLimitFormError=t.error,!1)}async deleteRateLimit(e){let t=nD(e);if(this.rateLimitDeletingKey===t)return;this.rateLimitDeletingKey=t;let n=await vT(`/admin/rate-limits`,`DELETE`,{scope:KE(e),subject:qE(e),limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`delete rate limit`,errorFallback:`Unable to delete rate limit.`,unavailableStatuses:[]});if(this.rateLimitDeletingKey=``,n.status!==`stale`){if(n.status!==`ok`){q.error(n.error);return}this.rateLimits=uD(n.result.data),q.success(`Rate limit deleted.`)}}async resetRateLimit(e){let t=nD(e);if(this.rateLimitResettingKey===t)return;this.rateLimitResettingKey=t;let n=await vT(`/admin/rate-limits/reset-one`,`POST`,{scope:KE(e),subject:qE(e),period_seconds:Number(e.period_seconds||0)},{label:`reset rate limit`,errorFallback:`Unable to reset rate limit.`,unavailableStatuses:[]});if(this.rateLimitResettingKey=``,n.status!==`stale`){if(n.status!==`ok`){q.error(n.error);return}this.rateLimits=uD(n.result.data),q.success(`Rate limit counters reset.`)}}rateLimitInspectorModelID(e){return String(e&&e.model&&e.model.id||``).trim()}openRateLimitInspectorForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`model`,provider:n,model:t,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}openRateLimitInspectorForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`provider`,provider:t,model:``,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}showRateLimitInspector(){this.rateLimitInspectorOpen=!0,this.fetchRateLimitsPage()}closeRateLimitInspector(){this.rateLimitInspectorOpen=!1}rateLimitRuleMatchesModel(e,t,n){return mD(e,t,n)}rateLimitRuleMatchesProvider(e,t){return hD(e,t)}rateLimitInspectorQualifiedModel(){return gD(this.rateLimitInspector)}rateLimitInspectorSections(){return _D(this.rateLimitInspector,this.rateLimits)}rateLimitPressurePercent(e){return vD(e)}rateLimitPressureStyle(e){return yD(e)}rateLimitPressureClass(e){return bD(e)}rateLimitGaugeCache={rules:null,states:{}};rateLimitGaugeMemo(e,t){this.rateLimitGaugeCache.rules!==this.rateLimits&&(this.rateLimitGaugeCache={rules:this.rateLimits,states:{}});let n=this.rateLimitGaugeCache.states;return e in n||(n[e]=t()),n[e]}rateLimitGaugeClassForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase(),r=this.rateLimits;return this.rateLimitGaugeMemo(`model:`+n+`/`+t,()=>SD(r,n,t))}rateLimitGaugeClassForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase(),n=this.rateLimits;return this.rateLimitGaugeMemo(`provider:`+t,()=>CD(n,t))}hasGlobalRateLimits(){let e=this.rateLimits;return this.rateLimitGaugeMemo(`global`,()=>xD(e))}rateLimitGaugeTitle(e,t){return wD(e,t)}rateLimitInspectorSummary(e){return TD(e)}openRateLimitFormFromInspector(e,t,n){this.rateLimitInspectorOpen=!1,this.rateLimitFormReturnToInspector=!0,this.openRateLimitForm(n||void 0),n||(this.rateLimitForm.scope=e,this.rateLimitForm.subject=t)}},ED=R(``),DD=R(``),OD=R(``),kD=R(``),AD=R(``),jD=R(``),MD=R(``),ND=R(`

                Scope, subject, and period identify the rule: changing any of them + moves the rule to a new key and restarts its live counters.

                `),PD=R(`

                A user path rule limits the whole subtree; provider and model rules cap + all traffic routed there and make load balancing skip the target while + it is saturated. One shared counter per rule. Leave a field empty to + skip that limit. Token limits require usage tracking.

                `,1);function FD(e,t){E(t,!0);{let t=O(()=>X.rateLimitEditing?`Edit Rate Limit`:`Create Rate Limit`);bE(e,{get open(){return X.rateLimitFormOpen},get title(){return I(t)},ariaLabel:`Rate limit editor`,get error(){return X.rateLimitFormError},get submitting(){return X.rateLimitFormSubmitting},submitLabel:`Save Rate Limit`,dialogClass:`budget-editor`,novalidate:!0,onclose:()=>X.closeRateLimitForm(),onsubmit:()=>X.submitRateLimitForm(),children:(e,t)=>{var n=PD(),r=N(n),i=M(r);SE(i,{id:`rate-limit-scope`,label:`Scope`,children:(e,t)=>{var n=DD();H(n,21,()=>X.rateLimitScopeOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitScope()),Gi(n,()=>X.rateLimitForm.scope,e=>X.rateLimitForm.scope=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);{let e=O(()=>X.rateLimitSubjectFieldLabel());SE(a,{id:`rate-limit-subject`,get label(){return I(e)},children:(e,t)=>{var n=OD();na(n),F(e=>{W(n,`placeholder`,e),W(n,`data-modal-autofocus`,!X.rateLimitEditing||void 0),ra(n,X.rateLimitForm.subject)},[()=>X.rateLimitSubjectPlaceholder()]),L(`input`,n,e=>X.setRateLimitFormSubject(e.currentTarget.value)),z(e,n)},$$slots:{default:!0}})}var o=P(a,2);SE(o,{id:`rate-limit-period`,label:`Period`,children:(e,t)=>{var n=kD();H(n,21,()=>X.rateLimitPeriodOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitPeriodSeconds()),Gi(n,()=>X.rateLimitForm.period,e=>X.rateLimitForm.period=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=e=>{SE(e,{id:`rate-limit-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=AD();na(n),da(n,()=>X.rateLimitForm.period_seconds,e=>X.rateLimitForm.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(s,e=>{X.rateLimitForm.period===`custom`&&e(c)});var l=P(s,2);{let e=O(()=>X.rateLimitForm.period===`concurrent`?`Max In-Flight Requests`:`Max Requests`);SE(l,{id:`rate-limit-max-requests`,get label(){return I(e)},children:(e,t)=>{var n=jD();na(n),F(()=>W(n,`data-modal-autofocus`,X.rateLimitEditing?!0:void 0)),da(n,()=>X.rateLimitForm.max_requests,e=>X.rateLimitForm.max_requests=e),z(e,n)},$$slots:{default:!0}})}var u=P(l,2),d=e=>{SE(e,{id:`rate-limit-max-tokens`,label:`Max Tokens`,children:(e,t)=>{var n=MD();na(n),da(n,()=>X.rateLimitForm.max_tokens,e=>X.rateLimitForm.max_tokens=e),z(e,n)},$$slots:{default:!0}})};V(u,e=>{X.rateLimitForm.period!==`concurrent`&&e(d)}),T(r);var f=P(r,4),p=e=>{z(e,ND())};V(f,e=>{X.rateLimitEditing&&e(p)}),z(e,n)},$$slots:{default:!0}})}D()}Hr([`change`,`input`]);var ID=R(` `),LD=R(` Edit`,1),RD=R(` `,1),zD=R(`
                In-flight
                `),BD=R(`
                Requests
                `),VD=R(`
                Tokens
                `),HD=R(`
                `),UD=R(`
                `);function WD(e,t){E(t,!0);var n=UD();H(n,21,()=>t.rules,e=>X.rateLimitKey(e),(e,t)=>{var n=HD(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=e=>{var n=ID(),r=M(n);{let e=O(()=>X.rateLimitScope(I(t))===`provider`?bo:Fa);G(r,{get icon(){return I(e)},class:`budget-period-icon`})}var i=P(r,2),a=M(i,!0);T(i),T(n),F((e,t)=>{W(n,`title`,e),B(a,t)},[()=>`Rule scope: `+X.rateLimitScopeLabel(I(t)),()=>X.rateLimitScopeLabel(I(t))]),z(e,n)},u=O(()=>X.rateLimitScope(I(t))!==`user_path`);V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=M(d);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?Ma:ko);G(f,{get icon(){return I(e)},class:`budget-period-icon`})}var p=P(f,2),m=M(p,!0);T(p),T(d),T(s);var h=P(s,2),g=M(h),_=M(g),v=M(_,!0);T(_),T(g);var y=P(g,2),b=M(y),x=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitForm(I(t)),children:(e,t)=>{var n=LD();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},S=O(()=>!X.rateLimitIsReadOnly(I(t)));V(b,e=>{I(S)&&e(x)});var C=P(b,2);{let e=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting counters`:`Reset counters`),n=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t)));gT(C,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>X.resetRateLimit(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=RD(),i=N(r);G(i,{get icon(){return go},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var w=P(C,2),ee=e=>{{let n=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting rate limit`:`Delete rate limit`),r=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>X.deleteRateLimit(I(t)),get disabled(){return I(r)},children:(e,n)=>{var r=RD(),i=N(r);G(i,{get icon(){return Ao},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}},te=O(()=>!X.rateLimitIsReadOnly(I(t)));V(w,e=>{I(te)&&e(ee)}),T(y),T(h),T(i);var ne=P(i,2),re=M(ne),ie=e=>{var n=zD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u),T(l),T(o),T(n),F((e,t,n,r,i,l)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l)},[()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests),()=>`In-flight requests: `+X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` in flight`]),z(e,n)},ae=O(()=>X.rateLimitIsConcurrent(I(t)));V(re,e=>{I(ae)&&e(ie)});var oe=P(re,2),se=e=>{var n=BD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests),()=>`Requests used: `+X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` requests`,()=>X.formatRateLimitNumber(I(t).requests_remaining)+` left`]),z(e,n)},ce=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_requests);V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{var n=VD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens),()=>`Tokens used: `+X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)>=100}),()=>X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens)+` tokens`,()=>X.formatRateLimitNumber(I(t).tokens_remaining)+` left`]),z(e,n)},de=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_tokens);V(le,e=>{I(de)&&e(ue)}),T(ne),T(r),T(n),F((e,t,n,r,i)=>{W(a,`title`,e),B(o,t),B(m,n),W(_,`title`,r),B(v,i)},[()=>X.rateLimitScopeLabel(I(t))+`: `+X.rateLimitSubject(I(t)),()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n),D()}var GD=R(`

                Rate Limits

                `),KD=R(``),qD=R(`
                Rate limit management is unavailable.
                `),JD=R(``),YD=R(`
                `),XD=R(`

                No rate limits configured yet.

                `),ZD=R(`

                No rate limits match your filter.

                `),QD=R(`
                `);function $D(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`rate-limits`&&X.fetchRateLimitsPage()});let n=O(()=>X.filteredRateLimits());var r=QD(),i=M(r),a=M(i);qS(M(a),{copyId:`rate-limits-help-copy`,label:`rate limits help`,text:`Rate limits cap requests, tokens, and in-flight concurrency for a user path subtree, a provider, or a model. Consumer (user path) breaches return 429 with Retry-After and x-ratelimit-* headers; saturated providers and models are skipped by load balancing and failover while capacity exists elsewhere. Counters are per gateway instance and reset on restart; token limits need usage tracking.`,title:e=>{z(e,GD())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=KD();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=X.rateLimitFormSubmitting),L(`click`,t,()=>X.openRateLimitForm()),z(e,t)},l=O(()=>X.rateLimitsEnabled()&&X.rateLimitsAvailable&&!K.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Fc(u,{});var d=P(u,2),f=e=>{z(e,qD())},p=O(()=>(!X.rateLimitsEnabled()||!X.rateLimitsAvailable)&&!K.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=JD(),n=M(t,!0);T(t),F(()=>B(n,X.rateLimitError)),z(e,t)};V(m,e=>{X.rateLimitError&&!K.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading rate limits...`})};V(g,e=>{X.rateLimitsLoading&&!K.authError&&e(_)});var v=P(g,2),y=e=>{var t=YD(),n=M(t);yw(M(n),{id:`rate-limit-filter`,placeholder:`Filter by subject, scope, or period...`,label:`Filter rate limits by subject, scope, or period`,get value(){return X.rateLimitFilter},set value(e){X.rateLimitFilter=e}}),T(n),T(t),z(e,t)};V(v,e=>{(X.rateLimits.length>0||X.rateLimitFilter)&&X.rateLimitsAvailable&&!K.authError&&!X.rateLimitFormOpen&&e(y)});var b=P(v,2);FD(b,{});var x=P(b,2),S=e=>{WD(e,{get rules(){return I(n)}})};V(x,e=>{I(n).length>0&&X.rateLimitsAvailable&&!K.authError&&e(S)});var C=P(x,2),w=e=>{z(e,XD())},ee=O(()=>X.rateLimits.length===0&&!X.rateLimitFilter&&!X.rateLimitsLoading&&!K.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,ZD())},re=O(()=>X.rateLimits.length>0&&I(n).length===0&&X.rateLimitFilter&&!X.rateLimitsLoading&&!K.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function eO(e){return String(e||``).trim().toLowerCase()}function tO(e){if(!e)return``;let t=String(e.selector||``).trim();if(t)return t;if(!e.model||!e.model.id)return``;let n=String(e.model.id||``).trim(),r=String(e.provider_name||``).trim();if(r)return r+`/`+n;let i=String(e.provider_type||``).trim();return!i||n.includes(`/`)?n:i+`/`+n}function nO(e,t,n,r){let i=new Set,a=String(e||``).trim().toLowerCase(),o=String(t||``).trim().toLowerCase(),s=String(n||``).trim().toLowerCase(),c=String(r||``).trim().toLowerCase();if(c&&i.add(c),!a)return i;i.add(a),s&&i.add(s+`/`+a),o&&!a.includes(`/`)&&i.add(o+`/`+a);let l=a.split(`/`);return l.length===2&&l[1]&&i.add(l[1]),i}function rO(e){return nO(e&&e.model?e.model.id:``,e?e.provider_type:``,e?e.provider_name:``,e?e.selector:``)}function iO(e){let t=new Set,n=String(e.resolved_model||``).trim().toLowerCase(),r=String(e.target_model||``).trim().toLowerCase(),i=String(e.target_provider||``).trim().toLowerCase();if(n){t.add(n);let e=n.split(`/`);e.length===2&&e[1]&&t.add(e[1])}if(r){t.add(r);let e=r.split(`/`);e.length===2&&e[1]&&t.add(e[1])}return r&&i&&t.add(i+`/`+r),t}function aO(e){if(!e)return``;let t=String(e.provider||``).trim(),n=String(e.model||``).trim();return!t||!n||n===t||n.startsWith(t+`/`)?n:t+`/`+n}function oO(e){if(e===``||e==null)return null;let t=Number(e);return!Number.isFinite(t)||t<=0?null:t}function sO(e,t){let n={model:e},r=oO(t);return r!==null&&(n.weight=r),n}function cO(e){let t=Array.isArray(e)?e:[],n=[];for(let e of t){let t=String(e&&e.model||``).trim();t&&n.push(sO(t,e&&e.weight))}return n}function lO(e){switch(String(e||``).toLowerCase()){case`cost`:return`lowest cost`;case`round_robin`:case``:return`round robin`;default:return e}}var uO={round_robin:`Round-robin (rotate across targets; honors weights)`,cost:`Lowest cost (cheapest target per request)`,adaptive:`Adaptive (target chosen by the registered routing extension)`};function dO(e,t){let n=Array.isArray(e)?[...e]:[],r=String(t||``).trim().toLowerCase();return r&&!n.includes(r)&&n.push(r),n.map(e=>({value:e,label:uO[e]||e}))}function fO(e){let t=Array.isArray(e.targets)?e.targets:[],n=t.length>0?t[0]:{},r=t.map(e=>{let t={provider:e.provider||``,model:e.model||``};return e.weight&&(t.weight=e.weight),t});return{name:e.source,target_provider:n.provider||``,target_model:n.model||``,targets:r,strategy:e.strategy||``,session_affinity:e.session_affinity!==!1,description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,valid:!!e.valid,resolved_model:e.resolved_model||``,provider_type:e.provider_type||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[]}}function pO(e){let t=Array.isArray(e)?e:[],n=[],r=[];for(let e of t)!e||typeof e!=`object`||(e.kind===`redirect`?n.push(fO(e)):e.kind===`policy`&&r.push({selector:e.source,provider_name:e.provider_name||``,model:e.model||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[],description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,scope_kind:e.scope_kind||``}));return{aliases:n,policies:r}}function mO(e){if(!e)return`—`;let t=Array.isArray(e.targets)?e.targets:[];return t.length>1?t.length+` targets · `+lO(e.strategy):e.resolved_model?e.resolved_model:e.target_provider?e.target_provider+`/`+e.target_model:e.target_model||`—`}function hO(e){return e?e.enabled===!1?`is-disabled`:e.valid?`is-valid`:`is-invalid`:`is-invalid`}function gO(e){return e?e.enabled===!1?`Disabled`:e.valid?`Active`:`Invalid`:`Invalid`}function _O(e){return Array.isArray(e)&&e.length>0&&e.indexOf(`/`)===-1}function vO(e,t){return!t||!e?``:e.effective_enabled===!1?`is-disabled`:_O(e.user_paths)?`is-restricted`:`is-enabled`}function yO(e){if(!e)return``;let t=[];e.effective_enabled===!1&&t.push(e.default_enabled===!1?`Disabled by default`:`Disabled`);let n=Array.isArray(e.user_paths)?e.user_paths:[];return n.length>0&&t.push(`Allowed for `+n.join(`, `)),t.join(` · `)}function bO({models:e,aliases:t,virtualModelsAvailable:n,activeCategory:r}){let i=Array.isArray(e)?e:[],a=Array.isArray(t)?t:[],o=new Map;if(n)for(let e of a){let t=eO(e&&e.name);!t||e.enabled===!1||!e.valid||o.set(t,e)}let s=new Map,c=i.map(e=>{let t=tO(e),n=null;for(let t of rO(e))s.has(t)||s.set(t,e),!n&&o.has(t)&&(n=o.get(t));let r=e&&e.access?e.access:null;return{key:`model:`+t,display_name:t,secondary_name:``,provider_name:e.provider_name||``,provider_type:e.provider_type||``,model:e.model,selector:e.selector||``,is_alias:!1,alias:null,access:r,masking_alias:n,has_virtual_model:!!(n||r&&r.override),alias_state_class:``,alias_state_text:``}});if(!n)return c;for(let e of a){let t=s.get(eO(e&&e.name));if(e&&e.enabled!==!1&&e.valid&&t)continue;let n=null;for(let t of iO(e))if(n=s.get(t)||null,n)break;!n&&r&&r!==`all`||c.push({key:`alias:`+e.name,display_name:e.name,secondary_name:mO(e),provider_name:n&&n.provider_name||``,provider_type:n?n.provider_type||e.provider_type||``:e.provider_type||``,model:n?n.model:{id:e.name,object:`model`},selector:``,is_alias:!0,alias:e,access:null,masking_alias:null,source_model_exists:!!t,has_virtual_model:!0,alias_state_class:hO(e),alias_state_text:gO(e)})}return c.sort((e,t)=>e.is_alias===t.is_alias?String(e.display_name||``).localeCompare(String(t.display_name||``)):e.is_alias?-1:1)}function xO(e,t){if(!t)return e;let n=String(t).toLowerCase();return e.filter(e=>[e.display_name,e.secondary_name,e.provider_name,e.provider_type,e.model&&e.model.owned_by,e.alias&&e.alias.description,e.alias&&e.alias_state_text,e.model&&e.model.metadata&&e.model.metadata.modes?e.model.metadata.modes.join(`,`):``,e.model&&e.model.metadata&&e.model.metadata.categories?e.model.metadata.categories.join(`,`):``].some(e=>String(e||``).toLowerCase().includes(n)))}function SO(e,t){return String(e||``).trim()||String(t||``).trim()||`Unassigned`}function CO(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!r||r===n?``:r}function wO(e){let t=String(e||``).trim();return t?t+`/`:``}function TO(e){let t=Array.isArray(e)?e:[],n=t.filter(e=>e&&!e.is_alias).length,r=t.filter(e=>e&&e.is_alias).length,i=[];return n>0&&i.push(n+(n===1?` model`:` models`)),r>0&&i.push(r+(r===1?` alias`:` aliases`)),i.join(` · `)}function EO(e,t,n){let r=String(t||``).trim(),i=String(n||``).trim();for(let t of Array.isArray(e)?e:[]){let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim();if(!(r&&e!==r)&&!(!r&&i&&n!==i)&&t&&t.access)return t.access.default_enabled!==!1}return!0}function DO(e){for(let t of Array.isArray(e)?e:[])if(t&&t.access)return t.access.default_enabled!==!1;return!0}function OO(e,t){let n=String(t||``).trim();if(!n)return null;for(let t of Array.isArray(e)?e:[])if(String(t&&t.selector||``).trim()===n)return t;return null}function kO(e,t,n,r){let i=wO(t),a=r&&r.get(`/`)||null,o=i&&r&&r.get(i)||null,s=EO(e,t,n),c=o||a,l=c&&Array.isArray(c.user_paths)?Array.from(new Set(c.user_paths)).sort():[];return{selector:i,default_enabled:s,effective_enabled:c?c.enabled!==!1:s,user_paths:l,override:o}}function AO(e,t,n){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let e of Array.isArray(n)?n:[]){let t=String(e&&e.selector||``).trim();t&&r.set(t,e)}let i=[],a=new Map;for(let t of e){if(t&&t.is_alias){i.push(t);continue}let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim(),r=`provider-group:`+(e||n||`unassigned`);a.has(r)||a.set(r,{key:r,provider_name:e,provider_type:n,display_name:SO(e,n),type_label:CO(e,n),rows:[]});let o=a.get(r);!o.provider_name&&e&&(o.provider_name=e),!o.provider_type&&n&&(o.provider_type=n),o.display_name=SO(o.provider_name,o.provider_type),o.type_label=CO(o.provider_name,o.provider_type),o.rows.push(t)}let o=Array.from(a.values()).map(e=>{let n=kO(t,e.provider_name,e.provider_type,r);return{...e,access:n,access_summary:yO(n),item_count_label:TO(e.rows)}}).sort((e,t)=>String(e.display_name||``).localeCompare(String(t.display_name||``)));return i.length>0&&o.unshift({key:`virtual-model-group`,is_virtual_models:!0,provider_name:``,provider_type:``,display_name:`Virtual models`,type_label:``,rows:i,access:{selector:``},access_summary:``,item_count_label:TO(i)}),o}function jO(e,t){let n=OO(t,`/`),r=DO(e),i=n&&Array.isArray(n.user_paths)?n.user_paths:[];return{key:`scope-global`,is_alias:!1,display_name:`all providers and models`,access:{selector:`/`,default_enabled:r,effective_enabled:n?n.enabled!==!1:r,user_paths:i,override:n}}}function MO(e){return e?String(e.access&&e.access.selector||``).trim()||String(e.override_selector||``).trim()||tO(e):``}function NO(e){if(!e)return[];let t=[];return e.is_alias?t.push(`alias-row`,hO(e.alias)):e.has_virtual_model&&t.push(`alias-row`,`is-valid`),!e.is_alias&&e.masking_alias&&t.push(`masked-model-row`),!e.is_alias&&e.access&&e.access.effective_enabled===!1&&t.push(`model-access-disabled-row`),t}function PO(e){return!!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)}function FO(e){return!!(e&&!e.is_alias&&e.masking_alias&&e.masking_alias.name&&!e.masking_alias.managed)}function IO(e){return e&&e.is_alias&&e.alias&&e.alias.name?`alias-row-`+String(e.alias.name).replace(/[^a-zA-Z0-9_-]+/g,`-`):``}function LO(e){return e?e.is_alias?!!(e.alias&&e.alias.managed):!!(e.access&&e.access.override&&e.access.override.managed||e.masking_alias&&e.masking_alias.managed):!1}function RO(e){return!!(e&&e.override)}function zO(e){return e?`table-action-btn-active`:``}function BO(e,t){let n=`Edit `+String(e||`model access`);return t?n+` (virtual model exists)`:n}function VO(){return{source:``,target_model:``,target_weight:1,targets:[],strategy:`round_robin`,session_affinity:!0,user_paths:``,description:``,enabled:!0}}function HO(e){return String(e&&e.target_model||``).trim()!==``}function UO(e){return String(e&&e.target_model||``).trim()?!0:cO(e&&e.targets).length>0}function WO(e){return!!e&&Array.isArray(e.targets)&&e.targets.length>0}function GO(e){return WO(e)&&String(e&&e.strategy||``).toLowerCase()!==`cost`}function KO(e){let t=Array.isArray(e.targets)?e.targets:[];if(t.length>0){let n=t.shift();e.target_model=n.model||``,e.target_weight=n.weight||1;return}e.target_model=``,e.target_weight=1}function qO(e){let t=Array.isArray(e&&e.targets)?e.targets:[];return t.length>0?{primaryModel:aO(t[0]),primaryWeight:t[0].weight||1,extraTargets:t.slice(1).map(e=>({model:aO(e),weight:e.weight||1}))}:{primaryModel:e&&e.target_provider?e.target_provider+`/`+e.target_model:e&&e.target_model||``,primaryWeight:1,extraTargets:[]}}function JO(e){return String(e||``).split(/\r?\n|,/).map(e=>String(e||``).trim()).filter(Boolean)}function YO(e,t,n){let r=String(e&&e.source||``).trim(),i=String(e&&e.target_model||``).trim(),a=cO(e&&e.targets),o=UO(e),s=String(t||``).trim(),c=n===`edit`&&!!s&&r!==s,l={source:r,user_paths:JO(e&&e.user_paths),description:String(e&&e.description||``).trim(),enabled:!!(e&&e.enabled)};if(c&&(l.old_source=s),o){let t=[];if(i&&t.push(sO(i,e.target_weight)),t.push(...a),t.length>1){let n=e.strategy||`round_robin`;l.targets=n===`cost`?t.map(e=>({model:e.model})):t,l.strategy=n,e&&e.session_affinity===!1&&(l.session_affinity=!1)}else l.target_model=t[0].model}return{payload:l,source:r,isRedirect:o,isRename:c}}function XO(e){let t={source:e.name,description:String(e.description||``).trim(),user_paths:Array.isArray(e.user_paths)?e.user_paths:[],enabled:e.enabled===!1},n=Array.isArray(e.targets)?e.targets:[];return n.length>1?(t.strategy=e.strategy||`round_robin`,e.session_affinity===!1&&(t.session_affinity=!1),t.targets=t.strategy===`cost`?n.map(e=>({model:aO(e)})):n.map(e=>sO(aO(e),e.weight))):n.length===1?t.target_model=aO(n[0]):t.target_model=e.target_provider?e.target_provider+`/`+e.target_model:e.target_model,t}function ZO(e,t,n){let r=n||{},i=r.effective_enabled===!1,a=t&&Array.isArray(t.user_paths)?t.user_paths:[],o=`PUT`,s;return i===!1?s={source:e,enabled:!1,user_paths:a}:t&&a.length===0&&r.default_enabled!==!1?(o=`DELETE`,s={source:e}):s={source:e,enabled:!0,user_paths:a},{method:o,payload:s,desired:i}}function QO(e,t,n){let r=Math.max(1,Number(t||75)),i=Math.min(n,e+r);return{limit:i,rendering:ibO({models:Nc.models,aliases:this.aliases,virtualModelsAvailable:this.virtualModelsAvailable,activeCategory:Nc.activeCategory}));get displayModels(){return I(this.#T)}set displayModels(e){A(this.#T,e)}#E=O(()=>AO(this.displayModels,Nc.models,this.modelOverrideViews));get displayModelGroups(){return I(this.#E)}set displayModelGroups(e){A(this.#E,e)}#D=O(()=>xO(this.displayModels,Nc.filter));get filteredDisplayModels(){return I(this.#D)}set filteredDisplayModels(e){A(this.#D,e)}#O=O(()=>{let e=this.filteredDisplayModels,t=Math.max(0,Math.min(Number(this.modelRenderLimit||0),e.length));return!Nc.filter&&t>=this.displayModels.length?this.displayModelGroups:AO(e.slice(0,t),Nc.models,this.modelOverrideViews)});get filteredDisplayModelGroups(){return I(this.#O)}set filteredDisplayModelGroups(e){A(this.#O,e)}#k=O(()=>jO(Nc.models,this.modelOverrideViews));get globalScopeRow(){return I(this.#k)}set globalScopeRow(e){A(this.#k,e)}modelsBusy(){return!!(Nc.loading||this.modelsRendering)}modelLoadingText(){if(Nc.loading)return this.displayModels.length>0?`Refreshing models...`:`Loading models...`;let e=this.filteredDisplayModels.length;return`Rendering models... `+Math.min(Number(this.modelRenderLimit||0),e)+` / `+e}restartModelRendering(e){let t=++this.#a,n=$O(this.modelRenderBatchSize,e);this.modelRenderLimit=n.limit,this.modelsRendering=n.rendering,n.rendering&&this.#A(t)}stopModelRendering(){this.#a++,this.modelsRendering=!1}#A(e){let t=()=>{if(e!==this.#a)return;let t=QO(this.modelRenderLimit,this.modelRenderBatchSize,this.filteredDisplayModels.length);this.modelRenderLimit=t.limit,this.modelsRendering=t.rendering,t.rendering&&this.#A(e)};typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>setTimeout(t,0)):setTimeout(t,0)}async fetchVirtualModels(){this.aliasLoading=!0,this.aliasError=``;try{let e=await _s(`/admin/virtual-models`,{label:`virtual models`});if(e.status===503){this.virtualModelsAvailable=!1,this.aliases=[],this.modelOverrideViews=[];return}if(e.stale)return;if(this.virtualModelsAvailable=!0,!e.ok){this.aliases=[],this.modelOverrideViews=[];return}let{aliases:t,policies:n}=pO(e.data);this.aliases=t,this.modelOverrideViews=n}catch(e){console.error(`Failed to fetch virtual models:`,e),this.aliases=[],this.modelOverrideViews=[],this.aliasError=`Unable to load virtual models.`}finally{this.aliasLoading=!1}}qualifiedModelName(e){return tO(e)}findModelOverrideView(e){return OO(this.modelOverrideViews,e)}hasGlobalModelOverride(){return!!this.findModelOverrideView(`/`)}findExistingAliasByName(e){let t=eO(e);if(!t)return null;for(let e of this.aliases)if(eO(e&&e.name)===t)return e;return null}findConcreteModelByName(e){let t=eO(e);if(!t)return null;for(let e of Nc.models)if(rO(e).has(t))return e;return null}rowToggleEnabled(e){return e?e.is_alias?e.alias&&e.alias.enabled!==!1:!!(e.access&&e.access.effective_enabled!==!1):!1}rowToggleLabel(e){return this.rowTogglingKey&&this.rowTogglingKey===e.key?`Updating...`:this.rowToggleRestricted(e)?`Restricted`:this.rowToggleEnabled(e)?`Enabled`:`Disabled`}rowToggleRestricted(e){return!!e&&!e.is_alias&&vO(e.access,this.virtualModelsAvailable)===`is-restricted`}rowToggleAriaLabel(e){if(!e)return``;let t=this.rowToggleEnabled(e)?`Disable `:`Enable `,n;return n=e.is_alias?`alias `+String(e.alias&&e.alias.name||``):String(e.display_name||e.access&&e.access.selector||`model`),t+n.trim()}async toggleRowEnabled(e){if(this.virtualModelsAvailable&&!(!e||this.rowTogglingKey===e.key)){if(LO(e)){q.success(`This virtual model is managed by configuration and is read-only.`);return}if(e.is_alias){await this.toggleAliasRow(e);return}await this.toggleModelRow(e)}}async toggleAliasRow(e){let t=e.alias;if(!t||!t.name)return;this.rowTogglingKey=e.key;let n=XO(t);try{let e=await vs(`/admin/virtual-models`,`PUT`,n,{label:`alias state`});if(e.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(e.stale)return;if(!e.ok){q.error(e.status===401?`Authentication required.`:ps(e,`Failed to update alias state.`));return}q.success(n.enabled?`Alias enabled.`:`Alias disabled.`),this.fetchVirtualModels()}catch(e){console.error(`Failed to toggle alias state:`,e),q.error(`Failed to update alias state.`)}finally{this.rowTogglingKey=``}}async toggleModelRow(e){let t=MO(e);if(!t)return;let{method:n,payload:r,desired:i}=ZO(t,this.findModelOverrideView(t),e.access||{});this.rowTogglingKey=e.key;try{let e=await vs(`/admin/virtual-models`,n,r,{label:`model access`});if(e.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(!(n===`DELETE`&&e.status===404)){if(e.stale)return;if(!e.ok){q.error(e.status===401?`Authentication required.`:ps(e,`Failed to update model access.`));return}}q.success(i?`Model enabled.`:`Model disabled.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to toggle model access:`,e),q.error(`Failed to update model access.`)}finally{this.rowTogglingKey=``}}async removeAliasRow(e){if(!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)||this.rowDeletingKey)return;let t=String(e.alias.name||``).trim();t&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the virtual model alias "`+t+`"?`,method:`DELETE`,payload:{source:t},operation:`virtual model`,failureMessage:`Failed to remove virtual model.`,notice:`Virtual model removed.`,ignoreNotFound:!0})}async removeRedirectRow(e){let t=e&&e.masking_alias;if(!(e&&!e.is_alias&&t&&t.name&&!t.managed)||this.rowDeletingKey)return;let n=String(t.name||``).trim();n&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the redirect for "`+n+`"? Other virtual model settings will be preserved.`,method:`PUT`,payload:{source:n,user_paths:Array.isArray(t.user_paths)?t.user_paths:[],description:String(t.description||``).trim(),enabled:t.enabled!==!1},operation:`virtual model redirect`,failureMessage:`Failed to remove redirect.`,notice:`Redirect removed. Other virtual model settings were preserved.`})}async mutateVirtualModelRow(e){if(!this.rowDeletingKey&&window.confirm(e.confirmMessage)){this.rowDeletingKey=e.rowKey;try{let t=await vs(`/admin/virtual-models`,e.method,e.payload,{label:e.operation});if(t.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(!(e.ignoreNotFound&&t.status===404)){if(t.stale)return;if(!t.ok){q.error(t.status===401?`Authentication required.`:ps(t,e.failureMessage));return}}this.virtualModelsAvailable=!0,q.success(e.notice),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(t){console.error(e.failureMessage,t),q.error(e.failureMessage)}finally{this.rowDeletingKey=``}}}addVmTarget(){Array.isArray(this.vmForm.targets)||(this.vmForm.targets=[]),this.vmForm.targets.push({model:``,weight:1})}removeVmTarget(e){Array.isArray(this.vmForm.targets)&&this.vmForm.targets.splice(e,1)}removePrimaryTarget(){KO(this.vmForm)}vmFormHasPrimaryTarget(){return HO(this.vmForm)}vmFormShowStrategy(){return WO(this.vmForm)}vmStrategyOptions(){return dO(Ss.virtualModelStrategies(),this.vmForm.strategy)}vmFormShowWeights(){return GO(this.vmForm)}vmFormToggleRestricted(){return!!(this.vmForm&&this.vmForm.enabled)&&_O(JO(this.vmForm.user_paths))}vmFormToggleLabel(){return!this.vmForm||!this.vmForm.enabled?`Disabled`:this.vmFormToggleRestricted()?`Restricted`:`Enabled`}resetVirtualModelForm(){this.vmFormError=``,this.vmFormHelpOpen=!1,this.vmFormUserPathsHelpOpen=!1,this.vmSubmitting=!1,this.vmDeleting=!1,this.vmFormHasExisting=!1,this.vmFormDefaultEnabled=!0,this.vmFormEffectiveEnabled=!0,this.vmFormDisplayName=``,this.vmFormSourceLocked=!1,this.vmFormOriginalSource=``,this.vmFormManaged=!1,this.vmForm=VO()}closeVirtualModelForm(){this.vmFormOpen=!1,this.resetVirtualModelForm()}openVirtualModelCreate(e){this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`create`,this.vmFormSourceLocked=!1,this.vmFormDisplayName=`New virtual model`,e&&e.model&&e.model.id&&(this.vmForm.target_model=tO(e))}openVirtualModelEditAlias(e){if(!e)return;this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!1,this.vmFormHasExisting=!0,this.vmFormManaged=!!e.managed,this.vmFormOriginalSource=e.name||``,this.vmFormDisplayName=e.name||``,this.vmFormDefaultEnabled=DO(Nc.models),this.vmFormEffectiveEnabled=e.enabled!==!1;let{primaryModel:t,primaryWeight:n,extraTargets:r}=qO(e);this.vmForm={source:e.name||``,target_model:t,target_weight:n,targets:r,strategy:e.strategy||`round_robin`,session_affinity:e.session_affinity!==!1,user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` +`),description:e.description||``,enabled:e.enabled!==!1}}openVirtualModelEditModel(e){if(!e||e.is_alias)return;let t=e.access||{},n=t.override||null,r=n&&Array.isArray(n.user_paths)?n.user_paths:Array.isArray(t.user_paths)?t.user_paths:[],i=MO(e);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!n,this.vmFormOriginalSource=i;let a=n?n.enabled!==!1:t.effective_enabled!==!1;this.vmFormDefaultEnabled=t.default_enabled!==!1,this.vmFormEffectiveEnabled=a,this.vmFormManaged=!!(n&&n.managed),this.vmFormDisplayName=e.access_display_name||e.display_name||i||``,this.vmForm={source:i,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:r.join(` +`),description:n&&n.description?n.description:``,enabled:a}}openGlobalModelOverrideEdit(){let e=this.findModelOverrideView(`/`),t=e&&Array.isArray(e.user_paths)?e.user_paths:[],n=DO(Nc.models);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!e,this.vmFormOriginalSource=`/`,this.vmFormDefaultEnabled=n,this.vmFormEffectiveEnabled=e?e.enabled!==!1:n,this.vmFormManaged=!!(e&&e.managed),this.vmFormDisplayName=`All providers and models`,this.vmForm={source:`/`,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:t.join(` +`),description:e&&e.description?e.description:``,enabled:e?e.enabled!==!1:n}}openProviderOverrideEdit(e){!e||!e.access||!e.access.selector||this.openVirtualModelEditModel({display_name:e.display_name,access_display_name:`All models in `+e.display_name,provider_name:e.provider_name,provider_type:e.provider_type,access:e.access,override_selector:e.access.selector,is_alias:!1})}async submitVirtualModelForm(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be edited here.`;return}let{payload:e,source:t,isRedirect:n,isRename:r}=YO(this.vmForm,this.vmFormOriginalSource,this.vmFormMode);if(!t){this.vmFormError=`Source is required.`;return}if(this.vmFormError=``,this.vmFormMode!==`edit`){let e=this.findExistingAliasByName(t),r=e?null:this.findModelOverrideView(t);if(e||r){let n=e?`A virtual model named "`+e.name+`" already exists. Saving will update that virtual model. Continue?`:`An access policy for "`+t+`" already exists. Saving will update that virtual model. Continue?`;if(!window.confirm(n)){this.vmFormError=`Choose a different source or edit the existing virtual model.`;return}}else if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Creating this alias will mask that model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}else if(r){let e=(this.aliases||[]).find(e=>e&&e.name===t)||null,r=e?null:this.findModelOverrideView(t);if(e||r){this.vmFormError=`A virtual model for "`+t+`" already exists. Choose a different source.`;return}if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Renaming to that name will mask the model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}this.vmSubmitting=!0;try{let t=await vs(`/admin/virtual-models`,`PUT`,e,{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:ps(t,`Failed to save virtual model.`);return}let r=!n&&t.status===204;this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),q.success(n?`Alias saved.`:r?`Model access reset to inherited/default.`:`Model access saved.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to save virtual model:`,e),this.vmFormError=`Failed to save virtual model.`}finally{this.vmSubmitting=!1}}async deleteVirtualModel(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be removed here.`;return}let e=String(this.vmForm.source||this.vmFormOriginalSource||``).trim();if(!(!e||!this.vmFormHasExisting)&&window.confirm(`Remove the virtual model for "`+e+`"? This reverts to inherited/default behavior.`)){this.vmDeleting=!0,this.vmFormError=``;try{let t=await vs(`/admin/virtual-models`,`DELETE`,{source:e},{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:ps(t,`Failed to remove virtual model.`);return}}this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),q.success(`Virtual model removed.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to delete virtual model:`,e),this.vmFormError=`Failed to remove virtual model.`}finally{this.vmDeleting=!1}}}},tk=[{value:`input_per_mtok`,label:`Input $/MTok`,group:`Tokens`},{value:`output_per_mtok`,label:`Output $/MTok`,group:`Tokens`},{value:`cached_input_per_mtok`,label:`Cached input $/MTok`,group:`Tokens`},{value:`cache_write_per_mtok`,label:`Cache write $/MTok`,group:`Tokens`},{value:`reasoning_output_per_mtok`,label:`Reasoning output $/MTok`,group:`Tokens`},{value:`batch_input_per_mtok`,label:`Batch input $/MTok`,group:`Batch`},{value:`batch_output_per_mtok`,label:`Batch output $/MTok`,group:`Batch`},{value:`audio_input_per_mtok`,label:`Audio input $/MTok`,group:`Audio`},{value:`audio_output_per_mtok`,label:`Audio output $/MTok`,group:`Audio`},{value:`per_image`,label:`$/Image`,group:`Image`},{value:`input_per_image`,label:`Input $/Image`,group:`Image`},{value:`per_second_input`,label:`Input $/Second`,group:`Audio/Video`},{value:`per_second_output`,label:`Output $/Second`,group:`Video`},{value:`per_character_input`,label:`$/Character`,group:`Audio`},{value:`per_page`,label:`$/Page`,group:`Utility`},{value:`per_request`,label:`$/Request`,group:`Utility`}];function nk(e){let t=tk.find(t=>t.value===e);return t?t.label:String(e||``).replace(/_/g,` `)}function rk(e){return e&&typeof e==`object`?JSON.parse(JSON.stringify(e)):{}}function ik(e,t){let n=rk(e),r=t&&t.pricing?t.pricing:t;if(!r||typeof r!=`object`)return n;for(let e of tk)r[e.value]!==null&&r[e.value]!==void 0&&(n[e.value]=Number(r[e.value]));return Array.isArray(r.tiers)&&r.tiers.length>0&&(n.tiers=rk(r.tiers)),n}function ak(e){switch(String(e||``).trim()){case`config_yaml`:return`config.yaml`;case`model_registry`:return`Model registry`;default:return e?String(e):`Unknown`}}function ok(e){let t=e&&e.pricing?e.pricing:{},n=e&&e.pricing_sources&&typeof e.pricing_sources==`object`?e.pricing_sources:{},r={};for(let e of tk)t[e.value]!==null&&t[e.value]!==void 0&&(r[e.value]=ak(n[e.value]||`model_registry`));return r}function sk(e){let t=String(e&&e.selector||``).trim();return t?`Dashboard/API override (`+t+`)`:`Dashboard/API override`}function ck(e){let t=String(e||``).trim();return t?t+`/`:``}function lk(e){return String(e&&e.model&&e.model.id||``).trim()}function uk(e){let t=String(e&&e.provider_name||``).trim(),n=lk(e);return t&&n?t+`/`+n:n}function dk(e){return lk(e)}function fk(e){let t=new Map;for(let n of Array.isArray(e)?e:[]){let e=String(n&&n.selector||``).trim();e&&t.set(e,n)}return t}function pk(e,t){let n=String(t||``).trim();return n&&fk(e).get(n)||null}function mk(e,t,n){let r=fk(e),i=uk(t),a=dk(t),o=ck(t&&t.provider_name),s=String(n||``).trim();for(let e of[i,a,o,`/`]){if(!e||e===s)continue;let t=r.get(e);if(t)return t}return null}function hk(e,t,n){let r=e&&e.model&&e.model.metadata?e.model.metadata:null,i=rk(r&&r.pricing),a=ok(r),o=mk(t,e,n),s=o&&o.pricing?o.pricing:null;if(s){let e=sk(o);for(let t of tk)s[t.value]!==null&&s[t.value]!==void 0&&(i[t.value]=Number(s[t.value]),a[t.value]=e);Array.isArray(s.tiers)&&s.tiers.length>0&&(i.tiers=rk(s.tiers),a.tiers=e)}return{pricing:i,sources:a}}function gk(e,t){let n=e&&e.pricing?e.pricing:{},r=[];for(let e of tk)n[e.value]!==null&&n[e.value]!==void 0&&r.push({id:t(),field:e.value,value:String(n[e.value])});return r}function _k(e,t){let n=new Set;for(let r of Array.isArray(e)?e:[]){if(t&&r.id===t)continue;let e=String(r.field||``).trim();e&&n.add(e)}return n}function vk(e,t){let n=_k(e,t&&t.id);return tk.filter(e=>e.value===(t&&t.field)||!n.has(e.value))}function yk(e,t){let n={},r=new Set;for(let t of Array.isArray(e)?e:[]){let e=String(t.field||``).trim();if(!e)return{error:`Choose a price type for every row.`};if(r.has(e))return{error:`Each price type can only be used once.`};r.add(e);let i=String(t.value||``).trim();if(i===``)return{error:`Enter a value for `+nk(e)+`.`};let a=Number(i);if(!Number.isFinite(a)||a<0)return{error:`Pricing values must be numbers greater than or equal to 0.`};n[e]=a}let i=Array.isArray(t)?t:[];return i.length>0&&(n.tiers=rk(i)),Object.keys(n).length===0?{error:`Add at least one pricing field before saving.`}:{pricing:n}}function bk(e,t,n){let r=e||{},i=t||{},a=n||{},o=ik(r,a);return tk.map(e=>{let t=a[e.value]!==null&&a[e.value]!==void 0,n=r[e.value]!==null&&r[e.value]!==void 0;return{field:e.value,label:e.label,value:o[e.value],source:t?`Form/API value`:n?i[e.value]||`Model registry`:`Unset`}}).filter(e=>e.source!==`Unset`||e.value!==void 0)}var xk=new class{#e=k(!0);get modelPricingOverridesAvailable(){return I(this.#e)}set modelPricingOverridesAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get modelPricingOverrideViews(){return I(this.#t)}set modelPricingOverrideViews(e){A(this.#t,e,!0)}#n=k(``);get modelPricingOverrideError(){return I(this.#n)}set modelPricingOverrideError(e){A(this.#n,e,!0)}#r=k(!1);get modelPricingOverrideFormOpen(){return I(this.#r)}set modelPricingOverrideFormOpen(e){A(this.#r,e,!0)}#i=k(!1);get modelPricingOverrideSubmitting(){return I(this.#i)}set modelPricingOverrideSubmitting(e){A(this.#i,e,!0)}#a=k(!1);get modelPricingOverrideFormHasExistingOverride(){return I(this.#a)}set modelPricingOverrideFormHasExistingOverride(e){A(this.#a,e,!0)}#o=k(``);get modelPricingOverrideFormDisplayName(){return I(this.#o)}set modelPricingOverrideFormDisplayName(e){A(this.#o,e,!0)}#s=k(``);get modelPricingOverrideFormScope(){return I(this.#s)}set modelPricingOverrideFormScope(e){A(this.#s,e,!0)}#c=k(j([]));get modelPricingOverrideFormScopeOptions(){return I(this.#c)}set modelPricingOverrideFormScopeOptions(e){A(this.#c,e,!0)}#l=k(null);get modelPricingOverrideFormRow(){return I(this.#l)}set modelPricingOverrideFormRow(e){A(this.#l,e,!0)}#u=k(null);get modelPricingOverrideFormBasePricing(){return I(this.#u)}set modelPricingOverrideFormBasePricing(e){A(this.#u,e,!0)}#d=k(null);get modelPricingOverrideFormBasePricingSources(){return I(this.#d)}set modelPricingOverrideFormBasePricingSources(e){A(this.#d,e,!0)}#f=k(j([]));get modelPricingOverrideFormPreservedTiers(){return I(this.#f)}set modelPricingOverrideFormPreservedTiers(e){A(this.#f,e,!0)}#p=k(j([]));get modelPricingOverrideRows(){return I(this.#p)}set modelPricingOverrideRows(e){A(this.#p,e,!0)}#m=k(j({selector:``}));get modelPricingOverrideForm(){return I(this.#m)}set modelPricingOverrideForm(e){A(this.#m,e,!0)}_modelPricingOverrideRowID=0;pricingFieldOptions(){return tk}pricingFieldLabel(e){return nk(e)}async fetchModelPricingOverrides(){this.modelPricingOverrideError=``;try{let e=await _s(`/admin/model-pricing-overrides`,{label:`model pricing overrides`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideViews=[];return}if(e.stale)return;if(this.modelPricingOverridesAvailable=!0,!e.ok){this.modelPricingOverrideViews=[];return}this.modelPricingOverrideViews=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch model pricing overrides:`,e),this.modelPricingOverrideViews=[],this.modelPricingOverrideError=`Unable to load model pricing overrides.`}}findModelPricingOverrideView(e){return pk(this.modelPricingOverrideViews,e)}hasGlobalPricingOverride(){return!!this.findModelPricingOverrideView(`/`)}hasProviderPricingOverride(e){return!!this.findModelPricingOverrideView(ck(e&&e.provider_name))}hasModelPricingOverride(e){return!!this.findModelPricingOverrideView(uk(e))}modelPricingButtonClass(e){return e?`table-action-btn-active`:``}modelPricingButtonLabel(e,t){let n=`Edit `+String(e||`model pricing`);return t?n+` (override exists)`:n}modelRowPricing(e){return hk(e,this.modelPricingOverrideViews).pricing}openGlobalPricingOverrideEdit(){this.openModelPricingOverrideForm({displayName:`All providers and models`,selector:`/`,scope:`global`,scopeOptions:[{value:`global`,label:`All providers and models`,selector:`/`}],row:null})}openProviderPricingOverrideEdit(e){let t=ck(e&&e.provider_name);t&&this.openModelPricingOverrideForm({displayName:`All models in `+(e.display_name||e.provider_name||t),selector:t,scope:`provider`,scopeOptions:[{value:`provider`,label:`Provider`,selector:t}],row:null})}openModelPricingOverrideEdit(e){if(!e||e.is_alias)return;let t=uk(e),n=dk(e),r=[{value:`exact`,label:`This provider and model`,selector:t}];n&&n!==t&&r.push({value:`model`,label:`This model across providers`,selector:n}),this.openModelPricingOverrideForm({displayName:e.display_name||t,selector:t,scope:`exact`,scopeOptions:r,row:e})}openModelPricingOverrideForm(e){let t=e||{};this.modelPricingOverrideFormOpen=!0,this.modelPricingOverrideError=``,this.modelPricingOverrideFormDisplayName=t.displayName||t.selector||`Pricing`,this.modelPricingOverrideFormScope=t.scope||``,this.modelPricingOverrideFormScopeOptions=Array.isArray(t.scopeOptions)?t.scopeOptions:[],this.modelPricingOverrideFormRow=t.row||null,this.modelPricingOverrideForm={selector:t.selector||``},this.loadModelPricingOverrideFormSelector(t.selector||``)}loadModelPricingOverrideFormSelector(e){e=String(e||``).trim();let t=this.findModelPricingOverrideView(e);this.modelPricingOverrideFormHasExistingOverride=!!t,this.modelPricingOverrideRows=gk(t,()=>this.nextModelPricingOverrideRowID()),this.modelPricingOverrideFormPreservedTiers=t&&t.pricing&&Array.isArray(t.pricing.tiers)?rk(t.pricing.tiers):[],this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow();let n=this.modelPricingOverrideFormRow,r=n?hk(n,this.modelPricingOverrideViews,e):{pricing:{},sources:{}};this.modelPricingOverrideFormBasePricing=r.pricing,this.modelPricingOverrideFormBasePricingSources=r.sources}setModelPricingOverrideScope(e){this.modelPricingOverrideFormScope=e;let t=this.modelPricingOverrideFormScopeOptions.find(t=>t.value===e);t&&(this.modelPricingOverrideForm.selector=t.selector,this.loadModelPricingOverrideFormSelector(t.selector))}nextModelPricingOverrideRowID(){return this._modelPricingOverrideRowID=(this._modelPricingOverrideRowID||0)+1,`pricing-row-`+this._modelPricingOverrideRowID}availablePricingFieldOptions(e){return vk(this.modelPricingOverrideRows,e)}addModelPricingOverrideRow(){let e=_k(this.modelPricingOverrideRows),t=tk.find(t=>!e.has(t.value))||tk[0];t&&this.modelPricingOverrideRows.push({id:this.nextModelPricingOverrideRowID(),field:t.value,value:``})}removeModelPricingOverrideRow(e){this.modelPricingOverrideRows=this.modelPricingOverrideRows.filter(t=>t.id!==e.id),this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow()}modelPricingOverridePayload(){return yk(this.modelPricingOverrideRows,this.modelPricingOverrideFormPreservedTiers)}modelPricingOverrideDraftPricing(){let e=this.modelPricingOverridePayload();return e&&e.pricing?e.pricing:{}}modelPricingEffectivePreviewRows(){return bk(this.modelPricingOverrideFormBasePricing,this.modelPricingOverrideFormBasePricingSources,this.modelPricingOverrideDraftPricing())}closeModelPricingOverrideForm(){this.modelPricingOverrideFormOpen=!1,this.modelPricingOverrideSubmitting=!1,this.modelPricingOverrideError=``,this.modelPricingOverrideFormHasExistingOverride=!1,this.modelPricingOverrideFormDisplayName=``,this.modelPricingOverrideFormScope=``,this.modelPricingOverrideFormScopeOptions=[],this.modelPricingOverrideFormRow=null,this.modelPricingOverrideFormBasePricing=null,this.modelPricingOverrideFormBasePricingSources=null,this.modelPricingOverrideFormPreservedTiers=[],this.modelPricingOverrideRows=[],this.modelPricingOverrideForm={selector:``}}async submitModelPricingOverrideForm(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!e){this.modelPricingOverrideError=`Model pricing selector is required.`;return}let t=this.modelPricingOverridePayload();if(t.error){this.modelPricingOverrideError=t.error;return}let n={selector:e,...t};this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let e=await vs(`/admin/model-pricing-overrides`,`PUT`,n,{label:`model pricing override`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(e.stale)return;if(!e.ok){this.modelPricingOverrideError=e.status===401?`Authentication required.`:ps(e,`Failed to save model pricing.`);return}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),q.success(`Model pricing saved.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to save model pricing override:`,e),this.modelPricingOverrideError=`Failed to save model pricing.`}finally{this.modelPricingOverrideSubmitting=!1}}async deleteModelPricingOverride(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!(!e||!this.modelPricingOverrideFormHasExistingOverride)&&window.confirm(`Remove the model pricing override for "`+e+`"?`)){this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let t=await vs(`/admin/model-pricing-overrides`,`DELETE`,{selector:e},{label:`model pricing override`});if(t.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.modelPricingOverrideError=t.status===401?`Authentication required.`:ps(t,`Failed to remove model pricing override.`);return}}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),q.success(`Model pricing override removed.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to delete model pricing override:`,e),this.modelPricingOverrideError=`Failed to remove model pricing override.`}finally{this.modelPricingOverrideSubmitting=!1}}}},Sk=R(``);function Ck(e,t){E(t,!0);var n=Sk();let r;var i=P(M(n),2),a=M(i,!0);T(i),T(n),F((e,i,o)=>{r=U(n,1,`alias-toggle`,null,r,e),n.disabled=ek.rowTogglingKey===t.row.key||!ek.virtualModelsAvailable,W(n,`aria-label`,i),B(a,o)},[()=>({enabled:ek.rowToggleEnabled(t.row),restricted:ek.rowToggleRestricted(t.row)}),()=>ek.rowToggleAriaLabel(t.row),()=>ek.rowToggleLabel(t.row)]),L(`click`,n,()=>ek.toggleRowEnabled(t.row)),z(e,n),D()}Hr([`click`]);var wk=R(`
                `);function Tk(e,t){E(t,!0);var n=wk(),r=M(n),i=e=>{Ck(e,{get row(){return ek.globalScopeRow}})};V(r,e=>{ek.virtualModelsAvailable&&e(i)});var a=P(r,2),o=e=>{{let t=O(()=>xk.modelPricingButtonLabel(`global model pricing`,xk.hasGlobalPricingOverride())),n=O(()=>xk.modelPricingButtonClass(xk.hasGlobalPricingOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>xk.openGlobalPricingOverrideEdit(),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(a,e=>{xk.modelPricingOverridesAvailable&&e(o)});var s=P(a,2),c=e=>{{let t=O(()=>BO(`global model access`,ek.hasGlobalModelOverride())),n=O(()=>zO(ek.hasGlobalModelOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>ek.openGlobalModelOverrideEdit(),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n),D()}function Ek(e){return String(e&&(e.primary_model||e.source)||``).trim()}function Dk(e){return Array.isArray(e&&e.fallback_models)?e.fallback_models:Array.isArray(e&&e.targets)?e.targets:[]}function Ok(e){return Array.isArray(e)?e.map(e=>({...e,source:Ek(e),targets:Dk(e)})):[]}function kk(e){let t=Dk(e);return t.length===0?`-`:t.join(`, `)}function Ak(e){return e&&e.enabled===!1?`Off`:e&&e.managed?`Config`:`On`}function jk(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>Ek(e)===n)||null}function Mk(e,t){if(!t||t.is_alias)return!1;let n=jk(e,tO(t));return!!(n&&n.enabled!==!1&&Dk(n).length>0)}function Nk(e,t){return Mk(e,t)?`table-action-btn-failover-active`:``}function Pk(e,t){let n=`Edit failover for `+(t&&t.display_name?t.display_name:`model`);return Mk(e,t)?n+` (active)`:n}function Fk(e){let t=[e&&e.target_model];return(Array.isArray(e&&e.targets)?e.targets:[]).forEach(e=>t.push(e&&e.model)),t.map(e=>String(e||``).trim()).filter(Boolean)}function Ik(e){let t=Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(Boolean):[];return{target_model:t[0]||``,targets:t.slice(1).map(e=>({model:e}))}}function Lk(e){return{primary_model:String(e&&e.source||``).trim(),fallback_models:Fk(e),enabled:!(e&&e.enabled===!1)}}function Rk(e){return Ek(e)}function zk(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=Rk(e);n&&(t[n]=!0)}),t}function Bk(e,t){let n=Rk(t);return!!(n&&e&&e[n])}function Vk(e,t){return(Array.isArray(e)?e:[]).filter(e=>Bk(t,e))}function Hk(e,t){let n=Array.isArray(e)?e:[];return n.length>0&&Vk(n,t).length===n.length}function Uk(e){return[Ek(e),Dk(e).join(` `)].join(` `).toLowerCase()}function Wk(e,t){let n=Array.isArray(e)?e:[],r=String(t||``).trim().toLowerCase();return r?n.filter(e=>Uk(e).includes(r)):n}function Gk(e){return{primary_model:Ek(e),fallback_models:Dk(e).map(e=>String(e||``).trim()).filter(Boolean),enabled:!!(e&&e.enabled!==!1)}}function Kk(){return{source:``,target_model:``,targets:[],enabled:!0}}var Z=new class{#e=k(!0);get failoverAvailable(){return I(this.#e)}set failoverAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get failoverRules(){return I(this.#t)}set failoverRules(e){A(this.#t,e,!0)}#n=k(!1);get failoverLoading(){return I(this.#n)}set failoverLoading(e){A(this.#n,e,!0)}#r=k(!1);get failoverSaving(){return I(this.#r)}set failoverSaving(e){A(this.#r,e,!0)}#i=k(!1);get failoverGenerating(){return I(this.#i)}set failoverGenerating(e){A(this.#i,e,!0)}#a=k(``);get failoverError(){return I(this.#a)}set failoverError(e){A(this.#a,e,!0)}#o=k(j([]));get failoverGeneratedRules(){return I(this.#o)}set failoverGeneratedRules(e){A(this.#o,e,!0)}#s=k(!1);get failoverDraftsOpen(){return I(this.#s)}set failoverDraftsOpen(e){A(this.#s,e,!0)}#c=k(j({}));get failoverDraftSelections(){return I(this.#c)}set failoverDraftSelections(e){A(this.#c,e,!0)}#l=k(``);get failoverDraftFilter(){return I(this.#l)}set failoverDraftFilter(e){A(this.#l,e,!0)}#u=k(!1);get failoverDraftSaving(){return I(this.#u)}set failoverDraftSaving(e){A(this.#u,e,!0)}#d=k(!1);get failoverFormOpen(){return I(this.#d)}set failoverFormOpen(e){A(this.#d,e,!0)}#f=k(`create`);get failoverFormMode(){return I(this.#f)}set failoverFormMode(e){A(this.#f,e,!0)}#p=k(!1);get failoverFormManaged(){return I(this.#p)}set failoverFormManaged(e){A(this.#p,e,!0)}#m=k(j(Kk()));get failoverForm(){return I(this.#m)}set failoverForm(e){A(this.#m,e,!0)}failoverEnabled(){return Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}async fetchFailoverRules(){if(!this.failoverEnabled()){this.failoverAvailable=!1,this.failoverRules=[],this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,this.failoverError=``,this.failoverLoading=!1;return}this.failoverLoading=!0,this.failoverError=``;try{let e=await _s(`/admin/failover`,{label:`failover mappings`});if(e.status===503){this.failoverAvailable=!1,this.failoverRules=[];return}if(e.stale)return;if(this.failoverAvailable=!0,!e.ok){this.failoverRules=[];return}this.failoverRules=Ok(e.data)}catch(e){console.error(`Failed to fetch failover mappings:`,e),this.failoverRules=[],this.failoverError=`Unable to load failover mappings.`}finally{this.failoverLoading=!1}}resetFailoverForm(){this.failoverFormMode=`create`,this.failoverFormManaged=!1,this.failoverForm=Kk()}openFailoverCreate(){this.resetFailoverForm(),this.failoverFormOpen=!0,this.focusFailoverEditor()}openFailoverEdit(e){if(!e)return;this.resetFailoverForm(),this.failoverFormMode=`edit`,this.failoverFormOpen=!0,this.failoverFormManaged=!!e.managed;let t=this.failoverPrimaryModel(e),n=this.failoverTargets(e);this.failoverForm={source:t,target_model:n[0]||``,targets:n.slice(1).map(e=>({model:e})),enabled:e.enabled!==!1},this.focusFailoverEditor()}openFailoverForModel(e){if(!e||e.is_alias)return;let t=this.qualifiedModelName(e),n=this.failoverRules.find(e=>this.failoverPrimaryModel(e)===t);if(n){this.openFailoverEdit(n);return}this.resetFailoverForm(),this.failoverFormMode=`create`,this.failoverFormOpen=!0,this.failoverForm.source=t,this.focusFailoverEditor()}closeFailoverForm(){this.failoverFormOpen=!1}closeFailoverDraftsModal(){this.failoverDraftSaving||(this.failoverDraftsOpen=!1)}failoverFormTargets(){return Fk(this.failoverForm)}setFailoverFormTargets(e){let t=Ik(e);this.failoverForm.target_model=t.target_model,this.failoverForm.targets=t.targets}addFailoverTarget(){Array.isArray(this.failoverForm.targets)||(this.failoverForm.targets=[]),this.failoverForm.targets.push({model:``}),this.focusFailoverEditor()}removeFailoverTarget(e){if(!Array.isArray(this.failoverForm.targets)){this.failoverForm.targets=[];return}this.failoverForm.targets.splice(e,1)}removePrimaryFailoverTarget(){let e=Array.isArray(this.failoverForm.targets)?this.failoverForm.targets:[];if(e.length>0){let t=e.shift();this.failoverForm.target_model=t&&t.model?t.model:``,this.failoverForm.targets=e;return}this.failoverForm.target_model=``}failoverRulePayload(){return Lk(this.failoverForm)}async submitFailoverForm(){if(this.failoverSaving||this.failoverGenerating||this.failoverFormManaged)return;let e=this.failoverRulePayload();if(!e.primary_model){this.failoverError=`Primary model is required.`;return}if(e.enabled&&e.fallback_models.length===0){this.failoverError=`Add at least one failover target.`;return}this.failoverSaving=!0,this.failoverError=``;try{let t=await vs(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to save failover mapping.`;return}q.success(`Failover mapping saved.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to save failover mapping:`,e),this.failoverError=`Failed to save failover mapping.`}finally{this.failoverSaving=!1}}async deleteFailoverRule(e){let t=String(e&&this.failoverPrimaryModel(e)||this.failoverForm.source||``).trim();if(!(!t||this.failoverSaving||this.failoverGenerating)&&confirm(`Remove failover mapping for "`+t+`"?`)){this.failoverSaving=!0,this.failoverError=``;try{let e=await vs(`/admin/failover`,`DELETE`,{primary_model:t},{label:`failover mapping`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mapping.`;return}q.success(`Failover mapping removed.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to remove failover mapping:`,e),this.failoverError=`Failed to remove failover mapping.`}finally{this.failoverSaving=!1}}}async generateFailoverForForm(){if(this.failoverGenerating||this.failoverSaving||this.failoverFormManaged)return;let e=String(this.failoverForm.source||``).trim();if(!e){this.failoverError=`Primary model is required.`;return}this.failoverGenerating=!0,this.failoverError=``;try{let t=await vs(`/admin/failover/generate`,`POST`,{primary_model:e},{label:`failover generation`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to generate failover mapping.`;return}let n=Ok(t.data),r=n.find(t=>this.failoverPrimaryModel(t)===e)||n[0]||null,i=this.failoverTargets(r);if(i.length===0){this.failoverError=`No failover suggestions were generated for this model.`;return}this.setFailoverFormTargets(i),q.success(`Generated `+i.length+` fallback model`+(i.length===1?`.`:`s.`)),this.focusFailoverEditor()}catch(e){console.error(`Failed to generate failover mapping:`,e),this.failoverError=`Failed to generate failover mapping.`}finally{this.failoverGenerating=!1}}openFailoverResetDialog(){Rs.open({title:`Remove failover models`,titleId:`failoverResetDialogTitle`,inputId:`failover-reset-confirmation`,message:`Remove every dashboard-managed failover mapping. Configuration-managed mappings remain active.`,requiredText:`remove`,confirmLabel:`Remove Failover`,icon:Ao,dialogClass:`budget-reset-dialog`,onConfirm:async()=>{await this.resetFailoverRules(),this.failoverError&&(Rs.error=this.failoverError)}})}async resetFailoverRules(){if(!this.failoverSaving){this.failoverSaving=!0,this.failoverError=``;try{let e=await vs(`/admin/failover/reset`,`POST`,void 0,{label:`failover removal`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mappings.`;return}this.failoverRules=Ok(e.data),this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,q.success(`Dashboard-managed failover mappings removed.`),Rs.close()}catch(e){console.error(`Failed to remove failover mappings:`,e),this.failoverError=`Failed to remove failover mappings.`}finally{this.failoverSaving=!1}}}async generateFailoverRules(){if(!(this.failoverGenerating||this.failoverDraftSaving)){this.failoverGenerating=!0,this.failoverError=``,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!0;try{let e=await vs(`/admin/failover/generate`,`POST`,void 0,{label:`failover generation`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to generate failover mappings.`;return}this.failoverGeneratedRules=Ok(e.data),this.selectAllFailoverDrafts(this.failoverGeneratedRules)}catch(e){console.error(`Failed to generate failover mappings:`,e),this.failoverError=`Failed to generate failover mappings.`}finally{this.failoverGenerating=!1}}}failoverDraftKey(e){return Rk(e)}selectAllFailoverDrafts(e){this.failoverDraftSelections=zk(e)}failoverDraftSelected(e){return Bk(this.failoverDraftSelections,e)}setFailoverDraftSelected(e,t){let n=this.failoverDraftKey(e);n&&(this.failoverDraftSelections={...this.failoverDraftSelections,[n]:!!t})}selectedFailoverDrafts(){return Vk(this.failoverGeneratedRules,this.failoverDraftSelections)}selectedFailoverDraftCount(){return this.selectedFailoverDrafts().length}failoverDraftCountLabel(){return this.selectedFailoverDraftCount()+` / `+this.failoverGeneratedRules.length+` selected`}allFailoverDraftsSelected(){return Hk(this.failoverGeneratedRules,this.failoverDraftSelections)}toggleAllFailoverDrafts(){if(!(this.failoverDraftSaving||this.failoverGenerating||this.failoverGeneratedRules.length===0)){if(this.allFailoverDraftsSelected()){this.failoverDraftSelections={};return}this.selectAllFailoverDrafts(this.failoverGeneratedRules)}}failoverDraftSearchText(e){return Uk(e)}filteredFailoverDrafts(){return Wk(this.failoverGeneratedRules,this.failoverDraftFilter)}failoverDraftPayload(e){return Gk(e)}async saveSelectedFailoverDrafts(){if(this.failoverDraftSaving||this.failoverGenerating)return;let e=this.selectedFailoverDrafts();if(e.length===0){this.failoverError=`Select at least one failover draft.`;return}this.failoverDraftSaving=!0,this.failoverError=``;try{for(let t of e){let e=this.failoverDraftPayload(t);if(!e.primary_model||e.fallback_models.length===0){this.failoverError=`Generated failover draft is missing model data.`;return}let n=await vs(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(n.stale)return;if(!n.ok){this.failoverError=`Failed to save failover mapping.`;return}}q.success(`Saved `+e.length+` failover mapping`+(e.length===1?`.`:`s.`)),this.failoverDraftsOpen=!1,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.fetchFailoverRules()}catch(e){console.error(`Failed to save generated failover mappings:`,e),this.failoverError=`Failed to save failover mappings.`}finally{this.failoverDraftSaving=!1}}focusFailoverEditor(){setTimeout(()=>{let e=document.querySelector(`[data-failover-editor]`),t=e&&e.querySelector?e.querySelector(`[data-modal-autofocus], input:not([disabled]), textarea:not([disabled]), button:not([disabled])`):null;t&&typeof t.focus==`function`&&t.focus({preventScroll:!0})},0)}failoverTargetLabel(e){return kk(e)}failoverPrimaryModel(e){return Ek(e)}failoverTargets(e){return Dk(e)}findFailoverMapping(e){return jk(this.failoverRules,e)}hasActiveFailoverMapping(e){return Mk(this.failoverRules,e)}failoverButtonClass(e){return Nk(this.failoverRules,e)}failoverButtonLabel(e){return Pk(this.failoverRules,e)}normalizeFailoverRules(e){return Ok(e)}failoverRuleStatus(e){return Ak(e)}qualifiedModelName(e){return tO(e)}},qk=R(``),Jk=R(``),Yk=R(`Config`),Xk=R(`
                Targets
                `),Zk=R(``),Qk=R(`
                Redirects to
                `),$k=R(` `),eA=R(`
                `),tA=R(`
                `),nA=R(`
                `);function rA(e,t){E(t,!0);let n=O(()=>xk.modelRowPricing(t.row));var r=nA(),i=M(r),a=M(i),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{z(e,qk())};V(l,e=>{t.row.is_alias&&e(u)});var d=P(l,2),f=e=>{z(e,Jk())};V(d,e=>{!t.row.is_alias&&t.row.masking_alias&&e(f)});var p=P(d,2),m=e=>{z(e,Yk())},h=O(()=>LO(t.row));V(p,e=>{I(h)&&e(m)}),T(o);var g=P(o,2),_=e=>{var n=Xk(),r=P(M(n)),i=M(r,!0);T(r),T(n),F(()=>B(i,t.row.secondary_name)),z(e,n)};V(g,e=>{t.row.is_alias&&e(_)});var v=P(g,2),y=e=>{var n=Qk(),r=P(M(n)),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=Zk();F(e=>{W(n,`aria-label`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),W(n,`title`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),n.disabled=e},[()=>!!ek.rowDeletingKey]),L(`click`,n,()=>ek.removeRedirectRow(t.row)),z(e,n)},s=O(()=>ek.virtualModelsAvailable&&FO(t.row));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>mO(t.row.masking_alias)]),z(e,n)};V(v,e=>{!t.row.is_alias&&t.row.masking_alias&&e(y)}),T(a),T(i);var b=P(i);H(b,17,()=>t.columns,oi,(e,r)=>{var i=$k(),a=M(i,!0);T(i),F(e=>{U(i,1,Fi(I(r).class),`svelte-1iynym`),B(a,e)},[()=>I(r).value(t.row,I(n))]),z(e,i)});var x=P(b),S=M(x),C=e=>{var n=eA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>ek.rowDeletingKey===t.row.key?`Removing alias `+t.row.alias.name:`Remove alias `+t.row.alias.name),r=O(()=>!!ek.rowDeletingKey);gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>ek.removeAliasRow(t.row),get disabled(){return I(r)},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})}},o=O(()=>ek.virtualModelsAvailable&&PO(t.row));V(i,e=>{I(o)&&e(a)});var s=P(i,2),c=e=>{{let n=O(()=>`Edit alias `+t.row.alias.name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.alias),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n)},w=e=>{var n=tA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`model pricing for `+t.row.display_name,xk.hasModelPricingOverride(t.row))),r=O(()=>xk.modelPricingButtonClass(xk.hasModelPricingOverride(t.row)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openModelPricingOverrideEdit(t.row),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(i,e=>{xk.modelPricingOverridesAvailable&&e(a)});var o=P(i,2),s=e=>{{let n=O(()=>Z.failoverButtonLabel(t.row)),r=O(()=>Z.failoverButtonClass(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>Z.openFailoverForModel(t.row),children:(e,t)=>{G(e,{get icon(){return Eo},class:`table-icon-svg`})},$$slots:{default:!0}})}},c=O(()=>Z.failoverAvailable&&Z.failoverEnabled());V(o,e=>{I(c)&&e(s)});var l=P(o,2),u=e=>{{let n=O(()=>X.rateLimitGaugeTitle(t.row.display_name,X.rateLimitGaugeClassForModel(t.row))),r=O(()=>X.rateLimitGaugeClassForModel(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForModel(t.row),children:(e,t)=>{G(e,{get icon(){return $a},class:`table-icon-svg`})},$$slots:{default:!0}})}},d=O(()=>X.rateLimitsEnabled()&&X.rateLimitInspectorModelID(t.row));V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{{let n=O(()=>`Edit redirect for `+t.row.display_name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.masking_alias),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(f,e=>{ek.virtualModelsAvailable&&t.row.masking_alias&&t.row.masking_alias.name&&e(p)});var m=P(f,2),h=e=>{{let n=O(()=>BO(`model access for `+t.row.display_name,RO(t.row.access))),r=O(()=>zO(RO(t.row.access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openVirtualModelEditModel(t.row),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(m,e=>{ek.virtualModelsAvailable&&!t.row.masking_alias&&e(h)}),T(n),z(e,n)};V(S,e=>{t.row.is_alias?e(C):e(w,-1)}),T(x),T(r),F((e,n)=>{W(r,`id`,e),U(r,1,n,`svelte-1iynym`),B(c,t.row.display_name)},[()=>IO(t.row)||void 0,()=>Fi(NO(t.row))]),z(e,r),D()}Hr([`click`]);var iA={headerLines:[`Modes`],value:e=>(e.model?.metadata?.modes??[]).join(`, `)||`-`};function aA(e,t){return{headerLines:e,class:`col-price`,value:t}}var oA=aA([`Input / Output ($/MTok)`],(e,t)=>cc(t?.input_per_mtok)+` / `+cc(t?.output_per_mtok)),sA={all:[oA],text_generation:[iA,oA,aA([`Cached $/MTok`],(e,t)=>cc(t?.cached_input_per_mtok))],embedding:[aA([`Input`,`$/MTok`],(e,t)=>cc(t?.input_per_mtok))],image:[aA([`$/Image`],(e,t)=>lc(t?.per_image))],audio:[aA([`$/Second`],(e,t)=>lc(t?.per_second_input)),aA([`$/Character`],(e,t)=>lc(t?.per_character_input))],video:[aA([`$/Second (In)`],(e,t)=>lc(t?.per_second_input)),aA([`$/Second (Out)`],(e,t)=>lc(t?.per_second_output))],utility:[aA([`$/Page`],(e,t)=>lc(t?.per_page)),aA([`$/Request`],(e,t)=>lc(t?.per_request))]};function cA(e){return sA[e]||sA.all}function lA(e){return cA(e).length+2}var uA=R(`
                `),dA=R(` `,1),fA=R(``),pA=R(` `),mA=R(` `),hA=R(`
                `),gA=R(`
                `),_A=R(`
                Model
                `);function vA(e,t){E(t,!0);let n=O(()=>Nc.activeCategory||`all`),r=O(()=>cA(I(n))),i=O(()=>lA(I(n)));var a=_A(),o=M(a),s=M(o),c=M(s),l=P(M(c));H(l,17,()=>I(r),oi,(e,t)=>{var n=fA();H(n,21,()=>I(t).headerLines,oi,(e,t,n)=>{var r=dA(),i=N(r),a=e=>{z(e,uA())};V(i,e=>{n>0&&e(a)});var o=P(i,1,!0);F(()=>B(o,I(t))),z(e,r)}),T(n),F(()=>U(n,1,Fi(I(t).class),`svelte-1911hy6`)),z(e,n)});var u=P(l);Tk(M(u),{}),T(u),T(c),T(s),H(P(s),17,()=>ek.filteredDisplayModelGroups,e=>e.key,(e,t)=>{var n=gA(),a=M(n),o=M(a),s=M(o),c=M(s),l=M(c),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=e=>{var n=pA(),r=M(n,!0);T(n),F(()=>B(r,`(`+I(t).type_label+`)`)),z(e,n)};V(f,e=>{I(t).type_label&&e(p)});var m=P(f,2),h=e=>{var n=mA(),r=M(n,!0);T(n),F(()=>B(r,I(t).item_count_label)),z(e,n)};V(m,e=>{I(t).item_count_label&&e(h)}),T(l);var g=P(l,2),_=e=>{var n=hA(),r=M(n,!0);T(n),F(()=>B(r,I(t).access_summary)),z(e,n)};V(g,e=>{I(t).access_summary&&e(_)}),T(c);var v=P(c,2),y=M(v),b=e=>{Ck(e,{get row(){return I(t)}})};V(y,e=>{I(t).access.selector&&e(b)});var x=P(y,2),S=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`provider pricing for `+I(t).display_name,xk.hasProviderPricingOverride(I(t)))),r=O(()=>xk.modelPricingButtonClass(xk.hasProviderPricingOverride(I(t))));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openProviderPricingOverrideEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(x,e=>{xk.modelPricingOverridesAvailable&&I(t).provider_name&&e(S)});var C=P(x,2),w=e=>{{let n=O(()=>X.rateLimitGaugeTitle(`provider `+I(t).display_name,X.rateLimitGaugeClassForProvider(I(t)))),r=O(()=>X.rateLimitGaugeClassForProvider(I(t)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForProvider(I(t)),children:(e,t)=>{G(e,{get icon(){return $a},class:`table-icon-svg`})},$$slots:{default:!0}})}},ee=O(()=>X.rateLimitsEnabled()&&I(t).provider_name);V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{{let n=O(()=>BO(`provider access for `+I(t).display_name,RO(I(t).access))),r=O(()=>zO(RO(I(t).access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openProviderOverrideEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(te,e=>{ek.virtualModelsAvailable&&I(t).access.selector&&e(ne)}),T(v),T(s),T(o),T(a),H(P(a),17,()=>I(t).rows,e=>e.key,(e,t)=>{rA(e,{get row(){return I(t)},get columns(){return I(r)}})}),T(n),F(()=>{W(o,`colspan`,I(i)),B(d,I(t).display_name)}),z(e,n)}),T(o),T(a),z(e,a),D()}var yA=R(``);function bA(e,t){let n=ya(t,`enabled`,3,!1),r=ya(t,`label`,3,``),i=ya(t,`disabled`,3,!1),a=ya(t,`restricted`,3,!1);var o=yA();let s;var c=P(M(o),2),l=M(c,!0);T(c),T(o),F(()=>{s=U(o,1,`alias-toggle`,null,s,{enabled:n(),restricted:a()}),o.disabled=i(),W(o,`aria-label`,(n()?`Disable `:`Enable `)+r()),B(l,t.text??(n()?`Enabled`:`Disabled`))}),L(`click`,o,function(...e){t.onclick?.apply(this,e)}),z(e,o)}Hr([`click`]);var xA=R(``),SA=R(`
                `);function CA(e,t){E(t,!0);let n=ya(t,`model`,15,``),r=ya(t,`weight`,15),i=ya(t,`id`,3,void 0),a=ya(t,`placeholder`,3,`openai/gpt-4o`),o=ya(t,`showRemove`,3,!0);var s=SA(),c=M(s);na(c);var l=P(c,2),u=e=>{var t=xA();na(t),F(()=>t.disabled=ek.vmFormManaged),da(t,r),z(e,t)},d=O(()=>ek.vmFormShowWeights());V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{gT(e,{label:`Remove target`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,get onclick(){return t.onremove},get disabled(){return ek.vmFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})};V(f,e=>{o()&&e(p)}),T(s),F(()=>{W(c,`id`,i()),W(c,`placeholder`,a()),c.disabled=ek.vmFormManaged}),da(c,n),z(e,s),D()}var wA=R(`

                `),TA=R(`adaptive lets the registered routing extension pick the target per + request.`,1),EA=R(`Add one target to make this a redirect/alias, or two or more to load + balance across them, then pick a strategy: round_robin rotates across targets + (weight biases the share) and cost always routes to the cheapest available + target. Leave Targets empty to make it only an access policy on the Source selector. The selector uses / for all providers and + models, for one provider, or for one model. user_paths is + matched against the effective request user_path: the managed API key user_path when present, otherwise the configured user path request header.`,1),DA=R(``),OA=R(`

                This virtual model is defined in configuration (config.yaml / VIRTUAL_MODELS) and is read-only here. Edit your configuration to change it.

                `),kA=R(``),AA=R(``),jA=R(``),MA=R(`
                `,1),NA=R(``),PA=R(`Use / to allow every user path. Use a team path to restrict to that + subtree, or an unused path to make the selector unavailable.`,1),FA=R(``),IA=R(` `),LA=R(`
                Targets
                `,1);function RA(e,t){E(t,!0);let n=ek;An(()=>{n.vmFormOpen&&Ss.ensureLoaded()});{let t=e=>{qS(e,{copyId:`virtual-model-help-copy`,label:`virtual model help`,get open(){return n.vmFormHelpOpen},set open(e){n.vmFormHelpOpen=e},title:e=>{var t=wA(),r=M(t,!0);T(t),F(()=>B(r,n.vmFormDisplayName||n.vmForm.source||`Virtual model`)),z(e,t)},help:e=>{Ue();var t=EA(),n=P(N(t),7),r=e=>{var t=TA();Ue(),z(e,t)},i=O(()=>Ss.virtualModelStrategies().includes(`adaptive`));V(n,e=>{I(i)&&e(r)});var a=P(n,8);a.textContent=`{provider_name}/`;var o=P(a,2);o.textContent=`{provider_name}/{model}`,Ue(7),z(e,t)},$$slots:{title:!0,help:!0}})},r=e=>{var t=Qr(),r=N(t),i=e=>{var t=DA();F(()=>t.disabled=n.vmDeleting||n.vmSubmitting),L(`click`,t,()=>n.deleteVirtualModel()),z(e,t)};V(r,e=>{n.vmFormHasExisting&&!n.vmFormManaged&&e(i)}),z(e,t)},i=O(()=>n.vmDeleting||n.vmFormManaged),a=O(()=>n.vmFormMode===`edit`?`Save`:`Create`),o=O(()=>n.vmFormMode===`edit`?_o:po);bE(e,{get open(){return n.vmFormOpen},ariaLabel:`Virtual model editor`,get error(){return n.vmFormError},get submitting(){return n.vmSubmitting},get submitDisabled(){return I(i)},get submitLabel(){return I(a)},get submitIcon(){return I(o)},onclose:()=>n.closeVirtualModelForm(),onsubmit:()=>n.submitVirtualModelForm(),header:t,extraActions:r,children:(e,t)=>{var r=LA(),i=N(r),a=e=>{z(e,OA())};V(i,e=>{n.vmFormManaged&&e(a)});var o=P(i,2);SE(o,{id:`virtual-model-source`,label:`Source`,children:(e,t)=>{var r=kA();na(r),F(()=>r.disabled=n.vmFormSourceLocked||n.vmFormManaged),da(r,()=>n.vmForm.source,e=>n.vmForm.source=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2);H(s,21,()=>Nc.models,e=>tO(e),(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(s);var c=P(s,2),l=P(M(c),2);{let e=O(()=>n.vmFormHasPrimaryTarget());CA(l,{id:`virtual-model-target`,get showRemove(){return I(e)},onremove:()=>n.removePrimaryTarget(),get model(){return n.vmForm.target_model},set model(e){n.vmForm.target_model=e},get weight(){return n.vmForm.target_weight},set weight(e){n.vmForm.target_weight=e}})}var u=P(l,2);H(u,17,()=>n.vmForm.targets,oi,(e,t,r)=>{CA(e,{placeholder:`groq/llama`,onremove:()=>n.removeVmTarget(r),get model(){return I(t).model},set model(e){I(t).model=e},get weight(){return I(t).weight},set weight(e){I(t).weight=e}})});var d=P(u,2),f=M(d);G(M(f),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(f),T(d),T(c);var p=P(c,2),m=e=>{var t=MA(),r=N(t);SE(r,{id:`virtual-model-strategy`,label:`Load-balancing strategy`,children:(e,t)=>{var r=jA();H(r,21,()=>n.vmStrategyOptions(),e=>e.value,(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),F(()=>r.disabled=n.vmFormManaged),Gi(r,()=>n.vmForm.strategy,e=>n.vmForm.strategy=e),z(e,r)},$$slots:{default:!0}});var i=P(r,2),a=M(i),o=M(a);na(o),Ue(2),T(a),T(i),F(()=>o.disabled=n.vmFormManaged),fa(o,()=>n.vmForm.session_affinity,e=>n.vmForm.session_affinity=e),z(e,t)},h=O(()=>n.vmFormShowStrategy());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=M(g);qS(_,{copyId:`virtual-model-user-paths-help`,label:`user paths help`,get open(){return n.vmFormUserPathsHelpOpen},set open(e){n.vmFormUserPathsHelpOpen=e},title:e=>{z(e,NA())},help:e=>{Ue();var t=PA();Ue(2),z(e,t)},$$slots:{title:!0,help:!0}});var v=P(_,2);ft(v),W(v,`placeholder`,`/ +/team/alpha +/non-existing`),T(g);var y=P(g,2);SE(y,{id:`virtual-model-description`,label:`Description`,children:(e,t)=>{var r=FA();ft(r),F(()=>r.disabled=n.vmFormManaged),da(r,()=>n.vmForm.description,e=>n.vmForm.description=e),z(e,r)},$$slots:{default:!0}});var b=P(y,2),x=M(b),S=e=>{var t=IA(),r=M(t,!0);T(t),F(()=>B(r,`Default enabled: `+(n.vmFormDefaultEnabled?`yes`:`no`)+` · Effective now: `+(n.vmFormEffectiveEnabled?`yes`:`no`))),z(e,t)};V(x,e=>{n.vmFormMode===`edit`&&e(S)});var C=P(x,2),w=M(C);{let e=O(()=>n.vmFormToggleRestricted()),t=O(()=>n.vmFormToggleLabel());bA(w,{get enabled(){return n.vmForm.enabled},get restricted(){return I(e)},label:`virtual model`,get disabled(){return n.vmFormManaged},get text(){return I(t)},onclick:()=>{n.vmFormManaged||(n.vmForm.enabled=!n.vmForm.enabled)}})}T(C),T(b),F(()=>{f.disabled=n.vmFormManaged,v.disabled=n.vmFormManaged}),L(`click`,f,()=>n.addVmTarget()),da(v,()=>n.vmForm.user_paths,e=>n.vmForm.user_paths=e),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var zA=R(`

                Pricing override

                `,1),BA=R(``),VA=R(``),HA=R(``),UA=R(``),WA=R(`
                `),GA=R(`
                Tiered pricing exists for this override and will be preserved. Tier editing can be added + without a database migration.
                `),KA=R(`
                No pricing fields set.
                `),qA=R(`
                `),JA=R(`

                Currency is USD. Saved fields override model registry and config.yaml pricing for this + selector; unset fields continue to inherit.

                Price Type USD Source
                `,1);function YA(e,t){E(t,!0);let n=xk;bE(e,{get open(){return n.modelPricingOverrideFormOpen},ariaLabel:`Model pricing editor`,dialogClass:`model-pricing-editor`,get error(){return n.modelPricingOverrideError},get submitting(){return n.modelPricingOverrideSubmitting},submitLabel:`Save Pricing`,onclose:()=>n.closeModelPricingOverrideForm(),onsubmit:()=>n.submitModelPricingOverrideForm(),header:e=>{var t=zA(),r=P(N(t),2),i=M(r,!0);T(r),F(()=>B(i,n.modelPricingOverrideFormDisplayName||n.modelPricingOverrideForm.selector||`Pricing`)),z(e,t)},extraActions:e=>{var t=Qr(),r=N(t),i=e=>{var t=BA();F(()=>t.disabled=n.modelPricingOverrideSubmitting),L(`click`,t,()=>n.deleteModelPricingOverride()),z(e,t)};V(r,e=>{n.modelPricingOverrideFormHasExistingOverride&&e(i)}),z(e,t)},children:(e,t)=>{var r=JA(),i=N(r),a=M(i);SE(a,{id:`model-pricing-override-selector`,label:`Selector`,children:(e,t)=>{var r=VA();na(r),da(r,()=>n.modelPricingOverrideForm.selector,e=>n.modelPricingOverrideForm.selector=e),z(e,r)},$$slots:{default:!0}});var o=P(a,2),s=e=>{SE(e,{id:`model-pricing-override-scope`,label:`Scope`,children:(e,t)=>{var r=UA();H(r,21,()=>n.modelPricingOverrideFormScopeOptions,e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),L(`change`,r,()=>n.setModelPricingOverrideScope(n.modelPricingOverrideFormScope)),Gi(r,()=>n.modelPricingOverrideFormScope,e=>n.modelPricingOverrideFormScope=e),z(e,r)},$$slots:{default:!0}})};V(o,e=>{n.modelPricingOverrideFormScopeOptions.length>1&&e(s)}),T(i);var c=P(i,4);H(c,21,()=>n.modelPricingOverrideRows,e=>e.id,(e,t,r)=>{var i=WA(),a=M(i),o=M(a),s=P(o,2);H(s,21,()=>n.availablePricingFieldOptions(I(t)),e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).group+` - `+I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(s),T(a);var c=P(a,2),l=M(c),u=P(l,2);na(u),T(c);var d=P(c,2);{let e=O(()=>`Remove `+n.pricingFieldLabel(I(t).field));gT(d,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn pricing-override-remove-row`,onclick:()=>n.removeModelPricingOverrideRow(I(t)),children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}T(i),F(()=>{W(o,`for`,`pricing-type-`+I(t).id),W(s,`id`,`pricing-type-`+I(t).id),W(l,`for`,`pricing-value-`+I(t).id),W(u,`id`,`pricing-value-`+I(t).id)}),Gi(s,()=>I(t).field,e=>I(t).field=e),da(u,()=>I(t).value,e=>I(t).value=e),z(e,i)}),T(c);var l=P(c,2),u=M(l);G(M(u),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(u),T(l);var d=P(l,2),f=e=>{z(e,GA())};V(d,e=>{n.modelPricingOverrideFormPreservedTiers.length>0&&e(f)});var p=P(d,2),m=P(M(p),2),h=e=>{z(e,KA())},g=O(()=>n.modelPricingEffectivePreviewRows().length===0);V(m,e=>{I(g)&&e(h)}),H(P(m,2),17,()=>n.modelPricingEffectivePreviewRows(),e=>e.field,(e,t)=>{var n=qA(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{B(i,I(t).label),B(o,e),B(c,I(t).source)},[()=>I(t).value===null||I(t).value===void 0?`-`:lc(Number(I(t).value))]),z(e,n)}),T(p),L(`click`,u,()=>n.addModelPricingOverrideRow()),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}}),D()}Hr([`click`,`change`]);var XA=R(`

                Failover mapping

                `,1),ZA=R(``),QA=R(`

                This failover mapping is defined in configuration and is read-only here.

                `),$A=R(``),ej=R(`
                `),tj=R(`
                `,1),nj=R(`
                `);function rj(e,t){E(t,!0);{let t=e=>{var t=XA(),n=P(N(t),2),r=M(n,!0);T(n),F(()=>B(r,Z.failoverForm.source||`Failover`)),z(e,t)},n=e=>{var t=Qr(),n=N(t),r=e=>{var t=ZA();F(()=>t.disabled=Z.failoverSaving||Z.failoverGenerating),L(`click`,t,()=>Z.deleteFailoverRule()),z(e,t)};V(n,e=>{Z.failoverFormMode===`edit`&&!Z.failoverFormManaged&&e(r)}),z(e,t)},r=O(()=>Z.failoverGenerating||Z.failoverFormManaged);bE(e,{get open(){return Z.failoverFormOpen},ariaLabel:`Failover editor`,get error(){return Z.failoverError},get submitting(){return Z.failoverSaving},get submitDisabled(){return I(r)},submitLabel:`Save`,onclose:()=>Z.closeFailoverForm(),onsubmit:()=>Z.submitFailoverForm(),header:t,extraActions:n,children:(e,t)=>{var n=nj(),r=M(n),i=e=>{z(e,QA())};V(r,e=>{Z.failoverFormManaged&&e(i)});var a=P(r,2);H(a,21,()=>Nc.models,oi,(e,t)=>{var n=$A(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(a);var o=P(a,2);SE(o,{id:`failover-target`,label:`Fallback models`,children:(e,t)=>{var n=tj(),r=N(n),i=M(r),a=M(i);na(a);var o=P(a,2),s=e=>{gT(e,{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removePrimaryFailoverTarget(),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})};V(o,e=>{Z.failoverForm.target_model&&e(s)}),T(i),H(P(i,2),17,()=>Z.failoverForm.targets,oi,(e,t,n)=>{var r=ej(),i=M(r);na(i),gT(P(i,2),{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removeFailoverTarget(n),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),F(()=>i.disabled=Z.failoverFormManaged),da(i,()=>I(t).model,e=>I(t).model=e),z(e,r)}),T(r);var c=P(r,2),l=M(c);G(M(l),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(l);var u=P(l,2),d=M(u);G(d,{get icon(){return Po},class:`form-action-icon`});var f=P(d,2),p=M(f,!0);T(f),T(u),T(c),F(e=>{a.disabled=Z.failoverFormManaged,l.disabled=Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving,u.disabled=e,B(p,Z.failoverGenerating?`Generating...`:`Generate automatically`)},[()=>Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving||!Z.failoverEnabled()]),da(a,()=>Z.failoverForm.target_model,e=>Z.failoverForm.target_model=e),L(`click`,l,()=>Z.addFailoverTarget()),L(`click`,u,()=>Z.generateFailoverForForm()),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=M(s);bA(M(c),{get enabled(){return Z.failoverForm.enabled},label:`failover mapping`,get disabled(){return Z.failoverFormManaged},onclick:()=>{Z.failoverFormManaged||(Z.failoverForm.enabled=!Z.failoverForm.enabled)}}),T(c),T(s),T(n),z(e,n)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var ij=R(` `),aj=R(`
                `),oj=R(``),sj=R(`
                `),cj=R(`

                No failover suggestions were generated.

                `),lj=R(`

                No failover drafts match the filter.

                `),uj=R(``),dj=R(``);function fj(e,t){E(t,!0),Ns(e,{get open(){return Z.failoverDraftsOpen},variant:`editor`,onclose:()=>Z.closeFailoverDraftsModal(),children:(e,t)=>{var n=dj(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=ij(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>Z.failoverDraftCountLabel()]),z(e,t)};V(a,e=>{Z.failoverGeneratedRules.length>0&&e(o)}),ks(P(a,2),{label:`Close failover drafts`,onclick:()=>Z.closeFailoverDraftsModal(),get disabled(){return Z.failoverDraftSaving}}),T(i),T(r);var s=P(r,2),c=e=>{mT(e,{label:`Generating failover drafts...`,class:`failover-drafts-loading`})};V(s,e=>{Z.failoverGenerating&&e(c)});var l=P(s,2),u=e=>{var t=aj(),n=M(t);yw(n,{placeholder:`Filter failover drafts...`,label:`Filter failover drafts`,get value(){return Z.failoverDraftFilter},set value(e){Z.failoverDraftFilter=e}});var r=P(n,2),i=M(r);G(i,{get icon(){return Va},class:`form-action-icon`});var a=P(i,2),o=M(a,!0);T(a),T(r),T(t),F(e=>{r.disabled=Z.failoverDraftSaving,B(o,e)},[()=>Z.allFailoverDraftsSelected()?`Deselect all`:`Select all`]),L(`click`,r,()=>Z.toggleAllFailoverDrafts()),z(e,t)};V(l,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&e(u)});var d=P(l,2),f=e=>{var t=sj();H(t,21,()=>Z.filteredFailoverDrafts(),e=>`failover-draft:`+Z.failoverPrimaryModel(e),(e,t)=>{var n=oj(),r=M(n);na(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(i),T(n),F((e,t,n,i)=>{ia(r,e),r.disabled=Z.failoverDraftSaving,W(r,`aria-label`,t),B(o,n),B(c,i)},[()=>Z.failoverDraftSelected(I(t)),()=>`Select failover draft for `+Z.failoverPrimaryModel(I(t)),()=>Z.failoverPrimaryModel(I(t)),()=>Z.failoverTargetLabel(I(t))]),L(`change`,r,e=>Z.setFailoverDraftSelected(I(t),e.currentTarget.checked)),z(e,n)}),T(t),z(e,t)},p=O(()=>!Z.failoverGenerating&&Z.filteredFailoverDrafts().length>0);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{z(e,cj())};V(m,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length===0&&!Z.failoverError&&e(h)});var g=P(m,2),_=e=>{z(e,lj())},v=O(()=>!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&Z.filteredFailoverDrafts().length===0);V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=uj(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(y,e=>{Z.failoverError&&e(b)});var x=P(y,2),S=M(x),C=P(S,2),w=M(C);G(w,{get icon(){return _o},class:`form-action-icon`});var ee=P(w,2),te=M(ee,!0);T(ee),T(C),T(x),T(n),F(e=>{S.disabled=Z.failoverDraftSaving,C.disabled=e,B(te,Z.failoverDraftSaving?`Saving...`:`Save selected`)},[()=>Z.failoverGenerating||Z.failoverDraftSaving||Z.selectedFailoverDraftCount()===0]),L(`click`,S,()=>Z.closeFailoverDraftsModal()),L(`click`,C,()=>Z.saveSelectedFailoverDrafts()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`,`change`]);var pj=R(`
                Rate limit management is unavailable.
                `),mj=R(` Add`,1),hj=R(`

                `),gj=R(`

                No rules.

                `),_j=R(` Edit`,1),vj=R(`
                `),yj=R(`
                `),bj=R(`

                `),xj=R(``),Sj=R(``);function Cj(e,t){E(t,!0);function n(){K.dialogOpen||X.closeRateLimitInspector()}Ns(e,{get open(){return X.rateLimitInspectorOpen},variant:`editor`,onclose:n,children:(e,t)=>{var n=Sj(),r=M(n),i=M(r),a=P(M(i),2),o=M(a),s=M(o,!0);T(o),T(a),T(i),ks(P(i,2),{label:`Close rate limits inspector`,onclick:()=>X.closeRateLimitInspector()}),T(r);var c=P(r,2),l=e=>{mT(e,{label:`Loading rate limits...`})},u=e=>{z(e,pj())},d=e=>{var t=Qr();H(N(t),17,()=>X.rateLimitInspectorSections(),e=>e.key,(e,t)=>{var n=bj(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2);{let e=O(()=>`Add `+I(t).title.toLowerCase());gT(o,{get label(){return I(e)},class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(I(t).scope,I(t).subject),children:(e,t)=>{var n=mj();G(N(n),{get icon(){return po},class:`table-icon-svg`}),Ue(2),z(e,n)},$$slots:{default:!0}})}T(r);var s=P(r,2),c=e=>{var n=hj(),r=M(n,!0);T(n),F(()=>B(r,I(t).hint)),z(e,n)};V(s,e=>{I(t).hint&&e(c)});var l=P(s,2),u=e=>{z(e,gj())},d=e=>{var n=yj();H(n,21,()=>I(t).items,e=>X.rateLimitKey(e),(e,t)=>{var n=vj(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=M(c);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?Ma:ko);G(l,{get icon(){return I(e)},class:`budget-period-icon`})}var u=P(l,2),d=M(u,!0);T(u),T(c),T(s);var f=P(s,2),p=M(f),m=M(p),h=M(m,!0);T(m);var g=P(m,2),_=M(g,!0);T(g),T(p);var v=P(p,2),y=M(v),b=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(null,null,I(t)),children:(e,t)=>{var n=_j();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},x=O(()=>!X.rateLimitIsReadOnly(I(t)));V(y,e=>{I(x)&&e(b)}),T(v),T(f),T(i),T(r),T(n),F((e,t,r,i,a,s,c,l)=>{U(n,1,`budget-row ${e??``}`),Hi(n,t),W(n,`title`,r),B(o,i),B(d,a),B(h,s),W(g,`title`,c),B(_,l)},[()=>X.rateLimitPressureClass(I(t)),()=>X.rateLimitPressureStyle(I(t)),()=>X.rateLimitPressurePercent(I(t))+`% of the most constrained cap used`,()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitInspectorSummary(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n)};V(l,e=>{I(t).items.length===0?e(u):e(d,-1)}),T(n),F(()=>B(a,I(t).title)),z(e,n)}),z(e,t)};V(c,e=>{X.rateLimitsLoading?e(l):X.rateLimitsAvailable?e(d,-1):e(u,1)});var f=P(c,2),p=M(f),m=P(p,2),h=e=>{var t=xj();L(`click`,t,()=>{X.closeRateLimitInspector(),Jo.navigate(`rate-limits`)}),z(e,t)},g=O(()=>X.rateLimitsEnabled());V(m,e=>{I(g)&&e(h)}),T(f),T(n),F(()=>B(s,X.rateLimitInspector.title)),L(`click`,p,()=>X.closeRateLimitInspector()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`]);var wj=R(`
                models
                `),Tj=R(`
                Virtual models feature is unavailable.
                `),Ej=R(`
                `),Dj=R(``),Oj=R(`
                `),kj=R(``),Aj=R(`
                `),jj=R(`

                No models registered.

                `),Mj=R(`

                No models in this category.

                `),Nj=R(`

                No models match your filter.

                `),Pj=R(`
                `);function Fj(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`models`&&(ek.fetchVirtualModels(),xk.fetchModelPricingOverrides(),Z.fetchFailoverRules(),X.fetchRateLimitsPage())}),An(()=>{let e=ek.filteredDisplayModels.length;return Er(()=>ek.restartModelRendering(e)),()=>ek.stopModelRendering()});let n=O(()=>K.needsAuth);var r=Pj(),i=M(r),a=P(M(i),2),o=e=>{var t=wj(),n=M(t),r=M(n,!0);T(n),Ue(),T(t),F(()=>B(r,Nc.filter?ek.filteredDisplayModels.length+` / `+ek.displayModels.length:ek.displayModels.length)),z(e,t)};V(a,e=>{ek.displayModels.length>0&&e(o)}),T(i);var s=P(i,2);Fc(s,{});var c=P(s,2),l=e=>{z(e,Tj())};V(c,e=>{!ek.virtualModelsAvailable&&!I(n)&&e(l)});var u=P(c,2),d=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,ek.aliasError)),z(e,t)};V(u,e=>{ek.aliasError&&!I(n)&&e(d)});var f=P(u,2),p=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,xk.modelPricingOverrideError)),z(e,t)};V(f,e=>{xk.modelPricingOverrideError&&!I(n)&&!xk.modelPricingOverrideFormOpen&&e(p)});var m=P(f,2),h=e=>{var t=Oj();H(t,21,()=>Nc.categories,e=>e.category,(e,t)=>{var n=Dj();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F(()=>{r=U(n,1,`category-tab svelte-scpjps`,null,r,{active:Nc.activeCategory===I(t).category}),B(a,I(t).display_name),B(s,I(t).count)}),L(`click`,n,()=>Nc.selectCategory(I(t).category)),z(e,n)}),T(t),z(e,t)};V(m,e=>{Nc.categories.length>0&&e(h)});var g=P(m,2),_=e=>{var t=Aj(),n=M(t);yw(M(n),{placeholder:`Filter by provider, provider/model, alias, or owner...`,label:`Filter models by provider, provider/model, alias, or owner`,get value(){return Nc.filter},set value(e){Nc.filter=e}}),T(n);var r=P(n,2),i=M(r),a=e=>{var t=kj();G(M(t),{get icon(){return po},class:`alias-create-icon`}),Ue(2),T(t),L(`click`,t,()=>ek.openVirtualModelCreate()),z(e,t)};V(i,e=>{ek.virtualModelsAvailable&&e(a)}),T(r),T(t),z(e,t)};V(g,e=>{(ek.displayModels.length>0||Nc.filter||ek.virtualModelsAvailable)&&e(_)});var v=P(g,2),y=e=>{{let t=O(()=>ek.modelLoadingText());mT(e,{get label(){return I(t)},class:`models-loading-state`})}},b=O(()=>ek.modelsBusy()&&!I(n));V(v,e=>{I(b)&&e(y)});var x=P(v,2);RA(x,{});var S=P(x,2);YA(S,{});var C=P(S,2),w=e=>{vA(e,{})};V(C,e=>{(ek.displayModels.length>0||Nc.filter)&&e(w)});var ee=P(C,2),te=e=>{z(e,jj())};V(ee,e=>{ek.displayModels.length===0&&!Nc.loading&&!I(n)&&!Nc.filter&&(Nc.activeCategory===`all`||!Nc.activeCategory)&&e(te)});var ne=P(ee,2),re=e=>{z(e,Mj())};V(ne,e=>{ek.displayModels.length===0&&!Nc.loading&&!I(n)&&!Nc.filter&&Nc.activeCategory&&Nc.activeCategory!==`all`&&e(re)});var ie=P(ne,2),ae=e=>{z(e,Nj())};V(ie,e=>{ek.displayModels.length>0&&ek.filteredDisplayModels.length===0&&Nc.filter&&e(ae)});var oe=P(ie,2);Cj(oe,{});var se=P(oe,2);FD(se,{});var ce=P(se,2);rj(ce,{}),fj(P(ce,2),{}),T(r),z(e,r),D()}Hr([`click`]);var Ij=`draft-workflow-preview`;function Lj(){return{scope_provider:``,scope_model:``,scope_user_path:``,name:``,description:``,features:{cache:!0,audit:!0,usage:!0,budget:!0,guardrails:!1,failover:!0},guardrails:[]}}function Rj(){return{scope_provider:``,scope_model:``,scope_user_path:``}}function zj(e){return{ref:``,step:Number.isFinite(e)?e:10}}function Bj(e){let t=e==null?``:String(e).trim();if(t===``)return NaN;let n=Number(t);return Number.isFinite(n)?n:NaN}function Vj(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=t.charAt(0).toUpperCase()+t.slice(1);for(let n of[t,r])if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==null&&e[n]!==void 0)return e[n];return n}function Hj(e,t){return!e||typeof e!=`object`||Array.isArray(e)?!1:[t,t.charAt(0).toUpperCase()+t.slice(1)].some(t=>Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==null&&e[t]!==void 0)}function Uj(e){return{cache:!!Vj(e,`cache`,!1),audit:!!Vj(e,`audit`,!1),usage:!!Vj(e,`usage`,!1),budget:Vj(e,`budget`,!0)!==!1,guardrails:!!Vj(e,`guardrails`,!1),failover:Vj(e,`failover`,!0)!==!1}}function Wj(e,t){let n=Uj(e),r=t||{},i=n.usage&&!!r.usage;return{cache:n.cache&&!!r.cache,audit:n.audit&&!!r.audit,usage:i,budget:i&&n.budget&&!!r.budget,guardrails:n.guardrails&&!!r.guardrails,failover:n.failover&&!!r.failover}}function Gj(e,t){let n=e&&e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:e&&e.features?e.features:{};return{...Wj((e&&e.effective_features&&typeof e.effective_features==`object`&&!Array.isArray(e.effective_features)?e.effective_features:null)||n,t),failover:Uj(n).failover}}function Kj(e,t){return Gj(e,t).failover?`On`:`Off`}function qj(e){return(Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:Array.isArray(e&&e.guardrails)?e.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0)}function Jj(e,t){return Gj(e,t).guardrails&&Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[]}function Yj(e){return String(e&&(e.scope_provider_name||e.scope_provider)||``).trim()}function Xj(e){return String(e&&(e.provider_name||e.provider_type)||``).trim()}function Zj(e,t){let n=new Set,r=String(t&&t.scope_provider||``).trim();return r&&n.add(r),(Array.isArray(e)?e:[]).forEach(e=>{let t=Xj(e);t&&n.add(t)}),[...n].sort()}function Qj(e,t,n){let r=String(t||``).trim(),i=new Set,a=String(n&&n.scope_provider||``).trim(),o=String(n&&n.scope_model||``).trim();return r&&r===a&&o&&i.add(o),(Array.isArray(e)?e:[]).forEach(e=>{if(r&&Xj(e)!==r)return;let t=String(e&&e.model&&e.model.id||``).trim();t&&i.add(t)}),[...i].sort()}function $j(e){let t=String(e&&e.scope_type||``).trim();return t===`provider_model`?`Provider Name + Model`:t===`provider_model_path`?`Provider Name + Model + Path`:t===`provider_path`?`Provider Name + Path`:t===`path`?`Path`:t===`provider`?`Provider Name`:`Global`}function eM(e){return String(e&&e.scope_display||`global`).trim()||`global`}function tM(e){let t=String(e&&e.name||``).trim();if(t)return t;let n=eM(e);return n===`global`?`All models`:n}function nM(e){let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function rM(e){if(nM(e))return``;let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function iM(e){let t=e||Lj(),n=String(t.scope_provider||``).trim(),r=rM(t.scope_user_path);return{scope_provider:n,scope_model:n?String(t.scope_model||``).trim():``,scope_user_path:r}}function aM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path);return!t&&!r?`global`:!t&&r?`path`:!n&&!r?`provider`:!n&&r?`provider_path`:r?`provider_model_path`:`provider_model`}function oM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path),i=aM({scope_provider:t,scope_model:n,scope_user_path:r});return i===`global`?`global`:i===`path`?r:i===`provider`?t:i===`provider_path`?t+` @ `+r:i===`provider_model_path`?t+`/`+n+` @ `+r:t+`/`+n}function sM(e,t){let n=t||Rj(),r=Yj(e&&e.scope),i=r?String(e&&e.scope&&e.scope.scope_model||``).trim():``,a=rM(e&&e.scope&&e.scope.scope_user_path);return r===String(n.scope_provider||``).trim()&&i===String(n.scope_model||``).trim()&&a===rM(n.scope_user_path)}function cM(e,t,n){let r=iM(t);return!(r.scope_provider!==``||r.scope_model!==``||r.scope_user_path!==``)&&!n?null:(Array.isArray(e)?e:[]).find(e=>sM(e,r))||null}function lM(e){return String(e&&e.scope_type||``).trim()!==`global`}function uM(e){let t=String(e||``).trim();return t?t.length<=14?t:t.slice(0,12)+`…`:`—`}function dM(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.description,e.scope_display,e.scope_type,Yj(e&&e.scope),e.scope&&e.scope.scope_model,e.scope&&e.scope.scope_user_path,e.workflow_hash,...Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>e.ref):[]].some(e=>String(e||``).toLowerCase().includes(r)))}function fM(e,t){let n=e||Lj(),r=iM(n),i=Uj(n.features||{}),a=Wj(i,t);a.failover=i.failover;let o=!!a.guardrails,s=o?qj(n):[];return{id:Ij,scope_type:aM(r),scope_display:oM(r),scope:{scope_provider_name:r.scope_provider,scope_model:r.scope_model,...r.scope_user_path?{scope_user_path:r.scope_user_path}:{}},name:String(n.name||``).trim(),description:String(n.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!a.cache,audit:!!a.audit,usage:!!a.usage,budget:!!a.budget,guardrails:o,failover:!!a.failover},guardrails:s}}}function pM({form:e,caps:t,workflows:n=[],formHydrated:r=!1,hydratedScope:i=null}){let a=e||Lj(),o=String(a.scope_provider||``).trim(),s=o?String(a.scope_model||``).trim():``,c=rM(a.scope_user_path),l=Uj(a.features||{}),u=Wj(l,t),d=cM(n,a,r),f=d&&d.workflow_payload&&d.workflow_payload.features,p=Hj(f,`failover`),m=p?Vj(f,`failover`,!0)!==!1:null,h=i||Rj(),g=String(h.scope_provider||``).trim()===o&&String(h.scope_model||``).trim()===s&&rM(h.scope_user_path)===rM(c),_=!!(t&&t.failover),v=_||!!r&&g&&Object.prototype.hasOwnProperty.call(l,`failover`)||!r&&!!d&&p,y=u.guardrails?(Array.isArray(a.guardrails)?a.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})):[],b={scope_provider_name:o,scope_model:s,...c?{scope_user_path:c}:{},name:String(a.name||``).trim(),description:String(a.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!u.cache,audit:!!u.audit,usage:!!u.usage,budget:!!u.budget,guardrails:!!u.guardrails},guardrails:y}};return v&&(b.workflow_payload.features.failover=!_&&!r&&d&&p?m:!!l.failover),b}function mM(e,{models:t=[],hydratedScope:n=null}={}){let r=n||Rj(),i=String(r.scope_provider||``).trim(),a=String(r.scope_model||``).trim(),o=String(e&&(e.scope_provider_name||e.scope_provider)||``).trim(),s=String(e&&e.scope_model||``).trim();if(o&&!Zj(t,r).includes(o)&&o!==i)return`Choose a registered provider name.`;if(s&&!o)return`Model selection requires a provider name.`;if(s){let e=Qj(t,o,r),n=o===i&&s===a;if(!e.includes(s)&&!n)return`Choose a registered model for the selected provider name.`}let c=nM(e.scope_user_path);if(c)return c;let l=e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:{},u=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[];if(!l.guardrails)return``;let d=new Set;for(let e of u){if(!e.ref)return`Each guardrail step needs a guardrail ref.`;if(!Number.isInteger(e.step)||e.step<0)return`Each guardrail step must use a non-negative integer step number.`;if(d.has(e.ref))return`Each guardrail ref may appear only once in a workflow.`;d.add(e.ref)}return``}var hM=new class{#e=k(j([]));get workflows(){return I(this.#e)}set workflows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get submitting(){return I(this.#o)}set submitting(e){A(this.#o,e,!0)}#s=k(``);get deactivatingID(){return I(this.#s)}set deactivatingID(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get formHydrated(){return I(this.#l)}set formHydrated(e){A(this.#l,e,!0)}#u=k(j(Rj()));get hydratedScope(){return I(this.#u)}set hydratedScope(e){A(this.#u,e,!0)}#d=k(j([]));get guardrailRefs(){return I(this.#d)}set guardrailRefs(e){A(this.#d,e,!0)}#f=k(j(Lj()));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}#p=null;failoverVisible(){return Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}featureCaps(){return{cache:Ss.cacheVisible(),audit:Ss.auditVisible(),usage:Ss.usageVisible(),budget:Ss.budgetsVisible(),guardrails:Ss.guardrailsVisible(),failover:this.failoverVisible()}}get filteredWorkflows(){return dM(this.workflows,this.filter)}providerOptions(){return Zj(Nc.models,this.hydratedScope)}modelOptions(e){return Qj(Nc.models,e,this.hydratedScope)}activeScopeMatch(){return cM(this.workflows,this.form,this.formHydrated)}submitMode(){return this.activeScopeMatch()?`save`:`create`}submitLabel(){return this.submitMode()===`save`?`Save`:`Create`}submittingLabel(){return this.submitMode()===`save`?`Saving...`:`Creating...`}preview(){return fM(this.form,this.featureCaps())}openCreate(e){if(this.formOpen=!0,this.submitting=!1,this.formError=``,!e){this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj();return}this.formHydrated=!0,this.hydratedScope={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``).trim(),scope_user_path:String(e.scope&&e.scope.scope_user_path||``).trim()};let t=e.workflow_payload&&e.workflow_payload.features?Uj(e.workflow_payload.features):Gj(e,this.featureCaps()),n=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0):qj(e);this.form={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``),scope_user_path:String(e.scope&&e.scope.scope_user_path||``),name:String(e.name||``),description:String(e.description||``),features:{cache:!!t.cache,audit:!!t.audit,usage:!!t.usage,budget:!!t.budget,guardrails:!!t.guardrails,failover:!!t.failover},guardrails:n.map(e=>({ref:String(e&&e.ref||``),step:Number.isFinite(e&&e.step)?e.step:10}))}}closeForm(){this.formOpen=!1,this.submitting=!1,this.formError=``,this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj()}setProvider(e){if(this.form.scope_provider=String(e||``).trim(),!this.form.scope_provider){this.form.scope_model=``;return}this.modelOptions(this.form.scope_provider).includes(String(this.form.scope_model||``).trim())||(this.form.scope_model=``)}addGuardrailStep(){let e=(Array.isArray(this.form.guardrails)?this.form.guardrails:[]).reduce((e,t)=>{let n=Number(t&&t.step);return Number.isFinite(n)?Math.max(e,n):e},0)+10;this.form.guardrails.push(zj(e))}removeGuardrailStep(e){Array.isArray(this.form.guardrails)&&this.form.guardrails.splice(e,1)}buildRequest(){return pM({form:this.form,caps:this.featureCaps(),workflows:this.workflows,formHydrated:this.formHydrated,hydratedScope:this.hydratedScope})}async fetchWorkflows(){this.#p&&this.#p.abort();let e=new AbortController;this.#p=e,this.loading=!0,this.error=``;let t=setTimeout(()=>e.abort(),1e4),n=await _T(`/admin/workflows`,{label:`workflows`,options:{signal:e.signal}});if(clearTimeout(t),this.#p===e&&(this.#p=null,this.loading=!1,n.status!==`stale`)){if(n.status===`unavailable`){this.available=!1,this.workflows=[];return}if(n.result&&(this.available=!0),n.status===`error`){this.workflows=[],this.error=e.signal.aborted?`Loading workflows timed out.`:n.error;return}this.workflows=n.items}}async fetchGuardrailRefs(){let e=await _T(`/admin/workflows/guardrails`,{label:`workflow guardrails`});e.status!==`stale`&&(this.guardrailRefs=e.items)}async fetchPage(){await Promise.all([Ss.ensureLoaded(),this.fetchWorkflows(),this.fetchGuardrailRefs()])}async submitForm(){if(this.submitting)return;this.formError=``;let e=this.buildRequest(),t=mM(e,{models:Nc.models,hydratedScope:this.hydratedScope});if(t){this.formError=t;return}this.submitting=!0;try{let t=await vT(`/admin/workflows`,`POST`,e,{label:`create workflow`,unavailableStatuses:[]});if(t.status===`stale`||t.result&&t.result.status===401)return;if(t.status===`error`){this.formError=t.error;return}q.success(`Workflow created and activated.`),this.closeForm(),this.fetchPage()}finally{this.submitting=!1}}async deactivate(e){let t=String(e&&e.id||``).trim();if(!t||this.deactivatingID||!lM(e))return;let n=tM(e);if(confirm(`Deactivate workflow "`+n+`"? Requests will fall back to the next active workflow for this scope.`)){this.deactivatingID=t;try{let e=await vT(`/admin/workflows/`+encodeURIComponent(t)+`/deactivate`,`POST`,void 0,{label:`deactivate workflow`,unavailableStatuses:[]});if(e.status===`stale`||e.result&&e.result.status===401)return;if(e.status===`error`){q.error(e.error);return}q.success(`Workflow deactivated.`),this.fetchPage()}finally{this.deactivatingID=``}}}};function gM(e){let t=String(e??``),n=typeof navigator<`u`?navigator.clipboard:null;if(n&&typeof n.writeText==`function`)return n.writeText(t);let r=typeof document<`u`?document:null;if(!r||!r.body||typeof r.execCommand!=`function`)return Promise.reject(Error(`Clipboard API unavailable`));let i=r.createElement(`textarea`);i.value=t,i.setAttribute(`readonly`,``),i.style.position=`fixed`,i.style.top=`0`,i.style.left=`0`,i.style.opacity=`0`;try{if(r.body.appendChild(i),i.focus(),i.select(),i.setSelectionRange(0,i.value.length),!r.execCommand(`copy`))throw Error(`execCommand copy returned false`)}finally{i.parentNode&&i.parentNode.removeChild(i)}return Promise.resolve()}function _M({resetDelayMs:e=2e3,logPrefix:t}={}){let n=j({copied:!1,error:!1}),r=null;function i(){r!==null&&clearTimeout(r),r=null}function a(){i(),r=setTimeout(()=>{n.copied=!1,n.error=!1,r=null},e)}return{get copied(){return n.copied},get error(){return n.error},reset(){i(),n.copied=!1,n.error=!1},async copy(e,r){if(!(e==null||e===``)){i(),n.copied=!1,n.error=!1;try{await gM(typeof r==`function`?r(e):String(e)),n.copied=!0,n.error=!1}catch(e){console.error(t||`Failed to copy text:`,e),n.copied=!1,n.error=!0}a()}}}}var vM=R(``);function yM(e,t){E(t,!0);let n=ya(t,`workflowID`,3,``),r=_M({logPrefix:`Failed to copy workflow ID:`});An(()=>{n(),r.reset()});let i=O(()=>r.error?`Unable to copy workflow ID`:r.copied?`Workflow ID copied`:`Copy workflow ID`),a=O(()=>n()?I(i)+` `+n():I(i));async function o(e){e.preventDefault(),n()&&await r.copy(n())}var s=vM();let c;var l=P(M(s),4),u=M(l,!0);T(l);var d=P(l,2);G(M(d),{get icon(){return Ya}}),T(d),T(s),F(()=>{c=U(s,1,`workflow-pipeline-meta mono svelte-1viff7o`,null,c,{"workflow-pipeline-meta-copied":r.copied,"workflow-pipeline-meta-error":r.error}),W(s,`title`,I(i)),W(s,`aria-label`,I(a)),B(u,n())}),L(`click`,s,o),z(e,s),D()}Hr([`click`]);var bM=(e,t)=>{let n=()=>(t?.()).icon,r=()=>(t?.()).label,i=Ot(()=>h((t?.()).variant,`workflow-node-feature`)),a=()=>(t?.()).state,o=()=>(t?.()).sub,s=()=>(t?.()).badge;var c=wM(),l=M(c),u=e=>{var t=xM();let r;G(M(t),{get icon(){return n()}}),T(t),F(()=>r=U(t,1,`workflow-node-icon svelte-nbptrg`,null,r,{"workflow-node-icon-endpoint":I(i)===`workflow-node-endpoint`})),z(e,t)};V(l,e=>{n()&&e(u)});var d=P(l,2),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var t=SM(),n=M(t,!0);T(t),F(()=>B(n,s())),z(e,t)};V(p,e=>{s()&&e(m)});var g=P(p,2),_=e=>{var t=CM(),n=M(t,!0);T(t),F(()=>B(n,o())),z(e,t)};V(g,e=>{o()&&e(_)}),T(c),F(()=>{U(c,1,Fi([`workflow-node`,I(i),a()]),`svelte-nbptrg`),B(f,r())}),z(e,c)},xM=R(`
                `),SM=R(` `),CM=R(` `),wM=R(`
                `),TM=R(`
                `,1),EM=R(`
                `,1),DM=R(`
                `),OM=R(`
                Async
                `),kM=R(`
                `);function AM(e,t){E(t,!0);let n=ya(t,`chart`,19,()=>({}));var r=kM();let i;var a=M(r),o=e=>{yM(e,{get workflowID(){return n().workflowID}})};V(a,e=>{n().workflowID&&e(o)});var s=P(a,2),c=M(s);bM(c,()=>({icon:Mo,label:`Client`,variant:`workflow-node-endpoint`}));var l=P(c,4);bM(l,()=>({icon:Za,label:`Auth`,state:n().authNodeClass,sub:n().authNodeSublabel}));var u=P(l,2),d=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:Za,label:`Cache`,state:n().cacheNodeClass,badge:n().cacheStatusLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().cacheConnClass]),`svelte-nbptrg`)),z(e,t)};V(u,e=>{n().showCache&&e(d)});var f=P(u,2),p=e=>{var t=EM();bM(P(N(t),2),()=>({icon:No,label:`Budget`,state:n().budgetNodeClass,badge:n().budgetStatusLabel})),z(e,t)};V(f,e=>{n().showBudget&&e(p)});var m=P(f,2),h=e=>{var t=EM();bM(P(N(t),2),()=>({icon:To,label:`Guardrails`,sub:n().guardrailLabel})),z(e,t)};V(m,e=>{n().showGuardrails&&e(h)});var g=P(m,2),_=P(g,2);bM(_,()=>({label:n().aiLabel,variant:`workflow-node-ai`,state:n().aiNodeClass,sub:n().aiSublabel}));var v=P(_,2),y=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:oo,label:`Failover`,state:n().failoverNodeClass,badge:n().failoverStatusLabel,sub:n().failoverTargetLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().failoverConnClass]),`svelte-nbptrg`)),z(e,t)};V(v,e=>{n().showFailover&&e(y)});var b=P(v,2);bM(P(b,2),()=>({icon:Ga,label:`Response`,variant:`workflow-node-endpoint`,state:n().responseNodeClass,sub:n().responseNodeSublabel})),T(s);var x=P(s,2),S=e=>{var t=OM(),r=M(t),i=M(r),a=e=>{bM(e,()=>({icon:za,label:`Usage`,variant:`workflow-node-feature workflow-node-async`,state:n().usageNodeClass}))};V(i,e=>{n().showUsage&&e(a)});var o=P(i,2),s=e=>{z(e,DM())};V(o,e=>{n().showUsage&&n().showAudit&&e(s)});var c=P(o,2),l=e=>{bM(e,()=>({icon:Qa,label:`Audit Log`,variant:`workflow-node-feature workflow-node-async`,state:n().auditNodeClass}))};V(c,e=>{n().showAudit&&e(l)}),T(r),Ue(4),T(t),z(e,t)};V(x,e=>{n().showAsync&&e(S)}),T(r),F(()=>{i=U(r,1,`workflow-pipeline svelte-nbptrg`,null,i,{"workflow-pipeline-has-meta":n().workflowID}),U(g,1,Fi([`workflow-conn`,n().aiConnClass]),`svelte-nbptrg`),U(b,1,Fi([`workflow-conn`,n().responseConnClass]),`svelte-nbptrg`)}),z(e,r),D()}function jM(e){let t=qj(e).length;return t===0?``:t===1?`1 step`:t+` steps`}function MM(e,t){return t&&t.provider?t.provider:Yj(e&&e.scope)||`AI`}function NM(e,t){return t&&t.model?t.model:e&&e.scope&&e.scope.scope_model||null}function PM(e,t){let n=String(e&&e.id||``).trim();if(n&&n!==`draft-workflow-preview`)return n;let r=String(t&&t.workflow_version_id||``).trim();return r&&r!==`draft-workflow-preview`?r:null}function FM(e){let t=e&&e.data&&e.data.workflow_features;return!t||typeof t!=`object`||Array.isArray(t)?null:Uj(t)}function IM(e){let t=e&&e.data&&e.data.failover;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=String(t.target_model||t.targetModel||``).trim()||null;return n?{targetModel:n}:null}function LM(e,t=0){if(t>4||e==null)return``;if(typeof e==`string`){let n=e.trim();if(!n||n[0]!==`{`&&n[0]!==`[`)return``;try{return LM(JSON.parse(n),t+1)}catch{return``}}if(Array.isArray(e)){for(let n of e){let e=LM(n,t+1);if(e)return e}return``}return typeof e==`object`?String(e.code||``).trim()||(e.error===void 0?``:LM(e.error,t+1)):``}function RM(e){let t=e&&e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{};return String(t.error_code||t.errorCode||``).trim()||LM(t.response_body)}function zM(e){let t=String(e||``).trim();if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{provider:t.slice(0,n),model:t.slice(n+1)}}function BM(e,t){let n=String(e&&(e.requested_model||e.model)||``).trim(),r=IM(e);if(!(r&&r.targetModel))return{provider:String(e&&e.provider||``).trim()||null,model:n||null};let i=zM(n);if(i)return i;let a=Yj(t&&t.scope),o=a?String(t&&t.scope&&t.scope.scope_model||``).trim():``;return a||o?{provider:a||null,model:o||n||null}:{provider:null,model:n||null}}function VM(e,t){if(!e)return null;let n=(()=>{let t=String(e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`?t:null})(),r=(()=>{if(e.status_code===void 0||e.status_code===null)return null;let t=String(e.status_code).trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null})(),i=n?!0:e.cache_hit!==void 0&&e.cache_hit!==null&&!!e.cache_hit,a=IM(e),o=BM(e,t),s=Number.isFinite(r)&&r>=200&&r<300,c=String(e.error_type||``).trim().toLowerCase()===`authentication_error`,l=String(e.auth_method||``).trim().toLowerCase()||null,u=RM(e).toLowerCase()===`budget_exceeded`;return{cacheHit:i,cacheType:n||null,failoverTarget:a&&a.targetModel?a.targetModel:null,provider:o.provider,model:o.model,statusCode:r,responseSuccess:s,aiSuccess:s&&!i,authError:c,authMethod:l,budgetExceeded:u}}function HM(e){return!!(e&&e.cacheHit)}function UM(e){return!!(e&&e.failoverTarget)}function WM(e){return!!(e&&e.budgetExceeded)}function GM(e,t){return t?`workflow-node-current`:e&&e.cacheHit?`workflow-node-success`:``}function KM(e){return e&&e.cacheHit?`workflow-conn-hit`:``}function qM(e){return!e||!e.cacheHit?null:e.cacheType===`semantic`?`Hit (Semantic)`:`Hit (Exact)`}function JM(e,t,n,r){return e?WM(t)?`workflow-node-error`:r?`workflow-node-current`:n?`workflow-node-success`:``:``}function YM(e){return WM(e)?`Exceeded`:null}function XM(e){return e&&e.cacheHit?`workflow-node-skipped`:e&&e.failoverTarget?`workflow-node-success`:``}function ZM(e){return e&&e.cacheHit?`workflow-conn-dim`:e&&e.failoverTarget?`workflow-conn-hit`:``}function QM(e){return e&&e.failoverTarget?`Redirected`:null}function $M(e){return e&&e.failoverTarget?e.failoverTarget:null}function eN(e){return e&&e.cacheHit?`workflow-conn-dim`:``}function tN(e,t){return e?e.cacheHit?`workflow-node-skipped`:t?`workflow-node-current`:e.aiSuccess?`workflow-node-success`:``:``}function nN(e,t){if(!e)return``;let n=e.statusCode;return!Number.isFinite(n)&&t?`workflow-node-current`:Number.isFinite(n)?n>=500?`workflow-node-error`:n>=400?`workflow-node-warning`:n>=300?`workflow-node-neutral`:n>=200?`workflow-node-success`:``:``}function rN(e){return!e||!Number.isFinite(e.statusCode)?null:String(e.statusCode)}function iN(e,t){return e?e.authError?`workflow-node-error`:t?`workflow-node-current`:e.authMethod===`api_key`||e.authMethod===`master_key`?`workflow-node-success`:``:``}function aN(e){return!e||!e.authMethod?null:e.authMethod}function oN(e,t,n){return e?n?`workflow-node-current`:t?`workflow-node-success`:``:``}function sN(e,t){if(!e||!e._live)return!!t;let n=String(e._live_state||``).trim();return!!e._audit_flushed||n===`audit.flushed`||n===`audit.detail`}function cN(e,t){if(!e)return!!t;let n=e.usage||{},r=Number(n.entries||0)>0;if(!e._live)return r;let i=String(e._usage_live_state||``).trim();return e._usage_flushed||i===`usage.flushed`?!0:!e._usage_live_pending&&r&&!e._live_pending}function lN(e){return!!(e&&e._live&&e._usage_live_pending&&!e._usage_flushed)}function uN(e,t){return!e||!e._live||sN(e,!1)?!1:String(e._live_state||``).trim()===`audit.completed`||!!(t&&Number.isFinite(t.statusCode))}function dN(e,t,n){return!e||!e._live?``:lN(e)?`usage`:uN(e,t)?`audit`:sN(e,!1)&&!e._live_pending?``:t&&t.cacheHit?`cache`:t&&(t.provider||t.model)?`ai`:n&&n.budget&&(e.workflow_version_id||e.requested_model)?`budget`:t&&t.authMethod?``:`auth`}function fN(e,t,n,r){let i=n||{},a=i.features&&typeof i.features==`object`&&!Array.isArray(i.features)?Uj(i.features):Gj(e,r),o=!!i.forceAudit,s=!!i.highlightAsyncPresent,c=!!a.budget||WM(t),l=!!a.guardrails,u=!!a.usage,d=o||!!a.audit,f=!!i.forceAsync||!!(u||d),p=!!a.failover||UM(t),m=PM(e,i.entry),h=dN(i.entry,t,a),g=lN(i.entry),_=uN(i.entry,t),v=sN(i.entry,s),y=cN(i.entry,s);return{showBudget:c,budgetNodeClass:JM(c,t,s,h===`budget`),budgetStatusLabel:YM(t),showGuardrails:l,guardrailLabel:l?jM(e):``,showCache:!!i.forceCache||!!a.cache||HM(t),cacheNodeClass:GM(t,h===`cache`),cacheConnClass:KM(t),cacheStatusLabel:qM(t),showFailover:p,failoverNodeClass:p?XM(t):``,failoverConnClass:p?ZM(t):``,failoverStatusLabel:p?QM(t):null,failoverTargetLabel:p?$M(t):null,aiLabel:MM(e,t),aiSublabel:NM(e,t),aiConnClass:eN(t),aiNodeClass:tN(t,h===`ai`),responseConnClass:eN(t),responseNodeClass:nN(t,h===`response`),responseNodeSublabel:rN(t),authNodeClass:iN(t,h===`auth`),authNodeSublabel:aN(t),usageNodeClass:oN(u,y,g),auditNodeClass:oN(d,v,_),showAsync:f,showUsage:u,showAudit:d,workflowID:m}}function pN(e,t){return fN(e,null,{forceCache:!1},t)}function mN(e,t,n){return fN(t,VM(e,t),{entry:e,features:FM(e)||(t?Gj(t,n):{cache:!1,audit:!1,usage:!1,budget:!1,guardrails:!1,failover:!1}),forceAudit:!0,forceAsync:!0,highlightAsyncPresent:!0},n)}var hN=R(`

                `),gN=R(`

                `),_N=R(`
                `),vN=R(`
                `),yN=R(`

                No guardrails configured for this workflow.

                `),bN=R(`

                Guardrails

                `),xN=R(``),SN=R(`

                `);function CN(e,t){E(t,!0);let n=ya(t,`preview`,3,!1),r=O(()=>hM.featureCaps()),i=O(()=>tM(t.workflow)),a=O(()=>Jj(t.workflow,I(r))),o=O(()=>pN(t.workflow,I(r))),s=O(()=>n()?`draft-workflow-preview-guardrail-`:t.workflow.id+`-guardrail-`);var c=SN();let l;var u=M(c),d=M(u),f=M(d),p=M(f,!0);T(f);var m=P(f,2),h=M(m,!0);T(m),T(d);var g=P(d,2),_=M(g),v=M(_,!0);T(_),T(g),T(u);var y=P(u,2),b=e=>{var n=hN(),r=M(n,!0);T(n),F(()=>B(r,t.workflow.description)),z(e,n)};V(y,e=>{t.workflow.description&&e(b)});var x=P(y,2),S=e=>{var n=gN(),i=M(n);T(n),F(e=>B(i,`Failover: ${e??``}`),[()=>Kj(t.workflow,I(r))]),z(e,n)},C=O(()=>hM.failoverVisible());V(x,e=>{I(C)&&e(S)});var w=P(x,2);AM(w,{get chart(){return I(o)}});var ee=P(w,2),te=e=>{var t=bN(),n=M(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var o=P(n,2),c=e=>{var t=vN();H(t,23,()=>I(a),(e,t)=>I(s)+t,(e,t)=>{var n=_N(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a);T(a),T(n),F(()=>{B(i,I(t).ref),B(o,`step ${I(t).step??``}`)}),z(e,n)}),T(t),z(e,t)},l=e=>{z(e,yN())};V(o,e=>{I(a).length>0?e(c):e(l,-1)}),T(t),F(()=>B(i,I(a).length?I(a).length+` steps`:`None`)),z(e,t)},ne=O(()=>Ss.guardrailsVisible());V(ee,e=>{I(ne)&&e(te)});var re=P(ee,2),ie=e=>{var n=xN(),r=M(n),a=M(r),o=M(a,!0);T(a);var s=P(a,2);{let e=O(()=>`Edit workflow `+I(i));gT(s,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>hM.openCreate(t.workflow),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(r);var c=P(r,2),l=M(c),u=M(l);T(l);var d=P(l,2),f=M(d);T(d);var p=P(d,2),m=M(p);T(p),T(c),T(n),F((e,n,r,s)=>{a.disabled=e,W(a,`aria-label`,`Deactivate workflow `+I(i)),W(a,`title`,n),B(o,hM.deactivatingID===t.workflow.id?`Deactivating...`:`Deactivate`),B(u,`version: v${t.workflow.version??``}`),B(f,`created: ${r??``}`),B(m,`hash: ${s??``}`)},[()=>hM.deactivatingID===t.workflow.id||!lM(t.workflow),()=>lM(t.workflow)?`Deactivate active workflow`:`The global workflow cannot be deactivated.`,()=>ds.formatTimestamp(t.workflow.created_at),()=>uM(t.workflow.workflow_hash)]),L(`click`,a,()=>hM.deactivate(t.workflow)),z(e,n)};V(re,e=>{n()||e(ie)}),T(c),F((e,t)=>{l=U(c,1,`workflow-card svelte-1fo9fvq`,null,l,{"workflow-preview-card":n()}),B(p,e),B(h,I(i)),B(v,t)},[()=>$j(t.workflow),()=>eM(t.workflow)]),z(e,c),D()}Hr([`click`]);var wN=R(`

                `),TN=R(``),EN=R(``),DN=R(``),ON=R(``),kN=R(``),AN=R(``),jN=R(``),MN=R(``),NN=R(``),PN=R(``),FN=R(``),IN=R(``),LN=R(`
                No named guardrails are currently registered on this deployment. You can still draft a workflow, but guardrail-backed creation may be rejected.
                `),RN=R(`
                `),zN=R(`
                `),BN=R(`

                No guardrail steps configured yet.

                `),VN=R(`

                Guardrail Steps

                Guardrails in the same numeric step run together. Later steps wait for earlier ones to finish.

                `),HN=R(`

                Leave provider name empty to target all providers and models. Select a provider name without a model to target all models for that configured provider.

                Add a path to scope the workflow to that subtree. Leading slashes are optional and will be normalized; you can enter "team/alpha" or "/team/alpha". Matching checks the deepest user path first, then falls back toward the root.

                If you leave the name empty, the workflow will display as the matched provider/model scope or “All models”.

                Preview

                Live
                `,1);function UN(e,t){E(t,!0);{let t=e=>{qS(e,{copyId:`workflow-help-copy`,label:`workflow help`,text:`Create immutable version. Submitting activates it for the selected scope.`,title:e=>{var t=wN(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>hM.submitMode()===`save`?`Edit Workflow`:`Create Workflow`]),z(e,t)},$$slots:{title:!0}})},n=O(()=>hM.submitLabel()),r=O(()=>hM.submittingLabel()),i=O(()=>hM.submitMode()===`create`?po:_o);bE(e,{get open(){return hM.formOpen},ariaLabel:`Workflow editor`,get error(){return hM.formError},get submitting(){return hM.submitting},get submitLabel(){return I(n)},get submittingLabel(){return I(r)},get submitIcon(){return I(i)},dialogClass:`workflow-editor`,onclose:()=>hM.closeForm(),onsubmit:()=>hM.submitForm(),header:t,children:(e,t)=>{var n=HN(),r=N(n),i=M(r);SE(i,{id:`workflow-scope-provider`,label:`Provider Name`,children:(e,t)=>{var n=EN(),r=M(n);r.value=r.__value=``,H(P(r),16,()=>hM.providerOptions(),e=>e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(n),L(`change`,n,e=>hM.setProvider(e.currentTarget.value)),Gi(n,()=>hM.form.scope_provider,e=>hM.form.scope_provider=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2),o=e=>{SE(e,{id:`workflow-scope-model`,label:`Model`,children:(e,t)=>{var n=DN(),r=M(n);r.value=r.__value=``,H(P(r),17,()=>hM.modelOptions(hM.form.scope_provider),e=>hM.form.scope_provider+`-`+e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t)),i!==(i=I(t))&&(n.value=(n.__value=I(t))??``)}),z(e,n)}),T(n),Gi(n,()=>hM.form.scope_model,e=>hM.form.scope_model=e),z(e,n)},$$slots:{default:!0}})};V(a,e=>{hM.form.scope_provider&&e(o)});var s=P(a,2);SE(s,{id:`workflow-name`,label:`Name`,children:(e,t)=>{var n=ON();na(n),da(n,()=>hM.form.name,e=>hM.form.name=e),z(e,n)},$$slots:{default:!0}}),SE(P(s,2),{id:`workflow-user-path`,label:`User Path`,children:(e,t)=>{var n=kN();na(n),da(n,()=>hM.form.scope_user_path,e=>hM.form.scope_user_path=e),z(e,n)},$$slots:{default:!0}}),T(r);var c=P(r,8);SE(c,{id:`workflow-description`,label:`Description`,children:(e,t)=>{var n=AN();ft(n),da(n,()=>hM.form.description,e=>hM.form.description=e),z(e,n)},$$slots:{default:!0}});var l=P(c,2),u=M(l),d=e=>{var t=jN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.cache,e=>hM.form.features.cache=e),z(e,t)},f=O(()=>Ss.cacheVisible());V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var t=MN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.audit,e=>hM.form.features.audit=e),z(e,t)},h=O(()=>Ss.auditVisible());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=e=>{var t=NN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.usage,e=>hM.form.features.usage=e),z(e,t)},v=O(()=>Ss.usageVisible());V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=PN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.budget,e=>hM.form.features.budget=e),z(e,t)},x=O(()=>Ss.budgetsVisible());V(y,e=>{I(x)&&e(b)});var S=P(y,2),C=e=>{var t=FN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.guardrails,e=>hM.form.features.guardrails=e),z(e,t)},w=O(()=>Ss.guardrailsVisible());V(S,e=>{I(w)&&e(C)});var ee=P(S,2),te=e=>{var t=IN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.failover,e=>hM.form.features.failover=e),z(e,t)},ne=O(()=>hM.failoverVisible());V(ee,e=>{I(ne)&&e(te)}),T(l);var re=P(l,2),ie=P(M(re),2);{let e=O(()=>hM.preview());CN(ie,{get workflow(){return I(e)},preview:!0})}T(re);var ae=P(re,2),oe=e=>{var t=VN(),n=M(t),r=P(M(n),2);T(n);var i=P(n,2),a=e=>{var t=LN(),n=P(M(t),2);T(t),L(`click`,n,()=>Jo.navigate(`guardrails`)),z(e,t)};V(i,e=>{hM.guardrailRefs.length===0&&e(a)});var o=P(i,2),s=e=>{var t=zN();H(t,21,()=>hM.form.guardrails,oi,(e,t,n)=>{var r=RN(),i=M(r),a=M(i);W(a,`for`,`workflow-guardrail-ref-`+n);var o=P(a,2);na(o),W(o,`id`,`workflow-guardrail-ref-`+n),W(o,`aria-label`,`Guardrail reference `+(n+1)),T(i);var s=P(i,2),c=M(s);W(c,`for`,`workflow-guardrail-step-`+n);var l=P(c,2);na(l),W(l,`id`,`workflow-guardrail-step-`+n),W(l,`aria-label`,`Guardrail step `+(n+1)),T(s);var u=P(s,2);T(r),da(o,()=>I(t).ref,e=>I(t).ref=e),da(l,()=>I(t).step,e=>I(t).step=e),L(`click`,u,()=>hM.removeGuardrailStep(n)),z(e,r)}),T(t),z(e,t)},c=e=>{z(e,BN())};V(o,e=>{hM.form.guardrails.length>0?e(s):e(c,-1)}),T(t),L(`click`,r,()=>hM.addGuardrailStep()),z(e,t)},se=O(()=>hM.form.features.guardrails&&Ss.guardrailsVisible());V(ae,e=>{I(se)&&e(oe)}),z(e,n)},$$slots:{header:!0,default:!0}})}D()}Hr([`change`,`click`]);var WN=R(`

                Loading workflows...

                `),GN=R(`
                `),KN=R(`

                No active workflows found.

                `),qN=R(`

                No workflows match your filter.

                `),JN=R(`
                `);function YN(e,t){E(t,!0);var n=JN(),r=M(n),i=e=>{var t=WN();SS(M(t),{size:16,label:`Loading workflows`}),Ue(),T(t),z(e,t)};V(r,e=>{hM.loading&&!K.authError&&e(i)});var a=P(r,2),o=e=>{var t=GN();H(t,21,()=>hM.filteredWorkflows,e=>e.id,(e,t)=>{CN(e,{get workflow(){return I(t)}})}),T(t),z(e,t)};V(a,e=>{hM.filteredWorkflows.length>0&&e(o)});var s=P(a,2),c=e=>{z(e,KN())};V(s,e=>{hM.workflows.length===0&&!hM.loading&&!K.authError&&hM.available&&e(c)});var l=P(s,2),u=e=>{z(e,qN())};V(l,e=>{hM.workflows.length>0&&hM.filteredWorkflows.length===0&&!hM.loading&&e(u)}),T(n),z(e,n),D()}var XN=R(``),ZN=R(`
                Workflows feature is unavailable.
                `),QN=R(`
                `),$N=R(`
                `),eP=R(``),tP=R(`
                `);function nP(e,t){E(t,!0),An(()=>{K.refreshTick,hM.fetchPage()});var n=tP(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=XN();G(M(t),{get icon(){return po},class:`form-action-icon`,"aria-hidden":`true`}),Ue(2),T(t),L(`click`,t,()=>hM.openCreate()),z(e,t)};V(a,e=>{hM.available&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,ZN())};V(s,e=>{!hM.available&&!K.authError&&e(c)});var l=P(s,2),u=e=>{var t=QN(),n=M(t,!0);T(t),F(()=>B(n,hM.error)),z(e,t)};V(l,e=>{hM.error&&!K.authError&&e(u)});var d=P(l,2),f=e=>{var t=$N(),n=M(t);yw(M(n),{placeholder:`Filter by scope, name, hash, or guardrail...`,label:`Filter workflows by scope, name, hash, or guardrail`,get value(){return hM.filter},set value(e){hM.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i,!0);T(i),T(r),T(t),F(()=>B(a,hM.filteredWorkflows.length+` active scopes`)),z(e,t)};V(d,e=>{hM.available&&e(f)});var p=P(d,2);UN(p,{});var m=P(p,2);YN(m,{});var h=P(m,2);H(h,20,()=>hM.guardrailRefs,e=>e,(e,t)=>{var n=eP(),r={};F(()=>{r!==(r=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(h),T(n),z(e,n),D()}Hr([`click`]);function rP(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=Xs}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=iP(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function iP(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}var aP=null;function oP(){return aP===null&&(aP=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`)),!!(aP&&aP.matches)}function sP(e){return oP()?0:e}function cP(e,t){return!t||!t.live?{duration:0}:Js(e,{duration:sP(150)})}var lP=new class{#e=k(j({}));get workflowVersionsByID(){return I(this.#e)}set workflowVersionsByID(e){A(this.#e,e,!0)}workflowVersionRequests={};workflowFeatureCaps(){return{cache:Ss.cacheVisible(),audit:Ss.auditVisible(),usage:Ss.usageVisible(),budget:Ss.budgetsVisible(),guardrails:Ss.guardrailsVisible(),failover:Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}}cacheWorkflowVersion(e){let t=String(e&&e.id||``).trim();return t?(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:e},e):null}cacheMissingWorkflowVersion(e){let t=String(e||``).trim();t&&(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:null})}workflowVersionCacheHas(e){return Object.prototype.hasOwnProperty.call(this.workflowVersionsByID||{},String(e||``).trim())}workflowVersionByID(e){let t=String(e||``).trim();return t&&this.workflowVersionCacheHas(t)?this.workflowVersionsByID[t]:null}async fetchWorkflowVersion(e){let t=String(e||``).trim();if(!t)return null;if(this.workflowVersionCacheHas(t))return this.workflowVersionsByID[t];if(this.workflowVersionRequests[t])return this.workflowVersionRequests[t];let n=(async()=>{let e=typeof AbortController==`function`?new AbortController:null,n=e?setTimeout(()=>e.abort(),1e4):null;try{let n=await _s(`/admin/workflows/`+encodeURIComponent(t),{label:`workflow`,signal:e?e.signal:void 0});if(n.stale)return null;if(n.status===404)return this.cacheMissingWorkflowVersion(t),null;if(!n.ok)return null;let r=n.data;return!r||typeof r!=`object`||Array.isArray(r)?(this.cacheMissingWorkflowVersion(t),null):this.cacheWorkflowVersion(r)}catch(e){return e&&e.name===`AbortError`||console.error(`Failed to fetch workflow version:`,e),null}finally{n!==null&&clearTimeout(n),delete this.workflowVersionRequests[t]}})();return this.workflowVersionRequests[t]=n,n}async prefetchAuditWorkflows(e){let t=[...new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.workflow_version_id||``).trim()).filter(Boolean))];t.length!==0&&await Promise.all(t.map(e=>this.fetchWorkflowVersion(e)))}auditEntryWorkflow(e){let t=String(e&&e.workflow_version_id||``).trim();return t?this.workflowVersionByID(t):null}},uP=6;function dP(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}function fP(e,t=0,n=null){let r=String(e||``).trim();if(!r)return``;if(t>uP)return r;let i=dP(r);return i==null?r:pP(i,t+1,n)||n&&n(i)||r}function pP(e,t=0,n=null,r=null){if(e==null||t>uP)return``;if(typeof e==`string`){let i=dP(e.trim());return i==null?``:pP(i,t+1,n,r)}if(typeof e!=`object`)return``;let i=r||new Set;if(i.has(e))return``;if(i.add(e),Array.isArray(e)){for(let r=0;r=400||gP(t&&t.response_body)}function vP(e){let t=e&&e.data?e.data:null;return t?mP(t.error_message)||(_P(e,t)?pP(t.response_body,0):``):``}function yP(e){if(e==null||String(e).trim()===``)return null;let t=Number(e);return!Number.isInteger(t)||t<0?null:t}function bP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained indefinitely.`:t===1?`Audit logs are retained for 1 day.`:`Audit logs are retained for `+t+` days.`}function xP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained `:`Audit logs are retained for `}function SP(e){let t=yP(e);return t===null?``:t===0?`indefinitely`:t===1?`1 day`:t+` days`}function CP({dateQuery:e,limit:t,offset:n,search:r,method:i,statusCode:a,stream:o}){let s=e;return s+=`&limit=`+t+`&offset=`+n,r&&(s+=`&search=`+encodeURIComponent(r)),i&&(s+=`&method=`+encodeURIComponent(i)),a&&(s+=`&status_code=`+encodeURIComponent(a)),o&&(s+=`&stream=`+encodeURIComponent(o)),s}function wP({sessionId:e,limit:t}){return`session_id=`+encodeURIComponent(e)+`&limit=`+(t||100)+`&offset=0`}function TP(e){return String(e&&e.session_id||``).trim()}function EP(e){let t=Number(e&&e.session_count);return Number.isFinite(t)&&t>1?t:1}function DP(e){return!!TP(e)&&EP(e)>1}function OP(e){return{entries:(Array.isArray(e&&e.sessions)?e.sessions:[]).filter(e=>e&&e.latest).map(e=>({...e.latest,session_id:TP(e.latest)||String(e.session_id||``).trim(),session_count:Number(e.count||1)})),total:Number(e&&e.total||0),limit:Number(e&&e.limit||25),offset:Number(e&&e.offset||0)}}function kP(e,t,n){let r=new Set((Array.isArray(n)?n:[]).flatMap(e=>NP(e))),i=(Array.isArray(t)?t:[]).filter(e=>!NP(e).some(e=>r.has(e))),a=new Set([...r,...i.flatMap(e=>NP(e))]),o=(e&&Array.isArray(e.entries)?e.entries:[]).filter(e=>e&&e._live&&!NP(e).some(e=>a.has(e)));return{entries:[...o,...i],preservedCount:o.length}}function AP(e,t){let n=e||{};if(!t)return n;if(n[t]){let e={...n};return delete e[t],e}return{...n,[t]:!0}}function jP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>TP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=n[e];return}a=!0}),a?i:n}function MP(e){return String(e&&e.id||``).trim()}function NP(e){if(!e)return[];let t=[],n=String(e.id||``).trim(),r=String(e.request_id||``).trim();return n&&t.push(`id:`+n),r&&t.push(`request:`+r),t}function PP(e){return!!(e&&e._live&&e._live_pending&&!e._audit_flushed)}function FP(e){let t=e&&e.customStartDate,n=e&&e.customEndDate;if(!t&&!n)return!0;let r=new Date;if(t){let e=new Date(t);if(e.setHours(0,0,0,0),Number.isFinite(e.getTime())&&re)return!1}return!0}function IP(e,t){return e&&Number(e.offset||0)===0&&!(t&&t.search)&&!(t&&t.method)&&!(t&&t.statusCode)&&!(t&&t.stream)&&FP(t)}function LP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=[];return a.forEach(e=>{let t=NP(e);t.length!==0&&(t.some(e=>o.has(e))||(t.forEach(e=>o.add(e)),s.push(e)))}),s.length===0?r:(r.entries=[...s,...i].slice(0,r.limit||25),r.total=Number(r.total||0)+s.length,r)}function RP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=new Map;i.forEach((e,t)=>{let n=TP(e);n&&!s.has(n)&&s.set(n,t)});let c=[],l=i;return a.forEach(e=>{let t=NP(e);if(t.length===0||t.some(e=>o.has(e)))return;let n=TP(e);if(n&&s.has(n)){let r=s.get(n);l===i&&(l=[...i]),l[r]={...e,session_count:Math.max(EP(l[r]),EP(e))},t.forEach(e=>o.add(e));return}t.forEach(e=>o.add(e)),c.push(e)}),r.entries=[...c,...l].slice(0,r.limit||25),r.total=Number(r.total||0)+c.length,r}function zP(e,t){let n=MP(t),r=e||{};return n?r[n]?{}:{[n]:!0}:r}function BP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>MP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=!0;return}a=!0}),a?i:n}function VP(e){if(e==null)return`-`;let t=Number(e);return Number.isFinite(t)?t<=0?`pending`:t<1e6?Math.round(t/1e3)+` µs`:t<1e9?(t/1e6).toFixed(2)+` ms`:(t/1e9).toFixed(2)+` s`:`-`}function HP(e){if(e==null||e===``)return`status-unknown`;let t=Number(e);return Number.isFinite(t)?t>=500?`status-error`:t>=400?`status-warning`:t>=300?`status-neutral`:`status-success`:`status-unknown`}function UP(e){if(!e||!e._live||!e._live_pending)return!1;let t=String(e._live_state||``).trim();if(t===`audit.completed`||t===`audit.flushed`||t===`audit.detail`)return!1;if(e._response_partial)return!0;if(e.status_code!==null&&e.status_code!==void 0&&e.status_code!==``||Number(e.duration_ns||0)>0||e.error_type||e.error_message)return!1;let n=e.data||{};return!(n.response_headers||n.response_body||n.error_message)}function WP(e){let t=e&&e.data&&e.data.failover;return!t||typeof t!=`object`||Array.isArray(t)?null:String(t.target_model||t.targetModel||``).trim()||null}function GP(e){return(e&&e.data&&Array.isArray(e.data.attempts)?e.data.attempts:[]).map((e,t)=>({...e,seq:Number(e&&e.seq||t+1)})).sort((e,t)=>e.seq-t.seq)}function KP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))}function qP(e){if(!e)return`-`;let t=e.status_code||e.status;return t?String(t):e.success?`ok`:`error`}function JP(e){return String(e&&e.kind||``).trim()||`attempt`}function YP(e){if(!e)return`-`;let t=String(e.provider_name||``).trim(),n=String(e.provider_type||e.provider||``).trim();return t&&n&&t!==n?t+` (`+n+`)`:t||n||`-`}function XP(e){return String(e&&e.model||``).trim()||`-`}function ZP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))?t:[]}function QP(e){return GP(e).length+`×`}function $P(e){let t=GP(e),n=t.filter(e=>!(e&&e.success)).length,r=t.length===1?`attempt`:`attempts`,i=t.length+` provider `+r;return n>0?i+` · `+n+` failed`:i}function eF(e){if(!e)return``;let t=[`#`+Number(e.seq||0)],n=JP(e);n&&n!==`attempt`&&t.push(n),t.push(qP(e));let r=YP(e);r&&r!==`-`&&t.push(r);let i=XP(e);return i&&i!==`-`&&t.push(i),t.push(e.success?`succeeded`:`failed`),t.join(` · `)}function tF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t&&t.response_body!=null?t.response_body:null}return t.response_body!=null&&t.response_body!==``?t.response_body:null}function nF(e){if(!e||e.success)return``;let t=String(e.error_message||``).trim(),n=String(e.error_code||``).trim(),r=String(e.error_type||``).trim();return t&&n?n+`: `+t:t||n||r||`Provider attempt failed`}function rF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t?t.response_headers:null}return t.response_headers||null}function iF(e){let t=Number(e&&e.status_code);return Number.isFinite(t)&&t>0?t:null}function aF(e,t){let n=!!(t&&t.success),r=e&&e.data?e.data:null,i=tF(e,t),a=rF(e,t),o=nF(t),s=i!=null&&i!==``,c=JP(t),l=GP(e).length<=1;return{title:`Response`,direction:`response`,seq:l?0:Number(t&&t.seq||0),kind:l||c===`attempt`?``:c,statusCode:l?null:iF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:i,showErrorMessage:!!o,errorMessage:o,showHeaders:!!a,headers:a,showBody:s,body:i,showEmpty:!o&&!s&&!a,emptyMessage:`No response was captured for this attempt.`,showTooLarge:!!(n&&r&&r.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function oF(e){return e&&e.data&&Array.isArray(e.data.request_revisions)?e.data.request_revisions:[]}function sF(e){return oF(e).filter(e=>!(e&&e.no_change))}function cF(e){return oF(e).filter(e=>e&&e.no_change).map(e=>{let t=String(e.rewriter||`rewriter`);return{id:`step-`+Number(e.seq||0),rewriter:t,label:t+`: no change`,title:t+` ran and forwarded the request unchanged`}})}function lF(e){let t=Number(e&&e.bytes_before),n=Number(e&&e.bytes_after);if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n>=t)return``;let r=(1-n/t)*100;return`-`+(r>=10?String(Math.round(r)):r.toFixed(1))+`%`}function uF(e,t){let n=t&&t.body,r=n!=null&&n!==``,i=sF(e).length<=1,a={rewriter:t&&t.rewriter||``,bytes:Number(t&&t.bytes_before||0)+` → `+Number(t&&t.bytes_after||0)};return t&&t.detail!=null&&(a.detail=t.detail),{title:`Rewritten`,direction:`request`,seq:i?0:Number(t&&t.seq||0),kind:t&&t.rewriter?String(t.rewriter):``,savingsLabel:lF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:n,showErrorMessage:!1,errorMessage:null,showHeaders:!0,headers:a,headersTitle:`What changed`,showBody:r,body:n,showEmpty:!1,emptyMessage:``,showTooLarge:!r,tooLargeMessage:`Rewritten body not captured (body logging disabled or body too large).`}}function dF(e){let t=e&&e.usage;return!t||typeof t!=`object`?null:t}function fF(e){let t=dF(e);return Number(t&&t.cached_input_tokens||0)>0}function pF(e){let t=dF(e),n=Number(t&&t.input_tokens||0),r=Number(t&&t.cached_input_tokens||0);return!Number.isFinite(n)||n<=0||!Number.isFinite(r)||r<=0?0:Math.max(0,Math.min(100,r/n*100))}function mF(e){let t=dF(e);if(!t)return``;let n=Number(t.input_tokens||0),r=Number(t.cached_input_tokens||0);return n<=0?oc(r)+` cached`:pF(e).toFixed(1)+`% cached`}function hF(e){return fF(e)?mF(e):``}function gF(e,t){let n=dF(e);if(!n||!e||!e.data||!e.data.request_body)return null;let r=Number(n.estimated_cached_characters||0);if(!Number.isFinite(r)||r<=0||typeof t!=`function`)return null;let i=t(e.data.request_body);return!Array.isArray(i)||i.length===0?null:{characters:r,segments:i}}function _F(e,t){let n=e&&e.data?e.data:null,r=!n||!n.request_headers&&!n.request_body,i=r&&UP(e);return{title:`Request`,direction:`request`,layout:`split`,entry:e,copyHeaders:n&&n.request_headers,copyBody:n&&n.request_body,showErrorMessage:!1,errorMessage:null,showHeaders:!!(n&&n.request_headers),headers:n&&n.request_headers,showBody:!!(n&&n.request_body),body:n&&n.request_body,bodyCacheRatioLabel:hF(e),promptCacheHighlight:gF(e,t),noChangeSteps:cF(e),showEmpty:r&&!i,emptyMessage:`Request details were not captured.`,showPending:i,pendingMessage:`Waiting for request data…`,showTooLarge:!!(n&&n.request_body_too_big_to_handle),tooLargeMessage:`Request body was too large to capture.`}}function vF(e){let t=e&&e.data?e.data:null,n=vP(e),r=!t||!n&&!t.response_headers&&!t.response_body,i=r&&UP(e);return{title:`Response`,direction:`response`,layout:`split`,entry:e,copyHeaders:t&&t.response_headers,copyBody:t&&t.response_body,showErrorMessage:!!n,errorMessage:n,showHeaders:!!(t&&t.response_headers),headers:t&&t.response_headers,showBody:!!(t&&t.response_body),body:t&&t.response_body,streaming:!!(e&&e._response_partial&&t&&t.response_body)&&UP(e),showEmpty:r&&!i,emptyMessage:`Response details were not captured.`,showPending:i,pendingMessage:`Response in progress…`,showTooLarge:!!(t&&t.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function yF(e,t){let n=[{id:`request`,pane:_F(e,t)}];return sF(e).forEach(t=>{n.push({id:`revision-`+Number(t&&t.seq||0),pane:uF(e,t)})}),KP(e)?GP(e).forEach(t=>{n.push({id:`response-`+Number(t&&t.seq||0),pane:aF(e,t)})}):n.push({id:`response`,pane:vF(e)}),n}function bF(e){if(!KP(e))return`response`;let t=GP(e),n=null;return t.forEach(e=>{e&&e.success&&(n=e)}),n||=t[t.length-1],n?`response-`+Number(n.seq||0):`request`}function xF(e,t,n){return e&&(Array.isArray(n)?n:yF(t)).some(t=>t.id===e)?e:bF(t)}function SF(e,t,n){if(!t||!t.length)return null;let r=t.indexOf(n);r<0&&(r=0);let i;switch(e){case`ArrowRight`:case`ArrowDown`:i=(r+1)%t.length;break;case`ArrowLeft`:case`ArrowUp`:i=(r-1+t.length)%t.length;break;case`Home`:i=0;break;case`End`:i=t.length-1;break;default:return null}return t[i]}var CF=100;function wF(){return{entries:[],total:0,limit:25,offset:0}}var TF=new class{#e=k(j({}));get auditExpandedEntries(){return I(this.#e)}set auditExpandedEntries(e){A(this.#e,e,!0)}#t=k(j({}));get auditExpandedThreads(){return I(this.#t)}set auditExpandedThreads(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}auditFetchToken=0;get auditLog(){return MC.auditLog}set auditLog(e){MC.auditLog=e}get auditSearch(){return MC.auditSearch}set auditSearch(e){MC.auditSearch=e}get auditMethod(){return MC.auditMethod}set auditMethod(e){MC.auditMethod=e}get auditStatusCode(){return MC.auditStatusCode}set auditStatusCode(e){MC.auditStatusCode=e}get auditStream(){return MC.auditStream}set auditStream(e){MC.auditStream=e}get auditGroupSessions(){return MC.auditGroupSessions}liveFilters(){return{search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream,customStartDate:Mc.customStartDate,customEndDate:Mc.customEndDate}}toggleAuditGroupSessions(){MC.auditGroupSessions=!MC.auditGroupSessions,Ea(`gomodel_audit_group_sessions`,MC.auditGroupSessions),this.auditExpandedThreads={},MC.auditThreadChildren={},this.fetchAuditLog(!0)}async fetchAuditLog(e){let t=++this.auditFetchToken;this.loading=!0;try{e&&(this.auditLog.offset=0);let n=this.auditGroupSessions,r=CP({dateQuery:Mc.queryStr(),limit:this.auditLog.limit,offset:this.auditLog.offset,search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream}),i=await _s((n?`/admin/audit/sessions?`:`/admin/audit/log?`)+r,{label:`audit log`});if(i.stale||t!==this.auditFetchToken)return;if(!i.ok){this.auditLog=wF();return}let a=n?OP(i.data):i.data,o=(n?RP:LP)(a,this.auditLog&&this.auditLog.entries,this.liveFilters());Array.isArray(o.entries)||(o.entries=[]),o.entries=MC.upsertAuditRecords(o.entries,`audit.list`),this.auditLog=o,this.auditExpandedThreads=jP(this.auditExpandedThreads,o.entries),MC.auditThreadChildren=jP(MC.auditThreadChildren,o.entries);let s=[...o.entries,...this.loadedThreadChildren()];this.auditExpandedEntries=BP(this.auditExpandedEntries,s);try{await lP.prefetchAuditWorkflows(s)}catch(e){console.error(`Failed to prefetch audit workflows:`,e)}}catch(e){if(console.error(`Failed to fetch audit log:`,e),t!==this.auditFetchToken)return;this.auditLog=wF()}finally{t===this.auditFetchToken&&(this.loading=!1)}}loadedThreadChildren(){let e=MC.auditThreadChildren||{};return Object.keys(e).flatMap(t=>Array.isArray(e[t]&&e[t].entries)?e[t].entries:[])}isThreadExpanded(e){return!!(e&&this.auditExpandedThreads[e])}threadChildren(e){return e&&MC.auditThreadChildren[e]||null}async toggleThread(e){let t=TP(e);if(!t)return;let n=!this.isThreadExpanded(t);this.auditExpandedThreads=AP(this.auditExpandedThreads,t);let r=MC.auditThreadChildren[t];n&&!(r&&(r.loaded||r.loading))&&await this.fetchThreadEntries(e)}async fetchThreadEntries(e){let t=TP(e);if(!t)return;let n=MC.auditThreadChildren[t];MC.auditThreadChildren={...MC.auditThreadChildren,[t]:{loading:!0,loaded:!1,entries:n&&Array.isArray(n.entries)?n.entries:[],total:Number(n&&n.total||0)}};let r=()=>{let e={...MC.auditThreadChildren},n=e[t],r=n&&Array.isArray(n.entries)?n.entries:[];r.length>0?e[t]={loading:!1,loaded:!1,entries:r,total:r.length}:(delete e[t],this.auditExpandedThreads[t]&&(this.auditExpandedThreads=AP(this.auditExpandedThreads,t))),MC.auditThreadChildren=e};try{let n=await _s(`/admin/audit/log?`+wP({sessionId:t,limit:CF}),{label:`audit session`});if(n.stale){r();return}if(!n.ok)throw Error(`audit session fetch failed`);let i=MC.auditThreadChildren[t],a=this.auditLog.entries.find(e=>TP(e)===t),o=kP(i,n.data.entries,a?[a]:[e]);o.entries=MC.upsertAuditRecords(o.entries,`audit.thread`),MC.auditThreadChildren={...MC.auditThreadChildren,[t]:{loading:!1,loaded:!0,entries:o.entries,total:Number(n.data.total||0)+o.preservedCount}}}catch(e){console.error(`Failed to fetch audit session entries:`,e),r()}}clearAuditFilters(){this.auditSearch=``,this.auditMethod=``,this.auditStatusCode=``,this.auditStream=``,this.fetchAuditLog(!0)}auditLogNextPage(){this.auditLog.offset+this.auditLog.limit0&&(this.auditLog.offset=Math.max(0,this.auditLog.offset-this.auditLog.limit),this.fetchAuditLog(!1))}isAuditEntryExpanded(e){let t=MP(e);return t?!!(this.auditExpandedEntries&&this.auditExpandedEntries[t]):!1}toggleAuditEntryExpanded(e){this.auditExpandedEntries=zP(this.auditExpandedEntries,e);let t=this.isAuditEntryExpanded(e);return t&&typeof MC.fetchAuditEntryDetail==`function`&&MC.fetchAuditEntryDetail(e),t}expandAuditEntry(e){this.isAuditEntryExpanded(e)||this.toggleAuditEntryExpanded(e)}};MC.fetchAuditLog=e=>TF.fetchAuditLog(e),MC.isAuditEntryExpanded=e=>TF.isAuditEntryExpanded(e);var EF=R(`
                `);function DF(e,t){E(t,!0);let n=bw(()=>TF.fetchAuditLog(!0));An(()=>n.cancel);var r=EF(),i=M(r);yw(M(i),{id:`audit-filter-search`,placeholder:`Search by request ID, model, provider, path, user path, or error...`,label:`Search by request ID, model, provider, path, user path, or error`,get oninput(){return n},get value(){return TF.auditSearch},set value(e){TF.auditSearch=e}}),T(i);var a=P(i,2),o=M(a),s=M(o);s.value=s.__value=``;var c=P(s);c.value=c.__value=`GET`;var l=P(c);l.value=l.__value=`POST`;var u=P(l);u.value=u.__value=`PUT`;var d=P(u);d.value=d.__value=`PATCH`;var f=P(d);f.value=f.__value=`DELETE`,T(o);var p=P(o,2),m=M(p);m.value=m.__value=``;var h=P(m);h.value=h.__value=`200`;var g=P(h);g.value=g.__value=`201`;var _=P(g);_.value=_.__value=`400`;var v=P(_);v.value=v.__value=`401`;var y=P(v);y.value=y.__value=`403`;var b=P(y);b.value=b.__value=`404`;var x=P(b);x.value=x.__value=`429`;var S=P(x);S.value=S.__value=`500`;var C=P(S);C.value=C.__value=`502`;var w=P(C);w.value=w.__value=`503`;var ee=P(w);ee.value=ee.__value=`504`,T(p);var te=P(p,2),ne=M(te);ne.value=ne.__value=``;var re=P(ne);re.value=re.__value=`true`;var ie=P(re);ie.value=ie.__value=`false`,T(te);var ae=P(te,2);G(M(ae),{get icon(){return Io},class:`table-icon-svg`}),Ue(2),T(ae),T(a),T(r),L(`change`,o,()=>TF.fetchAuditLog(!0)),Gi(o,()=>TF.auditMethod,e=>TF.auditMethod=e),L(`change`,p,()=>TF.fetchAuditLog(!0)),Gi(p,()=>TF.auditStatusCode,e=>TF.auditStatusCode=e),L(`change`,te,()=>TF.fetchAuditLog(!0)),Gi(te,()=>TF.auditStream,e=>TF.auditStream=e),L(`click`,ae,()=>TF.clearAuditFilters()),z(e,r),D()}Hr([`change`,`click`]);var OF=R(`Live stream connecting…`),kF=R(` `),AF=R(`Live`),jF=R(` `);function MF(e,t){E(t,!0);let n=O(()=>MC.auditLivePauseReason()),r=O(()=>MC.liveLogsStreaming&&!I(n));var i=Qr(),a=N(i),o=e=>{var t=jF(),i=M(t);let a;var o=P(i,2),s=e=>{z(e,OF())},c=e=>{var t=kF(),r=M(t,!0);T(t),F(e=>B(r,e),[()=>bC(I(n))]),z(e,t)},l=e=>{z(e,AF())};V(o,e=>{MC.liveLogsStreaming?I(n)?e(c,1):e(l,-1):e(s)}),T(t),F(()=>a=U(i,1,`live-dot svelte-tve6yv`,null,a,{"is-streaming":I(r)})),z(e,t)},s=O(()=>Ss.liveLogsVisible());V(a,e=>{I(s)&&e(o)}),z(e,i),D()}var NF=R(` `),PF=R(``);function FF(e,t){E(t,!0);let n=O(()=>[{key:`provider`,text:gc(t.entry)||`-`},{key:`model`,text:t.entry.requested_model||t.entry.model||`-`,mono:!0},{key:`user_path`,text:t.entry.user_path,mono:!0},{key:`request_id`,text:`request_id: `+(t.entry.request_id||`-`),mono:!0},{key:`ip`,text:t.entry.client_ip&&`ip: `+t.entry.client_ip,mono:!0},{key:`auth_key_id`,text:t.entry.auth_key_id&&`auth_key_id: `+t.entry.auth_key_id,mono:!0},{key:`alias`,text:t.entry.alias_used&&`alias`,class:`audit-alias-badge`},{key:`resolved`,text:t.entry.alias_used&&t.entry.resolved_model&&`resolved: `+yc(t.entry),mono:!0},{key:`failover`,text:WP(t.entry)&&`failover: `+WP(t.entry),mono:!0},{key:`stream`,text:t.entry.stream&&`stream`},{key:`error_type`,text:t.entry.error_type}].filter(e=>!!e.text));var r=PF(),i=P(M(r),2);H(i,21,()=>I(n),e=>e.key,(e,t)=>{var n=NF(),r=M(n,!0);T(n),F(()=>{U(n,1,Fi([`provider-badge`,I(t).class,{mono:I(t).mono}]),`svelte-hyopt0`),B(r,I(t).text)}),z(e,n)}),T(i),T(r),z(e,r),D()}var IF=R(``),LF=R(` `);function RF(e,t){E(t,!0);let n=O(()=>ZP(t.entry)),r=O(()=>I(n).length>0?$P(t.entry):``),i=O(()=>I(n).length>0?QP(t.entry):``);var a=Qr(),o=N(a),s=e=>{var a=LF(),o=M(a);H(o,21,()=>I(n),e=>t.entry.id+`-pip-`+e.seq,(e,t)=>{var n=IF();let r;F(e=>{r=U(n,1,`audit-attempt-pip svelte-1eu22xn`,null,r,{"audit-attempt-success":!!(I(t)&&I(t).success),"audit-attempt-error":!(I(t)&&I(t).success)}),W(n,`title`,e)},[()=>eF(I(t))]),z(e,n)}),T(o);var s=P(o,2),c=M(s,!0);T(s),T(a),F(()=>{W(a,`title`,I(r)),W(a,`aria-label`,I(r)),B(c,I(i))}),z(e,a)};V(o,e=>{I(n).length>0&&e(s)}),z(e,a),D()}var zF=new Set([`instructions`,`messages`,`input`,`previous_response_id`,`choices`,`output`]);function BF(e){if(!e||typeof e!=`object`)return``;let t=String(e.type||``).toLowerCase();if(t===`image`||t===`image_url`||t===`input_image`||t===`output_image`)return`[Image]`;if(t===`audio`||t===`input_audio`||t===`output_audio`)return`[Audio]`;if(t===`file`||t===`input_file`||t===`output_file`){let t=String(e.filename||e.name||``).trim();return t?`[File: `+t+`]`:`[File]`}return typeof e.refusal==`string`?e.refusal:``}function VF(e){if(e==null)return``;if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:!e||typeof e!=`object`?``:typeof e.text==`string`?e.text:typeof e.output_text==`string`?e.output_text:BF(e)).filter(Boolean).join(` +`).trim();if(typeof e==`object`){if(typeof e.text==`string`)return e.text.trim();try{return JSON.stringify(e,null,2)}catch{return``}}return String(e).trim()}function HF(e){return!e||typeof e!=`object`?``:VF(e.content)||(typeof e.refusal==`string`?e.refusal.trim():``)}function UF(e){if(e==null)return[];if(typeof e==`string`)return e?[e]:[];if(Array.isArray(e))return e.flatMap(e=>typeof e==`string`?e?[e]:[]:!e||typeof e!=`object`?[]:typeof e.text==`string`?e.text?[e.text]:[]:typeof e.output_text==`string`&&e.output_text?[e.output_text]:[]);if(typeof e==`object`)return typeof e.text==`string`&&e.text?[e.text]:[];let t=String(e);return t?[t]:[]}function WF(e){let t=Number(e&&e.usage&&e.usage.estimated_cached_characters||0);return Number.isFinite(t)&&t>0?Math.floor(t):0}function GF(e,t){if(!e)return null;let n=(Array.isArray(t)?t:[]).reduce((e,t)=>e+String(t||``).length,0),r=Math.min(String(e).length,n);return r>0?{total:r}:null}function KF(e){let t=e&&e.arguments!==void 0?e.arguments:``,n=``;if(typeof t==`string`)n=t;else try{n=JSON.stringify(t)}catch{n=String(t)}return(String(e&&e.name||``)+`(`+n+`)`).length}function qF(e){return{characters:(Array.isArray(e)?e:[]).map(KF)}}function JF(e,t){let n=Math.max(0,Number(t||0));return e.map(e=>{if(!e||e.role===`error`)return e;let t=Math.max(0,Number(e._promptTextCharacters||0)),r=Math.min(n,t);n-=r;let i=0;(Array.isArray(e._toolPromptCharacters)?e._toolPromptCharacters:[]).forEach(e=>{let t=Math.max(0,Number(e||0)),r=Math.min(n,t);n-=r,i+=r});let a=t+(e._toolPromptCharacters||[]).reduce((e,t)=>e+Math.max(0,Number(t||0)),0);return{...e,promptCacheRatio:a>0?(r+i)/a:0}})}function YF(e){if(e==null)return[];if(typeof e==`string`){let t=e.trim();return t?[{role:`user`,text:t}]:[]}if(!Array.isArray(e)){let t=VF(e);return t?[{role:`user`,text:t}]:[]}return e.map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e.role||`user`).toLowerCase(),n=VF(e.content);return n?{role:t,text:n}:null}).filter(Boolean)}function XF(e){return!e||typeof e!=`object`?``:Array.isArray(e.content)?e.content.map(e=>e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` +`).trim():VF(e.content)}function ZF(e){if(!e||typeof e!=`object`)return[];let t=[];return t.push(...UF(e.instructions)),Array.isArray(e.messages)&&e.messages.forEach(e=>{!e||typeof e!=`object`||t.push(...UF(e.content))}),typeof e.input==`string`?t.push(e.input):Array.isArray(e.input)?e.input.forEach(e=>{!e||typeof e!=`object`||(t.push(...UF(e.content)),typeof e.text==`string`&&t.push(e.text))}):e.input&&typeof e.input==`object`&&(t.push(...UF(e.input.content)),typeof e.input.text==`string`&&t.push(e.input.text)),t.map(e=>String(e||``)).filter(e=>e.length>0)}var QF=e=>VF(e);function $F(e){if(!e||!e.data)return``;let t=pP(e.data.response_body,0,QF);if(t)return t;let n=e.data.error_message;if(n==null)return``;if(typeof n==`string`){let e=n.trim();return e?pP(dP(e),0,QF)||e:``}return pP(n,0,QF)||VF(n)}function eI(e){return Array.isArray(e)?e.some(e=>!e||typeof e!=`object`?!1:e.type===`message`||e.role===`assistant`||e.role===`user`||e.role===`system`?!0:Array.isArray(e.content)?e.content.some(e=>!e||typeof e!=`object`?!1:typeof e.text==`string`||e.type===`output_text`||e.type===`input_text`):!1):!1}function tI(e){if(!e)return!1;let t=String(e).toLowerCase();return t===`/v1/embeddings`||t===`/v1/embeddings/`||t.startsWith(`/v1/embeddings?`)||t.startsWith(`/v1/embeddings/`)}function nI(e){return e?!!iI(e):!1}function rI(e){let t=String(e||``).trim().split(`?`)[0].replace(/\/+$/,``).toLowerCase();return t.startsWith(`/v1/`)?t.slice(3):t}function iI(e){switch(rI(e)){case`/chat/completions`:return`chat`;case`/responses`:return`responses`;case`/messages`:return`messages`;default:return``}}function aI(e){if(!e||typeof e!=`object`)return null;try{return JSON.parse(JSON.stringify(e))}catch{return null}}function oI(e,t){if(!t||typeof t!=`object`)return;let n=e[e.length-1];try{if(n&&JSON.stringify(n)===JSON.stringify(t))return}catch{}e.push(t)}function sI(e){let t=iI(e&&e.path),n=e&&e.data&&e.data.request_body;return!t||!n||typeof n!=`object`?!1:t!==`responses`||(e.data&&e.data.response_body&&typeof e.data.response_body.id==`string`?e.data.response_body.id.trim():``)!==``||GI(n)!==``}function cI(e,t){let n=String(t||``).trim(),r=iI(e&&e.path),i=aI(e&&e.data&&e.data.request_body);if(!n||!r||!i)return null;let a=e&&e.data?e.data.response_body:null;if(r===`responses`){let e=a&&typeof a.id==`string`?a.id.trim():``,t=GI(i);return!e&&!t?null:(i.input=n,e&&!t?i.previous_response_id=e:delete i.previous_response_id,i)}let o=Array.isArray(i.messages)?i.messages:[];if(r===`chat`){let e=a&&Array.isArray(a.choices)?a.choices[0]:null;e&&e.message&&oI(o,aI(e.message)),o.push({role:`user`,content:n})}else a&&a.content!==void 0&&oI(o,{role:String(a.role||`assistant`),content:aI(a.content)||a.content}),o.push({role:`user`,content:n});return i.messages=o,i}var lI=new Set(`authorization.proxy-authorization.cookie.content-type.content-length.host.accept.connection.accept-encoding.content-encoding.transfer-encoding.user-agent.date.expect.upgrade.via.te.trailer.keep-alive.origin.referer.forwarded.x-real-ip.traceparent.tracestate.x-request-id.idempotency-key.x-idempotency-key.x-gomodel-timezone.x-gomodel-interaction-parent`.split(`.`));function uI(e,t,n=``){let r=e&&e.data&&e.data.request_headers,i={};return r&&typeof r==`object`&&Object.keys(r).forEach(e=>{let t=String(e).toLowerCase(),n=String(r[e]==null?``:r[e]);!e||!n||n===`[REDACTED]`||lI.has(t)||t.startsWith(`sec-`)||t.startsWith(`cf-`)||t.startsWith(`x-forwarded-`)||(i[e]=n)}),i[`X-GoModel-Interaction-Parent`]=String(t||e&&e.id||``).trim(),String(n||``).trim()&&(i[`X-Request-ID`]=String(n).trim()),i}function dI(e,t){let n=String(t||``).trim();return!n||!Array.isArray(e)?null:e.find(e=>String(e&&e.request_id||``).trim()===n)||null}function fI(e,t,n,r,i){let a=Array.isArray(e)?e:[],o=String(i&&i.id||``).trim(),s=String(i&&i.request_id||``).trim(),c=String(i&&i.session_id||``).trim(),l=String(r||``).trim(),u=pI(i),d=a.some(e=>o&&String(e&&e.id||``).trim()===o||s&&String(e&&e.request_id||``).trim()===s),f=!!l&&s===l,p=!!n&&c===String(n).trim(),m=!!u&&(u===String(t||``).trim()||a.some(e=>String(e&&e.id||``).trim()===u)),h=d||f||!l&&(p||m);return{accepted:h,submittedChild:f,followUpRequestID:h&&f&&o?``:l}}function pI(e){let t=e&&e.data&&e.data.request_headers;if(!t||typeof t!=`object`)return``;let n=Object.keys(t).find(e=>e.toLowerCase()===`x-gomodel-interaction-parent`);return n?String(t[n]||``).trim():``}function mI(e,t){return!Array.isArray(e)||!t?null:e.find(e=>String(e&&e.id||``)===String(t))||null}function hI(e){return!Array.isArray(e)||e.length===0?null:e.reduce((e,t)=>e?KI(t,e)>=0?t:e:t,null)}function gI(e,t){let n=new Set(Array.isArray(t)?t.map(String):[]);return hI((Array.isArray(e)?e:[]).filter(e=>{let t=String(e&&e.id||``);return n.has(t)&&e&&e.data&&e.data.request_body!=null}))}function _I(e,t){let n=hI(e);return!!n&&String(n.id||``)===String(t||``)}function vI(e,t,n){return String(e||``).trim()===`audit.flushed`&&String(t||``).trim()!==``&&String(t||``).trim()===String(n||``).trim()}function yI(e,t){let n=Array.isArray(e)?e.filter(Boolean).map(String):[];return(Array.isArray(t)?t:[]).forEach(e=>{let t=String(e&&(e.id||e.request_id)||``).trim();t&&!n.includes(t)&&n.push(t)}),n}function bI(e){if(e&&e.conversation_payload)return!0;let t=e&&e.data?e.data.request_body:null,n=e&&e.data?e.data.response_body:null,r=t&&(Array.isArray(t.messages)||t.input!==void 0||typeof t.instructions==`string`||typeof t.previous_response_id==`string`),i=n&&(Array.isArray(n.choices)||eI(n.output));return!!(r||i)}function xI(e){return!e||tI(e.path)?!1:nI(e.path)||bI(e)}function SI(e){let t=0,n=!1,r=!1,i=String(e||``);for(let e=0;e0&&a+1`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function EI(e){return!!(e&&typeof e==`object`&&e.__audio__===!0)}function DI(e){let t=Number(e||0);if(!Number.isFinite(t)||t<=0)return`0 B`;let n=[`B`,`KB`,`MB`,`GB`],r=0,i=t;for(;i>=1024&&r`
                `+TI(t)+``+TI(kI(e[t]))+`
                `);return t.length?``:``}function jI(e){let t=OI(e.content_type),n=TI(t+` · `+DI(e.bytes)),r=AI(e.meta);if(e.stored&&e.encoding===`base64`&&e.data){let i=String(e.data).replace(/[^A-Za-z0-9+/=]/g,``);return`
                `+n+`
                `+r+`
                `}let i=e.too_large?`Audio too large to store.`:`Audio not logged. Set LOGGING_LOG_AUDIO_BODIES=true to capture playable audio.`;return`
                `+n+`
                `+TI(i)+`
                `+r+`
                `}function MI(e){try{return JSON.stringify(String(e)).slice(1,-1)}catch{return``}}function NI(e){if(!e||typeof e!=`object`)return null;let t=Number(e.characters||0);if(!Number.isFinite(t)||t<=0)return null;let n=Array.isArray(e.segments)?e.segments.map(e=>String(e||``)).filter(Boolean):[];return n.length===0?null:{remaining:Math.floor(t),segments:n,segmentIndex:0}}function PI(e,t){if(!t||t.remaining<=0||t.segmentIndex>=t.segments.length)return TI(e);let n=``,r=0,i=0;for(;t.remaining>0&&t.segmentIndex`+TI(l)+``,r=s+l.length,i=s+o.length,t.remaining-=c,c>=a.length){t.segmentIndex++;continue}break}return n?n+TI(e.slice(r)):TI(e)}function FI(e,t,n){let r=n&&typeof n.formatJSON==`function`?n.formatJSON:e=>String(e),i=n&&typeof n.canShowConversation==`function`?n.canShowConversation:()=>!1,a=NI(n&&n.promptCacheHighlight),o=r(t);if(!o||o===`Not captured`)return TI(o);if(!i(e))return o.split(` +`).map(e=>PI(e,a)).join(` +`);let s=o.split(` +`),c=[],l=0;for(;lPI(e,a)).join(` +`);c.push(``+o+``),l=r+1;continue}c.push(PI(e,a)),l++}return c.join(` +`)}function II(e){let t=String(e||``).toLowerCase();return t===`system`||t===`developer`?{role:`system`,label:`System Prompt`,className:`role-system`}:t===`assistant`?{role:`assistant`,label:`Agent`,className:`role-assistant`}:t===`error`?{role:`error`,label:`Error`,className:`role-error`}:t===`function_call`?{role:`function_call`,label:`Function Call`,className:`role-function-call`}:t===`function_result`?{role:`function_result`,label:`Function Result`,className:`role-function-result`}:{role:`user`,label:`User`,className:`role-user`}}function LI(e,t,{timestamp:n,entryID:r,isAnchor:i,isAfterAnchor:a,index:o,toolCalls:s,functionName:c,functionCallID:l,promptCache:u,toolPromptCache:d}){let f=II(e),p=u&&Number.isFinite(Number(u.total))?Math.max(0,Number(u.total)):u===null?0:String(t||``).length,m=d&&Array.isArray(d.characters)?d.characters:qF(s).characters;return{uid:r+`-`+o,entryID:r,timestamp:n,text:t,role:f.role,roleLabel:f.label,roleClass:f.className,isAnchor:i,isAfterAnchor:a,toolCalls:Array.isArray(s)&&s.length>0?s:null,functionName:c||``,functionCallID:l||``,promptCacheRatio:0,_promptTextCharacters:p,_toolPromptCharacters:m}}function RI(e){return Array.isArray(e)?e.map(e=>{if(!e)return null;let t=e.function||e,n=``;return t.arguments===void 0?e.arguments===void 0?t.input===void 0?e.input!==void 0&&(n=e.input):n=t.input:n=e.arguments:n=t.arguments,{name:t.name||e.name||``,arguments:n,id:e.call_id||e.id||``}}).filter(Boolean):[]}function zI(e){return Array.isArray(e)?RI(e.filter(e=>e&&typeof e==`object`&&e.type===`tool_use`)):[]}function BI(e){return Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`tool_result`).map(e=>({id:e.tool_use_id||e.call_id||``,text:VF(e.content)})):[]}function VI(e,t,n){!t||!n||[t.call_id,t.id].forEach(t=>{t&&(e[t]=n)})}function HI(e,t,n){if(t&&Array.isArray(t.messages)&&t.messages.forEach(t=>{t&&[...Array.isArray(t.tool_calls)?t.tool_calls:[],...Array.isArray(t.content)?t.content.filter(e=>e&&e.type===`tool_use`):[]].forEach(t=>{t&&VI(e,t,(t.function||t).name||t.name||``)})}),t&&Array.isArray(t.input)&&t.input.forEach(t=>{!t||typeof t!=`object`||t.type!==`function_call`&&t.type!==`tool_use`||VI(e,t,t.name||``)}),n&&Array.isArray(n.choices)){let t=n.choices[0];t&&t.message&&Array.isArray(t.message.tool_calls)&&t.message.tool_calls.forEach(t=>{t&&VI(e,t,(t.function||t).name||t.name||``)})}n&&Array.isArray(n.output)&&n.output.forEach(t=>{!t||t.type!==`function_call`&&t.type!==`tool_use`||VI(e,t,t.name||``)}),n&&Array.isArray(n.content)&&n.content.forEach(t=>{!t||t.type!==`tool_use`||VI(e,t,t.name||``)})}function UI(e){return Array.isArray(e)?`[`+e.map(UI).join(`,`)+`]`:e&&typeof e==`object`?`{`+Object.keys(e).sort().map(t=>JSON.stringify(t)+`:`+UI(e[t])).join(`,`)+`}`:JSON.stringify(e)}function WI(e){if(!e||typeof e!=`object`)return null;let t=[];if(e.system!==void 0&&t.push({system:e.system}),e.instructions!==void 0&&t.push({instructions:e.instructions}),Array.isArray(e.messages))t.push(...e.messages);else if(Array.isArray(e.input)&&e.previous_response_id==null&&e.conversation==null)t.push(...e.input);else return null;return t.map(UI)}function GI(e){let t=e&&e.conversation;return typeof t==`string`?t.trim():t&&typeof t.id==`string`?t.id.trim():``}function KI(e,t){let n=new Date(e&&e.timestamp).getTime(),r=new Date(t&&t.timestamp).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r)return n-r;let i=String(e&&e.timestamp||``).localeCompare(String(t&&t.timestamp||``));if(i!==0)return i;let a=String(e&&e.id||``),o=String(t&&t.id||``);return ao)}function qI(e,t){if(!Array.isArray(e)||e.length===0)return{messages:[],entryIDs:[]};let n=[...e].sort(KI),r={};n.forEach(e=>{let t=e.data&&e.data.request_body?e.data.request_body:null,n=e.data&&e.data.response_body?e.data.response_body:null;HI(r,t,n)});let i=[],a=new Set,o=new Set,s=new Set,c=[],l=null,u=0,d=n.findIndex(e=>e.id===t),f=e=>JSON.stringify({role:e.role,text:e.text,toolCalls:e.toolCalls,functionName:e.functionName,functionCallID:e.functionCallID});return n.forEach((e,n)=>{let p=e.id===t,m=d>=0&&n>d,h=e.timestamp,g=e.data&&e.data.request_body?e.data.request_body:null,_=e.data&&e.data.response_body?e.data.response_body:null,v=i.length,y=(e,t)=>GF(e,t),b=e=>qF(e),x=(t,n,{toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s}={})=>LI(t,n,{timestamp:h,entryID:e.id,isAnchor:p,isAfterAnchor:m,index:++u,toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s});if(g&&g.system!==void 0){let e=VF(g.system);e&&i.push(x(`system`,e,{promptCache:y(e,UF(g.system))}))}if(g&&g.instructions!==void 0){let e=VF(g.instructions);e&&i.push(x(`system`,e,{promptCache:y(e,UF(g.instructions))}))}g&&Array.isArray(g.messages)&&g.messages.forEach(e=>{if(!e)return;let t=(e.role||`user`).toLowerCase();if(t===`tool`){let t=VF(e.content),n=e.name||r[e.tool_call_id]||``;t&&i.push(x(`function_result`,t,{functionName:n,functionCallID:e.tool_call_id||``,promptCache:y(t,UF(e.content))}));return}if(t===`assistant`){let n=HF(e),r=[...RI(e.tool_calls),...zI(e.content)];if(n||r.length>0){let a=y(n,UF(e.content));i.push(x(t,n,{toolCalls:r,promptCache:a,toolPromptCache:b(r)}))}return}BI(e.content).forEach(e=>{e.text&&i.push(x(`function_result`,e.text,{functionName:r[e.id]||``,functionCallID:e.id,promptCache:y(e.text,[e.text])}))});let n=HF(e);n&&i.push(x(t,n,{promptCache:y(n,UF(e.content))}))}),g&&g.input!==void 0&&(Array.isArray(g.input)?g.input.forEach(e=>{if(!(!e||typeof e!=`object`)){if(e.type===`function_call_output`){let t=typeof e.output==`string`?e.output:VF(e.output);t&&i.push(x(`function_result`,t,{functionName:r[e.call_id]||e.name||``,functionCallID:e.call_id||``,promptCache:y(t,[t])}))}else if(e.type===`function_call`){let t=RI([e]);i.push(x(`function_call`,``,{toolCalls:t,toolPromptCache:b(t)}))}else if(e.role){let t=String(e.role).toLowerCase(),n=VF(e.content);n&&i.push(x(t,n,{promptCache:y(n,UF(e.content))}))}}}):YF(g.input).forEach(e=>{if(!e.text)return;let t=[];typeof g.input==`string`?t=[g.input]:g.input&&typeof g.input==`object`&&(t=UF(g.input.content),typeof g.input.text==`string`&&t.push(g.input.text)),i.push(x(e.role,e.text,{promptCache:y(e.text,t)}))}));let S=i.splice(v),C=S.map(f),w=WI(g),ee=w!==null,te=pI(e),ne=!!te&&a.has(te),re=String(g&&g.previous_response_id||``).trim(),ie=GI(g),ae=ne||!!re&&o.has(re)||!!ie&&s.has(ie);if(m){let e=ee&&l&&l.length>0&&l.every((e,t)=>w[t]===e);if(ee&&!e&&!ne||!ee&&!ae)return}p&&ee&&(l=[...w]);let oe=String(e.id||``).trim();p&&(a.clear(),o.clear(),s.clear()),oe&&(p||m)&&a.add(oe),ie&&s.add(ie);let se=0;for(;se0;){let t=c.slice(-e),n=C.slice(0,e);if(t.every((e,t)=>e===n[t]))break;e--}i.push(...S.slice(e)),c.push(...C.slice(e))}if(g&&i.splice(0,i.length,...JF(i,WF(e))),_&&Array.isArray(_.choices)){let e=_.choices[0];if(e&&e.message){let t=(e.message.role||`assistant`).toLowerCase(),n=HF(e.message),r=RI(e.message.tool_calls);if(n||r.length>0){let e=x(t,n,{toolCalls:r});i.push(e),c.push(f(e))}}}if(_&&Array.isArray(_.output)&&_.output.forEach(e=>{if(!e)return;if(e.type===`function_call`){let t=x(`function_call`,``,{toolCalls:RI([e])});i.push(t),c.push(f(t));return}let t=(e.role||`assistant`).toLowerCase(),n=XF(e);if(n){let e=x(t,n);i.push(e),c.push(f(e))}}),_&&_.content!==void 0&&!Array.isArray(_.choices)&&!Array.isArray(_.output)){let e=String(_.role||`assistant`).toLowerCase(),t=VF(_.content),n=zI(_.content);if(t||n.length>0){let r=x(e,t,{toolCalls:n});i.push(r),c.push(f(r))}}let ce=$F(e);ce&&i.push(x(`error`,ce));let le=String(_&&_.id||``).trim();le&&o.add(le)}),{messages:i,entryIDs:[...a]}}function JI(e){return e.role===`function_call`?(e.toolCalls||[]).map(function(e){return e.name+`(`+YI(e)+`)`}).join(` + +`):e.text||``}function YI(e){let t=e&&e.arguments!==void 0?e.arguments:``;if(typeof t!=`string`)try{return JSON.stringify(t,null,2)}catch{return String(t)}try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var XI=600*1e3,ZI=15*1e3,QI=250,$I=class{#e=k(!1);get conversationOpen(){return I(this.#e)}set conversationOpen(e){A(this.#e,e,!0)}#t=k(!1);get conversationLoading(){return I(this.#t)}set conversationLoading(e){A(this.#t,e,!0)}#n=k(``);get conversationError(){return I(this.#n)}set conversationError(e){A(this.#n,e,!0)}#r=k(``);get conversationAnchorID(){return I(this.#r)}set conversationAnchorID(e){A(this.#r,e,!0)}#i=k(j([]));get conversationEntryIDs(){return I(this.#i)}set conversationEntryIDs(e){A(this.#i,e,!0)}#a=k(``);get conversationSessionID(){return I(this.#a)}set conversationSessionID(e){A(this.#a,e,!0)}#o=k(!1);get conversationTruncated(){return I(this.#o)}set conversationTruncated(e){A(this.#o,e,!0)}#s=k(!1);get conversationFollowLatest(){return I(this.#s)}set conversationFollowLatest(e){A(this.#s,e,!0)}#c=k(``);get conversationOpenedFromID(){return I(this.#c)}set conversationOpenedFromID(e){A(this.#c,e,!0)}#l=k(``);get followUpText(){return I(this.#l)}set followUpText(e){A(this.#l,e,!0)}#u=k(!1);get followUpSending(){return I(this.#u)}set followUpSending(e){A(this.#u,e,!0)}#d=k(``);get followUpError(){return I(this.#d)}set followUpError(e){A(this.#d,e,!0)}followUpRequestID=``;followUpAbort=null;conversationRequestToken=0;conversationReturnFocusEl=null;bodyPointerStart=null;#f=k(null);get conversationDialogEl(){return I(this.#f)}set conversationDialogEl(e){A(this.#f,e,!0)}#p=k(null);get conversationCloseBtnEl(){return I(this.#p)}set conversationCloseBtnEl(e){A(this.#p,e,!0)}#m=k(null);get conversationThreadEl(){return I(this.#m)}set conversationThreadEl(e){A(this.#m,e,!0)}get conversationEntries(){return(this.conversationEntryIDs||[]).map(e=>MC.auditRecord(e)).filter(Boolean)}#h=O(()=>qI(this.conversationEntries,this.conversationAnchorID));get conversationView(){return I(this.#h)}set conversationView(e){A(this.#h,e)}get conversationMessages(){return this.conversationView.messages}get conversationBranchEntryIDs(){return this.conversationView.entryIDs}_setConversationEntryIDs(e){this.conversationEntryIDs=[...new Set((Array.isArray(e)?e:[]).filter(Boolean))],MC.pinAuditRecords(this.conversationEntryIDs)}canShowConversation(e){return xI(e)}startBodyInteraction(e){this.bodyPointerStart={x:e.clientX,y:e.clientY}}_isBodyDrag(e){if(!this.bodyPointerStart)return!1;let t=Math.abs(e.clientX-this.bodyPointerStart.x),n=Math.abs(e.clientY-this.bodyPointerStart.y);return t>4||n>4}_hasActiveSelection(){let e=window.getSelection?window.getSelection():null;return!e||e.isCollapsed?!1:String(e.toString()||``).trim().length>0}handleBodyConversationClick(e,t){let n=this._isBodyDrag(e);if(this.bodyPointerStart=null,n||this._hasActiveSelection()||!this.canShowConversation(t))return;let r=e.target&&e.target.closest?e.target.closest(`[data-conversation-trigger="1"]`):null;r&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,r))}handleErrorConversationClick(e,t){let n=this._isBodyDrag(e);this.bodyPointerStart=null,!n&&(this._hasActiveSelection()||this.canShowConversation(t)&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,e.currentTarget)))}formatJSON(e){return ac(e)}renderBodyWithConversationHighlights(e,t,n){return FI(e,t,{formatJSON:e=>this.formatJSON(e),canShowConversation:e=>this.canShowConversation(e),promptCacheHighlight:n&&n.promptCacheHighlight})}async openConversation(e,t){if(!e||!e.id||!this.canShowConversation(e))return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null;t instanceof HTMLElement?this.conversationReturnFocusEl=t:n&&n!==document.body&&(this.conversationReturnFocusEl=n);let r=++this.conversationRequestToken;if(this.conversationOpen=!0,this.conversationError=``,this.conversationAnchorID=e.id,this.conversationOpenedFromID=e.id,this.conversationSessionID=String(e.session_id||``).trim(),this._setConversationEntryIDs([]),this.conversationTruncated=!1,this.conversationFollowLatest=!1,this.followUpText=``,this.followUpError=``,this.followUpRequestID=``,requestAnimationFrame(()=>this._focusConversationDrawer()),this._conversationEntryLivePending(e)){this.conversationFollowLatest=!0,this.conversationLoading=!1,this._addConversationRecord(MC.upsertAuditRecord(e,`conversation.live`));return}this.conversationLoading=!0,await this.fetchConversation(e.id,r,!0,!0)}_conversationEntryLivePending(e){return typeof MC.auditEntryLiveDetailPending==`function`&&MC.auditEntryLiveDetailPending(e)}_applyConversationView(){let e=this.conversationEntries,t=qI(e,this.conversationAnchorID);if(this.conversationFollowLatest){let n=gI(e,t.entryIDs);n&&n.id&&String(n.id)!==this.conversationAnchorID&&(this.conversationAnchorID=String(n.id))}}handleAuditRecordChange(e,t){if(!this.conversationOpen||!e)return;let n=String(e.id||``).trim(),r=fI(this.conversationEntries,this.conversationAnchorID,this.conversationSessionID,this.followUpRequestID,e);if(r.accepted&&(this.followUpRequestID=r.followUpRequestID,n&&r.submittedChild&&(this.conversationAnchorID=n,this.conversationFollowLatest=!0),this._addConversationRecord(e),vI(String(t||e._live_state||``).trim(),n,this.conversationAnchorID))){this.conversationMessages.length===0&&(this.conversationLoading=!0);let e=++this.conversationRequestToken;this.fetchConversation(n,e,!1)}}_addConversationRecord(e){let t=TC(e);t&&!this.conversationEntryIDs.includes(t)&&this._setConversationEntryIDs([...this.conversationEntryIDs,t]),!this.conversationSessionID&&e.session_id&&(this.conversationSessionID=String(e.session_id).trim()),this._applyConversationView(),this.conversationFollowLatest&&this._scheduleLatestScroll()}conversationLiveWaiting(){if(!this.conversationOpen)return!1;let e=new Set(this.conversationBranchEntryIDs||[]);return(this.conversationEntries||[]).some(t=>e.has(String(t&&t.id||``))&&t._live&&(typeof MC.liveAuditStateSettled!=`function`||!MC.liveAuditStateSettled(t._live_state)))}conversationLiveStatusText(){return(this.conversationMessages||[]).length>0?`Model is responding…`:`Waiting for request data…`}closeConversation(){this.followUpAbort&&this.followUpAbort.abort(),this.conversationOpen=!1,this.conversationRequestToken++,this.conversationSessionID=``,this._setConversationEntryIDs([]),this.conversationFollowLatest=!1,this.conversationOpenedFromID=``,this.followUpRequestID=``,this.followUpSending=!1;let e=this.conversationReturnFocusEl;this.conversationReturnFocusEl=null,e&&typeof e.focus==`function`&&document.contains(e)&&requestAnimationFrame(()=>e.focus())}_focusConversationDrawer(){if(!this.conversationOpen)return;let e=this.conversationCloseBtnEl;if(e&&typeof e.focus==`function`){e.focus();return}let t=this.conversationDialogEl;t&&typeof t.focus==`function`&&t.focus()}async fetchConversation(e,t,n=!0,r=!1){try{let i=await _s(`/admin/audit/conversation?`+(`log_id=`+encodeURIComponent(e)+`&limit=120`),{label:`audit conversation`});if(t!==this.conversationRequestToken||i.stale)return;if(!i.ok){this.conversationError=`Unable to load interactions.`;return}let a=i.data||{},o=a.anchor_id||e,s=Array.isArray(a.entries)?a.entries:[],c=MC.upsertAuditRecords(s,`conversation.hydrated`),l=yI(this.conversationEntryIDs,c);l.length>this.conversationEntryIDs.length&&this._setConversationEntryIDs(l),r&&(this.conversationFollowLatest=_I(c,o)),this.conversationAnchorID=o;let u=this.conversationEntries.find(e=>e.id===this.conversationAnchorID);u&&u.session_id&&(this.conversationSessionID=String(u.session_id).trim()),this.conversationTruncated=!!a.truncated,this._applyConversationView(),this.conversationFollowLatest?this._scheduleLatestScroll():n&&this._scheduleAnchorScroll()}catch(e){if(t!==this.conversationRequestToken)return;console.error(`Failed to fetch audit conversation:`,e),this.conversationError=`Failed to load interactions.`}finally{t===this.conversationRequestToken&&(this.conversationLoading=!1)}}selectedConversationEntry(){return mI(this.conversationEntries,this.conversationAnchorID)}followUpKind(){let e=this.selectedConversationEntry();return sI(e)?iI(e.path):``}canSendFollowUp(){return!!this.followUpKind()&&!!String(this.followUpText||``).trim()&&!this.followUpSending&&!this.conversationLiveWaiting()}async sendFollowUp(){if(!this.canSendFollowUp())return;let e=this.selectedConversationEntry(),t=cI(e,this.followUpText);if(!e||!t)return;let n=this.conversationAnchorID,r=tL(),i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},XI);this.followUpSending=!0,this.followUpError=``,this.followUpRequestID=r,this.followUpAbort=i;try{let a=uI(e,n,r),o=await hs(e.path,{method:`POST`,headers:a,body:JSON.stringify(t),signal:i.signal}),s=String(o.headers.get(`X-Request-ID`)||``).trim();if(s&&this.followUpRequestID&&(this.followUpRequestID=s),!o.ok){let e=`Unable to send message.`;try{let t=await o.json();e=t&&t.error&&t.error.message||e}catch{}this.followUpError=e,(this.followUpRequestID===r||this.followUpRequestID===s)&&(this.followUpRequestID=``);return}if(this.followUpText=``,await eL(o),!MC.liveLogsStreaming&&this.conversationOpen){let e=++this.conversationRequestToken;await this._selectPersistedFollowUp(n,this.followUpRequestID,e,i.signal)}}catch(e){ys(e)||i.signal.aborted?a&&this.conversationOpen&&(this.followUpError=`The request timed out.`):(console.error(`Failed to send interaction follow-up:`,e),this.followUpError=`Failed to send message.`)}finally{clearTimeout(o),this.followUpAbort===i&&(this.followUpAbort=null,this.followUpSending=!1)}}async _selectPersistedFollowUp(e,t,n,r){let i=Date.now()+ZI;for(;this.conversationOpen&&n===this.conversationRequestToken&&Date.now(){let e=this.conversationThreadEl;if(!e)return;let t=e.querySelectorAll(`[data-conversation-anchor="true"]`),n=t[t.length-1];n&&typeof n.scrollIntoView==`function`&&n.scrollIntoView({block:`center`})})}_scheduleLatestScroll(){requestAnimationFrame(()=>{let e=this.conversationThreadEl;if(!e)return;let t=e.lastElementChild;t&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`end`})})}};async function eL(e){let t=e&&e.body&&typeof e.body.getReader==`function`?e.body.getReader():null;if(!t){await e.text();return}for(;!(await t.read()).done;);}function tL(){return globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`?globalThis.crypto.randomUUID():`dashboard-`+Date.now().toString(36)+`-`+Math.random().toString(36).slice(2)}function nL(e,t){return new Promise((n,r)=>{let i,a=()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))};if(i=setTimeout(()=>{t&&t.removeEventListener(`abort`,a),n()},e),t){if(t.aborted){a();return}t.addEventListener(`abort`,a,{once:!0})}})}var rL=new $I,iL=0;Mn(()=>{An(()=>{let e=DC(MC.auditRecordChanges,iL);e.length!==0&&(iL=Number(e[e.length-1].version||0),Er(()=>{e.forEach(e=>{if(!OC(e))return;let t=MC.auditRecord(e.key);rL.handleAuditRecordChange(t,e.eventType)})}))})});var aL=R(``),oL=R(` `),sL=R(``),cL=R(`
                `);function lL(e,t){E(t,!0);let n=ya(t,`thread`,3,null),r=ya(t,`expanded`,3,!1),i=ya(t,`onactivate`,3,null),a=O(()=>ds.formatTimestamp(t.entry.timestamp)),o=O(()=>I(a)===`-`?I(a):I(a).slice(I(a).lastIndexOf(` `)+1)),s=O(()=>rL.conversationOpen&&String(rL.conversationAnchorID||``)===String(t.entry.id||``));function c(e){e.preventDefault(),i()&&i()()}function l(e){e.stopPropagation(),e.preventDefault(),n().ontoggle()}function u(e){if(e.stopPropagation(),e.preventDefault(),I(s)){rL.closeConversation();return}rL.openConversation(t.entry,e.currentTarget)}var d=cL();let f;var p=M(d),m=M(p),h=e=>{var t=aL(),r=M(t);{let e=O(()=>n().expanded?Ha:Wa);G(r,{get icon(){return I(e)},class:`audit-thread-expander-svg`})}var i=P(r,2),a=M(i,!0);T(i),T(t),F(()=>{W(t,`aria-expanded`,n().expanded),W(t,`title`,`Session with `+n().count+` requests`),W(t,`aria-label`,`Session with `+n().count+` requests, `+(n().expanded?`collapse`:`expand`)),B(a,n().count)}),L(`click`,t,l),z(e,t)};V(m,e=>{n()&&e(h)});var g=P(m,2),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=M(y,!0);T(y),T(g);var x=P(g,2),S=e=>{var n=oL(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>bc(t.entry)]),z(e,n)};V(x,e=>{(t.entry.requested_model||t.entry.model)&&e(S)});var C=P(x,2),w=M(C,!0);T(C),T(p);var ee=P(p,2),te=M(ee);RF(te,{get entry(){return t.entry}});var ne=P(te,2),re=M(ne),ie=M(re,!0);T(re);var ae=P(re,2),oe=M(ae,!0);T(ae),T(ne);var se=P(ne,2),ce=M(se,!0);T(se);var le=P(se,2),ue=e=>{var t=sL();let n;var r=M(t);{let e=O(()=>I(s)?Ua:Wa);G(r,{get icon(){return I(e)},class:`audit-conversation-trigger-svg`})}T(t),F(()=>{n=U(t,1,`audit-conversation-trigger svelte-17mysgz`,null,n,{"audit-conversation-trigger-active":I(s)}),W(t,`title`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-label`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-pressed`,I(s))}),L(`click`,t,u),z(e,t)},de=O(()=>rL.canShowConversation(t.entry));V(le,e=>{I(de)&&e(ue)}),T(ee),T(d),F((e,n,i,s)=>{f=U(d,1,`audit-entry-summary svelte-17mysgz`,null,f,e),W(d,`aria-expanded`,r()),U(g,1,`audit-status-badge audit-request-badge ${n??``}`,`svelte-17mysgz`),W(g,`title`,`Status `+(t.entry.status_code||`-`)+` · `+(t.entry.method||`-`)),W(g,`aria-label`,(t.entry.status_code||`-`)+` `+(t.entry.method||`-`)),B(v,t.entry.status_code||`-`),B(b,t.entry.method||`-`),B(w,t.entry.path||`-`),W(ne,`title`,i),W(ne,`aria-label`,I(a)),B(ie,I(a)),B(oe,I(o)),B(ce,s)},[()=>({"audit-entry-summary-live-in-progress":UP(t.entry),"audit-entry-summary-has-interactions":rL.canShowConversation(t.entry)}),()=>HP(t.entry.status_code),()=>mc(t.entry.timestamp),()=>VP(t.entry.duration_ns)]),L(`click`,d,c),z(e,d),D()}Hr([`click`]);var uL=R(``);function dL(e,t){E(t,!0);let n=ya(t,`label`,3,`Copy`),r=ya(t,`copiedLabel`,3,`Copied`),i=ya(t,`errorLabel`,3,``),a=ya(t,`class`,3,`btn`),o=O(()=>t.state.error&&i()?i():t.state.copied?r():n());var s=uL();let c;var l=M(s),u=e=>{G(e,{get icon(){return Ka},width:`14`,height:`14`,"stroke-width":`2.5`})},d=e=>{G(e,{get icon(){return Ya},width:`14`,height:`14`})};V(l,e=>{t.state.copied?e(u):e(d,-1)});var f=P(l,2),p=M(f,!0);T(f),T(s),F(()=>{c=U(s,1,Fi([`copy-feedback-btn`,a()]),null,c,{"copy-feedback-btn-copied":t.state.copied}),B(p,I(o))}),L(`click`,s,e=>{e.preventDefault(),t.onclick?.(e)}),z(e,s),D()}Hr([`click`]);var fL=R(`
                Error Message
                 
                `),pL=R(`
                 
                `),mL=R(` `),hL=R(` streaming`),gL=R(`
                Body
                `),_L=R(`

                `),vL=R(`

                `),yL=R(`

                `),bL=R(`
                `);function xL(e,t){E(t,!0);let n=_M({logPrefix:`Failed to copy audit payload:`}),r=_M({logPrefix:`Failed to copy audit payload:`}),i=O(()=>t.pane&&t.pane.showHeaders?ac(t.pane.headers):``),a=O(()=>!t.pane||!t.pane.showBody?``:EI(t.pane.body)?jI(t.pane.body):rL.renderBodyWithConversationHighlights(t.pane.entry,t.pane.body,{promptCacheHighlight:t.pane.promptCacheHighlight})),o=O(()=>!!(t.pane&&rL.canShowConversation(t.pane.entry)));function s(e){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),rL.handleErrorConversationClick(e,t.pane.entry))}var c=bL();let l;var u=M(c),d=e=>{var n=fL(),r=P(M(n),2);let i;var a=M(r,!0);T(r),T(n),F(()=>{i=U(r,1,`audit-json audit-pane-error-message svelte-1h5puht`,null,i,{"audit-pane-clickable-preview":I(o)}),W(r,`role`,I(o)?`button`:null),W(r,`tabindex`,I(o)?0:null),B(a,t.pane.errorMessage)}),L(`mousedown`,r,e=>rL.startBodyInteraction(e)),L(`keydown`,r,s),L(`click`,r,e=>rL.handleErrorConversationClick(e,t.pane.entry)),z(e,n)};V(u,e=>{t.pane.showErrorMessage&&e(d)});var f=P(u,2),p=e=>{var n=pL(),a=M(n),o=M(a),s=M(o,!0);T(o),dL(P(o,2),{get state(){return r},label:`Copy Headers`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>r.copy(t.pane.copyHeaders,ac)}),T(a);var c=P(a,2),l=M(c,!0);T(c),T(n),F(()=>{B(s,t.pane.headersTitle||`Headers`),B(l,I(i))}),z(e,n)};V(f,e=>{t.pane.showHeaders&&e(p)});var m=P(f,2),h=e=>{var r=gL(),i=M(r),o=M(i),s=P(M(o),2),c=e=>{var n=mL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.bodyCacheRatioLabel)),z(e,n)};V(s,e=>{t.pane.bodyCacheRatioLabel&&e(c)});var l=P(s,2),u=e=>{z(e,hL())};V(l,e=>{t.pane.streaming&&e(u)}),T(o),dL(P(o,2),{get state(){return n},label:`Copy Body`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>n.copy(t.pane.copyBody,ac)}),T(i);var d=P(i,2);hi(d,()=>I(a),!0),T(d),T(r),L(`mousedown`,d,e=>rL.startBodyInteraction(e)),L(`click`,d,e=>rL.handleBodyConversationClick(e,t.pane.entry)),z(e,r)};V(m,e=>{t.pane.showBody&&e(h)});var g=P(m,2),_=e=>{var n=_L(),r=M(n,!0);T(n),F(()=>B(r,t.pane.emptyMessage)),z(e,n)};V(g,e=>{t.pane.showEmpty&&e(_)});var v=P(g,2),y=e=>{var n=vL(),r=P(M(n),2),i=M(r,!0);T(r),T(n),F(()=>B(i,t.pane.pendingMessage)),z(e,n)};V(v,e=>{t.pane.showPending&&e(y)});var b=P(v,2),x=e=>{var n=yL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.tooLargeMessage)),z(e,n)};V(b,e=>{t.pane.showTooLarge&&e(x)}),T(c),F(()=>l=U(c,1,`audit-pane svelte-1h5puht`,null,l,{"audit-pane-split":t.pane&&t.pane.layout===`split`,"audit-pane-split-single":t.pane&&t.pane.layout===`split`&&!(t.pane.showHeaders&&t.pane.showBody)})),z(e,c),D()}Hr([`mousedown`,`keydown`,`click`]);var SL=R(` `),CL=R(` `),wL=R(` `),TL=R(` `),EL=R(``),DL=R(`
                `),OL=R(`
                `);function kL(e,t){E(t,!0);let n=ya(t,`panes`,19,()=>[]),r=k(null),i=O(()=>xF(I(r),t.entry,n())),a=e=>`audit-tab-`+t.entry.id+`-`+e,o=e=>`audit-tabpanel-`+t.entry.id+`-`+e;function s(e,t){let i=n().map(e=>e.id),a=SF(e.key,i,t);a!=null&&(e.preventDefault(),((e.currentTarget?.closest?.(`.audit-pane-tablist`))?.querySelectorAll(`.audit-pane-tab`)[i.indexOf(a)])?.focus?.(),A(r,a,!0))}var c=OL(),l=M(c);H(l,21,n,e=>e.id,(e,t)=>{var n=EL();let c;var l=M(n),u=M(l),d=e=>{G(e,{get icon(){return Pa}})},f=e=>{G(e,{get icon(){return Na}})};V(u,e=>{I(t).pane.direction===`request`?e(d):I(t).pane.direction===`response`&&e(f,1)}),T(l);var p=P(l,2),m=M(p,!0);T(p);var h=P(p,2),g=e=>{var n=SL(),r=M(n);T(n),F(()=>B(r,`#${I(t).pane.seq??``}`)),z(e,n)};V(h,e=>{I(t).pane.seq&&e(g)});var _=P(h,2),v=e=>{var n=CL(),r=M(n,!0);T(n),F(()=>{U(n,1,`provider-badge audit-pane-kind audit-pane-kind-${I(t).pane.kind??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.kind)}),z(e,n)};V(_,e=>{I(t).pane.kind&&e(v)});var y=P(_,2);H(y,17,()=>I(t).pane.noChangeSteps||[],e=>e.id,(e,t)=>{var n=wL(),r=M(n,!0);T(n),F(()=>{W(n,`title`,I(t).title),B(r,I(t).label)}),z(e,n)});var b=P(y,2),x=e=>{var n=TL(),r=M(n,!0);T(n),F(()=>B(r,I(t).pane.savingsLabel)),z(e,n)};V(b,e=>{I(t).pane.savingsLabel&&e(x)});var S=P(b,2),C=e=>{var n=CL(),r=M(n,!0);T(n),F(e=>{U(n,1,`audit-status-badge ${e??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.statusCode)},[()=>HP(I(t).pane.statusCode)]),z(e,n)};V(S,e=>{I(t).pane.statusCode&&e(C)}),T(n),F((e,r)=>{c=U(n,1,`audit-pane-tab svelte-1bc5vi5`,null,c,{"audit-pane-tab-active":I(i)===I(t).id}),W(n,`aria-selected`,I(i)===I(t).id),W(n,`id`,e),W(n,`aria-controls`,r),W(n,`tabindex`,I(i)===I(t).id?0:-1),U(l,1,Fi([`audit-pane-icon`,I(t).pane.direction&&`audit-pane-icon-${I(t).pane.direction}`]),`svelte-1bc5vi5`),B(m,I(t).pane.title)},[()=>a(I(t).id),()=>o(I(t).id)]),L(`keydown`,n,e=>s(e,I(t).id)),L(`click`,n,()=>A(r,I(t).id,!0)),z(e,n)}),T(l),H(P(l,2),17,n,e=>e.id,(e,t)=>{var n=DL();let r;xL(M(n),{get pane(){return I(t).pane}}),T(n),F((e,a)=>{W(n,`id`,e),W(n,`aria-labelledby`,a),r=Hi(n,``,r,{display:I(i)===I(t).id?null:`none`})},[()=>o(I(t).id),()=>a(I(t).id)]),z(e,n)}),T(c),z(e,c),D()}Hr([`keydown`,`click`]);var AL=R(`
                `),jL=R(`
                `);function ML(e,t){E(t,!0);let n=ya(t,`thread`,3,null),r=O(()=>TF.isAuditEntryExpanded(t.entry)),i=O(()=>rL.conversationOpen&&String(rL.conversationAnchorID||``)===String(t.entry.id||``)),a=O(()=>I(r)?yF(t.entry,ZF):[]),o=O(()=>I(r)?mN(t.entry,lP.auditEntryWorkflow(t.entry),lP.workflowFeatureCaps()):null);function s(){TF.toggleAuditEntryExpanded(t.entry)}var c=jL();let l;var u=M(c);lL(u,{get entry(){return t.entry},get thread(){return n()},get expanded(){return I(r)},onactivate:s});var d=P(u,2),f=e=>{var n=AL(),r=M(n),i=e=>{AM(e,{get chart(){return I(o)}})};V(r,e=>{I(o)&&e(i)});var s=P(r,2);kL(s,{get entry(){return t.entry},get panes(){return I(a)}}),FF(P(s,2),{get entry(){return t.entry}}),T(n),ki(3,n,()=>qs,()=>({y:-6,duration:sP(150)})),z(e,n)};V(d,e=>{I(r)&&e(f)}),T(c),F(()=>l=U(c,1,`audit-entry svelte-cmjgwr`,null,l,{"audit-entry-interactions-open":I(i)})),z(e,c),D()}var NL=R(`
                `),PL=R(`
                `),FL=R(`

                `),IL=R(`
                `),LL=R(`
                `);function RL(e,t){E(t,!0);let n=O(()=>TP(t.entry)),r=O(()=>TF.isThreadExpanded(I(n))),i=O(()=>TF.threadChildren(I(n))),a=O(()=>I(i)&&!I(i).loading&&Number(I(i).total||0)>I(i).entries.length+1);var o=Qr(),s=N(o),c=e=>{ML(e,{get entry(){return t.entry}})},l=O(()=>!DP(t.entry)),u=e=>{var n=LL(),o=M(n);{let e=O(()=>({count:EP(t.entry),expanded:I(r),ontoggle:()=>TF.toggleThread(t.entry)}));ML(o,{get entry(){return t.entry},get thread(){return I(e)}})}var s=P(o,2),c=e=>{var t=IL(),n=M(t),r=e=>{var t=NL();SS(M(t),{size:14,label:`Loading session requests`}),T(t),z(e,t)};V(n,e=>{I(i)&&I(i).loading&&e(r)});var o=P(n,2);H(o,17,()=>I(i)&&I(i).entries||[],e=>e.id,(e,t)=>{var n=PL();ML(M(n),{get entry(){return I(t)}}),T(n),z(e,n)});var s=P(o,2),c=e=>{var t=FL(),n=M(t);T(t),F(()=>B(n,`Showing the latest ${I(i).entries.length+1} of ${I(i).total??``} + requests in this session.`)),z(e,t)};V(s,e=>{I(a)&&e(c)}),T(t),ki(3,t,()=>Js,()=>({duration:sP(150)})),z(e,t)};V(s,e=>{I(r)&&e(c)}),T(n),z(e,n)};V(s,e=>{I(l)?e(c):e(u,-1)}),z(e,o),D()}var zL=R(`

                .

                `),BL=R(`
                Audit logging is off. Live entries are temporary and disappear after + refresh. Set LOGGING_ENABLED=true to persist them.
                `),VL=R(`

                `),HL=R(`
                `),UL=R(`
                `),WL=R(`
                `),GL=R(`
                `),KL=R(`
                `);function qL(e,t){E(t,!0);let n=O(()=>Ss.config&&Ss.config.LOGGING_RETENTION_DAYS);An(()=>{if(K.refreshTick,Jo.page===`audit-logs`)return Er(()=>r())});function r(){let e=!1;return(async()=>{try{await Ss.ensureLoaded()}finally{await TF.fetchAuditLog(!0),!e&&Ss.liveLogsVisible()&&MC.ensureLiveLogs()}})(),()=>{e=!0,MC.stopLiveLogs()}}var i=KL(),a=M(i),o=M(a),s=P(M(o),2),c=e=>{qS(e,{copyId:`audit-retention-help-copy`,label:`retention help`,text:`If you want to change the retention period, set LOGGING_RETENTION_DAYS (env var) or logging.retention_days (config.yaml) and restart the gateway. Default is 30 days; 0 keeps audit logs forever.`,title:e=>{var t=zL(),r=M(t,!0),i=P(r),a=M(i,!0);T(i),Ue(),T(t),F((e,t)=>{B(r,e),B(a,t)},[()=>xP(I(n)),()=>SP(I(n))]),z(e,t)},$$slots:{title:!0}})},l=O(()=>bP(I(n)));V(s,e=>{I(l)&&e(c)}),T(o),T(a);var u=P(a,2);tl(M(u),{onchange:()=>TF.fetchAuditLog(!0)}),T(u);var d=P(u,2);Fc(d,{});var f=P(d,2),p=e=>{z(e,BL())},m=O(()=>Ss.loaded&&!Ss.auditVisible()&&!K.needsAuth);V(f,e=>{I(m)&&e(p)});var h=P(f,2),g=M(h);DF(g,{});var _=P(g,2),v=M(_),y=M(v),b=e=>{var t=VL(),n=M(t);T(t),F(e=>B(n,`Showing ${TF.auditLog.offset+1}-${e??``} of ${TF.auditLog.total??``} + ${TF.auditGroupSessions?`sessions`:`logs`}`),[()=>Math.min(TF.auditLog.offset+TF.auditLog.limit,TF.auditLog.total)]),z(e,t)};V(y,e=>{TF.auditLog.total>0&&e(b)});var x=P(y,2),S=M(x);na(S),Ue(2),T(x),T(v),MF(P(v,2),{}),T(_);var C=P(_,2),w=e=>{var t=HL();SS(M(t),{size:18,label:`Loading audit logs`}),T(t),z(e,t)},ee=e=>{var t=WL();H(t,29,()=>TF.auditLog.entries,e=>e.id,(e,t)=>{var n=UL(),r=M(n),i=e=>{RL(e,{get entry(){return I(t)}})},a=e=>{ML(e,{get entry(){return I(t)}})};V(r,e=>{TF.auditGroupSessions?e(i):e(a,-1)}),T(n),Oi(n,()=>rP,()=>({duration:sP(150)})),ki(1,n,()=>cP,()=>({live:I(t)._live})),z(e,n)}),T(t),z(e,t)};V(C,e=>{TF.loading&&TF.auditLog.entries.length===0?e(w):TF.auditLog.entries.length>0&&e(ee,1)});var te=P(C,2),ne=e=>{var t=GL();TS(M(t),{}),T(t),z(e,t)};V(te,e=>{TF.auditLog.entries.length===0&&!TF.loading&&!K.needsAuth&&e(ne)}),Jw(P(te,2),{get total(){return TF.auditLog.total},get offset(){return TF.auditLog.offset},get limit(){return TF.auditLog.limit},onprev:()=>TF.auditLogPrevPage(),onnext:()=>TF.auditLogNextPage()}),T(h),T(i),F(()=>ia(S,TF.auditGroupSessions)),L(`change`,S,()=>TF.toggleAuditGroupSessions()),z(e,i),D()}Hr([`change`]);function JL(e){try{let t=JSON.parse(JSON.stringify(e||{}));return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function YL(e){return Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(e=>e):e==null?[]:String(e).split(`,`).map(e=>e.trim()).filter(e=>e)}function XL(e,t){let n=String(t||``).trim();return(e||[]).find(e=>String(e&&e.type||``).trim()===n)||null}function ZL(e){return Array.isArray(e)&&e.length>0&&String(e[0].type||``).trim()||`system_prompt`}function QL(e,t){let n=String(t||``).trim();return n&&XL(e,n)?n:ZL(e)}function $L(e,t){let n=XL(e,t);return!n||!n.defaults?{}:JL(n.defaults)}function eR(e,t,n){return{...$L(e,n),...JL(t)}}function tR(e,t){let n=QL(e,t);return{name:``,type:n,description:``,user_path:``,config:$L(e,n)}}function nR(e,t){if(!t)return e||[];let n=String(t).toLowerCase();return(e||[]).filter(e=>[e.name,e.type,e.user_path,e.description,e.summary].some(e=>String(e||``).toLowerCase().includes(n)))}function rR(e,t){let n=XL(e,t);return n&&n.label?n.label:t||`Unknown`}function iR(e,t){let n=XL(e,t);return Array.isArray(n&&n.fields)?n.fields:[]}function aR(e,t){if(!t||!e)return t&&t.input===`checkboxes`?[]:``;let n=e[t.key];return n==null?t.input===`checkboxes`?[]:``:t.input===`checkboxes`?YL(n):n}function oR(e,t,n){if(!t)return e;let r=JL(e);if(t.input===`number`){let e=String(n||``).trim();if(e===``)delete r[t.key];else{let n=Number(e);r[t.key]=Number.isFinite(n)?n:e}}else t.input===`checkboxes`?r[t.key]=YL(n):r[t.key]=n;return r}function sR(e,t,n){return aR(e,t).includes(String(n||``).trim())}function cR(e,t,n,r){let i=YL(aR(e,t)),a=String(n||``).trim();return a?oR(e,t,r?Array.from(new Set([...i,a])):i.filter(e=>e!==a)):e}function lR(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),description:String(e&&e.description||``).trim()||void 0,user_path:String(e&&e.user_path||``).trim()||void 0,config:JL(e&&e.config)}}var uR=new class{#e=k(j([]));get guardrails(){return I(this.#e)}set guardrails(e){A(this.#e,e,!0)}#t=k(j([]));get types(){return I(this.#t)}set types(e){A(this.#t,e,!0)}#n=k(!0);get available(){return I(this.#n)}set available(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=k(!1);get typesLoading(){return I(this.#i)}set typesLoading(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(``);get filter(){return I(this.#o)}set filter(e){A(this.#o,e,!0)}#s=k(!1);get formOpen(){return I(this.#s)}set formOpen(e){A(this.#s,e,!0)}#c=k(!1);get formSubmitting(){return I(this.#c)}set formSubmitting(e){A(this.#c,e,!0)}#l=k(``);get deletingName(){return I(this.#l)}set deletingName(e){A(this.#l,e,!0)}#u=k(`create`);get formMode(){return I(this.#u)}set formMode(e){A(this.#u,e,!0)}#d=k(``);get formOriginalName(){return I(this.#d)}set formOriginalName(e){A(this.#d,e,!0)}#f=k(j({name:``,type:``,description:``,user_path:``,config:{}}));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}get filtered(){return nR(this.guardrails,this.filter)}typeLabel(e){return rR(this.types,e)}typeFields(e){return iR(this.types,e)}fieldValue(e){return aR(this.form&&this.form.config,e)}setFieldValue(e,t){this.form={...this.form,config:oR(this.form.config,e,t)}}arrayFieldSelected(e,t){return sR(this.form&&this.form.config,e,t)}toggleArrayFieldValue(e,t,n){this.form={...this.form,config:cR(this.form.config,e,t,n)}}openCreate(){this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=tR(this.types,ZL(this.types)),this.formOpen=!0}openEdit(e){let t=QL(this.types,e&&e.type);this.formMode=`edit`,this.formOriginalName=String(e&&e.name||``).trim(),this.error=``,this.form={name:this.formOriginalName,type:t,description:String(e&&e.description||``).trim(),user_path:String(e&&e.user_path||``).trim(),config:eR(this.types,e&&e.config,t)},this.formOpen=!0}closeForm(){this.formOpen=!1,this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=tR(this.types,ZL(this.types))}changeType(e){let t=QL(this.types,e);this.form={...this.form,type:t,config:$L(this.types,t)}}async fetchTypes(){this.typesLoading=!0;try{let e=await _T(`/admin/guardrails/types`,{label:`guardrail types`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.types=[];return}if(e.result&&(this.available=!0),this.types=e.items,e.status===`error`){this.error=e.error;return}let t=QL(this.types,this.form.type);this.form={...this.form,type:t,config:eR(this.types,this.form.config,t)}}finally{this.typesLoading=!1}}async fetchGuardrails(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/guardrails`,{label:`guardrails`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.guardrails=[];return}e.result&&(this.available=!0),this.guardrails=e.items,this.error=e.error}finally{this.loading=!1}}async fetchPage(){await Promise.all([this.fetchTypes(),this.fetchGuardrails()])}async submitForm(){let e=String(this.form.name||``).trim(),t=String(this.form.type||``).trim();if(!e){this.error=`Name is required.`;return}if(!t){this.error=`Type is required.`;return}this.error=``,this.formSubmitting=!0;let n=lR(this.form);try{let t=await vT(`/admin/guardrails`,`PUT`,n,{label:`save guardrail`,errorFallback:`Failed to save guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}q.success(`Guardrail "`+e+`" saved.`),this.closeForm(),this.fetchGuardrails()}finally{this.formSubmitting=!1}}async deleteGuardrail(e){let t=String(e&&e.name||``).trim();if(!(!t||this.deletingName)&&window.confirm(`Delete guardrail "`+t+`"? Workflows that still reference it must be updated first.`)){this.deletingName=t;try{let e=await vT(`/admin/guardrails`,`DELETE`,{name:t},{label:`delete guardrail`,errorFallback:`Failed to delete guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}q.success(`Guardrail "`+t+`" deleted.`),this.formOpen&&this.formOriginalName===t&&this.closeForm(),this.fetchGuardrails()}finally{this.deletingName=``}}}},dR=R(`
                `),fR=R(`

                Loading guardrails...

                `),pR=R(`
                `),mR=R(`
                `),hR=R(`
                NameTypeUser PathSummaryActions
                `),gR=R(`

                No guardrails defined yet.

                `),_R=R(`

                Instances

                Each instance has a reusable name, a type, an optional user path for + future UI visibility scoping, and a JSON-backed config payload for + that type.

                `);function vR(e,t){E(t,!0);var n=_R(),r=M(n),i=P(M(r),2);G(M(i),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(i),T(r);var a=P(r,2),o=e=>{var t=dR(),n=M(t);yw(M(n),{id:`guardrail-filter`,placeholder:`Filter by name, type, user path, summary...`,label:`Guardrail filter`,get value(){return uR.filter},set value(e){uR.filter=e}}),T(n),T(t),z(e,t)};V(a,e=>{uR.available&&e(o)});var s=P(a,2),c=e=>{var t=fR();SS(M(t),{size:16,label:`Loading guardrails`}),Ue(),T(t),z(e,t)};V(s,e=>{uR.loading&&uR.filtered.length===0&&e(c)});var l=P(s,2),u=e=>{var t=hR(),n=M(t),r=P(M(n));H(r,21,()=>uR.filtered,e=>e.name,(e,t)=>{var n=mR(),r=M(n),i=M(r,!0);T(r);var a=P(r),o=M(a),s=M(o,!0);T(o),T(a);var c=P(a),l=M(c,!0);T(c);var u=P(c),d=M(u),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var n=pR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(p,e=>{I(t).description&&e(m)}),T(u);var h=P(u),g=M(h),_=M(g);{let e=O(()=>`Edit guardrail `+I(t).name);gT(_,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>uR.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var v=P(_,2);{let e=O(()=>(uR.deletingName===I(t).name?`Deleting guardrail `:`Delete guardrail `)+I(t).name),n=O(()=>uR.deletingName===I(t).name);gT(v,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>uR.deleteGuardrail(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}T(g),T(h),T(n),F(e=>{B(i,I(t).name),B(s,e),B(l,I(t).user_path||`—`),B(f,I(t).summary||I(t).description||`No summary yet.`)},[()=>uR.typeLabel(I(t).type)]),z(e,n)}),T(r),T(n),T(t),z(e,t)};V(l,e=>{uR.filtered.length>0&&e(u)});var d=P(l,2),f=e=>{z(e,gR())};V(d,e=>{uR.filtered.length===0&&!uR.loading&&uR.available&&!uR.error&&!K.authError&&e(f)}),T(n),F(()=>i.disabled=uR.typesLoading||uR.formSubmitting||!uR.available),L(`click`,i,()=>uR.openCreate()),z(e,n),D()}Hr([`click`]);var yR=R(`

                Workflows reference these names directly, so renames are + intentionally avoided after creation.

                `),bR=R(``),xR=R(``),SR=R(``),CR=R(``),wR=R(``),TR=R(``),ER=R(``),DR=R(``),OR=R(``),kR=R(`
                `),AR=R(``),jR=R(` `),MR=R(`
                `),NR=R(`
                `);function PR(e,t){E(t,!0);let n=O(()=>uR.formMode===`edit`);{let t=e=>{z(e,yR())},r=O(()=>I(n)?`Edit Guardrail`:`Create Guardrail`);bE(e,{get open(){return uR.formOpen},get title(){return I(r)},ariaLabel:`Guardrail editor`,get error(){return uR.error},get submitting(){return uR.formSubmitting},submitLabel:`Save Guardrail`,dialogClass:`settings-guardrails-editor guardrails-editor-wide`,onclose:()=>uR.closeForm(),onsubmit:()=>uR.submitForm(),headerHint:t,children:(e,t)=>{var r=NR(),i=M(r);SE(i,{id:`guardrail-name`,label:`Name`,children:(e,t)=>{var r=bR();na(r),F(()=>{r.disabled=I(n),W(r,`data-modal-autofocus`,!I(n)||void 0)}),da(r,()=>uR.form.name,e=>uR.form.name=e),z(e,r)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`guardrail-type`,label:`Type`,children:(e,t)=>{var r=SR();H(r,21,()=>uR.types,e=>e.type,(e,t)=>{var n=xR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).type)&&(n.value=(n.__value=I(t).type)??``)}),z(e,n)}),T(r);var i;Wi(r),F(()=>{r.disabled=I(n),i!==(i=uR.form.type)&&(r.value=(r.__value=uR.form.type)??``,Ui(r,uR.form.type))}),L(`change`,r,e=>uR.changeType(e.currentTarget.value)),z(e,r)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`guardrail-description`,label:`Description`,children:(e,t)=>{var r=CR();na(r),F(()=>W(r,`data-modal-autofocus`,I(n)?!0:void 0)),da(r,()=>uR.form.description,e=>uR.form.description=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2),c=M(s);qS(c,{copyId:`guardrail-user-path-help-copy`,label:`guardrail user path help`,text:`Only used for auxiliary rewrite (llm_based_altering) guardrails; ignored for other guardrail types.`,title:e=>{z(e,wR())},$$slots:{title:!0}});var l=P(c,2);na(l),T(s),H(P(s,2),17,()=>uR.typeFields(uR.form.type),e=>e.key,(e,t)=>{var n=Qr(),r=N(n),i=e=>{var n=kR(),r=M(n);{let e=e=>{var n=TR(),r=M(n,!0);T(n),F(()=>{W(n,`for`,`guardrail-field-`+I(t).key),B(r,I(t).label)}),z(e,n)},n=O(()=>`guardrail-field-help-`+I(t).key),i=O(()=>I(t).label+` help`),a=O(()=>I(t).help||``);qS(r,{get copyId(){return I(n)},get label(){return I(i)},get text(){return I(a)},title:e,$$slots:{title:!0}})}var i=P(r,2),a=e=>{var n=ER();H(n,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=xR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n);var r;Wi(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),r!==(r=e)&&(n.value=(n.__value=e)??``,Ui(n,e))},[()=>uR.fieldValue(I(t))]),L(`change`,n,e=>uR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},o=e=>{var n=DR();ft(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>uR.fieldValue(I(t))]),L(`input`,n,e=>uR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},s=e=>{var n=OR();na(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`type`,I(t).input||`text`),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>uR.fieldValue(I(t))]),L(`input`,n,e=>uR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)};V(i,e=>{I(t).input===`select`?e(a):I(t).input===`textarea`?e(o,1):e(s,-1)}),T(n),z(e,n)},a=e=>{var n=MR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).options||[],e=>I(t).key+`-`+e.value,(e,n)=>{var r=AR(),i=M(r);na(i);var a=P(i,2),o=M(a,!0);T(a),T(r),F(e=>{ia(i,e),B(o,I(n).label)},[()=>uR.arrayFieldSelected(I(t),I(n).value)]),L(`change`,i,e=>uR.toggleArrayFieldValue(I(t),I(n).value,e.currentTarget.checked)),z(e,r)}),T(a);var o=P(a,2),s=e=>{var n=jR(),r=M(n,!0);T(n),F(()=>{W(n,`id`,`guardrail-field-help-`+I(t).key),B(r,I(t).help)}),z(e,n)};V(o,e=>{I(t).help&&e(s)}),T(n),F(()=>{W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),B(i,I(t).label)}),z(e,n)};V(r,e=>{I(t).input===`checkboxes`?e(a,-1):e(i)}),z(e,n)}),T(r),da(l,()=>uR.form.user_path,e=>uR.form.user_path=e),z(e,r)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var FR=R(`

                Guardrails

                `),IR=R(`
                Runtime guardrail execution is currently off because GUARDRAILS_ENABLED is disabled. You can still manage + definitions here.
                `),LR=R(`
                Guardrails feature is unavailable.
                `),RR=R(`
                `),zR=R(`

                Reusable Policy Objects

                Guardrail Library

                Store guardrails in the database, keep them hot in memory, and attach + them to workflows by reference.

                Instances
                Types
                `);function BR(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`guardrails`&&(Ss.ensureLoaded(),uR.fetchPage())});var n=zR(),r=M(n),i=M(r);qS(M(i),{copyId:`guardrails-help-copy`,label:`guardrails help`,text:`Reusable policy objects stored in the database and kept hot in memory for workflow execution.`,title:e=>{z(e,FR())},$$slots:{title:!0}}),T(i),T(r);var a=P(r,2),o=P(M(a),2),s=M(o),c=P(M(s),2),l=M(c,!0);T(c),T(s);var u=P(s,2),d=P(M(u),2),f=M(d,!0);T(d),T(u),T(o),T(a);var p=P(a,2);Fc(p,{});var m=P(p,2),h=e=>{z(e,IR())},g=O(()=>!Ss.guardrailsVisible());V(m,e=>{I(g)&&e(h)});var _=P(m,2),v=e=>{z(e,LR())};V(_,e=>{!K.authError&&!uR.available&&e(v)});var y=P(_,2),b=e=>{var t=RR(),n=M(t,!0);T(t),F(()=>B(n,uR.error)),z(e,t)};V(y,e=>{!K.authError&&uR.error&&!uR.formOpen&&e(b)});var x=P(y,2);PR(x,{}),vR(P(x,2),{}),T(n),F((e,t)=>{B(l,e),B(f,t)},[()=>oc(uR.guardrails.length),()=>oc(uR.types.length)]),z(e,n),D()}var Q=new class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get slugEdited(){return I(this.#c)}set slugEdited(e){A(this.#c,e,!0)}#l=k(!1);get advancedOpen(){return I(this.#l)}set advancedOpen(e){A(this.#l,e,!0)}#u=k(j(dx()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(``);get deletingName(){return I(this.#d)}set deletingName(e){A(this.#d,e,!0)}#f=k(``);get reconnectingName(){return I(this.#f)}set reconnectingName(e){A(this.#f,e,!0)}#p=k(!1);get catalogOpen(){return I(this.#p)}set catalogOpen(e){A(this.#p,e,!0)}#m=k(!1);get catalogLoading(){return I(this.#m)}set catalogLoading(e){A(this.#m,e,!0)}#h=k(``);get catalogError(){return I(this.#h)}set catalogError(e){A(this.#h,e,!0)}#g=k(j(fx()));get catalog(){return I(this.#g)}set catalog(e){A(this.#g,e,!0)}#_=O(()=>Cx(this.servers,this.filter));get filtered(){return I(this.#_)}set filtered(e){A(this.#_,e)}async fetchServers(){if(await Ss.ensureLoaded(),!Ss.mcpVisible()){this.available=!1,this.servers=[],this.error=``,this.loading=!1;return}this.loading=!0,this.error=``;try{let e=await _T(`/admin/mcp-servers`,{label:`mcp servers`,errorFallback:`Failed to load MCP servers.`,unavailableStatuses:[503,404]});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.servers=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.servers=[],this.error=e.error;return}this.available=!0,this.servers=e.items}finally{this.loading=!1}}openCreate(){this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=dx(),this.formOpen=!0}openEdit(e){!e||e.managed||(this.formMode=`edit`,this.slugEdited=!0,this.advancedOpen=!1,this.error=``,this.form=wx(e),this.formOpen=!0)}closeForm(){this.formOpen=!1,this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=dx()}syncSlugFromName(){this.formMode===`create`&&!this.slugEdited&&(this.form.slug=yx(this.form.name))}markSlugEdited(){this.formMode===`create`&&(this.slugEdited=!0)}addHeader(){this.form.headers.push({name:``,value:``})}removeHeader(e){this.form.headers.splice(e,1)}async submitForm(){let e=Tx(this.form,this.formMode,this.servers);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/mcp-servers`,`PUT`,e.payload,{label:`save mcp server`,errorFallback:`Failed to save MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}q.success(`MCP server "`+e.payload.name+`" saved.`),this.closeForm(),this.fetchServers()}finally{this.formSubmitting=!1}}async deleteServer(e){let t=String(e&&e.name||``).trim(),n=px(e);if(!(!n||this.deletingName||e&&e.managed)&&confirm(`Delete MCP server "`+t+`"? Clients lose access to its tools immediately.`)){this.deletingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n),`DELETE`,void 0,{label:`delete mcp server`,errorFallback:`Failed to delete MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}q.success(`MCP server "`+t+`" deleted.`),this.formOpen&&this.form.slug===n&&this.closeForm(),this.fetchServers()}finally{this.deletingName=``}}}async reconnectServer(e){let t=String(e&&e.name||``).trim(),n=px(e);if(!(!n||this.reconnectingName)){this.reconnectingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n)+`/reconnect`,`POST`,void 0,{label:`reconnect mcp server`,errorFallback:`Failed to reconnect MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}let r=e.result.data,i=mx(r);i===`connected`?q.success(`MCP server "`+t+`" reconnected.`):i===`disabled`?q.success(`MCP server "`+t+`" is disabled; no connection was attempted.`):q.error(`Reconnect attempted, but MCP server "`+t+`" is still `+i+`.`),r&&r.name?this.servers=(this.servers||[]).map(e=>px(e)===px(r)?r:e):this.fetchServers()}finally{this.reconnectingName=``}}}async openCatalog(e){let t=String(e&&e.name||``).trim(),n=px(e);if(n){this.catalogOpen=!0,this.catalogLoading=!0,this.catalogError=``,this.catalog={...fx(),server:n,status:mx(e)};try{let e=await _s(`/admin/mcp-servers/`+encodeURIComponent(n)+`/catalog`,{label:`mcp server catalog`});if(e.stale)return;if(e.status===503){this.available=!1,this.catalogError=`MCP server management is unavailable.`;return}if(e.status===404){this.catalogError=`MCP server "`+t+`" was not found.`;return}if(!e.ok){this.catalogError=e.status===401?`Authentication required.`:fs(e.data,`Failed to load MCP server catalog.`);return}this.catalog=Ex(n,e.data)}catch(e){console.error(`Failed to load MCP server catalog:`,e),this.catalogError=`Failed to load MCP server catalog.`}finally{this.catalogLoading=!1}}}closeCatalog(){this.catalogOpen=!1,this.catalogLoading=!1,this.catalogError=``,this.catalog=fx()}},VR=R(``),HR=R(`

                `),UR=R(`
                `),WR=R(`

                `),GR=R(`
              • `),KR=R(`

                  `),qR=R(`

                  No tools listed — the server may still be connecting or degraded.

                  `),JR=R(` `,1),YR=R(``);function XR(e,t){E(t,!0);let n=O(()=>Ox(Q.catalog));Ns(e,{get open(){return Q.catalogOpen},variant:`editor`,onclose:()=>Q.closeCatalog(),children:(e,t)=>{var r=YR(),i=M(r),a=M(i),o=P(M(a),2),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l),T(o),T(a),ks(P(a,2),{label:`Close MCP server catalog`,onclick:()=>Q.closeCatalog()}),T(i);var d=P(i,2),f=e=>{mT(e,{label:`Loading catalog...`})},p=e=>{var t=VR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalogError)),z(e,t)},m=e=>{var t=JR(),r=N(t),i=e=>{var t=HR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalog.instructions)),z(e,t)};V(r,e=>{Q.catalog.instructions&&e(i)});var a=P(r,2);H(a,17,()=>I(n),e=>e.key,(e,t)=>{var n=KR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).items,e=>e.key,(e,t)=>{var n=GR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=UR(),r=M(n,!0);T(n),F(()=>{W(n,`title`,`Exposed on the aggregated /mcp endpoint as `+I(t).aggregated),B(r,I(t).aggregated)}),z(e,n)};V(a,e=>{I(t).aggregated&&e(o)});var s=P(a,2),c=e=>{var n=WR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(s,e=>{I(t).description&&e(c)}),T(n),F(()=>{W(r,`title`,I(t).aggregated||I(t).name),B(i,I(t).name)}),z(e,n)}),T(a),T(n),F(()=>B(i,I(t).title)),z(e,n)});var o=P(a,2),s=e=>{z(e,qR())},c=O(()=>kx(Q.catalog));V(o,e=>{I(c)&&e(s)}),z(e,t)};V(d,e=>{Q.catalogLoading?e(f):Q.catalogError?e(p,1):e(m,-1)});var h=P(d,2),g=M(h);T(h),T(r),F((e,t)=>{B(c,Q.catalog.server),U(l,1,`audit-status-badge ${e??``}`,`svelte-1xqrzco`),B(u,t)},[()=>hx(Q.catalog),()=>mx(Q.catalog)]),L(`click`,g,()=>Q.closeCatalog()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var ZR=R(`

                  The display name can change. The slug is the stable client-facing identity.

                  `),QR=R(` Human-readable and Unicode-friendly. You can change it later.`,1),$R=R(`Derived from the name. You may edit it before saving.`),ez=R(`Immutable because it is used in URLs, scope headers, and aggregated tool names.`),tz=R(` `,1),nz=R(` stdio servers are config-only: declare them in config.yaml under mcp.servers.`,1),rz=R(``),iz=R(`
                  `),az=R(`
                  Headers
                  Sent only to the configured server origin. Saved values are shown as ***; leave *** unchanged to keep the stored value.
                  Advanced settings Description, access rules, and timeout
                  `,1);function oz(e,t){E(t,!0);{let t=e=>{z(e,ZR())},n=O(()=>Q.formMode===`edit`?`Edit MCP Server`:`Add MCP Server`);bE(e,{get open(){return Q.formOpen},get title(){return I(n)},ariaLabel:`MCP server editor`,get error(){return Q.error},get submitting(){return Q.formSubmitting},onclose:()=>Q.closeForm(),onsubmit:()=>Q.submitForm(),headerHint:t,children:(e,t)=>{var n=az(),r=N(n);SE(r,{id:`mcp-server-name`,label:`Name`,children:(e,t)=>{var n=QR(),r=N(n);na(r),Ue(2),L(`input`,r,()=>Q.syncSlugFromName()),da(r,()=>Q.form.name,e=>Q.form.name=e),z(e,n)},$$slots:{default:!0}});var i=P(r,2);SE(i,{id:`mcp-server-slug`,label:`Slug`,children:(e,t)=>{var n=tz(),r=N(n);na(r);var i=P(r,2),a=e=>{z(e,$R())},o=e=>{z(e,ez())};V(i,e=>{Q.formMode===`create`?e(a):e(o,-1)}),F(()=>r.disabled=Q.formMode===`edit`),L(`input`,r,()=>Q.markSlugEdited()),da(r,()=>Q.form.slug,e=>Q.form.slug=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`mcp-server-transport`,label:`Transport`,children:(e,t)=>{var n=nz(),r=N(n),i=M(r);i.value=i.__value=`http`;var a=P(i);a.value=a.__value=`sse`,T(r),Ue(2),Gi(r,()=>Q.form.transport,e=>Q.form.transport=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`mcp-server-url`,label:`URL`,children:(e,t)=>{var n=rz();na(n),da(n,()=>Q.form.url,e=>Q.form.url=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=P(M(s),2);H(c,21,()=>Q.form.headers,oi,(e,t,n)=>{var r=iz(),i=M(r);na(i);var a=P(i,2);na(a),gT(P(a,2),{label:`Remove header`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Q.removeHeader(n),children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),da(i,()=>I(t).name,e=>I(t).name=e),da(a,()=>I(t).value,e=>I(t).value=e),z(e,r)}),T(c);var l=P(c,2),u=M(l);G(M(u),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(u),T(l),Ue(2),T(s);var d=P(s,2),f=M(d);bA(M(f),{get enabled(){return Q.form.enabled},label:`MCP server`,onclick:()=>Q.form.enabled=!Q.form.enabled}),T(f),T(d);var p=P(d,2),m=P(M(p),2),h=M(m),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=P(M(y),2);na(b),T(y);var x=P(y,2),S=P(M(x),2);ft(S),W(S,`placeholder`,`/ +/team/alpha`),T(x);var C=P(x,2),w=P(M(C),2);na(w),T(C),T(m),T(p),F(()=>p.open=Q.advancedOpen),L(`click`,u,()=>Q.addHeader()),Vr(`toggle`,p,e=>Q.advancedOpen=e.currentTarget.open),da(g,()=>Q.form.description,e=>Q.form.description=e),da(v,()=>Q.form.allowed_tools,e=>Q.form.allowed_tools=e),da(b,()=>Q.form.disallowed_tools,e=>Q.form.disallowed_tools=e),da(S,()=>Q.form.user_paths,e=>Q.form.user_paths=e),da(w,()=>Q.form.tool_timeout_seconds,e=>Q.form.tool_timeout_seconds=e),z(e,n)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`input`,`click`]);var sz=R(`Config`),cz=R(`
                  `),lz=R(`
                  `),uz=R(`
                  NameTransportEndpointStatusToolsEnabledActions
                  `);function dz(e,t){E(t,!0);function n(e){return gx(e,e=>ds.formatTimestamp(e))}var r=uz(),i=M(r),a=P(M(i));H(a,21,()=>Q.filtered,e=>px(e),(e,t)=>{var r=lz(),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=e=>{z(e,sz())};V(s,e=>{I(t).managed&&e(c)});var l=P(s,2),u=M(l,!0);T(l),T(i);var d=P(i),f=M(d),p=M(f,!0);T(f),T(d);var m=P(d),h=M(m,!0);T(m);var g=P(m),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=e=>{var n=cz(),r=M(n,!0);T(n),F(()=>B(r,I(t).last_error)),z(e,n)},x=O(()=>mx(I(t))===`degraded`&&I(t).last_error);V(y,e=>{I(x)&&e(b)}),T(g);var S=P(g),C=M(S),w=M(C,!0);T(C);var ee=P(C,2),te=M(ee,!0);T(ee),T(S);var ne=P(S),re=M(ne),ie=M(re,!0);T(re),T(ne);var ae=P(ne),oe=M(ae),se=M(oe),ce=e=>{{let n=O(()=>`Edit MCP server `+I(t).name);gT(e,{get label(){return I(n)},class:`table-icon-btn`,onclick:()=>Q.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(se,e=>{I(t).managed||e(ce)});var le=P(se,2);{let e=O(()=>`Inspect catalog of MCP server `+I(t).name);gT(le,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.openCatalog(I(t)),children:(e,t)=>{G(e,{get icon(){return io},class:`form-action-icon`})},$$slots:{default:!0}})}var ue=P(le,2);{let e=O(()=>(Q.reconnectingName===px(I(t))?`Reconnecting MCP server `:`Reconnect MCP server `)+I(t).name),n=O(()=>Q.reconnectingName===px(I(t)));gT(ue,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.reconnectServer(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return ho},class:`form-action-icon`})},$$slots:{default:!0}})}var de=P(ue,2),fe=e=>{{let n=O(()=>(Q.deletingName===px(I(t))?`Deleting MCP server `:`Delete MCP server `)+I(t).name),r=O(()=>Q.deletingName===px(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>Q.deleteServer(I(t)),get disabled(){return I(r)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(de,e=>{I(t).managed||e(fe)}),T(oe),T(ae),T(r),F((e,n,r,i,a,s,c,l)=>{B(o,I(t).name),B(u,e),B(p,I(t).transport||`http`),W(m,`title`,n),B(h,r),U(_,1,`audit-status-badge ${i??``}`,`svelte-ah8nrt`),W(_,`title`,a),B(v,s),B(w,c),B(te,l),U(re,1,Fi([`auth-key-status-badge`,I(t).enabled?`auth-key-status-active`:`auth-key-status-inactive`])),B(ie,I(t).enabled?`Enabled`:`Disabled`)},[()=>px(I(t)),()=>_x(I(t)),()=>_x(I(t)),()=>hx(I(t)),()=>n(I(t)),()=>mx(I(t)),()=>oc(I(t).tool_count||0),()=>vx(I(t))]),z(e,r)}),T(a),T(i),T(r),z(e,r),D()}var fz=R(`

                  MCP Servers

                  `),pz=R(``),mz=R(`
                  MCP server management is unavailable.
                  `),hz=R(``),gz=R(`
                  `),_z=R(`

                  No MCP servers yet. Add one here, or declare servers in config.yaml under mcp.servers.

                  `),vz=R(`

                  No MCP servers match your filter.

                  `),yz=R(`
                  `);function bz(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`mcp-servers`&&Q.fetchServers()});var n=yz(),r=M(n),i=M(r);qS(M(i),{copyId:`mcp-servers-help-copy`,label:`MCP servers help`,text:`Upstream Model Context Protocol servers whose tools, prompts, and resources the gateway exposes to clients. Servers added here connect over HTTP or SSE; stdio servers and rows marked Config are declared in config.yaml under mcp.servers and are read-only in the dashboard. Saved header values are masked in API and dashboard responses.`,title:e=>{z(e,fz())},$$slots:{title:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=pz();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Q.formSubmitting),L(`click`,t,()=>Q.openCreate()),z(e,t)};V(o,e=>{Q.available&&!K.authError&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,mz())};V(c,e=>{!Q.available&&!K.authError&&e(l)});var u=P(c,2),d=e=>{var t=hz(),n=M(t,!0);T(t),F(()=>B(n,Q.error)),z(e,t)};V(u,e=>{Q.error&&!K.authError&&!Q.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading MCP servers...`})};V(f,e=>{Q.loading&&!K.authError&&e(p)});var m=P(f,2),h=e=>{var t=gz(),n=M(t);yw(M(n),{id:`mcp-server-filter`,placeholder:`Filter by name, slug, URL, transport, or status...`,label:`Filter MCP servers by name, slug, URL, transport, or status`,get value(){return Q.filter},set value(e){Q.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{(Q.servers.length>0||Q.filter)&&Q.available&&!K.authError&&e(h)});var g=P(m,2);oz(g,{});var _=P(g,2);XR(_,{});var v=P(_,2),y=e=>{dz(e,{})};V(v,e=>{Q.filtered.length>0&&Q.available&&!K.authError&&e(y)});var b=P(v,2),x=e=>{z(e,_z())};V(b,e=>{Q.servers.length===0&&!Q.filter&&!Q.loading&&!K.authError&&!Q.error&&Q.available&&e(x)});var S=P(b,2),C=e=>{z(e,vz())};V(S,e=>{Q.servers.length>0&&Q.filtered.length===0&&Q.filter&&!Q.loading&&!K.authError&&Q.available&&e(C)}),T(n),z(e,n),D()}Hr([`click`]);var xz=`api_keys`,Sz=`session_sticky_keys`,Cz=`base_url`,wz=`service_account_json`,Tz=`models`,Ez={[xz]:{label:`API Keys`,control:`keys`,hint:`Identified sessions stay on one key by default, improving provider prompt-cache hits. Saved values are shown as ***********; leave the asterisks unchanged to keep the stored key.`},[Sz]:{label:`Session-sticky API keys`,control:`checkbox`,hint:`Keep each identified conversation on one API key to preserve provider prompt-cache affinity. Turn off to rotate keys round-robin on every request.`},[Cz]:{label:`Base URL`,control:`text`},api_version:{label:`API Version`,control:`text`,placeholder:`e.g. 2024-10-01-preview`,hint:`Leave empty for the provider default. Realtime endpoints may need a newer version.`},backend:{label:`Backend`,control:`select`,hint:`Which Google surface to call. Vertex authenticates with Google credentials instead of an API key.`},auth_type:{label:`Auth Type`,control:`select`,hint:`How to obtain Google credentials. Leave on the default to use Application Default Credentials.`},api_mode:{label:`API Mode`,control:`select`,hint:`Which request shape to send upstream.`},vertex_project:{label:`Vertex Project`,control:`text`,placeholder:`my-gcp-project`},vertex_location:{label:`Vertex Location`,control:`text`,placeholder:`us-central1`},service_account_file:{label:`Service Account File`,control:`text`,placeholder:`/path/to/service-account.json`,hint:`Path readable by the gateway process.`},[wz]:{label:`Service Account JSON`,control:`textarea`,placeholder:`Paste service account JSON`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value, or clear it to remove.`},service_account_json_base64:{label:`Service Account JSON (base64)`,control:`text`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value.`},gcp_scope:{label:`GCP Scope`,control:`text`,placeholder:`https://www.googleapis.com/auth/cloud-platform`},[Tz]:{label:`Models (comma-separated)`,control:`text`,placeholder:`gpt-4o, gpt-4o-mini`,hint:`Leave empty to auto-discover models from the provider's /models endpoint where supported.`}};function Dz(e){return Ez[e]||{label:String(e||``).split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),control:`text`}}function Oz(){return{name:``,type:``,api_keys:[],session_sticky_keys:!0,base_url:``,api_version:``,backend:``,auth_type:``,api_mode:``,vertex_project:``,vertex_location:``,service_account_file:``,service_account_json:``,service_account_json_base64:``,gcp_scope:``,models:``,enabled:!0}}function kz(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.type,e.base_url].some(e=>String(e||``).toLowerCase().includes(r)))}function Az(e,t){let n=(Array.isArray(e)?e:[]).map(e=>String(e&&e.type||``).trim()).filter(Boolean),r=String(t||``).trim();return r&&!n.includes(r)&&n.push(r),n}function jz(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>String(e&&e.type||``).trim()===n)||null}function Mz(e,t){let n=e&&Array.isArray(e.fields)&&e.fields.length>0?e.fields:Object.keys(Ez).map(e=>({name:e,advanced:e!==xz})),r=t||e&&e.default_base_url||``,i=[],a=[];for(let e of n){let t=String(e&&e.name||``).trim();if(!t)continue;let n={...Dz(t),name:t,required:!!(e&&e.required),options:Array.isArray(e&&e.options)?e.options:[]};t===`base_url`&&r&&(n.placeholder=r,n.hint=`Defaults to `+r),n.options.length>0&&(n.control=`select`),(e&&e.advanced?a:i).push(n)}return{primary:i,advanced:a}}var Nz=new Set([`name`,`type`,`enabled`]);function Pz(e,t){let n=new Set([...t.primary||[],...t.advanced||[]].map(e=>e.name)),r=Oz(),i={...e};for(let e of Object.keys(r))!Nz.has(e)&&!n.has(e)&&(i[e]=r[e]);return i}function Fz(e){let t=Array.isArray(e&&e.api_keys)?e.api_keys.length:0;return t>0?t+` key`+(t===1?``:`s`):String(e&&e.service_account_json||``).trim()||String(e&&e.service_account_json_base64||``).trim()||String(e&&e.service_account_file||``).trim()?`service account`:String(e&&e.vertex_project||``).trim()?`ADC`:`keyless`}function Iz(e){let t=Array.isArray(e&&e.models)?e.models:[];return t.length===0?`auto-discovered`:t.length+` model`+(t.length===1?``:`s`)}function Lz(e){return(Array.isArray(e)?e:[]).map(e=>({value:String(e||``)}))}function Rz(e){return(Array.isArray(e)?e:[]).map(e=>String(e&&e.value||``))}function zz(e,t){let n=String(t||``).trim();if(!n)return``;let r=new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.name||``).trim()));if(!r.has(n))return n;let i=1;for(;r.has(n+`-`+i);)i+=1;return n+`-`+i}function Bz(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),api_keys:Lz(e&&e.api_keys),session_sticky_keys:!e||e.session_sticky_keys!==!1,base_url:String(e&&e.base_url||``),api_version:String(e&&e.api_version||``),backend:String(e&&e.backend||``),auth_type:String(e&&e.auth_type||``),api_mode:String(e&&e.api_mode||``),vertex_project:String(e&&e.vertex_project||``),vertex_location:String(e&&e.vertex_location||``),service_account_file:String(e&&e.service_account_file||``),service_account_json:String(e&&e.service_account_json||``),service_account_json_base64:String(e&&e.service_account_json_base64||``),gcp_scope:String(e&&e.gcp_scope||``),models:(Array.isArray(e&&e.models)?e.models:[]).join(`, `),enabled:!e||e.enabled!==!1}}function Vz(e){let t=String(e||``).trim();return t.length>=3&&/^\*+$/.test(t)}function Hz(e,t,n,r){let i={},a=String(e&&e.name||``).trim();String(e&&e.type||``).trim()||(i.type=`Select a provider type.`),a?a.includes(`/`)?i.name=`Name cannot contain '/' — it separates the provider from the model.`:t===`create`&&(Array.isArray(n)?n:[]).some(e=>String(e&&e.name||``).trim()===a)&&(i.name=`Provider "`+a+`" already exists.`):i.name=`Name is required.`;let{primary:o,advanced:s}=Mz(r);for(let t of[...o,...s]){let n=Uz(e,t);n&&(i[t.name]=n)}return i}function Uz(e,t){if(t.name===`api_keys`){let n=Rz(e&&e.api_keys);return t.required&&!n.some(e=>e.trim())?`At least one API key is required for this provider type.`:n.some(e=>!e.trim())?`Remove the empty row instead of leaving a key blank.`:``}let n=String(e&&e[t.name]||``).trim();if(t.required&&!n)return t.label+` is required for this provider type.`;if(!n)return``;if(t.name===`base_url`&&!n.includes(`://`)&&/[./]/.test(n))return`Include the scheme, e.g. https://`+n;if(t.name===`service_account_json`&&!Vz(n))try{JSON.parse(n)}catch{return`Paste the service account JSON file's contents — this is not valid JSON.`}return``}function Wz(e,t){let n={name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),enabled:!!(e&&e.enabled)},{primary:r,advanced:i}=Mz(t),a=!!(t&&Array.isArray(t.fields)&&t.fields.length>0),o=new Set;for(let t of[...r,...i])!a&&t.name===`session_sticky_keys`||(o.add(t.name),n[t.name]=Gz(e,t.name));for(let t of Object.keys(Ez)){if(o.has(t)||t===`session_sticky_keys`)continue;let r=Gz(e,t);(Array.isArray(r)?r.length>0:String(r).trim()!==``)&&(n[t]=r)}return n}function Gz(e,t){switch(t){case xz:return Rz(e&&e.api_keys);case Tz:return ic(e&&e.models);case Sz:return!!(e&&e.session_sticky_keys);case wz:return e&&e.service_account_json||``;default:return String(e&&e[t]||``).trim()}}var $=new class{#e=k(j([]));get rows(){return I(this.#e)}set rows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get advancedOpen(){return I(this.#c)}set advancedOpen(e){A(this.#c,e,!0)}#l=k(j(Oz()));get form(){return I(this.#l)}set form(e){A(this.#l,e,!0)}#u=k(j({}));get fieldErrors(){return I(this.#u)}set fieldErrors(e){A(this.#u,e,!0)}#d=k(``);get focusField(){return I(this.#d)}set focusField(e){A(this.#d,e,!0)}#f=k(``);get deletingName(){return I(this.#f)}set deletingName(e){A(this.#f,e,!0)}#p=k(!1);get deleteSubmitting(){return I(this.#p)}set deleteSubmitting(e){A(this.#p,e,!0)}#m=k(j([]));get types(){return I(this.#m)}set types(e){A(this.#m,e,!0)}#h=k(!1);get typesLoaded(){return I(this.#h)}set typesLoaded(e){A(this.#h,e,!0)}#g=null;get filteredRows(){return kz(this.rows,this.filter)}get schema(){return jz(this.types,this.form.type)}get formFields(){if(!String(this.form.type||``).trim())return{primary:[],advanced:[]};let e=this.schema;return Mz(e,e&&e.default_base_url)}async fetchTypes(){let e=await _T(`/admin/provider-credentials/types`,{label:`provider credential types`});e.status===`ok`&&(this.types=e.items,this.typesLoaded=!0)}async fetchPage(){this.#g&&this.#g.abort();let e=new AbortController;this.#g=e,this.loading=!0,this.error=``;try{let t=await _T(`/admin/provider-credentials`,{label:`provider credentials`,errorFallback:`Failed to load provider credentials.`,unavailableStatuses:[503,404],options:{signal:e.signal}});if(t.status===`stale`||e.signal.aborted)return;if(t.status===`unavailable`){this.available=!1,this.rows=[];return}if(t.status===`error`){t.result&&(this.available=!0),this.rows=[],this.error=t.error;return}this.available=!0,this.rows=t.items,this.typesLoaded||await this.fetchTypes()}finally{this.#g===e&&(this.#g=null,this.loading=!1)}}#_(e,t){this.formMode=e,this.form=t,this.advancedOpen=!1,this.error=``,this.fieldErrors={},this.focusField=``}openCreate(){this.#_(`create`,Oz()),this.formOpen=!0,this.typesLoaded||this.fetchTypes()}openEdit(e){!e||e.managed||(this.#_(`edit`,Bz(e)),this.formOpen=!0,this.typesLoaded||this.fetchTypes())}closeForm(){this.formOpen=!1,this.#_(`create`,Oz())}selectType(){this.fieldErrors={};let e=this.formFields;this.formMode===`create`&&(this.form=Pz(this.form,e));let t=e.primary.find(e=>e.name===`api_keys`);t&&t.required&&this.form.api_keys.length===0&&(this.form.api_keys=[{value:``}])}clearFieldError(e){if(this.fieldErrors[e]===void 0)return;let{[e]:t,...n}=this.fieldErrors;this.fieldErrors=n}addApiKeyRow(){this.form.api_keys.push({value:``}),this.clearFieldError(`api_keys`)}removeApiKeyRow(e){this.form.api_keys.splice(e,1),this.clearFieldError(`api_keys`)}#v(e){let t=fs(e,`Failed to save provider credential.`),n=String(e&&e.error&&typeof e.error==`object`&&e.error.param||``).trim();if(n&&this.#y(n)){this.fieldErrors={...this.fieldErrors,[n]:t},this.error=``,this.#b();return}this.error=t}#y(e){if(e===`name`||e===`type`)return!0;let{primary:t,advanced:n}=this.formFields;return[...t,...n].some(t=>t.name===e)}#b(){let e=Object.keys(this.fieldErrors);if(e.length===0)return;let{primary:t,advanced:n}=this.formFields;n.some(t=>e.includes(t.name))&&(this.advancedOpen=!0);let r=[`type`,`name`,...t.map(e=>e.name),...n.map(e=>e.name)];this.focusField=r.find(t=>e.includes(t))||e[0]}#x(){Nc.fetchModels(),Nc.fetchCategories()}async submitForm(){let e=this.schema,t=Hz(this.form,this.formMode,this.rows,e);if(Object.keys(t).length>0){this.fieldErrors=t,this.error=``,this.#b();return}let n=Wz(this.form,e);this.error=``,this.fieldErrors={},this.formSubmitting=!0;try{let e=await vT(`/admin/provider-credentials`,`PUT`,n,{label:`save provider credential`,errorFallback:`Failed to save provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.error=e.error;return}if(e.status===`error`){e.result&&e.result.status!==401?this.#v(e.result.data):this.error=e.error;return}q.success(`Provider "`+n.name+`" saved.`),this.closeForm(),this.#x(),this.fetchPage()}finally{this.formSubmitting=!1}}async performDelete(e){this.deleteSubmitting=!0,this.deletingName=e;try{let t=await vT(`/admin/provider-credentials/`+encodeURIComponent(e),`DELETE`,void 0,{label:`delete provider credential`,errorFallback:`Failed to delete provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,Rs.error=t.error;return}if(t.status===`error`){Rs.error=t.error;return}q.success(`Provider "`+e+`" deleted.`),Rs.close(),this.formOpen&&this.form.name===e&&this.closeForm(),this.#x(),this.fetchPage()}finally{this.deleteSubmitting=!1,this.deletingName=``}}requestDelete(e){let t=String(e||``).trim();if(!t||this.deleteSubmitting)return;let n=(this.rows||[]).find(e=>String(e&&e.name||``).trim()===t);n&&n.managed||Rs.open({title:`Delete Provider`,titleId:`providerCredentialDeleteDialogTitle`,inputId:`provider-credential-delete-confirmation`,message:`Type "`+t+`" to permanently delete this provider credential. Requests routed to it will fail until it is reconfigured.`,requiredText:t,confirmLabel:`Delete Provider`,icon:Ao,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.performDelete(t)})}},Kz=R(`Config`),qz=R(` `,1),Jz=R(`
                  `),Yz=R(`
                  NameTypeBase URLAuthModelsEnabledUpdatedActions
                  `);function Xz(e,t){E(t,!0);var n=Yz(),r=M(n),i=P(M(r));H(i,21,()=>$.filteredRows,e=>e.name,(e,t)=>{var n=Jz(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=e=>{z(e,Kz())};V(o,e=>{I(t).managed&&e(s)}),T(r);var c=P(r),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=M(h,!0);T(h);var _=P(h),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x,!0);T(x);var C=P(x),w=M(C),ee=M(w),te=e=>{var n=qz(),r=N(n);{let e=O(()=>`Edit provider `+I(t).name);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>$.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>($.deletingName===I(t).name?`Deleting provider `:`Delete provider `)+I(t).name),n=O(()=>$.deletingName===I(t).name);gT(i,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>$.requestDelete(I(t).name),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)};V(ee,e=>{I(t).managed||e(te)}),T(w),T(C),T(n),F((e,n,r)=>{B(a,I(t).name),B(u,I(t).type),W(d,`title`,I(t).base_url||``),B(f,I(t).base_url||`—`),B(m,e),B(g,n),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).enabled,"auth-key-status-inactive":!I(t).enabled}),B(b,I(t).enabled?`Enabled`:`Disabled`),B(S,r)},[()=>Fz(I(t)),()=>Iz(I(t)),()=>ds.formatTimestamp(I(t).updated_at)]),z(e,n)}),T(i),T(r),T(n),z(e,n),D()}var Zz=R(``),Qz=R(`
                  `),$z=R(`
                  `,1),eB=R(``),tB=R(``),nB=R(``),rB=R(``),iB=R(``),aB=R(` `),oB=R(` `),sB=R(`
                  `);function cB(e,t){E(t,!0);let n=O(()=>`provider-credential-`+t.field.name),r=O(()=>$.fieldErrors[t.field.name]||``),i=O(()=>I(r)?I(n)+`-error`:t.field.hint?I(n)+`-hint`:void 0),a=O(()=>{let e=String($.form[t.field.name]||``).trim();return!e||t.field.options.includes(e)?t.field.options:[...t.field.options,e]});function o(){$.clearFieldError(t.field.name)}var s=sB(),c=M(s),l=M(c),u=P(l),d=e=>{z(e,Zz())};V(u,e=>{t.field.required&&e(d)}),T(c);var f=P(c,2),p=e=>{var t=$z(),a=N(t);H(a,21,()=>$.form.api_keys,oi,(e,t,a)=>{var s=Qz(),c=M(s);na(c),W(c,`aria-label`,`API key `+(a+1)),gT(P(c,2),{label:`Remove API key `+(a+1),class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>$.removeApiKeyRow(a),children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(s),F(()=>{W(c,`id`,a===0?I(n):I(n)+`-`+a),W(c,`aria-invalid`,I(r)?`true`:void 0),W(c,`aria-describedby`,a===0?I(i):void 0)}),L(`input`,c,o),da(c,()=>I(t).value,e=>I(t).value=e),z(e,s)}),T(a);var s=P(a,2),c=M(s);G(M(c),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(c),T(s),F(()=>W(c,`id`,$.form.api_keys.length===0?I(n):void 0)),L(`click`,c,()=>$.addApiKeyRow()),z(e,t)},m=e=>{var s=tB(),c=M(s);c.value=c.__value=``,H(P(c),16,()=>I(a),e=>e,(e,t)=>{var n=eB(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(s),F(()=>{W(s,`id`,I(n)),W(s,`aria-invalid`,I(r)?`true`:void 0),W(s,`aria-describedby`,I(i))}),L(`change`,s,o),Gi(s,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,s)},h=e=>{var a=nB();na(a),F(()=>{W(a,`id`,I(n)),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`change`,a,o),fa(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},g=e=>{var a=rB();ft(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},_=e=>{var a=iB();na(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)};V(f,e=>{t.field.control===`keys`?e(p):t.field.control===`select`?e(m,1):t.field.control===`checkbox`?e(h,2):t.field.control===`textarea`?e(g,3):e(_,-1)});var v=P(f,2),y=e=>{var t=aB(),i=M(t,!0);T(t),F(()=>{W(t,`id`,I(n)+`-error`),B(i,I(r))}),z(e,t)},b=e=>{var r=oB(),i=M(r,!0);T(r),F(()=>{W(r,`id`,I(n)+`-hint`),B(i,t.field.hint)}),z(e,r)};V(v,e=>{I(r)?e(y):t.field.hint&&e(b,1)}),T(s),F(()=>{W(c,`for`,I(n)),B(l,`${t.field.label??``} `)}),z(e,s),D()}Hr([`input`,`click`,`change`]);var lB=R(`

                  The name is the stable identity used for routing and cannot change once created.

                  `),uB=R(``),dB=R(` `),fB=R(`Determines which fields the gateway uses to build requests.`),pB=R(` `),mB=R(`Suggested from the selected type; used to route requests to this provider instance and editable before saving.`),hB=R(`Immutable once created.`),gB=R(`

                  Pick a type to configure its credentials — each provider type asks for different settings.

                  `),_B=R(`
                  Advanced settings
                  `),vB=R(`
                  `,1);function yB(e,t){E(t,!0);let n=O(()=>Az($.types,$.form.type)),r=O(()=>$.formFields),i=O(()=>$.fieldErrors.name||``),a=O(()=>$.fieldErrors.type||``);function o(){$.selectType(),$.formMode===`create`&&($.form.name=zz($.rows,$.form.type))}An(()=>{let e=$.focusField;if(!e)return;$.focusField=``;let t=document.getElementById(`provider-credential-`+e);t&&(t.scrollIntoView({block:`center`}),t.focus({preventScroll:!0}))});{let t=e=>{z(e,lB())},s=O(()=>$.formMode===`edit`?`Edit Provider`:`Add Provider`);bE(e,{get open(){return $.formOpen},get title(){return I(s)},ariaLabel:`Provider credential editor`,get error(){return $.error},get submitting(){return $.formSubmitting},novalidate:!0,onclose:()=>$.closeForm(),onsubmit:()=>$.submitForm(),headerHint:t,children:(e,t)=>{var s=vB(),c=N(s),l=P(M(c),2),u=M(l);u.value=u.__value=``,H(P(u),16,()=>I(n),e=>e,(e,t)=>{var n=uB(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(l);var d=P(l,2),f=e=>{var t=dB(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)},p=e=>{z(e,fB())};V(d,e=>{I(a)?e(f):e(p,-1)}),T(c);var m=P(c,2),h=P(M(m),2);na(h);var g=P(h,2),_=e=>{var t=pB(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)},v=e=>{z(e,mB())},y=e=>{z(e,hB())};V(g,e=>{I(i)?e(_):$.formMode===`create`?e(v,1):e(y,-1)}),T(m);var b=P(m,2),x=e=>{z(e,gB())};V(b,e=>{$.form.type||e(x)});var S=P(b,2);H(S,17,()=>I(r).primary,e=>e.name,(e,t)=>{cB(e,{get field(){return I(t)}})});var C=P(S,2),w=M(C);bA(M(w),{get enabled(){return $.form.enabled},label:`provider`,onclick:()=>$.form.enabled=!$.form.enabled}),T(w),T(C);var ee=P(C,2),te=e=>{var t=_B(),n=M(t),i=M(n),a=P(M(i),2),o=M(a,!0);T(a),T(i),T(n);var s=P(n,2);H(s,21,()=>I(r).advanced,e=>e.name,(e,t)=>{cB(e,{get field(){return I(t)}})}),T(s),T(t),F(e=>{t.open=$.advancedOpen,B(o,e)},[()=>I(r).advanced.map(e=>e.label).join(`, `)]),Vr(`toggle`,t,e=>$.advancedOpen=e.currentTarget.open),z(e,t)};V(ee,e=>{I(r).advanced.length>0&&e(te)}),F(()=>{l.disabled=$.formMode===`edit`,W(l,`aria-invalid`,I(a)?`true`:void 0),W(l,`aria-describedby`,I(a)?`provider-credential-type-error`:`provider-credential-type-hint`),h.disabled=$.formMode===`edit`,W(h,`aria-invalid`,I(i)?`true`:void 0),W(h,`aria-describedby`,I(i)?`provider-credential-name-error`:`provider-credential-name-hint`)}),L(`change`,l,o),Gi(l,()=>$.form.type,e=>$.form.type=e),L(`input`,h,()=>$.clearFieldError(`name`)),da(h,()=>$.form.name,e=>$.form.name=e),z(e,s)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var bB=R(`

                  Providers

                  `),xB=R(``),SB=R(`
                  Provider credential management is unavailable.
                  `),CB=R(``),wB=R(`
                  `),TB=R(`

                  No dashboard-managed providers yet. Add one here, or declare providers in config.yaml / environment variables.

                  `),EB=R(`

                  No providers match your filter.

                  `),DB=R(`
                  `);function OB(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`providers-config`&&$.fetchPage()});var n=DB(),r=M(n),i=M(r);qS(M(i),{copyId:`providers-config-help-copy`,label:`model providers help`,title:e=>{z(e,bB())},help:e=>{Ue(),z(e,Zr(`Configure LLM provider credentials here instead of setting API keys as + environment variables. Providers declared in config.yaml or env vars + are read-only (Config badge) and cannot be edited or deleted from the + dashboard. Keys are masked after saving.`))},$$slots:{title:!0,help:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=xB();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=$.formSubmitting),L(`click`,t,()=>$.openCreate()),z(e,t)};V(o,e=>{$.available&&!K.needsAuth&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,SB())};V(c,e=>{!$.available&&!K.needsAuth&&e(l)});var u=P(c,2),d=e=>{var t=CB(),n=M(t,!0);T(t),F(()=>B(n,$.error)),z(e,t)};V(u,e=>{$.error&&!K.needsAuth&&!$.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading providers...`})};V(f,e=>{$.loading&&!K.needsAuth&&e(p)});var m=P(f,2),h=e=>{var t=wB(),n=M(t);yw(M(n),{id:`provider-credential-filter`,placeholder:`Filter by name, type, or base URL...`,label:`Filter providers by name, type, or base URL`,get value(){return $.filter},set value(e){$.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{($.rows.length>0||$.filter)&&$.available&&!K.needsAuth&&e(h)});var g=P(m,2);yB(g,{});var _=P(g,2),v=e=>{Xz(e,{})};V(_,e=>{$.filteredRows.length>0&&$.available&&!K.needsAuth&&e(v)});var y=P(_,2),b=e=>{z(e,TB())};V(y,e=>{$.rows.length===0&&!$.filter&&!$.loading&&!K.needsAuth&&!$.error&&$.available&&e(b)});var x=P(y,2),S=e=>{z(e,EB())};V(x,e=>{$.rows.length>0&&$.filteredRows.length===0&&$.filter&&!$.loading&&!K.needsAuth&&$.available&&e(S)}),T(n),z(e,n),D()}Hr([`click`]);function kB(){return{name:``,description:``,user_path:``,labels:``,dashboard_access:!1,expires_at:``}}function AB(e){let t=[];for(let n of String(e||``).split(`,`)){let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function jB(e){let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t;for(let e of n.split(`/`)){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function MB(e){if(jB(e))return``;let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t,r=[];for(let e of n.split(`/`)){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function NB(e){let t=e||{},n=String(t.name||``).trim();if(!n)return{error:`Name is required.`};let r=jB(t.user_path);if(r)return{error:r};let i=MB(t.user_path),a=AB(t.labels),o={name:n,description:String(t.description||``).trim()||void 0,user_path:i||void 0,labels:a.length?a:void 0,dashboard_access:t.dashboard_access?!0:void 0};return t.expires_at&&(o.expires_at=t.expires_at+`T23:59:59Z`),{payload:o}}function PB(e,t=Date.now()){let n=e&&e.expires_at;if(!n)return!1;let r=Date.parse(n);return Number.isFinite(r)&&r<=t}function FB(e){return e?!!e.deactivated_at||e.enabled===!1:!1}function IB(e,t=Date.now()){return!e||e.active===!1||FB(e)?!1:!PB(e,t)}function LB(e){return[e.name,e.description,e.user_path,e.redacted_value,...e.labels||[]].filter(Boolean).join(` `).toLowerCase()}function RB(e,t={}){let{query:n=``,showInactive:r=!1,now:i=Date.now()}=t,a=String(n||``).trim().toLowerCase();return(Array.isArray(e)?e:[]).filter(e=>!r&&!IB(e,i)?!1:!a||LB(e).includes(a))}function zB(e,t){return FB(e)?2:+!IB(e,t)}function BB(e){let t=e&&e.expires_at;if(!t)return 1/0;let n=Date.parse(t);return Number.isFinite(n)?n:1/0}function VB(e){let t=Date.parse(e&&e.deactivated_at||``);return Number.isFinite(t)?t:-1/0}function HB(e,t=Date.now()){return(Array.isArray(e)?e.slice():[]).sort((e,n)=>{let r=zB(e,t),i=zB(n,t);if(r!==i)return r-i;let[a,o]=r===2?[VB(e),VB(n)]:[BB(e),BB(n)];return a===o?String(e.name||``).localeCompare(String(n.name||``)):a>o?-1:1})}function UB(e,t=Date.now()){return(Array.isArray(e)?e:[]).reduce((e,n)=>e+ +!IB(n,t),0)}function WB(){return{open:!1,id:``,name:``,value:``,submitting:!1,error:``}}var GB=new class{#e=k(j([]));get keys(){return I(this.#e)}set keys(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get showInactive(){return I(this.#a)}set showInactive(e){A(this.#a,e,!0)}#o=O(()=>HB(RB(this.keys,{query:this.filter,showInactive:this.showInactive})));get visibleKeys(){return I(this.#o)}set visibleKeys(e){A(this.#o,e)}#s=O(()=>UB(this.keys));get inactiveCount(){return I(this.#s)}set inactiveCount(e){A(this.#s,e)}#c=k(!1);get formOpen(){return I(this.#c)}set formOpen(e){A(this.#c,e,!0)}#l=k(!1);get formSubmitting(){return I(this.#l)}set formSubmitting(e){A(this.#l,e,!0)}#u=k(``);get issuedValue(){return I(this.#u)}set issuedValue(e){A(this.#u,e,!0)}#d=k(``);get deactivatingID(){return I(this.#d)}set deactivatingID(e){A(this.#d,e,!0)}#f=k(``);get dashboardAccessID(){return I(this.#f)}set dashboardAccessID(e){A(this.#f,e,!0)}#p=k(j(kB()));get form(){return I(this.#p)}set form(e){A(this.#p,e,!0)}#m=k(j(WB()));get labelsEditor(){return I(this.#m)}set labelsEditor(e){A(this.#m,e,!0)}copyState=_M({logPrefix:`Failed to copy auth key:`});async fetchKeys(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/auth-keys`,{label:`auth keys`,errorFallback:`Unable to load API keys.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.keys=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.error=e.error;return}this.available=!0,this.keys=e.items}finally{this.loading=!1}}openForm(){this.formSubmitting||this.formOpen||(this.formOpen=!0,this.error=``,this.issuedValue||(this.copyState.reset(),this.form=kB()))}closeForm(){this.formOpen&&(this.formOpen=!1,this.error=``,this.copyState.reset(),!this.formSubmitting&&!this.issuedValue&&(this.form=kB()))}copyIssuedValue(){return this.copyState.copy(this.issuedValue)}dismissIssuedKey(){this.issuedValue=``,this.copyState.reset(),this.form=kB()}async submitForm(){let e=NB(this.form);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/auth-keys`,`POST`,e.payload,{label:`create API key`,errorFallback:`Failed to create API key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error,t.result&&t.result.status!==401&&console.error(`Failed to create API key:`,t.result.status,this.error);return}let n=t.result.data||{};this.issuedValue=n.value||``,this.formOpen=!0,this.copyState.reset(),this.form=kB(),this.fetchKeys()}finally{this.formSubmitting=!1}}openLabelsEditor(e){!e||this.labelsEditor.submitting||(this.labelsEditor={open:!0,id:e.id,name:e.name||``,value:(e.labels||[]).join(`, `),submitting:!1,error:``})}closeLabelsEditor(){!this.labelsEditor.open||this.labelsEditor.submitting||(this.labelsEditor=WB())}async submitLabelsEditor(){let e=this.labelsEditor;if(!e.open||e.submitting||!e.id)return;e.submitting=!0,e.error=``;let t={labels:AB(e.value)};try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/labels`,`PUT`,t,{label:`update API key labels`,errorFallback:`Failed to update labels.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,e.error=n.error;return}if(n.status===`error`){e.error=n.error,n.result&&n.result.status!==401&&console.error(`Failed to update auth key labels:`,n.result.status,e.error);return}q.success(`Labels updated for key "`+e.name+`".`),e.submitting=!1,this.closeLabelsEditor(),this.fetchKeys()}finally{e.submitting=!1}}async toggleDashboardAccess(e){if(!e||!e.active||this.dashboardAccessID)return;let t=!e.dashboard_access;this.dashboardAccessID=e.id;try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/dashboard-access`,`PUT`,{dashboard_access:t},{label:`update API key dashboard access`,errorFallback:`Failed to update dashboard access.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,q.error(n.error);return}if(n.status===`error`){n.result&&n.result.status!==401&&console.error(`Failed to update auth key dashboard access:`,n.result.status,n.error),q.error(n.error);return}q.success(`Dashboard access `+(t?`granted to`:`revoked for`)+` key "`+e.name+`".`),this.fetchKeys()}finally{this.dashboardAccessID=``}}async deactivateKey(e){if(!(!e||!e.active)&&window.confirm(`Deactivate key "`+e.name+`"? This cannot be undone.`)){this.deactivatingID=e.id;try{let t=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/deactivate`,`POST`,void 0,{label:`deactivate API key`,errorFallback:`Failed to deactivate key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,q.error(t.error);return}if(t.status===`error`){t.result&&t.result.status!==401&&console.error(`Failed to deactivate auth key:`,t.result.status,t.error),q.error(t.error);return}q.success(`Key "`+e.name+`" deactivated.`),this.fetchKeys()}finally{this.deactivatingID=``}}}},KB=R(``),qB=R(`

                  Store this key securely — it won’t be shown again.

                  `),JB=R(``),YB=R(``),XB=R(``),ZB=R(``),QB=R(`
                  `);function $B(e,t){E(t,!0);{let t=O(()=>GB.issuedValue?``:GB.error),n=O(()=>GB.issuedValue?`Done, I’ve stored it`:`Create API Key`),r=O(()=>GB.issuedValue?Va:po);bE(e,{get open(){return GB.formOpen},title:`Create API Key`,ariaLabel:`API key editor`,get error(){return I(t)},get submitting(){return GB.formSubmitting},get submitLabel(){return I(n)},submittingLabel:`Creating...`,get submitIcon(){return I(r)},cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>GB.closeForm(),onsubmit:()=>GB.issuedValue?GB.dismissIssuedKey():GB.submitForm(),children:(e,t)=>{var n=Qr(),r=N(n),i=e=>{var t=qB(),n=P(M(t),2),r=M(n),i=M(r,!0);T(r),dL(P(r,2),{get state(){return GB.copyState},onclick:()=>GB.copyIssuedValue()}),T(n);var a=P(n,2),o=e=>{z(e,KB())};V(a,e=>{GB.copyState.error&&e(o)}),T(t),F(()=>B(i,GB.issuedValue)),z(e,t)},a=e=>{var t=QB(),n=M(t),r=M(n),i=P(M(r),2);na(i),T(r);var a=P(r,2),o=P(M(a),2);na(o),T(a),T(n);var s=P(n,2),c=M(s);qS(c,{copyId:`auth-key-user-path-help-copy`,label:`API key user path help`,title:e=>{z(e,JB())},help:e=>{Ue(),z(e,Zr(`When set, this key overrides the configured user path request + header for audit logging and downstream request context.`))},$$slots:{title:!0,help:!0}});var l=P(c,2);na(l),T(s);var u=P(s,2),d=M(u);qS(d,{copyId:`auth-key-labels-help-copy`,label:`API key labels help`,title:e=>{z(e,YB())},help:e=>{Ue(),z(e,Zr(`Every request authenticated with this key gets these labels, in + addition to any labels from tagging headers. Labels show up in + usage analytics, the request log, and audit logs.`))},$$slots:{title:!0,help:!0}});var f=P(d,2);na(f),T(u);var p=P(u,2),m=M(p);qS(m,{copyId:`auth-key-dashboard-access-help-copy`,label:`API key dashboard access help`,title:e=>{z(e,XB())},help:e=>{Ue(),z(e,Zr(`When off, this key is denied the dashboard and every /admin API + endpoint. Model endpoints and GET /v1/usage stay available to + the key. The master key always has dashboard access.`))},$$slots:{title:!0,help:!0}});var h=P(m,2),g=M(h);na(g),Ue(2),T(h),T(p),SE(P(p,2),{id:`auth-key-description`,label:`Description (optional)`,children:(e,t)=>{var n=ZB();ft(n),da(n,()=>GB.form.description,e=>GB.form.description=e),z(e,n)},$$slots:{default:!0}}),T(t),da(i,()=>GB.form.name,e=>GB.form.name=e),da(o,()=>GB.form.expires_at,e=>GB.form.expires_at=e),da(l,()=>GB.form.user_path,e=>GB.form.user_path=e),da(f,()=>GB.form.labels,e=>GB.form.labels=e),fa(g,()=>GB.form.dashboard_access,e=>GB.form.dashboard_access=e),z(e,t)};V(r,e=>{GB.issuedValue?e(i):e(a,-1)}),z(e,n)},$$slots:{default:!0}})}D()}var eV=R(`

                  `),tV=R(`

                  Applies to new requests made with this key. Leave empty to remove all labels.

                  `,1);function nV(e,t){E(t,!0),bE(e,{get open(){return GB.labelsEditor.open},title:`Edit Labels`,ariaLabel:`API key labels editor`,get error(){return GB.labelsEditor.error},get submitting(){return GB.labelsEditor.submitting},submitLabel:`Save Labels`,cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>GB.closeLabelsEditor(),onsubmit:()=>GB.submitLabelsEditor(),headerHint:e=>{var t=eV(),n=M(t,!0);T(t),F(()=>B(n,GB.labelsEditor.name)),z(e,t)},children:(e,t)=>{SE(e,{id:`auth-key-labels-edit`,label:`Labels (comma-separated)`,children:(e,t)=>{var n=tV(),r=N(n);na(r),Ue(2),da(r,()=>GB.labelsEditor.value,e=>GB.labelsEditor.value=e),z(e,n)},$$slots:{default:!0}})},$$slots:{headerHint:!0,default:!0}}),D()}var rV=R(` `),iV=R(`
                  `),aV=R(``),oV=R(`Expired`),sV=R(` `),cV=R(` `,1),lV=R(`Deactivated`),uV=R(`
                  `),dV=R(`
                  NameDescriptionUser PathLabelsTokenDashboard Access ExpiresCreated
                  `);function fV(e,t){E(t,!0);var n=dV(),r=M(n),i=M(r),a=M(i),o=P(M(a),5),s=M(o);G(P(M(s)),{get icon(){return to},width:`13`,height:`13`}),T(s),T(o),Ue(3),T(a),T(i);var c=P(i);H(c,21,()=>GB.visibleKeys,e=>e.id,(e,t)=>{var n=uV();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i),s=M(o,!0);T(o);var c=P(o),l=M(c,!0);T(c);var u=P(c),d=M(u),f=e=>{var n=iV();H(n,20,()=>I(t).labels||[],e=>e,(e,t)=>{var n=rV(),r=M(n,!0);T(n),F(e=>{Hi(n,e),B(r,t)},[()=>Uy(t)]),z(e,n)}),T(n),z(e,n)},p=e=>{z(e,aV())};V(d,e=>{(I(t).labels||[]).length>0?e(f):e(p,-1)}),T(u);var m=P(u),h=M(m),g=M(h,!0);T(h),T(m);var _=P(m),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x),C=e=>{var n=sV(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{z(e,oV())},s=O(()=>PB(I(t)));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>pc(I(t).expires_at)]),z(e,n)},w=e=>{z(e,Zr(`—`))};V(S,e=>{I(t).expires_at?e(C):e(w,-1)}),T(x);var ee=P(x),te=M(ee,!0);T(ee);var ne=P(ee),re=M(ne),ie=M(re),ae=e=>{var n=cV(),r=N(n);{let e=O(()=>(I(t).dashboard_access?`Revoke dashboard access for API key `:`Grant dashboard access to API key `)+I(t).name),n=O(()=>!!GB.dashboardAccessID);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>GB.toggleDashboardAccess(I(t)),get disabled(){return I(n)},children:(e,n)=>{{let n=O(()=>I(t).dashboard_access?wo:Co);G(e,{get icon(){return I(n)},class:`table-icon-svg`})}},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>`Edit labels for API key `+I(t).name);gT(i,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>GB.openLabelsEditor(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var a=P(i,2);{let e=O(()=>(GB.deactivatingID===I(t).id?`Deactivating API key `:`Deactivate API key `)+I(t).name),n=O(()=>GB.deactivatingID===I(t).id);gT(a,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>GB.deactivateKey(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return mo},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)},oe=e=>{var n=lV();F(e=>W(n,`title`,e),[()=>I(t).deactivated_at?`Deactivated on `+mc(I(t).deactivated_at):`Deactivated`]),z(e,n)},se=O(()=>FB(I(t)));V(ie,e=>{I(t).active?e(ae):I(se)&&e(oe,1)}),T(re),T(ne),T(n),F((e,i,o)=>{r=U(n,1,`svelte-nf0ldb`,null,r,e),B(a,I(t).name),B(s,I(t).description||`—`),B(l,I(t).user_path||`—`),B(g,I(t).redacted_value),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).dashboard_access,"auth-key-status-inactive":!I(t).dashboard_access}),B(b,I(t).dashboard_access?`Allowed`:`Denied`),W(x,`title`,i),B(te,o)},[()=>({"auth-key-row-deactivated":FB(I(t))}),()=>I(t).expires_at?mc(I(t).expires_at):``,()=>ds.formatTimestamp(I(t).created_at)]),z(e,n)}),T(c),T(r),T(n),z(e,n),D()}var pV=R(``),mV=R(`
                  API key management is unavailable.
                  `),hV=R(``),gV=R(`

                  Managed API keys authenticate requests to the gateway. Deactivation is + permanent — create a new key if access needs to be restored.

                  `),_V=R(`
                  `),vV=R(`
                  `),yV=R(`

                  `),bV=R(`

                  No API keys yet. Issue a key to get started.

                  `),xV=R(`
                  `);function SV(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`auth-keys`&&GB.fetchKeys()});var n=xV(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=pV();G(M(t),{get icon(){return po},class:`table-icon-svg`}),Ue(2),T(t),F(()=>t.disabled=GB.formSubmitting),L(`click`,t,()=>{GB.formSubmitting||GB.openForm()}),z(e,t)};V(a,e=>{GB.available&&!K.authError&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,mV())};V(s,e=>{!GB.available&&!K.authError&&e(c)});var l=P(s,2),u=e=>{var t=hV(),n=M(t,!0);T(t),F(()=>B(n,GB.error)),z(e,t)};V(l,e=>{GB.error&&!K.authError&&!GB.formOpen&&e(u)});var d=P(l,2),f=e=>{z(e,gV())};V(d,e=>{GB.available&&!K.authError&&e(f)});var p=P(d,2);$B(p,{});var m=P(p,2);nV(m,{});var h=P(m,2),g=e=>{var t=_V();SS(M(t),{size:18,label:`Loading API keys`}),T(t),z(e,t)};V(h,e=>{GB.loading&&GB.keys.length===0&&e(g)});var _=P(h,2),v=e=>{var t=vV(),n=M(t);yw(M(n),{placeholder:`Filter by name, description, user path, label, or token...`,label:`Filter API keys by name, description, user path, label, or token`,get value(){return GB.filter},set value(e){GB.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i);na(a);var o=P(a,2),s=P(M(o)),c=e=>{var t=Zr();F(()=>B(t,`(${GB.inactiveCount??``})`)),z(e,t)};V(s,e=>{GB.inactiveCount>0&&e(c)}),T(o),T(i),T(r),T(t),fa(a,()=>GB.showInactive,e=>GB.showInactive=e),z(e,t)};V(_,e=>{GB.keys.length>0&&GB.available&&e(v)});var y=P(_,2),b=e=>{fV(e,{})};V(y,e=>{GB.visibleKeys.length>0&&GB.available&&e(b)});var x=P(y,2),S=e=>{var t=yV(),n=M(t);T(t),F(()=>B(n,`No API keys match the current filter.${GB.inactiveCount>0&&!GB.showInactive?` `+GB.inactiveCount+` inactive `+(GB.inactiveCount===1?`key is`:`keys are`)+` hidden.`:``}`)),z(e,t)};V(x,e=>{GB.keys.length>0&&GB.visibleKeys.length===0&&GB.available&&e(S)});var C=P(x,2),w=e=>{z(e,bV())};V(C,e=>{GB.keys.length===0&&!GB.loading&&!K.authError&&!GB.error&&GB.available&&e(w)}),T(n),z(e,n),D()}Hr([`click`]);var CV=R(`

                  Timezone

                  `),wV=R(``),TV=R(``),EV=R(`
                  `,1);function DV(e,t){E(t,!0);function n(){ds.saveOverride(),K.refresh()}function r(){ds.clearOverride(),K.refresh()}var i=EV(),a=N(i);qS(M(a),{copyId:`timezone-help-copy`,label:`timezone help`,text:`Day-based analytics, charts, and date filters use your effective timezone. Usage and audit logs keep UTC in the hover title while rendering row timestamps in your effective timezone.`,title:e=>{z(e,CV())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=P(M(s),2),l=M(c),u=M(l);T(l),l.value=l.__value=``,H(P(l),17,()=>ds.options,e=>e.value,(e,t)=>{var n=wV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(c),T(s),T(o);var d=P(o,2),f=M(d),p=e=>{var t=TV();L(`click`,t,r),z(e,t)};V(f,e=>{ds.override&&e(p)}),T(d),F(e=>B(u,`Automatic (${e??``})`),[()=>ds.detectedTimeZoneLabel()]),Vr(`focus`,c,()=>ds.ensureOptions()),L(`change`,c,n),Gi(c,()=>ds.override,e=>ds.override=e),z(e,i),D()}Hr([`change`,`click`]);var OV=R(``),kV=R(`

                  Failover

                  `,1);function AV(e,t){E(t,!0);let n=O(()=>Z.failoverSaving||Z.failoverGenerating||Z.failoverDraftSaving||!Z.failoverAvailable||!Z.failoverEnabled());var r=kV(),i=N(r),a=P(M(i),2),o=M(a),s=M(o);G(s,{get icon(){return Po},class:`form-action-icon`});var c=P(s,2),l=M(c,!0);T(c),T(o);var u=P(o,2);G(M(u),{get icon(){return Ao},class:`form-action-icon`}),Ue(2),T(u),T(a),T(i);var d=P(i,2),f=M(d),p=e=>{var t=OV(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(f,e=>{Z.failoverError&&e(p)}),T(d),fj(P(d,2),{}),F(()=>{o.disabled=I(n),B(l,Z.failoverGenerating?`Generating...`:`Generate failover models automatically`),u.disabled=I(n)}),L(`click`,o,()=>Z.generateFailoverRules()),L(`click`,u,()=>Z.openFailoverResetDialog()),z(e,r),D()}Hr([`click`]);function jV(){return{daily_reset_hour:0,daily_reset_minute:0,weekly_reset_weekday:1,weekly_reset_hour:0,weekly_reset_minute:0,monthly_reset_day:1,monthly_reset_hour:0,monthly_reset_minute:0}}function MV(e,t){let n=t||{},r=(e,t)=>{if(e===``)return t;let n=Number(e);return Number.isFinite(n)&&Number.isInteger(n)?Math.trunc(n):t},i=(e,t)=>r(n[e],t),a=(t,n)=>e?r(e[t],n):n;return{daily_reset_hour:a(`daily_reset_hour`,i(`daily_reset_hour`,0)),daily_reset_minute:a(`daily_reset_minute`,i(`daily_reset_minute`,0)),weekly_reset_weekday:a(`weekly_reset_weekday`,i(`weekly_reset_weekday`,1)),weekly_reset_hour:a(`weekly_reset_hour`,i(`weekly_reset_hour`,0)),weekly_reset_minute:a(`weekly_reset_minute`,i(`weekly_reset_minute`,0)),monthly_reset_day:a(`monthly_reset_day`,i(`monthly_reset_day`,1)),monthly_reset_hour:a(`monthly_reset_hour`,i(`monthly_reset_hour`,0)),monthly_reset_minute:a(`monthly_reset_minute`,i(`monthly_reset_minute`,0))}}function NV(){return[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}]}var PV=R(`

                  Budget Resets

                  `),FV=R(``),IV=R(`

                  If the selected day does not exist in a month, the reset runs on + the last day of that month.

                  `),LV=R(``),RV=R(``),zV=R(`
                  Monthly
                  Weekly
                  Daily
                  `,1);function BV(e,t){E(t,!0);let n=k(j(jV())),r=k(!1),i=k(!1),a=k(``),o=k(!1),s=O(()=>Ss.budgetsVisible());async function c(){if(await Ss.ensureLoaded(),!Ss.budgetsVisible()){A(a,``);return}A(r,!0),A(a,``);try{let e=await _s(`/admin/budgets/settings`,{label:`budget settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load budget settings.`);return}A(n,MV(e.data,I(n)),!0)}catch(e){console.error(`Failed to fetch budget settings:`,e),A(a,`Unable to load budget settings.`)}finally{A(r,!1)}}async function l(){if(!I(i)){A(i,!0);try{let e=await vs(`/admin/budgets/settings`,`PUT`,MV(I(n),I(n)),{label:`budget settings`});if(e.stale)return;if(!e.ok){q.error(`Unable to save budget settings.`);return}A(n,MV(e.data,I(n)),!0),A(a,``),q.success(`Budget settings saved.`)}catch(e){console.error(`Failed to save budget settings:`,e),q.error(`Unable to save budget settings.`)}finally{A(i,!1)}}}An(()=>{K.refreshTick,c()});var u=Qr(),d=N(u),f=e=>{var t=zV(),s=N(t),c=M(s);qS(c,{copyId:`budget-settings-help-copy`,label:`budget help`,text:`Budget reset anchors are stored in the database and evaluated in UTC. Hourly budgets reset at the top of each hour.`,title:e=>{z(e,PV())},$$slots:{title:!0}});var u=P(c,2),d=M(u),f=P(M(d),2),p=M(f);qS(p,{copyId:`budget-monthly-day-help-copy`,label:`day of month help`,external:!0,get open(){return I(o)},set open(e){A(o,e,!0)},title:e=>{z(e,FV())},$$slots:{title:!0}});var m=P(p,2);na(m),T(f);var h=P(f,2),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=M(y),x=e=>{z(e,IV())};V(b,e=>{I(o)&&e(x)}),T(y),T(d);var S=P(d,2),C=P(M(S),2),w=P(M(C),2);H(w,21,NV,e=>e.value,(e,t)=>{var n=LV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(w),T(C);var ee=P(C,2),te=P(M(ee),2);na(te),T(ee);var ne=P(ee,2),re=P(M(ne),2);na(re),T(ne),Ue(2),T(S);var ie=P(S,2),ae=P(M(ie),4),oe=P(M(ae),2);na(oe),T(ae);var se=P(ae,2),ce=P(M(se),2);na(ce),T(se),Ue(2),T(ie),T(u);var le=P(u,2),ue=M(le);G(M(ue),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(ue);var de=P(ue,2),fe=e=>{SS(e,{size:16,label:`Loading budget settings`})};V(de,e=>{I(r)&&e(fe)}),T(le),T(s);var pe=P(s,2),me=M(pe),he=e=>{var t=RV(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(me,e=>{I(a)&&e(he)}),T(pe),F(()=>{ue.disabled=I(i)||I(r),W(ue,`aria-busy`,I(i)?`true`:`false`)}),da(m,()=>I(n).monthly_reset_day,e=>I(n).monthly_reset_day=e),da(g,()=>I(n).monthly_reset_hour,e=>I(n).monthly_reset_hour=e),da(v,()=>I(n).monthly_reset_minute,e=>I(n).monthly_reset_minute=e),Gi(w,()=>I(n).weekly_reset_weekday,e=>I(n).weekly_reset_weekday=e),da(te,()=>I(n).weekly_reset_hour,e=>I(n).weekly_reset_hour=e),da(re,()=>I(n).weekly_reset_minute,e=>I(n).weekly_reset_minute=e),da(oe,()=>I(n).daily_reset_hour,e=>I(n).daily_reset_hour=e),da(ce,()=>I(n).daily_reset_minute,e=>I(n).daily_reset_minute=e),L(`click`,ue,l),z(e,t)};V(d,e=>{I(s)&&e(f)}),z(e,u),D()}Hr([`click`]);var VV=R(`

                  Reset All Budgets

                  Start new budget periods for every configured budget without changing + the limits.

                  `);function HV(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=VV(),n=P(M(t),2),r=M(n);G(M(r),{get icon(){return go},class:`form-action-icon`}),Ue(2),T(r),T(n),T(t),F(()=>r.disabled=Y.resetAllLoading),L(`click`,r,()=>Y.openResetDialog()),z(e,t)},a=O(()=>Ss.budgetsVisible());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}Hr([`click`]);function UV(){return{header:``,prefix:``,do_not_pass:!1,delimiter:``,managed:!1}}function WV(e){return(e&&Array.isArray(e.headers)?e.headers:[]).map(e=>({header:typeof e.header==`string`?e.header:``,prefix:typeof e.prefix==`string`?e.prefix:``,do_not_pass:e.do_not_pass===!0,delimiter:typeof e.delimiter==`string`&&e.delimiter!==`,`?e.delimiter:``,managed:e.managed===!0}))}function GV(e){return{headers:(Array.isArray(e)?e:[]).filter(e=>!e.managed&&e.header.trim()!==``).map(e=>({header:e.header.trim(),prefix:e.prefix,do_not_pass:e.do_not_pass,delimiter:e.delimiter}))}}function KV(e){return e&&e.error&&e.error.message?e.error.message:``}var qV=R(`

                  Tagging based on headers

                  `),JV=R(`config`),YV=R(``),XV=R(`
                  `),ZV=R(`

                  No tagging headers configured. Requests are not labelled.

                  `),QV=R(``),$V=R(`
                  `,1);function eH(e,t){E(t,!0);let n=k(j([])),r=k(!0),i=k(!1),a=k(!1),o=k(``);function s(){I(n).push(UV())}function c(e){let t=I(n)[e];!t||t.managed||I(n).splice(e,1)}async function l(){A(i,!0),A(o,``);try{let e=await _s(`/admin/tagging/settings`,{label:`tagging settings`});if(e.stale)return;if(!e.ok){A(o,`Unable to load tagging settings.`);return}A(n,WV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0)}catch(e){console.error(`Failed to fetch tagging settings:`,e),A(o,`Unable to load tagging settings.`)}finally{A(i,!1)}}async function u(){if(!(I(a)||!I(r))){A(a,!0);try{let e=await vs(`/admin/tagging/settings`,`PUT`,GV(I(n)),{label:`tagging settings`});if(e.stale)return;if(!e.ok){q.error(e.status!==401&&KV(e.data)||`Unable to save tagging settings.`);return}A(n,WV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0),A(o,``),q.success(`Tagging settings saved.`)}catch(e){console.error(`Failed to save tagging settings:`,e),q.error(`Unable to save tagging settings.`)}finally{A(a,!1)}}}An(()=>{K.refreshTick,l()});var d=$V(),f=N(d),p=M(f);qS(p,{copyId:`tagging-settings-help-copy`,label:`tagging help`,text:`Each request is labelled from the listed headers; labels land in usage tracking and audit logs. A header value can carry several labels split by the delimiter (default: comma). The prefix is trimmed from each label only — the header itself is forwarded unchanged unless 'Do not pass' is checked. Rows marked CONFIG come from config.yaml or TAGGING_HEADER_* env vars and are read-only here.`,title:e=>{z(e,qV())},$$slots:{title:!0}});var m=P(p,2),h=M(m);H(h,17,()=>I(n),oi,(e,t,n)=>{var i=XV(),a=M(i),o=M(a);W(o,`for`,`tagging-header-`+n);var s=P(o,2);na(s),W(s,`id`,`tagging-header-`+n),T(a);var l=P(a,2),u=M(l);W(u,`for`,`tagging-prefix-`+n);var d=P(u,2);na(d),W(d,`id`,`tagging-prefix-`+n),T(l);var f=P(l,2),p=M(f);W(p,`for`,`tagging-delimiter-`+n);var m=P(p,2);na(m),W(m,`id`,`tagging-delimiter-`+n),T(f);var h=P(f,2),g=M(h);na(g),Ue(2),T(h);var _=P(h,2),v=M(_),y=e=>{z(e,JV())},b=e=>{var i=YV();F(()=>{i.disabled=!I(r),W(i,`aria-label`,`Remove tagging header `+(I(t).header||n+1))}),L(`click`,i,()=>c(n)),z(e,i)};V(v,e=>{I(t).managed?e(y):e(b,-1)}),T(_),T(i),F(()=>{s.disabled=I(t).managed||!I(r),d.disabled=I(t).managed||!I(r),m.disabled=I(t).managed||!I(r),g.disabled=I(t).managed||!I(r)}),da(s,()=>I(t).header,e=>I(t).header=e),da(d,()=>I(t).prefix,e=>I(t).prefix=e),da(m,()=>I(t).delimiter,e=>I(t).delimiter=e),fa(g,()=>I(t).do_not_pass,e=>I(t).do_not_pass=e),z(e,i)});var g=P(h,2),_=e=>{SS(e,{size:16,label:`Loading tagging settings`})};V(g,e=>{I(i)&&e(_)});var v=P(g,2),y=e=>{z(e,ZV())};V(v,e=>{!I(i)&&I(n).length===0&&e(y)}),T(m);var b=P(m,2),x=M(b);G(M(x),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(x);var S=P(x,2);G(M(S),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(S),T(b),T(f);var C=P(f,2),w=M(C),ee=e=>{var t=QV(),n=M(t,!0);T(t),F(()=>B(n,I(o))),z(e,t)};V(w,e=>{I(o)&&e(ee)}),T(C),F(()=>{x.disabled=!I(r)||I(a)||I(i),S.disabled=!I(r)||I(a)||I(i),W(S,`aria-busy`,I(a)?`true`:`false`)}),L(`click`,x,s),L(`click`,S,u),z(e,d),D()}Hr([`click`]);function tH(e){let t=e||{};if(t.selectedPreset)return{days:parseInt(t.selectedPreset,10)||30};let n=t.customStartDate?fc(t.customStartDate):``,r=t.customEndDate||t.today||null;return{start_date:n,end_date:r?fc(r):``}}function nH(e,t,n,r){return{...tH(e),user_path:String(t||``).trim(),selector:String(n||``).trim(),confirmation:r}}function rH(e){let t=Number(e&&e.matched||0),n=Number(e&&e.recalculated||0),r=Number(e&&e.without_pricing||0),i=`Pricing recalculated for `+n+` of `+t+` usage record`+(t===1?``:`s`)+`.`;return r>0&&(i+=` `+r+` usage record`+(r===1?` still lacks`:`s still lack`)+` pricing metadata.`),i}var iH=R(`

                  Usage Pricing Recalculation

                  `),aH=R(`
                  `);function oH(e,t){E(t,!0);let n=k(``),r=k(``),i=k(!1),a=O(()=>Ss.booleanFlag(`USAGE_PRICING_RECALCULATION_ENABLED`,!1));function o(){if(!I(a)){q.error(`Usage pricing recalculation is unavailable.`);return}I(i)||Rs.open({title:`Recalculate Pricing`,titleId:`pricingRecalculateDialogTitle`,inputId:`pricing-recalculate-confirmation`,requiredText:`recalculate`,confirmLabel:`Recalculate Pricing`,icon:Ia,dialogClass:`pricing-recalculate-dialog`,message:`Stored usage cost fields matching the selected filters will be overwritten.`,onConfirm:()=>s()})}async function s(){if(!I(a)){q.error(`Usage pricing recalculation is unavailable.`);return}if(!I(i)){A(i,!0);try{let e=await vs(`/admin/usage/recalculate-pricing`,`POST`,nH({selectedPreset:Mc.selectedPreset,customStartDate:Mc.customStartDate,customEndDate:Mc.customEndDate,today:ds.todayDate()},I(n),I(r),`recalculate`),{label:`pricing recalculation`});if(e.stale)return;if(!e.ok){Rs.error=`Unable to recalculate pricing.`;return}Rs.close(),q.success(rH(e.data)),Rc.fetchUsage()}catch(e){console.error(`Failed to recalculate pricing:`,e),Rs.error=`Unable to recalculate pricing.`}finally{A(i,!1)}}}var c=Qr(),l=N(c),u=e=>{var t=aH(),s=M(t);qS(s,{copyId:`pricing-recalculate-help-copy`,label:`pricing recalculation help`,text:`Recalculate stored input, output, total, and Pro Saved costs from the current model pricing metadata. This overwrites matching historical cost fields. Filters are applied to the selected date range, user path subtree, and provider/model selector or alias.`,title:e=>{z(e,iH())},$$slots:{title:!0}});var c=P(s,2),l=M(c),u=P(M(l),2);tl(M(u),{}),T(u),T(l);var d=P(l,2),f=P(M(d),2);na(f),T(d);var p=P(d,2),m=P(M(p),2);na(m),T(p),T(c);var h=P(c,2),g=M(h);G(M(g),{get icon(){return Ia},class:`form-action-icon`}),Ue(2),T(g),T(h),T(t),F(()=>{g.disabled=I(i)||!I(a),W(g,`aria-busy`,I(i)?`true`:`false`)}),da(f,()=>I(n),e=>A(n,e)),da(m,()=>I(r),e=>A(r,e)),L(`click`,g,o),z(e,t)};V(l,e=>{I(a)&&e(u)}),z(e,c),D()}Hr([`click`]);function sH(e){return String(e&&e.status||`ok`).toLowerCase()}function cH(e){if(!e||typeof e!=`object`)return`Runtime refresh completed.`;let t=Number(e.model_count||0),n=Number(e.provider_count||0),r=sH(e);return(r===`ok`?`Runtime refreshed.`:r===`partial`?`Runtime refresh completed with warnings.`:`Runtime refresh failed.`)+` `+t+` model`+(t===1?``:`s`)+` across `+n+` provider`+(n===1?``:`s`)+`.`}function lH(e){return!!e&&sH(e)===`ok`}function uH(e){let t=e&&e.steps;return Array.isArray(t)?t:[]}function dH(e){let t=String(e&&e.name||``).replace(/_/g,` `),n=String(e&&e.status||``).trim(),r=String(e&&(e.error||e.message)||``).trim();return t?r?t+`: `+n+` - `+r:t+`: `+n:r||n||``}var fH=R(`

                  Runtime Refresh

                  `),pH=R(`
                • `),mH=R(`
                    `),hH=R(`
                    `,1);function gH(e,t){E(t,!0);let n=k(!1),r=k(null);async function i(){if(!I(n)){A(n,!0),A(r,null);try{let e=await vs(`/admin/runtime/refresh`,`POST`,void 0,{label:`runtime refresh`});if(e.stale)return;if(!e.ok){q.error(`Runtime refresh failed.`);return}A(r,e.data&&typeof e.data==`object`?e.data:null,!0),lH(I(r))?q.success(cH(I(r))):q.error(cH(I(r))),K.refresh()}catch(e){console.error(`Failed to refresh runtime:`,e),q.error(`Runtime refresh failed.`)}finally{A(n,!1)}}}var a=hH(),o=N(a),s=M(o);qS(s,{copyId:`runtime-refresh-help-copy`,label:`runtime refresh help`,text:`Pull the latest model metadata, provider inventory, API keys, aliases, model access rules, guardrails, and workflows.`,title:e=>{z(e,fH())},$$slots:{title:!0}});var c=P(s,2),l=M(c);let u;G(M(l),{get icon(){return ho},class:`settings-refresh-icon`}),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=M(d),p=e=>{var t=mH();H(t,21,()=>uH(I(r)),e=>e.name,(e,t)=>{var n=pH(),r=M(n,!0);T(n),F(e=>{U(n,1,`runtime-refresh-step is-${I(t).status??``}`,`svelte-yeq2mp`),B(r,e)},[()=>dH(I(t))]),z(e,n)}),T(t),z(e,t)},m=O(()=>uH(I(r)).length>0);V(f,e=>{I(m)&&e(p)}),T(d),F(()=>{u=U(l,1,`btn btn-primary btn-with-icon settings-refresh-btn`,null,u,{"is-refreshing":I(n)}),l.disabled=I(n),W(l,`aria-busy`,I(n)?`true`:`false`)}),L(`click`,l,i),z(e,a),D()}Hr([`click`]);var _H=R(``),vH=R(`

                    `),yH=R(`

                    `),bH=R(``),xH=R(`
                    `),SH=R(`

                    AI Processing

                    `);function CH(e,t){E(t,!0);let n=k(j([])),r=k(!1),i=k(``),a=k(``);async function o(){A(r,!0),A(a,``);try{let e=await _s(`/admin/runtime/settings`,{label:`runtime settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load runtime settings.`);return}A(n,Array.isArray(e.data?.settings)?e.data.settings:[],!0)}catch(e){console.error(`Failed to load runtime settings:`,e),A(a,`Unable to load runtime settings.`)}finally{A(r,!1)}}async function s(e,t,r){if(!(e.locked||I(i))){A(i,e.key,!0);try{let i=await vs(`/admin/runtime/settings/${encodeURIComponent(e.key)}`,`PUT`,{value:t},{label:`save ${e.label}`});if(i.stale){r.value=e.value;return}if(!i.ok){r.value=e.value,q.error(`Unable to save ${e.label}.`);return}A(n,I(n).map(t=>t.key===e.key?i.data:t),!0),q.success(`${e.label} saved.`)}catch(t){r.value=e.value,console.error(`Failed to save runtime setting:`,t),q.error(`Unable to save ${e.label}.`)}finally{A(i,``)}}}An(()=>{K.refreshTick,o()});var c=Qr(),l=N(c),u=e=>{var t=SH(),o=M(t),c=P(M(o),2),l=e=>{var t=_H(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(c,e=>{I(a)&&e(l)}),T(o);var u=P(o,2);H(u,21,()=>I(n),e=>e.key,(e,t)=>{var n=xH(),r=M(n),a=M(r),o=M(a,!0);T(a);var c=P(a,2),l=e=>{var n=vH(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(c,e=>{I(t).description&&e(l)});var u=P(c,2),d=e=>{var n=yH(),r=M(n);T(n),F(()=>B(r,`Managed by ${(I(t).managed_by||`environment`)??``}`)),z(e,n)};V(u,e=>{I(t).locked&&e(d)}),T(r);var f=P(r,2);H(f,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=bH(),r=M(n,!0);T(n);var i={};F(()=>{W(n,`title`,I(t).description||``),B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(f);var p;Wi(f),T(n),F(()=>{W(a,`for`,`runtime-setting-${I(t).key}`),B(o,I(t).label),W(f,`id`,`runtime-setting-${I(t).key}`),f.disabled=I(t).locked||I(i)!==``,p!==(p=I(t).value)&&(f.value=(f.__value=I(t).value)??``,Ui(f,I(t).value))}),L(`change`,f,e=>s(I(t),e.currentTarget.value,e.currentTarget)),z(e,n)}),T(u),T(t),F(()=>W(u,`aria-busy`,I(r)?`true`:`false`)),z(e,t)};V(l,e=>{(I(n).length>0||I(a))&&e(u)}),z(e,c),D()}Hr([`change`]);var wH=R(`
                    `);function TH(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`settings`&&(ds.ensureOptions(),Ss.ensureLoaded())});var n=wH(),r=P(M(n),2),i=M(r);DV(i,{});var a=P(i,2);AV(a,{});var o=P(a,2);BV(o,{});var s=P(o,2);HV(s,{});var c=P(s,2);eH(c,{});var l=P(c,2);CH(l,{});var u=P(l,2);oH(u,{}),gH(P(u,2),{}),T(r);var d=P(r,2),f=M(d,!0);T(d),T(n),F(e=>B(f,e),[()=>Uo()]),z(e,n),D()}var EH=R(`
                    `),DH=R(`
                     
                    `),OH=R(`
                     
                    `),kH=R(`
                     
                    `),AH=R(`
                    `),jH=R(`
                    `,1),MH=R(`
                    `);function NH(e,t){E(t,!0);let n=ya(t,`showPromptCache`,3,!0),r=O(()=>t.msg.role===`function_call`||t.msg.role===`function_result`);function i(e){return(Math.max(0,Math.min(1,Number(e||0)))*100).toFixed(1)+`%`}function a(e){let t=Math.max(0,Math.min(1,Number(e||0)));return t>0?Math.round(t*100)+`% of this visible prompt item is estimated provider-cached`:void 0}function o(e){return e.role===`function_call`?(e.toolCalls||[]).map(e=>e.name+`()`).join(`, `):(e.functionName?e.functionName+`: `:``)+e.text}var s=MH();let c;var l=M(s),u=e=>{var r=DH(),i=M(r),s=M(i),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l);var d=P(l,2),f=M(d,!0);T(d),T(i);var p=P(i,2),m=e=>{var n=EH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${t.msg.functionCallID??``}`)),z(e,n)};V(p,e=>{t.msg.functionCallID&&e(m)});var h=P(p,2),g=e=>{var n=Qr();H(N(n),17,()=>t.msg.toolCalls,oi,(e,n)=>{var r=Qr(),i=N(r),a=e=>{var r=EH(),i=M(r);T(r),F(()=>B(i,`Call ID${t.msg.toolCalls.length>1?` (`+I(n).name+`)`:``}: ${I(n).id??``}`)),z(e,r)};V(i,e=>{I(n).id&&e(a)}),z(e,r)}),z(e,n)};V(h,e=>{t.msg.role===`function_call`&&t.msg.toolCalls&&e(g)});var _=P(h,2),v=M(_,!0);T(_),T(r),F((e,n,i,a)=>{W(r,`title`,e),B(c,t.msg.roleLabel),B(u,n),B(f,i),B(v,a)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>o(t.msg),()=>ds.formatTimestamp(t.msg.timestamp),()=>JI(t.msg)]),z(e,r)},d=e=>{var r=jH(),i=N(r),o=M(i),s=M(o,!0);T(o);var c=P(o,2),l=M(c,!0);T(c),T(i);var u=P(i,2),d=e=>{var r=OH(),i=M(r,!0);T(r),F(e=>{W(r,`title`,e),B(i,t.msg.text)},[()=>n()?a(t.msg.promptCacheRatio):void 0]),z(e,r)};V(u,e=>{t.msg.text&&e(d)});var f=P(u,2),p=e=>{var n=AH();H(n,23,()=>t.msg.toolCalls,(e,t)=>e.name+`-`+t,(e,t)=>{var n=kH(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(r);var c=P(r,2),l=e=>{var n=EH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${I(t).id??``}`)),z(e,n)};V(c,e=>{I(t).id&&e(l)});var u=P(c,2),d=M(u,!0);T(u),T(n),F((e,n)=>{B(a,I(t).name+`()`),B(s,e),B(d,n)},[()=>YI(I(t))||`No arguments`,()=>YI(I(t))||`No arguments`]),z(e,n)}),T(n),z(e,n)};V(f,e=>{t.msg.toolCalls&&e(p)}),F((e,n)=>{W(i,`title`,e),B(s,t.msg.roleLabel),B(l,n)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>ds.formatTimestamp(t.msg.timestamp)]),z(e,r)};V(l,e=>{I(r)?e(u):e(d,-1)}),T(s),F(e=>{U(s,1,Fi([I(r)?`chat-function-note`:`chat-message`,t.msg.roleClass,{"is-anchor":t.msg.isAnchor,"is-after-anchor":t.msg.isAfterAnchor}]),`svelte-12s99s5`),W(s,`data-conversation-anchor`,t.msg.isAnchor?`true`:void 0),W(s,`data-entry-id`,t.msg.entryID),c=Hi(s,``,c,e)},[()=>({"--prompt-cache-fill":i(t.msg.promptCacheRatio),"--prompt-cache-visibility":n()&&t.msg.promptCacheRatio>0?`1`:`0`})]),z(e,s),D()}function PH(e,t=0){let n=Math.max(0,LH(e)-Math.max(0,LH(t))),r=Math.min(320,Math.max(180,Math.floor(n*.58))),i=Math.min(360,Math.max(128,Math.floor(n*.35)));return{min:r,max:Math.max(r,n-i)}}function FH(e,t,n=0){let r=PH(t,n),i=LH(e)||520;return Math.min(r.max,Math.max(r.min,Math.round(i)))}function IH(e,t,n=0){return FH(LH(t)-LH(e),t,n)}function LH(e){let t=Number(e);return Number.isFinite(t)?t:0}var RH=R(`
                    `),zH=R(`

                    Loading interactions...

                    `),BH=R(`

                    No interaction data available for this entry.

                    `),VH=R(``),HH=R(`
                    `,1),UH=R(`

                    Showing the newest part of this session and the selected log.

                    `),WH=R(`
                    `),GH=R(``),KH=R(``),qH=R(``);function JH(e,t){E(t,!0);let n=rL,r=Number(Ta(`gomodel_interactions_panel_width`)),i=`gomodel_interactions_prompt_cache_fill`,a=Number.isFinite(r)&&r>0?r:520,o=k(j(a)),s=k(320),c=k(760),l=k(!1),u=k(Ta(i,`true`)!==`false`),d=null;function f(){A(u,!I(u)),Ea(i,I(u))}function p(){return(document.querySelector(`.sidebar`)?.getBoundingClientRect().width||0)+(document.querySelector(`.sidebar-toggle`)?.getBoundingClientRect().width||0)}function m(){let e=p(),t=PH(window.innerWidth,e);A(s,t.min,!0),A(c,t.max,!0),A(o,FH(a,window.innerWidth,e),!0)}function h(e){A(o,IH(e,window.innerWidth,p()),!0),a=I(o)}function g(e){e.button===0&&(e.preventDefault(),d=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`conversation-panel-resizing`),h(e.clientX))}function _(e){e.pointerId===d&&h(e.clientX)}function v(e){d===null||e.pointerId!==void 0&&e.pointerId!==d||(d=null,document.body.classList.remove(`conversation-panel-resizing`),Ea(`gomodel_interactions_panel_width`,a))}function y(e){e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a=I(o)+(e.key===`ArrowLeft`?24:-24),m(),a=I(o),Ea(`gomodel_interactions_panel_width`,a))}function b(){return[document.querySelector(`.sidebar`),document.querySelector(`.sidebar-toggle`),document.getElementById(`dashboard-content`)].filter(Boolean)}An(()=>{if(!n.conversationOpen)return;m();let e=document.querySelector(`.sidebar`),t=new ResizeObserver(m);e&&t.observe(e);let r=e=>{e.key===`Escape`&&!ja.anyOpen&&(I(l)?A(l,!1):n.closeConversation())};return window.addEventListener(`keydown`,r),window.addEventListener(`resize`,m),()=>{v({}),t.disconnect(),window.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,m)}}),An(()=>{n.conversationOpen||A(l,!1)}),An(()=>{if(!I(l))return;let e=b().map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));return e.forEach(({element:e})=>{e.inert=!0,e.setAttribute(`aria-hidden`,`true`)}),()=>{e.forEach(({element:e,inert:t,ariaHidden:n})=>{e.inert=t,n===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)})}}),An(()=>{Jo.page!==`audit-logs`&&n.conversationOpen&&n.closeConversation()});var x=Qr(),S=N(x),C=e=>{var t=qH();let r,i;var a=M(t),d=P(a,2),p=M(d),m=P(M(p),2),h=M(m);let b;T(m),T(p);var x=P(p,2),S=M(x),C=M(S);{let e=O(()=>I(l)?so:oo);G(C,{get icon(){return I(e)},class:`table-icon-svg`})}T(S),ks(P(S,2),{label:`Close interactions`,onclick:()=>n.closeConversation(),get el(){return n.conversationCloseBtnEl},set el(e){n.conversationCloseBtnEl=e}}),T(x),T(d);var w=P(d,2),ee=M(w),te=e=>{var t=RH(),r=M(t,!0);T(t),F(()=>B(r,n.conversationError)),z(e,t)};V(ee,e=>{n.conversationError&&e(te)});var ne=P(ee,2),re=e=>{z(e,zH())};V(ne,e=>{n.conversationLoading&&e(re)});var ie=P(ne,2),ae=e=>{z(e,BH())},oe=O(()=>!n.conversationLoading&&!n.followUpSending&&!n.conversationError&&n.conversationMessages.length===0&&!n.conversationLiveWaiting());V(ie,e=>{I(oe)&&e(ae)});var se=P(ie,2),ce=e=>{var t=HH(),r=N(t),i=e=>{var t=VH(),n=M(t);let r;Ue(2),T(t),F(()=>{W(t,`aria-checked`,I(u)),W(t,`title`,(I(u)?`Hide`:`Show`)+` estimated provider prompt-cache fill`),r=U(n,1,`conversation-cache-switch svelte-ssrzja`,null,r,{"is-active":I(u)})}),L(`click`,t,f),z(e,t)},a=O(()=>n.conversationMessages.some(e=>Number(e.promptCacheRatio||0)>0));V(r,e=>{I(a)&&e(i)});var o=P(r,2);H(o,21,()=>n.conversationMessages,e=>e.uid,(e,t)=>{NH(e,{get msg(){return I(t)},get showPromptCache(){return I(u)}})}),T(o),ga(o,e=>n.conversationThreadEl=e,()=>n?.conversationThreadEl),z(e,t)};V(se,e=>{n.conversationMessages.length>0&&e(ce)});var le=P(se,2),ue=e=>{z(e,UH())};V(le,e=>{n.conversationTruncated&&e(ue)});var de=P(le,2),fe=e=>{var t=WH(),r=P(M(t),2),i=M(r,!0);T(r),T(t),F(e=>B(i,e),[()=>n.conversationLiveStatusText()]),z(e,t)},pe=O(()=>n.conversationLiveWaiting());V(de,e=>{I(pe)&&e(fe)}),T(w);var me=P(w,2),he=e=>{var t=KH(),r=M(t),i=M(r);ft(i);var a=P(i,2),o=e=>{var t=GH(),r=M(t,!0);T(t),F(()=>B(r,n.followUpError)),z(e,t)};V(a,e=>{n.followUpError&&e(o)});var s=P(a,2),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u),T(s),T(r),T(t),F((e,t,r)=>{i.disabled=e,B(l,t),u.disabled=r,B(d,n.followUpSending?`Sending…`:`Send`)},[()=>n.followUpSending||n.conversationLiveWaiting(),()=>n.selectedConversationEntry()?.path||``,()=>!n.canSendFollowUp()]),Vr(`submit`,r,e=>{e.preventDefault(),n.sendFollowUp()}),da(i,()=>n.followUpText,e=>n.followUpText=e),z(e,t)},ge=O(()=>n.conversationAnchorID&&n.followUpKind());V(me,e=>{I(ge)&&e(he)}),T(t),ga(t,e=>n.conversationDialogEl=e,()=>n?.conversationDialogEl),F(()=>{r=U(t,1,`conversation-drawer svelte-ssrzja`,null,r,{"conversation-drawer-fullscreen":I(l)}),W(t,`role`,I(l)?`dialog`:void 0),W(t,`aria-modal`,I(l)?`true`:void 0),i=Hi(t,``,i,{"--conversation-panel-width":I(o)+`px`}),W(a,`aria-valuemin`,I(s)),W(a,`aria-valuemax`,I(c)),W(a,`aria-valuenow`,I(o)),W(m,`aria-label`,n.conversationFollowLatest?`Following the latest interaction`:`Viewing a historical interaction`),W(m,`title`,n.conversationFollowLatest?`Following the latest interaction as new events arrive`:`Viewing a historical interaction; live updates are not followed`),b=U(h,1,`live-dot`,null,b,{"is-streaming":n.conversationFollowLatest}),W(S,`aria-label`,I(l)?`Exit fullscreen interactions`:`Show interactions fullscreen`),W(S,`title`,I(l)?`Exit fullscreen`:`Fullscreen`),W(S,`aria-pressed`,I(l))}),L(`pointerdown`,a,g),L(`pointermove`,a,_),L(`pointerup`,a,v),Vr(`pointercancel`,a,v),Vr(`lostpointercapture`,a,v),L(`keydown`,a,y),L(`click`,S,()=>A(l,!I(l))),z(e,t)};V(S,e=>{n.conversationOpen&&e(C)}),z(e,x),D()}Hr([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`click`]);var YH=R(`
                    `,1);function XH(e,t){E(t,!0);let n={overview:_C,usage:fT,budgets:HE,"rate-limits":$D,models:Fj,workflows:nP,"audit-logs":qL,guardrails:BR,"mcp-servers":bz,"providers-config":OB,"auth-keys":SV,settings:TH};ds.init(),Mc.init(),K.init(),ka.init(),Aa.init(),Jo.init(),An(()=>{K.refreshTick,Ss.fetch(),Nc.fetchModels(),Nc.fetchCategories()}),An(()=>{document.body.classList.toggle(`dashboard-modal-open`,ja.anyOpen)});let r=O(()=>n[Jo.page]||_C);var i=YH(),a=N(i);Ds(a,{});var o=P(a,2);let s;var c=M(o);rc(c,{}),_i(P(c,2),()=>I(r),(e,t)=>{t(e,{})}),T(o);var l=P(o,2);JH(l,{});var u=P(l,2);Is(u,{});var d=P(u,2);Hs(d,{}),tc(P(d,2),{}),F(()=>s=U(o,1,`content`,null,s,{"interactions-open":rL.conversationOpen})),z(e,i),D()}ti(XH,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/admin/dashboard/static/dist/index.html b/internal/admin/dashboard/static/dist/index.html index fa5030518..0ad1a05e9 100644 --- a/internal/admin/dashboard/static/dist/index.html +++ b/internal/admin/dashboard/static/dist/index.html @@ -7,7 +7,7 @@ GoModel Dashboard - + diff --git a/web/dashboard/src/pages/audit-logs/conversation-helpers.js b/web/dashboard/src/pages/audit-logs/conversation-helpers.js index 1cf878f5a..2ea228d57 100644 --- a/web/dashboard/src/pages/audit-logs/conversation-helpers.js +++ b/web/dashboard/src/pages/audit-logs/conversation-helpers.js @@ -836,7 +836,7 @@ function extractToolCallsList(toolCalls) { return { name: fn.name || tc.name || '', arguments: args, - id: tc.id || tc.call_id || '' + id: tc.call_id || tc.id || '' }; }).filter(Boolean); } @@ -856,6 +856,13 @@ function extractContentToolResults(content) { })); } +function registerCallIds(map, item, name) { + if (!item || !name) return; + [item.call_id, item.id].forEach((id) => { + if (id) map[id] = name; + }); +} + function collectCallIds(map, requestBody, responseBody) { if (requestBody && Array.isArray(requestBody.messages)) { requestBody.messages.forEach((m) => { @@ -866,19 +873,18 @@ function collectCallIds(map, requestBody, responseBody) { ]; toolCalls.forEach((tc) => { if (!tc) return; - const id = tc.id || tc.call_id || ''; const fn = tc.function || tc; const name = fn.name || tc.name || ''; - if (id && name) map[id] = name; + registerCallIds(map, tc, name); }); }); } if (requestBody && Array.isArray(requestBody.input)) { requestBody.input.forEach((item) => { - if (!item || typeof item !== 'object' || item.type !== 'function_call') return; - const id = item.id || item.call_id || ''; + if (!item || typeof item !== 'object' || + (item.type !== 'function_call' && item.type !== 'tool_use')) return; const name = item.name || ''; - if (id && name) map[id] = name; + registerCallIds(map, item, name); }); } if (responseBody && Array.isArray(responseBody.choices)) { @@ -886,27 +892,24 @@ function collectCallIds(map, requestBody, responseBody) { if (first && first.message && Array.isArray(first.message.tool_calls)) { first.message.tool_calls.forEach((tc) => { if (!tc) return; - const id = tc.id || ''; const fn = tc.function || tc; const name = fn.name || tc.name || ''; - if (id && name) map[id] = name; + registerCallIds(map, tc, name); }); } } if (responseBody && Array.isArray(responseBody.output)) { responseBody.output.forEach((item) => { - if (!item || item.type !== 'function_call') return; - const id = item.id || item.call_id || ''; + if (!item || (item.type !== 'function_call' && item.type !== 'tool_use')) return; const name = item.name || ''; - if (id && name) map[id] = name; + registerCallIds(map, item, name); }); } if (responseBody && Array.isArray(responseBody.content)) { responseBody.content.forEach((item) => { if (!item || item.type !== 'tool_use') return; - const id = item.id || item.call_id || ''; const name = item.name || ''; - if (id && name) map[id] = name; + registerCallIds(map, item, name); }); } } diff --git a/web/dashboard/tests/conversation-drawer.test.js b/web/dashboard/tests/conversation-drawer.test.js index 4a641a1aa..e716126ef 100644 --- a/web/dashboard/tests/conversation-drawer.test.js +++ b/web/dashboard/tests/conversation-drawer.test.js @@ -136,7 +136,7 @@ test("responses-API threads shape input items, function calls and outputs", () = instructions: "Be terse.", input: [ { role: "user", content: "Ping" }, - { type: "function_call", call_id: "call-9", name: "lookup", arguments: '{"q":"x"}' }, + { type: "function_call", id: "fc-9", call_id: "call-9", name: "lookup", arguments: '{"q":"x"}' }, { type: "function_call_output", call_id: "call-9", output: "42" }, ], }, @@ -159,7 +159,9 @@ test("responses-API threads shape input items, function calls and outputs", () = "function_call", ]); assert.equal(messages[0].text, "Be terse."); + assert.equal(messages[2].toolCalls[0].id, "call-9"); assert.equal(messages[3].functionName, "lookup"); + assert.equal(messages[3].functionCallID, "call-9"); assert.equal(messages[3].text, "42"); assert.equal(messages[4].text, "Pong"); assert.ok(messages.every((m) => m.isAnchor === false)); From da16d3de8f346373b84633802d4f5bc7c3bd9345 Mon Sep 17 00:00:00 2001 From: "Jakub A. W" Date: Fri, 7 Aug 2026 11:18:00 +0200 Subject: [PATCH 06/19] feat(dashboard): animate interactions drawer --- .../static/dist/assets/index-BaVMEB1g.js | 67 +++++++++++++++++++ ...{index-B9uQpjJg.css => index-CRFx_SAS.css} | 2 +- .../static/dist/assets/index-ayXqZ3cf.js | 67 ------------------- .../admin/dashboard/static/dist/index.html | 4 +- .../src/pages/audit-logs/AuditEntryRow.svelte | 1 + .../pages/audit-logs/AuditEntrySummary.svelte | 1 + .../audit-logs/ConversationDrawer.svelte | 5 ++ 7 files changed, 77 insertions(+), 70 deletions(-) create mode 100644 internal/admin/dashboard/static/dist/assets/index-BaVMEB1g.js rename internal/admin/dashboard/static/dist/assets/{index-B9uQpjJg.css => index-CRFx_SAS.css} (78%) delete mode 100644 internal/admin/dashboard/static/dist/assets/index-ayXqZ3cf.js diff --git a/internal/admin/dashboard/static/dist/assets/index-BaVMEB1g.js b/internal/admin/dashboard/static/dist/assets/index-BaVMEB1g.js new file mode 100644 index 000000000..5f9034cda --- /dev/null +++ b/internal/admin/dashboard/static/dist/assets/index-BaVMEB1g.js @@ -0,0 +1,67 @@ +(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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`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){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function h(e,t,n=!1){return e===void 0?n?t():t:e}function g(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 _=1<<24,v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,ee=65536,te=1<<19,ne=1<<20,re=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(`legacy props`),ue=Symbol(``),de=Symbol(`attributes`),fe=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),he=Symbol(`form reset`),ge=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},_e=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(`uninitialized`),je=`http://www.w3.org/1999/xhtml`,Me=`http://www.w3.org/2000/svg`,Ne=`http://www.w3.org/1998/Math/MathML`;function Pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Fe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ie(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Le(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Re=!1;function ze(e){Re=e}var Be;function Ve(e){if(e===null)throw Fe(),ke;return Be=e}function He(){return Ve(bn(Be))}function T(e){if(Re){if(bn(Be)!==null)throw Fe(),ke;Be=e}}function Ue(e=1){if(Re){for(var t=e,n=Be;t--;)n=bn(n);Be=n}}function We(e=!0){for(var t=0,n=Be;;){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=bn(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Fe(),ke;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=null;function Xe(e){Ye=e}function E(e,t=!1,n){Ye={p:Ye,i:!1,c:null,e:null,s:e,x:null,r:ir,l:null}}function D(e){var t=Ye,n=t.e;if(n!==null){t.e=null;for(var r of n)jn(r)}return e!==void 0&&(t.x=e),t.i=!0,Ye=t.p,e??{}}function Ze(){return!0}var Qe=[];function $e(){var e=Qe;Qe=[],p(e)}function et(e){if(Qe.length===0&&!zt){var t=Qe;queueMicrotask(()=>{t===Qe&&$e()})}Qe.push(e)}function tt(){for(;Qe.length>0;)$e()}function nt(e){var t=ir;if(t===null)return tr.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;rt(e,t)}function rt(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var it=~(y|b|v);function at(e,t){e.f=e.f&it|t}function ot(e){e.f&512||e.deps===null?at(e,v):at(e,b)}function st(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,st(t.deps))}function ct(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),st(e.deps),at(e,v)}var lt=!1;function ut(e){var t=lt;try{return lt=!1,[e(),lt]}finally{lt=t}}function dt(e,t){if(t){let t=document.body;e.autofocus=!0,et(()=>{document.activeElement===t&&e.focus()})}}function ft(e){Re&&yn(e)!==null&&xn(e)}var pt=!1;function mt(){pt||(pt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[he]?.()})},{capture:!0}))}function ht(e){var t=tr,n=ir;rr(null),ar(null);try{return e()}finally{rr(t),ar(n)}}function gt(e,t,n,r=n){e.addEventListener(t,()=>ht(n));let i=e[he];i?e[he]=()=>{i(),r(!0)}:e[he]=()=>r(!0),mt()}function _t(e){let t=0,n=an(0),r;return()=>{On()&&(I(n),In(()=>(t===0&&(r=Er(()=>e(()=>ln(n)))),t+=1,()=>{et(()=>{--t,t===0&&(r?.(),r=void 0,ln(n))})})))}}var vt=ee|te;function yt(e,t,n,r){new bt(e,t,n,r)}var bt=class{parent;is_pending=!1;transform_error;#e;#t=Re?Be: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=_t(()=>(this.#m=an(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=ir;t.b=this,t.f|=128,n(e)},this.parent=ir.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Ln(()=>{if(Re){let e=this.#t;He();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},vt),Re&&(this.#e=Be)}#g(){try{this.#a=zn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=zn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=zn(()=>e(this.#e)),et(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>zn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Kn(this.#o,()=>{this.#o=null}),this.#b(Ft))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=zn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Xn(this.#a,e);let t=this.#n.pending;this.#o=zn(()=>t(this.#e))}else this.#b(Ft)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){ct(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=ir,n=tr,r=Ye;ar(this.#i),rr(this.#i),Xe(this.#i.ctx);try{return Gt.ensure(),e()}catch(e){return nt(e),null}finally{ar(t),rr(n),Xe(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Kn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,et(()=>{this.#d=!1,this.#m&&sn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),I(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Ft?.is_fork?(this.#a&&Ft.skip_effect(this.#a),this.#o&&Ft.skip_effect(this.#o),this.#s&&Ft.skip_effect(this.#s),Ft.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Un(this.#a),null),this.#o&&=(Un(this.#o),null),this.#s&&=(Un(this.#s),null),Re&&(Ve(this.#t),Ue(),Ve(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Le();return}r=!0,i&&Oe(),this.#s!==null&&Kn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){rt(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return zn(()=>{var t=ir;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return rt(e,this.#i.parent),null}}))};et(()=>{var t;try{t=this.transform_error(e)}catch(e){rt(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>rt(e,this.#i&&this.#i.parent)):o(t)})}};function xt(e,t,n,r){let i=Ze()?Tt:Ot;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=ir,c=St(),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){rt(e,s)}Ct()}}var d=wt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Dt(e))).then(u).catch(e=>rt(e,s)).finally(d)}l?l.then(()=>{c(),f(),Ct()}):f()}function St(){var e=ir,t=tr,n=Ye,r=Ft;return function(i=!0){ar(e),rr(t),Xe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ct(e=!0){ar(null),rr(null),Xe(null),e&&Ft?.deactivate()}function wt(){var e=ir,t=e.b,n=Ft,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 Tt(e){var t=2|y;return ir!==null&&(ir.f|=te),{ctx:Ye,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:ir,ac:null}}var Et=Symbol(`obsolete`);function Dt(e,t,n){let r=ir;r===null&&ve();var i=void 0,a=an(Ae),o=!tr,s=new Set;return Fn(()=>{var t=ir,n=m();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ge&&n.reject(e)}).finally(Ct)}catch(e){n.reject(e),Ct()}var c=Ft;if(o){if(t.f&32768)var l=wt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Et);else for(let e of s.values())e.reject(Et);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Et&&(c.activate(),t?(a.f|=se,sn(a,t)):(a.f&8388608&&(a.f^=se),sn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),kn(()=>{for(let e of s)e.reject(Et)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function O(e){let t=Tt(e);return sr(t),t}function Ot(e){let t=Tt(e);return t.equals=Je,t}function kt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(ge),t.ac=null}),t.fn!==null&&(t.teardown=f),xr(t,0),Vn(t))}function Nt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Sr(t)}var Pt=null,Ft=null,It=null,Lt=null,Rt=null,zt=!1,Bt=!1,Vt=null,Ht=null,Ut=0,Wt=1,Gt=class e{id=Wt++;#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(){Pt===null?Pt=this:(Pt.#n=this,this.#t=Pt),Pt=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)at(r,y),t(r);for(r of n.m)at(r,b),t(r)}this.#p.add(e)}#g(){this.#e=!0,Ut++>1e3&&(this.#x(),qt());for(let e of this.#u)this.#d.delete(e),at(e,y),this.schedule(e);for(let e of this.#d)at(e,b),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Vt=[],r=[],i=Ht=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw en(e),this.#h()||this.discard(),t}if(Ft=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Vt=null,Ht=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)$t(e,t);i.length>0&&Ft.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),It=this,Yt(r),Yt(n),It=null,this.#s?.resolve();var s=Ft;if(this.#a===0&&(this.#c.length===0||s!==null)&&this.#x(),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):_r(r)&&(i&16&&this.#d.add(r),Sr(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}}}#v(){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}#y(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),at(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#x(),Ft=this,this.#g()}#b(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??=m()).promise}static ensure(){if(Ft===null){let t=Ft=new e;!Bt&&!zt&&et(()=>{t.#e||t.flush()})}return Ft}apply(){Lt=null}schedule(e){if(Rt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Vt!==null&&t===ir&&(tr===null||!(tr.f&2)))return;if(n&96){if(!(n&1024))return;t.f^=v}}this.#c.push(t)}#x(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?Pt=e:t.#t=e,this.linked=!1}}};function Kt(e){var t=zt;zt=!0;try{var n;for(e&&(Ft!==null&&!Ft.is_fork&&Ft.flush(),n=e());;){if(tt(),Ft===null)return n;Ft.flush()}}finally{zt=t}}function qt(){try{Ce()}catch(e){rt(e,Rt)}}var Jt=null;function Yt(e){var t=e.length;if(t!==0){for(var n=0;n0)){nn.clear();for(let e of Jt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Jt.has(n)&&(Jt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sr(n)}}Jt.clear()}}Jt=null}}function Xt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Xt(i,t,n,r):e&4194320&&!(e&2048)&&Zt(i,t,r)&&(at(i,y),Qt(i))}}function Zt(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(e.deps!==null)for(let i of e.deps){if(n.call(t,i))return!0;if(i.f&2&&Zt(i,t,r))return r.set(i,!0),!0}return r.set(e,!1),!1}function Qt(e){Ft.schedule(e)}function $t(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),at(e,v);for(var n=e.first;n!==null;)$t(n,t),n=n.next}}function en(e){at(e,v);for(var t=e.first;t!==null;)en(t),t=t.next}var tn=new Set,nn=new Map,rn=!1;function an(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function k(e,t){let n=an(e,t);return sr(n),n}function on(e,t=!1,n=!0){let r=an(e);return t||(r.equals=Je),r}function A(e,t,n=!1){return tr!==null&&(!nr||tr.f&131072)&&Ze()&&tr.f&4325394&&(or===null||!or.has(e))&&De(),sn(e,n?j(t):t,Ht)}function sn(e,t,n=null){if(!e.equals(t)){nn.set(e,$n?t:e.v);var r=Gt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&At(t),Lt===null&&ot(t)}e.wv=gr(),un(e,y,n),Ze()&&ir!==null&&ir.f&1024&&!(ir.f&96)&&(ur===null?dr([e]):ur.push(e)),!r.is_fork&&tn.size>0&&!rn&&cn()}return t}function cn(){rn=!1;for(let e of tn){e.f&1024&&at(e,b);let t;try{t=_r(e)}catch{t=!0}t&&Sr(e)}tn.clear()}function ln(e){A(e,e.v+1)}function un(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ze(),a=r.length,o=0;o{if(mr===d)return e();var t=tr,n=mr;rr(null),hr(d);var r=e();return rr(t),hr(n),r};return i&&r.set(`length`,k(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Te();var i=r.get(t);return i===void 0?f(()=>{var e=k(n.value,u);return r.set(t,e),e}):A(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>k(Ae,u));r.set(t,e),ln(o)}}else A(n,Ae),ln(o);return!0},get(e,n,i){if(n===ce)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>k(j(s?e[n]:Ae),u)),r.set(n,o)),o!==void 0){var c=I(o);return c===Ae?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=I(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===ce)return!0;var n=r.get(t),i=n!==void 0&&n.v!==Ae||Reflect.has(e,t);return(n!==void 0||ir!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>k(i?j(e[t]):Ae,u)),r.set(t,n)),I(n)===Ae)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dk(Ae,u)),r.set(d+``,p)):A(p,Ae)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>k(void 0,u)),A(c,j(n)),r.set(t,c));else{l=c.v!==Ae;var m=f(()=>j(n));A(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&&A(g,_+1)}ln(o)}return!0},ownKeys(e){I(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==Ae});for(var[n,i]of r)i.v!==Ae&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ee()}})}function dn(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=a(t,`firstChild`).get,gn=a(t,`nextSibling`).get,u(e)&&(e[fe]=void 0,e[de]=null,e[pe]=void 0,e.__e=void 0),u(n)&&(n[me]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function M(e,t){if(!Re)return yn(e);var n=yn(Be);if(n===null)n=Be.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),Ve(r),r}return t&&wn(n),Ve(n),n}function N(e,t=!1){if(!Re){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Be?.nodeType!==3){var r=vn();return Be?.before(r),Ve(r),r}wn(Be)}return Be}function P(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=bn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),Ve(a),a}wn(r)}return Ve(r),r}function xn(e){e.textContent=``}function Sn(){return!1}function Cn(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 wn(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 Tn(e){ir===null&&(tr===null&&Se(e),xe()),$n&&be(e)}function En(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Dn(e,t){var n=ir;n!==null&&n.f&8192&&(e|=x);var r={ctx:Ye,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};Ft?.register_created_effect(r);var i=r;if(e&4)Vt===null?Gt.ensure().schedule(r):Vt.push(r);else if(t!==null){try{Sr(r)}catch(e){throw Un(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|=ee))}if(i!==null&&(i.parent=n,n!==null&&En(i,n),tr!==null&&tr.f&2&&!(e&64))){var a=tr;(a.effects??=[]).push(i)}return r}function On(){return tr!==null&&!nr}function kn(e){let t=Dn(8,null);return at(t,v),t.teardown=e,t}function An(e){Tn(`$effect`);var t=ir.f;if(!tr&&t&32&&Ye!==null&&!Ye.i){var n=Ye;(n.e??=[]).push(e)}else return jn(e)}function jn(e){return Dn(4|ne,e)}function Mn(e){Gt.ensure();let t=Dn(64|te,e);return()=>{Un(t)}}function Nn(e){Gt.ensure();let t=Dn(64|te,e);return(e={})=>new Promise(n=>{e.outro?Kn(t,()=>{Un(t),n(void 0)}):(Un(t),n(void 0))})}function Pn(e){return Dn(4,e)}function Fn(e){return Dn(oe|te,e)}function In(e,t=0){return Dn(8|t,e)}function F(e,t=[],n=[],r=[]){xt(r,t,n,t=>{Dn(8,()=>{e(...t.map(I))})})}function Ln(e,t=0){return Dn(16|t,e)}function Rn(e,t=0){return Dn(_|t,e)}function zn(e){return Dn(32|te,e)}function Bn(e){var t=e.teardown;if(t!==null){let e=$n,n=tr;er(!0),rr(null);try{t.call(null)}finally{er(e),rr(n)}}}function Vn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ht(()=>{e.abort(ge)});var r=n.next;n.f&64?n.parent=null:Un(n,t),n=r}}function Hn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Un(t),t=n}}function Un(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Wn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,Vn(e,t&&!n),xr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Bn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Gn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Wn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Gn(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 Kn(e,t,n=!0){var r=[];qn(e,r,!0);var i=()=>{n&&Un(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function qn(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)!=0||(i.f&32)!=0&&(e.f&16)!=0;qn(i,t,o?n:!1)}i=a}}}function Jn(e){Yn(e,!0)}function Yn(e,t){if(e.f&8192){e.f^=x,e.f&1024||(at(e,y),Gt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Yn(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 Xn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var Zn=null,Qn=!1,$n=!1;function er(e){$n=e}var tr=null,nr=!1;function rr(e){tr=e}var ir=null;function ar(e){ir=e}var or=null;function sr(e){tr!==null&&(or??=new Set).add(e)}var cr=null,lr=0,ur=null;function dr(e){ur=e}var fr=1,pr=0,mr=pr;function hr(e){mr=e}function gr(){return++fr}function _r(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Lt===null&&at(e,v)}return!1}function vr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(or!==null&&or.has(e)))for(var i=0;i{e.ac.abort(ge)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=C;var f=e.deps,p=Ft?.is_fork;if(cr!==null){var m;if(p||xr(e,lr),f!==null&&lr>0)for(f.length=lr+cr.length,m=0;m{s.ac.abort(ge),s.ac=null,at(s,y)}),Mt(s),xr(s,0)}}function xr(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`?et(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Vr(e,t,n,r,i){var a={capture:r,passive:i},o=Br(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&kn(()=>{t.removeEventListener(e,o,a)})}function L(e,t,n){(t[Lr]??={})[e]=n}function Hr(e){for(var t=0;t{throw e});throw p}}finally{e[Lr]=t,delete e.currentTarget,rr(d),ar(f)}}}var Gr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Kr(e){return Gr?.createHTML(e)??e}function qr(e){var t=Cn(`template`);return t.innerHTML=Kr(e.replaceAll(``,``)),t.content}function Jr(e,t){var n=ir;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function R(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Re)return Jr(Be,null),Be;i===void 0&&(i=qr(a?e:``+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;Jr(o,s)}else Jr(t,t);return t}}function Yr(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}`,o;return()=>{if(Re)return Jr(Be,null),Be;if(!o){var e=yn(qr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;Jr(n,r)}else Jr(t,t);return t}}function Xr(e,t){return Yr(e,t,`svg`)}function Zr(e=``){if(!Re){var t=vn(e+``);return Jr(t,t),t}var n=Be;return n.nodeType===3?wn(n):(n.before(n=vn()),Ve(n)),Jr(n,n),n}function Qr(){if(Re)return Jr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),Jr(t,n),e}function z(e,t){if(Re){var n=ir;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Be),He();return}e!==null&&e.before(t)}var $r=!0;function ei(e){$r=e}function B(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function ti(e,t){return ri(e,t)}var ni=new Map;function ri(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=Nn(()=>{var u=n??t.appendChild(vn());yt(u,{pending:()=>{}},t=>{E({});var n=Ye;if(o&&(n.c=o),a&&(i.$$events=a),Re&&Jr(t,null),$r=s,l=e(t,i)||{},$r=!0,Re&&(ir.nodes.end=Be,Be===null||Be.nodeType!==8||Be.data!==`]`))throw Fe(),ke;D()},c);var d=new Set,f=e=>{for(var n=0;n{for(var e of d)for(let n of[t,document]){var r=ni.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Wr),r.delete(e),r.size===0&&ni.delete(n)):r.set(e,i)}zr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ii.set(l,u),l}var ii=new WeakMap,ai=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)Jn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Jn(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&&(Un(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();Xn(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else Un(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Kn(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)||(Un(n.effect),this.#n.delete(e))};ensure(e,t){var n=Ft,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:zn(()=>t(a)),fragment:i})}else this.#t.set(e,zn(()=>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 Re&&(this.anchor=Be),this.#a(n)}};function V(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ai(e),a=n?ee:0;function o(e,t){if(Re){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}Ln(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var oi=Symbol(`NaN`);function si(e,t,n){Re&&He();var r=new ai(e),i=!Ze();Ln(()=>{var e=t();e!==e&&(e=oi),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function ci(e,t){return t}function li(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;ui(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;if(l){var u=n,d=u.parentNode;xn(d),d.append(u),e.items.clear()}ui(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function ui(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,pi(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=re,hi(d,null,c)):Jn(d):Kn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Ln(()=>{p=I(f);var e=p.length;let t=!1;Re&&Ge(c)===`[!`!=(e===0)&&(c=We(),Ve(c),ze(!1),t=!0);for(var r=new Set,u=Ft,v=Sn(),y=0;ys(c)):(d=zn(()=>s(di??=vn())),d.f|=re)),e>r.size&&ye(``,``,``),Re&&e>0&&Ve(We()),!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&&ze(!0),I(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Re&&(c=Be)}function fi(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function pi(e,t,n,i,a){var o=(i&8)!=0,s=t.length,c=e.items,l=fi(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var te=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function mi(e,t,n,r,i,a,o,s){var c=o&1?o&16?an(n):on(n,!1,!1):null,l=o&2?an(i):null;return{v:c,i:l,e:zn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function hi(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=bn(r);if(a.before(r),r===i)return;r=o}}function gi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function _i(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Re&&(o=Ve(yn(c)))}F(()=>{var e=ir;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&Jr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Wn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Re){for(var a=Be.data,l=He(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Fe(),ke;Jr(Be,u),o=Ve(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Jr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function vi(e,t,...n){var r=new ai(e);Ln(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},ee)}function yi(e,t,n){var r;Re&&(r=Be,He());var i=new ai(e);Ln(()=>{var e=t()??null;if(Re&&Ge(r)===`[`!=(e!==null)){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,e&&(t=>n(t,e))),ze(!0);return}i.ensure(e,e&&(t=>n(t,e)))},ee)}var bi=()=>performance.now(),xi={tick:e=>requestAnimationFrame(e),now:()=>bi(),tasks:new Set};function Si(){let e=xi.now();xi.tasks.forEach(t=>{t.c(e)||(xi.tasks.delete(t),t.f())}),xi.tasks.size!==0&&xi.tick(Si)}function Ci(e){let t;return xi.tasks.size===0&&xi.tick(Si),{promise:new Promise(n=>{xi.tasks.add(t={c:e,f:n})}),abort(){xi.tasks.delete(t)}}}function wi(e,t){ht(()=>{e.dispatchEvent(new CustomEvent(t))})}function Ti(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function Ei(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Ti(n.trim());t[i]=r.trim()}return t}var Di=e=>e,Oi=null;function ki(e){Oi=e}function Ai(e,t,n){var r=(Oi??ir).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Mi(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function ji(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return ht(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Mi(t,m(),p,1,()=>{wi(t,`introstart`)},()=>{wi(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Mi(t,m(),f,0,()=>{wi(t,`outrostart`)},()=>{wi(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=ir;if((g.nodes.t??=[]).push(h),i&&$r){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Pn(()=>{Er(()=>h.in())})}}function Mi(e,t,n,r,i,a){var o=r===1;if(d(t)){var s,c=!1;return et(()=>{c||(s=Mi(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:f,deactivate:f,reset:f,t:()=>r};let{delay:l=0,css:u,tick:p,easing:m=Di}=t;var h=[];if(o&&n===void 0&&(p&&p(0,1),u)){var g=Ei(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var d=!1;if(u)for(var f=Math.ceil(c/(1e3/60)),h=0;h<=f;h+=1){var g=o+s*m(h/f),y=Ei(u(g,1-g));l.push(y),d||=y.overflow===`hidden`}d&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*m(e/c)},p&&Ci(()=>{if(v.playState!==`running`)return!1;var e=_();return p(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,p?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=f)},deactivate:()=>{a=f},reset:()=>{r===0&&p?.(1,0)},t:()=>_()}}function Ni(e,t,n,r,i,a){let o=Re;Re&&He();var s=null;Re&&Be.nodeType===1&&(s=Be,He());var c=Re?Be:e,l=ir,u=new ai(c,!1);Ln(()=>{let e=t()||null;var a=i?i():n||e===`svg`?Me:void 0;if(e===null){u.ensure(null,null),ei(!0);return}return u.ensure(e,t=>{if(e){if(s=Re?s:Cn(e,a),Jr(s,s),r){var n=null;Re&&Ir(e)&&s.append(n=document.createComment(``));var i=Re?yn(s):s.appendChild(vn());Re&&(i===null?ze(!1):Ve(i)),ki(l),r(s,i),n?.remove(),ki(null)}ir.nodes.end=s,t.before(s)}Re&&Ve(t)}),ei(!0),()=>{e&&ei(!1)}},ee),kn(()=>{ei(!0)}),o&&(ze(!0),Ve(c))}function Pi(e,t){var n=void 0,r;Rn(()=>{n!==(n=t())&&(r&&=(Un(r),null),n&&(r=zn(()=>{Pn(()=>n(e))})))})}function Fi(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=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 Bi(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 Vi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Hi(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(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(Vi)),i&&c.push(...Object.keys(i).map(Vi));var l=0,u=-1;let t=e.length;for(var d=0;d{Gi(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),kn(()=>{t.disconnect()})}function qi(e,t,n=t){var r=new WeakSet,i=!0;gt(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ji);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ji(o)}n(a),e.__value=a,Ft!==null&&r.add(Ft)}),Pn(()=>{var a=t();if(e===document.activeElement){var o=Ft;if(r.has(o))return}if(Gi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ji(s),n(a))}e.__value=a,i=!1}),Ki(e)}function Ji(e){return`__value`in e?e.__value:e.value}var Yi=Symbol(`class`),Xi=Symbol(`style`),Zi=Symbol(`is custom element`),Qi=Symbol(`is html`),$i=_e?`link`:`LINK`,ea=_e?`input`:`INPUT`,ta=_e?`option`:`OPTION`,na=_e?`select`:`SELECT`,ra=_e?`progress`:`PROGRESS`;function ia(e){if(Re){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;W(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;W(e,`checked`,null),e.checked=r}}};e[he]=n,et(n),mt()}}function aa(e,t){var n=ua(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==ra)||(e.value=t??``)}function oa(e,t){var n=ua(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function sa(e,t){t?e.hasAttribute(`selected`)||e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}function W(e,t,n,r){var i=ua(e);Re&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===$i)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ue]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&fa(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function ca(e,t,n,r,i=!1,a=!1){if(Re&&i&&e.nodeName===ea){var o=e;(o.type===`checkbox`?`defaultChecked`:`defaultValue`)in n||ia(o)}var s=ua(e),c=s[Zi],l=!s[Qi];let u=Re&&c;u&&ze(!1);var d=t||{},f=e.nodeName===ta;for(var p in t)p in n||(n[p]=null);n.class?n.class=Li(n.class):(r||n[Yi])&&(n.class=null),n[Xi]&&(n.style??=null);var m=fa(e);if(e.nodeName===ea&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==d.type||h===void 0&&e.hasAttribute(`type`))&&(d.type=h,W(e,`type`,h,a))}for(let i in n){let o=n[i];if(f&&i===`value`&&o==null){e.value=e.__value=``,d[i]=o;continue}if(i===`class`){U(e,e.namespaceURI===`http://www.w3.org/1999/xhtml`,o,r,t?.[Yi],n[Yi]),d[i]=o,d[Yi]=n[Yi];continue}if(i===`style`){Wi(e,o,t?.[Xi],n[Xi]),d[i]=o,d[Xi]=n[Xi];continue}var g=d[i];if(!(o===g&&!(o===void 0&&e.hasAttribute(i)))){d[i]=o;var _=i[0]+i[1];if(_!==`$$`)if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=kr(r);if(Dr(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(o!=null)continue;e.removeEventListener(r,d[n],t),d[n]=null}if(v)L(r,e,o),Hr([r]);else if(o!=null){function a(e){d[i].call(this,e)}d[n]=Br(r,e,a,t)}}else if(i===`style`)W(e,i,o);else if(i===`autofocus`)dt(e,!!o);else if(!c&&(i===`__value`||i===`value`&&o!=null))e.value=e.__value=o;else if(i===`selected`&&f)sa(e,o);else{var y=i;l||(y=Mr(y));var b=y===`defaultValue`||y===`defaultChecked`;if(o==null&&!c&&!b)if(s[i]=null,y===`value`||y===`checked`){let n=e,r=t===void 0;if(y===`value`){let e=n.defaultValue;n.removeAttribute(y),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(y),n.defaultChecked=e,n.checked=r?e:!1}}else e.removeAttribute(i);else b||m.includes(y)&&(c||typeof o!=`string`)?(e[y]=o,y in s&&(s[y]=Ae)):typeof o!=`function`&&W(e,y,o,a)}}}return u&&ze(!0),d}function la(e,t,n=[],r=[],i=[],a,o=!1,s=!1){xt(i,n,r,n=>{var r=void 0,i={},c=e.nodeName===na,l=!1;if(Rn(()=>{var u=t(...n.map(I)),d=ca(e,r,u,a,o,s);l&&c&&`value`in u&&Gi(e,u.value);for(let e of Object.getOwnPropertySymbols(i))u[e]||Un(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var f=u[t];t.description===`@attach`&&(!r||f!==r[t])&&(i[t]&&Un(i[t]),i[t]=zn(()=>Pi(e,()=>f))),d[t]=f}r=d}),c){var u=e;Pn(()=>{Gi(u,r.value,!0),Ki(u)})}l=!0})}function ua(e){return e[de]??={[Zi]:e.nodeName.includes(`-`),[Qi]:e.namespaceURI===je}}var da=new Map;function fa(e){var t=e.getAttribute(`is`)||e.nodeName,n=da.get(t);if(n)return n;da.set(t,n=[]);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.push(s);i=l(i)}return n}function pa(e,t,n=t){var r=new WeakSet;gt(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ha(e)?ga(a):a,n(a),Ft!==null&&r.add(Ft),await Cr(),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))}}}),(Re&&e.defaultValue!==e.value||Er(t)==null&&e.value)&&(n(ha(e)?ga(e.value):e.value),Ft!==null&&r.add(Ft)),In(()=>{var n=t();if(e===document.activeElement){var i=Ft;if(r.has(i))return}ha(e)&&n===ga(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function ma(e,t,n=t){gt(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Re&&e.defaultChecked!==e.checked||Er(t)==null)&&n(e.checked),In(()=>{e.checked=!!t()})}function ha(e){var t=e.type;return t===`number`||t===`range`}function ga(e){return e===``?null:+e}function _a(e,t){return e===t||e?.[ce]===t}function va(e={},t,n,r){var i=Ye.r,a=ir;return Pn(()=>{var o,s;return In(()=>{o=s,s=r?.()||[],Er(()=>{_a(n(...s),e)||(t(e,...s),o&&_a(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&&_a(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var ya={get(e,t){if(!e.exclude.has(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return!e.exclude.has(t)&&t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))}};function ba(e,t,n){return new Proxy({props:e,exclude:t},ya)}function G(e,t,n,r){var i=!0,o=(n&8)!=0,s=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>s&&i?(u??=Tt(r),I(u)):(l&&(l=!1,c=s?Er(r):r),c);let f;if(o){var p=ce in e||le in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=ut(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&we(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?Tt:Ot)(()=>(v=!1,g()));o&&I(y);var b=ir;return(function(e,t){if(arguments.length>0){let n=t?I(y):i&&o?j(e):e;return A(y,n),v=!0,c!==void 0&&(c=n),e}return $n&&v||b.f&16384?y.v:I(y)})}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var xa=new Set([`$$slots`,`$$events`,`$$legacy`,`icon`,`class`]),Sa=Xr(``);function K(e,t){let n=G(t,`icon`,19,()=>[]),r=G(t,`class`,3,``),i=ba(t,xa);var a=Sa();la(a,()=>({xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:r(),"aria-hidden":`true`,focusable:`false`,...i}));{let e=(t,n=f)=>{var r=Qr();H(N(r),17,n,ci,(t,n)=>{var r=O(()=>g(I(n),3));let i=()=>I(r)[0],a=()=>I(r)[1],o=()=>I(r)[2];var s=Qr();Ni(N(s),i,!0,(t,n)=>{la(t,()=>({xmlns:`http://www.w3.org/2000/svg`,...a()}));var r=Qr(),i=N(r),s=t=>{e(t,o)},c=O(()=>Array.isArray(o()));V(i,e=>{I(c)&&e(s)}),z(n,r)}),z(t,s)}),z(t,r)};e(M(a),n),T(a)}z(e,a)}var Ca=Xr(``);function wa(e){z(e,Ca())}function Ta(){try{return typeof localStorage>`u`?null:localStorage}catch{return null}}function Ea(e,t=null){let n=Ta();if(!n)return t;try{return n.getItem(e)??t}catch{return t}}function Da(e,t){let n=Ta();if(n)try{n.setItem(e,String(t))}catch{}}function Oa(e){let t=Number(e);return Number.isFinite(t)?Math.min(240,Math.max(60,Math.round(t))):240}function ka(e,t,n){return Oa(Number(e)+Number(n)-Number(t))}var Aa=new class{#e=k(`system`);get theme(){return I(this.#e)}set theme(e){A(this.#e,e,!0)}#t=k(0);get tick(){return I(this.#t)}set tick(e){A(this.#t,e,!0)}init(){this.theme=Ea(`gomodel_theme`,`system`),this.apply(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{this.theme===`system`&&this.tick++})}set(e){this.theme=e,Da(`gomodel_theme`,e),this.apply(),this.tick++}toggle(){let e=[`light`,`system`,`dark`];this.set(e[(e.indexOf(this.theme)+1)%e.length])}apply(){let e=document.documentElement;this.theme===`system`?e.removeAttribute(`data-theme`):e.setAttribute(`data-theme`,this.theme)}},ja=new class{#e=k(j(240));get width(){return I(this.#e)}set width(e){A(this.#e,e,!0)}get collapsed(){return this.width===60}init(){let e=Ea(`gomodel_sidebar_width`),t=Ea(`gomodel_sidebar_collapsed`)===`true`;this.setWidth(e??(t?60:240))}toggle(){this.setWidth(this.collapsed?240:60,!0)}setWidth(e,t=!1){this.width=Oa(e),typeof document<`u`&&document.documentElement.style.setProperty(`--sidebar-width`,`${this.width}px`),t&&(Da(`gomodel_sidebar_width`,this.width),Da(`gomodel_sidebar_collapsed`,this.collapsed))}},Ma=new class{#e=k(j([]));get stack(){return I(this.#e)}set stack(e){A(this.#e,e,!0)}#t=1;opened(){let e=this.#t++;return this.stack=[...this.stack,e],e}closed(e){this.stack=this.stack.filter(t=>t!==e)}isTop(e){return this.stack.length>0&&this.stack[this.stack.length-1]===e}get openCount(){return this.stack.length}get anyOpen(){return this.stack.length>0}},Na=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],Pa=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],Fa=[[`path`,{d:`M5 12h14`}],[`path`,{d:`m12 5 7 7-7 7`}]],Ia=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]],La=[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`}],[`path`,{d:`M16 10h.01`}],[`path`,{d:`M12 10h.01`}],[`path`,{d:`M8 10h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M8 18h.01`}]],Ra=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M16 14h.01`}],[`path`,{d:`M8 18h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M16 18h.01`}]],za=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}]],Ba=[[`path`,{d:`M13 17V9`}],[`path`,{d:`M18 17V5`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M8 17v-3`}]],Va=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M18 17V9`}],[`path`,{d:`M13 17V5`}],[`path`,{d:`M8 17v-3`}]],Ha=[[`path`,{d:`M20 6 9 17l-5-5`}]],Ua=[[`path`,{d:`m6 9 6 6 6-6`}]],Wa=[[`path`,{d:`m15 18-6-6 6-6`}]],Ga=[[`path`,{d:`m9 18 6-6-6-6`}]],Ka=[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`}],[`path`,{d:`m9 11 3 3L22 4`}]],qa=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m9 12 2 2 4-4`}]],Ja=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}],[`path`,{d:`M12 18V6`}]],Ya=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],Xa=[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`}]],Za=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`}],[`path`,{d:`M21 5V8`}],[`path`,{d:`M21 12L18 17H22L19 22`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`}]],Qa=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`}]],$a=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],eo=[[`path`,{d:`m12 14 4-4`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`}]],to=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}],[`path`,{d:`M12 7v5l4 2`}]],no=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 16v-4`}],[`path`,{d:`M12 8h.01`}]],ro=[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],io=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],ao=[[`path`,{d:`M3 5h.01`}],[`path`,{d:`M3 12h.01`}],[`path`,{d:`M3 19h.01`}],[`path`,{d:`M8 5h13`}],[`path`,{d:`M8 12h13`}],[`path`,{d:`M8 19h13`}]],oo=[[`circle`,{cx:`12`,cy:`16`,r:`1`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`}]],so=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]],co=[[`path`,{d:`m14 10 7-7`}],[`path`,{d:`M20 10h-6V4`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M4 14h6v6`}]],lo=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],uo=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],fo=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],po=[[`path`,{d:`M12 22v-5`}],[`path`,{d:`M15 8V2`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`}],[`path`,{d:`M9 8V2`}]],mo=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],ho=[[`path`,{d:`M12 2v10`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`}]],go=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],_o=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],vo=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],yo=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],bo=[[`path`,{d:`m10.852 14.772-.383.923`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`}],[`path`,{d:`m13.148 9.228.383-.923`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`}],[`path`,{d:`m14.772 10.852.923-.383`}],[`path`,{d:`m14.772 13.148.923.383`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`}],[`path`,{d:`M6 18h.01`}],[`path`,{d:`M6 6h.01`}],[`path`,{d:`m9.228 10.852-.923-.383`}],[`path`,{d:`m9.228 13.148-.923.383`}]],xo=[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`}]],So=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]],Co=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],wo=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}],[`path`,{d:`m9 12 2 2 4-4`}]],To=[[`path`,{d:`m2 2 20 20`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`}]],Eo=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}]],Do=[[`path`,{d:`m18 14 4 4-4 4`}],[`path`,{d:`m18 2 4 4-4 4`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`}]],Oo=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],ko=[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],Ao=[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`}],[`circle`,{cx:`12`,cy:`14`,r:`8`}]],jo=[[`path`,{d:`M10 11v6`}],[`path`,{d:`M14 11v6`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]],Mo=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]],No=[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}],[`circle`,{cx:`12`,cy:`7`,r:`4`}]],Po=[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`}]],Fo=[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`}],[`path`,{d:`m14 7 3 3`}],[`path`,{d:`M5 6v4`}],[`path`,{d:`M19 14v4`}],[`path`,{d:`M10 2v2`}],[`path`,{d:`M7 8H3`}],[`path`,{d:`M21 16h-4`}],[`path`,{d:`M11 3H9`}]],Io=[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`}]],Lo=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],Ro=R(``),zo=R(`
                    `,1);function Bo(e,t){E(t,!0);let n=G(t,`compact`,3,!1),r=[{value:`light`,icon:Oo,label:`Light theme`},{value:`system`,icon:lo,label:`System theme`},{value:`dark`,icon:uo,label:`Dark theme`}],i=O(()=>r.find(e=>e.value===Aa.theme)||r[1]),a=O(()=>`Change theme (currently `+I(i).label+`)`);var o=zo(),s=N(o);let c;H(s,21,()=>r,e=>e.value,(e,t)=>{var n=Ro();let r;K(M(n),{get icon(){return I(t).icon},class:`theme-icon`}),T(n),F(()=>{r=U(n,1,`theme-btn svelte-1keql7b`,null,r,{active:Aa.theme===I(t).value}),W(n,`aria-pressed`,Aa.theme===I(t).value),W(n,`title`,I(t).label),W(n,`aria-label`,I(t).label)}),L(`click`,n,()=>Aa.set(I(t).value)),z(e,n)}),T(s);var l=P(s,2);let u;K(M(l),{get icon(){return I(i).icon},class:`theme-icon`}),T(l),F(()=>{c=U(s,1,`theme-toggle svelte-1keql7b`,null,c,{"is-compact":n()}),u=U(l,1,`theme-toggle-mobile svelte-1keql7b`,null,u,{"is-compact":n()}),W(l,`title`,I(a)),W(l,`aria-label`,I(a))}),L(`click`,l,()=>Aa.toggle()),z(e,o),D()}Hr([`click`]);function Vo(){return typeof window>`u`?`/`:window.GOMODEL_BASE_PATH||`/`}function Ho(e){let t=Vo();return!e||e.charAt(0)!==`/`||e.indexOf(`//`)===0||t===`/`||e===t||e.indexOf(t+`/`)===0?e:t+e}function Uo(e){let t=Vo();return t===`/`||!e?e:e===t?`/`:e.indexOf(t+`/`)===0?e.slice(t.length)||`/`:e}function Wo(){return typeof window>`u`?``:window.GOMODEL_VERSION||``}function Go(){return typeof window>`u`?!1:window.GOMODEL_DEMO_MODE===!0}var Ko=[`overview`,`usage`,`budgets`,`rate-limits`,`models`,`workflows`,`audit-logs`,`guardrails`,`mcp-servers`,`providers-config`,`auth-keys`,`settings`];function qo(e){return e.startsWith(`/admin/static/`)?`/`+e.slice(14).replace(/^\/+/,``):e}function Jo(e){let t=qo(Uo(e)).replace(/\/$/,``).replace(`/admin/dashboard`,``).replace(/^\//,``).split(`/`),n=t[0];n===`audit`&&(n=`audit-logs`);let r=t[1]||null;return n===`settings`&&r===`guardrails`?{page:`guardrails`,sub:null}:(n=Ko.includes(n)?n:`overview`,{page:n,sub:r})}var Yo=new class{#e=k(`overview`);get page(){return I(this.#e)}set page(e){A(this.#e,e,!0)}#t=k(null);get sub(){return I(this.#t)}set sub(e){A(this.#t,e,!0)}init(){let{page:e,sub:t}=Jo(window.location.pathname);this.page=e,this.sub=t,window.addEventListener(`popstate`,()=>{let{page:e,sub:t}=Jo(window.location.pathname);this.page=e,this.sub=t})}navigate(e,t=null){let n=t?`/`+t:``;history.pushState(null,``,Ho(`/admin/dashboard/`+e+n)),this.page=e,this.sub=t}},Xo=`gomodel_api_key`;function Zo(e){let t=String(e||``).trim();if(/^Bearer\s*$/i.test(t))return``;let n=t.match(/^Bearer\s+(.+)$/i);return n?n[1].trim():t}var q=new class{#e=k(``);get apiKey(){return I(this.#e)}set apiKey(e){A(this.#e,e,!0)}#t=k(!1);get needsAuth(){return I(this.#t)}set needsAuth(e){A(this.#t,e,!0)}#n=k(!1);get authError(){return I(this.#n)}set authError(e){A(this.#n,e,!0)}#r=k(``);get authErrorMessage(){return I(this.#r)}set authErrorMessage(e){A(this.#r,e,!0)}#i=k(!1);get dialogOpen(){return I(this.#i)}set dialogOpen(e){A(this.#i,e,!0)}#a=k(0);get generation(){return I(this.#a)}set generation(e){A(this.#a,e,!0)}#o=k(0);get refreshTick(){return I(this.#o)}set refreshTick(e){A(this.#o,e,!0)}init(){try{this.apiKey=Zo(localStorage.getItem(Xo)||``)}catch{this.apiKey=``}}hasApiKey(){return Zo(this.apiKey)!==``}save(){this.apiKey=Zo(this.apiKey);try{localStorage.setItem(Xo,this.apiKey)}catch{}}openDialog(){this.dialogOpen=!0}closeDialog(){this.dialogOpen=!1}submit(){let e=Zo(this.apiKey);return e?(this.apiKey=e,this.save(),this.generation++,this.authError=!1,this.authErrorMessage=``,this.needsAuth=!1,this.closeDialog(),this.refresh(),!0):(this.apiKey=``,this.authError=!0,this.authErrorMessage=``,this.needsAuth=!0,this.openDialog(),!1)}refresh(){this.refreshTick++}handleUnauthorized(e,t=``){return typeof e==`number`&&e{r[e.type]=e.value}),r.year+`-`+r.month+`-`+r.day}formatTimestampInTimeZone(e,t){if(e==null)return`-`;let n=new Date(e);if(Number.isNaN(n.getTime()))return`-`;let r=cs(`en-CA`,{timeZone:ls(t)?t:is,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(n),i={};return r.forEach(e=>{i[e.type]=e.value}),i.year+`-`+i.month+`-`+i.day+` `+i.hour+`:`+i.minute+`:`+i.second}formatTimestamp(e){return this.formatTimestampInTimeZone(e,this.effectiveTimezone())}currentDateKey(e){return this.dateKeyInTimeZone(e||new Date,this.effectiveTimezone())}dateKeyToDate(e){return $o(e)}dateToDateKey(e){return es(e)}addDaysToDateKey(e,t){return ts(e,t)}todayDate(){return this.dateKeyToDate(this.currentDateKey())}startOfMonthDate(e){let t=e instanceof Date?e:this.todayDate();return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1))}timeZoneOffsetLabel(e,t){let n=ls(e)?e:is;try{let e=cs(`en-US`,{timeZone:n,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`,timeZoneName:`longOffset`}).formatToParts(t||new Date).find(e=>e.type===`timeZoneName`);if(!e||!e.value)return`UTC+00:00`;let r=e.value.replace(`GMT`,`UTC`);return r===`UTC`?`UTC+00:00`:r}catch{return`UTC+00:00`}}timeZoneOffsetMinutes(e,t){let n=/^UTC([+-])(\d{2}):(\d{2})$/.exec(this.timeZoneOffsetLabel(e,t));if(!n)return 0;let r=Number(n[2])*60+Number(n[3]);return n[1]===`-`?-r:r}timeZoneOptionLabel(e,t){return e+` (`+this.timeZoneOffsetLabel(e,t)+`)`}detectedTimeZoneLabel(){return this.timeZoneOptionLabel(this.detectedTimezone)}effectiveTimeZoneLabel(){return this.timeZoneOptionLabel(this.effectiveTimezone())}ensureOptions(){if(this.optionsLoaded)return;let e=new Date,t=[];try{typeof Intl.supportedValuesOf==`function`&&(t=Intl.supportedValuesOf(`timeZone`))}catch{t=[]}[is,this.detectedTimezone,this.override].forEach(e=>{e&&t.indexOf(e)===-1&&ls(e)&&t.push(e)}),t=t.filter(e=>ls(e)),t.sort((t,n)=>{let r=this.timeZoneOffsetMinutes(t,e)-this.timeZoneOffsetMinutes(n,e);return r===0?t.localeCompare(n):r}),this.options=t.map(t=>({value:t,label:this.timeZoneOptionLabel(t,e)})),this.optionsLoaded=!0}saveOverride(){let e=Ta();if(e)if(this.override&&ls(this.override))try{e.setItem(as,this.override)}catch{}else{try{e.removeItem(as)}catch{}this.override=``}this.optionsLoaded=!1,this.ensureOptions()}clearOverride(){let e=Ta();if(e)try{e.removeItem(as)}catch{}this.override=``}calendarTimeZoneText(){let e=this.override?`manual override`:`auto-detected`;return`Activity grouped by `+this.effectiveTimeZoneLabel()+` (`+e+`)`}};function ps(e,t){let n=e&&typeof e==`object`&&e.error&&e.error.message;return(typeof n==`string`?n.trim():``)||t}function ms(e,t){let n=e&&e.data;if(n&&typeof n==`object`){let e=[n.message,n.error,n.error&&typeof n.error==`object`?n.error.message:null];for(let t of e)if(typeof t==`string`&&t.trim())return t.trim()}return t}function hs(){let e={"Content-Type":`application/json`},t=Zo(q.apiKey);return t&&(e.Authorization=`Bearer `+t),e[`X-GoModel-Timezone`]=fs.effectiveTimezone(),e}function gs(e,t={}){return fetch(Ho(e),{...t,headers:{...hs(),...t.headers||{}}})}async function _s(e,t,{label:n=e,parse:r=!0}={}){let i=q.generation,a=await gs(e,t);if(a.status===401)return q.handleUnauthorized(i),{ok:!1,stale:ie.trim()).filter(Boolean);return e.length>0?e:Ss}cacheVisible(){if(this.flag(`CACHE_ENABLED`)!==``)return this.booleanFlag(`CACHE_ENABLED`,!1);let e=this.flag(`REDIS_URL`),t=this.flag(`SEMANTIC_CACHE_ENABLED`);return e===``&&t===``||this.booleanFlag(`REDIS_URL`,!1)||this.booleanFlag(`SEMANTIC_CACHE_ENABLED`,!1)}auditVisible(){return this.booleanFlag(`LOGGING_ENABLED`,!0)}usageVisible(){return this.booleanFlag(`USAGE_ENABLED`,!0)}budgetsVisible(){return this.booleanFlag(`BUDGETS_ENABLED`,!0)}rateLimitsVisible(){return this.booleanFlag(`RATE_LIMITS_ENABLED`,!0)}guardrailsVisible(){return this.booleanFlag(`GUARDRAILS_ENABLED`,!0)}mcpVisible(){return this.booleanFlag(`MCP_ENABLED`,!0)}liveLogsVisible(){return this.booleanFlag(`DASHBOARD_LIVE_LOGS_ENABLED`,!0)}fetch(){return this.#n||=this.#r().finally(()=>{this.#n=null}),this.#n}async ensureLoaded(){if(this.#n){await this.#n;return}this.loaded||await this.fetch()}async#r(){let e=typeof AbortController==`function`?new AbortController:null,t=e?setTimeout(()=>e.abort(),1e4):null;try{let t=await vs(`/admin/runtime/config`,{label:`dashboard config`,signal:e?e.signal:void 0});if(t.stale)return;if(!t.ok){this.config={},this.loaded=!1;return}let n=t.data,r={};for(let e of xs)n&&typeof n==`object`&&!Array.isArray(n)&&n[e]!==void 0&&n[e]!==null&&(r[e]=String(n[e]).trim());this.config=r,this.loaded=!0}catch(e){console.error(`Failed to fetch dashboard config:`,e),this.config={},this.loaded=!1}finally{t!==null&&clearTimeout(t)}}},ws=[{page:`overview`,label:`Overview`,icon:io},{page:`providers-config`,label:`Providers`,icon:bo},{page:`models`,label:`Models`,icon:Ia},{page:`audit-logs`,label:`Audit Logs`,icon:to},{page:`usage`,label:`Usage`,icon:Va},{page:`budgets`,label:`Budgets`,icon:Po,visible:()=>Cs.budgetsVisible()},{page:`rate-limits`,label:`Rate Limits`,icon:eo,visible:()=>Cs.rateLimitsVisible()},{page:`auth-keys`,label:`API Keys`,icon:ro},{page:`workflows`,label:`Workflows`,icon:Io},{page:`guardrails`,label:`Guardrails (experimental)`,icon:wo,visible:()=>Cs.guardrailsVisible()},{page:`mcp-servers`,label:`MCP Servers`,icon:po,visible:()=>Cs.mcpVisible()},{page:`settings`,label:`Settings`,icon:Co}],Ts=R(` `),Es=R(`
                    `),Ds=R(` `,1);function Os(e,t){E(t,!0);let n=O(()=>ws.filter(e=>!e.visible||e.visible())),r=k(null),i=0,a=0,o=!1;function s(e){e.button===0&&(e.preventDefault(),A(r,e.pointerId,!0),i=e.clientX,a=ja.width,o=!1,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`sidebar-resizing`))}function c(e){e.pointerId===I(r)&&(!o&&Math.abs(e.clientX-i)<=4||(o=!0,ja.setWidth(ka(a,i,e.clientX))))}function l(e){I(r)===null||e.pointerId!==void 0&&e.pointerId!==I(r)||(A(r,null),document.body.classList.remove(`sidebar-resizing`),ja.setWidth(ja.width,!0))}function u(){if(o){o=!1;return}ja.toggle()}function d(e){let t;if(e.key===`ArrowLeft`)t=ja.width-12;else if(e.key===`ArrowRight`)t=ja.width+12;else if(e.key===`Home`)t=60;else if(e.key===`End`)t=240;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),ja.toggle();return}else return;e.preventDefault(),ja.setWidth(t,!0)}var f=Ds(),p=N(f);let m;var h=M(p),g=M(h);wa(M(g),{}),T(g),Ue(4),T(h);var _=P(h,2);H(_,21,()=>I(n),e=>e.page,(e,t)=>{var n=Ts();let r;var i=M(n);K(i,{get icon(){return I(t).icon},class:`nav-icon`});var a=P(i,2),o=M(a,!0);T(a),T(n),F(e=>{W(n,`href`,e),r=U(n,1,`nav-item svelte-1nwtzae`,null,r,{active:Yo.page===I(t).page}),W(n,`title`,I(t).label),B(o,I(t).label)},[()=>Ho(`/admin/dashboard/`+I(t).page)]),L(`click`,n,e=>{e.preventDefault(),Yo.navigate(I(t).page)}),z(e,n)}),T(_);var v=P(_,2),y=M(v);Bo(y,{get compact(){return ja.collapsed}});var b=P(y,2),x=e=>{var t=Es(),n=M(t),r=M(n);K(r,{get icon(){return oo},class:`api-key-open-icon`});var i=P(r,2),a=M(i,!0);T(i),T(n),T(t),F(()=>{W(n,`aria-label`,q.needsAuth?`Enter API key`:`Change API key`),B(a,q.needsAuth?`Enter API key`:`Change API key`)}),L(`click`,n,()=>q.openDialog()),z(e,t)},S=O(()=>q.needsAuth||q.hasApiKey());V(b,e=>{I(S)&&e(x)}),T(v),T(p);var C=P(p,2);F(()=>{m=U(p,1,`sidebar svelte-1nwtzae`,null,m,{"sidebar-collapsed":ja.collapsed,"sidebar-resizing":I(r)!==null}),W(C,`aria-valuemin`,60),W(C,`aria-valuemax`,240),W(C,`aria-valuenow`,ja.width)}),L(`pointerdown`,C,s),L(`pointermove`,C,c),L(`pointerup`,C,l),Vr(`pointercancel`,C,l),Vr(`lostpointercapture`,C,l),L(`keydown`,C,d),L(`click`,C,u),z(e,f),D()}Hr([`click`,`pointerdown`,`pointermove`,`pointerup`,`keydown`]);var ks=R(``);function As(e,t){E(t,!0);let n=G(t,`label`,3,`Close`),r=G(t,`class`,3,``),i=G(t,`iconClass`,3,`table-icon-svg`),a=G(t,`disabled`,3,!1),o=G(t,`el`,15,null);var s=ks();K(M(s),{get icon(){return Lo},get class(){return i()}}),T(s),va(s,e=>o(e),()=>o()),F(()=>{U(s,1,Li([`dialog-close-btn`,r()]),`svelte-11l1bb5`),W(s,`aria-label`,n()),s.disabled=a()}),L(`click`,s,function(...e){t.onclick?.apply(this,e)}),z(e,s),D()}Hr([`click`]);function js(e){return t=>{let n=n=>{t.contains(n.target)||e()},r=t=>{t.key===`Escape`&&e()};return document.addEventListener(`click`,n,!0),window.addEventListener(`keydown`,r),()=>{document.removeEventListener(`click`,n,!0),window.removeEventListener(`keydown`,r)}}}function Ms(e=`[data-modal-autofocus]`){return t=>{let n=t.querySelector(e);n&&typeof n.focus==`function`&&n.focus()}}var Ns=R(`
                    `,1);function Ps(e,t){E(t,!0);let n=G(t,`open`,3,!1),r=G(t,`variant`,3,`editor`),i=G(t,`closeOnBackdrop`,3,!0),a=O(()=>r()===`auth`?`auth-dialog-backdrop`:`editor-modal-backdrop`),o=O(()=>r()===`auth`?`auth-dialog-shell`:`editor-modal-shell`);An(()=>{if(!n())return;let e=Er(()=>Ma.opened()),r=n=>{n.key===`Escape`&&Ma.isTop(e)&&t.onclose?.()};return window.addEventListener(`keydown`,r),()=>{Ma.closed(e),window.removeEventListener(`keydown`,r)}});function s(e){i()&&e.target===e.currentTarget&&t.onclose?.()}var c=Qr(),l=N(c),u=e=>{var n=Ns(),r=N(n),i=P(r,2);vi(M(i),()=>t.children??f),T(i),Pi(i,Ms),F(()=>{U(r,1,Li(I(a)),`svelte-17e0w4c`),U(i,1,Li(I(o)),`svelte-17e0w4c`)}),L(`click`,i,s),z(e,n)};V(l,e=>{n()&&e(u)}),z(e,c),D()}Hr([`click`]);var Fs=R(``),Is=R(``);function Ls(e,t){E(t,!0),Ps(e,{get open(){return q.dialogOpen},variant:`auth`,onclose:()=>q.closeDialog(),children:(e,t)=>{var n=Is(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a),T(i),As(P(i,2),{label:`Close authentication dialog`,onclick:()=>q.closeDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var s=P(r,2),c=M(s),l=M(c);K(l,{get icon(){return oo},class:`auth-dialog-input-icon`});var u=P(l,2);ia(u),T(c);var d=P(c,2),f=e=>{var t=Fs(),n=M(t,!0);T(t),F(()=>B(n,q.authErrorMessage||`Enter a valid API key to continue.`)),z(e,t)};V(d,e=>{q.authError&&e(f)});var p=P(d,4),m=M(p),h=M(m);K(h,{get icon(){return Ha},class:`auth-dialog-submit-icon`});var g=P(h,2),_=M(g,!0);T(g),T(m),T(p),T(s),T(n),F(()=>{B(o,q.needsAuth?`Dashboard locked`:`Change API key`),B(_,q.needsAuth?`Unlock dashboard`:`Save API key`)}),Vr(`submit`,s,e=>{e.preventDefault(),q.submit()}),pa(u,()=>q.apiKey,e=>q.apiKey=e),z(e,n)},$$slots:{default:!0}}),D()}function Rs(){return{open:!1,title:``,titleId:`typedConfirmationDialogTitle`,inputId:`typed-confirmation-input`,message:``,requiredText:``,value:``,confirmLabel:`Confirm`,icon:Mo,dialogClass:``,loading:!1,onConfirm:null,onClose:null}}var zs=new class{#e=k(j(Rs()));get state(){return I(this.#e)}set state(e){A(this.#e,e,!0)}#t=k(``);get error(){return I(this.#t)}set error(e){A(this.#t,e,!0)}open(e){this.error=``,this.state={...Rs(),open:!0,...e||{}}}close(){let e=this.state;typeof e.onClose==`function`&&e.onClose(),this.state=Rs(),this.error=``}ready(){return String(this.state.value||``).trim().toLowerCase()===String(this.state.requiredText||``).trim().toLowerCase()}inputLabel(){return`Type `+String(this.state.requiredText||``).trim()+` to confirm`}async submit(){if(!this.ready()){this.error=this.inputLabel()+`.`;return}if(typeof this.state.onConfirm==`function`){this.state.loading=!0;try{await this.state.onConfirm()}finally{this.state.loading=!1}}}},Bs=R(`

                    `),Vs=R(``),Hs=R(`

                    `);function Us(e,t){E(t,!0);let n=O(()=>zs.state);Ps(e,{get open(){return I(n).open},variant:`auth`,onclose:()=>zs.close(),children:(e,t)=>{var r=Hs(),i=M(r),a=M(i),o=M(a,!0);T(a),As(P(a,2),{label:`Close confirmation dialog`,onclick:()=>zs.close(),class:`auth-dialog-close`,iconClass:``}),T(i);var s=P(i,2),c=M(s),l=e=>{var t=Bs(),r=M(t,!0);T(t),F(()=>B(r,I(n).message)),z(e,t)};V(c,e=>{I(n).message&&e(l)});var u=P(c,2),d=M(u),f=M(d,!0);T(d);var p=P(d,2);ia(p),T(u);var m=P(u,2),h=e=>{var t=Vs(),n=M(t,!0);T(t),F(()=>B(n,zs.error)),z(e,t)};V(m,e=>{zs.error&&e(h)});var g=P(m,2),_=M(g),v=P(_,2),y=M(v);K(y,{get icon(){return I(n).icon},class:`form-action-icon`});var b=P(y,2),x=M(b,!0);T(b),T(v),T(g),T(s),T(r),F((e,t)=>{U(r,1,`auth-dialog ${I(n).dialogClass??``}`),W(r,`aria-labelledby`,I(n).titleId),W(a,`id`,I(n).titleId),B(o,I(n).title),W(d,`for`,I(n).inputId),B(f,e),W(p,`id`,I(n).inputId),v.disabled=t,B(x,I(n).confirmLabel)},[()=>zs.inputLabel(),()=>I(n).loading||!zs.ready()]),Vr(`submit`,s,e=>{e.preventDefault(),zs.submit()}),pa(p,()=>zs.state.value,e=>zs.state.value=e),L(`click`,_,()=>zs.close()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var Ws=e=>e;function Gs(e){let t=e-1;return t*t*t+1}function Ks(e){let t=typeof e==`string`&&e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);return t?[parseFloat(t[1]),t[2]||`px`]:[e,`px`]}function qs(e,{delay:t=0,duration:n=400,easing:r=Ws}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}function Js(e,{delay:t=0,duration:n=400,easing:r=Gs,x:i=0,y:a=0,opacity:o=0}={}){let s=getComputedStyle(e),c=+s.opacity,l=s.transform===`none`?``:s.transform,u=c*(1-o),[d,f]=Ks(i),[p,m]=Ks(a);return{delay:t,duration:n,easing:r,css:(e,t)=>` + transform: ${l} translate(${(1-e)*d}${f}, ${(1-e)*p}${m}); + opacity: ${c-u*t}`}}function Ys(e,{delay:t=0,duration:n=400,easing:r=Gs,axis:i=`y`}={}){let a=getComputedStyle(e),o=+a.opacity,s=i===`y`?`height`:`width`,c=parseFloat(a[s]),l=i===`y`?[`top`,`bottom`]:[`left`,`right`],u=l.map(e=>`${e[0].toUpperCase()}${e.slice(1)}`),d=parseFloat(a[`padding${u[0]}`]),f=parseFloat(a[`padding${u[1]}`]),p=parseFloat(a[`margin${u[0]}`]),m=parseFloat(a[`margin${u[1]}`]),h=parseFloat(a[`border${u[0]}Width`]),g=parseFloat(a[`border${u[1]}Width`]);return{delay:t,duration:n,easing:r,css:e=>`overflow: hidden;opacity: ${Math.min(e*20,1)*o};${s}: ${e*c}px;padding-${l[0]}: ${e*d}px;padding-${l[1]}: ${e*f}px;margin-${l[0]}: ${e*p}px;margin-${l[1]}: ${e*m}px;border-${l[0]}-width: ${e*h}px;border-${l[1]}-width: ${e*g}px;min-${s}: 0`}}function Xs(e){return--e*e*(2.70158*e+1.70158)+1}function Zs(e){let t=e-1;return t*t*t+1}var Qs=5e3,$s=8e3,J=new class{#e=k(j([]));get toasts(){return I(this.#e)}set toasts(e){A(this.#e,e,!0)}#t=0;#n=new Map;success(e){this.#r(`success`,e,Qs)}error(e){this.#r(`error`,e,$s)}dismiss(e){let t=this.#n.get(e);t&&(clearTimeout(t),this.#n.delete(e)),this.toasts=this.toasts.filter(t=>t.id!==e)}#r(e,t,n){let r=String(t||``).trim();if(!r)return;let i=this.toasts.find(t=>t.kind===e&&t.text===r);i&&this.dismiss(i.id);let a=++this.#t;this.toasts=[...this.toasts,{id:a,kind:e,text:r}],this.#n.set(a,setTimeout(()=>this.dismiss(a),n))}},ec=R(`
                    `),tc=R(`
                    `);function nc(e,t){E(t,!0);var n=tc();H(n,21,()=>J.toasts,e=>e.id,(e,t)=>{var n=ec();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2);T(n),F(()=>{r=U(n,1,`flash-toast svelte-1i257xg`,null,r,{"flash-toast-success":I(t).kind===`success`,"flash-toast-error":I(t).kind===`error`}),W(n,`role`,I(t).kind===`error`?`alert`:`status`),W(n,`aria-live`,I(t).kind===`error`?`assertive`:`polite`),B(a,I(t).text)}),L(`click`,o,()=>J.dismiss(I(t).id)),ji(1,n,()=>Js,()=>({y:-24,duration:360,easing:Xs})),ji(2,n,()=>qs,()=>({duration:150})),z(e,n)}),T(n),z(e,n),D()}Hr([`click`]);var rc=R(``);function ic(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{z(e,rc())},a=O(()=>Go());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}function ac(e){return String(e||``).split(`,`).map(e=>e.trim()).filter(e=>e)}function oc(e){if(e==null||e===``)return`Not captured`;if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function sc(e){return e==null||e===void 0?`-`:e.toLocaleString()}function cc(e){if(e==null)return`---`;let t=Number(e);return Number.isFinite(t)?t>0&&t<1e-4?`<$0.0001`:`$`+t.toFixed(4).replace(/(\.\d{2}\d*?)0+$/,`$1`):`---`}function lc(e){return e==null||e===void 0?`—`:`$`+e.toFixed(2)}function uc(e){return e==null||e===void 0?`—`:e<.01?`$`+e.toFixed(6):`$`+e.toFixed(4)}function dc(e){if(e==null||e===``)return`-`;let t=Number(e);if(!Number.isFinite(t))return`-`;let n=Math.abs(t),r=[{threshold:1e9,suffix:`B`},{threshold:1e6,suffix:`M`},{threshold:1e3,suffix:`K`}];for(let e=0;e=i.threshold){let n=t/i.threshold;return Math.abs(Number(n.toFixed(1)))>=1e3&&e>0&&(i=r[e-1],n=t/i.threshold),n.toFixed(1).replace(/\.0$/,``)+i.suffix}}return String(t)}function fc(e,t){let n=t==null||t===``?NaN:Number(t),r=Number.isFinite(n)?sc(n):`-`;return String(e||`Tokens`)+`: `+r}function pc(e){return e?typeof e==`string`?e:e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`):``}function mc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)}function hc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)+` `+String(t.getUTCHours()).padStart(2,`0`)+`:`+String(t.getUTCMinutes()).padStart(2,`0`)+`:`+String(t.getUTCSeconds()).padStart(2,`0`)+` UTC`}function gc(e){return String(e&&e.provider||``).trim()}function _c(e){return String(e&&e.provider_name||``).trim()||gc(e)}function vc(e,t){let n=String(t||``).trim();if(!n)return`-`;let r=_c(e);return!r||n===r||n.startsWith(r+`/`)?n:r+`/`+n}function yc(e){return vc(e,e&&e.model)}function bc(e){return vc(e,e&&e.resolved_model)}function xc(e){let t=String(e&&(e.requested_model||e.model)||``).trim();if(!e)return t;let n=String(e.data&&e.data.failover&&e.data.failover.target_model||``).trim();if(n&&n!==t)return t+` ⮕ `+n;if(e.alias_used&&e.resolved_model){let n=bc(e);if(n&&n!==`-`&&n!==t)return t+` ⮕ `+n}return t}var Sc=`gomodel_date_range`,Cc=1;function wc(e){return/^[1-9]\d*$/.test(String(e??``))}var Tc=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Ec({selectedPreset:e,startKey:t,endKey:n,followsToday:r}){return e&&wc(e)?{v:Cc,mode:`preset`,days:String(e)}:e?null:ns(t)&&ns(n)?{v:Cc,mode:`custom`,start:t,end:n,follow:r===!0}:null}function Dc(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return null}return!t||typeof t!=`object`?null:t.mode===`preset`?wc(t.days)?{mode:`preset`,days:String(t.days)}:null:t.mode===`custom`&&ns(t.start)&&ns(t.end)&&t.start<=t.end?{mode:`custom`,start:t.start,end:t.end,follow:t.follow===!0}:null}function Oc(e,t,n){let r=rs(e,t);return r<1||!ns(n)?{start:e,end:t}:{start:ts(n,-(r-1)),end:n}}function kc(e,t){if(e===t)return`Today`;let[n,r,i]=e.split(`-`);return Tc[Number(r)-1]+` `+Number(i)+`, `+n}function Ac({selectedPreset:e,startKey:t,endKey:n,followsToday:r,todayKey:i}){if(e)return`Last `+e+` days`;if(!ns(t)||!ns(n))return``;let a=rs(t,n);return r||n===i?a===1?`Today`:`Last `+a+` days`:a===1?`1 day`:a+` days`}function jc({selectedPreset:e,startKey:t,endKey:n,todayKey:r}){if(e)return`Last `+e+` days`;let i=e=>kc(e,r);return ns(t)&&ns(n)?t===n?i(t):i(t)+` – `+i(n):ns(t)?i(t)+` – ...`:`Last 30 days`}var Mc=6e4,Nc=new class{#e=k(j(`30`));get days(){return I(this.#e)}set days(e){A(this.#e,e,!0)}#t=k(j(`30`));get selectedPreset(){return I(this.#t)}set selectedPreset(e){A(this.#t,e,!0)}#n=k(null);get customStartDate(){return I(this.#n)}set customStartDate(e){A(this.#n,e,!0)}#r=k(null);get customEndDate(){return I(this.#r)}set customEndDate(e){A(this.#r,e,!0)}#i=k(!1);get followsToday(){return I(this.#i)}set followsToday(e){A(this.#i,e,!0)}#a=k(`daily`);get interval(){return I(this.#a)}set interval(e){A(this.#a,e,!0)}#o=k(0);get syncTick(){return I(this.#o)}set syncTick(e){A(this.#o,e,!0)}init(){this.restore(),this.syncToToday(),typeof setInterval==`function`&&setInterval(()=>this.syncToToday(),Mc)}queryStr(){return this.customStartDate&&this.customEndDate?`start_date=`+pc(this.customStartDate)+`&end_date=`+pc(this.customEndDate):`days=`+this.days}selectPreset(e){this.selectedPreset=e,this.customStartDate=null,this.customEndDate=null,this.followsToday=!1,this.days=e,this.persist()}selectStart(e){this.selectedPreset=null,this.customStartDate=e,this.customEndDate&&this.customEndDatet.category===e);return t?t.count:0}get filteredModels(){if(!this.filter)return this.models;let e=this.filter.toLowerCase();return this.models.filter(t=>(t.model?.id??``).toLowerCase().includes(e)||(t.provider_name??``).toLowerCase().includes(e)||(t.provider_type??``).toLowerCase().includes(e)||(t.selector??``).toLowerCase().includes(e)||(t.model?.owned_by??``).toLowerCase().includes(e)||(t.model?.metadata?.modes??[]).join(`,`).toLowerCase().includes(e)||(t.model?.metadata?.categories??[]).join(`,`).toLowerCase().includes(e))}},Fc=R(``);function Ic(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Fc(),n=P(M(t),2);T(t),L(`click`,n,()=>q.openDialog()),z(e,t)};V(r,e=>{q.authError&&e(i)}),z(e,n),D()}Hr([`click`]);function Lc(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null}}function Rc(){return{summary:{total_hits:0,exact_hits:0,semantic_hits:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_saved_cost:null},daily:[]}}var zc=new class{#e=k(j(Lc()));get summary(){return I(this.#e)}set summary(e){A(this.#e,e,!0)}#t=k(j([]));get daily(){return I(this.#t)}set daily(e){A(this.#t,e,!0)}#n=k(j(Rc()));get cacheOverview(){return I(this.#n)}set cacheOverview(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=null;#a=null;cacheAnalyticsEnabled(){return Cs.cacheVisible()}async fetchUsage(){this.#i&&this.#i.abort();let e=new AbortController;this.#i=e,this.loading=!0;try{let t=Nc.queryStr()+`&interval=`+Nc.interval,[n,r]=await Promise.all([vs(`/admin/usage/summary?`+t,{label:`usage summary`,signal:e.signal}),vs(`/admin/usage/daily?`+t,{label:`usage daily`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.summary=Lc(),this.daily=[],this.cacheOverview=Rc();return}this.summary=n.data||Lc(),this.daily=Array.isArray(r.data)?r.data:[]}catch(e){if(bs(e))return;console.error(`Failed to fetch usage:`,e),this.summary=Lc(),this.daily=[]}finally{this.#i===e&&(this.#i=null,this.loading=!1)}}async fetchCacheOverview(e=``){if(await Cs.ensureLoaded(),!this.cacheAnalyticsEnabled()){this.cacheOverview=Rc();return}this.#a&&this.#a.abort();let t=new AbortController;this.#a=t;try{let n=await vs(`/admin/cache/overview?`+(Nc.queryStr()+`&interval=`+Nc.interval+e),{label:`cache overview`,signal:t.signal});if(n.stale||t.signal.aborted)return;if(!n.ok){this.cacheOverview=Rc();return}let r=n.data&&typeof n.data==`object`?n.data:Rc();r.summary||=Rc().summary,Array.isArray(r.daily)||(r.daily=[]),this.cacheOverview=r}catch(e){if(bs(e))return;console.error(`Failed to fetch cache overview:`,e),this.cacheOverview=Rc()}finally{this.#a===t&&(this.#a=null)}}},Bc=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Vc(e,t){let n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return Bc[n.getUTCMonth()]+` `+n.getUTCFullYear()}function Hc(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth()+t,a=new Date(Date.UTC(r,i,1)),o=new Date(Date.UTC(r,i+1,0)),s=(a.getUTCDay()+6)%7,c=[],l=new Date(Date.UTC(r,i,0));for(let e=s-1;e>=0;e--){let t=l.getUTCDate()-e,a=new Date(Date.UTC(r,i-1,t));c.push({day:t,date:a,current:!1,key:`p-`+n(a)})}for(let e=1;e<=o.getUTCDate();e++){let t=new Date(Date.UTC(r,i,e));c.push({day:e,date:t,current:!0,key:`c-`+n(t)})}let u=42-c.length;for(let e=1;e<=u;e++){let t=new Date(Date.UTC(r,i+1,e));c.push({day:e,date:t,current:!1,key:`n-`+n(t)})}return c}function Uc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return n&&r.getTime()>n.getTime()?e:r}function Wc(e,t){return e.getUTCFullYear()===t.getUTCFullYear()&&e.getUTCMonth()===t.getUTCMonth()}var Gc=R(``),Kc=R(``),qc=R(``),Jc=R(`
                    MoTuWeThFrSaSu
                    `);function Yc(e,t){E(t,!0);let n=G(t,`offset`,3,0),r=O(()=>Hc(t.calendarMonth,n(),e=>fs.dateToDateKey(e))),i=O(()=>Wc(t.calendarMonth,fs.todayDate())),a=e=>fs.dateToDateKey(e.date),o=e=>a(e)>fs.currentDateKey(),s=e=>e.current&&a(e)===fs.currentDateKey();function c(e,t){let n=t===`start`?Nc.rangeStart():Nc.rangeEnd();return e.current&&!!n&&a(e)===fs.dateToDateKey(n)}function l(e){let t=Nc.rangeStart(),n=Nc.rangeEnd();return!e.current||!t||!n?!1:a(e)>=fs.dateToDateKey(t)&&a(e)<=fs.dateToDateKey(n)}var u=Jc(),d=M(u),f=M(d);let p;var m=P(f,2),h=M(m,!0);T(m);var g=P(m,2),_=e=>{z(e,Gc())},v=e=>{var n=Kc();F(()=>n.disabled=I(i)),L(`click`,n,function(...e){t.onnext?.apply(this,e)}),z(e,n)};V(g,e=>{n()===-1?e(_):e(v,-1)}),T(d);var y=P(d,4);H(y,21,()=>I(r),e=>e.key,(e,n)=>{var r=qc(),i=M(r,!0);T(r),F((e,t)=>{U(r,1,e,`svelte-g7ga4u`),r.disabled=t,B(i,I(n).day)},[()=>Li([`dp-day`,{"other-month":!I(n).current,today:s(I(n)),"range-start":c(I(n),`start`),"range-end":c(I(n),`end`),"in-range":l(I(n)),disabled:o(I(n))}]),()=>o(I(n))||!I(n).current]),L(`click`,r,()=>t.onselect?.(I(n))),z(e,r)}),T(y),T(u),F(e=>{p=U(f,1,`dp-nav-btn svelte-g7ga4u`,null,p,{"dp-nav-prev-mobile":n()!==-1}),B(h,e)},[()=>Vc(t.calendarMonth,n())]),L(`click`,f,function(...e){t.onprev?.apply(this,e)}),z(e,u),D()}Hr([`click`]);var Xc=R(``),Zc=R(`
                    `),Qc=Xr(``),$c=Xr(``),el=R(`
                    `),tl=R(`
                    `);function nl(e,t){E(t,!0);let n=[`3`,`7`,`14`,`30`,`90`],r=k(!1),i=k(`start`),a=k(j(new Date)),o=k(j({show:!1,x:0,y:0}));function s(){A(r,!I(r)),I(r)&&(Nc.syncToToday(),A(a,fs.startOfMonthDate(Nc.customEndDate||fs.todayDate()),!0),A(i,`start`))}function c(){A(r,!1),A(o,{show:!1,x:0,y:0},!0)}let l=Nc.syncTick;An(()=>{let e=Nc.syncTick;e!==l&&(l=e,t.onchange?.())});function u(e){Nc.selectPreset(e),A(i,`start`),t.onchange?.(),c()}let d=()=>A(a,Uc(I(a),-1),!0),f=()=>A(a,Uc(I(a),1,fs.startOfMonthDate(fs.todayDate())),!0);function p(e){let n=new Date(e.date);if(I(i)===`start`){Nc.selectStart(n),A(i,`end`),t.onchange?.();return}Nc.selectEnd(n),A(i,`start`),t.onchange?.(),c()}var m=tl(),h=M(m),g=P(M(h),2),_=M(g,!0);T(g);var v=P(g,2);let y;T(h);var b=P(h,2),x=e=>{var t=Zc(),r=M(t);H(r,20,()=>n,e=>e,(e,t)=>{var n=Xc();let r;var i=M(n);T(n),F(()=>{r=U(n,1,`preset-btn svelte-ax7ma4`,null,r,{active:Nc.selectedPreset===t}),B(i,`Last ${t??``} days`)}),L(`click`,n,()=>u(t)),z(e,n)}),T(r);var i=P(r,2);H(i,20,()=>[-1,0],e=>e,(e,t)=>{Yc(e,{get calendarMonth(){return I(a)},get offset(){return t},onprev:d,onnext:f,onselect:p})}),T(i),T(t),L(`mousemove`,i,e=>A(o,{show:!0,x:e.clientX,y:e.clientY},!0)),Vr(`mouseleave`,i,()=>A(o,{show:!1,x:0,y:0},!0)),z(e,t)};V(b,e=>{I(r)&&e(x)});var S=P(b,2),C=e=>{var t=el(),n=M(t),r=e=>{z(e,Qc())},a=e=>{z(e,$c())};V(n,e=>{I(i)===`start`?e(r):e(a,-1)});var s=P(n,2),c=M(s,!0);T(s),T(t),F(()=>{Wi(t,`left:${I(o).x??``}px;top:${I(o).y??``}px`),B(c,I(i)===`end`?`Select end date`:`Select start date`)}),z(e,t)};V(S,e=>{I(o).show&&e(C)}),T(m),Pi(m,()=>I(r)?js(c):void 0),F((e,t)=>{W(h,`title`,e),B(_,t),y=U(v,0,`date-picker-chevron svelte-ax7ma4`,null,y,{open:I(r)})},[()=>Nc.dateRangeSpanLabel(),()=>Nc.dateRangeLabel()]),L(`click`,h,s),z(e,m),D()}Hr([`click`,`mousemove`]);function rl(e){return e+.5|0}var il=(e,t,n)=>Math.max(Math.min(e,n),t);function al(e){return il(rl(e*2.55),0,255)}function ol(e){return il(rl(e*255),0,255)}function sl(e){return il(rl(e/2.55)/100,0,1)}function cl(e){return il(rl(e*100),0,100)}var ll={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},ul=[...`0123456789ABCDEF`],dl=e=>ul[e&15],fl=e=>ul[(e&240)>>4]+ul[e&15],pl=e=>(e&240)>>4==(e&15),ml=e=>pl(e.r)&&pl(e.g)&&pl(e.b)&&pl(e.a);function hl(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&ll[e[1]]*17,g:255&ll[e[2]]*17,b:255&ll[e[3]]*17,a:t===5?ll[e[4]]*17:255}:(t===7||t===9)&&(n={r:ll[e[1]]<<4|ll[e[2]],g:ll[e[3]]<<4|ll[e[4]],b:ll[e[5]]<<4|ll[e[6]],a:t===9?ll[e[7]]<<4|ll[e[8]]:255})),n}var gl=(e,t)=>e<255?t(e):``;function _l(e){var t=ml(e)?dl:fl;return e?`#`+t(e.r)+t(e.g)+t(e.b)+gl(e.a,t):void 0}var vl=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function yl(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function bl(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function xl(e,t,n){let r=yl(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function Sl(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=Sl(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function wl(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(ol)}function Tl(e,t,n){return wl(yl,e,t,n)}function El(e,t,n){return wl(xl,e,t,n)}function Dl(e,t,n){return wl(bl,e,t,n)}function Ol(e){return(e%360+360)%360}function kl(e){let t=vl.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?al(+t[5]):ol(+t[5]));let i=Ol(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?El(i,a,o):t[1]===`hsv`?Dl(i,a,o):Tl(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function Al(e,t){var n=Cl(e);n[0]=Ol(n[0]+t),n=Tl(n),e.r=n[0],e.g=n[1],e.b=n[2]}function jl(e){if(!e)return;let t=Cl(e),n=t[0],r=cl(t[1]),i=cl(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${sl(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var Ml={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},Nl={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function Pl(){let e={},t=Object.keys(Nl),n=Object.keys(Ml),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var Fl;function Il(e){Fl||(Fl=Pl(),Fl.transparent=[0,0,0,0]);let t=Fl[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var Ll=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Rl(e){let t=Ll.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?al(e):il(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?al(r):il(r,0,255)),i=255&(t[4]?al(i):il(i,0,255)),a=255&(t[6]?al(a):il(a,0,255)),{r,g:i,b:a,a:n}}}function zl(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${sl(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var Bl=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,Vl=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Hl(e,t,n){let r=Vl(sl(e.r)),i=Vl(sl(e.g)),a=Vl(sl(e.b));return{r:ol(Bl(r+n*(Vl(sl(t.r))-r))),g:ol(Bl(i+n*(Vl(sl(t.g))-i))),b:ol(Bl(a+n*(Vl(sl(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Ul(e,t,n){if(e){let r=Cl(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=Tl(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Wl(e,t){return e&&Object.assign(t||{},e)}function Gl(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=ol(e[3]))):(t=Wl(e,{r:0,g:0,b:0,a:1}),t.a=ol(t.a)),t}function Kl(e){return e.charAt(0)===`r`?Rl(e):kl(e)}var ql=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Gl(t):n===`string`&&(r=hl(t)||Il(t)||Kl(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Wl(this._rgb);return e&&(e.a=sl(e.a)),e}set rgb(e){this._rgb=Gl(e)}rgbString(){return this._valid?zl(this._rgb):void 0}hexString(){return this._valid?_l(this._rgb):void 0}hslString(){return this._valid?jl(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Hl(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=ol(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=rl(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Ul(this._rgb,2,e),this}darken(e){return Ul(this._rgb,2,-e),this}saturate(e){return Ul(this._rgb,1,e),this}desaturate(e){return Ul(this._rgb,1,-e),this}rotate(e){return Al(this._rgb,e),this}};function Jl(){}var Yl=(()=>{let e=0;return()=>e++})();function Xl(e){return e==null}function Zl(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function Ql(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function $l(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function eu(e,t){return $l(e)?e:t}function tu(e,t){return e===void 0?t:e}var nu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,ru=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function iu(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function au(e,t,n,r){let i,a,o;if(Zl(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function mu(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function hu(e){let t=mu(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function gu(e,t){return(pu[t]||(pu[t]=hu(t)))(e)}function _u(e){return e.charAt(0).toUpperCase()+e.slice(1)}var vu=e=>e!==void 0,yu=e=>typeof e==`function`,bu=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function xu(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var Su=Math.PI,Cu=2*Su,wu=Cu+Su,Tu=1/0,Eu=Su/180,Du=Su/2,Ou=Su/4,ku=Su*2/3,Au=Math.log10,ju=Math.sign;function Mu(e,t,n){return Math.abs(e-t)e-t).pop(),t}function Fu(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Iu(e){return!Fu(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Lu(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Ru(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Xu(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var Zu=(e,t,n,r)=>Xu(e,n,r?r=>{let i=e[r][t];return ie[r][t]Xu(e,n,r=>e[r][t]>=n);function $u(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+_u(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function nd(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(ed.forEach(t=>{delete e[t]}),delete e._chartjs)}function rd(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var id=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function ad(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,id.call(window,()=>{r=!1,e.apply(t,n)}))}}function od(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var sd=e=>e===`start`?`left`:e===`end`?`right`:`center`,cd=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,ld=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function ud(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(Zu(c,u,d).lo,n?r:Zu(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!Xl(e[s.axis]));i-=Math.max(0,e)}i=qu(i,0,r-1)}if(m){let e=Math.max(Zu(c,o.axis,f,!0).hi+1,n?0:Zu(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!Xl(e[s.axis]));e+=Math.max(0,t)}a=qu(e,i,r)-i}else a=r-i}return{start:i,count:a}}function dd(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var fd=e=>e===0||e===1,pd=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*Cu/n)),md=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*Cu/n)+1,hd={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Du)+1,easeOutSine:e=>Math.sin(e*Du),easeInOutSine:e=>-.5*(Math.cos(Su*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>fd(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>fd(e)?e:pd(e,.075,.3),easeOutElastic:e=>fd(e)?e:md(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return fd(e)?e:e<.5?.5*pd(e*2,t,n):.5+.5*md(e*2-1,t,n)},easeInBack(e){return e*e*(2.70158*e-1.70158)},easeOutBack(e){return--e*e*(2.70158*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-hd.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?hd.easeInBounce(e*2)*.5:hd.easeOutBounce(e*2-1)*.5+.5};function gd(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function _d(e){return gd(e)?e:new ql(e)}function vd(e){return gd(e)?e:new ql(e).saturate(.5).darken(.1).hexString()}var yd=[`x`,`y`,`borderWidth`,`radius`,`tension`],bd=[`color`,`borderColor`,`backgroundColor`];function xd(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:bd},numbers:{type:`number`,properties:yd}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function Sd(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var Cd=new Map;function wd(e,t){t||={};let n=e+JSON.stringify(t),r=Cd.get(n);return r||(r=new Intl.NumberFormat(e,t),Cd.set(n,r)),r}function Td(e,t,n){return wd(t,n).format(e)}var Ed={values(e){return Zl(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Dd(e,n)}let o=Au(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),Td(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(Au(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?Ed.numeric.call(this,e,t,n):``}};function Dd(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Od={formatters:Ed};function kd(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Od.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var Ad=Object.create(null),jd=Object.create(null);function Md(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>vd(t.backgroundColor),this.hoverBorderColor=(e,t)=>vd(t.borderColor),this.hoverColor=(e,t)=>vd(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return Nd(this,e,t)}get(e){return Md(this,e)}describe(e,t){return Nd(jd,e,t)}override(e,t){return Nd(Ad,e,t)}route(e,t,n,r){let i=Md(this,e),a=Md(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return Ql(e)?Object.assign({},t,e):tu(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[xd,Sd,kd]);function Fd(e){return!e||Xl(e.size)||Xl(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Id(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Ld(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function Hd(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,qd(e,a),c=0;c+e||0;function nf(e,t){let n={},r=Ql(t),i=r?Object.keys(t):t,a=Ql(e)?r?n=>tu(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=tf(a(e));return n}function rf(e){return nf(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function af(e){return nf(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function of(e){let t=rf(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function sf(e,t){e||={},t||=Pd.font;let n=tu(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=tu(e.style,t.style);r&&!(``+r).match($d)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:tu(e.family,t.family),lineHeight:ef(tu(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:tu(e.weight,t.weight),string:``};return i.string=Fd(i),i}function cf(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function uf(e,t){return Object.assign(Object.create(e),t)}function df(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Df(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>df([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return gf(n,r,()=>Ef(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Of(e).includes(t)},ownKeys(e){return Of(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function ff(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:pf(e,r),setContext:t=>ff(e,t,n,r),override:i=>ff(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return gf(e,t,()=>_f(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function pf(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:yu(n)?n:()=>n,isIndexable:yu(r)?r:()=>r}}var mf=(e,t)=>e?e+_u(t):t,hf=(e,t)=>Ql(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function gf(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function _f(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return yu(s)&&o.isScriptable(t)&&(s=vf(t,s,e,n)),Zl(s)&&s.length&&(s=yf(t,s,e,o.isIndexable)),hf(t,s)&&(s=ff(s,i,a&&a[t],o)),s}function vf(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),hf(e,c)&&(c=Cf(i._scopes,i,e,c)),c}function yf(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(Ql(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=Cf(r,i,e,c);t.push(ff(n,a,o&&o[e],s))}}return t}function bf(e,t,n){return yu(e)?e(t,n):e}var xf=(e,t)=>e===!0?t:typeof e==`string`?gu(t,e):void 0;function Sf(e,t,n,r,i){for(let a of t){let t=xf(n,a);if(t){e.add(t);let a=bf(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function Cf(e,t,n,r){let i=t._rootScopes,a=bf(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=wf(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=wf(s,o,a,c,r),c===null)?!1:df(Array.from(s),[``],i,a,()=>Tf(t,n,r))}function wf(e,t,n,r,i){for(;n;)n=Sf(e,t,n,r,i);return n}function Tf(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Zl(i)&&Ql(n)?n:i||{}}function Ef(e,t,n,r){let i;for(let a of t)if(i=Df(mf(a,e),n),i!==void 0)return hf(e,i)?Cf(n,r,e,i):i}function Df(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Of(e){let t=e._keys;return t||=e._keys=kf(e._scopes),t}function kf(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function Af(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;ste===`x`?`y`:`x`;function Pf(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=Uu(a,i),c=Uu(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Ff(e,t,n){let r=e.length,i,a,o,s,c,l=Mf(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)Lf(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function Gf(e,t){return Wf(e).getPropertyValue(t)}var Kf=[`top`,`right`,`bottom`,`left`];function qf(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Kf[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var Jf=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Yf(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(Jf(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Xf(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Wf(n),a=i.boxSizing===`border-box`,o=qf(i,`padding`),s=qf(i,`border`,`width`),{x:c,y:l,box:u}=Yf(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function Zf(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Hf(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Wf(a),s=qf(o,`border`,`width`),c=qf(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=Uf(o.maxWidth,a,`clientWidth`),i=Uf(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||Tu,maxHeight:i||Tu}}var Qf=e=>Math.round(e*10)/10;function $f(e,t,n,r){let i=Wf(e),a=qf(i,`margin`),o=Uf(i.maxWidth,e,`clientWidth`)||Tu,s=Uf(i.maxHeight,e,`clientHeight`)||Tu,c=Zf(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=qf(i,`border`,`width`),t=qf(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=Qf(Math.min(l,o,c.maxWidth)),u=Qf(Math.min(u,s,c.maxHeight)),l&&!u&&(u=Qf(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=Qf(Math.floor(u*r))),{width:l,height:u}}function ep(e,t,n){let r=t||1,i=Qf(e.height*r),a=Qf(e.width*r);e.height=Qf(e.height),e.width=Qf(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var tp=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Vf()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function np(e,t){let n=Gf(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function rp(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function ip(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function ap(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=rp(e,i,n),s=rp(i,a,n),c=rp(a,t,n);return rp(rp(o,s,n),rp(s,c,n),n)}var op=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},sp=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function cp(e,t,n){return e?op(t,n):sp()}function lp(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function up(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function dp(e){return e===`angle`?{between:Ku,compare:Wu,normalize:Gu}:{between:Yu,compare:(e,t)=>e-t,normalize:e=>e}}function fp({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function pp(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=dp(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(fp({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(fp({start:g,end:d,loop:f,count:o,style:p})),m}function hp(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function _p(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function vp(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=gp(n,i,a,r);return r===!0?yp(e,[{start:o,end:s,loop:a}],n,t):yp(e,_p(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,id.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Dp=`transparent`,Op={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=_d(e||Dp),i=r.valid&&_d(t||Dp);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},kp=class{constructor(e,t,n,r){let i=t[n];r=cf([e.to,r,i,e.from]);let a=cf([e.from,i,r]);this._active=!0,this._fn=e.fn||Op[e.type||typeof a],this._easing=hd[e.easing]||hd.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=cf([e.to,t,r,e.from]),this._from=cf([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!Ql(i))return;let a={};for(let e of t)a[e]=i[e];(Zl(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=Mp(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&jp(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new kp(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return Ep.add(this._chart,n),!0}};function jp(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function Wp(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=Bp(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function Kp(e,t){return uf(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function qp(e,t,n){return uf(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function Jp(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var Yp=e=>e===`reset`||e===`none`,Xp=(e,t)=>t?e:Object.assign({},e),Zp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Ip(n,!0),values:null},Qp=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=zp(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&Jp(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=tu(n.xAxisID,Gp(e,`x`)),a=t.yAxisID=tu(n.yAxisID,Gp(e,`y`)),o=t.rAxisID=tu(n.rAxisID,Gp(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&nd(this._data,this),e._stacked&&Jp(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(Ql(t)){let e=this._cachedMeta;this._data=Rp(t,e)}else if(n!==t){if(n){nd(n,this);let e=this._cachedMeta;Jp(e),e._parsed=[]}t&&Object.isExtensible(t)&&td(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=zp(t.vScale,t),t.stack!==n.stack&&(r=!0,Jp(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Wp(this,t._parsed),t._stacked=zp(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length||n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=Zl(r[e])?this.parseArrayData(n,r,e,t):Ql(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Xp(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new Ap(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||Yp(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){Yp(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!Yp(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function em(e){let t=e.iScale,n=$p(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(vu(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function im(e,t,n,r){return Zl(e)?rm(e,t,n,r):t[n.axis]=n.parse(e,r),t}function am(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):ju(e)}function cm(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(Xl(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[tu(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;dKu(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>Ku(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(Du,u,f),_=m(Su,l,d),v=m(Su+Du,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var _m=class extends Qp{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(Ql(n[e])){let{key:e=`value`}=this._parsing;i=t=>+gu(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*Cu:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Td(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=Xl(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},ym=class extends Qp{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Td(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return Af.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(rt.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*Su,d=u,f,p=360/this.countVisibleElements();for(f=0;f{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?zu(this.resolveDataElementOptions(e,t).angle||n):0}},bm=Object.freeze({__proto__:null,BarController:mm,BubbleController:hm,DoughnutController:_m,LineController:vm,PieController:class extends _m{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:ym,RadarController:class extends Qp{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return Af.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function xm(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var Sm={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return xm()}parse(){return xm()}format(){return xm()}add(){return xm()}diff(){return xm()}startOf(){return xm()}endOf(){return xm()}}};function Cm(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?Qu:Zu;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!Xl(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!Xl(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function wm(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var jm={evaluateInteractionItems:wm,modes:{index(e,t,n,r){let i=Xf(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Em(e,i,a,r,o):km(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Xf(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Em(e,i,a,r,o):km(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Pm(e,t){return e.filter(e=>Mm.indexOf(e.pos)===-1&&e.box.axis===t)}function Fm(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Im(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=Fm(Nm(t,`left`),!0),i=Fm(Nm(t,`right`)),a=Fm(Nm(t,`top`),!0),o=Fm(Nm(t,`bottom`)),s=Pm(t,`x`),c=Pm(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Nm(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function Bm(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Vm(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Hm(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!Ql(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&Vm(o,a.getPadding());let s=Math.max(0,t.outerWidth-Bm(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-Bm(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function Um(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Wm(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Gm(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);Vm(f,of(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Rm(c.concat(l),d);Gm(s.fullSize,p,d,m),Gm(c,p,d,m),Gm(l,p,d,m)&&Gm(c,p,d,m),Um(p),qm(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,qm(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},au(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},Ym=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},Xm=class extends Ym{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},Zm=`$chartjs`,Qm={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},$m=e=>e===null||e===``;function eh(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[Zm]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,$m(i)){let t=np(e,`width`);t!==void 0&&(e.width=t)}if($m(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=np(e,`height`);t!==void 0&&(e.height=t)}return e}var th=tp?{passive:!0}:!1;function nh(e,t,n){e&&e.addEventListener(t,n,th)}function rh(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,th)}function ih(e,t){let n=Qm[e.type]||e.type,{x:r,y:i}=Xf(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function ah(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function oh(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ah(n.addedNodes,r),t&&=!ah(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function sh(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ah(n.removedNodes,r),t&&=!ah(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var ch=new Map,lh=0;function uh(){let e=window.devicePixelRatio;e!==lh&&(lh=e,ch.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function dh(e,t){ch.size||window.addEventListener(`resize`,uh),ch.set(e,t)}function fh(e){ch.delete(e),ch.size||window.removeEventListener(`resize`,uh)}function ph(e,t,n){let r=e.canvas,i=r&&Hf(r);if(!i)return;let a=ad((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),dh(e,a),o}function mh(e,t,n){n&&n.disconnect(),t===`resize`&&fh(e)}function hh(e,t,n){let r=e.canvas,i=ad(t=>{e.ctx!==null&&n(ih(t,e))},e);return nh(r,t,i),i}var gh=class extends Ym{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(eh(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[Zm])return!1;let n=t[Zm].initial;[`height`,`width`].forEach(e=>{let r=n[e];Xl(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[Zm],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:oh,detach:sh,resize:ph}[t]||hh)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:mh,detach:mh,resize:mh}[t]||rh)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return $f(e,t,n,r)}isAttached(e){let t=e&&Hf(e);return!!(t&&t.isConnected)}};function _h(e){return!Vf()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?Xm:gh}var vh=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Iu(this.x)&&Iu(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function yh(e,t){let n=e.options.ticks,r=bh(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?Sh(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return Ch(t,l,a,o/i),l;let u=xh(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(wh(t,l,u,Xl(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function Sh(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Dh=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,Oh=(e,t)=>Math.min(t||e,e);function kh(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function jh(e,t){au(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:eu(t,eu(n,t)),max:eu(n,eu(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){iu(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=lf(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=qu(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-Mh(e.grid)-t.padding-Nh(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=Bu(Math.min(Math.asin(qu((l.highest.height+6)/o,-1,1)),Math.asin(qu(s/c,-1,1))-Math.asin(qu(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){iu(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){iu(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=Nh(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=Mh(i)+a):(e.height=this.maxHeight,e.width=Mh(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=zu(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){iu(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return Ju(this._alignToPixels?Rd(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=Mh(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Rd(n,e,p)},g,_,v,y,b,x,S,C,w,ee,te,ne;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,ee=h(e.top)+m,ne=e.bottom;else if(a===`bottom`)g=h(this.top),ee=e.top,ne=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,te=e.right;else if(a===`right`)g=h(this.left),w=e.left,te=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(Ql(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}ee=e.top,ne=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(Ql(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,te=e.right}let re=tu(r.ticks.maxTicksLimit,l),ie=Math.max(1,Math.ceil(l/re));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:ne,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:re,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-zu(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Pd.route(a,i,c,s)})}function Hh(e){return`id`in e&&`defaults`in e}var Uh=new class{constructor(){this.controllers=new zh(Qp,`datasets`,!0),this.elements=new zh(vh,`elements`),this.plugins=new zh(Object,`plugins`),this.scales=new zh(Rh,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):au(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=_u(e);iu(n[`before`+r],[],n),t[e](n),iu(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Gh(e){let t={},n=[],r=Object.keys(Uh.plugins.items);for(let e=0;e1&&Qh(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function tg(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function ng(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return tg(e,`x`,n[0])||tg(e,`y`,n[0])}return{}}function rg(e,t){let n=Ad[e.type]||{scales:{}},r=t.scales||{},i=Yh(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!Ql(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=eg(t,o,ng(t,e),Pd.scales[o.type]),c=Zh(s,i),l=n.scales||{};a[t]=du(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||Yh(i,t),s=(Ad[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=Xh(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),du(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];du(t,[Pd.scales[t.type],Pd.scale])}),a}function ig(e){let t=e.options||={};t.plugins=tu(t.plugins,{}),t.scales=rg(e,t)}function ag(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function og(e){return e||={},e.data=ag(e.data),ig(e),e}var sg=new Map,cg=new Set;function lg(e,t){let n=sg.get(e);return n||(n=t(),sg.set(e,n),cg.add(n)),n}var ug=(e,t,n)=>{let r=gu(t,n);r!==void 0&&e.add(r)},dg=class{constructor(e){this._config=og(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=ag(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),ig(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return lg(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return lg(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return lg(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return lg(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>ug(s,e,t))),t.forEach(e=>ug(s,r,e)),t.forEach(e=>ug(s,Ad[i]||{},e)),t.forEach(e=>ug(s,Pd,e)),t.forEach(e=>ug(s,jd,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),cg.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,Ad[t]||{},Pd.datasets[t]||{},{type:t},Pd,jd]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=fg(this._resolverCache,e,r),s=a;if(mg(a,t)){i.$shared=!1,n=yu(n)?n():n;let t=this.createResolver(e,n,o);s=ff(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=fg(this._resolverCache,e,n);return Ql(t)?ff(i,t,void 0,r):i}};function fg(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:df(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var pg=e=>Ql(e)&&Object.getOwnPropertyNames(e).some(t=>yu(e[t]));function mg(e,t){let{isScriptable:n,isIndexable:r}=pf(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(yu(o)||pg(o))||a&&Zl(o))return!0}return!1}var hg=`4.5.1`,gg=[`top`,`bottom`,`left`,`right`,`chartArea`];function _g(e,t){return e===`top`||e===`bottom`||gg.indexOf(e)===-1&&t===`x`}function vg(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function yg(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),iu(n&&n.onComplete,[e],t)}function bg(e){let t=e.chart,n=t.options.animation;iu(n&&n.onProgress,[e],t)}function xg(e){return Vf()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var Sg={},Cg=e=>{let t=xg(e);return Object.values(Sg).filter(e=>e.canvas===t).pop()};function wg(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function Tg(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var Eg=class{static defaults=Pd;static instances=Sg;static overrides=Ad;static registry=Uh;static version=hg;static getChart=Cg;static register(...e){Uh.add(...e),Dg()}static unregister(...e){Uh.remove(...e),Dg()}constructor(e,t){let n=this.config=new dg(t),r=xg(e),i=Cg(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(_h(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=Yl(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Wh,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=od(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],Sg[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}Ep.listen(this,`complete`,yg),Ep.listen(this,`progress`,bg),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return Xl(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Uh}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():ep(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return zd(this.canvas,this.ctx),this}stop(){return Ep.stop(this),this}resize(e,t){Ep.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,ep(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),iu(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){au(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=eg(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),au(i,t=>{let i=t.options,a=i.id,o=eg(a,i),s=tu(i.type,t.dtype);(i.position===void 0||_g(i.position,o)!==_g(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(Uh.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),au(r,(e,t)=>{e||delete n[t]}),au(n,e=>{Jm.configure(this,e,e.options),Jm.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(vg(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){au(this.scales,e=>{Jm.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!bu(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)wg(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;Jm.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],au(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=Tp(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&Ud(t,r),e.controller.draw(),r&&Wd(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return Hd(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=jm.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=uf(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);vu(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),Ep.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};au(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){au(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},au(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});ou(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=xu(e),c=Tg(e,this._lastEvent,n,s);n&&(this._lastEvent=null,iu(i.onHover,[e,o,this],this),s&&iu(i.onClick,[e,o,this],this));let l=!ou(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Dg(){return au(Eg.instances,e=>e._plugins.invalidate())}function Og(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,Gu(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,Gu(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*Gu(r-n));if(u===`round`)e.arc(i,a,t,n-Su/2,r+Su/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+Su/2)+i,c=-o*Math.sin(n+Su/2)+a,l=o*Math.cos(r+Su/2)+i,u=o*Math.sin(r+Su/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function kg(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+Du,r-Du),e.closePath(),e.clip()}function Ag(e){return nf(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function jg(e,t,n,r){let i=Ag(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return qu(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:qu(i.innerStart,0,o),innerEnd:qu(i.innerEnd,0,o)}}function Mg(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Ng(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/Su)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=jg(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,ee=_-y/C,te=f+b,ne=f+x,re=g+b/te,ie=_-x/ne;if(e.beginPath(),a){let t=(w+ee)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,ee),y>0){let t=Mg(C,ee,o,s);e.arc(t.x,t.y,y,ee,_+Du)}let n=Mg(ne,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=Mg(ne,ie,o,s);e.arc(t.x,t.y,x,_+Du,ie+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=Mg(te,re,o,s);e.arc(t.x,t.y,b,re+Math.PI,g-Du)}let i=Mg(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=Mg(S,w,o,s);e.arc(t.x,t.y,v,g-Du,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(ee)*d+o,i=Math.sin(ee)*d+s;e.lineTo(r,i)}e.closePath()}function Pg(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){Ng(e,t,n,r,c,i);for(let t=0;t=Su&&p===0&&u!==`miter`&&Og(e,t,h),a||(Ng(e,t,n,r,h,i),e.stroke())}var Ig=class extends vh{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=Hu(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=tu(l,o-a),f=Ku(r,a,o)&&a!==o,p=d>=Cu||f,m=Yu(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>Cu?Math.floor(n/Cu):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(Su,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Pg(e,this,s,i,a),Fg(e,this,s,i,a),e.restore()}};function Lg(e,t,n=t){e.lineCap=tu(n.borderCapStyle,t.borderCapStyle),e.setLineDash(tu(n.borderDash,t.borderDash)),e.lineDashOffset=tu(n.borderDashOffset,t.borderDashOffset),e.lineJoin=tu(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=tu(n.borderWidth,t.borderWidth),e.strokeStyle=tu(n.borderColor,t.borderColor)}function Rg(e,t,n){e.lineTo(n.x,n.y)}function zg(e){return e.stepped?Gd:e.tension||e.cubicInterpolationMode===`monotone`?Kd:Rg}function Bg(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function Ug(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?Hg:Vg}function Wg(e){return e.stepped?ip:e.tension||e.cubicInterpolationMode===`monotone`?ap:rp}function Gg(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Lg(e,t.options),e.stroke(i)}function Kg(e,t,n,r){let{segments:i,options:a}=t,o=Ug(t);for(let s of i)Lg(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var qg=typeof Path2D==`function`;function Jg(e,t,n,r){qg&&!t.options.segment?Gg(e,t,n,r):Kg(e,t,n,r)}var Yg=class extends vh{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;Bf(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=vp(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=hp(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Wg(n),c,l;for(c=0,l=a.length;ce.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function u_(e){return c_[e%c_.length]}function d_(e){return l_[e%l_.length]}function f_(e,t){return e.borderColor=u_(t),e.backgroundColor=d_(t),++t}function p_(e,t){return e.backgroundColor=e.data.map(()=>u_(t++)),t}function m_(e,t){return e.backgroundColor=e.data.map(()=>d_(t++)),t}function h_(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof _m?t=p_(n,t):i instanceof ym?t=m_(n,t):i&&(t=f_(n,t))}}function g_(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function __(e){return e&&(e.borderColor||e.backgroundColor)}function v_(){return Pd.borderColor!==`rgba(0,0,0,0.1)`||Pd.backgroundColor!==`rgba(0,0,0,0.1)`}var y_={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=g_(r)||__(i)||a&&g_(a)||v_();if(!n.forceOverride&&o)return;let s=h_(e);r.forEach(s)}};function b_(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;dp&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function x_(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;oh&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!Xl(d)&&!Xl(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function S_(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function C_(e){e.data.datasets.forEach(e=>{S_(e)})}function w_(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=qu(Zu(t,a.axis,o).lo,0,n-1)),i=l?qu(Zu(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var T_={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){C_(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(cf([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=w_(s,c);if(d<=(n.threshold||4*r)){S_(t);return}Xl(a)&&(t._data=c,delete t.data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=b_(c,u,d,r,n);break;case`min-max`:f=x_(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){C_(e)}};function E_(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=k_(r,s,i);let c=D_(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=hp(t,c);for(let t of l){let r=D_(n,a[t.start],a[t.end],t.loop),s=mp(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:A_(c,r,`start`,Math.max)},end:{[n]:A_(c,r,`end`,Math.min)}})}}return o}function D_(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=Gu(i),a=Gu(a)),{property:e,start:i,end:a}}function O_(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=k_(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function k_(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function A_(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function j_(e,t){let n=[],r=!1;return Zl(e)?(r=!0,n=e):n=O_(e,t),n.length?new Yg({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function M_(e){return e&&e.fill!==!1}function N_(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!$l(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function P_(e,t,n){let r=R_(e);if(Ql(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return $l(i)&&Math.floor(i)===i?F_(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function F_(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function I_(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:Ql(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function L_(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:Ql(e)?e.value:t.getBaseValue(),r}function R_(e){let t=e.options,n=t.fill,r=tu(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function z_(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=B_(t,n);s.push(j_({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&Y_(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;M_(n)&&Y_(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!M_(r)||n.drawTime!==`beforeDatasetDraw`||Y_(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},rv=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},iv=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,av=class extends vh{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=iu(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=sf(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=rv(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=ov(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=cp(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=cd(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=cd(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=cd(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=cd(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;Ud(e,this),this._draw(),Wd(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Pd.color,s=cp(e.rtl,this.left,this.width),c=sf(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=rv(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=tu(n.lineWidth,1);if(r.fillStyle=tu(n.fillStyle,o),r.lineCap=tu(n.lineCap,`butt`),r.lineDashOffset=tu(n.lineDashOffset,0),r.lineJoin=tu(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=tu(n.strokeStyle,o),r.setLineDash(tu(n.lineDash,[])),a.usePointStyle){let o={radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},c=s.xPlus(e,p/2),l=t+d;Vd(r,o,c,l,a.pointStyleWidth&&p)}else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=af(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?Zd(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){Xd(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:cd(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:cd(i,this.top+y+l,this.bottom-t[0].height),line:0},lp(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=cd(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=cd(i,this.top+y+l,this.bottom-t[f.line].height));let w=s.x(S);if(g(w,C,o),S=ld(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=lv(o,e)+l}else f.y+=b}),up(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=sf(t.font),r=of(t.padding);if(!t.display)return;let i=cp(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=cd(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+cd(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=cd(o,u,u+d);a.textAlign=i.textAlign(sd(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,Xd(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=sf(e.font),n=of(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(Yu(e,this.left,this.right)&&Yu(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function cv(e,t,n){let r=e;return typeof t.text!=`string`&&(r=lv(t,n)),r}function lv(e,t){return t*(e.text?e.text.length:0)}function uv(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var dv={id:`legend`,_element:av,start(e,t,n){let r=e.legend=new av({ctx:e.ctx,options:n,chart:e});Jm.configure(e,r,n),Jm.addBox(e,r)},stop(e){Jm.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;Jm.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=of(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},fv=class extends vh{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=Zl(n.text)?n.text.length:1;this._padding=of(n.padding);let i=r*sf(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=cd(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=cd(o,r,t),s=Su*-.5):(l=i-e,u=cd(o,t,r),s=Su*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=sf(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);Xd(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:sd(t.align),textBaseline:`middle`,translation:[i,a]})}};function pv(e,t){let n=new fv({ctx:e.ctx,options:t,chart:e});Jm.configure(e,n,t),Jm.addBox(e,n),e.titleBlock=n}var mv={id:`title`,_element:fv,start(e,t,n){pv(e,n)},stop(e){let t=e.titleBlock;Jm.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;Jm.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},hv=new WeakMap,gv={id:`subtitle`,start(e,t,n){let r=new fv({ctx:e.ctx,options:n,chart:e});Jm.configure(e,r,n),Jm.addBox(e,r),hv.set(e,r)},stop(e){Jm.removeBox(e,hv.get(e)),hv.delete(e)},beforeUpdate(e,t,n){let r=hv.get(e);Jm.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`normal`},fullSize:!0,padding:0,position:`top`,text:``,weight:1500},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},_v={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` +`):e}function bv(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function xv(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=sf(t.bodyFont),l=sf(t.titleFont),u=sf(t.footerFont),d=a.length,f=i.length,p=r.length,m=of(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,au(e.title,y),n.font=c.string,au(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,au(r,e=>{au(e.before,y),au(e.lines,y),au(e.after,y)}),v=0,n.font=u.string,au(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function Sv(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function Cv(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function wv(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),Cv(l,e,t,n)&&(l=`center`),l}function Tv(e,t,n){let r=n.yAlign||t.yAlign||Sv(e,n);return{xAlign:n.xAlign||t.xAlign||wv(e,t,n,r),yAlign:r}}function Ev(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Dv(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function Ov(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=af(o),m=Ev(t,s),h=Dv(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:qu(m,0,r.width-t.width),y:qu(h,0,r.height-t.height)}}function kv(e,t,n){let r=of(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function Av(e){return vv([],yv(e))}function jv(e,t,n){return uf(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function Mv(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var Nv={beforeTitle:Jl,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=Mv(n,e);vv(t.before,yv(Pv(i,`beforeLabel`,this,e))),vv(t.lines,Pv(i,`label`,this,e)),vv(t.after,yv(Pv(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return Av(Pv(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Pv(n,`beforeFooter`,this,e),i=Pv(n,`footer`,this,e),a=Pv(n,`afterFooter`,this,e),o=[];return o=vv(o,yv(r)),o=vv(o,yv(i)),o=vv(o,yv(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),au(o,t=>{let n=Mv(e.callbacks,t);r.push(Pv(n,`labelColor`,this,t)),i.push(Pv(n,`labelPointStyle`,this,t)),a.push(Pv(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=_v[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=xv(this,n),o=Object.assign({},e,t),s=Tv(this.chart,n,o),c=Ov(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=af(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=cp(n.rtl,this.x,this.width);for(e.x=kv(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=sf(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,Zd(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),Zd(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=sf(n.bodyFont),d=u.lineHeight,f=0,p=cp(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=kv(this,h,n),t.fillStyle=n.bodyColor,au(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=_v[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=xv(this,e),o=Object.assign({},n,this._size),s=Tv(t,e,o),c=Ov(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=of(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),lp(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),up(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!ou(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!ou(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=_v[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Iv=Object.freeze({__proto__:null,Colors:y_,Decimation:T_,Filler:nv,Legend:dv,SubTitle:gv,Title:mv,Tooltip:{id:`tooltip`,_element:Fv,positioners:_v,afterInit(e,t,n){n&&(e.tooltip=new Fv({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:Nv},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Lv=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Rv(e,t,n,r){let i=e.indexOf(t);return i===-1?Lv(e,t,n,r):i===e.lastIndexOf(t)?i:n}var zv=(e,t)=>e===null?null:qu(Math.round(e),0,t);function Bv(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function Hv(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!Xl(a),_=!Xl(o),v=!Xl(c),y=(h-m)/(u+1),b=Nu((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=Nu(w*b/p/f)*f),Xl(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Lu((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=Mu(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let ee=Math.max(Vu(b),Vu(S));x=10**(Xl(s)?ee:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let te=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&Mu(n[n.length-1].value,o,Uv(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Uv(e,t,{horizontal:n,minRotation:r}){let i=zu(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Wv=class extends Rh{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return Xl(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=ju(r),t=ju(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=Hv({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Ru(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return Td(e,this.chart.options.locale,this.options.ticks.format)}},Gv=class extends Wv{static id=`linear`;static defaults={ticks:{callback:Od.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=$l(e)?e:0,this.max=$l(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=zu(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Kv=e=>Math.floor(Au(e)),qv=(e,t)=>10**(Kv(e)+t);function Jv(e){return e/10**Kv(e)==1}function Yv(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Xv(e,t){let n=Kv(t-e);for(;Yv(e,t,n)>10;)n++;for(;Yv(e,t,n)<10;)n--;return Math.min(n,Kv(e))}function Zv(e,{min:t,max:n}){t=eu(e.min,t);let r=[],i=Kv(t),a=Xv(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=eu(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=eu(e.max,f);return r.push({value:p,major:Jv(p),significand:d}),r}var Qv=class extends Rh{static id=`logarithmic`;static defaults={ticks:{callback:Od.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Wv.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return $l(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=$l(e)?Math.max(0,e):null,this.max=$l(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!$l(this._userMin)&&(this.min=e===qv(this.min,0)?qv(this.min,-1):qv(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(qv(n,-1)),a(qv(r,1)))),n<=0&&i(qv(r,-1)),r<=0&&a(qv(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Zv({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Ru(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:Td(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=Au(e),this._valueRange=Au(this.max)-Au(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(Au(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function $v(e){let t=e.ticks;if(t.display&&e.display){let e=of(t.backdropPadding);return tu(t.font&&t.font.size,Pd.font.size)+e.height}return 0}function ey(e,t,n){return n=Zl(n)?n:[n],{w:Ld(e,t.string,n),h:n.length*t.lineHeight}}function ty(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function ny(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?Su/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function iy(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(Bu(Gu(c.angle+Du))),u=ly(c.y,s.h,l),d=sy(l),f=cy(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function ay(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(Hd({x:n,y:r},t)||Hd({x:n,y:a},t)||Hd({x:i,y:r},t)||Hd({x:i,y:a},t))}function oy(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:$v(a)/2,additionalAngle:o?Su/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function uy(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!Xl(s)){let n=af(t.borderRadius),c=of(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),Zd(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function dy(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));uy(n,a,t);let o=sf(a.font),{x:s,y:c,textAlign:l}=t;Xd(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function fy(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,Cu);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=iu(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?ny(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=Cu/(this._pointLabels.length||1),n=this.options.startAngle||0;return Gu(e*t+zu(n))}getDistanceFromCenterForValue(e){if(Xl(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(Xl(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);py(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=sf(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=of(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}Xd(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},gy={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},_y=Object.keys(gy);function vy(e,t){return e-t}function yy(e,t){if(Xl(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),$l(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Iu(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function by(e,t,n,r){let i=_y.length;for(let a=_y.indexOf(e);a=_y.indexOf(n);a--){let n=_y[a];if(gy[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return _y[n?_y.indexOf(n):0]}function Sy(e){for(let t=_y.indexOf(e)+1,n=_y.length;t=t?n[r]:n[i];e[a]=!0}}function wy(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function Ty(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=qu(t,0,a),n=qu(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||by(i.minUnit,t,n,this._getLabelCapacity(t)),o=tu(r.ticks.stepSize,1),s=a===`week`&&i.isoWeekday,c=Iu(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return iu(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=Zu(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=Zu(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var Oy=class extends Ey{static id=`timeseries`;static defaults=Ey.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=Dy(t,this.min),this._tableRange=Dy(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(Dy(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return Dy(this._table,n*this._tableRange+this._minPos,!0)}},ky=[bm,s_,Iv,Object.freeze({__proto__:null,CategoryScale:Vv,LinearScale:Gv,LogarithmicScale:Qv,RadialLinearScale:hy,TimeScale:Ey,TimeSeriesScale:Oy})];Eg.register(...ky);var Ay=Eg,jy=R(``);function My(e,t){E(t,!0);let n=G(t,`class`,3,``),r=G(t,`ariaLabel`,3,``);function i(e){if(Aa.tick,typeof t.build!=`function`)return;let n=t.build();if(!n)return;let r=new Ay(e.getContext(`2d`),n);return()=>r.destroy()}var a=jy();Pi(a,()=>i),F(()=>{U(a,1,Li(n())),W(a,`aria-label`,r())}),z(e,a),D()}var Ny=R(``),Py=R(`
                    `);function Fy(e,t){E(t,!0);let n=G(t,`options`,19,()=>[]),r=G(t,`ariaLabel`,3,``),i=G(t,`class`,3,``);var a=Py();H(a,21,n,e=>e.value,(e,n)=>{var r=Ny();let i;var a=M(r,!0);T(r),F(()=>{i=U(r,1,`segmented-btn svelte-92fh5i`,null,i,{active:t.value===I(n).value}),W(r,`aria-pressed`,t.value===I(n).value),B(a,I(n).label)}),L(`click`,r,()=>t.onchange?.(I(n).value)),z(e,r)}),T(a),F(()=>{U(a,1,Li([`segmented-control`,i()]),`svelte-92fh5i`),W(a,`aria-label`,r())}),z(e,a),D()}Hr([`click`]);function Iy(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Ly(){return{grid:Iy(`--chart-grid`),text:Iy(`--chart-text`),dayMarker:Iy(`--chart-day-marker`),tooltipBg:Iy(`--chart-tooltip-bg`),tooltipBorder:Iy(`--chart-tooltip-border`),tooltipText:Iy(`--chart-tooltip-text`)}}function Ry(){return{size:11,family:`'SF Mono', Menlo, Consolas, monospace`}}function zy(e,t){return{backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,borderWidth:1,titleColor:e.tooltipText,bodyColor:e.tooltipText,callbacks:t}}function By(e){if(typeof document>`u`||!document.body)return e;let t=document.createElement(`span`);t.style.display=`none`,t.style.color=e,document.body.appendChild(t);let n=getComputedStyle(t).color;return document.body.removeChild(t),n||e}var Vy=[`#c2845a`,`#7a9e7e`,`#d4a574`,`#b8a98e`,`#8b9e6b`,`#7d8a97`,`#c47a5a`,`#6b8e6b`,`#a09486`,`#9b7ea4`,`#c49a6c`];function Hy(){return[...Vy]}function Uy(e){let t=5381,n=String(e||``);for(let e=0;edc(e)}}var Yy={seconds:{apiName:`second`,windowLabel:`Last 60 seconds`,refreshMs:2e3},minutes:{apiName:`minute`,windowLabel:`Last 60 minutes`,refreshMs:5e3},hours:{apiName:`hour`,windowLabel:`Last 24 hours`,refreshMs:2e4},days:{apiName:`day`,windowLabel:`Last 30 days`,refreshMs:6e4}},Xy=[{value:`seconds`,label:`Seconds`},{value:`minutes`,label:`Minutes`},{value:`hours`,label:`Hours`},{value:`days`,label:`Days`}];function Zy(){return{input:0,output:0,prompt:0,local:0}}function Qy(e){return String(e).padStart(2,`0`)}function $y(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function eb(e,t){if(!Number.isFinite(t))return``;let n=new Date(t);switch(e){case`seconds`:return Qy(n.getHours())+`:`+Qy(n.getMinutes())+`:`+Qy(n.getSeconds());case`minutes`:return Qy(n.getHours())+`:`+Qy(n.getMinutes());case`hours`:return Qy(n.getHours())+`:00`;default:return Qy(n.getMonth()+1)+`-`+Qy(n.getDate())}}function tb(e,t){let n=[],r=[],i={input:[],output:[],prompt:[],local:[]},a=Zy();for(let o of e||[]){let e=Date.parse(o&&o.start),s=$y(o&&o.input_tokens),c=$y(o&&o.output_tokens),l=$y(o&&o.prompt_cached_tokens),u=$y(o&&o.locally_cached_tokens);n.push(eb(t,e)),r.push(Number.isFinite(e)?e:null),i.input.push(s),i.output.push(c),i.prompt.push(l),i.local.push(u),a.input+=s,a.output+=c,a.prompt+=l,a.local+=u}return{labels:n,stamps:r,cols:i,totals:a}}function nb(e){let t=e||Zy();return t.input+t.output+t.prompt+t.local>0}function rb(e,t){return dc(Math.max(0,Math.round(e&&e[t]||0)))}function ib(e){return(Yy[e]||Yy.minutes).windowLabel}function ab(e,t){return`Live token throughput, `+ib(t).toLowerCase()+`. Input `+rb(e,`input`)+`, output `+rb(e,`output`)+`, prompt cached `+rb(e,`prompt`)+`, locally cached `+rb(e,`local`)+` tokens.`}function ob(e,t,n,r){let i=e=>dc(Math.max(0,Math.round(e))),a=n.stamps,o=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderWidth:0,borderRadius:0,categoryPercentage:1,barPercentage:1,stack:`tokens`});return{type:`bar`,plugins:[{id:`liveTokensDayMarks`,afterDatasetsDraw:t=>{if(r===`days`)return;let n=t.getDatasetMeta(0),i=t.chartArea;if(!n||!n.data||!i)return;let o=t.ctx;o.save(),o.font=`10px 'SF Mono', Menlo, Consolas, monospace`;let s=null;for(let t=0;t{if(!e.length)return``;let t=a[e[0].dataIndex];if(!t)return e[0].label;let n=new Date(t);return r===`days`?n.toLocaleDateString():n.toLocaleString()},label:e=>e.dataset.label+`: `+i(e.parsed.y),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+i(t)}})}}}}var sb=900,cb=new class{#e=k(`minutes`);get granularity(){return I(this.#e)}set granularity(e){A(this.#e,e,!0)}#t=k(j([]));get buckets(){return I(this.#t)}set buckets(e){A(this.#t,e,!0)}#n=k(!1);get active(){return I(this.#n)}set active(e){A(this.#n,e,!0)}#r=null;#i=null;#a=null;#o=0;#s=null;#c=!1;start(){this.stop(),this.active=!0,this.fetch(),this.#l(),this.#u()}stop(){this.active=!1,this.#r&&=(clearInterval(this.#r),null),this.#i&&=(clearTimeout(this.#i),null),this.#a&&=(clearTimeout(this.#a),null),this.#o=0,this.#s&&=(this.#s.abort(),null),this.buckets=[]}setGranularity(e){!Yy[e]||e===this.granularity||(this.granularity=e,this.buckets=[],this.#l(),this.fetch())}#l(){this.#r&&=(clearInterval(this.#r),null);let e=Yy[this.granularity]||Yy.minutes;this.#r=setInterval(()=>{this.active&&this.fetch()},e.refreshMs)}noteUsageEvent(e){!this.active||e!==`usage.flushed`||(this.#i||=setTimeout(()=>{this.#i=null,this.fetch()},sb))}async fetch(){if(!this.active||this.#c)return;this.#c=!0;let e=this.granularity;try{let t=await vs(`/admin/usage/throughput?granularity=`+(Yy[e]||Yy.minutes).apiName,{label:`token throughput`});if(t.stale||!t.ok||this.granularity!==e)return;this.buckets=t.data&&Array.isArray(t.data.buckets)?t.data.buckets:[]}catch(e){if(bs(e))return;console.error(`Failed to fetch token throughput:`,e)}finally{this.#c=!1,this.active&&this.granularity!==e&&this.fetch()}}async#u(){await Cs.ensureLoaded(),this.active&&Cs.liveLogsVisible()&&(typeof ReadableStream>`u`||(this.#s&&this.#s.abort(),this.#s=new AbortController,this.#d(this.#s)))}async#d(e){try{let t=await gs(`/admin/live/logs?types=usage`,{signal:e.signal});if(!t.ok||!t.body||typeof t.body.getReader!=`function`){this.#p();return}this.#o=0,await Gy(t.body.getReader(),e=>this.#f(e)),this.#p()}catch(e){if(bs(e))return;console.error(`Live usage stream failed:`,e),this.#p()}}#f(e){if(!e||typeof e!=`object`)return;let t=String(e.type||``).trim();t.indexOf(`usage.`)===0&&this.noteUsageEvent(t)}#p(){if(!this.active||this.#a)return;let{attempt:e,delay:t}=qy(this.#o);this.#o=e,this.#a=setTimeout(()=>{this.#a=null,this.#u()},t)}},lb=R(`
                    `),ub=R(`
                    Waiting for live requests…
                    `),db=R(`

                    Live Token Throughput

                    `);function fb(e,t){E(t,!0);let n=O(()=>tb(cb.buckets,cb.granularity)),r=O(()=>I(n).totals);function i(){return{input:By(`var(--token-input)`),output:By(`var(--token-output)`),prompt:By(`var(--token-prompt)`),local:By(`var(--token-local)`)}}let a=[{metric:`input`,label:`Input Tokens`,colorVar:`--token-input`},{metric:`output`,label:`Output Tokens`,colorVar:`--token-output`},{metric:`prompt`,label:`Prompt (Input) Cached`,colorVar:`--token-prompt`},{metric:`local`,label:`Locally Cached`,colorVar:`--token-local`}];var o=db(),s=M(o),c=M(s),l=P(M(c),2),u=M(l);let d;var f=P(u,2),p=M(f,!0);T(f),T(l),T(c),Fy(P(c,2),{ariaLabel:`Live token throughput granularity`,get options(){return Xy},get value(){return cb.granularity},onchange:e=>cb.setGranularity(e)}),T(s);var m=P(s,2);H(m,21,()=>a,e=>e.metric,(e,t)=>{var n=lb(),i=M(n),a=P(i,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{Wi(i,`background: var(${I(t).colorVar??``})`),B(o,I(t).label),B(c,e)},[()=>rb(I(r),I(t).metric)]),z(e,n)}),T(m);var h=P(m,2),g=M(h);{let e=O(()=>ab(I(r),cb.granularity));My(g,{get ariaLabel(){return I(e)},build:()=>ob(Ly(),i(),I(n),cb.granularity)})}var _=P(g,2),v=e=>{z(e,ub())},y=O(()=>!nb(I(r)));V(_,e=>{I(y)&&e(v)}),T(h),T(o),F(e=>{d=U(u,1,`live-dot`,null,d,{"is-streaming":cb.active}),B(p,e)},[()=>ib(cb.granularity)]),z(e,o),D()}function pb(e){let t=e||{};if(t.total_tokens!==null&&t.total_tokens!==void 0){let e=Number(t.total_tokens);if(Number.isFinite(e))return e}let n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function mb(e,t){if(!t)return 0;let n=e&&e.summary?e.summary:{},r=Number(n.total_hits||0);return Number.isFinite(r)&&r>0?r:0}function hb(e,t,n){let r=Number(e&&e.total_requests||0);return(Number.isFinite(r)?r:0)+mb(t,n)}function gb(e,t,n){let r=mb(t,n);return r<=0?``:sc(hb(e,t,n)-r)+` to providers + `+sc(r)+` from cache`}function _b(e){let t=e&&e.summary?e.summary:{},n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function vb(e,t,n){let r=e=>{let t=Number(e||0);return Number.isFinite(t)&&t>0?t:0},i=e||{},a=r(i.uncached_input_tokens),o=r(i.cached_input_tokens),s=r(i.cache_write_input_tokens),c=t&&t.summary?t.summary:{},l=n?r(c.total_input_tokens):0;return[{key:`uncached`,label:`Regular`,tokens:a+s,colorVar:`--cache-meter-uncached`,note:s>0?`Includes `+sc(s)+` cache-write tokens`:``},{key:`prompt`,label:`Prompt cached`,tokens:o,colorVar:`--cache-meter-prompt`,note:`Provider prompt-cache reads`},{key:`local`,label:`Locally cached`,tokens:l,colorVar:`--cache-meter-local`,note:`Served from GoModel response cache`}]}function yb(e,t,n){return vb(e,t,n).reduce((e,t)=>e+t.tokens,0)}function bb(e,t,n){return yb(e,t,n)>0}function xb(e,t,n){let r=vb(e,t,n),i=r.reduce((e,t)=>e+t.tokens,0);if(i<=0)return r.map(e=>Object.assign({},e,{pct:0}));let a=r.map(e=>{let t=e.tokens/i*100,n=Math.floor(t);return Object.assign({},e,{pct:n,remainder:t-n})}),o=100-a.reduce((e,t)=>e+t.pct,0);return a.map((e,t)=>({index:t,remainder:e.remainder,tokens:e.tokens})).filter(e=>e.tokens>0).sort((e,t)=>t.remainder-e.remainder).forEach(e=>{o>0&&(a[e.index].pct+=1,--o)}),a}function Sb(e,t,n){return xb(e,t,n).filter(e=>e.tokens>0)}function Cb(e){let t=[e.label+`: `+sc(e.tokens)+` input tokens (`+e.pct+`%)`];return e.note&&t.push(e.note),t.join(` +`)}function wb(e){let t=(e||[]).map(e=>e.label+` `+e.pct+`%`);return`Cache breakdown of input tokens — `+(t.length?t.join(`, `):`no data`)}function Tb(e){return e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`)}function Eb(e,t,n,r){if(t!==`daily`||!n||!r)return e;let i={};(e||[]).forEach(e=>{i[e.date]=e});let a=[];for(let e=new Date(n);e<=r;e.setUTCDate(e.getUTCDate()+1)){let t=Tb(e);a.push(i[t]||{date:t,input_tokens:0,output_tokens:0,total_tokens:0,requests:0,input_cost:null,output_cost:null,total_cost:null})}return a}function Db(e,t){let n=e=>Number(e)||0,r=e.map(e=>e.date),i=e.map(e=>n(e.uncached_input_tokens)+n(e.cache_write_input_tokens)+n(e.cached_input_tokens)>0?n(e.uncached_input_tokens)+n(e.cache_write_input_tokens):n(e.input_tokens)),a=e.map(e=>n(e.output_tokens)),o=e.map(e=>n(e.cached_input_tokens)),s={};return(t||[]).forEach(e=>{s[e.date]=e}),{labels:r,inputPaid:i,output:a,prompt:o,local:r.map(e=>{let t=s[e];return t?n(t.input_tokens)+n(t.output_tokens):0})}}function Ob(e){let t=e||{},n=Math.max(0,Number(t.uncached_input_tokens)||0),r=Math.max(0,Number(t.cached_input_tokens)||0),i=Math.max(0,Number(t.cache_write_input_tokens)||0),a=n+r+i;return a>0?r/a*100:0}function kb(e){let t=e||{};return(Number(t.uncached_input_tokens)||0)+(Number(t.cached_input_tokens)||0)+(Number(t.cache_write_input_tokens)||0)>0}function Ab(e){return kb(e)?Math.round(Ob(e))+`%`:`—`}function jb(e,t,n={}){let r=!!n.cacheEnabled,i=n.resolve||(e=>e),a=(e,t)=>i(`color-mix(in srgb, `+e+` `+t+`%, transparent)`),o=(e,t,n,r)=>Object.assign({label:e,data:t,borderColor:n,backgroundColor:n,fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4},r||{}),s=[o(`Input Tokens`,t.inputPaid,i(`var(--token-input)`),{fill:`origin`}),o(`Output Tokens`,t.output,i(`var(--token-output)`),{fill:`-1`}),o(`Prompt (Input) Cached`,t.prompt,i(`var(--token-prompt)`),{fill:`-1`,borderDash:[6,4]})];return r&&s.push(o(`Locally Cached`,t.local,a(`var(--info)`,35),{fill:`-1`,borderDash:[2,3]})),{type:`line`,data:{labels:t.labels,datasets:s},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:zy(e,{label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ry(),maxRotation:0,autoSkip:!0,maxTicksLimit:10}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:Jy(e)}}}}}function Mb(e,t,n){let r=Math.max(0,Math.min(100,e));return{type:`doughnut`,data:{datasets:[{data:[r,100-r],backgroundColor:[t,n],borderWidth:0,spacing:0}]},options:{rotation:-90,circumference:180,cutout:`84%`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:1},events:[],plugins:{legend:{display:!1},tooltip:{enabled:!1}}}}}var Nb=`gomodel_provider_status_details_expanded`,Pb=`gomodel_provider_card_expanded_overrides`,Fb=3e3,Ib=`https://gomodel.enterpilot.io/docs/providers/`,Lb={anthropic:`anthropic`,azure:`azure`,bailian:`bailian`,bedrock:`bedrock`,"bedrock-mantle":`bedrock-mantle`,cohere:`cohere`,deepseek:`deepseek`,gemini:`gemini`,opencode_go:`opencode-go`,oracle:`oracle`,vertex:`vertex`,vllm:`vllm`,xiaomi:`xiaomi`};function Rb(){return{summary:{total:0,healthy:0,degraded:0,unhealthy:0,overall_status:`degraded`},providers:[]}}function zb(e){let t={detailsExpanded:!1,cardOverrides:{}};try{if(e){let n=e.getItem(Nb);n===`true`||n===`false`?t.detailsExpanded=n===`true`:e.setItem(Nb,`false`);let r=JSON.parse(e.getItem(Pb)||`{}`);r&&typeof r==`object`&&!Array.isArray(r)&&(t.cardOverrides=r)}}catch{}return t}function Bb(e,t){if(e)try{e.setItem(Nb,t?`true`:`false`)}catch{}}function Vb(e,t){if(e)try{e.setItem(Pb,JSON.stringify(t))}catch{}}function Hb(e,t,n){let r=n&&n.name?String(n.name):``;return r&&Object.prototype.hasOwnProperty.call(e,r)?e[r]===!0:t}function Ub(e){return`is-`+(String(e&&e.overall_status||`degraded`).trim()||`degraded`)}function Wb(e){return`is-`+(String(e||`degraded`).trim()||`degraded`)}function Gb(e){let t=e||{};return String(t.healthy||0)+`/`+String(t.total||0)}function Kb(e){let t=e||{},n=Number(t.total||0),r=Number(t.healthy||0);return n>0&&rString(e&&e.status_label||``).trim().toLowerCase()===`starting`)}function Yb(e){if(!e||!e.runtime)return``;let t=e.runtime.last_model_fetch_at||``,n=e.runtime.last_availability_check_at||``;return t?n&&Date.parse(n)>Date.parse(t)?n:t:n}function Xb(e,t){let n=Yb(e);if(!n||typeof t!=`function`)return`-`;let r=t(n);if(!r||r===`-`)return`-`;let i=String(r).split(` `);return i.length>1?i.slice(1).join(` `):r}function Zb(e,t){let n=Yb(e);return n?typeof t==`function`?t(n):String(n):``}function Qb(e){if(!e)return``;let t=String(e.name||``).trim(),n=String(e.type||e.config&&e.config.type||``).trim();return!n||n===t?``:n}function $b(e){let t=String(e&&(e.type||e.config&&e.config.type)||``).trim().toLowerCase(),n=t?Lb[t]:``;return n?Ib+n+`?utm_source=gomodel_dashboard`:``}function ex(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.retry:null;return t?String(t.max_retries)+` retries, `+t.initial_backoff+` initial, `+t.max_backoff+` max, factor `+t.backoff_factor+`, jitter `+t.jitter_factor:`-`}function tx(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.circuit_breaker:null;return t?String(t.failure_threshold)+` fail, `+String(t.success_threshold)+` success, `+t.timeout+` timeout`:`-`}function nx(e){let t=e&&e.config&&Array.isArray(e.config.models)?e.config.models.filter(Boolean):[];return t.length===0?`Automatic`:t.join(`, `)}function rx(e){if(!e)return``;let t=[];return e.status_reason&&t.push(String(e.status_reason)),e.last_error&&t.push(`Last error: `+String(e.last_error)),t.join(` + +`)}function ix(e){let t=e&&e.request_health;return t&&typeof t==`object`?t:null}function ax(e){let t=ix(e);return t?String(t.circuit_state||``).trim():``}function ox(e){let t=ax(e);return t?t.charAt(0).toUpperCase()+t.slice(1):``}function sx(e){let t=ax(e);return t===`open`?`is-unhealthy`:t===`half-open`?`is-degraded`:`is-healthy`}function cx(e){let t=ix(e);if(!t)return``;let n=Number(t.requests||0),r=Number(t.errors||0),i=Math.round(Number(t.window_seconds||0)/60),a=i>0?`last `+i+` min`:`recent`;return String(n)+` request`+(n===1?``:`s`)+` · `+String(r)+` error`+(r===1?``:`s`)+` (`+a+`)`}function lx(e){let t=ix(e);return t&&Array.isArray(t.models)?t.models:[]}function ux(e){return e?String(Number(e.errors||0))+`/`+String(Number(e.requests||0))+` failed`:``}function dx(e){let t=e&&e.last_error;return!t||!t.message?``:(t.status_code?`HTTP `+String(t.status_code)+`: `:``)+t.message}function fx(){return{name:``,slug:``,url:``,transport:`http`,description:``,enabled:!0,headers:[],allowed_tools:``,disallowed_tools:``,user_paths:``,tool_timeout_seconds:``}}function px(){return{server:``,status:``,instructions:``,tools:[],prompts:[],resources:[],templates:[]}}function mx(e){return String(e&&(e.slug||e.name)||``).trim()}function hx(e){return String(e&&e.status||``).trim()||`connecting`}function gx(e){switch(hx(e)){case`connected`:return`status-success`;case`degraded`:return String(e&&e.last_error||``).trim()?`status-error`:`status-warning`;case`connecting`:return`status-neutral`;default:return`status-unknown`}}function _x(e,t){let n=hx(e),r=String(e&&e.last_error||``).trim();return r&&n!==`connected`?r:n===`connected`&&e&&e.connected_at?`Connected since `+(typeof t==`function`?t:String)(e.connected_at):``}function vx(e){return String(e&&e.transport||``)===`stdio`?`local command`:String(e&&e.url||``).trim()||`—`}function yx(e){let t=Number(e&&e.prompt_count||0),n=Number(e&&e.resource_count||0);return t+` prompts · `+n+` resources`}function bx(e){let t=String(e||``).normalize(`NFKD`).toLowerCase(),n=t.replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/-+$/g,``);if(n)return n;let r=2166136261;for(let e of t)r=Math.imul((r^e.codePointAt(0))>>>0,16777619)>>>0;return`mcp-`+r.toString(16).padStart(8,`0`)}function xx(e){return String(e||``).split(` +`).map(e=>e.trim()).filter(e=>e)}function Sx(e){return!e||typeof e!=`object`||Array.isArray(e)?[]:Object.keys(e).sort().map(t=>({name:t,value:String(e[t]||``)}))}function Cx(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=String(e&&e.name||``).trim();n&&(t[n]=String(e&&e.value||``))}),t}function wx(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.slug,e.url,e.transport,e.description,e.status].some(e=>String(e||``).toLowerCase().includes(r)))}function Tx(e){return{name:String(e.name||``).trim(),slug:mx(e),url:String(e.url||``).trim(),transport:e.transport===`sse`?`sse`:`http`,description:String(e.description||``).trim(),enabled:e.enabled!==!1,headers:Sx(e.headers),allowed_tools:(Array.isArray(e.allowed_tools)?e.allowed_tools:[]).join(`, `),disallowed_tools:(Array.isArray(e.disallowed_tools)?e.disallowed_tools:[]).join(`, `),user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` +`),tool_timeout_seconds:e.tool_timeout_seconds?String(e.tool_timeout_seconds):``}}function Ex(e,t,n){let r=String(e.name||``).trim(),i=String(e.slug||bx(r)).trim().toLowerCase(),a=String(e.url||``).trim(),o=e.transport===`sse`?`sse`:`http`;if(!r)return{error:`Name is required.`};if(!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(i))return{error:`Slug must use 1–64 lowercase ASCII letters, numbers, hyphens, or underscores.`};if(t===`create`&&(n||[]).some(e=>mx(e)===i))return{error:`Slug "`+i+`" is already in use.`};if(!a)return{error:`URL is required.`};let s,c=String(e.tool_timeout_seconds||``).trim();if(c!==``){let e=Number(c);if(!Number.isSafeInteger(e)||e<0)return{error:`Tool timeout must be a non-negative whole number of seconds.`};s=e}return{payload:{name:r,slug:i,url:a,transport:o,headers:Cx(e.headers),description:String(e.description||``).trim(),enabled:!!e.enabled,allowed_tools:ac(e.allowed_tools),disallowed_tools:ac(e.disallowed_tools),user_paths:xx(e.user_paths),tool_timeout_seconds:s}}}function Dx(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=e=>(Array.isArray(e)?e:[]).filter(e=>e&&typeof e==`object`);return{server:String(n.server||e||``).trim(),status:String(n.status||``).trim(),instructions:String(n.instructions||``).trim(),tools:r(n.tools),prompts:r(n.prompts),resources:r(n.resources),templates:r(n.templates)}}function Ox(e,t){return String(e&&e.server||``)+`_`+String(t||``)}function kx(e){let t=e||px(),n=(e,t)=>{let n=String(e||``).trim(),r=String(t||``).trim();return n&&r?n+` — `+r:r||n},r=e=>n=>({key:e+`:`+String(n.name||``),name:String(n.name||``),aggregated:Ox(t,n.name),description:String(n.description||``).trim()});return[{key:`tools`,title:`Tools`,items:(t.tools||[]).map(r(`tool`))},{key:`prompts`,title:`Prompts`,items:(t.prompts||[]).map(r(`prompt`))},{key:`resources`,title:`Resources`,items:(t.resources||[]).map(e=>({key:`resource:`+String(e.uri||``),name:String(e.uri||``),aggregated:``,description:n(e.name,e.description)}))},{key:`templates`,title:`Resource templates`,items:(t.templates||[]).map(e=>({key:`template:`+String(e.uri_template||``),name:String(e.uri_template||``),aggregated:``,description:n(e.name,e.description)}))}].filter(e=>e.items.length>0)}function Ax(e){return kx(e).length===0}function jx(e){return(e||[]).length}function Mx(e){return(e||[]).filter(e=>hx(e)===`connected`).length}function Nx(e){return(e||[]).filter(e=>e&&e.enabled!==!1&&hx(e)===`degraded`).length}function Px(e,t){return!!e&&jx(t)>0}function Fx(e){return String(Mx(e))+`/`+String(jx(e))}function Ix(e){return Nx(e)>0?`is-degraded`:`is-healthy`}function Lx(e){let t=Nx(e);if(t>0)return String(t)+` server`+(t===1?``:`s`)+` need`+(t===1?`s`:``)+` attention`;let n=jx(e),r=Mx(e);return n>0&&r===n?`All MCP servers connected`:String(r)+` of `+String(n)+` server`+(n===1?``:`s`)+` connected`}function Rx(){return{interval:`day`,buckets:[],summary:{requests:0},provider_latency:[]}}function zx(e){let t=e&&typeof e==`object`?e:{};return{interval:t.interval===`hour`?`hour`:`day`,buckets:Array.isArray(t.buckets)?t.buckets:[],summary:t.summary&&typeof t.summary==`object`?t.summary:{requests:0},provider_latency:Array.isArray(t.provider_latency)?t.provider_latency:[]}}function Bx(e){return Number(e&&e.summary&&e.summary.requests||0)>0}function Vx(e){return(e&&Array.isArray(e.provider_latency)?e.provider_latency:[]).length>0}function Hx(e){let t=e&&e.summary?e.summary.success_rate:null;return t==null?`—`:(Math.round(Number(t)*1e3)/10).toFixed(1)+`%`}function Ux(e,t){return Number(e&&e.summary&&e.summary[t]||0)}function Wx(e){let t=Number(e);return Number.isFinite(t)?t>=6e4?(t/6e4).toFixed(1)+` min`:t>=1e3?(t/1e3).toFixed(2)+` s`:Math.round(t)+` ms`:`-`}function Gx(e){let t=e&&e.summary?e.summary.avg_duration_ms:null;return t==null?`—`:Wx(Number(t))}function Kx(e,t){try{let n={};return new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,hourCycle:`h23`}).formatToParts(e).forEach(e=>{n[e.type]=e.value}),{year:n.year,month:n.month,day:n.day,hour:Number(n.hour)}}catch{return{year:String(e.getFullYear()),month:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()],day:String(e.getDate()),hour:e.getHours()}}}function qx(e,t,n){let r=new Date(e.start);if(Number.isNaN(r.getTime()))return String(e.start||``);let i=Kx(r,n),a=i.month+` `+i.day;return t!==`hour`||i.hour===0?a:String(i.hour).padStart(2,`0`)+`:00`}function Jx(e,t,n,r){let i=new Date(e.start);if(Number.isNaN(i.getTime()))return String(e.start||``);if(t===`hour`)return r(e.start);let a=Kx(i,n);return a.month+` `+a.day+`, `+a.year}function Yx(e){return{ok:e(`var(--success)`),clientError:e(`var(--warning)`),serverError:e(`var(--danger)`),other:e(`color-mix(in srgb, var(--text-muted) 55%, transparent)`)}}function Xx(e,t,n={}){let r=n.interval===`hour`?`hour`:`day`,i=n.zone,a=n.resolve||(e=>e),o=n.formatTimestamp||(e=>String(e)),s=t.map(e=>qx(e,r,i)),c=Yx(a),l=a(`var(--bg-surface)`),u=e=>Number(e)||0,d=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:l,borderWidth:1,borderSkipped:!1,borderRadius:2,maxBarThickness:28}),f=[d(`2xx`,t.map(e=>u(e.status_2xx)),c.ok),d(`4xx`,t.map(e=>u(e.status_4xx)),c.clientError),d(`5xx`,t.map(e=>u(e.status_5xx)),c.serverError)];return t.some(e=>u(e.status_other)>0)&&f.push(d(`Other`,t.map(e=>u(e.status_other)),c.other)),{type:`bar`,data:{labels:s,datasets:f},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:zy(e,{title:e=>e.length?Jx(t[e[0].dataIndex],r,i,o):``,label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Ry(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ry(),precision:0,callback:e=>dc(e)}}}}}}function Zx(e=Hy()){let t={};return function(n){return n in t||(t[n]=e[Object.keys(t).length%e.length]),t[n]}}function Qx(e,t,n,r={}){let i=r.interval===`hour`?`hour`:`day`,a=r.zone,o=r.formatTimestamp||(e=>String(e)),s=r.providerColor||Zx();return{type:`line`,data:{labels:t.map(e=>qx(e,i,a)),datasets:n.map(e=>({label:e.provider,data:(e.avg_duration_ms||[]).map(e=>e==null?null:Number(e)),borderColor:s(e.provider),backgroundColor:s(e.provider),fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4,spanGaps:i===`hour`&&2}))},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:zy(e,{title:e=>e.length?Jx(t[e[0].dataIndex],i,a,o):``,label:e=>{let t=(n[e.datasetIndex]&&n[e.datasetIndex].requests||[])[e.dataIndex],r=Number(t)||0;return e.dataset.label+`: `+Wx(e.parsed.y)+(r>0?` (`+r.toLocaleString()+` req)`:``)}})},scales:{x:{grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ry(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ry(),callback:e=>Wx(e)}}}}}}var $x=class{#e=k(j(Rb()));get status(){return I(this.#e)}set status(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=k(!1);get loadedOnce(){return I(this.#n)}set loadedOnce(e){A(this.#n,e,!0)}#r=k(!1);get detailsExpanded(){return I(this.#r)}set detailsExpanded(e){A(this.#r,e,!0)}#i=k(j({}));get cardOverrides(){return I(this.#i)}set cardOverrides(e){A(this.#i,e,!0)}#a=null;#o=null;#s=!1;initPreferences(){if(this.#s)return;this.#s=!0;let e=zb(Ta());this.detailsExpanded=e.detailsExpanded,this.cardOverrides=e.cardOverrides}cardExpanded(e){return Hb(this.cardOverrides,this.detailsExpanded,e)}toggleCard(e){let t=e&&e.name?String(e.name):``;if(!t)return;let n={...this.cardOverrides};n[t]=!this.cardExpanded(e),this.cardOverrides=n,Vb(Ta(),this.cardOverrides)}toggleDetails(){this.detailsExpanded=!this.detailsExpanded,this.cardOverrides={},Bb(Ta(),this.detailsExpanded),Vb(Ta(),this.cardOverrides)}detailsToggleLabel(){return this.detailsExpanded?`Show Details`:`Hide Details`}async fetch(){this.initPreferences(),this.#a&&this.#a.abort();let e=new AbortController;this.#a=e,this.loading=!0;try{let t=await vs(`/admin/providers/status`,{label:`provider status`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.status=Rb(),this.#l();return}let n=t.data&&typeof t.data==`object`?t.data:Rb();n.summary||=Rb().summary,Array.isArray(n.providers)||(n.providers=[]),this.status=n,this.#c()}catch(e){if(bs(e))return;console.error(`Failed to fetch provider status:`,e),this.status=Rb(),this.#l()}finally{this.#a===e&&(this.#a=null,this.loading=!1,this.loadedOnce=!0)}}#c(){this.#l(),Jb(this.status.providers)&&(this.#o=setTimeout(()=>{this.#o=null,this.fetch()},Fb))}#l(){this.#o&&=(clearTimeout(this.#o),null)}stopPolling(){this.#l()}},eS=class{#e=k(j(Rx()));get stats(){return I(this.#e)}set stats(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=0;async fetch(){let e=++this.#n;this.loading=!0;try{let t=await vs(`/admin/audit/stats?`+Nc.queryStr(),{label:`audit stats`});if(t.stale||e!==this.#n)return;if(!t.ok){this.stats=Rx();return}this.stats=zx(t.data)}catch(t){if(console.error(`Failed to fetch audit stats:`,t),e!==this.#n)return;this.stats=Rx()}finally{e===this.#n&&(this.loading=!1)}}},tS=class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!1);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}async fetch(){if(await Cs.ensureLoaded(),!Cs.mcpVisible()){this.available=!1,this.servers=[];return}this.loading=!0;try{let e=await vs(`/admin/mcp-servers`,{label:`mcp servers`});if(e.stale)return;if(e.status===503||e.status===404){this.available=!1,this.servers=[];return}if(this.available=!0,!e.ok){this.servers=[];return}this.servers=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch MCP servers:`,e),this.servers=[]}finally{this.loading=!1}}},nS=class{#e=k(j([]));get data(){return I(this.#e)}set data(e){A(this.#e,e,!0)}#t=k(`tokens`);get mode(){return I(this.#t)}set mode(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=null;async fetch(){this.#r&&this.#r.abort();let e=new AbortController;this.#r=e,this.loading=!0;try{let t=await vs(`/admin/usage/daily?days=365&interval=daily`,{label:`calendar`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.data=[];return}this.data=Array.isArray(t.data)?t.data:[]}catch(e){if(bs(e))return;console.error(`Failed to fetch calendar data:`,e),this.data=[]}finally{this.#r===e&&(this.#r=null,this.loading=!1)}}},rS=new $x,iS=new eS,aS=new tS,oS=new nS,sS=(e,t=f,n=f,r=f,i=f)=>{var a=lS(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=M(c),u=M(l),d=M(u,!0);T(u),Ue(),T(l);var p=P(l,4),m=M(p),h=M(m,!0);T(m),Ue(),T(p);var g=P(p,4),_=M(g,!0);T(g),T(c),T(a),F((e,n,r,i,a,o)=>{B(s,t()),W(l,`title`,e),B(d,n),W(p,`title`,r),B(h,i),W(g,`title`,a),B(_,o)},[()=>fc(`Input tokens`,n()),()=>dc(n()),()=>fc(`Output tokens`,r()),()=>dc(r()),()=>fc(`Total tokens`,i()),()=>dc(i())]),z(e,a)},cS=(e,t=f,n=f,r=f,i=f,a=f,o=f)=>{var s=fS(),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u);var p=P(u,2),m=e=>{var t=uS(),n=M(t,!0);T(t),F(()=>{W(t,`aria-label`,o().title),W(t,`title`,o().title),B(n,a())}),L(`click`,t,function(...e){o().onclick?.apply(this,e)}),z(e,t)},h=e=>{var t=dS(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(p,e=>{o()?e(m):e(h,-1)}),T(s),F(()=>{U(s,1,`card provider-status-flag ${t()??``} ${n()??``}`,`svelte-6tr9cf`),B(l,r()),B(d,i())}),z(e,s)},lS=R(`
                    i + o =
                    `),uS=R(``),dS=R(` `),fS=R(`
                    `),pS=R(`
                    Cache Hits
                    `),mS=R(`
                    Total Requests
                    Estimated Cost
                    Prompt Cache Rate
                    `);function hS(e,t){E(t,!0);let n=O(()=>zc.summary),r=O(()=>zc.cacheOverview),i=O(()=>zc.cacheAnalyticsEnabled()),a=O(()=>rS.status.summary);function o(){let e=document.getElementById(`provider-status-section`);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),e.focus({preventScroll:!0}))}var s=mS(),c=M(s);{let e=O(()=>pb(I(n)));sS(c,()=>`Tokens`,()=>I(n).total_input_tokens,()=>I(n).total_output_tokens,()=>I(e))}var l=P(c,2),u=P(M(l),2),d=M(u,!0);T(u),T(l);var f=P(l,2),p=e=>{var t=pS(),n=P(M(t),2),i=M(n,!0);T(n),T(t),F(e=>B(i,e),[()=>sc(I(r).summary.total_hits)]),z(e,t)};V(f,e=>{I(i)&&e(p)});var m=P(f,2),h=P(M(m),2),g=M(h,!0);T(h),T(m);var _=P(m,2),v=e=>{{let t=O(()=>_b(I(r)));sS(e,()=>`Local Cache`,()=>I(r).summary.total_input_tokens,()=>I(r).summary.total_output_tokens,()=>I(t))}};V(_,e=>{I(i)&&e(v)});var y=P(_,2),b=P(M(y),2),x=M(b);My(x,{build:()=>Mb(Ob(I(n)),By(`var(--token-prompt)`),By(`var(--bg-surface-hover)`))});var S=P(x,2),C=M(S,!0);T(S),T(b),T(y);var w=P(y,2),ee=e=>{{let t=O(()=>Ub(I(a))),n=O(()=>Gb(I(a))),r=O(()=>qb(I(a))),i=O(()=>Kb(I(a))?{title:`View providers overview`,onclick:o}:null);cS(e,()=>`provider-status-overview-card`,()=>I(t),()=>`Provider Status`,()=>I(n),()=>I(r),()=>I(i))}};V(w,e=>{I(a).total>0&&e(ee)});var te=P(w,2),ne=e=>{{let t=O(()=>Ix(aS.servers)),n=O(()=>Fx(aS.servers)),r=O(()=>Lx(aS.servers));cS(e,()=>`mcp-servers-flag`,()=>I(t),()=>`MCP Servers`,()=>I(n),()=>I(r),()=>({title:`View MCP servers`,onclick:()=>Yo.navigate(`mcp-servers`)}))}},re=O(()=>Px(aS.available,aS.servers));V(te,e=>{I(re)&&e(ne)}),T(s),F((e,t,n,r,i)=>{W(u,`title`,e),B(d,t),B(g,n),W(b,`aria-label`,r),B(C,i)},[()=>gb(I(n),I(r),I(i)),()=>sc(hb(I(n),I(r),I(i))),()=>cc(I(n).total_cost),()=>`Prompt cache rate `+Ab(I(n)),()=>Ab(I(n))]),z(e,s),D()}Hr([`click`]);var gS=R(` `),_S=R(`
                    `),vS=R(`No usage in the selected period yet`),yS=R(`
                    `),bS=R(`

                    Tokens

                    Share of input tokens over the selected period
                    `);function xS(e,t){E(t,!0);let n=O(()=>zc.cacheAnalyticsEnabled()),r=O(()=>xb(zc.summary,zc.cacheOverview,I(n))),i=O(()=>Sb(zc.summary,zc.cacheOverview,I(n))),a=O(()=>bb(zc.summary,zc.cacheOverview,I(n)));var o=bS(),s=P(M(o),2);let c;var l=M(s);H(l,17,()=>I(i),e=>e.key,(e,t)=>{var n=_S(),r=M(n),i=e=>{var n=gS(),r=M(n);T(n),F(()=>B(r,`${I(t).pct??``}%`)),z(e,n)};V(r,e=>{I(t).pct>=8&&e(i)}),T(n),F(e=>{Wi(n,`width: ${I(t).pct??``}%; background: var(${I(t).colorVar??``})`),W(n,`title`,e)},[()=>Cb(I(t))]),z(e,n)});var u=P(l,2),d=e=>{z(e,vS())};V(u,e=>{I(a)||e(d)}),T(s);var f=P(s,2);H(f,21,()=>I(r),e=>e.key,(e,t)=>{var n=yS(),r=M(n),i=P(r,2),a=M(i,!0);T(i);var o=P(i,2),s=M(o);T(o);var c=P(o,2),l=M(c,!0);T(c),T(n),F((e,i)=>{W(n,`title`,e),Wi(r,`background: var(${I(t).colorVar??``})`),B(a,I(t).label),B(s,`${I(t).pct??``}%`),B(l,i)},[()=>Cb(I(t)),()=>sc(I(t).tokens)]),z(e,n)}),T(f),T(o),F(e=>{c=U(s,1,`cache-meter-bar svelte-1yzecxj`,null,c,{"is-empty":!I(a)}),W(s,`aria-label`,e)},[()=>wb(I(i))]),z(e,o),D()}var SS=R(``);function CS(e,t){let n=G(t,`size`,3,16),r=G(t,`label`,3,`Loading`),i=G(t,`class`,3,``);var a=SS();F(()=>{U(a,1,Li([`spinner`,i()]),`svelte-b54l9o`),Wi(a,`--spinner-size: ${n()??``}px`),W(a,`aria-label`,r())}),z(e,a)}var wS=Xr(` `),TS=Xr(``);function ES(e,t){let n=G(t,`label`,3,`No data`);var r=TS(),i=P(M(r),9),a=e=>{var t=wS(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(i,e=>{n()&&e(a)}),T(r),F(()=>{W(r,`role`,n()?`img`:void 0),W(r,`aria-label`,n()||void 0),W(r,`aria-hidden`,n()?void 0:`true`)}),z(e,r)}var DS=R(`
                    `),OS=R(`

                    `);function kS(e,t){E(t,!0);let n=[`daily`,`weekly`,`monthly`,`yearly`];function r(e){Nc.interval=e,t.onintervalchange?.()}function i(){let e=zc.daily;if(e.length===0)return null;let t=Nc.rangeStart(),n=Nc.rangeEnd(),r=Db(Eb(e,Nc.interval,t,n),Eb(Array.isArray(zc.cacheOverview.daily)?zc.cacheOverview.daily:[],Nc.interval,t,n));return jb(Ly(),r,{cacheEnabled:zc.cacheAnalyticsEnabled(),resolve:By})}var a=OS(),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2);{let e=O(()=>n.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})));Fy(l,{ariaLabel:`Usage chart interval`,get options(){return I(e)},get value(){return Nc.interval},onchange:r})}T(o);var u=P(o,2),d=M(u);My(d,{build:i});var f=P(d,2),p=e=>{var t=DS();CS(M(t),{size:24,label:`Loading usage`}),T(t),z(e,t)},m=e=>{var t=DS();ES(M(t),{}),T(t),z(e,t)};V(f,e=>{zc.daily.length===0&&zc.loading?e(p):zc.daily.length===0&&!q.authError&&e(m,1)}),T(u),T(a),F(e=>B(c,e),[()=>Nc.chartTitle()]),z(e,a),D()}var AS=10,jS=.7;function MS(e,t){if(e<=0||t<=0)return 0;let n=(e/t)**+jS,r=Math.ceil(n*AS);return r<1?1:r>AS?AS:r}function NS(){let e=[];for(let t=0;t<=AS;t++)e.push(t);return e}function PS(e,t,n){let r={};(e||[]).forEach(e=>{r[e.date]=e});let i=$o(ts(n,-364)),a=i.getUTCDay();i.setUTCDate(i.getUTCDate()-a);let o=[];for(let e=new Date(i);es(e)<=n;e.setUTCDate(e.getUTCDate()+1)){let n=es(e),i=r[n],a=0;i&&(a=t===`costs`?i.total_cost==null?0:i.total_cost:i.total_tokens||0),o.push({dateStr:n,value:a,level:0,empty:!1})}let s=0;for(let e=0;es&&(s=o[e].value);for(let e=0;e0){for(;l.length<7;)l.push({dateStr:``,value:0,level:0,empty:!0});c.push(l)}return c}function FS(e){let t=$o(ts(e,-364)),n=t.getUTCDay();t.setUTCDate(t.getUTCDate()-n);let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],i=[],a={},o=0;for(let n=new Date(t);es(n)<=e;n.setUTCDate(n.getUTCDate()+7),o++){let t=null;if(o===0)t=new Date(n);else for(let r=0;r<7;r++){let i=new Date(n);if(i.setUTCDate(n.getUTCDate()+r),es(i)>e)break;if(i.getUTCDate()===1){t=i;break}}if(!t)continue;let s=t.getUTCFullYear()+`-`+t.getUTCMonth();a[s]||(i.push({label:r[t.getUTCMonth()],col:o,key:s}),a[s]=!0)}for(let e=0;e `),zS=R(`
                    `),BS=R(`
                    `),VS=R(`
                    `),HS=R(`
                    `),US=R(`

                    Activity

                    Mon Wed Fri
                    `,1);function WS(e,t){E(t,!0);let n=k(j({show:!1,x:0,y:0,text:``})),r=O(()=>fs.currentDateKey()),i=O(()=>PS(oS.data,oS.mode,I(r))),a=O(()=>FS(I(r)));function o(e,t){t.empty||A(n,{show:!0,x:e.clientX,y:e.clientY,text:LS(t,oS.mode)},!0)}function s(){A(n,{show:!1,x:0,y:0,text:``},!0)}var c=US(),l=N(c),u=M(l),d=P(M(u),2),f=e=>{CS(e,{size:14,label:`Loading activity`})};V(d,e=>{oS.loading&&oS.data.length===0&&e(f)}),Fy(P(d,2),{ariaLabel:`Activity calendar mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return oS.mode},onchange:e=>oS.mode=e}),T(u);var p=P(u,2),m=P(M(p),2),h=M(m);H(h,21,()=>I(a),e=>e.key,(e,t)=>{var n=RS(),r=M(n,!0);T(n),F(()=>{Wi(n,`grid-column: ${I(t).col+1} / span ${I(t).span??``}`),B(r,I(t).label)}),z(e,n)}),T(h);var g=P(h,2);H(g,21,()=>I(i),ci,(e,t,n)=>{var r=BS();H(r,23,()=>I(t),(e,t)=>n+`-`+t,(e,t)=>{var n=zS();F(()=>U(n,1,Li([`contribution-calendar-cell`,I(t).empty?`empty`:`level-${I(t).level}`]),`svelte-3hfxuq`)),Vr(`mouseenter`,n,e=>o(e,I(t))),Vr(`mouseleave`,n,s),z(e,n)}),T(r),z(e,r)}),T(g),T(m),T(p);var _=P(p,2),v=M(_),y=M(v),b=M(y,!0);T(y),T(v);var x=P(v,2);H(P(M(x),2),16,NS,e=>e,(e,t)=>{var n=VS();F(()=>U(n,1,`contribution-calendar-cell level-${t??``}`,`svelte-3hfxuq`)),z(e,n)}),Ue(2),T(x),T(_),T(l);var S=P(l,2),C=e=>{var t=HS(),r=M(t,!0);T(t),F(()=>{Wi(t,`left: ${I(n).x??``}px; top: ${I(n).y-40}px`),B(r,I(n).text)}),z(e,t)};V(S,e=>{I(n).show&&e(C)}),F(e=>B(b,e),[()=>IS(oS.data,oS.mode)]),z(e,c),D()}var GS=R(``),KS=R(`

                    `),qS=R(`
                    `);function JS(e,t){E(t,!0);let n=G(t,`label`,3,`help`),r=G(t,`text`,3,``),i=G(t,`open`,15,!1),a=G(t,`external`,3,!1),o=O(()=>!!r()||!!t.help||a());var s=qS(),c=M(s),l=M(c);vi(l,()=>t.title??f);var u=P(l,2),d=e=>{var r=GS();let a;F(()=>{a=U(r,1,`inline-help-toggle svelte-y40or3`,null,a,{"is-open":i()}),W(r,`aria-label`,(i()?`Hide `:`Show `)+n()),W(r,`aria-expanded`,i()),W(r,`aria-controls`,t.copyId)}),L(`click`,r,()=>i(!i())),z(e,r)};V(u,e=>{I(o)&&e(d)}),vi(P(u,2),()=>t.extra??f),T(c);var p=P(c,2),m=e=>{var n=KS(),i=M(n),a=e=>{var n=Qr();vi(N(n),()=>t.help),z(e,n)},o=e=>{var t=Zr();F(()=>B(t,r())),z(e,t)};V(i,e=>{t.help?e(a):e(o,-1)}),T(n),F(()=>W(n,`id`,t.copyId)),z(e,n)};V(p,e=>{i()&&I(o)&&!a()&&e(m)}),T(s),z(e,s),D()}Hr([`click`]);var YS=R(`

                    Provider Latency

                    `),XS=R(`
                    Avg
                    `),ZS=R(`

                    Requests by Status

                    Success 2xx 4xx 5xx
                    `,1);function QS(e,t){E(t,!0);let n=Zx(),r=O(()=>iS.stats);function i(){return{interval:I(r).interval,zone:fs.effectiveTimezone(),resolve:By,formatTimestamp:e=>fs.formatTimestamp(e)}}var a=Qr(),o=N(a),s=e=>{var t=ZS(),a=N(t),o=M(a),s=P(M(o),2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c);var d=P(c,2),f=P(M(d),4),p=M(f,!0);T(f),T(d);var m=P(d,2),h=P(M(m),4),g=M(h,!0);T(h),T(m);var _=P(m,2),v=P(M(_),4),y=M(v,!0);T(v),T(_),T(s),T(o);var b=P(o,2);My(M(b),{build:()=>Xx(Ly(),I(r).buckets,i())}),T(b),T(a);var x=P(a,2),S=e=>{var t=XS(),a=M(t),o=M(a);JS(o,{copyId:`audit-latency-help-copy`,label:`provider latency help`,text:`Average duration of successful requests as measured at the gateway, per provider. Local cache hits and failed requests are excluded; streamed responses count until the stream completes.`,title:e=>{z(e,YS())},$$slots:{title:!0}});var s=P(o,2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c),T(s),T(a);var d=P(a,2);My(M(d),{build:()=>Qx(Ly(),I(r).buckets,I(r).provider_latency,{...i(),providerColor:n})}),T(d),T(t),F(e=>B(u,e),[()=>Gx(I(r))]),z(e,t)},C=O(()=>Vx(I(r)));V(x,e=>{I(C)&&e(S)}),F((e,t,n,r)=>{B(u,e),B(p,t),B(g,n),B(y,r)},[()=>Hx(I(r)),()=>sc(Ux(I(r),`status_2xx`)),()=>sc(Ux(I(r),`status_4xx`)),()=>sc(Ux(I(r),`status_5xx`))]),z(e,t)},c=O(()=>Bx(I(r)));V(o,e=>{I(c)&&e(s)}),z(e,a),D()}var $S=(e,t=f,n=f,r)=>{let i=Ot(()=>h(r?.(),!1));var a=nC(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=e=>{var t=eC(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)},u=e=>{var t=tC(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(c,e=>{I(i)?e(l):e(u,-1)}),T(a),F(()=>B(s,t())),z(e,a)},eC=R(` `),tC=R(` `),nC=R(`
                    `),rC=R(`

                    `),iC=R(`
                    Breaker State
                    `),aC=R(`
                    `),oC=R(`
                    Models (Recent Traffic)
                    `),sC=R(`
                    `),cC=R(`

                    `);function lC(e,t){E(t,!0);let n=O(()=>sx(t.provider)),r=O(()=>[[`Base URL`,t.provider.config?.base_url],[`API Version`,t.provider.config?.api_version]].filter(([,e])=>!!e));var i=cC();let a;var o=M(i),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{var n=rC(),r=M(n,!0);T(n),F(()=>B(r,t.provider.last_error)),z(e,n)};V(l,e=>{t.provider.last_error&&e(u)});var d=P(l,2),f=e=>{var r=sC(),i=M(r);{let e=O(()=>cx(t.provider));$S(i,()=>`Recent Requests`,()=>I(e))}var a=P(i,2),o=e=>{var r=iC(),i=P(M(r),2),a=M(i),o=M(a,!0);T(a),T(i),T(r),F(e=>{U(a,1,Li([`provider-status-health-state`,I(n)]),`svelte-6y9wjv`),B(o,e)},[()=>ox(t.provider)]),z(e,r)},s=O(()=>ax(t.provider));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{var n=oC(),r=P(M(n),2);H(r,21,()=>lx(t.provider),e=>e.model,(e,t)=>{var n=aC();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F((e,i)=>{r=U(n,1,`provider-status-health-model svelte-6y9wjv`,null,r,{"is-flagged":I(t).flagged}),W(n,`title`,e),B(a,I(t).model),B(s,i)},[()=>dx(I(t)),()=>ux(I(t))]),z(e,n)}),T(r),T(n),z(e,n)},u=O(()=>lx(t.provider).length>0);V(c,e=>{I(u)&&e(l)}),T(r),z(e,r)},p=O(()=>ix(t.provider));V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=M(m);H(h,17,()=>I(r),([e,t])=>e,(e,t)=>{var n=O(()=>g(I(t),2));$S(e,()=>I(n)[0],()=>I(n)[1],()=>!0)});var _=P(h,2);{let e=O(()=>nx(t.provider));$S(_,()=>`Configured Models`,()=>I(e))}var v=P(_,2);{let e=O(()=>ex(t.provider));$S(v,()=>`Retry`,()=>I(e))}var y=P(v,2);{let e=O(()=>tx(t.provider));$S(y,()=>`Circuit Breaker`,()=>I(e))}T(m),T(o),T(i),F(()=>{a=U(i,1,`provider-status-details svelte-6y9wjv`,null,a,{"is-expanded":t.expanded,"is-collapsed":!t.expanded}),W(i,`aria-hidden`,!t.expanded),B(c,t.provider.status_reason)}),z(e,i),D()}var uC=R(` `),dC=R(``),fC=R(`

                    Models Available
                    Last Checked
                    `);function pC(e,t){E(t,!0);let n=O(()=>rS.cardExpanded(t.provider)),r=e=>fs.formatTimestamp(e);var i=fC(),a=M(i),o=M(a),s=M(o),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=e=>{var n=uC(),r=M(n);T(n),F(e=>B(r,`(${e??``})`),[()=>Qb(t.provider)]),z(e,n)},f=O(()=>Qb(t.provider));V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var n=dC();F((e,t,r)=>{W(n,`href`,e),W(n,`aria-label`,t),W(n,`title`,r)},[()=>$b(t.provider),()=>`View `+(Qb(t.provider)||t.provider.name)+` provider docs`,()=>`View `+(Qb(t.provider)||t.provider.name)+` provider docs`]),z(e,n)},h=O(()=>$b(t.provider));V(p,e=>{I(h)&&e(m)}),T(s),T(o);var g=P(o,2),_=M(g,!0);T(g),T(a);var v=P(a,2),y=M(v),b=P(M(y),2),x=M(b,!0);T(b),T(y);var S=P(y,2),C=P(M(S),2),w=M(C,!0);T(C),T(S),T(v);var ee=P(v,2);lC(ee,{get provider(){return t.provider},get expanded(){return I(n)}});var te=P(ee,2);let ne;K(M(te),{get icon(){return Ua},class:`provider-status-card-toggle-icon`}),T(te),T(i),F((e,r,i,a,o)=>{B(l,t.provider.name),U(g,1,`provider-status-pill ${e??``}`,`svelte-nopjmh`),W(g,`title`,r),B(_,t.provider.status_label),B(x,i),W(C,`title`,a),B(w,o),ne=U(te,1,`provider-status-card-toggle svelte-nopjmh`,null,ne,{"is-expanded":I(n)}),W(te,`aria-expanded`,I(n)),W(te,`aria-label`,(I(n)?`Collapse `:`Expand `)+t.provider.name+` details`),W(te,`title`,I(n)?`Collapse details`:`Expand details`)},[()=>Wb(t.provider.status),()=>rx(t.provider),()=>sc(t.provider.runtime?.discovered_model_count),()=>Zb(t.provider,r),()=>Xb(t.provider,r)]),L(`click`,te,()=>rS.toggleCard(t.provider)),z(e,i),D()}Hr([`click`]);var mC=R(`

                    Providers Overview

                    `),hC=R(`
                    `);function gC(e,t){E(t,!0);let n=O(()=>rS.status.providers);var r=Qr(),i=N(r),a=e=>{var t=mC(),r=M(t),i=P(M(r),2),a=M(i),o=M(a,!0);T(a);var s=P(a,2);let c;T(i),T(r);var l=P(r,2);H(l,21,()=>I(n),e=>e.name,(e,t)=>{pC(e,{get provider(){return I(t)}})}),T(l),T(t),F((e,t)=>{W(i,`aria-checked`,rS.detailsExpanded),W(i,`title`,e),B(o,t),c=U(s,1,`provider-status-toggle-track svelte-1kx3uw4`,null,c,{"is-active":rS.detailsExpanded})},[()=>rS.detailsToggleLabel(),()=>rS.detailsToggleLabel()]),L(`click`,i,()=>rS.toggleDetails()),z(e,t)},o=e=>{var t=hC();CS(M(t),{size:18,label:`Loading provider status`}),T(t),z(e,t)};V(i,e=>{I(n).length>0?e(a):rS.loading&&!rS.loadedOnce&&e(o,1)}),z(e,r),D()}Hr([`click`]);var _C=R(`
                    `);function vC(e,t){E(t,!0);function n(){zc.fetchUsage(),zc.fetchCacheOverview(``),iS.fetch(),rS.fetch(),aS.fetch(),oS.fetch()}function r(){zc.fetchUsage(),zc.fetchCacheOverview(``),iS.fetch()}function i(){r(),oS.fetch()}An(()=>{if(q.refreshTick,Yo.page===`overview`)return Er(()=>{n(),cb.start()}),()=>{cb.stop(),rS.stopPolling()}});var a=_C(),o=M(a);fb(o,{});var s=P(o,4);nl(M(s),{onchange:i}),T(s);var c=P(s,2);Ic(c,{});var l=P(c,2);hS(l,{});var u=P(l,2);xS(u,{});var d=P(u,2);kS(d,{onintervalchange:r});var f=P(d,2);WS(f,{});var p=P(f,2);QS(p,{}),gC(P(p,2),{}),T(a),z(e,a),D()}var yC=`/admin/live/logs?types=audit,usage`;function bC(e,t,n){return!!t&&String(e&&e.id||``).trim()===t||!!n&&String(e&&e.request_id||``).trim()===n}function xC(e){switch(e){case`date_range`:return`Live paused — the selected date range does not include today. Set it to today to resume.`;case`filters`:return`Live paused while filters are active. Clear them to resume.`;case`pagination`:return`Live paused on later pages. Go to the first page to resume.`;default:return``}}function SC(e){let t=yC,n=Number(e||0);return Number.isFinite(n)&&n>0&&(t+=`&cursor=`+encodeURIComponent(String(n))),t}function CC(){return{async consumeLiveLogsBody(e){await Gy(e,e=>this.applyLiveLogEvent(e))},applyLiveLogEvent(e){if(!e||typeof e!=`object`)return;let t=Number(e.seq||0);Number.isFinite(t)&&t>this.liveLogsLastSeq&&(this.liveLogsLastSeq=t);let n=String(e.type||``).trim();if(n!==`heartbeat`){if(n===`reset`){this.reloadLiveLogSources();return}if(n===`audit.removed`){this.removeLiveAuditEntry(e.data);return}if(n.indexOf(`audit.`)===0){this.mergeLiveAuditEntry(e.data||{},n);return}n.indexOf(`usage.`)===0&&(this.mergeLiveUsageEntry(e.data||{},n),typeof this.noteLiveTokenUsage==`function`&&this.noteLiveTokenUsage(n))}},reloadLiveLogSources(){typeof this.fetchUsage==`function`&&this.fetchUsage(),this.page===`audit-logs`&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},auditLivePauseReason(){return!this.auditLog||this.auditLog.offset!==0?`pagination`:this.auditSearch||this.auditMethod||this.auditStatusCode||this.auditStream?`filters`:!this.followsToday&&(this.customStartDate||this.customEndDate)?`date_range`:null},auditLiveInsertAllowed(){return!this.auditLivePauseReason()},usageLiveInsertAllowed(){return this.usageLog&&this.usageLog.offset===0&&!this.usageLogSearch&&!this.usageFilterModel&&!this.usageFilterProvider&&!this.usageFilterLabel&&!this.usageFilterUserPath},mergeLiveAuditEntry(e,t){if(!e||typeof e!=`object`)return;let n=String(e.id||e.request_id||``).trim();if(!n)return;let r=String(e.request_id||``).trim(),i=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],a=i.findIndex(e=>bC(e,n,r)),o=a>=0&&i[a]||{},s=t===`audit.detail`,c=s?{...e,_detail_loaded:!0,_response_partial:!1,bodies_omitted:!1}:this.liveAuditPatch(o,e,t);if(a>=0){let e=this.mergeLiveAuditPatch(o,c);return i.splice(a,1,e),this.auditLog.entries=[...i],this.regroupLiveAuditHead(e),s||this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}let l=this.mergeLiveAuditChild(e,c);if(l)return s||this.fetchExpandedAuditDetailIfReady(l),this.cacheMergedAuditRecord(l,t),l;if(!this.auditLiveInsertAllowed()){this.cacheMergedAuditRecord(c,t);return}if(!s&&this.auditGroupSessions){let e=this.foldLiveAuditIntoThread(c);if(e)return this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}this.auditLog.entries=[this.mergeLiveAuditUsagePatch(c),...i].slice(0,this.auditLog.limit||25),this.auditLog.total=Number(this.auditLog.total||0)+1;let u=this.auditLog.entries[0];return s||this.fetchExpandedAuditDetailIfReady(u),this.cacheMergedAuditRecord(u,t),u},liveAuditPatch(e,t,n){let r=this.liveAuditStateAfter(e._live_state,n),i=this.liveAuditEventFlushed(e._live_state)||this.liveAuditEventFlushed(r),a={...t,_live:!0,_live_state:r,_audit_flushed:i,_live_pending:!i};return n===`audit.stream`?a._response_partial=!0:this.liveAuditStateSettled(n)&&(a._response_partial=!1),a},mergeLiveAuditChild(e,t){let n=this.auditThreadChildren;if(!n||typeof n!=`object`)return null;let r=String(e.id||``).trim(),i=String(e.request_id||``).trim(),a=Object.keys(n);for(let e=0;ebC(e,r,i));if(c<0)continue;let l=this.mergeLiveAuditPatch(s[c]||{},t),u=[...s];return u.splice(c,1,l),this.auditThreadChildren={...n,[a[e]]:{...o,entries:u}},l}return null},regroupLiveAuditHead(e){if(!this.auditGroupSessions)return null;let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=String(e.id||``).trim(),i=n.findIndex(e=>String(e.id||``).trim()===r);if(i<0)return null;let a=n.findIndex((e,n)=>n!==i&&String(e.session_id||``).trim()===t);if(a<0)return null;let o=n[a],s=Date.parse(o&&o.timestamp),c=Date.parse(e&&e.timestamp),l=Number.isFinite(s)&&Number.isFinite(c)&&s>c,u=l?o:e,d=l?e:o,f={...u,session_count:Math.max(1,Number(o.session_count||1))+Math.max(1,Number(e.session_count||1))},p=n.filter((e,t)=>t!==i&&t!==a);return p.unshift(f),this.auditLog.entries=p,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-1),this.prependLiveAuditThreadChild(t,d),f},foldLiveAuditIntoThread(e){let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(e=>String(e.session_id||``).trim()===t);if(r<0)return null;let i=n[r],a=Number(i.session_count),o=this.mergeLiveAuditUsagePatch({...e,session_count:(Number.isFinite(a)&&a>0?a:1)+1}),s=[...n];return s.splice(r,1),s.unshift(o),this.auditLog.entries=s,this.prependLiveAuditThreadChild(t,i),o},prependLiveAuditThreadChild(e,t){let n=this.auditThreadChildren||{},r=n[e],i={...t};delete i.session_count;let a=r&&Array.isArray(r.entries)?{...r,entries:[i,...r.entries],total:Number(r.total||r.entries.length)+1}:{loading:!1,loaded:!1,entries:[i],total:1};this.auditThreadChildren={...n,[e]:a}},removeLiveAuditThreadChild(e,t){let n=this.auditThreadChildren;!n||typeof n!=`object`||Object.keys(n).forEach(r=>{let i=n[r],a=i&&Array.isArray(i.entries)?i.entries:[],o=a.filter(n=>!bC(n,e,t)),s=a.length-o.length;s!==0&&(this.auditThreadChildren={...this.auditThreadChildren,[r]:{...i,entries:o,total:Math.max(0,Number(i.total||a.length)-s)}},this.decrementLiveAuditThreadCount(r,s))})},decrementLiveAuditThreadCount(e,t){let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(t=>String(t.session_id||``).trim()===e);if(r<0)return;let i=n[r],a=[...n];a.splice(r,1,{...i,session_count:Math.max(1,Number(i.session_count||1)-t)}),this.auditLog.entries=a},mergeLiveAuditPatch(e,t){let n={...e,...t};return t.data===void 0&&e.data!==void 0?n.data=e.data:e.data&&t.data&&typeof e.data==`object`&&typeof t.data==`object`&&!Array.isArray(e.data)&&!Array.isArray(t.data)&&(n.data={...e.data,...t.data}),this.mergeLiveAuditUsagePatch(n)},mergeLiveAuditUsagePatch(e){let t=this.liveUsageEntryForAudit(e);if(!t)return e;let n=this.auditEntryWithLiveUsage(e,t);return this.removeSkippedLiveUsage(t),n},liveUsageEntryForAudit(e){let t=String(e&&e.request_id||``).trim();return t&&((this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[]).find(e=>String(e&&e.request_id||``).trim()===t)||this.skippedLiveUsageByRequestId&&this.skippedLiveUsageByRequestId[t])||null},cacheMergedAuditRecord(e,t){return e&&typeof this.cacheAuditRecord==`function`?this.cacheAuditRecord(e,t):e},fetchExpandedAuditDetailIfReady(e){!e||!this.isAuditEntryExpanded||!this.isAuditEntryExpanded(e)||String(e._live_state||``).trim()!==`audit.flushed`&&!e._audit_flushed||typeof this.fetchAuditEntryDetail==`function`&&this.fetchAuditEntryDetail(e)},liveAuditStateRank(e){switch(String(e||``).trim()){case`audit.started`:return 10;case`audit.updated`:case`audit.stream`:return 20;case`audit.completed`:return 30;case`audit.failed`:case`audit.flushed`:case`audit.detail`:return 40;default:return 0}},liveAuditStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveAuditStateRank(n)>this.liveAuditStateRank(r)?n:r},liveAuditStateSettled(e){return this.liveAuditStateRank(e)>=this.liveAuditStateRank(`audit.completed`)},liveAuditEventFlushed(e){let t=String(e||``).trim();return t===`audit.failed`||t===`audit.flushed`||t===`audit.detail`},removeLiveAuditEntry(e){if(!e||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim();if(!t&&!n)return;let r=this.auditLog.entries,i=[],a=0,o=0,s=!1;r.forEach(e=>{if(!bC(e,t,n)){i.push(e);return}a++;let r=String(e.session_id||``).trim(),c=Math.max(1,Number(e.session_count||1));if(!this.auditGroupSessions||!r||c<=1)return;o++;let l=this.auditThreadChildren&&this.auditThreadChildren[r],u=l&&Array.isArray(l.entries)?l.entries.filter(e=>!bC(e,t,n)):[];if(u.length===0){s=!0;return}let d={...u[0],session_id:r,session_count:c-1};i.push(d),this.auditThreadChildren={...this.auditThreadChildren,[r]:{...l,entries:u.slice(1),total:Math.max(0,Number(l.total||c)-1)}}}),a>0&&(this.auditLog.entries=i,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-a+o)),this.removeLiveAuditThreadChild(t,n),s&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},mergeLiveUsageEntry(e,t){if(!e||typeof e!=`object`)return;e={...e,_live_state:t||e._live_state||`usage.completed`};let n=String(e.id||``).trim();if(!n)return;let r=this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[],i=r.findIndex(e=>String(e.id||``).trim()===n);if(i>=0){let t=r[i]||{},n=this.mergeLiveUsagePatch(t,e);if(this.applyLiveUsageToAudit(n),this.liveUsageShouldSkip(n)){r.splice(i,1),this.usageLog.entries=[...r],this.usageLog.total=Math.max(0,Number(this.usageLog.total||0)-1),this.storeSkippedLiveUsage(n);return}r.splice(i,1,n),this.usageLog.entries=[...r],this.removeSkippedLiveUsage(n);return}let a=this.mergeLiveUsagePatch(this.liveUsageSeedForEntry(e),e);if(this.applyLiveUsageToAudit(a),this.liveUsageShouldSkip(a)){this.storeSkippedLiveUsage(a);return}this.removeSkippedLiveUsage(a),this.usageLog.entries=[a,...r].slice(0,this.usageLog.limit||50),this.usageLog.total=Number(this.usageLog.total||0)+1},mergeLiveUsagePatch(e,t){e=e&&typeof e==`object`?e:{};let n=this.liveUsageStateAfter(e._live_state,t&&t._live_state),r=this.liveUsageEventFlushed(e)||this.liveUsageEventFlushed({...t,_live_state:n});return{...e,...t,_live:!0,_live_state:n||`usage.completed`,_live_pending:!r,_usage_flushed:r}},liveUsageShouldSkip(e){return!!(this.usageLogHideCached&&this.liveUsageEntryCached(e))||!this.usageLiveInsertAllowed()},liveUsageSeedForEntry(e){return this.skippedLiveUsageForEntry(e)||this.auditLiveUsageForEntry(e)},skippedLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();return t&&this.skippedLiveUsageByRequestId?this.skippedLiveUsageByRequestId[t]:null},auditLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return null;let n=this.auditLog.entries.find(e=>String(e&&e.request_id||``).trim()===t),r=n&&n.usage&&typeof n.usage==`object`&&!Array.isArray(n.usage)?n.usage:null;return r?{id:e&&e.id,request_id:t,entries:r.entries,input_tokens:r.input_tokens,uncached_input_tokens:r.uncached_input_tokens,cached_input_tokens:r.cached_input_tokens,cache_write_input_tokens:r.cache_write_input_tokens,output_tokens:r.output_tokens,total_tokens:r.total_tokens,cached_input_ratio:r.cached_input_ratio,estimated_cached_characters:r.estimated_cached_characters,_live_state:n._usage_live_state,_live_pending:n._usage_live_pending,_usage_flushed:n._usage_flushed}:null},storeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&((!this.skippedLiveUsageByRequestId||typeof this.skippedLiveUsageByRequestId!=`object`||Array.isArray(this.skippedLiveUsageByRequestId))&&(this.skippedLiveUsageByRequestId={}),this.skippedLiveUsageByRequestId[t]=e)},removeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&this.skippedLiveUsageByRequestId&&delete this.skippedLiveUsageByRequestId[t]},liveUsageEntryCached(e){let t=String(e&&e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`||!!(e&&e.cache_hit)},liveUsageEventFlushed(e){let t=String(e&&e._live_state||``).trim();return!!(e&&e._usage_flushed)||t===`usage.failed`||t===`usage.flushed`},liveUsageStateRank(e){switch(String(e||``).trim()){case`usage.completed`:return 10;case`usage.failed`:case`usage.flushed`:return 20;default:return 0}},liveUsageStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveUsageStateRank(n)>this.liveUsageStateRank(r)?n:r},applyLiveUsageToAudit(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let n=this.auditLog.entries.findIndex(e=>String(e.request_id||``).trim()===t);if(n>=0){let t=this.auditLog.entries[n];this.auditLog.entries.splice(n,1,this.auditEntryWithLiveUsage(t,e)),this.auditLog.entries=[...this.auditLog.entries]}let r=this.auditThreadChildren;if(!r||typeof r!=`object`)return;let i=r,a=!1;Object.keys(r).forEach(n=>{let r=i[n],o=r&&Array.isArray(r.entries)?r.entries:[],s=o.findIndex(e=>String(e.request_id||``).trim()===t);if(s<0)return;let c=[...o];c.splice(s,1,this.auditEntryWithLiveUsage(o[s],e)),i={...i,[n]:{...r,entries:c}},a=!0}),a&&(this.auditThreadChildren=i)},auditEntryWithLiveUsage(e,t){let n=this.liveUsageStateAfter(e._usage_live_state,t._live_state||`usage.completed`),r=this.liveUsageEventFlushed({_live_state:n,_usage_flushed:e._usage_flushed||t._usage_flushed});return{...e,usage:this.liveUsageSummary(t,e.usage),_usage_live_state:n||`usage.completed`,_usage_live_pending:!r,_usage_flushed:r}},liveUsageSummary(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=this.liveNumber(e.input_tokens,this.liveNumber(n.input_tokens,0)),i=this.liveNumber(e.output_tokens,this.liveNumber(n.output_tokens,0)),a=this.liveNumber(e.uncached_input_tokens,this.liveNumber(n.uncached_input_tokens,0)),o=this.liveNumber(e.cached_input_tokens,this.liveNumber(n.cached_input_tokens,0)),s=this.liveNumber(e.cache_write_input_tokens,this.liveNumber(n.cache_write_input_tokens,0));r>0&&a+o+s===0&&(a=r);let c=a+o+s||r,l=c+i||this.liveNumber(e.total_tokens,this.liveNumber(n.total_tokens,0)),u=this.liveNumber(e.cached_input_ratio,this.liveNumber(n.cached_input_ratio,c>0?o/c:0));return{entries:Math.max(1,this.liveNumber(e.entries,this.liveNumber(n.entries,1))),input_tokens:c,uncached_input_tokens:a,cached_input_tokens:o,cache_write_input_tokens:s,output_tokens:i,total_tokens:l,cached_input_ratio:u,estimated_cached_characters:this.liveNumber(e.estimated_cached_characters,this.liveNumber(n.estimated_cached_characters,o*4))}},liveNumber(e,t){let n=Number(e);return Number.isFinite(n)?n:t},auditEntryShouldFetchDetail(e){return!e||e._detail_loading||e._detail_loaded||this.auditEntryLiveDetailPending(e)?!1:this.auditEntryNeedsPersistedLiveDetail(e)||e.bodies_omitted?!0:!this.auditEntryHasDetailData(e)},auditEntryLiveDetailPending(e){if(!e||!e._live)return!1;let t=String(e._live_state||``).trim();return t===`audit.failed`||!e._audit_flushed&&t!==`audit.flushed`&&t!==`audit.detail`},auditEntryNeedsPersistedLiveDetail(e){return!!(e&&e._live&&!e._detail_loaded)},auditEntryHasDetailData(e){let t=e&&e.data;return!t||typeof t!=`object`?!1:t.request_headers!==void 0||t.response_headers!==void 0||t.request_body!==void 0||t.response_body!==void 0||t.request_body_too_big_to_handle!==void 0||t.response_body_too_big_to_handle!==void 0||t.user_agent!==void 0||t.api_key_hash!==void 0||t.temperature!==void 0||t.max_tokens!==void 0||t.error_message!==void 0||t.error_code!==void 0},clearAuditDetailLoading(e){if(!e)return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim(),r=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],i=r.find(e=>t&&String(e.id||``).trim()===t?!0:!!(n&&String(e.request_id||``).trim()===n)),a=i||e;a._detail_loading=!1,i&&(this.auditLog.entries=[...r])}}}var wC={"audit.started":10,"audit.updated":20,"audit.stream":20,"audit.completed":30,"audit.failed":40,"audit.flushed":40,"audit.detail":40},TC=new Set(Object.keys(wC));function EC(e){return String(e&&(e.id||e.request_id)||``).trim()}function DC(e,t){let n=e&&typeof e==`object`?e:{},r=t&&typeof t==`object`?t:{},i={...n,...r};r.data==null&&n.data!=null?i.data=n.data:AC(n.data)&&AC(r.data)&&(i.data={...n.data,...r.data});let a=String(n._live_state||``).trim(),o=String(r._live_state||``).trim();return(wC[a]||0)>(wC[o]||0)&&(i._live_state=a),n._audit_flushed&&(i._audit_flushed=!0),i._audit_flushed&&(i._live_pending=!1),n._detail_loaded&&!r._detail_loaded&&(i._detail_loaded=!0,i.bodies_omitted=!1),i.bodies_omitted&&AC(i.data)&&(i.data.request_body!==void 0||i.data.response_body!==void 0)&&(i.bodies_omitted=!1),i}function OC(e,t){let n=Number(t||0);return(Array.isArray(e)?e:[]).filter(e=>Number(e&&e.version||0)>n)}function kC(e){return TC.has(String(e&&e.eventType||``).trim())}function AC(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var jC=200,MC=class{#e=k(j({entries:[],total:0,limit:25,offset:0}));get auditLog(){return I(this.#e)}set auditLog(e){A(this.#e,e,!0)}#t=k(j({entries:[],total:0,limit:50,offset:0}));get usageLog(){return I(this.#t)}set usageLog(e){A(this.#t,e,!0)}#n=k(j({}));get auditRecords(){return I(this.#n)}set auditRecords(e){A(this.#n,e,!0)}#r=k(j([]));get auditRecordChanges(){return I(this.#r)}set auditRecordChanges(e){A(this.#r,e,!0)}auditRecordVersion=0;auditRecordPins=new Set;#i=k(``);get auditSearch(){return I(this.#i)}set auditSearch(e){A(this.#i,e,!0)}#a=k(``);get auditMethod(){return I(this.#a)}set auditMethod(e){A(this.#a,e,!0)}#o=k(``);get auditStatusCode(){return I(this.#o)}set auditStatusCode(e){A(this.#o,e,!0)}#s=k(``);get auditStream(){return I(this.#s)}set auditStream(e){A(this.#s,e,!0)}#c=k(Ea(`gomodel_audit_group_sessions`,`true`)!==`false`);get auditGroupSessions(){return I(this.#c)}set auditGroupSessions(e){A(this.#c,e,!0)}#l=k(j({}));get auditThreadChildren(){return I(this.#l)}set auditThreadChildren(e){A(this.#l,e,!0)}#u=k(``);get usageLogSearch(){return I(this.#u)}set usageLogSearch(e){A(this.#u,e,!0)}#d=k(``);get usageFilterModel(){return I(this.#d)}set usageFilterModel(e){A(this.#d,e,!0)}#f=k(``);get usageFilterProvider(){return I(this.#f)}set usageFilterProvider(e){A(this.#f,e,!0)}#p=k(``);get usageFilterLabel(){return I(this.#p)}set usageFilterLabel(e){A(this.#p,e,!0)}#m=k(``);get usageFilterUserPath(){return I(this.#m)}set usageFilterUserPath(e){A(this.#m,e,!0)}#h=k(!1);get usageLogHideCached(){return I(this.#h)}set usageLogHideCached(e){A(this.#h,e,!0)}#g=k(!1);get liveLogsStreaming(){return I(this.#g)}set liveLogsStreaming(e){A(this.#g,e,!0)}liveLogsLastSeq=0;liveLogsReconnectAttempts=0;liveLogsReconnectTimer=null;liveLogsController=null;skippedLiveUsageByRequestId=null;fetchUsage=null;fetchAuditLog=null;isAuditEntryExpanded=null;noteLiveTokenUsage=null;upsertAuditRecord(e,t=``){let n=EC(e);if(!n)return e;let r=DC(this.auditRecords[n],e);return this.auditRecords={...this.auditRecords,[n]:r},this.pruneAuditRecords(),this.auditRecordVersion++,this.auditRecordChanges=[...this.auditRecordChanges,{version:this.auditRecordVersion,key:n,eventType:t}].slice(-512),r}upsertAuditRecords(e,t=``){return(Array.isArray(e)?e:[]).map(e=>this.upsertAuditRecord(e,t))}auditRecord(e){let t=typeof e==`string`?String(e).trim():EC(e);return t&&this.auditRecords[t]||null}cacheAuditRecord(e,t){return this.upsertAuditRecord(e,t)}pinAuditRecords(e){this.auditRecordPins=new Set((Array.isArray(e)?e:[]).map(String))}pruneAuditRecords(){let e=Object.keys(this.auditRecords);if(e.length<=jC)return;let t={...this.auditRecords},n=e.length-jC;for(let r of e){if(n<=0)break;this.auditRecordPins.has(r)||(delete t[r],n--)}this.auditRecords=t}get page(){return Yo.page}get customStartDate(){return Nc.customStartDate}get customEndDate(){return Nc.customEndDate}get followsToday(){return Nc.followsToday}liveLogsEnabled(){return Cs.liveLogsVisible()}async startLiveLogs(){typeof fetch!=`function`||typeof ReadableStream>`u`||(await Cs.ensureLoaded(),this.liveLogsEnabled()&&(this.stopLiveLogs(),this.liveLogsController=typeof AbortController==`function`?new AbortController:null,this.readLiveLogsStream(this.liveLogsController)))}stopLiveLogs(){this.liveLogsStreaming=!1,this.liveLogsReconnectTimer&&=(clearTimeout(this.liveLogsReconnectTimer),null),this.liveLogsController&&typeof this.liveLogsController.abort==`function`&&this.liveLogsController.abort(),this.liveLogsController=null}ensureLiveLogs(){this.liveLogsController||this.liveLogsReconnectTimer||this.startLiveLogs()}async readLiveLogsStream(e){let t={};e&&(t.signal=e.signal);let n=SC(this.liveLogsLastSeq),r=q.generation;try{let i=await gs(n,t);if(i.status===401){if(q.handleUnauthorized(r),r{this.liveLogsReconnectTimer=null,this.startLiveLogs()},t)}async fetchAuditEntryDetail(e){if(!this.auditEntryShouldFetchDetail(e))return;let t=String(e.id||``).trim();if(!t)return;e._detail_loading=!0;let n=e;try{let e=await vs(`/admin/audit/detail?log_id=`+encodeURIComponent(t),{label:`audit detail`});if(e.stale||!e.ok)return;n=this.mergeLiveAuditEntry(e.data,`audit.detail`)||n}catch(e){console.error(`Failed to fetch audit detail:`,e)}finally{this.clearAuditDetailLoading(n)}}};Object.assign(MC.prototype,CC());var NC=new MC;if(typeof window<`u`){let e=!1;window.addEventListener(`pagehide`,()=>{e=!!NC.liveLogsController,NC.stopLiveLogs()}),window.addEventListener(`pageshow`,t=>{t.persisted&&e&&NC.ensureLiveLogs()})}var PC=null;Mn(()=>{An(()=>{let e=q.refreshTick;if(PC===null){PC=e;return}e!==PC&&(PC=e,Er(()=>{NC.stopLiveLogs(),NC.startLiveLogs()}))})});function FC(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,uncached_input_tokens:0,cached_input_tokens:0,cache_write_input_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null,rewrite_tokens_saved:0,rewrite_cost_saved:null}}function IC(){return{entries:[],total:0,limit:50,offset:0}}function LC(e,t){let n=[[`model`,e&&e.model],[`provider`,e&&e.provider],[`label`,e&&e.label],[`user_path`,e&&e.user_path]],r=``;for(let[e,i]of n)!i||e===t||(r+=`&`+e+`=`+encodeURIComponent(i));return r}function RC({limit:e,offset:t,hideCached:n,search:r}){let i=`&limit=`+e+`&offset=`+t;return i+=`&cache_mode=`+(n?`uncached`:`all`),r&&(i+=`&search=`+encodeURIComponent(r)),i}function zC(e,t){let n=new Set(e||[]);return t&&n.add(t),[...n].sort()}function BC(e,t){let n=Number(t&&t.total_requests||0)-Number(e&&e.total_requests||0);return Number.isFinite(n)&&n>0?n:0}function VC(e,t,n){let r=n?e:t,i=Number(r&&r.total_requests||0);return Number.isFinite(i)?i:0}function HC(e,t,n){let r=BC(e,t);return r<=0?``:n?sc(r)+` cached requests hidden`:sc(Number(e&&e.total_requests||0))+` to providers + `+sc(r)+` from cache`}function UC(e){let t=e||{};return t.total_input_cost===null||t.total_input_cost===void 0?``:cc(t.total_input_cost)+` input + `+cc(t.total_output_cost)+` output`}function WC(e){let t=Number(e&&e.rewrite_tokens_saved||0);return Number.isFinite(t)&&t>0?t:0}function GC(e){return WC(e)>0}function KC(e){let t=e||{};return t.rewrite_cost_saved===void 0?null:t.rewrite_cost_saved}function qC(){return`Estimated at 4 net characters removed per token`}function JC(e,t){return t===`costs`?cc(KC(e)):dc(WC(e))}function YC(e,t){let n=t===`costs`,r=n?Number(KC(e)):WC(e);if(!Number.isFinite(r)||r<=0)return null;let i=e&&(n?e.total_cost:e.total_input_tokens);if(i==null)return null;let a=Number(i);return!Number.isFinite(a)||a<0?null:r/(a+r)*100}function XC(e,t){let n=YC(e,t);return n===null?``:(n<.1?`<0.1`:n.toFixed(1))+`% less`}function ZC(e,t){let n=WC(e);if(n<=0)return``;let r=[sc(n)+` estimated prompt token-transmissions removed across provider requests`,qC(),`Savings are summed per provider request; resent conversation history is counted again`],i=KC(e);i!=null&&(r.push(cc(i)+` estimated gross input cost avoided`),r.push(`Prompt-cache changes caused by rewriting are not included`));let a=XC(e,t);return a&&r.push(a+` than the same traffic without rewriting (`+(t===`costs`?`cost`:`tokens`)+`)`),r.join(` +`)}function QC(e){return String(e&&e.cost_source||``).trim()}function $C(e){let t=QC(e);return t===`openrouter_credits`||t===`xai_cost_in_usd_ticks`}function ew(e){switch(QC(e)){case`openrouter_credits`:return`Costs from OpenRouter USD-based credits.`;case`xai_cost_in_usd_ticks`:return`Costs from xAI usage.cost_in_usd_ticks.`;default:return``}}function tw(e){return String(e&&e.cache_type||``).trim().toLowerCase()}function nw(e){let t=tw(e);return t===`exact`||t===`semantic`}function rw(e){let t=tw(e);return t===`exact`?`Exact`:t===`semantic`?`Semantic`:`-`}function iw(e,t){let n=t?String(t):``;return nw(e)?n?`Saved by cache — not charged +`+n:`Saved by cache — not charged`:n}function aw(e){let t=Number(e&&e.cached_input_ratio);return!Number.isFinite(t)||t<=0?0:Math.min(1,t)}function ow(e){return Number(e&&e.cached_input_tokens||0)>0}function sw(e){return ow(e)?(aw(e)*100).toFixed(1)+`%`:``}function cw(e){if(!ow(e))return``;let t=Number(e.cached_input_tokens||0),n=Number(e.uncached_input_tokens||0),r=Number(e.cache_write_input_tokens||0),i=t+n+r,a=[sc(t)+` cached / `+sc(i)+` input tokens`];return r>0&&a.push(sc(r)+` cache write`),a.join(` +`)}function lw(e){let t=[];if(ew(e)&&(t.push(ew(e)),t.push(``)),t.push(`Input: `+cc(e.input_cost)),t.push(`Output: `+cc(e.output_cost)),e.raw_data){t.push(``);for(let[n,r]of Object.entries(e.raw_data)){let e=n.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),i=r&&typeof r==`object`?JSON.stringify(r):sc(r);t.push(e+`: `+i)}}return t.join(` +`)}function uw(e){return Array.isArray(e&&e.labels)?e.labels:[]}function dw(e,t,n){return(e||[]).length>0||t?!0:(n||[]).some(e=>uw(e).length>0)}function fw(e){return e&&typeof e.total_tokens==`number`?e.total_tokens:(e&&e.input_tokens||0)+(e&&e.output_tokens||0)}function pw(e,t){return t?e.total_cost||0:fw(e)}function mw(e,t){return[...e||[]].sort((e,n)=>t?(n.total_cost||0)-(e.total_cost||0):pw(n,t)-pw(e,t))}function hw(e){let t=Array.isArray(e)?e:[];if(t.length===0)return!1;if(t.length!==1)return!0;let n=String(t[0]&&t[0].user_path||``).trim();return n!==``&&n!==`/`}function gw(e){return(e||`chart`)===`chart`||e===`stacked`}function _w(e,t,n){let r=mw(e,n),i=e=>Number(e)||0,a=e=>n?Math.min(i(e.cached_input_cost),i(e.input_cost)):i(e.cached_input_tokens),o=e=>n?i(e.input_cost)-a(e):i(e.uncached_input_tokens)+i(e.cached_input_tokens)+i(e.cache_write_input_tokens)>0?i(e.uncached_input_tokens)+i(e.cache_write_input_tokens):i(e.input_tokens),s=e=>i(n?e.output_cost:e.output_tokens),c=e=>n?0:i(e.local_cached_input_tokens),l=e=>n?0:i(e.local_cached_output_tokens),u=r.slice(0,10),d=r.slice(10),f=u.map(t),p=u.map(o),m=u.map(s),h=u.map(a),g=u.map(c),_=u.map(l);if(d.length>0){f.push(`Other`);let e=e=>d.reduce((t,n)=>t+e(n),0);p.push(e(o)),m.push(e(s)),h.push(e(a)),g.push(e(c)),_.push(e(l))}return{labels:f,inputs:p,outputs:m,prompts:h,localIns:g,localOuts:_}}function vw(e){return Math.max(200,e*32+72)}var yw=new class{#e=k(`tokens`);get usageMode(){return I(this.#e)}set usageMode(e){A(this.#e,e,!0)}get usageFilterModel(){return NC.usageFilterModel}set usageFilterModel(e){NC.usageFilterModel=e}get usageFilterProvider(){return NC.usageFilterProvider}set usageFilterProvider(e){NC.usageFilterProvider=e}get usageFilterLabel(){return NC.usageFilterLabel}set usageFilterLabel(e){NC.usageFilterLabel=e}get usageFilterUserPath(){return NC.usageFilterUserPath}set usageFilterUserPath(e){NC.usageFilterUserPath=e}#t=k(j({models:[],providers:[],labels:[]}));get usageFacetOptions(){return I(this.#t)}set usageFacetOptions(e){A(this.#t,e,!0)}#n=k(j(FC()));get usageSummary(){return I(this.#n)}set usageSummary(e){A(this.#n,e,!0)}#r=k(j(FC()));get usageSummaryAll(){return I(this.#r)}set usageSummaryAll(e){A(this.#r,e,!0)}#i=k(j([]));get modelUsage(){return I(this.#i)}set modelUsage(e){A(this.#i,e,!0)}#a=k(j([]));get userPathUsage(){return I(this.#a)}set userPathUsage(e){A(this.#a,e,!0)}#o=k(j([]));get labelUsage(){return I(this.#o)}set labelUsage(e){A(this.#o,e,!0)}get usageLog(){return NC.usageLog}set usageLog(e){NC.usageLog=e}get usageLogSearch(){return NC.usageLogSearch}set usageLogSearch(e){NC.usageLogSearch=e}get usageLogHideCached(){return NC.usageLogHideCached}set usageLogHideCached(e){NC.usageLogHideCached=e}#s=k(`chart`);get modelUsageView(){return I(this.#s)}set modelUsageView(e){A(this.#s,e,!0)}#c=k(`chart`);get userPathUsageView(){return I(this.#c)}set userPathUsageView(e){A(this.#c,e,!0)}#l=k(`chart`);get labelUsageView(){return I(this.#l)}set labelUsageView(e){A(this.#l,e,!0)}#u=k(!1);get summaryLoading(){return I(this.#u)}set summaryLoading(e){A(this.#u,e,!0)}#d=k(!1);get modelUsageLoading(){return I(this.#d)}set modelUsageLoading(e){A(this.#d,e,!0)}#f=k(!1);get userPathUsageLoading(){return I(this.#f)}set userPathUsageLoading(e){A(this.#f,e,!0)}#p=k(!1);get labelUsageLoading(){return I(this.#p)}set labelUsageLoading(e){A(this.#p,e,!0)}#m=k(!1);get usageLogLoading(){return I(this.#m)}set usageLogLoading(e){A(this.#m,e,!0)}#h={};#g(e){this.#h[e]&&this.#h[e].abort();let t=new AbortController;return this.#h[e]=t,t}#_(e,t){this.#h[e]===t&&(this.#h[e]=null)}filterQueryStr(e){return LC({model:this.usageFilterModel,provider:this.usageFilterProvider,label:this.usageFilterLabel,user_path:this.usageFilterUserPath},e)}onUsageFilterChanged(){this.fetchUsagePage()}toggleUsageLabelFilter(e){this.usageFilterLabel=this.usageFilterLabel===e?``:e,this.onUsageFilterChanged()}usageLabelChipTitle(e){return this.usageFilterLabel===e?`Clear label filter`:`Filter usage by "`+e+`"`}toggleUsageMode(e){this.usageMode=e,Yo.navigate(`usage`,e===`costs`?`costs`:null)}toggleUsageChartView(e,t){e===`model`&&(this.modelUsageView=t),e===`userPath`&&(this.userPathUsageView=t),e===`label`&&(this.labelUsageView=t)}usageFilterModelOptions(){return zC(this.usageFacetOptions.models,this.usageFilterModel)}usageFilterProviderOptions(){return zC(this.usageFacetOptions.providers,this.usageFilterProvider)}usageFilterLabelOptions(){return zC(this.usageFacetOptions.labels,this.usageFilterLabel)}async fetchUsagePage(){await Cs.ensureLoaded();let e=[this.fetchUsagePageSummary(),this.fetchUsageFacetOptions(),this.fetchModelUsage(),this.fetchUserPathUsage(),this.fetchLabelUsage(),this.fetchUsageLog(!0)];zc.cacheAnalyticsEnabled()&&e.push(zc.fetchCacheOverview(this.filterQueryStr())),await Promise.all(e)}async fetchUsagePageSummary(){let e=this.#g(`summary`);this.summaryLoading=!0;try{let t=Nc.queryStr()+this.filterQueryStr(),[n,r]=await Promise.all([vs(`/admin/usage/summary?`+t+`&cache_mode=uncached`,{label:`usage page summary`,signal:e.signal}),vs(`/admin/usage/summary?`+t+`&cache_mode=all`,{label:`usage page summary (all)`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.usageSummary=FC(),this.usageSummaryAll=FC();return}this.usageSummary=n.data&&typeof n.data==`object`?n.data:FC(),this.usageSummaryAll=r.data&&typeof r.data==`object`?r.data:FC()}catch(e){if(bs(e))return;console.error(`Failed to fetch usage page summary:`,e),this.usageSummary=FC(),this.usageSummaryAll=FC()}finally{this.#_(`summary`,e),this.#h.summary===null&&(this.summaryLoading=!1)}}async fetchUsageFacetOptions(){let e=this.#g(`facets`);try{let t=async(t,n)=>{let r=await vs(t+`?`+Nc.queryStr()+this.filterQueryStr(n),{label:`usage facet options`,signal:e.signal});return r.stale?null:r.ok&&Array.isArray(r.data)?r.data:[]},n=t(`/admin/usage/models`,`model`),r=!this.usageFilterModel&&!this.usageFilterProvider,[i,a,o]=await Promise.all([n,r?n:t(`/admin/usage/models`,`provider`),t(`/admin/usage/labels`,`label`)]);if(e.signal.aborted||i===null||a===null||o===null)return;this.usageFacetOptions={models:i.map(e=>e&&e.model).filter(Boolean),providers:a.map(e=>_c(e)).filter(Boolean),labels:o.map(e=>e&&e.label).filter(Boolean)}}catch(e){if(bs(e))return;console.error(`Failed to fetch usage facet options:`,e),this.usageFacetOptions={models:[],providers:[],labels:[]}}finally{this.#_(`facets`,e)}}async#v(e,t,n,r,i){let a=this.#g(e);i(!0);try{let e=await vs(t+`?`+Nc.queryStr()+this.filterQueryStr(),{label:n,signal:a.signal});if(e.stale||a.signal.aborted)return;if(!e.ok){r([]);return}r(Array.isArray(e.data)?e.data:[])}catch(e){if(bs(e))return;console.error(`Failed to fetch `+n+`:`,e),r([])}finally{this.#_(e,a),this.#h[e]===null&&i(!1)}}fetchModelUsage(){return this.#v(`modelUsage`,`/admin/usage/models`,`usage models`,e=>this.modelUsage=e,e=>this.modelUsageLoading=e)}fetchUserPathUsage(){return this.#v(`userPathUsage`,`/admin/usage/user-paths`,`usage user paths`,e=>this.userPathUsage=e,e=>this.userPathUsageLoading=e)}fetchLabelUsage(){return this.#v(`labelUsage`,`/admin/usage/labels`,`usage labels`,e=>this.labelUsage=e,e=>this.labelUsageLoading=e)}async fetchUsageLog(e){let t=this.#g(`usageLog`);this.usageLogLoading=!0;try{e&&(this.usageLog.offset=0);let n=Nc.queryStr()+this.filterQueryStr();n+=RC({limit:this.usageLog.limit,offset:this.usageLog.offset,hideCached:this.usageLogHideCached,search:this.usageLogSearch});let r=await vs(`/admin/usage/log?`+n,{label:`usage log`,signal:t.signal});if(r.stale||t.signal.aborted)return;if(!r.ok){this.usageLog=IC();return}let i=r.data&&typeof r.data==`object`?r.data:IC();i.entries||=[],this.usageLog=i}catch(e){if(bs(e))return;console.error(`Failed to fetch usage log:`,e),this.usageLog=IC()}finally{this.#_(`usageLog`,t),this.#h.usageLog===null&&(this.usageLogLoading=!1)}}usageLogNextPage(){this.usageLog.offset+this.usageLog.limit0&&(this.usageLog.offset=Math.max(0,this.usageLog.offset-this.usageLog.limit),this.fetchUsageLog(!1))}};NC.fetchUsage=()=>{Yo.page===`usage`&&yw.fetchUsagePage()};var bw=R(`
                    `);function xw(e,t){E(t,!0);let n=G(t,`value`,15,``),r=G(t,`placeholder`,3,``),i=G(t,`label`,3,``),a=G(t,`id`,3,void 0),o=G(t,`oninput`,3,void 0),s=G(t,`class`,3,``);var c=bw(),l=M(c);K(l,{get icon(){return yo},class:`filter-input-icon`});var u=P(l,2);ia(u),T(c),F(()=>{U(c,1,Li([`filter-input-wrap`,s()]),`svelte-30xz1k`),W(u,`id`,a()),W(u,`placeholder`,r()),W(u,`aria-label`,i())}),L(`input`,u,function(...e){o()?.apply(this,e)}),pa(u,n),z(e,c),D()}Hr([`input`]);function Sw(e,t=300){let n=null,r=(...r)=>{clearTimeout(n),n=setTimeout(()=>{n=null,e(...r)},t)};return r.cancel=()=>{clearTimeout(n),n=null},r}var Cw=R(``),ww=R(``),Tw=R(`
                    `);function Ew(e,t){E(t,!0);let n=Sw(()=>yw.onUsageFilterChanged());An(()=>n.cancel);var r=Tw(),i=M(r),a=M(i);a.value=a.__value=``,H(P(a),16,()=>yw.usageFilterModelOptions(),e=>e,(e,t)=>{var n=Cw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(i);var o=P(i,2),s=M(o);s.value=s.__value=``,H(P(s),16,()=>yw.usageFilterProviderOptions(),e=>e,(e,t)=>{var n=Cw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(o);var c=P(o,2),l=e=>{var t=ww(),n=M(t);n.value=n.__value=``,H(P(n),16,()=>yw.usageFilterLabelOptions(),e=>e,(e,t)=>{var n=Cw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(t),L(`change`,t,()=>yw.onUsageFilterChanged()),qi(t,()=>yw.usageFilterLabel,e=>yw.usageFilterLabel=e),z(e,t)},u=O(()=>yw.usageFilterLabelOptions().length>0);V(c,e=>{I(u)&&e(l)}),xw(P(c,2),{class:`usage-page-filters-user-path`,placeholder:`User path /team/alpha`,label:`Filter by user path`,get oninput(){return n},get value(){return yw.usageFilterUserPath},set value(e){yw.usageFilterUserPath=e}}),T(r),L(`change`,i,()=>yw.onUsageFilterChanged()),qi(i,()=>yw.usageFilterModel,e=>yw.usageFilterModel=e),L(`change`,o,()=>yw.onUsageFilterChanged()),qi(o,()=>yw.usageFilterProvider,e=>yw.usageFilterProvider=e),z(e,r),D()}Hr([`change`]);var Dw=R(`
                    Cache Saved
                    Cache Hits
                    `,1);function Ow(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Dw(),n=N(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var a=P(n,2),o=P(M(a),2),s=M(o,!0);T(o),T(a),F((e,t)=>{B(i,e),B(s,t)},[()=>cc(zc.cacheOverview.summary.total_saved_cost),()=>sc(zc.cacheOverview.summary.total_hits)]),z(e,t)},a=O(()=>zc.cacheAnalyticsEnabled());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}var kw=R(` `),Aw=R(`
                    Pro Saved
                    `),jw=R(`
                    Total Requests
                    Estimated Cost
                    `);function Mw(e,t){E(t,!0);let n=O(()=>GC(yw.usageSummary)),r=O(()=>JC(yw.usageSummary,yw.usageMode)),i=O(()=>XC(yw.usageSummary,yw.usageMode));var a=jw(),o=M(a),s=P(M(o),2),c=M(s),l=e=>{CS(e,{size:18,label:`Loading usage summary`})},u=e=>{var t=Zr();F(e=>B(t,e),[()=>sc(VC(yw.usageSummary,yw.usageSummaryAll,yw.usageLogHideCached))]),z(e,t)};V(c,e=>{yw.summaryLoading?e(l):e(u,-1)}),T(s),T(o);var d=P(o,2),f=P(M(d),2),p=M(f),m=e=>{CS(e,{size:18,label:`Loading usage summary`})},h=e=>{var t=Zr();F(e=>B(t,e),[()=>cc(yw.usageSummary.total_cost)]),z(e,t)};V(p,e=>{yw.summaryLoading?e(m):e(h,-1)}),T(f),T(d);var g=P(d,2),_=e=>{var t=Aw(),n=P(M(t),2),a=M(n),o=M(a,!0);T(a);var s=P(a,2),c=e=>{var t=kw(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)};V(s,e=>{I(i)&&e(c)}),T(n),T(t),F(e=>{W(n,`title`,e),B(o,I(r))},[()=>ZC(yw.usageSummary,yw.usageMode)]),z(e,t)};V(g,e=>{I(n)&&e(_)}),Ow(P(g,2),{}),T(a),F((e,t)=>{W(s,`title`,e),W(f,`title`,t)},[()=>HC(yw.usageSummary,yw.usageSummaryAll,yw.usageLogHideCached),()=>UC(yw.usageSummary)]),z(e,a),D()}function Nw(e,t,n,r){let{stacked:i=!1,costs:a=!1,resolve:o=e=>e}=r||{},s=e=>a?`$`+Math.abs(e).toFixed(2):dc(Math.abs(e)),c=e=>a?`$`+Math.abs(e).toFixed(4):Math.abs(e).toLocaleString(),l=e=>e.map(e=>i?Math.abs(e):-Math.abs(e)),u=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:`transparent`,borderWidth:0,borderRadius:4,maxBarThickness:22}),d=e=>(e||[]).some(e=>Math.abs(e)>0),f=[u(a?`Input Cost`:`Input Tokens`,l(n.inputs),o(`var(--token-input)`)),u(a?`Output Cost`:`Output Tokens`,n.outputs,o(`var(--token-output)`))];return d(n.prompts)&&f.push(u(a?`Prompt Cached Cost`:`Prompt Cached`,l(n.prompts),o(`var(--token-prompt)`))),!a&&d(n.localIns)&&f.push(u(`Locally Cached (Input)`,l(n.localIns),o(`var(--token-local)`))),!a&&d(n.localOuts)&&f.push(u(`Locally Cached (Output)`,n.localOuts,o(`var(--token-local)`))),{type:`bar`,data:{labels:t,datasets:f},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:{top:8}},scales:{x:{stacked:!0,beginAtZero:!0,grid:i?{color:e.grid}:{color:t=>t.tick&&t.tick.value===0?e.text:e.grid},border:{display:!1},ticks:{color:e.text,font:Ry(),callback:e=>s(e)}},y:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Ry(),autoSkip:!1}}},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:zy(e,{label:e=>e.dataset.label+`: `+c(e.parsed.x),footer:e=>{let t=0;return e.forEach(e=>{t+=Math.abs(Number(e.parsed.x))||0}),`Total: `+c(t)}})}}}}var Pw=R(`
                    `),Fw=R(`

                    `),Iw=R(`

                    `,1),Lw=R(`
                    `),Rw=R(`Model Provider`,1),zw=R(`User Path`),Bw=R(`Label Requests`,1),Vw=R(` `,1),Hw=R(` `),Uw=R(` `,1),Ww=R(` `),Gw=R(`
                    Input TokensOutput TokensPrompt CachedLocal CachedTotal TokensInput CostOutput CostTotal Cost
                    `),Kw=R(`
                    `),qw=R(`
                    `);function Jw(e,t){E(t,!0);let n=e=>{var n=Pw(),r=M(n);let a;var o=P(r,2);let s;var l=P(o,2);let u;T(n),F(()=>{W(n,`aria-label`,I(i).group),a=U(r,1,`chart-view-btn svelte-1kee4g8`,null,a,{active:I(c)===`chart`}),W(r,`aria-pressed`,I(c)===`chart`),W(r,`aria-label`,`Show ${I(i).noun??``} chart`),s=U(o,1,`chart-view-btn svelte-1kee4g8`,null,s,{active:I(c)===`stacked`}),W(o,`aria-pressed`,I(c)===`stacked`),W(o,`aria-label`,`Show ${I(i).noun??``} stacked chart`),u=U(l,1,`chart-view-btn svelte-1kee4g8`,null,u,{active:I(c)===`table`}),W(l,`aria-pressed`,I(c)===`table`),W(l,`aria-label`,`Show ${I(i).noun??``} table`)}),L(`click`,r,()=>yw.toggleUsageChartView(t.kind,`chart`)),L(`click`,o,()=>yw.toggleUsageChartView(t.kind,`stacked`)),L(`click`,l,()=>yw.toggleUsageChartView(t.kind,`table`)),z(e,n)},r={model:{group:`Model usage view`,noun:`model usage`,tokensTitle:`Token Usage by Model`,costsTitle:`Cost by Model`},userPath:{group:`User path usage view`,noun:`user path usage`,tokensTitle:`Usage by User Path`,costsTitle:`Cost by User Path`},label:{group:`Label usage view`,noun:`label usage`,tokensTitle:`Usage by Label`,costsTitle:`Cost by Label`}},i=O(()=>r[t.kind]),a=O(()=>t.kind===`model`?e=>yc(e):t.kind===`userPath`?e=>e.user_path||`/`:e=>e.label);function o(e){return t.kind===`model`?(e.provider_name||e.provider||`-`)+`/`+e.model:t.kind===`userPath`?e.user_path||`/`:e.label}let s=O(()=>t.kind===`model`?yw.modelUsage:t.kind===`userPath`?yw.userPathUsage:yw.labelUsage),c=O(()=>t.kind===`model`?yw.modelUsageView:t.kind===`userPath`?yw.userPathUsageView:yw.labelUsageView),l=O(()=>t.kind===`model`?yw.modelUsageLoading:t.kind===`userPath`?yw.userPathUsageLoading:yw.labelUsageLoading),u=O(()=>yw.usageMode===`costs`),d=O(()=>t.kind===`userPath`?hw(I(s)):I(s).length>0),f=O(()=>I(u)?I(i).costsTitle:I(i).tokensTitle),p=O(()=>_w(I(s),I(a),I(u))),m=O(()=>mw(I(s),I(u)));function h(){return gw(I(c))?Nw(Ly(),I(p).labels,I(p),{stacked:I(c)===`stacked`,costs:I(u),resolve:By}):null}var g=Qr(),_=N(g),v=e=>{var r=Kw(),a=M(r),s=M(a),u=e=>{JS(e,{copyId:`label-usage-help-copy`,label:`label usage help`,text:`One request can have multiple labels. Such a request counts once under each of its labels, so label rows can overlap and add up to more than the period totals.`,title:e=>{var t=Fw(),n=M(t,!0);T(t),F(()=>B(n,I(f))),z(e,t)},extra:e=>{var t=Qr(),n=N(t),r=e=>{CS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(n,e=>{I(l)&&e(r)}),z(e,t)},$$slots:{title:!0,extra:!0}})},d=e=>{var t=Iw(),n=N(t),r=M(n,!0);T(n);var a=P(n,2),o=e=>{CS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(a,e=>{I(l)&&e(o)}),F(()=>B(r,I(f))),z(e,t)};V(s,e=>{t.kind===`label`?e(u):e(d,-1)});var g=P(s,2);n(g),T(a);var _=P(a,2),v=e=>{var t=Lw();let n;My(M(t),{build:h}),T(t),F(e=>n=Wi(t,``,n,e),[()=>({height:`${vw(I(p).labels.length)??``}px`})]),z(e,t)},y=O(()=>gw(I(c))),b=e=>{var n=Gw(),r=M(n),i=M(r),a=M(i),s=M(a),c=e=>{var t=Rw();Ue(2),z(e,t)},l=e=>{z(e,zw())},u=e=>{var t=Bw();Ue(2),z(e,t)};V(s,e=>{t.kind===`model`?e(c):t.kind===`userPath`?e(l,1):e(u,-1)}),Ue(8),T(a),T(i);var d=P(i);H(d,21,()=>I(m),e=>o(e),(e,n)=>{var r=Ww(),i=M(r),a=e=>{var t=Vw(),r=N(t),i=M(r,!0);T(r);var a=P(r,2),o=M(a),s=M(o,!0);T(o),T(a),F(e=>{B(i,I(n).model||`-`),B(s,e)},[()=>_c(I(n))||`-`]),z(e,t)},o=e=>{var t=Hw(),r=M(t,!0);T(t),F(()=>B(r,I(n).user_path||`/`)),z(e,t)},s=e=>{var t=Uw(),r=N(t),i=M(r);let a;var o=M(i,!0);T(i),T(r);var s=P(r,2),c=M(s,!0);T(s),F((e,t,r)=>{a=U(i,1,`usage-label-chip`,null,a,{active:yw.usageFilterLabel===I(n).label}),Wi(i,`--label-color: ${e??``}`),W(i,`title`,t),B(o,I(n).label),B(c,r)},[()=>Uy(I(n).label),()=>yw.usageLabelChipTitle(I(n).label),()=>sc(I(n).requests)]),L(`click`,i,()=>yw.toggleUsageLabelFilter(I(n).label)),z(e,t)};V(i,e=>{t.kind===`model`?e(a):t.kind===`userPath`?e(o,1):e(s,-1)});var c=P(i),l=M(c,!0);T(c);var u=P(c),d=M(u,!0);T(u);var f=P(u),p=M(f,!0);T(f);var m=P(f),h=M(m,!0);T(m);var g=P(m),_=M(g,!0);T(g);var v=P(g),y=M(v,!0);T(v);var b=P(v),x=M(b,!0);T(b);var S=P(b),C=M(S,!0);T(S),T(r),F((e,t,n,r,i,a,o,s,c,u,g)=>{B(l,e),B(d,t),W(f,`title`,n),B(p,r),W(m,`title`,`${i??``} input + ${a??``} output`),B(h,o),B(_,s),B(y,c),B(x,u),B(C,g)},[()=>sc(I(n).input_tokens),()=>sc(I(n).output_tokens),()=>I(n).cached_input_cost==null?``:`~`+cc(I(n).cached_input_cost)+` at current cached-input pricing`,()=>sc(I(n).cached_input_tokens||0),()=>sc(I(n).local_cached_input_tokens||0),()=>sc(I(n).local_cached_output_tokens||0),()=>sc((I(n).local_cached_input_tokens||0)+(I(n).local_cached_output_tokens||0)),()=>sc(fw(I(n))),()=>cc(I(n).input_cost),()=>cc(I(n).output_cost),()=>cc(I(n).total_cost)]),z(e,r)}),T(d),T(r),T(n),z(e,n)};V(_,e=>{I(y)?e(v):e(b,-1)}),T(r),z(e,r)},y=e=>{var t=qw();CS(M(t),{size:20,get label(){return`Loading ${I(i).noun??``}`}}),T(t),z(e,t)};V(_,e=>{I(d)?e(v):I(l)&&e(y,1)}),z(e,g),D()}Hr([`click`]);var Yw=R(``);function Xw(e,t){E(t,!0);let n=G(t,`total`,3,0),r=G(t,`offset`,3,0),i=G(t,`limit`,3,25);var a=Qr(),o=N(a),s=e=>{var a=Yw(),o=M(a),s=M(o);T(o);var c=P(o,2),l=M(c),u=P(l,2);T(c),T(a),F(e=>{B(s,`Showing ${r()+1}-${e??``} of ${n()??``}`),l.disabled=r()===0,u.disabled=r()+i()>=n()},[()=>Math.min(r()+i(),n())]),L(`click`,l,()=>t.onprev?.()),L(`click`,u,()=>t.onnext?.()),z(e,a)};V(o,e=>{n()>0&&e(s)}),z(e,a),D()}Hr([`click`]);var Zw=(e,t=f)=>{var n=Qr(),r=N(n),i=e=>{var n=$w();H(n,20,()=>uw(t()),e=>e,(e,t)=>{var n=Qw();let r;var i=M(n,!0);T(n),F((e,a)=>{r=U(n,1,`usage-label-chip`,null,r,{active:yw.usageFilterLabel===t}),Wi(n,`--label-color: ${e??``}`),W(n,`title`,a),B(i,t)},[()=>Uy(t),()=>yw.usageLabelChipTitle(t)]),L(`click`,n,()=>yw.toggleUsageLabelFilter(t)),z(e,n)}),T(n),z(e,n)},a=O(()=>uw(t()).length>0),o=e=>{z(e,eT())};V(r,e=>{I(a)?e(i):e(o,-1)}),z(e,n)},Qw=R(``),$w=R(`
                    `),eT=R(`-`),tT=R(`Labels`),nT=R(`Cost`),rT=R(``),iT=R(` `),aT=R(``),oT=R(` `),sT=R(` `),cT=R(`
                    TimestampProviderModelUser PathCacheProvider Cache
                    `),lT=R(`
                    `),uT=R(`
                    `),dT=R(`

                    Request Log

                    `);function fT(e,t){E(t,!0);let n=O(()=>yw.usageMode===`costs`),r=O(()=>dw(yw.labelUsage,yw.usageFilterLabel,yw.usageLog.entries)),i=Sw(()=>yw.fetchUsageLog(!0));An(()=>i.cancel);var a=dT(),o=P(M(a),2),s=M(o);xw(M(s),{placeholder:`Search by request ID, model, provider...`,label:`Search by request ID, model, provider`,get oninput(){return i},get value(){return yw.usageLogSearch},set value(e){yw.usageLogSearch=e}}),T(s);var c=P(s,2),l=M(c),u=M(l);ia(u),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=e=>{var t=cT(),i=M(t),a=M(i),o=M(a),s=P(M(o),4),c=e=>{z(e,tT())};V(s,e=>{I(r)&&e(c)});var l=P(s,3),u=M(l,!0);T(l);var d=P(l),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{z(e,nT())};V(h,e=>{I(n)||e(g)}),T(o),T(a);var _=P(a);H(_,21,()=>yw.usageLog.entries,e=>e.id,(e,t)=>{var i=sT();let a;var o=M(i),s=M(o,!0);T(o);var c=P(o),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{var n=rT();Zw(M(n),()=>I(t)),T(n),z(e,n)};V(h,e=>{I(r)&&e(g)});var _=P(h),v=M(_,!0);T(_);var y=P(_),b=M(y),x=e=>{var n=iT(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>sw(I(t))]),z(e,n)},S=O(()=>ow(I(t))),C=e=>{z(e,eT())};V(b,e=>{I(S)?e(x):e(C,-1)}),T(y);var w=P(y),ee=M(w,!0);T(w);var te=P(w),ne=M(te,!0);T(te);var re=P(te),ie=M(re),ae=M(ie,!0);T(ie);var oe=P(ie,2),se=e=>{{let n=O(()=>ew(I(t)));K(e,{get icon(){return Ja},class:`cost-source-icon`,get title(){return I(n)}})}},ce=O(()=>I(n)&&$C(I(t)));V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{K(e,{get icon(){return Za},class:`cache-savings-icon`})},de=O(()=>I(n)&&nw(I(t)));V(le,e=>{I(de)&&e(ue)});var fe=P(le,2),pe=e=>{var n=aT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(fe,e=>{I(n)&&I(t).costs_calculation_caveat&&e(pe)}),T(re);var me=P(re),he=e=>{var n=oT(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{{let n=O(()=>ew(I(t)));K(e,{get icon(){return Ja},class:`cost-source-icon`,get title(){return I(n)}})}},s=O(()=>$C(I(t)));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{K(e,{get icon(){return Za},class:`cache-savings-icon`})},u=O(()=>nw(I(t)));V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=e=>{var n=aT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(d,e=>{I(t).costs_calculation_caveat&&e(f)}),T(n),F((e,t)=>{W(n,`title`,e),B(i,t)},[()=>iw(I(t),lw(I(t))),()=>cc(I(t).total_cost)]),z(e,n)};V(me,e=>{I(n)||e(he)}),T(i),F((e,n,r,c,l,d,p,h,g,_,b,x,S)=>{a=U(i,1,`svelte-hg4ill`,null,a,e),W(o,`title`,n),B(s,r),B(u,c),B(f,I(t).model),B(m,I(t).user_path||`-`),B(v,l),W(y,`title`,d),W(w,`title`,p),B(ee,h),W(te,`title`,g),B(ne,_),W(re,`title`,b),W(ie,`title`,x),B(ae,S)},[()=>({"usage-log-row-cached":nw(I(t))}),()=>hc(I(t).timestamp),()=>fs.formatTimestamp(I(t).timestamp),()=>_c(I(t))||`-`,()=>rw(I(t)),()=>cw(I(t)),()=>I(n)?sc(I(t).input_tokens)+` tokens`:``,()=>I(n)?cc(I(t).input_cost):sc(I(t).input_tokens),()=>I(n)?sc(I(t).output_tokens)+` tokens`:``,()=>I(n)?cc(I(t).output_cost):sc(I(t).output_tokens),()=>I(n)?iw(I(t),``):``,()=>I(n)?iw(I(t),sc(I(t).total_tokens)+` tokens +`+lw(I(t))):``,()=>I(n)?cc(I(t).total_cost):sc(I(t).total_tokens)]),z(e,i)}),T(_),T(i),T(t),F(()=>{B(u,I(n)?`Input Cost`:`Input`),B(f,I(n)?`Output Cost`:`Output`),B(m,I(n)?`Total Cost`:`Total`)}),z(e,t)},p=e=>{var t=lT();CS(M(t),{size:20,label:`Loading request log`}),T(t),z(e,t)},m=e=>{var t=uT();ES(M(t),{}),T(t),z(e,t)};V(d,e=>{yw.usageLog.entries.length>0?e(f):yw.usageLogLoading?e(p,1):e(m,-1)}),Xw(P(d,2),{get total(){return yw.usageLog.total},get offset(){return yw.usageLog.offset},get limit(){return yw.usageLog.limit},onprev:()=>yw.usageLogPrevPage(),onnext:()=>yw.usageLogNextPage()}),T(a),L(`change`,u,()=>yw.fetchUsageLog(!0)),ma(u,()=>yw.usageLogHideCached,e=>yw.usageLogHideCached=e),z(e,a),D()}Hr([`click`,`change`]);var pT=R(`
                    `);function mT(e,t){E(t,!0);let n=`usage`;An(()=>{q.refreshTick,Yo.page===n&&(yw.fetchUsagePage(),NC.ensureLiveLogs())}),An(()=>{Yo.page===n&&(yw.usageMode=Yo.sub===`costs`?`costs`:`tokens`)});var r=pT(),i=P(M(r),2),a=M(i);Fy(a,{ariaLabel:`Usage mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return yw.usageMode},onchange:e=>yw.toggleUsageMode(e)}),nl(P(a,2),{onchange:()=>yw.fetchUsagePage()}),T(i);var o=P(i,2);Ew(o,{});var s=P(o,2);Mw(s,{});var c=P(s,2),l=M(c);Jw(l,{kind:`model`});var u=P(l,2);Jw(u,{kind:`userPath`}),Jw(P(u,2),{kind:`label`}),T(c),fT(P(c,2),{}),T(r),z(e,r),D()}var hT=R(`
                    `);function gT(e,t){let n=G(t,`label`,3,`Loading...`),r=G(t,`class`,3,``);var i=hT(),a=P(M(i),2),o=M(a,!0);T(a),T(i),F(()=>{U(i,1,Li([`loading-state`,r()]),`svelte-hzxv1d`),B(o,n())}),z(e,i)}var _T=R(``);function vT(e,t){let n=G(t,`label`,3,``),r=G(t,`class`,3,``),i=G(t,`disabled`,3,!1);var a=_T();vi(M(a),()=>t.children??f),T(a),F(()=>{U(a,1,Li([`table-action-btn`,r()])),W(a,`aria-label`,n()),W(a,`title`,n()),a.disabled=i()}),L(`click`,a,function(...e){t.onclick?.apply(this,e)}),z(e,a)}Hr([`click`]);async function yT(e,{label:t,errorFallback:n=`Unable to load ${t}.`,unavailableStatuses:r=[503],normalize:i=e=>Array.isArray(e)?e:[],options:a}){let o;try{o=await vs(e,{...a||{},label:t})}catch(e){return bs(e)||console.error(`Failed to fetch ${t}:`,e),{status:`error`,items:[],error:n,result:null}}return o.stale?{status:`stale`,items:[],error:``,result:o}:r.includes(o.status)?{status:`unavailable`,items:[],error:``,result:o}:o.ok?{status:`ok`,items:i(o.data),error:``,result:o}:{status:`error`,items:[],error:o.status===401?``:ps(o.data,n),result:o}}async function bT(e,t,n,{label:r,errorFallback:i=`Unable to ${r}.`,unavailableStatuses:a=[503],unavailableMessage:o=`This feature is unavailable on the gateway.`,options:s}){let c;try{c=await ys(e,t,n,{...s||{},label:r})}catch(e){return bs(e)||console.error(`Failed to ${r}:`,e),{status:`error`,error:i,result:null}}return c.stale?{status:`stale`,error:``,result:c}:a.includes(c.status)?{status:`unavailable`,error:o,result:c}:c.ok?{status:`ok`,error:``,result:c}:{status:`error`,error:c.status===401?`Authentication required.`:ps(c.data,i),result:c}}function xT(){return{scope:`user_path`,subject:`/`,period:`daily`,period_seconds:86400,amount:``,source:`manual`}}function ST(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},label:{label:`Label`,chip:`label`,fieldLabel:`Label`,placeholder:`Mobile-App-iOS`}};return t[e]||t.user_path}function CT(){return[`user_path`,`label`].map(e=>({value:e,label:ST(e).label}))}function wT(e){return String(e&&e.scope||``).trim()||`user_path`}function TT(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function ET(e){return ST(wT(e)).chip}function DT(e){return wT(e)===`label`?`budget-label`:`budget-user-path`}function OT(e){return ST(String(e&&e.scope||``)).fieldLabel}function kT(e){return ST(String(e&&e.scope||``)).placeholder}function AT(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function jT(){return[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`},{value:`custom`,label:`Custom seconds`}]}function MT(e){switch(String(e||``).trim().toLowerCase()){case`hourly`:return 3600;case`daily`:return 86400;case`weekly`:return 604800;case`monthly`:return 2592e3;default:return 0}}function NT(e){switch(Number(e||0)){case 3600:return`hourly`;case 86400:return`daily`;case 604800:return`weekly`;case 2592e3:return`monthly`;default:return`custom`}}function PT(e){return wT(e)+`:`+TT(e)+`:`+String(e&&e.period_seconds||``)}function FT(e,t){if(!t||!Array.isArray(e))return null;let n=PT(t);return e.find(e=>PT(e)===n)||null}function IT(e){let t=String(e||``).trim();if(!t)return`User path is required.`;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function LT(e){if(IT(e))return``;let t=String(e||``).trim(),n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function RT(e){return`/`+String(e||``).trimStart().replace(/^\/+/,``)}function zT(e){return Array.isArray(e)?e:e&&Array.isArray(e.budgets)?e.budgets:[]}function BT(e){let t=Number(e&&e.period_seconds||0);return[TT(e),ET(e),rE(e),NT(t),t?String(t)+`s`:``,t?String(t)+` seconds`:``].join(` `).toLowerCase()}var VT={user_path:0,label:1};function HT(e,t){let n=Array.isArray(e)?e.slice():[],r=String(t||`subject`);return n.sort((e,t)=>{let n=(VT[wT(e)]||0)-(VT[wT(t)]||0),i=TT(e).localeCompare(TT(t)),a=Number(t&&t.period_seconds||0)-Number(e&&e.period_seconds||0);return r===`period`?a||n||i:n||i||a}),n}function UT(e,t,n){let r=Array.isArray(e)?e:[],i=String(t||``).trim().toLowerCase();return HT(i?r.filter(e=>BT(e).includes(i)):r.slice(),n)}function WT(e){let t=e||{},n=wT(t),r=String(t.subject||``).trim();if(n===`user_path`){let e=IT(r);if(e)return{payload:null,error:e}}else if(!r)return{payload:null,error:`Label is required.`};let i=Number(t.amount);if(!Number.isFinite(i)||i<=0)return{payload:null,error:`Amount must be greater than 0.`};let a=String(t.period||``).trim(),o=MT(a);return a===`custom`&&(o=Number(t.period_seconds)),!Number.isFinite(o)||o<=0?{payload:null,error:`Period seconds must be greater than 0.`}:{payload:{scope:n,subject:n===`user_path`?LT(r):r,period_seconds:Math.trunc(o),amount:i,source:String(t.source||`manual`).trim()||`manual`},error:``}}function GT(e){return{scope:wT(e),subject:TT(e),budget_key:{period_seconds:e.period_seconds},amount:e.amount}}function KT(e){return{scope:wT(e),subject:TT(e),budget_key:{period_seconds:e.period_seconds}}}function qT(e){return{scope:wT(e),subject:TT(e),period_seconds:e.period_seconds}}function JT(e){return cc(e)}function YT(e,t){let n=e||{},r=t||{};return`A budget for "`+((TT(n)||TT(r))+` `+rE({period_seconds:n.period_seconds||r.period_seconds,period_label:r.period_label}))+`" already exists. Saving will override the current `+JT(r.amount)+` limit with `+JT(n.amount)+`.`}function XT(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:t}function ZT(e,t){let n=XT(e);return Math.round((t?Math.min(n,1):n)*1e3)/10}function QT(e){return XT(e&&e.usage_ratio)}function $T(e){return ZT(QT(e),!0)}function eE(e){return ZT(e&&e.period_ratio,!0)}function tE(e){return ZT(QT(e),!1).toFixed(1).replace(/\.0$/,``)+`%`}function nE(e){return eE(e).toFixed(1).replace(/\.0$/,``)+`%`}function rE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`Hourly`;case 86400:return`Daily`;case 604800:return`Weekly`;case 2592e3:return`Monthly`;default:{let n=String(e&&e.period_label||``).trim();return n?`Custom `+n:`Custom `+String(t||``)+`s`}}}function iE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return`budget-period-label-hourly`;case 86400:return`budget-period-label-daily`;case 604800:return`budget-period-label-weekly`;case 2592e3:return`budget-period-label-monthly`;default:return`budget-period-label-custom`}}function aE(e){return iE(e).replace(`budget-period-label-`,`budget-bar-fill-period-`)}function oE(e){return iE(e).replace(`budget-period-label-`,`budget-bar-track-period-`)}function sE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return Ya;case 86400:return Oo;case 604800:return Ra;case 2592e3:return za;default:return So}}function cE(e){let t=Math.max(0,Math.trunc(Number(e||0)));return t+` `+(t===1?`second`:`seconds`)}function lE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`1 hour`;case 86400:return`1 day`;case 604800:return`1 week`;case 2592e3:return`1 month`;default:return cE(t)}}function uE(e){return String(e&&e.source||``).trim()||`manual`}function dE(e){let t=uE(e).toLowerCase();return t===`manual`?`Created from the dashboard.`:t===`config`?`Loaded from configuration.`:`Budget source: `+t}function fE(e){let t=Number(e&&e.remaining);return Number.isFinite(t)?t<0?cc(Math.abs(t))+` over`:cc(t)+` remaining`:``}var Y=new class{#e=k(j([]));get budgets(){return I(this.#e)}set budgets(e){A(this.#e,e,!0)}#t=k(!0);get budgetsAvailable(){return I(this.#t)}set budgetsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get filter(){return I(this.#r)}set filter(e){A(this.#r,e,!0)}#i=k(`subject`);get sortBy(){return I(this.#i)}set sortBy(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(!1);get formOpen(){return I(this.#o)}set formOpen(e){A(this.#o,e,!0)}#s=k(!1);get formSubmitting(){return I(this.#s)}set formSubmitting(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get editing(){return I(this.#l)}set editing(e){A(this.#l,e,!0)}#u=k(j(xT()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(!1);get overrideDialogOpen(){return I(this.#d)}set overrideDialogOpen(e){A(this.#d,e,!0)}#f=k(null);get overridePendingPayload(){return I(this.#f)}set overridePendingPayload(e){A(this.#f,e,!0)}#p=k(null);get overrideExistingBudget(){return I(this.#p)}set overrideExistingBudget(e){A(this.#p,e,!0)}#m=k(``);get resettingKey(){return I(this.#m)}set resettingKey(e){A(this.#m,e,!0)}#h=k(``);get deletingKey(){return I(this.#h)}set deletingKey(e){A(this.#h,e,!0)}#g=k(!1);get resetAllLoading(){return I(this.#g)}set resetAllLoading(e){A(this.#g,e,!0)}#_=null;managementEnabled(){return Cs.budgetsVisible()}filteredBudgets(){return UT(this.budgets,this.filter,this.sortBy)}async fetchBudgetsPage(){if(await Cs.ensureLoaded(),!this.managementEnabled()){this.budgets=[],this.budgetsAvailable=!1,this.error=``;return}return this.#_||=this.fetchBudgets().finally(()=>{this.#_=null}),this.#_}async fetchBudgets(){this.loading=!0,this.error=``;let e=await yT(`/admin/budgets`,{label:`budgets`,errorFallback:`Unable to load budgets.`,normalize:zT});if(this.loading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.budgetsAvailable=!1,this.budgets=[];return}if(!e.result){this.budgets=[],this.error=e.error;return}if(this.budgetsAvailable=!0,e.status===`error`){this.error=e.error;return}this.budgets=e.items}}openForm(e){if(this.editing=!!e,this.formError=``,e){let t=Number(e.period_seconds||0);this.form={scope:wT(e),subject:TT(e),period:NT(t),period_seconds:t,amount:String(e.amount||``),source:String(e.source||`manual`)}}else this.form=xT();this.formOpen=!0}syncPeriodSeconds(){let e=MT(String(this.form.period||``).trim());e>0&&(this.form.period_seconds=e)}setFormSubject(e){this.form.subject=this.form.scope===`label`?String(e??``):RT(e)}syncScope(){AT(this.form)}closeForm(){this.closeOverrideDialog(),this.formOpen=!1,this.formSubmitting=!1,this.formError=``,this.editing=!1,this.form=xT()}async submitForm(){if(this.formSubmitting)return;let{payload:e,error:t}=WT(this.form);if(!e){this.formError=t;return}if(!this.editing){let t=FT(this.budgets,e);if(t){this.openOverrideDialog(t,e);return}}await this.saveBudgetPayload(e)}async saveBudgetPayload(e){if(this.formSubmitting||!e)return;this.formSubmitting=!0,this.formError=``;let t=await bT(`/admin/budgets`,`PUT`,GT(e),{label:`save budget`,errorFallback:`Unable to save budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.formSubmitting=!1,t.status!==`stale`){if(t.status===`unavailable`){this.budgetsAvailable=!1,this.formError=t.error;return}if(t.status===`error`){this.formError=t.error;return}this.closeForm(),J.success(`Budget saved.`),this.fetchBudgets()}}openOverrideDialog(e,t){this.overrideExistingBudget=e||null,this.overridePendingPayload=t||null,this.overrideDialogOpen=!0}closeOverrideDialog(){this.overrideDialogOpen=!1,this.overridePendingPayload=null,this.overrideExistingBudget=null}async confirmOverride(){if(!this.overridePendingPayload){this.closeOverrideDialog();return}let e=this.overridePendingPayload;this.closeOverrideDialog(),await this.saveBudgetPayload(e)}async resetBudget(e){if(!e)return;let t=PT(e);if(this.resettingKey===t)return;let n=TT(e)+` `+rE(e);if(!confirm(`Reset budget "`+n+`"?`))return;this.resettingKey=t;let r=await bT(`/admin/budgets/reset-one`,`POST`,qT(e),{label:`reset budget`,errorFallback:`Unable to reset budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.resettingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,J.error(r.error);return}if(r.status===`error`){J.error(r.error);return}J.success(`Budget reset.`),this.fetchBudgets()}}async deleteBudget(e){if(!e)return;let t=PT(e);if(this.deletingKey===t)return;let n=TT(e)+` `+rE(e);if(!confirm(`Delete budget "`+n+`"? This cannot be undone.`))return;this.deletingKey=t;let r=await bT(`/admin/budgets`,`DELETE`,KT(e),{label:`delete budget`,errorFallback:`Unable to delete budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.deletingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,J.error(r.error);return}if(r.status===`error`){J.error(r.error);return}this.budgets=zT(r.result.data),J.success(`Budget deleted.`)}}openResetDialog(){zs.open({title:`Reset Budgets`,titleId:`budgetResetDialogTitle`,inputId:`budget-reset-confirmation`,requiredText:`reset`,confirmLabel:`Reset All Budgets`,icon:_o,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.resetAllBudgets()})}async resetAllBudgets(){if(this.resetAllLoading)return;this.resetAllLoading=!0;let e=await bT(`/admin/budgets/reset`,`POST`,{confirmation:`reset`},{label:`reset budgets`,errorFallback:`Unable to reset budgets.`,unavailableStatuses:[]});if(this.resetAllLoading=!1,e.status!==`stale`){if(e.status!==`ok`){zs.error=e.error;return}zs.close(),J.success(`Budgets reset.`),Yo.page===`budgets`&&this.fetchBudgets()}}},pE=R(` Edit`,1),mE=R(` `,1),hE=R(`
                    Usage
                    Period
                    `),gE=R(`
                    `);function _E(e,t){E(t,!0);let n=G(t,`budgets`,19,()=>[]);function r(e){if(!e)return``;let t=fs.formatTimestamp(e);return!t||t===`-`?``:t+` `+fs.effectiveTimeZoneLabel()}var i=gE();H(i,21,n,e=>PT(e),(e,t)=>{var n=hE(),i=M(n),a=M(i),o=M(a),s=M(o),c=e=>{K(e,{get icon(){return ko},class:`budget-scope-icon`})},l=O(()=>wT(I(t))===`label`);V(s,e=>{I(l)&&e(c)});var u=P(s);T(o);var d=P(o,2),f=M(d),p=M(f);{let e=O(()=>sE(I(t)));K(p,{get icon(){return I(e)},class:`budget-period-icon`})}var m=P(p,2),h=M(m,!0);T(m),T(f),T(d);var g=P(d,2),_=M(g),v=M(_),y=M(v,!0);T(v),T(_);var b=P(_,2),x=M(b);vT(x,{label:`Edit budget`,class:`budget-action-btn`,onclick:()=>Y.openForm(I(t)),children:(e,t)=>{var n=pE();K(N(n),{get icon(){return fo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}});var S=P(x,2);{let e=O(()=>Y.resettingKey===PT(I(t))?`Resetting budget`:`Reset budget`),n=O(()=>Y.resettingKey===PT(I(t)));vT(S,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>Y.resetBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=mE(),i=N(r);K(i,{get icon(){return _o},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.resettingKey===PT(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var C=P(S,2);{let e=O(()=>Y.deletingKey===PT(I(t))?`Deleting budget`:`Delete budget`),n=O(()=>Y.deletingKey===PT(I(t)));vT(C,{get label(){return I(e)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>Y.deleteBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=mE(),i=N(r);K(i,{get icon(){return jo},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.deletingKey===PT(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}T(b),T(g),T(a);var w=P(a,2),ee=M(w),te=M(ee),ne=P(M(te),2),re=M(ne,!0);T(ne),T(te);var ie=P(te,2),ae=M(ie);let oe;var se=P(ae,2),ce=M(se),le=M(ce,!0);T(ce);var ue=P(ce,2),de=M(ue,!0);T(ue),T(se);var fe=P(se,2),pe=M(fe),me=M(pe,!0);T(pe);var he=P(pe,2),ge=M(he,!0);T(he),T(fe),T(ie),T(ee);var _e=P(ee,2),ve=M(_e),ye=P(M(ve),2),be=M(ye,!0);T(ye),T(ve);var xe=P(ve,2),Se=M(xe),Ce=P(Se,2),we=M(Ce),Te=M(we,!0);T(we);var Ee=P(we,2),De=M(Ee,!0);T(Ee);var Oe=P(Ee,2),ke=M(Oe,!0);T(Oe),T(Ce);var Ae=P(Ce,2),je=M(Ae),Me=M(je,!0);T(je);var Ne=P(je,2),Pe=M(Ne,!0);T(Ne);var Fe=P(Ne,2),Ie=M(Fe,!0);T(Fe),T(Ae),T(xe),T(_e),T(w),T(i),T(n),F((e,t,n,r,i,a,s,c,l,d,p,m,g,_,b,x,S,C,w,ee,te,ne,se,ce,ue,fe,pe,he,_e,ve)=>{U(o,1,`budget-scope-value ${e??``}`,`svelte-1jm56wo`),Wi(o,t),W(o,`title`,n),B(u,` ${r??``}`),U(f,1,`budget-period-label ${i??``}`,`svelte-1jm56wo`),B(h,a),W(v,`title`,s),B(y,c),B(re,l),W(ie,`aria-valuenow`,d),W(ie,`aria-label`,p),Wi(ie,`--budget-progress: ${m??``}%`),oe=U(ae,1,`budget-bar-fill budget-bar-fill-usage`,null,oe,g),B(le,_),B(de,b),B(me,x),B(ge,S),B(be,C),U(xe,1,`budget-bar-track ${w??``}`,`svelte-1jm56wo`),W(xe,`aria-valuenow`,ee),Wi(xe,`--budget-progress: ${te??``}%`),U(Se,1,`budget-bar-fill budget-bar-fill-period ${ne??``}`,`svelte-1jm56wo`),W(we,`title`,se),B(Te,ce),B(De,ue),W(Oe,`title`,fe),B(ke,pe),B(Me,he),B(Pe,_e),B(Ie,ve)},[()=>DT(I(t)),()=>wT(I(t))===`label`?`--label-color: `+Uy(TT(I(t))):void 0,()=>ET(I(t))+`: `+TT(I(t)),()=>TT(I(t)),()=>iE(I(t)),()=>rE(I(t)),()=>dE(I(t)),()=>uE(I(t)),()=>tE(I(t)),()=>$T(I(t)),()=>`Budget usage: `+cc(I(t).spent)+` of `+cc(I(t).amount)+`, `+fE(I(t)),()=>$T(I(t)),()=>({"budget-bar-fill-danger":QT(I(t))>=1}),()=>cc(I(t).spent)+` of `+cc(I(t).amount),()=>fE(I(t)),()=>cc(I(t).spent)+` of `+cc(I(t).amount),()=>fE(I(t)),()=>nE(I(t)),()=>oE(I(t)),()=>eE(I(t)),()=>eE(I(t)),()=>aE(I(t)),()=>r(I(t).period_start),()=>fs.formatTimestamp(I(t).period_start),()=>lE(I(t)),()=>r(I(t).period_end),()=>fs.formatTimestamp(I(t).period_end),()=>fs.formatTimestamp(I(t).period_start),()=>lE(I(t)),()=>fs.formatTimestamp(I(t).period_end)]),z(e,n)}),T(i),z(e,i),D()}var vE=R(`

                    `,1),yE=R(``),bE=R(``),xE=R(`
                    `);function SE(e,t){E(t,!0);let n=G(t,`open`,3,!1),r=G(t,`title`,3,``),i=G(t,`ariaLabel`,3,``),a=G(t,`error`,3,``),o=G(t,`submitting`,3,!1),s=G(t,`submitDisabled`,3,!1),c=G(t,`submitLabel`,3,`Save`),l=G(t,`submittingLabel`,3,`Saving...`),u=G(t,`submitIcon`,3,vo),d=G(t,`cancel`,3,!0),p=G(t,`dialogClass`,3,``),m=G(t,`novalidate`,3,!1),h=G(t,`canClose`,3,()=>!0);function g(){q.dialogOpen||h()()&&t.onclose?.()}Ps(e,{get open(){return n()},variant:`editor`,onclose:g,children:(e,n)=>{var h=xE(),g=M(h),_=M(g),v=M(_),y=M(v),b=e=>{var n=Qr();vi(N(n),()=>t.header),z(e,n)},x=e=>{var n=vE(),i=N(n),a=M(i,!0);T(i);var o=P(i,2),s=e=>{var n=Qr();vi(N(n),()=>t.headerHint),z(e,n)};V(o,e=>{t.headerHint&&e(s)}),F(()=>B(a,r())),z(e,n)};V(y,e=>{t.header?e(b):e(x,-1)}),T(v);var S=P(v,2);{let e=O(()=>`Close `+(i()||r()).toLowerCase());As(S,{get label(){return I(e)},onclick:()=>t.onclose?.()})}T(_);var C=P(_,2);vi(C,()=>t.children??f);var w=P(C,2),ee=e=>{var t=yE(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(w,e=>{a()&&e(ee)});var te=P(w,2),ne=M(te),re=e=>{var n=bE();L(`click`,n,()=>t.onclose?.()),z(e,n)};V(ne,e=>{d()&&e(re)});var ie=P(ne,2),ae=e=>{var n=Qr();vi(N(n),()=>t.extraActions),z(e,n)};V(ie,e=>{t.extraActions&&e(ae)});var oe=P(ie,2),se=M(oe);K(se,{get icon(){return u()},class:`form-action-icon`});var ce=P(se,2),le=M(ce,!0);T(ce),T(oe),T(te),T(g),T(h),F(()=>{U(h,1,Li([`model-editor`,p()])),W(h,`aria-label`,i()||r()),g.noValidate=m(),oe.disabled=o()||s(),B(le,o()?l():c())}),Vr(`submit`,g,e=>{e.preventDefault(),t.onsubmit?.()}),z(e,h)},$$slots:{default:!0}}),D()}Hr([`click`]);var CE=R(`
                    `);function wE(e,t){let n=G(t,`label`,3,``);var r=CE(),i=M(r),a=M(i,!0);T(i),vi(P(i,2),()=>t.children??f),T(r),F(()=>{W(i,`for`,t.id),B(a,n())}),z(e,r)}var TE=R(``),EE=R(``),DE=R(``),OE=R(``),kE=R(``),AE=R(``),jE=R(`

                    Editing a budget updates its limit only. Use Reset to start a new + budget period.

                    `),ME=R(`
                    `,1),NE=R(``),PE=R(` `,1);function FE(e,t){E(t,!0);function n(e){Y.setFormSubject(e.target.value),e.target.value=Y.form.subject}var r=PE(),i=N(r);{let e=O(()=>Y.editing?`Edit Budget`:`Create Budget`);SE(i,{get open(){return Y.formOpen},get title(){return I(e)},ariaLabel:`Budget editor`,get error(){return Y.formError},get submitting(){return Y.formSubmitting},submitLabel:`Save Budget`,dialogClass:`budget-editor`,canClose:()=>!Y.overrideDialogOpen,onclose:()=>Y.closeForm(),onsubmit:()=>Y.submitForm(),children:(e,t)=>{var r=ME(),i=N(r),a=M(i);wE(a,{id:`budget-scope`,label:`Scope`,children:(e,t)=>{var n=EE();H(n,21,CT,e=>e.value,(e,t)=>{var n=TE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncScope()),qi(n,()=>Y.form.scope,e=>Y.form.scope=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);{let e=O(()=>OT(Y.form));wE(o,{id:`budget-subject`,get label(){return I(e)},children:(e,t)=>{var r=DE();ia(r),F(e=>{W(r,`placeholder`,e),aa(r,Y.form.subject),r.disabled=Y.editing,W(r,`data-modal-autofocus`,!Y.editing||void 0)},[()=>kT(Y.form)]),L(`input`,r,n),z(e,r)},$$slots:{default:!0}})}var s=P(o,2);wE(s,{id:`budget-period`,label:`Period`,children:(e,t)=>{var n=OE();H(n,21,jT,e=>e.value,(e,t)=>{var n=TE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncPeriodSeconds()),qi(n,()=>Y.form.period,e=>Y.form.period=e),z(e,n)},$$slots:{default:!0}});var c=P(s,2),l=e=>{wE(e,{id:`budget-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=kE();ia(n),F(()=>n.disabled=Y.editing),pa(n,()=>Y.form.period_seconds,e=>Y.form.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(c,e=>{Y.form.period===`custom`&&e(l)}),wE(P(c,2),{id:`budget-amount`,label:`Amount`,children:(e,t)=>{var n=AE();ia(n),F(()=>W(n,`data-modal-autofocus`,Y.editing||void 0)),pa(n,()=>Y.form.amount,e=>Y.form.amount=e),z(e,n)},$$slots:{default:!0}}),T(i);var u=P(i,2),d=e=>{z(e,jE())};V(u,e=>{Y.editing&&e(d)}),z(e,r)},$$slots:{default:!0}})}Ps(P(i,2),{get open(){return Y.overrideDialogOpen},variant:`auth`,onclose:()=>Y.closeOverrideDialog(),children:(e,t)=>{var n=NE(),r=M(n);As(P(M(r),2),{label:`Close budget override dialog`,onclick:()=>Y.closeOverrideDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=P(c,2),u=M(l);K(u,{get icon(){return vo},class:`form-action-icon`});var d=P(u,2),f=M(d,!0);T(d),T(l),T(s),T(i),T(n),F(e=>{B(o,e),l.disabled=Y.formSubmitting,B(f,Y.formSubmitting?`Saving...`:`Override Budget`)},[()=>YT(Y.overridePendingPayload,Y.overrideExistingBudget)]),Vr(`submit`,i,e=>{e.preventDefault(),Y.confirmOverride()}),L(`click`,c,()=>Y.closeOverrideDialog()),z(e,n)},$$slots:{default:!0}}),z(e,r),D()}Hr([`change`,`input`,`click`]);var IE=R(`

                    Budgets

                    `),LE=R(``),RE=R(`
                    Budget management is unavailable.
                    `),zE=R(``),BE=R(`
                    `),VE=R(`

                    No budgets configured yet.

                    `),HE=R(`

                    No budgets match your filter.

                    `),UE=R(`
                    `);function WE(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`budgets`&&Y.fetchBudgetsPage()});let n=O(()=>Y.filteredBudgets());var r=UE(),i=M(r),a=M(i);JS(M(a),{copyId:`budgets-help-copy`,label:`budgets help`,title:e=>{z(e,IE())},help:e=>{Ue(),z(e,Zr(`Budgets are evaluated from tracked usage cost records for each user + path subtree. Enforcement runs only when Budget is enabled for the + active workflow.`))},$$slots:{title:!0,help:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=LE();K(M(t),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Y.formSubmitting),L(`click`,t,()=>Y.openForm()),z(e,t)},l=O(()=>Y.managementEnabled()&&Y.budgetsAvailable&&!q.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Ic(u,{});var d=P(u,2),f=e=>{z(e,RE())},p=O(()=>(!Y.managementEnabled()||!Y.budgetsAvailable)&&!q.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=zE(),n=M(t,!0);T(t),F(()=>B(n,Y.error)),z(e,t)};V(m,e=>{Y.error&&!q.authError&&e(h)});var g=P(m,2),_=e=>{gT(e,{label:`Loading budgets...`})};V(g,e=>{Y.loading&&!q.authError&&e(_)});var v=P(g,2),y=e=>{var t=BE(),n=M(t);xw(M(n),{id:`budget-filter`,placeholder:`Filter by user path, label, or period...`,label:`Filter budgets by user path or period`,get value(){return Y.filter},set value(e){Y.filter=e}}),T(n);var r=P(n,2),i=P(M(r),2),a=M(i);a.value=a.__value=`subject`;var o=P(a);o.value=o.__value=`period`,T(i),T(r),T(t),qi(i,()=>Y.sortBy,e=>Y.sortBy=e),z(e,t)};V(v,e=>{(Y.budgets.length>0||Y.filter)&&Y.budgetsAvailable&&!q.authError&&!Y.formOpen&&e(y)});var b=P(v,2);FE(b,{});var x=P(b,2),S=e=>{_E(e,{get budgets(){return I(n)}})};V(x,e=>{I(n).length>0&&Y.budgetsAvailable&&!q.authError&&e(S)});var C=P(x,2),w=e=>{z(e,VE())},ee=O(()=>Y.budgets.length===0&&!Y.filter&&!Y.loading&&!q.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,HE())},re=O(()=>Y.budgets.length>0&&I(n).length===0&&Y.filter&&!Y.loading&&!q.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function GE(){return{scope:`user_path`,subject:`/`,period:`minute`,period_seconds:60,max_requests:``,max_tokens:``,source:`manual`}}function KE(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},provider:{label:`Provider`,chip:`provider`,fieldLabel:`Provider Name`,placeholder:`openai`},model:{label:`Model`,chip:`model`,fieldLabel:`Model`,placeholder:`openai/gpt-4o`}};return t[e]||t.user_path}function qE(){return[`user_path`,`provider`,`model`].map(e=>({value:e,label:KE(e).label}))}function JE(e){return String(e&&e.scope||``).trim()||`user_path`}function YE(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function XE(e){return KE(JE(e)).chip}function ZE(e){return KE(String(e&&e.scope||``)).fieldLabel}function QE(e){return KE(String(e&&e.scope||``)).placeholder}function $E(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function eD(){return[{value:`minute`,label:`Per minute`},{value:`hour`,label:`Per hour`},{value:`day`,label:`Per day`},{value:`concurrent`,label:`Concurrent (in-flight)`},{value:`custom`,label:`Custom seconds`}]}function tD(e){switch(String(e||``).trim().toLowerCase()){case`minute`:return 60;case`hour`:return 3600;case`day`:return 86400;case`concurrent`:return 0;default:return-1}}function nD(e){switch(Number(e||0)){case 60:return`minute`;case 3600:return`hour`;case 86400:return`day`;case 0:return`concurrent`;default:return`custom`}}function rD(e){let t=String(e&&e.period||``).trim(),n=tD(t);n>=0&&(e.period_seconds=n),t===`concurrent`&&(e.max_tokens=``)}function iD(e){return JE(e)+`:`+YE(e)+`:`+String(e&&e.period_seconds||`0`)}function aD(e){return Number(e&&e.period_seconds||0)===0}function oD(e){return String(e&&e.period_label||``).trim()||nD(Number(e&&e.period_seconds||0))}function sD(e){return String(e&&e.source||``)===`config`?`config`:`manual`}function cD(e){return String(e&&e.source||``)===`config`}function lD(e){let t=Number(e);return Number.isFinite(t)?t.toLocaleString():`0`}function uD(e,t){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return 0;let i=Math.round(n/r*100);return Math.min(Math.max(i,0),100)}function dD(e,t){let n=String(t||``).trim().toLowerCase(),r=Array.isArray(e)?e.slice():[],i={user_path:0,provider:1,model:2};return r.sort((e,t)=>{let n=(i[JE(e)]||0)-(i[JE(t)]||0);if(n!==0)return n;let r=YE(e).localeCompare(YE(t));return r===0?Number(e.period_seconds||0)-Number(t.period_seconds||0):r}),n?r.filter(e=>{let t=YE(e).toLowerCase(),r=XE(e).toLowerCase(),i=oD(e).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)}):r}function fD(e){return!e||!Array.isArray(e.rate_limits)?[]:e.rate_limits}function pD(e,t,n){let r=String(t||``).trim();return r=e===`provider`||e===`model`?r.toLowerCase():`/`+r.split(`/`).map(e=>e.trim()).filter(Boolean).join(`/`),e+`:`+r+`:`+Number(n||0)}function mD(e,t){return e?pD(t.scope,t.subject,t.limit_key.period_seconds)!==pD(e.scope,e.subject,e.period_seconds):!1}function hD(e){let t=e||{},n=String(t.scope||`user_path`),r=String(t.subject||``).trim();if(n!==`user_path`&&!r)return{error:ZE(t)+` is required.`};let i=String(t.period||``)===`concurrent`,a=t.period_seconds;if(a===``||a==null)return{error:`Period seconds is required.`};let o=Number(a);if(!Number.isInteger(o)||o<0||o===0&&!i)return{error:`Period seconds must be a positive integer (0 only for the concurrent period).`};let s=String(t.max_requests===void 0||t.max_requests===null?``:t.max_requests).trim(),c=String(t.max_tokens===void 0||t.max_tokens===null?``:t.max_tokens).trim();if(!s&&!c)return{error:`Set max requests, max tokens, or both.`};if(i&&c)return{error:`Token limits are not valid for the concurrent period.`};let l={scope:n,subject:r||`/`,limit_key:{period_seconds:o}};if(s){let e=Number(s);if(!Number.isInteger(e)||e<=0)return{error:`Max requests must be a positive integer.`};l.max_requests=e}if(c){let e=Number(c);if(!Number.isInteger(e)||e<=0)return{error:`Max tokens must be a positive integer.`};l.max_tokens=e}return{payload:l}}function gD(e,t,n){if(JE(e)!==`model`)return!1;let r=String(YE(e)).toLowerCase(),i=String(n||``).trim().toLowerCase();if(!i)return!1;if(r===i)return!0;let a=String(t||``).trim().toLowerCase();return a?r===a+`/`+i||i.startsWith(a+`/`)&&r===i.slice(a.length+1):!1}function _D(e,t){return JE(e)===`provider`&&String(YE(e)).toLowerCase()===String(t||``).trim().toLowerCase()}function vD(e){let t=e||{},n=String(t.model||``),r=String(t.provider||``);return!r||n.toLowerCase().startsWith(r+`/`)?n:r+`/`+n}function yD(e,t){let n=e||{},r=Array.isArray(t)?t:[],i=[];return n.kind===`model`&&i.push({key:`model`,title:`Model limits`,scope:`model`,subject:vD(n),hint:``,items:r.filter(e=>gD(e,n.provider,n.model))}),i.push({key:`provider`,title:`Provider limits (`+n.provider+`)`,scope:`provider`,subject:n.provider,hint:n.kind===`model`?`Shared by every model routed to this provider.`:``,items:r.filter(e=>_D(e,n.provider))}),i.push({key:`global`,title:`Global limits`,scope:`user_path`,subject:`/`,hint:`Root user-path rules throttle all traffic. Narrower user-path rules also apply, per consumer.`,items:r.filter(e=>JE(e)===`user_path`&&YE(e)===`/`)}),i}function bD(e){return aD(e)?uD(e.in_flight,e.max_requests):Math.max(uD(e.requests_used,e.max_requests),uD(e.tokens_used,e.max_tokens))}function xD(e){return`--rate-limit-pressure: `+bD(e)+`%`}function SD(e){let t=bD(e);return t>=100?`rate-limit-pressure-row rate-limit-pressure-full`:t>=75?`rate-limit-pressure-row rate-limit-pressure-high`:`rate-limit-pressure-row`}function CD(e){return(Array.isArray(e)?e:[]).some(e=>JE(e)===`user_path`&&YE(e)===`/`)}function wD(e,t,n){let r=Array.isArray(e)?e:[];return r.some(e=>gD(e,t,n))?`table-action-btn-active`:r.some(e=>_D(e,t))||CD(r)?`rate-limit-gauge-inherited`:``}function TD(e,t){let n=Array.isArray(e)?e:[];return n.some(e=>_D(e,t))?`table-action-btn-active`:CD(n)?`rate-limit-gauge-inherited`:``}function ED(e,t){let n=`Rate limits for `+e;return t===`table-action-btn-active`?n+` (direct limits configured)`:t?n+` (inherited limits apply)`:n}function DD(e){if(aD(e))return lD(e.in_flight)+` of `+lD(e.max_requests)+` in flight`;let t=[];return e.max_requests!==null&&e.max_requests!==void 0&&t.push(lD(e.requests_used)+`/`+lD(e.max_requests)+` req`),e.max_tokens!==null&&e.max_tokens!==void 0&&t.push(lD(e.tokens_used)+`/`+lD(e.max_tokens)+` tok`),t.join(` · `)}var X=new class{#e=k(j([]));get rateLimits(){return I(this.#e)}set rateLimits(e){A(this.#e,e,!0)}#t=k(!0);get rateLimitsAvailable(){return I(this.#t)}set rateLimitsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get rateLimitsLoading(){return I(this.#n)}set rateLimitsLoading(e){A(this.#n,e,!0)}rateLimitFetchPromise=null;#r=k(``);get rateLimitFilter(){return I(this.#r)}set rateLimitFilter(e){A(this.#r,e,!0)}#i=k(``);get rateLimitError(){return I(this.#i)}set rateLimitError(e){A(this.#i,e,!0)}#a=k(!1);get rateLimitFormOpen(){return I(this.#a)}set rateLimitFormOpen(e){A(this.#a,e,!0)}#o=k(!1);get rateLimitFormSubmitting(){return I(this.#o)}set rateLimitFormSubmitting(e){A(this.#o,e,!0)}#s=k(``);get rateLimitFormError(){return I(this.#s)}set rateLimitFormError(e){A(this.#s,e,!0)}#c=k(!1);get rateLimitEditing(){return I(this.#c)}set rateLimitEditing(e){A(this.#c,e,!0)}rateLimitEditingOriginal=null;rateLimitFormReturnToInspector=!1;#l=k(``);get rateLimitResettingKey(){return I(this.#l)}set rateLimitResettingKey(e){A(this.#l,e,!0)}#u=k(``);get rateLimitDeletingKey(){return I(this.#u)}set rateLimitDeletingKey(e){A(this.#u,e,!0)}#d=k(!1);get rateLimitInspectorOpen(){return I(this.#d)}set rateLimitInspectorOpen(e){A(this.#d,e,!0)}#f=k(j({kind:``,provider:``,model:``,title:``}));get rateLimitInspector(){return I(this.#f)}set rateLimitInspector(e){A(this.#f,e,!0)}#p=k(j(GE()));get rateLimitForm(){return I(this.#p)}set rateLimitForm(e){A(this.#p,e,!0)}rateLimitsEnabled(){return Cs.rateLimitsVisible()}defaultRateLimitForm(){return GE()}rateLimitScopeMeta(e){return KE(e)}rateLimitScopeOptions(){return qE()}rateLimitScope(e){return JE(e)}rateLimitSubject(e){return YE(e)}rateLimitScopeLabel(e){return XE(e)}rateLimitSubjectFieldLabel(){return ZE(this.rateLimitForm)}rateLimitSubjectPlaceholder(){return QE(this.rateLimitForm)}syncRateLimitScope(){$E(this.rateLimitForm)}rateLimitPeriodOptions(){return eD()}rateLimitPeriodSeconds(e){return tD(e)}rateLimitPeriodFromSeconds(e){return nD(e)}syncRateLimitPeriodSeconds(){rD(this.rateLimitForm)}rateLimitKey(e){return iD(e)}rateLimitIsConcurrent(e){return aD(e)}rateLimitPeriodLabel(e){return oD(e)}rateLimitSourceLabel(e){return sD(e)}rateLimitIsReadOnly(e){return cD(e)}formatRateLimitNumber(e){return lD(e)}rateLimitUsagePercent(e,t){return uD(e,t)}filteredRateLimits(){return dD(this.rateLimits,this.rateLimitFilter)}normalizeRateLimitListPayload(e){return fD(e)}async fetchRateLimitsPage(){if(await Cs.ensureLoaded(),!this.rateLimitsEnabled()){this.rateLimits=[],this.rateLimitsAvailable=!1,this.rateLimitError=``;return}return this.rateLimitFetchPromise||=this.fetchRateLimits().finally(()=>{this.rateLimitFetchPromise=null}),this.rateLimitFetchPromise}async fetchRateLimits(){this.rateLimitsLoading=!0,this.rateLimitError=``;let e=await yT(`/admin/rate-limits`,{label:`rate limits`,errorFallback:`Unable to load rate limits.`,normalize:fD});if(this.rateLimitsLoading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.rateLimitsAvailable=!1,this.rateLimits=[];return}if(!e.result){this.rateLimits=[],this.rateLimitError=e.error;return}if(this.rateLimitsAvailable=!0,e.status===`error`){this.rateLimitError=e.error;return}this.rateLimits=e.items}}openRateLimitForm(e){if(this.rateLimitEditing=!!e,this.rateLimitFormError=``,e){let t=Number(e.period_seconds||0);this.rateLimitEditingOriginal={scope:JE(e),subject:YE(e),period_seconds:t},this.rateLimitForm={scope:JE(e),subject:YE(e),period:nD(t),period_seconds:t,max_requests:e.max_requests===null||e.max_requests===void 0?``:String(e.max_requests),max_tokens:e.max_tokens===null||e.max_tokens===void 0?``:String(e.max_tokens),source:String(e.source||`manual`)}}else this.rateLimitEditingOriginal=null,this.rateLimitForm=GE();this.rateLimitFormOpen=!0}closeRateLimitForm(){this.rateLimitFormOpen=!1,this.rateLimitFormSubmitting=!1,this.rateLimitFormError=``,this.rateLimitEditing=!1,this.rateLimitEditingOriginal=null,this.rateLimitForm=GE(),this.rateLimitFormReturnToInspector&&(this.rateLimitFormReturnToInspector=!1,this.rateLimitInspectorOpen=!0)}rateLimitNormalizedIdentity(e,t,n){return pD(e,t,n)}rateLimitIdentityMoved(e){return mD(this.rateLimitEditingOriginal,e)}setRateLimitFormSubject(e){this.rateLimitForm.subject=String(e||``)}rateLimitFormPayload(){return hD(this.rateLimitForm)}async submitRateLimitForm(){if(this.rateLimitFormSubmitting)return;let{payload:e,error:t}=this.rateLimitFormPayload();if(t){this.rateLimitFormError=t;return}let n=this.rateLimitIdentityMoved(e),r=this.rateLimitEditingOriginal;this.rateLimitFormSubmitting=!0,this.rateLimitFormError=``;try{let t=await bT(`/admin/rate-limits`,`PUT`,e,{label:`save rate limit`,errorFallback:`Unable to save rate limit.`,unavailableStatuses:[]});if(t.status===`stale`)return;if(t.status!==`ok`){this.rateLimitFormError=t.error;return}if(this.rateLimits=fD(t.result.data),n&&!await this.deleteMovedRateLimitOriginal(r))return;this.closeRateLimitForm(),J.success(n?`Rate limit moved; live counters restarted.`:`Rate limit saved.`)}finally{this.rateLimitFormSubmitting=!1}}async deleteMovedRateLimitOriginal(e){let t=await bT(`/admin/rate-limits`,`DELETE`,{scope:e.scope,subject:e.subject,limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`remove the moved rate limit`,errorFallback:`The new rule was saved, but the previous one could not be removed. Delete it manually.`,unavailableStatuses:[]});return t.status===`stale`?!1:t.status===`ok`?(this.rateLimits=fD(t.result.data),!0):(this.rateLimitFormError=t.error,!1)}async deleteRateLimit(e){let t=iD(e);if(this.rateLimitDeletingKey===t)return;this.rateLimitDeletingKey=t;let n=await bT(`/admin/rate-limits`,`DELETE`,{scope:JE(e),subject:YE(e),limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`delete rate limit`,errorFallback:`Unable to delete rate limit.`,unavailableStatuses:[]});if(this.rateLimitDeletingKey=``,n.status!==`stale`){if(n.status!==`ok`){J.error(n.error);return}this.rateLimits=fD(n.result.data),J.success(`Rate limit deleted.`)}}async resetRateLimit(e){let t=iD(e);if(this.rateLimitResettingKey===t)return;this.rateLimitResettingKey=t;let n=await bT(`/admin/rate-limits/reset-one`,`POST`,{scope:JE(e),subject:YE(e),period_seconds:Number(e.period_seconds||0)},{label:`reset rate limit`,errorFallback:`Unable to reset rate limit.`,unavailableStatuses:[]});if(this.rateLimitResettingKey=``,n.status!==`stale`){if(n.status!==`ok`){J.error(n.error);return}this.rateLimits=fD(n.result.data),J.success(`Rate limit counters reset.`)}}rateLimitInspectorModelID(e){return String(e&&e.model&&e.model.id||``).trim()}openRateLimitInspectorForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`model`,provider:n,model:t,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}openRateLimitInspectorForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`provider`,provider:t,model:``,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}showRateLimitInspector(){this.rateLimitInspectorOpen=!0,this.fetchRateLimitsPage()}closeRateLimitInspector(){this.rateLimitInspectorOpen=!1}rateLimitRuleMatchesModel(e,t,n){return gD(e,t,n)}rateLimitRuleMatchesProvider(e,t){return _D(e,t)}rateLimitInspectorQualifiedModel(){return vD(this.rateLimitInspector)}rateLimitInspectorSections(){return yD(this.rateLimitInspector,this.rateLimits)}rateLimitPressurePercent(e){return bD(e)}rateLimitPressureStyle(e){return xD(e)}rateLimitPressureClass(e){return SD(e)}rateLimitGaugeCache={rules:null,states:{}};rateLimitGaugeMemo(e,t){this.rateLimitGaugeCache.rules!==this.rateLimits&&(this.rateLimitGaugeCache={rules:this.rateLimits,states:{}});let n=this.rateLimitGaugeCache.states;return e in n||(n[e]=t()),n[e]}rateLimitGaugeClassForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase(),r=this.rateLimits;return this.rateLimitGaugeMemo(`model:`+n+`/`+t,()=>wD(r,n,t))}rateLimitGaugeClassForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase(),n=this.rateLimits;return this.rateLimitGaugeMemo(`provider:`+t,()=>TD(n,t))}hasGlobalRateLimits(){let e=this.rateLimits;return this.rateLimitGaugeMemo(`global`,()=>CD(e))}rateLimitGaugeTitle(e,t){return ED(e,t)}rateLimitInspectorSummary(e){return DD(e)}openRateLimitFormFromInspector(e,t,n){this.rateLimitInspectorOpen=!1,this.rateLimitFormReturnToInspector=!0,this.openRateLimitForm(n||void 0),n||(this.rateLimitForm.scope=e,this.rateLimitForm.subject=t)}},OD=R(``),kD=R(``),AD=R(``),jD=R(``),MD=R(``),ND=R(``),PD=R(``),FD=R(`

                    Scope, subject, and period identify the rule: changing any of them + moves the rule to a new key and restarts its live counters.

                    `),ID=R(`

                    A user path rule limits the whole subtree; provider and model rules cap + all traffic routed there and make load balancing skip the target while + it is saturated. One shared counter per rule. Leave a field empty to + skip that limit. Token limits require usage tracking.

                    `,1);function LD(e,t){E(t,!0);{let t=O(()=>X.rateLimitEditing?`Edit Rate Limit`:`Create Rate Limit`);SE(e,{get open(){return X.rateLimitFormOpen},get title(){return I(t)},ariaLabel:`Rate limit editor`,get error(){return X.rateLimitFormError},get submitting(){return X.rateLimitFormSubmitting},submitLabel:`Save Rate Limit`,dialogClass:`budget-editor`,novalidate:!0,onclose:()=>X.closeRateLimitForm(),onsubmit:()=>X.submitRateLimitForm(),children:(e,t)=>{var n=ID(),r=N(n),i=M(r);wE(i,{id:`rate-limit-scope`,label:`Scope`,children:(e,t)=>{var n=kD();H(n,21,()=>X.rateLimitScopeOptions(),e=>e.value,(e,t)=>{var n=OD(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitScope()),qi(n,()=>X.rateLimitForm.scope,e=>X.rateLimitForm.scope=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);{let e=O(()=>X.rateLimitSubjectFieldLabel());wE(a,{id:`rate-limit-subject`,get label(){return I(e)},children:(e,t)=>{var n=AD();ia(n),F(e=>{W(n,`placeholder`,e),W(n,`data-modal-autofocus`,!X.rateLimitEditing||void 0),aa(n,X.rateLimitForm.subject)},[()=>X.rateLimitSubjectPlaceholder()]),L(`input`,n,e=>X.setRateLimitFormSubject(e.currentTarget.value)),z(e,n)},$$slots:{default:!0}})}var o=P(a,2);wE(o,{id:`rate-limit-period`,label:`Period`,children:(e,t)=>{var n=jD();H(n,21,()=>X.rateLimitPeriodOptions(),e=>e.value,(e,t)=>{var n=OD(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitPeriodSeconds()),qi(n,()=>X.rateLimitForm.period,e=>X.rateLimitForm.period=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=e=>{wE(e,{id:`rate-limit-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=MD();ia(n),pa(n,()=>X.rateLimitForm.period_seconds,e=>X.rateLimitForm.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(s,e=>{X.rateLimitForm.period===`custom`&&e(c)});var l=P(s,2);{let e=O(()=>X.rateLimitForm.period===`concurrent`?`Max In-Flight Requests`:`Max Requests`);wE(l,{id:`rate-limit-max-requests`,get label(){return I(e)},children:(e,t)=>{var n=ND();ia(n),F(()=>W(n,`data-modal-autofocus`,X.rateLimitEditing?!0:void 0)),pa(n,()=>X.rateLimitForm.max_requests,e=>X.rateLimitForm.max_requests=e),z(e,n)},$$slots:{default:!0}})}var u=P(l,2),d=e=>{wE(e,{id:`rate-limit-max-tokens`,label:`Max Tokens`,children:(e,t)=>{var n=PD();ia(n),pa(n,()=>X.rateLimitForm.max_tokens,e=>X.rateLimitForm.max_tokens=e),z(e,n)},$$slots:{default:!0}})};V(u,e=>{X.rateLimitForm.period!==`concurrent`&&e(d)}),T(r);var f=P(r,4),p=e=>{z(e,FD())};V(f,e=>{X.rateLimitEditing&&e(p)}),z(e,n)},$$slots:{default:!0}})}D()}Hr([`change`,`input`]);var RD=R(` `),zD=R(` Edit`,1),BD=R(` `,1),VD=R(`
                    In-flight
                    `),HD=R(`
                    Requests
                    `),UD=R(`
                    Tokens
                    `),WD=R(`
                    `),GD=R(`
                    `);function KD(e,t){E(t,!0);var n=GD();H(n,21,()=>t.rules,e=>X.rateLimitKey(e),(e,t)=>{var n=WD(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=e=>{var n=RD(),r=M(n);{let e=O(()=>X.rateLimitScope(I(t))===`provider`?xo:Ia);K(r,{get icon(){return I(e)},class:`budget-period-icon`})}var i=P(r,2),a=M(i,!0);T(i),T(n),F((e,t)=>{W(n,`title`,e),B(a,t)},[()=>`Rule scope: `+X.rateLimitScopeLabel(I(t)),()=>X.rateLimitScopeLabel(I(t))]),z(e,n)},u=O(()=>X.rateLimitScope(I(t))!==`user_path`);V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=M(d);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?Na:Ao);K(f,{get icon(){return I(e)},class:`budget-period-icon`})}var p=P(f,2),m=M(p,!0);T(p),T(d),T(s);var h=P(s,2),g=M(h),_=M(g),v=M(_,!0);T(_),T(g);var y=P(g,2),b=M(y),x=e=>{vT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitForm(I(t)),children:(e,t)=>{var n=zD();K(N(n),{get icon(){return fo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},S=O(()=>!X.rateLimitIsReadOnly(I(t)));V(b,e=>{I(S)&&e(x)});var C=P(b,2);{let e=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting counters`:`Reset counters`),n=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t)));vT(C,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>X.resetRateLimit(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=BD(),i=N(r);K(i,{get icon(){return _o},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var w=P(C,2),ee=e=>{{let n=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting rate limit`:`Delete rate limit`),r=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t)));vT(e,{get label(){return I(n)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>X.deleteRateLimit(I(t)),get disabled(){return I(r)},children:(e,n)=>{var r=BD(),i=N(r);K(i,{get icon(){return jo},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}},te=O(()=>!X.rateLimitIsReadOnly(I(t)));V(w,e=>{I(te)&&e(ee)}),T(y),T(h),T(i);var ne=P(i,2),re=M(ne),ie=e=>{var n=VD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u),T(l),T(o),T(n),F((e,t,n,r,i,l)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Wi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l)},[()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests),()=>`In-flight requests: `+X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` in flight`]),z(e,n)},ae=O(()=>X.rateLimitIsConcurrent(I(t)));V(re,e=>{I(ae)&&e(ie)});var oe=P(re,2),se=e=>{var n=HD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Wi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests),()=>`Requests used: `+X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` requests`,()=>X.formatRateLimitNumber(I(t).requests_remaining)+` left`]),z(e,n)},ce=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_requests);V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{var n=UD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Wi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens),()=>`Tokens used: `+X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)>=100}),()=>X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens)+` tokens`,()=>X.formatRateLimitNumber(I(t).tokens_remaining)+` left`]),z(e,n)},de=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_tokens);V(le,e=>{I(de)&&e(ue)}),T(ne),T(r),T(n),F((e,t,n,r,i)=>{W(a,`title`,e),B(o,t),B(m,n),W(_,`title`,r),B(v,i)},[()=>X.rateLimitScopeLabel(I(t))+`: `+X.rateLimitSubject(I(t)),()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n),D()}var qD=R(`

                    Rate Limits

                    `),JD=R(``),YD=R(`
                    Rate limit management is unavailable.
                    `),XD=R(``),ZD=R(`
                    `),QD=R(`

                    No rate limits configured yet.

                    `),$D=R(`

                    No rate limits match your filter.

                    `),eO=R(`
                    `);function tO(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`rate-limits`&&X.fetchRateLimitsPage()});let n=O(()=>X.filteredRateLimits());var r=eO(),i=M(r),a=M(i);JS(M(a),{copyId:`rate-limits-help-copy`,label:`rate limits help`,text:`Rate limits cap requests, tokens, and in-flight concurrency for a user path subtree, a provider, or a model. Consumer (user path) breaches return 429 with Retry-After and x-ratelimit-* headers; saturated providers and models are skipped by load balancing and failover while capacity exists elsewhere. Counters are per gateway instance and reset on restart; token limits need usage tracking.`,title:e=>{z(e,qD())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=JD();K(M(t),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=X.rateLimitFormSubmitting),L(`click`,t,()=>X.openRateLimitForm()),z(e,t)},l=O(()=>X.rateLimitsEnabled()&&X.rateLimitsAvailable&&!q.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Ic(u,{});var d=P(u,2),f=e=>{z(e,YD())},p=O(()=>(!X.rateLimitsEnabled()||!X.rateLimitsAvailable)&&!q.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=XD(),n=M(t,!0);T(t),F(()=>B(n,X.rateLimitError)),z(e,t)};V(m,e=>{X.rateLimitError&&!q.authError&&e(h)});var g=P(m,2),_=e=>{gT(e,{label:`Loading rate limits...`})};V(g,e=>{X.rateLimitsLoading&&!q.authError&&e(_)});var v=P(g,2),y=e=>{var t=ZD(),n=M(t);xw(M(n),{id:`rate-limit-filter`,placeholder:`Filter by subject, scope, or period...`,label:`Filter rate limits by subject, scope, or period`,get value(){return X.rateLimitFilter},set value(e){X.rateLimitFilter=e}}),T(n),T(t),z(e,t)};V(v,e=>{(X.rateLimits.length>0||X.rateLimitFilter)&&X.rateLimitsAvailable&&!q.authError&&!X.rateLimitFormOpen&&e(y)});var b=P(v,2);LD(b,{});var x=P(b,2),S=e=>{KD(e,{get rules(){return I(n)}})};V(x,e=>{I(n).length>0&&X.rateLimitsAvailable&&!q.authError&&e(S)});var C=P(x,2),w=e=>{z(e,QD())},ee=O(()=>X.rateLimits.length===0&&!X.rateLimitFilter&&!X.rateLimitsLoading&&!q.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,$D())},re=O(()=>X.rateLimits.length>0&&I(n).length===0&&X.rateLimitFilter&&!X.rateLimitsLoading&&!q.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function nO(e){return String(e||``).trim().toLowerCase()}function rO(e){if(!e)return``;let t=String(e.selector||``).trim();if(t)return t;if(!e.model||!e.model.id)return``;let n=String(e.model.id||``).trim(),r=String(e.provider_name||``).trim();if(r)return r+`/`+n;let i=String(e.provider_type||``).trim();return!i||n.includes(`/`)?n:i+`/`+n}function iO(e,t,n,r){let i=new Set,a=String(e||``).trim().toLowerCase(),o=String(t||``).trim().toLowerCase(),s=String(n||``).trim().toLowerCase(),c=String(r||``).trim().toLowerCase();if(c&&i.add(c),!a)return i;i.add(a),s&&i.add(s+`/`+a),o&&!a.includes(`/`)&&i.add(o+`/`+a);let l=a.split(`/`);return l.length===2&&l[1]&&i.add(l[1]),i}function aO(e){return iO(e&&e.model?e.model.id:``,e?e.provider_type:``,e?e.provider_name:``,e?e.selector:``)}function oO(e){let t=new Set,n=String(e.resolved_model||``).trim().toLowerCase(),r=String(e.target_model||``).trim().toLowerCase(),i=String(e.target_provider||``).trim().toLowerCase();if(n){t.add(n);let e=n.split(`/`);e.length===2&&e[1]&&t.add(e[1])}if(r){t.add(r);let e=r.split(`/`);e.length===2&&e[1]&&t.add(e[1])}return r&&i&&t.add(i+`/`+r),t}function sO(e){if(!e)return``;let t=String(e.provider||``).trim(),n=String(e.model||``).trim();return!t||!n||n===t||n.startsWith(t+`/`)?n:t+`/`+n}function cO(e){if(e===``||e==null)return null;let t=Number(e);return!Number.isFinite(t)||t<=0?null:t}function lO(e,t){let n={model:e},r=cO(t);return r!==null&&(n.weight=r),n}function uO(e){let t=Array.isArray(e)?e:[],n=[];for(let e of t){let t=String(e&&e.model||``).trim();t&&n.push(lO(t,e&&e.weight))}return n}function dO(e){switch(String(e||``).toLowerCase()){case`cost`:return`lowest cost`;case`round_robin`:case``:return`round robin`;default:return e}}var fO={round_robin:`Round-robin (rotate across targets; honors weights)`,cost:`Lowest cost (cheapest target per request)`,adaptive:`Adaptive (target chosen by the registered routing extension)`};function pO(e,t){let n=Array.isArray(e)?[...e]:[],r=String(t||``).trim().toLowerCase();return r&&!n.includes(r)&&n.push(r),n.map(e=>({value:e,label:fO[e]||e}))}function mO(e){let t=Array.isArray(e.targets)?e.targets:[],n=t.length>0?t[0]:{},r=t.map(e=>{let t={provider:e.provider||``,model:e.model||``};return e.weight&&(t.weight=e.weight),t});return{name:e.source,target_provider:n.provider||``,target_model:n.model||``,targets:r,strategy:e.strategy||``,session_affinity:e.session_affinity!==!1,description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,valid:!!e.valid,resolved_model:e.resolved_model||``,provider_type:e.provider_type||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[]}}function hO(e){let t=Array.isArray(e)?e:[],n=[],r=[];for(let e of t)!e||typeof e!=`object`||(e.kind===`redirect`?n.push(mO(e)):e.kind===`policy`&&r.push({selector:e.source,provider_name:e.provider_name||``,model:e.model||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[],description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,scope_kind:e.scope_kind||``}));return{aliases:n,policies:r}}function gO(e){if(!e)return`—`;let t=Array.isArray(e.targets)?e.targets:[];return t.length>1?t.length+` targets · `+dO(e.strategy):e.resolved_model?e.resolved_model:e.target_provider?e.target_provider+`/`+e.target_model:e.target_model||`—`}function _O(e){return e?e.enabled===!1?`is-disabled`:e.valid?`is-valid`:`is-invalid`:`is-invalid`}function vO(e){return e?e.enabled===!1?`Disabled`:e.valid?`Active`:`Invalid`:`Invalid`}function yO(e){return Array.isArray(e)&&e.length>0&&e.indexOf(`/`)===-1}function bO(e,t){return!t||!e?``:e.effective_enabled===!1?`is-disabled`:yO(e.user_paths)?`is-restricted`:`is-enabled`}function xO(e){if(!e)return``;let t=[];e.effective_enabled===!1&&t.push(e.default_enabled===!1?`Disabled by default`:`Disabled`);let n=Array.isArray(e.user_paths)?e.user_paths:[];return n.length>0&&t.push(`Allowed for `+n.join(`, `)),t.join(` · `)}function SO({models:e,aliases:t,virtualModelsAvailable:n,activeCategory:r}){let i=Array.isArray(e)?e:[],a=Array.isArray(t)?t:[],o=new Map;if(n)for(let e of a){let t=nO(e&&e.name);!t||e.enabled===!1||!e.valid||o.set(t,e)}let s=new Map,c=i.map(e=>{let t=rO(e),n=null;for(let t of aO(e))s.has(t)||s.set(t,e),!n&&o.has(t)&&(n=o.get(t));let r=e&&e.access?e.access:null;return{key:`model:`+t,display_name:t,secondary_name:``,provider_name:e.provider_name||``,provider_type:e.provider_type||``,model:e.model,selector:e.selector||``,is_alias:!1,alias:null,access:r,masking_alias:n,has_virtual_model:!!(n||r&&r.override),alias_state_class:``,alias_state_text:``}});if(!n)return c;for(let e of a){let t=s.get(nO(e&&e.name));if(e&&e.enabled!==!1&&e.valid&&t)continue;let n=null;for(let t of oO(e))if(n=s.get(t)||null,n)break;!n&&r&&r!==`all`||c.push({key:`alias:`+e.name,display_name:e.name,secondary_name:gO(e),provider_name:n&&n.provider_name||``,provider_type:n?n.provider_type||e.provider_type||``:e.provider_type||``,model:n?n.model:{id:e.name,object:`model`},selector:``,is_alias:!0,alias:e,access:null,masking_alias:null,source_model_exists:!!t,has_virtual_model:!0,alias_state_class:_O(e),alias_state_text:vO(e)})}return c.sort((e,t)=>e.is_alias===t.is_alias?String(e.display_name||``).localeCompare(String(t.display_name||``)):e.is_alias?-1:1)}function CO(e,t){if(!t)return e;let n=String(t).toLowerCase();return e.filter(e=>[e.display_name,e.secondary_name,e.provider_name,e.provider_type,e.model&&e.model.owned_by,e.alias&&e.alias.description,e.alias&&e.alias_state_text,e.model&&e.model.metadata&&e.model.metadata.modes?e.model.metadata.modes.join(`,`):``,e.model&&e.model.metadata&&e.model.metadata.categories?e.model.metadata.categories.join(`,`):``].some(e=>String(e||``).toLowerCase().includes(n)))}function wO(e,t){return String(e||``).trim()||String(t||``).trim()||`Unassigned`}function TO(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!r||r===n?``:r}function EO(e){let t=String(e||``).trim();return t?t+`/`:``}function DO(e){let t=Array.isArray(e)?e:[],n=t.filter(e=>e&&!e.is_alias).length,r=t.filter(e=>e&&e.is_alias).length,i=[];return n>0&&i.push(n+(n===1?` model`:` models`)),r>0&&i.push(r+(r===1?` alias`:` aliases`)),i.join(` · `)}function OO(e,t,n){let r=String(t||``).trim(),i=String(n||``).trim();for(let t of Array.isArray(e)?e:[]){let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim();if(!(r&&e!==r)&&!(!r&&i&&n!==i)&&t&&t.access)return t.access.default_enabled!==!1}return!0}function kO(e){for(let t of Array.isArray(e)?e:[])if(t&&t.access)return t.access.default_enabled!==!1;return!0}function AO(e,t){let n=String(t||``).trim();if(!n)return null;for(let t of Array.isArray(e)?e:[])if(String(t&&t.selector||``).trim()===n)return t;return null}function jO(e,t,n,r){let i=EO(t),a=r&&r.get(`/`)||null,o=i&&r&&r.get(i)||null,s=OO(e,t,n),c=o||a,l=c&&Array.isArray(c.user_paths)?Array.from(new Set(c.user_paths)).sort():[];return{selector:i,default_enabled:s,effective_enabled:c?c.enabled!==!1:s,user_paths:l,override:o}}function MO(e,t,n){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let e of Array.isArray(n)?n:[]){let t=String(e&&e.selector||``).trim();t&&r.set(t,e)}let i=[],a=new Map;for(let t of e){if(t&&t.is_alias){i.push(t);continue}let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim(),r=`provider-group:`+(e||n||`unassigned`);a.has(r)||a.set(r,{key:r,provider_name:e,provider_type:n,display_name:wO(e,n),type_label:TO(e,n),rows:[]});let o=a.get(r);!o.provider_name&&e&&(o.provider_name=e),!o.provider_type&&n&&(o.provider_type=n),o.display_name=wO(o.provider_name,o.provider_type),o.type_label=TO(o.provider_name,o.provider_type),o.rows.push(t)}let o=Array.from(a.values()).map(e=>{let n=jO(t,e.provider_name,e.provider_type,r);return{...e,access:n,access_summary:xO(n),item_count_label:DO(e.rows)}}).sort((e,t)=>String(e.display_name||``).localeCompare(String(t.display_name||``)));return i.length>0&&o.unshift({key:`virtual-model-group`,is_virtual_models:!0,provider_name:``,provider_type:``,display_name:`Virtual models`,type_label:``,rows:i,access:{selector:``},access_summary:``,item_count_label:DO(i)}),o}function NO(e,t){let n=AO(t,`/`),r=kO(e),i=n&&Array.isArray(n.user_paths)?n.user_paths:[];return{key:`scope-global`,is_alias:!1,display_name:`all providers and models`,access:{selector:`/`,default_enabled:r,effective_enabled:n?n.enabled!==!1:r,user_paths:i,override:n}}}function PO(e){return e?String(e.access&&e.access.selector||``).trim()||String(e.override_selector||``).trim()||rO(e):``}function FO(e){if(!e)return[];let t=[];return e.is_alias?t.push(`alias-row`,_O(e.alias)):e.has_virtual_model&&t.push(`alias-row`,`is-valid`),!e.is_alias&&e.masking_alias&&t.push(`masked-model-row`),!e.is_alias&&e.access&&e.access.effective_enabled===!1&&t.push(`model-access-disabled-row`),t}function IO(e){return!!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)}function LO(e){return!!(e&&!e.is_alias&&e.masking_alias&&e.masking_alias.name&&!e.masking_alias.managed)}function RO(e){return e&&e.is_alias&&e.alias&&e.alias.name?`alias-row-`+String(e.alias.name).replace(/[^a-zA-Z0-9_-]+/g,`-`):``}function zO(e){return e?e.is_alias?!!(e.alias&&e.alias.managed):!!(e.access&&e.access.override&&e.access.override.managed||e.masking_alias&&e.masking_alias.managed):!1}function BO(e){return!!(e&&e.override)}function VO(e){return e?`table-action-btn-active`:``}function HO(e,t){let n=`Edit `+String(e||`model access`);return t?n+` (virtual model exists)`:n}function UO(){return{source:``,target_model:``,target_weight:1,targets:[],strategy:`round_robin`,session_affinity:!0,user_paths:``,description:``,enabled:!0}}function WO(e){return String(e&&e.target_model||``).trim()!==``}function GO(e){return String(e&&e.target_model||``).trim()?!0:uO(e&&e.targets).length>0}function KO(e){return!!e&&Array.isArray(e.targets)&&e.targets.length>0}function qO(e){return KO(e)&&String(e&&e.strategy||``).toLowerCase()!==`cost`}function JO(e){let t=Array.isArray(e.targets)?e.targets:[];if(t.length>0){let n=t.shift();e.target_model=n.model||``,e.target_weight=n.weight||1;return}e.target_model=``,e.target_weight=1}function YO(e){let t=Array.isArray(e&&e.targets)?e.targets:[];return t.length>0?{primaryModel:sO(t[0]),primaryWeight:t[0].weight||1,extraTargets:t.slice(1).map(e=>({model:sO(e),weight:e.weight||1}))}:{primaryModel:e&&e.target_provider?e.target_provider+`/`+e.target_model:e&&e.target_model||``,primaryWeight:1,extraTargets:[]}}function XO(e){return String(e||``).split(/\r?\n|,/).map(e=>String(e||``).trim()).filter(Boolean)}function ZO(e,t,n){let r=String(e&&e.source||``).trim(),i=String(e&&e.target_model||``).trim(),a=uO(e&&e.targets),o=GO(e),s=String(t||``).trim(),c=n===`edit`&&!!s&&r!==s,l={source:r,user_paths:XO(e&&e.user_paths),description:String(e&&e.description||``).trim(),enabled:!!(e&&e.enabled)};if(c&&(l.old_source=s),o){let t=[];if(i&&t.push(lO(i,e.target_weight)),t.push(...a),t.length>1){let n=e.strategy||`round_robin`;l.targets=n===`cost`?t.map(e=>({model:e.model})):t,l.strategy=n,e&&e.session_affinity===!1&&(l.session_affinity=!1)}else l.target_model=t[0].model}return{payload:l,source:r,isRedirect:o,isRename:c}}function QO(e){let t={source:e.name,description:String(e.description||``).trim(),user_paths:Array.isArray(e.user_paths)?e.user_paths:[],enabled:e.enabled===!1},n=Array.isArray(e.targets)?e.targets:[];return n.length>1?(t.strategy=e.strategy||`round_robin`,e.session_affinity===!1&&(t.session_affinity=!1),t.targets=t.strategy===`cost`?n.map(e=>({model:sO(e)})):n.map(e=>lO(sO(e),e.weight))):n.length===1?t.target_model=sO(n[0]):t.target_model=e.target_provider?e.target_provider+`/`+e.target_model:e.target_model,t}function $O(e,t,n){let r=n||{},i=r.effective_enabled===!1,a=t&&Array.isArray(t.user_paths)?t.user_paths:[],o=`PUT`,s;return i===!1?s={source:e,enabled:!1,user_paths:a}:t&&a.length===0&&r.default_enabled!==!1?(o=`DELETE`,s={source:e}):s={source:e,enabled:!0,user_paths:a},{method:o,payload:s,desired:i}}function ek(e,t,n){let r=Math.max(1,Number(t||75)),i=Math.min(n,e+r);return{limit:i,rendering:iSO({models:Pc.models,aliases:this.aliases,virtualModelsAvailable:this.virtualModelsAvailable,activeCategory:Pc.activeCategory}));get displayModels(){return I(this.#T)}set displayModels(e){A(this.#T,e)}#E=O(()=>MO(this.displayModels,Pc.models,this.modelOverrideViews));get displayModelGroups(){return I(this.#E)}set displayModelGroups(e){A(this.#E,e)}#D=O(()=>CO(this.displayModels,Pc.filter));get filteredDisplayModels(){return I(this.#D)}set filteredDisplayModels(e){A(this.#D,e)}#O=O(()=>{let e=this.filteredDisplayModels,t=Math.max(0,Math.min(Number(this.modelRenderLimit||0),e.length));return!Pc.filter&&t>=this.displayModels.length?this.displayModelGroups:MO(e.slice(0,t),Pc.models,this.modelOverrideViews)});get filteredDisplayModelGroups(){return I(this.#O)}set filteredDisplayModelGroups(e){A(this.#O,e)}#k=O(()=>NO(Pc.models,this.modelOverrideViews));get globalScopeRow(){return I(this.#k)}set globalScopeRow(e){A(this.#k,e)}modelsBusy(){return!!(Pc.loading||this.modelsRendering)}modelLoadingText(){if(Pc.loading)return this.displayModels.length>0?`Refreshing models...`:`Loading models...`;let e=this.filteredDisplayModels.length;return`Rendering models... `+Math.min(Number(this.modelRenderLimit||0),e)+` / `+e}restartModelRendering(e){let t=++this.#a,n=tk(this.modelRenderBatchSize,e);this.modelRenderLimit=n.limit,this.modelsRendering=n.rendering,n.rendering&&this.#A(t)}stopModelRendering(){this.#a++,this.modelsRendering=!1}#A(e){let t=()=>{if(e!==this.#a)return;let t=ek(this.modelRenderLimit,this.modelRenderBatchSize,this.filteredDisplayModels.length);this.modelRenderLimit=t.limit,this.modelsRendering=t.rendering,t.rendering&&this.#A(e)};typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>setTimeout(t,0)):setTimeout(t,0)}async fetchVirtualModels(){this.aliasLoading=!0,this.aliasError=``;try{let e=await vs(`/admin/virtual-models`,{label:`virtual models`});if(e.status===503){this.virtualModelsAvailable=!1,this.aliases=[],this.modelOverrideViews=[];return}if(e.stale)return;if(this.virtualModelsAvailable=!0,!e.ok){this.aliases=[],this.modelOverrideViews=[];return}let{aliases:t,policies:n}=hO(e.data);this.aliases=t,this.modelOverrideViews=n}catch(e){console.error(`Failed to fetch virtual models:`,e),this.aliases=[],this.modelOverrideViews=[],this.aliasError=`Unable to load virtual models.`}finally{this.aliasLoading=!1}}qualifiedModelName(e){return rO(e)}findModelOverrideView(e){return AO(this.modelOverrideViews,e)}hasGlobalModelOverride(){return!!this.findModelOverrideView(`/`)}findExistingAliasByName(e){let t=nO(e);if(!t)return null;for(let e of this.aliases)if(nO(e&&e.name)===t)return e;return null}findConcreteModelByName(e){let t=nO(e);if(!t)return null;for(let e of Pc.models)if(aO(e).has(t))return e;return null}rowToggleEnabled(e){return e?e.is_alias?e.alias&&e.alias.enabled!==!1:!!(e.access&&e.access.effective_enabled!==!1):!1}rowToggleLabel(e){return this.rowTogglingKey&&this.rowTogglingKey===e.key?`Updating...`:this.rowToggleRestricted(e)?`Restricted`:this.rowToggleEnabled(e)?`Enabled`:`Disabled`}rowToggleRestricted(e){return!!e&&!e.is_alias&&bO(e.access,this.virtualModelsAvailable)===`is-restricted`}rowToggleAriaLabel(e){if(!e)return``;let t=this.rowToggleEnabled(e)?`Disable `:`Enable `,n;return n=e.is_alias?`alias `+String(e.alias&&e.alias.name||``):String(e.display_name||e.access&&e.access.selector||`model`),t+n.trim()}async toggleRowEnabled(e){if(this.virtualModelsAvailable&&!(!e||this.rowTogglingKey===e.key)){if(zO(e)){J.success(`This virtual model is managed by configuration and is read-only.`);return}if(e.is_alias){await this.toggleAliasRow(e);return}await this.toggleModelRow(e)}}async toggleAliasRow(e){let t=e.alias;if(!t||!t.name)return;this.rowTogglingKey=e.key;let n=QO(t);try{let e=await ys(`/admin/virtual-models`,`PUT`,n,{label:`alias state`});if(e.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(e.stale)return;if(!e.ok){J.error(e.status===401?`Authentication required.`:ms(e,`Failed to update alias state.`));return}J.success(n.enabled?`Alias enabled.`:`Alias disabled.`),this.fetchVirtualModels()}catch(e){console.error(`Failed to toggle alias state:`,e),J.error(`Failed to update alias state.`)}finally{this.rowTogglingKey=``}}async toggleModelRow(e){let t=PO(e);if(!t)return;let{method:n,payload:r,desired:i}=$O(t,this.findModelOverrideView(t),e.access||{});this.rowTogglingKey=e.key;try{let e=await ys(`/admin/virtual-models`,n,r,{label:`model access`});if(e.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(!(n===`DELETE`&&e.status===404)){if(e.stale)return;if(!e.ok){J.error(e.status===401?`Authentication required.`:ms(e,`Failed to update model access.`));return}}J.success(i?`Model enabled.`:`Model disabled.`),Promise.all([Pc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to toggle model access:`,e),J.error(`Failed to update model access.`)}finally{this.rowTogglingKey=``}}async removeAliasRow(e){if(!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)||this.rowDeletingKey)return;let t=String(e.alias.name||``).trim();t&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the virtual model alias "`+t+`"?`,method:`DELETE`,payload:{source:t},operation:`virtual model`,failureMessage:`Failed to remove virtual model.`,notice:`Virtual model removed.`,ignoreNotFound:!0})}async removeRedirectRow(e){let t=e&&e.masking_alias;if(!(e&&!e.is_alias&&t&&t.name&&!t.managed)||this.rowDeletingKey)return;let n=String(t.name||``).trim();n&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the redirect for "`+n+`"? Other virtual model settings will be preserved.`,method:`PUT`,payload:{source:n,user_paths:Array.isArray(t.user_paths)?t.user_paths:[],description:String(t.description||``).trim(),enabled:t.enabled!==!1},operation:`virtual model redirect`,failureMessage:`Failed to remove redirect.`,notice:`Redirect removed. Other virtual model settings were preserved.`})}async mutateVirtualModelRow(e){if(!this.rowDeletingKey&&window.confirm(e.confirmMessage)){this.rowDeletingKey=e.rowKey;try{let t=await ys(`/admin/virtual-models`,e.method,e.payload,{label:e.operation});if(t.status===503){this.virtualModelsAvailable=!1,J.error(`Virtual models feature is unavailable.`);return}if(!(e.ignoreNotFound&&t.status===404)){if(t.stale)return;if(!t.ok){J.error(t.status===401?`Authentication required.`:ms(t,e.failureMessage));return}}this.virtualModelsAvailable=!0,J.success(e.notice),Promise.all([Pc.fetchModels(),this.fetchVirtualModels()])}catch(t){console.error(e.failureMessage,t),J.error(e.failureMessage)}finally{this.rowDeletingKey=``}}}addVmTarget(){Array.isArray(this.vmForm.targets)||(this.vmForm.targets=[]),this.vmForm.targets.push({model:``,weight:1})}removeVmTarget(e){Array.isArray(this.vmForm.targets)&&this.vmForm.targets.splice(e,1)}removePrimaryTarget(){JO(this.vmForm)}vmFormHasPrimaryTarget(){return WO(this.vmForm)}vmFormShowStrategy(){return KO(this.vmForm)}vmStrategyOptions(){return pO(Cs.virtualModelStrategies(),this.vmForm.strategy)}vmFormShowWeights(){return qO(this.vmForm)}vmFormToggleRestricted(){return!!(this.vmForm&&this.vmForm.enabled)&&yO(XO(this.vmForm.user_paths))}vmFormToggleLabel(){return!this.vmForm||!this.vmForm.enabled?`Disabled`:this.vmFormToggleRestricted()?`Restricted`:`Enabled`}resetVirtualModelForm(){this.vmFormError=``,this.vmFormHelpOpen=!1,this.vmFormUserPathsHelpOpen=!1,this.vmSubmitting=!1,this.vmDeleting=!1,this.vmFormHasExisting=!1,this.vmFormDefaultEnabled=!0,this.vmFormEffectiveEnabled=!0,this.vmFormDisplayName=``,this.vmFormSourceLocked=!1,this.vmFormOriginalSource=``,this.vmFormManaged=!1,this.vmForm=UO()}closeVirtualModelForm(){this.vmFormOpen=!1,this.resetVirtualModelForm()}openVirtualModelCreate(e){this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`create`,this.vmFormSourceLocked=!1,this.vmFormDisplayName=`New virtual model`,e&&e.model&&e.model.id&&(this.vmForm.target_model=rO(e))}openVirtualModelEditAlias(e){if(!e)return;this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!1,this.vmFormHasExisting=!0,this.vmFormManaged=!!e.managed,this.vmFormOriginalSource=e.name||``,this.vmFormDisplayName=e.name||``,this.vmFormDefaultEnabled=kO(Pc.models),this.vmFormEffectiveEnabled=e.enabled!==!1;let{primaryModel:t,primaryWeight:n,extraTargets:r}=YO(e);this.vmForm={source:e.name||``,target_model:t,target_weight:n,targets:r,strategy:e.strategy||`round_robin`,session_affinity:e.session_affinity!==!1,user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` +`),description:e.description||``,enabled:e.enabled!==!1}}openVirtualModelEditModel(e){if(!e||e.is_alias)return;let t=e.access||{},n=t.override||null,r=n&&Array.isArray(n.user_paths)?n.user_paths:Array.isArray(t.user_paths)?t.user_paths:[],i=PO(e);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!n,this.vmFormOriginalSource=i;let a=n?n.enabled!==!1:t.effective_enabled!==!1;this.vmFormDefaultEnabled=t.default_enabled!==!1,this.vmFormEffectiveEnabled=a,this.vmFormManaged=!!(n&&n.managed),this.vmFormDisplayName=e.access_display_name||e.display_name||i||``,this.vmForm={source:i,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:r.join(` +`),description:n&&n.description?n.description:``,enabled:a}}openGlobalModelOverrideEdit(){let e=this.findModelOverrideView(`/`),t=e&&Array.isArray(e.user_paths)?e.user_paths:[],n=kO(Pc.models);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!e,this.vmFormOriginalSource=`/`,this.vmFormDefaultEnabled=n,this.vmFormEffectiveEnabled=e?e.enabled!==!1:n,this.vmFormManaged=!!(e&&e.managed),this.vmFormDisplayName=`All providers and models`,this.vmForm={source:`/`,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:t.join(` +`),description:e&&e.description?e.description:``,enabled:e?e.enabled!==!1:n}}openProviderOverrideEdit(e){!e||!e.access||!e.access.selector||this.openVirtualModelEditModel({display_name:e.display_name,access_display_name:`All models in `+e.display_name,provider_name:e.provider_name,provider_type:e.provider_type,access:e.access,override_selector:e.access.selector,is_alias:!1})}async submitVirtualModelForm(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be edited here.`;return}let{payload:e,source:t,isRedirect:n,isRename:r}=ZO(this.vmForm,this.vmFormOriginalSource,this.vmFormMode);if(!t){this.vmFormError=`Source is required.`;return}if(this.vmFormError=``,this.vmFormMode!==`edit`){let e=this.findExistingAliasByName(t),r=e?null:this.findModelOverrideView(t);if(e||r){let n=e?`A virtual model named "`+e.name+`" already exists. Saving will update that virtual model. Continue?`:`An access policy for "`+t+`" already exists. Saving will update that virtual model. Continue?`;if(!window.confirm(n)){this.vmFormError=`Choose a different source or edit the existing virtual model.`;return}}else if(n){let e=this.findConcreteModelByName(t);if(e){let t=rO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Creating this alias will mask that model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}else if(r){let e=(this.aliases||[]).find(e=>e&&e.name===t)||null,r=e?null:this.findModelOverrideView(t);if(e||r){this.vmFormError=`A virtual model for "`+t+`" already exists. Choose a different source.`;return}if(n){let e=this.findConcreteModelByName(t);if(e){let t=rO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Renaming to that name will mask the model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}this.vmSubmitting=!0;try{let t=await ys(`/admin/virtual-models`,`PUT`,e,{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:ms(t,`Failed to save virtual model.`);return}let r=!n&&t.status===204;this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),J.success(n?`Alias saved.`:r?`Model access reset to inherited/default.`:`Model access saved.`),Promise.all([Pc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to save virtual model:`,e),this.vmFormError=`Failed to save virtual model.`}finally{this.vmSubmitting=!1}}async deleteVirtualModel(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be removed here.`;return}let e=String(this.vmForm.source||this.vmFormOriginalSource||``).trim();if(!(!e||!this.vmFormHasExisting)&&window.confirm(`Remove the virtual model for "`+e+`"? This reverts to inherited/default behavior.`)){this.vmDeleting=!0,this.vmFormError=``;try{let t=await ys(`/admin/virtual-models`,`DELETE`,{source:e},{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:ms(t,`Failed to remove virtual model.`);return}}this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),J.success(`Virtual model removed.`),Promise.all([Pc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to delete virtual model:`,e),this.vmFormError=`Failed to remove virtual model.`}finally{this.vmDeleting=!1}}}},rk=[{value:`input_per_mtok`,label:`Input $/MTok`,group:`Tokens`},{value:`output_per_mtok`,label:`Output $/MTok`,group:`Tokens`},{value:`cached_input_per_mtok`,label:`Cached input $/MTok`,group:`Tokens`},{value:`cache_write_per_mtok`,label:`Cache write $/MTok`,group:`Tokens`},{value:`reasoning_output_per_mtok`,label:`Reasoning output $/MTok`,group:`Tokens`},{value:`batch_input_per_mtok`,label:`Batch input $/MTok`,group:`Batch`},{value:`batch_output_per_mtok`,label:`Batch output $/MTok`,group:`Batch`},{value:`audio_input_per_mtok`,label:`Audio input $/MTok`,group:`Audio`},{value:`audio_output_per_mtok`,label:`Audio output $/MTok`,group:`Audio`},{value:`per_image`,label:`$/Image`,group:`Image`},{value:`input_per_image`,label:`Input $/Image`,group:`Image`},{value:`per_second_input`,label:`Input $/Second`,group:`Audio/Video`},{value:`per_second_output`,label:`Output $/Second`,group:`Video`},{value:`per_character_input`,label:`$/Character`,group:`Audio`},{value:`per_page`,label:`$/Page`,group:`Utility`},{value:`per_request`,label:`$/Request`,group:`Utility`}];function ik(e){let t=rk.find(t=>t.value===e);return t?t.label:String(e||``).replace(/_/g,` `)}function ak(e){return e&&typeof e==`object`?JSON.parse(JSON.stringify(e)):{}}function ok(e,t){let n=ak(e),r=t&&t.pricing?t.pricing:t;if(!r||typeof r!=`object`)return n;for(let e of rk)r[e.value]!==null&&r[e.value]!==void 0&&(n[e.value]=Number(r[e.value]));return Array.isArray(r.tiers)&&r.tiers.length>0&&(n.tiers=ak(r.tiers)),n}function sk(e){switch(String(e||``).trim()){case`config_yaml`:return`config.yaml`;case`model_registry`:return`Model registry`;default:return e?String(e):`Unknown`}}function ck(e){let t=e&&e.pricing?e.pricing:{},n=e&&e.pricing_sources&&typeof e.pricing_sources==`object`?e.pricing_sources:{},r={};for(let e of rk)t[e.value]!==null&&t[e.value]!==void 0&&(r[e.value]=sk(n[e.value]||`model_registry`));return r}function lk(e){let t=String(e&&e.selector||``).trim();return t?`Dashboard/API override (`+t+`)`:`Dashboard/API override`}function uk(e){let t=String(e||``).trim();return t?t+`/`:``}function dk(e){return String(e&&e.model&&e.model.id||``).trim()}function fk(e){let t=String(e&&e.provider_name||``).trim(),n=dk(e);return t&&n?t+`/`+n:n}function pk(e){return dk(e)}function mk(e){let t=new Map;for(let n of Array.isArray(e)?e:[]){let e=String(n&&n.selector||``).trim();e&&t.set(e,n)}return t}function hk(e,t){let n=String(t||``).trim();return n&&mk(e).get(n)||null}function gk(e,t,n){let r=mk(e),i=fk(t),a=pk(t),o=uk(t&&t.provider_name),s=String(n||``).trim();for(let e of[i,a,o,`/`]){if(!e||e===s)continue;let t=r.get(e);if(t)return t}return null}function _k(e,t,n){let r=e&&e.model&&e.model.metadata?e.model.metadata:null,i=ak(r&&r.pricing),a=ck(r),o=gk(t,e,n),s=o&&o.pricing?o.pricing:null;if(s){let e=lk(o);for(let t of rk)s[t.value]!==null&&s[t.value]!==void 0&&(i[t.value]=Number(s[t.value]),a[t.value]=e);Array.isArray(s.tiers)&&s.tiers.length>0&&(i.tiers=ak(s.tiers),a.tiers=e)}return{pricing:i,sources:a}}function vk(e,t){let n=e&&e.pricing?e.pricing:{},r=[];for(let e of rk)n[e.value]!==null&&n[e.value]!==void 0&&r.push({id:t(),field:e.value,value:String(n[e.value])});return r}function yk(e,t){let n=new Set;for(let r of Array.isArray(e)?e:[]){if(t&&r.id===t)continue;let e=String(r.field||``).trim();e&&n.add(e)}return n}function bk(e,t){let n=yk(e,t&&t.id);return rk.filter(e=>e.value===(t&&t.field)||!n.has(e.value))}function xk(e,t){let n={},r=new Set;for(let t of Array.isArray(e)?e:[]){let e=String(t.field||``).trim();if(!e)return{error:`Choose a price type for every row.`};if(r.has(e))return{error:`Each price type can only be used once.`};r.add(e);let i=String(t.value||``).trim();if(i===``)return{error:`Enter a value for `+ik(e)+`.`};let a=Number(i);if(!Number.isFinite(a)||a<0)return{error:`Pricing values must be numbers greater than or equal to 0.`};n[e]=a}let i=Array.isArray(t)?t:[];return i.length>0&&(n.tiers=ak(i)),Object.keys(n).length===0?{error:`Add at least one pricing field before saving.`}:{pricing:n}}function Sk(e,t,n){let r=e||{},i=t||{},a=n||{},o=ok(r,a);return rk.map(e=>{let t=a[e.value]!==null&&a[e.value]!==void 0,n=r[e.value]!==null&&r[e.value]!==void 0;return{field:e.value,label:e.label,value:o[e.value],source:t?`Form/API value`:n?i[e.value]||`Model registry`:`Unset`}}).filter(e=>e.source!==`Unset`||e.value!==void 0)}var Ck=new class{#e=k(!0);get modelPricingOverridesAvailable(){return I(this.#e)}set modelPricingOverridesAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get modelPricingOverrideViews(){return I(this.#t)}set modelPricingOverrideViews(e){A(this.#t,e,!0)}#n=k(``);get modelPricingOverrideError(){return I(this.#n)}set modelPricingOverrideError(e){A(this.#n,e,!0)}#r=k(!1);get modelPricingOverrideFormOpen(){return I(this.#r)}set modelPricingOverrideFormOpen(e){A(this.#r,e,!0)}#i=k(!1);get modelPricingOverrideSubmitting(){return I(this.#i)}set modelPricingOverrideSubmitting(e){A(this.#i,e,!0)}#a=k(!1);get modelPricingOverrideFormHasExistingOverride(){return I(this.#a)}set modelPricingOverrideFormHasExistingOverride(e){A(this.#a,e,!0)}#o=k(``);get modelPricingOverrideFormDisplayName(){return I(this.#o)}set modelPricingOverrideFormDisplayName(e){A(this.#o,e,!0)}#s=k(``);get modelPricingOverrideFormScope(){return I(this.#s)}set modelPricingOverrideFormScope(e){A(this.#s,e,!0)}#c=k(j([]));get modelPricingOverrideFormScopeOptions(){return I(this.#c)}set modelPricingOverrideFormScopeOptions(e){A(this.#c,e,!0)}#l=k(null);get modelPricingOverrideFormRow(){return I(this.#l)}set modelPricingOverrideFormRow(e){A(this.#l,e,!0)}#u=k(null);get modelPricingOverrideFormBasePricing(){return I(this.#u)}set modelPricingOverrideFormBasePricing(e){A(this.#u,e,!0)}#d=k(null);get modelPricingOverrideFormBasePricingSources(){return I(this.#d)}set modelPricingOverrideFormBasePricingSources(e){A(this.#d,e,!0)}#f=k(j([]));get modelPricingOverrideFormPreservedTiers(){return I(this.#f)}set modelPricingOverrideFormPreservedTiers(e){A(this.#f,e,!0)}#p=k(j([]));get modelPricingOverrideRows(){return I(this.#p)}set modelPricingOverrideRows(e){A(this.#p,e,!0)}#m=k(j({selector:``}));get modelPricingOverrideForm(){return I(this.#m)}set modelPricingOverrideForm(e){A(this.#m,e,!0)}_modelPricingOverrideRowID=0;pricingFieldOptions(){return rk}pricingFieldLabel(e){return ik(e)}async fetchModelPricingOverrides(){this.modelPricingOverrideError=``;try{let e=await vs(`/admin/model-pricing-overrides`,{label:`model pricing overrides`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideViews=[];return}if(e.stale)return;if(this.modelPricingOverridesAvailable=!0,!e.ok){this.modelPricingOverrideViews=[];return}this.modelPricingOverrideViews=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch model pricing overrides:`,e),this.modelPricingOverrideViews=[],this.modelPricingOverrideError=`Unable to load model pricing overrides.`}}findModelPricingOverrideView(e){return hk(this.modelPricingOverrideViews,e)}hasGlobalPricingOverride(){return!!this.findModelPricingOverrideView(`/`)}hasProviderPricingOverride(e){return!!this.findModelPricingOverrideView(uk(e&&e.provider_name))}hasModelPricingOverride(e){return!!this.findModelPricingOverrideView(fk(e))}modelPricingButtonClass(e){return e?`table-action-btn-active`:``}modelPricingButtonLabel(e,t){let n=`Edit `+String(e||`model pricing`);return t?n+` (override exists)`:n}modelRowPricing(e){return _k(e,this.modelPricingOverrideViews).pricing}openGlobalPricingOverrideEdit(){this.openModelPricingOverrideForm({displayName:`All providers and models`,selector:`/`,scope:`global`,scopeOptions:[{value:`global`,label:`All providers and models`,selector:`/`}],row:null})}openProviderPricingOverrideEdit(e){let t=uk(e&&e.provider_name);t&&this.openModelPricingOverrideForm({displayName:`All models in `+(e.display_name||e.provider_name||t),selector:t,scope:`provider`,scopeOptions:[{value:`provider`,label:`Provider`,selector:t}],row:null})}openModelPricingOverrideEdit(e){if(!e||e.is_alias)return;let t=fk(e),n=pk(e),r=[{value:`exact`,label:`This provider and model`,selector:t}];n&&n!==t&&r.push({value:`model`,label:`This model across providers`,selector:n}),this.openModelPricingOverrideForm({displayName:e.display_name||t,selector:t,scope:`exact`,scopeOptions:r,row:e})}openModelPricingOverrideForm(e){let t=e||{};this.modelPricingOverrideFormOpen=!0,this.modelPricingOverrideError=``,this.modelPricingOverrideFormDisplayName=t.displayName||t.selector||`Pricing`,this.modelPricingOverrideFormScope=t.scope||``,this.modelPricingOverrideFormScopeOptions=Array.isArray(t.scopeOptions)?t.scopeOptions:[],this.modelPricingOverrideFormRow=t.row||null,this.modelPricingOverrideForm={selector:t.selector||``},this.loadModelPricingOverrideFormSelector(t.selector||``)}loadModelPricingOverrideFormSelector(e){e=String(e||``).trim();let t=this.findModelPricingOverrideView(e);this.modelPricingOverrideFormHasExistingOverride=!!t,this.modelPricingOverrideRows=vk(t,()=>this.nextModelPricingOverrideRowID()),this.modelPricingOverrideFormPreservedTiers=t&&t.pricing&&Array.isArray(t.pricing.tiers)?ak(t.pricing.tiers):[],this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow();let n=this.modelPricingOverrideFormRow,r=n?_k(n,this.modelPricingOverrideViews,e):{pricing:{},sources:{}};this.modelPricingOverrideFormBasePricing=r.pricing,this.modelPricingOverrideFormBasePricingSources=r.sources}setModelPricingOverrideScope(e){this.modelPricingOverrideFormScope=e;let t=this.modelPricingOverrideFormScopeOptions.find(t=>t.value===e);t&&(this.modelPricingOverrideForm.selector=t.selector,this.loadModelPricingOverrideFormSelector(t.selector))}nextModelPricingOverrideRowID(){return this._modelPricingOverrideRowID=(this._modelPricingOverrideRowID||0)+1,`pricing-row-`+this._modelPricingOverrideRowID}availablePricingFieldOptions(e){return bk(this.modelPricingOverrideRows,e)}addModelPricingOverrideRow(){let e=yk(this.modelPricingOverrideRows),t=rk.find(t=>!e.has(t.value))||rk[0];t&&this.modelPricingOverrideRows.push({id:this.nextModelPricingOverrideRowID(),field:t.value,value:``})}removeModelPricingOverrideRow(e){this.modelPricingOverrideRows=this.modelPricingOverrideRows.filter(t=>t.id!==e.id),this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow()}modelPricingOverridePayload(){return xk(this.modelPricingOverrideRows,this.modelPricingOverrideFormPreservedTiers)}modelPricingOverrideDraftPricing(){let e=this.modelPricingOverridePayload();return e&&e.pricing?e.pricing:{}}modelPricingEffectivePreviewRows(){return Sk(this.modelPricingOverrideFormBasePricing,this.modelPricingOverrideFormBasePricingSources,this.modelPricingOverrideDraftPricing())}closeModelPricingOverrideForm(){this.modelPricingOverrideFormOpen=!1,this.modelPricingOverrideSubmitting=!1,this.modelPricingOverrideError=``,this.modelPricingOverrideFormHasExistingOverride=!1,this.modelPricingOverrideFormDisplayName=``,this.modelPricingOverrideFormScope=``,this.modelPricingOverrideFormScopeOptions=[],this.modelPricingOverrideFormRow=null,this.modelPricingOverrideFormBasePricing=null,this.modelPricingOverrideFormBasePricingSources=null,this.modelPricingOverrideFormPreservedTiers=[],this.modelPricingOverrideRows=[],this.modelPricingOverrideForm={selector:``}}async submitModelPricingOverrideForm(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!e){this.modelPricingOverrideError=`Model pricing selector is required.`;return}let t=this.modelPricingOverridePayload();if(t.error){this.modelPricingOverrideError=t.error;return}let n={selector:e,...t};this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let e=await ys(`/admin/model-pricing-overrides`,`PUT`,n,{label:`model pricing override`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(e.stale)return;if(!e.ok){this.modelPricingOverrideError=e.status===401?`Authentication required.`:ms(e,`Failed to save model pricing.`);return}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),J.success(`Model pricing saved.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to save model pricing override:`,e),this.modelPricingOverrideError=`Failed to save model pricing.`}finally{this.modelPricingOverrideSubmitting=!1}}async deleteModelPricingOverride(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!(!e||!this.modelPricingOverrideFormHasExistingOverride)&&window.confirm(`Remove the model pricing override for "`+e+`"?`)){this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let t=await ys(`/admin/model-pricing-overrides`,`DELETE`,{selector:e},{label:`model pricing override`});if(t.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.modelPricingOverrideError=t.status===401?`Authentication required.`:ms(t,`Failed to remove model pricing override.`);return}}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),J.success(`Model pricing override removed.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to delete model pricing override:`,e),this.modelPricingOverrideError=`Failed to remove model pricing override.`}finally{this.modelPricingOverrideSubmitting=!1}}}},wk=R(``);function Tk(e,t){E(t,!0);var n=wk();let r;var i=P(M(n),2),a=M(i,!0);T(i),T(n),F((e,i,o)=>{r=U(n,1,`alias-toggle`,null,r,e),n.disabled=nk.rowTogglingKey===t.row.key||!nk.virtualModelsAvailable,W(n,`aria-label`,i),B(a,o)},[()=>({enabled:nk.rowToggleEnabled(t.row),restricted:nk.rowToggleRestricted(t.row)}),()=>nk.rowToggleAriaLabel(t.row),()=>nk.rowToggleLabel(t.row)]),L(`click`,n,()=>nk.toggleRowEnabled(t.row)),z(e,n),D()}Hr([`click`]);var Ek=R(`
                    `);function Dk(e,t){E(t,!0);var n=Ek(),r=M(n),i=e=>{Tk(e,{get row(){return nk.globalScopeRow}})};V(r,e=>{nk.virtualModelsAvailable&&e(i)});var a=P(r,2),o=e=>{{let t=O(()=>Ck.modelPricingButtonLabel(`global model pricing`,Ck.hasGlobalPricingOverride())),n=O(()=>Ck.modelPricingButtonClass(Ck.hasGlobalPricingOverride()));vT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>Ck.openGlobalPricingOverrideEdit(),children:(e,t)=>{K(e,{get icon(){return Ja},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(a,e=>{Ck.modelPricingOverridesAvailable&&e(o)});var s=P(a,2),c=e=>{{let t=O(()=>HO(`global model access`,nk.hasGlobalModelOverride())),n=O(()=>VO(nk.hasGlobalModelOverride()));vT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>nk.openGlobalModelOverrideEdit(),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{nk.virtualModelsAvailable&&e(c)}),T(n),z(e,n),D()}function Ok(e){return String(e&&(e.primary_model||e.source)||``).trim()}function kk(e){return Array.isArray(e&&e.fallback_models)?e.fallback_models:Array.isArray(e&&e.targets)?e.targets:[]}function Ak(e){return Array.isArray(e)?e.map(e=>({...e,source:Ok(e),targets:kk(e)})):[]}function jk(e){let t=kk(e);return t.length===0?`-`:t.join(`, `)}function Mk(e){return e&&e.enabled===!1?`Off`:e&&e.managed?`Config`:`On`}function Nk(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>Ok(e)===n)||null}function Pk(e,t){if(!t||t.is_alias)return!1;let n=Nk(e,rO(t));return!!(n&&n.enabled!==!1&&kk(n).length>0)}function Fk(e,t){return Pk(e,t)?`table-action-btn-failover-active`:``}function Ik(e,t){let n=`Edit failover for `+(t&&t.display_name?t.display_name:`model`);return Pk(e,t)?n+` (active)`:n}function Lk(e){let t=[e&&e.target_model];return(Array.isArray(e&&e.targets)?e.targets:[]).forEach(e=>t.push(e&&e.model)),t.map(e=>String(e||``).trim()).filter(Boolean)}function Rk(e){let t=Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(Boolean):[];return{target_model:t[0]||``,targets:t.slice(1).map(e=>({model:e}))}}function zk(e){return{primary_model:String(e&&e.source||``).trim(),fallback_models:Lk(e),enabled:!(e&&e.enabled===!1)}}function Bk(e){return Ok(e)}function Vk(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=Bk(e);n&&(t[n]=!0)}),t}function Hk(e,t){let n=Bk(t);return!!(n&&e&&e[n])}function Uk(e,t){return(Array.isArray(e)?e:[]).filter(e=>Hk(t,e))}function Wk(e,t){let n=Array.isArray(e)?e:[];return n.length>0&&Uk(n,t).length===n.length}function Gk(e){return[Ok(e),kk(e).join(` `)].join(` `).toLowerCase()}function Kk(e,t){let n=Array.isArray(e)?e:[],r=String(t||``).trim().toLowerCase();return r?n.filter(e=>Gk(e).includes(r)):n}function qk(e){return{primary_model:Ok(e),fallback_models:kk(e).map(e=>String(e||``).trim()).filter(Boolean),enabled:!!(e&&e.enabled!==!1)}}function Jk(){return{source:``,target_model:``,targets:[],enabled:!0}}var Z=new class{#e=k(!0);get failoverAvailable(){return I(this.#e)}set failoverAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get failoverRules(){return I(this.#t)}set failoverRules(e){A(this.#t,e,!0)}#n=k(!1);get failoverLoading(){return I(this.#n)}set failoverLoading(e){A(this.#n,e,!0)}#r=k(!1);get failoverSaving(){return I(this.#r)}set failoverSaving(e){A(this.#r,e,!0)}#i=k(!1);get failoverGenerating(){return I(this.#i)}set failoverGenerating(e){A(this.#i,e,!0)}#a=k(``);get failoverError(){return I(this.#a)}set failoverError(e){A(this.#a,e,!0)}#o=k(j([]));get failoverGeneratedRules(){return I(this.#o)}set failoverGeneratedRules(e){A(this.#o,e,!0)}#s=k(!1);get failoverDraftsOpen(){return I(this.#s)}set failoverDraftsOpen(e){A(this.#s,e,!0)}#c=k(j({}));get failoverDraftSelections(){return I(this.#c)}set failoverDraftSelections(e){A(this.#c,e,!0)}#l=k(``);get failoverDraftFilter(){return I(this.#l)}set failoverDraftFilter(e){A(this.#l,e,!0)}#u=k(!1);get failoverDraftSaving(){return I(this.#u)}set failoverDraftSaving(e){A(this.#u,e,!0)}#d=k(!1);get failoverFormOpen(){return I(this.#d)}set failoverFormOpen(e){A(this.#d,e,!0)}#f=k(`create`);get failoverFormMode(){return I(this.#f)}set failoverFormMode(e){A(this.#f,e,!0)}#p=k(!1);get failoverFormManaged(){return I(this.#p)}set failoverFormManaged(e){A(this.#p,e,!0)}#m=k(j(Jk()));get failoverForm(){return I(this.#m)}set failoverForm(e){A(this.#m,e,!0)}failoverEnabled(){return Cs.booleanFlag(`FAILOVER_ENABLED`,!0)}async fetchFailoverRules(){if(!this.failoverEnabled()){this.failoverAvailable=!1,this.failoverRules=[],this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,this.failoverError=``,this.failoverLoading=!1;return}this.failoverLoading=!0,this.failoverError=``;try{let e=await vs(`/admin/failover`,{label:`failover mappings`});if(e.status===503){this.failoverAvailable=!1,this.failoverRules=[];return}if(e.stale)return;if(this.failoverAvailable=!0,!e.ok){this.failoverRules=[];return}this.failoverRules=Ak(e.data)}catch(e){console.error(`Failed to fetch failover mappings:`,e),this.failoverRules=[],this.failoverError=`Unable to load failover mappings.`}finally{this.failoverLoading=!1}}resetFailoverForm(){this.failoverFormMode=`create`,this.failoverFormManaged=!1,this.failoverForm=Jk()}openFailoverCreate(){this.resetFailoverForm(),this.failoverFormOpen=!0,this.focusFailoverEditor()}openFailoverEdit(e){if(!e)return;this.resetFailoverForm(),this.failoverFormMode=`edit`,this.failoverFormOpen=!0,this.failoverFormManaged=!!e.managed;let t=this.failoverPrimaryModel(e),n=this.failoverTargets(e);this.failoverForm={source:t,target_model:n[0]||``,targets:n.slice(1).map(e=>({model:e})),enabled:e.enabled!==!1},this.focusFailoverEditor()}openFailoverForModel(e){if(!e||e.is_alias)return;let t=this.qualifiedModelName(e),n=this.failoverRules.find(e=>this.failoverPrimaryModel(e)===t);if(n){this.openFailoverEdit(n);return}this.resetFailoverForm(),this.failoverFormMode=`create`,this.failoverFormOpen=!0,this.failoverForm.source=t,this.focusFailoverEditor()}closeFailoverForm(){this.failoverFormOpen=!1}closeFailoverDraftsModal(){this.failoverDraftSaving||(this.failoverDraftsOpen=!1)}failoverFormTargets(){return Lk(this.failoverForm)}setFailoverFormTargets(e){let t=Rk(e);this.failoverForm.target_model=t.target_model,this.failoverForm.targets=t.targets}addFailoverTarget(){Array.isArray(this.failoverForm.targets)||(this.failoverForm.targets=[]),this.failoverForm.targets.push({model:``}),this.focusFailoverEditor()}removeFailoverTarget(e){if(!Array.isArray(this.failoverForm.targets)){this.failoverForm.targets=[];return}this.failoverForm.targets.splice(e,1)}removePrimaryFailoverTarget(){let e=Array.isArray(this.failoverForm.targets)?this.failoverForm.targets:[];if(e.length>0){let t=e.shift();this.failoverForm.target_model=t&&t.model?t.model:``,this.failoverForm.targets=e;return}this.failoverForm.target_model=``}failoverRulePayload(){return zk(this.failoverForm)}async submitFailoverForm(){if(this.failoverSaving||this.failoverGenerating||this.failoverFormManaged)return;let e=this.failoverRulePayload();if(!e.primary_model){this.failoverError=`Primary model is required.`;return}if(e.enabled&&e.fallback_models.length===0){this.failoverError=`Add at least one failover target.`;return}this.failoverSaving=!0,this.failoverError=``;try{let t=await ys(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to save failover mapping.`;return}J.success(`Failover mapping saved.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to save failover mapping:`,e),this.failoverError=`Failed to save failover mapping.`}finally{this.failoverSaving=!1}}async deleteFailoverRule(e){let t=String(e&&this.failoverPrimaryModel(e)||this.failoverForm.source||``).trim();if(!(!t||this.failoverSaving||this.failoverGenerating)&&confirm(`Remove failover mapping for "`+t+`"?`)){this.failoverSaving=!0,this.failoverError=``;try{let e=await ys(`/admin/failover`,`DELETE`,{primary_model:t},{label:`failover mapping`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mapping.`;return}J.success(`Failover mapping removed.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to remove failover mapping:`,e),this.failoverError=`Failed to remove failover mapping.`}finally{this.failoverSaving=!1}}}async generateFailoverForForm(){if(this.failoverGenerating||this.failoverSaving||this.failoverFormManaged)return;let e=String(this.failoverForm.source||``).trim();if(!e){this.failoverError=`Primary model is required.`;return}this.failoverGenerating=!0,this.failoverError=``;try{let t=await ys(`/admin/failover/generate`,`POST`,{primary_model:e},{label:`failover generation`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to generate failover mapping.`;return}let n=Ak(t.data),r=n.find(t=>this.failoverPrimaryModel(t)===e)||n[0]||null,i=this.failoverTargets(r);if(i.length===0){this.failoverError=`No failover suggestions were generated for this model.`;return}this.setFailoverFormTargets(i),J.success(`Generated `+i.length+` fallback model`+(i.length===1?`.`:`s.`)),this.focusFailoverEditor()}catch(e){console.error(`Failed to generate failover mapping:`,e),this.failoverError=`Failed to generate failover mapping.`}finally{this.failoverGenerating=!1}}openFailoverResetDialog(){zs.open({title:`Remove failover models`,titleId:`failoverResetDialogTitle`,inputId:`failover-reset-confirmation`,message:`Remove every dashboard-managed failover mapping. Configuration-managed mappings remain active.`,requiredText:`remove`,confirmLabel:`Remove Failover`,icon:jo,dialogClass:`budget-reset-dialog`,onConfirm:async()=>{await this.resetFailoverRules(),this.failoverError&&(zs.error=this.failoverError)}})}async resetFailoverRules(){if(!this.failoverSaving){this.failoverSaving=!0,this.failoverError=``;try{let e=await ys(`/admin/failover/reset`,`POST`,void 0,{label:`failover removal`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mappings.`;return}this.failoverRules=Ak(e.data),this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,J.success(`Dashboard-managed failover mappings removed.`),zs.close()}catch(e){console.error(`Failed to remove failover mappings:`,e),this.failoverError=`Failed to remove failover mappings.`}finally{this.failoverSaving=!1}}}async generateFailoverRules(){if(!(this.failoverGenerating||this.failoverDraftSaving)){this.failoverGenerating=!0,this.failoverError=``,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!0;try{let e=await ys(`/admin/failover/generate`,`POST`,void 0,{label:`failover generation`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to generate failover mappings.`;return}this.failoverGeneratedRules=Ak(e.data),this.selectAllFailoverDrafts(this.failoverGeneratedRules)}catch(e){console.error(`Failed to generate failover mappings:`,e),this.failoverError=`Failed to generate failover mappings.`}finally{this.failoverGenerating=!1}}}failoverDraftKey(e){return Bk(e)}selectAllFailoverDrafts(e){this.failoverDraftSelections=Vk(e)}failoverDraftSelected(e){return Hk(this.failoverDraftSelections,e)}setFailoverDraftSelected(e,t){let n=this.failoverDraftKey(e);n&&(this.failoverDraftSelections={...this.failoverDraftSelections,[n]:!!t})}selectedFailoverDrafts(){return Uk(this.failoverGeneratedRules,this.failoverDraftSelections)}selectedFailoverDraftCount(){return this.selectedFailoverDrafts().length}failoverDraftCountLabel(){return this.selectedFailoverDraftCount()+` / `+this.failoverGeneratedRules.length+` selected`}allFailoverDraftsSelected(){return Wk(this.failoverGeneratedRules,this.failoverDraftSelections)}toggleAllFailoverDrafts(){if(!(this.failoverDraftSaving||this.failoverGenerating||this.failoverGeneratedRules.length===0)){if(this.allFailoverDraftsSelected()){this.failoverDraftSelections={};return}this.selectAllFailoverDrafts(this.failoverGeneratedRules)}}failoverDraftSearchText(e){return Gk(e)}filteredFailoverDrafts(){return Kk(this.failoverGeneratedRules,this.failoverDraftFilter)}failoverDraftPayload(e){return qk(e)}async saveSelectedFailoverDrafts(){if(this.failoverDraftSaving||this.failoverGenerating)return;let e=this.selectedFailoverDrafts();if(e.length===0){this.failoverError=`Select at least one failover draft.`;return}this.failoverDraftSaving=!0,this.failoverError=``;try{for(let t of e){let e=this.failoverDraftPayload(t);if(!e.primary_model||e.fallback_models.length===0){this.failoverError=`Generated failover draft is missing model data.`;return}let n=await ys(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(n.stale)return;if(!n.ok){this.failoverError=`Failed to save failover mapping.`;return}}J.success(`Saved `+e.length+` failover mapping`+(e.length===1?`.`:`s.`)),this.failoverDraftsOpen=!1,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.fetchFailoverRules()}catch(e){console.error(`Failed to save generated failover mappings:`,e),this.failoverError=`Failed to save failover mappings.`}finally{this.failoverDraftSaving=!1}}focusFailoverEditor(){setTimeout(()=>{let e=document.querySelector(`[data-failover-editor]`),t=e&&e.querySelector?e.querySelector(`[data-modal-autofocus], input:not([disabled]), textarea:not([disabled]), button:not([disabled])`):null;t&&typeof t.focus==`function`&&t.focus({preventScroll:!0})},0)}failoverTargetLabel(e){return jk(e)}failoverPrimaryModel(e){return Ok(e)}failoverTargets(e){return kk(e)}findFailoverMapping(e){return Nk(this.failoverRules,e)}hasActiveFailoverMapping(e){return Pk(this.failoverRules,e)}failoverButtonClass(e){return Fk(this.failoverRules,e)}failoverButtonLabel(e){return Ik(this.failoverRules,e)}normalizeFailoverRules(e){return Ak(e)}failoverRuleStatus(e){return Mk(e)}qualifiedModelName(e){return rO(e)}},Yk=R(``),Xk=R(``),Zk=R(`Config`),Qk=R(`
                    Targets
                    `),$k=R(``),eA=R(`
                    Redirects to
                    `),tA=R(` `),nA=R(`
                    `),rA=R(`
                    `),iA=R(`
                    `);function aA(e,t){E(t,!0);let n=O(()=>Ck.modelRowPricing(t.row));var r=iA(),i=M(r),a=M(i),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{z(e,Yk())};V(l,e=>{t.row.is_alias&&e(u)});var d=P(l,2),f=e=>{z(e,Xk())};V(d,e=>{!t.row.is_alias&&t.row.masking_alias&&e(f)});var p=P(d,2),m=e=>{z(e,Zk())},h=O(()=>zO(t.row));V(p,e=>{I(h)&&e(m)}),T(o);var g=P(o,2),_=e=>{var n=Qk(),r=P(M(n)),i=M(r,!0);T(r),T(n),F(()=>B(i,t.row.secondary_name)),z(e,n)};V(g,e=>{t.row.is_alias&&e(_)});var v=P(g,2),y=e=>{var n=eA(),r=P(M(n)),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=$k();F(e=>{W(n,`aria-label`,nk.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),W(n,`title`,nk.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),n.disabled=e},[()=>!!nk.rowDeletingKey]),L(`click`,n,()=>nk.removeRedirectRow(t.row)),z(e,n)},s=O(()=>nk.virtualModelsAvailable&&LO(t.row));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>gO(t.row.masking_alias)]),z(e,n)};V(v,e=>{!t.row.is_alias&&t.row.masking_alias&&e(y)}),T(a),T(i);var b=P(i);H(b,17,()=>t.columns,ci,(e,r)=>{var i=tA(),a=M(i,!0);T(i),F(e=>{U(i,1,Li(I(r).class),`svelte-1iynym`),B(a,e)},[()=>I(r).value(t.row,I(n))]),z(e,i)});var x=P(b),S=M(x),C=e=>{var n=nA(),r=M(n);Tk(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>nk.rowDeletingKey===t.row.key?`Removing alias `+t.row.alias.name:`Remove alias `+t.row.alias.name),r=O(()=>!!nk.rowDeletingKey);vT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>nk.removeAliasRow(t.row),get disabled(){return I(r)},children:(e,t)=>{K(e,{get icon(){return jo},class:`table-icon-svg`})},$$slots:{default:!0}})}},o=O(()=>nk.virtualModelsAvailable&&IO(t.row));V(i,e=>{I(o)&&e(a)});var s=P(i,2),c=e=>{{let n=O(()=>`Edit alias `+t.row.alias.name);vT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>nk.openVirtualModelEditAlias(t.row.alias),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{nk.virtualModelsAvailable&&e(c)}),T(n),z(e,n)},w=e=>{var n=rA(),r=M(n);Tk(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>Ck.modelPricingButtonLabel(`model pricing for `+t.row.display_name,Ck.hasModelPricingOverride(t.row))),r=O(()=>Ck.modelPricingButtonClass(Ck.hasModelPricingOverride(t.row)));vT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>Ck.openModelPricingOverrideEdit(t.row),children:(e,t)=>{K(e,{get icon(){return Ja},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(i,e=>{Ck.modelPricingOverridesAvailable&&e(a)});var o=P(i,2),s=e=>{{let n=O(()=>Z.failoverButtonLabel(t.row)),r=O(()=>Z.failoverButtonClass(t.row));vT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>Z.openFailoverForModel(t.row),children:(e,t)=>{K(e,{get icon(){return Do},class:`table-icon-svg`})},$$slots:{default:!0}})}},c=O(()=>Z.failoverAvailable&&Z.failoverEnabled());V(o,e=>{I(c)&&e(s)});var l=P(o,2),u=e=>{{let n=O(()=>X.rateLimitGaugeTitle(t.row.display_name,X.rateLimitGaugeClassForModel(t.row))),r=O(()=>X.rateLimitGaugeClassForModel(t.row));vT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForModel(t.row),children:(e,t)=>{K(e,{get icon(){return eo},class:`table-icon-svg`})},$$slots:{default:!0}})}},d=O(()=>X.rateLimitsEnabled()&&X.rateLimitInspectorModelID(t.row));V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{{let n=O(()=>`Edit redirect for `+t.row.display_name);vT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>nk.openVirtualModelEditAlias(t.row.masking_alias),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(f,e=>{nk.virtualModelsAvailable&&t.row.masking_alias&&t.row.masking_alias.name&&e(p)});var m=P(f,2),h=e=>{{let n=O(()=>HO(`model access for `+t.row.display_name,BO(t.row.access))),r=O(()=>VO(BO(t.row.access)));vT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>nk.openVirtualModelEditModel(t.row),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(m,e=>{nk.virtualModelsAvailable&&!t.row.masking_alias&&e(h)}),T(n),z(e,n)};V(S,e=>{t.row.is_alias?e(C):e(w,-1)}),T(x),T(r),F((e,n)=>{W(r,`id`,e),U(r,1,n,`svelte-1iynym`),B(c,t.row.display_name)},[()=>RO(t.row)||void 0,()=>Li(FO(t.row))]),z(e,r),D()}Hr([`click`]);var oA={headerLines:[`Modes`],value:e=>(e.model?.metadata?.modes??[]).join(`, `)||`-`};function sA(e,t){return{headerLines:e,class:`col-price`,value:t}}var cA=sA([`Input / Output ($/MTok)`],(e,t)=>lc(t?.input_per_mtok)+` / `+lc(t?.output_per_mtok)),lA={all:[cA],text_generation:[oA,cA,sA([`Cached $/MTok`],(e,t)=>lc(t?.cached_input_per_mtok))],embedding:[sA([`Input`,`$/MTok`],(e,t)=>lc(t?.input_per_mtok))],image:[sA([`$/Image`],(e,t)=>uc(t?.per_image))],audio:[sA([`$/Second`],(e,t)=>uc(t?.per_second_input)),sA([`$/Character`],(e,t)=>uc(t?.per_character_input))],video:[sA([`$/Second (In)`],(e,t)=>uc(t?.per_second_input)),sA([`$/Second (Out)`],(e,t)=>uc(t?.per_second_output))],utility:[sA([`$/Page`],(e,t)=>uc(t?.per_page)),sA([`$/Request`],(e,t)=>uc(t?.per_request))]};function uA(e){return lA[e]||lA.all}function dA(e){return uA(e).length+2}var fA=R(`
                    `),pA=R(` `,1),mA=R(``),hA=R(` `),gA=R(` `),_A=R(`
                    `),vA=R(`
                    `),yA=R(`
                    Model
                    `);function bA(e,t){E(t,!0);let n=O(()=>Pc.activeCategory||`all`),r=O(()=>uA(I(n))),i=O(()=>dA(I(n)));var a=yA(),o=M(a),s=M(o),c=M(s),l=P(M(c));H(l,17,()=>I(r),ci,(e,t)=>{var n=mA();H(n,21,()=>I(t).headerLines,ci,(e,t,n)=>{var r=pA(),i=N(r),a=e=>{z(e,fA())};V(i,e=>{n>0&&e(a)});var o=P(i,1,!0);F(()=>B(o,I(t))),z(e,r)}),T(n),F(()=>U(n,1,Li(I(t).class),`svelte-1911hy6`)),z(e,n)});var u=P(l);Dk(M(u),{}),T(u),T(c),T(s),H(P(s),17,()=>nk.filteredDisplayModelGroups,e=>e.key,(e,t)=>{var n=vA(),a=M(n),o=M(a),s=M(o),c=M(s),l=M(c),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=e=>{var n=hA(),r=M(n,!0);T(n),F(()=>B(r,`(`+I(t).type_label+`)`)),z(e,n)};V(f,e=>{I(t).type_label&&e(p)});var m=P(f,2),h=e=>{var n=gA(),r=M(n,!0);T(n),F(()=>B(r,I(t).item_count_label)),z(e,n)};V(m,e=>{I(t).item_count_label&&e(h)}),T(l);var g=P(l,2),_=e=>{var n=_A(),r=M(n,!0);T(n),F(()=>B(r,I(t).access_summary)),z(e,n)};V(g,e=>{I(t).access_summary&&e(_)}),T(c);var v=P(c,2),y=M(v),b=e=>{Tk(e,{get row(){return I(t)}})};V(y,e=>{I(t).access.selector&&e(b)});var x=P(y,2),S=e=>{{let n=O(()=>Ck.modelPricingButtonLabel(`provider pricing for `+I(t).display_name,Ck.hasProviderPricingOverride(I(t)))),r=O(()=>Ck.modelPricingButtonClass(Ck.hasProviderPricingOverride(I(t))));vT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>Ck.openProviderPricingOverrideEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return Ja},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(x,e=>{Ck.modelPricingOverridesAvailable&&I(t).provider_name&&e(S)});var C=P(x,2),w=e=>{{let n=O(()=>X.rateLimitGaugeTitle(`provider `+I(t).display_name,X.rateLimitGaugeClassForProvider(I(t)))),r=O(()=>X.rateLimitGaugeClassForProvider(I(t)));vT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForProvider(I(t)),children:(e,t)=>{K(e,{get icon(){return eo},class:`table-icon-svg`})},$$slots:{default:!0}})}},ee=O(()=>X.rateLimitsEnabled()&&I(t).provider_name);V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{{let n=O(()=>HO(`provider access for `+I(t).display_name,BO(I(t).access))),r=O(()=>VO(BO(I(t).access)));vT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>nk.openProviderOverrideEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(te,e=>{nk.virtualModelsAvailable&&I(t).access.selector&&e(ne)}),T(v),T(s),T(o),T(a),H(P(a),17,()=>I(t).rows,e=>e.key,(e,t)=>{aA(e,{get row(){return I(t)},get columns(){return I(r)}})}),T(n),F(()=>{W(o,`colspan`,I(i)),B(d,I(t).display_name)}),z(e,n)}),T(o),T(a),z(e,a),D()}var xA=R(``);function SA(e,t){let n=G(t,`enabled`,3,!1),r=G(t,`label`,3,``),i=G(t,`disabled`,3,!1),a=G(t,`restricted`,3,!1);var o=xA();let s;var c=P(M(o),2),l=M(c,!0);T(c),T(o),F(()=>{s=U(o,1,`alias-toggle`,null,s,{enabled:n(),restricted:a()}),o.disabled=i(),W(o,`aria-label`,(n()?`Disable `:`Enable `)+r()),B(l,t.text??(n()?`Enabled`:`Disabled`))}),L(`click`,o,function(...e){t.onclick?.apply(this,e)}),z(e,o)}Hr([`click`]);var CA=R(``),wA=R(`
                    `);function TA(e,t){E(t,!0);let n=G(t,`model`,15,``),r=G(t,`weight`,15),i=G(t,`id`,3,void 0),a=G(t,`placeholder`,3,`openai/gpt-4o`),o=G(t,`showRemove`,3,!0);var s=wA(),c=M(s);ia(c);var l=P(c,2),u=e=>{var t=CA();ia(t),F(()=>t.disabled=nk.vmFormManaged),pa(t,r),z(e,t)},d=O(()=>nk.vmFormShowWeights());V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{vT(e,{label:`Remove target`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,get onclick(){return t.onremove},get disabled(){return nk.vmFormManaged},children:(e,t)=>{K(e,{get icon(){return jo},class:`table-icon-svg`})},$$slots:{default:!0}})};V(f,e=>{o()&&e(p)}),T(s),F(()=>{W(c,`id`,i()),W(c,`placeholder`,a()),c.disabled=nk.vmFormManaged}),pa(c,n),z(e,s),D()}var EA=R(`

                    `),DA=R(`adaptive lets the registered routing extension pick the target per + request.`,1),OA=R(`Add one target to make this a redirect/alias, or two or more to load + balance across them, then pick a strategy: round_robin rotates across targets + (weight biases the share) and cost always routes to the cheapest available + target. Leave Targets empty to make it only an access policy on the Source selector. The selector uses / for all providers and + models, for one provider, or for one model. user_paths is + matched against the effective request user_path: the managed API key user_path when present, otherwise the configured user path request header.`,1),kA=R(``),AA=R(`

                    This virtual model is defined in configuration (config.yaml / VIRTUAL_MODELS) and is read-only here. Edit your configuration to change it.

                    `),jA=R(``),MA=R(``),NA=R(``),PA=R(`
                    `,1),FA=R(``),IA=R(`Use / to allow every user path. Use a team path to restrict to that + subtree, or an unused path to make the selector unavailable.`,1),LA=R(``),RA=R(` `),zA=R(`
                    Targets
                    `,1);function BA(e,t){E(t,!0);let n=nk;An(()=>{n.vmFormOpen&&Cs.ensureLoaded()});{let t=e=>{JS(e,{copyId:`virtual-model-help-copy`,label:`virtual model help`,get open(){return n.vmFormHelpOpen},set open(e){n.vmFormHelpOpen=e},title:e=>{var t=EA(),r=M(t,!0);T(t),F(()=>B(r,n.vmFormDisplayName||n.vmForm.source||`Virtual model`)),z(e,t)},help:e=>{Ue();var t=OA(),n=P(N(t),7),r=e=>{var t=DA();Ue(),z(e,t)},i=O(()=>Cs.virtualModelStrategies().includes(`adaptive`));V(n,e=>{I(i)&&e(r)});var a=P(n,8);a.textContent=`{provider_name}/`;var o=P(a,2);o.textContent=`{provider_name}/{model}`,Ue(7),z(e,t)},$$slots:{title:!0,help:!0}})},r=e=>{var t=Qr(),r=N(t),i=e=>{var t=kA();F(()=>t.disabled=n.vmDeleting||n.vmSubmitting),L(`click`,t,()=>n.deleteVirtualModel()),z(e,t)};V(r,e=>{n.vmFormHasExisting&&!n.vmFormManaged&&e(i)}),z(e,t)},i=O(()=>n.vmDeleting||n.vmFormManaged),a=O(()=>n.vmFormMode===`edit`?`Save`:`Create`),o=O(()=>n.vmFormMode===`edit`?vo:mo);SE(e,{get open(){return n.vmFormOpen},ariaLabel:`Virtual model editor`,get error(){return n.vmFormError},get submitting(){return n.vmSubmitting},get submitDisabled(){return I(i)},get submitLabel(){return I(a)},get submitIcon(){return I(o)},onclose:()=>n.closeVirtualModelForm(),onsubmit:()=>n.submitVirtualModelForm(),header:t,extraActions:r,children:(e,t)=>{var r=zA(),i=N(r),a=e=>{z(e,AA())};V(i,e=>{n.vmFormManaged&&e(a)});var o=P(i,2);wE(o,{id:`virtual-model-source`,label:`Source`,children:(e,t)=>{var r=jA();ia(r),F(()=>r.disabled=n.vmFormSourceLocked||n.vmFormManaged),pa(r,()=>n.vmForm.source,e=>n.vmForm.source=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2);H(s,21,()=>Pc.models,e=>rO(e),(e,t)=>{var n=MA(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>rO(I(t)),()=>rO(I(t))]),z(e,n)}),T(s);var c=P(s,2),l=P(M(c),2);{let e=O(()=>n.vmFormHasPrimaryTarget());TA(l,{id:`virtual-model-target`,get showRemove(){return I(e)},onremove:()=>n.removePrimaryTarget(),get model(){return n.vmForm.target_model},set model(e){n.vmForm.target_model=e},get weight(){return n.vmForm.target_weight},set weight(e){n.vmForm.target_weight=e}})}var u=P(l,2);H(u,17,()=>n.vmForm.targets,ci,(e,t,r)=>{TA(e,{placeholder:`groq/llama`,onremove:()=>n.removeVmTarget(r),get model(){return I(t).model},set model(e){I(t).model=e},get weight(){return I(t).weight},set weight(e){I(t).weight=e}})});var d=P(u,2),f=M(d);K(M(f),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(f),T(d),T(c);var p=P(c,2),m=e=>{var t=PA(),r=N(t);wE(r,{id:`virtual-model-strategy`,label:`Load-balancing strategy`,children:(e,t)=>{var r=NA();H(r,21,()=>n.vmStrategyOptions(),e=>e.value,(e,t)=>{var n=MA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),F(()=>r.disabled=n.vmFormManaged),qi(r,()=>n.vmForm.strategy,e=>n.vmForm.strategy=e),z(e,r)},$$slots:{default:!0}});var i=P(r,2),a=M(i),o=M(a);ia(o),Ue(2),T(a),T(i),F(()=>o.disabled=n.vmFormManaged),ma(o,()=>n.vmForm.session_affinity,e=>n.vmForm.session_affinity=e),z(e,t)},h=O(()=>n.vmFormShowStrategy());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=M(g);JS(_,{copyId:`virtual-model-user-paths-help`,label:`user paths help`,get open(){return n.vmFormUserPathsHelpOpen},set open(e){n.vmFormUserPathsHelpOpen=e},title:e=>{z(e,FA())},help:e=>{Ue();var t=IA();Ue(2),z(e,t)},$$slots:{title:!0,help:!0}});var v=P(_,2);ft(v),W(v,`placeholder`,`/ +/team/alpha +/non-existing`),T(g);var y=P(g,2);wE(y,{id:`virtual-model-description`,label:`Description`,children:(e,t)=>{var r=LA();ft(r),F(()=>r.disabled=n.vmFormManaged),pa(r,()=>n.vmForm.description,e=>n.vmForm.description=e),z(e,r)},$$slots:{default:!0}});var b=P(y,2),x=M(b),S=e=>{var t=RA(),r=M(t,!0);T(t),F(()=>B(r,`Default enabled: `+(n.vmFormDefaultEnabled?`yes`:`no`)+` · Effective now: `+(n.vmFormEffectiveEnabled?`yes`:`no`))),z(e,t)};V(x,e=>{n.vmFormMode===`edit`&&e(S)});var C=P(x,2),w=M(C);{let e=O(()=>n.vmFormToggleRestricted()),t=O(()=>n.vmFormToggleLabel());SA(w,{get enabled(){return n.vmForm.enabled},get restricted(){return I(e)},label:`virtual model`,get disabled(){return n.vmFormManaged},get text(){return I(t)},onclick:()=>{n.vmFormManaged||(n.vmForm.enabled=!n.vmForm.enabled)}})}T(C),T(b),F(()=>{f.disabled=n.vmFormManaged,v.disabled=n.vmFormManaged}),L(`click`,f,()=>n.addVmTarget()),pa(v,()=>n.vmForm.user_paths,e=>n.vmForm.user_paths=e),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var VA=R(`

                    Pricing override

                    `,1),HA=R(``),UA=R(``),WA=R(``),GA=R(``),KA=R(`
                    `),qA=R(`
                    Tiered pricing exists for this override and will be preserved. Tier editing can be added + without a database migration.
                    `),JA=R(`
                    No pricing fields set.
                    `),YA=R(`
                    `),XA=R(`

                    Currency is USD. Saved fields override model registry and config.yaml pricing for this + selector; unset fields continue to inherit.

                    Price Type USD Source
                    `,1);function ZA(e,t){E(t,!0);let n=Ck;SE(e,{get open(){return n.modelPricingOverrideFormOpen},ariaLabel:`Model pricing editor`,dialogClass:`model-pricing-editor`,get error(){return n.modelPricingOverrideError},get submitting(){return n.modelPricingOverrideSubmitting},submitLabel:`Save Pricing`,onclose:()=>n.closeModelPricingOverrideForm(),onsubmit:()=>n.submitModelPricingOverrideForm(),header:e=>{var t=VA(),r=P(N(t),2),i=M(r,!0);T(r),F(()=>B(i,n.modelPricingOverrideFormDisplayName||n.modelPricingOverrideForm.selector||`Pricing`)),z(e,t)},extraActions:e=>{var t=Qr(),r=N(t),i=e=>{var t=HA();F(()=>t.disabled=n.modelPricingOverrideSubmitting),L(`click`,t,()=>n.deleteModelPricingOverride()),z(e,t)};V(r,e=>{n.modelPricingOverrideFormHasExistingOverride&&e(i)}),z(e,t)},children:(e,t)=>{var r=XA(),i=N(r),a=M(i);wE(a,{id:`model-pricing-override-selector`,label:`Selector`,children:(e,t)=>{var r=UA();ia(r),pa(r,()=>n.modelPricingOverrideForm.selector,e=>n.modelPricingOverrideForm.selector=e),z(e,r)},$$slots:{default:!0}});var o=P(a,2),s=e=>{wE(e,{id:`model-pricing-override-scope`,label:`Scope`,children:(e,t)=>{var r=GA();H(r,21,()=>n.modelPricingOverrideFormScopeOptions,e=>e.value,(e,t)=>{var n=WA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),L(`change`,r,()=>n.setModelPricingOverrideScope(n.modelPricingOverrideFormScope)),qi(r,()=>n.modelPricingOverrideFormScope,e=>n.modelPricingOverrideFormScope=e),z(e,r)},$$slots:{default:!0}})};V(o,e=>{n.modelPricingOverrideFormScopeOptions.length>1&&e(s)}),T(i);var c=P(i,4);H(c,21,()=>n.modelPricingOverrideRows,e=>e.id,(e,t,r)=>{var i=KA(),a=M(i),o=M(a),s=P(o,2);H(s,21,()=>n.availablePricingFieldOptions(I(t)),e=>e.value,(e,t)=>{var n=WA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).group+` - `+I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(s),T(a);var c=P(a,2),l=M(c),u=P(l,2);ia(u),T(c);var d=P(c,2);{let e=O(()=>`Remove `+n.pricingFieldLabel(I(t).field));vT(d,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn pricing-override-remove-row`,onclick:()=>n.removeModelPricingOverrideRow(I(t)),children:(e,t)=>{K(e,{get icon(){return Lo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(i),F(()=>{W(o,`for`,`pricing-type-`+I(t).id),W(s,`id`,`pricing-type-`+I(t).id),W(l,`for`,`pricing-value-`+I(t).id),W(u,`id`,`pricing-value-`+I(t).id)}),qi(s,()=>I(t).field,e=>I(t).field=e),pa(u,()=>I(t).value,e=>I(t).value=e),z(e,i)}),T(c);var l=P(c,2),u=M(l);K(M(u),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(u),T(l);var d=P(l,2),f=e=>{z(e,qA())};V(d,e=>{n.modelPricingOverrideFormPreservedTiers.length>0&&e(f)});var p=P(d,2),m=P(M(p),2),h=e=>{z(e,JA())},g=O(()=>n.modelPricingEffectivePreviewRows().length===0);V(m,e=>{I(g)&&e(h)}),H(P(m,2),17,()=>n.modelPricingEffectivePreviewRows(),e=>e.field,(e,t)=>{var n=YA(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{B(i,I(t).label),B(o,e),B(c,I(t).source)},[()=>I(t).value===null||I(t).value===void 0?`-`:uc(Number(I(t).value))]),z(e,n)}),T(p),L(`click`,u,()=>n.addModelPricingOverrideRow()),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}}),D()}Hr([`click`,`change`]);var QA=R(`

                    Failover mapping

                    `,1),$A=R(``),ej=R(`

                    This failover mapping is defined in configuration and is read-only here.

                    `),tj=R(``),nj=R(`
                    `),rj=R(`
                    `,1),ij=R(`
                    `);function aj(e,t){E(t,!0);{let t=e=>{var t=QA(),n=P(N(t),2),r=M(n,!0);T(n),F(()=>B(r,Z.failoverForm.source||`Failover`)),z(e,t)},n=e=>{var t=Qr(),n=N(t),r=e=>{var t=$A();F(()=>t.disabled=Z.failoverSaving||Z.failoverGenerating),L(`click`,t,()=>Z.deleteFailoverRule()),z(e,t)};V(n,e=>{Z.failoverFormMode===`edit`&&!Z.failoverFormManaged&&e(r)}),z(e,t)},r=O(()=>Z.failoverGenerating||Z.failoverFormManaged);SE(e,{get open(){return Z.failoverFormOpen},ariaLabel:`Failover editor`,get error(){return Z.failoverError},get submitting(){return Z.failoverSaving},get submitDisabled(){return I(r)},submitLabel:`Save`,onclose:()=>Z.closeFailoverForm(),onsubmit:()=>Z.submitFailoverForm(),header:t,extraActions:n,children:(e,t)=>{var n=ij(),r=M(n),i=e=>{z(e,ej())};V(r,e=>{Z.failoverFormManaged&&e(i)});var a=P(r,2);H(a,21,()=>Pc.models,ci,(e,t)=>{var n=tj(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>rO(I(t)),()=>rO(I(t))]),z(e,n)}),T(a);var o=P(a,2);wE(o,{id:`failover-target`,label:`Fallback models`,children:(e,t)=>{var n=rj(),r=N(n),i=M(r),a=M(i);ia(a);var o=P(a,2),s=e=>{vT(e,{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removePrimaryFailoverTarget(),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{K(e,{get icon(){return jo},class:`table-icon-svg`})},$$slots:{default:!0}})};V(o,e=>{Z.failoverForm.target_model&&e(s)}),T(i),H(P(i,2),17,()=>Z.failoverForm.targets,ci,(e,t,n)=>{var r=nj(),i=M(r);ia(i),vT(P(i,2),{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removeFailoverTarget(n),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{K(e,{get icon(){return jo},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),F(()=>i.disabled=Z.failoverFormManaged),pa(i,()=>I(t).model,e=>I(t).model=e),z(e,r)}),T(r);var c=P(r,2),l=M(c);K(M(l),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(l);var u=P(l,2),d=M(u);K(d,{get icon(){return Fo},class:`form-action-icon`});var f=P(d,2),p=M(f,!0);T(f),T(u),T(c),F(e=>{a.disabled=Z.failoverFormManaged,l.disabled=Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving,u.disabled=e,B(p,Z.failoverGenerating?`Generating...`:`Generate automatically`)},[()=>Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving||!Z.failoverEnabled()]),pa(a,()=>Z.failoverForm.target_model,e=>Z.failoverForm.target_model=e),L(`click`,l,()=>Z.addFailoverTarget()),L(`click`,u,()=>Z.generateFailoverForForm()),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=M(s);SA(M(c),{get enabled(){return Z.failoverForm.enabled},label:`failover mapping`,get disabled(){return Z.failoverFormManaged},onclick:()=>{Z.failoverFormManaged||(Z.failoverForm.enabled=!Z.failoverForm.enabled)}}),T(c),T(s),T(n),z(e,n)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var oj=R(` `),sj=R(`
                    `),cj=R(``),lj=R(`
                    `),uj=R(`

                    No failover suggestions were generated.

                    `),dj=R(`

                    No failover drafts match the filter.

                    `),fj=R(``),pj=R(``);function mj(e,t){E(t,!0),Ps(e,{get open(){return Z.failoverDraftsOpen},variant:`editor`,onclose:()=>Z.closeFailoverDraftsModal(),children:(e,t)=>{var n=pj(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=oj(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>Z.failoverDraftCountLabel()]),z(e,t)};V(a,e=>{Z.failoverGeneratedRules.length>0&&e(o)}),As(P(a,2),{label:`Close failover drafts`,onclick:()=>Z.closeFailoverDraftsModal(),get disabled(){return Z.failoverDraftSaving}}),T(i),T(r);var s=P(r,2),c=e=>{gT(e,{label:`Generating failover drafts...`,class:`failover-drafts-loading`})};V(s,e=>{Z.failoverGenerating&&e(c)});var l=P(s,2),u=e=>{var t=sj(),n=M(t);xw(n,{placeholder:`Filter failover drafts...`,label:`Filter failover drafts`,get value(){return Z.failoverDraftFilter},set value(e){Z.failoverDraftFilter=e}});var r=P(n,2),i=M(r);K(i,{get icon(){return Ha},class:`form-action-icon`});var a=P(i,2),o=M(a,!0);T(a),T(r),T(t),F(e=>{r.disabled=Z.failoverDraftSaving,B(o,e)},[()=>Z.allFailoverDraftsSelected()?`Deselect all`:`Select all`]),L(`click`,r,()=>Z.toggleAllFailoverDrafts()),z(e,t)};V(l,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&e(u)});var d=P(l,2),f=e=>{var t=lj();H(t,21,()=>Z.filteredFailoverDrafts(),e=>`failover-draft:`+Z.failoverPrimaryModel(e),(e,t)=>{var n=cj(),r=M(n);ia(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(i),T(n),F((e,t,n,i)=>{oa(r,e),r.disabled=Z.failoverDraftSaving,W(r,`aria-label`,t),B(o,n),B(c,i)},[()=>Z.failoverDraftSelected(I(t)),()=>`Select failover draft for `+Z.failoverPrimaryModel(I(t)),()=>Z.failoverPrimaryModel(I(t)),()=>Z.failoverTargetLabel(I(t))]),L(`change`,r,e=>Z.setFailoverDraftSelected(I(t),e.currentTarget.checked)),z(e,n)}),T(t),z(e,t)},p=O(()=>!Z.failoverGenerating&&Z.filteredFailoverDrafts().length>0);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{z(e,uj())};V(m,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length===0&&!Z.failoverError&&e(h)});var g=P(m,2),_=e=>{z(e,dj())},v=O(()=>!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&Z.filteredFailoverDrafts().length===0);V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=fj(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(y,e=>{Z.failoverError&&e(b)});var x=P(y,2),S=M(x),C=P(S,2),w=M(C);K(w,{get icon(){return vo},class:`form-action-icon`});var ee=P(w,2),te=M(ee,!0);T(ee),T(C),T(x),T(n),F(e=>{S.disabled=Z.failoverDraftSaving,C.disabled=e,B(te,Z.failoverDraftSaving?`Saving...`:`Save selected`)},[()=>Z.failoverGenerating||Z.failoverDraftSaving||Z.selectedFailoverDraftCount()===0]),L(`click`,S,()=>Z.closeFailoverDraftsModal()),L(`click`,C,()=>Z.saveSelectedFailoverDrafts()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`,`change`]);var hj=R(`
                    Rate limit management is unavailable.
                    `),gj=R(` Add`,1),_j=R(`

                    `),vj=R(`

                    No rules.

                    `),yj=R(` Edit`,1),bj=R(`
                    `),xj=R(`
                    `),Sj=R(`

                    `),Cj=R(``),wj=R(``);function Tj(e,t){E(t,!0);function n(){q.dialogOpen||X.closeRateLimitInspector()}Ps(e,{get open(){return X.rateLimitInspectorOpen},variant:`editor`,onclose:n,children:(e,t)=>{var n=wj(),r=M(n),i=M(r),a=P(M(i),2),o=M(a),s=M(o,!0);T(o),T(a),T(i),As(P(i,2),{label:`Close rate limits inspector`,onclick:()=>X.closeRateLimitInspector()}),T(r);var c=P(r,2),l=e=>{gT(e,{label:`Loading rate limits...`})},u=e=>{z(e,hj())},d=e=>{var t=Qr();H(N(t),17,()=>X.rateLimitInspectorSections(),e=>e.key,(e,t)=>{var n=Sj(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2);{let e=O(()=>`Add `+I(t).title.toLowerCase());vT(o,{get label(){return I(e)},class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(I(t).scope,I(t).subject),children:(e,t)=>{var n=gj();K(N(n),{get icon(){return mo},class:`table-icon-svg`}),Ue(2),z(e,n)},$$slots:{default:!0}})}T(r);var s=P(r,2),c=e=>{var n=_j(),r=M(n,!0);T(n),F(()=>B(r,I(t).hint)),z(e,n)};V(s,e=>{I(t).hint&&e(c)});var l=P(s,2),u=e=>{z(e,vj())},d=e=>{var n=xj();H(n,21,()=>I(t).items,e=>X.rateLimitKey(e),(e,t)=>{var n=bj(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=M(c);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?Na:Ao);K(l,{get icon(){return I(e)},class:`budget-period-icon`})}var u=P(l,2),d=M(u,!0);T(u),T(c),T(s);var f=P(s,2),p=M(f),m=M(p),h=M(m,!0);T(m);var g=P(m,2),_=M(g,!0);T(g),T(p);var v=P(p,2),y=M(v),b=e=>{vT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(null,null,I(t)),children:(e,t)=>{var n=yj();K(N(n),{get icon(){return fo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},x=O(()=>!X.rateLimitIsReadOnly(I(t)));V(y,e=>{I(x)&&e(b)}),T(v),T(f),T(i),T(r),T(n),F((e,t,r,i,a,s,c,l)=>{U(n,1,`budget-row ${e??``}`),Wi(n,t),W(n,`title`,r),B(o,i),B(d,a),B(h,s),W(g,`title`,c),B(_,l)},[()=>X.rateLimitPressureClass(I(t)),()=>X.rateLimitPressureStyle(I(t)),()=>X.rateLimitPressurePercent(I(t))+`% of the most constrained cap used`,()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitInspectorSummary(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n)};V(l,e=>{I(t).items.length===0?e(u):e(d,-1)}),T(n),F(()=>B(a,I(t).title)),z(e,n)}),z(e,t)};V(c,e=>{X.rateLimitsLoading?e(l):X.rateLimitsAvailable?e(d,-1):e(u,1)});var f=P(c,2),p=M(f),m=P(p,2),h=e=>{var t=Cj();L(`click`,t,()=>{X.closeRateLimitInspector(),Yo.navigate(`rate-limits`)}),z(e,t)},g=O(()=>X.rateLimitsEnabled());V(m,e=>{I(g)&&e(h)}),T(f),T(n),F(()=>B(s,X.rateLimitInspector.title)),L(`click`,p,()=>X.closeRateLimitInspector()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`]);var Ej=R(`
                    models
                    `),Dj=R(`
                    Virtual models feature is unavailable.
                    `),Oj=R(`
                    `),kj=R(``),Aj=R(`
                    `),jj=R(``),Mj=R(`
                    `),Nj=R(`

                    No models registered.

                    `),Pj=R(`

                    No models in this category.

                    `),Fj=R(`

                    No models match your filter.

                    `),Ij=R(`
                    `);function Lj(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`models`&&(nk.fetchVirtualModels(),Ck.fetchModelPricingOverrides(),Z.fetchFailoverRules(),X.fetchRateLimitsPage())}),An(()=>{let e=nk.filteredDisplayModels.length;return Er(()=>nk.restartModelRendering(e)),()=>nk.stopModelRendering()});let n=O(()=>q.needsAuth);var r=Ij(),i=M(r),a=P(M(i),2),o=e=>{var t=Ej(),n=M(t),r=M(n,!0);T(n),Ue(),T(t),F(()=>B(r,Pc.filter?nk.filteredDisplayModels.length+` / `+nk.displayModels.length:nk.displayModels.length)),z(e,t)};V(a,e=>{nk.displayModels.length>0&&e(o)}),T(i);var s=P(i,2);Ic(s,{});var c=P(s,2),l=e=>{z(e,Dj())};V(c,e=>{!nk.virtualModelsAvailable&&!I(n)&&e(l)});var u=P(c,2),d=e=>{var t=Oj(),n=M(t,!0);T(t),F(()=>B(n,nk.aliasError)),z(e,t)};V(u,e=>{nk.aliasError&&!I(n)&&e(d)});var f=P(u,2),p=e=>{var t=Oj(),n=M(t,!0);T(t),F(()=>B(n,Ck.modelPricingOverrideError)),z(e,t)};V(f,e=>{Ck.modelPricingOverrideError&&!I(n)&&!Ck.modelPricingOverrideFormOpen&&e(p)});var m=P(f,2),h=e=>{var t=Aj();H(t,21,()=>Pc.categories,e=>e.category,(e,t)=>{var n=kj();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F(()=>{r=U(n,1,`category-tab svelte-scpjps`,null,r,{active:Pc.activeCategory===I(t).category}),B(a,I(t).display_name),B(s,I(t).count)}),L(`click`,n,()=>Pc.selectCategory(I(t).category)),z(e,n)}),T(t),z(e,t)};V(m,e=>{Pc.categories.length>0&&e(h)});var g=P(m,2),_=e=>{var t=Mj(),n=M(t);xw(M(n),{placeholder:`Filter by provider, provider/model, alias, or owner...`,label:`Filter models by provider, provider/model, alias, or owner`,get value(){return Pc.filter},set value(e){Pc.filter=e}}),T(n);var r=P(n,2),i=M(r),a=e=>{var t=jj();K(M(t),{get icon(){return mo},class:`alias-create-icon`}),Ue(2),T(t),L(`click`,t,()=>nk.openVirtualModelCreate()),z(e,t)};V(i,e=>{nk.virtualModelsAvailable&&e(a)}),T(r),T(t),z(e,t)};V(g,e=>{(nk.displayModels.length>0||Pc.filter||nk.virtualModelsAvailable)&&e(_)});var v=P(g,2),y=e=>{{let t=O(()=>nk.modelLoadingText());gT(e,{get label(){return I(t)},class:`models-loading-state`})}},b=O(()=>nk.modelsBusy()&&!I(n));V(v,e=>{I(b)&&e(y)});var x=P(v,2);BA(x,{});var S=P(x,2);ZA(S,{});var C=P(S,2),w=e=>{bA(e,{})};V(C,e=>{(nk.displayModels.length>0||Pc.filter)&&e(w)});var ee=P(C,2),te=e=>{z(e,Nj())};V(ee,e=>{nk.displayModels.length===0&&!Pc.loading&&!I(n)&&!Pc.filter&&(Pc.activeCategory===`all`||!Pc.activeCategory)&&e(te)});var ne=P(ee,2),re=e=>{z(e,Pj())};V(ne,e=>{nk.displayModels.length===0&&!Pc.loading&&!I(n)&&!Pc.filter&&Pc.activeCategory&&Pc.activeCategory!==`all`&&e(re)});var ie=P(ne,2),ae=e=>{z(e,Fj())};V(ie,e=>{nk.displayModels.length>0&&nk.filteredDisplayModels.length===0&&Pc.filter&&e(ae)});var oe=P(ie,2);Tj(oe,{});var se=P(oe,2);LD(se,{});var ce=P(se,2);aj(ce,{}),mj(P(ce,2),{}),T(r),z(e,r),D()}Hr([`click`]);var Rj=`draft-workflow-preview`;function zj(){return{scope_provider:``,scope_model:``,scope_user_path:``,name:``,description:``,features:{cache:!0,audit:!0,usage:!0,budget:!0,guardrails:!1,failover:!0},guardrails:[]}}function Bj(){return{scope_provider:``,scope_model:``,scope_user_path:``}}function Vj(e){return{ref:``,step:Number.isFinite(e)?e:10}}function Hj(e){let t=e==null?``:String(e).trim();if(t===``)return NaN;let n=Number(t);return Number.isFinite(n)?n:NaN}function Uj(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=t.charAt(0).toUpperCase()+t.slice(1);for(let n of[t,r])if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==null&&e[n]!==void 0)return e[n];return n}function Wj(e,t){return!e||typeof e!=`object`||Array.isArray(e)?!1:[t,t.charAt(0).toUpperCase()+t.slice(1)].some(t=>Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==null&&e[t]!==void 0)}function Gj(e){return{cache:!!Uj(e,`cache`,!1),audit:!!Uj(e,`audit`,!1),usage:!!Uj(e,`usage`,!1),budget:Uj(e,`budget`,!0)!==!1,guardrails:!!Uj(e,`guardrails`,!1),failover:Uj(e,`failover`,!0)!==!1}}function Kj(e,t){let n=Gj(e),r=t||{},i=n.usage&&!!r.usage;return{cache:n.cache&&!!r.cache,audit:n.audit&&!!r.audit,usage:i,budget:i&&n.budget&&!!r.budget,guardrails:n.guardrails&&!!r.guardrails,failover:n.failover&&!!r.failover}}function qj(e,t){let n=e&&e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:e&&e.features?e.features:{};return{...Kj((e&&e.effective_features&&typeof e.effective_features==`object`&&!Array.isArray(e.effective_features)?e.effective_features:null)||n,t),failover:Gj(n).failover}}function Jj(e,t){return qj(e,t).failover?`On`:`Off`}function Yj(e){return(Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:Array.isArray(e&&e.guardrails)?e.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Hj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0)}function Xj(e,t){return qj(e,t).guardrails&&Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[]}function Zj(e){return String(e&&(e.scope_provider_name||e.scope_provider)||``).trim()}function Qj(e){return String(e&&(e.provider_name||e.provider_type)||``).trim()}function $j(e,t){let n=new Set,r=String(t&&t.scope_provider||``).trim();return r&&n.add(r),(Array.isArray(e)?e:[]).forEach(e=>{let t=Qj(e);t&&n.add(t)}),[...n].sort()}function eM(e,t,n){let r=String(t||``).trim(),i=new Set,a=String(n&&n.scope_provider||``).trim(),o=String(n&&n.scope_model||``).trim();return r&&r===a&&o&&i.add(o),(Array.isArray(e)?e:[]).forEach(e=>{if(r&&Qj(e)!==r)return;let t=String(e&&e.model&&e.model.id||``).trim();t&&i.add(t)}),[...i].sort()}function tM(e){let t=String(e&&e.scope_type||``).trim();return t===`provider_model`?`Provider Name + Model`:t===`provider_model_path`?`Provider Name + Model + Path`:t===`provider_path`?`Provider Name + Path`:t===`path`?`Path`:t===`provider`?`Provider Name`:`Global`}function nM(e){return String(e&&e.scope_display||`global`).trim()||`global`}function rM(e){let t=String(e&&e.name||``).trim();if(t)return t;let n=nM(e);return n===`global`?`All models`:n}function iM(e){let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function aM(e){if(iM(e))return``;let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function oM(e){let t=e||zj(),n=String(t.scope_provider||``).trim(),r=aM(t.scope_user_path);return{scope_provider:n,scope_model:n?String(t.scope_model||``).trim():``,scope_user_path:r}}function sM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=aM(e&&e.scope_user_path);return!t&&!r?`global`:!t&&r?`path`:!n&&!r?`provider`:!n&&r?`provider_path`:r?`provider_model_path`:`provider_model`}function cM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=aM(e&&e.scope_user_path),i=sM({scope_provider:t,scope_model:n,scope_user_path:r});return i===`global`?`global`:i===`path`?r:i===`provider`?t:i===`provider_path`?t+` @ `+r:i===`provider_model_path`?t+`/`+n+` @ `+r:t+`/`+n}function lM(e,t){let n=t||Bj(),r=Zj(e&&e.scope),i=r?String(e&&e.scope&&e.scope.scope_model||``).trim():``,a=aM(e&&e.scope&&e.scope.scope_user_path);return r===String(n.scope_provider||``).trim()&&i===String(n.scope_model||``).trim()&&a===aM(n.scope_user_path)}function uM(e,t,n){let r=oM(t);return!(r.scope_provider!==``||r.scope_model!==``||r.scope_user_path!==``)&&!n?null:(Array.isArray(e)?e:[]).find(e=>lM(e,r))||null}function dM(e){return String(e&&e.scope_type||``).trim()!==`global`}function fM(e){let t=String(e||``).trim();return t?t.length<=14?t:t.slice(0,12)+`…`:`—`}function pM(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.description,e.scope_display,e.scope_type,Zj(e&&e.scope),e.scope&&e.scope.scope_model,e.scope&&e.scope.scope_user_path,e.workflow_hash,...Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>e.ref):[]].some(e=>String(e||``).toLowerCase().includes(r)))}function mM(e,t){let n=e||zj(),r=oM(n),i=Gj(n.features||{}),a=Kj(i,t);a.failover=i.failover;let o=!!a.guardrails,s=o?Yj(n):[];return{id:Rj,scope_type:sM(r),scope_display:cM(r),scope:{scope_provider_name:r.scope_provider,scope_model:r.scope_model,...r.scope_user_path?{scope_user_path:r.scope_user_path}:{}},name:String(n.name||``).trim(),description:String(n.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!a.cache,audit:!!a.audit,usage:!!a.usage,budget:!!a.budget,guardrails:o,failover:!!a.failover},guardrails:s}}}function hM({form:e,caps:t,workflows:n=[],formHydrated:r=!1,hydratedScope:i=null}){let a=e||zj(),o=String(a.scope_provider||``).trim(),s=o?String(a.scope_model||``).trim():``,c=aM(a.scope_user_path),l=Gj(a.features||{}),u=Kj(l,t),d=uM(n,a,r),f=d&&d.workflow_payload&&d.workflow_payload.features,p=Wj(f,`failover`),m=p?Uj(f,`failover`,!0)!==!1:null,h=i||Bj(),g=String(h.scope_provider||``).trim()===o&&String(h.scope_model||``).trim()===s&&aM(h.scope_user_path)===aM(c),_=!!(t&&t.failover),v=_||!!r&&g&&Object.prototype.hasOwnProperty.call(l,`failover`)||!r&&!!d&&p,y=u.guardrails?(Array.isArray(a.guardrails)?a.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Hj(e&&e.step)})):[],b={scope_provider_name:o,scope_model:s,...c?{scope_user_path:c}:{},name:String(a.name||``).trim(),description:String(a.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!u.cache,audit:!!u.audit,usage:!!u.usage,budget:!!u.budget,guardrails:!!u.guardrails},guardrails:y}};return v&&(b.workflow_payload.features.failover=!_&&!r&&d&&p?m:!!l.failover),b}function gM(e,{models:t=[],hydratedScope:n=null}={}){let r=n||Bj(),i=String(r.scope_provider||``).trim(),a=String(r.scope_model||``).trim(),o=String(e&&(e.scope_provider_name||e.scope_provider)||``).trim(),s=String(e&&e.scope_model||``).trim();if(o&&!$j(t,r).includes(o)&&o!==i)return`Choose a registered provider name.`;if(s&&!o)return`Model selection requires a provider name.`;if(s){let e=eM(t,o,r),n=o===i&&s===a;if(!e.includes(s)&&!n)return`Choose a registered model for the selected provider name.`}let c=iM(e.scope_user_path);if(c)return c;let l=e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:{},u=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[];if(!l.guardrails)return``;let d=new Set;for(let e of u){if(!e.ref)return`Each guardrail step needs a guardrail ref.`;if(!Number.isInteger(e.step)||e.step<0)return`Each guardrail step must use a non-negative integer step number.`;if(d.has(e.ref))return`Each guardrail ref may appear only once in a workflow.`;d.add(e.ref)}return``}var _M=new class{#e=k(j([]));get workflows(){return I(this.#e)}set workflows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get submitting(){return I(this.#o)}set submitting(e){A(this.#o,e,!0)}#s=k(``);get deactivatingID(){return I(this.#s)}set deactivatingID(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get formHydrated(){return I(this.#l)}set formHydrated(e){A(this.#l,e,!0)}#u=k(j(Bj()));get hydratedScope(){return I(this.#u)}set hydratedScope(e){A(this.#u,e,!0)}#d=k(j([]));get guardrailRefs(){return I(this.#d)}set guardrailRefs(e){A(this.#d,e,!0)}#f=k(j(zj()));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}#p=null;failoverVisible(){return Cs.booleanFlag(`FAILOVER_ENABLED`,!0)}featureCaps(){return{cache:Cs.cacheVisible(),audit:Cs.auditVisible(),usage:Cs.usageVisible(),budget:Cs.budgetsVisible(),guardrails:Cs.guardrailsVisible(),failover:this.failoverVisible()}}get filteredWorkflows(){return pM(this.workflows,this.filter)}providerOptions(){return $j(Pc.models,this.hydratedScope)}modelOptions(e){return eM(Pc.models,e,this.hydratedScope)}activeScopeMatch(){return uM(this.workflows,this.form,this.formHydrated)}submitMode(){return this.activeScopeMatch()?`save`:`create`}submitLabel(){return this.submitMode()===`save`?`Save`:`Create`}submittingLabel(){return this.submitMode()===`save`?`Saving...`:`Creating...`}preview(){return mM(this.form,this.featureCaps())}openCreate(e){if(this.formOpen=!0,this.submitting=!1,this.formError=``,!e){this.formHydrated=!1,this.hydratedScope=Bj(),this.form=zj();return}this.formHydrated=!0,this.hydratedScope={scope_provider:Zj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``).trim(),scope_user_path:String(e.scope&&e.scope.scope_user_path||``).trim()};let t=e.workflow_payload&&e.workflow_payload.features?Gj(e.workflow_payload.features):qj(e,this.featureCaps()),n=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>({ref:String(e&&e.ref||``).trim(),step:Hj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0):Yj(e);this.form={scope_provider:Zj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``),scope_user_path:String(e.scope&&e.scope.scope_user_path||``),name:String(e.name||``),description:String(e.description||``),features:{cache:!!t.cache,audit:!!t.audit,usage:!!t.usage,budget:!!t.budget,guardrails:!!t.guardrails,failover:!!t.failover},guardrails:n.map(e=>({ref:String(e&&e.ref||``),step:Number.isFinite(e&&e.step)?e.step:10}))}}closeForm(){this.formOpen=!1,this.submitting=!1,this.formError=``,this.formHydrated=!1,this.hydratedScope=Bj(),this.form=zj()}setProvider(e){if(this.form.scope_provider=String(e||``).trim(),!this.form.scope_provider){this.form.scope_model=``;return}this.modelOptions(this.form.scope_provider).includes(String(this.form.scope_model||``).trim())||(this.form.scope_model=``)}addGuardrailStep(){let e=(Array.isArray(this.form.guardrails)?this.form.guardrails:[]).reduce((e,t)=>{let n=Number(t&&t.step);return Number.isFinite(n)?Math.max(e,n):e},0)+10;this.form.guardrails.push(Vj(e))}removeGuardrailStep(e){Array.isArray(this.form.guardrails)&&this.form.guardrails.splice(e,1)}buildRequest(){return hM({form:this.form,caps:this.featureCaps(),workflows:this.workflows,formHydrated:this.formHydrated,hydratedScope:this.hydratedScope})}async fetchWorkflows(){this.#p&&this.#p.abort();let e=new AbortController;this.#p=e,this.loading=!0,this.error=``;let t=setTimeout(()=>e.abort(),1e4),n=await yT(`/admin/workflows`,{label:`workflows`,options:{signal:e.signal}});if(clearTimeout(t),this.#p===e&&(this.#p=null,this.loading=!1,n.status!==`stale`)){if(n.status===`unavailable`){this.available=!1,this.workflows=[];return}if(n.result&&(this.available=!0),n.status===`error`){this.workflows=[],this.error=e.signal.aborted?`Loading workflows timed out.`:n.error;return}this.workflows=n.items}}async fetchGuardrailRefs(){let e=await yT(`/admin/workflows/guardrails`,{label:`workflow guardrails`});e.status!==`stale`&&(this.guardrailRefs=e.items)}async fetchPage(){await Promise.all([Cs.ensureLoaded(),this.fetchWorkflows(),this.fetchGuardrailRefs()])}async submitForm(){if(this.submitting)return;this.formError=``;let e=this.buildRequest(),t=gM(e,{models:Pc.models,hydratedScope:this.hydratedScope});if(t){this.formError=t;return}this.submitting=!0;try{let t=await bT(`/admin/workflows`,`POST`,e,{label:`create workflow`,unavailableStatuses:[]});if(t.status===`stale`||t.result&&t.result.status===401)return;if(t.status===`error`){this.formError=t.error;return}J.success(`Workflow created and activated.`),this.closeForm(),this.fetchPage()}finally{this.submitting=!1}}async deactivate(e){let t=String(e&&e.id||``).trim();if(!t||this.deactivatingID||!dM(e))return;let n=rM(e);if(confirm(`Deactivate workflow "`+n+`"? Requests will fall back to the next active workflow for this scope.`)){this.deactivatingID=t;try{let e=await bT(`/admin/workflows/`+encodeURIComponent(t)+`/deactivate`,`POST`,void 0,{label:`deactivate workflow`,unavailableStatuses:[]});if(e.status===`stale`||e.result&&e.result.status===401)return;if(e.status===`error`){J.error(e.error);return}J.success(`Workflow deactivated.`),this.fetchPage()}finally{this.deactivatingID=``}}}};function vM(e){let t=String(e??``),n=typeof navigator<`u`?navigator.clipboard:null;if(n&&typeof n.writeText==`function`)return n.writeText(t);let r=typeof document<`u`?document:null;if(!r||!r.body||typeof r.execCommand!=`function`)return Promise.reject(Error(`Clipboard API unavailable`));let i=r.createElement(`textarea`);i.value=t,i.setAttribute(`readonly`,``),i.style.position=`fixed`,i.style.top=`0`,i.style.left=`0`,i.style.opacity=`0`;try{if(r.body.appendChild(i),i.focus(),i.select(),i.setSelectionRange(0,i.value.length),!r.execCommand(`copy`))throw Error(`execCommand copy returned false`)}finally{i.parentNode&&i.parentNode.removeChild(i)}return Promise.resolve()}function yM({resetDelayMs:e=2e3,logPrefix:t}={}){let n=j({copied:!1,error:!1}),r=null;function i(){r!==null&&clearTimeout(r),r=null}function a(){i(),r=setTimeout(()=>{n.copied=!1,n.error=!1,r=null},e)}return{get copied(){return n.copied},get error(){return n.error},reset(){i(),n.copied=!1,n.error=!1},async copy(e,r){if(!(e==null||e===``)){i(),n.copied=!1,n.error=!1;try{await vM(typeof r==`function`?r(e):String(e)),n.copied=!0,n.error=!1}catch(e){console.error(t||`Failed to copy text:`,e),n.copied=!1,n.error=!0}a()}}}}var bM=R(``);function xM(e,t){E(t,!0);let n=G(t,`workflowID`,3,``),r=yM({logPrefix:`Failed to copy workflow ID:`});An(()=>{n(),r.reset()});let i=O(()=>r.error?`Unable to copy workflow ID`:r.copied?`Workflow ID copied`:`Copy workflow ID`),a=O(()=>n()?I(i)+` `+n():I(i));async function o(e){e.preventDefault(),n()&&await r.copy(n())}var s=bM();let c;var l=P(M(s),4),u=M(l,!0);T(l);var d=P(l,2);K(M(d),{get icon(){return Xa}}),T(d),T(s),F(()=>{c=U(s,1,`workflow-pipeline-meta mono svelte-1viff7o`,null,c,{"workflow-pipeline-meta-copied":r.copied,"workflow-pipeline-meta-error":r.error}),W(s,`title`,I(i)),W(s,`aria-label`,I(a)),B(u,n())}),L(`click`,s,o),z(e,s),D()}Hr([`click`]);var SM=(e,t)=>{let n=()=>(t?.()).icon,r=()=>(t?.()).label,i=Ot(()=>h((t?.()).variant,`workflow-node-feature`)),a=()=>(t?.()).state,o=()=>(t?.()).sub,s=()=>(t?.()).badge;var c=EM(),l=M(c),u=e=>{var t=CM();let r;K(M(t),{get icon(){return n()}}),T(t),F(()=>r=U(t,1,`workflow-node-icon svelte-nbptrg`,null,r,{"workflow-node-icon-endpoint":I(i)===`workflow-node-endpoint`})),z(e,t)};V(l,e=>{n()&&e(u)});var d=P(l,2),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var t=wM(),n=M(t,!0);T(t),F(()=>B(n,s())),z(e,t)};V(p,e=>{s()&&e(m)});var g=P(p,2),_=e=>{var t=TM(),n=M(t,!0);T(t),F(()=>B(n,o())),z(e,t)};V(g,e=>{o()&&e(_)}),T(c),F(()=>{U(c,1,Li([`workflow-node`,I(i),a()]),`svelte-nbptrg`),B(f,r())}),z(e,c)},CM=R(`
                    `),wM=R(` `),TM=R(` `),EM=R(`
                    `),DM=R(`
                    `,1),OM=R(`
                    `,1),kM=R(`
                    `),AM=R(`
                    Async
                    `),jM=R(`
                    `);function MM(e,t){E(t,!0);let n=G(t,`chart`,19,()=>({}));var r=jM();let i;var a=M(r),o=e=>{xM(e,{get workflowID(){return n().workflowID}})};V(a,e=>{n().workflowID&&e(o)});var s=P(a,2),c=M(s);SM(c,()=>({icon:No,label:`Client`,variant:`workflow-node-endpoint`}));var l=P(c,4);SM(l,()=>({icon:Qa,label:`Auth`,state:n().authNodeClass,sub:n().authNodeSublabel}));var u=P(l,2),d=e=>{var t=DM(),r=N(t);SM(P(r,2),()=>({icon:Qa,label:`Cache`,state:n().cacheNodeClass,badge:n().cacheStatusLabel})),F(()=>U(r,1,Li([`workflow-conn`,n().cacheConnClass]),`svelte-nbptrg`)),z(e,t)};V(u,e=>{n().showCache&&e(d)});var f=P(u,2),p=e=>{var t=OM();SM(P(N(t),2),()=>({icon:Po,label:`Budget`,state:n().budgetNodeClass,badge:n().budgetStatusLabel})),z(e,t)};V(f,e=>{n().showBudget&&e(p)});var m=P(f,2),h=e=>{var t=OM();SM(P(N(t),2),()=>({icon:Eo,label:`Guardrails`,sub:n().guardrailLabel})),z(e,t)};V(m,e=>{n().showGuardrails&&e(h)});var g=P(m,2),_=P(g,2);SM(_,()=>({label:n().aiLabel,variant:`workflow-node-ai`,state:n().aiNodeClass,sub:n().aiSublabel}));var v=P(_,2),y=e=>{var t=DM(),r=N(t);SM(P(r,2),()=>({icon:so,label:`Failover`,state:n().failoverNodeClass,badge:n().failoverStatusLabel,sub:n().failoverTargetLabel})),F(()=>U(r,1,Li([`workflow-conn`,n().failoverConnClass]),`svelte-nbptrg`)),z(e,t)};V(v,e=>{n().showFailover&&e(y)});var b=P(v,2);SM(P(b,2),()=>({icon:Ka,label:`Response`,variant:`workflow-node-endpoint`,state:n().responseNodeClass,sub:n().responseNodeSublabel})),T(s);var x=P(s,2),S=e=>{var t=AM(),r=M(t),i=M(r),a=e=>{SM(e,()=>({icon:Ba,label:`Usage`,variant:`workflow-node-feature workflow-node-async`,state:n().usageNodeClass}))};V(i,e=>{n().showUsage&&e(a)});var o=P(i,2),s=e=>{z(e,kM())};V(o,e=>{n().showUsage&&n().showAudit&&e(s)});var c=P(o,2),l=e=>{SM(e,()=>({icon:$a,label:`Audit Log`,variant:`workflow-node-feature workflow-node-async`,state:n().auditNodeClass}))};V(c,e=>{n().showAudit&&e(l)}),T(r),Ue(4),T(t),z(e,t)};V(x,e=>{n().showAsync&&e(S)}),T(r),F(()=>{i=U(r,1,`workflow-pipeline svelte-nbptrg`,null,i,{"workflow-pipeline-has-meta":n().workflowID}),U(g,1,Li([`workflow-conn`,n().aiConnClass]),`svelte-nbptrg`),U(b,1,Li([`workflow-conn`,n().responseConnClass]),`svelte-nbptrg`)}),z(e,r),D()}function NM(e){let t=Yj(e).length;return t===0?``:t===1?`1 step`:t+` steps`}function PM(e,t){return t&&t.provider?t.provider:Zj(e&&e.scope)||`AI`}function FM(e,t){return t&&t.model?t.model:e&&e.scope&&e.scope.scope_model||null}function IM(e,t){let n=String(e&&e.id||``).trim();if(n&&n!==`draft-workflow-preview`)return n;let r=String(t&&t.workflow_version_id||``).trim();return r&&r!==`draft-workflow-preview`?r:null}function LM(e){let t=e&&e.data&&e.data.workflow_features;return!t||typeof t!=`object`||Array.isArray(t)?null:Gj(t)}function RM(e){let t=e&&e.data&&e.data.failover;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=String(t.target_model||t.targetModel||``).trim()||null;return n?{targetModel:n}:null}function zM(e,t=0){if(t>4||e==null)return``;if(typeof e==`string`){let n=e.trim();if(!n||n[0]!==`{`&&n[0]!==`[`)return``;try{return zM(JSON.parse(n),t+1)}catch{return``}}if(Array.isArray(e)){for(let n of e){let e=zM(n,t+1);if(e)return e}return``}return typeof e==`object`?String(e.code||``).trim()||(e.error===void 0?``:zM(e.error,t+1)):``}function BM(e){let t=e&&e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{};return String(t.error_code||t.errorCode||``).trim()||zM(t.response_body)}function VM(e){let t=String(e||``).trim();if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{provider:t.slice(0,n),model:t.slice(n+1)}}function HM(e,t){let n=String(e&&(e.requested_model||e.model)||``).trim(),r=RM(e);if(!(r&&r.targetModel))return{provider:String(e&&e.provider||``).trim()||null,model:n||null};let i=VM(n);if(i)return i;let a=Zj(t&&t.scope),o=a?String(t&&t.scope&&t.scope.scope_model||``).trim():``;return a||o?{provider:a||null,model:o||n||null}:{provider:null,model:n||null}}function UM(e,t){if(!e)return null;let n=(()=>{let t=String(e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`?t:null})(),r=(()=>{if(e.status_code===void 0||e.status_code===null)return null;let t=String(e.status_code).trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null})(),i=n?!0:e.cache_hit!==void 0&&e.cache_hit!==null&&!!e.cache_hit,a=RM(e),o=HM(e,t),s=Number.isFinite(r)&&r>=200&&r<300,c=String(e.error_type||``).trim().toLowerCase()===`authentication_error`,l=String(e.auth_method||``).trim().toLowerCase()||null,u=BM(e).toLowerCase()===`budget_exceeded`;return{cacheHit:i,cacheType:n||null,failoverTarget:a&&a.targetModel?a.targetModel:null,provider:o.provider,model:o.model,statusCode:r,responseSuccess:s,aiSuccess:s&&!i,authError:c,authMethod:l,budgetExceeded:u}}function WM(e){return!!(e&&e.cacheHit)}function GM(e){return!!(e&&e.failoverTarget)}function KM(e){return!!(e&&e.budgetExceeded)}function qM(e,t){return t?`workflow-node-current`:e&&e.cacheHit?`workflow-node-success`:``}function JM(e){return e&&e.cacheHit?`workflow-conn-hit`:``}function YM(e){return!e||!e.cacheHit?null:e.cacheType===`semantic`?`Hit (Semantic)`:`Hit (Exact)`}function XM(e,t,n,r){return e?KM(t)?`workflow-node-error`:r?`workflow-node-current`:n?`workflow-node-success`:``:``}function ZM(e){return KM(e)?`Exceeded`:null}function QM(e){return e&&e.cacheHit?`workflow-node-skipped`:e&&e.failoverTarget?`workflow-node-success`:``}function $M(e){return e&&e.cacheHit?`workflow-conn-dim`:e&&e.failoverTarget?`workflow-conn-hit`:``}function eN(e){return e&&e.failoverTarget?`Redirected`:null}function tN(e){return e&&e.failoverTarget?e.failoverTarget:null}function nN(e){return e&&e.cacheHit?`workflow-conn-dim`:``}function rN(e,t){return e?e.cacheHit?`workflow-node-skipped`:t?`workflow-node-current`:e.aiSuccess?`workflow-node-success`:``:``}function iN(e,t){if(!e)return``;let n=e.statusCode;return!Number.isFinite(n)&&t?`workflow-node-current`:Number.isFinite(n)?n>=500?`workflow-node-error`:n>=400?`workflow-node-warning`:n>=300?`workflow-node-neutral`:n>=200?`workflow-node-success`:``:``}function aN(e){return!e||!Number.isFinite(e.statusCode)?null:String(e.statusCode)}function oN(e,t){return e?e.authError?`workflow-node-error`:t?`workflow-node-current`:e.authMethod===`api_key`||e.authMethod===`master_key`?`workflow-node-success`:``:``}function sN(e){return!e||!e.authMethod?null:e.authMethod}function cN(e,t,n){return e?n?`workflow-node-current`:t?`workflow-node-success`:``:``}function lN(e,t){if(!e||!e._live)return!!t;let n=String(e._live_state||``).trim();return!!e._audit_flushed||n===`audit.flushed`||n===`audit.detail`}function uN(e,t){if(!e)return!!t;let n=e.usage||{},r=Number(n.entries||0)>0;if(!e._live)return r;let i=String(e._usage_live_state||``).trim();return e._usage_flushed||i===`usage.flushed`?!0:!e._usage_live_pending&&r&&!e._live_pending}function dN(e){return!!(e&&e._live&&e._usage_live_pending&&!e._usage_flushed)}function fN(e,t){return!e||!e._live||lN(e,!1)?!1:String(e._live_state||``).trim()===`audit.completed`||!!(t&&Number.isFinite(t.statusCode))}function pN(e,t,n){return!e||!e._live?``:dN(e)?`usage`:fN(e,t)?`audit`:lN(e,!1)&&!e._live_pending?``:t&&t.cacheHit?`cache`:t&&(t.provider||t.model)?`ai`:n&&n.budget&&(e.workflow_version_id||e.requested_model)?`budget`:t&&t.authMethod?``:`auth`}function mN(e,t,n,r){let i=n||{},a=i.features&&typeof i.features==`object`&&!Array.isArray(i.features)?Gj(i.features):qj(e,r),o=!!i.forceAudit,s=!!i.highlightAsyncPresent,c=!!a.budget||KM(t),l=!!a.guardrails,u=!!a.usage,d=o||!!a.audit,f=!!i.forceAsync||!!(u||d),p=!!a.failover||GM(t),m=IM(e,i.entry),h=pN(i.entry,t,a),g=dN(i.entry),_=fN(i.entry,t),v=lN(i.entry,s),y=uN(i.entry,s);return{showBudget:c,budgetNodeClass:XM(c,t,s,h===`budget`),budgetStatusLabel:ZM(t),showGuardrails:l,guardrailLabel:l?NM(e):``,showCache:!!i.forceCache||!!a.cache||WM(t),cacheNodeClass:qM(t,h===`cache`),cacheConnClass:JM(t),cacheStatusLabel:YM(t),showFailover:p,failoverNodeClass:p?QM(t):``,failoverConnClass:p?$M(t):``,failoverStatusLabel:p?eN(t):null,failoverTargetLabel:p?tN(t):null,aiLabel:PM(e,t),aiSublabel:FM(e,t),aiConnClass:nN(t),aiNodeClass:rN(t,h===`ai`),responseConnClass:nN(t),responseNodeClass:iN(t,h===`response`),responseNodeSublabel:aN(t),authNodeClass:oN(t,h===`auth`),authNodeSublabel:sN(t),usageNodeClass:cN(u,y,g),auditNodeClass:cN(d,v,_),showAsync:f,showUsage:u,showAudit:d,workflowID:m}}function hN(e,t){return mN(e,null,{forceCache:!1},t)}function gN(e,t,n){return mN(t,UM(e,t),{entry:e,features:LM(e)||(t?qj(t,n):{cache:!1,audit:!1,usage:!1,budget:!1,guardrails:!1,failover:!1}),forceAudit:!0,forceAsync:!0,highlightAsyncPresent:!0},n)}var _N=R(`

                    `),vN=R(`

                    `),yN=R(`
                    `),bN=R(`
                    `),xN=R(`

                    No guardrails configured for this workflow.

                    `),SN=R(`

                    Guardrails

                    `),CN=R(``),wN=R(`

                    `);function TN(e,t){E(t,!0);let n=G(t,`preview`,3,!1),r=O(()=>_M.featureCaps()),i=O(()=>rM(t.workflow)),a=O(()=>Xj(t.workflow,I(r))),o=O(()=>hN(t.workflow,I(r))),s=O(()=>n()?`draft-workflow-preview-guardrail-`:t.workflow.id+`-guardrail-`);var c=wN();let l;var u=M(c),d=M(u),f=M(d),p=M(f,!0);T(f);var m=P(f,2),h=M(m,!0);T(m),T(d);var g=P(d,2),_=M(g),v=M(_,!0);T(_),T(g),T(u);var y=P(u,2),b=e=>{var n=_N(),r=M(n,!0);T(n),F(()=>B(r,t.workflow.description)),z(e,n)};V(y,e=>{t.workflow.description&&e(b)});var x=P(y,2),S=e=>{var n=vN(),i=M(n);T(n),F(e=>B(i,`Failover: ${e??``}`),[()=>Jj(t.workflow,I(r))]),z(e,n)},C=O(()=>_M.failoverVisible());V(x,e=>{I(C)&&e(S)});var w=P(x,2);MM(w,{get chart(){return I(o)}});var ee=P(w,2),te=e=>{var t=SN(),n=M(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var o=P(n,2),c=e=>{var t=bN();H(t,23,()=>I(a),(e,t)=>I(s)+t,(e,t)=>{var n=yN(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a);T(a),T(n),F(()=>{B(i,I(t).ref),B(o,`step ${I(t).step??``}`)}),z(e,n)}),T(t),z(e,t)},l=e=>{z(e,xN())};V(o,e=>{I(a).length>0?e(c):e(l,-1)}),T(t),F(()=>B(i,I(a).length?I(a).length+` steps`:`None`)),z(e,t)},ne=O(()=>Cs.guardrailsVisible());V(ee,e=>{I(ne)&&e(te)});var re=P(ee,2),ie=e=>{var n=CN(),r=M(n),a=M(r),o=M(a,!0);T(a);var s=P(a,2);{let e=O(()=>`Edit workflow `+I(i));vT(s,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>_M.openCreate(t.workflow),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(r);var c=P(r,2),l=M(c),u=M(l);T(l);var d=P(l,2),f=M(d);T(d);var p=P(d,2),m=M(p);T(p),T(c),T(n),F((e,n,r,s)=>{a.disabled=e,W(a,`aria-label`,`Deactivate workflow `+I(i)),W(a,`title`,n),B(o,_M.deactivatingID===t.workflow.id?`Deactivating...`:`Deactivate`),B(u,`version: v${t.workflow.version??``}`),B(f,`created: ${r??``}`),B(m,`hash: ${s??``}`)},[()=>_M.deactivatingID===t.workflow.id||!dM(t.workflow),()=>dM(t.workflow)?`Deactivate active workflow`:`The global workflow cannot be deactivated.`,()=>fs.formatTimestamp(t.workflow.created_at),()=>fM(t.workflow.workflow_hash)]),L(`click`,a,()=>_M.deactivate(t.workflow)),z(e,n)};V(re,e=>{n()||e(ie)}),T(c),F((e,t)=>{l=U(c,1,`workflow-card svelte-1fo9fvq`,null,l,{"workflow-preview-card":n()}),B(p,e),B(h,I(i)),B(v,t)},[()=>tM(t.workflow),()=>nM(t.workflow)]),z(e,c),D()}Hr([`click`]);var EN=R(`

                    `),DN=R(``),ON=R(``),kN=R(``),AN=R(``),jN=R(``),MN=R(``),NN=R(``),PN=R(``),FN=R(``),IN=R(``),LN=R(``),RN=R(``),zN=R(`
                    No named guardrails are currently registered on this deployment. You can still draft a workflow, but guardrail-backed creation may be rejected.
                    `),BN=R(`
                    `),VN=R(`
                    `),HN=R(`

                    No guardrail steps configured yet.

                    `),UN=R(`

                    Guardrail Steps

                    Guardrails in the same numeric step run together. Later steps wait for earlier ones to finish.

                    `),WN=R(`

                    Leave provider name empty to target all providers and models. Select a provider name without a model to target all models for that configured provider.

                    Add a path to scope the workflow to that subtree. Leading slashes are optional and will be normalized; you can enter "team/alpha" or "/team/alpha". Matching checks the deepest user path first, then falls back toward the root.

                    If you leave the name empty, the workflow will display as the matched provider/model scope or “All models”.

                    Preview

                    Live
                    `,1);function GN(e,t){E(t,!0);{let t=e=>{JS(e,{copyId:`workflow-help-copy`,label:`workflow help`,text:`Create immutable version. Submitting activates it for the selected scope.`,title:e=>{var t=EN(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>_M.submitMode()===`save`?`Edit Workflow`:`Create Workflow`]),z(e,t)},$$slots:{title:!0}})},n=O(()=>_M.submitLabel()),r=O(()=>_M.submittingLabel()),i=O(()=>_M.submitMode()===`create`?mo:vo);SE(e,{get open(){return _M.formOpen},ariaLabel:`Workflow editor`,get error(){return _M.formError},get submitting(){return _M.submitting},get submitLabel(){return I(n)},get submittingLabel(){return I(r)},get submitIcon(){return I(i)},dialogClass:`workflow-editor`,onclose:()=>_M.closeForm(),onsubmit:()=>_M.submitForm(),header:t,children:(e,t)=>{var n=WN(),r=N(n),i=M(r);wE(i,{id:`workflow-scope-provider`,label:`Provider Name`,children:(e,t)=>{var n=ON(),r=M(n);r.value=r.__value=``,H(P(r),16,()=>_M.providerOptions(),e=>e,(e,t)=>{var n=DN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(n),L(`change`,n,e=>_M.setProvider(e.currentTarget.value)),qi(n,()=>_M.form.scope_provider,e=>_M.form.scope_provider=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2),o=e=>{wE(e,{id:`workflow-scope-model`,label:`Model`,children:(e,t)=>{var n=kN(),r=M(n);r.value=r.__value=``,H(P(r),17,()=>_M.modelOptions(_M.form.scope_provider),e=>_M.form.scope_provider+`-`+e,(e,t)=>{var n=DN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t)),i!==(i=I(t))&&(n.value=(n.__value=I(t))??``)}),z(e,n)}),T(n),qi(n,()=>_M.form.scope_model,e=>_M.form.scope_model=e),z(e,n)},$$slots:{default:!0}})};V(a,e=>{_M.form.scope_provider&&e(o)});var s=P(a,2);wE(s,{id:`workflow-name`,label:`Name`,children:(e,t)=>{var n=AN();ia(n),pa(n,()=>_M.form.name,e=>_M.form.name=e),z(e,n)},$$slots:{default:!0}}),wE(P(s,2),{id:`workflow-user-path`,label:`User Path`,children:(e,t)=>{var n=jN();ia(n),pa(n,()=>_M.form.scope_user_path,e=>_M.form.scope_user_path=e),z(e,n)},$$slots:{default:!0}}),T(r);var c=P(r,8);wE(c,{id:`workflow-description`,label:`Description`,children:(e,t)=>{var n=MN();ft(n),pa(n,()=>_M.form.description,e=>_M.form.description=e),z(e,n)},$$slots:{default:!0}});var l=P(c,2),u=M(l),d=e=>{var t=NN(),n=M(t);ia(n),Ue(2),T(t),ma(n,()=>_M.form.features.cache,e=>_M.form.features.cache=e),z(e,t)},f=O(()=>Cs.cacheVisible());V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var t=PN(),n=M(t);ia(n),Ue(2),T(t),ma(n,()=>_M.form.features.audit,e=>_M.form.features.audit=e),z(e,t)},h=O(()=>Cs.auditVisible());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=e=>{var t=FN(),n=M(t);ia(n),Ue(2),T(t),ma(n,()=>_M.form.features.usage,e=>_M.form.features.usage=e),z(e,t)},v=O(()=>Cs.usageVisible());V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=IN(),n=M(t);ia(n),Ue(2),T(t),ma(n,()=>_M.form.features.budget,e=>_M.form.features.budget=e),z(e,t)},x=O(()=>Cs.budgetsVisible());V(y,e=>{I(x)&&e(b)});var S=P(y,2),C=e=>{var t=LN(),n=M(t);ia(n),Ue(2),T(t),ma(n,()=>_M.form.features.guardrails,e=>_M.form.features.guardrails=e),z(e,t)},w=O(()=>Cs.guardrailsVisible());V(S,e=>{I(w)&&e(C)});var ee=P(S,2),te=e=>{var t=RN(),n=M(t);ia(n),Ue(2),T(t),ma(n,()=>_M.form.features.failover,e=>_M.form.features.failover=e),z(e,t)},ne=O(()=>_M.failoverVisible());V(ee,e=>{I(ne)&&e(te)}),T(l);var re=P(l,2),ie=P(M(re),2);{let e=O(()=>_M.preview());TN(ie,{get workflow(){return I(e)},preview:!0})}T(re);var ae=P(re,2),oe=e=>{var t=UN(),n=M(t),r=P(M(n),2);T(n);var i=P(n,2),a=e=>{var t=zN(),n=P(M(t),2);T(t),L(`click`,n,()=>Yo.navigate(`guardrails`)),z(e,t)};V(i,e=>{_M.guardrailRefs.length===0&&e(a)});var o=P(i,2),s=e=>{var t=VN();H(t,21,()=>_M.form.guardrails,ci,(e,t,n)=>{var r=BN(),i=M(r),a=M(i);W(a,`for`,`workflow-guardrail-ref-`+n);var o=P(a,2);ia(o),W(o,`id`,`workflow-guardrail-ref-`+n),W(o,`aria-label`,`Guardrail reference `+(n+1)),T(i);var s=P(i,2),c=M(s);W(c,`for`,`workflow-guardrail-step-`+n);var l=P(c,2);ia(l),W(l,`id`,`workflow-guardrail-step-`+n),W(l,`aria-label`,`Guardrail step `+(n+1)),T(s);var u=P(s,2);T(r),pa(o,()=>I(t).ref,e=>I(t).ref=e),pa(l,()=>I(t).step,e=>I(t).step=e),L(`click`,u,()=>_M.removeGuardrailStep(n)),z(e,r)}),T(t),z(e,t)},c=e=>{z(e,HN())};V(o,e=>{_M.form.guardrails.length>0?e(s):e(c,-1)}),T(t),L(`click`,r,()=>_M.addGuardrailStep()),z(e,t)},se=O(()=>_M.form.features.guardrails&&Cs.guardrailsVisible());V(ae,e=>{I(se)&&e(oe)}),z(e,n)},$$slots:{header:!0,default:!0}})}D()}Hr([`change`,`click`]);var KN=R(`

                    Loading workflows...

                    `),qN=R(`
                    `),JN=R(`

                    No active workflows found.

                    `),YN=R(`

                    No workflows match your filter.

                    `),XN=R(`
                    `);function ZN(e,t){E(t,!0);var n=XN(),r=M(n),i=e=>{var t=KN();CS(M(t),{size:16,label:`Loading workflows`}),Ue(),T(t),z(e,t)};V(r,e=>{_M.loading&&!q.authError&&e(i)});var a=P(r,2),o=e=>{var t=qN();H(t,21,()=>_M.filteredWorkflows,e=>e.id,(e,t)=>{TN(e,{get workflow(){return I(t)}})}),T(t),z(e,t)};V(a,e=>{_M.filteredWorkflows.length>0&&e(o)});var s=P(a,2),c=e=>{z(e,JN())};V(s,e=>{_M.workflows.length===0&&!_M.loading&&!q.authError&&_M.available&&e(c)});var l=P(s,2),u=e=>{z(e,YN())};V(l,e=>{_M.workflows.length>0&&_M.filteredWorkflows.length===0&&!_M.loading&&e(u)}),T(n),z(e,n),D()}var QN=R(``),$N=R(`
                    Workflows feature is unavailable.
                    `),eP=R(`
                    `),tP=R(`
                    `),nP=R(``),rP=R(`
                    `);function iP(e,t){E(t,!0),An(()=>{q.refreshTick,_M.fetchPage()});var n=rP(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=QN();K(M(t),{get icon(){return mo},class:`form-action-icon`,"aria-hidden":`true`}),Ue(2),T(t),L(`click`,t,()=>_M.openCreate()),z(e,t)};V(a,e=>{_M.available&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,$N())};V(s,e=>{!_M.available&&!q.authError&&e(c)});var l=P(s,2),u=e=>{var t=eP(),n=M(t,!0);T(t),F(()=>B(n,_M.error)),z(e,t)};V(l,e=>{_M.error&&!q.authError&&e(u)});var d=P(l,2),f=e=>{var t=tP(),n=M(t);xw(M(n),{placeholder:`Filter by scope, name, hash, or guardrail...`,label:`Filter workflows by scope, name, hash, or guardrail`,get value(){return _M.filter},set value(e){_M.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i,!0);T(i),T(r),T(t),F(()=>B(a,_M.filteredWorkflows.length+` active scopes`)),z(e,t)};V(d,e=>{_M.available&&e(f)});var p=P(d,2);GN(p,{});var m=P(p,2);ZN(m,{});var h=P(m,2);H(h,20,()=>_M.guardrailRefs,e=>e,(e,t)=>{var n=nP(),r={};F(()=>{r!==(r=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(h),T(n),z(e,n),D()}Hr([`click`]);function aP(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=Zs}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=oP(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function oP(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}var sP=null;function cP(){return sP===null&&(sP=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`)),!!(sP&&sP.matches)}function lP(e){return cP()?0:e}function uP(e,t){return!t||!t.live?{duration:0}:Ys(e,{duration:lP(150)})}var dP=new class{#e=k(j({}));get workflowVersionsByID(){return I(this.#e)}set workflowVersionsByID(e){A(this.#e,e,!0)}workflowVersionRequests={};workflowFeatureCaps(){return{cache:Cs.cacheVisible(),audit:Cs.auditVisible(),usage:Cs.usageVisible(),budget:Cs.budgetsVisible(),guardrails:Cs.guardrailsVisible(),failover:Cs.booleanFlag(`FAILOVER_ENABLED`,!0)}}cacheWorkflowVersion(e){let t=String(e&&e.id||``).trim();return t?(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:e},e):null}cacheMissingWorkflowVersion(e){let t=String(e||``).trim();t&&(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:null})}workflowVersionCacheHas(e){return Object.prototype.hasOwnProperty.call(this.workflowVersionsByID||{},String(e||``).trim())}workflowVersionByID(e){let t=String(e||``).trim();return t&&this.workflowVersionCacheHas(t)?this.workflowVersionsByID[t]:null}async fetchWorkflowVersion(e){let t=String(e||``).trim();if(!t)return null;if(this.workflowVersionCacheHas(t))return this.workflowVersionsByID[t];if(this.workflowVersionRequests[t])return this.workflowVersionRequests[t];let n=(async()=>{let e=typeof AbortController==`function`?new AbortController:null,n=e?setTimeout(()=>e.abort(),1e4):null;try{let n=await vs(`/admin/workflows/`+encodeURIComponent(t),{label:`workflow`,signal:e?e.signal:void 0});if(n.stale)return null;if(n.status===404)return this.cacheMissingWorkflowVersion(t),null;if(!n.ok)return null;let r=n.data;return!r||typeof r!=`object`||Array.isArray(r)?(this.cacheMissingWorkflowVersion(t),null):this.cacheWorkflowVersion(r)}catch(e){return e&&e.name===`AbortError`||console.error(`Failed to fetch workflow version:`,e),null}finally{n!==null&&clearTimeout(n),delete this.workflowVersionRequests[t]}})();return this.workflowVersionRequests[t]=n,n}async prefetchAuditWorkflows(e){let t=[...new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.workflow_version_id||``).trim()).filter(Boolean))];t.length!==0&&await Promise.all(t.map(e=>this.fetchWorkflowVersion(e)))}auditEntryWorkflow(e){let t=String(e&&e.workflow_version_id||``).trim();return t?this.workflowVersionByID(t):null}},fP=6;function pP(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}function mP(e,t=0,n=null){let r=String(e||``).trim();if(!r)return``;if(t>fP)return r;let i=pP(r);return i==null?r:hP(i,t+1,n)||n&&n(i)||r}function hP(e,t=0,n=null,r=null){if(e==null||t>fP)return``;if(typeof e==`string`){let i=pP(e.trim());return i==null?``:hP(i,t+1,n,r)}if(typeof e!=`object`)return``;let i=r||new Set;if(i.has(e))return``;if(i.add(e),Array.isArray(e)){for(let r=0;r=400||vP(t&&t.response_body)}function bP(e){let t=e&&e.data?e.data:null;return t?gP(t.error_message)||(yP(e,t)?hP(t.response_body,0):``):``}function xP(e){if(e==null||String(e).trim()===``)return null;let t=Number(e);return!Number.isInteger(t)||t<0?null:t}function SP(e){let t=xP(e);return t===null?``:t===0?`Audit logs are retained indefinitely.`:t===1?`Audit logs are retained for 1 day.`:`Audit logs are retained for `+t+` days.`}function CP(e){let t=xP(e);return t===null?``:t===0?`Audit logs are retained `:`Audit logs are retained for `}function wP(e){let t=xP(e);return t===null?``:t===0?`indefinitely`:t===1?`1 day`:t+` days`}function TP({dateQuery:e,limit:t,offset:n,search:r,method:i,statusCode:a,stream:o}){let s=e;return s+=`&limit=`+t+`&offset=`+n,r&&(s+=`&search=`+encodeURIComponent(r)),i&&(s+=`&method=`+encodeURIComponent(i)),a&&(s+=`&status_code=`+encodeURIComponent(a)),o&&(s+=`&stream=`+encodeURIComponent(o)),s}function EP({sessionId:e,limit:t}){return`session_id=`+encodeURIComponent(e)+`&limit=`+(t||100)+`&offset=0`}function DP(e){return String(e&&e.session_id||``).trim()}function OP(e){let t=Number(e&&e.session_count);return Number.isFinite(t)&&t>1?t:1}function kP(e){return!!DP(e)&&OP(e)>1}function AP(e){return{entries:(Array.isArray(e&&e.sessions)?e.sessions:[]).filter(e=>e&&e.latest).map(e=>({...e.latest,session_id:DP(e.latest)||String(e.session_id||``).trim(),session_count:Number(e.count||1)})),total:Number(e&&e.total||0),limit:Number(e&&e.limit||25),offset:Number(e&&e.offset||0)}}function jP(e,t,n){let r=new Set((Array.isArray(n)?n:[]).flatMap(e=>FP(e))),i=(Array.isArray(t)?t:[]).filter(e=>!FP(e).some(e=>r.has(e))),a=new Set([...r,...i.flatMap(e=>FP(e))]),o=(e&&Array.isArray(e.entries)?e.entries:[]).filter(e=>e&&e._live&&!FP(e).some(e=>a.has(e)));return{entries:[...o,...i],preservedCount:o.length}}function MP(e,t){let n=e||{};if(!t)return n;if(n[t]){let e={...n};return delete e[t],e}return{...n,[t]:!0}}function NP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>DP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=n[e];return}a=!0}),a?i:n}function PP(e){return String(e&&e.id||``).trim()}function FP(e){if(!e)return[];let t=[],n=String(e.id||``).trim(),r=String(e.request_id||``).trim();return n&&t.push(`id:`+n),r&&t.push(`request:`+r),t}function IP(e){return!!(e&&e._live&&e._live_pending&&!e._audit_flushed)}function LP(e){let t=e&&e.customStartDate,n=e&&e.customEndDate;if(!t&&!n)return!0;let r=new Date;if(t){let e=new Date(t);if(e.setHours(0,0,0,0),Number.isFinite(e.getTime())&&re)return!1}return!0}function RP(e,t){return e&&Number(e.offset||0)===0&&!(t&&t.search)&&!(t&&t.method)&&!(t&&t.statusCode)&&!(t&&t.stream)&&LP(t)}function zP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!RP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>IP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>FP(e))),s=[];return a.forEach(e=>{let t=FP(e);t.length!==0&&(t.some(e=>o.has(e))||(t.forEach(e=>o.add(e)),s.push(e)))}),s.length===0?r:(r.entries=[...s,...i].slice(0,r.limit||25),r.total=Number(r.total||0)+s.length,r)}function BP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!RP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>IP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>FP(e))),s=new Map;i.forEach((e,t)=>{let n=DP(e);n&&!s.has(n)&&s.set(n,t)});let c=[],l=i;return a.forEach(e=>{let t=FP(e);if(t.length===0||t.some(e=>o.has(e)))return;let n=DP(e);if(n&&s.has(n)){let r=s.get(n);l===i&&(l=[...i]),l[r]={...e,session_count:Math.max(OP(l[r]),OP(e))},t.forEach(e=>o.add(e));return}t.forEach(e=>o.add(e)),c.push(e)}),r.entries=[...c,...l].slice(0,r.limit||25),r.total=Number(r.total||0)+c.length,r}function VP(e,t){let n=PP(t),r=e||{};return n?r[n]?{}:{[n]:!0}:r}function HP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>PP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=!0;return}a=!0}),a?i:n}function UP(e){if(e==null)return`-`;let t=Number(e);return Number.isFinite(t)?t<=0?`pending`:t<1e6?Math.round(t/1e3)+` µs`:t<1e9?(t/1e6).toFixed(2)+` ms`:(t/1e9).toFixed(2)+` s`:`-`}function WP(e){if(e==null||e===``)return`status-unknown`;let t=Number(e);return Number.isFinite(t)?t>=500?`status-error`:t>=400?`status-warning`:t>=300?`status-neutral`:`status-success`:`status-unknown`}function GP(e){if(!e||!e._live||!e._live_pending)return!1;let t=String(e._live_state||``).trim();if(t===`audit.completed`||t===`audit.flushed`||t===`audit.detail`)return!1;if(e._response_partial)return!0;if(e.status_code!==null&&e.status_code!==void 0&&e.status_code!==``||Number(e.duration_ns||0)>0||e.error_type||e.error_message)return!1;let n=e.data||{};return!(n.response_headers||n.response_body||n.error_message)}function KP(e){let t=e&&e.data&&e.data.failover;return!t||typeof t!=`object`||Array.isArray(t)?null:String(t.target_model||t.targetModel||``).trim()||null}function qP(e){return(e&&e.data&&Array.isArray(e.data.attempts)?e.data.attempts:[]).map((e,t)=>({...e,seq:Number(e&&e.seq||t+1)})).sort((e,t)=>e.seq-t.seq)}function JP(e){let t=qP(e);return t.length>1||t.some(e=>!(e&&e.success))}function YP(e){if(!e)return`-`;let t=e.status_code||e.status;return t?String(t):e.success?`ok`:`error`}function XP(e){return String(e&&e.kind||``).trim()||`attempt`}function ZP(e){if(!e)return`-`;let t=String(e.provider_name||``).trim(),n=String(e.provider_type||e.provider||``).trim();return t&&n&&t!==n?t+` (`+n+`)`:t||n||`-`}function QP(e){return String(e&&e.model||``).trim()||`-`}function $P(e){let t=qP(e);return t.length>1||t.some(e=>!(e&&e.success))?t:[]}function eF(e){return qP(e).length+`×`}function tF(e){let t=qP(e),n=t.filter(e=>!(e&&e.success)).length,r=t.length===1?`attempt`:`attempts`,i=t.length+` provider `+r;return n>0?i+` · `+n+` failed`:i}function nF(e){if(!e)return``;let t=[`#`+Number(e.seq||0)],n=XP(e);n&&n!==`attempt`&&t.push(n),t.push(YP(e));let r=ZP(e);r&&r!==`-`&&t.push(r);let i=QP(e);return i&&i!==`-`&&t.push(i),t.push(e.success?`succeeded`:`failed`),t.join(` · `)}function rF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t&&t.response_body!=null?t.response_body:null}return t.response_body!=null&&t.response_body!==``?t.response_body:null}function iF(e){if(!e||e.success)return``;let t=String(e.error_message||``).trim(),n=String(e.error_code||``).trim(),r=String(e.error_type||``).trim();return t&&n?n+`: `+t:t||n||r||`Provider attempt failed`}function aF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t?t.response_headers:null}return t.response_headers||null}function oF(e){let t=Number(e&&e.status_code);return Number.isFinite(t)&&t>0?t:null}function sF(e,t){let n=!!(t&&t.success),r=e&&e.data?e.data:null,i=rF(e,t),a=aF(e,t),o=iF(t),s=i!=null&&i!==``,c=XP(t),l=qP(e).length<=1;return{title:`Response`,direction:`response`,seq:l?0:Number(t&&t.seq||0),kind:l||c===`attempt`?``:c,statusCode:l?null:oF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:i,showErrorMessage:!!o,errorMessage:o,showHeaders:!!a,headers:a,showBody:s,body:i,showEmpty:!o&&!s&&!a,emptyMessage:`No response was captured for this attempt.`,showTooLarge:!!(n&&r&&r.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function cF(e){return e&&e.data&&Array.isArray(e.data.request_revisions)?e.data.request_revisions:[]}function lF(e){return cF(e).filter(e=>!(e&&e.no_change))}function uF(e){return cF(e).filter(e=>e&&e.no_change).map(e=>{let t=String(e.rewriter||`rewriter`);return{id:`step-`+Number(e.seq||0),rewriter:t,label:t+`: no change`,title:t+` ran and forwarded the request unchanged`}})}function dF(e){let t=Number(e&&e.bytes_before),n=Number(e&&e.bytes_after);if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n>=t)return``;let r=(1-n/t)*100;return`-`+(r>=10?String(Math.round(r)):r.toFixed(1))+`%`}function fF(e,t){let n=t&&t.body,r=n!=null&&n!==``,i=lF(e).length<=1,a={rewriter:t&&t.rewriter||``,bytes:Number(t&&t.bytes_before||0)+` → `+Number(t&&t.bytes_after||0)};return t&&t.detail!=null&&(a.detail=t.detail),{title:`Rewritten`,direction:`request`,seq:i?0:Number(t&&t.seq||0),kind:t&&t.rewriter?String(t.rewriter):``,savingsLabel:dF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:n,showErrorMessage:!1,errorMessage:null,showHeaders:!0,headers:a,headersTitle:`What changed`,showBody:r,body:n,showEmpty:!1,emptyMessage:``,showTooLarge:!r,tooLargeMessage:`Rewritten body not captured (body logging disabled or body too large).`}}function pF(e){let t=e&&e.usage;return!t||typeof t!=`object`?null:t}function mF(e){let t=pF(e);return Number(t&&t.cached_input_tokens||0)>0}function hF(e){let t=pF(e),n=Number(t&&t.input_tokens||0),r=Number(t&&t.cached_input_tokens||0);return!Number.isFinite(n)||n<=0||!Number.isFinite(r)||r<=0?0:Math.max(0,Math.min(100,r/n*100))}function gF(e){let t=pF(e);if(!t)return``;let n=Number(t.input_tokens||0),r=Number(t.cached_input_tokens||0);return n<=0?sc(r)+` cached`:hF(e).toFixed(1)+`% cached`}function _F(e){return mF(e)?gF(e):``}function vF(e,t){let n=pF(e);if(!n||!e||!e.data||!e.data.request_body)return null;let r=Number(n.estimated_cached_characters||0);if(!Number.isFinite(r)||r<=0||typeof t!=`function`)return null;let i=t(e.data.request_body);return!Array.isArray(i)||i.length===0?null:{characters:r,segments:i}}function yF(e,t){let n=e&&e.data?e.data:null,r=!n||!n.request_headers&&!n.request_body,i=r&&GP(e);return{title:`Request`,direction:`request`,layout:`split`,entry:e,copyHeaders:n&&n.request_headers,copyBody:n&&n.request_body,showErrorMessage:!1,errorMessage:null,showHeaders:!!(n&&n.request_headers),headers:n&&n.request_headers,showBody:!!(n&&n.request_body),body:n&&n.request_body,bodyCacheRatioLabel:_F(e),promptCacheHighlight:vF(e,t),noChangeSteps:uF(e),showEmpty:r&&!i,emptyMessage:`Request details were not captured.`,showPending:i,pendingMessage:`Waiting for request data…`,showTooLarge:!!(n&&n.request_body_too_big_to_handle),tooLargeMessage:`Request body was too large to capture.`}}function bF(e){let t=e&&e.data?e.data:null,n=bP(e),r=!t||!n&&!t.response_headers&&!t.response_body,i=r&&GP(e);return{title:`Response`,direction:`response`,layout:`split`,entry:e,copyHeaders:t&&t.response_headers,copyBody:t&&t.response_body,showErrorMessage:!!n,errorMessage:n,showHeaders:!!(t&&t.response_headers),headers:t&&t.response_headers,showBody:!!(t&&t.response_body),body:t&&t.response_body,streaming:!!(e&&e._response_partial&&t&&t.response_body)&&GP(e),showEmpty:r&&!i,emptyMessage:`Response details were not captured.`,showPending:i,pendingMessage:`Response in progress…`,showTooLarge:!!(t&&t.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function xF(e,t){let n=[{id:`request`,pane:yF(e,t)}];return lF(e).forEach(t=>{n.push({id:`revision-`+Number(t&&t.seq||0),pane:fF(e,t)})}),JP(e)?qP(e).forEach(t=>{n.push({id:`response-`+Number(t&&t.seq||0),pane:sF(e,t)})}):n.push({id:`response`,pane:bF(e)}),n}function SF(e){if(!JP(e))return`response`;let t=qP(e),n=null;return t.forEach(e=>{e&&e.success&&(n=e)}),n||=t[t.length-1],n?`response-`+Number(n.seq||0):`request`}function CF(e,t,n){return e&&(Array.isArray(n)?n:xF(t)).some(t=>t.id===e)?e:SF(t)}function wF(e,t,n){if(!t||!t.length)return null;let r=t.indexOf(n);r<0&&(r=0);let i;switch(e){case`ArrowRight`:case`ArrowDown`:i=(r+1)%t.length;break;case`ArrowLeft`:case`ArrowUp`:i=(r-1+t.length)%t.length;break;case`Home`:i=0;break;case`End`:i=t.length-1;break;default:return null}return t[i]}var TF=100;function EF(){return{entries:[],total:0,limit:25,offset:0}}var DF=new class{#e=k(j({}));get auditExpandedEntries(){return I(this.#e)}set auditExpandedEntries(e){A(this.#e,e,!0)}#t=k(j({}));get auditExpandedThreads(){return I(this.#t)}set auditExpandedThreads(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}auditFetchToken=0;get auditLog(){return NC.auditLog}set auditLog(e){NC.auditLog=e}get auditSearch(){return NC.auditSearch}set auditSearch(e){NC.auditSearch=e}get auditMethod(){return NC.auditMethod}set auditMethod(e){NC.auditMethod=e}get auditStatusCode(){return NC.auditStatusCode}set auditStatusCode(e){NC.auditStatusCode=e}get auditStream(){return NC.auditStream}set auditStream(e){NC.auditStream=e}get auditGroupSessions(){return NC.auditGroupSessions}liveFilters(){return{search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream,customStartDate:Nc.customStartDate,customEndDate:Nc.customEndDate}}toggleAuditGroupSessions(){NC.auditGroupSessions=!NC.auditGroupSessions,Da(`gomodel_audit_group_sessions`,NC.auditGroupSessions),this.auditExpandedThreads={},NC.auditThreadChildren={},this.fetchAuditLog(!0)}async fetchAuditLog(e){let t=++this.auditFetchToken;this.loading=!0;try{e&&(this.auditLog.offset=0);let n=this.auditGroupSessions,r=TP({dateQuery:Nc.queryStr(),limit:this.auditLog.limit,offset:this.auditLog.offset,search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream}),i=await vs((n?`/admin/audit/sessions?`:`/admin/audit/log?`)+r,{label:`audit log`});if(i.stale||t!==this.auditFetchToken)return;if(!i.ok){this.auditLog=EF();return}let a=n?AP(i.data):i.data,o=(n?BP:zP)(a,this.auditLog&&this.auditLog.entries,this.liveFilters());Array.isArray(o.entries)||(o.entries=[]),o.entries=NC.upsertAuditRecords(o.entries,`audit.list`),this.auditLog=o,this.auditExpandedThreads=NP(this.auditExpandedThreads,o.entries),NC.auditThreadChildren=NP(NC.auditThreadChildren,o.entries);let s=[...o.entries,...this.loadedThreadChildren()];this.auditExpandedEntries=HP(this.auditExpandedEntries,s);try{await dP.prefetchAuditWorkflows(s)}catch(e){console.error(`Failed to prefetch audit workflows:`,e)}}catch(e){if(console.error(`Failed to fetch audit log:`,e),t!==this.auditFetchToken)return;this.auditLog=EF()}finally{t===this.auditFetchToken&&(this.loading=!1)}}loadedThreadChildren(){let e=NC.auditThreadChildren||{};return Object.keys(e).flatMap(t=>Array.isArray(e[t]&&e[t].entries)?e[t].entries:[])}isThreadExpanded(e){return!!(e&&this.auditExpandedThreads[e])}threadChildren(e){return e&&NC.auditThreadChildren[e]||null}async toggleThread(e){let t=DP(e);if(!t)return;let n=!this.isThreadExpanded(t);this.auditExpandedThreads=MP(this.auditExpandedThreads,t);let r=NC.auditThreadChildren[t];n&&!(r&&(r.loaded||r.loading))&&await this.fetchThreadEntries(e)}async fetchThreadEntries(e){let t=DP(e);if(!t)return;let n=NC.auditThreadChildren[t];NC.auditThreadChildren={...NC.auditThreadChildren,[t]:{loading:!0,loaded:!1,entries:n&&Array.isArray(n.entries)?n.entries:[],total:Number(n&&n.total||0)}};let r=()=>{let e={...NC.auditThreadChildren},n=e[t],r=n&&Array.isArray(n.entries)?n.entries:[];r.length>0?e[t]={loading:!1,loaded:!1,entries:r,total:r.length}:(delete e[t],this.auditExpandedThreads[t]&&(this.auditExpandedThreads=MP(this.auditExpandedThreads,t))),NC.auditThreadChildren=e};try{let n=await vs(`/admin/audit/log?`+EP({sessionId:t,limit:TF}),{label:`audit session`});if(n.stale){r();return}if(!n.ok)throw Error(`audit session fetch failed`);let i=NC.auditThreadChildren[t],a=this.auditLog.entries.find(e=>DP(e)===t),o=jP(i,n.data.entries,a?[a]:[e]);o.entries=NC.upsertAuditRecords(o.entries,`audit.thread`),NC.auditThreadChildren={...NC.auditThreadChildren,[t]:{loading:!1,loaded:!0,entries:o.entries,total:Number(n.data.total||0)+o.preservedCount}}}catch(e){console.error(`Failed to fetch audit session entries:`,e),r()}}clearAuditFilters(){this.auditSearch=``,this.auditMethod=``,this.auditStatusCode=``,this.auditStream=``,this.fetchAuditLog(!0)}auditLogNextPage(){this.auditLog.offset+this.auditLog.limit0&&(this.auditLog.offset=Math.max(0,this.auditLog.offset-this.auditLog.limit),this.fetchAuditLog(!1))}isAuditEntryExpanded(e){let t=PP(e);return t?!!(this.auditExpandedEntries&&this.auditExpandedEntries[t]):!1}toggleAuditEntryExpanded(e){this.auditExpandedEntries=VP(this.auditExpandedEntries,e);let t=this.isAuditEntryExpanded(e);return t&&typeof NC.fetchAuditEntryDetail==`function`&&NC.fetchAuditEntryDetail(e),t}expandAuditEntry(e){this.isAuditEntryExpanded(e)||this.toggleAuditEntryExpanded(e)}};NC.fetchAuditLog=e=>DF.fetchAuditLog(e),NC.isAuditEntryExpanded=e=>DF.isAuditEntryExpanded(e);var OF=R(`
                    `);function kF(e,t){E(t,!0);let n=Sw(()=>DF.fetchAuditLog(!0));An(()=>n.cancel);var r=OF(),i=M(r);xw(M(i),{id:`audit-filter-search`,placeholder:`Search by request ID, model, provider, path, user path, or error...`,label:`Search by request ID, model, provider, path, user path, or error`,get oninput(){return n},get value(){return DF.auditSearch},set value(e){DF.auditSearch=e}}),T(i);var a=P(i,2),o=M(a),s=M(o);s.value=s.__value=``;var c=P(s);c.value=c.__value=`GET`;var l=P(c);l.value=l.__value=`POST`;var u=P(l);u.value=u.__value=`PUT`;var d=P(u);d.value=d.__value=`PATCH`;var f=P(d);f.value=f.__value=`DELETE`,T(o);var p=P(o,2),m=M(p);m.value=m.__value=``;var h=P(m);h.value=h.__value=`200`;var g=P(h);g.value=g.__value=`201`;var _=P(g);_.value=_.__value=`400`;var v=P(_);v.value=v.__value=`401`;var y=P(v);y.value=y.__value=`403`;var b=P(y);b.value=b.__value=`404`;var x=P(b);x.value=x.__value=`429`;var S=P(x);S.value=S.__value=`500`;var C=P(S);C.value=C.__value=`502`;var w=P(C);w.value=w.__value=`503`;var ee=P(w);ee.value=ee.__value=`504`,T(p);var te=P(p,2),ne=M(te);ne.value=ne.__value=``;var re=P(ne);re.value=re.__value=`true`;var ie=P(re);ie.value=ie.__value=`false`,T(te);var ae=P(te,2);K(M(ae),{get icon(){return Lo},class:`table-icon-svg`}),Ue(2),T(ae),T(a),T(r),L(`change`,o,()=>DF.fetchAuditLog(!0)),qi(o,()=>DF.auditMethod,e=>DF.auditMethod=e),L(`change`,p,()=>DF.fetchAuditLog(!0)),qi(p,()=>DF.auditStatusCode,e=>DF.auditStatusCode=e),L(`change`,te,()=>DF.fetchAuditLog(!0)),qi(te,()=>DF.auditStream,e=>DF.auditStream=e),L(`click`,ae,()=>DF.clearAuditFilters()),z(e,r),D()}Hr([`change`,`click`]);var AF=R(`Live stream connecting…`),jF=R(` `),MF=R(`Live`),NF=R(` `);function PF(e,t){E(t,!0);let n=O(()=>NC.auditLivePauseReason()),r=O(()=>NC.liveLogsStreaming&&!I(n));var i=Qr(),a=N(i),o=e=>{var t=NF(),i=M(t);let a;var o=P(i,2),s=e=>{z(e,AF())},c=e=>{var t=jF(),r=M(t,!0);T(t),F(e=>B(r,e),[()=>xC(I(n))]),z(e,t)},l=e=>{z(e,MF())};V(o,e=>{NC.liveLogsStreaming?I(n)?e(c,1):e(l,-1):e(s)}),T(t),F(()=>a=U(i,1,`live-dot svelte-tve6yv`,null,a,{"is-streaming":I(r)})),z(e,t)},s=O(()=>Cs.liveLogsVisible());V(a,e=>{I(s)&&e(o)}),z(e,i),D()}var FF=R(` `),IF=R(``);function LF(e,t){E(t,!0);let n=O(()=>[{key:`provider`,text:_c(t.entry)||`-`},{key:`model`,text:t.entry.requested_model||t.entry.model||`-`,mono:!0},{key:`user_path`,text:t.entry.user_path,mono:!0},{key:`request_id`,text:`request_id: `+(t.entry.request_id||`-`),mono:!0},{key:`ip`,text:t.entry.client_ip&&`ip: `+t.entry.client_ip,mono:!0},{key:`auth_key_id`,text:t.entry.auth_key_id&&`auth_key_id: `+t.entry.auth_key_id,mono:!0},{key:`alias`,text:t.entry.alias_used&&`alias`,class:`audit-alias-badge`},{key:`resolved`,text:t.entry.alias_used&&t.entry.resolved_model&&`resolved: `+bc(t.entry),mono:!0},{key:`failover`,text:KP(t.entry)&&`failover: `+KP(t.entry),mono:!0},{key:`stream`,text:t.entry.stream&&`stream`},{key:`error_type`,text:t.entry.error_type}].filter(e=>!!e.text));var r=IF(),i=P(M(r),2);H(i,21,()=>I(n),e=>e.key,(e,t)=>{var n=FF(),r=M(n,!0);T(n),F(()=>{U(n,1,Li([`provider-badge`,I(t).class,{mono:I(t).mono}]),`svelte-hyopt0`),B(r,I(t).text)}),z(e,n)}),T(i),T(r),z(e,r),D()}var RF=R(``),zF=R(` `);function BF(e,t){E(t,!0);let n=O(()=>$P(t.entry)),r=O(()=>I(n).length>0?tF(t.entry):``),i=O(()=>I(n).length>0?eF(t.entry):``);var a=Qr(),o=N(a),s=e=>{var a=zF(),o=M(a);H(o,21,()=>I(n),e=>t.entry.id+`-pip-`+e.seq,(e,t)=>{var n=RF();let r;F(e=>{r=U(n,1,`audit-attempt-pip svelte-1eu22xn`,null,r,{"audit-attempt-success":!!(I(t)&&I(t).success),"audit-attempt-error":!(I(t)&&I(t).success)}),W(n,`title`,e)},[()=>nF(I(t))]),z(e,n)}),T(o);var s=P(o,2),c=M(s,!0);T(s),T(a),F(()=>{W(a,`title`,I(r)),W(a,`aria-label`,I(r)),B(c,I(i))}),z(e,a)};V(o,e=>{I(n).length>0&&e(s)}),z(e,a),D()}var VF=new Set([`instructions`,`messages`,`input`,`previous_response_id`,`choices`,`output`]);function HF(e){if(!e||typeof e!=`object`)return``;let t=String(e.type||``).toLowerCase();if(t===`image`||t===`image_url`||t===`input_image`||t===`output_image`)return`[Image]`;if(t===`audio`||t===`input_audio`||t===`output_audio`)return`[Audio]`;if(t===`file`||t===`input_file`||t===`output_file`){let t=String(e.filename||e.name||``).trim();return t?`[File: `+t+`]`:`[File]`}return typeof e.refusal==`string`?e.refusal:``}function UF(e){if(e==null)return``;if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:!e||typeof e!=`object`?``:typeof e.text==`string`?e.text:typeof e.output_text==`string`?e.output_text:HF(e)).filter(Boolean).join(` +`).trim();if(typeof e==`object`){if(typeof e.text==`string`)return e.text.trim();try{return JSON.stringify(e,null,2)}catch{return``}}return String(e).trim()}function WF(e){return!e||typeof e!=`object`?``:UF(e.content)||(typeof e.refusal==`string`?e.refusal.trim():``)}function GF(e){if(e==null)return[];if(typeof e==`string`)return e?[e]:[];if(Array.isArray(e))return e.flatMap(e=>typeof e==`string`?e?[e]:[]:!e||typeof e!=`object`?[]:typeof e.text==`string`?e.text?[e.text]:[]:typeof e.output_text==`string`&&e.output_text?[e.output_text]:[]);if(typeof e==`object`)return typeof e.text==`string`&&e.text?[e.text]:[];let t=String(e);return t?[t]:[]}function KF(e){let t=Number(e&&e.usage&&e.usage.estimated_cached_characters||0);return Number.isFinite(t)&&t>0?Math.floor(t):0}function qF(e,t){if(!e)return null;let n=(Array.isArray(t)?t:[]).reduce((e,t)=>e+String(t||``).length,0),r=Math.min(String(e).length,n);return r>0?{total:r}:null}function JF(e){let t=e&&e.arguments!==void 0?e.arguments:``,n=``;if(typeof t==`string`)n=t;else try{n=JSON.stringify(t)}catch{n=String(t)}return(String(e&&e.name||``)+`(`+n+`)`).length}function YF(e){return{characters:(Array.isArray(e)?e:[]).map(JF)}}function XF(e,t){let n=Math.max(0,Number(t||0));return e.map(e=>{if(!e||e.role===`error`)return e;let t=Math.max(0,Number(e._promptTextCharacters||0)),r=Math.min(n,t);n-=r;let i=0;(Array.isArray(e._toolPromptCharacters)?e._toolPromptCharacters:[]).forEach(e=>{let t=Math.max(0,Number(e||0)),r=Math.min(n,t);n-=r,i+=r});let a=t+(e._toolPromptCharacters||[]).reduce((e,t)=>e+Math.max(0,Number(t||0)),0);return{...e,promptCacheRatio:a>0?(r+i)/a:0}})}function ZF(e){if(e==null)return[];if(typeof e==`string`){let t=e.trim();return t?[{role:`user`,text:t}]:[]}if(!Array.isArray(e)){let t=UF(e);return t?[{role:`user`,text:t}]:[]}return e.map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e.role||`user`).toLowerCase(),n=UF(e.content);return n?{role:t,text:n}:null}).filter(Boolean)}function QF(e){return!e||typeof e!=`object`?``:Array.isArray(e.content)?e.content.map(e=>e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` +`).trim():UF(e.content)}function $F(e){if(!e||typeof e!=`object`)return[];let t=[];return t.push(...GF(e.instructions)),Array.isArray(e.messages)&&e.messages.forEach(e=>{!e||typeof e!=`object`||t.push(...GF(e.content))}),typeof e.input==`string`?t.push(e.input):Array.isArray(e.input)?e.input.forEach(e=>{!e||typeof e!=`object`||(t.push(...GF(e.content)),typeof e.text==`string`&&t.push(e.text))}):e.input&&typeof e.input==`object`&&(t.push(...GF(e.input.content)),typeof e.input.text==`string`&&t.push(e.input.text)),t.map(e=>String(e||``)).filter(e=>e.length>0)}var eI=e=>UF(e);function tI(e){if(!e||!e.data)return``;let t=hP(e.data.response_body,0,eI);if(t)return t;let n=e.data.error_message;if(n==null)return``;if(typeof n==`string`){let e=n.trim();return e?hP(pP(e),0,eI)||e:``}return hP(n,0,eI)||UF(n)}function nI(e){return Array.isArray(e)?e.some(e=>!e||typeof e!=`object`?!1:e.type===`message`||e.role===`assistant`||e.role===`user`||e.role===`system`?!0:Array.isArray(e.content)?e.content.some(e=>!e||typeof e!=`object`?!1:typeof e.text==`string`||e.type===`output_text`||e.type===`input_text`):!1):!1}function rI(e){if(!e)return!1;let t=String(e).toLowerCase();return t===`/v1/embeddings`||t===`/v1/embeddings/`||t.startsWith(`/v1/embeddings?`)||t.startsWith(`/v1/embeddings/`)}function iI(e){return e?!!oI(e):!1}function aI(e){let t=String(e||``).trim().split(`?`)[0].replace(/\/+$/,``).toLowerCase();return t.startsWith(`/v1/`)?t.slice(3):t}function oI(e){switch(aI(e)){case`/chat/completions`:return`chat`;case`/responses`:return`responses`;case`/messages`:return`messages`;default:return``}}function sI(e){if(!e||typeof e!=`object`)return null;try{return JSON.parse(JSON.stringify(e))}catch{return null}}function cI(e,t){if(!t||typeof t!=`object`)return;let n=e[e.length-1];try{if(n&&JSON.stringify(n)===JSON.stringify(t))return}catch{}e.push(t)}function lI(e){let t=oI(e&&e.path),n=e&&e.data&&e.data.request_body;return!t||!n||typeof n!=`object`?!1:t!==`responses`||(e.data&&e.data.response_body&&typeof e.data.response_body.id==`string`?e.data.response_body.id.trim():``)!==``||qI(n)!==``}function uI(e,t){let n=String(t||``).trim(),r=oI(e&&e.path),i=sI(e&&e.data&&e.data.request_body);if(!n||!r||!i)return null;let a=e&&e.data?e.data.response_body:null;if(r===`responses`){let e=a&&typeof a.id==`string`?a.id.trim():``,t=qI(i);return!e&&!t?null:(i.input=n,e&&!t?i.previous_response_id=e:delete i.previous_response_id,i)}let o=Array.isArray(i.messages)?i.messages:[];if(r===`chat`){let e=a&&Array.isArray(a.choices)?a.choices[0]:null;e&&e.message&&cI(o,sI(e.message)),o.push({role:`user`,content:n})}else a&&a.content!==void 0&&cI(o,{role:String(a.role||`assistant`),content:sI(a.content)||a.content}),o.push({role:`user`,content:n});return i.messages=o,i}var dI=new Set(`authorization.proxy-authorization.cookie.content-type.content-length.host.accept.connection.accept-encoding.content-encoding.transfer-encoding.user-agent.date.expect.upgrade.via.te.trailer.keep-alive.origin.referer.forwarded.x-real-ip.traceparent.tracestate.x-request-id.idempotency-key.x-idempotency-key.x-gomodel-timezone.x-gomodel-interaction-parent`.split(`.`));function fI(e,t,n=``){let r=e&&e.data&&e.data.request_headers,i={};return r&&typeof r==`object`&&Object.keys(r).forEach(e=>{let t=String(e).toLowerCase(),n=String(r[e]==null?``:r[e]);!e||!n||n===`[REDACTED]`||dI.has(t)||t.startsWith(`sec-`)||t.startsWith(`cf-`)||t.startsWith(`x-forwarded-`)||(i[e]=n)}),i[`X-GoModel-Interaction-Parent`]=String(t||e&&e.id||``).trim(),String(n||``).trim()&&(i[`X-Request-ID`]=String(n).trim()),i}function pI(e,t){let n=String(t||``).trim();return!n||!Array.isArray(e)?null:e.find(e=>String(e&&e.request_id||``).trim()===n)||null}function mI(e,t,n,r,i){let a=Array.isArray(e)?e:[],o=String(i&&i.id||``).trim(),s=String(i&&i.request_id||``).trim(),c=String(i&&i.session_id||``).trim(),l=String(r||``).trim(),u=hI(i),d=a.some(e=>o&&String(e&&e.id||``).trim()===o||s&&String(e&&e.request_id||``).trim()===s),f=!!l&&s===l,p=!!n&&c===String(n).trim(),m=!!u&&(u===String(t||``).trim()||a.some(e=>String(e&&e.id||``).trim()===u)),h=d||f||!l&&(p||m);return{accepted:h,submittedChild:f,followUpRequestID:h&&f&&o?``:l}}function hI(e){let t=e&&e.data&&e.data.request_headers;if(!t||typeof t!=`object`)return``;let n=Object.keys(t).find(e=>e.toLowerCase()===`x-gomodel-interaction-parent`);return n?String(t[n]||``).trim():``}function gI(e,t){return!Array.isArray(e)||!t?null:e.find(e=>String(e&&e.id||``)===String(t))||null}function _I(e){return!Array.isArray(e)||e.length===0?null:e.reduce((e,t)=>e?JI(t,e)>=0?t:e:t,null)}function vI(e,t){let n=new Set(Array.isArray(t)?t.map(String):[]);return _I((Array.isArray(e)?e:[]).filter(e=>{let t=String(e&&e.id||``);return n.has(t)&&e&&e.data&&e.data.request_body!=null}))}function yI(e,t){let n=_I(e);return!!n&&String(n.id||``)===String(t||``)}function bI(e,t,n){return String(e||``).trim()===`audit.flushed`&&String(t||``).trim()!==``&&String(t||``).trim()===String(n||``).trim()}function xI(e,t){let n=Array.isArray(e)?e.filter(Boolean).map(String):[];return(Array.isArray(t)?t:[]).forEach(e=>{let t=String(e&&(e.id||e.request_id)||``).trim();t&&!n.includes(t)&&n.push(t)}),n}function SI(e){if(e&&e.conversation_payload)return!0;let t=e&&e.data?e.data.request_body:null,n=e&&e.data?e.data.response_body:null,r=t&&(Array.isArray(t.messages)||t.input!==void 0||typeof t.instructions==`string`||typeof t.previous_response_id==`string`),i=n&&(Array.isArray(n.choices)||nI(n.output));return!!(r||i)}function CI(e){return!e||rI(e.path)?!1:iI(e.path)||SI(e)}function wI(e){let t=0,n=!1,r=!1,i=String(e||``);for(let e=0;e0&&a+1`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function OI(e){return!!(e&&typeof e==`object`&&e.__audio__===!0)}function kI(e){let t=Number(e||0);if(!Number.isFinite(t)||t<=0)return`0 B`;let n=[`B`,`KB`,`MB`,`GB`],r=0,i=t;for(;i>=1024&&r`
                    `+DI(t)+``+DI(jI(e[t]))+`
                    `);return t.length?``:``}function NI(e){let t=AI(e.content_type),n=DI(t+` · `+kI(e.bytes)),r=MI(e.meta);if(e.stored&&e.encoding===`base64`&&e.data){let i=String(e.data).replace(/[^A-Za-z0-9+/=]/g,``);return`
                    `+n+`
                    `+r+`
                    `}let i=e.too_large?`Audio too large to store.`:`Audio not logged. Set LOGGING_LOG_AUDIO_BODIES=true to capture playable audio.`;return`
                    `+n+`
                    `+DI(i)+`
                    `+r+`
                    `}function PI(e){try{return JSON.stringify(String(e)).slice(1,-1)}catch{return``}}function FI(e){if(!e||typeof e!=`object`)return null;let t=Number(e.characters||0);if(!Number.isFinite(t)||t<=0)return null;let n=Array.isArray(e.segments)?e.segments.map(e=>String(e||``)).filter(Boolean):[];return n.length===0?null:{remaining:Math.floor(t),segments:n,segmentIndex:0}}function II(e,t){if(!t||t.remaining<=0||t.segmentIndex>=t.segments.length)return DI(e);let n=``,r=0,i=0;for(;t.remaining>0&&t.segmentIndex`+DI(l)+``,r=s+l.length,i=s+o.length,t.remaining-=c,c>=a.length){t.segmentIndex++;continue}break}return n?n+DI(e.slice(r)):DI(e)}function LI(e,t,n){let r=n&&typeof n.formatJSON==`function`?n.formatJSON:e=>String(e),i=n&&typeof n.canShowConversation==`function`?n.canShowConversation:()=>!1,a=FI(n&&n.promptCacheHighlight),o=r(t);if(!o||o===`Not captured`)return DI(o);if(!i(e))return o.split(` +`).map(e=>II(e,a)).join(` +`);let s=o.split(` +`),c=[],l=0;for(;lII(e,a)).join(` +`);c.push(``+o+``),l=r+1;continue}c.push(II(e,a)),l++}return c.join(` +`)}function RI(e){let t=String(e||``).toLowerCase();return t===`system`||t===`developer`?{role:`system`,label:`System Prompt`,className:`role-system`}:t===`assistant`?{role:`assistant`,label:`Agent`,className:`role-assistant`}:t===`error`?{role:`error`,label:`Error`,className:`role-error`}:t===`function_call`?{role:`function_call`,label:`Function Call`,className:`role-function-call`}:t===`function_result`?{role:`function_result`,label:`Function Result`,className:`role-function-result`}:{role:`user`,label:`User`,className:`role-user`}}function zI(e,t,{timestamp:n,entryID:r,isAnchor:i,isAfterAnchor:a,index:o,toolCalls:s,functionName:c,functionCallID:l,promptCache:u,toolPromptCache:d}){let f=RI(e),p=u&&Number.isFinite(Number(u.total))?Math.max(0,Number(u.total)):u===null?0:String(t||``).length,m=d&&Array.isArray(d.characters)?d.characters:YF(s).characters;return{uid:r+`-`+o,entryID:r,timestamp:n,text:t,role:f.role,roleLabel:f.label,roleClass:f.className,isAnchor:i,isAfterAnchor:a,toolCalls:Array.isArray(s)&&s.length>0?s:null,functionName:c||``,functionCallID:l||``,promptCacheRatio:0,_promptTextCharacters:p,_toolPromptCharacters:m}}function BI(e){return Array.isArray(e)?e.map(e=>{if(!e)return null;let t=e.function||e,n=``;return t.arguments===void 0?e.arguments===void 0?t.input===void 0?e.input!==void 0&&(n=e.input):n=t.input:n=e.arguments:n=t.arguments,{name:t.name||e.name||``,arguments:n,id:e.call_id||e.id||``}}).filter(Boolean):[]}function VI(e){return Array.isArray(e)?BI(e.filter(e=>e&&typeof e==`object`&&e.type===`tool_use`)):[]}function HI(e){return Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`tool_result`).map(e=>({id:e.tool_use_id||e.call_id||``,text:UF(e.content)})):[]}function UI(e,t,n){!t||!n||[t.call_id,t.id].forEach(t=>{t&&(e[t]=n)})}function WI(e,t,n){if(t&&Array.isArray(t.messages)&&t.messages.forEach(t=>{t&&[...Array.isArray(t.tool_calls)?t.tool_calls:[],...Array.isArray(t.content)?t.content.filter(e=>e&&e.type===`tool_use`):[]].forEach(t=>{t&&UI(e,t,(t.function||t).name||t.name||``)})}),t&&Array.isArray(t.input)&&t.input.forEach(t=>{!t||typeof t!=`object`||t.type!==`function_call`&&t.type!==`tool_use`||UI(e,t,t.name||``)}),n&&Array.isArray(n.choices)){let t=n.choices[0];t&&t.message&&Array.isArray(t.message.tool_calls)&&t.message.tool_calls.forEach(t=>{t&&UI(e,t,(t.function||t).name||t.name||``)})}n&&Array.isArray(n.output)&&n.output.forEach(t=>{!t||t.type!==`function_call`&&t.type!==`tool_use`||UI(e,t,t.name||``)}),n&&Array.isArray(n.content)&&n.content.forEach(t=>{!t||t.type!==`tool_use`||UI(e,t,t.name||``)})}function GI(e){return Array.isArray(e)?`[`+e.map(GI).join(`,`)+`]`:e&&typeof e==`object`?`{`+Object.keys(e).sort().map(t=>JSON.stringify(t)+`:`+GI(e[t])).join(`,`)+`}`:JSON.stringify(e)}function KI(e){if(!e||typeof e!=`object`)return null;let t=[];if(e.system!==void 0&&t.push({system:e.system}),e.instructions!==void 0&&t.push({instructions:e.instructions}),Array.isArray(e.messages))t.push(...e.messages);else if(Array.isArray(e.input)&&e.previous_response_id==null&&e.conversation==null)t.push(...e.input);else return null;return t.map(GI)}function qI(e){let t=e&&e.conversation;return typeof t==`string`?t.trim():t&&typeof t.id==`string`?t.id.trim():``}function JI(e,t){let n=new Date(e&&e.timestamp).getTime(),r=new Date(t&&t.timestamp).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r)return n-r;let i=String(e&&e.timestamp||``).localeCompare(String(t&&t.timestamp||``));if(i!==0)return i;let a=String(e&&e.id||``),o=String(t&&t.id||``);return ao)}function YI(e,t){if(!Array.isArray(e)||e.length===0)return{messages:[],entryIDs:[]};let n=[...e].sort(JI),r={};n.forEach(e=>{let t=e.data&&e.data.request_body?e.data.request_body:null,n=e.data&&e.data.response_body?e.data.response_body:null;WI(r,t,n)});let i=[],a=new Set,o=new Set,s=new Set,c=[],l=null,u=0,d=n.findIndex(e=>e.id===t),f=e=>JSON.stringify({role:e.role,text:e.text,toolCalls:e.toolCalls,functionName:e.functionName,functionCallID:e.functionCallID});return n.forEach((e,n)=>{let p=e.id===t,m=d>=0&&n>d,h=e.timestamp,g=e.data&&e.data.request_body?e.data.request_body:null,_=e.data&&e.data.response_body?e.data.response_body:null,v=i.length,y=(e,t)=>qF(e,t),b=e=>YF(e),x=(t,n,{toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s}={})=>zI(t,n,{timestamp:h,entryID:e.id,isAnchor:p,isAfterAnchor:m,index:++u,toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s});if(g&&g.system!==void 0){let e=UF(g.system);e&&i.push(x(`system`,e,{promptCache:y(e,GF(g.system))}))}if(g&&g.instructions!==void 0){let e=UF(g.instructions);e&&i.push(x(`system`,e,{promptCache:y(e,GF(g.instructions))}))}g&&Array.isArray(g.messages)&&g.messages.forEach(e=>{if(!e)return;let t=(e.role||`user`).toLowerCase();if(t===`tool`){let t=UF(e.content),n=e.name||r[e.tool_call_id]||``;t&&i.push(x(`function_result`,t,{functionName:n,functionCallID:e.tool_call_id||``,promptCache:y(t,GF(e.content))}));return}if(t===`assistant`){let n=WF(e),r=[...BI(e.tool_calls),...VI(e.content)];if(n||r.length>0){let a=y(n,GF(e.content));i.push(x(t,n,{toolCalls:r,promptCache:a,toolPromptCache:b(r)}))}return}HI(e.content).forEach(e=>{e.text&&i.push(x(`function_result`,e.text,{functionName:r[e.id]||``,functionCallID:e.id,promptCache:y(e.text,[e.text])}))});let n=WF(e);n&&i.push(x(t,n,{promptCache:y(n,GF(e.content))}))}),g&&g.input!==void 0&&(Array.isArray(g.input)?g.input.forEach(e=>{if(!(!e||typeof e!=`object`)){if(e.type===`function_call_output`){let t=typeof e.output==`string`?e.output:UF(e.output);t&&i.push(x(`function_result`,t,{functionName:r[e.call_id]||e.name||``,functionCallID:e.call_id||``,promptCache:y(t,[t])}))}else if(e.type===`function_call`){let t=BI([e]);i.push(x(`function_call`,``,{toolCalls:t,toolPromptCache:b(t)}))}else if(e.role){let t=String(e.role).toLowerCase(),n=UF(e.content);n&&i.push(x(t,n,{promptCache:y(n,GF(e.content))}))}}}):ZF(g.input).forEach(e=>{if(!e.text)return;let t=[];typeof g.input==`string`?t=[g.input]:g.input&&typeof g.input==`object`&&(t=GF(g.input.content),typeof g.input.text==`string`&&t.push(g.input.text)),i.push(x(e.role,e.text,{promptCache:y(e.text,t)}))}));let S=i.splice(v),C=S.map(f),w=KI(g),ee=w!==null,te=hI(e),ne=!!te&&a.has(te),re=String(g&&g.previous_response_id||``).trim(),ie=qI(g),ae=ne||!!re&&o.has(re)||!!ie&&s.has(ie);if(m){let e=ee&&l&&l.length>0&&l.every((e,t)=>w[t]===e);if(ee&&!e&&!ne||!ee&&!ae)return}p&&ee&&(l=[...w]);let oe=String(e.id||``).trim();p&&(a.clear(),o.clear(),s.clear()),oe&&(p||m)&&a.add(oe),ie&&s.add(ie);let se=0;for(;se0;){let t=c.slice(-e),n=C.slice(0,e);if(t.every((e,t)=>e===n[t]))break;e--}i.push(...S.slice(e)),c.push(...C.slice(e))}if(g&&i.splice(0,i.length,...XF(i,KF(e))),_&&Array.isArray(_.choices)){let e=_.choices[0];if(e&&e.message){let t=(e.message.role||`assistant`).toLowerCase(),n=WF(e.message),r=BI(e.message.tool_calls);if(n||r.length>0){let e=x(t,n,{toolCalls:r});i.push(e),c.push(f(e))}}}if(_&&Array.isArray(_.output)&&_.output.forEach(e=>{if(!e)return;if(e.type===`function_call`){let t=x(`function_call`,``,{toolCalls:BI([e])});i.push(t),c.push(f(t));return}let t=(e.role||`assistant`).toLowerCase(),n=QF(e);if(n){let e=x(t,n);i.push(e),c.push(f(e))}}),_&&_.content!==void 0&&!Array.isArray(_.choices)&&!Array.isArray(_.output)){let e=String(_.role||`assistant`).toLowerCase(),t=UF(_.content),n=VI(_.content);if(t||n.length>0){let r=x(e,t,{toolCalls:n});i.push(r),c.push(f(r))}}let ce=tI(e);ce&&i.push(x(`error`,ce));let le=String(_&&_.id||``).trim();le&&o.add(le)}),{messages:i,entryIDs:[...a]}}function XI(e){return e.role===`function_call`?(e.toolCalls||[]).map(function(e){return e.name+`(`+ZI(e)+`)`}).join(` + +`):e.text||``}function ZI(e){let t=e&&e.arguments!==void 0?e.arguments:``;if(typeof t!=`string`)try{return JSON.stringify(t,null,2)}catch{return String(t)}try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var QI=600*1e3,$I=15*1e3,eL=250,tL=class{#e=k(!1);get conversationOpen(){return I(this.#e)}set conversationOpen(e){A(this.#e,e,!0)}#t=k(!1);get conversationLoading(){return I(this.#t)}set conversationLoading(e){A(this.#t,e,!0)}#n=k(``);get conversationError(){return I(this.#n)}set conversationError(e){A(this.#n,e,!0)}#r=k(``);get conversationAnchorID(){return I(this.#r)}set conversationAnchorID(e){A(this.#r,e,!0)}#i=k(j([]));get conversationEntryIDs(){return I(this.#i)}set conversationEntryIDs(e){A(this.#i,e,!0)}#a=k(``);get conversationSessionID(){return I(this.#a)}set conversationSessionID(e){A(this.#a,e,!0)}#o=k(!1);get conversationTruncated(){return I(this.#o)}set conversationTruncated(e){A(this.#o,e,!0)}#s=k(!1);get conversationFollowLatest(){return I(this.#s)}set conversationFollowLatest(e){A(this.#s,e,!0)}#c=k(``);get conversationOpenedFromID(){return I(this.#c)}set conversationOpenedFromID(e){A(this.#c,e,!0)}#l=k(``);get followUpText(){return I(this.#l)}set followUpText(e){A(this.#l,e,!0)}#u=k(!1);get followUpSending(){return I(this.#u)}set followUpSending(e){A(this.#u,e,!0)}#d=k(``);get followUpError(){return I(this.#d)}set followUpError(e){A(this.#d,e,!0)}followUpRequestID=``;followUpAbort=null;conversationRequestToken=0;conversationReturnFocusEl=null;bodyPointerStart=null;#f=k(null);get conversationDialogEl(){return I(this.#f)}set conversationDialogEl(e){A(this.#f,e,!0)}#p=k(null);get conversationCloseBtnEl(){return I(this.#p)}set conversationCloseBtnEl(e){A(this.#p,e,!0)}#m=k(null);get conversationThreadEl(){return I(this.#m)}set conversationThreadEl(e){A(this.#m,e,!0)}get conversationEntries(){return(this.conversationEntryIDs||[]).map(e=>NC.auditRecord(e)).filter(Boolean)}#h=O(()=>YI(this.conversationEntries,this.conversationAnchorID));get conversationView(){return I(this.#h)}set conversationView(e){A(this.#h,e)}get conversationMessages(){return this.conversationView.messages}get conversationBranchEntryIDs(){return this.conversationView.entryIDs}_setConversationEntryIDs(e){this.conversationEntryIDs=[...new Set((Array.isArray(e)?e:[]).filter(Boolean))],NC.pinAuditRecords(this.conversationEntryIDs)}canShowConversation(e){return CI(e)}startBodyInteraction(e){this.bodyPointerStart={x:e.clientX,y:e.clientY}}_isBodyDrag(e){if(!this.bodyPointerStart)return!1;let t=Math.abs(e.clientX-this.bodyPointerStart.x),n=Math.abs(e.clientY-this.bodyPointerStart.y);return t>4||n>4}_hasActiveSelection(){let e=window.getSelection?window.getSelection():null;return!e||e.isCollapsed?!1:String(e.toString()||``).trim().length>0}handleBodyConversationClick(e,t){let n=this._isBodyDrag(e);if(this.bodyPointerStart=null,n||this._hasActiveSelection()||!this.canShowConversation(t))return;let r=e.target&&e.target.closest?e.target.closest(`[data-conversation-trigger="1"]`):null;r&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,r))}handleErrorConversationClick(e,t){let n=this._isBodyDrag(e);this.bodyPointerStart=null,!n&&(this._hasActiveSelection()||this.canShowConversation(t)&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,e.currentTarget)))}formatJSON(e){return oc(e)}renderBodyWithConversationHighlights(e,t,n){return LI(e,t,{formatJSON:e=>this.formatJSON(e),canShowConversation:e=>this.canShowConversation(e),promptCacheHighlight:n&&n.promptCacheHighlight})}async openConversation(e,t){if(!e||!e.id||!this.canShowConversation(e))return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null;t instanceof HTMLElement?this.conversationReturnFocusEl=t:n&&n!==document.body&&(this.conversationReturnFocusEl=n);let r=++this.conversationRequestToken;if(this.conversationOpen=!0,this.conversationError=``,this.conversationAnchorID=e.id,this.conversationOpenedFromID=e.id,this.conversationSessionID=String(e.session_id||``).trim(),this._setConversationEntryIDs([]),this.conversationTruncated=!1,this.conversationFollowLatest=!1,this.followUpText=``,this.followUpError=``,this.followUpRequestID=``,requestAnimationFrame(()=>this._focusConversationDrawer()),this._conversationEntryLivePending(e)){this.conversationFollowLatest=!0,this.conversationLoading=!1,this._addConversationRecord(NC.upsertAuditRecord(e,`conversation.live`));return}this.conversationLoading=!0,await this.fetchConversation(e.id,r,!0,!0)}_conversationEntryLivePending(e){return typeof NC.auditEntryLiveDetailPending==`function`&&NC.auditEntryLiveDetailPending(e)}_applyConversationView(){let e=this.conversationEntries,t=YI(e,this.conversationAnchorID);if(this.conversationFollowLatest){let n=vI(e,t.entryIDs);n&&n.id&&String(n.id)!==this.conversationAnchorID&&(this.conversationAnchorID=String(n.id))}}handleAuditRecordChange(e,t){if(!this.conversationOpen||!e)return;let n=String(e.id||``).trim(),r=mI(this.conversationEntries,this.conversationAnchorID,this.conversationSessionID,this.followUpRequestID,e);if(r.accepted&&(this.followUpRequestID=r.followUpRequestID,n&&r.submittedChild&&(this.conversationAnchorID=n,this.conversationFollowLatest=!0),this._addConversationRecord(e),bI(String(t||e._live_state||``).trim(),n,this.conversationAnchorID))){this.conversationMessages.length===0&&(this.conversationLoading=!0);let e=++this.conversationRequestToken;this.fetchConversation(n,e,!1)}}_addConversationRecord(e){let t=EC(e);t&&!this.conversationEntryIDs.includes(t)&&this._setConversationEntryIDs([...this.conversationEntryIDs,t]),!this.conversationSessionID&&e.session_id&&(this.conversationSessionID=String(e.session_id).trim()),this._applyConversationView(),this.conversationFollowLatest&&this._scheduleLatestScroll()}conversationLiveWaiting(){if(!this.conversationOpen)return!1;let e=new Set(this.conversationBranchEntryIDs||[]);return(this.conversationEntries||[]).some(t=>e.has(String(t&&t.id||``))&&t._live&&(typeof NC.liveAuditStateSettled!=`function`||!NC.liveAuditStateSettled(t._live_state)))}conversationLiveStatusText(){return(this.conversationMessages||[]).length>0?`Model is responding…`:`Waiting for request data…`}closeConversation(){this.followUpAbort&&this.followUpAbort.abort(),this.conversationOpen=!1,this.conversationRequestToken++,this.conversationSessionID=``,this._setConversationEntryIDs([]),this.conversationFollowLatest=!1,this.conversationOpenedFromID=``,this.followUpRequestID=``,this.followUpSending=!1;let e=this.conversationReturnFocusEl;this.conversationReturnFocusEl=null,e&&typeof e.focus==`function`&&document.contains(e)&&requestAnimationFrame(()=>e.focus())}_focusConversationDrawer(){if(!this.conversationOpen)return;let e=this.conversationCloseBtnEl;if(e&&typeof e.focus==`function`){e.focus();return}let t=this.conversationDialogEl;t&&typeof t.focus==`function`&&t.focus()}async fetchConversation(e,t,n=!0,r=!1){try{let i=await vs(`/admin/audit/conversation?`+(`log_id=`+encodeURIComponent(e)+`&limit=120`),{label:`audit conversation`});if(t!==this.conversationRequestToken||i.stale)return;if(!i.ok){this.conversationError=`Unable to load interactions.`;return}let a=i.data||{},o=a.anchor_id||e,s=Array.isArray(a.entries)?a.entries:[],c=NC.upsertAuditRecords(s,`conversation.hydrated`),l=xI(this.conversationEntryIDs,c);l.length>this.conversationEntryIDs.length&&this._setConversationEntryIDs(l),r&&(this.conversationFollowLatest=yI(c,o)),this.conversationAnchorID=o;let u=this.conversationEntries.find(e=>e.id===this.conversationAnchorID);u&&u.session_id&&(this.conversationSessionID=String(u.session_id).trim()),this.conversationTruncated=!!a.truncated,this._applyConversationView(),this.conversationFollowLatest?this._scheduleLatestScroll():n&&this._scheduleAnchorScroll()}catch(e){if(t!==this.conversationRequestToken)return;console.error(`Failed to fetch audit conversation:`,e),this.conversationError=`Failed to load interactions.`}finally{t===this.conversationRequestToken&&(this.conversationLoading=!1)}}selectedConversationEntry(){return gI(this.conversationEntries,this.conversationAnchorID)}followUpKind(){let e=this.selectedConversationEntry();return lI(e)?oI(e.path):``}canSendFollowUp(){return!!this.followUpKind()&&!!String(this.followUpText||``).trim()&&!this.followUpSending&&!this.conversationLiveWaiting()}async sendFollowUp(){if(!this.canSendFollowUp())return;let e=this.selectedConversationEntry(),t=uI(e,this.followUpText);if(!e||!t)return;let n=this.conversationAnchorID,r=rL(),i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},QI);this.followUpSending=!0,this.followUpError=``,this.followUpRequestID=r,this.followUpAbort=i;try{let a=fI(e,n,r),o=await gs(e.path,{method:`POST`,headers:a,body:JSON.stringify(t),signal:i.signal}),s=String(o.headers.get(`X-Request-ID`)||``).trim();if(s&&this.followUpRequestID&&(this.followUpRequestID=s),!o.ok){let e=`Unable to send message.`;try{let t=await o.json();e=t&&t.error&&t.error.message||e}catch{}this.followUpError=e,(this.followUpRequestID===r||this.followUpRequestID===s)&&(this.followUpRequestID=``);return}if(this.followUpText=``,await nL(o),!NC.liveLogsStreaming&&this.conversationOpen){let e=++this.conversationRequestToken;await this._selectPersistedFollowUp(n,this.followUpRequestID,e,i.signal)}}catch(e){bs(e)||i.signal.aborted?a&&this.conversationOpen&&(this.followUpError=`The request timed out.`):(console.error(`Failed to send interaction follow-up:`,e),this.followUpError=`Failed to send message.`)}finally{clearTimeout(o),this.followUpAbort===i&&(this.followUpAbort=null,this.followUpSending=!1)}}async _selectPersistedFollowUp(e,t,n,r){let i=Date.now()+$I;for(;this.conversationOpen&&n===this.conversationRequestToken&&Date.now(){let e=this.conversationThreadEl;if(!e)return;let t=e.querySelectorAll(`[data-conversation-anchor="true"]`),n=t[t.length-1];n&&typeof n.scrollIntoView==`function`&&n.scrollIntoView({block:`center`})})}_scheduleLatestScroll(){requestAnimationFrame(()=>{let e=this.conversationThreadEl;if(!e)return;let t=e.lastElementChild;t&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`end`})})}};async function nL(e){let t=e&&e.body&&typeof e.body.getReader==`function`?e.body.getReader():null;if(!t){await e.text();return}for(;!(await t.read()).done;);}function rL(){return globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`?globalThis.crypto.randomUUID():`dashboard-`+Date.now().toString(36)+`-`+Math.random().toString(36).slice(2)}function iL(e,t){return new Promise((n,r)=>{let i,a=()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))};if(i=setTimeout(()=>{t&&t.removeEventListener(`abort`,a),n()},e),t){if(t.aborted){a();return}t.addEventListener(`abort`,a,{once:!0})}})}var aL=new tL,oL=0;Mn(()=>{An(()=>{let e=OC(NC.auditRecordChanges,oL);e.length!==0&&(oL=Number(e[e.length-1].version||0),Er(()=>{e.forEach(e=>{if(!kC(e))return;let t=NC.auditRecord(e.key);aL.handleAuditRecordChange(t,e.eventType)})}))})});var sL=R(``),cL=R(` `),lL=R(``),uL=R(`
                    `);function dL(e,t){E(t,!0);let n=G(t,`thread`,3,null),r=G(t,`expanded`,3,!1),i=G(t,`onactivate`,3,null),a=O(()=>fs.formatTimestamp(t.entry.timestamp)),o=O(()=>I(a)===`-`?I(a):I(a).slice(I(a).lastIndexOf(` `)+1)),s=O(()=>aL.conversationOpen&&String(aL.conversationAnchorID||``)===String(t.entry.id||``));function c(e){e.preventDefault(),i()&&i()()}function l(e){e.stopPropagation(),e.preventDefault(),n().ontoggle()}function u(e){if(e.stopPropagation(),e.preventDefault(),I(s)){aL.closeConversation();return}aL.openConversation(t.entry,e.currentTarget)}var d=uL();let f;var p=M(d),m=M(p),h=e=>{var t=sL(),r=M(t);{let e=O(()=>n().expanded?Ua:Ga);K(r,{get icon(){return I(e)},class:`audit-thread-expander-svg`})}var i=P(r,2),a=M(i,!0);T(i),T(t),F(()=>{W(t,`aria-expanded`,n().expanded),W(t,`title`,`Session with `+n().count+` requests`),W(t,`aria-label`,`Session with `+n().count+` requests, `+(n().expanded?`collapse`:`expand`)),B(a,n().count)}),L(`click`,t,l),z(e,t)};V(m,e=>{n()&&e(h)});var g=P(m,2),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=M(y,!0);T(y),T(g);var x=P(g,2),S=e=>{var n=cL(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>xc(t.entry)]),z(e,n)};V(x,e=>{(t.entry.requested_model||t.entry.model)&&e(S)});var C=P(x,2),w=M(C,!0);T(C),T(p);var ee=P(p,2),te=M(ee);BF(te,{get entry(){return t.entry}});var ne=P(te,2),re=M(ne),ie=M(re,!0);T(re);var ae=P(re,2),oe=M(ae,!0);T(ae),T(ne);var se=P(ne,2),ce=M(se,!0);T(se);var le=P(se,2),ue=e=>{var t=lL();let n;var r=M(t);{let e=O(()=>I(s)?Wa:Ga);K(r,{get icon(){return I(e)},class:`audit-conversation-trigger-svg`})}T(t),F(()=>{n=U(t,1,`audit-conversation-trigger svelte-17mysgz`,null,n,{"audit-conversation-trigger-active":I(s)}),W(t,`title`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-label`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-pressed`,I(s))}),L(`click`,t,u),z(e,t)},de=O(()=>aL.canShowConversation(t.entry));V(le,e=>{I(de)&&e(ue)}),T(ee),T(d),F((e,n,i,s)=>{f=U(d,1,`audit-entry-summary svelte-17mysgz`,null,f,e),W(d,`aria-expanded`,r()),U(g,1,`audit-status-badge audit-request-badge ${n??``}`,`svelte-17mysgz`),W(g,`title`,`Status `+(t.entry.status_code||`-`)+` · `+(t.entry.method||`-`)),W(g,`aria-label`,(t.entry.status_code||`-`)+` `+(t.entry.method||`-`)),B(v,t.entry.status_code||`-`),B(b,t.entry.method||`-`),B(w,t.entry.path||`-`),W(ne,`title`,i),W(ne,`aria-label`,I(a)),B(ie,I(a)),B(oe,I(o)),B(ce,s)},[()=>({"audit-entry-summary-live-in-progress":GP(t.entry),"audit-entry-summary-has-interactions":aL.canShowConversation(t.entry)}),()=>WP(t.entry.status_code),()=>hc(t.entry.timestamp),()=>UP(t.entry.duration_ns)]),L(`click`,d,c),z(e,d),D()}Hr([`click`]);var fL=R(``);function pL(e,t){E(t,!0);let n=G(t,`label`,3,`Copy`),r=G(t,`copiedLabel`,3,`Copied`),i=G(t,`errorLabel`,3,``),a=G(t,`class`,3,`btn`),o=O(()=>t.state.error&&i()?i():t.state.copied?r():n());var s=fL();let c;var l=M(s),u=e=>{K(e,{get icon(){return qa},width:`14`,height:`14`,"stroke-width":`2.5`})},d=e=>{K(e,{get icon(){return Xa},width:`14`,height:`14`})};V(l,e=>{t.state.copied?e(u):e(d,-1)});var f=P(l,2),p=M(f,!0);T(f),T(s),F(()=>{c=U(s,1,Li([`copy-feedback-btn`,a()]),null,c,{"copy-feedback-btn-copied":t.state.copied}),B(p,I(o))}),L(`click`,s,e=>{e.preventDefault(),t.onclick?.(e)}),z(e,s),D()}Hr([`click`]);var mL=R(`
                    Error Message
                     
                    `),hL=R(`
                     
                    `),gL=R(` `),_L=R(` streaming`),vL=R(`
                    Body
                    `),yL=R(`

                    `),bL=R(`

                    `),xL=R(`

                    `),SL=R(`
                    `);function CL(e,t){E(t,!0);let n=yM({logPrefix:`Failed to copy audit payload:`}),r=yM({logPrefix:`Failed to copy audit payload:`}),i=O(()=>t.pane&&t.pane.showHeaders?oc(t.pane.headers):``),a=O(()=>!t.pane||!t.pane.showBody?``:OI(t.pane.body)?NI(t.pane.body):aL.renderBodyWithConversationHighlights(t.pane.entry,t.pane.body,{promptCacheHighlight:t.pane.promptCacheHighlight})),o=O(()=>!!(t.pane&&aL.canShowConversation(t.pane.entry)));function s(e){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),aL.handleErrorConversationClick(e,t.pane.entry))}var c=SL();let l;var u=M(c),d=e=>{var n=mL(),r=P(M(n),2);let i;var a=M(r,!0);T(r),T(n),F(()=>{i=U(r,1,`audit-json audit-pane-error-message svelte-1h5puht`,null,i,{"audit-pane-clickable-preview":I(o)}),W(r,`role`,I(o)?`button`:null),W(r,`tabindex`,I(o)?0:null),B(a,t.pane.errorMessage)}),L(`mousedown`,r,e=>aL.startBodyInteraction(e)),L(`keydown`,r,s),L(`click`,r,e=>aL.handleErrorConversationClick(e,t.pane.entry)),z(e,n)};V(u,e=>{t.pane.showErrorMessage&&e(d)});var f=P(u,2),p=e=>{var n=hL(),a=M(n),o=M(a),s=M(o,!0);T(o),pL(P(o,2),{get state(){return r},label:`Copy Headers`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>r.copy(t.pane.copyHeaders,oc)}),T(a);var c=P(a,2),l=M(c,!0);T(c),T(n),F(()=>{B(s,t.pane.headersTitle||`Headers`),B(l,I(i))}),z(e,n)};V(f,e=>{t.pane.showHeaders&&e(p)});var m=P(f,2),h=e=>{var r=vL(),i=M(r),o=M(i),s=P(M(o),2),c=e=>{var n=gL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.bodyCacheRatioLabel)),z(e,n)};V(s,e=>{t.pane.bodyCacheRatioLabel&&e(c)});var l=P(s,2),u=e=>{z(e,_L())};V(l,e=>{t.pane.streaming&&e(u)}),T(o),pL(P(o,2),{get state(){return n},label:`Copy Body`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>n.copy(t.pane.copyBody,oc)}),T(i);var d=P(i,2);_i(d,()=>I(a),!0),T(d),T(r),L(`mousedown`,d,e=>aL.startBodyInteraction(e)),L(`click`,d,e=>aL.handleBodyConversationClick(e,t.pane.entry)),z(e,r)};V(m,e=>{t.pane.showBody&&e(h)});var g=P(m,2),_=e=>{var n=yL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.emptyMessage)),z(e,n)};V(g,e=>{t.pane.showEmpty&&e(_)});var v=P(g,2),y=e=>{var n=bL(),r=P(M(n),2),i=M(r,!0);T(r),T(n),F(()=>B(i,t.pane.pendingMessage)),z(e,n)};V(v,e=>{t.pane.showPending&&e(y)});var b=P(v,2),x=e=>{var n=xL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.tooLargeMessage)),z(e,n)};V(b,e=>{t.pane.showTooLarge&&e(x)}),T(c),F(()=>l=U(c,1,`audit-pane svelte-1h5puht`,null,l,{"audit-pane-split":t.pane&&t.pane.layout===`split`,"audit-pane-split-single":t.pane&&t.pane.layout===`split`&&!(t.pane.showHeaders&&t.pane.showBody)})),z(e,c),D()}Hr([`mousedown`,`keydown`,`click`]);var wL=R(` `),TL=R(` `),EL=R(` `),DL=R(` `),OL=R(``),kL=R(`
                    `),AL=R(`
                    `);function jL(e,t){E(t,!0);let n=G(t,`panes`,19,()=>[]),r=k(null),i=O(()=>CF(I(r),t.entry,n())),a=e=>`audit-tab-`+t.entry.id+`-`+e,o=e=>`audit-tabpanel-`+t.entry.id+`-`+e;function s(e,t){let i=n().map(e=>e.id),a=wF(e.key,i,t);a!=null&&(e.preventDefault(),((e.currentTarget?.closest?.(`.audit-pane-tablist`))?.querySelectorAll(`.audit-pane-tab`)[i.indexOf(a)])?.focus?.(),A(r,a,!0))}var c=AL(),l=M(c);H(l,21,n,e=>e.id,(e,t)=>{var n=OL();let c;var l=M(n),u=M(l),d=e=>{K(e,{get icon(){return Fa}})},f=e=>{K(e,{get icon(){return Pa}})};V(u,e=>{I(t).pane.direction===`request`?e(d):I(t).pane.direction===`response`&&e(f,1)}),T(l);var p=P(l,2),m=M(p,!0);T(p);var h=P(p,2),g=e=>{var n=wL(),r=M(n);T(n),F(()=>B(r,`#${I(t).pane.seq??``}`)),z(e,n)};V(h,e=>{I(t).pane.seq&&e(g)});var _=P(h,2),v=e=>{var n=TL(),r=M(n,!0);T(n),F(()=>{U(n,1,`provider-badge audit-pane-kind audit-pane-kind-${I(t).pane.kind??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.kind)}),z(e,n)};V(_,e=>{I(t).pane.kind&&e(v)});var y=P(_,2);H(y,17,()=>I(t).pane.noChangeSteps||[],e=>e.id,(e,t)=>{var n=EL(),r=M(n,!0);T(n),F(()=>{W(n,`title`,I(t).title),B(r,I(t).label)}),z(e,n)});var b=P(y,2),x=e=>{var n=DL(),r=M(n,!0);T(n),F(()=>B(r,I(t).pane.savingsLabel)),z(e,n)};V(b,e=>{I(t).pane.savingsLabel&&e(x)});var S=P(b,2),C=e=>{var n=TL(),r=M(n,!0);T(n),F(e=>{U(n,1,`audit-status-badge ${e??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.statusCode)},[()=>WP(I(t).pane.statusCode)]),z(e,n)};V(S,e=>{I(t).pane.statusCode&&e(C)}),T(n),F((e,r)=>{c=U(n,1,`audit-pane-tab svelte-1bc5vi5`,null,c,{"audit-pane-tab-active":I(i)===I(t).id}),W(n,`aria-selected`,I(i)===I(t).id),W(n,`id`,e),W(n,`aria-controls`,r),W(n,`tabindex`,I(i)===I(t).id?0:-1),U(l,1,Li([`audit-pane-icon`,I(t).pane.direction&&`audit-pane-icon-${I(t).pane.direction}`]),`svelte-1bc5vi5`),B(m,I(t).pane.title)},[()=>a(I(t).id),()=>o(I(t).id)]),L(`keydown`,n,e=>s(e,I(t).id)),L(`click`,n,()=>A(r,I(t).id,!0)),z(e,n)}),T(l),H(P(l,2),17,n,e=>e.id,(e,t)=>{var n=kL();let r;CL(M(n),{get pane(){return I(t).pane}}),T(n),F((e,a)=>{W(n,`id`,e),W(n,`aria-labelledby`,a),r=Wi(n,``,r,{display:I(i)===I(t).id?null:`none`})},[()=>o(I(t).id),()=>a(I(t).id)]),z(e,n)}),T(c),z(e,c),D()}Hr([`keydown`,`click`]);var ML=R(`
                    `),NL=R(`
                    `);function PL(e,t){E(t,!0);let n=G(t,`thread`,3,null),r=O(()=>DF.isAuditEntryExpanded(t.entry)),i=O(()=>aL.conversationOpen&&String(aL.conversationAnchorID||``)===String(t.entry.id||``)),a=O(()=>I(r)?xF(t.entry,$F):[]),o=O(()=>I(r)?gN(t.entry,dP.auditEntryWorkflow(t.entry),dP.workflowFeatureCaps()):null);function s(){DF.toggleAuditEntryExpanded(t.entry)}var c=NL();let l;var u=M(c);dL(u,{get entry(){return t.entry},get thread(){return n()},get expanded(){return I(r)},onactivate:s});var d=P(u,2),f=e=>{var n=ML(),r=M(n),i=e=>{MM(e,{get chart(){return I(o)}})};V(r,e=>{I(o)&&e(i)});var s=P(r,2);jL(s,{get entry(){return t.entry},get panes(){return I(a)}}),LF(P(s,2),{get entry(){return t.entry}}),T(n),ji(3,n,()=>Js,()=>({y:-6,duration:lP(150)})),z(e,n)};V(d,e=>{I(r)&&e(f)}),T(c),F(()=>l=U(c,1,`audit-entry svelte-cmjgwr`,null,l,{"audit-entry-interactions-open":I(i)})),z(e,c),D()}var FL=R(`
                    `),IL=R(`
                    `),LL=R(`

                    `),RL=R(`
                    `),zL=R(`
                    `);function BL(e,t){E(t,!0);let n=O(()=>DP(t.entry)),r=O(()=>DF.isThreadExpanded(I(n))),i=O(()=>DF.threadChildren(I(n))),a=O(()=>I(i)&&!I(i).loading&&Number(I(i).total||0)>I(i).entries.length+1);var o=Qr(),s=N(o),c=e=>{PL(e,{get entry(){return t.entry}})},l=O(()=>!kP(t.entry)),u=e=>{var n=zL(),o=M(n);{let e=O(()=>({count:OP(t.entry),expanded:I(r),ontoggle:()=>DF.toggleThread(t.entry)}));PL(o,{get entry(){return t.entry},get thread(){return I(e)}})}var s=P(o,2),c=e=>{var t=RL(),n=M(t),r=e=>{var t=FL();CS(M(t),{size:14,label:`Loading session requests`}),T(t),z(e,t)};V(n,e=>{I(i)&&I(i).loading&&e(r)});var o=P(n,2);H(o,17,()=>I(i)&&I(i).entries||[],e=>e.id,(e,t)=>{var n=IL();PL(M(n),{get entry(){return I(t)}}),T(n),z(e,n)});var s=P(o,2),c=e=>{var t=LL(),n=M(t);T(t),F(()=>B(n,`Showing the latest ${I(i).entries.length+1} of ${I(i).total??``} + requests in this session.`)),z(e,t)};V(s,e=>{I(a)&&e(c)}),T(t),ji(3,t,()=>Ys,()=>({duration:lP(150)})),z(e,t)};V(s,e=>{I(r)&&e(c)}),T(n),z(e,n)};V(s,e=>{I(l)?e(c):e(u,-1)}),z(e,o),D()}var VL=R(`

                    .

                    `),HL=R(`
                    Audit logging is off. Live entries are temporary and disappear after + refresh. Set LOGGING_ENABLED=true to persist them.
                    `),UL=R(`

                    `),WL=R(`
                    `),GL=R(`
                    `),KL=R(`
                    `),qL=R(`
                    `),JL=R(`
                    `);function YL(e,t){E(t,!0);let n=O(()=>Cs.config&&Cs.config.LOGGING_RETENTION_DAYS);An(()=>{if(q.refreshTick,Yo.page===`audit-logs`)return Er(()=>r())});function r(){let e=!1;return(async()=>{try{await Cs.ensureLoaded()}finally{await DF.fetchAuditLog(!0),!e&&Cs.liveLogsVisible()&&NC.ensureLiveLogs()}})(),()=>{e=!0,NC.stopLiveLogs()}}var i=JL(),a=M(i),o=M(a),s=P(M(o),2),c=e=>{JS(e,{copyId:`audit-retention-help-copy`,label:`retention help`,text:`If you want to change the retention period, set LOGGING_RETENTION_DAYS (env var) or logging.retention_days (config.yaml) and restart the gateway. Default is 30 days; 0 keeps audit logs forever.`,title:e=>{var t=VL(),r=M(t,!0),i=P(r),a=M(i,!0);T(i),Ue(),T(t),F((e,t)=>{B(r,e),B(a,t)},[()=>CP(I(n)),()=>wP(I(n))]),z(e,t)},$$slots:{title:!0}})},l=O(()=>SP(I(n)));V(s,e=>{I(l)&&e(c)}),T(o),T(a);var u=P(a,2);nl(M(u),{onchange:()=>DF.fetchAuditLog(!0)}),T(u);var d=P(u,2);Ic(d,{});var f=P(d,2),p=e=>{z(e,HL())},m=O(()=>Cs.loaded&&!Cs.auditVisible()&&!q.needsAuth);V(f,e=>{I(m)&&e(p)});var h=P(f,2),g=M(h);kF(g,{});var _=P(g,2),v=M(_),y=M(v),b=e=>{var t=UL(),n=M(t);T(t),F(e=>B(n,`Showing ${DF.auditLog.offset+1}-${e??``} of ${DF.auditLog.total??``} + ${DF.auditGroupSessions?`sessions`:`logs`}`),[()=>Math.min(DF.auditLog.offset+DF.auditLog.limit,DF.auditLog.total)]),z(e,t)};V(y,e=>{DF.auditLog.total>0&&e(b)});var x=P(y,2),S=M(x);ia(S),Ue(2),T(x),T(v),PF(P(v,2),{}),T(_);var C=P(_,2),w=e=>{var t=WL();CS(M(t),{size:18,label:`Loading audit logs`}),T(t),z(e,t)},ee=e=>{var t=KL();H(t,29,()=>DF.auditLog.entries,e=>e.id,(e,t)=>{var n=GL(),r=M(n),i=e=>{BL(e,{get entry(){return I(t)}})},a=e=>{PL(e,{get entry(){return I(t)}})};V(r,e=>{DF.auditGroupSessions?e(i):e(a,-1)}),T(n),Ai(n,()=>aP,()=>({duration:lP(150)})),ji(1,n,()=>uP,()=>({live:I(t)._live})),z(e,n)}),T(t),z(e,t)};V(C,e=>{DF.loading&&DF.auditLog.entries.length===0?e(w):DF.auditLog.entries.length>0&&e(ee,1)});var te=P(C,2),ne=e=>{var t=qL();ES(M(t),{}),T(t),z(e,t)};V(te,e=>{DF.auditLog.entries.length===0&&!DF.loading&&!q.needsAuth&&e(ne)}),Xw(P(te,2),{get total(){return DF.auditLog.total},get offset(){return DF.auditLog.offset},get limit(){return DF.auditLog.limit},onprev:()=>DF.auditLogPrevPage(),onnext:()=>DF.auditLogNextPage()}),T(h),T(i),F(()=>oa(S,DF.auditGroupSessions)),L(`change`,S,()=>DF.toggleAuditGroupSessions()),z(e,i),D()}Hr([`change`]);function XL(e){try{let t=JSON.parse(JSON.stringify(e||{}));return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function ZL(e){return Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(e=>e):e==null?[]:String(e).split(`,`).map(e=>e.trim()).filter(e=>e)}function QL(e,t){let n=String(t||``).trim();return(e||[]).find(e=>String(e&&e.type||``).trim()===n)||null}function $L(e){return Array.isArray(e)&&e.length>0&&String(e[0].type||``).trim()||`system_prompt`}function eR(e,t){let n=String(t||``).trim();return n&&QL(e,n)?n:$L(e)}function tR(e,t){let n=QL(e,t);return!n||!n.defaults?{}:XL(n.defaults)}function nR(e,t,n){return{...tR(e,n),...XL(t)}}function rR(e,t){let n=eR(e,t);return{name:``,type:n,description:``,user_path:``,config:tR(e,n)}}function iR(e,t){if(!t)return e||[];let n=String(t).toLowerCase();return(e||[]).filter(e=>[e.name,e.type,e.user_path,e.description,e.summary].some(e=>String(e||``).toLowerCase().includes(n)))}function aR(e,t){let n=QL(e,t);return n&&n.label?n.label:t||`Unknown`}function oR(e,t){let n=QL(e,t);return Array.isArray(n&&n.fields)?n.fields:[]}function sR(e,t){if(!t||!e)return t&&t.input===`checkboxes`?[]:``;let n=e[t.key];return n==null?t.input===`checkboxes`?[]:``:t.input===`checkboxes`?ZL(n):n}function cR(e,t,n){if(!t)return e;let r=XL(e);if(t.input===`number`){let e=String(n||``).trim();if(e===``)delete r[t.key];else{let n=Number(e);r[t.key]=Number.isFinite(n)?n:e}}else t.input===`checkboxes`?r[t.key]=ZL(n):r[t.key]=n;return r}function lR(e,t,n){return sR(e,t).includes(String(n||``).trim())}function uR(e,t,n,r){let i=ZL(sR(e,t)),a=String(n||``).trim();return a?cR(e,t,r?Array.from(new Set([...i,a])):i.filter(e=>e!==a)):e}function dR(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),description:String(e&&e.description||``).trim()||void 0,user_path:String(e&&e.user_path||``).trim()||void 0,config:XL(e&&e.config)}}var fR=new class{#e=k(j([]));get guardrails(){return I(this.#e)}set guardrails(e){A(this.#e,e,!0)}#t=k(j([]));get types(){return I(this.#t)}set types(e){A(this.#t,e,!0)}#n=k(!0);get available(){return I(this.#n)}set available(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=k(!1);get typesLoading(){return I(this.#i)}set typesLoading(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(``);get filter(){return I(this.#o)}set filter(e){A(this.#o,e,!0)}#s=k(!1);get formOpen(){return I(this.#s)}set formOpen(e){A(this.#s,e,!0)}#c=k(!1);get formSubmitting(){return I(this.#c)}set formSubmitting(e){A(this.#c,e,!0)}#l=k(``);get deletingName(){return I(this.#l)}set deletingName(e){A(this.#l,e,!0)}#u=k(`create`);get formMode(){return I(this.#u)}set formMode(e){A(this.#u,e,!0)}#d=k(``);get formOriginalName(){return I(this.#d)}set formOriginalName(e){A(this.#d,e,!0)}#f=k(j({name:``,type:``,description:``,user_path:``,config:{}}));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}get filtered(){return iR(this.guardrails,this.filter)}typeLabel(e){return aR(this.types,e)}typeFields(e){return oR(this.types,e)}fieldValue(e){return sR(this.form&&this.form.config,e)}setFieldValue(e,t){this.form={...this.form,config:cR(this.form.config,e,t)}}arrayFieldSelected(e,t){return lR(this.form&&this.form.config,e,t)}toggleArrayFieldValue(e,t,n){this.form={...this.form,config:uR(this.form.config,e,t,n)}}openCreate(){this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=rR(this.types,$L(this.types)),this.formOpen=!0}openEdit(e){let t=eR(this.types,e&&e.type);this.formMode=`edit`,this.formOriginalName=String(e&&e.name||``).trim(),this.error=``,this.form={name:this.formOriginalName,type:t,description:String(e&&e.description||``).trim(),user_path:String(e&&e.user_path||``).trim(),config:nR(this.types,e&&e.config,t)},this.formOpen=!0}closeForm(){this.formOpen=!1,this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=rR(this.types,$L(this.types))}changeType(e){let t=eR(this.types,e);this.form={...this.form,type:t,config:tR(this.types,t)}}async fetchTypes(){this.typesLoading=!0;try{let e=await yT(`/admin/guardrails/types`,{label:`guardrail types`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.types=[];return}if(e.result&&(this.available=!0),this.types=e.items,e.status===`error`){this.error=e.error;return}let t=eR(this.types,this.form.type);this.form={...this.form,type:t,config:nR(this.types,this.form.config,t)}}finally{this.typesLoading=!1}}async fetchGuardrails(){this.loading=!0,this.error=``;try{let e=await yT(`/admin/guardrails`,{label:`guardrails`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.guardrails=[];return}e.result&&(this.available=!0),this.guardrails=e.items,this.error=e.error}finally{this.loading=!1}}async fetchPage(){await Promise.all([this.fetchTypes(),this.fetchGuardrails()])}async submitForm(){let e=String(this.form.name||``).trim(),t=String(this.form.type||``).trim();if(!e){this.error=`Name is required.`;return}if(!t){this.error=`Type is required.`;return}this.error=``,this.formSubmitting=!0;let n=dR(this.form);try{let t=await bT(`/admin/guardrails`,`PUT`,n,{label:`save guardrail`,errorFallback:`Failed to save guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}J.success(`Guardrail "`+e+`" saved.`),this.closeForm(),this.fetchGuardrails()}finally{this.formSubmitting=!1}}async deleteGuardrail(e){let t=String(e&&e.name||``).trim();if(!(!t||this.deletingName)&&window.confirm(`Delete guardrail "`+t+`"? Workflows that still reference it must be updated first.`)){this.deletingName=t;try{let e=await bT(`/admin/guardrails`,`DELETE`,{name:t},{label:`delete guardrail`,errorFallback:`Failed to delete guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}J.success(`Guardrail "`+t+`" deleted.`),this.formOpen&&this.formOriginalName===t&&this.closeForm(),this.fetchGuardrails()}finally{this.deletingName=``}}}},pR=R(`
                    `),mR=R(`

                    Loading guardrails...

                    `),hR=R(`
                    `),gR=R(`
                    `),_R=R(`
                    NameTypeUser PathSummaryActions
                    `),vR=R(`

                    No guardrails defined yet.

                    `),yR=R(`

                    Instances

                    Each instance has a reusable name, a type, an optional user path for + future UI visibility scoping, and a JSON-backed config payload for + that type.

                    `);function bR(e,t){E(t,!0);var n=yR(),r=M(n),i=P(M(r),2);K(M(i),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(i),T(r);var a=P(r,2),o=e=>{var t=pR(),n=M(t);xw(M(n),{id:`guardrail-filter`,placeholder:`Filter by name, type, user path, summary...`,label:`Guardrail filter`,get value(){return fR.filter},set value(e){fR.filter=e}}),T(n),T(t),z(e,t)};V(a,e=>{fR.available&&e(o)});var s=P(a,2),c=e=>{var t=mR();CS(M(t),{size:16,label:`Loading guardrails`}),Ue(),T(t),z(e,t)};V(s,e=>{fR.loading&&fR.filtered.length===0&&e(c)});var l=P(s,2),u=e=>{var t=_R(),n=M(t),r=P(M(n));H(r,21,()=>fR.filtered,e=>e.name,(e,t)=>{var n=gR(),r=M(n),i=M(r,!0);T(r);var a=P(r),o=M(a),s=M(o,!0);T(o),T(a);var c=P(a),l=M(c,!0);T(c);var u=P(c),d=M(u),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var n=hR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(p,e=>{I(t).description&&e(m)}),T(u);var h=P(u),g=M(h),_=M(g);{let e=O(()=>`Edit guardrail `+I(t).name);vT(_,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>fR.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}var v=P(_,2);{let e=O(()=>(fR.deletingName===I(t).name?`Deleting guardrail `:`Delete guardrail `)+I(t).name),n=O(()=>fR.deletingName===I(t).name);vT(v,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>fR.deleteGuardrail(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return Lo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(g),T(h),T(n),F(e=>{B(i,I(t).name),B(s,e),B(l,I(t).user_path||`—`),B(f,I(t).summary||I(t).description||`No summary yet.`)},[()=>fR.typeLabel(I(t).type)]),z(e,n)}),T(r),T(n),T(t),z(e,t)};V(l,e=>{fR.filtered.length>0&&e(u)});var d=P(l,2),f=e=>{z(e,vR())};V(d,e=>{fR.filtered.length===0&&!fR.loading&&fR.available&&!fR.error&&!q.authError&&e(f)}),T(n),F(()=>i.disabled=fR.typesLoading||fR.formSubmitting||!fR.available),L(`click`,i,()=>fR.openCreate()),z(e,n),D()}Hr([`click`]);var xR=R(`

                    Workflows reference these names directly, so renames are + intentionally avoided after creation.

                    `),SR=R(``),CR=R(``),wR=R(``),TR=R(``),ER=R(``),DR=R(``),OR=R(``),kR=R(``),AR=R(``),jR=R(`
                    `),MR=R(``),NR=R(` `),PR=R(`
                    `),FR=R(`
                    `);function IR(e,t){E(t,!0);let n=O(()=>fR.formMode===`edit`);{let t=e=>{z(e,xR())},r=O(()=>I(n)?`Edit Guardrail`:`Create Guardrail`);SE(e,{get open(){return fR.formOpen},get title(){return I(r)},ariaLabel:`Guardrail editor`,get error(){return fR.error},get submitting(){return fR.formSubmitting},submitLabel:`Save Guardrail`,dialogClass:`settings-guardrails-editor guardrails-editor-wide`,onclose:()=>fR.closeForm(),onsubmit:()=>fR.submitForm(),headerHint:t,children:(e,t)=>{var r=FR(),i=M(r);wE(i,{id:`guardrail-name`,label:`Name`,children:(e,t)=>{var r=SR();ia(r),F(()=>{r.disabled=I(n),W(r,`data-modal-autofocus`,!I(n)||void 0)}),pa(r,()=>fR.form.name,e=>fR.form.name=e),z(e,r)},$$slots:{default:!0}});var a=P(i,2);wE(a,{id:`guardrail-type`,label:`Type`,children:(e,t)=>{var r=wR();H(r,21,()=>fR.types,e=>e.type,(e,t)=>{var n=CR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).type)&&(n.value=(n.__value=I(t).type)??``)}),z(e,n)}),T(r);var i;Ki(r),F(()=>{r.disabled=I(n),i!==(i=fR.form.type)&&(r.value=(r.__value=fR.form.type)??``,Gi(r,fR.form.type))}),L(`change`,r,e=>fR.changeType(e.currentTarget.value)),z(e,r)},$$slots:{default:!0}});var o=P(a,2);wE(o,{id:`guardrail-description`,label:`Description`,children:(e,t)=>{var r=TR();ia(r),F(()=>W(r,`data-modal-autofocus`,I(n)?!0:void 0)),pa(r,()=>fR.form.description,e=>fR.form.description=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2),c=M(s);JS(c,{copyId:`guardrail-user-path-help-copy`,label:`guardrail user path help`,text:`Only used for auxiliary rewrite (llm_based_altering) guardrails; ignored for other guardrail types.`,title:e=>{z(e,ER())},$$slots:{title:!0}});var l=P(c,2);ia(l),T(s),H(P(s,2),17,()=>fR.typeFields(fR.form.type),e=>e.key,(e,t)=>{var n=Qr(),r=N(n),i=e=>{var n=jR(),r=M(n);{let e=e=>{var n=DR(),r=M(n,!0);T(n),F(()=>{W(n,`for`,`guardrail-field-`+I(t).key),B(r,I(t).label)}),z(e,n)},n=O(()=>`guardrail-field-help-`+I(t).key),i=O(()=>I(t).label+` help`),a=O(()=>I(t).help||``);JS(r,{get copyId(){return I(n)},get label(){return I(i)},get text(){return I(a)},title:e,$$slots:{title:!0}})}var i=P(r,2),a=e=>{var n=OR();H(n,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=CR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n);var r;Ki(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),r!==(r=e)&&(n.value=(n.__value=e)??``,Gi(n,e))},[()=>fR.fieldValue(I(t))]),L(`change`,n,e=>fR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},o=e=>{var n=kR();ft(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`placeholder`,I(t).placeholder||``),aa(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>fR.fieldValue(I(t))]),L(`input`,n,e=>fR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},s=e=>{var n=AR();ia(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`type`,I(t).input||`text`),W(n,`placeholder`,I(t).placeholder||``),aa(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>fR.fieldValue(I(t))]),L(`input`,n,e=>fR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)};V(i,e=>{I(t).input===`select`?e(a):I(t).input===`textarea`?e(o,1):e(s,-1)}),T(n),z(e,n)},a=e=>{var n=PR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).options||[],e=>I(t).key+`-`+e.value,(e,n)=>{var r=MR(),i=M(r);ia(i);var a=P(i,2),o=M(a,!0);T(a),T(r),F(e=>{oa(i,e),B(o,I(n).label)},[()=>fR.arrayFieldSelected(I(t),I(n).value)]),L(`change`,i,e=>fR.toggleArrayFieldValue(I(t),I(n).value,e.currentTarget.checked)),z(e,r)}),T(a);var o=P(a,2),s=e=>{var n=NR(),r=M(n,!0);T(n),F(()=>{W(n,`id`,`guardrail-field-help-`+I(t).key),B(r,I(t).help)}),z(e,n)};V(o,e=>{I(t).help&&e(s)}),T(n),F(()=>{W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),B(i,I(t).label)}),z(e,n)};V(r,e=>{I(t).input===`checkboxes`?e(a,-1):e(i)}),z(e,n)}),T(r),pa(l,()=>fR.form.user_path,e=>fR.form.user_path=e),z(e,r)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var LR=R(`

                    Guardrails

                    `),RR=R(`
                    Runtime guardrail execution is currently off because GUARDRAILS_ENABLED is disabled. You can still manage + definitions here.
                    `),zR=R(`
                    Guardrails feature is unavailable.
                    `),BR=R(`
                    `),VR=R(`

                    Reusable Policy Objects

                    Guardrail Library

                    Store guardrails in the database, keep them hot in memory, and attach + them to workflows by reference.

                    Instances
                    Types
                    `);function HR(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`guardrails`&&(Cs.ensureLoaded(),fR.fetchPage())});var n=VR(),r=M(n),i=M(r);JS(M(i),{copyId:`guardrails-help-copy`,label:`guardrails help`,text:`Reusable policy objects stored in the database and kept hot in memory for workflow execution.`,title:e=>{z(e,LR())},$$slots:{title:!0}}),T(i),T(r);var a=P(r,2),o=P(M(a),2),s=M(o),c=P(M(s),2),l=M(c,!0);T(c),T(s);var u=P(s,2),d=P(M(u),2),f=M(d,!0);T(d),T(u),T(o),T(a);var p=P(a,2);Ic(p,{});var m=P(p,2),h=e=>{z(e,RR())},g=O(()=>!Cs.guardrailsVisible());V(m,e=>{I(g)&&e(h)});var _=P(m,2),v=e=>{z(e,zR())};V(_,e=>{!q.authError&&!fR.available&&e(v)});var y=P(_,2),b=e=>{var t=BR(),n=M(t,!0);T(t),F(()=>B(n,fR.error)),z(e,t)};V(y,e=>{!q.authError&&fR.error&&!fR.formOpen&&e(b)});var x=P(y,2);IR(x,{}),bR(P(x,2),{}),T(n),F((e,t)=>{B(l,e),B(f,t)},[()=>sc(fR.guardrails.length),()=>sc(fR.types.length)]),z(e,n),D()}var Q=new class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get slugEdited(){return I(this.#c)}set slugEdited(e){A(this.#c,e,!0)}#l=k(!1);get advancedOpen(){return I(this.#l)}set advancedOpen(e){A(this.#l,e,!0)}#u=k(j(fx()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(``);get deletingName(){return I(this.#d)}set deletingName(e){A(this.#d,e,!0)}#f=k(``);get reconnectingName(){return I(this.#f)}set reconnectingName(e){A(this.#f,e,!0)}#p=k(!1);get catalogOpen(){return I(this.#p)}set catalogOpen(e){A(this.#p,e,!0)}#m=k(!1);get catalogLoading(){return I(this.#m)}set catalogLoading(e){A(this.#m,e,!0)}#h=k(``);get catalogError(){return I(this.#h)}set catalogError(e){A(this.#h,e,!0)}#g=k(j(px()));get catalog(){return I(this.#g)}set catalog(e){A(this.#g,e,!0)}#_=O(()=>wx(this.servers,this.filter));get filtered(){return I(this.#_)}set filtered(e){A(this.#_,e)}async fetchServers(){if(await Cs.ensureLoaded(),!Cs.mcpVisible()){this.available=!1,this.servers=[],this.error=``,this.loading=!1;return}this.loading=!0,this.error=``;try{let e=await yT(`/admin/mcp-servers`,{label:`mcp servers`,errorFallback:`Failed to load MCP servers.`,unavailableStatuses:[503,404]});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.servers=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.servers=[],this.error=e.error;return}this.available=!0,this.servers=e.items}finally{this.loading=!1}}openCreate(){this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=fx(),this.formOpen=!0}openEdit(e){!e||e.managed||(this.formMode=`edit`,this.slugEdited=!0,this.advancedOpen=!1,this.error=``,this.form=Tx(e),this.formOpen=!0)}closeForm(){this.formOpen=!1,this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=fx()}syncSlugFromName(){this.formMode===`create`&&!this.slugEdited&&(this.form.slug=bx(this.form.name))}markSlugEdited(){this.formMode===`create`&&(this.slugEdited=!0)}addHeader(){this.form.headers.push({name:``,value:``})}removeHeader(e){this.form.headers.splice(e,1)}async submitForm(){let e=Ex(this.form,this.formMode,this.servers);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await bT(`/admin/mcp-servers`,`PUT`,e.payload,{label:`save mcp server`,errorFallback:`Failed to save MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}J.success(`MCP server "`+e.payload.name+`" saved.`),this.closeForm(),this.fetchServers()}finally{this.formSubmitting=!1}}async deleteServer(e){let t=String(e&&e.name||``).trim(),n=mx(e);if(!(!n||this.deletingName||e&&e.managed)&&confirm(`Delete MCP server "`+t+`"? Clients lose access to its tools immediately.`)){this.deletingName=n;try{let e=await bT(`/admin/mcp-servers/`+encodeURIComponent(n),`DELETE`,void 0,{label:`delete mcp server`,errorFallback:`Failed to delete MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}J.success(`MCP server "`+t+`" deleted.`),this.formOpen&&this.form.slug===n&&this.closeForm(),this.fetchServers()}finally{this.deletingName=``}}}async reconnectServer(e){let t=String(e&&e.name||``).trim(),n=mx(e);if(!(!n||this.reconnectingName)){this.reconnectingName=n;try{let e=await bT(`/admin/mcp-servers/`+encodeURIComponent(n)+`/reconnect`,`POST`,void 0,{label:`reconnect mcp server`,errorFallback:`Failed to reconnect MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,J.error(e.error);return}if(e.status===`error`){J.error(e.error);return}let r=e.result.data,i=hx(r);i===`connected`?J.success(`MCP server "`+t+`" reconnected.`):i===`disabled`?J.success(`MCP server "`+t+`" is disabled; no connection was attempted.`):J.error(`Reconnect attempted, but MCP server "`+t+`" is still `+i+`.`),r&&r.name?this.servers=(this.servers||[]).map(e=>mx(e)===mx(r)?r:e):this.fetchServers()}finally{this.reconnectingName=``}}}async openCatalog(e){let t=String(e&&e.name||``).trim(),n=mx(e);if(n){this.catalogOpen=!0,this.catalogLoading=!0,this.catalogError=``,this.catalog={...px(),server:n,status:hx(e)};try{let e=await vs(`/admin/mcp-servers/`+encodeURIComponent(n)+`/catalog`,{label:`mcp server catalog`});if(e.stale)return;if(e.status===503){this.available=!1,this.catalogError=`MCP server management is unavailable.`;return}if(e.status===404){this.catalogError=`MCP server "`+t+`" was not found.`;return}if(!e.ok){this.catalogError=e.status===401?`Authentication required.`:ps(e.data,`Failed to load MCP server catalog.`);return}this.catalog=Dx(n,e.data)}catch(e){console.error(`Failed to load MCP server catalog:`,e),this.catalogError=`Failed to load MCP server catalog.`}finally{this.catalogLoading=!1}}}closeCatalog(){this.catalogOpen=!1,this.catalogLoading=!1,this.catalogError=``,this.catalog=px()}},UR=R(``),WR=R(`

                    `),GR=R(`
                    `),KR=R(`

                    `),qR=R(`
                  • `),JR=R(`

                      `),YR=R(`

                      No tools listed — the server may still be connecting or degraded.

                      `),XR=R(` `,1),ZR=R(``);function QR(e,t){E(t,!0);let n=O(()=>kx(Q.catalog));Ps(e,{get open(){return Q.catalogOpen},variant:`editor`,onclose:()=>Q.closeCatalog(),children:(e,t)=>{var r=ZR(),i=M(r),a=M(i),o=P(M(a),2),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l),T(o),T(a),As(P(a,2),{label:`Close MCP server catalog`,onclick:()=>Q.closeCatalog()}),T(i);var d=P(i,2),f=e=>{gT(e,{label:`Loading catalog...`})},p=e=>{var t=UR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalogError)),z(e,t)},m=e=>{var t=XR(),r=N(t),i=e=>{var t=WR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalog.instructions)),z(e,t)};V(r,e=>{Q.catalog.instructions&&e(i)});var a=P(r,2);H(a,17,()=>I(n),e=>e.key,(e,t)=>{var n=JR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).items,e=>e.key,(e,t)=>{var n=qR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=GR(),r=M(n,!0);T(n),F(()=>{W(n,`title`,`Exposed on the aggregated /mcp endpoint as `+I(t).aggregated),B(r,I(t).aggregated)}),z(e,n)};V(a,e=>{I(t).aggregated&&e(o)});var s=P(a,2),c=e=>{var n=KR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(s,e=>{I(t).description&&e(c)}),T(n),F(()=>{W(r,`title`,I(t).aggregated||I(t).name),B(i,I(t).name)}),z(e,n)}),T(a),T(n),F(()=>B(i,I(t).title)),z(e,n)});var o=P(a,2),s=e=>{z(e,YR())},c=O(()=>Ax(Q.catalog));V(o,e=>{I(c)&&e(s)}),z(e,t)};V(d,e=>{Q.catalogLoading?e(f):Q.catalogError?e(p,1):e(m,-1)});var h=P(d,2),g=M(h);T(h),T(r),F((e,t)=>{B(c,Q.catalog.server),U(l,1,`audit-status-badge ${e??``}`,`svelte-1xqrzco`),B(u,t)},[()=>gx(Q.catalog),()=>hx(Q.catalog)]),L(`click`,g,()=>Q.closeCatalog()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var $R=R(`

                      The display name can change. The slug is the stable client-facing identity.

                      `),ez=R(` Human-readable and Unicode-friendly. You can change it later.`,1),tz=R(`Derived from the name. You may edit it before saving.`),nz=R(`Immutable because it is used in URLs, scope headers, and aggregated tool names.`),rz=R(` `,1),iz=R(` stdio servers are config-only: declare them in config.yaml under mcp.servers.`,1),az=R(``),oz=R(`
                      `),sz=R(`
                      Headers
                      Sent only to the configured server origin. Saved values are shown as ***; leave *** unchanged to keep the stored value.
                      Advanced settings Description, access rules, and timeout
                      `,1);function cz(e,t){E(t,!0);{let t=e=>{z(e,$R())},n=O(()=>Q.formMode===`edit`?`Edit MCP Server`:`Add MCP Server`);SE(e,{get open(){return Q.formOpen},get title(){return I(n)},ariaLabel:`MCP server editor`,get error(){return Q.error},get submitting(){return Q.formSubmitting},onclose:()=>Q.closeForm(),onsubmit:()=>Q.submitForm(),headerHint:t,children:(e,t)=>{var n=sz(),r=N(n);wE(r,{id:`mcp-server-name`,label:`Name`,children:(e,t)=>{var n=ez(),r=N(n);ia(r),Ue(2),L(`input`,r,()=>Q.syncSlugFromName()),pa(r,()=>Q.form.name,e=>Q.form.name=e),z(e,n)},$$slots:{default:!0}});var i=P(r,2);wE(i,{id:`mcp-server-slug`,label:`Slug`,children:(e,t)=>{var n=rz(),r=N(n);ia(r);var i=P(r,2),a=e=>{z(e,tz())},o=e=>{z(e,nz())};V(i,e=>{Q.formMode===`create`?e(a):e(o,-1)}),F(()=>r.disabled=Q.formMode===`edit`),L(`input`,r,()=>Q.markSlugEdited()),pa(r,()=>Q.form.slug,e=>Q.form.slug=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);wE(a,{id:`mcp-server-transport`,label:`Transport`,children:(e,t)=>{var n=iz(),r=N(n),i=M(r);i.value=i.__value=`http`;var a=P(i);a.value=a.__value=`sse`,T(r),Ue(2),qi(r,()=>Q.form.transport,e=>Q.form.transport=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);wE(o,{id:`mcp-server-url`,label:`URL`,children:(e,t)=>{var n=az();ia(n),pa(n,()=>Q.form.url,e=>Q.form.url=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=P(M(s),2);H(c,21,()=>Q.form.headers,ci,(e,t,n)=>{var r=oz(),i=M(r);ia(i);var a=P(i,2);ia(a),vT(P(a,2),{label:`Remove header`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Q.removeHeader(n),children:(e,t)=>{K(e,{get icon(){return jo},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),pa(i,()=>I(t).name,e=>I(t).name=e),pa(a,()=>I(t).value,e=>I(t).value=e),z(e,r)}),T(c);var l=P(c,2),u=M(l);K(M(u),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(u),T(l),Ue(2),T(s);var d=P(s,2),f=M(d);SA(M(f),{get enabled(){return Q.form.enabled},label:`MCP server`,onclick:()=>Q.form.enabled=!Q.form.enabled}),T(f),T(d);var p=P(d,2),m=P(M(p),2),h=M(m),g=P(M(h),2);ia(g),T(h);var _=P(h,2),v=P(M(_),2);ia(v),T(_);var y=P(_,2),b=P(M(y),2);ia(b),T(y);var x=P(y,2),S=P(M(x),2);ft(S),W(S,`placeholder`,`/ +/team/alpha`),T(x);var C=P(x,2),w=P(M(C),2);ia(w),T(C),T(m),T(p),F(()=>p.open=Q.advancedOpen),L(`click`,u,()=>Q.addHeader()),Vr(`toggle`,p,e=>Q.advancedOpen=e.currentTarget.open),pa(g,()=>Q.form.description,e=>Q.form.description=e),pa(v,()=>Q.form.allowed_tools,e=>Q.form.allowed_tools=e),pa(b,()=>Q.form.disallowed_tools,e=>Q.form.disallowed_tools=e),pa(S,()=>Q.form.user_paths,e=>Q.form.user_paths=e),pa(w,()=>Q.form.tool_timeout_seconds,e=>Q.form.tool_timeout_seconds=e),z(e,n)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`input`,`click`]);var lz=R(`Config`),uz=R(`
                      `),dz=R(`
                      `),fz=R(`
                      NameTransportEndpointStatusToolsEnabledActions
                      `);function pz(e,t){E(t,!0);function n(e){return _x(e,e=>fs.formatTimestamp(e))}var r=fz(),i=M(r),a=P(M(i));H(a,21,()=>Q.filtered,e=>mx(e),(e,t)=>{var r=dz(),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=e=>{z(e,lz())};V(s,e=>{I(t).managed&&e(c)});var l=P(s,2),u=M(l,!0);T(l),T(i);var d=P(i),f=M(d),p=M(f,!0);T(f),T(d);var m=P(d),h=M(m,!0);T(m);var g=P(m),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=e=>{var n=uz(),r=M(n,!0);T(n),F(()=>B(r,I(t).last_error)),z(e,n)},x=O(()=>hx(I(t))===`degraded`&&I(t).last_error);V(y,e=>{I(x)&&e(b)}),T(g);var S=P(g),C=M(S),w=M(C,!0);T(C);var ee=P(C,2),te=M(ee,!0);T(ee),T(S);var ne=P(S),re=M(ne),ie=M(re,!0);T(re),T(ne);var ae=P(ne),oe=M(ae),se=M(oe),ce=e=>{{let n=O(()=>`Edit MCP server `+I(t).name);vT(e,{get label(){return I(n)},class:`table-icon-btn`,onclick:()=>Q.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(se,e=>{I(t).managed||e(ce)});var le=P(se,2);{let e=O(()=>`Inspect catalog of MCP server `+I(t).name);vT(le,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.openCatalog(I(t)),children:(e,t)=>{K(e,{get icon(){return ao},class:`form-action-icon`})},$$slots:{default:!0}})}var ue=P(le,2);{let e=O(()=>(Q.reconnectingName===mx(I(t))?`Reconnecting MCP server `:`Reconnect MCP server `)+I(t).name),n=O(()=>Q.reconnectingName===mx(I(t)));vT(ue,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.reconnectServer(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return go},class:`form-action-icon`})},$$slots:{default:!0}})}var de=P(ue,2),fe=e=>{{let n=O(()=>(Q.deletingName===mx(I(t))?`Deleting MCP server `:`Delete MCP server `)+I(t).name),r=O(()=>Q.deletingName===mx(I(t)));vT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>Q.deleteServer(I(t)),get disabled(){return I(r)},children:(e,t)=>{K(e,{get icon(){return Lo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(de,e=>{I(t).managed||e(fe)}),T(oe),T(ae),T(r),F((e,n,r,i,a,s,c,l)=>{B(o,I(t).name),B(u,e),B(p,I(t).transport||`http`),W(m,`title`,n),B(h,r),U(_,1,`audit-status-badge ${i??``}`,`svelte-ah8nrt`),W(_,`title`,a),B(v,s),B(w,c),B(te,l),U(re,1,Li([`auth-key-status-badge`,I(t).enabled?`auth-key-status-active`:`auth-key-status-inactive`])),B(ie,I(t).enabled?`Enabled`:`Disabled`)},[()=>mx(I(t)),()=>vx(I(t)),()=>vx(I(t)),()=>gx(I(t)),()=>n(I(t)),()=>hx(I(t)),()=>sc(I(t).tool_count||0),()=>yx(I(t))]),z(e,r)}),T(a),T(i),T(r),z(e,r),D()}var mz=R(`

                      MCP Servers

                      `),hz=R(``),gz=R(`
                      MCP server management is unavailable.
                      `),_z=R(``),vz=R(`
                      `),yz=R(`

                      No MCP servers yet. Add one here, or declare servers in config.yaml under mcp.servers.

                      `),bz=R(`

                      No MCP servers match your filter.

                      `),xz=R(`
                      `);function Sz(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`mcp-servers`&&Q.fetchServers()});var n=xz(),r=M(n),i=M(r);JS(M(i),{copyId:`mcp-servers-help-copy`,label:`MCP servers help`,text:`Upstream Model Context Protocol servers whose tools, prompts, and resources the gateway exposes to clients. Servers added here connect over HTTP or SSE; stdio servers and rows marked Config are declared in config.yaml under mcp.servers and are read-only in the dashboard. Saved header values are masked in API and dashboard responses.`,title:e=>{z(e,mz())},$$slots:{title:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=hz();K(M(t),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Q.formSubmitting),L(`click`,t,()=>Q.openCreate()),z(e,t)};V(o,e=>{Q.available&&!q.authError&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,gz())};V(c,e=>{!Q.available&&!q.authError&&e(l)});var u=P(c,2),d=e=>{var t=_z(),n=M(t,!0);T(t),F(()=>B(n,Q.error)),z(e,t)};V(u,e=>{Q.error&&!q.authError&&!Q.formOpen&&e(d)});var f=P(u,2),p=e=>{gT(e,{label:`Loading MCP servers...`})};V(f,e=>{Q.loading&&!q.authError&&e(p)});var m=P(f,2),h=e=>{var t=vz(),n=M(t);xw(M(n),{id:`mcp-server-filter`,placeholder:`Filter by name, slug, URL, transport, or status...`,label:`Filter MCP servers by name, slug, URL, transport, or status`,get value(){return Q.filter},set value(e){Q.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{(Q.servers.length>0||Q.filter)&&Q.available&&!q.authError&&e(h)});var g=P(m,2);cz(g,{});var _=P(g,2);QR(_,{});var v=P(_,2),y=e=>{pz(e,{})};V(v,e=>{Q.filtered.length>0&&Q.available&&!q.authError&&e(y)});var b=P(v,2),x=e=>{z(e,yz())};V(b,e=>{Q.servers.length===0&&!Q.filter&&!Q.loading&&!q.authError&&!Q.error&&Q.available&&e(x)});var S=P(b,2),C=e=>{z(e,bz())};V(S,e=>{Q.servers.length>0&&Q.filtered.length===0&&Q.filter&&!Q.loading&&!q.authError&&Q.available&&e(C)}),T(n),z(e,n),D()}Hr([`click`]);var Cz=`api_keys`,wz=`session_sticky_keys`,Tz=`base_url`,Ez=`service_account_json`,Dz=`models`,Oz={[Cz]:{label:`API Keys`,control:`keys`,hint:`Identified sessions stay on one key by default, improving provider prompt-cache hits. Saved values are shown as ***********; leave the asterisks unchanged to keep the stored key.`},[wz]:{label:`Session-sticky API keys`,control:`checkbox`,hint:`Keep each identified conversation on one API key to preserve provider prompt-cache affinity. Turn off to rotate keys round-robin on every request.`},[Tz]:{label:`Base URL`,control:`text`},api_version:{label:`API Version`,control:`text`,placeholder:`e.g. 2024-10-01-preview`,hint:`Leave empty for the provider default. Realtime endpoints may need a newer version.`},backend:{label:`Backend`,control:`select`,hint:`Which Google surface to call. Vertex authenticates with Google credentials instead of an API key.`},auth_type:{label:`Auth Type`,control:`select`,hint:`How to obtain Google credentials. Leave on the default to use Application Default Credentials.`},api_mode:{label:`API Mode`,control:`select`,hint:`Which request shape to send upstream.`},vertex_project:{label:`Vertex Project`,control:`text`,placeholder:`my-gcp-project`},vertex_location:{label:`Vertex Location`,control:`text`,placeholder:`us-central1`},service_account_file:{label:`Service Account File`,control:`text`,placeholder:`/path/to/service-account.json`,hint:`Path readable by the gateway process.`},[Ez]:{label:`Service Account JSON`,control:`textarea`,placeholder:`Paste service account JSON`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value, or clear it to remove.`},service_account_json_base64:{label:`Service Account JSON (base64)`,control:`text`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value.`},gcp_scope:{label:`GCP Scope`,control:`text`,placeholder:`https://www.googleapis.com/auth/cloud-platform`},[Dz]:{label:`Models (comma-separated)`,control:`text`,placeholder:`gpt-4o, gpt-4o-mini`,hint:`Leave empty to auto-discover models from the provider's /models endpoint where supported.`}};function kz(e){return Oz[e]||{label:String(e||``).split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),control:`text`}}function Az(){return{name:``,type:``,api_keys:[],session_sticky_keys:!0,base_url:``,api_version:``,backend:``,auth_type:``,api_mode:``,vertex_project:``,vertex_location:``,service_account_file:``,service_account_json:``,service_account_json_base64:``,gcp_scope:``,models:``,enabled:!0}}function jz(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.type,e.base_url].some(e=>String(e||``).toLowerCase().includes(r)))}function Mz(e,t){let n=(Array.isArray(e)?e:[]).map(e=>String(e&&e.type||``).trim()).filter(Boolean),r=String(t||``).trim();return r&&!n.includes(r)&&n.push(r),n}function Nz(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>String(e&&e.type||``).trim()===n)||null}function Pz(e,t){let n=e&&Array.isArray(e.fields)&&e.fields.length>0?e.fields:Object.keys(Oz).map(e=>({name:e,advanced:e!==Cz})),r=t||e&&e.default_base_url||``,i=[],a=[];for(let e of n){let t=String(e&&e.name||``).trim();if(!t)continue;let n={...kz(t),name:t,required:!!(e&&e.required),options:Array.isArray(e&&e.options)?e.options:[]};t===`base_url`&&r&&(n.placeholder=r,n.hint=`Defaults to `+r),n.options.length>0&&(n.control=`select`),(e&&e.advanced?a:i).push(n)}return{primary:i,advanced:a}}var Fz=new Set([`name`,`type`,`enabled`]);function Iz(e,t){let n=new Set([...t.primary||[],...t.advanced||[]].map(e=>e.name)),r=Az(),i={...e};for(let e of Object.keys(r))!Fz.has(e)&&!n.has(e)&&(i[e]=r[e]);return i}function Lz(e){let t=Array.isArray(e&&e.api_keys)?e.api_keys.length:0;return t>0?t+` key`+(t===1?``:`s`):String(e&&e.service_account_json||``).trim()||String(e&&e.service_account_json_base64||``).trim()||String(e&&e.service_account_file||``).trim()?`service account`:String(e&&e.vertex_project||``).trim()?`ADC`:`keyless`}function Rz(e){let t=Array.isArray(e&&e.models)?e.models:[];return t.length===0?`auto-discovered`:t.length+` model`+(t.length===1?``:`s`)}function zz(e){return(Array.isArray(e)?e:[]).map(e=>({value:String(e||``)}))}function Bz(e){return(Array.isArray(e)?e:[]).map(e=>String(e&&e.value||``))}function Vz(e,t){let n=String(t||``).trim();if(!n)return``;let r=new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.name||``).trim()));if(!r.has(n))return n;let i=1;for(;r.has(n+`-`+i);)i+=1;return n+`-`+i}function Hz(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),api_keys:zz(e&&e.api_keys),session_sticky_keys:!e||e.session_sticky_keys!==!1,base_url:String(e&&e.base_url||``),api_version:String(e&&e.api_version||``),backend:String(e&&e.backend||``),auth_type:String(e&&e.auth_type||``),api_mode:String(e&&e.api_mode||``),vertex_project:String(e&&e.vertex_project||``),vertex_location:String(e&&e.vertex_location||``),service_account_file:String(e&&e.service_account_file||``),service_account_json:String(e&&e.service_account_json||``),service_account_json_base64:String(e&&e.service_account_json_base64||``),gcp_scope:String(e&&e.gcp_scope||``),models:(Array.isArray(e&&e.models)?e.models:[]).join(`, `),enabled:!e||e.enabled!==!1}}function Uz(e){let t=String(e||``).trim();return t.length>=3&&/^\*+$/.test(t)}function Wz(e,t,n,r){let i={},a=String(e&&e.name||``).trim();String(e&&e.type||``).trim()||(i.type=`Select a provider type.`),a?a.includes(`/`)?i.name=`Name cannot contain '/' — it separates the provider from the model.`:t===`create`&&(Array.isArray(n)?n:[]).some(e=>String(e&&e.name||``).trim()===a)&&(i.name=`Provider "`+a+`" already exists.`):i.name=`Name is required.`;let{primary:o,advanced:s}=Pz(r);for(let t of[...o,...s]){let n=Gz(e,t);n&&(i[t.name]=n)}return i}function Gz(e,t){if(t.name===`api_keys`){let n=Bz(e&&e.api_keys);return t.required&&!n.some(e=>e.trim())?`At least one API key is required for this provider type.`:n.some(e=>!e.trim())?`Remove the empty row instead of leaving a key blank.`:``}let n=String(e&&e[t.name]||``).trim();if(t.required&&!n)return t.label+` is required for this provider type.`;if(!n)return``;if(t.name===`base_url`&&!n.includes(`://`)&&/[./]/.test(n))return`Include the scheme, e.g. https://`+n;if(t.name===`service_account_json`&&!Uz(n))try{JSON.parse(n)}catch{return`Paste the service account JSON file's contents — this is not valid JSON.`}return``}function Kz(e,t){let n={name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),enabled:!!(e&&e.enabled)},{primary:r,advanced:i}=Pz(t),a=!!(t&&Array.isArray(t.fields)&&t.fields.length>0),o=new Set;for(let t of[...r,...i])!a&&t.name===`session_sticky_keys`||(o.add(t.name),n[t.name]=qz(e,t.name));for(let t of Object.keys(Oz)){if(o.has(t)||t===`session_sticky_keys`)continue;let r=qz(e,t);(Array.isArray(r)?r.length>0:String(r).trim()!==``)&&(n[t]=r)}return n}function qz(e,t){switch(t){case Cz:return Bz(e&&e.api_keys);case Dz:return ac(e&&e.models);case wz:return!!(e&&e.session_sticky_keys);case Ez:return e&&e.service_account_json||``;default:return String(e&&e[t]||``).trim()}}var $=new class{#e=k(j([]));get rows(){return I(this.#e)}set rows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get advancedOpen(){return I(this.#c)}set advancedOpen(e){A(this.#c,e,!0)}#l=k(j(Az()));get form(){return I(this.#l)}set form(e){A(this.#l,e,!0)}#u=k(j({}));get fieldErrors(){return I(this.#u)}set fieldErrors(e){A(this.#u,e,!0)}#d=k(``);get focusField(){return I(this.#d)}set focusField(e){A(this.#d,e,!0)}#f=k(``);get deletingName(){return I(this.#f)}set deletingName(e){A(this.#f,e,!0)}#p=k(!1);get deleteSubmitting(){return I(this.#p)}set deleteSubmitting(e){A(this.#p,e,!0)}#m=k(j([]));get types(){return I(this.#m)}set types(e){A(this.#m,e,!0)}#h=k(!1);get typesLoaded(){return I(this.#h)}set typesLoaded(e){A(this.#h,e,!0)}#g=null;get filteredRows(){return jz(this.rows,this.filter)}get schema(){return Nz(this.types,this.form.type)}get formFields(){if(!String(this.form.type||``).trim())return{primary:[],advanced:[]};let e=this.schema;return Pz(e,e&&e.default_base_url)}async fetchTypes(){let e=await yT(`/admin/provider-credentials/types`,{label:`provider credential types`});e.status===`ok`&&(this.types=e.items,this.typesLoaded=!0)}async fetchPage(){this.#g&&this.#g.abort();let e=new AbortController;this.#g=e,this.loading=!0,this.error=``;try{let t=await yT(`/admin/provider-credentials`,{label:`provider credentials`,errorFallback:`Failed to load provider credentials.`,unavailableStatuses:[503,404],options:{signal:e.signal}});if(t.status===`stale`||e.signal.aborted)return;if(t.status===`unavailable`){this.available=!1,this.rows=[];return}if(t.status===`error`){t.result&&(this.available=!0),this.rows=[],this.error=t.error;return}this.available=!0,this.rows=t.items,this.typesLoaded||await this.fetchTypes()}finally{this.#g===e&&(this.#g=null,this.loading=!1)}}#_(e,t){this.formMode=e,this.form=t,this.advancedOpen=!1,this.error=``,this.fieldErrors={},this.focusField=``}openCreate(){this.#_(`create`,Az()),this.formOpen=!0,this.typesLoaded||this.fetchTypes()}openEdit(e){!e||e.managed||(this.#_(`edit`,Hz(e)),this.formOpen=!0,this.typesLoaded||this.fetchTypes())}closeForm(){this.formOpen=!1,this.#_(`create`,Az())}selectType(){this.fieldErrors={};let e=this.formFields;this.formMode===`create`&&(this.form=Iz(this.form,e));let t=e.primary.find(e=>e.name===`api_keys`);t&&t.required&&this.form.api_keys.length===0&&(this.form.api_keys=[{value:``}])}clearFieldError(e){if(this.fieldErrors[e]===void 0)return;let{[e]:t,...n}=this.fieldErrors;this.fieldErrors=n}addApiKeyRow(){this.form.api_keys.push({value:``}),this.clearFieldError(`api_keys`)}removeApiKeyRow(e){this.form.api_keys.splice(e,1),this.clearFieldError(`api_keys`)}#v(e){let t=ps(e,`Failed to save provider credential.`),n=String(e&&e.error&&typeof e.error==`object`&&e.error.param||``).trim();if(n&&this.#y(n)){this.fieldErrors={...this.fieldErrors,[n]:t},this.error=``,this.#b();return}this.error=t}#y(e){if(e===`name`||e===`type`)return!0;let{primary:t,advanced:n}=this.formFields;return[...t,...n].some(t=>t.name===e)}#b(){let e=Object.keys(this.fieldErrors);if(e.length===0)return;let{primary:t,advanced:n}=this.formFields;n.some(t=>e.includes(t.name))&&(this.advancedOpen=!0);let r=[`type`,`name`,...t.map(e=>e.name),...n.map(e=>e.name)];this.focusField=r.find(t=>e.includes(t))||e[0]}#x(){Pc.fetchModels(),Pc.fetchCategories()}async submitForm(){let e=this.schema,t=Wz(this.form,this.formMode,this.rows,e);if(Object.keys(t).length>0){this.fieldErrors=t,this.error=``,this.#b();return}let n=Kz(this.form,e);this.error=``,this.fieldErrors={},this.formSubmitting=!0;try{let e=await bT(`/admin/provider-credentials`,`PUT`,n,{label:`save provider credential`,errorFallback:`Failed to save provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.error=e.error;return}if(e.status===`error`){e.result&&e.result.status!==401?this.#v(e.result.data):this.error=e.error;return}J.success(`Provider "`+n.name+`" saved.`),this.closeForm(),this.#x(),this.fetchPage()}finally{this.formSubmitting=!1}}async performDelete(e){this.deleteSubmitting=!0,this.deletingName=e;try{let t=await bT(`/admin/provider-credentials/`+encodeURIComponent(e),`DELETE`,void 0,{label:`delete provider credential`,errorFallback:`Failed to delete provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,zs.error=t.error;return}if(t.status===`error`){zs.error=t.error;return}J.success(`Provider "`+e+`" deleted.`),zs.close(),this.formOpen&&this.form.name===e&&this.closeForm(),this.#x(),this.fetchPage()}finally{this.deleteSubmitting=!1,this.deletingName=``}}requestDelete(e){let t=String(e||``).trim();if(!t||this.deleteSubmitting)return;let n=(this.rows||[]).find(e=>String(e&&e.name||``).trim()===t);n&&n.managed||zs.open({title:`Delete Provider`,titleId:`providerCredentialDeleteDialogTitle`,inputId:`provider-credential-delete-confirmation`,message:`Type "`+t+`" to permanently delete this provider credential. Requests routed to it will fail until it is reconfigured.`,requiredText:t,confirmLabel:`Delete Provider`,icon:jo,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.performDelete(t)})}},Jz=R(`Config`),Yz=R(` `,1),Xz=R(`
                      `),Zz=R(`
                      NameTypeBase URLAuthModelsEnabledUpdatedActions
                      `);function Qz(e,t){E(t,!0);var n=Zz(),r=M(n),i=P(M(r));H(i,21,()=>$.filteredRows,e=>e.name,(e,t)=>{var n=Xz(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=e=>{z(e,Jz())};V(o,e=>{I(t).managed&&e(s)}),T(r);var c=P(r),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=M(h,!0);T(h);var _=P(h),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x,!0);T(x);var C=P(x),w=M(C),ee=M(w),te=e=>{var n=Yz(),r=N(n);{let e=O(()=>`Edit provider `+I(t).name);vT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>$.openEdit(I(t)),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>($.deletingName===I(t).name?`Deleting provider `:`Delete provider `)+I(t).name),n=O(()=>$.deletingName===I(t).name);vT(i,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>$.requestDelete(I(t).name),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return Lo},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)};V(ee,e=>{I(t).managed||e(te)}),T(w),T(C),T(n),F((e,n,r)=>{B(a,I(t).name),B(u,I(t).type),W(d,`title`,I(t).base_url||``),B(f,I(t).base_url||`—`),B(m,e),B(g,n),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).enabled,"auth-key-status-inactive":!I(t).enabled}),B(b,I(t).enabled?`Enabled`:`Disabled`),B(S,r)},[()=>Lz(I(t)),()=>Rz(I(t)),()=>fs.formatTimestamp(I(t).updated_at)]),z(e,n)}),T(i),T(r),T(n),z(e,n),D()}var $z=R(``),eB=R(`
                      `),tB=R(`
                      `,1),nB=R(``),rB=R(``),iB=R(``),aB=R(``),oB=R(``),sB=R(` `),cB=R(` `),lB=R(`
                      `);function uB(e,t){E(t,!0);let n=O(()=>`provider-credential-`+t.field.name),r=O(()=>$.fieldErrors[t.field.name]||``),i=O(()=>I(r)?I(n)+`-error`:t.field.hint?I(n)+`-hint`:void 0),a=O(()=>{let e=String($.form[t.field.name]||``).trim();return!e||t.field.options.includes(e)?t.field.options:[...t.field.options,e]});function o(){$.clearFieldError(t.field.name)}var s=lB(),c=M(s),l=M(c),u=P(l),d=e=>{z(e,$z())};V(u,e=>{t.field.required&&e(d)}),T(c);var f=P(c,2),p=e=>{var t=tB(),a=N(t);H(a,21,()=>$.form.api_keys,ci,(e,t,a)=>{var s=eB(),c=M(s);ia(c),W(c,`aria-label`,`API key `+(a+1)),vT(P(c,2),{label:`Remove API key `+(a+1),class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>$.removeApiKeyRow(a),children:(e,t)=>{K(e,{get icon(){return jo},class:`table-icon-svg`})},$$slots:{default:!0}}),T(s),F(()=>{W(c,`id`,a===0?I(n):I(n)+`-`+a),W(c,`aria-invalid`,I(r)?`true`:void 0),W(c,`aria-describedby`,a===0?I(i):void 0)}),L(`input`,c,o),pa(c,()=>I(t).value,e=>I(t).value=e),z(e,s)}),T(a);var s=P(a,2),c=M(s);K(M(c),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(c),T(s),F(()=>W(c,`id`,$.form.api_keys.length===0?I(n):void 0)),L(`click`,c,()=>$.addApiKeyRow()),z(e,t)},m=e=>{var s=rB(),c=M(s);c.value=c.__value=``,H(P(c),16,()=>I(a),e=>e,(e,t)=>{var n=nB(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(s),F(()=>{W(s,`id`,I(n)),W(s,`aria-invalid`,I(r)?`true`:void 0),W(s,`aria-describedby`,I(i))}),L(`change`,s,o),qi(s,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,s)},h=e=>{var a=iB();ia(a),F(()=>{W(a,`id`,I(n)),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`change`,a,o),ma(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},g=e=>{var a=aB();ft(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),pa(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},_=e=>{var a=oB();ia(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),pa(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)};V(f,e=>{t.field.control===`keys`?e(p):t.field.control===`select`?e(m,1):t.field.control===`checkbox`?e(h,2):t.field.control===`textarea`?e(g,3):e(_,-1)});var v=P(f,2),y=e=>{var t=sB(),i=M(t,!0);T(t),F(()=>{W(t,`id`,I(n)+`-error`),B(i,I(r))}),z(e,t)},b=e=>{var r=cB(),i=M(r,!0);T(r),F(()=>{W(r,`id`,I(n)+`-hint`),B(i,t.field.hint)}),z(e,r)};V(v,e=>{I(r)?e(y):t.field.hint&&e(b,1)}),T(s),F(()=>{W(c,`for`,I(n)),B(l,`${t.field.label??``} `)}),z(e,s),D()}Hr([`input`,`click`,`change`]);var dB=R(`

                      The name is the stable identity used for routing and cannot change once created.

                      `),fB=R(``),pB=R(` `),mB=R(`Determines which fields the gateway uses to build requests.`),hB=R(` `),gB=R(`Suggested from the selected type; used to route requests to this provider instance and editable before saving.`),_B=R(`Immutable once created.`),vB=R(`

                      Pick a type to configure its credentials — each provider type asks for different settings.

                      `),yB=R(`
                      Advanced settings
                      `),bB=R(`
                      `,1);function xB(e,t){E(t,!0);let n=O(()=>Mz($.types,$.form.type)),r=O(()=>$.formFields),i=O(()=>$.fieldErrors.name||``),a=O(()=>$.fieldErrors.type||``);function o(){$.selectType(),$.formMode===`create`&&($.form.name=Vz($.rows,$.form.type))}An(()=>{let e=$.focusField;if(!e)return;$.focusField=``;let t=document.getElementById(`provider-credential-`+e);t&&(t.scrollIntoView({block:`center`}),t.focus({preventScroll:!0}))});{let t=e=>{z(e,dB())},s=O(()=>$.formMode===`edit`?`Edit Provider`:`Add Provider`);SE(e,{get open(){return $.formOpen},get title(){return I(s)},ariaLabel:`Provider credential editor`,get error(){return $.error},get submitting(){return $.formSubmitting},novalidate:!0,onclose:()=>$.closeForm(),onsubmit:()=>$.submitForm(),headerHint:t,children:(e,t)=>{var s=bB(),c=N(s),l=P(M(c),2),u=M(l);u.value=u.__value=``,H(P(u),16,()=>I(n),e=>e,(e,t)=>{var n=fB(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(l);var d=P(l,2),f=e=>{var t=pB(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)},p=e=>{z(e,mB())};V(d,e=>{I(a)?e(f):e(p,-1)}),T(c);var m=P(c,2),h=P(M(m),2);ia(h);var g=P(h,2),_=e=>{var t=hB(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)},v=e=>{z(e,gB())},y=e=>{z(e,_B())};V(g,e=>{I(i)?e(_):$.formMode===`create`?e(v,1):e(y,-1)}),T(m);var b=P(m,2),x=e=>{z(e,vB())};V(b,e=>{$.form.type||e(x)});var S=P(b,2);H(S,17,()=>I(r).primary,e=>e.name,(e,t)=>{uB(e,{get field(){return I(t)}})});var C=P(S,2),w=M(C);SA(M(w),{get enabled(){return $.form.enabled},label:`provider`,onclick:()=>$.form.enabled=!$.form.enabled}),T(w),T(C);var ee=P(C,2),te=e=>{var t=yB(),n=M(t),i=M(n),a=P(M(i),2),o=M(a,!0);T(a),T(i),T(n);var s=P(n,2);H(s,21,()=>I(r).advanced,e=>e.name,(e,t)=>{uB(e,{get field(){return I(t)}})}),T(s),T(t),F(e=>{t.open=$.advancedOpen,B(o,e)},[()=>I(r).advanced.map(e=>e.label).join(`, `)]),Vr(`toggle`,t,e=>$.advancedOpen=e.currentTarget.open),z(e,t)};V(ee,e=>{I(r).advanced.length>0&&e(te)}),F(()=>{l.disabled=$.formMode===`edit`,W(l,`aria-invalid`,I(a)?`true`:void 0),W(l,`aria-describedby`,I(a)?`provider-credential-type-error`:`provider-credential-type-hint`),h.disabled=$.formMode===`edit`,W(h,`aria-invalid`,I(i)?`true`:void 0),W(h,`aria-describedby`,I(i)?`provider-credential-name-error`:`provider-credential-name-hint`)}),L(`change`,l,o),qi(l,()=>$.form.type,e=>$.form.type=e),L(`input`,h,()=>$.clearFieldError(`name`)),pa(h,()=>$.form.name,e=>$.form.name=e),z(e,s)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var SB=R(`

                      Providers

                      `),CB=R(``),wB=R(`
                      Provider credential management is unavailable.
                      `),TB=R(``),EB=R(`
                      `),DB=R(`

                      No dashboard-managed providers yet. Add one here, or declare providers in config.yaml / environment variables.

                      `),OB=R(`

                      No providers match your filter.

                      `),kB=R(`
                      `);function AB(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`providers-config`&&$.fetchPage()});var n=kB(),r=M(n),i=M(r);JS(M(i),{copyId:`providers-config-help-copy`,label:`model providers help`,title:e=>{z(e,SB())},help:e=>{Ue(),z(e,Zr(`Configure LLM provider credentials here instead of setting API keys as + environment variables. Providers declared in config.yaml or env vars + are read-only (Config badge) and cannot be edited or deleted from the + dashboard. Keys are masked after saving.`))},$$slots:{title:!0,help:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=CB();K(M(t),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=$.formSubmitting),L(`click`,t,()=>$.openCreate()),z(e,t)};V(o,e=>{$.available&&!q.needsAuth&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,wB())};V(c,e=>{!$.available&&!q.needsAuth&&e(l)});var u=P(c,2),d=e=>{var t=TB(),n=M(t,!0);T(t),F(()=>B(n,$.error)),z(e,t)};V(u,e=>{$.error&&!q.needsAuth&&!$.formOpen&&e(d)});var f=P(u,2),p=e=>{gT(e,{label:`Loading providers...`})};V(f,e=>{$.loading&&!q.needsAuth&&e(p)});var m=P(f,2),h=e=>{var t=EB(),n=M(t);xw(M(n),{id:`provider-credential-filter`,placeholder:`Filter by name, type, or base URL...`,label:`Filter providers by name, type, or base URL`,get value(){return $.filter},set value(e){$.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{($.rows.length>0||$.filter)&&$.available&&!q.needsAuth&&e(h)});var g=P(m,2);xB(g,{});var _=P(g,2),v=e=>{Qz(e,{})};V(_,e=>{$.filteredRows.length>0&&$.available&&!q.needsAuth&&e(v)});var y=P(_,2),b=e=>{z(e,DB())};V(y,e=>{$.rows.length===0&&!$.filter&&!$.loading&&!q.needsAuth&&!$.error&&$.available&&e(b)});var x=P(y,2),S=e=>{z(e,OB())};V(x,e=>{$.rows.length>0&&$.filteredRows.length===0&&$.filter&&!$.loading&&!q.needsAuth&&$.available&&e(S)}),T(n),z(e,n),D()}Hr([`click`]);function jB(){return{name:``,description:``,user_path:``,labels:``,dashboard_access:!1,expires_at:``}}function MB(e){let t=[];for(let n of String(e||``).split(`,`)){let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function NB(e){let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t;for(let e of n.split(`/`)){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function PB(e){if(NB(e))return``;let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t,r=[];for(let e of n.split(`/`)){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function FB(e){let t=e||{},n=String(t.name||``).trim();if(!n)return{error:`Name is required.`};let r=NB(t.user_path);if(r)return{error:r};let i=PB(t.user_path),a=MB(t.labels),o={name:n,description:String(t.description||``).trim()||void 0,user_path:i||void 0,labels:a.length?a:void 0,dashboard_access:t.dashboard_access?!0:void 0};return t.expires_at&&(o.expires_at=t.expires_at+`T23:59:59Z`),{payload:o}}function IB(e,t=Date.now()){let n=e&&e.expires_at;if(!n)return!1;let r=Date.parse(n);return Number.isFinite(r)&&r<=t}function LB(e){return e?!!e.deactivated_at||e.enabled===!1:!1}function RB(e,t=Date.now()){return!e||e.active===!1||LB(e)?!1:!IB(e,t)}function zB(e){return[e.name,e.description,e.user_path,e.redacted_value,...e.labels||[]].filter(Boolean).join(` `).toLowerCase()}function BB(e,t={}){let{query:n=``,showInactive:r=!1,now:i=Date.now()}=t,a=String(n||``).trim().toLowerCase();return(Array.isArray(e)?e:[]).filter(e=>!r&&!RB(e,i)?!1:!a||zB(e).includes(a))}function VB(e,t){return LB(e)?2:+!RB(e,t)}function HB(e){let t=e&&e.expires_at;if(!t)return 1/0;let n=Date.parse(t);return Number.isFinite(n)?n:1/0}function UB(e){let t=Date.parse(e&&e.deactivated_at||``);return Number.isFinite(t)?t:-1/0}function WB(e,t=Date.now()){return(Array.isArray(e)?e.slice():[]).sort((e,n)=>{let r=VB(e,t),i=VB(n,t);if(r!==i)return r-i;let[a,o]=r===2?[UB(e),UB(n)]:[HB(e),HB(n)];return a===o?String(e.name||``).localeCompare(String(n.name||``)):a>o?-1:1})}function GB(e,t=Date.now()){return(Array.isArray(e)?e:[]).reduce((e,n)=>e+ +!RB(n,t),0)}function KB(){return{open:!1,id:``,name:``,value:``,submitting:!1,error:``}}var qB=new class{#e=k(j([]));get keys(){return I(this.#e)}set keys(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get showInactive(){return I(this.#a)}set showInactive(e){A(this.#a,e,!0)}#o=O(()=>WB(BB(this.keys,{query:this.filter,showInactive:this.showInactive})));get visibleKeys(){return I(this.#o)}set visibleKeys(e){A(this.#o,e)}#s=O(()=>GB(this.keys));get inactiveCount(){return I(this.#s)}set inactiveCount(e){A(this.#s,e)}#c=k(!1);get formOpen(){return I(this.#c)}set formOpen(e){A(this.#c,e,!0)}#l=k(!1);get formSubmitting(){return I(this.#l)}set formSubmitting(e){A(this.#l,e,!0)}#u=k(``);get issuedValue(){return I(this.#u)}set issuedValue(e){A(this.#u,e,!0)}#d=k(``);get deactivatingID(){return I(this.#d)}set deactivatingID(e){A(this.#d,e,!0)}#f=k(``);get dashboardAccessID(){return I(this.#f)}set dashboardAccessID(e){A(this.#f,e,!0)}#p=k(j(jB()));get form(){return I(this.#p)}set form(e){A(this.#p,e,!0)}#m=k(j(KB()));get labelsEditor(){return I(this.#m)}set labelsEditor(e){A(this.#m,e,!0)}copyState=yM({logPrefix:`Failed to copy auth key:`});async fetchKeys(){this.loading=!0,this.error=``;try{let e=await yT(`/admin/auth-keys`,{label:`auth keys`,errorFallback:`Unable to load API keys.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.keys=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.error=e.error;return}this.available=!0,this.keys=e.items}finally{this.loading=!1}}openForm(){this.formSubmitting||this.formOpen||(this.formOpen=!0,this.error=``,this.issuedValue||(this.copyState.reset(),this.form=jB()))}closeForm(){this.formOpen&&(this.formOpen=!1,this.error=``,this.copyState.reset(),!this.formSubmitting&&!this.issuedValue&&(this.form=jB()))}copyIssuedValue(){return this.copyState.copy(this.issuedValue)}dismissIssuedKey(){this.issuedValue=``,this.copyState.reset(),this.form=jB()}async submitForm(){let e=FB(this.form);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await bT(`/admin/auth-keys`,`POST`,e.payload,{label:`create API key`,errorFallback:`Failed to create API key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error,t.result&&t.result.status!==401&&console.error(`Failed to create API key:`,t.result.status,this.error);return}let n=t.result.data||{};this.issuedValue=n.value||``,this.formOpen=!0,this.copyState.reset(),this.form=jB(),this.fetchKeys()}finally{this.formSubmitting=!1}}openLabelsEditor(e){!e||this.labelsEditor.submitting||(this.labelsEditor={open:!0,id:e.id,name:e.name||``,value:(e.labels||[]).join(`, `),submitting:!1,error:``})}closeLabelsEditor(){!this.labelsEditor.open||this.labelsEditor.submitting||(this.labelsEditor=KB())}async submitLabelsEditor(){let e=this.labelsEditor;if(!e.open||e.submitting||!e.id)return;e.submitting=!0,e.error=``;let t={labels:MB(e.value)};try{let n=await bT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/labels`,`PUT`,t,{label:`update API key labels`,errorFallback:`Failed to update labels.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,e.error=n.error;return}if(n.status===`error`){e.error=n.error,n.result&&n.result.status!==401&&console.error(`Failed to update auth key labels:`,n.result.status,e.error);return}J.success(`Labels updated for key "`+e.name+`".`),e.submitting=!1,this.closeLabelsEditor(),this.fetchKeys()}finally{e.submitting=!1}}async toggleDashboardAccess(e){if(!e||!e.active||this.dashboardAccessID)return;let t=!e.dashboard_access;this.dashboardAccessID=e.id;try{let n=await bT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/dashboard-access`,`PUT`,{dashboard_access:t},{label:`update API key dashboard access`,errorFallback:`Failed to update dashboard access.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,J.error(n.error);return}if(n.status===`error`){n.result&&n.result.status!==401&&console.error(`Failed to update auth key dashboard access:`,n.result.status,n.error),J.error(n.error);return}J.success(`Dashboard access `+(t?`granted to`:`revoked for`)+` key "`+e.name+`".`),this.fetchKeys()}finally{this.dashboardAccessID=``}}async deactivateKey(e){if(!(!e||!e.active)&&window.confirm(`Deactivate key "`+e.name+`"? This cannot be undone.`)){this.deactivatingID=e.id;try{let t=await bT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/deactivate`,`POST`,void 0,{label:`deactivate API key`,errorFallback:`Failed to deactivate key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,J.error(t.error);return}if(t.status===`error`){t.result&&t.result.status!==401&&console.error(`Failed to deactivate auth key:`,t.result.status,t.error),J.error(t.error);return}J.success(`Key "`+e.name+`" deactivated.`),this.fetchKeys()}finally{this.deactivatingID=``}}}},JB=R(``),YB=R(`

                      Store this key securely — it won’t be shown again.

                      `),XB=R(``),ZB=R(``),QB=R(``),$B=R(``),eV=R(`
                      `);function tV(e,t){E(t,!0);{let t=O(()=>qB.issuedValue?``:qB.error),n=O(()=>qB.issuedValue?`Done, I’ve stored it`:`Create API Key`),r=O(()=>qB.issuedValue?Ha:mo);SE(e,{get open(){return qB.formOpen},title:`Create API Key`,ariaLabel:`API key editor`,get error(){return I(t)},get submitting(){return qB.formSubmitting},get submitLabel(){return I(n)},submittingLabel:`Creating...`,get submitIcon(){return I(r)},cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>qB.closeForm(),onsubmit:()=>qB.issuedValue?qB.dismissIssuedKey():qB.submitForm(),children:(e,t)=>{var n=Qr(),r=N(n),i=e=>{var t=YB(),n=P(M(t),2),r=M(n),i=M(r,!0);T(r),pL(P(r,2),{get state(){return qB.copyState},onclick:()=>qB.copyIssuedValue()}),T(n);var a=P(n,2),o=e=>{z(e,JB())};V(a,e=>{qB.copyState.error&&e(o)}),T(t),F(()=>B(i,qB.issuedValue)),z(e,t)},a=e=>{var t=eV(),n=M(t),r=M(n),i=P(M(r),2);ia(i),T(r);var a=P(r,2),o=P(M(a),2);ia(o),T(a),T(n);var s=P(n,2),c=M(s);JS(c,{copyId:`auth-key-user-path-help-copy`,label:`API key user path help`,title:e=>{z(e,XB())},help:e=>{Ue(),z(e,Zr(`When set, this key overrides the configured user path request + header for audit logging and downstream request context.`))},$$slots:{title:!0,help:!0}});var l=P(c,2);ia(l),T(s);var u=P(s,2),d=M(u);JS(d,{copyId:`auth-key-labels-help-copy`,label:`API key labels help`,title:e=>{z(e,ZB())},help:e=>{Ue(),z(e,Zr(`Every request authenticated with this key gets these labels, in + addition to any labels from tagging headers. Labels show up in + usage analytics, the request log, and audit logs.`))},$$slots:{title:!0,help:!0}});var f=P(d,2);ia(f),T(u);var p=P(u,2),m=M(p);JS(m,{copyId:`auth-key-dashboard-access-help-copy`,label:`API key dashboard access help`,title:e=>{z(e,QB())},help:e=>{Ue(),z(e,Zr(`When off, this key is denied the dashboard and every /admin API + endpoint. Model endpoints and GET /v1/usage stay available to + the key. The master key always has dashboard access.`))},$$slots:{title:!0,help:!0}});var h=P(m,2),g=M(h);ia(g),Ue(2),T(h),T(p),wE(P(p,2),{id:`auth-key-description`,label:`Description (optional)`,children:(e,t)=>{var n=$B();ft(n),pa(n,()=>qB.form.description,e=>qB.form.description=e),z(e,n)},$$slots:{default:!0}}),T(t),pa(i,()=>qB.form.name,e=>qB.form.name=e),pa(o,()=>qB.form.expires_at,e=>qB.form.expires_at=e),pa(l,()=>qB.form.user_path,e=>qB.form.user_path=e),pa(f,()=>qB.form.labels,e=>qB.form.labels=e),ma(g,()=>qB.form.dashboard_access,e=>qB.form.dashboard_access=e),z(e,t)};V(r,e=>{qB.issuedValue?e(i):e(a,-1)}),z(e,n)},$$slots:{default:!0}})}D()}var nV=R(`

                      `),rV=R(`

                      Applies to new requests made with this key. Leave empty to remove all labels.

                      `,1);function iV(e,t){E(t,!0),SE(e,{get open(){return qB.labelsEditor.open},title:`Edit Labels`,ariaLabel:`API key labels editor`,get error(){return qB.labelsEditor.error},get submitting(){return qB.labelsEditor.submitting},submitLabel:`Save Labels`,cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>qB.closeLabelsEditor(),onsubmit:()=>qB.submitLabelsEditor(),headerHint:e=>{var t=nV(),n=M(t,!0);T(t),F(()=>B(n,qB.labelsEditor.name)),z(e,t)},children:(e,t)=>{wE(e,{id:`auth-key-labels-edit`,label:`Labels (comma-separated)`,children:(e,t)=>{var n=rV(),r=N(n);ia(r),Ue(2),pa(r,()=>qB.labelsEditor.value,e=>qB.labelsEditor.value=e),z(e,n)},$$slots:{default:!0}})},$$slots:{headerHint:!0,default:!0}}),D()}var aV=R(` `),oV=R(`
                      `),sV=R(``),cV=R(`Expired`),lV=R(` `),uV=R(` `,1),dV=R(`Deactivated`),fV=R(`
                      `),pV=R(`
                      NameDescriptionUser PathLabelsTokenDashboard Access ExpiresCreated
                      `);function mV(e,t){E(t,!0);var n=pV(),r=M(n),i=M(r),a=M(i),o=P(M(a),5),s=M(o);K(P(M(s)),{get icon(){return no},width:`13`,height:`13`}),T(s),T(o),Ue(3),T(a),T(i);var c=P(i);H(c,21,()=>qB.visibleKeys,e=>e.id,(e,t)=>{var n=fV();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i),s=M(o,!0);T(o);var c=P(o),l=M(c,!0);T(c);var u=P(c),d=M(u),f=e=>{var n=oV();H(n,20,()=>I(t).labels||[],e=>e,(e,t)=>{var n=aV(),r=M(n,!0);T(n),F(e=>{Wi(n,e),B(r,t)},[()=>Wy(t)]),z(e,n)}),T(n),z(e,n)},p=e=>{z(e,sV())};V(d,e=>{(I(t).labels||[]).length>0?e(f):e(p,-1)}),T(u);var m=P(u),h=M(m),g=M(h,!0);T(h),T(m);var _=P(m),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x),C=e=>{var n=lV(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{z(e,cV())},s=O(()=>IB(I(t)));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>mc(I(t).expires_at)]),z(e,n)},w=e=>{z(e,Zr(`—`))};V(S,e=>{I(t).expires_at?e(C):e(w,-1)}),T(x);var ee=P(x),te=M(ee,!0);T(ee);var ne=P(ee),re=M(ne),ie=M(re),ae=e=>{var n=uV(),r=N(n);{let e=O(()=>(I(t).dashboard_access?`Revoke dashboard access for API key `:`Grant dashboard access to API key `)+I(t).name),n=O(()=>!!qB.dashboardAccessID);vT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>qB.toggleDashboardAccess(I(t)),get disabled(){return I(n)},children:(e,n)=>{{let n=O(()=>I(t).dashboard_access?To:wo);K(e,{get icon(){return I(n)},class:`table-icon-svg`})}},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>`Edit labels for API key `+I(t).name);vT(i,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>qB.openLabelsEditor(I(t)),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}var a=P(i,2);{let e=O(()=>(qB.deactivatingID===I(t).id?`Deactivating API key `:`Deactivate API key `)+I(t).name),n=O(()=>qB.deactivatingID===I(t).id);vT(a,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>qB.deactivateKey(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return ho},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)},oe=e=>{var n=dV();F(e=>W(n,`title`,e),[()=>I(t).deactivated_at?`Deactivated on `+hc(I(t).deactivated_at):`Deactivated`]),z(e,n)},se=O(()=>LB(I(t)));V(ie,e=>{I(t).active?e(ae):I(se)&&e(oe,1)}),T(re),T(ne),T(n),F((e,i,o)=>{r=U(n,1,`svelte-nf0ldb`,null,r,e),B(a,I(t).name),B(s,I(t).description||`—`),B(l,I(t).user_path||`—`),B(g,I(t).redacted_value),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).dashboard_access,"auth-key-status-inactive":!I(t).dashboard_access}),B(b,I(t).dashboard_access?`Allowed`:`Denied`),W(x,`title`,i),B(te,o)},[()=>({"auth-key-row-deactivated":LB(I(t))}),()=>I(t).expires_at?hc(I(t).expires_at):``,()=>fs.formatTimestamp(I(t).created_at)]),z(e,n)}),T(c),T(r),T(n),z(e,n),D()}var hV=R(``),gV=R(`
                      API key management is unavailable.
                      `),_V=R(``),vV=R(`

                      Managed API keys authenticate requests to the gateway. Deactivation is + permanent — create a new key if access needs to be restored.

                      `),yV=R(`
                      `),bV=R(`
                      `),xV=R(`

                      `),SV=R(`

                      No API keys yet. Issue a key to get started.

                      `),CV=R(`
                      `);function wV(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`auth-keys`&&qB.fetchKeys()});var n=CV(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=hV();K(M(t),{get icon(){return mo},class:`table-icon-svg`}),Ue(2),T(t),F(()=>t.disabled=qB.formSubmitting),L(`click`,t,()=>{qB.formSubmitting||qB.openForm()}),z(e,t)};V(a,e=>{qB.available&&!q.authError&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,gV())};V(s,e=>{!qB.available&&!q.authError&&e(c)});var l=P(s,2),u=e=>{var t=_V(),n=M(t,!0);T(t),F(()=>B(n,qB.error)),z(e,t)};V(l,e=>{qB.error&&!q.authError&&!qB.formOpen&&e(u)});var d=P(l,2),f=e=>{z(e,vV())};V(d,e=>{qB.available&&!q.authError&&e(f)});var p=P(d,2);tV(p,{});var m=P(p,2);iV(m,{});var h=P(m,2),g=e=>{var t=yV();CS(M(t),{size:18,label:`Loading API keys`}),T(t),z(e,t)};V(h,e=>{qB.loading&&qB.keys.length===0&&e(g)});var _=P(h,2),v=e=>{var t=bV(),n=M(t);xw(M(n),{placeholder:`Filter by name, description, user path, label, or token...`,label:`Filter API keys by name, description, user path, label, or token`,get value(){return qB.filter},set value(e){qB.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i);ia(a);var o=P(a,2),s=P(M(o)),c=e=>{var t=Zr();F(()=>B(t,`(${qB.inactiveCount??``})`)),z(e,t)};V(s,e=>{qB.inactiveCount>0&&e(c)}),T(o),T(i),T(r),T(t),ma(a,()=>qB.showInactive,e=>qB.showInactive=e),z(e,t)};V(_,e=>{qB.keys.length>0&&qB.available&&e(v)});var y=P(_,2),b=e=>{mV(e,{})};V(y,e=>{qB.visibleKeys.length>0&&qB.available&&e(b)});var x=P(y,2),S=e=>{var t=xV(),n=M(t);T(t),F(()=>B(n,`No API keys match the current filter.${qB.inactiveCount>0&&!qB.showInactive?` `+qB.inactiveCount+` inactive `+(qB.inactiveCount===1?`key is`:`keys are`)+` hidden.`:``}`)),z(e,t)};V(x,e=>{qB.keys.length>0&&qB.visibleKeys.length===0&&qB.available&&e(S)});var C=P(x,2),w=e=>{z(e,SV())};V(C,e=>{qB.keys.length===0&&!qB.loading&&!q.authError&&!qB.error&&qB.available&&e(w)}),T(n),z(e,n),D()}Hr([`click`]);var TV=R(`

                      Timezone

                      `),EV=R(``),DV=R(``),OV=R(`
                      `,1);function kV(e,t){E(t,!0);function n(){fs.saveOverride(),q.refresh()}function r(){fs.clearOverride(),q.refresh()}var i=OV(),a=N(i);JS(M(a),{copyId:`timezone-help-copy`,label:`timezone help`,text:`Day-based analytics, charts, and date filters use your effective timezone. Usage and audit logs keep UTC in the hover title while rendering row timestamps in your effective timezone.`,title:e=>{z(e,TV())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=P(M(s),2),l=M(c),u=M(l);T(l),l.value=l.__value=``,H(P(l),17,()=>fs.options,e=>e.value,(e,t)=>{var n=EV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(c),T(s),T(o);var d=P(o,2),f=M(d),p=e=>{var t=DV();L(`click`,t,r),z(e,t)};V(f,e=>{fs.override&&e(p)}),T(d),F(e=>B(u,`Automatic (${e??``})`),[()=>fs.detectedTimeZoneLabel()]),Vr(`focus`,c,()=>fs.ensureOptions()),L(`change`,c,n),qi(c,()=>fs.override,e=>fs.override=e),z(e,i),D()}Hr([`change`,`click`]);var AV=R(``),jV=R(`

                      Failover

                      `,1);function MV(e,t){E(t,!0);let n=O(()=>Z.failoverSaving||Z.failoverGenerating||Z.failoverDraftSaving||!Z.failoverAvailable||!Z.failoverEnabled());var r=jV(),i=N(r),a=P(M(i),2),o=M(a),s=M(o);K(s,{get icon(){return Fo},class:`form-action-icon`});var c=P(s,2),l=M(c,!0);T(c),T(o);var u=P(o,2);K(M(u),{get icon(){return jo},class:`form-action-icon`}),Ue(2),T(u),T(a),T(i);var d=P(i,2),f=M(d),p=e=>{var t=AV(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(f,e=>{Z.failoverError&&e(p)}),T(d),mj(P(d,2),{}),F(()=>{o.disabled=I(n),B(l,Z.failoverGenerating?`Generating...`:`Generate failover models automatically`),u.disabled=I(n)}),L(`click`,o,()=>Z.generateFailoverRules()),L(`click`,u,()=>Z.openFailoverResetDialog()),z(e,r),D()}Hr([`click`]);function NV(){return{daily_reset_hour:0,daily_reset_minute:0,weekly_reset_weekday:1,weekly_reset_hour:0,weekly_reset_minute:0,monthly_reset_day:1,monthly_reset_hour:0,monthly_reset_minute:0}}function PV(e,t){let n=t||{},r=(e,t)=>{if(e===``)return t;let n=Number(e);return Number.isFinite(n)&&Number.isInteger(n)?Math.trunc(n):t},i=(e,t)=>r(n[e],t),a=(t,n)=>e?r(e[t],n):n;return{daily_reset_hour:a(`daily_reset_hour`,i(`daily_reset_hour`,0)),daily_reset_minute:a(`daily_reset_minute`,i(`daily_reset_minute`,0)),weekly_reset_weekday:a(`weekly_reset_weekday`,i(`weekly_reset_weekday`,1)),weekly_reset_hour:a(`weekly_reset_hour`,i(`weekly_reset_hour`,0)),weekly_reset_minute:a(`weekly_reset_minute`,i(`weekly_reset_minute`,0)),monthly_reset_day:a(`monthly_reset_day`,i(`monthly_reset_day`,1)),monthly_reset_hour:a(`monthly_reset_hour`,i(`monthly_reset_hour`,0)),monthly_reset_minute:a(`monthly_reset_minute`,i(`monthly_reset_minute`,0))}}function FV(){return[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}]}var IV=R(`

                      Budget Resets

                      `),LV=R(``),RV=R(`

                      If the selected day does not exist in a month, the reset runs on + the last day of that month.

                      `),zV=R(``),BV=R(``),VV=R(`
                      Monthly
                      Weekly
                      Daily
                      `,1);function HV(e,t){E(t,!0);let n=k(j(NV())),r=k(!1),i=k(!1),a=k(``),o=k(!1),s=O(()=>Cs.budgetsVisible());async function c(){if(await Cs.ensureLoaded(),!Cs.budgetsVisible()){A(a,``);return}A(r,!0),A(a,``);try{let e=await vs(`/admin/budgets/settings`,{label:`budget settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load budget settings.`);return}A(n,PV(e.data,I(n)),!0)}catch(e){console.error(`Failed to fetch budget settings:`,e),A(a,`Unable to load budget settings.`)}finally{A(r,!1)}}async function l(){if(!I(i)){A(i,!0);try{let e=await ys(`/admin/budgets/settings`,`PUT`,PV(I(n),I(n)),{label:`budget settings`});if(e.stale)return;if(!e.ok){J.error(`Unable to save budget settings.`);return}A(n,PV(e.data,I(n)),!0),A(a,``),J.success(`Budget settings saved.`)}catch(e){console.error(`Failed to save budget settings:`,e),J.error(`Unable to save budget settings.`)}finally{A(i,!1)}}}An(()=>{q.refreshTick,c()});var u=Qr(),d=N(u),f=e=>{var t=VV(),s=N(t),c=M(s);JS(c,{copyId:`budget-settings-help-copy`,label:`budget help`,text:`Budget reset anchors are stored in the database and evaluated in UTC. Hourly budgets reset at the top of each hour.`,title:e=>{z(e,IV())},$$slots:{title:!0}});var u=P(c,2),d=M(u),f=P(M(d),2),p=M(f);JS(p,{copyId:`budget-monthly-day-help-copy`,label:`day of month help`,external:!0,get open(){return I(o)},set open(e){A(o,e,!0)},title:e=>{z(e,LV())},$$slots:{title:!0}});var m=P(p,2);ia(m),T(f);var h=P(f,2),g=P(M(h),2);ia(g),T(h);var _=P(h,2),v=P(M(_),2);ia(v),T(_);var y=P(_,2),b=M(y),x=e=>{z(e,RV())};V(b,e=>{I(o)&&e(x)}),T(y),T(d);var S=P(d,2),C=P(M(S),2),w=P(M(C),2);H(w,21,FV,e=>e.value,(e,t)=>{var n=zV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(w),T(C);var ee=P(C,2),te=P(M(ee),2);ia(te),T(ee);var ne=P(ee,2),re=P(M(ne),2);ia(re),T(ne),Ue(2),T(S);var ie=P(S,2),ae=P(M(ie),4),oe=P(M(ae),2);ia(oe),T(ae);var se=P(ae,2),ce=P(M(se),2);ia(ce),T(se),Ue(2),T(ie),T(u);var le=P(u,2),ue=M(le);K(M(ue),{get icon(){return vo},class:`form-action-icon`}),Ue(2),T(ue);var de=P(ue,2),fe=e=>{CS(e,{size:16,label:`Loading budget settings`})};V(de,e=>{I(r)&&e(fe)}),T(le),T(s);var pe=P(s,2),me=M(pe),he=e=>{var t=BV(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(me,e=>{I(a)&&e(he)}),T(pe),F(()=>{ue.disabled=I(i)||I(r),W(ue,`aria-busy`,I(i)?`true`:`false`)}),pa(m,()=>I(n).monthly_reset_day,e=>I(n).monthly_reset_day=e),pa(g,()=>I(n).monthly_reset_hour,e=>I(n).monthly_reset_hour=e),pa(v,()=>I(n).monthly_reset_minute,e=>I(n).monthly_reset_minute=e),qi(w,()=>I(n).weekly_reset_weekday,e=>I(n).weekly_reset_weekday=e),pa(te,()=>I(n).weekly_reset_hour,e=>I(n).weekly_reset_hour=e),pa(re,()=>I(n).weekly_reset_minute,e=>I(n).weekly_reset_minute=e),pa(oe,()=>I(n).daily_reset_hour,e=>I(n).daily_reset_hour=e),pa(ce,()=>I(n).daily_reset_minute,e=>I(n).daily_reset_minute=e),L(`click`,ue,l),z(e,t)};V(d,e=>{I(s)&&e(f)}),z(e,u),D()}Hr([`click`]);var UV=R(`

                      Reset All Budgets

                      Start new budget periods for every configured budget without changing + the limits.

                      `);function WV(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=UV(),n=P(M(t),2),r=M(n);K(M(r),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(r),T(n),T(t),F(()=>r.disabled=Y.resetAllLoading),L(`click`,r,()=>Y.openResetDialog()),z(e,t)},a=O(()=>Cs.budgetsVisible());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}Hr([`click`]);function GV(){return{header:``,prefix:``,do_not_pass:!1,delimiter:``,managed:!1}}function KV(e){return(e&&Array.isArray(e.headers)?e.headers:[]).map(e=>({header:typeof e.header==`string`?e.header:``,prefix:typeof e.prefix==`string`?e.prefix:``,do_not_pass:e.do_not_pass===!0,delimiter:typeof e.delimiter==`string`&&e.delimiter!==`,`?e.delimiter:``,managed:e.managed===!0}))}function qV(e){return{headers:(Array.isArray(e)?e:[]).filter(e=>!e.managed&&e.header.trim()!==``).map(e=>({header:e.header.trim(),prefix:e.prefix,do_not_pass:e.do_not_pass,delimiter:e.delimiter}))}}function JV(e){return e&&e.error&&e.error.message?e.error.message:``}var YV=R(`

                      Tagging based on headers

                      `),XV=R(`config`),ZV=R(``),QV=R(`
                      `),$V=R(`

                      No tagging headers configured. Requests are not labelled.

                      `),eH=R(``),tH=R(`
                      `,1);function nH(e,t){E(t,!0);let n=k(j([])),r=k(!0),i=k(!1),a=k(!1),o=k(``);function s(){I(n).push(GV())}function c(e){let t=I(n)[e];!t||t.managed||I(n).splice(e,1)}async function l(){A(i,!0),A(o,``);try{let e=await vs(`/admin/tagging/settings`,{label:`tagging settings`});if(e.stale)return;if(!e.ok){A(o,`Unable to load tagging settings.`);return}A(n,KV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0)}catch(e){console.error(`Failed to fetch tagging settings:`,e),A(o,`Unable to load tagging settings.`)}finally{A(i,!1)}}async function u(){if(!(I(a)||!I(r))){A(a,!0);try{let e=await ys(`/admin/tagging/settings`,`PUT`,qV(I(n)),{label:`tagging settings`});if(e.stale)return;if(!e.ok){J.error(e.status!==401&&JV(e.data)||`Unable to save tagging settings.`);return}A(n,KV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0),A(o,``),J.success(`Tagging settings saved.`)}catch(e){console.error(`Failed to save tagging settings:`,e),J.error(`Unable to save tagging settings.`)}finally{A(a,!1)}}}An(()=>{q.refreshTick,l()});var d=tH(),f=N(d),p=M(f);JS(p,{copyId:`tagging-settings-help-copy`,label:`tagging help`,text:`Each request is labelled from the listed headers; labels land in usage tracking and audit logs. A header value can carry several labels split by the delimiter (default: comma). The prefix is trimmed from each label only — the header itself is forwarded unchanged unless 'Do not pass' is checked. Rows marked CONFIG come from config.yaml or TAGGING_HEADER_* env vars and are read-only here.`,title:e=>{z(e,YV())},$$slots:{title:!0}});var m=P(p,2),h=M(m);H(h,17,()=>I(n),ci,(e,t,n)=>{var i=QV(),a=M(i),o=M(a);W(o,`for`,`tagging-header-`+n);var s=P(o,2);ia(s),W(s,`id`,`tagging-header-`+n),T(a);var l=P(a,2),u=M(l);W(u,`for`,`tagging-prefix-`+n);var d=P(u,2);ia(d),W(d,`id`,`tagging-prefix-`+n),T(l);var f=P(l,2),p=M(f);W(p,`for`,`tagging-delimiter-`+n);var m=P(p,2);ia(m),W(m,`id`,`tagging-delimiter-`+n),T(f);var h=P(f,2),g=M(h);ia(g),Ue(2),T(h);var _=P(h,2),v=M(_),y=e=>{z(e,XV())},b=e=>{var i=ZV();F(()=>{i.disabled=!I(r),W(i,`aria-label`,`Remove tagging header `+(I(t).header||n+1))}),L(`click`,i,()=>c(n)),z(e,i)};V(v,e=>{I(t).managed?e(y):e(b,-1)}),T(_),T(i),F(()=>{s.disabled=I(t).managed||!I(r),d.disabled=I(t).managed||!I(r),m.disabled=I(t).managed||!I(r),g.disabled=I(t).managed||!I(r)}),pa(s,()=>I(t).header,e=>I(t).header=e),pa(d,()=>I(t).prefix,e=>I(t).prefix=e),pa(m,()=>I(t).delimiter,e=>I(t).delimiter=e),ma(g,()=>I(t).do_not_pass,e=>I(t).do_not_pass=e),z(e,i)});var g=P(h,2),_=e=>{CS(e,{size:16,label:`Loading tagging settings`})};V(g,e=>{I(i)&&e(_)});var v=P(g,2),y=e=>{z(e,$V())};V(v,e=>{!I(i)&&I(n).length===0&&e(y)}),T(m);var b=P(m,2),x=M(b);K(M(x),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(x);var S=P(x,2);K(M(S),{get icon(){return vo},class:`form-action-icon`}),Ue(2),T(S),T(b),T(f);var C=P(f,2),w=M(C),ee=e=>{var t=eH(),n=M(t,!0);T(t),F(()=>B(n,I(o))),z(e,t)};V(w,e=>{I(o)&&e(ee)}),T(C),F(()=>{x.disabled=!I(r)||I(a)||I(i),S.disabled=!I(r)||I(a)||I(i),W(S,`aria-busy`,I(a)?`true`:`false`)}),L(`click`,x,s),L(`click`,S,u),z(e,d),D()}Hr([`click`]);function rH(e){let t=e||{};if(t.selectedPreset)return{days:parseInt(t.selectedPreset,10)||30};let n=t.customStartDate?pc(t.customStartDate):``,r=t.customEndDate||t.today||null;return{start_date:n,end_date:r?pc(r):``}}function iH(e,t,n,r){return{...rH(e),user_path:String(t||``).trim(),selector:String(n||``).trim(),confirmation:r}}function aH(e){let t=Number(e&&e.matched||0),n=Number(e&&e.recalculated||0),r=Number(e&&e.without_pricing||0),i=`Pricing recalculated for `+n+` of `+t+` usage record`+(t===1?``:`s`)+`.`;return r>0&&(i+=` `+r+` usage record`+(r===1?` still lacks`:`s still lack`)+` pricing metadata.`),i}var oH=R(`

                      Usage Pricing Recalculation

                      `),sH=R(`
                      `);function cH(e,t){E(t,!0);let n=k(``),r=k(``),i=k(!1),a=O(()=>Cs.booleanFlag(`USAGE_PRICING_RECALCULATION_ENABLED`,!1));function o(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}I(i)||zs.open({title:`Recalculate Pricing`,titleId:`pricingRecalculateDialogTitle`,inputId:`pricing-recalculate-confirmation`,requiredText:`recalculate`,confirmLabel:`Recalculate Pricing`,icon:La,dialogClass:`pricing-recalculate-dialog`,message:`Stored usage cost fields matching the selected filters will be overwritten.`,onConfirm:()=>s()})}async function s(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}if(!I(i)){A(i,!0);try{let e=await ys(`/admin/usage/recalculate-pricing`,`POST`,iH({selectedPreset:Nc.selectedPreset,customStartDate:Nc.customStartDate,customEndDate:Nc.customEndDate,today:fs.todayDate()},I(n),I(r),`recalculate`),{label:`pricing recalculation`});if(e.stale)return;if(!e.ok){zs.error=`Unable to recalculate pricing.`;return}zs.close(),J.success(aH(e.data)),zc.fetchUsage()}catch(e){console.error(`Failed to recalculate pricing:`,e),zs.error=`Unable to recalculate pricing.`}finally{A(i,!1)}}}var c=Qr(),l=N(c),u=e=>{var t=sH(),s=M(t);JS(s,{copyId:`pricing-recalculate-help-copy`,label:`pricing recalculation help`,text:`Recalculate stored input, output, total, and Pro Saved costs from the current model pricing metadata. This overwrites matching historical cost fields. Filters are applied to the selected date range, user path subtree, and provider/model selector or alias.`,title:e=>{z(e,oH())},$$slots:{title:!0}});var c=P(s,2),l=M(c),u=P(M(l),2);nl(M(u),{}),T(u),T(l);var d=P(l,2),f=P(M(d),2);ia(f),T(d);var p=P(d,2),m=P(M(p),2);ia(m),T(p),T(c);var h=P(c,2),g=M(h);K(M(g),{get icon(){return La},class:`form-action-icon`}),Ue(2),T(g),T(h),T(t),F(()=>{g.disabled=I(i)||!I(a),W(g,`aria-busy`,I(i)?`true`:`false`)}),pa(f,()=>I(n),e=>A(n,e)),pa(m,()=>I(r),e=>A(r,e)),L(`click`,g,o),z(e,t)};V(l,e=>{I(a)&&e(u)}),z(e,c),D()}Hr([`click`]);function lH(e){return String(e&&e.status||`ok`).toLowerCase()}function uH(e){if(!e||typeof e!=`object`)return`Runtime refresh completed.`;let t=Number(e.model_count||0),n=Number(e.provider_count||0),r=lH(e);return(r===`ok`?`Runtime refreshed.`:r===`partial`?`Runtime refresh completed with warnings.`:`Runtime refresh failed.`)+` `+t+` model`+(t===1?``:`s`)+` across `+n+` provider`+(n===1?``:`s`)+`.`}function dH(e){return!!e&&lH(e)===`ok`}function fH(e){let t=e&&e.steps;return Array.isArray(t)?t:[]}function pH(e){let t=String(e&&e.name||``).replace(/_/g,` `),n=String(e&&e.status||``).trim(),r=String(e&&(e.error||e.message)||``).trim();return t?r?t+`: `+n+` - `+r:t+`: `+n:r||n||``}var mH=R(`

                      Runtime Refresh

                      `),hH=R(`
                    • `),gH=R(`
                        `),_H=R(`
                        `,1);function vH(e,t){E(t,!0);let n=k(!1),r=k(null);async function i(){if(!I(n)){A(n,!0),A(r,null);try{let e=await ys(`/admin/runtime/refresh`,`POST`,void 0,{label:`runtime refresh`});if(e.stale)return;if(!e.ok){J.error(`Runtime refresh failed.`);return}A(r,e.data&&typeof e.data==`object`?e.data:null,!0),dH(I(r))?J.success(uH(I(r))):J.error(uH(I(r))),q.refresh()}catch(e){console.error(`Failed to refresh runtime:`,e),J.error(`Runtime refresh failed.`)}finally{A(n,!1)}}}var a=_H(),o=N(a),s=M(o);JS(s,{copyId:`runtime-refresh-help-copy`,label:`runtime refresh help`,text:`Pull the latest model metadata, provider inventory, API keys, aliases, model access rules, guardrails, and workflows.`,title:e=>{z(e,mH())},$$slots:{title:!0}});var c=P(s,2),l=M(c);let u;K(M(l),{get icon(){return go},class:`settings-refresh-icon`}),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=M(d),p=e=>{var t=gH();H(t,21,()=>fH(I(r)),e=>e.name,(e,t)=>{var n=hH(),r=M(n,!0);T(n),F(e=>{U(n,1,`runtime-refresh-step is-${I(t).status??``}`,`svelte-yeq2mp`),B(r,e)},[()=>pH(I(t))]),z(e,n)}),T(t),z(e,t)},m=O(()=>fH(I(r)).length>0);V(f,e=>{I(m)&&e(p)}),T(d),F(()=>{u=U(l,1,`btn btn-primary btn-with-icon settings-refresh-btn`,null,u,{"is-refreshing":I(n)}),l.disabled=I(n),W(l,`aria-busy`,I(n)?`true`:`false`)}),L(`click`,l,i),z(e,a),D()}Hr([`click`]);var yH=R(``),bH=R(`

                        `),xH=R(`

                        `),SH=R(``),CH=R(`
                        `),wH=R(`

                        AI Processing

                        `);function TH(e,t){E(t,!0);let n=k(j([])),r=k(!1),i=k(``),a=k(``);async function o(){A(r,!0),A(a,``);try{let e=await vs(`/admin/runtime/settings`,{label:`runtime settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load runtime settings.`);return}A(n,Array.isArray(e.data?.settings)?e.data.settings:[],!0)}catch(e){console.error(`Failed to load runtime settings:`,e),A(a,`Unable to load runtime settings.`)}finally{A(r,!1)}}async function s(e,t,r){if(!(e.locked||I(i))){A(i,e.key,!0);try{let i=await ys(`/admin/runtime/settings/${encodeURIComponent(e.key)}`,`PUT`,{value:t},{label:`save ${e.label}`});if(i.stale){r.value=e.value;return}if(!i.ok){r.value=e.value,J.error(`Unable to save ${e.label}.`);return}A(n,I(n).map(t=>t.key===e.key?i.data:t),!0),J.success(`${e.label} saved.`)}catch(t){r.value=e.value,console.error(`Failed to save runtime setting:`,t),J.error(`Unable to save ${e.label}.`)}finally{A(i,``)}}}An(()=>{q.refreshTick,o()});var c=Qr(),l=N(c),u=e=>{var t=wH(),o=M(t),c=P(M(o),2),l=e=>{var t=yH(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(c,e=>{I(a)&&e(l)}),T(o);var u=P(o,2);H(u,21,()=>I(n),e=>e.key,(e,t)=>{var n=CH(),r=M(n),a=M(r),o=M(a,!0);T(a);var c=P(a,2),l=e=>{var n=bH(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(c,e=>{I(t).description&&e(l)});var u=P(c,2),d=e=>{var n=xH(),r=M(n);T(n),F(()=>B(r,`Managed by ${(I(t).managed_by||`environment`)??``}`)),z(e,n)};V(u,e=>{I(t).locked&&e(d)}),T(r);var f=P(r,2);H(f,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=SH(),r=M(n,!0);T(n);var i={};F(()=>{W(n,`title`,I(t).description||``),B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(f);var p;Ki(f),T(n),F(()=>{W(a,`for`,`runtime-setting-${I(t).key}`),B(o,I(t).label),W(f,`id`,`runtime-setting-${I(t).key}`),f.disabled=I(t).locked||I(i)!==``,p!==(p=I(t).value)&&(f.value=(f.__value=I(t).value)??``,Gi(f,I(t).value))}),L(`change`,f,e=>s(I(t),e.currentTarget.value,e.currentTarget)),z(e,n)}),T(u),T(t),F(()=>W(u,`aria-busy`,I(r)?`true`:`false`)),z(e,t)};V(l,e=>{(I(n).length>0||I(a))&&e(u)}),z(e,c),D()}Hr([`change`]);var EH=R(`
                        `);function DH(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`settings`&&(fs.ensureOptions(),Cs.ensureLoaded())});var n=EH(),r=P(M(n),2),i=M(r);kV(i,{});var a=P(i,2);MV(a,{});var o=P(a,2);HV(o,{});var s=P(o,2);WV(s,{});var c=P(s,2);nH(c,{});var l=P(c,2);TH(l,{});var u=P(l,2);cH(u,{}),vH(P(u,2),{}),T(r);var d=P(r,2),f=M(d,!0);T(d),T(n),F(e=>B(f,e),[()=>Wo()]),z(e,n),D()}var OH=R(`
                        `),kH=R(`
                         
                        `),AH=R(`
                         
                        `),jH=R(`
                         
                        `),MH=R(`
                        `),NH=R(`
                        `,1),PH=R(`
                        `);function FH(e,t){E(t,!0);let n=G(t,`showPromptCache`,3,!0),r=O(()=>t.msg.role===`function_call`||t.msg.role===`function_result`);function i(e){return(Math.max(0,Math.min(1,Number(e||0)))*100).toFixed(1)+`%`}function a(e){let t=Math.max(0,Math.min(1,Number(e||0)));return t>0?Math.round(t*100)+`% of this visible prompt item is estimated provider-cached`:void 0}function o(e){return e.role===`function_call`?(e.toolCalls||[]).map(e=>e.name+`()`).join(`, `):(e.functionName?e.functionName+`: `:``)+e.text}var s=PH();let c;var l=M(s),u=e=>{var r=kH(),i=M(r),s=M(i),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l);var d=P(l,2),f=M(d,!0);T(d),T(i);var p=P(i,2),m=e=>{var n=OH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${t.msg.functionCallID??``}`)),z(e,n)};V(p,e=>{t.msg.functionCallID&&e(m)});var h=P(p,2),g=e=>{var n=Qr();H(N(n),17,()=>t.msg.toolCalls,ci,(e,n)=>{var r=Qr(),i=N(r),a=e=>{var r=OH(),i=M(r);T(r),F(()=>B(i,`Call ID${t.msg.toolCalls.length>1?` (`+I(n).name+`)`:``}: ${I(n).id??``}`)),z(e,r)};V(i,e=>{I(n).id&&e(a)}),z(e,r)}),z(e,n)};V(h,e=>{t.msg.role===`function_call`&&t.msg.toolCalls&&e(g)});var _=P(h,2),v=M(_,!0);T(_),T(r),F((e,n,i,a)=>{W(r,`title`,e),B(c,t.msg.roleLabel),B(u,n),B(f,i),B(v,a)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>o(t.msg),()=>fs.formatTimestamp(t.msg.timestamp),()=>XI(t.msg)]),z(e,r)},d=e=>{var r=NH(),i=N(r),o=M(i),s=M(o,!0);T(o);var c=P(o,2),l=M(c,!0);T(c),T(i);var u=P(i,2),d=e=>{var r=AH(),i=M(r,!0);T(r),F(e=>{W(r,`title`,e),B(i,t.msg.text)},[()=>n()?a(t.msg.promptCacheRatio):void 0]),z(e,r)};V(u,e=>{t.msg.text&&e(d)});var f=P(u,2),p=e=>{var n=MH();H(n,23,()=>t.msg.toolCalls,(e,t)=>e.name+`-`+t,(e,t)=>{var n=jH(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(r);var c=P(r,2),l=e=>{var n=OH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${I(t).id??``}`)),z(e,n)};V(c,e=>{I(t).id&&e(l)});var u=P(c,2),d=M(u,!0);T(u),T(n),F((e,n)=>{B(a,I(t).name+`()`),B(s,e),B(d,n)},[()=>ZI(I(t))||`No arguments`,()=>ZI(I(t))||`No arguments`]),z(e,n)}),T(n),z(e,n)};V(f,e=>{t.msg.toolCalls&&e(p)}),F((e,n)=>{W(i,`title`,e),B(s,t.msg.roleLabel),B(l,n)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>fs.formatTimestamp(t.msg.timestamp)]),z(e,r)};V(l,e=>{I(r)?e(u):e(d,-1)}),T(s),F(e=>{U(s,1,Li([I(r)?`chat-function-note`:`chat-message`,t.msg.roleClass,{"is-anchor":t.msg.isAnchor,"is-after-anchor":t.msg.isAfterAnchor}]),`svelte-12s99s5`),W(s,`data-conversation-anchor`,t.msg.isAnchor?`true`:void 0),W(s,`data-entry-id`,t.msg.entryID),c=Wi(s,``,c,e)},[()=>({"--prompt-cache-fill":i(t.msg.promptCacheRatio),"--prompt-cache-visibility":n()&&t.msg.promptCacheRatio>0?`1`:`0`})]),z(e,s),D()}function IH(e,t=0){let n=Math.max(0,zH(e)-Math.max(0,zH(t))),r=Math.min(320,Math.max(180,Math.floor(n*.58))),i=Math.min(360,Math.max(128,Math.floor(n*.35)));return{min:r,max:Math.max(r,n-i)}}function LH(e,t,n=0){let r=IH(t,n),i=zH(e)||520;return Math.min(r.max,Math.max(r.min,Math.round(i)))}function RH(e,t,n=0){return LH(zH(t)-zH(e),t,n)}function zH(e){let t=Number(e);return Number.isFinite(t)?t:0}var BH=R(`
                        `),VH=R(`

                        Loading interactions...

                        `),HH=R(`

                        No interaction data available for this entry.

                        `),UH=R(``),WH=R(`
                        `,1),GH=R(`

                        Showing the newest part of this session and the selected log.

                        `),KH=R(`
                        `),qH=R(``),JH=R(``),YH=R(``);function XH(e,t){E(t,!0);let n=aL,r=Number(Ea(`gomodel_interactions_panel_width`)),i=`gomodel_interactions_prompt_cache_fill`,a=Number.isFinite(r)&&r>0?r:520,o=k(j(a)),s=k(320),c=k(760),l=k(!1),u=k(Ea(i,`true`)!==`false`),d=null;function f(){A(u,!I(u)),Da(i,I(u))}function p(){return(document.querySelector(`.sidebar`)?.getBoundingClientRect().width||0)+(document.querySelector(`.sidebar-toggle`)?.getBoundingClientRect().width||0)}function m(){let e=p(),t=IH(window.innerWidth,e);A(s,t.min,!0),A(c,t.max,!0),A(o,LH(a,window.innerWidth,e),!0)}function h(e){A(o,RH(e,window.innerWidth,p()),!0),a=I(o)}function g(e){e.button===0&&(e.preventDefault(),d=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`conversation-panel-resizing`),h(e.clientX))}function _(e){e.pointerId===d&&h(e.clientX)}function v(e){d===null||e.pointerId!==void 0&&e.pointerId!==d||(d=null,document.body.classList.remove(`conversation-panel-resizing`),Da(`gomodel_interactions_panel_width`,a))}function y(e){e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a=I(o)+(e.key===`ArrowLeft`?24:-24),m(),a=I(o),Da(`gomodel_interactions_panel_width`,a))}function b(){return[document.querySelector(`.sidebar`),document.querySelector(`.sidebar-toggle`),document.getElementById(`dashboard-content`)].filter(Boolean)}An(()=>{if(!n.conversationOpen)return;m();let e=document.querySelector(`.sidebar`),t=new ResizeObserver(m);e&&t.observe(e);let r=e=>{e.key===`Escape`&&!Ma.anyOpen&&(I(l)?A(l,!1):n.closeConversation())};return window.addEventListener(`keydown`,r),window.addEventListener(`resize`,m),()=>{v({}),t.disconnect(),window.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,m)}}),An(()=>{n.conversationOpen||A(l,!1)}),An(()=>{if(!I(l))return;let e=b().map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));return e.forEach(({element:e})=>{e.inert=!0,e.setAttribute(`aria-hidden`,`true`)}),()=>{e.forEach(({element:e,inert:t,ariaHidden:n})=>{e.inert=t,n===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)})}}),An(()=>{Yo.page!==`audit-logs`&&n.conversationOpen&&n.closeConversation()});var x=Qr(),S=N(x),C=e=>{var t=Qr();si(N(t),()=>I(l),e=>{var t=YH();let r,i;var a=M(t),d=P(a,2),p=M(d),m=P(M(p),2),h=M(m);let b;T(m),T(p);var x=P(p,2),S=M(x),C=M(S);{let e=O(()=>I(l)?co:so);K(C,{get icon(){return I(e)},class:`table-icon-svg`})}T(S),As(P(S,2),{label:`Close interactions`,onclick:()=>n.closeConversation(),get el(){return n.conversationCloseBtnEl},set el(e){n.conversationCloseBtnEl=e}}),T(x),T(d);var w=P(d,2),ee=M(w),te=e=>{var t=BH(),r=M(t,!0);T(t),F(()=>B(r,n.conversationError)),z(e,t)};V(ee,e=>{n.conversationError&&e(te)});var ne=P(ee,2),re=e=>{z(e,VH())};V(ne,e=>{n.conversationLoading&&e(re)});var ie=P(ne,2),ae=e=>{z(e,HH())},oe=O(()=>!n.conversationLoading&&!n.followUpSending&&!n.conversationError&&n.conversationMessages.length===0&&!n.conversationLiveWaiting());V(ie,e=>{I(oe)&&e(ae)});var se=P(ie,2),ce=e=>{var t=WH(),r=N(t),i=e=>{var t=UH(),n=M(t);let r;Ue(2),T(t),F(()=>{W(t,`aria-checked`,I(u)),W(t,`title`,(I(u)?`Hide`:`Show`)+` estimated provider prompt-cache fill`),r=U(n,1,`conversation-cache-switch svelte-ssrzja`,null,r,{"is-active":I(u)})}),L(`click`,t,f),z(e,t)},a=O(()=>n.conversationMessages.some(e=>Number(e.promptCacheRatio||0)>0));V(r,e=>{I(a)&&e(i)});var o=P(r,2);H(o,21,()=>n.conversationMessages,e=>e.uid,(e,t)=>{FH(e,{get msg(){return I(t)},get showPromptCache(){return I(u)}})}),T(o),va(o,e=>n.conversationThreadEl=e,()=>n?.conversationThreadEl),z(e,t)};V(se,e=>{n.conversationMessages.length>0&&e(ce)});var le=P(se,2),ue=e=>{z(e,GH())};V(le,e=>{n.conversationTruncated&&e(ue)});var de=P(le,2),fe=e=>{var t=KH(),r=P(M(t),2),i=M(r,!0);T(r),T(t),F(e=>B(i,e),[()=>n.conversationLiveStatusText()]),z(e,t)},pe=O(()=>n.conversationLiveWaiting());V(de,e=>{I(pe)&&e(fe)}),T(w);var me=P(w,2),he=e=>{var t=JH(),r=M(t),i=M(r);ft(i);var a=P(i,2),o=e=>{var t=qH(),r=M(t,!0);T(t),F(()=>B(r,n.followUpError)),z(e,t)};V(a,e=>{n.followUpError&&e(o)});var s=P(a,2),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u),T(s),T(r),T(t),F((e,t,r)=>{i.disabled=e,B(l,t),u.disabled=r,B(d,n.followUpSending?`Sending…`:`Send`)},[()=>n.followUpSending||n.conversationLiveWaiting(),()=>n.selectedConversationEntry()?.path||``,()=>!n.canSendFollowUp()]),Vr(`submit`,r,e=>{e.preventDefault(),n.sendFollowUp()}),pa(i,()=>n.followUpText,e=>n.followUpText=e),z(e,t)},ge=O(()=>n.conversationAnchorID&&n.followUpKind());V(me,e=>{I(ge)&&e(he)}),T(t),va(t,e=>n.conversationDialogEl=e,()=>n?.conversationDialogEl),F(()=>{r=U(t,1,`conversation-drawer svelte-ssrzja`,null,r,{"conversation-drawer-fullscreen":I(l)}),W(t,`role`,I(l)?`dialog`:void 0),W(t,`aria-modal`,I(l)?`true`:void 0),i=Wi(t,``,i,{"--conversation-panel-width":I(o)+`px`}),W(a,`aria-valuemin`,I(s)),W(a,`aria-valuemax`,I(c)),W(a,`aria-valuenow`,I(o)),W(m,`aria-label`,n.conversationFollowLatest?`Following the latest interaction`:`Viewing a historical interaction`),W(m,`title`,n.conversationFollowLatest?`Following the latest interaction as new events arrive`:`Viewing a historical interaction; live updates are not followed`),b=U(h,1,`live-dot`,null,b,{"is-streaming":n.conversationFollowLatest}),W(S,`aria-label`,I(l)?`Exit fullscreen interactions`:`Show interactions fullscreen`),W(S,`title`,I(l)?`Exit fullscreen`:`Fullscreen`),W(S,`aria-pressed`,I(l))}),L(`pointerdown`,a,g),L(`pointermove`,a,_),L(`pointerup`,a,v),Vr(`pointercancel`,a,v),Vr(`lostpointercapture`,a,v),L(`keydown`,a,y),L(`click`,S,()=>A(l,!I(l))),ji(3,t,()=>Js,()=>({x:40,duration:lP(140)})),z(e,t)}),z(e,t)};V(S,e=>{n.conversationOpen&&e(C)}),z(e,x),D()}Hr([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`click`]);var ZH=R(`
                        `,1);function QH(e,t){E(t,!0);let n={overview:vC,usage:mT,budgets:WE,"rate-limits":tO,models:Lj,workflows:iP,"audit-logs":YL,guardrails:HR,"mcp-servers":Sz,"providers-config":AB,"auth-keys":wV,settings:DH};fs.init(),Nc.init(),q.init(),Aa.init(),ja.init(),Yo.init(),An(()=>{q.refreshTick,Cs.fetch(),Pc.fetchModels(),Pc.fetchCategories()}),An(()=>{document.body.classList.toggle(`dashboard-modal-open`,Ma.anyOpen)});let r=O(()=>n[Yo.page]||vC);var i=ZH(),a=N(i);Os(a,{});var o=P(a,2);let s;var c=M(o);ic(c,{}),yi(P(c,2),()=>I(r),(e,t)=>{t(e,{})}),T(o);var l=P(o,2);XH(l,{});var u=P(l,2);Ls(u,{});var d=P(u,2);Us(d,{}),nc(P(d,2),{}),F(()=>s=U(o,1,`content`,null,s,{"interactions-open":aL.conversationOpen})),z(e,i),D()}ti(QH,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/admin/dashboard/static/dist/assets/index-B9uQpjJg.css b/internal/admin/dashboard/static/dist/assets/index-CRFx_SAS.css similarity index 78% rename from internal/admin/dashboard/static/dist/assets/index-B9uQpjJg.css rename to internal/admin/dashboard/static/dist/assets/index-CRFx_SAS.css index dbe93401b..9b26a74f2 100644 --- a/internal/admin/dashboard/static/dist/assets/index-B9uQpjJg.css +++ b/internal/admin/dashboard/static/dist/assets/index-CRFx_SAS.css @@ -1 +1 @@ -:root{--bg:#111110;--bg-surface:#1e1d1c;--bg-surface-hover:#2a2420;--border:#2a2826;--text:#e8e0d6;--text-muted:#9a918a;--accent:#b8956e;--accent-hover:#d4b896;--success:#34d399;--info:#3b82f6;--warning:#f59e0b;--danger:#ef4444;--prompt-cache-color:color-mix(in srgb, var(--info) 72%, #fff);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 24%, var(--bg-surface));--cache-meter-uncached:var(--token-input);--cache-meter-local:var(--token-local);--cache-meter-prompt:var(--token-prompt);--token-input:#c0824a;--token-output:#ddb27a;--token-prompt:color-mix(in srgb, var(--info) 60%, transparent);--token-local:color-mix(in srgb, var(--info) 20%, transparent);--sidebar-width:240px;--radius:8px;--chart-grid:#2a2826;--chart-text:#9a918a;--chart-day-marker:var(--text);--chart-tooltip-bg:#1e1d1c;--chart-tooltip-border:#2a2826;--chart-tooltip-text:#e8e0d6;--cal-level-0:#161b22;--cal-level-1:color-mix(in srgb, var(--info) 15%, var(--bg-surface));--cal-level-2:color-mix(in srgb, var(--info) 25%, var(--bg-surface));--cal-level-3:color-mix(in srgb, var(--info) 36%, var(--bg-surface));--cal-level-4:color-mix(in srgb, var(--info) 48%, var(--bg-surface));--cal-level-5:color-mix(in srgb, var(--info) 60%, var(--bg-surface));--cal-level-6:color-mix(in srgb, var(--info) 73%, var(--bg-surface));--cal-level-7:color-mix(in srgb, var(--info) 87%, var(--bg-surface));--cal-level-8:var(--info);--cal-level-9:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-10:color-mix(in srgb, var(--info) 62%, #fff);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface-hover) 86%, #fff 14%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface-hover) 72%, #fff 28%);--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}[data-theme=light]{--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}@media (prefers-color-scheme:light){:root:not([data-theme=dark]){--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}}*{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;line-height:1.5}body.dashboard-modal-open{overflow:hidden}.app{height:100vh;min-height:0;display:flex;overflow:hidden}.badge{background:var(--accent);color:#fff;text-transform:uppercase;letter-spacing:.5px;border-radius:10px;padding:2px 8px;font-size:10px;font-weight:600}.auth-dialog{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:min(440px,100%);padding:22px;box-shadow:0 24px 70px #00000061}.auth-dialog-header{justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px;display:flex}.auth-dialog h2{margin-top:2px;font-size:22px;line-height:1.2}.auth-dialog-close{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.auth-dialog-close:hover{color:var(--text);background:var(--bg-surface-hover)}.auth-dialog-close:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-hint{color:var(--text-muted);font-size:13px}.auth-dialog-error{color:var(--danger);font-size:13px;font-weight:600}.auth-dialog-form{gap:10px;margin-top:18px;display:grid}.auth-dialog-actions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}.content{-webkit-overflow-scrolling:touch;flex:1 1 0;width:100%;min-width:0;min-height:0;padding:32px;transition:width .2s;overflow-y:auto;container:dashboard-content/inline-size}.content>*{width:100%;max-width:1336px;margin-inline:auto}body.dashboard-modal-open .content{overflow-y:hidden}.content.interactions-open>*{max-width:none}.page-header{justify-content:space-between;align-items:center;margin-bottom:24px;display:flex}.page-header h2{letter-spacing:-.3px;font-size:22px;font-weight:700}.page-header-controls{align-items:center;gap:12px;display:flex}.page-with-sticky-date{grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:12px;display:grid}.page-with-sticky-date>*{grid-column:1/-1}.page-with-sticky-date>.date-range-page-header{grid-column:1}.page-with-sticky-date>.sticky-date-range{z-index:8;grid-column:2;justify-self:end;position:sticky;top:16px}.model-count{color:var(--text-muted);font-size:14px}.provider-status-section{margin-top:28px;scroll-margin-top:24px}.cards{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:28px;display:grid}.card{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px}.card-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);margin-bottom:8px;font-size:12px;font-weight:600}.card-value{letter-spacing:-.5px;font-size:28px;font-weight:700}.cache-meter{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:28px;padding:24px}.chart-container{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.chart-container h3{margin-bottom:16px;font-size:16px;font-weight:600}.chart-container-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;display:flex}.chart-container-header h3{margin-bottom:0}.chart-wrapper{height:210px;position:relative}.live-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:8px;height:8px}.live-dot.is-streaming{background:var(--success);position:relative}.live-dot.is-streaming:after{content:"";z-index:-1;background:color-mix(in srgb, var(--success) 55%, transparent);border-radius:50%;animation:1.8s ease-out infinite live-dot-pulse;position:absolute;inset:0}@media (prefers-reduced-motion:reduce){.live-dot.is-streaming:after{opacity:0;animation:none}}@keyframes live-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(2.5)}to{opacity:0;transform:scale(2.5)}}.alert{border-radius:var(--radius);margin-bottom:20px;padding:12px 16px;font-size:14px}.alert-warning{color:var(--warning);background:#f59e0b1a;border:1px solid #f59e0b4d}.table-toolbar{align-items:center;gap:12px;margin-bottom:16px;display:flex}.table-toolbar-main{flex:1;min-width:0}.table-toolbar-actions{justify-content:flex-end;margin-left:auto;display:flex}input:is([type=text],[type=date],[type=number]){background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:8px 12px;font-family:inherit;font-size:13px}input:is([type=text],[type=date],[type=number]):focus{border-color:var(--accent)}input:is([type=text],[type=date],[type=number]):disabled,textarea:disabled,.form-input:disabled{opacity:.6;cursor:not-allowed}.table-wrapper{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}.data-table{border-collapse:collapse;width:100%;font-size:14px}.data-table th{text-align:left;text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);background:var(--bg);border-bottom:1px solid var(--border);padding:12px 16px;font-size:12px;font-weight:600}.data-table th.model-actions-header{text-align:right;white-space:nowrap;width:1%;min-width:156px}.data-table td{border-bottom:1px solid var(--border);padding:10px 16px}.data-table tr:last-child td{border-bottom:none}.data-table tr:hover td{background:var(--bg-surface-hover)}.mono{font-family:SF Mono,Menlo,Consolas,monospace}.font-size-md{font-size:13px}.col-price,.data-table th.col-price{text-align:right}td.col-price{color:var(--text-muted);white-space:nowrap;font-family:SF Mono,Menlo,Consolas,monospace;font-size:13px}.provider-badge{background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:2px 10px;font-size:12px;font-weight:500;display:inline-block}.empty-state{text-align:center;color:var(--text-muted);padding:48px 0;font-size:14px}.empty-state-icon{width:auto;height:auto;max-height:160px;color:var(--text-muted);margin:0 auto;display:block}.empty-state-icon text{fill:var(--text-muted);font-family:inherit;font-weight:600}.chart-empty-overlay{pointer-events:none;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.chart-empty-overlay .empty-state-icon{width:auto;max-width:90%;height:auto;max-height:195px}.loading-spinner{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:16px;height:16px;animation:.8s linear infinite loading-spin}@keyframes loading-spin{to{transform:rotate(360deg)}}.table-action-btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;gap:6px;padding:6px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:inline-flex}.table-action-btn:hover:not(:disabled){background:var(--bg-surface-hover)}.table-action-btn:disabled{opacity:.45;cursor:default}.table-action-btn-danger{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.table-action-btn-active{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 12%, var(--bg));border-color:color-mix(in srgb, var(--accent) 38%, var(--border))}.table-action-btn-active:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 18%, var(--bg-surface-hover))}.table-action-btn-failover-active{color:var(--info);background:color-mix(in srgb, var(--cache-meter-prompt) 35%, var(--bg));border-color:color-mix(in srgb, var(--info) 45%, var(--border));position:relative}.table-action-btn-failover-active:hover:not(:disabled){background:color-mix(in srgb, var(--cache-meter-prompt) 45%, var(--bg-surface-hover))}.table-icon-btn{border-radius:6px;gap:0;width:32px;min-width:32px;height:32px;padding:0}.table-icon-btn.table-action-btn-active{position:relative}.table-icon-btn.table-action-btn-active:after{content:"";background:var(--accent);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-btn.table-action-btn-failover-active:after{content:"";background:var(--info);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-svg{flex-shrink:0;width:14px;height:14px}.model-editor{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:16px;padding:24px}.alias-kind-badge{border:1px solid var(--border);background:var(--bg);min-height:24px;color:var(--accent);letter-spacing:.2px;text-transform:uppercase;border-color:color-mix(in srgb, var(--accent) 55%, var(--border));border-radius:999px;justify-content:center;align-items:center;gap:4px;padding:0 10px;font-size:11px;font-weight:600;display:inline-flex}.form h3{font-size:20px;font-weight:700}.form-kicker,.form-hint{color:var(--text-muted);font-size:13px}.alias-actions-cell{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.model-list-actions{white-space:nowrap;flex-wrap:nowrap}.model-list-actions .table-icon-btn{flex:0 0 32px}.model-list-actions .alias-toggle{flex:none}.alias-toggle{border:1px solid var(--border);background:var(--bg);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:8px;padding:6px 10px;font-family:inherit;font-size:12px;transition:all .15s;display:inline-flex}.alias-toggle:hover:not(:disabled){background:var(--bg-surface-hover)}.alias-toggle:disabled{opacity:.45;cursor:default}.alias-toggle-track{background:color-mix(in srgb, var(--border) 80%, var(--bg));border-radius:6px;width:34px;height:18px;transition:background .15s;position:relative}.alias-toggle-thumb{background:var(--text-muted);border-radius:6px;width:16px;height:16px;transition:transform .15s,background .15s;position:absolute;top:1px;left:2px}.alias-toggle.enabled{border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.alias-toggle.enabled .alias-toggle-track{background:color-mix(in srgb, var(--success) 55%, var(--bg))}.alias-toggle.enabled .alias-toggle-thumb{background:#fff;transform:translate(14px)}.alias-toggle.restricted{border-color:color-mix(in srgb, var(--accent) 50%, var(--border));color:color-mix(in srgb, var(--accent) 70%, var(--text))}.alias-toggle.restricted .alias-toggle-track{background:color-mix(in srgb, var(--accent) 55%, var(--bg))}.editor-header{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:20px;display:flex}.form{flex-direction:column;gap:16px;display:flex}.auth-key-editor{background:color-mix(in srgb, var(--bg-surface) 82%, var(--bg) 18%)}.form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.form-field{flex-direction:column;gap:8px;display:flex}.form-field-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);font-size:12px;font-weight:600;display:inline-block}.vm-target-row{align-items:center;gap:8px;display:flex}.vm-target-row .vm-target-model{flex:auto;min-width:0}.vm-target-row .vm-target-weight{flex:0 0 88px;width:88px}.vm-status-row{justify-content:space-between;align-items:center;gap:12px;display:flex}.vm-status-row .vm-status-toggle{margin-left:auto}.form-error{border:1px solid color-mix(in srgb, var(--danger) 42%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface));color:var(--danger);overflow-wrap:anywhere;margin:0;padding:10px 12px;font-size:13px;font-weight:600;line-height:1.4}.form-error:empty{display:none}.form-field-error{color:var(--danger);overflow-wrap:anywhere;font-size:13px;font-weight:500;line-height:1.4}.form-field-required{color:var(--danger);margin-left:3px}:is(input,textarea,select)[aria-invalid=true]{border-color:color-mix(in srgb, var(--danger) 60%, var(--border))}:is(input,textarea,select)[aria-invalid=true]:focus{border-color:var(--danger)}textarea{resize:vertical;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:60px;color:var(--text);outline:none;padding:10px 12px;font-family:inherit;font-size:13px}textarea:focus{border-color:var(--accent)}.form-input{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:38px;color:var(--text);outline:none;padding:8px 10px;font-family:inherit;font-size:13px}.form-input:focus{border-color:var(--accent)}.form-actions{flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:16px;display:flex}.failover-target-actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.data-table tr.alias-row.is-valid td{background:var(--alias-row-valid-bg)}.data-table tr.alias-row.is-valid:hover td{background:var(--alias-row-valid-bg-hover)}.data-table tr.alias-row:not(.is-valid) td{background:color-mix(in srgb, var(--accent) 10%, var(--bg-surface))}.data-table tr.alias-row:not(.is-valid):hover td{background:color-mix(in srgb, var(--accent) 16%, var(--bg-surface-hover))}.data-table tr.alias-row.is-disabled td{background:var(--bg-surface);opacity:.58}.data-table tr.alias-row.is-disabled:hover td{background:var(--bg-surface-hover);opacity:.72}.data-table tr.model-access-disabled-row td{background:color-mix(in srgb, var(--danger) 6%, var(--bg-surface))}.data-table tr.model-access-disabled-row:hover td{background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface-hover))}.workflow-section-head{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-section-head h4{font-size:14px;font-weight:700}.workflow-preview{flex-direction:column;gap:12px;display:flex}.workflow-feature-toggles{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.workflow-feature-toggle{border:1px solid var(--border);background:var(--bg);border-radius:10px;align-items:center;gap:10px;padding:10px 12px;font-size:14px;font-weight:500;display:flex}.workflow-feature-toggle input{width:16px;height:16px}.model-chart-section{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:24px;padding:24px}.model-chart-section h3{margin:0;font-size:16px;font-weight:600}.model-chart-header{justify-content:space-between;align-items:center;gap:16px;margin-bottom:16px;display:flex}.bar-chart-wrap{width:100%;height:180px;position:relative}.form-select,.usage-log-select{appearance:none;background-color:var(--bg);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 17px),calc(100% - 12px);background-repeat:no-repeat;background-size:5px 5px;outline:none;min-width:140px;padding:8px 34px 8px 12px;font-family:inherit;font-size:13px}.form-select:disabled,.usage-log-select:disabled{cursor:not-allowed;opacity:.6}.form-select:focus,.usage-log-select:focus{border-color:var(--accent)}.form-select{width:100%;min-width:0}.usage-label-chips{flex-wrap:wrap;gap:4px;max-width:280px;display:inline-flex}.usage-label-chip{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg));min-height:20px;color:var(--text);white-space:nowrap;cursor:pointer;border-radius:999px;align-items:center;padding:1px 9px;font-family:inherit;font-size:11px;font-style:normal;font-weight:600;line-height:1.4;transition:background .15s,border-color .15s;display:inline-flex}.usage-label-chip:hover{background:color-mix(in srgb, var(--label-color,var(--accent)) 26%, var(--bg))}.usage-label-chip.active{background:color-mix(in srgb, var(--label-color,var(--accent)) 32%, var(--bg));border-color:var(--label-color,var(--accent));box-shadow:0 0 0 1px color-mix(in srgb, var(--label-color,var(--accent)) 55%, transparent)}@keyframes audit-live-summary-stripe-blink{0%,to{opacity:.9}50%{opacity:.28}}.audit-status-badge{border:1px solid var(--border);letter-spacing:.2px;background:var(--bg-surface);border-radius:999px;justify-content:center;align-items:center;min-width:46px;height:24px;padding:0 10px;font-size:12px;font-weight:600;display:inline-flex}.audit-status-badge.status-success{color:var(--success);border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.audit-status-badge.status-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.audit-status-badge.status-error{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.audit-status-badge.status-neutral{color:var(--text-muted)}.audit-status-badge.status-unknown{color:var(--text-muted);border-color:color-mix(in srgb, var(--border) 75%, transparent)}.audit-pane{border:1px solid var(--border);background:var(--bg);border-top:0;border-radius:0 0 8px 8px;min-width:0;padding:12px}.audit-pane h5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:11px;font-weight:600}.audit-prompt-cache-pill{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);min-height:20px;color:var(--prompt-cache-color);letter-spacing:.02em;text-transform:none;border-radius:999px;align-items:center;padding:2px 8px;font-size:11px;font-weight:700;display:inline-flex}.audit-prompt-cache-highlight{color:var(--prompt-cache-color);font-weight:700}.audit-audio{white-space:normal;flex-direction:column;gap:8px;display:flex}.audit-audio-player{width:100%;max-width:420px;height:36px}.audit-audio-meta{color:var(--text-muted);font-size:12px}.audit-audio-empty{align-items:flex-start;padding:4px 0}.audit-audio-icon{font-size:20px;line-height:1}.audit-audio-note{color:var(--text-muted);font-size:12px}.audit-audio-metadata{flex-direction:column;gap:2px;margin-top:4px;font-size:12px;display:flex}.audit-audio-meta-row{gap:8px;display:flex}.audit-audio-meta-key{color:var(--text-muted);min-width:120px}.conversation-body-highlight{border-left:2px solid color-mix(in srgb, var(--accent) 70%, var(--border));background:color-mix(in srgb, var(--accent) 10%, transparent);cursor:pointer;line-height:inherit;border-radius:2px;margin:0 0 0 -2px;padding:0 0 0 2px;display:inline}.conversation-body-highlight:hover{background:color-mix(in srgb, var(--accent) 18%, transparent)}.conversation-body-highlight.conversation-system{border-left-color:color-mix(in srgb, var(--warning) 70%, var(--border));background:color-mix(in srgb, var(--warning) 10%, transparent)}.conversation-body-highlight.conversation-user{border-left-color:color-mix(in srgb, var(--accent) 75%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent)}.conversation-body-highlight.conversation-assistant{border-left-color:color-mix(in srgb, var(--success) 65%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}#interactions-drawer-content{flex:1;min-height:0;overflow-y:auto}.pagination{justify-content:space-between;align-items:center;padding:12px 0 0;display:flex}.btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;padding:6px 16px;font-family:inherit;font-size:13px;transition:all .15s}.btn:hover:not(:disabled){background:var(--bg-surface-hover)}.btn-primary{background:var(--accent);border-color:color-mix(in srgb, var(--accent) 70%, #000 10%);color:#fff;font-weight:600;box-shadow:0 10px 22px #3b82f62e}.btn-primary:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 90%, #fff 10%);border-color:color-mix(in srgb, var(--accent) 78%, #000 12%)}.btn-danger-outline{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:0 0;font-weight:600}.btn-danger-outline:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 75%, var(--border))}.btn-danger{color:#fff;border-color:color-mix(in srgb, var(--danger) 76%, #000 12%);background:var(--danger);box-shadow:0 10px 22px color-mix(in srgb, var(--danger) 20%, transparent);font-weight:600}.btn-danger:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 90%, #fff 10%);border-color:color-mix(in srgb, var(--danger) 82%, #000 14%)}.btn-with-icon{justify-content:center;align-items:center;gap:8px;display:inline-flex}.btn-with-icon .table-icon-svg{width:16px;height:16px}.btn:disabled{opacity:.4;cursor:default}.settings-panel{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.inline-help-section{flex-direction:column;gap:2px;display:flex}.inline-help-title-row{align-items:center;gap:10px;display:inline-flex}.inline-help-title-row h2,.inline-help-title-row h3{margin-bottom:0}.inline-help-title-row h2:empty,.inline-help-title-row h3:empty{display:none}.inline-help-toggle{border:1px solid color-mix(in srgb, var(--accent) 28%, var(--border));width:16px;height:16px;color:var(--accent);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border-radius:4px;justify-content:center;align-items:center;padding:0;transition:color .18s,border-color .18s;display:inline-flex;position:relative}.inline-help-toggle:before{content:"";pointer-events:auto;background:0 0;width:32px;height:32px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.inline-help-toggle:hover{border-color:color-mix(in srgb, var(--accent) 48%, var(--border));color:var(--text);background:0 0}.inline-help-toggle:active{background:0 0}.inline-help-toggle:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.inline-help-toggle-icon{justify-content:center;align-items:center;width:100%;height:100%;padding-bottom:1px;font-size:13px;font-weight:700;line-height:1;transition:transform .52s cubic-bezier(.22,.72,.12,1);display:inline-flex;transform:rotate(0)}.inline-help-copy{max-width:780px;color:var(--text-muted);margin-top:2px;font-size:14px}.settings-select{width:100%}.settings-refresh-section{border-top:1px solid var(--border);justify-items:start;gap:12px;margin-top:24px;padding-top:22px;display:grid}.settings-refresh-section h3{font-size:18px}.settings-refresh-section p{max-width:720px;color:var(--text-muted);font-size:14px;line-height:1.55}.budget-list{gap:10px;padding:10px 0;display:grid}.budget-row{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);grid-template-columns:minmax(0,1fr);align-items:center;gap:16px;padding:12px 14px;display:grid}.budget-row-main{min-width:0}.budget-row-head{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:10px;min-width:0;display:grid}.budget-scope-value{width:fit-content;max-width:100%;min-height:24px;color:var(--text);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;justify-self:start;align-items:center;gap:5px;padding:2px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;display:inline-flex;overflow:hidden}.budget-user-path{border:1px solid color-mix(in srgb, var(--accent) 32%, var(--border));background:color-mix(in srgb, var(--accent) 9%, var(--bg))}.budget-label{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.budget-scope-icon{stroke-width:2.2px;opacity:.85;flex:0 0 12px;width:12px;height:12px}.budget-row-meta{min-width:0;color:var(--text-muted);align-items:center;gap:8px;font-size:12px;display:inline-flex}.budget-source{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:999px;padding:2px 7px;font-size:11px}.budget-row-period{justify-content:center;min-width:0;display:flex}.budget-row-controls{justify-content:flex-end;align-items:center;gap:8px;min-width:0;display:flex}.budget-bars{gap:6px;margin-top:10px;display:grid}.budget-bar-line{grid-template-columns:118px minmax(0,1fr);align-items:center;gap:10px;display:grid}.budget-bar-label{color:var(--text-muted);justify-content:space-between;align-items:center;gap:6px;font-size:11px;line-height:1;display:flex}.budget-bar-percent{font-weight:700}.budget-bar-track{background:color-mix(in srgb, var(--border) 75%, var(--bg));border-radius:999px;height:16px;position:relative;overflow:hidden}.budget-bar-fill{border-radius:inherit;min-width:0;height:100%;transition:width .2s}.budget-bar-fill-usage{background:color-mix(in srgb, var(--success) 82%, var(--accent))}.budget-bar-fill-danger{background:var(--danger)}.budget-bar-text-row{z-index:1;pointer-events:none;color:var(--text);position:absolute;inset:0}.budget-bar-text{text-overflow:ellipsis;white-space:nowrap;max-width:min(44%,190px);font-size:11px;font-weight:700;line-height:12px;position:absolute;top:50%;overflow:hidden}.budget-bar-text-center{max-width:min(46%,240px);left:50%;transform:translate(-50%,-50%)}.budget-bar-text-end{text-align:right;max-width:min(34%,180px);right:8px;transform:translateY(-50%)}.budget-period-label{border:1px solid var(--border);color:var(--text);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;gap:5px;padding:2px 7px;font-size:11px;font-weight:600;display:inline-flex}.budget-period-icon{stroke-width:2.2px;flex:0 0 12px;width:12px;height:12px}.budget-period-label-monthly{border-color:color-mix(in srgb, #30302c 62%, var(--border));background:color-mix(in srgb, #30302c 12%, var(--bg));color:color-mix(in srgb, #30302c 34%, var(--text) 66%)}.budget-period-label-weekly{border-color:color-mix(in srgb, #68765c 62%, var(--border));background:color-mix(in srgb, #68765c 12%, var(--bg));color:color-mix(in srgb, #68765c 34%, var(--text) 66%)}.budget-period-label-daily{border-color:color-mix(in srgb, #b5652d 62%, var(--border));background:color-mix(in srgb, #b5652d 12%, var(--bg));color:color-mix(in srgb, #b5652d 34%, var(--text) 66%)}.budget-period-label-hourly{border-color:color-mix(in srgb, #783f22 62%, var(--border));background:color-mix(in srgb, #783f22 12%, var(--bg));color:color-mix(in srgb, #783f22 34%, var(--text) 66%)}.budget-period-label-custom{border-style:dashed;border-color:color-mix(in srgb, #bfa584 68%, var(--border));background:color-mix(in srgb, #bfa584 16%, var(--bg));color:color-mix(in srgb, #8b6f4f 34%, var(--text) 66%)}[data-theme=light] .budget-period-label-monthly{color:#30302c}[data-theme=light] .budget-period-label-weekly{color:#68765c}[data-theme=light] .budget-period-label-daily{color:#b5652d}[data-theme=light] .budget-period-label-hourly{color:#783f22}[data-theme=light] .budget-period-label-custom{color:#8b6f4f}@media (prefers-color-scheme:light){:root:not([data-theme=dark]) .budget-period-label-monthly{color:#30302c}:root:not([data-theme=dark]) .budget-period-label-weekly{color:#68765c}:root:not([data-theme=dark]) .budget-period-label-daily{color:#b5652d}:root:not([data-theme=dark]) .budget-period-label-hourly{color:#783f22}:root:not([data-theme=dark]) .budget-period-label-custom{color:#8b6f4f}}.budget-row-actions{flex-flow:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.budget-action-btn{white-space:nowrap;justify-content:center;gap:0;width:28px;min-width:0;height:28px;padding:0;transition:width .18s,border-color .15s,background .15s,color .15s;overflow:hidden}.budget-action-btn:hover,.budget-action-btn:focus-visible{gap:6px;width:82px;padding:0 9px}.budget-action-label{opacity:0;max-width:0;transition:max-width .18s,opacity .12s;overflow:hidden}.budget-action-btn:hover .budget-action-label,.budget-action-btn:focus-visible .budget-action-label{opacity:1;max-width:58px}.budget-action-btn-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.budget-action-icon{flex:0 0 14px;width:14px;height:14px}.budget-editor{background:color-mix(in srgb, var(--bg-surface) 86%, var(--bg) 14%)}.budget-settings-actions{flex-wrap:wrap;gap:10px;display:flex}.budget-reset-dialog{max-width:460px}.form-action-icon{flex:0 0 16px;width:16px;height:16px}.settings-refresh-alert{margin-top:16px;margin-bottom:0}@media (width<=768px){.badge{display:none}.content{width:100%;margin:0 auto;padding:20px}.auth-dialog{padding:18px}.auth-dialog-actions{flex-direction:column-reverse}.auth-dialog-actions .btn{width:100%}.cards{grid-template-columns:repeat(2,1fr)}.page-header{flex-wrap:wrap;gap:12px}.page-header h2{width:100%}.page-header-controls{flex-wrap:wrap;justify-content:space-between;width:100%}.page-with-sticky-date{grid-template-columns:minmax(0,1fr)}.page-with-sticky-date>.date-range-page-header,.page-with-sticky-date>.sticky-date-range{grid-column:1}.page-with-sticky-date>.date-range-page-header{margin-bottom:12px}.page-with-sticky-date>.sticky-date-range{width:100%;margin-bottom:24px;top:10px}.sticky-date-range .date-picker-trigger{justify-content:space-between;width:100%}.usage-log-select{min-width:0}.budget-row{grid-template-columns:1fr}.budget-row-controls{flex-wrap:wrap}.budget-bar-line{grid-template-columns:1fr;gap:5px}.form-grid,.workflow-feature-toggles{grid-template-columns:1fr}.workflow-section-head{flex-direction:column;align-items:flex-start}.table-toolbar{flex-direction:column;align-items:stretch}.table-toolbar-actions{justify-content:stretch;margin-left:0}.table-toolbar-actions .btn{width:100%}.model-editor{padding:16px}.alias-actions-cell,.editor-header{flex-direction:column;align-items:flex-start}.alias-actions-cell .table-action-btn,.editor-header .table-action-btn{width:100%}.alias-actions-cell .table-icon-btn,.editor-header .table-icon-btn{width:36px}.model-list-actions{flex-flow:row;align-items:center}.model-list-actions .table-action-btn{width:auto}.model-list-actions .table-icon-btn{flex-basis:32px;width:32px}.model-editor .editor-header{flex-direction:row;align-items:flex-start}.model-editor .editor-header>:first-child{flex:1;min-width:0}.model-editor .editor-header .dialog-close-btn{flex:0 0 32px;align-self:flex-start;width:32px;min-width:32px}.settings-panel{padding:18px}.budget-settings-actions,.budget-settings-actions .btn{width:100%}}.workflow-conn{background:color-mix(in srgb, var(--accent) 44%, var(--border));flex:1 1 0;width:auto;min-width:13px;height:2px;position:relative}.workflow-conn:after{content:"";background:color-mix(in srgb, var(--accent) 44%, var(--border));clip-path:polygon(0 0,100% 50%,0 100%);width:7px;height:9px;position:absolute;top:50%;right:-1px;transform:translateY(-50%)}.workflow-node{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg-surface);text-align:center;flex-direction:column;flex-shrink:0;justify-content:center;align-items:center;gap:4px;min-width:72px;padding:8px 12px;display:flex}.auth-key-description{color:var(--text-muted);max-width:220px;font-size:13px}.auth-key-status-badge{border-radius:999px;padding:2px 10px;font-size:12px;font-weight:600;display:inline-block}.auth-key-status-active{background:color-mix(in srgb, var(--success) 12%, var(--bg));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));color:var(--success)}.auth-key-status-inactive{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border:1px solid color-mix(in srgb, var(--danger) 30%, var(--border));color:var(--danger)}.mcp-server-advanced{border:1px solid var(--border);border-radius:var(--radius);background:color-mix(in srgb, var(--bg-surface) 72%, var(--bg) 28%);overflow:hidden}.mcp-server-advanced>summary{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;list-style:none;display:flex}.mcp-server-advanced>summary::-webkit-details-marker{display:none}.mcp-server-advanced>summary:after{border-right:2px solid var(--text-muted);border-bottom:2px solid var(--text-muted);content:"";flex:none;width:7px;height:7px;transition:transform .15s;transform:rotate(45deg)}.mcp-server-advanced[open]>summary:after{transform:rotate(225deg)}.mcp-server-advanced-summary-copy{flex-direction:column;gap:2px;min-width:0;display:flex}.mcp-server-advanced-title{font-size:13px;font-weight:600}.mcp-server-advanced-fields{border-top:1px solid var(--border);flex-direction:column;gap:16px;padding:14px;display:flex}.copy-feedback-btn{align-items:center;gap:6px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.rate-limit-pressure-row{background-image:linear-gradient(to right, color-mix(in srgb, var(--success) 16%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-high{background-image:linear-gradient(to right, color-mix(in srgb, var(--warning) 20%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-full{background-image:linear-gradient(to right, color-mix(in srgb, var(--danger) 22%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.table-icon-btn.rate-limit-gauge-inherited{color:var(--accent-strong,var(--accent));background:linear-gradient(to right, color-mix(in srgb, var(--accent) 22%, var(--bg)) 50%, var(--bg) 50%);border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.auth-dialog-input-icon{width:16px;height:16px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.auth-dialog-input-shell:focus-within .auth-dialog-input-icon{color:var(--accent)}.auth-dialog-submit-icon{flex:0 0 16px;width:16px;height:16px}.nav-icon{flex:0 0 18px;width:18px;height:18px}.api-key-open-icon{flex:0 0 15px;width:15px;height:15px}.theme-icon{flex:0 0 14px;width:14px;height:14px}.theme-toggle-mobile .theme-icon{flex-basis:16px;width:16px;height:16px}@media (width<=768px){.sidebar-footer .api-key-open-icon{flex-basis:16px;width:16px;height:16px}}.failover-drafts-loading{min-height:96px}.models-loading-state{top:16px;left:var(--sidebar-width);z-index:110;pointer-events:none;--loading-state-min-height:0;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-surface);width:fit-content;box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);margin:0 auto;padding:10px 14px;position:fixed;right:0}@media (width<=768px){.models-loading-state{left:60px}}.sidebar.sidebar-collapsed~.content .models-loading-state{left:60px}.alias-create-icon{flex:0 0 16px;width:16px;height:16px}.pricing-override-remove-row{margin-bottom:1px}@media (width<=768px){.pricing-override-remove-row{margin-bottom:0}}.pricing-recalculate-dialog{max-width:480px}.settings-refresh-btn.is-refreshing .settings-refresh-icon{transform-origin:50%;animation:.8s linear infinite loading-spin}.cost-source-icon{width:14px;height:14px;color:var(--success);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.cache-savings-icon{width:14px;height:14px;color:var(--accent);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.theme-toggle.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;margin-bottom:10px;padding:2px;display:inline-flex}.theme-btn.svelte-1keql7b{width:28px;height:24px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:flex}.theme-btn.svelte-1keql7b:hover{color:var(--text)}.theme-btn.active.svelte-1keql7b{background:var(--accent);color:#fff}.theme-btn.svelte-1keql7b:focus-visible,.theme-toggle-mobile.svelte-1keql7b:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.theme-toggle-mobile.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);width:36px;height:36px;color:var(--text-muted);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:none}.theme-toggle-mobile.svelte-1keql7b:hover{color:var(--text)}.theme-toggle.is-compact.svelte-1keql7b{display:none}.theme-toggle-mobile.is-compact.svelte-1keql7b{margin:0 auto;display:flex}@media (width<=768px){.theme-toggle.svelte-1keql7b{display:none}.theme-toggle-mobile.svelte-1keql7b{margin:0 auto;display:flex}}.sidebar.svelte-1nwtzae{flex:0 0 var(--sidebar-width);width:var(--sidebar-width);background:var(--bg-surface);border-right:1px solid var(--border);-webkit-overflow-scrolling:touch;z-index:10;flex-direction:column;max-height:100vh;transition:flex-basis .2s,width .2s;display:flex;position:sticky;top:0;overflow:hidden auto}.sidebar.sidebar-resizing.svelte-1nwtzae{transition:none}.sidebar-header.svelte-1nwtzae{border-bottom:1px solid var(--border);align-items:center;gap:10px;padding:20px;display:flex}.sidebar-logo.svelte-1nwtzae{width:28px;height:28px;color:var(--accent);flex-shrink:0}.sidebar-logo.svelte-1nwtzae svg{width:100%;height:100%}.sidebar-header.svelte-1nwtzae h1{letter-spacing:-.3px;font-size:18px;font-weight:700}.sidebar-nav.svelte-1nwtzae{flex-direction:column;flex:1;gap:4px;padding:12px;display:flex}.nav-item.svelte-1nwtzae{border-radius:var(--radius);color:var(--text-muted);align-items:center;gap:10px;padding:8px 12px;font-size:14px;font-weight:500;text-decoration:none;transition:all .15s;display:flex}.nav-item.svelte-1nwtzae:hover{background:var(--bg-surface-hover);color:var(--text)}.nav-item.active.svelte-1nwtzae{background:var(--accent);color:#fff}.nav-label.svelte-1nwtzae{white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;overflow:hidden}.sidebar-footer.svelte-1nwtzae{border-top:1px solid var(--border);padding:16px}.api-key-section.svelte-1nwtzae{gap:8px;display:grid}.api-key-open-btn.svelte-1nwtzae{border:1px solid var(--accent);border-radius:var(--radius);width:100%;color:var(--accent);cursor:pointer;background:0 0;justify-content:center;align-items:center;gap:8px;padding:8px 10px;font-family:inherit;font-size:13px;font-weight:600;transition:background-color .15s,border-color .15s;display:inline-flex}.api-key-open-btn.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);border-color:color-mix(in srgb, var(--accent) 78%, var(--text));color:color-mix(in srgb, var(--accent) 78%, var(--text))}.api-key-open-btn.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.sidebar-toggle.svelte-1nwtzae{cursor:ew-resize;z-index:11;background:0 0;border:none;flex:0 0 6px;width:6px;height:100vh;padding:0;transition:background .15s;position:sticky;top:0}.sidebar-toggle.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 15%, transparent)}.sidebar-toggle.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}body.sidebar-resizing{cursor:ew-resize;-webkit-user-select:none;user-select:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae){justify-content:center;padding:16px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae) h1,.sidebar.sidebar-collapsed.svelte-1nwtzae .badge{display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae){padding:8px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:none}@media (width<=768px){.sidebar.svelte-1nwtzae{flex-basis:60px;width:60px}.sidebar-header.svelte-1nwtzae{justify-content:center;padding:16px}.sidebar-header.svelte-1nwtzae h1{display:none}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar-footer.svelte-1nwtzae{gap:8px;padding:8px;display:grid}.sidebar-footer.svelte-1nwtzae .api-key-section:where(.svelte-1nwtzae),.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:grid}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae){justify-self:center;width:36px;height:36px;min-height:36px;padding:0}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae) span,.sidebar-toggle.svelte-1nwtzae{display:none}}.dialog-close-btn.svelte-11l1bb5{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.dialog-close-btn.svelte-11l1bb5:hover{color:var(--text);background:var(--bg-surface-hover)}.dialog-close-btn.svelte-11l1bb5:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-backdrop.svelte-17e0w4c,.editor-modal-backdrop.svelte-17e0w4c{z-index:80;background:#0000007a;position:fixed;inset:0}.auth-dialog-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0}.editor-modal-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0;overflow-y:auto}.editor-modal-shell.svelte-17e0w4c>*{overscroll-behavior:contain;width:min(760px,100%);max-height:min(100vh - 40px,960px);margin:0;overflow:auto;box-shadow:0 24px 70px #00000061}@media (width<=768px){.auth-dialog-shell.svelte-17e0w4c,.editor-modal-shell.svelte-17e0w4c{align-items:end;padding:12px}.editor-modal-shell.svelte-17e0w4c>*{max-height:calc(100vh - 24px)}}.auth-dialog-input-shell.svelte-1dsu6u0{position:relative}.auth-dialog-input.svelte-1dsu6u0{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:11px 12px 11px 38px;font-family:inherit;font-size:14px}.auth-dialog-input.svelte-1dsu6u0:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}.flash-region.svelte-1i257xg{top:16px;left:var(--sidebar-width);z-index:120;pointer-events:none;flex-direction:column;align-items:center;gap:10px;display:flex;position:fixed;right:0}.sidebar.sidebar-collapsed~.flash-region.svelte-1i257xg{left:60px}@media (width<=768px){.flash-region.svelte-1i257xg{left:60px}}.flash-toast.svelte-1i257xg{border-radius:var(--radius);pointer-events:auto;align-items:flex-start;gap:10px;width:max-content;max-width:min(480px,100% - 32px);padding:12px 12px 12px 16px;font-size:14px;animation:.9s ease-out svelte-1i257xg-flash-toast-glow;display:flex;box-shadow:0 10px 30px #00000059}@keyframes svelte-1i257xg-flash-toast-glow{0%{box-shadow:0 0 0 4px color-mix(in srgb, currentColor 45%, transparent), 0 10px 30px #00000059}to{box-shadow:0 0 0 4px #0000,0 10px 30px #00000059}}@media (prefers-reduced-motion:reduce){.flash-toast.svelte-1i257xg{animation:none}}.flash-toast-success.svelte-1i257xg{background:color-mix(in srgb, var(--success) 14%, var(--bg-surface));color:var(--success);border:1px solid #34d39959}.flash-toast-error.svelte-1i257xg{background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--warning);border:1px solid #f59e0b66}.flash-toast-text.svelte-1i257xg{overflow-wrap:anywhere;flex:1;min-width:0}.flash-toast-dismiss.svelte-1i257xg{color:inherit;cursor:pointer;opacity:.7;background:0 0;border:0;flex-shrink:0;padding:0 2px;font-size:18px;line-height:1}.flash-toast-dismiss.svelte-1i257xg:hover{opacity:1}.demo-mode-banner.svelte-1s3mcn8{border:1px solid color-mix(in srgb, var(--warning) 55%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--text);box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;margin-bottom:24px;padding:12px 16px;display:grid}.demo-mode-banner-icon.svelte-1s3mcn8{width:20px;height:20px;color:var(--warning);flex:0 0 20px}.demo-mode-banner-copy.svelte-1s3mcn8{align-items:baseline;gap:8px;min-width:0;font-size:13px;display:flex}.demo-mode-banner.svelte-1s3mcn8 strong{color:var(--warning);letter-spacing:.06em;text-transform:uppercase;flex-shrink:0;font-size:12px}.demo-mode-banner-links.svelte-1s3mcn8{justify-content:flex-end;align-items:center;gap:6px;display:flex}.demo-mode-banner-links.svelte-1s3mcn8 a{border:1px solid color-mix(in srgb, var(--warning) 42%, var(--border));border-radius:var(--radius);min-height:28px;color:var(--text);white-space:nowrap;align-items:center;padding:4px 8px;font-size:12px;font-weight:600;line-height:1;text-decoration:none;display:inline-flex}.demo-mode-banner-links.svelte-1s3mcn8 a:hover{border-color:var(--warning);background:color-mix(in srgb, var(--warning) 16%, transparent);color:var(--text)}.demo-mode-banner-links.svelte-1s3mcn8 a:focus-visible{outline:2px solid color-mix(in srgb, var(--warning) 42%, transparent);outline-offset:2px}@media (width<=768px){.demo-mode-banner.svelte-1s3mcn8{grid-template-columns:auto minmax(0,1fr);align-items:flex-start}.demo-mode-banner-copy.svelte-1s3mcn8{gap:2px;display:grid}.demo-mode-banner-links.svelte-1s3mcn8{flex-wrap:wrap;grid-column:2;justify-content:flex-start}}.auth-banner.svelte-1c5yh36{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.dp-calendar.svelte-g7ga4u{flex-shrink:0;width:224px}.dp-cal-header.svelte-g7ga4u{justify-content:space-between;align-items:center;margin-bottom:8px;padding:0 4px;display:flex}.dp-cal-title.svelte-g7ga4u{font-size:13px;font-weight:600}.dp-nav-btn.svelte-g7ga4u{width:28px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:flex}.dp-nav-btn.svelte-g7ga4u:hover{background:var(--bg-surface-hover);color:var(--text)}.dp-nav-btn.svelte-g7ga4u:disabled{opacity:.3;cursor:default;pointer-events:none}.dp-nav-prev-mobile.svelte-g7ga4u{display:none}.dp-weekdays.svelte-g7ga4u{text-align:center;grid-template-columns:repeat(7,1fr);margin-bottom:4px;display:grid}.dp-weekdays.svelte-g7ga4u span:where(.svelte-g7ga4u){color:var(--text-muted);padding:4px 0;font-size:11px;font-weight:600}.dp-days.svelte-g7ga4u{grid-template-columns:repeat(7,1fr);gap:1px;display:grid}.dp-day.svelte-g7ga4u{width:32px;height:32px;color:var(--text);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:inherit;font-size:12px;transition:all .1s;display:flex}.dp-day.svelte-g7ga4u:hover:not(.disabled):not(.other-month){background:var(--bg-surface-hover)}.dp-day.other-month.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default}.dp-day.today.svelte-g7ga4u{color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);font-weight:700}.dp-day.in-range.svelte-g7ga4u{background:color-mix(in srgb, var(--accent) 15%, transparent);border-radius:0}.dp-day.range-start.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:6px 0 0 6px;font-weight:600}.dp-day.range-end.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:0 6px 6px 0;font-weight:600}.dp-day.range-start.range-end.svelte-g7ga4u{border-radius:6px}.dp-day.range-start.today.svelte-g7ga4u,.dp-day.range-end.today.svelte-g7ga4u{box-shadow:none}.dp-day.disabled.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default;pointer-events:none}@media (width<=768px){.dp-nav-prev-mobile.svelte-g7ga4u{display:flex}}.date-picker.svelte-ax7ma4{position:relative}.date-picker-trigger.svelte-ax7ma4{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;white-space:nowrap;align-items:center;gap:8px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s;display:inline-flex}.date-picker-trigger.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.date-picker-trigger.svelte-ax7ma4 svg:where(.svelte-ax7ma4){color:var(--text-muted);flex-shrink:0}.date-picker-chevron.svelte-ax7ma4{transition:transform .15s}.date-picker-chevron.open.svelte-ax7ma4{transform:rotate(180deg)}.date-picker-dropdown.svelte-ax7ma4{z-index:100;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:hidden;box-shadow:0 8px 24px #00000040}.date-picker-presets.svelte-ax7ma4{border-right:1px solid var(--border);flex-direction:column;gap:2px;min-width:140px;padding:8px;display:flex}.preset-btn.svelte-ax7ma4{color:var(--text);text-align:left;cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s}.preset-btn.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.preset-btn.active.svelte-ax7ma4{background:var(--accent);color:#fff}.date-picker-calendars.svelte-ax7ma4{flex-wrap:nowrap;gap:16px;padding:12px;display:flex}.dp-cursor-hint.svelte-ax7ma4{pointer-events:none;z-index:101;background:var(--bg-surface);color:var(--text);border:1px solid var(--accent);white-space:nowrap;border-radius:4px;align-items:center;gap:5px;padding:3px 8px;font-size:11px;font-weight:500;display:flex;position:fixed;transform:translate(12px,-50%)}.dp-cursor-hint.svelte-ax7ma4 svg:where(.svelte-ax7ma4){width:12px;height:12px;color:var(--accent);flex-shrink:0}@media (width<=768px){.date-picker-dropdown.svelte-ax7ma4{border-radius:var(--radius) var(--radius) 0 0;flex-direction:column;max-height:80vh;position:fixed;inset:auto 0 0;overflow-y:auto}.date-picker-presets.svelte-ax7ma4{-webkit-overflow-scrolling:touch;border-right:none;border-bottom:1px solid var(--border);flex-flow:row;min-width:0;overflow-x:auto}.date-picker-calendars.svelte-ax7ma4{justify-content:center}.date-picker-calendars.svelte-ax7ma4>.dp-calendar:first-child{display:none}}.segmented-control.svelte-92fh5i{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.segmented-btn.svelte-92fh5i{color:var(--text-muted);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;padding:5px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:flex}.segmented-btn.svelte-92fh5i:hover{color:var(--text)}.segmented-btn.active.svelte-92fh5i{background:var(--accent);color:#fff}@media (width<=768px){.segmented-btn.svelte-92fh5i{padding:4px 8px;font-size:11px}}.live-tokens.svelte-17qr2ta{margin-bottom:28px}.live-tokens-heading.svelte-17qr2ta{flex-direction:column;gap:2px;display:flex}.live-tokens-subtitle.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:6px;font-size:12px;display:inline-flex}.live-tokens-legend.svelte-17qr2ta{flex-wrap:wrap;gap:8px 18px;margin-bottom:16px;display:flex}.live-tokens-legend-item.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:7px;font-size:12px;display:inline-flex}.live-tokens-swatch.svelte-17qr2ta{border-radius:2px;flex-shrink:0;width:10px;height:10px}.live-tokens-legend-value.svelte-17qr2ta{color:var(--text);font-weight:600}.live-tokens-empty.svelte-17qr2ta .live-tokens-empty-text:where(.svelte-17qr2ta){color:var(--text-muted);font-size:13px}.provider-status-flag.svelte-6tr9cf{grid-column:span 2}.provider-status-overview-card.svelte-6tr9cf{grid-column:span 1}.provider-status-flag.is-healthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, var(--bg-surface))}.provider-status-flag.is-degraded.svelte-6tr9cf{border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-flag.is-unhealthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface))}.provider-status-value.svelte-6tr9cf{margin-bottom:8px}.provider-status-card-link.svelte-6tr9cf{color:var(--accent-strong,var(--accent));font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;margin:0;padding:0;font-size:13px;font-weight:600}.provider-status-card-link.svelte-6tr9cf:hover{color:var(--text);text-decoration:underline}.provider-status-card-link.svelte-6tr9cf:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:3px;border-radius:4px}.provider-status-card-note.svelte-6tr9cf{color:var(--text-muted);font-size:13px;display:block}@media (width>=720px){.card-wide.svelte-6tr9cf{grid-column:span 2}}.cache-token-value.svelte-6tr9cf{flex-wrap:wrap;align-items:center;gap:6px;line-height:1;display:flex}.cache-token-part.svelte-6tr9cf{align-items:center;display:inline-flex}.cache-token-operator.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;font-size:24px;font-weight:600;line-height:1}.cache-token-marker.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;text-transform:uppercase;margin-left:2px;font-size:14px;font-weight:700}.prompt-cache-gauge.svelte-6tr9cf{width:120px;height:60px;margin:8px auto 0;position:relative;overflow:hidden}.prompt-cache-gauge.svelte-6tr9cf canvas{display:block}.prompt-cache-gauge-value.svelte-6tr9cf{text-align:center;color:var(--text);font-size:18px;font-weight:700;line-height:1;position:absolute;bottom:4px;left:0;right:0}@media (width<=768px){.provider-status-flag.svelte-6tr9cf{grid-column:span 1}}.mcp-servers-flag.svelte-6tr9cf{grid-column:span 1}.cache-meter-header.svelte-1yzecxj{flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:16px;display:flex}.cache-meter-header.svelte-1yzecxj h3{font-size:16px;font-weight:600}.cache-meter-subtitle.svelte-1yzecxj{color:var(--text-muted);font-size:13px}.cache-meter-bar.svelte-1yzecxj{background:var(--bg-surface-hover);border-radius:6px;width:100%;height:28px;display:flex;overflow:hidden}.cache-meter-segment.svelte-1yzecxj{justify-content:center;align-items:center;min-width:3px;height:100%;transition:width .3s;display:flex;overflow:hidden}.cache-meter-segment-label.svelte-1yzecxj{color:#fff;white-space:nowrap;text-shadow:0 1px 2px #00000073;font-size:12px;font-weight:600;line-height:1}.cache-meter-segment.svelte-1yzecxj+.cache-meter-segment:where(.svelte-1yzecxj){box-shadow:-1px 0 0 var(--bg-surface)}.cache-meter-bar.is-empty.svelte-1yzecxj{background:var(--bg-surface-hover);justify-content:center;align-items:center;height:auto;min-height:28px;padding:6px 12px}.cache-meter-legend.svelte-1yzecxj{flex-wrap:wrap;gap:10px 24px;margin-top:16px;display:flex}.cache-meter-legend-item.svelte-1yzecxj{align-items:center;gap:8px;font-size:13px;display:flex}.cache-meter-swatch.svelte-1yzecxj{border-radius:3px;flex-shrink:0;width:12px;height:12px}.cache-meter-legend-label.svelte-1yzecxj{color:var(--text)}.cache-meter-legend-pct.svelte-1yzecxj{color:var(--text);font-weight:600}.cache-meter-legend-tokens.svelte-1yzecxj{color:var(--text-muted)}.cache-meter-empty.svelte-1yzecxj{color:var(--text-muted);text-align:center;font-size:13px}.spinner.svelte-b54l9o{width:var(--spinner-size);height:var(--spinner-size);border:2px solid var(--border,#80808059);border-top-color:var(--accent,currentColor);border-radius:50%;flex:none;animation:.7s linear infinite svelte-b54l9o-spinner-rotate;display:inline-block}@keyframes svelte-b54l9o-spinner-rotate{to{transform:rotate(360deg)}}.contribution-calendar-section.svelte-3hfxuq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-top:24px;padding:24px}.contribution-calendar-header.svelte-3hfxuq{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.contribution-calendar-header.svelte-3hfxuq h3{font-size:16px;font-weight:600}.contribution-calendar-grid-wrapper.svelte-3hfxuq{gap:8px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq{flex-direction:column;gap:2px;padding-top:22px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq span{height:13px;color:var(--text-muted);text-align:right;min-width:28px;font-size:10px;line-height:13px}.contribution-calendar-scroll.svelte-3hfxuq{--contribution-week-size:13px;--contribution-week-gap:2px;flex:1;min-width:0;overflow-x:auto}.contribution-calendar-months.svelte-3hfxuq{grid-auto-columns:var(--contribution-week-size);gap:var(--contribution-week-gap);grid-auto-flow:column;height:16px;margin-bottom:6px;display:grid}.contribution-calendar-month-label.svelte-3hfxuq{color:var(--text-muted);white-space:nowrap;font-size:10px}.contribution-calendar-grid.svelte-3hfxuq{gap:var(--contribution-week-gap);display:flex}.contribution-calendar-week.svelte-3hfxuq{flex-direction:column;gap:2px;display:flex}.contribution-calendar-cell.svelte-3hfxuq{width:var(--contribution-week-size);height:var(--contribution-week-size);background:var(--cal-level-0);border-radius:2px}.contribution-calendar-cell.level-1.svelte-3hfxuq{background:var(--cal-level-1)}.contribution-calendar-cell.level-2.svelte-3hfxuq{background:var(--cal-level-2)}.contribution-calendar-cell.level-3.svelte-3hfxuq{background:var(--cal-level-3)}.contribution-calendar-cell.level-4.svelte-3hfxuq{background:var(--cal-level-4)}.contribution-calendar-cell.level-5.svelte-3hfxuq{background:var(--cal-level-5)}.contribution-calendar-cell.level-6.svelte-3hfxuq{background:var(--cal-level-6)}.contribution-calendar-cell.level-7.svelte-3hfxuq{background:var(--cal-level-7)}.contribution-calendar-cell.level-8.svelte-3hfxuq{background:var(--cal-level-8)}.contribution-calendar-cell.level-9.svelte-3hfxuq{background:var(--cal-level-9)}.contribution-calendar-cell.level-10.svelte-3hfxuq{background:var(--cal-level-10)}.contribution-calendar-cell.empty.svelte-3hfxuq{background:0 0}.contribution-calendar-footer.svelte-3hfxuq{justify-content:space-between;align-items:center;gap:12px;margin-top:12px;display:flex}.contribution-calendar-meta.svelte-3hfxuq{flex-direction:column;gap:4px;display:flex}.contribution-calendar-summary.svelte-3hfxuq{color:var(--text-muted);font-size:12px}.contribution-calendar-legend.svelte-3hfxuq{color:var(--text-muted);align-items:center;gap:4px;font-size:11px;display:flex}.contribution-calendar-legend.svelte-3hfxuq .contribution-calendar-cell:where(.svelte-3hfxuq){cursor:default;width:11px;height:11px}.contribution-calendar-tooltip.svelte-3hfxuq{z-index:200;background:var(--bg-surface);color:var(--text);border:1px solid var(--border);white-space:nowrap;pointer-events:none;border-radius:4px;padding:4px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;position:fixed;transform:translate(-50%);box-shadow:0 4px 12px #0003}@media (width<=768px){.contribution-calendar-day-labels.svelte-3hfxuq{display:none}.contribution-calendar-section.svelte-3hfxuq{padding:16px}.contribution-calendar-footer.svelte-3hfxuq{flex-direction:column;align-items:flex-start}}.inline-help-toggle.is-open.svelte-y40or3{color:var(--text);background:0 0}.inline-help-toggle.is-open.svelte-y40or3 .inline-help-toggle-icon{transform:rotate(540deg)}.audit-stats-section.svelte-14e9yan{margin-top:24px}.audit-stats-header.svelte-14e9yan{align-items:flex-start}.audit-stats-kpis.svelte-14e9yan{flex-wrap:wrap;align-items:center;gap:14px;display:flex}.audit-stats-kpi.svelte-14e9yan{color:var(--text-muted);white-space:nowrap;align-items:center;gap:6px;font-size:12px;display:inline-flex}.audit-stats-kpi-value.svelte-14e9yan{color:var(--text);font-size:13px}.audit-stats-kpi-dot.svelte-14e9yan{border-radius:2px;flex-shrink:0;width:8px;height:8px}.audit-stats-dot-2xx.svelte-14e9yan{background:var(--success)}.audit-stats-dot-4xx.svelte-14e9yan{background:var(--warning)}.audit-stats-dot-5xx.svelte-14e9yan{background:var(--danger)}.provider-status-details.svelte-6y9wjv{opacity:0;grid-template-rows:0fr;transition:grid-template-rows .28s,opacity .22s;display:grid}.provider-status-details.is-expanded.svelte-6y9wjv{opacity:1;grid-template-rows:1fr}.provider-status-details.is-collapsed.svelte-6y9wjv{pointer-events:none}.provider-status-details-inner.svelte-6y9wjv{flex-direction:column;gap:14px;min-height:0;display:flex;overflow:hidden}.provider-status-reason.svelte-6y9wjv{color:var(--text-muted);font-size:13px}.provider-status-error.svelte-6y9wjv{color:var(--danger);overflow-wrap:break-word;font-size:12px}.provider-status-config-label.svelte-6y9wjv{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-config.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;padding-top:12px;display:flex}.provider-status-config-row.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-config-value.svelte-6y9wjv{color:var(--text);overflow-wrap:break-word;font-size:13px;display:block}.provider-status-health.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;margin-bottom:12px;padding-top:12px;display:flex}.provider-status-health-state.svelte-6y9wjv{border:1px solid var(--border);border-radius:999px;align-items:center;padding:1px 8px;font-size:12px;font-weight:600;display:inline-flex}.provider-status-health-state.is-healthy.svelte-6y9wjv{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-health-state.is-degraded.svelte-6y9wjv{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-health-state.is-unhealthy.svelte-6y9wjv{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-health-models.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-health-model.svelte-6y9wjv{color:var(--text);justify-content:space-between;gap:8px;font-size:13px;display:flex}.provider-status-health-model.is-flagged.svelte-6y9wjv{color:var(--danger)}.provider-status-health-model-name.svelte-6y9wjv{overflow-wrap:anywhere}.provider-status-health-model-stats.svelte-6y9wjv{white-space:nowrap;color:var(--text-muted)}.provider-status-health-model.is-flagged.svelte-6y9wjv .provider-status-health-model-stats:where(.svelte-6y9wjv){color:var(--danger);font-weight:700}.provider-status-card.svelte-nopjmh{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:14px;padding:18px;display:flex}.provider-status-card-toggle.svelte-nopjmh{border:0;border-top:1px solid var(--border);border-radius:0 0 var(--radius) var(--radius);color:var(--text-muted);cursor:pointer;background:0 0;justify-content:center;align-items:center;margin:auto -18px -18px;padding:7px 0;transition:background .15s,color .15s;display:flex}.provider-status-card-toggle.svelte-nopjmh:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);color:var(--text)}.provider-status-card-toggle.svelte-nopjmh:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:-2px}.provider-status-card-toggle.svelte-nopjmh .provider-status-card-toggle-icon{width:16px;height:16px;transition:transform .28s;display:block}.provider-status-card-toggle.is-expanded.svelte-nopjmh .provider-status-card-toggle-icon{transform:rotate(180deg)}.provider-status-card-head.svelte-nopjmh{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.provider-status-name.svelte-nopjmh{letter-spacing:-.02em;flex-wrap:wrap;align-items:baseline;gap:6px;font-size:16px;font-weight:700;display:flex}.provider-doc-help.svelte-nopjmh{align-self:center;text-decoration:none}.provider-status-name-type.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-pill.svelte-nopjmh{border:1px solid var(--border);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;min-height:28px;padding:0 10px;font-size:12px;font-weight:700;display:inline-flex}.provider-status-pill.is-healthy.svelte-nopjmh{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-pill.is-degraded.svelte-nopjmh{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-pill.is-unhealthy.svelte-nopjmh{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-meta.svelte-nopjmh{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.provider-status-meta-item.svelte-nopjmh{background:var(--bg);border:1px solid var(--border);border-radius:6px;flex-direction:column;gap:4px;padding:10px 12px;display:flex}.provider-status-meta-label.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-meta-value.svelte-nopjmh{color:var(--text);font-size:14px}@media (width<=768px){.provider-status-meta.svelte-nopjmh{grid-template-columns:1fr}}.provider-status-section-loading.svelte-1kx3uw4{justify-content:center;padding:24px 0;display:flex}.provider-status-section-header.svelte-1kx3uw4{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px;display:flex}.provider-status-toggle.svelte-1kx3uw4{background:var(--bg-surface);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:10px;padding:8px 12px;font-family:inherit;font-size:12px;font-weight:600;transition:background-color .18s,border-color .18s,color .18s;display:inline-flex}.provider-status-toggle.svelte-1kx3uw4:hover{background:var(--bg-surface-hover)}.provider-status-toggle.svelte-1kx3uw4:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.provider-status-toggle-copy.svelte-1kx3uw4{white-space:nowrap}.provider-status-toggle-track.svelte-1kx3uw4{background:color-mix(in srgb, var(--text-muted) 35%, var(--border));border-radius:999px;flex-shrink:0;width:34px;height:20px;transition:background-color .2s;position:relative}.provider-status-toggle-track.is-active.svelte-1kx3uw4{background:color-mix(in srgb, var(--accent) 82%, var(--bg-surface))}.provider-status-toggle-thumb.svelte-1kx3uw4{background:#fff;border-radius:50%;width:16px;height:16px;transition:transform .2s;position:absolute;top:2px;left:2px;box-shadow:0 1px 3px #0000003d}.provider-status-toggle-track.is-active.svelte-1kx3uw4 .provider-status-toggle-thumb:where(.svelte-1kx3uw4){transform:translate(14px)}.provider-status-grid.svelte-1kx3uw4{grid-template-columns:repeat(auto-fit,minmax(280px,1fr));align-items:start;gap:16px;display:grid}@media (width<=768px){.provider-status-section-header.svelte-1kx3uw4{flex-direction:column;align-items:flex-start}.provider-status-toggle.svelte-1kx3uw4{justify-content:space-between;width:100%}}.filter-input-wrap.svelte-30xz1k{flex:1;width:100%;min-width:min(400px,100%);display:flex;position:relative}.filter-input.svelte-30xz1k{flex:1;width:100%;min-width:0;padding-left:34px}.filter-input-wrap.svelte-30xz1k .filter-input-icon{width:14px;height:14px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.usage-page-filters.svelte-1oi6ywk{flex-wrap:wrap;gap:10px;margin-bottom:20px;display:flex}.usage-page-filters.svelte-1oi6ywk .usage-log-select{flex:0 auto}.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:220px;min-width:180px;max-width:360px}@media (width<=768px){.usage-page-filters.svelte-1oi6ywk .usage-log-select,.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:100%;max-width:none}}.pro-saved-value.svelte-1qiwzdu{flex-wrap:wrap;align-items:baseline;gap:8px;display:flex}.pro-saved-delta.svelte-1qiwzdu{color:var(--success);letter-spacing:0;font-size:13px;font-weight:600}.usage-breakdown-loading.svelte-1kee4g8{justify-content:center;align-items:center;min-height:120px;display:flex}.chart-view-toggle.svelte-1kee4g8{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.chart-view-btn.svelte-1kee4g8{width:30px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:inline-flex}.chart-view-btn.svelte-1kee4g8:hover{color:var(--text)}.chart-view-btn.active.svelte-1kee4g8{background:var(--accent);color:#fff}.chart-view-btn.svelte-1kee4g8 svg{fill:none;stroke:currentColor;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:16px;height:16px}.usage-chart-table-wrapper.svelte-1kee4g8{-webkit-overflow-scrolling:touch;margin-top:0;overflow-x:auto}.usage-chart-data-table.svelte-1kee4g8{min-width:max-content}.usage-chart-data-table.svelte-1kee4g8 th,.usage-chart-data-table.svelte-1kee4g8 td{white-space:nowrap}.pagination-info.svelte-1imew3q{color:var(--text-muted);font-size:13px}.pagination-buttons.svelte-1imew3q{gap:8px;display:flex}.usage-log-loading.svelte-hg4ill{justify-content:center;align-items:center;min-height:120px;display:flex}.usage-log-section.svelte-hg4ill{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.usage-log-section.svelte-hg4ill h3{margin-bottom:16px;font-size:16px;font-weight:600}.usage-log-section.svelte-hg4ill .table-wrapper{overflow-x:auto}.usage-log-toolbar.svelte-hg4ill{gap:12px;margin-bottom:16px;display:grid}.usage-filter-row.svelte-hg4ill{grid-template-columns:repeat(12,minmax(0,1fr));align-items:center;gap:12px;display:grid}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1/-1}.usage-filter-row-options.svelte-hg4ill{grid-template-columns:1fr}.usage-log-checkbox.svelte-hg4ill{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.usage-log-checkbox.svelte-hg4ill input{cursor:pointer;width:16px;height:16px}.usage-ts.svelte-hg4ill{white-space:nowrap;font-size:12px}.usage-log-row-cached.svelte-hg4ill td{opacity:.75;font-style:italic}.usage-log-row-cached.svelte-hg4ill .usage-log-cache-cell:where(.svelte-hg4ill){font-weight:700}.caveat-icon.svelte-hg4ill{color:var(--warning);cursor:help;margin-left:4px;font-size:14px}@media (width<=768px){.usage-log-toolbar.svelte-hg4ill{gap:10px}.usage-filter-row.svelte-hg4ill{grid-template-columns:1fr}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1}.usage-log-table.svelte-hg4ill{display:block;overflow-x:auto}}.usage-sticky-controls.svelte-spwie6{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}.usage-charts-grid.svelte-spwie6{flex-wrap:wrap;gap:24px;margin-bottom:24px;display:flex}.usage-charts-grid.svelte-spwie6 .model-chart-section{flex:calc(50% - 24px);min-width:420px;margin-bottom:0}@media (width<=520px){.usage-charts-grid.svelte-spwie6 .model-chart-section{min-width:0}}.loading-state.svelte-hzxv1d{min-height:var(--loading-state-min-height,64px);color:var(--text-muted);justify-content:center;align-items:center;gap:10px;font-size:14px;display:flex}.budget-bar-text-row-on-fill.svelte-1jm56wo{color:#fff;clip-path:inset(0 calc(100% - var(--budget-progress,0%)) 0 0)}.budget-bar-text-start.svelte-1jm56wo{left:8px;transform:translateY(-50%)}.budget-bar-track-period-custom.svelte-1jm56wo .budget-bar-text-row-on-fill:where(.svelte-1jm56wo){color:#3f332a}.budget-override-dialog.svelte-13ryo7h{max-width:460px}.budget-sort-control.svelte-1752fqe{align-items:center;gap:8px}.budget-sort-control.svelte-1752fqe label{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.budget-sort-select.svelte-1752fqe{background-color:var(--bg-surface);min-width:132px}.budget-sort-select.svelte-1752fqe:hover{background-color:var(--bg-surface-hover)}.model-name-cell.svelte-1iynym{flex-direction:column;gap:8px;display:flex}.model-name-primary.svelte-1iynym{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.model-name-secondary.svelte-1iynym{color:var(--text-muted);font-size:12px}.model-redirect-remove-btn.svelte-1iynym{appearance:none;color:var(--danger);cursor:pointer;background:0 0;border:0;margin-left:4px;padding:0;font-size:11px}.model-redirect-remove-btn.svelte-1iynym:hover:not(:disabled){text-decoration:underline}.model-redirect-remove-btn.svelte-1iynym:disabled{opacity:.45;cursor:default}.model-kind-icon.svelte-1iynym{border:1px solid color-mix(in srgb, var(--accent) 55%, var(--border));background:var(--bg);width:24px;height:24px;color:var(--accent);border-radius:999px;flex:0 0 24px;justify-content:center;align-items:center;display:inline-flex}.model-kind-icon-svg.svelte-1iynym{width:14px;height:14px}.model-row-actions.svelte-1iynym{text-align:right;width:170px}@media (width<=768px){.model-name-primary.svelte-1iynym{flex-direction:column;align-items:flex-start}}.provider-group-row.svelte-1911hy6 td{background:color-mix(in srgb, var(--accent) 6%, var(--bg));padding-top:12px;padding-bottom:12px}.provider-group-row.svelte-1911hy6:hover td{background:color-mix(in srgb, var(--accent) 8%, var(--bg))}.provider-group-header.svelte-1911hy6{justify-content:space-between;align-items:center;gap:16px;display:flex}.provider-group-meta.svelte-1911hy6{flex-direction:column;gap:4px;min-width:0;display:flex}.provider-group-title.svelte-1911hy6{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.provider-group-type.svelte-1911hy6,.provider-group-count.svelte-1911hy6,.provider-group-summary.svelte-1911hy6{color:var(--text-muted);font-size:12px}@media (width<=768px){.provider-group-header.svelte-1911hy6{flex-direction:column;align-items:flex-start}}.vm-session-affinity-checkbox.svelte-d1j6xw{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.vm-session-affinity-checkbox.svelte-d1j6xw input:where(.svelte-d1j6xw){accent-color:var(--accent);cursor:pointer}.pricing-override-rows.svelte-u8snes{gap:12px;display:grid}.pricing-override-row.svelte-u8snes{grid-template-columns:minmax(220px,1fr) minmax(130px,180px) 32px;align-items:end;gap:12px;display:grid}.pricing-override-row-actions.svelte-u8snes{justify-content:flex-start;display:flex}.pricing-override-tier-note.svelte-u8snes{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:6px;padding:10px 12px;font-size:13px}.pricing-preview.svelte-u8snes{border:1px solid var(--border);border-radius:6px;overflow:hidden}.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:minmax(150px,1fr) minmax(90px,auto) minmax(130px,.8fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.pricing-preview-header.svelte-u8snes{background:var(--bg);color:var(--text-muted);text-transform:uppercase;font-size:12px;font-weight:600}.pricing-preview-row.svelte-u8snes{border-top:1px solid var(--border);font-size:13px}.pricing-preview-row-empty.svelte-u8snes{color:var(--text-muted);grid-template-columns:1fr}@media (width<=768px){.pricing-override-row.svelte-u8snes,.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:1fr}}.failover-drafts-editor.svelte-1n87bip{flex-direction:column;gap:16px;display:flex}.failover-draft-header-actions.svelte-1n87bip{flex:none;align-items:center;gap:10px;display:flex}.failover-draft-counter.svelte-1n87bip{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.failover-draft-toolbar.svelte-1n87bip{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.failover-draft-toolbar.svelte-1n87bip .filter-input-wrap,.failover-draft-toolbar.svelte-1n87bip .filter-input{min-width:0}.failover-draft-toggle-all.svelte-1n87bip{flex:none}.failover-draft-list.svelte-1n87bip{flex-direction:column;gap:8px;max-height:min(52vh,430px);padding-right:4px;display:flex;overflow-y:auto}.failover-draft-row.svelte-1n87bip{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);cursor:pointer;grid-template-columns:18px minmax(0,1fr);align-items:start;gap:10px;padding:10px;display:grid}.failover-draft-row.svelte-1n87bip:hover{border-color:color-mix(in srgb, var(--accent) 42%, var(--border));background:var(--bg-surface-hover)}.failover-draft-row.svelte-1n87bip input{width:16px;height:16px;margin-top:2px}.failover-draft-copy.svelte-1n87bip{gap:4px;min-width:0;display:grid}.failover-draft-source.svelte-1n87bip,.failover-draft-targets.svelte-1n87bip{overflow-wrap:anywhere}.failover-draft-targets.svelte-1n87bip{color:var(--text-muted);font-size:12px}.failover-drafts-empty.svelte-1n87bip{align-items:center;min-height:96px;display:flex}.failover-draft-actions.svelte-1n87bip{margin-top:0}.category-tabs.svelte-scpjps{-webkit-overflow-scrolling:touch;align-items:center;gap:4px;margin-bottom:16px;padding-bottom:2px;display:flex;overflow-x:auto}.category-tab.svelte-scpjps{background:var(--bg-surface);border:1px solid var(--border);color:var(--text-muted);cursor:pointer;white-space:nowrap;border-radius:6px;flex-shrink:0;align-items:center;gap:6px;padding:6px 14px;font-family:inherit;font-size:13px;font-weight:500;transition:all .15s;display:inline-flex}.category-tab.svelte-scpjps:hover{color:var(--text);background:var(--bg-surface-hover)}.category-tab.active.svelte-scpjps{background:var(--accent);color:#fff;border-color:var(--accent)}.category-tab.svelte-scpjps .tab-count:where(.svelte-scpjps){background:#ffffff26;border-radius:9px;justify-content:center;align-items:center;min-width:20px;height:18px;padding:0 5px;font-size:11px;font-weight:600;line-height:1;display:inline-flex}.category-tab.svelte-scpjps:not(.active) .tab-count:where(.svelte-scpjps){background:var(--bg)}@media (width<=768px){.category-tabs.svelte-scpjps{gap:4px}.category-tab.svelte-scpjps{padding:5px 10px;font-size:12px}}.workflow-pipeline-meta.svelte-1viff7o{border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 86%, transparent);min-width:0;max-width:calc(100% - 28px);color:var(--text-muted);white-space:nowrap;appearance:none;cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:0;padding:2px 10px;font-size:12px;font-weight:500;line-height:1.2;transition:background-color .15s,border-color .15s,color .15s,box-shadow .15s;display:inline-flex;position:absolute;top:12px;right:14px;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover,.workflow-pipeline-meta.svelte-1viff7o:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface));color:color-mix(in srgb, var(--accent) 74%, var(--text))}.workflow-pipeline-meta.svelte-1viff7o:focus-visible{box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);outline:none}.workflow-pipeline-meta-label.svelte-1viff7o{flex:none;font-weight:700}.workflow-pipeline-meta-placeholder.svelte-1viff7o{opacity:1;flex:none;max-width:3ch;margin-left:4px;transition:max-width .18s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta-value.svelte-1viff7o{opacity:0;text-overflow:clip;flex:0 auto;max-width:0;margin-left:0;transition:max-width .22s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o){opacity:0;max-width:0;margin-left:0}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o){opacity:1;max-width:42ch;margin-left:4px}.workflow-pipeline-meta-icon.svelte-1viff7o{opacity:0;flex:none;justify-content:center;align-items:center;width:0;height:14px;margin-left:0;line-height:0;transition:width .18s,margin-left .18s,opacity .15s,transform .18s;display:inline-flex;overflow:hidden;transform:translate(4px)translateY(1px)scale(.84)}.workflow-pipeline-meta-icon.svelte-1viff7o svg{width:14px;height:14px}.workflow-pipeline-meta-copied.svelte-1viff7o,.workflow-pipeline-meta-copied.svelte-1viff7o:hover,.workflow-pipeline-meta-copied.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-icon:where(.svelte-1viff7o){opacity:1;width:14px;margin-left:6px;transform:translateY(1px)}.workflow-pipeline-meta-error.svelte-1viff7o,.workflow-pipeline-meta-error.svelte-1viff7o:hover,.workflow-pipeline-meta-error.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 34%, var(--border));color:var(--danger)}.workflow-pipeline.svelte-nbptrg{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg);flex-direction:column;gap:0;margin-bottom:12px;padding:18px 20px 20px;display:flex;position:relative}.workflow-pipeline-has-meta.svelte-nbptrg{padding-top:42px}.workflow-pipeline-row.svelte-nbptrg{align-items:center;width:100%;min-width:0;display:flex;overflow-x:auto}.workflow-node-icon.svelte-nbptrg{border-radius:var(--radius);background:var(--bg);width:28px;height:28px;color:var(--text-muted);justify-content:center;align-items:center;display:flex}.workflow-node-icon.svelte-nbptrg svg{stroke:currentColor;fill:none;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:15px;height:15px}.workflow-node-label.svelte-nbptrg{letter-spacing:.03em;color:var(--text);white-space:nowrap;font-size:11px;font-weight:700;line-height:1.2}.workflow-node-sub.svelte-nbptrg{color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;max-width:120px;font-size:10px;font-weight:500;line-height:1.2;font-family:var(--font-mono,ui-monospace, monospace);overflow:hidden}.workflow-node-badge.svelte-nbptrg{border-radius:var(--radius);letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;border:1px solid var(--border);background:var(--bg);color:var(--text-muted);align-items:center;padding:2px 7px;font-size:9px;font-weight:800;line-height:1.5;display:inline-flex}.workflow-node-endpoint.svelte-nbptrg{border-radius:var(--radius);border-color:var(--border);background:var(--bg-surface);flex-direction:row;gap:7px;min-width:auto;padding:10px 14px}.workflow-node-icon-endpoint.svelte-nbptrg{border-radius:var(--radius);width:auto;height:auto;color:var(--text-muted);background:0 0;justify-content:flex-start;padding:0}.workflow-node-icon-endpoint.svelte-nbptrg svg{width:14px;height:14px}.workflow-node-endpoint.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted);font-size:11px;font-weight:600}.workflow-node-feature.svelte-nbptrg{border-color:color-mix(in srgb, var(--accent) 46%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface))}.workflow-node-feature.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--accent) 16%, var(--bg));color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--accent) 70%, var(--text-muted))}.workflow-node-ai.svelte-nbptrg{border-radius:var(--radius);gap:6px;min-width:96px;padding:12px 16px}.workflow-async-section.svelte-nbptrg{justify-content:flex-end;align-items:center;gap:0;width:100%;min-width:0;margin-top:10px;display:flex}.workflow-async-turn.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 60px;height:2px;position:relative}.workflow-async-turn.svelte-nbptrg:before{content:"";background:color-mix(in srgb, var(--text-muted) 40%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);width:7px;height:9px;position:absolute;top:50%;left:-7px;transform:translateY(-50%)}.workflow-async-turn.svelte-nbptrg:after{content:"";border-right:2px dashed color-mix(in srgb, var(--text-muted) 40%, var(--border));height:16px;position:absolute;bottom:1px;right:0}.workflow-async-row.svelte-nbptrg{align-items:center;min-width:0;margin-right:7px;display:flex}.workflow-conn-async.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 24px;width:24px}.workflow-conn-async.svelte-nbptrg:after{background:color-mix(in srgb, var(--text-muted) 45%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);left:-1px;right:auto}.workflow-node-async.svelte-nbptrg{border-radius:var(--radius);border-style:dashed;flex-direction:row;gap:7px;min-width:auto;padding:7px 12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){border-radius:var(--radius);width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg) svg{width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){font-size:10px;font-weight:700}.workflow-async-label.svelte-nbptrg{letter-spacing:.1em;text-transform:uppercase;color:var(--text-muted);opacity:.55;white-space:nowrap;flex-shrink:0;align-items:center;margin-left:8px;font-size:9px;font-weight:800;display:inline-flex}.workflow-node-success.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 18%, var(--bg));color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 85%, var(--text))}.workflow-node-success.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 74%, var(--text-muted))}.workflow-node-success.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 14%, var(--bg));border-color:color-mix(in srgb, var(--success) 38%, var(--border));color:var(--success)}.workflow-node-current.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 16%, var(--bg));color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 85%, var(--text))}.workflow-node-current.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 72%, var(--text-muted))}.workflow-node-current.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 13%, var(--bg));border-color:color-mix(in srgb, var(--info) 36%, var(--border));color:var(--info)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 85%, var(--text))}.workflow-node-warning.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 72%, var(--text-muted))}.workflow-node-warning.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 38%, var(--border));color:var(--warning)}.workflow-node-error.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--danger) 14%, var(--bg));color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 85%, var(--text))}.workflow-node-error.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 72%, var(--text-muted))}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 12%, var(--bg));color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg),.workflow-node-neutral.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--text-muted) 84%, var(--border))}.workflow-node-neutral.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 10%, var(--bg));border-color:color-mix(in srgb, var(--text-muted) 28%, var(--border));color:var(--text-muted)}.workflow-conn-hit.svelte-nbptrg,.workflow-conn-hit.svelte-nbptrg:after{background:color-mix(in srgb, var(--success) 58%, var(--border))}.workflow-conn-dim.svelte-nbptrg,.workflow-conn-dim.svelte-nbptrg:after{background:color-mix(in srgb, var(--border) 75%, transparent)}.workflow-node-success.svelte-nbptrg{border-color:color-mix(in srgb, var(--success) 52%, var(--border));background:color-mix(in srgb, var(--success) 9%, var(--bg-surface))}.workflow-node-current.svelte-nbptrg{border-color:color-mix(in srgb, var(--info) 56%, var(--border));background:color-mix(in srgb, var(--info) 10%, var(--bg-surface))}.workflow-node-warning.svelte-nbptrg{border-color:color-mix(in srgb, var(--warning) 52%, var(--border));background:color-mix(in srgb, var(--warning) 9%, var(--bg-surface))}.workflow-node-error.svelte-nbptrg{border-color:color-mix(in srgb, var(--danger) 52%, var(--border));background:color-mix(in srgb, var(--danger) 9%, var(--bg-surface))}.workflow-node-neutral.svelte-nbptrg{border-color:color-mix(in srgb, var(--text-muted) 40%, var(--border));background:color-mix(in srgb, var(--text-muted) 8%, var(--bg-surface))}.workflow-node-skipped.svelte-nbptrg{opacity:.28;position:relative}.workflow-card.svelte-1fo9fvq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:16px;padding:20px;display:flex}.workflow-card-head.svelte-1fo9fvq{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-card-footer.svelte-1fo9fvq{flex-direction:column;align-items:stretch;gap:10px;display:flex}.workflow-card-head.svelte-1fo9fvq h3{font-size:18px;font-weight:700}.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq{flex-wrap:wrap;justify-content:flex-end;gap:8px;display:flex}.workflow-card-meta-footer.svelte-1fo9fvq{justify-content:flex-start}.workflow-card-footer.svelte-1fo9fvq .alias-actions-cell{align-self:flex-end}.workflow-card-description.svelte-1fo9fvq{color:var(--text-muted);font-size:14px}.workflow-guardrails.svelte-1fo9fvq{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list.svelte-1fo9fvq{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-item.svelte-1fo9fvq{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;display:flex}@media (width<=768px){.workflow-card-head.svelte-1fo9fvq,.workflow-card-footer.svelte-1fo9fvq,.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq,.workflow-guardrail-item.svelte-1fo9fvq{flex-direction:column;align-items:flex-start}}.model-editor.workflow-editor{width:min(1080px,100%);margin-bottom:0}.alert-inline-actions.svelte-1bcpzh1{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.workflow-guardrail-editor.svelte-1bcpzh1{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list-editor.svelte-1bcpzh1{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-row.svelte-1bcpzh1{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:stretch;align-items:center;gap:12px;padding:10px 12px;display:flex}.workflow-guardrail-field.svelte-1bcpzh1{flex:auto;min-width:0}.workflow-guardrail-step-field.svelte-1bcpzh1{flex:0 0 120px}.workflow-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-step-input.svelte-1bcpzh1{max-width:120px}@media (width<=768px){.workflow-guardrail-row.svelte-1bcpzh1{flex-direction:column;align-items:flex-start}.workflow-step-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-guardrail-field.svelte-1bcpzh1,.workflow-guardrail-step-field.svelte-1bcpzh1{flex-basis:auto;width:100%}}.workflow-list-loading.svelte-ie2kfk{justify-content:center;align-items:center;gap:8px;display:flex}.workflows-list.svelte-ie2kfk{min-width:0}.workflow-card-grid.svelte-ie2kfk{grid-template-columns:1fr;gap:16px;display:grid}.workflow-page-note.svelte-l8kr26{color:var(--text-muted);margin-top:6px;font-size:14px}.audit-log-toolbar.svelte-1pwbpcm{flex-direction:column;gap:10px;margin-bottom:14px;display:flex}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:repeat(12,minmax(0,1fr));gap:10px;display:grid}.audit-filter-select.svelte-1pwbpcm{grid-column:span 2;min-width:0}.audit-filter-row-search.svelte-1pwbpcm .filter-input-wrap{grid-column:1/-1;max-width:none}.audit-filter-row-controls.svelte-1pwbpcm .audit-filter-select:where(.svelte-1pwbpcm){grid-column:span 2}.audit-filter-row-controls.svelte-1pwbpcm .btn{grid-column:11/-1;justify-self:end;min-width:108px}.audit-clear-btn.svelte-1pwbpcm{justify-content:center;align-items:center;gap:8px;font-weight:600;display:inline-flex}.audit-clear-btn.svelte-1pwbpcm .table-icon-svg{width:12px;height:12px}@media (width<=768px){.audit-log-toolbar.svelte-1pwbpcm{gap:8px}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:1fr}.audit-filter-row.svelte-1pwbpcm .filter-input-wrap,.audit-filter-row.svelte-1pwbpcm .filter-input,.audit-filter-select.svelte-1pwbpcm,.audit-filter-row.svelte-1pwbpcm .btn{grid-column:auto}}.audit-live-status.svelte-tve6yv{color:var(--text-muted);align-items:center;gap:10px;margin-left:16px;padding-left:6px;font-size:12px;display:inline-flex}.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:1.8s ease-out infinite svelte-tve6yv-audit-live-dot-throb}@keyframes svelte-tve6yv-audit-live-dot-throb{0%{transform:scale(1)}35%{transform:scale(1.35)}70%{transform:scale(1)}to{transform:scale(1)}}@media (prefers-reduced-motion:reduce){.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:none}}.audit-live-status-text.is-live.svelte-tve6yv{color:var(--success);font-weight:600}.audit-entry-metadata.svelte-hyopt0{border-top:1px solid var(--border);align-items:center;gap:10px;margin-top:12px;padding-top:12px;display:flex}.audit-entry-metadata-label.svelte-hyopt0{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;flex:none;font-size:12px;font-weight:700}.audit-entry-context.svelte-hyopt0{flex-wrap:wrap;flex:auto;gap:8px;display:flex}.audit-alias-badge.svelte-hyopt0{background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 28%, var(--border));color:var(--accent-strong,var(--accent))}@media (width<=768px){.audit-entry-metadata.svelte-hyopt0{flex-direction:column;align-items:flex-start;gap:8px}}.audit-attempt-track.svelte-1eu22xn{cursor:pointer;align-items:center;gap:6px;display:inline-flex}.audit-attempt-track-pips.svelte-1eu22xn{align-items:center;gap:3px;display:inline-flex}.audit-attempt-pip.svelte-1eu22xn{background:var(--text-muted);border-radius:2px;width:8px;height:8px}.audit-attempt-pip.audit-attempt-success.svelte-1eu22xn{background:var(--success)}.audit-attempt-pip.audit-attempt-error.svelte-1eu22xn{background:var(--danger)}.audit-attempt-track-count.svelte-1eu22xn{color:var(--text-muted);font-size:11px}.audit-entry-summary.svelte-17mysgz{cursor:pointer;justify-content:space-between;align-items:center;gap:12px;padding:5px 14px;list-style:none;display:flex;position:relative}.audit-entry-summary.svelte-17mysgz::-webkit-details-marker{display:none}.audit-entry-summary-live-in-progress.svelte-17mysgz{background:color-mix(in srgb, var(--info) 7%, var(--bg))}.audit-entry-summary-has-interactions.svelte-17mysgz{padding-right:44px}.audit-entry-summary-live-in-progress.svelte-17mysgz:before{content:"";background:var(--info);pointer-events:none;width:3px;animation:1.2s ease-in-out infinite audit-live-summary-stripe-blink;position:absolute;inset:0 auto 0 0}@media (prefers-reduced-motion:reduce){.audit-entry-summary-live-in-progress.svelte-17mysgz:before{opacity:.78;animation:none}}.audit-entry-left.svelte-17mysgz{align-items:center;gap:8px;min-width:0;display:flex}.audit-entry-right.svelte-17mysgz{color:var(--text-muted);flex-shrink:0;align-items:center;gap:10px;min-height:28px;display:inline-flex}.audit-thread-expander.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);min-width:28px;height:28px;color:var(--text-muted);cursor:pointer;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;gap:3px;padding:0 7px 0 4px;transition:background .1s ease-out,color .1s ease-out;display:inline-flex}.audit-thread-expander.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 12%, var(--bg));color:var(--accent)}.audit-thread-expander.svelte-17mysgz .audit-thread-expander-svg{width:14px;height:14px}.audit-thread-count.svelte-17mysgz{font-size:11px;font-weight:600}.audit-conversation-trigger.svelte-17mysgz{border:0;border-left:1px solid var(--border);background:color-mix(in srgb, var(--accent) 12%, var(--bg));width:32px;height:100%;color:var(--accent);cursor:pointer;border-radius:0;justify-content:center;align-items:center;margin:0;transition:background .1s ease-out,color .1s ease-out;display:inline-flex;position:absolute;inset:0 0 0 auto}.audit-conversation-trigger.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 20%, var(--bg))}.audit-conversation-trigger-active.svelte-17mysgz{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 28%, var(--bg));box-shadow:inset 2px 0 0 color-mix(in srgb, var(--accent) 60%, transparent)}.audit-conversation-trigger-active.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 34%, var(--bg))}.audit-conversation-trigger.svelte-17mysgz .audit-conversation-trigger-svg{stroke-linecap:butt;stroke-linejoin:miter;width:18px;height:18px}.audit-path.svelte-17mysgz{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.audit-request-badge.svelte-17mysgz{white-space:nowrap;gap:6px;min-width:0}.audit-timestamp-time.svelte-17mysgz{display:none}.audit-provider-model.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);height:24px;color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;border-radius:999px;align-items:center;max-width:420px;padding:0 10px;font-size:12px;display:inline-flex;overflow:hidden}@container dashboard-content (width<=699px){.audit-entry-summary.svelte-17mysgz{flex-direction:column;align-items:flex-start}.audit-entry-right.svelte-17mysgz{justify-content:space-between;width:100%}.audit-request-status.svelte-17mysgz,.audit-timestamp-full.svelte-17mysgz{display:none}.audit-timestamp-time.svelte-17mysgz{display:inline}}.audit-pane-split.svelte-1h5puht{grid-template-columns:1fr 2fr;align-items:start;gap:10px 14px;display:grid}.audit-pane-split-single.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}@container dashboard-content (width<=699px){.audit-pane-split.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}}.audit-pane-split.svelte-1h5puht .audit-pane-block-error:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-pane-empty:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-size-warning:where(.svelte-1h5puht){grid-column:1/-1}.audit-pane-block.svelte-1h5puht{min-width:0}.audit-pane-block.svelte-1h5puht>h5{margin-bottom:6px}.audit-pane-block-head.svelte-1h5puht{justify-content:space-between;align-items:center;gap:8px;margin-bottom:6px;display:flex}.audit-pane-block-title.svelte-1h5puht{align-items:center;gap:8px;min-width:0;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn{background-color:var(--bg-surface);border:1px solid color-mix(in srgb, var(--border) 70%, var(--text) 30%);color:var(--text);cursor:pointer;border-radius:6px;flex:none;align-items:center;gap:6px;padding:4px 8px;font-family:inherit;font-size:12px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn:hover:not(:disabled){background:color-mix(in srgb, var(--bg-surface) 80%, var(--text) 20%);border-color:color-mix(in srgb, var(--border) 45%, var(--text) 55%)}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 18%, var(--bg-surface))}.audit-json.svelte-1h5puht{background:var(--bg-surface);border:1px solid var(--border);box-sizing:border-box;white-space:pre;max-width:100%;max-height:220px;color:var(--text);border-radius:6px;padding:10px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;line-height:1.45;overflow:auto}.audit-pane-error-message.svelte-1h5puht{color:var(--danger)}.audit-pane-clickable-preview.svelte-1h5puht{cursor:pointer}.audit-pane-clickable-preview.svelte-1h5puht:hover{background:color-mix(in srgb, var(--danger) 8%, transparent)}.audit-json-body.svelte-1h5puht{white-space:pre;overflow-wrap:normal}.audit-pane-empty.svelte-1h5puht{text-align:left;padding:8px 0 0}.audit-pane-pending.svelte-1h5puht{align-items:center;gap:8px;display:flex}.audit-pane-streaming.svelte-1h5puht{letter-spacing:.02em;color:var(--text-muted);align-items:center;gap:7px;padding-left:4px;font-size:11px;font-weight:600;display:inline-flex}.audit-size-warning.svelte-1h5puht{color:var(--warning);margin-top:8px;font-size:12px}.audit-request-response.svelte-1bc5vi5{margin-top:4px}.audit-pane-tablist.svelte-1bc5vi5{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:2px;display:flex}.audit-pane-tab.svelte-1bc5vi5{border:1px solid var(--border);color:var(--text-muted);cursor:pointer;background:0 0;border-bottom-color:#0000;border-radius:6px 6px 0 0;align-items:center;gap:8px;margin-bottom:-1px;margin-right:12px;padding:8px 12px;font-family:inherit;font-size:13px;transition:color .15s,border-color .15s,background-color .15s;display:inline-flex}.audit-pane-tab.svelte-1bc5vi5:not(.audit-pane-tab-active):hover{color:var(--text);background:color-mix(in srgb, var(--text) 5%, transparent)}.audit-pane-tab-active.svelte-1bc5vi5{color:var(--text);border-color:var(--border);border-bottom-color:var(--bg);background:var(--bg)}.audit-pane-tab-label.svelte-1bc5vi5{font-weight:600}.audit-pane-tabpanel.svelte-1bc5vi5{min-width:0}.audit-pane-icon.svelte-1bc5vi5{color:var(--text-muted);flex:none;align-items:center;display:inline-flex}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-request{color:var(--accent)}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-response{color:var(--info)}.audit-pane-icon.svelte-1bc5vi5 svg{width:16px;height:16px}.audit-pane-seq.svelte-1bc5vi5{color:var(--text-muted);font-size:12px}.audit-pane-kind.svelte-1bc5vi5{text-transform:uppercase;letter-spacing:.04em;font-size:10px;font-weight:600}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-primary{color:var(--text-muted)}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-failover{color:var(--accent);background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-retry{color:var(--warning);background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 30%, var(--border))}.audit-savings-pill.svelte-1bc5vi5{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);color:var(--prompt-cache-color);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;font-weight:700;display:inline-flex}.audit-step-pill.svelte-1bc5vi5{border:1px dashed var(--border);color:var(--text-muted);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;display:inline-flex}.audit-entry.svelte-cmjgwr{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);transition:background .12s ease-out,border-color .12s ease-out;overflow:hidden}.audit-entry-interactions-open.svelte-cmjgwr{border-color:color-mix(in srgb, var(--prompt-cache-color) 38%, var(--border))}.audit-entry-details.svelte-cmjgwr{border-top:1px solid var(--border);background:var(--bg-surface);padding:12px;overflow:hidden}.audit-thread.svelte-pneivi{flex-direction:column;gap:10px;display:flex}.audit-thread-children.svelte-pneivi{flex-direction:column;gap:10px;margin-left:26px;display:flex}.audit-thread-child.svelte-pneivi,.audit-thread-loading.svelte-pneivi{position:relative}.audit-thread-child.svelte-pneivi:before,.audit-thread-loading.svelte-pneivi:before{content:"";border-left:1px solid var(--border);border-bottom:1px solid var(--border);pointer-events:none;border-bottom-left-radius:6px;width:12px;height:calc(50% + 10px);position:absolute;top:-10px;left:-14px}.audit-thread-child.svelte-pneivi:not(:last-child):after{content:"";border-left:1px solid var(--border);pointer-events:none;position:absolute;top:50%;bottom:-10px;left:-14px}.audit-thread-loading.svelte-pneivi{padding:6px 0 6px 4px;display:flex}.audit-thread-more.svelte-pneivi{color:var(--text-muted);padding-left:4px;font-size:12px}.audit-log-loading.svelte-1nhcbov{justify-content:center;padding:2rem 0;display:flex}.audit-list-toolbar.svelte-1nhcbov{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;display:flex}.audit-list-toolbar-left.svelte-1nhcbov{flex-wrap:wrap;align-items:center;gap:16px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov{color:var(--text-muted);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:7px;font-size:13px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov input:where(.svelte-1nhcbov){accent-color:var(--accent);cursor:pointer}.audit-retention-note.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-retention-highlight.svelte-1nhcbov{color:var(--text);font-weight:600}.audit-log-section.svelte-1nhcbov{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.audit-log-summary.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-log-list.svelte-1nhcbov{flex-direction:column;gap:10px;display:flex}.settings-guardrails-list.svelte-1bvx512{min-width:0}.settings-guardrail-type-pill.svelte-1bvx512{border:1px solid color-mix(in srgb, var(--accent) 18%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent);color:var(--text);white-space:nowrap;border-radius:999px;align-items:center;padding:6px 10px;font-size:12px;font-weight:600;display:inline-flex}.settings-guardrail-summary.svelte-1bvx512{color:var(--text);font-size:14px;line-height:1.45}.settings-guardrail-description.svelte-1bvx512{color:var(--text-muted);margin-top:6px;font-size:12px}.model-editor.guardrails-editor-wide{width:min(1080px,100%)}.form-field-fieldset.svelte-s964s3{border:0;min-inline-size:0;margin:0;padding:0}.form-field-legend.svelte-s964s3{color:var(--text-muted);letter-spacing:.5px;text-transform:uppercase;padding:0;font-size:12px;font-weight:600}.model-editor.settings-guardrails-editor{min-width:0}.settings-guardrails-hero.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));border-radius:var(--radius);background:radial-gradient(circle at top right, color-mix(in srgb, var(--accent-hover) 18%, transparent), transparent 42%), radial-gradient(circle at bottom left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 40%), var(--bg-surface);justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:20px;padding:24px;display:flex}.settings-kicker.svelte-5x874c{color:var(--accent);letter-spacing:.08em;text-transform:uppercase;margin:0 0 10px;font-size:11px;font-weight:700}.settings-guardrails-hero.svelte-5x874c h3{margin-bottom:8px}.settings-guardrails-hero.svelte-5x874c p:last-child{color:var(--text-muted);margin-bottom:0}.settings-guardrails-meta.svelte-5x874c{gap:12px;display:flex}.settings-guardrails-stat.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));background:color-mix(in srgb, var(--bg-surface-hover) 76%, transparent);border-radius:16px;min-width:110px;padding:14px 16px}.settings-guardrails-stat-label.svelte-5x874c{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;margin-bottom:8px;font-size:11px;font-weight:700;display:block}.settings-guardrails-stat.svelte-5x874c strong{font-size:24px;font-weight:700}@media (width<=768px){.settings-guardrails-hero.svelte-5x874c{flex-direction:column}.settings-guardrails-meta.svelte-5x874c{width:100%}.settings-guardrails-stat.svelte-5x874c{flex:1 1 0}}.mcp-catalog-section.svelte-1xqrzco{margin-top:18px}.mcp-catalog-section.svelte-1xqrzco .form-field-label{margin-bottom:8px}.mcp-catalog-subtitle.svelte-1xqrzco{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.mcp-catalog-list.svelte-1xqrzco{flex-direction:column;gap:12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.mcp-catalog-item-name.svelte-1xqrzco{overflow-wrap:anywhere;font-size:13px}.mcp-catalog-item-aggregated.svelte-1xqrzco{color:var(--text-muted);overflow-wrap:anywhere;margin-top:2px;font-size:11px}.mcp-catalog-item-description.svelte-1xqrzco{color:var(--text-muted);margin:2px 0 0;font-size:13px;font-weight:400}.mcp-server-sub-counts.svelte-ah8nrt{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;max-width:280px;margin-top:4px;font-size:11px;overflow:hidden}.mcp-server-table-wrapper.svelte-ah8nrt{overflow-x:auto}.mcp-server-table-wrapper.svelte-ah8nrt .data-table{min-width:860px}.auth-key-form-fields.svelte-1gswxes>.form-field{margin-bottom:4px}.auth-key-dashboard-toggle.svelte-1gswxes{cursor:pointer;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-key-issued-banner.svelte-1gswxes{background:color-mix(in srgb, var(--success) 8%, var(--bg-surface));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));border-radius:var(--radius);margin-bottom:20px;padding:16px}.auth-key-issued-warning.svelte-1gswxes{color:color-mix(in srgb, var(--success) 80%, var(--text));margin-bottom:12px;font-size:13px;font-weight:600}.auth-key-issued-value-row.svelte-1gswxes{flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:12px;display:flex}.auth-key-issued-token.svelte-1gswxes{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);word-break:break-all;flex:1;min-width:0;padding:8px 12px;font-size:13px;overflow-x:auto}.usage-label-chip-static.svelte-nf0ldb,.usage-label-chip-static.svelte-nf0ldb:hover{cursor:default;background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.auth-key-redacted.svelte-nf0ldb{color:var(--text-muted);font-size:13px}.auth-key-actions-cell.svelte-nf0ldb{white-space:nowrap}.auth-key-row-deactivated.svelte-nf0ldb td:where(.svelte-nf0ldb):not(.auth-key-actions-cell){opacity:.55}.auth-key-expiry.svelte-nf0ldb{white-space:nowrap;align-items:center;gap:8px;display:inline-flex}.auth-key-th-help.svelte-nf0ldb{cursor:help;align-items:center;gap:4px;display:inline-flex}.auth-key-row-actions.svelte-nf0ldb{align-items:center;gap:6px;display:inline-flex}.auth-keys-loading.svelte-1xpdcqx{justify-content:center;align-items:center;padding:32px 0;display:flex}.auth-keys-help-notice.svelte-1xpdcqx{margin-bottom:20px}.auth-keys-inactive-toggle.svelte-1xpdcqx{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-keys-inactive-toggle.svelte-1xpdcqx input:where(.svelte-1xpdcqx){width:16px;height:16px;accent-color:var(--accent);cursor:pointer}.settings-panel-header.svelte-15kyv2y{justify-content:space-between;gap:16px;margin-bottom:20px;display:flex}.settings-panel-header.svelte-15kyv2y h3{font-size:18px}.settings-form-grid.svelte-15kyv2y{grid-template-columns:minmax(280px,420px);gap:16px;display:grid}@media (width<=768px){.settings-form-grid.svelte-15kyv2y{grid-template-columns:1fr}}.budget-settings-section.svelte-a747ys{width:100%}.budget-settings-grid.svelte-a747ys{gap:12px;display:grid}.budget-settings-row.svelte-a747ys{grid-template-columns:96px minmax(170px,1fr) minmax(110px,140px) minmax(110px,140px) minmax(220px,280px);align-items:start;gap:12px;display:grid}.budget-settings-period.svelte-a747ys{color:var(--text);letter-spacing:0;text-transform:uppercase;align-self:end;min-height:35px;padding-bottom:9px;font-size:12px;font-weight:700}.budget-settings-spacer.svelte-a747ys{min-height:1px}.budget-settings-help-cell.svelte-a747ys{align-self:start;min-width:0;min-height:35px}.budget-settings-help-cell.svelte-a747ys .inline-help-copy{max-width:280px;margin:22px 0 0;font-size:12px;line-height:1.35}@media (width<=768px){.budget-settings-grid.svelte-a747ys,.budget-settings-row.svelte-a747ys{grid-template-columns:1fr}.budget-settings-spacer.svelte-a747ys{display:none}}.tagging-settings-grid.svelte-18e8yem{gap:12px;display:grid}.tagging-settings-row.svelte-18e8yem{grid-template-columns:minmax(170px,1fr) minmax(150px,1fr) minmax(80px,110px) auto minmax(90px,auto);align-items:end;gap:12px;display:grid}.tagging-do-not-pass.svelte-18e8yem{color:var(--text);white-space:nowrap;align-items:center;gap:6px;min-height:35px;font-size:13px;display:flex}.tagging-row-trailer.svelte-18e8yem{align-items:center;gap:8px;min-height:35px;display:flex}.tagging-settings-empty.svelte-18e8yem{color:var(--text-muted);margin:0}.tagging-settings-actions.svelte-18e8yem{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.tagging-settings-row.svelte-18e8yem{grid-template-columns:1fr;align-items:stretch}.tagging-settings-actions.svelte-18e8yem,.tagging-settings-actions.svelte-18e8yem .btn{width:100%}}.pricing-recalculate-section.svelte-1cdxzyk{width:100%}.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:minmax(220px,320px) minmax(260px,360px);justify-content:start;align-items:end;gap:12px;width:100%;display:grid}.pricing-recalculate-date-field.svelte-1cdxzyk{grid-column:1/-1;width:100%;max-width:320px}.pricing-recalculate-filter-field.svelte-1cdxzyk{width:100%;max-width:360px}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker{width:100%}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-trigger{justify-content:space-between;width:100%}.pricing-recalculate-actions.svelte-1cdxzyk{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:1fr}.pricing-recalculate-actions.svelte-1cdxzyk,.pricing-recalculate-actions.svelte-1cdxzyk .btn{width:100%}}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-dropdown{inset:auto auto calc(100% + 6px) 0}.settings-refresh-icon.svelte-yeq2mp{flex:0 0 16px;width:16px;height:16px}.runtime-refresh-steps.svelte-yeq2mp{color:var(--text-muted);gap:8px;margin-top:14px;padding-left:18px;font-size:13px;display:grid}.runtime-refresh-step.is-ok.svelte-yeq2mp{color:var(--success)}.runtime-refresh-step.is-partial.svelte-yeq2mp{color:var(--warning)}.runtime-refresh-step.is-failed.svelte-yeq2mp{color:var(--danger)}.runtime-settings-copy.svelte-tldbe5{min-width:180px}.runtime-settings-fields.svelte-tldbe5{gap:16px;width:min(560px,100%);display:grid}.runtime-setting-row.svelte-tldbe5{grid-template-columns:minmax(220px,1fr) 180px;align-items:center;gap:20px;display:grid}.runtime-setting-description.svelte-tldbe5,.runtime-setting-managed.svelte-tldbe5{color:var(--text-muted);margin:4px 0 0;font-size:12px}.runtime-setting-managed.svelte-tldbe5{color:var(--warning)}@media (width<=720px){.runtime-setting-row.svelte-tldbe5{grid-template-columns:1fr;gap:8px}}.settings-version-footer.svelte-3naq7u{color:var(--text-muted);text-align:right;margin-top:24px;font-size:12px}.chat-message.svelte-12s99s5{border:1px solid var(--border);background:var(--bg);border-radius:10px;max-width:94%;padding:10px 12px;position:relative;overflow:hidden}.chat-message.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border));box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent)}.chat-message.is-after-anchor.svelte-12s99s5,.chat-function-note.is-after-anchor.svelte-12s99s5{opacity:.46}.chat-message.role-user.svelte-12s99s5{align-self:flex-start}.chat-message.role-assistant.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 18%, var(--bg));align-self:flex-end}.chat-message.role-system.svelte-12s99s5{background:color-mix(in srgb, var(--warning) 10%, var(--bg));align-self:center;width:100%;max-width:100%}.chat-message.role-error.svelte-12s99s5{border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg));align-self:flex-end}.chat-message.role-error.svelte-12s99s5 .chat-role:where(.svelte-12s99s5){color:color-mix(in srgb, var(--danger) 75%, var(--text-muted))}.chat-message-meta.svelte-12s99s5{justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:6px;display:flex}.chat-role.svelte-12s99s5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:12px;font-weight:700}.chat-time.svelte-12s99s5{color:var(--text-muted);white-space:nowrap;font-size:11px}.chat-content.svelte-12s99s5{white-space:pre-wrap;overflow-wrap:break-word;color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:13px;line-height:1.5}.chat-message.svelte-12s99s5:before,.chat-function-note.svelte-12s99s5:before{content:"";z-index:0;pointer-events:none;opacity:var(--prompt-cache-visibility);background:linear-gradient(90deg, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) 0, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) var(--prompt-cache-fill), transparent var(--prompt-cache-fill), transparent 100%);transition:opacity .15s;position:absolute;inset:0}.chat-message.svelte-12s99s5>:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5>:where(.svelte-12s99s5){z-index:1;position:relative}.chat-tool-calls.svelte-12s99s5{border-top:1px solid var(--border);flex-direction:column;gap:3px;margin-top:8px;padding-top:6px;display:flex}.chat-tool-call.svelte-12s99s5{color:var(--text-muted);border-radius:5px;min-width:0;padding:3px 5px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;position:relative;overflow:hidden}.chat-tool-call-summary.svelte-12s99s5{cursor:pointer;align-items:baseline;gap:6px;min-width:0;display:flex}.chat-tool-call-preview.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;opacity:.8;flex:1;min-width:0;overflow:hidden}.chat-tool-call-arguments.svelte-12s99s5{background:color-mix(in srgb, var(--border) 45%, transparent);color:var(--text);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;border-radius:6px;max-height:200px;margin-top:5px;padding:6px 8px;line-height:1.45;overflow:auto}.chat-tool-call-name.svelte-12s99s5:before{content:"⚡"}.chat-function-note.svelte-12s99s5{max-width:94%;color:var(--text-muted);background:color-mix(in srgb, var(--border) 40%, transparent);border:1px dashed var(--border);border-radius:12px;align-self:center;padding:4px 12px;font-size:12px;position:relative;overflow:hidden}.chat-function-note.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-inner.svelte-12s99s5{align-items:baseline;gap:6px;display:flex;overflow:hidden}.chat-function-note-inner.svelte-12s99s5 .chat-time:where(.svelte-12s99s5){flex-shrink:0;margin-left:auto}.chat-function-call-id.svelte-12s99s5{color:var(--text-muted);overflow-wrap:anywhere;margin-top:6px;font-size:10px}.chat-function-label.svelte-12s99s5{text-transform:uppercase;letter-spacing:.3px;white-space:nowrap;flex-shrink:0;font-size:11px;font-weight:600}.chat-function-label.svelte-12s99s5:before{content:"▸";margin-right:4px;transition:transform .12s;display:inline-block}.chat-function-note-details[open].svelte-12s99s5 .chat-function-label:where(.svelte-12s99s5):before{transform:rotate(90deg)}.chat-function-detail.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;overflow:hidden}.chat-function-note.role-function-call.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 8%, transparent);border-color:color-mix(in srgb, var(--accent) 30%, var(--border));align-self:flex-end}.chat-function-note.role-function-result.svelte-12s99s5{background:color-mix(in srgb, var(--success) 8%, transparent);border-color:color-mix(in srgb, var(--success) 30%, var(--border));align-self:flex-start}.chat-function-note.is-anchor.role-function-call.svelte-12s99s5,.chat-function-note.is-anchor.role-function-result.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-details.svelte-12s99s5{width:100%}.chat-function-note-details.svelte-12s99s5>summary{cursor:pointer;list-style:none}.chat-function-note-details.svelte-12s99s5>summary::-webkit-details-marker{display:none}.chat-function-expanded.svelte-12s99s5{border-top:1px solid var(--border);white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text);max-height:200px;margin-top:6px;padding-top:6px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;line-height:1.45;overflow:auto}@media (width<=768px){.chat-message.svelte-12s99s5{max-width:100%}}.conversation-drawer.svelte-ssrzja{flex:0 0 var(--conversation-panel-width);width:var(--conversation-panel-width);background:var(--bg-surface);border-left:1px solid var(--border);z-index:12;flex-direction:column;min-width:0;height:100vh;display:flex;position:sticky;top:0}.conversation-drawer-fullscreen.svelte-ssrzja{z-index:70;border-left:0;flex-basis:auto;width:100vw;height:100dvh;position:fixed;inset:0}.conversation-drawer-fullscreen.svelte-ssrzja .conversation-resize-handle:where(.svelte-ssrzja){display:none}.conversation-resize-handle.svelte-ssrzja{z-index:2;cursor:col-resize;touch-action:none;background:0 0;border:0;border-radius:0;outline:none;width:10px;padding:0;position:absolute;top:0;bottom:0;left:-5px}.conversation-resize-handle.svelte-ssrzja:after{content:"";background:0 0;width:2px;transition:background .15s;position:absolute;top:0;bottom:0;left:4px}.conversation-resize-handle.svelte-ssrzja:hover:after,.conversation-resize-handle.svelte-ssrzja:focus-visible:after{background:color-mix(in srgb, var(--accent) 70%, var(--border))}body.conversation-panel-resizing{cursor:col-resize;-webkit-user-select:none;user-select:none}.conversation-drawer-header.svelte-ssrzja{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:10px;padding:14px 16px;display:flex}.conversation-drawer-header-actions.svelte-ssrzja{align-items:center;gap:6px;display:flex}.conversation-drawer-title.svelte-ssrzja{align-items:center;gap:9px;min-width:0;display:flex}.conversation-follow-status.svelte-ssrzja{justify-content:center;align-items:center;margin:-4px;padding:4px;display:inline-flex}.conversation-drawer-header.svelte-ssrzja h3{font-size:16px;font-weight:700}.conversation-drawer-footer.svelte-ssrzja{border-top:1px solid var(--border);background:var(--bg-surface);flex-direction:column;flex-shrink:0;gap:9px;padding:10px 16px;display:flex}.conversation-composer.svelte-ssrzja{flex-direction:column;gap:7px;display:flex}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja){resize:vertical;border:1px solid var(--border);background:var(--bg);width:100%;min-height:50px;color:var(--text);font:inherit;border-radius:7px;padding:9px 10px;line-height:1.45}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):focus{outline:2px solid color-mix(in srgb, var(--accent) 38%, transparent);outline-offset:1px}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):disabled{opacity:.65}.conversation-composer-actions.svelte-ssrzja{justify-content:space-between;align-items:center;gap:10px;display:flex}.conversation-endpoint.svelte-ssrzja{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--text-muted);font-size:11px;overflow:hidden}.conversation-send-error.svelte-ssrzja{color:var(--danger);font-size:12px}.conversation-truncated.svelte-ssrzja{color:var(--text-muted);padding:0 16px 14px;font-size:12px}.conversation-cache-legend.svelte-ssrzja{color:var(--text-muted);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:7px;margin:12px 16px 0;padding:0;font-family:inherit;font-size:11px;display:flex}.conversation-cache-legend.svelte-ssrzja:hover{color:var(--text)}.conversation-cache-legend.svelte-ssrzja:focus-visible{outline:2px solid color-mix(in srgb, var(--prompt-cache-color) 35%, transparent);outline-offset:3px;border-radius:3px}.conversation-cache-switch.svelte-ssrzja{background:color-mix(in srgb, var(--text-muted) 30%, var(--border));border-radius:999px;flex:none;width:28px;height:16px;transition:background-color .15s;position:relative}.conversation-cache-switch.is-active.svelte-ssrzja{background:color-mix(in srgb, var(--prompt-cache-color) 80%, var(--bg))}.conversation-cache-switch-thumb.svelte-ssrzja{background:#fff;border-radius:50%;width:12px;height:12px;transition:transform .15s;position:absolute;top:2px;left:2px;box-shadow:0 1px 2px #0000003d}.conversation-cache-switch.is-active.svelte-ssrzja .conversation-cache-switch-thumb:where(.svelte-ssrzja){transform:translate(12px)}.conversation-cache-estimate.svelte-ssrzja{opacity:.75}.conversation-thread.svelte-ssrzja{flex-direction:column;gap:10px;padding:14px 16px 20px;display:flex}.conversation-live-status.svelte-ssrzja{color:var(--text-muted);align-items:center;gap:10px;padding:4px 16px 20px;font-size:13px;display:flex} +:root{--bg:#111110;--bg-surface:#1e1d1c;--bg-surface-hover:#2a2420;--border:#2a2826;--text:#e8e0d6;--text-muted:#9a918a;--accent:#b8956e;--accent-hover:#d4b896;--success:#34d399;--info:#3b82f6;--warning:#f59e0b;--danger:#ef4444;--prompt-cache-color:color-mix(in srgb, var(--info) 72%, #fff);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 24%, var(--bg-surface));--cache-meter-uncached:var(--token-input);--cache-meter-local:var(--token-local);--cache-meter-prompt:var(--token-prompt);--token-input:#c0824a;--token-output:#ddb27a;--token-prompt:color-mix(in srgb, var(--info) 60%, transparent);--token-local:color-mix(in srgb, var(--info) 20%, transparent);--sidebar-width:240px;--radius:8px;--chart-grid:#2a2826;--chart-text:#9a918a;--chart-day-marker:var(--text);--chart-tooltip-bg:#1e1d1c;--chart-tooltip-border:#2a2826;--chart-tooltip-text:#e8e0d6;--cal-level-0:#161b22;--cal-level-1:color-mix(in srgb, var(--info) 15%, var(--bg-surface));--cal-level-2:color-mix(in srgb, var(--info) 25%, var(--bg-surface));--cal-level-3:color-mix(in srgb, var(--info) 36%, var(--bg-surface));--cal-level-4:color-mix(in srgb, var(--info) 48%, var(--bg-surface));--cal-level-5:color-mix(in srgb, var(--info) 60%, var(--bg-surface));--cal-level-6:color-mix(in srgb, var(--info) 73%, var(--bg-surface));--cal-level-7:color-mix(in srgb, var(--info) 87%, var(--bg-surface));--cal-level-8:var(--info);--cal-level-9:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-10:color-mix(in srgb, var(--info) 62%, #fff);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface-hover) 86%, #fff 14%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface-hover) 72%, #fff 28%);--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}[data-theme=light]{--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}@media (prefers-color-scheme:light){:root:not([data-theme=dark]){--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}}*{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;line-height:1.5}body.dashboard-modal-open{overflow:hidden}.app{height:100vh;min-height:0;display:flex;overflow:hidden}.badge{background:var(--accent);color:#fff;text-transform:uppercase;letter-spacing:.5px;border-radius:10px;padding:2px 8px;font-size:10px;font-weight:600}.auth-dialog{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:min(440px,100%);padding:22px;box-shadow:0 24px 70px #00000061}.auth-dialog-header{justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px;display:flex}.auth-dialog h2{margin-top:2px;font-size:22px;line-height:1.2}.auth-dialog-close{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.auth-dialog-close:hover{color:var(--text);background:var(--bg-surface-hover)}.auth-dialog-close:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-hint{color:var(--text-muted);font-size:13px}.auth-dialog-error{color:var(--danger);font-size:13px;font-weight:600}.auth-dialog-form{gap:10px;margin-top:18px;display:grid}.auth-dialog-actions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}.content{-webkit-overflow-scrolling:touch;flex:1 1 0;width:100%;min-width:0;min-height:0;padding:32px;transition:width .2s;overflow-y:auto;container:dashboard-content/inline-size}.content>*{width:100%;max-width:1336px;margin-inline:auto}body.dashboard-modal-open .content{overflow-y:hidden}.content.interactions-open>*{max-width:none}.page-header{justify-content:space-between;align-items:center;margin-bottom:24px;display:flex}.page-header h2{letter-spacing:-.3px;font-size:22px;font-weight:700}.page-header-controls{align-items:center;gap:12px;display:flex}.page-with-sticky-date{grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:12px;display:grid}.page-with-sticky-date>*{grid-column:1/-1}.page-with-sticky-date>.date-range-page-header{grid-column:1}.page-with-sticky-date>.sticky-date-range{z-index:8;grid-column:2;justify-self:end;position:sticky;top:16px}.model-count{color:var(--text-muted);font-size:14px}.provider-status-section{margin-top:28px;scroll-margin-top:24px}.cards{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:28px;display:grid}.card{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px}.card-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);margin-bottom:8px;font-size:12px;font-weight:600}.card-value{letter-spacing:-.5px;font-size:28px;font-weight:700}.cache-meter{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:28px;padding:24px}.chart-container{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.chart-container h3{margin-bottom:16px;font-size:16px;font-weight:600}.chart-container-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;display:flex}.chart-container-header h3{margin-bottom:0}.chart-wrapper{height:210px;position:relative}.live-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:8px;height:8px}.live-dot.is-streaming{background:var(--success);position:relative}.live-dot.is-streaming:after{content:"";z-index:-1;background:color-mix(in srgb, var(--success) 55%, transparent);border-radius:50%;animation:1.8s ease-out infinite live-dot-pulse;position:absolute;inset:0}@media (prefers-reduced-motion:reduce){.live-dot.is-streaming:after{opacity:0;animation:none}}@keyframes live-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(2.5)}to{opacity:0;transform:scale(2.5)}}.alert{border-radius:var(--radius);margin-bottom:20px;padding:12px 16px;font-size:14px}.alert-warning{color:var(--warning);background:#f59e0b1a;border:1px solid #f59e0b4d}.table-toolbar{align-items:center;gap:12px;margin-bottom:16px;display:flex}.table-toolbar-main{flex:1;min-width:0}.table-toolbar-actions{justify-content:flex-end;margin-left:auto;display:flex}input:is([type=text],[type=date],[type=number]){background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:8px 12px;font-family:inherit;font-size:13px}input:is([type=text],[type=date],[type=number]):focus{border-color:var(--accent)}input:is([type=text],[type=date],[type=number]):disabled,textarea:disabled,.form-input:disabled{opacity:.6;cursor:not-allowed}.table-wrapper{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}.data-table{border-collapse:collapse;width:100%;font-size:14px}.data-table th{text-align:left;text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);background:var(--bg);border-bottom:1px solid var(--border);padding:12px 16px;font-size:12px;font-weight:600}.data-table th.model-actions-header{text-align:right;white-space:nowrap;width:1%;min-width:156px}.data-table td{border-bottom:1px solid var(--border);padding:10px 16px}.data-table tr:last-child td{border-bottom:none}.data-table tr:hover td{background:var(--bg-surface-hover)}.mono{font-family:SF Mono,Menlo,Consolas,monospace}.font-size-md{font-size:13px}.col-price,.data-table th.col-price{text-align:right}td.col-price{color:var(--text-muted);white-space:nowrap;font-family:SF Mono,Menlo,Consolas,monospace;font-size:13px}.provider-badge{background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:2px 10px;font-size:12px;font-weight:500;display:inline-block}.empty-state{text-align:center;color:var(--text-muted);padding:48px 0;font-size:14px}.empty-state-icon{width:auto;height:auto;max-height:160px;color:var(--text-muted);margin:0 auto;display:block}.empty-state-icon text{fill:var(--text-muted);font-family:inherit;font-weight:600}.chart-empty-overlay{pointer-events:none;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.chart-empty-overlay .empty-state-icon{width:auto;max-width:90%;height:auto;max-height:195px}.loading-spinner{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:16px;height:16px;animation:.8s linear infinite loading-spin}@keyframes loading-spin{to{transform:rotate(360deg)}}.table-action-btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;gap:6px;padding:6px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:inline-flex}.table-action-btn:hover:not(:disabled){background:var(--bg-surface-hover)}.table-action-btn:disabled{opacity:.45;cursor:default}.table-action-btn-danger{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.table-action-btn-active{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 12%, var(--bg));border-color:color-mix(in srgb, var(--accent) 38%, var(--border))}.table-action-btn-active:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 18%, var(--bg-surface-hover))}.table-action-btn-failover-active{color:var(--info);background:color-mix(in srgb, var(--cache-meter-prompt) 35%, var(--bg));border-color:color-mix(in srgb, var(--info) 45%, var(--border));position:relative}.table-action-btn-failover-active:hover:not(:disabled){background:color-mix(in srgb, var(--cache-meter-prompt) 45%, var(--bg-surface-hover))}.table-icon-btn{border-radius:6px;gap:0;width:32px;min-width:32px;height:32px;padding:0}.table-icon-btn.table-action-btn-active{position:relative}.table-icon-btn.table-action-btn-active:after{content:"";background:var(--accent);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-btn.table-action-btn-failover-active:after{content:"";background:var(--info);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-svg{flex-shrink:0;width:14px;height:14px}.model-editor{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:16px;padding:24px}.alias-kind-badge{border:1px solid var(--border);background:var(--bg);min-height:24px;color:var(--accent);letter-spacing:.2px;text-transform:uppercase;border-color:color-mix(in srgb, var(--accent) 55%, var(--border));border-radius:999px;justify-content:center;align-items:center;gap:4px;padding:0 10px;font-size:11px;font-weight:600;display:inline-flex}.form h3{font-size:20px;font-weight:700}.form-kicker,.form-hint{color:var(--text-muted);font-size:13px}.alias-actions-cell{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.model-list-actions{white-space:nowrap;flex-wrap:nowrap}.model-list-actions .table-icon-btn{flex:0 0 32px}.model-list-actions .alias-toggle{flex:none}.alias-toggle{border:1px solid var(--border);background:var(--bg);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:8px;padding:6px 10px;font-family:inherit;font-size:12px;transition:all .15s;display:inline-flex}.alias-toggle:hover:not(:disabled){background:var(--bg-surface-hover)}.alias-toggle:disabled{opacity:.45;cursor:default}.alias-toggle-track{background:color-mix(in srgb, var(--border) 80%, var(--bg));border-radius:6px;width:34px;height:18px;transition:background .15s;position:relative}.alias-toggle-thumb{background:var(--text-muted);border-radius:6px;width:16px;height:16px;transition:transform .15s,background .15s;position:absolute;top:1px;left:2px}.alias-toggle.enabled{border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.alias-toggle.enabled .alias-toggle-track{background:color-mix(in srgb, var(--success) 55%, var(--bg))}.alias-toggle.enabled .alias-toggle-thumb{background:#fff;transform:translate(14px)}.alias-toggle.restricted{border-color:color-mix(in srgb, var(--accent) 50%, var(--border));color:color-mix(in srgb, var(--accent) 70%, var(--text))}.alias-toggle.restricted .alias-toggle-track{background:color-mix(in srgb, var(--accent) 55%, var(--bg))}.editor-header{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:20px;display:flex}.form{flex-direction:column;gap:16px;display:flex}.auth-key-editor{background:color-mix(in srgb, var(--bg-surface) 82%, var(--bg) 18%)}.form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.form-field{flex-direction:column;gap:8px;display:flex}.form-field-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);font-size:12px;font-weight:600;display:inline-block}.vm-target-row{align-items:center;gap:8px;display:flex}.vm-target-row .vm-target-model{flex:auto;min-width:0}.vm-target-row .vm-target-weight{flex:0 0 88px;width:88px}.vm-status-row{justify-content:space-between;align-items:center;gap:12px;display:flex}.vm-status-row .vm-status-toggle{margin-left:auto}.form-error{border:1px solid color-mix(in srgb, var(--danger) 42%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface));color:var(--danger);overflow-wrap:anywhere;margin:0;padding:10px 12px;font-size:13px;font-weight:600;line-height:1.4}.form-error:empty{display:none}.form-field-error{color:var(--danger);overflow-wrap:anywhere;font-size:13px;font-weight:500;line-height:1.4}.form-field-required{color:var(--danger);margin-left:3px}:is(input,textarea,select)[aria-invalid=true]{border-color:color-mix(in srgb, var(--danger) 60%, var(--border))}:is(input,textarea,select)[aria-invalid=true]:focus{border-color:var(--danger)}textarea{resize:vertical;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:60px;color:var(--text);outline:none;padding:10px 12px;font-family:inherit;font-size:13px}textarea:focus{border-color:var(--accent)}.form-input{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:38px;color:var(--text);outline:none;padding:8px 10px;font-family:inherit;font-size:13px}.form-input:focus{border-color:var(--accent)}.form-actions{flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:16px;display:flex}.failover-target-actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.data-table tr.alias-row.is-valid td{background:var(--alias-row-valid-bg)}.data-table tr.alias-row.is-valid:hover td{background:var(--alias-row-valid-bg-hover)}.data-table tr.alias-row:not(.is-valid) td{background:color-mix(in srgb, var(--accent) 10%, var(--bg-surface))}.data-table tr.alias-row:not(.is-valid):hover td{background:color-mix(in srgb, var(--accent) 16%, var(--bg-surface-hover))}.data-table tr.alias-row.is-disabled td{background:var(--bg-surface);opacity:.58}.data-table tr.alias-row.is-disabled:hover td{background:var(--bg-surface-hover);opacity:.72}.data-table tr.model-access-disabled-row td{background:color-mix(in srgb, var(--danger) 6%, var(--bg-surface))}.data-table tr.model-access-disabled-row:hover td{background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface-hover))}.workflow-section-head{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-section-head h4{font-size:14px;font-weight:700}.workflow-preview{flex-direction:column;gap:12px;display:flex}.workflow-feature-toggles{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.workflow-feature-toggle{border:1px solid var(--border);background:var(--bg);border-radius:10px;align-items:center;gap:10px;padding:10px 12px;font-size:14px;font-weight:500;display:flex}.workflow-feature-toggle input{width:16px;height:16px}.model-chart-section{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:24px;padding:24px}.model-chart-section h3{margin:0;font-size:16px;font-weight:600}.model-chart-header{justify-content:space-between;align-items:center;gap:16px;margin-bottom:16px;display:flex}.bar-chart-wrap{width:100%;height:180px;position:relative}.form-select,.usage-log-select{appearance:none;background-color:var(--bg);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 17px),calc(100% - 12px);background-repeat:no-repeat;background-size:5px 5px;outline:none;min-width:140px;padding:8px 34px 8px 12px;font-family:inherit;font-size:13px}.form-select:disabled,.usage-log-select:disabled{cursor:not-allowed;opacity:.6}.form-select:focus,.usage-log-select:focus{border-color:var(--accent)}.form-select{width:100%;min-width:0}.usage-label-chips{flex-wrap:wrap;gap:4px;max-width:280px;display:inline-flex}.usage-label-chip{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg));min-height:20px;color:var(--text);white-space:nowrap;cursor:pointer;border-radius:999px;align-items:center;padding:1px 9px;font-family:inherit;font-size:11px;font-style:normal;font-weight:600;line-height:1.4;transition:background .15s,border-color .15s;display:inline-flex}.usage-label-chip:hover{background:color-mix(in srgb, var(--label-color,var(--accent)) 26%, var(--bg))}.usage-label-chip.active{background:color-mix(in srgb, var(--label-color,var(--accent)) 32%, var(--bg));border-color:var(--label-color,var(--accent));box-shadow:0 0 0 1px color-mix(in srgb, var(--label-color,var(--accent)) 55%, transparent)}@keyframes audit-live-summary-stripe-blink{0%,to{opacity:.9}50%{opacity:.28}}.audit-status-badge{border:1px solid var(--border);letter-spacing:.2px;background:var(--bg-surface);border-radius:999px;justify-content:center;align-items:center;min-width:46px;height:24px;padding:0 10px;font-size:12px;font-weight:600;display:inline-flex}.audit-status-badge.status-success{color:var(--success);border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.audit-status-badge.status-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.audit-status-badge.status-error{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.audit-status-badge.status-neutral{color:var(--text-muted)}.audit-status-badge.status-unknown{color:var(--text-muted);border-color:color-mix(in srgb, var(--border) 75%, transparent)}.audit-pane{border:1px solid var(--border);background:var(--bg);border-top:0;border-radius:0 0 8px 8px;min-width:0;padding:12px}.audit-pane h5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:11px;font-weight:600}.audit-prompt-cache-pill{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);min-height:20px;color:var(--prompt-cache-color);letter-spacing:.02em;text-transform:none;border-radius:999px;align-items:center;padding:2px 8px;font-size:11px;font-weight:700;display:inline-flex}.audit-prompt-cache-highlight{color:var(--prompt-cache-color);font-weight:700}.audit-audio{white-space:normal;flex-direction:column;gap:8px;display:flex}.audit-audio-player{width:100%;max-width:420px;height:36px}.audit-audio-meta{color:var(--text-muted);font-size:12px}.audit-audio-empty{align-items:flex-start;padding:4px 0}.audit-audio-icon{font-size:20px;line-height:1}.audit-audio-note{color:var(--text-muted);font-size:12px}.audit-audio-metadata{flex-direction:column;gap:2px;margin-top:4px;font-size:12px;display:flex}.audit-audio-meta-row{gap:8px;display:flex}.audit-audio-meta-key{color:var(--text-muted);min-width:120px}.conversation-body-highlight{border-left:2px solid color-mix(in srgb, var(--accent) 70%, var(--border));background:color-mix(in srgb, var(--accent) 10%, transparent);cursor:pointer;line-height:inherit;border-radius:2px;margin:0 0 0 -2px;padding:0 0 0 2px;display:inline}.conversation-body-highlight:hover{background:color-mix(in srgb, var(--accent) 18%, transparent)}.conversation-body-highlight.conversation-system{border-left-color:color-mix(in srgb, var(--warning) 70%, var(--border));background:color-mix(in srgb, var(--warning) 10%, transparent)}.conversation-body-highlight.conversation-user{border-left-color:color-mix(in srgb, var(--accent) 75%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent)}.conversation-body-highlight.conversation-assistant{border-left-color:color-mix(in srgb, var(--success) 65%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}#interactions-drawer-content{flex:1;min-height:0;overflow-y:auto}.pagination{justify-content:space-between;align-items:center;padding:12px 0 0;display:flex}.btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;padding:6px 16px;font-family:inherit;font-size:13px;transition:all .15s}.btn:hover:not(:disabled){background:var(--bg-surface-hover)}.btn-primary{background:var(--accent);border-color:color-mix(in srgb, var(--accent) 70%, #000 10%);color:#fff;font-weight:600;box-shadow:0 10px 22px #3b82f62e}.btn-primary:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 90%, #fff 10%);border-color:color-mix(in srgb, var(--accent) 78%, #000 12%)}.btn-danger-outline{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:0 0;font-weight:600}.btn-danger-outline:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 75%, var(--border))}.btn-danger{color:#fff;border-color:color-mix(in srgb, var(--danger) 76%, #000 12%);background:var(--danger);box-shadow:0 10px 22px color-mix(in srgb, var(--danger) 20%, transparent);font-weight:600}.btn-danger:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 90%, #fff 10%);border-color:color-mix(in srgb, var(--danger) 82%, #000 14%)}.btn-with-icon{justify-content:center;align-items:center;gap:8px;display:inline-flex}.btn-with-icon .table-icon-svg{width:16px;height:16px}.btn:disabled{opacity:.4;cursor:default}.settings-panel{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.inline-help-section{flex-direction:column;gap:2px;display:flex}.inline-help-title-row{align-items:center;gap:10px;display:inline-flex}.inline-help-title-row h2,.inline-help-title-row h3{margin-bottom:0}.inline-help-title-row h2:empty,.inline-help-title-row h3:empty{display:none}.inline-help-toggle{border:1px solid color-mix(in srgb, var(--accent) 28%, var(--border));width:16px;height:16px;color:var(--accent);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border-radius:4px;justify-content:center;align-items:center;padding:0;transition:color .18s,border-color .18s;display:inline-flex;position:relative}.inline-help-toggle:before{content:"";pointer-events:auto;background:0 0;width:32px;height:32px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.inline-help-toggle:hover{border-color:color-mix(in srgb, var(--accent) 48%, var(--border));color:var(--text);background:0 0}.inline-help-toggle:active{background:0 0}.inline-help-toggle:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.inline-help-toggle-icon{justify-content:center;align-items:center;width:100%;height:100%;padding-bottom:1px;font-size:13px;font-weight:700;line-height:1;transition:transform .52s cubic-bezier(.22,.72,.12,1);display:inline-flex;transform:rotate(0)}.inline-help-copy{max-width:780px;color:var(--text-muted);margin-top:2px;font-size:14px}.settings-select{width:100%}.settings-refresh-section{border-top:1px solid var(--border);justify-items:start;gap:12px;margin-top:24px;padding-top:22px;display:grid}.settings-refresh-section h3{font-size:18px}.settings-refresh-section p{max-width:720px;color:var(--text-muted);font-size:14px;line-height:1.55}.budget-list{gap:10px;padding:10px 0;display:grid}.budget-row{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);grid-template-columns:minmax(0,1fr);align-items:center;gap:16px;padding:12px 14px;display:grid}.budget-row-main{min-width:0}.budget-row-head{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:10px;min-width:0;display:grid}.budget-scope-value{width:fit-content;max-width:100%;min-height:24px;color:var(--text);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;justify-self:start;align-items:center;gap:5px;padding:2px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;display:inline-flex;overflow:hidden}.budget-user-path{border:1px solid color-mix(in srgb, var(--accent) 32%, var(--border));background:color-mix(in srgb, var(--accent) 9%, var(--bg))}.budget-label{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.budget-scope-icon{stroke-width:2.2px;opacity:.85;flex:0 0 12px;width:12px;height:12px}.budget-row-meta{min-width:0;color:var(--text-muted);align-items:center;gap:8px;font-size:12px;display:inline-flex}.budget-source{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:999px;padding:2px 7px;font-size:11px}.budget-row-period{justify-content:center;min-width:0;display:flex}.budget-row-controls{justify-content:flex-end;align-items:center;gap:8px;min-width:0;display:flex}.budget-bars{gap:6px;margin-top:10px;display:grid}.budget-bar-line{grid-template-columns:118px minmax(0,1fr);align-items:center;gap:10px;display:grid}.budget-bar-label{color:var(--text-muted);justify-content:space-between;align-items:center;gap:6px;font-size:11px;line-height:1;display:flex}.budget-bar-percent{font-weight:700}.budget-bar-track{background:color-mix(in srgb, var(--border) 75%, var(--bg));border-radius:999px;height:16px;position:relative;overflow:hidden}.budget-bar-fill{border-radius:inherit;min-width:0;height:100%;transition:width .2s}.budget-bar-fill-usage{background:color-mix(in srgb, var(--success) 82%, var(--accent))}.budget-bar-fill-danger{background:var(--danger)}.budget-bar-text-row{z-index:1;pointer-events:none;color:var(--text);position:absolute;inset:0}.budget-bar-text{text-overflow:ellipsis;white-space:nowrap;max-width:min(44%,190px);font-size:11px;font-weight:700;line-height:12px;position:absolute;top:50%;overflow:hidden}.budget-bar-text-center{max-width:min(46%,240px);left:50%;transform:translate(-50%,-50%)}.budget-bar-text-end{text-align:right;max-width:min(34%,180px);right:8px;transform:translateY(-50%)}.budget-period-label{border:1px solid var(--border);color:var(--text);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;gap:5px;padding:2px 7px;font-size:11px;font-weight:600;display:inline-flex}.budget-period-icon{stroke-width:2.2px;flex:0 0 12px;width:12px;height:12px}.budget-period-label-monthly{border-color:color-mix(in srgb, #30302c 62%, var(--border));background:color-mix(in srgb, #30302c 12%, var(--bg));color:color-mix(in srgb, #30302c 34%, var(--text) 66%)}.budget-period-label-weekly{border-color:color-mix(in srgb, #68765c 62%, var(--border));background:color-mix(in srgb, #68765c 12%, var(--bg));color:color-mix(in srgb, #68765c 34%, var(--text) 66%)}.budget-period-label-daily{border-color:color-mix(in srgb, #b5652d 62%, var(--border));background:color-mix(in srgb, #b5652d 12%, var(--bg));color:color-mix(in srgb, #b5652d 34%, var(--text) 66%)}.budget-period-label-hourly{border-color:color-mix(in srgb, #783f22 62%, var(--border));background:color-mix(in srgb, #783f22 12%, var(--bg));color:color-mix(in srgb, #783f22 34%, var(--text) 66%)}.budget-period-label-custom{border-style:dashed;border-color:color-mix(in srgb, #bfa584 68%, var(--border));background:color-mix(in srgb, #bfa584 16%, var(--bg));color:color-mix(in srgb, #8b6f4f 34%, var(--text) 66%)}[data-theme=light] .budget-period-label-monthly{color:#30302c}[data-theme=light] .budget-period-label-weekly{color:#68765c}[data-theme=light] .budget-period-label-daily{color:#b5652d}[data-theme=light] .budget-period-label-hourly{color:#783f22}[data-theme=light] .budget-period-label-custom{color:#8b6f4f}@media (prefers-color-scheme:light){:root:not([data-theme=dark]) .budget-period-label-monthly{color:#30302c}:root:not([data-theme=dark]) .budget-period-label-weekly{color:#68765c}:root:not([data-theme=dark]) .budget-period-label-daily{color:#b5652d}:root:not([data-theme=dark]) .budget-period-label-hourly{color:#783f22}:root:not([data-theme=dark]) .budget-period-label-custom{color:#8b6f4f}}.budget-row-actions{flex-flow:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.budget-action-btn{white-space:nowrap;justify-content:center;gap:0;width:28px;min-width:0;height:28px;padding:0;transition:width .18s,border-color .15s,background .15s,color .15s;overflow:hidden}.budget-action-btn:hover,.budget-action-btn:focus-visible{gap:6px;width:82px;padding:0 9px}.budget-action-label{opacity:0;max-width:0;transition:max-width .18s,opacity .12s;overflow:hidden}.budget-action-btn:hover .budget-action-label,.budget-action-btn:focus-visible .budget-action-label{opacity:1;max-width:58px}.budget-action-btn-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.budget-action-icon{flex:0 0 14px;width:14px;height:14px}.budget-editor{background:color-mix(in srgb, var(--bg-surface) 86%, var(--bg) 14%)}.budget-settings-actions{flex-wrap:wrap;gap:10px;display:flex}.budget-reset-dialog{max-width:460px}.form-action-icon{flex:0 0 16px;width:16px;height:16px}.settings-refresh-alert{margin-top:16px;margin-bottom:0}@media (width<=768px){.badge{display:none}.content{width:100%;margin:0 auto;padding:20px}.auth-dialog{padding:18px}.auth-dialog-actions{flex-direction:column-reverse}.auth-dialog-actions .btn{width:100%}.cards{grid-template-columns:repeat(2,1fr)}.page-header{flex-wrap:wrap;gap:12px}.page-header h2{width:100%}.page-header-controls{flex-wrap:wrap;justify-content:space-between;width:100%}.page-with-sticky-date{grid-template-columns:minmax(0,1fr)}.page-with-sticky-date>.date-range-page-header,.page-with-sticky-date>.sticky-date-range{grid-column:1}.page-with-sticky-date>.date-range-page-header{margin-bottom:12px}.page-with-sticky-date>.sticky-date-range{width:100%;margin-bottom:24px;top:10px}.sticky-date-range .date-picker-trigger{justify-content:space-between;width:100%}.usage-log-select{min-width:0}.budget-row{grid-template-columns:1fr}.budget-row-controls{flex-wrap:wrap}.budget-bar-line{grid-template-columns:1fr;gap:5px}.form-grid,.workflow-feature-toggles{grid-template-columns:1fr}.workflow-section-head{flex-direction:column;align-items:flex-start}.table-toolbar{flex-direction:column;align-items:stretch}.table-toolbar-actions{justify-content:stretch;margin-left:0}.table-toolbar-actions .btn{width:100%}.model-editor{padding:16px}.alias-actions-cell,.editor-header{flex-direction:column;align-items:flex-start}.alias-actions-cell .table-action-btn,.editor-header .table-action-btn{width:100%}.alias-actions-cell .table-icon-btn,.editor-header .table-icon-btn{width:36px}.model-list-actions{flex-flow:row;align-items:center}.model-list-actions .table-action-btn{width:auto}.model-list-actions .table-icon-btn{flex-basis:32px;width:32px}.model-editor .editor-header{flex-direction:row;align-items:flex-start}.model-editor .editor-header>:first-child{flex:1;min-width:0}.model-editor .editor-header .dialog-close-btn{flex:0 0 32px;align-self:flex-start;width:32px;min-width:32px}.settings-panel{padding:18px}.budget-settings-actions,.budget-settings-actions .btn{width:100%}}.workflow-conn{background:color-mix(in srgb, var(--accent) 44%, var(--border));flex:1 1 0;width:auto;min-width:13px;height:2px;position:relative}.workflow-conn:after{content:"";background:color-mix(in srgb, var(--accent) 44%, var(--border));clip-path:polygon(0 0,100% 50%,0 100%);width:7px;height:9px;position:absolute;top:50%;right:-1px;transform:translateY(-50%)}.workflow-node{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg-surface);text-align:center;flex-direction:column;flex-shrink:0;justify-content:center;align-items:center;gap:4px;min-width:72px;padding:8px 12px;display:flex}.auth-key-description{color:var(--text-muted);max-width:220px;font-size:13px}.auth-key-status-badge{border-radius:999px;padding:2px 10px;font-size:12px;font-weight:600;display:inline-block}.auth-key-status-active{background:color-mix(in srgb, var(--success) 12%, var(--bg));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));color:var(--success)}.auth-key-status-inactive{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border:1px solid color-mix(in srgb, var(--danger) 30%, var(--border));color:var(--danger)}.mcp-server-advanced{border:1px solid var(--border);border-radius:var(--radius);background:color-mix(in srgb, var(--bg-surface) 72%, var(--bg) 28%);overflow:hidden}.mcp-server-advanced>summary{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;list-style:none;display:flex}.mcp-server-advanced>summary::-webkit-details-marker{display:none}.mcp-server-advanced>summary:after{border-right:2px solid var(--text-muted);border-bottom:2px solid var(--text-muted);content:"";flex:none;width:7px;height:7px;transition:transform .15s;transform:rotate(45deg)}.mcp-server-advanced[open]>summary:after{transform:rotate(225deg)}.mcp-server-advanced-summary-copy{flex-direction:column;gap:2px;min-width:0;display:flex}.mcp-server-advanced-title{font-size:13px;font-weight:600}.mcp-server-advanced-fields{border-top:1px solid var(--border);flex-direction:column;gap:16px;padding:14px;display:flex}.copy-feedback-btn{align-items:center;gap:6px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.rate-limit-pressure-row{background-image:linear-gradient(to right, color-mix(in srgb, var(--success) 16%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-high{background-image:linear-gradient(to right, color-mix(in srgb, var(--warning) 20%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-full{background-image:linear-gradient(to right, color-mix(in srgb, var(--danger) 22%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.table-icon-btn.rate-limit-gauge-inherited{color:var(--accent-strong,var(--accent));background:linear-gradient(to right, color-mix(in srgb, var(--accent) 22%, var(--bg)) 50%, var(--bg) 50%);border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.auth-dialog-input-icon{width:16px;height:16px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.auth-dialog-input-shell:focus-within .auth-dialog-input-icon{color:var(--accent)}.auth-dialog-submit-icon{flex:0 0 16px;width:16px;height:16px}.nav-icon{flex:0 0 18px;width:18px;height:18px}.api-key-open-icon{flex:0 0 15px;width:15px;height:15px}.theme-icon{flex:0 0 14px;width:14px;height:14px}.theme-toggle-mobile .theme-icon{flex-basis:16px;width:16px;height:16px}@media (width<=768px){.sidebar-footer .api-key-open-icon{flex-basis:16px;width:16px;height:16px}}.failover-drafts-loading{min-height:96px}.models-loading-state{top:16px;left:var(--sidebar-width);z-index:110;pointer-events:none;--loading-state-min-height:0;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-surface);width:fit-content;box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);margin:0 auto;padding:10px 14px;position:fixed;right:0}@media (width<=768px){.models-loading-state{left:60px}}.sidebar.sidebar-collapsed~.content .models-loading-state{left:60px}.alias-create-icon{flex:0 0 16px;width:16px;height:16px}.pricing-override-remove-row{margin-bottom:1px}@media (width<=768px){.pricing-override-remove-row{margin-bottom:0}}.pricing-recalculate-dialog{max-width:480px}.settings-refresh-btn.is-refreshing .settings-refresh-icon{transform-origin:50%;animation:.8s linear infinite loading-spin}.cost-source-icon{width:14px;height:14px;color:var(--success);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.cache-savings-icon{width:14px;height:14px;color:var(--accent);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.theme-toggle.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;margin-bottom:10px;padding:2px;display:inline-flex}.theme-btn.svelte-1keql7b{width:28px;height:24px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:flex}.theme-btn.svelte-1keql7b:hover{color:var(--text)}.theme-btn.active.svelte-1keql7b{background:var(--accent);color:#fff}.theme-btn.svelte-1keql7b:focus-visible,.theme-toggle-mobile.svelte-1keql7b:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.theme-toggle-mobile.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);width:36px;height:36px;color:var(--text-muted);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:none}.theme-toggle-mobile.svelte-1keql7b:hover{color:var(--text)}.theme-toggle.is-compact.svelte-1keql7b{display:none}.theme-toggle-mobile.is-compact.svelte-1keql7b{margin:0 auto;display:flex}@media (width<=768px){.theme-toggle.svelte-1keql7b{display:none}.theme-toggle-mobile.svelte-1keql7b{margin:0 auto;display:flex}}.sidebar.svelte-1nwtzae{flex:0 0 var(--sidebar-width);width:var(--sidebar-width);background:var(--bg-surface);border-right:1px solid var(--border);-webkit-overflow-scrolling:touch;z-index:10;flex-direction:column;max-height:100vh;transition:flex-basis .2s,width .2s;display:flex;position:sticky;top:0;overflow:hidden auto}.sidebar.sidebar-resizing.svelte-1nwtzae{transition:none}.sidebar-header.svelte-1nwtzae{border-bottom:1px solid var(--border);align-items:center;gap:10px;padding:20px;display:flex}.sidebar-logo.svelte-1nwtzae{width:28px;height:28px;color:var(--accent);flex-shrink:0}.sidebar-logo.svelte-1nwtzae svg{width:100%;height:100%}.sidebar-header.svelte-1nwtzae h1{letter-spacing:-.3px;font-size:18px;font-weight:700}.sidebar-nav.svelte-1nwtzae{flex-direction:column;flex:1;gap:4px;padding:12px;display:flex}.nav-item.svelte-1nwtzae{border-radius:var(--radius);color:var(--text-muted);align-items:center;gap:10px;padding:8px 12px;font-size:14px;font-weight:500;text-decoration:none;transition:all .15s;display:flex}.nav-item.svelte-1nwtzae:hover{background:var(--bg-surface-hover);color:var(--text)}.nav-item.active.svelte-1nwtzae{background:var(--accent);color:#fff}.nav-label.svelte-1nwtzae{white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;overflow:hidden}.sidebar-footer.svelte-1nwtzae{border-top:1px solid var(--border);padding:16px}.api-key-section.svelte-1nwtzae{gap:8px;display:grid}.api-key-open-btn.svelte-1nwtzae{border:1px solid var(--accent);border-radius:var(--radius);width:100%;color:var(--accent);cursor:pointer;background:0 0;justify-content:center;align-items:center;gap:8px;padding:8px 10px;font-family:inherit;font-size:13px;font-weight:600;transition:background-color .15s,border-color .15s;display:inline-flex}.api-key-open-btn.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);border-color:color-mix(in srgb, var(--accent) 78%, var(--text));color:color-mix(in srgb, var(--accent) 78%, var(--text))}.api-key-open-btn.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.sidebar-toggle.svelte-1nwtzae{cursor:ew-resize;z-index:11;background:0 0;border:none;flex:0 0 6px;width:6px;height:100vh;padding:0;transition:background .15s;position:sticky;top:0}.sidebar-toggle.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 15%, transparent)}.sidebar-toggle.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}body.sidebar-resizing{cursor:ew-resize;-webkit-user-select:none;user-select:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae){justify-content:center;padding:16px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae) h1,.sidebar.sidebar-collapsed.svelte-1nwtzae .badge{display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae){padding:8px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:none}@media (width<=768px){.sidebar.svelte-1nwtzae{flex-basis:60px;width:60px}.sidebar-header.svelte-1nwtzae{justify-content:center;padding:16px}.sidebar-header.svelte-1nwtzae h1{display:none}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar-footer.svelte-1nwtzae{gap:8px;padding:8px;display:grid}.sidebar-footer.svelte-1nwtzae .api-key-section:where(.svelte-1nwtzae),.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:grid}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae){justify-self:center;width:36px;height:36px;min-height:36px;padding:0}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae) span,.sidebar-toggle.svelte-1nwtzae{display:none}}.dialog-close-btn.svelte-11l1bb5{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.dialog-close-btn.svelte-11l1bb5:hover{color:var(--text);background:var(--bg-surface-hover)}.dialog-close-btn.svelte-11l1bb5:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-backdrop.svelte-17e0w4c,.editor-modal-backdrop.svelte-17e0w4c{z-index:80;background:#0000007a;position:fixed;inset:0}.auth-dialog-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0}.editor-modal-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0;overflow-y:auto}.editor-modal-shell.svelte-17e0w4c>*{overscroll-behavior:contain;width:min(760px,100%);max-height:min(100vh - 40px,960px);margin:0;overflow:auto;box-shadow:0 24px 70px #00000061}@media (width<=768px){.auth-dialog-shell.svelte-17e0w4c,.editor-modal-shell.svelte-17e0w4c{align-items:end;padding:12px}.editor-modal-shell.svelte-17e0w4c>*{max-height:calc(100vh - 24px)}}.auth-dialog-input-shell.svelte-1dsu6u0{position:relative}.auth-dialog-input.svelte-1dsu6u0{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:11px 12px 11px 38px;font-family:inherit;font-size:14px}.auth-dialog-input.svelte-1dsu6u0:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}.flash-region.svelte-1i257xg{top:16px;left:var(--sidebar-width);z-index:120;pointer-events:none;flex-direction:column;align-items:center;gap:10px;display:flex;position:fixed;right:0}.sidebar.sidebar-collapsed~.flash-region.svelte-1i257xg{left:60px}@media (width<=768px){.flash-region.svelte-1i257xg{left:60px}}.flash-toast.svelte-1i257xg{border-radius:var(--radius);pointer-events:auto;align-items:flex-start;gap:10px;width:max-content;max-width:min(480px,100% - 32px);padding:12px 12px 12px 16px;font-size:14px;animation:.9s ease-out svelte-1i257xg-flash-toast-glow;display:flex;box-shadow:0 10px 30px #00000059}@keyframes svelte-1i257xg-flash-toast-glow{0%{box-shadow:0 0 0 4px color-mix(in srgb, currentColor 45%, transparent), 0 10px 30px #00000059}to{box-shadow:0 0 0 4px #0000,0 10px 30px #00000059}}@media (prefers-reduced-motion:reduce){.flash-toast.svelte-1i257xg{animation:none}}.flash-toast-success.svelte-1i257xg{background:color-mix(in srgb, var(--success) 14%, var(--bg-surface));color:var(--success);border:1px solid #34d39959}.flash-toast-error.svelte-1i257xg{background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--warning);border:1px solid #f59e0b66}.flash-toast-text.svelte-1i257xg{overflow-wrap:anywhere;flex:1;min-width:0}.flash-toast-dismiss.svelte-1i257xg{color:inherit;cursor:pointer;opacity:.7;background:0 0;border:0;flex-shrink:0;padding:0 2px;font-size:18px;line-height:1}.flash-toast-dismiss.svelte-1i257xg:hover{opacity:1}.demo-mode-banner.svelte-1s3mcn8{border:1px solid color-mix(in srgb, var(--warning) 55%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--text);box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;margin-bottom:24px;padding:12px 16px;display:grid}.demo-mode-banner-icon.svelte-1s3mcn8{width:20px;height:20px;color:var(--warning);flex:0 0 20px}.demo-mode-banner-copy.svelte-1s3mcn8{align-items:baseline;gap:8px;min-width:0;font-size:13px;display:flex}.demo-mode-banner.svelte-1s3mcn8 strong{color:var(--warning);letter-spacing:.06em;text-transform:uppercase;flex-shrink:0;font-size:12px}.demo-mode-banner-links.svelte-1s3mcn8{justify-content:flex-end;align-items:center;gap:6px;display:flex}.demo-mode-banner-links.svelte-1s3mcn8 a{border:1px solid color-mix(in srgb, var(--warning) 42%, var(--border));border-radius:var(--radius);min-height:28px;color:var(--text);white-space:nowrap;align-items:center;padding:4px 8px;font-size:12px;font-weight:600;line-height:1;text-decoration:none;display:inline-flex}.demo-mode-banner-links.svelte-1s3mcn8 a:hover{border-color:var(--warning);background:color-mix(in srgb, var(--warning) 16%, transparent);color:var(--text)}.demo-mode-banner-links.svelte-1s3mcn8 a:focus-visible{outline:2px solid color-mix(in srgb, var(--warning) 42%, transparent);outline-offset:2px}@media (width<=768px){.demo-mode-banner.svelte-1s3mcn8{grid-template-columns:auto minmax(0,1fr);align-items:flex-start}.demo-mode-banner-copy.svelte-1s3mcn8{gap:2px;display:grid}.demo-mode-banner-links.svelte-1s3mcn8{flex-wrap:wrap;grid-column:2;justify-content:flex-start}}.auth-banner.svelte-1c5yh36{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.dp-calendar.svelte-g7ga4u{flex-shrink:0;width:224px}.dp-cal-header.svelte-g7ga4u{justify-content:space-between;align-items:center;margin-bottom:8px;padding:0 4px;display:flex}.dp-cal-title.svelte-g7ga4u{font-size:13px;font-weight:600}.dp-nav-btn.svelte-g7ga4u{width:28px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:flex}.dp-nav-btn.svelte-g7ga4u:hover{background:var(--bg-surface-hover);color:var(--text)}.dp-nav-btn.svelte-g7ga4u:disabled{opacity:.3;cursor:default;pointer-events:none}.dp-nav-prev-mobile.svelte-g7ga4u{display:none}.dp-weekdays.svelte-g7ga4u{text-align:center;grid-template-columns:repeat(7,1fr);margin-bottom:4px;display:grid}.dp-weekdays.svelte-g7ga4u span:where(.svelte-g7ga4u){color:var(--text-muted);padding:4px 0;font-size:11px;font-weight:600}.dp-days.svelte-g7ga4u{grid-template-columns:repeat(7,1fr);gap:1px;display:grid}.dp-day.svelte-g7ga4u{width:32px;height:32px;color:var(--text);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:inherit;font-size:12px;transition:all .1s;display:flex}.dp-day.svelte-g7ga4u:hover:not(.disabled):not(.other-month){background:var(--bg-surface-hover)}.dp-day.other-month.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default}.dp-day.today.svelte-g7ga4u{color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);font-weight:700}.dp-day.in-range.svelte-g7ga4u{background:color-mix(in srgb, var(--accent) 15%, transparent);border-radius:0}.dp-day.range-start.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:6px 0 0 6px;font-weight:600}.dp-day.range-end.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:0 6px 6px 0;font-weight:600}.dp-day.range-start.range-end.svelte-g7ga4u{border-radius:6px}.dp-day.range-start.today.svelte-g7ga4u,.dp-day.range-end.today.svelte-g7ga4u{box-shadow:none}.dp-day.disabled.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default;pointer-events:none}@media (width<=768px){.dp-nav-prev-mobile.svelte-g7ga4u{display:flex}}.date-picker.svelte-ax7ma4{position:relative}.date-picker-trigger.svelte-ax7ma4{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;white-space:nowrap;align-items:center;gap:8px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s;display:inline-flex}.date-picker-trigger.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.date-picker-trigger.svelte-ax7ma4 svg:where(.svelte-ax7ma4){color:var(--text-muted);flex-shrink:0}.date-picker-chevron.svelte-ax7ma4{transition:transform .15s}.date-picker-chevron.open.svelte-ax7ma4{transform:rotate(180deg)}.date-picker-dropdown.svelte-ax7ma4{z-index:100;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:hidden;box-shadow:0 8px 24px #00000040}.date-picker-presets.svelte-ax7ma4{border-right:1px solid var(--border);flex-direction:column;gap:2px;min-width:140px;padding:8px;display:flex}.preset-btn.svelte-ax7ma4{color:var(--text);text-align:left;cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s}.preset-btn.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.preset-btn.active.svelte-ax7ma4{background:var(--accent);color:#fff}.date-picker-calendars.svelte-ax7ma4{flex-wrap:nowrap;gap:16px;padding:12px;display:flex}.dp-cursor-hint.svelte-ax7ma4{pointer-events:none;z-index:101;background:var(--bg-surface);color:var(--text);border:1px solid var(--accent);white-space:nowrap;border-radius:4px;align-items:center;gap:5px;padding:3px 8px;font-size:11px;font-weight:500;display:flex;position:fixed;transform:translate(12px,-50%)}.dp-cursor-hint.svelte-ax7ma4 svg:where(.svelte-ax7ma4){width:12px;height:12px;color:var(--accent);flex-shrink:0}@media (width<=768px){.date-picker-dropdown.svelte-ax7ma4{border-radius:var(--radius) var(--radius) 0 0;flex-direction:column;max-height:80vh;position:fixed;inset:auto 0 0;overflow-y:auto}.date-picker-presets.svelte-ax7ma4{-webkit-overflow-scrolling:touch;border-right:none;border-bottom:1px solid var(--border);flex-flow:row;min-width:0;overflow-x:auto}.date-picker-calendars.svelte-ax7ma4{justify-content:center}.date-picker-calendars.svelte-ax7ma4>.dp-calendar:first-child{display:none}}.segmented-control.svelte-92fh5i{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.segmented-btn.svelte-92fh5i{color:var(--text-muted);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;padding:5px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:flex}.segmented-btn.svelte-92fh5i:hover{color:var(--text)}.segmented-btn.active.svelte-92fh5i{background:var(--accent);color:#fff}@media (width<=768px){.segmented-btn.svelte-92fh5i{padding:4px 8px;font-size:11px}}.live-tokens.svelte-17qr2ta{margin-bottom:28px}.live-tokens-heading.svelte-17qr2ta{flex-direction:column;gap:2px;display:flex}.live-tokens-subtitle.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:6px;font-size:12px;display:inline-flex}.live-tokens-legend.svelte-17qr2ta{flex-wrap:wrap;gap:8px 18px;margin-bottom:16px;display:flex}.live-tokens-legend-item.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:7px;font-size:12px;display:inline-flex}.live-tokens-swatch.svelte-17qr2ta{border-radius:2px;flex-shrink:0;width:10px;height:10px}.live-tokens-legend-value.svelte-17qr2ta{color:var(--text);font-weight:600}.live-tokens-empty.svelte-17qr2ta .live-tokens-empty-text:where(.svelte-17qr2ta){color:var(--text-muted);font-size:13px}.provider-status-flag.svelte-6tr9cf{grid-column:span 2}.provider-status-overview-card.svelte-6tr9cf{grid-column:span 1}.provider-status-flag.is-healthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, var(--bg-surface))}.provider-status-flag.is-degraded.svelte-6tr9cf{border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-flag.is-unhealthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface))}.provider-status-value.svelte-6tr9cf{margin-bottom:8px}.provider-status-card-link.svelte-6tr9cf{color:var(--accent-strong,var(--accent));font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;margin:0;padding:0;font-size:13px;font-weight:600}.provider-status-card-link.svelte-6tr9cf:hover{color:var(--text);text-decoration:underline}.provider-status-card-link.svelte-6tr9cf:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:3px;border-radius:4px}.provider-status-card-note.svelte-6tr9cf{color:var(--text-muted);font-size:13px;display:block}@media (width>=720px){.card-wide.svelte-6tr9cf{grid-column:span 2}}.cache-token-value.svelte-6tr9cf{flex-wrap:wrap;align-items:center;gap:6px;line-height:1;display:flex}.cache-token-part.svelte-6tr9cf{align-items:center;display:inline-flex}.cache-token-operator.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;font-size:24px;font-weight:600;line-height:1}.cache-token-marker.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;text-transform:uppercase;margin-left:2px;font-size:14px;font-weight:700}.prompt-cache-gauge.svelte-6tr9cf{width:120px;height:60px;margin:8px auto 0;position:relative;overflow:hidden}.prompt-cache-gauge.svelte-6tr9cf canvas{display:block}.prompt-cache-gauge-value.svelte-6tr9cf{text-align:center;color:var(--text);font-size:18px;font-weight:700;line-height:1;position:absolute;bottom:4px;left:0;right:0}@media (width<=768px){.provider-status-flag.svelte-6tr9cf{grid-column:span 1}}.mcp-servers-flag.svelte-6tr9cf{grid-column:span 1}.cache-meter-header.svelte-1yzecxj{flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:16px;display:flex}.cache-meter-header.svelte-1yzecxj h3{font-size:16px;font-weight:600}.cache-meter-subtitle.svelte-1yzecxj{color:var(--text-muted);font-size:13px}.cache-meter-bar.svelte-1yzecxj{background:var(--bg-surface-hover);border-radius:6px;width:100%;height:28px;display:flex;overflow:hidden}.cache-meter-segment.svelte-1yzecxj{justify-content:center;align-items:center;min-width:3px;height:100%;transition:width .3s;display:flex;overflow:hidden}.cache-meter-segment-label.svelte-1yzecxj{color:#fff;white-space:nowrap;text-shadow:0 1px 2px #00000073;font-size:12px;font-weight:600;line-height:1}.cache-meter-segment.svelte-1yzecxj+.cache-meter-segment:where(.svelte-1yzecxj){box-shadow:-1px 0 0 var(--bg-surface)}.cache-meter-bar.is-empty.svelte-1yzecxj{background:var(--bg-surface-hover);justify-content:center;align-items:center;height:auto;min-height:28px;padding:6px 12px}.cache-meter-legend.svelte-1yzecxj{flex-wrap:wrap;gap:10px 24px;margin-top:16px;display:flex}.cache-meter-legend-item.svelte-1yzecxj{align-items:center;gap:8px;font-size:13px;display:flex}.cache-meter-swatch.svelte-1yzecxj{border-radius:3px;flex-shrink:0;width:12px;height:12px}.cache-meter-legend-label.svelte-1yzecxj{color:var(--text)}.cache-meter-legend-pct.svelte-1yzecxj{color:var(--text);font-weight:600}.cache-meter-legend-tokens.svelte-1yzecxj{color:var(--text-muted)}.cache-meter-empty.svelte-1yzecxj{color:var(--text-muted);text-align:center;font-size:13px}.spinner.svelte-b54l9o{width:var(--spinner-size);height:var(--spinner-size);border:2px solid var(--border,#80808059);border-top-color:var(--accent,currentColor);border-radius:50%;flex:none;animation:.7s linear infinite svelte-b54l9o-spinner-rotate;display:inline-block}@keyframes svelte-b54l9o-spinner-rotate{to{transform:rotate(360deg)}}.contribution-calendar-section.svelte-3hfxuq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-top:24px;padding:24px}.contribution-calendar-header.svelte-3hfxuq{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.contribution-calendar-header.svelte-3hfxuq h3{font-size:16px;font-weight:600}.contribution-calendar-grid-wrapper.svelte-3hfxuq{gap:8px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq{flex-direction:column;gap:2px;padding-top:22px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq span{height:13px;color:var(--text-muted);text-align:right;min-width:28px;font-size:10px;line-height:13px}.contribution-calendar-scroll.svelte-3hfxuq{--contribution-week-size:13px;--contribution-week-gap:2px;flex:1;min-width:0;overflow-x:auto}.contribution-calendar-months.svelte-3hfxuq{grid-auto-columns:var(--contribution-week-size);gap:var(--contribution-week-gap);grid-auto-flow:column;height:16px;margin-bottom:6px;display:grid}.contribution-calendar-month-label.svelte-3hfxuq{color:var(--text-muted);white-space:nowrap;font-size:10px}.contribution-calendar-grid.svelte-3hfxuq{gap:var(--contribution-week-gap);display:flex}.contribution-calendar-week.svelte-3hfxuq{flex-direction:column;gap:2px;display:flex}.contribution-calendar-cell.svelte-3hfxuq{width:var(--contribution-week-size);height:var(--contribution-week-size);background:var(--cal-level-0);border-radius:2px}.contribution-calendar-cell.level-1.svelte-3hfxuq{background:var(--cal-level-1)}.contribution-calendar-cell.level-2.svelte-3hfxuq{background:var(--cal-level-2)}.contribution-calendar-cell.level-3.svelte-3hfxuq{background:var(--cal-level-3)}.contribution-calendar-cell.level-4.svelte-3hfxuq{background:var(--cal-level-4)}.contribution-calendar-cell.level-5.svelte-3hfxuq{background:var(--cal-level-5)}.contribution-calendar-cell.level-6.svelte-3hfxuq{background:var(--cal-level-6)}.contribution-calendar-cell.level-7.svelte-3hfxuq{background:var(--cal-level-7)}.contribution-calendar-cell.level-8.svelte-3hfxuq{background:var(--cal-level-8)}.contribution-calendar-cell.level-9.svelte-3hfxuq{background:var(--cal-level-9)}.contribution-calendar-cell.level-10.svelte-3hfxuq{background:var(--cal-level-10)}.contribution-calendar-cell.empty.svelte-3hfxuq{background:0 0}.contribution-calendar-footer.svelte-3hfxuq{justify-content:space-between;align-items:center;gap:12px;margin-top:12px;display:flex}.contribution-calendar-meta.svelte-3hfxuq{flex-direction:column;gap:4px;display:flex}.contribution-calendar-summary.svelte-3hfxuq{color:var(--text-muted);font-size:12px}.contribution-calendar-legend.svelte-3hfxuq{color:var(--text-muted);align-items:center;gap:4px;font-size:11px;display:flex}.contribution-calendar-legend.svelte-3hfxuq .contribution-calendar-cell:where(.svelte-3hfxuq){cursor:default;width:11px;height:11px}.contribution-calendar-tooltip.svelte-3hfxuq{z-index:200;background:var(--bg-surface);color:var(--text);border:1px solid var(--border);white-space:nowrap;pointer-events:none;border-radius:4px;padding:4px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;position:fixed;transform:translate(-50%);box-shadow:0 4px 12px #0003}@media (width<=768px){.contribution-calendar-day-labels.svelte-3hfxuq{display:none}.contribution-calendar-section.svelte-3hfxuq{padding:16px}.contribution-calendar-footer.svelte-3hfxuq{flex-direction:column;align-items:flex-start}}.inline-help-toggle.is-open.svelte-y40or3{color:var(--text);background:0 0}.inline-help-toggle.is-open.svelte-y40or3 .inline-help-toggle-icon{transform:rotate(540deg)}.audit-stats-section.svelte-14e9yan{margin-top:24px}.audit-stats-header.svelte-14e9yan{align-items:flex-start}.audit-stats-kpis.svelte-14e9yan{flex-wrap:wrap;align-items:center;gap:14px;display:flex}.audit-stats-kpi.svelte-14e9yan{color:var(--text-muted);white-space:nowrap;align-items:center;gap:6px;font-size:12px;display:inline-flex}.audit-stats-kpi-value.svelte-14e9yan{color:var(--text);font-size:13px}.audit-stats-kpi-dot.svelte-14e9yan{border-radius:2px;flex-shrink:0;width:8px;height:8px}.audit-stats-dot-2xx.svelte-14e9yan{background:var(--success)}.audit-stats-dot-4xx.svelte-14e9yan{background:var(--warning)}.audit-stats-dot-5xx.svelte-14e9yan{background:var(--danger)}.provider-status-details.svelte-6y9wjv{opacity:0;grid-template-rows:0fr;transition:grid-template-rows .28s,opacity .22s;display:grid}.provider-status-details.is-expanded.svelte-6y9wjv{opacity:1;grid-template-rows:1fr}.provider-status-details.is-collapsed.svelte-6y9wjv{pointer-events:none}.provider-status-details-inner.svelte-6y9wjv{flex-direction:column;gap:14px;min-height:0;display:flex;overflow:hidden}.provider-status-reason.svelte-6y9wjv{color:var(--text-muted);font-size:13px}.provider-status-error.svelte-6y9wjv{color:var(--danger);overflow-wrap:break-word;font-size:12px}.provider-status-config-label.svelte-6y9wjv{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-config.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;padding-top:12px;display:flex}.provider-status-config-row.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-config-value.svelte-6y9wjv{color:var(--text);overflow-wrap:break-word;font-size:13px;display:block}.provider-status-health.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;margin-bottom:12px;padding-top:12px;display:flex}.provider-status-health-state.svelte-6y9wjv{border:1px solid var(--border);border-radius:999px;align-items:center;padding:1px 8px;font-size:12px;font-weight:600;display:inline-flex}.provider-status-health-state.is-healthy.svelte-6y9wjv{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-health-state.is-degraded.svelte-6y9wjv{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-health-state.is-unhealthy.svelte-6y9wjv{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-health-models.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-health-model.svelte-6y9wjv{color:var(--text);justify-content:space-between;gap:8px;font-size:13px;display:flex}.provider-status-health-model.is-flagged.svelte-6y9wjv{color:var(--danger)}.provider-status-health-model-name.svelte-6y9wjv{overflow-wrap:anywhere}.provider-status-health-model-stats.svelte-6y9wjv{white-space:nowrap;color:var(--text-muted)}.provider-status-health-model.is-flagged.svelte-6y9wjv .provider-status-health-model-stats:where(.svelte-6y9wjv){color:var(--danger);font-weight:700}.provider-status-card.svelte-nopjmh{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:14px;padding:18px;display:flex}.provider-status-card-toggle.svelte-nopjmh{border:0;border-top:1px solid var(--border);border-radius:0 0 var(--radius) var(--radius);color:var(--text-muted);cursor:pointer;background:0 0;justify-content:center;align-items:center;margin:auto -18px -18px;padding:7px 0;transition:background .15s,color .15s;display:flex}.provider-status-card-toggle.svelte-nopjmh:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);color:var(--text)}.provider-status-card-toggle.svelte-nopjmh:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:-2px}.provider-status-card-toggle.svelte-nopjmh .provider-status-card-toggle-icon{width:16px;height:16px;transition:transform .28s;display:block}.provider-status-card-toggle.is-expanded.svelte-nopjmh .provider-status-card-toggle-icon{transform:rotate(180deg)}.provider-status-card-head.svelte-nopjmh{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.provider-status-name.svelte-nopjmh{letter-spacing:-.02em;flex-wrap:wrap;align-items:baseline;gap:6px;font-size:16px;font-weight:700;display:flex}.provider-doc-help.svelte-nopjmh{align-self:center;text-decoration:none}.provider-status-name-type.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-pill.svelte-nopjmh{border:1px solid var(--border);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;min-height:28px;padding:0 10px;font-size:12px;font-weight:700;display:inline-flex}.provider-status-pill.is-healthy.svelte-nopjmh{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-pill.is-degraded.svelte-nopjmh{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-pill.is-unhealthy.svelte-nopjmh{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-meta.svelte-nopjmh{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.provider-status-meta-item.svelte-nopjmh{background:var(--bg);border:1px solid var(--border);border-radius:6px;flex-direction:column;gap:4px;padding:10px 12px;display:flex}.provider-status-meta-label.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-meta-value.svelte-nopjmh{color:var(--text);font-size:14px}@media (width<=768px){.provider-status-meta.svelte-nopjmh{grid-template-columns:1fr}}.provider-status-section-loading.svelte-1kx3uw4{justify-content:center;padding:24px 0;display:flex}.provider-status-section-header.svelte-1kx3uw4{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px;display:flex}.provider-status-toggle.svelte-1kx3uw4{background:var(--bg-surface);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:10px;padding:8px 12px;font-family:inherit;font-size:12px;font-weight:600;transition:background-color .18s,border-color .18s,color .18s;display:inline-flex}.provider-status-toggle.svelte-1kx3uw4:hover{background:var(--bg-surface-hover)}.provider-status-toggle.svelte-1kx3uw4:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.provider-status-toggle-copy.svelte-1kx3uw4{white-space:nowrap}.provider-status-toggle-track.svelte-1kx3uw4{background:color-mix(in srgb, var(--text-muted) 35%, var(--border));border-radius:999px;flex-shrink:0;width:34px;height:20px;transition:background-color .2s;position:relative}.provider-status-toggle-track.is-active.svelte-1kx3uw4{background:color-mix(in srgb, var(--accent) 82%, var(--bg-surface))}.provider-status-toggle-thumb.svelte-1kx3uw4{background:#fff;border-radius:50%;width:16px;height:16px;transition:transform .2s;position:absolute;top:2px;left:2px;box-shadow:0 1px 3px #0000003d}.provider-status-toggle-track.is-active.svelte-1kx3uw4 .provider-status-toggle-thumb:where(.svelte-1kx3uw4){transform:translate(14px)}.provider-status-grid.svelte-1kx3uw4{grid-template-columns:repeat(auto-fit,minmax(280px,1fr));align-items:start;gap:16px;display:grid}@media (width<=768px){.provider-status-section-header.svelte-1kx3uw4{flex-direction:column;align-items:flex-start}.provider-status-toggle.svelte-1kx3uw4{justify-content:space-between;width:100%}}.filter-input-wrap.svelte-30xz1k{flex:1;width:100%;min-width:min(400px,100%);display:flex;position:relative}.filter-input.svelte-30xz1k{flex:1;width:100%;min-width:0;padding-left:34px}.filter-input-wrap.svelte-30xz1k .filter-input-icon{width:14px;height:14px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.usage-page-filters.svelte-1oi6ywk{flex-wrap:wrap;gap:10px;margin-bottom:20px;display:flex}.usage-page-filters.svelte-1oi6ywk .usage-log-select{flex:0 auto}.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:220px;min-width:180px;max-width:360px}@media (width<=768px){.usage-page-filters.svelte-1oi6ywk .usage-log-select,.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:100%;max-width:none}}.pro-saved-value.svelte-1qiwzdu{flex-wrap:wrap;align-items:baseline;gap:8px;display:flex}.pro-saved-delta.svelte-1qiwzdu{color:var(--success);letter-spacing:0;font-size:13px;font-weight:600}.usage-breakdown-loading.svelte-1kee4g8{justify-content:center;align-items:center;min-height:120px;display:flex}.chart-view-toggle.svelte-1kee4g8{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.chart-view-btn.svelte-1kee4g8{width:30px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:inline-flex}.chart-view-btn.svelte-1kee4g8:hover{color:var(--text)}.chart-view-btn.active.svelte-1kee4g8{background:var(--accent);color:#fff}.chart-view-btn.svelte-1kee4g8 svg{fill:none;stroke:currentColor;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:16px;height:16px}.usage-chart-table-wrapper.svelte-1kee4g8{-webkit-overflow-scrolling:touch;margin-top:0;overflow-x:auto}.usage-chart-data-table.svelte-1kee4g8{min-width:max-content}.usage-chart-data-table.svelte-1kee4g8 th,.usage-chart-data-table.svelte-1kee4g8 td{white-space:nowrap}.pagination-info.svelte-1imew3q{color:var(--text-muted);font-size:13px}.pagination-buttons.svelte-1imew3q{gap:8px;display:flex}.usage-log-loading.svelte-hg4ill{justify-content:center;align-items:center;min-height:120px;display:flex}.usage-log-section.svelte-hg4ill{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.usage-log-section.svelte-hg4ill h3{margin-bottom:16px;font-size:16px;font-weight:600}.usage-log-section.svelte-hg4ill .table-wrapper{overflow-x:auto}.usage-log-toolbar.svelte-hg4ill{gap:12px;margin-bottom:16px;display:grid}.usage-filter-row.svelte-hg4ill{grid-template-columns:repeat(12,minmax(0,1fr));align-items:center;gap:12px;display:grid}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1/-1}.usage-filter-row-options.svelte-hg4ill{grid-template-columns:1fr}.usage-log-checkbox.svelte-hg4ill{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.usage-log-checkbox.svelte-hg4ill input{cursor:pointer;width:16px;height:16px}.usage-ts.svelte-hg4ill{white-space:nowrap;font-size:12px}.usage-log-row-cached.svelte-hg4ill td{opacity:.75;font-style:italic}.usage-log-row-cached.svelte-hg4ill .usage-log-cache-cell:where(.svelte-hg4ill){font-weight:700}.caveat-icon.svelte-hg4ill{color:var(--warning);cursor:help;margin-left:4px;font-size:14px}@media (width<=768px){.usage-log-toolbar.svelte-hg4ill{gap:10px}.usage-filter-row.svelte-hg4ill{grid-template-columns:1fr}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1}.usage-log-table.svelte-hg4ill{display:block;overflow-x:auto}}.usage-sticky-controls.svelte-spwie6{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}.usage-charts-grid.svelte-spwie6{flex-wrap:wrap;gap:24px;margin-bottom:24px;display:flex}.usage-charts-grid.svelte-spwie6 .model-chart-section{flex:calc(50% - 24px);min-width:420px;margin-bottom:0}@media (width<=520px){.usage-charts-grid.svelte-spwie6 .model-chart-section{min-width:0}}.loading-state.svelte-hzxv1d{min-height:var(--loading-state-min-height,64px);color:var(--text-muted);justify-content:center;align-items:center;gap:10px;font-size:14px;display:flex}.budget-bar-text-row-on-fill.svelte-1jm56wo{color:#fff;clip-path:inset(0 calc(100% - var(--budget-progress,0%)) 0 0)}.budget-bar-text-start.svelte-1jm56wo{left:8px;transform:translateY(-50%)}.budget-bar-track-period-custom.svelte-1jm56wo .budget-bar-text-row-on-fill:where(.svelte-1jm56wo){color:#3f332a}.budget-override-dialog.svelte-13ryo7h{max-width:460px}.budget-sort-control.svelte-1752fqe{align-items:center;gap:8px}.budget-sort-control.svelte-1752fqe label{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.budget-sort-select.svelte-1752fqe{background-color:var(--bg-surface);min-width:132px}.budget-sort-select.svelte-1752fqe:hover{background-color:var(--bg-surface-hover)}.model-name-cell.svelte-1iynym{flex-direction:column;gap:8px;display:flex}.model-name-primary.svelte-1iynym{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.model-name-secondary.svelte-1iynym{color:var(--text-muted);font-size:12px}.model-redirect-remove-btn.svelte-1iynym{appearance:none;color:var(--danger);cursor:pointer;background:0 0;border:0;margin-left:4px;padding:0;font-size:11px}.model-redirect-remove-btn.svelte-1iynym:hover:not(:disabled){text-decoration:underline}.model-redirect-remove-btn.svelte-1iynym:disabled{opacity:.45;cursor:default}.model-kind-icon.svelte-1iynym{border:1px solid color-mix(in srgb, var(--accent) 55%, var(--border));background:var(--bg);width:24px;height:24px;color:var(--accent);border-radius:999px;flex:0 0 24px;justify-content:center;align-items:center;display:inline-flex}.model-kind-icon-svg.svelte-1iynym{width:14px;height:14px}.model-row-actions.svelte-1iynym{text-align:right;width:170px}@media (width<=768px){.model-name-primary.svelte-1iynym{flex-direction:column;align-items:flex-start}}.provider-group-row.svelte-1911hy6 td{background:color-mix(in srgb, var(--accent) 6%, var(--bg));padding-top:12px;padding-bottom:12px}.provider-group-row.svelte-1911hy6:hover td{background:color-mix(in srgb, var(--accent) 8%, var(--bg))}.provider-group-header.svelte-1911hy6{justify-content:space-between;align-items:center;gap:16px;display:flex}.provider-group-meta.svelte-1911hy6{flex-direction:column;gap:4px;min-width:0;display:flex}.provider-group-title.svelte-1911hy6{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.provider-group-type.svelte-1911hy6,.provider-group-count.svelte-1911hy6,.provider-group-summary.svelte-1911hy6{color:var(--text-muted);font-size:12px}@media (width<=768px){.provider-group-header.svelte-1911hy6{flex-direction:column;align-items:flex-start}}.vm-session-affinity-checkbox.svelte-d1j6xw{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.vm-session-affinity-checkbox.svelte-d1j6xw input:where(.svelte-d1j6xw){accent-color:var(--accent);cursor:pointer}.pricing-override-rows.svelte-u8snes{gap:12px;display:grid}.pricing-override-row.svelte-u8snes{grid-template-columns:minmax(220px,1fr) minmax(130px,180px) 32px;align-items:end;gap:12px;display:grid}.pricing-override-row-actions.svelte-u8snes{justify-content:flex-start;display:flex}.pricing-override-tier-note.svelte-u8snes{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:6px;padding:10px 12px;font-size:13px}.pricing-preview.svelte-u8snes{border:1px solid var(--border);border-radius:6px;overflow:hidden}.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:minmax(150px,1fr) minmax(90px,auto) minmax(130px,.8fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.pricing-preview-header.svelte-u8snes{background:var(--bg);color:var(--text-muted);text-transform:uppercase;font-size:12px;font-weight:600}.pricing-preview-row.svelte-u8snes{border-top:1px solid var(--border);font-size:13px}.pricing-preview-row-empty.svelte-u8snes{color:var(--text-muted);grid-template-columns:1fr}@media (width<=768px){.pricing-override-row.svelte-u8snes,.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:1fr}}.failover-drafts-editor.svelte-1n87bip{flex-direction:column;gap:16px;display:flex}.failover-draft-header-actions.svelte-1n87bip{flex:none;align-items:center;gap:10px;display:flex}.failover-draft-counter.svelte-1n87bip{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.failover-draft-toolbar.svelte-1n87bip{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.failover-draft-toolbar.svelte-1n87bip .filter-input-wrap,.failover-draft-toolbar.svelte-1n87bip .filter-input{min-width:0}.failover-draft-toggle-all.svelte-1n87bip{flex:none}.failover-draft-list.svelte-1n87bip{flex-direction:column;gap:8px;max-height:min(52vh,430px);padding-right:4px;display:flex;overflow-y:auto}.failover-draft-row.svelte-1n87bip{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);cursor:pointer;grid-template-columns:18px minmax(0,1fr);align-items:start;gap:10px;padding:10px;display:grid}.failover-draft-row.svelte-1n87bip:hover{border-color:color-mix(in srgb, var(--accent) 42%, var(--border));background:var(--bg-surface-hover)}.failover-draft-row.svelte-1n87bip input{width:16px;height:16px;margin-top:2px}.failover-draft-copy.svelte-1n87bip{gap:4px;min-width:0;display:grid}.failover-draft-source.svelte-1n87bip,.failover-draft-targets.svelte-1n87bip{overflow-wrap:anywhere}.failover-draft-targets.svelte-1n87bip{color:var(--text-muted);font-size:12px}.failover-drafts-empty.svelte-1n87bip{align-items:center;min-height:96px;display:flex}.failover-draft-actions.svelte-1n87bip{margin-top:0}.category-tabs.svelte-scpjps{-webkit-overflow-scrolling:touch;align-items:center;gap:4px;margin-bottom:16px;padding-bottom:2px;display:flex;overflow-x:auto}.category-tab.svelte-scpjps{background:var(--bg-surface);border:1px solid var(--border);color:var(--text-muted);cursor:pointer;white-space:nowrap;border-radius:6px;flex-shrink:0;align-items:center;gap:6px;padding:6px 14px;font-family:inherit;font-size:13px;font-weight:500;transition:all .15s;display:inline-flex}.category-tab.svelte-scpjps:hover{color:var(--text);background:var(--bg-surface-hover)}.category-tab.active.svelte-scpjps{background:var(--accent);color:#fff;border-color:var(--accent)}.category-tab.svelte-scpjps .tab-count:where(.svelte-scpjps){background:#ffffff26;border-radius:9px;justify-content:center;align-items:center;min-width:20px;height:18px;padding:0 5px;font-size:11px;font-weight:600;line-height:1;display:inline-flex}.category-tab.svelte-scpjps:not(.active) .tab-count:where(.svelte-scpjps){background:var(--bg)}@media (width<=768px){.category-tabs.svelte-scpjps{gap:4px}.category-tab.svelte-scpjps{padding:5px 10px;font-size:12px}}.workflow-pipeline-meta.svelte-1viff7o{border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 86%, transparent);min-width:0;max-width:calc(100% - 28px);color:var(--text-muted);white-space:nowrap;appearance:none;cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:0;padding:2px 10px;font-size:12px;font-weight:500;line-height:1.2;transition:background-color .15s,border-color .15s,color .15s,box-shadow .15s;display:inline-flex;position:absolute;top:12px;right:14px;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover,.workflow-pipeline-meta.svelte-1viff7o:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface));color:color-mix(in srgb, var(--accent) 74%, var(--text))}.workflow-pipeline-meta.svelte-1viff7o:focus-visible{box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);outline:none}.workflow-pipeline-meta-label.svelte-1viff7o{flex:none;font-weight:700}.workflow-pipeline-meta-placeholder.svelte-1viff7o{opacity:1;flex:none;max-width:3ch;margin-left:4px;transition:max-width .18s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta-value.svelte-1viff7o{opacity:0;text-overflow:clip;flex:0 auto;max-width:0;margin-left:0;transition:max-width .22s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o){opacity:0;max-width:0;margin-left:0}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o){opacity:1;max-width:42ch;margin-left:4px}.workflow-pipeline-meta-icon.svelte-1viff7o{opacity:0;flex:none;justify-content:center;align-items:center;width:0;height:14px;margin-left:0;line-height:0;transition:width .18s,margin-left .18s,opacity .15s,transform .18s;display:inline-flex;overflow:hidden;transform:translate(4px)translateY(1px)scale(.84)}.workflow-pipeline-meta-icon.svelte-1viff7o svg{width:14px;height:14px}.workflow-pipeline-meta-copied.svelte-1viff7o,.workflow-pipeline-meta-copied.svelte-1viff7o:hover,.workflow-pipeline-meta-copied.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-icon:where(.svelte-1viff7o){opacity:1;width:14px;margin-left:6px;transform:translateY(1px)}.workflow-pipeline-meta-error.svelte-1viff7o,.workflow-pipeline-meta-error.svelte-1viff7o:hover,.workflow-pipeline-meta-error.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 34%, var(--border));color:var(--danger)}.workflow-pipeline.svelte-nbptrg{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg);flex-direction:column;gap:0;margin-bottom:12px;padding:18px 20px 20px;display:flex;position:relative}.workflow-pipeline-has-meta.svelte-nbptrg{padding-top:42px}.workflow-pipeline-row.svelte-nbptrg{align-items:center;width:100%;min-width:0;display:flex;overflow-x:auto}.workflow-node-icon.svelte-nbptrg{border-radius:var(--radius);background:var(--bg);width:28px;height:28px;color:var(--text-muted);justify-content:center;align-items:center;display:flex}.workflow-node-icon.svelte-nbptrg svg{stroke:currentColor;fill:none;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:15px;height:15px}.workflow-node-label.svelte-nbptrg{letter-spacing:.03em;color:var(--text);white-space:nowrap;font-size:11px;font-weight:700;line-height:1.2}.workflow-node-sub.svelte-nbptrg{color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;max-width:120px;font-size:10px;font-weight:500;line-height:1.2;font-family:var(--font-mono,ui-monospace, monospace);overflow:hidden}.workflow-node-badge.svelte-nbptrg{border-radius:var(--radius);letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;border:1px solid var(--border);background:var(--bg);color:var(--text-muted);align-items:center;padding:2px 7px;font-size:9px;font-weight:800;line-height:1.5;display:inline-flex}.workflow-node-endpoint.svelte-nbptrg{border-radius:var(--radius);border-color:var(--border);background:var(--bg-surface);flex-direction:row;gap:7px;min-width:auto;padding:10px 14px}.workflow-node-icon-endpoint.svelte-nbptrg{border-radius:var(--radius);width:auto;height:auto;color:var(--text-muted);background:0 0;justify-content:flex-start;padding:0}.workflow-node-icon-endpoint.svelte-nbptrg svg{width:14px;height:14px}.workflow-node-endpoint.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted);font-size:11px;font-weight:600}.workflow-node-feature.svelte-nbptrg{border-color:color-mix(in srgb, var(--accent) 46%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface))}.workflow-node-feature.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--accent) 16%, var(--bg));color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--accent) 70%, var(--text-muted))}.workflow-node-ai.svelte-nbptrg{border-radius:var(--radius);gap:6px;min-width:96px;padding:12px 16px}.workflow-async-section.svelte-nbptrg{justify-content:flex-end;align-items:center;gap:0;width:100%;min-width:0;margin-top:10px;display:flex}.workflow-async-turn.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 60px;height:2px;position:relative}.workflow-async-turn.svelte-nbptrg:before{content:"";background:color-mix(in srgb, var(--text-muted) 40%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);width:7px;height:9px;position:absolute;top:50%;left:-7px;transform:translateY(-50%)}.workflow-async-turn.svelte-nbptrg:after{content:"";border-right:2px dashed color-mix(in srgb, var(--text-muted) 40%, var(--border));height:16px;position:absolute;bottom:1px;right:0}.workflow-async-row.svelte-nbptrg{align-items:center;min-width:0;margin-right:7px;display:flex}.workflow-conn-async.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 24px;width:24px}.workflow-conn-async.svelte-nbptrg:after{background:color-mix(in srgb, var(--text-muted) 45%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);left:-1px;right:auto}.workflow-node-async.svelte-nbptrg{border-radius:var(--radius);border-style:dashed;flex-direction:row;gap:7px;min-width:auto;padding:7px 12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){border-radius:var(--radius);width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg) svg{width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){font-size:10px;font-weight:700}.workflow-async-label.svelte-nbptrg{letter-spacing:.1em;text-transform:uppercase;color:var(--text-muted);opacity:.55;white-space:nowrap;flex-shrink:0;align-items:center;margin-left:8px;font-size:9px;font-weight:800;display:inline-flex}.workflow-node-success.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 18%, var(--bg));color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 85%, var(--text))}.workflow-node-success.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 74%, var(--text-muted))}.workflow-node-success.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 14%, var(--bg));border-color:color-mix(in srgb, var(--success) 38%, var(--border));color:var(--success)}.workflow-node-current.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 16%, var(--bg));color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 85%, var(--text))}.workflow-node-current.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 72%, var(--text-muted))}.workflow-node-current.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 13%, var(--bg));border-color:color-mix(in srgb, var(--info) 36%, var(--border));color:var(--info)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 85%, var(--text))}.workflow-node-warning.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 72%, var(--text-muted))}.workflow-node-warning.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 38%, var(--border));color:var(--warning)}.workflow-node-error.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--danger) 14%, var(--bg));color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 85%, var(--text))}.workflow-node-error.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 72%, var(--text-muted))}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 12%, var(--bg));color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg),.workflow-node-neutral.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--text-muted) 84%, var(--border))}.workflow-node-neutral.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 10%, var(--bg));border-color:color-mix(in srgb, var(--text-muted) 28%, var(--border));color:var(--text-muted)}.workflow-conn-hit.svelte-nbptrg,.workflow-conn-hit.svelte-nbptrg:after{background:color-mix(in srgb, var(--success) 58%, var(--border))}.workflow-conn-dim.svelte-nbptrg,.workflow-conn-dim.svelte-nbptrg:after{background:color-mix(in srgb, var(--border) 75%, transparent)}.workflow-node-success.svelte-nbptrg{border-color:color-mix(in srgb, var(--success) 52%, var(--border));background:color-mix(in srgb, var(--success) 9%, var(--bg-surface))}.workflow-node-current.svelte-nbptrg{border-color:color-mix(in srgb, var(--info) 56%, var(--border));background:color-mix(in srgb, var(--info) 10%, var(--bg-surface))}.workflow-node-warning.svelte-nbptrg{border-color:color-mix(in srgb, var(--warning) 52%, var(--border));background:color-mix(in srgb, var(--warning) 9%, var(--bg-surface))}.workflow-node-error.svelte-nbptrg{border-color:color-mix(in srgb, var(--danger) 52%, var(--border));background:color-mix(in srgb, var(--danger) 9%, var(--bg-surface))}.workflow-node-neutral.svelte-nbptrg{border-color:color-mix(in srgb, var(--text-muted) 40%, var(--border));background:color-mix(in srgb, var(--text-muted) 8%, var(--bg-surface))}.workflow-node-skipped.svelte-nbptrg{opacity:.28;position:relative}.workflow-card.svelte-1fo9fvq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:16px;padding:20px;display:flex}.workflow-card-head.svelte-1fo9fvq{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-card-footer.svelte-1fo9fvq{flex-direction:column;align-items:stretch;gap:10px;display:flex}.workflow-card-head.svelte-1fo9fvq h3{font-size:18px;font-weight:700}.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq{flex-wrap:wrap;justify-content:flex-end;gap:8px;display:flex}.workflow-card-meta-footer.svelte-1fo9fvq{justify-content:flex-start}.workflow-card-footer.svelte-1fo9fvq .alias-actions-cell{align-self:flex-end}.workflow-card-description.svelte-1fo9fvq{color:var(--text-muted);font-size:14px}.workflow-guardrails.svelte-1fo9fvq{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list.svelte-1fo9fvq{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-item.svelte-1fo9fvq{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;display:flex}@media (width<=768px){.workflow-card-head.svelte-1fo9fvq,.workflow-card-footer.svelte-1fo9fvq,.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq,.workflow-guardrail-item.svelte-1fo9fvq{flex-direction:column;align-items:flex-start}}.model-editor.workflow-editor{width:min(1080px,100%);margin-bottom:0}.alert-inline-actions.svelte-1bcpzh1{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.workflow-guardrail-editor.svelte-1bcpzh1{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list-editor.svelte-1bcpzh1{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-row.svelte-1bcpzh1{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:stretch;align-items:center;gap:12px;padding:10px 12px;display:flex}.workflow-guardrail-field.svelte-1bcpzh1{flex:auto;min-width:0}.workflow-guardrail-step-field.svelte-1bcpzh1{flex:0 0 120px}.workflow-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-step-input.svelte-1bcpzh1{max-width:120px}@media (width<=768px){.workflow-guardrail-row.svelte-1bcpzh1{flex-direction:column;align-items:flex-start}.workflow-step-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-guardrail-field.svelte-1bcpzh1,.workflow-guardrail-step-field.svelte-1bcpzh1{flex-basis:auto;width:100%}}.workflow-list-loading.svelte-ie2kfk{justify-content:center;align-items:center;gap:8px;display:flex}.workflows-list.svelte-ie2kfk{min-width:0}.workflow-card-grid.svelte-ie2kfk{grid-template-columns:1fr;gap:16px;display:grid}.workflow-page-note.svelte-l8kr26{color:var(--text-muted);margin-top:6px;font-size:14px}.audit-log-toolbar.svelte-1pwbpcm{flex-direction:column;gap:10px;margin-bottom:14px;display:flex}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:repeat(12,minmax(0,1fr));gap:10px;display:grid}.audit-filter-select.svelte-1pwbpcm{grid-column:span 2;min-width:0}.audit-filter-row-search.svelte-1pwbpcm .filter-input-wrap{grid-column:1/-1;max-width:none}.audit-filter-row-controls.svelte-1pwbpcm .audit-filter-select:where(.svelte-1pwbpcm){grid-column:span 2}.audit-filter-row-controls.svelte-1pwbpcm .btn{grid-column:11/-1;justify-self:end;min-width:108px}.audit-clear-btn.svelte-1pwbpcm{justify-content:center;align-items:center;gap:8px;font-weight:600;display:inline-flex}.audit-clear-btn.svelte-1pwbpcm .table-icon-svg{width:12px;height:12px}@media (width<=768px){.audit-log-toolbar.svelte-1pwbpcm{gap:8px}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:1fr}.audit-filter-row.svelte-1pwbpcm .filter-input-wrap,.audit-filter-row.svelte-1pwbpcm .filter-input,.audit-filter-select.svelte-1pwbpcm,.audit-filter-row.svelte-1pwbpcm .btn{grid-column:auto}}.audit-live-status.svelte-tve6yv{color:var(--text-muted);align-items:center;gap:10px;margin-left:16px;padding-left:6px;font-size:12px;display:inline-flex}.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:1.8s ease-out infinite svelte-tve6yv-audit-live-dot-throb}@keyframes svelte-tve6yv-audit-live-dot-throb{0%{transform:scale(1)}35%{transform:scale(1.35)}70%{transform:scale(1)}to{transform:scale(1)}}@media (prefers-reduced-motion:reduce){.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:none}}.audit-live-status-text.is-live.svelte-tve6yv{color:var(--success);font-weight:600}.audit-entry-metadata.svelte-hyopt0{border-top:1px solid var(--border);align-items:center;gap:10px;margin-top:12px;padding-top:12px;display:flex}.audit-entry-metadata-label.svelte-hyopt0{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;flex:none;font-size:12px;font-weight:700}.audit-entry-context.svelte-hyopt0{flex-wrap:wrap;flex:auto;gap:8px;display:flex}.audit-alias-badge.svelte-hyopt0{background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 28%, var(--border));color:var(--accent-strong,var(--accent))}@media (width<=768px){.audit-entry-metadata.svelte-hyopt0{flex-direction:column;align-items:flex-start;gap:8px}}.audit-attempt-track.svelte-1eu22xn{cursor:pointer;align-items:center;gap:6px;display:inline-flex}.audit-attempt-track-pips.svelte-1eu22xn{align-items:center;gap:3px;display:inline-flex}.audit-attempt-pip.svelte-1eu22xn{background:var(--text-muted);border-radius:2px;width:8px;height:8px}.audit-attempt-pip.audit-attempt-success.svelte-1eu22xn{background:var(--success)}.audit-attempt-pip.audit-attempt-error.svelte-1eu22xn{background:var(--danger)}.audit-attempt-track-count.svelte-1eu22xn{color:var(--text-muted);font-size:11px}.audit-entry-summary.svelte-17mysgz{cursor:pointer;justify-content:space-between;align-items:center;gap:12px;padding:5px 14px;list-style:none;display:flex;position:relative}.audit-entry-summary.svelte-17mysgz::-webkit-details-marker{display:none}.audit-entry-summary-live-in-progress.svelte-17mysgz{background:color-mix(in srgb, var(--info) 7%, var(--bg))}.audit-entry-summary-has-interactions.svelte-17mysgz{padding-right:44px}.audit-entry-summary-live-in-progress.svelte-17mysgz:before{content:"";background:var(--info);pointer-events:none;width:3px;animation:1.2s ease-in-out infinite audit-live-summary-stripe-blink;position:absolute;inset:0 auto 0 0}@media (prefers-reduced-motion:reduce){.audit-entry-summary-live-in-progress.svelte-17mysgz:before{opacity:.78;animation:none}}.audit-entry-left.svelte-17mysgz{align-items:center;gap:8px;min-width:0;display:flex}.audit-entry-right.svelte-17mysgz{color:var(--text-muted);flex-shrink:0;align-items:center;gap:10px;min-height:28px;display:inline-flex}.audit-thread-expander.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);min-width:28px;height:28px;color:var(--text-muted);cursor:pointer;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;gap:3px;padding:0 7px 0 4px;transition:background .1s ease-out,color .1s ease-out;display:inline-flex}.audit-thread-expander.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 12%, var(--bg));color:var(--accent)}.audit-thread-expander.svelte-17mysgz .audit-thread-expander-svg{width:14px;height:14px}.audit-thread-count.svelte-17mysgz{font-size:11px;font-weight:600}.audit-conversation-trigger.svelte-17mysgz{border:0;border-left:1px solid var(--border);background:color-mix(in srgb, var(--accent) 12%, var(--bg));width:32px;height:100%;color:var(--accent);cursor:pointer;border-radius:0;justify-content:center;align-items:center;margin:0;transition:background .1s ease-out,color .1s ease-out;display:inline-flex;position:absolute;inset:0 0 0 auto}.audit-conversation-trigger.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 20%, var(--bg))}.audit-conversation-trigger-active.svelte-17mysgz{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 28%, var(--bg));box-shadow:inset 2px 0 0 color-mix(in srgb, var(--accent) 60%, transparent);border-left:0}.audit-conversation-trigger-active.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 34%, var(--bg))}.audit-conversation-trigger.svelte-17mysgz .audit-conversation-trigger-svg{stroke-linecap:butt;stroke-linejoin:miter;width:18px;height:18px}.audit-path.svelte-17mysgz{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.audit-request-badge.svelte-17mysgz{white-space:nowrap;gap:6px;min-width:0}.audit-timestamp-time.svelte-17mysgz{display:none}.audit-provider-model.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);height:24px;color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;border-radius:999px;align-items:center;max-width:420px;padding:0 10px;font-size:12px;display:inline-flex;overflow:hidden}@container dashboard-content (width<=699px){.audit-entry-summary.svelte-17mysgz{flex-direction:column;align-items:flex-start}.audit-entry-right.svelte-17mysgz{justify-content:space-between;width:100%}.audit-request-status.svelte-17mysgz,.audit-timestamp-full.svelte-17mysgz{display:none}.audit-timestamp-time.svelte-17mysgz{display:inline}}.audit-pane-split.svelte-1h5puht{grid-template-columns:1fr 2fr;align-items:start;gap:10px 14px;display:grid}.audit-pane-split-single.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}@container dashboard-content (width<=699px){.audit-pane-split.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}}.audit-pane-split.svelte-1h5puht .audit-pane-block-error:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-pane-empty:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-size-warning:where(.svelte-1h5puht){grid-column:1/-1}.audit-pane-block.svelte-1h5puht{min-width:0}.audit-pane-block.svelte-1h5puht>h5{margin-bottom:6px}.audit-pane-block-head.svelte-1h5puht{justify-content:space-between;align-items:center;gap:8px;margin-bottom:6px;display:flex}.audit-pane-block-title.svelte-1h5puht{align-items:center;gap:8px;min-width:0;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn{background-color:var(--bg-surface);border:1px solid color-mix(in srgb, var(--border) 70%, var(--text) 30%);color:var(--text);cursor:pointer;border-radius:6px;flex:none;align-items:center;gap:6px;padding:4px 8px;font-family:inherit;font-size:12px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn:hover:not(:disabled){background:color-mix(in srgb, var(--bg-surface) 80%, var(--text) 20%);border-color:color-mix(in srgb, var(--border) 45%, var(--text) 55%)}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 18%, var(--bg-surface))}.audit-json.svelte-1h5puht{background:var(--bg-surface);border:1px solid var(--border);box-sizing:border-box;white-space:pre;max-width:100%;max-height:220px;color:var(--text);border-radius:6px;padding:10px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;line-height:1.45;overflow:auto}.audit-pane-error-message.svelte-1h5puht{color:var(--danger)}.audit-pane-clickable-preview.svelte-1h5puht{cursor:pointer}.audit-pane-clickable-preview.svelte-1h5puht:hover{background:color-mix(in srgb, var(--danger) 8%, transparent)}.audit-json-body.svelte-1h5puht{white-space:pre;overflow-wrap:normal}.audit-pane-empty.svelte-1h5puht{text-align:left;padding:8px 0 0}.audit-pane-pending.svelte-1h5puht{align-items:center;gap:8px;display:flex}.audit-pane-streaming.svelte-1h5puht{letter-spacing:.02em;color:var(--text-muted);align-items:center;gap:7px;padding-left:4px;font-size:11px;font-weight:600;display:inline-flex}.audit-size-warning.svelte-1h5puht{color:var(--warning);margin-top:8px;font-size:12px}.audit-request-response.svelte-1bc5vi5{margin-top:4px}.audit-pane-tablist.svelte-1bc5vi5{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:2px;display:flex}.audit-pane-tab.svelte-1bc5vi5{border:1px solid var(--border);color:var(--text-muted);cursor:pointer;background:0 0;border-bottom-color:#0000;border-radius:6px 6px 0 0;align-items:center;gap:8px;margin-bottom:-1px;margin-right:12px;padding:8px 12px;font-family:inherit;font-size:13px;transition:color .15s,border-color .15s,background-color .15s;display:inline-flex}.audit-pane-tab.svelte-1bc5vi5:not(.audit-pane-tab-active):hover{color:var(--text);background:color-mix(in srgb, var(--text) 5%, transparent)}.audit-pane-tab-active.svelte-1bc5vi5{color:var(--text);border-color:var(--border);border-bottom-color:var(--bg);background:var(--bg)}.audit-pane-tab-label.svelte-1bc5vi5{font-weight:600}.audit-pane-tabpanel.svelte-1bc5vi5{min-width:0}.audit-pane-icon.svelte-1bc5vi5{color:var(--text-muted);flex:none;align-items:center;display:inline-flex}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-request{color:var(--accent)}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-response{color:var(--info)}.audit-pane-icon.svelte-1bc5vi5 svg{width:16px;height:16px}.audit-pane-seq.svelte-1bc5vi5{color:var(--text-muted);font-size:12px}.audit-pane-kind.svelte-1bc5vi5{text-transform:uppercase;letter-spacing:.04em;font-size:10px;font-weight:600}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-primary{color:var(--text-muted)}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-failover{color:var(--accent);background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-retry{color:var(--warning);background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 30%, var(--border))}.audit-savings-pill.svelte-1bc5vi5{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);color:var(--prompt-cache-color);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;font-weight:700;display:inline-flex}.audit-step-pill.svelte-1bc5vi5{border:1px dashed var(--border);color:var(--text-muted);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;display:inline-flex}.audit-entry.svelte-cmjgwr{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);transition:background .12s ease-out,border-color .12s ease-out;overflow:hidden}.audit-entry-interactions-open.svelte-cmjgwr{border-width:2px;border-color:color-mix(in srgb, var(--prompt-cache-color) 38%, var(--border))}.audit-entry-details.svelte-cmjgwr{border-top:1px solid var(--border);background:var(--bg-surface);padding:12px;overflow:hidden}.audit-thread.svelte-pneivi{flex-direction:column;gap:10px;display:flex}.audit-thread-children.svelte-pneivi{flex-direction:column;gap:10px;margin-left:26px;display:flex}.audit-thread-child.svelte-pneivi,.audit-thread-loading.svelte-pneivi{position:relative}.audit-thread-child.svelte-pneivi:before,.audit-thread-loading.svelte-pneivi:before{content:"";border-left:1px solid var(--border);border-bottom:1px solid var(--border);pointer-events:none;border-bottom-left-radius:6px;width:12px;height:calc(50% + 10px);position:absolute;top:-10px;left:-14px}.audit-thread-child.svelte-pneivi:not(:last-child):after{content:"";border-left:1px solid var(--border);pointer-events:none;position:absolute;top:50%;bottom:-10px;left:-14px}.audit-thread-loading.svelte-pneivi{padding:6px 0 6px 4px;display:flex}.audit-thread-more.svelte-pneivi{color:var(--text-muted);padding-left:4px;font-size:12px}.audit-log-loading.svelte-1nhcbov{justify-content:center;padding:2rem 0;display:flex}.audit-list-toolbar.svelte-1nhcbov{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;display:flex}.audit-list-toolbar-left.svelte-1nhcbov{flex-wrap:wrap;align-items:center;gap:16px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov{color:var(--text-muted);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:7px;font-size:13px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov input:where(.svelte-1nhcbov){accent-color:var(--accent);cursor:pointer}.audit-retention-note.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-retention-highlight.svelte-1nhcbov{color:var(--text);font-weight:600}.audit-log-section.svelte-1nhcbov{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.audit-log-summary.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-log-list.svelte-1nhcbov{flex-direction:column;gap:10px;display:flex}.settings-guardrails-list.svelte-1bvx512{min-width:0}.settings-guardrail-type-pill.svelte-1bvx512{border:1px solid color-mix(in srgb, var(--accent) 18%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent);color:var(--text);white-space:nowrap;border-radius:999px;align-items:center;padding:6px 10px;font-size:12px;font-weight:600;display:inline-flex}.settings-guardrail-summary.svelte-1bvx512{color:var(--text);font-size:14px;line-height:1.45}.settings-guardrail-description.svelte-1bvx512{color:var(--text-muted);margin-top:6px;font-size:12px}.model-editor.guardrails-editor-wide{width:min(1080px,100%)}.form-field-fieldset.svelte-s964s3{border:0;min-inline-size:0;margin:0;padding:0}.form-field-legend.svelte-s964s3{color:var(--text-muted);letter-spacing:.5px;text-transform:uppercase;padding:0;font-size:12px;font-weight:600}.model-editor.settings-guardrails-editor{min-width:0}.settings-guardrails-hero.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));border-radius:var(--radius);background:radial-gradient(circle at top right, color-mix(in srgb, var(--accent-hover) 18%, transparent), transparent 42%), radial-gradient(circle at bottom left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 40%), var(--bg-surface);justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:20px;padding:24px;display:flex}.settings-kicker.svelte-5x874c{color:var(--accent);letter-spacing:.08em;text-transform:uppercase;margin:0 0 10px;font-size:11px;font-weight:700}.settings-guardrails-hero.svelte-5x874c h3{margin-bottom:8px}.settings-guardrails-hero.svelte-5x874c p:last-child{color:var(--text-muted);margin-bottom:0}.settings-guardrails-meta.svelte-5x874c{gap:12px;display:flex}.settings-guardrails-stat.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));background:color-mix(in srgb, var(--bg-surface-hover) 76%, transparent);border-radius:16px;min-width:110px;padding:14px 16px}.settings-guardrails-stat-label.svelte-5x874c{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;margin-bottom:8px;font-size:11px;font-weight:700;display:block}.settings-guardrails-stat.svelte-5x874c strong{font-size:24px;font-weight:700}@media (width<=768px){.settings-guardrails-hero.svelte-5x874c{flex-direction:column}.settings-guardrails-meta.svelte-5x874c{width:100%}.settings-guardrails-stat.svelte-5x874c{flex:1 1 0}}.mcp-catalog-section.svelte-1xqrzco{margin-top:18px}.mcp-catalog-section.svelte-1xqrzco .form-field-label{margin-bottom:8px}.mcp-catalog-subtitle.svelte-1xqrzco{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.mcp-catalog-list.svelte-1xqrzco{flex-direction:column;gap:12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.mcp-catalog-item-name.svelte-1xqrzco{overflow-wrap:anywhere;font-size:13px}.mcp-catalog-item-aggregated.svelte-1xqrzco{color:var(--text-muted);overflow-wrap:anywhere;margin-top:2px;font-size:11px}.mcp-catalog-item-description.svelte-1xqrzco{color:var(--text-muted);margin:2px 0 0;font-size:13px;font-weight:400}.mcp-server-sub-counts.svelte-ah8nrt{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;max-width:280px;margin-top:4px;font-size:11px;overflow:hidden}.mcp-server-table-wrapper.svelte-ah8nrt{overflow-x:auto}.mcp-server-table-wrapper.svelte-ah8nrt .data-table{min-width:860px}.auth-key-form-fields.svelte-1gswxes>.form-field{margin-bottom:4px}.auth-key-dashboard-toggle.svelte-1gswxes{cursor:pointer;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-key-issued-banner.svelte-1gswxes{background:color-mix(in srgb, var(--success) 8%, var(--bg-surface));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));border-radius:var(--radius);margin-bottom:20px;padding:16px}.auth-key-issued-warning.svelte-1gswxes{color:color-mix(in srgb, var(--success) 80%, var(--text));margin-bottom:12px;font-size:13px;font-weight:600}.auth-key-issued-value-row.svelte-1gswxes{flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:12px;display:flex}.auth-key-issued-token.svelte-1gswxes{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);word-break:break-all;flex:1;min-width:0;padding:8px 12px;font-size:13px;overflow-x:auto}.usage-label-chip-static.svelte-nf0ldb,.usage-label-chip-static.svelte-nf0ldb:hover{cursor:default;background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.auth-key-redacted.svelte-nf0ldb{color:var(--text-muted);font-size:13px}.auth-key-actions-cell.svelte-nf0ldb{white-space:nowrap}.auth-key-row-deactivated.svelte-nf0ldb td:where(.svelte-nf0ldb):not(.auth-key-actions-cell){opacity:.55}.auth-key-expiry.svelte-nf0ldb{white-space:nowrap;align-items:center;gap:8px;display:inline-flex}.auth-key-th-help.svelte-nf0ldb{cursor:help;align-items:center;gap:4px;display:inline-flex}.auth-key-row-actions.svelte-nf0ldb{align-items:center;gap:6px;display:inline-flex}.auth-keys-loading.svelte-1xpdcqx{justify-content:center;align-items:center;padding:32px 0;display:flex}.auth-keys-help-notice.svelte-1xpdcqx{margin-bottom:20px}.auth-keys-inactive-toggle.svelte-1xpdcqx{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-keys-inactive-toggle.svelte-1xpdcqx input:where(.svelte-1xpdcqx){width:16px;height:16px;accent-color:var(--accent);cursor:pointer}.settings-panel-header.svelte-15kyv2y{justify-content:space-between;gap:16px;margin-bottom:20px;display:flex}.settings-panel-header.svelte-15kyv2y h3{font-size:18px}.settings-form-grid.svelte-15kyv2y{grid-template-columns:minmax(280px,420px);gap:16px;display:grid}@media (width<=768px){.settings-form-grid.svelte-15kyv2y{grid-template-columns:1fr}}.budget-settings-section.svelte-a747ys{width:100%}.budget-settings-grid.svelte-a747ys{gap:12px;display:grid}.budget-settings-row.svelte-a747ys{grid-template-columns:96px minmax(170px,1fr) minmax(110px,140px) minmax(110px,140px) minmax(220px,280px);align-items:start;gap:12px;display:grid}.budget-settings-period.svelte-a747ys{color:var(--text);letter-spacing:0;text-transform:uppercase;align-self:end;min-height:35px;padding-bottom:9px;font-size:12px;font-weight:700}.budget-settings-spacer.svelte-a747ys{min-height:1px}.budget-settings-help-cell.svelte-a747ys{align-self:start;min-width:0;min-height:35px}.budget-settings-help-cell.svelte-a747ys .inline-help-copy{max-width:280px;margin:22px 0 0;font-size:12px;line-height:1.35}@media (width<=768px){.budget-settings-grid.svelte-a747ys,.budget-settings-row.svelte-a747ys{grid-template-columns:1fr}.budget-settings-spacer.svelte-a747ys{display:none}}.tagging-settings-grid.svelte-18e8yem{gap:12px;display:grid}.tagging-settings-row.svelte-18e8yem{grid-template-columns:minmax(170px,1fr) minmax(150px,1fr) minmax(80px,110px) auto minmax(90px,auto);align-items:end;gap:12px;display:grid}.tagging-do-not-pass.svelte-18e8yem{color:var(--text);white-space:nowrap;align-items:center;gap:6px;min-height:35px;font-size:13px;display:flex}.tagging-row-trailer.svelte-18e8yem{align-items:center;gap:8px;min-height:35px;display:flex}.tagging-settings-empty.svelte-18e8yem{color:var(--text-muted);margin:0}.tagging-settings-actions.svelte-18e8yem{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.tagging-settings-row.svelte-18e8yem{grid-template-columns:1fr;align-items:stretch}.tagging-settings-actions.svelte-18e8yem,.tagging-settings-actions.svelte-18e8yem .btn{width:100%}}.pricing-recalculate-section.svelte-1cdxzyk{width:100%}.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:minmax(220px,320px) minmax(260px,360px);justify-content:start;align-items:end;gap:12px;width:100%;display:grid}.pricing-recalculate-date-field.svelte-1cdxzyk{grid-column:1/-1;width:100%;max-width:320px}.pricing-recalculate-filter-field.svelte-1cdxzyk{width:100%;max-width:360px}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker{width:100%}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-trigger{justify-content:space-between;width:100%}.pricing-recalculate-actions.svelte-1cdxzyk{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:1fr}.pricing-recalculate-actions.svelte-1cdxzyk,.pricing-recalculate-actions.svelte-1cdxzyk .btn{width:100%}}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-dropdown{inset:auto auto calc(100% + 6px) 0}.settings-refresh-icon.svelte-yeq2mp{flex:0 0 16px;width:16px;height:16px}.runtime-refresh-steps.svelte-yeq2mp{color:var(--text-muted);gap:8px;margin-top:14px;padding-left:18px;font-size:13px;display:grid}.runtime-refresh-step.is-ok.svelte-yeq2mp{color:var(--success)}.runtime-refresh-step.is-partial.svelte-yeq2mp{color:var(--warning)}.runtime-refresh-step.is-failed.svelte-yeq2mp{color:var(--danger)}.runtime-settings-copy.svelte-tldbe5{min-width:180px}.runtime-settings-fields.svelte-tldbe5{gap:16px;width:min(560px,100%);display:grid}.runtime-setting-row.svelte-tldbe5{grid-template-columns:minmax(220px,1fr) 180px;align-items:center;gap:20px;display:grid}.runtime-setting-description.svelte-tldbe5,.runtime-setting-managed.svelte-tldbe5{color:var(--text-muted);margin:4px 0 0;font-size:12px}.runtime-setting-managed.svelte-tldbe5{color:var(--warning)}@media (width<=720px){.runtime-setting-row.svelte-tldbe5{grid-template-columns:1fr;gap:8px}}.settings-version-footer.svelte-3naq7u{color:var(--text-muted);text-align:right;margin-top:24px;font-size:12px}.chat-message.svelte-12s99s5{border:1px solid var(--border);background:var(--bg);border-radius:10px;max-width:94%;padding:10px 12px;position:relative;overflow:hidden}.chat-message.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border));box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent)}.chat-message.is-after-anchor.svelte-12s99s5,.chat-function-note.is-after-anchor.svelte-12s99s5{opacity:.46}.chat-message.role-user.svelte-12s99s5{align-self:flex-start}.chat-message.role-assistant.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 18%, var(--bg));align-self:flex-end}.chat-message.role-system.svelte-12s99s5{background:color-mix(in srgb, var(--warning) 10%, var(--bg));align-self:center;width:100%;max-width:100%}.chat-message.role-error.svelte-12s99s5{border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg));align-self:flex-end}.chat-message.role-error.svelte-12s99s5 .chat-role:where(.svelte-12s99s5){color:color-mix(in srgb, var(--danger) 75%, var(--text-muted))}.chat-message-meta.svelte-12s99s5{justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:6px;display:flex}.chat-role.svelte-12s99s5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:12px;font-weight:700}.chat-time.svelte-12s99s5{color:var(--text-muted);white-space:nowrap;font-size:11px}.chat-content.svelte-12s99s5{white-space:pre-wrap;overflow-wrap:break-word;color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:13px;line-height:1.5}.chat-message.svelte-12s99s5:before,.chat-function-note.svelte-12s99s5:before{content:"";z-index:0;pointer-events:none;opacity:var(--prompt-cache-visibility);background:linear-gradient(90deg, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) 0, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) var(--prompt-cache-fill), transparent var(--prompt-cache-fill), transparent 100%);transition:opacity .15s;position:absolute;inset:0}.chat-message.svelte-12s99s5>:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5>:where(.svelte-12s99s5){z-index:1;position:relative}.chat-tool-calls.svelte-12s99s5{border-top:1px solid var(--border);flex-direction:column;gap:3px;margin-top:8px;padding-top:6px;display:flex}.chat-tool-call.svelte-12s99s5{color:var(--text-muted);border-radius:5px;min-width:0;padding:3px 5px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;position:relative;overflow:hidden}.chat-tool-call-summary.svelte-12s99s5{cursor:pointer;align-items:baseline;gap:6px;min-width:0;display:flex}.chat-tool-call-preview.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;opacity:.8;flex:1;min-width:0;overflow:hidden}.chat-tool-call-arguments.svelte-12s99s5{background:color-mix(in srgb, var(--border) 45%, transparent);color:var(--text);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;border-radius:6px;max-height:200px;margin-top:5px;padding:6px 8px;line-height:1.45;overflow:auto}.chat-tool-call-name.svelte-12s99s5:before{content:"⚡"}.chat-function-note.svelte-12s99s5{max-width:94%;color:var(--text-muted);background:color-mix(in srgb, var(--border) 40%, transparent);border:1px dashed var(--border);border-radius:12px;align-self:center;padding:4px 12px;font-size:12px;position:relative;overflow:hidden}.chat-function-note.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-inner.svelte-12s99s5{align-items:baseline;gap:6px;display:flex;overflow:hidden}.chat-function-note-inner.svelte-12s99s5 .chat-time:where(.svelte-12s99s5){flex-shrink:0;margin-left:auto}.chat-function-call-id.svelte-12s99s5{color:var(--text-muted);overflow-wrap:anywhere;margin-top:6px;font-size:10px}.chat-function-label.svelte-12s99s5{text-transform:uppercase;letter-spacing:.3px;white-space:nowrap;flex-shrink:0;font-size:11px;font-weight:600}.chat-function-label.svelte-12s99s5:before{content:"▸";margin-right:4px;transition:transform .12s;display:inline-block}.chat-function-note-details[open].svelte-12s99s5 .chat-function-label:where(.svelte-12s99s5):before{transform:rotate(90deg)}.chat-function-detail.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;overflow:hidden}.chat-function-note.role-function-call.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 8%, transparent);border-color:color-mix(in srgb, var(--accent) 30%, var(--border));align-self:flex-end}.chat-function-note.role-function-result.svelte-12s99s5{background:color-mix(in srgb, var(--success) 8%, transparent);border-color:color-mix(in srgb, var(--success) 30%, var(--border));align-self:flex-start}.chat-function-note.is-anchor.role-function-call.svelte-12s99s5,.chat-function-note.is-anchor.role-function-result.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-details.svelte-12s99s5{width:100%}.chat-function-note-details.svelte-12s99s5>summary{cursor:pointer;list-style:none}.chat-function-note-details.svelte-12s99s5>summary::-webkit-details-marker{display:none}.chat-function-expanded.svelte-12s99s5{border-top:1px solid var(--border);white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text);max-height:200px;margin-top:6px;padding-top:6px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;line-height:1.45;overflow:auto}@media (width<=768px){.chat-message.svelte-12s99s5{max-width:100%}}.conversation-drawer.svelte-ssrzja{flex:0 0 var(--conversation-panel-width);width:var(--conversation-panel-width);background:var(--bg-surface);border-left:1px solid var(--border);z-index:12;flex-direction:column;min-width:0;height:100vh;display:flex;position:sticky;top:0}.conversation-drawer-fullscreen.svelte-ssrzja{z-index:70;border-left:0;flex-basis:auto;width:100vw;height:100dvh;position:fixed;inset:0}.conversation-drawer-fullscreen.svelte-ssrzja .conversation-resize-handle:where(.svelte-ssrzja){display:none}.conversation-resize-handle.svelte-ssrzja{z-index:2;cursor:col-resize;touch-action:none;background:0 0;border:0;border-radius:0;outline:none;width:10px;padding:0;position:absolute;top:0;bottom:0;left:-5px}.conversation-resize-handle.svelte-ssrzja:after{content:"";background:0 0;width:2px;transition:background .15s;position:absolute;top:0;bottom:0;left:4px}.conversation-resize-handle.svelte-ssrzja:hover:after,.conversation-resize-handle.svelte-ssrzja:focus-visible:after{background:color-mix(in srgb, var(--accent) 70%, var(--border))}body.conversation-panel-resizing{cursor:col-resize;-webkit-user-select:none;user-select:none}.conversation-drawer-header.svelte-ssrzja{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:10px;padding:14px 16px;display:flex}.conversation-drawer-header-actions.svelte-ssrzja{align-items:center;gap:6px;display:flex}.conversation-drawer-title.svelte-ssrzja{align-items:center;gap:9px;min-width:0;display:flex}.conversation-follow-status.svelte-ssrzja{justify-content:center;align-items:center;margin:-4px;padding:4px;display:inline-flex}.conversation-drawer-header.svelte-ssrzja h3{font-size:16px;font-weight:700}.conversation-drawer-footer.svelte-ssrzja{border-top:1px solid var(--border);background:var(--bg-surface);flex-direction:column;flex-shrink:0;gap:9px;padding:10px 16px;display:flex}.conversation-composer.svelte-ssrzja{flex-direction:column;gap:7px;display:flex}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja){resize:vertical;border:1px solid var(--border);background:var(--bg);width:100%;min-height:50px;color:var(--text);font:inherit;border-radius:7px;padding:9px 10px;line-height:1.45}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):focus{outline:2px solid color-mix(in srgb, var(--accent) 38%, transparent);outline-offset:1px}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):disabled{opacity:.65}.conversation-composer-actions.svelte-ssrzja{justify-content:space-between;align-items:center;gap:10px;display:flex}.conversation-endpoint.svelte-ssrzja{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--text-muted);font-size:11px;overflow:hidden}.conversation-send-error.svelte-ssrzja{color:var(--danger);font-size:12px}.conversation-truncated.svelte-ssrzja{color:var(--text-muted);padding:0 16px 14px;font-size:12px}.conversation-cache-legend.svelte-ssrzja{color:var(--text-muted);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:7px;margin:12px 16px 0;padding:0;font-family:inherit;font-size:11px;display:flex}.conversation-cache-legend.svelte-ssrzja:hover{color:var(--text)}.conversation-cache-legend.svelte-ssrzja:focus-visible{outline:2px solid color-mix(in srgb, var(--prompt-cache-color) 35%, transparent);outline-offset:3px;border-radius:3px}.conversation-cache-switch.svelte-ssrzja{background:color-mix(in srgb, var(--text-muted) 30%, var(--border));border-radius:999px;flex:none;width:28px;height:16px;transition:background-color .15s;position:relative}.conversation-cache-switch.is-active.svelte-ssrzja{background:color-mix(in srgb, var(--prompt-cache-color) 80%, var(--bg))}.conversation-cache-switch-thumb.svelte-ssrzja{background:#fff;border-radius:50%;width:12px;height:12px;transition:transform .15s;position:absolute;top:2px;left:2px;box-shadow:0 1px 2px #0000003d}.conversation-cache-switch.is-active.svelte-ssrzja .conversation-cache-switch-thumb:where(.svelte-ssrzja){transform:translate(12px)}.conversation-cache-estimate.svelte-ssrzja{opacity:.75}.conversation-thread.svelte-ssrzja{flex-direction:column;gap:10px;padding:14px 16px 20px;display:flex}.conversation-live-status.svelte-ssrzja{color:var(--text-muted);align-items:center;gap:10px;padding:4px 16px 20px;font-size:13px;display:flex} diff --git a/internal/admin/dashboard/static/dist/assets/index-ayXqZ3cf.js b/internal/admin/dashboard/static/dist/assets/index-ayXqZ3cf.js deleted file mode 100644 index 53662aa18..000000000 --- a/internal/admin/dashboard/static/dist/assets/index-ayXqZ3cf.js +++ /dev/null @@ -1,67 +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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`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){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function h(e,t,n=!1){return e===void 0?n?t():t:e}function g(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 _=1<<24,v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,ee=65536,te=1<<19,ne=1<<20,re=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(`legacy props`),ue=Symbol(``),de=Symbol(`attributes`),fe=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),he=Symbol(`form reset`),ge=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},_e=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(`uninitialized`),je=`http://www.w3.org/1999/xhtml`,Me=`http://www.w3.org/2000/svg`,Ne=`http://www.w3.org/1998/Math/MathML`;function Pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Fe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ie(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Le(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Re=!1;function ze(e){Re=e}var Be;function Ve(e){if(e===null)throw Fe(),ke;return Be=e}function He(){return Ve(bn(Be))}function T(e){if(Re){if(bn(Be)!==null)throw Fe(),ke;Be=e}}function Ue(e=1){if(Re){for(var t=e,n=Be;t--;)n=bn(n);Be=n}}function We(e=!0){for(var t=0,n=Be;;){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=bn(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Fe(),ke;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=null;function Xe(e){Ye=e}function E(e,t=!1,n){Ye={p:Ye,i:!1,c:null,e:null,s:e,x:null,r:ir,l:null}}function D(e){var t=Ye,n=t.e;if(n!==null){t.e=null;for(var r of n)jn(r)}return e!==void 0&&(t.x=e),t.i=!0,Ye=t.p,e??{}}function Ze(){return!0}var Qe=[];function $e(){var e=Qe;Qe=[],p(e)}function et(e){if(Qe.length===0&&!zt){var t=Qe;queueMicrotask(()=>{t===Qe&&$e()})}Qe.push(e)}function tt(){for(;Qe.length>0;)$e()}function nt(e){var t=ir;if(t===null)return tr.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;rt(e,t)}function rt(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var it=~(y|b|v);function at(e,t){e.f=e.f&it|t}function ot(e){e.f&512||e.deps===null?at(e,v):at(e,b)}function st(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,st(t.deps))}function ct(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),st(e.deps),at(e,v)}var lt=!1;function ut(e){var t=lt;try{return lt=!1,[e(),lt]}finally{lt=t}}function dt(e,t){if(t){let t=document.body;e.autofocus=!0,et(()=>{document.activeElement===t&&e.focus()})}}function ft(e){Re&&yn(e)!==null&&xn(e)}var pt=!1;function mt(){pt||(pt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[he]?.()})},{capture:!0}))}function ht(e){var t=tr,n=ir;rr(null),ar(null);try{return e()}finally{rr(t),ar(n)}}function gt(e,t,n,r=n){e.addEventListener(t,()=>ht(n));let i=e[he];i?e[he]=()=>{i(),r(!0)}:e[he]=()=>r(!0),mt()}function _t(e){let t=0,n=an(0),r;return()=>{On()&&(I(n),In(()=>(t===0&&(r=Er(()=>e(()=>ln(n)))),t+=1,()=>{et(()=>{--t,t===0&&(r?.(),r=void 0,ln(n))})})))}}var vt=ee|te;function yt(e,t,n,r){new bt(e,t,n,r)}var bt=class{parent;is_pending=!1;transform_error;#e;#t=Re?Be: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=_t(()=>(this.#m=an(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=ir;t.b=this,t.f|=128,n(e)},this.parent=ir.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Ln(()=>{if(Re){let e=this.#t;He();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},vt),Re&&(this.#e=Be)}#g(){try{this.#a=zn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=zn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=zn(()=>e(this.#e)),et(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>zn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Kn(this.#o,()=>{this.#o=null}),this.#b(Ft))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=zn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Xn(this.#a,e);let t=this.#n.pending;this.#o=zn(()=>t(this.#e))}else this.#b(Ft)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){ct(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=ir,n=tr,r=Ye;ar(this.#i),rr(this.#i),Xe(this.#i.ctx);try{return Gt.ensure(),e()}catch(e){return nt(e),null}finally{ar(t),rr(n),Xe(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Kn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,et(()=>{this.#d=!1,this.#m&&sn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),I(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;Ft?.is_fork?(this.#a&&Ft.skip_effect(this.#a),this.#o&&Ft.skip_effect(this.#o),this.#s&&Ft.skip_effect(this.#s),Ft.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Un(this.#a),null),this.#o&&=(Un(this.#o),null),this.#s&&=(Un(this.#s),null),Re&&(Ve(this.#t),Ue(),Ve(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Le();return}r=!0,i&&Oe(),this.#s!==null&&Kn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){rt(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return zn(()=>{var t=ir;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return rt(e,this.#i.parent),null}}))};et(()=>{var t;try{t=this.transform_error(e)}catch(e){rt(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>rt(e,this.#i&&this.#i.parent)):o(t)})}};function xt(e,t,n,r){let i=Ze()?Tt:Ot;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=ir,c=St(),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){rt(e,s)}Ct()}}var d=wt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Dt(e))).then(u).catch(e=>rt(e,s)).finally(d)}l?l.then(()=>{c(),f(),Ct()}):f()}function St(){var e=ir,t=tr,n=Ye,r=Ft;return function(i=!0){ar(e),rr(t),Xe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ct(e=!0){ar(null),rr(null),Xe(null),e&&Ft?.deactivate()}function wt(){var e=ir,t=e.b,n=Ft,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 Tt(e){var t=2|y;return ir!==null&&(ir.f|=te),{ctx:Ye,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:ir,ac:null}}var Et=Symbol(`obsolete`);function Dt(e,t,n){let r=ir;r===null&&ve();var i=void 0,a=an(Ae),o=!tr,s=new Set;return Fn(()=>{var t=ir,n=m();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ge&&n.reject(e)}).finally(Ct)}catch(e){n.reject(e),Ct()}var c=Ft;if(o){if(t.f&32768)var l=wt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Et);else for(let e of s.values())e.reject(Et);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Et&&(c.activate(),t?(a.f|=se,sn(a,t)):(a.f&8388608&&(a.f^=se),sn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),kn(()=>{for(let e of s)e.reject(Et)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function O(e){let t=Tt(e);return sr(t),t}function Ot(e){let t=Tt(e);return t.equals=Je,t}function kt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(ge),t.ac=null}),t.fn!==null&&(t.teardown=f),xr(t,0),Vn(t))}function Nt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Sr(t)}var Pt=null,Ft=null,It=null,Lt=null,Rt=null,zt=!1,Bt=!1,Vt=null,Ht=null,Ut=0,Wt=1,Gt=class e{id=Wt++;#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(){Pt===null?Pt=this:(Pt.#n=this,this.#t=Pt),Pt=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)at(r,y),t(r);for(r of n.m)at(r,b),t(r)}this.#p.add(e)}#g(){this.#e=!0,Ut++>1e3&&(this.#x(),qt());for(let e of this.#u)this.#d.delete(e),at(e,y),this.schedule(e);for(let e of this.#d)at(e,b),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Vt=[],r=[],i=Ht=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw en(e),this.#h()||this.discard(),t}if(Ft=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Vt=null,Ht=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)$t(e,t);i.length>0&&Ft.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),It=this,Yt(r),Yt(n),It=null,this.#s?.resolve();var s=Ft;if(this.#a===0&&(this.#c.length===0||s!==null)&&this.#x(),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):_r(r)&&(i&16&&this.#d.add(r),Sr(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}}}#v(){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}#y(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),at(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#x(),Ft=this,this.#g()}#b(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??=m()).promise}static ensure(){if(Ft===null){let t=Ft=new e;!Bt&&!zt&&et(()=>{t.#e||t.flush()})}return Ft}apply(){Lt=null}schedule(e){if(Rt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Vt!==null&&t===ir&&(tr===null||!(tr.f&2)))return;if(n&96){if(!(n&1024))return;t.f^=v}}this.#c.push(t)}#x(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?Pt=e:t.#t=e,this.linked=!1}}};function Kt(e){var t=zt;zt=!0;try{var n;for(e&&(Ft!==null&&!Ft.is_fork&&Ft.flush(),n=e());;){if(tt(),Ft===null)return n;Ft.flush()}}finally{zt=t}}function qt(){try{Ce()}catch(e){rt(e,Rt)}}var Jt=null;function Yt(e){var t=e.length;if(t!==0){for(var n=0;n0)){nn.clear();for(let e of Jt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Jt.has(n)&&(Jt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sr(n)}}Jt.clear()}}Jt=null}}function Xt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Xt(i,t,n,r):e&4194320&&!(e&2048)&&Zt(i,t,r)&&(at(i,y),Qt(i))}}function Zt(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(e.deps!==null)for(let i of e.deps){if(n.call(t,i))return!0;if(i.f&2&&Zt(i,t,r))return r.set(i,!0),!0}return r.set(e,!1),!1}function Qt(e){Ft.schedule(e)}function $t(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),at(e,v);for(var n=e.first;n!==null;)$t(n,t),n=n.next}}function en(e){at(e,v);for(var t=e.first;t!==null;)en(t),t=t.next}var tn=new Set,nn=new Map,rn=!1;function an(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function k(e,t){let n=an(e,t);return sr(n),n}function on(e,t=!1,n=!0){let r=an(e);return t||(r.equals=Je),r}function A(e,t,n=!1){return tr!==null&&(!nr||tr.f&131072)&&Ze()&&tr.f&4325394&&(or===null||!or.has(e))&&De(),sn(e,n?j(t):t,Ht)}function sn(e,t,n=null){if(!e.equals(t)){nn.set(e,$n?t:e.v);var r=Gt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&At(t),Lt===null&&ot(t)}e.wv=gr(),un(e,y,n),Ze()&&ir!==null&&ir.f&1024&&!(ir.f&96)&&(ur===null?dr([e]):ur.push(e)),!r.is_fork&&tn.size>0&&!rn&&cn()}return t}function cn(){rn=!1;for(let e of tn){e.f&1024&&at(e,b);let t;try{t=_r(e)}catch{t=!0}t&&Sr(e)}tn.clear()}function ln(e){A(e,e.v+1)}function un(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ze(),a=r.length,o=0;o{if(mr===d)return e();var t=tr,n=mr;rr(null),hr(d);var r=e();return rr(t),hr(n),r};return i&&r.set(`length`,k(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Te();var i=r.get(t);return i===void 0?f(()=>{var e=k(n.value,u);return r.set(t,e),e}):A(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>k(Ae,u));r.set(t,e),ln(o)}}else A(n,Ae),ln(o);return!0},get(e,n,i){if(n===ce)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>k(j(s?e[n]:Ae),u)),r.set(n,o)),o!==void 0){var c=I(o);return c===Ae?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=I(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===ce)return!0;var n=r.get(t),i=n!==void 0&&n.v!==Ae||Reflect.has(e,t);return(n!==void 0||ir!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>k(i?j(e[t]):Ae,u)),r.set(t,n)),I(n)===Ae)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dk(Ae,u)),r.set(d+``,p)):A(p,Ae)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>k(void 0,u)),A(c,j(n)),r.set(t,c));else{l=c.v!==Ae;var m=f(()=>j(n));A(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&&A(g,_+1)}ln(o)}return!0},ownKeys(e){I(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==Ae});for(var[n,i]of r)i.v!==Ae&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ee()}})}function dn(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=a(t,`firstChild`).get,gn=a(t,`nextSibling`).get,u(e)&&(e[fe]=void 0,e[de]=null,e[pe]=void 0,e.__e=void 0),u(n)&&(n[me]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function M(e,t){if(!Re)return yn(e);var n=yn(Be);if(n===null)n=Be.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),Ve(r),r}return t&&wn(n),Ve(n),n}function N(e,t=!1){if(!Re){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Be?.nodeType!==3){var r=vn();return Be?.before(r),Ve(r),r}wn(Be)}return Be}function P(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=bn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),Ve(a),a}wn(r)}return Ve(r),r}function xn(e){e.textContent=``}function Sn(){return!1}function Cn(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 wn(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 Tn(e){ir===null&&(tr===null&&Se(e),xe()),$n&&be(e)}function En(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Dn(e,t){var n=ir;n!==null&&n.f&8192&&(e|=x);var r={ctx:Ye,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};Ft?.register_created_effect(r);var i=r;if(e&4)Vt===null?Gt.ensure().schedule(r):Vt.push(r);else if(t!==null){try{Sr(r)}catch(e){throw Un(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|=ee))}if(i!==null&&(i.parent=n,n!==null&&En(i,n),tr!==null&&tr.f&2&&!(e&64))){var a=tr;(a.effects??=[]).push(i)}return r}function On(){return tr!==null&&!nr}function kn(e){let t=Dn(8,null);return at(t,v),t.teardown=e,t}function An(e){Tn(`$effect`);var t=ir.f;if(!tr&&t&32&&Ye!==null&&!Ye.i){var n=Ye;(n.e??=[]).push(e)}else return jn(e)}function jn(e){return Dn(4|ne,e)}function Mn(e){Gt.ensure();let t=Dn(64|te,e);return()=>{Un(t)}}function Nn(e){Gt.ensure();let t=Dn(64|te,e);return(e={})=>new Promise(n=>{e.outro?Kn(t,()=>{Un(t),n(void 0)}):(Un(t),n(void 0))})}function Pn(e){return Dn(4,e)}function Fn(e){return Dn(oe|te,e)}function In(e,t=0){return Dn(8|t,e)}function F(e,t=[],n=[],r=[]){xt(r,t,n,t=>{Dn(8,()=>{e(...t.map(I))})})}function Ln(e,t=0){return Dn(16|t,e)}function Rn(e,t=0){return Dn(_|t,e)}function zn(e){return Dn(32|te,e)}function Bn(e){var t=e.teardown;if(t!==null){let e=$n,n=tr;er(!0),rr(null);try{t.call(null)}finally{er(e),rr(n)}}}function Vn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ht(()=>{e.abort(ge)});var r=n.next;n.f&64?n.parent=null:Un(n,t),n=r}}function Hn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Un(t),t=n}}function Un(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Wn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,Vn(e,t&&!n),xr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Bn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Gn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Wn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Gn(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 Kn(e,t,n=!0){var r=[];qn(e,r,!0);var i=()=>{n&&Un(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function qn(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)!=0||(i.f&32)!=0&&(e.f&16)!=0;qn(i,t,o?n:!1)}i=a}}}function Jn(e){Yn(e,!0)}function Yn(e,t){if(e.f&8192){e.f^=x,e.f&1024||(at(e,y),Gt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Yn(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 Xn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var Zn=null,Qn=!1,$n=!1;function er(e){$n=e}var tr=null,nr=!1;function rr(e){tr=e}var ir=null;function ar(e){ir=e}var or=null;function sr(e){tr!==null&&(or??=new Set).add(e)}var cr=null,lr=0,ur=null;function dr(e){ur=e}var fr=1,pr=0,mr=pr;function hr(e){mr=e}function gr(){return++fr}function _r(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Lt===null&&at(e,v)}return!1}function vr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(or!==null&&or.has(e)))for(var i=0;i{e.ac.abort(ge)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=C;var f=e.deps,p=Ft?.is_fork;if(cr!==null){var m;if(p||xr(e,lr),f!==null&&lr>0)for(f.length=lr+cr.length,m=0;m{s.ac.abort(ge),s.ac=null,at(s,y)}),Mt(s),xr(s,0)}}function xr(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`?et(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Vr(e,t,n,r,i){var a={capture:r,passive:i},o=Br(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&kn(()=>{t.removeEventListener(e,o,a)})}function L(e,t,n){(t[Lr]??={})[e]=n}function Hr(e){for(var t=0;t{throw e});throw p}}finally{e[Lr]=t,delete e.currentTarget,rr(d),ar(f)}}}var Gr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Kr(e){return Gr?.createHTML(e)??e}function qr(e){var t=Cn(`template`);return t.innerHTML=Kr(e.replaceAll(``,``)),t.content}function Jr(e,t){var n=ir;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function R(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Re)return Jr(Be,null),Be;i===void 0&&(i=qr(a?e:``+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;Jr(o,s)}else Jr(t,t);return t}}function Yr(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}`,o;return()=>{if(Re)return Jr(Be,null),Be;if(!o){var e=yn(qr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;Jr(n,r)}else Jr(t,t);return t}}function Xr(e,t){return Yr(e,t,`svg`)}function Zr(e=``){if(!Re){var t=vn(e+``);return Jr(t,t),t}var n=Be;return n.nodeType===3?wn(n):(n.before(n=vn()),Ve(n)),Jr(n,n),n}function Qr(){if(Re)return Jr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),Jr(t,n),e}function z(e,t){if(Re){var n=ir;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Be),He();return}e!==null&&e.before(t)}var $r=!0;function ei(e){$r=e}function B(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function ti(e,t){return ri(e,t)}var ni=new Map;function ri(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=Nn(()=>{var u=n??t.appendChild(vn());yt(u,{pending:()=>{}},t=>{E({});var n=Ye;if(o&&(n.c=o),a&&(i.$$events=a),Re&&Jr(t,null),$r=s,l=e(t,i)||{},$r=!0,Re&&(ir.nodes.end=Be,Be===null||Be.nodeType!==8||Be.data!==`]`))throw Fe(),ke;D()},c);var d=new Set,f=e=>{for(var n=0;n{for(var e of d)for(let n of[t,document]){var r=ni.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Wr),r.delete(e),r.size===0&&ni.delete(n)):r.set(e,i)}zr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ii.set(l,u),l}var ii=new WeakMap,ai=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)Jn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Jn(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&&(Un(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();Xn(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else Un(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Kn(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)||(Un(n.effect),this.#n.delete(e))};ensure(e,t){var n=Ft,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:zn(()=>t(a)),fragment:i})}else this.#t.set(e,zn(()=>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 Re&&(this.anchor=Be),this.#a(n)}};function V(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ai(e),a=n?ee:0;function o(e,t){if(Re){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}Ln(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function oi(e,t){return t}function si(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;ci(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;if(l){var u=n,d=u.parentNode;xn(d),d.append(u),e.items.clear()}ci(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function ci(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,di(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=re,pi(d,null,c)):Jn(d):Kn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Ln(()=>{p=I(f);var e=p.length;let t=!1;Re&&Ge(c)===`[!`!=(e===0)&&(c=We(),Ve(c),ze(!1),t=!0);for(var r=new Set,u=Ft,v=Sn(),y=0;ys(c)):(d=zn(()=>s(li??=vn())),d.f|=re)),e>r.size&&ye(``,``,``),Re&&e>0&&Ve(We()),!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&&ze(!0),I(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Re&&(c=Be)}function ui(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function di(e,t,n,i,a){var o=(i&8)!=0,s=t.length,c=e.items,l=ui(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var te=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function fi(e,t,n,r,i,a,o,s){var c=o&1?o&16?an(n):on(n,!1,!1):null,l=o&2?an(i):null;return{v:c,i:l,e:zn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function pi(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=bn(r);if(a.before(r),r===i)return;r=o}}function mi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function hi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Re&&(o=Ve(yn(c)))}F(()=>{var e=ir;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&Jr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Wn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Re){for(var a=Be.data,l=He(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Fe(),ke;Jr(Be,u),o=Ve(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Jr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function gi(e,t,...n){var r=new ai(e);Ln(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},ee)}function _i(e,t,n){var r;Re&&(r=Be,He());var i=new ai(e);Ln(()=>{var e=t()??null;if(Re&&Ge(r)===`[`!=(e!==null)){var a=We();Ve(a),i.anchor=a,ze(!1),i.ensure(e,e&&(t=>n(t,e))),ze(!0);return}i.ensure(e,e&&(t=>n(t,e)))},ee)}var vi=()=>performance.now(),yi={tick:e=>requestAnimationFrame(e),now:()=>vi(),tasks:new Set};function bi(){let e=yi.now();yi.tasks.forEach(t=>{t.c(e)||(yi.tasks.delete(t),t.f())}),yi.tasks.size!==0&&yi.tick(bi)}function xi(e){let t;return yi.tasks.size===0&&yi.tick(bi),{promise:new Promise(n=>{yi.tasks.add(t={c:e,f:n})}),abort(){yi.tasks.delete(t)}}}function Si(e,t){ht(()=>{e.dispatchEvent(new CustomEvent(t))})}function Ci(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function wi(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Ci(n.trim());t[i]=r.trim()}return t}var Ti=e=>e,Ei=null;function Di(e){Ei=e}function Oi(e,t,n){var r=(Ei??ir).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Ai(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function ki(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return ht(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Ai(t,m(),p,1,()=>{Si(t,`introstart`)},()=>{Si(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Ai(t,m(),f,0,()=>{Si(t,`outrostart`)},()=>{Si(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=ir;if((g.nodes.t??=[]).push(h),i&&$r){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Pn(()=>{Er(()=>h.in())})}}function Ai(e,t,n,r,i,a){var o=r===1;if(d(t)){var s,c=!1;return et(()=>{c||(s=Ai(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:f,deactivate:f,reset:f,t:()=>r};let{delay:l=0,css:u,tick:p,easing:m=Ti}=t;var h=[];if(o&&n===void 0&&(p&&p(0,1),u)){var g=wi(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var d=!1;if(u)for(var f=Math.ceil(c/(1e3/60)),h=0;h<=f;h+=1){var g=o+s*m(h/f),y=wi(u(g,1-g));l.push(y),d||=y.overflow===`hidden`}d&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*m(e/c)},p&&xi(()=>{if(v.playState!==`running`)return!1;var e=_();return p(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,p?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=f)},deactivate:()=>{a=f},reset:()=>{r===0&&p?.(1,0)},t:()=>_()}}function ji(e,t,n,r,i,a){let o=Re;Re&&He();var s=null;Re&&Be.nodeType===1&&(s=Be,He());var c=Re?Be:e,l=ir,u=new ai(c,!1);Ln(()=>{let e=t()||null;var a=i?i():n||e===`svg`?Me:void 0;if(e===null){u.ensure(null,null),ei(!0);return}return u.ensure(e,t=>{if(e){if(s=Re?s:Cn(e,a),Jr(s,s),r){var n=null;Re&&Ir(e)&&s.append(n=document.createComment(``));var i=Re?yn(s):s.appendChild(vn());Re&&(i===null?ze(!1):Ve(i)),Di(l),r(s,i),n?.remove(),Di(null)}ir.nodes.end=s,t.before(s)}Re&&Ve(t)}),ei(!0),()=>{e&&ei(!1)}},ee),kn(()=>{ei(!0)}),o&&(ze(!0),Ve(c))}function Mi(e,t){var n=void 0,r;Rn(()=>{n!==(n=t())&&(r&&=(Un(r),null),n&&(r=zn(()=>{Pn(()=>n(e))})))})}function Ni(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||Ii.includes(r[o-1]))&&(s===r.length||Ii.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Ri(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 zi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Bi(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(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(zi)),i&&c.push(...Object.keys(i).map(zi));var l=0,u=-1;let t=e.length;for(var d=0;d{Ui(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),kn(()=>{t.disconnect()})}function Gi(e,t,n=t){var r=new WeakSet,i=!0;gt(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ki);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ki(o)}n(a),e.__value=a,Ft!==null&&r.add(Ft)}),Pn(()=>{var a=t();if(e===document.activeElement){var o=Ft;if(r.has(o))return}if(Ui(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ki(s),n(a))}e.__value=a,i=!1}),Wi(e)}function Ki(e){return`__value`in e?e.__value:e.value}var qi=Symbol(`class`),Ji=Symbol(`style`),Yi=Symbol(`is custom element`),Xi=Symbol(`is html`),Zi=_e?`link`:`LINK`,Qi=_e?`input`:`INPUT`,$i=_e?`option`:`OPTION`,ea=_e?`select`:`SELECT`,ta=_e?`progress`:`PROGRESS`;function na(e){if(Re){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;W(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;W(e,`checked`,null),e.checked=r}}};e[he]=n,et(n),mt()}}function ra(e,t){var n=ca(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==ta)||(e.value=t??``)}function ia(e,t){var n=ca(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function aa(e,t){t?e.hasAttribute(`selected`)||e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}function W(e,t,n,r){var i=ca(e);Re&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Zi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ue]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ua(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function oa(e,t,n,r,i=!1,a=!1){if(Re&&i&&e.nodeName===Qi){var o=e;(o.type===`checkbox`?`defaultChecked`:`defaultValue`)in n||na(o)}var s=ca(e),c=s[Yi],l=!s[Xi];let u=Re&&c;u&&ze(!1);var d=t||{},f=e.nodeName===$i;for(var p in t)p in n||(n[p]=null);n.class?n.class=Fi(n.class):(r||n[qi])&&(n.class=null),n[Ji]&&(n.style??=null);var m=ua(e);if(e.nodeName===Qi&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==d.type||h===void 0&&e.hasAttribute(`type`))&&(d.type=h,W(e,`type`,h,a))}for(let i in n){let o=n[i];if(f&&i===`value`&&o==null){e.value=e.__value=``,d[i]=o;continue}if(i===`class`){U(e,e.namespaceURI===`http://www.w3.org/1999/xhtml`,o,r,t?.[qi],n[qi]),d[i]=o,d[qi]=n[qi];continue}if(i===`style`){Hi(e,o,t?.[Ji],n[Ji]),d[i]=o,d[Ji]=n[Ji];continue}var g=d[i];if(!(o===g&&!(o===void 0&&e.hasAttribute(i)))){d[i]=o;var _=i[0]+i[1];if(_!==`$$`)if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=kr(r);if(Dr(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(o!=null)continue;e.removeEventListener(r,d[n],t),d[n]=null}if(v)L(r,e,o),Hr([r]);else if(o!=null){function a(e){d[i].call(this,e)}d[n]=Br(r,e,a,t)}}else if(i===`style`)W(e,i,o);else if(i===`autofocus`)dt(e,!!o);else if(!c&&(i===`__value`||i===`value`&&o!=null))e.value=e.__value=o;else if(i===`selected`&&f)aa(e,o);else{var y=i;l||(y=Mr(y));var b=y===`defaultValue`||y===`defaultChecked`;if(o==null&&!c&&!b)if(s[i]=null,y===`value`||y===`checked`){let n=e,r=t===void 0;if(y===`value`){let e=n.defaultValue;n.removeAttribute(y),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(y),n.defaultChecked=e,n.checked=r?e:!1}}else e.removeAttribute(i);else b||m.includes(y)&&(c||typeof o!=`string`)?(e[y]=o,y in s&&(s[y]=Ae)):typeof o!=`function`&&W(e,y,o,a)}}}return u&&ze(!0),d}function sa(e,t,n=[],r=[],i=[],a,o=!1,s=!1){xt(i,n,r,n=>{var r=void 0,i={},c=e.nodeName===ea,l=!1;if(Rn(()=>{var u=t(...n.map(I)),d=oa(e,r,u,a,o,s);l&&c&&`value`in u&&Ui(e,u.value);for(let e of Object.getOwnPropertySymbols(i))u[e]||Un(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var f=u[t];t.description===`@attach`&&(!r||f!==r[t])&&(i[t]&&Un(i[t]),i[t]=zn(()=>Mi(e,()=>f))),d[t]=f}r=d}),c){var u=e;Pn(()=>{Ui(u,r.value,!0),Wi(u)})}l=!0})}function ca(e){return e[de]??={[Yi]:e.nodeName.includes(`-`),[Xi]:e.namespaceURI===je}}var la=new Map;function ua(e){var t=e.getAttribute(`is`)||e.nodeName,n=la.get(t);if(n)return n;la.set(t,n=[]);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.push(s);i=l(i)}return n}function da(e,t,n=t){var r=new WeakSet;gt(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=pa(e)?ma(a):a,n(a),Ft!==null&&r.add(Ft),await Cr(),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))}}}),(Re&&e.defaultValue!==e.value||Er(t)==null&&e.value)&&(n(pa(e)?ma(e.value):e.value),Ft!==null&&r.add(Ft)),In(()=>{var n=t();if(e===document.activeElement){var i=Ft;if(r.has(i))return}pa(e)&&n===ma(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function fa(e,t,n=t){gt(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Re&&e.defaultChecked!==e.checked||Er(t)==null)&&n(e.checked),In(()=>{e.checked=!!t()})}function pa(e){var t=e.type;return t===`number`||t===`range`}function ma(e){return e===``?null:+e}function ha(e,t){return e===t||e?.[ce]===t}function ga(e={},t,n,r){var i=Ye.r,a=ir;return Pn(()=>{var o,s;return In(()=>{o=s,s=r?.()||[],Er(()=>{ha(n(...s),e)||(t(e,...s),o&&ha(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&&ha(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var _a={get(e,t){if(!e.exclude.has(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return!e.exclude.has(t)&&t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))}};function va(e,t,n){return new Proxy({props:e,exclude:t},_a)}function ya(e,t,n,r){var i=!0,o=(n&8)!=0,s=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>s&&i?(u??=Tt(r),I(u)):(l&&(l=!1,c=s?Er(r):r),c);let f;if(o){var p=ce in e||le in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=ut(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&we(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?Tt:Ot)(()=>(v=!1,g()));o&&I(y);var b=ir;return(function(e,t){if(arguments.length>0){let n=t?I(y):i&&o?j(e):e;return A(y,n),v=!0,c!==void 0&&(c=n),e}return $n&&v||b.f&16384?y.v:I(y)})}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var ba=new Set([`$$slots`,`$$events`,`$$legacy`,`icon`,`class`]),xa=Xr(``);function G(e,t){let n=ya(t,`icon`,19,()=>[]),r=ya(t,`class`,3,``),i=va(t,ba);var a=xa();sa(a,()=>({xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:r(),"aria-hidden":`true`,focusable:`false`,...i}));{let e=(t,n=f)=>{var r=Qr();H(N(r),17,n,oi,(t,n)=>{var r=O(()=>g(I(n),3));let i=()=>I(r)[0],a=()=>I(r)[1],o=()=>I(r)[2];var s=Qr();ji(N(s),i,!0,(t,n)=>{sa(t,()=>({xmlns:`http://www.w3.org/2000/svg`,...a()}));var r=Qr(),i=N(r),s=t=>{e(t,o)},c=O(()=>Array.isArray(o()));V(i,e=>{I(c)&&e(s)}),z(n,r)}),z(t,s)}),z(t,r)};e(M(a),n),T(a)}z(e,a)}var Sa=Xr(``);function Ca(e){z(e,Sa())}function wa(){try{return typeof localStorage>`u`?null:localStorage}catch{return null}}function Ta(e,t=null){let n=wa();if(!n)return t;try{return n.getItem(e)??t}catch{return t}}function Ea(e,t){let n=wa();if(n)try{n.setItem(e,String(t))}catch{}}function Da(e){let t=Number(e);return Number.isFinite(t)?Math.min(240,Math.max(60,Math.round(t))):240}function Oa(e,t,n){return Da(Number(e)+Number(n)-Number(t))}var ka=new class{#e=k(`system`);get theme(){return I(this.#e)}set theme(e){A(this.#e,e,!0)}#t=k(0);get tick(){return I(this.#t)}set tick(e){A(this.#t,e,!0)}init(){this.theme=Ta(`gomodel_theme`,`system`),this.apply(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{this.theme===`system`&&this.tick++})}set(e){this.theme=e,Ea(`gomodel_theme`,e),this.apply(),this.tick++}toggle(){let e=[`light`,`system`,`dark`];this.set(e[(e.indexOf(this.theme)+1)%e.length])}apply(){let e=document.documentElement;this.theme===`system`?e.removeAttribute(`data-theme`):e.setAttribute(`data-theme`,this.theme)}},Aa=new class{#e=k(j(240));get width(){return I(this.#e)}set width(e){A(this.#e,e,!0)}get collapsed(){return this.width===60}init(){let e=Ta(`gomodel_sidebar_width`),t=Ta(`gomodel_sidebar_collapsed`)===`true`;this.setWidth(e??(t?60:240))}toggle(){this.setWidth(this.collapsed?240:60,!0)}setWidth(e,t=!1){this.width=Da(e),typeof document<`u`&&document.documentElement.style.setProperty(`--sidebar-width`,`${this.width}px`),t&&(Ea(`gomodel_sidebar_width`,this.width),Ea(`gomodel_sidebar_collapsed`,this.collapsed))}},ja=new class{#e=k(j([]));get stack(){return I(this.#e)}set stack(e){A(this.#e,e,!0)}#t=1;opened(){let e=this.#t++;return this.stack=[...this.stack,e],e}closed(e){this.stack=this.stack.filter(t=>t!==e)}isTop(e){return this.stack.length>0&&this.stack[this.stack.length-1]===e}get openCount(){return this.stack.length}get anyOpen(){return this.stack.length>0}},Ma=[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`}]],Na=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],Pa=[[`path`,{d:`M5 12h14`}],[`path`,{d:`m12 5 7 7-7 7`}]],Fa=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]],Ia=[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`}],[`path`,{d:`M16 10h.01`}],[`path`,{d:`M12 10h.01`}],[`path`,{d:`M8 10h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M8 18h.01`}]],La=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}],[`path`,{d:`M8 14h.01`}],[`path`,{d:`M12 14h.01`}],[`path`,{d:`M16 14h.01`}],[`path`,{d:`M8 18h.01`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M16 18h.01`}]],Ra=[[`path`,{d:`M8 2v4`}],[`path`,{d:`M16 2v4`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`}],[`path`,{d:`M3 10h18`}]],za=[[`path`,{d:`M13 17V9`}],[`path`,{d:`M18 17V5`}],[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M8 17v-3`}]],Ba=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`M18 17V9`}],[`path`,{d:`M13 17V5`}],[`path`,{d:`M8 17v-3`}]],Va=[[`path`,{d:`M20 6 9 17l-5-5`}]],Ha=[[`path`,{d:`m6 9 6 6 6-6`}]],Ua=[[`path`,{d:`m15 18-6-6 6-6`}]],Wa=[[`path`,{d:`m9 18 6-6-6-6`}]],Ga=[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`}],[`path`,{d:`m9 11 3 3L22 4`}]],Ka=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m9 12 2 2 4-4`}]],qa=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}],[`path`,{d:`M12 18V6`}]],Ja=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],Ya=[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`}]],Xa=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`}],[`path`,{d:`M21 5V8`}],[`path`,{d:`M21 12L18 17H22L19 22`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`}]],Za=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`}]],Qa=[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}],[`path`,{d:`M10 9H8`}],[`path`,{d:`M16 13H8`}],[`path`,{d:`M16 17H8`}]],$a=[[`path`,{d:`m12 14 4-4`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`}]],eo=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}],[`path`,{d:`M12 7v5l4 2`}]],to=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 16v-4`}],[`path`,{d:`M12 8h.01`}]],no=[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],ro=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],io=[[`path`,{d:`M3 5h.01`}],[`path`,{d:`M3 12h.01`}],[`path`,{d:`M3 19h.01`}],[`path`,{d:`M8 5h13`}],[`path`,{d:`M8 12h13`}],[`path`,{d:`M8 19h13`}]],ao=[[`circle`,{cx:`12`,cy:`16`,r:`1`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`}]],oo=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]],so=[[`path`,{d:`m14 10 7-7`}],[`path`,{d:`M20 10h-6V4`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M4 14h6v6`}]],co=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],lo=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],uo=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],fo=[[`path`,{d:`M12 22v-5`}],[`path`,{d:`M15 8V2`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`}],[`path`,{d:`M9 8V2`}]],po=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],mo=[[`path`,{d:`M12 2v10`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`}]],ho=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{d:`M8 16H3v5`}]],go=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],_o=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]],vo=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],yo=[[`path`,{d:`m10.852 14.772-.383.923`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`}],[`path`,{d:`m13.148 9.228.383-.923`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`}],[`path`,{d:`m14.772 10.852.923-.383`}],[`path`,{d:`m14.772 13.148.923.383`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`}],[`path`,{d:`M6 18h.01`}],[`path`,{d:`M6 6h.01`}],[`path`,{d:`m9.228 10.852-.923-.383`}],[`path`,{d:`m9.228 13.148-.923.383`}]],bo=[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`}]],xo=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]],So=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],Co=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}],[`path`,{d:`m9 12 2 2 4-4`}]],wo=[[`path`,{d:`m2 2 20 20`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`}]],To=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`}]],Eo=[[`path`,{d:`m18 14 4 4-4 4`}],[`path`,{d:`m18 2 4 4-4 4`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`}]],Do=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],Oo=[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],ko=[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`}],[`circle`,{cx:`12`,cy:`14`,r:`8`}]],Ao=[[`path`,{d:`M10 11v6`}],[`path`,{d:`M14 11v6`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]],jo=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]],Mo=[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}],[`circle`,{cx:`12`,cy:`7`,r:`4`}]],No=[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`}]],Po=[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`}],[`path`,{d:`m14 7 3 3`}],[`path`,{d:`M5 6v4`}],[`path`,{d:`M19 14v4`}],[`path`,{d:`M10 2v2`}],[`path`,{d:`M7 8H3`}],[`path`,{d:`M21 16h-4`}],[`path`,{d:`M11 3H9`}]],Fo=[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`}]],Io=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],Lo=R(``),Ro=R(`
                        `,1);function zo(e,t){E(t,!0);let n=ya(t,`compact`,3,!1),r=[{value:`light`,icon:Do,label:`Light theme`},{value:`system`,icon:co,label:`System theme`},{value:`dark`,icon:lo,label:`Dark theme`}],i=O(()=>r.find(e=>e.value===ka.theme)||r[1]),a=O(()=>`Change theme (currently `+I(i).label+`)`);var o=Ro(),s=N(o);let c;H(s,21,()=>r,e=>e.value,(e,t)=>{var n=Lo();let r;G(M(n),{get icon(){return I(t).icon},class:`theme-icon`}),T(n),F(()=>{r=U(n,1,`theme-btn svelte-1keql7b`,null,r,{active:ka.theme===I(t).value}),W(n,`aria-pressed`,ka.theme===I(t).value),W(n,`title`,I(t).label),W(n,`aria-label`,I(t).label)}),L(`click`,n,()=>ka.set(I(t).value)),z(e,n)}),T(s);var l=P(s,2);let u;G(M(l),{get icon(){return I(i).icon},class:`theme-icon`}),T(l),F(()=>{c=U(s,1,`theme-toggle svelte-1keql7b`,null,c,{"is-compact":n()}),u=U(l,1,`theme-toggle-mobile svelte-1keql7b`,null,u,{"is-compact":n()}),W(l,`title`,I(a)),W(l,`aria-label`,I(a))}),L(`click`,l,()=>ka.toggle()),z(e,o),D()}Hr([`click`]);function Bo(){return typeof window>`u`?`/`:window.GOMODEL_BASE_PATH||`/`}function Vo(e){let t=Bo();return!e||e.charAt(0)!==`/`||e.indexOf(`//`)===0||t===`/`||e===t||e.indexOf(t+`/`)===0?e:t+e}function Ho(e){let t=Bo();return t===`/`||!e?e:e===t?`/`:e.indexOf(t+`/`)===0?e.slice(t.length)||`/`:e}function Uo(){return typeof window>`u`?``:window.GOMODEL_VERSION||``}function Wo(){return typeof window>`u`?!1:window.GOMODEL_DEMO_MODE===!0}var Go=[`overview`,`usage`,`budgets`,`rate-limits`,`models`,`workflows`,`audit-logs`,`guardrails`,`mcp-servers`,`providers-config`,`auth-keys`,`settings`];function Ko(e){return e.startsWith(`/admin/static/`)?`/`+e.slice(14).replace(/^\/+/,``):e}function qo(e){let t=Ko(Ho(e)).replace(/\/$/,``).replace(`/admin/dashboard`,``).replace(/^\//,``).split(`/`),n=t[0];n===`audit`&&(n=`audit-logs`);let r=t[1]||null;return n===`settings`&&r===`guardrails`?{page:`guardrails`,sub:null}:(n=Go.includes(n)?n:`overview`,{page:n,sub:r})}var Jo=new class{#e=k(`overview`);get page(){return I(this.#e)}set page(e){A(this.#e,e,!0)}#t=k(null);get sub(){return I(this.#t)}set sub(e){A(this.#t,e,!0)}init(){let{page:e,sub:t}=qo(window.location.pathname);this.page=e,this.sub=t,window.addEventListener(`popstate`,()=>{let{page:e,sub:t}=qo(window.location.pathname);this.page=e,this.sub=t})}navigate(e,t=null){let n=t?`/`+t:``;history.pushState(null,``,Vo(`/admin/dashboard/`+e+n)),this.page=e,this.sub=t}},Yo=`gomodel_api_key`;function Xo(e){let t=String(e||``).trim();if(/^Bearer\s*$/i.test(t))return``;let n=t.match(/^Bearer\s+(.+)$/i);return n?n[1].trim():t}var K=new class{#e=k(``);get apiKey(){return I(this.#e)}set apiKey(e){A(this.#e,e,!0)}#t=k(!1);get needsAuth(){return I(this.#t)}set needsAuth(e){A(this.#t,e,!0)}#n=k(!1);get authError(){return I(this.#n)}set authError(e){A(this.#n,e,!0)}#r=k(``);get authErrorMessage(){return I(this.#r)}set authErrorMessage(e){A(this.#r,e,!0)}#i=k(!1);get dialogOpen(){return I(this.#i)}set dialogOpen(e){A(this.#i,e,!0)}#a=k(0);get generation(){return I(this.#a)}set generation(e){A(this.#a,e,!0)}#o=k(0);get refreshTick(){return I(this.#o)}set refreshTick(e){A(this.#o,e,!0)}init(){try{this.apiKey=Xo(localStorage.getItem(Yo)||``)}catch{this.apiKey=``}}hasApiKey(){return Xo(this.apiKey)!==``}save(){this.apiKey=Xo(this.apiKey);try{localStorage.setItem(Yo,this.apiKey)}catch{}}openDialog(){this.dialogOpen=!0}closeDialog(){this.dialogOpen=!1}submit(){let e=Xo(this.apiKey);return e?(this.apiKey=e,this.save(),this.generation++,this.authError=!1,this.authErrorMessage=``,this.needsAuth=!1,this.closeDialog(),this.refresh(),!0):(this.apiKey=``,this.authError=!0,this.authErrorMessage=``,this.needsAuth=!0,this.openDialog(),!1)}refresh(){this.refreshTick++}handleUnauthorized(e,t=``){return typeof e==`number`&&e{r[e.type]=e.value}),r.year+`-`+r.month+`-`+r.day}formatTimestampInTimeZone(e,t){if(e==null)return`-`;let n=new Date(e);if(Number.isNaN(n.getTime()))return`-`;let r=ss(`en-CA`,{timeZone:cs(t)?t:rs,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(n),i={};return r.forEach(e=>{i[e.type]=e.value}),i.year+`-`+i.month+`-`+i.day+` `+i.hour+`:`+i.minute+`:`+i.second}formatTimestamp(e){return this.formatTimestampInTimeZone(e,this.effectiveTimezone())}currentDateKey(e){return this.dateKeyInTimeZone(e||new Date,this.effectiveTimezone())}dateKeyToDate(e){return Qo(e)}dateToDateKey(e){return $o(e)}addDaysToDateKey(e,t){return es(e,t)}todayDate(){return this.dateKeyToDate(this.currentDateKey())}startOfMonthDate(e){let t=e instanceof Date?e:this.todayDate();return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1))}timeZoneOffsetLabel(e,t){let n=cs(e)?e:rs;try{let e=ss(`en-US`,{timeZone:n,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`,timeZoneName:`longOffset`}).formatToParts(t||new Date).find(e=>e.type===`timeZoneName`);if(!e||!e.value)return`UTC+00:00`;let r=e.value.replace(`GMT`,`UTC`);return r===`UTC`?`UTC+00:00`:r}catch{return`UTC+00:00`}}timeZoneOffsetMinutes(e,t){let n=/^UTC([+-])(\d{2}):(\d{2})$/.exec(this.timeZoneOffsetLabel(e,t));if(!n)return 0;let r=Number(n[2])*60+Number(n[3]);return n[1]===`-`?-r:r}timeZoneOptionLabel(e,t){return e+` (`+this.timeZoneOffsetLabel(e,t)+`)`}detectedTimeZoneLabel(){return this.timeZoneOptionLabel(this.detectedTimezone)}effectiveTimeZoneLabel(){return this.timeZoneOptionLabel(this.effectiveTimezone())}ensureOptions(){if(this.optionsLoaded)return;let e=new Date,t=[];try{typeof Intl.supportedValuesOf==`function`&&(t=Intl.supportedValuesOf(`timeZone`))}catch{t=[]}[rs,this.detectedTimezone,this.override].forEach(e=>{e&&t.indexOf(e)===-1&&cs(e)&&t.push(e)}),t=t.filter(e=>cs(e)),t.sort((t,n)=>{let r=this.timeZoneOffsetMinutes(t,e)-this.timeZoneOffsetMinutes(n,e);return r===0?t.localeCompare(n):r}),this.options=t.map(t=>({value:t,label:this.timeZoneOptionLabel(t,e)})),this.optionsLoaded=!0}saveOverride(){let e=wa();if(e)if(this.override&&cs(this.override))try{e.setItem(is,this.override)}catch{}else{try{e.removeItem(is)}catch{}this.override=``}this.optionsLoaded=!1,this.ensureOptions()}clearOverride(){let e=wa();if(e)try{e.removeItem(is)}catch{}this.override=``}calendarTimeZoneText(){let e=this.override?`manual override`:`auto-detected`;return`Activity grouped by `+this.effectiveTimeZoneLabel()+` (`+e+`)`}};function fs(e,t){let n=e&&typeof e==`object`&&e.error&&e.error.message;return(typeof n==`string`?n.trim():``)||t}function ps(e,t){let n=e&&e.data;if(n&&typeof n==`object`){let e=[n.message,n.error,n.error&&typeof n.error==`object`?n.error.message:null];for(let t of e)if(typeof t==`string`&&t.trim())return t.trim()}return t}function ms(){let e={"Content-Type":`application/json`},t=Xo(K.apiKey);return t&&(e.Authorization=`Bearer `+t),e[`X-GoModel-Timezone`]=ds.effectiveTimezone(),e}function hs(e,t={}){return fetch(Vo(e),{...t,headers:{...ms(),...t.headers||{}}})}async function gs(e,t,{label:n=e,parse:r=!0}={}){let i=K.generation,a=await hs(e,t);if(a.status===401)return K.handleUnauthorized(i),{ok:!1,stale:ie.trim()).filter(Boolean);return e.length>0?e:xs}cacheVisible(){if(this.flag(`CACHE_ENABLED`)!==``)return this.booleanFlag(`CACHE_ENABLED`,!1);let e=this.flag(`REDIS_URL`),t=this.flag(`SEMANTIC_CACHE_ENABLED`);return e===``&&t===``||this.booleanFlag(`REDIS_URL`,!1)||this.booleanFlag(`SEMANTIC_CACHE_ENABLED`,!1)}auditVisible(){return this.booleanFlag(`LOGGING_ENABLED`,!0)}usageVisible(){return this.booleanFlag(`USAGE_ENABLED`,!0)}budgetsVisible(){return this.booleanFlag(`BUDGETS_ENABLED`,!0)}rateLimitsVisible(){return this.booleanFlag(`RATE_LIMITS_ENABLED`,!0)}guardrailsVisible(){return this.booleanFlag(`GUARDRAILS_ENABLED`,!0)}mcpVisible(){return this.booleanFlag(`MCP_ENABLED`,!0)}liveLogsVisible(){return this.booleanFlag(`DASHBOARD_LIVE_LOGS_ENABLED`,!0)}fetch(){return this.#n||=this.#r().finally(()=>{this.#n=null}),this.#n}async ensureLoaded(){if(this.#n){await this.#n;return}this.loaded||await this.fetch()}async#r(){let e=typeof AbortController==`function`?new AbortController:null,t=e?setTimeout(()=>e.abort(),1e4):null;try{let t=await _s(`/admin/runtime/config`,{label:`dashboard config`,signal:e?e.signal:void 0});if(t.stale)return;if(!t.ok){this.config={},this.loaded=!1;return}let n=t.data,r={};for(let e of bs)n&&typeof n==`object`&&!Array.isArray(n)&&n[e]!==void 0&&n[e]!==null&&(r[e]=String(n[e]).trim());this.config=r,this.loaded=!0}catch(e){console.error(`Failed to fetch dashboard config:`,e),this.config={},this.loaded=!1}finally{t!==null&&clearTimeout(t)}}},Cs=[{page:`overview`,label:`Overview`,icon:ro},{page:`providers-config`,label:`Providers`,icon:yo},{page:`models`,label:`Models`,icon:Fa},{page:`audit-logs`,label:`Audit Logs`,icon:eo},{page:`usage`,label:`Usage`,icon:Ba},{page:`budgets`,label:`Budgets`,icon:No,visible:()=>Ss.budgetsVisible()},{page:`rate-limits`,label:`Rate Limits`,icon:$a,visible:()=>Ss.rateLimitsVisible()},{page:`auth-keys`,label:`API Keys`,icon:no},{page:`workflows`,label:`Workflows`,icon:Fo},{page:`guardrails`,label:`Guardrails (experimental)`,icon:Co,visible:()=>Ss.guardrailsVisible()},{page:`mcp-servers`,label:`MCP Servers`,icon:fo,visible:()=>Ss.mcpVisible()},{page:`settings`,label:`Settings`,icon:So}],ws=R(` `),Ts=R(`
                        `),Es=R(` `,1);function Ds(e,t){E(t,!0);let n=O(()=>Cs.filter(e=>!e.visible||e.visible())),r=k(null),i=0,a=0,o=!1;function s(e){e.button===0&&(e.preventDefault(),A(r,e.pointerId,!0),i=e.clientX,a=Aa.width,o=!1,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`sidebar-resizing`))}function c(e){e.pointerId===I(r)&&(!o&&Math.abs(e.clientX-i)<=4||(o=!0,Aa.setWidth(Oa(a,i,e.clientX))))}function l(e){I(r)===null||e.pointerId!==void 0&&e.pointerId!==I(r)||(A(r,null),document.body.classList.remove(`sidebar-resizing`),Aa.setWidth(Aa.width,!0))}function u(){if(o){o=!1;return}Aa.toggle()}function d(e){let t;if(e.key===`ArrowLeft`)t=Aa.width-12;else if(e.key===`ArrowRight`)t=Aa.width+12;else if(e.key===`Home`)t=60;else if(e.key===`End`)t=240;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),Aa.toggle();return}else return;e.preventDefault(),Aa.setWidth(t,!0)}var f=Es(),p=N(f);let m;var h=M(p),g=M(h);Ca(M(g),{}),T(g),Ue(4),T(h);var _=P(h,2);H(_,21,()=>I(n),e=>e.page,(e,t)=>{var n=ws();let r;var i=M(n);G(i,{get icon(){return I(t).icon},class:`nav-icon`});var a=P(i,2),o=M(a,!0);T(a),T(n),F(e=>{W(n,`href`,e),r=U(n,1,`nav-item svelte-1nwtzae`,null,r,{active:Jo.page===I(t).page}),W(n,`title`,I(t).label),B(o,I(t).label)},[()=>Vo(`/admin/dashboard/`+I(t).page)]),L(`click`,n,e=>{e.preventDefault(),Jo.navigate(I(t).page)}),z(e,n)}),T(_);var v=P(_,2),y=M(v);zo(y,{get compact(){return Aa.collapsed}});var b=P(y,2),x=e=>{var t=Ts(),n=M(t),r=M(n);G(r,{get icon(){return ao},class:`api-key-open-icon`});var i=P(r,2),a=M(i,!0);T(i),T(n),T(t),F(()=>{W(n,`aria-label`,K.needsAuth?`Enter API key`:`Change API key`),B(a,K.needsAuth?`Enter API key`:`Change API key`)}),L(`click`,n,()=>K.openDialog()),z(e,t)},S=O(()=>K.needsAuth||K.hasApiKey());V(b,e=>{I(S)&&e(x)}),T(v),T(p);var C=P(p,2);F(()=>{m=U(p,1,`sidebar svelte-1nwtzae`,null,m,{"sidebar-collapsed":Aa.collapsed,"sidebar-resizing":I(r)!==null}),W(C,`aria-valuemin`,60),W(C,`aria-valuemax`,240),W(C,`aria-valuenow`,Aa.width)}),L(`pointerdown`,C,s),L(`pointermove`,C,c),L(`pointerup`,C,l),Vr(`pointercancel`,C,l),Vr(`lostpointercapture`,C,l),L(`keydown`,C,d),L(`click`,C,u),z(e,f),D()}Hr([`click`,`pointerdown`,`pointermove`,`pointerup`,`keydown`]);var Os=R(``);function ks(e,t){E(t,!0);let n=ya(t,`label`,3,`Close`),r=ya(t,`class`,3,``),i=ya(t,`iconClass`,3,`table-icon-svg`),a=ya(t,`disabled`,3,!1),o=ya(t,`el`,15,null);var s=Os();G(M(s),{get icon(){return Io},get class(){return i()}}),T(s),ga(s,e=>o(e),()=>o()),F(()=>{U(s,1,Fi([`dialog-close-btn`,r()]),`svelte-11l1bb5`),W(s,`aria-label`,n()),s.disabled=a()}),L(`click`,s,function(...e){t.onclick?.apply(this,e)}),z(e,s),D()}Hr([`click`]);function As(e){return t=>{let n=n=>{t.contains(n.target)||e()},r=t=>{t.key===`Escape`&&e()};return document.addEventListener(`click`,n,!0),window.addEventListener(`keydown`,r),()=>{document.removeEventListener(`click`,n,!0),window.removeEventListener(`keydown`,r)}}}function js(e=`[data-modal-autofocus]`){return t=>{let n=t.querySelector(e);n&&typeof n.focus==`function`&&n.focus()}}var Ms=R(`
                        `,1);function Ns(e,t){E(t,!0);let n=ya(t,`open`,3,!1),r=ya(t,`variant`,3,`editor`),i=ya(t,`closeOnBackdrop`,3,!0),a=O(()=>r()===`auth`?`auth-dialog-backdrop`:`editor-modal-backdrop`),o=O(()=>r()===`auth`?`auth-dialog-shell`:`editor-modal-shell`);An(()=>{if(!n())return;let e=Er(()=>ja.opened()),r=n=>{n.key===`Escape`&&ja.isTop(e)&&t.onclose?.()};return window.addEventListener(`keydown`,r),()=>{ja.closed(e),window.removeEventListener(`keydown`,r)}});function s(e){i()&&e.target===e.currentTarget&&t.onclose?.()}var c=Qr(),l=N(c),u=e=>{var n=Ms(),r=N(n),i=P(r,2);gi(M(i),()=>t.children??f),T(i),Mi(i,js),F(()=>{U(r,1,Fi(I(a)),`svelte-17e0w4c`),U(i,1,Fi(I(o)),`svelte-17e0w4c`)}),L(`click`,i,s),z(e,n)};V(l,e=>{n()&&e(u)}),z(e,c),D()}Hr([`click`]);var Ps=R(``),Fs=R(``);function Is(e,t){E(t,!0),Ns(e,{get open(){return K.dialogOpen},variant:`auth`,onclose:()=>K.closeDialog(),children:(e,t)=>{var n=Fs(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a),T(i),ks(P(i,2),{label:`Close authentication dialog`,onclick:()=>K.closeDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var s=P(r,2),c=M(s),l=M(c);G(l,{get icon(){return ao},class:`auth-dialog-input-icon`});var u=P(l,2);na(u),T(c);var d=P(c,2),f=e=>{var t=Ps(),n=M(t,!0);T(t),F(()=>B(n,K.authErrorMessage||`Enter a valid API key to continue.`)),z(e,t)};V(d,e=>{K.authError&&e(f)});var p=P(d,4),m=M(p),h=M(m);G(h,{get icon(){return Va},class:`auth-dialog-submit-icon`});var g=P(h,2),_=M(g,!0);T(g),T(m),T(p),T(s),T(n),F(()=>{B(o,K.needsAuth?`Dashboard locked`:`Change API key`),B(_,K.needsAuth?`Unlock dashboard`:`Save API key`)}),Vr(`submit`,s,e=>{e.preventDefault(),K.submit()}),da(u,()=>K.apiKey,e=>K.apiKey=e),z(e,n)},$$slots:{default:!0}}),D()}function Ls(){return{open:!1,title:``,titleId:`typedConfirmationDialogTitle`,inputId:`typed-confirmation-input`,message:``,requiredText:``,value:``,confirmLabel:`Confirm`,icon:jo,dialogClass:``,loading:!1,onConfirm:null,onClose:null}}var Rs=new class{#e=k(j(Ls()));get state(){return I(this.#e)}set state(e){A(this.#e,e,!0)}#t=k(``);get error(){return I(this.#t)}set error(e){A(this.#t,e,!0)}open(e){this.error=``,this.state={...Ls(),open:!0,...e||{}}}close(){let e=this.state;typeof e.onClose==`function`&&e.onClose(),this.state=Ls(),this.error=``}ready(){return String(this.state.value||``).trim().toLowerCase()===String(this.state.requiredText||``).trim().toLowerCase()}inputLabel(){return`Type `+String(this.state.requiredText||``).trim()+` to confirm`}async submit(){if(!this.ready()){this.error=this.inputLabel()+`.`;return}if(typeof this.state.onConfirm==`function`){this.state.loading=!0;try{await this.state.onConfirm()}finally{this.state.loading=!1}}}},zs=R(`

                        `),Bs=R(``),Vs=R(`

                        `);function Hs(e,t){E(t,!0);let n=O(()=>Rs.state);Ns(e,{get open(){return I(n).open},variant:`auth`,onclose:()=>Rs.close(),children:(e,t)=>{var r=Vs(),i=M(r),a=M(i),o=M(a,!0);T(a),ks(P(a,2),{label:`Close confirmation dialog`,onclick:()=>Rs.close(),class:`auth-dialog-close`,iconClass:``}),T(i);var s=P(i,2),c=M(s),l=e=>{var t=zs(),r=M(t,!0);T(t),F(()=>B(r,I(n).message)),z(e,t)};V(c,e=>{I(n).message&&e(l)});var u=P(c,2),d=M(u),f=M(d,!0);T(d);var p=P(d,2);na(p),T(u);var m=P(u,2),h=e=>{var t=Bs(),n=M(t,!0);T(t),F(()=>B(n,Rs.error)),z(e,t)};V(m,e=>{Rs.error&&e(h)});var g=P(m,2),_=M(g),v=P(_,2),y=M(v);G(y,{get icon(){return I(n).icon},class:`form-action-icon`});var b=P(y,2),x=M(b,!0);T(b),T(v),T(g),T(s),T(r),F((e,t)=>{U(r,1,`auth-dialog ${I(n).dialogClass??``}`),W(r,`aria-labelledby`,I(n).titleId),W(a,`id`,I(n).titleId),B(o,I(n).title),W(d,`for`,I(n).inputId),B(f,e),W(p,`id`,I(n).inputId),v.disabled=t,B(x,I(n).confirmLabel)},[()=>Rs.inputLabel(),()=>I(n).loading||!Rs.ready()]),Vr(`submit`,s,e=>{e.preventDefault(),Rs.submit()}),da(p,()=>Rs.state.value,e=>Rs.state.value=e),L(`click`,_,()=>Rs.close()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var Us=e=>e;function Ws(e){let t=e-1;return t*t*t+1}function Gs(e){let t=typeof e==`string`&&e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);return t?[parseFloat(t[1]),t[2]||`px`]:[e,`px`]}function Ks(e,{delay:t=0,duration:n=400,easing:r=Us}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}function qs(e,{delay:t=0,duration:n=400,easing:r=Ws,x:i=0,y:a=0,opacity:o=0}={}){let s=getComputedStyle(e),c=+s.opacity,l=s.transform===`none`?``:s.transform,u=c*(1-o),[d,f]=Gs(i),[p,m]=Gs(a);return{delay:t,duration:n,easing:r,css:(e,t)=>` - transform: ${l} translate(${(1-e)*d}${f}, ${(1-e)*p}${m}); - opacity: ${c-u*t}`}}function Js(e,{delay:t=0,duration:n=400,easing:r=Ws,axis:i=`y`}={}){let a=getComputedStyle(e),o=+a.opacity,s=i===`y`?`height`:`width`,c=parseFloat(a[s]),l=i===`y`?[`top`,`bottom`]:[`left`,`right`],u=l.map(e=>`${e[0].toUpperCase()}${e.slice(1)}`),d=parseFloat(a[`padding${u[0]}`]),f=parseFloat(a[`padding${u[1]}`]),p=parseFloat(a[`margin${u[0]}`]),m=parseFloat(a[`margin${u[1]}`]),h=parseFloat(a[`border${u[0]}Width`]),g=parseFloat(a[`border${u[1]}Width`]);return{delay:t,duration:n,easing:r,css:e=>`overflow: hidden;opacity: ${Math.min(e*20,1)*o};${s}: ${e*c}px;padding-${l[0]}: ${e*d}px;padding-${l[1]}: ${e*f}px;margin-${l[0]}: ${e*p}px;margin-${l[1]}: ${e*m}px;border-${l[0]}-width: ${e*h}px;border-${l[1]}-width: ${e*g}px;min-${s}: 0`}}function Ys(e){return--e*e*(2.70158*e+1.70158)+1}function Xs(e){let t=e-1;return t*t*t+1}var Zs=5e3,Qs=8e3,q=new class{#e=k(j([]));get toasts(){return I(this.#e)}set toasts(e){A(this.#e,e,!0)}#t=0;#n=new Map;success(e){this.#r(`success`,e,Zs)}error(e){this.#r(`error`,e,Qs)}dismiss(e){let t=this.#n.get(e);t&&(clearTimeout(t),this.#n.delete(e)),this.toasts=this.toasts.filter(t=>t.id!==e)}#r(e,t,n){let r=String(t||``).trim();if(!r)return;let i=this.toasts.find(t=>t.kind===e&&t.text===r);i&&this.dismiss(i.id);let a=++this.#t;this.toasts=[...this.toasts,{id:a,kind:e,text:r}],this.#n.set(a,setTimeout(()=>this.dismiss(a),n))}},$s=R(`
                        `),ec=R(`
                        `);function tc(e,t){E(t,!0);var n=ec();H(n,21,()=>q.toasts,e=>e.id,(e,t)=>{var n=$s();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2);T(n),F(()=>{r=U(n,1,`flash-toast svelte-1i257xg`,null,r,{"flash-toast-success":I(t).kind===`success`,"flash-toast-error":I(t).kind===`error`}),W(n,`role`,I(t).kind===`error`?`alert`:`status`),W(n,`aria-live`,I(t).kind===`error`?`assertive`:`polite`),B(a,I(t).text)}),L(`click`,o,()=>q.dismiss(I(t).id)),ki(1,n,()=>qs,()=>({y:-24,duration:360,easing:Ys})),ki(2,n,()=>Ks,()=>({duration:150})),z(e,n)}),T(n),z(e,n),D()}Hr([`click`]);var nc=R(``);function rc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{z(e,nc())},a=O(()=>Wo());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}function ic(e){return String(e||``).split(`,`).map(e=>e.trim()).filter(e=>e)}function ac(e){if(e==null||e===``)return`Not captured`;if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function oc(e){return e==null||e===void 0?`-`:e.toLocaleString()}function sc(e){if(e==null)return`---`;let t=Number(e);return Number.isFinite(t)?t>0&&t<1e-4?`<$0.0001`:`$`+t.toFixed(4).replace(/(\.\d{2}\d*?)0+$/,`$1`):`---`}function cc(e){return e==null||e===void 0?`—`:`$`+e.toFixed(2)}function lc(e){return e==null||e===void 0?`—`:e<.01?`$`+e.toFixed(6):`$`+e.toFixed(4)}function uc(e){if(e==null||e===``)return`-`;let t=Number(e);if(!Number.isFinite(t))return`-`;let n=Math.abs(t),r=[{threshold:1e9,suffix:`B`},{threshold:1e6,suffix:`M`},{threshold:1e3,suffix:`K`}];for(let e=0;e=i.threshold){let n=t/i.threshold;return Math.abs(Number(n.toFixed(1)))>=1e3&&e>0&&(i=r[e-1],n=t/i.threshold),n.toFixed(1).replace(/\.0$/,``)+i.suffix}}return String(t)}function dc(e,t){let n=t==null||t===``?NaN:Number(t),r=Number.isFinite(n)?oc(n):`-`;return String(e||`Tokens`)+`: `+r}function fc(e){return e?typeof e==`string`?e:e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`):``}function pc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)}function mc(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.getUTCFullYear()+`-`+String(t.getUTCMonth()+1).padStart(2,`0`)+`-`+String(t.getUTCDate()).padStart(2,`0`)+` `+String(t.getUTCHours()).padStart(2,`0`)+`:`+String(t.getUTCMinutes()).padStart(2,`0`)+`:`+String(t.getUTCSeconds()).padStart(2,`0`)+` UTC`}function hc(e){return String(e&&e.provider||``).trim()}function gc(e){return String(e&&e.provider_name||``).trim()||hc(e)}function _c(e,t){let n=String(t||``).trim();if(!n)return`-`;let r=gc(e);return!r||n===r||n.startsWith(r+`/`)?n:r+`/`+n}function vc(e){return _c(e,e&&e.model)}function yc(e){return _c(e,e&&e.resolved_model)}function bc(e){let t=String(e&&(e.requested_model||e.model)||``).trim();if(!e)return t;let n=String(e.data&&e.data.failover&&e.data.failover.target_model||``).trim();if(n&&n!==t)return t+` ⮕ `+n;if(e.alias_used&&e.resolved_model){let n=yc(e);if(n&&n!==`-`&&n!==t)return t+` ⮕ `+n}return t}var xc=`gomodel_date_range`,Sc=1;function Cc(e){return/^[1-9]\d*$/.test(String(e??``))}var wc=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Tc({selectedPreset:e,startKey:t,endKey:n,followsToday:r}){return e&&Cc(e)?{v:Sc,mode:`preset`,days:String(e)}:e?null:ts(t)&&ts(n)?{v:Sc,mode:`custom`,start:t,end:n,follow:r===!0}:null}function Ec(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return null}return!t||typeof t!=`object`?null:t.mode===`preset`?Cc(t.days)?{mode:`preset`,days:String(t.days)}:null:t.mode===`custom`&&ts(t.start)&&ts(t.end)&&t.start<=t.end?{mode:`custom`,start:t.start,end:t.end,follow:t.follow===!0}:null}function Dc(e,t,n){let r=ns(e,t);return r<1||!ts(n)?{start:e,end:t}:{start:es(n,-(r-1)),end:n}}function Oc(e,t){if(e===t)return`Today`;let[n,r,i]=e.split(`-`);return wc[Number(r)-1]+` `+Number(i)+`, `+n}function kc({selectedPreset:e,startKey:t,endKey:n,followsToday:r,todayKey:i}){if(e)return`Last `+e+` days`;if(!ts(t)||!ts(n))return``;let a=ns(t,n);return r||n===i?a===1?`Today`:`Last `+a+` days`:a===1?`1 day`:a+` days`}function Ac({selectedPreset:e,startKey:t,endKey:n,todayKey:r}){if(e)return`Last `+e+` days`;let i=e=>Oc(e,r);return ts(t)&&ts(n)?t===n?i(t):i(t)+` – `+i(n):ts(t)?i(t)+` – ...`:`Last 30 days`}var jc=6e4,Mc=new class{#e=k(j(`30`));get days(){return I(this.#e)}set days(e){A(this.#e,e,!0)}#t=k(j(`30`));get selectedPreset(){return I(this.#t)}set selectedPreset(e){A(this.#t,e,!0)}#n=k(null);get customStartDate(){return I(this.#n)}set customStartDate(e){A(this.#n,e,!0)}#r=k(null);get customEndDate(){return I(this.#r)}set customEndDate(e){A(this.#r,e,!0)}#i=k(!1);get followsToday(){return I(this.#i)}set followsToday(e){A(this.#i,e,!0)}#a=k(`daily`);get interval(){return I(this.#a)}set interval(e){A(this.#a,e,!0)}#o=k(0);get syncTick(){return I(this.#o)}set syncTick(e){A(this.#o,e,!0)}init(){this.restore(),this.syncToToday(),typeof setInterval==`function`&&setInterval(()=>this.syncToToday(),jc)}queryStr(){return this.customStartDate&&this.customEndDate?`start_date=`+fc(this.customStartDate)+`&end_date=`+fc(this.customEndDate):`days=`+this.days}selectPreset(e){this.selectedPreset=e,this.customStartDate=null,this.customEndDate=null,this.followsToday=!1,this.days=e,this.persist()}selectStart(e){this.selectedPreset=null,this.customStartDate=e,this.customEndDate&&this.customEndDatet.category===e);return t?t.count:0}get filteredModels(){if(!this.filter)return this.models;let e=this.filter.toLowerCase();return this.models.filter(t=>(t.model?.id??``).toLowerCase().includes(e)||(t.provider_name??``).toLowerCase().includes(e)||(t.provider_type??``).toLowerCase().includes(e)||(t.selector??``).toLowerCase().includes(e)||(t.model?.owned_by??``).toLowerCase().includes(e)||(t.model?.metadata?.modes??[]).join(`,`).toLowerCase().includes(e)||(t.model?.metadata?.categories??[]).join(`,`).toLowerCase().includes(e))}},Pc=R(``);function Fc(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Pc(),n=P(M(t),2);T(t),L(`click`,n,()=>K.openDialog()),z(e,t)};V(r,e=>{K.authError&&e(i)}),z(e,n),D()}Hr([`click`]);function Ic(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null}}function Lc(){return{summary:{total_hits:0,exact_hits:0,semantic_hits:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,total_saved_cost:null},daily:[]}}var Rc=new class{#e=k(j(Ic()));get summary(){return I(this.#e)}set summary(e){A(this.#e,e,!0)}#t=k(j([]));get daily(){return I(this.#t)}set daily(e){A(this.#t,e,!0)}#n=k(j(Lc()));get cacheOverview(){return I(this.#n)}set cacheOverview(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=null;#a=null;cacheAnalyticsEnabled(){return Ss.cacheVisible()}async fetchUsage(){this.#i&&this.#i.abort();let e=new AbortController;this.#i=e,this.loading=!0;try{let t=Mc.queryStr()+`&interval=`+Mc.interval,[n,r]=await Promise.all([_s(`/admin/usage/summary?`+t,{label:`usage summary`,signal:e.signal}),_s(`/admin/usage/daily?`+t,{label:`usage daily`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.summary=Ic(),this.daily=[],this.cacheOverview=Lc();return}this.summary=n.data||Ic(),this.daily=Array.isArray(r.data)?r.data:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch usage:`,e),this.summary=Ic(),this.daily=[]}finally{this.#i===e&&(this.#i=null,this.loading=!1)}}async fetchCacheOverview(e=``){if(await Ss.ensureLoaded(),!this.cacheAnalyticsEnabled()){this.cacheOverview=Lc();return}this.#a&&this.#a.abort();let t=new AbortController;this.#a=t;try{let n=await _s(`/admin/cache/overview?`+(Mc.queryStr()+`&interval=`+Mc.interval+e),{label:`cache overview`,signal:t.signal});if(n.stale||t.signal.aborted)return;if(!n.ok){this.cacheOverview=Lc();return}let r=n.data&&typeof n.data==`object`?n.data:Lc();r.summary||=Lc().summary,Array.isArray(r.daily)||(r.daily=[]),this.cacheOverview=r}catch(e){if(ys(e))return;console.error(`Failed to fetch cache overview:`,e),this.cacheOverview=Lc()}finally{this.#a===t&&(this.#a=null)}}},zc=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Bc(e,t){let n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return zc[n.getUTCMonth()]+` `+n.getUTCFullYear()}function Vc(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth()+t,a=new Date(Date.UTC(r,i,1)),o=new Date(Date.UTC(r,i+1,0)),s=(a.getUTCDay()+6)%7,c=[],l=new Date(Date.UTC(r,i,0));for(let e=s-1;e>=0;e--){let t=l.getUTCDate()-e,a=new Date(Date.UTC(r,i-1,t));c.push({day:t,date:a,current:!1,key:`p-`+n(a)})}for(let e=1;e<=o.getUTCDate();e++){let t=new Date(Date.UTC(r,i,e));c.push({day:e,date:t,current:!0,key:`c-`+n(t)})}let u=42-c.length;for(let e=1;e<=u;e++){let t=new Date(Date.UTC(r,i+1,e));c.push({day:e,date:t,current:!1,key:`n-`+n(t)})}return c}function Hc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+t,1));return n&&r.getTime()>n.getTime()?e:r}function Uc(e,t){return e.getUTCFullYear()===t.getUTCFullYear()&&e.getUTCMonth()===t.getUTCMonth()}var Wc=R(``),Gc=R(``),Kc=R(``),qc=R(`
                        MoTuWeThFrSaSu
                        `);function Jc(e,t){E(t,!0);let n=ya(t,`offset`,3,0),r=O(()=>Vc(t.calendarMonth,n(),e=>ds.dateToDateKey(e))),i=O(()=>Uc(t.calendarMonth,ds.todayDate())),a=e=>ds.dateToDateKey(e.date),o=e=>a(e)>ds.currentDateKey(),s=e=>e.current&&a(e)===ds.currentDateKey();function c(e,t){let n=t===`start`?Mc.rangeStart():Mc.rangeEnd();return e.current&&!!n&&a(e)===ds.dateToDateKey(n)}function l(e){let t=Mc.rangeStart(),n=Mc.rangeEnd();return!e.current||!t||!n?!1:a(e)>=ds.dateToDateKey(t)&&a(e)<=ds.dateToDateKey(n)}var u=qc(),d=M(u),f=M(d);let p;var m=P(f,2),h=M(m,!0);T(m);var g=P(m,2),_=e=>{z(e,Wc())},v=e=>{var n=Gc();F(()=>n.disabled=I(i)),L(`click`,n,function(...e){t.onnext?.apply(this,e)}),z(e,n)};V(g,e=>{n()===-1?e(_):e(v,-1)}),T(d);var y=P(d,4);H(y,21,()=>I(r),e=>e.key,(e,n)=>{var r=Kc(),i=M(r,!0);T(r),F((e,t)=>{U(r,1,e,`svelte-g7ga4u`),r.disabled=t,B(i,I(n).day)},[()=>Fi([`dp-day`,{"other-month":!I(n).current,today:s(I(n)),"range-start":c(I(n),`start`),"range-end":c(I(n),`end`),"in-range":l(I(n)),disabled:o(I(n))}]),()=>o(I(n))||!I(n).current]),L(`click`,r,()=>t.onselect?.(I(n))),z(e,r)}),T(y),T(u),F(e=>{p=U(f,1,`dp-nav-btn svelte-g7ga4u`,null,p,{"dp-nav-prev-mobile":n()!==-1}),B(h,e)},[()=>Bc(t.calendarMonth,n())]),L(`click`,f,function(...e){t.onprev?.apply(this,e)}),z(e,u),D()}Hr([`click`]);var Yc=R(``),Xc=R(`
                        `),Zc=Xr(``),Qc=Xr(``),$c=R(`
                        `),el=R(`
                        `);function tl(e,t){E(t,!0);let n=[`3`,`7`,`14`,`30`,`90`],r=k(!1),i=k(`start`),a=k(j(new Date)),o=k(j({show:!1,x:0,y:0}));function s(){A(r,!I(r)),I(r)&&(Mc.syncToToday(),A(a,ds.startOfMonthDate(Mc.customEndDate||ds.todayDate()),!0),A(i,`start`))}function c(){A(r,!1),A(o,{show:!1,x:0,y:0},!0)}let l=Mc.syncTick;An(()=>{let e=Mc.syncTick;e!==l&&(l=e,t.onchange?.())});function u(e){Mc.selectPreset(e),A(i,`start`),t.onchange?.(),c()}let d=()=>A(a,Hc(I(a),-1),!0),f=()=>A(a,Hc(I(a),1,ds.startOfMonthDate(ds.todayDate())),!0);function p(e){let n=new Date(e.date);if(I(i)===`start`){Mc.selectStart(n),A(i,`end`),t.onchange?.();return}Mc.selectEnd(n),A(i,`start`),t.onchange?.(),c()}var m=el(),h=M(m),g=P(M(h),2),_=M(g,!0);T(g);var v=P(g,2);let y;T(h);var b=P(h,2),x=e=>{var t=Xc(),r=M(t);H(r,20,()=>n,e=>e,(e,t)=>{var n=Yc();let r;var i=M(n);T(n),F(()=>{r=U(n,1,`preset-btn svelte-ax7ma4`,null,r,{active:Mc.selectedPreset===t}),B(i,`Last ${t??``} days`)}),L(`click`,n,()=>u(t)),z(e,n)}),T(r);var i=P(r,2);H(i,20,()=>[-1,0],e=>e,(e,t)=>{Jc(e,{get calendarMonth(){return I(a)},get offset(){return t},onprev:d,onnext:f,onselect:p})}),T(i),T(t),L(`mousemove`,i,e=>A(o,{show:!0,x:e.clientX,y:e.clientY},!0)),Vr(`mouseleave`,i,()=>A(o,{show:!1,x:0,y:0},!0)),z(e,t)};V(b,e=>{I(r)&&e(x)});var S=P(b,2),C=e=>{var t=$c(),n=M(t),r=e=>{z(e,Zc())},a=e=>{z(e,Qc())};V(n,e=>{I(i)===`start`?e(r):e(a,-1)});var s=P(n,2),c=M(s,!0);T(s),T(t),F(()=>{Hi(t,`left:${I(o).x??``}px;top:${I(o).y??``}px`),B(c,I(i)===`end`?`Select end date`:`Select start date`)}),z(e,t)};V(S,e=>{I(o).show&&e(C)}),T(m),Mi(m,()=>I(r)?As(c):void 0),F((e,t)=>{W(h,`title`,e),B(_,t),y=U(v,0,`date-picker-chevron svelte-ax7ma4`,null,y,{open:I(r)})},[()=>Mc.dateRangeSpanLabel(),()=>Mc.dateRangeLabel()]),L(`click`,h,s),z(e,m),D()}Hr([`click`,`mousemove`]);function nl(e){return e+.5|0}var rl=(e,t,n)=>Math.max(Math.min(e,n),t);function il(e){return rl(nl(e*2.55),0,255)}function al(e){return rl(nl(e*255),0,255)}function ol(e){return rl(nl(e/2.55)/100,0,1)}function sl(e){return rl(nl(e*100),0,100)}var cl={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},ll=[...`0123456789ABCDEF`],ul=e=>ll[e&15],dl=e=>ll[(e&240)>>4]+ll[e&15],fl=e=>(e&240)>>4==(e&15),pl=e=>fl(e.r)&&fl(e.g)&&fl(e.b)&&fl(e.a);function ml(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&cl[e[1]]*17,g:255&cl[e[2]]*17,b:255&cl[e[3]]*17,a:t===5?cl[e[4]]*17:255}:(t===7||t===9)&&(n={r:cl[e[1]]<<4|cl[e[2]],g:cl[e[3]]<<4|cl[e[4]],b:cl[e[5]]<<4|cl[e[6]],a:t===9?cl[e[7]]<<4|cl[e[8]]:255})),n}var hl=(e,t)=>e<255?t(e):``;function gl(e){var t=pl(e)?ul:dl;return e?`#`+t(e.r)+t(e.g)+t(e.b)+hl(e.a,t):void 0}var _l=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function vl(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function yl(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function bl(e,t,n){let r=vl(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function xl(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=xl(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function Cl(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(al)}function wl(e,t,n){return Cl(vl,e,t,n)}function Tl(e,t,n){return Cl(bl,e,t,n)}function El(e,t,n){return Cl(yl,e,t,n)}function Dl(e){return(e%360+360)%360}function Ol(e){let t=_l.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?il(+t[5]):al(+t[5]));let i=Dl(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?Tl(i,a,o):t[1]===`hsv`?El(i,a,o):wl(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function kl(e,t){var n=Sl(e);n[0]=Dl(n[0]+t),n=wl(n),e.r=n[0],e.g=n[1],e.b=n[2]}function Al(e){if(!e)return;let t=Sl(e),n=t[0],r=sl(t[1]),i=sl(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${ol(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var jl={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},Ml={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function Nl(){let e={},t=Object.keys(Ml),n=Object.keys(jl),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var Pl;function Fl(e){Pl||(Pl=Nl(),Pl.transparent=[0,0,0,0]);let t=Pl[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var Il=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Ll(e){let t=Il.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?il(e):rl(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?il(r):rl(r,0,255)),i=255&(t[4]?il(i):rl(i,0,255)),a=255&(t[6]?il(a):rl(a,0,255)),{r,g:i,b:a,a:n}}}function Rl(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${ol(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var zl=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,Bl=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Vl(e,t,n){let r=Bl(ol(e.r)),i=Bl(ol(e.g)),a=Bl(ol(e.b));return{r:al(zl(r+n*(Bl(ol(t.r))-r))),g:al(zl(i+n*(Bl(ol(t.g))-i))),b:al(zl(a+n*(Bl(ol(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Hl(e,t,n){if(e){let r=Sl(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=wl(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Ul(e,t){return e&&Object.assign(t||{},e)}function Wl(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=al(e[3]))):(t=Ul(e,{r:0,g:0,b:0,a:1}),t.a=al(t.a)),t}function Gl(e){return e.charAt(0)===`r`?Ll(e):Ol(e)}var Kl=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Wl(t):n===`string`&&(r=ml(t)||Fl(t)||Gl(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Ul(this._rgb);return e&&(e.a=ol(e.a)),e}set rgb(e){this._rgb=Wl(e)}rgbString(){return this._valid?Rl(this._rgb):void 0}hexString(){return this._valid?gl(this._rgb):void 0}hslString(){return this._valid?Al(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Vl(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=al(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=nl(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Hl(this._rgb,2,e),this}darken(e){return Hl(this._rgb,2,-e),this}saturate(e){return Hl(this._rgb,1,e),this}desaturate(e){return Hl(this._rgb,1,-e),this}rotate(e){return kl(this._rgb,e),this}};function ql(){}var Jl=(()=>{let e=0;return()=>e++})();function Yl(e){return e==null}function Xl(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function Zl(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function Ql(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function $l(e,t){return Ql(e)?e:t}function eu(e,t){return e===void 0?t:e}var tu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,nu=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function ru(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function iu(e,t,n,r){let i,a,o;if(Xl(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function pu(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function mu(e){let t=pu(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function hu(e,t){return(fu[t]||(fu[t]=mu(t)))(e)}function gu(e){return e.charAt(0).toUpperCase()+e.slice(1)}var _u=e=>e!==void 0,vu=e=>typeof e==`function`,yu=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function bu(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var xu=Math.PI,Su=2*xu,Cu=Su+xu,wu=1/0,Tu=xu/180,Eu=xu/2,Du=xu/4,Ou=xu*2/3,ku=Math.log10,Au=Math.sign;function ju(e,t,n){return Math.abs(e-t)e-t).pop(),t}function Pu(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Fu(e){return!Pu(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Iu(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Lu(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Yu(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var Xu=(e,t,n,r)=>Yu(e,n,r?r=>{let i=e[r][t];return ie[r][t]Yu(e,n,r=>e[r][t]>=n);function Qu(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+gu(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function td(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&($u.forEach(t=>{delete e[t]}),delete e._chartjs)}function nd(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var rd=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function id(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,rd.call(window,()=>{r=!1,e.apply(t,n)}))}}function ad(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var od=e=>e===`start`?`left`:e===`end`?`right`:`center`,sd=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,cd=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function ld(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(Xu(c,u,d).lo,n?r:Xu(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!Yl(e[s.axis]));i-=Math.max(0,e)}i=Ku(i,0,r-1)}if(m){let e=Math.max(Xu(c,o.axis,f,!0).hi+1,n?0:Xu(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!Yl(e[s.axis]));e+=Math.max(0,t)}a=Ku(e,i,r)-i}else a=r-i}return{start:i,count:a}}function ud(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var dd=e=>e===0||e===1,fd=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*Su/n)),pd=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*Su/n)+1,md={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Eu)+1,easeOutSine:e=>Math.sin(e*Eu),easeInOutSine:e=>-.5*(Math.cos(xu*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>dd(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>dd(e)?e:fd(e,.075,.3),easeOutElastic:e=>dd(e)?e:pd(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return dd(e)?e:e<.5?.5*fd(e*2,t,n):.5+.5*pd(e*2-1,t,n)},easeInBack(e){return e*e*(2.70158*e-1.70158)},easeOutBack(e){return--e*e*(2.70158*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-md.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?md.easeInBounce(e*2)*.5:md.easeOutBounce(e*2-1)*.5+.5};function hd(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function gd(e){return hd(e)?e:new Kl(e)}function _d(e){return hd(e)?e:new Kl(e).saturate(.5).darken(.1).hexString()}var vd=[`x`,`y`,`borderWidth`,`radius`,`tension`],yd=[`color`,`borderColor`,`backgroundColor`];function bd(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:yd},numbers:{type:`number`,properties:vd}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function xd(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var Sd=new Map;function Cd(e,t){t||={};let n=e+JSON.stringify(t),r=Sd.get(n);return r||(r=new Intl.NumberFormat(e,t),Sd.set(n,r)),r}function wd(e,t,n){return Cd(t,n).format(e)}var Td={values(e){return Xl(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Ed(e,n)}let o=ku(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),wd(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(ku(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?Td.numeric.call(this,e,t,n):``}};function Ed(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Dd={formatters:Td};function Od(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Dd.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var kd=Object.create(null),Ad=Object.create(null);function jd(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>_d(t.backgroundColor),this.hoverBorderColor=(e,t)=>_d(t.borderColor),this.hoverColor=(e,t)=>_d(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return Md(this,e,t)}get(e){return jd(this,e)}describe(e,t){return Md(Ad,e,t)}override(e,t){return Md(kd,e,t)}route(e,t,n,r){let i=jd(this,e),a=jd(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return Zl(e)?Object.assign({},t,e):eu(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[bd,xd,Od]);function Pd(e){return!e||Yl(e.size)||Yl(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Fd(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Id(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function Vd(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Kd(e,a),c=0;c+e||0;function tf(e,t){let n={},r=Zl(t),i=r?Object.keys(t):t,a=Zl(e)?r?n=>eu(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=ef(a(e));return n}function nf(e){return tf(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function rf(e){return tf(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function af(e){let t=nf(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function of(e,t){e||={},t||=Nd.font;let n=eu(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=eu(e.style,t.style);r&&!(``+r).match(Qd)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:eu(e.family,t.family),lineHeight:$d(eu(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:eu(e.weight,t.weight),string:``};return i.string=Pd(i),i}function sf(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function lf(e,t){return Object.assign(Object.create(e),t)}function uf(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Ef(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>uf([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return hf(n,r,()=>Tf(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Df(e).includes(t)},ownKeys(e){return Df(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function df(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:ff(e,r),setContext:t=>df(e,t,n,r),override:i=>df(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return hf(e,t,()=>gf(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function ff(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:vu(n)?n:()=>n,isIndexable:vu(r)?r:()=>r}}var pf=(e,t)=>e?e+gu(t):t,mf=(e,t)=>Zl(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function hf(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function gf(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return vu(s)&&o.isScriptable(t)&&(s=_f(t,s,e,n)),Xl(s)&&s.length&&(s=vf(t,s,e,o.isIndexable)),mf(t,s)&&(s=df(s,i,a&&a[t],o)),s}function _f(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),mf(e,c)&&(c=Sf(i._scopes,i,e,c)),c}function vf(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(Zl(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=Sf(r,i,e,c);t.push(df(n,a,o&&o[e],s))}}return t}function yf(e,t,n){return vu(e)?e(t,n):e}var bf=(e,t)=>e===!0?t:typeof e==`string`?hu(t,e):void 0;function xf(e,t,n,r,i){for(let a of t){let t=bf(n,a);if(t){e.add(t);let a=yf(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function Sf(e,t,n,r){let i=t._rootScopes,a=yf(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=Cf(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=Cf(s,o,a,c,r),c===null)?!1:uf(Array.from(s),[``],i,a,()=>wf(t,n,r))}function Cf(e,t,n,r,i){for(;n;)n=xf(e,t,n,r,i);return n}function wf(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Xl(i)&&Zl(n)?n:i||{}}function Tf(e,t,n,r){let i;for(let a of t)if(i=Ef(pf(a,e),n),i!==void 0)return mf(e,i)?Sf(n,r,e,i):i}function Ef(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Df(e){let t=e._keys;return t||=e._keys=Of(e._scopes),t}function Of(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function kf(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;ste===`x`?`y`:`x`;function Nf(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=Hu(a,i),c=Hu(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Pf(e,t,n){let r=e.length,i,a,o,s,c,l=jf(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)If(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function Wf(e,t){return Uf(e).getPropertyValue(t)}var Gf=[`top`,`right`,`bottom`,`left`];function Kf(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Gf[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var qf=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Jf(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(qf(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Yf(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Uf(n),a=i.boxSizing===`border-box`,o=Kf(i,`padding`),s=Kf(i,`border`,`width`),{x:c,y:l,box:u}=Jf(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function Xf(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Vf(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Uf(a),s=Kf(o,`border`,`width`),c=Kf(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=Hf(o.maxWidth,a,`clientWidth`),i=Hf(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||wu,maxHeight:i||wu}}var Zf=e=>Math.round(e*10)/10;function Qf(e,t,n,r){let i=Uf(e),a=Kf(i,`margin`),o=Hf(i.maxWidth,e,`clientWidth`)||wu,s=Hf(i.maxHeight,e,`clientHeight`)||wu,c=Xf(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Kf(i,`border`,`width`),t=Kf(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=Zf(Math.min(l,o,c.maxWidth)),u=Zf(Math.min(u,s,c.maxHeight)),l&&!u&&(u=Zf(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=Zf(Math.floor(u*r))),{width:l,height:u}}function $f(e,t,n){let r=t||1,i=Zf(e.height*r),a=Zf(e.width*r);e.height=Zf(e.height),e.width=Zf(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var ep=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Bf()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function tp(e,t){let n=Wf(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function np(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function rp(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function ip(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=np(e,i,n),s=np(i,a,n),c=np(a,t,n);return np(np(o,s,n),np(s,c,n),n)}var ap=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},op=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function sp(e,t,n){return e?ap(t,n):op()}function cp(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function lp(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function up(e){return e===`angle`?{between:Gu,compare:Uu,normalize:Wu}:{between:Ju,compare:(e,t)=>e-t,normalize:e=>e}}function dp({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function fp(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=up(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(dp({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(dp({start:g,end:d,loop:f,count:o,style:p})),m}function mp(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function gp(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function _p(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=hp(n,i,a,r);return r===!0?vp(e,[{start:o,end:s,loop:a}],n,t):vp(e,gp(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,rd.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Ep=`transparent`,Dp={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=gd(e||Ep),i=r.valid&&gd(t||Ep);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},Op=class{constructor(e,t,n,r){let i=t[n];r=sf([e.to,r,i,e.from]);let a=sf([e.from,i,r]);this._active=!0,this._fn=e.fn||Dp[e.type||typeof a],this._easing=md[e.easing]||md.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=sf([e.to,t,r,e.from]),this._from=sf([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!Zl(i))return;let a={};for(let e of t)a[e]=i[e];(Xl(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=jp(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&Ap(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new Op(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return Tp.add(this._chart,n),!0}};function Ap(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function Up(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=zp(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function Gp(e,t){return lf(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Kp(e,t,n){return lf(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function qp(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var Jp=e=>e===`reset`||e===`none`,Yp=(e,t)=>t?e:Object.assign({},e),Xp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Fp(n,!0),values:null},Zp=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Rp(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&qp(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=eu(n.xAxisID,Wp(e,`x`)),a=t.yAxisID=eu(n.yAxisID,Wp(e,`y`)),o=t.rAxisID=eu(n.rAxisID,Wp(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&td(this._data,this),e._stacked&&qp(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(Zl(t)){let e=this._cachedMeta;this._data=Lp(t,e)}else if(n!==t){if(n){td(n,this);let e=this._cachedMeta;qp(e),e._parsed=[]}t&&Object.isExtensible(t)&&ed(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Rp(t.vScale,t),t.stack!==n.stack&&(r=!0,qp(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Up(this,t._parsed),t._stacked=Rp(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length||n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=Xl(r[e])?this.parseArrayData(n,r,e,t):Zl(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Yp(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new kp(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||Jp(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){Jp(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!Jp(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function $p(e){let t=e.iScale,n=Qp(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(_u(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function rm(e,t,n,r){return Xl(e)?nm(e,t,n,r):t[n.axis]=n.parse(e,r),t}function im(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):Au(e)}function sm(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(Yl(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[eu(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;dGu(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>Gu(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(Eu,u,f),_=m(xu,l,d),v=m(xu+Eu,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var gm=class extends Zp{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(Zl(n[e])){let{key:e=`value`}=this._parsing;i=t=>+hu(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*Su:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=wd(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=Yl(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},vm=class extends Zp{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=wd(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return kf.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(rt.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*xu,d=u,f,p=360/this.countVisibleElements();for(f=0;f{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?Ru(this.resolveDataElementOptions(e,t).angle||n):0}},ym=Object.freeze({__proto__:null,BarController:pm,BubbleController:mm,DoughnutController:gm,LineController:_m,PieController:class extends gm{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:vm,RadarController:class extends Zp{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return kf.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function bm(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var xm={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return bm()}parse(){return bm()}format(){return bm()}add(){return bm()}diff(){return bm()}startOf(){return bm()}endOf(){return bm()}}};function Sm(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?Zu:Xu;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!Yl(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!Yl(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function Cm(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var Am={evaluateInteractionItems:Cm,modes:{index(e,t,n,r){let i=Yf(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Tm(e,i,a,r,o):Om(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Yf(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Tm(e,i,a,r,o):Om(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Nm(e,t){return e.filter(e=>jm.indexOf(e.pos)===-1&&e.box.axis===t)}function Pm(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Fm(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=Pm(Mm(t,`left`),!0),i=Pm(Mm(t,`right`)),a=Pm(Mm(t,`top`),!0),o=Pm(Mm(t,`bottom`)),s=Nm(t,`x`),c=Nm(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Mm(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function zm(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Bm(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Vm(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!Zl(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&Bm(o,a.getPadding());let s=Math.max(0,t.outerWidth-zm(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-zm(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function Hm(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Um(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Wm(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);Bm(f,af(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Lm(c.concat(l),d);Wm(s.fullSize,p,d,m),Wm(c,p,d,m),Wm(l,p,d,m)&&Wm(c,p,d,m),Hm(p),Km(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,Km(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},iu(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},Jm=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},Ym=class extends Jm{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},Xm=`$chartjs`,Zm={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},Qm=e=>e===null||e===``;function $m(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[Xm]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,Qm(i)){let t=tp(e,`width`);t!==void 0&&(e.width=t)}if(Qm(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=tp(e,`height`);t!==void 0&&(e.height=t)}return e}var eh=ep?{passive:!0}:!1;function th(e,t,n){e&&e.addEventListener(t,n,eh)}function nh(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,eh)}function rh(e,t){let n=Zm[e.type]||e.type,{x:r,y:i}=Yf(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function ih(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function ah(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ih(n.addedNodes,r),t&&=!ih(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function oh(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=ih(n.removedNodes,r),t&&=!ih(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var sh=new Map,ch=0;function lh(){let e=window.devicePixelRatio;e!==ch&&(ch=e,sh.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function uh(e,t){sh.size||window.addEventListener(`resize`,lh),sh.set(e,t)}function dh(e){sh.delete(e),sh.size||window.removeEventListener(`resize`,lh)}function fh(e,t,n){let r=e.canvas,i=r&&Vf(r);if(!i)return;let a=id((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),uh(e,a),o}function ph(e,t,n){n&&n.disconnect(),t===`resize`&&dh(e)}function mh(e,t,n){let r=e.canvas,i=id(t=>{e.ctx!==null&&n(rh(t,e))},e);return th(r,t,i),i}var hh=class extends Jm{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?($m(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[Xm])return!1;let n=t[Xm].initial;[`height`,`width`].forEach(e=>{let r=n[e];Yl(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[Xm],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:ah,detach:oh,resize:fh}[t]||mh)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:ph,detach:ph,resize:ph}[t]||nh)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return Qf(e,t,n,r)}isAttached(e){let t=e&&Vf(e);return!!(t&&t.isConnected)}};function gh(e){return!Bf()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?Ym:hh}var _h=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Fu(this.x)&&Fu(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function vh(e,t){let n=e.options.ticks,r=yh(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?xh(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return Sh(t,l,a,o/i),l;let u=bh(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Ch(t,l,u,Yl(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function xh(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Eh=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,Dh=(e,t)=>Math.min(t||e,e);function Oh(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function Ah(e,t){iu(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:$l(t,$l(n,t)),max:$l(n,$l(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){ru(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=cf(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=Ku(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-jh(e.grid)-t.padding-Mh(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=zu(Math.min(Math.asin(Ku((l.highest.height+6)/o,-1,1)),Math.asin(Ku(s/c,-1,1))-Math.asin(Ku(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){ru(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){ru(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=Mh(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=jh(i)+a):(e.height=this.maxHeight,e.width=jh(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Ru(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){ru(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return qu(this._alignToPixels?Ld(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=jh(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Ld(n,e,p)},g,_,v,y,b,x,S,C,w,ee,te,ne;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,ee=h(e.top)+m,ne=e.bottom;else if(a===`bottom`)g=h(this.top),ee=e.top,ne=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,te=e.right;else if(a===`right`)g=h(this.left),w=e.left,te=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(Zl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}ee=e.top,ne=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(Zl(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,te=e.right}let re=eu(r.ticks.maxTicksLimit,l),ie=Math.max(1,Math.ceil(l/re));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:ne,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:re,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Ru(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Nd.route(a,i,c,s)})}function Vh(e){return`id`in e&&`defaults`in e}var Hh=new class{constructor(){this.controllers=new Rh(Zp,`datasets`,!0),this.elements=new Rh(_h,`elements`),this.plugins=new Rh(Object,`plugins`),this.scales=new Rh(Lh,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):iu(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=gu(e);ru(n[`before`+r],[],n),t[e](n),ru(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Wh(e){let t={},n=[],r=Object.keys(Hh.plugins.items);for(let e=0;e1&&Zh(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function eg(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function tg(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return eg(e,`x`,n[0])||eg(e,`y`,n[0])}return{}}function ng(e,t){let n=kd[e.type]||{scales:{}},r=t.scales||{},i=Jh(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!Zl(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=$h(t,o,tg(t,e),Nd.scales[o.type]),c=Xh(s,i),l=n.scales||{};a[t]=uu(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||Jh(i,t),s=(kd[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=Yh(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),uu(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];uu(t,[Nd.scales[t.type],Nd.scale])}),a}function rg(e){let t=e.options||={};t.plugins=eu(t.plugins,{}),t.scales=ng(e,t)}function ig(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function ag(e){return e||={},e.data=ig(e.data),rg(e),e}var og=new Map,sg=new Set;function cg(e,t){let n=og.get(e);return n||(n=t(),og.set(e,n),sg.add(n)),n}var lg=(e,t,n)=>{let r=hu(t,n);r!==void 0&&e.add(r)},ug=class{constructor(e){this._config=ag(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=ig(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),rg(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return cg(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return cg(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return cg(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return cg(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>lg(s,e,t))),t.forEach(e=>lg(s,r,e)),t.forEach(e=>lg(s,kd[i]||{},e)),t.forEach(e=>lg(s,Nd,e)),t.forEach(e=>lg(s,Ad,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),sg.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,kd[t]||{},Nd.datasets[t]||{},{type:t},Nd,Ad]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=dg(this._resolverCache,e,r),s=a;if(pg(a,t)){i.$shared=!1,n=vu(n)?n():n;let t=this.createResolver(e,n,o);s=df(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=dg(this._resolverCache,e,n);return Zl(t)?df(i,t,void 0,r):i}};function dg(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:uf(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var fg=e=>Zl(e)&&Object.getOwnPropertyNames(e).some(t=>vu(e[t]));function pg(e,t){let{isScriptable:n,isIndexable:r}=ff(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(vu(o)||fg(o))||a&&Xl(o))return!0}return!1}var mg=`4.5.1`,hg=[`top`,`bottom`,`left`,`right`,`chartArea`];function gg(e,t){return e===`top`||e===`bottom`||hg.indexOf(e)===-1&&t===`x`}function _g(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function vg(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),ru(n&&n.onComplete,[e],t)}function yg(e){let t=e.chart,n=t.options.animation;ru(n&&n.onProgress,[e],t)}function bg(e){return Bf()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var xg={},Sg=e=>{let t=bg(e);return Object.values(xg).filter(e=>e.canvas===t).pop()};function Cg(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function wg(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var Tg=class{static defaults=Nd;static instances=xg;static overrides=kd;static registry=Hh;static version=mg;static getChart=Sg;static register(...e){Hh.add(...e),Eg()}static unregister(...e){Hh.remove(...e),Eg()}constructor(e,t){let n=this.config=new ug(t),r=bg(e),i=Sg(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(gh(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=Jl(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Uh,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=ad(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],xg[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}Tp.listen(this,`complete`,vg),Tp.listen(this,`progress`,yg),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return Yl(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Hh}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():$f(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Rd(this.canvas,this.ctx),this}stop(){return Tp.stop(this),this}resize(e,t){Tp.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,$f(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),ru(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){iu(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=$h(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),iu(i,t=>{let i=t.options,a=i.id,o=$h(a,i),s=eu(i.type,t.dtype);(i.position===void 0||gg(i.position,o)!==gg(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(Hh.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),iu(r,(e,t)=>{e||delete n[t]}),iu(n,e=>{qm.configure(this,e,e.options),qm.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(_g(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){iu(this.scales,e=>{qm.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!yu(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)Cg(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;qm.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],iu(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=wp(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&Hd(t,r),e.controller.draw(),r&&Ud(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return Vd(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=Am.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=lf(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);_u(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),Tp.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};iu(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){iu(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},iu(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});au(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=bu(e),c=wg(e,this._lastEvent,n,s);n&&(this._lastEvent=null,ru(i.onHover,[e,o,this],this),s&&ru(i.onClick,[e,o,this],this));let l=!au(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Eg(){return iu(Tg.instances,e=>e._plugins.invalidate())}function Dg(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,Wu(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,Wu(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*Wu(r-n));if(u===`round`)e.arc(i,a,t,n-xu/2,r+xu/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+xu/2)+i,c=-o*Math.sin(n+xu/2)+a,l=o*Math.cos(r+xu/2)+i,u=o*Math.sin(r+xu/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Og(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+Eu,r-Eu),e.closePath(),e.clip()}function kg(e){return tf(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function Ag(e,t,n,r){let i=kg(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return Ku(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:Ku(i.innerStart,0,o),innerEnd:Ku(i.innerEnd,0,o)}}function jg(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Mg(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/xu)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=Ag(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,ee=_-y/C,te=f+b,ne=f+x,re=g+b/te,ie=_-x/ne;if(e.beginPath(),a){let t=(w+ee)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,ee),y>0){let t=jg(C,ee,o,s);e.arc(t.x,t.y,y,ee,_+Eu)}let n=jg(ne,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=jg(ne,ie,o,s);e.arc(t.x,t.y,x,_+Eu,ie+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=jg(te,re,o,s);e.arc(t.x,t.y,b,re+Math.PI,g-Eu)}let i=jg(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=jg(S,w,o,s);e.arc(t.x,t.y,v,g-Eu,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(ee)*d+o,i=Math.sin(ee)*d+s;e.lineTo(r,i)}e.closePath()}function Ng(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){Mg(e,t,n,r,c,i);for(let t=0;t=xu&&p===0&&u!==`miter`&&Dg(e,t,h),a||(Mg(e,t,n,r,h,i),e.stroke())}var Fg=class extends _h{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=Vu(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=eu(l,o-a),f=Gu(r,a,o)&&a!==o,p=d>=Su||f,m=Ju(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>Su?Math.floor(n/Su):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(xu,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Ng(e,this,s,i,a),Pg(e,this,s,i,a),e.restore()}};function Ig(e,t,n=t){e.lineCap=eu(n.borderCapStyle,t.borderCapStyle),e.setLineDash(eu(n.borderDash,t.borderDash)),e.lineDashOffset=eu(n.borderDashOffset,t.borderDashOffset),e.lineJoin=eu(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=eu(n.borderWidth,t.borderWidth),e.strokeStyle=eu(n.borderColor,t.borderColor)}function Lg(e,t,n){e.lineTo(n.x,n.y)}function Rg(e){return e.stepped?Wd:e.tension||e.cubicInterpolationMode===`monotone`?Gd:Lg}function zg(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function Hg(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?Vg:Bg}function Ug(e){return e.stepped?rp:e.tension||e.cubicInterpolationMode===`monotone`?ip:np}function Wg(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Ig(e,t.options),e.stroke(i)}function Gg(e,t,n,r){let{segments:i,options:a}=t,o=Hg(t);for(let s of i)Ig(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var Kg=typeof Path2D==`function`;function qg(e,t,n,r){Kg&&!t.options.segment?Wg(e,t,n,r):Gg(e,t,n,r)}var Jg=class extends _h{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;zf(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=_p(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=mp(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Ug(n),c,l;for(c=0,l=a.length;ce.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function l_(e){return s_[e%s_.length]}function u_(e){return c_[e%c_.length]}function d_(e,t){return e.borderColor=l_(t),e.backgroundColor=u_(t),++t}function f_(e,t){return e.backgroundColor=e.data.map(()=>l_(t++)),t}function p_(e,t){return e.backgroundColor=e.data.map(()=>u_(t++)),t}function m_(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof gm?t=f_(n,t):i instanceof vm?t=p_(n,t):i&&(t=d_(n,t))}}function h_(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function g_(e){return e&&(e.borderColor||e.backgroundColor)}function __(){return Nd.borderColor!==`rgba(0,0,0,0.1)`||Nd.backgroundColor!==`rgba(0,0,0,0.1)`}var v_={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=h_(r)||g_(i)||a&&h_(a)||__();if(!n.forceOverride&&o)return;let s=m_(e);r.forEach(s)}};function y_(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;dp&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function b_(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;oh&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!Yl(d)&&!Yl(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function x_(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function S_(e){e.data.datasets.forEach(e=>{x_(e)})}function C_(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=Ku(Xu(t,a.axis,o).lo,0,n-1)),i=l?Ku(Xu(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var w_={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){S_(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(sf([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=C_(s,c);if(d<=(n.threshold||4*r)){x_(t);return}Yl(a)&&(t._data=c,delete t.data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=y_(c,u,d,r,n);break;case`min-max`:f=b_(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){S_(e)}};function T_(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=O_(r,s,i);let c=E_(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=mp(t,c);for(let t of l){let r=E_(n,a[t.start],a[t.end],t.loop),s=pp(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:k_(c,r,`start`,Math.max)},end:{[n]:k_(c,r,`end`,Math.min)}})}}return o}function E_(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=Wu(i),a=Wu(a)),{property:e,start:i,end:a}}function D_(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=O_(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function O_(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function k_(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function A_(e,t){let n=[],r=!1;return Xl(e)?(r=!0,n=e):n=D_(e,t),n.length?new Jg({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function j_(e){return e&&e.fill!==!1}function M_(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!Ql(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function N_(e,t,n){let r=L_(e);if(Zl(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return Ql(i)&&Math.floor(i)===i?P_(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function P_(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function F_(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:Zl(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function I_(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:Zl(e)?e.value:t.getBaseValue(),r}function L_(e){let t=e.options,n=t.fill,r=eu(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function R_(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=z_(t,n);s.push(A_({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&J_(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;j_(n)&&J_(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!j_(r)||n.drawTime!==`beforeDatasetDraw`||J_(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},nv=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},rv=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,iv=class extends _h{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=ru(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=of(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=nv(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=av(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=sp(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=sd(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=sd(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=sd(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=sd(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;Hd(e,this),this._draw(),Ud(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Nd.color,s=sp(e.rtl,this.left,this.width),c=of(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=nv(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=eu(n.lineWidth,1);if(r.fillStyle=eu(n.fillStyle,o),r.lineCap=eu(n.lineCap,`butt`),r.lineDashOffset=eu(n.lineDashOffset,0),r.lineJoin=eu(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=eu(n.strokeStyle,o),r.setLineDash(eu(n.lineDash,[])),a.usePointStyle){let o={radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},c=s.xPlus(e,p/2),l=t+d;Bd(r,o,c,l,a.pointStyleWidth&&p)}else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=rf(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?Xd(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){Yd(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:sd(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:sd(i,this.top+y+l,this.bottom-t[0].height),line:0},cp(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=sd(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=sd(i,this.top+y+l,this.bottom-t[f.line].height));let w=s.x(S);if(g(w,C,o),S=cd(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=cv(o,e)+l}else f.y+=b}),lp(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=of(t.font),r=af(t.padding);if(!t.display)return;let i=sp(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=sd(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+sd(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=sd(o,u,u+d);a.textAlign=i.textAlign(od(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,Yd(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=of(e.font),n=af(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(Ju(e,this.left,this.right)&&Ju(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function sv(e,t,n){let r=e;return typeof t.text!=`string`&&(r=cv(t,n)),r}function cv(e,t){return t*(e.text?e.text.length:0)}function lv(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var uv={id:`legend`,_element:iv,start(e,t,n){let r=e.legend=new iv({ctx:e.ctx,options:n,chart:e});qm.configure(e,r,n),qm.addBox(e,r)},stop(e){qm.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;qm.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=af(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},dv=class extends _h{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=Xl(n.text)?n.text.length:1;this._padding=af(n.padding);let i=r*of(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=sd(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=sd(o,r,t),s=xu*-.5):(l=i-e,u=sd(o,t,r),s=xu*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=of(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);Yd(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:od(t.align),textBaseline:`middle`,translation:[i,a]})}};function fv(e,t){let n=new dv({ctx:e.ctx,options:t,chart:e});qm.configure(e,n,t),qm.addBox(e,n),e.titleBlock=n}var pv={id:`title`,_element:dv,start(e,t,n){fv(e,n)},stop(e){let t=e.titleBlock;qm.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;qm.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},mv=new WeakMap,hv={id:`subtitle`,start(e,t,n){let r=new dv({ctx:e.ctx,options:n,chart:e});qm.configure(e,r,n),qm.addBox(e,r),mv.set(e,r)},stop(e){qm.removeBox(e,mv.get(e)),mv.delete(e)},beforeUpdate(e,t,n){let r=mv.get(e);qm.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`normal`},fullSize:!0,padding:0,position:`top`,text:``,weight:1500},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},gv={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` -`):e}function yv(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function bv(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=of(t.bodyFont),l=of(t.titleFont),u=of(t.footerFont),d=a.length,f=i.length,p=r.length,m=af(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,iu(e.title,y),n.font=c.string,iu(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,iu(r,e=>{iu(e.before,y),iu(e.lines,y),iu(e.after,y)}),v=0,n.font=u.string,iu(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function xv(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function Sv(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function Cv(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),Sv(l,e,t,n)&&(l=`center`),l}function wv(e,t,n){let r=n.yAlign||t.yAlign||xv(e,n);return{xAlign:n.xAlign||t.xAlign||Cv(e,t,n,r),yAlign:r}}function Tv(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Ev(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function Dv(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=rf(o),m=Tv(t,s),h=Ev(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:Ku(m,0,r.width-t.width),y:Ku(h,0,r.height-t.height)}}function Ov(e,t,n){let r=af(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function kv(e){return _v([],vv(e))}function Av(e,t,n){return lf(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function jv(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var Mv={beforeTitle:ql,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=jv(n,e);_v(t.before,vv(Nv(i,`beforeLabel`,this,e))),_v(t.lines,Nv(i,`label`,this,e)),_v(t.after,vv(Nv(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return kv(Nv(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Nv(n,`beforeFooter`,this,e),i=Nv(n,`footer`,this,e),a=Nv(n,`afterFooter`,this,e),o=[];return o=_v(o,vv(r)),o=_v(o,vv(i)),o=_v(o,vv(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),iu(o,t=>{let n=jv(e.callbacks,t);r.push(Nv(n,`labelColor`,this,t)),i.push(Nv(n,`labelPointStyle`,this,t)),a.push(Nv(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=gv[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=bv(this,n),o=Object.assign({},e,t),s=wv(this.chart,n,o),c=Dv(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=rf(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=sp(n.rtl,this.x,this.width);for(e.x=Ov(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=of(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,Xd(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),Xd(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=of(n.bodyFont),d=u.lineHeight,f=0,p=sp(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=Ov(this,h,n),t.fillStyle=n.bodyColor,iu(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=gv[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=bv(this,e),o=Object.assign({},n,this._size),s=wv(t,e,o),c=Dv(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=af(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),cp(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),lp(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!au(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!au(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=gv[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Fv=Object.freeze({__proto__:null,Colors:v_,Decimation:w_,Filler:tv,Legend:uv,SubTitle:hv,Title:pv,Tooltip:{id:`tooltip`,_element:Pv,positioners:gv,afterInit(e,t,n){n&&(e.tooltip=new Pv({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:Mv},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Iv=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Lv(e,t,n,r){let i=e.indexOf(t);return i===-1?Iv(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Rv=(e,t)=>e===null?null:Ku(Math.round(e),0,t);function zv(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function Vv(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!Yl(a),_=!Yl(o),v=!Yl(c),y=(h-m)/(u+1),b=Mu((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=Mu(w*b/p/f)*f),Yl(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Iu((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=ju(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let ee=Math.max(Bu(b),Bu(S));x=10**(Yl(s)?ee:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let te=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&ju(n[n.length-1].value,o,Hv(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Hv(e,t,{horizontal:n,minRotation:r}){let i=Ru(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Uv=class extends Lh{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return Yl(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=Au(r),t=Au(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=Vv({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Lu(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return wd(e,this.chart.options.locale,this.options.ticks.format)}},Wv=class extends Uv{static id=`linear`;static defaults={ticks:{callback:Dd.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Ql(e)?e:0,this.max=Ql(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Ru(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Gv=e=>Math.floor(ku(e)),Kv=(e,t)=>10**(Gv(e)+t);function qv(e){return e/10**Gv(e)==1}function Jv(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Yv(e,t){let n=Gv(t-e);for(;Jv(e,t,n)>10;)n++;for(;Jv(e,t,n)<10;)n--;return Math.min(n,Gv(e))}function Xv(e,{min:t,max:n}){t=$l(e.min,t);let r=[],i=Gv(t),a=Yv(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=$l(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=$l(e.max,f);return r.push({value:p,major:qv(p),significand:d}),r}var Zv=class extends Lh{static id=`logarithmic`;static defaults={ticks:{callback:Dd.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Uv.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return Ql(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Ql(e)?Math.max(0,e):null,this.max=Ql(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Ql(this._userMin)&&(this.min=e===Kv(this.min,0)?Kv(this.min,-1):Kv(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Kv(n,-1)),a(Kv(r,1)))),n<=0&&i(Kv(r,-1)),r<=0&&a(Kv(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Xv({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Lu(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:wd(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=ku(e),this._valueRange=ku(this.max)-ku(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(ku(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function Qv(e){let t=e.ticks;if(t.display&&e.display){let e=af(t.backdropPadding);return eu(t.font&&t.font.size,Nd.font.size)+e.height}return 0}function $v(e,t,n){return n=Xl(n)?n:[n],{w:Id(e,t.string,n),h:n.length*t.lineHeight}}function ey(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function ty(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?xu/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function ry(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(zu(Wu(c.angle+Eu))),u=cy(c.y,s.h,l),d=oy(l),f=sy(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function iy(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(Vd({x:n,y:r},t)||Vd({x:n,y:a},t)||Vd({x:i,y:r},t)||Vd({x:i,y:a},t))}function ay(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Qv(a)/2,additionalAngle:o?xu/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function ly(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!Yl(s)){let n=rf(t.borderRadius),c=af(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),Xd(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function uy(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));ly(n,a,t);let o=of(a.font),{x:s,y:c,textAlign:l}=t;Yd(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function dy(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,Su);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=ru(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?ty(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=Su/(this._pointLabels.length||1),n=this.options.startAngle||0;return Wu(e*t+Ru(n))}getDistanceFromCenterForValue(e){if(Yl(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(Yl(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);fy(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=of(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=af(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}Yd(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},hy={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},gy=Object.keys(hy);function _y(e,t){return e-t}function vy(e,t){if(Yl(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),Ql(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Fu(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function yy(e,t,n,r){let i=gy.length;for(let a=gy.indexOf(e);a=gy.indexOf(n);a--){let n=gy[a];if(hy[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return gy[n?gy.indexOf(n):0]}function xy(e){for(let t=gy.indexOf(e)+1,n=gy.length;t=t?n[r]:n[i];e[a]=!0}}function Cy(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function wy(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=Ku(t,0,a),n=Ku(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||yy(i.minUnit,t,n,this._getLabelCapacity(t)),o=eu(r.ticks.stepSize,1),s=a===`week`&&i.isoWeekday,c=Fu(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return ru(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=Xu(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=Xu(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var Dy=class extends Ty{static id=`timeseries`;static defaults=Ty.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=Ey(t,this.min),this._tableRange=Ey(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(Ey(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return Ey(this._table,n*this._tableRange+this._minPos,!0)}},Oy=[ym,o_,Fv,Object.freeze({__proto__:null,CategoryScale:Bv,LinearScale:Wv,LogarithmicScale:Zv,RadialLinearScale:my,TimeScale:Ty,TimeSeriesScale:Dy})];Tg.register(...Oy);var ky=Tg,Ay=R(``);function jy(e,t){E(t,!0);let n=ya(t,`class`,3,``),r=ya(t,`ariaLabel`,3,``);function i(e){if(ka.tick,typeof t.build!=`function`)return;let n=t.build();if(!n)return;let r=new ky(e.getContext(`2d`),n);return()=>r.destroy()}var a=Ay();Mi(a,()=>i),F(()=>{U(a,1,Fi(n())),W(a,`aria-label`,r())}),z(e,a),D()}var My=R(``),Ny=R(`
                        `);function Py(e,t){E(t,!0);let n=ya(t,`options`,19,()=>[]),r=ya(t,`ariaLabel`,3,``),i=ya(t,`class`,3,``);var a=Ny();H(a,21,n,e=>e.value,(e,n)=>{var r=My();let i;var a=M(r,!0);T(r),F(()=>{i=U(r,1,`segmented-btn svelte-92fh5i`,null,i,{active:t.value===I(n).value}),W(r,`aria-pressed`,t.value===I(n).value),B(a,I(n).label)}),L(`click`,r,()=>t.onchange?.(I(n).value)),z(e,r)}),T(a),F(()=>{U(a,1,Fi([`segmented-control`,i()]),`svelte-92fh5i`),W(a,`aria-label`,r())}),z(e,a),D()}Hr([`click`]);function Fy(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Iy(){return{grid:Fy(`--chart-grid`),text:Fy(`--chart-text`),dayMarker:Fy(`--chart-day-marker`),tooltipBg:Fy(`--chart-tooltip-bg`),tooltipBorder:Fy(`--chart-tooltip-border`),tooltipText:Fy(`--chart-tooltip-text`)}}function Ly(){return{size:11,family:`'SF Mono', Menlo, Consolas, monospace`}}function Ry(e,t){return{backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,borderWidth:1,titleColor:e.tooltipText,bodyColor:e.tooltipText,callbacks:t}}function zy(e){if(typeof document>`u`||!document.body)return e;let t=document.createElement(`span`);t.style.display=`none`,t.style.color=e,document.body.appendChild(t);let n=getComputedStyle(t).color;return document.body.removeChild(t),n||e}var By=[`#c2845a`,`#7a9e7e`,`#d4a574`,`#b8a98e`,`#8b9e6b`,`#7d8a97`,`#c47a5a`,`#6b8e6b`,`#a09486`,`#9b7ea4`,`#c49a6c`];function Vy(){return[...By]}function Hy(e){let t=5381,n=String(e||``);for(let e=0;euc(e)}}var Jy={seconds:{apiName:`second`,windowLabel:`Last 60 seconds`,refreshMs:2e3},minutes:{apiName:`minute`,windowLabel:`Last 60 minutes`,refreshMs:5e3},hours:{apiName:`hour`,windowLabel:`Last 24 hours`,refreshMs:2e4},days:{apiName:`day`,windowLabel:`Last 30 days`,refreshMs:6e4}},Yy=[{value:`seconds`,label:`Seconds`},{value:`minutes`,label:`Minutes`},{value:`hours`,label:`Hours`},{value:`days`,label:`Days`}];function Xy(){return{input:0,output:0,prompt:0,local:0}}function Zy(e){return String(e).padStart(2,`0`)}function Qy(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function $y(e,t){if(!Number.isFinite(t))return``;let n=new Date(t);switch(e){case`seconds`:return Zy(n.getHours())+`:`+Zy(n.getMinutes())+`:`+Zy(n.getSeconds());case`minutes`:return Zy(n.getHours())+`:`+Zy(n.getMinutes());case`hours`:return Zy(n.getHours())+`:00`;default:return Zy(n.getMonth()+1)+`-`+Zy(n.getDate())}}function eb(e,t){let n=[],r=[],i={input:[],output:[],prompt:[],local:[]},a=Xy();for(let o of e||[]){let e=Date.parse(o&&o.start),s=Qy(o&&o.input_tokens),c=Qy(o&&o.output_tokens),l=Qy(o&&o.prompt_cached_tokens),u=Qy(o&&o.locally_cached_tokens);n.push($y(t,e)),r.push(Number.isFinite(e)?e:null),i.input.push(s),i.output.push(c),i.prompt.push(l),i.local.push(u),a.input+=s,a.output+=c,a.prompt+=l,a.local+=u}return{labels:n,stamps:r,cols:i,totals:a}}function tb(e){let t=e||Xy();return t.input+t.output+t.prompt+t.local>0}function nb(e,t){return uc(Math.max(0,Math.round(e&&e[t]||0)))}function rb(e){return(Jy[e]||Jy.minutes).windowLabel}function ib(e,t){return`Live token throughput, `+rb(t).toLowerCase()+`. Input `+nb(e,`input`)+`, output `+nb(e,`output`)+`, prompt cached `+nb(e,`prompt`)+`, locally cached `+nb(e,`local`)+` tokens.`}function ab(e,t,n,r){let i=e=>uc(Math.max(0,Math.round(e))),a=n.stamps,o=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderWidth:0,borderRadius:0,categoryPercentage:1,barPercentage:1,stack:`tokens`});return{type:`bar`,plugins:[{id:`liveTokensDayMarks`,afterDatasetsDraw:t=>{if(r===`days`)return;let n=t.getDatasetMeta(0),i=t.chartArea;if(!n||!n.data||!i)return;let o=t.ctx;o.save(),o.font=`10px 'SF Mono', Menlo, Consolas, monospace`;let s=null;for(let t=0;t{if(!e.length)return``;let t=a[e[0].dataIndex];if(!t)return e[0].label;let n=new Date(t);return r===`days`?n.toLocaleDateString():n.toLocaleString()},label:e=>e.dataset.label+`: `+i(e.parsed.y),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+i(t)}})}}}}var ob=900,sb=new class{#e=k(`minutes`);get granularity(){return I(this.#e)}set granularity(e){A(this.#e,e,!0)}#t=k(j([]));get buckets(){return I(this.#t)}set buckets(e){A(this.#t,e,!0)}#n=k(!1);get active(){return I(this.#n)}set active(e){A(this.#n,e,!0)}#r=null;#i=null;#a=null;#o=0;#s=null;#c=!1;start(){this.stop(),this.active=!0,this.fetch(),this.#l(),this.#u()}stop(){this.active=!1,this.#r&&=(clearInterval(this.#r),null),this.#i&&=(clearTimeout(this.#i),null),this.#a&&=(clearTimeout(this.#a),null),this.#o=0,this.#s&&=(this.#s.abort(),null),this.buckets=[]}setGranularity(e){!Jy[e]||e===this.granularity||(this.granularity=e,this.buckets=[],this.#l(),this.fetch())}#l(){this.#r&&=(clearInterval(this.#r),null);let e=Jy[this.granularity]||Jy.minutes;this.#r=setInterval(()=>{this.active&&this.fetch()},e.refreshMs)}noteUsageEvent(e){!this.active||e!==`usage.flushed`||(this.#i||=setTimeout(()=>{this.#i=null,this.fetch()},ob))}async fetch(){if(!this.active||this.#c)return;this.#c=!0;let e=this.granularity;try{let t=await _s(`/admin/usage/throughput?granularity=`+(Jy[e]||Jy.minutes).apiName,{label:`token throughput`});if(t.stale||!t.ok||this.granularity!==e)return;this.buckets=t.data&&Array.isArray(t.data.buckets)?t.data.buckets:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch token throughput:`,e)}finally{this.#c=!1,this.active&&this.granularity!==e&&this.fetch()}}async#u(){await Ss.ensureLoaded(),this.active&&Ss.liveLogsVisible()&&(typeof ReadableStream>`u`||(this.#s&&this.#s.abort(),this.#s=new AbortController,this.#d(this.#s)))}async#d(e){try{let t=await hs(`/admin/live/logs?types=usage`,{signal:e.signal});if(!t.ok||!t.body||typeof t.body.getReader!=`function`){this.#p();return}this.#o=0,await Wy(t.body.getReader(),e=>this.#f(e)),this.#p()}catch(e){if(ys(e))return;console.error(`Live usage stream failed:`,e),this.#p()}}#f(e){if(!e||typeof e!=`object`)return;let t=String(e.type||``).trim();t.indexOf(`usage.`)===0&&this.noteUsageEvent(t)}#p(){if(!this.active||this.#a)return;let{attempt:e,delay:t}=Ky(this.#o);this.#o=e,this.#a=setTimeout(()=>{this.#a=null,this.#u()},t)}},cb=R(`
                        `),lb=R(`
                        Waiting for live requests…
                        `),ub=R(`

                        Live Token Throughput

                        `);function db(e,t){E(t,!0);let n=O(()=>eb(sb.buckets,sb.granularity)),r=O(()=>I(n).totals);function i(){return{input:zy(`var(--token-input)`),output:zy(`var(--token-output)`),prompt:zy(`var(--token-prompt)`),local:zy(`var(--token-local)`)}}let a=[{metric:`input`,label:`Input Tokens`,colorVar:`--token-input`},{metric:`output`,label:`Output Tokens`,colorVar:`--token-output`},{metric:`prompt`,label:`Prompt (Input) Cached`,colorVar:`--token-prompt`},{metric:`local`,label:`Locally Cached`,colorVar:`--token-local`}];var o=ub(),s=M(o),c=M(s),l=P(M(c),2),u=M(l);let d;var f=P(u,2),p=M(f,!0);T(f),T(l),T(c),Py(P(c,2),{ariaLabel:`Live token throughput granularity`,get options(){return Yy},get value(){return sb.granularity},onchange:e=>sb.setGranularity(e)}),T(s);var m=P(s,2);H(m,21,()=>a,e=>e.metric,(e,t)=>{var n=cb(),i=M(n),a=P(i,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{Hi(i,`background: var(${I(t).colorVar??``})`),B(o,I(t).label),B(c,e)},[()=>nb(I(r),I(t).metric)]),z(e,n)}),T(m);var h=P(m,2),g=M(h);{let e=O(()=>ib(I(r),sb.granularity));jy(g,{get ariaLabel(){return I(e)},build:()=>ab(Iy(),i(),I(n),sb.granularity)})}var _=P(g,2),v=e=>{z(e,lb())},y=O(()=>!tb(I(r)));V(_,e=>{I(y)&&e(v)}),T(h),T(o),F(e=>{d=U(u,1,`live-dot`,null,d,{"is-streaming":sb.active}),B(p,e)},[()=>rb(sb.granularity)]),z(e,o),D()}function fb(e){let t=e||{};if(t.total_tokens!==null&&t.total_tokens!==void 0){let e=Number(t.total_tokens);if(Number.isFinite(e))return e}let n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function pb(e,t){if(!t)return 0;let n=e&&e.summary?e.summary:{},r=Number(n.total_hits||0);return Number.isFinite(r)&&r>0?r:0}function mb(e,t,n){let r=Number(e&&e.total_requests||0);return(Number.isFinite(r)?r:0)+pb(t,n)}function hb(e,t,n){let r=pb(t,n);return r<=0?``:oc(mb(e,t,n)-r)+` to providers + `+oc(r)+` from cache`}function gb(e){let t=e&&e.summary?e.summary:{},n=Number(t.total_input_tokens||0),r=Number(t.total_output_tokens||0);return(Number.isFinite(n)?n:0)+(Number.isFinite(r)?r:0)}function _b(e,t,n){let r=e=>{let t=Number(e||0);return Number.isFinite(t)&&t>0?t:0},i=e||{},a=r(i.uncached_input_tokens),o=r(i.cached_input_tokens),s=r(i.cache_write_input_tokens),c=t&&t.summary?t.summary:{},l=n?r(c.total_input_tokens):0;return[{key:`uncached`,label:`Regular`,tokens:a+s,colorVar:`--cache-meter-uncached`,note:s>0?`Includes `+oc(s)+` cache-write tokens`:``},{key:`prompt`,label:`Prompt cached`,tokens:o,colorVar:`--cache-meter-prompt`,note:`Provider prompt-cache reads`},{key:`local`,label:`Locally cached`,tokens:l,colorVar:`--cache-meter-local`,note:`Served from GoModel response cache`}]}function vb(e,t,n){return _b(e,t,n).reduce((e,t)=>e+t.tokens,0)}function yb(e,t,n){return vb(e,t,n)>0}function bb(e,t,n){let r=_b(e,t,n),i=r.reduce((e,t)=>e+t.tokens,0);if(i<=0)return r.map(e=>Object.assign({},e,{pct:0}));let a=r.map(e=>{let t=e.tokens/i*100,n=Math.floor(t);return Object.assign({},e,{pct:n,remainder:t-n})}),o=100-a.reduce((e,t)=>e+t.pct,0);return a.map((e,t)=>({index:t,remainder:e.remainder,tokens:e.tokens})).filter(e=>e.tokens>0).sort((e,t)=>t.remainder-e.remainder).forEach(e=>{o>0&&(a[e.index].pct+=1,--o)}),a}function xb(e,t,n){return bb(e,t,n).filter(e=>e.tokens>0)}function Sb(e){let t=[e.label+`: `+oc(e.tokens)+` input tokens (`+e.pct+`%)`];return e.note&&t.push(e.note),t.join(` -`)}function Cb(e){let t=(e||[]).map(e=>e.label+` `+e.pct+`%`);return`Cache breakdown of input tokens — `+(t.length?t.join(`, `):`no data`)}function wb(e){return e.getUTCFullYear()+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`)}function Tb(e,t,n,r){if(t!==`daily`||!n||!r)return e;let i={};(e||[]).forEach(e=>{i[e.date]=e});let a=[];for(let e=new Date(n);e<=r;e.setUTCDate(e.getUTCDate()+1)){let t=wb(e);a.push(i[t]||{date:t,input_tokens:0,output_tokens:0,total_tokens:0,requests:0,input_cost:null,output_cost:null,total_cost:null})}return a}function Eb(e,t){let n=e=>Number(e)||0,r=e.map(e=>e.date),i=e.map(e=>n(e.uncached_input_tokens)+n(e.cache_write_input_tokens)+n(e.cached_input_tokens)>0?n(e.uncached_input_tokens)+n(e.cache_write_input_tokens):n(e.input_tokens)),a=e.map(e=>n(e.output_tokens)),o=e.map(e=>n(e.cached_input_tokens)),s={};return(t||[]).forEach(e=>{s[e.date]=e}),{labels:r,inputPaid:i,output:a,prompt:o,local:r.map(e=>{let t=s[e];return t?n(t.input_tokens)+n(t.output_tokens):0})}}function Db(e){let t=e||{},n=Math.max(0,Number(t.uncached_input_tokens)||0),r=Math.max(0,Number(t.cached_input_tokens)||0),i=Math.max(0,Number(t.cache_write_input_tokens)||0),a=n+r+i;return a>0?r/a*100:0}function Ob(e){let t=e||{};return(Number(t.uncached_input_tokens)||0)+(Number(t.cached_input_tokens)||0)+(Number(t.cache_write_input_tokens)||0)>0}function kb(e){return Ob(e)?Math.round(Db(e))+`%`:`—`}function Ab(e,t,n={}){let r=!!n.cacheEnabled,i=n.resolve||(e=>e),a=(e,t)=>i(`color-mix(in srgb, `+e+` `+t+`%, transparent)`),o=(e,t,n,r)=>Object.assign({label:e,data:t,borderColor:n,backgroundColor:n,fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4},r||{}),s=[o(`Input Tokens`,t.inputPaid,i(`var(--token-input)`),{fill:`origin`}),o(`Output Tokens`,t.output,i(`var(--token-output)`),{fill:`-1`}),o(`Prompt (Input) Cached`,t.prompt,i(`var(--token-prompt)`),{fill:`-1`,borderDash:[6,4]})];return r&&s.push(o(`Locally Cached`,t.local,a(`var(--info)`,35),{fill:`-1`,borderDash:[2,3]})),{type:`line`,data:{labels:t.labels,datasets:s},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:10}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:qy(e)}}}}}function jb(e,t,n){let r=Math.max(0,Math.min(100,e));return{type:`doughnut`,data:{datasets:[{data:[r,100-r],backgroundColor:[t,n],borderWidth:0,spacing:0}]},options:{rotation:-90,circumference:180,cutout:`84%`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:1},events:[],plugins:{legend:{display:!1},tooltip:{enabled:!1}}}}}var Mb=`gomodel_provider_status_details_expanded`,Nb=`gomodel_provider_card_expanded_overrides`,Pb=3e3,Fb=`https://gomodel.enterpilot.io/docs/providers/`,Ib={anthropic:`anthropic`,azure:`azure`,bailian:`bailian`,bedrock:`bedrock`,"bedrock-mantle":`bedrock-mantle`,cohere:`cohere`,deepseek:`deepseek`,gemini:`gemini`,opencode_go:`opencode-go`,oracle:`oracle`,vertex:`vertex`,vllm:`vllm`,xiaomi:`xiaomi`};function Lb(){return{summary:{total:0,healthy:0,degraded:0,unhealthy:0,overall_status:`degraded`},providers:[]}}function Rb(e){let t={detailsExpanded:!1,cardOverrides:{}};try{if(e){let n=e.getItem(Mb);n===`true`||n===`false`?t.detailsExpanded=n===`true`:e.setItem(Mb,`false`);let r=JSON.parse(e.getItem(Nb)||`{}`);r&&typeof r==`object`&&!Array.isArray(r)&&(t.cardOverrides=r)}}catch{}return t}function zb(e,t){if(e)try{e.setItem(Mb,t?`true`:`false`)}catch{}}function Bb(e,t){if(e)try{e.setItem(Nb,JSON.stringify(t))}catch{}}function Vb(e,t,n){let r=n&&n.name?String(n.name):``;return r&&Object.prototype.hasOwnProperty.call(e,r)?e[r]===!0:t}function Hb(e){return`is-`+(String(e&&e.overall_status||`degraded`).trim()||`degraded`)}function Ub(e){return`is-`+(String(e||`degraded`).trim()||`degraded`)}function Wb(e){let t=e||{};return String(t.healthy||0)+`/`+String(t.total||0)}function Gb(e){let t=e||{},n=Number(t.total||0),r=Number(t.healthy||0);return n>0&&rString(e&&e.status_label||``).trim().toLowerCase()===`starting`)}function Jb(e){if(!e||!e.runtime)return``;let t=e.runtime.last_model_fetch_at||``,n=e.runtime.last_availability_check_at||``;return t?n&&Date.parse(n)>Date.parse(t)?n:t:n}function Yb(e,t){let n=Jb(e);if(!n||typeof t!=`function`)return`-`;let r=t(n);if(!r||r===`-`)return`-`;let i=String(r).split(` `);return i.length>1?i.slice(1).join(` `):r}function Xb(e,t){let n=Jb(e);return n?typeof t==`function`?t(n):String(n):``}function Zb(e){if(!e)return``;let t=String(e.name||``).trim(),n=String(e.type||e.config&&e.config.type||``).trim();return!n||n===t?``:n}function Qb(e){let t=String(e&&(e.type||e.config&&e.config.type)||``).trim().toLowerCase(),n=t?Ib[t]:``;return n?Fb+n+`?utm_source=gomodel_dashboard`:``}function $b(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.retry:null;return t?String(t.max_retries)+` retries, `+t.initial_backoff+` initial, `+t.max_backoff+` max, factor `+t.backoff_factor+`, jitter `+t.jitter_factor:`-`}function ex(e){let t=e&&e.config&&e.config.resilience?e.config.resilience.circuit_breaker:null;return t?String(t.failure_threshold)+` fail, `+String(t.success_threshold)+` success, `+t.timeout+` timeout`:`-`}function tx(e){let t=e&&e.config&&Array.isArray(e.config.models)?e.config.models.filter(Boolean):[];return t.length===0?`Automatic`:t.join(`, `)}function nx(e){if(!e)return``;let t=[];return e.status_reason&&t.push(String(e.status_reason)),e.last_error&&t.push(`Last error: `+String(e.last_error)),t.join(` - -`)}function rx(e){let t=e&&e.request_health;return t&&typeof t==`object`?t:null}function ix(e){let t=rx(e);return t?String(t.circuit_state||``).trim():``}function ax(e){let t=ix(e);return t?t.charAt(0).toUpperCase()+t.slice(1):``}function ox(e){let t=ix(e);return t===`open`?`is-unhealthy`:t===`half-open`?`is-degraded`:`is-healthy`}function sx(e){let t=rx(e);if(!t)return``;let n=Number(t.requests||0),r=Number(t.errors||0),i=Math.round(Number(t.window_seconds||0)/60),a=i>0?`last `+i+` min`:`recent`;return String(n)+` request`+(n===1?``:`s`)+` · `+String(r)+` error`+(r===1?``:`s`)+` (`+a+`)`}function cx(e){let t=rx(e);return t&&Array.isArray(t.models)?t.models:[]}function lx(e){return e?String(Number(e.errors||0))+`/`+String(Number(e.requests||0))+` failed`:``}function ux(e){let t=e&&e.last_error;return!t||!t.message?``:(t.status_code?`HTTP `+String(t.status_code)+`: `:``)+t.message}function dx(){return{name:``,slug:``,url:``,transport:`http`,description:``,enabled:!0,headers:[],allowed_tools:``,disallowed_tools:``,user_paths:``,tool_timeout_seconds:``}}function fx(){return{server:``,status:``,instructions:``,tools:[],prompts:[],resources:[],templates:[]}}function px(e){return String(e&&(e.slug||e.name)||``).trim()}function mx(e){return String(e&&e.status||``).trim()||`connecting`}function hx(e){switch(mx(e)){case`connected`:return`status-success`;case`degraded`:return String(e&&e.last_error||``).trim()?`status-error`:`status-warning`;case`connecting`:return`status-neutral`;default:return`status-unknown`}}function gx(e,t){let n=mx(e),r=String(e&&e.last_error||``).trim();return r&&n!==`connected`?r:n===`connected`&&e&&e.connected_at?`Connected since `+(typeof t==`function`?t:String)(e.connected_at):``}function _x(e){return String(e&&e.transport||``)===`stdio`?`local command`:String(e&&e.url||``).trim()||`—`}function vx(e){let t=Number(e&&e.prompt_count||0),n=Number(e&&e.resource_count||0);return t+` prompts · `+n+` resources`}function yx(e){let t=String(e||``).normalize(`NFKD`).toLowerCase(),n=t.replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/-+$/g,``);if(n)return n;let r=2166136261;for(let e of t)r=Math.imul((r^e.codePointAt(0))>>>0,16777619)>>>0;return`mcp-`+r.toString(16).padStart(8,`0`)}function bx(e){return String(e||``).split(` -`).map(e=>e.trim()).filter(e=>e)}function xx(e){return!e||typeof e!=`object`||Array.isArray(e)?[]:Object.keys(e).sort().map(t=>({name:t,value:String(e[t]||``)}))}function Sx(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=String(e&&e.name||``).trim();n&&(t[n]=String(e&&e.value||``))}),t}function Cx(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.slug,e.url,e.transport,e.description,e.status].some(e=>String(e||``).toLowerCase().includes(r)))}function wx(e){return{name:String(e.name||``).trim(),slug:px(e),url:String(e.url||``).trim(),transport:e.transport===`sse`?`sse`:`http`,description:String(e.description||``).trim(),enabled:e.enabled!==!1,headers:xx(e.headers),allowed_tools:(Array.isArray(e.allowed_tools)?e.allowed_tools:[]).join(`, `),disallowed_tools:(Array.isArray(e.disallowed_tools)?e.disallowed_tools:[]).join(`, `),user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` -`),tool_timeout_seconds:e.tool_timeout_seconds?String(e.tool_timeout_seconds):``}}function Tx(e,t,n){let r=String(e.name||``).trim(),i=String(e.slug||yx(r)).trim().toLowerCase(),a=String(e.url||``).trim(),o=e.transport===`sse`?`sse`:`http`;if(!r)return{error:`Name is required.`};if(!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(i))return{error:`Slug must use 1–64 lowercase ASCII letters, numbers, hyphens, or underscores.`};if(t===`create`&&(n||[]).some(e=>px(e)===i))return{error:`Slug "`+i+`" is already in use.`};if(!a)return{error:`URL is required.`};let s,c=String(e.tool_timeout_seconds||``).trim();if(c!==``){let e=Number(c);if(!Number.isSafeInteger(e)||e<0)return{error:`Tool timeout must be a non-negative whole number of seconds.`};s=e}return{payload:{name:r,slug:i,url:a,transport:o,headers:Sx(e.headers),description:String(e.description||``).trim(),enabled:!!e.enabled,allowed_tools:ic(e.allowed_tools),disallowed_tools:ic(e.disallowed_tools),user_paths:bx(e.user_paths),tool_timeout_seconds:s}}}function Ex(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=e=>(Array.isArray(e)?e:[]).filter(e=>e&&typeof e==`object`);return{server:String(n.server||e||``).trim(),status:String(n.status||``).trim(),instructions:String(n.instructions||``).trim(),tools:r(n.tools),prompts:r(n.prompts),resources:r(n.resources),templates:r(n.templates)}}function Dx(e,t){return String(e&&e.server||``)+`_`+String(t||``)}function Ox(e){let t=e||fx(),n=(e,t)=>{let n=String(e||``).trim(),r=String(t||``).trim();return n&&r?n+` — `+r:r||n},r=e=>n=>({key:e+`:`+String(n.name||``),name:String(n.name||``),aggregated:Dx(t,n.name),description:String(n.description||``).trim()});return[{key:`tools`,title:`Tools`,items:(t.tools||[]).map(r(`tool`))},{key:`prompts`,title:`Prompts`,items:(t.prompts||[]).map(r(`prompt`))},{key:`resources`,title:`Resources`,items:(t.resources||[]).map(e=>({key:`resource:`+String(e.uri||``),name:String(e.uri||``),aggregated:``,description:n(e.name,e.description)}))},{key:`templates`,title:`Resource templates`,items:(t.templates||[]).map(e=>({key:`template:`+String(e.uri_template||``),name:String(e.uri_template||``),aggregated:``,description:n(e.name,e.description)}))}].filter(e=>e.items.length>0)}function kx(e){return Ox(e).length===0}function Ax(e){return(e||[]).length}function jx(e){return(e||[]).filter(e=>mx(e)===`connected`).length}function Mx(e){return(e||[]).filter(e=>e&&e.enabled!==!1&&mx(e)===`degraded`).length}function Nx(e,t){return!!e&&Ax(t)>0}function Px(e){return String(jx(e))+`/`+String(Ax(e))}function Fx(e){return Mx(e)>0?`is-degraded`:`is-healthy`}function Ix(e){let t=Mx(e);if(t>0)return String(t)+` server`+(t===1?``:`s`)+` need`+(t===1?`s`:``)+` attention`;let n=Ax(e),r=jx(e);return n>0&&r===n?`All MCP servers connected`:String(r)+` of `+String(n)+` server`+(n===1?``:`s`)+` connected`}function Lx(){return{interval:`day`,buckets:[],summary:{requests:0},provider_latency:[]}}function Rx(e){let t=e&&typeof e==`object`?e:{};return{interval:t.interval===`hour`?`hour`:`day`,buckets:Array.isArray(t.buckets)?t.buckets:[],summary:t.summary&&typeof t.summary==`object`?t.summary:{requests:0},provider_latency:Array.isArray(t.provider_latency)?t.provider_latency:[]}}function zx(e){return Number(e&&e.summary&&e.summary.requests||0)>0}function Bx(e){return(e&&Array.isArray(e.provider_latency)?e.provider_latency:[]).length>0}function Vx(e){let t=e&&e.summary?e.summary.success_rate:null;return t==null?`—`:(Math.round(Number(t)*1e3)/10).toFixed(1)+`%`}function Hx(e,t){return Number(e&&e.summary&&e.summary[t]||0)}function Ux(e){let t=Number(e);return Number.isFinite(t)?t>=6e4?(t/6e4).toFixed(1)+` min`:t>=1e3?(t/1e3).toFixed(2)+` s`:Math.round(t)+` ms`:`-`}function Wx(e){let t=e&&e.summary?e.summary.avg_duration_ms:null;return t==null?`—`:Ux(Number(t))}function Gx(e,t){try{let n={};return new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,hourCycle:`h23`}).formatToParts(e).forEach(e=>{n[e.type]=e.value}),{year:n.year,month:n.month,day:n.day,hour:Number(n.hour)}}catch{return{year:String(e.getFullYear()),month:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()],day:String(e.getDate()),hour:e.getHours()}}}function Kx(e,t,n){let r=new Date(e.start);if(Number.isNaN(r.getTime()))return String(e.start||``);let i=Gx(r,n),a=i.month+` `+i.day;return t!==`hour`||i.hour===0?a:String(i.hour).padStart(2,`0`)+`:00`}function qx(e,t,n,r){let i=new Date(e.start);if(Number.isNaN(i.getTime()))return String(e.start||``);if(t===`hour`)return r(e.start);let a=Gx(i,n);return a.month+` `+a.day+`, `+a.year}function Jx(e){return{ok:e(`var(--success)`),clientError:e(`var(--warning)`),serverError:e(`var(--danger)`),other:e(`color-mix(in srgb, var(--text-muted) 55%, transparent)`)}}function Yx(e,t,n={}){let r=n.interval===`hour`?`hour`:`day`,i=n.zone,a=n.resolve||(e=>e),o=n.formatTimestamp||(e=>String(e)),s=t.map(e=>Kx(e,r,i)),c=Jx(a),l=a(`var(--bg-surface)`),u=e=>Number(e)||0,d=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:l,borderWidth:1,borderSkipped:!1,borderRadius:2,maxBarThickness:28}),f=[d(`2xx`,t.map(e=>u(e.status_2xx)),c.ok),d(`4xx`,t.map(e=>u(e.status_4xx)),c.clientError),d(`5xx`,t.map(e=>u(e.status_5xx)),c.serverError)];return t.some(e=>u(e.status_other)>0)&&f.push(d(`Other`,t.map(e=>u(e.status_other)),c.other)),{type:`bar`,data:{labels:s,datasets:f},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{title:e=>e.length?qx(t[e[0].dataIndex],r,i,o):``,label:e=>e.dataset.label+`: `+e.parsed.y.toLocaleString(),footer:e=>{let t=0;return e.forEach(e=>{t+=Number(e.parsed.y)||0}),`Total: `+t.toLocaleString()}})},scales:{x:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{stacked:!0,beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),precision:0,callback:e=>uc(e)}}}}}}function Xx(e=Vy()){let t={};return function(n){return n in t||(t[n]=e[Object.keys(t).length%e.length]),t[n]}}function Zx(e,t,n,r={}){let i=r.interval===`hour`?`hour`:`day`,a=r.zone,o=r.formatTimestamp||(e=>String(e)),s=r.providerColor||Xx();return{type:`line`,data:{labels:t.map(e=>Kx(e,i,a)),datasets:n.map(e=>({label:e.provider,data:(e.avg_duration_ms||[]).map(e=>e==null?null:Number(e)),borderColor:s(e.provider),backgroundColor:s(e.provider),fill:!1,tension:.3,borderWidth:2,pointRadius:0,pointHoverRadius:4,spanGaps:i===`hour`&&2}))},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:0},interaction:{mode:`index`,intersect:!1},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{title:e=>e.length?qx(t[e[0].dataIndex],i,a,o):``,label:e=>{let t=(n[e.datasetIndex]&&n[e.datasetIndex].requests||[])[e.dataIndex],r=Number(t)||0;return e.dataset.label+`: `+Ux(e.parsed.y)+(r>0?` (`+r.toLocaleString()+` req)`:``)}})},scales:{x:{grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),maxRotation:0,autoSkip:!0,maxTicksLimit:12}},y:{beginAtZero:!0,grid:{color:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),callback:e=>Ux(e)}}}}}}var Qx=class{#e=k(j(Lb()));get status(){return I(this.#e)}set status(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=k(!1);get loadedOnce(){return I(this.#n)}set loadedOnce(e){A(this.#n,e,!0)}#r=k(!1);get detailsExpanded(){return I(this.#r)}set detailsExpanded(e){A(this.#r,e,!0)}#i=k(j({}));get cardOverrides(){return I(this.#i)}set cardOverrides(e){A(this.#i,e,!0)}#a=null;#o=null;#s=!1;initPreferences(){if(this.#s)return;this.#s=!0;let e=Rb(wa());this.detailsExpanded=e.detailsExpanded,this.cardOverrides=e.cardOverrides}cardExpanded(e){return Vb(this.cardOverrides,this.detailsExpanded,e)}toggleCard(e){let t=e&&e.name?String(e.name):``;if(!t)return;let n={...this.cardOverrides};n[t]=!this.cardExpanded(e),this.cardOverrides=n,Bb(wa(),this.cardOverrides)}toggleDetails(){this.detailsExpanded=!this.detailsExpanded,this.cardOverrides={},zb(wa(),this.detailsExpanded),Bb(wa(),this.cardOverrides)}detailsToggleLabel(){return this.detailsExpanded?`Show Details`:`Hide Details`}async fetch(){this.initPreferences(),this.#a&&this.#a.abort();let e=new AbortController;this.#a=e,this.loading=!0;try{let t=await _s(`/admin/providers/status`,{label:`provider status`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.status=Lb(),this.#l();return}let n=t.data&&typeof t.data==`object`?t.data:Lb();n.summary||=Lb().summary,Array.isArray(n.providers)||(n.providers=[]),this.status=n,this.#c()}catch(e){if(ys(e))return;console.error(`Failed to fetch provider status:`,e),this.status=Lb(),this.#l()}finally{this.#a===e&&(this.#a=null,this.loading=!1,this.loadedOnce=!0)}}#c(){this.#l(),qb(this.status.providers)&&(this.#o=setTimeout(()=>{this.#o=null,this.fetch()},Pb))}#l(){this.#o&&=(clearTimeout(this.#o),null)}stopPolling(){this.#l()}},$x=class{#e=k(j(Lx()));get stats(){return I(this.#e)}set stats(e){A(this.#e,e,!0)}#t=k(!1);get loading(){return I(this.#t)}set loading(e){A(this.#t,e,!0)}#n=0;async fetch(){let e=++this.#n;this.loading=!0;try{let t=await _s(`/admin/audit/stats?`+Mc.queryStr(),{label:`audit stats`});if(t.stale||e!==this.#n)return;if(!t.ok){this.stats=Lx();return}this.stats=Rx(t.data)}catch(t){if(console.error(`Failed to fetch audit stats:`,t),e!==this.#n)return;this.stats=Lx()}finally{e===this.#n&&(this.loading=!1)}}},eS=class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!1);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}async fetch(){if(await Ss.ensureLoaded(),!Ss.mcpVisible()){this.available=!1,this.servers=[];return}this.loading=!0;try{let e=await _s(`/admin/mcp-servers`,{label:`mcp servers`});if(e.stale)return;if(e.status===503||e.status===404){this.available=!1,this.servers=[];return}if(this.available=!0,!e.ok){this.servers=[];return}this.servers=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch MCP servers:`,e),this.servers=[]}finally{this.loading=!1}}},tS=class{#e=k(j([]));get data(){return I(this.#e)}set data(e){A(this.#e,e,!0)}#t=k(`tokens`);get mode(){return I(this.#t)}set mode(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=null;async fetch(){this.#r&&this.#r.abort();let e=new AbortController;this.#r=e,this.loading=!0;try{let t=await _s(`/admin/usage/daily?days=365&interval=daily`,{label:`calendar`,signal:e.signal});if(t.stale||e.signal.aborted)return;if(!t.ok){this.data=[];return}this.data=Array.isArray(t.data)?t.data:[]}catch(e){if(ys(e))return;console.error(`Failed to fetch calendar data:`,e),this.data=[]}finally{this.#r===e&&(this.#r=null,this.loading=!1)}}},nS=new Qx,rS=new $x,iS=new eS,aS=new tS,oS=(e,t=f,n=f,r=f,i=f)=>{var a=cS(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=M(c),u=M(l),d=M(u,!0);T(u),Ue(),T(l);var p=P(l,4),m=M(p),h=M(m,!0);T(m),Ue(),T(p);var g=P(p,4),_=M(g,!0);T(g),T(c),T(a),F((e,n,r,i,a,o)=>{B(s,t()),W(l,`title`,e),B(d,n),W(p,`title`,r),B(h,i),W(g,`title`,a),B(_,o)},[()=>dc(`Input tokens`,n()),()=>uc(n()),()=>dc(`Output tokens`,r()),()=>uc(r()),()=>dc(`Total tokens`,i()),()=>uc(i())]),z(e,a)},sS=(e,t=f,n=f,r=f,i=f,a=f,o=f)=>{var s=dS(),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u);var p=P(u,2),m=e=>{var t=lS(),n=M(t,!0);T(t),F(()=>{W(t,`aria-label`,o().title),W(t,`title`,o().title),B(n,a())}),L(`click`,t,function(...e){o().onclick?.apply(this,e)}),z(e,t)},h=e=>{var t=uS(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(p,e=>{o()?e(m):e(h,-1)}),T(s),F(()=>{U(s,1,`card provider-status-flag ${t()??``} ${n()??``}`,`svelte-6tr9cf`),B(l,r()),B(d,i())}),z(e,s)},cS=R(`
                        i + o =
                        `),lS=R(``),uS=R(` `),dS=R(`
                        `),fS=R(`
                        Cache Hits
                        `),pS=R(`
                        Total Requests
                        Estimated Cost
                        Prompt Cache Rate
                        `);function mS(e,t){E(t,!0);let n=O(()=>Rc.summary),r=O(()=>Rc.cacheOverview),i=O(()=>Rc.cacheAnalyticsEnabled()),a=O(()=>nS.status.summary);function o(){let e=document.getElementById(`provider-status-section`);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),e.focus({preventScroll:!0}))}var s=pS(),c=M(s);{let e=O(()=>fb(I(n)));oS(c,()=>`Tokens`,()=>I(n).total_input_tokens,()=>I(n).total_output_tokens,()=>I(e))}var l=P(c,2),u=P(M(l),2),d=M(u,!0);T(u),T(l);var f=P(l,2),p=e=>{var t=fS(),n=P(M(t),2),i=M(n,!0);T(n),T(t),F(e=>B(i,e),[()=>oc(I(r).summary.total_hits)]),z(e,t)};V(f,e=>{I(i)&&e(p)});var m=P(f,2),h=P(M(m),2),g=M(h,!0);T(h),T(m);var _=P(m,2),v=e=>{{let t=O(()=>gb(I(r)));oS(e,()=>`Local Cache`,()=>I(r).summary.total_input_tokens,()=>I(r).summary.total_output_tokens,()=>I(t))}};V(_,e=>{I(i)&&e(v)});var y=P(_,2),b=P(M(y),2),x=M(b);jy(x,{build:()=>jb(Db(I(n)),zy(`var(--token-prompt)`),zy(`var(--bg-surface-hover)`))});var S=P(x,2),C=M(S,!0);T(S),T(b),T(y);var w=P(y,2),ee=e=>{{let t=O(()=>Hb(I(a))),n=O(()=>Wb(I(a))),r=O(()=>Kb(I(a))),i=O(()=>Gb(I(a))?{title:`View providers overview`,onclick:o}:null);sS(e,()=>`provider-status-overview-card`,()=>I(t),()=>`Provider Status`,()=>I(n),()=>I(r),()=>I(i))}};V(w,e=>{I(a).total>0&&e(ee)});var te=P(w,2),ne=e=>{{let t=O(()=>Fx(iS.servers)),n=O(()=>Px(iS.servers)),r=O(()=>Ix(iS.servers));sS(e,()=>`mcp-servers-flag`,()=>I(t),()=>`MCP Servers`,()=>I(n),()=>I(r),()=>({title:`View MCP servers`,onclick:()=>Jo.navigate(`mcp-servers`)}))}},re=O(()=>Nx(iS.available,iS.servers));V(te,e=>{I(re)&&e(ne)}),T(s),F((e,t,n,r,i)=>{W(u,`title`,e),B(d,t),B(g,n),W(b,`aria-label`,r),B(C,i)},[()=>hb(I(n),I(r),I(i)),()=>oc(mb(I(n),I(r),I(i))),()=>sc(I(n).total_cost),()=>`Prompt cache rate `+kb(I(n)),()=>kb(I(n))]),z(e,s),D()}Hr([`click`]);var hS=R(` `),gS=R(`
                        `),_S=R(`No usage in the selected period yet`),vS=R(`
                        `),yS=R(`

                        Tokens

                        Share of input tokens over the selected period
                        `);function bS(e,t){E(t,!0);let n=O(()=>Rc.cacheAnalyticsEnabled()),r=O(()=>bb(Rc.summary,Rc.cacheOverview,I(n))),i=O(()=>xb(Rc.summary,Rc.cacheOverview,I(n))),a=O(()=>yb(Rc.summary,Rc.cacheOverview,I(n)));var o=yS(),s=P(M(o),2);let c;var l=M(s);H(l,17,()=>I(i),e=>e.key,(e,t)=>{var n=gS(),r=M(n),i=e=>{var n=hS(),r=M(n);T(n),F(()=>B(r,`${I(t).pct??``}%`)),z(e,n)};V(r,e=>{I(t).pct>=8&&e(i)}),T(n),F(e=>{Hi(n,`width: ${I(t).pct??``}%; background: var(${I(t).colorVar??``})`),W(n,`title`,e)},[()=>Sb(I(t))]),z(e,n)});var u=P(l,2),d=e=>{z(e,_S())};V(u,e=>{I(a)||e(d)}),T(s);var f=P(s,2);H(f,21,()=>I(r),e=>e.key,(e,t)=>{var n=vS(),r=M(n),i=P(r,2),a=M(i,!0);T(i);var o=P(i,2),s=M(o);T(o);var c=P(o,2),l=M(c,!0);T(c),T(n),F((e,i)=>{W(n,`title`,e),Hi(r,`background: var(${I(t).colorVar??``})`),B(a,I(t).label),B(s,`${I(t).pct??``}%`),B(l,i)},[()=>Sb(I(t)),()=>oc(I(t).tokens)]),z(e,n)}),T(f),T(o),F(e=>{c=U(s,1,`cache-meter-bar svelte-1yzecxj`,null,c,{"is-empty":!I(a)}),W(s,`aria-label`,e)},[()=>Cb(I(i))]),z(e,o),D()}var xS=R(``);function SS(e,t){let n=ya(t,`size`,3,16),r=ya(t,`label`,3,`Loading`),i=ya(t,`class`,3,``);var a=xS();F(()=>{U(a,1,Fi([`spinner`,i()]),`svelte-b54l9o`),Hi(a,`--spinner-size: ${n()??``}px`),W(a,`aria-label`,r())}),z(e,a)}var CS=Xr(` `),wS=Xr(``);function TS(e,t){let n=ya(t,`label`,3,`No data`);var r=wS(),i=P(M(r),9),a=e=>{var t=CS(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(i,e=>{n()&&e(a)}),T(r),F(()=>{W(r,`role`,n()?`img`:void 0),W(r,`aria-label`,n()||void 0),W(r,`aria-hidden`,n()?void 0:`true`)}),z(e,r)}var ES=R(`
                        `),DS=R(`

                        `);function OS(e,t){E(t,!0);let n=[`daily`,`weekly`,`monthly`,`yearly`];function r(e){Mc.interval=e,t.onintervalchange?.()}function i(){let e=Rc.daily;if(e.length===0)return null;let t=Mc.rangeStart(),n=Mc.rangeEnd(),r=Eb(Tb(e,Mc.interval,t,n),Tb(Array.isArray(Rc.cacheOverview.daily)?Rc.cacheOverview.daily:[],Mc.interval,t,n));return Ab(Iy(),r,{cacheEnabled:Rc.cacheAnalyticsEnabled(),resolve:zy})}var a=DS(),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2);{let e=O(()=>n.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})));Py(l,{ariaLabel:`Usage chart interval`,get options(){return I(e)},get value(){return Mc.interval},onchange:r})}T(o);var u=P(o,2),d=M(u);jy(d,{build:i});var f=P(d,2),p=e=>{var t=ES();SS(M(t),{size:24,label:`Loading usage`}),T(t),z(e,t)},m=e=>{var t=ES();TS(M(t),{}),T(t),z(e,t)};V(f,e=>{Rc.daily.length===0&&Rc.loading?e(p):Rc.daily.length===0&&!K.authError&&e(m,1)}),T(u),T(a),F(e=>B(c,e),[()=>Mc.chartTitle()]),z(e,a),D()}var kS=10,AS=.7;function jS(e,t){if(e<=0||t<=0)return 0;let n=(e/t)**+AS,r=Math.ceil(n*kS);return r<1?1:r>kS?kS:r}function MS(){let e=[];for(let t=0;t<=kS;t++)e.push(t);return e}function NS(e,t,n){let r={};(e||[]).forEach(e=>{r[e.date]=e});let i=Qo(es(n,-364)),a=i.getUTCDay();i.setUTCDate(i.getUTCDate()-a);let o=[];for(let e=new Date(i);$o(e)<=n;e.setUTCDate(e.getUTCDate()+1)){let n=$o(e),i=r[n],a=0;i&&(a=t===`costs`?i.total_cost==null?0:i.total_cost:i.total_tokens||0),o.push({dateStr:n,value:a,level:0,empty:!1})}let s=0;for(let e=0;es&&(s=o[e].value);for(let e=0;e0){for(;l.length<7;)l.push({dateStr:``,value:0,level:0,empty:!0});c.push(l)}return c}function PS(e){let t=Qo(es(e,-364)),n=t.getUTCDay();t.setUTCDate(t.getUTCDate()-n);let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],i=[],a={},o=0;for(let n=new Date(t);$o(n)<=e;n.setUTCDate(n.getUTCDate()+7),o++){let t=null;if(o===0)t=new Date(n);else for(let r=0;r<7;r++){let i=new Date(n);if(i.setUTCDate(n.getUTCDate()+r),$o(i)>e)break;if(i.getUTCDate()===1){t=i;break}}if(!t)continue;let s=t.getUTCFullYear()+`-`+t.getUTCMonth();a[s]||(i.push({label:r[t.getUTCMonth()],col:o,key:s}),a[s]=!0)}for(let e=0;e `),RS=R(`
                        `),zS=R(`
                        `),BS=R(`
                        `),VS=R(`
                        `),HS=R(`

                        Activity

                        Mon Wed Fri
                        `,1);function US(e,t){E(t,!0);let n=k(j({show:!1,x:0,y:0,text:``})),r=O(()=>ds.currentDateKey()),i=O(()=>NS(aS.data,aS.mode,I(r))),a=O(()=>PS(I(r)));function o(e,t){t.empty||A(n,{show:!0,x:e.clientX,y:e.clientY,text:IS(t,aS.mode)},!0)}function s(){A(n,{show:!1,x:0,y:0,text:``},!0)}var c=HS(),l=N(c),u=M(l),d=P(M(u),2),f=e=>{SS(e,{size:14,label:`Loading activity`})};V(d,e=>{aS.loading&&aS.data.length===0&&e(f)}),Py(P(d,2),{ariaLabel:`Activity calendar mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return aS.mode},onchange:e=>aS.mode=e}),T(u);var p=P(u,2),m=P(M(p),2),h=M(m);H(h,21,()=>I(a),e=>e.key,(e,t)=>{var n=LS(),r=M(n,!0);T(n),F(()=>{Hi(n,`grid-column: ${I(t).col+1} / span ${I(t).span??``}`),B(r,I(t).label)}),z(e,n)}),T(h);var g=P(h,2);H(g,21,()=>I(i),oi,(e,t,n)=>{var r=zS();H(r,23,()=>I(t),(e,t)=>n+`-`+t,(e,t)=>{var n=RS();F(()=>U(n,1,Fi([`contribution-calendar-cell`,I(t).empty?`empty`:`level-${I(t).level}`]),`svelte-3hfxuq`)),Vr(`mouseenter`,n,e=>o(e,I(t))),Vr(`mouseleave`,n,s),z(e,n)}),T(r),z(e,r)}),T(g),T(m),T(p);var _=P(p,2),v=M(_),y=M(v),b=M(y,!0);T(y),T(v);var x=P(v,2);H(P(M(x),2),16,MS,e=>e,(e,t)=>{var n=BS();F(()=>U(n,1,`contribution-calendar-cell level-${t??``}`,`svelte-3hfxuq`)),z(e,n)}),Ue(2),T(x),T(_),T(l);var S=P(l,2),C=e=>{var t=VS(),r=M(t,!0);T(t),F(()=>{Hi(t,`left: ${I(n).x??``}px; top: ${I(n).y-40}px`),B(r,I(n).text)}),z(e,t)};V(S,e=>{I(n).show&&e(C)}),F(e=>B(b,e),[()=>FS(aS.data,aS.mode)]),z(e,c),D()}var WS=R(``),GS=R(`

                        `),KS=R(`
                        `);function qS(e,t){E(t,!0);let n=ya(t,`label`,3,`help`),r=ya(t,`text`,3,``),i=ya(t,`open`,15,!1),a=ya(t,`external`,3,!1),o=O(()=>!!r()||!!t.help||a());var s=KS(),c=M(s),l=M(c);gi(l,()=>t.title??f);var u=P(l,2),d=e=>{var r=WS();let a;F(()=>{a=U(r,1,`inline-help-toggle svelte-y40or3`,null,a,{"is-open":i()}),W(r,`aria-label`,(i()?`Hide `:`Show `)+n()),W(r,`aria-expanded`,i()),W(r,`aria-controls`,t.copyId)}),L(`click`,r,()=>i(!i())),z(e,r)};V(u,e=>{I(o)&&e(d)}),gi(P(u,2),()=>t.extra??f),T(c);var p=P(c,2),m=e=>{var n=GS(),i=M(n),a=e=>{var n=Qr();gi(N(n),()=>t.help),z(e,n)},o=e=>{var t=Zr();F(()=>B(t,r())),z(e,t)};V(i,e=>{t.help?e(a):e(o,-1)}),T(n),F(()=>W(n,`id`,t.copyId)),z(e,n)};V(p,e=>{i()&&I(o)&&!a()&&e(m)}),T(s),z(e,s),D()}Hr([`click`]);var JS=R(`

                        Provider Latency

                        `),YS=R(`
                        Avg
                        `),XS=R(`

                        Requests by Status

                        Success 2xx 4xx 5xx
                        `,1);function ZS(e,t){E(t,!0);let n=Xx(),r=O(()=>rS.stats);function i(){return{interval:I(r).interval,zone:ds.effectiveTimezone(),resolve:zy,formatTimestamp:e=>ds.formatTimestamp(e)}}var a=Qr(),o=N(a),s=e=>{var t=XS(),a=N(t),o=M(a),s=P(M(o),2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c);var d=P(c,2),f=P(M(d),4),p=M(f,!0);T(f),T(d);var m=P(d,2),h=P(M(m),4),g=M(h,!0);T(h),T(m);var _=P(m,2),v=P(M(_),4),y=M(v,!0);T(v),T(_),T(s),T(o);var b=P(o,2);jy(M(b),{build:()=>Yx(Iy(),I(r).buckets,i())}),T(b),T(a);var x=P(a,2),S=e=>{var t=YS(),a=M(t),o=M(a);qS(o,{copyId:`audit-latency-help-copy`,label:`provider latency help`,text:`Average duration of successful requests as measured at the gateway, per provider. Local cache hits and failed requests are excluded; streamed responses count until the stream completes.`,title:e=>{z(e,JS())},$$slots:{title:!0}});var s=P(o,2),c=M(s),l=P(M(c),2),u=M(l,!0);T(l),T(c),T(s),T(a);var d=P(a,2);jy(M(d),{build:()=>Zx(Iy(),I(r).buckets,I(r).provider_latency,{...i(),providerColor:n})}),T(d),T(t),F(e=>B(u,e),[()=>Wx(I(r))]),z(e,t)},C=O(()=>Bx(I(r)));V(x,e=>{I(C)&&e(S)}),F((e,t,n,r)=>{B(u,e),B(p,t),B(g,n),B(y,r)},[()=>Vx(I(r)),()=>oc(Hx(I(r),`status_2xx`)),()=>oc(Hx(I(r),`status_4xx`)),()=>oc(Hx(I(r),`status_5xx`))]),z(e,t)},c=O(()=>zx(I(r)));V(o,e=>{I(c)&&e(s)}),z(e,a),D()}var QS=(e,t=f,n=f,r)=>{let i=Ot(()=>h(r?.(),!1));var a=tC(),o=M(a),s=M(o,!0);T(o);var c=P(o,2),l=e=>{var t=$S(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)},u=e=>{var t=eC(),r=M(t,!0);T(t),F(()=>B(r,n())),z(e,t)};V(c,e=>{I(i)?e(l):e(u,-1)}),T(a),F(()=>B(s,t())),z(e,a)},$S=R(` `),eC=R(` `),tC=R(`
                        `),nC=R(`

                        `),rC=R(`
                        Breaker State
                        `),iC=R(`
                        `),aC=R(`
                        Models (Recent Traffic)
                        `),oC=R(`
                        `),sC=R(`

                        `);function cC(e,t){E(t,!0);let n=O(()=>ox(t.provider)),r=O(()=>[[`Base URL`,t.provider.config?.base_url],[`API Version`,t.provider.config?.api_version]].filter(([,e])=>!!e));var i=sC();let a;var o=M(i),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{var n=nC(),r=M(n,!0);T(n),F(()=>B(r,t.provider.last_error)),z(e,n)};V(l,e=>{t.provider.last_error&&e(u)});var d=P(l,2),f=e=>{var r=oC(),i=M(r);{let e=O(()=>sx(t.provider));QS(i,()=>`Recent Requests`,()=>I(e))}var a=P(i,2),o=e=>{var r=rC(),i=P(M(r),2),a=M(i),o=M(a,!0);T(a),T(i),T(r),F(e=>{U(a,1,Fi([`provider-status-health-state`,I(n)]),`svelte-6y9wjv`),B(o,e)},[()=>ax(t.provider)]),z(e,r)},s=O(()=>ix(t.provider));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{var n=aC(),r=P(M(n),2);H(r,21,()=>cx(t.provider),e=>e.model,(e,t)=>{var n=iC();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F((e,i)=>{r=U(n,1,`provider-status-health-model svelte-6y9wjv`,null,r,{"is-flagged":I(t).flagged}),W(n,`title`,e),B(a,I(t).model),B(s,i)},[()=>ux(I(t)),()=>lx(I(t))]),z(e,n)}),T(r),T(n),z(e,n)},u=O(()=>cx(t.provider).length>0);V(c,e=>{I(u)&&e(l)}),T(r),z(e,r)},p=O(()=>rx(t.provider));V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=M(m);H(h,17,()=>I(r),([e,t])=>e,(e,t)=>{var n=O(()=>g(I(t),2));QS(e,()=>I(n)[0],()=>I(n)[1],()=>!0)});var _=P(h,2);{let e=O(()=>tx(t.provider));QS(_,()=>`Configured Models`,()=>I(e))}var v=P(_,2);{let e=O(()=>$b(t.provider));QS(v,()=>`Retry`,()=>I(e))}var y=P(v,2);{let e=O(()=>ex(t.provider));QS(y,()=>`Circuit Breaker`,()=>I(e))}T(m),T(o),T(i),F(()=>{a=U(i,1,`provider-status-details svelte-6y9wjv`,null,a,{"is-expanded":t.expanded,"is-collapsed":!t.expanded}),W(i,`aria-hidden`,!t.expanded),B(c,t.provider.status_reason)}),z(e,i),D()}var lC=R(` `),uC=R(``),dC=R(`

                        Models Available
                        Last Checked
                        `);function fC(e,t){E(t,!0);let n=O(()=>nS.cardExpanded(t.provider)),r=e=>ds.formatTimestamp(e);var i=dC(),a=M(i),o=M(a),s=M(o),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=e=>{var n=lC(),r=M(n);T(n),F(e=>B(r,`(${e??``})`),[()=>Zb(t.provider)]),z(e,n)},f=O(()=>Zb(t.provider));V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var n=uC();F((e,t,r)=>{W(n,`href`,e),W(n,`aria-label`,t),W(n,`title`,r)},[()=>Qb(t.provider),()=>`View `+(Zb(t.provider)||t.provider.name)+` provider docs`,()=>`View `+(Zb(t.provider)||t.provider.name)+` provider docs`]),z(e,n)},h=O(()=>Qb(t.provider));V(p,e=>{I(h)&&e(m)}),T(s),T(o);var g=P(o,2),_=M(g,!0);T(g),T(a);var v=P(a,2),y=M(v),b=P(M(y),2),x=M(b,!0);T(b),T(y);var S=P(y,2),C=P(M(S),2),w=M(C,!0);T(C),T(S),T(v);var ee=P(v,2);cC(ee,{get provider(){return t.provider},get expanded(){return I(n)}});var te=P(ee,2);let ne;G(M(te),{get icon(){return Ha},class:`provider-status-card-toggle-icon`}),T(te),T(i),F((e,r,i,a,o)=>{B(l,t.provider.name),U(g,1,`provider-status-pill ${e??``}`,`svelte-nopjmh`),W(g,`title`,r),B(_,t.provider.status_label),B(x,i),W(C,`title`,a),B(w,o),ne=U(te,1,`provider-status-card-toggle svelte-nopjmh`,null,ne,{"is-expanded":I(n)}),W(te,`aria-expanded`,I(n)),W(te,`aria-label`,(I(n)?`Collapse `:`Expand `)+t.provider.name+` details`),W(te,`title`,I(n)?`Collapse details`:`Expand details`)},[()=>Ub(t.provider.status),()=>nx(t.provider),()=>oc(t.provider.runtime?.discovered_model_count),()=>Xb(t.provider,r),()=>Yb(t.provider,r)]),L(`click`,te,()=>nS.toggleCard(t.provider)),z(e,i),D()}Hr([`click`]);var pC=R(`

                        Providers Overview

                        `),mC=R(`
                        `);function hC(e,t){E(t,!0);let n=O(()=>nS.status.providers);var r=Qr(),i=N(r),a=e=>{var t=pC(),r=M(t),i=P(M(r),2),a=M(i),o=M(a,!0);T(a);var s=P(a,2);let c;T(i),T(r);var l=P(r,2);H(l,21,()=>I(n),e=>e.name,(e,t)=>{fC(e,{get provider(){return I(t)}})}),T(l),T(t),F((e,t)=>{W(i,`aria-checked`,nS.detailsExpanded),W(i,`title`,e),B(o,t),c=U(s,1,`provider-status-toggle-track svelte-1kx3uw4`,null,c,{"is-active":nS.detailsExpanded})},[()=>nS.detailsToggleLabel(),()=>nS.detailsToggleLabel()]),L(`click`,i,()=>nS.toggleDetails()),z(e,t)},o=e=>{var t=mC();SS(M(t),{size:18,label:`Loading provider status`}),T(t),z(e,t)};V(i,e=>{I(n).length>0?e(a):nS.loading&&!nS.loadedOnce&&e(o,1)}),z(e,r),D()}Hr([`click`]);var gC=R(`
                        `);function _C(e,t){E(t,!0);function n(){Rc.fetchUsage(),Rc.fetchCacheOverview(``),rS.fetch(),nS.fetch(),iS.fetch(),aS.fetch()}function r(){Rc.fetchUsage(),Rc.fetchCacheOverview(``),rS.fetch()}function i(){r(),aS.fetch()}An(()=>{if(K.refreshTick,Jo.page===`overview`)return Er(()=>{n(),sb.start()}),()=>{sb.stop(),nS.stopPolling()}});var a=gC(),o=M(a);db(o,{});var s=P(o,4);tl(M(s),{onchange:i}),T(s);var c=P(s,2);Fc(c,{});var l=P(c,2);mS(l,{});var u=P(l,2);bS(u,{});var d=P(u,2);OS(d,{onintervalchange:r});var f=P(d,2);US(f,{});var p=P(f,2);ZS(p,{}),hC(P(p,2),{}),T(a),z(e,a),D()}var vC=`/admin/live/logs?types=audit,usage`;function yC(e,t,n){return!!t&&String(e&&e.id||``).trim()===t||!!n&&String(e&&e.request_id||``).trim()===n}function bC(e){switch(e){case`date_range`:return`Live paused — the selected date range does not include today. Set it to today to resume.`;case`filters`:return`Live paused while filters are active. Clear them to resume.`;case`pagination`:return`Live paused on later pages. Go to the first page to resume.`;default:return``}}function xC(e){let t=vC,n=Number(e||0);return Number.isFinite(n)&&n>0&&(t+=`&cursor=`+encodeURIComponent(String(n))),t}function SC(){return{async consumeLiveLogsBody(e){await Wy(e,e=>this.applyLiveLogEvent(e))},applyLiveLogEvent(e){if(!e||typeof e!=`object`)return;let t=Number(e.seq||0);Number.isFinite(t)&&t>this.liveLogsLastSeq&&(this.liveLogsLastSeq=t);let n=String(e.type||``).trim();if(n!==`heartbeat`){if(n===`reset`){this.reloadLiveLogSources();return}if(n===`audit.removed`){this.removeLiveAuditEntry(e.data);return}if(n.indexOf(`audit.`)===0){this.mergeLiveAuditEntry(e.data||{},n);return}n.indexOf(`usage.`)===0&&(this.mergeLiveUsageEntry(e.data||{},n),typeof this.noteLiveTokenUsage==`function`&&this.noteLiveTokenUsage(n))}},reloadLiveLogSources(){typeof this.fetchUsage==`function`&&this.fetchUsage(),this.page===`audit-logs`&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},auditLivePauseReason(){return!this.auditLog||this.auditLog.offset!==0?`pagination`:this.auditSearch||this.auditMethod||this.auditStatusCode||this.auditStream?`filters`:!this.followsToday&&(this.customStartDate||this.customEndDate)?`date_range`:null},auditLiveInsertAllowed(){return!this.auditLivePauseReason()},usageLiveInsertAllowed(){return this.usageLog&&this.usageLog.offset===0&&!this.usageLogSearch&&!this.usageFilterModel&&!this.usageFilterProvider&&!this.usageFilterLabel&&!this.usageFilterUserPath},mergeLiveAuditEntry(e,t){if(!e||typeof e!=`object`)return;let n=String(e.id||e.request_id||``).trim();if(!n)return;let r=String(e.request_id||``).trim(),i=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],a=i.findIndex(e=>yC(e,n,r)),o=a>=0&&i[a]||{},s=t===`audit.detail`,c=s?{...e,_detail_loaded:!0,_response_partial:!1,bodies_omitted:!1}:this.liveAuditPatch(o,e,t);if(a>=0){let e=this.mergeLiveAuditPatch(o,c);return i.splice(a,1,e),this.auditLog.entries=[...i],this.regroupLiveAuditHead(e),s||this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}let l=this.mergeLiveAuditChild(e,c);if(l)return s||this.fetchExpandedAuditDetailIfReady(l),this.cacheMergedAuditRecord(l,t),l;if(!this.auditLiveInsertAllowed()){this.cacheMergedAuditRecord(c,t);return}if(!s&&this.auditGroupSessions){let e=this.foldLiveAuditIntoThread(c);if(e)return this.fetchExpandedAuditDetailIfReady(e),this.cacheMergedAuditRecord(e,t),e}this.auditLog.entries=[this.mergeLiveAuditUsagePatch(c),...i].slice(0,this.auditLog.limit||25),this.auditLog.total=Number(this.auditLog.total||0)+1;let u=this.auditLog.entries[0];return s||this.fetchExpandedAuditDetailIfReady(u),this.cacheMergedAuditRecord(u,t),u},liveAuditPatch(e,t,n){let r=this.liveAuditStateAfter(e._live_state,n),i=this.liveAuditEventFlushed(e._live_state)||this.liveAuditEventFlushed(r),a={...t,_live:!0,_live_state:r,_audit_flushed:i,_live_pending:!i};return n===`audit.stream`?a._response_partial=!0:this.liveAuditStateSettled(n)&&(a._response_partial=!1),a},mergeLiveAuditChild(e,t){let n=this.auditThreadChildren;if(!n||typeof n!=`object`)return null;let r=String(e.id||``).trim(),i=String(e.request_id||``).trim(),a=Object.keys(n);for(let e=0;eyC(e,r,i));if(c<0)continue;let l=this.mergeLiveAuditPatch(s[c]||{},t),u=[...s];return u.splice(c,1,l),this.auditThreadChildren={...n,[a[e]]:{...o,entries:u}},l}return null},regroupLiveAuditHead(e){if(!this.auditGroupSessions)return null;let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=String(e.id||``).trim(),i=n.findIndex(e=>String(e.id||``).trim()===r);if(i<0)return null;let a=n.findIndex((e,n)=>n!==i&&String(e.session_id||``).trim()===t);if(a<0)return null;let o=n[a],s=Date.parse(o&&o.timestamp),c=Date.parse(e&&e.timestamp),l=Number.isFinite(s)&&Number.isFinite(c)&&s>c,u=l?o:e,d=l?e:o,f={...u,session_count:Math.max(1,Number(o.session_count||1))+Math.max(1,Number(e.session_count||1))},p=n.filter((e,t)=>t!==i&&t!==a);return p.unshift(f),this.auditLog.entries=p,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-1),this.prependLiveAuditThreadChild(t,d),f},foldLiveAuditIntoThread(e){let t=String(e&&e.session_id||``).trim();if(!t)return null;let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(e=>String(e.session_id||``).trim()===t);if(r<0)return null;let i=n[r],a=Number(i.session_count),o=this.mergeLiveAuditUsagePatch({...e,session_count:(Number.isFinite(a)&&a>0?a:1)+1}),s=[...n];return s.splice(r,1),s.unshift(o),this.auditLog.entries=s,this.prependLiveAuditThreadChild(t,i),o},prependLiveAuditThreadChild(e,t){let n=this.auditThreadChildren||{},r=n[e],i={...t};delete i.session_count;let a=r&&Array.isArray(r.entries)?{...r,entries:[i,...r.entries],total:Number(r.total||r.entries.length)+1}:{loading:!1,loaded:!1,entries:[i],total:1};this.auditThreadChildren={...n,[e]:a}},removeLiveAuditThreadChild(e,t){let n=this.auditThreadChildren;!n||typeof n!=`object`||Object.keys(n).forEach(r=>{let i=n[r],a=i&&Array.isArray(i.entries)?i.entries:[],o=a.filter(n=>!yC(n,e,t)),s=a.length-o.length;s!==0&&(this.auditThreadChildren={...this.auditThreadChildren,[r]:{...i,entries:o,total:Math.max(0,Number(i.total||a.length)-s)}},this.decrementLiveAuditThreadCount(r,s))})},decrementLiveAuditThreadCount(e,t){let n=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],r=n.findIndex(t=>String(t.session_id||``).trim()===e);if(r<0)return;let i=n[r],a=[...n];a.splice(r,1,{...i,session_count:Math.max(1,Number(i.session_count||1)-t)}),this.auditLog.entries=a},mergeLiveAuditPatch(e,t){let n={...e,...t};return t.data===void 0&&e.data!==void 0?n.data=e.data:e.data&&t.data&&typeof e.data==`object`&&typeof t.data==`object`&&!Array.isArray(e.data)&&!Array.isArray(t.data)&&(n.data={...e.data,...t.data}),this.mergeLiveAuditUsagePatch(n)},mergeLiveAuditUsagePatch(e){let t=this.liveUsageEntryForAudit(e);if(!t)return e;let n=this.auditEntryWithLiveUsage(e,t);return this.removeSkippedLiveUsage(t),n},liveUsageEntryForAudit(e){let t=String(e&&e.request_id||``).trim();return t&&((this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[]).find(e=>String(e&&e.request_id||``).trim()===t)||this.skippedLiveUsageByRequestId&&this.skippedLiveUsageByRequestId[t])||null},cacheMergedAuditRecord(e,t){return e&&typeof this.cacheAuditRecord==`function`?this.cacheAuditRecord(e,t):e},fetchExpandedAuditDetailIfReady(e){!e||!this.isAuditEntryExpanded||!this.isAuditEntryExpanded(e)||String(e._live_state||``).trim()!==`audit.flushed`&&!e._audit_flushed||typeof this.fetchAuditEntryDetail==`function`&&this.fetchAuditEntryDetail(e)},liveAuditStateRank(e){switch(String(e||``).trim()){case`audit.started`:return 10;case`audit.updated`:case`audit.stream`:return 20;case`audit.completed`:return 30;case`audit.failed`:case`audit.flushed`:case`audit.detail`:return 40;default:return 0}},liveAuditStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveAuditStateRank(n)>this.liveAuditStateRank(r)?n:r},liveAuditStateSettled(e){return this.liveAuditStateRank(e)>=this.liveAuditStateRank(`audit.completed`)},liveAuditEventFlushed(e){let t=String(e||``).trim();return t===`audit.failed`||t===`audit.flushed`||t===`audit.detail`},removeLiveAuditEntry(e){if(!e||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim();if(!t&&!n)return;let r=this.auditLog.entries,i=[],a=0,o=0,s=!1;r.forEach(e=>{if(!yC(e,t,n)){i.push(e);return}a++;let r=String(e.session_id||``).trim(),c=Math.max(1,Number(e.session_count||1));if(!this.auditGroupSessions||!r||c<=1)return;o++;let l=this.auditThreadChildren&&this.auditThreadChildren[r],u=l&&Array.isArray(l.entries)?l.entries.filter(e=>!yC(e,t,n)):[];if(u.length===0){s=!0;return}let d={...u[0],session_id:r,session_count:c-1};i.push(d),this.auditThreadChildren={...this.auditThreadChildren,[r]:{...l,entries:u.slice(1),total:Math.max(0,Number(l.total||c)-1)}}}),a>0&&(this.auditLog.entries=i,this.auditLog.total=Math.max(0,Number(this.auditLog.total||0)-a+o)),this.removeLiveAuditThreadChild(t,n),s&&typeof this.fetchAuditLog==`function`&&this.fetchAuditLog(!0)},mergeLiveUsageEntry(e,t){if(!e||typeof e!=`object`)return;e={...e,_live_state:t||e._live_state||`usage.completed`};let n=String(e.id||``).trim();if(!n)return;let r=this.usageLog&&Array.isArray(this.usageLog.entries)?this.usageLog.entries:[],i=r.findIndex(e=>String(e.id||``).trim()===n);if(i>=0){let t=r[i]||{},n=this.mergeLiveUsagePatch(t,e);if(this.applyLiveUsageToAudit(n),this.liveUsageShouldSkip(n)){r.splice(i,1),this.usageLog.entries=[...r],this.usageLog.total=Math.max(0,Number(this.usageLog.total||0)-1),this.storeSkippedLiveUsage(n);return}r.splice(i,1,n),this.usageLog.entries=[...r],this.removeSkippedLiveUsage(n);return}let a=this.mergeLiveUsagePatch(this.liveUsageSeedForEntry(e),e);if(this.applyLiveUsageToAudit(a),this.liveUsageShouldSkip(a)){this.storeSkippedLiveUsage(a);return}this.removeSkippedLiveUsage(a),this.usageLog.entries=[a,...r].slice(0,this.usageLog.limit||50),this.usageLog.total=Number(this.usageLog.total||0)+1},mergeLiveUsagePatch(e,t){e=e&&typeof e==`object`?e:{};let n=this.liveUsageStateAfter(e._live_state,t&&t._live_state),r=this.liveUsageEventFlushed(e)||this.liveUsageEventFlushed({...t,_live_state:n});return{...e,...t,_live:!0,_live_state:n||`usage.completed`,_live_pending:!r,_usage_flushed:r}},liveUsageShouldSkip(e){return!!(this.usageLogHideCached&&this.liveUsageEntryCached(e))||!this.usageLiveInsertAllowed()},liveUsageSeedForEntry(e){return this.skippedLiveUsageForEntry(e)||this.auditLiveUsageForEntry(e)},skippedLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();return t&&this.skippedLiveUsageByRequestId?this.skippedLiveUsageByRequestId[t]:null},auditLiveUsageForEntry(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return null;let n=this.auditLog.entries.find(e=>String(e&&e.request_id||``).trim()===t),r=n&&n.usage&&typeof n.usage==`object`&&!Array.isArray(n.usage)?n.usage:null;return r?{id:e&&e.id,request_id:t,entries:r.entries,input_tokens:r.input_tokens,uncached_input_tokens:r.uncached_input_tokens,cached_input_tokens:r.cached_input_tokens,cache_write_input_tokens:r.cache_write_input_tokens,output_tokens:r.output_tokens,total_tokens:r.total_tokens,cached_input_ratio:r.cached_input_ratio,estimated_cached_characters:r.estimated_cached_characters,_live_state:n._usage_live_state,_live_pending:n._usage_live_pending,_usage_flushed:n._usage_flushed}:null},storeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&((!this.skippedLiveUsageByRequestId||typeof this.skippedLiveUsageByRequestId!=`object`||Array.isArray(this.skippedLiveUsageByRequestId))&&(this.skippedLiveUsageByRequestId={}),this.skippedLiveUsageByRequestId[t]=e)},removeSkippedLiveUsage(e){let t=String(e&&e.request_id||``).trim();t&&this.skippedLiveUsageByRequestId&&delete this.skippedLiveUsageByRequestId[t]},liveUsageEntryCached(e){let t=String(e&&e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`||!!(e&&e.cache_hit)},liveUsageEventFlushed(e){let t=String(e&&e._live_state||``).trim();return!!(e&&e._usage_flushed)||t===`usage.failed`||t===`usage.flushed`},liveUsageStateRank(e){switch(String(e||``).trim()){case`usage.completed`:return 10;case`usage.failed`:case`usage.flushed`:return 20;default:return 0}},liveUsageStateAfter(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return this.liveUsageStateRank(n)>this.liveUsageStateRank(r)?n:r},applyLiveUsageToAudit(e){let t=String(e&&e.request_id||``).trim();if(!t||!this.auditLog||!Array.isArray(this.auditLog.entries))return;let n=this.auditLog.entries.findIndex(e=>String(e.request_id||``).trim()===t);if(n>=0){let t=this.auditLog.entries[n];this.auditLog.entries.splice(n,1,this.auditEntryWithLiveUsage(t,e)),this.auditLog.entries=[...this.auditLog.entries]}let r=this.auditThreadChildren;if(!r||typeof r!=`object`)return;let i=r,a=!1;Object.keys(r).forEach(n=>{let r=i[n],o=r&&Array.isArray(r.entries)?r.entries:[],s=o.findIndex(e=>String(e.request_id||``).trim()===t);if(s<0)return;let c=[...o];c.splice(s,1,this.auditEntryWithLiveUsage(o[s],e)),i={...i,[n]:{...r,entries:c}},a=!0}),a&&(this.auditThreadChildren=i)},auditEntryWithLiveUsage(e,t){let n=this.liveUsageStateAfter(e._usage_live_state,t._live_state||`usage.completed`),r=this.liveUsageEventFlushed({_live_state:n,_usage_flushed:e._usage_flushed||t._usage_flushed});return{...e,usage:this.liveUsageSummary(t,e.usage),_usage_live_state:n||`usage.completed`,_usage_live_pending:!r,_usage_flushed:r}},liveUsageSummary(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{},r=this.liveNumber(e.input_tokens,this.liveNumber(n.input_tokens,0)),i=this.liveNumber(e.output_tokens,this.liveNumber(n.output_tokens,0)),a=this.liveNumber(e.uncached_input_tokens,this.liveNumber(n.uncached_input_tokens,0)),o=this.liveNumber(e.cached_input_tokens,this.liveNumber(n.cached_input_tokens,0)),s=this.liveNumber(e.cache_write_input_tokens,this.liveNumber(n.cache_write_input_tokens,0));r>0&&a+o+s===0&&(a=r);let c=a+o+s||r,l=c+i||this.liveNumber(e.total_tokens,this.liveNumber(n.total_tokens,0)),u=this.liveNumber(e.cached_input_ratio,this.liveNumber(n.cached_input_ratio,c>0?o/c:0));return{entries:Math.max(1,this.liveNumber(e.entries,this.liveNumber(n.entries,1))),input_tokens:c,uncached_input_tokens:a,cached_input_tokens:o,cache_write_input_tokens:s,output_tokens:i,total_tokens:l,cached_input_ratio:u,estimated_cached_characters:this.liveNumber(e.estimated_cached_characters,this.liveNumber(n.estimated_cached_characters,o*4))}},liveNumber(e,t){let n=Number(e);return Number.isFinite(n)?n:t},auditEntryShouldFetchDetail(e){return!e||e._detail_loading||e._detail_loaded||this.auditEntryLiveDetailPending(e)?!1:this.auditEntryNeedsPersistedLiveDetail(e)||e.bodies_omitted?!0:!this.auditEntryHasDetailData(e)},auditEntryLiveDetailPending(e){if(!e||!e._live)return!1;let t=String(e._live_state||``).trim();return t===`audit.failed`||!e._audit_flushed&&t!==`audit.flushed`&&t!==`audit.detail`},auditEntryNeedsPersistedLiveDetail(e){return!!(e&&e._live&&!e._detail_loaded)},auditEntryHasDetailData(e){let t=e&&e.data;return!t||typeof t!=`object`?!1:t.request_headers!==void 0||t.response_headers!==void 0||t.request_body!==void 0||t.response_body!==void 0||t.request_body_too_big_to_handle!==void 0||t.response_body_too_big_to_handle!==void 0||t.user_agent!==void 0||t.api_key_hash!==void 0||t.temperature!==void 0||t.max_tokens!==void 0||t.error_message!==void 0||t.error_code!==void 0},clearAuditDetailLoading(e){if(!e)return;let t=String(e.id||``).trim(),n=String(e.request_id||``).trim(),r=this.auditLog&&Array.isArray(this.auditLog.entries)?this.auditLog.entries:[],i=r.find(e=>t&&String(e.id||``).trim()===t?!0:!!(n&&String(e.request_id||``).trim()===n)),a=i||e;a._detail_loading=!1,i&&(this.auditLog.entries=[...r])}}}var CC={"audit.started":10,"audit.updated":20,"audit.stream":20,"audit.completed":30,"audit.failed":40,"audit.flushed":40,"audit.detail":40},wC=new Set(Object.keys(CC));function TC(e){return String(e&&(e.id||e.request_id)||``).trim()}function EC(e,t){let n=e&&typeof e==`object`?e:{},r=t&&typeof t==`object`?t:{},i={...n,...r};r.data==null&&n.data!=null?i.data=n.data:kC(n.data)&&kC(r.data)&&(i.data={...n.data,...r.data});let a=String(n._live_state||``).trim(),o=String(r._live_state||``).trim();return(CC[a]||0)>(CC[o]||0)&&(i._live_state=a),n._audit_flushed&&(i._audit_flushed=!0),i._audit_flushed&&(i._live_pending=!1),n._detail_loaded&&!r._detail_loaded&&(i._detail_loaded=!0,i.bodies_omitted=!1),i.bodies_omitted&&kC(i.data)&&(i.data.request_body!==void 0||i.data.response_body!==void 0)&&(i.bodies_omitted=!1),i}function DC(e,t){let n=Number(t||0);return(Array.isArray(e)?e:[]).filter(e=>Number(e&&e.version||0)>n)}function OC(e){return wC.has(String(e&&e.eventType||``).trim())}function kC(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var AC=200,jC=class{#e=k(j({entries:[],total:0,limit:25,offset:0}));get auditLog(){return I(this.#e)}set auditLog(e){A(this.#e,e,!0)}#t=k(j({entries:[],total:0,limit:50,offset:0}));get usageLog(){return I(this.#t)}set usageLog(e){A(this.#t,e,!0)}#n=k(j({}));get auditRecords(){return I(this.#n)}set auditRecords(e){A(this.#n,e,!0)}#r=k(j([]));get auditRecordChanges(){return I(this.#r)}set auditRecordChanges(e){A(this.#r,e,!0)}auditRecordVersion=0;auditRecordPins=new Set;#i=k(``);get auditSearch(){return I(this.#i)}set auditSearch(e){A(this.#i,e,!0)}#a=k(``);get auditMethod(){return I(this.#a)}set auditMethod(e){A(this.#a,e,!0)}#o=k(``);get auditStatusCode(){return I(this.#o)}set auditStatusCode(e){A(this.#o,e,!0)}#s=k(``);get auditStream(){return I(this.#s)}set auditStream(e){A(this.#s,e,!0)}#c=k(Ta(`gomodel_audit_group_sessions`,`true`)!==`false`);get auditGroupSessions(){return I(this.#c)}set auditGroupSessions(e){A(this.#c,e,!0)}#l=k(j({}));get auditThreadChildren(){return I(this.#l)}set auditThreadChildren(e){A(this.#l,e,!0)}#u=k(``);get usageLogSearch(){return I(this.#u)}set usageLogSearch(e){A(this.#u,e,!0)}#d=k(``);get usageFilterModel(){return I(this.#d)}set usageFilterModel(e){A(this.#d,e,!0)}#f=k(``);get usageFilterProvider(){return I(this.#f)}set usageFilterProvider(e){A(this.#f,e,!0)}#p=k(``);get usageFilterLabel(){return I(this.#p)}set usageFilterLabel(e){A(this.#p,e,!0)}#m=k(``);get usageFilterUserPath(){return I(this.#m)}set usageFilterUserPath(e){A(this.#m,e,!0)}#h=k(!1);get usageLogHideCached(){return I(this.#h)}set usageLogHideCached(e){A(this.#h,e,!0)}#g=k(!1);get liveLogsStreaming(){return I(this.#g)}set liveLogsStreaming(e){A(this.#g,e,!0)}liveLogsLastSeq=0;liveLogsReconnectAttempts=0;liveLogsReconnectTimer=null;liveLogsController=null;skippedLiveUsageByRequestId=null;fetchUsage=null;fetchAuditLog=null;isAuditEntryExpanded=null;noteLiveTokenUsage=null;upsertAuditRecord(e,t=``){let n=TC(e);if(!n)return e;let r=EC(this.auditRecords[n],e);return this.auditRecords={...this.auditRecords,[n]:r},this.pruneAuditRecords(),this.auditRecordVersion++,this.auditRecordChanges=[...this.auditRecordChanges,{version:this.auditRecordVersion,key:n,eventType:t}].slice(-512),r}upsertAuditRecords(e,t=``){return(Array.isArray(e)?e:[]).map(e=>this.upsertAuditRecord(e,t))}auditRecord(e){let t=typeof e==`string`?String(e).trim():TC(e);return t&&this.auditRecords[t]||null}cacheAuditRecord(e,t){return this.upsertAuditRecord(e,t)}pinAuditRecords(e){this.auditRecordPins=new Set((Array.isArray(e)?e:[]).map(String))}pruneAuditRecords(){let e=Object.keys(this.auditRecords);if(e.length<=AC)return;let t={...this.auditRecords},n=e.length-AC;for(let r of e){if(n<=0)break;this.auditRecordPins.has(r)||(delete t[r],n--)}this.auditRecords=t}get page(){return Jo.page}get customStartDate(){return Mc.customStartDate}get customEndDate(){return Mc.customEndDate}get followsToday(){return Mc.followsToday}liveLogsEnabled(){return Ss.liveLogsVisible()}async startLiveLogs(){typeof fetch!=`function`||typeof ReadableStream>`u`||(await Ss.ensureLoaded(),this.liveLogsEnabled()&&(this.stopLiveLogs(),this.liveLogsController=typeof AbortController==`function`?new AbortController:null,this.readLiveLogsStream(this.liveLogsController)))}stopLiveLogs(){this.liveLogsStreaming=!1,this.liveLogsReconnectTimer&&=(clearTimeout(this.liveLogsReconnectTimer),null),this.liveLogsController&&typeof this.liveLogsController.abort==`function`&&this.liveLogsController.abort(),this.liveLogsController=null}ensureLiveLogs(){this.liveLogsController||this.liveLogsReconnectTimer||this.startLiveLogs()}async readLiveLogsStream(e){let t={};e&&(t.signal=e.signal);let n=xC(this.liveLogsLastSeq),r=K.generation;try{let i=await hs(n,t);if(i.status===401){if(K.handleUnauthorized(r),r{this.liveLogsReconnectTimer=null,this.startLiveLogs()},t)}async fetchAuditEntryDetail(e){if(!this.auditEntryShouldFetchDetail(e))return;let t=String(e.id||``).trim();if(!t)return;e._detail_loading=!0;let n=e;try{let e=await _s(`/admin/audit/detail?log_id=`+encodeURIComponent(t),{label:`audit detail`});if(e.stale||!e.ok)return;n=this.mergeLiveAuditEntry(e.data,`audit.detail`)||n}catch(e){console.error(`Failed to fetch audit detail:`,e)}finally{this.clearAuditDetailLoading(n)}}};Object.assign(jC.prototype,SC());var MC=new jC;if(typeof window<`u`){let e=!1;window.addEventListener(`pagehide`,()=>{e=!!MC.liveLogsController,MC.stopLiveLogs()}),window.addEventListener(`pageshow`,t=>{t.persisted&&e&&MC.ensureLiveLogs()})}var NC=null;Mn(()=>{An(()=>{let e=K.refreshTick;if(NC===null){NC=e;return}e!==NC&&(NC=e,Er(()=>{MC.stopLiveLogs(),MC.startLiveLogs()}))})});function PC(){return{total_requests:0,total_input_tokens:0,total_output_tokens:0,total_tokens:0,uncached_input_tokens:0,cached_input_tokens:0,cache_write_input_tokens:0,total_input_cost:null,total_output_cost:null,total_cost:null,rewrite_tokens_saved:0,rewrite_cost_saved:null}}function FC(){return{entries:[],total:0,limit:50,offset:0}}function IC(e,t){let n=[[`model`,e&&e.model],[`provider`,e&&e.provider],[`label`,e&&e.label],[`user_path`,e&&e.user_path]],r=``;for(let[e,i]of n)!i||e===t||(r+=`&`+e+`=`+encodeURIComponent(i));return r}function LC({limit:e,offset:t,hideCached:n,search:r}){let i=`&limit=`+e+`&offset=`+t;return i+=`&cache_mode=`+(n?`uncached`:`all`),r&&(i+=`&search=`+encodeURIComponent(r)),i}function RC(e,t){let n=new Set(e||[]);return t&&n.add(t),[...n].sort()}function zC(e,t){let n=Number(t&&t.total_requests||0)-Number(e&&e.total_requests||0);return Number.isFinite(n)&&n>0?n:0}function BC(e,t,n){let r=n?e:t,i=Number(r&&r.total_requests||0);return Number.isFinite(i)?i:0}function VC(e,t,n){let r=zC(e,t);return r<=0?``:n?oc(r)+` cached requests hidden`:oc(Number(e&&e.total_requests||0))+` to providers + `+oc(r)+` from cache`}function HC(e){let t=e||{};return t.total_input_cost===null||t.total_input_cost===void 0?``:sc(t.total_input_cost)+` input + `+sc(t.total_output_cost)+` output`}function UC(e){let t=Number(e&&e.rewrite_tokens_saved||0);return Number.isFinite(t)&&t>0?t:0}function WC(e){return UC(e)>0}function GC(e){let t=e||{};return t.rewrite_cost_saved===void 0?null:t.rewrite_cost_saved}function KC(){return`Estimated at 4 net characters removed per token`}function qC(e,t){return t===`costs`?sc(GC(e)):uc(UC(e))}function JC(e,t){let n=t===`costs`,r=n?Number(GC(e)):UC(e);if(!Number.isFinite(r)||r<=0)return null;let i=e&&(n?e.total_cost:e.total_input_tokens);if(i==null)return null;let a=Number(i);return!Number.isFinite(a)||a<0?null:r/(a+r)*100}function YC(e,t){let n=JC(e,t);return n===null?``:(n<.1?`<0.1`:n.toFixed(1))+`% less`}function XC(e,t){let n=UC(e);if(n<=0)return``;let r=[oc(n)+` estimated prompt token-transmissions removed across provider requests`,KC(),`Savings are summed per provider request; resent conversation history is counted again`],i=GC(e);i!=null&&(r.push(sc(i)+` estimated gross input cost avoided`),r.push(`Prompt-cache changes caused by rewriting are not included`));let a=YC(e,t);return a&&r.push(a+` than the same traffic without rewriting (`+(t===`costs`?`cost`:`tokens`)+`)`),r.join(` -`)}function ZC(e){return String(e&&e.cost_source||``).trim()}function QC(e){let t=ZC(e);return t===`openrouter_credits`||t===`xai_cost_in_usd_ticks`}function $C(e){switch(ZC(e)){case`openrouter_credits`:return`Costs from OpenRouter USD-based credits.`;case`xai_cost_in_usd_ticks`:return`Costs from xAI usage.cost_in_usd_ticks.`;default:return``}}function ew(e){return String(e&&e.cache_type||``).trim().toLowerCase()}function tw(e){let t=ew(e);return t===`exact`||t===`semantic`}function nw(e){let t=ew(e);return t===`exact`?`Exact`:t===`semantic`?`Semantic`:`-`}function rw(e,t){let n=t?String(t):``;return tw(e)?n?`Saved by cache — not charged -`+n:`Saved by cache — not charged`:n}function iw(e){let t=Number(e&&e.cached_input_ratio);return!Number.isFinite(t)||t<=0?0:Math.min(1,t)}function aw(e){return Number(e&&e.cached_input_tokens||0)>0}function ow(e){return aw(e)?(iw(e)*100).toFixed(1)+`%`:``}function sw(e){if(!aw(e))return``;let t=Number(e.cached_input_tokens||0),n=Number(e.uncached_input_tokens||0),r=Number(e.cache_write_input_tokens||0),i=t+n+r,a=[oc(t)+` cached / `+oc(i)+` input tokens`];return r>0&&a.push(oc(r)+` cache write`),a.join(` -`)}function cw(e){let t=[];if($C(e)&&(t.push($C(e)),t.push(``)),t.push(`Input: `+sc(e.input_cost)),t.push(`Output: `+sc(e.output_cost)),e.raw_data){t.push(``);for(let[n,r]of Object.entries(e.raw_data)){let e=n.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),i=r&&typeof r==`object`?JSON.stringify(r):oc(r);t.push(e+`: `+i)}}return t.join(` -`)}function lw(e){return Array.isArray(e&&e.labels)?e.labels:[]}function uw(e,t,n){return(e||[]).length>0||t?!0:(n||[]).some(e=>lw(e).length>0)}function dw(e){return e&&typeof e.total_tokens==`number`?e.total_tokens:(e&&e.input_tokens||0)+(e&&e.output_tokens||0)}function fw(e,t){return t?e.total_cost||0:dw(e)}function pw(e,t){return[...e||[]].sort((e,n)=>t?(n.total_cost||0)-(e.total_cost||0):fw(n,t)-fw(e,t))}function mw(e){let t=Array.isArray(e)?e:[];if(t.length===0)return!1;if(t.length!==1)return!0;let n=String(t[0]&&t[0].user_path||``).trim();return n!==``&&n!==`/`}function hw(e){return(e||`chart`)===`chart`||e===`stacked`}function gw(e,t,n){let r=pw(e,n),i=e=>Number(e)||0,a=e=>n?Math.min(i(e.cached_input_cost),i(e.input_cost)):i(e.cached_input_tokens),o=e=>n?i(e.input_cost)-a(e):i(e.uncached_input_tokens)+i(e.cached_input_tokens)+i(e.cache_write_input_tokens)>0?i(e.uncached_input_tokens)+i(e.cache_write_input_tokens):i(e.input_tokens),s=e=>i(n?e.output_cost:e.output_tokens),c=e=>n?0:i(e.local_cached_input_tokens),l=e=>n?0:i(e.local_cached_output_tokens),u=r.slice(0,10),d=r.slice(10),f=u.map(t),p=u.map(o),m=u.map(s),h=u.map(a),g=u.map(c),_=u.map(l);if(d.length>0){f.push(`Other`);let e=e=>d.reduce((t,n)=>t+e(n),0);p.push(e(o)),m.push(e(s)),h.push(e(a)),g.push(e(c)),_.push(e(l))}return{labels:f,inputs:p,outputs:m,prompts:h,localIns:g,localOuts:_}}function _w(e){return Math.max(200,e*32+72)}var J=new class{#e=k(`tokens`);get usageMode(){return I(this.#e)}set usageMode(e){A(this.#e,e,!0)}get usageFilterModel(){return MC.usageFilterModel}set usageFilterModel(e){MC.usageFilterModel=e}get usageFilterProvider(){return MC.usageFilterProvider}set usageFilterProvider(e){MC.usageFilterProvider=e}get usageFilterLabel(){return MC.usageFilterLabel}set usageFilterLabel(e){MC.usageFilterLabel=e}get usageFilterUserPath(){return MC.usageFilterUserPath}set usageFilterUserPath(e){MC.usageFilterUserPath=e}#t=k(j({models:[],providers:[],labels:[]}));get usageFacetOptions(){return I(this.#t)}set usageFacetOptions(e){A(this.#t,e,!0)}#n=k(j(PC()));get usageSummary(){return I(this.#n)}set usageSummary(e){A(this.#n,e,!0)}#r=k(j(PC()));get usageSummaryAll(){return I(this.#r)}set usageSummaryAll(e){A(this.#r,e,!0)}#i=k(j([]));get modelUsage(){return I(this.#i)}set modelUsage(e){A(this.#i,e,!0)}#a=k(j([]));get userPathUsage(){return I(this.#a)}set userPathUsage(e){A(this.#a,e,!0)}#o=k(j([]));get labelUsage(){return I(this.#o)}set labelUsage(e){A(this.#o,e,!0)}get usageLog(){return MC.usageLog}set usageLog(e){MC.usageLog=e}get usageLogSearch(){return MC.usageLogSearch}set usageLogSearch(e){MC.usageLogSearch=e}get usageLogHideCached(){return MC.usageLogHideCached}set usageLogHideCached(e){MC.usageLogHideCached=e}#s=k(`chart`);get modelUsageView(){return I(this.#s)}set modelUsageView(e){A(this.#s,e,!0)}#c=k(`chart`);get userPathUsageView(){return I(this.#c)}set userPathUsageView(e){A(this.#c,e,!0)}#l=k(`chart`);get labelUsageView(){return I(this.#l)}set labelUsageView(e){A(this.#l,e,!0)}#u=k(!1);get summaryLoading(){return I(this.#u)}set summaryLoading(e){A(this.#u,e,!0)}#d=k(!1);get modelUsageLoading(){return I(this.#d)}set modelUsageLoading(e){A(this.#d,e,!0)}#f=k(!1);get userPathUsageLoading(){return I(this.#f)}set userPathUsageLoading(e){A(this.#f,e,!0)}#p=k(!1);get labelUsageLoading(){return I(this.#p)}set labelUsageLoading(e){A(this.#p,e,!0)}#m=k(!1);get usageLogLoading(){return I(this.#m)}set usageLogLoading(e){A(this.#m,e,!0)}#h={};#g(e){this.#h[e]&&this.#h[e].abort();let t=new AbortController;return this.#h[e]=t,t}#_(e,t){this.#h[e]===t&&(this.#h[e]=null)}filterQueryStr(e){return IC({model:this.usageFilterModel,provider:this.usageFilterProvider,label:this.usageFilterLabel,user_path:this.usageFilterUserPath},e)}onUsageFilterChanged(){this.fetchUsagePage()}toggleUsageLabelFilter(e){this.usageFilterLabel=this.usageFilterLabel===e?``:e,this.onUsageFilterChanged()}usageLabelChipTitle(e){return this.usageFilterLabel===e?`Clear label filter`:`Filter usage by "`+e+`"`}toggleUsageMode(e){this.usageMode=e,Jo.navigate(`usage`,e===`costs`?`costs`:null)}toggleUsageChartView(e,t){e===`model`&&(this.modelUsageView=t),e===`userPath`&&(this.userPathUsageView=t),e===`label`&&(this.labelUsageView=t)}usageFilterModelOptions(){return RC(this.usageFacetOptions.models,this.usageFilterModel)}usageFilterProviderOptions(){return RC(this.usageFacetOptions.providers,this.usageFilterProvider)}usageFilterLabelOptions(){return RC(this.usageFacetOptions.labels,this.usageFilterLabel)}async fetchUsagePage(){await Ss.ensureLoaded();let e=[this.fetchUsagePageSummary(),this.fetchUsageFacetOptions(),this.fetchModelUsage(),this.fetchUserPathUsage(),this.fetchLabelUsage(),this.fetchUsageLog(!0)];Rc.cacheAnalyticsEnabled()&&e.push(Rc.fetchCacheOverview(this.filterQueryStr())),await Promise.all(e)}async fetchUsagePageSummary(){let e=this.#g(`summary`);this.summaryLoading=!0;try{let t=Mc.queryStr()+this.filterQueryStr(),[n,r]=await Promise.all([_s(`/admin/usage/summary?`+t+`&cache_mode=uncached`,{label:`usage page summary`,signal:e.signal}),_s(`/admin/usage/summary?`+t+`&cache_mode=all`,{label:`usage page summary (all)`,signal:e.signal})]);if(n.stale||r.stale||e.signal.aborted)return;if(!n.ok||!r.ok){this.usageSummary=PC(),this.usageSummaryAll=PC();return}this.usageSummary=n.data&&typeof n.data==`object`?n.data:PC(),this.usageSummaryAll=r.data&&typeof r.data==`object`?r.data:PC()}catch(e){if(ys(e))return;console.error(`Failed to fetch usage page summary:`,e),this.usageSummary=PC(),this.usageSummaryAll=PC()}finally{this.#_(`summary`,e),this.#h.summary===null&&(this.summaryLoading=!1)}}async fetchUsageFacetOptions(){let e=this.#g(`facets`);try{let t=async(t,n)=>{let r=await _s(t+`?`+Mc.queryStr()+this.filterQueryStr(n),{label:`usage facet options`,signal:e.signal});return r.stale?null:r.ok&&Array.isArray(r.data)?r.data:[]},n=t(`/admin/usage/models`,`model`),r=!this.usageFilterModel&&!this.usageFilterProvider,[i,a,o]=await Promise.all([n,r?n:t(`/admin/usage/models`,`provider`),t(`/admin/usage/labels`,`label`)]);if(e.signal.aborted||i===null||a===null||o===null)return;this.usageFacetOptions={models:i.map(e=>e&&e.model).filter(Boolean),providers:a.map(e=>gc(e)).filter(Boolean),labels:o.map(e=>e&&e.label).filter(Boolean)}}catch(e){if(ys(e))return;console.error(`Failed to fetch usage facet options:`,e),this.usageFacetOptions={models:[],providers:[],labels:[]}}finally{this.#_(`facets`,e)}}async#v(e,t,n,r,i){let a=this.#g(e);i(!0);try{let e=await _s(t+`?`+Mc.queryStr()+this.filterQueryStr(),{label:n,signal:a.signal});if(e.stale||a.signal.aborted)return;if(!e.ok){r([]);return}r(Array.isArray(e.data)?e.data:[])}catch(e){if(ys(e))return;console.error(`Failed to fetch `+n+`:`,e),r([])}finally{this.#_(e,a),this.#h[e]===null&&i(!1)}}fetchModelUsage(){return this.#v(`modelUsage`,`/admin/usage/models`,`usage models`,e=>this.modelUsage=e,e=>this.modelUsageLoading=e)}fetchUserPathUsage(){return this.#v(`userPathUsage`,`/admin/usage/user-paths`,`usage user paths`,e=>this.userPathUsage=e,e=>this.userPathUsageLoading=e)}fetchLabelUsage(){return this.#v(`labelUsage`,`/admin/usage/labels`,`usage labels`,e=>this.labelUsage=e,e=>this.labelUsageLoading=e)}async fetchUsageLog(e){let t=this.#g(`usageLog`);this.usageLogLoading=!0;try{e&&(this.usageLog.offset=0);let n=Mc.queryStr()+this.filterQueryStr();n+=LC({limit:this.usageLog.limit,offset:this.usageLog.offset,hideCached:this.usageLogHideCached,search:this.usageLogSearch});let r=await _s(`/admin/usage/log?`+n,{label:`usage log`,signal:t.signal});if(r.stale||t.signal.aborted)return;if(!r.ok){this.usageLog=FC();return}let i=r.data&&typeof r.data==`object`?r.data:FC();i.entries||=[],this.usageLog=i}catch(e){if(ys(e))return;console.error(`Failed to fetch usage log:`,e),this.usageLog=FC()}finally{this.#_(`usageLog`,t),this.#h.usageLog===null&&(this.usageLogLoading=!1)}}usageLogNextPage(){this.usageLog.offset+this.usageLog.limit0&&(this.usageLog.offset=Math.max(0,this.usageLog.offset-this.usageLog.limit),this.fetchUsageLog(!1))}};MC.fetchUsage=()=>{Jo.page===`usage`&&J.fetchUsagePage()};var vw=R(`
                        `);function yw(e,t){E(t,!0);let n=ya(t,`value`,15,``),r=ya(t,`placeholder`,3,``),i=ya(t,`label`,3,``),a=ya(t,`id`,3,void 0),o=ya(t,`oninput`,3,void 0),s=ya(t,`class`,3,``);var c=vw(),l=M(c);G(l,{get icon(){return vo},class:`filter-input-icon`});var u=P(l,2);na(u),T(c),F(()=>{U(c,1,Fi([`filter-input-wrap`,s()]),`svelte-30xz1k`),W(u,`id`,a()),W(u,`placeholder`,r()),W(u,`aria-label`,i())}),L(`input`,u,function(...e){o()?.apply(this,e)}),da(u,n),z(e,c),D()}Hr([`input`]);function bw(e,t=300){let n=null,r=(...r)=>{clearTimeout(n),n=setTimeout(()=>{n=null,e(...r)},t)};return r.cancel=()=>{clearTimeout(n),n=null},r}var xw=R(``),Sw=R(``),Cw=R(`
                        `);function ww(e,t){E(t,!0);let n=bw(()=>J.onUsageFilterChanged());An(()=>n.cancel);var r=Cw(),i=M(r),a=M(i);a.value=a.__value=``,H(P(a),16,()=>J.usageFilterModelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(i);var o=P(i,2),s=M(o);s.value=s.__value=``,H(P(s),16,()=>J.usageFilterProviderOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(o);var c=P(o,2),l=e=>{var t=Sw(),n=M(t);n.value=n.__value=``,H(P(n),16,()=>J.usageFilterLabelOptions(),e=>e,(e,t)=>{var n=xw(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(t),L(`change`,t,()=>J.onUsageFilterChanged()),Gi(t,()=>J.usageFilterLabel,e=>J.usageFilterLabel=e),z(e,t)},u=O(()=>J.usageFilterLabelOptions().length>0);V(c,e=>{I(u)&&e(l)}),yw(P(c,2),{class:`usage-page-filters-user-path`,placeholder:`User path /team/alpha`,label:`Filter by user path`,get oninput(){return n},get value(){return J.usageFilterUserPath},set value(e){J.usageFilterUserPath=e}}),T(r),L(`change`,i,()=>J.onUsageFilterChanged()),Gi(i,()=>J.usageFilterModel,e=>J.usageFilterModel=e),L(`change`,o,()=>J.onUsageFilterChanged()),Gi(o,()=>J.usageFilterProvider,e=>J.usageFilterProvider=e),z(e,r),D()}Hr([`change`]);var Tw=R(`
                        Cache Saved
                        Cache Hits
                        `,1);function Ew(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=Tw(),n=N(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var a=P(n,2),o=P(M(a),2),s=M(o,!0);T(o),T(a),F((e,t)=>{B(i,e),B(s,t)},[()=>sc(Rc.cacheOverview.summary.total_saved_cost),()=>oc(Rc.cacheOverview.summary.total_hits)]),z(e,t)},a=O(()=>Rc.cacheAnalyticsEnabled());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}var Dw=R(` `),Ow=R(`
                        Pro Saved
                        `),kw=R(`
                        Total Requests
                        Estimated Cost
                        `);function Aw(e,t){E(t,!0);let n=O(()=>WC(J.usageSummary)),r=O(()=>qC(J.usageSummary,J.usageMode)),i=O(()=>YC(J.usageSummary,J.usageMode));var a=kw(),o=M(a),s=P(M(o),2),c=M(s),l=e=>{SS(e,{size:18,label:`Loading usage summary`})},u=e=>{var t=Zr();F(e=>B(t,e),[()=>oc(BC(J.usageSummary,J.usageSummaryAll,J.usageLogHideCached))]),z(e,t)};V(c,e=>{J.summaryLoading?e(l):e(u,-1)}),T(s),T(o);var d=P(o,2),f=P(M(d),2),p=M(f),m=e=>{SS(e,{size:18,label:`Loading usage summary`})},h=e=>{var t=Zr();F(e=>B(t,e),[()=>sc(J.usageSummary.total_cost)]),z(e,t)};V(p,e=>{J.summaryLoading?e(m):e(h,-1)}),T(f),T(d);var g=P(d,2),_=e=>{var t=Ow(),n=P(M(t),2),a=M(n),o=M(a,!0);T(a);var s=P(a,2),c=e=>{var t=Dw(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)};V(s,e=>{I(i)&&e(c)}),T(n),T(t),F(e=>{W(n,`title`,e),B(o,I(r))},[()=>XC(J.usageSummary,J.usageMode)]),z(e,t)};V(g,e=>{I(n)&&e(_)}),Ew(P(g,2),{}),T(a),F((e,t)=>{W(s,`title`,e),W(f,`title`,t)},[()=>VC(J.usageSummary,J.usageSummaryAll,J.usageLogHideCached),()=>HC(J.usageSummary)]),z(e,a),D()}function jw(e,t,n,r){let{stacked:i=!1,costs:a=!1,resolve:o=e=>e}=r||{},s=e=>a?`$`+Math.abs(e).toFixed(2):uc(Math.abs(e)),c=e=>a?`$`+Math.abs(e).toFixed(4):Math.abs(e).toLocaleString(),l=e=>e.map(e=>i?Math.abs(e):-Math.abs(e)),u=(e,t,n)=>({label:e,data:t,backgroundColor:n,borderColor:`transparent`,borderWidth:0,borderRadius:4,maxBarThickness:22}),d=e=>(e||[]).some(e=>Math.abs(e)>0),f=[u(a?`Input Cost`:`Input Tokens`,l(n.inputs),o(`var(--token-input)`)),u(a?`Output Cost`:`Output Tokens`,n.outputs,o(`var(--token-output)`))];return d(n.prompts)&&f.push(u(a?`Prompt Cached Cost`:`Prompt Cached`,l(n.prompts),o(`var(--token-prompt)`))),!a&&d(n.localIns)&&f.push(u(`Locally Cached (Input)`,l(n.localIns),o(`var(--token-local)`))),!a&&d(n.localOuts)&&f.push(u(`Locally Cached (Output)`,n.localOuts,o(`var(--token-local)`))),{type:`bar`,data:{labels:t,datasets:f},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,animation:{duration:0},layout:{padding:{top:8}},scales:{x:{stacked:!0,beginAtZero:!0,grid:i?{color:e.grid}:{color:t=>t.tick&&t.tick.value===0?e.text:e.grid},border:{display:!1},ticks:{color:e.text,font:Ly(),callback:e=>s(e)}},y:{stacked:!0,grid:{display:!1},border:{display:!1},ticks:{color:e.text,font:Ly(),autoSkip:!1}}},plugins:{legend:{labels:{color:e.text,font:{size:12}}},tooltip:Ry(e,{label:e=>e.dataset.label+`: `+c(e.parsed.x),footer:e=>{let t=0;return e.forEach(e=>{t+=Math.abs(Number(e.parsed.x))||0}),`Total: `+c(t)}})}}}}var Mw=R(`
                        `),Nw=R(`

                        `),Pw=R(`

                        `,1),Fw=R(`
                        `),Iw=R(`Model Provider`,1),Lw=R(`User Path`),Rw=R(`Label Requests`,1),zw=R(` `,1),Bw=R(` `),Vw=R(` `,1),Hw=R(` `),Uw=R(`
                        Input TokensOutput TokensPrompt CachedLocal CachedTotal TokensInput CostOutput CostTotal Cost
                        `),Ww=R(`
                        `),Gw=R(`
                        `);function Kw(e,t){E(t,!0);let n=e=>{var n=Mw(),r=M(n);let a;var o=P(r,2);let s;var l=P(o,2);let u;T(n),F(()=>{W(n,`aria-label`,I(i).group),a=U(r,1,`chart-view-btn svelte-1kee4g8`,null,a,{active:I(c)===`chart`}),W(r,`aria-pressed`,I(c)===`chart`),W(r,`aria-label`,`Show ${I(i).noun??``} chart`),s=U(o,1,`chart-view-btn svelte-1kee4g8`,null,s,{active:I(c)===`stacked`}),W(o,`aria-pressed`,I(c)===`stacked`),W(o,`aria-label`,`Show ${I(i).noun??``} stacked chart`),u=U(l,1,`chart-view-btn svelte-1kee4g8`,null,u,{active:I(c)===`table`}),W(l,`aria-pressed`,I(c)===`table`),W(l,`aria-label`,`Show ${I(i).noun??``} table`)}),L(`click`,r,()=>J.toggleUsageChartView(t.kind,`chart`)),L(`click`,o,()=>J.toggleUsageChartView(t.kind,`stacked`)),L(`click`,l,()=>J.toggleUsageChartView(t.kind,`table`)),z(e,n)},r={model:{group:`Model usage view`,noun:`model usage`,tokensTitle:`Token Usage by Model`,costsTitle:`Cost by Model`},userPath:{group:`User path usage view`,noun:`user path usage`,tokensTitle:`Usage by User Path`,costsTitle:`Cost by User Path`},label:{group:`Label usage view`,noun:`label usage`,tokensTitle:`Usage by Label`,costsTitle:`Cost by Label`}},i=O(()=>r[t.kind]),a=O(()=>t.kind===`model`?e=>vc(e):t.kind===`userPath`?e=>e.user_path||`/`:e=>e.label);function o(e){return t.kind===`model`?(e.provider_name||e.provider||`-`)+`/`+e.model:t.kind===`userPath`?e.user_path||`/`:e.label}let s=O(()=>t.kind===`model`?J.modelUsage:t.kind===`userPath`?J.userPathUsage:J.labelUsage),c=O(()=>t.kind===`model`?J.modelUsageView:t.kind===`userPath`?J.userPathUsageView:J.labelUsageView),l=O(()=>t.kind===`model`?J.modelUsageLoading:t.kind===`userPath`?J.userPathUsageLoading:J.labelUsageLoading),u=O(()=>J.usageMode===`costs`),d=O(()=>t.kind===`userPath`?mw(I(s)):I(s).length>0),f=O(()=>I(u)?I(i).costsTitle:I(i).tokensTitle),p=O(()=>gw(I(s),I(a),I(u))),m=O(()=>pw(I(s),I(u)));function h(){return hw(I(c))?jw(Iy(),I(p).labels,I(p),{stacked:I(c)===`stacked`,costs:I(u),resolve:zy}):null}var g=Qr(),_=N(g),v=e=>{var r=Ww(),a=M(r),s=M(a),u=e=>{qS(e,{copyId:`label-usage-help-copy`,label:`label usage help`,text:`One request can have multiple labels. Such a request counts once under each of its labels, so label rows can overlap and add up to more than the period totals.`,title:e=>{var t=Nw(),n=M(t,!0);T(t),F(()=>B(n,I(f))),z(e,t)},extra:e=>{var t=Qr(),n=N(t),r=e=>{SS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(n,e=>{I(l)&&e(r)}),z(e,t)},$$slots:{title:!0,extra:!0}})},d=e=>{var t=Pw(),n=N(t),r=M(n,!0);T(n);var a=P(n,2),o=e=>{SS(e,{size:14,get label(){return`Loading ${I(i).noun??``}`}})};V(a,e=>{I(l)&&e(o)}),F(()=>B(r,I(f))),z(e,t)};V(s,e=>{t.kind===`label`?e(u):e(d,-1)});var g=P(s,2);n(g),T(a);var _=P(a,2),v=e=>{var t=Fw();let n;jy(M(t),{build:h}),T(t),F(e=>n=Hi(t,``,n,e),[()=>({height:`${_w(I(p).labels.length)??``}px`})]),z(e,t)},y=O(()=>hw(I(c))),b=e=>{var n=Uw(),r=M(n),i=M(r),a=M(i),s=M(a),c=e=>{var t=Iw();Ue(2),z(e,t)},l=e=>{z(e,Lw())},u=e=>{var t=Rw();Ue(2),z(e,t)};V(s,e=>{t.kind===`model`?e(c):t.kind===`userPath`?e(l,1):e(u,-1)}),Ue(8),T(a),T(i);var d=P(i);H(d,21,()=>I(m),e=>o(e),(e,n)=>{var r=Hw(),i=M(r),a=e=>{var t=zw(),r=N(t),i=M(r,!0);T(r);var a=P(r,2),o=M(a),s=M(o,!0);T(o),T(a),F(e=>{B(i,I(n).model||`-`),B(s,e)},[()=>gc(I(n))||`-`]),z(e,t)},o=e=>{var t=Bw(),r=M(t,!0);T(t),F(()=>B(r,I(n).user_path||`/`)),z(e,t)},s=e=>{var t=Vw(),r=N(t),i=M(r);let a;var o=M(i,!0);T(i),T(r);var s=P(r,2),c=M(s,!0);T(s),F((e,t,r)=>{a=U(i,1,`usage-label-chip`,null,a,{active:J.usageFilterLabel===I(n).label}),Hi(i,`--label-color: ${e??``}`),W(i,`title`,t),B(o,I(n).label),B(c,r)},[()=>Hy(I(n).label),()=>J.usageLabelChipTitle(I(n).label),()=>oc(I(n).requests)]),L(`click`,i,()=>J.toggleUsageLabelFilter(I(n).label)),z(e,t)};V(i,e=>{t.kind===`model`?e(a):t.kind===`userPath`?e(o,1):e(s,-1)});var c=P(i),l=M(c,!0);T(c);var u=P(c),d=M(u,!0);T(u);var f=P(u),p=M(f,!0);T(f);var m=P(f),h=M(m,!0);T(m);var g=P(m),_=M(g,!0);T(g);var v=P(g),y=M(v,!0);T(v);var b=P(v),x=M(b,!0);T(b);var S=P(b),C=M(S,!0);T(S),T(r),F((e,t,n,r,i,a,o,s,c,u,g)=>{B(l,e),B(d,t),W(f,`title`,n),B(p,r),W(m,`title`,`${i??``} input + ${a??``} output`),B(h,o),B(_,s),B(y,c),B(x,u),B(C,g)},[()=>oc(I(n).input_tokens),()=>oc(I(n).output_tokens),()=>I(n).cached_input_cost==null?``:`~`+sc(I(n).cached_input_cost)+` at current cached-input pricing`,()=>oc(I(n).cached_input_tokens||0),()=>oc(I(n).local_cached_input_tokens||0),()=>oc(I(n).local_cached_output_tokens||0),()=>oc((I(n).local_cached_input_tokens||0)+(I(n).local_cached_output_tokens||0)),()=>oc(dw(I(n))),()=>sc(I(n).input_cost),()=>sc(I(n).output_cost),()=>sc(I(n).total_cost)]),z(e,r)}),T(d),T(r),T(n),z(e,n)};V(_,e=>{I(y)?e(v):e(b,-1)}),T(r),z(e,r)},y=e=>{var t=Gw();SS(M(t),{size:20,get label(){return`Loading ${I(i).noun??``}`}}),T(t),z(e,t)};V(_,e=>{I(d)?e(v):I(l)&&e(y,1)}),z(e,g),D()}Hr([`click`]);var qw=R(``);function Jw(e,t){E(t,!0);let n=ya(t,`total`,3,0),r=ya(t,`offset`,3,0),i=ya(t,`limit`,3,25);var a=Qr(),o=N(a),s=e=>{var a=qw(),o=M(a),s=M(o);T(o);var c=P(o,2),l=M(c),u=P(l,2);T(c),T(a),F(e=>{B(s,`Showing ${r()+1}-${e??``} of ${n()??``}`),l.disabled=r()===0,u.disabled=r()+i()>=n()},[()=>Math.min(r()+i(),n())]),L(`click`,l,()=>t.onprev?.()),L(`click`,u,()=>t.onnext?.()),z(e,a)};V(o,e=>{n()>0&&e(s)}),z(e,a),D()}Hr([`click`]);var Yw=(e,t=f)=>{var n=Qr(),r=N(n),i=e=>{var n=Zw();H(n,20,()=>lw(t()),e=>e,(e,t)=>{var n=Xw();let r;var i=M(n,!0);T(n),F((e,a)=>{r=U(n,1,`usage-label-chip`,null,r,{active:J.usageFilterLabel===t}),Hi(n,`--label-color: ${e??``}`),W(n,`title`,a),B(i,t)},[()=>Hy(t),()=>J.usageLabelChipTitle(t)]),L(`click`,n,()=>J.toggleUsageLabelFilter(t)),z(e,n)}),T(n),z(e,n)},a=O(()=>lw(t()).length>0),o=e=>{z(e,Qw())};V(r,e=>{I(a)?e(i):e(o,-1)}),z(e,n)},Xw=R(``),Zw=R(`
                        `),Qw=R(`-`),$w=R(`Labels`),eT=R(`Cost`),tT=R(``),nT=R(` `),rT=R(``),iT=R(` `),aT=R(` `),oT=R(`
                        TimestampProviderModelUser PathCacheProvider Cache
                        `),sT=R(`
                        `),cT=R(`
                        `),lT=R(`

                        Request Log

                        `);function uT(e,t){E(t,!0);let n=O(()=>J.usageMode===`costs`),r=O(()=>uw(J.labelUsage,J.usageFilterLabel,J.usageLog.entries)),i=bw(()=>J.fetchUsageLog(!0));An(()=>i.cancel);var a=lT(),o=P(M(a),2),s=M(o);yw(M(s),{placeholder:`Search by request ID, model, provider...`,label:`Search by request ID, model, provider`,get oninput(){return i},get value(){return J.usageLogSearch},set value(e){J.usageLogSearch=e}}),T(s);var c=P(s,2),l=M(c),u=M(l);na(u),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=e=>{var t=oT(),i=M(t),a=M(i),o=M(a),s=P(M(o),4),c=e=>{z(e,$w())};V(s,e=>{I(r)&&e(c)});var l=P(s,3),u=M(l,!0);T(l);var d=P(l),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{z(e,eT())};V(h,e=>{I(n)||e(g)}),T(o),T(a);var _=P(a);H(_,21,()=>J.usageLog.entries,e=>e.id,(e,t)=>{var i=aT();let a;var o=M(i),s=M(o,!0);T(o);var c=P(o),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=e=>{var n=tT();Yw(M(n),()=>I(t)),T(n),z(e,n)};V(h,e=>{I(r)&&e(g)});var _=P(h),v=M(_,!0);T(_);var y=P(_),b=M(y),x=e=>{var n=nT(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>ow(I(t))]),z(e,n)},S=O(()=>aw(I(t))),C=e=>{z(e,Qw())};V(b,e=>{I(S)?e(x):e(C,-1)}),T(y);var w=P(y),ee=M(w,!0);T(w);var te=P(w),ne=M(te,!0);T(te);var re=P(te),ie=M(re),ae=M(ie,!0);T(ie);var oe=P(ie,2),se=e=>{{let n=O(()=>$C(I(t)));G(e,{get icon(){return qa},class:`cost-source-icon`,get title(){return I(n)}})}},ce=O(()=>I(n)&&QC(I(t)));V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{G(e,{get icon(){return Xa},class:`cache-savings-icon`})},de=O(()=>I(n)&&tw(I(t)));V(le,e=>{I(de)&&e(ue)});var fe=P(le,2),pe=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(fe,e=>{I(n)&&I(t).costs_calculation_caveat&&e(pe)}),T(re);var me=P(re),he=e=>{var n=iT(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{{let n=O(()=>$C(I(t)));G(e,{get icon(){return qa},class:`cost-source-icon`,get title(){return I(n)}})}},s=O(()=>QC(I(t)));V(a,e=>{I(s)&&e(o)});var c=P(a,2),l=e=>{G(e,{get icon(){return Xa},class:`cache-savings-icon`})},u=O(()=>tw(I(t)));V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=e=>{var n=rT();F(()=>W(n,`title`,I(t).costs_calculation_caveat)),z(e,n)};V(d,e=>{I(t).costs_calculation_caveat&&e(f)}),T(n),F((e,t)=>{W(n,`title`,e),B(i,t)},[()=>rw(I(t),cw(I(t))),()=>sc(I(t).total_cost)]),z(e,n)};V(me,e=>{I(n)||e(he)}),T(i),F((e,n,r,c,l,d,p,h,g,_,b,x,S)=>{a=U(i,1,`svelte-hg4ill`,null,a,e),W(o,`title`,n),B(s,r),B(u,c),B(f,I(t).model),B(m,I(t).user_path||`-`),B(v,l),W(y,`title`,d),W(w,`title`,p),B(ee,h),W(te,`title`,g),B(ne,_),W(re,`title`,b),W(ie,`title`,x),B(ae,S)},[()=>({"usage-log-row-cached":tw(I(t))}),()=>mc(I(t).timestamp),()=>ds.formatTimestamp(I(t).timestamp),()=>gc(I(t))||`-`,()=>nw(I(t)),()=>sw(I(t)),()=>I(n)?oc(I(t).input_tokens)+` tokens`:``,()=>I(n)?sc(I(t).input_cost):oc(I(t).input_tokens),()=>I(n)?oc(I(t).output_tokens)+` tokens`:``,()=>I(n)?sc(I(t).output_cost):oc(I(t).output_tokens),()=>I(n)?rw(I(t),``):``,()=>I(n)?rw(I(t),oc(I(t).total_tokens)+` tokens -`+cw(I(t))):``,()=>I(n)?sc(I(t).total_cost):oc(I(t).total_tokens)]),z(e,i)}),T(_),T(i),T(t),F(()=>{B(u,I(n)?`Input Cost`:`Input`),B(f,I(n)?`Output Cost`:`Output`),B(m,I(n)?`Total Cost`:`Total`)}),z(e,t)},p=e=>{var t=sT();SS(M(t),{size:20,label:`Loading request log`}),T(t),z(e,t)},m=e=>{var t=cT();TS(M(t),{}),T(t),z(e,t)};V(d,e=>{J.usageLog.entries.length>0?e(f):J.usageLogLoading?e(p,1):e(m,-1)}),Jw(P(d,2),{get total(){return J.usageLog.total},get offset(){return J.usageLog.offset},get limit(){return J.usageLog.limit},onprev:()=>J.usageLogPrevPage(),onnext:()=>J.usageLogNextPage()}),T(a),L(`change`,u,()=>J.fetchUsageLog(!0)),fa(u,()=>J.usageLogHideCached,e=>J.usageLogHideCached=e),z(e,a),D()}Hr([`click`,`change`]);var dT=R(`
                        `);function fT(e,t){E(t,!0);let n=`usage`;An(()=>{K.refreshTick,Jo.page===n&&(J.fetchUsagePage(),MC.ensureLiveLogs())}),An(()=>{Jo.page===n&&(J.usageMode=Jo.sub===`costs`?`costs`:`tokens`)});var r=dT(),i=P(M(r),2),a=M(i);Py(a,{ariaLabel:`Usage mode`,options:[{value:`tokens`,label:`Tokens`},{value:`costs`,label:`Costs`}],get value(){return J.usageMode},onchange:e=>J.toggleUsageMode(e)}),tl(P(a,2),{onchange:()=>J.fetchUsagePage()}),T(i);var o=P(i,2);ww(o,{});var s=P(o,2);Aw(s,{});var c=P(s,2),l=M(c);Kw(l,{kind:`model`});var u=P(l,2);Kw(u,{kind:`userPath`}),Kw(P(u,2),{kind:`label`}),T(c),uT(P(c,2),{}),T(r),z(e,r),D()}var pT=R(`
                        `);function mT(e,t){let n=ya(t,`label`,3,`Loading...`),r=ya(t,`class`,3,``);var i=pT(),a=P(M(i),2),o=M(a,!0);T(a),T(i),F(()=>{U(i,1,Fi([`loading-state`,r()]),`svelte-hzxv1d`),B(o,n())}),z(e,i)}var hT=R(``);function gT(e,t){let n=ya(t,`label`,3,``),r=ya(t,`class`,3,``),i=ya(t,`disabled`,3,!1);var a=hT();gi(M(a),()=>t.children??f),T(a),F(()=>{U(a,1,Fi([`table-action-btn`,r()])),W(a,`aria-label`,n()),W(a,`title`,n()),a.disabled=i()}),L(`click`,a,function(...e){t.onclick?.apply(this,e)}),z(e,a)}Hr([`click`]);async function _T(e,{label:t,errorFallback:n=`Unable to load ${t}.`,unavailableStatuses:r=[503],normalize:i=e=>Array.isArray(e)?e:[],options:a}){let o;try{o=await _s(e,{...a||{},label:t})}catch(e){return ys(e)||console.error(`Failed to fetch ${t}:`,e),{status:`error`,items:[],error:n,result:null}}return o.stale?{status:`stale`,items:[],error:``,result:o}:r.includes(o.status)?{status:`unavailable`,items:[],error:``,result:o}:o.ok?{status:`ok`,items:i(o.data),error:``,result:o}:{status:`error`,items:[],error:o.status===401?``:fs(o.data,n),result:o}}async function vT(e,t,n,{label:r,errorFallback:i=`Unable to ${r}.`,unavailableStatuses:a=[503],unavailableMessage:o=`This feature is unavailable on the gateway.`,options:s}){let c;try{c=await vs(e,t,n,{...s||{},label:r})}catch(e){return ys(e)||console.error(`Failed to ${r}:`,e),{status:`error`,error:i,result:null}}return c.stale?{status:`stale`,error:``,result:c}:a.includes(c.status)?{status:`unavailable`,error:o,result:c}:c.ok?{status:`ok`,error:``,result:c}:{status:`error`,error:c.status===401?`Authentication required.`:fs(c.data,i),result:c}}function yT(){return{scope:`user_path`,subject:`/`,period:`daily`,period_seconds:86400,amount:``,source:`manual`}}function bT(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},label:{label:`Label`,chip:`label`,fieldLabel:`Label`,placeholder:`Mobile-App-iOS`}};return t[e]||t.user_path}function xT(){return[`user_path`,`label`].map(e=>({value:e,label:bT(e).label}))}function ST(e){return String(e&&e.scope||``).trim()||`user_path`}function CT(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function wT(e){return bT(ST(e)).chip}function TT(e){return ST(e)===`label`?`budget-label`:`budget-user-path`}function ET(e){return bT(String(e&&e.scope||``)).fieldLabel}function DT(e){return bT(String(e&&e.scope||``)).placeholder}function OT(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function kT(){return[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`},{value:`custom`,label:`Custom seconds`}]}function AT(e){switch(String(e||``).trim().toLowerCase()){case`hourly`:return 3600;case`daily`:return 86400;case`weekly`:return 604800;case`monthly`:return 2592e3;default:return 0}}function jT(e){switch(Number(e||0)){case 3600:return`hourly`;case 86400:return`daily`;case 604800:return`weekly`;case 2592e3:return`monthly`;default:return`custom`}}function MT(e){return ST(e)+`:`+CT(e)+`:`+String(e&&e.period_seconds||``)}function NT(e,t){if(!t||!Array.isArray(e))return null;let n=MT(t);return e.find(e=>MT(e)===n)||null}function PT(e){let t=String(e||``).trim();if(!t)return`User path is required.`;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function FT(e){if(PT(e))return``;let t=String(e||``).trim(),n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function IT(e){return`/`+String(e||``).trimStart().replace(/^\/+/,``)}function LT(e){return Array.isArray(e)?e:e&&Array.isArray(e.budgets)?e.budgets:[]}function RT(e){let t=Number(e&&e.period_seconds||0);return[CT(e),wT(e),tE(e),jT(t),t?String(t)+`s`:``,t?String(t)+` seconds`:``].join(` `).toLowerCase()}var zT={user_path:0,label:1};function BT(e,t){let n=Array.isArray(e)?e.slice():[],r=String(t||`subject`);return n.sort((e,t)=>{let n=(zT[ST(e)]||0)-(zT[ST(t)]||0),i=CT(e).localeCompare(CT(t)),a=Number(t&&t.period_seconds||0)-Number(e&&e.period_seconds||0);return r===`period`?a||n||i:n||i||a}),n}function VT(e,t,n){let r=Array.isArray(e)?e:[],i=String(t||``).trim().toLowerCase();return BT(i?r.filter(e=>RT(e).includes(i)):r.slice(),n)}function HT(e){let t=e||{},n=ST(t),r=String(t.subject||``).trim();if(n===`user_path`){let e=PT(r);if(e)return{payload:null,error:e}}else if(!r)return{payload:null,error:`Label is required.`};let i=Number(t.amount);if(!Number.isFinite(i)||i<=0)return{payload:null,error:`Amount must be greater than 0.`};let a=String(t.period||``).trim(),o=AT(a);return a===`custom`&&(o=Number(t.period_seconds)),!Number.isFinite(o)||o<=0?{payload:null,error:`Period seconds must be greater than 0.`}:{payload:{scope:n,subject:n===`user_path`?FT(r):r,period_seconds:Math.trunc(o),amount:i,source:String(t.source||`manual`).trim()||`manual`},error:``}}function UT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds},amount:e.amount}}function WT(e){return{scope:ST(e),subject:CT(e),budget_key:{period_seconds:e.period_seconds}}}function GT(e){return{scope:ST(e),subject:CT(e),period_seconds:e.period_seconds}}function KT(e){return sc(e)}function qT(e,t){let n=e||{},r=t||{};return`A budget for "`+((CT(n)||CT(r))+` `+tE({period_seconds:n.period_seconds||r.period_seconds,period_label:r.period_label}))+`" already exists. Saving will override the current `+KT(r.amount)+` limit with `+KT(n.amount)+`.`}function JT(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:t}function YT(e,t){let n=JT(e);return Math.round((t?Math.min(n,1):n)*1e3)/10}function XT(e){return JT(e&&e.usage_ratio)}function ZT(e){return YT(XT(e),!0)}function QT(e){return YT(e&&e.period_ratio,!0)}function $T(e){return YT(XT(e),!1).toFixed(1).replace(/\.0$/,``)+`%`}function eE(e){return QT(e).toFixed(1).replace(/\.0$/,``)+`%`}function tE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`Hourly`;case 86400:return`Daily`;case 604800:return`Weekly`;case 2592e3:return`Monthly`;default:{let n=String(e&&e.period_label||``).trim();return n?`Custom `+n:`Custom `+String(t||``)+`s`}}}function nE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return`budget-period-label-hourly`;case 86400:return`budget-period-label-daily`;case 604800:return`budget-period-label-weekly`;case 2592e3:return`budget-period-label-monthly`;default:return`budget-period-label-custom`}}function rE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-fill-period-`)}function iE(e){return nE(e).replace(`budget-period-label-`,`budget-bar-track-period-`)}function aE(e){switch(Number(e&&e.period_seconds||0)){case 3600:return Ja;case 86400:return Do;case 604800:return La;case 2592e3:return Ra;default:return xo}}function oE(e){let t=Math.max(0,Math.trunc(Number(e||0)));return t+` `+(t===1?`second`:`seconds`)}function sE(e){let t=Number(e&&e.period_seconds||0);switch(t){case 3600:return`1 hour`;case 86400:return`1 day`;case 604800:return`1 week`;case 2592e3:return`1 month`;default:return oE(t)}}function cE(e){return String(e&&e.source||``).trim()||`manual`}function lE(e){let t=cE(e).toLowerCase();return t===`manual`?`Created from the dashboard.`:t===`config`?`Loaded from configuration.`:`Budget source: `+t}function uE(e){let t=Number(e&&e.remaining);return Number.isFinite(t)?t<0?sc(Math.abs(t))+` over`:sc(t)+` remaining`:``}var Y=new class{#e=k(j([]));get budgets(){return I(this.#e)}set budgets(e){A(this.#e,e,!0)}#t=k(!0);get budgetsAvailable(){return I(this.#t)}set budgetsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get filter(){return I(this.#r)}set filter(e){A(this.#r,e,!0)}#i=k(`subject`);get sortBy(){return I(this.#i)}set sortBy(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(!1);get formOpen(){return I(this.#o)}set formOpen(e){A(this.#o,e,!0)}#s=k(!1);get formSubmitting(){return I(this.#s)}set formSubmitting(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get editing(){return I(this.#l)}set editing(e){A(this.#l,e,!0)}#u=k(j(yT()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(!1);get overrideDialogOpen(){return I(this.#d)}set overrideDialogOpen(e){A(this.#d,e,!0)}#f=k(null);get overridePendingPayload(){return I(this.#f)}set overridePendingPayload(e){A(this.#f,e,!0)}#p=k(null);get overrideExistingBudget(){return I(this.#p)}set overrideExistingBudget(e){A(this.#p,e,!0)}#m=k(``);get resettingKey(){return I(this.#m)}set resettingKey(e){A(this.#m,e,!0)}#h=k(``);get deletingKey(){return I(this.#h)}set deletingKey(e){A(this.#h,e,!0)}#g=k(!1);get resetAllLoading(){return I(this.#g)}set resetAllLoading(e){A(this.#g,e,!0)}#_=null;managementEnabled(){return Ss.budgetsVisible()}filteredBudgets(){return VT(this.budgets,this.filter,this.sortBy)}async fetchBudgetsPage(){if(await Ss.ensureLoaded(),!this.managementEnabled()){this.budgets=[],this.budgetsAvailable=!1,this.error=``;return}return this.#_||=this.fetchBudgets().finally(()=>{this.#_=null}),this.#_}async fetchBudgets(){this.loading=!0,this.error=``;let e=await _T(`/admin/budgets`,{label:`budgets`,errorFallback:`Unable to load budgets.`,normalize:LT});if(this.loading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.budgetsAvailable=!1,this.budgets=[];return}if(!e.result){this.budgets=[],this.error=e.error;return}if(this.budgetsAvailable=!0,e.status===`error`){this.error=e.error;return}this.budgets=e.items}}openForm(e){if(this.editing=!!e,this.formError=``,e){let t=Number(e.period_seconds||0);this.form={scope:ST(e),subject:CT(e),period:jT(t),period_seconds:t,amount:String(e.amount||``),source:String(e.source||`manual`)}}else this.form=yT();this.formOpen=!0}syncPeriodSeconds(){let e=AT(String(this.form.period||``).trim());e>0&&(this.form.period_seconds=e)}setFormSubject(e){this.form.subject=this.form.scope===`label`?String(e??``):IT(e)}syncScope(){OT(this.form)}closeForm(){this.closeOverrideDialog(),this.formOpen=!1,this.formSubmitting=!1,this.formError=``,this.editing=!1,this.form=yT()}async submitForm(){if(this.formSubmitting)return;let{payload:e,error:t}=HT(this.form);if(!e){this.formError=t;return}if(!this.editing){let t=NT(this.budgets,e);if(t){this.openOverrideDialog(t,e);return}}await this.saveBudgetPayload(e)}async saveBudgetPayload(e){if(this.formSubmitting||!e)return;this.formSubmitting=!0,this.formError=``;let t=await vT(`/admin/budgets`,`PUT`,UT(e),{label:`save budget`,errorFallback:`Unable to save budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.formSubmitting=!1,t.status!==`stale`){if(t.status===`unavailable`){this.budgetsAvailable=!1,this.formError=t.error;return}if(t.status===`error`){this.formError=t.error;return}this.closeForm(),q.success(`Budget saved.`),this.fetchBudgets()}}openOverrideDialog(e,t){this.overrideExistingBudget=e||null,this.overridePendingPayload=t||null,this.overrideDialogOpen=!0}closeOverrideDialog(){this.overrideDialogOpen=!1,this.overridePendingPayload=null,this.overrideExistingBudget=null}async confirmOverride(){if(!this.overridePendingPayload){this.closeOverrideDialog();return}let e=this.overridePendingPayload;this.closeOverrideDialog(),await this.saveBudgetPayload(e)}async resetBudget(e){if(!e)return;let t=MT(e);if(this.resettingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Reset budget "`+n+`"?`))return;this.resettingKey=t;let r=await vT(`/admin/budgets/reset-one`,`POST`,GT(e),{label:`reset budget`,errorFallback:`Unable to reset budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.resettingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,q.error(r.error);return}if(r.status===`error`){q.error(r.error);return}q.success(`Budget reset.`),this.fetchBudgets()}}async deleteBudget(e){if(!e)return;let t=MT(e);if(this.deletingKey===t)return;let n=CT(e)+` `+tE(e);if(!confirm(`Delete budget "`+n+`"? This cannot be undone.`))return;this.deletingKey=t;let r=await vT(`/admin/budgets`,`DELETE`,WT(e),{label:`delete budget`,errorFallback:`Unable to delete budget.`,unavailableMessage:`Budget management is unavailable.`});if(this.deletingKey=``,r.status!==`stale`){if(r.status===`unavailable`){this.budgetsAvailable=!1,q.error(r.error);return}if(r.status===`error`){q.error(r.error);return}this.budgets=LT(r.result.data),q.success(`Budget deleted.`)}}openResetDialog(){Rs.open({title:`Reset Budgets`,titleId:`budgetResetDialogTitle`,inputId:`budget-reset-confirmation`,requiredText:`reset`,confirmLabel:`Reset All Budgets`,icon:go,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.resetAllBudgets()})}async resetAllBudgets(){if(this.resetAllLoading)return;this.resetAllLoading=!0;let e=await vT(`/admin/budgets/reset`,`POST`,{confirmation:`reset`},{label:`reset budgets`,errorFallback:`Unable to reset budgets.`,unavailableStatuses:[]});if(this.resetAllLoading=!1,e.status!==`stale`){if(e.status!==`ok`){Rs.error=e.error;return}Rs.close(),q.success(`Budgets reset.`),Jo.page===`budgets`&&this.fetchBudgets()}}},dE=R(` Edit`,1),fE=R(` `,1),pE=R(`
                        Usage
                        Period
                        `),mE=R(`
                        `);function hE(e,t){E(t,!0);let n=ya(t,`budgets`,19,()=>[]);function r(e){if(!e)return``;let t=ds.formatTimestamp(e);return!t||t===`-`?``:t+` `+ds.effectiveTimeZoneLabel()}var i=mE();H(i,21,n,e=>MT(e),(e,t)=>{var n=pE(),i=M(n),a=M(i),o=M(a),s=M(o),c=e=>{G(e,{get icon(){return Oo},class:`budget-scope-icon`})},l=O(()=>ST(I(t))===`label`);V(s,e=>{I(l)&&e(c)});var u=P(s);T(o);var d=P(o,2),f=M(d),p=M(f);{let e=O(()=>aE(I(t)));G(p,{get icon(){return I(e)},class:`budget-period-icon`})}var m=P(p,2),h=M(m,!0);T(m),T(f),T(d);var g=P(d,2),_=M(g),v=M(_),y=M(v,!0);T(v),T(_);var b=P(_,2),x=M(b);gT(x,{label:`Edit budget`,class:`budget-action-btn`,onclick:()=>Y.openForm(I(t)),children:(e,t)=>{var n=dE();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}});var S=P(x,2);{let e=O(()=>Y.resettingKey===MT(I(t))?`Resetting budget`:`Reset budget`),n=O(()=>Y.resettingKey===MT(I(t)));gT(S,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>Y.resetBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);G(i,{get icon(){return go},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.resettingKey===MT(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var C=P(S,2);{let e=O(()=>Y.deletingKey===MT(I(t))?`Deleting budget`:`Delete budget`),n=O(()=>Y.deletingKey===MT(I(t)));gT(C,{get label(){return I(e)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>Y.deleteBudget(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=fE(),i=N(r);G(i,{get icon(){return Ao},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>Y.deletingKey===MT(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}T(b),T(g),T(a);var w=P(a,2),ee=M(w),te=M(ee),ne=P(M(te),2),re=M(ne,!0);T(ne),T(te);var ie=P(te,2),ae=M(ie);let oe;var se=P(ae,2),ce=M(se),le=M(ce,!0);T(ce);var ue=P(ce,2),de=M(ue,!0);T(ue),T(se);var fe=P(se,2),pe=M(fe),me=M(pe,!0);T(pe);var he=P(pe,2),ge=M(he,!0);T(he),T(fe),T(ie),T(ee);var _e=P(ee,2),ve=M(_e),ye=P(M(ve),2),be=M(ye,!0);T(ye),T(ve);var xe=P(ve,2),Se=M(xe),Ce=P(Se,2),we=M(Ce),Te=M(we,!0);T(we);var Ee=P(we,2),De=M(Ee,!0);T(Ee);var Oe=P(Ee,2),ke=M(Oe,!0);T(Oe),T(Ce);var Ae=P(Ce,2),je=M(Ae),Me=M(je,!0);T(je);var Ne=P(je,2),Pe=M(Ne,!0);T(Ne);var Fe=P(Ne,2),Ie=M(Fe,!0);T(Fe),T(Ae),T(xe),T(_e),T(w),T(i),T(n),F((e,t,n,r,i,a,s,c,l,d,p,m,g,_,b,x,S,C,w,ee,te,ne,se,ce,ue,fe,pe,he,_e,ve)=>{U(o,1,`budget-scope-value ${e??``}`,`svelte-1jm56wo`),Hi(o,t),W(o,`title`,n),B(u,` ${r??``}`),U(f,1,`budget-period-label ${i??``}`,`svelte-1jm56wo`),B(h,a),W(v,`title`,s),B(y,c),B(re,l),W(ie,`aria-valuenow`,d),W(ie,`aria-label`,p),Hi(ie,`--budget-progress: ${m??``}%`),oe=U(ae,1,`budget-bar-fill budget-bar-fill-usage`,null,oe,g),B(le,_),B(de,b),B(me,x),B(ge,S),B(be,C),U(xe,1,`budget-bar-track ${w??``}`,`svelte-1jm56wo`),W(xe,`aria-valuenow`,ee),Hi(xe,`--budget-progress: ${te??``}%`),U(Se,1,`budget-bar-fill budget-bar-fill-period ${ne??``}`,`svelte-1jm56wo`),W(we,`title`,se),B(Te,ce),B(De,ue),W(Oe,`title`,fe),B(ke,pe),B(Me,he),B(Pe,_e),B(Ie,ve)},[()=>TT(I(t)),()=>ST(I(t))===`label`?`--label-color: `+Hy(CT(I(t))):void 0,()=>wT(I(t))+`: `+CT(I(t)),()=>CT(I(t)),()=>nE(I(t)),()=>tE(I(t)),()=>lE(I(t)),()=>cE(I(t)),()=>$T(I(t)),()=>ZT(I(t)),()=>`Budget usage: `+sc(I(t).spent)+` of `+sc(I(t).amount)+`, `+uE(I(t)),()=>ZT(I(t)),()=>({"budget-bar-fill-danger":XT(I(t))>=1}),()=>sc(I(t).spent)+` of `+sc(I(t).amount),()=>uE(I(t)),()=>sc(I(t).spent)+` of `+sc(I(t).amount),()=>uE(I(t)),()=>eE(I(t)),()=>iE(I(t)),()=>QT(I(t)),()=>QT(I(t)),()=>rE(I(t)),()=>r(I(t).period_start),()=>ds.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>r(I(t).period_end),()=>ds.formatTimestamp(I(t).period_end),()=>ds.formatTimestamp(I(t).period_start),()=>sE(I(t)),()=>ds.formatTimestamp(I(t).period_end)]),z(e,n)}),T(i),z(e,i),D()}var gE=R(`

                        `,1),_E=R(``),vE=R(``),yE=R(`
                        `);function bE(e,t){E(t,!0);let n=ya(t,`open`,3,!1),r=ya(t,`title`,3,``),i=ya(t,`ariaLabel`,3,``),a=ya(t,`error`,3,``),o=ya(t,`submitting`,3,!1),s=ya(t,`submitDisabled`,3,!1),c=ya(t,`submitLabel`,3,`Save`),l=ya(t,`submittingLabel`,3,`Saving...`),u=ya(t,`submitIcon`,3,_o),d=ya(t,`cancel`,3,!0),p=ya(t,`dialogClass`,3,``),m=ya(t,`novalidate`,3,!1),h=ya(t,`canClose`,3,()=>!0);function g(){K.dialogOpen||h()()&&t.onclose?.()}Ns(e,{get open(){return n()},variant:`editor`,onclose:g,children:(e,n)=>{var h=yE(),g=M(h),_=M(g),v=M(_),y=M(v),b=e=>{var n=Qr();gi(N(n),()=>t.header),z(e,n)},x=e=>{var n=gE(),i=N(n),a=M(i,!0);T(i);var o=P(i,2),s=e=>{var n=Qr();gi(N(n),()=>t.headerHint),z(e,n)};V(o,e=>{t.headerHint&&e(s)}),F(()=>B(a,r())),z(e,n)};V(y,e=>{t.header?e(b):e(x,-1)}),T(v);var S=P(v,2);{let e=O(()=>`Close `+(i()||r()).toLowerCase());ks(S,{get label(){return I(e)},onclick:()=>t.onclose?.()})}T(_);var C=P(_,2);gi(C,()=>t.children??f);var w=P(C,2),ee=e=>{var t=_E(),n=M(t,!0);T(t),F(()=>B(n,a())),z(e,t)};V(w,e=>{a()&&e(ee)});var te=P(w,2),ne=M(te),re=e=>{var n=vE();L(`click`,n,()=>t.onclose?.()),z(e,n)};V(ne,e=>{d()&&e(re)});var ie=P(ne,2),ae=e=>{var n=Qr();gi(N(n),()=>t.extraActions),z(e,n)};V(ie,e=>{t.extraActions&&e(ae)});var oe=P(ie,2),se=M(oe);G(se,{get icon(){return u()},class:`form-action-icon`});var ce=P(se,2),le=M(ce,!0);T(ce),T(oe),T(te),T(g),T(h),F(()=>{U(h,1,Fi([`model-editor`,p()])),W(h,`aria-label`,i()||r()),g.noValidate=m(),oe.disabled=o()||s(),B(le,o()?l():c())}),Vr(`submit`,g,e=>{e.preventDefault(),t.onsubmit?.()}),z(e,h)},$$slots:{default:!0}}),D()}Hr([`click`]);var xE=R(`
                        `);function SE(e,t){let n=ya(t,`label`,3,``);var r=xE(),i=M(r),a=M(i,!0);T(i),gi(P(i,2),()=>t.children??f),T(r),F(()=>{W(i,`for`,t.id),B(a,n())}),z(e,r)}var CE=R(``),wE=R(``),TE=R(``),EE=R(``),DE=R(``),OE=R(``),kE=R(`

                        Editing a budget updates its limit only. Use Reset to start a new - budget period.

                        `),AE=R(`
                        `,1),jE=R(``),ME=R(` `,1);function NE(e,t){E(t,!0);function n(e){Y.setFormSubject(e.target.value),e.target.value=Y.form.subject}var r=ME(),i=N(r);{let e=O(()=>Y.editing?`Edit Budget`:`Create Budget`);bE(i,{get open(){return Y.formOpen},get title(){return I(e)},ariaLabel:`Budget editor`,get error(){return Y.formError},get submitting(){return Y.formSubmitting},submitLabel:`Save Budget`,dialogClass:`budget-editor`,canClose:()=>!Y.overrideDialogOpen,onclose:()=>Y.closeForm(),onsubmit:()=>Y.submitForm(),children:(e,t)=>{var r=AE(),i=N(r),a=M(i);SE(a,{id:`budget-scope`,label:`Scope`,children:(e,t)=>{var n=wE();H(n,21,xT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncScope()),Gi(n,()=>Y.form.scope,e=>Y.form.scope=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);{let e=O(()=>ET(Y.form));SE(o,{id:`budget-subject`,get label(){return I(e)},children:(e,t)=>{var r=TE();na(r),F(e=>{W(r,`placeholder`,e),ra(r,Y.form.subject),r.disabled=Y.editing,W(r,`data-modal-autofocus`,!Y.editing||void 0)},[()=>DT(Y.form)]),L(`input`,r,n),z(e,r)},$$slots:{default:!0}})}var s=P(o,2);SE(s,{id:`budget-period`,label:`Period`,children:(e,t)=>{var n=EE();H(n,21,kT,e=>e.value,(e,t)=>{var n=CE(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),F(()=>n.disabled=Y.editing),L(`change`,n,()=>Y.syncPeriodSeconds()),Gi(n,()=>Y.form.period,e=>Y.form.period=e),z(e,n)},$$slots:{default:!0}});var c=P(s,2),l=e=>{SE(e,{id:`budget-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=DE();na(n),F(()=>n.disabled=Y.editing),da(n,()=>Y.form.period_seconds,e=>Y.form.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(c,e=>{Y.form.period===`custom`&&e(l)}),SE(P(c,2),{id:`budget-amount`,label:`Amount`,children:(e,t)=>{var n=OE();na(n),F(()=>W(n,`data-modal-autofocus`,Y.editing||void 0)),da(n,()=>Y.form.amount,e=>Y.form.amount=e),z(e,n)},$$slots:{default:!0}}),T(i);var u=P(i,2),d=e=>{z(e,kE())};V(u,e=>{Y.editing&&e(d)}),z(e,r)},$$slots:{default:!0}})}Ns(P(i,2),{get open(){return Y.overrideDialogOpen},variant:`auth`,onclose:()=>Y.closeOverrideDialog(),children:(e,t)=>{var n=jE(),r=M(n);ks(P(M(r),2),{label:`Close budget override dialog`,onclick:()=>Y.closeOverrideDialog(),class:`auth-dialog-close`,iconClass:``}),T(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=P(c,2),u=M(l);G(u,{get icon(){return _o},class:`form-action-icon`});var d=P(u,2),f=M(d,!0);T(d),T(l),T(s),T(i),T(n),F(e=>{B(o,e),l.disabled=Y.formSubmitting,B(f,Y.formSubmitting?`Saving...`:`Override Budget`)},[()=>qT(Y.overridePendingPayload,Y.overrideExistingBudget)]),Vr(`submit`,i,e=>{e.preventDefault(),Y.confirmOverride()}),L(`click`,c,()=>Y.closeOverrideDialog()),z(e,n)},$$slots:{default:!0}}),z(e,r),D()}Hr([`change`,`input`,`click`]);var PE=R(`

                        Budgets

                        `),FE=R(``),IE=R(`
                        Budget management is unavailable.
                        `),LE=R(``),RE=R(`
                        `),zE=R(`

                        No budgets configured yet.

                        `),BE=R(`

                        No budgets match your filter.

                        `),VE=R(`
                        `);function HE(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`budgets`&&Y.fetchBudgetsPage()});let n=O(()=>Y.filteredBudgets());var r=VE(),i=M(r),a=M(i);qS(M(a),{copyId:`budgets-help-copy`,label:`budgets help`,title:e=>{z(e,PE())},help:e=>{Ue(),z(e,Zr(`Budgets are evaluated from tracked usage cost records for each user - path subtree. Enforcement runs only when Budget is enabled for the - active workflow.`))},$$slots:{title:!0,help:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=FE();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Y.formSubmitting),L(`click`,t,()=>Y.openForm()),z(e,t)},l=O(()=>Y.managementEnabled()&&Y.budgetsAvailable&&!K.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Fc(u,{});var d=P(u,2),f=e=>{z(e,IE())},p=O(()=>(!Y.managementEnabled()||!Y.budgetsAvailable)&&!K.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=LE(),n=M(t,!0);T(t),F(()=>B(n,Y.error)),z(e,t)};V(m,e=>{Y.error&&!K.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading budgets...`})};V(g,e=>{Y.loading&&!K.authError&&e(_)});var v=P(g,2),y=e=>{var t=RE(),n=M(t);yw(M(n),{id:`budget-filter`,placeholder:`Filter by user path, label, or period...`,label:`Filter budgets by user path or period`,get value(){return Y.filter},set value(e){Y.filter=e}}),T(n);var r=P(n,2),i=P(M(r),2),a=M(i);a.value=a.__value=`subject`;var o=P(a);o.value=o.__value=`period`,T(i),T(r),T(t),Gi(i,()=>Y.sortBy,e=>Y.sortBy=e),z(e,t)};V(v,e=>{(Y.budgets.length>0||Y.filter)&&Y.budgetsAvailable&&!K.authError&&!Y.formOpen&&e(y)});var b=P(v,2);NE(b,{});var x=P(b,2),S=e=>{hE(e,{get budgets(){return I(n)}})};V(x,e=>{I(n).length>0&&Y.budgetsAvailable&&!K.authError&&e(S)});var C=P(x,2),w=e=>{z(e,zE())},ee=O(()=>Y.budgets.length===0&&!Y.filter&&!Y.loading&&!K.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,BE())},re=O(()=>Y.budgets.length>0&&I(n).length===0&&Y.filter&&!Y.loading&&!K.authError&&!Y.error&&Y.budgetsAvailable&&Y.managementEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function UE(){return{scope:`user_path`,subject:`/`,period:`minute`,period_seconds:60,max_requests:``,max_tokens:``,source:`manual`}}function WE(e){let t={user_path:{label:`User path`,chip:`user path`,fieldLabel:`User Path`,placeholder:`/team/alpha`},provider:{label:`Provider`,chip:`provider`,fieldLabel:`Provider Name`,placeholder:`openai`},model:{label:`Model`,chip:`model`,fieldLabel:`Model`,placeholder:`openai/gpt-4o`}};return t[e]||t.user_path}function GE(){return[`user_path`,`provider`,`model`].map(e=>({value:e,label:WE(e).label}))}function KE(e){return String(e&&e.scope||``).trim()||`user_path`}function qE(e){return String(e&&e.subject||``).trim()||String(e&&e.user_path||``)}function JE(e){return WE(KE(e)).chip}function YE(e){return WE(String(e&&e.scope||``)).fieldLabel}function XE(e){return WE(String(e&&e.scope||``)).placeholder}function ZE(e){e.subject=String(e&&e.scope||``)===`user_path`?`/`:``}function QE(){return[{value:`minute`,label:`Per minute`},{value:`hour`,label:`Per hour`},{value:`day`,label:`Per day`},{value:`concurrent`,label:`Concurrent (in-flight)`},{value:`custom`,label:`Custom seconds`}]}function $E(e){switch(String(e||``).trim().toLowerCase()){case`minute`:return 60;case`hour`:return 3600;case`day`:return 86400;case`concurrent`:return 0;default:return-1}}function eD(e){switch(Number(e||0)){case 60:return`minute`;case 3600:return`hour`;case 86400:return`day`;case 0:return`concurrent`;default:return`custom`}}function tD(e){let t=String(e&&e.period||``).trim(),n=$E(t);n>=0&&(e.period_seconds=n),t===`concurrent`&&(e.max_tokens=``)}function nD(e){return KE(e)+`:`+qE(e)+`:`+String(e&&e.period_seconds||`0`)}function rD(e){return Number(e&&e.period_seconds||0)===0}function iD(e){return String(e&&e.period_label||``).trim()||eD(Number(e&&e.period_seconds||0))}function aD(e){return String(e&&e.source||``)===`config`?`config`:`manual`}function oD(e){return String(e&&e.source||``)===`config`}function sD(e){let t=Number(e);return Number.isFinite(t)?t.toLocaleString():`0`}function cD(e,t){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return 0;let i=Math.round(n/r*100);return Math.min(Math.max(i,0),100)}function lD(e,t){let n=String(t||``).trim().toLowerCase(),r=Array.isArray(e)?e.slice():[],i={user_path:0,provider:1,model:2};return r.sort((e,t)=>{let n=(i[KE(e)]||0)-(i[KE(t)]||0);if(n!==0)return n;let r=qE(e).localeCompare(qE(t));return r===0?Number(e.period_seconds||0)-Number(t.period_seconds||0):r}),n?r.filter(e=>{let t=qE(e).toLowerCase(),r=JE(e).toLowerCase(),i=iD(e).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)}):r}function uD(e){return!e||!Array.isArray(e.rate_limits)?[]:e.rate_limits}function dD(e,t,n){let r=String(t||``).trim();return r=e===`provider`||e===`model`?r.toLowerCase():`/`+r.split(`/`).map(e=>e.trim()).filter(Boolean).join(`/`),e+`:`+r+`:`+Number(n||0)}function fD(e,t){return e?dD(t.scope,t.subject,t.limit_key.period_seconds)!==dD(e.scope,e.subject,e.period_seconds):!1}function pD(e){let t=e||{},n=String(t.scope||`user_path`),r=String(t.subject||``).trim();if(n!==`user_path`&&!r)return{error:YE(t)+` is required.`};let i=String(t.period||``)===`concurrent`,a=t.period_seconds;if(a===``||a==null)return{error:`Period seconds is required.`};let o=Number(a);if(!Number.isInteger(o)||o<0||o===0&&!i)return{error:`Period seconds must be a positive integer (0 only for the concurrent period).`};let s=String(t.max_requests===void 0||t.max_requests===null?``:t.max_requests).trim(),c=String(t.max_tokens===void 0||t.max_tokens===null?``:t.max_tokens).trim();if(!s&&!c)return{error:`Set max requests, max tokens, or both.`};if(i&&c)return{error:`Token limits are not valid for the concurrent period.`};let l={scope:n,subject:r||`/`,limit_key:{period_seconds:o}};if(s){let e=Number(s);if(!Number.isInteger(e)||e<=0)return{error:`Max requests must be a positive integer.`};l.max_requests=e}if(c){let e=Number(c);if(!Number.isInteger(e)||e<=0)return{error:`Max tokens must be a positive integer.`};l.max_tokens=e}return{payload:l}}function mD(e,t,n){if(KE(e)!==`model`)return!1;let r=String(qE(e)).toLowerCase(),i=String(n||``).trim().toLowerCase();if(!i)return!1;if(r===i)return!0;let a=String(t||``).trim().toLowerCase();return a?r===a+`/`+i||i.startsWith(a+`/`)&&r===i.slice(a.length+1):!1}function hD(e,t){return KE(e)===`provider`&&String(qE(e)).toLowerCase()===String(t||``).trim().toLowerCase()}function gD(e){let t=e||{},n=String(t.model||``),r=String(t.provider||``);return!r||n.toLowerCase().startsWith(r+`/`)?n:r+`/`+n}function _D(e,t){let n=e||{},r=Array.isArray(t)?t:[],i=[];return n.kind===`model`&&i.push({key:`model`,title:`Model limits`,scope:`model`,subject:gD(n),hint:``,items:r.filter(e=>mD(e,n.provider,n.model))}),i.push({key:`provider`,title:`Provider limits (`+n.provider+`)`,scope:`provider`,subject:n.provider,hint:n.kind===`model`?`Shared by every model routed to this provider.`:``,items:r.filter(e=>hD(e,n.provider))}),i.push({key:`global`,title:`Global limits`,scope:`user_path`,subject:`/`,hint:`Root user-path rules throttle all traffic. Narrower user-path rules also apply, per consumer.`,items:r.filter(e=>KE(e)===`user_path`&&qE(e)===`/`)}),i}function vD(e){return rD(e)?cD(e.in_flight,e.max_requests):Math.max(cD(e.requests_used,e.max_requests),cD(e.tokens_used,e.max_tokens))}function yD(e){return`--rate-limit-pressure: `+vD(e)+`%`}function bD(e){let t=vD(e);return t>=100?`rate-limit-pressure-row rate-limit-pressure-full`:t>=75?`rate-limit-pressure-row rate-limit-pressure-high`:`rate-limit-pressure-row`}function xD(e){return(Array.isArray(e)?e:[]).some(e=>KE(e)===`user_path`&&qE(e)===`/`)}function SD(e,t,n){let r=Array.isArray(e)?e:[];return r.some(e=>mD(e,t,n))?`table-action-btn-active`:r.some(e=>hD(e,t))||xD(r)?`rate-limit-gauge-inherited`:``}function CD(e,t){let n=Array.isArray(e)?e:[];return n.some(e=>hD(e,t))?`table-action-btn-active`:xD(n)?`rate-limit-gauge-inherited`:``}function wD(e,t){let n=`Rate limits for `+e;return t===`table-action-btn-active`?n+` (direct limits configured)`:t?n+` (inherited limits apply)`:n}function TD(e){if(rD(e))return sD(e.in_flight)+` of `+sD(e.max_requests)+` in flight`;let t=[];return e.max_requests!==null&&e.max_requests!==void 0&&t.push(sD(e.requests_used)+`/`+sD(e.max_requests)+` req`),e.max_tokens!==null&&e.max_tokens!==void 0&&t.push(sD(e.tokens_used)+`/`+sD(e.max_tokens)+` tok`),t.join(` · `)}var X=new class{#e=k(j([]));get rateLimits(){return I(this.#e)}set rateLimits(e){A(this.#e,e,!0)}#t=k(!0);get rateLimitsAvailable(){return I(this.#t)}set rateLimitsAvailable(e){A(this.#t,e,!0)}#n=k(!1);get rateLimitsLoading(){return I(this.#n)}set rateLimitsLoading(e){A(this.#n,e,!0)}rateLimitFetchPromise=null;#r=k(``);get rateLimitFilter(){return I(this.#r)}set rateLimitFilter(e){A(this.#r,e,!0)}#i=k(``);get rateLimitError(){return I(this.#i)}set rateLimitError(e){A(this.#i,e,!0)}#a=k(!1);get rateLimitFormOpen(){return I(this.#a)}set rateLimitFormOpen(e){A(this.#a,e,!0)}#o=k(!1);get rateLimitFormSubmitting(){return I(this.#o)}set rateLimitFormSubmitting(e){A(this.#o,e,!0)}#s=k(``);get rateLimitFormError(){return I(this.#s)}set rateLimitFormError(e){A(this.#s,e,!0)}#c=k(!1);get rateLimitEditing(){return I(this.#c)}set rateLimitEditing(e){A(this.#c,e,!0)}rateLimitEditingOriginal=null;rateLimitFormReturnToInspector=!1;#l=k(``);get rateLimitResettingKey(){return I(this.#l)}set rateLimitResettingKey(e){A(this.#l,e,!0)}#u=k(``);get rateLimitDeletingKey(){return I(this.#u)}set rateLimitDeletingKey(e){A(this.#u,e,!0)}#d=k(!1);get rateLimitInspectorOpen(){return I(this.#d)}set rateLimitInspectorOpen(e){A(this.#d,e,!0)}#f=k(j({kind:``,provider:``,model:``,title:``}));get rateLimitInspector(){return I(this.#f)}set rateLimitInspector(e){A(this.#f,e,!0)}#p=k(j(UE()));get rateLimitForm(){return I(this.#p)}set rateLimitForm(e){A(this.#p,e,!0)}rateLimitsEnabled(){return Ss.rateLimitsVisible()}defaultRateLimitForm(){return UE()}rateLimitScopeMeta(e){return WE(e)}rateLimitScopeOptions(){return GE()}rateLimitScope(e){return KE(e)}rateLimitSubject(e){return qE(e)}rateLimitScopeLabel(e){return JE(e)}rateLimitSubjectFieldLabel(){return YE(this.rateLimitForm)}rateLimitSubjectPlaceholder(){return XE(this.rateLimitForm)}syncRateLimitScope(){ZE(this.rateLimitForm)}rateLimitPeriodOptions(){return QE()}rateLimitPeriodSeconds(e){return $E(e)}rateLimitPeriodFromSeconds(e){return eD(e)}syncRateLimitPeriodSeconds(){tD(this.rateLimitForm)}rateLimitKey(e){return nD(e)}rateLimitIsConcurrent(e){return rD(e)}rateLimitPeriodLabel(e){return iD(e)}rateLimitSourceLabel(e){return aD(e)}rateLimitIsReadOnly(e){return oD(e)}formatRateLimitNumber(e){return sD(e)}rateLimitUsagePercent(e,t){return cD(e,t)}filteredRateLimits(){return lD(this.rateLimits,this.rateLimitFilter)}normalizeRateLimitListPayload(e){return uD(e)}async fetchRateLimitsPage(){if(await Ss.ensureLoaded(),!this.rateLimitsEnabled()){this.rateLimits=[],this.rateLimitsAvailable=!1,this.rateLimitError=``;return}return this.rateLimitFetchPromise||=this.fetchRateLimits().finally(()=>{this.rateLimitFetchPromise=null}),this.rateLimitFetchPromise}async fetchRateLimits(){this.rateLimitsLoading=!0,this.rateLimitError=``;let e=await _T(`/admin/rate-limits`,{label:`rate limits`,errorFallback:`Unable to load rate limits.`,normalize:uD});if(this.rateLimitsLoading=!1,e.status!==`stale`){if(e.status===`unavailable`){this.rateLimitsAvailable=!1,this.rateLimits=[];return}if(!e.result){this.rateLimits=[],this.rateLimitError=e.error;return}if(this.rateLimitsAvailable=!0,e.status===`error`){this.rateLimitError=e.error;return}this.rateLimits=e.items}}openRateLimitForm(e){if(this.rateLimitEditing=!!e,this.rateLimitFormError=``,e){let t=Number(e.period_seconds||0);this.rateLimitEditingOriginal={scope:KE(e),subject:qE(e),period_seconds:t},this.rateLimitForm={scope:KE(e),subject:qE(e),period:eD(t),period_seconds:t,max_requests:e.max_requests===null||e.max_requests===void 0?``:String(e.max_requests),max_tokens:e.max_tokens===null||e.max_tokens===void 0?``:String(e.max_tokens),source:String(e.source||`manual`)}}else this.rateLimitEditingOriginal=null,this.rateLimitForm=UE();this.rateLimitFormOpen=!0}closeRateLimitForm(){this.rateLimitFormOpen=!1,this.rateLimitFormSubmitting=!1,this.rateLimitFormError=``,this.rateLimitEditing=!1,this.rateLimitEditingOriginal=null,this.rateLimitForm=UE(),this.rateLimitFormReturnToInspector&&(this.rateLimitFormReturnToInspector=!1,this.rateLimitInspectorOpen=!0)}rateLimitNormalizedIdentity(e,t,n){return dD(e,t,n)}rateLimitIdentityMoved(e){return fD(this.rateLimitEditingOriginal,e)}setRateLimitFormSubject(e){this.rateLimitForm.subject=String(e||``)}rateLimitFormPayload(){return pD(this.rateLimitForm)}async submitRateLimitForm(){if(this.rateLimitFormSubmitting)return;let{payload:e,error:t}=this.rateLimitFormPayload();if(t){this.rateLimitFormError=t;return}let n=this.rateLimitIdentityMoved(e),r=this.rateLimitEditingOriginal;this.rateLimitFormSubmitting=!0,this.rateLimitFormError=``;try{let t=await vT(`/admin/rate-limits`,`PUT`,e,{label:`save rate limit`,errorFallback:`Unable to save rate limit.`,unavailableStatuses:[]});if(t.status===`stale`)return;if(t.status!==`ok`){this.rateLimitFormError=t.error;return}if(this.rateLimits=uD(t.result.data),n&&!await this.deleteMovedRateLimitOriginal(r))return;this.closeRateLimitForm(),q.success(n?`Rate limit moved; live counters restarted.`:`Rate limit saved.`)}finally{this.rateLimitFormSubmitting=!1}}async deleteMovedRateLimitOriginal(e){let t=await vT(`/admin/rate-limits`,`DELETE`,{scope:e.scope,subject:e.subject,limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`remove the moved rate limit`,errorFallback:`The new rule was saved, but the previous one could not be removed. Delete it manually.`,unavailableStatuses:[]});return t.status===`stale`?!1:t.status===`ok`?(this.rateLimits=uD(t.result.data),!0):(this.rateLimitFormError=t.error,!1)}async deleteRateLimit(e){let t=nD(e);if(this.rateLimitDeletingKey===t)return;this.rateLimitDeletingKey=t;let n=await vT(`/admin/rate-limits`,`DELETE`,{scope:KE(e),subject:qE(e),limit_key:{period_seconds:Number(e.period_seconds||0)}},{label:`delete rate limit`,errorFallback:`Unable to delete rate limit.`,unavailableStatuses:[]});if(this.rateLimitDeletingKey=``,n.status!==`stale`){if(n.status!==`ok`){q.error(n.error);return}this.rateLimits=uD(n.result.data),q.success(`Rate limit deleted.`)}}async resetRateLimit(e){let t=nD(e);if(this.rateLimitResettingKey===t)return;this.rateLimitResettingKey=t;let n=await vT(`/admin/rate-limits/reset-one`,`POST`,{scope:KE(e),subject:qE(e),period_seconds:Number(e.period_seconds||0)},{label:`reset rate limit`,errorFallback:`Unable to reset rate limit.`,unavailableStatuses:[]});if(this.rateLimitResettingKey=``,n.status!==`stale`){if(n.status!==`ok`){q.error(n.error);return}this.rateLimits=uD(n.result.data),q.success(`Rate limit counters reset.`)}}rateLimitInspectorModelID(e){return String(e&&e.model&&e.model.id||``).trim()}openRateLimitInspectorForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`model`,provider:n,model:t,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}openRateLimitInspectorForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase();this.rateLimitInspector={kind:`provider`,provider:t,model:``,title:String(e&&e.display_name||t)},this.showRateLimitInspector()}showRateLimitInspector(){this.rateLimitInspectorOpen=!0,this.fetchRateLimitsPage()}closeRateLimitInspector(){this.rateLimitInspectorOpen=!1}rateLimitRuleMatchesModel(e,t,n){return mD(e,t,n)}rateLimitRuleMatchesProvider(e,t){return hD(e,t)}rateLimitInspectorQualifiedModel(){return gD(this.rateLimitInspector)}rateLimitInspectorSections(){return _D(this.rateLimitInspector,this.rateLimits)}rateLimitPressurePercent(e){return vD(e)}rateLimitPressureStyle(e){return yD(e)}rateLimitPressureClass(e){return bD(e)}rateLimitGaugeCache={rules:null,states:{}};rateLimitGaugeMemo(e,t){this.rateLimitGaugeCache.rules!==this.rateLimits&&(this.rateLimitGaugeCache={rules:this.rateLimits,states:{}});let n=this.rateLimitGaugeCache.states;return e in n||(n[e]=t()),n[e]}rateLimitGaugeClassForModel(e){let t=this.rateLimitInspectorModelID(e),n=String(e&&e.provider_name||``).trim().toLowerCase(),r=this.rateLimits;return this.rateLimitGaugeMemo(`model:`+n+`/`+t,()=>SD(r,n,t))}rateLimitGaugeClassForProvider(e){let t=String(e&&e.provider_name||``).trim().toLowerCase(),n=this.rateLimits;return this.rateLimitGaugeMemo(`provider:`+t,()=>CD(n,t))}hasGlobalRateLimits(){let e=this.rateLimits;return this.rateLimitGaugeMemo(`global`,()=>xD(e))}rateLimitGaugeTitle(e,t){return wD(e,t)}rateLimitInspectorSummary(e){return TD(e)}openRateLimitFormFromInspector(e,t,n){this.rateLimitInspectorOpen=!1,this.rateLimitFormReturnToInspector=!0,this.openRateLimitForm(n||void 0),n||(this.rateLimitForm.scope=e,this.rateLimitForm.subject=t)}},ED=R(``),DD=R(``),OD=R(``),kD=R(``),AD=R(``),jD=R(``),MD=R(``),ND=R(`

                        Scope, subject, and period identify the rule: changing any of them - moves the rule to a new key and restarts its live counters.

                        `),PD=R(`

                        A user path rule limits the whole subtree; provider and model rules cap - all traffic routed there and make load balancing skip the target while - it is saturated. One shared counter per rule. Leave a field empty to - skip that limit. Token limits require usage tracking.

                        `,1);function FD(e,t){E(t,!0);{let t=O(()=>X.rateLimitEditing?`Edit Rate Limit`:`Create Rate Limit`);bE(e,{get open(){return X.rateLimitFormOpen},get title(){return I(t)},ariaLabel:`Rate limit editor`,get error(){return X.rateLimitFormError},get submitting(){return X.rateLimitFormSubmitting},submitLabel:`Save Rate Limit`,dialogClass:`budget-editor`,novalidate:!0,onclose:()=>X.closeRateLimitForm(),onsubmit:()=>X.submitRateLimitForm(),children:(e,t)=>{var n=PD(),r=N(n),i=M(r);SE(i,{id:`rate-limit-scope`,label:`Scope`,children:(e,t)=>{var n=DD();H(n,21,()=>X.rateLimitScopeOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitScope()),Gi(n,()=>X.rateLimitForm.scope,e=>X.rateLimitForm.scope=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);{let e=O(()=>X.rateLimitSubjectFieldLabel());SE(a,{id:`rate-limit-subject`,get label(){return I(e)},children:(e,t)=>{var n=OD();na(n),F(e=>{W(n,`placeholder`,e),W(n,`data-modal-autofocus`,!X.rateLimitEditing||void 0),ra(n,X.rateLimitForm.subject)},[()=>X.rateLimitSubjectPlaceholder()]),L(`input`,n,e=>X.setRateLimitFormSubject(e.currentTarget.value)),z(e,n)},$$slots:{default:!0}})}var o=P(a,2);SE(o,{id:`rate-limit-period`,label:`Period`,children:(e,t)=>{var n=kD();H(n,21,()=>X.rateLimitPeriodOptions(),e=>e.value,(e,t)=>{var n=ED(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n),L(`change`,n,()=>X.syncRateLimitPeriodSeconds()),Gi(n,()=>X.rateLimitForm.period,e=>X.rateLimitForm.period=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=e=>{SE(e,{id:`rate-limit-period-seconds`,label:`Period Seconds`,children:(e,t)=>{var n=AD();na(n),da(n,()=>X.rateLimitForm.period_seconds,e=>X.rateLimitForm.period_seconds=e),z(e,n)},$$slots:{default:!0}})};V(s,e=>{X.rateLimitForm.period===`custom`&&e(c)});var l=P(s,2);{let e=O(()=>X.rateLimitForm.period===`concurrent`?`Max In-Flight Requests`:`Max Requests`);SE(l,{id:`rate-limit-max-requests`,get label(){return I(e)},children:(e,t)=>{var n=jD();na(n),F(()=>W(n,`data-modal-autofocus`,X.rateLimitEditing?!0:void 0)),da(n,()=>X.rateLimitForm.max_requests,e=>X.rateLimitForm.max_requests=e),z(e,n)},$$slots:{default:!0}})}var u=P(l,2),d=e=>{SE(e,{id:`rate-limit-max-tokens`,label:`Max Tokens`,children:(e,t)=>{var n=MD();na(n),da(n,()=>X.rateLimitForm.max_tokens,e=>X.rateLimitForm.max_tokens=e),z(e,n)},$$slots:{default:!0}})};V(u,e=>{X.rateLimitForm.period!==`concurrent`&&e(d)}),T(r);var f=P(r,4),p=e=>{z(e,ND())};V(f,e=>{X.rateLimitEditing&&e(p)}),z(e,n)},$$slots:{default:!0}})}D()}Hr([`change`,`input`]);var ID=R(` `),LD=R(` Edit`,1),RD=R(` `,1),zD=R(`
                        In-flight
                        `),BD=R(`
                        Requests
                        `),VD=R(`
                        Tokens
                        `),HD=R(`
                        `),UD=R(`
                        `);function WD(e,t){E(t,!0);var n=UD();H(n,21,()=>t.rules,e=>X.rateLimitKey(e),(e,t)=>{var n=HD(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=e=>{var n=ID(),r=M(n);{let e=O(()=>X.rateLimitScope(I(t))===`provider`?bo:Fa);G(r,{get icon(){return I(e)},class:`budget-period-icon`})}var i=P(r,2),a=M(i,!0);T(i),T(n),F((e,t)=>{W(n,`title`,e),B(a,t)},[()=>`Rule scope: `+X.rateLimitScopeLabel(I(t)),()=>X.rateLimitScopeLabel(I(t))]),z(e,n)},u=O(()=>X.rateLimitScope(I(t))!==`user_path`);V(c,e=>{I(u)&&e(l)});var d=P(c,2),f=M(d);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?Ma:ko);G(f,{get icon(){return I(e)},class:`budget-period-icon`})}var p=P(f,2),m=M(p,!0);T(p),T(d),T(s);var h=P(s,2),g=M(h),_=M(g),v=M(_,!0);T(_),T(g);var y=P(g,2),b=M(y),x=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitForm(I(t)),children:(e,t)=>{var n=LD();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},S=O(()=>!X.rateLimitIsReadOnly(I(t)));V(b,e=>{I(S)&&e(x)});var C=P(b,2);{let e=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting counters`:`Reset counters`),n=O(()=>X.rateLimitResettingKey===X.rateLimitKey(I(t)));gT(C,{get label(){return I(e)},class:`budget-action-btn budget-action-btn-warning`,onclick:()=>X.resetRateLimit(I(t)),get disabled(){return I(n)},children:(e,n)=>{var r=RD(),i=N(r);G(i,{get icon(){return go},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitResettingKey===X.rateLimitKey(I(t))?`Resetting`:`Reset`]),z(e,r)},$$slots:{default:!0}})}var w=P(C,2),ee=e=>{{let n=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting rate limit`:`Delete rate limit`),r=O(()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger budget-action-btn`,onclick:()=>X.deleteRateLimit(I(t)),get disabled(){return I(r)},children:(e,n)=>{var r=RD(),i=N(r);G(i,{get icon(){return Ao},class:`budget-action-icon`});var a=P(i,2),o=M(a,!0);T(a),F(e=>B(o,e),[()=>X.rateLimitDeletingKey===X.rateLimitKey(I(t))?`Deleting`:`Delete`]),z(e,r)},$$slots:{default:!0}})}},te=O(()=>!X.rateLimitIsReadOnly(I(t)));V(w,e=>{I(te)&&e(ee)}),T(y),T(h),T(i);var ne=P(i,2),re=M(ne),ie=e=>{var n=zD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u),T(l),T(o),T(n),F((e,t,n,r,i,l)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l)},[()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests),()=>`In-flight requests: `+X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).in_flight,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).in_flight)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` in flight`]),z(e,n)},ae=O(()=>X.rateLimitIsConcurrent(I(t)));V(re,e=>{I(ae)&&e(ie)});var oe=P(re,2),se=e=>{var n=BD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests),()=>`Requests used: `+X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).requests_used,I(t).max_requests)>=100}),()=>X.formatRateLimitNumber(I(t).requests_used)+` of `+X.formatRateLimitNumber(I(t).max_requests)+` requests`,()=>X.formatRateLimitNumber(I(t).requests_remaining)+` left`]),z(e,n)},ce=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_requests);V(oe,e=>{I(ce)&&e(se)});var le=P(oe,2),ue=e=>{var n=VD(),r=M(n),i=P(M(r),2),a=M(i,!0);T(i),T(r);var o=P(r,2),s=M(o);let c;var l=P(s,2),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=M(f,!0);T(f),T(l),T(o),T(n),F((e,t,n,r,i,l,u)=>{B(a,e),W(o,`aria-valuenow`,t),W(o,`aria-label`,n),Hi(o,r),c=U(s,1,`budget-bar-fill budget-bar-fill-usage`,null,c,i),B(d,l),B(p,u)},[()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens),()=>`Tokens used: `+X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens),()=>`--budget-progress: `+X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)+`%`,()=>({"budget-bar-fill-danger":X.rateLimitUsagePercent(I(t).tokens_used,I(t).max_tokens)>=100}),()=>X.formatRateLimitNumber(I(t).tokens_used)+` of `+X.formatRateLimitNumber(I(t).max_tokens)+` tokens`,()=>X.formatRateLimitNumber(I(t).tokens_remaining)+` left`]),z(e,n)},de=O(()=>!X.rateLimitIsConcurrent(I(t))&&I(t).max_tokens);V(le,e=>{I(de)&&e(ue)}),T(ne),T(r),T(n),F((e,t,n,r,i)=>{W(a,`title`,e),B(o,t),B(m,n),W(_,`title`,r),B(v,i)},[()=>X.rateLimitScopeLabel(I(t))+`: `+X.rateLimitSubject(I(t)),()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n),D()}var GD=R(`

                        Rate Limits

                        `),KD=R(``),qD=R(`
                        Rate limit management is unavailable.
                        `),JD=R(``),YD=R(`
                        `),XD=R(`

                        No rate limits configured yet.

                        `),ZD=R(`

                        No rate limits match your filter.

                        `),QD=R(`
                        `);function $D(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`rate-limits`&&X.fetchRateLimitsPage()});let n=O(()=>X.filteredRateLimits());var r=QD(),i=M(r),a=M(i);qS(M(a),{copyId:`rate-limits-help-copy`,label:`rate limits help`,text:`Rate limits cap requests, tokens, and in-flight concurrency for a user path subtree, a provider, or a model. Consumer (user path) breaches return 429 with Retry-After and x-ratelimit-* headers; saturated providers and models are skipped by load balancing and failover while capacity exists elsewhere. Counters are per gateway instance and reset on restart; token limits need usage tracking.`,title:e=>{z(e,GD())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=e=>{var t=KD();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=X.rateLimitFormSubmitting),L(`click`,t,()=>X.openRateLimitForm()),z(e,t)},l=O(()=>X.rateLimitsEnabled()&&X.rateLimitsAvailable&&!K.authError);V(s,e=>{I(l)&&e(c)}),T(o),T(i);var u=P(i,2);Fc(u,{});var d=P(u,2),f=e=>{z(e,qD())},p=O(()=>(!X.rateLimitsEnabled()||!X.rateLimitsAvailable)&&!K.authError);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{var t=JD(),n=M(t,!0);T(t),F(()=>B(n,X.rateLimitError)),z(e,t)};V(m,e=>{X.rateLimitError&&!K.authError&&e(h)});var g=P(m,2),_=e=>{mT(e,{label:`Loading rate limits...`})};V(g,e=>{X.rateLimitsLoading&&!K.authError&&e(_)});var v=P(g,2),y=e=>{var t=YD(),n=M(t);yw(M(n),{id:`rate-limit-filter`,placeholder:`Filter by subject, scope, or period...`,label:`Filter rate limits by subject, scope, or period`,get value(){return X.rateLimitFilter},set value(e){X.rateLimitFilter=e}}),T(n),T(t),z(e,t)};V(v,e=>{(X.rateLimits.length>0||X.rateLimitFilter)&&X.rateLimitsAvailable&&!K.authError&&!X.rateLimitFormOpen&&e(y)});var b=P(v,2);FD(b,{});var x=P(b,2),S=e=>{WD(e,{get rules(){return I(n)}})};V(x,e=>{I(n).length>0&&X.rateLimitsAvailable&&!K.authError&&e(S)});var C=P(x,2),w=e=>{z(e,XD())},ee=O(()=>X.rateLimits.length===0&&!X.rateLimitFilter&&!X.rateLimitsLoading&&!K.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{z(e,ZD())},re=O(()=>X.rateLimits.length>0&&I(n).length===0&&X.rateLimitFilter&&!X.rateLimitsLoading&&!K.authError&&!X.rateLimitError&&X.rateLimitsAvailable&&X.rateLimitsEnabled());V(te,e=>{I(re)&&e(ne)}),T(r),z(e,r),D()}Hr([`click`]);function eO(e){return String(e||``).trim().toLowerCase()}function tO(e){if(!e)return``;let t=String(e.selector||``).trim();if(t)return t;if(!e.model||!e.model.id)return``;let n=String(e.model.id||``).trim(),r=String(e.provider_name||``).trim();if(r)return r+`/`+n;let i=String(e.provider_type||``).trim();return!i||n.includes(`/`)?n:i+`/`+n}function nO(e,t,n,r){let i=new Set,a=String(e||``).trim().toLowerCase(),o=String(t||``).trim().toLowerCase(),s=String(n||``).trim().toLowerCase(),c=String(r||``).trim().toLowerCase();if(c&&i.add(c),!a)return i;i.add(a),s&&i.add(s+`/`+a),o&&!a.includes(`/`)&&i.add(o+`/`+a);let l=a.split(`/`);return l.length===2&&l[1]&&i.add(l[1]),i}function rO(e){return nO(e&&e.model?e.model.id:``,e?e.provider_type:``,e?e.provider_name:``,e?e.selector:``)}function iO(e){let t=new Set,n=String(e.resolved_model||``).trim().toLowerCase(),r=String(e.target_model||``).trim().toLowerCase(),i=String(e.target_provider||``).trim().toLowerCase();if(n){t.add(n);let e=n.split(`/`);e.length===2&&e[1]&&t.add(e[1])}if(r){t.add(r);let e=r.split(`/`);e.length===2&&e[1]&&t.add(e[1])}return r&&i&&t.add(i+`/`+r),t}function aO(e){if(!e)return``;let t=String(e.provider||``).trim(),n=String(e.model||``).trim();return!t||!n||n===t||n.startsWith(t+`/`)?n:t+`/`+n}function oO(e){if(e===``||e==null)return null;let t=Number(e);return!Number.isFinite(t)||t<=0?null:t}function sO(e,t){let n={model:e},r=oO(t);return r!==null&&(n.weight=r),n}function cO(e){let t=Array.isArray(e)?e:[],n=[];for(let e of t){let t=String(e&&e.model||``).trim();t&&n.push(sO(t,e&&e.weight))}return n}function lO(e){switch(String(e||``).toLowerCase()){case`cost`:return`lowest cost`;case`round_robin`:case``:return`round robin`;default:return e}}var uO={round_robin:`Round-robin (rotate across targets; honors weights)`,cost:`Lowest cost (cheapest target per request)`,adaptive:`Adaptive (target chosen by the registered routing extension)`};function dO(e,t){let n=Array.isArray(e)?[...e]:[],r=String(t||``).trim().toLowerCase();return r&&!n.includes(r)&&n.push(r),n.map(e=>({value:e,label:uO[e]||e}))}function fO(e){let t=Array.isArray(e.targets)?e.targets:[],n=t.length>0?t[0]:{},r=t.map(e=>{let t={provider:e.provider||``,model:e.model||``};return e.weight&&(t.weight=e.weight),t});return{name:e.source,target_provider:n.provider||``,target_model:n.model||``,targets:r,strategy:e.strategy||``,session_affinity:e.session_affinity!==!1,description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,valid:!!e.valid,resolved_model:e.resolved_model||``,provider_type:e.provider_type||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[]}}function pO(e){let t=Array.isArray(e)?e:[],n=[],r=[];for(let e of t)!e||typeof e!=`object`||(e.kind===`redirect`?n.push(fO(e)):e.kind===`policy`&&r.push({selector:e.source,provider_name:e.provider_name||``,model:e.model||``,user_paths:Array.isArray(e.user_paths)?e.user_paths:[],description:e.description||``,enabled:e.enabled!==!1,managed:!!e.managed,scope_kind:e.scope_kind||``}));return{aliases:n,policies:r}}function mO(e){if(!e)return`—`;let t=Array.isArray(e.targets)?e.targets:[];return t.length>1?t.length+` targets · `+lO(e.strategy):e.resolved_model?e.resolved_model:e.target_provider?e.target_provider+`/`+e.target_model:e.target_model||`—`}function hO(e){return e?e.enabled===!1?`is-disabled`:e.valid?`is-valid`:`is-invalid`:`is-invalid`}function gO(e){return e?e.enabled===!1?`Disabled`:e.valid?`Active`:`Invalid`:`Invalid`}function _O(e){return Array.isArray(e)&&e.length>0&&e.indexOf(`/`)===-1}function vO(e,t){return!t||!e?``:e.effective_enabled===!1?`is-disabled`:_O(e.user_paths)?`is-restricted`:`is-enabled`}function yO(e){if(!e)return``;let t=[];e.effective_enabled===!1&&t.push(e.default_enabled===!1?`Disabled by default`:`Disabled`);let n=Array.isArray(e.user_paths)?e.user_paths:[];return n.length>0&&t.push(`Allowed for `+n.join(`, `)),t.join(` · `)}function bO({models:e,aliases:t,virtualModelsAvailable:n,activeCategory:r}){let i=Array.isArray(e)?e:[],a=Array.isArray(t)?t:[],o=new Map;if(n)for(let e of a){let t=eO(e&&e.name);!t||e.enabled===!1||!e.valid||o.set(t,e)}let s=new Map,c=i.map(e=>{let t=tO(e),n=null;for(let t of rO(e))s.has(t)||s.set(t,e),!n&&o.has(t)&&(n=o.get(t));let r=e&&e.access?e.access:null;return{key:`model:`+t,display_name:t,secondary_name:``,provider_name:e.provider_name||``,provider_type:e.provider_type||``,model:e.model,selector:e.selector||``,is_alias:!1,alias:null,access:r,masking_alias:n,has_virtual_model:!!(n||r&&r.override),alias_state_class:``,alias_state_text:``}});if(!n)return c;for(let e of a){let t=s.get(eO(e&&e.name));if(e&&e.enabled!==!1&&e.valid&&t)continue;let n=null;for(let t of iO(e))if(n=s.get(t)||null,n)break;!n&&r&&r!==`all`||c.push({key:`alias:`+e.name,display_name:e.name,secondary_name:mO(e),provider_name:n&&n.provider_name||``,provider_type:n?n.provider_type||e.provider_type||``:e.provider_type||``,model:n?n.model:{id:e.name,object:`model`},selector:``,is_alias:!0,alias:e,access:null,masking_alias:null,source_model_exists:!!t,has_virtual_model:!0,alias_state_class:hO(e),alias_state_text:gO(e)})}return c.sort((e,t)=>e.is_alias===t.is_alias?String(e.display_name||``).localeCompare(String(t.display_name||``)):e.is_alias?-1:1)}function xO(e,t){if(!t)return e;let n=String(t).toLowerCase();return e.filter(e=>[e.display_name,e.secondary_name,e.provider_name,e.provider_type,e.model&&e.model.owned_by,e.alias&&e.alias.description,e.alias&&e.alias_state_text,e.model&&e.model.metadata&&e.model.metadata.modes?e.model.metadata.modes.join(`,`):``,e.model&&e.model.metadata&&e.model.metadata.categories?e.model.metadata.categories.join(`,`):``].some(e=>String(e||``).toLowerCase().includes(n)))}function SO(e,t){return String(e||``).trim()||String(t||``).trim()||`Unassigned`}function CO(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!r||r===n?``:r}function wO(e){let t=String(e||``).trim();return t?t+`/`:``}function TO(e){let t=Array.isArray(e)?e:[],n=t.filter(e=>e&&!e.is_alias).length,r=t.filter(e=>e&&e.is_alias).length,i=[];return n>0&&i.push(n+(n===1?` model`:` models`)),r>0&&i.push(r+(r===1?` alias`:` aliases`)),i.join(` · `)}function EO(e,t,n){let r=String(t||``).trim(),i=String(n||``).trim();for(let t of Array.isArray(e)?e:[]){let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim();if(!(r&&e!==r)&&!(!r&&i&&n!==i)&&t&&t.access)return t.access.default_enabled!==!1}return!0}function DO(e){for(let t of Array.isArray(e)?e:[])if(t&&t.access)return t.access.default_enabled!==!1;return!0}function OO(e,t){let n=String(t||``).trim();if(!n)return null;for(let t of Array.isArray(e)?e:[])if(String(t&&t.selector||``).trim()===n)return t;return null}function kO(e,t,n,r){let i=wO(t),a=r&&r.get(`/`)||null,o=i&&r&&r.get(i)||null,s=EO(e,t,n),c=o||a,l=c&&Array.isArray(c.user_paths)?Array.from(new Set(c.user_paths)).sort():[];return{selector:i,default_enabled:s,effective_enabled:c?c.enabled!==!1:s,user_paths:l,override:o}}function AO(e,t,n){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let e of Array.isArray(n)?n:[]){let t=String(e&&e.selector||``).trim();t&&r.set(t,e)}let i=[],a=new Map;for(let t of e){if(t&&t.is_alias){i.push(t);continue}let e=String(t&&t.provider_name||``).trim(),n=String(t&&t.provider_type||``).trim(),r=`provider-group:`+(e||n||`unassigned`);a.has(r)||a.set(r,{key:r,provider_name:e,provider_type:n,display_name:SO(e,n),type_label:CO(e,n),rows:[]});let o=a.get(r);!o.provider_name&&e&&(o.provider_name=e),!o.provider_type&&n&&(o.provider_type=n),o.display_name=SO(o.provider_name,o.provider_type),o.type_label=CO(o.provider_name,o.provider_type),o.rows.push(t)}let o=Array.from(a.values()).map(e=>{let n=kO(t,e.provider_name,e.provider_type,r);return{...e,access:n,access_summary:yO(n),item_count_label:TO(e.rows)}}).sort((e,t)=>String(e.display_name||``).localeCompare(String(t.display_name||``)));return i.length>0&&o.unshift({key:`virtual-model-group`,is_virtual_models:!0,provider_name:``,provider_type:``,display_name:`Virtual models`,type_label:``,rows:i,access:{selector:``},access_summary:``,item_count_label:TO(i)}),o}function jO(e,t){let n=OO(t,`/`),r=DO(e),i=n&&Array.isArray(n.user_paths)?n.user_paths:[];return{key:`scope-global`,is_alias:!1,display_name:`all providers and models`,access:{selector:`/`,default_enabled:r,effective_enabled:n?n.enabled!==!1:r,user_paths:i,override:n}}}function MO(e){return e?String(e.access&&e.access.selector||``).trim()||String(e.override_selector||``).trim()||tO(e):``}function NO(e){if(!e)return[];let t=[];return e.is_alias?t.push(`alias-row`,hO(e.alias)):e.has_virtual_model&&t.push(`alias-row`,`is-valid`),!e.is_alias&&e.masking_alias&&t.push(`masked-model-row`),!e.is_alias&&e.access&&e.access.effective_enabled===!1&&t.push(`model-access-disabled-row`),t}function PO(e){return!!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)}function FO(e){return!!(e&&!e.is_alias&&e.masking_alias&&e.masking_alias.name&&!e.masking_alias.managed)}function IO(e){return e&&e.is_alias&&e.alias&&e.alias.name?`alias-row-`+String(e.alias.name).replace(/[^a-zA-Z0-9_-]+/g,`-`):``}function LO(e){return e?e.is_alias?!!(e.alias&&e.alias.managed):!!(e.access&&e.access.override&&e.access.override.managed||e.masking_alias&&e.masking_alias.managed):!1}function RO(e){return!!(e&&e.override)}function zO(e){return e?`table-action-btn-active`:``}function BO(e,t){let n=`Edit `+String(e||`model access`);return t?n+` (virtual model exists)`:n}function VO(){return{source:``,target_model:``,target_weight:1,targets:[],strategy:`round_robin`,session_affinity:!0,user_paths:``,description:``,enabled:!0}}function HO(e){return String(e&&e.target_model||``).trim()!==``}function UO(e){return String(e&&e.target_model||``).trim()?!0:cO(e&&e.targets).length>0}function WO(e){return!!e&&Array.isArray(e.targets)&&e.targets.length>0}function GO(e){return WO(e)&&String(e&&e.strategy||``).toLowerCase()!==`cost`}function KO(e){let t=Array.isArray(e.targets)?e.targets:[];if(t.length>0){let n=t.shift();e.target_model=n.model||``,e.target_weight=n.weight||1;return}e.target_model=``,e.target_weight=1}function qO(e){let t=Array.isArray(e&&e.targets)?e.targets:[];return t.length>0?{primaryModel:aO(t[0]),primaryWeight:t[0].weight||1,extraTargets:t.slice(1).map(e=>({model:aO(e),weight:e.weight||1}))}:{primaryModel:e&&e.target_provider?e.target_provider+`/`+e.target_model:e&&e.target_model||``,primaryWeight:1,extraTargets:[]}}function JO(e){return String(e||``).split(/\r?\n|,/).map(e=>String(e||``).trim()).filter(Boolean)}function YO(e,t,n){let r=String(e&&e.source||``).trim(),i=String(e&&e.target_model||``).trim(),a=cO(e&&e.targets),o=UO(e),s=String(t||``).trim(),c=n===`edit`&&!!s&&r!==s,l={source:r,user_paths:JO(e&&e.user_paths),description:String(e&&e.description||``).trim(),enabled:!!(e&&e.enabled)};if(c&&(l.old_source=s),o){let t=[];if(i&&t.push(sO(i,e.target_weight)),t.push(...a),t.length>1){let n=e.strategy||`round_robin`;l.targets=n===`cost`?t.map(e=>({model:e.model})):t,l.strategy=n,e&&e.session_affinity===!1&&(l.session_affinity=!1)}else l.target_model=t[0].model}return{payload:l,source:r,isRedirect:o,isRename:c}}function XO(e){let t={source:e.name,description:String(e.description||``).trim(),user_paths:Array.isArray(e.user_paths)?e.user_paths:[],enabled:e.enabled===!1},n=Array.isArray(e.targets)?e.targets:[];return n.length>1?(t.strategy=e.strategy||`round_robin`,e.session_affinity===!1&&(t.session_affinity=!1),t.targets=t.strategy===`cost`?n.map(e=>({model:aO(e)})):n.map(e=>sO(aO(e),e.weight))):n.length===1?t.target_model=aO(n[0]):t.target_model=e.target_provider?e.target_provider+`/`+e.target_model:e.target_model,t}function ZO(e,t,n){let r=n||{},i=r.effective_enabled===!1,a=t&&Array.isArray(t.user_paths)?t.user_paths:[],o=`PUT`,s;return i===!1?s={source:e,enabled:!1,user_paths:a}:t&&a.length===0&&r.default_enabled!==!1?(o=`DELETE`,s={source:e}):s={source:e,enabled:!0,user_paths:a},{method:o,payload:s,desired:i}}function QO(e,t,n){let r=Math.max(1,Number(t||75)),i=Math.min(n,e+r);return{limit:i,rendering:ibO({models:Nc.models,aliases:this.aliases,virtualModelsAvailable:this.virtualModelsAvailable,activeCategory:Nc.activeCategory}));get displayModels(){return I(this.#T)}set displayModels(e){A(this.#T,e)}#E=O(()=>AO(this.displayModels,Nc.models,this.modelOverrideViews));get displayModelGroups(){return I(this.#E)}set displayModelGroups(e){A(this.#E,e)}#D=O(()=>xO(this.displayModels,Nc.filter));get filteredDisplayModels(){return I(this.#D)}set filteredDisplayModels(e){A(this.#D,e)}#O=O(()=>{let e=this.filteredDisplayModels,t=Math.max(0,Math.min(Number(this.modelRenderLimit||0),e.length));return!Nc.filter&&t>=this.displayModels.length?this.displayModelGroups:AO(e.slice(0,t),Nc.models,this.modelOverrideViews)});get filteredDisplayModelGroups(){return I(this.#O)}set filteredDisplayModelGroups(e){A(this.#O,e)}#k=O(()=>jO(Nc.models,this.modelOverrideViews));get globalScopeRow(){return I(this.#k)}set globalScopeRow(e){A(this.#k,e)}modelsBusy(){return!!(Nc.loading||this.modelsRendering)}modelLoadingText(){if(Nc.loading)return this.displayModels.length>0?`Refreshing models...`:`Loading models...`;let e=this.filteredDisplayModels.length;return`Rendering models... `+Math.min(Number(this.modelRenderLimit||0),e)+` / `+e}restartModelRendering(e){let t=++this.#a,n=$O(this.modelRenderBatchSize,e);this.modelRenderLimit=n.limit,this.modelsRendering=n.rendering,n.rendering&&this.#A(t)}stopModelRendering(){this.#a++,this.modelsRendering=!1}#A(e){let t=()=>{if(e!==this.#a)return;let t=QO(this.modelRenderLimit,this.modelRenderBatchSize,this.filteredDisplayModels.length);this.modelRenderLimit=t.limit,this.modelsRendering=t.rendering,t.rendering&&this.#A(e)};typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>setTimeout(t,0)):setTimeout(t,0)}async fetchVirtualModels(){this.aliasLoading=!0,this.aliasError=``;try{let e=await _s(`/admin/virtual-models`,{label:`virtual models`});if(e.status===503){this.virtualModelsAvailable=!1,this.aliases=[],this.modelOverrideViews=[];return}if(e.stale)return;if(this.virtualModelsAvailable=!0,!e.ok){this.aliases=[],this.modelOverrideViews=[];return}let{aliases:t,policies:n}=pO(e.data);this.aliases=t,this.modelOverrideViews=n}catch(e){console.error(`Failed to fetch virtual models:`,e),this.aliases=[],this.modelOverrideViews=[],this.aliasError=`Unable to load virtual models.`}finally{this.aliasLoading=!1}}qualifiedModelName(e){return tO(e)}findModelOverrideView(e){return OO(this.modelOverrideViews,e)}hasGlobalModelOverride(){return!!this.findModelOverrideView(`/`)}findExistingAliasByName(e){let t=eO(e);if(!t)return null;for(let e of this.aliases)if(eO(e&&e.name)===t)return e;return null}findConcreteModelByName(e){let t=eO(e);if(!t)return null;for(let e of Nc.models)if(rO(e).has(t))return e;return null}rowToggleEnabled(e){return e?e.is_alias?e.alias&&e.alias.enabled!==!1:!!(e.access&&e.access.effective_enabled!==!1):!1}rowToggleLabel(e){return this.rowTogglingKey&&this.rowTogglingKey===e.key?`Updating...`:this.rowToggleRestricted(e)?`Restricted`:this.rowToggleEnabled(e)?`Enabled`:`Disabled`}rowToggleRestricted(e){return!!e&&!e.is_alias&&vO(e.access,this.virtualModelsAvailable)===`is-restricted`}rowToggleAriaLabel(e){if(!e)return``;let t=this.rowToggleEnabled(e)?`Disable `:`Enable `,n;return n=e.is_alias?`alias `+String(e.alias&&e.alias.name||``):String(e.display_name||e.access&&e.access.selector||`model`),t+n.trim()}async toggleRowEnabled(e){if(this.virtualModelsAvailable&&!(!e||this.rowTogglingKey===e.key)){if(LO(e)){q.success(`This virtual model is managed by configuration and is read-only.`);return}if(e.is_alias){await this.toggleAliasRow(e);return}await this.toggleModelRow(e)}}async toggleAliasRow(e){let t=e.alias;if(!t||!t.name)return;this.rowTogglingKey=e.key;let n=XO(t);try{let e=await vs(`/admin/virtual-models`,`PUT`,n,{label:`alias state`});if(e.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(e.stale)return;if(!e.ok){q.error(e.status===401?`Authentication required.`:ps(e,`Failed to update alias state.`));return}q.success(n.enabled?`Alias enabled.`:`Alias disabled.`),this.fetchVirtualModels()}catch(e){console.error(`Failed to toggle alias state:`,e),q.error(`Failed to update alias state.`)}finally{this.rowTogglingKey=``}}async toggleModelRow(e){let t=MO(e);if(!t)return;let{method:n,payload:r,desired:i}=ZO(t,this.findModelOverrideView(t),e.access||{});this.rowTogglingKey=e.key;try{let e=await vs(`/admin/virtual-models`,n,r,{label:`model access`});if(e.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(!(n===`DELETE`&&e.status===404)){if(e.stale)return;if(!e.ok){q.error(e.status===401?`Authentication required.`:ps(e,`Failed to update model access.`));return}}q.success(i?`Model enabled.`:`Model disabled.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to toggle model access:`,e),q.error(`Failed to update model access.`)}finally{this.rowTogglingKey=``}}async removeAliasRow(e){if(!(e&&e.is_alias&&e.alias&&e.alias.name&&!e.alias.managed)||this.rowDeletingKey)return;let t=String(e.alias.name||``).trim();t&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the virtual model alias "`+t+`"?`,method:`DELETE`,payload:{source:t},operation:`virtual model`,failureMessage:`Failed to remove virtual model.`,notice:`Virtual model removed.`,ignoreNotFound:!0})}async removeRedirectRow(e){let t=e&&e.masking_alias;if(!(e&&!e.is_alias&&t&&t.name&&!t.managed)||this.rowDeletingKey)return;let n=String(t.name||``).trim();n&&await this.mutateVirtualModelRow({rowKey:e.key,confirmMessage:`Remove the redirect for "`+n+`"? Other virtual model settings will be preserved.`,method:`PUT`,payload:{source:n,user_paths:Array.isArray(t.user_paths)?t.user_paths:[],description:String(t.description||``).trim(),enabled:t.enabled!==!1},operation:`virtual model redirect`,failureMessage:`Failed to remove redirect.`,notice:`Redirect removed. Other virtual model settings were preserved.`})}async mutateVirtualModelRow(e){if(!this.rowDeletingKey&&window.confirm(e.confirmMessage)){this.rowDeletingKey=e.rowKey;try{let t=await vs(`/admin/virtual-models`,e.method,e.payload,{label:e.operation});if(t.status===503){this.virtualModelsAvailable=!1,q.error(`Virtual models feature is unavailable.`);return}if(!(e.ignoreNotFound&&t.status===404)){if(t.stale)return;if(!t.ok){q.error(t.status===401?`Authentication required.`:ps(t,e.failureMessage));return}}this.virtualModelsAvailable=!0,q.success(e.notice),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(t){console.error(e.failureMessage,t),q.error(e.failureMessage)}finally{this.rowDeletingKey=``}}}addVmTarget(){Array.isArray(this.vmForm.targets)||(this.vmForm.targets=[]),this.vmForm.targets.push({model:``,weight:1})}removeVmTarget(e){Array.isArray(this.vmForm.targets)&&this.vmForm.targets.splice(e,1)}removePrimaryTarget(){KO(this.vmForm)}vmFormHasPrimaryTarget(){return HO(this.vmForm)}vmFormShowStrategy(){return WO(this.vmForm)}vmStrategyOptions(){return dO(Ss.virtualModelStrategies(),this.vmForm.strategy)}vmFormShowWeights(){return GO(this.vmForm)}vmFormToggleRestricted(){return!!(this.vmForm&&this.vmForm.enabled)&&_O(JO(this.vmForm.user_paths))}vmFormToggleLabel(){return!this.vmForm||!this.vmForm.enabled?`Disabled`:this.vmFormToggleRestricted()?`Restricted`:`Enabled`}resetVirtualModelForm(){this.vmFormError=``,this.vmFormHelpOpen=!1,this.vmFormUserPathsHelpOpen=!1,this.vmSubmitting=!1,this.vmDeleting=!1,this.vmFormHasExisting=!1,this.vmFormDefaultEnabled=!0,this.vmFormEffectiveEnabled=!0,this.vmFormDisplayName=``,this.vmFormSourceLocked=!1,this.vmFormOriginalSource=``,this.vmFormManaged=!1,this.vmForm=VO()}closeVirtualModelForm(){this.vmFormOpen=!1,this.resetVirtualModelForm()}openVirtualModelCreate(e){this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`create`,this.vmFormSourceLocked=!1,this.vmFormDisplayName=`New virtual model`,e&&e.model&&e.model.id&&(this.vmForm.target_model=tO(e))}openVirtualModelEditAlias(e){if(!e)return;this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!1,this.vmFormHasExisting=!0,this.vmFormManaged=!!e.managed,this.vmFormOriginalSource=e.name||``,this.vmFormDisplayName=e.name||``,this.vmFormDefaultEnabled=DO(Nc.models),this.vmFormEffectiveEnabled=e.enabled!==!1;let{primaryModel:t,primaryWeight:n,extraTargets:r}=qO(e);this.vmForm={source:e.name||``,target_model:t,target_weight:n,targets:r,strategy:e.strategy||`round_robin`,session_affinity:e.session_affinity!==!1,user_paths:(Array.isArray(e.user_paths)?e.user_paths:[]).join(` -`),description:e.description||``,enabled:e.enabled!==!1}}openVirtualModelEditModel(e){if(!e||e.is_alias)return;let t=e.access||{},n=t.override||null,r=n&&Array.isArray(n.user_paths)?n.user_paths:Array.isArray(t.user_paths)?t.user_paths:[],i=MO(e);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!n,this.vmFormOriginalSource=i;let a=n?n.enabled!==!1:t.effective_enabled!==!1;this.vmFormDefaultEnabled=t.default_enabled!==!1,this.vmFormEffectiveEnabled=a,this.vmFormManaged=!!(n&&n.managed),this.vmFormDisplayName=e.access_display_name||e.display_name||i||``,this.vmForm={source:i,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:r.join(` -`),description:n&&n.description?n.description:``,enabled:a}}openGlobalModelOverrideEdit(){let e=this.findModelOverrideView(`/`),t=e&&Array.isArray(e.user_paths)?e.user_paths:[],n=DO(Nc.models);this.resetVirtualModelForm(),this.vmFormOpen=!0,this.vmFormMode=`edit`,this.vmFormSourceLocked=!0,this.vmFormHasExisting=!!e,this.vmFormOriginalSource=`/`,this.vmFormDefaultEnabled=n,this.vmFormEffectiveEnabled=e?e.enabled!==!1:n,this.vmFormManaged=!!(e&&e.managed),this.vmFormDisplayName=`All providers and models`,this.vmForm={source:`/`,target_model:``,target_weight:``,targets:[],strategy:`round_robin`,user_paths:t.join(` -`),description:e&&e.description?e.description:``,enabled:e?e.enabled!==!1:n}}openProviderOverrideEdit(e){!e||!e.access||!e.access.selector||this.openVirtualModelEditModel({display_name:e.display_name,access_display_name:`All models in `+e.display_name,provider_name:e.provider_name,provider_type:e.provider_type,access:e.access,override_selector:e.access.selector,is_alias:!1})}async submitVirtualModelForm(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be edited here.`;return}let{payload:e,source:t,isRedirect:n,isRename:r}=YO(this.vmForm,this.vmFormOriginalSource,this.vmFormMode);if(!t){this.vmFormError=`Source is required.`;return}if(this.vmFormError=``,this.vmFormMode!==`edit`){let e=this.findExistingAliasByName(t),r=e?null:this.findModelOverrideView(t);if(e||r){let n=e?`A virtual model named "`+e.name+`" already exists. Saving will update that virtual model. Continue?`:`An access policy for "`+t+`" already exists. Saving will update that virtual model. Continue?`;if(!window.confirm(n)){this.vmFormError=`Choose a different source or edit the existing virtual model.`;return}}else if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Creating this alias will mask that model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}else if(r){let e=(this.aliases||[]).find(e=>e&&e.name===t)||null,r=e?null:this.findModelOverrideView(t);if(e||r){this.vmFormError=`A virtual model for "`+t+`" already exists. Choose a different source.`;return}if(n){let e=this.findConcreteModelByName(t);if(e){let t=tO(e)||String(e.model&&e.model.id||``).trim();if(!window.confirm(`A model named "`+t+`" already exists. Renaming to that name will mask the model in the list. Continue?`)){this.vmFormError=`Choose a different source to avoid masking an existing model.`;return}}}}this.vmSubmitting=!0;try{let t=await vs(`/admin/virtual-models`,`PUT`,e,{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:ps(t,`Failed to save virtual model.`);return}let r=!n&&t.status===204;this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),q.success(n?`Alias saved.`:r?`Model access reset to inherited/default.`:`Model access saved.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to save virtual model:`,e),this.vmFormError=`Failed to save virtual model.`}finally{this.vmSubmitting=!1}}async deleteVirtualModel(){if(this.vmFormManaged){this.vmFormError=`This virtual model is managed by configuration and cannot be removed here.`;return}let e=String(this.vmForm.source||this.vmFormOriginalSource||``).trim();if(!(!e||!this.vmFormHasExisting)&&window.confirm(`Remove the virtual model for "`+e+`"? This reverts to inherited/default behavior.`)){this.vmDeleting=!0,this.vmFormError=``;try{let t=await vs(`/admin/virtual-models`,`DELETE`,{source:e},{label:`virtual model`});if(t.status===503){this.virtualModelsAvailable=!1,this.vmFormError=`Virtual models feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.vmFormError=t.status===401?`Authentication required.`:ps(t,`Failed to remove virtual model.`);return}}this.virtualModelsAvailable=!0,this.closeVirtualModelForm(),q.success(`Virtual model removed.`),Promise.all([Nc.fetchModels(),this.fetchVirtualModels()])}catch(e){console.error(`Failed to delete virtual model:`,e),this.vmFormError=`Failed to remove virtual model.`}finally{this.vmDeleting=!1}}}},tk=[{value:`input_per_mtok`,label:`Input $/MTok`,group:`Tokens`},{value:`output_per_mtok`,label:`Output $/MTok`,group:`Tokens`},{value:`cached_input_per_mtok`,label:`Cached input $/MTok`,group:`Tokens`},{value:`cache_write_per_mtok`,label:`Cache write $/MTok`,group:`Tokens`},{value:`reasoning_output_per_mtok`,label:`Reasoning output $/MTok`,group:`Tokens`},{value:`batch_input_per_mtok`,label:`Batch input $/MTok`,group:`Batch`},{value:`batch_output_per_mtok`,label:`Batch output $/MTok`,group:`Batch`},{value:`audio_input_per_mtok`,label:`Audio input $/MTok`,group:`Audio`},{value:`audio_output_per_mtok`,label:`Audio output $/MTok`,group:`Audio`},{value:`per_image`,label:`$/Image`,group:`Image`},{value:`input_per_image`,label:`Input $/Image`,group:`Image`},{value:`per_second_input`,label:`Input $/Second`,group:`Audio/Video`},{value:`per_second_output`,label:`Output $/Second`,group:`Video`},{value:`per_character_input`,label:`$/Character`,group:`Audio`},{value:`per_page`,label:`$/Page`,group:`Utility`},{value:`per_request`,label:`$/Request`,group:`Utility`}];function nk(e){let t=tk.find(t=>t.value===e);return t?t.label:String(e||``).replace(/_/g,` `)}function rk(e){return e&&typeof e==`object`?JSON.parse(JSON.stringify(e)):{}}function ik(e,t){let n=rk(e),r=t&&t.pricing?t.pricing:t;if(!r||typeof r!=`object`)return n;for(let e of tk)r[e.value]!==null&&r[e.value]!==void 0&&(n[e.value]=Number(r[e.value]));return Array.isArray(r.tiers)&&r.tiers.length>0&&(n.tiers=rk(r.tiers)),n}function ak(e){switch(String(e||``).trim()){case`config_yaml`:return`config.yaml`;case`model_registry`:return`Model registry`;default:return e?String(e):`Unknown`}}function ok(e){let t=e&&e.pricing?e.pricing:{},n=e&&e.pricing_sources&&typeof e.pricing_sources==`object`?e.pricing_sources:{},r={};for(let e of tk)t[e.value]!==null&&t[e.value]!==void 0&&(r[e.value]=ak(n[e.value]||`model_registry`));return r}function sk(e){let t=String(e&&e.selector||``).trim();return t?`Dashboard/API override (`+t+`)`:`Dashboard/API override`}function ck(e){let t=String(e||``).trim();return t?t+`/`:``}function lk(e){return String(e&&e.model&&e.model.id||``).trim()}function uk(e){let t=String(e&&e.provider_name||``).trim(),n=lk(e);return t&&n?t+`/`+n:n}function dk(e){return lk(e)}function fk(e){let t=new Map;for(let n of Array.isArray(e)?e:[]){let e=String(n&&n.selector||``).trim();e&&t.set(e,n)}return t}function pk(e,t){let n=String(t||``).trim();return n&&fk(e).get(n)||null}function mk(e,t,n){let r=fk(e),i=uk(t),a=dk(t),o=ck(t&&t.provider_name),s=String(n||``).trim();for(let e of[i,a,o,`/`]){if(!e||e===s)continue;let t=r.get(e);if(t)return t}return null}function hk(e,t,n){let r=e&&e.model&&e.model.metadata?e.model.metadata:null,i=rk(r&&r.pricing),a=ok(r),o=mk(t,e,n),s=o&&o.pricing?o.pricing:null;if(s){let e=sk(o);for(let t of tk)s[t.value]!==null&&s[t.value]!==void 0&&(i[t.value]=Number(s[t.value]),a[t.value]=e);Array.isArray(s.tiers)&&s.tiers.length>0&&(i.tiers=rk(s.tiers),a.tiers=e)}return{pricing:i,sources:a}}function gk(e,t){let n=e&&e.pricing?e.pricing:{},r=[];for(let e of tk)n[e.value]!==null&&n[e.value]!==void 0&&r.push({id:t(),field:e.value,value:String(n[e.value])});return r}function _k(e,t){let n=new Set;for(let r of Array.isArray(e)?e:[]){if(t&&r.id===t)continue;let e=String(r.field||``).trim();e&&n.add(e)}return n}function vk(e,t){let n=_k(e,t&&t.id);return tk.filter(e=>e.value===(t&&t.field)||!n.has(e.value))}function yk(e,t){let n={},r=new Set;for(let t of Array.isArray(e)?e:[]){let e=String(t.field||``).trim();if(!e)return{error:`Choose a price type for every row.`};if(r.has(e))return{error:`Each price type can only be used once.`};r.add(e);let i=String(t.value||``).trim();if(i===``)return{error:`Enter a value for `+nk(e)+`.`};let a=Number(i);if(!Number.isFinite(a)||a<0)return{error:`Pricing values must be numbers greater than or equal to 0.`};n[e]=a}let i=Array.isArray(t)?t:[];return i.length>0&&(n.tiers=rk(i)),Object.keys(n).length===0?{error:`Add at least one pricing field before saving.`}:{pricing:n}}function bk(e,t,n){let r=e||{},i=t||{},a=n||{},o=ik(r,a);return tk.map(e=>{let t=a[e.value]!==null&&a[e.value]!==void 0,n=r[e.value]!==null&&r[e.value]!==void 0;return{field:e.value,label:e.label,value:o[e.value],source:t?`Form/API value`:n?i[e.value]||`Model registry`:`Unset`}}).filter(e=>e.source!==`Unset`||e.value!==void 0)}var xk=new class{#e=k(!0);get modelPricingOverridesAvailable(){return I(this.#e)}set modelPricingOverridesAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get modelPricingOverrideViews(){return I(this.#t)}set modelPricingOverrideViews(e){A(this.#t,e,!0)}#n=k(``);get modelPricingOverrideError(){return I(this.#n)}set modelPricingOverrideError(e){A(this.#n,e,!0)}#r=k(!1);get modelPricingOverrideFormOpen(){return I(this.#r)}set modelPricingOverrideFormOpen(e){A(this.#r,e,!0)}#i=k(!1);get modelPricingOverrideSubmitting(){return I(this.#i)}set modelPricingOverrideSubmitting(e){A(this.#i,e,!0)}#a=k(!1);get modelPricingOverrideFormHasExistingOverride(){return I(this.#a)}set modelPricingOverrideFormHasExistingOverride(e){A(this.#a,e,!0)}#o=k(``);get modelPricingOverrideFormDisplayName(){return I(this.#o)}set modelPricingOverrideFormDisplayName(e){A(this.#o,e,!0)}#s=k(``);get modelPricingOverrideFormScope(){return I(this.#s)}set modelPricingOverrideFormScope(e){A(this.#s,e,!0)}#c=k(j([]));get modelPricingOverrideFormScopeOptions(){return I(this.#c)}set modelPricingOverrideFormScopeOptions(e){A(this.#c,e,!0)}#l=k(null);get modelPricingOverrideFormRow(){return I(this.#l)}set modelPricingOverrideFormRow(e){A(this.#l,e,!0)}#u=k(null);get modelPricingOverrideFormBasePricing(){return I(this.#u)}set modelPricingOverrideFormBasePricing(e){A(this.#u,e,!0)}#d=k(null);get modelPricingOverrideFormBasePricingSources(){return I(this.#d)}set modelPricingOverrideFormBasePricingSources(e){A(this.#d,e,!0)}#f=k(j([]));get modelPricingOverrideFormPreservedTiers(){return I(this.#f)}set modelPricingOverrideFormPreservedTiers(e){A(this.#f,e,!0)}#p=k(j([]));get modelPricingOverrideRows(){return I(this.#p)}set modelPricingOverrideRows(e){A(this.#p,e,!0)}#m=k(j({selector:``}));get modelPricingOverrideForm(){return I(this.#m)}set modelPricingOverrideForm(e){A(this.#m,e,!0)}_modelPricingOverrideRowID=0;pricingFieldOptions(){return tk}pricingFieldLabel(e){return nk(e)}async fetchModelPricingOverrides(){this.modelPricingOverrideError=``;try{let e=await _s(`/admin/model-pricing-overrides`,{label:`model pricing overrides`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideViews=[];return}if(e.stale)return;if(this.modelPricingOverridesAvailable=!0,!e.ok){this.modelPricingOverrideViews=[];return}this.modelPricingOverrideViews=Array.isArray(e.data)?e.data:[]}catch(e){console.error(`Failed to fetch model pricing overrides:`,e),this.modelPricingOverrideViews=[],this.modelPricingOverrideError=`Unable to load model pricing overrides.`}}findModelPricingOverrideView(e){return pk(this.modelPricingOverrideViews,e)}hasGlobalPricingOverride(){return!!this.findModelPricingOverrideView(`/`)}hasProviderPricingOverride(e){return!!this.findModelPricingOverrideView(ck(e&&e.provider_name))}hasModelPricingOverride(e){return!!this.findModelPricingOverrideView(uk(e))}modelPricingButtonClass(e){return e?`table-action-btn-active`:``}modelPricingButtonLabel(e,t){let n=`Edit `+String(e||`model pricing`);return t?n+` (override exists)`:n}modelRowPricing(e){return hk(e,this.modelPricingOverrideViews).pricing}openGlobalPricingOverrideEdit(){this.openModelPricingOverrideForm({displayName:`All providers and models`,selector:`/`,scope:`global`,scopeOptions:[{value:`global`,label:`All providers and models`,selector:`/`}],row:null})}openProviderPricingOverrideEdit(e){let t=ck(e&&e.provider_name);t&&this.openModelPricingOverrideForm({displayName:`All models in `+(e.display_name||e.provider_name||t),selector:t,scope:`provider`,scopeOptions:[{value:`provider`,label:`Provider`,selector:t}],row:null})}openModelPricingOverrideEdit(e){if(!e||e.is_alias)return;let t=uk(e),n=dk(e),r=[{value:`exact`,label:`This provider and model`,selector:t}];n&&n!==t&&r.push({value:`model`,label:`This model across providers`,selector:n}),this.openModelPricingOverrideForm({displayName:e.display_name||t,selector:t,scope:`exact`,scopeOptions:r,row:e})}openModelPricingOverrideForm(e){let t=e||{};this.modelPricingOverrideFormOpen=!0,this.modelPricingOverrideError=``,this.modelPricingOverrideFormDisplayName=t.displayName||t.selector||`Pricing`,this.modelPricingOverrideFormScope=t.scope||``,this.modelPricingOverrideFormScopeOptions=Array.isArray(t.scopeOptions)?t.scopeOptions:[],this.modelPricingOverrideFormRow=t.row||null,this.modelPricingOverrideForm={selector:t.selector||``},this.loadModelPricingOverrideFormSelector(t.selector||``)}loadModelPricingOverrideFormSelector(e){e=String(e||``).trim();let t=this.findModelPricingOverrideView(e);this.modelPricingOverrideFormHasExistingOverride=!!t,this.modelPricingOverrideRows=gk(t,()=>this.nextModelPricingOverrideRowID()),this.modelPricingOverrideFormPreservedTiers=t&&t.pricing&&Array.isArray(t.pricing.tiers)?rk(t.pricing.tiers):[],this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow();let n=this.modelPricingOverrideFormRow,r=n?hk(n,this.modelPricingOverrideViews,e):{pricing:{},sources:{}};this.modelPricingOverrideFormBasePricing=r.pricing,this.modelPricingOverrideFormBasePricingSources=r.sources}setModelPricingOverrideScope(e){this.modelPricingOverrideFormScope=e;let t=this.modelPricingOverrideFormScopeOptions.find(t=>t.value===e);t&&(this.modelPricingOverrideForm.selector=t.selector,this.loadModelPricingOverrideFormSelector(t.selector))}nextModelPricingOverrideRowID(){return this._modelPricingOverrideRowID=(this._modelPricingOverrideRowID||0)+1,`pricing-row-`+this._modelPricingOverrideRowID}availablePricingFieldOptions(e){return vk(this.modelPricingOverrideRows,e)}addModelPricingOverrideRow(){let e=_k(this.modelPricingOverrideRows),t=tk.find(t=>!e.has(t.value))||tk[0];t&&this.modelPricingOverrideRows.push({id:this.nextModelPricingOverrideRowID(),field:t.value,value:``})}removeModelPricingOverrideRow(e){this.modelPricingOverrideRows=this.modelPricingOverrideRows.filter(t=>t.id!==e.id),this.modelPricingOverrideRows.length===0&&this.modelPricingOverrideFormPreservedTiers.length===0&&this.addModelPricingOverrideRow()}modelPricingOverridePayload(){return yk(this.modelPricingOverrideRows,this.modelPricingOverrideFormPreservedTiers)}modelPricingOverrideDraftPricing(){let e=this.modelPricingOverridePayload();return e&&e.pricing?e.pricing:{}}modelPricingEffectivePreviewRows(){return bk(this.modelPricingOverrideFormBasePricing,this.modelPricingOverrideFormBasePricingSources,this.modelPricingOverrideDraftPricing())}closeModelPricingOverrideForm(){this.modelPricingOverrideFormOpen=!1,this.modelPricingOverrideSubmitting=!1,this.modelPricingOverrideError=``,this.modelPricingOverrideFormHasExistingOverride=!1,this.modelPricingOverrideFormDisplayName=``,this.modelPricingOverrideFormScope=``,this.modelPricingOverrideFormScopeOptions=[],this.modelPricingOverrideFormRow=null,this.modelPricingOverrideFormBasePricing=null,this.modelPricingOverrideFormBasePricingSources=null,this.modelPricingOverrideFormPreservedTiers=[],this.modelPricingOverrideRows=[],this.modelPricingOverrideForm={selector:``}}async submitModelPricingOverrideForm(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!e){this.modelPricingOverrideError=`Model pricing selector is required.`;return}let t=this.modelPricingOverridePayload();if(t.error){this.modelPricingOverrideError=t.error;return}let n={selector:e,...t};this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let e=await vs(`/admin/model-pricing-overrides`,`PUT`,n,{label:`model pricing override`});if(e.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(e.stale)return;if(!e.ok){this.modelPricingOverrideError=e.status===401?`Authentication required.`:ps(e,`Failed to save model pricing.`);return}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),q.success(`Model pricing saved.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to save model pricing override:`,e),this.modelPricingOverrideError=`Failed to save model pricing.`}finally{this.modelPricingOverrideSubmitting=!1}}async deleteModelPricingOverride(){let e=String(this.modelPricingOverrideForm.selector||``).trim();if(!(!e||!this.modelPricingOverrideFormHasExistingOverride)&&window.confirm(`Remove the model pricing override for "`+e+`"?`)){this.modelPricingOverrideSubmitting=!0,this.modelPricingOverrideError=``;try{let t=await vs(`/admin/model-pricing-overrides`,`DELETE`,{selector:e},{label:`model pricing override`});if(t.status===503){this.modelPricingOverridesAvailable=!1,this.modelPricingOverrideError=`Model pricing overrides feature is unavailable.`;return}if(t.status!==404){if(t.stale)return;if(!t.ok){this.modelPricingOverrideError=t.status===401?`Authentication required.`:ps(t,`Failed to remove model pricing override.`);return}}this.modelPricingOverridesAvailable=!0,this.closeModelPricingOverrideForm(),q.success(`Model pricing override removed.`),this.fetchModelPricingOverrides()}catch(e){console.error(`Failed to delete model pricing override:`,e),this.modelPricingOverrideError=`Failed to remove model pricing override.`}finally{this.modelPricingOverrideSubmitting=!1}}}},Sk=R(``);function Ck(e,t){E(t,!0);var n=Sk();let r;var i=P(M(n),2),a=M(i,!0);T(i),T(n),F((e,i,o)=>{r=U(n,1,`alias-toggle`,null,r,e),n.disabled=ek.rowTogglingKey===t.row.key||!ek.virtualModelsAvailable,W(n,`aria-label`,i),B(a,o)},[()=>({enabled:ek.rowToggleEnabled(t.row),restricted:ek.rowToggleRestricted(t.row)}),()=>ek.rowToggleAriaLabel(t.row),()=>ek.rowToggleLabel(t.row)]),L(`click`,n,()=>ek.toggleRowEnabled(t.row)),z(e,n),D()}Hr([`click`]);var wk=R(`
                        `);function Tk(e,t){E(t,!0);var n=wk(),r=M(n),i=e=>{Ck(e,{get row(){return ek.globalScopeRow}})};V(r,e=>{ek.virtualModelsAvailable&&e(i)});var a=P(r,2),o=e=>{{let t=O(()=>xk.modelPricingButtonLabel(`global model pricing`,xk.hasGlobalPricingOverride())),n=O(()=>xk.modelPricingButtonClass(xk.hasGlobalPricingOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>xk.openGlobalPricingOverrideEdit(),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(a,e=>{xk.modelPricingOverridesAvailable&&e(o)});var s=P(a,2),c=e=>{{let t=O(()=>BO(`global model access`,ek.hasGlobalModelOverride())),n=O(()=>zO(ek.hasGlobalModelOverride()));gT(e,{get label(){return I(t)},get class(){return`table-icon-btn ${I(n)??``}`},onclick:()=>ek.openGlobalModelOverrideEdit(),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n),D()}function Ek(e){return String(e&&(e.primary_model||e.source)||``).trim()}function Dk(e){return Array.isArray(e&&e.fallback_models)?e.fallback_models:Array.isArray(e&&e.targets)?e.targets:[]}function Ok(e){return Array.isArray(e)?e.map(e=>({...e,source:Ek(e),targets:Dk(e)})):[]}function kk(e){let t=Dk(e);return t.length===0?`-`:t.join(`, `)}function Ak(e){return e&&e.enabled===!1?`Off`:e&&e.managed?`Config`:`On`}function jk(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>Ek(e)===n)||null}function Mk(e,t){if(!t||t.is_alias)return!1;let n=jk(e,tO(t));return!!(n&&n.enabled!==!1&&Dk(n).length>0)}function Nk(e,t){return Mk(e,t)?`table-action-btn-failover-active`:``}function Pk(e,t){let n=`Edit failover for `+(t&&t.display_name?t.display_name:`model`);return Mk(e,t)?n+` (active)`:n}function Fk(e){let t=[e&&e.target_model];return(Array.isArray(e&&e.targets)?e.targets:[]).forEach(e=>t.push(e&&e.model)),t.map(e=>String(e||``).trim()).filter(Boolean)}function Ik(e){let t=Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(Boolean):[];return{target_model:t[0]||``,targets:t.slice(1).map(e=>({model:e}))}}function Lk(e){return{primary_model:String(e&&e.source||``).trim(),fallback_models:Fk(e),enabled:!(e&&e.enabled===!1)}}function Rk(e){return Ek(e)}function zk(e){let t={};return(Array.isArray(e)?e:[]).forEach(e=>{let n=Rk(e);n&&(t[n]=!0)}),t}function Bk(e,t){let n=Rk(t);return!!(n&&e&&e[n])}function Vk(e,t){return(Array.isArray(e)?e:[]).filter(e=>Bk(t,e))}function Hk(e,t){let n=Array.isArray(e)?e:[];return n.length>0&&Vk(n,t).length===n.length}function Uk(e){return[Ek(e),Dk(e).join(` `)].join(` `).toLowerCase()}function Wk(e,t){let n=Array.isArray(e)?e:[],r=String(t||``).trim().toLowerCase();return r?n.filter(e=>Uk(e).includes(r)):n}function Gk(e){return{primary_model:Ek(e),fallback_models:Dk(e).map(e=>String(e||``).trim()).filter(Boolean),enabled:!!(e&&e.enabled!==!1)}}function Kk(){return{source:``,target_model:``,targets:[],enabled:!0}}var Z=new class{#e=k(!0);get failoverAvailable(){return I(this.#e)}set failoverAvailable(e){A(this.#e,e,!0)}#t=k(j([]));get failoverRules(){return I(this.#t)}set failoverRules(e){A(this.#t,e,!0)}#n=k(!1);get failoverLoading(){return I(this.#n)}set failoverLoading(e){A(this.#n,e,!0)}#r=k(!1);get failoverSaving(){return I(this.#r)}set failoverSaving(e){A(this.#r,e,!0)}#i=k(!1);get failoverGenerating(){return I(this.#i)}set failoverGenerating(e){A(this.#i,e,!0)}#a=k(``);get failoverError(){return I(this.#a)}set failoverError(e){A(this.#a,e,!0)}#o=k(j([]));get failoverGeneratedRules(){return I(this.#o)}set failoverGeneratedRules(e){A(this.#o,e,!0)}#s=k(!1);get failoverDraftsOpen(){return I(this.#s)}set failoverDraftsOpen(e){A(this.#s,e,!0)}#c=k(j({}));get failoverDraftSelections(){return I(this.#c)}set failoverDraftSelections(e){A(this.#c,e,!0)}#l=k(``);get failoverDraftFilter(){return I(this.#l)}set failoverDraftFilter(e){A(this.#l,e,!0)}#u=k(!1);get failoverDraftSaving(){return I(this.#u)}set failoverDraftSaving(e){A(this.#u,e,!0)}#d=k(!1);get failoverFormOpen(){return I(this.#d)}set failoverFormOpen(e){A(this.#d,e,!0)}#f=k(`create`);get failoverFormMode(){return I(this.#f)}set failoverFormMode(e){A(this.#f,e,!0)}#p=k(!1);get failoverFormManaged(){return I(this.#p)}set failoverFormManaged(e){A(this.#p,e,!0)}#m=k(j(Kk()));get failoverForm(){return I(this.#m)}set failoverForm(e){A(this.#m,e,!0)}failoverEnabled(){return Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}async fetchFailoverRules(){if(!this.failoverEnabled()){this.failoverAvailable=!1,this.failoverRules=[],this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,this.failoverError=``,this.failoverLoading=!1;return}this.failoverLoading=!0,this.failoverError=``;try{let e=await _s(`/admin/failover`,{label:`failover mappings`});if(e.status===503){this.failoverAvailable=!1,this.failoverRules=[];return}if(e.stale)return;if(this.failoverAvailable=!0,!e.ok){this.failoverRules=[];return}this.failoverRules=Ok(e.data)}catch(e){console.error(`Failed to fetch failover mappings:`,e),this.failoverRules=[],this.failoverError=`Unable to load failover mappings.`}finally{this.failoverLoading=!1}}resetFailoverForm(){this.failoverFormMode=`create`,this.failoverFormManaged=!1,this.failoverForm=Kk()}openFailoverCreate(){this.resetFailoverForm(),this.failoverFormOpen=!0,this.focusFailoverEditor()}openFailoverEdit(e){if(!e)return;this.resetFailoverForm(),this.failoverFormMode=`edit`,this.failoverFormOpen=!0,this.failoverFormManaged=!!e.managed;let t=this.failoverPrimaryModel(e),n=this.failoverTargets(e);this.failoverForm={source:t,target_model:n[0]||``,targets:n.slice(1).map(e=>({model:e})),enabled:e.enabled!==!1},this.focusFailoverEditor()}openFailoverForModel(e){if(!e||e.is_alias)return;let t=this.qualifiedModelName(e),n=this.failoverRules.find(e=>this.failoverPrimaryModel(e)===t);if(n){this.openFailoverEdit(n);return}this.resetFailoverForm(),this.failoverFormMode=`create`,this.failoverFormOpen=!0,this.failoverForm.source=t,this.focusFailoverEditor()}closeFailoverForm(){this.failoverFormOpen=!1}closeFailoverDraftsModal(){this.failoverDraftSaving||(this.failoverDraftsOpen=!1)}failoverFormTargets(){return Fk(this.failoverForm)}setFailoverFormTargets(e){let t=Ik(e);this.failoverForm.target_model=t.target_model,this.failoverForm.targets=t.targets}addFailoverTarget(){Array.isArray(this.failoverForm.targets)||(this.failoverForm.targets=[]),this.failoverForm.targets.push({model:``}),this.focusFailoverEditor()}removeFailoverTarget(e){if(!Array.isArray(this.failoverForm.targets)){this.failoverForm.targets=[];return}this.failoverForm.targets.splice(e,1)}removePrimaryFailoverTarget(){let e=Array.isArray(this.failoverForm.targets)?this.failoverForm.targets:[];if(e.length>0){let t=e.shift();this.failoverForm.target_model=t&&t.model?t.model:``,this.failoverForm.targets=e;return}this.failoverForm.target_model=``}failoverRulePayload(){return Lk(this.failoverForm)}async submitFailoverForm(){if(this.failoverSaving||this.failoverGenerating||this.failoverFormManaged)return;let e=this.failoverRulePayload();if(!e.primary_model){this.failoverError=`Primary model is required.`;return}if(e.enabled&&e.fallback_models.length===0){this.failoverError=`Add at least one failover target.`;return}this.failoverSaving=!0,this.failoverError=``;try{let t=await vs(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to save failover mapping.`;return}q.success(`Failover mapping saved.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to save failover mapping:`,e),this.failoverError=`Failed to save failover mapping.`}finally{this.failoverSaving=!1}}async deleteFailoverRule(e){let t=String(e&&this.failoverPrimaryModel(e)||this.failoverForm.source||``).trim();if(!(!t||this.failoverSaving||this.failoverGenerating)&&confirm(`Remove failover mapping for "`+t+`"?`)){this.failoverSaving=!0,this.failoverError=``;try{let e=await vs(`/admin/failover`,`DELETE`,{primary_model:t},{label:`failover mapping`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mapping.`;return}q.success(`Failover mapping removed.`),this.closeFailoverForm(),this.fetchFailoverRules()}catch(e){console.error(`Failed to remove failover mapping:`,e),this.failoverError=`Failed to remove failover mapping.`}finally{this.failoverSaving=!1}}}async generateFailoverForForm(){if(this.failoverGenerating||this.failoverSaving||this.failoverFormManaged)return;let e=String(this.failoverForm.source||``).trim();if(!e){this.failoverError=`Primary model is required.`;return}this.failoverGenerating=!0,this.failoverError=``;try{let t=await vs(`/admin/failover/generate`,`POST`,{primary_model:e},{label:`failover generation`});if(t.stale)return;if(!t.ok){this.failoverError=`Failed to generate failover mapping.`;return}let n=Ok(t.data),r=n.find(t=>this.failoverPrimaryModel(t)===e)||n[0]||null,i=this.failoverTargets(r);if(i.length===0){this.failoverError=`No failover suggestions were generated for this model.`;return}this.setFailoverFormTargets(i),q.success(`Generated `+i.length+` fallback model`+(i.length===1?`.`:`s.`)),this.focusFailoverEditor()}catch(e){console.error(`Failed to generate failover mapping:`,e),this.failoverError=`Failed to generate failover mapping.`}finally{this.failoverGenerating=!1}}openFailoverResetDialog(){Rs.open({title:`Remove failover models`,titleId:`failoverResetDialogTitle`,inputId:`failover-reset-confirmation`,message:`Remove every dashboard-managed failover mapping. Configuration-managed mappings remain active.`,requiredText:`remove`,confirmLabel:`Remove Failover`,icon:Ao,dialogClass:`budget-reset-dialog`,onConfirm:async()=>{await this.resetFailoverRules(),this.failoverError&&(Rs.error=this.failoverError)}})}async resetFailoverRules(){if(!this.failoverSaving){this.failoverSaving=!0,this.failoverError=``;try{let e=await vs(`/admin/failover/reset`,`POST`,void 0,{label:`failover removal`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to remove failover mappings.`;return}this.failoverRules=Ok(e.data),this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!1,q.success(`Dashboard-managed failover mappings removed.`),Rs.close()}catch(e){console.error(`Failed to remove failover mappings:`,e),this.failoverError=`Failed to remove failover mappings.`}finally{this.failoverSaving=!1}}}async generateFailoverRules(){if(!(this.failoverGenerating||this.failoverDraftSaving)){this.failoverGenerating=!0,this.failoverError=``,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.failoverDraftsOpen=!0;try{let e=await vs(`/admin/failover/generate`,`POST`,void 0,{label:`failover generation`});if(e.stale)return;if(!e.ok){this.failoverError=`Failed to generate failover mappings.`;return}this.failoverGeneratedRules=Ok(e.data),this.selectAllFailoverDrafts(this.failoverGeneratedRules)}catch(e){console.error(`Failed to generate failover mappings:`,e),this.failoverError=`Failed to generate failover mappings.`}finally{this.failoverGenerating=!1}}}failoverDraftKey(e){return Rk(e)}selectAllFailoverDrafts(e){this.failoverDraftSelections=zk(e)}failoverDraftSelected(e){return Bk(this.failoverDraftSelections,e)}setFailoverDraftSelected(e,t){let n=this.failoverDraftKey(e);n&&(this.failoverDraftSelections={...this.failoverDraftSelections,[n]:!!t})}selectedFailoverDrafts(){return Vk(this.failoverGeneratedRules,this.failoverDraftSelections)}selectedFailoverDraftCount(){return this.selectedFailoverDrafts().length}failoverDraftCountLabel(){return this.selectedFailoverDraftCount()+` / `+this.failoverGeneratedRules.length+` selected`}allFailoverDraftsSelected(){return Hk(this.failoverGeneratedRules,this.failoverDraftSelections)}toggleAllFailoverDrafts(){if(!(this.failoverDraftSaving||this.failoverGenerating||this.failoverGeneratedRules.length===0)){if(this.allFailoverDraftsSelected()){this.failoverDraftSelections={};return}this.selectAllFailoverDrafts(this.failoverGeneratedRules)}}failoverDraftSearchText(e){return Uk(e)}filteredFailoverDrafts(){return Wk(this.failoverGeneratedRules,this.failoverDraftFilter)}failoverDraftPayload(e){return Gk(e)}async saveSelectedFailoverDrafts(){if(this.failoverDraftSaving||this.failoverGenerating)return;let e=this.selectedFailoverDrafts();if(e.length===0){this.failoverError=`Select at least one failover draft.`;return}this.failoverDraftSaving=!0,this.failoverError=``;try{for(let t of e){let e=this.failoverDraftPayload(t);if(!e.primary_model||e.fallback_models.length===0){this.failoverError=`Generated failover draft is missing model data.`;return}let n=await vs(`/admin/failover`,`PUT`,e,{label:`failover mapping`});if(n.stale)return;if(!n.ok){this.failoverError=`Failed to save failover mapping.`;return}}q.success(`Saved `+e.length+` failover mapping`+(e.length===1?`.`:`s.`)),this.failoverDraftsOpen=!1,this.failoverGeneratedRules=[],this.failoverDraftSelections={},this.failoverDraftFilter=``,this.fetchFailoverRules()}catch(e){console.error(`Failed to save generated failover mappings:`,e),this.failoverError=`Failed to save failover mappings.`}finally{this.failoverDraftSaving=!1}}focusFailoverEditor(){setTimeout(()=>{let e=document.querySelector(`[data-failover-editor]`),t=e&&e.querySelector?e.querySelector(`[data-modal-autofocus], input:not([disabled]), textarea:not([disabled]), button:not([disabled])`):null;t&&typeof t.focus==`function`&&t.focus({preventScroll:!0})},0)}failoverTargetLabel(e){return kk(e)}failoverPrimaryModel(e){return Ek(e)}failoverTargets(e){return Dk(e)}findFailoverMapping(e){return jk(this.failoverRules,e)}hasActiveFailoverMapping(e){return Mk(this.failoverRules,e)}failoverButtonClass(e){return Nk(this.failoverRules,e)}failoverButtonLabel(e){return Pk(this.failoverRules,e)}normalizeFailoverRules(e){return Ok(e)}failoverRuleStatus(e){return Ak(e)}qualifiedModelName(e){return tO(e)}},qk=R(``),Jk=R(``),Yk=R(`Config`),Xk=R(`
                        Targets
                        `),Zk=R(``),Qk=R(`
                        Redirects to
                        `),$k=R(` `),eA=R(`
                        `),tA=R(`
                        `),nA=R(`
                        `);function rA(e,t){E(t,!0);let n=O(()=>xk.modelRowPricing(t.row));var r=nA(),i=M(r),a=M(i),o=M(a),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=e=>{z(e,qk())};V(l,e=>{t.row.is_alias&&e(u)});var d=P(l,2),f=e=>{z(e,Jk())};V(d,e=>{!t.row.is_alias&&t.row.masking_alias&&e(f)});var p=P(d,2),m=e=>{z(e,Yk())},h=O(()=>LO(t.row));V(p,e=>{I(h)&&e(m)}),T(o);var g=P(o,2),_=e=>{var n=Xk(),r=P(M(n)),i=M(r,!0);T(r),T(n),F(()=>B(i,t.row.secondary_name)),z(e,n)};V(g,e=>{t.row.is_alias&&e(_)});var v=P(g,2),y=e=>{var n=Qk(),r=P(M(n)),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=Zk();F(e=>{W(n,`aria-label`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),W(n,`title`,ek.rowDeletingKey===t.row.key?`Removing redirect for `+t.row.display_name:`Remove redirect for `+t.row.display_name),n.disabled=e},[()=>!!ek.rowDeletingKey]),L(`click`,n,()=>ek.removeRedirectRow(t.row)),z(e,n)},s=O(()=>ek.virtualModelsAvailable&&FO(t.row));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>mO(t.row.masking_alias)]),z(e,n)};V(v,e=>{!t.row.is_alias&&t.row.masking_alias&&e(y)}),T(a),T(i);var b=P(i);H(b,17,()=>t.columns,oi,(e,r)=>{var i=$k(),a=M(i,!0);T(i),F(e=>{U(i,1,Fi(I(r).class),`svelte-1iynym`),B(a,e)},[()=>I(r).value(t.row,I(n))]),z(e,i)});var x=P(b),S=M(x),C=e=>{var n=eA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>ek.rowDeletingKey===t.row.key?`Removing alias `+t.row.alias.name:`Remove alias `+t.row.alias.name),r=O(()=>!!ek.rowDeletingKey);gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>ek.removeAliasRow(t.row),get disabled(){return I(r)},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})}},o=O(()=>ek.virtualModelsAvailable&&PO(t.row));V(i,e=>{I(o)&&e(a)});var s=P(i,2),c=e=>{{let n=O(()=>`Edit alias `+t.row.alias.name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.alias),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(s,e=>{ek.virtualModelsAvailable&&e(c)}),T(n),z(e,n)},w=e=>{var n=tA(),r=M(n);Ck(r,{get row(){return t.row}});var i=P(r,2),a=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`model pricing for `+t.row.display_name,xk.hasModelPricingOverride(t.row))),r=O(()=>xk.modelPricingButtonClass(xk.hasModelPricingOverride(t.row)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openModelPricingOverrideEdit(t.row),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(i,e=>{xk.modelPricingOverridesAvailable&&e(a)});var o=P(i,2),s=e=>{{let n=O(()=>Z.failoverButtonLabel(t.row)),r=O(()=>Z.failoverButtonClass(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>Z.openFailoverForModel(t.row),children:(e,t)=>{G(e,{get icon(){return Eo},class:`table-icon-svg`})},$$slots:{default:!0}})}},c=O(()=>Z.failoverAvailable&&Z.failoverEnabled());V(o,e=>{I(c)&&e(s)});var l=P(o,2),u=e=>{{let n=O(()=>X.rateLimitGaugeTitle(t.row.display_name,X.rateLimitGaugeClassForModel(t.row))),r=O(()=>X.rateLimitGaugeClassForModel(t.row));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForModel(t.row),children:(e,t)=>{G(e,{get icon(){return $a},class:`table-icon-svg`})},$$slots:{default:!0}})}},d=O(()=>X.rateLimitsEnabled()&&X.rateLimitInspectorModelID(t.row));V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{{let n=O(()=>`Edit redirect for `+t.row.display_name);gT(e,{get label(){return I(n)},class:`table-icon-btn table-action-btn-active`,onclick:()=>ek.openVirtualModelEditAlias(t.row.masking_alias),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(f,e=>{ek.virtualModelsAvailable&&t.row.masking_alias&&t.row.masking_alias.name&&e(p)});var m=P(f,2),h=e=>{{let n=O(()=>BO(`model access for `+t.row.display_name,RO(t.row.access))),r=O(()=>zO(RO(t.row.access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openVirtualModelEditModel(t.row),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(m,e=>{ek.virtualModelsAvailable&&!t.row.masking_alias&&e(h)}),T(n),z(e,n)};V(S,e=>{t.row.is_alias?e(C):e(w,-1)}),T(x),T(r),F((e,n)=>{W(r,`id`,e),U(r,1,n,`svelte-1iynym`),B(c,t.row.display_name)},[()=>IO(t.row)||void 0,()=>Fi(NO(t.row))]),z(e,r),D()}Hr([`click`]);var iA={headerLines:[`Modes`],value:e=>(e.model?.metadata?.modes??[]).join(`, `)||`-`};function aA(e,t){return{headerLines:e,class:`col-price`,value:t}}var oA=aA([`Input / Output ($/MTok)`],(e,t)=>cc(t?.input_per_mtok)+` / `+cc(t?.output_per_mtok)),sA={all:[oA],text_generation:[iA,oA,aA([`Cached $/MTok`],(e,t)=>cc(t?.cached_input_per_mtok))],embedding:[aA([`Input`,`$/MTok`],(e,t)=>cc(t?.input_per_mtok))],image:[aA([`$/Image`],(e,t)=>lc(t?.per_image))],audio:[aA([`$/Second`],(e,t)=>lc(t?.per_second_input)),aA([`$/Character`],(e,t)=>lc(t?.per_character_input))],video:[aA([`$/Second (In)`],(e,t)=>lc(t?.per_second_input)),aA([`$/Second (Out)`],(e,t)=>lc(t?.per_second_output))],utility:[aA([`$/Page`],(e,t)=>lc(t?.per_page)),aA([`$/Request`],(e,t)=>lc(t?.per_request))]};function cA(e){return sA[e]||sA.all}function lA(e){return cA(e).length+2}var uA=R(`
                        `),dA=R(` `,1),fA=R(``),pA=R(` `),mA=R(` `),hA=R(`
                        `),gA=R(`
                        `),_A=R(`
                        Model
                        `);function vA(e,t){E(t,!0);let n=O(()=>Nc.activeCategory||`all`),r=O(()=>cA(I(n))),i=O(()=>lA(I(n)));var a=_A(),o=M(a),s=M(o),c=M(s),l=P(M(c));H(l,17,()=>I(r),oi,(e,t)=>{var n=fA();H(n,21,()=>I(t).headerLines,oi,(e,t,n)=>{var r=dA(),i=N(r),a=e=>{z(e,uA())};V(i,e=>{n>0&&e(a)});var o=P(i,1,!0);F(()=>B(o,I(t))),z(e,r)}),T(n),F(()=>U(n,1,Fi(I(t).class),`svelte-1911hy6`)),z(e,n)});var u=P(l);Tk(M(u),{}),T(u),T(c),T(s),H(P(s),17,()=>ek.filteredDisplayModelGroups,e=>e.key,(e,t)=>{var n=gA(),a=M(n),o=M(a),s=M(o),c=M(s),l=M(c),u=M(l),d=M(u,!0);T(u);var f=P(u,2),p=e=>{var n=pA(),r=M(n,!0);T(n),F(()=>B(r,`(`+I(t).type_label+`)`)),z(e,n)};V(f,e=>{I(t).type_label&&e(p)});var m=P(f,2),h=e=>{var n=mA(),r=M(n,!0);T(n),F(()=>B(r,I(t).item_count_label)),z(e,n)};V(m,e=>{I(t).item_count_label&&e(h)}),T(l);var g=P(l,2),_=e=>{var n=hA(),r=M(n,!0);T(n),F(()=>B(r,I(t).access_summary)),z(e,n)};V(g,e=>{I(t).access_summary&&e(_)}),T(c);var v=P(c,2),y=M(v),b=e=>{Ck(e,{get row(){return I(t)}})};V(y,e=>{I(t).access.selector&&e(b)});var x=P(y,2),S=e=>{{let n=O(()=>xk.modelPricingButtonLabel(`provider pricing for `+I(t).display_name,xk.hasProviderPricingOverride(I(t)))),r=O(()=>xk.modelPricingButtonClass(xk.hasProviderPricingOverride(I(t))));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>xk.openProviderPricingOverrideEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return qa},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(x,e=>{xk.modelPricingOverridesAvailable&&I(t).provider_name&&e(S)});var C=P(x,2),w=e=>{{let n=O(()=>X.rateLimitGaugeTitle(`provider `+I(t).display_name,X.rateLimitGaugeClassForProvider(I(t)))),r=O(()=>X.rateLimitGaugeClassForProvider(I(t)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>X.openRateLimitInspectorForProvider(I(t)),children:(e,t)=>{G(e,{get icon(){return $a},class:`table-icon-svg`})},$$slots:{default:!0}})}},ee=O(()=>X.rateLimitsEnabled()&&I(t).provider_name);V(C,e=>{I(ee)&&e(w)});var te=P(C,2),ne=e=>{{let n=O(()=>BO(`provider access for `+I(t).display_name,RO(I(t).access))),r=O(()=>zO(RO(I(t).access)));gT(e,{get label(){return I(n)},get class(){return`table-icon-btn ${I(r)??``}`},onclick:()=>ek.openProviderOverrideEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(te,e=>{ek.virtualModelsAvailable&&I(t).access.selector&&e(ne)}),T(v),T(s),T(o),T(a),H(P(a),17,()=>I(t).rows,e=>e.key,(e,t)=>{rA(e,{get row(){return I(t)},get columns(){return I(r)}})}),T(n),F(()=>{W(o,`colspan`,I(i)),B(d,I(t).display_name)}),z(e,n)}),T(o),T(a),z(e,a),D()}var yA=R(``);function bA(e,t){let n=ya(t,`enabled`,3,!1),r=ya(t,`label`,3,``),i=ya(t,`disabled`,3,!1),a=ya(t,`restricted`,3,!1);var o=yA();let s;var c=P(M(o),2),l=M(c,!0);T(c),T(o),F(()=>{s=U(o,1,`alias-toggle`,null,s,{enabled:n(),restricted:a()}),o.disabled=i(),W(o,`aria-label`,(n()?`Disable `:`Enable `)+r()),B(l,t.text??(n()?`Enabled`:`Disabled`))}),L(`click`,o,function(...e){t.onclick?.apply(this,e)}),z(e,o)}Hr([`click`]);var xA=R(``),SA=R(`
                        `);function CA(e,t){E(t,!0);let n=ya(t,`model`,15,``),r=ya(t,`weight`,15),i=ya(t,`id`,3,void 0),a=ya(t,`placeholder`,3,`openai/gpt-4o`),o=ya(t,`showRemove`,3,!0);var s=SA(),c=M(s);na(c);var l=P(c,2),u=e=>{var t=xA();na(t),F(()=>t.disabled=ek.vmFormManaged),da(t,r),z(e,t)},d=O(()=>ek.vmFormShowWeights());V(l,e=>{I(d)&&e(u)});var f=P(l,2),p=e=>{gT(e,{label:`Remove target`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,get onclick(){return t.onremove},get disabled(){return ek.vmFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})};V(f,e=>{o()&&e(p)}),T(s),F(()=>{W(c,`id`,i()),W(c,`placeholder`,a()),c.disabled=ek.vmFormManaged}),da(c,n),z(e,s),D()}var wA=R(`

                        `),TA=R(`adaptive lets the registered routing extension pick the target per - request.`,1),EA=R(`Add one target to make this a redirect/alias, or two or more to load - balance across them, then pick a strategy: round_robin rotates across targets - (weight biases the share) and cost always routes to the cheapest available - target. Leave Targets empty to make it only an access policy on the Source selector. The selector uses / for all providers and - models, for one provider, or for one model. user_paths is - matched against the effective request user_path: the managed API key user_path when present, otherwise the configured user path request header.`,1),DA=R(``),OA=R(`

                        This virtual model is defined in configuration (config.yaml / VIRTUAL_MODELS) and is read-only here. Edit your configuration to change it.

                        `),kA=R(``),AA=R(``),jA=R(``),MA=R(`
                        `,1),NA=R(``),PA=R(`Use / to allow every user path. Use a team path to restrict to that - subtree, or an unused path to make the selector unavailable.`,1),FA=R(``),IA=R(` `),LA=R(`
                        Targets
                        `,1);function RA(e,t){E(t,!0);let n=ek;An(()=>{n.vmFormOpen&&Ss.ensureLoaded()});{let t=e=>{qS(e,{copyId:`virtual-model-help-copy`,label:`virtual model help`,get open(){return n.vmFormHelpOpen},set open(e){n.vmFormHelpOpen=e},title:e=>{var t=wA(),r=M(t,!0);T(t),F(()=>B(r,n.vmFormDisplayName||n.vmForm.source||`Virtual model`)),z(e,t)},help:e=>{Ue();var t=EA(),n=P(N(t),7),r=e=>{var t=TA();Ue(),z(e,t)},i=O(()=>Ss.virtualModelStrategies().includes(`adaptive`));V(n,e=>{I(i)&&e(r)});var a=P(n,8);a.textContent=`{provider_name}/`;var o=P(a,2);o.textContent=`{provider_name}/{model}`,Ue(7),z(e,t)},$$slots:{title:!0,help:!0}})},r=e=>{var t=Qr(),r=N(t),i=e=>{var t=DA();F(()=>t.disabled=n.vmDeleting||n.vmSubmitting),L(`click`,t,()=>n.deleteVirtualModel()),z(e,t)};V(r,e=>{n.vmFormHasExisting&&!n.vmFormManaged&&e(i)}),z(e,t)},i=O(()=>n.vmDeleting||n.vmFormManaged),a=O(()=>n.vmFormMode===`edit`?`Save`:`Create`),o=O(()=>n.vmFormMode===`edit`?_o:po);bE(e,{get open(){return n.vmFormOpen},ariaLabel:`Virtual model editor`,get error(){return n.vmFormError},get submitting(){return n.vmSubmitting},get submitDisabled(){return I(i)},get submitLabel(){return I(a)},get submitIcon(){return I(o)},onclose:()=>n.closeVirtualModelForm(),onsubmit:()=>n.submitVirtualModelForm(),header:t,extraActions:r,children:(e,t)=>{var r=LA(),i=N(r),a=e=>{z(e,OA())};V(i,e=>{n.vmFormManaged&&e(a)});var o=P(i,2);SE(o,{id:`virtual-model-source`,label:`Source`,children:(e,t)=>{var r=kA();na(r),F(()=>r.disabled=n.vmFormSourceLocked||n.vmFormManaged),da(r,()=>n.vmForm.source,e=>n.vmForm.source=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2);H(s,21,()=>Nc.models,e=>tO(e),(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(s);var c=P(s,2),l=P(M(c),2);{let e=O(()=>n.vmFormHasPrimaryTarget());CA(l,{id:`virtual-model-target`,get showRemove(){return I(e)},onremove:()=>n.removePrimaryTarget(),get model(){return n.vmForm.target_model},set model(e){n.vmForm.target_model=e},get weight(){return n.vmForm.target_weight},set weight(e){n.vmForm.target_weight=e}})}var u=P(l,2);H(u,17,()=>n.vmForm.targets,oi,(e,t,r)=>{CA(e,{placeholder:`groq/llama`,onremove:()=>n.removeVmTarget(r),get model(){return I(t).model},set model(e){I(t).model=e},get weight(){return I(t).weight},set weight(e){I(t).weight=e}})});var d=P(u,2),f=M(d);G(M(f),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(f),T(d),T(c);var p=P(c,2),m=e=>{var t=MA(),r=N(t);SE(r,{id:`virtual-model-strategy`,label:`Load-balancing strategy`,children:(e,t)=>{var r=jA();H(r,21,()=>n.vmStrategyOptions(),e=>e.value,(e,t)=>{var n=AA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),F(()=>r.disabled=n.vmFormManaged),Gi(r,()=>n.vmForm.strategy,e=>n.vmForm.strategy=e),z(e,r)},$$slots:{default:!0}});var i=P(r,2),a=M(i),o=M(a);na(o),Ue(2),T(a),T(i),F(()=>o.disabled=n.vmFormManaged),fa(o,()=>n.vmForm.session_affinity,e=>n.vmForm.session_affinity=e),z(e,t)},h=O(()=>n.vmFormShowStrategy());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=M(g);qS(_,{copyId:`virtual-model-user-paths-help`,label:`user paths help`,get open(){return n.vmFormUserPathsHelpOpen},set open(e){n.vmFormUserPathsHelpOpen=e},title:e=>{z(e,NA())},help:e=>{Ue();var t=PA();Ue(2),z(e,t)},$$slots:{title:!0,help:!0}});var v=P(_,2);ft(v),W(v,`placeholder`,`/ -/team/alpha -/non-existing`),T(g);var y=P(g,2);SE(y,{id:`virtual-model-description`,label:`Description`,children:(e,t)=>{var r=FA();ft(r),F(()=>r.disabled=n.vmFormManaged),da(r,()=>n.vmForm.description,e=>n.vmForm.description=e),z(e,r)},$$slots:{default:!0}});var b=P(y,2),x=M(b),S=e=>{var t=IA(),r=M(t,!0);T(t),F(()=>B(r,`Default enabled: `+(n.vmFormDefaultEnabled?`yes`:`no`)+` · Effective now: `+(n.vmFormEffectiveEnabled?`yes`:`no`))),z(e,t)};V(x,e=>{n.vmFormMode===`edit`&&e(S)});var C=P(x,2),w=M(C);{let e=O(()=>n.vmFormToggleRestricted()),t=O(()=>n.vmFormToggleLabel());bA(w,{get enabled(){return n.vmForm.enabled},get restricted(){return I(e)},label:`virtual model`,get disabled(){return n.vmFormManaged},get text(){return I(t)},onclick:()=>{n.vmFormManaged||(n.vmForm.enabled=!n.vmForm.enabled)}})}T(C),T(b),F(()=>{f.disabled=n.vmFormManaged,v.disabled=n.vmFormManaged}),L(`click`,f,()=>n.addVmTarget()),da(v,()=>n.vmForm.user_paths,e=>n.vmForm.user_paths=e),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var zA=R(`

                        Pricing override

                        `,1),BA=R(``),VA=R(``),HA=R(``),UA=R(``),WA=R(`
                        `),GA=R(`
                        Tiered pricing exists for this override and will be preserved. Tier editing can be added - without a database migration.
                        `),KA=R(`
                        No pricing fields set.
                        `),qA=R(`
                        `),JA=R(`

                        Currency is USD. Saved fields override model registry and config.yaml pricing for this - selector; unset fields continue to inherit.

                        Price Type USD Source
                        `,1);function YA(e,t){E(t,!0);let n=xk;bE(e,{get open(){return n.modelPricingOverrideFormOpen},ariaLabel:`Model pricing editor`,dialogClass:`model-pricing-editor`,get error(){return n.modelPricingOverrideError},get submitting(){return n.modelPricingOverrideSubmitting},submitLabel:`Save Pricing`,onclose:()=>n.closeModelPricingOverrideForm(),onsubmit:()=>n.submitModelPricingOverrideForm(),header:e=>{var t=zA(),r=P(N(t),2),i=M(r,!0);T(r),F(()=>B(i,n.modelPricingOverrideFormDisplayName||n.modelPricingOverrideForm.selector||`Pricing`)),z(e,t)},extraActions:e=>{var t=Qr(),r=N(t),i=e=>{var t=BA();F(()=>t.disabled=n.modelPricingOverrideSubmitting),L(`click`,t,()=>n.deleteModelPricingOverride()),z(e,t)};V(r,e=>{n.modelPricingOverrideFormHasExistingOverride&&e(i)}),z(e,t)},children:(e,t)=>{var r=JA(),i=N(r),a=M(i);SE(a,{id:`model-pricing-override-selector`,label:`Selector`,children:(e,t)=>{var r=VA();na(r),da(r,()=>n.modelPricingOverrideForm.selector,e=>n.modelPricingOverrideForm.selector=e),z(e,r)},$$slots:{default:!0}});var o=P(a,2),s=e=>{SE(e,{id:`model-pricing-override-scope`,label:`Scope`,children:(e,t)=>{var r=UA();H(r,21,()=>n.modelPricingOverrideFormScopeOptions,e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(r),L(`change`,r,()=>n.setModelPricingOverrideScope(n.modelPricingOverrideFormScope)),Gi(r,()=>n.modelPricingOverrideFormScope,e=>n.modelPricingOverrideFormScope=e),z(e,r)},$$slots:{default:!0}})};V(o,e=>{n.modelPricingOverrideFormScopeOptions.length>1&&e(s)}),T(i);var c=P(i,4);H(c,21,()=>n.modelPricingOverrideRows,e=>e.id,(e,t,r)=>{var i=WA(),a=M(i),o=M(a),s=P(o,2);H(s,21,()=>n.availablePricingFieldOptions(I(t)),e=>e.value,(e,t)=>{var n=HA(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).group+` - `+I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(s),T(a);var c=P(a,2),l=M(c),u=P(l,2);na(u),T(c);var d=P(c,2);{let e=O(()=>`Remove `+n.pricingFieldLabel(I(t).field));gT(d,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn pricing-override-remove-row`,onclick:()=>n.removeModelPricingOverrideRow(I(t)),children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}T(i),F(()=>{W(o,`for`,`pricing-type-`+I(t).id),W(s,`id`,`pricing-type-`+I(t).id),W(l,`for`,`pricing-value-`+I(t).id),W(u,`id`,`pricing-value-`+I(t).id)}),Gi(s,()=>I(t).field,e=>I(t).field=e),da(u,()=>I(t).value,e=>I(t).value=e),z(e,i)}),T(c);var l=P(c,2),u=M(l);G(M(u),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(u),T(l);var d=P(l,2),f=e=>{z(e,GA())};V(d,e=>{n.modelPricingOverrideFormPreservedTiers.length>0&&e(f)});var p=P(d,2),m=P(M(p),2),h=e=>{z(e,KA())},g=O(()=>n.modelPricingEffectivePreviewRows().length===0);V(m,e=>{I(g)&&e(h)}),H(P(m,2),17,()=>n.modelPricingEffectivePreviewRows(),e=>e.field,(e,t)=>{var n=qA(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(n),F(e=>{B(i,I(t).label),B(o,e),B(c,I(t).source)},[()=>I(t).value===null||I(t).value===void 0?`-`:lc(Number(I(t).value))]),z(e,n)}),T(p),L(`click`,u,()=>n.addModelPricingOverrideRow()),z(e,r)},$$slots:{header:!0,extraActions:!0,default:!0}}),D()}Hr([`click`,`change`]);var XA=R(`

                        Failover mapping

                        `,1),ZA=R(``),QA=R(`

                        This failover mapping is defined in configuration and is read-only here.

                        `),$A=R(``),ej=R(`
                        `),tj=R(`
                        `,1),nj=R(`
                        `);function rj(e,t){E(t,!0);{let t=e=>{var t=XA(),n=P(N(t),2),r=M(n,!0);T(n),F(()=>B(r,Z.failoverForm.source||`Failover`)),z(e,t)},n=e=>{var t=Qr(),n=N(t),r=e=>{var t=ZA();F(()=>t.disabled=Z.failoverSaving||Z.failoverGenerating),L(`click`,t,()=>Z.deleteFailoverRule()),z(e,t)};V(n,e=>{Z.failoverFormMode===`edit`&&!Z.failoverFormManaged&&e(r)}),z(e,t)},r=O(()=>Z.failoverGenerating||Z.failoverFormManaged);bE(e,{get open(){return Z.failoverFormOpen},ariaLabel:`Failover editor`,get error(){return Z.failoverError},get submitting(){return Z.failoverSaving},get submitDisabled(){return I(r)},submitLabel:`Save`,onclose:()=>Z.closeFailoverForm(),onsubmit:()=>Z.submitFailoverForm(),header:t,extraActions:n,children:(e,t)=>{var n=nj(),r=M(n),i=e=>{z(e,QA())};V(r,e=>{Z.failoverFormManaged&&e(i)});var a=P(r,2);H(a,21,()=>Nc.models,oi,(e,t)=>{var n=$A(),r=M(n,!0);T(n);var i={};F((e,t)=>{B(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>tO(I(t)),()=>tO(I(t))]),z(e,n)}),T(a);var o=P(a,2);SE(o,{id:`failover-target`,label:`Fallback models`,children:(e,t)=>{var n=tj(),r=N(n),i=M(r),a=M(i);na(a);var o=P(a,2),s=e=>{gT(e,{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removePrimaryFailoverTarget(),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}})};V(o,e=>{Z.failoverForm.target_model&&e(s)}),T(i),H(P(i,2),17,()=>Z.failoverForm.targets,oi,(e,t,n)=>{var r=ej(),i=M(r);na(i),gT(P(i,2),{label:`Remove fallback model`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Z.removeFailoverTarget(n),get disabled(){return Z.failoverFormManaged},children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),F(()=>i.disabled=Z.failoverFormManaged),da(i,()=>I(t).model,e=>I(t).model=e),z(e,r)}),T(r);var c=P(r,2),l=M(c);G(M(l),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(l);var u=P(l,2),d=M(u);G(d,{get icon(){return Po},class:`form-action-icon`});var f=P(d,2),p=M(f,!0);T(f),T(u),T(c),F(e=>{a.disabled=Z.failoverFormManaged,l.disabled=Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving,u.disabled=e,B(p,Z.failoverGenerating?`Generating...`:`Generate automatically`)},[()=>Z.failoverFormManaged||Z.failoverGenerating||Z.failoverSaving||!Z.failoverEnabled()]),da(a,()=>Z.failoverForm.target_model,e=>Z.failoverForm.target_model=e),L(`click`,l,()=>Z.addFailoverTarget()),L(`click`,u,()=>Z.generateFailoverForForm()),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=M(s);bA(M(c),{get enabled(){return Z.failoverForm.enabled},label:`failover mapping`,get disabled(){return Z.failoverFormManaged},onclick:()=>{Z.failoverFormManaged||(Z.failoverForm.enabled=!Z.failoverForm.enabled)}}),T(c),T(s),T(n),z(e,n)},$$slots:{header:!0,extraActions:!0,default:!0}})}D()}Hr([`click`]);var ij=R(` `),aj=R(`
                        `),oj=R(``),sj=R(`
                        `),cj=R(`

                        No failover suggestions were generated.

                        `),lj=R(`

                        No failover drafts match the filter.

                        `),uj=R(``),dj=R(``);function fj(e,t){E(t,!0),Ns(e,{get open(){return Z.failoverDraftsOpen},variant:`editor`,onclose:()=>Z.closeFailoverDraftsModal(),children:(e,t)=>{var n=dj(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=ij(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>Z.failoverDraftCountLabel()]),z(e,t)};V(a,e=>{Z.failoverGeneratedRules.length>0&&e(o)}),ks(P(a,2),{label:`Close failover drafts`,onclick:()=>Z.closeFailoverDraftsModal(),get disabled(){return Z.failoverDraftSaving}}),T(i),T(r);var s=P(r,2),c=e=>{mT(e,{label:`Generating failover drafts...`,class:`failover-drafts-loading`})};V(s,e=>{Z.failoverGenerating&&e(c)});var l=P(s,2),u=e=>{var t=aj(),n=M(t);yw(n,{placeholder:`Filter failover drafts...`,label:`Filter failover drafts`,get value(){return Z.failoverDraftFilter},set value(e){Z.failoverDraftFilter=e}});var r=P(n,2),i=M(r);G(i,{get icon(){return Va},class:`form-action-icon`});var a=P(i,2),o=M(a,!0);T(a),T(r),T(t),F(e=>{r.disabled=Z.failoverDraftSaving,B(o,e)},[()=>Z.allFailoverDraftsSelected()?`Deselect all`:`Select all`]),L(`click`,r,()=>Z.toggleAllFailoverDrafts()),z(e,t)};V(l,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&e(u)});var d=P(l,2),f=e=>{var t=sj();H(t,21,()=>Z.filteredFailoverDrafts(),e=>`failover-draft:`+Z.failoverPrimaryModel(e),(e,t)=>{var n=oj(),r=M(n);na(r);var i=P(r,2),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s,!0);T(s),T(i),T(n),F((e,t,n,i)=>{ia(r,e),r.disabled=Z.failoverDraftSaving,W(r,`aria-label`,t),B(o,n),B(c,i)},[()=>Z.failoverDraftSelected(I(t)),()=>`Select failover draft for `+Z.failoverPrimaryModel(I(t)),()=>Z.failoverPrimaryModel(I(t)),()=>Z.failoverTargetLabel(I(t))]),L(`change`,r,e=>Z.setFailoverDraftSelected(I(t),e.currentTarget.checked)),z(e,n)}),T(t),z(e,t)},p=O(()=>!Z.failoverGenerating&&Z.filteredFailoverDrafts().length>0);V(d,e=>{I(p)&&e(f)});var m=P(d,2),h=e=>{z(e,cj())};V(m,e=>{!Z.failoverGenerating&&Z.failoverGeneratedRules.length===0&&!Z.failoverError&&e(h)});var g=P(m,2),_=e=>{z(e,lj())},v=O(()=>!Z.failoverGenerating&&Z.failoverGeneratedRules.length>0&&Z.filteredFailoverDrafts().length===0);V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=uj(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(y,e=>{Z.failoverError&&e(b)});var x=P(y,2),S=M(x),C=P(S,2),w=M(C);G(w,{get icon(){return _o},class:`form-action-icon`});var ee=P(w,2),te=M(ee,!0);T(ee),T(C),T(x),T(n),F(e=>{S.disabled=Z.failoverDraftSaving,C.disabled=e,B(te,Z.failoverDraftSaving?`Saving...`:`Save selected`)},[()=>Z.failoverGenerating||Z.failoverDraftSaving||Z.selectedFailoverDraftCount()===0]),L(`click`,S,()=>Z.closeFailoverDraftsModal()),L(`click`,C,()=>Z.saveSelectedFailoverDrafts()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`,`change`]);var pj=R(`
                        Rate limit management is unavailable.
                        `),mj=R(` Add`,1),hj=R(`

                        `),gj=R(`

                        No rules.

                        `),_j=R(` Edit`,1),vj=R(`
                        `),yj=R(`
                        `),bj=R(`

                        `),xj=R(``),Sj=R(``);function Cj(e,t){E(t,!0);function n(){K.dialogOpen||X.closeRateLimitInspector()}Ns(e,{get open(){return X.rateLimitInspectorOpen},variant:`editor`,onclose:n,children:(e,t)=>{var n=Sj(),r=M(n),i=M(r),a=P(M(i),2),o=M(a),s=M(o,!0);T(o),T(a),T(i),ks(P(i,2),{label:`Close rate limits inspector`,onclick:()=>X.closeRateLimitInspector()}),T(r);var c=P(r,2),l=e=>{mT(e,{label:`Loading rate limits...`})},u=e=>{z(e,pj())},d=e=>{var t=Qr();H(N(t),17,()=>X.rateLimitInspectorSections(),e=>e.key,(e,t)=>{var n=bj(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2);{let e=O(()=>`Add `+I(t).title.toLowerCase());gT(o,{get label(){return I(e)},class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(I(t).scope,I(t).subject),children:(e,t)=>{var n=mj();G(N(n),{get icon(){return po},class:`table-icon-svg`}),Ue(2),z(e,n)},$$slots:{default:!0}})}T(r);var s=P(r,2),c=e=>{var n=hj(),r=M(n,!0);T(n),F(()=>B(r,I(t).hint)),z(e,n)};V(s,e=>{I(t).hint&&e(c)});var l=P(s,2),u=e=>{z(e,gj())},d=e=>{var n=yj();H(n,21,()=>I(t).items,e=>X.rateLimitKey(e),(e,t)=>{var n=vj(),r=M(n),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=M(s),l=M(c);{let e=O(()=>X.rateLimitIsConcurrent(I(t))?Ma:ko);G(l,{get icon(){return I(e)},class:`budget-period-icon`})}var u=P(l,2),d=M(u,!0);T(u),T(c),T(s);var f=P(s,2),p=M(f),m=M(p),h=M(m,!0);T(m);var g=P(m,2),_=M(g,!0);T(g),T(p);var v=P(p,2),y=M(v),b=e=>{gT(e,{label:`Edit rate limit`,class:`budget-action-btn`,onclick:()=>X.openRateLimitFormFromInspector(null,null,I(t)),children:(e,t)=>{var n=_j();G(N(n),{get icon(){return uo},class:`budget-action-icon`}),Ue(2),z(e,n)},$$slots:{default:!0}})},x=O(()=>!X.rateLimitIsReadOnly(I(t)));V(y,e=>{I(x)&&e(b)}),T(v),T(f),T(i),T(r),T(n),F((e,t,r,i,a,s,c,l)=>{U(n,1,`budget-row ${e??``}`),Hi(n,t),W(n,`title`,r),B(o,i),B(d,a),B(h,s),W(g,`title`,c),B(_,l)},[()=>X.rateLimitPressureClass(I(t)),()=>X.rateLimitPressureStyle(I(t)),()=>X.rateLimitPressurePercent(I(t))+`% of the most constrained cap used`,()=>X.rateLimitSubject(I(t)),()=>X.rateLimitPeriodLabel(I(t)),()=>X.rateLimitInspectorSummary(I(t)),()=>X.rateLimitIsReadOnly(I(t))?`Declared in configuration; read-only in the dashboard`:`Managed via dashboard or admin API`,()=>X.rateLimitSourceLabel(I(t))]),z(e,n)}),T(n),z(e,n)};V(l,e=>{I(t).items.length===0?e(u):e(d,-1)}),T(n),F(()=>B(a,I(t).title)),z(e,n)}),z(e,t)};V(c,e=>{X.rateLimitsLoading?e(l):X.rateLimitsAvailable?e(d,-1):e(u,1)});var f=P(c,2),p=M(f),m=P(p,2),h=e=>{var t=xj();L(`click`,t,()=>{X.closeRateLimitInspector(),Jo.navigate(`rate-limits`)}),z(e,t)},g=O(()=>X.rateLimitsEnabled());V(m,e=>{I(g)&&e(h)}),T(f),T(n),F(()=>B(s,X.rateLimitInspector.title)),L(`click`,p,()=>X.closeRateLimitInspector()),z(e,n)},$$slots:{default:!0}}),D()}Hr([`click`]);var wj=R(`
                        models
                        `),Tj=R(`
                        Virtual models feature is unavailable.
                        `),Ej=R(`
                        `),Dj=R(``),Oj=R(`
                        `),kj=R(``),Aj=R(`
                        `),jj=R(`

                        No models registered.

                        `),Mj=R(`

                        No models in this category.

                        `),Nj=R(`

                        No models match your filter.

                        `),Pj=R(`
                        `);function Fj(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`models`&&(ek.fetchVirtualModels(),xk.fetchModelPricingOverrides(),Z.fetchFailoverRules(),X.fetchRateLimitsPage())}),An(()=>{let e=ek.filteredDisplayModels.length;return Er(()=>ek.restartModelRendering(e)),()=>ek.stopModelRendering()});let n=O(()=>K.needsAuth);var r=Pj(),i=M(r),a=P(M(i),2),o=e=>{var t=wj(),n=M(t),r=M(n,!0);T(n),Ue(),T(t),F(()=>B(r,Nc.filter?ek.filteredDisplayModels.length+` / `+ek.displayModels.length:ek.displayModels.length)),z(e,t)};V(a,e=>{ek.displayModels.length>0&&e(o)}),T(i);var s=P(i,2);Fc(s,{});var c=P(s,2),l=e=>{z(e,Tj())};V(c,e=>{!ek.virtualModelsAvailable&&!I(n)&&e(l)});var u=P(c,2),d=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,ek.aliasError)),z(e,t)};V(u,e=>{ek.aliasError&&!I(n)&&e(d)});var f=P(u,2),p=e=>{var t=Ej(),n=M(t,!0);T(t),F(()=>B(n,xk.modelPricingOverrideError)),z(e,t)};V(f,e=>{xk.modelPricingOverrideError&&!I(n)&&!xk.modelPricingOverrideFormOpen&&e(p)});var m=P(f,2),h=e=>{var t=Oj();H(t,21,()=>Nc.categories,e=>e.category,(e,t)=>{var n=Dj();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(n),F(()=>{r=U(n,1,`category-tab svelte-scpjps`,null,r,{active:Nc.activeCategory===I(t).category}),B(a,I(t).display_name),B(s,I(t).count)}),L(`click`,n,()=>Nc.selectCategory(I(t).category)),z(e,n)}),T(t),z(e,t)};V(m,e=>{Nc.categories.length>0&&e(h)});var g=P(m,2),_=e=>{var t=Aj(),n=M(t);yw(M(n),{placeholder:`Filter by provider, provider/model, alias, or owner...`,label:`Filter models by provider, provider/model, alias, or owner`,get value(){return Nc.filter},set value(e){Nc.filter=e}}),T(n);var r=P(n,2),i=M(r),a=e=>{var t=kj();G(M(t),{get icon(){return po},class:`alias-create-icon`}),Ue(2),T(t),L(`click`,t,()=>ek.openVirtualModelCreate()),z(e,t)};V(i,e=>{ek.virtualModelsAvailable&&e(a)}),T(r),T(t),z(e,t)};V(g,e=>{(ek.displayModels.length>0||Nc.filter||ek.virtualModelsAvailable)&&e(_)});var v=P(g,2),y=e=>{{let t=O(()=>ek.modelLoadingText());mT(e,{get label(){return I(t)},class:`models-loading-state`})}},b=O(()=>ek.modelsBusy()&&!I(n));V(v,e=>{I(b)&&e(y)});var x=P(v,2);RA(x,{});var S=P(x,2);YA(S,{});var C=P(S,2),w=e=>{vA(e,{})};V(C,e=>{(ek.displayModels.length>0||Nc.filter)&&e(w)});var ee=P(C,2),te=e=>{z(e,jj())};V(ee,e=>{ek.displayModels.length===0&&!Nc.loading&&!I(n)&&!Nc.filter&&(Nc.activeCategory===`all`||!Nc.activeCategory)&&e(te)});var ne=P(ee,2),re=e=>{z(e,Mj())};V(ne,e=>{ek.displayModels.length===0&&!Nc.loading&&!I(n)&&!Nc.filter&&Nc.activeCategory&&Nc.activeCategory!==`all`&&e(re)});var ie=P(ne,2),ae=e=>{z(e,Nj())};V(ie,e=>{ek.displayModels.length>0&&ek.filteredDisplayModels.length===0&&Nc.filter&&e(ae)});var oe=P(ie,2);Cj(oe,{});var se=P(oe,2);FD(se,{});var ce=P(se,2);rj(ce,{}),fj(P(ce,2),{}),T(r),z(e,r),D()}Hr([`click`]);var Ij=`draft-workflow-preview`;function Lj(){return{scope_provider:``,scope_model:``,scope_user_path:``,name:``,description:``,features:{cache:!0,audit:!0,usage:!0,budget:!0,guardrails:!1,failover:!0},guardrails:[]}}function Rj(){return{scope_provider:``,scope_model:``,scope_user_path:``}}function zj(e){return{ref:``,step:Number.isFinite(e)?e:10}}function Bj(e){let t=e==null?``:String(e).trim();if(t===``)return NaN;let n=Number(t);return Number.isFinite(n)?n:NaN}function Vj(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n;let r=t.charAt(0).toUpperCase()+t.slice(1);for(let n of[t,r])if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==null&&e[n]!==void 0)return e[n];return n}function Hj(e,t){return!e||typeof e!=`object`||Array.isArray(e)?!1:[t,t.charAt(0).toUpperCase()+t.slice(1)].some(t=>Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==null&&e[t]!==void 0)}function Uj(e){return{cache:!!Vj(e,`cache`,!1),audit:!!Vj(e,`audit`,!1),usage:!!Vj(e,`usage`,!1),budget:Vj(e,`budget`,!0)!==!1,guardrails:!!Vj(e,`guardrails`,!1),failover:Vj(e,`failover`,!0)!==!1}}function Wj(e,t){let n=Uj(e),r=t||{},i=n.usage&&!!r.usage;return{cache:n.cache&&!!r.cache,audit:n.audit&&!!r.audit,usage:i,budget:i&&n.budget&&!!r.budget,guardrails:n.guardrails&&!!r.guardrails,failover:n.failover&&!!r.failover}}function Gj(e,t){let n=e&&e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:e&&e.features?e.features:{};return{...Wj((e&&e.effective_features&&typeof e.effective_features==`object`&&!Array.isArray(e.effective_features)?e.effective_features:null)||n,t),failover:Uj(n).failover}}function Kj(e,t){return Gj(e,t).failover?`On`:`Off`}function qj(e){return(Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:Array.isArray(e&&e.guardrails)?e.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0)}function Jj(e,t){return Gj(e,t).guardrails&&Array.isArray(e&&e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[]}function Yj(e){return String(e&&(e.scope_provider_name||e.scope_provider)||``).trim()}function Xj(e){return String(e&&(e.provider_name||e.provider_type)||``).trim()}function Zj(e,t){let n=new Set,r=String(t&&t.scope_provider||``).trim();return r&&n.add(r),(Array.isArray(e)?e:[]).forEach(e=>{let t=Xj(e);t&&n.add(t)}),[...n].sort()}function Qj(e,t,n){let r=String(t||``).trim(),i=new Set,a=String(n&&n.scope_provider||``).trim(),o=String(n&&n.scope_model||``).trim();return r&&r===a&&o&&i.add(o),(Array.isArray(e)?e:[]).forEach(e=>{if(r&&Xj(e)!==r)return;let t=String(e&&e.model&&e.model.id||``).trim();t&&i.add(t)}),[...i].sort()}function $j(e){let t=String(e&&e.scope_type||``).trim();return t===`provider_model`?`Provider Name + Model`:t===`provider_model_path`?`Provider Name + Model + Path`:t===`provider_path`?`Provider Name + Path`:t===`path`?`Path`:t===`provider`?`Provider Name`:`Global`}function eM(e){return String(e&&e.scope_display||`global`).trim()||`global`}function tM(e){let t=String(e&&e.name||``).trim();if(t)return t;let n=eM(e);return n===`global`?`All models`:n}function nM(e){let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`);for(let e of n){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function rM(e){if(nM(e))return``;let t=String(e||``).trim();if(!t)return``;let n=(t.startsWith(`/`)?t:`/`+t).split(`/`),r=[];for(let e of n){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function iM(e){let t=e||Lj(),n=String(t.scope_provider||``).trim(),r=rM(t.scope_user_path);return{scope_provider:n,scope_model:n?String(t.scope_model||``).trim():``,scope_user_path:r}}function aM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path);return!t&&!r?`global`:!t&&r?`path`:!n&&!r?`provider`:!n&&r?`provider_path`:r?`provider_model_path`:`provider_model`}function oM(e){let t=String(e&&e.scope_provider||``).trim(),n=t?String(e&&e.scope_model||``).trim():``,r=rM(e&&e.scope_user_path),i=aM({scope_provider:t,scope_model:n,scope_user_path:r});return i===`global`?`global`:i===`path`?r:i===`provider`?t:i===`provider_path`?t+` @ `+r:i===`provider_model_path`?t+`/`+n+` @ `+r:t+`/`+n}function sM(e,t){let n=t||Rj(),r=Yj(e&&e.scope),i=r?String(e&&e.scope&&e.scope.scope_model||``).trim():``,a=rM(e&&e.scope&&e.scope.scope_user_path);return r===String(n.scope_provider||``).trim()&&i===String(n.scope_model||``).trim()&&a===rM(n.scope_user_path)}function cM(e,t,n){let r=iM(t);return!(r.scope_provider!==``||r.scope_model!==``||r.scope_user_path!==``)&&!n?null:(Array.isArray(e)?e:[]).find(e=>sM(e,r))||null}function lM(e){return String(e&&e.scope_type||``).trim()!==`global`}function uM(e){let t=String(e||``).trim();return t?t.length<=14?t:t.slice(0,12)+`…`:`—`}function dM(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.description,e.scope_display,e.scope_type,Yj(e&&e.scope),e.scope&&e.scope.scope_model,e.scope&&e.scope.scope_user_path,e.workflow_hash,...Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>e.ref):[]].some(e=>String(e||``).toLowerCase().includes(r)))}function fM(e,t){let n=e||Lj(),r=iM(n),i=Uj(n.features||{}),a=Wj(i,t);a.failover=i.failover;let o=!!a.guardrails,s=o?qj(n):[];return{id:Ij,scope_type:aM(r),scope_display:oM(r),scope:{scope_provider_name:r.scope_provider,scope_model:r.scope_model,...r.scope_user_path?{scope_user_path:r.scope_user_path}:{}},name:String(n.name||``).trim(),description:String(n.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!a.cache,audit:!!a.audit,usage:!!a.usage,budget:!!a.budget,guardrails:o,failover:!!a.failover},guardrails:s}}}function pM({form:e,caps:t,workflows:n=[],formHydrated:r=!1,hydratedScope:i=null}){let a=e||Lj(),o=String(a.scope_provider||``).trim(),s=o?String(a.scope_model||``).trim():``,c=rM(a.scope_user_path),l=Uj(a.features||{}),u=Wj(l,t),d=cM(n,a,r),f=d&&d.workflow_payload&&d.workflow_payload.features,p=Hj(f,`failover`),m=p?Vj(f,`failover`,!0)!==!1:null,h=i||Rj(),g=String(h.scope_provider||``).trim()===o&&String(h.scope_model||``).trim()===s&&rM(h.scope_user_path)===rM(c),_=!!(t&&t.failover),v=_||!!r&&g&&Object.prototype.hasOwnProperty.call(l,`failover`)||!r&&!!d&&p,y=u.guardrails?(Array.isArray(a.guardrails)?a.guardrails:[]).map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})):[],b={scope_provider_name:o,scope_model:s,...c?{scope_user_path:c}:{},name:String(a.name||``).trim(),description:String(a.description||``).trim(),workflow_payload:{schema_version:1,features:{cache:!!u.cache,audit:!!u.audit,usage:!!u.usage,budget:!!u.budget,guardrails:!!u.guardrails},guardrails:y}};return v&&(b.workflow_payload.features.failover=!_&&!r&&d&&p?m:!!l.failover),b}function mM(e,{models:t=[],hydratedScope:n=null}={}){let r=n||Rj(),i=String(r.scope_provider||``).trim(),a=String(r.scope_model||``).trim(),o=String(e&&(e.scope_provider_name||e.scope_provider)||``).trim(),s=String(e&&e.scope_model||``).trim();if(o&&!Zj(t,r).includes(o)&&o!==i)return`Choose a registered provider name.`;if(s&&!o)return`Model selection requires a provider name.`;if(s){let e=Qj(t,o,r),n=o===i&&s===a;if(!e.includes(s)&&!n)return`Choose a registered model for the selected provider name.`}let c=nM(e.scope_user_path);if(c)return c;let l=e.workflow_payload&&e.workflow_payload.features?e.workflow_payload.features:{},u=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails:[];if(!l.guardrails)return``;let d=new Set;for(let e of u){if(!e.ref)return`Each guardrail step needs a guardrail ref.`;if(!Number.isInteger(e.step)||e.step<0)return`Each guardrail step must use a non-negative integer step number.`;if(d.has(e.ref))return`Each guardrail ref may appear only once in a workflow.`;d.add(e.ref)}return``}var hM=new class{#e=k(j([]));get workflows(){return I(this.#e)}set workflows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get submitting(){return I(this.#o)}set submitting(e){A(this.#o,e,!0)}#s=k(``);get deactivatingID(){return I(this.#s)}set deactivatingID(e){A(this.#s,e,!0)}#c=k(``);get formError(){return I(this.#c)}set formError(e){A(this.#c,e,!0)}#l=k(!1);get formHydrated(){return I(this.#l)}set formHydrated(e){A(this.#l,e,!0)}#u=k(j(Rj()));get hydratedScope(){return I(this.#u)}set hydratedScope(e){A(this.#u,e,!0)}#d=k(j([]));get guardrailRefs(){return I(this.#d)}set guardrailRefs(e){A(this.#d,e,!0)}#f=k(j(Lj()));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}#p=null;failoverVisible(){return Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}featureCaps(){return{cache:Ss.cacheVisible(),audit:Ss.auditVisible(),usage:Ss.usageVisible(),budget:Ss.budgetsVisible(),guardrails:Ss.guardrailsVisible(),failover:this.failoverVisible()}}get filteredWorkflows(){return dM(this.workflows,this.filter)}providerOptions(){return Zj(Nc.models,this.hydratedScope)}modelOptions(e){return Qj(Nc.models,e,this.hydratedScope)}activeScopeMatch(){return cM(this.workflows,this.form,this.formHydrated)}submitMode(){return this.activeScopeMatch()?`save`:`create`}submitLabel(){return this.submitMode()===`save`?`Save`:`Create`}submittingLabel(){return this.submitMode()===`save`?`Saving...`:`Creating...`}preview(){return fM(this.form,this.featureCaps())}openCreate(e){if(this.formOpen=!0,this.submitting=!1,this.formError=``,!e){this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj();return}this.formHydrated=!0,this.hydratedScope={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``).trim(),scope_user_path:String(e.scope&&e.scope.scope_user_path||``).trim()};let t=e.workflow_payload&&e.workflow_payload.features?Uj(e.workflow_payload.features):Gj(e,this.featureCaps()),n=Array.isArray(e.workflow_payload&&e.workflow_payload.guardrails)?e.workflow_payload.guardrails.map(e=>({ref:String(e&&e.ref||``).trim(),step:Bj(e&&e.step)})).filter(e=>Number.isInteger(e.step)&&e.step>=0):qj(e);this.form={scope_provider:Yj(e.scope),scope_model:String(e.scope&&e.scope.scope_model||``),scope_user_path:String(e.scope&&e.scope.scope_user_path||``),name:String(e.name||``),description:String(e.description||``),features:{cache:!!t.cache,audit:!!t.audit,usage:!!t.usage,budget:!!t.budget,guardrails:!!t.guardrails,failover:!!t.failover},guardrails:n.map(e=>({ref:String(e&&e.ref||``),step:Number.isFinite(e&&e.step)?e.step:10}))}}closeForm(){this.formOpen=!1,this.submitting=!1,this.formError=``,this.formHydrated=!1,this.hydratedScope=Rj(),this.form=Lj()}setProvider(e){if(this.form.scope_provider=String(e||``).trim(),!this.form.scope_provider){this.form.scope_model=``;return}this.modelOptions(this.form.scope_provider).includes(String(this.form.scope_model||``).trim())||(this.form.scope_model=``)}addGuardrailStep(){let e=(Array.isArray(this.form.guardrails)?this.form.guardrails:[]).reduce((e,t)=>{let n=Number(t&&t.step);return Number.isFinite(n)?Math.max(e,n):e},0)+10;this.form.guardrails.push(zj(e))}removeGuardrailStep(e){Array.isArray(this.form.guardrails)&&this.form.guardrails.splice(e,1)}buildRequest(){return pM({form:this.form,caps:this.featureCaps(),workflows:this.workflows,formHydrated:this.formHydrated,hydratedScope:this.hydratedScope})}async fetchWorkflows(){this.#p&&this.#p.abort();let e=new AbortController;this.#p=e,this.loading=!0,this.error=``;let t=setTimeout(()=>e.abort(),1e4),n=await _T(`/admin/workflows`,{label:`workflows`,options:{signal:e.signal}});if(clearTimeout(t),this.#p===e&&(this.#p=null,this.loading=!1,n.status!==`stale`)){if(n.status===`unavailable`){this.available=!1,this.workflows=[];return}if(n.result&&(this.available=!0),n.status===`error`){this.workflows=[],this.error=e.signal.aborted?`Loading workflows timed out.`:n.error;return}this.workflows=n.items}}async fetchGuardrailRefs(){let e=await _T(`/admin/workflows/guardrails`,{label:`workflow guardrails`});e.status!==`stale`&&(this.guardrailRefs=e.items)}async fetchPage(){await Promise.all([Ss.ensureLoaded(),this.fetchWorkflows(),this.fetchGuardrailRefs()])}async submitForm(){if(this.submitting)return;this.formError=``;let e=this.buildRequest(),t=mM(e,{models:Nc.models,hydratedScope:this.hydratedScope});if(t){this.formError=t;return}this.submitting=!0;try{let t=await vT(`/admin/workflows`,`POST`,e,{label:`create workflow`,unavailableStatuses:[]});if(t.status===`stale`||t.result&&t.result.status===401)return;if(t.status===`error`){this.formError=t.error;return}q.success(`Workflow created and activated.`),this.closeForm(),this.fetchPage()}finally{this.submitting=!1}}async deactivate(e){let t=String(e&&e.id||``).trim();if(!t||this.deactivatingID||!lM(e))return;let n=tM(e);if(confirm(`Deactivate workflow "`+n+`"? Requests will fall back to the next active workflow for this scope.`)){this.deactivatingID=t;try{let e=await vT(`/admin/workflows/`+encodeURIComponent(t)+`/deactivate`,`POST`,void 0,{label:`deactivate workflow`,unavailableStatuses:[]});if(e.status===`stale`||e.result&&e.result.status===401)return;if(e.status===`error`){q.error(e.error);return}q.success(`Workflow deactivated.`),this.fetchPage()}finally{this.deactivatingID=``}}}};function gM(e){let t=String(e??``),n=typeof navigator<`u`?navigator.clipboard:null;if(n&&typeof n.writeText==`function`)return n.writeText(t);let r=typeof document<`u`?document:null;if(!r||!r.body||typeof r.execCommand!=`function`)return Promise.reject(Error(`Clipboard API unavailable`));let i=r.createElement(`textarea`);i.value=t,i.setAttribute(`readonly`,``),i.style.position=`fixed`,i.style.top=`0`,i.style.left=`0`,i.style.opacity=`0`;try{if(r.body.appendChild(i),i.focus(),i.select(),i.setSelectionRange(0,i.value.length),!r.execCommand(`copy`))throw Error(`execCommand copy returned false`)}finally{i.parentNode&&i.parentNode.removeChild(i)}return Promise.resolve()}function _M({resetDelayMs:e=2e3,logPrefix:t}={}){let n=j({copied:!1,error:!1}),r=null;function i(){r!==null&&clearTimeout(r),r=null}function a(){i(),r=setTimeout(()=>{n.copied=!1,n.error=!1,r=null},e)}return{get copied(){return n.copied},get error(){return n.error},reset(){i(),n.copied=!1,n.error=!1},async copy(e,r){if(!(e==null||e===``)){i(),n.copied=!1,n.error=!1;try{await gM(typeof r==`function`?r(e):String(e)),n.copied=!0,n.error=!1}catch(e){console.error(t||`Failed to copy text:`,e),n.copied=!1,n.error=!0}a()}}}}var vM=R(``);function yM(e,t){E(t,!0);let n=ya(t,`workflowID`,3,``),r=_M({logPrefix:`Failed to copy workflow ID:`});An(()=>{n(),r.reset()});let i=O(()=>r.error?`Unable to copy workflow ID`:r.copied?`Workflow ID copied`:`Copy workflow ID`),a=O(()=>n()?I(i)+` `+n():I(i));async function o(e){e.preventDefault(),n()&&await r.copy(n())}var s=vM();let c;var l=P(M(s),4),u=M(l,!0);T(l);var d=P(l,2);G(M(d),{get icon(){return Ya}}),T(d),T(s),F(()=>{c=U(s,1,`workflow-pipeline-meta mono svelte-1viff7o`,null,c,{"workflow-pipeline-meta-copied":r.copied,"workflow-pipeline-meta-error":r.error}),W(s,`title`,I(i)),W(s,`aria-label`,I(a)),B(u,n())}),L(`click`,s,o),z(e,s),D()}Hr([`click`]);var bM=(e,t)=>{let n=()=>(t?.()).icon,r=()=>(t?.()).label,i=Ot(()=>h((t?.()).variant,`workflow-node-feature`)),a=()=>(t?.()).state,o=()=>(t?.()).sub,s=()=>(t?.()).badge;var c=wM(),l=M(c),u=e=>{var t=xM();let r;G(M(t),{get icon(){return n()}}),T(t),F(()=>r=U(t,1,`workflow-node-icon svelte-nbptrg`,null,r,{"workflow-node-icon-endpoint":I(i)===`workflow-node-endpoint`})),z(e,t)};V(l,e=>{n()&&e(u)});var d=P(l,2),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var t=SM(),n=M(t,!0);T(t),F(()=>B(n,s())),z(e,t)};V(p,e=>{s()&&e(m)});var g=P(p,2),_=e=>{var t=CM(),n=M(t,!0);T(t),F(()=>B(n,o())),z(e,t)};V(g,e=>{o()&&e(_)}),T(c),F(()=>{U(c,1,Fi([`workflow-node`,I(i),a()]),`svelte-nbptrg`),B(f,r())}),z(e,c)},xM=R(`
                        `),SM=R(` `),CM=R(` `),wM=R(`
                        `),TM=R(`
                        `,1),EM=R(`
                        `,1),DM=R(`
                        `),OM=R(`
                        Async
                        `),kM=R(`
                        `);function AM(e,t){E(t,!0);let n=ya(t,`chart`,19,()=>({}));var r=kM();let i;var a=M(r),o=e=>{yM(e,{get workflowID(){return n().workflowID}})};V(a,e=>{n().workflowID&&e(o)});var s=P(a,2),c=M(s);bM(c,()=>({icon:Mo,label:`Client`,variant:`workflow-node-endpoint`}));var l=P(c,4);bM(l,()=>({icon:Za,label:`Auth`,state:n().authNodeClass,sub:n().authNodeSublabel}));var u=P(l,2),d=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:Za,label:`Cache`,state:n().cacheNodeClass,badge:n().cacheStatusLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().cacheConnClass]),`svelte-nbptrg`)),z(e,t)};V(u,e=>{n().showCache&&e(d)});var f=P(u,2),p=e=>{var t=EM();bM(P(N(t),2),()=>({icon:No,label:`Budget`,state:n().budgetNodeClass,badge:n().budgetStatusLabel})),z(e,t)};V(f,e=>{n().showBudget&&e(p)});var m=P(f,2),h=e=>{var t=EM();bM(P(N(t),2),()=>({icon:To,label:`Guardrails`,sub:n().guardrailLabel})),z(e,t)};V(m,e=>{n().showGuardrails&&e(h)});var g=P(m,2),_=P(g,2);bM(_,()=>({label:n().aiLabel,variant:`workflow-node-ai`,state:n().aiNodeClass,sub:n().aiSublabel}));var v=P(_,2),y=e=>{var t=TM(),r=N(t);bM(P(r,2),()=>({icon:oo,label:`Failover`,state:n().failoverNodeClass,badge:n().failoverStatusLabel,sub:n().failoverTargetLabel})),F(()=>U(r,1,Fi([`workflow-conn`,n().failoverConnClass]),`svelte-nbptrg`)),z(e,t)};V(v,e=>{n().showFailover&&e(y)});var b=P(v,2);bM(P(b,2),()=>({icon:Ga,label:`Response`,variant:`workflow-node-endpoint`,state:n().responseNodeClass,sub:n().responseNodeSublabel})),T(s);var x=P(s,2),S=e=>{var t=OM(),r=M(t),i=M(r),a=e=>{bM(e,()=>({icon:za,label:`Usage`,variant:`workflow-node-feature workflow-node-async`,state:n().usageNodeClass}))};V(i,e=>{n().showUsage&&e(a)});var o=P(i,2),s=e=>{z(e,DM())};V(o,e=>{n().showUsage&&n().showAudit&&e(s)});var c=P(o,2),l=e=>{bM(e,()=>({icon:Qa,label:`Audit Log`,variant:`workflow-node-feature workflow-node-async`,state:n().auditNodeClass}))};V(c,e=>{n().showAudit&&e(l)}),T(r),Ue(4),T(t),z(e,t)};V(x,e=>{n().showAsync&&e(S)}),T(r),F(()=>{i=U(r,1,`workflow-pipeline svelte-nbptrg`,null,i,{"workflow-pipeline-has-meta":n().workflowID}),U(g,1,Fi([`workflow-conn`,n().aiConnClass]),`svelte-nbptrg`),U(b,1,Fi([`workflow-conn`,n().responseConnClass]),`svelte-nbptrg`)}),z(e,r),D()}function jM(e){let t=qj(e).length;return t===0?``:t===1?`1 step`:t+` steps`}function MM(e,t){return t&&t.provider?t.provider:Yj(e&&e.scope)||`AI`}function NM(e,t){return t&&t.model?t.model:e&&e.scope&&e.scope.scope_model||null}function PM(e,t){let n=String(e&&e.id||``).trim();if(n&&n!==`draft-workflow-preview`)return n;let r=String(t&&t.workflow_version_id||``).trim();return r&&r!==`draft-workflow-preview`?r:null}function FM(e){let t=e&&e.data&&e.data.workflow_features;return!t||typeof t!=`object`||Array.isArray(t)?null:Uj(t)}function IM(e){let t=e&&e.data&&e.data.failover;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=String(t.target_model||t.targetModel||``).trim()||null;return n?{targetModel:n}:null}function LM(e,t=0){if(t>4||e==null)return``;if(typeof e==`string`){let n=e.trim();if(!n||n[0]!==`{`&&n[0]!==`[`)return``;try{return LM(JSON.parse(n),t+1)}catch{return``}}if(Array.isArray(e)){for(let n of e){let e=LM(n,t+1);if(e)return e}return``}return typeof e==`object`?String(e.code||``).trim()||(e.error===void 0?``:LM(e.error,t+1)):``}function RM(e){let t=e&&e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{};return String(t.error_code||t.errorCode||``).trim()||LM(t.response_body)}function zM(e){let t=String(e||``).trim();if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{provider:t.slice(0,n),model:t.slice(n+1)}}function BM(e,t){let n=String(e&&(e.requested_model||e.model)||``).trim(),r=IM(e);if(!(r&&r.targetModel))return{provider:String(e&&e.provider||``).trim()||null,model:n||null};let i=zM(n);if(i)return i;let a=Yj(t&&t.scope),o=a?String(t&&t.scope&&t.scope.scope_model||``).trim():``;return a||o?{provider:a||null,model:o||n||null}:{provider:null,model:n||null}}function VM(e,t){if(!e)return null;let n=(()=>{let t=String(e.cache_type||``).trim().toLowerCase();return t===`exact`||t===`semantic`?t:null})(),r=(()=>{if(e.status_code===void 0||e.status_code===null)return null;let t=String(e.status_code).trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null})(),i=n?!0:e.cache_hit!==void 0&&e.cache_hit!==null&&!!e.cache_hit,a=IM(e),o=BM(e,t),s=Number.isFinite(r)&&r>=200&&r<300,c=String(e.error_type||``).trim().toLowerCase()===`authentication_error`,l=String(e.auth_method||``).trim().toLowerCase()||null,u=RM(e).toLowerCase()===`budget_exceeded`;return{cacheHit:i,cacheType:n||null,failoverTarget:a&&a.targetModel?a.targetModel:null,provider:o.provider,model:o.model,statusCode:r,responseSuccess:s,aiSuccess:s&&!i,authError:c,authMethod:l,budgetExceeded:u}}function HM(e){return!!(e&&e.cacheHit)}function UM(e){return!!(e&&e.failoverTarget)}function WM(e){return!!(e&&e.budgetExceeded)}function GM(e,t){return t?`workflow-node-current`:e&&e.cacheHit?`workflow-node-success`:``}function KM(e){return e&&e.cacheHit?`workflow-conn-hit`:``}function qM(e){return!e||!e.cacheHit?null:e.cacheType===`semantic`?`Hit (Semantic)`:`Hit (Exact)`}function JM(e,t,n,r){return e?WM(t)?`workflow-node-error`:r?`workflow-node-current`:n?`workflow-node-success`:``:``}function YM(e){return WM(e)?`Exceeded`:null}function XM(e){return e&&e.cacheHit?`workflow-node-skipped`:e&&e.failoverTarget?`workflow-node-success`:``}function ZM(e){return e&&e.cacheHit?`workflow-conn-dim`:e&&e.failoverTarget?`workflow-conn-hit`:``}function QM(e){return e&&e.failoverTarget?`Redirected`:null}function $M(e){return e&&e.failoverTarget?e.failoverTarget:null}function eN(e){return e&&e.cacheHit?`workflow-conn-dim`:``}function tN(e,t){return e?e.cacheHit?`workflow-node-skipped`:t?`workflow-node-current`:e.aiSuccess?`workflow-node-success`:``:``}function nN(e,t){if(!e)return``;let n=e.statusCode;return!Number.isFinite(n)&&t?`workflow-node-current`:Number.isFinite(n)?n>=500?`workflow-node-error`:n>=400?`workflow-node-warning`:n>=300?`workflow-node-neutral`:n>=200?`workflow-node-success`:``:``}function rN(e){return!e||!Number.isFinite(e.statusCode)?null:String(e.statusCode)}function iN(e,t){return e?e.authError?`workflow-node-error`:t?`workflow-node-current`:e.authMethod===`api_key`||e.authMethod===`master_key`?`workflow-node-success`:``:``}function aN(e){return!e||!e.authMethod?null:e.authMethod}function oN(e,t,n){return e?n?`workflow-node-current`:t?`workflow-node-success`:``:``}function sN(e,t){if(!e||!e._live)return!!t;let n=String(e._live_state||``).trim();return!!e._audit_flushed||n===`audit.flushed`||n===`audit.detail`}function cN(e,t){if(!e)return!!t;let n=e.usage||{},r=Number(n.entries||0)>0;if(!e._live)return r;let i=String(e._usage_live_state||``).trim();return e._usage_flushed||i===`usage.flushed`?!0:!e._usage_live_pending&&r&&!e._live_pending}function lN(e){return!!(e&&e._live&&e._usage_live_pending&&!e._usage_flushed)}function uN(e,t){return!e||!e._live||sN(e,!1)?!1:String(e._live_state||``).trim()===`audit.completed`||!!(t&&Number.isFinite(t.statusCode))}function dN(e,t,n){return!e||!e._live?``:lN(e)?`usage`:uN(e,t)?`audit`:sN(e,!1)&&!e._live_pending?``:t&&t.cacheHit?`cache`:t&&(t.provider||t.model)?`ai`:n&&n.budget&&(e.workflow_version_id||e.requested_model)?`budget`:t&&t.authMethod?``:`auth`}function fN(e,t,n,r){let i=n||{},a=i.features&&typeof i.features==`object`&&!Array.isArray(i.features)?Uj(i.features):Gj(e,r),o=!!i.forceAudit,s=!!i.highlightAsyncPresent,c=!!a.budget||WM(t),l=!!a.guardrails,u=!!a.usage,d=o||!!a.audit,f=!!i.forceAsync||!!(u||d),p=!!a.failover||UM(t),m=PM(e,i.entry),h=dN(i.entry,t,a),g=lN(i.entry),_=uN(i.entry,t),v=sN(i.entry,s),y=cN(i.entry,s);return{showBudget:c,budgetNodeClass:JM(c,t,s,h===`budget`),budgetStatusLabel:YM(t),showGuardrails:l,guardrailLabel:l?jM(e):``,showCache:!!i.forceCache||!!a.cache||HM(t),cacheNodeClass:GM(t,h===`cache`),cacheConnClass:KM(t),cacheStatusLabel:qM(t),showFailover:p,failoverNodeClass:p?XM(t):``,failoverConnClass:p?ZM(t):``,failoverStatusLabel:p?QM(t):null,failoverTargetLabel:p?$M(t):null,aiLabel:MM(e,t),aiSublabel:NM(e,t),aiConnClass:eN(t),aiNodeClass:tN(t,h===`ai`),responseConnClass:eN(t),responseNodeClass:nN(t,h===`response`),responseNodeSublabel:rN(t),authNodeClass:iN(t,h===`auth`),authNodeSublabel:aN(t),usageNodeClass:oN(u,y,g),auditNodeClass:oN(d,v,_),showAsync:f,showUsage:u,showAudit:d,workflowID:m}}function pN(e,t){return fN(e,null,{forceCache:!1},t)}function mN(e,t,n){return fN(t,VM(e,t),{entry:e,features:FM(e)||(t?Gj(t,n):{cache:!1,audit:!1,usage:!1,budget:!1,guardrails:!1,failover:!1}),forceAudit:!0,forceAsync:!0,highlightAsyncPresent:!0},n)}var hN=R(`

                        `),gN=R(`

                        `),_N=R(`
                        `),vN=R(`
                        `),yN=R(`

                        No guardrails configured for this workflow.

                        `),bN=R(`

                        Guardrails

                        `),xN=R(``),SN=R(`

                        `);function CN(e,t){E(t,!0);let n=ya(t,`preview`,3,!1),r=O(()=>hM.featureCaps()),i=O(()=>tM(t.workflow)),a=O(()=>Jj(t.workflow,I(r))),o=O(()=>pN(t.workflow,I(r))),s=O(()=>n()?`draft-workflow-preview-guardrail-`:t.workflow.id+`-guardrail-`);var c=SN();let l;var u=M(c),d=M(u),f=M(d),p=M(f,!0);T(f);var m=P(f,2),h=M(m,!0);T(m),T(d);var g=P(d,2),_=M(g),v=M(_,!0);T(_),T(g),T(u);var y=P(u,2),b=e=>{var n=hN(),r=M(n,!0);T(n),F(()=>B(r,t.workflow.description)),z(e,n)};V(y,e=>{t.workflow.description&&e(b)});var x=P(y,2),S=e=>{var n=gN(),i=M(n);T(n),F(e=>B(i,`Failover: ${e??``}`),[()=>Kj(t.workflow,I(r))]),z(e,n)},C=O(()=>hM.failoverVisible());V(x,e=>{I(C)&&e(S)});var w=P(x,2);AM(w,{get chart(){return I(o)}});var ee=P(w,2),te=e=>{var t=bN(),n=M(t),r=P(M(n),2),i=M(r,!0);T(r),T(n);var o=P(n,2),c=e=>{var t=vN();H(t,23,()=>I(a),(e,t)=>I(s)+t,(e,t)=>{var n=_N(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=M(a);T(a),T(n),F(()=>{B(i,I(t).ref),B(o,`step ${I(t).step??``}`)}),z(e,n)}),T(t),z(e,t)},l=e=>{z(e,yN())};V(o,e=>{I(a).length>0?e(c):e(l,-1)}),T(t),F(()=>B(i,I(a).length?I(a).length+` steps`:`None`)),z(e,t)},ne=O(()=>Ss.guardrailsVisible());V(ee,e=>{I(ne)&&e(te)});var re=P(ee,2),ie=e=>{var n=xN(),r=M(n),a=M(r),o=M(a,!0);T(a);var s=P(a,2);{let e=O(()=>`Edit workflow `+I(i));gT(s,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>hM.openCreate(t.workflow),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}T(r);var c=P(r,2),l=M(c),u=M(l);T(l);var d=P(l,2),f=M(d);T(d);var p=P(d,2),m=M(p);T(p),T(c),T(n),F((e,n,r,s)=>{a.disabled=e,W(a,`aria-label`,`Deactivate workflow `+I(i)),W(a,`title`,n),B(o,hM.deactivatingID===t.workflow.id?`Deactivating...`:`Deactivate`),B(u,`version: v${t.workflow.version??``}`),B(f,`created: ${r??``}`),B(m,`hash: ${s??``}`)},[()=>hM.deactivatingID===t.workflow.id||!lM(t.workflow),()=>lM(t.workflow)?`Deactivate active workflow`:`The global workflow cannot be deactivated.`,()=>ds.formatTimestamp(t.workflow.created_at),()=>uM(t.workflow.workflow_hash)]),L(`click`,a,()=>hM.deactivate(t.workflow)),z(e,n)};V(re,e=>{n()||e(ie)}),T(c),F((e,t)=>{l=U(c,1,`workflow-card svelte-1fo9fvq`,null,l,{"workflow-preview-card":n()}),B(p,e),B(h,I(i)),B(v,t)},[()=>$j(t.workflow),()=>eM(t.workflow)]),z(e,c),D()}Hr([`click`]);var wN=R(`

                        `),TN=R(``),EN=R(``),DN=R(``),ON=R(``),kN=R(``),AN=R(``),jN=R(``),MN=R(``),NN=R(``),PN=R(``),FN=R(``),IN=R(``),LN=R(`
                        No named guardrails are currently registered on this deployment. You can still draft a workflow, but guardrail-backed creation may be rejected.
                        `),RN=R(`
                        `),zN=R(`
                        `),BN=R(`

                        No guardrail steps configured yet.

                        `),VN=R(`

                        Guardrail Steps

                        Guardrails in the same numeric step run together. Later steps wait for earlier ones to finish.

                        `),HN=R(`

                        Leave provider name empty to target all providers and models. Select a provider name without a model to target all models for that configured provider.

                        Add a path to scope the workflow to that subtree. Leading slashes are optional and will be normalized; you can enter "team/alpha" or "/team/alpha". Matching checks the deepest user path first, then falls back toward the root.

                        If you leave the name empty, the workflow will display as the matched provider/model scope or “All models”.

                        Preview

                        Live
                        `,1);function UN(e,t){E(t,!0);{let t=e=>{qS(e,{copyId:`workflow-help-copy`,label:`workflow help`,text:`Create immutable version. Submitting activates it for the selected scope.`,title:e=>{var t=wN(),n=M(t,!0);T(t),F(e=>B(n,e),[()=>hM.submitMode()===`save`?`Edit Workflow`:`Create Workflow`]),z(e,t)},$$slots:{title:!0}})},n=O(()=>hM.submitLabel()),r=O(()=>hM.submittingLabel()),i=O(()=>hM.submitMode()===`create`?po:_o);bE(e,{get open(){return hM.formOpen},ariaLabel:`Workflow editor`,get error(){return hM.formError},get submitting(){return hM.submitting},get submitLabel(){return I(n)},get submittingLabel(){return I(r)},get submitIcon(){return I(i)},dialogClass:`workflow-editor`,onclose:()=>hM.closeForm(),onsubmit:()=>hM.submitForm(),header:t,children:(e,t)=>{var n=HN(),r=N(n),i=M(r);SE(i,{id:`workflow-scope-provider`,label:`Provider Name`,children:(e,t)=>{var n=EN(),r=M(n);r.value=r.__value=``,H(P(r),16,()=>hM.providerOptions(),e=>e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(n),L(`change`,n,e=>hM.setProvider(e.currentTarget.value)),Gi(n,()=>hM.form.scope_provider,e=>hM.form.scope_provider=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2),o=e=>{SE(e,{id:`workflow-scope-model`,label:`Model`,children:(e,t)=>{var n=DN(),r=M(n);r.value=r.__value=``,H(P(r),17,()=>hM.modelOptions(hM.form.scope_provider),e=>hM.form.scope_provider+`-`+e,(e,t)=>{var n=TN(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t)),i!==(i=I(t))&&(n.value=(n.__value=I(t))??``)}),z(e,n)}),T(n),Gi(n,()=>hM.form.scope_model,e=>hM.form.scope_model=e),z(e,n)},$$slots:{default:!0}})};V(a,e=>{hM.form.scope_provider&&e(o)});var s=P(a,2);SE(s,{id:`workflow-name`,label:`Name`,children:(e,t)=>{var n=ON();na(n),da(n,()=>hM.form.name,e=>hM.form.name=e),z(e,n)},$$slots:{default:!0}}),SE(P(s,2),{id:`workflow-user-path`,label:`User Path`,children:(e,t)=>{var n=kN();na(n),da(n,()=>hM.form.scope_user_path,e=>hM.form.scope_user_path=e),z(e,n)},$$slots:{default:!0}}),T(r);var c=P(r,8);SE(c,{id:`workflow-description`,label:`Description`,children:(e,t)=>{var n=AN();ft(n),da(n,()=>hM.form.description,e=>hM.form.description=e),z(e,n)},$$slots:{default:!0}});var l=P(c,2),u=M(l),d=e=>{var t=jN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.cache,e=>hM.form.features.cache=e),z(e,t)},f=O(()=>Ss.cacheVisible());V(u,e=>{I(f)&&e(d)});var p=P(u,2),m=e=>{var t=MN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.audit,e=>hM.form.features.audit=e),z(e,t)},h=O(()=>Ss.auditVisible());V(p,e=>{I(h)&&e(m)});var g=P(p,2),_=e=>{var t=NN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.usage,e=>hM.form.features.usage=e),z(e,t)},v=O(()=>Ss.usageVisible());V(g,e=>{I(v)&&e(_)});var y=P(g,2),b=e=>{var t=PN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.budget,e=>hM.form.features.budget=e),z(e,t)},x=O(()=>Ss.budgetsVisible());V(y,e=>{I(x)&&e(b)});var S=P(y,2),C=e=>{var t=FN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.guardrails,e=>hM.form.features.guardrails=e),z(e,t)},w=O(()=>Ss.guardrailsVisible());V(S,e=>{I(w)&&e(C)});var ee=P(S,2),te=e=>{var t=IN(),n=M(t);na(n),Ue(2),T(t),fa(n,()=>hM.form.features.failover,e=>hM.form.features.failover=e),z(e,t)},ne=O(()=>hM.failoverVisible());V(ee,e=>{I(ne)&&e(te)}),T(l);var re=P(l,2),ie=P(M(re),2);{let e=O(()=>hM.preview());CN(ie,{get workflow(){return I(e)},preview:!0})}T(re);var ae=P(re,2),oe=e=>{var t=VN(),n=M(t),r=P(M(n),2);T(n);var i=P(n,2),a=e=>{var t=LN(),n=P(M(t),2);T(t),L(`click`,n,()=>Jo.navigate(`guardrails`)),z(e,t)};V(i,e=>{hM.guardrailRefs.length===0&&e(a)});var o=P(i,2),s=e=>{var t=zN();H(t,21,()=>hM.form.guardrails,oi,(e,t,n)=>{var r=RN(),i=M(r),a=M(i);W(a,`for`,`workflow-guardrail-ref-`+n);var o=P(a,2);na(o),W(o,`id`,`workflow-guardrail-ref-`+n),W(o,`aria-label`,`Guardrail reference `+(n+1)),T(i);var s=P(i,2),c=M(s);W(c,`for`,`workflow-guardrail-step-`+n);var l=P(c,2);na(l),W(l,`id`,`workflow-guardrail-step-`+n),W(l,`aria-label`,`Guardrail step `+(n+1)),T(s);var u=P(s,2);T(r),da(o,()=>I(t).ref,e=>I(t).ref=e),da(l,()=>I(t).step,e=>I(t).step=e),L(`click`,u,()=>hM.removeGuardrailStep(n)),z(e,r)}),T(t),z(e,t)},c=e=>{z(e,BN())};V(o,e=>{hM.form.guardrails.length>0?e(s):e(c,-1)}),T(t),L(`click`,r,()=>hM.addGuardrailStep()),z(e,t)},se=O(()=>hM.form.features.guardrails&&Ss.guardrailsVisible());V(ae,e=>{I(se)&&e(oe)}),z(e,n)},$$slots:{header:!0,default:!0}})}D()}Hr([`change`,`click`]);var WN=R(`

                        Loading workflows...

                        `),GN=R(`
                        `),KN=R(`

                        No active workflows found.

                        `),qN=R(`

                        No workflows match your filter.

                        `),JN=R(`
                        `);function YN(e,t){E(t,!0);var n=JN(),r=M(n),i=e=>{var t=WN();SS(M(t),{size:16,label:`Loading workflows`}),Ue(),T(t),z(e,t)};V(r,e=>{hM.loading&&!K.authError&&e(i)});var a=P(r,2),o=e=>{var t=GN();H(t,21,()=>hM.filteredWorkflows,e=>e.id,(e,t)=>{CN(e,{get workflow(){return I(t)}})}),T(t),z(e,t)};V(a,e=>{hM.filteredWorkflows.length>0&&e(o)});var s=P(a,2),c=e=>{z(e,KN())};V(s,e=>{hM.workflows.length===0&&!hM.loading&&!K.authError&&hM.available&&e(c)});var l=P(s,2),u=e=>{z(e,qN())};V(l,e=>{hM.workflows.length>0&&hM.filteredWorkflows.length===0&&!hM.loading&&e(u)}),T(n),z(e,n),D()}var XN=R(``),ZN=R(`
                        Workflows feature is unavailable.
                        `),QN=R(`
                        `),$N=R(`
                        `),eP=R(``),tP=R(`
                        `);function nP(e,t){E(t,!0),An(()=>{K.refreshTick,hM.fetchPage()});var n=tP(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=XN();G(M(t),{get icon(){return po},class:`form-action-icon`,"aria-hidden":`true`}),Ue(2),T(t),L(`click`,t,()=>hM.openCreate()),z(e,t)};V(a,e=>{hM.available&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,ZN())};V(s,e=>{!hM.available&&!K.authError&&e(c)});var l=P(s,2),u=e=>{var t=QN(),n=M(t,!0);T(t),F(()=>B(n,hM.error)),z(e,t)};V(l,e=>{hM.error&&!K.authError&&e(u)});var d=P(l,2),f=e=>{var t=$N(),n=M(t);yw(M(n),{placeholder:`Filter by scope, name, hash, or guardrail...`,label:`Filter workflows by scope, name, hash, or guardrail`,get value(){return hM.filter},set value(e){hM.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i,!0);T(i),T(r),T(t),F(()=>B(a,hM.filteredWorkflows.length+` active scopes`)),z(e,t)};V(d,e=>{hM.available&&e(f)});var p=P(d,2);UN(p,{});var m=P(p,2);YN(m,{});var h=P(m,2);H(h,20,()=>hM.guardrailRefs,e=>e,(e,t)=>{var n=eP(),r={};F(()=>{r!==(r=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(h),T(n),z(e,n),D()}Hr([`click`]);function rP(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=Xs}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=iP(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function iP(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}var aP=null;function oP(){return aP===null&&(aP=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`)),!!(aP&&aP.matches)}function sP(e){return oP()?0:e}function cP(e,t){return!t||!t.live?{duration:0}:Js(e,{duration:sP(150)})}var lP=new class{#e=k(j({}));get workflowVersionsByID(){return I(this.#e)}set workflowVersionsByID(e){A(this.#e,e,!0)}workflowVersionRequests={};workflowFeatureCaps(){return{cache:Ss.cacheVisible(),audit:Ss.auditVisible(),usage:Ss.usageVisible(),budget:Ss.budgetsVisible(),guardrails:Ss.guardrailsVisible(),failover:Ss.booleanFlag(`FAILOVER_ENABLED`,!0)}}cacheWorkflowVersion(e){let t=String(e&&e.id||``).trim();return t?(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:e},e):null}cacheMissingWorkflowVersion(e){let t=String(e||``).trim();t&&(this.workflowVersionsByID={...this.workflowVersionsByID||{},[t]:null})}workflowVersionCacheHas(e){return Object.prototype.hasOwnProperty.call(this.workflowVersionsByID||{},String(e||``).trim())}workflowVersionByID(e){let t=String(e||``).trim();return t&&this.workflowVersionCacheHas(t)?this.workflowVersionsByID[t]:null}async fetchWorkflowVersion(e){let t=String(e||``).trim();if(!t)return null;if(this.workflowVersionCacheHas(t))return this.workflowVersionsByID[t];if(this.workflowVersionRequests[t])return this.workflowVersionRequests[t];let n=(async()=>{let e=typeof AbortController==`function`?new AbortController:null,n=e?setTimeout(()=>e.abort(),1e4):null;try{let n=await _s(`/admin/workflows/`+encodeURIComponent(t),{label:`workflow`,signal:e?e.signal:void 0});if(n.stale)return null;if(n.status===404)return this.cacheMissingWorkflowVersion(t),null;if(!n.ok)return null;let r=n.data;return!r||typeof r!=`object`||Array.isArray(r)?(this.cacheMissingWorkflowVersion(t),null):this.cacheWorkflowVersion(r)}catch(e){return e&&e.name===`AbortError`||console.error(`Failed to fetch workflow version:`,e),null}finally{n!==null&&clearTimeout(n),delete this.workflowVersionRequests[t]}})();return this.workflowVersionRequests[t]=n,n}async prefetchAuditWorkflows(e){let t=[...new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.workflow_version_id||``).trim()).filter(Boolean))];t.length!==0&&await Promise.all(t.map(e=>this.fetchWorkflowVersion(e)))}auditEntryWorkflow(e){let t=String(e&&e.workflow_version_id||``).trim();return t?this.workflowVersionByID(t):null}},uP=6;function dP(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}function fP(e,t=0,n=null){let r=String(e||``).trim();if(!r)return``;if(t>uP)return r;let i=dP(r);return i==null?r:pP(i,t+1,n)||n&&n(i)||r}function pP(e,t=0,n=null,r=null){if(e==null||t>uP)return``;if(typeof e==`string`){let i=dP(e.trim());return i==null?``:pP(i,t+1,n,r)}if(typeof e!=`object`)return``;let i=r||new Set;if(i.has(e))return``;if(i.add(e),Array.isArray(e)){for(let r=0;r=400||gP(t&&t.response_body)}function vP(e){let t=e&&e.data?e.data:null;return t?mP(t.error_message)||(_P(e,t)?pP(t.response_body,0):``):``}function yP(e){if(e==null||String(e).trim()===``)return null;let t=Number(e);return!Number.isInteger(t)||t<0?null:t}function bP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained indefinitely.`:t===1?`Audit logs are retained for 1 day.`:`Audit logs are retained for `+t+` days.`}function xP(e){let t=yP(e);return t===null?``:t===0?`Audit logs are retained `:`Audit logs are retained for `}function SP(e){let t=yP(e);return t===null?``:t===0?`indefinitely`:t===1?`1 day`:t+` days`}function CP({dateQuery:e,limit:t,offset:n,search:r,method:i,statusCode:a,stream:o}){let s=e;return s+=`&limit=`+t+`&offset=`+n,r&&(s+=`&search=`+encodeURIComponent(r)),i&&(s+=`&method=`+encodeURIComponent(i)),a&&(s+=`&status_code=`+encodeURIComponent(a)),o&&(s+=`&stream=`+encodeURIComponent(o)),s}function wP({sessionId:e,limit:t}){return`session_id=`+encodeURIComponent(e)+`&limit=`+(t||100)+`&offset=0`}function TP(e){return String(e&&e.session_id||``).trim()}function EP(e){let t=Number(e&&e.session_count);return Number.isFinite(t)&&t>1?t:1}function DP(e){return!!TP(e)&&EP(e)>1}function OP(e){return{entries:(Array.isArray(e&&e.sessions)?e.sessions:[]).filter(e=>e&&e.latest).map(e=>({...e.latest,session_id:TP(e.latest)||String(e.session_id||``).trim(),session_count:Number(e.count||1)})),total:Number(e&&e.total||0),limit:Number(e&&e.limit||25),offset:Number(e&&e.offset||0)}}function kP(e,t,n){let r=new Set((Array.isArray(n)?n:[]).flatMap(e=>NP(e))),i=(Array.isArray(t)?t:[]).filter(e=>!NP(e).some(e=>r.has(e))),a=new Set([...r,...i.flatMap(e=>NP(e))]),o=(e&&Array.isArray(e.entries)?e.entries:[]).filter(e=>e&&e._live&&!NP(e).some(e=>a.has(e)));return{entries:[...o,...i],preservedCount:o.length}}function AP(e,t){let n=e||{};if(!t)return n;if(n[t]){let e={...n};return delete e[t],e}return{...n,[t]:!0}}function jP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>TP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=n[e];return}a=!0}),a?i:n}function MP(e){return String(e&&e.id||``).trim()}function NP(e){if(!e)return[];let t=[],n=String(e.id||``).trim(),r=String(e.request_id||``).trim();return n&&t.push(`id:`+n),r&&t.push(`request:`+r),t}function PP(e){return!!(e&&e._live&&e._live_pending&&!e._audit_flushed)}function FP(e){let t=e&&e.customStartDate,n=e&&e.customEndDate;if(!t&&!n)return!0;let r=new Date;if(t){let e=new Date(t);if(e.setHours(0,0,0,0),Number.isFinite(e.getTime())&&re)return!1}return!0}function IP(e,t){return e&&Number(e.offset||0)===0&&!(t&&t.search)&&!(t&&t.method)&&!(t&&t.statusCode)&&!(t&&t.stream)&&FP(t)}function LP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=[];return a.forEach(e=>{let t=NP(e);t.length!==0&&(t.some(e=>o.has(e))||(t.forEach(e=>o.add(e)),s.push(e)))}),s.length===0?r:(r.entries=[...s,...i].slice(0,r.limit||25),r.total=Number(r.total||0)+s.length,r)}function RP(e,t,n){let r=e&&typeof e==`object`?{...e}:{entries:[],total:0,limit:25,offset:0},i=Array.isArray(r.entries)?r.entries:[];if(r.entries=i,!IP(r,n))return r;let a=(Array.isArray(t)?t:[]).filter(e=>PP(e));if(a.length===0)return r;let o=new Set(i.flatMap(e=>NP(e))),s=new Map;i.forEach((e,t)=>{let n=TP(e);n&&!s.has(n)&&s.set(n,t)});let c=[],l=i;return a.forEach(e=>{let t=NP(e);if(t.length===0||t.some(e=>o.has(e)))return;let n=TP(e);if(n&&s.has(n)){let r=s.get(n);l===i&&(l=[...i]),l[r]={...e,session_count:Math.max(EP(l[r]),EP(e))},t.forEach(e=>o.add(e));return}t.forEach(e=>o.add(e)),c.push(e)}),r.entries=[...c,...l].slice(0,r.limit||25),r.total=Number(r.total||0)+c.length,r}function zP(e,t){let n=MP(t),r=e||{};return n?r[n]?{}:{[n]:!0}:r}function BP(e,t){let n=e||{},r=new Set((Array.isArray(t)?t:[]).map(e=>MP(e)).filter(Boolean)),i={},a=!1;return Object.keys(n).forEach(e=>{if(r.has(e)){i[e]=!0;return}a=!0}),a?i:n}function VP(e){if(e==null)return`-`;let t=Number(e);return Number.isFinite(t)?t<=0?`pending`:t<1e6?Math.round(t/1e3)+` µs`:t<1e9?(t/1e6).toFixed(2)+` ms`:(t/1e9).toFixed(2)+` s`:`-`}function HP(e){if(e==null||e===``)return`status-unknown`;let t=Number(e);return Number.isFinite(t)?t>=500?`status-error`:t>=400?`status-warning`:t>=300?`status-neutral`:`status-success`:`status-unknown`}function UP(e){if(!e||!e._live||!e._live_pending)return!1;let t=String(e._live_state||``).trim();if(t===`audit.completed`||t===`audit.flushed`||t===`audit.detail`)return!1;if(e._response_partial)return!0;if(e.status_code!==null&&e.status_code!==void 0&&e.status_code!==``||Number(e.duration_ns||0)>0||e.error_type||e.error_message)return!1;let n=e.data||{};return!(n.response_headers||n.response_body||n.error_message)}function WP(e){let t=e&&e.data&&e.data.failover;return!t||typeof t!=`object`||Array.isArray(t)?null:String(t.target_model||t.targetModel||``).trim()||null}function GP(e){return(e&&e.data&&Array.isArray(e.data.attempts)?e.data.attempts:[]).map((e,t)=>({...e,seq:Number(e&&e.seq||t+1)})).sort((e,t)=>e.seq-t.seq)}function KP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))}function qP(e){if(!e)return`-`;let t=e.status_code||e.status;return t?String(t):e.success?`ok`:`error`}function JP(e){return String(e&&e.kind||``).trim()||`attempt`}function YP(e){if(!e)return`-`;let t=String(e.provider_name||``).trim(),n=String(e.provider_type||e.provider||``).trim();return t&&n&&t!==n?t+` (`+n+`)`:t||n||`-`}function XP(e){return String(e&&e.model||``).trim()||`-`}function ZP(e){let t=GP(e);return t.length>1||t.some(e=>!(e&&e.success))?t:[]}function QP(e){return GP(e).length+`×`}function $P(e){let t=GP(e),n=t.filter(e=>!(e&&e.success)).length,r=t.length===1?`attempt`:`attempts`,i=t.length+` provider `+r;return n>0?i+` · `+n+` failed`:i}function eF(e){if(!e)return``;let t=[`#`+Number(e.seq||0)],n=JP(e);n&&n!==`attempt`&&t.push(n),t.push(qP(e));let r=YP(e);r&&r!==`-`&&t.push(r);let i=XP(e);return i&&i!==`-`&&t.push(i),t.push(e.success?`succeeded`:`failed`),t.join(` · `)}function tF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t&&t.response_body!=null?t.response_body:null}return t.response_body!=null&&t.response_body!==``?t.response_body:null}function nF(e){if(!e||e.success)return``;let t=String(e.error_message||``).trim(),n=String(e.error_code||``).trim(),r=String(e.error_type||``).trim();return t&&n?n+`: `+t:t||n||r||`Provider attempt failed`}function rF(e,t){if(!t)return null;if(t.success){let t=e&&e.data?e.data:null;return t?t.response_headers:null}return t.response_headers||null}function iF(e){let t=Number(e&&e.status_code);return Number.isFinite(t)&&t>0?t:null}function aF(e,t){let n=!!(t&&t.success),r=e&&e.data?e.data:null,i=tF(e,t),a=rF(e,t),o=nF(t),s=i!=null&&i!==``,c=JP(t),l=GP(e).length<=1;return{title:`Response`,direction:`response`,seq:l?0:Number(t&&t.seq||0),kind:l||c===`attempt`?``:c,statusCode:l?null:iF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:i,showErrorMessage:!!o,errorMessage:o,showHeaders:!!a,headers:a,showBody:s,body:i,showEmpty:!o&&!s&&!a,emptyMessage:`No response was captured for this attempt.`,showTooLarge:!!(n&&r&&r.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function oF(e){return e&&e.data&&Array.isArray(e.data.request_revisions)?e.data.request_revisions:[]}function sF(e){return oF(e).filter(e=>!(e&&e.no_change))}function cF(e){return oF(e).filter(e=>e&&e.no_change).map(e=>{let t=String(e.rewriter||`rewriter`);return{id:`step-`+Number(e.seq||0),rewriter:t,label:t+`: no change`,title:t+` ran and forwarded the request unchanged`}})}function lF(e){let t=Number(e&&e.bytes_before),n=Number(e&&e.bytes_after);if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n>=t)return``;let r=(1-n/t)*100;return`-`+(r>=10?String(Math.round(r)):r.toFixed(1))+`%`}function uF(e,t){let n=t&&t.body,r=n!=null&&n!==``,i=sF(e).length<=1,a={rewriter:t&&t.rewriter||``,bytes:Number(t&&t.bytes_before||0)+` → `+Number(t&&t.bytes_after||0)};return t&&t.detail!=null&&(a.detail=t.detail),{title:`Rewritten`,direction:`request`,seq:i?0:Number(t&&t.seq||0),kind:t&&t.rewriter?String(t.rewriter):``,savingsLabel:lF(t),layout:`split`,entry:e,copyHeaders:a,copyBody:n,showErrorMessage:!1,errorMessage:null,showHeaders:!0,headers:a,headersTitle:`What changed`,showBody:r,body:n,showEmpty:!1,emptyMessage:``,showTooLarge:!r,tooLargeMessage:`Rewritten body not captured (body logging disabled or body too large).`}}function dF(e){let t=e&&e.usage;return!t||typeof t!=`object`?null:t}function fF(e){let t=dF(e);return Number(t&&t.cached_input_tokens||0)>0}function pF(e){let t=dF(e),n=Number(t&&t.input_tokens||0),r=Number(t&&t.cached_input_tokens||0);return!Number.isFinite(n)||n<=0||!Number.isFinite(r)||r<=0?0:Math.max(0,Math.min(100,r/n*100))}function mF(e){let t=dF(e);if(!t)return``;let n=Number(t.input_tokens||0),r=Number(t.cached_input_tokens||0);return n<=0?oc(r)+` cached`:pF(e).toFixed(1)+`% cached`}function hF(e){return fF(e)?mF(e):``}function gF(e,t){let n=dF(e);if(!n||!e||!e.data||!e.data.request_body)return null;let r=Number(n.estimated_cached_characters||0);if(!Number.isFinite(r)||r<=0||typeof t!=`function`)return null;let i=t(e.data.request_body);return!Array.isArray(i)||i.length===0?null:{characters:r,segments:i}}function _F(e,t){let n=e&&e.data?e.data:null,r=!n||!n.request_headers&&!n.request_body,i=r&&UP(e);return{title:`Request`,direction:`request`,layout:`split`,entry:e,copyHeaders:n&&n.request_headers,copyBody:n&&n.request_body,showErrorMessage:!1,errorMessage:null,showHeaders:!!(n&&n.request_headers),headers:n&&n.request_headers,showBody:!!(n&&n.request_body),body:n&&n.request_body,bodyCacheRatioLabel:hF(e),promptCacheHighlight:gF(e,t),noChangeSteps:cF(e),showEmpty:r&&!i,emptyMessage:`Request details were not captured.`,showPending:i,pendingMessage:`Waiting for request data…`,showTooLarge:!!(n&&n.request_body_too_big_to_handle),tooLargeMessage:`Request body was too large to capture.`}}function vF(e){let t=e&&e.data?e.data:null,n=vP(e),r=!t||!n&&!t.response_headers&&!t.response_body,i=r&&UP(e);return{title:`Response`,direction:`response`,layout:`split`,entry:e,copyHeaders:t&&t.response_headers,copyBody:t&&t.response_body,showErrorMessage:!!n,errorMessage:n,showHeaders:!!(t&&t.response_headers),headers:t&&t.response_headers,showBody:!!(t&&t.response_body),body:t&&t.response_body,streaming:!!(e&&e._response_partial&&t&&t.response_body)&&UP(e),showEmpty:r&&!i,emptyMessage:`Response details were not captured.`,showPending:i,pendingMessage:`Response in progress…`,showTooLarge:!!(t&&t.response_body_too_big_to_handle),tooLargeMessage:`Response body was too large to capture.`}}function yF(e,t){let n=[{id:`request`,pane:_F(e,t)}];return sF(e).forEach(t=>{n.push({id:`revision-`+Number(t&&t.seq||0),pane:uF(e,t)})}),KP(e)?GP(e).forEach(t=>{n.push({id:`response-`+Number(t&&t.seq||0),pane:aF(e,t)})}):n.push({id:`response`,pane:vF(e)}),n}function bF(e){if(!KP(e))return`response`;let t=GP(e),n=null;return t.forEach(e=>{e&&e.success&&(n=e)}),n||=t[t.length-1],n?`response-`+Number(n.seq||0):`request`}function xF(e,t,n){return e&&(Array.isArray(n)?n:yF(t)).some(t=>t.id===e)?e:bF(t)}function SF(e,t,n){if(!t||!t.length)return null;let r=t.indexOf(n);r<0&&(r=0);let i;switch(e){case`ArrowRight`:case`ArrowDown`:i=(r+1)%t.length;break;case`ArrowLeft`:case`ArrowUp`:i=(r-1+t.length)%t.length;break;case`Home`:i=0;break;case`End`:i=t.length-1;break;default:return null}return t[i]}var CF=100;function wF(){return{entries:[],total:0,limit:25,offset:0}}var TF=new class{#e=k(j({}));get auditExpandedEntries(){return I(this.#e)}set auditExpandedEntries(e){A(this.#e,e,!0)}#t=k(j({}));get auditExpandedThreads(){return I(this.#t)}set auditExpandedThreads(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}auditFetchToken=0;get auditLog(){return MC.auditLog}set auditLog(e){MC.auditLog=e}get auditSearch(){return MC.auditSearch}set auditSearch(e){MC.auditSearch=e}get auditMethod(){return MC.auditMethod}set auditMethod(e){MC.auditMethod=e}get auditStatusCode(){return MC.auditStatusCode}set auditStatusCode(e){MC.auditStatusCode=e}get auditStream(){return MC.auditStream}set auditStream(e){MC.auditStream=e}get auditGroupSessions(){return MC.auditGroupSessions}liveFilters(){return{search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream,customStartDate:Mc.customStartDate,customEndDate:Mc.customEndDate}}toggleAuditGroupSessions(){MC.auditGroupSessions=!MC.auditGroupSessions,Ea(`gomodel_audit_group_sessions`,MC.auditGroupSessions),this.auditExpandedThreads={},MC.auditThreadChildren={},this.fetchAuditLog(!0)}async fetchAuditLog(e){let t=++this.auditFetchToken;this.loading=!0;try{e&&(this.auditLog.offset=0);let n=this.auditGroupSessions,r=CP({dateQuery:Mc.queryStr(),limit:this.auditLog.limit,offset:this.auditLog.offset,search:this.auditSearch,method:this.auditMethod,statusCode:this.auditStatusCode,stream:this.auditStream}),i=await _s((n?`/admin/audit/sessions?`:`/admin/audit/log?`)+r,{label:`audit log`});if(i.stale||t!==this.auditFetchToken)return;if(!i.ok){this.auditLog=wF();return}let a=n?OP(i.data):i.data,o=(n?RP:LP)(a,this.auditLog&&this.auditLog.entries,this.liveFilters());Array.isArray(o.entries)||(o.entries=[]),o.entries=MC.upsertAuditRecords(o.entries,`audit.list`),this.auditLog=o,this.auditExpandedThreads=jP(this.auditExpandedThreads,o.entries),MC.auditThreadChildren=jP(MC.auditThreadChildren,o.entries);let s=[...o.entries,...this.loadedThreadChildren()];this.auditExpandedEntries=BP(this.auditExpandedEntries,s);try{await lP.prefetchAuditWorkflows(s)}catch(e){console.error(`Failed to prefetch audit workflows:`,e)}}catch(e){if(console.error(`Failed to fetch audit log:`,e),t!==this.auditFetchToken)return;this.auditLog=wF()}finally{t===this.auditFetchToken&&(this.loading=!1)}}loadedThreadChildren(){let e=MC.auditThreadChildren||{};return Object.keys(e).flatMap(t=>Array.isArray(e[t]&&e[t].entries)?e[t].entries:[])}isThreadExpanded(e){return!!(e&&this.auditExpandedThreads[e])}threadChildren(e){return e&&MC.auditThreadChildren[e]||null}async toggleThread(e){let t=TP(e);if(!t)return;let n=!this.isThreadExpanded(t);this.auditExpandedThreads=AP(this.auditExpandedThreads,t);let r=MC.auditThreadChildren[t];n&&!(r&&(r.loaded||r.loading))&&await this.fetchThreadEntries(e)}async fetchThreadEntries(e){let t=TP(e);if(!t)return;let n=MC.auditThreadChildren[t];MC.auditThreadChildren={...MC.auditThreadChildren,[t]:{loading:!0,loaded:!1,entries:n&&Array.isArray(n.entries)?n.entries:[],total:Number(n&&n.total||0)}};let r=()=>{let e={...MC.auditThreadChildren},n=e[t],r=n&&Array.isArray(n.entries)?n.entries:[];r.length>0?e[t]={loading:!1,loaded:!1,entries:r,total:r.length}:(delete e[t],this.auditExpandedThreads[t]&&(this.auditExpandedThreads=AP(this.auditExpandedThreads,t))),MC.auditThreadChildren=e};try{let n=await _s(`/admin/audit/log?`+wP({sessionId:t,limit:CF}),{label:`audit session`});if(n.stale){r();return}if(!n.ok)throw Error(`audit session fetch failed`);let i=MC.auditThreadChildren[t],a=this.auditLog.entries.find(e=>TP(e)===t),o=kP(i,n.data.entries,a?[a]:[e]);o.entries=MC.upsertAuditRecords(o.entries,`audit.thread`),MC.auditThreadChildren={...MC.auditThreadChildren,[t]:{loading:!1,loaded:!0,entries:o.entries,total:Number(n.data.total||0)+o.preservedCount}}}catch(e){console.error(`Failed to fetch audit session entries:`,e),r()}}clearAuditFilters(){this.auditSearch=``,this.auditMethod=``,this.auditStatusCode=``,this.auditStream=``,this.fetchAuditLog(!0)}auditLogNextPage(){this.auditLog.offset+this.auditLog.limit0&&(this.auditLog.offset=Math.max(0,this.auditLog.offset-this.auditLog.limit),this.fetchAuditLog(!1))}isAuditEntryExpanded(e){let t=MP(e);return t?!!(this.auditExpandedEntries&&this.auditExpandedEntries[t]):!1}toggleAuditEntryExpanded(e){this.auditExpandedEntries=zP(this.auditExpandedEntries,e);let t=this.isAuditEntryExpanded(e);return t&&typeof MC.fetchAuditEntryDetail==`function`&&MC.fetchAuditEntryDetail(e),t}expandAuditEntry(e){this.isAuditEntryExpanded(e)||this.toggleAuditEntryExpanded(e)}};MC.fetchAuditLog=e=>TF.fetchAuditLog(e),MC.isAuditEntryExpanded=e=>TF.isAuditEntryExpanded(e);var EF=R(`
                        `);function DF(e,t){E(t,!0);let n=bw(()=>TF.fetchAuditLog(!0));An(()=>n.cancel);var r=EF(),i=M(r);yw(M(i),{id:`audit-filter-search`,placeholder:`Search by request ID, model, provider, path, user path, or error...`,label:`Search by request ID, model, provider, path, user path, or error`,get oninput(){return n},get value(){return TF.auditSearch},set value(e){TF.auditSearch=e}}),T(i);var a=P(i,2),o=M(a),s=M(o);s.value=s.__value=``;var c=P(s);c.value=c.__value=`GET`;var l=P(c);l.value=l.__value=`POST`;var u=P(l);u.value=u.__value=`PUT`;var d=P(u);d.value=d.__value=`PATCH`;var f=P(d);f.value=f.__value=`DELETE`,T(o);var p=P(o,2),m=M(p);m.value=m.__value=``;var h=P(m);h.value=h.__value=`200`;var g=P(h);g.value=g.__value=`201`;var _=P(g);_.value=_.__value=`400`;var v=P(_);v.value=v.__value=`401`;var y=P(v);y.value=y.__value=`403`;var b=P(y);b.value=b.__value=`404`;var x=P(b);x.value=x.__value=`429`;var S=P(x);S.value=S.__value=`500`;var C=P(S);C.value=C.__value=`502`;var w=P(C);w.value=w.__value=`503`;var ee=P(w);ee.value=ee.__value=`504`,T(p);var te=P(p,2),ne=M(te);ne.value=ne.__value=``;var re=P(ne);re.value=re.__value=`true`;var ie=P(re);ie.value=ie.__value=`false`,T(te);var ae=P(te,2);G(M(ae),{get icon(){return Io},class:`table-icon-svg`}),Ue(2),T(ae),T(a),T(r),L(`change`,o,()=>TF.fetchAuditLog(!0)),Gi(o,()=>TF.auditMethod,e=>TF.auditMethod=e),L(`change`,p,()=>TF.fetchAuditLog(!0)),Gi(p,()=>TF.auditStatusCode,e=>TF.auditStatusCode=e),L(`change`,te,()=>TF.fetchAuditLog(!0)),Gi(te,()=>TF.auditStream,e=>TF.auditStream=e),L(`click`,ae,()=>TF.clearAuditFilters()),z(e,r),D()}Hr([`change`,`click`]);var OF=R(`Live stream connecting…`),kF=R(` `),AF=R(`Live`),jF=R(` `);function MF(e,t){E(t,!0);let n=O(()=>MC.auditLivePauseReason()),r=O(()=>MC.liveLogsStreaming&&!I(n));var i=Qr(),a=N(i),o=e=>{var t=jF(),i=M(t);let a;var o=P(i,2),s=e=>{z(e,OF())},c=e=>{var t=kF(),r=M(t,!0);T(t),F(e=>B(r,e),[()=>bC(I(n))]),z(e,t)},l=e=>{z(e,AF())};V(o,e=>{MC.liveLogsStreaming?I(n)?e(c,1):e(l,-1):e(s)}),T(t),F(()=>a=U(i,1,`live-dot svelte-tve6yv`,null,a,{"is-streaming":I(r)})),z(e,t)},s=O(()=>Ss.liveLogsVisible());V(a,e=>{I(s)&&e(o)}),z(e,i),D()}var NF=R(` `),PF=R(``);function FF(e,t){E(t,!0);let n=O(()=>[{key:`provider`,text:gc(t.entry)||`-`},{key:`model`,text:t.entry.requested_model||t.entry.model||`-`,mono:!0},{key:`user_path`,text:t.entry.user_path,mono:!0},{key:`request_id`,text:`request_id: `+(t.entry.request_id||`-`),mono:!0},{key:`ip`,text:t.entry.client_ip&&`ip: `+t.entry.client_ip,mono:!0},{key:`auth_key_id`,text:t.entry.auth_key_id&&`auth_key_id: `+t.entry.auth_key_id,mono:!0},{key:`alias`,text:t.entry.alias_used&&`alias`,class:`audit-alias-badge`},{key:`resolved`,text:t.entry.alias_used&&t.entry.resolved_model&&`resolved: `+yc(t.entry),mono:!0},{key:`failover`,text:WP(t.entry)&&`failover: `+WP(t.entry),mono:!0},{key:`stream`,text:t.entry.stream&&`stream`},{key:`error_type`,text:t.entry.error_type}].filter(e=>!!e.text));var r=PF(),i=P(M(r),2);H(i,21,()=>I(n),e=>e.key,(e,t)=>{var n=NF(),r=M(n,!0);T(n),F(()=>{U(n,1,Fi([`provider-badge`,I(t).class,{mono:I(t).mono}]),`svelte-hyopt0`),B(r,I(t).text)}),z(e,n)}),T(i),T(r),z(e,r),D()}var IF=R(``),LF=R(` `);function RF(e,t){E(t,!0);let n=O(()=>ZP(t.entry)),r=O(()=>I(n).length>0?$P(t.entry):``),i=O(()=>I(n).length>0?QP(t.entry):``);var a=Qr(),o=N(a),s=e=>{var a=LF(),o=M(a);H(o,21,()=>I(n),e=>t.entry.id+`-pip-`+e.seq,(e,t)=>{var n=IF();let r;F(e=>{r=U(n,1,`audit-attempt-pip svelte-1eu22xn`,null,r,{"audit-attempt-success":!!(I(t)&&I(t).success),"audit-attempt-error":!(I(t)&&I(t).success)}),W(n,`title`,e)},[()=>eF(I(t))]),z(e,n)}),T(o);var s=P(o,2),c=M(s,!0);T(s),T(a),F(()=>{W(a,`title`,I(r)),W(a,`aria-label`,I(r)),B(c,I(i))}),z(e,a)};V(o,e=>{I(n).length>0&&e(s)}),z(e,a),D()}var zF=new Set([`instructions`,`messages`,`input`,`previous_response_id`,`choices`,`output`]);function BF(e){if(!e||typeof e!=`object`)return``;let t=String(e.type||``).toLowerCase();if(t===`image`||t===`image_url`||t===`input_image`||t===`output_image`)return`[Image]`;if(t===`audio`||t===`input_audio`||t===`output_audio`)return`[Audio]`;if(t===`file`||t===`input_file`||t===`output_file`){let t=String(e.filename||e.name||``).trim();return t?`[File: `+t+`]`:`[File]`}return typeof e.refusal==`string`?e.refusal:``}function VF(e){if(e==null)return``;if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:!e||typeof e!=`object`?``:typeof e.text==`string`?e.text:typeof e.output_text==`string`?e.output_text:BF(e)).filter(Boolean).join(` -`).trim();if(typeof e==`object`){if(typeof e.text==`string`)return e.text.trim();try{return JSON.stringify(e,null,2)}catch{return``}}return String(e).trim()}function HF(e){return!e||typeof e!=`object`?``:VF(e.content)||(typeof e.refusal==`string`?e.refusal.trim():``)}function UF(e){if(e==null)return[];if(typeof e==`string`)return e?[e]:[];if(Array.isArray(e))return e.flatMap(e=>typeof e==`string`?e?[e]:[]:!e||typeof e!=`object`?[]:typeof e.text==`string`?e.text?[e.text]:[]:typeof e.output_text==`string`&&e.output_text?[e.output_text]:[]);if(typeof e==`object`)return typeof e.text==`string`&&e.text?[e.text]:[];let t=String(e);return t?[t]:[]}function WF(e){let t=Number(e&&e.usage&&e.usage.estimated_cached_characters||0);return Number.isFinite(t)&&t>0?Math.floor(t):0}function GF(e,t){if(!e)return null;let n=(Array.isArray(t)?t:[]).reduce((e,t)=>e+String(t||``).length,0),r=Math.min(String(e).length,n);return r>0?{total:r}:null}function KF(e){let t=e&&e.arguments!==void 0?e.arguments:``,n=``;if(typeof t==`string`)n=t;else try{n=JSON.stringify(t)}catch{n=String(t)}return(String(e&&e.name||``)+`(`+n+`)`).length}function qF(e){return{characters:(Array.isArray(e)?e:[]).map(KF)}}function JF(e,t){let n=Math.max(0,Number(t||0));return e.map(e=>{if(!e||e.role===`error`)return e;let t=Math.max(0,Number(e._promptTextCharacters||0)),r=Math.min(n,t);n-=r;let i=0;(Array.isArray(e._toolPromptCharacters)?e._toolPromptCharacters:[]).forEach(e=>{let t=Math.max(0,Number(e||0)),r=Math.min(n,t);n-=r,i+=r});let a=t+(e._toolPromptCharacters||[]).reduce((e,t)=>e+Math.max(0,Number(t||0)),0);return{...e,promptCacheRatio:a>0?(r+i)/a:0}})}function YF(e){if(e==null)return[];if(typeof e==`string`){let t=e.trim();return t?[{role:`user`,text:t}]:[]}if(!Array.isArray(e)){let t=VF(e);return t?[{role:`user`,text:t}]:[]}return e.map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e.role||`user`).toLowerCase(),n=VF(e.content);return n?{role:t,text:n}:null}).filter(Boolean)}function XF(e){return!e||typeof e!=`object`?``:Array.isArray(e.content)?e.content.map(e=>e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` -`).trim():VF(e.content)}function ZF(e){if(!e||typeof e!=`object`)return[];let t=[];return t.push(...UF(e.instructions)),Array.isArray(e.messages)&&e.messages.forEach(e=>{!e||typeof e!=`object`||t.push(...UF(e.content))}),typeof e.input==`string`?t.push(e.input):Array.isArray(e.input)?e.input.forEach(e=>{!e||typeof e!=`object`||(t.push(...UF(e.content)),typeof e.text==`string`&&t.push(e.text))}):e.input&&typeof e.input==`object`&&(t.push(...UF(e.input.content)),typeof e.input.text==`string`&&t.push(e.input.text)),t.map(e=>String(e||``)).filter(e=>e.length>0)}var QF=e=>VF(e);function $F(e){if(!e||!e.data)return``;let t=pP(e.data.response_body,0,QF);if(t)return t;let n=e.data.error_message;if(n==null)return``;if(typeof n==`string`){let e=n.trim();return e?pP(dP(e),0,QF)||e:``}return pP(n,0,QF)||VF(n)}function eI(e){return Array.isArray(e)?e.some(e=>!e||typeof e!=`object`?!1:e.type===`message`||e.role===`assistant`||e.role===`user`||e.role===`system`?!0:Array.isArray(e.content)?e.content.some(e=>!e||typeof e!=`object`?!1:typeof e.text==`string`||e.type===`output_text`||e.type===`input_text`):!1):!1}function tI(e){if(!e)return!1;let t=String(e).toLowerCase();return t===`/v1/embeddings`||t===`/v1/embeddings/`||t.startsWith(`/v1/embeddings?`)||t.startsWith(`/v1/embeddings/`)}function nI(e){return e?!!iI(e):!1}function rI(e){let t=String(e||``).trim().split(`?`)[0].replace(/\/+$/,``).toLowerCase();return t.startsWith(`/v1/`)?t.slice(3):t}function iI(e){switch(rI(e)){case`/chat/completions`:return`chat`;case`/responses`:return`responses`;case`/messages`:return`messages`;default:return``}}function aI(e){if(!e||typeof e!=`object`)return null;try{return JSON.parse(JSON.stringify(e))}catch{return null}}function oI(e,t){if(!t||typeof t!=`object`)return;let n=e[e.length-1];try{if(n&&JSON.stringify(n)===JSON.stringify(t))return}catch{}e.push(t)}function sI(e){let t=iI(e&&e.path),n=e&&e.data&&e.data.request_body;return!t||!n||typeof n!=`object`?!1:t!==`responses`||(e.data&&e.data.response_body&&typeof e.data.response_body.id==`string`?e.data.response_body.id.trim():``)!==``||GI(n)!==``}function cI(e,t){let n=String(t||``).trim(),r=iI(e&&e.path),i=aI(e&&e.data&&e.data.request_body);if(!n||!r||!i)return null;let a=e&&e.data?e.data.response_body:null;if(r===`responses`){let e=a&&typeof a.id==`string`?a.id.trim():``,t=GI(i);return!e&&!t?null:(i.input=n,e&&!t?i.previous_response_id=e:delete i.previous_response_id,i)}let o=Array.isArray(i.messages)?i.messages:[];if(r===`chat`){let e=a&&Array.isArray(a.choices)?a.choices[0]:null;e&&e.message&&oI(o,aI(e.message)),o.push({role:`user`,content:n})}else a&&a.content!==void 0&&oI(o,{role:String(a.role||`assistant`),content:aI(a.content)||a.content}),o.push({role:`user`,content:n});return i.messages=o,i}var lI=new Set(`authorization.proxy-authorization.cookie.content-type.content-length.host.accept.connection.accept-encoding.content-encoding.transfer-encoding.user-agent.date.expect.upgrade.via.te.trailer.keep-alive.origin.referer.forwarded.x-real-ip.traceparent.tracestate.x-request-id.idempotency-key.x-idempotency-key.x-gomodel-timezone.x-gomodel-interaction-parent`.split(`.`));function uI(e,t,n=``){let r=e&&e.data&&e.data.request_headers,i={};return r&&typeof r==`object`&&Object.keys(r).forEach(e=>{let t=String(e).toLowerCase(),n=String(r[e]==null?``:r[e]);!e||!n||n===`[REDACTED]`||lI.has(t)||t.startsWith(`sec-`)||t.startsWith(`cf-`)||t.startsWith(`x-forwarded-`)||(i[e]=n)}),i[`X-GoModel-Interaction-Parent`]=String(t||e&&e.id||``).trim(),String(n||``).trim()&&(i[`X-Request-ID`]=String(n).trim()),i}function dI(e,t){let n=String(t||``).trim();return!n||!Array.isArray(e)?null:e.find(e=>String(e&&e.request_id||``).trim()===n)||null}function fI(e,t,n,r,i){let a=Array.isArray(e)?e:[],o=String(i&&i.id||``).trim(),s=String(i&&i.request_id||``).trim(),c=String(i&&i.session_id||``).trim(),l=String(r||``).trim(),u=pI(i),d=a.some(e=>o&&String(e&&e.id||``).trim()===o||s&&String(e&&e.request_id||``).trim()===s),f=!!l&&s===l,p=!!n&&c===String(n).trim(),m=!!u&&(u===String(t||``).trim()||a.some(e=>String(e&&e.id||``).trim()===u)),h=d||f||!l&&(p||m);return{accepted:h,submittedChild:f,followUpRequestID:h&&f&&o?``:l}}function pI(e){let t=e&&e.data&&e.data.request_headers;if(!t||typeof t!=`object`)return``;let n=Object.keys(t).find(e=>e.toLowerCase()===`x-gomodel-interaction-parent`);return n?String(t[n]||``).trim():``}function mI(e,t){return!Array.isArray(e)||!t?null:e.find(e=>String(e&&e.id||``)===String(t))||null}function hI(e){return!Array.isArray(e)||e.length===0?null:e.reduce((e,t)=>e?KI(t,e)>=0?t:e:t,null)}function gI(e,t){let n=new Set(Array.isArray(t)?t.map(String):[]);return hI((Array.isArray(e)?e:[]).filter(e=>{let t=String(e&&e.id||``);return n.has(t)&&e&&e.data&&e.data.request_body!=null}))}function _I(e,t){let n=hI(e);return!!n&&String(n.id||``)===String(t||``)}function vI(e,t,n){return String(e||``).trim()===`audit.flushed`&&String(t||``).trim()!==``&&String(t||``).trim()===String(n||``).trim()}function yI(e,t){let n=Array.isArray(e)?e.filter(Boolean).map(String):[];return(Array.isArray(t)?t:[]).forEach(e=>{let t=String(e&&(e.id||e.request_id)||``).trim();t&&!n.includes(t)&&n.push(t)}),n}function bI(e){if(e&&e.conversation_payload)return!0;let t=e&&e.data?e.data.request_body:null,n=e&&e.data?e.data.response_body:null,r=t&&(Array.isArray(t.messages)||t.input!==void 0||typeof t.instructions==`string`||typeof t.previous_response_id==`string`),i=n&&(Array.isArray(n.choices)||eI(n.output));return!!(r||i)}function xI(e){return!e||tI(e.path)?!1:nI(e.path)||bI(e)}function SI(e){let t=0,n=!1,r=!1,i=String(e||``);for(let e=0;e0&&a+1`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function EI(e){return!!(e&&typeof e==`object`&&e.__audio__===!0)}function DI(e){let t=Number(e||0);if(!Number.isFinite(t)||t<=0)return`0 B`;let n=[`B`,`KB`,`MB`,`GB`],r=0,i=t;for(;i>=1024&&r`
                        `+TI(t)+``+TI(kI(e[t]))+`
                        `);return t.length?``:``}function jI(e){let t=OI(e.content_type),n=TI(t+` · `+DI(e.bytes)),r=AI(e.meta);if(e.stored&&e.encoding===`base64`&&e.data){let i=String(e.data).replace(/[^A-Za-z0-9+/=]/g,``);return`
                        `+n+`
                        `+r+`
                        `}let i=e.too_large?`Audio too large to store.`:`Audio not logged. Set LOGGING_LOG_AUDIO_BODIES=true to capture playable audio.`;return`
                        `+n+`
                        `+TI(i)+`
                        `+r+`
                        `}function MI(e){try{return JSON.stringify(String(e)).slice(1,-1)}catch{return``}}function NI(e){if(!e||typeof e!=`object`)return null;let t=Number(e.characters||0);if(!Number.isFinite(t)||t<=0)return null;let n=Array.isArray(e.segments)?e.segments.map(e=>String(e||``)).filter(Boolean):[];return n.length===0?null:{remaining:Math.floor(t),segments:n,segmentIndex:0}}function PI(e,t){if(!t||t.remaining<=0||t.segmentIndex>=t.segments.length)return TI(e);let n=``,r=0,i=0;for(;t.remaining>0&&t.segmentIndex`+TI(l)+``,r=s+l.length,i=s+o.length,t.remaining-=c,c>=a.length){t.segmentIndex++;continue}break}return n?n+TI(e.slice(r)):TI(e)}function FI(e,t,n){let r=n&&typeof n.formatJSON==`function`?n.formatJSON:e=>String(e),i=n&&typeof n.canShowConversation==`function`?n.canShowConversation:()=>!1,a=NI(n&&n.promptCacheHighlight),o=r(t);if(!o||o===`Not captured`)return TI(o);if(!i(e))return o.split(` -`).map(e=>PI(e,a)).join(` -`);let s=o.split(` -`),c=[],l=0;for(;lPI(e,a)).join(` -`);c.push(``+o+``),l=r+1;continue}c.push(PI(e,a)),l++}return c.join(` -`)}function II(e){let t=String(e||``).toLowerCase();return t===`system`||t===`developer`?{role:`system`,label:`System Prompt`,className:`role-system`}:t===`assistant`?{role:`assistant`,label:`Agent`,className:`role-assistant`}:t===`error`?{role:`error`,label:`Error`,className:`role-error`}:t===`function_call`?{role:`function_call`,label:`Function Call`,className:`role-function-call`}:t===`function_result`?{role:`function_result`,label:`Function Result`,className:`role-function-result`}:{role:`user`,label:`User`,className:`role-user`}}function LI(e,t,{timestamp:n,entryID:r,isAnchor:i,isAfterAnchor:a,index:o,toolCalls:s,functionName:c,functionCallID:l,promptCache:u,toolPromptCache:d}){let f=II(e),p=u&&Number.isFinite(Number(u.total))?Math.max(0,Number(u.total)):u===null?0:String(t||``).length,m=d&&Array.isArray(d.characters)?d.characters:qF(s).characters;return{uid:r+`-`+o,entryID:r,timestamp:n,text:t,role:f.role,roleLabel:f.label,roleClass:f.className,isAnchor:i,isAfterAnchor:a,toolCalls:Array.isArray(s)&&s.length>0?s:null,functionName:c||``,functionCallID:l||``,promptCacheRatio:0,_promptTextCharacters:p,_toolPromptCharacters:m}}function RI(e){return Array.isArray(e)?e.map(e=>{if(!e)return null;let t=e.function||e,n=``;return t.arguments===void 0?e.arguments===void 0?t.input===void 0?e.input!==void 0&&(n=e.input):n=t.input:n=e.arguments:n=t.arguments,{name:t.name||e.name||``,arguments:n,id:e.call_id||e.id||``}}).filter(Boolean):[]}function zI(e){return Array.isArray(e)?RI(e.filter(e=>e&&typeof e==`object`&&e.type===`tool_use`)):[]}function BI(e){return Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`tool_result`).map(e=>({id:e.tool_use_id||e.call_id||``,text:VF(e.content)})):[]}function VI(e,t,n){!t||!n||[t.call_id,t.id].forEach(t=>{t&&(e[t]=n)})}function HI(e,t,n){if(t&&Array.isArray(t.messages)&&t.messages.forEach(t=>{t&&[...Array.isArray(t.tool_calls)?t.tool_calls:[],...Array.isArray(t.content)?t.content.filter(e=>e&&e.type===`tool_use`):[]].forEach(t=>{t&&VI(e,t,(t.function||t).name||t.name||``)})}),t&&Array.isArray(t.input)&&t.input.forEach(t=>{!t||typeof t!=`object`||t.type!==`function_call`&&t.type!==`tool_use`||VI(e,t,t.name||``)}),n&&Array.isArray(n.choices)){let t=n.choices[0];t&&t.message&&Array.isArray(t.message.tool_calls)&&t.message.tool_calls.forEach(t=>{t&&VI(e,t,(t.function||t).name||t.name||``)})}n&&Array.isArray(n.output)&&n.output.forEach(t=>{!t||t.type!==`function_call`&&t.type!==`tool_use`||VI(e,t,t.name||``)}),n&&Array.isArray(n.content)&&n.content.forEach(t=>{!t||t.type!==`tool_use`||VI(e,t,t.name||``)})}function UI(e){return Array.isArray(e)?`[`+e.map(UI).join(`,`)+`]`:e&&typeof e==`object`?`{`+Object.keys(e).sort().map(t=>JSON.stringify(t)+`:`+UI(e[t])).join(`,`)+`}`:JSON.stringify(e)}function WI(e){if(!e||typeof e!=`object`)return null;let t=[];if(e.system!==void 0&&t.push({system:e.system}),e.instructions!==void 0&&t.push({instructions:e.instructions}),Array.isArray(e.messages))t.push(...e.messages);else if(Array.isArray(e.input)&&e.previous_response_id==null&&e.conversation==null)t.push(...e.input);else return null;return t.map(UI)}function GI(e){let t=e&&e.conversation;return typeof t==`string`?t.trim():t&&typeof t.id==`string`?t.id.trim():``}function KI(e,t){let n=new Date(e&&e.timestamp).getTime(),r=new Date(t&&t.timestamp).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r)return n-r;let i=String(e&&e.timestamp||``).localeCompare(String(t&&t.timestamp||``));if(i!==0)return i;let a=String(e&&e.id||``),o=String(t&&t.id||``);return ao)}function qI(e,t){if(!Array.isArray(e)||e.length===0)return{messages:[],entryIDs:[]};let n=[...e].sort(KI),r={};n.forEach(e=>{let t=e.data&&e.data.request_body?e.data.request_body:null,n=e.data&&e.data.response_body?e.data.response_body:null;HI(r,t,n)});let i=[],a=new Set,o=new Set,s=new Set,c=[],l=null,u=0,d=n.findIndex(e=>e.id===t),f=e=>JSON.stringify({role:e.role,text:e.text,toolCalls:e.toolCalls,functionName:e.functionName,functionCallID:e.functionCallID});return n.forEach((e,n)=>{let p=e.id===t,m=d>=0&&n>d,h=e.timestamp,g=e.data&&e.data.request_body?e.data.request_body:null,_=e.data&&e.data.response_body?e.data.response_body:null,v=i.length,y=(e,t)=>GF(e,t),b=e=>qF(e),x=(t,n,{toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s}={})=>LI(t,n,{timestamp:h,entryID:e.id,isAnchor:p,isAfterAnchor:m,index:++u,toolCalls:r,functionName:i,functionCallID:a,promptCache:o,toolPromptCache:s});if(g&&g.system!==void 0){let e=VF(g.system);e&&i.push(x(`system`,e,{promptCache:y(e,UF(g.system))}))}if(g&&g.instructions!==void 0){let e=VF(g.instructions);e&&i.push(x(`system`,e,{promptCache:y(e,UF(g.instructions))}))}g&&Array.isArray(g.messages)&&g.messages.forEach(e=>{if(!e)return;let t=(e.role||`user`).toLowerCase();if(t===`tool`){let t=VF(e.content),n=e.name||r[e.tool_call_id]||``;t&&i.push(x(`function_result`,t,{functionName:n,functionCallID:e.tool_call_id||``,promptCache:y(t,UF(e.content))}));return}if(t===`assistant`){let n=HF(e),r=[...RI(e.tool_calls),...zI(e.content)];if(n||r.length>0){let a=y(n,UF(e.content));i.push(x(t,n,{toolCalls:r,promptCache:a,toolPromptCache:b(r)}))}return}BI(e.content).forEach(e=>{e.text&&i.push(x(`function_result`,e.text,{functionName:r[e.id]||``,functionCallID:e.id,promptCache:y(e.text,[e.text])}))});let n=HF(e);n&&i.push(x(t,n,{promptCache:y(n,UF(e.content))}))}),g&&g.input!==void 0&&(Array.isArray(g.input)?g.input.forEach(e=>{if(!(!e||typeof e!=`object`)){if(e.type===`function_call_output`){let t=typeof e.output==`string`?e.output:VF(e.output);t&&i.push(x(`function_result`,t,{functionName:r[e.call_id]||e.name||``,functionCallID:e.call_id||``,promptCache:y(t,[t])}))}else if(e.type===`function_call`){let t=RI([e]);i.push(x(`function_call`,``,{toolCalls:t,toolPromptCache:b(t)}))}else if(e.role){let t=String(e.role).toLowerCase(),n=VF(e.content);n&&i.push(x(t,n,{promptCache:y(n,UF(e.content))}))}}}):YF(g.input).forEach(e=>{if(!e.text)return;let t=[];typeof g.input==`string`?t=[g.input]:g.input&&typeof g.input==`object`&&(t=UF(g.input.content),typeof g.input.text==`string`&&t.push(g.input.text)),i.push(x(e.role,e.text,{promptCache:y(e.text,t)}))}));let S=i.splice(v),C=S.map(f),w=WI(g),ee=w!==null,te=pI(e),ne=!!te&&a.has(te),re=String(g&&g.previous_response_id||``).trim(),ie=GI(g),ae=ne||!!re&&o.has(re)||!!ie&&s.has(ie);if(m){let e=ee&&l&&l.length>0&&l.every((e,t)=>w[t]===e);if(ee&&!e&&!ne||!ee&&!ae)return}p&&ee&&(l=[...w]);let oe=String(e.id||``).trim();p&&(a.clear(),o.clear(),s.clear()),oe&&(p||m)&&a.add(oe),ie&&s.add(ie);let se=0;for(;se0;){let t=c.slice(-e),n=C.slice(0,e);if(t.every((e,t)=>e===n[t]))break;e--}i.push(...S.slice(e)),c.push(...C.slice(e))}if(g&&i.splice(0,i.length,...JF(i,WF(e))),_&&Array.isArray(_.choices)){let e=_.choices[0];if(e&&e.message){let t=(e.message.role||`assistant`).toLowerCase(),n=HF(e.message),r=RI(e.message.tool_calls);if(n||r.length>0){let e=x(t,n,{toolCalls:r});i.push(e),c.push(f(e))}}}if(_&&Array.isArray(_.output)&&_.output.forEach(e=>{if(!e)return;if(e.type===`function_call`){let t=x(`function_call`,``,{toolCalls:RI([e])});i.push(t),c.push(f(t));return}let t=(e.role||`assistant`).toLowerCase(),n=XF(e);if(n){let e=x(t,n);i.push(e),c.push(f(e))}}),_&&_.content!==void 0&&!Array.isArray(_.choices)&&!Array.isArray(_.output)){let e=String(_.role||`assistant`).toLowerCase(),t=VF(_.content),n=zI(_.content);if(t||n.length>0){let r=x(e,t,{toolCalls:n});i.push(r),c.push(f(r))}}let ce=$F(e);ce&&i.push(x(`error`,ce));let le=String(_&&_.id||``).trim();le&&o.add(le)}),{messages:i,entryIDs:[...a]}}function JI(e){return e.role===`function_call`?(e.toolCalls||[]).map(function(e){return e.name+`(`+YI(e)+`)`}).join(` - -`):e.text||``}function YI(e){let t=e&&e.arguments!==void 0?e.arguments:``;if(typeof t!=`string`)try{return JSON.stringify(t,null,2)}catch{return String(t)}try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var XI=600*1e3,ZI=15*1e3,QI=250,$I=class{#e=k(!1);get conversationOpen(){return I(this.#e)}set conversationOpen(e){A(this.#e,e,!0)}#t=k(!1);get conversationLoading(){return I(this.#t)}set conversationLoading(e){A(this.#t,e,!0)}#n=k(``);get conversationError(){return I(this.#n)}set conversationError(e){A(this.#n,e,!0)}#r=k(``);get conversationAnchorID(){return I(this.#r)}set conversationAnchorID(e){A(this.#r,e,!0)}#i=k(j([]));get conversationEntryIDs(){return I(this.#i)}set conversationEntryIDs(e){A(this.#i,e,!0)}#a=k(``);get conversationSessionID(){return I(this.#a)}set conversationSessionID(e){A(this.#a,e,!0)}#o=k(!1);get conversationTruncated(){return I(this.#o)}set conversationTruncated(e){A(this.#o,e,!0)}#s=k(!1);get conversationFollowLatest(){return I(this.#s)}set conversationFollowLatest(e){A(this.#s,e,!0)}#c=k(``);get conversationOpenedFromID(){return I(this.#c)}set conversationOpenedFromID(e){A(this.#c,e,!0)}#l=k(``);get followUpText(){return I(this.#l)}set followUpText(e){A(this.#l,e,!0)}#u=k(!1);get followUpSending(){return I(this.#u)}set followUpSending(e){A(this.#u,e,!0)}#d=k(``);get followUpError(){return I(this.#d)}set followUpError(e){A(this.#d,e,!0)}followUpRequestID=``;followUpAbort=null;conversationRequestToken=0;conversationReturnFocusEl=null;bodyPointerStart=null;#f=k(null);get conversationDialogEl(){return I(this.#f)}set conversationDialogEl(e){A(this.#f,e,!0)}#p=k(null);get conversationCloseBtnEl(){return I(this.#p)}set conversationCloseBtnEl(e){A(this.#p,e,!0)}#m=k(null);get conversationThreadEl(){return I(this.#m)}set conversationThreadEl(e){A(this.#m,e,!0)}get conversationEntries(){return(this.conversationEntryIDs||[]).map(e=>MC.auditRecord(e)).filter(Boolean)}#h=O(()=>qI(this.conversationEntries,this.conversationAnchorID));get conversationView(){return I(this.#h)}set conversationView(e){A(this.#h,e)}get conversationMessages(){return this.conversationView.messages}get conversationBranchEntryIDs(){return this.conversationView.entryIDs}_setConversationEntryIDs(e){this.conversationEntryIDs=[...new Set((Array.isArray(e)?e:[]).filter(Boolean))],MC.pinAuditRecords(this.conversationEntryIDs)}canShowConversation(e){return xI(e)}startBodyInteraction(e){this.bodyPointerStart={x:e.clientX,y:e.clientY}}_isBodyDrag(e){if(!this.bodyPointerStart)return!1;let t=Math.abs(e.clientX-this.bodyPointerStart.x),n=Math.abs(e.clientY-this.bodyPointerStart.y);return t>4||n>4}_hasActiveSelection(){let e=window.getSelection?window.getSelection():null;return!e||e.isCollapsed?!1:String(e.toString()||``).trim().length>0}handleBodyConversationClick(e,t){let n=this._isBodyDrag(e);if(this.bodyPointerStart=null,n||this._hasActiveSelection()||!this.canShowConversation(t))return;let r=e.target&&e.target.closest?e.target.closest(`[data-conversation-trigger="1"]`):null;r&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,r))}handleErrorConversationClick(e,t){let n=this._isBodyDrag(e);this.bodyPointerStart=null,!n&&(this._hasActiveSelection()||this.canShowConversation(t)&&(e.preventDefault(),e.stopPropagation(),this.openConversation(t,e.currentTarget)))}formatJSON(e){return ac(e)}renderBodyWithConversationHighlights(e,t,n){return FI(e,t,{formatJSON:e=>this.formatJSON(e),canShowConversation:e=>this.canShowConversation(e),promptCacheHighlight:n&&n.promptCacheHighlight})}async openConversation(e,t){if(!e||!e.id||!this.canShowConversation(e))return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null;t instanceof HTMLElement?this.conversationReturnFocusEl=t:n&&n!==document.body&&(this.conversationReturnFocusEl=n);let r=++this.conversationRequestToken;if(this.conversationOpen=!0,this.conversationError=``,this.conversationAnchorID=e.id,this.conversationOpenedFromID=e.id,this.conversationSessionID=String(e.session_id||``).trim(),this._setConversationEntryIDs([]),this.conversationTruncated=!1,this.conversationFollowLatest=!1,this.followUpText=``,this.followUpError=``,this.followUpRequestID=``,requestAnimationFrame(()=>this._focusConversationDrawer()),this._conversationEntryLivePending(e)){this.conversationFollowLatest=!0,this.conversationLoading=!1,this._addConversationRecord(MC.upsertAuditRecord(e,`conversation.live`));return}this.conversationLoading=!0,await this.fetchConversation(e.id,r,!0,!0)}_conversationEntryLivePending(e){return typeof MC.auditEntryLiveDetailPending==`function`&&MC.auditEntryLiveDetailPending(e)}_applyConversationView(){let e=this.conversationEntries,t=qI(e,this.conversationAnchorID);if(this.conversationFollowLatest){let n=gI(e,t.entryIDs);n&&n.id&&String(n.id)!==this.conversationAnchorID&&(this.conversationAnchorID=String(n.id))}}handleAuditRecordChange(e,t){if(!this.conversationOpen||!e)return;let n=String(e.id||``).trim(),r=fI(this.conversationEntries,this.conversationAnchorID,this.conversationSessionID,this.followUpRequestID,e);if(r.accepted&&(this.followUpRequestID=r.followUpRequestID,n&&r.submittedChild&&(this.conversationAnchorID=n,this.conversationFollowLatest=!0),this._addConversationRecord(e),vI(String(t||e._live_state||``).trim(),n,this.conversationAnchorID))){this.conversationMessages.length===0&&(this.conversationLoading=!0);let e=++this.conversationRequestToken;this.fetchConversation(n,e,!1)}}_addConversationRecord(e){let t=TC(e);t&&!this.conversationEntryIDs.includes(t)&&this._setConversationEntryIDs([...this.conversationEntryIDs,t]),!this.conversationSessionID&&e.session_id&&(this.conversationSessionID=String(e.session_id).trim()),this._applyConversationView(),this.conversationFollowLatest&&this._scheduleLatestScroll()}conversationLiveWaiting(){if(!this.conversationOpen)return!1;let e=new Set(this.conversationBranchEntryIDs||[]);return(this.conversationEntries||[]).some(t=>e.has(String(t&&t.id||``))&&t._live&&(typeof MC.liveAuditStateSettled!=`function`||!MC.liveAuditStateSettled(t._live_state)))}conversationLiveStatusText(){return(this.conversationMessages||[]).length>0?`Model is responding…`:`Waiting for request data…`}closeConversation(){this.followUpAbort&&this.followUpAbort.abort(),this.conversationOpen=!1,this.conversationRequestToken++,this.conversationSessionID=``,this._setConversationEntryIDs([]),this.conversationFollowLatest=!1,this.conversationOpenedFromID=``,this.followUpRequestID=``,this.followUpSending=!1;let e=this.conversationReturnFocusEl;this.conversationReturnFocusEl=null,e&&typeof e.focus==`function`&&document.contains(e)&&requestAnimationFrame(()=>e.focus())}_focusConversationDrawer(){if(!this.conversationOpen)return;let e=this.conversationCloseBtnEl;if(e&&typeof e.focus==`function`){e.focus();return}let t=this.conversationDialogEl;t&&typeof t.focus==`function`&&t.focus()}async fetchConversation(e,t,n=!0,r=!1){try{let i=await _s(`/admin/audit/conversation?`+(`log_id=`+encodeURIComponent(e)+`&limit=120`),{label:`audit conversation`});if(t!==this.conversationRequestToken||i.stale)return;if(!i.ok){this.conversationError=`Unable to load interactions.`;return}let a=i.data||{},o=a.anchor_id||e,s=Array.isArray(a.entries)?a.entries:[],c=MC.upsertAuditRecords(s,`conversation.hydrated`),l=yI(this.conversationEntryIDs,c);l.length>this.conversationEntryIDs.length&&this._setConversationEntryIDs(l),r&&(this.conversationFollowLatest=_I(c,o)),this.conversationAnchorID=o;let u=this.conversationEntries.find(e=>e.id===this.conversationAnchorID);u&&u.session_id&&(this.conversationSessionID=String(u.session_id).trim()),this.conversationTruncated=!!a.truncated,this._applyConversationView(),this.conversationFollowLatest?this._scheduleLatestScroll():n&&this._scheduleAnchorScroll()}catch(e){if(t!==this.conversationRequestToken)return;console.error(`Failed to fetch audit conversation:`,e),this.conversationError=`Failed to load interactions.`}finally{t===this.conversationRequestToken&&(this.conversationLoading=!1)}}selectedConversationEntry(){return mI(this.conversationEntries,this.conversationAnchorID)}followUpKind(){let e=this.selectedConversationEntry();return sI(e)?iI(e.path):``}canSendFollowUp(){return!!this.followUpKind()&&!!String(this.followUpText||``).trim()&&!this.followUpSending&&!this.conversationLiveWaiting()}async sendFollowUp(){if(!this.canSendFollowUp())return;let e=this.selectedConversationEntry(),t=cI(e,this.followUpText);if(!e||!t)return;let n=this.conversationAnchorID,r=tL(),i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},XI);this.followUpSending=!0,this.followUpError=``,this.followUpRequestID=r,this.followUpAbort=i;try{let a=uI(e,n,r),o=await hs(e.path,{method:`POST`,headers:a,body:JSON.stringify(t),signal:i.signal}),s=String(o.headers.get(`X-Request-ID`)||``).trim();if(s&&this.followUpRequestID&&(this.followUpRequestID=s),!o.ok){let e=`Unable to send message.`;try{let t=await o.json();e=t&&t.error&&t.error.message||e}catch{}this.followUpError=e,(this.followUpRequestID===r||this.followUpRequestID===s)&&(this.followUpRequestID=``);return}if(this.followUpText=``,await eL(o),!MC.liveLogsStreaming&&this.conversationOpen){let e=++this.conversationRequestToken;await this._selectPersistedFollowUp(n,this.followUpRequestID,e,i.signal)}}catch(e){ys(e)||i.signal.aborted?a&&this.conversationOpen&&(this.followUpError=`The request timed out.`):(console.error(`Failed to send interaction follow-up:`,e),this.followUpError=`Failed to send message.`)}finally{clearTimeout(o),this.followUpAbort===i&&(this.followUpAbort=null,this.followUpSending=!1)}}async _selectPersistedFollowUp(e,t,n,r){let i=Date.now()+ZI;for(;this.conversationOpen&&n===this.conversationRequestToken&&Date.now(){let e=this.conversationThreadEl;if(!e)return;let t=e.querySelectorAll(`[data-conversation-anchor="true"]`),n=t[t.length-1];n&&typeof n.scrollIntoView==`function`&&n.scrollIntoView({block:`center`})})}_scheduleLatestScroll(){requestAnimationFrame(()=>{let e=this.conversationThreadEl;if(!e)return;let t=e.lastElementChild;t&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`end`})})}};async function eL(e){let t=e&&e.body&&typeof e.body.getReader==`function`?e.body.getReader():null;if(!t){await e.text();return}for(;!(await t.read()).done;);}function tL(){return globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`?globalThis.crypto.randomUUID():`dashboard-`+Date.now().toString(36)+`-`+Math.random().toString(36).slice(2)}function nL(e,t){return new Promise((n,r)=>{let i,a=()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))};if(i=setTimeout(()=>{t&&t.removeEventListener(`abort`,a),n()},e),t){if(t.aborted){a();return}t.addEventListener(`abort`,a,{once:!0})}})}var rL=new $I,iL=0;Mn(()=>{An(()=>{let e=DC(MC.auditRecordChanges,iL);e.length!==0&&(iL=Number(e[e.length-1].version||0),Er(()=>{e.forEach(e=>{if(!OC(e))return;let t=MC.auditRecord(e.key);rL.handleAuditRecordChange(t,e.eventType)})}))})});var aL=R(``),oL=R(` `),sL=R(``),cL=R(`
                        `);function lL(e,t){E(t,!0);let n=ya(t,`thread`,3,null),r=ya(t,`expanded`,3,!1),i=ya(t,`onactivate`,3,null),a=O(()=>ds.formatTimestamp(t.entry.timestamp)),o=O(()=>I(a)===`-`?I(a):I(a).slice(I(a).lastIndexOf(` `)+1)),s=O(()=>rL.conversationOpen&&String(rL.conversationAnchorID||``)===String(t.entry.id||``));function c(e){e.preventDefault(),i()&&i()()}function l(e){e.stopPropagation(),e.preventDefault(),n().ontoggle()}function u(e){if(e.stopPropagation(),e.preventDefault(),I(s)){rL.closeConversation();return}rL.openConversation(t.entry,e.currentTarget)}var d=cL();let f;var p=M(d),m=M(p),h=e=>{var t=aL(),r=M(t);{let e=O(()=>n().expanded?Ha:Wa);G(r,{get icon(){return I(e)},class:`audit-thread-expander-svg`})}var i=P(r,2),a=M(i,!0);T(i),T(t),F(()=>{W(t,`aria-expanded`,n().expanded),W(t,`title`,`Session with `+n().count+` requests`),W(t,`aria-label`,`Session with `+n().count+` requests, `+(n().expanded?`collapse`:`expand`)),B(a,n().count)}),L(`click`,t,l),z(e,t)};V(m,e=>{n()&&e(h)});var g=P(m,2),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=M(y,!0);T(y),T(g);var x=P(g,2),S=e=>{var n=oL(),r=M(n,!0);T(n),F(e=>B(r,e),[()=>bc(t.entry)]),z(e,n)};V(x,e=>{(t.entry.requested_model||t.entry.model)&&e(S)});var C=P(x,2),w=M(C,!0);T(C),T(p);var ee=P(p,2),te=M(ee);RF(te,{get entry(){return t.entry}});var ne=P(te,2),re=M(ne),ie=M(re,!0);T(re);var ae=P(re,2),oe=M(ae,!0);T(ae),T(ne);var se=P(ne,2),ce=M(se,!0);T(se);var le=P(se,2),ue=e=>{var t=sL();let n;var r=M(t);{let e=O(()=>I(s)?Ua:Wa);G(r,{get icon(){return I(e)},class:`audit-conversation-trigger-svg`})}T(t),F(()=>{n=U(t,1,`audit-conversation-trigger svelte-17mysgz`,null,n,{"audit-conversation-trigger-active":I(s)}),W(t,`title`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-label`,I(s)?`Close interactions`:`Open interactions`),W(t,`aria-pressed`,I(s))}),L(`click`,t,u),z(e,t)},de=O(()=>rL.canShowConversation(t.entry));V(le,e=>{I(de)&&e(ue)}),T(ee),T(d),F((e,n,i,s)=>{f=U(d,1,`audit-entry-summary svelte-17mysgz`,null,f,e),W(d,`aria-expanded`,r()),U(g,1,`audit-status-badge audit-request-badge ${n??``}`,`svelte-17mysgz`),W(g,`title`,`Status `+(t.entry.status_code||`-`)+` · `+(t.entry.method||`-`)),W(g,`aria-label`,(t.entry.status_code||`-`)+` `+(t.entry.method||`-`)),B(v,t.entry.status_code||`-`),B(b,t.entry.method||`-`),B(w,t.entry.path||`-`),W(ne,`title`,i),W(ne,`aria-label`,I(a)),B(ie,I(a)),B(oe,I(o)),B(ce,s)},[()=>({"audit-entry-summary-live-in-progress":UP(t.entry),"audit-entry-summary-has-interactions":rL.canShowConversation(t.entry)}),()=>HP(t.entry.status_code),()=>mc(t.entry.timestamp),()=>VP(t.entry.duration_ns)]),L(`click`,d,c),z(e,d),D()}Hr([`click`]);var uL=R(``);function dL(e,t){E(t,!0);let n=ya(t,`label`,3,`Copy`),r=ya(t,`copiedLabel`,3,`Copied`),i=ya(t,`errorLabel`,3,``),a=ya(t,`class`,3,`btn`),o=O(()=>t.state.error&&i()?i():t.state.copied?r():n());var s=uL();let c;var l=M(s),u=e=>{G(e,{get icon(){return Ka},width:`14`,height:`14`,"stroke-width":`2.5`})},d=e=>{G(e,{get icon(){return Ya},width:`14`,height:`14`})};V(l,e=>{t.state.copied?e(u):e(d,-1)});var f=P(l,2),p=M(f,!0);T(f),T(s),F(()=>{c=U(s,1,Fi([`copy-feedback-btn`,a()]),null,c,{"copy-feedback-btn-copied":t.state.copied}),B(p,I(o))}),L(`click`,s,e=>{e.preventDefault(),t.onclick?.(e)}),z(e,s),D()}Hr([`click`]);var fL=R(`
                        Error Message
                         
                        `),pL=R(`
                         
                        `),mL=R(` `),hL=R(` streaming`),gL=R(`
                        Body
                        `),_L=R(`

                        `),vL=R(`

                        `),yL=R(`

                        `),bL=R(`
                        `);function xL(e,t){E(t,!0);let n=_M({logPrefix:`Failed to copy audit payload:`}),r=_M({logPrefix:`Failed to copy audit payload:`}),i=O(()=>t.pane&&t.pane.showHeaders?ac(t.pane.headers):``),a=O(()=>!t.pane||!t.pane.showBody?``:EI(t.pane.body)?jI(t.pane.body):rL.renderBodyWithConversationHighlights(t.pane.entry,t.pane.body,{promptCacheHighlight:t.pane.promptCacheHighlight})),o=O(()=>!!(t.pane&&rL.canShowConversation(t.pane.entry)));function s(e){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),rL.handleErrorConversationClick(e,t.pane.entry))}var c=bL();let l;var u=M(c),d=e=>{var n=fL(),r=P(M(n),2);let i;var a=M(r,!0);T(r),T(n),F(()=>{i=U(r,1,`audit-json audit-pane-error-message svelte-1h5puht`,null,i,{"audit-pane-clickable-preview":I(o)}),W(r,`role`,I(o)?`button`:null),W(r,`tabindex`,I(o)?0:null),B(a,t.pane.errorMessage)}),L(`mousedown`,r,e=>rL.startBodyInteraction(e)),L(`keydown`,r,s),L(`click`,r,e=>rL.handleErrorConversationClick(e,t.pane.entry)),z(e,n)};V(u,e=>{t.pane.showErrorMessage&&e(d)});var f=P(u,2),p=e=>{var n=pL(),a=M(n),o=M(a),s=M(o,!0);T(o),dL(P(o,2),{get state(){return r},label:`Copy Headers`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>r.copy(t.pane.copyHeaders,ac)}),T(a);var c=P(a,2),l=M(c,!0);T(c),T(n),F(()=>{B(s,t.pane.headersTitle||`Headers`),B(l,I(i))}),z(e,n)};V(f,e=>{t.pane.showHeaders&&e(p)});var m=P(f,2),h=e=>{var r=gL(),i=M(r),o=M(i),s=P(M(o),2),c=e=>{var n=mL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.bodyCacheRatioLabel)),z(e,n)};V(s,e=>{t.pane.bodyCacheRatioLabel&&e(c)});var l=P(s,2),u=e=>{z(e,hL())};V(l,e=>{t.pane.streaming&&e(u)}),T(o),dL(P(o,2),{get state(){return n},label:`Copy Body`,errorLabel:`Copy failed`,class:`audit-copy-btn`,onclick:()=>n.copy(t.pane.copyBody,ac)}),T(i);var d=P(i,2);hi(d,()=>I(a),!0),T(d),T(r),L(`mousedown`,d,e=>rL.startBodyInteraction(e)),L(`click`,d,e=>rL.handleBodyConversationClick(e,t.pane.entry)),z(e,r)};V(m,e=>{t.pane.showBody&&e(h)});var g=P(m,2),_=e=>{var n=_L(),r=M(n,!0);T(n),F(()=>B(r,t.pane.emptyMessage)),z(e,n)};V(g,e=>{t.pane.showEmpty&&e(_)});var v=P(g,2),y=e=>{var n=vL(),r=P(M(n),2),i=M(r,!0);T(r),T(n),F(()=>B(i,t.pane.pendingMessage)),z(e,n)};V(v,e=>{t.pane.showPending&&e(y)});var b=P(v,2),x=e=>{var n=yL(),r=M(n,!0);T(n),F(()=>B(r,t.pane.tooLargeMessage)),z(e,n)};V(b,e=>{t.pane.showTooLarge&&e(x)}),T(c),F(()=>l=U(c,1,`audit-pane svelte-1h5puht`,null,l,{"audit-pane-split":t.pane&&t.pane.layout===`split`,"audit-pane-split-single":t.pane&&t.pane.layout===`split`&&!(t.pane.showHeaders&&t.pane.showBody)})),z(e,c),D()}Hr([`mousedown`,`keydown`,`click`]);var SL=R(` `),CL=R(` `),wL=R(` `),TL=R(` `),EL=R(``),DL=R(`
                        `),OL=R(`
                        `);function kL(e,t){E(t,!0);let n=ya(t,`panes`,19,()=>[]),r=k(null),i=O(()=>xF(I(r),t.entry,n())),a=e=>`audit-tab-`+t.entry.id+`-`+e,o=e=>`audit-tabpanel-`+t.entry.id+`-`+e;function s(e,t){let i=n().map(e=>e.id),a=SF(e.key,i,t);a!=null&&(e.preventDefault(),((e.currentTarget?.closest?.(`.audit-pane-tablist`))?.querySelectorAll(`.audit-pane-tab`)[i.indexOf(a)])?.focus?.(),A(r,a,!0))}var c=OL(),l=M(c);H(l,21,n,e=>e.id,(e,t)=>{var n=EL();let c;var l=M(n),u=M(l),d=e=>{G(e,{get icon(){return Pa}})},f=e=>{G(e,{get icon(){return Na}})};V(u,e=>{I(t).pane.direction===`request`?e(d):I(t).pane.direction===`response`&&e(f,1)}),T(l);var p=P(l,2),m=M(p,!0);T(p);var h=P(p,2),g=e=>{var n=SL(),r=M(n);T(n),F(()=>B(r,`#${I(t).pane.seq??``}`)),z(e,n)};V(h,e=>{I(t).pane.seq&&e(g)});var _=P(h,2),v=e=>{var n=CL(),r=M(n,!0);T(n),F(()=>{U(n,1,`provider-badge audit-pane-kind audit-pane-kind-${I(t).pane.kind??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.kind)}),z(e,n)};V(_,e=>{I(t).pane.kind&&e(v)});var y=P(_,2);H(y,17,()=>I(t).pane.noChangeSteps||[],e=>e.id,(e,t)=>{var n=wL(),r=M(n,!0);T(n),F(()=>{W(n,`title`,I(t).title),B(r,I(t).label)}),z(e,n)});var b=P(y,2),x=e=>{var n=TL(),r=M(n,!0);T(n),F(()=>B(r,I(t).pane.savingsLabel)),z(e,n)};V(b,e=>{I(t).pane.savingsLabel&&e(x)});var S=P(b,2),C=e=>{var n=CL(),r=M(n,!0);T(n),F(e=>{U(n,1,`audit-status-badge ${e??``}`,`svelte-1bc5vi5`),B(r,I(t).pane.statusCode)},[()=>HP(I(t).pane.statusCode)]),z(e,n)};V(S,e=>{I(t).pane.statusCode&&e(C)}),T(n),F((e,r)=>{c=U(n,1,`audit-pane-tab svelte-1bc5vi5`,null,c,{"audit-pane-tab-active":I(i)===I(t).id}),W(n,`aria-selected`,I(i)===I(t).id),W(n,`id`,e),W(n,`aria-controls`,r),W(n,`tabindex`,I(i)===I(t).id?0:-1),U(l,1,Fi([`audit-pane-icon`,I(t).pane.direction&&`audit-pane-icon-${I(t).pane.direction}`]),`svelte-1bc5vi5`),B(m,I(t).pane.title)},[()=>a(I(t).id),()=>o(I(t).id)]),L(`keydown`,n,e=>s(e,I(t).id)),L(`click`,n,()=>A(r,I(t).id,!0)),z(e,n)}),T(l),H(P(l,2),17,n,e=>e.id,(e,t)=>{var n=DL();let r;xL(M(n),{get pane(){return I(t).pane}}),T(n),F((e,a)=>{W(n,`id`,e),W(n,`aria-labelledby`,a),r=Hi(n,``,r,{display:I(i)===I(t).id?null:`none`})},[()=>o(I(t).id),()=>a(I(t).id)]),z(e,n)}),T(c),z(e,c),D()}Hr([`keydown`,`click`]);var AL=R(`
                        `),jL=R(`
                        `);function ML(e,t){E(t,!0);let n=ya(t,`thread`,3,null),r=O(()=>TF.isAuditEntryExpanded(t.entry)),i=O(()=>rL.conversationOpen&&String(rL.conversationAnchorID||``)===String(t.entry.id||``)),a=O(()=>I(r)?yF(t.entry,ZF):[]),o=O(()=>I(r)?mN(t.entry,lP.auditEntryWorkflow(t.entry),lP.workflowFeatureCaps()):null);function s(){TF.toggleAuditEntryExpanded(t.entry)}var c=jL();let l;var u=M(c);lL(u,{get entry(){return t.entry},get thread(){return n()},get expanded(){return I(r)},onactivate:s});var d=P(u,2),f=e=>{var n=AL(),r=M(n),i=e=>{AM(e,{get chart(){return I(o)}})};V(r,e=>{I(o)&&e(i)});var s=P(r,2);kL(s,{get entry(){return t.entry},get panes(){return I(a)}}),FF(P(s,2),{get entry(){return t.entry}}),T(n),ki(3,n,()=>qs,()=>({y:-6,duration:sP(150)})),z(e,n)};V(d,e=>{I(r)&&e(f)}),T(c),F(()=>l=U(c,1,`audit-entry svelte-cmjgwr`,null,l,{"audit-entry-interactions-open":I(i)})),z(e,c),D()}var NL=R(`
                        `),PL=R(`
                        `),FL=R(`

                        `),IL=R(`
                        `),LL=R(`
                        `);function RL(e,t){E(t,!0);let n=O(()=>TP(t.entry)),r=O(()=>TF.isThreadExpanded(I(n))),i=O(()=>TF.threadChildren(I(n))),a=O(()=>I(i)&&!I(i).loading&&Number(I(i).total||0)>I(i).entries.length+1);var o=Qr(),s=N(o),c=e=>{ML(e,{get entry(){return t.entry}})},l=O(()=>!DP(t.entry)),u=e=>{var n=LL(),o=M(n);{let e=O(()=>({count:EP(t.entry),expanded:I(r),ontoggle:()=>TF.toggleThread(t.entry)}));ML(o,{get entry(){return t.entry},get thread(){return I(e)}})}var s=P(o,2),c=e=>{var t=IL(),n=M(t),r=e=>{var t=NL();SS(M(t),{size:14,label:`Loading session requests`}),T(t),z(e,t)};V(n,e=>{I(i)&&I(i).loading&&e(r)});var o=P(n,2);H(o,17,()=>I(i)&&I(i).entries||[],e=>e.id,(e,t)=>{var n=PL();ML(M(n),{get entry(){return I(t)}}),T(n),z(e,n)});var s=P(o,2),c=e=>{var t=FL(),n=M(t);T(t),F(()=>B(n,`Showing the latest ${I(i).entries.length+1} of ${I(i).total??``} - requests in this session.`)),z(e,t)};V(s,e=>{I(a)&&e(c)}),T(t),ki(3,t,()=>Js,()=>({duration:sP(150)})),z(e,t)};V(s,e=>{I(r)&&e(c)}),T(n),z(e,n)};V(s,e=>{I(l)?e(c):e(u,-1)}),z(e,o),D()}var zL=R(`

                        .

                        `),BL=R(`
                        Audit logging is off. Live entries are temporary and disappear after - refresh. Set LOGGING_ENABLED=true to persist them.
                        `),VL=R(`

                        `),HL=R(`
                        `),UL=R(`
                        `),WL=R(`
                        `),GL=R(`
                        `),KL=R(`
                        `);function qL(e,t){E(t,!0);let n=O(()=>Ss.config&&Ss.config.LOGGING_RETENTION_DAYS);An(()=>{if(K.refreshTick,Jo.page===`audit-logs`)return Er(()=>r())});function r(){let e=!1;return(async()=>{try{await Ss.ensureLoaded()}finally{await TF.fetchAuditLog(!0),!e&&Ss.liveLogsVisible()&&MC.ensureLiveLogs()}})(),()=>{e=!0,MC.stopLiveLogs()}}var i=KL(),a=M(i),o=M(a),s=P(M(o),2),c=e=>{qS(e,{copyId:`audit-retention-help-copy`,label:`retention help`,text:`If you want to change the retention period, set LOGGING_RETENTION_DAYS (env var) or logging.retention_days (config.yaml) and restart the gateway. Default is 30 days; 0 keeps audit logs forever.`,title:e=>{var t=zL(),r=M(t,!0),i=P(r),a=M(i,!0);T(i),Ue(),T(t),F((e,t)=>{B(r,e),B(a,t)},[()=>xP(I(n)),()=>SP(I(n))]),z(e,t)},$$slots:{title:!0}})},l=O(()=>bP(I(n)));V(s,e=>{I(l)&&e(c)}),T(o),T(a);var u=P(a,2);tl(M(u),{onchange:()=>TF.fetchAuditLog(!0)}),T(u);var d=P(u,2);Fc(d,{});var f=P(d,2),p=e=>{z(e,BL())},m=O(()=>Ss.loaded&&!Ss.auditVisible()&&!K.needsAuth);V(f,e=>{I(m)&&e(p)});var h=P(f,2),g=M(h);DF(g,{});var _=P(g,2),v=M(_),y=M(v),b=e=>{var t=VL(),n=M(t);T(t),F(e=>B(n,`Showing ${TF.auditLog.offset+1}-${e??``} of ${TF.auditLog.total??``} - ${TF.auditGroupSessions?`sessions`:`logs`}`),[()=>Math.min(TF.auditLog.offset+TF.auditLog.limit,TF.auditLog.total)]),z(e,t)};V(y,e=>{TF.auditLog.total>0&&e(b)});var x=P(y,2),S=M(x);na(S),Ue(2),T(x),T(v),MF(P(v,2),{}),T(_);var C=P(_,2),w=e=>{var t=HL();SS(M(t),{size:18,label:`Loading audit logs`}),T(t),z(e,t)},ee=e=>{var t=WL();H(t,29,()=>TF.auditLog.entries,e=>e.id,(e,t)=>{var n=UL(),r=M(n),i=e=>{RL(e,{get entry(){return I(t)}})},a=e=>{ML(e,{get entry(){return I(t)}})};V(r,e=>{TF.auditGroupSessions?e(i):e(a,-1)}),T(n),Oi(n,()=>rP,()=>({duration:sP(150)})),ki(1,n,()=>cP,()=>({live:I(t)._live})),z(e,n)}),T(t),z(e,t)};V(C,e=>{TF.loading&&TF.auditLog.entries.length===0?e(w):TF.auditLog.entries.length>0&&e(ee,1)});var te=P(C,2),ne=e=>{var t=GL();TS(M(t),{}),T(t),z(e,t)};V(te,e=>{TF.auditLog.entries.length===0&&!TF.loading&&!K.needsAuth&&e(ne)}),Jw(P(te,2),{get total(){return TF.auditLog.total},get offset(){return TF.auditLog.offset},get limit(){return TF.auditLog.limit},onprev:()=>TF.auditLogPrevPage(),onnext:()=>TF.auditLogNextPage()}),T(h),T(i),F(()=>ia(S,TF.auditGroupSessions)),L(`change`,S,()=>TF.toggleAuditGroupSessions()),z(e,i),D()}Hr([`change`]);function JL(e){try{let t=JSON.parse(JSON.stringify(e||{}));return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function YL(e){return Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(e=>e):e==null?[]:String(e).split(`,`).map(e=>e.trim()).filter(e=>e)}function XL(e,t){let n=String(t||``).trim();return(e||[]).find(e=>String(e&&e.type||``).trim()===n)||null}function ZL(e){return Array.isArray(e)&&e.length>0&&String(e[0].type||``).trim()||`system_prompt`}function QL(e,t){let n=String(t||``).trim();return n&&XL(e,n)?n:ZL(e)}function $L(e,t){let n=XL(e,t);return!n||!n.defaults?{}:JL(n.defaults)}function eR(e,t,n){return{...$L(e,n),...JL(t)}}function tR(e,t){let n=QL(e,t);return{name:``,type:n,description:``,user_path:``,config:$L(e,n)}}function nR(e,t){if(!t)return e||[];let n=String(t).toLowerCase();return(e||[]).filter(e=>[e.name,e.type,e.user_path,e.description,e.summary].some(e=>String(e||``).toLowerCase().includes(n)))}function rR(e,t){let n=XL(e,t);return n&&n.label?n.label:t||`Unknown`}function iR(e,t){let n=XL(e,t);return Array.isArray(n&&n.fields)?n.fields:[]}function aR(e,t){if(!t||!e)return t&&t.input===`checkboxes`?[]:``;let n=e[t.key];return n==null?t.input===`checkboxes`?[]:``:t.input===`checkboxes`?YL(n):n}function oR(e,t,n){if(!t)return e;let r=JL(e);if(t.input===`number`){let e=String(n||``).trim();if(e===``)delete r[t.key];else{let n=Number(e);r[t.key]=Number.isFinite(n)?n:e}}else t.input===`checkboxes`?r[t.key]=YL(n):r[t.key]=n;return r}function sR(e,t,n){return aR(e,t).includes(String(n||``).trim())}function cR(e,t,n,r){let i=YL(aR(e,t)),a=String(n||``).trim();return a?oR(e,t,r?Array.from(new Set([...i,a])):i.filter(e=>e!==a)):e}function lR(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),description:String(e&&e.description||``).trim()||void 0,user_path:String(e&&e.user_path||``).trim()||void 0,config:JL(e&&e.config)}}var uR=new class{#e=k(j([]));get guardrails(){return I(this.#e)}set guardrails(e){A(this.#e,e,!0)}#t=k(j([]));get types(){return I(this.#t)}set types(e){A(this.#t,e,!0)}#n=k(!0);get available(){return I(this.#n)}set available(e){A(this.#n,e,!0)}#r=k(!1);get loading(){return I(this.#r)}set loading(e){A(this.#r,e,!0)}#i=k(!1);get typesLoading(){return I(this.#i)}set typesLoading(e){A(this.#i,e,!0)}#a=k(``);get error(){return I(this.#a)}set error(e){A(this.#a,e,!0)}#o=k(``);get filter(){return I(this.#o)}set filter(e){A(this.#o,e,!0)}#s=k(!1);get formOpen(){return I(this.#s)}set formOpen(e){A(this.#s,e,!0)}#c=k(!1);get formSubmitting(){return I(this.#c)}set formSubmitting(e){A(this.#c,e,!0)}#l=k(``);get deletingName(){return I(this.#l)}set deletingName(e){A(this.#l,e,!0)}#u=k(`create`);get formMode(){return I(this.#u)}set formMode(e){A(this.#u,e,!0)}#d=k(``);get formOriginalName(){return I(this.#d)}set formOriginalName(e){A(this.#d,e,!0)}#f=k(j({name:``,type:``,description:``,user_path:``,config:{}}));get form(){return I(this.#f)}set form(e){A(this.#f,e,!0)}get filtered(){return nR(this.guardrails,this.filter)}typeLabel(e){return rR(this.types,e)}typeFields(e){return iR(this.types,e)}fieldValue(e){return aR(this.form&&this.form.config,e)}setFieldValue(e,t){this.form={...this.form,config:oR(this.form.config,e,t)}}arrayFieldSelected(e,t){return sR(this.form&&this.form.config,e,t)}toggleArrayFieldValue(e,t,n){this.form={...this.form,config:cR(this.form.config,e,t,n)}}openCreate(){this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=tR(this.types,ZL(this.types)),this.formOpen=!0}openEdit(e){let t=QL(this.types,e&&e.type);this.formMode=`edit`,this.formOriginalName=String(e&&e.name||``).trim(),this.error=``,this.form={name:this.formOriginalName,type:t,description:String(e&&e.description||``).trim(),user_path:String(e&&e.user_path||``).trim(),config:eR(this.types,e&&e.config,t)},this.formOpen=!0}closeForm(){this.formOpen=!1,this.formMode=`create`,this.formOriginalName=``,this.error=``,this.form=tR(this.types,ZL(this.types))}changeType(e){let t=QL(this.types,e);this.form={...this.form,type:t,config:$L(this.types,t)}}async fetchTypes(){this.typesLoading=!0;try{let e=await _T(`/admin/guardrails/types`,{label:`guardrail types`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.types=[];return}if(e.result&&(this.available=!0),this.types=e.items,e.status===`error`){this.error=e.error;return}let t=QL(this.types,this.form.type);this.form={...this.form,type:t,config:eR(this.types,this.form.config,t)}}finally{this.typesLoading=!1}}async fetchGuardrails(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/guardrails`,{label:`guardrails`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.guardrails=[];return}e.result&&(this.available=!0),this.guardrails=e.items,this.error=e.error}finally{this.loading=!1}}async fetchPage(){await Promise.all([this.fetchTypes(),this.fetchGuardrails()])}async submitForm(){let e=String(this.form.name||``).trim(),t=String(this.form.type||``).trim();if(!e){this.error=`Name is required.`;return}if(!t){this.error=`Type is required.`;return}this.error=``,this.formSubmitting=!0;let n=lR(this.form);try{let t=await vT(`/admin/guardrails`,`PUT`,n,{label:`save guardrail`,errorFallback:`Failed to save guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}q.success(`Guardrail "`+e+`" saved.`),this.closeForm(),this.fetchGuardrails()}finally{this.formSubmitting=!1}}async deleteGuardrail(e){let t=String(e&&e.name||``).trim();if(!(!t||this.deletingName)&&window.confirm(`Delete guardrail "`+t+`"? Workflows that still reference it must be updated first.`)){this.deletingName=t;try{let e=await vT(`/admin/guardrails`,`DELETE`,{name:t},{label:`delete guardrail`,errorFallback:`Failed to delete guardrail.`,unavailableMessage:`Guardrails feature is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}q.success(`Guardrail "`+t+`" deleted.`),this.formOpen&&this.formOriginalName===t&&this.closeForm(),this.fetchGuardrails()}finally{this.deletingName=``}}}},dR=R(`
                        `),fR=R(`

                        Loading guardrails...

                        `),pR=R(`
                        `),mR=R(`
                        `),hR=R(`
                        NameTypeUser PathSummaryActions
                        `),gR=R(`

                        No guardrails defined yet.

                        `),_R=R(`

                        Instances

                        Each instance has a reusable name, a type, an optional user path for - future UI visibility scoping, and a JSON-backed config payload for - that type.

                        `);function vR(e,t){E(t,!0);var n=_R(),r=M(n),i=P(M(r),2);G(M(i),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(i),T(r);var a=P(r,2),o=e=>{var t=dR(),n=M(t);yw(M(n),{id:`guardrail-filter`,placeholder:`Filter by name, type, user path, summary...`,label:`Guardrail filter`,get value(){return uR.filter},set value(e){uR.filter=e}}),T(n),T(t),z(e,t)};V(a,e=>{uR.available&&e(o)});var s=P(a,2),c=e=>{var t=fR();SS(M(t),{size:16,label:`Loading guardrails`}),Ue(),T(t),z(e,t)};V(s,e=>{uR.loading&&uR.filtered.length===0&&e(c)});var l=P(s,2),u=e=>{var t=hR(),n=M(t),r=P(M(n));H(r,21,()=>uR.filtered,e=>e.name,(e,t)=>{var n=mR(),r=M(n),i=M(r,!0);T(r);var a=P(r),o=M(a),s=M(o,!0);T(o),T(a);var c=P(a),l=M(c,!0);T(c);var u=P(c),d=M(u),f=M(d,!0);T(d);var p=P(d,2),m=e=>{var n=pR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(p,e=>{I(t).description&&e(m)}),T(u);var h=P(u),g=M(h),_=M(g);{let e=O(()=>`Edit guardrail `+I(t).name);gT(_,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>uR.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var v=P(_,2);{let e=O(()=>(uR.deletingName===I(t).name?`Deleting guardrail `:`Delete guardrail `)+I(t).name),n=O(()=>uR.deletingName===I(t).name);gT(v,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>uR.deleteGuardrail(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}T(g),T(h),T(n),F(e=>{B(i,I(t).name),B(s,e),B(l,I(t).user_path||`—`),B(f,I(t).summary||I(t).description||`No summary yet.`)},[()=>uR.typeLabel(I(t).type)]),z(e,n)}),T(r),T(n),T(t),z(e,t)};V(l,e=>{uR.filtered.length>0&&e(u)});var d=P(l,2),f=e=>{z(e,gR())};V(d,e=>{uR.filtered.length===0&&!uR.loading&&uR.available&&!uR.error&&!K.authError&&e(f)}),T(n),F(()=>i.disabled=uR.typesLoading||uR.formSubmitting||!uR.available),L(`click`,i,()=>uR.openCreate()),z(e,n),D()}Hr([`click`]);var yR=R(`

                        Workflows reference these names directly, so renames are - intentionally avoided after creation.

                        `),bR=R(``),xR=R(``),SR=R(``),CR=R(``),wR=R(``),TR=R(``),ER=R(``),DR=R(``),OR=R(``),kR=R(`
                        `),AR=R(``),jR=R(` `),MR=R(`
                        `),NR=R(`
                        `);function PR(e,t){E(t,!0);let n=O(()=>uR.formMode===`edit`);{let t=e=>{z(e,yR())},r=O(()=>I(n)?`Edit Guardrail`:`Create Guardrail`);bE(e,{get open(){return uR.formOpen},get title(){return I(r)},ariaLabel:`Guardrail editor`,get error(){return uR.error},get submitting(){return uR.formSubmitting},submitLabel:`Save Guardrail`,dialogClass:`settings-guardrails-editor guardrails-editor-wide`,onclose:()=>uR.closeForm(),onsubmit:()=>uR.submitForm(),headerHint:t,children:(e,t)=>{var r=NR(),i=M(r);SE(i,{id:`guardrail-name`,label:`Name`,children:(e,t)=>{var r=bR();na(r),F(()=>{r.disabled=I(n),W(r,`data-modal-autofocus`,!I(n)||void 0)}),da(r,()=>uR.form.name,e=>uR.form.name=e),z(e,r)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`guardrail-type`,label:`Type`,children:(e,t)=>{var r=SR();H(r,21,()=>uR.types,e=>e.type,(e,t)=>{var n=xR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).type)&&(n.value=(n.__value=I(t).type)??``)}),z(e,n)}),T(r);var i;Wi(r),F(()=>{r.disabled=I(n),i!==(i=uR.form.type)&&(r.value=(r.__value=uR.form.type)??``,Ui(r,uR.form.type))}),L(`change`,r,e=>uR.changeType(e.currentTarget.value)),z(e,r)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`guardrail-description`,label:`Description`,children:(e,t)=>{var r=CR();na(r),F(()=>W(r,`data-modal-autofocus`,I(n)?!0:void 0)),da(r,()=>uR.form.description,e=>uR.form.description=e),z(e,r)},$$slots:{default:!0}});var s=P(o,2),c=M(s);qS(c,{copyId:`guardrail-user-path-help-copy`,label:`guardrail user path help`,text:`Only used for auxiliary rewrite (llm_based_altering) guardrails; ignored for other guardrail types.`,title:e=>{z(e,wR())},$$slots:{title:!0}});var l=P(c,2);na(l),T(s),H(P(s,2),17,()=>uR.typeFields(uR.form.type),e=>e.key,(e,t)=>{var n=Qr(),r=N(n),i=e=>{var n=kR(),r=M(n);{let e=e=>{var n=TR(),r=M(n,!0);T(n),F(()=>{W(n,`for`,`guardrail-field-`+I(t).key),B(r,I(t).label)}),z(e,n)},n=O(()=>`guardrail-field-help-`+I(t).key),i=O(()=>I(t).label+` help`),a=O(()=>I(t).help||``);qS(r,{get copyId(){return I(n)},get label(){return I(i)},get text(){return I(a)},title:e,$$slots:{title:!0}})}var i=P(r,2),a=e=>{var n=ER();H(n,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=xR(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(n);var r;Wi(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),r!==(r=e)&&(n.value=(n.__value=e)??``,Ui(n,e))},[()=>uR.fieldValue(I(t))]),L(`change`,n,e=>uR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},o=e=>{var n=DR();ft(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>uR.fieldValue(I(t))]),L(`input`,n,e=>uR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)},s=e=>{var n=OR();na(n),F(e=>{W(n,`id`,`guardrail-field-`+I(t).key),W(n,`type`,I(t).input||`text`),W(n,`placeholder`,I(t).placeholder||``),ra(n,e),W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0)},[()=>uR.fieldValue(I(t))]),L(`input`,n,e=>uR.setFieldValue(I(t),e.currentTarget.value)),z(e,n)};V(i,e=>{I(t).input===`select`?e(a):I(t).input===`textarea`?e(o,1):e(s,-1)}),T(n),z(e,n)},a=e=>{var n=MR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).options||[],e=>I(t).key+`-`+e.value,(e,n)=>{var r=AR(),i=M(r);na(i);var a=P(i,2),o=M(a,!0);T(a),T(r),F(e=>{ia(i,e),B(o,I(n).label)},[()=>uR.arrayFieldSelected(I(t),I(n).value)]),L(`change`,i,e=>uR.toggleArrayFieldValue(I(t),I(n).value,e.currentTarget.checked)),z(e,r)}),T(a);var o=P(a,2),s=e=>{var n=jR(),r=M(n,!0);T(n),F(()=>{W(n,`id`,`guardrail-field-help-`+I(t).key),B(r,I(t).help)}),z(e,n)};V(o,e=>{I(t).help&&e(s)}),T(n),F(()=>{W(n,`aria-describedby`,I(t).help?`guardrail-field-help-`+I(t).key:void 0),B(i,I(t).label)}),z(e,n)};V(r,e=>{I(t).input===`checkboxes`?e(a,-1):e(i)}),z(e,n)}),T(r),da(l,()=>uR.form.user_path,e=>uR.form.user_path=e),z(e,r)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var FR=R(`

                        Guardrails

                        `),IR=R(`
                        Runtime guardrail execution is currently off because GUARDRAILS_ENABLED is disabled. You can still manage - definitions here.
                        `),LR=R(`
                        Guardrails feature is unavailable.
                        `),RR=R(`
                        `),zR=R(`

                        Reusable Policy Objects

                        Guardrail Library

                        Store guardrails in the database, keep them hot in memory, and attach - them to workflows by reference.

                        Instances
                        Types
                        `);function BR(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`guardrails`&&(Ss.ensureLoaded(),uR.fetchPage())});var n=zR(),r=M(n),i=M(r);qS(M(i),{copyId:`guardrails-help-copy`,label:`guardrails help`,text:`Reusable policy objects stored in the database and kept hot in memory for workflow execution.`,title:e=>{z(e,FR())},$$slots:{title:!0}}),T(i),T(r);var a=P(r,2),o=P(M(a),2),s=M(o),c=P(M(s),2),l=M(c,!0);T(c),T(s);var u=P(s,2),d=P(M(u),2),f=M(d,!0);T(d),T(u),T(o),T(a);var p=P(a,2);Fc(p,{});var m=P(p,2),h=e=>{z(e,IR())},g=O(()=>!Ss.guardrailsVisible());V(m,e=>{I(g)&&e(h)});var _=P(m,2),v=e=>{z(e,LR())};V(_,e=>{!K.authError&&!uR.available&&e(v)});var y=P(_,2),b=e=>{var t=RR(),n=M(t,!0);T(t),F(()=>B(n,uR.error)),z(e,t)};V(y,e=>{!K.authError&&uR.error&&!uR.formOpen&&e(b)});var x=P(y,2);PR(x,{}),vR(P(x,2),{}),T(n),F((e,t)=>{B(l,e),B(f,t)},[()=>oc(uR.guardrails.length),()=>oc(uR.types.length)]),z(e,n),D()}var Q=new class{#e=k(j([]));get servers(){return I(this.#e)}set servers(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get slugEdited(){return I(this.#c)}set slugEdited(e){A(this.#c,e,!0)}#l=k(!1);get advancedOpen(){return I(this.#l)}set advancedOpen(e){A(this.#l,e,!0)}#u=k(j(dx()));get form(){return I(this.#u)}set form(e){A(this.#u,e,!0)}#d=k(``);get deletingName(){return I(this.#d)}set deletingName(e){A(this.#d,e,!0)}#f=k(``);get reconnectingName(){return I(this.#f)}set reconnectingName(e){A(this.#f,e,!0)}#p=k(!1);get catalogOpen(){return I(this.#p)}set catalogOpen(e){A(this.#p,e,!0)}#m=k(!1);get catalogLoading(){return I(this.#m)}set catalogLoading(e){A(this.#m,e,!0)}#h=k(``);get catalogError(){return I(this.#h)}set catalogError(e){A(this.#h,e,!0)}#g=k(j(fx()));get catalog(){return I(this.#g)}set catalog(e){A(this.#g,e,!0)}#_=O(()=>Cx(this.servers,this.filter));get filtered(){return I(this.#_)}set filtered(e){A(this.#_,e)}async fetchServers(){if(await Ss.ensureLoaded(),!Ss.mcpVisible()){this.available=!1,this.servers=[],this.error=``,this.loading=!1;return}this.loading=!0,this.error=``;try{let e=await _T(`/admin/mcp-servers`,{label:`mcp servers`,errorFallback:`Failed to load MCP servers.`,unavailableStatuses:[503,404]});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.servers=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.servers=[],this.error=e.error;return}this.available=!0,this.servers=e.items}finally{this.loading=!1}}openCreate(){this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=dx(),this.formOpen=!0}openEdit(e){!e||e.managed||(this.formMode=`edit`,this.slugEdited=!0,this.advancedOpen=!1,this.error=``,this.form=wx(e),this.formOpen=!0)}closeForm(){this.formOpen=!1,this.formMode=`create`,this.slugEdited=!1,this.advancedOpen=!1,this.error=``,this.form=dx()}syncSlugFromName(){this.formMode===`create`&&!this.slugEdited&&(this.form.slug=yx(this.form.name))}markSlugEdited(){this.formMode===`create`&&(this.slugEdited=!0)}addHeader(){this.form.headers.push({name:``,value:``})}removeHeader(e){this.form.headers.splice(e,1)}async submitForm(){let e=Tx(this.form,this.formMode,this.servers);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/mcp-servers`,`PUT`,e.payload,{label:`save mcp server`,errorFallback:`Failed to save MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error;return}q.success(`MCP server "`+e.payload.name+`" saved.`),this.closeForm(),this.fetchServers()}finally{this.formSubmitting=!1}}async deleteServer(e){let t=String(e&&e.name||``).trim(),n=px(e);if(!(!n||this.deletingName||e&&e.managed)&&confirm(`Delete MCP server "`+t+`"? Clients lose access to its tools immediately.`)){this.deletingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n),`DELETE`,void 0,{label:`delete mcp server`,errorFallback:`Failed to delete MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}q.success(`MCP server "`+t+`" deleted.`),this.formOpen&&this.form.slug===n&&this.closeForm(),this.fetchServers()}finally{this.deletingName=``}}}async reconnectServer(e){let t=String(e&&e.name||``).trim(),n=px(e);if(!(!n||this.reconnectingName)){this.reconnectingName=n;try{let e=await vT(`/admin/mcp-servers/`+encodeURIComponent(n)+`/reconnect`,`POST`,void 0,{label:`reconnect mcp server`,errorFallback:`Failed to reconnect MCP server.`,unavailableMessage:`MCP server management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,q.error(e.error);return}if(e.status===`error`){q.error(e.error);return}let r=e.result.data,i=mx(r);i===`connected`?q.success(`MCP server "`+t+`" reconnected.`):i===`disabled`?q.success(`MCP server "`+t+`" is disabled; no connection was attempted.`):q.error(`Reconnect attempted, but MCP server "`+t+`" is still `+i+`.`),r&&r.name?this.servers=(this.servers||[]).map(e=>px(e)===px(r)?r:e):this.fetchServers()}finally{this.reconnectingName=``}}}async openCatalog(e){let t=String(e&&e.name||``).trim(),n=px(e);if(n){this.catalogOpen=!0,this.catalogLoading=!0,this.catalogError=``,this.catalog={...fx(),server:n,status:mx(e)};try{let e=await _s(`/admin/mcp-servers/`+encodeURIComponent(n)+`/catalog`,{label:`mcp server catalog`});if(e.stale)return;if(e.status===503){this.available=!1,this.catalogError=`MCP server management is unavailable.`;return}if(e.status===404){this.catalogError=`MCP server "`+t+`" was not found.`;return}if(!e.ok){this.catalogError=e.status===401?`Authentication required.`:fs(e.data,`Failed to load MCP server catalog.`);return}this.catalog=Ex(n,e.data)}catch(e){console.error(`Failed to load MCP server catalog:`,e),this.catalogError=`Failed to load MCP server catalog.`}finally{this.catalogLoading=!1}}}closeCatalog(){this.catalogOpen=!1,this.catalogLoading=!1,this.catalogError=``,this.catalog=fx()}},VR=R(``),HR=R(`

                        `),UR=R(`
                        `),WR=R(`

                        `),GR=R(`
                      • `),KR=R(`

                          `),qR=R(`

                          No tools listed — the server may still be connecting or degraded.

                          `),JR=R(` `,1),YR=R(``);function XR(e,t){E(t,!0);let n=O(()=>Ox(Q.catalog));Ns(e,{get open(){return Q.catalogOpen},variant:`editor`,onclose:()=>Q.closeCatalog(),children:(e,t)=>{var r=YR(),i=M(r),a=M(i),o=P(M(a),2),s=M(o),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l),T(o),T(a),ks(P(a,2),{label:`Close MCP server catalog`,onclick:()=>Q.closeCatalog()}),T(i);var d=P(i,2),f=e=>{mT(e,{label:`Loading catalog...`})},p=e=>{var t=VR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalogError)),z(e,t)},m=e=>{var t=JR(),r=N(t),i=e=>{var t=HR(),n=M(t,!0);T(t),F(()=>B(n,Q.catalog.instructions)),z(e,t)};V(r,e=>{Q.catalog.instructions&&e(i)});var a=P(r,2);H(a,17,()=>I(n),e=>e.key,(e,t)=>{var n=KR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2);H(a,21,()=>I(t).items,e=>e.key,(e,t)=>{var n=GR(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{var n=UR(),r=M(n,!0);T(n),F(()=>{W(n,`title`,`Exposed on the aggregated /mcp endpoint as `+I(t).aggregated),B(r,I(t).aggregated)}),z(e,n)};V(a,e=>{I(t).aggregated&&e(o)});var s=P(a,2),c=e=>{var n=WR(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(s,e=>{I(t).description&&e(c)}),T(n),F(()=>{W(r,`title`,I(t).aggregated||I(t).name),B(i,I(t).name)}),z(e,n)}),T(a),T(n),F(()=>B(i,I(t).title)),z(e,n)});var o=P(a,2),s=e=>{z(e,qR())},c=O(()=>kx(Q.catalog));V(o,e=>{I(c)&&e(s)}),z(e,t)};V(d,e=>{Q.catalogLoading?e(f):Q.catalogError?e(p,1):e(m,-1)});var h=P(d,2),g=M(h);T(h),T(r),F((e,t)=>{B(c,Q.catalog.server),U(l,1,`audit-status-badge ${e??``}`,`svelte-1xqrzco`),B(u,t)},[()=>hx(Q.catalog),()=>mx(Q.catalog)]),L(`click`,g,()=>Q.closeCatalog()),z(e,r)},$$slots:{default:!0}}),D()}Hr([`click`]);var ZR=R(`

                          The display name can change. The slug is the stable client-facing identity.

                          `),QR=R(` Human-readable and Unicode-friendly. You can change it later.`,1),$R=R(`Derived from the name. You may edit it before saving.`),ez=R(`Immutable because it is used in URLs, scope headers, and aggregated tool names.`),tz=R(` `,1),nz=R(` stdio servers are config-only: declare them in config.yaml under mcp.servers.`,1),rz=R(``),iz=R(`
                          `),az=R(`
                          Headers
                          Sent only to the configured server origin. Saved values are shown as ***; leave *** unchanged to keep the stored value.
                          Advanced settings Description, access rules, and timeout
                          `,1);function oz(e,t){E(t,!0);{let t=e=>{z(e,ZR())},n=O(()=>Q.formMode===`edit`?`Edit MCP Server`:`Add MCP Server`);bE(e,{get open(){return Q.formOpen},get title(){return I(n)},ariaLabel:`MCP server editor`,get error(){return Q.error},get submitting(){return Q.formSubmitting},onclose:()=>Q.closeForm(),onsubmit:()=>Q.submitForm(),headerHint:t,children:(e,t)=>{var n=az(),r=N(n);SE(r,{id:`mcp-server-name`,label:`Name`,children:(e,t)=>{var n=QR(),r=N(n);na(r),Ue(2),L(`input`,r,()=>Q.syncSlugFromName()),da(r,()=>Q.form.name,e=>Q.form.name=e),z(e,n)},$$slots:{default:!0}});var i=P(r,2);SE(i,{id:`mcp-server-slug`,label:`Slug`,children:(e,t)=>{var n=tz(),r=N(n);na(r);var i=P(r,2),a=e=>{z(e,$R())},o=e=>{z(e,ez())};V(i,e=>{Q.formMode===`create`?e(a):e(o,-1)}),F(()=>r.disabled=Q.formMode===`edit`),L(`input`,r,()=>Q.markSlugEdited()),da(r,()=>Q.form.slug,e=>Q.form.slug=e),z(e,n)},$$slots:{default:!0}});var a=P(i,2);SE(a,{id:`mcp-server-transport`,label:`Transport`,children:(e,t)=>{var n=nz(),r=N(n),i=M(r);i.value=i.__value=`http`;var a=P(i);a.value=a.__value=`sse`,T(r),Ue(2),Gi(r,()=>Q.form.transport,e=>Q.form.transport=e),z(e,n)},$$slots:{default:!0}});var o=P(a,2);SE(o,{id:`mcp-server-url`,label:`URL`,children:(e,t)=>{var n=rz();na(n),da(n,()=>Q.form.url,e=>Q.form.url=e),z(e,n)},$$slots:{default:!0}});var s=P(o,2),c=P(M(s),2);H(c,21,()=>Q.form.headers,oi,(e,t,n)=>{var r=iz(),i=M(r);na(i);var a=P(i,2);na(a),gT(P(a,2),{label:`Remove header`,class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>Q.removeHeader(n),children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(r),da(i,()=>I(t).name,e=>I(t).name=e),da(a,()=>I(t).value,e=>I(t).value=e),z(e,r)}),T(c);var l=P(c,2),u=M(l);G(M(u),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(u),T(l),Ue(2),T(s);var d=P(s,2),f=M(d);bA(M(f),{get enabled(){return Q.form.enabled},label:`MCP server`,onclick:()=>Q.form.enabled=!Q.form.enabled}),T(f),T(d);var p=P(d,2),m=P(M(p),2),h=M(m),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=P(M(y),2);na(b),T(y);var x=P(y,2),S=P(M(x),2);ft(S),W(S,`placeholder`,`/ -/team/alpha`),T(x);var C=P(x,2),w=P(M(C),2);na(w),T(C),T(m),T(p),F(()=>p.open=Q.advancedOpen),L(`click`,u,()=>Q.addHeader()),Vr(`toggle`,p,e=>Q.advancedOpen=e.currentTarget.open),da(g,()=>Q.form.description,e=>Q.form.description=e),da(v,()=>Q.form.allowed_tools,e=>Q.form.allowed_tools=e),da(b,()=>Q.form.disallowed_tools,e=>Q.form.disallowed_tools=e),da(S,()=>Q.form.user_paths,e=>Q.form.user_paths=e),da(w,()=>Q.form.tool_timeout_seconds,e=>Q.form.tool_timeout_seconds=e),z(e,n)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`input`,`click`]);var sz=R(`Config`),cz=R(`
                          `),lz=R(`
                          `),uz=R(`
                          NameTransportEndpointStatusToolsEnabledActions
                          `);function dz(e,t){E(t,!0);function n(e){return gx(e,e=>ds.formatTimestamp(e))}var r=uz(),i=M(r),a=P(M(i));H(a,21,()=>Q.filtered,e=>px(e),(e,t)=>{var r=lz(),i=M(r),a=M(i),o=M(a,!0);T(a);var s=P(a,2),c=e=>{z(e,sz())};V(s,e=>{I(t).managed&&e(c)});var l=P(s,2),u=M(l,!0);T(l),T(i);var d=P(i),f=M(d),p=M(f,!0);T(f),T(d);var m=P(d),h=M(m,!0);T(m);var g=P(m),_=M(g),v=M(_,!0);T(_);var y=P(_,2),b=e=>{var n=cz(),r=M(n,!0);T(n),F(()=>B(r,I(t).last_error)),z(e,n)},x=O(()=>mx(I(t))===`degraded`&&I(t).last_error);V(y,e=>{I(x)&&e(b)}),T(g);var S=P(g),C=M(S),w=M(C,!0);T(C);var ee=P(C,2),te=M(ee,!0);T(ee),T(S);var ne=P(S),re=M(ne),ie=M(re,!0);T(re),T(ne);var ae=P(ne),oe=M(ae),se=M(oe),ce=e=>{{let n=O(()=>`Edit MCP server `+I(t).name);gT(e,{get label(){return I(n)},class:`table-icon-btn`,onclick:()=>Q.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(se,e=>{I(t).managed||e(ce)});var le=P(se,2);{let e=O(()=>`Inspect catalog of MCP server `+I(t).name);gT(le,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.openCatalog(I(t)),children:(e,t)=>{G(e,{get icon(){return io},class:`form-action-icon`})},$$slots:{default:!0}})}var ue=P(le,2);{let e=O(()=>(Q.reconnectingName===px(I(t))?`Reconnecting MCP server `:`Reconnect MCP server `)+I(t).name),n=O(()=>Q.reconnectingName===px(I(t)));gT(ue,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>Q.reconnectServer(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return ho},class:`form-action-icon`})},$$slots:{default:!0}})}var de=P(ue,2),fe=e=>{{let n=O(()=>(Q.deletingName===px(I(t))?`Deleting MCP server `:`Delete MCP server `)+I(t).name),r=O(()=>Q.deletingName===px(I(t)));gT(e,{get label(){return I(n)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>Q.deleteServer(I(t)),get disabled(){return I(r)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}};V(de,e=>{I(t).managed||e(fe)}),T(oe),T(ae),T(r),F((e,n,r,i,a,s,c,l)=>{B(o,I(t).name),B(u,e),B(p,I(t).transport||`http`),W(m,`title`,n),B(h,r),U(_,1,`audit-status-badge ${i??``}`,`svelte-ah8nrt`),W(_,`title`,a),B(v,s),B(w,c),B(te,l),U(re,1,Fi([`auth-key-status-badge`,I(t).enabled?`auth-key-status-active`:`auth-key-status-inactive`])),B(ie,I(t).enabled?`Enabled`:`Disabled`)},[()=>px(I(t)),()=>_x(I(t)),()=>_x(I(t)),()=>hx(I(t)),()=>n(I(t)),()=>mx(I(t)),()=>oc(I(t).tool_count||0),()=>vx(I(t))]),z(e,r)}),T(a),T(i),T(r),z(e,r),D()}var fz=R(`

                          MCP Servers

                          `),pz=R(``),mz=R(`
                          MCP server management is unavailable.
                          `),hz=R(``),gz=R(`
                          `),_z=R(`

                          No MCP servers yet. Add one here, or declare servers in config.yaml under mcp.servers.

                          `),vz=R(`

                          No MCP servers match your filter.

                          `),yz=R(`
                          `);function bz(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`mcp-servers`&&Q.fetchServers()});var n=yz(),r=M(n),i=M(r);qS(M(i),{copyId:`mcp-servers-help-copy`,label:`MCP servers help`,text:`Upstream Model Context Protocol servers whose tools, prompts, and resources the gateway exposes to clients. Servers added here connect over HTTP or SSE; stdio servers and rows marked Config are declared in config.yaml under mcp.servers and are read-only in the dashboard. Saved header values are masked in API and dashboard responses.`,title:e=>{z(e,fz())},$$slots:{title:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=pz();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=Q.formSubmitting),L(`click`,t,()=>Q.openCreate()),z(e,t)};V(o,e=>{Q.available&&!K.authError&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,mz())};V(c,e=>{!Q.available&&!K.authError&&e(l)});var u=P(c,2),d=e=>{var t=hz(),n=M(t,!0);T(t),F(()=>B(n,Q.error)),z(e,t)};V(u,e=>{Q.error&&!K.authError&&!Q.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading MCP servers...`})};V(f,e=>{Q.loading&&!K.authError&&e(p)});var m=P(f,2),h=e=>{var t=gz(),n=M(t);yw(M(n),{id:`mcp-server-filter`,placeholder:`Filter by name, slug, URL, transport, or status...`,label:`Filter MCP servers by name, slug, URL, transport, or status`,get value(){return Q.filter},set value(e){Q.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{(Q.servers.length>0||Q.filter)&&Q.available&&!K.authError&&e(h)});var g=P(m,2);oz(g,{});var _=P(g,2);XR(_,{});var v=P(_,2),y=e=>{dz(e,{})};V(v,e=>{Q.filtered.length>0&&Q.available&&!K.authError&&e(y)});var b=P(v,2),x=e=>{z(e,_z())};V(b,e=>{Q.servers.length===0&&!Q.filter&&!Q.loading&&!K.authError&&!Q.error&&Q.available&&e(x)});var S=P(b,2),C=e=>{z(e,vz())};V(S,e=>{Q.servers.length>0&&Q.filtered.length===0&&Q.filter&&!Q.loading&&!K.authError&&Q.available&&e(C)}),T(n),z(e,n),D()}Hr([`click`]);var xz=`api_keys`,Sz=`session_sticky_keys`,Cz=`base_url`,wz=`service_account_json`,Tz=`models`,Ez={[xz]:{label:`API Keys`,control:`keys`,hint:`Identified sessions stay on one key by default, improving provider prompt-cache hits. Saved values are shown as ***********; leave the asterisks unchanged to keep the stored key.`},[Sz]:{label:`Session-sticky API keys`,control:`checkbox`,hint:`Keep each identified conversation on one API key to preserve provider prompt-cache affinity. Turn off to rotate keys round-robin on every request.`},[Cz]:{label:`Base URL`,control:`text`},api_version:{label:`API Version`,control:`text`,placeholder:`e.g. 2024-10-01-preview`,hint:`Leave empty for the provider default. Realtime endpoints may need a newer version.`},backend:{label:`Backend`,control:`select`,hint:`Which Google surface to call. Vertex authenticates with Google credentials instead of an API key.`},auth_type:{label:`Auth Type`,control:`select`,hint:`How to obtain Google credentials. Leave on the default to use Application Default Credentials.`},api_mode:{label:`API Mode`,control:`select`,hint:`Which request shape to send upstream.`},vertex_project:{label:`Vertex Project`,control:`text`,placeholder:`my-gcp-project`},vertex_location:{label:`Vertex Location`,control:`text`,placeholder:`us-central1`},service_account_file:{label:`Service Account File`,control:`text`,placeholder:`/path/to/service-account.json`,hint:`Path readable by the gateway process.`},[wz]:{label:`Service Account JSON`,control:`textarea`,placeholder:`Paste service account JSON`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value, or clear it to remove.`},service_account_json_base64:{label:`Service Account JSON (base64)`,control:`text`,hint:`Saved values are shown as ***********; leave the asterisks unchanged to keep the stored value.`},gcp_scope:{label:`GCP Scope`,control:`text`,placeholder:`https://www.googleapis.com/auth/cloud-platform`},[Tz]:{label:`Models (comma-separated)`,control:`text`,placeholder:`gpt-4o, gpt-4o-mini`,hint:`Leave empty to auto-discover models from the provider's /models endpoint where supported.`}};function Dz(e){return Ez[e]||{label:String(e||``).split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),control:`text`}}function Oz(){return{name:``,type:``,api_keys:[],session_sticky_keys:!0,base_url:``,api_version:``,backend:``,auth_type:``,api_mode:``,vertex_project:``,vertex_location:``,service_account_file:``,service_account_json:``,service_account_json_base64:``,gcp_scope:``,models:``,enabled:!0}}function kz(e,t){let n=Array.isArray(e)?e:[];if(!t)return n;let r=String(t).toLowerCase();return n.filter(e=>[e.name,e.type,e.base_url].some(e=>String(e||``).toLowerCase().includes(r)))}function Az(e,t){let n=(Array.isArray(e)?e:[]).map(e=>String(e&&e.type||``).trim()).filter(Boolean),r=String(t||``).trim();return r&&!n.includes(r)&&n.push(r),n}function jz(e,t){let n=String(t||``).trim();return n&&(Array.isArray(e)?e:[]).find(e=>String(e&&e.type||``).trim()===n)||null}function Mz(e,t){let n=e&&Array.isArray(e.fields)&&e.fields.length>0?e.fields:Object.keys(Ez).map(e=>({name:e,advanced:e!==xz})),r=t||e&&e.default_base_url||``,i=[],a=[];for(let e of n){let t=String(e&&e.name||``).trim();if(!t)continue;let n={...Dz(t),name:t,required:!!(e&&e.required),options:Array.isArray(e&&e.options)?e.options:[]};t===`base_url`&&r&&(n.placeholder=r,n.hint=`Defaults to `+r),n.options.length>0&&(n.control=`select`),(e&&e.advanced?a:i).push(n)}return{primary:i,advanced:a}}var Nz=new Set([`name`,`type`,`enabled`]);function Pz(e,t){let n=new Set([...t.primary||[],...t.advanced||[]].map(e=>e.name)),r=Oz(),i={...e};for(let e of Object.keys(r))!Nz.has(e)&&!n.has(e)&&(i[e]=r[e]);return i}function Fz(e){let t=Array.isArray(e&&e.api_keys)?e.api_keys.length:0;return t>0?t+` key`+(t===1?``:`s`):String(e&&e.service_account_json||``).trim()||String(e&&e.service_account_json_base64||``).trim()||String(e&&e.service_account_file||``).trim()?`service account`:String(e&&e.vertex_project||``).trim()?`ADC`:`keyless`}function Iz(e){let t=Array.isArray(e&&e.models)?e.models:[];return t.length===0?`auto-discovered`:t.length+` model`+(t.length===1?``:`s`)}function Lz(e){return(Array.isArray(e)?e:[]).map(e=>({value:String(e||``)}))}function Rz(e){return(Array.isArray(e)?e:[]).map(e=>String(e&&e.value||``))}function zz(e,t){let n=String(t||``).trim();if(!n)return``;let r=new Set((Array.isArray(e)?e:[]).map(e=>String(e&&e.name||``).trim()));if(!r.has(n))return n;let i=1;for(;r.has(n+`-`+i);)i+=1;return n+`-`+i}function Bz(e){return{name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),api_keys:Lz(e&&e.api_keys),session_sticky_keys:!e||e.session_sticky_keys!==!1,base_url:String(e&&e.base_url||``),api_version:String(e&&e.api_version||``),backend:String(e&&e.backend||``),auth_type:String(e&&e.auth_type||``),api_mode:String(e&&e.api_mode||``),vertex_project:String(e&&e.vertex_project||``),vertex_location:String(e&&e.vertex_location||``),service_account_file:String(e&&e.service_account_file||``),service_account_json:String(e&&e.service_account_json||``),service_account_json_base64:String(e&&e.service_account_json_base64||``),gcp_scope:String(e&&e.gcp_scope||``),models:(Array.isArray(e&&e.models)?e.models:[]).join(`, `),enabled:!e||e.enabled!==!1}}function Vz(e){let t=String(e||``).trim();return t.length>=3&&/^\*+$/.test(t)}function Hz(e,t,n,r){let i={},a=String(e&&e.name||``).trim();String(e&&e.type||``).trim()||(i.type=`Select a provider type.`),a?a.includes(`/`)?i.name=`Name cannot contain '/' — it separates the provider from the model.`:t===`create`&&(Array.isArray(n)?n:[]).some(e=>String(e&&e.name||``).trim()===a)&&(i.name=`Provider "`+a+`" already exists.`):i.name=`Name is required.`;let{primary:o,advanced:s}=Mz(r);for(let t of[...o,...s]){let n=Uz(e,t);n&&(i[t.name]=n)}return i}function Uz(e,t){if(t.name===`api_keys`){let n=Rz(e&&e.api_keys);return t.required&&!n.some(e=>e.trim())?`At least one API key is required for this provider type.`:n.some(e=>!e.trim())?`Remove the empty row instead of leaving a key blank.`:``}let n=String(e&&e[t.name]||``).trim();if(t.required&&!n)return t.label+` is required for this provider type.`;if(!n)return``;if(t.name===`base_url`&&!n.includes(`://`)&&/[./]/.test(n))return`Include the scheme, e.g. https://`+n;if(t.name===`service_account_json`&&!Vz(n))try{JSON.parse(n)}catch{return`Paste the service account JSON file's contents — this is not valid JSON.`}return``}function Wz(e,t){let n={name:String(e&&e.name||``).trim(),type:String(e&&e.type||``).trim(),enabled:!!(e&&e.enabled)},{primary:r,advanced:i}=Mz(t),a=!!(t&&Array.isArray(t.fields)&&t.fields.length>0),o=new Set;for(let t of[...r,...i])!a&&t.name===`session_sticky_keys`||(o.add(t.name),n[t.name]=Gz(e,t.name));for(let t of Object.keys(Ez)){if(o.has(t)||t===`session_sticky_keys`)continue;let r=Gz(e,t);(Array.isArray(r)?r.length>0:String(r).trim()!==``)&&(n[t]=r)}return n}function Gz(e,t){switch(t){case xz:return Rz(e&&e.api_keys);case Tz:return ic(e&&e.models);case Sz:return!!(e&&e.session_sticky_keys);case wz:return e&&e.service_account_json||``;default:return String(e&&e[t]||``).trim()}}var $=new class{#e=k(j([]));get rows(){return I(this.#e)}set rows(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get formOpen(){return I(this.#a)}set formOpen(e){A(this.#a,e,!0)}#o=k(!1);get formSubmitting(){return I(this.#o)}set formSubmitting(e){A(this.#o,e,!0)}#s=k(`create`);get formMode(){return I(this.#s)}set formMode(e){A(this.#s,e,!0)}#c=k(!1);get advancedOpen(){return I(this.#c)}set advancedOpen(e){A(this.#c,e,!0)}#l=k(j(Oz()));get form(){return I(this.#l)}set form(e){A(this.#l,e,!0)}#u=k(j({}));get fieldErrors(){return I(this.#u)}set fieldErrors(e){A(this.#u,e,!0)}#d=k(``);get focusField(){return I(this.#d)}set focusField(e){A(this.#d,e,!0)}#f=k(``);get deletingName(){return I(this.#f)}set deletingName(e){A(this.#f,e,!0)}#p=k(!1);get deleteSubmitting(){return I(this.#p)}set deleteSubmitting(e){A(this.#p,e,!0)}#m=k(j([]));get types(){return I(this.#m)}set types(e){A(this.#m,e,!0)}#h=k(!1);get typesLoaded(){return I(this.#h)}set typesLoaded(e){A(this.#h,e,!0)}#g=null;get filteredRows(){return kz(this.rows,this.filter)}get schema(){return jz(this.types,this.form.type)}get formFields(){if(!String(this.form.type||``).trim())return{primary:[],advanced:[]};let e=this.schema;return Mz(e,e&&e.default_base_url)}async fetchTypes(){let e=await _T(`/admin/provider-credentials/types`,{label:`provider credential types`});e.status===`ok`&&(this.types=e.items,this.typesLoaded=!0)}async fetchPage(){this.#g&&this.#g.abort();let e=new AbortController;this.#g=e,this.loading=!0,this.error=``;try{let t=await _T(`/admin/provider-credentials`,{label:`provider credentials`,errorFallback:`Failed to load provider credentials.`,unavailableStatuses:[503,404],options:{signal:e.signal}});if(t.status===`stale`||e.signal.aborted)return;if(t.status===`unavailable`){this.available=!1,this.rows=[];return}if(t.status===`error`){t.result&&(this.available=!0),this.rows=[],this.error=t.error;return}this.available=!0,this.rows=t.items,this.typesLoaded||await this.fetchTypes()}finally{this.#g===e&&(this.#g=null,this.loading=!1)}}#_(e,t){this.formMode=e,this.form=t,this.advancedOpen=!1,this.error=``,this.fieldErrors={},this.focusField=``}openCreate(){this.#_(`create`,Oz()),this.formOpen=!0,this.typesLoaded||this.fetchTypes()}openEdit(e){!e||e.managed||(this.#_(`edit`,Bz(e)),this.formOpen=!0,this.typesLoaded||this.fetchTypes())}closeForm(){this.formOpen=!1,this.#_(`create`,Oz())}selectType(){this.fieldErrors={};let e=this.formFields;this.formMode===`create`&&(this.form=Pz(this.form,e));let t=e.primary.find(e=>e.name===`api_keys`);t&&t.required&&this.form.api_keys.length===0&&(this.form.api_keys=[{value:``}])}clearFieldError(e){if(this.fieldErrors[e]===void 0)return;let{[e]:t,...n}=this.fieldErrors;this.fieldErrors=n}addApiKeyRow(){this.form.api_keys.push({value:``}),this.clearFieldError(`api_keys`)}removeApiKeyRow(e){this.form.api_keys.splice(e,1),this.clearFieldError(`api_keys`)}#v(e){let t=fs(e,`Failed to save provider credential.`),n=String(e&&e.error&&typeof e.error==`object`&&e.error.param||``).trim();if(n&&this.#y(n)){this.fieldErrors={...this.fieldErrors,[n]:t},this.error=``,this.#b();return}this.error=t}#y(e){if(e===`name`||e===`type`)return!0;let{primary:t,advanced:n}=this.formFields;return[...t,...n].some(t=>t.name===e)}#b(){let e=Object.keys(this.fieldErrors);if(e.length===0)return;let{primary:t,advanced:n}=this.formFields;n.some(t=>e.includes(t.name))&&(this.advancedOpen=!0);let r=[`type`,`name`,...t.map(e=>e.name),...n.map(e=>e.name)];this.focusField=r.find(t=>e.includes(t))||e[0]}#x(){Nc.fetchModels(),Nc.fetchCategories()}async submitForm(){let e=this.schema,t=Hz(this.form,this.formMode,this.rows,e);if(Object.keys(t).length>0){this.fieldErrors=t,this.error=``,this.#b();return}let n=Wz(this.form,e);this.error=``,this.fieldErrors={},this.formSubmitting=!0;try{let e=await vT(`/admin/provider-credentials`,`PUT`,n,{label:`save provider credential`,errorFallback:`Failed to save provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.error=e.error;return}if(e.status===`error`){e.result&&e.result.status!==401?this.#v(e.result.data):this.error=e.error;return}q.success(`Provider "`+n.name+`" saved.`),this.closeForm(),this.#x(),this.fetchPage()}finally{this.formSubmitting=!1}}async performDelete(e){this.deleteSubmitting=!0,this.deletingName=e;try{let t=await vT(`/admin/provider-credentials/`+encodeURIComponent(e),`DELETE`,void 0,{label:`delete provider credential`,errorFallback:`Failed to delete provider credential.`,unavailableMessage:`Provider credential management is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,Rs.error=t.error;return}if(t.status===`error`){Rs.error=t.error;return}q.success(`Provider "`+e+`" deleted.`),Rs.close(),this.formOpen&&this.form.name===e&&this.closeForm(),this.#x(),this.fetchPage()}finally{this.deleteSubmitting=!1,this.deletingName=``}}requestDelete(e){let t=String(e||``).trim();if(!t||this.deleteSubmitting)return;let n=(this.rows||[]).find(e=>String(e&&e.name||``).trim()===t);n&&n.managed||Rs.open({title:`Delete Provider`,titleId:`providerCredentialDeleteDialogTitle`,inputId:`provider-credential-delete-confirmation`,message:`Type "`+t+`" to permanently delete this provider credential. Requests routed to it will fail until it is reconfigured.`,requiredText:t,confirmLabel:`Delete Provider`,icon:Ao,dialogClass:`budget-reset-dialog`,onConfirm:()=>this.performDelete(t)})}},Kz=R(`Config`),qz=R(` `,1),Jz=R(`
                          `),Yz=R(`
                          NameTypeBase URLAuthModelsEnabledUpdatedActions
                          `);function Xz(e,t){E(t,!0);var n=Yz(),r=M(n),i=P(M(r));H(i,21,()=>$.filteredRows,e=>e.name,(e,t)=>{var n=Jz(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=e=>{z(e,Kz())};V(o,e=>{I(t).managed&&e(s)}),T(r);var c=P(r),l=M(c),u=M(l,!0);T(l),T(c);var d=P(c),f=M(d,!0);T(d);var p=P(d),m=M(p,!0);T(p);var h=P(p),g=M(h,!0);T(h);var _=P(h),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x,!0);T(x);var C=P(x),w=M(C),ee=M(w),te=e=>{var n=qz(),r=N(n);{let e=O(()=>`Edit provider `+I(t).name);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>$.openEdit(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>($.deletingName===I(t).name?`Deleting provider `:`Delete provider `)+I(t).name),n=O(()=>$.deletingName===I(t).name);gT(i,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>$.requestDelete(I(t).name),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return Io},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)};V(ee,e=>{I(t).managed||e(te)}),T(w),T(C),T(n),F((e,n,r)=>{B(a,I(t).name),B(u,I(t).type),W(d,`title`,I(t).base_url||``),B(f,I(t).base_url||`—`),B(m,e),B(g,n),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).enabled,"auth-key-status-inactive":!I(t).enabled}),B(b,I(t).enabled?`Enabled`:`Disabled`),B(S,r)},[()=>Fz(I(t)),()=>Iz(I(t)),()=>ds.formatTimestamp(I(t).updated_at)]),z(e,n)}),T(i),T(r),T(n),z(e,n),D()}var Zz=R(``),Qz=R(`
                          `),$z=R(`
                          `,1),eB=R(``),tB=R(``),nB=R(``),rB=R(``),iB=R(``),aB=R(` `),oB=R(` `),sB=R(`
                          `);function cB(e,t){E(t,!0);let n=O(()=>`provider-credential-`+t.field.name),r=O(()=>$.fieldErrors[t.field.name]||``),i=O(()=>I(r)?I(n)+`-error`:t.field.hint?I(n)+`-hint`:void 0),a=O(()=>{let e=String($.form[t.field.name]||``).trim();return!e||t.field.options.includes(e)?t.field.options:[...t.field.options,e]});function o(){$.clearFieldError(t.field.name)}var s=sB(),c=M(s),l=M(c),u=P(l),d=e=>{z(e,Zz())};V(u,e=>{t.field.required&&e(d)}),T(c);var f=P(c,2),p=e=>{var t=$z(),a=N(t);H(a,21,()=>$.form.api_keys,oi,(e,t,a)=>{var s=Qz(),c=M(s);na(c),W(c,`aria-label`,`API key `+(a+1)),gT(P(c,2),{label:`Remove API key `+(a+1),class:`table-action-btn-danger table-icon-btn vm-target-remove`,onclick:()=>$.removeApiKeyRow(a),children:(e,t)=>{G(e,{get icon(){return Ao},class:`table-icon-svg`})},$$slots:{default:!0}}),T(s),F(()=>{W(c,`id`,a===0?I(n):I(n)+`-`+a),W(c,`aria-invalid`,I(r)?`true`:void 0),W(c,`aria-describedby`,a===0?I(i):void 0)}),L(`input`,c,o),da(c,()=>I(t).value,e=>I(t).value=e),z(e,s)}),T(a);var s=P(a,2),c=M(s);G(M(c),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(c),T(s),F(()=>W(c,`id`,$.form.api_keys.length===0?I(n):void 0)),L(`click`,c,()=>$.addApiKeyRow()),z(e,t)},m=e=>{var s=tB(),c=M(s);c.value=c.__value=``,H(P(c),16,()=>I(a),e=>e,(e,t)=>{var n=eB(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(s),F(()=>{W(s,`id`,I(n)),W(s,`aria-invalid`,I(r)?`true`:void 0),W(s,`aria-describedby`,I(i))}),L(`change`,s,o),Gi(s,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,s)},h=e=>{var a=nB();na(a),F(()=>{W(a,`id`,I(n)),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`change`,a,o),fa(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},g=e=>{var a=rB();ft(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)},_=e=>{var a=iB();na(a),F(()=>{W(a,`id`,I(n)),W(a,`placeholder`,t.field.placeholder||``),W(a,`aria-invalid`,I(r)?`true`:void 0),W(a,`aria-describedby`,I(i))}),L(`input`,a,o),da(a,()=>$.form[t.field.name],e=>$.form[t.field.name]=e),z(e,a)};V(f,e=>{t.field.control===`keys`?e(p):t.field.control===`select`?e(m,1):t.field.control===`checkbox`?e(h,2):t.field.control===`textarea`?e(g,3):e(_,-1)});var v=P(f,2),y=e=>{var t=aB(),i=M(t,!0);T(t),F(()=>{W(t,`id`,I(n)+`-error`),B(i,I(r))}),z(e,t)},b=e=>{var r=oB(),i=M(r,!0);T(r),F(()=>{W(r,`id`,I(n)+`-hint`),B(i,t.field.hint)}),z(e,r)};V(v,e=>{I(r)?e(y):t.field.hint&&e(b,1)}),T(s),F(()=>{W(c,`for`,I(n)),B(l,`${t.field.label??``} `)}),z(e,s),D()}Hr([`input`,`click`,`change`]);var lB=R(`

                          The name is the stable identity used for routing and cannot change once created.

                          `),uB=R(``),dB=R(` `),fB=R(`Determines which fields the gateway uses to build requests.`),pB=R(` `),mB=R(`Suggested from the selected type; used to route requests to this provider instance and editable before saving.`),hB=R(`Immutable once created.`),gB=R(`

                          Pick a type to configure its credentials — each provider type asks for different settings.

                          `),_B=R(`
                          Advanced settings
                          `),vB=R(`
                          `,1);function yB(e,t){E(t,!0);let n=O(()=>Az($.types,$.form.type)),r=O(()=>$.formFields),i=O(()=>$.fieldErrors.name||``),a=O(()=>$.fieldErrors.type||``);function o(){$.selectType(),$.formMode===`create`&&($.form.name=zz($.rows,$.form.type))}An(()=>{let e=$.focusField;if(!e)return;$.focusField=``;let t=document.getElementById(`provider-credential-`+e);t&&(t.scrollIntoView({block:`center`}),t.focus({preventScroll:!0}))});{let t=e=>{z(e,lB())},s=O(()=>$.formMode===`edit`?`Edit Provider`:`Add Provider`);bE(e,{get open(){return $.formOpen},get title(){return I(s)},ariaLabel:`Provider credential editor`,get error(){return $.error},get submitting(){return $.formSubmitting},novalidate:!0,onclose:()=>$.closeForm(),onsubmit:()=>$.submitForm(),headerHint:t,children:(e,t)=>{var s=vB(),c=N(s),l=P(M(c),2),u=M(l);u.value=u.__value=``,H(P(u),16,()=>I(n),e=>e,(e,t)=>{var n=uB(),r=M(n,!0);T(n);var i={};F(()=>{B(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),z(e,n)}),T(l);var d=P(l,2),f=e=>{var t=dB(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)},p=e=>{z(e,fB())};V(d,e=>{I(a)?e(f):e(p,-1)}),T(c);var m=P(c,2),h=P(M(m),2);na(h);var g=P(h,2),_=e=>{var t=pB(),n=M(t,!0);T(t),F(()=>B(n,I(i))),z(e,t)},v=e=>{z(e,mB())},y=e=>{z(e,hB())};V(g,e=>{I(i)?e(_):$.formMode===`create`?e(v,1):e(y,-1)}),T(m);var b=P(m,2),x=e=>{z(e,gB())};V(b,e=>{$.form.type||e(x)});var S=P(b,2);H(S,17,()=>I(r).primary,e=>e.name,(e,t)=>{cB(e,{get field(){return I(t)}})});var C=P(S,2),w=M(C);bA(M(w),{get enabled(){return $.form.enabled},label:`provider`,onclick:()=>$.form.enabled=!$.form.enabled}),T(w),T(C);var ee=P(C,2),te=e=>{var t=_B(),n=M(t),i=M(n),a=P(M(i),2),o=M(a,!0);T(a),T(i),T(n);var s=P(n,2);H(s,21,()=>I(r).advanced,e=>e.name,(e,t)=>{cB(e,{get field(){return I(t)}})}),T(s),T(t),F(e=>{t.open=$.advancedOpen,B(o,e)},[()=>I(r).advanced.map(e=>e.label).join(`, `)]),Vr(`toggle`,t,e=>$.advancedOpen=e.currentTarget.open),z(e,t)};V(ee,e=>{I(r).advanced.length>0&&e(te)}),F(()=>{l.disabled=$.formMode===`edit`,W(l,`aria-invalid`,I(a)?`true`:void 0),W(l,`aria-describedby`,I(a)?`provider-credential-type-error`:`provider-credential-type-hint`),h.disabled=$.formMode===`edit`,W(h,`aria-invalid`,I(i)?`true`:void 0),W(h,`aria-describedby`,I(i)?`provider-credential-name-error`:`provider-credential-name-hint`)}),L(`change`,l,o),Gi(l,()=>$.form.type,e=>$.form.type=e),L(`input`,h,()=>$.clearFieldError(`name`)),da(h,()=>$.form.name,e=>$.form.name=e),z(e,s)},$$slots:{headerHint:!0,default:!0}})}D()}Hr([`change`,`input`]);var bB=R(`

                          Providers

                          `),xB=R(``),SB=R(`
                          Provider credential management is unavailable.
                          `),CB=R(``),wB=R(`
                          `),TB=R(`

                          No dashboard-managed providers yet. Add one here, or declare providers in config.yaml / environment variables.

                          `),EB=R(`

                          No providers match your filter.

                          `),DB=R(`
                          `);function OB(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`providers-config`&&$.fetchPage()});var n=DB(),r=M(n),i=M(r);qS(M(i),{copyId:`providers-config-help-copy`,label:`model providers help`,title:e=>{z(e,bB())},help:e=>{Ue(),z(e,Zr(`Configure LLM provider credentials here instead of setting API keys as - environment variables. Providers declared in config.yaml or env vars - are read-only (Config badge) and cannot be edited or deleted from the - dashboard. Keys are masked after saving.`))},$$slots:{title:!0,help:!0}}),T(i);var a=P(i,2),o=M(a),s=e=>{var t=xB();G(M(t),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(t),F(()=>t.disabled=$.formSubmitting),L(`click`,t,()=>$.openCreate()),z(e,t)};V(o,e=>{$.available&&!K.needsAuth&&e(s)}),T(a),T(r);var c=P(r,2),l=e=>{z(e,SB())};V(c,e=>{!$.available&&!K.needsAuth&&e(l)});var u=P(c,2),d=e=>{var t=CB(),n=M(t,!0);T(t),F(()=>B(n,$.error)),z(e,t)};V(u,e=>{$.error&&!K.needsAuth&&!$.formOpen&&e(d)});var f=P(u,2),p=e=>{mT(e,{label:`Loading providers...`})};V(f,e=>{$.loading&&!K.needsAuth&&e(p)});var m=P(f,2),h=e=>{var t=wB(),n=M(t);yw(M(n),{id:`provider-credential-filter`,placeholder:`Filter by name, type, or base URL...`,label:`Filter providers by name, type, or base URL`,get value(){return $.filter},set value(e){$.filter=e}}),T(n),T(t),z(e,t)};V(m,e=>{($.rows.length>0||$.filter)&&$.available&&!K.needsAuth&&e(h)});var g=P(m,2);yB(g,{});var _=P(g,2),v=e=>{Xz(e,{})};V(_,e=>{$.filteredRows.length>0&&$.available&&!K.needsAuth&&e(v)});var y=P(_,2),b=e=>{z(e,TB())};V(y,e=>{$.rows.length===0&&!$.filter&&!$.loading&&!K.needsAuth&&!$.error&&$.available&&e(b)});var x=P(y,2),S=e=>{z(e,EB())};V(x,e=>{$.rows.length>0&&$.filteredRows.length===0&&$.filter&&!$.loading&&!K.needsAuth&&$.available&&e(S)}),T(n),z(e,n),D()}Hr([`click`]);function kB(){return{name:``,description:``,user_path:``,labels:``,dashboard_access:!1,expires_at:``}}function AB(e){let t=[];for(let n of String(e||``).split(`,`)){let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function jB(e){let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t;for(let e of n.split(`/`)){let t=String(e||``).trim();if(t){if(t===`.`||t===`..`)return`User path cannot contain "." or ".." segments.`;if(t.includes(`:`))return`User path cannot contain ":" segments.`}}return``}function MB(e){if(jB(e))return``;let t=String(e||``).trim();if(!t)return``;let n=t.startsWith(`/`)?t:`/`+t,r=[];for(let e of n.split(`/`)){let t=String(e||``).trim();t&&r.push(t)}return r.length?`/`+r.join(`/`):`/`}function NB(e){let t=e||{},n=String(t.name||``).trim();if(!n)return{error:`Name is required.`};let r=jB(t.user_path);if(r)return{error:r};let i=MB(t.user_path),a=AB(t.labels),o={name:n,description:String(t.description||``).trim()||void 0,user_path:i||void 0,labels:a.length?a:void 0,dashboard_access:t.dashboard_access?!0:void 0};return t.expires_at&&(o.expires_at=t.expires_at+`T23:59:59Z`),{payload:o}}function PB(e,t=Date.now()){let n=e&&e.expires_at;if(!n)return!1;let r=Date.parse(n);return Number.isFinite(r)&&r<=t}function FB(e){return e?!!e.deactivated_at||e.enabled===!1:!1}function IB(e,t=Date.now()){return!e||e.active===!1||FB(e)?!1:!PB(e,t)}function LB(e){return[e.name,e.description,e.user_path,e.redacted_value,...e.labels||[]].filter(Boolean).join(` `).toLowerCase()}function RB(e,t={}){let{query:n=``,showInactive:r=!1,now:i=Date.now()}=t,a=String(n||``).trim().toLowerCase();return(Array.isArray(e)?e:[]).filter(e=>!r&&!IB(e,i)?!1:!a||LB(e).includes(a))}function zB(e,t){return FB(e)?2:+!IB(e,t)}function BB(e){let t=e&&e.expires_at;if(!t)return 1/0;let n=Date.parse(t);return Number.isFinite(n)?n:1/0}function VB(e){let t=Date.parse(e&&e.deactivated_at||``);return Number.isFinite(t)?t:-1/0}function HB(e,t=Date.now()){return(Array.isArray(e)?e.slice():[]).sort((e,n)=>{let r=zB(e,t),i=zB(n,t);if(r!==i)return r-i;let[a,o]=r===2?[VB(e),VB(n)]:[BB(e),BB(n)];return a===o?String(e.name||``).localeCompare(String(n.name||``)):a>o?-1:1})}function UB(e,t=Date.now()){return(Array.isArray(e)?e:[]).reduce((e,n)=>e+ +!IB(n,t),0)}function WB(){return{open:!1,id:``,name:``,value:``,submitting:!1,error:``}}var GB=new class{#e=k(j([]));get keys(){return I(this.#e)}set keys(e){A(this.#e,e,!0)}#t=k(!0);get available(){return I(this.#t)}set available(e){A(this.#t,e,!0)}#n=k(!1);get loading(){return I(this.#n)}set loading(e){A(this.#n,e,!0)}#r=k(``);get error(){return I(this.#r)}set error(e){A(this.#r,e,!0)}#i=k(``);get filter(){return I(this.#i)}set filter(e){A(this.#i,e,!0)}#a=k(!1);get showInactive(){return I(this.#a)}set showInactive(e){A(this.#a,e,!0)}#o=O(()=>HB(RB(this.keys,{query:this.filter,showInactive:this.showInactive})));get visibleKeys(){return I(this.#o)}set visibleKeys(e){A(this.#o,e)}#s=O(()=>UB(this.keys));get inactiveCount(){return I(this.#s)}set inactiveCount(e){A(this.#s,e)}#c=k(!1);get formOpen(){return I(this.#c)}set formOpen(e){A(this.#c,e,!0)}#l=k(!1);get formSubmitting(){return I(this.#l)}set formSubmitting(e){A(this.#l,e,!0)}#u=k(``);get issuedValue(){return I(this.#u)}set issuedValue(e){A(this.#u,e,!0)}#d=k(``);get deactivatingID(){return I(this.#d)}set deactivatingID(e){A(this.#d,e,!0)}#f=k(``);get dashboardAccessID(){return I(this.#f)}set dashboardAccessID(e){A(this.#f,e,!0)}#p=k(j(kB()));get form(){return I(this.#p)}set form(e){A(this.#p,e,!0)}#m=k(j(WB()));get labelsEditor(){return I(this.#m)}set labelsEditor(e){A(this.#m,e,!0)}copyState=_M({logPrefix:`Failed to copy auth key:`});async fetchKeys(){this.loading=!0,this.error=``;try{let e=await _T(`/admin/auth-keys`,{label:`auth keys`,errorFallback:`Unable to load API keys.`});if(e.status===`stale`)return;if(e.status===`unavailable`){this.available=!1,this.keys=[];return}if(e.status===`error`){e.result&&(this.available=!0),this.error=e.error;return}this.available=!0,this.keys=e.items}finally{this.loading=!1}}openForm(){this.formSubmitting||this.formOpen||(this.formOpen=!0,this.error=``,this.issuedValue||(this.copyState.reset(),this.form=kB()))}closeForm(){this.formOpen&&(this.formOpen=!1,this.error=``,this.copyState.reset(),!this.formSubmitting&&!this.issuedValue&&(this.form=kB()))}copyIssuedValue(){return this.copyState.copy(this.issuedValue)}dismissIssuedKey(){this.issuedValue=``,this.copyState.reset(),this.form=kB()}async submitForm(){let e=NB(this.form);if(e.error){this.error=e.error;return}this.error=``,this.formSubmitting=!0;try{let t=await vT(`/admin/auth-keys`,`POST`,e.payload,{label:`create API key`,errorFallback:`Failed to create API key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,this.error=t.error;return}if(t.status===`error`){this.error=t.error,t.result&&t.result.status!==401&&console.error(`Failed to create API key:`,t.result.status,this.error);return}let n=t.result.data||{};this.issuedValue=n.value||``,this.formOpen=!0,this.copyState.reset(),this.form=kB(),this.fetchKeys()}finally{this.formSubmitting=!1}}openLabelsEditor(e){!e||this.labelsEditor.submitting||(this.labelsEditor={open:!0,id:e.id,name:e.name||``,value:(e.labels||[]).join(`, `),submitting:!1,error:``})}closeLabelsEditor(){!this.labelsEditor.open||this.labelsEditor.submitting||(this.labelsEditor=WB())}async submitLabelsEditor(){let e=this.labelsEditor;if(!e.open||e.submitting||!e.id)return;e.submitting=!0,e.error=``;let t={labels:AB(e.value)};try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/labels`,`PUT`,t,{label:`update API key labels`,errorFallback:`Failed to update labels.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,e.error=n.error;return}if(n.status===`error`){e.error=n.error,n.result&&n.result.status!==401&&console.error(`Failed to update auth key labels:`,n.result.status,e.error);return}q.success(`Labels updated for key "`+e.name+`".`),e.submitting=!1,this.closeLabelsEditor(),this.fetchKeys()}finally{e.submitting=!1}}async toggleDashboardAccess(e){if(!e||!e.active||this.dashboardAccessID)return;let t=!e.dashboard_access;this.dashboardAccessID=e.id;try{let n=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/dashboard-access`,`PUT`,{dashboard_access:t},{label:`update API key dashboard access`,errorFallback:`Failed to update dashboard access.`,unavailableMessage:`Auth keys feature is unavailable.`});if(n.status===`stale`)return;if(n.status===`unavailable`){this.available=!1,q.error(n.error);return}if(n.status===`error`){n.result&&n.result.status!==401&&console.error(`Failed to update auth key dashboard access:`,n.result.status,n.error),q.error(n.error);return}q.success(`Dashboard access `+(t?`granted to`:`revoked for`)+` key "`+e.name+`".`),this.fetchKeys()}finally{this.dashboardAccessID=``}}async deactivateKey(e){if(!(!e||!e.active)&&window.confirm(`Deactivate key "`+e.name+`"? This cannot be undone.`)){this.deactivatingID=e.id;try{let t=await vT(`/admin/auth-keys/`+encodeURIComponent(e.id)+`/deactivate`,`POST`,void 0,{label:`deactivate API key`,errorFallback:`Failed to deactivate key.`,unavailableMessage:`Auth keys feature is unavailable.`});if(t.status===`stale`)return;if(t.status===`unavailable`){this.available=!1,q.error(t.error);return}if(t.status===`error`){t.result&&t.result.status!==401&&console.error(`Failed to deactivate auth key:`,t.result.status,t.error),q.error(t.error);return}q.success(`Key "`+e.name+`" deactivated.`),this.fetchKeys()}finally{this.deactivatingID=``}}}},KB=R(``),qB=R(`

                          Store this key securely — it won’t be shown again.

                          `),JB=R(``),YB=R(``),XB=R(``),ZB=R(``),QB=R(`
                          `);function $B(e,t){E(t,!0);{let t=O(()=>GB.issuedValue?``:GB.error),n=O(()=>GB.issuedValue?`Done, I’ve stored it`:`Create API Key`),r=O(()=>GB.issuedValue?Va:po);bE(e,{get open(){return GB.formOpen},title:`Create API Key`,ariaLabel:`API key editor`,get error(){return I(t)},get submitting(){return GB.formSubmitting},get submitLabel(){return I(n)},submittingLabel:`Creating...`,get submitIcon(){return I(r)},cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>GB.closeForm(),onsubmit:()=>GB.issuedValue?GB.dismissIssuedKey():GB.submitForm(),children:(e,t)=>{var n=Qr(),r=N(n),i=e=>{var t=qB(),n=P(M(t),2),r=M(n),i=M(r,!0);T(r),dL(P(r,2),{get state(){return GB.copyState},onclick:()=>GB.copyIssuedValue()}),T(n);var a=P(n,2),o=e=>{z(e,KB())};V(a,e=>{GB.copyState.error&&e(o)}),T(t),F(()=>B(i,GB.issuedValue)),z(e,t)},a=e=>{var t=QB(),n=M(t),r=M(n),i=P(M(r),2);na(i),T(r);var a=P(r,2),o=P(M(a),2);na(o),T(a),T(n);var s=P(n,2),c=M(s);qS(c,{copyId:`auth-key-user-path-help-copy`,label:`API key user path help`,title:e=>{z(e,JB())},help:e=>{Ue(),z(e,Zr(`When set, this key overrides the configured user path request - header for audit logging and downstream request context.`))},$$slots:{title:!0,help:!0}});var l=P(c,2);na(l),T(s);var u=P(s,2),d=M(u);qS(d,{copyId:`auth-key-labels-help-copy`,label:`API key labels help`,title:e=>{z(e,YB())},help:e=>{Ue(),z(e,Zr(`Every request authenticated with this key gets these labels, in - addition to any labels from tagging headers. Labels show up in - usage analytics, the request log, and audit logs.`))},$$slots:{title:!0,help:!0}});var f=P(d,2);na(f),T(u);var p=P(u,2),m=M(p);qS(m,{copyId:`auth-key-dashboard-access-help-copy`,label:`API key dashboard access help`,title:e=>{z(e,XB())},help:e=>{Ue(),z(e,Zr(`When off, this key is denied the dashboard and every /admin API - endpoint. Model endpoints and GET /v1/usage stay available to - the key. The master key always has dashboard access.`))},$$slots:{title:!0,help:!0}});var h=P(m,2),g=M(h);na(g),Ue(2),T(h),T(p),SE(P(p,2),{id:`auth-key-description`,label:`Description (optional)`,children:(e,t)=>{var n=ZB();ft(n),da(n,()=>GB.form.description,e=>GB.form.description=e),z(e,n)},$$slots:{default:!0}}),T(t),da(i,()=>GB.form.name,e=>GB.form.name=e),da(o,()=>GB.form.expires_at,e=>GB.form.expires_at=e),da(l,()=>GB.form.user_path,e=>GB.form.user_path=e),da(f,()=>GB.form.labels,e=>GB.form.labels=e),fa(g,()=>GB.form.dashboard_access,e=>GB.form.dashboard_access=e),z(e,t)};V(r,e=>{GB.issuedValue?e(i):e(a,-1)}),z(e,n)},$$slots:{default:!0}})}D()}var eV=R(`

                          `),tV=R(`

                          Applies to new requests made with this key. Leave empty to remove all labels.

                          `,1);function nV(e,t){E(t,!0),bE(e,{get open(){return GB.labelsEditor.open},title:`Edit Labels`,ariaLabel:`API key labels editor`,get error(){return GB.labelsEditor.error},get submitting(){return GB.labelsEditor.submitting},submitLabel:`Save Labels`,cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>GB.closeLabelsEditor(),onsubmit:()=>GB.submitLabelsEditor(),headerHint:e=>{var t=eV(),n=M(t,!0);T(t),F(()=>B(n,GB.labelsEditor.name)),z(e,t)},children:(e,t)=>{SE(e,{id:`auth-key-labels-edit`,label:`Labels (comma-separated)`,children:(e,t)=>{var n=tV(),r=N(n);na(r),Ue(2),da(r,()=>GB.labelsEditor.value,e=>GB.labelsEditor.value=e),z(e,n)},$$slots:{default:!0}})},$$slots:{headerHint:!0,default:!0}}),D()}var rV=R(` `),iV=R(`
                          `),aV=R(``),oV=R(`Expired`),sV=R(` `),cV=R(` `,1),lV=R(`Deactivated`),uV=R(`
                          `),dV=R(`
                          NameDescriptionUser PathLabelsTokenDashboard Access ExpiresCreated
                          `);function fV(e,t){E(t,!0);var n=dV(),r=M(n),i=M(r),a=M(i),o=P(M(a),5),s=M(o);G(P(M(s)),{get icon(){return to},width:`13`,height:`13`}),T(s),T(o),Ue(3),T(a),T(i);var c=P(i);H(c,21,()=>GB.visibleKeys,e=>e.id,(e,t)=>{var n=uV();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i),s=M(o,!0);T(o);var c=P(o),l=M(c,!0);T(c);var u=P(c),d=M(u),f=e=>{var n=iV();H(n,20,()=>I(t).labels||[],e=>e,(e,t)=>{var n=rV(),r=M(n,!0);T(n),F(e=>{Hi(n,e),B(r,t)},[()=>Uy(t)]),z(e,n)}),T(n),z(e,n)},p=e=>{z(e,aV())};V(d,e=>{(I(t).labels||[]).length>0?e(f):e(p,-1)}),T(u);var m=P(u),h=M(m),g=M(h,!0);T(h),T(m);var _=P(m),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x),C=e=>{var n=sV(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{z(e,oV())},s=O(()=>PB(I(t)));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>pc(I(t).expires_at)]),z(e,n)},w=e=>{z(e,Zr(`—`))};V(S,e=>{I(t).expires_at?e(C):e(w,-1)}),T(x);var ee=P(x),te=M(ee,!0);T(ee);var ne=P(ee),re=M(ne),ie=M(re),ae=e=>{var n=cV(),r=N(n);{let e=O(()=>(I(t).dashboard_access?`Revoke dashboard access for API key `:`Grant dashboard access to API key `)+I(t).name),n=O(()=>!!GB.dashboardAccessID);gT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>GB.toggleDashboardAccess(I(t)),get disabled(){return I(n)},children:(e,n)=>{{let n=O(()=>I(t).dashboard_access?wo:Co);G(e,{get icon(){return I(n)},class:`table-icon-svg`})}},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>`Edit labels for API key `+I(t).name);gT(i,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>GB.openLabelsEditor(I(t)),children:(e,t)=>{G(e,{get icon(){return uo},class:`table-icon-svg`})},$$slots:{default:!0}})}var a=P(i,2);{let e=O(()=>(GB.deactivatingID===I(t).id?`Deactivating API key `:`Deactivate API key `)+I(t).name),n=O(()=>GB.deactivatingID===I(t).id);gT(a,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>GB.deactivateKey(I(t)),get disabled(){return I(n)},children:(e,t)=>{G(e,{get icon(){return mo},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)},oe=e=>{var n=lV();F(e=>W(n,`title`,e),[()=>I(t).deactivated_at?`Deactivated on `+mc(I(t).deactivated_at):`Deactivated`]),z(e,n)},se=O(()=>FB(I(t)));V(ie,e=>{I(t).active?e(ae):I(se)&&e(oe,1)}),T(re),T(ne),T(n),F((e,i,o)=>{r=U(n,1,`svelte-nf0ldb`,null,r,e),B(a,I(t).name),B(s,I(t).description||`—`),B(l,I(t).user_path||`—`),B(g,I(t).redacted_value),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).dashboard_access,"auth-key-status-inactive":!I(t).dashboard_access}),B(b,I(t).dashboard_access?`Allowed`:`Denied`),W(x,`title`,i),B(te,o)},[()=>({"auth-key-row-deactivated":FB(I(t))}),()=>I(t).expires_at?mc(I(t).expires_at):``,()=>ds.formatTimestamp(I(t).created_at)]),z(e,n)}),T(c),T(r),T(n),z(e,n),D()}var pV=R(``),mV=R(`
                          API key management is unavailable.
                          `),hV=R(``),gV=R(`

                          Managed API keys authenticate requests to the gateway. Deactivation is - permanent — create a new key if access needs to be restored.

                          `),_V=R(`
                          `),vV=R(`
                          `),yV=R(`

                          `),bV=R(`

                          No API keys yet. Issue a key to get started.

                          `),xV=R(`
                          `);function SV(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`auth-keys`&&GB.fetchKeys()});var n=xV(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=pV();G(M(t),{get icon(){return po},class:`table-icon-svg`}),Ue(2),T(t),F(()=>t.disabled=GB.formSubmitting),L(`click`,t,()=>{GB.formSubmitting||GB.openForm()}),z(e,t)};V(a,e=>{GB.available&&!K.authError&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,mV())};V(s,e=>{!GB.available&&!K.authError&&e(c)});var l=P(s,2),u=e=>{var t=hV(),n=M(t,!0);T(t),F(()=>B(n,GB.error)),z(e,t)};V(l,e=>{GB.error&&!K.authError&&!GB.formOpen&&e(u)});var d=P(l,2),f=e=>{z(e,gV())};V(d,e=>{GB.available&&!K.authError&&e(f)});var p=P(d,2);$B(p,{});var m=P(p,2);nV(m,{});var h=P(m,2),g=e=>{var t=_V();SS(M(t),{size:18,label:`Loading API keys`}),T(t),z(e,t)};V(h,e=>{GB.loading&&GB.keys.length===0&&e(g)});var _=P(h,2),v=e=>{var t=vV(),n=M(t);yw(M(n),{placeholder:`Filter by name, description, user path, label, or token...`,label:`Filter API keys by name, description, user path, label, or token`,get value(){return GB.filter},set value(e){GB.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i);na(a);var o=P(a,2),s=P(M(o)),c=e=>{var t=Zr();F(()=>B(t,`(${GB.inactiveCount??``})`)),z(e,t)};V(s,e=>{GB.inactiveCount>0&&e(c)}),T(o),T(i),T(r),T(t),fa(a,()=>GB.showInactive,e=>GB.showInactive=e),z(e,t)};V(_,e=>{GB.keys.length>0&&GB.available&&e(v)});var y=P(_,2),b=e=>{fV(e,{})};V(y,e=>{GB.visibleKeys.length>0&&GB.available&&e(b)});var x=P(y,2),S=e=>{var t=yV(),n=M(t);T(t),F(()=>B(n,`No API keys match the current filter.${GB.inactiveCount>0&&!GB.showInactive?` `+GB.inactiveCount+` inactive `+(GB.inactiveCount===1?`key is`:`keys are`)+` hidden.`:``}`)),z(e,t)};V(x,e=>{GB.keys.length>0&&GB.visibleKeys.length===0&&GB.available&&e(S)});var C=P(x,2),w=e=>{z(e,bV())};V(C,e=>{GB.keys.length===0&&!GB.loading&&!K.authError&&!GB.error&&GB.available&&e(w)}),T(n),z(e,n),D()}Hr([`click`]);var CV=R(`

                          Timezone

                          `),wV=R(``),TV=R(``),EV=R(`
                          `,1);function DV(e,t){E(t,!0);function n(){ds.saveOverride(),K.refresh()}function r(){ds.clearOverride(),K.refresh()}var i=EV(),a=N(i);qS(M(a),{copyId:`timezone-help-copy`,label:`timezone help`,text:`Day-based analytics, charts, and date filters use your effective timezone. Usage and audit logs keep UTC in the hover title while rendering row timestamps in your effective timezone.`,title:e=>{z(e,CV())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=P(M(s),2),l=M(c),u=M(l);T(l),l.value=l.__value=``,H(P(l),17,()=>ds.options,e=>e.value,(e,t)=>{var n=wV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(c),T(s),T(o);var d=P(o,2),f=M(d),p=e=>{var t=TV();L(`click`,t,r),z(e,t)};V(f,e=>{ds.override&&e(p)}),T(d),F(e=>B(u,`Automatic (${e??``})`),[()=>ds.detectedTimeZoneLabel()]),Vr(`focus`,c,()=>ds.ensureOptions()),L(`change`,c,n),Gi(c,()=>ds.override,e=>ds.override=e),z(e,i),D()}Hr([`change`,`click`]);var OV=R(``),kV=R(`

                          Failover

                          `,1);function AV(e,t){E(t,!0);let n=O(()=>Z.failoverSaving||Z.failoverGenerating||Z.failoverDraftSaving||!Z.failoverAvailable||!Z.failoverEnabled());var r=kV(),i=N(r),a=P(M(i),2),o=M(a),s=M(o);G(s,{get icon(){return Po},class:`form-action-icon`});var c=P(s,2),l=M(c,!0);T(c),T(o);var u=P(o,2);G(M(u),{get icon(){return Ao},class:`form-action-icon`}),Ue(2),T(u),T(a),T(i);var d=P(i,2),f=M(d),p=e=>{var t=OV(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(f,e=>{Z.failoverError&&e(p)}),T(d),fj(P(d,2),{}),F(()=>{o.disabled=I(n),B(l,Z.failoverGenerating?`Generating...`:`Generate failover models automatically`),u.disabled=I(n)}),L(`click`,o,()=>Z.generateFailoverRules()),L(`click`,u,()=>Z.openFailoverResetDialog()),z(e,r),D()}Hr([`click`]);function jV(){return{daily_reset_hour:0,daily_reset_minute:0,weekly_reset_weekday:1,weekly_reset_hour:0,weekly_reset_minute:0,monthly_reset_day:1,monthly_reset_hour:0,monthly_reset_minute:0}}function MV(e,t){let n=t||{},r=(e,t)=>{if(e===``)return t;let n=Number(e);return Number.isFinite(n)&&Number.isInteger(n)?Math.trunc(n):t},i=(e,t)=>r(n[e],t),a=(t,n)=>e?r(e[t],n):n;return{daily_reset_hour:a(`daily_reset_hour`,i(`daily_reset_hour`,0)),daily_reset_minute:a(`daily_reset_minute`,i(`daily_reset_minute`,0)),weekly_reset_weekday:a(`weekly_reset_weekday`,i(`weekly_reset_weekday`,1)),weekly_reset_hour:a(`weekly_reset_hour`,i(`weekly_reset_hour`,0)),weekly_reset_minute:a(`weekly_reset_minute`,i(`weekly_reset_minute`,0)),monthly_reset_day:a(`monthly_reset_day`,i(`monthly_reset_day`,1)),monthly_reset_hour:a(`monthly_reset_hour`,i(`monthly_reset_hour`,0)),monthly_reset_minute:a(`monthly_reset_minute`,i(`monthly_reset_minute`,0))}}function NV(){return[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}]}var PV=R(`

                          Budget Resets

                          `),FV=R(``),IV=R(`

                          If the selected day does not exist in a month, the reset runs on - the last day of that month.

                          `),LV=R(``),RV=R(``),zV=R(`
                          Monthly
                          Weekly
                          Daily
                          `,1);function BV(e,t){E(t,!0);let n=k(j(jV())),r=k(!1),i=k(!1),a=k(``),o=k(!1),s=O(()=>Ss.budgetsVisible());async function c(){if(await Ss.ensureLoaded(),!Ss.budgetsVisible()){A(a,``);return}A(r,!0),A(a,``);try{let e=await _s(`/admin/budgets/settings`,{label:`budget settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load budget settings.`);return}A(n,MV(e.data,I(n)),!0)}catch(e){console.error(`Failed to fetch budget settings:`,e),A(a,`Unable to load budget settings.`)}finally{A(r,!1)}}async function l(){if(!I(i)){A(i,!0);try{let e=await vs(`/admin/budgets/settings`,`PUT`,MV(I(n),I(n)),{label:`budget settings`});if(e.stale)return;if(!e.ok){q.error(`Unable to save budget settings.`);return}A(n,MV(e.data,I(n)),!0),A(a,``),q.success(`Budget settings saved.`)}catch(e){console.error(`Failed to save budget settings:`,e),q.error(`Unable to save budget settings.`)}finally{A(i,!1)}}}An(()=>{K.refreshTick,c()});var u=Qr(),d=N(u),f=e=>{var t=zV(),s=N(t),c=M(s);qS(c,{copyId:`budget-settings-help-copy`,label:`budget help`,text:`Budget reset anchors are stored in the database and evaluated in UTC. Hourly budgets reset at the top of each hour.`,title:e=>{z(e,PV())},$$slots:{title:!0}});var u=P(c,2),d=M(u),f=P(M(d),2),p=M(f);qS(p,{copyId:`budget-monthly-day-help-copy`,label:`day of month help`,external:!0,get open(){return I(o)},set open(e){A(o,e,!0)},title:e=>{z(e,FV())},$$slots:{title:!0}});var m=P(p,2);na(m),T(f);var h=P(f,2),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=M(y),x=e=>{z(e,IV())};V(b,e=>{I(o)&&e(x)}),T(y),T(d);var S=P(d,2),C=P(M(S),2),w=P(M(C),2);H(w,21,NV,e=>e.value,(e,t)=>{var n=LV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(w),T(C);var ee=P(C,2),te=P(M(ee),2);na(te),T(ee);var ne=P(ee,2),re=P(M(ne),2);na(re),T(ne),Ue(2),T(S);var ie=P(S,2),ae=P(M(ie),4),oe=P(M(ae),2);na(oe),T(ae);var se=P(ae,2),ce=P(M(se),2);na(ce),T(se),Ue(2),T(ie),T(u);var le=P(u,2),ue=M(le);G(M(ue),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(ue);var de=P(ue,2),fe=e=>{SS(e,{size:16,label:`Loading budget settings`})};V(de,e=>{I(r)&&e(fe)}),T(le),T(s);var pe=P(s,2),me=M(pe),he=e=>{var t=RV(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(me,e=>{I(a)&&e(he)}),T(pe),F(()=>{ue.disabled=I(i)||I(r),W(ue,`aria-busy`,I(i)?`true`:`false`)}),da(m,()=>I(n).monthly_reset_day,e=>I(n).monthly_reset_day=e),da(g,()=>I(n).monthly_reset_hour,e=>I(n).monthly_reset_hour=e),da(v,()=>I(n).monthly_reset_minute,e=>I(n).monthly_reset_minute=e),Gi(w,()=>I(n).weekly_reset_weekday,e=>I(n).weekly_reset_weekday=e),da(te,()=>I(n).weekly_reset_hour,e=>I(n).weekly_reset_hour=e),da(re,()=>I(n).weekly_reset_minute,e=>I(n).weekly_reset_minute=e),da(oe,()=>I(n).daily_reset_hour,e=>I(n).daily_reset_hour=e),da(ce,()=>I(n).daily_reset_minute,e=>I(n).daily_reset_minute=e),L(`click`,ue,l),z(e,t)};V(d,e=>{I(s)&&e(f)}),z(e,u),D()}Hr([`click`]);var VV=R(`

                          Reset All Budgets

                          Start new budget periods for every configured budget without changing - the limits.

                          `);function HV(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=VV(),n=P(M(t),2),r=M(n);G(M(r),{get icon(){return go},class:`form-action-icon`}),Ue(2),T(r),T(n),T(t),F(()=>r.disabled=Y.resetAllLoading),L(`click`,r,()=>Y.openResetDialog()),z(e,t)},a=O(()=>Ss.budgetsVisible());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}Hr([`click`]);function UV(){return{header:``,prefix:``,do_not_pass:!1,delimiter:``,managed:!1}}function WV(e){return(e&&Array.isArray(e.headers)?e.headers:[]).map(e=>({header:typeof e.header==`string`?e.header:``,prefix:typeof e.prefix==`string`?e.prefix:``,do_not_pass:e.do_not_pass===!0,delimiter:typeof e.delimiter==`string`&&e.delimiter!==`,`?e.delimiter:``,managed:e.managed===!0}))}function GV(e){return{headers:(Array.isArray(e)?e:[]).filter(e=>!e.managed&&e.header.trim()!==``).map(e=>({header:e.header.trim(),prefix:e.prefix,do_not_pass:e.do_not_pass,delimiter:e.delimiter}))}}function KV(e){return e&&e.error&&e.error.message?e.error.message:``}var qV=R(`

                          Tagging based on headers

                          `),JV=R(`config`),YV=R(``),XV=R(`
                          `),ZV=R(`

                          No tagging headers configured. Requests are not labelled.

                          `),QV=R(``),$V=R(`
                          `,1);function eH(e,t){E(t,!0);let n=k(j([])),r=k(!0),i=k(!1),a=k(!1),o=k(``);function s(){I(n).push(UV())}function c(e){let t=I(n)[e];!t||t.managed||I(n).splice(e,1)}async function l(){A(i,!0),A(o,``);try{let e=await _s(`/admin/tagging/settings`,{label:`tagging settings`});if(e.stale)return;if(!e.ok){A(o,`Unable to load tagging settings.`);return}A(n,WV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0)}catch(e){console.error(`Failed to fetch tagging settings:`,e),A(o,`Unable to load tagging settings.`)}finally{A(i,!1)}}async function u(){if(!(I(a)||!I(r))){A(a,!0);try{let e=await vs(`/admin/tagging/settings`,`PUT`,GV(I(n)),{label:`tagging settings`});if(e.stale)return;if(!e.ok){q.error(e.status!==401&&KV(e.data)||`Unable to save tagging settings.`);return}A(n,WV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0),A(o,``),q.success(`Tagging settings saved.`)}catch(e){console.error(`Failed to save tagging settings:`,e),q.error(`Unable to save tagging settings.`)}finally{A(a,!1)}}}An(()=>{K.refreshTick,l()});var d=$V(),f=N(d),p=M(f);qS(p,{copyId:`tagging-settings-help-copy`,label:`tagging help`,text:`Each request is labelled from the listed headers; labels land in usage tracking and audit logs. A header value can carry several labels split by the delimiter (default: comma). The prefix is trimmed from each label only — the header itself is forwarded unchanged unless 'Do not pass' is checked. Rows marked CONFIG come from config.yaml or TAGGING_HEADER_* env vars and are read-only here.`,title:e=>{z(e,qV())},$$slots:{title:!0}});var m=P(p,2),h=M(m);H(h,17,()=>I(n),oi,(e,t,n)=>{var i=XV(),a=M(i),o=M(a);W(o,`for`,`tagging-header-`+n);var s=P(o,2);na(s),W(s,`id`,`tagging-header-`+n),T(a);var l=P(a,2),u=M(l);W(u,`for`,`tagging-prefix-`+n);var d=P(u,2);na(d),W(d,`id`,`tagging-prefix-`+n),T(l);var f=P(l,2),p=M(f);W(p,`for`,`tagging-delimiter-`+n);var m=P(p,2);na(m),W(m,`id`,`tagging-delimiter-`+n),T(f);var h=P(f,2),g=M(h);na(g),Ue(2),T(h);var _=P(h,2),v=M(_),y=e=>{z(e,JV())},b=e=>{var i=YV();F(()=>{i.disabled=!I(r),W(i,`aria-label`,`Remove tagging header `+(I(t).header||n+1))}),L(`click`,i,()=>c(n)),z(e,i)};V(v,e=>{I(t).managed?e(y):e(b,-1)}),T(_),T(i),F(()=>{s.disabled=I(t).managed||!I(r),d.disabled=I(t).managed||!I(r),m.disabled=I(t).managed||!I(r),g.disabled=I(t).managed||!I(r)}),da(s,()=>I(t).header,e=>I(t).header=e),da(d,()=>I(t).prefix,e=>I(t).prefix=e),da(m,()=>I(t).delimiter,e=>I(t).delimiter=e),fa(g,()=>I(t).do_not_pass,e=>I(t).do_not_pass=e),z(e,i)});var g=P(h,2),_=e=>{SS(e,{size:16,label:`Loading tagging settings`})};V(g,e=>{I(i)&&e(_)});var v=P(g,2),y=e=>{z(e,ZV())};V(v,e=>{!I(i)&&I(n).length===0&&e(y)}),T(m);var b=P(m,2),x=M(b);G(M(x),{get icon(){return po},class:`form-action-icon`}),Ue(2),T(x);var S=P(x,2);G(M(S),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(S),T(b),T(f);var C=P(f,2),w=M(C),ee=e=>{var t=QV(),n=M(t,!0);T(t),F(()=>B(n,I(o))),z(e,t)};V(w,e=>{I(o)&&e(ee)}),T(C),F(()=>{x.disabled=!I(r)||I(a)||I(i),S.disabled=!I(r)||I(a)||I(i),W(S,`aria-busy`,I(a)?`true`:`false`)}),L(`click`,x,s),L(`click`,S,u),z(e,d),D()}Hr([`click`]);function tH(e){let t=e||{};if(t.selectedPreset)return{days:parseInt(t.selectedPreset,10)||30};let n=t.customStartDate?fc(t.customStartDate):``,r=t.customEndDate||t.today||null;return{start_date:n,end_date:r?fc(r):``}}function nH(e,t,n,r){return{...tH(e),user_path:String(t||``).trim(),selector:String(n||``).trim(),confirmation:r}}function rH(e){let t=Number(e&&e.matched||0),n=Number(e&&e.recalculated||0),r=Number(e&&e.without_pricing||0),i=`Pricing recalculated for `+n+` of `+t+` usage record`+(t===1?``:`s`)+`.`;return r>0&&(i+=` `+r+` usage record`+(r===1?` still lacks`:`s still lack`)+` pricing metadata.`),i}var iH=R(`

                          Usage Pricing Recalculation

                          `),aH=R(`
                          `);function oH(e,t){E(t,!0);let n=k(``),r=k(``),i=k(!1),a=O(()=>Ss.booleanFlag(`USAGE_PRICING_RECALCULATION_ENABLED`,!1));function o(){if(!I(a)){q.error(`Usage pricing recalculation is unavailable.`);return}I(i)||Rs.open({title:`Recalculate Pricing`,titleId:`pricingRecalculateDialogTitle`,inputId:`pricing-recalculate-confirmation`,requiredText:`recalculate`,confirmLabel:`Recalculate Pricing`,icon:Ia,dialogClass:`pricing-recalculate-dialog`,message:`Stored usage cost fields matching the selected filters will be overwritten.`,onConfirm:()=>s()})}async function s(){if(!I(a)){q.error(`Usage pricing recalculation is unavailable.`);return}if(!I(i)){A(i,!0);try{let e=await vs(`/admin/usage/recalculate-pricing`,`POST`,nH({selectedPreset:Mc.selectedPreset,customStartDate:Mc.customStartDate,customEndDate:Mc.customEndDate,today:ds.todayDate()},I(n),I(r),`recalculate`),{label:`pricing recalculation`});if(e.stale)return;if(!e.ok){Rs.error=`Unable to recalculate pricing.`;return}Rs.close(),q.success(rH(e.data)),Rc.fetchUsage()}catch(e){console.error(`Failed to recalculate pricing:`,e),Rs.error=`Unable to recalculate pricing.`}finally{A(i,!1)}}}var c=Qr(),l=N(c),u=e=>{var t=aH(),s=M(t);qS(s,{copyId:`pricing-recalculate-help-copy`,label:`pricing recalculation help`,text:`Recalculate stored input, output, total, and Pro Saved costs from the current model pricing metadata. This overwrites matching historical cost fields. Filters are applied to the selected date range, user path subtree, and provider/model selector or alias.`,title:e=>{z(e,iH())},$$slots:{title:!0}});var c=P(s,2),l=M(c),u=P(M(l),2);tl(M(u),{}),T(u),T(l);var d=P(l,2),f=P(M(d),2);na(f),T(d);var p=P(d,2),m=P(M(p),2);na(m),T(p),T(c);var h=P(c,2),g=M(h);G(M(g),{get icon(){return Ia},class:`form-action-icon`}),Ue(2),T(g),T(h),T(t),F(()=>{g.disabled=I(i)||!I(a),W(g,`aria-busy`,I(i)?`true`:`false`)}),da(f,()=>I(n),e=>A(n,e)),da(m,()=>I(r),e=>A(r,e)),L(`click`,g,o),z(e,t)};V(l,e=>{I(a)&&e(u)}),z(e,c),D()}Hr([`click`]);function sH(e){return String(e&&e.status||`ok`).toLowerCase()}function cH(e){if(!e||typeof e!=`object`)return`Runtime refresh completed.`;let t=Number(e.model_count||0),n=Number(e.provider_count||0),r=sH(e);return(r===`ok`?`Runtime refreshed.`:r===`partial`?`Runtime refresh completed with warnings.`:`Runtime refresh failed.`)+` `+t+` model`+(t===1?``:`s`)+` across `+n+` provider`+(n===1?``:`s`)+`.`}function lH(e){return!!e&&sH(e)===`ok`}function uH(e){let t=e&&e.steps;return Array.isArray(t)?t:[]}function dH(e){let t=String(e&&e.name||``).replace(/_/g,` `),n=String(e&&e.status||``).trim(),r=String(e&&(e.error||e.message)||``).trim();return t?r?t+`: `+n+` - `+r:t+`: `+n:r||n||``}var fH=R(`

                          Runtime Refresh

                          `),pH=R(`
                        • `),mH=R(`
                            `),hH=R(`
                            `,1);function gH(e,t){E(t,!0);let n=k(!1),r=k(null);async function i(){if(!I(n)){A(n,!0),A(r,null);try{let e=await vs(`/admin/runtime/refresh`,`POST`,void 0,{label:`runtime refresh`});if(e.stale)return;if(!e.ok){q.error(`Runtime refresh failed.`);return}A(r,e.data&&typeof e.data==`object`?e.data:null,!0),lH(I(r))?q.success(cH(I(r))):q.error(cH(I(r))),K.refresh()}catch(e){console.error(`Failed to refresh runtime:`,e),q.error(`Runtime refresh failed.`)}finally{A(n,!1)}}}var a=hH(),o=N(a),s=M(o);qS(s,{copyId:`runtime-refresh-help-copy`,label:`runtime refresh help`,text:`Pull the latest model metadata, provider inventory, API keys, aliases, model access rules, guardrails, and workflows.`,title:e=>{z(e,fH())},$$slots:{title:!0}});var c=P(s,2),l=M(c);let u;G(M(l),{get icon(){return ho},class:`settings-refresh-icon`}),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=M(d),p=e=>{var t=mH();H(t,21,()=>uH(I(r)),e=>e.name,(e,t)=>{var n=pH(),r=M(n,!0);T(n),F(e=>{U(n,1,`runtime-refresh-step is-${I(t).status??``}`,`svelte-yeq2mp`),B(r,e)},[()=>dH(I(t))]),z(e,n)}),T(t),z(e,t)},m=O(()=>uH(I(r)).length>0);V(f,e=>{I(m)&&e(p)}),T(d),F(()=>{u=U(l,1,`btn btn-primary btn-with-icon settings-refresh-btn`,null,u,{"is-refreshing":I(n)}),l.disabled=I(n),W(l,`aria-busy`,I(n)?`true`:`false`)}),L(`click`,l,i),z(e,a),D()}Hr([`click`]);var _H=R(``),vH=R(`

                            `),yH=R(`

                            `),bH=R(``),xH=R(`
                            `),SH=R(`

                            AI Processing

                            `);function CH(e,t){E(t,!0);let n=k(j([])),r=k(!1),i=k(``),a=k(``);async function o(){A(r,!0),A(a,``);try{let e=await _s(`/admin/runtime/settings`,{label:`runtime settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load runtime settings.`);return}A(n,Array.isArray(e.data?.settings)?e.data.settings:[],!0)}catch(e){console.error(`Failed to load runtime settings:`,e),A(a,`Unable to load runtime settings.`)}finally{A(r,!1)}}async function s(e,t,r){if(!(e.locked||I(i))){A(i,e.key,!0);try{let i=await vs(`/admin/runtime/settings/${encodeURIComponent(e.key)}`,`PUT`,{value:t},{label:`save ${e.label}`});if(i.stale){r.value=e.value;return}if(!i.ok){r.value=e.value,q.error(`Unable to save ${e.label}.`);return}A(n,I(n).map(t=>t.key===e.key?i.data:t),!0),q.success(`${e.label} saved.`)}catch(t){r.value=e.value,console.error(`Failed to save runtime setting:`,t),q.error(`Unable to save ${e.label}.`)}finally{A(i,``)}}}An(()=>{K.refreshTick,o()});var c=Qr(),l=N(c),u=e=>{var t=SH(),o=M(t),c=P(M(o),2),l=e=>{var t=_H(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(c,e=>{I(a)&&e(l)}),T(o);var u=P(o,2);H(u,21,()=>I(n),e=>e.key,(e,t)=>{var n=xH(),r=M(n),a=M(r),o=M(a,!0);T(a);var c=P(a,2),l=e=>{var n=vH(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(c,e=>{I(t).description&&e(l)});var u=P(c,2),d=e=>{var n=yH(),r=M(n);T(n),F(()=>B(r,`Managed by ${(I(t).managed_by||`environment`)??``}`)),z(e,n)};V(u,e=>{I(t).locked&&e(d)}),T(r);var f=P(r,2);H(f,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=bH(),r=M(n,!0);T(n);var i={};F(()=>{W(n,`title`,I(t).description||``),B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(f);var p;Wi(f),T(n),F(()=>{W(a,`for`,`runtime-setting-${I(t).key}`),B(o,I(t).label),W(f,`id`,`runtime-setting-${I(t).key}`),f.disabled=I(t).locked||I(i)!==``,p!==(p=I(t).value)&&(f.value=(f.__value=I(t).value)??``,Ui(f,I(t).value))}),L(`change`,f,e=>s(I(t),e.currentTarget.value,e.currentTarget)),z(e,n)}),T(u),T(t),F(()=>W(u,`aria-busy`,I(r)?`true`:`false`)),z(e,t)};V(l,e=>{(I(n).length>0||I(a))&&e(u)}),z(e,c),D()}Hr([`change`]);var wH=R(`
                            `);function TH(e,t){E(t,!0),An(()=>{K.refreshTick,Jo.page===`settings`&&(ds.ensureOptions(),Ss.ensureLoaded())});var n=wH(),r=P(M(n),2),i=M(r);DV(i,{});var a=P(i,2);AV(a,{});var o=P(a,2);BV(o,{});var s=P(o,2);HV(s,{});var c=P(s,2);eH(c,{});var l=P(c,2);CH(l,{});var u=P(l,2);oH(u,{}),gH(P(u,2),{}),T(r);var d=P(r,2),f=M(d,!0);T(d),T(n),F(e=>B(f,e),[()=>Uo()]),z(e,n),D()}var EH=R(`
                            `),DH=R(`
                             
                            `),OH=R(`
                             
                            `),kH=R(`
                             
                            `),AH=R(`
                            `),jH=R(`
                            `,1),MH=R(`
                            `);function NH(e,t){E(t,!0);let n=ya(t,`showPromptCache`,3,!0),r=O(()=>t.msg.role===`function_call`||t.msg.role===`function_result`);function i(e){return(Math.max(0,Math.min(1,Number(e||0)))*100).toFixed(1)+`%`}function a(e){let t=Math.max(0,Math.min(1,Number(e||0)));return t>0?Math.round(t*100)+`% of this visible prompt item is estimated provider-cached`:void 0}function o(e){return e.role===`function_call`?(e.toolCalls||[]).map(e=>e.name+`()`).join(`, `):(e.functionName?e.functionName+`: `:``)+e.text}var s=MH();let c;var l=M(s),u=e=>{var r=DH(),i=M(r),s=M(i),c=M(s,!0);T(s);var l=P(s,2),u=M(l,!0);T(l);var d=P(l,2),f=M(d,!0);T(d),T(i);var p=P(i,2),m=e=>{var n=EH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${t.msg.functionCallID??``}`)),z(e,n)};V(p,e=>{t.msg.functionCallID&&e(m)});var h=P(p,2),g=e=>{var n=Qr();H(N(n),17,()=>t.msg.toolCalls,oi,(e,n)=>{var r=Qr(),i=N(r),a=e=>{var r=EH(),i=M(r);T(r),F(()=>B(i,`Call ID${t.msg.toolCalls.length>1?` (`+I(n).name+`)`:``}: ${I(n).id??``}`)),z(e,r)};V(i,e=>{I(n).id&&e(a)}),z(e,r)}),z(e,n)};V(h,e=>{t.msg.role===`function_call`&&t.msg.toolCalls&&e(g)});var _=P(h,2),v=M(_,!0);T(_),T(r),F((e,n,i,a)=>{W(r,`title`,e),B(c,t.msg.roleLabel),B(u,n),B(f,i),B(v,a)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>o(t.msg),()=>ds.formatTimestamp(t.msg.timestamp),()=>JI(t.msg)]),z(e,r)},d=e=>{var r=jH(),i=N(r),o=M(i),s=M(o,!0);T(o);var c=P(o,2),l=M(c,!0);T(c),T(i);var u=P(i,2),d=e=>{var r=OH(),i=M(r,!0);T(r),F(e=>{W(r,`title`,e),B(i,t.msg.text)},[()=>n()?a(t.msg.promptCacheRatio):void 0]),z(e,r)};V(u,e=>{t.msg.text&&e(d)});var f=P(u,2),p=e=>{var n=AH();H(n,23,()=>t.msg.toolCalls,(e,t)=>e.name+`-`+t,(e,t)=>{var n=kH(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(r);var c=P(r,2),l=e=>{var n=EH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${I(t).id??``}`)),z(e,n)};V(c,e=>{I(t).id&&e(l)});var u=P(c,2),d=M(u,!0);T(u),T(n),F((e,n)=>{B(a,I(t).name+`()`),B(s,e),B(d,n)},[()=>YI(I(t))||`No arguments`,()=>YI(I(t))||`No arguments`]),z(e,n)}),T(n),z(e,n)};V(f,e=>{t.msg.toolCalls&&e(p)}),F((e,n)=>{W(i,`title`,e),B(s,t.msg.roleLabel),B(l,n)},[()=>n()?a(t.msg.promptCacheRatio):void 0,()=>ds.formatTimestamp(t.msg.timestamp)]),z(e,r)};V(l,e=>{I(r)?e(u):e(d,-1)}),T(s),F(e=>{U(s,1,Fi([I(r)?`chat-function-note`:`chat-message`,t.msg.roleClass,{"is-anchor":t.msg.isAnchor,"is-after-anchor":t.msg.isAfterAnchor}]),`svelte-12s99s5`),W(s,`data-conversation-anchor`,t.msg.isAnchor?`true`:void 0),W(s,`data-entry-id`,t.msg.entryID),c=Hi(s,``,c,e)},[()=>({"--prompt-cache-fill":i(t.msg.promptCacheRatio),"--prompt-cache-visibility":n()&&t.msg.promptCacheRatio>0?`1`:`0`})]),z(e,s),D()}function PH(e,t=0){let n=Math.max(0,LH(e)-Math.max(0,LH(t))),r=Math.min(320,Math.max(180,Math.floor(n*.58))),i=Math.min(360,Math.max(128,Math.floor(n*.35)));return{min:r,max:Math.max(r,n-i)}}function FH(e,t,n=0){let r=PH(t,n),i=LH(e)||520;return Math.min(r.max,Math.max(r.min,Math.round(i)))}function IH(e,t,n=0){return FH(LH(t)-LH(e),t,n)}function LH(e){let t=Number(e);return Number.isFinite(t)?t:0}var RH=R(`
                            `),zH=R(`

                            Loading interactions...

                            `),BH=R(`

                            No interaction data available for this entry.

                            `),VH=R(``),HH=R(`
                            `,1),UH=R(`

                            Showing the newest part of this session and the selected log.

                            `),WH=R(`
                            `),GH=R(``),KH=R(``),qH=R(``);function JH(e,t){E(t,!0);let n=rL,r=Number(Ta(`gomodel_interactions_panel_width`)),i=`gomodel_interactions_prompt_cache_fill`,a=Number.isFinite(r)&&r>0?r:520,o=k(j(a)),s=k(320),c=k(760),l=k(!1),u=k(Ta(i,`true`)!==`false`),d=null;function f(){A(u,!I(u)),Ea(i,I(u))}function p(){return(document.querySelector(`.sidebar`)?.getBoundingClientRect().width||0)+(document.querySelector(`.sidebar-toggle`)?.getBoundingClientRect().width||0)}function m(){let e=p(),t=PH(window.innerWidth,e);A(s,t.min,!0),A(c,t.max,!0),A(o,FH(a,window.innerWidth,e),!0)}function h(e){A(o,IH(e,window.innerWidth,p()),!0),a=I(o)}function g(e){e.button===0&&(e.preventDefault(),d=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`conversation-panel-resizing`),h(e.clientX))}function _(e){e.pointerId===d&&h(e.clientX)}function v(e){d===null||e.pointerId!==void 0&&e.pointerId!==d||(d=null,document.body.classList.remove(`conversation-panel-resizing`),Ea(`gomodel_interactions_panel_width`,a))}function y(e){e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a=I(o)+(e.key===`ArrowLeft`?24:-24),m(),a=I(o),Ea(`gomodel_interactions_panel_width`,a))}function b(){return[document.querySelector(`.sidebar`),document.querySelector(`.sidebar-toggle`),document.getElementById(`dashboard-content`)].filter(Boolean)}An(()=>{if(!n.conversationOpen)return;m();let e=document.querySelector(`.sidebar`),t=new ResizeObserver(m);e&&t.observe(e);let r=e=>{e.key===`Escape`&&!ja.anyOpen&&(I(l)?A(l,!1):n.closeConversation())};return window.addEventListener(`keydown`,r),window.addEventListener(`resize`,m),()=>{v({}),t.disconnect(),window.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,m)}}),An(()=>{n.conversationOpen||A(l,!1)}),An(()=>{if(!I(l))return;let e=b().map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));return e.forEach(({element:e})=>{e.inert=!0,e.setAttribute(`aria-hidden`,`true`)}),()=>{e.forEach(({element:e,inert:t,ariaHidden:n})=>{e.inert=t,n===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)})}}),An(()=>{Jo.page!==`audit-logs`&&n.conversationOpen&&n.closeConversation()});var x=Qr(),S=N(x),C=e=>{var t=qH();let r,i;var a=M(t),d=P(a,2),p=M(d),m=P(M(p),2),h=M(m);let b;T(m),T(p);var x=P(p,2),S=M(x),C=M(S);{let e=O(()=>I(l)?so:oo);G(C,{get icon(){return I(e)},class:`table-icon-svg`})}T(S),ks(P(S,2),{label:`Close interactions`,onclick:()=>n.closeConversation(),get el(){return n.conversationCloseBtnEl},set el(e){n.conversationCloseBtnEl=e}}),T(x),T(d);var w=P(d,2),ee=M(w),te=e=>{var t=RH(),r=M(t,!0);T(t),F(()=>B(r,n.conversationError)),z(e,t)};V(ee,e=>{n.conversationError&&e(te)});var ne=P(ee,2),re=e=>{z(e,zH())};V(ne,e=>{n.conversationLoading&&e(re)});var ie=P(ne,2),ae=e=>{z(e,BH())},oe=O(()=>!n.conversationLoading&&!n.followUpSending&&!n.conversationError&&n.conversationMessages.length===0&&!n.conversationLiveWaiting());V(ie,e=>{I(oe)&&e(ae)});var se=P(ie,2),ce=e=>{var t=HH(),r=N(t),i=e=>{var t=VH(),n=M(t);let r;Ue(2),T(t),F(()=>{W(t,`aria-checked`,I(u)),W(t,`title`,(I(u)?`Hide`:`Show`)+` estimated provider prompt-cache fill`),r=U(n,1,`conversation-cache-switch svelte-ssrzja`,null,r,{"is-active":I(u)})}),L(`click`,t,f),z(e,t)},a=O(()=>n.conversationMessages.some(e=>Number(e.promptCacheRatio||0)>0));V(r,e=>{I(a)&&e(i)});var o=P(r,2);H(o,21,()=>n.conversationMessages,e=>e.uid,(e,t)=>{NH(e,{get msg(){return I(t)},get showPromptCache(){return I(u)}})}),T(o),ga(o,e=>n.conversationThreadEl=e,()=>n?.conversationThreadEl),z(e,t)};V(se,e=>{n.conversationMessages.length>0&&e(ce)});var le=P(se,2),ue=e=>{z(e,UH())};V(le,e=>{n.conversationTruncated&&e(ue)});var de=P(le,2),fe=e=>{var t=WH(),r=P(M(t),2),i=M(r,!0);T(r),T(t),F(e=>B(i,e),[()=>n.conversationLiveStatusText()]),z(e,t)},pe=O(()=>n.conversationLiveWaiting());V(de,e=>{I(pe)&&e(fe)}),T(w);var me=P(w,2),he=e=>{var t=KH(),r=M(t),i=M(r);ft(i);var a=P(i,2),o=e=>{var t=GH(),r=M(t,!0);T(t),F(()=>B(r,n.followUpError)),z(e,t)};V(a,e=>{n.followUpError&&e(o)});var s=P(a,2),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u),T(s),T(r),T(t),F((e,t,r)=>{i.disabled=e,B(l,t),u.disabled=r,B(d,n.followUpSending?`Sending…`:`Send`)},[()=>n.followUpSending||n.conversationLiveWaiting(),()=>n.selectedConversationEntry()?.path||``,()=>!n.canSendFollowUp()]),Vr(`submit`,r,e=>{e.preventDefault(),n.sendFollowUp()}),da(i,()=>n.followUpText,e=>n.followUpText=e),z(e,t)},ge=O(()=>n.conversationAnchorID&&n.followUpKind());V(me,e=>{I(ge)&&e(he)}),T(t),ga(t,e=>n.conversationDialogEl=e,()=>n?.conversationDialogEl),F(()=>{r=U(t,1,`conversation-drawer svelte-ssrzja`,null,r,{"conversation-drawer-fullscreen":I(l)}),W(t,`role`,I(l)?`dialog`:void 0),W(t,`aria-modal`,I(l)?`true`:void 0),i=Hi(t,``,i,{"--conversation-panel-width":I(o)+`px`}),W(a,`aria-valuemin`,I(s)),W(a,`aria-valuemax`,I(c)),W(a,`aria-valuenow`,I(o)),W(m,`aria-label`,n.conversationFollowLatest?`Following the latest interaction`:`Viewing a historical interaction`),W(m,`title`,n.conversationFollowLatest?`Following the latest interaction as new events arrive`:`Viewing a historical interaction; live updates are not followed`),b=U(h,1,`live-dot`,null,b,{"is-streaming":n.conversationFollowLatest}),W(S,`aria-label`,I(l)?`Exit fullscreen interactions`:`Show interactions fullscreen`),W(S,`title`,I(l)?`Exit fullscreen`:`Fullscreen`),W(S,`aria-pressed`,I(l))}),L(`pointerdown`,a,g),L(`pointermove`,a,_),L(`pointerup`,a,v),Vr(`pointercancel`,a,v),Vr(`lostpointercapture`,a,v),L(`keydown`,a,y),L(`click`,S,()=>A(l,!I(l))),z(e,t)};V(S,e=>{n.conversationOpen&&e(C)}),z(e,x),D()}Hr([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`click`]);var YH=R(`
                            `,1);function XH(e,t){E(t,!0);let n={overview:_C,usage:fT,budgets:HE,"rate-limits":$D,models:Fj,workflows:nP,"audit-logs":qL,guardrails:BR,"mcp-servers":bz,"providers-config":OB,"auth-keys":SV,settings:TH};ds.init(),Mc.init(),K.init(),ka.init(),Aa.init(),Jo.init(),An(()=>{K.refreshTick,Ss.fetch(),Nc.fetchModels(),Nc.fetchCategories()}),An(()=>{document.body.classList.toggle(`dashboard-modal-open`,ja.anyOpen)});let r=O(()=>n[Jo.page]||_C);var i=YH(),a=N(i);Ds(a,{});var o=P(a,2);let s;var c=M(o);rc(c,{}),_i(P(c,2),()=>I(r),(e,t)=>{t(e,{})}),T(o);var l=P(o,2);JH(l,{});var u=P(l,2);Is(u,{});var d=P(u,2);Hs(d,{}),tc(P(d,2),{}),F(()=>s=U(o,1,`content`,null,s,{"interactions-open":rL.conversationOpen})),z(e,i),D()}ti(XH,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/admin/dashboard/static/dist/index.html b/internal/admin/dashboard/static/dist/index.html index 0ad1a05e9..4e09d4d5b 100644 --- a/internal/admin/dashboard/static/dist/index.html +++ b/internal/admin/dashboard/static/dist/index.html @@ -7,8 +7,8 @@ GoModel Dashboard - - + +
                            diff --git a/web/dashboard/src/pages/audit-logs/AuditEntryRow.svelte b/web/dashboard/src/pages/audit-logs/AuditEntryRow.svelte index 121d2656f..d577ee6a1 100644 --- a/web/dashboard/src/pages/audit-logs/AuditEntryRow.svelte +++ b/web/dashboard/src/pages/audit-logs/AuditEntryRow.svelte @@ -89,6 +89,7 @@ } .audit-entry-interactions-open { + border-width: 2px; border-color: color-mix( in srgb, var(--prompt-cache-color) 38%, diff --git a/web/dashboard/src/pages/audit-logs/AuditEntrySummary.svelte b/web/dashboard/src/pages/audit-logs/AuditEntrySummary.svelte index d874a38c7..a1bff684a 100644 --- a/web/dashboard/src/pages/audit-logs/AuditEntrySummary.svelte +++ b/web/dashboard/src/pages/audit-logs/AuditEntrySummary.svelte @@ -248,6 +248,7 @@ } .audit-conversation-trigger-active { + border-left: 0; color: var(--accent-strong, var(--accent)); background: color-mix(in srgb, var(--accent) 28%, var(--bg)); box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 60%, transparent); diff --git a/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte b/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte index 3cf995beb..09590f8eb 100644 --- a/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte +++ b/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte @@ -4,9 +4,11 @@ import DialogCloseButton from "$lib/components/atoms/DialogCloseButton.svelte"; import Icon from "$lib/components/atoms/Icon.svelte"; import { readStored, writeStored } from "$lib/utils/storage.js"; + import { motionDuration } from "$lib/utils/motion.js"; import { modals } from "$lib/stores/ui.svelte.js"; import { router } from "$lib/stores/router.svelte.js"; import { Maximize2, Minimize2 } from "lucide"; + import { fly } from "svelte/transition"; import ChatMessage from "./ChatMessage.svelte"; import { conversationDrawer } from "./conversationDrawer.svelte.js"; import { @@ -156,6 +158,7 @@ {#if drawer.conversationOpen} +{#key fullscreen} +{/key} {/if} diff --git a/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte b/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte index e822e23c2..da5635538 100644 --- a/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte +++ b/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte @@ -7,7 +7,7 @@ import { motionDuration } from "$lib/utils/motion.js"; import { modals } from "$lib/stores/ui.svelte.js"; import { router } from "$lib/stores/router.svelte.js"; - import { Maximize2, Minimize2 } from "lucide"; + import { ArrowDown, ArrowUp, Maximize2, Minimize2 } from "lucide"; import { tick } from "svelte"; import { cubicOut } from "svelte/easing"; import { fly, slide } from "svelte/transition"; @@ -16,6 +16,7 @@ import { DEFAULT_CONVERSATION_PANEL_WIDTH, clampConversationPanelWidth, + conversationMessageNavigationIndex, conversationPanelBounds, conversationPanelWidthFromPointer, } from "./conversation-panel.js"; @@ -117,6 +118,30 @@ writeStored("gomodel_interactions_panel_width", preferredWidth); } + function scrollToConversationMessage(direction) { + const content = document.getElementById("interactions-drawer-content"); + const thread = drawer.conversationThreadEl; + if (!content || !thread) return; + const messages = [...thread.querySelectorAll('[data-conversation-message="true"]')]; + const contentRect = content.getBoundingClientRect(); + const contentTop = contentRect.top + 14; + const index = conversationMessageNavigationIndex( + messages.map((message) => message.getBoundingClientRect().top), + contentTop, + direction, + ); + const target = messages[index]; + if (!target) return; + const targetTop = content.scrollTop + + target.getBoundingClientRect().top + - contentRect.top + - 14; + content.scrollTo({ + top: targetTop, + behavior: motionDuration(1) > 0 ? "smooth" : "auto", + }); + } + function dashboardShellElements() { return [ document.querySelector(".sidebar"), @@ -255,6 +280,26 @@
                            + {#if drawer.conversationMessages.length > 1} +
                            + + +
                            + {/if} {#if drawer.conversationError}
                            {drawer.conversationError}
                            {/if} @@ -437,6 +482,58 @@ font-weight: 700; } + #interactions-drawer-content { + position: relative; + } + + .conversation-message-navigation { + position: sticky; + top: 12px; + z-index: 4; + display: flex; + flex-direction: column; + gap: 4px; + width: max-content; + height: 0; + margin-left: auto; + margin-right: 12px; + opacity: 0; + pointer-events: none; + transform: translateY(-3px); + transition: opacity 120ms ease, transform 120ms ease; + } + + #interactions-drawer-content:hover .conversation-message-navigation, + .conversation-message-navigation:focus-within { + opacity: 1; + pointer-events: auto; + transform: translateY(0); + } + + .conversation-message-navigation button { + display: inline-flex; + align-items: center; + justify-content: center; + width: 30px; + height: 30px; + padding: 0; + border: 1px solid var(--border); + border-radius: 6px; + background: color-mix(in srgb, var(--bg-surface) 94%, transparent); + color: var(--text-muted); + box-shadow: 0 1px 3px color-mix(in srgb, #000 16%, transparent); + } + + .conversation-message-navigation button:hover { + color: var(--text); + background: var(--bg-surface-hover); + } + + .conversation-message-navigation button:focus-visible { + outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); + outline-offset: 1px; + } + .conversation-drawer-footer { flex-shrink: 0; border-top: 1px solid var(--border); @@ -576,4 +673,18 @@ color: var(--text-muted); font-size: 13px; } + + @media (hover: none) { + .conversation-message-navigation { + opacity: 1; + pointer-events: auto; + transform: none; + } + } + + @media (prefers-reduced-motion: reduce) { + .conversation-message-navigation { + transition: none; + } + } diff --git a/web/dashboard/src/pages/audit-logs/conversation-helpers.js b/web/dashboard/src/pages/audit-logs/conversation-helpers.js index baaea527a..b5ac89c39 100644 --- a/web/dashboard/src/pages/audit-logs/conversation-helpers.js +++ b/web/dashboard/src/pages/audit-logs/conversation-helpers.js @@ -1312,6 +1312,15 @@ export function functionExpandedContent(msg) { return msg.text || ''; } +export function conversationMessageCopyText(msg) { + if (!msg) return ''; + const text = String(msg.text || ''); + const toolCalls = Array.isArray(msg.toolCalls) && msg.toolCalls.length > 0 + ? functionExpandedContent({ role: 'function_call', toolCalls: msg.toolCalls }) + : ''; + return [text, toolCalls].filter(Boolean).join('\n\n'); +} + export function formatFunctionArguments(toolCall) { const value = toolCall && toolCall.arguments !== undefined ? toolCall.arguments : ''; if (typeof value !== 'string') { diff --git a/web/dashboard/src/pages/audit-logs/conversation-panel.js b/web/dashboard/src/pages/audit-logs/conversation-panel.js index 3023d9d21..a05a76236 100644 --- a/web/dashboard/src/pages/audit-logs/conversation-panel.js +++ b/web/dashboard/src/pages/audit-logs/conversation-panel.js @@ -24,6 +24,17 @@ export function conversationPanelWidthFromPointer(clientX, viewportWidth, leadin ); } +export function conversationMessageNavigationIndex(messageTops, viewportTop, direction) { + if (!Array.isArray(messageTops) || messageTops.length === 0) return -1; + const top = finite(viewportTop); + let current = 0; + messageTops.forEach((messageTop, index) => { + if (finite(messageTop) <= top + 1) current = index; + }); + const step = Number(direction) < 0 ? -1 : 1; + return Math.min(messageTops.length - 1, Math.max(0, current + step)); +} + function finite(value) { const number = Number(value); return Number.isFinite(number) ? number : 0; diff --git a/web/dashboard/tests/conversation-drawer.test.js b/web/dashboard/tests/conversation-drawer.test.js index fc2205339..3986adef0 100644 --- a/web/dashboard/tests/conversation-drawer.test.js +++ b/web/dashboard/tests/conversation-drawer.test.js @@ -11,6 +11,7 @@ import { conversationEntryByRequestID, conversationEntryIsLatest, conversationFollowUpEntry, + conversationMessageCopyText, extractConversationErrorMessage, extractRequestPromptTextSegments, formatFunctionArguments, @@ -520,6 +521,14 @@ test("functionExpandedContent pretty-prints function call arguments", () => { assert.equal(formatFunctionArguments({ arguments: { q: "object" } }), '{\n "q": "object"\n}'); }); +test("conversationMessageCopyText includes message text and visible tool calls", () => { + assert.equal(conversationMessageCopyText({ text: "Hello" }), "Hello"); + assert.equal(conversationMessageCopyText({ + text: "Looking it up", + toolCalls: [{ name: "lookup", arguments: { q: "x" } }], + }), 'Looking it up\n\nlookup({\n "q": "x"\n})'); +}); + test("the latest request snapshot is displayed once in timestamp order", () => { const first = { id: "log-a", diff --git a/web/dashboard/tests/conversation-panel.test.js b/web/dashboard/tests/conversation-panel.test.js index 99b39f2e3..b34dd4600 100644 --- a/web/dashboard/tests/conversation-panel.test.js +++ b/web/dashboard/tests/conversation-panel.test.js @@ -3,6 +3,7 @@ import assert from "node:assert/strict"; import { clampConversationPanelWidth, + conversationMessageNavigationIndex, conversationPanelBounds, conversationPanelWidthFromPointer, } from "../src/pages/audit-logs/conversation-panel.js"; @@ -31,3 +32,13 @@ test("panel bounds stay continuous across the former compact breakpoint", () => assert.equal(clampConversationPanelWidth(520, 679), 442); assert.equal(clampConversationPanelWidth(520, 680), 443); }); + +test("message navigation steps from the message nearest the viewport top", () => { + const tops = [-80, 40, 180, 320]; + assert.equal(conversationMessageNavigationIndex(tops, 20, 1), 1); + assert.equal(conversationMessageNavigationIndex(tops, 20, -1), 0); + assert.equal(conversationMessageNavigationIndex(tops, 185, 1), 3); + assert.equal(conversationMessageNavigationIndex(tops, 185, -1), 1); + assert.equal(conversationMessageNavigationIndex(tops, -100, -1), 0); + assert.equal(conversationMessageNavigationIndex(tops, 400, 1), 3); +}); From fe9561464d3ec27ce4d6b370e9c742a6fdfc9402 Mon Sep 17 00:00:00 2001 From: "Jakub A. W" Date: Fri, 7 Aug 2026 14:23:29 +0200 Subject: [PATCH 18/19] fix(dashboard): keep interaction arrows square --- .../dist/assets/{index-4h69I0Q9.js => index-BDPZydjS.js} | 0 .../dist/assets/{index-rKZniRbk.css => index-_N2yDOD9.css} | 2 +- internal/admin/dashboard/static/dist/index.html | 4 ++-- web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) rename internal/admin/dashboard/static/dist/assets/{index-4h69I0Q9.js => index-BDPZydjS.js} (100%) rename internal/admin/dashboard/static/dist/assets/{index-rKZniRbk.css => index-_N2yDOD9.css} (97%) diff --git a/internal/admin/dashboard/static/dist/assets/index-4h69I0Q9.js b/internal/admin/dashboard/static/dist/assets/index-BDPZydjS.js similarity index 100% rename from internal/admin/dashboard/static/dist/assets/index-4h69I0Q9.js rename to internal/admin/dashboard/static/dist/assets/index-BDPZydjS.js diff --git a/internal/admin/dashboard/static/dist/assets/index-rKZniRbk.css b/internal/admin/dashboard/static/dist/assets/index-_N2yDOD9.css similarity index 97% rename from internal/admin/dashboard/static/dist/assets/index-rKZniRbk.css rename to internal/admin/dashboard/static/dist/assets/index-_N2yDOD9.css index 5ed65f73d..ff91f95f6 100644 --- a/internal/admin/dashboard/static/dist/assets/index-rKZniRbk.css +++ b/internal/admin/dashboard/static/dist/assets/index-_N2yDOD9.css @@ -1 +1 @@ -:root{--bg:#111110;--bg-surface:#1e1d1c;--bg-surface-hover:#2a2420;--border:#2a2826;--text:#e8e0d6;--text-muted:#9a918a;--accent:#b8956e;--accent-hover:#d4b896;--success:#34d399;--info:#3b82f6;--warning:#f59e0b;--danger:#ef4444;--prompt-cache-color:color-mix(in srgb, var(--info) 72%, #fff);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 24%, var(--bg-surface));--cache-meter-uncached:var(--token-input);--cache-meter-local:var(--token-local);--cache-meter-prompt:var(--token-prompt);--token-input:#c0824a;--token-output:#ddb27a;--token-prompt:color-mix(in srgb, var(--info) 60%, transparent);--token-local:color-mix(in srgb, var(--info) 20%, transparent);--sidebar-width:240px;--radius:8px;--chart-grid:#2a2826;--chart-text:#9a918a;--chart-day-marker:var(--text);--chart-tooltip-bg:#1e1d1c;--chart-tooltip-border:#2a2826;--chart-tooltip-text:#e8e0d6;--cal-level-0:#161b22;--cal-level-1:color-mix(in srgb, var(--info) 15%, var(--bg-surface));--cal-level-2:color-mix(in srgb, var(--info) 25%, var(--bg-surface));--cal-level-3:color-mix(in srgb, var(--info) 36%, var(--bg-surface));--cal-level-4:color-mix(in srgb, var(--info) 48%, var(--bg-surface));--cal-level-5:color-mix(in srgb, var(--info) 60%, var(--bg-surface));--cal-level-6:color-mix(in srgb, var(--info) 73%, var(--bg-surface));--cal-level-7:color-mix(in srgb, var(--info) 87%, var(--bg-surface));--cal-level-8:var(--info);--cal-level-9:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-10:color-mix(in srgb, var(--info) 62%, #fff);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface-hover) 86%, #fff 14%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface-hover) 72%, #fff 28%);--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}[data-theme=light]{--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}@media (prefers-color-scheme:light){:root:not([data-theme=dark]){--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}}*{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;line-height:1.5}body.dashboard-modal-open{overflow:hidden}.app{height:100vh;min-height:0;display:flex;overflow:hidden}.badge{background:var(--accent);color:#fff;text-transform:uppercase;letter-spacing:.5px;border-radius:10px;padding:2px 8px;font-size:10px;font-weight:600}.auth-dialog{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:min(440px,100%);padding:22px;box-shadow:0 24px 70px #00000061}.auth-dialog-header{justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px;display:flex}.auth-dialog h2{margin-top:2px;font-size:22px;line-height:1.2}.auth-dialog-close{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.auth-dialog-close:hover{color:var(--text);background:var(--bg-surface-hover)}.auth-dialog-close:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-hint{color:var(--text-muted);font-size:13px}.auth-dialog-error{color:var(--danger);font-size:13px;font-weight:600}.auth-dialog-form{gap:10px;margin-top:18px;display:grid}.auth-dialog-actions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}.content{-webkit-overflow-scrolling:touch;flex:1 1 0;width:100%;min-width:0;min-height:0;padding:32px;transition:width .2s;overflow-y:auto;container:dashboard-content/inline-size}.content>*{width:100%;max-width:1336px;margin-inline:auto}body.dashboard-modal-open .content{overflow-y:hidden}.content.interactions-open>*{max-width:none}.page-header{justify-content:space-between;align-items:center;margin-bottom:24px;display:flex}.page-header h2{letter-spacing:-.3px;font-size:22px;font-weight:700}.page-header-controls{align-items:center;gap:12px;display:flex}.page-with-sticky-date{grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:12px;display:grid}.page-with-sticky-date>*{grid-column:1/-1}.page-with-sticky-date>.date-range-page-header{grid-column:1}.page-with-sticky-date>.sticky-date-range{z-index:8;grid-column:2;justify-self:end;position:sticky;top:16px}.model-count{color:var(--text-muted);font-size:14px}.provider-status-section{margin-top:28px;scroll-margin-top:24px}.cards{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:28px;display:grid}.card{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px}.card-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);margin-bottom:8px;font-size:12px;font-weight:600}.card-value{letter-spacing:-.5px;font-size:28px;font-weight:700}.cache-meter{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:28px;padding:24px}.chart-container{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.chart-container h3{margin-bottom:16px;font-size:16px;font-weight:600}.chart-container-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;display:flex}.chart-container-header h3{margin-bottom:0}.chart-wrapper{height:210px;position:relative}.live-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:8px;height:8px}.live-dot.is-streaming{background:var(--success);position:relative}.live-dot.is-streaming:after{content:"";z-index:-1;background:color-mix(in srgb, var(--success) 55%, transparent);border-radius:50%;animation:1.8s ease-out infinite live-dot-pulse;position:absolute;inset:0}@media (prefers-reduced-motion:reduce){.live-dot.is-streaming:after{opacity:0;animation:none}}@keyframes live-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(2.5)}to{opacity:0;transform:scale(2.5)}}.alert{border-radius:var(--radius);margin-bottom:20px;padding:12px 16px;font-size:14px}.alert-warning{color:var(--warning);background:#f59e0b1a;border:1px solid #f59e0b4d}.table-toolbar{align-items:center;gap:12px;margin-bottom:16px;display:flex}.table-toolbar-main{flex:1;min-width:0}.table-toolbar-actions{justify-content:flex-end;margin-left:auto;display:flex}input:is([type=text],[type=date],[type=number]){background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:8px 12px;font-family:inherit;font-size:13px}input:is([type=text],[type=date],[type=number]):focus{border-color:var(--accent)}input:is([type=text],[type=date],[type=number]):disabled,textarea:disabled,.form-input:disabled{opacity:.6;cursor:not-allowed}.table-wrapper{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}.data-table{border-collapse:collapse;width:100%;font-size:14px}.data-table th{text-align:left;text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);background:var(--bg);border-bottom:1px solid var(--border);padding:12px 16px;font-size:12px;font-weight:600}.data-table th.model-actions-header{text-align:right;white-space:nowrap;width:1%;min-width:156px}.data-table td{border-bottom:1px solid var(--border);padding:10px 16px}.data-table tr:last-child td{border-bottom:none}.data-table tr:hover td{background:var(--bg-surface-hover)}.mono{font-family:SF Mono,Menlo,Consolas,monospace}.font-size-md{font-size:13px}.col-price,.data-table th.col-price{text-align:right}td.col-price{color:var(--text-muted);white-space:nowrap;font-family:SF Mono,Menlo,Consolas,monospace;font-size:13px}.provider-badge{background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:2px 10px;font-size:12px;font-weight:500;display:inline-block}.empty-state{text-align:center;color:var(--text-muted);padding:48px 0;font-size:14px}.empty-state-icon{width:auto;height:auto;max-height:160px;color:var(--text-muted);margin:0 auto;display:block}.empty-state-icon text{fill:var(--text-muted);font-family:inherit;font-weight:600}.chart-empty-overlay{pointer-events:none;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.chart-empty-overlay .empty-state-icon{width:auto;max-width:90%;height:auto;max-height:195px}.loading-spinner{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:16px;height:16px;animation:.8s linear infinite loading-spin}@keyframes loading-spin{to{transform:rotate(360deg)}}.table-action-btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;gap:6px;padding:6px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:inline-flex}.table-action-btn:hover:not(:disabled){background:var(--bg-surface-hover)}.table-action-btn:disabled{opacity:.45;cursor:default}.table-action-btn-danger{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.table-action-btn-active{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 12%, var(--bg));border-color:color-mix(in srgb, var(--accent) 38%, var(--border))}.table-action-btn-active:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 18%, var(--bg-surface-hover))}.table-action-btn-failover-active{color:var(--info);background:color-mix(in srgb, var(--cache-meter-prompt) 35%, var(--bg));border-color:color-mix(in srgb, var(--info) 45%, var(--border));position:relative}.table-action-btn-failover-active:hover:not(:disabled){background:color-mix(in srgb, var(--cache-meter-prompt) 45%, var(--bg-surface-hover))}.table-icon-btn{border-radius:6px;gap:0;width:32px;min-width:32px;height:32px;padding:0}.table-icon-btn.table-action-btn-active{position:relative}.table-icon-btn.table-action-btn-active:after{content:"";background:var(--accent);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-btn.table-action-btn-failover-active:after{content:"";background:var(--info);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-svg{flex-shrink:0;width:14px;height:14px}.model-editor{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:16px;padding:24px}.alias-kind-badge{border:1px solid var(--border);background:var(--bg);min-height:24px;color:var(--accent);letter-spacing:.2px;text-transform:uppercase;border-color:color-mix(in srgb, var(--accent) 55%, var(--border));border-radius:999px;justify-content:center;align-items:center;gap:4px;padding:0 10px;font-size:11px;font-weight:600;display:inline-flex}.form h3{font-size:20px;font-weight:700}.form-kicker,.form-hint{color:var(--text-muted);font-size:13px}.alias-actions-cell{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.model-list-actions{white-space:nowrap;flex-wrap:nowrap}.model-list-actions .table-icon-btn{flex:0 0 32px}.model-list-actions .alias-toggle{flex:none}.alias-toggle{border:1px solid var(--border);background:var(--bg);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:8px;padding:6px 10px;font-family:inherit;font-size:12px;transition:all .15s;display:inline-flex}.alias-toggle:hover:not(:disabled){background:var(--bg-surface-hover)}.alias-toggle:disabled{opacity:.45;cursor:default}.alias-toggle-track{background:color-mix(in srgb, var(--border) 80%, var(--bg));border-radius:6px;width:34px;height:18px;transition:background .15s;position:relative}.alias-toggle-thumb{background:var(--text-muted);border-radius:6px;width:16px;height:16px;transition:transform .15s,background .15s;position:absolute;top:1px;left:2px}.alias-toggle.enabled{border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.alias-toggle.enabled .alias-toggle-track{background:color-mix(in srgb, var(--success) 55%, var(--bg))}.alias-toggle.enabled .alias-toggle-thumb{background:#fff;transform:translate(14px)}.alias-toggle.restricted{border-color:color-mix(in srgb, var(--accent) 50%, var(--border));color:color-mix(in srgb, var(--accent) 70%, var(--text))}.alias-toggle.restricted .alias-toggle-track{background:color-mix(in srgb, var(--accent) 55%, var(--bg))}.editor-header{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:20px;display:flex}.form{flex-direction:column;gap:16px;display:flex}.auth-key-editor{background:color-mix(in srgb, var(--bg-surface) 82%, var(--bg) 18%)}.form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.form-field{flex-direction:column;gap:8px;display:flex}.form-field-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);font-size:12px;font-weight:600;display:inline-block}.vm-target-row{align-items:center;gap:8px;display:flex}.vm-target-row .vm-target-model{flex:auto;min-width:0}.vm-target-row .vm-target-weight{flex:0 0 88px;width:88px}.vm-status-row{justify-content:space-between;align-items:center;gap:12px;display:flex}.vm-status-row .vm-status-toggle{margin-left:auto}.form-error{border:1px solid color-mix(in srgb, var(--danger) 42%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface));color:var(--danger);overflow-wrap:anywhere;margin:0;padding:10px 12px;font-size:13px;font-weight:600;line-height:1.4}.form-error:empty{display:none}.form-field-error{color:var(--danger);overflow-wrap:anywhere;font-size:13px;font-weight:500;line-height:1.4}.form-field-required{color:var(--danger);margin-left:3px}:is(input,textarea,select)[aria-invalid=true]{border-color:color-mix(in srgb, var(--danger) 60%, var(--border))}:is(input,textarea,select)[aria-invalid=true]:focus{border-color:var(--danger)}textarea{resize:vertical;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:60px;color:var(--text);outline:none;padding:10px 12px;font-family:inherit;font-size:13px}textarea:focus{border-color:var(--accent)}.form-input{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:38px;color:var(--text);outline:none;padding:8px 10px;font-family:inherit;font-size:13px}.form-input:focus{border-color:var(--accent)}.form-actions{flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:16px;display:flex}.failover-target-actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.data-table tr.alias-row.is-valid td{background:var(--alias-row-valid-bg)}.data-table tr.alias-row.is-valid:hover td{background:var(--alias-row-valid-bg-hover)}.data-table tr.alias-row:not(.is-valid) td{background:color-mix(in srgb, var(--accent) 10%, var(--bg-surface))}.data-table tr.alias-row:not(.is-valid):hover td{background:color-mix(in srgb, var(--accent) 16%, var(--bg-surface-hover))}.data-table tr.alias-row.is-disabled td{background:var(--bg-surface);opacity:.58}.data-table tr.alias-row.is-disabled:hover td{background:var(--bg-surface-hover);opacity:.72}.data-table tr.model-access-disabled-row td{background:color-mix(in srgb, var(--danger) 6%, var(--bg-surface))}.data-table tr.model-access-disabled-row:hover td{background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface-hover))}.workflow-section-head{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-section-head h4{font-size:14px;font-weight:700}.workflow-preview{flex-direction:column;gap:12px;display:flex}.workflow-feature-toggles{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.workflow-feature-toggle{border:1px solid var(--border);background:var(--bg);border-radius:10px;align-items:center;gap:10px;padding:10px 12px;font-size:14px;font-weight:500;display:flex}.workflow-feature-toggle input{width:16px;height:16px}.model-chart-section{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:24px;padding:24px}.model-chart-section h3{margin:0;font-size:16px;font-weight:600}.model-chart-header{justify-content:space-between;align-items:center;gap:16px;margin-bottom:16px;display:flex}.bar-chart-wrap{width:100%;height:180px;position:relative}.form-select,.usage-log-select{appearance:none;background-color:var(--bg);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 17px),calc(100% - 12px);background-repeat:no-repeat;background-size:5px 5px;outline:none;min-width:140px;padding:8px 34px 8px 12px;font-family:inherit;font-size:13px}.form-select:disabled,.usage-log-select:disabled{cursor:not-allowed;opacity:.6}.form-select:focus,.usage-log-select:focus{border-color:var(--accent)}.form-select{width:100%;min-width:0}.usage-label-chips{flex-wrap:wrap;gap:4px;max-width:280px;display:inline-flex}.usage-label-chip{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg));min-height:20px;color:var(--text);white-space:nowrap;cursor:pointer;border-radius:999px;align-items:center;padding:1px 9px;font-family:inherit;font-size:11px;font-style:normal;font-weight:600;line-height:1.4;transition:background .15s,border-color .15s;display:inline-flex}.usage-label-chip:hover{background:color-mix(in srgb, var(--label-color,var(--accent)) 26%, var(--bg))}.usage-label-chip.active{background:color-mix(in srgb, var(--label-color,var(--accent)) 32%, var(--bg));border-color:var(--label-color,var(--accent));box-shadow:0 0 0 1px color-mix(in srgb, var(--label-color,var(--accent)) 55%, transparent)}@keyframes audit-live-summary-stripe-blink{0%,to{opacity:.9}50%{opacity:.28}}.audit-status-badge{border:1px solid var(--border);letter-spacing:.2px;background:var(--bg-surface);border-radius:999px;justify-content:center;align-items:center;min-width:46px;height:24px;padding:0 10px;font-size:12px;font-weight:600;display:inline-flex}.audit-status-badge.status-success{color:var(--success);border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.audit-status-badge.status-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.audit-status-badge.status-error{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.audit-status-badge.status-neutral{color:var(--text-muted)}.audit-status-badge.status-unknown{color:var(--text-muted);border-color:color-mix(in srgb, var(--border) 75%, transparent)}.audit-pane{border:1px solid var(--border);background:var(--bg);border-top:0;border-radius:0 0 8px 8px;min-width:0;padding:12px}.audit-pane h5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:11px;font-weight:600}.audit-prompt-cache-pill{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);min-height:20px;color:var(--prompt-cache-color);letter-spacing:.02em;text-transform:none;border-radius:999px;align-items:center;padding:2px 8px;font-size:11px;font-weight:700;display:inline-flex}.audit-prompt-cache-highlight{color:var(--prompt-cache-color);font-weight:700}.audit-audio{white-space:normal;flex-direction:column;gap:8px;display:flex}.audit-audio-player{width:100%;max-width:420px;height:36px}.audit-audio-meta{color:var(--text-muted);font-size:12px}.audit-audio-empty{align-items:flex-start;padding:4px 0}.audit-audio-icon{font-size:20px;line-height:1}.audit-audio-note{color:var(--text-muted);font-size:12px}.audit-audio-metadata{flex-direction:column;gap:2px;margin-top:4px;font-size:12px;display:flex}.audit-audio-meta-row{gap:8px;display:flex}.audit-audio-meta-key{color:var(--text-muted);min-width:120px}.conversation-body-highlight{border-left:2px solid color-mix(in srgb, var(--accent) 70%, var(--border));background:color-mix(in srgb, var(--accent) 10%, transparent);cursor:pointer;line-height:inherit;border-radius:2px;margin:0 0 0 -2px;padding:0 0 0 2px;display:inline}.conversation-body-highlight:hover{background:color-mix(in srgb, var(--accent) 18%, transparent)}.conversation-body-highlight.conversation-system{border-left-color:color-mix(in srgb, var(--warning) 70%, var(--border));background:color-mix(in srgb, var(--warning) 10%, transparent)}.conversation-body-highlight.conversation-user{border-left-color:color-mix(in srgb, var(--accent) 75%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent)}.conversation-body-highlight.conversation-assistant{border-left-color:color-mix(in srgb, var(--success) 65%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}#interactions-drawer-content{flex:1;min-height:0;overflow-y:auto}.pagination{justify-content:space-between;align-items:center;padding:12px 0 0;display:flex}.btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;padding:6px 16px;font-family:inherit;font-size:13px;transition:all .15s}.btn:hover:not(:disabled){background:var(--bg-surface-hover)}.btn-primary{background:var(--accent);border-color:color-mix(in srgb, var(--accent) 70%, #000 10%);color:#fff;font-weight:600;box-shadow:0 10px 22px #3b82f62e}.btn-primary:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 90%, #fff 10%);border-color:color-mix(in srgb, var(--accent) 78%, #000 12%)}.btn-danger-outline{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:0 0;font-weight:600}.btn-danger-outline:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 75%, var(--border))}.btn-danger{color:#fff;border-color:color-mix(in srgb, var(--danger) 76%, #000 12%);background:var(--danger);box-shadow:0 10px 22px color-mix(in srgb, var(--danger) 20%, transparent);font-weight:600}.btn-danger:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 90%, #fff 10%);border-color:color-mix(in srgb, var(--danger) 82%, #000 14%)}.btn-with-icon{justify-content:center;align-items:center;gap:8px;display:inline-flex}.btn-with-icon .table-icon-svg{width:16px;height:16px}.btn:disabled{opacity:.4;cursor:default}.settings-panel{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.inline-help-section{flex-direction:column;gap:2px;display:flex}.inline-help-title-row{align-items:center;gap:10px;display:inline-flex}.inline-help-title-row h2,.inline-help-title-row h3{margin-bottom:0}.inline-help-title-row h2:empty,.inline-help-title-row h3:empty{display:none}.inline-help-toggle{border:1px solid color-mix(in srgb, var(--accent) 28%, var(--border));width:16px;height:16px;color:var(--accent);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border-radius:4px;justify-content:center;align-items:center;padding:0;transition:color .18s,border-color .18s;display:inline-flex;position:relative}.inline-help-toggle:before{content:"";pointer-events:auto;background:0 0;width:32px;height:32px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.inline-help-toggle:hover{border-color:color-mix(in srgb, var(--accent) 48%, var(--border));color:var(--text);background:0 0}.inline-help-toggle:active{background:0 0}.inline-help-toggle:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.inline-help-toggle-icon{justify-content:center;align-items:center;width:100%;height:100%;padding-bottom:1px;font-size:13px;font-weight:700;line-height:1;transition:transform .52s cubic-bezier(.22,.72,.12,1);display:inline-flex;transform:rotate(0)}.inline-help-copy{max-width:780px;color:var(--text-muted);margin-top:2px;font-size:14px}.settings-select{width:100%}.settings-refresh-section{border-top:1px solid var(--border);justify-items:start;gap:12px;margin-top:24px;padding-top:22px;display:grid}.settings-refresh-section h3{font-size:18px}.settings-refresh-section p{max-width:720px;color:var(--text-muted);font-size:14px;line-height:1.55}.budget-list{gap:10px;padding:10px 0;display:grid}.budget-row{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);grid-template-columns:minmax(0,1fr);align-items:center;gap:16px;padding:12px 14px;display:grid}.budget-row-main{min-width:0}.budget-row-head{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:10px;min-width:0;display:grid}.budget-scope-value{width:fit-content;max-width:100%;min-height:24px;color:var(--text);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;justify-self:start;align-items:center;gap:5px;padding:2px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;display:inline-flex;overflow:hidden}.budget-user-path{border:1px solid color-mix(in srgb, var(--accent) 32%, var(--border));background:color-mix(in srgb, var(--accent) 9%, var(--bg))}.budget-label{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.budget-scope-icon{stroke-width:2.2px;opacity:.85;flex:0 0 12px;width:12px;height:12px}.budget-row-meta{min-width:0;color:var(--text-muted);align-items:center;gap:8px;font-size:12px;display:inline-flex}.budget-source{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:999px;padding:2px 7px;font-size:11px}.budget-row-period{justify-content:center;min-width:0;display:flex}.budget-row-controls{justify-content:flex-end;align-items:center;gap:8px;min-width:0;display:flex}.budget-bars{gap:6px;margin-top:10px;display:grid}.budget-bar-line{grid-template-columns:118px minmax(0,1fr);align-items:center;gap:10px;display:grid}.budget-bar-label{color:var(--text-muted);justify-content:space-between;align-items:center;gap:6px;font-size:11px;line-height:1;display:flex}.budget-bar-percent{font-weight:700}.budget-bar-track{background:color-mix(in srgb, var(--border) 75%, var(--bg));border-radius:999px;height:16px;position:relative;overflow:hidden}.budget-bar-fill{border-radius:inherit;min-width:0;height:100%;transition:width .2s}.budget-bar-fill-usage{background:color-mix(in srgb, var(--success) 82%, var(--accent))}.budget-bar-fill-danger{background:var(--danger)}.budget-bar-text-row{z-index:1;pointer-events:none;color:var(--text);position:absolute;inset:0}.budget-bar-text{text-overflow:ellipsis;white-space:nowrap;max-width:min(44%,190px);font-size:11px;font-weight:700;line-height:12px;position:absolute;top:50%;overflow:hidden}.budget-bar-text-center{max-width:min(46%,240px);left:50%;transform:translate(-50%,-50%)}.budget-bar-text-end{text-align:right;max-width:min(34%,180px);right:8px;transform:translateY(-50%)}.budget-period-label{border:1px solid var(--border);color:var(--text);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;gap:5px;padding:2px 7px;font-size:11px;font-weight:600;display:inline-flex}.budget-period-icon{stroke-width:2.2px;flex:0 0 12px;width:12px;height:12px}.budget-period-label-monthly{border-color:color-mix(in srgb, #30302c 62%, var(--border));background:color-mix(in srgb, #30302c 12%, var(--bg));color:color-mix(in srgb, #30302c 34%, var(--text) 66%)}.budget-period-label-weekly{border-color:color-mix(in srgb, #68765c 62%, var(--border));background:color-mix(in srgb, #68765c 12%, var(--bg));color:color-mix(in srgb, #68765c 34%, var(--text) 66%)}.budget-period-label-daily{border-color:color-mix(in srgb, #b5652d 62%, var(--border));background:color-mix(in srgb, #b5652d 12%, var(--bg));color:color-mix(in srgb, #b5652d 34%, var(--text) 66%)}.budget-period-label-hourly{border-color:color-mix(in srgb, #783f22 62%, var(--border));background:color-mix(in srgb, #783f22 12%, var(--bg));color:color-mix(in srgb, #783f22 34%, var(--text) 66%)}.budget-period-label-custom{border-style:dashed;border-color:color-mix(in srgb, #bfa584 68%, var(--border));background:color-mix(in srgb, #bfa584 16%, var(--bg));color:color-mix(in srgb, #8b6f4f 34%, var(--text) 66%)}[data-theme=light] .budget-period-label-monthly{color:#30302c}[data-theme=light] .budget-period-label-weekly{color:#68765c}[data-theme=light] .budget-period-label-daily{color:#b5652d}[data-theme=light] .budget-period-label-hourly{color:#783f22}[data-theme=light] .budget-period-label-custom{color:#8b6f4f}@media (prefers-color-scheme:light){:root:not([data-theme=dark]) .budget-period-label-monthly{color:#30302c}:root:not([data-theme=dark]) .budget-period-label-weekly{color:#68765c}:root:not([data-theme=dark]) .budget-period-label-daily{color:#b5652d}:root:not([data-theme=dark]) .budget-period-label-hourly{color:#783f22}:root:not([data-theme=dark]) .budget-period-label-custom{color:#8b6f4f}}.budget-row-actions{flex-flow:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.budget-action-btn{white-space:nowrap;justify-content:center;gap:0;width:28px;min-width:0;height:28px;padding:0;transition:width .18s,border-color .15s,background .15s,color .15s;overflow:hidden}.budget-action-btn:hover,.budget-action-btn:focus-visible{gap:6px;width:82px;padding:0 9px}.budget-action-label{opacity:0;max-width:0;transition:max-width .18s,opacity .12s;overflow:hidden}.budget-action-btn:hover .budget-action-label,.budget-action-btn:focus-visible .budget-action-label{opacity:1;max-width:58px}.budget-action-btn-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.budget-action-icon{flex:0 0 14px;width:14px;height:14px}.budget-editor{background:color-mix(in srgb, var(--bg-surface) 86%, var(--bg) 14%)}.budget-settings-actions{flex-wrap:wrap;gap:10px;display:flex}.budget-reset-dialog{max-width:460px}.form-action-icon{flex:0 0 16px;width:16px;height:16px}.settings-refresh-alert{margin-top:16px;margin-bottom:0}@media (width<=768px){.badge{display:none}.content{width:100%;margin:0 auto;padding:20px}.auth-dialog{padding:18px}.auth-dialog-actions{flex-direction:column-reverse}.auth-dialog-actions .btn{width:100%}.cards{grid-template-columns:repeat(2,1fr)}.page-header{flex-wrap:wrap;gap:12px}.page-header h2{width:100%}.page-header-controls{flex-wrap:wrap;justify-content:space-between;width:100%}.page-with-sticky-date{grid-template-columns:minmax(0,1fr)}.page-with-sticky-date>.date-range-page-header,.page-with-sticky-date>.sticky-date-range{grid-column:1}.page-with-sticky-date>.date-range-page-header{margin-bottom:12px}.page-with-sticky-date>.sticky-date-range{width:100%;margin-bottom:24px;top:10px}.sticky-date-range .date-picker-trigger{justify-content:space-between;width:100%}.usage-log-select{min-width:0}.budget-row{grid-template-columns:1fr}.budget-row-controls{flex-wrap:wrap}.budget-bar-line{grid-template-columns:1fr;gap:5px}.form-grid,.workflow-feature-toggles{grid-template-columns:1fr}.workflow-section-head{flex-direction:column;align-items:flex-start}.table-toolbar{flex-direction:column;align-items:stretch}.table-toolbar-actions{justify-content:stretch;margin-left:0}.table-toolbar-actions .btn{width:100%}.model-editor{padding:16px}.alias-actions-cell,.editor-header{flex-direction:column;align-items:flex-start}.alias-actions-cell .table-action-btn,.editor-header .table-action-btn{width:100%}.alias-actions-cell .table-icon-btn,.editor-header .table-icon-btn{width:36px}.model-list-actions{flex-flow:row;align-items:center}.model-list-actions .table-action-btn{width:auto}.model-list-actions .table-icon-btn{flex-basis:32px;width:32px}.model-editor .editor-header{flex-direction:row;align-items:flex-start}.model-editor .editor-header>:first-child{flex:1;min-width:0}.model-editor .editor-header .dialog-close-btn{flex:0 0 32px;align-self:flex-start;width:32px;min-width:32px}.settings-panel{padding:18px}.budget-settings-actions,.budget-settings-actions .btn{width:100%}}.workflow-conn{background:color-mix(in srgb, var(--accent) 44%, var(--border));flex:1 1 0;width:auto;min-width:13px;height:2px;position:relative}.workflow-conn:after{content:"";background:color-mix(in srgb, var(--accent) 44%, var(--border));clip-path:polygon(0 0,100% 50%,0 100%);width:7px;height:9px;position:absolute;top:50%;right:-1px;transform:translateY(-50%)}.workflow-node{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg-surface);text-align:center;flex-direction:column;flex-shrink:0;justify-content:center;align-items:center;gap:4px;min-width:72px;padding:8px 12px;display:flex}.auth-key-description{color:var(--text-muted);max-width:220px;font-size:13px}.auth-key-status-badge{border-radius:999px;padding:2px 10px;font-size:12px;font-weight:600;display:inline-block}.auth-key-status-active{background:color-mix(in srgb, var(--success) 12%, var(--bg));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));color:var(--success)}.auth-key-status-inactive{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border:1px solid color-mix(in srgb, var(--danger) 30%, var(--border));color:var(--danger)}.mcp-server-advanced{border:1px solid var(--border);border-radius:var(--radius);background:color-mix(in srgb, var(--bg-surface) 72%, var(--bg) 28%);overflow:hidden}.mcp-server-advanced>summary{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;list-style:none;display:flex}.mcp-server-advanced>summary::-webkit-details-marker{display:none}.mcp-server-advanced>summary:after{border-right:2px solid var(--text-muted);border-bottom:2px solid var(--text-muted);content:"";flex:none;width:7px;height:7px;transition:transform .15s;transform:rotate(45deg)}.mcp-server-advanced[open]>summary:after{transform:rotate(225deg)}.mcp-server-advanced-summary-copy{flex-direction:column;gap:2px;min-width:0;display:flex}.mcp-server-advanced-title{font-size:13px;font-weight:600}.mcp-server-advanced-fields{border-top:1px solid var(--border);flex-direction:column;gap:16px;padding:14px;display:flex}.copy-feedback-btn{align-items:center;gap:6px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.rate-limit-pressure-row{background-image:linear-gradient(to right, color-mix(in srgb, var(--success) 16%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-high{background-image:linear-gradient(to right, color-mix(in srgb, var(--warning) 20%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-full{background-image:linear-gradient(to right, color-mix(in srgb, var(--danger) 22%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.table-icon-btn.rate-limit-gauge-inherited{color:var(--accent-strong,var(--accent));background:linear-gradient(to right, color-mix(in srgb, var(--accent) 22%, var(--bg)) 50%, var(--bg) 50%);border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.auth-dialog-input-icon{width:16px;height:16px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.auth-dialog-input-shell:focus-within .auth-dialog-input-icon{color:var(--accent)}.auth-dialog-submit-icon{flex:0 0 16px;width:16px;height:16px}.nav-icon{flex:0 0 18px;width:18px;height:18px}.api-key-open-icon{flex:0 0 15px;width:15px;height:15px}.theme-icon{flex:0 0 14px;width:14px;height:14px}.theme-toggle-mobile .theme-icon{flex-basis:16px;width:16px;height:16px}@media (width<=768px){.sidebar-footer .api-key-open-icon{flex-basis:16px;width:16px;height:16px}}.failover-drafts-loading{min-height:96px}.models-loading-state{top:16px;left:var(--sidebar-width);z-index:110;pointer-events:none;--loading-state-min-height:0;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-surface);width:fit-content;box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);margin:0 auto;padding:10px 14px;position:fixed;right:0}@media (width<=768px){.models-loading-state{left:60px}}.sidebar.sidebar-collapsed~.content .models-loading-state{left:60px}.alias-create-icon{flex:0 0 16px;width:16px;height:16px}.pricing-override-remove-row{margin-bottom:1px}@media (width<=768px){.pricing-override-remove-row{margin-bottom:0}}.pricing-recalculate-dialog{max-width:480px}.settings-refresh-btn.is-refreshing .settings-refresh-icon{transform-origin:50%;animation:.8s linear infinite loading-spin}.cost-source-icon{width:14px;height:14px;color:var(--success);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.cache-savings-icon{width:14px;height:14px;color:var(--accent);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.theme-toggle.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;margin-bottom:10px;padding:2px;display:inline-flex}.theme-btn.svelte-1keql7b{width:28px;height:24px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:flex}.theme-btn.svelte-1keql7b:hover{color:var(--text)}.theme-btn.active.svelte-1keql7b{background:var(--accent);color:#fff}.theme-btn.svelte-1keql7b:focus-visible,.theme-toggle-mobile.svelte-1keql7b:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.theme-toggle-mobile.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);width:36px;height:36px;color:var(--text-muted);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:none}.theme-toggle-mobile.svelte-1keql7b:hover{color:var(--text)}.theme-toggle.is-compact.svelte-1keql7b{display:none}.theme-toggle-mobile.is-compact.svelte-1keql7b{margin:0 auto;display:flex}@media (width<=768px){.theme-toggle.svelte-1keql7b{display:none}.theme-toggle-mobile.svelte-1keql7b{margin:0 auto;display:flex}}.sidebar.svelte-1nwtzae{flex:0 0 var(--sidebar-width);width:var(--sidebar-width);background:var(--bg-surface);border-right:1px solid var(--border);-webkit-overflow-scrolling:touch;z-index:10;flex-direction:column;max-height:100vh;transition:flex-basis .2s,width .2s;display:flex;position:sticky;top:0;overflow:hidden auto}.sidebar.sidebar-resizing.svelte-1nwtzae{transition:none}.sidebar-header.svelte-1nwtzae{border-bottom:1px solid var(--border);align-items:center;gap:10px;padding:20px;display:flex}.sidebar-logo.svelte-1nwtzae{width:28px;height:28px;color:var(--accent);flex-shrink:0}.sidebar-logo.svelte-1nwtzae svg{width:100%;height:100%}.sidebar-header.svelte-1nwtzae h1{letter-spacing:-.3px;font-size:18px;font-weight:700}.sidebar-nav.svelte-1nwtzae{flex-direction:column;flex:1;gap:4px;padding:12px;display:flex}.nav-item.svelte-1nwtzae{border-radius:var(--radius);color:var(--text-muted);align-items:center;gap:10px;padding:8px 12px;font-size:14px;font-weight:500;text-decoration:none;transition:all .15s;display:flex}.nav-item.svelte-1nwtzae:hover{background:var(--bg-surface-hover);color:var(--text)}.nav-item.active.svelte-1nwtzae{background:var(--accent);color:#fff}.nav-label.svelte-1nwtzae{white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;overflow:hidden}.sidebar-footer.svelte-1nwtzae{border-top:1px solid var(--border);padding:16px}.api-key-section.svelte-1nwtzae{gap:8px;display:grid}.api-key-open-btn.svelte-1nwtzae{border:1px solid var(--accent);border-radius:var(--radius);width:100%;color:var(--accent);cursor:pointer;background:0 0;justify-content:center;align-items:center;gap:8px;padding:8px 10px;font-family:inherit;font-size:13px;font-weight:600;transition:background-color .15s,border-color .15s;display:inline-flex}.api-key-open-btn.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);border-color:color-mix(in srgb, var(--accent) 78%, var(--text));color:color-mix(in srgb, var(--accent) 78%, var(--text))}.api-key-open-btn.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.sidebar-toggle.svelte-1nwtzae{cursor:ew-resize;z-index:11;background:0 0;border:none;flex:0 0 6px;width:6px;height:100vh;padding:0;transition:background .15s;position:sticky;top:0}.sidebar-toggle.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 15%, transparent)}.sidebar-toggle.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}body.sidebar-resizing{cursor:ew-resize;-webkit-user-select:none;user-select:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae){justify-content:center;padding:16px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae) h1,.sidebar.sidebar-collapsed.svelte-1nwtzae .badge{display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae){padding:8px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:none}@media (width<=768px){.sidebar.svelte-1nwtzae{flex-basis:60px;width:60px}.sidebar-header.svelte-1nwtzae{justify-content:center;padding:16px}.sidebar-header.svelte-1nwtzae h1{display:none}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar-footer.svelte-1nwtzae{gap:8px;padding:8px;display:grid}.sidebar-footer.svelte-1nwtzae .api-key-section:where(.svelte-1nwtzae),.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:grid}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae){justify-self:center;width:36px;height:36px;min-height:36px;padding:0}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae) span,.sidebar-toggle.svelte-1nwtzae{display:none}}.dialog-close-btn.svelte-11l1bb5{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.dialog-close-btn.svelte-11l1bb5:hover{color:var(--text);background:var(--bg-surface-hover)}.dialog-close-btn.svelte-11l1bb5:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-backdrop.svelte-17e0w4c,.editor-modal-backdrop.svelte-17e0w4c{z-index:80;background:#0000007a;position:fixed;inset:0}.auth-dialog-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0}.editor-modal-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0;overflow-y:auto}.editor-modal-shell.svelte-17e0w4c>*{overscroll-behavior:contain;width:min(760px,100%);max-height:min(100vh - 40px,960px);margin:0;overflow:auto;box-shadow:0 24px 70px #00000061}@media (width<=768px){.auth-dialog-shell.svelte-17e0w4c,.editor-modal-shell.svelte-17e0w4c{align-items:end;padding:12px}.editor-modal-shell.svelte-17e0w4c>*{max-height:calc(100vh - 24px)}}.auth-dialog-input-shell.svelte-1dsu6u0{position:relative}.auth-dialog-input.svelte-1dsu6u0{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:11px 12px 11px 38px;font-family:inherit;font-size:14px}.auth-dialog-input.svelte-1dsu6u0:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}.flash-region.svelte-1i257xg{top:16px;left:var(--sidebar-width);z-index:120;pointer-events:none;flex-direction:column;align-items:center;gap:10px;display:flex;position:fixed;right:0}.sidebar.sidebar-collapsed~.flash-region.svelte-1i257xg{left:60px}@media (width<=768px){.flash-region.svelte-1i257xg{left:60px}}.flash-toast.svelte-1i257xg{border-radius:var(--radius);pointer-events:auto;align-items:flex-start;gap:10px;width:max-content;max-width:min(480px,100% - 32px);padding:12px 12px 12px 16px;font-size:14px;animation:.9s ease-out svelte-1i257xg-flash-toast-glow;display:flex;box-shadow:0 10px 30px #00000059}@keyframes svelte-1i257xg-flash-toast-glow{0%{box-shadow:0 0 0 4px color-mix(in srgb, currentColor 45%, transparent), 0 10px 30px #00000059}to{box-shadow:0 0 0 4px #0000,0 10px 30px #00000059}}@media (prefers-reduced-motion:reduce){.flash-toast.svelte-1i257xg{animation:none}}.flash-toast-success.svelte-1i257xg{background:color-mix(in srgb, var(--success) 14%, var(--bg-surface));color:var(--success);border:1px solid #34d39959}.flash-toast-error.svelte-1i257xg{background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--warning);border:1px solid #f59e0b66}.flash-toast-text.svelte-1i257xg{overflow-wrap:anywhere;flex:1;min-width:0}.flash-toast-dismiss.svelte-1i257xg{color:inherit;cursor:pointer;opacity:.7;background:0 0;border:0;flex-shrink:0;padding:0 2px;font-size:18px;line-height:1}.flash-toast-dismiss.svelte-1i257xg:hover{opacity:1}.demo-mode-banner.svelte-1s3mcn8{border:1px solid color-mix(in srgb, var(--warning) 55%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--text);box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;margin-bottom:24px;padding:12px 16px;display:grid}.demo-mode-banner-icon.svelte-1s3mcn8{width:20px;height:20px;color:var(--warning);flex:0 0 20px}.demo-mode-banner-copy.svelte-1s3mcn8{align-items:baseline;gap:8px;min-width:0;font-size:13px;display:flex}.demo-mode-banner.svelte-1s3mcn8 strong{color:var(--warning);letter-spacing:.06em;text-transform:uppercase;flex-shrink:0;font-size:12px}.demo-mode-banner-links.svelte-1s3mcn8{justify-content:flex-end;align-items:center;gap:6px;display:flex}.demo-mode-banner-links.svelte-1s3mcn8 a{border:1px solid color-mix(in srgb, var(--warning) 42%, var(--border));border-radius:var(--radius);min-height:28px;color:var(--text);white-space:nowrap;align-items:center;padding:4px 8px;font-size:12px;font-weight:600;line-height:1;text-decoration:none;display:inline-flex}.demo-mode-banner-links.svelte-1s3mcn8 a:hover{border-color:var(--warning);background:color-mix(in srgb, var(--warning) 16%, transparent);color:var(--text)}.demo-mode-banner-links.svelte-1s3mcn8 a:focus-visible{outline:2px solid color-mix(in srgb, var(--warning) 42%, transparent);outline-offset:2px}@media (width<=768px){.demo-mode-banner.svelte-1s3mcn8{grid-template-columns:auto minmax(0,1fr);align-items:flex-start}.demo-mode-banner-copy.svelte-1s3mcn8{gap:2px;display:grid}.demo-mode-banner-links.svelte-1s3mcn8{flex-wrap:wrap;grid-column:2;justify-content:flex-start}}.auth-banner.svelte-1c5yh36{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.dp-calendar.svelte-g7ga4u{flex-shrink:0;width:224px}.dp-cal-header.svelte-g7ga4u{justify-content:space-between;align-items:center;margin-bottom:8px;padding:0 4px;display:flex}.dp-cal-title.svelte-g7ga4u{font-size:13px;font-weight:600}.dp-nav-btn.svelte-g7ga4u{width:28px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:flex}.dp-nav-btn.svelte-g7ga4u:hover{background:var(--bg-surface-hover);color:var(--text)}.dp-nav-btn.svelte-g7ga4u:disabled{opacity:.3;cursor:default;pointer-events:none}.dp-nav-prev-mobile.svelte-g7ga4u{display:none}.dp-weekdays.svelte-g7ga4u{text-align:center;grid-template-columns:repeat(7,1fr);margin-bottom:4px;display:grid}.dp-weekdays.svelte-g7ga4u span:where(.svelte-g7ga4u){color:var(--text-muted);padding:4px 0;font-size:11px;font-weight:600}.dp-days.svelte-g7ga4u{grid-template-columns:repeat(7,1fr);gap:1px;display:grid}.dp-day.svelte-g7ga4u{width:32px;height:32px;color:var(--text);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:inherit;font-size:12px;transition:all .1s;display:flex}.dp-day.svelte-g7ga4u:hover:not(.disabled):not(.other-month){background:var(--bg-surface-hover)}.dp-day.other-month.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default}.dp-day.today.svelte-g7ga4u{color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);font-weight:700}.dp-day.in-range.svelte-g7ga4u{background:color-mix(in srgb, var(--accent) 15%, transparent);border-radius:0}.dp-day.range-start.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:6px 0 0 6px;font-weight:600}.dp-day.range-end.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:0 6px 6px 0;font-weight:600}.dp-day.range-start.range-end.svelte-g7ga4u{border-radius:6px}.dp-day.range-start.today.svelte-g7ga4u,.dp-day.range-end.today.svelte-g7ga4u{box-shadow:none}.dp-day.disabled.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default;pointer-events:none}@media (width<=768px){.dp-nav-prev-mobile.svelte-g7ga4u{display:flex}}.date-picker.svelte-ax7ma4{position:relative}.date-picker-trigger.svelte-ax7ma4{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;white-space:nowrap;align-items:center;gap:8px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s;display:inline-flex}.date-picker-trigger.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.date-picker-trigger.svelte-ax7ma4 svg:where(.svelte-ax7ma4){color:var(--text-muted);flex-shrink:0}.date-picker-chevron.svelte-ax7ma4{transition:transform .15s}.date-picker-chevron.open.svelte-ax7ma4{transform:rotate(180deg)}.date-picker-dropdown.svelte-ax7ma4{z-index:100;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:hidden;box-shadow:0 8px 24px #00000040}.date-picker-presets.svelte-ax7ma4{border-right:1px solid var(--border);flex-direction:column;gap:2px;min-width:140px;padding:8px;display:flex}.preset-btn.svelte-ax7ma4{color:var(--text);text-align:left;cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s}.preset-btn.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.preset-btn.active.svelte-ax7ma4{background:var(--accent);color:#fff}.date-picker-calendars.svelte-ax7ma4{flex-wrap:nowrap;gap:16px;padding:12px;display:flex}.dp-cursor-hint.svelte-ax7ma4{pointer-events:none;z-index:101;background:var(--bg-surface);color:var(--text);border:1px solid var(--accent);white-space:nowrap;border-radius:4px;align-items:center;gap:5px;padding:3px 8px;font-size:11px;font-weight:500;display:flex;position:fixed;transform:translate(12px,-50%)}.dp-cursor-hint.svelte-ax7ma4 svg:where(.svelte-ax7ma4){width:12px;height:12px;color:var(--accent);flex-shrink:0}@media (width<=768px){.date-picker-dropdown.svelte-ax7ma4{border-radius:var(--radius) var(--radius) 0 0;flex-direction:column;max-height:80vh;position:fixed;inset:auto 0 0;overflow-y:auto}.date-picker-presets.svelte-ax7ma4{-webkit-overflow-scrolling:touch;border-right:none;border-bottom:1px solid var(--border);flex-flow:row;min-width:0;overflow-x:auto}.date-picker-calendars.svelte-ax7ma4{justify-content:center}.date-picker-calendars.svelte-ax7ma4>.dp-calendar:first-child{display:none}}.segmented-control.svelte-92fh5i{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.segmented-btn.svelte-92fh5i{color:var(--text-muted);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;padding:5px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:flex}.segmented-btn.svelte-92fh5i:hover{color:var(--text)}.segmented-btn.active.svelte-92fh5i{background:var(--accent);color:#fff}@media (width<=768px){.segmented-btn.svelte-92fh5i{padding:4px 8px;font-size:11px}}.live-tokens.svelte-17qr2ta{margin-bottom:28px}.live-tokens-heading.svelte-17qr2ta{flex-direction:column;gap:2px;display:flex}.live-tokens-subtitle.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:6px;font-size:12px;display:inline-flex}.live-tokens-legend.svelte-17qr2ta{flex-wrap:wrap;gap:8px 18px;margin-bottom:16px;display:flex}.live-tokens-legend-item.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:7px;font-size:12px;display:inline-flex}.live-tokens-swatch.svelte-17qr2ta{border-radius:2px;flex-shrink:0;width:10px;height:10px}.live-tokens-legend-value.svelte-17qr2ta{color:var(--text);font-weight:600}.live-tokens-empty.svelte-17qr2ta .live-tokens-empty-text:where(.svelte-17qr2ta){color:var(--text-muted);font-size:13px}.provider-status-flag.svelte-6tr9cf{grid-column:span 2}.provider-status-overview-card.svelte-6tr9cf{grid-column:span 1}.provider-status-flag.is-healthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, var(--bg-surface))}.provider-status-flag.is-degraded.svelte-6tr9cf{border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-flag.is-unhealthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface))}.provider-status-value.svelte-6tr9cf{margin-bottom:8px}.provider-status-card-link.svelte-6tr9cf{color:var(--accent-strong,var(--accent));font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;margin:0;padding:0;font-size:13px;font-weight:600}.provider-status-card-link.svelte-6tr9cf:hover{color:var(--text);text-decoration:underline}.provider-status-card-link.svelte-6tr9cf:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:3px;border-radius:4px}.provider-status-card-note.svelte-6tr9cf{color:var(--text-muted);font-size:13px;display:block}@media (width>=720px){.card-wide.svelte-6tr9cf{grid-column:span 2}}.cache-token-value.svelte-6tr9cf{flex-wrap:wrap;align-items:center;gap:6px;line-height:1;display:flex}.cache-token-part.svelte-6tr9cf{align-items:center;display:inline-flex}.cache-token-operator.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;font-size:24px;font-weight:600;line-height:1}.cache-token-marker.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;text-transform:uppercase;margin-left:2px;font-size:14px;font-weight:700}.prompt-cache-gauge.svelte-6tr9cf{width:120px;height:60px;margin:8px auto 0;position:relative;overflow:hidden}.prompt-cache-gauge.svelte-6tr9cf canvas{display:block}.prompt-cache-gauge-value.svelte-6tr9cf{text-align:center;color:var(--text);font-size:18px;font-weight:700;line-height:1;position:absolute;bottom:4px;left:0;right:0}@media (width<=768px){.provider-status-flag.svelte-6tr9cf{grid-column:span 1}}.mcp-servers-flag.svelte-6tr9cf{grid-column:span 1}.cache-meter-header.svelte-1yzecxj{flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:16px;display:flex}.cache-meter-header.svelte-1yzecxj h3{font-size:16px;font-weight:600}.cache-meter-subtitle.svelte-1yzecxj{color:var(--text-muted);font-size:13px}.cache-meter-bar.svelte-1yzecxj{background:var(--bg-surface-hover);border-radius:6px;width:100%;height:28px;display:flex;overflow:hidden}.cache-meter-segment.svelte-1yzecxj{justify-content:center;align-items:center;min-width:3px;height:100%;transition:width .3s;display:flex;overflow:hidden}.cache-meter-segment-label.svelte-1yzecxj{color:#fff;white-space:nowrap;text-shadow:0 1px 2px #00000073;font-size:12px;font-weight:600;line-height:1}.cache-meter-segment.svelte-1yzecxj+.cache-meter-segment:where(.svelte-1yzecxj){box-shadow:-1px 0 0 var(--bg-surface)}.cache-meter-bar.is-empty.svelte-1yzecxj{background:var(--bg-surface-hover);justify-content:center;align-items:center;height:auto;min-height:28px;padding:6px 12px}.cache-meter-legend.svelte-1yzecxj{flex-wrap:wrap;gap:10px 24px;margin-top:16px;display:flex}.cache-meter-legend-item.svelte-1yzecxj{align-items:center;gap:8px;font-size:13px;display:flex}.cache-meter-swatch.svelte-1yzecxj{border-radius:3px;flex-shrink:0;width:12px;height:12px}.cache-meter-legend-label.svelte-1yzecxj{color:var(--text)}.cache-meter-legend-pct.svelte-1yzecxj{color:var(--text);font-weight:600}.cache-meter-legend-tokens.svelte-1yzecxj{color:var(--text-muted)}.cache-meter-empty.svelte-1yzecxj{color:var(--text-muted);text-align:center;font-size:13px}.spinner.svelte-b54l9o{width:var(--spinner-size);height:var(--spinner-size);border:2px solid var(--border,#80808059);border-top-color:var(--accent,currentColor);border-radius:50%;flex:none;animation:.7s linear infinite svelte-b54l9o-spinner-rotate;display:inline-block}@keyframes svelte-b54l9o-spinner-rotate{to{transform:rotate(360deg)}}.contribution-calendar-section.svelte-3hfxuq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-top:24px;padding:24px}.contribution-calendar-header.svelte-3hfxuq{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.contribution-calendar-header.svelte-3hfxuq h3{font-size:16px;font-weight:600}.contribution-calendar-grid-wrapper.svelte-3hfxuq{gap:8px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq{flex-direction:column;gap:2px;padding-top:22px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq span{height:13px;color:var(--text-muted);text-align:right;min-width:28px;font-size:10px;line-height:13px}.contribution-calendar-scroll.svelte-3hfxuq{--contribution-week-size:13px;--contribution-week-gap:2px;flex:1;min-width:0;overflow-x:auto}.contribution-calendar-months.svelte-3hfxuq{grid-auto-columns:var(--contribution-week-size);gap:var(--contribution-week-gap);grid-auto-flow:column;height:16px;margin-bottom:6px;display:grid}.contribution-calendar-month-label.svelte-3hfxuq{color:var(--text-muted);white-space:nowrap;font-size:10px}.contribution-calendar-grid.svelte-3hfxuq{gap:var(--contribution-week-gap);display:flex}.contribution-calendar-week.svelte-3hfxuq{flex-direction:column;gap:2px;display:flex}.contribution-calendar-cell.svelte-3hfxuq{width:var(--contribution-week-size);height:var(--contribution-week-size);background:var(--cal-level-0);border-radius:2px}.contribution-calendar-cell.level-1.svelte-3hfxuq{background:var(--cal-level-1)}.contribution-calendar-cell.level-2.svelte-3hfxuq{background:var(--cal-level-2)}.contribution-calendar-cell.level-3.svelte-3hfxuq{background:var(--cal-level-3)}.contribution-calendar-cell.level-4.svelte-3hfxuq{background:var(--cal-level-4)}.contribution-calendar-cell.level-5.svelte-3hfxuq{background:var(--cal-level-5)}.contribution-calendar-cell.level-6.svelte-3hfxuq{background:var(--cal-level-6)}.contribution-calendar-cell.level-7.svelte-3hfxuq{background:var(--cal-level-7)}.contribution-calendar-cell.level-8.svelte-3hfxuq{background:var(--cal-level-8)}.contribution-calendar-cell.level-9.svelte-3hfxuq{background:var(--cal-level-9)}.contribution-calendar-cell.level-10.svelte-3hfxuq{background:var(--cal-level-10)}.contribution-calendar-cell.empty.svelte-3hfxuq{background:0 0}.contribution-calendar-footer.svelte-3hfxuq{justify-content:space-between;align-items:center;gap:12px;margin-top:12px;display:flex}.contribution-calendar-meta.svelte-3hfxuq{flex-direction:column;gap:4px;display:flex}.contribution-calendar-summary.svelte-3hfxuq{color:var(--text-muted);font-size:12px}.contribution-calendar-legend.svelte-3hfxuq{color:var(--text-muted);align-items:center;gap:4px;font-size:11px;display:flex}.contribution-calendar-legend.svelte-3hfxuq .contribution-calendar-cell:where(.svelte-3hfxuq){cursor:default;width:11px;height:11px}.contribution-calendar-tooltip.svelte-3hfxuq{z-index:200;background:var(--bg-surface);color:var(--text);border:1px solid var(--border);white-space:nowrap;pointer-events:none;border-radius:4px;padding:4px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;position:fixed;transform:translate(-50%);box-shadow:0 4px 12px #0003}@media (width<=768px){.contribution-calendar-day-labels.svelte-3hfxuq{display:none}.contribution-calendar-section.svelte-3hfxuq{padding:16px}.contribution-calendar-footer.svelte-3hfxuq{flex-direction:column;align-items:flex-start}}.inline-help-toggle.is-open.svelte-y40or3{color:var(--text);background:0 0}.inline-help-toggle.is-open.svelte-y40or3 .inline-help-toggle-icon{transform:rotate(540deg)}.audit-stats-section.svelte-14e9yan{margin-top:24px}.audit-stats-header.svelte-14e9yan{align-items:flex-start}.audit-stats-kpis.svelte-14e9yan{flex-wrap:wrap;align-items:center;gap:14px;display:flex}.audit-stats-kpi.svelte-14e9yan{color:var(--text-muted);white-space:nowrap;align-items:center;gap:6px;font-size:12px;display:inline-flex}.audit-stats-kpi-value.svelte-14e9yan{color:var(--text);font-size:13px}.audit-stats-kpi-dot.svelte-14e9yan{border-radius:2px;flex-shrink:0;width:8px;height:8px}.audit-stats-dot-2xx.svelte-14e9yan{background:var(--success)}.audit-stats-dot-4xx.svelte-14e9yan{background:var(--warning)}.audit-stats-dot-5xx.svelte-14e9yan{background:var(--danger)}.provider-status-details.svelte-6y9wjv{opacity:0;grid-template-rows:0fr;transition:grid-template-rows .28s,opacity .22s;display:grid}.provider-status-details.is-expanded.svelte-6y9wjv{opacity:1;grid-template-rows:1fr}.provider-status-details.is-collapsed.svelte-6y9wjv{pointer-events:none}.provider-status-details-inner.svelte-6y9wjv{flex-direction:column;gap:14px;min-height:0;display:flex;overflow:hidden}.provider-status-reason.svelte-6y9wjv{color:var(--text-muted);font-size:13px}.provider-status-error.svelte-6y9wjv{color:var(--danger);overflow-wrap:break-word;font-size:12px}.provider-status-config-label.svelte-6y9wjv{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-config.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;padding-top:12px;display:flex}.provider-status-config-row.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-config-value.svelte-6y9wjv{color:var(--text);overflow-wrap:break-word;font-size:13px;display:block}.provider-status-health.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;margin-bottom:12px;padding-top:12px;display:flex}.provider-status-health-state.svelte-6y9wjv{border:1px solid var(--border);border-radius:999px;align-items:center;padding:1px 8px;font-size:12px;font-weight:600;display:inline-flex}.provider-status-health-state.is-healthy.svelte-6y9wjv{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-health-state.is-degraded.svelte-6y9wjv{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-health-state.is-unhealthy.svelte-6y9wjv{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-health-models.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-health-model.svelte-6y9wjv{color:var(--text);justify-content:space-between;gap:8px;font-size:13px;display:flex}.provider-status-health-model.is-flagged.svelte-6y9wjv{color:var(--danger)}.provider-status-health-model-name.svelte-6y9wjv{overflow-wrap:anywhere}.provider-status-health-model-stats.svelte-6y9wjv{white-space:nowrap;color:var(--text-muted)}.provider-status-health-model.is-flagged.svelte-6y9wjv .provider-status-health-model-stats:where(.svelte-6y9wjv){color:var(--danger);font-weight:700}.provider-status-card.svelte-nopjmh{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:14px;padding:18px;display:flex}.provider-status-card-toggle.svelte-nopjmh{border:0;border-top:1px solid var(--border);border-radius:0 0 var(--radius) var(--radius);color:var(--text-muted);cursor:pointer;background:0 0;justify-content:center;align-items:center;margin:auto -18px -18px;padding:7px 0;transition:background .15s,color .15s;display:flex}.provider-status-card-toggle.svelte-nopjmh:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);color:var(--text)}.provider-status-card-toggle.svelte-nopjmh:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:-2px}.provider-status-card-toggle.svelte-nopjmh .provider-status-card-toggle-icon{width:16px;height:16px;transition:transform .28s;display:block}.provider-status-card-toggle.is-expanded.svelte-nopjmh .provider-status-card-toggle-icon{transform:rotate(180deg)}.provider-status-card-head.svelte-nopjmh{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.provider-status-name.svelte-nopjmh{letter-spacing:-.02em;flex-wrap:wrap;align-items:baseline;gap:6px;font-size:16px;font-weight:700;display:flex}.provider-doc-help.svelte-nopjmh{align-self:center;text-decoration:none}.provider-status-name-type.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-pill.svelte-nopjmh{border:1px solid var(--border);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;min-height:28px;padding:0 10px;font-size:12px;font-weight:700;display:inline-flex}.provider-status-pill.is-healthy.svelte-nopjmh{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-pill.is-degraded.svelte-nopjmh{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-pill.is-unhealthy.svelte-nopjmh{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-meta.svelte-nopjmh{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.provider-status-meta-item.svelte-nopjmh{background:var(--bg);border:1px solid var(--border);border-radius:6px;flex-direction:column;gap:4px;padding:10px 12px;display:flex}.provider-status-meta-label.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-meta-value.svelte-nopjmh{color:var(--text);font-size:14px}@media (width<=768px){.provider-status-meta.svelte-nopjmh{grid-template-columns:1fr}}.provider-status-section-loading.svelte-1kx3uw4{justify-content:center;padding:24px 0;display:flex}.provider-status-section-header.svelte-1kx3uw4{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px;display:flex}.provider-status-toggle.svelte-1kx3uw4{background:var(--bg-surface);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:10px;padding:8px 12px;font-family:inherit;font-size:12px;font-weight:600;transition:background-color .18s,border-color .18s,color .18s;display:inline-flex}.provider-status-toggle.svelte-1kx3uw4:hover{background:var(--bg-surface-hover)}.provider-status-toggle.svelte-1kx3uw4:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.provider-status-toggle-copy.svelte-1kx3uw4{white-space:nowrap}.provider-status-toggle-track.svelte-1kx3uw4{background:color-mix(in srgb, var(--text-muted) 35%, var(--border));border-radius:999px;flex-shrink:0;width:34px;height:20px;transition:background-color .2s;position:relative}.provider-status-toggle-track.is-active.svelte-1kx3uw4{background:color-mix(in srgb, var(--accent) 82%, var(--bg-surface))}.provider-status-toggle-thumb.svelte-1kx3uw4{background:#fff;border-radius:50%;width:16px;height:16px;transition:transform .2s;position:absolute;top:2px;left:2px;box-shadow:0 1px 3px #0000003d}.provider-status-toggle-track.is-active.svelte-1kx3uw4 .provider-status-toggle-thumb:where(.svelte-1kx3uw4){transform:translate(14px)}.provider-status-grid.svelte-1kx3uw4{grid-template-columns:repeat(auto-fit,minmax(280px,1fr));align-items:start;gap:16px;display:grid}@media (width<=768px){.provider-status-section-header.svelte-1kx3uw4{flex-direction:column;align-items:flex-start}.provider-status-toggle.svelte-1kx3uw4{justify-content:space-between;width:100%}}.filter-input-wrap.svelte-30xz1k{flex:1;width:100%;min-width:min(400px,100%);display:flex;position:relative}.filter-input.svelte-30xz1k{flex:1;width:100%;min-width:0;padding-left:34px}.filter-input-wrap.svelte-30xz1k .filter-input-icon{width:14px;height:14px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.usage-page-filters.svelte-1oi6ywk{flex-wrap:wrap;gap:10px;margin-bottom:20px;display:flex}.usage-page-filters.svelte-1oi6ywk .usage-log-select{flex:0 auto}.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:220px;min-width:180px;max-width:360px}@media (width<=768px){.usage-page-filters.svelte-1oi6ywk .usage-log-select,.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:100%;max-width:none}}.pro-saved-value.svelte-1qiwzdu{flex-wrap:wrap;align-items:baseline;gap:8px;display:flex}.pro-saved-delta.svelte-1qiwzdu{color:var(--success);letter-spacing:0;font-size:13px;font-weight:600}.usage-breakdown-loading.svelte-1kee4g8{justify-content:center;align-items:center;min-height:120px;display:flex}.chart-view-toggle.svelte-1kee4g8{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.chart-view-btn.svelte-1kee4g8{width:30px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:inline-flex}.chart-view-btn.svelte-1kee4g8:hover{color:var(--text)}.chart-view-btn.active.svelte-1kee4g8{background:var(--accent);color:#fff}.chart-view-btn.svelte-1kee4g8 svg{fill:none;stroke:currentColor;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:16px;height:16px}.usage-chart-table-wrapper.svelte-1kee4g8{-webkit-overflow-scrolling:touch;margin-top:0;overflow-x:auto}.usage-chart-data-table.svelte-1kee4g8{min-width:max-content}.usage-chart-data-table.svelte-1kee4g8 th,.usage-chart-data-table.svelte-1kee4g8 td{white-space:nowrap}.pagination-info.svelte-1imew3q{color:var(--text-muted);font-size:13px}.pagination-buttons.svelte-1imew3q{gap:8px;display:flex}.usage-log-loading.svelte-hg4ill{justify-content:center;align-items:center;min-height:120px;display:flex}.usage-log-section.svelte-hg4ill{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.usage-log-section.svelte-hg4ill h3{margin-bottom:16px;font-size:16px;font-weight:600}.usage-log-section.svelte-hg4ill .table-wrapper{overflow-x:auto}.usage-log-toolbar.svelte-hg4ill{gap:12px;margin-bottom:16px;display:grid}.usage-filter-row.svelte-hg4ill{grid-template-columns:repeat(12,minmax(0,1fr));align-items:center;gap:12px;display:grid}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1/-1}.usage-filter-row-options.svelte-hg4ill{grid-template-columns:1fr}.usage-log-checkbox.svelte-hg4ill{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.usage-log-checkbox.svelte-hg4ill input{cursor:pointer;width:16px;height:16px}.usage-ts.svelte-hg4ill{white-space:nowrap;font-size:12px}.usage-log-row-cached.svelte-hg4ill td{opacity:.75;font-style:italic}.usage-log-row-cached.svelte-hg4ill .usage-log-cache-cell:where(.svelte-hg4ill){font-weight:700}.caveat-icon.svelte-hg4ill{color:var(--warning);cursor:help;margin-left:4px;font-size:14px}@media (width<=768px){.usage-log-toolbar.svelte-hg4ill{gap:10px}.usage-filter-row.svelte-hg4ill{grid-template-columns:1fr}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1}.usage-log-table.svelte-hg4ill{display:block;overflow-x:auto}}.usage-sticky-controls.svelte-spwie6{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}.usage-charts-grid.svelte-spwie6{flex-wrap:wrap;gap:24px;margin-bottom:24px;display:flex}.usage-charts-grid.svelte-spwie6 .model-chart-section{flex:calc(50% - 24px);min-width:420px;margin-bottom:0}@media (width<=520px){.usage-charts-grid.svelte-spwie6 .model-chart-section{min-width:0}}.loading-state.svelte-hzxv1d{min-height:var(--loading-state-min-height,64px);color:var(--text-muted);justify-content:center;align-items:center;gap:10px;font-size:14px;display:flex}.budget-bar-text-row-on-fill.svelte-1jm56wo{color:#fff;clip-path:inset(0 calc(100% - var(--budget-progress,0%)) 0 0)}.budget-bar-text-start.svelte-1jm56wo{left:8px;transform:translateY(-50%)}.budget-bar-track-period-custom.svelte-1jm56wo .budget-bar-text-row-on-fill:where(.svelte-1jm56wo){color:#3f332a}.budget-override-dialog.svelte-13ryo7h{max-width:460px}.budget-sort-control.svelte-1752fqe{align-items:center;gap:8px}.budget-sort-control.svelte-1752fqe label{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.budget-sort-select.svelte-1752fqe{background-color:var(--bg-surface);min-width:132px}.budget-sort-select.svelte-1752fqe:hover{background-color:var(--bg-surface-hover)}.model-name-cell.svelte-1iynym{flex-direction:column;gap:8px;display:flex}.model-name-primary.svelte-1iynym{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.model-name-secondary.svelte-1iynym{color:var(--text-muted);font-size:12px}.model-redirect-remove-btn.svelte-1iynym{appearance:none;color:var(--danger);cursor:pointer;background:0 0;border:0;margin-left:4px;padding:0;font-size:11px}.model-redirect-remove-btn.svelte-1iynym:hover:not(:disabled){text-decoration:underline}.model-redirect-remove-btn.svelte-1iynym:disabled{opacity:.45;cursor:default}.model-kind-icon.svelte-1iynym{border:1px solid color-mix(in srgb, var(--accent) 55%, var(--border));background:var(--bg);width:24px;height:24px;color:var(--accent);border-radius:999px;flex:0 0 24px;justify-content:center;align-items:center;display:inline-flex}.model-kind-icon-svg.svelte-1iynym{width:14px;height:14px}.model-row-actions.svelte-1iynym{text-align:right;width:170px}@media (width<=768px){.model-name-primary.svelte-1iynym{flex-direction:column;align-items:flex-start}}.provider-group-row.svelte-1911hy6 td{background:color-mix(in srgb, var(--accent) 6%, var(--bg));padding-top:12px;padding-bottom:12px}.provider-group-row.svelte-1911hy6:hover td{background:color-mix(in srgb, var(--accent) 8%, var(--bg))}.provider-group-header.svelte-1911hy6{justify-content:space-between;align-items:center;gap:16px;display:flex}.provider-group-meta.svelte-1911hy6{flex-direction:column;gap:4px;min-width:0;display:flex}.provider-group-title.svelte-1911hy6{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.provider-group-type.svelte-1911hy6,.provider-group-count.svelte-1911hy6,.provider-group-summary.svelte-1911hy6{color:var(--text-muted);font-size:12px}@media (width<=768px){.provider-group-header.svelte-1911hy6{flex-direction:column;align-items:flex-start}}.vm-session-affinity-checkbox.svelte-d1j6xw{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.vm-session-affinity-checkbox.svelte-d1j6xw input:where(.svelte-d1j6xw){accent-color:var(--accent);cursor:pointer}.pricing-override-rows.svelte-u8snes{gap:12px;display:grid}.pricing-override-row.svelte-u8snes{grid-template-columns:minmax(220px,1fr) minmax(130px,180px) 32px;align-items:end;gap:12px;display:grid}.pricing-override-row-actions.svelte-u8snes{justify-content:flex-start;display:flex}.pricing-override-tier-note.svelte-u8snes{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:6px;padding:10px 12px;font-size:13px}.pricing-preview.svelte-u8snes{border:1px solid var(--border);border-radius:6px;overflow:hidden}.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:minmax(150px,1fr) minmax(90px,auto) minmax(130px,.8fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.pricing-preview-header.svelte-u8snes{background:var(--bg);color:var(--text-muted);text-transform:uppercase;font-size:12px;font-weight:600}.pricing-preview-row.svelte-u8snes{border-top:1px solid var(--border);font-size:13px}.pricing-preview-row-empty.svelte-u8snes{color:var(--text-muted);grid-template-columns:1fr}@media (width<=768px){.pricing-override-row.svelte-u8snes,.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:1fr}}.failover-drafts-editor.svelte-1n87bip{flex-direction:column;gap:16px;display:flex}.failover-draft-header-actions.svelte-1n87bip{flex:none;align-items:center;gap:10px;display:flex}.failover-draft-counter.svelte-1n87bip{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.failover-draft-toolbar.svelte-1n87bip{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.failover-draft-toolbar.svelte-1n87bip .filter-input-wrap,.failover-draft-toolbar.svelte-1n87bip .filter-input{min-width:0}.failover-draft-toggle-all.svelte-1n87bip{flex:none}.failover-draft-list.svelte-1n87bip{flex-direction:column;gap:8px;max-height:min(52vh,430px);padding-right:4px;display:flex;overflow-y:auto}.failover-draft-row.svelte-1n87bip{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);cursor:pointer;grid-template-columns:18px minmax(0,1fr);align-items:start;gap:10px;padding:10px;display:grid}.failover-draft-row.svelte-1n87bip:hover{border-color:color-mix(in srgb, var(--accent) 42%, var(--border));background:var(--bg-surface-hover)}.failover-draft-row.svelte-1n87bip input{width:16px;height:16px;margin-top:2px}.failover-draft-copy.svelte-1n87bip{gap:4px;min-width:0;display:grid}.failover-draft-source.svelte-1n87bip,.failover-draft-targets.svelte-1n87bip{overflow-wrap:anywhere}.failover-draft-targets.svelte-1n87bip{color:var(--text-muted);font-size:12px}.failover-drafts-empty.svelte-1n87bip{align-items:center;min-height:96px;display:flex}.failover-draft-actions.svelte-1n87bip{margin-top:0}.category-tabs.svelte-scpjps{-webkit-overflow-scrolling:touch;align-items:center;gap:4px;margin-bottom:16px;padding-bottom:2px;display:flex;overflow-x:auto}.category-tab.svelte-scpjps{background:var(--bg-surface);border:1px solid var(--border);color:var(--text-muted);cursor:pointer;white-space:nowrap;border-radius:6px;flex-shrink:0;align-items:center;gap:6px;padding:6px 14px;font-family:inherit;font-size:13px;font-weight:500;transition:all .15s;display:inline-flex}.category-tab.svelte-scpjps:hover{color:var(--text);background:var(--bg-surface-hover)}.category-tab.active.svelte-scpjps{background:var(--accent);color:#fff;border-color:var(--accent)}.category-tab.svelte-scpjps .tab-count:where(.svelte-scpjps){background:#ffffff26;border-radius:9px;justify-content:center;align-items:center;min-width:20px;height:18px;padding:0 5px;font-size:11px;font-weight:600;line-height:1;display:inline-flex}.category-tab.svelte-scpjps:not(.active) .tab-count:where(.svelte-scpjps){background:var(--bg)}@media (width<=768px){.category-tabs.svelte-scpjps{gap:4px}.category-tab.svelte-scpjps{padding:5px 10px;font-size:12px}}.workflow-pipeline-meta.svelte-1viff7o{border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 86%, transparent);min-width:0;max-width:calc(100% - 28px);color:var(--text-muted);white-space:nowrap;appearance:none;cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:0;padding:2px 10px;font-size:12px;font-weight:500;line-height:1.2;transition:background-color .15s,border-color .15s,color .15s,box-shadow .15s;display:inline-flex;position:absolute;top:12px;right:14px;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover,.workflow-pipeline-meta.svelte-1viff7o:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface));color:color-mix(in srgb, var(--accent) 74%, var(--text))}.workflow-pipeline-meta.svelte-1viff7o:focus-visible{box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);outline:none}.workflow-pipeline-meta-label.svelte-1viff7o{flex:none;font-weight:700}.workflow-pipeline-meta-placeholder.svelte-1viff7o{opacity:1;flex:none;max-width:3ch;margin-left:4px;transition:max-width .18s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta-value.svelte-1viff7o{opacity:0;text-overflow:clip;flex:0 auto;max-width:0;margin-left:0;transition:max-width .22s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o){opacity:0;max-width:0;margin-left:0}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o){opacity:1;max-width:42ch;margin-left:4px}.workflow-pipeline-meta-icon.svelte-1viff7o{opacity:0;flex:none;justify-content:center;align-items:center;width:0;height:14px;margin-left:0;line-height:0;transition:width .18s,margin-left .18s,opacity .15s,transform .18s;display:inline-flex;overflow:hidden;transform:translate(4px)translateY(1px)scale(.84)}.workflow-pipeline-meta-icon.svelte-1viff7o svg{width:14px;height:14px}.workflow-pipeline-meta-copied.svelte-1viff7o,.workflow-pipeline-meta-copied.svelte-1viff7o:hover,.workflow-pipeline-meta-copied.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-icon:where(.svelte-1viff7o){opacity:1;width:14px;margin-left:6px;transform:translateY(1px)}.workflow-pipeline-meta-error.svelte-1viff7o,.workflow-pipeline-meta-error.svelte-1viff7o:hover,.workflow-pipeline-meta-error.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 34%, var(--border));color:var(--danger)}.workflow-pipeline.svelte-nbptrg{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg);flex-direction:column;gap:0;margin-bottom:12px;padding:18px 20px 20px;display:flex;position:relative}.workflow-pipeline-has-meta.svelte-nbptrg{padding-top:42px}.workflow-pipeline-row.svelte-nbptrg{align-items:center;width:100%;min-width:0;display:flex;overflow-x:auto}.workflow-node-icon.svelte-nbptrg{border-radius:var(--radius);background:var(--bg);width:28px;height:28px;color:var(--text-muted);justify-content:center;align-items:center;display:flex}.workflow-node-icon.svelte-nbptrg svg{stroke:currentColor;fill:none;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:15px;height:15px}.workflow-node-label.svelte-nbptrg{letter-spacing:.03em;color:var(--text);white-space:nowrap;font-size:11px;font-weight:700;line-height:1.2}.workflow-node-sub.svelte-nbptrg{color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;max-width:120px;font-size:10px;font-weight:500;line-height:1.2;font-family:var(--font-mono,ui-monospace, monospace);overflow:hidden}.workflow-node-badge.svelte-nbptrg{border-radius:var(--radius);letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;border:1px solid var(--border);background:var(--bg);color:var(--text-muted);align-items:center;padding:2px 7px;font-size:9px;font-weight:800;line-height:1.5;display:inline-flex}.workflow-node-endpoint.svelte-nbptrg{border-radius:var(--radius);border-color:var(--border);background:var(--bg-surface);flex-direction:row;gap:7px;min-width:auto;padding:10px 14px}.workflow-node-icon-endpoint.svelte-nbptrg{border-radius:var(--radius);width:auto;height:auto;color:var(--text-muted);background:0 0;justify-content:flex-start;padding:0}.workflow-node-icon-endpoint.svelte-nbptrg svg{width:14px;height:14px}.workflow-node-endpoint.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted);font-size:11px;font-weight:600}.workflow-node-feature.svelte-nbptrg{border-color:color-mix(in srgb, var(--accent) 46%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface))}.workflow-node-feature.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--accent) 16%, var(--bg));color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--accent) 70%, var(--text-muted))}.workflow-node-ai.svelte-nbptrg{border-radius:var(--radius);gap:6px;min-width:96px;padding:12px 16px}.workflow-async-section.svelte-nbptrg{justify-content:flex-end;align-items:center;gap:0;width:100%;min-width:0;margin-top:10px;display:flex}.workflow-async-turn.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 60px;height:2px;position:relative}.workflow-async-turn.svelte-nbptrg:before{content:"";background:color-mix(in srgb, var(--text-muted) 40%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);width:7px;height:9px;position:absolute;top:50%;left:-7px;transform:translateY(-50%)}.workflow-async-turn.svelte-nbptrg:after{content:"";border-right:2px dashed color-mix(in srgb, var(--text-muted) 40%, var(--border));height:16px;position:absolute;bottom:1px;right:0}.workflow-async-row.svelte-nbptrg{align-items:center;min-width:0;margin-right:7px;display:flex}.workflow-conn-async.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 24px;width:24px}.workflow-conn-async.svelte-nbptrg:after{background:color-mix(in srgb, var(--text-muted) 45%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);left:-1px;right:auto}.workflow-node-async.svelte-nbptrg{border-radius:var(--radius);border-style:dashed;flex-direction:row;gap:7px;min-width:auto;padding:7px 12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){border-radius:var(--radius);width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg) svg{width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){font-size:10px;font-weight:700}.workflow-async-label.svelte-nbptrg{letter-spacing:.1em;text-transform:uppercase;color:var(--text-muted);opacity:.55;white-space:nowrap;flex-shrink:0;align-items:center;margin-left:8px;font-size:9px;font-weight:800;display:inline-flex}.workflow-node-success.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 18%, var(--bg));color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 85%, var(--text))}.workflow-node-success.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 74%, var(--text-muted))}.workflow-node-success.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 14%, var(--bg));border-color:color-mix(in srgb, var(--success) 38%, var(--border));color:var(--success)}.workflow-node-current.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 16%, var(--bg));color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 85%, var(--text))}.workflow-node-current.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 72%, var(--text-muted))}.workflow-node-current.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 13%, var(--bg));border-color:color-mix(in srgb, var(--info) 36%, var(--border));color:var(--info)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 85%, var(--text))}.workflow-node-warning.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 72%, var(--text-muted))}.workflow-node-warning.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 38%, var(--border));color:var(--warning)}.workflow-node-error.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--danger) 14%, var(--bg));color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 85%, var(--text))}.workflow-node-error.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 72%, var(--text-muted))}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 12%, var(--bg));color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg),.workflow-node-neutral.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--text-muted) 84%, var(--border))}.workflow-node-neutral.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 10%, var(--bg));border-color:color-mix(in srgb, var(--text-muted) 28%, var(--border));color:var(--text-muted)}.workflow-conn-hit.svelte-nbptrg,.workflow-conn-hit.svelte-nbptrg:after{background:color-mix(in srgb, var(--success) 58%, var(--border))}.workflow-conn-dim.svelte-nbptrg,.workflow-conn-dim.svelte-nbptrg:after{background:color-mix(in srgb, var(--border) 75%, transparent)}.workflow-node-success.svelte-nbptrg{border-color:color-mix(in srgb, var(--success) 52%, var(--border));background:color-mix(in srgb, var(--success) 9%, var(--bg-surface))}.workflow-node-current.svelte-nbptrg{border-color:color-mix(in srgb, var(--info) 56%, var(--border));background:color-mix(in srgb, var(--info) 10%, var(--bg-surface))}.workflow-node-warning.svelte-nbptrg{border-color:color-mix(in srgb, var(--warning) 52%, var(--border));background:color-mix(in srgb, var(--warning) 9%, var(--bg-surface))}.workflow-node-error.svelte-nbptrg{border-color:color-mix(in srgb, var(--danger) 52%, var(--border));background:color-mix(in srgb, var(--danger) 9%, var(--bg-surface))}.workflow-node-neutral.svelte-nbptrg{border-color:color-mix(in srgb, var(--text-muted) 40%, var(--border));background:color-mix(in srgb, var(--text-muted) 8%, var(--bg-surface))}.workflow-node-skipped.svelte-nbptrg{opacity:.28;position:relative}.workflow-card.svelte-1fo9fvq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:16px;padding:20px;display:flex}.workflow-card-head.svelte-1fo9fvq{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-card-footer.svelte-1fo9fvq{flex-direction:column;align-items:stretch;gap:10px;display:flex}.workflow-card-head.svelte-1fo9fvq h3{font-size:18px;font-weight:700}.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq{flex-wrap:wrap;justify-content:flex-end;gap:8px;display:flex}.workflow-card-meta-footer.svelte-1fo9fvq{justify-content:flex-start}.workflow-card-footer.svelte-1fo9fvq .alias-actions-cell{align-self:flex-end}.workflow-card-description.svelte-1fo9fvq{color:var(--text-muted);font-size:14px}.workflow-guardrails.svelte-1fo9fvq{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list.svelte-1fo9fvq{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-item.svelte-1fo9fvq{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;display:flex}@media (width<=768px){.workflow-card-head.svelte-1fo9fvq,.workflow-card-footer.svelte-1fo9fvq,.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq,.workflow-guardrail-item.svelte-1fo9fvq{flex-direction:column;align-items:flex-start}}.model-editor.workflow-editor{width:min(1080px,100%);margin-bottom:0}.alert-inline-actions.svelte-1bcpzh1{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.workflow-guardrail-editor.svelte-1bcpzh1{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list-editor.svelte-1bcpzh1{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-row.svelte-1bcpzh1{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:stretch;align-items:center;gap:12px;padding:10px 12px;display:flex}.workflow-guardrail-field.svelte-1bcpzh1{flex:auto;min-width:0}.workflow-guardrail-step-field.svelte-1bcpzh1{flex:0 0 120px}.workflow-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-step-input.svelte-1bcpzh1{max-width:120px}@media (width<=768px){.workflow-guardrail-row.svelte-1bcpzh1{flex-direction:column;align-items:flex-start}.workflow-step-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-guardrail-field.svelte-1bcpzh1,.workflow-guardrail-step-field.svelte-1bcpzh1{flex-basis:auto;width:100%}}.workflow-list-loading.svelte-ie2kfk{justify-content:center;align-items:center;gap:8px;display:flex}.workflows-list.svelte-ie2kfk{min-width:0}.workflow-card-grid.svelte-ie2kfk{grid-template-columns:1fr;gap:16px;display:grid}.workflow-page-note.svelte-l8kr26{color:var(--text-muted);margin-top:6px;font-size:14px}.audit-log-toolbar.svelte-1pwbpcm{flex-direction:column;gap:10px;margin-bottom:14px;display:flex}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:repeat(12,minmax(0,1fr));gap:10px;display:grid}.audit-filter-select.svelte-1pwbpcm{grid-column:span 2;min-width:0}.audit-filter-row-search.svelte-1pwbpcm .filter-input-wrap{grid-column:1/-1;max-width:none}.audit-filter-row-controls.svelte-1pwbpcm .audit-filter-select:where(.svelte-1pwbpcm){grid-column:span 2}.audit-filter-row-controls.svelte-1pwbpcm .btn{grid-column:11/-1;justify-self:end;min-width:108px}.audit-clear-btn.svelte-1pwbpcm{justify-content:center;align-items:center;gap:8px;font-weight:600;display:inline-flex}.audit-clear-btn.svelte-1pwbpcm .table-icon-svg{width:12px;height:12px}@media (width<=768px){.audit-log-toolbar.svelte-1pwbpcm{gap:8px}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:1fr}.audit-filter-row.svelte-1pwbpcm .filter-input-wrap,.audit-filter-row.svelte-1pwbpcm .filter-input,.audit-filter-select.svelte-1pwbpcm,.audit-filter-row.svelte-1pwbpcm .btn{grid-column:auto}}.audit-live-status.svelte-tve6yv{color:var(--text-muted);align-items:center;gap:10px;margin-left:16px;padding-left:6px;font-size:12px;display:inline-flex}.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:1.8s ease-out infinite svelte-tve6yv-audit-live-dot-throb}@keyframes svelte-tve6yv-audit-live-dot-throb{0%{transform:scale(1)}35%{transform:scale(1.35)}70%{transform:scale(1)}to{transform:scale(1)}}@media (prefers-reduced-motion:reduce){.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:none}}.audit-live-status-text.is-live.svelte-tve6yv{color:var(--success);font-weight:600}.audit-entry-metadata.svelte-hyopt0{border-top:1px solid var(--border);align-items:center;gap:10px;margin-top:12px;padding-top:12px;display:flex}.audit-entry-metadata-label.svelte-hyopt0{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;flex:none;font-size:12px;font-weight:700}.audit-entry-context.svelte-hyopt0{flex-wrap:wrap;flex:auto;gap:8px;display:flex}.audit-alias-badge.svelte-hyopt0{background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 28%, var(--border));color:var(--accent-strong,var(--accent))}@media (width<=768px){.audit-entry-metadata.svelte-hyopt0{flex-direction:column;align-items:flex-start;gap:8px}}.audit-attempt-track.svelte-1eu22xn{cursor:pointer;align-items:center;gap:6px;display:inline-flex}.audit-attempt-track-pips.svelte-1eu22xn{align-items:center;gap:3px;display:inline-flex}.audit-attempt-pip.svelte-1eu22xn{background:var(--text-muted);border-radius:2px;width:8px;height:8px}.audit-attempt-pip.audit-attempt-success.svelte-1eu22xn{background:var(--success)}.audit-attempt-pip.audit-attempt-error.svelte-1eu22xn{background:var(--danger)}.audit-attempt-track-count.svelte-1eu22xn{color:var(--text-muted);font-size:11px}.audit-entry-summary.svelte-17mysgz{cursor:pointer;justify-content:space-between;align-items:center;gap:12px;padding:5px 14px;list-style:none;display:flex;position:relative}.audit-entry-summary.svelte-17mysgz::-webkit-details-marker{display:none}.audit-entry-summary-live-in-progress.svelte-17mysgz{background:color-mix(in srgb, var(--info) 7%, var(--bg))}.audit-entry-summary-has-interactions.svelte-17mysgz{padding-right:44px}.audit-entry-summary-live-in-progress.svelte-17mysgz:before{content:"";background:var(--info);pointer-events:none;width:3px;animation:1.2s ease-in-out infinite audit-live-summary-stripe-blink;position:absolute;inset:0 auto 0 0}@media (prefers-reduced-motion:reduce){.audit-entry-summary-live-in-progress.svelte-17mysgz:before{opacity:.78;animation:none}}.audit-entry-left.svelte-17mysgz{align-items:center;gap:8px;min-width:0;display:flex}.audit-entry-right.svelte-17mysgz{color:var(--text-muted);flex-shrink:0;align-items:center;gap:10px;min-height:28px;display:inline-flex}.audit-thread-expander.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);min-width:28px;height:28px;color:var(--text-muted);cursor:pointer;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;gap:3px;padding:0 7px 0 4px;transition:background .1s ease-out,color .1s ease-out;display:inline-flex}.audit-thread-expander.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 12%, var(--bg));color:var(--accent)}.audit-thread-expander.svelte-17mysgz .audit-thread-expander-svg{width:14px;height:14px}.audit-thread-count.svelte-17mysgz{font-size:11px;font-weight:600}.audit-conversation-trigger.svelte-17mysgz{border:0;border-left:1px solid var(--border);background:color-mix(in srgb, var(--accent) 12%, var(--bg));width:32px;height:100%;color:var(--accent);cursor:pointer;border-radius:0;justify-content:center;align-items:center;margin:0;transition:background .1s ease-out,color .1s ease-out;display:inline-flex;position:absolute;inset:0 0 0 auto}.audit-conversation-trigger.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 20%, var(--bg))}.audit-conversation-trigger-active.svelte-17mysgz{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 28%, var(--bg));border-left:0}.audit-conversation-trigger-active.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 34%, var(--bg))}.audit-conversation-trigger.svelte-17mysgz .audit-conversation-trigger-svg{stroke-linecap:butt;stroke-linejoin:miter;width:18px;height:18px}.audit-path.svelte-17mysgz{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.audit-request-badge.svelte-17mysgz{white-space:nowrap;gap:6px;min-width:0}.audit-timestamp-time.svelte-17mysgz{display:none}.audit-provider-model.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);height:24px;color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;border-radius:999px;align-items:center;max-width:420px;padding:0 10px;font-size:12px;display:inline-flex;overflow:hidden}@container dashboard-content (width<=699px){.audit-entry-summary.svelte-17mysgz{flex-direction:column;align-items:flex-start}.audit-entry-right.svelte-17mysgz{justify-content:space-between;width:100%}.audit-request-status.svelte-17mysgz,.audit-timestamp-full.svelte-17mysgz{display:none}.audit-timestamp-time.svelte-17mysgz{display:inline}}.audit-pane-split.svelte-1h5puht{grid-template-columns:1fr 2fr;align-items:start;gap:10px 14px;display:grid}.audit-pane-split-single.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}@container dashboard-content (width<=699px){.audit-pane-split.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}}.audit-pane-split.svelte-1h5puht .audit-pane-block-error:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-pane-empty:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-size-warning:where(.svelte-1h5puht){grid-column:1/-1}.audit-pane-block.svelte-1h5puht{min-width:0}.audit-pane-block.svelte-1h5puht>h5{margin-bottom:6px}.audit-pane-block-head.svelte-1h5puht{justify-content:space-between;align-items:center;gap:8px;margin-bottom:6px;display:flex}.audit-pane-block-title.svelte-1h5puht{align-items:center;gap:8px;min-width:0;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn{background-color:var(--bg-surface);border:1px solid color-mix(in srgb, var(--border) 70%, var(--text) 30%);color:var(--text);cursor:pointer;border-radius:6px;flex:none;align-items:center;gap:6px;padding:4px 8px;font-family:inherit;font-size:12px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn:hover:not(:disabled){background:color-mix(in srgb, var(--bg-surface) 80%, var(--text) 20%);border-color:color-mix(in srgb, var(--border) 45%, var(--text) 55%)}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 18%, var(--bg-surface))}.audit-json.svelte-1h5puht{background:var(--bg-surface);border:1px solid var(--border);box-sizing:border-box;white-space:pre;max-width:100%;max-height:220px;color:var(--text);border-radius:6px;padding:10px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;line-height:1.45;overflow:auto}.audit-pane-error-message.svelte-1h5puht{color:var(--danger)}.audit-pane-clickable-preview.svelte-1h5puht{cursor:pointer}.audit-pane-clickable-preview.svelte-1h5puht:hover{background:color-mix(in srgb, var(--danger) 8%, transparent)}.audit-json-body.svelte-1h5puht{white-space:pre;overflow-wrap:normal}.audit-pane-empty.svelte-1h5puht{text-align:left;padding:8px 0 0}.audit-pane-pending.svelte-1h5puht{align-items:center;gap:8px;display:flex}.audit-pane-streaming.svelte-1h5puht{letter-spacing:.02em;color:var(--text-muted);align-items:center;gap:7px;padding-left:4px;font-size:11px;font-weight:600;display:inline-flex}.audit-size-warning.svelte-1h5puht{color:var(--warning);margin-top:8px;font-size:12px}.audit-request-response.svelte-1bc5vi5{margin-top:4px}.audit-pane-tablist.svelte-1bc5vi5{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:2px;display:flex}.audit-pane-tab.svelte-1bc5vi5{border:1px solid var(--border);color:var(--text-muted);cursor:pointer;background:0 0;border-bottom-color:#0000;border-radius:6px 6px 0 0;align-items:center;gap:8px;margin-bottom:-1px;margin-right:12px;padding:8px 12px;font-family:inherit;font-size:13px;transition:color .15s,border-color .15s,background-color .15s;display:inline-flex}.audit-pane-tab.svelte-1bc5vi5:not(.audit-pane-tab-active):hover{color:var(--text);background:color-mix(in srgb, var(--text) 5%, transparent)}.audit-pane-tab-active.svelte-1bc5vi5{color:var(--text);border-color:var(--border);border-bottom-color:var(--bg);background:var(--bg)}.audit-pane-tab-label.svelte-1bc5vi5{font-weight:600}.audit-pane-tabpanel.svelte-1bc5vi5{min-width:0}.audit-pane-icon.svelte-1bc5vi5{color:var(--text-muted);flex:none;align-items:center;display:inline-flex}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-request{color:var(--accent)}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-response{color:var(--info)}.audit-pane-icon.svelte-1bc5vi5 svg{width:16px;height:16px}.audit-pane-seq.svelte-1bc5vi5{color:var(--text-muted);font-size:12px}.audit-pane-kind.svelte-1bc5vi5{text-transform:uppercase;letter-spacing:.04em;font-size:10px;font-weight:600}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-primary{color:var(--text-muted)}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-failover{color:var(--accent);background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-retry{color:var(--warning);background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 30%, var(--border))}.audit-savings-pill.svelte-1bc5vi5{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);color:var(--prompt-cache-color);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;font-weight:700;display:inline-flex}.audit-step-pill.svelte-1bc5vi5{border:1px dashed var(--border);color:var(--text-muted);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;display:inline-flex}.audit-entry.svelte-cmjgwr{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);transition:background .12s ease-out,border-color .12s ease-out;overflow:hidden}.audit-entry-interactions-open.svelte-cmjgwr{border-width:2px;border-color:color-mix(in srgb, var(--prompt-cache-color) 38%, var(--border))}.audit-entry-details.svelte-cmjgwr{border-top:1px solid var(--border);background:var(--bg-surface);padding:12px;overflow:hidden}.audit-thread.svelte-pneivi{flex-direction:column;gap:10px;display:flex}.audit-thread-children.svelte-pneivi{flex-direction:column;gap:10px;margin-left:26px;display:flex}.audit-thread-child.svelte-pneivi,.audit-thread-loading.svelte-pneivi{position:relative}.audit-thread-child.svelte-pneivi:before,.audit-thread-loading.svelte-pneivi:before{content:"";border-left:1px solid var(--border);border-bottom:1px solid var(--border);pointer-events:none;border-bottom-left-radius:6px;width:12px;height:calc(50% + 10px);position:absolute;top:-10px;left:-14px}.audit-thread-child.svelte-pneivi:not(:last-child):after{content:"";border-left:1px solid var(--border);pointer-events:none;position:absolute;top:50%;bottom:-10px;left:-14px}.audit-thread-loading.svelte-pneivi{padding:6px 0 6px 4px;display:flex}.audit-thread-more.svelte-pneivi{color:var(--text-muted);padding-left:4px;font-size:12px}.audit-log-loading.svelte-1nhcbov{justify-content:center;padding:2rem 0;display:flex}.audit-list-toolbar.svelte-1nhcbov{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;display:flex}.audit-list-toolbar-left.svelte-1nhcbov{flex-wrap:wrap;align-items:center;gap:16px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov{color:var(--text-muted);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:7px;font-size:13px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov input:where(.svelte-1nhcbov){accent-color:var(--accent);cursor:pointer}.audit-retention-note.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-retention-highlight.svelte-1nhcbov{color:var(--text);font-weight:600}.audit-log-section.svelte-1nhcbov{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.audit-log-summary.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-log-list.svelte-1nhcbov{flex-direction:column;gap:10px;display:flex}.settings-guardrails-list.svelte-1bvx512{min-width:0}.settings-guardrail-type-pill.svelte-1bvx512{border:1px solid color-mix(in srgb, var(--accent) 18%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent);color:var(--text);white-space:nowrap;border-radius:999px;align-items:center;padding:6px 10px;font-size:12px;font-weight:600;display:inline-flex}.settings-guardrail-summary.svelte-1bvx512{color:var(--text);font-size:14px;line-height:1.45}.settings-guardrail-description.svelte-1bvx512{color:var(--text-muted);margin-top:6px;font-size:12px}.model-editor.guardrails-editor-wide{width:min(1080px,100%)}.form-field-fieldset.svelte-s964s3{border:0;min-inline-size:0;margin:0;padding:0}.form-field-legend.svelte-s964s3{color:var(--text-muted);letter-spacing:.5px;text-transform:uppercase;padding:0;font-size:12px;font-weight:600}.model-editor.settings-guardrails-editor{min-width:0}.settings-guardrails-hero.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));border-radius:var(--radius);background:radial-gradient(circle at top right, color-mix(in srgb, var(--accent-hover) 18%, transparent), transparent 42%), radial-gradient(circle at bottom left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 40%), var(--bg-surface);justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:20px;padding:24px;display:flex}.settings-kicker.svelte-5x874c{color:var(--accent);letter-spacing:.08em;text-transform:uppercase;margin:0 0 10px;font-size:11px;font-weight:700}.settings-guardrails-hero.svelte-5x874c h3{margin-bottom:8px}.settings-guardrails-hero.svelte-5x874c p:last-child{color:var(--text-muted);margin-bottom:0}.settings-guardrails-meta.svelte-5x874c{gap:12px;display:flex}.settings-guardrails-stat.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));background:color-mix(in srgb, var(--bg-surface-hover) 76%, transparent);border-radius:16px;min-width:110px;padding:14px 16px}.settings-guardrails-stat-label.svelte-5x874c{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;margin-bottom:8px;font-size:11px;font-weight:700;display:block}.settings-guardrails-stat.svelte-5x874c strong{font-size:24px;font-weight:700}@media (width<=768px){.settings-guardrails-hero.svelte-5x874c{flex-direction:column}.settings-guardrails-meta.svelte-5x874c{width:100%}.settings-guardrails-stat.svelte-5x874c{flex:1 1 0}}.mcp-catalog-section.svelte-1xqrzco{margin-top:18px}.mcp-catalog-section.svelte-1xqrzco .form-field-label{margin-bottom:8px}.mcp-catalog-subtitle.svelte-1xqrzco{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.mcp-catalog-list.svelte-1xqrzco{flex-direction:column;gap:12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.mcp-catalog-item-name.svelte-1xqrzco{overflow-wrap:anywhere;font-size:13px}.mcp-catalog-item-aggregated.svelte-1xqrzco{color:var(--text-muted);overflow-wrap:anywhere;margin-top:2px;font-size:11px}.mcp-catalog-item-description.svelte-1xqrzco{color:var(--text-muted);margin:2px 0 0;font-size:13px;font-weight:400}.mcp-server-sub-counts.svelte-ah8nrt{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;max-width:280px;margin-top:4px;font-size:11px;overflow:hidden}.mcp-server-table-wrapper.svelte-ah8nrt{overflow-x:auto}.mcp-server-table-wrapper.svelte-ah8nrt .data-table{min-width:860px}.auth-key-form-fields.svelte-1gswxes>.form-field{margin-bottom:4px}.auth-key-dashboard-toggle.svelte-1gswxes{cursor:pointer;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-key-issued-banner.svelte-1gswxes{background:color-mix(in srgb, var(--success) 8%, var(--bg-surface));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));border-radius:var(--radius);margin-bottom:20px;padding:16px}.auth-key-issued-warning.svelte-1gswxes{color:color-mix(in srgb, var(--success) 80%, var(--text));margin-bottom:12px;font-size:13px;font-weight:600}.auth-key-issued-value-row.svelte-1gswxes{flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:12px;display:flex}.auth-key-issued-token.svelte-1gswxes{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);word-break:break-all;flex:1;min-width:0;padding:8px 12px;font-size:13px;overflow-x:auto}.usage-label-chip-static.svelte-nf0ldb,.usage-label-chip-static.svelte-nf0ldb:hover{cursor:default;background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.auth-key-redacted.svelte-nf0ldb{color:var(--text-muted);font-size:13px}.auth-key-actions-cell.svelte-nf0ldb{white-space:nowrap}.auth-key-row-deactivated.svelte-nf0ldb td:where(.svelte-nf0ldb):not(.auth-key-actions-cell){opacity:.55}.auth-key-expiry.svelte-nf0ldb{white-space:nowrap;align-items:center;gap:8px;display:inline-flex}.auth-key-th-help.svelte-nf0ldb{cursor:help;align-items:center;gap:4px;display:inline-flex}.auth-key-row-actions.svelte-nf0ldb{align-items:center;gap:6px;display:inline-flex}.auth-keys-loading.svelte-1xpdcqx{justify-content:center;align-items:center;padding:32px 0;display:flex}.auth-keys-help-notice.svelte-1xpdcqx{margin-bottom:20px}.auth-keys-inactive-toggle.svelte-1xpdcqx{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-keys-inactive-toggle.svelte-1xpdcqx input:where(.svelte-1xpdcqx){width:16px;height:16px;accent-color:var(--accent);cursor:pointer}.settings-panel-header.svelte-15kyv2y{justify-content:space-between;gap:16px;margin-bottom:20px;display:flex}.settings-panel-header.svelte-15kyv2y h3{font-size:18px}.settings-form-grid.svelte-15kyv2y{grid-template-columns:minmax(280px,420px);gap:16px;display:grid}@media (width<=768px){.settings-form-grid.svelte-15kyv2y{grid-template-columns:1fr}}.budget-settings-section.svelte-a747ys{width:100%}.budget-settings-grid.svelte-a747ys{gap:12px;display:grid}.budget-settings-row.svelte-a747ys{grid-template-columns:96px minmax(170px,1fr) minmax(110px,140px) minmax(110px,140px) minmax(220px,280px);align-items:start;gap:12px;display:grid}.budget-settings-period.svelte-a747ys{color:var(--text);letter-spacing:0;text-transform:uppercase;align-self:end;min-height:35px;padding-bottom:9px;font-size:12px;font-weight:700}.budget-settings-spacer.svelte-a747ys{min-height:1px}.budget-settings-help-cell.svelte-a747ys{align-self:start;min-width:0;min-height:35px}.budget-settings-help-cell.svelte-a747ys .inline-help-copy{max-width:280px;margin:22px 0 0;font-size:12px;line-height:1.35}@media (width<=768px){.budget-settings-grid.svelte-a747ys,.budget-settings-row.svelte-a747ys{grid-template-columns:1fr}.budget-settings-spacer.svelte-a747ys{display:none}}.tagging-settings-grid.svelte-18e8yem{gap:12px;display:grid}.tagging-settings-row.svelte-18e8yem{grid-template-columns:minmax(170px,1fr) minmax(150px,1fr) minmax(80px,110px) auto minmax(90px,auto);align-items:end;gap:12px;display:grid}.tagging-do-not-pass.svelte-18e8yem{color:var(--text);white-space:nowrap;align-items:center;gap:6px;min-height:35px;font-size:13px;display:flex}.tagging-row-trailer.svelte-18e8yem{align-items:center;gap:8px;min-height:35px;display:flex}.tagging-settings-empty.svelte-18e8yem{color:var(--text-muted);margin:0}.tagging-settings-actions.svelte-18e8yem{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.tagging-settings-row.svelte-18e8yem{grid-template-columns:1fr;align-items:stretch}.tagging-settings-actions.svelte-18e8yem,.tagging-settings-actions.svelte-18e8yem .btn{width:100%}}.pricing-recalculate-section.svelte-1cdxzyk{width:100%}.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:minmax(220px,320px) minmax(260px,360px);justify-content:start;align-items:end;gap:12px;width:100%;display:grid}.pricing-recalculate-date-field.svelte-1cdxzyk{grid-column:1/-1;width:100%;max-width:320px}.pricing-recalculate-filter-field.svelte-1cdxzyk{width:100%;max-width:360px}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker{width:100%}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-trigger{justify-content:space-between;width:100%}.pricing-recalculate-actions.svelte-1cdxzyk{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:1fr}.pricing-recalculate-actions.svelte-1cdxzyk,.pricing-recalculate-actions.svelte-1cdxzyk .btn{width:100%}}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-dropdown{inset:auto auto calc(100% + 6px) 0}.settings-refresh-icon.svelte-yeq2mp{flex:0 0 16px;width:16px;height:16px}.runtime-refresh-steps.svelte-yeq2mp{color:var(--text-muted);gap:8px;margin-top:14px;padding-left:18px;font-size:13px;display:grid}.runtime-refresh-step.is-ok.svelte-yeq2mp{color:var(--success)}.runtime-refresh-step.is-partial.svelte-yeq2mp{color:var(--warning)}.runtime-refresh-step.is-failed.svelte-yeq2mp{color:var(--danger)}.runtime-settings-copy.svelte-tldbe5{min-width:180px}.runtime-settings-fields.svelte-tldbe5{gap:16px;width:min(560px,100%);display:grid}.runtime-setting-row.svelte-tldbe5{grid-template-columns:minmax(220px,1fr) 180px;align-items:center;gap:20px;display:grid}.runtime-setting-description.svelte-tldbe5,.runtime-setting-managed.svelte-tldbe5{color:var(--text-muted);margin:4px 0 0;font-size:12px}.runtime-setting-managed.svelte-tldbe5{color:var(--warning)}@media (width<=720px){.runtime-setting-row.svelte-tldbe5{grid-template-columns:1fr;gap:8px}}.settings-version-footer.svelte-3naq7u{color:var(--text-muted);text-align:right;margin-top:24px;font-size:12px}.chat-message.svelte-12s99s5{border:1px solid var(--border);background:var(--bg);border-radius:10px;max-width:94%;padding:10px 42px 10px 12px;position:relative;overflow:hidden}.chat-message.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border));box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent)}.chat-message.is-after-anchor.svelte-12s99s5,.chat-function-note.is-after-anchor.svelte-12s99s5{opacity:.46}.chat-message.role-user.svelte-12s99s5{align-self:flex-start}.chat-message.role-assistant.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 18%, var(--bg));align-self:flex-end}.chat-message.role-system.svelte-12s99s5{background:color-mix(in srgb, var(--warning) 10%, var(--bg));align-self:center;width:100%;max-width:100%}.chat-message.role-error.svelte-12s99s5{border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg));align-self:flex-end}.chat-message.role-error.svelte-12s99s5 .chat-role:where(.svelte-12s99s5){color:color-mix(in srgb, var(--danger) 75%, var(--text-muted))}.chat-message-meta.svelte-12s99s5{justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:6px;display:flex}.chat-role.svelte-12s99s5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:12px;font-weight:700}.chat-time.svelte-12s99s5{color:var(--text-muted);white-space:nowrap;font-size:11px}.chat-content.svelte-12s99s5{white-space:pre-wrap;overflow-wrap:break-word;color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:13px;line-height:1.5}.chat-message.svelte-12s99s5:before,.chat-function-note.svelte-12s99s5:before{content:"";z-index:0;pointer-events:none;opacity:var(--prompt-cache-visibility);background:linear-gradient(90deg, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) 0, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) var(--prompt-cache-fill), transparent var(--prompt-cache-fill), transparent 100%);transition:opacity .15s;position:absolute;inset:0}.chat-message.svelte-12s99s5>:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5>:where(.svelte-12s99s5){z-index:1;position:relative}.chat-message-copy.svelte-12s99s5{z-index:2;border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 92%, transparent);width:26px;height:26px;color:var(--text-muted);opacity:0;pointer-events:none;border-radius:6px;justify-content:center;align-items:center;padding:0;transition:opacity .12s,transform .12s,color .12s,background-color .12s,border-color .12s;display:inline-flex;position:absolute;bottom:6px;right:6px;transform:translateY(3px)}.chat-message.svelte-12s99s5:hover .chat-message-copy:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5:hover .chat-message-copy:where(.svelte-12s99s5),.chat-message.svelte-12s99s5:focus-within .chat-message-copy:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5:focus-within .chat-message-copy:where(.svelte-12s99s5),.chat-message-copy.is-copied.svelte-12s99s5{opacity:1;pointer-events:auto;transform:translateY(0)}.chat-message-copy.svelte-12s99s5:hover{color:var(--text);background:var(--bg-surface-hover)}.chat-message-copy.svelte-12s99s5:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 45%, transparent);outline-offset:1px}.chat-message-copy.is-copied.svelte-12s99s5{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border))}.chat-tool-calls.svelte-12s99s5{border-top:1px solid var(--border);flex-direction:column;gap:3px;margin-top:8px;padding-top:6px;display:flex}.chat-tool-call.svelte-12s99s5{color:var(--text-muted);border-radius:5px;min-width:0;padding:3px 5px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;position:relative;overflow:hidden}.chat-tool-call-summary.svelte-12s99s5{cursor:pointer;align-items:baseline;gap:6px;min-width:0;display:flex}.chat-tool-call-preview.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;opacity:.8;flex:1;min-width:0;overflow:hidden}.chat-tool-call-arguments.svelte-12s99s5{background:color-mix(in srgb, var(--border) 45%, transparent);color:var(--text);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;border-radius:6px;max-height:200px;margin-top:5px;padding:6px 8px;line-height:1.45;overflow:auto}.chat-tool-call-name.svelte-12s99s5:before{content:"⚡"}.chat-function-note.svelte-12s99s5{max-width:94%;color:var(--text-muted);background:color-mix(in srgb, var(--border) 40%, transparent);border:1px dashed var(--border);border-radius:12px;align-self:center;padding:4px 42px 4px 12px;font-size:12px;position:relative;overflow:hidden}.chat-function-note.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-inner.svelte-12s99s5{align-items:baseline;gap:6px;min-height:26px;display:flex;overflow:hidden}.chat-function-note-inner.svelte-12s99s5 .chat-time:where(.svelte-12s99s5){flex-shrink:0;margin-left:auto}.chat-function-call-id.svelte-12s99s5{color:var(--text-muted);overflow-wrap:anywhere;margin-top:6px;font-size:10px}.chat-function-label.svelte-12s99s5{text-transform:uppercase;letter-spacing:.3px;white-space:nowrap;flex-shrink:0;font-size:11px;font-weight:600}.chat-function-label.svelte-12s99s5:before{content:"▸";margin-right:4px;transition:transform .12s;display:inline-block}.chat-function-note-details[open].svelte-12s99s5 .chat-function-label:where(.svelte-12s99s5):before{transform:rotate(90deg)}.chat-function-detail.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;overflow:hidden}.chat-function-note.role-function-call.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 8%, transparent);border-color:color-mix(in srgb, var(--accent) 30%, var(--border));align-self:flex-end}.chat-function-note.role-function-result.svelte-12s99s5{background:color-mix(in srgb, var(--success) 8%, transparent);border-color:color-mix(in srgb, var(--success) 30%, var(--border));align-self:flex-start}.chat-function-note.is-anchor.role-function-call.svelte-12s99s5,.chat-function-note.is-anchor.role-function-result.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-details.svelte-12s99s5{width:100%}.chat-function-note-details.svelte-12s99s5>summary{cursor:pointer;list-style:none}.chat-function-note-details.svelte-12s99s5>summary::-webkit-details-marker{display:none}.chat-function-expanded.svelte-12s99s5{border-top:1px solid var(--border);white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text);max-height:200px;margin-top:6px;padding-top:6px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;line-height:1.45;overflow:auto}@media (width<=768px){.chat-message.svelte-12s99s5{max-width:100%}}@media (hover:none){.chat-message-copy.svelte-12s99s5{opacity:1;pointer-events:auto;transform:none}}@media (prefers-reduced-motion:reduce){.chat-message-copy.svelte-12s99s5{transition:none}}.conversation-drawer.svelte-ssrzja{width:var(--conversation-panel-width);background:var(--bg-surface);border-left:1px solid var(--border);z-index:12;flex-direction:column;flex:none;min-width:0;height:100vh;display:flex;position:sticky;top:0}.conversation-drawer-fullscreen.svelte-ssrzja{z-index:70;border-left:0;flex-basis:auto;width:100vw;height:100dvh;position:fixed;inset:0}.conversation-drawer-fullscreen.svelte-ssrzja .conversation-resize-handle:where(.svelte-ssrzja){display:none}.conversation-resize-handle.svelte-ssrzja{z-index:2;cursor:col-resize;touch-action:none;background:0 0;border:0;border-radius:0;outline:none;width:10px;padding:0;position:absolute;top:0;bottom:0;left:-5px}.conversation-resize-handle.svelte-ssrzja:after{content:"";background:0 0;width:2px;transition:background .15s;position:absolute;top:0;bottom:0;left:4px}.conversation-resize-handle.svelte-ssrzja:hover:after,.conversation-resize-handle.svelte-ssrzja:focus-visible:after{background:color-mix(in srgb, var(--accent) 70%, var(--border))}body.conversation-panel-resizing{cursor:col-resize;-webkit-user-select:none;user-select:none}.conversation-drawer-header.svelte-ssrzja{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:10px;padding:14px 16px;display:flex}.conversation-drawer-header-actions.svelte-ssrzja{align-items:center;gap:6px;display:flex}.conversation-drawer-title.svelte-ssrzja{align-items:center;gap:9px;min-width:0;display:flex}.conversation-follow-status.svelte-ssrzja{justify-content:center;align-items:center;margin:-4px;padding:4px;display:inline-flex}.conversation-drawer-header.svelte-ssrzja h3{font-size:16px;font-weight:700}#interactions-drawer-content.svelte-ssrzja{position:relative}.conversation-message-navigation.svelte-ssrzja{z-index:4;opacity:0;pointer-events:none;flex-direction:column;gap:4px;width:max-content;height:0;margin-left:auto;margin-right:12px;transition:opacity .12s,transform .12s;display:flex;position:sticky;top:12px;transform:translateY(-3px)}#interactions-drawer-content.svelte-ssrzja:hover .conversation-message-navigation:where(.svelte-ssrzja),.conversation-message-navigation.svelte-ssrzja:focus-within{opacity:1;pointer-events:auto;transform:translateY(0)}.conversation-message-navigation.svelte-ssrzja button:where(.svelte-ssrzja){border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 94%, transparent);width:30px;height:30px;color:var(--text-muted);border-radius:6px;justify-content:center;align-items:center;padding:0;display:inline-flex;box-shadow:0 1px 3px #00000029}.conversation-message-navigation.svelte-ssrzja button:where(.svelte-ssrzja):hover{color:var(--text);background:var(--bg-surface-hover)}.conversation-message-navigation.svelte-ssrzja button:where(.svelte-ssrzja):focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 45%, transparent);outline-offset:1px}.conversation-drawer-footer.svelte-ssrzja{border-top:1px solid var(--border);background:var(--bg-surface);flex-direction:column;flex-shrink:0;gap:9px;padding:10px 16px;display:flex}.conversation-composer.svelte-ssrzja{flex-direction:column;gap:7px;display:flex}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja){resize:vertical;border:1px solid var(--border);background:var(--bg);width:100%;min-height:50px;color:var(--text);font:inherit;border-radius:7px;padding:9px 10px;line-height:1.45}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):focus{outline:2px solid color-mix(in srgb, var(--accent) 38%, transparent);outline-offset:1px}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):disabled{opacity:.65}.conversation-composer-actions.svelte-ssrzja{justify-content:space-between;align-items:center;gap:10px;display:flex}.conversation-endpoint.svelte-ssrzja{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--text-muted);font-size:11px;overflow:hidden}.conversation-send-error.svelte-ssrzja{color:var(--danger);font-size:12px}.conversation-truncated.svelte-ssrzja{color:var(--text-muted);padding:0 16px 14px;font-size:12px}.conversation-cache-legend.svelte-ssrzja{color:var(--text-muted);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:7px;margin:12px 16px 0;padding:0;font-family:inherit;font-size:11px;display:flex}.conversation-cache-legend.svelte-ssrzja:hover{color:var(--text)}.conversation-cache-legend.svelte-ssrzja:focus-visible{outline:2px solid color-mix(in srgb, var(--prompt-cache-color) 35%, transparent);outline-offset:3px;border-radius:3px}.conversation-cache-switch.svelte-ssrzja{background:color-mix(in srgb, var(--text-muted) 30%, var(--border));border-radius:999px;flex:none;width:28px;height:16px;transition:background-color .15s;position:relative}.conversation-cache-switch.is-active.svelte-ssrzja{background:color-mix(in srgb, var(--prompt-cache-color) 80%, var(--bg))}.conversation-cache-switch-thumb.svelte-ssrzja{background:#fff;border-radius:50%;width:12px;height:12px;transition:transform .15s;position:absolute;top:2px;left:2px;box-shadow:0 1px 2px #0000003d}.conversation-cache-switch.is-active.svelte-ssrzja .conversation-cache-switch-thumb:where(.svelte-ssrzja){transform:translate(12px)}.conversation-cache-estimate.svelte-ssrzja{opacity:.75}.conversation-thread.svelte-ssrzja{flex-direction:column;gap:10px;padding:14px 16px 20px;display:flex}.conversation-live-status.svelte-ssrzja{color:var(--text-muted);align-items:center;gap:10px;padding:4px 16px 20px;font-size:13px;display:flex}@media (hover:none){.conversation-message-navigation.svelte-ssrzja{opacity:1;pointer-events:auto;transform:none}}@media (prefers-reduced-motion:reduce){.conversation-message-navigation.svelte-ssrzja{transition:none}} +:root{--bg:#111110;--bg-surface:#1e1d1c;--bg-surface-hover:#2a2420;--border:#2a2826;--text:#e8e0d6;--text-muted:#9a918a;--accent:#b8956e;--accent-hover:#d4b896;--success:#34d399;--info:#3b82f6;--warning:#f59e0b;--danger:#ef4444;--prompt-cache-color:color-mix(in srgb, var(--info) 72%, #fff);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 24%, var(--bg-surface));--cache-meter-uncached:var(--token-input);--cache-meter-local:var(--token-local);--cache-meter-prompt:var(--token-prompt);--token-input:#c0824a;--token-output:#ddb27a;--token-prompt:color-mix(in srgb, var(--info) 60%, transparent);--token-local:color-mix(in srgb, var(--info) 20%, transparent);--sidebar-width:240px;--radius:8px;--chart-grid:#2a2826;--chart-text:#9a918a;--chart-day-marker:var(--text);--chart-tooltip-bg:#1e1d1c;--chart-tooltip-border:#2a2826;--chart-tooltip-text:#e8e0d6;--cal-level-0:#161b22;--cal-level-1:color-mix(in srgb, var(--info) 15%, var(--bg-surface));--cal-level-2:color-mix(in srgb, var(--info) 25%, var(--bg-surface));--cal-level-3:color-mix(in srgb, var(--info) 36%, var(--bg-surface));--cal-level-4:color-mix(in srgb, var(--info) 48%, var(--bg-surface));--cal-level-5:color-mix(in srgb, var(--info) 60%, var(--bg-surface));--cal-level-6:color-mix(in srgb, var(--info) 73%, var(--bg-surface));--cal-level-7:color-mix(in srgb, var(--info) 87%, var(--bg-surface));--cal-level-8:var(--info);--cal-level-9:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-10:color-mix(in srgb, var(--info) 62%, #fff);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface-hover) 86%, #fff 14%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface-hover) 72%, #fff 28%);--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}[data-theme=light]{--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}@media (prefers-color-scheme:light){:root:not([data-theme=dark]){--bg:#f5f0ea;--bg-surface:#fff;--bg-surface-hover:#ece5dc;--border:#e8e0d6;--text:#2d2519;--text-muted:#7a7068;--accent:#755c3d;--accent-hover:#9a7d5a;--success:#34d399;--info:#2563eb;--warning:#d97706;--danger:#dc2626;--prompt-cache-color:color-mix(in srgb, var(--info) 84%, #0f172a);--prompt-cache-color-bg:color-mix(in srgb, var(--token-prompt) 18%, var(--bg-surface));--chart-grid:#e8e0d6;--chart-text:#7a7068;--chart-day-marker:var(--text);--chart-tooltip-bg:#fff;--chart-tooltip-border:#e8e0d6;--chart-tooltip-text:#2d2519;--cal-level-0:#ebedf0;--cal-level-1:color-mix(in srgb, var(--info) 12%, #fff);--cal-level-2:color-mix(in srgb, var(--info) 24%, #fff);--cal-level-3:color-mix(in srgb, var(--info) 37%, #fff);--cal-level-4:color-mix(in srgb, var(--info) 50%, #fff);--cal-level-5:color-mix(in srgb, var(--info) 64%, #fff);--cal-level-6:color-mix(in srgb, var(--info) 80%, #fff);--cal-level-7:var(--info);--cal-level-8:color-mix(in srgb, var(--info) 85%, #000);--cal-level-9:color-mix(in srgb, var(--info) 72%, #000);--cal-level-10:color-mix(in srgb, var(--info) 60%, #000);--alias-row-valid-bg:color-mix(in srgb, var(--bg-surface) 96%, var(--accent) 4%);--alias-row-valid-bg-hover:color-mix(in srgb, var(--bg-surface) 90%, var(--accent) 10%);--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}}*{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;line-height:1.5}body.dashboard-modal-open{overflow:hidden}.app{height:100vh;min-height:0;display:flex;overflow:hidden}.badge{background:var(--accent);color:#fff;text-transform:uppercase;letter-spacing:.5px;border-radius:10px;padding:2px 8px;font-size:10px;font-weight:600}.auth-dialog{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:min(440px,100%);padding:22px;box-shadow:0 24px 70px #00000061}.auth-dialog-header{justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px;display:flex}.auth-dialog h2{margin-top:2px;font-size:22px;line-height:1.2}.auth-dialog-close{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.auth-dialog-close:hover{color:var(--text);background:var(--bg-surface-hover)}.auth-dialog-close:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-hint{color:var(--text-muted);font-size:13px}.auth-dialog-error{color:var(--danger);font-size:13px;font-weight:600}.auth-dialog-form{gap:10px;margin-top:18px;display:grid}.auth-dialog-actions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}.content{-webkit-overflow-scrolling:touch;flex:1 1 0;width:100%;min-width:0;min-height:0;padding:32px;transition:width .2s;overflow-y:auto;container:dashboard-content/inline-size}.content>*{width:100%;max-width:1336px;margin-inline:auto}body.dashboard-modal-open .content{overflow-y:hidden}.content.interactions-open>*{max-width:none}.page-header{justify-content:space-between;align-items:center;margin-bottom:24px;display:flex}.page-header h2{letter-spacing:-.3px;font-size:22px;font-weight:700}.page-header-controls{align-items:center;gap:12px;display:flex}.page-with-sticky-date{grid-template-columns:minmax(0,1fr) auto;align-items:start;column-gap:12px;display:grid}.page-with-sticky-date>*{grid-column:1/-1}.page-with-sticky-date>.date-range-page-header{grid-column:1}.page-with-sticky-date>.sticky-date-range{z-index:8;grid-column:2;justify-self:end;position:sticky;top:16px}.model-count{color:var(--text-muted);font-size:14px}.provider-status-section{margin-top:28px;scroll-margin-top:24px}.cards{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:28px;display:grid}.card{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px}.card-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);margin-bottom:8px;font-size:12px;font-weight:600}.card-value{letter-spacing:-.5px;font-size:28px;font-weight:700}.cache-meter{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:28px;padding:24px}.chart-container{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.chart-container h3{margin-bottom:16px;font-size:16px;font-weight:600}.chart-container-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;display:flex}.chart-container-header h3{margin-bottom:0}.chart-wrapper{height:210px;position:relative}.live-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:8px;height:8px}.live-dot.is-streaming{background:var(--success);position:relative}.live-dot.is-streaming:after{content:"";z-index:-1;background:color-mix(in srgb, var(--success) 55%, transparent);border-radius:50%;animation:1.8s ease-out infinite live-dot-pulse;position:absolute;inset:0}@media (prefers-reduced-motion:reduce){.live-dot.is-streaming:after{opacity:0;animation:none}}@keyframes live-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(2.5)}to{opacity:0;transform:scale(2.5)}}.alert{border-radius:var(--radius);margin-bottom:20px;padding:12px 16px;font-size:14px}.alert-warning{color:var(--warning);background:#f59e0b1a;border:1px solid #f59e0b4d}.table-toolbar{align-items:center;gap:12px;margin-bottom:16px;display:flex}.table-toolbar-main{flex:1;min-width:0}.table-toolbar-actions{justify-content:flex-end;margin-left:auto;display:flex}input:is([type=text],[type=date],[type=number]){background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:8px 12px;font-family:inherit;font-size:13px}input:is([type=text],[type=date],[type=number]):focus{border-color:var(--accent)}input:is([type=text],[type=date],[type=number]):disabled,textarea:disabled,.form-input:disabled{opacity:.6;cursor:not-allowed}.table-wrapper{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}.data-table{border-collapse:collapse;width:100%;font-size:14px}.data-table th{text-align:left;text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);background:var(--bg);border-bottom:1px solid var(--border);padding:12px 16px;font-size:12px;font-weight:600}.data-table th.model-actions-header{text-align:right;white-space:nowrap;width:1%;min-width:156px}.data-table td{border-bottom:1px solid var(--border);padding:10px 16px}.data-table tr:last-child td{border-bottom:none}.data-table tr:hover td{background:var(--bg-surface-hover)}.mono{font-family:SF Mono,Menlo,Consolas,monospace}.font-size-md{font-size:13px}.col-price,.data-table th.col-price{text-align:right}td.col-price{color:var(--text-muted);white-space:nowrap;font-family:SF Mono,Menlo,Consolas,monospace;font-size:13px}.provider-badge{background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:2px 10px;font-size:12px;font-weight:500;display:inline-block}.empty-state{text-align:center;color:var(--text-muted);padding:48px 0;font-size:14px}.empty-state-icon{width:auto;height:auto;max-height:160px;color:var(--text-muted);margin:0 auto;display:block}.empty-state-icon text{fill:var(--text-muted);font-family:inherit;font-weight:600}.chart-empty-overlay{pointer-events:none;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.chart-empty-overlay .empty-state-icon{width:auto;max-width:90%;height:auto;max-height:195px}.loading-spinner{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:16px;height:16px;animation:.8s linear infinite loading-spin}@keyframes loading-spin{to{transform:rotate(360deg)}}.table-action-btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;gap:6px;padding:6px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:inline-flex}.table-action-btn:hover:not(:disabled){background:var(--bg-surface-hover)}.table-action-btn:disabled{opacity:.45;cursor:default}.table-action-btn-danger{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.table-action-btn-active{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 12%, var(--bg));border-color:color-mix(in srgb, var(--accent) 38%, var(--border))}.table-action-btn-active:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 18%, var(--bg-surface-hover))}.table-action-btn-failover-active{color:var(--info);background:color-mix(in srgb, var(--cache-meter-prompt) 35%, var(--bg));border-color:color-mix(in srgb, var(--info) 45%, var(--border));position:relative}.table-action-btn-failover-active:hover:not(:disabled){background:color-mix(in srgb, var(--cache-meter-prompt) 45%, var(--bg-surface-hover))}.table-icon-btn{border-radius:6px;gap:0;width:32px;min-width:32px;height:32px;padding:0}.table-icon-btn.table-action-btn-active{position:relative}.table-icon-btn.table-action-btn-active:after{content:"";background:var(--accent);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-btn.table-action-btn-failover-active:after{content:"";background:var(--info);width:6px;height:6px;box-shadow:0 0 0 2px var(--bg-surface);border-radius:999px;position:absolute;top:4px;right:4px}.table-icon-svg{flex-shrink:0;width:14px;height:14px}.model-editor{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:16px;padding:24px}.alias-kind-badge{border:1px solid var(--border);background:var(--bg);min-height:24px;color:var(--accent);letter-spacing:.2px;text-transform:uppercase;border-color:color-mix(in srgb, var(--accent) 55%, var(--border));border-radius:999px;justify-content:center;align-items:center;gap:4px;padding:0 10px;font-size:11px;font-weight:600;display:inline-flex}.form h3{font-size:20px;font-weight:700}.form-kicker,.form-hint{color:var(--text-muted);font-size:13px}.alias-actions-cell{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.model-list-actions{white-space:nowrap;flex-wrap:nowrap}.model-list-actions .table-icon-btn{flex:0 0 32px}.model-list-actions .alias-toggle{flex:none}.alias-toggle{border:1px solid var(--border);background:var(--bg);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:8px;padding:6px 10px;font-family:inherit;font-size:12px;transition:all .15s;display:inline-flex}.alias-toggle:hover:not(:disabled){background:var(--bg-surface-hover)}.alias-toggle:disabled{opacity:.45;cursor:default}.alias-toggle-track{background:color-mix(in srgb, var(--border) 80%, var(--bg));border-radius:6px;width:34px;height:18px;transition:background .15s;position:relative}.alias-toggle-thumb{background:var(--text-muted);border-radius:6px;width:16px;height:16px;transition:transform .15s,background .15s;position:absolute;top:1px;left:2px}.alias-toggle.enabled{border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.alias-toggle.enabled .alias-toggle-track{background:color-mix(in srgb, var(--success) 55%, var(--bg))}.alias-toggle.enabled .alias-toggle-thumb{background:#fff;transform:translate(14px)}.alias-toggle.restricted{border-color:color-mix(in srgb, var(--accent) 50%, var(--border));color:color-mix(in srgb, var(--accent) 70%, var(--text))}.alias-toggle.restricted .alias-toggle-track{background:color-mix(in srgb, var(--accent) 55%, var(--bg))}.editor-header{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:20px;display:flex}.form{flex-direction:column;gap:16px;display:flex}.auth-key-editor{background:color-mix(in srgb, var(--bg-surface) 82%, var(--bg) 18%)}.form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.form-field{flex-direction:column;gap:8px;display:flex}.form-field-label{text-transform:uppercase;letter-spacing:.5px;color:var(--text-muted);font-size:12px;font-weight:600;display:inline-block}.vm-target-row{align-items:center;gap:8px;display:flex}.vm-target-row .vm-target-model{flex:auto;min-width:0}.vm-target-row .vm-target-weight{flex:0 0 88px;width:88px}.vm-status-row{justify-content:space-between;align-items:center;gap:12px;display:flex}.vm-status-row .vm-status-toggle{margin-left:auto}.form-error{border:1px solid color-mix(in srgb, var(--danger) 42%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface));color:var(--danger);overflow-wrap:anywhere;margin:0;padding:10px 12px;font-size:13px;font-weight:600;line-height:1.4}.form-error:empty{display:none}.form-field-error{color:var(--danger);overflow-wrap:anywhere;font-size:13px;font-weight:500;line-height:1.4}.form-field-required{color:var(--danger);margin-left:3px}:is(input,textarea,select)[aria-invalid=true]{border-color:color-mix(in srgb, var(--danger) 60%, var(--border))}:is(input,textarea,select)[aria-invalid=true]:focus{border-color:var(--danger)}textarea{resize:vertical;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:60px;color:var(--text);outline:none;padding:10px 12px;font-family:inherit;font-size:13px}textarea:focus{border-color:var(--accent)}.form-input{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);width:100%;min-height:38px;color:var(--text);outline:none;padding:8px 10px;font-family:inherit;font-size:13px}.form-input:focus{border-color:var(--accent)}.form-actions{flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:16px;display:flex}.failover-target-actions{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.data-table tr.alias-row.is-valid td{background:var(--alias-row-valid-bg)}.data-table tr.alias-row.is-valid:hover td{background:var(--alias-row-valid-bg-hover)}.data-table tr.alias-row:not(.is-valid) td{background:color-mix(in srgb, var(--accent) 10%, var(--bg-surface))}.data-table tr.alias-row:not(.is-valid):hover td{background:color-mix(in srgb, var(--accent) 16%, var(--bg-surface-hover))}.data-table tr.alias-row.is-disabled td{background:var(--bg-surface);opacity:.58}.data-table tr.alias-row.is-disabled:hover td{background:var(--bg-surface-hover);opacity:.72}.data-table tr.model-access-disabled-row td{background:color-mix(in srgb, var(--danger) 6%, var(--bg-surface))}.data-table tr.model-access-disabled-row:hover td{background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface-hover))}.workflow-section-head{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-section-head h4{font-size:14px;font-weight:700}.workflow-preview{flex-direction:column;gap:12px;display:flex}.workflow-feature-toggles{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.workflow-feature-toggle{border:1px solid var(--border);background:var(--bg);border-radius:10px;align-items:center;gap:10px;padding:10px 12px;font-size:14px;font-weight:500;display:flex}.workflow-feature-toggle input{width:16px;height:16px}.model-chart-section{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:24px;padding:24px}.model-chart-section h3{margin:0;font-size:16px;font-weight:600}.model-chart-header{justify-content:space-between;align-items:center;gap:16px;margin-bottom:16px;display:flex}.bar-chart-wrap{width:100%;height:180px;position:relative}.form-select,.usage-log-select{appearance:none;background-color:var(--bg);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 17px),calc(100% - 12px);background-repeat:no-repeat;background-size:5px 5px;outline:none;min-width:140px;padding:8px 34px 8px 12px;font-family:inherit;font-size:13px}.form-select:disabled,.usage-log-select:disabled{cursor:not-allowed;opacity:.6}.form-select:focus,.usage-log-select:focus{border-color:var(--accent)}.form-select{width:100%;min-width:0}.usage-label-chips{flex-wrap:wrap;gap:4px;max-width:280px;display:inline-flex}.usage-label-chip{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg));min-height:20px;color:var(--text);white-space:nowrap;cursor:pointer;border-radius:999px;align-items:center;padding:1px 9px;font-family:inherit;font-size:11px;font-style:normal;font-weight:600;line-height:1.4;transition:background .15s,border-color .15s;display:inline-flex}.usage-label-chip:hover{background:color-mix(in srgb, var(--label-color,var(--accent)) 26%, var(--bg))}.usage-label-chip.active{background:color-mix(in srgb, var(--label-color,var(--accent)) 32%, var(--bg));border-color:var(--label-color,var(--accent));box-shadow:0 0 0 1px color-mix(in srgb, var(--label-color,var(--accent)) 55%, transparent)}@keyframes audit-live-summary-stripe-blink{0%,to{opacity:.9}50%{opacity:.28}}.audit-status-badge{border:1px solid var(--border);letter-spacing:.2px;background:var(--bg-surface);border-radius:999px;justify-content:center;align-items:center;min-width:46px;height:24px;padding:0 10px;font-size:12px;font-weight:600;display:inline-flex}.audit-status-badge.status-success{color:var(--success);border-color:color-mix(in srgb, var(--success) 50%, var(--border))}.audit-status-badge.status-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.audit-status-badge.status-error{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 50%, var(--border))}.audit-status-badge.status-neutral{color:var(--text-muted)}.audit-status-badge.status-unknown{color:var(--text-muted);border-color:color-mix(in srgb, var(--border) 75%, transparent)}.audit-pane{border:1px solid var(--border);background:var(--bg);border-top:0;border-radius:0 0 8px 8px;min-width:0;padding:12px}.audit-pane h5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:11px;font-weight:600}.audit-prompt-cache-pill{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);min-height:20px;color:var(--prompt-cache-color);letter-spacing:.02em;text-transform:none;border-radius:999px;align-items:center;padding:2px 8px;font-size:11px;font-weight:700;display:inline-flex}.audit-prompt-cache-highlight{color:var(--prompt-cache-color);font-weight:700}.audit-audio{white-space:normal;flex-direction:column;gap:8px;display:flex}.audit-audio-player{width:100%;max-width:420px;height:36px}.audit-audio-meta{color:var(--text-muted);font-size:12px}.audit-audio-empty{align-items:flex-start;padding:4px 0}.audit-audio-icon{font-size:20px;line-height:1}.audit-audio-note{color:var(--text-muted);font-size:12px}.audit-audio-metadata{flex-direction:column;gap:2px;margin-top:4px;font-size:12px;display:flex}.audit-audio-meta-row{gap:8px;display:flex}.audit-audio-meta-key{color:var(--text-muted);min-width:120px}.conversation-body-highlight{border-left:2px solid color-mix(in srgb, var(--accent) 70%, var(--border));background:color-mix(in srgb, var(--accent) 10%, transparent);cursor:pointer;line-height:inherit;border-radius:2px;margin:0 0 0 -2px;padding:0 0 0 2px;display:inline}.conversation-body-highlight:hover{background:color-mix(in srgb, var(--accent) 18%, transparent)}.conversation-body-highlight.conversation-system{border-left-color:color-mix(in srgb, var(--warning) 70%, var(--border));background:color-mix(in srgb, var(--warning) 10%, transparent)}.conversation-body-highlight.conversation-user{border-left-color:color-mix(in srgb, var(--accent) 75%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent)}.conversation-body-highlight.conversation-assistant{border-left-color:color-mix(in srgb, var(--success) 65%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}#interactions-drawer-content{flex:1;min-height:0;overflow-y:auto}.pagination{justify-content:space-between;align-items:center;padding:12px 0 0;display:flex}.btn{background:var(--bg);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;padding:6px 16px;font-family:inherit;font-size:13px;transition:all .15s}.btn:hover:not(:disabled){background:var(--bg-surface-hover)}.btn-primary{background:var(--accent);border-color:color-mix(in srgb, var(--accent) 70%, #000 10%);color:#fff;font-weight:600;box-shadow:0 10px 22px #3b82f62e}.btn-primary:hover:not(:disabled){background:color-mix(in srgb, var(--accent) 90%, #fff 10%);border-color:color-mix(in srgb, var(--accent) 78%, #000 12%)}.btn-danger-outline{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:0 0;font-weight:600}.btn-danger-outline:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 75%, var(--border))}.btn-danger{color:#fff;border-color:color-mix(in srgb, var(--danger) 76%, #000 12%);background:var(--danger);box-shadow:0 10px 22px color-mix(in srgb, var(--danger) 20%, transparent);font-weight:600}.btn-danger:hover:not(:disabled){background:color-mix(in srgb, var(--danger) 90%, #fff 10%);border-color:color-mix(in srgb, var(--danger) 82%, #000 14%)}.btn-with-icon{justify-content:center;align-items:center;gap:8px;display:inline-flex}.btn-with-icon .table-icon-svg{width:16px;height:16px}.btn:disabled{opacity:.4;cursor:default}.settings-panel{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.inline-help-section{flex-direction:column;gap:2px;display:flex}.inline-help-title-row{align-items:center;gap:10px;display:inline-flex}.inline-help-title-row h2,.inline-help-title-row h3{margin-bottom:0}.inline-help-title-row h2:empty,.inline-help-title-row h3:empty{display:none}.inline-help-toggle{border:1px solid color-mix(in srgb, var(--accent) 28%, var(--border));width:16px;height:16px;color:var(--accent);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border-radius:4px;justify-content:center;align-items:center;padding:0;transition:color .18s,border-color .18s;display:inline-flex;position:relative}.inline-help-toggle:before{content:"";pointer-events:auto;background:0 0;width:32px;height:32px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.inline-help-toggle:hover{border-color:color-mix(in srgb, var(--accent) 48%, var(--border));color:var(--text);background:0 0}.inline-help-toggle:active{background:0 0}.inline-help-toggle:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.inline-help-toggle-icon{justify-content:center;align-items:center;width:100%;height:100%;padding-bottom:1px;font-size:13px;font-weight:700;line-height:1;transition:transform .52s cubic-bezier(.22,.72,.12,1);display:inline-flex;transform:rotate(0)}.inline-help-copy{max-width:780px;color:var(--text-muted);margin-top:2px;font-size:14px}.settings-select{width:100%}.settings-refresh-section{border-top:1px solid var(--border);justify-items:start;gap:12px;margin-top:24px;padding-top:22px;display:grid}.settings-refresh-section h3{font-size:18px}.settings-refresh-section p{max-width:720px;color:var(--text-muted);font-size:14px;line-height:1.55}.budget-list{gap:10px;padding:10px 0;display:grid}.budget-row{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);grid-template-columns:minmax(0,1fr);align-items:center;gap:16px;padding:12px 14px;display:grid}.budget-row-main{min-width:0}.budget-row-head{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:10px;min-width:0;display:grid}.budget-scope-value{width:fit-content;max-width:100%;min-height:24px;color:var(--text);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;justify-self:start;align-items:center;gap:5px;padding:2px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;display:inline-flex;overflow:hidden}.budget-user-path{border:1px solid color-mix(in srgb, var(--accent) 32%, var(--border));background:color-mix(in srgb, var(--accent) 9%, var(--bg))}.budget-label{border:1px solid color-mix(in srgb, var(--label-color,var(--accent)) 45%, var(--border));background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.budget-scope-icon{stroke-width:2.2px;opacity:.85;flex:0 0 12px;width:12px;height:12px}.budget-row-meta{min-width:0;color:var(--text-muted);align-items:center;gap:8px;font-size:12px;display:inline-flex}.budget-source{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:999px;padding:2px 7px;font-size:11px}.budget-row-period{justify-content:center;min-width:0;display:flex}.budget-row-controls{justify-content:flex-end;align-items:center;gap:8px;min-width:0;display:flex}.budget-bars{gap:6px;margin-top:10px;display:grid}.budget-bar-line{grid-template-columns:118px minmax(0,1fr);align-items:center;gap:10px;display:grid}.budget-bar-label{color:var(--text-muted);justify-content:space-between;align-items:center;gap:6px;font-size:11px;line-height:1;display:flex}.budget-bar-percent{font-weight:700}.budget-bar-track{background:color-mix(in srgb, var(--border) 75%, var(--bg));border-radius:999px;height:16px;position:relative;overflow:hidden}.budget-bar-fill{border-radius:inherit;min-width:0;height:100%;transition:width .2s}.budget-bar-fill-usage{background:color-mix(in srgb, var(--success) 82%, var(--accent))}.budget-bar-fill-danger{background:var(--danger)}.budget-bar-text-row{z-index:1;pointer-events:none;color:var(--text);position:absolute;inset:0}.budget-bar-text{text-overflow:ellipsis;white-space:nowrap;max-width:min(44%,190px);font-size:11px;font-weight:700;line-height:12px;position:absolute;top:50%;overflow:hidden}.budget-bar-text-center{max-width:min(46%,240px);left:50%;transform:translate(-50%,-50%)}.budget-bar-text-end{text-align:right;max-width:min(34%,180px);right:8px;transform:translateY(-50%)}.budget-period-label{border:1px solid var(--border);color:var(--text);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;gap:5px;padding:2px 7px;font-size:11px;font-weight:600;display:inline-flex}.budget-period-icon{stroke-width:2.2px;flex:0 0 12px;width:12px;height:12px}.budget-period-label-monthly{border-color:color-mix(in srgb, #30302c 62%, var(--border));background:color-mix(in srgb, #30302c 12%, var(--bg));color:color-mix(in srgb, #30302c 34%, var(--text) 66%)}.budget-period-label-weekly{border-color:color-mix(in srgb, #68765c 62%, var(--border));background:color-mix(in srgb, #68765c 12%, var(--bg));color:color-mix(in srgb, #68765c 34%, var(--text) 66%)}.budget-period-label-daily{border-color:color-mix(in srgb, #b5652d 62%, var(--border));background:color-mix(in srgb, #b5652d 12%, var(--bg));color:color-mix(in srgb, #b5652d 34%, var(--text) 66%)}.budget-period-label-hourly{border-color:color-mix(in srgb, #783f22 62%, var(--border));background:color-mix(in srgb, #783f22 12%, var(--bg));color:color-mix(in srgb, #783f22 34%, var(--text) 66%)}.budget-period-label-custom{border-style:dashed;border-color:color-mix(in srgb, #bfa584 68%, var(--border));background:color-mix(in srgb, #bfa584 16%, var(--bg));color:color-mix(in srgb, #8b6f4f 34%, var(--text) 66%)}[data-theme=light] .budget-period-label-monthly{color:#30302c}[data-theme=light] .budget-period-label-weekly{color:#68765c}[data-theme=light] .budget-period-label-daily{color:#b5652d}[data-theme=light] .budget-period-label-hourly{color:#783f22}[data-theme=light] .budget-period-label-custom{color:#8b6f4f}@media (prefers-color-scheme:light){:root:not([data-theme=dark]) .budget-period-label-monthly{color:#30302c}:root:not([data-theme=dark]) .budget-period-label-weekly{color:#68765c}:root:not([data-theme=dark]) .budget-period-label-daily{color:#b5652d}:root:not([data-theme=dark]) .budget-period-label-hourly{color:#783f22}:root:not([data-theme=dark]) .budget-period-label-custom{color:#8b6f4f}}.budget-row-actions{flex-flow:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.budget-action-btn{white-space:nowrap;justify-content:center;gap:0;width:28px;min-width:0;height:28px;padding:0;transition:width .18s,border-color .15s,background .15s,color .15s;overflow:hidden}.budget-action-btn:hover,.budget-action-btn:focus-visible{gap:6px;width:82px;padding:0 9px}.budget-action-label{opacity:0;max-width:0;transition:max-width .18s,opacity .12s;overflow:hidden}.budget-action-btn:hover .budget-action-label,.budget-action-btn:focus-visible .budget-action-label{opacity:1;max-width:58px}.budget-action-btn-warning{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 50%, var(--border))}.budget-action-icon{flex:0 0 14px;width:14px;height:14px}.budget-editor{background:color-mix(in srgb, var(--bg-surface) 86%, var(--bg) 14%)}.budget-settings-actions{flex-wrap:wrap;gap:10px;display:flex}.budget-reset-dialog{max-width:460px}.form-action-icon{flex:0 0 16px;width:16px;height:16px}.settings-refresh-alert{margin-top:16px;margin-bottom:0}@media (width<=768px){.badge{display:none}.content{width:100%;margin:0 auto;padding:20px}.auth-dialog{padding:18px}.auth-dialog-actions{flex-direction:column-reverse}.auth-dialog-actions .btn{width:100%}.cards{grid-template-columns:repeat(2,1fr)}.page-header{flex-wrap:wrap;gap:12px}.page-header h2{width:100%}.page-header-controls{flex-wrap:wrap;justify-content:space-between;width:100%}.page-with-sticky-date{grid-template-columns:minmax(0,1fr)}.page-with-sticky-date>.date-range-page-header,.page-with-sticky-date>.sticky-date-range{grid-column:1}.page-with-sticky-date>.date-range-page-header{margin-bottom:12px}.page-with-sticky-date>.sticky-date-range{width:100%;margin-bottom:24px;top:10px}.sticky-date-range .date-picker-trigger{justify-content:space-between;width:100%}.usage-log-select{min-width:0}.budget-row{grid-template-columns:1fr}.budget-row-controls{flex-wrap:wrap}.budget-bar-line{grid-template-columns:1fr;gap:5px}.form-grid,.workflow-feature-toggles{grid-template-columns:1fr}.workflow-section-head{flex-direction:column;align-items:flex-start}.table-toolbar{flex-direction:column;align-items:stretch}.table-toolbar-actions{justify-content:stretch;margin-left:0}.table-toolbar-actions .btn{width:100%}.model-editor{padding:16px}.alias-actions-cell,.editor-header{flex-direction:column;align-items:flex-start}.alias-actions-cell .table-action-btn,.editor-header .table-action-btn{width:100%}.alias-actions-cell .table-icon-btn,.editor-header .table-icon-btn{width:36px}.model-list-actions{flex-flow:row;align-items:center}.model-list-actions .table-action-btn{width:auto}.model-list-actions .table-icon-btn{flex-basis:32px;width:32px}.model-editor .editor-header{flex-direction:row;align-items:flex-start}.model-editor .editor-header>:first-child{flex:1;min-width:0}.model-editor .editor-header .dialog-close-btn{flex:0 0 32px;align-self:flex-start;width:32px;min-width:32px}.settings-panel{padding:18px}.budget-settings-actions,.budget-settings-actions .btn{width:100%}}.workflow-conn{background:color-mix(in srgb, var(--accent) 44%, var(--border));flex:1 1 0;width:auto;min-width:13px;height:2px;position:relative}.workflow-conn:after{content:"";background:color-mix(in srgb, var(--accent) 44%, var(--border));clip-path:polygon(0 0,100% 50%,0 100%);width:7px;height:9px;position:absolute;top:50%;right:-1px;transform:translateY(-50%)}.workflow-node{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg-surface);text-align:center;flex-direction:column;flex-shrink:0;justify-content:center;align-items:center;gap:4px;min-width:72px;padding:8px 12px;display:flex}.auth-key-description{color:var(--text-muted);max-width:220px;font-size:13px}.auth-key-status-badge{border-radius:999px;padding:2px 10px;font-size:12px;font-weight:600;display:inline-block}.auth-key-status-active{background:color-mix(in srgb, var(--success) 12%, var(--bg));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));color:var(--success)}.auth-key-status-inactive{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border:1px solid color-mix(in srgb, var(--danger) 30%, var(--border));color:var(--danger)}.mcp-server-advanced{border:1px solid var(--border);border-radius:var(--radius);background:color-mix(in srgb, var(--bg-surface) 72%, var(--bg) 28%);overflow:hidden}.mcp-server-advanced>summary{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;list-style:none;display:flex}.mcp-server-advanced>summary::-webkit-details-marker{display:none}.mcp-server-advanced>summary:after{border-right:2px solid var(--text-muted);border-bottom:2px solid var(--text-muted);content:"";flex:none;width:7px;height:7px;transition:transform .15s;transform:rotate(45deg)}.mcp-server-advanced[open]>summary:after{transform:rotate(225deg)}.mcp-server-advanced-summary-copy{flex-direction:column;gap:2px;min-width:0;display:flex}.mcp-server-advanced-title{font-size:13px;font-weight:600}.mcp-server-advanced-fields{border-top:1px solid var(--border);flex-direction:column;gap:16px;padding:14px;display:flex}.copy-feedback-btn{align-items:center;gap:6px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.rate-limit-pressure-row{background-image:linear-gradient(to right, color-mix(in srgb, var(--success) 16%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-high{background-image:linear-gradient(to right, color-mix(in srgb, var(--warning) 20%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.rate-limit-pressure-row.rate-limit-pressure-full{background-image:linear-gradient(to right, color-mix(in srgb, var(--danger) 22%, transparent) var(--rate-limit-pressure,0%), transparent var(--rate-limit-pressure,0%))}.table-icon-btn.rate-limit-gauge-inherited{color:var(--accent-strong,var(--accent));background:linear-gradient(to right, color-mix(in srgb, var(--accent) 22%, var(--bg)) 50%, var(--bg) 50%);border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.auth-dialog-input-icon{width:16px;height:16px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.auth-dialog-input-shell:focus-within .auth-dialog-input-icon{color:var(--accent)}.auth-dialog-submit-icon{flex:0 0 16px;width:16px;height:16px}.nav-icon{flex:0 0 18px;width:18px;height:18px}.api-key-open-icon{flex:0 0 15px;width:15px;height:15px}.theme-icon{flex:0 0 14px;width:14px;height:14px}.theme-toggle-mobile .theme-icon{flex-basis:16px;width:16px;height:16px}@media (width<=768px){.sidebar-footer .api-key-open-icon{flex-basis:16px;width:16px;height:16px}}.failover-drafts-loading{min-height:96px}.models-loading-state{top:16px;left:var(--sidebar-width);z-index:110;pointer-events:none;--loading-state-min-height:0;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-surface);width:fit-content;box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);margin:0 auto;padding:10px 14px;position:fixed;right:0}@media (width<=768px){.models-loading-state{left:60px}}.sidebar.sidebar-collapsed~.content .models-loading-state{left:60px}.alias-create-icon{flex:0 0 16px;width:16px;height:16px}.pricing-override-remove-row{margin-bottom:1px}@media (width<=768px){.pricing-override-remove-row{margin-bottom:0}}.pricing-recalculate-dialog{max-width:480px}.settings-refresh-btn.is-refreshing .settings-refresh-icon{transform-origin:50%;animation:.8s linear infinite loading-spin}.cost-source-icon{width:14px;height:14px;color:var(--success);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.cache-savings-icon{width:14px;height:14px;color:var(--accent);cursor:help;vertical-align:-2px;stroke-width:2px;margin-left:4px}.theme-toggle.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;margin-bottom:10px;padding:2px;display:inline-flex}.theme-btn.svelte-1keql7b{width:28px;height:24px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:flex}.theme-btn.svelte-1keql7b:hover{color:var(--text)}.theme-btn.active.svelte-1keql7b{background:var(--accent);color:#fff}.theme-btn.svelte-1keql7b:focus-visible,.theme-toggle-mobile.svelte-1keql7b:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.theme-toggle-mobile.svelte-1keql7b{background:var(--bg);border:1px solid var(--border);width:36px;height:36px;color:var(--text-muted);cursor:pointer;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:none}.theme-toggle-mobile.svelte-1keql7b:hover{color:var(--text)}.theme-toggle.is-compact.svelte-1keql7b{display:none}.theme-toggle-mobile.is-compact.svelte-1keql7b{margin:0 auto;display:flex}@media (width<=768px){.theme-toggle.svelte-1keql7b{display:none}.theme-toggle-mobile.svelte-1keql7b{margin:0 auto;display:flex}}.sidebar.svelte-1nwtzae{flex:0 0 var(--sidebar-width);width:var(--sidebar-width);background:var(--bg-surface);border-right:1px solid var(--border);-webkit-overflow-scrolling:touch;z-index:10;flex-direction:column;max-height:100vh;transition:flex-basis .2s,width .2s;display:flex;position:sticky;top:0;overflow:hidden auto}.sidebar.sidebar-resizing.svelte-1nwtzae{transition:none}.sidebar-header.svelte-1nwtzae{border-bottom:1px solid var(--border);align-items:center;gap:10px;padding:20px;display:flex}.sidebar-logo.svelte-1nwtzae{width:28px;height:28px;color:var(--accent);flex-shrink:0}.sidebar-logo.svelte-1nwtzae svg{width:100%;height:100%}.sidebar-header.svelte-1nwtzae h1{letter-spacing:-.3px;font-size:18px;font-weight:700}.sidebar-nav.svelte-1nwtzae{flex-direction:column;flex:1;gap:4px;padding:12px;display:flex}.nav-item.svelte-1nwtzae{border-radius:var(--radius);color:var(--text-muted);align-items:center;gap:10px;padding:8px 12px;font-size:14px;font-weight:500;text-decoration:none;transition:all .15s;display:flex}.nav-item.svelte-1nwtzae:hover{background:var(--bg-surface-hover);color:var(--text)}.nav-item.active.svelte-1nwtzae{background:var(--accent);color:#fff}.nav-label.svelte-1nwtzae{white-space:nowrap;text-overflow:ellipsis;flex:1;min-width:0;overflow:hidden}.sidebar-footer.svelte-1nwtzae{border-top:1px solid var(--border);padding:16px}.api-key-section.svelte-1nwtzae{gap:8px;display:grid}.api-key-open-btn.svelte-1nwtzae{border:1px solid var(--accent);border-radius:var(--radius);width:100%;color:var(--accent);cursor:pointer;background:0 0;justify-content:center;align-items:center;gap:8px;padding:8px 10px;font-family:inherit;font-size:13px;font-weight:600;transition:background-color .15s,border-color .15s;display:inline-flex}.api-key-open-btn.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);border-color:color-mix(in srgb, var(--accent) 78%, var(--text));color:color-mix(in srgb, var(--accent) 78%, var(--text))}.api-key-open-btn.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.sidebar-toggle.svelte-1nwtzae{cursor:ew-resize;z-index:11;background:0 0;border:none;flex:0 0 6px;width:6px;height:100vh;padding:0;transition:background .15s;position:sticky;top:0}.sidebar-toggle.svelte-1nwtzae:hover{background:color-mix(in srgb, var(--accent) 15%, transparent)}.sidebar-toggle.svelte-1nwtzae:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}body.sidebar-resizing{cursor:ew-resize;-webkit-user-select:none;user-select:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae){justify-content:center;padding:16px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-header:where(.svelte-1nwtzae) h1,.sidebar.sidebar-collapsed.svelte-1nwtzae .badge{display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-nav:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae){padding:8px}.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:none}@media (width<=768px){.sidebar.svelte-1nwtzae{flex-basis:60px;width:60px}.sidebar-header.svelte-1nwtzae{justify-content:center;padding:16px}.sidebar-header.svelte-1nwtzae h1{display:none}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae){justify-content:center;padding:10px}.sidebar-nav.svelte-1nwtzae .nav-item:where(.svelte-1nwtzae) .nav-label:where(.svelte-1nwtzae){display:none}.sidebar-footer.svelte-1nwtzae{gap:8px;padding:8px;display:grid}.sidebar-footer.svelte-1nwtzae .api-key-section:where(.svelte-1nwtzae),.sidebar.sidebar-collapsed.svelte-1nwtzae .sidebar-footer:where(.svelte-1nwtzae) .api-key-section:where(.svelte-1nwtzae){display:grid}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae){justify-self:center;width:36px;height:36px;min-height:36px;padding:0}.sidebar-footer.svelte-1nwtzae .api-key-open-btn:where(.svelte-1nwtzae) span,.sidebar-toggle.svelte-1nwtzae{display:none}}.dialog-close-btn.svelte-11l1bb5{background:var(--bg);border:1px solid var(--border);width:32px;min-width:32px;height:32px;color:var(--text-muted);cursor:pointer;font:inherit;border-radius:6px;flex:0 0 32px;justify-content:center;align-items:center;padding:0;line-height:1;transition:background .15s,border-color .15s,color .15s;display:inline-flex}.dialog-close-btn.svelte-11l1bb5:hover{color:var(--text);background:var(--bg-surface-hover)}.dialog-close-btn.svelte-11l1bb5:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 36%, transparent);outline-offset:2px}.auth-dialog-backdrop.svelte-17e0w4c,.editor-modal-backdrop.svelte-17e0w4c{z-index:80;background:#0000007a;position:fixed;inset:0}.auth-dialog-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0}.editor-modal-shell.svelte-17e0w4c{z-index:90;place-items:center;padding:20px;display:grid;position:fixed;inset:0;overflow-y:auto}.editor-modal-shell.svelte-17e0w4c>*{overscroll-behavior:contain;width:min(760px,100%);max-height:min(100vh - 40px,960px);margin:0;overflow:auto;box-shadow:0 24px 70px #00000061}@media (width<=768px){.auth-dialog-shell.svelte-17e0w4c,.editor-modal-shell.svelte-17e0w4c{align-items:end;padding:12px}.editor-modal-shell.svelte-17e0w4c>*{max-height:calc(100vh - 24px)}}.auth-dialog-input-shell.svelte-1dsu6u0{position:relative}.auth-dialog-input.svelte-1dsu6u0{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);width:100%;color:var(--text);outline:none;padding:11px 12px 11px 38px;font-family:inherit;font-size:14px}.auth-dialog-input.svelte-1dsu6u0:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent)}.flash-region.svelte-1i257xg{top:16px;left:var(--sidebar-width);z-index:120;pointer-events:none;flex-direction:column;align-items:center;gap:10px;display:flex;position:fixed;right:0}.sidebar.sidebar-collapsed~.flash-region.svelte-1i257xg{left:60px}@media (width<=768px){.flash-region.svelte-1i257xg{left:60px}}.flash-toast.svelte-1i257xg{border-radius:var(--radius);pointer-events:auto;align-items:flex-start;gap:10px;width:max-content;max-width:min(480px,100% - 32px);padding:12px 12px 12px 16px;font-size:14px;animation:.9s ease-out svelte-1i257xg-flash-toast-glow;display:flex;box-shadow:0 10px 30px #00000059}@keyframes svelte-1i257xg-flash-toast-glow{0%{box-shadow:0 0 0 4px color-mix(in srgb, currentColor 45%, transparent), 0 10px 30px #00000059}to{box-shadow:0 0 0 4px #0000,0 10px 30px #00000059}}@media (prefers-reduced-motion:reduce){.flash-toast.svelte-1i257xg{animation:none}}.flash-toast-success.svelte-1i257xg{background:color-mix(in srgb, var(--success) 14%, var(--bg-surface));color:var(--success);border:1px solid #34d39959}.flash-toast-error.svelte-1i257xg{background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--warning);border:1px solid #f59e0b66}.flash-toast-text.svelte-1i257xg{overflow-wrap:anywhere;flex:1;min-width:0}.flash-toast-dismiss.svelte-1i257xg{color:inherit;cursor:pointer;opacity:.7;background:0 0;border:0;flex-shrink:0;padding:0 2px;font-size:18px;line-height:1}.flash-toast-dismiss.svelte-1i257xg:hover{opacity:1}.demo-mode-banner.svelte-1s3mcn8{border:1px solid color-mix(in srgb, var(--warning) 55%, var(--border));border-radius:var(--radius);background:color-mix(in srgb, var(--warning) 14%, var(--bg-surface));color:var(--text);box-shadow:0 8px 24px color-mix(in srgb, var(--bg) 70%, transparent);grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;margin-bottom:24px;padding:12px 16px;display:grid}.demo-mode-banner-icon.svelte-1s3mcn8{width:20px;height:20px;color:var(--warning);flex:0 0 20px}.demo-mode-banner-copy.svelte-1s3mcn8{align-items:baseline;gap:8px;min-width:0;font-size:13px;display:flex}.demo-mode-banner.svelte-1s3mcn8 strong{color:var(--warning);letter-spacing:.06em;text-transform:uppercase;flex-shrink:0;font-size:12px}.demo-mode-banner-links.svelte-1s3mcn8{justify-content:flex-end;align-items:center;gap:6px;display:flex}.demo-mode-banner-links.svelte-1s3mcn8 a{border:1px solid color-mix(in srgb, var(--warning) 42%, var(--border));border-radius:var(--radius);min-height:28px;color:var(--text);white-space:nowrap;align-items:center;padding:4px 8px;font-size:12px;font-weight:600;line-height:1;text-decoration:none;display:inline-flex}.demo-mode-banner-links.svelte-1s3mcn8 a:hover{border-color:var(--warning);background:color-mix(in srgb, var(--warning) 16%, transparent);color:var(--text)}.demo-mode-banner-links.svelte-1s3mcn8 a:focus-visible{outline:2px solid color-mix(in srgb, var(--warning) 42%, transparent);outline-offset:2px}@media (width<=768px){.demo-mode-banner.svelte-1s3mcn8{grid-template-columns:auto minmax(0,1fr);align-items:flex-start}.demo-mode-banner-copy.svelte-1s3mcn8{gap:2px;display:grid}.demo-mode-banner-links.svelte-1s3mcn8{flex-wrap:wrap;grid-column:2;justify-content:flex-start}}.auth-banner.svelte-1c5yh36{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.dp-calendar.svelte-g7ga4u{flex-shrink:0;width:224px}.dp-cal-header.svelte-g7ga4u{justify-content:space-between;align-items:center;margin-bottom:8px;padding:0 4px;display:flex}.dp-cal-title.svelte-g7ga4u{font-size:13px;font-weight:600}.dp-nav-btn.svelte-g7ga4u{width:28px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;transition:all .15s;display:flex}.dp-nav-btn.svelte-g7ga4u:hover{background:var(--bg-surface-hover);color:var(--text)}.dp-nav-btn.svelte-g7ga4u:disabled{opacity:.3;cursor:default;pointer-events:none}.dp-nav-prev-mobile.svelte-g7ga4u{display:none}.dp-weekdays.svelte-g7ga4u{text-align:center;grid-template-columns:repeat(7,1fr);margin-bottom:4px;display:grid}.dp-weekdays.svelte-g7ga4u span:where(.svelte-g7ga4u){color:var(--text-muted);padding:4px 0;font-size:11px;font-weight:600}.dp-days.svelte-g7ga4u{grid-template-columns:repeat(7,1fr);gap:1px;display:grid}.dp-day.svelte-g7ga4u{width:32px;height:32px;color:var(--text);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;font-family:inherit;font-size:12px;transition:all .1s;display:flex}.dp-day.svelte-g7ga4u:hover:not(.disabled):not(.other-month){background:var(--bg-surface-hover)}.dp-day.other-month.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default}.dp-day.today.svelte-g7ga4u{color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);font-weight:700}.dp-day.in-range.svelte-g7ga4u{background:color-mix(in srgb, var(--accent) 15%, transparent);border-radius:0}.dp-day.range-start.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:6px 0 0 6px;font-weight:600}.dp-day.range-end.svelte-g7ga4u{background:var(--accent);color:#fff;border-radius:0 6px 6px 0;font-weight:600}.dp-day.range-start.range-end.svelte-g7ga4u{border-radius:6px}.dp-day.range-start.today.svelte-g7ga4u,.dp-day.range-end.today.svelte-g7ga4u{box-shadow:none}.dp-day.disabled.svelte-g7ga4u{color:var(--text-muted);opacity:.3;cursor:default;pointer-events:none}@media (width<=768px){.dp-nav-prev-mobile.svelte-g7ga4u{display:flex}}.date-picker.svelte-ax7ma4{position:relative}.date-picker-trigger.svelte-ax7ma4{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);cursor:pointer;white-space:nowrap;align-items:center;gap:8px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s;display:inline-flex}.date-picker-trigger.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.date-picker-trigger.svelte-ax7ma4 svg:where(.svelte-ax7ma4){color:var(--text-muted);flex-shrink:0}.date-picker-chevron.svelte-ax7ma4{transition:transform .15s}.date-picker-chevron.open.svelte-ax7ma4{transform:rotate(180deg)}.date-picker-dropdown.svelte-ax7ma4{z-index:100;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:hidden;box-shadow:0 8px 24px #00000040}.date-picker-presets.svelte-ax7ma4{border-right:1px solid var(--border);flex-direction:column;gap:2px;min-width:140px;padding:8px;display:flex}.preset-btn.svelte-ax7ma4{color:var(--text);text-align:left;cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:8px 12px;font-family:inherit;font-size:13px;transition:all .15s}.preset-btn.svelte-ax7ma4:hover{background:var(--bg-surface-hover)}.preset-btn.active.svelte-ax7ma4{background:var(--accent);color:#fff}.date-picker-calendars.svelte-ax7ma4{flex-wrap:nowrap;gap:16px;padding:12px;display:flex}.dp-cursor-hint.svelte-ax7ma4{pointer-events:none;z-index:101;background:var(--bg-surface);color:var(--text);border:1px solid var(--accent);white-space:nowrap;border-radius:4px;align-items:center;gap:5px;padding:3px 8px;font-size:11px;font-weight:500;display:flex;position:fixed;transform:translate(12px,-50%)}.dp-cursor-hint.svelte-ax7ma4 svg:where(.svelte-ax7ma4){width:12px;height:12px;color:var(--accent);flex-shrink:0}@media (width<=768px){.date-picker-dropdown.svelte-ax7ma4{border-radius:var(--radius) var(--radius) 0 0;flex-direction:column;max-height:80vh;position:fixed;inset:auto 0 0;overflow-y:auto}.date-picker-presets.svelte-ax7ma4{-webkit-overflow-scrolling:touch;border-right:none;border-bottom:1px solid var(--border);flex-flow:row;min-width:0;overflow-x:auto}.date-picker-calendars.svelte-ax7ma4{justify-content:center}.date-picker-calendars.svelte-ax7ma4>.dp-calendar:first-child{display:none}}.segmented-control.svelte-92fh5i{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.segmented-btn.svelte-92fh5i{color:var(--text-muted);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;padding:5px 12px;font-family:inherit;font-size:12px;font-weight:500;transition:all .15s;display:flex}.segmented-btn.svelte-92fh5i:hover{color:var(--text)}.segmented-btn.active.svelte-92fh5i{background:var(--accent);color:#fff}@media (width<=768px){.segmented-btn.svelte-92fh5i{padding:4px 8px;font-size:11px}}.live-tokens.svelte-17qr2ta{margin-bottom:28px}.live-tokens-heading.svelte-17qr2ta{flex-direction:column;gap:2px;display:flex}.live-tokens-subtitle.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:6px;font-size:12px;display:inline-flex}.live-tokens-legend.svelte-17qr2ta{flex-wrap:wrap;gap:8px 18px;margin-bottom:16px;display:flex}.live-tokens-legend-item.svelte-17qr2ta{color:var(--text-muted);align-items:center;gap:7px;font-size:12px;display:inline-flex}.live-tokens-swatch.svelte-17qr2ta{border-radius:2px;flex-shrink:0;width:10px;height:10px}.live-tokens-legend-value.svelte-17qr2ta{color:var(--text);font-weight:600}.live-tokens-empty.svelte-17qr2ta .live-tokens-empty-text:where(.svelte-17qr2ta){color:var(--text-muted);font-size:13px}.provider-status-flag.svelte-6tr9cf{grid-column:span 2}.provider-status-overview-card.svelte-6tr9cf{grid-column:span 1}.provider-status-flag.is-healthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, var(--bg-surface))}.provider-status-flag.is-degraded.svelte-6tr9cf{border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-flag.is-unhealthy.svelte-6tr9cf{border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg-surface))}.provider-status-value.svelte-6tr9cf{margin-bottom:8px}.provider-status-card-link.svelte-6tr9cf{color:var(--accent-strong,var(--accent));font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;margin:0;padding:0;font-size:13px;font-weight:600}.provider-status-card-link.svelte-6tr9cf:hover{color:var(--text);text-decoration:underline}.provider-status-card-link.svelte-6tr9cf:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:3px;border-radius:4px}.provider-status-card-note.svelte-6tr9cf{color:var(--text-muted);font-size:13px;display:block}@media (width>=720px){.card-wide.svelte-6tr9cf{grid-column:span 2}}.cache-token-value.svelte-6tr9cf{flex-wrap:wrap;align-items:center;gap:6px;line-height:1;display:flex}.cache-token-part.svelte-6tr9cf{align-items:center;display:inline-flex}.cache-token-operator.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;font-size:24px;font-weight:600;line-height:1}.cache-token-marker.svelte-6tr9cf{color:var(--text-muted);letter-spacing:0;text-transform:uppercase;margin-left:2px;font-size:14px;font-weight:700}.prompt-cache-gauge.svelte-6tr9cf{width:120px;height:60px;margin:8px auto 0;position:relative;overflow:hidden}.prompt-cache-gauge.svelte-6tr9cf canvas{display:block}.prompt-cache-gauge-value.svelte-6tr9cf{text-align:center;color:var(--text);font-size:18px;font-weight:700;line-height:1;position:absolute;bottom:4px;left:0;right:0}@media (width<=768px){.provider-status-flag.svelte-6tr9cf{grid-column:span 1}}.mcp-servers-flag.svelte-6tr9cf{grid-column:span 1}.cache-meter-header.svelte-1yzecxj{flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:16px;display:flex}.cache-meter-header.svelte-1yzecxj h3{font-size:16px;font-weight:600}.cache-meter-subtitle.svelte-1yzecxj{color:var(--text-muted);font-size:13px}.cache-meter-bar.svelte-1yzecxj{background:var(--bg-surface-hover);border-radius:6px;width:100%;height:28px;display:flex;overflow:hidden}.cache-meter-segment.svelte-1yzecxj{justify-content:center;align-items:center;min-width:3px;height:100%;transition:width .3s;display:flex;overflow:hidden}.cache-meter-segment-label.svelte-1yzecxj{color:#fff;white-space:nowrap;text-shadow:0 1px 2px #00000073;font-size:12px;font-weight:600;line-height:1}.cache-meter-segment.svelte-1yzecxj+.cache-meter-segment:where(.svelte-1yzecxj){box-shadow:-1px 0 0 var(--bg-surface)}.cache-meter-bar.is-empty.svelte-1yzecxj{background:var(--bg-surface-hover);justify-content:center;align-items:center;height:auto;min-height:28px;padding:6px 12px}.cache-meter-legend.svelte-1yzecxj{flex-wrap:wrap;gap:10px 24px;margin-top:16px;display:flex}.cache-meter-legend-item.svelte-1yzecxj{align-items:center;gap:8px;font-size:13px;display:flex}.cache-meter-swatch.svelte-1yzecxj{border-radius:3px;flex-shrink:0;width:12px;height:12px}.cache-meter-legend-label.svelte-1yzecxj{color:var(--text)}.cache-meter-legend-pct.svelte-1yzecxj{color:var(--text);font-weight:600}.cache-meter-legend-tokens.svelte-1yzecxj{color:var(--text-muted)}.cache-meter-empty.svelte-1yzecxj{color:var(--text-muted);text-align:center;font-size:13px}.spinner.svelte-b54l9o{width:var(--spinner-size);height:var(--spinner-size);border:2px solid var(--border,#80808059);border-top-color:var(--accent,currentColor);border-radius:50%;flex:none;animation:.7s linear infinite svelte-b54l9o-spinner-rotate;display:inline-block}@keyframes svelte-b54l9o-spinner-rotate{to{transform:rotate(360deg)}}.contribution-calendar-section.svelte-3hfxuq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);margin-top:24px;padding:24px}.contribution-calendar-header.svelte-3hfxuq{justify-content:space-between;align-items:center;margin-bottom:16px;display:flex}.contribution-calendar-header.svelte-3hfxuq h3{font-size:16px;font-weight:600}.contribution-calendar-grid-wrapper.svelte-3hfxuq{gap:8px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq{flex-direction:column;gap:2px;padding-top:22px;display:flex}.contribution-calendar-day-labels.svelte-3hfxuq span{height:13px;color:var(--text-muted);text-align:right;min-width:28px;font-size:10px;line-height:13px}.contribution-calendar-scroll.svelte-3hfxuq{--contribution-week-size:13px;--contribution-week-gap:2px;flex:1;min-width:0;overflow-x:auto}.contribution-calendar-months.svelte-3hfxuq{grid-auto-columns:var(--contribution-week-size);gap:var(--contribution-week-gap);grid-auto-flow:column;height:16px;margin-bottom:6px;display:grid}.contribution-calendar-month-label.svelte-3hfxuq{color:var(--text-muted);white-space:nowrap;font-size:10px}.contribution-calendar-grid.svelte-3hfxuq{gap:var(--contribution-week-gap);display:flex}.contribution-calendar-week.svelte-3hfxuq{flex-direction:column;gap:2px;display:flex}.contribution-calendar-cell.svelte-3hfxuq{width:var(--contribution-week-size);height:var(--contribution-week-size);background:var(--cal-level-0);border-radius:2px}.contribution-calendar-cell.level-1.svelte-3hfxuq{background:var(--cal-level-1)}.contribution-calendar-cell.level-2.svelte-3hfxuq{background:var(--cal-level-2)}.contribution-calendar-cell.level-3.svelte-3hfxuq{background:var(--cal-level-3)}.contribution-calendar-cell.level-4.svelte-3hfxuq{background:var(--cal-level-4)}.contribution-calendar-cell.level-5.svelte-3hfxuq{background:var(--cal-level-5)}.contribution-calendar-cell.level-6.svelte-3hfxuq{background:var(--cal-level-6)}.contribution-calendar-cell.level-7.svelte-3hfxuq{background:var(--cal-level-7)}.contribution-calendar-cell.level-8.svelte-3hfxuq{background:var(--cal-level-8)}.contribution-calendar-cell.level-9.svelte-3hfxuq{background:var(--cal-level-9)}.contribution-calendar-cell.level-10.svelte-3hfxuq{background:var(--cal-level-10)}.contribution-calendar-cell.empty.svelte-3hfxuq{background:0 0}.contribution-calendar-footer.svelte-3hfxuq{justify-content:space-between;align-items:center;gap:12px;margin-top:12px;display:flex}.contribution-calendar-meta.svelte-3hfxuq{flex-direction:column;gap:4px;display:flex}.contribution-calendar-summary.svelte-3hfxuq{color:var(--text-muted);font-size:12px}.contribution-calendar-legend.svelte-3hfxuq{color:var(--text-muted);align-items:center;gap:4px;font-size:11px;display:flex}.contribution-calendar-legend.svelte-3hfxuq .contribution-calendar-cell:where(.svelte-3hfxuq){cursor:default;width:11px;height:11px}.contribution-calendar-tooltip.svelte-3hfxuq{z-index:200;background:var(--bg-surface);color:var(--text);border:1px solid var(--border);white-space:nowrap;pointer-events:none;border-radius:4px;padding:4px 8px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;position:fixed;transform:translate(-50%);box-shadow:0 4px 12px #0003}@media (width<=768px){.contribution-calendar-day-labels.svelte-3hfxuq{display:none}.contribution-calendar-section.svelte-3hfxuq{padding:16px}.contribution-calendar-footer.svelte-3hfxuq{flex-direction:column;align-items:flex-start}}.inline-help-toggle.is-open.svelte-y40or3{color:var(--text);background:0 0}.inline-help-toggle.is-open.svelte-y40or3 .inline-help-toggle-icon{transform:rotate(540deg)}.audit-stats-section.svelte-14e9yan{margin-top:24px}.audit-stats-header.svelte-14e9yan{align-items:flex-start}.audit-stats-kpis.svelte-14e9yan{flex-wrap:wrap;align-items:center;gap:14px;display:flex}.audit-stats-kpi.svelte-14e9yan{color:var(--text-muted);white-space:nowrap;align-items:center;gap:6px;font-size:12px;display:inline-flex}.audit-stats-kpi-value.svelte-14e9yan{color:var(--text);font-size:13px}.audit-stats-kpi-dot.svelte-14e9yan{border-radius:2px;flex-shrink:0;width:8px;height:8px}.audit-stats-dot-2xx.svelte-14e9yan{background:var(--success)}.audit-stats-dot-4xx.svelte-14e9yan{background:var(--warning)}.audit-stats-dot-5xx.svelte-14e9yan{background:var(--danger)}.provider-status-details.svelte-6y9wjv{opacity:0;grid-template-rows:0fr;transition:grid-template-rows .28s,opacity .22s;display:grid}.provider-status-details.is-expanded.svelte-6y9wjv{opacity:1;grid-template-rows:1fr}.provider-status-details.is-collapsed.svelte-6y9wjv{pointer-events:none}.provider-status-details-inner.svelte-6y9wjv{flex-direction:column;gap:14px;min-height:0;display:flex;overflow:hidden}.provider-status-reason.svelte-6y9wjv{color:var(--text-muted);font-size:13px}.provider-status-error.svelte-6y9wjv{color:var(--danger);overflow-wrap:break-word;font-size:12px}.provider-status-config-label.svelte-6y9wjv{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-config.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;padding-top:12px;display:flex}.provider-status-config-row.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-config-value.svelte-6y9wjv{color:var(--text);overflow-wrap:break-word;font-size:13px;display:block}.provider-status-health.svelte-6y9wjv{border-top:1px solid var(--border);flex-direction:column;gap:10px;margin-bottom:12px;padding-top:12px;display:flex}.provider-status-health-state.svelte-6y9wjv{border:1px solid var(--border);border-radius:999px;align-items:center;padding:1px 8px;font-size:12px;font-weight:600;display:inline-flex}.provider-status-health-state.is-healthy.svelte-6y9wjv{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-health-state.is-degraded.svelte-6y9wjv{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-health-state.is-unhealthy.svelte-6y9wjv{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-health-models.svelte-6y9wjv{flex-direction:column;gap:4px;display:flex}.provider-status-health-model.svelte-6y9wjv{color:var(--text);justify-content:space-between;gap:8px;font-size:13px;display:flex}.provider-status-health-model.is-flagged.svelte-6y9wjv{color:var(--danger)}.provider-status-health-model-name.svelte-6y9wjv{overflow-wrap:anywhere}.provider-status-health-model-stats.svelte-6y9wjv{white-space:nowrap;color:var(--text-muted)}.provider-status-health-model.is-flagged.svelte-6y9wjv .provider-status-health-model-stats:where(.svelte-6y9wjv){color:var(--danger);font-weight:700}.provider-status-card.svelte-nopjmh{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:14px;padding:18px;display:flex}.provider-status-card-toggle.svelte-nopjmh{border:0;border-top:1px solid var(--border);border-radius:0 0 var(--radius) var(--radius);color:var(--text-muted);cursor:pointer;background:0 0;justify-content:center;align-items:center;margin:auto -18px -18px;padding:7px 0;transition:background .15s,color .15s;display:flex}.provider-status-card-toggle.svelte-nopjmh:hover{background:color-mix(in srgb, var(--accent) 10%, transparent);color:var(--text)}.provider-status-card-toggle.svelte-nopjmh:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 32%, transparent);outline-offset:-2px}.provider-status-card-toggle.svelte-nopjmh .provider-status-card-toggle-icon{width:16px;height:16px;transition:transform .28s;display:block}.provider-status-card-toggle.is-expanded.svelte-nopjmh .provider-status-card-toggle-icon{transform:rotate(180deg)}.provider-status-card-head.svelte-nopjmh{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.provider-status-name.svelte-nopjmh{letter-spacing:-.02em;flex-wrap:wrap;align-items:baseline;gap:6px;font-size:16px;font-weight:700;display:flex}.provider-doc-help.svelte-nopjmh{align-self:center;text-decoration:none}.provider-status-name-type.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-pill.svelte-nopjmh{border:1px solid var(--border);white-space:nowrap;border-radius:999px;justify-content:center;align-items:center;min-height:28px;padding:0 10px;font-size:12px;font-weight:700;display:inline-flex}.provider-status-pill.is-healthy.svelte-nopjmh{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border));background:color-mix(in srgb, var(--success) 10%, transparent)}.provider-status-pill.is-degraded.svelte-nopjmh{color:var(--warning);border-color:color-mix(in srgb, var(--warning) 48%, var(--border));background:color-mix(in srgb, var(--warning) 26%, var(--bg-surface))}.provider-status-pill.is-unhealthy.svelte-nopjmh{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 45%, var(--border));background:color-mix(in srgb, var(--danger) 10%, transparent)}.provider-status-meta.svelte-nopjmh{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}.provider-status-meta-item.svelte-nopjmh{background:var(--bg);border:1px solid var(--border);border-radius:6px;flex-direction:column;gap:4px;padding:10px 12px;display:flex}.provider-status-meta-label.svelte-nopjmh{letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);font-size:11px;font-weight:700}.provider-status-meta-value.svelte-nopjmh{color:var(--text);font-size:14px}@media (width<=768px){.provider-status-meta.svelte-nopjmh{grid-template-columns:1fr}}.provider-status-section-loading.svelte-1kx3uw4{justify-content:center;padding:24px 0;display:flex}.provider-status-section-header.svelte-1kx3uw4{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px;display:flex}.provider-status-toggle.svelte-1kx3uw4{background:var(--bg-surface);border:1px solid var(--border);color:var(--text);cursor:pointer;border-radius:6px;align-items:center;gap:10px;padding:8px 12px;font-family:inherit;font-size:12px;font-weight:600;transition:background-color .18s,border-color .18s,color .18s;display:inline-flex}.provider-status-toggle.svelte-1kx3uw4:hover{background:var(--bg-surface-hover)}.provider-status-toggle.svelte-1kx3uw4:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 28%, transparent);outline-offset:2px}.provider-status-toggle-copy.svelte-1kx3uw4{white-space:nowrap}.provider-status-toggle-track.svelte-1kx3uw4{background:color-mix(in srgb, var(--text-muted) 35%, var(--border));border-radius:999px;flex-shrink:0;width:34px;height:20px;transition:background-color .2s;position:relative}.provider-status-toggle-track.is-active.svelte-1kx3uw4{background:color-mix(in srgb, var(--accent) 82%, var(--bg-surface))}.provider-status-toggle-thumb.svelte-1kx3uw4{background:#fff;border-radius:50%;width:16px;height:16px;transition:transform .2s;position:absolute;top:2px;left:2px;box-shadow:0 1px 3px #0000003d}.provider-status-toggle-track.is-active.svelte-1kx3uw4 .provider-status-toggle-thumb:where(.svelte-1kx3uw4){transform:translate(14px)}.provider-status-grid.svelte-1kx3uw4{grid-template-columns:repeat(auto-fit,minmax(280px,1fr));align-items:start;gap:16px;display:grid}@media (width<=768px){.provider-status-section-header.svelte-1kx3uw4{flex-direction:column;align-items:flex-start}.provider-status-toggle.svelte-1kx3uw4{justify-content:space-between;width:100%}}.filter-input-wrap.svelte-30xz1k{flex:1;width:100%;min-width:min(400px,100%);display:flex;position:relative}.filter-input.svelte-30xz1k{flex:1;width:100%;min-width:0;padding-left:34px}.filter-input-wrap.svelte-30xz1k .filter-input-icon{width:14px;height:14px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:12px;transform:translateY(-50%)}.usage-page-filters.svelte-1oi6ywk{flex-wrap:wrap;gap:10px;margin-bottom:20px;display:flex}.usage-page-filters.svelte-1oi6ywk .usage-log-select{flex:0 auto}.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:220px;min-width:180px;max-width:360px}@media (width<=768px){.usage-page-filters.svelte-1oi6ywk .usage-log-select,.usage-page-filters.svelte-1oi6ywk .usage-page-filters-user-path{flex:100%;max-width:none}}.pro-saved-value.svelte-1qiwzdu{flex-wrap:wrap;align-items:baseline;gap:8px;display:flex}.pro-saved-delta.svelte-1qiwzdu{color:var(--success);letter-spacing:0;font-size:13px;font-weight:600}.usage-breakdown-loading.svelte-1kee4g8{justify-content:center;align-items:center;min-height:120px;display:flex}.chart-view-toggle.svelte-1kee4g8{background:var(--bg);border:1px solid var(--border);border-radius:6px;align-items:center;padding:2px;display:inline-flex}.chart-view-btn.svelte-1kee4g8{width:30px;height:28px;color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;transition:all .15s;display:inline-flex}.chart-view-btn.svelte-1kee4g8:hover{color:var(--text)}.chart-view-btn.active.svelte-1kee4g8{background:var(--accent);color:#fff}.chart-view-btn.svelte-1kee4g8 svg{fill:none;stroke:currentColor;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:16px;height:16px}.usage-chart-table-wrapper.svelte-1kee4g8{-webkit-overflow-scrolling:touch;margin-top:0;overflow-x:auto}.usage-chart-data-table.svelte-1kee4g8{min-width:max-content}.usage-chart-data-table.svelte-1kee4g8 th,.usage-chart-data-table.svelte-1kee4g8 td{white-space:nowrap}.pagination-info.svelte-1imew3q{color:var(--text-muted);font-size:13px}.pagination-buttons.svelte-1imew3q{gap:8px;display:flex}.usage-log-loading.svelte-hg4ill{justify-content:center;align-items:center;min-height:120px;display:flex}.usage-log-section.svelte-hg4ill{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.usage-log-section.svelte-hg4ill h3{margin-bottom:16px;font-size:16px;font-weight:600}.usage-log-section.svelte-hg4ill .table-wrapper{overflow-x:auto}.usage-log-toolbar.svelte-hg4ill{gap:12px;margin-bottom:16px;display:grid}.usage-filter-row.svelte-hg4ill{grid-template-columns:repeat(12,minmax(0,1fr));align-items:center;gap:12px;display:grid}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1/-1}.usage-filter-row-options.svelte-hg4ill{grid-template-columns:1fr}.usage-log-checkbox.svelte-hg4ill{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.usage-log-checkbox.svelte-hg4ill input{cursor:pointer;width:16px;height:16px}.usage-ts.svelte-hg4ill{white-space:nowrap;font-size:12px}.usage-log-row-cached.svelte-hg4ill td{opacity:.75;font-style:italic}.usage-log-row-cached.svelte-hg4ill .usage-log-cache-cell:where(.svelte-hg4ill){font-weight:700}.caveat-icon.svelte-hg4ill{color:var(--warning);cursor:help;margin-left:4px;font-size:14px}@media (width<=768px){.usage-log-toolbar.svelte-hg4ill{gap:10px}.usage-filter-row.svelte-hg4ill{grid-template-columns:1fr}.usage-filter-row-search.svelte-hg4ill .filter-input-wrap{grid-column:1}.usage-log-table.svelte-hg4ill{display:block;overflow-x:auto}}.usage-sticky-controls.svelte-spwie6{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}.usage-charts-grid.svelte-spwie6{flex-wrap:wrap;gap:24px;margin-bottom:24px;display:flex}.usage-charts-grid.svelte-spwie6 .model-chart-section{flex:calc(50% - 24px);min-width:420px;margin-bottom:0}@media (width<=520px){.usage-charts-grid.svelte-spwie6 .model-chart-section{min-width:0}}.loading-state.svelte-hzxv1d{min-height:var(--loading-state-min-height,64px);color:var(--text-muted);justify-content:center;align-items:center;gap:10px;font-size:14px;display:flex}.budget-bar-text-row-on-fill.svelte-1jm56wo{color:#fff;clip-path:inset(0 calc(100% - var(--budget-progress,0%)) 0 0)}.budget-bar-text-start.svelte-1jm56wo{left:8px;transform:translateY(-50%)}.budget-bar-track-period-custom.svelte-1jm56wo .budget-bar-text-row-on-fill:where(.svelte-1jm56wo){color:#3f332a}.budget-override-dialog.svelte-13ryo7h{max-width:460px}.budget-sort-control.svelte-1752fqe{align-items:center;gap:8px}.budget-sort-control.svelte-1752fqe label{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.budget-sort-select.svelte-1752fqe{background-color:var(--bg-surface);min-width:132px}.budget-sort-select.svelte-1752fqe:hover{background-color:var(--bg-surface-hover)}.model-name-cell.svelte-1iynym{flex-direction:column;gap:8px;display:flex}.model-name-primary.svelte-1iynym{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.model-name-secondary.svelte-1iynym{color:var(--text-muted);font-size:12px}.model-redirect-remove-btn.svelte-1iynym{appearance:none;color:var(--danger);cursor:pointer;background:0 0;border:0;margin-left:4px;padding:0;font-size:11px}.model-redirect-remove-btn.svelte-1iynym:hover:not(:disabled){text-decoration:underline}.model-redirect-remove-btn.svelte-1iynym:disabled{opacity:.45;cursor:default}.model-kind-icon.svelte-1iynym{border:1px solid color-mix(in srgb, var(--accent) 55%, var(--border));background:var(--bg);width:24px;height:24px;color:var(--accent);border-radius:999px;flex:0 0 24px;justify-content:center;align-items:center;display:inline-flex}.model-kind-icon-svg.svelte-1iynym{width:14px;height:14px}.model-row-actions.svelte-1iynym{text-align:right;width:170px}@media (width<=768px){.model-name-primary.svelte-1iynym{flex-direction:column;align-items:flex-start}}.provider-group-row.svelte-1911hy6 td{background:color-mix(in srgb, var(--accent) 6%, var(--bg));padding-top:12px;padding-bottom:12px}.provider-group-row.svelte-1911hy6:hover td{background:color-mix(in srgb, var(--accent) 8%, var(--bg))}.provider-group-header.svelte-1911hy6{justify-content:space-between;align-items:center;gap:16px;display:flex}.provider-group-meta.svelte-1911hy6{flex-direction:column;gap:4px;min-width:0;display:flex}.provider-group-title.svelte-1911hy6{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.provider-group-type.svelte-1911hy6,.provider-group-count.svelte-1911hy6,.provider-group-summary.svelte-1911hy6{color:var(--text-muted);font-size:12px}@media (width<=768px){.provider-group-header.svelte-1911hy6{flex-direction:column;align-items:flex-start}}.vm-session-affinity-checkbox.svelte-d1j6xw{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:8px;font-size:13px;display:inline-flex}.vm-session-affinity-checkbox.svelte-d1j6xw input:where(.svelte-d1j6xw){accent-color:var(--accent);cursor:pointer}.pricing-override-rows.svelte-u8snes{gap:12px;display:grid}.pricing-override-row.svelte-u8snes{grid-template-columns:minmax(220px,1fr) minmax(130px,180px) 32px;align-items:end;gap:12px;display:grid}.pricing-override-row-actions.svelte-u8snes{justify-content:flex-start;display:flex}.pricing-override-tier-note.svelte-u8snes{border:1px solid var(--border);background:var(--bg);color:var(--text-muted);border-radius:6px;padding:10px 12px;font-size:13px}.pricing-preview.svelte-u8snes{border:1px solid var(--border);border-radius:6px;overflow:hidden}.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:minmax(150px,1fr) minmax(90px,auto) minmax(130px,.8fr);align-items:center;gap:12px;padding:10px 12px;display:grid}.pricing-preview-header.svelte-u8snes{background:var(--bg);color:var(--text-muted);text-transform:uppercase;font-size:12px;font-weight:600}.pricing-preview-row.svelte-u8snes{border-top:1px solid var(--border);font-size:13px}.pricing-preview-row-empty.svelte-u8snes{color:var(--text-muted);grid-template-columns:1fr}@media (width<=768px){.pricing-override-row.svelte-u8snes,.pricing-preview-header.svelte-u8snes,.pricing-preview-row.svelte-u8snes{grid-template-columns:1fr}}.failover-drafts-editor.svelte-1n87bip{flex-direction:column;gap:16px;display:flex}.failover-draft-header-actions.svelte-1n87bip{flex:none;align-items:center;gap:10px;display:flex}.failover-draft-counter.svelte-1n87bip{color:var(--text-muted);white-space:nowrap;font-size:12px;font-weight:600}.failover-draft-toolbar.svelte-1n87bip{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.failover-draft-toolbar.svelte-1n87bip .filter-input-wrap,.failover-draft-toolbar.svelte-1n87bip .filter-input{min-width:0}.failover-draft-toggle-all.svelte-1n87bip{flex:none}.failover-draft-list.svelte-1n87bip{flex-direction:column;gap:8px;max-height:min(52vh,430px);padding-right:4px;display:flex;overflow-y:auto}.failover-draft-row.svelte-1n87bip{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);cursor:pointer;grid-template-columns:18px minmax(0,1fr);align-items:start;gap:10px;padding:10px;display:grid}.failover-draft-row.svelte-1n87bip:hover{border-color:color-mix(in srgb, var(--accent) 42%, var(--border));background:var(--bg-surface-hover)}.failover-draft-row.svelte-1n87bip input{width:16px;height:16px;margin-top:2px}.failover-draft-copy.svelte-1n87bip{gap:4px;min-width:0;display:grid}.failover-draft-source.svelte-1n87bip,.failover-draft-targets.svelte-1n87bip{overflow-wrap:anywhere}.failover-draft-targets.svelte-1n87bip{color:var(--text-muted);font-size:12px}.failover-drafts-empty.svelte-1n87bip{align-items:center;min-height:96px;display:flex}.failover-draft-actions.svelte-1n87bip{margin-top:0}.category-tabs.svelte-scpjps{-webkit-overflow-scrolling:touch;align-items:center;gap:4px;margin-bottom:16px;padding-bottom:2px;display:flex;overflow-x:auto}.category-tab.svelte-scpjps{background:var(--bg-surface);border:1px solid var(--border);color:var(--text-muted);cursor:pointer;white-space:nowrap;border-radius:6px;flex-shrink:0;align-items:center;gap:6px;padding:6px 14px;font-family:inherit;font-size:13px;font-weight:500;transition:all .15s;display:inline-flex}.category-tab.svelte-scpjps:hover{color:var(--text);background:var(--bg-surface-hover)}.category-tab.active.svelte-scpjps{background:var(--accent);color:#fff;border-color:var(--accent)}.category-tab.svelte-scpjps .tab-count:where(.svelte-scpjps){background:#ffffff26;border-radius:9px;justify-content:center;align-items:center;min-width:20px;height:18px;padding:0 5px;font-size:11px;font-weight:600;line-height:1;display:inline-flex}.category-tab.svelte-scpjps:not(.active) .tab-count:where(.svelte-scpjps){background:var(--bg)}@media (width<=768px){.category-tabs.svelte-scpjps{gap:4px}.category-tab.svelte-scpjps{padding:5px 10px;font-size:12px}}.workflow-pipeline-meta.svelte-1viff7o{border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 86%, transparent);min-width:0;max-width:calc(100% - 28px);color:var(--text-muted);white-space:nowrap;appearance:none;cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:0;padding:2px 10px;font-size:12px;font-weight:500;line-height:1.2;transition:background-color .15s,border-color .15s,color .15s,box-shadow .15s;display:inline-flex;position:absolute;top:12px;right:14px;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover,.workflow-pipeline-meta.svelte-1viff7o:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface));color:color-mix(in srgb, var(--accent) 74%, var(--text))}.workflow-pipeline-meta.svelte-1viff7o:focus-visible{box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);outline:none}.workflow-pipeline-meta-label.svelte-1viff7o{flex:none;font-weight:700}.workflow-pipeline-meta-placeholder.svelte-1viff7o{opacity:1;flex:none;max-width:3ch;margin-left:4px;transition:max-width .18s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta-value.svelte-1viff7o{opacity:0;text-overflow:clip;flex:0 auto;max-width:0;margin-left:0;transition:max-width .22s,margin-left .18s,opacity .15s;overflow:hidden}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-placeholder:where(.svelte-1viff7o){opacity:0;max-width:0;margin-left:0}.workflow-pipeline-meta.svelte-1viff7o:hover .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta.svelte-1viff7o:focus-visible .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o),.workflow-pipeline-meta-error.svelte-1viff7o .workflow-pipeline-meta-value:where(.svelte-1viff7o){opacity:1;max-width:42ch;margin-left:4px}.workflow-pipeline-meta-icon.svelte-1viff7o{opacity:0;flex:none;justify-content:center;align-items:center;width:0;height:14px;margin-left:0;line-height:0;transition:width .18s,margin-left .18s,opacity .15s,transform .18s;display:inline-flex;overflow:hidden;transform:translate(4px)translateY(1px)scale(.84)}.workflow-pipeline-meta-icon.svelte-1viff7o svg{width:14px;height:14px}.workflow-pipeline-meta-copied.svelte-1viff7o,.workflow-pipeline-meta-copied.svelte-1viff7o:hover,.workflow-pipeline-meta-copied.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--success) 12%, var(--bg));border-color:color-mix(in srgb, var(--success) 40%, var(--border));color:var(--success)}.workflow-pipeline-meta-copied.svelte-1viff7o .workflow-pipeline-meta-icon:where(.svelte-1viff7o){opacity:1;width:14px;margin-left:6px;transform:translateY(1px)}.workflow-pipeline-meta-error.svelte-1viff7o,.workflow-pipeline-meta-error.svelte-1viff7o:hover,.workflow-pipeline-meta-error.svelte-1viff7o:focus-visible{background:color-mix(in srgb, var(--danger) 10%, var(--bg));border-color:color-mix(in srgb, var(--danger) 34%, var(--border));color:var(--danger)}.workflow-pipeline.svelte-nbptrg{border-radius:var(--radius);border:1px solid var(--border);background:var(--bg);flex-direction:column;gap:0;margin-bottom:12px;padding:18px 20px 20px;display:flex;position:relative}.workflow-pipeline-has-meta.svelte-nbptrg{padding-top:42px}.workflow-pipeline-row.svelte-nbptrg{align-items:center;width:100%;min-width:0;display:flex;overflow-x:auto}.workflow-node-icon.svelte-nbptrg{border-radius:var(--radius);background:var(--bg);width:28px;height:28px;color:var(--text-muted);justify-content:center;align-items:center;display:flex}.workflow-node-icon.svelte-nbptrg svg{stroke:currentColor;fill:none;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:15px;height:15px}.workflow-node-label.svelte-nbptrg{letter-spacing:.03em;color:var(--text);white-space:nowrap;font-size:11px;font-weight:700;line-height:1.2}.workflow-node-sub.svelte-nbptrg{color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;max-width:120px;font-size:10px;font-weight:500;line-height:1.2;font-family:var(--font-mono,ui-monospace, monospace);overflow:hidden}.workflow-node-badge.svelte-nbptrg{border-radius:var(--radius);letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;border:1px solid var(--border);background:var(--bg);color:var(--text-muted);align-items:center;padding:2px 7px;font-size:9px;font-weight:800;line-height:1.5;display:inline-flex}.workflow-node-endpoint.svelte-nbptrg{border-radius:var(--radius);border-color:var(--border);background:var(--bg-surface);flex-direction:row;gap:7px;min-width:auto;padding:10px 14px}.workflow-node-icon-endpoint.svelte-nbptrg{border-radius:var(--radius);width:auto;height:auto;color:var(--text-muted);background:0 0;justify-content:flex-start;padding:0}.workflow-node-icon-endpoint.svelte-nbptrg svg{width:14px;height:14px}.workflow-node-endpoint.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted);font-size:11px;font-weight:600}.workflow-node-feature.svelte-nbptrg{border-color:color-mix(in srgb, var(--accent) 46%, var(--border));background:color-mix(in srgb, var(--accent) 8%, var(--bg-surface))}.workflow-node-feature.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--accent) 16%, var(--bg));color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--accent)}.workflow-node-feature.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--accent) 70%, var(--text-muted))}.workflow-node-ai.svelte-nbptrg{border-radius:var(--radius);gap:6px;min-width:96px;padding:12px 16px}.workflow-async-section.svelte-nbptrg{justify-content:flex-end;align-items:center;gap:0;width:100%;min-width:0;margin-top:10px;display:flex}.workflow-async-turn.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 60px;height:2px;position:relative}.workflow-async-turn.svelte-nbptrg:before{content:"";background:color-mix(in srgb, var(--text-muted) 40%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);width:7px;height:9px;position:absolute;top:50%;left:-7px;transform:translateY(-50%)}.workflow-async-turn.svelte-nbptrg:after{content:"";border-right:2px dashed color-mix(in srgb, var(--text-muted) 40%, var(--border));height:16px;position:absolute;bottom:1px;right:0}.workflow-async-row.svelte-nbptrg{align-items:center;min-width:0;margin-right:7px;display:flex}.workflow-conn-async.svelte-nbptrg{background:repeating-linear-gradient(to left, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 0, color-mix(in srgb, var(--text-muted) 45%, var(--border)) 5px, transparent 5px, transparent 9px);flex:0 0 24px;width:24px}.workflow-conn-async.svelte-nbptrg:after{background:color-mix(in srgb, var(--text-muted) 45%, var(--border));clip-path:polygon(100% 0,0 50%,100% 100%);left:-1px;right:auto}.workflow-node-async.svelte-nbptrg{border-radius:var(--radius);border-style:dashed;flex-direction:row;gap:7px;min-width:auto;padding:7px 12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){border-radius:var(--radius);width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg) svg{width:12px;height:12px}.workflow-node-async.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){font-size:10px;font-weight:700}.workflow-async-label.svelte-nbptrg{letter-spacing:.1em;text-transform:uppercase;color:var(--text-muted);opacity:.55;white-space:nowrap;flex-shrink:0;align-items:center;margin-left:8px;font-size:9px;font-weight:800;display:inline-flex}.workflow-node-success.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 18%, var(--bg));color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--success)}.workflow-node-success.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 85%, var(--text))}.workflow-node-success.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--success) 74%, var(--text-muted))}.workflow-node-success.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--success) 14%, var(--bg));border-color:color-mix(in srgb, var(--success) 38%, var(--border));color:var(--success)}.workflow-node-current.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 16%, var(--bg));color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--info)}.workflow-node-current.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 85%, var(--text))}.workflow-node-current.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--info) 72%, var(--text-muted))}.workflow-node-current.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--info) 13%, var(--bg));border-color:color-mix(in srgb, var(--info) 36%, var(--border));color:var(--info)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--warning)}.workflow-node-warning.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 85%, var(--text))}.workflow-node-warning.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--warning) 72%, var(--text-muted))}.workflow-node-warning.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 38%, var(--border));color:var(--warning)}.workflow-node-error.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--danger) 14%, var(--bg));color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg){color:var(--danger)}.workflow-node-error.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 85%, var(--text))}.workflow-node-error.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--danger) 72%, var(--text-muted))}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 12%, var(--bg));color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-icon-endpoint:where(.svelte-nbptrg),.workflow-node-neutral.svelte-nbptrg .workflow-node-label:where(.svelte-nbptrg){color:var(--text-muted)}.workflow-node-neutral.svelte-nbptrg .workflow-node-sub:where(.svelte-nbptrg){color:color-mix(in srgb, var(--text-muted) 84%, var(--border))}.workflow-node-neutral.svelte-nbptrg .workflow-node-badge:where(.svelte-nbptrg){background:color-mix(in srgb, var(--text-muted) 10%, var(--bg));border-color:color-mix(in srgb, var(--text-muted) 28%, var(--border));color:var(--text-muted)}.workflow-conn-hit.svelte-nbptrg,.workflow-conn-hit.svelte-nbptrg:after{background:color-mix(in srgb, var(--success) 58%, var(--border))}.workflow-conn-dim.svelte-nbptrg,.workflow-conn-dim.svelte-nbptrg:after{background:color-mix(in srgb, var(--border) 75%, transparent)}.workflow-node-success.svelte-nbptrg{border-color:color-mix(in srgb, var(--success) 52%, var(--border));background:color-mix(in srgb, var(--success) 9%, var(--bg-surface))}.workflow-node-current.svelte-nbptrg{border-color:color-mix(in srgb, var(--info) 56%, var(--border));background:color-mix(in srgb, var(--info) 10%, var(--bg-surface))}.workflow-node-warning.svelte-nbptrg{border-color:color-mix(in srgb, var(--warning) 52%, var(--border));background:color-mix(in srgb, var(--warning) 9%, var(--bg-surface))}.workflow-node-error.svelte-nbptrg{border-color:color-mix(in srgb, var(--danger) 52%, var(--border));background:color-mix(in srgb, var(--danger) 9%, var(--bg-surface))}.workflow-node-neutral.svelte-nbptrg{border-color:color-mix(in srgb, var(--text-muted) 40%, var(--border));background:color-mix(in srgb, var(--text-muted) 8%, var(--bg-surface))}.workflow-node-skipped.svelte-nbptrg{opacity:.28;position:relative}.workflow-card.svelte-1fo9fvq{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);flex-direction:column;gap:16px;padding:20px;display:flex}.workflow-card-head.svelte-1fo9fvq{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.workflow-card-footer.svelte-1fo9fvq{flex-direction:column;align-items:stretch;gap:10px;display:flex}.workflow-card-head.svelte-1fo9fvq h3{font-size:18px;font-weight:700}.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq{flex-wrap:wrap;justify-content:flex-end;gap:8px;display:flex}.workflow-card-meta-footer.svelte-1fo9fvq{justify-content:flex-start}.workflow-card-footer.svelte-1fo9fvq .alias-actions-cell{align-self:flex-end}.workflow-card-description.svelte-1fo9fvq{color:var(--text-muted);font-size:14px}.workflow-guardrails.svelte-1fo9fvq{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list.svelte-1fo9fvq{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-item.svelte-1fo9fvq{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;display:flex}@media (width<=768px){.workflow-card-head.svelte-1fo9fvq,.workflow-card-footer.svelte-1fo9fvq,.workflow-card-badges.svelte-1fo9fvq,.workflow-card-meta.svelte-1fo9fvq,.workflow-guardrail-item.svelte-1fo9fvq{flex-direction:column;align-items:flex-start}}.model-editor.workflow-editor{width:min(1080px,100%);margin-bottom:0}.alert-inline-actions.svelte-1bcpzh1{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;display:flex}.workflow-guardrail-editor.svelte-1bcpzh1{flex-direction:column;gap:12px;display:flex}.workflow-guardrail-list-editor.svelte-1bcpzh1{flex-direction:column;gap:10px;display:flex}.workflow-guardrail-row.svelte-1bcpzh1{border:1px solid var(--border);background:var(--bg);border-radius:10px;justify-content:stretch;align-items:center;gap:12px;padding:10px 12px;display:flex}.workflow-guardrail-field.svelte-1bcpzh1{flex:auto;min-width:0}.workflow-guardrail-step-field.svelte-1bcpzh1{flex:0 0 120px}.workflow-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-step-input.svelte-1bcpzh1{max-width:120px}@media (width<=768px){.workflow-guardrail-row.svelte-1bcpzh1{flex-direction:column;align-items:flex-start}.workflow-step-input.svelte-1bcpzh1{width:100%;max-width:none}.workflow-guardrail-field.svelte-1bcpzh1,.workflow-guardrail-step-field.svelte-1bcpzh1{flex-basis:auto;width:100%}}.workflow-list-loading.svelte-ie2kfk{justify-content:center;align-items:center;gap:8px;display:flex}.workflows-list.svelte-ie2kfk{min-width:0}.workflow-card-grid.svelte-ie2kfk{grid-template-columns:1fr;gap:16px;display:grid}.workflow-page-note.svelte-l8kr26{color:var(--text-muted);margin-top:6px;font-size:14px}.audit-log-toolbar.svelte-1pwbpcm{flex-direction:column;gap:10px;margin-bottom:14px;display:flex}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:repeat(12,minmax(0,1fr));gap:10px;display:grid}.audit-filter-select.svelte-1pwbpcm{grid-column:span 2;min-width:0}.audit-filter-row-search.svelte-1pwbpcm .filter-input-wrap{grid-column:1/-1;max-width:none}.audit-filter-row-controls.svelte-1pwbpcm .audit-filter-select:where(.svelte-1pwbpcm){grid-column:span 2}.audit-filter-row-controls.svelte-1pwbpcm .btn{grid-column:11/-1;justify-self:end;min-width:108px}.audit-clear-btn.svelte-1pwbpcm{justify-content:center;align-items:center;gap:8px;font-weight:600;display:inline-flex}.audit-clear-btn.svelte-1pwbpcm .table-icon-svg{width:12px;height:12px}@media (width<=768px){.audit-log-toolbar.svelte-1pwbpcm{gap:8px}.audit-filter-row.svelte-1pwbpcm{grid-template-columns:1fr}.audit-filter-row.svelte-1pwbpcm .filter-input-wrap,.audit-filter-row.svelte-1pwbpcm .filter-input,.audit-filter-select.svelte-1pwbpcm,.audit-filter-row.svelte-1pwbpcm .btn{grid-column:auto}}.audit-live-status.svelte-tve6yv{color:var(--text-muted);align-items:center;gap:10px;margin-left:16px;padding-left:6px;font-size:12px;display:inline-flex}.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:1.8s ease-out infinite svelte-tve6yv-audit-live-dot-throb}@keyframes svelte-tve6yv-audit-live-dot-throb{0%{transform:scale(1)}35%{transform:scale(1.35)}70%{transform:scale(1)}to{transform:scale(1)}}@media (prefers-reduced-motion:reduce){.audit-live-status.svelte-tve6yv .live-dot.is-streaming:where(.svelte-tve6yv){animation:none}}.audit-live-status-text.is-live.svelte-tve6yv{color:var(--success);font-weight:600}.audit-entry-metadata.svelte-hyopt0{border-top:1px solid var(--border);align-items:center;gap:10px;margin-top:12px;padding-top:12px;display:flex}.audit-entry-metadata-label.svelte-hyopt0{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;flex:none;font-size:12px;font-weight:700}.audit-entry-context.svelte-hyopt0{flex-wrap:wrap;flex:auto;gap:8px;display:flex}.audit-alias-badge.svelte-hyopt0{background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 28%, var(--border));color:var(--accent-strong,var(--accent))}@media (width<=768px){.audit-entry-metadata.svelte-hyopt0{flex-direction:column;align-items:flex-start;gap:8px}}.audit-attempt-track.svelte-1eu22xn{cursor:pointer;align-items:center;gap:6px;display:inline-flex}.audit-attempt-track-pips.svelte-1eu22xn{align-items:center;gap:3px;display:inline-flex}.audit-attempt-pip.svelte-1eu22xn{background:var(--text-muted);border-radius:2px;width:8px;height:8px}.audit-attempt-pip.audit-attempt-success.svelte-1eu22xn{background:var(--success)}.audit-attempt-pip.audit-attempt-error.svelte-1eu22xn{background:var(--danger)}.audit-attempt-track-count.svelte-1eu22xn{color:var(--text-muted);font-size:11px}.audit-entry-summary.svelte-17mysgz{cursor:pointer;justify-content:space-between;align-items:center;gap:12px;padding:5px 14px;list-style:none;display:flex;position:relative}.audit-entry-summary.svelte-17mysgz::-webkit-details-marker{display:none}.audit-entry-summary-live-in-progress.svelte-17mysgz{background:color-mix(in srgb, var(--info) 7%, var(--bg))}.audit-entry-summary-has-interactions.svelte-17mysgz{padding-right:44px}.audit-entry-summary-live-in-progress.svelte-17mysgz:before{content:"";background:var(--info);pointer-events:none;width:3px;animation:1.2s ease-in-out infinite audit-live-summary-stripe-blink;position:absolute;inset:0 auto 0 0}@media (prefers-reduced-motion:reduce){.audit-entry-summary-live-in-progress.svelte-17mysgz:before{opacity:.78;animation:none}}.audit-entry-left.svelte-17mysgz{align-items:center;gap:8px;min-width:0;display:flex}.audit-entry-right.svelte-17mysgz{color:var(--text-muted);flex-shrink:0;align-items:center;gap:10px;min-height:28px;display:inline-flex}.audit-thread-expander.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);min-width:28px;height:28px;color:var(--text-muted);cursor:pointer;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;gap:3px;padding:0 7px 0 4px;transition:background .1s ease-out,color .1s ease-out;display:inline-flex}.audit-thread-expander.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 12%, var(--bg));color:var(--accent)}.audit-thread-expander.svelte-17mysgz .audit-thread-expander-svg{width:14px;height:14px}.audit-thread-count.svelte-17mysgz{font-size:11px;font-weight:600}.audit-conversation-trigger.svelte-17mysgz{border:0;border-left:1px solid var(--border);background:color-mix(in srgb, var(--accent) 12%, var(--bg));width:32px;height:100%;color:var(--accent);cursor:pointer;border-radius:0;justify-content:center;align-items:center;margin:0;transition:background .1s ease-out,color .1s ease-out;display:inline-flex;position:absolute;inset:0 0 0 auto}.audit-conversation-trigger.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 20%, var(--bg))}.audit-conversation-trigger-active.svelte-17mysgz{color:var(--accent-strong,var(--accent));background:color-mix(in srgb, var(--accent) 28%, var(--bg));border-left:0}.audit-conversation-trigger-active.svelte-17mysgz:hover{background:color-mix(in srgb, var(--accent) 34%, var(--bg))}.audit-conversation-trigger.svelte-17mysgz .audit-conversation-trigger-svg{stroke-linecap:butt;stroke-linejoin:miter;width:18px;height:18px}.audit-path.svelte-17mysgz{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.audit-request-badge.svelte-17mysgz{white-space:nowrap;gap:6px;min-width:0}.audit-timestamp-time.svelte-17mysgz{display:none}.audit-provider-model.svelte-17mysgz{border:1px solid var(--border);background:var(--bg-surface);height:24px;color:var(--text-muted);white-space:nowrap;text-overflow:ellipsis;border-radius:999px;align-items:center;max-width:420px;padding:0 10px;font-size:12px;display:inline-flex;overflow:hidden}@container dashboard-content (width<=699px){.audit-entry-summary.svelte-17mysgz{flex-direction:column;align-items:flex-start}.audit-entry-right.svelte-17mysgz{justify-content:space-between;width:100%}.audit-request-status.svelte-17mysgz,.audit-timestamp-full.svelte-17mysgz{display:none}.audit-timestamp-time.svelte-17mysgz{display:inline}}.audit-pane-split.svelte-1h5puht{grid-template-columns:1fr 2fr;align-items:start;gap:10px 14px;display:grid}.audit-pane-split-single.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}@container dashboard-content (width<=699px){.audit-pane-split.svelte-1h5puht{grid-template-columns:minmax(0,1fr)}}.audit-pane-split.svelte-1h5puht .audit-pane-block-error:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-pane-empty:where(.svelte-1h5puht),.audit-pane-split.svelte-1h5puht .audit-size-warning:where(.svelte-1h5puht){grid-column:1/-1}.audit-pane-block.svelte-1h5puht{min-width:0}.audit-pane-block.svelte-1h5puht>h5{margin-bottom:6px}.audit-pane-block-head.svelte-1h5puht{justify-content:space-between;align-items:center;gap:8px;margin-bottom:6px;display:flex}.audit-pane-block-title.svelte-1h5puht{align-items:center;gap:8px;min-width:0;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn{background-color:var(--bg-surface);border:1px solid color-mix(in srgb, var(--border) 70%, var(--text) 30%);color:var(--text);cursor:pointer;border-radius:6px;flex:none;align-items:center;gap:6px;padding:4px 8px;font-family:inherit;font-size:12px;transition:background-color .15s,border-color .15s,color .15s;display:inline-flex}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn:hover:not(:disabled){background:color-mix(in srgb, var(--bg-surface) 80%, var(--text) 20%);border-color:color-mix(in srgb, var(--border) 45%, var(--text) 55%)}.audit-pane-block-head.svelte-1h5puht .audit-copy-btn.copy-feedback-btn-copied{background:color-mix(in srgb, var(--success) 18%, var(--bg-surface))}.audit-json.svelte-1h5puht{background:var(--bg-surface);border:1px solid var(--border);box-sizing:border-box;white-space:pre;max-width:100%;max-height:220px;color:var(--text);border-radius:6px;padding:10px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:12px;line-height:1.45;overflow:auto}.audit-pane-error-message.svelte-1h5puht{color:var(--danger)}.audit-pane-clickable-preview.svelte-1h5puht{cursor:pointer}.audit-pane-clickable-preview.svelte-1h5puht:hover{background:color-mix(in srgb, var(--danger) 8%, transparent)}.audit-json-body.svelte-1h5puht{white-space:pre;overflow-wrap:normal}.audit-pane-empty.svelte-1h5puht{text-align:left;padding:8px 0 0}.audit-pane-pending.svelte-1h5puht{align-items:center;gap:8px;display:flex}.audit-pane-streaming.svelte-1h5puht{letter-spacing:.02em;color:var(--text-muted);align-items:center;gap:7px;padding-left:4px;font-size:11px;font-weight:600;display:inline-flex}.audit-size-warning.svelte-1h5puht{color:var(--warning);margin-top:8px;font-size:12px}.audit-request-response.svelte-1bc5vi5{margin-top:4px}.audit-pane-tablist.svelte-1bc5vi5{border-bottom:1px solid var(--border);flex-wrap:wrap;gap:2px;display:flex}.audit-pane-tab.svelte-1bc5vi5{border:1px solid var(--border);color:var(--text-muted);cursor:pointer;background:0 0;border-bottom-color:#0000;border-radius:6px 6px 0 0;align-items:center;gap:8px;margin-bottom:-1px;margin-right:12px;padding:8px 12px;font-family:inherit;font-size:13px;transition:color .15s,border-color .15s,background-color .15s;display:inline-flex}.audit-pane-tab.svelte-1bc5vi5:not(.audit-pane-tab-active):hover{color:var(--text);background:color-mix(in srgb, var(--text) 5%, transparent)}.audit-pane-tab-active.svelte-1bc5vi5{color:var(--text);border-color:var(--border);border-bottom-color:var(--bg);background:var(--bg)}.audit-pane-tab-label.svelte-1bc5vi5{font-weight:600}.audit-pane-tabpanel.svelte-1bc5vi5{min-width:0}.audit-pane-icon.svelte-1bc5vi5{color:var(--text-muted);flex:none;align-items:center;display:inline-flex}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-request{color:var(--accent)}.audit-pane-icon.svelte-1bc5vi5.audit-pane-icon-response{color:var(--info)}.audit-pane-icon.svelte-1bc5vi5 svg{width:16px;height:16px}.audit-pane-seq.svelte-1bc5vi5{color:var(--text-muted);font-size:12px}.audit-pane-kind.svelte-1bc5vi5{text-transform:uppercase;letter-spacing:.04em;font-size:10px;font-weight:600}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-primary{color:var(--text-muted)}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-failover{color:var(--accent);background:color-mix(in srgb, var(--accent) 14%, var(--bg));border-color:color-mix(in srgb, var(--accent) 30%, var(--border))}.audit-pane-kind.svelte-1bc5vi5.audit-pane-kind-retry{color:var(--warning);background:color-mix(in srgb, var(--warning) 14%, var(--bg));border-color:color-mix(in srgb, var(--warning) 30%, var(--border))}.audit-savings-pill.svelte-1bc5vi5{border:1px solid color-mix(in srgb, var(--prompt-cache-color) 45%, var(--border));background:var(--prompt-cache-color-bg);color:var(--prompt-cache-color);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;font-weight:700;display:inline-flex}.audit-step-pill.svelte-1bc5vi5{border:1px dashed var(--border);color:var(--text-muted);letter-spacing:.02em;border-radius:999px;align-items:center;padding:1px 7px;font-size:11px;display:inline-flex}.audit-entry.svelte-cmjgwr{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);transition:background .12s ease-out,border-color .12s ease-out;overflow:hidden}.audit-entry-interactions-open.svelte-cmjgwr{border-width:2px;border-color:color-mix(in srgb, var(--prompt-cache-color) 38%, var(--border))}.audit-entry-details.svelte-cmjgwr{border-top:1px solid var(--border);background:var(--bg-surface);padding:12px;overflow:hidden}.audit-thread.svelte-pneivi{flex-direction:column;gap:10px;display:flex}.audit-thread-children.svelte-pneivi{flex-direction:column;gap:10px;margin-left:26px;display:flex}.audit-thread-child.svelte-pneivi,.audit-thread-loading.svelte-pneivi{position:relative}.audit-thread-child.svelte-pneivi:before,.audit-thread-loading.svelte-pneivi:before{content:"";border-left:1px solid var(--border);border-bottom:1px solid var(--border);pointer-events:none;border-bottom-left-radius:6px;width:12px;height:calc(50% + 10px);position:absolute;top:-10px;left:-14px}.audit-thread-child.svelte-pneivi:not(:last-child):after{content:"";border-left:1px solid var(--border);pointer-events:none;position:absolute;top:50%;bottom:-10px;left:-14px}.audit-thread-loading.svelte-pneivi{padding:6px 0 6px 4px;display:flex}.audit-thread-more.svelte-pneivi{color:var(--text-muted);padding-left:4px;font-size:12px}.audit-log-loading.svelte-1nhcbov{justify-content:center;padding:2rem 0;display:flex}.audit-list-toolbar.svelte-1nhcbov{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;display:flex}.audit-list-toolbar-left.svelte-1nhcbov{flex-wrap:wrap;align-items:center;gap:16px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov{color:var(--text-muted);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:7px;font-size:13px;display:inline-flex}.audit-group-checkbox.svelte-1nhcbov input:where(.svelte-1nhcbov){accent-color:var(--accent);cursor:pointer}.audit-retention-note.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-retention-highlight.svelte-1nhcbov{color:var(--text);font-weight:600}.audit-log-section.svelte-1nhcbov{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px}.audit-log-summary.svelte-1nhcbov{color:var(--text-muted);font-size:13px}.audit-log-list.svelte-1nhcbov{flex-direction:column;gap:10px;display:flex}.settings-guardrails-list.svelte-1bvx512{min-width:0}.settings-guardrail-type-pill.svelte-1bvx512{border:1px solid color-mix(in srgb, var(--accent) 18%, var(--border));background:color-mix(in srgb, var(--accent) 12%, transparent);color:var(--text);white-space:nowrap;border-radius:999px;align-items:center;padding:6px 10px;font-size:12px;font-weight:600;display:inline-flex}.settings-guardrail-summary.svelte-1bvx512{color:var(--text);font-size:14px;line-height:1.45}.settings-guardrail-description.svelte-1bvx512{color:var(--text-muted);margin-top:6px;font-size:12px}.model-editor.guardrails-editor-wide{width:min(1080px,100%)}.form-field-fieldset.svelte-s964s3{border:0;min-inline-size:0;margin:0;padding:0}.form-field-legend.svelte-s964s3{color:var(--text-muted);letter-spacing:.5px;text-transform:uppercase;padding:0;font-size:12px;font-weight:600}.model-editor.settings-guardrails-editor{min-width:0}.settings-guardrails-hero.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));border-radius:var(--radius);background:radial-gradient(circle at top right, color-mix(in srgb, var(--accent-hover) 18%, transparent), transparent 42%), radial-gradient(circle at bottom left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 40%), var(--bg-surface);justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:20px;padding:24px;display:flex}.settings-kicker.svelte-5x874c{color:var(--accent);letter-spacing:.08em;text-transform:uppercase;margin:0 0 10px;font-size:11px;font-weight:700}.settings-guardrails-hero.svelte-5x874c h3{margin-bottom:8px}.settings-guardrails-hero.svelte-5x874c p:last-child{color:var(--text-muted);margin-bottom:0}.settings-guardrails-meta.svelte-5x874c{gap:12px;display:flex}.settings-guardrails-stat.svelte-5x874c{border:1px solid color-mix(in srgb, var(--accent) 14%, var(--border));background:color-mix(in srgb, var(--bg-surface-hover) 76%, transparent);border-radius:16px;min-width:110px;padding:14px 16px}.settings-guardrails-stat-label.svelte-5x874c{color:var(--text-muted);letter-spacing:.08em;text-transform:uppercase;margin-bottom:8px;font-size:11px;font-weight:700;display:block}.settings-guardrails-stat.svelte-5x874c strong{font-size:24px;font-weight:700}@media (width<=768px){.settings-guardrails-hero.svelte-5x874c{flex-direction:column}.settings-guardrails-meta.svelte-5x874c{width:100%}.settings-guardrails-stat.svelte-5x874c{flex:1 1 0}}.mcp-catalog-section.svelte-1xqrzco{margin-top:18px}.mcp-catalog-section.svelte-1xqrzco .form-field-label{margin-bottom:8px}.mcp-catalog-subtitle.svelte-1xqrzco{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.mcp-catalog-list.svelte-1xqrzco{flex-direction:column;gap:12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.mcp-catalog-item-name.svelte-1xqrzco{overflow-wrap:anywhere;font-size:13px}.mcp-catalog-item-aggregated.svelte-1xqrzco{color:var(--text-muted);overflow-wrap:anywhere;margin-top:2px;font-size:11px}.mcp-catalog-item-description.svelte-1xqrzco{color:var(--text-muted);margin:2px 0 0;font-size:13px;font-weight:400}.mcp-server-sub-counts.svelte-ah8nrt{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;max-width:280px;margin-top:4px;font-size:11px;overflow:hidden}.mcp-server-table-wrapper.svelte-ah8nrt{overflow-x:auto}.mcp-server-table-wrapper.svelte-ah8nrt .data-table{min-width:860px}.auth-key-form-fields.svelte-1gswxes>.form-field{margin-bottom:4px}.auth-key-dashboard-toggle.svelte-1gswxes{cursor:pointer;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-key-issued-banner.svelte-1gswxes{background:color-mix(in srgb, var(--success) 8%, var(--bg-surface));border:1px solid color-mix(in srgb, var(--success) 30%, var(--border));border-radius:var(--radius);margin-bottom:20px;padding:16px}.auth-key-issued-warning.svelte-1gswxes{color:color-mix(in srgb, var(--success) 80%, var(--text));margin-bottom:12px;font-size:13px;font-weight:600}.auth-key-issued-value-row.svelte-1gswxes{flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:12px;display:flex}.auth-key-issued-token.svelte-1gswxes{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);word-break:break-all;flex:1;min-width:0;padding:8px 12px;font-size:13px;overflow-x:auto}.usage-label-chip-static.svelte-nf0ldb,.usage-label-chip-static.svelte-nf0ldb:hover{cursor:default;background:color-mix(in srgb, var(--label-color,var(--accent)) 14%, var(--bg))}.auth-key-redacted.svelte-nf0ldb{color:var(--text-muted);font-size:13px}.auth-key-actions-cell.svelte-nf0ldb{white-space:nowrap}.auth-key-row-deactivated.svelte-nf0ldb td:where(.svelte-nf0ldb):not(.auth-key-actions-cell){opacity:.55}.auth-key-expiry.svelte-nf0ldb{white-space:nowrap;align-items:center;gap:8px;display:inline-flex}.auth-key-th-help.svelte-nf0ldb{cursor:help;align-items:center;gap:4px;display:inline-flex}.auth-key-row-actions.svelte-nf0ldb{align-items:center;gap:6px;display:inline-flex}.auth-keys-loading.svelte-1xpdcqx{justify-content:center;align-items:center;padding:32px 0;display:flex}.auth-keys-help-notice.svelte-1xpdcqx{margin-bottom:20px}.auth-keys-inactive-toggle.svelte-1xpdcqx{color:var(--text);cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;align-items:center;gap:8px;font-size:13px;display:inline-flex}.auth-keys-inactive-toggle.svelte-1xpdcqx input:where(.svelte-1xpdcqx){width:16px;height:16px;accent-color:var(--accent);cursor:pointer}.settings-panel-header.svelte-15kyv2y{justify-content:space-between;gap:16px;margin-bottom:20px;display:flex}.settings-panel-header.svelte-15kyv2y h3{font-size:18px}.settings-form-grid.svelte-15kyv2y{grid-template-columns:minmax(280px,420px);gap:16px;display:grid}@media (width<=768px){.settings-form-grid.svelte-15kyv2y{grid-template-columns:1fr}}.budget-settings-section.svelte-a747ys{width:100%}.budget-settings-grid.svelte-a747ys{gap:12px;display:grid}.budget-settings-row.svelte-a747ys{grid-template-columns:96px minmax(170px,1fr) minmax(110px,140px) minmax(110px,140px) minmax(220px,280px);align-items:start;gap:12px;display:grid}.budget-settings-period.svelte-a747ys{color:var(--text);letter-spacing:0;text-transform:uppercase;align-self:end;min-height:35px;padding-bottom:9px;font-size:12px;font-weight:700}.budget-settings-spacer.svelte-a747ys{min-height:1px}.budget-settings-help-cell.svelte-a747ys{align-self:start;min-width:0;min-height:35px}.budget-settings-help-cell.svelte-a747ys .inline-help-copy{max-width:280px;margin:22px 0 0;font-size:12px;line-height:1.35}@media (width<=768px){.budget-settings-grid.svelte-a747ys,.budget-settings-row.svelte-a747ys{grid-template-columns:1fr}.budget-settings-spacer.svelte-a747ys{display:none}}.tagging-settings-grid.svelte-18e8yem{gap:12px;display:grid}.tagging-settings-row.svelte-18e8yem{grid-template-columns:minmax(170px,1fr) minmax(150px,1fr) minmax(80px,110px) auto minmax(90px,auto);align-items:end;gap:12px;display:grid}.tagging-do-not-pass.svelte-18e8yem{color:var(--text);white-space:nowrap;align-items:center;gap:6px;min-height:35px;font-size:13px;display:flex}.tagging-row-trailer.svelte-18e8yem{align-items:center;gap:8px;min-height:35px;display:flex}.tagging-settings-empty.svelte-18e8yem{color:var(--text-muted);margin:0}.tagging-settings-actions.svelte-18e8yem{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.tagging-settings-row.svelte-18e8yem{grid-template-columns:1fr;align-items:stretch}.tagging-settings-actions.svelte-18e8yem,.tagging-settings-actions.svelte-18e8yem .btn{width:100%}}.pricing-recalculate-section.svelte-1cdxzyk{width:100%}.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:minmax(220px,320px) minmax(260px,360px);justify-content:start;align-items:end;gap:12px;width:100%;display:grid}.pricing-recalculate-date-field.svelte-1cdxzyk{grid-column:1/-1;width:100%;max-width:320px}.pricing-recalculate-filter-field.svelte-1cdxzyk{width:100%;max-width:360px}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker{width:100%}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-trigger{justify-content:space-between;width:100%}.pricing-recalculate-actions.svelte-1cdxzyk{flex-wrap:wrap;gap:10px;display:flex}@media (width<=768px){.pricing-recalculate-grid.svelte-1cdxzyk{grid-template-columns:1fr}.pricing-recalculate-actions.svelte-1cdxzyk,.pricing-recalculate-actions.svelte-1cdxzyk .btn{width:100%}}.pricing-recalculate-date-field.svelte-1cdxzyk .date-picker-dropdown{inset:auto auto calc(100% + 6px) 0}.settings-refresh-icon.svelte-yeq2mp{flex:0 0 16px;width:16px;height:16px}.runtime-refresh-steps.svelte-yeq2mp{color:var(--text-muted);gap:8px;margin-top:14px;padding-left:18px;font-size:13px;display:grid}.runtime-refresh-step.is-ok.svelte-yeq2mp{color:var(--success)}.runtime-refresh-step.is-partial.svelte-yeq2mp{color:var(--warning)}.runtime-refresh-step.is-failed.svelte-yeq2mp{color:var(--danger)}.runtime-settings-copy.svelte-tldbe5{min-width:180px}.runtime-settings-fields.svelte-tldbe5{gap:16px;width:min(560px,100%);display:grid}.runtime-setting-row.svelte-tldbe5{grid-template-columns:minmax(220px,1fr) 180px;align-items:center;gap:20px;display:grid}.runtime-setting-description.svelte-tldbe5,.runtime-setting-managed.svelte-tldbe5{color:var(--text-muted);margin:4px 0 0;font-size:12px}.runtime-setting-managed.svelte-tldbe5{color:var(--warning)}@media (width<=720px){.runtime-setting-row.svelte-tldbe5{grid-template-columns:1fr;gap:8px}}.settings-version-footer.svelte-3naq7u{color:var(--text-muted);text-align:right;margin-top:24px;font-size:12px}.chat-message.svelte-12s99s5{border:1px solid var(--border);background:var(--bg);border-radius:10px;max-width:94%;padding:10px 42px 10px 12px;position:relative;overflow:hidden}.chat-message.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border));box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent)}.chat-message.is-after-anchor.svelte-12s99s5,.chat-function-note.is-after-anchor.svelte-12s99s5{opacity:.46}.chat-message.role-user.svelte-12s99s5{align-self:flex-start}.chat-message.role-assistant.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 18%, var(--bg));align-self:flex-end}.chat-message.role-system.svelte-12s99s5{background:color-mix(in srgb, var(--warning) 10%, var(--bg));align-self:center;width:100%;max-width:100%}.chat-message.role-error.svelte-12s99s5{border-color:color-mix(in srgb, var(--danger) 55%, var(--border));background:color-mix(in srgb, var(--danger) 10%, var(--bg));align-self:flex-end}.chat-message.role-error.svelte-12s99s5 .chat-role:where(.svelte-12s99s5){color:color-mix(in srgb, var(--danger) 75%, var(--text-muted))}.chat-message-meta.svelte-12s99s5{justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:6px;display:flex}.chat-role.svelte-12s99s5{text-transform:uppercase;letter-spacing:.4px;color:var(--text-muted);font-size:12px;font-weight:700}.chat-time.svelte-12s99s5{color:var(--text-muted);white-space:nowrap;font-size:11px}.chat-content.svelte-12s99s5{white-space:pre-wrap;overflow-wrap:break-word;color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:13px;line-height:1.5}.chat-message.svelte-12s99s5:before,.chat-function-note.svelte-12s99s5:before{content:"";z-index:0;pointer-events:none;opacity:var(--prompt-cache-visibility);background:linear-gradient(90deg, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) 0, color-mix(in srgb, var(--prompt-cache-color) 18%, transparent) var(--prompt-cache-fill), transparent var(--prompt-cache-fill), transparent 100%);transition:opacity .15s;position:absolute;inset:0}.chat-message.svelte-12s99s5>:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5>:where(.svelte-12s99s5){z-index:1;position:relative}.chat-message-copy.svelte-12s99s5{z-index:2;border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 92%, transparent);width:26px;height:26px;color:var(--text-muted);opacity:0;pointer-events:none;border-radius:6px;justify-content:center;align-items:center;padding:0;transition:opacity .12s,transform .12s,color .12s,background-color .12s,border-color .12s;display:inline-flex;position:absolute;bottom:6px;right:6px;transform:translateY(3px)}.chat-message.svelte-12s99s5:hover .chat-message-copy:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5:hover .chat-message-copy:where(.svelte-12s99s5),.chat-message.svelte-12s99s5:focus-within .chat-message-copy:where(.svelte-12s99s5),.chat-function-note.svelte-12s99s5:focus-within .chat-message-copy:where(.svelte-12s99s5),.chat-message-copy.is-copied.svelte-12s99s5{opacity:1;pointer-events:auto;transform:translateY(0)}.chat-message-copy.svelte-12s99s5:hover{color:var(--text);background:var(--bg-surface-hover)}.chat-message-copy.svelte-12s99s5:focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 45%, transparent);outline-offset:1px}.chat-message-copy.is-copied.svelte-12s99s5{color:var(--success);border-color:color-mix(in srgb, var(--success) 45%, var(--border))}.chat-tool-calls.svelte-12s99s5{border-top:1px solid var(--border);flex-direction:column;gap:3px;margin-top:8px;padding-top:6px;display:flex}.chat-tool-call.svelte-12s99s5{color:var(--text-muted);border-radius:5px;min-width:0;padding:3px 5px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;position:relative;overflow:hidden}.chat-tool-call-summary.svelte-12s99s5{cursor:pointer;align-items:baseline;gap:6px;min-width:0;display:flex}.chat-tool-call-preview.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;opacity:.8;flex:1;min-width:0;overflow:hidden}.chat-tool-call-arguments.svelte-12s99s5{background:color-mix(in srgb, var(--border) 45%, transparent);color:var(--text);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;border-radius:6px;max-height:200px;margin-top:5px;padding:6px 8px;line-height:1.45;overflow:auto}.chat-tool-call-name.svelte-12s99s5:before{content:"⚡"}.chat-function-note.svelte-12s99s5{max-width:94%;color:var(--text-muted);background:color-mix(in srgb, var(--border) 40%, transparent);border:1px dashed var(--border);border-radius:12px;align-self:center;padding:4px 42px 4px 12px;font-size:12px;position:relative;overflow:hidden}.chat-function-note.is-anchor.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-inner.svelte-12s99s5{align-items:baseline;gap:6px;min-height:26px;display:flex;overflow:hidden}.chat-function-note-inner.svelte-12s99s5 .chat-time:where(.svelte-12s99s5){flex-shrink:0;margin-left:auto}.chat-function-call-id.svelte-12s99s5{color:var(--text-muted);overflow-wrap:anywhere;margin-top:6px;font-size:10px}.chat-function-label.svelte-12s99s5{text-transform:uppercase;letter-spacing:.3px;white-space:nowrap;flex-shrink:0;font-size:11px;font-weight:600}.chat-function-label.svelte-12s99s5:before{content:"▸";margin-right:4px;transition:transform .12s;display:inline-block}.chat-function-note-details[open].svelte-12s99s5 .chat-function-label:where(.svelte-12s99s5):before{transform:rotate(90deg)}.chat-function-detail.svelte-12s99s5{white-space:nowrap;text-overflow:ellipsis;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;overflow:hidden}.chat-function-note.role-function-call.svelte-12s99s5{background:color-mix(in srgb, var(--accent) 8%, transparent);border-color:color-mix(in srgb, var(--accent) 30%, var(--border));align-self:flex-end}.chat-function-note.role-function-result.svelte-12s99s5{background:color-mix(in srgb, var(--success) 8%, transparent);border-color:color-mix(in srgb, var(--success) 30%, var(--border));align-self:flex-start}.chat-function-note.is-anchor.role-function-call.svelte-12s99s5,.chat-function-note.is-anchor.role-function-result.svelte-12s99s5{border-color:color-mix(in srgb, var(--accent) 55%, var(--border))}.chat-function-note-details.svelte-12s99s5{width:100%}.chat-function-note-details.svelte-12s99s5>summary{cursor:pointer;list-style:none}.chat-function-note-details.svelte-12s99s5>summary::-webkit-details-marker{display:none}.chat-function-expanded.svelte-12s99s5{border-top:1px solid var(--border);white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text);max-height:200px;margin-top:6px;padding-top:6px;font-family:SF Mono,Menlo,Consolas,monospace;font-size:11px;line-height:1.45;overflow:auto}@media (width<=768px){.chat-message.svelte-12s99s5{max-width:100%}}@media (hover:none){.chat-message-copy.svelte-12s99s5{opacity:1;pointer-events:auto;transform:none}}@media (prefers-reduced-motion:reduce){.chat-message-copy.svelte-12s99s5{transition:none}}.conversation-drawer.svelte-ssrzja{width:var(--conversation-panel-width);background:var(--bg-surface);border-left:1px solid var(--border);z-index:12;flex-direction:column;flex:none;min-width:0;height:100vh;display:flex;position:sticky;top:0}.conversation-drawer-fullscreen.svelte-ssrzja{z-index:70;border-left:0;flex-basis:auto;width:100vw;height:100dvh;position:fixed;inset:0}.conversation-drawer-fullscreen.svelte-ssrzja .conversation-resize-handle:where(.svelte-ssrzja){display:none}.conversation-resize-handle.svelte-ssrzja{z-index:2;cursor:col-resize;touch-action:none;background:0 0;border:0;border-radius:0;outline:none;width:10px;padding:0;position:absolute;top:0;bottom:0;left:-5px}.conversation-resize-handle.svelte-ssrzja:after{content:"";background:0 0;width:2px;transition:background .15s;position:absolute;top:0;bottom:0;left:4px}.conversation-resize-handle.svelte-ssrzja:hover:after,.conversation-resize-handle.svelte-ssrzja:focus-visible:after{background:color-mix(in srgb, var(--accent) 70%, var(--border))}body.conversation-panel-resizing{cursor:col-resize;-webkit-user-select:none;user-select:none}.conversation-drawer-header.svelte-ssrzja{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:10px;padding:14px 16px;display:flex}.conversation-drawer-header-actions.svelte-ssrzja{align-items:center;gap:6px;display:flex}.conversation-drawer-title.svelte-ssrzja{align-items:center;gap:9px;min-width:0;display:flex}.conversation-follow-status.svelte-ssrzja{justify-content:center;align-items:center;margin:-4px;padding:4px;display:inline-flex}.conversation-drawer-header.svelte-ssrzja h3{font-size:16px;font-weight:700}#interactions-drawer-content.svelte-ssrzja{position:relative}.conversation-message-navigation.svelte-ssrzja{z-index:4;opacity:0;pointer-events:none;flex-direction:column;gap:4px;width:max-content;height:0;margin-left:auto;margin-right:12px;transition:opacity .12s,transform .12s;display:flex;position:sticky;top:12px;transform:translateY(-3px)}#interactions-drawer-content.svelte-ssrzja:hover .conversation-message-navigation:where(.svelte-ssrzja),.conversation-message-navigation.svelte-ssrzja:focus-within{opacity:1;pointer-events:auto;transform:translateY(0)}.conversation-message-navigation.svelte-ssrzja button:where(.svelte-ssrzja){border:1px solid var(--border);background:color-mix(in srgb, var(--bg-surface) 94%, transparent);width:30px;height:30px;min-height:30px;color:var(--text-muted);border-radius:6px;justify-content:center;align-items:center;padding:0;display:inline-flex;box-shadow:0 1px 3px #00000029}.conversation-message-navigation.svelte-ssrzja button:where(.svelte-ssrzja):hover{color:var(--text);background:var(--bg-surface-hover)}.conversation-message-navigation.svelte-ssrzja button:where(.svelte-ssrzja):focus-visible{outline:2px solid color-mix(in srgb, var(--accent) 45%, transparent);outline-offset:1px}.conversation-drawer-footer.svelte-ssrzja{border-top:1px solid var(--border);background:var(--bg-surface);flex-direction:column;flex-shrink:0;gap:9px;padding:10px 16px;display:flex}.conversation-composer.svelte-ssrzja{flex-direction:column;gap:7px;display:flex}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja){resize:vertical;border:1px solid var(--border);background:var(--bg);width:100%;min-height:50px;color:var(--text);font:inherit;border-radius:7px;padding:9px 10px;line-height:1.45}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):focus{outline:2px solid color-mix(in srgb, var(--accent) 38%, transparent);outline-offset:1px}.conversation-composer.svelte-ssrzja textarea:where(.svelte-ssrzja):disabled{opacity:.65}.conversation-composer-actions.svelte-ssrzja{justify-content:space-between;align-items:center;gap:10px;display:flex}.conversation-endpoint.svelte-ssrzja{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--text-muted);font-size:11px;overflow:hidden}.conversation-send-error.svelte-ssrzja{color:var(--danger);font-size:12px}.conversation-truncated.svelte-ssrzja{color:var(--text-muted);padding:0 16px 14px;font-size:12px}.conversation-cache-legend.svelte-ssrzja{color:var(--text-muted);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:7px;margin:12px 16px 0;padding:0;font-family:inherit;font-size:11px;display:flex}.conversation-cache-legend.svelte-ssrzja:hover{color:var(--text)}.conversation-cache-legend.svelte-ssrzja:focus-visible{outline:2px solid color-mix(in srgb, var(--prompt-cache-color) 35%, transparent);outline-offset:3px;border-radius:3px}.conversation-cache-switch.svelte-ssrzja{background:color-mix(in srgb, var(--text-muted) 30%, var(--border));border-radius:999px;flex:none;width:28px;height:16px;transition:background-color .15s;position:relative}.conversation-cache-switch.is-active.svelte-ssrzja{background:color-mix(in srgb, var(--prompt-cache-color) 80%, var(--bg))}.conversation-cache-switch-thumb.svelte-ssrzja{background:#fff;border-radius:50%;width:12px;height:12px;transition:transform .15s;position:absolute;top:2px;left:2px;box-shadow:0 1px 2px #0000003d}.conversation-cache-switch.is-active.svelte-ssrzja .conversation-cache-switch-thumb:where(.svelte-ssrzja){transform:translate(12px)}.conversation-cache-estimate.svelte-ssrzja{opacity:.75}.conversation-thread.svelte-ssrzja{flex-direction:column;gap:10px;padding:14px 16px 20px;display:flex}.conversation-live-status.svelte-ssrzja{color:var(--text-muted);align-items:center;gap:10px;padding:4px 16px 20px;font-size:13px;display:flex}@media (hover:none){.conversation-message-navigation.svelte-ssrzja{opacity:1;pointer-events:auto;transform:none}}@media (prefers-reduced-motion:reduce){.conversation-message-navigation.svelte-ssrzja{transition:none}} diff --git a/internal/admin/dashboard/static/dist/index.html b/internal/admin/dashboard/static/dist/index.html index 6186919c1..ae8f92c4f 100644 --- a/internal/admin/dashboard/static/dist/index.html +++ b/internal/admin/dashboard/static/dist/index.html @@ -7,8 +7,8 @@ GoModel Dashboard - - + +
                            diff --git a/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte b/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte index da5635538..cebc8426d 100644 --- a/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte +++ b/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte @@ -516,6 +516,7 @@ justify-content: center; width: 30px; height: 30px; + min-height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; From d073d8c359e63171d7fea4c82bd8b2e16c22a915 Mon Sep 17 00:00:00 2001 From: "Jakub A. W" Date: Fri, 7 Aug 2026 14:25:19 +0200 Subject: [PATCH 19/19] fix(dashboard): scroll past final interaction message --- .../{index-BDPZydjS.js => index-CaLK2wmu.js} | 2 +- .../admin/dashboard/static/dist/index.html | 2 +- .../audit-logs/ConversationDrawer.svelte | 17 ++++++---- .../pages/audit-logs/conversation-panel.js | 19 +++++++++-- .../tests/conversation-panel.test.js | 32 +++++++++++++++---- 5 files changed, 53 insertions(+), 19 deletions(-) rename internal/admin/dashboard/static/dist/assets/{index-BDPZydjS.js => index-CaLK2wmu.js} (98%) diff --git a/internal/admin/dashboard/static/dist/assets/index-BDPZydjS.js b/internal/admin/dashboard/static/dist/assets/index-CaLK2wmu.js similarity index 98% rename from internal/admin/dashboard/static/dist/assets/index-BDPZydjS.js rename to internal/admin/dashboard/static/dist/assets/index-CaLK2wmu.js index c0825612d..b839e043d 100644 --- a/internal/admin/dashboard/static/dist/assets/index-BDPZydjS.js +++ b/internal/admin/dashboard/static/dist/assets/index-CaLK2wmu.js @@ -65,4 +65,4 @@ the key. The master key always has dashboard access.`))},$$slots:{title:!0,help:!0}});var h=P(m,2),g=M(h);na(g),Ue(2),T(h),T(p),wE(P(p,2),{id:`auth-key-description`,label:`Description (optional)`,children:(e,t)=>{var n=iV();ft(n),da(n,()=>QB.form.description,e=>QB.form.description=e),z(e,n)},$$slots:{default:!0}}),T(t),da(i,()=>QB.form.name,e=>QB.form.name=e),da(o,()=>QB.form.expires_at,e=>QB.form.expires_at=e),da(l,()=>QB.form.user_path,e=>QB.form.user_path=e),da(f,()=>QB.form.labels,e=>QB.form.labels=e),fa(g,()=>QB.form.dashboard_access,e=>QB.form.dashboard_access=e),z(e,t)};V(r,e=>{QB.issuedValue?e(i):e(a,-1)}),z(e,n)},$$slots:{default:!0}})}D()}var sV=R(`

                            `),cV=R(`

                            Applies to new requests made with this key. Leave empty to remove all labels.

                            `,1);function lV(e,t){E(t,!0),SE(e,{get open(){return QB.labelsEditor.open},title:`Edit Labels`,ariaLabel:`API key labels editor`,get error(){return QB.labelsEditor.error},get submitting(){return QB.labelsEditor.submitting},submitLabel:`Save Labels`,cancel:!1,dialogClass:`auth-key-editor`,onclose:()=>QB.closeLabelsEditor(),onsubmit:()=>QB.submitLabelsEditor(),headerHint:e=>{var t=sV(),n=M(t,!0);T(t),F(()=>B(n,QB.labelsEditor.name)),z(e,t)},children:(e,t)=>{wE(e,{id:`auth-key-labels-edit`,label:`Labels (comma-separated)`,children:(e,t)=>{var n=cV(),r=N(n);na(r),Ue(2),da(r,()=>QB.labelsEditor.value,e=>QB.labelsEditor.value=e),z(e,n)},$$slots:{default:!0}})},$$slots:{headerHint:!0,default:!0}}),D()}var uV=R(` `),dV=R(`
                            `),fV=R(``),pV=R(`Expired`),mV=R(` `),hV=R(` `,1),gV=R(`Deactivated`),_V=R(`
                            `),vV=R(`
                            NameDescriptionUser PathLabelsTokenDashboard Access ExpiresCreated
                            `);function yV(e,t){E(t,!0);var n=vV(),r=M(n),i=M(r),a=M(i),o=P(M(a),5),s=M(o);K(P(M(s)),{get icon(){return no},width:`13`,height:`13`}),T(s),T(o),Ue(3),T(a),T(i);var c=P(i);H(c,21,()=>QB.visibleKeys,e=>e.id,(e,t)=>{var n=_V();let r;var i=M(n),a=M(i,!0);T(i);var o=P(i),s=M(o,!0);T(o);var c=P(o),l=M(c,!0);T(c);var u=P(c),d=M(u),f=e=>{var n=dV();H(n,20,()=>I(t).labels||[],e=>e,(e,t)=>{var n=uV(),r=M(n,!0);T(n),F(e=>{Hi(n,e),B(r,t)},[()=>Wy(t)]),z(e,n)}),T(n),z(e,n)},p=e=>{z(e,fV())};V(d,e=>{(I(t).labels||[]).length>0?e(f):e(p,-1)}),T(u);var m=P(u),h=M(m),g=M(h,!0);T(h),T(m);var _=P(m),v=M(_);let y;var b=M(v,!0);T(v),T(_);var x=P(_),S=M(x),C=e=>{var n=mV(),r=M(n),i=M(r,!0);T(r);var a=P(r,2),o=e=>{z(e,pV())},s=O(()=>VB(I(t)));V(a,e=>{I(s)&&e(o)}),T(n),F(e=>B(i,e),[()=>mc(I(t).expires_at)]),z(e,n)},w=e=>{z(e,Zr(`—`))};V(S,e=>{I(t).expires_at?e(C):e(w,-1)}),T(x);var ee=P(x),te=M(ee,!0);T(ee);var ne=P(ee),re=M(ne),ie=M(re),ae=e=>{var n=hV(),r=N(n);{let e=O(()=>(I(t).dashboard_access?`Revoke dashboard access for API key `:`Grant dashboard access to API key `)+I(t).name),n=O(()=>!!QB.dashboardAccessID);vT(r,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>QB.toggleDashboardAccess(I(t)),get disabled(){return I(n)},children:(e,n)=>{{let n=O(()=>I(t).dashboard_access?To:wo);K(e,{get icon(){return I(n)},class:`table-icon-svg`})}},$$slots:{default:!0}})}var i=P(r,2);{let e=O(()=>`Edit labels for API key `+I(t).name);vT(i,{get label(){return I(e)},class:`table-icon-btn`,onclick:()=>QB.openLabelsEditor(I(t)),children:(e,t)=>{K(e,{get icon(){return fo},class:`table-icon-svg`})},$$slots:{default:!0}})}var a=P(i,2);{let e=O(()=>(QB.deactivatingID===I(t).id?`Deactivating API key `:`Deactivate API key `)+I(t).name),n=O(()=>QB.deactivatingID===I(t).id);vT(a,{get label(){return I(e)},class:`table-action-btn-danger table-icon-btn`,onclick:()=>QB.deactivateKey(I(t)),get disabled(){return I(n)},children:(e,t)=>{K(e,{get icon(){return ho},class:`table-icon-svg`})},$$slots:{default:!0}})}z(e,n)},oe=e=>{var n=gV();F(e=>W(n,`title`,e),[()=>I(t).deactivated_at?`Deactivated on `+hc(I(t).deactivated_at):`Deactivated`]),z(e,n)},se=O(()=>HB(I(t)));V(ie,e=>{I(t).active?e(ae):I(se)&&e(oe,1)}),T(re),T(ne),T(n),F((e,i,o)=>{r=U(n,1,`svelte-nf0ldb`,null,r,e),B(a,I(t).name),B(s,I(t).description||`—`),B(l,I(t).user_path||`—`),B(g,I(t).redacted_value),y=U(v,1,`auth-key-status-badge`,null,y,{"auth-key-status-active":I(t).dashboard_access,"auth-key-status-inactive":!I(t).dashboard_access}),B(b,I(t).dashboard_access?`Allowed`:`Denied`),W(x,`title`,i),B(te,o)},[()=>({"auth-key-row-deactivated":HB(I(t))}),()=>I(t).expires_at?hc(I(t).expires_at):``,()=>fs.formatTimestamp(I(t).created_at)]),z(e,n)}),T(c),T(r),T(n),z(e,n),D()}var bV=R(``),xV=R(`
                            API key management is unavailable.
                            `),SV=R(``),CV=R(`

                            Managed API keys authenticate requests to the gateway. Deactivation is permanent — create a new key if access needs to be restored.

                            `),wV=R(`
                            `),TV=R(`
                            `),EV=R(`

                            `),DV=R(`

                            No API keys yet. Issue a key to get started.

                            `),OV=R(`
                            `);function kV(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`auth-keys`&&QB.fetchKeys()});var n=OV(),r=M(n),i=P(M(r),2),a=M(i),o=e=>{var t=bV();K(M(t),{get icon(){return mo},class:`table-icon-svg`}),Ue(2),T(t),F(()=>t.disabled=QB.formSubmitting),L(`click`,t,()=>{QB.formSubmitting||QB.openForm()}),z(e,t)};V(a,e=>{QB.available&&!q.authError&&e(o)}),T(i),T(r);var s=P(r,2),c=e=>{z(e,xV())};V(s,e=>{!QB.available&&!q.authError&&e(c)});var l=P(s,2),u=e=>{var t=SV(),n=M(t,!0);T(t),F(()=>B(n,QB.error)),z(e,t)};V(l,e=>{QB.error&&!q.authError&&!QB.formOpen&&e(u)});var d=P(l,2),f=e=>{z(e,CV())};V(d,e=>{QB.available&&!q.authError&&e(f)});var p=P(d,2);oV(p,{});var m=P(p,2);lV(m,{});var h=P(m,2),g=e=>{var t=wV();CS(M(t),{size:18,label:`Loading API keys`}),T(t),z(e,t)};V(h,e=>{QB.loading&&QB.keys.length===0&&e(g)});var _=P(h,2),v=e=>{var t=TV(),n=M(t);xw(M(n),{placeholder:`Filter by name, description, user path, label, or token...`,label:`Filter API keys by name, description, user path, label, or token`,get value(){return QB.filter},set value(e){QB.filter=e}}),T(n);var r=P(n,2),i=M(r),a=M(i);na(a);var o=P(a,2),s=P(M(o)),c=e=>{var t=Zr();F(()=>B(t,`(${QB.inactiveCount??``})`)),z(e,t)};V(s,e=>{QB.inactiveCount>0&&e(c)}),T(o),T(i),T(r),T(t),fa(a,()=>QB.showInactive,e=>QB.showInactive=e),z(e,t)};V(_,e=>{QB.keys.length>0&&QB.available&&e(v)});var y=P(_,2),b=e=>{yV(e,{})};V(y,e=>{QB.visibleKeys.length>0&&QB.available&&e(b)});var x=P(y,2),S=e=>{var t=EV(),n=M(t);T(t),F(()=>B(n,`No API keys match the current filter.${QB.inactiveCount>0&&!QB.showInactive?` `+QB.inactiveCount+` inactive `+(QB.inactiveCount===1?`key is`:`keys are`)+` hidden.`:``}`)),z(e,t)};V(x,e=>{QB.keys.length>0&&QB.visibleKeys.length===0&&QB.available&&e(S)});var C=P(x,2),w=e=>{z(e,DV())};V(C,e=>{QB.keys.length===0&&!QB.loading&&!q.authError&&!QB.error&&QB.available&&e(w)}),T(n),z(e,n),D()}Hr([`click`]);var AV=R(`

                            Timezone

                            `),jV=R(``),MV=R(``),NV=R(`
                            `,1);function PV(e,t){E(t,!0);function n(){fs.saveOverride(),q.refresh()}function r(){fs.clearOverride(),q.refresh()}var i=NV(),a=N(i);JS(M(a),{copyId:`timezone-help-copy`,label:`timezone help`,text:`Day-based analytics, charts, and date filters use your effective timezone. Usage and audit logs keep UTC in the hover title while rendering row timestamps in your effective timezone.`,title:e=>{z(e,AV())},$$slots:{title:!0}}),T(a);var o=P(a,2),s=M(o),c=P(M(s),2),l=M(c),u=M(l);T(l),l.value=l.__value=``,H(P(l),17,()=>fs.options,e=>e.value,(e,t)=>{var n=jV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(c),T(s),T(o);var d=P(o,2),f=M(d),p=e=>{var t=MV();L(`click`,t,r),z(e,t)};V(f,e=>{fs.override&&e(p)}),T(d),F(e=>B(u,`Automatic (${e??``})`),[()=>fs.detectedTimeZoneLabel()]),Vr(`focus`,c,()=>fs.ensureOptions()),L(`change`,c,n),Gi(c,()=>fs.override,e=>fs.override=e),z(e,i),D()}Hr([`change`,`click`]);var FV=R(``),IV=R(`

                            Failover

                            `,1);function LV(e,t){E(t,!0);let n=O(()=>Z.failoverSaving||Z.failoverGenerating||Z.failoverDraftSaving||!Z.failoverAvailable||!Z.failoverEnabled());var r=IV(),i=N(r),a=P(M(i),2),o=M(a),s=M(o);K(s,{get icon(){return Fo},class:`form-action-icon`});var c=P(s,2),l=M(c,!0);T(c),T(o);var u=P(o,2);K(M(u),{get icon(){return jo},class:`form-action-icon`}),Ue(2),T(u),T(a),T(i);var d=P(i,2),f=M(d),p=e=>{var t=FV(),n=M(t,!0);T(t),F(()=>B(n,Z.failoverError)),z(e,t)};V(f,e=>{Z.failoverError&&e(p)}),T(d),mj(P(d,2),{}),F(()=>{o.disabled=I(n),B(l,Z.failoverGenerating?`Generating...`:`Generate failover models automatically`),u.disabled=I(n)}),L(`click`,o,()=>Z.generateFailoverRules()),L(`click`,u,()=>Z.openFailoverResetDialog()),z(e,r),D()}Hr([`click`]);function RV(){return{daily_reset_hour:0,daily_reset_minute:0,weekly_reset_weekday:1,weekly_reset_hour:0,weekly_reset_minute:0,monthly_reset_day:1,monthly_reset_hour:0,monthly_reset_minute:0}}function zV(e,t){let n=t||{},r=(e,t)=>{if(e===``)return t;let n=Number(e);return Number.isFinite(n)&&Number.isInteger(n)?Math.trunc(n):t},i=(e,t)=>r(n[e],t),a=(t,n)=>e?r(e[t],n):n;return{daily_reset_hour:a(`daily_reset_hour`,i(`daily_reset_hour`,0)),daily_reset_minute:a(`daily_reset_minute`,i(`daily_reset_minute`,0)),weekly_reset_weekday:a(`weekly_reset_weekday`,i(`weekly_reset_weekday`,1)),weekly_reset_hour:a(`weekly_reset_hour`,i(`weekly_reset_hour`,0)),weekly_reset_minute:a(`weekly_reset_minute`,i(`weekly_reset_minute`,0)),monthly_reset_day:a(`monthly_reset_day`,i(`monthly_reset_day`,1)),monthly_reset_hour:a(`monthly_reset_hour`,i(`monthly_reset_hour`,0)),monthly_reset_minute:a(`monthly_reset_minute`,i(`monthly_reset_minute`,0))}}function BV(){return[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}]}var VV=R(`

                            Budget Resets

                            `),HV=R(``),UV=R(`

                            If the selected day does not exist in a month, the reset runs on the last day of that month.

                            `),WV=R(``),GV=R(``),KV=R(`
                            Monthly
                            Weekly
                            Daily
                            `,1);function qV(e,t){E(t,!0);let n=k(j(RV())),r=k(!1),i=k(!1),a=k(``),o=k(!1),s=O(()=>Cs.budgetsVisible());async function c(){if(await Cs.ensureLoaded(),!Cs.budgetsVisible()){A(a,``);return}A(r,!0),A(a,``);try{let e=await vs(`/admin/budgets/settings`,{label:`budget settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load budget settings.`);return}A(n,zV(e.data,I(n)),!0)}catch(e){console.error(`Failed to fetch budget settings:`,e),A(a,`Unable to load budget settings.`)}finally{A(r,!1)}}async function l(){if(!I(i)){A(i,!0);try{let e=await ys(`/admin/budgets/settings`,`PUT`,zV(I(n),I(n)),{label:`budget settings`});if(e.stale)return;if(!e.ok){J.error(`Unable to save budget settings.`);return}A(n,zV(e.data,I(n)),!0),A(a,``),J.success(`Budget settings saved.`)}catch(e){console.error(`Failed to save budget settings:`,e),J.error(`Unable to save budget settings.`)}finally{A(i,!1)}}}An(()=>{q.refreshTick,c()});var u=Qr(),d=N(u),f=e=>{var t=KV(),s=N(t),c=M(s);JS(c,{copyId:`budget-settings-help-copy`,label:`budget help`,text:`Budget reset anchors are stored in the database and evaluated in UTC. Hourly budgets reset at the top of each hour.`,title:e=>{z(e,VV())},$$slots:{title:!0}});var u=P(c,2),d=M(u),f=P(M(d),2),p=M(f);JS(p,{copyId:`budget-monthly-day-help-copy`,label:`day of month help`,external:!0,get open(){return I(o)},set open(e){A(o,e,!0)},title:e=>{z(e,HV())},$$slots:{title:!0}});var m=P(p,2);na(m),T(f);var h=P(f,2),g=P(M(h),2);na(g),T(h);var _=P(h,2),v=P(M(_),2);na(v),T(_);var y=P(_,2),b=M(y),x=e=>{z(e,UV())};V(b,e=>{I(o)&&e(x)}),T(y),T(d);var S=P(d,2),C=P(M(S),2),w=P(M(C),2);H(w,21,BV,e=>e.value,(e,t)=>{var n=WV(),r=M(n,!0);T(n);var i={};F(()=>{B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(w),T(C);var ee=P(C,2),te=P(M(ee),2);na(te),T(ee);var ne=P(ee,2),re=P(M(ne),2);na(re),T(ne),Ue(2),T(S);var ie=P(S,2),ae=P(M(ie),4),oe=P(M(ae),2);na(oe),T(ae);var se=P(ae,2),ce=P(M(se),2);na(ce),T(se),Ue(2),T(ie),T(u);var le=P(u,2),ue=M(le);K(M(ue),{get icon(){return vo},class:`form-action-icon`}),Ue(2),T(ue);var de=P(ue,2),fe=e=>{CS(e,{size:16,label:`Loading budget settings`})};V(de,e=>{I(r)&&e(fe)}),T(le),T(s);var pe=P(s,2),me=M(pe),he=e=>{var t=GV(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(me,e=>{I(a)&&e(he)}),T(pe),F(()=>{ue.disabled=I(i)||I(r),W(ue,`aria-busy`,I(i)?`true`:`false`)}),da(m,()=>I(n).monthly_reset_day,e=>I(n).monthly_reset_day=e),da(g,()=>I(n).monthly_reset_hour,e=>I(n).monthly_reset_hour=e),da(v,()=>I(n).monthly_reset_minute,e=>I(n).monthly_reset_minute=e),Gi(w,()=>I(n).weekly_reset_weekday,e=>I(n).weekly_reset_weekday=e),da(te,()=>I(n).weekly_reset_hour,e=>I(n).weekly_reset_hour=e),da(re,()=>I(n).weekly_reset_minute,e=>I(n).weekly_reset_minute=e),da(oe,()=>I(n).daily_reset_hour,e=>I(n).daily_reset_hour=e),da(ce,()=>I(n).daily_reset_minute,e=>I(n).daily_reset_minute=e),L(`click`,ue,l),z(e,t)};V(d,e=>{I(s)&&e(f)}),z(e,u),D()}Hr([`click`]);var JV=R(`

                            Reset All Budgets

                            Start new budget periods for every configured budget without changing - the limits.

                            `);function YV(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=JV(),n=P(M(t),2),r=M(n);K(M(r),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(r),T(n),T(t),F(()=>r.disabled=Y.resetAllLoading),L(`click`,r,()=>Y.openResetDialog()),z(e,t)},a=O(()=>Cs.budgetsVisible());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}Hr([`click`]);function XV(){return{header:``,prefix:``,do_not_pass:!1,delimiter:``,managed:!1}}function ZV(e){return(e&&Array.isArray(e.headers)?e.headers:[]).map(e=>({header:typeof e.header==`string`?e.header:``,prefix:typeof e.prefix==`string`?e.prefix:``,do_not_pass:e.do_not_pass===!0,delimiter:typeof e.delimiter==`string`&&e.delimiter!==`,`?e.delimiter:``,managed:e.managed===!0}))}function QV(e){return{headers:(Array.isArray(e)?e:[]).filter(e=>!e.managed&&e.header.trim()!==``).map(e=>({header:e.header.trim(),prefix:e.prefix,do_not_pass:e.do_not_pass,delimiter:e.delimiter}))}}function $V(e){return e&&e.error&&e.error.message?e.error.message:``}var eH=R(`

                            Tagging based on headers

                            `),tH=R(`config`),nH=R(``),rH=R(`
                            `),iH=R(`

                            No tagging headers configured. Requests are not labelled.

                            `),aH=R(``),oH=R(`
                            `,1);function sH(e,t){E(t,!0);let n=k(j([])),r=k(!0),i=k(!1),a=k(!1),o=k(``);function s(){I(n).push(XV())}function c(e){let t=I(n)[e];!t||t.managed||I(n).splice(e,1)}async function l(){A(i,!0),A(o,``);try{let e=await vs(`/admin/tagging/settings`,{label:`tagging settings`});if(e.stale)return;if(!e.ok){A(o,`Unable to load tagging settings.`);return}A(n,ZV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0)}catch(e){console.error(`Failed to fetch tagging settings:`,e),A(o,`Unable to load tagging settings.`)}finally{A(i,!1)}}async function u(){if(!(I(a)||!I(r))){A(a,!0);try{let e=await ys(`/admin/tagging/settings`,`PUT`,QV(I(n)),{label:`tagging settings`});if(e.stale)return;if(!e.ok){J.error(e.status!==401&&$V(e.data)||`Unable to save tagging settings.`);return}A(n,ZV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0),A(o,``),J.success(`Tagging settings saved.`)}catch(e){console.error(`Failed to save tagging settings:`,e),J.error(`Unable to save tagging settings.`)}finally{A(a,!1)}}}An(()=>{q.refreshTick,l()});var d=oH(),f=N(d),p=M(f);JS(p,{copyId:`tagging-settings-help-copy`,label:`tagging help`,text:`Each request is labelled from the listed headers; labels land in usage tracking and audit logs. A header value can carry several labels split by the delimiter (default: comma). The prefix is trimmed from each label only — the header itself is forwarded unchanged unless 'Do not pass' is checked. Rows marked CONFIG come from config.yaml or TAGGING_HEADER_* env vars and are read-only here.`,title:e=>{z(e,eH())},$$slots:{title:!0}});var m=P(p,2),h=M(m);H(h,17,()=>I(n),oi,(e,t,n)=>{var i=rH(),a=M(i),o=M(a);W(o,`for`,`tagging-header-`+n);var s=P(o,2);na(s),W(s,`id`,`tagging-header-`+n),T(a);var l=P(a,2),u=M(l);W(u,`for`,`tagging-prefix-`+n);var d=P(u,2);na(d),W(d,`id`,`tagging-prefix-`+n),T(l);var f=P(l,2),p=M(f);W(p,`for`,`tagging-delimiter-`+n);var m=P(p,2);na(m),W(m,`id`,`tagging-delimiter-`+n),T(f);var h=P(f,2),g=M(h);na(g),Ue(2),T(h);var _=P(h,2),v=M(_),y=e=>{z(e,tH())},b=e=>{var i=nH();F(()=>{i.disabled=!I(r),W(i,`aria-label`,`Remove tagging header `+(I(t).header||n+1))}),L(`click`,i,()=>c(n)),z(e,i)};V(v,e=>{I(t).managed?e(y):e(b,-1)}),T(_),T(i),F(()=>{s.disabled=I(t).managed||!I(r),d.disabled=I(t).managed||!I(r),m.disabled=I(t).managed||!I(r),g.disabled=I(t).managed||!I(r)}),da(s,()=>I(t).header,e=>I(t).header=e),da(d,()=>I(t).prefix,e=>I(t).prefix=e),da(m,()=>I(t).delimiter,e=>I(t).delimiter=e),fa(g,()=>I(t).do_not_pass,e=>I(t).do_not_pass=e),z(e,i)});var g=P(h,2),_=e=>{CS(e,{size:16,label:`Loading tagging settings`})};V(g,e=>{I(i)&&e(_)});var v=P(g,2),y=e=>{z(e,iH())};V(v,e=>{!I(i)&&I(n).length===0&&e(y)}),T(m);var b=P(m,2),x=M(b);K(M(x),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(x);var S=P(x,2);K(M(S),{get icon(){return vo},class:`form-action-icon`}),Ue(2),T(S),T(b),T(f);var C=P(f,2),w=M(C),ee=e=>{var t=aH(),n=M(t,!0);T(t),F(()=>B(n,I(o))),z(e,t)};V(w,e=>{I(o)&&e(ee)}),T(C),F(()=>{x.disabled=!I(r)||I(a)||I(i),S.disabled=!I(r)||I(a)||I(i),W(S,`aria-busy`,I(a)?`true`:`false`)}),L(`click`,x,s),L(`click`,S,u),z(e,d),D()}Hr([`click`]);function cH(e){let t=e||{};if(t.selectedPreset)return{days:parseInt(t.selectedPreset,10)||30};let n=t.customStartDate?pc(t.customStartDate):``,r=t.customEndDate||t.today||null;return{start_date:n,end_date:r?pc(r):``}}function lH(e,t,n,r){return{...cH(e),user_path:String(t||``).trim(),selector:String(n||``).trim(),confirmation:r}}function uH(e){let t=Number(e&&e.matched||0),n=Number(e&&e.recalculated||0),r=Number(e&&e.without_pricing||0),i=`Pricing recalculated for `+n+` of `+t+` usage record`+(t===1?``:`s`)+`.`;return r>0&&(i+=` `+r+` usage record`+(r===1?` still lacks`:`s still lack`)+` pricing metadata.`),i}var dH=R(`

                            Usage Pricing Recalculation

                            `),fH=R(`
                            `);function pH(e,t){E(t,!0);let n=k(``),r=k(``),i=k(!1),a=O(()=>Cs.booleanFlag(`USAGE_PRICING_RECALCULATION_ENABLED`,!1));function o(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}I(i)||zs.open({title:`Recalculate Pricing`,titleId:`pricingRecalculateDialogTitle`,inputId:`pricing-recalculate-confirmation`,requiredText:`recalculate`,confirmLabel:`Recalculate Pricing`,icon:La,dialogClass:`pricing-recalculate-dialog`,message:`Stored usage cost fields matching the selected filters will be overwritten.`,onConfirm:()=>s()})}async function s(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}if(!I(i)){A(i,!0);try{let e=await ys(`/admin/usage/recalculate-pricing`,`POST`,lH({selectedPreset:Nc.selectedPreset,customStartDate:Nc.customStartDate,customEndDate:Nc.customEndDate,today:fs.todayDate()},I(n),I(r),`recalculate`),{label:`pricing recalculation`});if(e.stale)return;if(!e.ok){zs.error=`Unable to recalculate pricing.`;return}zs.close(),J.success(uH(e.data)),zc.fetchUsage()}catch(e){console.error(`Failed to recalculate pricing:`,e),zs.error=`Unable to recalculate pricing.`}finally{A(i,!1)}}}var c=Qr(),l=N(c),u=e=>{var t=fH(),s=M(t);JS(s,{copyId:`pricing-recalculate-help-copy`,label:`pricing recalculation help`,text:`Recalculate stored input, output, total, and Pro Saved costs from the current model pricing metadata. This overwrites matching historical cost fields. Filters are applied to the selected date range, user path subtree, and provider/model selector or alias.`,title:e=>{z(e,dH())},$$slots:{title:!0}});var c=P(s,2),l=M(c),u=P(M(l),2);nl(M(u),{}),T(u),T(l);var d=P(l,2),f=P(M(d),2);na(f),T(d);var p=P(d,2),m=P(M(p),2);na(m),T(p),T(c);var h=P(c,2),g=M(h);K(M(g),{get icon(){return La},class:`form-action-icon`}),Ue(2),T(g),T(h),T(t),F(()=>{g.disabled=I(i)||!I(a),W(g,`aria-busy`,I(i)?`true`:`false`)}),da(f,()=>I(n),e=>A(n,e)),da(m,()=>I(r),e=>A(r,e)),L(`click`,g,o),z(e,t)};V(l,e=>{I(a)&&e(u)}),z(e,c),D()}Hr([`click`]);function mH(e){return String(e&&e.status||`ok`).toLowerCase()}function hH(e){if(!e||typeof e!=`object`)return`Runtime refresh completed.`;let t=Number(e.model_count||0),n=Number(e.provider_count||0),r=mH(e);return(r===`ok`?`Runtime refreshed.`:r===`partial`?`Runtime refresh completed with warnings.`:`Runtime refresh failed.`)+` `+t+` model`+(t===1?``:`s`)+` across `+n+` provider`+(n===1?``:`s`)+`.`}function gH(e){return!!e&&mH(e)===`ok`}function _H(e){let t=e&&e.steps;return Array.isArray(t)?t:[]}function vH(e){let t=String(e&&e.name||``).replace(/_/g,` `),n=String(e&&e.status||``).trim(),r=String(e&&(e.error||e.message)||``).trim();return t?r?t+`: `+n+` - `+r:t+`: `+n:r||n||``}var yH=R(`

                            Runtime Refresh

                            `),bH=R(`
                          • `),xH=R(`
                              `),SH=R(`
                              `,1);function CH(e,t){E(t,!0);let n=k(!1),r=k(null);async function i(){if(!I(n)){A(n,!0),A(r,null);try{let e=await ys(`/admin/runtime/refresh`,`POST`,void 0,{label:`runtime refresh`});if(e.stale)return;if(!e.ok){J.error(`Runtime refresh failed.`);return}A(r,e.data&&typeof e.data==`object`?e.data:null,!0),gH(I(r))?J.success(hH(I(r))):J.error(hH(I(r))),q.refresh()}catch(e){console.error(`Failed to refresh runtime:`,e),J.error(`Runtime refresh failed.`)}finally{A(n,!1)}}}var a=SH(),o=N(a),s=M(o);JS(s,{copyId:`runtime-refresh-help-copy`,label:`runtime refresh help`,text:`Pull the latest model metadata, provider inventory, API keys, aliases, model access rules, guardrails, and workflows.`,title:e=>{z(e,yH())},$$slots:{title:!0}});var c=P(s,2),l=M(c);let u;K(M(l),{get icon(){return go},class:`settings-refresh-icon`}),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=M(d),p=e=>{var t=xH();H(t,21,()=>_H(I(r)),e=>e.name,(e,t)=>{var n=bH(),r=M(n,!0);T(n),F(e=>{U(n,1,`runtime-refresh-step is-${I(t).status??``}`,`svelte-yeq2mp`),B(r,e)},[()=>vH(I(t))]),z(e,n)}),T(t),z(e,t)},m=O(()=>_H(I(r)).length>0);V(f,e=>{I(m)&&e(p)}),T(d),F(()=>{u=U(l,1,`btn btn-primary btn-with-icon settings-refresh-btn`,null,u,{"is-refreshing":I(n)}),l.disabled=I(n),W(l,`aria-busy`,I(n)?`true`:`false`)}),L(`click`,l,i),z(e,a),D()}Hr([`click`]);var wH=R(``),TH=R(`

                              `),EH=R(`

                              `),DH=R(``),OH=R(`
                              `),kH=R(`

                              AI Processing

                              `);function AH(e,t){E(t,!0);let n=k(j([])),r=k(!1),i=k(``),a=k(``);async function o(){A(r,!0),A(a,``);try{let e=await vs(`/admin/runtime/settings`,{label:`runtime settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load runtime settings.`);return}A(n,Array.isArray(e.data?.settings)?e.data.settings:[],!0)}catch(e){console.error(`Failed to load runtime settings:`,e),A(a,`Unable to load runtime settings.`)}finally{A(r,!1)}}async function s(e,t,r){if(!(e.locked||I(i))){A(i,e.key,!0);try{let i=await ys(`/admin/runtime/settings/${encodeURIComponent(e.key)}`,`PUT`,{value:t},{label:`save ${e.label}`});if(i.stale){r.value=e.value;return}if(!i.ok){r.value=e.value,J.error(`Unable to save ${e.label}.`);return}A(n,I(n).map(t=>t.key===e.key?i.data:t),!0),J.success(`${e.label} saved.`)}catch(t){r.value=e.value,console.error(`Failed to save runtime setting:`,t),J.error(`Unable to save ${e.label}.`)}finally{A(i,``)}}}An(()=>{q.refreshTick,o()});var c=Qr(),l=N(c),u=e=>{var t=kH(),o=M(t),c=P(M(o),2),l=e=>{var t=wH(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(c,e=>{I(a)&&e(l)}),T(o);var u=P(o,2);H(u,21,()=>I(n),e=>e.key,(e,t)=>{var n=OH(),r=M(n),a=M(r),o=M(a,!0);T(a);var c=P(a,2),l=e=>{var n=TH(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(c,e=>{I(t).description&&e(l)});var u=P(c,2),d=e=>{var n=EH(),r=M(n);T(n),F(()=>B(r,`Managed by ${(I(t).managed_by||`environment`)??``}`)),z(e,n)};V(u,e=>{I(t).locked&&e(d)}),T(r);var f=P(r,2);H(f,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=DH(),r=M(n,!0);T(n);var i={};F(()=>{W(n,`title`,I(t).description||``),B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(f);var p;Wi(f),T(n),F(()=>{W(a,`for`,`runtime-setting-${I(t).key}`),B(o,I(t).label),W(f,`id`,`runtime-setting-${I(t).key}`),f.disabled=I(t).locked||I(i)!==``,p!==(p=I(t).value)&&(f.value=(f.__value=I(t).value)??``,Ui(f,I(t).value))}),L(`change`,f,e=>s(I(t),e.currentTarget.value,e.currentTarget)),z(e,n)}),T(u),T(t),F(()=>W(u,`aria-busy`,I(r)?`true`:`false`)),z(e,t)};V(l,e=>{(I(n).length>0||I(a))&&e(u)}),z(e,c),D()}Hr([`change`]);var jH=R(`
                              `);function MH(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`settings`&&(fs.ensureOptions(),Cs.ensureLoaded())});var n=jH(),r=P(M(n),2),i=M(r);PV(i,{});var a=P(i,2);LV(a,{});var o=P(a,2);qV(o,{});var s=P(o,2);YV(s,{});var c=P(s,2);sH(c,{});var l=P(c,2);AH(l,{});var u=P(l,2);pH(u,{}),CH(P(u,2),{}),T(r);var d=P(r,2),f=M(d,!0);T(d),T(n),F(e=>B(f,e),[()=>Wo()]),z(e,n),D()}var NH=R(`
                              `),PH=R(`
                               
                              `),FH=R(`
                               
                              `),IH=R(`
                               
                              `),LH=R(`
                              `),RH=R(`
                              `,1),zH=R(`
                              `);function BH(e,t){E(t,!0);let n=G(t,`showPromptCache`,3,!0),r=yM({logPrefix:`Failed to copy interaction message:`}),i=O(()=>t.msg.role===`function_call`||t.msg.role===`function_result`);function a(e){return(Math.max(0,Math.min(1,Number(e||0)))*100).toFixed(1)+`%`}function o(e){let t=Math.max(0,Math.min(1,Number(e||0)));return t>0?Math.round(t*100)+`% of this visible prompt item is estimated provider-cached`:void 0}function s(e){return e.role===`function_call`?(e.toolCalls||[]).map(e=>e.name+`()`).join(`, `):(e.functionName?e.functionName+`: `:``)+e.text}var c=zH();let l;var u=M(c),d=e=>{var r=PH(),i=M(r),a=M(i),c=M(a,!0);T(a);var l=P(a,2),u=M(l,!0);T(l);var d=P(l,2),f=M(d,!0);T(d),T(i);var p=P(i,2),m=e=>{var n=NH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${t.msg.functionCallID??``}`)),z(e,n)};V(p,e=>{t.msg.functionCallID&&e(m)});var h=P(p,2),g=e=>{var n=Qr();H(N(n),17,()=>t.msg.toolCalls,oi,(e,n)=>{var r=Qr(),i=N(r),a=e=>{var r=NH(),i=M(r);T(r),F(()=>B(i,`Call ID${t.msg.toolCalls.length>1?` (`+I(n).name+`)`:``}: ${I(n).id??``}`)),z(e,r)};V(i,e=>{I(n).id&&e(a)}),z(e,r)}),z(e,n)};V(h,e=>{t.msg.role===`function_call`&&t.msg.toolCalls&&e(g)});var _=P(h,2),v=M(_,!0);T(_),T(r),F((e,n,i,a)=>{W(r,`title`,e),B(c,t.msg.roleLabel),B(u,n),B(f,i),B(v,a)},[()=>n()?o(t.msg.promptCacheRatio):void 0,()=>s(t.msg),()=>fs.formatTimestamp(t.msg.timestamp),()=>$I(t.msg)]),z(e,r)},f=e=>{var r=RH(),i=N(r),a=M(i),s=M(a,!0);T(a);var c=P(a,2),l=M(c,!0);T(c),T(i);var u=P(i,2),d=e=>{var r=FH(),i=M(r,!0);T(r),F(e=>{W(r,`title`,e),B(i,t.msg.text)},[()=>n()?o(t.msg.promptCacheRatio):void 0]),z(e,r)};V(u,e=>{t.msg.text&&e(d)});var f=P(u,2),p=e=>{var n=LH();H(n,23,()=>t.msg.toolCalls,(e,t)=>e.name+`-`+t,(e,t)=>{var n=IH(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(r);var c=P(r,2),l=e=>{var n=NH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${I(t).id??``}`)),z(e,n)};V(c,e=>{I(t).id&&e(l)});var u=P(c,2),d=M(u,!0);T(u),T(n),F((e,n)=>{B(a,I(t).name+`()`),B(s,e),B(d,n)},[()=>tL(I(t))||`No arguments`,()=>tL(I(t))||`No arguments`]),z(e,n)}),T(n),z(e,n)};V(f,e=>{t.msg.toolCalls&&e(p)}),F((e,n)=>{W(i,`title`,e),B(s,t.msg.roleLabel),B(l,n)},[()=>n()?o(t.msg.promptCacheRatio):void 0,()=>fs.formatTimestamp(t.msg.timestamp)]),z(e,r)};V(u,e=>{I(i)?e(d):e(f,-1)});var p=P(u,2);let m;var h=M(p);{let e=O(()=>r.copied?qa:Xa);K(h,{get icon(){return I(e)},width:`14`,height:`14`})}T(p),T(c),F(e=>{U(c,1,Fi([I(i)?`chat-function-note`:`chat-message`,t.msg.roleClass,{"is-anchor":t.msg.isAnchor,"is-after-anchor":t.msg.isAfterAnchor}]),`svelte-12s99s5`),W(c,`data-conversation-anchor`,t.msg.isAnchor?`true`:void 0),W(c,`data-entry-id`,t.msg.entryID),l=Hi(c,``,l,e),m=U(p,1,`chat-message-copy svelte-12s99s5`,null,m,{"is-copied":r.copied}),W(p,`aria-label`,r.copied?`Message copied`:`Copy message`),W(p,`title`,r.copied?`Copied`:`Copy message`)},[()=>({"--prompt-cache-fill":a(t.msg.promptCacheRatio),"--prompt-cache-visibility":n()&&t.msg.promptCacheRatio>0?`1`:`0`})]),L(`click`,p,e=>{e.stopPropagation(),r.copy(eL(t.msg))}),z(e,c),D()}Hr([`click`]);function VH(e,t=0){let n=Math.max(0,GH(e)-Math.max(0,GH(t))),r=Math.min(320,Math.max(180,Math.floor(n*.58))),i=Math.min(360,Math.max(128,Math.floor(n*.35)));return{min:r,max:Math.max(r,n-i)}}function HH(e,t,n=0){let r=VH(t,n),i=GH(e)||520;return Math.min(r.max,Math.max(r.min,Math.round(i)))}function UH(e,t,n=0){return HH(GH(t)-GH(e),t,n)}function WH(e,t,n){if(!Array.isArray(e)||e.length===0)return-1;let r=GH(t),i=0;e.forEach((e,t)=>{GH(e)<=r+1&&(i=t)});let a=Number(n)<0?-1:1;return Math.min(e.length-1,Math.max(0,i+a))}function GH(e){let t=Number(e);return Number.isFinite(t)?t:0}var KH=R(`
                              `),qH=R(`
                              `),JH=R(`

                              Loading interactions...

                              `),YH=R(`

                              No interaction data available for this entry.

                              `),XH=R(``),ZH=R(`
                              `,1),QH=R(`

                              Showing the newest part of this session and the selected log.

                              `),$H=R(`
                              `),eU=R(``),tU=R(``),nU=R(``);function rU(e,t){E(t,!0);let n=lL,r=Number(wa(`gomodel_interactions_panel_width`)),i=`gomodel_interactions_prompt_cache_fill`,a=Number.isFinite(r)&&r>0?r:520,o=k(j(a)),s=k(320),c=k(760),l=k(!1),u=k(!1),d=k(wa(i,`true`)!==`false`),f=null;function p(e,{fullscreen:t,revealWithoutSlide:n=!1}){let r=lP(180);return t?Js(e,{x:I(o),duration:r,easing:Zs}):n?{duration:0}:Ys(e,{axis:`x`,duration:r,easing:Zs})}async function m(e){if(e===I(l))return;let t=I(l)&&!e;A(u,t,!0),A(l,e,!0),t&&(await Cr(),A(u,!1))}function h(){A(d,!I(d)),Ta(i,I(d))}function g(){return(document.querySelector(`.sidebar`)?.getBoundingClientRect().width||0)+(document.querySelector(`.sidebar-toggle`)?.getBoundingClientRect().width||0)}function _(){let e=g(),t=VH(window.innerWidth,e);A(s,t.min,!0),A(c,t.max,!0),A(o,HH(a,window.innerWidth,e),!0)}function v(e){A(o,UH(e,window.innerWidth,g()),!0),a=I(o)}function y(e){e.button===0&&(e.preventDefault(),f=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`conversation-panel-resizing`),v(e.clientX))}function b(e){e.pointerId===f&&v(e.clientX)}function x(e){f===null||e.pointerId!==void 0&&e.pointerId!==f||(f=null,document.body.classList.remove(`conversation-panel-resizing`),Ta(`gomodel_interactions_panel_width`,a))}function S(e){e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a=I(o)+(e.key===`ArrowLeft`?24:-24),_(),a=I(o),Ta(`gomodel_interactions_panel_width`,a))}function C(e){let t=document.getElementById(`interactions-drawer-content`),r=n.conversationThreadEl;if(!t||!r)return;let i=[...r.querySelectorAll(`[data-conversation-message="true"]`)],a=t.getBoundingClientRect(),o=a.top+14,s=i[WH(i.map(e=>e.getBoundingClientRect().top),o,e)];if(!s)return;let c=t.scrollTop+s.getBoundingClientRect().top-a.top-14;t.scrollTo({top:c,behavior:lP(1)>0?`smooth`:`auto`})}function w(){return[document.querySelector(`.sidebar`),document.querySelector(`.sidebar-toggle`),document.getElementById(`dashboard-content`)].filter(Boolean)}An(()=>{if(!n.conversationOpen)return;_();let e=document.querySelector(`.sidebar`),t=new ResizeObserver(_);e&&t.observe(e);let r=e=>{e.key===`Escape`&&!Aa.anyOpen&&(I(l)?m(!1):n.closeConversation())};return window.addEventListener(`keydown`,r),window.addEventListener(`resize`,_),()=>{x({}),t.disconnect(),window.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,_)}}),An(()=>{n.conversationOpen||A(l,!1)}),An(()=>{if(!I(l))return;let e=w().map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));return e.forEach(({element:e})=>{e.inert=!0,e.setAttribute(`aria-hidden`,`true`)}),()=>{e.forEach(({element:e,inert:t,ariaHidden:n})=>{e.inert=t,n===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)})}}),An(()=>{Yo.page!==`audit-logs`&&n.conversationOpen&&n.closeConversation()});var ee=Qr(),te=N(ee),ne=e=>{var t=Qr();H(N(t),16,()=>[I(l)],e=>e,(e,t)=>{var r=nU();let i,a;var l=M(r),f=P(l,2),g=M(f),_=P(M(g),2),v=M(_);let w;T(_),T(g);var ee=P(g,2),te=M(ee),ne=M(te);{let e=O(()=>t?co:so);K(ne,{get icon(){return I(e)},class:`table-icon-svg`})}T(te),As(P(te,2),{label:`Close interactions`,onclick:()=>n.closeConversation(),get el(){return n.conversationCloseBtnEl},set el(e){n.conversationCloseBtnEl=e}}),T(ee),T(f);var re=P(f,2),ie=M(re),ae=e=>{var t=KH(),n=M(t);K(M(n),{get icon(){return Fa},width:`14`,height:`14`}),T(n);var r=P(n,2);K(M(r),{get icon(){return Ma},width:`14`,height:`14`}),T(r),T(t),L(`click`,n,()=>C(-1)),L(`click`,r,()=>C(1)),z(e,t)};V(ie,e=>{n.conversationMessages.length>1&&e(ae)});var oe=P(ie,2),se=e=>{var t=qH(),r=M(t,!0);T(t),F(()=>B(r,n.conversationError)),z(e,t)};V(oe,e=>{n.conversationError&&e(se)});var ce=P(oe,2),le=e=>{z(e,JH())};V(ce,e=>{n.conversationLoading&&e(le)});var ue=P(ce,2),de=e=>{z(e,YH())},fe=O(()=>!n.conversationLoading&&!n.followUpSending&&!n.conversationError&&n.conversationMessages.length===0&&!n.conversationLiveWaiting());V(ue,e=>{I(fe)&&e(de)});var pe=P(ue,2),me=e=>{var t=ZH(),r=N(t),i=e=>{var t=XH(),n=M(t);let r;Ue(2),T(t),F(()=>{W(t,`aria-checked`,I(d)),W(t,`title`,(I(d)?`Hide`:`Show`)+` estimated provider prompt-cache fill`),r=U(n,1,`conversation-cache-switch svelte-ssrzja`,null,r,{"is-active":I(d)})}),L(`click`,t,h),z(e,t)},a=O(()=>n.conversationMessages.some(e=>Number(e.promptCacheRatio||0)>0));V(r,e=>{I(a)&&e(i)});var o=P(r,2);H(o,21,()=>n.conversationMessages,e=>e.uid,(e,t)=>{BH(e,{get msg(){return I(t)},get showPromptCache(){return I(d)}})}),T(o),ga(o,e=>n.conversationThreadEl=e,()=>n?.conversationThreadEl),z(e,t)};V(pe,e=>{n.conversationMessages.length>0&&e(me)});var he=P(pe,2),ge=e=>{z(e,QH())};V(he,e=>{n.conversationTruncated&&e(ge)});var _e=P(he,2),ve=e=>{var t=$H(),r=P(M(t),2),i=M(r,!0);T(r),T(t),F(e=>B(i,e),[()=>n.conversationLiveStatusText()]),z(e,t)},ye=O(()=>n.conversationLiveWaiting());V(_e,e=>{I(ye)&&e(ve)}),T(re);var be=P(re,2),xe=e=>{var t=tU(),r=M(t),i=M(r);ft(i);var a=P(i,2),o=e=>{var t=eU(),r=M(t,!0);T(t),F(()=>B(r,n.followUpError)),z(e,t)};V(a,e=>{n.followUpError&&e(o)});var s=P(a,2),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u),T(s),T(r),T(t),F((e,t,r)=>{i.disabled=e,B(l,t),u.disabled=r,B(d,n.followUpSending?`Sending…`:`Send`)},[()=>n.followUpSending||n.conversationLiveWaiting(),()=>n.selectedConversationEntry()?.path||``,()=>!n.canSendFollowUp()]),Vr(`submit`,r,e=>{e.preventDefault(),n.sendFollowUp()}),da(i,()=>n.followUpText,e=>n.followUpText=e),z(e,t)},Se=O(()=>n.conversationAnchorID&&n.followUpKind());V(be,e=>{I(Se)&&e(xe)}),T(r),ga(r,e=>n.conversationDialogEl=e,()=>n?.conversationDialogEl),F(()=>{i=U(r,1,`conversation-drawer svelte-ssrzja`,null,i,{"conversation-drawer-fullscreen":t}),W(r,`role`,t?`dialog`:void 0),W(r,`aria-modal`,t?`true`:void 0),a=Hi(r,``,a,{"--conversation-panel-width":I(o)+`px`}),W(l,`aria-valuemin`,I(s)),W(l,`aria-valuemax`,I(c)),W(l,`aria-valuenow`,I(o)),W(_,`aria-label`,n.conversationFollowLatest?`Following the latest interaction`:`Viewing a historical interaction`),W(_,`title`,n.conversationFollowLatest?`Following the latest interaction as new events arrive`:`Viewing a historical interaction; live updates are not followed`),w=U(v,1,`live-dot`,null,w,{"is-streaming":n.conversationFollowLatest}),W(te,`aria-label`,t?`Exit fullscreen interactions`:`Show interactions fullscreen`),W(te,`title`,t?`Exit fullscreen`:`Fullscreen`),W(te,`aria-pressed`,t)}),L(`pointerdown`,l,y),L(`pointermove`,l,b),L(`pointerup`,l,x),Vr(`pointercancel`,l,x),Vr(`lostpointercapture`,l,x),L(`keydown`,l,S),L(`click`,te,()=>m(!t)),ki(7,r,()=>p,()=>({fullscreen:t,revealWithoutSlide:!t&&I(u)})),z(e,r)}),z(e,t)};V(te,e=>{n.conversationOpen&&e(ne)}),z(e,ee),D()}Hr([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`click`]);var iU=R(`
                              `,1);function aU(e,t){E(t,!0);let n={overview:vC,usage:mT,budgets:WE,"rate-limits":tO,models:Lj,workflows:iP,"audit-logs":eR,guardrails:qR,"mcp-servers":Dz,"providers-config":FB,"auth-keys":kV,settings:MH};fs.init(),Nc.init(),q.init(),Oa.init(),ka.init(),Yo.init(),An(()=>{q.refreshTick,Cs.fetch(),Pc.fetchModels(),Pc.fetchCategories()}),An(()=>{document.body.classList.toggle(`dashboard-modal-open`,Aa.anyOpen)});let r=O(()=>n[Yo.page]||vC);var i=iU(),a=N(i);Os(a,{});var o=P(a,2);let s;var c=M(o);ic(c,{}),_i(P(c,2),()=>I(r),(e,t)=>{t(e,{})}),T(o);var l=P(o,2);rU(l,{});var u=P(l,2);Ls(u,{});var d=P(u,2);Us(d,{}),nc(P(d,2),{}),F(()=>s=U(o,1,`content`,null,s,{"interactions-open":lL.conversationOpen})),z(e,i),D()}ti(aU,{target:document.getElementById(`app`)}); \ No newline at end of file + the limits.

                              `);function YV(e,t){E(t,!0);var n=Qr(),r=N(n),i=e=>{var t=JV(),n=P(M(t),2),r=M(n);K(M(r),{get icon(){return _o},class:`form-action-icon`}),Ue(2),T(r),T(n),T(t),F(()=>r.disabled=Y.resetAllLoading),L(`click`,r,()=>Y.openResetDialog()),z(e,t)},a=O(()=>Cs.budgetsVisible());V(r,e=>{I(a)&&e(i)}),z(e,n),D()}Hr([`click`]);function XV(){return{header:``,prefix:``,do_not_pass:!1,delimiter:``,managed:!1}}function ZV(e){return(e&&Array.isArray(e.headers)?e.headers:[]).map(e=>({header:typeof e.header==`string`?e.header:``,prefix:typeof e.prefix==`string`?e.prefix:``,do_not_pass:e.do_not_pass===!0,delimiter:typeof e.delimiter==`string`&&e.delimiter!==`,`?e.delimiter:``,managed:e.managed===!0}))}function QV(e){return{headers:(Array.isArray(e)?e:[]).filter(e=>!e.managed&&e.header.trim()!==``).map(e=>({header:e.header.trim(),prefix:e.prefix,do_not_pass:e.do_not_pass,delimiter:e.delimiter}))}}function $V(e){return e&&e.error&&e.error.message?e.error.message:``}var eH=R(`

                              Tagging based on headers

                              `),tH=R(`config`),nH=R(``),rH=R(`
                              `),iH=R(`

                              No tagging headers configured. Requests are not labelled.

                              `),aH=R(``),oH=R(`
                              `,1);function sH(e,t){E(t,!0);let n=k(j([])),r=k(!0),i=k(!1),a=k(!1),o=k(``);function s(){I(n).push(XV())}function c(e){let t=I(n)[e];!t||t.managed||I(n).splice(e,1)}async function l(){A(i,!0),A(o,``);try{let e=await vs(`/admin/tagging/settings`,{label:`tagging settings`});if(e.stale)return;if(!e.ok){A(o,`Unable to load tagging settings.`);return}A(n,ZV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0)}catch(e){console.error(`Failed to fetch tagging settings:`,e),A(o,`Unable to load tagging settings.`)}finally{A(i,!1)}}async function u(){if(!(I(a)||!I(r))){A(a,!0);try{let e=await ys(`/admin/tagging/settings`,`PUT`,QV(I(n)),{label:`tagging settings`});if(e.stale)return;if(!e.ok){J.error(e.status!==401&&$V(e.data)||`Unable to save tagging settings.`);return}A(n,ZV(e.data),!0),A(r,e.data&&e.data.editable!==!1,!0),A(o,``),J.success(`Tagging settings saved.`)}catch(e){console.error(`Failed to save tagging settings:`,e),J.error(`Unable to save tagging settings.`)}finally{A(a,!1)}}}An(()=>{q.refreshTick,l()});var d=oH(),f=N(d),p=M(f);JS(p,{copyId:`tagging-settings-help-copy`,label:`tagging help`,text:`Each request is labelled from the listed headers; labels land in usage tracking and audit logs. A header value can carry several labels split by the delimiter (default: comma). The prefix is trimmed from each label only — the header itself is forwarded unchanged unless 'Do not pass' is checked. Rows marked CONFIG come from config.yaml or TAGGING_HEADER_* env vars and are read-only here.`,title:e=>{z(e,eH())},$$slots:{title:!0}});var m=P(p,2),h=M(m);H(h,17,()=>I(n),oi,(e,t,n)=>{var i=rH(),a=M(i),o=M(a);W(o,`for`,`tagging-header-`+n);var s=P(o,2);na(s),W(s,`id`,`tagging-header-`+n),T(a);var l=P(a,2),u=M(l);W(u,`for`,`tagging-prefix-`+n);var d=P(u,2);na(d),W(d,`id`,`tagging-prefix-`+n),T(l);var f=P(l,2),p=M(f);W(p,`for`,`tagging-delimiter-`+n);var m=P(p,2);na(m),W(m,`id`,`tagging-delimiter-`+n),T(f);var h=P(f,2),g=M(h);na(g),Ue(2),T(h);var _=P(h,2),v=M(_),y=e=>{z(e,tH())},b=e=>{var i=nH();F(()=>{i.disabled=!I(r),W(i,`aria-label`,`Remove tagging header `+(I(t).header||n+1))}),L(`click`,i,()=>c(n)),z(e,i)};V(v,e=>{I(t).managed?e(y):e(b,-1)}),T(_),T(i),F(()=>{s.disabled=I(t).managed||!I(r),d.disabled=I(t).managed||!I(r),m.disabled=I(t).managed||!I(r),g.disabled=I(t).managed||!I(r)}),da(s,()=>I(t).header,e=>I(t).header=e),da(d,()=>I(t).prefix,e=>I(t).prefix=e),da(m,()=>I(t).delimiter,e=>I(t).delimiter=e),fa(g,()=>I(t).do_not_pass,e=>I(t).do_not_pass=e),z(e,i)});var g=P(h,2),_=e=>{CS(e,{size:16,label:`Loading tagging settings`})};V(g,e=>{I(i)&&e(_)});var v=P(g,2),y=e=>{z(e,iH())};V(v,e=>{!I(i)&&I(n).length===0&&e(y)}),T(m);var b=P(m,2),x=M(b);K(M(x),{get icon(){return mo},class:`form-action-icon`}),Ue(2),T(x);var S=P(x,2);K(M(S),{get icon(){return vo},class:`form-action-icon`}),Ue(2),T(S),T(b),T(f);var C=P(f,2),w=M(C),ee=e=>{var t=aH(),n=M(t,!0);T(t),F(()=>B(n,I(o))),z(e,t)};V(w,e=>{I(o)&&e(ee)}),T(C),F(()=>{x.disabled=!I(r)||I(a)||I(i),S.disabled=!I(r)||I(a)||I(i),W(S,`aria-busy`,I(a)?`true`:`false`)}),L(`click`,x,s),L(`click`,S,u),z(e,d),D()}Hr([`click`]);function cH(e){let t=e||{};if(t.selectedPreset)return{days:parseInt(t.selectedPreset,10)||30};let n=t.customStartDate?pc(t.customStartDate):``,r=t.customEndDate||t.today||null;return{start_date:n,end_date:r?pc(r):``}}function lH(e,t,n,r){return{...cH(e),user_path:String(t||``).trim(),selector:String(n||``).trim(),confirmation:r}}function uH(e){let t=Number(e&&e.matched||0),n=Number(e&&e.recalculated||0),r=Number(e&&e.without_pricing||0),i=`Pricing recalculated for `+n+` of `+t+` usage record`+(t===1?``:`s`)+`.`;return r>0&&(i+=` `+r+` usage record`+(r===1?` still lacks`:`s still lack`)+` pricing metadata.`),i}var dH=R(`

                              Usage Pricing Recalculation

                              `),fH=R(`
                              `);function pH(e,t){E(t,!0);let n=k(``),r=k(``),i=k(!1),a=O(()=>Cs.booleanFlag(`USAGE_PRICING_RECALCULATION_ENABLED`,!1));function o(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}I(i)||zs.open({title:`Recalculate Pricing`,titleId:`pricingRecalculateDialogTitle`,inputId:`pricing-recalculate-confirmation`,requiredText:`recalculate`,confirmLabel:`Recalculate Pricing`,icon:La,dialogClass:`pricing-recalculate-dialog`,message:`Stored usage cost fields matching the selected filters will be overwritten.`,onConfirm:()=>s()})}async function s(){if(!I(a)){J.error(`Usage pricing recalculation is unavailable.`);return}if(!I(i)){A(i,!0);try{let e=await ys(`/admin/usage/recalculate-pricing`,`POST`,lH({selectedPreset:Nc.selectedPreset,customStartDate:Nc.customStartDate,customEndDate:Nc.customEndDate,today:fs.todayDate()},I(n),I(r),`recalculate`),{label:`pricing recalculation`});if(e.stale)return;if(!e.ok){zs.error=`Unable to recalculate pricing.`;return}zs.close(),J.success(uH(e.data)),zc.fetchUsage()}catch(e){console.error(`Failed to recalculate pricing:`,e),zs.error=`Unable to recalculate pricing.`}finally{A(i,!1)}}}var c=Qr(),l=N(c),u=e=>{var t=fH(),s=M(t);JS(s,{copyId:`pricing-recalculate-help-copy`,label:`pricing recalculation help`,text:`Recalculate stored input, output, total, and Pro Saved costs from the current model pricing metadata. This overwrites matching historical cost fields. Filters are applied to the selected date range, user path subtree, and provider/model selector or alias.`,title:e=>{z(e,dH())},$$slots:{title:!0}});var c=P(s,2),l=M(c),u=P(M(l),2);nl(M(u),{}),T(u),T(l);var d=P(l,2),f=P(M(d),2);na(f),T(d);var p=P(d,2),m=P(M(p),2);na(m),T(p),T(c);var h=P(c,2),g=M(h);K(M(g),{get icon(){return La},class:`form-action-icon`}),Ue(2),T(g),T(h),T(t),F(()=>{g.disabled=I(i)||!I(a),W(g,`aria-busy`,I(i)?`true`:`false`)}),da(f,()=>I(n),e=>A(n,e)),da(m,()=>I(r),e=>A(r,e)),L(`click`,g,o),z(e,t)};V(l,e=>{I(a)&&e(u)}),z(e,c),D()}Hr([`click`]);function mH(e){return String(e&&e.status||`ok`).toLowerCase()}function hH(e){if(!e||typeof e!=`object`)return`Runtime refresh completed.`;let t=Number(e.model_count||0),n=Number(e.provider_count||0),r=mH(e);return(r===`ok`?`Runtime refreshed.`:r===`partial`?`Runtime refresh completed with warnings.`:`Runtime refresh failed.`)+` `+t+` model`+(t===1?``:`s`)+` across `+n+` provider`+(n===1?``:`s`)+`.`}function gH(e){return!!e&&mH(e)===`ok`}function _H(e){let t=e&&e.steps;return Array.isArray(t)?t:[]}function vH(e){let t=String(e&&e.name||``).replace(/_/g,` `),n=String(e&&e.status||``).trim(),r=String(e&&(e.error||e.message)||``).trim();return t?r?t+`: `+n+` - `+r:t+`: `+n:r||n||``}var yH=R(`

                              Runtime Refresh

                              `),bH=R(`
                            • `),xH=R(`
                                `),SH=R(`
                                `,1);function CH(e,t){E(t,!0);let n=k(!1),r=k(null);async function i(){if(!I(n)){A(n,!0),A(r,null);try{let e=await ys(`/admin/runtime/refresh`,`POST`,void 0,{label:`runtime refresh`});if(e.stale)return;if(!e.ok){J.error(`Runtime refresh failed.`);return}A(r,e.data&&typeof e.data==`object`?e.data:null,!0),gH(I(r))?J.success(hH(I(r))):J.error(hH(I(r))),q.refresh()}catch(e){console.error(`Failed to refresh runtime:`,e),J.error(`Runtime refresh failed.`)}finally{A(n,!1)}}}var a=SH(),o=N(a),s=M(o);JS(s,{copyId:`runtime-refresh-help-copy`,label:`runtime refresh help`,text:`Pull the latest model metadata, provider inventory, API keys, aliases, model access rules, guardrails, and workflows.`,title:e=>{z(e,yH())},$$slots:{title:!0}});var c=P(s,2),l=M(c);let u;K(M(l),{get icon(){return go},class:`settings-refresh-icon`}),Ue(2),T(l),T(c),T(o);var d=P(o,2),f=M(d),p=e=>{var t=xH();H(t,21,()=>_H(I(r)),e=>e.name,(e,t)=>{var n=bH(),r=M(n,!0);T(n),F(e=>{U(n,1,`runtime-refresh-step is-${I(t).status??``}`,`svelte-yeq2mp`),B(r,e)},[()=>vH(I(t))]),z(e,n)}),T(t),z(e,t)},m=O(()=>_H(I(r)).length>0);V(f,e=>{I(m)&&e(p)}),T(d),F(()=>{u=U(l,1,`btn btn-primary btn-with-icon settings-refresh-btn`,null,u,{"is-refreshing":I(n)}),l.disabled=I(n),W(l,`aria-busy`,I(n)?`true`:`false`)}),L(`click`,l,i),z(e,a),D()}Hr([`click`]);var wH=R(``),TH=R(`

                                `),EH=R(`

                                `),DH=R(``),OH=R(`
                                `),kH=R(`

                                AI Processing

                                `);function AH(e,t){E(t,!0);let n=k(j([])),r=k(!1),i=k(``),a=k(``);async function o(){A(r,!0),A(a,``);try{let e=await vs(`/admin/runtime/settings`,{label:`runtime settings`});if(e.stale)return;if(!e.ok){A(a,`Unable to load runtime settings.`);return}A(n,Array.isArray(e.data?.settings)?e.data.settings:[],!0)}catch(e){console.error(`Failed to load runtime settings:`,e),A(a,`Unable to load runtime settings.`)}finally{A(r,!1)}}async function s(e,t,r){if(!(e.locked||I(i))){A(i,e.key,!0);try{let i=await ys(`/admin/runtime/settings/${encodeURIComponent(e.key)}`,`PUT`,{value:t},{label:`save ${e.label}`});if(i.stale){r.value=e.value;return}if(!i.ok){r.value=e.value,J.error(`Unable to save ${e.label}.`);return}A(n,I(n).map(t=>t.key===e.key?i.data:t),!0),J.success(`${e.label} saved.`)}catch(t){r.value=e.value,console.error(`Failed to save runtime setting:`,t),J.error(`Unable to save ${e.label}.`)}finally{A(i,``)}}}An(()=>{q.refreshTick,o()});var c=Qr(),l=N(c),u=e=>{var t=kH(),o=M(t),c=P(M(o),2),l=e=>{var t=wH(),n=M(t,!0);T(t),F(()=>B(n,I(a))),z(e,t)};V(c,e=>{I(a)&&e(l)}),T(o);var u=P(o,2);H(u,21,()=>I(n),e=>e.key,(e,t)=>{var n=OH(),r=M(n),a=M(r),o=M(a,!0);T(a);var c=P(a,2),l=e=>{var n=TH(),r=M(n,!0);T(n),F(()=>B(r,I(t).description)),z(e,n)};V(c,e=>{I(t).description&&e(l)});var u=P(c,2),d=e=>{var n=EH(),r=M(n);T(n),F(()=>B(r,`Managed by ${(I(t).managed_by||`environment`)??``}`)),z(e,n)};V(u,e=>{I(t).locked&&e(d)}),T(r);var f=P(r,2);H(f,21,()=>I(t).options||[],e=>e.value,(e,t)=>{var n=DH(),r=M(n,!0);T(n);var i={};F(()=>{W(n,`title`,I(t).description||``),B(r,I(t).label),i!==(i=I(t).value)&&(n.value=(n.__value=I(t).value)??``)}),z(e,n)}),T(f);var p;Wi(f),T(n),F(()=>{W(a,`for`,`runtime-setting-${I(t).key}`),B(o,I(t).label),W(f,`id`,`runtime-setting-${I(t).key}`),f.disabled=I(t).locked||I(i)!==``,p!==(p=I(t).value)&&(f.value=(f.__value=I(t).value)??``,Ui(f,I(t).value))}),L(`change`,f,e=>s(I(t),e.currentTarget.value,e.currentTarget)),z(e,n)}),T(u),T(t),F(()=>W(u,`aria-busy`,I(r)?`true`:`false`)),z(e,t)};V(l,e=>{(I(n).length>0||I(a))&&e(u)}),z(e,c),D()}Hr([`change`]);var jH=R(`
                                `);function MH(e,t){E(t,!0),An(()=>{q.refreshTick,Yo.page===`settings`&&(fs.ensureOptions(),Cs.ensureLoaded())});var n=jH(),r=P(M(n),2),i=M(r);PV(i,{});var a=P(i,2);LV(a,{});var o=P(a,2);qV(o,{});var s=P(o,2);YV(s,{});var c=P(s,2);sH(c,{});var l=P(c,2);AH(l,{});var u=P(l,2);pH(u,{}),CH(P(u,2),{}),T(r);var d=P(r,2),f=M(d,!0);T(d),T(n),F(e=>B(f,e),[()=>Wo()]),z(e,n),D()}var NH=R(`
                                `),PH=R(`
                                 
                                `),FH=R(`
                                 
                                `),IH=R(`
                                 
                                `),LH=R(`
                                `),RH=R(`
                                `,1),zH=R(`
                                `);function BH(e,t){E(t,!0);let n=G(t,`showPromptCache`,3,!0),r=yM({logPrefix:`Failed to copy interaction message:`}),i=O(()=>t.msg.role===`function_call`||t.msg.role===`function_result`);function a(e){return(Math.max(0,Math.min(1,Number(e||0)))*100).toFixed(1)+`%`}function o(e){let t=Math.max(0,Math.min(1,Number(e||0)));return t>0?Math.round(t*100)+`% of this visible prompt item is estimated provider-cached`:void 0}function s(e){return e.role===`function_call`?(e.toolCalls||[]).map(e=>e.name+`()`).join(`, `):(e.functionName?e.functionName+`: `:``)+e.text}var c=zH();let l;var u=M(c),d=e=>{var r=PH(),i=M(r),a=M(i),c=M(a,!0);T(a);var l=P(a,2),u=M(l,!0);T(l);var d=P(l,2),f=M(d,!0);T(d),T(i);var p=P(i,2),m=e=>{var n=NH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${t.msg.functionCallID??``}`)),z(e,n)};V(p,e=>{t.msg.functionCallID&&e(m)});var h=P(p,2),g=e=>{var n=Qr();H(N(n),17,()=>t.msg.toolCalls,oi,(e,n)=>{var r=Qr(),i=N(r),a=e=>{var r=NH(),i=M(r);T(r),F(()=>B(i,`Call ID${t.msg.toolCalls.length>1?` (`+I(n).name+`)`:``}: ${I(n).id??``}`)),z(e,r)};V(i,e=>{I(n).id&&e(a)}),z(e,r)}),z(e,n)};V(h,e=>{t.msg.role===`function_call`&&t.msg.toolCalls&&e(g)});var _=P(h,2),v=M(_,!0);T(_),T(r),F((e,n,i,a)=>{W(r,`title`,e),B(c,t.msg.roleLabel),B(u,n),B(f,i),B(v,a)},[()=>n()?o(t.msg.promptCacheRatio):void 0,()=>s(t.msg),()=>fs.formatTimestamp(t.msg.timestamp),()=>$I(t.msg)]),z(e,r)},f=e=>{var r=RH(),i=N(r),a=M(i),s=M(a,!0);T(a);var c=P(a,2),l=M(c,!0);T(c),T(i);var u=P(i,2),d=e=>{var r=FH(),i=M(r,!0);T(r),F(e=>{W(r,`title`,e),B(i,t.msg.text)},[()=>n()?o(t.msg.promptCacheRatio):void 0]),z(e,r)};V(u,e=>{t.msg.text&&e(d)});var f=P(u,2),p=e=>{var n=LH();H(n,23,()=>t.msg.toolCalls,(e,t)=>e.name+`-`+t,(e,t)=>{var n=IH(),r=M(n),i=M(r),a=M(i,!0);T(i);var o=P(i,2),s=M(o,!0);T(o),T(r);var c=P(r,2),l=e=>{var n=NH(),r=M(n);T(n),F(()=>B(r,`Call ID: ${I(t).id??``}`)),z(e,n)};V(c,e=>{I(t).id&&e(l)});var u=P(c,2),d=M(u,!0);T(u),T(n),F((e,n)=>{B(a,I(t).name+`()`),B(s,e),B(d,n)},[()=>tL(I(t))||`No arguments`,()=>tL(I(t))||`No arguments`]),z(e,n)}),T(n),z(e,n)};V(f,e=>{t.msg.toolCalls&&e(p)}),F((e,n)=>{W(i,`title`,e),B(s,t.msg.roleLabel),B(l,n)},[()=>n()?o(t.msg.promptCacheRatio):void 0,()=>fs.formatTimestamp(t.msg.timestamp)]),z(e,r)};V(u,e=>{I(i)?e(d):e(f,-1)});var p=P(u,2);let m;var h=M(p);{let e=O(()=>r.copied?qa:Xa);K(h,{get icon(){return I(e)},width:`14`,height:`14`})}T(p),T(c),F(e=>{U(c,1,Fi([I(i)?`chat-function-note`:`chat-message`,t.msg.roleClass,{"is-anchor":t.msg.isAnchor,"is-after-anchor":t.msg.isAfterAnchor}]),`svelte-12s99s5`),W(c,`data-conversation-anchor`,t.msg.isAnchor?`true`:void 0),W(c,`data-entry-id`,t.msg.entryID),l=Hi(c,``,l,e),m=U(p,1,`chat-message-copy svelte-12s99s5`,null,m,{"is-copied":r.copied}),W(p,`aria-label`,r.copied?`Message copied`:`Copy message`),W(p,`title`,r.copied?`Copied`:`Copy message`)},[()=>({"--prompt-cache-fill":a(t.msg.promptCacheRatio),"--prompt-cache-visibility":n()&&t.msg.promptCacheRatio>0?`1`:`0`})]),L(`click`,p,e=>{e.stopPropagation(),r.copy(eL(t.msg))}),z(e,c),D()}Hr([`click`]);function VH(e,t=0){let n=Math.max(0,GH(e)-Math.max(0,GH(t))),r=Math.min(320,Math.max(180,Math.floor(n*.58))),i=Math.min(360,Math.max(128,Math.floor(n*.35)));return{min:r,max:Math.max(r,n-i)}}function HH(e,t,n=0){let r=VH(t,n),i=GH(e)||520;return Math.min(r.max,Math.max(r.min,Math.round(i)))}function UH(e,t,n=0){return HH(GH(t)-GH(e),t,n)}function WH(e,t,n,r){if(!Array.isArray(e)||e.length===0)return{index:-1,align:`start`};let i=GH(t),a=0;e.forEach((e,t)=>{GH(e)<=i+1&&(a=t)});let o=Number(r)<0?-1:1,s=Math.min(e.length-1,Math.max(0,a+o)),c=e.length-1,l=GH(e[c])0&&s===c&&l?`end`:`start`}}function GH(e){let t=Number(e);return Number.isFinite(t)?t:0}var KH=R(`
                                `),qH=R(`
                                `),JH=R(`

                                Loading interactions...

                                `),YH=R(`

                                No interaction data available for this entry.

                                `),XH=R(``),ZH=R(`
                                `,1),QH=R(`

                                Showing the newest part of this session and the selected log.

                                `),$H=R(`
                                `),eU=R(``),tU=R(``),nU=R(``);function rU(e,t){E(t,!0);let n=lL,r=Number(wa(`gomodel_interactions_panel_width`)),i=`gomodel_interactions_prompt_cache_fill`,a=Number.isFinite(r)&&r>0?r:520,o=k(j(a)),s=k(320),c=k(760),l=k(!1),u=k(!1),d=k(wa(i,`true`)!==`false`),f=null;function p(e,{fullscreen:t,revealWithoutSlide:n=!1}){let r=lP(180);return t?Js(e,{x:I(o),duration:r,easing:Zs}):n?{duration:0}:Ys(e,{axis:`x`,duration:r,easing:Zs})}async function m(e){if(e===I(l))return;let t=I(l)&&!e;A(u,t,!0),A(l,e,!0),t&&(await Cr(),A(u,!1))}function h(){A(d,!I(d)),Ta(i,I(d))}function g(){return(document.querySelector(`.sidebar`)?.getBoundingClientRect().width||0)+(document.querySelector(`.sidebar-toggle`)?.getBoundingClientRect().width||0)}function _(){let e=g(),t=VH(window.innerWidth,e);A(s,t.min,!0),A(c,t.max,!0),A(o,HH(a,window.innerWidth,e),!0)}function v(e){A(o,UH(e,window.innerWidth,g()),!0),a=I(o)}function y(e){e.button===0&&(e.preventDefault(),f=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),document.body.classList.add(`conversation-panel-resizing`),v(e.clientX))}function b(e){e.pointerId===f&&v(e.clientX)}function x(e){f===null||e.pointerId!==void 0&&e.pointerId!==f||(f=null,document.body.classList.remove(`conversation-panel-resizing`),Ta(`gomodel_interactions_panel_width`,a))}function S(e){e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a=I(o)+(e.key===`ArrowLeft`?24:-24),_(),a=I(o),Ta(`gomodel_interactions_panel_width`,a))}function C(e){let t=document.getElementById(`interactions-drawer-content`),r=n.conversationThreadEl;if(!t||!r)return;let i=[...r.querySelectorAll(`[data-conversation-message="true"]`)],a=t.getBoundingClientRect(),o=a.top+14,s=WH(i.map(e=>e.getBoundingClientRect().top),o,a.bottom,e),c=i[s.index];if(!c)return;let l=s.align===`end`?t.scrollHeight:t.scrollTop+c.getBoundingClientRect().top-a.top-14;t.scrollTo({top:l,behavior:lP(1)>0?`smooth`:`auto`})}function w(){return[document.querySelector(`.sidebar`),document.querySelector(`.sidebar-toggle`),document.getElementById(`dashboard-content`)].filter(Boolean)}An(()=>{if(!n.conversationOpen)return;_();let e=document.querySelector(`.sidebar`),t=new ResizeObserver(_);e&&t.observe(e);let r=e=>{e.key===`Escape`&&!Aa.anyOpen&&(I(l)?m(!1):n.closeConversation())};return window.addEventListener(`keydown`,r),window.addEventListener(`resize`,_),()=>{x({}),t.disconnect(),window.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,_)}}),An(()=>{n.conversationOpen||A(l,!1)}),An(()=>{if(!I(l))return;let e=w().map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));return e.forEach(({element:e})=>{e.inert=!0,e.setAttribute(`aria-hidden`,`true`)}),()=>{e.forEach(({element:e,inert:t,ariaHidden:n})=>{e.inert=t,n===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)})}}),An(()=>{Yo.page!==`audit-logs`&&n.conversationOpen&&n.closeConversation()});var ee=Qr(),te=N(ee),ne=e=>{var t=Qr();H(N(t),16,()=>[I(l)],e=>e,(e,t)=>{var r=nU();let i,a;var l=M(r),f=P(l,2),g=M(f),_=P(M(g),2),v=M(_);let w;T(_),T(g);var ee=P(g,2),te=M(ee),ne=M(te);{let e=O(()=>t?co:so);K(ne,{get icon(){return I(e)},class:`table-icon-svg`})}T(te),As(P(te,2),{label:`Close interactions`,onclick:()=>n.closeConversation(),get el(){return n.conversationCloseBtnEl},set el(e){n.conversationCloseBtnEl=e}}),T(ee),T(f);var re=P(f,2),ie=M(re),ae=e=>{var t=KH(),n=M(t);K(M(n),{get icon(){return Fa},width:`14`,height:`14`}),T(n);var r=P(n,2);K(M(r),{get icon(){return Ma},width:`14`,height:`14`}),T(r),T(t),L(`click`,n,()=>C(-1)),L(`click`,r,()=>C(1)),z(e,t)};V(ie,e=>{n.conversationMessages.length>1&&e(ae)});var oe=P(ie,2),se=e=>{var t=qH(),r=M(t,!0);T(t),F(()=>B(r,n.conversationError)),z(e,t)};V(oe,e=>{n.conversationError&&e(se)});var ce=P(oe,2),le=e=>{z(e,JH())};V(ce,e=>{n.conversationLoading&&e(le)});var ue=P(ce,2),de=e=>{z(e,YH())},fe=O(()=>!n.conversationLoading&&!n.followUpSending&&!n.conversationError&&n.conversationMessages.length===0&&!n.conversationLiveWaiting());V(ue,e=>{I(fe)&&e(de)});var pe=P(ue,2),me=e=>{var t=ZH(),r=N(t),i=e=>{var t=XH(),n=M(t);let r;Ue(2),T(t),F(()=>{W(t,`aria-checked`,I(d)),W(t,`title`,(I(d)?`Hide`:`Show`)+` estimated provider prompt-cache fill`),r=U(n,1,`conversation-cache-switch svelte-ssrzja`,null,r,{"is-active":I(d)})}),L(`click`,t,h),z(e,t)},a=O(()=>n.conversationMessages.some(e=>Number(e.promptCacheRatio||0)>0));V(r,e=>{I(a)&&e(i)});var o=P(r,2);H(o,21,()=>n.conversationMessages,e=>e.uid,(e,t)=>{BH(e,{get msg(){return I(t)},get showPromptCache(){return I(d)}})}),T(o),ga(o,e=>n.conversationThreadEl=e,()=>n?.conversationThreadEl),z(e,t)};V(pe,e=>{n.conversationMessages.length>0&&e(me)});var he=P(pe,2),ge=e=>{z(e,QH())};V(he,e=>{n.conversationTruncated&&e(ge)});var _e=P(he,2),ve=e=>{var t=$H(),r=P(M(t),2),i=M(r,!0);T(r),T(t),F(e=>B(i,e),[()=>n.conversationLiveStatusText()]),z(e,t)},ye=O(()=>n.conversationLiveWaiting());V(_e,e=>{I(ye)&&e(ve)}),T(re);var be=P(re,2),xe=e=>{var t=tU(),r=M(t),i=M(r);ft(i);var a=P(i,2),o=e=>{var t=eU(),r=M(t,!0);T(t),F(()=>B(r,n.followUpError)),z(e,t)};V(a,e=>{n.followUpError&&e(o)});var s=P(a,2),c=M(s),l=M(c,!0);T(c);var u=P(c,2),d=M(u,!0);T(u),T(s),T(r),T(t),F((e,t,r)=>{i.disabled=e,B(l,t),u.disabled=r,B(d,n.followUpSending?`Sending…`:`Send`)},[()=>n.followUpSending||n.conversationLiveWaiting(),()=>n.selectedConversationEntry()?.path||``,()=>!n.canSendFollowUp()]),Vr(`submit`,r,e=>{e.preventDefault(),n.sendFollowUp()}),da(i,()=>n.followUpText,e=>n.followUpText=e),z(e,t)},Se=O(()=>n.conversationAnchorID&&n.followUpKind());V(be,e=>{I(Se)&&e(xe)}),T(r),ga(r,e=>n.conversationDialogEl=e,()=>n?.conversationDialogEl),F(()=>{i=U(r,1,`conversation-drawer svelte-ssrzja`,null,i,{"conversation-drawer-fullscreen":t}),W(r,`role`,t?`dialog`:void 0),W(r,`aria-modal`,t?`true`:void 0),a=Hi(r,``,a,{"--conversation-panel-width":I(o)+`px`}),W(l,`aria-valuemin`,I(s)),W(l,`aria-valuemax`,I(c)),W(l,`aria-valuenow`,I(o)),W(_,`aria-label`,n.conversationFollowLatest?`Following the latest interaction`:`Viewing a historical interaction`),W(_,`title`,n.conversationFollowLatest?`Following the latest interaction as new events arrive`:`Viewing a historical interaction; live updates are not followed`),w=U(v,1,`live-dot`,null,w,{"is-streaming":n.conversationFollowLatest}),W(te,`aria-label`,t?`Exit fullscreen interactions`:`Show interactions fullscreen`),W(te,`title`,t?`Exit fullscreen`:`Fullscreen`),W(te,`aria-pressed`,t)}),L(`pointerdown`,l,y),L(`pointermove`,l,b),L(`pointerup`,l,x),Vr(`pointercancel`,l,x),Vr(`lostpointercapture`,l,x),L(`keydown`,l,S),L(`click`,te,()=>m(!t)),ki(7,r,()=>p,()=>({fullscreen:t,revealWithoutSlide:!t&&I(u)})),z(e,r)}),z(e,t)};V(te,e=>{n.conversationOpen&&e(ne)}),z(e,ee),D()}Hr([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`click`]);var iU=R(`
                                `,1);function aU(e,t){E(t,!0);let n={overview:vC,usage:mT,budgets:WE,"rate-limits":tO,models:Lj,workflows:iP,"audit-logs":eR,guardrails:qR,"mcp-servers":Dz,"providers-config":FB,"auth-keys":kV,settings:MH};fs.init(),Nc.init(),q.init(),Oa.init(),ka.init(),Yo.init(),An(()=>{q.refreshTick,Cs.fetch(),Pc.fetchModels(),Pc.fetchCategories()}),An(()=>{document.body.classList.toggle(`dashboard-modal-open`,Aa.anyOpen)});let r=O(()=>n[Yo.page]||vC);var i=iU(),a=N(i);Os(a,{});var o=P(a,2);let s;var c=M(o);ic(c,{}),_i(P(c,2),()=>I(r),(e,t)=>{t(e,{})}),T(o);var l=P(o,2);rU(l,{});var u=P(l,2);Ls(u,{});var d=P(u,2);Us(d,{}),nc(P(d,2),{}),F(()=>s=U(o,1,`content`,null,s,{"interactions-open":lL.conversationOpen})),z(e,i),D()}ti(aU,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/admin/dashboard/static/dist/index.html b/internal/admin/dashboard/static/dist/index.html index ae8f92c4f..601ed55f8 100644 --- a/internal/admin/dashboard/static/dist/index.html +++ b/internal/admin/dashboard/static/dist/index.html @@ -7,7 +7,7 @@ GoModel Dashboard - + diff --git a/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte b/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte index cebc8426d..9612b8def 100644 --- a/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte +++ b/web/dashboard/src/pages/audit-logs/ConversationDrawer.svelte @@ -16,7 +16,7 @@ import { DEFAULT_CONVERSATION_PANEL_WIDTH, clampConversationPanelWidth, - conversationMessageNavigationIndex, + conversationMessageNavigationTarget, conversationPanelBounds, conversationPanelWidthFromPointer, } from "./conversation-panel.js"; @@ -125,17 +125,20 @@ const messages = [...thread.querySelectorAll('[data-conversation-message="true"]')]; const contentRect = content.getBoundingClientRect(); const contentTop = contentRect.top + 14; - const index = conversationMessageNavigationIndex( + const navigation = conversationMessageNavigationTarget( messages.map((message) => message.getBoundingClientRect().top), contentTop, + contentRect.bottom, direction, ); - const target = messages[index]; + const target = messages[navigation.index]; if (!target) return; - const targetTop = content.scrollTop - + target.getBoundingClientRect().top - - contentRect.top - - 14; + const targetTop = navigation.align === "end" + ? content.scrollHeight + : content.scrollTop + + target.getBoundingClientRect().top + - contentRect.top + - 14; content.scrollTo({ top: targetTop, behavior: motionDuration(1) > 0 ? "smooth" : "auto", diff --git a/web/dashboard/src/pages/audit-logs/conversation-panel.js b/web/dashboard/src/pages/audit-logs/conversation-panel.js index a05a76236..d3c216edc 100644 --- a/web/dashboard/src/pages/audit-logs/conversation-panel.js +++ b/web/dashboard/src/pages/audit-logs/conversation-panel.js @@ -24,15 +24,28 @@ export function conversationPanelWidthFromPointer(clientX, viewportWidth, leadin ); } -export function conversationMessageNavigationIndex(messageTops, viewportTop, direction) { - if (!Array.isArray(messageTops) || messageTops.length === 0) return -1; +export function conversationMessageNavigationTarget( + messageTops, + viewportTop, + viewportBottom, + direction, +) { + if (!Array.isArray(messageTops) || messageTops.length === 0) { + return { index: -1, align: "start" }; + } const top = finite(viewportTop); let current = 0; messageTops.forEach((messageTop, index) => { if (finite(messageTop) <= top + 1) current = index; }); const step = Number(direction) < 0 ? -1 : 1; - return Math.min(messageTops.length - 1, Math.max(0, current + step)); + const index = Math.min(messageTops.length - 1, Math.max(0, current + step)); + const lastIndex = messageTops.length - 1; + const lastMessageVisible = finite(messageTops[lastIndex]) < finite(viewportBottom); + return { + index, + align: step > 0 && index === lastIndex && lastMessageVisible ? "end" : "start", + }; } function finite(value) { diff --git a/web/dashboard/tests/conversation-panel.test.js b/web/dashboard/tests/conversation-panel.test.js index b34dd4600..708c74d38 100644 --- a/web/dashboard/tests/conversation-panel.test.js +++ b/web/dashboard/tests/conversation-panel.test.js @@ -3,7 +3,7 @@ import assert from "node:assert/strict"; import { clampConversationPanelWidth, - conversationMessageNavigationIndex, + conversationMessageNavigationTarget, conversationPanelBounds, conversationPanelWidthFromPointer, } from "../src/pages/audit-logs/conversation-panel.js"; @@ -35,10 +35,28 @@ test("panel bounds stay continuous across the former compact breakpoint", () => test("message navigation steps from the message nearest the viewport top", () => { const tops = [-80, 40, 180, 320]; - assert.equal(conversationMessageNavigationIndex(tops, 20, 1), 1); - assert.equal(conversationMessageNavigationIndex(tops, 20, -1), 0); - assert.equal(conversationMessageNavigationIndex(tops, 185, 1), 3); - assert.equal(conversationMessageNavigationIndex(tops, 185, -1), 1); - assert.equal(conversationMessageNavigationIndex(tops, -100, -1), 0); - assert.equal(conversationMessageNavigationIndex(tops, 400, 1), 3); + assert.deepEqual(conversationMessageNavigationTarget(tops, 20, 300, 1), { + index: 1, + align: "start", + }); + assert.deepEqual(conversationMessageNavigationTarget(tops, 20, 300, -1), { + index: 0, + align: "start", + }); + assert.deepEqual(conversationMessageNavigationTarget(tops, 185, 300, 1), { + index: 3, + align: "start", + }); + assert.deepEqual(conversationMessageNavigationTarget(tops, 185, 400, 1), { + index: 3, + align: "end", + }); + assert.deepEqual(conversationMessageNavigationTarget(tops, 185, 400, -1), { + index: 1, + align: "start", + }); + assert.deepEqual(conversationMessageNavigationTarget(tops, 400, 500, 1), { + index: 3, + align: "end", + }); });