vite-plugin-kiru 0.24.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.
package/dist/index.js ADDED
@@ -0,0 +1,3937 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.4/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js
28
+ var require_sourcemap_codec_umd = __commonJS({
29
+ "../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.4/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js"(exports, module) {
30
+ (function(global, factory, m) {
31
+ typeof exports === "object" && typeof module !== "undefined" ? factory(module) : typeof define === "function" && define.amd ? define(["module"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(m = { exports: {} }), global.sourcemapCodec = "default" in m.exports ? m.exports.default : m.exports);
32
+ })(exports, function(module2) {
33
+ "use strict";
34
+ var __defProp2 = Object.defineProperty;
35
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
36
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
37
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
38
+ var __export = (target, all) => {
39
+ for (var name in all)
40
+ __defProp2(target, name, { get: all[name], enumerable: true });
41
+ };
42
+ var __copyProps2 = (to, from, except, desc) => {
43
+ if (from && typeof from === "object" || typeof from === "function") {
44
+ for (let key of __getOwnPropNames2(from))
45
+ if (!__hasOwnProp2.call(to, key) && key !== except)
46
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
47
+ }
48
+ return to;
49
+ };
50
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
51
+ var sourcemap_codec_exports = {};
52
+ __export(sourcemap_codec_exports, {
53
+ decode: () => decode,
54
+ decodeGeneratedRanges: () => decodeGeneratedRanges,
55
+ decodeOriginalScopes: () => decodeOriginalScopes,
56
+ encode: () => encode,
57
+ encodeGeneratedRanges: () => encodeGeneratedRanges,
58
+ encodeOriginalScopes: () => encodeOriginalScopes
59
+ });
60
+ module2.exports = __toCommonJS(sourcemap_codec_exports);
61
+ var comma = ",".charCodeAt(0);
62
+ var semicolon = ";".charCodeAt(0);
63
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
64
+ var intToChar = new Uint8Array(64);
65
+ var charToInt = new Uint8Array(128);
66
+ for (let i = 0; i < chars.length; i++) {
67
+ const c = chars.charCodeAt(i);
68
+ intToChar[i] = c;
69
+ charToInt[c] = i;
70
+ }
71
+ function decodeInteger(reader, relative) {
72
+ let value = 0;
73
+ let shift = 0;
74
+ let integer = 0;
75
+ do {
76
+ const c = reader.next();
77
+ integer = charToInt[c];
78
+ value |= (integer & 31) << shift;
79
+ shift += 5;
80
+ } while (integer & 32);
81
+ const shouldNegate = value & 1;
82
+ value >>>= 1;
83
+ if (shouldNegate) {
84
+ value = -2147483648 | -value;
85
+ }
86
+ return relative + value;
87
+ }
88
+ function encodeInteger(builder, num, relative) {
89
+ let delta = num - relative;
90
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
91
+ do {
92
+ let clamped = delta & 31;
93
+ delta >>>= 5;
94
+ if (delta > 0) clamped |= 32;
95
+ builder.write(intToChar[clamped]);
96
+ } while (delta > 0);
97
+ return num;
98
+ }
99
+ function hasMoreVlq(reader, max) {
100
+ if (reader.pos >= max) return false;
101
+ return reader.peek() !== comma;
102
+ }
103
+ var bufLength = 1024 * 16;
104
+ var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
105
+ decode(buf) {
106
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
107
+ return out.toString();
108
+ }
109
+ } : {
110
+ decode(buf) {
111
+ let out = "";
112
+ for (let i = 0; i < buf.length; i++) {
113
+ out += String.fromCharCode(buf[i]);
114
+ }
115
+ return out;
116
+ }
117
+ };
118
+ var StringWriter = class {
119
+ constructor() {
120
+ this.pos = 0;
121
+ this.out = "";
122
+ this.buffer = new Uint8Array(bufLength);
123
+ }
124
+ write(v) {
125
+ const { buffer } = this;
126
+ buffer[this.pos++] = v;
127
+ if (this.pos === bufLength) {
128
+ this.out += td.decode(buffer);
129
+ this.pos = 0;
130
+ }
131
+ }
132
+ flush() {
133
+ const { buffer, out, pos } = this;
134
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
135
+ }
136
+ };
137
+ var StringReader = class {
138
+ constructor(buffer) {
139
+ this.pos = 0;
140
+ this.buffer = buffer;
141
+ }
142
+ next() {
143
+ return this.buffer.charCodeAt(this.pos++);
144
+ }
145
+ peek() {
146
+ return this.buffer.charCodeAt(this.pos);
147
+ }
148
+ indexOf(char) {
149
+ const { buffer, pos } = this;
150
+ const idx = buffer.indexOf(char, pos);
151
+ return idx === -1 ? buffer.length : idx;
152
+ }
153
+ };
154
+ var EMPTY = [];
155
+ function decodeOriginalScopes(input) {
156
+ const { length } = input;
157
+ const reader = new StringReader(input);
158
+ const scopes = [];
159
+ const stack = [];
160
+ let line = 0;
161
+ for (; reader.pos < length; reader.pos++) {
162
+ line = decodeInteger(reader, line);
163
+ const column = decodeInteger(reader, 0);
164
+ if (!hasMoreVlq(reader, length)) {
165
+ const last = stack.pop();
166
+ last[2] = line;
167
+ last[3] = column;
168
+ continue;
169
+ }
170
+ const kind = decodeInteger(reader, 0);
171
+ const fields = decodeInteger(reader, 0);
172
+ const hasName = fields & 1;
173
+ const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
174
+ let vars = EMPTY;
175
+ if (hasMoreVlq(reader, length)) {
176
+ vars = [];
177
+ do {
178
+ const varsIndex = decodeInteger(reader, 0);
179
+ vars.push(varsIndex);
180
+ } while (hasMoreVlq(reader, length));
181
+ }
182
+ scope.vars = vars;
183
+ scopes.push(scope);
184
+ stack.push(scope);
185
+ }
186
+ return scopes;
187
+ }
188
+ function encodeOriginalScopes(scopes) {
189
+ const writer = new StringWriter();
190
+ for (let i = 0; i < scopes.length; ) {
191
+ i = _encodeOriginalScopes(scopes, i, writer, [0]);
192
+ }
193
+ return writer.flush();
194
+ }
195
+ function _encodeOriginalScopes(scopes, index, writer, state) {
196
+ const scope = scopes[index];
197
+ const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
198
+ if (index > 0) writer.write(comma);
199
+ state[0] = encodeInteger(writer, startLine, state[0]);
200
+ encodeInteger(writer, startColumn, 0);
201
+ encodeInteger(writer, kind, 0);
202
+ const fields = scope.length === 6 ? 1 : 0;
203
+ encodeInteger(writer, fields, 0);
204
+ if (scope.length === 6) encodeInteger(writer, scope[5], 0);
205
+ for (const v of vars) {
206
+ encodeInteger(writer, v, 0);
207
+ }
208
+ for (index++; index < scopes.length; ) {
209
+ const next = scopes[index];
210
+ const { 0: l, 1: c } = next;
211
+ if (l > endLine || l === endLine && c >= endColumn) {
212
+ break;
213
+ }
214
+ index = _encodeOriginalScopes(scopes, index, writer, state);
215
+ }
216
+ writer.write(comma);
217
+ state[0] = encodeInteger(writer, endLine, state[0]);
218
+ encodeInteger(writer, endColumn, 0);
219
+ return index;
220
+ }
221
+ function decodeGeneratedRanges(input) {
222
+ const { length } = input;
223
+ const reader = new StringReader(input);
224
+ const ranges = [];
225
+ const stack = [];
226
+ let genLine = 0;
227
+ let definitionSourcesIndex = 0;
228
+ let definitionScopeIndex = 0;
229
+ let callsiteSourcesIndex = 0;
230
+ let callsiteLine = 0;
231
+ let callsiteColumn = 0;
232
+ let bindingLine = 0;
233
+ let bindingColumn = 0;
234
+ do {
235
+ const semi = reader.indexOf(";");
236
+ let genColumn = 0;
237
+ for (; reader.pos < semi; reader.pos++) {
238
+ genColumn = decodeInteger(reader, genColumn);
239
+ if (!hasMoreVlq(reader, semi)) {
240
+ const last = stack.pop();
241
+ last[2] = genLine;
242
+ last[3] = genColumn;
243
+ continue;
244
+ }
245
+ const fields = decodeInteger(reader, 0);
246
+ const hasDefinition = fields & 1;
247
+ const hasCallsite = fields & 2;
248
+ const hasScope = fields & 4;
249
+ let callsite = null;
250
+ let bindings = EMPTY;
251
+ let range;
252
+ if (hasDefinition) {
253
+ const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
254
+ definitionScopeIndex = decodeInteger(
255
+ reader,
256
+ definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0
257
+ );
258
+ definitionSourcesIndex = defSourcesIndex;
259
+ range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
260
+ } else {
261
+ range = [genLine, genColumn, 0, 0];
262
+ }
263
+ range.isScope = !!hasScope;
264
+ if (hasCallsite) {
265
+ const prevCsi = callsiteSourcesIndex;
266
+ const prevLine = callsiteLine;
267
+ callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
268
+ const sameSource = prevCsi === callsiteSourcesIndex;
269
+ callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
270
+ callsiteColumn = decodeInteger(
271
+ reader,
272
+ sameSource && prevLine === callsiteLine ? callsiteColumn : 0
273
+ );
274
+ callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
275
+ }
276
+ range.callsite = callsite;
277
+ if (hasMoreVlq(reader, semi)) {
278
+ bindings = [];
279
+ do {
280
+ bindingLine = genLine;
281
+ bindingColumn = genColumn;
282
+ const expressionsCount = decodeInteger(reader, 0);
283
+ let expressionRanges;
284
+ if (expressionsCount < -1) {
285
+ expressionRanges = [[decodeInteger(reader, 0)]];
286
+ for (let i = -1; i > expressionsCount; i--) {
287
+ const prevBl = bindingLine;
288
+ bindingLine = decodeInteger(reader, bindingLine);
289
+ bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
290
+ const expression = decodeInteger(reader, 0);
291
+ expressionRanges.push([expression, bindingLine, bindingColumn]);
292
+ }
293
+ } else {
294
+ expressionRanges = [[expressionsCount]];
295
+ }
296
+ bindings.push(expressionRanges);
297
+ } while (hasMoreVlq(reader, semi));
298
+ }
299
+ range.bindings = bindings;
300
+ ranges.push(range);
301
+ stack.push(range);
302
+ }
303
+ genLine++;
304
+ reader.pos = semi + 1;
305
+ } while (reader.pos < length);
306
+ return ranges;
307
+ }
308
+ function encodeGeneratedRanges(ranges) {
309
+ if (ranges.length === 0) return "";
310
+ const writer = new StringWriter();
311
+ for (let i = 0; i < ranges.length; ) {
312
+ i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
313
+ }
314
+ return writer.flush();
315
+ }
316
+ function _encodeGeneratedRanges(ranges, index, writer, state) {
317
+ const range = ranges[index];
318
+ const {
319
+ 0: startLine,
320
+ 1: startColumn,
321
+ 2: endLine,
322
+ 3: endColumn,
323
+ isScope,
324
+ callsite,
325
+ bindings
326
+ } = range;
327
+ if (state[0] < startLine) {
328
+ catchupLine(writer, state[0], startLine);
329
+ state[0] = startLine;
330
+ state[1] = 0;
331
+ } else if (index > 0) {
332
+ writer.write(comma);
333
+ }
334
+ state[1] = encodeInteger(writer, range[1], state[1]);
335
+ const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
336
+ encodeInteger(writer, fields, 0);
337
+ if (range.length === 6) {
338
+ const { 4: sourcesIndex, 5: scopesIndex } = range;
339
+ if (sourcesIndex !== state[2]) {
340
+ state[3] = 0;
341
+ }
342
+ state[2] = encodeInteger(writer, sourcesIndex, state[2]);
343
+ state[3] = encodeInteger(writer, scopesIndex, state[3]);
344
+ }
345
+ if (callsite) {
346
+ const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
347
+ if (sourcesIndex !== state[4]) {
348
+ state[5] = 0;
349
+ state[6] = 0;
350
+ } else if (callLine !== state[5]) {
351
+ state[6] = 0;
352
+ }
353
+ state[4] = encodeInteger(writer, sourcesIndex, state[4]);
354
+ state[5] = encodeInteger(writer, callLine, state[5]);
355
+ state[6] = encodeInteger(writer, callColumn, state[6]);
356
+ }
357
+ if (bindings) {
358
+ for (const binding of bindings) {
359
+ if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
360
+ const expression = binding[0][0];
361
+ encodeInteger(writer, expression, 0);
362
+ let bindingStartLine = startLine;
363
+ let bindingStartColumn = startColumn;
364
+ for (let i = 1; i < binding.length; i++) {
365
+ const expRange = binding[i];
366
+ bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
367
+ bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
368
+ encodeInteger(writer, expRange[0], 0);
369
+ }
370
+ }
371
+ }
372
+ for (index++; index < ranges.length; ) {
373
+ const next = ranges[index];
374
+ const { 0: l, 1: c } = next;
375
+ if (l > endLine || l === endLine && c >= endColumn) {
376
+ break;
377
+ }
378
+ index = _encodeGeneratedRanges(ranges, index, writer, state);
379
+ }
380
+ if (state[0] < endLine) {
381
+ catchupLine(writer, state[0], endLine);
382
+ state[0] = endLine;
383
+ state[1] = 0;
384
+ } else {
385
+ writer.write(comma);
386
+ }
387
+ state[1] = encodeInteger(writer, endColumn, state[1]);
388
+ return index;
389
+ }
390
+ function catchupLine(writer, lastLine, line) {
391
+ do {
392
+ writer.write(semicolon);
393
+ } while (++lastLine < line);
394
+ }
395
+ function decode(mappings) {
396
+ const { length } = mappings;
397
+ const reader = new StringReader(mappings);
398
+ const decoded = [];
399
+ let genColumn = 0;
400
+ let sourcesIndex = 0;
401
+ let sourceLine = 0;
402
+ let sourceColumn = 0;
403
+ let namesIndex = 0;
404
+ do {
405
+ const semi = reader.indexOf(";");
406
+ const line = [];
407
+ let sorted = true;
408
+ let lastCol = 0;
409
+ genColumn = 0;
410
+ while (reader.pos < semi) {
411
+ let seg;
412
+ genColumn = decodeInteger(reader, genColumn);
413
+ if (genColumn < lastCol) sorted = false;
414
+ lastCol = genColumn;
415
+ if (hasMoreVlq(reader, semi)) {
416
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
417
+ sourceLine = decodeInteger(reader, sourceLine);
418
+ sourceColumn = decodeInteger(reader, sourceColumn);
419
+ if (hasMoreVlq(reader, semi)) {
420
+ namesIndex = decodeInteger(reader, namesIndex);
421
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
422
+ } else {
423
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
424
+ }
425
+ } else {
426
+ seg = [genColumn];
427
+ }
428
+ line.push(seg);
429
+ reader.pos++;
430
+ }
431
+ if (!sorted) sort(line);
432
+ decoded.push(line);
433
+ reader.pos = semi + 1;
434
+ } while (reader.pos <= length);
435
+ return decoded;
436
+ }
437
+ function sort(line) {
438
+ line.sort(sortComparator);
439
+ }
440
+ function sortComparator(a, b) {
441
+ return a[0] - b[0];
442
+ }
443
+ function encode(decoded) {
444
+ const writer = new StringWriter();
445
+ let sourcesIndex = 0;
446
+ let sourceLine = 0;
447
+ let sourceColumn = 0;
448
+ let namesIndex = 0;
449
+ for (let i = 0; i < decoded.length; i++) {
450
+ const line = decoded[i];
451
+ if (i > 0) writer.write(semicolon);
452
+ if (line.length === 0) continue;
453
+ let genColumn = 0;
454
+ for (let j = 0; j < line.length; j++) {
455
+ const segment = line[j];
456
+ if (j > 0) writer.write(comma);
457
+ genColumn = encodeInteger(writer, segment[0], genColumn);
458
+ if (segment.length === 1) continue;
459
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
460
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
461
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
462
+ if (segment.length === 4) continue;
463
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
464
+ }
465
+ }
466
+ return writer.flush();
467
+ }
468
+ });
469
+ }
470
+ });
471
+
472
+ // ../../node_modules/.pnpm/magic-string@0.30.17/node_modules/magic-string/dist/magic-string.cjs.js
473
+ var require_magic_string_cjs = __commonJS({
474
+ "../../node_modules/.pnpm/magic-string@0.30.17/node_modules/magic-string/dist/magic-string.cjs.js"(exports, module) {
475
+ "use strict";
476
+ var sourcemapCodec = require_sourcemap_codec_umd();
477
+ var BitSet = class _BitSet {
478
+ constructor(arg) {
479
+ this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
480
+ }
481
+ add(n2) {
482
+ this.bits[n2 >> 5] |= 1 << (n2 & 31);
483
+ }
484
+ has(n2) {
485
+ return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
486
+ }
487
+ };
488
+ var Chunk = class _Chunk {
489
+ constructor(start, end, content) {
490
+ this.start = start;
491
+ this.end = end;
492
+ this.original = content;
493
+ this.intro = "";
494
+ this.outro = "";
495
+ this.content = content;
496
+ this.storeName = false;
497
+ this.edited = false;
498
+ {
499
+ this.previous = null;
500
+ this.next = null;
501
+ }
502
+ }
503
+ appendLeft(content) {
504
+ this.outro += content;
505
+ }
506
+ appendRight(content) {
507
+ this.intro = this.intro + content;
508
+ }
509
+ clone() {
510
+ const chunk = new _Chunk(this.start, this.end, this.original);
511
+ chunk.intro = this.intro;
512
+ chunk.outro = this.outro;
513
+ chunk.content = this.content;
514
+ chunk.storeName = this.storeName;
515
+ chunk.edited = this.edited;
516
+ return chunk;
517
+ }
518
+ contains(index) {
519
+ return this.start < index && index < this.end;
520
+ }
521
+ eachNext(fn) {
522
+ let chunk = this;
523
+ while (chunk) {
524
+ fn(chunk);
525
+ chunk = chunk.next;
526
+ }
527
+ }
528
+ eachPrevious(fn) {
529
+ let chunk = this;
530
+ while (chunk) {
531
+ fn(chunk);
532
+ chunk = chunk.previous;
533
+ }
534
+ }
535
+ edit(content, storeName, contentOnly) {
536
+ this.content = content;
537
+ if (!contentOnly) {
538
+ this.intro = "";
539
+ this.outro = "";
540
+ }
541
+ this.storeName = storeName;
542
+ this.edited = true;
543
+ return this;
544
+ }
545
+ prependLeft(content) {
546
+ this.outro = content + this.outro;
547
+ }
548
+ prependRight(content) {
549
+ this.intro = content + this.intro;
550
+ }
551
+ reset() {
552
+ this.intro = "";
553
+ this.outro = "";
554
+ if (this.edited) {
555
+ this.content = this.original;
556
+ this.storeName = false;
557
+ this.edited = false;
558
+ }
559
+ }
560
+ split(index) {
561
+ const sliceIndex = index - this.start;
562
+ const originalBefore = this.original.slice(0, sliceIndex);
563
+ const originalAfter = this.original.slice(sliceIndex);
564
+ this.original = originalBefore;
565
+ const newChunk = new _Chunk(index, this.end, originalAfter);
566
+ newChunk.outro = this.outro;
567
+ this.outro = "";
568
+ this.end = index;
569
+ if (this.edited) {
570
+ newChunk.edit("", false);
571
+ this.content = "";
572
+ } else {
573
+ this.content = originalBefore;
574
+ }
575
+ newChunk.next = this.next;
576
+ if (newChunk.next) newChunk.next.previous = newChunk;
577
+ newChunk.previous = this;
578
+ this.next = newChunk;
579
+ return newChunk;
580
+ }
581
+ toString() {
582
+ return this.intro + this.content + this.outro;
583
+ }
584
+ trimEnd(rx) {
585
+ this.outro = this.outro.replace(rx, "");
586
+ if (this.outro.length) return true;
587
+ const trimmed = this.content.replace(rx, "");
588
+ if (trimmed.length) {
589
+ if (trimmed !== this.content) {
590
+ this.split(this.start + trimmed.length).edit("", void 0, true);
591
+ if (this.edited) {
592
+ this.edit(trimmed, this.storeName, true);
593
+ }
594
+ }
595
+ return true;
596
+ } else {
597
+ this.edit("", void 0, true);
598
+ this.intro = this.intro.replace(rx, "");
599
+ if (this.intro.length) return true;
600
+ }
601
+ }
602
+ trimStart(rx) {
603
+ this.intro = this.intro.replace(rx, "");
604
+ if (this.intro.length) return true;
605
+ const trimmed = this.content.replace(rx, "");
606
+ if (trimmed.length) {
607
+ if (trimmed !== this.content) {
608
+ const newChunk = this.split(this.end - trimmed.length);
609
+ if (this.edited) {
610
+ newChunk.edit(trimmed, this.storeName, true);
611
+ }
612
+ this.edit("", void 0, true);
613
+ }
614
+ return true;
615
+ } else {
616
+ this.edit("", void 0, true);
617
+ this.outro = this.outro.replace(rx, "");
618
+ if (this.outro.length) return true;
619
+ }
620
+ }
621
+ };
622
+ function getBtoa() {
623
+ if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
624
+ return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
625
+ } else if (typeof Buffer === "function") {
626
+ return (str) => Buffer.from(str, "utf-8").toString("base64");
627
+ } else {
628
+ return () => {
629
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
630
+ };
631
+ }
632
+ }
633
+ var btoa = /* @__PURE__ */ getBtoa();
634
+ var SourceMap = class {
635
+ constructor(properties) {
636
+ this.version = 3;
637
+ this.file = properties.file;
638
+ this.sources = properties.sources;
639
+ this.sourcesContent = properties.sourcesContent;
640
+ this.names = properties.names;
641
+ this.mappings = sourcemapCodec.encode(properties.mappings);
642
+ if (typeof properties.x_google_ignoreList !== "undefined") {
643
+ this.x_google_ignoreList = properties.x_google_ignoreList;
644
+ }
645
+ if (typeof properties.debugId !== "undefined") {
646
+ this.debugId = properties.debugId;
647
+ }
648
+ }
649
+ toString() {
650
+ return JSON.stringify(this);
651
+ }
652
+ toUrl() {
653
+ return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
654
+ }
655
+ };
656
+ function guessIndent(code) {
657
+ const lines = code.split("\n");
658
+ const tabbed = lines.filter((line) => /^\t+/.test(line));
659
+ const spaced = lines.filter((line) => /^ {2,}/.test(line));
660
+ if (tabbed.length === 0 && spaced.length === 0) {
661
+ return null;
662
+ }
663
+ if (tabbed.length >= spaced.length) {
664
+ return " ";
665
+ }
666
+ const min = spaced.reduce((previous, current) => {
667
+ const numSpaces = /^ +/.exec(current)[0].length;
668
+ return Math.min(numSpaces, previous);
669
+ }, Infinity);
670
+ return new Array(min + 1).join(" ");
671
+ }
672
+ function getRelativePath(from, to) {
673
+ const fromParts = from.split(/[/\\]/);
674
+ const toParts = to.split(/[/\\]/);
675
+ fromParts.pop();
676
+ while (fromParts[0] === toParts[0]) {
677
+ fromParts.shift();
678
+ toParts.shift();
679
+ }
680
+ if (fromParts.length) {
681
+ let i = fromParts.length;
682
+ while (i--) fromParts[i] = "..";
683
+ }
684
+ return fromParts.concat(toParts).join("/");
685
+ }
686
+ var toString = Object.prototype.toString;
687
+ function isObject(thing) {
688
+ return toString.call(thing) === "[object Object]";
689
+ }
690
+ function getLocator(source) {
691
+ const originalLines = source.split("\n");
692
+ const lineOffsets = [];
693
+ for (let i = 0, pos = 0; i < originalLines.length; i++) {
694
+ lineOffsets.push(pos);
695
+ pos += originalLines[i].length + 1;
696
+ }
697
+ return function locate(index) {
698
+ let i = 0;
699
+ let j = lineOffsets.length;
700
+ while (i < j) {
701
+ const m = i + j >> 1;
702
+ if (index < lineOffsets[m]) {
703
+ j = m;
704
+ } else {
705
+ i = m + 1;
706
+ }
707
+ }
708
+ const line = i - 1;
709
+ const column = index - lineOffsets[line];
710
+ return { line, column };
711
+ };
712
+ }
713
+ var wordRegex = /\w/;
714
+ var Mappings = class {
715
+ constructor(hires) {
716
+ this.hires = hires;
717
+ this.generatedCodeLine = 0;
718
+ this.generatedCodeColumn = 0;
719
+ this.raw = [];
720
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
721
+ this.pending = null;
722
+ }
723
+ addEdit(sourceIndex, content, loc, nameIndex) {
724
+ if (content.length) {
725
+ const contentLengthMinusOne = content.length - 1;
726
+ let contentLineEnd = content.indexOf("\n", 0);
727
+ let previousContentLineEnd = -1;
728
+ while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
729
+ const segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
730
+ if (nameIndex >= 0) {
731
+ segment2.push(nameIndex);
732
+ }
733
+ this.rawSegments.push(segment2);
734
+ this.generatedCodeLine += 1;
735
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
736
+ this.generatedCodeColumn = 0;
737
+ previousContentLineEnd = contentLineEnd;
738
+ contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
739
+ }
740
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
741
+ if (nameIndex >= 0) {
742
+ segment.push(nameIndex);
743
+ }
744
+ this.rawSegments.push(segment);
745
+ this.advance(content.slice(previousContentLineEnd + 1));
746
+ } else if (this.pending) {
747
+ this.rawSegments.push(this.pending);
748
+ this.advance(content);
749
+ }
750
+ this.pending = null;
751
+ }
752
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
753
+ let originalCharIndex = chunk.start;
754
+ let first = true;
755
+ let charInHiresBoundary = false;
756
+ while (originalCharIndex < chunk.end) {
757
+ if (original[originalCharIndex] === "\n") {
758
+ loc.line += 1;
759
+ loc.column = 0;
760
+ this.generatedCodeLine += 1;
761
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
762
+ this.generatedCodeColumn = 0;
763
+ first = true;
764
+ charInHiresBoundary = false;
765
+ } else {
766
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
767
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
768
+ if (this.hires === "boundary") {
769
+ if (wordRegex.test(original[originalCharIndex])) {
770
+ if (!charInHiresBoundary) {
771
+ this.rawSegments.push(segment);
772
+ charInHiresBoundary = true;
773
+ }
774
+ } else {
775
+ this.rawSegments.push(segment);
776
+ charInHiresBoundary = false;
777
+ }
778
+ } else {
779
+ this.rawSegments.push(segment);
780
+ }
781
+ }
782
+ loc.column += 1;
783
+ this.generatedCodeColumn += 1;
784
+ first = false;
785
+ }
786
+ originalCharIndex += 1;
787
+ }
788
+ this.pending = null;
789
+ }
790
+ advance(str) {
791
+ if (!str) return;
792
+ const lines = str.split("\n");
793
+ if (lines.length > 1) {
794
+ for (let i = 0; i < lines.length - 1; i++) {
795
+ this.generatedCodeLine++;
796
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
797
+ }
798
+ this.generatedCodeColumn = 0;
799
+ }
800
+ this.generatedCodeColumn += lines[lines.length - 1].length;
801
+ }
802
+ };
803
+ var n = "\n";
804
+ var warned = {
805
+ insertLeft: false,
806
+ insertRight: false,
807
+ storeName: false
808
+ };
809
+ var MagicString4 = class _MagicString {
810
+ constructor(string, options = {}) {
811
+ const chunk = new Chunk(0, string.length, string);
812
+ Object.defineProperties(this, {
813
+ original: { writable: true, value: string },
814
+ outro: { writable: true, value: "" },
815
+ intro: { writable: true, value: "" },
816
+ firstChunk: { writable: true, value: chunk },
817
+ lastChunk: { writable: true, value: chunk },
818
+ lastSearchedChunk: { writable: true, value: chunk },
819
+ byStart: { writable: true, value: {} },
820
+ byEnd: { writable: true, value: {} },
821
+ filename: { writable: true, value: options.filename },
822
+ indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
823
+ sourcemapLocations: { writable: true, value: new BitSet() },
824
+ storedNames: { writable: true, value: {} },
825
+ indentStr: { writable: true, value: void 0 },
826
+ ignoreList: { writable: true, value: options.ignoreList },
827
+ offset: { writable: true, value: options.offset || 0 }
828
+ });
829
+ this.byStart[0] = chunk;
830
+ this.byEnd[string.length] = chunk;
831
+ }
832
+ addSourcemapLocation(char) {
833
+ this.sourcemapLocations.add(char);
834
+ }
835
+ append(content) {
836
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
837
+ this.outro += content;
838
+ return this;
839
+ }
840
+ appendLeft(index, content) {
841
+ index = index + this.offset;
842
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
843
+ this._split(index);
844
+ const chunk = this.byEnd[index];
845
+ if (chunk) {
846
+ chunk.appendLeft(content);
847
+ } else {
848
+ this.intro += content;
849
+ }
850
+ return this;
851
+ }
852
+ appendRight(index, content) {
853
+ index = index + this.offset;
854
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
855
+ this._split(index);
856
+ const chunk = this.byStart[index];
857
+ if (chunk) {
858
+ chunk.appendRight(content);
859
+ } else {
860
+ this.outro += content;
861
+ }
862
+ return this;
863
+ }
864
+ clone() {
865
+ const cloned = new _MagicString(this.original, { filename: this.filename, offset: this.offset });
866
+ let originalChunk = this.firstChunk;
867
+ let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
868
+ while (originalChunk) {
869
+ cloned.byStart[clonedChunk.start] = clonedChunk;
870
+ cloned.byEnd[clonedChunk.end] = clonedChunk;
871
+ const nextOriginalChunk = originalChunk.next;
872
+ const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
873
+ if (nextClonedChunk) {
874
+ clonedChunk.next = nextClonedChunk;
875
+ nextClonedChunk.previous = clonedChunk;
876
+ clonedChunk = nextClonedChunk;
877
+ }
878
+ originalChunk = nextOriginalChunk;
879
+ }
880
+ cloned.lastChunk = clonedChunk;
881
+ if (this.indentExclusionRanges) {
882
+ cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
883
+ }
884
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
885
+ cloned.intro = this.intro;
886
+ cloned.outro = this.outro;
887
+ return cloned;
888
+ }
889
+ generateDecodedMap(options) {
890
+ options = options || {};
891
+ const sourceIndex = 0;
892
+ const names = Object.keys(this.storedNames);
893
+ const mappings = new Mappings(options.hires);
894
+ const locate = getLocator(this.original);
895
+ if (this.intro) {
896
+ mappings.advance(this.intro);
897
+ }
898
+ this.firstChunk.eachNext((chunk) => {
899
+ const loc = locate(chunk.start);
900
+ if (chunk.intro.length) mappings.advance(chunk.intro);
901
+ if (chunk.edited) {
902
+ mappings.addEdit(
903
+ sourceIndex,
904
+ chunk.content,
905
+ loc,
906
+ chunk.storeName ? names.indexOf(chunk.original) : -1
907
+ );
908
+ } else {
909
+ mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
910
+ }
911
+ if (chunk.outro.length) mappings.advance(chunk.outro);
912
+ });
913
+ return {
914
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
915
+ sources: [
916
+ options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
917
+ ],
918
+ sourcesContent: options.includeContent ? [this.original] : void 0,
919
+ names,
920
+ mappings: mappings.raw,
921
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
922
+ };
923
+ }
924
+ generateMap(options) {
925
+ return new SourceMap(this.generateDecodedMap(options));
926
+ }
927
+ _ensureindentStr() {
928
+ if (this.indentStr === void 0) {
929
+ this.indentStr = guessIndent(this.original);
930
+ }
931
+ }
932
+ _getRawIndentString() {
933
+ this._ensureindentStr();
934
+ return this.indentStr;
935
+ }
936
+ getIndentString() {
937
+ this._ensureindentStr();
938
+ return this.indentStr === null ? " " : this.indentStr;
939
+ }
940
+ indent(indentStr, options) {
941
+ const pattern = /^[^\r\n]/gm;
942
+ if (isObject(indentStr)) {
943
+ options = indentStr;
944
+ indentStr = void 0;
945
+ }
946
+ if (indentStr === void 0) {
947
+ this._ensureindentStr();
948
+ indentStr = this.indentStr || " ";
949
+ }
950
+ if (indentStr === "") return this;
951
+ options = options || {};
952
+ const isExcluded = {};
953
+ if (options.exclude) {
954
+ const exclusions = typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude;
955
+ exclusions.forEach((exclusion) => {
956
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
957
+ isExcluded[i] = true;
958
+ }
959
+ });
960
+ }
961
+ let shouldIndentNextCharacter = options.indentStart !== false;
962
+ const replacer = (match) => {
963
+ if (shouldIndentNextCharacter) return `${indentStr}${match}`;
964
+ shouldIndentNextCharacter = true;
965
+ return match;
966
+ };
967
+ this.intro = this.intro.replace(pattern, replacer);
968
+ let charIndex = 0;
969
+ let chunk = this.firstChunk;
970
+ while (chunk) {
971
+ const end = chunk.end;
972
+ if (chunk.edited) {
973
+ if (!isExcluded[charIndex]) {
974
+ chunk.content = chunk.content.replace(pattern, replacer);
975
+ if (chunk.content.length) {
976
+ shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
977
+ }
978
+ }
979
+ } else {
980
+ charIndex = chunk.start;
981
+ while (charIndex < end) {
982
+ if (!isExcluded[charIndex]) {
983
+ const char = this.original[charIndex];
984
+ if (char === "\n") {
985
+ shouldIndentNextCharacter = true;
986
+ } else if (char !== "\r" && shouldIndentNextCharacter) {
987
+ shouldIndentNextCharacter = false;
988
+ if (charIndex === chunk.start) {
989
+ chunk.prependRight(indentStr);
990
+ } else {
991
+ this._splitChunk(chunk, charIndex);
992
+ chunk = chunk.next;
993
+ chunk.prependRight(indentStr);
994
+ }
995
+ }
996
+ }
997
+ charIndex += 1;
998
+ }
999
+ }
1000
+ charIndex = chunk.end;
1001
+ chunk = chunk.next;
1002
+ }
1003
+ this.outro = this.outro.replace(pattern, replacer);
1004
+ return this;
1005
+ }
1006
+ insert() {
1007
+ throw new Error(
1008
+ "magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
1009
+ );
1010
+ }
1011
+ insertLeft(index, content) {
1012
+ if (!warned.insertLeft) {
1013
+ console.warn(
1014
+ "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
1015
+ );
1016
+ warned.insertLeft = true;
1017
+ }
1018
+ return this.appendLeft(index, content);
1019
+ }
1020
+ insertRight(index, content) {
1021
+ if (!warned.insertRight) {
1022
+ console.warn(
1023
+ "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
1024
+ );
1025
+ warned.insertRight = true;
1026
+ }
1027
+ return this.prependRight(index, content);
1028
+ }
1029
+ move(start, end, index) {
1030
+ start = start + this.offset;
1031
+ end = end + this.offset;
1032
+ index = index + this.offset;
1033
+ if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
1034
+ this._split(start);
1035
+ this._split(end);
1036
+ this._split(index);
1037
+ const first = this.byStart[start];
1038
+ const last = this.byEnd[end];
1039
+ const oldLeft = first.previous;
1040
+ const oldRight = last.next;
1041
+ const newRight = this.byStart[index];
1042
+ if (!newRight && last === this.lastChunk) return this;
1043
+ const newLeft = newRight ? newRight.previous : this.lastChunk;
1044
+ if (oldLeft) oldLeft.next = oldRight;
1045
+ if (oldRight) oldRight.previous = oldLeft;
1046
+ if (newLeft) newLeft.next = first;
1047
+ if (newRight) newRight.previous = last;
1048
+ if (!first.previous) this.firstChunk = last.next;
1049
+ if (!last.next) {
1050
+ this.lastChunk = first.previous;
1051
+ this.lastChunk.next = null;
1052
+ }
1053
+ first.previous = newLeft;
1054
+ last.next = newRight || null;
1055
+ if (!newLeft) this.firstChunk = first;
1056
+ if (!newRight) this.lastChunk = last;
1057
+ return this;
1058
+ }
1059
+ overwrite(start, end, content, options) {
1060
+ options = options || {};
1061
+ return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
1062
+ }
1063
+ update(start, end, content, options) {
1064
+ start = start + this.offset;
1065
+ end = end + this.offset;
1066
+ if (typeof content !== "string") throw new TypeError("replacement content must be a string");
1067
+ if (this.original.length !== 0) {
1068
+ while (start < 0) start += this.original.length;
1069
+ while (end < 0) end += this.original.length;
1070
+ }
1071
+ if (end > this.original.length) throw new Error("end is out of bounds");
1072
+ if (start === end)
1073
+ throw new Error(
1074
+ "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
1075
+ );
1076
+ this._split(start);
1077
+ this._split(end);
1078
+ if (options === true) {
1079
+ if (!warned.storeName) {
1080
+ console.warn(
1081
+ "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
1082
+ );
1083
+ warned.storeName = true;
1084
+ }
1085
+ options = { storeName: true };
1086
+ }
1087
+ const storeName = options !== void 0 ? options.storeName : false;
1088
+ const overwrite = options !== void 0 ? options.overwrite : false;
1089
+ if (storeName) {
1090
+ const original = this.original.slice(start, end);
1091
+ Object.defineProperty(this.storedNames, original, {
1092
+ writable: true,
1093
+ value: true,
1094
+ enumerable: true
1095
+ });
1096
+ }
1097
+ const first = this.byStart[start];
1098
+ const last = this.byEnd[end];
1099
+ if (first) {
1100
+ let chunk = first;
1101
+ while (chunk !== last) {
1102
+ if (chunk.next !== this.byStart[chunk.end]) {
1103
+ throw new Error("Cannot overwrite across a split point");
1104
+ }
1105
+ chunk = chunk.next;
1106
+ chunk.edit("", false);
1107
+ }
1108
+ first.edit(content, storeName, !overwrite);
1109
+ } else {
1110
+ const newChunk = new Chunk(start, end, "").edit(content, storeName);
1111
+ last.next = newChunk;
1112
+ newChunk.previous = last;
1113
+ }
1114
+ return this;
1115
+ }
1116
+ prepend(content) {
1117
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
1118
+ this.intro = content + this.intro;
1119
+ return this;
1120
+ }
1121
+ prependLeft(index, content) {
1122
+ index = index + this.offset;
1123
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
1124
+ this._split(index);
1125
+ const chunk = this.byEnd[index];
1126
+ if (chunk) {
1127
+ chunk.prependLeft(content);
1128
+ } else {
1129
+ this.intro = content + this.intro;
1130
+ }
1131
+ return this;
1132
+ }
1133
+ prependRight(index, content) {
1134
+ index = index + this.offset;
1135
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
1136
+ this._split(index);
1137
+ const chunk = this.byStart[index];
1138
+ if (chunk) {
1139
+ chunk.prependRight(content);
1140
+ } else {
1141
+ this.outro = content + this.outro;
1142
+ }
1143
+ return this;
1144
+ }
1145
+ remove(start, end) {
1146
+ start = start + this.offset;
1147
+ end = end + this.offset;
1148
+ if (this.original.length !== 0) {
1149
+ while (start < 0) start += this.original.length;
1150
+ while (end < 0) end += this.original.length;
1151
+ }
1152
+ if (start === end) return this;
1153
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
1154
+ if (start > end) throw new Error("end must be greater than start");
1155
+ this._split(start);
1156
+ this._split(end);
1157
+ let chunk = this.byStart[start];
1158
+ while (chunk) {
1159
+ chunk.intro = "";
1160
+ chunk.outro = "";
1161
+ chunk.edit("");
1162
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
1163
+ }
1164
+ return this;
1165
+ }
1166
+ reset(start, end) {
1167
+ start = start + this.offset;
1168
+ end = end + this.offset;
1169
+ if (this.original.length !== 0) {
1170
+ while (start < 0) start += this.original.length;
1171
+ while (end < 0) end += this.original.length;
1172
+ }
1173
+ if (start === end) return this;
1174
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
1175
+ if (start > end) throw new Error("end must be greater than start");
1176
+ this._split(start);
1177
+ this._split(end);
1178
+ let chunk = this.byStart[start];
1179
+ while (chunk) {
1180
+ chunk.reset();
1181
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
1182
+ }
1183
+ return this;
1184
+ }
1185
+ lastChar() {
1186
+ if (this.outro.length) return this.outro[this.outro.length - 1];
1187
+ let chunk = this.lastChunk;
1188
+ do {
1189
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
1190
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
1191
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
1192
+ } while (chunk = chunk.previous);
1193
+ if (this.intro.length) return this.intro[this.intro.length - 1];
1194
+ return "";
1195
+ }
1196
+ lastLine() {
1197
+ let lineIndex = this.outro.lastIndexOf(n);
1198
+ if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
1199
+ let lineStr = this.outro;
1200
+ let chunk = this.lastChunk;
1201
+ do {
1202
+ if (chunk.outro.length > 0) {
1203
+ lineIndex = chunk.outro.lastIndexOf(n);
1204
+ if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
1205
+ lineStr = chunk.outro + lineStr;
1206
+ }
1207
+ if (chunk.content.length > 0) {
1208
+ lineIndex = chunk.content.lastIndexOf(n);
1209
+ if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
1210
+ lineStr = chunk.content + lineStr;
1211
+ }
1212
+ if (chunk.intro.length > 0) {
1213
+ lineIndex = chunk.intro.lastIndexOf(n);
1214
+ if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
1215
+ lineStr = chunk.intro + lineStr;
1216
+ }
1217
+ } while (chunk = chunk.previous);
1218
+ lineIndex = this.intro.lastIndexOf(n);
1219
+ if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
1220
+ return this.intro + lineStr;
1221
+ }
1222
+ slice(start = 0, end = this.original.length - this.offset) {
1223
+ start = start + this.offset;
1224
+ end = end + this.offset;
1225
+ if (this.original.length !== 0) {
1226
+ while (start < 0) start += this.original.length;
1227
+ while (end < 0) end += this.original.length;
1228
+ }
1229
+ let result = "";
1230
+ let chunk = this.firstChunk;
1231
+ while (chunk && (chunk.start > start || chunk.end <= start)) {
1232
+ if (chunk.start < end && chunk.end >= end) {
1233
+ return result;
1234
+ }
1235
+ chunk = chunk.next;
1236
+ }
1237
+ if (chunk && chunk.edited && chunk.start !== start)
1238
+ throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
1239
+ const startChunk = chunk;
1240
+ while (chunk) {
1241
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
1242
+ result += chunk.intro;
1243
+ }
1244
+ const containsEnd = chunk.start < end && chunk.end >= end;
1245
+ if (containsEnd && chunk.edited && chunk.end !== end)
1246
+ throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
1247
+ const sliceStart = startChunk === chunk ? start - chunk.start : 0;
1248
+ const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
1249
+ result += chunk.content.slice(sliceStart, sliceEnd);
1250
+ if (chunk.outro && (!containsEnd || chunk.end === end)) {
1251
+ result += chunk.outro;
1252
+ }
1253
+ if (containsEnd) {
1254
+ break;
1255
+ }
1256
+ chunk = chunk.next;
1257
+ }
1258
+ return result;
1259
+ }
1260
+ // TODO deprecate this? not really very useful
1261
+ snip(start, end) {
1262
+ const clone = this.clone();
1263
+ clone.remove(0, start);
1264
+ clone.remove(end, clone.original.length);
1265
+ return clone;
1266
+ }
1267
+ _split(index) {
1268
+ if (this.byStart[index] || this.byEnd[index]) return;
1269
+ let chunk = this.lastSearchedChunk;
1270
+ const searchForward = index > chunk.end;
1271
+ while (chunk) {
1272
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
1273
+ chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
1274
+ }
1275
+ }
1276
+ _splitChunk(chunk, index) {
1277
+ if (chunk.edited && chunk.content.length) {
1278
+ const loc = getLocator(this.original)(index);
1279
+ throw new Error(
1280
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
1281
+ );
1282
+ }
1283
+ const newChunk = chunk.split(index);
1284
+ this.byEnd[index] = chunk;
1285
+ this.byStart[index] = newChunk;
1286
+ this.byEnd[newChunk.end] = newChunk;
1287
+ if (chunk === this.lastChunk) this.lastChunk = newChunk;
1288
+ this.lastSearchedChunk = chunk;
1289
+ return true;
1290
+ }
1291
+ toString() {
1292
+ let str = this.intro;
1293
+ let chunk = this.firstChunk;
1294
+ while (chunk) {
1295
+ str += chunk.toString();
1296
+ chunk = chunk.next;
1297
+ }
1298
+ return str + this.outro;
1299
+ }
1300
+ isEmpty() {
1301
+ let chunk = this.firstChunk;
1302
+ do {
1303
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
1304
+ return false;
1305
+ } while (chunk = chunk.next);
1306
+ return true;
1307
+ }
1308
+ length() {
1309
+ let chunk = this.firstChunk;
1310
+ let length = 0;
1311
+ do {
1312
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length;
1313
+ } while (chunk = chunk.next);
1314
+ return length;
1315
+ }
1316
+ trimLines() {
1317
+ return this.trim("[\\r\\n]");
1318
+ }
1319
+ trim(charType) {
1320
+ return this.trimStart(charType).trimEnd(charType);
1321
+ }
1322
+ trimEndAborted(charType) {
1323
+ const rx = new RegExp((charType || "\\s") + "+$");
1324
+ this.outro = this.outro.replace(rx, "");
1325
+ if (this.outro.length) return true;
1326
+ let chunk = this.lastChunk;
1327
+ do {
1328
+ const end = chunk.end;
1329
+ const aborted = chunk.trimEnd(rx);
1330
+ if (chunk.end !== end) {
1331
+ if (this.lastChunk === chunk) {
1332
+ this.lastChunk = chunk.next;
1333
+ }
1334
+ this.byEnd[chunk.end] = chunk;
1335
+ this.byStart[chunk.next.start] = chunk.next;
1336
+ this.byEnd[chunk.next.end] = chunk.next;
1337
+ }
1338
+ if (aborted) return true;
1339
+ chunk = chunk.previous;
1340
+ } while (chunk);
1341
+ return false;
1342
+ }
1343
+ trimEnd(charType) {
1344
+ this.trimEndAborted(charType);
1345
+ return this;
1346
+ }
1347
+ trimStartAborted(charType) {
1348
+ const rx = new RegExp("^" + (charType || "\\s") + "+");
1349
+ this.intro = this.intro.replace(rx, "");
1350
+ if (this.intro.length) return true;
1351
+ let chunk = this.firstChunk;
1352
+ do {
1353
+ const end = chunk.end;
1354
+ const aborted = chunk.trimStart(rx);
1355
+ if (chunk.end !== end) {
1356
+ if (chunk === this.lastChunk) this.lastChunk = chunk.next;
1357
+ this.byEnd[chunk.end] = chunk;
1358
+ this.byStart[chunk.next.start] = chunk.next;
1359
+ this.byEnd[chunk.next.end] = chunk.next;
1360
+ }
1361
+ if (aborted) return true;
1362
+ chunk = chunk.next;
1363
+ } while (chunk);
1364
+ return false;
1365
+ }
1366
+ trimStart(charType) {
1367
+ this.trimStartAborted(charType);
1368
+ return this;
1369
+ }
1370
+ hasChanged() {
1371
+ return this.original !== this.toString();
1372
+ }
1373
+ _replaceRegexp(searchValue, replacement) {
1374
+ function getReplacement(match, str) {
1375
+ if (typeof replacement === "string") {
1376
+ return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
1377
+ if (i === "$") return "$";
1378
+ if (i === "&") return match[0];
1379
+ const num = +i;
1380
+ if (num < match.length) return match[+i];
1381
+ return `$${i}`;
1382
+ });
1383
+ } else {
1384
+ return replacement(...match, match.index, str, match.groups);
1385
+ }
1386
+ }
1387
+ function matchAll(re, str) {
1388
+ let match;
1389
+ const matches = [];
1390
+ while (match = re.exec(str)) {
1391
+ matches.push(match);
1392
+ }
1393
+ return matches;
1394
+ }
1395
+ if (searchValue.global) {
1396
+ const matches = matchAll(searchValue, this.original);
1397
+ matches.forEach((match) => {
1398
+ if (match.index != null) {
1399
+ const replacement2 = getReplacement(match, this.original);
1400
+ if (replacement2 !== match[0]) {
1401
+ this.overwrite(match.index, match.index + match[0].length, replacement2);
1402
+ }
1403
+ }
1404
+ });
1405
+ } else {
1406
+ const match = this.original.match(searchValue);
1407
+ if (match && match.index != null) {
1408
+ const replacement2 = getReplacement(match, this.original);
1409
+ if (replacement2 !== match[0]) {
1410
+ this.overwrite(match.index, match.index + match[0].length, replacement2);
1411
+ }
1412
+ }
1413
+ }
1414
+ return this;
1415
+ }
1416
+ _replaceString(string, replacement) {
1417
+ const { original } = this;
1418
+ const index = original.indexOf(string);
1419
+ if (index !== -1) {
1420
+ this.overwrite(index, index + string.length, replacement);
1421
+ }
1422
+ return this;
1423
+ }
1424
+ replace(searchValue, replacement) {
1425
+ if (typeof searchValue === "string") {
1426
+ return this._replaceString(searchValue, replacement);
1427
+ }
1428
+ return this._replaceRegexp(searchValue, replacement);
1429
+ }
1430
+ _replaceAllString(string, replacement) {
1431
+ const { original } = this;
1432
+ const stringLength = string.length;
1433
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
1434
+ const previous = original.slice(index, index + stringLength);
1435
+ if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
1436
+ }
1437
+ return this;
1438
+ }
1439
+ replaceAll(searchValue, replacement) {
1440
+ if (typeof searchValue === "string") {
1441
+ return this._replaceAllString(searchValue, replacement);
1442
+ }
1443
+ if (!searchValue.global) {
1444
+ throw new TypeError(
1445
+ "MagicString.prototype.replaceAll called with a non-global RegExp argument"
1446
+ );
1447
+ }
1448
+ return this._replaceRegexp(searchValue, replacement);
1449
+ }
1450
+ };
1451
+ var hasOwnProp = Object.prototype.hasOwnProperty;
1452
+ var Bundle = class _Bundle {
1453
+ constructor(options = {}) {
1454
+ this.intro = options.intro || "";
1455
+ this.separator = options.separator !== void 0 ? options.separator : "\n";
1456
+ this.sources = [];
1457
+ this.uniqueSources = [];
1458
+ this.uniqueSourceIndexByFilename = {};
1459
+ }
1460
+ addSource(source) {
1461
+ if (source instanceof MagicString4) {
1462
+ return this.addSource({
1463
+ content: source,
1464
+ filename: source.filename,
1465
+ separator: this.separator
1466
+ });
1467
+ }
1468
+ if (!isObject(source) || !source.content) {
1469
+ throw new Error(
1470
+ "bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`"
1471
+ );
1472
+ }
1473
+ ["filename", "ignoreList", "indentExclusionRanges", "separator"].forEach((option) => {
1474
+ if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
1475
+ });
1476
+ if (source.separator === void 0) {
1477
+ source.separator = this.separator;
1478
+ }
1479
+ if (source.filename) {
1480
+ if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
1481
+ this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
1482
+ this.uniqueSources.push({ filename: source.filename, content: source.content.original });
1483
+ } else {
1484
+ const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
1485
+ if (source.content.original !== uniqueSource.content) {
1486
+ throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
1487
+ }
1488
+ }
1489
+ }
1490
+ this.sources.push(source);
1491
+ return this;
1492
+ }
1493
+ append(str, options) {
1494
+ this.addSource({
1495
+ content: new MagicString4(str),
1496
+ separator: options && options.separator || ""
1497
+ });
1498
+ return this;
1499
+ }
1500
+ clone() {
1501
+ const bundle = new _Bundle({
1502
+ intro: this.intro,
1503
+ separator: this.separator
1504
+ });
1505
+ this.sources.forEach((source) => {
1506
+ bundle.addSource({
1507
+ filename: source.filename,
1508
+ content: source.content.clone(),
1509
+ separator: source.separator
1510
+ });
1511
+ });
1512
+ return bundle;
1513
+ }
1514
+ generateDecodedMap(options = {}) {
1515
+ const names = [];
1516
+ let x_google_ignoreList = void 0;
1517
+ this.sources.forEach((source) => {
1518
+ Object.keys(source.content.storedNames).forEach((name) => {
1519
+ if (!~names.indexOf(name)) names.push(name);
1520
+ });
1521
+ });
1522
+ const mappings = new Mappings(options.hires);
1523
+ if (this.intro) {
1524
+ mappings.advance(this.intro);
1525
+ }
1526
+ this.sources.forEach((source, i) => {
1527
+ if (i > 0) {
1528
+ mappings.advance(this.separator);
1529
+ }
1530
+ const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
1531
+ const magicString = source.content;
1532
+ const locate = getLocator(magicString.original);
1533
+ if (magicString.intro) {
1534
+ mappings.advance(magicString.intro);
1535
+ }
1536
+ magicString.firstChunk.eachNext((chunk) => {
1537
+ const loc = locate(chunk.start);
1538
+ if (chunk.intro.length) mappings.advance(chunk.intro);
1539
+ if (source.filename) {
1540
+ if (chunk.edited) {
1541
+ mappings.addEdit(
1542
+ sourceIndex,
1543
+ chunk.content,
1544
+ loc,
1545
+ chunk.storeName ? names.indexOf(chunk.original) : -1
1546
+ );
1547
+ } else {
1548
+ mappings.addUneditedChunk(
1549
+ sourceIndex,
1550
+ chunk,
1551
+ magicString.original,
1552
+ loc,
1553
+ magicString.sourcemapLocations
1554
+ );
1555
+ }
1556
+ } else {
1557
+ mappings.advance(chunk.content);
1558
+ }
1559
+ if (chunk.outro.length) mappings.advance(chunk.outro);
1560
+ });
1561
+ if (magicString.outro) {
1562
+ mappings.advance(magicString.outro);
1563
+ }
1564
+ if (source.ignoreList && sourceIndex !== -1) {
1565
+ if (x_google_ignoreList === void 0) {
1566
+ x_google_ignoreList = [];
1567
+ }
1568
+ x_google_ignoreList.push(sourceIndex);
1569
+ }
1570
+ });
1571
+ return {
1572
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
1573
+ sources: this.uniqueSources.map((source) => {
1574
+ return options.file ? getRelativePath(options.file, source.filename) : source.filename;
1575
+ }),
1576
+ sourcesContent: this.uniqueSources.map((source) => {
1577
+ return options.includeContent ? source.content : null;
1578
+ }),
1579
+ names,
1580
+ mappings: mappings.raw,
1581
+ x_google_ignoreList
1582
+ };
1583
+ }
1584
+ generateMap(options) {
1585
+ return new SourceMap(this.generateDecodedMap(options));
1586
+ }
1587
+ getIndentString() {
1588
+ const indentStringCounts = {};
1589
+ this.sources.forEach((source) => {
1590
+ const indentStr = source.content._getRawIndentString();
1591
+ if (indentStr === null) return;
1592
+ if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
1593
+ indentStringCounts[indentStr] += 1;
1594
+ });
1595
+ return Object.keys(indentStringCounts).sort((a, b) => {
1596
+ return indentStringCounts[a] - indentStringCounts[b];
1597
+ })[0] || " ";
1598
+ }
1599
+ indent(indentStr) {
1600
+ if (!arguments.length) {
1601
+ indentStr = this.getIndentString();
1602
+ }
1603
+ if (indentStr === "") return this;
1604
+ let trailingNewline = !this.intro || this.intro.slice(-1) === "\n";
1605
+ this.sources.forEach((source, i) => {
1606
+ const separator = source.separator !== void 0 ? source.separator : this.separator;
1607
+ const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
1608
+ source.content.indent(indentStr, {
1609
+ exclude: source.indentExclusionRanges,
1610
+ indentStart
1611
+ //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
1612
+ });
1613
+ trailingNewline = source.content.lastChar() === "\n";
1614
+ });
1615
+ if (this.intro) {
1616
+ this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index) => {
1617
+ return index > 0 ? indentStr + match : match;
1618
+ });
1619
+ }
1620
+ return this;
1621
+ }
1622
+ prepend(str) {
1623
+ this.intro = str + this.intro;
1624
+ return this;
1625
+ }
1626
+ toString() {
1627
+ const body = this.sources.map((source, i) => {
1628
+ const separator = source.separator !== void 0 ? source.separator : this.separator;
1629
+ const str = (i > 0 ? separator : "") + source.content.toString();
1630
+ return str;
1631
+ }).join("");
1632
+ return this.intro + body;
1633
+ }
1634
+ isEmpty() {
1635
+ if (this.intro.length && this.intro.trim()) return false;
1636
+ if (this.sources.some((source) => !source.content.isEmpty())) return false;
1637
+ return true;
1638
+ }
1639
+ length() {
1640
+ return this.sources.reduce(
1641
+ (length, source) => length + source.content.length(),
1642
+ this.intro.length
1643
+ );
1644
+ }
1645
+ trimLines() {
1646
+ return this.trim("[\\r\\n]");
1647
+ }
1648
+ trim(charType) {
1649
+ return this.trimStart(charType).trimEnd(charType);
1650
+ }
1651
+ trimStart(charType) {
1652
+ const rx = new RegExp("^" + (charType || "\\s") + "+");
1653
+ this.intro = this.intro.replace(rx, "");
1654
+ if (!this.intro) {
1655
+ let source;
1656
+ let i = 0;
1657
+ do {
1658
+ source = this.sources[i++];
1659
+ if (!source) {
1660
+ break;
1661
+ }
1662
+ } while (!source.content.trimStartAborted(charType));
1663
+ }
1664
+ return this;
1665
+ }
1666
+ trimEnd(charType) {
1667
+ const rx = new RegExp((charType || "\\s") + "+$");
1668
+ let source;
1669
+ let i = this.sources.length - 1;
1670
+ do {
1671
+ source = this.sources[i--];
1672
+ if (!source) {
1673
+ this.intro = this.intro.replace(rx, "");
1674
+ break;
1675
+ }
1676
+ } while (!source.content.trimEndAborted(charType));
1677
+ return this;
1678
+ }
1679
+ };
1680
+ MagicString4.Bundle = Bundle;
1681
+ MagicString4.SourceMap = SourceMap;
1682
+ MagicString4.default = MagicString4;
1683
+ module.exports = MagicString4;
1684
+ }
1685
+ });
1686
+
1687
+ // ../devtools-client/dist/index.js
1688
+ var dist_default = `<!DOCTYPE html>
1689
+ <html lang="en">
1690
+ <head>
1691
+ <meta charset="UTF-8" />
1692
+ <link rel="icon" type="image/svg+xml" href="./favicon.svg" />
1693
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
1694
+ <title>Kiru Devtools</title>
1695
+ <script type="module" crossorigin>import*as m from"kiru";import{useState as xe,useEffect as ct,useCallback as Te,createContext as ol,useContext as rl,useMemo as jn,unwrap as al,useRequestUpdate as te,useSignal as Q,sideEffectsEnabled as mr,useHook as br,depsRequireChange as xr,cleanupHook as yr,useLayoutEffect as Ki,signal as ht,useRef as Ce,computed as vr,mount as ll}from"kiru";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const cl=Symbol.for("kiru.fragment"),hl={DELETION:3};new Array;var zs;(function(e){e.Start="start",e.End="end"})(zs||(zs={}));const ul={set(e,t){return e|=1<<t},get(e,t){return(e&1<<t)!==0},unsetRange(e,t,n){const i=(1<<n-t+1)-1<<t;return e&~i}};function dl(e){return ul.get(e.flags,hl.DELETION)}function fl(e){return e.type===cl}function gl(e){return typeof e.type=="function"&&"displayName"in e.type&&e.type.displayName==="Kiru.lazy"}function pl(e){return typeof e.type=="function"&&"displayName"in e.type&&e.type.displayName==="Kiru.memo"}function Mi(...e){return e.filter(Boolean).join(" ")}function Zi(e,t,n){let i=e;for(let s=0;s<t.length;s++){const o=t[s];s===t.length-1?i[o]=n:i=i[o]}}function _r(e){return e.type.displayName??(e.type.name||"Anonymous Function")}const ml=e=>e.__devtoolsFileLink??null;function an(e){return e.name==="kiru.devtools"}function wr(e){return Array.from(e.entries())}function bl(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e},m.createElement("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),m.createElement("path",{d:"M12 9v11"}),m.createElement("path",{d:"M2 9h13a2 2 0 0 1 2 2v9"}))}function Kt(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},m.createElement("path",{d:"m9 18 6-6-6-6"}))}function xl(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},m.createElement("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),m.createElement("circle",{cx:"12",cy:"12",r:"3"}))}function yl(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},m.createElement("path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"}),m.createElement("path",{d:"m21 3-9 9"}),m.createElement("path",{d:"M15 3h6v6"}))}function vl(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},m.createElement("path",{d:"m12 14 4-4"}),m.createElement("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"}))}function _l(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},m.createElement("circle",{cx:"12",cy:"12",r:"10"}),m.createElement("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),m.createElement("path",{d:"M2 12h20"}))}function wl(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},m.createElement("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),m.createElement("path",{d:"M21 3v5h-5"}),m.createElement("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),m.createElement("path",{d:"M8 16H3v5"}))}function El(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e},m.createElement("path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z"}),m.createElement("path",{d:"M6 18h12"}),m.createElement("path",{d:"M6 14h12"}),m.createElement("rect",{width:"12",height:"12",x:"6",y:"10"}))}function Er(e){return m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},m.createElement("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),m.createElement("path",{d:"M12 9v4"}),m.createElement("path",{d:"M12 17h.01"}))}function Sr({title:e,children:t,className:n,disabled:i,...s}){const[o,r]=xe(!0);ct(()=>{!o&&i&&r(!0)},[i]);const a=Te(l=>{l.preventDefault(),l.stopImmediatePropagation(),r(c=>!c)},[]);return m.createElement("div",{className:"flex flex-col"},m.createElement("button",{onclick:a,disabled:i,className:\`\${i?"opacity-50 cursor-default":"cursor-pointer"}\`},m.createElement("span",{className:"flex items-center gap-2 font-medium"},m.createElement(Kt,{className:\`transition \${o?"":"rotate-90"}\`}),e)),o?null:m.createElement("div",{className:\`p-2 \${n||""}\`,...s},t))}const Qi={arrayChunkSize:10,objectKeysChunkSize:100};function kr(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const i in n)if(typeof t[i]!=typeof e[i]||typeof e[i]=="object"&&!kr(e[i],t[i]))return!1;return!0}function Tr(e,t,n){for(const i in t)typeof e[i]>"u"&&(e[i]=structuredClone(t[i]));for(const i in e)typeof e[i]=="object"?Tr(e[i],t[i],n):n(e,i,e[i])}let Mr={...Qi};const Fs=localStorage.getItem("kiru.devtools.userSettings");if(Fs)try{const e=JSON.parse(Fs);kr(Qi,e)&&(Mr=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}const Or=ol({userSettings:null,saveUserSettings:()=>{}}),ei=()=>rl(Or);function Sl({children:e}){const[t,n]=xe(Mr),i=s=>{localStorage.setItem("kiru.devtools.userSettings",JSON.stringify(s)),n(s)};return m.createElement(Or.Provider,{value:{userSettings:t,saveUserSettings:i}},e)}function kl(){const{userSettings:e,saveUserSettings:t}=ei();return m.createElement("div",{className:"rounded bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 overflow-hidden"},m.createElement(ye,{border:!1,data:e,onChange:(n,i)=>{const s={...e};Zi(s,n,i),Tr(s,Qi,(o,r,a)=>{o[r]=a<1?1:a}),t(s)},mutable:!0,objectRefAcc:[]}))}const Tl=Object.freeze(()=>{});function ye({data:e,onChange:t,mutable:n,objectRefAcc:i,keys:s=[],className:o,border:r=!0}){const{userSettings:{objectKeysChunkSize:a}}=ei(),[l,c]=xe(0),h=jn(()=>Object.keys(e).slice(0,(l+1)*a),[l,a,e]),d=()=>{h.forEach(p=>{typeof e[p]=="object"&&i.splice(i.indexOf(e[p]),1)}),c(l+1)},g=h.length<Object.keys(e).length;return m.createElement(m.Fragment,null,m.createElement("div",{className:Mi("flex flex-col items-start w-full",r&&"border border-neutral-700",al(o))},h.map(p=>{const y=s.concat(p),x=y.join(".");return m.createElement("div",{key:x,"data-key":x,className:"flex flex-col items-start w-full gap-2 pl-2 py-1 pr-1 border-b border-neutral-700 last:border-b-0"},m.createElement(Ji,{value:e[p],onChange:t,keys:y,path:x,label:p,mutable:n,objectRefAcc:i}))})),g&&m.createElement("button",{onclick:d,title:"Show more",className:"p-1 border font-bold border-neutral-700 hover:bg-neutral-700"},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m.createElement("circle",{cx:"12",cy:"12",r:"1"}),m.createElement("circle",{cx:"19",cy:"12",r:"1"}),m.createElement("circle",{cx:"5",cy:"12",r:"1"}))))}function Un(e,t){Array.isArray(e)?(t(e),e.forEach(n=>Un(n,t))):typeof e=="object"&&e!==null&&(t(e),Object.values(e).forEach(n=>Un(n,t)))}function Ji({value:e,onChange:t,keys:n,path:i,mutable:s,objectRefAcc:o,label:r}){const{userSettings:{arrayChunkSize:a}}=ei(),[l,c]=xe(!0),h=r!==void 0&&m.createElement("label",{htmlFor:i,className:"text-xs truncate",title:i,children:r});if(e===null)return m.createElement(pt,null,h,m.createElement(jt,null,"null"));if(e===void 0)return m.createElement(pt,null,h,m.createElement(jt,null,"undefined"));const d=window.opener?window.opener.Node:Node;if(e instanceof d)return m.createElement(pt,null,h,m.createElement(jt,null,"<",m.createElement("span",{style:{color:"#f0a05e"}},e.nodeName),"/>"));const g=window.opener?window.opener.Error:Error;if(e instanceof g)return m.createElement(pt,null,h,"cause"in e&&e.cause?m.createElement(jt,null,e.message," (",String(e.cause),")"):m.createElement(jt,null,e.message));const p=y=>t(n,y);switch(typeof e){case"string":return m.createElement(pt,null,h,m.createElement(pi,{disabled:!s,id:i,type:"text",value:e,onchange:y=>p(y.target.value)}));case"number":return m.createElement(pt,null,h,m.createElement(pi,{disabled:!s,id:i,type:"number",value:e,placeholder:"NaN",onchange:y=>p(Number(y.target.value))}));case"bigint":return m.createElement(pt,null,h,m.createElement(pi,{disabled:!s,id:i,type:"number",value:e.toString(),onchange:y=>p(BigInt(y.target.value))}));case"boolean":return m.createElement(pt,null,h,m.createElement("input",{disabled:!s,id:i,type:"checkbox",checked:e,onchange:y=>p(y.target.checked),className:"accent-red-500"}));case"function":return m.createElement(pt,null,h,m.createElement(jt,null,\`\u0192 \${e.name||"anonymous"}()\`));default:return Array.isArray(e)?m.createElement(pt,null,m.createElement("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",title:i,onclick:()=>{Un(e,y=>o.splice(o.indexOf(y),1)),c(y=>!y)}},r,m.createElement(Kt,{width:10,height:10,className:\`transition \${l?"":"rotate-90"}\`})),l?m.createElement(jt,null,"Array(",e.length,")"):e.length>a?m.createElement(Ml,{array:e,objectRefAcc:o}):m.createElement("div",{className:"flex flex-col items-start gap-1 w-full"},e.map((y,x)=>m.createElement(Ji,{value:y,onChange:t,keys:[...n,x.toString()],path:i.concat(".",x.toString()),label:x.toString(),mutable:s,objectRefAcc:o})))):o.includes(e)?m.createElement(pt,null,h,m.createElement(jt,null,"Object(circular reference)")):(o.push(e),m.createElement(pt,null,m.createElement("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",title:i,onclick:()=>{Un(e,y=>o.splice(o.indexOf(y),1)),c(y=>!y)}},r,m.createElement(Kt,{width:10,height:10,className:\`transition \${l?"":"rotate-90"}\`})),l?null:m.createElement(ye,{data:e,onChange:t,keys:n,mutable:s,objectRefAcc:o})))}}function pt({children:e}){return m.createElement("div",{className:"flex flex-col items-start gap-1 w-full"},e)}function pi(e){return m.createElement("input",{className:"flex-grow text-xs px-2 py-1 text-neutral-300 w-full",...e})}function jt({children:e}){return m.createElement("small",{className:"text-neutral-300"},m.createElement("i",null,e))}function Ml({array:e,objectRefAcc:t}){const{userSettings:{arrayChunkSize:n}}=ei(),i=e.length,s=Math.ceil(i/n);return m.createElement("div",{className:"flex flex-col items-start gap-1 w-full"},Array.from({length:s}).map((o,r)=>m.createElement(Ol,{array:e,range:{start:r*n,end:(r+1)*n},objectRefAcc:t})))}function Ol({array:e,range:t,objectRefAcc:n}){const[i,s]=xe(!0);let o;return i?o=void 0:o=e.slice(t.start,t.end),m.createElement("div",{className:"flex flex-col items-start gap-1 w-full"},m.createElement("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",onclick:()=>{n.splice(n.indexOf(e),1),s(r=>!r)}},"[",t.start,"..",(t.end<e.length?t.end:e.length)-1,"]",m.createElement(Kt,{width:10,height:10,className:\`transition \${i?"":"rotate-90"}\`})),o&&m.createElement("div",{className:"flex flex-col items-start gap-1 w-full"},o.map((r,a)=>m.createElement(Ji,{value:r,onChange:Tl,label:(t.start+a).toString(),keys:[a.toString()],path:a.toString(),mutable:!1,objectRefAcc:n}))))}const Cl="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??=null);class Pl extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}}const Pe=new Pl(Cl);function ts({fn:e,onclick:t}){const n=jn(()=>ml(e),[e]);return n?m.createElement("a",{className:"flex items-center gap-1 text-[10px] opacity-50 hover:opacity-100 transition-opacity",href:n,onclick:i=>{i.preventDefault(),Pe.send({type:"open-editor",fileLink:n}),t?.(i)},title:"Open in editor"},"Open in editor",m.createElement(yl,{width:"0.65rem",height:"0.65rem"})):null}function Dl({selectedApp:e,selectedNode:t,setSelectedNode:n,kiruGlobal:i}){const s=te();ct(()=>{const l=c=>{c===e&&(dl(t)?n(null):s())};return i?.on("update",l),()=>i?.off("update",l)},[]);const o=()=>{!t||!e?.mounted||e.requestUpdate(t)},r={...t.props};delete r.children;const a=Nl(t);return m.createElement("div",{className:"flex-grow p-2 sticky top-0"},m.createElement("h2",{className:"flex justify-between items-center font-bold mb-2 pb-2 border-b-2 border-neutral-800"},m.createElement("div",{className:"flex gap-2 items-center"},"<"+_r(t)+">",m.createElement(ts,{fn:t.type})),m.createElement("button",{onclick:o},m.createElement(wl,{className:"w-5 h-5"}))),m.createElement(Sr,{title:"props",disabled:Object.keys(r).length===0},m.createElement(ye,{data:r,onChange:()=>{},mutable:!1,objectRefAcc:[]})),m.createElement(Cr,{node:a,selectedApp:e}))}function Al(e){return e.name==="devtools:useHookDebugGroup"}function Il(e){return Oi in e}const Oi=Symbol.for("devtools.hookGroup");function Nl(e){const t={parent:null,name:"hooks",children:[],[Oi]:!0};if(e.hooks?.length){let n=t;for(let i=0;i<e.hooks.length;i++){const s=e.hooks[i];if(Al(s)){switch(s.action){case"start":const o={parent:n,name:s.displayName,children:[],[Oi]:!0};n.children.push(o),n=o;break;case"end":if(n.name!==s.displayName||n.parent===null)throw new Error("useHookDebugGroup:end called with no start");n=n.parent;break}continue}n.children.push(s)}}return t}function Cr({node:e,selectedApp:t,depth:n=0}){if(Il(e))return m.createElement(Sr,{title:e.name,className:"bg-[#ffffff04] border border-[#fff1] flex flex-col gap-2 pl-6",disabled:e.children.length===0},e.children.map(h=>m.createElement(Cr,{node:h,selectedApp:t,depth:n+1})));const{name:i,dev:s,cleanup:o,...r}=e,a=s?.devtools,l=typeof a?.get=="function"?a.get():r,c=(h,d)=>{if(!t?.mounted||!a?.set||!a?.get)return;const g=a.get();Zi(g,h,d),a.set(g)};return m.createElement("div",null,m.createElement("i",{className:"text-neutral-300 text-sm"},i||"anonymous hook"),m.createElement("div",{className:"p-2"},m.createElement(ye,{data:l,onChange:c,mutable:!!a?.set,objectRefAcc:[]})))}const ge=(e,t,n={})=>{ct(()=>{let i=window;const s=n?.ref?.();return s?i=s:n.ref&&console.warn("useEventListener ref failed, using window"),i.addEventListener(e,t,n),()=>{i.removeEventListener(e,t,n)}},[t])},Ll=()=>{const e=Q({x:0,y:0}),t=Q({x:0,y:0}),n=Q({x:0,y:0});return ge("mousemove",i=>{e.value={x:i.x,y:i.y},t.value={x:i.movementX,y:i.movementY},n.value={x:i.clientX,y:i.clientY}}),{mouse:e,delta:t,client:n}},Sn="window"in globalThis&&"ResizeObserver"in globalThis.window,Rl=(e,t,n=void 0)=>mr()?Sn?br("useResizeObserver",{resizeObserver:null,deps:[e.current]},({isInit:i,hook:s,queueEffect:o})=>(i&&(s.resizeObserver=new ResizeObserver(t),s.cleanup=()=>{s.resizeObserver?.disconnect?.(),s.resizeObserver=null}),o(()=>{xr([e.current],s.deps)&&(s.deps=[e.current],s.resizeObserver?.disconnect?.(),e.current&&s.resizeObserver?.observe(e.current,n))}),{isSupported:Sn,start:()=>{s.resizeObserver==null&&(s.resizeObserver=new ResizeObserver(t),e.current&&s.resizeObserver.observe(e.current,n),s.cleanup=()=>{s.resizeObserver?.disconnect?.(),s.resizeObserver=null})},stop:()=>{yr(s)}})):{isSupported:Sn,start:()=>{},stop:()=>{}}:{isSupported:Sn,start:()=>{},stop:()=>{}},kn="window"in globalThis&&"MutationObserver"in globalThis.window,zl=(e,t,n=void 0)=>mr()?kn?br("useMutationObserver",{mutationObserver:null,deps:[e.current]},({isInit:i,hook:s,queueEffect:o})=>(i?(o(()=>{s.deps=[e.current],s.mutationObserver=new MutationObserver(t),e.current&&s.mutationObserver.observe(e.current,n)}),s.cleanup=()=>{s.mutationObserver?.disconnect?.(),s.mutationObserver=null}):xr([e.current],s.deps)&&(s.deps=[e.current],s.mutationObserver?.disconnect?.(),e.current&&s.mutationObserver?.observe(e.current,n)),{isSupported:kn,start:()=>{s.mutationObserver==null&&(s.mutationObserver=new MutationObserver(t),e.current&&s.mutationObserver.observe(e.current,n),s.cleanup=()=>{s.mutationObserver?.disconnect?.(),s.mutationObserver=null})},stop:()=>{yr(s)}})):{isSupported:kn,start:()=>{},stop:()=>{}}:{isSupported:kn,start:()=>{},stop:()=>{}},Fl=(e,t={windowScroll:!0,windowResize:!0})=>{const n=t?.windowScroll??!0,i=t?.windowResize??!0,s=t.immediate??!0,o=Q(0),r=Q(0),a=Q(0),l=Q(0),c=Q(0),h=Q(0),d=Q(0),g=Q(0),p=()=>{const y=e.current;if(!y){o.value=0,r.value=0,a.value=0,l.value=0,c.value=0,h.value=0,d.value=0,g.value=0;return}const x=y.getBoundingClientRect();o.value=x.width,r.value=x.height,a.value=x.top,l.value=x.right,c.value=x.bottom,h.value=x.left,d.value=x.x,g.value=x.y};return Rl(e,p),zl(e,p,{attributeFilter:["style","class"]}),ge("scroll",()=>{n&&p()},{capture:!0,passive:!0}),ge("resize",()=>{i&&p()},{passive:!0}),Ki(()=>{s&&p()},[]),{width:o,height:r,top:a,right:l,bottom:c,left:h,x:d,y:g,update:p}};function Hl(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}const Hs=(e,t,n={})=>{const{ref:i,eventName:s="keydown",passive:o=!1}=n,r=Hl(e);return ge(s,l=>{l.repeat&&!n.repeat||r(l)&&t(l)},{ref:i,passive:o})};function Pr({value:e,className:t,...n}){return m.createElement("div",{className:Mi("w-full p-2 z-10","bg-[#1d1d1d] border border-white border-opacity-10 rounded",t?.toString()),...n},m.createElement("input",{className:Mi("px-2 py-1 w-full rounded focus:outline focus:outline-primary","bg-[#212121] border border-white border-opacity-10 rounded"),placeholder:"Filter...",type:"text","bind:value":e}))}let U;"window"in globalThis&&window.opener&&(U=window.opener.__kiru);const Me=ht(!1);Pe.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(Me.value=e.data.value)});const Dr=(U?.apps??[]).filter(e=>!an(e)),Xt=ht(Dr);ht(null);const Pt=ht(Dr[0]??null),qt=ht(null);U?.on("mount",e=>{an(e)||(Xt.value=[...Xt.peek(),e],Pt.peek()===null&&(Pt.value=e))});U?.on("unmount",e=>{Xt.value=Xt.peek().filter(t=>t!==e),Pt.peek()===e&&(Pt.value=Xt.peek()[0]??null)});const Ci=ht(new Map),Dt=ht(null),es=ht("");function Bl(e){return e.type.displayName??(e.type.name||"Anonymous Function")}function Wl(e,t){const n=t.toLowerCase();return e.every(i=>n.includes(i))}function Pi(e){return typeof e.type=="function"&&!fl(e)&&!gl(e)&&!pl(e)}function Vl(e){let t=[e];for(;t.length;){const n=t.pop();if(Pi(n))return!0;n.child&&t.push(n.child),n.sibling&&t.push(n.sibling)}return!1}const jl=(e,t)=>{const n=[t.parent];for(;n.length;){const i=n.pop();if(e===i)return!0;i?.parent&&n.push(i.parent)}return!1};function Di(e,t){if(!e)return null;const n=t(e),i=Di(e.sibling,t),s=Di(e.child,t);return n?{ref:e,sibling:i??null,child:s??null}:i||s||null}function Yn({node:e,traverseSiblings:t=!0}){const[n,i]=xe(!0),o=qt.value===e,r=jn(()=>crypto.randomUUID(),[]),a=jn(()=>Dt.value==null?null:jl(e,Dt.value),[Dt.value,e]);ct(()=>{a&&i(!1)},[a]),ct(()=>{if(!(!e||!Pi(e)))return Ci.peek().set(r,{vNode:e,setCollapsed:i}),()=>{Ci.peek().delete(r)}});const l=es.value;if(!e)return null;if(!Pi(e)||l.length>0&&!Wl(l.toLowerCase().split(" "),e.type.name))return m.createElement(m.Fragment,null,e.child&&m.createElement(Yn,{node:e.child}),t&&m.createElement(Bs,{node:e}));const c=e.child&&Vl(e.child);return m.createElement(m.Fragment,null,m.createElement("div",{className:"pl-4 mb-1"},m.createElement("h2",{onclick:()=>{Dt.value=null,qt.value=o?null:e},className:\`flex gap-2 items-center cursor-pointer mb-1 scroll-m-12 \${o?"font-medium bg-primary selected-vnode":""}\`,"data-id":r},c&&m.createElement(Kt,{className:\`cursor-pointer transition \${n?"":"rotate-90"}\`,onclick:h=>{h.preventDefault(),h.stopImmediatePropagation(),Dt.value=null,i(d=>!d)}}),m.createElement("div",{className:c?"":"ml-6"},m.createElement("span",{className:o?"":"text-neutral-400"},"<"),m.createElement("span",{className:o?"":"text-primary"},Bl(e)),m.createElement("span",{className:o?"":"text-neutral-400"},">"))),!n&&e.child||a!=null&&a&&e.child?m.createElement(Yn,{node:e.child}):null),t&&m.createElement(Bs,{node:e}))}function Bs({node:e}){if(!e)return null;let t=[],n=e.sibling;for(;n;)t.push(n),n=n.sibling;return m.createElement(m.Fragment,null,t.map(i=>m.createElement(Yn,{node:i,traverseSiblings:!1})))}const Ul=()=>{const e=Ce(null),t=r=>{if(!r)return null;const a=r.getAttribute("data-id");if(a!=null)return Ci.peek().get(a)},n=r=>{if(!r)return;const a=t(r);a!=null&&(r.scrollIntoView({behavior:"smooth"}),qt.value=a.vNode)},i=r=>{if(!r||r===document.body)return null;const a=r.parentElement,l=a?.nextElementSibling?.querySelector("h2[data-id]");return l||i(a)},s=()=>{const r=document.querySelector("h2[data-id]");n(r)},o=()=>{const r=document.querySelectorAll("h2[data-id]"),a=r.item(r.length-1);a&&n(a)};return Hs(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],r=>{if(Dt.value&&(Dt.value=null),document.activeElement&&document.activeElement instanceof HTMLInputElement&&document.activeElement!=e.current)return;r.preventDefault();const a=document.querySelector(".selected-vnode");if(a===null){r.key==="ArrowDown"?s():r.key==="ArrowUp"&&o();return}if(r.key==="ArrowRight"){const l=t(a);l&&l.setCollapsed(!1);return}else if(r.key==="ArrowLeft"){const l=t(a);l&&l.setCollapsed(!0);return}if(r.key==="ArrowDown"){const l=a?.nextElementSibling?.querySelector("h2[data-id]");if(l)return n(l);const c=a.parentElement?.nextElementSibling?.querySelector("h2[data-id]");if(c)return n(c);const h=i(a);return h?n(h):s()}else if(r.key==="ArrowUp"){const l=a.parentElement?.previousElementSibling;if(l?.matches("h2[data-id]"))return n(l);const c=l?.querySelectorAll("h2[data-id]");return c?.length!=null&&c?.length>=1?n(c?.item?.(c.length-1)):o()}}),Hs("l",r=>{r.ctrlKey&&(r.preventDefault(),e.current?.focus({preventScroll:!1}))}),{searchRef:e}},Yl=e=>{es.value=e.target.value,Dt.value&&(Dt.value=null)};function $l(){const{searchRef:e}=Ul(),t=Pt.value;return m.createElement("div",{className:"flex-grow p-2 sticky top-0"},m.createElement("div",{className:"flex gap-4 pb-2 border-b-2 border-neutral-800 mb-2 items-center"},m.createElement("input",{ref:e,className:"bg-[#171616] px-1 py-2 w-full focus:outline focus:outline-primary",placeholder:"Search for component",type:"text",value:es,oninput:Yl})),t?.rootNode&&m.createElement(Yn,{node:t.rootNode}))}const Xl=e=>{const{mouse:t}=Ll(),n=Q(null),i=Q(0),s=Q(0),o=Ce(null),r=Fl(o),a=Ce(null),[l,c]=Array.isArray(e.children)?e.children:[];return Ki(()=>{a.current&&(s.value=a.current.clientWidth/2)},[a.current]),ge("mouseup",Te(()=>n.value=null,[])),ge("mousemove",Te(h=>{if(n.value==null||a.current==null)return;const d=Math.max(i.value+h.x-n.value.x,250);s.value=Math.min(d,a.current.clientWidth-250)},[])),ge("resize",Te(()=>{a.current!=null&&a.current.clientWidth-250<s.value&&(s.value=Math.max(a.current.clientWidth-250,250))},[])),m.createElement("div",{onmousemove:h=>{h.x},ref:a,className:"flex-grow grid gap-2 items-start w-full relative",style:{gridTemplateColumns:\`\${s}px 1fr\`}},m.createElement("div",{ref:o,className:"firstContainer w-full h-full"},l),r.width.value!=0&&m.createElement("div",{className:"w-8 flex justify-center h-full absolute top-0 -translate-x-1/2 cursor-col-resize z-[9999]",style:{left:\`\${r.width}px\`},onmousedown:h=>{h.preventDefault(),n.value={...t.value},i.value=s.value}},m.createElement("div",{className:"dividerLine w-[5px] bg-neutral-800 h-full"})),m.createElement("div",{className:"secondContainer h-full"},c))},ql=()=>m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-square-mouse-pointer"},m.createElement("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),m.createElement("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"})),Gl=()=>{Me.value=!Me.value,Pe.send({type:"set-inspect-enabled",value:Me.value})};function Kl(){const e=Pt.value,t=qt.value,n=te();return ct(()=>{const i=s=>{s===e&&n()};return U?.on("update",i),()=>U?.off("update",i)},[Pt]),ct(()=>{const i=s=>{if(s.data.type!=="select-node")return;if(!window.__devtoolsSelection){console.error("no selection ptr");return}const{app:o,node:r}=window.__devtoolsSelection;window.__devtoolsSelection=null,Pt.value=o,qt.value=r,Dt.value=r,Me.value=!1};return Pe.addEventListener(i),()=>Pe.removeEventListener(i)},[Pt]),m.createElement(m.Fragment,null,m.createElement("div",{className:"flex items-center justify-between gap-4 p-2 bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 rounded"},m.createElement("div",{className:"flex items-center gap-4"},m.createElement("select",{className:"px-2 py-1 bg-neutral-800 text-neutral-100 rounded border border-white border-opacity-10",value:e?.name??"",onchange:i=>Pt.value=Xt.peek().find(s=>s.name===i.currentTarget.value)??null},m.createElement("option",{value:"",disabled:!0},"Select App"),Xt.value.map(i=>m.createElement("option",{key:i.id,value:i.name},i.name))),m.createElement("button",{title:"Toggle Component Inspection",onclick:Gl,className:\`p-1 rounded \${Me.value?"bg-neutral-900":""}\`},m.createElement(ql,null)))),m.createElement(Xl,null,e&&m.createElement($l,null),t&&e&&m.createElement(Dl,{selectedApp:e,selectedNode:t,setSelectedNode:i=>qt.value=i,kiruGlobal:U})))}const Ai=ht({}),ue=ht([]);U?.stores?.subscribe(e=>{Ai.value=e,ue.value=ue.value.filter(t=>Object.values(Ai.value).includes(t))});const Ar=ht(""),Zl=vr(()=>Ar.value.toLowerCase().split(" ").filter(e=>e.length>0));function Ql(e){return Zl.value.every(t=>e.toLowerCase().includes(t))}function Jl(){const e=Object.entries(Ai.value);return e.length===0?m.createElement("div",{className:"flex flex-col items-center justify-center h-full text-neutral-400"},m.createElement(Er,null),m.createElement("h2",{className:"text-lg italic"},"No stores detected")):m.createElement("div",{className:"flex flex-col gap-2 items-start"},m.createElement(Pr,{value:Ar,className:"sticky top-0"}),m.createElement("div",{className:"flex flex-col gap-2 w-full"},e.filter(([t])=>Ql(t)).map(([t,n])=>m.createElement(tc,{key:t,name:t,store:n}))))}function tc({name:e,store:t}){const n=ue.value.includes(t),i=te(),{value:s}=Ir(t);Ki(()=>{const r=t.subscribe(()=>i());return()=>r()},[]);const o=Te(()=>{n?ue.value=ue.value.filter(r=>r!==t):ue.value=[...ue.value,t]},[n]);return m.createElement("div",{className:"flex flex-col"},m.createElement("button",{onclick:o,className:"flex items-center gap-2 justify-between p-2 border border-white border-opacity-10 cursor-pointer"+(n?" bg-white bg-opacity-5 text-neutral-100 rounded-t":" hover:bg-white hover:bg-opacity-10 text-neutral-400 rounded")},e,m.createElement("div",{className:"flex gap-2"},m.createElement(ts,{fn:t,onclick:r=>r.stopPropagation()}),m.createElement(Kt,{className:"transition-all"+(n?" rotate-90":"")}))),n&&m.createElement("div",{className:"flex flex-col gap-2 p-2 border border-white border-opacity-10"},m.createElement(ye,{data:{value:s},mutable:!0,objectRefAcc:[],onChange:(r,a)=>{const l=structuredClone({value:s});Zi(l,r,a),t.setState(l.value)}}),m.createElement(ec,{store:t})))}function ec({store:e}){const t=Xt.value;return t.length===0?null:m.createElement(m.Fragment,null,t.map(n=>!n.mounted||!n.rootNode?null:m.createElement(nc,{store:e,app:n})))}const Ws=Symbol.for("kiru.hmrAccept"),Ir=e=>{if(Ws in e)return e[Ws].provide().current;throw new Error("Unable to get store subscribers")};function nc({store:e,app:t}){const n=te(),{subscribers:i,nodeStateMap:s}=Ir(e),o=t.rootNode.child;if(ct(()=>{const a=l=>{l===t&&n()};return U?.on("update",a),()=>U?.off("update",a)},[]),!o)return null;const r=Di(o,a=>i.has(a));return m.createElement("div",{className:"flex flex-col gap-2 p-2 rounded-b border border-white border-opacity-10"},m.createElement("b",null,t.name),r&&m.createElement("ul",{className:"pl-8"},m.createElement(Ii,{node:r,nodeStateMap:s})))}function Ii({node:e,nodeStateMap:t}){const[n,i]=xe(!1),o=t.get(e.ref)?.slices??[];return m.createElement(m.Fragment,null,m.createElement("li",{className:"flex flex-col gap-2"},m.createElement("div",{className:"flex flex-col border border-white border-opacity-10 rounded"+(n?" bg-white bg-opacity-5 text-neutral-100":" hover:bg-white hover:bg-opacity-10 text-neutral-400")},m.createElement("button",{onclick:()=>i(!n),className:"flex gap-2 p-2 justify-between cursor-pointer"},m.createElement("span",null,"<"+_r(e.ref)+" />"),m.createElement("div",{className:"flex gap-2 items-center"},m.createElement(ts,{fn:e.ref.type,onclick:r=>r.stopPropagation()}),m.createElement(Kt,{className:"transition-all"+(n?" rotate-90":"")}))),n&&m.createElement("div",{className:"flex flex-col gap-2 p-2 bg-[#1a1a1a]"},o.length===0&&m.createElement("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},m.createElement("h5",{className:"border-b border-white border-opacity-10"},"No slices")),o.map(r=>m.createElement("div",{className:"flex flex-col gap-2"},m.createElement("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},m.createElement("h5",{className:"border-b border-white border-opacity-10"},"Slice:"),m.createElement("pre",{className:"text-neutral-400"},m.createElement(ye,{data:{value:r.value},mutable:!1,objectRefAcc:[],onChange:()=>{}}))),m.createElement("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},m.createElement("h5",{className:"border-b border-white border-opacity-10"},"SliceFn:"),m.createElement("pre",{className:"text-neutral-400"},r.sliceFn?r.sliceFn.toString():"null")),r.eq&&m.createElement("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},m.createElement("h5",{className:"border-b border-white border-opacity-10"},"eq:"),m.createElement("pre",{className:"text-neutral-400"},r.eq.toString())))))),e.child&&m.createElement("ul",{className:"pl-8 flex flex-col gap-2"},m.createElement(Ii,{node:e.child,nodeStateMap:t}))),e.sibling&&m.createElement(Ii,{node:e.sibling,nodeStateMap:t}))}/*!
1696
+ * @kurkle/color v0.3.4
1697
+ * https://github.com/kurkle/color#readme
1698
+ * (c) 2024 Jukka Kurkela
1699
+ * Released under the MIT License
1700
+ */function fn(e){return e+.5|0}const Yt=(e,t,n)=>Math.max(Math.min(e,n),t);function Ke(e){return Yt(fn(e*2.55),0,255)}function Gt(e){return Yt(fn(e*255),0,255)}function Ht(e){return Yt(fn(e/2.55)/100,0,1)}function Vs(e){return Yt(fn(e*100),0,100)}const mt={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},Ni=[..."0123456789ABCDEF"],ic=e=>Ni[e&15],sc=e=>Ni[(e&240)>>4]+Ni[e&15],Tn=e=>(e&240)>>4===(e&15),oc=e=>Tn(e.r)&&Tn(e.g)&&Tn(e.b)&&Tn(e.a);function rc(e){var t=e.length,n;return e[0]==="#"&&(t===4||t===5?n={r:255&mt[e[1]]*17,g:255&mt[e[2]]*17,b:255&mt[e[3]]*17,a:t===5?mt[e[4]]*17:255}:(t===7||t===9)&&(n={r:mt[e[1]]<<4|mt[e[2]],g:mt[e[3]]<<4|mt[e[4]],b:mt[e[5]]<<4|mt[e[6]],a:t===9?mt[e[7]]<<4|mt[e[8]]:255})),n}const ac=(e,t)=>e<255?t(e):"";function lc(e){var t=oc(e)?ic:sc;return e?"#"+t(e.r)+t(e.g)+t(e.b)+ac(e.a,t):void 0}const cc=/^(hsla?|hwb|hsv)\\(\\s*([-+.e\\d]+)(?:deg)?[\\s,]+([-+.e\\d]+)%[\\s,]+([-+.e\\d]+)%(?:[\\s,]+([-+.e\\d]+)(%)?)?\\s*\\)$/;function Nr(e,t,n){const i=t*Math.min(n,1-n),s=(o,r=(o+e/30)%12)=>n-i*Math.max(Math.min(r-3,9-r,1),-1);return[s(0),s(8),s(4)]}function hc(e,t,n){const i=(s,o=(s+e/60)%6)=>n-n*t*Math.max(Math.min(o,4-o,1),0);return[i(5),i(3),i(1)]}function uc(e,t,n){const i=Nr(e,1,.5);let s;for(t+n>1&&(s=1/(t+n),t*=s,n*=s),s=0;s<3;s++)i[s]*=1-t-n,i[s]+=t;return i}function dc(e,t,n,i,s){return e===s?(t-n)/i+(t<n?6:0):t===s?(n-e)/i+2:(e-t)/i+4}function ns(e){const n=e.r/255,i=e.g/255,s=e.b/255,o=Math.max(n,i,s),r=Math.min(n,i,s),a=(o+r)/2;let l,c,h;return o!==r&&(h=o-r,c=a>.5?h/(2-o-r):h/(o+r),l=dc(n,i,s,h,o),l=l*60+.5),[l|0,c||0,a]}function is(e,t,n,i){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,i)).map(Gt)}function ss(e,t,n){return is(Nr,e,t,n)}function fc(e,t,n){return is(uc,e,t,n)}function gc(e,t,n){return is(hc,e,t,n)}function Lr(e){return(e%360+360)%360}function pc(e){const t=cc.exec(e);let n=255,i;if(!t)return;t[5]!==i&&(n=t[6]?Ke(+t[5]):Gt(+t[5]));const s=Lr(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?i=fc(s,o,r):t[1]==="hsv"?i=gc(s,o,r):i=ss(s,o,r),{r:i[0],g:i[1],b:i[2],a:n}}function mc(e,t){var n=ns(e);n[0]=Lr(n[0]+t),n=ss(n),e.r=n[0],e.g=n[1],e.b=n[2]}function bc(e){if(!e)return;const t=ns(e),n=t[0],i=Vs(t[1]),s=Vs(t[2]);return e.a<255?\`hsla(\${n}, \${i}%, \${s}%, \${Ht(e.a)})\`:\`hsl(\${n}, \${i}%, \${s}%)\`}const js={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"},Us={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 xc(){const e={},t=Object.keys(Us),n=Object.keys(js);let i,s,o,r,a;for(i=0;i<t.length;i++){for(r=a=t[i],s=0;s<n.length;s++)o=n[s],a=a.replace(o,js[o]);o=parseInt(Us[r],16),e[a]=[o>>16&255,o>>8&255,o&255]}return e}let Mn;function yc(e){Mn||(Mn=xc(),Mn.transparent=[0,0,0,0]);const t=Mn[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const vc=/^rgba?\\(\\s*([-+.\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?(?:[\\s,/]+([-+.e\\d]+)(%)?)?\\s*\\)$/;function _c(e){const t=vc.exec(e);let n=255,i,s,o;if(t){if(t[7]!==i){const r=+t[7];n=t[8]?Ke(r):Yt(r*255,0,255)}return i=+t[1],s=+t[3],o=+t[5],i=255&(t[2]?Ke(i):Yt(i,0,255)),s=255&(t[4]?Ke(s):Yt(s,0,255)),o=255&(t[6]?Ke(o):Yt(o,0,255)),{r:i,g:s,b:o,a:n}}}function wc(e){return e&&(e.a<255?\`rgba(\${e.r}, \${e.g}, \${e.b}, \${Ht(e.a)})\`:\`rgb(\${e.r}, \${e.g}, \${e.b})\`)}const mi=e=>e<=.0031308?e*12.92:Math.pow(e,1/2.4)*1.055-.055,ke=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function Ec(e,t,n){const i=ke(Ht(e.r)),s=ke(Ht(e.g)),o=ke(Ht(e.b));return{r:Gt(mi(i+n*(ke(Ht(t.r))-i))),g:Gt(mi(s+n*(ke(Ht(t.g))-s))),b:Gt(mi(o+n*(ke(Ht(t.b))-o))),a:e.a+n*(t.a-e.a)}}function On(e,t,n){if(e){let i=ns(e);i[t]=Math.max(0,Math.min(i[t]+i[t]*n,t===0?360:1)),i=ss(i),e.r=i[0],e.g=i[1],e.b=i[2]}}function Rr(e,t){return e&&Object.assign(t||{},e)}function Ys(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=Gt(e[3]))):(t=Rr(e,{r:0,g:0,b:0,a:1}),t.a=Gt(t.a)),t}function Sc(e){return e.charAt(0)==="r"?_c(e):pc(e)}class ln{constructor(t){if(t instanceof ln)return t;const n=typeof t;let i;n==="object"?i=Ys(t):n==="string"&&(i=rc(t)||yc(t)||Sc(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=Rr(this._rgb);return t&&(t.a=Ht(t.a)),t}set rgb(t){this._rgb=Ys(t)}rgbString(){return this._valid?wc(this._rgb):void 0}hexString(){return this._valid?lc(this._rgb):void 0}hslString(){return this._valid?bc(this._rgb):void 0}mix(t,n){if(t){const i=this.rgb,s=t.rgb;let o;const r=n===o?.5:n,a=2*r-1,l=i.a-s.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,i.r=255&c*i.r+o*s.r+.5,i.g=255&c*i.g+o*s.g+.5,i.b=255&c*i.b+o*s.b+.5,i.a=r*i.a+(1-r)*s.a,this.rgb=i}return this}interpolate(t,n){return t&&(this._rgb=Ec(this._rgb,t._rgb,n)),this}clone(){return new ln(this.rgb)}alpha(t){return this._rgb.a=Gt(t),this}clearer(t){const n=this._rgb;return n.a*=1-t,this}greyscale(){const t=this._rgb,n=fn(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=n,this}opaquer(t){const n=this._rgb;return n.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return On(this._rgb,2,t),this}darken(t){return On(this._rgb,2,-t),this}saturate(t){return On(this._rgb,1,t),this}desaturate(t){return On(this._rgb,1,-t),this}rotate(t){return mc(this._rgb,t),this}}/*!
1701
+ * Chart.js v4.5.0
1702
+ * https://www.chartjs.org
1703
+ * (c) 2025 Chart.js Contributors
1704
+ * Released under the MIT License
1705
+ */function Rt(){}const kc=(()=>{let e=0;return()=>e++})();function W(e){return e==null}function Z(e){if(Array.isArray&&Array.isArray(e))return!0;const t=Object.prototype.toString.call(e);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function B(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function xt(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function Tt(e,t){return xt(e)?e:t}function L(e,t){return typeof e>"u"?t:e}const Tc=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function I(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function z(e,t,n,i){let s,o,r;if(Z(e))for(o=e.length,s=0;s<o;s++)t.call(n,e[s],s);else if(B(e))for(r=Object.keys(e),o=r.length,s=0;s<o;s++)t.call(n,e[r[s]],r[s])}function $n(e,t){let n,i,s,o;if(!e||!t||e.length!==t.length)return!1;for(n=0,i=e.length;n<i;++n)if(s=e[n],o=t[n],s.datasetIndex!==o.datasetIndex||s.index!==o.index)return!1;return!0}function Xn(e){if(Z(e))return e.map(Xn);if(B(e)){const t=Object.create(null),n=Object.keys(e),i=n.length;let s=0;for(;s<i;++s)t[n[s]]=Xn(e[n[s]]);return t}return e}function zr(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function Mc(e,t,n,i){if(!zr(e))return;const s=t[e],o=n[e];B(s)&&B(o)?cn(s,o,i):t[e]=Xn(o)}function cn(e,t,n){const i=Z(t)?t:[t],s=i.length;if(!B(e))return e;n=n||{};const o=n.merger||Mc;let r;for(let a=0;a<s;++a){if(r=i[a],!B(r))continue;const l=Object.keys(r);for(let c=0,h=l.length;c<h;++c)o(l[c],e,r,n)}return e}function tn(e,t){return cn(e,t,{merger:Oc})}function Oc(e,t,n){if(!zr(e))return;const i=t[e],s=n[e];B(i)&&B(s)?tn(i,s):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=Xn(s))}const $s={"":e=>e,x:e=>e.x,y:e=>e.y};function Cc(e){const t=e.split("."),n=[];let i="";for(const s of t)i+=s,i.endsWith("\\\\")?i=i.slice(0,-1)+".":(n.push(i),i="");return n}function Pc(e){const t=Cc(e);return n=>{for(const i of t){if(i==="")break;n=n&&n[i]}return n}}function qn(e,t){return($s[t]||($s[t]=Pc(t)))(e)}function os(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Gn=e=>typeof e<"u",Zt=e=>typeof e=="function",Xs=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};function Dc(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}const J=Math.PI,At=2*J,Ac=At+J,Kn=Number.POSITIVE_INFINITY,Ic=J/180,_t=J/2,ae=J/4,qs=J*2/3,Fr=Math.log10,Qt=Math.sign;function pe(e,t,n){return Math.abs(e-t)<n}function Gs(e){const t=Math.round(e);e=pe(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(Fr(e))),i=e/n;return(i<=1?1:i<=2?2:i<=5?5:10)*n}function Nc(e){const t=[],n=Math.sqrt(e);let i;for(i=1;i<n;i++)e%i===0&&(t.push(i),t.push(e/i));return n===(n|0)&&t.push(n),t.sort((s,o)=>s-o).pop(),t}function Lc(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function hn(e){return!Lc(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Rc(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}function zc(e,t,n){let i,s,o;for(i=0,s=e.length;i<s;i++)o=e[i][n],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function de(e){return e*(J/180)}function Fc(e){return e*(180/J)}function Ks(e){if(!xt(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function Hc(e,t){const n=t.x-e.x,i=t.y-e.y,s=Math.sqrt(n*n+i*i);let o=Math.atan2(i,n);return o<-.5*J&&(o+=At),{angle:o,distance:s}}function Li(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Bc(e,t){return(e-t+Ac)%At-J}function Ut(e){return(e%At+At)%At}function Hr(e,t,n,i){const s=Ut(e),o=Ut(t),r=Ut(n),a=Ut(o-s),l=Ut(r-s),c=Ut(s-o),h=Ut(s-r);return s===o||s===r||i&&o===r||a>l&&c<h}function bt(e,t,n){return Math.max(t,Math.min(n,e))}function Wc(e){return bt(e,-32768,32767)}function Ze(e,t,n,i=1e-6){return e>=Math.min(t,n)-i&&e<=Math.max(t,n)+i}function rs(e,t,n){n=n||(r=>e[r]<t);let i=e.length-1,s=0,o;for(;i-s>1;)o=s+i>>1,n(o)?s=o:i=o;return{lo:s,hi:i}}const fe=(e,t,n,i)=>rs(e,n,i?s=>{const o=e[s][t];return o<n||o===n&&e[s+1][t]===n}:s=>e[s][t]<n),Vc=(e,t,n)=>rs(e,n,i=>e[i][t]>=n);function jc(e,t,n){let i=0,s=e.length;for(;i<s&&e[i]<t;)i++;for(;s>i&&e[s-1]>n;)s--;return i>0||s<e.length?e.slice(i,s):e}const Br=["push","pop","shift","splice","unshift"];function Uc(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),Br.forEach(n=>{const i="_onData"+os(n),s=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...o){const r=s.apply(this,o);return e._chartjs.listeners.forEach(a=>{typeof a[i]=="function"&&a[i](...o)}),r}})})}function Zs(e,t){const n=e._chartjs;if(!n)return;const i=n.listeners,s=i.indexOf(t);s!==-1&&i.splice(s,1),!(i.length>0)&&(Br.forEach(o=>{delete e[o]}),delete e._chartjs)}function Yc(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const Wr=function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame}();function Vr(e,t){let n=[],i=!1;return function(...s){n=s,i||(i=!0,Wr.call(window,()=>{i=!1,e.apply(t,n)}))}}function $c(e,t){let n;return function(...i){return t?(clearTimeout(n),n=setTimeout(e,t,i)):e.apply(this,i),t}}const jr=e=>e==="start"?"left":e==="end"?"right":"center",ut=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,Xc=(e,t,n,i)=>e===(i?"left":"right")?n:e==="center"?(t+n)/2:t;function qc(e,t,n){const i=t.length;let s=0,o=i;if(e._sorted){const{iScale:r,vScale:a,_parsed:l}=e,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,h=r.axis,{min:d,max:g,minDefined:p,maxDefined:y}=r.getUserBounds();if(p){if(s=Math.min(fe(l,h,d).lo,n?i:fe(t,h,r.getPixelForValue(d)).lo),c){const x=l.slice(0,s+1).reverse().findIndex(v=>!W(v[a.axis]));s-=Math.max(0,x)}s=bt(s,0,i-1)}if(y){let x=Math.max(fe(l,r.axis,g,!0).hi+1,n?0:fe(t,h,r.getPixelForValue(g),!0).hi+1);if(c){const v=l.slice(x-1).findIndex(w=>!W(w[a.axis]));x+=Math.max(0,v)}o=bt(x,s,i)-s}else o=i-s}return{start:s,count:o}}function Gc(e){const{xScale:t,yScale:n,_scaleRanges:i}=e,s={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!i)return e._scaleRanges=s,!0;const o=i.xmin!==t.min||i.xmax!==t.max||i.ymin!==n.min||i.ymax!==n.max;return Object.assign(i,s),o}const Cn=e=>e===0||e===1,Qs=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*At/n)),Js=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*At/n)+1,en={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-=1)*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-=1)*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-=1)*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*_t)+1,easeOutSine:e=>Math.sin(e*_t),easeInOutSine:e=>-.5*(Math.cos(J*e)-1),easeInExpo:e=>e===0?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>e===1?1:-Math.pow(2,-10*e)+1,easeInOutExpo:e=>Cn(e)?e:e<.5?.5*Math.pow(2,10*(e*2-1)):.5*(-Math.pow(2,-10*(e*2-1))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>Cn(e)?e:Qs(e,.075,.3),easeOutElastic:e=>Cn(e)?e:Js(e,.075,.3),easeInOutElastic(e){return Cn(e)?e:e<.5?.5*Qs(e*2,.1125,.45):.5+.5*Js(e*2-1,.1125,.45)},easeInBack(e){return e*e*((1.70158+1)*e-1.70158)},easeOutBack(e){return(e-=1)*e*((1.70158+1)*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-en.easeOutBounce(1-e),easeOutBounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},easeInOutBounce:e=>e<.5?en.easeInBounce(e*2)*.5:en.easeOutBounce(e*2-1)*.5+.5};function as(e){if(e&&typeof e=="object"){const t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function to(e){return as(e)?e:new ln(e)}function bi(e){return as(e)?e:new ln(e).saturate(.5).darken(.1).hexString()}const Kc=["x","y","borderWidth","radius","tension"],Zc=["color","borderColor","backgroundColor"];function Qc(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:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),e.set("animations",{colors:{type:"color",properties:Zc},numbers:{type:"number",properties:Kc}}),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:t=>t|0}}}})}function Jc(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const eo=new Map;function th(e,t){t=t||{};const n=e+JSON.stringify(t);let i=eo.get(n);return i||(i=new Intl.NumberFormat(e,t),eo.set(n,i)),i}function Ur(e,t,n){return th(t,n).format(e)}const eh={values(e){return Z(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";const i=this.chart.options.locale;let s,o=e;if(n.length>1){const c=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(c<1e-4||c>1e15)&&(s="scientific"),o=nh(e,n)}const r=Fr(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:s,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),Ur(e,i,l)}};function nh(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 Yr={formatters:eh};function ih(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:(t,n)=>n.lineWidth,tickColor:(t,n)=>n.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:Yr.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:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),e.describe("scales",{_fallback:"scale"}),e.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const be=Object.create(null),Ri=Object.create(null);function nn(e,t){if(!t)return e;const n=t.split(".");for(let i=0,s=n.length;i<s;++i){const o=n[i];e=e[o]||(e[o]=Object.create(null))}return e}function xi(e,t,n){return typeof t=="string"?cn(nn(e,t),n):cn(nn(e,""),t)}class sh{constructor(t,n){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=i=>i.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=(i,s)=>bi(s.backgroundColor),this.hoverBorderColor=(i,s)=>bi(s.borderColor),this.hoverColor=(i,s)=>bi(s.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(t),this.apply(n)}set(t,n){return xi(this,t,n)}get(t){return nn(this,t)}describe(t,n){return xi(Ri,t,n)}override(t,n){return xi(be,t,n)}route(t,n,i,s){const o=nn(this,t),r=nn(this,i),a="_"+n;Object.defineProperties(o,{[a]:{value:o[n],writable:!0},[n]:{enumerable:!0,get(){const l=this[a],c=r[s];return B(l)?Object.assign({},c,l):L(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(n=>n(this))}}var Y=new sh({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[Qc,Jc,ih]);function oh(e){return!e||W(e.size)||W(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function no(e,t,n,i,s){let o=t[s];return o||(o=t[s]=e.measureText(s).width,n.push(s)),o>i&&(i=o),i}function le(e,t,n){const i=e.currentDevicePixelRatio,s=n!==0?Math.max(n/2,.5):0;return Math.round((t-s)*i)/i+s}function io(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function zi(e,t,n,i){$r(e,t,n,i,null)}function $r(e,t,n,i,s){let o,r,a,l,c,h,d,g;const p=t.pointStyle,y=t.rotation,x=t.radius;let v=(y||0)*Ic;if(p&&typeof p=="object"&&(o=p.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){e.save(),e.translate(n,i),e.rotate(v),e.drawImage(p,-p.width/2,-p.height/2,p.width,p.height),e.restore();return}if(!(isNaN(x)||x<=0)){switch(e.beginPath(),p){default:s?e.ellipse(n,i,s/2,x,0,0,At):e.arc(n,i,x,0,At),e.closePath();break;case"triangle":h=s?s/2:x,e.moveTo(n+Math.sin(v)*h,i-Math.cos(v)*x),v+=qs,e.lineTo(n+Math.sin(v)*h,i-Math.cos(v)*x),v+=qs,e.lineTo(n+Math.sin(v)*h,i-Math.cos(v)*x),e.closePath();break;case"rectRounded":c=x*.516,l=x-c,r=Math.cos(v+ae)*l,d=Math.cos(v+ae)*(s?s/2-c:l),a=Math.sin(v+ae)*l,g=Math.sin(v+ae)*(s?s/2-c:l),e.arc(n-d,i-a,c,v-J,v-_t),e.arc(n+g,i-r,c,v-_t,v),e.arc(n+d,i+a,c,v,v+_t),e.arc(n-g,i+r,c,v+_t,v+J),e.closePath();break;case"rect":if(!y){l=Math.SQRT1_2*x,h=s?s/2:l,e.rect(n-h,i-l,2*h,2*l);break}v+=ae;case"rectRot":d=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,g=Math.sin(v)*(s?s/2:x),e.moveTo(n-d,i-a),e.lineTo(n+g,i-r),e.lineTo(n+d,i+a),e.lineTo(n-g,i+r),e.closePath();break;case"crossRot":v+=ae;case"cross":d=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,g=Math.sin(v)*(s?s/2:x),e.moveTo(n-d,i-a),e.lineTo(n+d,i+a),e.moveTo(n+g,i-r),e.lineTo(n-g,i+r);break;case"star":d=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,g=Math.sin(v)*(s?s/2:x),e.moveTo(n-d,i-a),e.lineTo(n+d,i+a),e.moveTo(n+g,i-r),e.lineTo(n-g,i+r),v+=ae,d=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,g=Math.sin(v)*(s?s/2:x),e.moveTo(n-d,i-a),e.lineTo(n+d,i+a),e.moveTo(n+g,i-r),e.lineTo(n-g,i+r);break;case"line":r=s?s/2:Math.cos(v)*x,a=Math.sin(v)*x,e.moveTo(n-r,i-a),e.lineTo(n+r,i+a);break;case"dash":e.moveTo(n,i),e.lineTo(n+Math.cos(v)*(s?s/2:x),i+Math.sin(v)*x);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function De(e,t,n){return n=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 ls(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function cs(e){e.restore()}function rh(e,t,n,i,s){if(!t)return e.lineTo(n.x,n.y);if(s==="middle"){const o=(t.x+n.x)/2;e.lineTo(o,t.y),e.lineTo(o,n.y)}else s==="after"!=!!i?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function ah(e,t,n,i){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(i?t.cp1x:t.cp2x,i?t.cp1y:t.cp2y,i?n.cp2x:n.cp1x,i?n.cp2y:n.cp1y,n.x,n.y)}function lh(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),W(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 ch(e,t,n,i,s){if(s.strikethrough||s.underline){const o=e.measureText(i),r=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,l=n-o.actualBoundingBoxAscent,c=n+o.actualBoundingBoxDescent,h=s.strikethrough?(l+c)/2:c;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=s.decorationWidth||2,e.moveTo(r,h),e.lineTo(a,h),e.stroke()}}function hh(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Zn(e,t,n,i,s,o={}){const r=Z(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="";let l,c;for(e.save(),e.font=s.string,lh(e,o),l=0;l<r.length;++l)c=r[l],o.backdrop&&hh(e,o.backdrop),a&&(o.strokeColor&&(e.strokeStyle=o.strokeColor),W(o.strokeWidth)||(e.lineWidth=o.strokeWidth),e.strokeText(c,n,i,o.maxWidth)),e.fillText(c,n,i,o.maxWidth),ch(e,n,i,c,o),i+=Number(s.lineHeight);e.restore()}function Fi(e,t){const{x:n,y:i,w:s,h:o,radius:r}=t;e.arc(n+r.topLeft,i+r.topLeft,r.topLeft,1.5*J,J,!0),e.lineTo(n,i+o-r.bottomLeft),e.arc(n+r.bottomLeft,i+o-r.bottomLeft,r.bottomLeft,J,_t,!0),e.lineTo(n+s-r.bottomRight,i+o),e.arc(n+s-r.bottomRight,i+o-r.bottomRight,r.bottomRight,_t,0,!0),e.lineTo(n+s,i+r.topRight),e.arc(n+s-r.topRight,i+r.topRight,r.topRight,0,-_t,!0),e.lineTo(n+r.topLeft,i)}const uh=/^(normal|(\\d+(?:\\.\\d+)?)(px|em|%)?)$/,dh=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function fh(e,t){const n=(""+e).match(uh);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}const gh=e=>+e||0;function Xr(e,t){const n={},i=B(t),s=i?Object.keys(t):t,o=B(e)?i?r=>L(e[r],e[t[r]]):r=>e[r]:()=>e;for(const r of s)n[r]=gh(o(r));return n}function ph(e){return Xr(e,{top:"y",right:"x",bottom:"y",left:"x"})}function sn(e){return Xr(e,["topLeft","topRight","bottomLeft","bottomRight"])}function wt(e){const t=ph(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function lt(e,t){e=e||{},t=t||Y.font;let n=L(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let i=L(e.style,t.style);i&&!(""+i).match(dh)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const s={family:L(e.family,t.family),lineHeight:fh(L(e.lineHeight,t.lineHeight),n),size:n,style:i,weight:L(e.weight,t.weight),string:""};return s.string=oh(s),s}function Pn(e,t,n,i){let s,o,r;for(s=0,o=e.length;s<o;++s)if(r=e[s],r!==void 0&&r!==void 0)return r}function mh(e,t,n){const{min:i,max:s}=e,o=Tc(t,(s-i)/2),r=(a,l)=>n&&a===0?0:a+l;return{min:r(i,-Math.abs(o)),max:r(s,o)}}function ve(e,t){return Object.assign(Object.create(e),t)}function hs(e,t=[""],n,i,s=()=>e[0]){const o=n||e;typeof i>"u"&&(i=Zr("_fallback",e));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:o,_fallback:i,_getTarget:s,override:a=>hs([a,...e],t,o,i)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete e[0][l],!0},get(a,l){return Gr(a,l,()=>Sh(l,t,e,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(a,l){return oo(a).includes(l)},ownKeys(a){return oo(a)},set(a,l,c){const h=a._storage||(a._storage=s());return a[l]=h[l]=c,delete a._keys,!0}})}function Ae(e,t,n,i){const s={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:qr(e,i),setContext:o=>Ae(e,o,n,i),override:o=>Ae(e.override(o),t,n,i)};return new Proxy(s,{deleteProperty(o,r){return delete o[r],delete e[r],!0},get(o,r,a){return Gr(o,r,()=>xh(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(e,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,r)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(o,r){return Reflect.has(e,r)},ownKeys(){return Reflect.ownKeys(e)},set(o,r,a){return e[r]=a,delete o[r],!0}})}function qr(e,t={scriptable:!0,indexable:!0}){const{_scriptable:n=t.scriptable,_indexable:i=t.indexable,_allKeys:s=t.allKeys}=e;return{allKeys:s,scriptable:n,indexable:i,isScriptable:Zt(n)?n:()=>n,isIndexable:Zt(i)?i:()=>i}}const bh=(e,t)=>e?e+os(t):t,us=(e,t)=>B(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function Gr(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];const i=n();return e[t]=i,i}function xh(e,t,n){const{_proxy:i,_context:s,_subProxy:o,_descriptors:r}=e;let a=i[t];return Zt(a)&&r.isScriptable(t)&&(a=yh(t,a,e,n)),Z(a)&&a.length&&(a=vh(t,a,e,r.isIndexable)),us(t,a)&&(a=Ae(a,s,o&&o[t],r)),a}function yh(e,t,n,i){const{_proxy:s,_context:o,_subProxy:r,_stack:a}=n;if(a.has(e))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+e);a.add(e);let l=t(o,r||i);return a.delete(e),us(e,l)&&(l=ds(s._scopes,s,e,l)),l}function vh(e,t,n,i){const{_proxy:s,_context:o,_subProxy:r,_descriptors:a}=n;if(typeof o.index<"u"&&i(e))return t[o.index%t.length];if(B(t[0])){const l=t,c=s._scopes.filter(h=>h!==l);t=[];for(const h of l){const d=ds(c,s,e,h);t.push(Ae(d,o,r&&r[e],a))}}return t}function Kr(e,t,n){return Zt(e)?e(t,n):e}const _h=(e,t)=>e===!0?t:typeof e=="string"?qn(t,e):void 0;function wh(e,t,n,i,s){for(const o of t){const r=_h(n,o);if(r){e.add(r);const a=Kr(r._fallback,n,s);if(typeof a<"u"&&a!==n&&a!==i)return a}else if(r===!1&&typeof i<"u"&&n!==i)return null}return!1}function ds(e,t,n,i){const s=t._rootScopes,o=Kr(t._fallback,n,i),r=[...e,...s],a=new Set;a.add(i);let l=so(a,r,n,o||n,i);return l===null||typeof o<"u"&&o!==n&&(l=so(a,r,o,l,i),l===null)?!1:hs(Array.from(a),[""],s,o,()=>Eh(t,n,i))}function so(e,t,n,i,s){for(;n;)n=wh(e,t,n,i,s);return n}function Eh(e,t,n){const i=e._getTarget();t in i||(i[t]={});const s=i[t];return Z(s)&&B(n)?n:s||{}}function Sh(e,t,n,i){let s;for(const o of t)if(s=Zr(bh(o,e),n),typeof s<"u")return us(e,s)?ds(n,i,e,s):s}function Zr(e,t){for(const n of t){if(!n)continue;const i=n[e];if(typeof i<"u")return i}}function oo(e){let t=e._keys;return t||(t=e._keys=kh(e._scopes)),t}function kh(e){const t=new Set;for(const n of e)for(const i of Object.keys(n).filter(s=>!s.startsWith("_")))t.add(i);return Array.from(t)}const Th=Number.EPSILON||1e-14,Ie=(e,t)=>t<e.length&&!e[t].skip&&e[t],Qr=e=>e==="x"?"y":"x";function Mh(e,t,n,i){const s=e.skip?t:e,o=t,r=n.skip?t:n,a=Li(o,s),l=Li(r,o);let c=a/(a+l),h=l/(a+l);c=isNaN(c)?0:c,h=isNaN(h)?0:h;const d=i*c,g=i*h;return{previous:{x:o.x-d*(r.x-s.x),y:o.y-d*(r.y-s.y)},next:{x:o.x+g*(r.x-s.x),y:o.y+g*(r.y-s.y)}}}function Oh(e,t,n){const i=e.length;let s,o,r,a,l,c=Ie(e,0);for(let h=0;h<i-1;++h)if(l=c,c=Ie(e,h+1),!(!l||!c)){if(pe(t[h],0,Th)){n[h]=n[h+1]=0;continue}s=n[h]/t[h],o=n[h+1]/t[h],a=Math.pow(s,2)+Math.pow(o,2),!(a<=9)&&(r=3/Math.sqrt(a),n[h]=s*r*t[h],n[h+1]=o*r*t[h])}}function Ch(e,t,n="x"){const i=Qr(n),s=e.length;let o,r,a,l=Ie(e,0);for(let c=0;c<s;++c){if(r=a,a=l,l=Ie(e,c+1),!a)continue;const h=a[n],d=a[i];r&&(o=(h-r[n])/3,a[\`cp1\${n}\`]=h-o,a[\`cp1\${i}\`]=d-o*t[c]),l&&(o=(l[n]-h)/3,a[\`cp2\${n}\`]=h+o,a[\`cp2\${i}\`]=d+o*t[c])}}function Ph(e,t="x"){const n=Qr(t),i=e.length,s=Array(i).fill(0),o=Array(i);let r,a,l,c=Ie(e,0);for(r=0;r<i;++r)if(a=l,l=c,c=Ie(e,r+1),!!l){if(c){const h=c[t]-l[t];s[r]=h!==0?(c[n]-l[n])/h:0}o[r]=a?c?Qt(s[r-1])!==Qt(s[r])?0:(s[r-1]+s[r])/2:s[r-1]:s[r]}Oh(e,s,o),Ch(e,o,t)}function Dn(e,t,n){return Math.max(Math.min(e,n),t)}function Dh(e,t){let n,i,s,o,r,a=De(e[0],t);for(n=0,i=e.length;n<i;++n)r=o,o=a,a=n<i-1&&De(e[n+1],t),o&&(s=e[n],r&&(s.cp1x=Dn(s.cp1x,t.left,t.right),s.cp1y=Dn(s.cp1y,t.top,t.bottom)),a&&(s.cp2x=Dn(s.cp2x,t.left,t.right),s.cp2y=Dn(s.cp2y,t.top,t.bottom)))}function Ah(e,t,n,i,s){let o,r,a,l;if(t.spanGaps&&(e=e.filter(c=>!c.skip)),t.cubicInterpolationMode==="monotone")Ph(e,s);else{let c=i?e[e.length-1]:e[0];for(o=0,r=e.length;o<r;++o)a=e[o],l=Mh(c,a,e[Math.min(o+1,r-(i?0:1))%r],t.tension),a.cp1x=l.previous.x,a.cp1y=l.previous.y,a.cp2x=l.next.x,a.cp2y=l.next.y,c=a}t.capBezierPoints&&Dh(e,n)}function fs(){return typeof window<"u"&&typeof document<"u"}function gs(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function Qn(e,t,n){let i;return typeof e=="string"?(i=parseInt(e,10),e.indexOf("%")!==-1&&(i=i/100*t.parentNode[n])):i=e,i}const ni=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function Ih(e,t){return ni(e).getPropertyValue(t)}const Nh=["top","right","bottom","left"];function me(e,t,n){const i={};n=n?"-"+n:"";for(let s=0;s<4;s++){const o=Nh[s];i[o]=parseFloat(e[t+"-"+o+n])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}const Lh=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Rh(e,t){const n=e.touches,i=n&&n.length?n[0]:e,{offsetX:s,offsetY:o}=i;let r=!1,a,l;if(Lh(s,o,e.target))a=s,l=o;else{const c=t.getBoundingClientRect();a=i.clientX-c.left,l=i.clientY-c.top,r=!0}return{x:a,y:l,box:r}}function Ct(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:i}=t,s=ni(n),o=s.boxSizing==="border-box",r=me(s,"padding"),a=me(s,"border","width"),{x:l,y:c,box:h}=Rh(e,n),d=r.left+(h&&a.left),g=r.top+(h&&a.top);let{width:p,height:y}=t;return o&&(p-=r.width+a.width,y-=r.height+a.height),{x:Math.round((l-d)/p*n.width/i),y:Math.round((c-g)/y*n.height/i)}}function zh(e,t,n){let i,s;if(t===void 0||n===void 0){const o=e&&gs(e);if(!o)t=e.clientWidth,n=e.clientHeight;else{const r=o.getBoundingClientRect(),a=ni(o),l=me(a,"border","width"),c=me(a,"padding");t=r.width-c.width-l.width,n=r.height-c.height-l.height,i=Qn(a.maxWidth,o,"clientWidth"),s=Qn(a.maxHeight,o,"clientHeight")}}return{width:t,height:n,maxWidth:i||Kn,maxHeight:s||Kn}}const An=e=>Math.round(e*10)/10;function Fh(e,t,n,i){const s=ni(e),o=me(s,"margin"),r=Qn(s.maxWidth,e,"clientWidth")||Kn,a=Qn(s.maxHeight,e,"clientHeight")||Kn,l=zh(e,t,n);let{width:c,height:h}=l;if(s.boxSizing==="content-box"){const g=me(s,"border","width"),p=me(s,"padding");c-=p.width+g.width,h-=p.height+g.height}return c=Math.max(0,c-o.width),h=Math.max(0,i?c/i:h-o.height),c=An(Math.min(c,r,l.maxWidth)),h=An(Math.min(h,a,l.maxHeight)),c&&!h&&(h=An(c/2)),(t!==void 0||n!==void 0)&&i&&l.height&&h>l.height&&(h=l.height,c=An(Math.floor(h*i))),{width:c,height:h}}function ro(e,t,n){const i=t||1,s=Math.floor(e.height*i),o=Math.floor(e.width*i);e.height=Math.floor(e.height),e.width=Math.floor(e.width);const r=e.canvas;return r.style&&(n||!r.style.height&&!r.style.width)&&(r.style.height=\`\${e.height}px\`,r.style.width=\`\${e.width}px\`),e.currentDevicePixelRatio!==i||r.height!==s||r.width!==o?(e.currentDevicePixelRatio=i,r.height=s,r.width=o,e.ctx.setTransform(i,0,0,i,0,0),!0):!1}const Hh=function(){let e=!1;try{const t={get passive(){return e=!0,!1}};fs()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e}();function ao(e,t){const n=Ih(e,t),i=n&&n.match(/^(\\d+)(\\.\\d+)?px$/);return i?+i[1]:void 0}function he(e,t,n,i){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function Bh(e,t,n,i){return{x:e.x+n*(t.x-e.x),y:i==="middle"?n<.5?e.y:t.y:i==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function Wh(e,t,n,i){const s={x:e.cp2x,y:e.cp2y},o={x:t.cp1x,y:t.cp1y},r=he(e,s,n),a=he(s,o,n),l=he(o,t,n),c=he(r,a,n),h=he(a,l,n);return he(c,h,n)}const Vh=function(e,t){return{x(n){return e+e+t-n},setWidth(n){t=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,i){return n-i},leftForLtr(n,i){return n-i}}},jh=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Oe(e,t,n){return e?Vh(t,n):jh()}function Jr(e,t){let n,i;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,i=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=i)}function ta(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function ea(e){return e==="angle"?{between:Hr,compare:Bc,normalize:Ut}:{between:Ze,compare:(t,n)=>t-n,normalize:t=>t}}function lo({start:e,end:t,count:n,loop:i,style:s}){return{start:e%n,end:t%n,loop:i&&(t-e+1)%n===0,style:s}}function Uh(e,t,n){const{property:i,start:s,end:o}=n,{between:r,normalize:a}=ea(i),l=t.length;let{start:c,end:h,loop:d}=e,g,p;if(d){for(c+=l,h+=l,g=0,p=l;g<p&&r(a(t[c%l][i]),s,o);++g)c--,h--;c%=l,h%=l}return h<c&&(h+=l),{start:c,end:h,loop:d,style:e.style}}function Yh(e,t,n){if(!n)return[e];const{property:i,start:s,end:o}=n,r=t.length,{compare:a,between:l,normalize:c}=ea(i),{start:h,end:d,loop:g,style:p}=Uh(e,t,n),y=[];let x=!1,v=null,w,S,O;const C=()=>l(s,O,w)&&a(s,O)!==0,k=()=>a(o,w)===0||l(o,O,w),D=()=>x||C(),P=()=>!x||k();for(let M=h,A=h;M<=d;++M)S=t[M%r],!S.skip&&(w=c(S[i]),w!==O&&(x=l(w,s,o),v===null&&D()&&(v=a(w,s)===0?M:A),v!==null&&P()&&(y.push(lo({start:v,end:M,loop:g,count:r,style:p})),v=null),A=M,O=w));return v!==null&&y.push(lo({start:v,end:d,loop:g,count:r,style:p})),y}function $h(e,t){const n=[],i=e.segments;for(let s=0;s<i.length;s++){const o=Yh(i[s],e.points,t);o.length&&n.push(...o)}return n}function Xh(e,t,n,i){let s=0,o=t-1;if(n&&!i)for(;s<t&&!e[s].skip;)s++;for(;s<t&&e[s].skip;)s++;for(s%=t,n&&(o+=s);o>s&&e[o%t].skip;)o--;return o%=t,{start:s,end:o}}function qh(e,t,n,i){const s=e.length,o=[];let r=t,a=e[t],l;for(l=t+1;l<=n;++l){const c=e[l%s];c.skip||c.stop?a.skip||(i=!1,o.push({start:t%s,end:(l-1)%s,loop:i}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%s,end:r%s,loop:i}),o}function Gh(e,t){const n=e.points,i=e.options.spanGaps,s=n.length;if(!s)return[];const o=!!e._loop,{start:r,end:a}=Xh(n,s,o,i);if(i===!0)return co(e,[{start:r,end:a,loop:o}],n,t);const l=a<r?a+s:a,c=!!e._fullLoop&&r===0&&a===s-1;return co(e,qh(n,r,l,c),n,t)}function co(e,t,n,i){return!i||!i.setContext||!n?t:Kh(e,t,n,i)}function Kh(e,t,n,i){const s=e._chart.getContext(),o=ho(e.options),{_datasetIndex:r,options:{spanGaps:a}}=e,l=n.length,c=[];let h=o,d=t[0].start,g=d;function p(y,x,v,w){const S=a?-1:1;if(y!==x){for(y+=l;n[y%l].skip;)y-=S;for(;n[x%l].skip;)x+=S;y%l!==x%l&&(c.push({start:y%l,end:x%l,loop:v,style:w}),h=w,d=x%l)}}for(const y of t){d=a?d:y.start;let x=n[d%l],v;for(g=d+1;g<=y.end;g++){const w=n[g%l];v=ho(i.setContext(ve(s,{type:"segment",p0:x,p1:w,p0DataIndex:(g-1)%l,p1DataIndex:g%l,datasetIndex:r}))),Zh(v,h)&&p(d,g-1,y.loop,h),x=w,h=v}d<g-1&&p(d,g-1,y.loop,h)}return c}function ho(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function Zh(e,t){if(!t)return!1;const n=[],i=function(s,o){return as(o)?(n.includes(o)||n.push(o),n.indexOf(o)):o};return JSON.stringify(e,i)!==JSON.stringify(t,i)}function In(e,t,n){return e.options.clip?e[n]:t[n]}function Qh(e,t){const{xScale:n,yScale:i}=e;return n&&i?{left:In(n,t,"left"),right:In(n,t,"right"),top:In(i,t,"top"),bottom:In(i,t,"bottom")}:t}function Jh(e,t){const n=t._clip;if(n.disabled)return!1;const i=Qh(t,e.chartArea);return{left:n.left===!1?0:i.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:i.right+(n.right===!0?0:n.right),top:n.top===!1?0:i.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:i.bottom+(n.bottom===!0?0:n.bottom)}}/*!
1706
+ * Chart.js v4.5.0
1707
+ * https://www.chartjs.org
1708
+ * (c) 2025 Chart.js Contributors
1709
+ * Released under the MIT License
1710
+ */class tu{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,i,s){const o=n.listeners[s],r=n.duration;o.forEach(a=>a({chart:t,initial:n.initial,numSteps:r,currentStep:Math.min(i-n.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=Wr.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const o=i.items;let r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(s.draw(),this._notify(s,i,t,"progress")),o.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),n+=o.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let i=n.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,i)),i}listen(t,n,i){this._getAnims(t).listeners[n].push(i)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){const n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((i,s)=>Math.max(i,s._duration),0),this._refresh())}running(t){if(!this._running)return!1;const n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){const n=this._charts.get(t);if(!n||!n.items.length)return;const i=n.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var zt=new tu;const uo="transparent",eu={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const i=to(e||uo),s=i.valid&&to(t||uo);return s&&s.valid?s.mix(i,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class nu{constructor(t,n,i,s){const o=n[i];s=Pn([t.to,s,o,t.from]);const r=Pn([t.from,o,s]);this._active=!0,this._fn=t.fn||eu[t.type||typeof r],this._easing=en[t.easing]||en.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=i,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,n,i){if(this._active){this._notify(!1);const s=this._target[this._prop],o=i-this._start,r=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=Pn([t.to,n,s,t.from]),this._from=Pn([t.from,s,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,i=this._duration,s=this._prop,o=this._from,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||n<i),!this._active){this._target[s]=a,this._notify(!0);return}if(n<0){this._target[s]=o;return}l=n/i%2,l=r&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[s]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,i)=>{t.push({res:n,rej:i})})}_notify(t){const n=t?"res":"rej",i=this._promises||[];for(let s=0;s<i.length;s++)i[s][n]()}}class na{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!B(t))return;const n=Object.keys(Y.animation),i=this._properties;Object.getOwnPropertyNames(t).forEach(s=>{const o=t[s];if(!B(o))return;const r={};for(const a of n)r[a]=o[a];(Z(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!i.has(a))&&i.set(a,r)})})}_animateOptions(t,n){const i=n.options,s=su(t,i);if(!s)return[];const o=this._createAnimations(s,i);return i.$shared&&iu(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,n){const i=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(n),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){s.push(...this._animateOptions(t,n));continue}const h=n[c];let d=o[c];const g=i.get(c);if(d)if(g&&d.active()){d.update(g,h,a);continue}else d.cancel();if(!g||!g.duration){t[c]=h;continue}o[c]=d=new nu(g,t,c,h),s.push(d)}return s}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const i=this._createAnimations(t,n);if(i.length)return zt.add(this._chart,i),!0}}function iu(e,t){const n=[],i=Object.keys(t);for(let s=0;s<i.length;s++){const o=e[i[s]];o&&o.active()&&n.push(o.wait())}return Promise.all(n)}function su(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 fo(e,t){const n=e&&e.options||{},i=n.reverse,s=n.min===void 0?t:0,o=n.max===void 0?t:0;return{start:i?o:s,end:i?s:o}}function ou(e,t,n){if(n===!1)return!1;const i=fo(e,n),s=fo(t,n);return{top:s.end,right:i.end,bottom:s.start,left:i.start}}function ru(e){let t,n,i,s;return B(e)?(t=e.top,n=e.right,i=e.bottom,s=e.left):t=n=i=s=e,{top:t,right:n,bottom:i,left:s,disabled:e===!1}}function ia(e,t){const n=[],i=e._getSortedDatasetMetas(t);let s,o;for(s=0,o=i.length;s<o;++s)n.push(i[s].index);return n}function go(e,t,n,i={}){const s=e.keys,o=i.mode==="single";let r,a,l,c;if(t===null)return;let h=!1;for(r=0,a=s.length;r<a;++r){if(l=+s[r],l===n){if(h=!0,i.all)continue;break}c=e.values[l],xt(c)&&(o||t===0||Qt(t)===Qt(c))&&(t+=c)}return!h&&!i.all?0:t}function au(e,t){const{iScale:n,vScale:i}=t,s=n.axis==="x"?"x":"y",o=i.axis==="x"?"x":"y",r=Object.keys(e),a=new Array(r.length);let l,c,h;for(l=0,c=r.length;l<c;++l)h=r[l],a[l]={[s]:h,[o]:e[h]};return a}function yi(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function lu(e,t,n){return\`\${e.id}.\${t.id}.\${n.stack||n.type}\`}function cu(e){const{min:t,max:n,minDefined:i,maxDefined:s}=e.getUserBounds();return{min:i?t:Number.NEGATIVE_INFINITY,max:s?n:Number.POSITIVE_INFINITY}}function hu(e,t,n){const i=e[t]||(e[t]={});return i[n]||(i[n]={})}function po(e,t,n,i){for(const s of t.getMatchingVisibleMetas(i).reverse()){const o=e[s.index];if(n&&o>0||!n&&o<0)return s.index}return null}function mo(e,t){const{chart:n,_cachedMeta:i}=e,s=n._stacks||(n._stacks={}),{iScale:o,vScale:r,index:a}=i,l=o.axis,c=r.axis,h=lu(o,r,i),d=t.length;let g;for(let p=0;p<d;++p){const y=t[p],{[l]:x,[c]:v}=y,w=y._stacks||(y._stacks={});g=w[c]=hu(s,h,x),g[a]=v,g._top=po(g,r,!0,i.type),g._bottom=po(g,r,!1,i.type);const S=g._visualValues||(g._visualValues={});S[a]=v}}function vi(e,t){const n=e.scales;return Object.keys(n).filter(i=>n[i].axis===t).shift()}function uu(e,t){return ve(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function du(e,t,n){return ve(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function Ue(e,t){const n=e.controller.index,i=e.vScale&&e.vScale.axis;if(i){t=t||e._parsed;for(const s of t){const o=s._stacks;if(!o||o[i]===void 0||o[i][n]===void 0)return;delete o[i][n],o[i]._visualValues!==void 0&&o[i]._visualValues[n]!==void 0&&delete o[i]._visualValues[n]}}}const _i=e=>e==="reset"||e==="none",bo=(e,t)=>t?e:Object.assign({},e),fu=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:ia(n,!0),values:null};class sa{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,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(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=yi(t.vScale,t),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(t){this.index!==t&&Ue(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,i=this.getDataset(),s=(d,g,p,y)=>d==="x"?g:d==="r"?y:p,o=n.xAxisID=L(i.xAxisID,vi(t,"x")),r=n.yAxisID=L(i.yAxisID,vi(t,"y")),a=n.rAxisID=L(i.rAxisID,vi(t,"r")),l=n.indexAxis,c=n.iAxisID=s(l,o,r,a),h=n.vAxisID=s(l,r,o,a);n.xScale=this.getScaleForId(o),n.yScale=this.getScaleForId(r),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(c),n.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&Zs(this._data,this),t._stacked&&Ue(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),i=this._data;if(B(n)){const s=this._cachedMeta;this._data=au(n,s)}else if(i!==n){if(i){Zs(i,this);const s=this._cachedMeta;Ue(s),s._parsed=[]}n&&Object.isExtensible(n)&&Uc(n,this),this._syncList=[],this._data=n}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const n=this._cachedMeta,i=this.getDataset();let s=!1;this._dataCheck();const o=n._stacked;n._stacked=yi(n.vScale,n),n.stack!==i.stack&&(s=!0,Ue(n),n.stack=i.stack),this._resyncElements(t),(s||o!==n._stacked)&&(mo(this,n._parsed),n._stacked=yi(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:i,_data:s}=this,{iScale:o,_stacked:r}=i,a=o.axis;let l=t===0&&n===s.length?!0:i._sorted,c=t>0&&i._parsed[t-1],h,d,g;if(this._parsing===!1)i._parsed=s,i._sorted=!0,g=s;else{Z(s[t])?g=this.parseArrayData(i,s,t,n):B(s[t])?g=this.parseObjectData(i,s,t,n):g=this.parsePrimitiveData(i,s,t,n);const p=()=>d[a]===null||c&&d[a]<c[a];for(h=0;h<n;++h)i._parsed[h+t]=d=g[h],l&&(p()&&(l=!1),c=d);i._sorted=l}r&&mo(this,g)}parsePrimitiveData(t,n,i,s){const{iScale:o,vScale:r}=t,a=o.axis,l=r.axis,c=o.getLabels(),h=o===r,d=new Array(s);let g,p,y;for(g=0,p=s;g<p;++g)y=g+i,d[g]={[a]:h||o.parse(c[y],y),[l]:r.parse(n[y],y)};return d}parseArrayData(t,n,i,s){const{xScale:o,yScale:r}=t,a=new Array(s);let l,c,h,d;for(l=0,c=s;l<c;++l)h=l+i,d=n[h],a[l]={x:o.parse(d[0],h),y:r.parse(d[1],h)};return a}parseObjectData(t,n,i,s){const{xScale:o,yScale:r}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=new Array(s);let h,d,g,p;for(h=0,d=s;h<d;++h)g=h+i,p=n[g],c[h]={x:o.parse(qn(p,a),g),y:r.parse(qn(p,l),g)};return c}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,i){const s=this.chart,o=this._cachedMeta,r=n[t.axis],a={keys:ia(s,!0),values:n._stacks[t.axis]._visualValues};return go(a,r,o.index,{mode:i})}updateRangeFromParsed(t,n,i,s){const o=i[n.axis];let r=o===null?NaN:o;const a=s&&i._stacks[n.axis];s&&a&&(s.values=a,r=go(s,o,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,n){const i=this._cachedMeta,s=i._parsed,o=i._sorted&&t===i.iScale,r=s.length,a=this._getOtherScale(t),l=fu(n,i,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:h,max:d}=cu(a);let g,p;function y(){p=s[g];const x=p[a.axis];return!xt(p[t.axis])||h>x||d<x}for(g=0;g<r&&!(!y()&&(this.updateRangeFromParsed(c,t,p,l),o));++g);if(o){for(g=r-1;g>=0;--g)if(!y()){this.updateRangeFromParsed(c,t,p,l);break}}return c}getAllParsedValues(t){const n=this._cachedMeta._parsed,i=[];let s,o,r;for(s=0,o=n.length;s<o;++s)r=n[s][t.axis],xt(r)&&i.push(r);return i}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,i=n.iScale,s=n.vScale,o=this.getParsed(t);return{label:i?""+i.getLabelForValue(o[i.axis]):"",value:s?""+s.getLabelForValue(o[s.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=ru(L(this.options.clip,ou(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,i=this._cachedMeta,s=i.data||[],o=n.chartArea,r=[],a=this._drawStart||0,l=this._drawCount||s.length-a,c=this.options.drawActiveElementsOnTop;let h;for(i.dataset&&i.dataset.draw(t,o,a,l),h=a;h<a+l;++h){const d=s[h];d.hidden||(d.active&&c?r.push(d):d.draw(t,o))}for(h=0;h<r.length;++h)r[h].draw(t,o)}getStyle(t,n){const i=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(i):this.resolveDataElementOptions(t||0,i)}getContext(t,n,i){const s=this.getDataset();let o;if(t>=0&&t<this._cachedMeta.data.length){const r=this._cachedMeta.data[t];o=r.$context||(r.$context=du(this.getContext(),t,r)),o.parsed=this.getParsed(t),o.raw=s.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=uu(this.chart.getContext(),this.index)),o.dataset=s,o.index=o.datasetIndex=this.index;return o.active=!!n,o.mode=i,o}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",i){const s=n==="active",o=this._cachedDataOpts,r=t+"-"+n,a=o[r],l=this.enableOptionSharing&&Gn(i);if(a)return bo(a,l);const c=this.chart.config,h=c.datasetElementScopeKeys(this._type,t),d=s?[\`\${t}Hover\`,"hover",t,""]:[t,""],g=c.getOptionScopes(this.getDataset(),h),p=Object.keys(Y.elements[t]),y=()=>this.getContext(i,s,n),x=c.resolveNamedOptions(g,p,y,d);return x.$shared&&(x.$shared=l,o[r]=Object.freeze(bo(x,l))),x}_resolveAnimations(t,n,i){const s=this.chart,o=this._cachedDataOpts,r=\`animation-\${n}\`,a=o[r];if(a)return a;let l;if(s.options.animation!==!1){const h=this.chart.config,d=h.datasetAnimationScopeKeys(this._type,n),g=h.getOptionScopes(this.getDataset(),d);l=h.createResolver(g,this.getContext(t,i,n))}const c=new na(s,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||_i(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const i=this.resolveDataElementOptions(t,n),s=this._sharedOptions,o=this.getSharedOptions(i),r=this.includeOptions(n,o)||o!==s;return this.updateSharedOptions(o,n,i),{sharedOptions:o,includeOptions:r}}updateElement(t,n,i,s){_i(s)?Object.assign(t,i):this._resolveAnimations(n,s).update(t,i)}updateSharedOptions(t,n,i){t&&!_i(n)&&this._resolveAnimations(void 0,n).update(t,i)}_setStyle(t,n,i,s){t.active=s;const o=this.getStyle(n,s);this._resolveAnimations(n,i,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,n,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,n,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const n=this._data,i=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const s=i.length,o=n.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o<s&&this._removeElements(o,s-o)}_insertElements(t,n,i=!0){const s=this._cachedMeta,o=s.data,r=t+n;let a;const l=c=>{for(c.length+=n,a=c.length-1;a>=r;a--)c[a]=c[a-n]};for(l(o),a=t;a<r;++a)o[a]=new this.dataElementType;this._parsing&&l(s._parsed),this.parse(t,n),i&&this.updateElements(o,t,n,"reset")}updateElements(t,n,i,s){}_removeElements(t,n){const i=this._cachedMeta;if(this._parsing){const s=i._parsed.splice(t,n);i._stacked&&Ue(i,s)}i.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,i,s]=t;this[n](i,s)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);const i=arguments.length-2;i&&this._sync(["_insertElements",t,i])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}class gu extends sa{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(t){const n=this._cachedMeta,{dataset:i,data:s=[],_dataset:o}=n,r=this.chart._animationsDisabled;let{start:a,count:l}=qc(n,s,r);this._drawStart=a,this._drawCount=l,Gc(n)&&(a=0,l=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!o._decimated,i.points=s;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:c},t),this.updateElements(s,a,l,t)}updateElements(t,n,i,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:h,includeOptions:d}=this._getSharedOptions(n,s),g=r.axis,p=a.axis,{spanGaps:y,segment:x}=this.options,v=hn(y)?y:Number.POSITIVE_INFINITY,w=this.chart._animationsDisabled||o||s==="none",S=n+i,O=t.length;let C=n>0&&this.getParsed(n-1);for(let k=0;k<O;++k){const D=t[k],P=w?D:{};if(k<n||k>=S){P.skip=!0;continue}const M=this.getParsed(k),A=W(M[p]),F=P[g]=r.getPixelForValue(M[g],k),N=P[p]=o||A?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,M,l):M[p],k);P.skip=isNaN(F)||isNaN(N)||A,P.stop=k>0&&Math.abs(M[g]-C[g])>v,x&&(P.parsed=M,P.raw=c.data[k]),d&&(P.options=h||this.resolveDataElementOptions(k,D.active?"active":s)),w||this.updateElement(D,k,P,s),C=M}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,i=n.options&&n.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const o=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}function ce(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class ps{static override(t){Object.assign(ps.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return ce()}parse(){return ce()}format(){return ce()}add(){return ce()}diff(){return ce()}startOf(){return ce()}endOf(){return ce()}}var pu={_date:ps};function mu(e,t,n,i){const{controller:s,data:o,_sorted:r}=e,a=s._cachedMeta.iScale,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const c=a._reversePixels?Vc:fe;if(i){if(s._sharedOptions){const h=o[0],d=typeof h.getRange=="function"&&h.getRange(t);if(d){const g=c(o,t,n-d),p=c(o,t,n+d);return{lo:g.lo,hi:p.hi}}}}else{const h=c(o,t,n);if(l){const{vScale:d}=s._cachedMeta,{_parsed:g}=e,p=g.slice(0,h.lo+1).reverse().findIndex(x=>!W(x[d.axis]));h.lo-=Math.max(0,p);const y=g.slice(h.hi).findIndex(x=>!W(x[d.axis]));h.hi+=Math.max(0,y)}return h}}return{lo:0,hi:o.length-1}}function ii(e,t,n,i,s){const o=e.getSortedVisibleDatasetMetas(),r=n[t];for(let a=0,l=o.length;a<l;++a){const{index:c,data:h}=o[a],{lo:d,hi:g}=mu(o[a],t,r,s);for(let p=d;p<=g;++p){const y=h[p];y.skip||i(y,c,p)}}}function bu(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(i,s){const o=t?Math.abs(i.x-s.x):0,r=n?Math.abs(i.y-s.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(r,2))}}function wi(e,t,n,i,s){const o=[];return!s&&!e.isPointInArea(t)||ii(e,n,t,function(a,l,c){!s&&!De(a,e.chartArea,0)||a.inRange(t.x,t.y,i)&&o.push({element:a,datasetIndex:l,index:c})},!0),o}function xu(e,t,n,i){let s=[];function o(r,a,l){const{startAngle:c,endAngle:h}=r.getProps(["startAngle","endAngle"],i),{angle:d}=Hc(r,{x:t.x,y:t.y});Hr(d,c,h)&&s.push({element:r,datasetIndex:a,index:l})}return ii(e,n,t,o),s}function yu(e,t,n,i,s,o){let r=[];const a=bu(n);let l=Number.POSITIVE_INFINITY;function c(h,d,g){const p=h.inRange(t.x,t.y,s);if(i&&!p)return;const y=h.getCenterPoint(s);if(!(!!o||e.isPointInArea(y))&&!p)return;const v=a(t,y);v<l?(r=[{element:h,datasetIndex:d,index:g}],l=v):v===l&&r.push({element:h,datasetIndex:d,index:g})}return ii(e,n,t,c),r}function Ei(e,t,n,i,s,o){return!o&&!e.isPointInArea(t)?[]:n==="r"&&!i?xu(e,t,n,s):yu(e,t,n,i,s,o)}function xo(e,t,n,i,s){const o=[],r=n==="x"?"inXRange":"inYRange";let a=!1;return ii(e,n,t,(l,c,h)=>{l[r]&&l[r](t[n],s)&&(o.push({element:l,datasetIndex:c,index:h}),a=a||l.inRange(t.x,t.y,s))}),i&&!a?[]:o}var vu={modes:{index(e,t,n,i){const s=Ct(t,e),o=n.axis||"x",r=n.includeInvisible||!1,a=n.intersect?wi(e,s,o,i,r):Ei(e,s,o,!1,i,r),l=[];return a.length?(e.getSortedVisibleDatasetMetas().forEach(c=>{const h=a[0].index,d=c.data[h];d&&!d.skip&&l.push({element:d,datasetIndex:c.index,index:h})}),l):[]},dataset(e,t,n,i){const s=Ct(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;let a=n.intersect?wi(e,s,o,i,r):Ei(e,s,o,!1,i,r);if(a.length>0){const l=a[0].datasetIndex,c=e.getDatasetMeta(l).data;a=[];for(let h=0;h<c.length;++h)a.push({element:c[h],datasetIndex:l,index:h})}return a},point(e,t,n,i){const s=Ct(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return wi(e,s,o,i,r)},nearest(e,t,n,i){const s=Ct(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return Ei(e,s,o,n.intersect,i,r)},x(e,t,n,i){const s=Ct(t,e);return xo(e,s,"x",n.intersect,i)},y(e,t,n,i){const s=Ct(t,e);return xo(e,s,"y",n.intersect,i)}}};const oa=["left","top","right","bottom"];function Ye(e,t){return e.filter(n=>n.pos===t)}function yo(e,t){return e.filter(n=>oa.indexOf(n.pos)===-1&&n.box.axis===t)}function $e(e,t){return e.sort((n,i)=>{const s=t?i:n,o=t?n:i;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function _u(e){const t=[];let n,i,s,o,r,a;for(n=0,i=(e||[]).length;n<i;++n)s=e[n],{position:o,options:{stack:r,stackWeight:a=1}}=s,t.push({index:n,box:s,pos:o,horizontal:s.isHorizontal(),weight:s.weight,stack:r&&o+r,stackWeight:a});return t}function wu(e){const t={};for(const n of e){const{stack:i,pos:s,stackWeight:o}=n;if(!i||!oa.includes(s))continue;const r=t[i]||(t[i]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=o}return t}function Eu(e,t){const n=wu(e),{vBoxMaxWidth:i,hBoxMaxHeight:s}=t;let o,r,a;for(o=0,r=e.length;o<r;++o){a=e[o];const{fullSize:l}=a.box,c=n[a.stack],h=c&&a.stackWeight/c.weight;a.horizontal?(a.width=h?h*i:l&&t.availableWidth,a.height=s):(a.width=i,a.height=h?h*s:l&&t.availableHeight)}return n}function Su(e){const t=_u(e),n=$e(t.filter(c=>c.box.fullSize),!0),i=$e(Ye(t,"left"),!0),s=$e(Ye(t,"right")),o=$e(Ye(t,"top"),!0),r=$e(Ye(t,"bottom")),a=yo(t,"x"),l=yo(t,"y");return{fullSize:n,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(r).concat(a),chartArea:Ye(t,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(r).concat(a)}}function vo(e,t,n,i){return Math.max(e[n],t[n])+Math.max(e[i],t[i])}function ra(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 ku(e,t,n,i){const{pos:s,box:o}=n,r=e.maxPadding;if(!B(s)){n.size&&(e[s]-=n.size);const d=i[n.stack]||{size:0,count:1};d.size=Math.max(d.size,n.horizontal?o.height:o.width),n.size=d.size/d.count,e[s]+=n.size}o.getPadding&&ra(r,o.getPadding());const a=Math.max(0,t.outerWidth-vo(r,e,"left","right")),l=Math.max(0,t.outerHeight-vo(r,e,"top","bottom")),c=a!==e.w,h=l!==e.h;return e.w=a,e.h=l,n.horizontal?{same:c,other:h}:{same:h,other:c}}function Tu(e){const t=e.maxPadding;function n(i){const s=Math.max(t[i]-e[i],0);return e[i]+=s,s}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function Mu(e,t){const n=t.maxPadding;function i(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],n[r])}),o}return i(e?["left","right"]:["top","bottom"])}function Qe(e,t,n,i){const s=[];let o,r,a,l,c,h;for(o=0,r=e.length,c=0;o<r;++o){a=e[o],l=a.box,l.update(a.width||t.w,a.height||t.h,Mu(a.horizontal,t));const{same:d,other:g}=ku(t,n,a,i);c|=d&&s.length,h=h||g,l.fullSize||s.push(a)}return c&&Qe(s,t,n,i)||h}function Nn(e,t,n,i,s){e.top=n,e.left=t,e.right=t+i,e.bottom=n+s,e.width=i,e.height=s}function _o(e,t,n,i){const s=n.padding;let{x:o,y:r}=t;for(const a of e){const l=a.box,c=i[a.stack]||{placed:0,weight:1},h=a.stackWeight/c.weight||1;if(a.horizontal){const d=t.w*h,g=c.size||l.height;Gn(c.start)&&(r=c.start),l.fullSize?Nn(l,s.left,r,n.outerWidth-s.right-s.left,g):Nn(l,t.left+c.placed,r,d,g),c.start=r,c.placed+=d,r=l.bottom}else{const d=t.h*h,g=c.size||l.width;Gn(c.start)&&(o=c.start),l.fullSize?Nn(l,o,s.top,g,n.outerHeight-s.bottom-s.top):Nn(l,o,t.top+c.placed,g,d),c.start=o,c.placed+=d,o=l.right}}t.x=o,t.y=r}var $t={addBox(e,t){e.boxes||(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(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){const 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,i){if(!e)return;const s=wt(e.options.layout.padding),o=Math.max(t-s.width,0),r=Math.max(n-s.height,0),a=Su(e.boxes),l=a.vertical,c=a.horizontal;z(e.boxes,x=>{typeof x.beforeLayout=="function"&&x.beforeLayout()});const h=l.reduce((x,v)=>v.box.options&&v.box.options.display===!1?x:x+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/h,hBoxMaxHeight:r/2}),g=Object.assign({},s);ra(g,wt(i));const p=Object.assign({maxPadding:g,w:o,h:r,x:s.left,y:s.top},s),y=Eu(l.concat(c),d);Qe(a.fullSize,p,d,y),Qe(l,p,d,y),Qe(c,p,d,y)&&Qe(l,p,d,y),Tu(p),_o(a.leftAndTop,p,d,y),p.x+=p.w,p.y+=p.h,_o(a.rightAndBottom,p,d,y),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},z(a.chartArea,x=>{const v=x.box;Object.assign(v,e.chartArea),v.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}};class aa{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,i){}removeEventListener(t,n,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,i,s){return n=Math.max(0,n||t.width),i=i||t.height,{width:n,height:Math.max(0,s?Math.floor(n/s):i)}}isAttached(t){return!0}updateConfig(t){}}class Ou extends aa{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const Wn="$chartjs",Cu={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},wo=e=>e===null||e==="";function Pu(e,t){const n=e.style,i=e.getAttribute("height"),s=e.getAttribute("width");if(e[Wn]={initial:{height:i,width:s,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",wo(s)){const o=ao(e,"width");o!==void 0&&(e.width=o)}if(wo(i))if(e.style.height==="")e.height=e.width/(t||2);else{const o=ao(e,"height");o!==void 0&&(e.height=o)}return e}const la=Hh?{passive:!0}:!1;function Du(e,t,n){e&&e.addEventListener(t,n,la)}function Au(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,la)}function Iu(e,t){const n=Cu[e.type]||e.type,{x:i,y:s}=Ct(e,t);return{type:n,chart:t,native:e,x:i!==void 0?i:null,y:s!==void 0?s:null}}function Jn(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function Nu(e,t,n){const i=e.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Jn(a.addedNodes,i),r=r&&!Jn(a.removedNodes,i);r&&n()});return s.observe(document,{childList:!0,subtree:!0}),s}function Lu(e,t,n){const i=e.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Jn(a.removedNodes,i),r=r&&!Jn(a.addedNodes,i);r&&n()});return s.observe(document,{childList:!0,subtree:!0}),s}const un=new Map;let Eo=0;function ca(){const e=window.devicePixelRatio;e!==Eo&&(Eo=e,un.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function Ru(e,t){un.size||window.addEventListener("resize",ca),un.set(e,t)}function zu(e){un.delete(e),un.size||window.removeEventListener("resize",ca)}function Fu(e,t,n){const i=e.canvas,s=i&&gs(i);if(!s)return;const o=Vr((a,l)=>{const c=s.clientWidth;n(a,l),c<s.clientWidth&&n()},window),r=new ResizeObserver(a=>{const l=a[0],c=l.contentRect.width,h=l.contentRect.height;c===0&&h===0||o(c,h)});return r.observe(s),Ru(e,o),r}function Si(e,t,n){n&&n.disconnect(),t==="resize"&&zu(e)}function Hu(e,t,n){const i=e.canvas,s=Vr(o=>{e.ctx!==null&&n(Iu(o,e))},e);return Du(i,t,s),s}class Bu extends aa{acquireContext(t,n){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(Pu(t,n),i):null}releaseContext(t){const n=t.canvas;if(!n[Wn])return!1;const i=n[Wn].initial;["height","width"].forEach(o=>{const r=i[o];W(r)?n.removeAttribute(o):n.setAttribute(o,r)});const s=i.style||{};return Object.keys(s).forEach(o=>{n.style[o]=s[o]}),n.width=n.width,delete n[Wn],!0}addEventListener(t,n,i){this.removeEventListener(t,n);const s=t.$proxies||(t.$proxies={}),r={attach:Nu,detach:Lu,resize:Fu}[n]||Hu;s[n]=r(t,n,i)}removeEventListener(t,n){const i=t.$proxies||(t.$proxies={}),s=i[n];if(!s)return;({attach:Si,detach:Si,resize:Si}[n]||Au)(t,n,s),i[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,i,s){return Fh(t,n,i,s)}isAttached(t){const n=t&&gs(t);return!!(n&&n.isConnected)}}function Wu(e){return!fs()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?Ou:Bu}class Ne{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:n,y:i}=this.getProps(["x","y"],t);return{x:n,y:i}}hasValue(){return hn(this.x)&&hn(this.y)}getProps(t,n){const i=this.$animations;if(!n||!i)return this;const s={};return t.forEach(o=>{s[o]=i[o]&&i[o].active()?i[o]._to:this[o]}),s}}function Vu(e,t){const n=e.options.ticks,i=ju(e),s=Math.min(n.maxTicksLimit||i,i),o=n.major.enabled?Yu(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>s)return $u(t,c,o,r/s),c;const h=Uu(o,t,s);if(r>0){let d,g;const p=r>1?Math.round((l-a)/(r-1)):null;for(Ln(t,c,h,W(p)?0:a-p,a),d=0,g=r-1;d<g;d++)Ln(t,c,h,o[d],o[d+1]);return Ln(t,c,h,l,W(p)?t.length:l+p),c}return Ln(t,c,h),c}function ju(e){const t=e.options.offset,n=e._tickSize(),i=e._length/n+(t?0:1),s=e._maxLength/n;return Math.floor(Math.min(i,s))}function Uu(e,t,n){const i=Xu(e),s=t.length/n;if(!i)return Math.max(s,1);const o=Nc(i);for(let r=0,a=o.length-1;r<a;r++){const l=o[r];if(l>s)return l}return Math.max(s,1)}function Yu(e){const t=[];let n,i;for(n=0,i=e.length;n<i;n++)e[n].major&&t.push(n);return t}function $u(e,t,n,i){let s=0,o=n[0],r;for(i=Math.ceil(i),r=0;r<e.length;r++)r===o&&(t.push(e[r]),s++,o=n[s*i])}function Ln(e,t,n,i,s){const o=L(i,0),r=Math.min(L(s,e.length),e.length);let a=0,l,c,h;for(n=Math.ceil(n),s&&(l=s-i,n=l/Math.floor(l/n)),h=o;h<0;)a++,h=Math.round(o+a*n);for(c=Math.max(o,0);c<r;c++)c===h&&(t.push(e[c]),a++,h=Math.round(o+a*n))}function Xu(e){const t=e.length;let n,i;if(t<2)return!1;for(i=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==i)return!1;return i}const qu=e=>e==="left"?"right":e==="right"?"left":e,So=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,ko=(e,t)=>Math.min(t||e,e);function To(e,t){const n=[],i=e.length/t,s=e.length;let o=0;for(;o<s;o+=i)n.push(e[Math.floor(o)]);return n}function Gu(e,t,n){const i=e.ticks.length,s=Math.min(t,i-1),o=e._startPixel,r=e._endPixel,a=1e-6;let l=e.getPixelForTick(s),c;if(!(n&&(i===1?c=Math.max(l-o,r-l):t===0?c=(e.getPixelForTick(1)-l)/2:c=(l-e.getPixelForTick(s-1))/2,l+=s<t?c:-c,l<o-a||l>r+a)))return l}function Ku(e,t){z(e,n=>{const i=n.gc,s=i.length/2;let o;if(s>t){for(o=0;o<s;++o)delete n.data[i[o]];i.splice(0,s)}})}function Xe(e){return e.drawTicks?e.tickLength:0}function Mo(e,t){if(!e.display)return 0;const n=lt(e.font,t),i=wt(e.padding);return(Z(e.text)?e.text.length:1)*n.lineHeight+i.height}function Zu(e,t){return ve(e,{scale:t,type:"scale"})}function Qu(e,t,n){return ve(e,{tick:n,index:t,type:"tick"})}function Ju(e,t,n){let i=jr(e);return(n&&t!=="right"||!n&&t==="right")&&(i=qu(i)),i}function td(e,t,n,i){const{top:s,left:o,bottom:r,right:a,chart:l}=e,{chartArea:c,scales:h}=l;let d=0,g,p,y;const x=r-s,v=a-o;if(e.isHorizontal()){if(p=ut(i,o,a),B(n)){const w=Object.keys(n)[0],S=n[w];y=h[w].getPixelForValue(S)+x-t}else n==="center"?y=(c.bottom+c.top)/2+x-t:y=So(e,n,t);g=a-o}else{if(B(n)){const w=Object.keys(n)[0],S=n[w];p=h[w].getPixelForValue(S)-v+t}else n==="center"?p=(c.left+c.right)/2-v+t:p=So(e,n,t);y=ut(i,r,s),d=n==="left"?-_t:_t}return{titleX:p,titleY:y,maxWidth:g,rotation:d}}class Le extends Ne{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.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(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:i,_suggestedMax:s}=this;return t=Tt(t,Number.POSITIVE_INFINITY),n=Tt(n,Number.NEGATIVE_INFINITY),i=Tt(i,Number.POSITIVE_INFINITY),s=Tt(s,Number.NEGATIVE_INFINITY),{min:Tt(t,i),max:Tt(n,s),minDefined:xt(t),maxDefined:xt(n)}}getMinMax(t){let{min:n,max:i,minDefined:s,maxDefined:o}=this.getUserBounds(),r;if(s&&o)return{min:n,max:i};const a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;l<c;++l)r=a[l].controller.getMinMax(this,t),s||(n=Math.min(n,r.min)),o||(i=Math.max(i,r.max));return n=o&&n>i?i:n,i=s&&n>i?n:i,{min:Tt(n,Tt(i,n)),max:Tt(i,Tt(n,i))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){I(this.options.beforeUpdate,[this])}update(t,n,i){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=mh(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a<this.ticks.length;this._convertTicksToLabels(l?To(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||r.source==="auto")&&(this.ticks=Vu(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,i;this.isHorizontal()?(n=this.left,i=this.right):(n=this.top,i=this.bottom,t=!t),this._startPixel=n,this._endPixel=i,this._reversePixels=t,this._length=i-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){I(this.options.afterUpdate,[this])}beforeSetDimensions(){I(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(){I(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),I(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){I(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let i,s,o;for(i=0,s=t.length;i<s;i++)o=t[i],o.label=I(n.callback,[o.value,i,t],this)}afterTickToLabelConversion(){I(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){I(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,i=ko(this.ticks.length,t.ticks.maxTicksLimit),s=n.minRotation||0,o=n.maxRotation;let r=s,a,l,c;if(!this._isVisible()||!n.display||s>=o||i<=1||!this.isHorizontal()){this.labelRotation=s;return}const h=this._getLabelSizes(),d=h.widest.width,g=h.highest.height,p=bt(this.chart.width-d,0,this.maxWidth);a=t.offset?this.maxWidth/i:p/(i-1),d+6>a&&(a=p/(i-(t.offset?.5:1)),l=this.maxHeight-Xe(t.grid)-n.padding-Mo(t.title,this.chart.options.font),c=Math.sqrt(d*d+g*g),r=Fc(Math.min(Math.asin(bt((h.highest.height+6)/a,-1,1)),Math.asin(bt(l/c,-1,1))-Math.asin(bt(g/c,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){I(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){I(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:i,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=Mo(s,n.options.font);if(a?(t.width=this.maxWidth,t.height=Xe(o)+l):(t.height=this.maxHeight,t.width=Xe(o)+l),i.display&&this.ticks.length){const{first:c,last:h,widest:d,highest:g}=this._getLabelSizes(),p=i.padding*2,y=de(this.labelRotation),x=Math.cos(y),v=Math.sin(y);if(a){const w=i.mirror?0:v*d.width+x*g.height;t.height=Math.min(this.maxHeight,t.height+w+p)}else{const w=i.mirror?0:x*d.width+v*g.height;t.width=Math.min(this.maxWidth,t.width+w+p)}this._calculatePadding(c,h,v,x)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,i,s){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const h=this.getPixelForTick(0)-this.left,d=this.right-this.getPixelForTick(this.ticks.length-1);let g=0,p=0;l?c?(g=s*t.width,p=i*n.height):(g=i*t.height,p=s*n.width):o==="start"?p=n.width:o==="end"?g=t.width:o!=="inner"&&(g=t.width/2,p=n.width/2),this.paddingLeft=Math.max((g-h+r)*this.width/(this.width-h),0),this.paddingRight=Math.max((p-d+r)*this.width/(this.width-d),0)}else{let h=n.height/2,d=t.height/2;o==="start"?(h=0,d=t.height):o==="end"&&(h=n.height,d=0),this.paddingTop=h+r,this.paddingBottom=d+r}}_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(){I(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,i;for(n=0,i=t.length;n<i;n++)W(t[n].label)&&(t.splice(n,1),i--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let i=this.ticks;n<i.length&&(i=To(i,n)),this._labelSizes=t=this._computeLabelSizes(i,i.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,i){const{ctx:s,_longestTextCache:o}=this,r=[],a=[],l=Math.floor(n/ko(n,i));let c=0,h=0,d,g,p,y,x,v,w,S,O,C,k;for(d=0;d<n;d+=l){if(y=t[d].label,x=this._resolveTickFontOptions(d),s.font=v=x.string,w=o[v]=o[v]||{data:{},gc:[]},S=x.lineHeight,O=C=0,!W(y)&&!Z(y))O=no(s,w.data,w.gc,O,y),C=S;else if(Z(y))for(g=0,p=y.length;g<p;++g)k=y[g],!W(k)&&!Z(k)&&(O=no(s,w.data,w.gc,O,k),C+=S);r.push(O),a.push(C),c=Math.max(O,c),h=Math.max(C,h)}Ku(o,n);const D=r.indexOf(c),P=a.indexOf(h),M=A=>({width:r[A]||0,height:a[A]||0});return{first:M(0),last:M(n-1),widest:M(D),highest:M(P),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const n=this._startPixel+t*this._length;return Wc(this._alignToPixels?le(this.chart,n,0):n)}getDecimalForPixel(t){const n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){const n=this.ticks||[];if(t>=0&&t<n.length){const i=n[t];return i.$context||(i.$context=Qu(this.getContext(),t,i))}return this.$context||(this.$context=Zu(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=de(this.labelRotation),i=Math.abs(Math.cos(n)),s=Math.abs(Math.sin(n)),o=this._getLabelSizes(),r=t.autoSkipPadding||0,a=o?o.widest.width+r:0,l=o?o.highest.height+r:0;return this.isHorizontal()?l*i>a*s?a/i:l/s:l*s<a*i?l/i:a/s}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,i=this.chart,s=this.options,{grid:o,position:r,border:a}=s,l=o.offset,c=this.isHorizontal(),d=this.ticks.length+(l?1:0),g=Xe(o),p=[],y=a.setContext(this.getContext()),x=y.display?y.width:0,v=x/2,w=function(X){return le(i,X,x)};let S,O,C,k,D,P,M,A,F,N,H,G;if(r==="top")S=w(this.bottom),P=this.bottom-g,A=S-v,N=w(t.top)+v,G=t.bottom;else if(r==="bottom")S=w(this.top),N=t.top,G=w(t.bottom)-v,P=S+v,A=this.top+g;else if(r==="left")S=w(this.right),D=this.right-g,M=S-v,F=w(t.left)+v,H=t.right;else if(r==="right")S=w(this.left),F=t.left,H=w(t.right)-v,D=S+v,M=this.left+g;else if(n==="x"){if(r==="center")S=w((t.top+t.bottom)/2+.5);else if(B(r)){const X=Object.keys(r)[0],et=r[X];S=w(this.chart.scales[X].getPixelForValue(et))}N=t.top,G=t.bottom,P=S+v,A=P+g}else if(n==="y"){if(r==="center")S=w((t.left+t.right)/2);else if(B(r)){const X=Object.keys(r)[0],et=r[X];S=w(this.chart.scales[X].getPixelForValue(et))}D=S-v,M=D-g,F=t.left,H=t.right}const tt=L(s.ticks.maxTicksLimit,d),V=Math.max(1,Math.ceil(d/tt));for(O=0;O<d;O+=V){const X=this.getContext(O),et=o.setContext(X),we=a.setContext(X),ee=et.lineWidth,Bt=et.color,Ee=we.dash||[],dt=we.dashOffset,ne=et.tickWidth,yt=et.tickColor,ie=et.tickBorderDash||[],It=et.tickBorderDashOffset;C=Gu(this,O,l),C!==void 0&&(k=le(i,C,ee),c?D=M=F=H=k:P=A=N=G=k,p.push({tx1:D,ty1:P,tx2:M,ty2:A,x1:F,y1:N,x2:H,y2:G,width:ee,color:Bt,borderDash:Ee,borderDashOffset:dt,tickWidth:ne,tickColor:yt,tickBorderDash:ie,tickBorderDashOffset:It}))}return this._ticksLength=d,this._borderValue=S,p}_computeLabelItems(t){const n=this.axis,i=this.options,{position:s,ticks:o}=i,r=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:c,padding:h,mirror:d}=o,g=Xe(i.grid),p=g+h,y=d?-h:p,x=-de(this.labelRotation),v=[];let w,S,O,C,k,D,P,M,A,F,N,H,G="middle";if(s==="top")D=this.bottom-y,P=this._getXAxisLabelAlignment();else if(s==="bottom")D=this.top+y,P=this._getXAxisLabelAlignment();else if(s==="left"){const V=this._getYAxisLabelAlignment(g);P=V.textAlign,k=V.x}else if(s==="right"){const V=this._getYAxisLabelAlignment(g);P=V.textAlign,k=V.x}else if(n==="x"){if(s==="center")D=(t.top+t.bottom)/2+p;else if(B(s)){const V=Object.keys(s)[0],X=s[V];D=this.chart.scales[V].getPixelForValue(X)+p}P=this._getXAxisLabelAlignment()}else if(n==="y"){if(s==="center")k=(t.left+t.right)/2-p;else if(B(s)){const V=Object.keys(s)[0],X=s[V];k=this.chart.scales[V].getPixelForValue(X)}P=this._getYAxisLabelAlignment(g).textAlign}n==="y"&&(l==="start"?G="top":l==="end"&&(G="bottom"));const tt=this._getLabelSizes();for(w=0,S=a.length;w<S;++w){O=a[w],C=O.label;const V=o.setContext(this.getContext(w));M=this.getPixelForTick(w)+o.labelOffset,A=this._resolveTickFontOptions(w),F=A.lineHeight,N=Z(C)?C.length:1;const X=N/2,et=V.color,we=V.textStrokeColor,ee=V.textStrokeWidth;let Bt=P;r?(k=M,P==="inner"&&(w===S-1?Bt=this.options.reverse?"left":"right":w===0?Bt=this.options.reverse?"right":"left":Bt="center"),s==="top"?c==="near"||x!==0?H=-N*F+F/2:c==="center"?H=-tt.highest.height/2-X*F+F:H=-tt.highest.height+F/2:c==="near"||x!==0?H=F/2:c==="center"?H=tt.highest.height/2-X*F:H=tt.highest.height-N*F,d&&(H*=-1),x!==0&&!V.showLabelBackdrop&&(k+=F/2*Math.sin(x))):(D=M,H=(1-N)*F/2);let Ee;if(V.showLabelBackdrop){const dt=wt(V.backdropPadding),ne=tt.heights[w],yt=tt.widths[w];let ie=H-dt.top,It=0-dt.left;switch(G){case"middle":ie-=ne/2;break;case"bottom":ie-=ne;break}switch(P){case"center":It-=yt/2;break;case"right":It-=yt;break;case"inner":w===S-1?It-=yt:w>0&&(It-=yt/2);break}Ee={left:It,top:ie,width:yt+dt.width,height:ne+dt.height,color:V.backdropColor}}v.push({label:C,font:A,textOffset:H,options:{rotation:x,color:et,strokeColor:we,strokeWidth:ee,textAlign:Bt,textBaseline:G,translation:[k,D],backdrop:Ee}})}return v}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-de(this.labelRotation))return t==="top"?"left":"right";let s="center";return n.align==="start"?s="left":n.align==="end"?s="right":n.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:i,mirror:s,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width;let c,h;return n==="left"?s?(h=this.right+o,i==="near"?c="left":i==="center"?(c="center",h+=l/2):(c="right",h+=l)):(h=this.right-a,i==="near"?c="right":i==="center"?(c="center",h-=l/2):(c="left",h=this.left)):n==="right"?s?(h=this.left+o,i==="near"?c="right":i==="center"?(c="center",h-=l/2):(c="left",h-=l)):(h=this.left+a,i==="near"?c="left":i==="center"?(c="center",h+=l/2):(c="right",h=this.right)):c="right",{textAlign:c,x:h}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:n},left:i,top:s,width:o,height:r}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(i,s,o,r),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const s=this.ticks.findIndex(o=>o.value===t);return s>=0?n.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const n=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(l,c,h)=>{!h.width||!h.color||(i.save(),i.lineWidth=h.width,i.strokeStyle=h.color,i.setLineDash(h.borderDash||[]),i.lineDashOffset=h.borderDashOffset,i.beginPath(),i.moveTo(l.x,l.y),i.lineTo(c.x,c.y),i.stroke(),i.restore())};if(n.display)for(o=0,r=s.length;o<r;++o){const l=s[o];n.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),n.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:n,options:{border:i,grid:s}}=this,o=i.setContext(this.getContext()),r=i.display?o.width:0;if(!r)return;const a=s.setContext(this.getContext(0)).lineWidth,l=this._borderValue;let c,h,d,g;this.isHorizontal()?(c=le(t,this.left,r)-r/2,h=le(t,this.right,a)+a/2,d=g=l):(d=le(t,this.top,r)-r/2,g=le(t,this.bottom,a)+a/2,c=h=l),n.save(),n.lineWidth=o.width,n.strokeStyle=o.color,n.beginPath(),n.moveTo(c,d),n.lineTo(h,g),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;const i=this.ctx,s=this._computeLabelArea();s&&ls(i,s);const o=this.getLabelItems(t);for(const r of o){const a=r.options,l=r.font,c=r.label,h=r.textOffset;Zn(i,c,0,h,l,a)}s&&cs(i)}drawTitle(){const{ctx:t,options:{position:n,title:i,reverse:s}}=this;if(!i.display)return;const o=lt(i.font),r=wt(i.padding),a=i.align;let l=o.lineHeight/2;n==="bottom"||n==="center"||B(n)?(l+=r.bottom,Z(i.text)&&(l+=o.lineHeight*(i.text.length-1))):l+=r.top;const{titleX:c,titleY:h,maxWidth:d,rotation:g}=td(this,l,n,a);Zn(t,i.text,0,0,o,{color:i.color,maxWidth:d,rotation:g,textAlign:Ju(a,n,s),textBaseline:"middle",translation:[c,h]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,n=t.ticks&&t.ticks.z||0,i=L(t.grid&&t.grid.z,-1),s=L(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==Le.prototype.draw?[{z:n,draw:o=>{this.draw(o)}}]:[{z:i,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:n,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let o,r;for(o=0,r=n.length;o<r;++o){const a=n[o];a[i]===this.id&&(!t||a.type===t)&&s.push(a)}return s}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return lt(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class Rn{constructor(t,n,i){this.type=t,this.scope=n,this.override=i,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const n=Object.getPrototypeOf(t);let i;id(n)&&(i=this.register(n));const s=this.items,o=t.id,r=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in s||(s[o]=t,ed(t,r,i),this.override&&Y.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){const n=this.items,i=t.id,s=this.scope;i in n&&delete n[i],s&&i in Y[s]&&(delete Y[s][i],this.override&&delete be[i])}}function ed(e,t,n){const i=cn(Object.create(null),[n?Y.get(n):{},Y.get(t),e.defaults]);Y.set(t,i),e.defaultRoutes&&nd(t,e.defaultRoutes),e.descriptors&&Y.describe(t,e.descriptors)}function nd(e,t){Object.keys(t).forEach(n=>{const i=n.split("."),s=i.pop(),o=[e].concat(i).join("."),r=t[n].split("."),a=r.pop(),l=r.join(".");Y.route(o,s,l,a)})}function id(e){return"id"in e&&"defaults"in e}class sd{constructor(){this.controllers=new Rn(sa,"datasets",!0),this.elements=new Rn(Ne,"elements"),this.plugins=new Rn(Object,"plugins"),this.scales=new Rn(Le,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,i){[...n].forEach(s=>{const o=i||this._getRegistryForType(s);i||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):z(s,r=>{const a=i||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,n,i){const s=os(t);I(i["before"+s],[],i),n[t](i),I(i["after"+s],[],i)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const i=this._typedRegistries[n];if(i.isForType(t))return i}return this.plugins}_get(t,n,i){const s=n.get(t);if(s===void 0)throw new Error('"'+t+'" is not a registered '+i+".");return s}}var Ot=new sd;class od{constructor(){this._init=[]}notify(t,n,i,s){n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));const o=s?this._descriptors(t).filter(s):this._descriptors(t),r=this._notify(o,t,n,i);return n==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall")),r}_notify(t,n,i,s){s=s||{};for(const o of t){const r=o.plugin,a=r[i],l=[n,s,o.options];if(I(a,l,r)===!1&&s.cancelable)return!1}return!0}invalidate(){W(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){const i=t&&t.config,s=L(i.options&&i.options.plugins,{}),o=rd(i);return s===!1&&!n?[]:ld(t,o,s,n)}_notifyStateChanges(t){const n=this._oldCache||[],i=this._cache,s=(o,r)=>o.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(s(n,i),t,"stop"),this._notify(s(i,n),t,"start")}}function rd(e){const t={},n=[],i=Object.keys(Ot.plugins.items);for(let o=0;o<i.length;o++)n.push(Ot.getPlugin(i[o]));const s=e.plugins||[];for(let o=0;o<s.length;o++){const r=s[o];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function ad(e,t){return!t&&e===!1?null:e===!0?{}:e}function ld(e,{plugins:t,localIds:n},i,s){const o=[],r=e.getContext();for(const a of t){const l=a.id,c=ad(i[l],s);c!==null&&o.push({plugin:a,options:cd(e.config,{plugin:a,local:n[l]},c,r)})}return o}function cd(e,{plugin:t,local:n},i,s){const o=e.pluginScopeKeys(t),r=e.getOptionScopes(i,o);return n&&t.defaults&&r.push(t.defaults),e.createResolver(r,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Hi(e,t){const n=Y.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function hd(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function ud(e,t){return e===t?"_index_":"_value_"}function Oo(e){if(e==="x"||e==="y"||e==="r")return e}function dd(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function Bi(e,...t){if(Oo(e))return e;for(const n of t){const i=n.axis||dd(n.position)||e.length>1&&Oo(e[0].toLowerCase());if(i)return i}throw new Error(\`Cannot determine type of '\${e}' axis. Please provide 'axis' or 'position' option.\`)}function Co(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function fd(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(i=>i.xAxisID===e||i.yAxisID===e);if(n.length)return Co(e,"x",n[0])||Co(e,"y",n[0])}return{}}function gd(e,t){const n=be[e.type]||{scales:{}},i=t.scales||{},s=Hi(e.type,t),o=Object.create(null);return Object.keys(i).forEach(r=>{const a=i[r];if(!B(a))return console.error(\`Invalid scale configuration for scale: \${r}\`);if(a._proxy)return console.warn(\`Ignoring resolver passed as options for scale: \${r}\`);const l=Bi(r,a,fd(r,e),Y.scales[a.type]),c=ud(l,s),h=n.scales||{};o[r]=tn(Object.create(null),[{axis:l},a,h[l],h[c]])}),e.data.datasets.forEach(r=>{const a=r.type||e.type,l=r.indexAxis||Hi(a,t),h=(be[a]||{}).scales||{};Object.keys(h).forEach(d=>{const g=hd(d,l),p=r[g+"AxisID"]||g;o[p]=o[p]||Object.create(null),tn(o[p],[{axis:g},i[p],h[d]])})}),Object.keys(o).forEach(r=>{const a=o[r];tn(a,[Y.scales[a.type],Y.scale])}),o}function ha(e){const t=e.options||(e.options={});t.plugins=L(t.plugins,{}),t.scales=gd(e,t)}function ua(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function pd(e){return e=e||{},e.data=ua(e.data),ha(e),e}const Po=new Map,da=new Set;function zn(e,t){let n=Po.get(e);return n||(n=t(),Po.set(e,n),da.add(n)),n}const qe=(e,t,n)=>{const i=qn(t,n);i!==void 0&&e.add(i)};class md{constructor(t){this._config=pd(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=ua(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),ha(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return zn(t,()=>[[\`datasets.\${t}\`,""]])}datasetAnimationScopeKeys(t,n){return zn(\`\${t}.transition.\${n}\`,()=>[[\`datasets.\${t}.transitions.\${n}\`,\`transitions.\${n}\`],[\`datasets.\${t}\`,""]])}datasetElementScopeKeys(t,n){return zn(\`\${t}-\${n}\`,()=>[[\`datasets.\${t}.elements.\${n}\`,\`datasets.\${t}\`,\`elements.\${n}\`,""]])}pluginScopeKeys(t){const n=t.id,i=this.type;return zn(\`\${i}-plugin-\${n}\`,()=>[[\`plugins.\${n}\`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const i=this._scopeCache;let s=i.get(t);return(!s||n)&&(s=new Map,i.set(t,s)),s}getOptionScopes(t,n,i){const{options:s,type:o}=this,r=this._cachedScopes(t,i),a=r.get(n);if(a)return a;const l=new Set;n.forEach(h=>{t&&(l.add(t),h.forEach(d=>qe(l,t,d))),h.forEach(d=>qe(l,s,d)),h.forEach(d=>qe(l,be[o]||{},d)),h.forEach(d=>qe(l,Y,d)),h.forEach(d=>qe(l,Ri,d))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),da.has(n)&&r.set(n,c),c}chartOptionScopes(){const{options:t,type:n}=this;return[t,be[n]||{},Y.datasets[n]||{},{type:n},Y,Ri]}resolveNamedOptions(t,n,i,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=Do(this._resolverCache,t,s);let l=r;if(xd(r,n)){o.$shared=!1,i=Zt(i)?i():i;const c=this.createResolver(t,i,a);l=Ae(r,i,c)}for(const c of n)o[c]=l[c];return o}createResolver(t,n,i=[""],s){const{resolver:o}=Do(this._resolverCache,t,i);return B(n)?Ae(o,n,void 0,s):o}}function Do(e,t,n){let i=e.get(t);i||(i=new Map,e.set(t,i));const s=n.join();let o=i.get(s);return o||(o={resolver:hs(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},i.set(s,o)),o}const bd=e=>B(e)&&Object.getOwnPropertyNames(e).some(t=>Zt(e[t]));function xd(e,t){const{isScriptable:n,isIndexable:i}=qr(e);for(const s of t){const o=n(s),r=i(s),a=(r||o)&&e[s];if(o&&(Zt(a)||bd(a))||r&&Z(a))return!0}return!1}var yd="4.5.0";const vd=["top","bottom","left","right","chartArea"];function Ao(e,t){return e==="top"||e==="bottom"||vd.indexOf(e)===-1&&t==="x"}function Io(e,t){return function(n,i){return n[e]===i[e]?n[t]-i[t]:n[e]-i[e]}}function No(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),I(n&&n.onComplete,[e],t)}function _d(e){const t=e.chart,n=t.options.animation;I(n&&n.onProgress,[e],t)}function fa(e){return fs()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const Vn={},Lo=e=>{const t=fa(e);return Object.values(Vn).filter(n=>n.canvas===t).pop()};function wd(e,t,n){const i=Object.keys(e);for(const s of i){const o=+s;if(o>=t){const r=e[s];delete e[s],(n>0||o>t)&&(e[o+n]=r)}}}function Ed(e,t,n,i){return!n||e.type==="mouseout"?null:i?t:e}class Wi{static defaults=Y;static instances=Vn;static overrides=be;static registry=Ot;static version=yd;static getChart=Lo;static register(...t){Ot.add(...t),Ro()}static unregister(...t){Ot.remove(...t),Ro()}constructor(t,n){const i=this.config=new md(n),s=fa(t),o=Lo(s);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||Wu(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,h=l&&l.width;if(this.id=kc(),this.ctx=a,this.canvas=l,this.width=h,this.height=c,this._options=r,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 od,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=$c(d=>this.update(d),r.resizeDelay||0),this._dataChanges=[],Vn[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}zt.listen(this,"complete",No),zt.listen(this,"progress",_d),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:i,height:s,_aspectRatio:o}=this;return W(t)?n&&o?o:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Ot}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():ro(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return io(this.canvas,this.ctx),this}stop(){return zt.stop(this),this}resize(t,n){zt.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const i=this.options,s=this.canvas,o=i.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,n,o),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,ro(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),I(i.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};z(n,(i,s)=>{i.id=s})}buildOrUpdateScales(){const t=this.options,n=t.scales,i=this.scales,s=Object.keys(i).reduce((r,a)=>(r[a]=!1,r),{});let o=[];n&&(o=o.concat(Object.keys(n).map(r=>{const a=n[r],l=Bi(r,a),c=l==="r",h=l==="x";return{options:a,dposition:c?"chartArea":h?"bottom":"left",dtype:c?"radialLinear":h?"category":"linear"}}))),z(o,r=>{const a=r.options,l=a.id,c=Bi(l,a),h=L(a.type,r.dtype);(a.position===void 0||Ao(a.position,c)!==Ao(r.dposition))&&(a.position=r.dposition),s[l]=!0;let d=null;if(l in i&&i[l].type===h)d=i[l];else{const g=Ot.getScale(h);d=new g({id:l,type:h,ctx:this.ctx,chart:this}),i[d.id]=d}d.init(a,t)}),z(s,(r,a)=>{r||delete i[a]}),z(i,r=>{$t.configure(this,r,r.options),$t.addBox(this,r)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,i=t.length;if(t.sort((s,o)=>s.index-o.index),i>n){for(let s=n;s<i;++s)this._destroyDatasetMeta(s);t.splice(n,i-n)}this._sortedMetasets=t.slice(0).sort(Io("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((i,s)=>{n.filter(o=>o===i._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=n.length;i<s;i++){const o=n[i];let r=this.getDatasetMeta(i);const a=o.type||this.config.type;if(r.type&&r.type!==a&&(this._destroyDatasetMeta(i),r=this.getDatasetMeta(i)),r.type=a,r.indexAxis=o.indexAxis||Hi(a,this.options),r.order=o.order||0,r.index=i,r.label=""+o.label,r.visible=this.isDatasetVisible(i),r.controller)r.controller.updateIndex(i),r.controller.linkScales();else{const l=Ot.getController(a),{datasetElementType:c,dataElementType:h}=Y.datasets[a];Object.assign(l,{dataElementType:Ot.getElement(h),datasetElementType:c&&Ot.getElement(c)}),r.controller=new l(this,i),t.push(r.controller)}}return this._updateMetasets(),t}_resetElements(){z(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const i=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,h=this.data.datasets.length;c<h;c++){const{controller:d}=this.getDatasetMeta(c),g=!s&&o.indexOf(d)===-1;d.buildOrUpdateElements(g),r=Math.max(+d.getMaxOverflow(),r)}r=this._minPadding=i.layout.autoPadding?r:0,this._updateLayout(r),s||z(o,c=>{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Io("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){z(this.scales,t=>{$t.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!Xs(n,i)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:o}of n){const r=i==="_removeElements"?-o:o;wd(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,i=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),s=i(0);for(let o=1;o<n;o++)if(!Xs(s,i(o)))return;return Array.from(s).map(o=>o.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;$t.update(this,this.width,this.height,t);const n=this.chartArea,i=n.width<=0||n.height<=0;this._layers=[],z(this.boxes,s=>{i&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,i=this.data.datasets.length;n<i;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,i=this.data.datasets.length;n<i;++n)this._updateDataset(n,Zt(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const i=this.getDatasetMeta(t),s={meta:i,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",s)!==!1&&(i.controller._update(n),s.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",s))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(zt.has(this)?this.attached&&!zt.running(this)&&zt.start(this):(this.draw(),No({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:i,height:s}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(i,s)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const n=this._sortedMetasets,i=[];let s,o;for(s=0,o=n.length;s<o;++s){const r=n[s];(!t||r.visible)&&i.push(r)}return i}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,i={meta:t,index:t.index,cancelable:!0},s=Jh(this,t);this.notifyPlugins("beforeDatasetDraw",i)!==!1&&(s&&ls(n,s),t.controller.draw(),s&&cs(n),i.cancelable=!1,this.notifyPlugins("afterDatasetDraw",i))}isPointInArea(t){return De(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,i,s){const o=vu.modes[n];return typeof o=="function"?o(this,t,i,s):[]}getDatasetMeta(t){const n=this.data.datasets[t],i=this._metasets;let s=i.filter(o=>o&&o._dataset===n).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=ve(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const i=this.getDatasetMeta(t);return typeof i.hidden=="boolean"?!i.hidden:!n.hidden}setDatasetVisibility(t,n){const i=this.getDatasetMeta(t);i.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,i){const s=i?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);Gn(n)?(o.data[n].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),r.update(o,{visible:i}),this.update(a=>a.datasetIndex===t?s:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),zt.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),io(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete Vn[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,n=this.platform,i=(o,r)=>{n.addEventListener(this,o,r),t[o]=r},s=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};z(this.options.events,o=>i(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,i=(l,c)=>{n.addEventListener(this,l,c),t[l]=c},s=(l,c)=>{t[l]&&(n.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",o),i("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),i("attach",a)},n.isAttached(this.canvas)?a():r()}unbindEvents(){z(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},z(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,i){const s=i?"set":"remove";let o,r,a,l;for(n==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){r=t[a];const c=r&&this.getDatasetMeta(r.datasetIndex).controller;c&&c[s+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],i=t.map(({datasetIndex:o,index:r})=>{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!$n(i,n)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,n))}notifyPlugins(t,n,i){return this._plugins.notify(this,t,n,i)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,i){const s=this.options.hover,o=(l,c)=>l.filter(h=>!c.some(d=>h.datasetIndex===d.datasetIndex&&h.index===d.index)),r=o(n,t),a=i?t:o(t,n);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,n){const i={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",i,s)===!1)return;const o=this._handleEvent(t,n,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(o||i.changed)&&this.render(),this}_handleEvent(t,n,i){const{_active:s=[],options:o}=this,r=n,a=this._getActiveElements(t,s,i,r),l=Dc(t),c=Ed(t,this._lastEvent,i,l);i&&(this._lastEvent=null,I(o.onHover,[t,a,this],this),l&&I(o.onClick,[t,a,this],this));const h=!$n(a,s);return(h||n)&&(this._active=a,this._updateHoverStyles(a,s,n)),this._lastEvent=c,h}_getActiveElements(t,n,i,s){if(t.type==="mouseout")return[];if(!i)return n;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}function Ro(){return z(Wi.instances,e=>e._plugins.invalidate())}function ga(e,t,n=t){e.lineCap=L(n.borderCapStyle,t.borderCapStyle),e.setLineDash(L(n.borderDash,t.borderDash)),e.lineDashOffset=L(n.borderDashOffset,t.borderDashOffset),e.lineJoin=L(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=L(n.borderWidth,t.borderWidth),e.strokeStyle=L(n.borderColor,t.borderColor)}function Sd(e,t,n){e.lineTo(n.x,n.y)}function kd(e){return e.stepped?rh:e.tension||e.cubicInterpolationMode==="monotone"?ah:Sd}function pa(e,t,n={}){const i=e.length,{start:s=0,end:o=i-1}=n,{start:r,end:a}=t,l=Math.max(s,r),c=Math.min(o,a),h=s<r&&o<r||s>a&&o>a;return{count:i,start:l,loop:t.loop,ilen:c<l&&!h?i+c-l:c-l}}function Td(e,t,n,i){const{points:s,options:o}=t,{count:r,start:a,loop:l,ilen:c}=pa(s,n,i),h=kd(o);let{move:d=!0,reverse:g}=i||{},p,y,x;for(p=0;p<=c;++p)y=s[(a+(g?c-p:p))%r],!y.skip&&(d?(e.moveTo(y.x,y.y),d=!1):h(e,x,y,g,o.stepped),x=y);return l&&(y=s[(a+(g?c:0))%r],h(e,x,y,g,o.stepped)),!!l}function Md(e,t,n,i){const s=t.points,{count:o,start:r,ilen:a}=pa(s,n,i),{move:l=!0,reverse:c}=i||{};let h=0,d=0,g,p,y,x,v,w;const S=C=>(r+(c?a-C:C))%o,O=()=>{x!==v&&(e.lineTo(h,v),e.lineTo(h,x),e.lineTo(h,w))};for(l&&(p=s[S(0)],e.moveTo(p.x,p.y)),g=0;g<=a;++g){if(p=s[S(g)],p.skip)continue;const C=p.x,k=p.y,D=C|0;D===y?(k<x?x=k:k>v&&(v=k),h=(d*h+C)/++d):(O(),e.lineTo(C,k),y=D,d=0,x=v=k),w=k}O()}function Vi(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?Md:Td}function Od(e){return e.stepped?Bh:e.tension||e.cubicInterpolationMode==="monotone"?Wh:he}function Cd(e,t,n,i){let s=t._path;s||(s=t._path=new Path2D,t.path(s,n,i)&&s.closePath()),ga(e,t.options),e.stroke(s)}function Pd(e,t,n,i){const{segments:s,options:o}=t,r=Vi(t);for(const a of s)ga(e,o,a.style),e.beginPath(),r(e,t,a,{start:n,end:n+i-1})&&e.closePath(),e.stroke()}const Dd=typeof Path2D=="function";function Ad(e,t,n,i){Dd&&!t.options.segment?Cd(e,t,n,i):Pd(e,t,n,i)}class Id extends Ne{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:t=>t!=="borderDash"&&t!=="fill"};constructor(t){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,t&&Object.assign(this,t)}updateControlPoints(t,n){const i=this.options;if((i.tension||i.cubicInterpolationMode==="monotone")&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Ah(this._points,i,t,s,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Gh(this,this.options.segment))}first(){const t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){const t=this.segments,n=this.points,i=t.length;return i&&n[t[i-1].end]}interpolate(t,n){const i=this.options,s=t[n],o=this.points,r=$h(this,{property:n,start:s,end:s});if(!r.length)return;const a=[],l=Od(i);let c,h;for(c=0,h=r.length;c<h;++c){const{start:d,end:g}=r[c],p=o[d],y=o[g];if(p===y){a.push(p);continue}const x=Math.abs((s-p[n])/(y[n]-p[n])),v=l(p,y,x,i.stepped);v[n]=t[n],a.push(v)}return a.length===1?a[0]:a}pathSegment(t,n,i){return Vi(this)(t,this,n,i)}path(t,n,i){const s=this.segments,o=Vi(this);let r=this._loop;n=n||0,i=i||this.points.length-n;for(const a of s)r&=o(t,this,a,{start:n,end:n+i-1});return!!r}draw(t,n,i,s){const o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),Ad(t,this,i,s),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function zo(e,t,n,i){const s=e.options,{[n]:o}=e.getProps([n],i);return Math.abs(t-o)<s.radius+s.hitRadius}class Nd extends Ne{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(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,n,i){const s=this.options,{x:o,y:r}=this.getProps(["x","y"],i);return Math.pow(t-o,2)+Math.pow(n-r,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(t,n){return zo(this,t,"x",n)}inYRange(t,n){return zo(this,t,"y",n)}getCenterPoint(t){const{x:n,y:i}=this.getProps(["x","y"],t);return{x:n,y:i}}size(t){t=t||this.options||{};let n=t.radius||0;n=Math.max(n,n&&t.hoverRadius||0);const i=n&&t.borderWidth||0;return(n+i)*2}draw(t,n){const i=this.options;this.skip||i.radius<.1||!De(this,n,this.size(i)/2)||(t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,zi(t,i,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}const Fo=(e,t)=>{let{boxHeight:n=t,boxWidth:i=t}=e;return e.usePointStyle&&(n=Math.min(n,t),i=e.pointStyleWidth||Math.min(i,t)),{boxWidth:i,boxHeight:n,itemHeight:Math.max(t,n)}},Ld=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class Ho extends Ne{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.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(t,n,i){this.maxWidth=t,this.maxHeight=n,this._margins=i,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(){const t=this.options.labels||{};let n=I(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(i=>t.filter(i,this.chart.data))),t.sort&&(n=n.sort((i,s)=>t.sort(i,s,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){const{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}const i=t.labels,s=lt(i.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=Fo(i,o);let c,h;n.font=s.string,this.isHorizontal()?(c=this.maxWidth,h=this._fitRows(r,o,a,l)+10):(h=this.maxHeight,c=this._fitCols(r,s,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,n,i,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],h=s+a;let d=t;o.textAlign="left",o.textBaseline="middle";let g=-1,p=-h;return this.legendItems.forEach((y,x)=>{const v=i+n/2+o.measureText(y.text).width;(x===0||c[c.length-1]+v+2*a>r)&&(d+=h,c[c.length-(x>0?0:1)]=0,p+=h,g++),l[x]={left:0,top:p,row:g,width:v,height:s},c[c.length-1]+=v+a}),d}_fitCols(t,n,i,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],h=r-t;let d=a,g=0,p=0,y=0,x=0;return this.legendItems.forEach((v,w)=>{const{itemWidth:S,itemHeight:O}=Rd(i,n,o,v,s);w>0&&p+O+2*a>h&&(d+=g+a,c.push({width:g,height:p}),y+=g+a,x++,g=p=0),l[w]={left:y,top:p,col:x,width:S,height:O},g=Math.max(g,S),p+=O+a}),d+=g,c.push({width:g,height:p}),d}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:i,labels:{padding:s},rtl:o}}=this,r=Oe(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=ut(i,this.left+s,this.right-this.lineWidths[a]);for(const c of n)a!==c.row&&(a=c.row,l=ut(i,this.left+s,this.right-this.lineWidths[a])),c.top+=this.top+t+s,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+s}else{let a=0,l=ut(i,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const c of n)c.col!==a&&(a=c.col,l=ut(i,this.top+t+s,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+s,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;ls(t,this),this._draw(),cs(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:i,ctx:s}=this,{align:o,labels:r}=t,a=Y.color,l=Oe(t.rtl,this.left,this.width),c=lt(r.font),{padding:h}=r,d=c.size,g=d/2;let p;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:y,boxHeight:x,itemHeight:v}=Fo(r,d),w=function(D,P,M){if(isNaN(y)||y<=0||isNaN(x)||x<0)return;s.save();const A=L(M.lineWidth,1);if(s.fillStyle=L(M.fillStyle,a),s.lineCap=L(M.lineCap,"butt"),s.lineDashOffset=L(M.lineDashOffset,0),s.lineJoin=L(M.lineJoin,"miter"),s.lineWidth=A,s.strokeStyle=L(M.strokeStyle,a),s.setLineDash(L(M.lineDash,[])),r.usePointStyle){const F={radius:x*Math.SQRT2/2,pointStyle:M.pointStyle,rotation:M.rotation,borderWidth:A},N=l.xPlus(D,y/2),H=P+g;$r(s,F,N,H,r.pointStyleWidth&&y)}else{const F=P+Math.max((d-x)/2,0),N=l.leftForLtr(D,y),H=sn(M.borderRadius);s.beginPath(),Object.values(H).some(G=>G!==0)?Fi(s,{x:N,y:F,w:y,h:x,radius:H}):s.rect(N,F,y,x),s.fill(),A!==0&&s.stroke()}s.restore()},S=function(D,P,M){Zn(s,M.text,D,P+v/2,c,{strikethrough:M.hidden,textAlign:l.textAlign(M.textAlign)})},O=this.isHorizontal(),C=this._computeTitleHeight();O?p={x:ut(o,this.left+h,this.right-i[0]),y:this.top+h+C,line:0}:p={x:this.left+h,y:ut(o,this.top+C+h,this.bottom-n[0].height),line:0},Jr(this.ctx,t.textDirection);const k=v+h;this.legendItems.forEach((D,P)=>{s.strokeStyle=D.fontColor,s.fillStyle=D.fontColor;const M=s.measureText(D.text).width,A=l.textAlign(D.textAlign||(D.textAlign=r.textAlign)),F=y+g+M;let N=p.x,H=p.y;l.setWidth(this.width),O?P>0&&N+F+h>this.right&&(H=p.y+=k,p.line++,N=p.x=ut(o,this.left+h,this.right-i[p.line])):P>0&&H+k>this.bottom&&(N=p.x=N+n[p.line].width+h,p.line++,H=p.y=ut(o,this.top+C+h,this.bottom-n[p.line].height));const G=l.x(N);if(w(G,H,D),N=Xc(A,N+y+g,O?N+F:this.right,t.rtl),S(l.x(N),H,D),O)p.x+=F+h;else if(typeof D.text!="string"){const tt=c.lineHeight;p.y+=ma(D,tt)+h}else p.y+=k}),ta(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,i=lt(n.font),s=wt(n.padding);if(!n.display)return;const o=Oe(t.rtl,this.left,this.width),r=this.ctx,a=n.position,l=i.size/2,c=s.top+l;let h,d=this.left,g=this.width;if(this.isHorizontal())g=Math.max(...this.lineWidths),h=this.top+c,d=ut(t.align,d,this.right-g);else{const y=this.columnSizes.reduce((x,v)=>Math.max(x,v.height),0);h=c+ut(t.align,this.top,this.bottom-y-t.labels.padding-this._computeTitleHeight())}const p=ut(a,d,d+g);r.textAlign=o.textAlign(jr(a)),r.textBaseline="middle",r.strokeStyle=n.color,r.fillStyle=n.color,r.font=i.string,Zn(r,n.text,p,h,i)}_computeTitleHeight(){const t=this.options.title,n=lt(t.font),i=wt(t.padding);return t.display?n.lineHeight+i.height:0}_getLegendItemAt(t,n){let i,s,o;if(Ze(t,this.left,this.right)&&Ze(n,this.top,this.bottom)){for(o=this.legendHitBoxes,i=0;i<o.length;++i)if(s=o[i],Ze(t,s.left,s.left+s.width)&&Ze(n,s.top,s.top+s.height))return this.legendItems[i]}return null}handleEvent(t){const n=this.options;if(!Hd(t.type,n))return;const i=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const s=this._hoveredItem,o=Ld(s,i);s&&!o&&I(n.onLeave,[t,s,this],this),this._hoveredItem=i,i&&!o&&I(n.onHover,[t,i,this],this)}else i&&I(n.onClick,[t,i,this],this)}}function Rd(e,t,n,i,s){const o=zd(i,e,t,n),r=Fd(s,i,t.lineHeight);return{itemWidth:o,itemHeight:r}}function zd(e,t,n,i){let s=e.text;return s&&typeof s!="string"&&(s=s.reduce((o,r)=>o.length>r.length?o:r)),t+n.size/2+i.measureText(s).width}function Fd(e,t,n){let i=e;return typeof t.text!="string"&&(i=ma(t,n)),i}function ma(e,t){const n=e.text?e.text.length:0;return t*n}function Hd(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var Bd={id:"legend",_element:Ho,start(e,t,n){const i=e.legend=new Ho({ctx:e.ctx,options:n,chart:e});$t.configure(e,i,n),$t.addBox(e,i)},stop(e){$t.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const i=e.legend;$t.configure(e,i,n),i.options=n},afterUpdate(e){const 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){const i=t.datasetIndex,s=n.chart;s.isDatasetVisible(i)?(s.hide(i),t.hidden=!0):(s.show(i),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:i,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(n?0:void 0),h=wt(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:c.borderColor,pointStyle:i||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.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)}}};const Je={average(e){if(!e.length)return!1;let t,n,i=new Set,s=0,o=0;for(t=0,n=e.length;t<n;++t){const a=e[t].element;if(a&&a.hasValue()){const l=a.tooltipPosition();i.add(l.x),s+=l.y,++o}}return o===0||i.size===0?!1:{x:[...i].reduce((a,l)=>a+l)/i.size,y:s/o}},nearest(e,t){if(!e.length)return!1;let n=t.x,i=t.y,s=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=e.length;o<r;++o){const l=e[o].element;if(l&&l.hasValue()){const c=l.getCenterPoint(),h=Li(t,c);h<s&&(s=h,a=l)}}if(a){const l=a.tooltipPosition();n=l.x,i=l.y}return{x:n,y:i}}};function Mt(e,t){return t&&(Z(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function Ft(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(\`
1711
+ \`)>-1?e.split(\`
1712
+ \`):e}function Wd(e,t){const{element:n,datasetIndex:i,index:s}=t,o=e.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:e,label:r,parsed:o.getParsed(s),raw:e.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:n}}function Bo(e,t){const n=e.chart.ctx,{body:i,footer:s,title:o}=e,{boxWidth:r,boxHeight:a}=t,l=lt(t.bodyFont),c=lt(t.titleFont),h=lt(t.footerFont),d=o.length,g=s.length,p=i.length,y=wt(t.padding);let x=y.height,v=0,w=i.reduce((C,k)=>C+k.before.length+k.lines.length+k.after.length,0);if(w+=e.beforeBody.length+e.afterBody.length,d&&(x+=d*c.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),w){const C=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;x+=p*C+(w-p)*l.lineHeight+(w-1)*t.bodySpacing}g&&(x+=t.footerMarginTop+g*h.lineHeight+(g-1)*t.footerSpacing);let S=0;const O=function(C){v=Math.max(v,n.measureText(C).width+S)};return n.save(),n.font=c.string,z(e.title,O),n.font=l.string,z(e.beforeBody.concat(e.afterBody),O),S=t.displayColors?r+2+t.boxPadding:0,z(i,C=>{z(C.before,O),z(C.lines,O),z(C.after,O)}),S=0,n.font=h.string,z(e.footer,O),n.restore(),v+=y.width,{width:v,height:x}}function Vd(e,t){const{y:n,height:i}=t;return n<i/2?"top":n>e.height-i/2?"bottom":"center"}function jd(e,t,n,i){const{x:s,width:o}=i,r=n.caretSize+n.caretPadding;if(e==="left"&&s+o+r>t.width||e==="right"&&s-o-r<0)return!0}function Ud(e,t,n,i){const{x:s,width:o}=n,{width:r,chartArea:{left:a,right:l}}=e;let c="center";return i==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),jd(c,e,t,n)&&(c="center"),c}function Wo(e,t,n){const i=n.yAlign||t.yAlign||Vd(e,n);return{xAlign:n.xAlign||t.xAlign||Ud(e,t,n,i),yAlign:i}}function Yd(e,t){let{x:n,width:i}=e;return t==="right"?n-=i:t==="center"&&(n-=i/2),n}function $d(e,t,n){let{y:i,height:s}=e;return t==="top"?i+=n:t==="bottom"?i-=s+n:i-=s/2,i}function Vo(e,t,n,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=e,{xAlign:a,yAlign:l}=n,c=s+o,{topLeft:h,topRight:d,bottomLeft:g,bottomRight:p}=sn(r);let y=Yd(t,a);const x=$d(t,l,c);return l==="center"?a==="left"?y+=c:a==="right"&&(y-=c):a==="left"?y-=Math.max(h,g)+s:a==="right"&&(y+=Math.max(d,p)+s),{x:bt(y,0,i.width-t.width),y:bt(x,0,i.height-t.height)}}function Fn(e,t,n){const i=wt(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-i.right:e.x+i.left}function jo(e){return Mt([],Ft(e))}function Xd(e,t,n){return ve(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function Uo(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const ba={beforeTitle:Rt,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,i=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex<i)return n[t.dataIndex]}return""},afterTitle:Rt,beforeBody:Rt,beforeLabel:Rt,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return W(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:Rt,afterBody:Rt,beforeFooter:Rt,footer:Rt,afterFooter:Rt};function ot(e,t,n,i){const s=e[t].call(n,i);return typeof s>"u"?ba[t].call(n,i):s}class Yo extends Ne{static positioners=Je;constructor(t){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=t.chart,this.options=t.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(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&n.options.animation&&i.animations,o=new na(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Xd(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:i}=n,s=ot(i,"beforeTitle",this,t),o=ot(i,"title",this,t),r=ot(i,"afterTitle",this,t);let a=[];return a=Mt(a,Ft(s)),a=Mt(a,Ft(o)),a=Mt(a,Ft(r)),a}getBeforeBody(t,n){return jo(ot(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:i}=n,s=[];return z(t,o=>{const r={before:[],lines:[],after:[]},a=Uo(i,o);Mt(r.before,Ft(ot(a,"beforeLabel",this,o))),Mt(r.lines,ot(a,"label",this,o)),Mt(r.after,Ft(ot(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,n){return jo(ot(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:i}=n,s=ot(i,"beforeFooter",this,t),o=ot(i,"footer",this,t),r=ot(i,"afterFooter",this,t);let a=[];return a=Mt(a,Ft(s)),a=Mt(a,Ft(o)),a=Mt(a,Ft(r)),a}_createItems(t){const n=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push(Wd(this.chart,n[l]));return t.filter&&(a=a.filter((h,d,g)=>t.filter(h,d,g,i))),t.itemSort&&(a=a.sort((h,d)=>t.itemSort(h,d,i))),z(a,h=>{const d=Uo(t.callbacks,h);s.push(ot(d,"labelColor",this,h)),o.push(ot(d,"labelPointStyle",this,h)),r.push(ot(d,"labelTextColor",this,h))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,n){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Je[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=Bo(this,i),c=Object.assign({},a,l),h=Wo(this.chart,i,c),d=Vo(i,c,h,this.chart);this.xAlign=h.xAlign,this.yAlign=h.yAlign,o={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,i,s){const o=this.getCaretPosition(t,i,s);n.lineTo(o.x1,o.y1),n.lineTo(o.x2,o.y2),n.lineTo(o.x3,o.y3)}getCaretPosition(t,n,i){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:h,bottomRight:d}=sn(a),{x:g,y:p}=t,{width:y,height:x}=n;let v,w,S,O,C,k;return o==="center"?(C=p+x/2,s==="left"?(v=g,w=v-r,O=C+r,k=C-r):(v=g+y,w=v+r,O=C-r,k=C+r),S=v):(s==="left"?w=g+Math.max(l,h)+r:s==="right"?w=g+y-Math.max(c,d)-r:w=this.caretX,o==="top"?(O=p,C=O-r,v=w-r,S=w+r):(O=p+x,C=O+r,v=w+r,S=w-r),k=O),{x1:v,x2:w,x3:S,y1:O,y2:C,y3:k}}drawTitle(t,n,i){const s=this.title,o=s.length;let r,a,l;if(o){const c=Oe(i.rtl,this.x,this.width);for(t.x=Fn(this,i.titleAlign,i),n.textAlign=c.textAlign(i.titleAlign),n.textBaseline="middle",r=lt(i.titleFont),a=i.titleSpacing,n.fillStyle=i.titleColor,n.font=r.string,l=0;l<o;++l)n.fillText(s[l],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,l+1===o&&(t.y+=i.titleMarginBottom-a)}}_drawColorBox(t,n,i,s,o){const r=this.labelColors[i],a=this.labelPointStyles[i],{boxHeight:l,boxWidth:c}=o,h=lt(o.bodyFont),d=Fn(this,"left",o),g=s.x(d),p=l<h.lineHeight?(h.lineHeight-l)/2:0,y=n.y+p;if(o.usePointStyle){const x={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},v=s.leftForLtr(g,c)+c/2,w=y+l/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,zi(t,x,v,w),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,zi(t,x,v,w)}else{t.lineWidth=B(r.borderWidth)?Math.max(...Object.values(r.borderWidth)):r.borderWidth||1,t.strokeStyle=r.borderColor,t.setLineDash(r.borderDash||[]),t.lineDashOffset=r.borderDashOffset||0;const x=s.leftForLtr(g,c),v=s.leftForLtr(s.xPlus(g,1),c-2),w=sn(r.borderRadius);Object.values(w).some(S=>S!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Fi(t,{x,y,w:c,h:l,radius:w}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),Fi(t,{x:v,y:y+1,w:c-2,h:l-2,radius:w}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(x,y,c,l),t.strokeRect(x,y,c,l),t.fillStyle=r.backgroundColor,t.fillRect(v,y+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,n,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:h}=i,d=lt(i.bodyFont);let g=d.lineHeight,p=0;const y=Oe(i.rtl,this.x,this.width),x=function(M){n.fillText(M,y.x(t.x+p),t.y+g/2),t.y+=g+o},v=y.textAlign(r);let w,S,O,C,k,D,P;for(n.textAlign=r,n.textBaseline="middle",n.font=d.string,t.x=Fn(this,v,i),n.fillStyle=i.bodyColor,z(this.beforeBody,x),p=a&&v!=="right"?r==="center"?c/2+h:c+2+h:0,C=0,D=s.length;C<D;++C){for(w=s[C],S=this.labelTextColors[C],n.fillStyle=S,z(w.before,x),O=w.lines,a&&O.length&&(this._drawColorBox(n,t,C,y,i),g=Math.max(d.lineHeight,l)),k=0,P=O.length;k<P;++k)x(O[k]),g=d.lineHeight;z(w.after,x)}p=0,g=d.lineHeight,z(this.afterBody,x),t.y-=o}drawFooter(t,n,i){const s=this.footer,o=s.length;let r,a;if(o){const l=Oe(i.rtl,this.x,this.width);for(t.x=Fn(this,i.footerAlign,i),t.y+=i.footerMarginTop,n.textAlign=l.textAlign(i.footerAlign),n.textBaseline="middle",r=lt(i.footerFont),n.fillStyle=i.footerColor,n.font=r.string,a=0;a<o;++a)n.fillText(s[a],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+i.footerSpacing}}drawBackground(t,n,i,s){const{xAlign:o,yAlign:r}=this,{x:a,y:l}=t,{width:c,height:h}=i,{topLeft:d,topRight:g,bottomLeft:p,bottomRight:y}=sn(s.cornerRadius);n.fillStyle=s.backgroundColor,n.strokeStyle=s.borderColor,n.lineWidth=s.borderWidth,n.beginPath(),n.moveTo(a+d,l),r==="top"&&this.drawCaret(t,n,i,s),n.lineTo(a+c-g,l),n.quadraticCurveTo(a+c,l,a+c,l+g),r==="center"&&o==="right"&&this.drawCaret(t,n,i,s),n.lineTo(a+c,l+h-y),n.quadraticCurveTo(a+c,l+h,a+c-y,l+h),r==="bottom"&&this.drawCaret(t,n,i,s),n.lineTo(a+p,l+h),n.quadraticCurveTo(a,l+h,a,l+h-p),r==="center"&&o==="left"&&this.drawCaret(t,n,i,s),n.lineTo(a,l+d),n.quadraticCurveTo(a,l,a+d,l),n.closePath(),n.fill(),s.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Je[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=Bo(this,t),l=Object.assign({},r,this._size),c=Wo(n,t,l),h=Vo(t,l,c,n);(s._to!==h.x||o._to!==h.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,h))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(n);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const r=wt(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,n),Jr(t,n.textDirection),o.y+=r.top,this.drawTitle(o,t,n),this.drawBody(o,t,n),this.drawFooter(o,t,n),ta(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const i=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!$n(i,s),r=this._positionChanged(s,n);(o||r)&&(this._active=s,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,i=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,n,i),a=this._positionChanged(r,t),l=n||!$n(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,n){const{caretX:i,caretY:s,options:o}=this,r=Je[o.position].call(this,t,n);return r!==!1&&(i!==r.x||s!==r.y)}}var qd={id:"tooltip",_element:Yo,positioners:Je,afterInit(e,t,n){n&&(e.tooltip=new Yo({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){const t=e.tooltip;if(t&&t._willRender()){const 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){const 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:ba},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"]};const Gd=(e,t,n,i)=>(typeof t=="string"?(n=e.push(t)-1,i.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Kd(e,t,n,i){const s=e.indexOf(t);if(s===-1)return Gd(e,t,n,i);const o=e.lastIndexOf(t);return s!==o?n:s}const Zd=(e,t)=>e===null?null:bt(Math.round(e),0,t);function $o(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class Qd extends Le{static id="category";static defaults={ticks:{callback:$o}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const i=this.getLabels();for(const{index:s,label:o}of n)i[s]===o&&i.splice(s,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(W(t))return null;const i=this.getLabels();return n=isFinite(n)&&i[n]===t?n:Kd(i,t,L(n,t),this._addedLabels),Zd(n,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(i=0),n||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,n=this.max,i=this.options.offset,s=[];let o=this.getLabels();o=t===0&&n===o.length-1?o:o.slice(t,n+1),this._valueRange=Math.max(o.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let r=t;r<=n;r++)s.push({value:r});return s}getLabelForValue(t){return $o.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Jd(e,t){const n=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:h,maxDigits:d,includeBounds:g}=e,p=o||1,y=h-1,{min:x,max:v}=t,w=!W(r),S=!W(a),O=!W(c),C=(v-x)/(d+1);let k=Gs((v-x)/y/p)*p,D,P,M,A;if(k<1e-14&&!w&&!S)return[{value:x},{value:v}];A=Math.ceil(v/k)-Math.floor(x/k),A>y&&(k=Gs(A*k/y/p)*p),W(l)||(D=Math.pow(10,l),k=Math.ceil(k*D)/D),s==="ticks"?(P=Math.floor(x/k)*k,M=Math.ceil(v/k)*k):(P=x,M=v),w&&S&&o&&Rc((a-r)/o,k/1e3)?(A=Math.round(Math.min((a-r)/k,h)),k=(a-r)/A,P=r,M=a):O?(P=w?r:P,M=S?a:M,A=c-1,k=(M-P)/A):(A=(M-P)/k,pe(A,Math.round(A),k/1e3)?A=Math.round(A):A=Math.ceil(A));const F=Math.max(Ks(k),Ks(P));D=Math.pow(10,W(l)?F:l),P=Math.round(P*D)/D,M=Math.round(M*D)/D;let N=0;for(w&&(g&&P!==r?(n.push({value:r}),P<r&&N++,pe(Math.round((P+N*k)*D)/D,r,Xo(r,C,e))&&N++):P<r&&N++);N<A;++N){const H=Math.round((P+N*k)*D)/D;if(S&&H>a)break;n.push({value:H})}return S&&g&&M!==a?n.length&&pe(n[n.length-1].value,a,Xo(a,C,e))?n[n.length-1].value=a:n.push({value:a}):(!S||M===a)&&n.push({value:M}),n}function Xo(e,t,{horizontal:n,minRotation:i}){const s=de(i),o=(n?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+e).length;return Math.min(t/o,r)}class tf extends Le{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return W(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:i}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=n?s:l,a=l=>o=i?o:l;if(t){const l=Qt(s),c=Qt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:i}=t,s;return i?(s=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,s>1e3&&(console.warn(\`scales.\${this.id}.ticks.stepSize: \${i} would result generating up to \${s} ticks. Limiting to 1000.\`),s=1e3)):(s=this.computeTickLimit(),n=n||11),n&&(s=Math.min(n,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s={maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},o=this._range||this,r=Jd(s,o);return t.bounds==="ticks"&&zc(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let n=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-n)/Math.max(t.length-1,1)/2;n-=s,i+=s}this._startValue=n,this._endValue=i,this._valueRange=i-n}getLabelForValue(t){return Ur(t,this.chart.options.locale,this.options.ticks.format)}}class ef extends tf{static id="linear";static defaults={ticks:{callback:Yr.formatters.numeric}};determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=xt(t)?t:0,this.max=xt(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,i=de(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const si={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}},at=Object.keys(si);function qo(e,t){return e-t}function Go(e,t){if(W(t))return null;const n=e._adapter,{parser:i,round:s,isoWeekday:o}=e._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),xt(r)||(r=typeof i=="string"?n.parse(r,i):n.parse(r)),r===null?null:(s&&(r=s==="week"&&(hn(o)||o===!0)?n.startOf(r,"isoWeek",o):n.startOf(r,s)),+r)}function Ko(e,t,n,i){const s=at.length;for(let o=at.indexOf(e);o<s-1;++o){const r=si[at[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((n-t)/(a*r.size))<=i)return at[o]}return at[s-1]}function nf(e,t,n,i,s){for(let o=at.length-1;o>=at.indexOf(n);o--){const r=at[o];if(si[r].common&&e._adapter.diff(s,i,r)>=t-1)return r}return at[n?at.indexOf(n):0]}function sf(e){for(let t=at.indexOf(e)+1,n=at.length;t<n;++t)if(si[at[t]].common)return at[t]}function Zo(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:i,hi:s}=rs(n,t),o=n[i]>=t?n[i]:n[s];e[o]=!0}}function of(e,t,n,i){const s=e._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,i))l=n[a],l>=0&&(t[l].major=!0);return t}function Qo(e,t,n){const i=[],s={},o=t.length;let r,a;for(r=0;r<o;++r)a=t[r],s[a]=r,i.push({value:a,major:!1});return o===0||!n?i:of(e,i,s,n)}class Jo extends Le{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(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const i=t.time||(t.time={}),s=this._adapter=new pu._date(t.adapters.date);s.init(n),tn(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:Go(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,i=t.time.unit||"day";let{min:s,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function l(c){!r&&!isNaN(c.min)&&(s=Math.min(s,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!r||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),s=xt(s)&&!isNaN(s)?s:+n.startOf(Date.now(),i),o=xt(o)&&!isNaN(o)?o:+n.endOf(Date.now(),i)+1,this.min=Math.min(s,o-1),this.max=Math.max(s+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],i=t[t.length-1]),{min:n,max:i}}buildTicks(){const t=this.options,n=t.time,i=t.ticks,s=i.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const o=this.min,r=this.max,a=jc(s,o,r);return this._unit=n.unit||(i.autoSkip?Ko(n.minUnit,this.min,this.max,this._getLabelCapacity(o)):nf(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!i.major.enabled||this._unit==="year"?void 0:sf(this._unit),this.initOffsets(s),t.reverse&&a.reverse(),Qo(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?n=1-s:n=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;n=bt(n,0,r),i=bt(i,0,r),this._offsets={start:n,end:i,factor:1/(n+1+i)}}_generate(){const t=this._adapter,n=this.min,i=this.max,s=this.options,o=s.time,r=o.unit||Ko(o.minUnit,n,i,this._getLabelCapacity(n)),a=L(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=hn(l)||l===!0,h={};let d=n,g,p;if(c&&(d=+t.startOf(d,"isoWeek",l)),d=+t.startOf(d,c?"day":r),t.diff(i,n,r)>1e5*a)throw new Error(n+" and "+i+" are too far apart with stepSize of "+a+" "+r);const y=s.ticks.source==="data"&&this.getDataTimestamps();for(g=d,p=0;g<i;g=+t.add(g,a,r),p++)Zo(h,g,y);return(g===i||s.bounds==="ticks"||p===1)&&Zo(h,g,y),Object.keys(h).sort(qo).map(x=>+x)}getLabelForValue(t){const n=this._adapter,i=this.options.time;return i.tooltipFormat?n.format(t,i.tooltipFormat):n.format(t,i.displayFormats.datetime)}format(t,n){const s=this.options.time.displayFormats,o=this._unit,r=n||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,n,i,s){const o=this.options,r=o.ticks.callback;if(r)return I(r,[t,n,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,h=l&&a[l],d=c&&a[c],g=i[n],p=c&&d&&g&&g.major;return this._adapter.format(t,s||(p?d:h))}generateTickLabels(t){let n,i,s;for(n=0,i=t.length;n<i;++n)s=t[n],s.label=this._tickFormatFunction(s.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,i=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+i)*n.factor)}getValueForPixel(t){const n=this._offsets,i=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+i*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,i=this.ctx.measureText(t).width,s=de(this.isHorizontal()?n.maxRotation:n.minRotation),o=Math.cos(s),r=Math.sin(s),a=this._resolveTickFontOptions(0).size;return{w:i*o+a*r,h:i*r+a*o}}_getLabelCapacity(t){const n=this.options.time,i=n.displayFormats,s=i[n.unit]||i.millisecond,o=this._tickFormatFunction(t,0,Qo(this,[t],this._majorUnit),s),r=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/r.w:this.height/r.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,i;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(n=0,i=s.length;n<i;++n)t=t.concat(s[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,i;if(t.length)return t;const s=this.getLabels();for(n=0,i=s.length;n<i;++n)t.push(Go(this,s[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return Yc(t.sort(qo))}}function Hn(e,t,n){let i=0,s=e.length-1,o,r,a,l;n?(t>=e[i].pos&&t<=e[s].pos&&({lo:i,hi:s}=fe(e,"pos",t)),{pos:o,time:a}=e[i],{pos:r,time:l}=e[s]):(t>=e[i].time&&t<=e[s].time&&({lo:i,hi:s}=fe(e,"time",t)),{time:o,pos:a}=e[i],{time:r,pos:l}=e[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class cg extends Jo{static id="timeseries";static defaults=Jo.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=Hn(n,this.min),this._tableRange=Hn(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:i}=this,s=[],o=[];let r,a,l,c,h;for(r=0,a=t.length;r<a;++r)c=t[r],c>=n&&c<=i&&s.push(c);if(s.length<2)return[{time:n,pos:0},{time:i,pos:1}];for(r=0,a=s.length;r<a;++r)h=s[r+1],l=s[r-1],c=s[r],Math.round((h+l)/2)!==c&&o.push({time:c,pos:r/(a-1)});return o}_generate(){const t=this.min,n=this.max;let i=super.getDataTimestamps();return(!i.includes(t)||!i.length)&&i.splice(0,0,t),(!i.includes(n)||i.length===1)&&i.push(n),i.sort((s,o)=>s-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),i=this.getLabelTimestamps();return n.length&&i.length?t=this.normalize(n.concat(i)):t=n.length?n:i,t=this._cache.all=t,t}getDecimalForValue(t){return(Hn(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,i=this.getDecimalForPixel(t)/n.factor-n.end;return Hn(this._table,i*this._tableRange+this._minPos,!0)}}function rf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ki={exports:{}};/*! Hammer.JS - v2.0.7 - 2016-04-22
1713
+ * http://hammerjs.github.io/
1714
+ *
1715
+ * Copyright (c) 2016 Jorik Tangelder;
1716
+ * Licensed under the MIT license */var tr;function af(){return tr||(tr=1,function(e){(function(t,n,i,s){var o=["","webkit","Moz","MS","ms","o"],r=n.createElement("div"),a="function",l=Math.round,c=Math.abs,h=Date.now;function d(u,f,b){return setTimeout(O(u,b),f)}function g(u,f,b){return Array.isArray(u)?(p(u,b[f],b),!0):!1}function p(u,f,b){var _;if(u)if(u.forEach)u.forEach(f,b);else if(u.length!==s)for(_=0;_<u.length;)f.call(b,u[_],_,u),_++;else for(_ in u)u.hasOwnProperty(_)&&f.call(b,u[_],_,u)}function y(u,f,b){var _="DEPRECATED METHOD: "+f+\`
1717
+ \`+b+\` AT
1718
+ \`;return function(){var E=new Error("get-stack-trace"),T=E&&E.stack?E.stack.replace(/^[^\\(]+?[\\n$]/gm,"").replace(/^\\s+at\\s+/gm,"").replace(/^Object.<anonymous>\\s*\\(/gm,"{anonymous}()@"):"Unknown Stack Trace",R=t.console&&(t.console.warn||t.console.log);return R&&R.call(t.console,_,T),u.apply(this,arguments)}}var x;typeof Object.assign!="function"?x=function(f){if(f===s||f===null)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(f),_=1;_<arguments.length;_++){var E=arguments[_];if(E!==s&&E!==null)for(var T in E)E.hasOwnProperty(T)&&(b[T]=E[T])}return b}:x=Object.assign;var v=y(function(f,b,_){for(var E=Object.keys(b),T=0;T<E.length;)(!_||_&&f[E[T]]===s)&&(f[E[T]]=b[E[T]]),T++;return f},"extend","Use \`assign\`."),w=y(function(f,b){return v(f,b,!0)},"merge","Use \`assign\`.");function S(u,f,b){var _=f.prototype,E;E=u.prototype=Object.create(_),E.constructor=u,E._super=_,b&&x(E,b)}function O(u,f){return function(){return u.apply(f,arguments)}}function C(u,f){return typeof u==a?u.apply(f&&f[0]||s,f):u}function k(u,f){return u===s?f:u}function D(u,f,b){p(F(f),function(_){u.addEventListener(_,b,!1)})}function P(u,f,b){p(F(f),function(_){u.removeEventListener(_,b,!1)})}function M(u,f){for(;u;){if(u==f)return!0;u=u.parentNode}return!1}function A(u,f){return u.indexOf(f)>-1}function F(u){return u.trim().split(/\\s+/g)}function N(u,f,b){if(u.indexOf&&!b)return u.indexOf(f);for(var _=0;_<u.length;){if(b&&u[_][b]==f||!b&&u[_]===f)return _;_++}return-1}function H(u){return Array.prototype.slice.call(u,0)}function G(u,f,b){for(var _=[],E=[],T=0;T<u.length;){var R=u[T][f];N(E,R)<0&&_.push(u[T]),E[T]=R,T++}return _=_.sort(function(K,it){return K[f]>it[f]}),_}function tt(u,f){for(var b,_,E=f[0].toUpperCase()+f.slice(1),T=0;T<o.length;){if(b=o[T],_=b?b+E:f,_ in u)return _;T++}return s}var V=1;function X(){return V++}function et(u){var f=u.ownerDocument||u;return f.defaultView||f.parentWindow||t}var we=/mobile|tablet|ip(ad|hone|od)|android/i,ee="ontouchstart"in t,Bt=tt(t,"PointerEvent")!==s,Ee=ee&&we.test(navigator.userAgent),dt="touch",ne="pen",yt="mouse",ie="kinect",It=25,nt=1,se=2,$=4,st=8,gn=1,ze=2,Fe=4,He=8,Be=16,Et=ze|Fe,oe=He|Be,xs=Et|oe,ys=["x","y"],pn=["clientX","clientY"];function ft(u,f){var b=this;this.manager=u,this.callback=f,this.element=u.element,this.target=u.options.inputTarget,this.domHandler=function(_){C(u.options.enable,[u])&&b.handler(_)},this.init()}ft.prototype={handler:function(){},init:function(){this.evEl&&D(this.element,this.evEl,this.domHandler),this.evTarget&&D(this.target,this.evTarget,this.domHandler),this.evWin&&D(et(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&P(this.element,this.evEl,this.domHandler),this.evTarget&&P(this.target,this.evTarget,this.domHandler),this.evWin&&P(et(this.element),this.evWin,this.domHandler)}};function Aa(u){var f,b=u.options.inputClass;return b?f=b:Bt?f=ri:Ee?f=xn:ee?f=ai:f=bn,new f(u,Ia)}function Ia(u,f,b){var _=b.pointers.length,E=b.changedPointers.length,T=f&nt&&_-E===0,R=f&($|st)&&_-E===0;b.isFirst=!!T,b.isFinal=!!R,T&&(u.session={}),b.eventType=f,Na(u,b),u.emit("hammer.input",b),u.recognize(b),u.session.prevInput=b}function Na(u,f){var b=u.session,_=f.pointers,E=_.length;b.firstInput||(b.firstInput=vs(f)),E>1&&!b.firstMultiple?b.firstMultiple=vs(f):E===1&&(b.firstMultiple=!1);var T=b.firstInput,R=b.firstMultiple,q=R?R.center:T.center,K=f.center=_s(_);f.timeStamp=h(),f.deltaTime=f.timeStamp-T.timeStamp,f.angle=oi(q,K),f.distance=mn(q,K),La(b,f),f.offsetDirection=Es(f.deltaX,f.deltaY);var it=ws(f.deltaTime,f.deltaX,f.deltaY);f.overallVelocityX=it.x,f.overallVelocityY=it.y,f.overallVelocity=c(it.x)>c(it.y)?it.x:it.y,f.scale=R?Fa(R.pointers,_):1,f.rotation=R?za(R.pointers,_):0,f.maxPointers=b.prevInput?f.pointers.length>b.prevInput.maxPointers?f.pointers.length:b.prevInput.maxPointers:f.pointers.length,Ra(b,f);var kt=u.element;M(f.srcEvent.target,kt)&&(kt=f.srcEvent.target),f.target=kt}function La(u,f){var b=f.center,_=u.offsetDelta||{},E=u.prevDelta||{},T=u.prevInput||{};(f.eventType===nt||T.eventType===$)&&(E=u.prevDelta={x:T.deltaX||0,y:T.deltaY||0},_=u.offsetDelta={x:b.x,y:b.y}),f.deltaX=E.x+(b.x-_.x),f.deltaY=E.y+(b.y-_.y)}function Ra(u,f){var b=u.lastInterval||f,_=f.timeStamp-b.timeStamp,E,T,R,q;if(f.eventType!=st&&(_>It||b.velocity===s)){var K=f.deltaX-b.deltaX,it=f.deltaY-b.deltaY,kt=ws(_,K,it);T=kt.x,R=kt.y,E=c(kt.x)>c(kt.y)?kt.x:kt.y,q=Es(K,it),u.lastInterval=f}else E=b.velocity,T=b.velocityX,R=b.velocityY,q=b.direction;f.velocity=E,f.velocityX=T,f.velocityY=R,f.direction=q}function vs(u){for(var f=[],b=0;b<u.pointers.length;)f[b]={clientX:l(u.pointers[b].clientX),clientY:l(u.pointers[b].clientY)},b++;return{timeStamp:h(),pointers:f,center:_s(f),deltaX:u.deltaX,deltaY:u.deltaY}}function _s(u){var f=u.length;if(f===1)return{x:l(u[0].clientX),y:l(u[0].clientY)};for(var b=0,_=0,E=0;E<f;)b+=u[E].clientX,_+=u[E].clientY,E++;return{x:l(b/f),y:l(_/f)}}function ws(u,f,b){return{x:f/u||0,y:b/u||0}}function Es(u,f){return u===f?gn:c(u)>=c(f)?u<0?ze:Fe:f<0?He:Be}function mn(u,f,b){b||(b=ys);var _=f[b[0]]-u[b[0]],E=f[b[1]]-u[b[1]];return Math.sqrt(_*_+E*E)}function oi(u,f,b){b||(b=ys);var _=f[b[0]]-u[b[0]],E=f[b[1]]-u[b[1]];return Math.atan2(E,_)*180/Math.PI}function za(u,f){return oi(f[1],f[0],pn)+oi(u[1],u[0],pn)}function Fa(u,f){return mn(f[0],f[1],pn)/mn(u[0],u[1],pn)}var Ha={mousedown:nt,mousemove:se,mouseup:$},Ba="mousedown",Wa="mousemove mouseup";function bn(){this.evEl=Ba,this.evWin=Wa,this.pressed=!1,ft.apply(this,arguments)}S(bn,ft,{handler:function(f){var b=Ha[f.type];b&nt&&f.button===0&&(this.pressed=!0),b&se&&f.which!==1&&(b=$),this.pressed&&(b&$&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[f],changedPointers:[f],pointerType:yt,srcEvent:f}))}});var Va={pointerdown:nt,pointermove:se,pointerup:$,pointercancel:st,pointerout:st},ja={2:dt,3:ne,4:yt,5:ie},Ss="pointerdown",ks="pointermove pointerup pointercancel";t.MSPointerEvent&&!t.PointerEvent&&(Ss="MSPointerDown",ks="MSPointerMove MSPointerUp MSPointerCancel");function ri(){this.evEl=Ss,this.evWin=ks,ft.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}S(ri,ft,{handler:function(f){var b=this.store,_=!1,E=f.type.toLowerCase().replace("ms",""),T=Va[E],R=ja[f.pointerType]||f.pointerType,q=R==dt,K=N(b,f.pointerId,"pointerId");T&nt&&(f.button===0||q)?K<0&&(b.push(f),K=b.length-1):T&($|st)&&(_=!0),!(K<0)&&(b[K]=f,this.callback(this.manager,T,{pointers:b,changedPointers:[f],pointerType:R,srcEvent:f}),_&&b.splice(K,1))}});var Ua={touchstart:nt,touchmove:se,touchend:$,touchcancel:st},Ya="touchstart",$a="touchstart touchmove touchend touchcancel";function Ts(){this.evTarget=Ya,this.evWin=$a,this.started=!1,ft.apply(this,arguments)}S(Ts,ft,{handler:function(f){var b=Ua[f.type];if(b===nt&&(this.started=!0),!!this.started){var _=Xa.call(this,f,b);b&($|st)&&_[0].length-_[1].length===0&&(this.started=!1),this.callback(this.manager,b,{pointers:_[0],changedPointers:_[1],pointerType:dt,srcEvent:f})}}});function Xa(u,f){var b=H(u.touches),_=H(u.changedTouches);return f&($|st)&&(b=G(b.concat(_),"identifier")),[b,_]}var qa={touchstart:nt,touchmove:se,touchend:$,touchcancel:st},Ga="touchstart touchmove touchend touchcancel";function xn(){this.evTarget=Ga,this.targetIds={},ft.apply(this,arguments)}S(xn,ft,{handler:function(f){var b=qa[f.type],_=Ka.call(this,f,b);_&&this.callback(this.manager,b,{pointers:_[0],changedPointers:_[1],pointerType:dt,srcEvent:f})}});function Ka(u,f){var b=H(u.touches),_=this.targetIds;if(f&(nt|se)&&b.length===1)return _[b[0].identifier]=!0,[b,b];var E,T,R=H(u.changedTouches),q=[],K=this.target;if(T=b.filter(function(it){return M(it.target,K)}),f===nt)for(E=0;E<T.length;)_[T[E].identifier]=!0,E++;for(E=0;E<R.length;)_[R[E].identifier]&&q.push(R[E]),f&($|st)&&delete _[R[E].identifier],E++;if(q.length)return[G(T.concat(q),"identifier"),q]}var Za=2500,Ms=25;function ai(){ft.apply(this,arguments);var u=O(this.handler,this);this.touch=new xn(this.manager,u),this.mouse=new bn(this.manager,u),this.primaryTouch=null,this.lastTouches=[]}S(ai,ft,{handler:function(f,b,_){var E=_.pointerType==dt,T=_.pointerType==yt;if(!(T&&_.sourceCapabilities&&_.sourceCapabilities.firesTouchEvents)){if(E)Qa.call(this,b,_);else if(T&&Ja.call(this,_))return;this.callback(f,b,_)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function Qa(u,f){u&nt?(this.primaryTouch=f.changedPointers[0].identifier,Os.call(this,f)):u&($|st)&&Os.call(this,f)}function Os(u){var f=u.changedPointers[0];if(f.identifier===this.primaryTouch){var b={x:f.clientX,y:f.clientY};this.lastTouches.push(b);var _=this.lastTouches,E=function(){var T=_.indexOf(b);T>-1&&_.splice(T,1)};setTimeout(E,Za)}}function Ja(u){for(var f=u.srcEvent.clientX,b=u.srcEvent.clientY,_=0;_<this.lastTouches.length;_++){var E=this.lastTouches[_],T=Math.abs(f-E.x),R=Math.abs(b-E.y);if(T<=Ms&&R<=Ms)return!0}return!1}var Cs=tt(r.style,"touchAction"),Ps=Cs!==s,Ds="compute",As="auto",li="manipulation",re="none",We="pan-x",Ve="pan-y",yn=el();function ci(u,f){this.manager=u,this.set(f)}ci.prototype={set:function(u){u==Ds&&(u=this.compute()),Ps&&this.manager.element.style&&yn[u]&&(this.manager.element.style[Cs]=u),this.actions=u.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var u=[];return p(this.manager.recognizers,function(f){C(f.options.enable,[f])&&(u=u.concat(f.getTouchAction()))}),tl(u.join(" "))},preventDefaults:function(u){var f=u.srcEvent,b=u.offsetDirection;if(this.manager.session.prevented){f.preventDefault();return}var _=this.actions,E=A(_,re)&&!yn[re],T=A(_,Ve)&&!yn[Ve],R=A(_,We)&&!yn[We];if(E){var q=u.pointers.length===1,K=u.distance<2,it=u.deltaTime<250;if(q&&K&&it)return}if(!(R&&T)&&(E||T&&b&Et||R&&b&oe))return this.preventSrc(f)},preventSrc:function(u){this.manager.session.prevented=!0,u.preventDefault()}};function tl(u){if(A(u,re))return re;var f=A(u,We),b=A(u,Ve);return f&&b?re:f||b?f?We:Ve:A(u,li)?li:As}function el(){if(!Ps)return!1;var u={},f=t.CSS&&t.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(b){u[b]=f?t.CSS.supports("touch-action",b):!0}),u}var vn=1,gt=2,Se=4,Wt=8,Nt=Wt,je=16,St=32;function Lt(u){this.options=x({},this.defaults,u||{}),this.id=X(),this.manager=null,this.options.enable=k(this.options.enable,!0),this.state=vn,this.simultaneous={},this.requireFail=[]}Lt.prototype={defaults:{},set:function(u){return x(this.options,u),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(u){if(g(u,"recognizeWith",this))return this;var f=this.simultaneous;return u=_n(u,this),f[u.id]||(f[u.id]=u,u.recognizeWith(this)),this},dropRecognizeWith:function(u){return g(u,"dropRecognizeWith",this)?this:(u=_n(u,this),delete this.simultaneous[u.id],this)},requireFailure:function(u){if(g(u,"requireFailure",this))return this;var f=this.requireFail;return u=_n(u,this),N(f,u)===-1&&(f.push(u),u.requireFailure(this)),this},dropRequireFailure:function(u){if(g(u,"dropRequireFailure",this))return this;u=_n(u,this);var f=N(this.requireFail,u);return f>-1&&this.requireFail.splice(f,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(u){return!!this.simultaneous[u.id]},emit:function(u){var f=this,b=this.state;function _(E){f.manager.emit(E,u)}b<Wt&&_(f.options.event+Is(b)),_(f.options.event),u.additionalEvent&&_(u.additionalEvent),b>=Wt&&_(f.options.event+Is(b))},tryEmit:function(u){if(this.canEmit())return this.emit(u);this.state=St},canEmit:function(){for(var u=0;u<this.requireFail.length;){if(!(this.requireFail[u].state&(St|vn)))return!1;u++}return!0},recognize:function(u){var f=x({},u);if(!C(this.options.enable,[this,f])){this.reset(),this.state=St;return}this.state&(Nt|je|St)&&(this.state=vn),this.state=this.process(f),this.state&(gt|Se|Wt|je)&&this.tryEmit(f)},process:function(u){},getTouchAction:function(){},reset:function(){}};function Is(u){return u&je?"cancel":u&Wt?"end":u&Se?"move":u&gt?"start":""}function Ns(u){return u==Be?"down":u==He?"up":u==ze?"left":u==Fe?"right":""}function _n(u,f){var b=f.manager;return b?b.get(u):u}function vt(){Lt.apply(this,arguments)}S(vt,Lt,{defaults:{pointers:1},attrTest:function(u){var f=this.options.pointers;return f===0||u.pointers.length===f},process:function(u){var f=this.state,b=u.eventType,_=f&(gt|Se),E=this.attrTest(u);return _&&(b&st||!E)?f|je:_||E?b&$?f|Wt:f&gt?f|Se:gt:St}});function wn(){vt.apply(this,arguments),this.pX=null,this.pY=null}S(wn,vt,{defaults:{event:"pan",threshold:10,pointers:1,direction:xs},getTouchAction:function(){var u=this.options.direction,f=[];return u&Et&&f.push(Ve),u&oe&&f.push(We),f},directionTest:function(u){var f=this.options,b=!0,_=u.distance,E=u.direction,T=u.deltaX,R=u.deltaY;return E&f.direction||(f.direction&Et?(E=T===0?gn:T<0?ze:Fe,b=T!=this.pX,_=Math.abs(u.deltaX)):(E=R===0?gn:R<0?He:Be,b=R!=this.pY,_=Math.abs(u.deltaY))),u.direction=E,b&&_>f.threshold&&E&f.direction},attrTest:function(u){return vt.prototype.attrTest.call(this,u)&&(this.state&gt||!(this.state&gt)&&this.directionTest(u))},emit:function(u){this.pX=u.deltaX,this.pY=u.deltaY;var f=Ns(u.direction);f&&(u.additionalEvent=this.options.event+f),this._super.emit.call(this,u)}});function hi(){vt.apply(this,arguments)}S(hi,vt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[re]},attrTest:function(u){return this._super.attrTest.call(this,u)&&(Math.abs(u.scale-1)>this.options.threshold||this.state&gt)},emit:function(u){if(u.scale!==1){var f=u.scale<1?"in":"out";u.additionalEvent=this.options.event+f}this._super.emit.call(this,u)}});function ui(){Lt.apply(this,arguments),this._timer=null,this._input=null}S(ui,Lt,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[As]},process:function(u){var f=this.options,b=u.pointers.length===f.pointers,_=u.distance<f.threshold,E=u.deltaTime>f.time;if(this._input=u,!_||!b||u.eventType&($|st)&&!E)this.reset();else if(u.eventType&nt)this.reset(),this._timer=d(function(){this.state=Nt,this.tryEmit()},f.time,this);else if(u.eventType&$)return Nt;return St},reset:function(){clearTimeout(this._timer)},emit:function(u){this.state===Nt&&(u&&u.eventType&$?this.manager.emit(this.options.event+"up",u):(this._input.timeStamp=h(),this.manager.emit(this.options.event,this._input)))}});function di(){vt.apply(this,arguments)}S(di,vt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[re]},attrTest:function(u){return this._super.attrTest.call(this,u)&&(Math.abs(u.rotation)>this.options.threshold||this.state&gt)}});function fi(){vt.apply(this,arguments)}S(fi,vt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:Et|oe,pointers:1},getTouchAction:function(){return wn.prototype.getTouchAction.call(this)},attrTest:function(u){var f=this.options.direction,b;return f&(Et|oe)?b=u.overallVelocity:f&Et?b=u.overallVelocityX:f&oe&&(b=u.overallVelocityY),this._super.attrTest.call(this,u)&&f&u.offsetDirection&&u.distance>this.options.threshold&&u.maxPointers==this.options.pointers&&c(b)>this.options.velocity&&u.eventType&$},emit:function(u){var f=Ns(u.offsetDirection);f&&this.manager.emit(this.options.event+f,u),this.manager.emit(this.options.event,u)}});function En(){Lt.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}S(En,Lt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[li]},process:function(u){var f=this.options,b=u.pointers.length===f.pointers,_=u.distance<f.threshold,E=u.deltaTime<f.time;if(this.reset(),u.eventType&nt&&this.count===0)return this.failTimeout();if(_&&E&&b){if(u.eventType!=$)return this.failTimeout();var T=this.pTime?u.timeStamp-this.pTime<f.interval:!0,R=!this.pCenter||mn(this.pCenter,u.center)<f.posThreshold;this.pTime=u.timeStamp,this.pCenter=u.center,!R||!T?this.count=1:this.count+=1,this._input=u;var q=this.count%f.taps;if(q===0)return this.hasRequireFailures()?(this._timer=d(function(){this.state=Nt,this.tryEmit()},f.interval,this),gt):Nt}return St},failTimeout:function(){return this._timer=d(function(){this.state=St},this.options.interval,this),St},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Nt&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});function Vt(u,f){return f=f||{},f.recognizers=k(f.recognizers,Vt.defaults.preset),new gi(u,f)}Vt.VERSION="2.0.7",Vt.defaults={domEvents:!1,touchAction:Ds,enable:!0,inputTarget:null,inputClass:null,preset:[[di,{enable:!1}],[hi,{enable:!1},["rotate"]],[fi,{direction:Et}],[wn,{direction:Et},["swipe"]],[En],[En,{event:"doubletap",taps:2},["tap"]],[ui]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var nl=1,Ls=2;function gi(u,f){this.options=x({},Vt.defaults,f||{}),this.options.inputTarget=this.options.inputTarget||u,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=u,this.input=Aa(this),this.touchAction=new ci(this,this.options.touchAction),Rs(this,!0),p(this.options.recognizers,function(b){var _=this.add(new b[0](b[1]));b[2]&&_.recognizeWith(b[2]),b[3]&&_.requireFailure(b[3])},this)}gi.prototype={set:function(u){return x(this.options,u),u.touchAction&&this.touchAction.update(),u.inputTarget&&(this.input.destroy(),this.input.target=u.inputTarget,this.input.init()),this},stop:function(u){this.session.stopped=u?Ls:nl},recognize:function(u){var f=this.session;if(!f.stopped){this.touchAction.preventDefaults(u);var b,_=this.recognizers,E=f.curRecognizer;(!E||E&&E.state&Nt)&&(E=f.curRecognizer=null);for(var T=0;T<_.length;)b=_[T],f.stopped!==Ls&&(!E||b==E||b.canRecognizeWith(E))?b.recognize(u):b.reset(),!E&&b.state&(gt|Se|Wt)&&(E=f.curRecognizer=b),T++}},get:function(u){if(u instanceof Lt)return u;for(var f=this.recognizers,b=0;b<f.length;b++)if(f[b].options.event==u)return f[b];return null},add:function(u){if(g(u,"add",this))return this;var f=this.get(u.options.event);return f&&this.remove(f),this.recognizers.push(u),u.manager=this,this.touchAction.update(),u},remove:function(u){if(g(u,"remove",this))return this;if(u=this.get(u),u){var f=this.recognizers,b=N(f,u);b!==-1&&(f.splice(b,1),this.touchAction.update())}return this},on:function(u,f){if(u!==s&&f!==s){var b=this.handlers;return p(F(u),function(_){b[_]=b[_]||[],b[_].push(f)}),this}},off:function(u,f){if(u!==s){var b=this.handlers;return p(F(u),function(_){f?b[_]&&b[_].splice(N(b[_],f),1):delete b[_]}),this}},emit:function(u,f){this.options.domEvents&&il(u,f);var b=this.handlers[u]&&this.handlers[u].slice();if(!(!b||!b.length)){f.type=u,f.preventDefault=function(){f.srcEvent.preventDefault()};for(var _=0;_<b.length;)b[_](f),_++}},destroy:function(){this.element&&Rs(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}};function Rs(u,f){var b=u.element;if(b.style){var _;p(u.options.cssProps,function(E,T){_=tt(b.style,T),f?(u.oldCssProps[_]=b.style[_],b.style[_]=E):b.style[_]=u.oldCssProps[_]||""}),f||(u.oldCssProps={})}}function il(u,f){var b=n.createEvent("Event");b.initEvent(u,!0,!0),b.gesture=f,f.target.dispatchEvent(b)}x(Vt,{INPUT_START:nt,INPUT_MOVE:se,INPUT_END:$,INPUT_CANCEL:st,STATE_POSSIBLE:vn,STATE_BEGAN:gt,STATE_CHANGED:Se,STATE_ENDED:Wt,STATE_RECOGNIZED:Nt,STATE_CANCELLED:je,STATE_FAILED:St,DIRECTION_NONE:gn,DIRECTION_LEFT:ze,DIRECTION_RIGHT:Fe,DIRECTION_UP:He,DIRECTION_DOWN:Be,DIRECTION_HORIZONTAL:Et,DIRECTION_VERTICAL:oe,DIRECTION_ALL:xs,Manager:gi,Input:ft,TouchAction:ci,TouchInput:xn,MouseInput:bn,PointerEventInput:ri,TouchMouseInput:ai,SingleTouchInput:Ts,Recognizer:Lt,AttrRecognizer:vt,Tap:En,Pan:wn,Swipe:fi,Pinch:hi,Rotate:di,Press:ui,on:D,off:P,each:p,merge:w,extend:v,assign:x,inherit:S,bindFn:O,prefixed:tt});var sl=typeof t<"u"?t:typeof self<"u"?self:{};sl.Hammer=Vt,e.exports?e.exports=Vt:t[i]=Vt})(window,document,"Hammer")}(ki)),ki.exports}var lf=af();const on=rf(lf);/*!
1719
+ * chartjs-plugin-zoom v2.2.0
1720
+ * https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
1721
+ * (c) 2016-2024 chartjs-plugin-zoom Contributors
1722
+ * Released under the MIT License
1723
+ */const dn=e=>e&&e.enabled&&e.modifierKey,xa=(e,t)=>e&&t[e+"Key"],ms=(e,t)=>e&&!t[e+"Key"];function Jt(e,t,n){return e===void 0?!0:typeof e=="string"?e.indexOf(t)!==-1:typeof e=="function"?e({chart:n}).indexOf(t)!==-1:!1}function Ti(e,t){return typeof e=="function"&&(e=e({chart:t})),typeof e=="string"?{x:e.indexOf("x")!==-1,y:e.indexOf("y")!==-1}:{x:!1,y:!1}}function cf(e,t){let n;return function(){return clearTimeout(n),n=setTimeout(e,t),t}}function hf({x:e,y:t},n){const i=n.scales,s=Object.keys(i);for(let o=0;o<s.length;o++){const r=i[s[o]];if(t>=r.top&&t<=r.bottom&&e>=r.left&&e<=r.right)return r}return null}function ya(e,t,n){const{mode:i="xy",scaleMode:s,overScaleMode:o}=e||{},r=hf(t,n),a=Ti(i,n),l=Ti(s,n);if(o){const h=Ti(o,n);for(const d of["x","y"])h[d]&&(l[d]=a[d],a[d]=!1)}if(r&&l[r.axis])return[r];const c=[];return z(n.scales,function(h){a[h.axis]&&c.push(h)}),c}const ji=new WeakMap;function j(e){let t=ji.get(e);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},ji.set(e,t)),t}function uf(e){ji.delete(e)}function va(e,t,n,i){const s=Math.max(0,Math.min(1,(e-t)/n||0)),o=1-s;return{min:i*s,max:i*o}}function _a(e,t){const n=e.isHorizontal()?t.x:t.y;return e.getValueForPixel(n)}function wa(e,t,n){const i=e.max-e.min,s=i*(t-1),o=_a(e,n);return va(o,e.min,i,s)}function df(e,t,n){const i=_a(e,n);if(i===void 0)return{min:e.min,max:e.max};const s=Math.log10(e.min),o=Math.log10(e.max),r=Math.log10(i),a=o-s,l=a*(t-1),c=va(r,s,a,l);return{min:Math.pow(10,s+c.min),max:Math.pow(10,o-c.max)}}function ff(e,t){return t&&(t[e.id]||t[e.axis])||{}}function er(e,t,n,i,s){let o=n[i];if(o==="original"){const r=e.originalScaleLimits[t.id][i];o=L(r.options,r.scale)}return L(o,s)}function gf(e,t,n){const i=e.getValueForPixel(t),s=e.getValueForPixel(n);return{min:Math.min(i,s),max:Math.max(i,s)}}function pf(e,{min:t,max:n,minLimit:i,maxLimit:s},o){const r=(e-n+t)/2;t-=r,n+=r;const a=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=e/1e6;return pe(t,a,c)&&(t=a),pe(n,l,c)&&(n=l),t<i?(t=i,n=Math.min(i+e,s)):n>s&&(n=s,t=Math.max(s-e,i)),{min:t,max:n}}function _e(e,{min:t,max:n},i,s=!1){const o=j(e.chart),{options:r}=e,a=ff(e,i),{minRange:l=0}=a,c=er(o,e,a,"min",-1/0),h=er(o,e,a,"max",1/0);if(s==="pan"&&(t<c||n>h))return!0;const d=e.max-e.min,g=s?Math.max(n-t,l):d;if(s&&g===l&&d<=l)return!0;const p=pf(g,{min:t,max:n,minLimit:c,maxLimit:h},o.originalScaleLimits[e.id]);return r.min=p.min,r.max=p.max,o.updatedScaleLimits[e.id]=p,e.parse(p.min)!==e.min||e.parse(p.max)!==e.max}function mf(e,t,n,i){const s=wa(e,t,n),o={min:e.min+s.min,max:e.max-s.max};return _e(e,o,i,!0)}function bf(e,t,n,i){const s=df(e,t,n);return _e(e,s,i,!0)}function xf(e,t,n,i){_e(e,gf(e,t,n),i,!0)}const nr=e=>e===0||isNaN(e)?0:e<0?Math.min(Math.round(e),-1):Math.max(Math.round(e),1);function yf(e){const n=e.getLabels().length-1;e.min>0&&(e.min-=1),e.max<n&&(e.max+=1)}function vf(e,t,n,i){const s=wa(e,t,n);e.min===e.max&&t<1&&yf(e);const o={min:e.min+nr(s.min),max:e.max-nr(s.max)};return _e(e,o,i,!0)}function _f(e){return e.isHorizontal()?e.width:e.height}function wf(e,t,n){const s=e.getLabels().length-1;let{min:o,max:r}=e;const a=Math.max(r-o,1),l=Math.round(_f(e)/Math.max(a,10)),c=Math.round(Math.abs(t/l));let h;return t<-l?(r=Math.min(r+c,s),o=a===1?r:r-a,h=r===s):t>l&&(o=Math.max(0,o-c),r=a===1?o:o+a,h=o===0),_e(e,{min:o,max:r},n)||h}const Ef={second:500,minute:30*1e3,hour:1800*1e3,day:720*60*1e3,week:3.5*24*60*60*1e3,month:360*60*60*1e3,quarter:1440*60*60*1e3,year:4368*60*60*1e3};function Ea(e,t,n,i=!1){const{min:s,max:o,options:r}=e,a=r.time&&r.time.round,l=Ef[a]||0,c=e.getValueForPixel(e.getPixelForValue(s+l)-t),h=e.getValueForPixel(e.getPixelForValue(o+l)-t);return isNaN(c)||isNaN(h)?!0:_e(e,{min:c,max:h},n,i?"pan":!1)}function ir(e,t,n){return Ea(e,t,n,!0)}const Ui={category:vf,default:mf,logarithmic:bf},Yi={default:xf},$i={category:wf,default:Ea,logarithmic:ir,timeseries:ir};function Sf(e,t,n){const{id:i,options:{min:s,max:o}}=e;if(!t[i]||!n[i])return!0;const r=n[i];return r.min!==s||r.max!==o}function sr(e,t){z(e,(n,i)=>{t[i]||delete e[i]})}function Re(e,t){const{scales:n}=e,{originalScaleLimits:i,updatedScaleLimits:s}=t;return z(n,function(o){Sf(o,i,s)&&(i[o.id]={min:{scale:o.min,options:o.options.min},max:{scale:o.max,options:o.options.max}})}),sr(i,n),sr(s,n),i}function or(e,t,n,i){const s=Ui[e.type]||Ui.default;I(s,[e,t,n,i])}function rr(e,t,n,i){const s=Yi[e.type]||Yi.default;I(s,[e,t,n,i])}function kf(e){const t=e.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function bs(e,t,n="none",i="api"){const{x:s=1,y:o=1,focalPoint:r=kf(e)}=typeof t=="number"?{x:t,y:t}:t,a=j(e),{options:{limits:l,zoom:c}}=a;Re(e,a);const h=s!==1,d=o!==1,g=ya(c,r,e);z(g||e.scales,function(p){p.isHorizontal()&&h?or(p,s,r,l):!p.isHorizontal()&&d&&or(p,o,r,l)}),e.update(n),I(c.onZoom,[{chart:e,trigger:i}])}function Sa(e,t,n,i="none",s="api"){const o=j(e),{options:{limits:r,zoom:a}}=o,{mode:l="xy"}=a;Re(e,o);const c=Jt(l,"x",e),h=Jt(l,"y",e);z(e.scales,function(d){d.isHorizontal()&&c?rr(d,t.x,n.x,r):!d.isHorizontal()&&h&&rr(d,t.y,n.y,r)}),e.update(i),I(a.onZoom,[{chart:e,trigger:s}])}function Tf(e,t,n,i="none",s="api"){const o=j(e);Re(e,o);const r=e.scales[t];_e(r,n,void 0,!0),e.update(i),I(o.options.zoom?.onZoom,[{chart:e,trigger:s}])}function Mf(e,t="default"){const n=j(e),i=Re(e,n);z(e.scales,function(s){const o=s.options;i[s.id]?(o.min=i[s.id].min.options,o.max=i[s.id].max.options):(delete o.min,delete o.max),delete n.updatedScaleLimits[s.id]}),e.update(t),I(n.options.zoom.onZoomComplete,[{chart:e}])}function Of(e,t){const n=e.originalScaleLimits[t];if(!n)return;const{min:i,max:s}=n;return L(s.options,s.scale)-L(i.options,i.scale)}function Cf(e){const t=j(e);let n=1,i=1;return z(e.scales,function(s){const o=Of(t,s.id);if(o){const r=Math.round(o/(s.max-s.min)*100)/100;n=Math.min(n,r),i=Math.max(i,r)}}),n<1?n:i}function ar(e,t,n,i){const{panDelta:s}=i,o=s[e.id]||0;Qt(o)===Qt(t)&&(t+=o);const r=$i[e.type]||$i.default;I(r,[e,t,n])?s[e.id]=0:s[e.id]=t}function ka(e,t,n,i="none"){const{x:s=0,y:o=0}=typeof t=="number"?{x:t,y:t}:t,r=j(e),{options:{pan:a,limits:l}}=r,{onPan:c}=a||{};Re(e,r);const h=s!==0,d=o!==0;z(n||e.scales,function(g){g.isHorizontal()&&h?ar(g,s,l,r):!g.isHorizontal()&&d&&ar(g,o,l,r)}),e.update(i),I(c,[{chart:e}])}function Ta(e){const t=j(e);Re(e,t);const n={};for(const i of Object.keys(e.scales)){const{min:s,max:o}=t.originalScaleLimits[i]||{min:{},max:{}};n[i]={min:s.scale,max:o.scale}}return n}function Pf(e){const t=j(e),n={};for(const i of Object.keys(e.scales))n[i]=t.updatedScaleLimits[i];return n}function Df(e){const t=Ta(e);for(const n of Object.keys(e.scales)){const{min:i,max:s}=t[n];if(i!==void 0&&e.scales[n].min!==i||s!==void 0&&e.scales[n].max!==s)return!0}return!1}function lr(e){const t=j(e);return t.panning||t.dragging}const cr=(e,t,n)=>Math.min(n,Math.max(t,e));function rt(e,t){const{handlers:n}=j(e),i=n[t];i&&i.target&&(i.target.removeEventListener(t,i),delete n[t])}function rn(e,t,n,i){const{handlers:s,options:o}=j(e),r=s[n];if(r&&r.target===t)return;rt(e,n),s[n]=l=>i(e,l,o),s[n].target=t;const a=n==="wheel"?!1:void 0;t.addEventListener(n,s[n],{passive:a})}function Af(e,t){const n=j(e);n.dragStart&&(n.dragging=!0,n.dragEnd=t,e.update("none"))}function If(e,t){const n=j(e);!n.dragStart||t.key!=="Escape"||(rt(e,"keydown"),n.dragging=!1,n.dragStart=n.dragEnd=null,e.update("none"))}function Xi(e,t){if(e.target!==t.canvas){const n=t.canvas.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}return Ct(e,t)}function Ma(e,t,n){const{onZoomStart:i,onZoomRejected:s}=n;if(i){const o=Xi(t,e);if(I(i,[{chart:e,event:t,point:o}])===!1)return I(s,[{chart:e,event:t}]),!1}}function Nf(e,t){if(e.legend){const o=Ct(t,e);if(De(o,e.legend))return}const n=j(e),{pan:i,zoom:s={}}=n.options;if(t.button!==0||xa(dn(i),t)||ms(dn(s.drag),t))return I(s.onZoomRejected,[{chart:e,event:t}]);Ma(e,t,s)!==!1&&(n.dragStart=t,rn(e,e.canvas.ownerDocument,"mousemove",Af),rn(e,window.document,"keydown",If))}function Lf({begin:e,end:t},n){let i=t.x-e.x,s=t.y-e.y;const o=Math.abs(i/s);o>n?i=Math.sign(i)*Math.abs(s*n):o<n&&(s=Math.sign(s)*Math.abs(i/n)),t.x=e.x+i,t.y=e.y+s}function hr(e,t,n,{min:i,max:s,prop:o}){e[i]=cr(Math.min(n.begin[o],n.end[o]),t[i],t[s]),e[s]=cr(Math.max(n.begin[o],n.end[o]),t[i],t[s])}function Rf(e,t,n){const i={begin:Xi(t.dragStart,e),end:Xi(t.dragEnd,e)};if(n){const s=e.chartArea.width/e.chartArea.height;Lf(i,s)}return i}function Oa(e,t,n,i){const s=Jt(t,"x",e),o=Jt(t,"y",e),{top:r,left:a,right:l,bottom:c,width:h,height:d}=e.chartArea,g={top:r,left:a,right:l,bottom:c},p=Rf(e,n,i&&s&&o);s&&hr(g,e.chartArea,p,{min:"left",max:"right",prop:"x"}),o&&hr(g,e.chartArea,p,{min:"top",max:"bottom",prop:"y"});const y=g.right-g.left,x=g.bottom-g.top;return{...g,width:y,height:x,zoomX:s&&y?1+(h-y)/h:1,zoomY:o&&x?1+(d-x)/d:1}}function zf(e,t){const n=j(e);if(!n.dragStart)return;rt(e,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:r}}=n.options.zoom,a=Oa(e,i,{dragStart:n.dragStart,dragEnd:t},r),l=Jt(i,"x",e)?a.width:0,c=Jt(i,"y",e)?a.height:0,h=Math.sqrt(l*l+c*c);if(n.dragStart=n.dragEnd=null,h<=o){n.dragging=!1,e.update("none");return}Sa(e,{x:a.left,y:a.top},{x:a.right,y:a.bottom},"zoom","drag"),n.dragging=!1,n.filterNextClick=!0,I(s,[{chart:e}])}function Ff(e,t,n){if(ms(dn(n.wheel),t)){I(n.onZoomRejected,[{chart:e,event:t}]);return}if(Ma(e,t,n)!==!1&&(t.cancelable&&t.preventDefault(),t.deltaY!==void 0))return!0}function Hf(e,t){const{handlers:{onZoomComplete:n},options:{zoom:i}}=j(e);if(!Ff(e,t,i))return;const s=t.target.getBoundingClientRect(),o=i.wheel.speed,r=t.deltaY>=0?2-1/(1-o):1+o,a={x:r,y:r,focalPoint:{x:t.clientX-s.left,y:t.clientY-s.top}};bs(e,a,"zoom","wheel"),I(n,[{chart:e}])}function Bf(e,t,n,i){n&&(j(e).handlers[t]=cf(()=>I(n,[{chart:e}]),i))}function Wf(e,t){const n=e.canvas,{wheel:i,drag:s,onZoomComplete:o}=t.zoom;i.enabled?(rn(e,n,"wheel",Hf),Bf(e,"onZoomComplete",o,250)):rt(e,"wheel"),s.enabled?(rn(e,n,"mousedown",Nf),rn(e,n.ownerDocument,"mouseup",zf)):(rt(e,"mousedown"),rt(e,"mousemove"),rt(e,"mouseup"),rt(e,"keydown"))}function Vf(e){rt(e,"mousedown"),rt(e,"mousemove"),rt(e,"mouseup"),rt(e,"wheel"),rt(e,"click"),rt(e,"keydown")}function jf(e,t){return function(n,i){const{pan:s,zoom:o={}}=t.options;if(!s||!s.enabled)return!1;const r=i&&i.srcEvent;return r&&!t.panning&&i.pointerType==="mouse"&&(ms(dn(s),r)||xa(dn(o.drag),r))?(I(s.onPanRejected,[{chart:e,event:i}]),!1):!0}}function Uf(e,t){const n=Math.abs(e.clientX-t.clientX),i=Math.abs(e.clientY-t.clientY),s=n/i;let o,r;return s>.3&&s<1.7?o=r=!0:n>i?o=!0:r=!0,{x:o,y:r}}function Ca(e,t,n){if(t.scale){const{center:i,pointers:s}=n,o=1/t.scale*n.scale,r=n.target.getBoundingClientRect(),a=Uf(s[0],s[1]),l=t.options.zoom.mode,c={x:a.x&&Jt(l,"x",e)?o:1,y:a.y&&Jt(l,"y",e)?o:1,focalPoint:{x:i.x-r.left,y:i.y-r.top}};bs(e,c,"zoom","pinch"),t.scale=n.scale}}function Yf(e,t,n){if(t.options.zoom.pinch.enabled){const i=Ct(n,e);I(t.options.zoom.onZoomStart,[{chart:e,event:n,point:i}])===!1?(t.scale=null,I(t.options.zoom.onZoomRejected,[{chart:e,event:n}])):t.scale=1}}function $f(e,t,n){t.scale&&(Ca(e,t,n),t.scale=null,I(t.options.zoom.onZoomComplete,[{chart:e}]))}function Pa(e,t,n){const i=t.delta;i&&(t.panning=!0,ka(e,{x:n.deltaX-i.x,y:n.deltaY-i.y},t.panScales),t.delta={x:n.deltaX,y:n.deltaY})}function Xf(e,t,n){const{enabled:i,onPanStart:s,onPanRejected:o}=t.options.pan;if(!i)return;const r=n.target.getBoundingClientRect(),a={x:n.center.x-r.left,y:n.center.y-r.top};if(I(s,[{chart:e,event:n,point:a}])===!1)return I(o,[{chart:e,event:n}]);t.panScales=ya(t.options.pan,a,e),t.delta={x:0,y:0},Pa(e,t,n)}function qf(e,t){t.delta=null,t.panning&&(t.panning=!1,t.filterNextClick=!0,I(t.options.pan.onPanComplete,[{chart:e}]))}const qi=new WeakMap;function ur(e,t){const n=j(e),i=e.canvas,{pan:s,zoom:o}=t,r=new on.Manager(i);o&&o.pinch.enabled&&(r.add(new on.Pinch),r.on("pinchstart",a=>Yf(e,n,a)),r.on("pinch",a=>Ca(e,n,a)),r.on("pinchend",a=>$f(e,n,a))),s&&s.enabled&&(r.add(new on.Pan({threshold:s.threshold,enable:jf(e,n)})),r.on("panstart",a=>Xf(e,n,a)),r.on("panmove",a=>Pa(e,n,a)),r.on("panend",()=>qf(e,n))),qi.set(e,r)}function dr(e){const t=qi.get(e);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),qi.delete(e))}function Gf(e,t){const{pan:n,zoom:i}=e,{pan:s,zoom:o}=t;return i?.zoom?.pinch?.enabled!==o?.zoom?.pinch?.enabled||n?.enabled!==s?.enabled||n?.threshold!==s?.threshold}var Kf="2.2.0";function Bn(e,t,n){const i=n.zoom.drag,{dragStart:s,dragEnd:o}=j(e);if(i.drawTime!==t||!o)return;const{left:r,top:a,width:l,height:c}=Oa(e,n.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),h=e.ctx;h.save(),h.beginPath(),h.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",h.fillRect(r,a,l,c),i.borderWidth>0&&(h.lineWidth=i.borderWidth,h.strokeStyle=i.borderColor||"rgba(225,225,225)",h.strokeRect(r,a,l,c)),h.restore()}var Zf={id:"zoom",version:Kf,defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(e,t,n){const i=j(e);i.options=n,Object.prototype.hasOwnProperty.call(n.zoom,"enabled")&&console.warn("The option \`zoom.enabled\` is no longer supported. Please use \`zoom.wheel.enabled\`, \`zoom.drag.enabled\`, or \`zoom.pinch.enabled\`."),(Object.prototype.hasOwnProperty.call(n.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(n.pan,"overScaleMode"))&&console.warn("The option \`overScaleMode\` is deprecated. Please use \`scaleMode\` instead (and update \`mode\` as desired)."),on&&ur(e,n),e.pan=(s,o,r)=>ka(e,s,o,r),e.zoom=(s,o)=>bs(e,s,o),e.zoomRect=(s,o,r)=>Sa(e,s,o,r),e.zoomScale=(s,o,r)=>Tf(e,s,o,r),e.resetZoom=s=>Mf(e,s),e.getZoomLevel=()=>Cf(e),e.getInitialScaleBounds=()=>Ta(e),e.getZoomedScaleBounds=()=>Pf(e),e.isZoomedOrPanned=()=>Df(e),e.isZoomingOrPanning=()=>lr(e)},beforeEvent(e,{event:t}){if(lr(e))return!1;if(t.type==="click"||t.type==="mouseup"){const n=j(e);if(n.filterNextClick)return n.filterNextClick=!1,!1}},beforeUpdate:function(e,t,n){const i=j(e),s=i.options;i.options=n,Gf(s,n)&&(dr(e),ur(e,n)),Wf(e,n)},beforeDatasetsDraw(e,t,n){Bn(e,"beforeDatasetsDraw",n)},afterDatasetsDraw(e,t,n){Bn(e,"afterDatasetsDraw",n)},beforeDraw(e,t,n){Bn(e,"beforeDraw",n)},afterDraw(e,t,n){Bn(e,"afterDraw",n)},stop:function(e){Vf(e),on&&dr(e),uf(e)},panFunctions:$i,zoomFunctions:Ui,zoomRectFunctions:Yi};function Qf({data:e,...t}){const n=Ce(null),i=Ce(null);return ct(()=>{Wi.register(Zf,ef,gu,Qd,Nd,Id,Bd,qd);const s=i.current,o=n.current=new Wi(s,{type:"line",data:e.peek(),options:{scales:{y:{min:0}},animation:!1,responsive:!0,plugins:{zoom:{pan:{enabled:!0,mode:"x"},zoom:{wheel:{enabled:!0},mode:"x"}},legend:{position:"top"},title:{display:!1}}}}),r=e.subscribe(a=>{o.data=a,o.update()});return()=>{o.destroy(),r()}},[]),m.createElement("canvas",{ref:i,...t})}function Jf(){const e=te();ct(()=>{const n=i=>{an(i)||e()};return U?.on("mount",n),U?.on("unmount",n),()=>{U?.off("mount",n),U?.off("unmount",n)}},[]);const t=U?.profilingContext;return m.createElement("div",{className:"flex flex-col gap-2"},wr(t.appStats).filter(([n])=>!an(n)).map(([n])=>m.createElement(tg,{key:n.id,app:n})))}const fr=100,gr=e=>Object.entries(e).map(([t,{values:n,color:i}])=>({label:t,data:n,fill:!1,borderColor:i,tension:.1}));function tg({app:e}){const t=te(),n=Ce({update:{values:[0],color:"#ad981f"},updateDirtied:{values:[0],color:"#b21f3a"},createNode:{values:[0],color:"#198019"},removeNode:{values:[0],color:"#5F3691"},updateNode:{values:[0],color:"#2f2f9d"},signalAttrUpdate:{values:[0],color:"#28888f"},signalTextUpdate:{values:[0],color:"#9b3b98"}}),i=Q({labels:[(performance.now()/1e3).toFixed(2)],datasets:gr(n.current)}),s=Q(!1),o=U?.profilingContext;return ct(()=>{const r=a=>{a.id===e.id&&t()};return U?.on("update",r),()=>U?.off("update",r)},[]),ct(()=>{const r=[];Object.entries(n.current).forEach(([l,{values:c}])=>{const h=g=>{g.id===e.id&&s.peek()!==!0&&c[c.length-1]++},d=l;o.addEventListener(d,h),r.push(()=>o.removeEventListener(d,h))});const a=setInterval(()=>{if(s.peek()===!0)return;const l=[...i.value.labels];Object.values(n.current).forEach(c=>{c.values.push(0),c.values.length>fr&&c.values.shift()}),l.push((performance.now()/1e3).toFixed(2)),l.length>fr&&l.shift(),i.value={labels:l,datasets:gr(n.current)}},100);return()=>{r.forEach(l=>l()),clearInterval(a)}},[]),m.createElement("div",{className:"flex flex-col gap-2 border border-white border-opacity-10 rounded bg-neutral-400 bg-opacity-5 text-neutral-400 p-2"},m.createElement("div",{className:"grid items-start gap-2",style:"grid-template-columns: 1fr max-content;"},m.createElement("div",{className:"flex flex-col gap-2"},m.createElement("span",null,e.name),m.createElement(Qf,{data:i,className:"w-full max-w-full min-h-20 bg-black bg-opacity-30",onmouseenter:()=>s.value=!0,onmouseleave:()=>s.value=!1})),m.createElement("div",{className:"text-xs grid grid-cols-2 gap-x-4",style:"grid-template-columns: auto auto;"},m.createElement("span",{className:"text-right"},"Mount duration:"),o.mountDuration(e).toFixed(2)," ms",m.createElement("span",{className:"text-right"},"Total updates:"),m.createElement("span",null,o.totalTicks(e).toLocaleString()),m.createElement("span",{className:"text-right"},"Avg. update duration:"),o.averageTickDuration(e).toFixed(2)," ms",m.createElement("span",{className:"text-right"},"Latest update:"),m.createElement("span",null,o.lastTickDuration(e).toFixed(2)," ms"))))}const Ge=ht([]),Da=ht(""),eg=vr(()=>Da.value.toLowerCase().split(" ").filter(e=>e.length>0));function ng(e){return eg.value.every(t=>e.toLowerCase().includes(t))}function ig(){const e=te();ct(()=>{const n=i=>{an(i)||e()};return U?.on("update",n),()=>U?.off("update",n)},[]);const t=U?.globalState[Symbol.for("SWR_GLOBAL")]??new Map;return t.size===0?m.createElement("div",{className:"flex flex-col items-center justify-center h-full text-neutral-400"},m.createElement(Er,null),m.createElement("h2",{className:"text-lg italic"},"No SWR detected")):m.createElement("div",{className:"flex flex-col gap-2 items-start"},m.createElement(Pr,{value:Da,className:"sticky top-0"}),m.createElement("div",{className:"flex flex-col gap-2 w-full"},wr(t).filter(([n])=>ng(n)).map(([n,i])=>m.createElement(sg,{key:n,entry:i}))))}function sg({key:e,entry:t}){const n=Ge.value.includes(e),i=te();ct(()=>{const{resource:o,isValidating:r,isMutating:a}=t,l=[o.subscribe(i),r.subscribe(i),a.subscribe(i)];return()=>l.forEach(c=>c())},[]);const s=Te(()=>{n?Ge.value=Ge.value.filter(o=>o!==e):Ge.value=[...Ge.value,e]},[n]);return m.createElement("div",{className:"flex flex-col"},m.createElement("button",{onclick:s,className:"flex items-center gap-2 justify-between p-2 border border-white border-opacity-10 cursor-pointer"+(n?" bg-white bg-opacity-5 text-neutral-100 rounded-t":" hover:bg-white hover:bg-opacity-10 text-neutral-400 rounded")},e,m.createElement(Kt,{className:"transition-all"+(n?" rotate-90":"")})),n&&m.createElement("div",{className:"flex flex-col gap-2 p-2 border border-white border-opacity-10"},m.createElement(ye,{data:{resource:t.resource.peek(),isMutating:t.isMutating.peek(),isValidating:t.isValidating.peek()},mutable:!1,objectRefAcc:[],keys:[],onChange:()=>{}})))}const og=e=>m.createElement("main",{className:"flex flex-col flex-1 max-h-[calc(100vh-1rem)] overflow-y-auto",style:e.active?{}:{display:"none"}},e.children),Gi={Apps:{Icon:bl,View:Kl},Stores:{Icon:El,View:Jl},SWR:{Icon:_l,View:ig},Profiling:{Icon:vl,View:Jf},Settings:{Icon:xl,View:kl}},ti=ht("Apps");let pr=qt.peek();qt.subscribe(e=>{e!==pr&&e!==null&&(ti.value="Apps"),pr=e});function rg(){return m.createElement(Sl,null,m.createElement("nav",{className:"flex flex-col gap-2 justify-between p-2 bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 rounded"},m.createElement("div",{className:"flex flex-col gap-2"},Object.keys(Gi).map(e=>m.createElement(ag,{key:e,title:e})))),Object.entries(Gi).map(([e,{View:t}])=>m.createElement(og,{key:e,active:ti.value===e},m.createElement(t,null))))}function ag({title:e}){const{Icon:t}=Gi[e];return m.createElement("button",{key:e,onclick:()=>{ti.value=e},className:"flex items-center px-2 py-1 gap-2 rounded border text-xs border-white border-opacity-10"+(ti.value===e?" bg-white bg-opacity-5 text-neutral-100":" hover:bg-white hover:bg-opacity-10 text-neutral-400"),title:e},m.createElement(t,{className:"text-primary"}),m.createElement("span",{className:"hidden sm:inline"},e))}ll(rg,document.getElementById("app")).then(()=>{Pe.send({type:"ready"}),setInterval(()=>{window.opener||window.close()},250)});</script>
1724
+ <style rel="stylesheet" crossorigin>*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.top-0{top:0}.z-10{z-index:10}.z-\\[9999\\]{z-index:9999}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.ml-6{margin-left:1.5rem}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-5{height:1.25rem}.h-full{height:100%}.max-h-\\[calc\\(100vh-1rem\\)\\]{max-height:calc(100vh - 1rem)}.min-h-20{min-height:5rem}.min-h-screen{min-height:100vh}.w-5{width:1.25rem}.w-8{width:2rem}.w-\\[5px\\]{width:5px}.w-full{width:100%}.max-w-full{max-width:100%}.flex-1{flex:1 1 0%}.flex-grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.resize{resize:both}.scroll-m-12{scroll-margin:3rem}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-4{gap:1rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rounded{border-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-\\[\\#fff1\\]{border-color:#fff1}.border-neutral-700{--tw-border-opacity: 1;border-color:rgb(64 64 64 / var(--tw-border-opacity, 1))}.border-neutral-800{--tw-border-opacity: 1;border-color:rgb(38 38 38 / var(--tw-border-opacity, 1))}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.border-opacity-10{--tw-border-opacity: .1}.bg-\\[\\#171616\\]{--tw-bg-opacity: 1;background-color:rgb(23 22 22 / var(--tw-bg-opacity, 1))}.bg-\\[\\#1a1a1a\\]{--tw-bg-opacity: 1;background-color:rgb(26 26 26 / var(--tw-bg-opacity, 1))}.bg-\\[\\#1d1d1d\\]{--tw-bg-opacity: 1;background-color:rgb(29 29 29 / var(--tw-bg-opacity, 1))}.bg-\\[\\#212121\\]{--tw-bg-opacity: 1;background-color:rgb(33 33 33 / var(--tw-bg-opacity, 1))}.bg-\\[\\#ffffff04\\]{background-color:#ffffff04}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-neutral-400{--tw-bg-opacity: 1;background-color:rgb(163 163 163 / var(--tw-bg-opacity, 1))}.bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity, 1))}.bg-neutral-900{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity, 1))}.bg-primary{--tw-bg-opacity: 1;background-color:rgb(220 20 60 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-opacity-30{--tw-bg-opacity: .3}.bg-opacity-5{--tw-bg-opacity: .05}.p-1{padding:.25rem}.p-2{padding:.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.pb-2{padding-bottom:.5rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-6{padding-left:1.5rem}.pl-8{padding-left:2rem}.pr-1{padding-right:.25rem}.text-right{text-align:right}.text-\\[10px\\]{font-size:10px}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.italic{font-style:italic}.text-neutral-100{--tw-text-opacity: 1;color:rgb(245 245 245 / var(--tw-text-opacity, 1))}.text-neutral-300{--tw-text-opacity: 1;color:rgb(212 212 212 / var(--tw-text-opacity, 1))}.text-neutral-400{--tw-text-opacity: 1;color:rgb(163 163 163 / var(--tw-text-opacity, 1))}.text-primary{--tw-text-opacity: 1;color:rgb(220 20 60 / var(--tw-text-opacity, 1))}.accent-red-500{accent-color:#ef4444}.opacity-50{opacity:.5}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{color-scheme:dark}#app{min-width:-moz-fit-content;min-width:fit-content;background-image:linear-gradient(#171616,#0e0e0e);color:#fff;min-height:100vh;width:100%;display:flex;flex-direction:row;padding:.5rem;gap:.5rem}select{background:url("data:image/svg+xml,<svg height='10px' width='10px' viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'><path d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/></svg>") no-repeat;background-position:calc(100% - .75rem) center!important;-moz-appearance:none!important;-webkit-appearance:none!important;appearance:none!important;padding-right:2rem!important}select:not([disabled]){cursor:pointer}.last\\:border-b-0:last-child{border-bottom-width:0px}.hover\\:bg-neutral-700:hover{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity, 1))}.hover\\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.hover\\:bg-opacity-10:hover{--tw-bg-opacity: .1}.hover\\:opacity-100:hover{opacity:1}.focus\\:outline:focus{outline-style:solid}.focus\\:outline-primary:focus{outline-color:#dc143c}@media (min-width: 640px){.sm\\:inline{display:inline}}</style>
1725
+ </head>
1726
+ <body class="w-full min-h-screen">
1727
+ <div id="app"></div>
1728
+ <div id="portal-root"></div>
1729
+ </body>
1730
+ </html>
1731
+ `;
1732
+
1733
+ // ../devtools-host/dist/index.js
1734
+ var dist_default2 = `var __defProp = Object.defineProperty;
1735
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
1736
+
1737
+ // src/index.ts
1738
+ import { mount } from "kiru";
1739
+
1740
+ // src/App.tsx
1741
+ import * as kiru6 from "kiru";
1742
+
1743
+ // src/icon/Flame.tsx
1744
+ import * as kiru2 from "kiru";
1745
+ var Flame = /* @__PURE__ */ __name(() => {
1746
+ return /* @__PURE__ */ kiru2.createElement(
1747
+ "svg",
1748
+ {
1749
+ xmlns: "http://www.w3.org/2000/svg",
1750
+ width: 20,
1751
+ height: 20,
1752
+ viewBox: "0 0 24 24",
1753
+ fill: "none",
1754
+ stroke: "white",
1755
+ strokeWidth: "2",
1756
+ strokeLinecap: "round",
1757
+ strokeLinejoin: "round"
1758
+ },
1759
+ /* @__PURE__ */ kiru2.createElement("path", { d: "M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z" })
1760
+ );
1761
+ }, "Flame");
1762
+
1763
+ // src/hooks/useAnchorPos.ts
1764
+ import { useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useRef, useSignal as useSignal4 } from "kiru";
1765
+
1766
+ // src/utils/constants.ts
1767
+ var PADDING = 16;
1768
+ var LOCAL_KEY = "kiru.devtools.anchorPosition";
1769
+ var DEFAULT_ANCHOR_POS = { x: -PADDING, y: -PADDING };
1770
+
1771
+ // ../lib/dist/globals.js
1772
+ var renderMode = {
1773
+ current: "window" in globalThis ? "dom" : "string"
1774
+ };
1775
+
1776
+ // ../lib/dist/constants.js
1777
+ var $SIGNAL = Symbol.for("kiru.signal");
1778
+ var $CONTEXT = Symbol.for("kiru.context");
1779
+ var $CONTEXT_PROVIDER = Symbol.for("kiru.contextProvider");
1780
+ var $FRAGMENT = Symbol.for("kiru.fragment");
1781
+ var $KIRU_ERROR = Symbol.for("kiru.error");
1782
+ var $HMR_ACCEPT = Symbol.for("kiru.hmrAccept");
1783
+ var $MEMO = Symbol.for("kiru.memo");
1784
+ var $HYDRATION_BOUNDARY = Symbol.for("kiru.hydrationBoundary");
1785
+
1786
+ // ../lib/dist/env.js
1787
+ var NODE_ENV = "development";
1788
+ if (NODE_ENV !== "development" && NODE_ENV !== "production") {
1789
+ throw new Error("NODE_ENV must either be set to development or production.");
1790
+ }
1791
+
1792
+ // ../lib/dist/signals/globals.js
1793
+ var tracking = {
1794
+ stack: new Array(),
1795
+ current: /* @__PURE__ */ __name(function() {
1796
+ return this.stack[this.stack.length - 1];
1797
+ }, "current")
1798
+ };
1799
+
1800
+ // ../lib/dist/error.js
1801
+ var _a;
1802
+ _a = $KIRU_ERROR;
1803
+
1804
+ // ../lib/dist/hooks/utils.js
1805
+ var HookDebugGroupAction;
1806
+ (function(HookDebugGroupAction2) {
1807
+ HookDebugGroupAction2["Start"] = "start";
1808
+ HookDebugGroupAction2["End"] = "end";
1809
+ })(HookDebugGroupAction || (HookDebugGroupAction = {}));
1810
+
1811
+ // ../lib/dist/signals/base.js
1812
+ var _a2;
1813
+ _a2 = $SIGNAL;
1814
+
1815
+ // ../lib/dist/utils.js
1816
+ var noop = Object.freeze(() => {
1817
+ });
1818
+ function isFragment(vNode) {
1819
+ return vNode.type === $FRAGMENT;
1820
+ }
1821
+ __name(isFragment, "isFragment");
1822
+ function vNodeContains(haystack, needle) {
1823
+ if (haystack === needle)
1824
+ return true;
1825
+ let checkSiblings = false;
1826
+ const stack = [haystack];
1827
+ while (stack.length) {
1828
+ const n = stack.pop();
1829
+ if (n === needle)
1830
+ return true;
1831
+ n.child && stack.push(n.child);
1832
+ checkSiblings && n.sibling && stack.push(n.sibling);
1833
+ checkSiblings = true;
1834
+ }
1835
+ return false;
1836
+ }
1837
+ __name(vNodeContains, "vNodeContains");
1838
+
1839
+ // src/utils/index.ts
1840
+ var reinitializeAnchorPos = /* @__PURE__ */ __name((storage, viewPortRef, elementBound) => {
1841
+ if (!viewPortRef.current) return { ...DEFAULT_ANCHOR_POS };
1842
+ const rateInWidthChange = window.innerWidth / storage.width;
1843
+ const rateInHeightChange = window.innerHeight / storage.height;
1844
+ let forceX = null;
1845
+ let forceY = null;
1846
+ if (storage.snapSide === "left") {
1847
+ forceX = (viewPortRef.current.offsetWidth - elementBound.width.value) * -1 + PADDING;
1848
+ } else if (storage.snapSide === "right") {
1849
+ forceX = -PADDING;
1850
+ } else if (storage.snapSide === "bottom") {
1851
+ forceY = -PADDING;
1852
+ } else if (storage.snapSide === "top") {
1853
+ forceY = (window.innerHeight - elementBound.height.value) * -1 + PADDING;
1854
+ }
1855
+ return {
1856
+ x: forceX ?? storage.x * rateInWidthChange,
1857
+ y: forceY ?? storage.y * rateInHeightChange
1858
+ };
1859
+ }, "reinitializeAnchorPos");
1860
+ var getComponentVnodeFromElement = /* @__PURE__ */ __name((domNode) => {
1861
+ if (domNode == null) return null;
1862
+ let parentComponent = null;
1863
+ let parent = domNode?.__kiruNode?.parent;
1864
+ while (parent) {
1865
+ if (typeof parent.type === "function" && !isFragment(parent)) {
1866
+ parentComponent = parent;
1867
+ break;
1868
+ }
1869
+ parent = parent.parent;
1870
+ }
1871
+ return parentComponent;
1872
+ }, "getComponentVnodeFromElement");
1873
+ var getNearestElm = /* @__PURE__ */ __name((vNode, element) => {
1874
+ const elementvNodeTreeUptillComponetVnode = [];
1875
+ const stack = [element.__kiruNode];
1876
+ while (stack.length) {
1877
+ const node2 = stack.pop();
1878
+ if (node2 === vNode) {
1879
+ break;
1880
+ }
1881
+ if (node2?.dom) {
1882
+ elementvNodeTreeUptillComponetVnode.push(node2);
1883
+ }
1884
+ if (node2?.parent) stack.push(node2.parent);
1885
+ }
1886
+ if (elementvNodeTreeUptillComponetVnode.length === 0) return void 0;
1887
+ const dom = elementvNodeTreeUptillComponetVnode[elementvNodeTreeUptillComponetVnode.length - 1].dom;
1888
+ return dom instanceof Element ? dom : void 0;
1889
+ }, "getNearestElm");
1890
+
1891
+ // ../devtools-shared/src/SelectedNodeView.tsx
1892
+ import { useEffect as useEffect2, useRequestUpdate } from "kiru";
1893
+
1894
+ // ../devtools-shared/src/NodeDataSection.tsx
1895
+ import { useCallback, useEffect, useState } from "kiru";
1896
+
1897
+ // ../devtools-shared/src/ValueEditor.tsx
1898
+ import { unwrap as unwrap2, useMemo, useState as useState3 } from "kiru";
1899
+
1900
+ // ../devtools-shared/src/Settings.tsx
1901
+ import { createContext, useContext, useState as useState2 } from "kiru";
1902
+ var defaultSettings = {
1903
+ arrayChunkSize: 10,
1904
+ objectKeysChunkSize: 100
1905
+ };
1906
+ function recursiveObjectValidate(obj, subject) {
1907
+ if (Object.keys(obj).length !== Object.keys(subject).length) {
1908
+ return false;
1909
+ }
1910
+ const keys = /* @__PURE__ */ new Set([...Object.keys(obj), ...Object.keys(subject)]);
1911
+ for (const key in keys) {
1912
+ if (typeof subject[key] !== typeof obj[key]) {
1913
+ return false;
1914
+ }
1915
+ if (typeof obj[key] === "object") {
1916
+ if (!recursiveObjectValidate(obj[key], subject[key])) {
1917
+ return false;
1918
+ }
1919
+ }
1920
+ }
1921
+ return true;
1922
+ }
1923
+ __name(recursiveObjectValidate, "recursiveObjectValidate");
1924
+ var userSettings = { ...defaultSettings };
1925
+ var storageData = localStorage.getItem("kiru.devtools.userSettings");
1926
+ if (storageData) {
1927
+ try {
1928
+ const parsed = JSON.parse(storageData);
1929
+ if (recursiveObjectValidate(defaultSettings, parsed)) {
1930
+ userSettings = parsed;
1931
+ }
1932
+ } catch (error) {
1933
+ console.error("kiru.devtools.userSettings error", error);
1934
+ }
1935
+ }
1936
+ var SettingsContext = createContext({
1937
+ userSettings: null,
1938
+ saveUserSettings: /* @__PURE__ */ __name(() => {
1939
+ }, "saveUserSettings")
1940
+ });
1941
+
1942
+ // ../devtools-shared/src/ValueEditor.tsx
1943
+ var noop2 = Object.freeze(() => {
1944
+ });
1945
+
1946
+ // ../devtools-shared/src/FileLink.tsx
1947
+ import { useMemo as useMemo2 } from "kiru";
1948
+
1949
+ // ../devtools-shared/src/broadcastChannel.ts
1950
+ var BROADCAST_CHANNEL_NAME = "kiru-devtools";
1951
+ if ("window" in globalThis) {
1952
+ window.__devtoolsSelection ?? (window.__devtoolsSelection = null);
1953
+ }
1954
+ var _TypedBroadcastChannel = class _TypedBroadcastChannel extends BroadcastChannel {
1955
+ send(data) {
1956
+ super.postMessage(data);
1957
+ }
1958
+ // @ts-expect-error heck u ts
1959
+ removeEventListener(listener) {
1960
+ return super.removeEventListener("message", listener);
1961
+ }
1962
+ // @ts-expect-error heck u ts
1963
+ addEventListener(listener) {
1964
+ return super.addEventListener("message", listener);
1965
+ }
1966
+ };
1967
+ __name(_TypedBroadcastChannel, "TypedBroadcastChannel");
1968
+ var TypedBroadcastChannel = _TypedBroadcastChannel;
1969
+ var broadcastChannel = new TypedBroadcastChannel(BROADCAST_CHANNEL_NAME);
1970
+
1971
+ // ../devtools-shared/src/SelectedNodeView.tsx
1972
+ var hookGroupSymbol = Symbol.for("devtools.hookGroup");
1973
+
1974
+ // ../devtools-shared/src/hooks/useEventListener.ts
1975
+ import { useEffect as useEffect3 } from "kiru";
1976
+ var useEventListener = /* @__PURE__ */ __name((event, listener, options = {}) => {
1977
+ useEffect3(() => {
1978
+ let pointer = window;
1979
+ const elm = options?.ref?.();
1980
+ if (elm) {
1981
+ pointer = elm;
1982
+ } else if (options.ref) {
1983
+ console.warn("useEventListener ref failed, using window");
1984
+ }
1985
+ pointer.addEventListener(event, listener, options);
1986
+ return () => {
1987
+ pointer.removeEventListener(event, listener, options);
1988
+ };
1989
+ }, [listener]);
1990
+ }, "useEventListener");
1991
+
1992
+ // ../devtools-shared/src/hooks/useMouse.ts
1993
+ import { useSignal } from "kiru";
1994
+ var useMouse = /* @__PURE__ */ __name(() => {
1995
+ const mouse = useSignal({ x: 0, y: 0 });
1996
+ const delta = useSignal({ x: 0, y: 0 });
1997
+ const client = useSignal({ x: 0, y: 0 });
1998
+ useEventListener("mousemove", (event) => {
1999
+ mouse.value = {
2000
+ x: event.x,
2001
+ y: event.y
2002
+ };
2003
+ delta.value = {
2004
+ x: event.movementX,
2005
+ y: event.movementY
2006
+ };
2007
+ client.value = {
2008
+ x: event.clientX,
2009
+ y: event.clientY
2010
+ };
2011
+ });
2012
+ return { mouse, delta, client };
2013
+ }, "useMouse");
2014
+
2015
+ // ../devtools-shared/src/hooks/useElementBounding.ts
2016
+ import { useLayoutEffect, useSignal as useSignal2 } from "kiru";
2017
+
2018
+ // ../devtools-shared/src/hooks/useResizeObserver.ts
2019
+ import {
2020
+ cleanupHook,
2021
+ depsRequireChange,
2022
+ sideEffectsEnabled as sideEffectsEnabled2,
2023
+ useHook as useHook2
2024
+ } from "kiru";
2025
+ var isSupported = "window" in globalThis && "ResizeObserver" in globalThis.window;
2026
+ var useResizeObserver = /* @__PURE__ */ __name((ref, callback, options = void 0) => {
2027
+ if (!sideEffectsEnabled2())
2028
+ return {
2029
+ isSupported,
2030
+ start: /* @__PURE__ */ __name(() => {
2031
+ }, "start"),
2032
+ stop: /* @__PURE__ */ __name(() => {
2033
+ }, "stop")
2034
+ };
2035
+ if (!isSupported) {
2036
+ return {
2037
+ isSupported,
2038
+ start: /* @__PURE__ */ __name(() => {
2039
+ }, "start"),
2040
+ stop: /* @__PURE__ */ __name(() => {
2041
+ }, "stop")
2042
+ };
2043
+ }
2044
+ return useHook2(
2045
+ "useResizeObserver",
2046
+ {
2047
+ resizeObserver: null,
2048
+ deps: [ref.current]
2049
+ },
2050
+ ({ isInit, hook, queueEffect }) => {
2051
+ if (isInit) {
2052
+ hook.resizeObserver = new ResizeObserver(callback);
2053
+ hook.cleanup = () => {
2054
+ hook.resizeObserver?.disconnect?.();
2055
+ hook.resizeObserver = null;
2056
+ };
2057
+ }
2058
+ queueEffect(() => {
2059
+ if (depsRequireChange([ref.current], hook.deps)) {
2060
+ hook.deps = [ref.current];
2061
+ hook.resizeObserver?.disconnect?.();
2062
+ if (ref.current) {
2063
+ hook.resizeObserver?.observe(ref.current, options);
2064
+ }
2065
+ }
2066
+ });
2067
+ return {
2068
+ isSupported,
2069
+ start: /* @__PURE__ */ __name(() => {
2070
+ if (hook.resizeObserver != null) {
2071
+ return;
2072
+ }
2073
+ hook.resizeObserver = new ResizeObserver(callback);
2074
+ if (ref.current) {
2075
+ hook.resizeObserver.observe(ref.current, options);
2076
+ }
2077
+ hook.cleanup = () => {
2078
+ hook.resizeObserver?.disconnect?.();
2079
+ hook.resizeObserver = null;
2080
+ };
2081
+ }, "start"),
2082
+ stop: /* @__PURE__ */ __name(() => {
2083
+ cleanupHook(hook);
2084
+ }, "stop")
2085
+ };
2086
+ }
2087
+ );
2088
+ }, "useResizeObserver");
2089
+
2090
+ // ../devtools-shared/src/hooks/useMutationObserver.ts
2091
+ import {
2092
+ cleanupHook as cleanupHook2,
2093
+ depsRequireChange as depsRequireChange2,
2094
+ sideEffectsEnabled as sideEffectsEnabled3,
2095
+ useHook as useHook3
2096
+ } from "kiru";
2097
+ var isSupported2 = "window" in globalThis && "MutationObserver" in globalThis.window;
2098
+ var useMutationObserver = /* @__PURE__ */ __name((ref, callback, options = void 0) => {
2099
+ if (!sideEffectsEnabled3())
2100
+ return {
2101
+ isSupported: isSupported2,
2102
+ start: /* @__PURE__ */ __name(() => {
2103
+ }, "start"),
2104
+ stop: /* @__PURE__ */ __name(() => {
2105
+ }, "stop")
2106
+ };
2107
+ if (!isSupported2) {
2108
+ return {
2109
+ isSupported: isSupported2,
2110
+ start: /* @__PURE__ */ __name(() => {
2111
+ }, "start"),
2112
+ stop: /* @__PURE__ */ __name(() => {
2113
+ }, "stop")
2114
+ };
2115
+ }
2116
+ return useHook3(
2117
+ "useMutationObserver",
2118
+ {
2119
+ mutationObserver: null,
2120
+ deps: [ref.current]
2121
+ },
2122
+ ({ isInit, hook, queueEffect }) => {
2123
+ if (isInit) {
2124
+ queueEffect(() => {
2125
+ hook.deps = [ref.current];
2126
+ hook.mutationObserver = new MutationObserver(callback);
2127
+ if (ref.current) {
2128
+ hook.mutationObserver.observe(ref.current, options);
2129
+ }
2130
+ });
2131
+ hook.cleanup = () => {
2132
+ hook.mutationObserver?.disconnect?.();
2133
+ hook.mutationObserver = null;
2134
+ };
2135
+ } else if (depsRequireChange2([ref.current], hook.deps)) {
2136
+ hook.deps = [ref.current];
2137
+ hook.mutationObserver?.disconnect?.();
2138
+ if (ref.current) {
2139
+ hook.mutationObserver?.observe(ref.current, options);
2140
+ }
2141
+ }
2142
+ return {
2143
+ isSupported: isSupported2,
2144
+ start: /* @__PURE__ */ __name(() => {
2145
+ if (hook.mutationObserver != null) {
2146
+ return;
2147
+ }
2148
+ hook.mutationObserver = new MutationObserver(callback);
2149
+ if (ref.current) {
2150
+ hook.mutationObserver.observe(ref.current, options);
2151
+ }
2152
+ hook.cleanup = () => {
2153
+ hook.mutationObserver?.disconnect?.();
2154
+ hook.mutationObserver = null;
2155
+ };
2156
+ }, "start"),
2157
+ stop: /* @__PURE__ */ __name(() => {
2158
+ cleanupHook2(hook);
2159
+ }, "stop")
2160
+ };
2161
+ }
2162
+ );
2163
+ }, "useMutationObserver");
2164
+
2165
+ // ../devtools-shared/src/hooks/useElementBounding.ts
2166
+ var useElementBounding = /* @__PURE__ */ __name((ref, options = {
2167
+ windowScroll: true,
2168
+ windowResize: true
2169
+ }) => {
2170
+ const windowScroll = options?.windowScroll ?? true;
2171
+ const windowResize = options?.windowResize ?? true;
2172
+ const immediate = options.immediate ?? true;
2173
+ const width = useSignal2(0);
2174
+ const height = useSignal2(0);
2175
+ const top = useSignal2(0);
2176
+ const right = useSignal2(0);
2177
+ const bottom = useSignal2(0);
2178
+ const left = useSignal2(0);
2179
+ const x = useSignal2(0);
2180
+ const y = useSignal2(0);
2181
+ const update = /* @__PURE__ */ __name(() => {
2182
+ const el = ref.current;
2183
+ if (!el) {
2184
+ width.value = 0;
2185
+ height.value = 0;
2186
+ top.value = 0;
2187
+ right.value = 0;
2188
+ bottom.value = 0;
2189
+ left.value = 0;
2190
+ x.value = 0;
2191
+ y.value = 0;
2192
+ return;
2193
+ }
2194
+ const bounding = el.getBoundingClientRect();
2195
+ width.value = bounding.width;
2196
+ height.value = bounding.height;
2197
+ top.value = bounding.top;
2198
+ right.value = bounding.right;
2199
+ bottom.value = bounding.bottom;
2200
+ left.value = bounding.left;
2201
+ x.value = bounding.x;
2202
+ y.value = bounding.y;
2203
+ }, "update");
2204
+ useResizeObserver(ref, update);
2205
+ useMutationObserver(ref, update, {
2206
+ attributeFilter: ["style", "class"]
2207
+ });
2208
+ useEventListener(
2209
+ "scroll",
2210
+ () => {
2211
+ if (windowScroll) {
2212
+ update();
2213
+ }
2214
+ },
2215
+ { capture: true, passive: true }
2216
+ );
2217
+ useEventListener(
2218
+ "resize",
2219
+ () => {
2220
+ if (windowResize) {
2221
+ update();
2222
+ }
2223
+ },
2224
+ { passive: true }
2225
+ );
2226
+ useLayoutEffect(() => {
2227
+ if (immediate) {
2228
+ update();
2229
+ }
2230
+ }, []);
2231
+ return {
2232
+ width,
2233
+ height,
2234
+ top,
2235
+ right,
2236
+ bottom,
2237
+ left,
2238
+ x,
2239
+ y,
2240
+ update
2241
+ };
2242
+ }, "useElementBounding");
2243
+
2244
+ // ../devtools-shared/src/hooks/useElementByPoint.ts
2245
+ import { useSignal as useSignal3 } from "kiru";
2246
+
2247
+ // ../devtools-shared/src/hooks/useRafFn.ts
2248
+ import { cleanupHook as cleanupHook3, sideEffectsEnabled as sideEffectsEnabled4, useHook as useHook4 } from "kiru";
2249
+ var useRafFn = /* @__PURE__ */ __name((callback, options) => {
2250
+ if (!sideEffectsEnabled4())
2251
+ return {
2252
+ isActive: options?.immediate ?? false,
2253
+ start: /* @__PURE__ */ __name(() => null, "start"),
2254
+ stop: /* @__PURE__ */ __name(() => null, "stop")
2255
+ };
2256
+ const intervalLimit = options?.fpsLimit ? 1e3 / options.fpsLimit : null;
2257
+ return useHook4(
2258
+ "useRafFn",
2259
+ () => ({
2260
+ callback,
2261
+ refId: null,
2262
+ previousFrameTimestamp: 0,
2263
+ isActive: options?.immediate ?? false,
2264
+ rafLoop: /* @__PURE__ */ __name(() => {
2265
+ }, "rafLoop")
2266
+ }),
2267
+ ({ isInit, hook, update }) => {
2268
+ hook.callback = callback;
2269
+ if (isInit) {
2270
+ hook.rafLoop = (timestamp) => {
2271
+ if (hook.isActive === false) return;
2272
+ if (!hook.previousFrameTimestamp)
2273
+ hook.previousFrameTimestamp = timestamp;
2274
+ const delta = timestamp - hook.previousFrameTimestamp;
2275
+ if (intervalLimit && delta < intervalLimit) {
2276
+ hook.refId = window.requestAnimationFrame(hook.rafLoop);
2277
+ return;
2278
+ }
2279
+ hook.previousFrameTimestamp = timestamp;
2280
+ hook.callback({ delta, timestamp });
2281
+ hook.refId = window.requestAnimationFrame(hook.rafLoop);
2282
+ };
2283
+ }
2284
+ if (isInit && options?.immediate) {
2285
+ hook.isActive = true;
2286
+ hook.refId = window.requestAnimationFrame(hook.rafLoop);
2287
+ hook.cleanup = () => {
2288
+ if (hook.refId != null) {
2289
+ window.cancelAnimationFrame(hook.refId);
2290
+ }
2291
+ hook.isActive = false;
2292
+ };
2293
+ update();
2294
+ }
2295
+ return {
2296
+ isActive: hook.isActive,
2297
+ start: /* @__PURE__ */ __name(() => {
2298
+ if (hook.isActive === true) return;
2299
+ hook.isActive = true;
2300
+ hook.refId = window.requestAnimationFrame(hook.rafLoop);
2301
+ hook.cleanup = () => {
2302
+ if (hook.refId != null) {
2303
+ window.cancelAnimationFrame(hook.refId);
2304
+ }
2305
+ hook.isActive = false;
2306
+ };
2307
+ update();
2308
+ }, "start"),
2309
+ stop: /* @__PURE__ */ __name(() => {
2310
+ cleanupHook3(hook);
2311
+ update();
2312
+ }, "stop")
2313
+ };
2314
+ }
2315
+ );
2316
+ }, "useRafFn");
2317
+
2318
+ // ../devtools-shared/src/hooks/useElementByPoint.ts
2319
+ var useElementByPoint = /* @__PURE__ */ __name((options) => {
2320
+ const { x, y, multiple, immediate = true } = options;
2321
+ const element = useSignal3(null);
2322
+ const cb = /* @__PURE__ */ __name(() => {
2323
+ element.value = multiple ? document.elementsFromPoint(x, y) ?? [] : document.elementFromPoint(x, y) ?? null;
2324
+ }, "cb");
2325
+ const controls = useRafFn(cb, { immediate });
2326
+ return {
2327
+ element,
2328
+ ...controls
2329
+ };
2330
+ }, "useElementByPoint");
2331
+
2332
+ // ../devtools-shared/src/hooks/useEffectDeep.ts
2333
+ import { useHook as useHook5, cleanupHook as cleanupHook4, sideEffectsEnabled as sideEffectsEnabled5 } from "kiru";
2334
+ var deepEqual = /* @__PURE__ */ __name((a, b) => {
2335
+ if (a === b) {
2336
+ return true;
2337
+ }
2338
+ if (typeof a != "object" || typeof b != "object" || a == null || b == null) {
2339
+ return false;
2340
+ }
2341
+ const aKeys = Object.keys(a);
2342
+ const bKeys = Object.keys(b);
2343
+ if (aKeys.length != bKeys.length) {
2344
+ return false;
2345
+ }
2346
+ for (let key of aKeys) {
2347
+ if (!bKeys.includes(key) || !deepEqual(a[key], b[key])) {
2348
+ return false;
2349
+ }
2350
+ }
2351
+ return true;
2352
+ }, "deepEqual");
2353
+ var depsRequireChange3 = /* @__PURE__ */ __name((a, b) => {
2354
+ return !deepEqual(a, b);
2355
+ }, "depsRequireChange");
2356
+ var useEffectDeep = /* @__PURE__ */ __name((callback, deps) => {
2357
+ if (!sideEffectsEnabled5()) return;
2358
+ useHook5(
2359
+ "useEffectDeep",
2360
+ { callback, deps },
2361
+ ({ hook, isInit, queueEffect }) => {
2362
+ if (isInit || depsRequireChange3(deps, hook.deps)) {
2363
+ hook.deps = structuredClone(deps);
2364
+ cleanupHook4(hook);
2365
+ queueEffect(() => {
2366
+ const cleanup = callback();
2367
+ if (cleanup && typeof cleanup === "function") {
2368
+ hook.cleanup = cleanup;
2369
+ }
2370
+ });
2371
+ }
2372
+ }
2373
+ );
2374
+ }, "useEffectDeep");
2375
+
2376
+ // src/hooks/useAnchorPos.ts
2377
+ var useAnchorPos = /* @__PURE__ */ __name(() => {
2378
+ const { mouse } = useMouse();
2379
+ const startMouse = useSignal4(null);
2380
+ const anchorRef = useRef(null);
2381
+ const viewPortRef = useRef(null);
2382
+ const elementBound = useElementBounding(anchorRef);
2383
+ const lastDroppedCoord = useSignal4({ x: -PADDING, y: -PADDING });
2384
+ const anchorCoords = useSignal4({ x: -PADDING, y: -PADDING });
2385
+ const viewportSize = useSignal4({
2386
+ width: window.innerWidth,
2387
+ height: window.innerHeight
2388
+ });
2389
+ const snapSide = useSignal4("bottom");
2390
+ const timeoutRef = useRef(null);
2391
+ useLayoutEffect2(() => {
2392
+ const resultString = localStorage.getItem(LOCAL_KEY);
2393
+ if (resultString == null) return;
2394
+ const result = JSON.parse(resultString);
2395
+ viewportSize.value.width = window.innerWidth;
2396
+ viewportSize.value.height = window.innerHeight;
2397
+ snapSide.value = result.snapSide;
2398
+ anchorCoords.value = reinitializeAnchorPos(
2399
+ result,
2400
+ viewPortRef,
2401
+ elementBound
2402
+ );
2403
+ }, [
2404
+ Math.round(elementBound.width.value),
2405
+ Math.round(elementBound.height.value)
2406
+ ]);
2407
+ const distanceCovered = useMemo3(() => {
2408
+ if (startMouse.value === null) return null;
2409
+ const { x, y } = mouse.value;
2410
+ return {
2411
+ x: x - startMouse.value.x,
2412
+ y: y - startMouse.value.y
2413
+ };
2414
+ }, [startMouse.value, mouse.value]);
2415
+ useEventListener(
2416
+ "dragstart",
2417
+ (e) => {
2418
+ e.preventDefault();
2419
+ startMouse.value = { x: e.x, y: e.y };
2420
+ lastDroppedCoord.value = anchorCoords.value;
2421
+ },
2422
+ {
2423
+ ref: /* @__PURE__ */ __name(() => anchorRef.current, "ref")
2424
+ }
2425
+ );
2426
+ useEventListener("mouseup", () => {
2427
+ if (timeoutRef.current) {
2428
+ clearTimeout(timeoutRef.current);
2429
+ timeoutRef.current = null;
2430
+ }
2431
+ if (startMouse.value) {
2432
+ startMouse.value = null;
2433
+ localStorage.setItem(
2434
+ LOCAL_KEY,
2435
+ JSON.stringify({
2436
+ ...anchorCoords.value,
2437
+ ...viewportSize.value,
2438
+ snapSide: snapSide.value
2439
+ })
2440
+ );
2441
+ }
2442
+ });
2443
+ const updateAnchorPos = useCallback2(() => {
2444
+ if (viewPortRef.current == null) return;
2445
+ const viewportWidth = viewPortRef.current.offsetWidth;
2446
+ if (snapSide.value === "right") {
2447
+ const min = Math.min(-PADDING, anchorCoords.value.y);
2448
+ anchorCoords.value = {
2449
+ x: -PADDING,
2450
+ y: Math.max(
2451
+ min,
2452
+ (window.innerHeight - elementBound.height.value) * -1 + PADDING
2453
+ )
2454
+ };
2455
+ } else if (snapSide.value === "left") {
2456
+ const min = Math.min(0, anchorCoords.value.y);
2457
+ anchorCoords.value = {
2458
+ x: (viewportWidth - elementBound.width.value) * -1 + PADDING,
2459
+ y: Math.max(
2460
+ min,
2461
+ (window.innerHeight - elementBound.height.value) * -1 + PADDING
2462
+ )
2463
+ };
2464
+ } else if (snapSide.value === "top") {
2465
+ const min = Math.min(-PADDING, anchorCoords.value.x);
2466
+ anchorCoords.value = {
2467
+ x: Math.max(
2468
+ min,
2469
+ (viewportWidth - elementBound.width.value) * -1 + PADDING
2470
+ ),
2471
+ y: (window.innerHeight - elementBound.height.value) * -1 + PADDING
2472
+ };
2473
+ return;
2474
+ } else {
2475
+ const min = Math.min(-PADDING, anchorCoords.value.x);
2476
+ anchorCoords.value = {
2477
+ x: Math.max(
2478
+ min,
2479
+ (viewportWidth - elementBound.width.value) * -1 + PADDING
2480
+ ),
2481
+ y: -PADDING
2482
+ };
2483
+ }
2484
+ }, []);
2485
+ useEffectDeep(() => {
2486
+ if (distanceCovered === null || !viewPortRef.current) return;
2487
+ const { x, y } = mouse.value;
2488
+ const viewportWidth = viewPortRef.current.offsetWidth;
2489
+ const isInBottomSeg = y >= window.innerHeight - 100;
2490
+ const isInTopSeg = y <= 100;
2491
+ const isInMidSeg = !isInTopSeg && !isInBottomSeg;
2492
+ if (isInMidSeg) {
2493
+ const isRight = x > window.innerWidth / 2;
2494
+ snapSide.value = isRight ? "right" : "left";
2495
+ } else {
2496
+ snapSide.value = isInTopSeg ? "top" : "bottom";
2497
+ }
2498
+ if (snapSide.value === "right") {
2499
+ const min2 = Math.min(
2500
+ -PADDING,
2501
+ lastDroppedCoord.value.y + distanceCovered.y
2502
+ );
2503
+ anchorCoords.value = {
2504
+ x: -PADDING,
2505
+ y: Math.max(
2506
+ min2,
2507
+ (window.innerHeight - elementBound.height.value) * -1 + PADDING
2508
+ )
2509
+ };
2510
+ return;
2511
+ } else if (snapSide.value === "left") {
2512
+ const min2 = Math.min(0, lastDroppedCoord.value.y + distanceCovered.y);
2513
+ anchorCoords.value = {
2514
+ x: (viewportWidth - elementBound.width.value) * -1 + PADDING,
2515
+ y: Math.max(
2516
+ min2,
2517
+ (window.innerHeight - elementBound.height.value) * -1 + PADDING
2518
+ )
2519
+ };
2520
+ return;
2521
+ } else if (snapSide.value === "top") {
2522
+ const min2 = Math.min(
2523
+ -PADDING,
2524
+ lastDroppedCoord.value.x + distanceCovered.x
2525
+ );
2526
+ anchorCoords.value = {
2527
+ x: Math.max(
2528
+ min2,
2529
+ (viewportWidth - elementBound.width.value) * -1 + PADDING
2530
+ ),
2531
+ y: (window.innerHeight - elementBound.height.value) * -1 + PADDING
2532
+ };
2533
+ return;
2534
+ }
2535
+ const min = Math.min(-PADDING, lastDroppedCoord.value.x + distanceCovered.x);
2536
+ anchorCoords.value = {
2537
+ y: -PADDING,
2538
+ x: Math.max(
2539
+ min,
2540
+ (viewportWidth - elementBound.width.value) * -1 + PADDING
2541
+ )
2542
+ };
2543
+ }, [distanceCovered]);
2544
+ const onResize = useCallback2(() => {
2545
+ if (viewPortRef.current === null) return;
2546
+ anchorCoords.value = reinitializeAnchorPos(
2547
+ {
2548
+ width: viewportSize.value.width,
2549
+ height: viewportSize.value.height,
2550
+ x: anchorCoords.value.x,
2551
+ y: anchorCoords.value.y,
2552
+ snapSide: snapSide.value
2553
+ },
2554
+ viewPortRef,
2555
+ elementBound
2556
+ );
2557
+ viewportSize.value.width = window.innerWidth;
2558
+ viewportSize.value.height = window.innerHeight;
2559
+ localStorage.setItem(
2560
+ LOCAL_KEY,
2561
+ JSON.stringify({
2562
+ ...anchorCoords.value,
2563
+ ...viewportSize.value,
2564
+ snapSide: snapSide.value
2565
+ })
2566
+ );
2567
+ }, [
2568
+ Math.round(elementBound.width.value),
2569
+ Math.round(elementBound.height.value)
2570
+ ]);
2571
+ useEventListener("resize", onResize);
2572
+ return {
2573
+ anchorRef,
2574
+ anchorCoords,
2575
+ viewPortRef,
2576
+ startMouse,
2577
+ elementBound,
2578
+ snapSide,
2579
+ updateAnchorPos
2580
+ };
2581
+ }, "useAnchorPos");
2582
+
2583
+ // src/App.tsx
2584
+ import {
2585
+ useSignal as useSignal5,
2586
+ Transition,
2587
+ useEffect as useEffect5,
2588
+ useLayoutEffect as useLayoutEffect3,
2589
+ useRef as useRef3,
2590
+ useAppContext
2591
+ } from "kiru";
2592
+
2593
+ // src/hooks/useDevtools.ts
2594
+ import { useCallback as useCallback3 } from "kiru";
2595
+
2596
+ // src/store.ts
2597
+ import { signal } from "kiru";
2598
+ var toggleElementToVnode = signal(false);
2599
+ if ("window" in globalThis) {
2600
+ broadcastChannel.addEventListener((e) => {
2601
+ if (e.data.type === "set-inspect-enabled") {
2602
+ toggleElementToVnode.value = e.data.value;
2603
+ }
2604
+ });
2605
+ }
2606
+ var popup = signal(null);
2607
+
2608
+ // src/hooks/useDevtools.ts
2609
+ var SIZE_STORAGE_KEY = "kiru-devtools-popup-size";
2610
+ var useDevTools = /* @__PURE__ */ __name(() => {
2611
+ const _popup = popup.value;
2612
+ const handleOpen = useCallback3(() => {
2613
+ return new Promise((res, rej) => {
2614
+ if (_popup) {
2615
+ if (_popup.closed) {
2616
+ popup.value = null;
2617
+ } else {
2618
+ _popup.focus();
2619
+ return res(_popup);
2620
+ }
2621
+ }
2622
+ const savedSize_raw = sessionStorage.getItem(SIZE_STORAGE_KEY);
2623
+ const size = savedSize_raw ? JSON.parse(savedSize_raw) : {
2624
+ width: Math.floor(Math.min(1920, window.screen.width) / 2),
2625
+ height: Math.floor(Math.min(1080, window.screen.height) / 2)
2626
+ };
2627
+ const features = \`popup,width=\${size.width},height=\${size.height};\`;
2628
+ const w = window.open(
2629
+ // @ts-ignore
2630
+ window.__KIRU_DEVTOOLS_PATHNAME__,
2631
+ "_blank",
2632
+ features
2633
+ );
2634
+ if (!w)
2635
+ return console.error("[kiru]: Unable to open devtools window"), rej();
2636
+ const handleReady = /* @__PURE__ */ __name((e) => {
2637
+ if (e.data.type !== "ready") return;
2638
+ broadcastChannel.removeEventListener(handleReady);
2639
+ console.debug("[kiru]: devtools window opened");
2640
+ res(w);
2641
+ popup.value = w;
2642
+ w.onbeforeunload = () => {
2643
+ console.debug("[kiru]: devtools window closed");
2644
+ popup.value = null;
2645
+ };
2646
+ }, "handleReady");
2647
+ broadcastChannel.addEventListener(handleReady);
2648
+ w.onresize = () => {
2649
+ sessionStorage.setItem(
2650
+ SIZE_STORAGE_KEY,
2651
+ JSON.stringify({
2652
+ width: w.innerWidth,
2653
+ height: w.innerHeight
2654
+ })
2655
+ );
2656
+ };
2657
+ });
2658
+ }, [_popup]);
2659
+ return handleOpen;
2660
+ }, "useDevTools");
2661
+
2662
+ // src/components/InspectComponent.tsx
2663
+ import * as kiru3 from "kiru";
2664
+ import { useEffect as useEffect4, useMemo as useMemo4, useRef as useRef2 } from "kiru";
2665
+ var InspectComponent = /* @__PURE__ */ __name(() => {
2666
+ const openDevTools = useDevTools();
2667
+ const { mouse } = useMouse();
2668
+ const controls = useElementByPoint({
2669
+ x: mouse.value.x,
2670
+ y: mouse.value.y,
2671
+ immediate: false
2672
+ });
2673
+ const _el = controls.element.value;
2674
+ const element = toggleElementToVnode.value ? _el : null;
2675
+ const elApp = useMemo4(() => {
2676
+ if (element && window.__kiru) {
2677
+ const app = window.__kiru.apps.find(($app) => {
2678
+ if ($app.rootNode == null || element.__kiruNode == null) return false;
2679
+ return vNodeContains($app.rootNode, element.__kiruNode);
2680
+ });
2681
+ if (app?.rootNode == null) return null;
2682
+ return app;
2683
+ }
2684
+ return null;
2685
+ }, [element]);
2686
+ const vnode = useMemo4(() => {
2687
+ if (element) {
2688
+ return getComponentVnodeFromElement(element);
2689
+ }
2690
+ return null;
2691
+ }, [element]);
2692
+ const boundingRef = useRef2(null);
2693
+ const bounding = useElementBounding(boundingRef);
2694
+ useEffect4(() => {
2695
+ const unsub = toggleElementToVnode.subscribe((toggled) => {
2696
+ controls[toggled ? "start" : "stop"]();
2697
+ });
2698
+ return unsub;
2699
+ }, []);
2700
+ useEffect4(() => {
2701
+ if (vnode && element) {
2702
+ boundingRef.current = getNearestElm(vnode, element) ?? null;
2703
+ } else {
2704
+ boundingRef.current = null;
2705
+ }
2706
+ }, [vnode, element]);
2707
+ useEventListener("click", (e) => {
2708
+ if (toggleElementToVnode.value === true && vnode && elApp) {
2709
+ e.preventDefault();
2710
+ const emitSelectNode = /* @__PURE__ */ __name((w) => {
2711
+ w.__devtoolsSelection = { node: vnode, app: elApp };
2712
+ broadcastChannel.send({ type: "select-node" });
2713
+ broadcastChannel.send({
2714
+ type: "set-inspect-enabled",
2715
+ value: false
2716
+ });
2717
+ toggleElementToVnode.value = false;
2718
+ boundingRef.current = null;
2719
+ w.focus();
2720
+ }, "emitSelectNode");
2721
+ if (!popup.value) {
2722
+ openDevTools().then((w) => emitSelectNode(w));
2723
+ } else {
2724
+ emitSelectNode(popup.value);
2725
+ }
2726
+ }
2727
+ });
2728
+ return vnode && /* @__PURE__ */ kiru3.createElement(
2729
+ "div",
2730
+ {
2731
+ className: "bg-[crimson]/80 fixed grid place-content-center pointer-events-none z-10 top-0 left-0",
2732
+ style: {
2733
+ width: \`\${bounding?.width}px\`,
2734
+ height: \`\${bounding?.height}px\`,
2735
+ transform: \`translate(\${bounding.x}px, \${bounding.y}px)\`
2736
+ }
2737
+ },
2738
+ /* @__PURE__ */ kiru3.createElement("p", null, vnode.type.name)
2739
+ );
2740
+ }, "InspectComponent");
2741
+
2742
+ // src/icon/PageInfo.tsx
2743
+ import * as kiru4 from "kiru";
2744
+ function PageInfo(props) {
2745
+ return /* @__PURE__ */ kiru4.createElement(
2746
+ "svg",
2747
+ {
2748
+ xmlns: "http://www.w3.org/2000/svg",
2749
+ width: 20,
2750
+ height: 20,
2751
+ viewBox: "0 -960 960 960",
2752
+ fill: "currentColor",
2753
+ ...props
2754
+ },
2755
+ /* @__PURE__ */ kiru4.createElement("path", { d: "M710-150q-63 0-106.5-43.5T560-300q0-63 43.5-106.5T710-450q63 0 106.5 43.5T860-300q0 63-43.5 106.5T710-150Zm0-80q29 0 49.5-20.5T780-300q0-29-20.5-49.5T710-370q-29 0-49.5 20.5T640-300q0 29 20.5 49.5T710-230Zm-270-30H200q-17 0-28.5-11.5T160-300q0-17 11.5-28.5T200-340h240q17 0 28.5 11.5T480-300q0 17-11.5 28.5T440-260ZM250-510q-63 0-106.5-43.5T100-660q0-63 43.5-106.5T250-810q63 0 106.5 43.5T400-660q0 63-43.5 106.5T250-510Zm0-80q29 0 49.5-20.5T320-660q0-29-20.5-49.5T250-730q-29 0-49.5 20.5T180-660q0 29 20.5 49.5T250-590Zm510-30H520q-17 0-28.5-11.5T480-660q0-17 11.5-28.5T520-700h240q17 0 28.5 11.5T800-660q0 17-11.5 28.5T760-620Zm-50 320ZM250-660Z" })
2756
+ );
2757
+ }
2758
+ __name(PageInfo, "PageInfo");
2759
+
2760
+ // src/icon/SquareMouse.tsx
2761
+ import * as kiru5 from "kiru";
2762
+ function SquareMouse(props) {
2763
+ return /* @__PURE__ */ kiru5.createElement(
2764
+ "svg",
2765
+ {
2766
+ xmlns: "http://www.w3.org/2000/svg",
2767
+ width: 20,
2768
+ height: 20,
2769
+ viewBox: "0 0 24 24",
2770
+ fill: "none",
2771
+ stroke: "currentColor",
2772
+ strokeWidth: "2",
2773
+ strokeLinecap: "round",
2774
+ strokeLinejoin: "round",
2775
+ className: "lucide lucide-square-mouse-pointer",
2776
+ ...props
2777
+ },
2778
+ /* @__PURE__ */ kiru5.createElement("path", { d: "M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z" }),
2779
+ /* @__PURE__ */ kiru5.createElement("path", { d: "M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6" })
2780
+ );
2781
+ }
2782
+ __name(SquareMouse, "SquareMouse");
2783
+
2784
+ // src/App.tsx
2785
+ var handleToggleInspect = /* @__PURE__ */ __name(() => {
2786
+ toggleElementToVnode.value = !toggleElementToVnode.value;
2787
+ broadcastChannel.send({
2788
+ type: "set-inspect-enabled",
2789
+ value: toggleElementToVnode.value
2790
+ });
2791
+ }, "handleToggleInspect");
2792
+ function useLerpedVec2(value, options) {
2793
+ const { damping } = options;
2794
+ const current = useSignal5(value);
2795
+ const target = useRef3(value);
2796
+ useEffect5(() => {
2797
+ let frameId = null;
2798
+ const callback = /* @__PURE__ */ __name(() => {
2799
+ const dist = Math.sqrt(
2800
+ Math.pow(target.current.x - current.value.x, 2) + Math.pow(target.current.y - current.value.y, 2)
2801
+ );
2802
+ if (dist < 5) {
2803
+ return;
2804
+ }
2805
+ const nextX = current.value.x + (target.current.x - current.value.x) * damping;
2806
+ const nextY = current.value.y + (target.current.y - current.value.y) * damping;
2807
+ current.value = {
2808
+ x: nextX,
2809
+ y: nextY
2810
+ };
2811
+ frameId = window.requestAnimationFrame(callback);
2812
+ }, "callback");
2813
+ frameId = window.requestAnimationFrame(callback);
2814
+ return () => {
2815
+ if (frameId != null) {
2816
+ window.cancelAnimationFrame(frameId);
2817
+ }
2818
+ };
2819
+ }, [value.x, value.y]);
2820
+ return Object.assign(current, {
2821
+ set: /* @__PURE__ */ __name((value2, options2) => {
2822
+ target.current = value2;
2823
+ if (options2?.hard) {
2824
+ current.value = value2;
2825
+ }
2826
+ }, "set")
2827
+ });
2828
+ }
2829
+ __name(useLerpedVec2, "useLerpedVec2");
2830
+ function App() {
2831
+ const appCtx = useAppContext();
2832
+ const toggled = useSignal5(false);
2833
+ const handleOpen = useDevTools();
2834
+ const {
2835
+ anchorCoords,
2836
+ anchorRef,
2837
+ viewPortRef,
2838
+ startMouse,
2839
+ snapSide,
2840
+ updateAnchorPos
2841
+ } = useAnchorPos();
2842
+ const isHorizontalSnap = snapSide.value === "left" || snapSide.value === "right";
2843
+ const isMounted = useRef3(false);
2844
+ const smoothedCoords = useLerpedVec2(anchorCoords.value, {
2845
+ damping: 0.4
2846
+ });
2847
+ useLayoutEffect3(() => {
2848
+ if (isMounted.current === false) {
2849
+ smoothedCoords.set(anchorCoords.value, {
2850
+ hard: true
2851
+ });
2852
+ }
2853
+ isMounted.current = true;
2854
+ }, []);
2855
+ useEffectDeep(() => {
2856
+ smoothedCoords.set(anchorCoords.value);
2857
+ }, [anchorCoords.value]);
2858
+ return /* @__PURE__ */ kiru6.createElement(kiru6.Fragment, null, /* @__PURE__ */ kiru6.createElement(
2859
+ "div",
2860
+ {
2861
+ ref: viewPortRef,
2862
+ className: "w-full h-0 fixed top-0 left-0 z-[-9999] overflow-scroll pointer-events-none"
2863
+ }
2864
+ ), /* @__PURE__ */ kiru6.createElement(
2865
+ "div",
2866
+ {
2867
+ ref: anchorRef,
2868
+ draggable: true,
2869
+ className: \`flex \${isHorizontalSnap ? "flex-col" : ""} \${toggled.value ? "rounded-3xl" : "rounded-full"} p-1 gap-1 items-center will-change-transform bg-crimson\`,
2870
+ style: {
2871
+ transform: \`translate3d(\${Math.round(
2872
+ smoothedCoords.value.x
2873
+ )}px, \${Math.round(smoothedCoords.value.y)}px, 0)\`
2874
+ }
2875
+ },
2876
+ /* @__PURE__ */ kiru6.createElement(
2877
+ Transition,
2878
+ {
2879
+ in: toggled.value,
2880
+ duration: {
2881
+ in: 40,
2882
+ out: 150
2883
+ },
2884
+ element: (state) => {
2885
+ if (state === "exited") return null;
2886
+ const scale = state === "entered" ? "1" : "0.5";
2887
+ const opacity = state === "entered" ? "1" : "0";
2888
+ return /* @__PURE__ */ kiru6.createElement(kiru6.Fragment, null, /* @__PURE__ */ kiru6.createElement(
2889
+ "button",
2890
+ {
2891
+ title: "Open Devtools",
2892
+ onclick: handleOpen,
2893
+ style: { transform: \`scale(\${scale})\`, opacity },
2894
+ className: "transition text-white rounded-full p-1 hover:bg-[#0003]"
2895
+ },
2896
+ /* @__PURE__ */ kiru6.createElement(PageInfo, { width: 16, height: 16 })
2897
+ ), /* @__PURE__ */ kiru6.createElement(
2898
+ "button",
2899
+ {
2900
+ title: "Toggle Component Inspection",
2901
+ onclick: handleToggleInspect,
2902
+ style: { transform: \`scale(\${scale})\`, opacity },
2903
+ className: \`transition text-white rounded-full p-1 hover:bg-[#0003] \${toggleElementToVnode.value ? "bg-[#0003]" : ""}\`
2904
+ },
2905
+ /* @__PURE__ */ kiru6.createElement(SquareMouse, { width: 16, height: 16 })
2906
+ ));
2907
+ }
2908
+ }
2909
+ ),
2910
+ /* @__PURE__ */ kiru6.createElement(
2911
+ "button",
2912
+ {
2913
+ className: "bg-crimson rounded-full p-1" + (startMouse.value ? " pointer-events-none" : ""),
2914
+ onclick: async () => {
2915
+ toggled.value = !toggled.value;
2916
+ appCtx.flushSync();
2917
+ requestAnimationFrame(() => {
2918
+ requestAnimationFrame(() => {
2919
+ updateAnchorPos();
2920
+ });
2921
+ });
2922
+ },
2923
+ tabIndex: -1
2924
+ },
2925
+ /* @__PURE__ */ kiru6.createElement(Flame, null)
2926
+ )
2927
+ ), /* @__PURE__ */ kiru6.createElement(InspectComponent, null));
2928
+ }
2929
+ __name(App, "App");
2930
+
2931
+ // _83eycjl0r:C:\\repos\\kiru\\packages\\devtools-host\\src\\style.css
2932
+ var style_default = "*, ::before, ::after {\\n --tw-border-spacing-x: 0;\\n --tw-border-spacing-y: 0;\\n --tw-translate-x: 0;\\n --tw-translate-y: 0;\\n --tw-rotate: 0;\\n --tw-skew-x: 0;\\n --tw-skew-y: 0;\\n --tw-scale-x: 1;\\n --tw-scale-y: 1;\\n --tw-pan-x: ;\\n --tw-pan-y: ;\\n --tw-pinch-zoom: ;\\n --tw-scroll-snap-strictness: proximity;\\n --tw-gradient-from-position: ;\\n --tw-gradient-via-position: ;\\n --tw-gradient-to-position: ;\\n --tw-ordinal: ;\\n --tw-slashed-zero: ;\\n --tw-numeric-figure: ;\\n --tw-numeric-spacing: ;\\n --tw-numeric-fraction: ;\\n --tw-ring-inset: ;\\n --tw-ring-offset-width: 0px;\\n --tw-ring-offset-color: #fff;\\n --tw-ring-color: rgb(59 130 246 / 0.5);\\n --tw-ring-offset-shadow: 0 0 #0000;\\n --tw-ring-shadow: 0 0 #0000;\\n --tw-shadow: 0 0 #0000;\\n --tw-shadow-colored: 0 0 #0000;\\n --tw-blur: ;\\n --tw-brightness: ;\\n --tw-contrast: ;\\n --tw-grayscale: ;\\n --tw-hue-rotate: ;\\n --tw-invert: ;\\n --tw-saturate: ;\\n --tw-sepia: ;\\n --tw-drop-shadow: ;\\n --tw-backdrop-blur: ;\\n --tw-backdrop-brightness: ;\\n --tw-backdrop-contrast: ;\\n --tw-backdrop-grayscale: ;\\n --tw-backdrop-hue-rotate: ;\\n --tw-backdrop-invert: ;\\n --tw-backdrop-opacity: ;\\n --tw-backdrop-saturate: ;\\n --tw-backdrop-sepia: ;\\n --tw-contain-size: ;\\n --tw-contain-layout: ;\\n --tw-contain-paint: ;\\n --tw-contain-style: ;\\n}\\n\\n::backdrop {\\n --tw-border-spacing-x: 0;\\n --tw-border-spacing-y: 0;\\n --tw-translate-x: 0;\\n --tw-translate-y: 0;\\n --tw-rotate: 0;\\n --tw-skew-x: 0;\\n --tw-skew-y: 0;\\n --tw-scale-x: 1;\\n --tw-scale-y: 1;\\n --tw-pan-x: ;\\n --tw-pan-y: ;\\n --tw-pinch-zoom: ;\\n --tw-scroll-snap-strictness: proximity;\\n --tw-gradient-from-position: ;\\n --tw-gradient-via-position: ;\\n --tw-gradient-to-position: ;\\n --tw-ordinal: ;\\n --tw-slashed-zero: ;\\n --tw-numeric-figure: ;\\n --tw-numeric-spacing: ;\\n --tw-numeric-fraction: ;\\n --tw-ring-inset: ;\\n --tw-ring-offset-width: 0px;\\n --tw-ring-offset-color: #fff;\\n --tw-ring-color: rgb(59 130 246 / 0.5);\\n --tw-ring-offset-shadow: 0 0 #0000;\\n --tw-ring-shadow: 0 0 #0000;\\n --tw-shadow: 0 0 #0000;\\n --tw-shadow-colored: 0 0 #0000;\\n --tw-blur: ;\\n --tw-brightness: ;\\n --tw-contrast: ;\\n --tw-grayscale: ;\\n --tw-hue-rotate: ;\\n --tw-invert: ;\\n --tw-saturate: ;\\n --tw-sepia: ;\\n --tw-drop-shadow: ;\\n --tw-backdrop-blur: ;\\n --tw-backdrop-brightness: ;\\n --tw-backdrop-contrast: ;\\n --tw-backdrop-grayscale: ;\\n --tw-backdrop-hue-rotate: ;\\n --tw-backdrop-invert: ;\\n --tw-backdrop-opacity: ;\\n --tw-backdrop-saturate: ;\\n --tw-backdrop-sepia: ;\\n --tw-contain-size: ;\\n --tw-contain-layout: ;\\n --tw-contain-paint: ;\\n --tw-contain-style: ;\\n}/*\\n! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com\\n*//*\\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\\n*/\\n\\n*,\\n::before,\\n::after {\\n box-sizing: border-box; /* 1 */\\n border-width: 0; /* 2 */\\n border-style: solid; /* 2 */\\n border-color: #e5e7eb; /* 2 */\\n}\\n\\n::before,\\n::after {\\n --tw-content: '';\\n}\\n\\n/*\\n1. Use a consistent sensible line-height in all browsers.\\n2. Prevent adjustments of font size after orientation changes in iOS.\\n3. Use a more readable tab size.\\n4. Use the user's configured \`sans\` font-family by default.\\n5. Use the user's configured \`sans\` font-feature-settings by default.\\n6. Use the user's configured \`sans\` font-variation-settings by default.\\n7. Disable tap highlights on iOS\\n*/\\n\\nhtml,\\n:host {\\n line-height: 1.5; /* 1 */\\n -webkit-text-size-adjust: 100%; /* 2 */\\n -moz-tab-size: 4; /* 3 */\\n -o-tab-size: 4;\\n tab-size: 4; /* 3 */\\n font-family: ui-sans-serif, system-ui, sans-serif, \\"Apple Color Emoji\\", \\"Segoe UI Emoji\\", \\"Segoe UI Symbol\\", \\"Noto Color Emoji\\"; /* 4 */\\n font-feature-settings: normal; /* 5 */\\n font-variation-settings: normal; /* 6 */\\n -webkit-tap-highlight-color: transparent; /* 7 */\\n}\\n\\n/*\\n1. Remove the margin in all browsers.\\n2. Inherit line-height from \`html\` so users can set them as a class directly on the \`html\` element.\\n*/\\n\\nbody {\\n margin: 0; /* 1 */\\n line-height: inherit; /* 2 */\\n}\\n\\n/*\\n1. Add the correct height in Firefox.\\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\\n3. Ensure horizontal rules are visible by default.\\n*/\\n\\nhr {\\n height: 0; /* 1 */\\n color: inherit; /* 2 */\\n border-top-width: 1px; /* 3 */\\n}\\n\\n/*\\nAdd the correct text decoration in Chrome, Edge, and Safari.\\n*/\\n\\nabbr:where([title]) {\\n -webkit-text-decoration: underline dotted;\\n text-decoration: underline dotted;\\n}\\n\\n/*\\nRemove the default font size and weight for headings.\\n*/\\n\\nh1,\\nh2,\\nh3,\\nh4,\\nh5,\\nh6 {\\n font-size: inherit;\\n font-weight: inherit;\\n}\\n\\n/*\\nReset links to optimize for opt-in styling instead of opt-out.\\n*/\\n\\na {\\n color: inherit;\\n text-decoration: inherit;\\n}\\n\\n/*\\nAdd the correct font weight in Edge and Safari.\\n*/\\n\\nb,\\nstrong {\\n font-weight: bolder;\\n}\\n\\n/*\\n1. Use the user's configured \`mono\` font-family by default.\\n2. Use the user's configured \`mono\` font-feature-settings by default.\\n3. Use the user's configured \`mono\` font-variation-settings by default.\\n4. Correct the odd \`em\` font sizing in all browsers.\\n*/\\n\\ncode,\\nkbd,\\nsamp,\\npre {\\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \\"Liberation Mono\\", \\"Courier New\\", monospace; /* 1 */\\n font-feature-settings: normal; /* 2 */\\n font-variation-settings: normal; /* 3 */\\n font-size: 1em; /* 4 */\\n}\\n\\n/*\\nAdd the correct font size in all browsers.\\n*/\\n\\nsmall {\\n font-size: 80%;\\n}\\n\\n/*\\nPrevent \`sub\` and \`sup\` elements from affecting the line height in all browsers.\\n*/\\n\\nsub,\\nsup {\\n font-size: 75%;\\n line-height: 0;\\n position: relative;\\n vertical-align: baseline;\\n}\\n\\nsub {\\n bottom: -0.25em;\\n}\\n\\nsup {\\n top: -0.5em;\\n}\\n\\n/*\\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\\n3. Remove gaps between table borders by default.\\n*/\\n\\ntable {\\n text-indent: 0; /* 1 */\\n border-color: inherit; /* 2 */\\n border-collapse: collapse; /* 3 */\\n}\\n\\n/*\\n1. Change the font styles in all browsers.\\n2. Remove the margin in Firefox and Safari.\\n3. Remove default padding in all browsers.\\n*/\\n\\nbutton,\\ninput,\\noptgroup,\\nselect,\\ntextarea {\\n font-family: inherit; /* 1 */\\n font-feature-settings: inherit; /* 1 */\\n font-variation-settings: inherit; /* 1 */\\n font-size: 100%; /* 1 */\\n font-weight: inherit; /* 1 */\\n line-height: inherit; /* 1 */\\n letter-spacing: inherit; /* 1 */\\n color: inherit; /* 1 */\\n margin: 0; /* 2 */\\n padding: 0; /* 3 */\\n}\\n\\n/*\\nRemove the inheritance of text transform in Edge and Firefox.\\n*/\\n\\nbutton,\\nselect {\\n text-transform: none;\\n}\\n\\n/*\\n1. Correct the inability to style clickable types in iOS and Safari.\\n2. Remove default button styles.\\n*/\\n\\nbutton,\\ninput:where([type='button']),\\ninput:where([type='reset']),\\ninput:where([type='submit']) {\\n -webkit-appearance: button; /* 1 */\\n background-color: transparent; /* 2 */\\n background-image: none; /* 2 */\\n}\\n\\n/*\\nUse the modern Firefox focus style for all focusable elements.\\n*/\\n\\n:-moz-focusring {\\n outline: auto;\\n}\\n\\n/*\\nRemove the additional \`:invalid\` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\\n*/\\n\\n:-moz-ui-invalid {\\n box-shadow: none;\\n}\\n\\n/*\\nAdd the correct vertical alignment in Chrome and Firefox.\\n*/\\n\\nprogress {\\n vertical-align: baseline;\\n}\\n\\n/*\\nCorrect the cursor style of increment and decrement buttons in Safari.\\n*/\\n\\n::-webkit-inner-spin-button,\\n::-webkit-outer-spin-button {\\n height: auto;\\n}\\n\\n/*\\n1. Correct the odd appearance in Chrome and Safari.\\n2. Correct the outline style in Safari.\\n*/\\n\\n[type='search'] {\\n -webkit-appearance: textfield; /* 1 */\\n outline-offset: -2px; /* 2 */\\n}\\n\\n/*\\nRemove the inner padding in Chrome and Safari on macOS.\\n*/\\n\\n::-webkit-search-decoration {\\n -webkit-appearance: none;\\n}\\n\\n/*\\n1. Correct the inability to style clickable types in iOS and Safari.\\n2. Change font properties to \`inherit\` in Safari.\\n*/\\n\\n::-webkit-file-upload-button {\\n -webkit-appearance: button; /* 1 */\\n font: inherit; /* 2 */\\n}\\n\\n/*\\nAdd the correct display in Chrome and Safari.\\n*/\\n\\nsummary {\\n display: list-item;\\n}\\n\\n/*\\nRemoves the default spacing and border for appropriate elements.\\n*/\\n\\nblockquote,\\ndl,\\ndd,\\nh1,\\nh2,\\nh3,\\nh4,\\nh5,\\nh6,\\nhr,\\nfigure,\\np,\\npre {\\n margin: 0;\\n}\\n\\nfieldset {\\n margin: 0;\\n padding: 0;\\n}\\n\\nlegend {\\n padding: 0;\\n}\\n\\nol,\\nul,\\nmenu {\\n list-style: none;\\n margin: 0;\\n padding: 0;\\n}\\n\\n/*\\nReset default styling for dialogs.\\n*/\\ndialog {\\n padding: 0;\\n}\\n\\n/*\\nPrevent resizing textareas horizontally by default.\\n*/\\n\\ntextarea {\\n resize: vertical;\\n}\\n\\n/*\\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\\n2. Set the default placeholder color to the user's configured gray 400 color.\\n*/\\n\\ninput::-moz-placeholder, textarea::-moz-placeholder {\\n opacity: 1; /* 1 */\\n color: #9ca3af; /* 2 */\\n}\\n\\ninput::placeholder,\\ntextarea::placeholder {\\n opacity: 1; /* 1 */\\n color: #9ca3af; /* 2 */\\n}\\n\\n/*\\nSet the default cursor for buttons.\\n*/\\n\\nbutton,\\n[role=\\"button\\"] {\\n cursor: pointer;\\n}\\n\\n/*\\nMake sure disabled buttons don't get the pointer cursor.\\n*/\\n:disabled {\\n cursor: default;\\n}\\n\\n/*\\n1. Make replaced elements \`display: block\` by default. (https://github.com/mozdevs/cssremedy/issues/14)\\n2. Add \`vertical-align: middle\` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\\n This can trigger a poorly considered lint error in some tools but is included by design.\\n*/\\n\\nimg,\\nsvg,\\nvideo,\\ncanvas,\\naudio,\\niframe,\\nembed,\\nobject {\\n display: block; /* 1 */\\n vertical-align: middle; /* 2 */\\n}\\n\\n/*\\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\\n*/\\n\\nimg,\\nvideo {\\n max-width: 100%;\\n height: auto;\\n}\\n\\n/* Make elements with the HTML hidden attribute stay hidden by default */\\n[hidden]:where(:not([hidden=\\"until-found\\"])) {\\n display: none;\\n}\\n.pointer-events-none {\\n pointer-events: none;\\n}\\n.fixed {\\n position: fixed;\\n}\\n.sticky {\\n position: sticky;\\n}\\n.bottom-0 {\\n bottom: 0px;\\n}\\n.left-0 {\\n left: 0px;\\n}\\n.right-0 {\\n right: 0px;\\n}\\n.top-0 {\\n top: 0px;\\n}\\n.z-10 {\\n z-index: 10;\\n}\\n.z-\\\\[-9999\\\\] {\\n z-index: -9999;\\n}\\n.z-\\\\[9999999\\\\] {\\n z-index: 9999999;\\n}\\n.mb-2 {\\n margin-bottom: 0.5rem;\\n}\\n.inline {\\n display: inline;\\n}\\n.flex {\\n display: flex;\\n}\\n.grid {\\n display: grid;\\n}\\n.contents {\\n display: contents;\\n}\\n.h-0 {\\n height: 0px;\\n}\\n.h-5 {\\n height: 1.25rem;\\n}\\n.w-5 {\\n width: 1.25rem;\\n}\\n.w-full {\\n width: 100%;\\n}\\n.flex-grow {\\n flex-grow: 1;\\n}\\n.rotate-90 {\\n --tw-rotate: 90deg;\\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\\n}\\n.transform {\\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\\n}\\n.cursor-default {\\n cursor: default;\\n}\\n.cursor-pointer {\\n cursor: pointer;\\n}\\n.resize {\\n resize: both;\\n}\\n.flex-col {\\n flex-direction: column;\\n}\\n.place-content-center {\\n place-content: center;\\n}\\n.items-start {\\n align-items: flex-start;\\n}\\n.items-center {\\n align-items: center;\\n}\\n.justify-between {\\n justify-content: space-between;\\n}\\n.gap-1 {\\n gap: 0.25rem;\\n}\\n.gap-2 {\\n gap: 0.5rem;\\n}\\n.overflow-hidden {\\n overflow: hidden;\\n}\\n.overflow-scroll {\\n overflow: scroll;\\n}\\n.truncate {\\n overflow: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n}\\n.rounded {\\n border-radius: 0.25rem;\\n}\\n.rounded-3xl {\\n border-radius: 1.5rem;\\n}\\n.rounded-full {\\n border-radius: 9999px;\\n}\\n.border {\\n border-width: 1px;\\n}\\n.border-b {\\n border-bottom-width: 1px;\\n}\\n.border-b-2 {\\n border-bottom-width: 2px;\\n}\\n.border-\\\\[\\\\#fff1\\\\] {\\n border-color: #fff1;\\n}\\n.border-neutral-700 {\\n --tw-border-opacity: 1;\\n border-color: rgb(64 64 64 / var(--tw-border-opacity, 1));\\n}\\n.border-neutral-800 {\\n --tw-border-opacity: 1;\\n border-color: rgb(38 38 38 / var(--tw-border-opacity, 1));\\n}\\n.border-white {\\n --tw-border-opacity: 1;\\n border-color: rgb(255 255 255 / var(--tw-border-opacity, 1));\\n}\\n.border-opacity-10 {\\n --tw-border-opacity: 0.1;\\n}\\n.bg-\\\\[\\\\#0003\\\\] {\\n background-color: #0003;\\n}\\n.bg-\\\\[\\\\#1d1d1d\\\\] {\\n --tw-bg-opacity: 1;\\n background-color: rgb(29 29 29 / var(--tw-bg-opacity, 1));\\n}\\n.bg-\\\\[\\\\#212121\\\\] {\\n --tw-bg-opacity: 1;\\n background-color: rgb(33 33 33 / var(--tw-bg-opacity, 1));\\n}\\n.bg-\\\\[\\\\#ffffff04\\\\] {\\n background-color: #ffffff04;\\n}\\n.bg-\\\\[crimson\\\\]\\\\/80 {\\n background-color: rgb(220 20 60 / 0.8);\\n}\\n.bg-crimson {\\n --tw-bg-opacity: 1;\\n background-color: rgb(220 20 60 / var(--tw-bg-opacity, 1));\\n}\\n.bg-neutral-400 {\\n --tw-bg-opacity: 1;\\n background-color: rgb(163 163 163 / var(--tw-bg-opacity, 1));\\n}\\n.bg-opacity-5 {\\n --tw-bg-opacity: 0.05;\\n}\\n.p-1 {\\n padding: 0.25rem;\\n}\\n.p-2 {\\n padding: 0.5rem;\\n}\\n.px-2 {\\n padding-left: 0.5rem;\\n padding-right: 0.5rem;\\n}\\n.py-1 {\\n padding-top: 0.25rem;\\n padding-bottom: 0.25rem;\\n}\\n.pb-2 {\\n padding-bottom: 0.5rem;\\n}\\n.pl-2 {\\n padding-left: 0.5rem;\\n}\\n.pl-6 {\\n padding-left: 1.5rem;\\n}\\n.pr-1 {\\n padding-right: 0.25rem;\\n}\\n.text-\\\\[10px\\\\] {\\n font-size: 10px;\\n}\\n.text-sm {\\n font-size: 0.875rem;\\n line-height: 1.25rem;\\n}\\n.text-xs {\\n font-size: 0.75rem;\\n line-height: 1rem;\\n}\\n.font-bold {\\n font-weight: 700;\\n}\\n.font-medium {\\n font-weight: 500;\\n}\\n.text-neutral-300 {\\n --tw-text-opacity: 1;\\n color: rgb(212 212 212 / var(--tw-text-opacity, 1));\\n}\\n.text-white {\\n --tw-text-opacity: 1;\\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\\n}\\n.accent-red-500 {\\n accent-color: #ef4444;\\n}\\n.opacity-50 {\\n opacity: 0.5;\\n}\\n.shadow {\\n --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\\n}\\n.filter {\\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\\n}\\n.transition {\\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\\n transition-duration: 150ms;\\n}\\n.transition-opacity {\\n transition-property: opacity;\\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\\n transition-duration: 150ms;\\n}\\n.will-change-transform {\\n will-change: transform;\\n}\\n.last\\\\:border-b-0:last-child {\\n border-bottom-width: 0px;\\n}\\n.hover\\\\:bg-\\\\[\\\\#0003\\\\]:hover {\\n background-color: #0003;\\n}\\n.hover\\\\:bg-neutral-700:hover {\\n --tw-bg-opacity: 1;\\n background-color: rgb(64 64 64 / var(--tw-bg-opacity, 1));\\n}\\n.hover\\\\:opacity-100:hover {\\n opacity: 1;\\n}\\n.focus\\\\:outline:focus {\\n outline-style: solid;\\n}\\n";
2933
+
2934
+ // src/index.ts
2935
+ if ("window" in globalThis) {
2936
+ const pageRoot = document.createElement("kiru-devtools");
2937
+ pageRoot.setAttribute("style", "display: contents");
2938
+ document.body.appendChild(pageRoot);
2939
+ const shadow = pageRoot.attachShadow({ mode: "open" });
2940
+ const sheet = new CSSStyleSheet();
2941
+ sheet.replaceSync(style_default);
2942
+ shadow.adoptedStyleSheets = [sheet];
2943
+ const appRoot = Object.assign(document.createElement("div"), {
2944
+ id: "devtools-root",
2945
+ className: "fixed flex bottom-0 right-0 z-[9999999]"
2946
+ });
2947
+ shadow.appendChild(appRoot);
2948
+ mount(App, {
2949
+ root: appRoot,
2950
+ name: "kiru.devtools"
2951
+ });
2952
+ const handleMainWindowClose = /* @__PURE__ */ __name(() => popup.value?.close(), "handleMainWindowClose");
2953
+ window.addEventListener("close", handleMainWindowClose);
2954
+ window.addEventListener("beforeunload", handleMainWindowClose);
2955
+ broadcastChannel.addEventListener((msg) => {
2956
+ if (msg.data.type === "open-editor") {
2957
+ window.open(msg.data.fileLink);
2958
+ }
2959
+ });
2960
+ }
2961
+
2962
+ `;
2963
+
2964
+ // src/codegen/shared.ts
2965
+ var import_magic_string = __toESM(require_magic_string_cjs(), 1);
2966
+
2967
+ // src/codegen/ast.ts
2968
+ function findNode(node, predicate, maxDepth = Infinity) {
2969
+ let res = null;
2970
+ walk(node, {
2971
+ "*": (node2, ctx) => {
2972
+ if (predicate(node2)) {
2973
+ res = node2;
2974
+ ctx.exit();
2975
+ }
2976
+ if (ctx.stack.length >= maxDepth) ctx.exitBranch();
2977
+ }
2978
+ });
2979
+ return res;
2980
+ }
2981
+ function walk(node, visitor) {
2982
+ const ctx = {
2983
+ stack: [],
2984
+ exit: exitWalk,
2985
+ exitBranch
2986
+ };
2987
+ try {
2988
+ walk_impl(node, visitor, ctx);
2989
+ } catch (error) {
2990
+ if (error === "walk:exit") return;
2991
+ throw error;
2992
+ }
2993
+ }
2994
+ var exitWalk = () => {
2995
+ throw "walk:exit";
2996
+ };
2997
+ var exitBranch = () => {
2998
+ throw "walk:exit-branch";
2999
+ };
3000
+ var flushCallbacks = (callbacks) => {
3001
+ while (callbacks.length) {
3002
+ callbacks.pop()();
3003
+ }
3004
+ };
3005
+ function walk_impl(node, visitor, ctx) {
3006
+ const onExitCallbacks = [];
3007
+ try {
3008
+ {
3009
+ const cb = visitor[node.type]?.(node, ctx);
3010
+ if (cb instanceof Function) onExitCallbacks.push(cb);
3011
+ }
3012
+ {
3013
+ const cb = visitor["*"]?.(node, ctx);
3014
+ if (cb instanceof Function) onExitCallbacks.push(cb);
3015
+ }
3016
+ } catch (error) {
3017
+ if (error === "walk:exit-branch") {
3018
+ flushCallbacks(onExitCallbacks);
3019
+ return;
3020
+ }
3021
+ throw error;
3022
+ }
3023
+ ctx.stack.push(node);
3024
+ [
3025
+ node.arguments,
3026
+ node.declarations,
3027
+ node.properties,
3028
+ node.property,
3029
+ node.cases,
3030
+ node.body,
3031
+ node.consequent,
3032
+ node.init,
3033
+ node.argument,
3034
+ node.alternate,
3035
+ node.callee,
3036
+ node.declaration,
3037
+ node.expression,
3038
+ node.expressions,
3039
+ node.left,
3040
+ node.right
3041
+ ].filter(Boolean).forEach((a) => {
3042
+ if (Array.isArray(a)) {
3043
+ for (let i = 0; i < a.length; i++) {
3044
+ walk_impl(a[i], visitor, ctx);
3045
+ }
3046
+ return;
3047
+ }
3048
+ if (typeof a === "object" && "type" in a) {
3049
+ walk_impl(a, visitor, ctx);
3050
+ return;
3051
+ }
3052
+ });
3053
+ if (node.type === "Property" && node.value && typeof node.value === "object") {
3054
+ walk_impl(node.value, visitor, ctx);
3055
+ }
3056
+ ctx.stack.pop();
3057
+ flushCallbacks(onExitCallbacks);
3058
+ }
3059
+
3060
+ // src/codegen/shared.ts
3061
+ function createAliasHandler(name, namespace = "kiru") {
3062
+ const aliases = /* @__PURE__ */ new Set();
3063
+ const isMatchingCallExpression = (node) => node.type === "CallExpression" && node.callee?.type === "Identifier" && typeof node.callee.name === "string" && aliases.has(node.callee.name);
3064
+ const addAliases = (node) => {
3065
+ if (node.source?.value !== namespace) return false;
3066
+ let didAdd = false;
3067
+ const specifiers = node.specifiers || [];
3068
+ for (let i = 0; i < specifiers.length; i++) {
3069
+ const specifier = specifiers[i];
3070
+ if (specifier.imported && specifier.imported.name === name && !!specifier.local) {
3071
+ aliases.add(specifier.local.name);
3072
+ didAdd = true;
3073
+ }
3074
+ }
3075
+ return didAdd;
3076
+ };
3077
+ return { name, aliases, addAliases, isMatchingCallExpression };
3078
+ }
3079
+ function isComponent(node, bodyNodes) {
3080
+ const isTlf = isTopLevelFunction(node, bodyNodes);
3081
+ if (!isTlf) return false;
3082
+ const name = findNodeName(node);
3083
+ if (name === null) return false;
3084
+ const charCode = name.charCodeAt(0);
3085
+ return charCode >= 65 && charCode <= 90;
3086
+ }
3087
+ function findNodeName(node) {
3088
+ if (node.id?.name) return node.id.name;
3089
+ if (node.declaration?.id?.name) return node.declaration.id.name;
3090
+ if (node.declaration?.declarations?.[0]?.id?.name)
3091
+ return node.declaration.declarations[0].id.name;
3092
+ if (node.declarations?.[0]?.id?.name) return node.declarations[0].id.name;
3093
+ return null;
3094
+ }
3095
+ function findFunctionBodyNodes(node, name, bodyNodes) {
3096
+ let dec = node.declaration;
3097
+ if (!dec) {
3098
+ for (const _node of bodyNodes) {
3099
+ if (_node.type === "VariableDeclaration") {
3100
+ if (_node.declarations?.[0]?.id?.name === name) {
3101
+ dec = _node;
3102
+ break;
3103
+ }
3104
+ } else if (_node.type === "FunctionDeclaration") {
3105
+ if (_node.id?.name === name) {
3106
+ dec = _node;
3107
+ break;
3108
+ }
3109
+ }
3110
+ }
3111
+ }
3112
+ if (!dec) {
3113
+ throw new Error(
3114
+ "[vite-plugin-kiru]: failed to find declaration for component"
3115
+ );
3116
+ }
3117
+ if (dec.type === "FunctionDeclaration" && dec.body && !Array.isArray(dec.body) && dec.body.type === "BlockStatement") {
3118
+ return dec.body.body;
3119
+ } else if (dec.type === "VariableDeclaration") {
3120
+ if (!Array.isArray(dec.declarations)) {
3121
+ return null;
3122
+ }
3123
+ for (const _dec of dec.declarations) {
3124
+ if (_dec.id?.name !== name) continue;
3125
+ if (_dec.init?.type === "ArrowFunctionExpression" || _dec.init?.type === "FunctionExpression") {
3126
+ return _dec.init.body.body;
3127
+ } else if (_dec.init?.type === "CallExpression" && _dec.init.arguments) {
3128
+ const nodes = [];
3129
+ for (const arg of _dec.init.arguments) {
3130
+ if (isFuncDecOrExpr(arg) && arg.body && !Array.isArray(arg.body) && Array.isArray(arg.body.body)) {
3131
+ nodes.push(...arg.body.body);
3132
+ }
3133
+ }
3134
+ return nodes;
3135
+ }
3136
+ }
3137
+ }
3138
+ return null;
3139
+ }
3140
+ function isFuncDecOrExpr(node) {
3141
+ if (!node) return false;
3142
+ if (node.type === "VariableDeclaration") {
3143
+ return isFuncDecOrExpr(node.declarations?.[0]?.init);
3144
+ }
3145
+ return [
3146
+ "FunctionDeclaration",
3147
+ "FunctionExpression",
3148
+ "ArrowFunctionExpression"
3149
+ ].includes(node.type);
3150
+ }
3151
+ function isTopLevelFunction(node, bodyNodes) {
3152
+ if (isFuncDecOrExpr(node)) {
3153
+ return true;
3154
+ }
3155
+ switch (node.type) {
3156
+ case "VariableDeclaration":
3157
+ case "ExportNamedDeclaration":
3158
+ if (node.declaration) {
3159
+ return isFuncDecOrExpr(node.declaration);
3160
+ } else if (node.declarations) {
3161
+ return !!findNode(node, isFuncDecOrExpr);
3162
+ }
3163
+ const name = findNodeName(node);
3164
+ if (name === null) return false;
3165
+ const dec = findFunctionBodyNodes(node, name, bodyNodes);
3166
+ if (!dec) return false;
3167
+ return isFuncDecOrExpr(dec[0]);
3168
+ case "ExportDefaultDeclaration":
3169
+ return isFuncDecOrExpr(node.declaration);
3170
+ }
3171
+ return false;
3172
+ }
3173
+
3174
+ // src/index.ts
3175
+ import path2 from "node:path";
3176
+
3177
+ // src/codegen/hmr.ts
3178
+ import fs from "node:fs";
3179
+ var UNNAMED_WATCH_PREAMBLE = `
3180
+
3181
+ if (import.meta.hot && "window" in globalThis) {
3182
+ window.__kiru.HMRContext?.signals.registerNextWatch();
3183
+ }
3184
+ `;
3185
+ function prepareHMR(ctx) {
3186
+ const { code, ast, fileLinkFormatter, filePath, isVirtualModule } = ctx;
3187
+ try {
3188
+ const hotVars = findHotVars(code, ast.body, filePath);
3189
+ if (hotVars.size === 0 && !code.hasChanged()) return;
3190
+ code.prepend(`
3191
+ if (import.meta.hot && "window" in globalThis) {
3192
+ window.__kiru.HMRContext?.prepare("${filePath}");
3193
+ }
3194
+ `);
3195
+ code.append(`
3196
+ if (import.meta.hot && "window" in globalThis) {
3197
+ import.meta.hot.accept();
3198
+ ${createHMRRegistrationBlurb(
3199
+ hotVars,
3200
+ fileLinkFormatter,
3201
+ filePath,
3202
+ isVirtualModule
3203
+ )}
3204
+ }
3205
+ `);
3206
+ } catch (error) {
3207
+ console.error(error);
3208
+ }
3209
+ }
3210
+ function createHMRRegistrationBlurb(hotVars, fileLinkFormatter, filePath, isVirtualModule) {
3211
+ let entries = [];
3212
+ if (isVirtualModule) {
3213
+ entries = Array.from(hotVars).map(({ name, type }) => {
3214
+ const key = JSON.stringify(name);
3215
+ if (type !== "component") {
3216
+ return ` ${key}: {
3217
+ type: "${type}",
3218
+ value: ${name}
3219
+ }`;
3220
+ }
3221
+ return ` ${key}: {
3222
+ type: "component",
3223
+ value: ${name},
3224
+ hooks: [],
3225
+ }`;
3226
+ });
3227
+ } else {
3228
+ const src = fs.readFileSync(filePath, "utf-8");
3229
+ entries = Array.from(hotVars).map(({ name, type }) => {
3230
+ const key = JSON.stringify(name);
3231
+ const line = findHotVarLineInSrc(src, name);
3232
+ return ` ${key}: {
3233
+ type: "${type}",
3234
+ value: ${name},
3235
+ link: "${fileLinkFormatter(filePath, line)}"
3236
+ }`;
3237
+ });
3238
+ }
3239
+ return `
3240
+ window.__kiru.HMRContext?.register({
3241
+ ${entries.join(",\n")}
3242
+ });`;
3243
+ }
3244
+ function findHotVarLineInSrc(src, name) {
3245
+ const lines = src.split("\n");
3246
+ const potentialMatches = [
3247
+ `const ${name}`,
3248
+ `let ${name}`,
3249
+ `var ${name}`,
3250
+ `function ${name}`,
3251
+ `export const ${name}`,
3252
+ `export let ${name}`,
3253
+ `export var ${name}`,
3254
+ `export default ${name}`,
3255
+ `export function ${name}`,
3256
+ `export default function ${name}`
3257
+ ];
3258
+ for (let i = 0; i < lines.length; i++) {
3259
+ const line = lines[i];
3260
+ for (let j = 0; j < potentialMatches.length; j++) {
3261
+ if (line.startsWith(potentialMatches[j])) return i + 1;
3262
+ }
3263
+ }
3264
+ return 0;
3265
+ }
3266
+ var exprAssign = [
3267
+ "ExpressionStatement",
3268
+ "AssignmentExpression"
3269
+ ];
3270
+ var allowedHotVarParentStacks = [
3271
+ ["VariableDeclaration", "VariableDeclarator"],
3272
+ exprAssign,
3273
+ ["ExportNamedDeclaration", "VariableDeclaration", "VariableDeclarator"]
3274
+ ];
3275
+ function findHotVars(code, bodyNodes, _id) {
3276
+ const hotVars = /* @__PURE__ */ new Set();
3277
+ const aliasHandlers = [
3278
+ "createStore",
3279
+ "signal",
3280
+ "computed",
3281
+ "watch",
3282
+ "createContext",
3283
+ "lazy"
3284
+ ].map((name) => createAliasHandler(name));
3285
+ for (const node of bodyNodes) {
3286
+ if (node.type === "ImportDeclaration") {
3287
+ for (const aliasHandler of aliasHandlers) {
3288
+ aliasHandler.addAliases(node);
3289
+ }
3290
+ continue;
3291
+ }
3292
+ if (isComponent(node, bodyNodes)) {
3293
+ addHotVarDesc(node, hotVars, "component");
3294
+ continue;
3295
+ }
3296
+ for (const aliasHandler of aliasHandlers) {
3297
+ walk(node, {
3298
+ CallExpression: (node2, ctx) => {
3299
+ if (!aliasHandler.isMatchingCallExpression(node2)) {
3300
+ return ctx.exitBranch();
3301
+ }
3302
+ if (aliasHandler.name === "watch" && ctx.stack.length === 1 && ctx.stack[0].type === "ExpressionStatement") {
3303
+ code.appendRight(node2.start, UNNAMED_WATCH_PREAMBLE);
3304
+ return ctx.exit();
3305
+ }
3306
+ const matchingParentStack = allowedHotVarParentStacks.find(
3307
+ (stack) => {
3308
+ return stack.every((type, i) => ctx.stack[i]?.type === type);
3309
+ }
3310
+ );
3311
+ if (!matchingParentStack) {
3312
+ return ctx.exitBranch();
3313
+ }
3314
+ if (matchingParentStack === exprAssign) {
3315
+ const [_expr, assign] = ctx.stack;
3316
+ const name2 = assign.left?.name;
3317
+ if (!name2) return ctx.exit();
3318
+ hotVars.add({
3319
+ type: aliasHandler.name,
3320
+ name: name2
3321
+ });
3322
+ return ctx.exit();
3323
+ }
3324
+ const remainingStack = ctx.stack.slice(matchingParentStack.length);
3325
+ if (remainingStack.some(
3326
+ (n) => n.type !== "ObjectExpression" && n.type !== "Property"
3327
+ )) {
3328
+ return ctx.exitBranch();
3329
+ }
3330
+ const name = ctx.stack.reduce((acc, item) => {
3331
+ switch (item.type) {
3332
+ case "VariableDeclarator":
3333
+ return item.id.name;
3334
+ case "Property":
3335
+ if (!item.key) return acc;
3336
+ if (item.key.name) return `${acc}.${item.key.name}`;
3337
+ if (item.key.raw) return `${acc}[${item.key.raw}]`;
3338
+ return acc;
3339
+ }
3340
+ return acc;
3341
+ }, "");
3342
+ hotVars.add({ type: aliasHandler.name, name });
3343
+ ctx.exitBranch();
3344
+ }
3345
+ });
3346
+ }
3347
+ }
3348
+ return hotVars;
3349
+ }
3350
+ function addHotVarDesc(node, names, type) {
3351
+ const name = findNodeName(node);
3352
+ if (name == null && type === "component") {
3353
+ console.error("[vite-plugin-kiru]: failed to find component name", node);
3354
+ throw new Error("[vite-plugin-kiru]: Component name not found");
3355
+ }
3356
+ if (name !== null) {
3357
+ names.add({ type, name });
3358
+ }
3359
+ }
3360
+
3361
+ // src/codegen/hydrationBoundary.ts
3362
+ import path from "node:path";
3363
+
3364
+ // src/ansi.ts
3365
+ var colors = {
3366
+ black: "\x1B[30m",
3367
+ black_bright: "\x1B[90m",
3368
+ red: "\x1B[31m",
3369
+ red_bright: "\x1B[91m",
3370
+ green: "\x1B[32m",
3371
+ green_bright: "\x1B[92m",
3372
+ yellow: "\x1B[33m",
3373
+ yellow_bright: "\x1B[93m",
3374
+ blue: "\x1B[34m",
3375
+ blue_bright: "\x1B[94m",
3376
+ magenta: "\x1B[35m",
3377
+ magenta_bright: "\x1B[95m",
3378
+ cyan: "\x1B[36m",
3379
+ cyan_bright: "\x1B[96m",
3380
+ white: "\x1B[37m",
3381
+ white_bright: "\x1B[97m",
3382
+ reset: "\x1B[0m"
3383
+ };
3384
+ var ANSI = tEntries(colors).reduce((acc, [key, value]) => {
3385
+ acc[key] = (str) => `${value}${str}${colors.reset}`;
3386
+ return acc;
3387
+ }, {});
3388
+ function tEntries(obj) {
3389
+ return Object.entries(obj);
3390
+ }
3391
+
3392
+ // src/codegen/hydrationBoundary.ts
3393
+ function prepareHydrationBoundaries(ctx) {
3394
+ const { log, code, ast, filePath } = ctx;
3395
+ const CWD = process.cwd().replace(/\\/g, "/");
3396
+ const folderPath = filePath.replace(/\\/g, "/").split("/").slice(0, -1).join("/");
3397
+ const modulePrefix = filePath.replace("+", "").split(".").slice(0, -1).join("").replace(CWD, "").split("/").filter(Boolean).join("_");
3398
+ const extraModules = {};
3399
+ const bodyNodes = ast.body;
3400
+ const hydrationBoundaryAliasHandler = createAliasHandler(
3401
+ "Experimental_HydrationBoundary",
3402
+ "kiru/ssr"
3403
+ );
3404
+ const importNodes = [];
3405
+ for (const node of ast.body) {
3406
+ if (node.type === "ImportDeclaration") {
3407
+ if (hydrationBoundaryAliasHandler.addAliases(node)) {
3408
+ continue;
3409
+ }
3410
+ importNodes.push(node);
3411
+ continue;
3412
+ }
3413
+ if (!isComponent(node, bodyNodes)) continue;
3414
+ const componentName = findNodeName(node);
3415
+ if (componentName === null) {
3416
+ log(
3417
+ ANSI.red(
3418
+ "unable to prepare hydration boundaries (failed to find component name)"
3419
+ ),
3420
+ node.type,
3421
+ node.start
3422
+ );
3423
+ continue;
3424
+ }
3425
+ const componentBodyNodes = findFunctionBodyNodes(
3426
+ node,
3427
+ componentName,
3428
+ bodyNodes
3429
+ );
3430
+ let currentBoundary = null;
3431
+ const globalVars = new Map(
3432
+ importNodes.reduce((acc, item) => {
3433
+ const entries = item.specifiers.map(
3434
+ (s) => [s.local.name, s]
3435
+ );
3436
+ return [...acc, ...entries];
3437
+ }, [])
3438
+ );
3439
+ const blockScopes = [
3440
+ // global scope
3441
+ globalVars,
3442
+ // function scope
3443
+ new Map(globalVars)
3444
+ ];
3445
+ let index = 0;
3446
+ const fnExprs = [];
3447
+ componentBodyNodes?.forEach((node2) => {
3448
+ walk(node2, {
3449
+ // ReturnStatement: (n) => {
3450
+ // log(JSON.stringify(n, null, 2))
3451
+ // },
3452
+ // capture variables encountered outside of boundary scopes
3453
+ VariableDeclarator: (n) => {
3454
+ if (currentBoundary) return;
3455
+ blockScopes[blockScopes.length - 1].set(n.id?.name, n);
3456
+ },
3457
+ BlockStatement: () => {
3458
+ if (currentBoundary) return;
3459
+ const parentScope = blockScopes[blockScopes.length - 1];
3460
+ blockScopes.push(new Map(parentScope));
3461
+ return () => blockScopes.pop();
3462
+ },
3463
+ // find jsx props, hoist non-literal values
3464
+ ObjectExpression: (n, ctx2) => {
3465
+ const boundary = currentBoundary;
3466
+ if (!boundary) return;
3467
+ const parent = ctx2.stack[ctx2.stack.length - 1];
3468
+ const isParentJSX = parent.type === "CallExpression" && parent.callee?.name === "_jsx";
3469
+ if (!isParentJSX) return;
3470
+ if (parent === currentBoundary?.node) return;
3471
+ const nonLiteralProperties = n.properties?.filter(
3472
+ (p) => typeof p.value === "object" && p.value.type !== "Literal"
3473
+ ) ?? [];
3474
+ nonLiteralProperties.forEach((p) => {
3475
+ boundary.deps.expressions.push({
3476
+ node: p.value,
3477
+ property: p
3478
+ });
3479
+ });
3480
+ ctx2.exitBranch();
3481
+ },
3482
+ MemberExpression: (n) => {
3483
+ if (!currentBoundary || !n.object?.name) return;
3484
+ const parentScope = blockScopes[blockScopes.length - 1];
3485
+ const variableFromParentScope = parentScope.get(n.object.name);
3486
+ if (variableFromParentScope) {
3487
+ currentBoundary.deps.expressions.push({
3488
+ node: n,
3489
+ property: null
3490
+ });
3491
+ }
3492
+ },
3493
+ BinaryExpression: (n, ctx2) => {
3494
+ if (!currentBoundary) return;
3495
+ const isHoistRequired = findNode(
3496
+ n,
3497
+ (node3) => node3 !== n && node3.type !== "Literal" && node3.type !== "BinaryExpression"
3498
+ );
3499
+ if (!isHoistRequired) return;
3500
+ currentBoundary.deps.expressions.push({
3501
+ node: n,
3502
+ property: null
3503
+ });
3504
+ ctx2.exitBranch();
3505
+ },
3506
+ ["*"]: (n, ctx2) => {
3507
+ if (!currentBoundary?.hasJsxChildren) return;
3508
+ switch (n.type) {
3509
+ case "ArrowFunctionExpression":
3510
+ case "FunctionExpression": {
3511
+ fnExprs.push(n);
3512
+ return () => fnExprs.pop();
3513
+ }
3514
+ case "Identifier": {
3515
+ if (fnExprs.length) return;
3516
+ if (n.name === "_jsx") return;
3517
+ const parentCallExpression = findFirstParentOfType(
3518
+ ctx2.stack,
3519
+ "CallExpression"
3520
+ );
3521
+ if (parentCallExpression && parentCallExpression.callee?.name !== "_jsx") {
3522
+ currentBoundary.deps.expressions.push({
3523
+ node: parentCallExpression,
3524
+ property: null
3525
+ });
3526
+ return;
3527
+ }
3528
+ if (ctx2.stack[ctx2.stack.length - 1].type === "MemberExpression") {
3529
+ const exprRoot = findLastConsecutiveParentOfType(
3530
+ ctx2.stack,
3531
+ "MemberExpression"
3532
+ );
3533
+ if (exprRoot?.type !== "MemberExpression") return;
3534
+ currentBoundary.deps.expressions.push({
3535
+ node: exprRoot,
3536
+ property: null
3537
+ });
3538
+ return;
3539
+ }
3540
+ const importNode = importNodes.find(
3541
+ (importNode2) => importNode2.specifiers?.some((s) => s.local?.name === n.name)
3542
+ );
3543
+ if (importNode) {
3544
+ currentBoundary.deps.imports.add(importNode);
3545
+ } else {
3546
+ currentBoundary.deps.expressions.push({
3547
+ node: n,
3548
+ property: null
3549
+ });
3550
+ }
3551
+ return;
3552
+ }
3553
+ }
3554
+ return;
3555
+ },
3556
+ CallExpression: (n) => {
3557
+ if (n.callee?.type !== "Identifier" || n.callee.name !== "_jsx") {
3558
+ return;
3559
+ }
3560
+ if (currentBoundary) {
3561
+ currentBoundary.hasJsxChildren = true;
3562
+ return;
3563
+ }
3564
+ const [nodeType, _, ...children] = n.arguments;
3565
+ if (nodeType.type === "Identifier" && nodeType.name && hydrationBoundaryAliasHandler.aliases.has(nodeType.name)) {
3566
+ const idx = index++;
3567
+ const boundary = currentBoundary = {
3568
+ id: `@boundaries/${modulePrefix}/${componentName}_${idx}`,
3569
+ node: n,
3570
+ deps: {
3571
+ imports: /* @__PURE__ */ new Set(),
3572
+ expressions: []
3573
+ },
3574
+ hasJsxChildren: false
3575
+ };
3576
+ return () => {
3577
+ if (!boundary.hasJsxChildren) return;
3578
+ const childExprStart = Math.min(...children.map((n2) => n2.start));
3579
+ const childExprEnd = Math.max(...children.map((n2) => n2.end));
3580
+ const childrenExpr = new import_magic_string.default(
3581
+ code.original.substring(childExprStart, childExprEnd)
3582
+ );
3583
+ transformChildExpression: {
3584
+ for (let i = 0; i < boundary.deps.expressions.length; i++) {
3585
+ const { node: expr, property } = boundary.deps.expressions[i];
3586
+ const start = expr.start - childExprStart;
3587
+ const end = expr.end - childExprStart;
3588
+ if (!property) {
3589
+ childrenExpr.update(start, end, `_props[${i}]`);
3590
+ continue;
3591
+ }
3592
+ if (!property.shorthand) {
3593
+ childrenExpr.update(start, end, `_props[${i}]`);
3594
+ continue;
3595
+ }
3596
+ childrenExpr.appendLeft(end, `: _props[${i}]`);
3597
+ }
3598
+ }
3599
+ let moduleCode = `
3600
+ import {createElement as _jsx, Fragment as _jsxFragment} from "kiru";
3601
+ `;
3602
+ copyImports: {
3603
+ for (const importedIdentifier of boundary.deps.imports) {
3604
+ const importPath = importedIdentifier.source.value;
3605
+ const isRelative = importPath[0] === "." || importPath[0] === "/";
3606
+ const defaultSpecifier = importedIdentifier.specifiers.find(
3607
+ (s) => s.type === "ImportDefaultSpecifier"
3608
+ );
3609
+ const nonDefaults = importedIdentifier.specifiers.filter(
3610
+ (s) => s !== defaultSpecifier
3611
+ );
3612
+ let importStr = "import ";
3613
+ if (defaultSpecifier) {
3614
+ importStr += defaultSpecifier.local?.name;
3615
+ }
3616
+ if (nonDefaults.length) {
3617
+ if (defaultSpecifier) {
3618
+ importStr += ", ";
3619
+ }
3620
+ const names = nonDefaults.map((s) => s.local?.name).join(", ");
3621
+ importStr += `{ ${names} }`;
3622
+ }
3623
+ if (isRelative) {
3624
+ importStr += ` from "${path.resolve(folderPath, importPath).replace(/\\/g, "/")}";`;
3625
+ } else {
3626
+ importStr += ` from "${importPath}";`;
3627
+ }
3628
+ moduleCode += `${importStr}
3629
+ `;
3630
+ }
3631
+ }
3632
+ addModules: {
3633
+ moduleCode += `
3634
+
3635
+ export default function BoundaryChildren({_props}) {
3636
+ return _jsx(_jsxFragment, null, ${childrenExpr})
3637
+ }`;
3638
+ const boundaryChildrenName = `BoundaryChildren_${componentName}_${idx}`;
3639
+ code.prepend(
3640
+ `
3641
+ import ${boundaryChildrenName} from "${boundary.id + "_loader"}";
3642
+ `
3643
+ );
3644
+ const props = boundary.deps.expressions.map(
3645
+ (expr) => code.original.slice(expr.node.start, expr.node.end)
3646
+ ).join(",\n");
3647
+ code.update(
3648
+ childExprStart,
3649
+ childExprEnd,
3650
+ `_jsx(${boundaryChildrenName}, { _props: [${props}] })`
3651
+ );
3652
+ extraModules[boundary.id] = moduleCode;
3653
+ extraModules[boundary.id + "_loader"] = `import {lazy} from "kiru";
3654
+ const BoundaryChildrenLoader = lazy(() => import("${boundary.id}"));
3655
+ export default BoundaryChildrenLoader;`;
3656
+ currentBoundary = null;
3657
+ }
3658
+ };
3659
+ }
3660
+ return;
3661
+ }
3662
+ });
3663
+ });
3664
+ }
3665
+ return { extraModules };
3666
+ }
3667
+ function findFirstParentOfType(stack, type) {
3668
+ for (let i = stack.length - 1; i >= 0; i--) {
3669
+ if (stack[i].type === type) {
3670
+ return stack[i];
3671
+ }
3672
+ }
3673
+ return null;
3674
+ }
3675
+ function findLastConsecutiveParentOfType(stack, type) {
3676
+ let last = null;
3677
+ for (let i = stack.length - 1; i >= 0; i--) {
3678
+ if (stack[i].type !== type) {
3679
+ return last;
3680
+ }
3681
+ last = stack[i];
3682
+ }
3683
+ return last;
3684
+ }
3685
+
3686
+ // src/codegen/devOnlyHooks.ts
3687
+ function prepareDevOnlyHooks(ctx) {
3688
+ const { code, ast, isBuild } = ctx;
3689
+ replaceOnHMRCallbacks(code, ast, isBuild);
3690
+ }
3691
+ var VITE_IMPORT_META_HOT_ACCEPT = `if ("window" in globalThis) {
3692
+ if (import.meta.hot) {
3693
+ import.meta.hot.accept(%);
3694
+ }
3695
+ }`;
3696
+ function replaceOnHMRCallbacks(code, ast, isBuild) {
3697
+ const onHMRAliasHandler = createAliasHandler("onHMR", "vite-plugin-kiru");
3698
+ for (const node of ast.body) {
3699
+ if (node.type === "ImportDeclaration") {
3700
+ if (onHMRAliasHandler.addAliases(node) && isBuild) {
3701
+ code.update(node.start, node.end, "");
3702
+ }
3703
+ continue;
3704
+ }
3705
+ walk(node, {
3706
+ CallExpression: (node2, ctx) => {
3707
+ if (onHMRAliasHandler.isMatchingCallExpression(node2)) {
3708
+ try {
3709
+ if (isBuild) {
3710
+ code.update(node2.start, node2.end, "");
3711
+ return;
3712
+ }
3713
+ const callback = node2.arguments[0];
3714
+ const callbackRaw = code.original.substring(
3715
+ callback.start,
3716
+ callback.end
3717
+ );
3718
+ code.update(
3719
+ node2.start,
3720
+ node2.end,
3721
+ VITE_IMPORT_META_HOT_ACCEPT.replace("%", callbackRaw)
3722
+ );
3723
+ } finally {
3724
+ ctx.exitBranch();
3725
+ }
3726
+ }
3727
+ }
3728
+ });
3729
+ }
3730
+ }
3731
+
3732
+ // src/index.ts
3733
+ var defaultEsBuildOptions = {
3734
+ jsxInject: `import { createElement as _jsx, Fragment as _jsxFragment } from "kiru"`,
3735
+ jsx: "transform",
3736
+ jsxFactory: "_jsx",
3737
+ jsxFragment: "_jsxFragment",
3738
+ loader: "tsx",
3739
+ include: ["**/*.tsx", "**/*.ts", "**/*.jsx", "**/*.js"]
3740
+ };
3741
+ function kiru(opts) {
3742
+ let isProduction = false;
3743
+ let isBuild = false;
3744
+ let devtoolsEnabled = false;
3745
+ let loggingEnabled = false;
3746
+ const log = (...data) => {
3747
+ if (!loggingEnabled) return;
3748
+ console.log(ANSI.cyan("[vite-plugin-kiru]"), ...data);
3749
+ };
3750
+ let fileLinkFormatter = (path3, line) => `vscode://file/${path3}:${line}`;
3751
+ let dtClientPathname = "/__devtools__";
3752
+ if (typeof opts?.devtools === "object") {
3753
+ dtClientPathname = opts.devtools.pathname ?? dtClientPathname;
3754
+ fileLinkFormatter = opts.devtools.formatFileLink ?? fileLinkFormatter;
3755
+ }
3756
+ const dtHostScriptPath = "/__devtools_host__.js";
3757
+ let transformedDtHostBuild = "";
3758
+ let transformedDtClientBuild = "";
3759
+ const virtualModules = {};
3760
+ const fileToVirtualModules = {};
3761
+ let projectRoot = process.cwd().replace(/\\/g, "/");
3762
+ let includedPaths = [];
3763
+ return {
3764
+ name: "vite-plugin-kiru",
3765
+ // @ts-ignore
3766
+ resolveId(id) {
3767
+ if (virtualModules[id]) {
3768
+ return id;
3769
+ }
3770
+ },
3771
+ load(id) {
3772
+ return virtualModules[id];
3773
+ },
3774
+ async buildStart() {
3775
+ if (!devtoolsEnabled) return;
3776
+ log("Preparing devtools...");
3777
+ const kiruPath = await this.resolve("kiru");
3778
+ if (!kiruPath) {
3779
+ throw new Error("[vite-plugin-kiru]: Unable to resolve kiru path.");
3780
+ }
3781
+ transformedDtHostBuild = dist_default2.replaceAll(
3782
+ 'from "kiru"',
3783
+ `from "/@fs/${kiruPath.id}"`
3784
+ );
3785
+ transformedDtClientBuild = dist_default.replaceAll(
3786
+ 'from"kiru";',
3787
+ `from"/@fs/${kiruPath.id}";`
3788
+ );
3789
+ log("Devtools ready.");
3790
+ },
3791
+ config(config) {
3792
+ return {
3793
+ ...config,
3794
+ esbuild: {
3795
+ ...defaultEsBuildOptions,
3796
+ ...config.esbuild
3797
+ }
3798
+ };
3799
+ },
3800
+ configResolved(config) {
3801
+ isProduction = config.isProduction;
3802
+ isBuild = config.command === "build";
3803
+ devtoolsEnabled = opts?.devtools !== false && !isBuild && !isProduction;
3804
+ loggingEnabled = opts?.loggingEnabled === true;
3805
+ projectRoot = config.root.replace(/\\/g, "/");
3806
+ includedPaths = (opts?.include ?? []).map(
3807
+ (p) => path2.resolve(projectRoot, p).replace(/\\/g, "/")
3808
+ );
3809
+ },
3810
+ transformIndexHtml(html) {
3811
+ if (!devtoolsEnabled) return;
3812
+ return {
3813
+ html,
3814
+ tags: [
3815
+ {
3816
+ tag: "script",
3817
+ children: `window.__KIRU_DEVTOOLS_PATHNAME__ = "${dtClientPathname}";`
3818
+ },
3819
+ {
3820
+ tag: "script",
3821
+ attrs: {
3822
+ type: "module",
3823
+ src: dtHostScriptPath
3824
+ }
3825
+ }
3826
+ ]
3827
+ };
3828
+ },
3829
+ configureServer(server) {
3830
+ if (isProduction || isBuild) return;
3831
+ if (devtoolsEnabled) {
3832
+ log(`Serving devtools host at ${ANSI.magenta(dtHostScriptPath)}`);
3833
+ server.middlewares.use(dtHostScriptPath, (_, res) => {
3834
+ res.setHeader("Content-Type", "application/javascript");
3835
+ res.end(transformedDtHostBuild, "utf-8");
3836
+ });
3837
+ log(`Serving devtools client at ${ANSI.magenta(dtClientPathname)}`);
3838
+ server.middlewares.use(dtClientPathname, (_, res) => {
3839
+ res.end(transformedDtClientBuild);
3840
+ });
3841
+ }
3842
+ server.watcher.on("change", (file) => {
3843
+ const filePath = path2.resolve(file).replace(/\\/g, "/");
3844
+ const affectedVirtualModules = fileToVirtualModules[filePath];
3845
+ if (affectedVirtualModules) {
3846
+ for (const modId of affectedVirtualModules) {
3847
+ const mod2 = server.moduleGraph.getModuleById(modId);
3848
+ if (mod2) {
3849
+ server.moduleGraph.invalidateModule(
3850
+ mod2,
3851
+ void 0,
3852
+ void 0,
3853
+ true
3854
+ );
3855
+ }
3856
+ }
3857
+ }
3858
+ const mod = server.moduleGraph.getModuleById(file);
3859
+ if (mod) {
3860
+ mod.importers.forEach((importer) => {
3861
+ if (importer.id && virtualModules[importer.id]) {
3862
+ server.moduleGraph.invalidateModule(
3863
+ importer,
3864
+ void 0,
3865
+ void 0,
3866
+ true
3867
+ );
3868
+ }
3869
+ });
3870
+ }
3871
+ });
3872
+ },
3873
+ transform(src, id, options) {
3874
+ const isVirtualModule = !!virtualModules[id];
3875
+ if (!isVirtualModule) {
3876
+ if (id.startsWith("\0") || id.startsWith("vite:") || id.includes("/node_modules/"))
3877
+ return { code: src };
3878
+ if (!/\.[cm]?[jt]sx?$/.test(id)) return { code: src };
3879
+ const filePath = path2.resolve(id).replace(/\\/g, "/");
3880
+ const isIncludedByUser = includedPaths.some(
3881
+ (p) => filePath.startsWith(p)
3882
+ );
3883
+ if (!isIncludedByUser && !filePath.startsWith(projectRoot)) {
3884
+ opts?.onFileExcluded?.(id);
3885
+ return { code: src };
3886
+ }
3887
+ }
3888
+ log(`Processing ${ANSI.black(id)}`);
3889
+ const ast = this.parse(src);
3890
+ const code = new import_magic_string.default(src);
3891
+ const ctx = {
3892
+ code,
3893
+ ast,
3894
+ isBuild,
3895
+ fileLinkFormatter,
3896
+ isVirtualModule,
3897
+ filePath: id,
3898
+ log
3899
+ };
3900
+ prepareDevOnlyHooks(ctx);
3901
+ if (!isProduction && !isBuild) {
3902
+ prepareHMR(ctx);
3903
+ }
3904
+ if (!options?.ssr) {
3905
+ const { extraModules } = prepareHydrationBoundaries(ctx);
3906
+ for (const key in extraModules) {
3907
+ ;
3908
+ (fileToVirtualModules[id] ??= /* @__PURE__ */ new Set()).add(key);
3909
+ virtualModules[key] = extraModules[key];
3910
+ }
3911
+ }
3912
+ if (!code.hasChanged()) {
3913
+ log(ANSI.green("\u2713"), "No changes");
3914
+ return { code: src };
3915
+ }
3916
+ const map = code.generateMap({
3917
+ source: id,
3918
+ file: `${id}.map`,
3919
+ includeContent: true
3920
+ });
3921
+ log(ANSI.green("\u2713"), "Transformed");
3922
+ const result = code.toString();
3923
+ opts?.onFileTransformed?.(id, result);
3924
+ return {
3925
+ code: result,
3926
+ map: map.toString()
3927
+ };
3928
+ }
3929
+ };
3930
+ }
3931
+ function onHMR(callback) {
3932
+ }
3933
+ export {
3934
+ kiru as default,
3935
+ defaultEsBuildOptions,
3936
+ onHMR
3937
+ };