llm-simple-router 0.10.13 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/config/model-directory.json +1 -0
  2. package/config/recommended-providers.json +6 -5
  3. package/dist/admin/groups.js +25 -0
  4. package/dist/admin/monitor.js +15 -6
  5. package/dist/admin/providers.js +22 -3
  6. package/dist/admin/recommended.js +13 -1
  7. package/dist/config/model-context.d.ts +12 -0
  8. package/dist/config/model-context.js +96 -2
  9. package/dist/config/model-directory.json +1 -0
  10. package/dist/config/recommended-providers.json +355 -0
  11. package/dist/config/recommended-retry-rules.json +12 -0
  12. package/dist/config/recommended.d.ts +2 -0
  13. package/dist/config/version.json +1 -0
  14. package/dist/core/monitor/request-tracker.d.ts +1 -1
  15. package/dist/core/monitor/request-tracker.js +2 -1
  16. package/dist/core/monitor/types.d.ts +1 -0
  17. package/dist/core/types.d.ts +1 -0
  18. package/dist/index.js +17 -1
  19. package/dist/metrics/metrics-extractor.js +3 -0
  20. package/dist/proxy/handler/create-proxy-handler.js +15 -0
  21. package/dist/proxy/handler/failover-loop.js +88 -63
  22. package/dist/proxy/pipeline-snapshot.d.ts +9 -1
  23. package/dist/proxy/proxy-logging.js +2 -2
  24. package/dist/proxy/routing/modality-redirect.d.ts +22 -0
  25. package/dist/proxy/routing/modality-redirect.js +252 -0
  26. package/dist/proxy/routing/overflow.d.ts +11 -0
  27. package/dist/proxy/routing/overflow.js +24 -0
  28. package/dist/proxy/transform/plugin-registry.js +1 -1
  29. package/dist/proxy/transform/stream-oa2ant.js +3 -0
  30. package/dist/proxy/transport/http.js +6 -0
  31. package/dist/proxy/transport/proxy-agent.js +20 -8
  32. package/dist/proxy/transport/stream.js +8 -1
  33. package/dist/proxy/transport/transport-fn.js +12 -0
  34. package/frontend-dist/assets/CardContent-yiYaxAko.js +1 -0
  35. package/frontend-dist/assets/CardTitle-CzqSlrtn.js +1 -0
  36. package/frontend-dist/assets/Checkbox-2voapLgE.js +1 -0
  37. package/frontend-dist/assets/CollapsibleContent-DHkVSWt2.js +1 -0
  38. package/frontend-dist/assets/CollapsibleTrigger-DbVCeTdD.js +1 -0
  39. package/frontend-dist/assets/Dashboard-xT1CEwOR.js +3 -0
  40. package/frontend-dist/assets/{Input-Ey_q_5_r.js → Input-DEfnoFS3.js} +1 -1
  41. package/frontend-dist/assets/Label-CjUuzGNQ.js +1 -0
  42. package/frontend-dist/assets/Login-CJDEk-tO.js +1 -0
  43. package/frontend-dist/assets/Logs-CzdPCIYV.js +1 -0
  44. package/frontend-dist/assets/MappingEntryEditor-GejG6FYv.js +1 -0
  45. package/frontend-dist/assets/ModelCard-DdQtySPM.js +1 -0
  46. package/frontend-dist/assets/ModelMappings-DffY7Izx.js +1 -0
  47. package/frontend-dist/assets/Monitor-y6d6LInm.js +1 -0
  48. package/frontend-dist/assets/Providers-Cb-CB1yf.js +1 -0
  49. package/frontend-dist/assets/ProxyEnhancement-CywRxDop.js +1 -0
  50. package/frontend-dist/assets/QuickSetup-Nj_ysAdc.js +1 -0
  51. package/frontend-dist/assets/RetryRules-DRdeZUPt.js +1 -0
  52. package/frontend-dist/assets/RouterKeys-BHOhDgXZ.js +1 -0
  53. package/frontend-dist/assets/RovingFocusItem-NxZWBEpr.js +1 -0
  54. package/frontend-dist/assets/Schedules-C4jRCbnI.js +1 -0
  55. package/frontend-dist/assets/Settings-Cn0qnqMY.js +6 -0
  56. package/frontend-dist/assets/Setup-BjN6KU0y.js +1 -0
  57. package/frontend-dist/assets/Switch-bk3eQSZ_.js +1 -0
  58. package/frontend-dist/assets/TooltipTrigger-DmYucHtv.js +1 -0
  59. package/frontend-dist/assets/TransformRulesForm-Bo-zFABv.js +1 -0
  60. package/frontend-dist/assets/UnifiedRequestDialog-5-vBmVMH.js +3 -0
  61. package/frontend-dist/assets/VisuallyHiddenInput-BflIWQCW.js +1 -0
  62. package/frontend-dist/assets/{button-C7HO6Dyb.js → button-DZwflOXO.js} +2 -2
  63. package/frontend-dist/assets/{copy-DxwFlq2A.js → copy-zQQvOqam.js} +1 -1
  64. package/frontend-dist/assets/dialog-C7v6Gaak.js +1 -0
  65. package/frontend-dist/assets/index-ClQS69Or.css +1 -0
  66. package/frontend-dist/assets/index-PMAQyWJb.js +3 -0
  67. package/frontend-dist/assets/mappings-BpkOqnsu.js +1 -0
  68. package/frontend-dist/assets/mappings-D7Qy46v_.js +1 -0
  69. package/frontend-dist/assets/{providers-Bcea72GK.js → providers-BI5dO-j0.js} +1 -1
  70. package/frontend-dist/assets/{providers-DNICB6Kg.js → providers-BzxbZ85B.js} +1 -1
  71. package/frontend-dist/assets/{trash-2-D2SrfECO.js → trash-2-CrcHK-G_.js} +1 -1
  72. package/frontend-dist/assets/{useClipboard-CttzUerj.js → useClipboard-B4K3eogm.js} +1 -1
  73. package/frontend-dist/assets/{useLogRetention-Dv0deAan.js → useLogRetention-BNbFXLBO.js} +1 -1
  74. package/frontend-dist/index.html +3 -3
  75. package/package.json +2 -2
  76. package/frontend-dist/assets/CardContent-DfVo-N85.js +0 -1
  77. package/frontend-dist/assets/CardTitle-npwJSAlz.js +0 -1
  78. package/frontend-dist/assets/Checkbox-Ddnzkh_i.js +0 -1
  79. package/frontend-dist/assets/CollapsibleContent-BTVazeoQ.js +0 -1
  80. package/frontend-dist/assets/CollapsibleTrigger-DCQeyHrt.js +0 -1
  81. package/frontend-dist/assets/Dashboard-DjnImtwH.js +0 -3
  82. package/frontend-dist/assets/Label-Dw5HcYsL.js +0 -1
  83. package/frontend-dist/assets/Login-CSrfhhm9.js +0 -1
  84. package/frontend-dist/assets/Logs-HR1DZs1M.js +0 -1
  85. package/frontend-dist/assets/MappingEntryEditor-C9pgNL0Q.js +0 -1
  86. package/frontend-dist/assets/ModelCard-IQMwlnCm.js +0 -1
  87. package/frontend-dist/assets/ModelMappings-kRx-GL_7.js +0 -1
  88. package/frontend-dist/assets/Monitor-y1ofDNK7.js +0 -1
  89. package/frontend-dist/assets/Providers-C1bP2PoM.js +0 -1
  90. package/frontend-dist/assets/ProxyEnhancement-DQx4coxn.js +0 -1
  91. package/frontend-dist/assets/QuickSetup-DHX9-CnO.js +0 -1
  92. package/frontend-dist/assets/RetryRules-zdJE0bFL.js +0 -1
  93. package/frontend-dist/assets/RouterKeys-CD0rI4kv.js +0 -1
  94. package/frontend-dist/assets/RovingFocusItem-CFmjbm49.js +0 -1
  95. package/frontend-dist/assets/Schedules-BUm3cC6w.js +0 -1
  96. package/frontend-dist/assets/Settings-D7z5IRkY.js +0 -6
  97. package/frontend-dist/assets/Setup-i9inmgjB.js +0 -1
  98. package/frontend-dist/assets/Switch-C9DeYAnK.js +0 -1
  99. package/frontend-dist/assets/TooltipTrigger-Dr6kqGSH.js +0 -1
  100. package/frontend-dist/assets/TransformRulesForm-CyXh4jHa.js +0 -1
  101. package/frontend-dist/assets/UnifiedRequestDialog-6ZRBfjko.js +0 -3
  102. package/frontend-dist/assets/VisuallyHiddenInput-CwE9jREu.js +0 -1
  103. package/frontend-dist/assets/constants-yM0YwP2s.js +0 -1
  104. package/frontend-dist/assets/dialog-BWB1aLcT.js +0 -1
  105. package/frontend-dist/assets/index-DeeDpH_W.css +0 -1
  106. package/frontend-dist/assets/index-itL9--Q_.js +0 -3
  107. package/frontend-dist/assets/mappings-6w7mc8YK.js +0 -1
  108. package/frontend-dist/assets/mappings-C1fK_e70.js +0 -1
  109. /package/frontend-dist/assets/{common-D96jEq-h.js → common-Bvxev9Ev.js} +0 -0
  110. /package/frontend-dist/assets/{common-BpwAv-lj.js → common-Cn0QcrnY.js} +0 -0
  111. /package/frontend-dist/assets/{dashboard-DjgmcUG5.js → dashboard-Cejt1wVQ.js} +0 -0
  112. /package/frontend-dist/assets/{dashboard-COCyp2p_.js → dashboard-DLTOR0fN.js} +0 -0
  113. /package/frontend-dist/assets/{login-BTNL5nN5.js → login-BkOvA7gg.js} +0 -0
  114. /package/frontend-dist/assets/{login-Sef1i0de.js → login-DWRFsEu3.js} +0 -0
  115. /package/frontend-dist/assets/{logs-CBRLywRw.js → logs-CA8USnXG.js} +0 -0
  116. /package/frontend-dist/assets/{logs-B-6cgV12.js → logs-QPt2Ybwy.js} +0 -0
  117. /package/frontend-dist/assets/{monitor-CaDMr_KG.js → monitor-CcPZdXUM.js} +0 -0
  118. /package/frontend-dist/assets/{monitor-C9j7ppMj.js → monitor-D-0KOVTC.js} +0 -0
  119. /package/frontend-dist/assets/{proxyEnhancement-DpIVSv-g.js → proxyEnhancement-B6vdsMeK.js} +0 -0
  120. /package/frontend-dist/assets/{proxyEnhancement-rSM6KhbN.js → proxyEnhancement-UuPFs4M3.js} +0 -0
  121. /package/frontend-dist/assets/{quickSetup-CCxaqY3U.js → quickSetup-CSpWmAy-.js} +0 -0
  122. /package/frontend-dist/assets/{quickSetup-DgDENHE4.js → quickSetup-D8ruRelW.js} +0 -0
  123. /package/frontend-dist/assets/{requestDetail-DZ55ph4h.js → requestDetail-8Sp9tWNb.js} +0 -0
  124. /package/frontend-dist/assets/{requestDetail-3KCtYe1N.js → requestDetail-CcHzzKYr.js} +0 -0
  125. /package/frontend-dist/assets/{retryRules-BXrRL52J.js → retryRules-C--dd-y8.js} +0 -0
  126. /package/frontend-dist/assets/{retryRules-CToGC6cR.js → retryRules-CzLnagW_.js} +0 -0
  127. /package/frontend-dist/assets/{routerKeys-DbTg4OP1.js → routerKeys-CB2l_V7w.js} +0 -0
  128. /package/frontend-dist/assets/{routerKeys-Be7OZCn0.js → routerKeys-p_ioAckE.js} +0 -0
  129. /package/frontend-dist/assets/{schedules-Bd66RL7P.js → schedules-Cz_-Wfa_.js} +0 -0
  130. /package/frontend-dist/assets/{schedules-HDwMuDgX.js → schedules-DTgk603B.js} +0 -0
  131. /package/frontend-dist/assets/{settings-DCS-RTKl.js → settings-B5Mq1HN8.js} +0 -0
  132. /package/frontend-dist/assets/{settings-C4zZB9GY.js → settings-j3dzVXzy.js} +0 -0
  133. /package/frontend-dist/assets/{setup-CrjgRrYP.js → setup-DaeEG9ll.js} +0 -0
  134. /package/frontend-dist/assets/{setup-DmgXvgkY.js → setup-Dryg-9wL.js} +0 -0
  135. /package/frontend-dist/assets/{sidebar-3c8D7l60.js → sidebar-BQWT-QZb.js} +0 -0
  136. /package/frontend-dist/assets/{sidebar-vj4kQ6t1.js → sidebar-DYwEKca3.js} +0 -0
@@ -170,7 +170,14 @@ class StreamProxy {
170
170
  }
171
171
  this.transition("STREAMING");
172
172
  this.headersSent = true;
173
- this.reply.raw.writeHead(this.statusCode, this.sseHeaders);
173
+ try {
174
+ this.reply.raw.writeHead(this.statusCode, this.sseHeaders);
175
+ }
176
+ catch {
177
+ // 客户端在 state transition 和 writeHead 之间断连,可安全忽略
178
+ this.terminal("stream_abort");
179
+ return;
180
+ }
174
181
  if (this.metricsTransform) {
175
182
  this.metricsTransform.pipe(this.formatTransform ?? this.passThrough, { end: true });
176
183
  }
@@ -14,6 +14,7 @@ function toStreamMetrics(m) {
14
14
  inputTokens: m.input_tokens,
15
15
  outputTokens: m.output_tokens,
16
16
  cacheReadTokens: m.cache_read_tokens,
17
+ cacheReadTokensEstimated: m.cache_read_tokens_estimated,
17
18
  ttftMs: m.ttft_ms,
18
19
  tokensPerSecond: m.tokens_per_second,
19
20
  stopReason: m.stop_reason,
@@ -53,6 +54,17 @@ export function buildTransportFn(p) {
53
54
  onChunk: (rawLine) => { p.tracker?.appendStreamChunk(p.logId, rawLine, p.apiType, STREAM_CONTENT_MAX_RAW, STREAM_CONTENT_MAX_TEXT); },
54
55
  onContentDelta: streamLoopGuard ? (text) => streamLoopGuard.feed(text) : undefined,
55
56
  });
57
+ // Transform stream 内部异常若无 listener 会触发 uncaught exception,
58
+ // 指标采集错误不影响业务数据流,仅记录 warn 日志。
59
+ metricsTransform.on("error", (err) => {
60
+ p.request.log.warn({ err, logId: p.logId }, "metricsTransform stream error");
61
+ });
62
+ if (p.formatTransform) {
63
+ // 格式转换异常会破坏管道,记录 warn 后由 StreamProxy 的空闲超时兜底清理。
64
+ p.formatTransform.on("error", (err) => {
65
+ p.request.log.warn({ err, logId: p.logId }, "formatTransform stream error");
66
+ });
67
+ }
56
68
  const checkEarlyError = p.matcher ? (data) => p.matcher.test(UPSTREAM_SUCCESS, data) : undefined;
57
69
  const streamResult = await callStream(p.provider, p.apiKey, p.body, p.cliHdrs, p.reply, p.streamTimeoutMs, p.upstreamPath, buildHeaders, metricsTransform, checkEarlyError, undefined, streamLoopGuard, p.formatTransform, p.timeoutContext, undefined, agent);
58
70
  const m = (streamResult.kind === "stream_success" || streamResult.kind === "stream_abort")
@@ -0,0 +1 @@
1
+ import{Ht as e,Q as t,Wt as n,gt as r,pt as i,r as a,tt as o}from"./button-DZwflOXO.js";var s=[`data-size`],c=o({__name:`Card`,props:{class:{type:[Boolean,null,String,Object,Array]},size:{default:`default`}},setup(o){let c=o;return(l,u)=>(i(),t(`div`,{"data-slot":`card`,"data-size":o.size,class:n(e(a)(`ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col`,c.class))},[r(l.$slots,`default`)],10,s))}}),l=o({__name:`CardContent`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(o){let s=o;return(o,c)=>(i(),t(`div`,{"data-slot":`card-content`,class:n(e(a)(`px-4 group-data-[size=sm]/card:px-3`,s.class))},[r(o.$slots,`default`)],2))}});export{c as n,l as t};
@@ -0,0 +1 @@
1
+ import{Ht as e,Q as t,Wt as n,gt as r,pt as i,r as a,tt as o}from"./button-DZwflOXO.js";var s=o({__name:`CardHeader`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(o){let s=o;return(o,c)=>(i(),t(`div`,{"data-slot":`card-header`,class:n(e(a)(`gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]`,s.class))},[r(o.$slots,`default`)],2))}}),c=o({__name:`CardTitle`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(o){let s=o;return(o,c)=>(i(),t(`div`,{"data-slot":`card-title`,class:n(e(a)(`text-base leading-snug font-medium group-data-[size=sm]/card:text-sm cn-font-heading`,s.class))},[r(o.$slots,`default`)],2))}});export{s as n,c as t};
@@ -0,0 +1 @@
1
+ import{Et as e,G as t,Gt as n,Ht as r,J as i,W as a,X as o,Z as s,ct as c,et as l,gt as u,i as d,m as f,o as p,pt as m,r as h,rt as g,tt as _,vt as v,x as y}from"./button-DZwflOXO.js";import{t as b}from"./VisuallyHiddenInput-BflIWQCW.js";import{t as x}from"./RovingFocusItem-NxZWBEpr.js";import{B as S,G as C,H as w,L as T,Y as E,dt as D,q as O}from"./index-PMAQyWJb.js";function k(e,t){return C(e)?!1:Array.isArray(e)?e.some(e=>E(e,t)):E(e,t)}var[A,j]=O(`CheckboxGroupRoot`);function M(e){return e===`indeterminate`}function N(e){return M(e)?`indeterminate`:e?`checked`:`unchecked`}var[P,F]=O(`CheckboxRoot`),I=_({inheritAttrs:!1,__name:`CheckboxRoot`,props:{defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1,default:void 0},disabled:{type:Boolean,required:!1},value:{type:null,required:!1,default:`on`},id:{type:String,required:!1},trueValue:{type:null,required:!1,default:()=>!0},falseValue:{type:null,required:!1,default:()=>!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:modelValue`],setup(n,{emit:l}){let h=n,g=l,{forwardRef:_,currentElement:y}=p(),S=A(null),T=f(h,`modelValue`,g,{defaultValue:h.defaultValue??h.falseValue,passive:h.modelValue===void 0}),D=i(()=>S?.disabled.value||h.disabled),O=i(()=>E(T.value,h.trueValue)),j=i(()=>C(S?.modelValue.value)?T.value===`indeterminate`?`indeterminate`:O.value:k(S.modelValue.value,h.value));function P(){if(C(S?.modelValue.value))T.value===`indeterminate`?T.value=h.trueValue:T.value=O.value?h.falseValue:h.trueValue;else{let e=[...S.modelValue.value||[]];if(k(e,h.value)){let t=e.findIndex(e=>E(e,h.value));e.splice(t,1)}else e.push(h.value);S.modelValue.value=e}}let I=w(y),L=i(()=>h.id&&y.value?document.querySelector(`[for="${h.id}"]`)?.innerText:void 0);return F({disabled:D,state:j}),(n,i)=>(m(),o(v(r(S)?.rovingFocus.value?r(x):r(d)),c(n.$attrs,{id:n.id,ref:r(_),role:`checkbox`,"as-child":n.asChild,as:n.as,type:n.as===`button`?`button`:void 0,"aria-checked":r(M)(j.value)?`mixed`:j.value,"aria-required":n.required,"aria-label":n.$attrs[`aria-label`]||L.value,"data-state":r(N)(j.value),"data-disabled":D.value?``:void 0,disabled:D.value,focusable:r(S)?.rovingFocus.value?!D.value:void 0,onKeydown:a(t(()=>{},[`prevent`]),[`enter`]),onClick:P}),{default:e(()=>[u(n.$slots,`default`,{modelValue:r(T),state:j.value}),r(I)&&n.name&&!r(S)?(m(),o(r(b),{key:0,type:`checkbox`,checked:!!j.value,name:n.name,value:n.value,disabled:D.value,required:n.required},null,8,[`checked`,`name`,`value`,`disabled`,`required`])):s(`v-if`,!0)]),_:3},16,[`id`,`as-child`,`as`,`type`,`aria-checked`,`aria-required`,`aria-label`,`data-state`,`data-disabled`,`disabled`,`focusable`,`onKeydown`]))}}),L=_({__name:`CheckboxIndicator`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`span`}},setup(t){let{forwardRef:n}=p(),i=P();return(t,a)=>(m(),o(r(T),{present:t.forceMount||r(M)(r(i).state.value)||r(i).state.value===!0},{default:e(()=>[l(r(d),c({ref:r(n),"data-state":r(N)(r(i).state.value),"data-disabled":r(i).disabled.value?``:void 0,style:{pointerEvents:`none`},"as-child":t.asChild,as:t.as},t.$attrs),{default:e(()=>[u(t.$slots,`default`)]),_:3},16,[`data-state`,`data-disabled`,`as-child`,`as`])]),_:3},8,[`present`]))}}),R=_({__name:`Checkbox`,props:{defaultValue:{},modelValue:{},disabled:{type:Boolean},value:{},id:{},trueValue:{},falseValue:{},asChild:{type:Boolean},as:{},name:{},required:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(t,{emit:i}){let a=t,s=i,d=S(y(a,`class`),s);return(t,i)=>(m(),o(r(I),c({"data-slot":`checkbox`},r(d),{class:r(h)(`border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex size-4 items-center justify-center rounded-md border transition-colors group-has-disabled/field:opacity-50 focus-visible:ring-3 aria-invalid:ring-3 peer relative shrink-0 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50`,a.class)}),{default:e(i=>[l(r(L),{"data-slot":`checkbox-indicator`,class:`[&>svg]:size-3.5 grid place-content-center text-current transition-none`},{default:e(()=>[u(t.$slots,`default`,n(g(i)),()=>[l(r(D))])]),_:2},1024)]),_:3},16,[`class`]))}});export{R as t};
@@ -0,0 +1 @@
1
+ import{Ct as e,Et as t,Gt as n,Ht as r,J as i,Pt as a,X as o,Z as s,ct as c,d as l,dt as u,et as d,gt as f,i as p,lt as m,m as h,o as g,pt as _,rt as v,tt as y,zt as b}from"./button-DZwflOXO.js";import{B as x,L as S,q as C,z as w}from"./index-PMAQyWJb.js";var[T,E]=C(`CollapsibleRoot`),D=y({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:n,emit:i}){let a=e,s=h(a,`open`,i,{defaultValue:a.defaultOpen,passive:a.open===void 0}),{disabled:c,unmountOnHide:l}=b(a);return E({contentId:``,disabled:c,open:s,unmountOnHide:l,onOpenToggle:()=>{c.value||(s.value=!s.value)}}),n({open:s}),g(),(e,n)=>(_(),o(r(p),{as:e.as,"as-child":a.asChild,"data-state":r(s)?`open`:`closed`,"data-disabled":r(c)?``:void 0},{default:t(()=>[f(e.$slots,`default`,{open:r(s)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),O=y({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(n,{emit:h}){let v=n,y=h,b=T();b.contentId||=w(void 0,`reka-collapsible-content`);let x=a(),{forwardRef:C,currentElement:E}=g(),D=a(0),O=a(0),k=i(()=>b.open.value),A=a(k.value),j=a();e(()=>[k.value,x.value?.present],async()=>{await m();let e=E.value;if(!e)return;j.value=j.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();O.value=t.height,D.value=t.width,A.value||(e.style.transitionDuration=j.value.transitionDuration,e.style.animationName=j.value.animationName)},{immediate:!0});let M=i(()=>A.value&&b.open.value);return u(()=>{requestAnimationFrame(()=>{A.value=!1})}),l(E,`beforematch`,e=>{requestAnimationFrame(()=>{b.onOpenToggle(),y(`contentFound`)})}),(e,n)=>(_(),o(r(S),{ref_key:`presentRef`,ref:x,present:e.forceMount||r(b).open.value,"force-mount":!0},{default:t(({present:n})=>[d(r(p),c(e.$attrs,{id:r(b).contentId,ref:r(C),"as-child":v.asChild,as:e.as,hidden:n?void 0:r(b).unmountOnHide.value?``:`until-found`,"data-state":M.value?void 0:r(b).open.value?`open`:`closed`,"data-disabled":r(b).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${O.value}px`,"--reka-collapsible-content-width":`${D.value}px`}}),{default:t(()=>[!r(b).unmountOnHide.value||n?f(e.$slots,`default`,{key:0}):s(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),k=y({__name:`Collapsible`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},disabled:{type:Boolean},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{}},emits:[`update:open`],setup(e,{emit:i}){let a=x(e,i);return(e,i)=>(_(),o(r(D),c({"data-slot":`collapsible`},r(a)),{default:t(t=>[f(e.$slots,`default`,n(v(t)))]),_:3},16))}}),A=y({__name:`CollapsibleContent`,props:{forceMount:{type:Boolean},asChild:{type:Boolean},as:{}},setup(e){let n=e;return(e,i)=>(_(),o(r(O),c({"data-slot":`collapsible-content`},n),{default:t(()=>[f(e.$slots,`default`)]),_:3},16))}});export{k as n,T as r,A as t};
@@ -0,0 +1 @@
1
+ import{Et as e,Ht as t,X as n,ct as r,gt as i,i as a,o,pt as s,tt as c}from"./button-DZwflOXO.js";import{r as l}from"./CollapsibleContent-DHkVSWt2.js";var u=c({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(r){let c=r;o();let u=l();return(r,o)=>(s(),n(t(a),{type:r.as===`button`?`button`:void 0,as:r.as,"as-child":c.asChild,"aria-controls":t(u).contentId,"aria-expanded":t(u).open.value,"data-state":t(u).open.value?`open`:`closed`,"data-disabled":t(u).disabled?.value?``:void 0,disabled:t(u).disabled?.value,onClick:t(u).onOpenToggle},{default:e(()=>[i(r.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}}),d=c({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean},as:{}},setup(a){let o=a;return(a,c)=>(s(),n(t(u),r({"data-slot":`collapsible-trigger`},o),{default:e(()=>[i(a.$slots,`default`)]),_:3},16))}});export{d as t};
@@ -0,0 +1,3 @@
1
+ import{$ as e,A as t,At as n,Ct as r,Et as i,Ht as a,It as o,J as s,K as c,Lt as l,Pt as u,Q as d,R as f,X as p,Y as m,dt as h,et as g,ft as _,ht as v,it as y,k as b,kt as x,lt as S,n as C,pt as w,qt as T,tt as E}from"./button-DZwflOXO.js";import{f as D,g as O,gt as k,h as ee,ht as te,m as ne,mt as re,n as ie,p as ae,pt as oe,r as se}from"./index-PMAQyWJb.js";import{n as A,t as j}from"./CardContent-yiYaxAko.js";import{n as ce,t as le}from"./CardTitle-CzqSlrtn.js";import{t as ue}from"./Input-DEfnoFS3.js";function M(e){return e+.5|0}var de=(e,t,n)=>Math.max(Math.min(e,n),t);function N(e){return de(M(e*2.55),0,255)}function fe(e){return de(M(e*255),0,255)}function pe(e){return de(M(e/2.55)/100,0,1)}function me(e){return de(M(e*100),0,100)}var P={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},he=[...`0123456789ABCDEF`],ge=e=>he[e&15],_e=e=>he[(e&240)>>4]+he[e&15],ve=e=>(e&240)>>4==(e&15),ye=e=>ve(e.r)&&ve(e.g)&&ve(e.b)&&ve(e.a);function be(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&P[e[1]]*17,g:255&P[e[2]]*17,b:255&P[e[3]]*17,a:t===5?P[e[4]]*17:255}:(t===7||t===9)&&(n={r:P[e[1]]<<4|P[e[2]],g:P[e[3]]<<4|P[e[4]],b:P[e[5]]<<4|P[e[6]],a:t===9?P[e[7]]<<4|P[e[8]]:255})),n}var xe=(e,t)=>e<255?t(e):``;function Se(e){var t=ye(e)?ge:_e;return e?`#`+t(e.r)+t(e.g)+t(e.b)+xe(e.a,t):void 0}var Ce=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function we(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 Te(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 Ee(e,t,n){let r=we(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 De(e,t,n,r,i){return e===i?(t-n)/r+(t<n?6:0):t===i?(n-e)/r+2:(e-t)/r+4}function Oe(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c,l;return i!==a&&(l=i-a,c=o>.5?l/(2-i-a):l/(i+a),s=De(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function ke(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(fe)}function Ae(e,t,n){return ke(we,e,t,n)}function je(e,t,n){return ke(Ee,e,t,n)}function Me(e,t,n){return ke(Te,e,t,n)}function Ne(e){return(e%360+360)%360}function Pe(e){let t=Ce.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?N(+t[5]):fe(+t[5]));let i=Ne(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?je(i,a,o):t[1]===`hsv`?Me(i,a,o):Ae(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function Fe(e,t){var n=Oe(e);n[0]=Ne(n[0]+t),n=Ae(n),e.r=n[0],e.g=n[1],e.b=n[2]}function Ie(e){if(!e)return;let t=Oe(e),n=t[0],r=me(t[1]),i=me(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${pe(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var Le={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`},Re={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 ze(){let e={},t=Object.keys(Re),n=Object.keys(Le),r,i,a,o,s;for(r=0;r<t.length;r++){for(o=s=t[r],i=0;i<n.length;i++)a=n[i],s=s.replace(a,Le[a]);a=parseInt(Re[o],16),e[s]=[a>>16&255,a>>8&255,a&255]}return e}var Be;function Ve(e){Be||(Be=ze(),Be.transparent=[0,0,0,0]);let t=Be[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var He=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Ue(e){let t=He.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?N(e):de(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?N(r):de(r,0,255)),i=255&(t[4]?N(i):de(i,0,255)),a=255&(t[6]?N(a):de(a,0,255)),{r,g:i,b:a,a:n}}}function We(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${pe(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var Ge=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,Ke=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function qe(e,t,n){let r=Ke(pe(e.r)),i=Ke(pe(e.g)),a=Ke(pe(e.b));return{r:fe(Ge(r+n*(Ke(pe(t.r))-r))),g:fe(Ge(i+n*(Ke(pe(t.g))-i))),b:fe(Ge(a+n*(Ke(pe(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Je(e,t,n){if(e){let r=Oe(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=Ae(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Ye(e,t){return e&&Object.assign(t||{},e)}function Xe(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=fe(e[3]))):(t=Ye(e,{r:0,g:0,b:0,a:1}),t.a=fe(t.a)),t}function Ze(e){return e.charAt(0)===`r`?Ue(e):Pe(e)}var Qe=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Xe(t):n===`string`&&(r=be(t)||Ve(t)||Ze(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Ye(this._rgb);return e&&(e.a=pe(e.a)),e}set rgb(e){this._rgb=Xe(e)}rgbString(){return this._valid?We(this._rgb):void 0}hexString(){return this._valid?Se(this._rgb):void 0}hslString(){return this._valid?Ie(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=qe(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=fe(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=M(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 Je(this._rgb,2,e),this}darken(e){return Je(this._rgb,2,-e),this}saturate(e){return Je(this._rgb,1,e),this}desaturate(e){return Je(this._rgb,1,-e),this}rotate(e){return Fe(this._rgb,e),this}};function $e(){}var et=(()=>{let e=0;return()=>e++})();function F(e){return e==null}function I(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 L(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function R(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function z(e,t){return R(e)?e:t}function B(e,t){return e===void 0?t:e}var tt=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function V(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function H(e,t,n,r){let i,a,o;if(I(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;i<a;i++)t.call(n,e[i],i);else if(L(e))for(o=Object.keys(e),a=o.length,i=0;i<a;i++)t.call(n,e[o[i]],o[i])}function nt(e,t){let n,r,i,a;if(!e||!t||e.length!==t.length)return!1;for(n=0,r=e.length;n<r;++n)if(i=e[n],a=t[n],i.datasetIndex!==a.datasetIndex||i.index!==a.index)return!1;return!0}function rt(e){if(I(e))return e.map(rt);if(L(e)){let t=Object.create(null),n=Object.keys(e),r=n.length,i=0;for(;i<r;++i)t[n[i]]=rt(e[n[i]]);return t}return e}function it(e){return[`__proto__`,`prototype`,`constructor`].indexOf(e)===-1}function at(e,t,n,r){if(!it(e))return;let i=t[e],a=n[e];L(i)&&L(a)?ot(i,a,r):t[e]=rt(a)}function ot(e,t,n){let r=I(t)?t:[t],i=r.length;if(!L(e))return e;n||={};let a=n.merger||at,o;for(let t=0;t<i;++t){if(o=r[t],!L(o))continue;let i=Object.keys(o);for(let t=0,r=i.length;t<r;++t)a(i[t],e,o,n)}return e}function st(e,t){return ot(e,t,{merger:ct})}function ct(e,t,n){if(!it(e))return;let r=t[e],i=n[e];L(r)&&L(i)?st(r,i):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=rt(i))}var lt={"":e=>e,x:e=>e.x,y:e=>e.y};function ut(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 dt(e){let t=ut(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function ft(e,t){return(lt[t]||(lt[t]=dt(t)))(e)}function pt(e){return e.charAt(0).toUpperCase()+e.slice(1)}var mt=e=>e!==void 0,ht=e=>typeof e==`function`,gt=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function _t(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var U=Math.PI,W=2*U,vt=W+U,yt=1/0,bt=U/180,G=U/2,xt=U/4,St=U*2/3,Ct=Math.log10,wt=Math.sign;function Tt(e,t,n){return Math.abs(e-t)<n}function Et(e){let t=Math.round(e);e=Tt(e,t,e/1e3)?t:e;let n=10**Math.floor(Ct(e)),r=e/n;return(r<=1?1:r<=2?2:r<=5?5:10)*n}function Dt(e){let t=[],n=Math.sqrt(e),r;for(r=1;r<n;r++)e%r===0&&(t.push(r),t.push(e/r));return n===(n|0)&&t.push(n),t.sort((e,t)=>e-t).pop(),t}function Ot(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function kt(e){return!Ot(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function At(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function jt(e,t,n){let r,i,a;for(r=0,i=e.length;r<i;r++)a=e[r][n],isNaN(a)||(t.min=Math.min(t.min,a),t.max=Math.max(t.max,a))}function Mt(e){return U/180*e}function Nt(e){return 180/U*e}function Pt(e){if(!R(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function Ft(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r),a=Math.atan2(r,n);return a<-.5*U&&(a+=W),{angle:a,distance:i}}function It(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function Lt(e,t){return(e-t+vt)%W-U}function K(e){return(e%W+W)%W}function Rt(e,t,n,r){let i=K(e),a=K(t),o=K(n),s=K(a-i),c=K(o-i),l=K(i-a),u=K(i-o);return i===a||i===o||r&&a===o||s>c&&l<u}function q(e,t,n){return Math.max(t,Math.min(n,e))}function zt(e){return q(e,-32768,32767)}function Bt(e,t,n,r=1e-6){return e>=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Vt(e,t,n){n||=(n=>e[n]<t);let r=e.length-1,i=0,a;for(;r-i>1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var Ht=(e,t,n,r)=>Vt(e,n,r?r=>{let i=e[r][t];return i<n||i===n&&e[r+1][t]===n}:r=>e[r][t]<n),Ut=(e,t,n)=>Vt(e,n,r=>e[r][t]>=n);function Wt(e,t,n){let r=0,i=e.length;for(;r<i&&e[r]<t;)r++;for(;i>r&&e[i-1]>n;)i--;return r>0||i<e.length?e.slice(r,i):e}var Gt=[`push`,`pop`,`shift`,`splice`,`unshift`];function Kt(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,`_chartjs`,{configurable:!0,enumerable:!1,value:{listeners:[t]}}),Gt.forEach(t=>{let n=`_onData`+pt(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 qt(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)&&(Gt.forEach(t=>{delete e[t]}),delete e._chartjs)}function Jt(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var Yt=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function Xt(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,Yt.call(window,()=>{r=!1,e.apply(t,n)}))}}function Zt(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var Qt=e=>e===`start`?`left`:e===`end`?`right`:`center`,J=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,$t=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function en(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(Ht(c,u,d).lo,n?r:Ht(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!F(e[s.axis]));i-=Math.max(0,e)}i=q(i,0,r-1)}if(m){let e=Math.max(Ht(c,o.axis,f,!0).hi+1,n?0:Ht(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!F(e[s.axis]));e+=Math.max(0,t)}a=q(e,i,r)-i}else a=r-i}return{start:i,count:a}}function tn(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 nn=e=>e===0||e===1,rn=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*W/n)),an=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*W/n)+1,on={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*G)+1,easeOutSine:e=>Math.sin(e*G),easeInOutSine:e=>-.5*(Math.cos(U*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>nn(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=>nn(e)?e:rn(e,.075,.3),easeOutElastic:e=>nn(e)?e:an(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return nn(e)?e:e<.5?.5*rn(e*2,t,n):.5+.5*an(e*2-1,t,n)},easeInBack(e){let t=1.70158;return e*e*((t+1)*e-t)},easeOutBack(e){let t=1.70158;return--e*e*((t+1)*e+t)+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-on.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?on.easeInBounce(e*2)*.5:on.easeOutBounce(e*2-1)*.5+.5};function sn(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function cn(e){return sn(e)?e:new Qe(e)}function ln(e){return sn(e)?e:new Qe(e).saturate(.5).darken(.1).hexString()}var un=[`x`,`y`,`borderWidth`,`radius`,`tension`],dn=[`color`,`borderColor`,`backgroundColor`];function fn(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:dn},numbers:{type:`number`,properties:un}}),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 pn(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var mn=new Map;function hn(e,t){t||={};let n=e+JSON.stringify(t),r=mn.get(n);return r||(r=new Intl.NumberFormat(e,t),mn.set(n,r)),r}function gn(e,t,n){return hn(t,n).format(e)}var _n={values(e){return I(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=vn(e,n)}let o=Ct(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),gn(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(Ct(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?_n.numeric.call(this,e,t,n):``}};function vn(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 yn={formatters:_n};function bn(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:yn.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 xn=Object.create(null),Sn=Object.create(null);function Cn(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;t<r;++t){let r=n[t];e=e[r]||(e[r]=Object.create(null))}return e}function wn(e,t,n){return typeof t==`string`?ot(Cn(e,t),n):ot(Cn(e,``),t)}var Y=new class{constructor(e,t){this.animation=void 0,this.backgroundColor=`rgba(0,0,0,0.1)`,this.borderColor=`rgba(0,0,0,0.1)`,this.color=`#666`,this.datasets={},this.devicePixelRatio=e=>e.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)=>ln(t.backgroundColor),this.hoverBorderColor=(e,t)=>ln(t.borderColor),this.hoverColor=(e,t)=>ln(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 wn(this,e,t)}get(e){return Cn(this,e)}describe(e,t){return wn(Sn,e,t)}override(e,t){return wn(xn,e,t)}route(e,t,n,r){let i=Cn(this,e),a=Cn(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 L(e)?Object.assign({},t,e):B(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}},[fn,pn,bn]);function Tn(e){return!e||F(e.size)||F(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function En(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 Dn(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;c<s;c++)if(d=n[c],d!=null&&!I(d))o=En(e,i,a,o,d);else if(I(d))for(l=0,u=d.length;l<u;l++)f=d[l],f!=null&&!I(f)&&(o=En(e,i,a,o,f));e.restore();let p=a.length/2;if(p>n.length){for(c=0;c<p;c++)delete i[a[c]];a.splice(0,p)}return o}function On(e,t,n){let r=e.currentDevicePixelRatio,i=n===0?0:Math.max(n/2,.5);return Math.round((t-i)*r)/r+i}function kn(e,t){!t&&!e||(t||=e.getContext(`2d`),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function An(e,t,n,r){jn(e,t,n,r,null)}function jn(e,t,n,r,i){let a,o,s,c,l,u,d,f,p=t.pointStyle,m=t.rotation,h=t.radius,g=(m||0)*bt;if(p&&typeof p==`object`&&(a=p.toString(),a===`[object HTMLImageElement]`||a===`[object HTMLCanvasElement]`)){e.save(),e.translate(n,r),e.rotate(g),e.drawImage(p,-p.width/2,-p.height/2,p.width,p.height),e.restore();return}if(!(isNaN(h)||h<=0)){switch(e.beginPath(),p){default:i?e.ellipse(n,r,i/2,h,0,0,W):e.arc(n,r,h,0,W),e.closePath();break;case`triangle`:u=i?i/2:h,e.moveTo(n+Math.sin(g)*u,r-Math.cos(g)*h),g+=St,e.lineTo(n+Math.sin(g)*u,r-Math.cos(g)*h),g+=St,e.lineTo(n+Math.sin(g)*u,r-Math.cos(g)*h),e.closePath();break;case`rectRounded`:l=h*.516,c=h-l,o=Math.cos(g+xt)*c,d=Math.cos(g+xt)*(i?i/2-l:c),s=Math.sin(g+xt)*c,f=Math.sin(g+xt)*(i?i/2-l:c),e.arc(n-d,r-s,l,g-U,g-G),e.arc(n+f,r-o,l,g-G,g),e.arc(n+d,r+s,l,g,g+G),e.arc(n-f,r+o,l,g+G,g+U),e.closePath();break;case`rect`:if(!m){c=Math.SQRT1_2*h,u=i?i/2:c,e.rect(n-u,r-c,2*u,2*c);break}g+=xt;case`rectRot`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+f,r-o),e.lineTo(n+d,r+s),e.lineTo(n-f,r+o),e.closePath();break;case`crossRot`:g+=xt;case`cross`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o);break;case`star`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o),g+=xt,d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o);break;case`line`:o=i?i/2:Math.cos(g)*h,s=Math.sin(g)*h,e.moveTo(n-o,r-s),e.lineTo(n+o,r+s);break;case`dash`:e.moveTo(n,r),e.lineTo(n+Math.cos(g)*(i?i/2:h),r+Math.sin(g)*h);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function Mn(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function Nn(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function Pn(e){e.restore()}function Fn(e,t,n,r,i){if(!t)return e.lineTo(n.x,n.y);if(i===`middle`){let r=(t.x+n.x)/2;e.lineTo(r,t.y),e.lineTo(r,n.y)}else i===`after`==!!r?e.lineTo(n.x,t.y):e.lineTo(t.x,n.y);e.lineTo(n.x,n.y)}function In(e,t,n,r){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(r?t.cp1x:t.cp2x,r?t.cp1y:t.cp2y,r?n.cp2x:n.cp1x,r?n.cp2y:n.cp1y,n.x,n.y)}function Ln(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),F(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function Rn(e,t,n,r,i){if(i.strikethrough||i.underline){let a=e.measureText(r),o=t-a.actualBoundingBoxLeft,s=t+a.actualBoundingBoxRight,c=n-a.actualBoundingBoxAscent,l=n+a.actualBoundingBoxDescent,u=i.strikethrough?(c+l)/2:l;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=i.decorationWidth||2,e.moveTo(o,u),e.lineTo(s,u),e.stroke()}}function zn(e,t){let n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Bn(e,t,n,r,i,a={}){let o=I(t)?t:[t],s=a.strokeWidth>0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Ln(e,a),c=0;c<o.length;++c)l=o[c],a.backdrop&&zn(e,a.backdrop),s&&(a.strokeColor&&(e.strokeStyle=a.strokeColor),F(a.strokeWidth)||(e.lineWidth=a.strokeWidth),e.strokeText(l,n,r,a.maxWidth)),e.fillText(l,n,r,a.maxWidth),Rn(e,n,r,l,a),r+=Number(i.lineHeight);e.restore()}function Vn(e,t){let{x:n,y:r,w:i,h:a,radius:o}=t;e.arc(n+o.topLeft,r+o.topLeft,o.topLeft,1.5*U,U,!0),e.lineTo(n,r+a-o.bottomLeft),e.arc(n+o.bottomLeft,r+a-o.bottomLeft,o.bottomLeft,U,G,!0),e.lineTo(n+i-o.bottomRight,r+a),e.arc(n+i-o.bottomRight,r+a-o.bottomRight,o.bottomRight,G,0,!0),e.lineTo(n+i,r+o.topRight),e.arc(n+i-o.topRight,r+o.topRight,o.topRight,0,-G,!0),e.lineTo(n+o.topLeft,r)}var Hn=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Un=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Wn(e,t){let n=(``+e).match(Hn);if(!n||n[1]===`normal`)return t*1.2;switch(e=+n[2],n[3]){case`px`:return e;case`%`:e/=100;break}return t*e}var Gn=e=>+e||0;function Kn(e,t){let n={},r=L(t),i=r?Object.keys(t):t,a=L(e)?r?n=>B(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=Gn(a(e));return n}function qn(e){return Kn(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function Jn(e){return Kn(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function X(e){let t=qn(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function Z(e,t){e||={},t||=Y.font;let n=B(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=B(e.style,t.style);r&&!(``+r).match(Un)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:B(e.family,t.family),lineHeight:Wn(B(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:B(e.weight,t.weight),string:``};return i.string=Tn(i),i}function Yn(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;a<o;++a)if(s=e[a],s!==void 0&&(t!==void 0&&typeof s==`function`&&(s=s(t),i=!1),n!==void 0&&I(s)&&(s=s[n%s.length],i=!1),s!==void 0))return r&&!i&&(r.cacheable=!1),s}function Xn(e,t,n){let{min:r,max:i}=e,a=tt(t,(i-r)/2),o=(e,t)=>n&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function Zn(e,t){return Object.assign(Object.create(e),t)}function Qn(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=mr(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>Qn([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return rr(n,r,()=>pr(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return hr(e).includes(t)},ownKeys(e){return hr(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function $n(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:er(e,r),setContext:t=>$n(e,t,n,r),override:i=>$n(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 rr(e,t,()=>ir(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 er(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:ht(n)?n:()=>n,isIndexable:ht(r)?r:()=>r}}var tr=(e,t)=>e?e+pt(t):t,nr=(e,t)=>L(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function rr(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function ir(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return ht(s)&&o.isScriptable(t)&&(s=ar(t,s,e,n)),I(s)&&s.length&&(s=or(t,s,e,o.isIndexable)),nr(t,s)&&(s=$n(s,i,a&&a[t],o)),s}function ar(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),nr(e,c)&&(c=ur(i._scopes,i,e,c)),c}function or(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(L(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=ur(r,i,e,c);t.push($n(n,a,o&&o[e],s))}}return t}function sr(e,t,n){return ht(e)?e(t,n):e}var cr=(e,t)=>e===!0?t:typeof e==`string`?ft(t,e):void 0;function lr(e,t,n,r,i){for(let a of t){let t=cr(n,a);if(t){e.add(t);let a=sr(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 ur(e,t,n,r){let i=t._rootScopes,a=sr(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=dr(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=dr(s,o,a,c,r),c===null)?!1:Qn(Array.from(s),[``],i,a,()=>fr(t,n,r))}function dr(e,t,n,r,i){for(;n;)n=lr(e,t,n,r,i);return n}function fr(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return I(i)&&L(n)?n:i||{}}function pr(e,t,n,r){let i;for(let a of t)if(i=mr(tr(a,e),n),i!==void 0)return nr(e,i)?ur(n,r,e,i):i}function mr(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function hr(e){let t=e._keys;return t||=e._keys=gr(e._scopes),t}function gr(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)}var _r=2**-52||1e-14,vr=(e,t)=>t<e.length&&!e[t].skip&&e[t],yr=e=>e===`x`?`y`:`x`;function br(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=It(a,i),c=It(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 xr(e,t,n){let r=e.length,i,a,o,s,c,l=vr(e,0);for(let u=0;u<r-1;++u)if(c=l,l=vr(e,u+1),!(!c||!l)){if(Tt(t[u],0,_r)){n[u]=n[u+1]=0;continue}i=n[u]/t[u],a=n[u+1]/t[u],s=i**2+a**2,!(s<=9)&&(o=3/Math.sqrt(s),n[u]=i*o*t[u],n[u+1]=a*o*t[u])}}function Sr(e,t,n=`x`){let r=yr(n),i=e.length,a,o,s,c=vr(e,0);for(let l=0;l<i;++l){if(o=s,s=c,c=vr(e,l+1),!s)continue;let i=s[n],u=s[r];o&&(a=(i-o[n])/3,s[`cp1${n}`]=i-a,s[`cp1${r}`]=u-a*t[l]),c&&(a=(c[n]-i)/3,s[`cp2${n}`]=i+a,s[`cp2${r}`]=u+a*t[l])}}function Cr(e,t=`x`){let n=yr(t),r=e.length,i=Array(r).fill(0),a=Array(r),o,s,c,l=vr(e,0);for(o=0;o<r;++o)if(s=c,c=l,l=vr(e,o+1),c){if(l){let e=l[t]-c[t];i[o]=e===0?0:(l[n]-c[n])/e}a[o]=s?l?wt(i[o-1])===wt(i[o])?(i[o-1]+i[o])/2:0:i[o-1]:i[o]}xr(e,i,a),Sr(e,a,t)}function wr(e,t,n){return Math.max(Math.min(e,n),t)}function Tr(e,t){let n,r,i,a,o,s=Mn(e[0],t);for(n=0,r=e.length;n<r;++n)o=a,a=s,s=n<r-1&&Mn(e[n+1],t),a&&(i=e[n],o&&(i.cp1x=wr(i.cp1x,t.left,t.right),i.cp1y=wr(i.cp1y,t.top,t.bottom)),s&&(i.cp2x=wr(i.cp2x,t.left,t.right),i.cp2y=wr(i.cp2y,t.top,t.bottom)))}function Er(e,t,n,r,i){let a,o,s,c;if(t.spanGaps&&(e=e.filter(e=>!e.skip)),t.cubicInterpolationMode===`monotone`)Cr(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;a<o;++a)s=e[a],c=br(n,s,e[Math.min(a+1,o-+!r)%o],t.tension),s.cp1x=c.previous.x,s.cp1y=c.previous.y,s.cp2x=c.next.x,s.cp2y=c.next.y,n=s}t.capBezierPoints&&Tr(e,n)}function Dr(){return typeof window<`u`&&typeof document<`u`}function Or(e){let t=e.parentNode;return t&&t.toString()===`[object ShadowRoot]`&&(t=t.host),t}function kr(e,t,n){let r;return typeof e==`string`?(r=parseInt(e,10),e.indexOf(`%`)!==-1&&(r=r/100*t.parentNode[n])):r=e,r}var Ar=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function jr(e,t){return Ar(e).getPropertyValue(t)}var Mr=[`top`,`right`,`bottom`,`left`];function Nr(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Mr[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var Pr=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Fr(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(Pr(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 Ir(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Ar(n),a=i.boxSizing===`border-box`,o=Nr(i,`padding`),s=Nr(i,`border`,`width`),{x:c,y:l,box:u}=Fr(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 Lr(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Or(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Ar(a),s=Nr(o,`border`,`width`),c=Nr(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=kr(o.maxWidth,a,`clientWidth`),i=kr(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||yt,maxHeight:i||yt}}var Rr=e=>Math.round(e*10)/10;function zr(e,t,n,r){let i=Ar(e),a=Nr(i,`margin`),o=kr(i.maxWidth,e,`clientWidth`)||yt,s=kr(i.maxHeight,e,`clientHeight`)||yt,c=Lr(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Nr(i,`border`,`width`),t=Nr(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=Rr(Math.min(l,o,c.maxWidth)),u=Rr(Math.min(u,s,c.maxHeight)),l&&!u&&(u=Rr(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=Rr(Math.floor(u*r))),{width:l,height:u}}function Br(e,t,n){let r=t||1,i=Rr(e.height*r),a=Rr(e.width*r);e.height=Rr(e.height),e.width=Rr(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 Vr=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Dr()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function Hr(e,t){let n=jr(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function Ur(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function Wr(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 Gr(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=Ur(e,i,n),s=Ur(i,a,n),c=Ur(a,t,n);return Ur(Ur(o,s,n),Ur(s,c,n),n)}var Kr=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}}},qr=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Jr(e,t,n){return e?Kr(t,n):qr()}function Yr(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 Xr(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function Zr(e){return e===`angle`?{between:Rt,compare:Lt,normalize:K}:{between:Bt,compare:(e,t)=>e-t,normalize:e=>e}}function Qr({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 $r(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=Zr(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;f<p&&o(s(t[l%c][r]),i,a);++f)l--,u--;l%=c,u%=c}return u<l&&(u+=c),{start:l,end:u,loop:d,style:e.style}}function ei(e,t,n){if(!n)return[e];let{property:r,start:i,end:a}=n,o=t.length,{compare:s,between:c,normalize:l}=Zr(r),{start:u,end:d,loop:f,style:p}=$r(e,t,n),m=[],h=!1,g=null,_,v,y,b=()=>c(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(Qr({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(Qr({start:g,end:d,loop:f,count:o,style:p})),m}function ti(e,t){let n=[],r=e.segments;for(let i=0;i<r.length;i++){let a=ei(r[i],e.points,t);a.length&&n.push(...a)}return n}function ni(e,t,n,r){let i=0,a=t-1;if(n&&!r)for(;i<t&&!e[i].skip;)i++;for(;i<t&&e[i].skip;)i++;for(i%=t,n&&(a+=i);a>i&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function ri(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 ii(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=ni(n,i,a,r);return r===!0?ai(e,[{start:o,end:s,loop:a}],n,t):ai(e,ri(n,o,s<o?s+i:s,!!e._fullLoop&&o===0&&s===i-1),n,t)}function ai(e,t,n,r){return!r||!r.setContext||!n?t:oi(e,t,n,r)}function oi(e,t,n,r){let i=e._chart.getContext(),a=si(e.options),{_datasetIndex:o,options:{spanGaps:s}}=e,c=n.length,l=[],u=a,d=t[0].start,f=d;function p(e,t,r,i){let a=s?-1:1;if(e!==t){for(e+=c;n[e%c].skip;)e-=a;for(;n[t%c].skip;)t+=a;e%c!==t%c&&(l.push({start:e%c,end:t%c,loop:r,style:i}),u=i,d=t%c)}}for(let e of t){d=s?d:e.start;let t=n[d%c],a;for(f=d+1;f<=e.end;f++){let s=n[f%c];a=si(r.setContext(Zn(i,{type:`segment`,p0:t,p1:s,p0DataIndex:(f-1)%c,p1DataIndex:f%c,datasetIndex:o}))),ci(a,u)&&p(d,f-1,e.loop,u),t=s,u=a}d<f-1&&p(d,f-1,e.loop,u)}return l}function si(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function ci(e,t){if(!t)return!1;let n=[],r=function(e,t){return sn(t)?(n.includes(t)||n.push(t),n.indexOf(t)):t};return JSON.stringify(e,r)!==JSON.stringify(t,r)}function li(e,t,n){return e.options.clip?e[n]:t[n]}function ui(e,t){let{xScale:n,yScale:r}=e;return n&&r?{left:li(n,t,`left`),right:li(n,t,`right`),top:li(r,t,`top`),bottom:li(r,t,`bottom`)}:t}function di(e,t){let n=t._clip;if(n.disabled)return!1;let r=ui(t,e.chartArea);return{left:n.left===!1?0:r.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:r.right+(n.right===!0?0:n.right),top:n.top===!1?0:r.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:r.bottom+(n.bottom===!0?0:n.bottom)}}var fi=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(e,t,n,r){let i=t.listeners[r],a=t.duration;i.forEach(r=>r({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,Yt.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)}},pi=`transparent`,mi={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=cn(e||pi),i=r.valid&&cn(t||pi);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},hi=class{constructor(e,t,n,r){let i=t[n];r=Yn([e.to,r,i,e.from]);let a=Yn([e.from,i,r]);this._active=!0,this._fn=e.fn||mi[e.type||typeof a],this._easing=on[e.easing]||on.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=Yn([e.to,t,r,e.from]),this._from=Yn([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||t<n),!this._active){this._target[r]=o,this._notify(!0);return}if(t<0){this._target[r]=i;return}s=t/n%2,s=a&&s>1?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<n.length;e++)n[e][t]()}},gi=class{constructor(e,t){this._chart=e,this._properties=new Map,this.configure(t)}configure(e){if(!L(e))return;let t=Object.keys(Y.animation),n=this._properties;Object.getOwnPropertyNames(e).forEach(r=>{let i=e[r];if(!L(i))return;let a={};for(let e of t)a[e]=i[e];(I(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=vi(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&_i(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 hi(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 fi.add(this._chart,n),!0}};function _i(e,t){let n=[],r=Object.keys(t);for(let t=0;t<r.length;t++){let i=e[r[t]];i&&i.active()&&n.push(i.wait())}return Promise.all(n)}function vi(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function yi(e,t){let n=e&&e.options||{},r=n.reverse,i=n.min===void 0?t:0,a=n.max===void 0?t:0;return{start:r?a:i,end:r?i:a}}function bi(e,t,n){if(n===!1)return!1;let r=yi(e,n),i=yi(t,n);return{top:i.end,right:r.end,bottom:i.start,left:r.start}}function xi(e){let t,n,r,i;return L(e)?(t=e.top,n=e.right,r=e.bottom,i=e.left):t=n=r=i=e,{top:t,right:n,bottom:r,left:i,disabled:e===!1}}function Si(e,t){let n=[],r=e._getSortedDatasetMetas(t),i,a;for(i=0,a=r.length;i<a;++i)n.push(r[i].index);return n}function Ci(e,t,n,r={}){let i=e.keys,a=r.mode===`single`,o,s,c,l;if(t===null)return;let u=!1;for(o=0,s=i.length;o<s;++o){if(c=+i[o],c===n){if(u=!0,r.all)continue;break}l=e.values[c],R(l)&&(a||t===0||wt(t)===wt(l))&&(t+=l)}return!u&&!r.all?0:t}function wi(e,t){let{iScale:n,vScale:r}=t,i=n.axis===`x`?`x`:`y`,a=r.axis===`x`?`x`:`y`,o=Object.keys(e),s=Array(o.length),c,l,u;for(c=0,l=o.length;c<l;++c)u=o[c],s[c]={[i]:u,[a]:e[u]};return s}function Ti(e,t){let n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function Ei(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function Di(e){let{min:t,max:n,minDefined:r,maxDefined:i}=e.getUserBounds();return{min:r?t:-1/0,max:i?n:1/0}}function Oi(e,t,n){let r=e[t]||(e[t]={});return r[n]||(r[n]={})}function ki(e,t,n,r){for(let i of t.getMatchingVisibleMetas(r).reverse()){let t=e[i.index];if(n&&t>0||!n&&t<0)return i.index}return null}function Ai(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=Ei(a,o,r),d=t.length,f;for(let e=0;e<d;++e){let n=t[e],{[c]:a,[l]:d}=n,p=n._stacks||={};f=p[l]=Oi(i,u,a),f[s]=d,f._top=ki(f,o,!0,r.type),f._bottom=ki(f,o,!1,r.type);let m=f._visualValues||={};m[s]=d}}function ji(e,t){let n=e.scales;return Object.keys(n).filter(e=>n[e].axis===t).shift()}function Mi(e,t){return Zn(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Ni(e,t,n){return Zn(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function Pi(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 Fi=e=>e===`reset`||e===`none`,Ii=(e,t)=>t?e:Object.assign({},e),Li=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Si(n,!0),values:null},Ri=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=Ti(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&&Pi(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=B(n.xAxisID,ji(e,`x`)),a=t.yAxisID=B(n.yAxisID,ji(e,`y`)),o=t.rAxisID=B(n.rAxisID,ji(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&&qt(this._data,this),e._stacked&&Pi(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(L(t)){let e=this._cachedMeta;this._data=wi(t,e)}else if(n!==t){if(n){qt(n,this);let e=this._cachedMeta;Pi(e),e._parsed=[]}t&&Object.isExtensible(t)&&Kt(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=Ti(t.vScale,t),t.stack!==n.stack&&(r=!0,Pi(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Ai(this,t._parsed),t._stacked=Ti(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?!0: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=I(r[e])?this.parseArrayData(n,r,e,t):L(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]<c[o];for(l=0;l<t;++l)n._parsed[l+e]=u=d[l],s&&(i()&&(s=!1),c=u);n._sorted=s}a&&Ai(this,d)}parsePrimitiveData(e,t,n,r){let{iScale:i,vScale:a}=e,o=i.axis,s=a.axis,c=i.getLabels(),l=i===a,u=Array(r),d,f,p;for(d=0,f=r;d<f;++d)p=d+n,u[d]={[o]:l||i.parse(c[p],p),[s]:a.parse(t[p],p)};return u}parseArrayData(e,t,n,r){let{xScale:i,yScale:a}=e,o=Array(r),s,c,l,u;for(s=0,c=r;s<c;++s)l=s+n,u=t[l],o[s]={x:i.parse(u[0],l),y:a.parse(u[1],l)};return o}parseObjectData(e,t,n,r){let{xScale:i,yScale:a}=e,{xAxisKey:o=`x`,yAxisKey:s=`y`}=this._parsing,c=Array(r),l,u,d,f;for(l=0,u=r;l<u;++l)d=l+n,f=t[d],c[l]={x:i.parse(ft(f,o),d),y:a.parse(ft(f,s),d)};return c}getParsed(e){return this._cachedMeta._parsed[e]}getDataElement(e){return this._cachedMeta.data[e]}applyStack(e,t,n){let r=this.chart,i=this._cachedMeta,a=t[e.axis];return Ci({keys:Si(r,!0),values:t._stacks[e.axis]._visualValues},a,i.index,{mode:n})}updateRangeFromParsed(e,t,n,r){let i=n[t.axis],a=i===null?NaN:i,o=r&&n._stacks[t.axis];r&&o&&(r.values=o,a=Ci(r,i,this._cachedMeta.index)),e.min=Math.min(e.min,a),e.max=Math.max(e.max,a)}getMinMax(e,t){let n=this._cachedMeta,r=n._parsed,i=n._sorted&&e===n.iScale,a=r.length,o=this._getOtherScale(e),s=Li(t,n,this.chart),c={min:1/0,max:-1/0},{min:l,max:u}=Di(o),d,f;function p(){f=r[d];let t=f[o.axis];return!R(f[e.axis])||l>t||u<t}for(d=0;d<a&&!(!p()&&(this.updateRangeFromParsed(c,e,f,s),i));++d);if(i){for(d=a-1;d>=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<i;++r)a=t[r][e.axis],R(a)&&n.push(a);return n}getMaxOverflow(){return!1}getLabelAndValue(e){let t=this._cachedMeta,n=t.iScale,r=t.vScale,i=this.getParsed(e);return{label:n?``+n.getLabelForValue(i[n.axis]):``,value:r?``+r.getLabelForValue(i[r.axis]):``}}_update(e){let t=this._cachedMeta;this.update(e||`default`),t._clip=xi(B(this.options.clip,bi(t.xScale,t.yScale,this.getMaxOverflow())))}update(e){}draw(){let e=this._ctx,t=this.chart,n=this._cachedMeta,r=n.data||[],i=t.chartArea,a=[],o=this._drawStart||0,s=this._drawCount||r.length-o,c=this.options.drawActiveElementsOnTop,l;for(n.dataset&&n.dataset.draw(e,i,o,s),l=o;l<o+s;++l){let t=r[l];t.hidden||(t.active&&c?a.push(t):t.draw(e,i))}for(l=0;l<a.length;++l)a[l].draw(e,i)}getStyle(e,t){let n=t?`active`:`default`;return e===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(n):this.resolveDataElementOptions(e||0,n)}getContext(e,t,n){let r=this.getDataset(),i;if(e>=0&&e<this._cachedMeta.data.length){let t=this._cachedMeta.data[e];i=t.$context||=Ni(this.getContext(),e,t),i.parsed=this.getParsed(e),i.raw=r.data[e],i.index=i.dataIndex=e}else i=this.$context||=Mi(this.chart.getContext(),this.index),i.dataset=r,i.index=i.datasetIndex=this.index;return i.active=!!t,i.mode=n,i}resolveDatasetElementOptions(e){return this._resolveElementOptions(this.datasetElementType.id,e)}resolveDataElementOptions(e,t){return this._resolveElementOptions(this.dataElementType.id,t,e)}_resolveElementOptions(e,t=`default`,n){let r=t===`active`,i=this._cachedDataOpts,a=e+`-`+t,o=i[a],s=this.enableOptionSharing&&mt(n);if(o)return Ii(o,s);let c=this.chart.config,l=c.datasetElementScopeKeys(this._type,e),u=r?[`${e}Hover`,`hover`,e,``]:[e,``],d=c.getOptionScopes(this.getDataset(),l),f=Object.keys(Y.elements[e]),p=c.resolveNamedOptions(d,f,()=>this.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Ii(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 gi(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||Fi(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){Fi(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!Fi(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<r&&this._removeElements(i,r-i)}_insertElements(e,t,n=!0){let r=this._cachedMeta,i=r.data,a=e+t,o,s=e=>{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;o<a;++o)i[o]=new this.dataElementType;this._parsing&&s(r._parsed),this.parse(e,t),n&&this.updateElements(i,e,t,`reset`)}updateElements(e,t,n,r){}_removeElements(e,t){let n=this._cachedMeta;if(this._parsing){let r=n._parsed.splice(e,t);n._stacked&&Pi(n,r)}n.data.splice(e,t)}_sync(e){if(this._parsing)this._syncList.push(e);else{let[t,n,r]=e;this[t](n,r)}this.chart._dataChanges.push([this.index,...e])}_onDataPush(){let e=arguments.length;this._sync([`_insertElements`,this.getDataset().data.length-e,e])}_onDataPop(){this._sync([`_removeElements`,this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync([`_removeElements`,0,1])}_onDataSplice(e,t){t&&this._sync([`_removeElements`,e,t]);let n=arguments.length-2;n&&this._sync([`_insertElements`,e,n])}_onDataUnshift(){this._sync([`_insertElements`,0,arguments.length])}},zi=class extends Ri{static id=`line`;static defaults={datasetElementType:`line`,dataElementType:`point`,showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:`category`},_value_:{type:`linear`}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(e){let t=this._cachedMeta,{dataset:n,data:r=[],_dataset:i}=t,a=this.chart._animationsDisabled,{start:o,count:s}=en(t,r,a);this._drawStart=o,this._drawCount=s,tn(t)&&(o=0,s=r.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!i._decimated,n.points=r;let c=this.resolveDatasetElementOptions(e);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(n,void 0,{animated:!a,options:c},e),this.updateElements(r,o,s,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o,_stacked:s,_dataset:c}=this._cachedMeta,{sharedOptions:l,includeOptions:u}=this._getSharedOptions(t,r),d=a.axis,f=o.axis,{spanGaps:p,segment:m}=this.options,h=kt(p)?p:1/0,g=this.chart._animationsDisabled||i||r===`none`,_=t+n,v=e.length,y=t>0&&this.getParsed(t-1);for(let n=0;n<v;++n){let p=e[n],v=g?p:{};if(n<t||n>=_){v.skip=!0;continue}let b=this.getParsed(n),x=F(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()}};function Bi(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var Vi={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return Bi()}parse(){return Bi()}format(){return Bi()}add(){return Bi()}diff(){return Bi()}startOf(){return Bi()}endOf(){return Bi()}}};function Hi(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?Ut:Ht;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=>!F(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!F(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 Ui(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e<n;++e){let{index:n,data:s}=a[e],{lo:c,hi:l}=Hi(a[e],t,o,i);for(let e=c;e<=l;++e){let t=s[e];t.skip||r(t,n,e)}}}function Wi(e){let t=e.indexOf(`x`)!==-1,n=e.indexOf(`y`)!==-1;return function(e,r){let i=t?Math.abs(e.x-r.x):0,a=n?Math.abs(e.y-r.y):0;return Math.sqrt(i**2+a**2)}}function Gi(e,t,n,r,i){let a=[];return!i&&!e.isPointInArea(t)||Ui(e,n,t,function(n,o,s){!i&&!Mn(n,e.chartArea,0)||n.inRange(t.x,t.y,r)&&a.push({element:n,datasetIndex:o,index:s})},!0),a}function Ki(e,t,n,r){let i=[];function a(e,n,a){let{startAngle:o,endAngle:s}=e.getProps([`startAngle`,`endAngle`],r),{angle:c}=Ft(e,{x:t.x,y:t.y});Rt(c,o,s)&&i.push({element:e,datasetIndex:n,index:a})}return Ui(e,n,t,a),i}function qi(e,t,n,r,i,a){let o=[],s=Wi(n),c=1/0;function l(n,l,u){let d=n.inRange(t.x,t.y,i);if(r&&!d)return;let f=n.getCenterPoint(i);if(!(a||e.isPointInArea(f))&&!d)return;let p=s(t,f);p<c?(o=[{element:n,datasetIndex:l,index:u}],c=p):p===c&&o.push({element:n,datasetIndex:l,index:u})}return Ui(e,n,t,l),o}function Ji(e,t,n,r,i,a){return!a&&!e.isPointInArea(t)?[]:n===`r`&&!r?Ki(e,t,n,i):qi(e,t,n,r,i,a)}function Yi(e,t,n,r,i){let a=[],o=n===`x`?`inXRange`:`inYRange`,s=!1;return Ui(e,n,t,(e,r,c)=>{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 Xi={evaluateInteractionItems:Ui,modes:{index(e,t,n,r){let i=Ir(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Gi(e,i,a,r,o):Ji(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=Ir(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Gi(e,i,a,r,o):Ji(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;e<n.length;++e)s.push({element:n[e],datasetIndex:t,index:e})}return s},point(e,t,n,r){return Gi(e,Ir(t,e),n.axis||`xy`,r,n.includeInvisible||!1)},nearest(e,t,n,r){let i=Ir(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1;return Ji(e,i,a,n.intersect,r,o)},x(e,t,n,r){return Yi(e,Ir(t,e),`x`,n.intersect,r)},y(e,t,n,r){return Yi(e,Ir(t,e),`y`,n.intersect,r)}}},Zi=[`left`,`top`,`right`,`bottom`];function Qi(e,t){return e.filter(e=>e.pos===t)}function $i(e,t){return e.filter(e=>Zi.indexOf(e.pos)===-1&&e.box.axis===t)}function ea(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 ta(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;n<r;++n)i=e[n],{position:a,options:{stack:o,stackWeight:s=1}}=i,t.push({index:n,box:i,pos:a,horizontal:i.isHorizontal(),weight:i.weight,stack:o&&a+o,stackWeight:s});return t}function na(e){let t={};for(let n of e){let{stack:e,pos:r,stackWeight:i}=n;if(!e||!Zi.includes(r))continue;let a=t[e]||(t[e]={count:0,placed:0,weight:0,size:0});a.count++,a.weight+=i}return t}function ra(e,t){let n=na(e),{vBoxMaxWidth:r,hBoxMaxHeight:i}=t,a,o,s;for(a=0,o=e.length;a<o;++a){s=e[a];let{fullSize:o}=s.box,c=n[s.stack],l=c&&s.stackWeight/c.weight;s.horizontal?(s.width=l?l*r:o&&t.availableWidth,s.height=i):(s.width=r,s.height=l?l*i:o&&t.availableHeight)}return n}function ia(e){let t=ta(e),n=ea(t.filter(e=>e.box.fullSize),!0),r=ea(Qi(t,`left`),!0),i=ea(Qi(t,`right`)),a=ea(Qi(t,`top`),!0),o=ea(Qi(t,`bottom`)),s=$i(t,`x`),c=$i(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Qi(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function aa(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function oa(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 sa(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!L(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&&oa(o,a.getPadding());let s=Math.max(0,t.outerWidth-aa(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-aa(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 ca(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 la(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 ua(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a<o;++a){s=e[a],c=s.box,c.update(s.width||t.w,s.height||t.h,la(s.horizontal,t));let{same:o,other:d}=sa(t,n,s,r);l|=o&&i.length,u||=d,c.fullSize||i.push(s)}return l&&ua(i,t,n,r)||u}function da(e,t,n,r,i){e.top=n,e.left=t,e.right=t+r,e.bottom=n+i,e.width=r,e.height=i}function fa(e,t,n,r){let i=n.padding,{x:a,y:o}=t;for(let s of e){let e=s.box,c=r[s.stack]||{count:1,placed:0,weight:1},l=s.stackWeight/c.weight||1;if(s.horizontal){let r=t.w*l,a=c.size||e.height;mt(c.start)&&(o=c.start),e.fullSize?da(e,i.left,o,n.outerWidth-i.right-i.left,a):da(e,t.left+c.placed,o,r,a),c.start=o,c.placed+=r,o=e.bottom}else{let r=t.h*l,o=c.size||e.width;mt(c.start)&&(a=c.start),e.fullSize?da(e,a,i.top,o,n.outerHeight-i.bottom-i.top):da(e,a,t.top+c.placed,o,r),c.start=a,c.placed+=r,a=e.right}}t.x=a,t.y=o}var pa={addBox(e,t){e.boxes||=[],t.fullSize=t.fullSize||!1,t.position=t.position||`top`,t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(e){t.draw(e)}}]},e.boxes.push(t)},removeBox(e,t){let n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,r){if(!e)return;let i=X(e.options.layout.padding),a=Math.max(t-i.width,0),o=Math.max(n-i.height,0),s=ia(e.boxes),c=s.vertical,l=s.horizontal;H(e.boxes,e=>{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);oa(f,X(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=ra(c.concat(l),d);ua(s.fullSize,p,d,m),ua(c,p,d,m),ua(l,p,d,m)&&ua(c,p,d,m),ca(p),fa(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,fa(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},H(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})})}},ma=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){}},ha=class extends ma{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},ga=`$chartjs`,_a={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},va=e=>e===null||e===``;function ya(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[ga]={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`,va(i)){let t=Hr(e,`width`);t!==void 0&&(e.width=t)}if(va(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=Hr(e,`height`);t!==void 0&&(e.height=t)}return e}var ba=Vr?{passive:!0}:!1;function xa(e,t,n){e&&e.addEventListener(t,n,ba)}function Sa(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,ba)}function Ca(e,t){let n=_a[e.type]||e.type,{x:r,y:i}=Ir(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function wa(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function Ta(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=wa(n.addedNodes,r),t&&=!wa(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function Ea(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=wa(n.removedNodes,r),t&&=!wa(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var Da=new Map,Oa=0;function ka(){let e=window.devicePixelRatio;e!==Oa&&(Oa=e,Da.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function Aa(e,t){Da.size||window.addEventListener(`resize`,ka),Da.set(e,t)}function ja(e){Da.delete(e),Da.size||window.removeEventListener(`resize`,ka)}function Ma(e,t,n){let r=e.canvas,i=r&&Or(r);if(!i)return;let a=Xt((e,t)=>{let r=i.clientWidth;n(e,t),r<i.clientWidth&&n()},window),o=new ResizeObserver(e=>{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),Aa(e,a),o}function Na(e,t,n){n&&n.disconnect(),t===`resize`&&ja(e)}function Pa(e,t,n){let r=e.canvas,i=Xt(t=>{e.ctx!==null&&n(Ca(t,e))},e);return xa(r,t,i),i}var Fa=class extends ma{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(ya(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[ga])return!1;let n=t[ga].initial;[`height`,`width`].forEach(e=>{let r=n[e];F(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[ga],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:Ta,detach:Ea,resize:Ma}[t]||Pa)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:Na,detach:Na,resize:Na}[t]||Sa)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return zr(e,t,n,r)}isAttached(e){let t=e&&Or(e);return!!(t&&t.isConnected)}};function Ia(e){return!Dr()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?ha:Fa}var La=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 kt(this.x)&&kt(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 Ra(e,t){let n=e.options.ticks,r=za(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?Va(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return Ha(t,l,a,o/i),l;let u=Ba(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Ua(t,l,u,F(r)?0:s-r,s),e=0,n=o-1;e<n;e++)Ua(t,l,u,a[e],a[e+1]);return Ua(t,l,u,c,F(r)?t.length:c+r),l}return Ua(t,l,u),l}function za(e){let t=e.options.offset,n=e._tickSize(),r=e._length/n+ +!t,i=e._maxLength/n;return Math.floor(Math.min(r,i))}function Ba(e,t,n){let r=Wa(e),i=t.length/n;if(!r)return Math.max(i,1);let a=Dt(r);for(let e=0,t=a.length-1;e<t;e++){let t=a[e];if(t>i)return t}return Math.max(i,1)}function Va(e){let t=[],n,r;for(n=0,r=e.length;n<r;n++)e[n].major&&t.push(n);return t}function Ha(e,t,n,r){let i=0,a=n[0],o;for(r=Math.ceil(r),o=0;o<e.length;o++)o===a&&(t.push(e[o]),i++,a=n[i*r])}function Ua(e,t,n,r,i){let a=B(r,0),o=Math.min(B(i,e.length),e.length),s=0,c,l,u;for(n=Math.ceil(n),i&&(c=i-r,n=c/Math.floor(c/n)),u=a;u<0;)s++,u=Math.round(a+s*n);for(l=Math.max(a,0);l<o;l++)l===u&&(t.push(e[l]),s++,u=Math.round(a+s*n))}function Wa(e){let t=e.length,n,r;if(t<2)return!1;for(r=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==r)return!1;return r}var Ga=e=>e===`left`?`right`:e===`right`?`left`:e,Ka=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,qa=(e,t)=>Math.min(t||e,e);function Ja(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;a<i;a+=r)n.push(e[Math.floor(a)]);return n}function Ya(e,t,n){let r=e.ticks.length,i=Math.min(t,r-1),a=e._startPixel,o=e._endPixel,s=1e-6,c=e.getPixelForTick(i),l;if(!(n&&(l=r===1?Math.max(c-a,o-c):t===0?(e.getPixelForTick(1)-c)/2:(c-e.getPixelForTick(i-1))/2,c+=i<t?l:-l,c<a-s||c>o+s)))return c}function Xa(e,t){H(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;i<r;++i)delete e.data[n[i]];n.splice(0,r)}})}function Za(e){return e.drawTicks?e.tickLength:0}function Qa(e,t){if(!e.display)return 0;let n=Z(e.font,t),r=X(e.padding);return(I(e.text)?e.text.length:1)*n.lineHeight+r.height}function $a(e,t){return Zn(e,{scale:t,type:`scale`})}function eo(e,t,n){return Zn(e,{tick:n,index:t,type:`tick`})}function to(e,t,n){let r=Qt(e);return(n&&t!==`right`||!n&&t===`right`)&&(r=Ga(r)),r}function no(e,t,n,r){let{top:i,left:a,bottom:o,right:s,chart:c}=e,{chartArea:l,scales:u}=c,d=0,f,p,m,h=o-i,g=s-a;if(e.isHorizontal()){if(p=J(r,a,s),L(n)){let e=Object.keys(n)[0],r=n[e];m=u[e].getPixelForValue(r)+h-t}else m=n===`center`?(l.bottom+l.top)/2+h-t:Ka(e,n,t);f=s-a}else{if(L(n)){let e=Object.keys(n)[0],r=n[e];p=u[e].getPixelForValue(r)-g+t}else p=n===`center`?(l.left+l.right)/2-g+t:Ka(e,n,t);m=J(r,o,i),d=n===`left`?-G:G}return{titleX:p,titleY:m,maxWidth:f,rotation:d}}var ro=class e extends La{constructor(e){super(),this.id=e.id,this.type=e.type,this.options=void 0,this.ctx=e.ctx,this.chart=e.chart,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._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(e){this.options=e.setContext(this.getContext()),this.axis=e.axis,this._userMin=this.parse(e.min),this._userMax=this.parse(e.max),this._suggestedMin=this.parse(e.suggestedMin),this._suggestedMax=this.parse(e.suggestedMax)}parse(e,t){return e}getUserBounds(){let{_userMin:e,_userMax:t,_suggestedMin:n,_suggestedMax:r}=this;return e=z(e,1/0),t=z(t,-1/0),n=z(n,1/0),r=z(r,-1/0),{min:z(e,n),max:z(t,r),minDefined:R(e),maxDefined:R(t)}}getMinMax(e){let{min:t,max:n,minDefined:r,maxDefined:i}=this.getUserBounds(),a;if(r&&i)return{min:t,max:n};let o=this.getMatchingVisibleMetas();for(let s=0,c=o.length;s<c;++s)a=o[s].controller.getMinMax(this,e),r||(t=Math.min(t,a.min)),i||(n=Math.max(n,a.max));return t=i&&t>n?n:t,n=r&&t>n?t:n,{min:z(t,z(n,t)),max:z(n,z(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(){V(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=Xn(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o<this.ticks.length;this._convertTicksToLabels(s?Ja(this.ticks,o):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),a.display&&(a.autoSkip||a.source===`auto`)&&(this.ticks=Ra(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),s&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let e=this.options.reverse,t,n;this.isHorizontal()?(t=this.left,n=this.right):(t=this.top,n=this.bottom,e=!e),this._startPixel=t,this._endPixel=n,this._reversePixels=e,this._length=n-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){V(this.options.afterUpdate,[this])}beforeSetDimensions(){V(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){V(this.options.afterSetDimensions,[this])}_callHooks(e){this.chart.notifyPlugins(e,this.getContext()),V(this.options[e],[this])}beforeDataLimits(){this._callHooks(`beforeDataLimits`)}determineDataLimits(){}afterDataLimits(){this._callHooks(`afterDataLimits`)}beforeBuildTicks(){this._callHooks(`beforeBuildTicks`)}buildTicks(){return[]}afterBuildTicks(){this._callHooks(`afterBuildTicks`)}beforeTickToLabelConversion(){V(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(e){let t=this.options.ticks,n,r,i;for(n=0,r=e.length;n<r;n++)i=e[n],i.label=V(t.callback,[i.value,n,e],this)}afterTickToLabelConversion(){V(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){V(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){let e=this.options,t=e.ticks,n=qa(this.ticks.length,e.ticks.maxTicksLimit),r=t.minRotation||0,i=t.maxRotation,a=r,o,s,c;if(!this._isVisible()||!t.display||r>=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=q(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-Za(e.grid)-t.padding-Qa(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=Nt(Math.min(Math.asin(q((l.highest.height+6)/o,-1,1)),Math.asin(q(s/c,-1,1))-Math.asin(q(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){V(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){V(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=Qa(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=Za(i)+a):(e.height=this.maxHeight,e.width=Za(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Mt(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(){V(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<n;t++)F(e[t].label)&&(e.splice(t,1),n--,t--);this.afterTickToLabelConversion()}_getLabelSizes(){let e=this._labelSizes;if(!e){let t=this.options.ticks.sampleSize,n=this.ticks;t<n.length&&(n=Ja(n,t)),this._labelSizes=e=this._computeLabelSizes(n,n.length,this.options.ticks.maxTicksLimit)}return e}_computeLabelSizes(e,t,n){let{ctx:r,_longestTextCache:i}=this,a=[],o=[],s=Math.floor(t/qa(t,n)),c=0,l=0,u,d,f,p,m,h,g,_,v,y,b;for(u=0;u<t;u+=s){if(p=e[u].label,m=this._resolveTickFontOptions(u),r.font=h=m.string,g=i[h]=i[h]||{data:{},gc:[]},_=m.lineHeight,v=y=0,!F(p)&&!I(p))v=En(r,g.data,g.gc,v,p),y=_;else if(I(p))for(d=0,f=p.length;d<f;++d)b=p[d],!F(b)&&!I(b)&&(v=En(r,g.data,g.gc,v,b),y+=_);a.push(v),o.push(y),c=Math.max(v,c),l=Math.max(y,l)}Xa(i,t);let x=a.indexOf(c),S=o.indexOf(l),C=e=>({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 zt(this._alignToPixels?On(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&&e<t.length){let n=t[e];return n.$context||=eo(this.getContext(),e,n)}return this.$context||=$a(this.chart.getContext(),this)}_tickSize(){let e=this.options.ticks,t=Mt(this.labelRotation),n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t)),i=this._getLabelSizes(),a=e.autoSkipPadding||0,o=i?i.widest.width+a:0,s=i?i.highest.height+a:0;return this.isHorizontal()?s*n>o*r?o/n:s/r:s*r<o*n?s/n:o/r}_isVisible(){let e=this.options.display;return e===`auto`?this.getMatchingVisibleMetas().length>0:!!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=Za(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return On(n,e,p)},g,_,v,y,b,x,S,C,w,T,E,D;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,T=h(e.top)+m,D=e.bottom;else if(a===`bottom`)g=h(this.top),T=e.top,D=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,E=e.right;else if(a===`right`)g=h(this.left),w=e.left,E=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(L(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}T=e.top,D=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(L(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,E=e.right}let O=B(r.ticks.maxTicksLimit,l),k=Math.max(1,Math.ceil(l/O));for(_=0;_<l;_+=k){let e=this.getContext(_),t=i.setContext(e),r=o.setContext(e),a=t.lineWidth,l=t.color,u=r.dash||[],f=r.dashOffset,p=t.tickWidth,m=t.tickColor,h=t.tickBorderDash||[],g=t.tickBorderDashOffset;v=Ya(this,_,s),v!==void 0&&(y=On(n,v,a),c?b=S=w=E=y:x=C=T=D=y,d.push({tx1:b,ty1:x,tx2:S,ty2:C,x1:w,y1:T,x2:E,y2:D,width:a,color:l,borderDash:u,borderDashOffset:f,tickWidth:p,tickColor:m,tickBorderDash:h,tickBorderDashOffset:g}))}return this._ticksLength=l,this._borderValue=g,d}_computeLabelItems(e){let t=this.axis,n=this.options,{position:r,ticks:i}=n,a=this.isHorizontal(),o=this.ticks,{align:s,crossAlign:c,padding:l,mirror:u}=i,d=Za(n.grid),f=d+l,p=u?-l:f,m=-Mt(this.labelRotation),h=[],g,_,v,y,b,x,S,C,w,T,E,D,O=`middle`;if(r===`top`)x=this.bottom-p,S=this._getXAxisLabelAlignment();else if(r===`bottom`)x=this.top+p,S=this._getXAxisLabelAlignment();else if(r===`left`){let e=this._getYAxisLabelAlignment(d);S=e.textAlign,b=e.x}else if(r===`right`){let e=this._getYAxisLabelAlignment(d);S=e.textAlign,b=e.x}else if(t===`x`){if(r===`center`)x=(e.top+e.bottom)/2+f;else if(L(r)){let e=Object.keys(r)[0],t=r[e];x=this.chart.scales[e].getPixelForValue(t)+f}S=this._getXAxisLabelAlignment()}else if(t===`y`){if(r===`center`)b=(e.left+e.right)/2-f;else if(L(r)){let e=Object.keys(r)[0],t=r[e];b=this.chart.scales[e].getPixelForValue(t)}S=this._getYAxisLabelAlignment(d).textAlign}t===`y`&&(s===`start`?O=`top`:s===`end`&&(O=`bottom`));let k=this._getLabelSizes();for(g=0,_=o.length;g<_;++g){v=o[g],y=v.label;let e=i.setContext(this.getContext(g));C=this.getPixelForTick(g)+i.labelOffset,w=this._resolveTickFontOptions(g),T=w.lineHeight,E=I(y)?y.length:1;let t=E/2,n=e.color,s=e.textStrokeColor,l=e.textStrokeWidth,d=S;a?(b=C,S===`inner`&&(d=g===_-1?this.options.reverse?`left`:`right`:g===0?this.options.reverse?`right`:`left`:`center`),D=r===`top`?c===`near`||m!==0?-E*T+T/2:c===`center`?-k.highest.height/2-t*T+T:-k.highest.height+T/2:c===`near`||m!==0?T/2:c===`center`?k.highest.height/2-t*T:k.highest.height-E*T,u&&(D*=-1),m!==0&&!e.showLabelBackdrop&&(b+=T/2*Math.sin(m))):(x=C,D=(1-E)*T/2);let f;if(e.showLabelBackdrop){let t=X(e.backdropPadding),n=k.heights[g],r=k.widths[g],i=D-t.top,a=0-t.left;switch(O){case`middle`:i-=n/2;break;case`bottom`:i-=n;break}switch(S){case`center`:a-=r/2;break;case`right`:a-=r;break;case`inner`:g===_-1?a-=r:g>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:D,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:O,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Mt(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<a;++i){let e=r[i];t.drawOnChartArea&&o({x:e.x1,y:e.y1},{x:e.x2,y:e.y2},e),t.drawTicks&&o({x:e.tx1,y:e.ty1},{x:e.tx2,y:e.ty2},{color:e.tickColor,width:e.tickWidth,borderDash:e.tickBorderDash,borderDashOffset:e.tickBorderDashOffset})}}drawBorder(){let{chart:e,ctx:t,options:{border:n,grid:r}}=this,i=n.setContext(this.getContext()),a=n.display?i.width:0;if(!a)return;let o=r.setContext(this.getContext(0)).lineWidth,s=this._borderValue,c,l,u,d;this.isHorizontal()?(c=On(e,this.left,a)-a/2,l=On(e,this.right,o)+o/2,u=d=s):(u=On(e,this.top,a)-a/2,d=On(e,this.bottom,o)+o/2,c=l=s),t.save(),t.lineWidth=i.width,t.strokeStyle=i.color,t.beginPath(),t.moveTo(c,u),t.lineTo(l,d),t.stroke(),t.restore()}drawLabels(e){if(!this.options.ticks.display)return;let t=this.ctx,n=this._computeLabelArea();n&&Nn(t,n);let r=this.getLabelItems(e);for(let e of r){let n=e.options,r=e.font,i=e.label,a=e.textOffset;Bn(t,i,0,a,r,n)}n&&Pn(t)}drawTitle(){let{ctx:e,options:{position:t,title:n,reverse:r}}=this;if(!n.display)return;let i=Z(n.font),a=X(n.padding),o=n.align,s=i.lineHeight/2;t===`bottom`||t===`center`||L(t)?(s+=a.bottom,I(n.text)&&(s+=i.lineHeight*(n.text.length-1))):s+=a.top;let{titleX:c,titleY:l,maxWidth:u,rotation:d}=no(this,s,t,o);Bn(e,n.text,0,0,i,{color:n.color,maxWidth:u,rotation:d,textAlign:to(o,t,r),textBaseline:`middle`,translation:[c,l]})}draw(e){this._isVisible()&&(this.drawBackground(),this.drawGrid(e),this.drawBorder(),this.drawTitle(),this.drawLabels(e))}_layers(){let t=this.options,n=t.ticks&&t.ticks.z||0,r=B(t.grid&&t.grid.z,-1),i=B(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==e.prototype.draw?[{z:n,draw:e=>{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<a;++i){let a=t[i];a[n]===this.id&&(!e||a.type===e)&&r.push(a)}return r}_resolveTickFontOptions(e){return Z(this.options.ticks.setContext(this.getContext(e)).font)}_maxDigits(){let e=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/e}},io=class{constructor(e,t,n){this.type=e,this.scope=t,this.override=n,this.items=Object.create(null)}isForType(e){return Object.prototype.isPrototypeOf.call(this.type.prototype,e.prototype)}register(e){let t=Object.getPrototypeOf(e),n;so(t)&&(n=this.register(t));let r=this.items,i=e.id,a=this.scope+`.`+i;if(!i)throw Error(`class does not have id: `+e);return i in r?a:(r[i]=e,ao(e,a,n),this.override&&Y.override(e.id,e.overrides),a)}get(e){return this.items[e]}unregister(e){let t=this.items,n=e.id,r=this.scope;n in t&&delete t[n],r&&n in Y[r]&&(delete Y[r][n],this.override&&delete xn[n])}};function ao(e,t,n){let r=ot(Object.create(null),[n?Y.get(n):{},Y.get(t),e.defaults]);Y.set(t,r),e.defaultRoutes&&oo(t,e.defaultRoutes),e.descriptors&&Y.describe(t,e.descriptors)}function oo(e,t){Object.keys(t).forEach(n=>{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Y.route(a,i,c,s)})}function so(e){return`id`in e&&`defaults`in e}var co=new class{constructor(){this.controllers=new io(Ri,`datasets`,!0),this.elements=new io(La,`elements`),this.plugins=new io(Object,`plugins`),this.scales=new io(ro,`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):H(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=pt(e);V(n[`before`+r],[],n),t[e](n),V(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;t<this._typedRegistries.length;t++){let n=this._typedRegistries[t];if(n.isForType(e))return n}return this.plugins}_get(e,t,n){let r=t.get(e);if(r===void 0)throw Error(`"`+e+`" is not a registered `+n+`.`);return r}},lo=class{constructor(){this._init=void 0}notify(e,t,n,r){if(t===`beforeInit`&&(this._init=this._createDescriptors(e,!0),this._notify(this._init,e,`install`)),this._init===void 0)return;let i=r?this._descriptors(e).filter(r):this._descriptors(e),a=this._notify(i,e,t,n);return t===`afterDestroy`&&(this._notify(i,e,`stop`),this._notify(this._init,e,`uninstall`),this._init=void 0),a}_notify(e,t,n,r){r||={};for(let i of e){let e=i.plugin,a=e[n];if(V(a,[t,r,i.options],e)===!1&&r.cancelable)return!1}return!0}invalidate(){F(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(e){if(this._cache)return this._cache;let t=this._cache=this._createDescriptors(e);return this._notifyStateChanges(e),t}_createDescriptors(e,t){let n=e&&e.config,r=B(n.options&&n.options.plugins,{}),i=uo(n);return r===!1&&!t?[]:po(e,i,r,t)}_notifyStateChanges(e){let t=this._oldCache||[],n=this._cache,r=(e,t)=>e.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 uo(e){let t={},n=[],r=Object.keys(co.plugins.items);for(let e=0;e<r.length;e++)n.push(co.getPlugin(r[e]));let i=e.plugins||[];for(let e=0;e<i.length;e++){let r=i[e];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function fo(e,t){return!t&&e===!1?null:e===!0?{}:e}function po(e,{plugins:t,localIds:n},r,i){let a=[],o=e.getContext();for(let s of t){let t=s.id,c=fo(r[t],i);c!==null&&a.push({plugin:s,options:mo(e.config,{plugin:s,local:n[t]},c,o)})}return a}function mo(e,{plugin:t,local:n},r,i){let a=e.pluginScopeKeys(t),o=e.getOptionScopes(r,a);return n&&t.defaults&&o.push(t.defaults),e.createResolver(o,i,[``],{scriptable:!1,indexable:!1,allKeys:!0})}function ho(e,t){let n=Y.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||`x`}function go(e,t){let n=e;return e===`_index_`?n=t:e===`_value_`&&(n=t===`x`?`y`:`x`),n}function _o(e,t){return e===t?`_index_`:`_value_`}function vo(e){if(e===`x`||e===`y`||e===`r`)return e}function yo(e){if(e===`top`||e===`bottom`)return`x`;if(e===`left`||e===`right`)return`y`}function bo(e,...t){if(vo(e))return e;for(let n of t){let t=n.axis||yo(n.position)||e.length>1&&vo(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function xo(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function So(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 xo(e,`x`,n[0])||xo(e,`y`,n[0])}return{}}function Co(e,t){let n=xn[e.type]||{scales:{}},r=t.scales||{},i=ho(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!L(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=bo(t,o,So(t,e),Y.scales[o.type]),c=_o(s,i),l=n.scales||{};a[t]=st(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||ho(i,t),s=(xn[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=go(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),st(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];st(t,[Y.scales[t.type],Y.scale])}),a}function wo(e){let t=e.options||={};t.plugins=B(t.plugins,{}),t.scales=Co(e,t)}function To(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function Eo(e){return e||={},e.data=To(e.data),wo(e),e}var Do=new Map,Oo=new Set;function ko(e,t){let n=Do.get(e);return n||(n=t(),Do.set(e,n),Oo.add(n)),n}var Ao=(e,t,n)=>{let r=ft(t,n);r!==void 0&&e.add(r)},jo=class{constructor(e){this._config=Eo(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=To(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(),wo(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return ko(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return ko(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return ko(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return ko(`${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=>Ao(s,e,t))),t.forEach(e=>Ao(s,r,e)),t.forEach(e=>Ao(s,xn[i]||{},e)),t.forEach(e=>Ao(s,Y,e)),t.forEach(e=>Ao(s,Sn,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),Oo.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,xn[t]||{},Y.datasets[t]||{},{type:t},Y,Sn]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=Mo(this._resolverCache,e,r),s=a;if(Po(a,t)){i.$shared=!1,n=ht(n)?n():n;let t=this.createResolver(e,n,o);s=$n(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=Mo(this._resolverCache,e,n);return L(t)?$n(i,t,void 0,r):i}};function Mo(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:Qn(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var No=e=>L(e)&&Object.getOwnPropertyNames(e).some(t=>ht(e[t]));function Po(e,t){let{isScriptable:n,isIndexable:r}=er(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(ht(o)||No(o))||a&&I(o))return!0}return!1}var Fo=`4.5.1`,Io=[`top`,`bottom`,`left`,`right`,`chartArea`];function Lo(e,t){return e===`top`||e===`bottom`||Io.indexOf(e)===-1&&t===`x`}function Ro(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function zo(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),V(n&&n.onComplete,[e],t)}function Bo(e){let t=e.chart,n=t.options.animation;V(n&&n.onProgress,[e],t)}function Vo(e){return Dr()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var Ho={},Uo=e=>{let t=Vo(e);return Object.values(Ho).filter(e=>e.canvas===t).pop()};function Wo(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 Go(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var Ko=class{static defaults=Y;static instances=Ho;static overrides=xn;static registry=co;static version=Fo;static getChart=Uo;static register(...e){co.add(...e),qo()}static unregister(...e){co.remove(...e),qo()}constructor(e,t){let n=this.config=new jo(t),r=Vo(e),i=Uo(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||(Ia(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=et(),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 lo,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Zt(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],Ho[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}fi.listen(this,`complete`,zo),fi.listen(this,`progress`,Bo),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return F(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 co}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():Br(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return kn(this.canvas,this.ctx),this}stop(){return fi.stop(this),this}resize(e,t){fi.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,Br(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),V(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){H(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=bo(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),H(i,t=>{let i=t.options,a=i.id,o=bo(a,i),s=B(i.type,t.dtype);(i.position===void 0||Lo(i.position,o)!==Lo(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(co.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),H(r,(e,t)=>{e||delete n[t]}),H(n,e=>{pa.configure(this,e,e.options),pa.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;e<n;++e)this._destroyDatasetMeta(e);e.splice(t,n-t)}this._sortedMetasets=e.slice(0).sort(Ro(`order`,`index`))}_removeUnreferencedMetasets(){let{_metasets:e,data:{datasets:t}}=this;e.length>t.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<r;n++){let r=t[n],i=this.getDatasetMeta(n),a=r.type||this.config.type;if(i.type&&i.type!==a&&(this._destroyDatasetMeta(n),i=this.getDatasetMeta(n)),i.type=a,i.indexAxis=r.indexAxis||ho(a,this.options),i.order=r.order||0,i.index=n,i.label=``+r.label,i.visible=this.isDatasetVisible(n),i.controller)i.controller.updateIndex(n),i.controller.linkScales();else{let t=co.getController(a),{datasetElementType:r,dataElementType:o}=Y.datasets[a];Object.assign(t,{dataElementType:co.getElement(o),datasetElementType:r&&co.getElement(r)}),i.controller=new t(this,n),e.push(i.controller)}}return this._updateMetasets(),e}_resetElements(){H(this.data.datasets,(e,t)=>{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<t;e++){let{controller:t}=this.getDatasetMeta(e),n=!r&&i.indexOf(t)===-1;t.buildOrUpdateElements(n),a=Math.max(+t.getMaxOverflow(),a)}a=this._minPadding=n.layout.autoPadding?a:0,this._updateLayout(a),r||H(i,e=>{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(Ro(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){H(this.scales,e=>{pa.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!gt(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)Wo(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;e<t;e++)if(!gt(r,n(e)))return;return Array.from(r).map(e=>e.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;pa.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],H(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<t;++e)this.getDatasetMeta(e).controller.configure();for(let t=0,n=this.data.datasets.length;t<n;++t)this._updateDataset(t,ht(e)?e({datasetIndex:t}):e);this.notifyPlugins(`afterDatasetsUpdate`,{mode:e})}}_updateDataset(e,t){let n=this.getDatasetMeta(e),r={meta:n,index:e,mode:t,cancelable:!0};this.notifyPlugins(`beforeDatasetUpdate`,r)!==!1&&(n.controller._update(t),r.cancelable=!1,this.notifyPlugins(`afterDatasetUpdate`,r))}render(){this.notifyPlugins(`beforeRender`,{cancelable:!0})!==!1&&(fi.has(this)?this.attached&&!fi.running(this)&&fi.start(this):(this.draw(),zo({chart:this})))}draw(){let e;if(this._resizeBeforeDraw){let{width:e,height:t}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(e,t)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins(`beforeDraw`,{cancelable:!0})===!1)return;let t=this._layers;for(e=0;e<t.length&&t[e].z<=0;++e)t[e].draw(this.chartArea);for(this._drawDatasets();e<t.length;++e)t[e].draw(this.chartArea);this.notifyPlugins(`afterDraw`)}_getSortedDatasetMetas(e){let t=this._sortedMetasets,n=[],r,i;for(r=0,i=t.length;r<i;++r){let i=t[r];(!e||i.visible)&&n.push(i)}return n}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins(`beforeDatasetsDraw`,{cancelable:!0})===!1)return;let e=this.getSortedVisibleDatasetMetas();for(let t=e.length-1;t>=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=di(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&Nn(t,r),e.controller.draw(),r&&Pn(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return Mn(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=Xi.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||=Zn(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);mt(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(),fi.remove(this),e=0,t=this.data.datasets.length;e<t;++e)this._destroyDatasetMeta(e)}destroy(){this.notifyPlugins(`beforeDestroy`);let{canvas:e,ctx:t}=this;this._stop(),this.config.clearCache(),e&&(this.unbindEvents(),kn(e,t),this.platform.releaseContext(t),this.canvas=null,this.ctx=null),delete Ho[this.id],this.notifyPlugins(`afterDestroy`)}toBase64Image(...e){return this.canvas.toDataURL(...e)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){let e=this._listeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};H(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(){H(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},H(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<s;++o){a=e[o];let t=a&&this.getDatasetMeta(a.datasetIndex).controller;t&&t[r+`HoverStyle`](a.element,a.datasetIndex,a.index)}}getActiveElements(){return this._active||[]}setActiveElements(e){let t=this._active||[],n=e.map(({datasetIndex:e,index:t})=>{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});nt(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=_t(e),c=Go(e,this._lastEvent,n,s);n&&(this._lastEvent=null,V(i.onHover,[e,o,this],this),s&&V(i.onClick,[e,o,this],this));let l=!nt(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 qo(){return H(Ko.instances,e=>e._plugins.invalidate())}function Jo(e,t,n=t){e.lineCap=B(n.borderCapStyle,t.borderCapStyle),e.setLineDash(B(n.borderDash,t.borderDash)),e.lineDashOffset=B(n.borderDashOffset,t.borderDashOffset),e.lineJoin=B(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=B(n.borderWidth,t.borderWidth),e.strokeStyle=B(n.borderColor,t.borderColor)}function Yo(e,t,n){e.lineTo(n.x,n.y)}function Xo(e){return e.stepped?Fn:e.tension||e.cubicInterpolationMode===`monotone`?In:Yo}function Zo(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=i<o&&a<o||i>s&&a>s;return{count:r,start:c,loop:t.loop,ilen:l<c&&!u?r+l-c:l-c}}function Qo(e,t,n,r){let{points:i,options:a}=t,{count:o,start:s,loop:c,ilen:l}=Zo(i,n,r),u=Xo(a),{move:d=!0,reverse:f}=r||{},p,m,h;for(p=0;p<=l;++p)m=i[(s+(f?l-p:p))%o],!m.skip&&(d?(e.moveTo(m.x,m.y),d=!1):u(e,h,m,f,a.stepped),h=m);return c&&(m=i[(s+(f?l:0))%o],u(e,h,m,f,a.stepped)),!!c}function $o(e,t,n,r){let i=t.points,{count:a,start:o,ilen:s}=Zo(i,n,r),{move:c=!0,reverse:l}=r||{},u=0,d=0,f,p,m,h,g,_,v=e=>(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?(n<h?h=n:n>g&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function es(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?$o:Qo}function ts(e){return e.stepped?Wr:e.tension||e.cubicInterpolationMode===`monotone`?Gr:Ur}function ns(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Jo(e,t.options),e.stroke(i)}function rs(e,t,n,r){let{segments:i,options:a}=t,o=es(t);for(let s of i)Jo(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var is=typeof Path2D==`function`;function as(e,t,n,r){is&&!t.options.segment?ns(e,t,n,r):rs(e,t,n,r)}var os=class extends La{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;Er(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||=ii(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=ti(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=ts(n),c,l;for(c=0,l=a.length;c<l;++c){let{start:l,end:u}=a[c],d=i[l],f=i[u];if(d===f){o.push(d);continue}let p=s(d,f,Math.abs((r-d[t])/(f[t]-d[t])),n.stepped);p[t]=e[t],o.push(p)}return o.length===1?o[0]:o}pathSegment(e,t,n){return es(this)(e,this,t,n)}path(e,t,n){let r=this.segments,i=es(this),a=this._loop;t||=0,n||=this.points.length-t;for(let o of r)a&=i(e,this,o,{start:t,end:t+n-1});return!!a}draw(e,t,n,r){let i=this.options||{};(this.points||[]).length&&i.borderWidth&&(e.save(),as(e,this,n,r),e.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}};function ss(e,t,n,r){let i=e.options,{[n]:a}=e.getProps([n],r);return Math.abs(t-a)<i.radius+i.hitRadius}var cs=class extends La{static id=`point`;parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:`circle`,radius:3,rotation:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};constructor(e){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,e&&Object.assign(this,e)}inRange(e,t,n){let r=this.options,{x:i,y:a}=this.getProps([`x`,`y`],n);return(e-i)**2+(t-a)**2<(r.hitRadius+r.radius)**2}inXRange(e,t){return ss(this,e,`x`,t)}inYRange(e,t){return ss(this,e,`y`,t)}getCenterPoint(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}size(e){e=e||this.options||{};let t=e.radius||0;t=Math.max(t,t&&e.hoverRadius||0);let n=t&&e.borderWidth||0;return(t+n)*2}draw(e,t){let n=this.options;this.skip||n.radius<.1||!Mn(this,t,this.size(n)/2)||(e.strokeStyle=n.borderColor,e.lineWidth=n.borderWidth,e.fillStyle=n.backgroundColor,An(e,n,this.x,this.y))}getRange(){let e=this.options||{};return e.radius+e.hitRadius}},ls=(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)}},us=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,ds=class extends La{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=V(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=Z(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=ls(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}=fs(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=Jr(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=J(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=J(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=J(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=J(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;Nn(e,this),this._draw(),Pn(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Y.color,s=Jr(e.rtl,this.left,this.width),c=Z(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}=ls(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=B(n.lineWidth,1);if(r.fillStyle=B(n.fillStyle,o),r.lineCap=B(n.lineCap,`butt`),r.lineDashOffset=B(n.lineDashOffset,0),r.lineJoin=B(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=B(n.strokeStyle,o),r.setLineDash(B(n.lineDash,[])),a.usePointStyle)jn(r,{radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},s.xPlus(e,p/2),t+d,a.pointStyleWidth&&p);else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=Jn(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?Vn(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){Bn(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:J(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:J(i,this.top+y+l,this.bottom-t[0].height),line:0},Yr(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;if(s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=J(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=J(i,this.top+y+l,this.bottom-t[f.line].height)),g(s.x(S),C,o),S=$t(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+=hs(o,e)+l}else f.y+=b}),Xr(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=Z(t.font),r=X(t.padding);if(!t.display)return;let i=Jr(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=J(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+J(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=J(o,u,u+d);a.textAlign=i.textAlign(Qt(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,Bn(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=Z(e.font),n=X(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(Bt(e,this.left,this.right)&&Bt(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;n<i.length;++n)if(r=i[n],Bt(e,r.left,r.left+r.width)&&Bt(t,r.top,r.top+r.height))return this.legendItems[n]}return null}handleEvent(e){let t=this.options;if(!gs(e.type,t))return;let n=this._getLegendItemAt(e.x,e.y);if(e.type===`mousemove`||e.type===`mouseout`){let r=this._hoveredItem,i=us(r,n);r&&!i&&V(t.onLeave,[e,r,this],this),this._hoveredItem=n,n&&!i&&V(t.onHover,[e,n,this],this)}else n&&V(t.onClick,[e,n,this],this)}};function fs(e,t,n,r,i){return{itemWidth:ps(r,e,t,n),itemHeight:ms(i,r,t.lineHeight)}}function ps(e,t,n,r){let i=e.text;return i&&typeof i!=`string`&&(i=i.reduce((e,t)=>e.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function ms(e,t,n){let r=e;return typeof t.text!=`string`&&(r=hs(t,n)),r}function hs(e,t){return t*(e.text?e.text.length:0)}function gs(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var _s={id:`legend`,_element:ds,start(e,t,n){let r=e.legend=new ds({ctx:e.ctx,options:n,chart:e});pa.configure(e,r,n),pa.addBox(e,r)},stop(e){pa.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;pa.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=X(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)}}},vs={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;t<n;++t){let n=e[t].element;if(n&&n.hasValue()){let e=n.tooltipPosition();r.add(e.x),i+=e.y,++a}}return a===0||r.size===0?!1:{x:[...r].reduce((e,t)=>e+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<o;++a){let n=e[a].element;if(n&&n.hasValue()){let e=It(t,n.getCenterPoint());e<i&&(i=e,s=n)}}if(s){let e=s.tooltipPosition();n=e.x,r=e.y}return{x:n,y:r}}};function ys(e,t){return t&&(I(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function bs(e){return(typeof e==`string`||e instanceof String)&&e.indexOf(`
2
+ `)>-1?e.split(`
3
+ `):e}function xs(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 Ss(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=Z(t.bodyFont),l=Z(t.titleFont),u=Z(t.footerFont),d=a.length,f=i.length,p=r.length,m=X(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,H(e.title,y),n.font=c.string,H(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,H(r,e=>{H(e.before,y),H(e.lines,y),H(e.after,y)}),v=0,n.font=u.string,H(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function Cs(e,t){let{y:n,height:r}=t;return n<r/2?`top`:n>e.height-r/2?`bottom`:`center`}function ws(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 Ts(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`),ws(l,e,t,n)&&(l=`center`),l}function Es(e,t,n){let r=n.yAlign||t.yAlign||Cs(e,n);return{xAlign:n.xAlign||t.xAlign||Ts(e,t,n,r),yAlign:r}}function Ds(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Os(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function ks(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}=Jn(o),m=Ds(t,s),h=Os(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:q(m,0,r.width-t.width),y:q(h,0,r.height-t.height)}}function As(e,t,n){let r=X(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function js(e){return ys([],bs(e))}function Ms(e,t,n){return Zn(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function Ns(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var Ps={beforeTitle:$e,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<r)return n[t.dataIndex]}return``},afterTitle:$e,beforeBody:$e,beforeLabel:$e,label(e){if(this&&this.options&&this.options.mode===`dataset`)return e.label+`: `+e.formattedValue||e.formattedValue;let t=e.dataset.label||``;t&&(t+=`: `);let n=e.formattedValue;return F(n)||(t+=n),t},labelColor(e){let t=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:t.borderColor,backgroundColor:t.backgroundColor,borderWidth:t.borderWidth,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){let t=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:t.pointStyle,rotation:t.rotation}},afterLabel:$e,afterBody:$e,beforeFooter:$e,footer:$e,afterFooter:$e};function Q(e,t,n,r){let i=e[t].call(n,r);return i===void 0?Ps[t].call(n,r):i}var Fs=class extends La{static positioners=vs;constructor(e){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=e.chart,this.options=e.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(e){this.options=e,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){let e=this._cachedAnimations;if(e)return e;let t=this.chart,n=this.options.setContext(this.getContext()),r=n.enabled&&t.options.animation&&n.animations,i=new gi(this.chart,r);return r._cacheable&&(this._cachedAnimations=Object.freeze(i)),i}getContext(){return this.$context||=Ms(this.chart.getContext(),this,this._tooltipItems)}getTitle(e,t){let{callbacks:n}=t,r=Q(n,`beforeTitle`,this,e),i=Q(n,`title`,this,e),a=Q(n,`afterTitle`,this,e),o=[];return o=ys(o,bs(r)),o=ys(o,bs(i)),o=ys(o,bs(a)),o}getBeforeBody(e,t){return js(Q(t.callbacks,`beforeBody`,this,e))}getBody(e,t){let{callbacks:n}=t,r=[];return H(e,e=>{let t={before:[],lines:[],after:[]},i=Ns(n,e);ys(t.before,bs(Q(i,`beforeLabel`,this,e))),ys(t.lines,Q(i,`label`,this,e)),ys(t.after,bs(Q(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return js(Q(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Q(n,`beforeFooter`,this,e),i=Q(n,`footer`,this,e),a=Q(n,`afterFooter`,this,e),o=[];return o=ys(o,bs(r)),o=ys(o,bs(i)),o=ys(o,bs(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;s<c;++s)o.push(xs(this.chart,t[s]));return e.filter&&(o=o.filter((t,r,i)=>e.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),H(o,t=>{let n=Ns(e.callbacks,t);r.push(Q(n,`labelColor`,this,t)),i.push(Q(n,`labelPointStyle`,this,t)),a.push(Q(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=vs[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=Ss(this,n),o=Object.assign({},e,t),s=Es(this.chart,n,o),c=ks(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}=Jn(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=Jr(n.rtl,this.x,this.width);for(e.x=As(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=Z(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;s<i;++s)t.fillText(r[s],c.x(e.x),e.y+a.lineHeight/2),e.y+=a.lineHeight+o,s+1===i&&(e.y+=n.titleMarginBottom-o)}}_drawColorBox(e,t,n,r,i){let a=this.labelColors[n],o=this.labelPointStyles[n],{boxHeight:s,boxWidth:c}=i,l=Z(i.bodyFont),u=As(this,`left`,i),d=r.x(u),f=s<l.lineHeight?(l.lineHeight-s)/2:0,p=t.y+f;if(i.usePointStyle){let t={radius:Math.min(c,s)/2,pointStyle:o.pointStyle,rotation:o.rotation,borderWidth:1},n=r.leftForLtr(d,c)+c/2,l=p+s/2;e.strokeStyle=i.multiKeyBackground,e.fillStyle=i.multiKeyBackground,An(e,t,n,l),e.strokeStyle=a.borderColor,e.fillStyle=a.backgroundColor,An(e,t,n,l)}else{e.lineWidth=L(a.borderWidth)?Math.max(...Object.values(a.borderWidth)):a.borderWidth||1,e.strokeStyle=a.borderColor,e.setLineDash(a.borderDash||[]),e.lineDashOffset=a.borderDashOffset||0;let t=r.leftForLtr(d,c),n=r.leftForLtr(r.xPlus(d,1),c-2),o=Jn(a.borderRadius);Object.values(o).some(e=>e!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,Vn(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),Vn(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=Z(n.bodyFont),d=u.lineHeight,f=0,p=Jr(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=As(this,h,n),t.fillStyle=n.bodyColor,H(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y<x;++y){for(g=r[y],_=this.labelTextColors[y],t.fillStyle=_,H(g.before,m),v=g.lines,o&&v.length&&(this._drawColorBox(t,e,y,p,n),d=Math.max(u.lineHeight,s)),b=0,S=v.length;b<S;++b)m(v[b]),d=u.lineHeight;H(g.after,m)}f=0,d=u.lineHeight,H(this.afterBody,m),e.y-=i}drawFooter(e,t,n){let r=this.footer,i=r.length,a,o;if(i){let s=Jr(n.rtl,this.x,this.width);for(e.x=As(this,n.footerAlign,n),e.y+=n.footerMarginTop,t.textAlign=s.textAlign(n.footerAlign),t.textBaseline=`middle`,a=Z(n.footerFont),t.fillStyle=n.footerColor,t.font=a.string,o=0;o<i;++o)t.fillText(r[o],s.x(e.x),e.y+a.lineHeight/2),e.y+=a.lineHeight+n.footerSpacing}}drawBackground(e,t,n,r){let{xAlign:i,yAlign:a}=this,{x:o,y:s}=e,{width:c,height:l}=n,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=Jn(r.cornerRadius);t.fillStyle=r.backgroundColor,t.strokeStyle=r.borderColor,t.lineWidth=r.borderWidth,t.beginPath(),t.moveTo(o+u,s),a===`top`&&this.drawCaret(e,t,n,r),t.lineTo(o+c-d,s),t.quadraticCurveTo(o+c,s,o+c,s+d),a===`center`&&i===`right`&&this.drawCaret(e,t,n,r),t.lineTo(o+c,s+l-p),t.quadraticCurveTo(o+c,s+l,o+c-p,s+l),a===`bottom`&&this.drawCaret(e,t,n,r),t.lineTo(o+f,s+l),t.quadraticCurveTo(o,s+l,o,s+l-f),a===`center`&&i===`left`&&this.drawCaret(e,t,n,r),t.lineTo(o,s+u),t.quadraticCurveTo(o,s,o+u,s),t.closePath(),t.fill(),r.borderWidth>0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=vs[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=Ss(this,e),o=Object.assign({},n,this._size),s=Es(t,e,o),c=ks(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=X(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),Yr(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),Xr(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=!nt(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||!nt(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=vs[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Is={id:`tooltip`,_element:Fs,positioners:vs,afterInit(e,t,n){n&&(e.tooltip=new Fs({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:Ps},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`]},Ls=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Rs(e,t,n,r){let i=e.indexOf(t);return i===-1?Ls(e,t,n,r):i===e.lastIndexOf(t)?i:n}var zs=(e,t)=>e===null?null:q(Math.round(e),0,t);function Bs(e){let t=this.getLabels();return e>=0&&e<t.length?t[e]:e}var Vs=class extends ro{static id=`category`;static defaults={ticks:{callback:Bs}};constructor(e){super(e),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(e){let t=this._addedLabels;if(t.length){let e=this.getLabels();for(let{index:n,label:r}of t)e[n]===r&&e.splice(n,1);this._addedLabels=[]}super.init(e)}parse(e,t){if(F(e))return null;let n=this.getLabels();return t=isFinite(t)&&n[t]===e?t:Rs(n,e,B(t,e),this._addedLabels),zs(t,n.length-1)}determineDataLimits(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),{min:n,max:r}=this.getMinMax(!0);this.options.bounds===`ticks`&&(e||(n=0),t||(r=this.getLabels().length-1)),this.min=n,this.max=r}buildTicks(){let e=this.min,t=this.max,n=this.options.offset,r=[],i=this.getLabels();i=e===0&&t===i.length-1?i:i.slice(e,t+1),this._valueRange=Math.max(i.length-+!n,1),this._startValue=this.min-(n?.5:0);for(let n=e;n<=t;n++)r.push({value:n});return r}getLabelForValue(e){return Bs.call(this,e)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(e){return typeof e!=`number`&&(e=this.parse(e)),e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getPixelForTick(e){let t=this.ticks;return e<0||e>t.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 Hs(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=!F(a),_=!F(o),v=!F(c),y=(h-m)/(u+1),b=Et((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=Et(w*b/p/f)*f),F(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&&At((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=Tt(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let T=Math.max(Pt(b),Pt(S));x=10**(F(s)?T:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let E=0;for(g&&(d&&S!==a?(n.push({value:a}),S<a&&E++,Tt(Math.round((S+E*b)*x)/x,a,Us(a,y,e))&&E++):S<a&&E++);E<w;++E){let e=Math.round((S+E*b)*x)/x;if(_&&e>o)break;n.push({value:e})}return _&&d&&C!==o?n.length&&Tt(n[n.length-1].value,o,Us(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Us(e,t,{horizontal:n,minRotation:r}){let i=Mt(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Ws=class extends ro{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 F(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=wt(r),t=wt(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=Hs({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`&&jt(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 gn(e,this.chart.options.locale,this.options.ticks.format)}},Gs=class extends Ws{static id=`linear`;static defaults={ticks:{callback:yn.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=R(e)?e:0,this.max=R(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Mt(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}},Ks=e=>Math.floor(Ct(e)),qs=(e,t)=>10**(Ks(e)+t);function Js(e){return e/10**Ks(e)==1}function Ys(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Xs(e,t){let n=Ks(t-e);for(;Ys(e,t,n)>10;)n++;for(;Ys(e,t,n)<10;)n--;return Math.min(n,Ks(e))}function Zs(e,{min:t,max:n}){t=z(e.min,t);let r=[],i=Ks(t),a=Xs(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=z(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f<n;)r.push({value:f,major:Js(f),significand:d}),d>=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=z(e.max,f);return r.push({value:p,major:Js(p),significand:d}),r}(class extends ro{static id=`logarithmic`;static defaults={ticks:{callback:yn.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=Ws.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return R(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=R(e)?Math.max(0,e):null,this.max=R(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!R(this._userMin)&&(this.min=e===qs(this.min,0)?qs(this.min,-1):qs(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(qs(n,-1)),a(qs(r,1)))),n<=0&&i(qs(r,-1)),r<=0&&a(qs(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Zs({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&jt(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`:gn(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=Ct(e),this._valueRange=Ct(this.max)-Ct(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(Ct(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}});function Qs(e){let t=e.ticks;if(t.display&&e.display){let e=X(t.backdropPadding);return B(t.font&&t.font.size,Y.font.size)+e.height}return 0}function $s(e,t,n){return n=I(n)?n:[n],{w:Dn(e,t.string,n),h:n.length*t.lineHeight}}function ec(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:e<r||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function tc(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?U/a:0;for(let c=0;c<a;c++){let a=o.setContext(e.getPointLabelContext(c));i[c]=a.padding;let l=e.getPointPosition(c,e.drawingArea+i[c],s),u=Z(a.font),d=$s(e.ctx,u,e._pointLabels[c]);r[c]=d;let f=K(e.getIndexAngle(c)+s),p=Math.round(Nt(f));nc(n,t,f,ec(p,l.x,d.w,0,180),ec(p,l.y,d.h,90,270))}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=ac(e,r,i)}function nc(e,t,n,r,i){let a=Math.abs(Math.sin(n)),o=Math.abs(Math.cos(n)),s=0,c=0;r.start<t.l?(s=(t.l-r.start)/a,e.l=Math.min(e.l,t.l-s)):r.end>t.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.start<t.t?(c=(t.t-i.start)/o,e.t=Math.min(e.t,t.t-c)):i.end>t.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function rc(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(Nt(K(c.angle+G))),u=cc(c.y,s.h,l),d=oc(l),f=sc(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 ic(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(Mn({x:n,y:r},t)||Mn({x:n,y:a},t)||Mn({x:i,y:r},t)||Mn({x:i,y:a},t))}function ac(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Qs(a)/2,additionalAngle:o?U/i:0},l;for(let a=0;a<i;a++){c.padding=n[a],c.size=t[a];let i=rc(e,a,c);r.push(i),s===`auto`&&(i.visible=ic(i,l),i.visible&&(l=i))}return r}function oc(e){return e===0||e===180?`center`:e<180?`left`:`right`}function sc(e,t,n){return n===`right`?e-=t:n===`center`&&(e-=t/2),e}function cc(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function lc(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!F(s)){let n=Jn(t.borderRadius),c=X(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(),Vn(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function uc(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));lc(n,a,t);let o=Z(a.font),{x:s,y:c,textAlign:l}=t;Bn(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function dc(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,W);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a<r;a++)n=e.getPointPosition(a,t),i.lineTo(n.x,n.y)}}function fc(e,t,n,r,i){let a=e.ctx,o=t.circular,{color:s,lineWidth:c}=t;!o&&!r||!s||!c||n<0||(a.save(),a.strokeStyle=s,a.lineWidth=c,a.setLineDash(i.dash||[]),a.lineDashOffset=i.dashOffset,a.beginPath(),dc(e,n,o,r),a.closePath(),a.stroke(),a.restore())}function pc(e,t,n){return Zn(e,{label:n,index:t,type:`pointLabel`})}(class extends Ws{static id=`radialLinear`;static defaults={display:!0,animate:!0,position:`chartArea`,angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:yn.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(e){return e},padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":`borderColor`,"pointLabels.color":`color`,"ticks.color":`color`};static descriptors={angleLines:{_fallback:`grid`}};constructor(e){super(e),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let e=this._padding=X(Qs(this.options)/2),t=this.width=this.maxWidth-e.width,n=this.height=this.maxHeight-e.height;this.xCenter=Math.floor(this.left+t/2+e.left),this.yCenter=Math.floor(this.top+n/2+e.top),this.drawingArea=Math.floor(Math.min(t,n)/2)}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!1);this.min=R(e)&&!isNaN(e)?e:0,this.max=R(t)&&!isNaN(t)?t:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Qs(this.options))}generateTickLabels(e){Ws.prototype.generateTickLabels.call(this,e),this._pointLabels=this.getLabels().map((e,t)=>{let n=V(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?tc(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=W/(this._pointLabels.length||1),n=this.options.startAngle||0;return K(e*t+Mt(n))}getDistanceFromCenterForValue(e){if(F(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(F(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<t.length){let n=t[e];return pc(this.getContext(),e,n)}}getPointPosition(e,t,n=0){let r=this.getIndexAngle(e)-G+n;return{x:Math.cos(r)*t+this.xCenter,y:Math.sin(r)*t+this.yCenter,angle:r}}getPointPositionForValue(e,t){return this.getPointPosition(e,this.getDistanceFromCenterForValue(t))}getBasePosition(e){return this.getPointPositionForValue(e||0,this.getBaseValue())}getPointLabelPosition(e){let{left:t,top:n,right:r,bottom:i}=this._pointLabelItems[e];return{left:t,top:n,right:r,bottom:i}}drawBackground(){let{backgroundColor:e,grid:{circular:t}}=this.options;if(e){let n=this.ctx;n.save(),n.beginPath(),dc(this,this.getDistanceFromCenterForValue(this._endValue),t,this._pointLabels.length),n.closePath(),n.fillStyle=e,n.fill(),n.restore()}}drawGrid(){let e=this.ctx,t=this.options,{angleLines:n,grid:r,border:i}=t,a=this._pointLabels.length,o,s,c;if(t.pointLabels.display&&uc(this,a),r.display&&this.ticks.forEach((e,t)=>{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);fc(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=Z(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=X(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}Bn(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}});var mc={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}},$=Object.keys(mc);function hc(e,t){return e-t}function gc(e,t){if(F(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),R(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(kt(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function _c(e,t,n,r){let i=$.length;for(let a=$.indexOf(e);a<i-1;++a){let e=mc[$[a]],i=e.steps?e.steps:2**53-1;if(e.common&&Math.ceil((n-t)/(i*e.size))<=r)return $[a]}return $[i-1]}function vc(e,t,n,r,i){for(let a=$.length-1;a>=$.indexOf(n);a--){let n=$[a];if(mc[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return $[n?$.indexOf(n):0]}function yc(e){for(let t=$.indexOf(e)+1,n=$.length;t<n;++t)if(mc[$[t]].common)return $[t]}function bc(e,t,n){if(!n)e[t]=!0;else if(n.length){let{lo:r,hi:i}=Vt(n,t),a=n[r]>=t?n[r]:n[i];e[a]=!0}}function xc(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 Sc(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o<a;++o)s=t[o],i[s]=o,r.push({value:s,major:!1});return a===0||!n?r:xc(e,r,i,n)}var Cc=class extends ro{static id=`time`;static defaults={bounds:`data`,adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:`millisecond`,displayFormats:{}},ticks:{source:`auto`,callback:!1,major:{enabled:!1}}};constructor(e){super(e),this._cache={data:[],labels:[],all:[]},this._unit=`day`,this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(e,t={}){let n=e.time||={},r=this._adapter=new Vi._date(e.adapters.date);r.init(t),st(n.displayFormats,r.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(e),this._normalized=t.normalized}parse(e,t){return e===void 0?null:gc(this,e)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let e=this.options,t=this._adapter,n=e.time.unit||`day`,{min:r,max:i,minDefined:a,maxDefined:o}=this.getUserBounds();function s(e){!a&&!isNaN(e.min)&&(r=Math.min(r,e.min)),!o&&!isNaN(e.max)&&(i=Math.max(i,e.max))}(!a||!o)&&(s(this._getLabelBounds()),(e.bounds!==`ticks`||e.ticks.source!==`labels`)&&s(this.getMinMax(!1))),r=R(r)&&!isNaN(r)?r:+t.startOf(Date.now(),n),i=R(i)&&!isNaN(i)?i:+t.endOf(Date.now(),n)+1,this.min=Math.min(r,i-1),this.max=Math.max(r+1,i)}_getLabelBounds(){let e=this.getLabelTimestamps(),t=1/0,n=-1/0;return e.length&&(t=e[0],n=e[e.length-1]),{min:t,max:n}}buildTicks(){let e=this.options,t=e.time,n=e.ticks,r=n.source===`labels`?this.getLabelTimestamps():this._generate();e.bounds===`ticks`&&r.length&&(this.min=this._userMin||r[0],this.max=this._userMax||r[r.length-1]);let i=this.min,a=this.max,o=Wt(r,i,a);return this._unit=t.unit||(n.autoSkip?_c(t.minUnit,this.min,this.max,this._getLabelCapacity(i)):vc(this,o.length,t.minUnit,this.min,this.max)),this._majorUnit=!n.major.enabled||this._unit===`year`?void 0:yc(this._unit),this.initOffsets(r),e.reverse&&o.reverse(),Sc(this,o,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(e=>+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=q(t,0,a),n=q(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||_c(i.minUnit,t,n,this._getLabelCapacity(t)),o=B(r.ticks.stepSize,1),s=a===`week`?i.isoWeekday:!1,c=kt(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<n;d=+e.add(d,o,a),f++)bc(l,d,p);return(d===n||r.bounds===`ticks`||f===1)&&bc(l,d,p),Object.keys(l).sort(hc).map(e=>+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 V(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;t<n;++t)r=e[t],r.label=this._tickFormatFunction(r.value,t,e)}getDecimalForValue(e){return e===null?NaN:(e-this.min)/(this.max-this.min)}getPixelForValue(e){let t=this._offsets,n=this.getDecimalForValue(e);return this.getPixelForDecimal((t.start+n)*t.factor)}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return this.min+n*(this.max-this.min)}_getLabelSize(e){let t=this.options.ticks,n=this.ctx.measureText(e).width,r=Mt(this.isHorizontal()?t.maxRotation:t.minRotation),i=Math.cos(r),a=Math.sin(r),o=this._resolveTickFontOptions(0).size;return{w:n*i+o*a,h:n*a+o*i}}_getLabelCapacity(e){let t=this.options.time,n=t.displayFormats,r=n[t.unit]||n.millisecond,i=this._tickFormatFunction(e,0,Sc(this,[e],this._majorUnit),r),a=this._getLabelSize(i),o=Math.floor(this.isHorizontal()?this.width/a.w:this.height/a.h)-1;return o>0?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<n;++t)e=e.concat(r[t].controller.getAllParsedValues(this));return this._cache.data=this.normalize(e)}getLabelTimestamps(){let e=this._cache.labels||[],t,n;if(e.length)return e;let r=this.getLabels();for(t=0,n=r.length;t<n;++t)e.push(gc(this,r[t]));return this._cache.labels=this._normalized?e:this.normalize(e)}normalize(e){return Jt(e.sort(hc))}};function wc(e,t,n){let r=0,i=e.length-1,a,o,s,c;n?(t>=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=Ht(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}=Ht(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}(class extends Cc{static id=`timeseries`;static defaults=Cc.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=wc(t,this.min),this._tableRange=wc(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<o;++a)c=e[a],c>=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;a<o;++a)l=r[a+1],s=r[a-1],c=r[a],Math.round((l+s)/2)!==c&&i.push({time:c,pos:a/(o-1)});return i}_generate(){let e=this.min,t=this.max,n=super.getDataTimestamps();return(!n.includes(e)||!n.length)&&n.splice(0,0,e),(!n.includes(t)||n.length===1)&&n.push(t),n.sort((e,t)=>e-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(wc(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return wc(this._table,n*this._tableRange+this._minPos,!0)}});var Tc={data:{type:Object,required:!0},options:{type:Object,default:()=>({})},plugins:{type:Array,default:()=>[]},datasetIdKey:{type:String,default:`label`},updateMode:{type:String,default:void 0}},Ec={ariaLabel:{type:String},ariaDescribedby:{type:String}},Dc={type:{type:String,required:!0},destroyDelay:{type:Number,default:0},...Tc,...Ec},Oc=(e,t)=>Object.assign(e,t);function kc(e){return x(e)?l(e):e}function Ac(e){return x(arguments.length>1&&arguments[1]!==void 0?arguments[1]:e)?new Proxy(e,{}):e}function jc(e,t){let n=e.options;n&&t&&Object.assign(n,t)}function Mc(e,t){e.labels=t}function Nc(e,t,n){let r=[];e.datasets=t.map(t=>{let i=e.datasets.find(e=>e[n]===t[n]);return!i||!t.data||r.includes(i)?{...t}:(r.push(i),Object.assign(i,t),i)})}function Pc(e,t){let n={labels:[],datasets:[]};return Mc(n,e.labels),Nc(n,e.datasets,t),n}var Fc=E({props:Dc,setup(e,t){let{expose:n,slots:i}=t,a=u(null),s=o(null);n({chart:s});let c=()=>{if(!a.value)return;let{type:t,data:n,options:r,plugins:i,datasetIdKey:o}=e,c=Ac(Pc(n,o),n);s.value=new Ko(a.value,{type:t,data:c,options:{...r},plugins:i})},d=()=>{let t=l(s.value);t&&(e.destroyDelay>0?setTimeout(()=>{t.destroy(),s.value=null},e.destroyDelay):(t.destroy(),s.value=null))},f=t=>{t.update(e.updateMode)};return h(c),_(d),r([()=>e.options,()=>e.data],(t,n)=>{let[r,i]=t,[a,o]=n,c=l(s.value);if(!c)return;let u=!1;if(r){let e=kc(r),t=kc(a);e&&e!==t&&(jc(c,e),u=!0)}if(i){let t=kc(i.labels),n=kc(o.labels),r=kc(i.datasets),a=kc(o.datasets);t!==n&&(Mc(c.config.data,t),u=!0),r&&r!==a&&(Nc(c.config.data,r,e.datasetIdKey),u=!0)}u&&S(()=>{f(c)})},{deep:!0}),()=>y(`canvas`,{role:`img`,"aria-label":e.ariaLabel,"aria-describedby":e.ariaDescribedby,ref:a},[y(`p`,{},[i.default?i.default():``])])}});function Ic(e,t){return Ko.register(t),E({props:Tc,setup(t,n){let{expose:r}=n,i=o(null),a=e=>{i.value=e?.chart};return r({chart:i}),()=>y(Fc,Oc({ref:a},{type:e,...t}))}})}var Lc=Ic(`line`,zi),Rc=1e3,zc=86400,Bc=zc*Rc,Vc=4,Hc=60,Uc=10,Wc={"1h":3600,"5h":18e3,"6h":21600,"24h":86400,"7d":604800,"30d":2592e3,window:18e3,weekly:604800,monthly:2592e3};function Gc(e){return Math.max(Hc,Math.round(e/Uc))}var Kc=zc,qc=5,Jc=new Set([`7d`,`30d`,`weekly`,`monthly`]);function Yc(e){return e*Rc}function Xc(e,t,n){return t!=null&&n!=null?n-t>Vc*Bc?`day`:`time`:Jc.has(e)?`day`:`time`}function Zc(e,t){return t===`day`?re(e):oe(e)}function Qc(e,t,n){let r=Wc[t]??Kc,i=Yc(Gc(n?(k(n.endTime).getTime()-k(n.startTime).getTime())/Rc:r)),a,o;if(n)a=Math.floor(k(n.startTime).getTime()/i)*i,o=Math.ceil(k(n.endTime).getTime()/i)*i;else{let e=Wc[t]??Kc,n=Math.floor(new Date().getTime()/i)*i;a=n-e*Rc,o=n}let s=Math.round((o-a)/i),c=Xc(t,a,o),l=new Map;for(let t of e){let e=k(t.time_bucket),n=Math.floor(e.getTime()/i);l.set(n,t)}let u=[],d=[];for(let e=0;e<=s;e++){let t=a+e*i;u.push(Zc(new Date(t),c));let n=l.get(Math.floor(t/i));d.push(n&&n.avg_value!=null?n.avg_value:0)}return{labels:u,values:d}}function $c(e){let t=new Set;if(e<=qc){for(let n=0;n<e;n++)t.add(n);return t}for(let n=0;n<qc;n++)t.add(Math.round(n*(e-1)/(qc-1)));return t}function el(e){return function(t){let n=typeof t==`number`?t:parseInt(t,10);return e.has(n)?this.getLabelForValue(n):``}}function tl(){return document.documentElement.classList.contains(`dark`)}function nl(){let e=tl();return{gridColor:e?`oklch(1 0 0 / 10%)`:`oklch(0.922 0 0)`,tickColor:e?`oklch(0.708 0 0)`:`oklch(0.556 0 0)`}}function rl(e,t){let n=$c(t.length),r=nl();return{responsive:!0,maintainAspectRatio:!1,interaction:{mode:`index`,intersect:!1},plugins:{legend:{display:!1},tooltip:{callbacks:{label:t=>`${t.parsed.y} ${e}`}}},scales:{x:{display:!0,grid:{display:!1},ticks:{maxRotation:0,autoSkip:!1,callback:el(n),color:r.tickColor}},y:{display:!0,beginAtZero:!0,grid:{color:r.gridColor},ticks:{color:r.tickColor}}}}}var il={teal:`oklch(0.58 0.14 175)`,tealFill:`oklch(0.58 0.14 175 / 0.3)`,tealFillLight:`oklch(0.58 0.14 175 / 0.1)`,indigo:`oklch(0.65 0.14 260)`,indigoFill:`oklch(0.65 0.14 260 / 0.3)`,green:`oklch(0.65 0.17 150)`,amber:`oklch(0.78 0.16 80)`,amberFill:`oklch(0.78 0.16 80 / 0.1)`};function al(e){return e.includes(`T`)?`${e}:00.000Z`:`${e}T00:00:00.000Z`}function ol(e){return e.includes(`T`)?`${e}:59.999Z`:`${e}T23:59:59.999Z`}function sl(){let{t:e}=f(),n=u([]),i=u(``),a=s(()=>[...n.value].sort((e,t)=>{let n=A.value[e.id]??0;return(A.value[t.id]??0)-n})),o=u(`window`),c=u(``),l=u(``),d=u(`all`),p=u(`all`),m=u(`all`),g=u([]),v=u([]),y=s(()=>{if(i.value){let e=n.value.find(e=>e.id===i.value);if(e){let t=new Set(e.models.map(e=>e.name));return g.value.filter(e=>t.has(e))}}return g.value}),x=s(()=>{let e=O.value.startTime,t=O.value.endTime;if(!e||!t)return`—`;try{return`${te(e)} ~ ${te(t)}`}catch{return`—`}}),S=s(()=>{if(o.value===`custom`&&c.value)return al(c.value)}),C=s(()=>{if(o.value===`custom`&&l.value)return ol(l.value)}),w=s(()=>{let e={};return o.value===`custom`?S.value&&C.value&&(e.start_time=S.value,e.end_time=C.value):e.period=o.value,i.value&&(e.provider_id=i.value),d.value!==`all`&&(e.backend_model=d.value),p.value!==`all`&&(e.router_key_id=p.value),e}),T=s(()=>{let e={};return o.value===`custom`?S.value&&C.value&&(e.start_time=S.value,e.end_time=C.value):e.period=o.value,i.value&&(e.provider_id=i.value),d.value!==`all`&&(e.backend_model=d.value),p.value!==`all`&&(e.router_key_id=p.value),m.value!==`all`&&(e.client_type=m.value),e}),E=s(()=>o.value===`custom`&&S.value&&C.value?`monthly`:o.value);function D(e){let t={metric:e};return o.value===`custom`?S.value&&C.value&&(t.start_time=S.value,t.end_time=C.value):t.period=o.value,i.value&&(t.provider_id=i.value),d.value!==`all`&&(t.backend_model=d.value),p.value!==`all`&&(t.router_key_id=p.value),t}let O=u({totalRequests:0,successRate:0,avgTps:0,totalInputTokens:0,totalOutputTokens:0,startTime:null,endTime:null}),k=u(0),ee=u({}),ne=u(null),re=u(null),ae=u(null),oe=u(!1),A=u({});function j(e,t,n){return{labels:e.labels,datasets:[{label:t,data:e.values,borderColor:n,backgroundColor:n.replace(`)`,` / 0.1)`),fill:!1,tension:.4,pointRadius:0}]}}async function ce(){try{n.value=await b.getProviders()}catch(n){console.error(`Failed to load providers:`,n),se.error(t(n,e(`dashboard.loadProvidersFailed`)))}}async function le(){try{let[e,t]=await Promise.allSettled([b.getAvailableModels(),b.getRouterKeys()]);e.status===`fulfilled`&&(g.value=e.value),t.status===`fulfilled`&&(v.value=t.value)}catch(n){console.error(`Failed to load filter options:`,n),se.error(t(n,e(`dashboard.loadFilterFailed`)))}}async function ue(){if(n.value.length===0||o.value===`custom`&&!(S.value&&C.value))return;let r={...w.value};delete r.provider_id,delete r.backend_model,delete r.router_key_id;try{let e=await b.getMetricsSummary(r),t={};if(e.rows&&Array.isArray(e.rows))for(let n of e.rows)n.provider_id&&(t[n.provider_id]=n.total_output_tokens||0);if(A.value=t,Object.keys(t).length>0&&!i.value){let e=a.value[0];e&&(i.value=e.id)}}catch(n){console.error(`Failed to load output tokens:`,n),se.error(t(n,e(`dashboard.loadOutputTokensFailed`)))}}async function M(){if(!i.value||o.value===`custom`&&!(S.value&&C.value))return;let n=de.value;if(!(n===me&&Date.now()-P<pe)){oe.value=!0;try{let[t,n,r,i,a]=await Promise.allSettled([b.getStats(w.value),b.getMetricsTimeseries(D(`total_tps`)),b.getMetricsTimeseries(D(`input_tokens`)),b.getMetricsTimeseries(D(`output_tokens`)),b.getMetricsSummary(T.value)]),o=e=>e.status===`fulfilled`;o(t)&&(O.value=t.value);let s=E.value,c=O.value.startTime&&O.value.endTime?{startTime:O.value.startTime,endTime:O.value.endTime}:void 0;o(n)&&n.value.length>0?ne.value=j(Qc(n.value,s,c),e(`dashboard.charts.tokenOutputSpeed`),il.indigo):ne.value=null,o(r)&&r.value.length>0?re.value=j(Qc(r.value,s,c),e(`dashboard.charts.tokenInputTotal`),il.teal):re.value=null,o(i)&&i.value.length>0?ae.value=j(Qc(i.value,s,c),e(`dashboard.charts.tokenOutputTotal`),il.green):ae.value=null,o(a)&&(k.value=a.value.cache_hit_rate,ee.value=a.value.client_type_breakdown)}catch(n){console.error(`Failed to load dashboard:`,n),se.error(t(n,e(`dashboard.loadDashboardFailed`)))}finally{oe.value=!1,me=n,P=Date.now()}}}let de=s(()=>JSON.stringify({periodTab:o.value,selectedProvider:i.value,modelFilter:d.value,keyFilter:p.value,clientType:m.value,customStart:c.value,customEnd:l.value}));r(o,()=>{o.value!==`custom`&&(c.value=``,l.value=``)}),r(i,()=>{d.value!==`all`&&!y.value.includes(d.value)&&(d.value=`all`)});let N=null;r(de,()=>{N&&clearTimeout(N),N=setTimeout(()=>M(),fe)}),r(o,()=>{n.value.length>0&&ue()});let fe=300,pe=5e3,me=``,P=0,he=null;return h(async()=>{await ce(),await le(),n.value.length>0&&await ue(),await M(),he=ie(()=>M())}),_(()=>{N&&clearTimeout(N),he&&he()}),{providers:n,selectedProvider:i,sortedProviders:a,periodTab:o,customStart:c,customEnd:l,modelFilter:d,keyFilter:p,clientType:m,modelOptions:y,keyOptions:v,timeRangeText:x,stats:O,loading:oe,cacheHitRate:k,clientTypeBreakdown:ee,tpsChartData:ne,inputTokensChartData:re,outputTokensChartData:ae}}var cl={class:`p-6`},ll={class:`flex items-center justify-between mb-4`},ul={class:`text-lg font-semibold text-foreground`},dl={class:`flex gap-1`},fl={class:`flex gap-1 mb-4`},pl={class:`flex items-center gap-2 mb-4 text-sm text-muted-foreground`},ml={key:1},hl={class:`flex items-center gap-3 mb-4`},gl={key:0,class:`text-center text-muted-foreground py-20`},_l={class:`grid grid-cols-6 gap-3 mb-6`},vl={class:`text-sm text-muted-foreground`},yl={class:`text-2xl font-bold text-foreground mt-1`},bl={class:`text-sm text-muted-foreground`},xl={class:`text-2xl font-bold text-success mt-1`},Sl={class:`text-sm text-muted-foreground`},Cl={class:`text-2xl font-bold text-foreground mt-1`},wl={class:`text-sm text-muted-foreground`},Tl={class:`text-2xl font-bold text-foreground mt-1`},El={class:`text-sm text-muted-foreground`},Dl={class:`text-2xl font-bold text-foreground mt-1`},Ol={class:`text-sm text-muted-foreground`},kl={class:`text-2xl font-bold text-primary mt-1`},Al={key:1,class:`text-base font-normal text-muted-foreground`},jl={class:`grid grid-cols-1 lg:grid-cols-3 gap-4 mb-6`},Ml={class:`h-56`},Nl={key:1,class:`flex items-center justify-center h-full text-muted-foreground text-sm`},Pl={class:`h-56`},Fl={key:1,class:`flex items-center justify-center h-full text-muted-foreground text-sm`},Il={class:`h-56`},Ll={key:1,class:`flex items-center justify-center h-full text-muted-foreground text-sm`},Rl=E({__name:`Dashboard`,setup(t){Ko.register(Vs,Gs,cs,os,Is,_s);let{sortedProviders:r,selectedProvider:o,periodTab:l,customStart:u,customEnd:h,modelFilter:_,keyFilter:y,clientType:b,modelOptions:x,keyOptions:S,timeRangeText:E,stats:k,loading:te,cacheHitRate:re,tpsChartData:ie,inputTokensChartData:oe,outputTokensChartData:se}=sl(),{t:M}=f(),de=s(()=>[{label:M(`dashboard.period.last5Hours`),value:`window`},{label:M(`dashboard.period.weekly`),value:`weekly`},{label:M(`dashboard.period.monthly`),value:`monthly`},{label:M(`dashboard.period.custom`),value:`custom`}]);function N(e){return rl(``,e)}return(t,s)=>(w(),d(`div`,cl,[m(`div`,ll,[m(`h2`,ul,T(a(M)(`dashboard.title`)),1),m(`div`,dl,[(w(!0),d(c,null,v(a(r),t=>(w(),p(a(C),{key:t.id,variant:a(o)===t.id?`default`:`ghost`,size:`sm`,onClick:e=>o.value=t.id},{default:i(()=>[e(T(t.name),1)]),_:2},1032,[`variant`,`onClick`]))),128))])]),m(`div`,fl,[(w(!0),d(c,null,v(de.value,t=>(w(),p(a(C),{key:t.value,variant:a(l)===t.value?`default`:`ghost`,size:`sm`,onClick:e=>l.value=t.value},{default:i(()=>[e(T(t.label),1)]),_:2},1032,[`variant`,`onClick`]))),128))]),m(`div`,pl,[a(l)===`custom`?(w(),d(c,{key:0},[g(a(ue),{type:`datetime-local`,modelValue:a(u),"onUpdate:modelValue":s[0]||=e=>n(u)?u.value=e:null,class:`w-44`},null,8,[`modelValue`]),s[5]||=m(`span`,null,`~`,-1),g(a(ue),{type:`datetime-local`,modelValue:a(h),"onUpdate:modelValue":s[1]||=e=>n(h)?h.value=e:null,class:`w-44`},null,8,[`modelValue`])],64)):(w(),d(`span`,ml,`⏱ `+T(a(E)),1))]),m(`div`,hl,[g(a(O),{modelValue:a(_),"onUpdate:modelValue":s[2]||=e=>n(_)?_.value=e:null},{default:i(()=>[g(a(ae),{class:`w-44`},{default:i(()=>[g(a(D),{placeholder:a(M)(`common.allModels`)},null,8,[`placeholder`])]),_:1}),g(a(ee),null,{default:i(()=>[g(a(ne),{value:`all`},{default:i(()=>[e(T(a(M)(`common.allModels`)),1)]),_:1}),(w(!0),d(c,null,v(a(x),t=>(w(),p(a(ne),{key:t,value:t},{default:i(()=>[e(T(t),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`modelValue`]),g(a(O),{modelValue:a(y),"onUpdate:modelValue":s[3]||=e=>n(y)?y.value=e:null},{default:i(()=>[g(a(ae),{class:`w-48`},{default:i(()=>[g(a(D),{placeholder:a(M)(`common.allKeys`)},null,8,[`placeholder`])]),_:1}),g(a(ee),null,{default:i(()=>[g(a(ne),{value:`all`},{default:i(()=>[e(T(a(M)(`common.allKeys`)),1)]),_:1}),(w(!0),d(c,null,v(a(S),t=>(w(),p(a(ne),{key:t.id,value:t.id},{default:i(()=>[e(T(t.name),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`modelValue`]),g(a(O),{modelValue:a(b),"onUpdate:modelValue":s[4]||=e=>n(b)?b.value=e:null},{default:i(()=>[g(a(ae),{class:`w-40`},{default:i(()=>[g(a(D),{placeholder:a(M)(`dashboard.clientType.all`)},null,8,[`placeholder`])]),_:1}),g(a(ee),null,{default:i(()=>[g(a(ne),{value:`all`},{default:i(()=>[e(T(a(M)(`dashboard.clientType.all`)),1)]),_:1}),g(a(ne),{value:`claude-code`},{default:i(()=>[e(T(a(M)(`dashboard.clientType.claude-code`)),1)]),_:1}),g(a(ne),{value:`pi`},{default:i(()=>[e(T(a(M)(`dashboard.clientType.pi`)),1)]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),a(te)?(w(),d(`div`,gl,T(a(M)(`common.loading`)),1)):(w(),d(c,{key:1},[m(`div`,_l,[g(a(A),null,{default:i(()=>[g(a(j),{class:`p-4`},{default:i(()=>[m(`p`,vl,T(a(M)(`dashboard.stats.totalRequests`)),1),m(`p`,yl,T(a(k).totalRequests.toLocaleString()),1)]),_:1})]),_:1}),g(a(A),null,{default:i(()=>[g(a(j),{class:`p-4`},{default:i(()=>[m(`p`,bl,T(a(M)(`dashboard.stats.successRate`)),1),m(`p`,xl,T((a(k).successRate*100).toFixed(1))+`%`,1)]),_:1})]),_:1}),g(a(A),null,{default:i(()=>[g(a(j),{class:`p-4`},{default:i(()=>[m(`p`,Sl,T(a(M)(`dashboard.stats.tokenOutputSpeed`)),1),m(`p`,Cl,[e(T(a(k).avgTps.toFixed(1))+` `,1),s[6]||=m(`span`,{class:`text-sm font-normal text-muted-foreground`},`t/s`,-1)])]),_:1})]),_:1}),g(a(A),null,{default:i(()=>[g(a(j),{class:`p-4`},{default:i(()=>[m(`p`,wl,T(a(M)(`dashboard.stats.tokenInputTotal`)),1),m(`p`,Tl,T(a(k).totalInputTokens.toLocaleString()),1)]),_:1})]),_:1}),g(a(A),null,{default:i(()=>[g(a(j),{class:`p-4`},{default:i(()=>[m(`p`,El,T(a(M)(`dashboard.stats.tokenOutputTotal`)),1),m(`p`,Dl,T(a(k).totalOutputTokens.toLocaleString()),1)]),_:1})]),_:1}),g(a(A),null,{default:i(()=>[g(a(j),{class:`p-4`},{default:i(()=>[m(`p`,Ol,T(a(M)(`dashboard.stats.cacheHitRate`)),1),m(`p`,kl,[a(k).totalInputTokens>0?(w(),d(c,{key:0},[e(T(a(re).toFixed(1))+`% `,1)],64)):(w(),d(`span`,Al,T(a(M)(`dashboard.noCacheData`)),1))])]),_:1})]),_:1})]),m(`div`,jl,[g(a(A),null,{default:i(()=>[g(a(ce),null,{default:i(()=>[g(a(le),{class:`text-sm font-medium text-foreground`},{default:i(()=>[e(T(a(M)(`dashboard.charts.tokenOutputSpeed`)),1)]),_:1})]),_:1}),g(a(j),null,{default:i(()=>[m(`div`,Ml,[a(ie)?(w(),p(a(Lc),{key:`tps-`+a(l)+`-`+a(o),data:a(ie),options:N(a(ie).labels)},null,8,[`data`,`options`])):(w(),d(`div`,Nl,T(a(M)(`common.noData`)),1))])]),_:1})]),_:1}),g(a(A),null,{default:i(()=>[g(a(ce),null,{default:i(()=>[g(a(le),{class:`text-sm font-medium text-foreground`},{default:i(()=>[e(T(a(M)(`dashboard.charts.tokenInputTotal`)),1)]),_:1})]),_:1}),g(a(j),null,{default:i(()=>[m(`div`,Pl,[a(oe)?(w(),p(a(Lc),{key:`input-`+a(l)+`-`+a(o),data:a(oe),options:N(a(oe).labels)},null,8,[`data`,`options`])):(w(),d(`div`,Fl,T(a(M)(`common.noData`)),1))])]),_:1})]),_:1}),g(a(A),null,{default:i(()=>[g(a(ce),null,{default:i(()=>[g(a(le),{class:`text-sm font-medium text-foreground`},{default:i(()=>[e(T(a(M)(`dashboard.charts.tokenOutputTotal`)),1)]),_:1})]),_:1}),g(a(j),null,{default:i(()=>[m(`div`,Il,[a(se)?(w(),p(a(Lc),{key:`output-`+a(l)+`-`+a(o),data:a(se),options:N(a(se).labels)},null,8,[`data`,`options`])):(w(),d(`div`,Ll,T(a(M)(`common.noData`)),1))])]),_:1})]),_:1})])],64))]))}});export{Rl as default};
@@ -1 +1 @@
1
- import{Et as e,H as t,Ut as n,Vt as r,Z as i,et as a,ft as o,kt as s,m as c,r as l}from"./button-C7HO6Dyb.js";var u=a({__name:`Input`,props:{defaultValue:{},modelValue:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(a,{emit:u}){let d=a,f=c(d,`modelValue`,u,{passive:!0,defaultValue:d.defaultValue});return(a,c)=>e((o(),i(`input`,{"onUpdate:modelValue":c[0]||=e=>s(f)?f.value=e:null,"data-slot":`input`,class:n(r(l)(`dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 md:text-sm w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,d.class))},null,2)),[[t,r(f)]])}});export{u as t};
1
+ import{At as e,Dt as t,Ht as n,Q as r,U as i,Wt as a,m as o,pt as s,r as c,tt as l}from"./button-DZwflOXO.js";var u=l({__name:`Input`,props:{defaultValue:{},modelValue:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(l,{emit:u}){let d=l,f=o(d,`modelValue`,u,{passive:!0,defaultValue:d.defaultValue});return(o,l)=>t((s(),r(`input`,{"onUpdate:modelValue":l[0]||=t=>e(f)?f.value=t:null,"data-slot":`input`,class:a(n(c)(`dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 md:text-sm w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,d.class))},null,2)),[[i,n(f)]])}});export{u as t};
@@ -0,0 +1 @@
1
+ import{Et as e,Ht as t,X as n,ct as r,gt as i,i as a,o,pt as s,r as c,tt as l,x as u}from"./button-DZwflOXO.js";var d=l({__name:`Label`,props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`label`}},setup(c){let l=c;return o(),(o,c)=>(s(),n(t(a),r(l,{onMousedown:c[0]||=e=>{!e.defaultPrevented&&e.detail>1&&e.preventDefault()}}),{default:e(()=>[i(o.$slots,`default`)]),_:3},16))}}),f=l({__name:`Label`,props:{for:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(a){let o=a,l=u(o,`class`);return(a,u)=>(s(),n(t(d),r({"data-slot":`label`},t(l),{class:t(c)(`gap-2 text-sm leading-none font-medium group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed`,o.class)}),{default:e(()=>[i(a.$slots,`default`)]),_:3},16,[`class`]))}});export{f as t};
@@ -0,0 +1 @@
1
+ import{$ as e,A as t,B as n,Et as r,G as i,Ht as a,Pt as o,Q as s,R as c,X as l,Y as u,Z as d,et as f,k as p,n as m,pt as h,qt as g,tt as _}from"./button-DZwflOXO.js";import{t as v}from"./Label-CjUuzGNQ.js";import{ot as y,st as b,t as x}from"./index-PMAQyWJb.js";import{n as S,t as C}from"./CardContent-yiYaxAko.js";import{t as w}from"./Input-DEfnoFS3.js";var T={class:`min-h-screen flex items-center justify-center bg-background relative`},E={class:`text-center mb-6`},D={class:`text-sm text-muted-foreground mt-1`},O={key:0,class:`text-destructive text-sm`},k=_({__name:`Login`,setup(_){let{t:k}=c(),{isDark:A,toggleTheme:j}=x(),M=n(),N=o(``),P=o(``),F=o(!1);async function I(){if(N.value){P.value=``,F.value=!0;try{await p.login(N.value),M.push(`/`)}catch(e){console.error(`login:`,e),P.value=t(e,k(`login.loginFailed`))}finally{F.value=!1}}}return(t,n)=>(h(),s(`div`,T,[f(a(m),{variant:`ghost`,size:`icon`,class:`absolute top-4 right-4 text-muted-foreground hover:text-foreground`,onClick:a(j)},{default:r(()=>[a(A)?(h(),l(a(y),{key:1,class:`w-4 h-4`})):(h(),l(a(b),{key:0,class:`w-4 h-4`}))]),_:1},8,[`onClick`]),f(a(S),{class:`w-full max-w-sm shadow-lg`},{default:r(()=>[f(a(C),{class:`pt-6`},{default:r(()=>[u(`div`,E,[n[1]||=u(`div`,{class:`w-12 h-12 bg-primary rounded-lg mx-auto mb-3 flex items-center justify-center`},[u(`svg`,{class:`w-7 h-7 text-white`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[u(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z`})])],-1),n[2]||=u(`h1`,{class:`text-xl font-semibold text-foreground`},`LLM Simple Router`,-1),u(`p`,D,g(a(k)(`login.subtitle`)),1)]),u(`form`,{onSubmit:i(I,[`prevent`]),class:`space-y-4`},[u(`div`,null,[f(a(v),{class:`block text-sm font-medium text-foreground mb-1`},{default:r(()=>[e(g(a(k)(`login.password`)),1)]),_:1}),f(a(w),{modelValue:N.value,"onUpdate:modelValue":n[0]||=e=>N.value=e,type:`password`,placeholder:a(k)(`login.passwordPlaceholder`),disabled:F.value},null,8,[`modelValue`,`placeholder`,`disabled`])]),P.value?(h(),s(`p`,O,g(P.value),1)):d(``,!0),f(a(m),{type:`submit`,class:`w-full`,disabled:F.value},{default:r(()=>[e(g(F.value?a(k)(`login.loggingIn`):a(k)(`login.loginButton`)),1)]),_:1},8,[`disabled`])],32)]),_:1})]),_:1})]))}});export{k as default};
@@ -0,0 +1 @@
1
+ import{$ as e,A as t,At as n,Ct as r,Et as i,G as a,Ht as o,J as s,K as c,Pt as l,Q as u,R as d,Wt as f,X as p,Y as m,Z as h,dt as g,et as _,ht as v,k as y,n as b,pt as x,qt as S,r as C,tt as w}from"./button-DZwflOXO.js";import{r as ee,t as te}from"./UnifiedRequestDialog-5-vBmVMH.js";import{t as T}from"./copy-zQQvOqam.js";import{i as E,n as D,r as O,t as ne}from"./TooltipTrigger-DmYucHtv.js";import{a as re,c as k,d as ie,f as ae,l as A,n as oe,o as se,r as ce,s as le,t as ue,u as j}from"./dialog-C7v6Gaak.js";import{t as de}from"./Label-CjUuzGNQ.js";import{a as fe,b as M,c as pe,d as me,dt as he,f as N,ft as ge,g as P,h as F,i as _e,m as I,o as ve,p as L,r as R,s as ye,u as be}from"./index-PMAQyWJb.js";import{t as z}from"./Input-DEfnoFS3.js";import{t as xe}from"./useClipboard-B4K3eogm.js";import{t as Se}from"./useLogRetention-BNbFXLBO.js";var Ce=w({__name:`Skeleton`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(x(),u(`div`,{"data-slot":`skeleton`,class:f(o(C)(`bg-muted rounded-md animate-pulse`,t.class))},null,2))}}),B={key:1,class:`ml-4 text-muted-foreground text-xs`},we={class:`inline-flex items-center gap-1`},V={class:`font-mono`},H={key:2,class:`text-muted-foreground`},U={key:1,class:`text-muted-foreground`},W={key:1,class:`text-muted-foreground`},Te=w({__name:`LogTableRow`,props:{log:{},isChild:{type:Boolean,default:!1},expanded:{type:Boolean,default:!1},copiedId:{default:null}},emits:[`toggleExpand`,`openDetail`,`copy`],setup(t,{emit:n}){let r=n,{t:s}=d();function l(e){if(!e)return s(`logs.row.unknown`);try{let t=JSON.parse(e);return t.action?t.detail?`${t.action}: ${t.detail}`:t.action:e}catch{return s(`logs.row.unknown`)}}return(n,d)=>(x(),p(o(A),{class:f({"bg-destructive/10":!t.isChild&&(t.log.status_code??0)>=400,"bg-muted/20":t.isChild})},{default:i(()=>[_(o(j),{class:`w-10`},{default:i(()=>[!t.isChild&&t.log.child_count?(x(),p(o(b),{key:0,variant:`ghost`,size:`xs`,onClick:d[0]||=e=>r(`toggleExpand`,t.log)},{default:i(()=>[m(`span`,{class:f([`text-xs transition-transform`,t.expanded?``:`-rotate-90`])},`▼`,2)]),_:1})):h(``,!0),t.isChild?(x(),u(`span`,B,`└`)):h(``,!0)]),_:1}),_(o(j),{class:`font-mono text-xs text-muted-foreground`,title:t.log.id},{default:i(()=>[m(`span`,we,[e(S(t.log.id.slice(0,8))+` `,1),_(o(D),null,{default:i(()=>[_(o(E),{"delay-duration":300},{default:i(()=>[_(o(ne),{"as-child":``},{default:i(()=>[_(o(b),{variant:`ghost`,size:`icon-xs`,class:`shrink-0`,onClick:d[1]||=a(e=>r(`copy`,t.log.id),[`stop`])},{default:i(()=>[t.copiedId===t.log.id?(x(),p(o(he),{key:0,class:`size-3 text-success`})):(x(),p(o(T),{key:1,class:`size-3`}))]),_:1})]),_:1}),_(o(O),null,{default:i(()=>[e(S(o(s)(`logs.row.copyFullId`)),1)]),_:1})]),_:1})]),_:1})])]),_:1},8,[`title`]),_(o(j),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(ge)(t.log.created_at)),1)]),_:1}),_(o(j),null,{default:i(()=>[_(o(M),{variant:t.log.api_type===`openai`?`default`:`secondary`},{default:i(()=>[e(S(t.log.api_type),1)]),_:1},8,[`variant`])]),_:1}),_(o(j),{class:`font-mono text-xs`},{default:i(()=>[e(S(t.log.model||`-`)+` `,1),!t.isChild&&t.log.original_model?(x(),p(o(M),{key:0,variant:`secondary`,class:`ml-1 text-xs`},{default:i(()=>[e(S(o(s)(`logs.row.replaced`)),1)]),_:1})):h(``,!0)]),_:1}),_(o(j),{class:`text-xs`},{default:i(()=>[!t.isChild&&t.log.provider_id===o(`router`)?(x(),p(o(M),{key:0,variant:`secondary`,class:`text-[10px] px-1 py-0`},{default:i(()=>[e(S(o(s)(`logs.row.proxyEnhancement`,{label:l(t.log.upstream_request)})),1)]),_:1})):t.log.backend_model||t.log.provider_name?(x(),u(c,{key:1},[m(`span`,V,S(t.log.backend_model||`-`),1),d[3]||=m(`span`,{class:`text-muted-foreground`},` @ `,-1),_(o(M),{variant:`outline`,class:`text-[10px] px-1 py-0`},{default:i(()=>[e(S(t.log.provider_name||t.log.provider_id||`-`),1)]),_:1})],64)):(x(),u(`span`,H,`-`))]),_:1}),_(o(j),null,{default:i(()=>[_(o(M),{variant:(t.log.status_code??0)<400?`default`:`destructive`},{default:i(()=>[e(S(t.log.status_code||`-`),1)]),_:1},8,[`variant`])]),_:1}),_(o(j),null,{default:i(()=>[e(S(t.log.latency_ms?t.log.latency_ms+`ms`:`-`),1)]),_:1}),_(o(j),null,{default:i(()=>[e(S(t.log.is_stream?`Yes`:`No`),1)]),_:1}),_(o(j),null,{default:i(()=>[t.log.is_retry?(x(),p(o(M),{key:0,variant:`outline`,class:`text-warning-dark border-warning`},{default:i(()=>[e(S(o(s)(`logs.table.retry`)),1)]),_:1})):(x(),u(`span`,U,`-`))]),_:1}),_(o(j),null,{default:i(()=>[t.log.is_failover?(x(),p(o(M),{key:0,variant:`outline`,class:`text-danger-dark border-danger`},{default:i(()=>[e(S(o(s)(`logs.table.failover`)),1)]),_:1})):(x(),u(`span`,W,`-`))]),_:1}),_(o(j),{class:`text-destructive text-xs`},{default:i(()=>[e(S(t.log.error_message||`-`),1)]),_:1}),_(o(j),null,{default:i(()=>[_(o(b),{variant:`ghost`,size:`sm`,onClick:d[2]||=e=>r(`openDetail`,t.log.id)},{default:i(()=>[e(S(o(s)(`logs.row.detail`)),1)]),_:1})]),_:1})]),_:1},8,[`class`]))}}),Ee=[{label:`1h`,value:`1h`},{label:`5h`,value:`5h`},{label:`24h`,value:`24h`},{label:`7d`,value:`7d`},{label:`30d`,value:`30d`}];function De(){let{t:e}=d(),n=l(`5h`),r=l({start:``,end:``}),i=l(`all`),a=l(`all`),o=l(`all`),c=l(`all`),u=l(`all`),f=l([]),p=l([]),m=l([]),h=s(()=>r.value.start&&r.value.end&&r.value.start<r.value.end),_=s(()=>{let{start:t,end:n}=r.value;return!t||!n?``:t>=n?e(`logs.validation.endTimeAfterStart`):``}),v=s(()=>{if(i.value===`all`)return m.value;let e=f.value.find(e=>e.id===i.value);if(!e)return m.value;let t=new Set(e.models.map(e=>e.name));return m.value.filter(e=>t.has(e))});function b(e){return e.includes(`T`)?`${e}:00.000Z`:`${e}T00:00:00.000Z`}function x(e){return e.includes(`T`)?`${e}:59.999Z`:`${e}T23:59:59.999Z`}let S={"1h":36e5,"5h":18e6,"24h":864e5,"7d":6048e5,"30d":2592e6};function C(){let e={};if(h.value)e.start_time=b(r.value.start),e.end_time=x(r.value.end);else{let t=S[n.value];t&&(e.start_time=new Date(Date.now()-t).toISOString())}return c.value!==`all`&&(e.api_type=c.value),i.value!==`all`&&(e.provider_id=i.value),a.value!==`all`&&(e.model=a.value),o.value!==`all`&&(e.router_key_id=o.value),u.value!==`all`&&(e.status_code=u.value),e}function w(){r.value={start:``,end:``}}async function ee(){try{f.value=await y.getProviders()}catch(n){console.error(`Failed to load providers:`,n),R.error(t(n,e(`logs.messages.loadProvidersFailed`)))}}async function te(){try{p.value=await y.getRouterKeys()}catch(n){console.error(`Failed to load router keys:`,n),R.error(t(n,e(`logs.messages.loadKeysFailed`)))}}async function T(){try{let e=await y.getMetricsSummary({period:`30d`});m.value=[...new Set(e.rows.map(e=>e.backend_model))]}catch{m.value=[]}}return g(()=>{Promise.allSettled([ee(),te(),T()])}),{PERIODS:Ee,period:n,dateRange:r,dateRangeError:_,providerFilter:i,modelFilter:a,keyFilter:o,apiTypeFilter:c,statusFilter:u,providers:f,routerKeys:p,filteredModelOptions:v,hasDateRange:h,clearDateRange:w,buildFilterParams:C}}var G=20,K=864e5;function Oe(){let{t:e}=d(),n=l([]),r=l(0),i=l(1),a=l({}),o=l(30),c=l(!1),u=l(new Set),f=l({}),p=l({}),m=l(!1),h=l(null),g=s(()=>Math.ceil(r.value/G));async function _(o){o&&(a.value=o);try{let e=await y.getLogs({page:i.value,limit:G,view:`grouped`,...a.value});n.value=e.data,r.value=e.total,u.value.clear(),f.value={},p.value={}}catch(n){console.error(`Failed to load logs:`,n),R.error(t(n,e(`logs.messages.loadFailed`)))}}function v(e){e>=1&&e<=g.value&&e!==i.value&&(i.value=e,_())}let b=l(null),x=l(!1);async function S(){try{let e=new Date(Date.now()-o.value*K).toISOString(),t=await y.deleteLogsBefore(e);c.value=!1,i.value=1,await _(),b.value=t.deleted,x.value=!0}catch(n){console.error(`Failed to cleanup logs:`,n),R.error(t(n,e(`logs.messages.cleanupFailed`)))}}async function C(n){let r=n.id;if(u.value.has(r)){u.value.delete(r);return}if(u.value.add(r),!f.value[r]){p.value[r]=!0;try{f.value[r]=await y.getLogChildren(r)}catch(n){console.error(`Failed to load child logs:`,n),R.error(t(n,e(`logs.messages.loadSubRequestsFailed`)))}finally{p.value[r]=!1}}}async function w(n){try{h.value=await y.getLogDetail(n),m.value=!0}catch(n){console.error(`Failed to load log detail:`,n),R.error(t(n,e(`logs.messages.loadDetailFailed`)))}}return{PAGE_SIZE:G,logs:n,total:r,page:i,totalPages:g,cleanupDays:o,showCleanup:c,expandedRows:u,childLogs:f,childLoading:p,logDetailOpen:m,selectedLogEntry:h,cleanupResult:b,showCleanupResult:x,loadLogs:_,goToPage:v,handleCleanup:S,toggleExpand:C,openLogDetail:w}}var ke={class:`p-6`},Ae={class:`flex items-center justify-between mb-4`},je={class:`text-lg font-semibold text-foreground`},Me={class:`flex flex-wrap items-center gap-2 mb-4`},Ne={class:`flex gap-1`},Pe={class:`flex items-center gap-1`},Fe={key:1,class:`text-xs text-destructive whitespace-nowrap`},Ie={class:`bg-card rounded-lg border overflow-hidden`},Le={class:`flex items-center justify-between mt-4`},Re={class:`text-sm text-muted-foreground`},ze={class:`flex items-center gap-1`},Be={key:0,class:`px-2 text-sm text-muted-foreground`},Ve={class:`text-sm text-muted-foreground`},He={class:`mb-4`},Ue={class:`space-y-3`},We={class:`text-sm font-medium`},Ge={class:`flex items-center gap-3`},Ke={class:`text-xs text-muted-foreground`},qe={class:`flex justify-end`},Je=13,Ye=300,Xe=7,q=2,J=1,Ze=2e3,Y=w({__name:`Logs`,setup(t){let{t:a}=d(),{PERIODS:f,period:y,dateRange:C,dateRangeError:w,providerFilter:T,modelFilter:E,keyFilter:D,statusFilter:O,providers:ne,routerKeys:M,filteredModelOptions:he,clearDateRange:ge,buildFilterParams:R}=De(),{logs:B,total:we,page:V,totalPages:H,cleanupDays:U,showCleanup:W,cleanupResult:Ee,showCleanupResult:G,expandedRows:K,childLogs:Y,childLoading:Qe,logDetailOpen:X,selectedLogEntry:$e,loadLogs:et,goToPage:Z,handleCleanup:tt,toggleExpand:nt,openLogDetail:rt}=Oe(),it=s(()=>{let e=H.value,t=V.value;if(e<=Xe)return Array.from({length:e},(e,t)=>t+1);let n=[J],r=Math.max(J+1,t-q),i=Math.min(e-J,t+q);r>J+q&&n.push(`...`);for(let e=r;e<=i;e++)n.push(e);return i<e-q&&n.push(`...`),n.push(e),n}),{retentionDays:at,retentionSaving:ot,saveRetention:st,loadRetention:ct}=Se(),{copy:lt}=xe(),Q=l(null);function ut(e){lt(e),Q.value=e,setTimeout(()=>{Q.value===e&&(Q.value=null)},Ze)}let $=null;return r([y,C,T,E,D,O],()=>{V.value=1,$&&clearTimeout($),$=setTimeout(()=>et(R()),Ye)},{deep:!0}),g(()=>{et(R()),ct()}),(t,r)=>(x(),u(`div`,ke,[m(`div`,Ae,[m(`h2`,je,S(o(a)(`logs.title`)),1),_(o(b),{variant:`outline`,class:`text-destructive border-destructive hover:bg-destructive/10`,onClick:r[0]||=e=>W.value=!0},{default:i(()=>[e(S(o(a)(`logs.cleanupLogs`)),1)]),_:1})]),m(`div`,Me,[m(`div`,Ne,[(x(!0),u(c,null,v(o(f),t=>(x(),p(o(b),{key:t.value,variant:o(y)===t.value?`default`:`ghost`,size:`sm`,onClick:e=>y.value=t.value},{default:i(()=>[e(S(t.label),1)]),_:2},1032,[`variant`,`onClick`]))),128))]),m(`div`,Pe,[_(o(z),{type:`datetime-local`,modelValue:o(C).start,"onUpdate:modelValue":r[1]||=e=>o(C).start=e,class:`w-44`},null,8,[`modelValue`]),r[18]||=m(`span`,{class:`text-muted-foreground text-sm`},`-`,-1),_(o(z),{type:`datetime-local`,modelValue:o(C).end,"onUpdate:modelValue":r[2]||=e=>o(C).end=e,class:`w-44`},null,8,[`modelValue`]),o(C).start||o(C).end?(x(),p(o(b),{key:0,variant:`ghost`,size:`sm`,onClick:o(ge)},{default:i(()=>[e(S(o(a)(`logs.clear`)),1)]),_:1},8,[`onClick`])):h(``,!0),o(w)?(x(),u(`span`,Fe,S(o(w)),1)):h(``,!0)]),_(o(P),{modelValue:o(T),"onUpdate:modelValue":r[3]||=e=>n(T)?T.value=e:null},{default:i(()=>[_(o(L),{class:`w-28 truncate`},{default:i(()=>[_(o(N),{placeholder:o(a)(`logs.allProviders`)},null,8,[`placeholder`])]),_:1}),_(o(F),null,{default:i(()=>[_(o(I),{value:`all`},{default:i(()=>[e(S(o(a)(`logs.allProviders`)),1)]),_:1}),(x(!0),u(c,null,v(o(ne),t=>(x(),p(o(I),{key:t.id,value:t.id},{default:i(()=>[e(S(t.name),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`modelValue`]),_(o(P),{modelValue:o(E),"onUpdate:modelValue":r[4]||=e=>n(E)?E.value=e:null},{default:i(()=>[_(o(L),{class:`w-32 truncate`},{default:i(()=>[_(o(N),{placeholder:o(a)(`logs.allModels`)},null,8,[`placeholder`])]),_:1}),_(o(F),null,{default:i(()=>[_(o(I),{value:`all`},{default:i(()=>[e(S(o(a)(`logs.allModels`)),1)]),_:1}),(x(!0),u(c,null,v(o(he),t=>(x(),p(o(I),{key:t,value:t},{default:i(()=>[e(S(t),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`modelValue`]),_(o(P),{modelValue:o(D),"onUpdate:modelValue":r[5]||=e=>n(D)?D.value=e:null},{default:i(()=>[_(o(L),{class:`w-32 truncate`},{default:i(()=>[_(o(N),{placeholder:o(a)(`logs.allKeys`)},null,8,[`placeholder`])]),_:1}),_(o(F),null,{default:i(()=>[_(o(I),{value:`all`},{default:i(()=>[e(S(o(a)(`logs.allKeys`)),1)]),_:1}),(x(!0),u(c,null,v(o(M),t=>(x(),p(o(I),{key:t.id,value:t.id},{default:i(()=>[e(S(t.name),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`modelValue`]),_(o(P),{modelValue:o(O),"onUpdate:modelValue":r[6]||=e=>n(O)?O.value=e:null},{default:i(()=>[_(o(L),{class:`w-28 truncate`},{default:i(()=>[_(o(N),{placeholder:o(a)(`logs.allStatus`)},null,8,[`placeholder`])]),_:1}),_(o(F),null,{default:i(()=>[_(o(I),{value:`all`},{default:i(()=>[e(S(o(a)(`logs.allStatus`)),1)]),_:1}),_(o(I),{value:`200`},{default:i(()=>[...r[19]||=[e(`200`,-1)]]),_:1}),_(o(I),{value:`non200`},{default:i(()=>[e(S(o(a)(`logs.non200`)),1)]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),m(`div`,Ie,[_(o(ae),null,{default:i(()=>[_(o(le),null,{default:i(()=>[_(o(A),{class:`bg-muted`},{default:i(()=>[_(o(k),{class:`w-10`}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.id`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.time`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.type`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.model`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.actualForward`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.statusCode`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.latency`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.streaming`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.retry`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.failover`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.error`)),1)]),_:1}),_(o(k),{class:`text-muted-foreground`},{default:i(()=>[e(S(o(a)(`logs.table.actions`)),1)]),_:1})]),_:1})]),_:1}),_(o(ie),null,{default:i(()=>[(x(!0),u(c,null,v(o(B),e=>(x(),u(c,{key:e.id},[_(Te,{log:e,expanded:o(K).has(e.id),"copied-id":Q.value,onToggleExpand:o(nt),onOpenDetail:o(rt),onCopy:ut},null,8,[`log`,`expanded`,`copied-id`,`onToggleExpand`,`onOpenDetail`]),o(K).has(e.id)?(x(),u(c,{key:0},[o(Qe)[e.id]?(x(),p(o(A),{key:0},{default:i(()=>[_(o(j),{colspan:Je,class:`text-center py-2 pl-10`},{default:i(()=>[_(o(Ce),{class:`h-4 w-32 mx-auto`})]),_:1})]),_:1})):o(Y)[e.id]?.length?(x(!0),u(c,{key:1},v(o(Y)[e.id],e=>(x(),p(Te,{key:e.id,log:e,"is-child":!0,"copied-id":Q.value,onOpenDetail:o(rt),onCopy:ut},null,8,[`log`,`copied-id`,`onOpenDetail`]))),128)):h(``,!0)],64)):h(``,!0)],64))),128)),o(B).length===0?(x(),p(o(A),{key:0},{default:i(()=>[_(o(j),{colspan:Je,class:`text-center text-muted-foreground py-8`},{default:i(()=>[e(S(o(a)(`logs.noLogs`)),1)]),_:1})]),_:1})):h(``,!0)]),_:1})]),_:1})]),m(`div`,Le,[m(`p`,Re,S(o(a)(`logs.pagination`,{total:o(we),page:o(V),totalPages:o(H)})),1),m(`div`,ze,[_(o(b),{variant:`outline`,size:`sm`,onClick:r[7]||=e=>o(Z)(1),disabled:o(V)<=1},{default:i(()=>[e(S(o(a)(`logs.firstPage`)),1)]),_:1},8,[`disabled`]),_(o(b),{variant:`outline`,size:`sm`,onClick:r[8]||=e=>o(Z)(o(V)-1),disabled:o(V)<=1},{default:i(()=>[e(S(o(a)(`logs.prevPage`)),1)]),_:1},8,[`disabled`]),(x(!0),u(c,null,v(it.value,t=>(x(),u(c,{key:t},[t===`...`?(x(),u(`span`,Be,`...`)):(x(),p(o(b),{key:1,variant:t===o(V)?`default`:`outline`,size:`sm`,class:`min-w-8`,onClick:e=>o(Z)(t)},{default:i(()=>[e(S(t),1)]),_:2},1032,[`variant`,`onClick`]))],64))),128)),_(o(b),{variant:`outline`,size:`sm`,onClick:r[9]||=e=>o(Z)(o(V)+1),disabled:o(V)>=o(H)},{default:i(()=>[e(S(o(a)(`logs.nextPage`)),1)]),_:1},8,[`disabled`]),_(o(b),{variant:`outline`,size:`sm`,onClick:r[10]||=e=>o(Z)(o(H)),disabled:o(V)>=o(H)},{default:i(()=>[e(S(o(a)(`logs.lastPage`)),1)]),_:1},8,[`disabled`]),r[20]||=e(` > `,-1)])]),_(te,{open:o(X),"onUpdate:open":r[11]||=e=>n(X)?X.value=e:null,source:`history`,"log-entry":o($e)},null,8,[`open`,`log-entry`]),_(o(se),{open:o(W),"onUpdate:open":r[15]||=e=>n(W)?W.value=e:null},{default:i(()=>[_(o(re),null,{default:i(()=>[_(o(oe),null,{default:i(()=>[_(o(ue),null,{default:i(()=>[e(S(o(a)(`logs.cleanup.title`)),1)]),_:1})]),_:1}),m(`p`,Ve,S(o(a)(`logs.cleanup.description`)),1),m(`div`,He,[_(o(de),{class:`block text-sm font-medium text-foreground mb-1`},{default:i(()=>[e(S(o(a)(`logs.cleanup.keepRecentDays`)),1)]),_:1}),_(o(z),{modelValue:o(U),"onUpdate:modelValue":r[12]||=e=>n(U)?U.value=e:null,modelModifiers:{number:!0},type:`number`,min:1},null,8,[`modelValue`])]),_(o(ee)),m(`div`,Ue,[m(`div`,We,S(o(a)(`logs.cleanup.autoCleanup`)),1),m(`div`,Ge,[_(o(de),{class:`whitespace-nowrap`},{default:i(()=>[e(S(o(a)(`logs.cleanup.retentionDays`)),1)]),_:1}),_(o(z),{type:`number`,modelValue:o(at),"onUpdate:modelValue":r[13]||=e=>n(at)?at.value=e:null,modelModifiers:{number:!0},min:0,max:90,class:`w-20`},null,8,[`modelValue`]),m(`span`,Ke,S(o(a)(`logs.cleanup.noAutoCleanup`)),1)]),m(`div`,qe,[_(o(b),{size:`sm`,onClick:o(st),disabled:o(ot)},{default:i(()=>[e(S(o(a)(`logs.cleanup.saveSettings`)),1)]),_:1},8,[`onClick`,`disabled`])])]),_(o(ce),null,{default:i(()=>[_(o(b),{variant:`outline`,onClick:r[14]||=e=>W.value=!1},{default:i(()=>[e(S(o(a)(`common.cancel`)),1)]),_:1}),_(o(b),{variant:`destructive`,onClick:o(tt)},{default:i(()=>[e(S(o(a)(`logs.cleanup.confirmCleanup`)),1)]),_:1},8,[`onClick`])]),_:1})]),_:1})]),_:1},8,[`open`]),_(o(me),{open:o(G),"onUpdate:open":r[17]||=e=>n(G)?G.value=e:null},{default:i(()=>[_(o(pe),null,{default:i(()=>[_(o(fe),null,{default:i(()=>[_(o(_e),null,{default:i(()=>[e(S(o(a)(`logs.cleanupResult.title`)),1)]),_:1}),_(o(ye),null,{default:i(()=>[e(S(o(a)(`logs.cleanupResult.description`,{count:o(Ee)})),1)]),_:1})]),_:1}),_(o(ve),null,{default:i(()=>[_(o(be),{onClick:r[16]||=e=>G.value=!1},{default:i(()=>[e(S(o(a)(`logs.cleanupResult.ok`)),1)]),_:1})]),_:1})]),_:1})]),_:1},8,[`open`])]))}});export{Y as default};