@kong-ui-public/dashboard-renderer 7.0.19 → 7.1.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.
@@ -0,0 +1,4282 @@
1
+ var ei = Object.defineProperty;
2
+ var nt = (c) => {
3
+ throw TypeError(c);
4
+ };
5
+ var ti = (c, e, t) => e in c ? ei(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
6
+ var ot = (c, e, t) => ti(c, typeof e != "symbol" ? e + "" : e, t), Ge = (c, e, t) => e.has(c) || nt("Cannot " + t);
7
+ var _ = (c, e, t) => (Ge(c, e, "read from private field"), t ? t.call(c) : e.get(c)), P = (c, e, t) => e.has(c) ? nt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(c) : e.set(c, t), L = (c, e, t, i) => (Ge(c, e, "write to private field"), i ? i.call(c, t) : e.set(c, t), t), $ = (c, e, t) => (Ge(c, e, "access private method"), t);
8
+ var we = (c, e, t, i) => ({
9
+ set _(s) {
10
+ L(c, e, s, t);
11
+ },
12
+ get _() {
13
+ return _(c, e, i);
14
+ }
15
+ });
16
+ import { ref as B, watchEffect as Et, inject as be, provide as ii, defineComponent as Q, onUnmounted as We, computed as S, watch as Ke, resolveComponent as de, createBlock as M, renderSlot as Pe, createCommentVNode as X, unref as k, openBlock as C, withCtx as I, createVNode as se, createTextVNode as Ee, toDisplayString as te, useCssVars as Ve, createElementVNode as le, normalizeClass as Ye, mergeProps as xt, createSlots as je, createElementBlock as V, normalizeProps as si, guardReactiveProps as ri, defineAsyncComponent as Ct, onMounted as Xe, nextTick as Rt, resolveDynamicComponent as Tt, toHandlers as ni, Fragment as zt, renderList as Dt, normalizeStyle as at, mergeModels as lt, useModel as oi, getCurrentInstance as ai } from "vue";
17
+ import { stripUnknownFilters as li, Timeframe as hi, TimePeriods as kt, TIMEFRAME_LOOKUP as di, formatTime as ht, msToGranularity as dt, getFieldDataSources as ui } from "@kong-ui-public/analytics-utilities";
18
+ import { SimpleChart as ci, AnalyticsChart as fi, TopNTable as gi, CsvExportModal as mi } from "@kong-ui-public/analytics-chart";
19
+ import pi from "swrv";
20
+ import "axios";
21
+ import { createI18n as yi, i18nTComponent as vi } from "@kong-ui-public/i18n";
22
+ import { useAnalyticsConfigStore as St } from "@kong-ui-public/analytics-config-store";
23
+ import { VisibilityOffIcon as _i, WarningIcon as bi, EditIcon as wi, MoreIcon as Ei } from "@kong/icons";
24
+ import { MetricsProvider as xi, MetricsConsumer as Ci } from "@kong-ui-public/analytics-metric-provider";
25
+ var Nt = /* @__PURE__ */ ((c) => (c.VALIDATING = "VALIDATING", c.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", c.PENDING = "PENDING", c.SUCCESS = "SUCCESS", c.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", c.ERROR = "ERROR", c.STALE_IF_ERROR = "STALE_IF_ERROR", c))(Nt || {});
26
+ const Ri = (c) => {
27
+ var e, t, i, s, r;
28
+ return c ? !!// TODO: revisit: currently only the first check ever matters?
29
+ ((e = Object.keys(c)) != null && e.length || (t = c.data) != null && t.length || (s = (i = c.data) == null ? void 0 : i.data) != null && s.length || !((r = c.data) != null && r.data) && typeof c.data == "object" && Object.keys(c == null ? void 0 : c.data).length) : !1;
30
+ };
31
+ function Ti(c = B({}), e, t, i = Ri) {
32
+ const s = B(
33
+ "PENDING"
34
+ /* PENDING */
35
+ );
36
+ return Et(() => {
37
+ const r = i(c.value);
38
+ if (c.value && r && t.value) {
39
+ s.value = "VALIDATING_HAS_DATA";
40
+ return;
41
+ }
42
+ if (c.value && t.value) {
43
+ s.value = "VALIDATING";
44
+ return;
45
+ }
46
+ if (c.value && e.value) {
47
+ s.value = "STALE_IF_ERROR";
48
+ return;
49
+ }
50
+ if (c.value === void 0 && !e.value) {
51
+ s.value = "PENDING";
52
+ return;
53
+ }
54
+ if (c.value && !e.value && r) {
55
+ s.value = "SUCCESS_HAS_DATA";
56
+ return;
57
+ }
58
+ if (c.value && !e.value) {
59
+ s.value = "SUCCESS";
60
+ return;
61
+ }
62
+ c.value === void 0 && e && (s.value = "ERROR");
63
+ }), {
64
+ state: s,
65
+ swrvState: Nt
66
+ };
67
+ }
68
+ const zi = {
69
+ noQueryBridge: "No query bridge provided. Unable to render dashboard.",
70
+ trendRange: {
71
+ "24h": "Last 24-hour summary",
72
+ "7d": "Last 7-day summary",
73
+ "30d": "Last 30-day summary"
74
+ },
75
+ edit: "Edit",
76
+ duplicateTile: "Duplicate",
77
+ remove: "Remove",
78
+ delete: "Delete"
79
+ }, Di = {
80
+ forbidden: "To access this data, either filter for an entity you have access to or request analytics viewer access from your administrator.",
81
+ timeRangeExceeded: "The time range for this report is outside of your organization's data retention period",
82
+ timeout: "Query timed out. Consider querying a shorter time range."
83
+ }, ki = {
84
+ defaultFilename: "Chart export",
85
+ exportAsCsv: "Export as CSV"
86
+ }, Si = "Explore", Ni = "View requests", Ai = "This tile was configured with {savedGranularity} granularity, which is no longer available. It now shows {currentGranularity} data, the closest available granularity.", Oi = {
87
+ daily: "1 day",
88
+ fiveMinutely: "5 minutes",
89
+ hourly: "1 hour",
90
+ minutely: "1 minute",
91
+ tenMinutely: "10 minutes",
92
+ tensecondly: "10 seconds",
93
+ thirtyMinutely: "30 minutes",
94
+ thirtySecondly: "30 seconds",
95
+ twelveHourly: "12 hours",
96
+ twoHourly: "2 hours",
97
+ weekly: "1 week",
98
+ unknown: "Unknown"
99
+ }, Hi = {
100
+ renderer: zi,
101
+ queryDataProvider: Di,
102
+ csvExport: ki,
103
+ jumpToExplore: Si,
104
+ jumpToRequests: Ni,
105
+ query_aged_out_warning: Ai,
106
+ granularities: Oi
107
+ };
108
+ function Li() {
109
+ const c = yi("en-us", Hi);
110
+ return {
111
+ i18n: c,
112
+ i18nT: vi(c)
113
+ // Translation component <i18n-t>
114
+ };
115
+ }
116
+ const $e = 170, At = 6, ue = "analytics-query-provider", ut = "{entity-id}", Mi = "{cp-id}", Ii = "{timeframe}", qi = 30 * 1e3;
117
+ function Pi() {
118
+ const c = be(ue);
119
+ return {
120
+ evaluateFeatureFlag: (t, i) => c ? c.evaluateFeatureFlagFn(t, i) : i
121
+ };
122
+ }
123
+ function $i(c) {
124
+ return c && c.__esModule && Object.prototype.hasOwnProperty.call(c, "default") ? c.default : c;
125
+ }
126
+ var Ot = { exports: {} };
127
+ (function(c) {
128
+ var e = Object.prototype.hasOwnProperty, t = "~";
129
+ function i() {
130
+ }
131
+ Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (t = !1));
132
+ function s(h, l, d) {
133
+ this.fn = h, this.context = l, this.once = d || !1;
134
+ }
135
+ function r(h, l, d, a, f) {
136
+ if (typeof d != "function")
137
+ throw new TypeError("The listener must be a function");
138
+ var y = new s(d, a || h, f), g = t ? t + l : l;
139
+ return h._events[g] ? h._events[g].fn ? h._events[g] = [h._events[g], y] : h._events[g].push(y) : (h._events[g] = y, h._eventsCount++), h;
140
+ }
141
+ function o(h, l) {
142
+ --h._eventsCount === 0 ? h._events = new i() : delete h._events[l];
143
+ }
144
+ function n() {
145
+ this._events = new i(), this._eventsCount = 0;
146
+ }
147
+ n.prototype.eventNames = function() {
148
+ var l = [], d, a;
149
+ if (this._eventsCount === 0) return l;
150
+ for (a in d = this._events)
151
+ e.call(d, a) && l.push(t ? a.slice(1) : a);
152
+ return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(d)) : l;
153
+ }, n.prototype.listeners = function(l) {
154
+ var d = t ? t + l : l, a = this._events[d];
155
+ if (!a) return [];
156
+ if (a.fn) return [a.fn];
157
+ for (var f = 0, y = a.length, g = new Array(y); f < y; f++)
158
+ g[f] = a[f].fn;
159
+ return g;
160
+ }, n.prototype.listenerCount = function(l) {
161
+ var d = t ? t + l : l, a = this._events[d];
162
+ return a ? a.fn ? 1 : a.length : 0;
163
+ }, n.prototype.emit = function(l, d, a, f, y, g) {
164
+ var v = t ? t + l : l;
165
+ if (!this._events[v]) return !1;
166
+ var p = this._events[v], R = arguments.length, H, T;
167
+ if (p.fn) {
168
+ switch (p.once && this.removeListener(l, p.fn, void 0, !0), R) {
169
+ case 1:
170
+ return p.fn.call(p.context), !0;
171
+ case 2:
172
+ return p.fn.call(p.context, d), !0;
173
+ case 3:
174
+ return p.fn.call(p.context, d, a), !0;
175
+ case 4:
176
+ return p.fn.call(p.context, d, a, f), !0;
177
+ case 5:
178
+ return p.fn.call(p.context, d, a, f, y), !0;
179
+ case 6:
180
+ return p.fn.call(p.context, d, a, f, y, g), !0;
181
+ }
182
+ for (T = 1, H = new Array(R - 1); T < R; T++)
183
+ H[T - 1] = arguments[T];
184
+ p.fn.apply(p.context, H);
185
+ } else {
186
+ var q = p.length, x;
187
+ for (T = 0; T < q; T++)
188
+ switch (p[T].once && this.removeListener(l, p[T].fn, void 0, !0), R) {
189
+ case 1:
190
+ p[T].fn.call(p[T].context);
191
+ break;
192
+ case 2:
193
+ p[T].fn.call(p[T].context, d);
194
+ break;
195
+ case 3:
196
+ p[T].fn.call(p[T].context, d, a);
197
+ break;
198
+ case 4:
199
+ p[T].fn.call(p[T].context, d, a, f);
200
+ break;
201
+ default:
202
+ if (!H) for (x = 1, H = new Array(R - 1); x < R; x++)
203
+ H[x - 1] = arguments[x];
204
+ p[T].fn.apply(p[T].context, H);
205
+ }
206
+ }
207
+ return !0;
208
+ }, n.prototype.on = function(l, d, a) {
209
+ return r(this, l, d, a, !1);
210
+ }, n.prototype.once = function(l, d, a) {
211
+ return r(this, l, d, a, !0);
212
+ }, n.prototype.removeListener = function(l, d, a, f) {
213
+ var y = t ? t + l : l;
214
+ if (!this._events[y]) return this;
215
+ if (!d)
216
+ return o(this, y), this;
217
+ var g = this._events[y];
218
+ if (g.fn)
219
+ g.fn === d && (!f || g.once) && (!a || g.context === a) && o(this, y);
220
+ else {
221
+ for (var v = 0, p = [], R = g.length; v < R; v++)
222
+ (g[v].fn !== d || f && !g[v].once || a && g[v].context !== a) && p.push(g[v]);
223
+ p.length ? this._events[y] = p.length === 1 ? p[0] : p : o(this, y);
224
+ }
225
+ return this;
226
+ }, n.prototype.removeAllListeners = function(l) {
227
+ var d;
228
+ return l ? (d = t ? t + l : l, this._events[d] && o(this, d)) : (this._events = new i(), this._eventsCount = 0), this;
229
+ }, n.prototype.off = n.prototype.removeListener, n.prototype.addListener = n.prototype.on, n.prefixed = t, n.EventEmitter = n, c.exports = n;
230
+ })(Ot);
231
+ var Bi = Ot.exports;
232
+ const Gi = /* @__PURE__ */ $i(Bi);
233
+ class Ht extends Error {
234
+ constructor(e) {
235
+ super(e), this.name = "TimeoutError";
236
+ }
237
+ }
238
+ class Ui extends Error {
239
+ constructor(e) {
240
+ super(), this.name = "AbortError", this.message = e;
241
+ }
242
+ }
243
+ const ct = (c) => globalThis.DOMException === void 0 ? new Ui(c) : new DOMException(c), ft = (c) => {
244
+ const e = c.reason === void 0 ? ct("This operation was aborted.") : c.reason;
245
+ return e instanceof Error ? e : ct(e);
246
+ };
247
+ function Fi(c, e) {
248
+ const {
249
+ milliseconds: t,
250
+ fallback: i,
251
+ message: s,
252
+ customTimers: r = { setTimeout, clearTimeout }
253
+ } = e;
254
+ let o, n;
255
+ const l = new Promise((d, a) => {
256
+ if (typeof t != "number" || Math.sign(t) !== 1)
257
+ throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);
258
+ if (e.signal) {
259
+ const { signal: y } = e;
260
+ y.aborted && a(ft(y)), n = () => {
261
+ a(ft(y));
262
+ }, y.addEventListener("abort", n, { once: !0 });
263
+ }
264
+ if (t === Number.POSITIVE_INFINITY) {
265
+ c.then(d, a);
266
+ return;
267
+ }
268
+ const f = new Ht();
269
+ o = r.setTimeout.call(void 0, () => {
270
+ if (i) {
271
+ try {
272
+ d(i());
273
+ } catch (y) {
274
+ a(y);
275
+ }
276
+ return;
277
+ }
278
+ typeof c.cancel == "function" && c.cancel(), s === !1 ? d() : s instanceof Error ? a(s) : (f.message = s ?? `Promise timed out after ${t} milliseconds`, a(f));
279
+ }, t), (async () => {
280
+ try {
281
+ d(await c);
282
+ } catch (y) {
283
+ a(y);
284
+ }
285
+ })();
286
+ }).finally(() => {
287
+ l.clear(), n && e.signal && e.signal.removeEventListener("abort", n);
288
+ });
289
+ return l.clear = () => {
290
+ r.clearTimeout.call(void 0, o), o = void 0;
291
+ }, l;
292
+ }
293
+ function Wi(c, e, t) {
294
+ let i = 0, s = c.length;
295
+ for (; s > 0; ) {
296
+ const r = Math.trunc(s / 2);
297
+ let o = i + r;
298
+ t(c[o], e) <= 0 ? (i = ++o, s -= r + 1) : s = r;
299
+ }
300
+ return i;
301
+ }
302
+ var Z;
303
+ class Ki {
304
+ constructor() {
305
+ P(this, Z, []);
306
+ }
307
+ enqueue(e, t) {
308
+ t = {
309
+ priority: 0,
310
+ ...t
311
+ };
312
+ const i = {
313
+ priority: t.priority,
314
+ id: t.id,
315
+ run: e
316
+ };
317
+ if (this.size === 0 || _(this, Z)[this.size - 1].priority >= t.priority) {
318
+ _(this, Z).push(i);
319
+ return;
320
+ }
321
+ const s = Wi(_(this, Z), i, (r, o) => o.priority - r.priority);
322
+ _(this, Z).splice(s, 0, i);
323
+ }
324
+ setPriority(e, t) {
325
+ const i = _(this, Z).findIndex((r) => r.id === e);
326
+ if (i === -1)
327
+ throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);
328
+ const [s] = _(this, Z).splice(i, 1);
329
+ this.enqueue(s.run, { priority: t, id: e });
330
+ }
331
+ dequeue() {
332
+ const e = _(this, Z).shift();
333
+ return e == null ? void 0 : e.run;
334
+ }
335
+ filter(e) {
336
+ return _(this, Z).filter((t) => t.priority === e.priority).map((t) => t.run);
337
+ }
338
+ get size() {
339
+ return _(this, Z).length;
340
+ }
341
+ }
342
+ Z = new WeakMap();
343
+ var ge, me, he, Re, pe, Te, J, ye, K, ze, ee, ve, ae, De, qe, D, Lt, Mt, It, qt, Pt, Se, Ue, Fe, Ne, $t, Ae;
344
+ class Vi extends Gi {
345
+ // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
346
+ constructor(t) {
347
+ var i, s;
348
+ super();
349
+ P(this, D);
350
+ P(this, ge);
351
+ P(this, me);
352
+ P(this, he, 0);
353
+ P(this, Re);
354
+ P(this, pe);
355
+ P(this, Te, 0);
356
+ P(this, J);
357
+ P(this, ye);
358
+ P(this, K);
359
+ P(this, ze);
360
+ P(this, ee, 0);
361
+ // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
362
+ P(this, ve);
363
+ P(this, ae);
364
+ P(this, De);
365
+ // Use to assign a unique identifier to a promise function, if not explicitly specified
366
+ P(this, qe, 1n);
367
+ /**
368
+ Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.
369
+
370
+ Applies to each future operation.
371
+ */
372
+ ot(this, "timeout");
373
+ if (t = {
374
+ carryoverConcurrencyCount: !1,
375
+ intervalCap: Number.POSITIVE_INFINITY,
376
+ interval: 0,
377
+ concurrency: Number.POSITIVE_INFINITY,
378
+ autoStart: !0,
379
+ queueClass: Ki,
380
+ ...t
381
+ }, !(typeof t.intervalCap == "number" && t.intervalCap >= 1))
382
+ throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${((i = t.intervalCap) == null ? void 0 : i.toString()) ?? ""}\` (${typeof t.intervalCap})`);
383
+ if (t.interval === void 0 || !(Number.isFinite(t.interval) && t.interval >= 0))
384
+ throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${((s = t.interval) == null ? void 0 : s.toString()) ?? ""}\` (${typeof t.interval})`);
385
+ L(this, ge, t.carryoverConcurrencyCount), L(this, me, t.intervalCap === Number.POSITIVE_INFINITY || t.interval === 0), L(this, Re, t.intervalCap), L(this, pe, t.interval), L(this, K, new t.queueClass()), L(this, ze, t.queueClass), this.concurrency = t.concurrency, this.timeout = t.timeout, L(this, De, t.throwOnTimeout === !0), L(this, ae, t.autoStart === !1);
386
+ }
387
+ get concurrency() {
388
+ return _(this, ve);
389
+ }
390
+ set concurrency(t) {
391
+ if (!(typeof t == "number" && t >= 1))
392
+ throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);
393
+ L(this, ve, t), $(this, D, Ne).call(this);
394
+ }
395
+ /**
396
+ Updates the priority of a promise function by its id, affecting its execution order. Requires a defined concurrency limit to take effect.
397
+
398
+ For example, this can be used to prioritize a promise function to run earlier.
399
+
400
+ ```js
401
+ import PQueue from 'p-queue';
402
+
403
+ const queue = new PQueue({concurrency: 1});
404
+
405
+ queue.add(async () => '🦄', {priority: 1});
406
+ queue.add(async () => '🦀', {priority: 0, id: '🦀'});
407
+ queue.add(async () => '🦄', {priority: 1});
408
+ queue.add(async () => '🦄', {priority: 1});
409
+
410
+ queue.setPriority('🦀', 2);
411
+ ```
412
+
413
+ In this case, the promise function with `id: '🦀'` runs second.
414
+
415
+ You can also deprioritize a promise function to delay its execution:
416
+
417
+ ```js
418
+ import PQueue from 'p-queue';
419
+
420
+ const queue = new PQueue({concurrency: 1});
421
+
422
+ queue.add(async () => '🦄', {priority: 1});
423
+ queue.add(async () => '🦀', {priority: 1, id: '🦀'});
424
+ queue.add(async () => '🦄');
425
+ queue.add(async () => '🦄', {priority: 0});
426
+
427
+ queue.setPriority('🦀', -1);
428
+ ```
429
+ Here, the promise function with `id: '🦀'` executes last.
430
+ */
431
+ setPriority(t, i) {
432
+ _(this, K).setPriority(t, i);
433
+ }
434
+ async add(t, i = {}) {
435
+ return i.id ?? (i.id = (we(this, qe)._++).toString()), i = {
436
+ timeout: this.timeout,
437
+ throwOnTimeout: _(this, De),
438
+ ...i
439
+ }, new Promise((s, r) => {
440
+ _(this, K).enqueue(async () => {
441
+ var o;
442
+ we(this, ee)._++, we(this, he)._++;
443
+ try {
444
+ (o = i.signal) == null || o.throwIfAborted();
445
+ let n = t({ signal: i.signal });
446
+ i.timeout && (n = Fi(Promise.resolve(n), { milliseconds: i.timeout })), i.signal && (n = Promise.race([n, $(this, D, $t).call(this, i.signal)]));
447
+ const h = await n;
448
+ s(h), this.emit("completed", h);
449
+ } catch (n) {
450
+ if (n instanceof Ht && !i.throwOnTimeout) {
451
+ s();
452
+ return;
453
+ }
454
+ r(n), this.emit("error", n);
455
+ } finally {
456
+ $(this, D, It).call(this);
457
+ }
458
+ }, i), this.emit("add"), $(this, D, Se).call(this);
459
+ });
460
+ }
461
+ async addAll(t, i) {
462
+ return Promise.all(t.map(async (s) => this.add(s, i)));
463
+ }
464
+ /**
465
+ Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
466
+ */
467
+ start() {
468
+ return _(this, ae) ? (L(this, ae, !1), $(this, D, Ne).call(this), this) : this;
469
+ }
470
+ /**
471
+ Put queue execution on hold.
472
+ */
473
+ pause() {
474
+ L(this, ae, !0);
475
+ }
476
+ /**
477
+ Clear the queue.
478
+ */
479
+ clear() {
480
+ L(this, K, new (_(this, ze))());
481
+ }
482
+ /**
483
+ Can be called multiple times. Useful if you for example add additional items at a later time.
484
+
485
+ @returns A promise that settles when the queue becomes empty.
486
+ */
487
+ async onEmpty() {
488
+ _(this, K).size !== 0 && await $(this, D, Ae).call(this, "empty");
489
+ }
490
+ /**
491
+ @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
492
+
493
+ If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
494
+
495
+ Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.
496
+ */
497
+ async onSizeLessThan(t) {
498
+ _(this, K).size < t || await $(this, D, Ae).call(this, "next", () => _(this, K).size < t);
499
+ }
500
+ /**
501
+ The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
502
+
503
+ @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
504
+ */
505
+ async onIdle() {
506
+ _(this, ee) === 0 && _(this, K).size === 0 || await $(this, D, Ae).call(this, "idle");
507
+ }
508
+ /**
509
+ Size of the queue, the number of queued items waiting to run.
510
+ */
511
+ get size() {
512
+ return _(this, K).size;
513
+ }
514
+ /**
515
+ Size of the queue, filtered by the given options.
516
+
517
+ For example, this can be used to find the number of items remaining in the queue with a specific priority level.
518
+ */
519
+ sizeBy(t) {
520
+ return _(this, K).filter(t).length;
521
+ }
522
+ /**
523
+ Number of running items (no longer in the queue).
524
+ */
525
+ get pending() {
526
+ return _(this, ee);
527
+ }
528
+ /**
529
+ Whether the queue is currently paused.
530
+ */
531
+ get isPaused() {
532
+ return _(this, ae);
533
+ }
534
+ }
535
+ ge = new WeakMap(), me = new WeakMap(), he = new WeakMap(), Re = new WeakMap(), pe = new WeakMap(), Te = new WeakMap(), J = new WeakMap(), ye = new WeakMap(), K = new WeakMap(), ze = new WeakMap(), ee = new WeakMap(), ve = new WeakMap(), ae = new WeakMap(), De = new WeakMap(), qe = new WeakMap(), D = new WeakSet(), Lt = function() {
536
+ return _(this, me) || _(this, he) < _(this, Re);
537
+ }, Mt = function() {
538
+ return _(this, ee) < _(this, ve);
539
+ }, It = function() {
540
+ we(this, ee)._--, $(this, D, Se).call(this), this.emit("next");
541
+ }, qt = function() {
542
+ $(this, D, Fe).call(this), $(this, D, Ue).call(this), L(this, ye, void 0);
543
+ }, Pt = function() {
544
+ const t = Date.now();
545
+ if (_(this, J) === void 0) {
546
+ const i = _(this, Te) - t;
547
+ if (i < 0)
548
+ L(this, he, _(this, ge) ? _(this, ee) : 0);
549
+ else
550
+ return _(this, ye) === void 0 && L(this, ye, setTimeout(() => {
551
+ $(this, D, qt).call(this);
552
+ }, i)), !0;
553
+ }
554
+ return !1;
555
+ }, Se = function() {
556
+ if (_(this, K).size === 0)
557
+ return _(this, J) && clearInterval(_(this, J)), L(this, J, void 0), this.emit("empty"), _(this, ee) === 0 && this.emit("idle"), !1;
558
+ if (!_(this, ae)) {
559
+ const t = !_(this, D, Pt);
560
+ if (_(this, D, Lt) && _(this, D, Mt)) {
561
+ const i = _(this, K).dequeue();
562
+ return i ? (this.emit("active"), i(), t && $(this, D, Ue).call(this), !0) : !1;
563
+ }
564
+ }
565
+ return !1;
566
+ }, Ue = function() {
567
+ _(this, me) || _(this, J) !== void 0 || (L(this, J, setInterval(() => {
568
+ $(this, D, Fe).call(this);
569
+ }, _(this, pe))), L(this, Te, Date.now() + _(this, pe)));
570
+ }, Fe = function() {
571
+ _(this, he) === 0 && _(this, ee) === 0 && _(this, J) && (clearInterval(_(this, J)), L(this, J, void 0)), L(this, he, _(this, ge) ? _(this, ee) : 0), $(this, D, Ne).call(this);
572
+ }, /**
573
+ Executes all queued functions until it reaches the limit.
574
+ */
575
+ Ne = function() {
576
+ for (; $(this, D, Se).call(this); )
577
+ ;
578
+ }, $t = async function(t) {
579
+ return new Promise((i, s) => {
580
+ t.addEventListener("abort", () => {
581
+ s(t.reason);
582
+ }, { once: !0 });
583
+ });
584
+ }, Ae = async function(t, i) {
585
+ return new Promise((s) => {
586
+ const r = () => {
587
+ i && !i() || (this.off(t, r), s());
588
+ };
589
+ this.on(t, r);
590
+ });
591
+ };
592
+ const Yi = () => {
593
+ const c = St(), e = be(ue);
594
+ if (!e)
595
+ return;
596
+ if (e.queryFnOverride) {
597
+ console.warn("Detected incorrect use of useRequestQueue. This composable should not be used in nested components. Please discuss with team-data or report an issue if you feel you have a use case.");
598
+ return;
599
+ }
600
+ const t = new Vi({
601
+ carryoverConcurrencyCount: !0,
602
+ concurrency: c.maxParallelRequests,
603
+ interval: c.requestInterval,
604
+ intervalCap: c.requestIntervalCap
605
+ }), i = {
606
+ ...e,
607
+ queryFnOverride: !0,
608
+ queryFn: (s, r) => t.add(() => e.queryFn(s, r), { throwOnTimeout: !0 })
609
+ };
610
+ ii(ue, i);
611
+ }, _e = {
612
+ useI18n: Li,
613
+ useEvaluateFeatureFlag: Pi,
614
+ useRequestQueue: Yi
615
+ }, Qe = /* @__PURE__ */ Q({
616
+ __name: "QueryDataProvider",
617
+ props: {
618
+ context: {},
619
+ query: {},
620
+ queryReady: { type: Boolean },
621
+ refreshCounter: {}
622
+ },
623
+ emits: ["chart-data", "queryComplete"],
624
+ setup(c, { emit: e }) {
625
+ const t = c, i = e, { i18n: s } = _e.useI18n(), r = be(ue), o = () => t.queryReady && r ? JSON.stringify([t.query, t.context, t.refreshCounter]) : null, n = new AbortController();
626
+ We(() => {
627
+ n.abort();
628
+ });
629
+ const h = (R, H, T) => {
630
+ const q = [];
631
+ return H && q.push(...H), q.push(...li(R, T)), q;
632
+ }, { data: l, error: d, isValidating: a } = pi(o, async () => {
633
+ var R, H, T, q;
634
+ try {
635
+ let {
636
+ datasource: x,
637
+ ...E
638
+ } = t.query;
639
+ x || (x = "basic");
640
+ const A = h(x, t.query.filters, t.context.filters);
641
+ let N = t.query.time_range;
642
+ N ? N.tz || (N = {
643
+ ...N,
644
+ tz: t.context.tz
645
+ }) : N = {
646
+ ...t.context.timeSpec,
647
+ tz: t.context.tz
648
+ };
649
+ const G = {
650
+ datasource: x,
651
+ query: {
652
+ ...E,
653
+ time_range: N,
654
+ filters: A
655
+ }
656
+ }, U = await (r == null ? void 0 : r.queryFn(G, n));
657
+ return g.value = null, U;
658
+ } catch (x) {
659
+ throw (x == null ? void 0 : x.status) === 403 ? g.value = {
660
+ message: s.t("queryDataProvider.forbidden"),
661
+ type: "forbidden"
662
+ } : (x == null ? void 0 : x.status) === 408 ? g.value = {
663
+ message: s.t("queryDataProvider.timeout"),
664
+ type: "timeout"
665
+ } : ((H = (R = x == null ? void 0 : x.response) == null ? void 0 : R.data) == null ? void 0 : H.message) === "Range not allowed for this tier" ? g.value = {
666
+ message: s.t("queryDataProvider.timeRangeExceeded"),
667
+ type: "range_exceeded"
668
+ } : g.value = {
669
+ message: ((q = (T = x == null ? void 0 : x.response) == null ? void 0 : T.data) == null ? void 0 : q.message) || (x == null ? void 0 : x.message),
670
+ type: "other"
671
+ }, x;
672
+ } finally {
673
+ i("queryComplete");
674
+ }
675
+ }, {
676
+ refreshInterval: t.context.refreshInterval,
677
+ revalidateOnFocus: !1,
678
+ shouldRetryOnError: !1
679
+ }), { state: f, swrvState: y } = Ti(l, d, a), g = B(null), v = S(() => f.value === y.ERROR || !!g.value), p = S(() => !t.queryReady || f.value === y.PENDING);
680
+ return Ke(l, (R) => {
681
+ R && i("chart-data", R);
682
+ }), (R, H) => {
683
+ var x;
684
+ const T = de("KSkeleton"), q = de("KEmptyState");
685
+ return p.value || !k(l) && !v.value ? (C(), M(T, {
686
+ key: 0,
687
+ class: "chart-skeleton",
688
+ type: "table"
689
+ })) : v.value && ((x = g.value) == null ? void 0 : x.type) === "forbidden" ? (C(), M(q, {
690
+ key: 1,
691
+ "action-button-visible": !1,
692
+ "data-testid": "chart-forbidden-state"
693
+ }, {
694
+ default: I(() => [
695
+ Ee(te(g.value.message), 1)
696
+ ]),
697
+ icon: I(() => [
698
+ se(k(_i))
699
+ ]),
700
+ _: 1
701
+ })) : v.value ? (C(), M(q, {
702
+ key: 2,
703
+ "action-button-visible": !1,
704
+ "data-testid": "chart-empty-state",
705
+ "icon-variant": "error"
706
+ }, {
707
+ default: I(() => {
708
+ var E;
709
+ return [
710
+ Ee(te((E = g.value) == null ? void 0 : E.message), 1)
711
+ ];
712
+ }),
713
+ _: 1
714
+ })) : k(l) ? Pe(R.$slots, "default", {
715
+ key: 3,
716
+ data: k(l)
717
+ }) : X("", !0);
718
+ };
719
+ }
720
+ }), ji = /* @__PURE__ */ Q({
721
+ __name: "SimpleChartRenderer",
722
+ props: {
723
+ query: {},
724
+ context: {},
725
+ queryReady: { type: Boolean },
726
+ chartOptions: {},
727
+ height: {},
728
+ refreshCounter: {},
729
+ requestsLink: {}
730
+ },
731
+ setup(c) {
732
+ Ve((i) => ({
733
+ "088169ae": `${i.height}px`
734
+ }));
735
+ const e = c, t = S(() => e.chartOptions.type === "single_value");
736
+ return (i, s) => (C(), M(Qe, {
737
+ context: i.context,
738
+ query: i.query,
739
+ "query-ready": i.queryReady,
740
+ "refresh-counter": i.refreshCounter
741
+ }, {
742
+ default: I(({ data: r }) => [
743
+ le("div", {
744
+ class: Ye(["analytics-chart", { "single-value": t.value }])
745
+ }, [
746
+ se(k(ci), {
747
+ "chart-data": r,
748
+ "chart-options": i.chartOptions,
749
+ "synthetics-data-key": t.value ? void 0 : i.chartOptions.synthetics_data_key
750
+ }, null, 8, ["chart-data", "chart-options", "synthetics-data-key"])
751
+ ], 2)
752
+ ]),
753
+ _: 1
754
+ }, 8, ["context", "query", "query-ready", "refresh-counter"]));
755
+ }
756
+ }), ce = (c, e) => {
757
+ const t = c.__vccOpts || c;
758
+ for (const [i, s] of e)
759
+ t[i] = s;
760
+ return t;
761
+ }, gt = /* @__PURE__ */ ce(ji, [["__scopeId", "data-v-1e9ff912"]]), Xi = { class: "analytics-chart" }, Qi = /* @__PURE__ */ Q({
762
+ __name: "BaseAnalyticsChartRenderer",
763
+ props: {
764
+ query: {},
765
+ context: {},
766
+ queryReady: { type: Boolean },
767
+ chartOptions: {},
768
+ height: {},
769
+ refreshCounter: {},
770
+ requestsLink: {},
771
+ extraProps: {}
772
+ },
773
+ emits: ["edit-tile", "chart-data", "zoom-time-range", "view-requests", "select-chart-range"],
774
+ setup(c, { emit: e }) {
775
+ const t = c, i = e, { i18n: s } = _e.useI18n(), { evaluateFeatureFlag: r } = _e.useEvaluateFeatureFlag(), o = r("ma-4135-allow-zooming-all-dashboard-tiles", !1), n = S(() => ({
776
+ type: t.chartOptions.type,
777
+ stacked: t.chartOptions.stacked ?? !1,
778
+ chartDatasetColors: t.chartOptions.chart_dataset_colors,
779
+ threshold: t.chartOptions.threshold
780
+ })), h = S(() => o ? t.context.zoomable : t.context.zoomable && !t.query.time_range), l = () => {
781
+ i("edit-tile");
782
+ }, d = (a) => {
783
+ i("chart-data", a);
784
+ };
785
+ return (a, f) => {
786
+ const y = de("KDropdownItem");
787
+ return C(), M(Qe, {
788
+ context: a.context,
789
+ query: a.query,
790
+ "query-ready": a.queryReady,
791
+ "refresh-counter": a.refreshCounter,
792
+ onChartData: d
793
+ }, {
794
+ default: I(({ data: g }) => [
795
+ le("div", Xi, [
796
+ se(k(fi), xt({
797
+ "chart-data": g,
798
+ "chart-options": n.value,
799
+ "legend-position": "bottom",
800
+ "requests-link": a.requestsLink,
801
+ "synthetics-data-key": a.chartOptions.synthetics_data_key,
802
+ "timeseries-zoom": h.value,
803
+ "tooltip-title": ""
804
+ }, a.extraProps, {
805
+ onSelectChartRange: f[0] || (f[0] = (v) => i("select-chart-range", v)),
806
+ onZoomTimeRange: f[1] || (f[1] = (v) => i("zoom-time-range", v))
807
+ }), je({ _: 2 }, [
808
+ a.context.editable ? {
809
+ name: "menu-items",
810
+ fn: I(() => [
811
+ se(y, { onClick: l }, {
812
+ default: I(() => [
813
+ Ee(te(k(s).t("renderer.edit")), 1)
814
+ ]),
815
+ _: 1
816
+ })
817
+ ]),
818
+ key: "0"
819
+ } : void 0
820
+ ]), 1040, ["chart-data", "chart-options", "requests-link", "synthetics-data-key", "timeseries-zoom"])
821
+ ])
822
+ ]),
823
+ _: 1
824
+ }, 8, ["context", "query", "query-ready", "refresh-counter"]);
825
+ };
826
+ }
827
+ }), Ze = /* @__PURE__ */ ce(Qi, [["__scopeId", "data-v-959ffa20"]]), mt = /* @__PURE__ */ Q({
828
+ __name: "BarChartRenderer",
829
+ props: {
830
+ query: {},
831
+ context: {},
832
+ queryReady: { type: Boolean },
833
+ chartOptions: {},
834
+ height: {},
835
+ refreshCounter: {},
836
+ requestsLink: {}
837
+ },
838
+ setup(c) {
839
+ return (e, t) => (C(), M(Ze, {
840
+ "chart-options": e.chartOptions,
841
+ context: e.context,
842
+ "extra-props": { showAnnotations: !1 },
843
+ height: e.height,
844
+ query: e.query,
845
+ "query-ready": e.queryReady,
846
+ "refresh-counter": e.refreshCounter
847
+ }, null, 8, ["chart-options", "context", "height", "query", "query-ready", "refresh-counter"]));
848
+ }
849
+ }), pt = /* @__PURE__ */ Q({
850
+ __name: "TimeseriesChartRenderer",
851
+ props: {
852
+ query: {},
853
+ context: {},
854
+ queryReady: { type: Boolean },
855
+ chartOptions: {},
856
+ height: {},
857
+ refreshCounter: {},
858
+ requestsLink: {}
859
+ },
860
+ emits: ["zoom-time-range", "select-chart-range"],
861
+ setup(c, { emit: e }) {
862
+ const t = e;
863
+ return (i, s) => (C(), M(Ze, {
864
+ "chart-options": i.chartOptions,
865
+ context: i.context,
866
+ height: i.height,
867
+ query: i.query,
868
+ "query-ready": i.queryReady,
869
+ "refresh-counter": i.refreshCounter,
870
+ "requests-link": i.requestsLink,
871
+ onSelectChartRange: s[0] || (s[0] = (r) => t("select-chart-range", r)),
872
+ onZoomTimeRange: s[1] || (s[1] = (r) => t("zoom-time-range", r))
873
+ }, null, 8, ["chart-options", "context", "height", "query", "query-ready", "refresh-counter", "requests-link"]));
874
+ }
875
+ }), Zi = { class: "metric-card-tile-wrapper" }, Ji = /* @__PURE__ */ Q({
876
+ __name: "GoldenSignalsRenderer",
877
+ props: {
878
+ query: {},
879
+ context: {},
880
+ queryReady: { type: Boolean },
881
+ chartOptions: {},
882
+ height: {},
883
+ refreshCounter: {},
884
+ requestsLink: {}
885
+ },
886
+ setup(c) {
887
+ const e = c, t = S(() => {
888
+ const s = e.context.timeSpec;
889
+ if (s.type === "absolute")
890
+ return new hi({
891
+ key: "custom",
892
+ timeframeText: "custom",
893
+ display: "custom",
894
+ startCustom: s.start,
895
+ endCustom: s.end,
896
+ timeframeLength: () => s.end.getTime() - s.start.getTime(),
897
+ defaultResponseGranularity: "daily",
898
+ dataGranularity: "daily",
899
+ isRelative: !1,
900
+ allowedTiers: ["free", "plus", "enterprise"]
901
+ });
902
+ const r = kt.get(s.time_range);
903
+ if (!r)
904
+ throw new Error("Unknown time range");
905
+ return r;
906
+ }), i = S(() => {
907
+ var r, o;
908
+ const s = (r = e.query) == null ? void 0 : r.datasource;
909
+ if (s && s !== "api_usage" && s !== "basic")
910
+ throw new Error(`Invalid datasource value: ${s}`);
911
+ return {
912
+ datasource: (o = e.query) == null ? void 0 : o.datasource,
913
+ overrideTimeframe: t.value,
914
+ tz: e.context.tz,
915
+ additionalFilter: e.context.filters,
916
+ // TODO: Decide how to handle metric card filters.
917
+ longCardTitles: e.chartOptions.long_card_titles,
918
+ percentileLatency: e.chartOptions.percentile_latency,
919
+ refreshInterval: e.context.refreshInterval,
920
+ queryReady: e.queryReady,
921
+ refreshCounter: e.refreshCounter
922
+ };
923
+ });
924
+ return (s, r) => (C(), V("div", Zi, [
925
+ se(k(xi), si(ri(i.value)), {
926
+ default: I(() => [
927
+ se(k(Ci))
928
+ ]),
929
+ _: 1
930
+ }, 16)
931
+ ]));
932
+ }
933
+ }), es = /* @__PURE__ */ ce(Ji, [["__scopeId", "data-v-7e1b1cc1"]]), yt = "#6c7489", ts = "12px", vt = "20px", Bt = "20px", is = {
934
+ class: "fallback-entity-link",
935
+ "data-testid": "entity-link-parent"
936
+ }, _t = /* @__PURE__ */ Q({
937
+ __name: "FallbackEntityLink",
938
+ props: {
939
+ entityLinkData: {}
940
+ },
941
+ setup(c) {
942
+ return (e, t) => (C(), V("div", is, te(e.entityLinkData.label), 1));
943
+ }
944
+ }), ss = /* @__PURE__ */ Q({
945
+ __name: "TopNTableRenderer",
946
+ props: {
947
+ query: {},
948
+ context: {},
949
+ queryReady: { type: Boolean },
950
+ chartOptions: {},
951
+ height: {},
952
+ refreshCounter: {},
953
+ requestsLink: {}
954
+ },
955
+ setup(c) {
956
+ const e = c, t = be(ue), i = Ct(async () => {
957
+ if (t != null && t.fetchComponent)
958
+ try {
959
+ return await t.fetchComponent("EntityLink");
960
+ } catch {
961
+ return _t;
962
+ }
963
+ return _t;
964
+ }), s = (r) => {
965
+ var o;
966
+ if ((o = e.chartOptions) != null && o.entity_link)
967
+ if (r.id.includes(":")) {
968
+ const [n, h] = r.id.split(":");
969
+ return e.chartOptions.entity_link.replace(Mi, n).replace(ut, h);
970
+ } else
971
+ return e.chartOptions.entity_link.replace(ut, r.id);
972
+ return "";
973
+ };
974
+ return (r, o) => (C(), M(Qe, {
975
+ context: r.context,
976
+ query: r.query,
977
+ "query-ready": r.queryReady,
978
+ "refresh-counter": r.refreshCounter
979
+ }, {
980
+ default: I(({ data: n }) => [
981
+ se(k(gi), {
982
+ data: n,
983
+ "synthetics-data-key": r.chartOptions.synthetics_data_key
984
+ }, je({ _: 2 }, [
985
+ e.chartOptions.entity_link ? {
986
+ name: "name",
987
+ fn: I(({ record: h }) => [
988
+ se(k(i), {
989
+ "entity-link-data": {
990
+ id: h.id,
991
+ label: h.name,
992
+ deleted: h.deleted
993
+ },
994
+ "external-link": s(h)
995
+ }, null, 8, ["entity-link-data", "external-link"])
996
+ ]),
997
+ key: "0"
998
+ } : void 0
999
+ ]), 1032, ["data", "synthetics-data-key"])
1000
+ ]),
1001
+ _: 1
1002
+ }, 8, ["context", "query", "query-ready", "refresh-counter"]));
1003
+ }
1004
+ }), rs = /* @__PURE__ */ Q({
1005
+ __name: "DonutChartRenderer",
1006
+ props: {
1007
+ query: {},
1008
+ context: {},
1009
+ queryReady: { type: Boolean },
1010
+ chartOptions: {},
1011
+ height: {},
1012
+ refreshCounter: {},
1013
+ requestsLink: {}
1014
+ },
1015
+ setup(c) {
1016
+ return (e, t) => (C(), M(Ze, {
1017
+ "chart-options": e.chartOptions,
1018
+ context: e.context,
1019
+ height: e.height,
1020
+ query: e.query,
1021
+ "query-ready": e.queryReady,
1022
+ "refresh-counter": e.refreshCounter
1023
+ }, null, 8, ["chart-options", "context", "height", "query", "query-ready", "refresh-counter"]));
1024
+ }
1025
+ }), ns = ["data-testid"], os = {
1026
+ key: 0,
1027
+ class: "tile-header"
1028
+ }, as = ["data-testid"], ls = { class: "badge-text" }, hs = ["data-testid"], ds = { class: "delete-option" }, us = ["data-testid"], cs = ["data-testid"], fs = /* @__PURE__ */ Q({
1029
+ __name: "DashboardTile",
1030
+ props: {
1031
+ definition: {},
1032
+ context: {},
1033
+ height: { default: $e },
1034
+ queryReady: { type: Boolean },
1035
+ refreshCounter: {},
1036
+ tileId: {}
1037
+ },
1038
+ emits: ["edit-tile", "duplicate-tile", "remove-tile", "tile-time-range-zoom"],
1039
+ setup(c, { emit: e }) {
1040
+ Ve((m) => ({
1041
+ "01c2c4e4": `${m.height}px`
1042
+ }));
1043
+ const t = parseInt(Bt, 10), i = c, s = e, r = Ct(() => import("./GeoMapRenderer-DqEby8vN.js")), o = be(ue), n = o == null ? void 0 : o.evaluateFeatureFlagFn("analytics-chart-zoom-actions", !1), { i18n: h } = _e.useI18n(), l = B(), d = B(!1), a = B(), f = B(!1), y = B(""), g = B(""), v = B(void 0), p = B(!0);
1044
+ Xe(async () => {
1045
+ var m, z;
1046
+ y.value = await ((m = o == null ? void 0 : o.exploreBaseUrl) == null ? void 0 : m.call(o)) ?? "", g.value = await ((z = o == null ? void 0 : o.requestsBaseUrl) == null ? void 0 : z.call(o)) ?? "";
1047
+ }), Ke(() => i.definition, async () => {
1048
+ await Rt(), a.value && (f.value = a.value.scrollWidth > a.value.clientWidth), p.value = !0;
1049
+ }, { immediate: !0, deep: !0 });
1050
+ const R = S(() => {
1051
+ if (!y.value || !i.definition.query || !E.value)
1052
+ return "";
1053
+ const m = Ft.value, z = i.definition.query.dimensions ?? [], O = {
1054
+ filters: m,
1055
+ metrics: i.definition.query.metrics ?? [],
1056
+ dimensions: z,
1057
+ time_range: i.definition.query.time_range || i.context.timeSpec,
1058
+ granularity: i.definition.query.granularity || fe.value
1059
+ }, F = ["api_usage", "llm_usage"].includes(i.definition.query.datasource) ? i.definition.query.datasource : "api_usage";
1060
+ return `${y.value}?q=${JSON.stringify(O)}&d=${F}&c=${i.definition.chart.type}`;
1061
+ }), H = S(() => {
1062
+ var m;
1063
+ return g.value && i.definition.query && ((m = i.definition.query) == null ? void 0 : m.datasource) !== "llm_usage";
1064
+ }), T = S(() => {
1065
+ if (!H.value || !E.value)
1066
+ return "";
1067
+ const m = [...i.context.filters, ...i.definition.query.filters ?? []], z = Qt(
1068
+ i.definition.query.time_range || i.context.timeSpec,
1069
+ m
1070
+ );
1071
+ return `${g.value}?q=${JSON.stringify(z)}`;
1072
+ }), q = S(() => h.t("csvExport.defaultFilename")), x = S(() => E.value && (A.value || i.context.editable) || !!oe.value), E = S(() => !["golden_signals", "top_n", "gauge"].includes(i.definition.chart.type)), A = S(() => !!R.value || "allow_csv_export" in i.definition.chart && i.definition.chart.allow_csv_export || i.context.editable), N = {
1073
+ timeseries_line: pt,
1074
+ timeseries_bar: pt,
1075
+ horizontal_bar: mt,
1076
+ vertical_bar: mt,
1077
+ gauge: gt,
1078
+ donut: rs,
1079
+ golden_signals: es,
1080
+ top_n: ss,
1081
+ slottable: void 0,
1082
+ single_value: gt,
1083
+ choropleth_map: r
1084
+ }, G = S(() => {
1085
+ var m, z;
1086
+ return {
1087
+ ...(m = U.value) != null && m.rendererEvents.supportsRequests ? { "select-chart-range": Jt } : {},
1088
+ ...(z = U.value) != null && z.rendererEvents.supportsZoom ? { "zoom-time-range": Xt } : {}
1089
+ };
1090
+ }), U = S(() => {
1091
+ var F, Y;
1092
+ const m = N[i.definition.chart.type], z = !!((F = m == null ? void 0 : m.emits) != null && F.includes("select-chart-range")), O = !!((Y = m == null ? void 0 : m.emits) != null && Y.includes("zoom-time-range"));
1093
+ return m && {
1094
+ component: m,
1095
+ rendererProps: {
1096
+ query: i.definition.query,
1097
+ context: i.context,
1098
+ queryReady: i.queryReady,
1099
+ chartOptions: i.definition.chart,
1100
+ height: i.height - t * 2,
1101
+ refreshCounter: i.refreshCounter,
1102
+ requestsLink: v.value
1103
+ },
1104
+ rendererEvents: {
1105
+ supportsRequests: z,
1106
+ supportsZoom: O
1107
+ }
1108
+ };
1109
+ }), oe = S(() => {
1110
+ var z;
1111
+ const m = (z = i.definition.query) == null ? void 0 : z.time_range;
1112
+ if ((m == null ? void 0 : m.type) === "relative") {
1113
+ const O = kt.get(di[m.time_range]);
1114
+ return O ? O.display : (console.warn("Did not recognize the given relative time range:", m.time_range), m.time_range);
1115
+ } else if ((m == null ? void 0 : m.type) === "absolute") {
1116
+ const O = m.tz || "Etc/UTC";
1117
+ return `${ht(m.start, { short: !0, tz: O })} - ${ht(m.end, { short: !0, tz: O })}`;
1118
+ }
1119
+ return null;
1120
+ }), fe = S(() => l.value ? dt(l.value.meta.granularity_ms) : void 0), ke = S(() => ["timeseries_line", "timeseries_bar"].includes(i.definition.chart.type)), tt = S(() => {
1121
+ var z, O;
1122
+ if (!ke.value || !i.queryReady || p.value)
1123
+ return !1;
1124
+ const m = (O = (z = i.definition) == null ? void 0 : z.query) == null ? void 0 : O.granularity;
1125
+ return !m || !fe.value ? !1 : m !== fe.value;
1126
+ }), Ut = S(() => {
1127
+ var O, F, Y;
1128
+ const m = dt(((O = l.value) == null ? void 0 : O.meta.granularity_ms) ?? 0) ?? "unknown", z = ((Y = (F = i.definition) == null ? void 0 : F.query) == null ? void 0 : Y.granularity) ?? "unknown";
1129
+ return h.t("query_aged_out_warning", {
1130
+ currentGranularity: h.t(`granularities.${m}`),
1131
+ savedGranularity: h.t(`granularities.${z}`)
1132
+ });
1133
+ }), Ft = S(() => {
1134
+ var O, F;
1135
+ const m = [...i.context.filters, ...i.definition.query.filters ?? []], z = ((F = (O = i.definition) == null ? void 0 : O.query) == null ? void 0 : F.datasource) ?? "api_usage";
1136
+ return m.filter((Y) => ui(Y.field).some((rt) => z === rt));
1137
+ }), Wt = () => {
1138
+ s("edit-tile", i.definition);
1139
+ }, Kt = () => {
1140
+ s("duplicate-tile", i.definition);
1141
+ }, Vt = () => {
1142
+ s("remove-tile", i.definition);
1143
+ }, Yt = (m) => {
1144
+ l.value = m, p.value = !1;
1145
+ }, it = (m) => {
1146
+ d.value = m;
1147
+ }, jt = () => {
1148
+ it(!0);
1149
+ }, Xt = (m) => {
1150
+ const z = {
1151
+ tileId: i.tileId.toString(),
1152
+ timeRange: m
1153
+ };
1154
+ s("tile-time-range-zoom", z);
1155
+ }, Qt = (m, z) => {
1156
+ var O, F;
1157
+ return {
1158
+ filter: z,
1159
+ timeframe: {
1160
+ timePeriodsKey: m.type === "relative" ? m.time_range : "custom",
1161
+ start: m.type === "absolute" ? (O = l.value) == null ? void 0 : O.meta.start_ms : void 0,
1162
+ end: m.type === "absolute" ? (F = l.value) == null ? void 0 : F.meta.end_ms : void 0
1163
+ }
1164
+ };
1165
+ }, Zt = (m, z) => ({
1166
+ filter: z,
1167
+ timeframe: {
1168
+ timePeriodsKey: m.type === "relative" ? m.time_range : "custom",
1169
+ start: m.type === "absolute" ? m.start : void 0,
1170
+ end: m.type === "absolute" ? m.end : void 0
1171
+ }
1172
+ }), Jt = (m) => {
1173
+ if (!H.value) {
1174
+ v.value = void 0;
1175
+ return;
1176
+ }
1177
+ const z = [...i.context.filters, ...i.definition.query.filters ?? []], O = Zt(m, z);
1178
+ v.value = { href: `${g.value}?q=${JSON.stringify(O)}` };
1179
+ };
1180
+ return (m, z) => {
1181
+ const O = de("KTooltip"), F = de("KBadge"), Y = de("KDropdownItem"), st = de("KDropdown");
1182
+ return C(), V("div", {
1183
+ class: Ye(["tile-boundary", { editable: m.context.editable }]),
1184
+ "data-testid": `tile-${m.tileId}`
1185
+ }, [
1186
+ m.definition.chart.type !== "slottable" ? (C(), V("div", os, [
1187
+ se(O, {
1188
+ class: "title-tooltip",
1189
+ disabled: !f.value,
1190
+ "max-width": "500",
1191
+ text: m.definition.chart.chart_title
1192
+ }, {
1193
+ default: I(() => [
1194
+ le("div", {
1195
+ ref_key: "titleRef",
1196
+ ref: a,
1197
+ class: "title"
1198
+ }, te(m.definition.chart.chart_title), 513)
1199
+ ]),
1200
+ _: 1
1201
+ }, 8, ["disabled", "text"]),
1202
+ x.value ? (C(), V("div", {
1203
+ key: 0,
1204
+ class: "tile-actions",
1205
+ "data-testid": `tile-actions-${m.tileId}`
1206
+ }, [
1207
+ oe.value ? (C(), M(F, {
1208
+ key: 0,
1209
+ "data-testid": "time-range-badge",
1210
+ tooltip: tt.value ? Ut.value : void 0,
1211
+ "tooltip-attributes": { maxWidth: "320px" }
1212
+ }, je({
1213
+ default: I(() => [
1214
+ le("span", ls, te(oe.value), 1)
1215
+ ]),
1216
+ _: 2
1217
+ }, [
1218
+ tt.value ? {
1219
+ name: "icon",
1220
+ fn: I(() => [
1221
+ se(k(bi), { size: k(ts) }, null, 8, ["size"])
1222
+ ]),
1223
+ key: "0"
1224
+ } : void 0
1225
+ ]), 1032, ["tooltip"])) : X("", !0),
1226
+ E.value && m.context.editable ? (C(), M(k(wi), {
1227
+ key: 1,
1228
+ class: "edit-icon",
1229
+ color: k(yt),
1230
+ "data-testid": `edit-tile-${m.tileId}`,
1231
+ size: k(vt),
1232
+ onClick: Wt
1233
+ }, null, 8, ["color", "data-testid", "size"])) : X("", !0),
1234
+ E.value && A.value ? (C(), M(st, {
1235
+ key: 2,
1236
+ class: "dropdown",
1237
+ "data-testid": `chart-action-menu-${m.tileId}`,
1238
+ "kpop-attributes": { placement: "bottom-end" }
1239
+ }, {
1240
+ items: I(() => [
1241
+ R.value ? (C(), M(Y, {
1242
+ key: 0,
1243
+ "data-testid": `chart-jump-to-explore-${m.tileId}`,
1244
+ item: { label: k(h).t("jumpToExplore"), to: R.value }
1245
+ }, null, 8, ["data-testid", "item"])) : X("", !0),
1246
+ k(n) && T.value ? (C(), M(Y, {
1247
+ key: 1,
1248
+ "data-testid": `chart-jump-to-requests-${m.tileId}`,
1249
+ item: { label: k(h).t("jumpToRequests"), to: T.value }
1250
+ }, null, 8, ["data-testid", "item"])) : X("", !0),
1251
+ !("allow_csv_export" in m.definition.chart) || m.definition.chart.allow_csv_export ? (C(), M(Y, {
1252
+ key: 2,
1253
+ class: "chart-export-button",
1254
+ "data-testid": `chart-csv-export-${m.tileId}`,
1255
+ onClick: z[0] || (z[0] = (rt) => jt())
1256
+ }, {
1257
+ default: I(() => [
1258
+ le("span", {
1259
+ class: "chart-export-trigger",
1260
+ "data-testid": `csv-export-button-${m.tileId}`
1261
+ }, te(k(h).t("csvExport.exportAsCsv")), 9, hs)
1262
+ ]),
1263
+ _: 1
1264
+ }, 8, ["data-testid"])) : X("", !0),
1265
+ m.context.editable ? (C(), M(Y, {
1266
+ key: 3,
1267
+ "data-testid": `duplicate-tile-${m.tileId}`,
1268
+ onClick: Kt
1269
+ }, {
1270
+ default: I(() => [
1271
+ Ee(te(k(h).t("renderer.duplicateTile")), 1)
1272
+ ]),
1273
+ _: 1
1274
+ }, 8, ["data-testid"])) : X("", !0),
1275
+ m.context.editable ? (C(), M(Y, {
1276
+ key: 4,
1277
+ "data-testid": `remove-tile-${m.tileId}`,
1278
+ onClick: Vt
1279
+ }, {
1280
+ default: I(() => [
1281
+ le("span", ds, te(k(h).t("renderer.delete")), 1)
1282
+ ]),
1283
+ _: 1
1284
+ }, 8, ["data-testid"])) : X("", !0)
1285
+ ]),
1286
+ default: I(() => [
1287
+ se(k(Ei), {
1288
+ class: "kebab-action-menu",
1289
+ color: k(yt),
1290
+ "data-testid": `kebab-action-menu-${m.tileId}`,
1291
+ size: k(vt)
1292
+ }, null, 8, ["color", "data-testid", "size"])
1293
+ ]),
1294
+ _: 1
1295
+ }, 8, ["data-testid"])) : X("", !0)
1296
+ ], 8, as)) : "description" in m.definition.chart ? (C(), V("div", {
1297
+ key: 1,
1298
+ class: "header-description",
1299
+ "data-testid": `tile-description-${m.tileId}`
1300
+ }, te(m.definition.chart.description), 9, us)) : X("", !0),
1301
+ d.value ? (C(), M(k(mi), {
1302
+ key: 2,
1303
+ "chart-data": l.value,
1304
+ "data-testid": `csv-export-modal-${m.tileId}`,
1305
+ filename: q.value,
1306
+ onToggleModal: it
1307
+ }, null, 8, ["chart-data", "data-testid", "filename"])) : X("", !0)
1308
+ ])) : X("", !0),
1309
+ le("div", {
1310
+ class: "tile-content",
1311
+ "data-testid": `tile-content-${m.tileId}`
1312
+ }, [
1313
+ U.value ? (C(), M(Tt(U.value.component), xt({ key: 0 }, U.value.rendererProps, ni(G.value), { onChartData: Yt }), null, 16)) : X("", !0)
1314
+ ], 8, cs)
1315
+ ], 10, ns);
1316
+ };
1317
+ }
1318
+ }), gs = /* @__PURE__ */ ce(fs, [["__scopeId", "data-v-81f91604"]]), ms = (c, e) => {
1319
+ let t = 0;
1320
+ const i = /* @__PURE__ */ new Map();
1321
+ e.forEach((r) => {
1322
+ const o = r.layout.position.row, n = i.get(o), h = r.layout.size.rows === 1 && !!r.layout.size.fit_to_content;
1323
+ t = Math.max(t, o + r.layout.size.rows), n === void 0 ? i.set(o, h) : i.set(o, n && h);
1324
+ });
1325
+ const s = [];
1326
+ for (let r = 0; r < t; r++)
1327
+ i.get(r) ? s.push("auto") : s.push(`${c}px`);
1328
+ return s;
1329
+ }, ps = /* @__PURE__ */ Q({
1330
+ __name: "GridLayout",
1331
+ props: {
1332
+ tileHeight: {
1333
+ type: Number,
1334
+ required: !1,
1335
+ default: () => $e
1336
+ },
1337
+ tiles: {
1338
+ type: Array,
1339
+ required: !0
1340
+ }
1341
+ },
1342
+ setup(c) {
1343
+ Ve((n) => ({
1344
+ "2a38e79e": k(At),
1345
+ "4cc71de6": r.value
1346
+ }));
1347
+ const e = c, t = B(null), i = B(0), s = new ResizeObserver((n) => {
1348
+ window.requestAnimationFrame(() => {
1349
+ !Array.isArray(n) || !n.length || (i.value = n[0].contentRect.width);
1350
+ });
1351
+ });
1352
+ Xe(() => {
1353
+ t.value && s.observe(t.value);
1354
+ }), We(() => {
1355
+ t.value && s.unobserve(t.value);
1356
+ });
1357
+ const r = S(() => ms(e.tileHeight, e.tiles).join(" ")), o = S(() => e.tiles.map((n, h) => ({
1358
+ key: `tile-${h}`,
1359
+ tile: n,
1360
+ style: {
1361
+ "grid-column-start": n.layout.position.col + 1,
1362
+ "grid-column-end": n.layout.position.col + 1 + n.layout.size.cols,
1363
+ "grid-row-start": n.layout.position.row + 1,
1364
+ "grid-row-end": n.layout.position.row + 1 + n.layout.size.rows
1365
+ }
1366
+ })));
1367
+ return (n, h) => (C(), V("div", {
1368
+ ref_key: "gridContainer",
1369
+ ref: t,
1370
+ class: "kong-ui-public-grid-layout"
1371
+ }, [
1372
+ (C(!0), V(zt, null, Dt(o.value, (l) => (C(), V("div", {
1373
+ key: l.key,
1374
+ class: Ye(["grid-cell", {
1375
+ "empty-cell": !l.tile
1376
+ }]),
1377
+ style: at(l.style)
1378
+ }, [
1379
+ Pe(n.$slots, "tile", {
1380
+ style: at(l.style),
1381
+ tile: l.tile
1382
+ }, void 0, !0)
1383
+ ], 6))), 128))
1384
+ ], 512));
1385
+ }
1386
+ }), ys = /* @__PURE__ */ ce(ps, [["__scopeId", "data-v-354b7177"]]);
1387
+ function vs(c, e, t, i, s) {
1388
+ const r = (...o) => (console.warn("gridstack.js: Function `" + t + "` is deprecated in " + s + " and has been replaced with `" + i + "`. It will be **removed** in a future release"), e.apply(c, o));
1389
+ return r.prototype = e.prototype, r;
1390
+ }
1391
+ class u {
1392
+ /** convert a potential selector into actual list of html elements. optional root which defaults to document (for shadow dom) */
1393
+ static getElements(e, t = document) {
1394
+ if (typeof e == "string") {
1395
+ const i = "getElementById" in t ? t : void 0;
1396
+ if (i && !isNaN(+e[0])) {
1397
+ const r = i.getElementById(e);
1398
+ return r ? [r] : [];
1399
+ }
1400
+ let s = t.querySelectorAll(e);
1401
+ return !s.length && e[0] !== "." && e[0] !== "#" && (s = t.querySelectorAll("." + e), s.length || (s = t.querySelectorAll("#" + e))), Array.from(s);
1402
+ }
1403
+ return [e];
1404
+ }
1405
+ /** convert a potential selector into actual single element. optional root which defaults to document (for shadow dom) */
1406
+ static getElement(e, t = document) {
1407
+ if (typeof e == "string") {
1408
+ const i = "getElementById" in t ? t : void 0;
1409
+ if (!e.length)
1410
+ return null;
1411
+ if (i && e[0] === "#")
1412
+ return i.getElementById(e.substring(1));
1413
+ if (e[0] === "#" || e[0] === "." || e[0] === "[")
1414
+ return t.querySelector(e);
1415
+ if (i && !isNaN(+e[0]))
1416
+ return i.getElementById(e);
1417
+ let s = t.querySelector(e);
1418
+ return i && !s && (s = i.getElementById(e)), s || (s = t.querySelector("." + e)), s;
1419
+ }
1420
+ return e;
1421
+ }
1422
+ /** true if widget (or grid) makes this item lazyLoad */
1423
+ static lazyLoad(e) {
1424
+ var t, i;
1425
+ return e.lazyLoad || ((i = (t = e.grid) == null ? void 0 : t.opts) == null ? void 0 : i.lazyLoad) && e.lazyLoad !== !1;
1426
+ }
1427
+ /** create a div with the given classes */
1428
+ static createDiv(e, t) {
1429
+ const i = document.createElement("div");
1430
+ return e.forEach((s) => {
1431
+ s && i.classList.add(s);
1432
+ }), t == null || t.appendChild(i), i;
1433
+ }
1434
+ /** true if we should resize to content. strict=true when only 'sizeToContent:true' and not a number which lets user adjust */
1435
+ static shouldSizeToContent(e, t = !1) {
1436
+ return (e == null ? void 0 : e.grid) && (t ? e.sizeToContent === !0 || e.grid.opts.sizeToContent === !0 && e.sizeToContent === void 0 : !!e.sizeToContent || e.grid.opts.sizeToContent && e.sizeToContent !== !1);
1437
+ }
1438
+ /** returns true if a and b overlap */
1439
+ static isIntercepted(e, t) {
1440
+ return !(e.y >= t.y + t.h || e.y + e.h <= t.y || e.x + e.w <= t.x || e.x >= t.x + t.w);
1441
+ }
1442
+ /** returns true if a and b touch edges or corners */
1443
+ static isTouching(e, t) {
1444
+ return u.isIntercepted(e, { x: t.x - 0.5, y: t.y - 0.5, w: t.w + 1, h: t.h + 1 });
1445
+ }
1446
+ /** returns the area a and b overlap */
1447
+ static areaIntercept(e, t) {
1448
+ const i = e.x > t.x ? e.x : t.x, s = e.x + e.w < t.x + t.w ? e.x + e.w : t.x + t.w;
1449
+ if (s <= i)
1450
+ return 0;
1451
+ const r = e.y > t.y ? e.y : t.y, o = e.y + e.h < t.y + t.h ? e.y + e.h : t.y + t.h;
1452
+ return o <= r ? 0 : (s - i) * (o - r);
1453
+ }
1454
+ /** returns the area */
1455
+ static area(e) {
1456
+ return e.w * e.h;
1457
+ }
1458
+ /**
1459
+ * Sorts array of nodes
1460
+ * @param nodes array to sort
1461
+ * @param dir 1 for ascending, -1 for descending (optional)
1462
+ **/
1463
+ static sort(e, t = 1) {
1464
+ return e.sort((s, r) => {
1465
+ const o = t * ((s.y ?? 1e4) - (r.y ?? 1e4));
1466
+ return o === 0 ? t * ((s.x ?? 1e4) - (r.x ?? 1e4)) : o;
1467
+ });
1468
+ }
1469
+ /** find an item by id */
1470
+ static find(e, t) {
1471
+ return t ? e.find((i) => i.id === t) : void 0;
1472
+ }
1473
+ /**
1474
+ * creates a style sheet with style id under given parent
1475
+ * @param id will set the 'gs-style-id' attribute to that id
1476
+ * @param parent to insert the stylesheet as first child,
1477
+ * if none supplied it will be appended to the document head instead.
1478
+ */
1479
+ static createStylesheet(e, t, i) {
1480
+ const s = document.createElement("style"), r = i == null ? void 0 : i.nonce;
1481
+ return r && (s.nonce = r), s.setAttribute("type", "text/css"), s.setAttribute("gs-style-id", e), s.styleSheet ? s.styleSheet.cssText = "" : s.appendChild(document.createTextNode("")), t ? t.insertBefore(s, t.firstChild) : (t = document.getElementsByTagName("head")[0], t.appendChild(s)), s;
1482
+ }
1483
+ /** removed the given stylesheet id */
1484
+ static removeStylesheet(e, t) {
1485
+ const s = (t || document).querySelector("STYLE[gs-style-id=" + e + "]");
1486
+ s && s.parentNode && s.remove();
1487
+ }
1488
+ /** inserts a CSS rule */
1489
+ static addCSSRule(e, t, i) {
1490
+ e.textContent += `${t} { ${i} } `;
1491
+ }
1492
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1493
+ static toBool(e) {
1494
+ return typeof e == "boolean" ? e : typeof e == "string" ? (e = e.toLowerCase(), !(e === "" || e === "no" || e === "false" || e === "0")) : !!e;
1495
+ }
1496
+ static toNumber(e) {
1497
+ return e === null || e.length === 0 ? void 0 : Number(e);
1498
+ }
1499
+ static parseHeight(e) {
1500
+ let t, i = "px";
1501
+ if (typeof e == "string")
1502
+ if (e === "auto" || e === "")
1503
+ t = 0;
1504
+ else {
1505
+ const s = e.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);
1506
+ if (!s)
1507
+ throw new Error(`Invalid height val = ${e}`);
1508
+ i = s[2] || "px", t = parseFloat(s[1]);
1509
+ }
1510
+ else
1511
+ t = e;
1512
+ return { h: t, unit: i };
1513
+ }
1514
+ /** copies unset fields in target to use the given default sources values */
1515
+ // eslint-disable-next-line
1516
+ static defaults(e, ...t) {
1517
+ return t.forEach((i) => {
1518
+ for (const s in i) {
1519
+ if (!i.hasOwnProperty(s))
1520
+ return;
1521
+ e[s] === null || e[s] === void 0 ? e[s] = i[s] : typeof i[s] == "object" && typeof e[s] == "object" && this.defaults(e[s], i[s]);
1522
+ }
1523
+ }), e;
1524
+ }
1525
+ /** given 2 objects return true if they have the same values. Checks for Object {} having same fields and values (just 1 level down) */
1526
+ static same(e, t) {
1527
+ if (typeof e != "object")
1528
+ return e == t;
1529
+ if (typeof e != typeof t || Object.keys(e).length !== Object.keys(t).length)
1530
+ return !1;
1531
+ for (const i in e)
1532
+ if (e[i] !== t[i])
1533
+ return !1;
1534
+ return !0;
1535
+ }
1536
+ /** copies over b size & position (GridStackPosition), and optionally min/max as well */
1537
+ static copyPos(e, t, i = !1) {
1538
+ return t.x !== void 0 && (e.x = t.x), t.y !== void 0 && (e.y = t.y), t.w !== void 0 && (e.w = t.w), t.h !== void 0 && (e.h = t.h), i && (t.minW && (e.minW = t.minW), t.minH && (e.minH = t.minH), t.maxW && (e.maxW = t.maxW), t.maxH && (e.maxH = t.maxH)), e;
1539
+ }
1540
+ /** true if a and b has same size & position */
1541
+ static samePos(e, t) {
1542
+ return e && t && e.x === t.x && e.y === t.y && (e.w || 1) === (t.w || 1) && (e.h || 1) === (t.h || 1);
1543
+ }
1544
+ /** given a node, makes sure it's min/max are valid */
1545
+ static sanitizeMinMax(e) {
1546
+ e.minW || delete e.minW, e.minH || delete e.minH, e.maxW || delete e.maxW, e.maxH || delete e.maxH;
1547
+ }
1548
+ /** removes field from the first object if same as the second objects (like diffing) and internal '_' for saving */
1549
+ static removeInternalAndSame(e, t) {
1550
+ if (!(typeof e != "object" || typeof t != "object"))
1551
+ for (let i in e) {
1552
+ const s = e[i], r = t[i];
1553
+ i[0] === "_" || s === r ? delete e[i] : s && typeof s == "object" && r !== void 0 && (u.removeInternalAndSame(s, r), Object.keys(s).length || delete e[i]);
1554
+ }
1555
+ }
1556
+ /** removes internal fields '_' and default values for saving */
1557
+ static removeInternalForSave(e, t = !0) {
1558
+ for (let i in e)
1559
+ (i[0] === "_" || e[i] === null || e[i] === void 0) && delete e[i];
1560
+ delete e.grid, t && delete e.el, e.autoPosition || delete e.autoPosition, e.noResize || delete e.noResize, e.noMove || delete e.noMove, e.locked || delete e.locked, (e.w === 1 || e.w === e.minW) && delete e.w, (e.h === 1 || e.h === e.minH) && delete e.h;
1561
+ }
1562
+ /** return the closest parent (or itself) matching the given class */
1563
+ // static closestUpByClass(el: HTMLElement, name: string): HTMLElement {
1564
+ // while (el) {
1565
+ // if (el.classList.contains(name)) return el;
1566
+ // el = el.parentElement
1567
+ // }
1568
+ // return null;
1569
+ // }
1570
+ /** delay calling the given function for given delay, preventing new calls from happening while waiting */
1571
+ static throttle(e, t) {
1572
+ let i = !1;
1573
+ return (...s) => {
1574
+ i || (i = !0, setTimeout(() => {
1575
+ e(...s), i = !1;
1576
+ }, t));
1577
+ };
1578
+ }
1579
+ static removePositioningStyles(e) {
1580
+ const t = e.style;
1581
+ t.position && t.removeProperty("position"), t.left && t.removeProperty("left"), t.top && t.removeProperty("top"), t.width && t.removeProperty("width"), t.height && t.removeProperty("height");
1582
+ }
1583
+ /** @internal returns the passed element if scrollable, else the closest parent that will, up to the entire document scrolling element */
1584
+ static getScrollElement(e) {
1585
+ if (!e)
1586
+ return document.scrollingElement || document.documentElement;
1587
+ const t = getComputedStyle(e);
1588
+ return /(auto|scroll)/.test(t.overflow + t.overflowY) ? e : this.getScrollElement(e.parentElement);
1589
+ }
1590
+ /** @internal */
1591
+ static updateScrollPosition(e, t, i) {
1592
+ const s = e.getBoundingClientRect(), r = window.innerHeight || document.documentElement.clientHeight;
1593
+ if (s.top < 0 || s.bottom > r) {
1594
+ const o = s.bottom - r, n = s.top, h = this.getScrollElement(e);
1595
+ if (h !== null) {
1596
+ const l = h.scrollTop;
1597
+ s.top < 0 && i < 0 ? e.offsetHeight > r ? h.scrollTop += i : h.scrollTop += Math.abs(n) > Math.abs(i) ? i : n : i > 0 && (e.offsetHeight > r ? h.scrollTop += i : h.scrollTop += o > i ? i : o), t.top += h.scrollTop - l;
1598
+ }
1599
+ }
1600
+ }
1601
+ /**
1602
+ * @internal Function used to scroll the page.
1603
+ *
1604
+ * @param event `MouseEvent` that triggers the resize
1605
+ * @param el `HTMLElement` that's being resized
1606
+ * @param distance Distance from the V edges to start scrolling
1607
+ */
1608
+ static updateScrollResize(e, t, i) {
1609
+ const s = this.getScrollElement(t), r = s.clientHeight, o = s === this.getScrollElement() ? 0 : s.getBoundingClientRect().top, n = e.clientY - o, h = n < i, l = n > r - i;
1610
+ h ? s.scrollBy({ behavior: "smooth", top: n - i }) : l && s.scrollBy({ behavior: "smooth", top: i - (r - n) });
1611
+ }
1612
+ /** single level clone, returning a new object with same top fields. This will share sub objects and arrays */
1613
+ static clone(e) {
1614
+ return e == null || typeof e != "object" ? e : e instanceof Array ? [...e] : { ...e };
1615
+ }
1616
+ /**
1617
+ * Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY.
1618
+ * Note: this will use as-is any key starting with double __ (and not copy inside) some lib have circular dependencies.
1619
+ */
1620
+ static cloneDeep(e) {
1621
+ const t = ["parentGrid", "el", "grid", "subGrid", "engine"], i = u.clone(e);
1622
+ for (const s in i)
1623
+ i.hasOwnProperty(s) && typeof i[s] == "object" && s.substring(0, 2) !== "__" && !t.find((r) => r === s) && (i[s] = u.cloneDeep(e[s]));
1624
+ return i;
1625
+ }
1626
+ /** deep clone the given HTML node, removing teh unique id field */
1627
+ static cloneNode(e) {
1628
+ const t = e.cloneNode(!0);
1629
+ return t.removeAttribute("id"), t;
1630
+ }
1631
+ static appendTo(e, t) {
1632
+ let i;
1633
+ typeof t == "string" ? i = u.getElement(t) : i = t, i && i.appendChild(e);
1634
+ }
1635
+ // public static setPositionRelative(el: HTMLElement): void {
1636
+ // if (!(/^(?:r|a|f)/).test(getComputedStyle(el).position)) {
1637
+ // el.style.position = "relative";
1638
+ // }
1639
+ // }
1640
+ static addElStyles(e, t) {
1641
+ if (t instanceof Object)
1642
+ for (const i in t)
1643
+ t.hasOwnProperty(i) && (Array.isArray(t[i]) ? t[i].forEach((s) => {
1644
+ e.style[i] = s;
1645
+ }) : e.style[i] = t[i]);
1646
+ }
1647
+ static initEvent(e, t) {
1648
+ const i = { type: t.type }, s = {
1649
+ button: 0,
1650
+ which: 0,
1651
+ buttons: 1,
1652
+ bubbles: !0,
1653
+ cancelable: !0,
1654
+ target: t.target ? t.target : e.target
1655
+ };
1656
+ return ["altKey", "ctrlKey", "metaKey", "shiftKey"].forEach((r) => i[r] = e[r]), ["pageX", "pageY", "clientX", "clientY", "screenX", "screenY"].forEach((r) => i[r] = e[r]), { ...i, ...s };
1657
+ }
1658
+ /** copies the MouseEvent (or convert Touch) properties and sends it as another event to the given target */
1659
+ static simulateMouseEvent(e, t, i) {
1660
+ const s = e, r = new MouseEvent(t, {
1661
+ bubbles: !0,
1662
+ composed: !0,
1663
+ cancelable: !0,
1664
+ view: window,
1665
+ detail: 1,
1666
+ screenX: e.screenX,
1667
+ screenY: e.screenY,
1668
+ clientX: e.clientX,
1669
+ clientY: e.clientY,
1670
+ ctrlKey: s.ctrlKey ?? !1,
1671
+ altKey: s.altKey ?? !1,
1672
+ shiftKey: s.shiftKey ?? !1,
1673
+ metaKey: s.metaKey ?? !1,
1674
+ button: 0,
1675
+ relatedTarget: e.target
1676
+ });
1677
+ (i || e.target).dispatchEvent(r);
1678
+ }
1679
+ /**
1680
+ * defines an element that is used to get the offset and scale from grid transforms
1681
+ * returns the scale and offsets from said element
1682
+ */
1683
+ static getValuesFromTransformedElement(e) {
1684
+ const t = document.createElement("div");
1685
+ u.addElStyles(t, {
1686
+ opacity: "0",
1687
+ position: "fixed",
1688
+ top: "0px",
1689
+ left: "0px",
1690
+ width: "1px",
1691
+ height: "1px",
1692
+ zIndex: "-999999"
1693
+ }), e.appendChild(t);
1694
+ const i = t.getBoundingClientRect();
1695
+ return e.removeChild(t), t.remove(), {
1696
+ xScale: 1 / i.width,
1697
+ yScale: 1 / i.height,
1698
+ xOffset: i.left,
1699
+ yOffset: i.top
1700
+ };
1701
+ }
1702
+ /** swap the given object 2 field values */
1703
+ static swap(e, t, i) {
1704
+ if (!e)
1705
+ return;
1706
+ const s = e[t];
1707
+ e[t] = e[i], e[i] = s;
1708
+ }
1709
+ /** returns true if event is inside the given element rectangle */
1710
+ // Note: Safari Mac has null event.relatedTarget which causes #1684 so check if DragEvent is inside the coordinates instead
1711
+ // this.el.contains(event.relatedTarget as HTMLElement)
1712
+ // public static inside(e: MouseEvent, el: HTMLElement): boolean {
1713
+ // // srcElement, toElement, target: all set to placeholder when leaving simple grid, so we can't use that (Chrome)
1714
+ // const target: HTMLElement = e.relatedTarget || (e as any).fromElement;
1715
+ // if (!target) {
1716
+ // const { bottom, left, right, top } = el.getBoundingClientRect();
1717
+ // return (e.x < right && e.x > left && e.y < bottom && e.y > top);
1718
+ // }
1719
+ // return el.contains(target);
1720
+ // }
1721
+ /** true if the item can be rotated (checking for prop, not space available) */
1722
+ static canBeRotated(e) {
1723
+ var t;
1724
+ return !(!e || e.w === e.h || e.locked || e.noResize || (t = e.grid) != null && t.opts.disableResize || e.minW && e.minW === e.maxW || e.minH && e.minH === e.maxH);
1725
+ }
1726
+ }
1727
+ class re {
1728
+ constructor(e = {}) {
1729
+ this.addedNodes = [], this.removedNodes = [], this.defaultColumn = 12, this.column = e.column || this.defaultColumn, this.column > this.defaultColumn && (this.defaultColumn = this.column), this.maxRow = e.maxRow, this._float = e.float, this.nodes = e.nodes || [], this.onChange = e.onChange;
1730
+ }
1731
+ batchUpdate(e = !0, t = !0) {
1732
+ return !!this.batchMode === e ? this : (this.batchMode = e, e ? (this._prevFloat = this._float, this._float = !0, this.cleanNodes(), this.saveInitial()) : (this._float = this._prevFloat, delete this._prevFloat, t && this._packNodes(), this._notify()), this);
1733
+ }
1734
+ // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip
1735
+ _useEntireRowArea(e, t) {
1736
+ return (!this.float || this.batchMode && !this._prevFloat) && !this._hasLocked && (!e._moving || e._skipDown || t.y <= e.y);
1737
+ }
1738
+ /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.
1739
+ * return true if we moved. */
1740
+ _fixCollisions(e, t = e, i, s = {}) {
1741
+ if (this.sortNodes(-1), i = i || this.collide(e, t), !i)
1742
+ return !1;
1743
+ if (e._moving && !s.nested && !this.float && this.swap(e, i))
1744
+ return !0;
1745
+ let r = t;
1746
+ !this._loading && this._useEntireRowArea(e, t) && (r = { x: 0, w: this.column, y: t.y, h: t.h }, i = this.collide(e, r, s.skip));
1747
+ let o = !1;
1748
+ const n = { nested: !0, pack: !1 };
1749
+ let h = 0;
1750
+ for (; i = i || this.collide(e, r, s.skip); ) {
1751
+ if (h++ > this.nodes.length * 2)
1752
+ throw new Error("Infinite collide check");
1753
+ let l;
1754
+ if (i.locked || this._loading || e._moving && !e._skipDown && t.y > e.y && !this.float && // can take space we had, or before where we're going
1755
+ (!this.collide(i, { ...i, y: e.y }, e) || !this.collide(i, { ...i, y: t.y - i.h }, e))) {
1756
+ e._skipDown = e._skipDown || t.y > e.y;
1757
+ const d = { ...t, y: i.y + i.h, ...n };
1758
+ l = this._loading && u.samePos(e, d) ? !0 : this.moveNode(e, d), (i.locked || this._loading) && l ? u.copyPos(t, e) : !i.locked && l && s.pack && (this._packNodes(), t.y = i.y + i.h, u.copyPos(e, t)), o = o || l;
1759
+ } else
1760
+ l = this.moveNode(i, { ...i, y: t.y + t.h, skip: e, ...n });
1761
+ if (!l)
1762
+ return o;
1763
+ i = void 0;
1764
+ }
1765
+ return o;
1766
+ }
1767
+ /** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */
1768
+ collide(e, t = e, i) {
1769
+ const s = e._id, r = i == null ? void 0 : i._id;
1770
+ return this.nodes.find((o) => o._id !== s && o._id !== r && u.isIntercepted(o, t));
1771
+ }
1772
+ collideAll(e, t = e, i) {
1773
+ const s = e._id, r = i == null ? void 0 : i._id;
1774
+ return this.nodes.filter((o) => o._id !== s && o._id !== r && u.isIntercepted(o, t));
1775
+ }
1776
+ /** does a pixel coverage collision based on where we started, returning the node that has the most coverage that is >50% mid line */
1777
+ directionCollideCoverage(e, t, i) {
1778
+ if (!t.rect || !e._rect)
1779
+ return;
1780
+ const s = e._rect, r = { ...t.rect };
1781
+ r.y > s.y ? (r.h += r.y - s.y, r.y = s.y) : r.h += s.y - r.y, r.x > s.x ? (r.w += r.x - s.x, r.x = s.x) : r.w += s.x - r.x;
1782
+ let o, n = 0.5;
1783
+ for (let h of i) {
1784
+ if (h.locked || !h._rect)
1785
+ break;
1786
+ const l = h._rect;
1787
+ let d = Number.MAX_VALUE, a = Number.MAX_VALUE;
1788
+ s.y < l.y ? d = (r.y + r.h - l.y) / l.h : s.y + s.h > l.y + l.h && (d = (l.y + l.h - r.y) / l.h), s.x < l.x ? a = (r.x + r.w - l.x) / l.w : s.x + s.w > l.x + l.w && (a = (l.x + l.w - r.x) / l.w);
1789
+ const f = Math.min(a, d);
1790
+ f > n && (n = f, o = h);
1791
+ }
1792
+ return t.collide = o, o;
1793
+ }
1794
+ /** does a pixel coverage returning the node that has the most coverage by area */
1795
+ /*
1796
+ protected collideCoverage(r: GridStackPosition, collides: GridStackNode[]): {collide: GridStackNode, over: number} {
1797
+ const collide: GridStackNode;
1798
+ const overMax = 0;
1799
+ collides.forEach(n => {
1800
+ if (n.locked || !n._rect) return;
1801
+ const over = Utils.areaIntercept(r, n._rect);
1802
+ if (over > overMax) {
1803
+ overMax = over;
1804
+ collide = n;
1805
+ }
1806
+ });
1807
+ return {collide, over: overMax};
1808
+ }
1809
+ */
1810
+ /** called to cache the nodes pixel rectangles used for collision detection during drag */
1811
+ cacheRects(e, t, i, s, r, o) {
1812
+ return this.nodes.forEach((n) => n._rect = {
1813
+ y: n.y * t + i,
1814
+ x: n.x * e + o,
1815
+ w: n.w * e - o - s,
1816
+ h: n.h * t - i - r
1817
+ }), this;
1818
+ }
1819
+ /** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */
1820
+ swap(e, t) {
1821
+ if (!t || t.locked || !e || e.locked)
1822
+ return !1;
1823
+ function i() {
1824
+ const r = t.x, o = t.y;
1825
+ return t.x = e.x, t.y = e.y, e.h != t.h ? (e.x = r, e.y = t.y + t.h) : e.w != t.w ? (e.x = t.x + t.w, e.y = o) : (e.x = r, e.y = o), e._dirty = t._dirty = !0, !0;
1826
+ }
1827
+ let s;
1828
+ if (e.w === t.w && e.h === t.h && (e.x === t.x || e.y === t.y) && (s = u.isTouching(e, t)))
1829
+ return i();
1830
+ if (s !== !1) {
1831
+ if (e.w === t.w && e.x === t.x && (s || (s = u.isTouching(e, t)))) {
1832
+ if (t.y < e.y) {
1833
+ const r = e;
1834
+ e = t, t = r;
1835
+ }
1836
+ return i();
1837
+ }
1838
+ if (s !== !1) {
1839
+ if (e.h === t.h && e.y === t.y && (s || (s = u.isTouching(e, t)))) {
1840
+ if (t.x < e.x) {
1841
+ const r = e;
1842
+ e = t, t = r;
1843
+ }
1844
+ return i();
1845
+ }
1846
+ return !1;
1847
+ }
1848
+ }
1849
+ }
1850
+ isAreaEmpty(e, t, i, s) {
1851
+ const r = { x: e || 0, y: t || 0, w: i || 1, h: s || 1 };
1852
+ return !this.collide(r);
1853
+ }
1854
+ /** re-layout grid items to reclaim any empty space - optionally keeping the sort order exactly the same ('list' mode) vs truly finding an empty spaces */
1855
+ compact(e = "compact", t = !0) {
1856
+ if (this.nodes.length === 0)
1857
+ return this;
1858
+ t && this.sortNodes();
1859
+ const i = this.batchMode;
1860
+ i || this.batchUpdate();
1861
+ const s = this._inColumnResize;
1862
+ s || (this._inColumnResize = !0);
1863
+ const r = this.nodes;
1864
+ return this.nodes = [], r.forEach((o, n, h) => {
1865
+ let l;
1866
+ o.locked || (o.autoPosition = !0, e === "list" && n && (l = h[n - 1])), this.addNode(o, !1, l);
1867
+ }), s || delete this._inColumnResize, i || this.batchUpdate(!1), this;
1868
+ }
1869
+ /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */
1870
+ set float(e) {
1871
+ this._float !== e && (this._float = e || !1, e || this._packNodes()._notify());
1872
+ }
1873
+ /** float getter method */
1874
+ get float() {
1875
+ return this._float || !1;
1876
+ }
1877
+ /** sort the nodes array from first to last, or reverse. Called during collision/placement to force an order */
1878
+ sortNodes(e = 1) {
1879
+ return this.nodes = u.sort(this.nodes, e), this;
1880
+ }
1881
+ /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */
1882
+ _packNodes() {
1883
+ return this.batchMode ? this : (this.sortNodes(), this.float ? this.nodes.forEach((e) => {
1884
+ if (e._updating || e._orig === void 0 || e.y === e._orig.y)
1885
+ return;
1886
+ let t = e.y;
1887
+ for (; t > e._orig.y; )
1888
+ --t, this.collide(e, { x: e.x, y: t, w: e.w, h: e.h }) || (e._dirty = !0, e.y = t);
1889
+ }) : this.nodes.forEach((e, t) => {
1890
+ if (!e.locked)
1891
+ for (; e.y > 0; ) {
1892
+ const i = t === 0 ? 0 : e.y - 1;
1893
+ if (!(t === 0 || !this.collide(e, { x: e.x, y: i, w: e.w, h: e.h })))
1894
+ break;
1895
+ e._dirty = e.y !== i, e.y = i;
1896
+ }
1897
+ }), this);
1898
+ }
1899
+ /**
1900
+ * given a random node, makes sure it's coordinates/values are valid in the current grid
1901
+ * @param node to adjust
1902
+ * @param resizing if out of bound, resize down or move into the grid to fit ?
1903
+ */
1904
+ prepareNode(e, t) {
1905
+ e._id = e._id ?? re._idSeq++;
1906
+ const i = e.id;
1907
+ if (i) {
1908
+ let r = 1;
1909
+ for (; this.nodes.find((o) => o.id === e.id && o !== e); )
1910
+ e.id = i + "_" + r++;
1911
+ }
1912
+ (e.x === void 0 || e.y === void 0 || e.x === null || e.y === null) && (e.autoPosition = !0);
1913
+ const s = { x: 0, y: 0, w: 1, h: 1 };
1914
+ return u.defaults(e, s), e.autoPosition || delete e.autoPosition, e.noResize || delete e.noResize, e.noMove || delete e.noMove, u.sanitizeMinMax(e), typeof e.x == "string" && (e.x = Number(e.x)), typeof e.y == "string" && (e.y = Number(e.y)), typeof e.w == "string" && (e.w = Number(e.w)), typeof e.h == "string" && (e.h = Number(e.h)), isNaN(e.x) && (e.x = s.x, e.autoPosition = !0), isNaN(e.y) && (e.y = s.y, e.autoPosition = !0), isNaN(e.w) && (e.w = s.w), isNaN(e.h) && (e.h = s.h), this.nodeBoundFix(e, t), e;
1915
+ }
1916
+ /** part2 of preparing a node to fit inside our grid - checks for x,y,w from grid dimensions */
1917
+ nodeBoundFix(e, t) {
1918
+ const i = e._orig || u.copyPos({}, e);
1919
+ if (e.maxW && (e.w = Math.min(e.w || 1, e.maxW)), e.maxH && (e.h = Math.min(e.h || 1, e.maxH)), e.minW && (e.w = Math.max(e.w || 1, e.minW)), e.minH && (e.h = Math.max(e.h || 1, e.minH)), (e.x || 0) + (e.w || 1) > this.column && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && e._id && this.findCacheLayout(e, this.defaultColumn) === -1) {
1920
+ const r = { ...e };
1921
+ r.autoPosition || r.x === void 0 ? (delete r.x, delete r.y) : r.x = Math.min(this.defaultColumn - 1, r.x), r.w = Math.min(this.defaultColumn, r.w || 1), this.cacheOneLayout(r, this.defaultColumn);
1922
+ }
1923
+ return e.w > this.column ? e.w = this.column : e.w < 1 && (e.w = 1), this.maxRow && e.h > this.maxRow ? e.h = this.maxRow : e.h < 1 && (e.h = 1), e.x < 0 && (e.x = 0), e.y < 0 && (e.y = 0), e.x + e.w > this.column && (t ? e.w = this.column - e.x : e.x = this.column - e.w), this.maxRow && e.y + e.h > this.maxRow && (t ? e.h = this.maxRow - e.y : e.y = this.maxRow - e.h), u.samePos(e, i) || (e._dirty = !0), this;
1924
+ }
1925
+ /** returns a list of modified nodes from their original values */
1926
+ getDirtyNodes(e) {
1927
+ return e ? this.nodes.filter((t) => t._dirty && !u.samePos(t, t._orig)) : this.nodes.filter((t) => t._dirty);
1928
+ }
1929
+ /** @internal call this to call onChange callback with dirty nodes so DOM can be updated */
1930
+ _notify(e) {
1931
+ if (this.batchMode || !this.onChange)
1932
+ return this;
1933
+ const t = (e || []).concat(this.getDirtyNodes());
1934
+ return this.onChange(t), this;
1935
+ }
1936
+ /** @internal remove dirty and last tried info */
1937
+ cleanNodes() {
1938
+ return this.batchMode ? this : (this.nodes.forEach((e) => {
1939
+ delete e._dirty, delete e._lastTried;
1940
+ }), this);
1941
+ }
1942
+ /** @internal called to save initial position/size to track real dirty state.
1943
+ * Note: should be called right after we call change event (so next API is can detect changes)
1944
+ * as well as right before we start move/resize/enter (so we can restore items to prev values) */
1945
+ saveInitial() {
1946
+ return this.nodes.forEach((e) => {
1947
+ e._orig = u.copyPos({}, e), delete e._dirty;
1948
+ }), this._hasLocked = this.nodes.some((e) => e.locked), this;
1949
+ }
1950
+ /** @internal restore all the nodes back to initial values (called when we leave) */
1951
+ restoreInitial() {
1952
+ return this.nodes.forEach((e) => {
1953
+ !e._orig || u.samePos(e, e._orig) || (u.copyPos(e, e._orig), e._dirty = !0);
1954
+ }), this._notify(), this;
1955
+ }
1956
+ /** find the first available empty spot for the given node width/height, updating the x,y attributes. return true if found.
1957
+ * optionally you can pass your own existing node list and column count, otherwise defaults to that engine data.
1958
+ * Optionally pass a widget to start search AFTER, meaning the order will remain the same but possibly have empty slots we skipped
1959
+ */
1960
+ findEmptyPosition(e, t = this.nodes, i = this.column, s) {
1961
+ const r = s ? s.y * i + (s.x + s.w) : 0;
1962
+ let o = !1;
1963
+ for (let n = r; !o; ++n) {
1964
+ const h = n % i, l = Math.floor(n / i);
1965
+ if (h + e.w > i)
1966
+ continue;
1967
+ const d = { x: h, y: l, w: e.w, h: e.h };
1968
+ t.find((a) => u.isIntercepted(d, a)) || ((e.x !== h || e.y !== l) && (e._dirty = !0), e.x = h, e.y = l, delete e.autoPosition, o = !0);
1969
+ }
1970
+ return o;
1971
+ }
1972
+ /** call to add the given node to our list, fixing collision and re-packing */
1973
+ addNode(e, t = !1, i) {
1974
+ const s = this.nodes.find((o) => o._id === e._id);
1975
+ if (s)
1976
+ return s;
1977
+ this._inColumnResize ? this.nodeBoundFix(e) : this.prepareNode(e), delete e._temporaryRemoved, delete e._removeDOM;
1978
+ let r;
1979
+ return e.autoPosition && this.findEmptyPosition(e, this.nodes, this.column, i) && (delete e.autoPosition, r = !0), this.nodes.push(e), t && this.addedNodes.push(e), r || this._fixCollisions(e), this.batchMode || this._packNodes()._notify(), e;
1980
+ }
1981
+ removeNode(e, t = !0, i = !1) {
1982
+ return this.nodes.find((s) => s._id === e._id) ? (i && this.removedNodes.push(e), t && (e._removeDOM = !0), this.nodes = this.nodes.filter((s) => s._id !== e._id), e._isAboutToRemove || this._packNodes(), this._notify([e]), this) : this;
1983
+ }
1984
+ removeAll(e = !0, t = !0) {
1985
+ if (delete this._layouts, !this.nodes.length)
1986
+ return this;
1987
+ e && this.nodes.forEach((s) => s._removeDOM = !0);
1988
+ const i = this.nodes;
1989
+ return this.removedNodes = t ? i : [], this.nodes = [], this._notify(i);
1990
+ }
1991
+ /** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.
1992
+ * In more complicated cases (maxRow) it will attempt at moving the item and fixing
1993
+ * others in a clone first, then apply those changes if still within specs. */
1994
+ moveNodeCheck(e, t) {
1995
+ if (!this.changedPosConstrain(e, t))
1996
+ return !1;
1997
+ if (t.pack = !0, !this.maxRow)
1998
+ return this.moveNode(e, t);
1999
+ let i;
2000
+ const s = new re({
2001
+ column: this.column,
2002
+ float: this.float,
2003
+ nodes: this.nodes.map((o) => o._id === e._id ? (i = { ...o }, i) : { ...o })
2004
+ });
2005
+ if (!i)
2006
+ return !1;
2007
+ const r = s.moveNode(i, t) && s.getRow() <= Math.max(this.getRow(), this.maxRow);
2008
+ if (!r && !t.resizing && t.collide) {
2009
+ const o = t.collide.el.gridstackNode;
2010
+ if (this.swap(e, o))
2011
+ return this._notify(), !0;
2012
+ }
2013
+ return r ? (s.nodes.filter((o) => o._dirty).forEach((o) => {
2014
+ const n = this.nodes.find((h) => h._id === o._id);
2015
+ n && (u.copyPos(n, o), n._dirty = !0);
2016
+ }), this._notify(), !0) : !1;
2017
+ }
2018
+ /** return true if can fit in grid height constrain only (always true if no maxRow) */
2019
+ willItFit(e) {
2020
+ if (delete e._willFitPos, !this.maxRow)
2021
+ return !0;
2022
+ const t = new re({
2023
+ column: this.column,
2024
+ float: this.float,
2025
+ nodes: this.nodes.map((s) => ({ ...s }))
2026
+ }), i = { ...e };
2027
+ return this.cleanupNode(i), delete i.el, delete i._id, delete i.content, delete i.grid, t.addNode(i), t.getRow() <= this.maxRow ? (e._willFitPos = u.copyPos({}, i), !0) : !1;
2028
+ }
2029
+ /** true if x,y or w,h are different after clamping to min/max */
2030
+ changedPosConstrain(e, t) {
2031
+ return t.w = t.w || e.w, t.h = t.h || e.h, e.x !== t.x || e.y !== t.y ? !0 : (e.maxW && (t.w = Math.min(t.w, e.maxW)), e.maxH && (t.h = Math.min(t.h, e.maxH)), e.minW && (t.w = Math.max(t.w, e.minW)), e.minH && (t.h = Math.max(t.h, e.minH)), e.w !== t.w || e.h !== t.h);
2032
+ }
2033
+ /** return true if the passed in node was actually moved (checks for no-op and locked) */
2034
+ moveNode(e, t) {
2035
+ var l, d;
2036
+ if (!e || /*node.locked ||*/
2037
+ !t)
2038
+ return !1;
2039
+ let i;
2040
+ t.pack === void 0 && !this.batchMode && (i = t.pack = !0), typeof t.x != "number" && (t.x = e.x), typeof t.y != "number" && (t.y = e.y), typeof t.w != "number" && (t.w = e.w), typeof t.h != "number" && (t.h = e.h);
2041
+ const s = e.w !== t.w || e.h !== t.h, r = u.copyPos({}, e, !0);
2042
+ if (u.copyPos(r, t), this.nodeBoundFix(r, s), u.copyPos(t, r), !t.forceCollide && u.samePos(e, t))
2043
+ return !1;
2044
+ const o = u.copyPos({}, e), n = this.collideAll(e, r, t.skip);
2045
+ let h = !0;
2046
+ if (n.length) {
2047
+ const a = e._moving && !t.nested;
2048
+ let f = a ? this.directionCollideCoverage(e, t, n) : n[0];
2049
+ if (a && f && ((d = (l = e.grid) == null ? void 0 : l.opts) != null && d.subGridDynamic) && !e.grid._isTemp) {
2050
+ const y = u.areaIntercept(t.rect, f._rect), g = u.area(t.rect), v = u.area(f._rect);
2051
+ y / (g < v ? g : v) > 0.8 && (f.grid.makeSubGrid(f.el, void 0, e), f = void 0);
2052
+ }
2053
+ f ? h = !this._fixCollisions(e, r, f, t) : (h = !1, i && delete t.pack);
2054
+ }
2055
+ return h && !u.samePos(e, r) && (e._dirty = !0, u.copyPos(e, r)), t.pack && this._packNodes()._notify(), !u.samePos(e, o);
2056
+ }
2057
+ getRow() {
2058
+ return this.nodes.reduce((e, t) => Math.max(e, t.y + t.h), 0);
2059
+ }
2060
+ beginUpdate(e) {
2061
+ return e._updating || (e._updating = !0, delete e._skipDown, this.batchMode || this.saveInitial()), this;
2062
+ }
2063
+ endUpdate() {
2064
+ const e = this.nodes.find((t) => t._updating);
2065
+ return e && (delete e._updating, delete e._skipDown), this;
2066
+ }
2067
+ /** saves a copy of the largest column layout (eg 12 even when rendering oneColumnMode) so we don't loose orig layout,
2068
+ * returning a list of widgets for serialization */
2069
+ save(e = !0, t) {
2070
+ var o;
2071
+ const i = (o = this._layouts) == null ? void 0 : o.length, s = i && this.column !== i - 1 ? this._layouts[i - 1] : null, r = [];
2072
+ return this.sortNodes(), this.nodes.forEach((n) => {
2073
+ const h = s == null ? void 0 : s.find((d) => d._id === n._id), l = { ...n, ...h || {} };
2074
+ u.removeInternalForSave(l, !e), t && t(n, l), r.push(l);
2075
+ }), r;
2076
+ }
2077
+ /** @internal called whenever a node is added or moved - updates the cached layouts */
2078
+ layoutsNodesChange(e) {
2079
+ return !this._layouts || this._inColumnResize ? this : (this._layouts.forEach((t, i) => {
2080
+ if (!t || i === this.column)
2081
+ return this;
2082
+ if (i < this.column)
2083
+ this._layouts[i] = void 0;
2084
+ else {
2085
+ const s = i / this.column;
2086
+ e.forEach((r) => {
2087
+ if (!r._orig)
2088
+ return;
2089
+ const o = t.find((n) => n._id === r._id);
2090
+ o && (o.y >= 0 && r.y !== r._orig.y && (o.y += r.y - r._orig.y), r.x !== r._orig.x && (o.x = Math.round(r.x * s)), r.w !== r._orig.w && (o.w = Math.round(r.w * s)));
2091
+ });
2092
+ }
2093
+ }), this);
2094
+ }
2095
+ /**
2096
+ * @internal Called to scale the widget width & position up/down based on the column change.
2097
+ * Note we store previous layouts (especially original ones) to make it possible to go
2098
+ * from say 12 -> 1 -> 12 and get back to where we were.
2099
+ *
2100
+ * @param prevColumn previous number of columns
2101
+ * @param column new column number
2102
+ * @param layout specify the type of re-layout that will happen (position, size, etc...).
2103
+ * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column
2104
+ */
2105
+ columnChanged(e, t, i = "moveScale") {
2106
+ var n;
2107
+ if (!this.nodes.length || !t || e === t)
2108
+ return this;
2109
+ const s = i === "compact" || i === "list";
2110
+ s && this.sortNodes(1), t < e && this.cacheLayout(this.nodes, e), this.batchUpdate();
2111
+ let r = [], o = s ? this.nodes : u.sort(this.nodes, -1);
2112
+ if (t > e && this._layouts) {
2113
+ const h = this._layouts[t] || [], l = this._layouts.length - 1;
2114
+ !h.length && e !== l && ((n = this._layouts[l]) != null && n.length) && (e = l, this._layouts[l].forEach((d) => {
2115
+ const a = o.find((f) => f._id === d._id);
2116
+ a && (!s && !d.autoPosition && (a.x = d.x ?? a.x, a.y = d.y ?? a.y), a.w = d.w ?? a.w, (d.x == null || d.y === void 0) && (a.autoPosition = !0));
2117
+ })), h.forEach((d) => {
2118
+ const a = o.findIndex((f) => f._id === d._id);
2119
+ if (a !== -1) {
2120
+ const f = o[a];
2121
+ if (s) {
2122
+ f.w = d.w;
2123
+ return;
2124
+ }
2125
+ (d.autoPosition || isNaN(d.x) || isNaN(d.y)) && this.findEmptyPosition(d, r), d.autoPosition || (f.x = d.x ?? f.x, f.y = d.y ?? f.y, f.w = d.w ?? f.w, r.push(f)), o.splice(a, 1);
2126
+ }
2127
+ });
2128
+ }
2129
+ if (s)
2130
+ this.compact(i, !1);
2131
+ else {
2132
+ if (o.length)
2133
+ if (typeof i == "function")
2134
+ i(t, e, r, o);
2135
+ else {
2136
+ const h = s || i === "none" ? 1 : t / e, l = i === "move" || i === "moveScale", d = i === "scale" || i === "moveScale";
2137
+ o.forEach((a) => {
2138
+ a.x = t === 1 ? 0 : l ? Math.round(a.x * h) : Math.min(a.x, t - 1), a.w = t === 1 || e === 1 ? 1 : d ? Math.round(a.w * h) || 1 : Math.min(a.w, t), r.push(a);
2139
+ }), o = [];
2140
+ }
2141
+ r = u.sort(r, -1), this._inColumnResize = !0, this.nodes = [], r.forEach((h) => {
2142
+ this.addNode(h, !1), delete h._orig;
2143
+ });
2144
+ }
2145
+ return this.nodes.forEach((h) => delete h._orig), this.batchUpdate(!1, !s), delete this._inColumnResize, this;
2146
+ }
2147
+ /**
2148
+ * call to cache the given layout internally to the given location so we can restore back when column changes size
2149
+ * @param nodes list of nodes
2150
+ * @param column corresponding column index to save it under
2151
+ * @param clear if true, will force other caches to be removed (default false)
2152
+ */
2153
+ cacheLayout(e, t, i = !1) {
2154
+ const s = [];
2155
+ return e.forEach((r, o) => {
2156
+ if (r._id === void 0) {
2157
+ const n = r.id ? this.nodes.find((h) => h.id === r.id) : void 0;
2158
+ r._id = (n == null ? void 0 : n._id) ?? re._idSeq++;
2159
+ }
2160
+ s[o] = { x: r.x, y: r.y, w: r.w, _id: r._id };
2161
+ }), this._layouts = i ? [] : this._layouts || [], this._layouts[t] = s, this;
2162
+ }
2163
+ /**
2164
+ * call to cache the given node layout internally to the given location so we can restore back when column changes size
2165
+ * @param node single node to cache
2166
+ * @param column corresponding column index to save it under
2167
+ */
2168
+ cacheOneLayout(e, t) {
2169
+ e._id = e._id ?? re._idSeq++;
2170
+ const i = { x: e.x, y: e.y, w: e.w, _id: e._id };
2171
+ (e.autoPosition || e.x === void 0) && (delete i.x, delete i.y, e.autoPosition && (i.autoPosition = !0)), this._layouts = this._layouts || [], this._layouts[t] = this._layouts[t] || [];
2172
+ const s = this.findCacheLayout(e, t);
2173
+ return s === -1 ? this._layouts[t].push(i) : this._layouts[t][s] = i, this;
2174
+ }
2175
+ findCacheLayout(e, t) {
2176
+ var i, s;
2177
+ return ((s = (i = this._layouts) == null ? void 0 : i[t]) == null ? void 0 : s.findIndex((r) => r._id === e._id)) ?? -1;
2178
+ }
2179
+ removeNodeFromLayoutCache(e) {
2180
+ if (this._layouts)
2181
+ for (let t = 0; t < this._layouts.length; t++) {
2182
+ const i = this.findCacheLayout(e, t);
2183
+ i !== -1 && this._layouts[t].splice(i, 1);
2184
+ }
2185
+ }
2186
+ /** called to remove all internal values but the _id */
2187
+ cleanupNode(e) {
2188
+ for (const t in e)
2189
+ t[0] === "_" && t !== "_id" && delete e[t];
2190
+ return this;
2191
+ }
2192
+ }
2193
+ re._idSeq = 0;
2194
+ const j = {
2195
+ alwaysShowResizeHandle: "mobile",
2196
+ animate: !0,
2197
+ auto: !0,
2198
+ cellHeight: "auto",
2199
+ cellHeightThrottle: 100,
2200
+ cellHeightUnit: "px",
2201
+ column: 12,
2202
+ draggable: { handle: ".grid-stack-item-content", appendTo: "body", scroll: !0 },
2203
+ handle: ".grid-stack-item-content",
2204
+ itemClass: "grid-stack-item",
2205
+ margin: 10,
2206
+ marginUnit: "px",
2207
+ maxRow: 0,
2208
+ minRow: 0,
2209
+ placeholderClass: "grid-stack-placeholder",
2210
+ placeholderText: "",
2211
+ removableOptions: { accept: "grid-stack-item", decline: "grid-stack-non-removable" },
2212
+ resizable: { handles: "se" },
2213
+ rtl: "auto"
2214
+ // **** same as not being set ****
2215
+ // disableDrag: false,
2216
+ // disableResize: false,
2217
+ // float: false,
2218
+ // handleClass: null,
2219
+ // removable: false,
2220
+ // staticGrid: false,
2221
+ // styleInHead: false,
2222
+ //removable
2223
+ };
2224
+ class w {
2225
+ }
2226
+ const ie = typeof window < "u" && typeof document < "u" && ("ontouchstart" in document || "ontouchstart" in window || window.DocumentTouch && document instanceof window.DocumentTouch || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
2227
+ class ne {
2228
+ }
2229
+ function Oe(c, e) {
2230
+ c.touches.length > 1 || (c.cancelable && c.preventDefault(), u.simulateMouseEvent(c.changedTouches[0], e));
2231
+ }
2232
+ function Gt(c, e) {
2233
+ c.cancelable && c.preventDefault(), u.simulateMouseEvent(c, e);
2234
+ }
2235
+ function He(c) {
2236
+ ne.touchHandled || (ne.touchHandled = !0, Oe(c, "mousedown"));
2237
+ }
2238
+ function Le(c) {
2239
+ ne.touchHandled && Oe(c, "mousemove");
2240
+ }
2241
+ function Me(c) {
2242
+ if (!ne.touchHandled)
2243
+ return;
2244
+ ne.pointerLeaveTimeout && (window.clearTimeout(ne.pointerLeaveTimeout), delete ne.pointerLeaveTimeout);
2245
+ const e = !!w.dragElement;
2246
+ Oe(c, "mouseup"), e || Oe(c, "click"), ne.touchHandled = !1;
2247
+ }
2248
+ function Ie(c) {
2249
+ c.pointerType !== "mouse" && c.target.releasePointerCapture(c.pointerId);
2250
+ }
2251
+ function bt(c) {
2252
+ w.dragElement && c.pointerType !== "mouse" && Gt(c, "mouseenter");
2253
+ }
2254
+ function wt(c) {
2255
+ w.dragElement && c.pointerType !== "mouse" && (ne.pointerLeaveTimeout = window.setTimeout(() => {
2256
+ delete ne.pointerLeaveTimeout, Gt(c, "mouseleave");
2257
+ }, 10));
2258
+ }
2259
+ class Be {
2260
+ constructor(e, t, i) {
2261
+ this.host = e, this.dir = t, this.option = i, this.moving = !1, this._mouseDown = this._mouseDown.bind(this), this._mouseMove = this._mouseMove.bind(this), this._mouseUp = this._mouseUp.bind(this), this._keyEvent = this._keyEvent.bind(this), this._init();
2262
+ }
2263
+ /** @internal */
2264
+ _init() {
2265
+ const e = this.el = document.createElement("div");
2266
+ return e.classList.add("ui-resizable-handle"), e.classList.add(`${Be.prefix}${this.dir}`), e.style.zIndex = "100", e.style.userSelect = "none", this.host.appendChild(this.el), this.el.addEventListener("mousedown", this._mouseDown), ie && (this.el.addEventListener("touchstart", He), this.el.addEventListener("pointerdown", Ie)), this;
2267
+ }
2268
+ /** call this when resize handle needs to be removed and cleaned up */
2269
+ destroy() {
2270
+ return this.moving && this._mouseUp(this.mouseDownEvent), this.el.removeEventListener("mousedown", this._mouseDown), ie && (this.el.removeEventListener("touchstart", He), this.el.removeEventListener("pointerdown", Ie)), this.host.removeChild(this.el), delete this.el, delete this.host, this;
2271
+ }
2272
+ /** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */
2273
+ _mouseDown(e) {
2274
+ this.mouseDownEvent = e, document.addEventListener("mousemove", this._mouseMove, { capture: !0, passive: !0 }), document.addEventListener("mouseup", this._mouseUp, !0), ie && (this.el.addEventListener("touchmove", Le), this.el.addEventListener("touchend", Me)), e.stopPropagation(), e.preventDefault();
2275
+ }
2276
+ /** @internal */
2277
+ _mouseMove(e) {
2278
+ const t = this.mouseDownEvent;
2279
+ this.moving ? this._triggerEvent("move", e) : Math.abs(e.x - t.x) + Math.abs(e.y - t.y) > 2 && (this.moving = !0, this._triggerEvent("start", this.mouseDownEvent), this._triggerEvent("move", e), document.addEventListener("keydown", this._keyEvent)), e.stopPropagation();
2280
+ }
2281
+ /** @internal */
2282
+ _mouseUp(e) {
2283
+ this.moving && (this._triggerEvent("stop", e), document.removeEventListener("keydown", this._keyEvent)), document.removeEventListener("mousemove", this._mouseMove, !0), document.removeEventListener("mouseup", this._mouseUp, !0), ie && (this.el.removeEventListener("touchmove", Le), this.el.removeEventListener("touchend", Me)), delete this.moving, delete this.mouseDownEvent, e.stopPropagation(), e.preventDefault();
2284
+ }
2285
+ /** @internal call when keys are being pressed - use Esc to cancel */
2286
+ _keyEvent(e) {
2287
+ var t, i;
2288
+ e.key === "Escape" && ((i = (t = this.host.gridstackNode) == null ? void 0 : t.grid) == null || i.engine.restoreInitial(), this._mouseUp(this.mouseDownEvent));
2289
+ }
2290
+ /** @internal */
2291
+ _triggerEvent(e, t) {
2292
+ return this.option[e] && this.option[e](t), this;
2293
+ }
2294
+ }
2295
+ Be.prefix = "ui-resizable-";
2296
+ class Je {
2297
+ constructor() {
2298
+ this._eventRegister = {};
2299
+ }
2300
+ /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */
2301
+ get disabled() {
2302
+ return this._disabled;
2303
+ }
2304
+ on(e, t) {
2305
+ this._eventRegister[e] = t;
2306
+ }
2307
+ off(e) {
2308
+ delete this._eventRegister[e];
2309
+ }
2310
+ enable() {
2311
+ this._disabled = !1;
2312
+ }
2313
+ disable() {
2314
+ this._disabled = !0;
2315
+ }
2316
+ destroy() {
2317
+ delete this._eventRegister;
2318
+ }
2319
+ triggerEvent(e, t) {
2320
+ if (!this.disabled && this._eventRegister && this._eventRegister[e])
2321
+ return this._eventRegister[e](t);
2322
+ }
2323
+ }
2324
+ class xe extends Je {
2325
+ // have to be public else complains for HTMLElementExtendOpt ?
2326
+ constructor(e, t = {}) {
2327
+ super(), this.el = e, this.option = t, this.rectScale = { x: 1, y: 1 }, this._ui = () => {
2328
+ const s = this.el.parentElement.getBoundingClientRect(), r = {
2329
+ width: this.originalRect.width,
2330
+ height: this.originalRect.height + this.scrolled,
2331
+ left: this.originalRect.left,
2332
+ top: this.originalRect.top - this.scrolled
2333
+ }, o = this.temporalRect || r;
2334
+ return {
2335
+ position: {
2336
+ left: (o.left - s.left) * this.rectScale.x,
2337
+ top: (o.top - s.top) * this.rectScale.y
2338
+ },
2339
+ size: {
2340
+ width: o.width * this.rectScale.x,
2341
+ height: o.height * this.rectScale.y
2342
+ }
2343
+ /* Gridstack ONLY needs position set above... keep around in case.
2344
+ element: [this.el], // The object representing the element to be resized
2345
+ helper: [], // TODO: not support yet - The object representing the helper that's being resized
2346
+ originalElement: [this.el],// we don't wrap here, so simplify as this.el //The object representing the original element before it is wrapped
2347
+ originalPosition: { // The position represented as { left, top } before the resizable is resized
2348
+ left: this.originalRect.left - containmentRect.left,
2349
+ top: this.originalRect.top - containmentRect.top
2350
+ },
2351
+ originalSize: { // The size represented as { width, height } before the resizable is resized
2352
+ width: this.originalRect.width,
2353
+ height: this.originalRect.height
2354
+ }
2355
+ */
2356
+ };
2357
+ }, this._mouseOver = this._mouseOver.bind(this), this._mouseOut = this._mouseOut.bind(this), this.enable(), this._setupAutoHide(this.option.autoHide), this._setupHandlers();
2358
+ }
2359
+ on(e, t) {
2360
+ super.on(e, t);
2361
+ }
2362
+ off(e) {
2363
+ super.off(e);
2364
+ }
2365
+ enable() {
2366
+ super.enable(), this.el.classList.remove("ui-resizable-disabled"), this._setupAutoHide(this.option.autoHide);
2367
+ }
2368
+ disable() {
2369
+ super.disable(), this.el.classList.add("ui-resizable-disabled"), this._setupAutoHide(!1);
2370
+ }
2371
+ destroy() {
2372
+ this._removeHandlers(), this._setupAutoHide(!1), delete this.el, super.destroy();
2373
+ }
2374
+ updateOption(e) {
2375
+ const t = e.handles && e.handles !== this.option.handles, i = e.autoHide && e.autoHide !== this.option.autoHide;
2376
+ return Object.keys(e).forEach((s) => this.option[s] = e[s]), t && (this._removeHandlers(), this._setupHandlers()), i && this._setupAutoHide(this.option.autoHide), this;
2377
+ }
2378
+ /** @internal turns auto hide on/off */
2379
+ _setupAutoHide(e) {
2380
+ return e ? (this.el.classList.add("ui-resizable-autohide"), this.el.addEventListener("mouseover", this._mouseOver), this.el.addEventListener("mouseout", this._mouseOut)) : (this.el.classList.remove("ui-resizable-autohide"), this.el.removeEventListener("mouseover", this._mouseOver), this.el.removeEventListener("mouseout", this._mouseOut), w.overResizeElement === this && delete w.overResizeElement), this;
2381
+ }
2382
+ /** @internal */
2383
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2384
+ _mouseOver(e) {
2385
+ w.overResizeElement || w.dragElement || (w.overResizeElement = this, this.el.classList.remove("ui-resizable-autohide"));
2386
+ }
2387
+ /** @internal */
2388
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2389
+ _mouseOut(e) {
2390
+ w.overResizeElement === this && (delete w.overResizeElement, this.el.classList.add("ui-resizable-autohide"));
2391
+ }
2392
+ /** @internal */
2393
+ _setupHandlers() {
2394
+ return this.handlers = this.option.handles.split(",").map((e) => e.trim()).map((e) => new Be(this.el, e, {
2395
+ start: (t) => {
2396
+ this._resizeStart(t);
2397
+ },
2398
+ stop: (t) => {
2399
+ this._resizeStop(t);
2400
+ },
2401
+ move: (t) => {
2402
+ this._resizing(t, e);
2403
+ }
2404
+ })), this;
2405
+ }
2406
+ /** @internal */
2407
+ _resizeStart(e) {
2408
+ this.sizeToContent = u.shouldSizeToContent(this.el.gridstackNode, !0), this.originalRect = this.el.getBoundingClientRect(), this.scrollEl = u.getScrollElement(this.el), this.scrollY = this.scrollEl.scrollTop, this.scrolled = 0, this.startEvent = e, this._setupHelper(), this._applyChange();
2409
+ const t = u.initEvent(e, { type: "resizestart", target: this.el });
2410
+ return this.option.start && this.option.start(t, this._ui()), this.el.classList.add("ui-resizable-resizing"), this.triggerEvent("resizestart", t), this;
2411
+ }
2412
+ /** @internal */
2413
+ _resizing(e, t) {
2414
+ this.scrolled = this.scrollEl.scrollTop - this.scrollY, this.temporalRect = this._getChange(e, t), this._applyChange();
2415
+ const i = u.initEvent(e, { type: "resize", target: this.el });
2416
+ return this.option.resize && this.option.resize(i, this._ui()), this.triggerEvent("resize", i), this;
2417
+ }
2418
+ /** @internal */
2419
+ _resizeStop(e) {
2420
+ const t = u.initEvent(e, { type: "resizestop", target: this.el });
2421
+ return this.option.stop && this.option.stop(t), this.el.classList.remove("ui-resizable-resizing"), this.triggerEvent("resizestop", t), this._cleanHelper(), delete this.startEvent, delete this.originalRect, delete this.temporalRect, delete this.scrollY, delete this.scrolled, this;
2422
+ }
2423
+ /** @internal */
2424
+ _setupHelper() {
2425
+ this.elOriginStyleVal = xe._originStyleProp.map((i) => this.el.style[i]), this.parentOriginStylePosition = this.el.parentElement.style.position;
2426
+ const e = this.el.parentElement, t = u.getValuesFromTransformedElement(e);
2427
+ return this.rectScale = {
2428
+ x: t.xScale,
2429
+ y: t.yScale
2430
+ }, getComputedStyle(this.el.parentElement).position.match(/static/) && (this.el.parentElement.style.position = "relative"), this.el.style.position = "absolute", this.el.style.opacity = "0.8", this;
2431
+ }
2432
+ /** @internal */
2433
+ _cleanHelper() {
2434
+ return xe._originStyleProp.forEach((e, t) => {
2435
+ this.el.style[e] = this.elOriginStyleVal[t] || null;
2436
+ }), this.el.parentElement.style.position = this.parentOriginStylePosition || null, this;
2437
+ }
2438
+ /** @internal */
2439
+ _getChange(e, t) {
2440
+ const i = this.startEvent, s = {
2441
+ width: this.originalRect.width,
2442
+ height: this.originalRect.height + this.scrolled,
2443
+ left: this.originalRect.left,
2444
+ top: this.originalRect.top - this.scrolled
2445
+ }, r = e.clientX - i.clientX, o = this.sizeToContent ? 0 : e.clientY - i.clientY;
2446
+ let n, h;
2447
+ t.indexOf("e") > -1 ? s.width += r : t.indexOf("w") > -1 && (s.width -= r, s.left += r, n = !0), t.indexOf("s") > -1 ? s.height += o : t.indexOf("n") > -1 && (s.height -= o, s.top += o, h = !0);
2448
+ const l = this._constrainSize(s.width, s.height, n, h);
2449
+ return Math.round(s.width) !== Math.round(l.width) && (t.indexOf("w") > -1 && (s.left += s.width - l.width), s.width = l.width), Math.round(s.height) !== Math.round(l.height) && (t.indexOf("n") > -1 && (s.top += s.height - l.height), s.height = l.height), s;
2450
+ }
2451
+ /** @internal constrain the size to the set min/max values */
2452
+ _constrainSize(e, t, i, s) {
2453
+ const r = this.option, o = (i ? r.maxWidthMoveLeft : r.maxWidth) || Number.MAX_SAFE_INTEGER, n = r.minWidth / this.rectScale.x || e, h = (s ? r.maxHeightMoveUp : r.maxHeight) || Number.MAX_SAFE_INTEGER, l = r.minHeight / this.rectScale.y || t, d = Math.min(o, Math.max(n, e)), a = Math.min(h, Math.max(l, t));
2454
+ return { width: d, height: a };
2455
+ }
2456
+ /** @internal */
2457
+ _applyChange() {
2458
+ let e = { left: 0, top: 0, width: 0, height: 0 };
2459
+ if (this.el.style.position === "absolute") {
2460
+ const t = this.el.parentElement, { left: i, top: s } = t.getBoundingClientRect();
2461
+ e = { left: i, top: s, width: 0, height: 0 };
2462
+ }
2463
+ return this.temporalRect ? (Object.keys(this.temporalRect).forEach((t) => {
2464
+ const i = this.temporalRect[t], s = t === "width" || t === "left" ? this.rectScale.x : t === "height" || t === "top" ? this.rectScale.y : 1;
2465
+ this.el.style[t] = (i - e[t]) * s + "px";
2466
+ }), this) : this;
2467
+ }
2468
+ /** @internal */
2469
+ _removeHandlers() {
2470
+ return this.handlers.forEach((e) => e.destroy()), delete this.handlers, this;
2471
+ }
2472
+ }
2473
+ xe._originStyleProp = ["width", "height", "position", "left", "top", "opacity", "zIndex"];
2474
+ const _s = 'input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';
2475
+ class Ce extends Je {
2476
+ constructor(e, t = {}) {
2477
+ var r;
2478
+ super(), this.el = e, this.option = t, this.dragTransform = {
2479
+ xScale: 1,
2480
+ yScale: 1,
2481
+ xOffset: 0,
2482
+ yOffset: 0
2483
+ };
2484
+ const i = (r = t == null ? void 0 : t.handle) == null ? void 0 : r.substring(1), s = e.gridstackNode;
2485
+ this.dragEls = !i || e.classList.contains(i) ? [e] : s != null && s.subGrid ? [e.querySelector(t.handle) || e] : Array.from(e.querySelectorAll(t.handle)), this.dragEls.length === 0 && (this.dragEls = [e]), this._mouseDown = this._mouseDown.bind(this), this._mouseMove = this._mouseMove.bind(this), this._mouseUp = this._mouseUp.bind(this), this._keyEvent = this._keyEvent.bind(this), this.enable();
2486
+ }
2487
+ on(e, t) {
2488
+ super.on(e, t);
2489
+ }
2490
+ off(e) {
2491
+ super.off(e);
2492
+ }
2493
+ enable() {
2494
+ this.disabled !== !1 && (super.enable(), this.dragEls.forEach((e) => {
2495
+ e.addEventListener("mousedown", this._mouseDown), ie && (e.addEventListener("touchstart", He), e.addEventListener("pointerdown", Ie));
2496
+ }), this.el.classList.remove("ui-draggable-disabled"));
2497
+ }
2498
+ disable(e = !1) {
2499
+ this.disabled !== !0 && (super.disable(), this.dragEls.forEach((t) => {
2500
+ t.removeEventListener("mousedown", this._mouseDown), ie && (t.removeEventListener("touchstart", He), t.removeEventListener("pointerdown", Ie));
2501
+ }), e || this.el.classList.add("ui-draggable-disabled"));
2502
+ }
2503
+ destroy() {
2504
+ this.dragTimeout && window.clearTimeout(this.dragTimeout), delete this.dragTimeout, this.mouseDownEvent && this._mouseUp(this.mouseDownEvent), this.disable(!0), delete this.el, delete this.helper, delete this.option, super.destroy();
2505
+ }
2506
+ updateOption(e) {
2507
+ return Object.keys(e).forEach((t) => this.option[t] = e[t]), this;
2508
+ }
2509
+ /** @internal call when mouse goes down before a dragstart happens */
2510
+ _mouseDown(e) {
2511
+ if (!w.mouseHandled)
2512
+ return e.button !== 0 || !this.dragEls.find((t) => t === e.target) && e.target.closest(_s) || this.option.cancel && e.target.closest(this.option.cancel) || (this.mouseDownEvent = e, delete this.dragging, delete w.dragElement, delete w.dropElement, document.addEventListener("mousemove", this._mouseMove, { capture: !0, passive: !0 }), document.addEventListener("mouseup", this._mouseUp, !0), ie && (e.currentTarget.addEventListener("touchmove", Le), e.currentTarget.addEventListener("touchend", Me)), e.preventDefault(), document.activeElement && document.activeElement.blur(), w.mouseHandled = !0), !0;
2513
+ }
2514
+ /** @internal method to call actual drag event */
2515
+ _callDrag(e) {
2516
+ if (!this.dragging)
2517
+ return;
2518
+ const t = u.initEvent(e, { target: this.el, type: "drag" });
2519
+ this.option.drag && this.option.drag(t, this.ui()), this.triggerEvent("drag", t);
2520
+ }
2521
+ /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */
2522
+ _mouseMove(e) {
2523
+ var i;
2524
+ const t = this.mouseDownEvent;
2525
+ if (this.lastDrag = e, this.dragging)
2526
+ if (this._dragFollow(e), w.pauseDrag) {
2527
+ const s = Number.isInteger(w.pauseDrag) ? w.pauseDrag : 100;
2528
+ this.dragTimeout && window.clearTimeout(this.dragTimeout), this.dragTimeout = window.setTimeout(() => this._callDrag(e), s);
2529
+ } else
2530
+ this._callDrag(e);
2531
+ else if (Math.abs(e.x - t.x) + Math.abs(e.y - t.y) > 3) {
2532
+ this.dragging = !0, w.dragElement = this;
2533
+ const s = (i = this.el.gridstackNode) == null ? void 0 : i.grid;
2534
+ s ? w.dropElement = s.el.ddElement.ddDroppable : delete w.dropElement, this.helper = this._createHelper(), this._setupHelperContainmentStyle(), this.dragTransform = u.getValuesFromTransformedElement(this.helperContainment), this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment), this._setupHelperStyle(e);
2535
+ const r = u.initEvent(e, { target: this.el, type: "dragstart" });
2536
+ this.option.start && this.option.start(r, this.ui()), this.triggerEvent("dragstart", r), document.addEventListener("keydown", this._keyEvent);
2537
+ }
2538
+ return !0;
2539
+ }
2540
+ /** @internal call when the mouse gets released to drop the item at current location */
2541
+ _mouseUp(e) {
2542
+ var t, i;
2543
+ if (document.removeEventListener("mousemove", this._mouseMove, !0), document.removeEventListener("mouseup", this._mouseUp, !0), ie && e.currentTarget && (e.currentTarget.removeEventListener("touchmove", Le, !0), e.currentTarget.removeEventListener("touchend", Me, !0)), this.dragging) {
2544
+ delete this.dragging, (t = this.el.gridstackNode) == null || delete t._origRotate, document.removeEventListener("keydown", this._keyEvent), ((i = w.dropElement) == null ? void 0 : i.el) === this.el.parentElement && delete w.dropElement, this.helperContainment.style.position = this.parentOriginStylePosition || null, this.helper !== this.el && this.helper.remove(), this._removeHelperStyle();
2545
+ const s = u.initEvent(e, { target: this.el, type: "dragstop" });
2546
+ this.option.stop && this.option.stop(s), this.triggerEvent("dragstop", s), w.dropElement && w.dropElement.drop(e);
2547
+ }
2548
+ delete this.helper, delete this.mouseDownEvent, delete w.dragElement, delete w.dropElement, delete w.mouseHandled, e.preventDefault();
2549
+ }
2550
+ /** @internal call when keys are being pressed - use Esc to cancel, R to rotate */
2551
+ _keyEvent(e) {
2552
+ var s, r;
2553
+ const t = this.el.gridstackNode, i = (t == null ? void 0 : t.grid) || ((r = (s = w.dropElement) == null ? void 0 : s.el) == null ? void 0 : r.gridstack);
2554
+ if (e.key === "Escape")
2555
+ t && t._origRotate && (t._orig = t._origRotate, delete t._origRotate), i == null || i.cancelDrag(), this._mouseUp(this.mouseDownEvent);
2556
+ else if (t && i && (e.key === "r" || e.key === "R")) {
2557
+ if (!u.canBeRotated(t))
2558
+ return;
2559
+ t._origRotate = t._origRotate || { ...t._orig }, delete t._moving, i.setAnimation(!1).rotate(t.el, { top: -this.dragOffset.offsetTop, left: -this.dragOffset.offsetLeft }).setAnimation(), t._moving = !0, this.dragOffset = this._getDragOffset(this.lastDrag, t.el, this.helperContainment), this.helper.style.width = this.dragOffset.width + "px", this.helper.style.height = this.dragOffset.height + "px", u.swap(t._orig, "w", "h"), delete t._rect, this._mouseMove(this.lastDrag);
2560
+ }
2561
+ }
2562
+ /** @internal create a clone copy (or user defined method) of the original drag item if set */
2563
+ _createHelper() {
2564
+ let e = this.el;
2565
+ return typeof this.option.helper == "function" ? e = this.option.helper(this.el) : this.option.helper === "clone" && (e = u.cloneNode(this.el)), e.parentElement || u.appendTo(e, this.option.appendTo === "parent" ? this.el.parentElement : this.option.appendTo), this.dragElementOriginStyle = Ce.originStyleProp.map((t) => this.el.style[t]), e;
2566
+ }
2567
+ /** @internal set the fix position of the dragged item */
2568
+ _setupHelperStyle(e) {
2569
+ this.helper.classList.add("ui-draggable-dragging");
2570
+ const t = this.helper.style;
2571
+ return t.pointerEvents = "none", t.width = this.dragOffset.width + "px", t.height = this.dragOffset.height + "px", t.willChange = "left, top", t.position = "fixed", this._dragFollow(e), t.transition = "none", setTimeout(() => {
2572
+ this.helper && (t.transition = null);
2573
+ }, 0), this;
2574
+ }
2575
+ /** @internal restore back the original style before dragging */
2576
+ _removeHelperStyle() {
2577
+ var t;
2578
+ this.helper.classList.remove("ui-draggable-dragging");
2579
+ const e = (t = this.helper) == null ? void 0 : t.gridstackNode;
2580
+ if (!(e != null && e._isAboutToRemove) && this.dragElementOriginStyle) {
2581
+ const i = this.helper, s = this.dragElementOriginStyle.transition || null;
2582
+ i.style.transition = this.dragElementOriginStyle.transition = "none", Ce.originStyleProp.forEach((r) => i.style[r] = this.dragElementOriginStyle[r] || null), setTimeout(() => i.style.transition = s, 50);
2583
+ }
2584
+ return delete this.dragElementOriginStyle, this;
2585
+ }
2586
+ /** @internal updates the top/left position to follow the mouse */
2587
+ _dragFollow(e) {
2588
+ const t = { left: 0, top: 0 }, i = this.helper.style, s = this.dragOffset;
2589
+ i.left = (e.clientX + s.offsetLeft - t.left) * this.dragTransform.xScale + "px", i.top = (e.clientY + s.offsetTop - t.top) * this.dragTransform.yScale + "px";
2590
+ }
2591
+ /** @internal */
2592
+ _setupHelperContainmentStyle() {
2593
+ return this.helperContainment = this.helper.parentElement, this.helper.style.position !== "fixed" && (this.parentOriginStylePosition = this.helperContainment.style.position, getComputedStyle(this.helperContainment).position.match(/static/) && (this.helperContainment.style.position = "relative")), this;
2594
+ }
2595
+ /** @internal */
2596
+ _getDragOffset(e, t, i) {
2597
+ let s = 0, r = 0;
2598
+ i && (s = this.dragTransform.xOffset, r = this.dragTransform.yOffset);
2599
+ const o = t.getBoundingClientRect();
2600
+ return {
2601
+ left: o.left,
2602
+ top: o.top,
2603
+ offsetLeft: -e.clientX + o.left - s,
2604
+ offsetTop: -e.clientY + o.top - r,
2605
+ width: o.width * this.dragTransform.xScale,
2606
+ height: o.height * this.dragTransform.yScale
2607
+ };
2608
+ }
2609
+ /** @internal TODO: set to public as called by DDDroppable! */
2610
+ ui() {
2611
+ const t = this.el.parentElement.getBoundingClientRect(), i = this.helper.getBoundingClientRect();
2612
+ return {
2613
+ position: {
2614
+ top: (i.top - t.top) * this.dragTransform.yScale,
2615
+ left: (i.left - t.left) * this.dragTransform.xScale
2616
+ }
2617
+ /* not used by GridStack for now...
2618
+ helper: [this.helper], //The object arr representing the helper that's being dragged.
2619
+ offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.
2620
+ */
2621
+ };
2622
+ }
2623
+ }
2624
+ Ce.originStyleProp = ["width", "height", "transform", "transform-origin", "transition", "pointerEvents", "position", "left", "top", "minWidth", "willChange"];
2625
+ class bs extends Je {
2626
+ constructor(e, t = {}) {
2627
+ super(), this.el = e, this.option = t, this._mouseEnter = this._mouseEnter.bind(this), this._mouseLeave = this._mouseLeave.bind(this), this.enable(), this._setupAccept();
2628
+ }
2629
+ on(e, t) {
2630
+ super.on(e, t);
2631
+ }
2632
+ off(e) {
2633
+ super.off(e);
2634
+ }
2635
+ enable() {
2636
+ this.disabled !== !1 && (super.enable(), this.el.classList.add("ui-droppable"), this.el.classList.remove("ui-droppable-disabled"), this.el.addEventListener("mouseenter", this._mouseEnter), this.el.addEventListener("mouseleave", this._mouseLeave), ie && (this.el.addEventListener("pointerenter", bt), this.el.addEventListener("pointerleave", wt)));
2637
+ }
2638
+ disable(e = !1) {
2639
+ this.disabled !== !0 && (super.disable(), this.el.classList.remove("ui-droppable"), e || this.el.classList.add("ui-droppable-disabled"), this.el.removeEventListener("mouseenter", this._mouseEnter), this.el.removeEventListener("mouseleave", this._mouseLeave), ie && (this.el.removeEventListener("pointerenter", bt), this.el.removeEventListener("pointerleave", wt)));
2640
+ }
2641
+ destroy() {
2642
+ this.disable(!0), this.el.classList.remove("ui-droppable"), this.el.classList.remove("ui-droppable-disabled"), super.destroy();
2643
+ }
2644
+ updateOption(e) {
2645
+ return Object.keys(e).forEach((t) => this.option[t] = e[t]), this._setupAccept(), this;
2646
+ }
2647
+ /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */
2648
+ _mouseEnter(e) {
2649
+ if (!w.dragElement || !this._canDrop(w.dragElement.el))
2650
+ return;
2651
+ e.preventDefault(), e.stopPropagation(), w.dropElement && w.dropElement !== this && w.dropElement._mouseLeave(e, !0), w.dropElement = this;
2652
+ const t = u.initEvent(e, { target: this.el, type: "dropover" });
2653
+ this.option.over && this.option.over(t, this._ui(w.dragElement)), this.triggerEvent("dropover", t), this.el.classList.add("ui-droppable-over");
2654
+ }
2655
+ /** @internal called when the item is leaving our area, stop tracking if we had moving item */
2656
+ _mouseLeave(e, t = !1) {
2657
+ var s;
2658
+ if (!w.dragElement || w.dropElement !== this)
2659
+ return;
2660
+ e.preventDefault(), e.stopPropagation();
2661
+ const i = u.initEvent(e, { target: this.el, type: "dropout" });
2662
+ if (this.option.out && this.option.out(i, this._ui(w.dragElement)), this.triggerEvent("dropout", i), w.dropElement === this && (delete w.dropElement, !t)) {
2663
+ let r, o = this.el.parentElement;
2664
+ for (; !r && o; )
2665
+ r = (s = o.ddElement) == null ? void 0 : s.ddDroppable, o = o.parentElement;
2666
+ r && r._mouseEnter(e);
2667
+ }
2668
+ }
2669
+ /** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
2670
+ drop(e) {
2671
+ e.preventDefault();
2672
+ const t = u.initEvent(e, { target: this.el, type: "drop" });
2673
+ this.option.drop && this.option.drop(t, this._ui(w.dragElement)), this.triggerEvent("drop", t);
2674
+ }
2675
+ /** @internal true if element matches the string/method accept option */
2676
+ _canDrop(e) {
2677
+ return e && (!this.accept || this.accept(e));
2678
+ }
2679
+ /** @internal */
2680
+ _setupAccept() {
2681
+ return this.option.accept ? (typeof this.option.accept == "string" ? this.accept = (e) => e.classList.contains(this.option.accept) || e.matches(this.option.accept) : this.accept = this.option.accept, this) : this;
2682
+ }
2683
+ /** @internal */
2684
+ _ui(e) {
2685
+ return {
2686
+ draggable: e.el,
2687
+ ...e.ui()
2688
+ };
2689
+ }
2690
+ }
2691
+ class et {
2692
+ static init(e) {
2693
+ return e.ddElement || (e.ddElement = new et(e)), e.ddElement;
2694
+ }
2695
+ constructor(e) {
2696
+ this.el = e;
2697
+ }
2698
+ on(e, t) {
2699
+ return this.ddDraggable && ["drag", "dragstart", "dragstop"].indexOf(e) > -1 ? this.ddDraggable.on(e, t) : this.ddDroppable && ["drop", "dropover", "dropout"].indexOf(e) > -1 ? this.ddDroppable.on(e, t) : this.ddResizable && ["resizestart", "resize", "resizestop"].indexOf(e) > -1 && this.ddResizable.on(e, t), this;
2700
+ }
2701
+ off(e) {
2702
+ return this.ddDraggable && ["drag", "dragstart", "dragstop"].indexOf(e) > -1 ? this.ddDraggable.off(e) : this.ddDroppable && ["drop", "dropover", "dropout"].indexOf(e) > -1 ? this.ddDroppable.off(e) : this.ddResizable && ["resizestart", "resize", "resizestop"].indexOf(e) > -1 && this.ddResizable.off(e), this;
2703
+ }
2704
+ setupDraggable(e) {
2705
+ return this.ddDraggable ? this.ddDraggable.updateOption(e) : this.ddDraggable = new Ce(this.el, e), this;
2706
+ }
2707
+ cleanDraggable() {
2708
+ return this.ddDraggable && (this.ddDraggable.destroy(), delete this.ddDraggable), this;
2709
+ }
2710
+ setupResizable(e) {
2711
+ return this.ddResizable ? this.ddResizable.updateOption(e) : this.ddResizable = new xe(this.el, e), this;
2712
+ }
2713
+ cleanResizable() {
2714
+ return this.ddResizable && (this.ddResizable.destroy(), delete this.ddResizable), this;
2715
+ }
2716
+ setupDroppable(e) {
2717
+ return this.ddDroppable ? this.ddDroppable.updateOption(e) : this.ddDroppable = new bs(this.el, e), this;
2718
+ }
2719
+ cleanDroppable() {
2720
+ return this.ddDroppable && (this.ddDroppable.destroy(), delete this.ddDroppable), this;
2721
+ }
2722
+ }
2723
+ class ws {
2724
+ resizable(e, t, i, s) {
2725
+ return this._getDDElements(e, t).forEach((r) => {
2726
+ if (t === "disable" || t === "enable")
2727
+ r.ddResizable && r.ddResizable[t]();
2728
+ else if (t === "destroy")
2729
+ r.ddResizable && r.cleanResizable();
2730
+ else if (t === "option")
2731
+ r.setupResizable({ [i]: s });
2732
+ else {
2733
+ const n = r.el.gridstackNode.grid;
2734
+ let h = r.el.getAttribute("gs-resize-handles") || n.opts.resizable.handles || "e,s,se";
2735
+ h === "all" && (h = "n,e,s,w,se,sw,ne,nw");
2736
+ const l = !n.opts.alwaysShowResizeHandle;
2737
+ r.setupResizable({
2738
+ ...n.opts.resizable,
2739
+ handles: h,
2740
+ autoHide: l,
2741
+ start: t.start,
2742
+ stop: t.stop,
2743
+ resize: t.resize
2744
+ });
2745
+ }
2746
+ }), this;
2747
+ }
2748
+ draggable(e, t, i, s) {
2749
+ return this._getDDElements(e, t).forEach((r) => {
2750
+ if (t === "disable" || t === "enable")
2751
+ r.ddDraggable && r.ddDraggable[t]();
2752
+ else if (t === "destroy")
2753
+ r.ddDraggable && r.cleanDraggable();
2754
+ else if (t === "option")
2755
+ r.setupDraggable({ [i]: s });
2756
+ else {
2757
+ const o = r.el.gridstackNode.grid;
2758
+ r.setupDraggable({
2759
+ ...o.opts.draggable,
2760
+ // containment: (grid.parentGridNode && grid.opts.dragOut === false) ? grid.el.parentElement : (grid.opts.draggable.containment || null),
2761
+ start: t.start,
2762
+ stop: t.stop,
2763
+ drag: t.drag
2764
+ });
2765
+ }
2766
+ }), this;
2767
+ }
2768
+ dragIn(e, t) {
2769
+ return this._getDDElements(e).forEach((i) => i.setupDraggable(t)), this;
2770
+ }
2771
+ droppable(e, t, i, s) {
2772
+ return typeof t.accept == "function" && !t._accept && (t._accept = t.accept, t.accept = (r) => t._accept(r)), this._getDDElements(e, t).forEach((r) => {
2773
+ t === "disable" || t === "enable" ? r.ddDroppable && r.ddDroppable[t]() : t === "destroy" ? r.ddDroppable && r.cleanDroppable() : t === "option" ? r.setupDroppable({ [i]: s }) : r.setupDroppable(t);
2774
+ }), this;
2775
+ }
2776
+ /** true if element is droppable */
2777
+ isDroppable(e) {
2778
+ var t;
2779
+ return !!((t = e == null ? void 0 : e.ddElement) != null && t.ddDroppable && !e.ddElement.ddDroppable.disabled);
2780
+ }
2781
+ /** true if element is draggable */
2782
+ isDraggable(e) {
2783
+ var t;
2784
+ return !!((t = e == null ? void 0 : e.ddElement) != null && t.ddDraggable && !e.ddElement.ddDraggable.disabled);
2785
+ }
2786
+ /** true if element is draggable */
2787
+ isResizable(e) {
2788
+ var t;
2789
+ return !!((t = e == null ? void 0 : e.ddElement) != null && t.ddResizable && !e.ddElement.ddResizable.disabled);
2790
+ }
2791
+ on(e, t, i) {
2792
+ return this._getDDElements(e).forEach((s) => s.on(t, (r) => {
2793
+ i(r, w.dragElement ? w.dragElement.el : r.target, w.dragElement ? w.dragElement.helper : null);
2794
+ })), this;
2795
+ }
2796
+ off(e, t) {
2797
+ return this._getDDElements(e).forEach((i) => i.off(t)), this;
2798
+ }
2799
+ /** @internal returns a list of DD elements, creating them on the fly by default unless option is to destroy or disable */
2800
+ _getDDElements(e, t) {
2801
+ const i = e.gridstack || t !== "destroy" && t !== "disable", s = u.getElements(e);
2802
+ return s.length ? s.map((o) => o.ddElement || (i ? et.init(o) : null)).filter((o) => o) : [];
2803
+ }
2804
+ }
2805
+ /*!
2806
+ * GridStack 11.5.1
2807
+ * https://gridstackjs.com/
2808
+ *
2809
+ * Copyright (c) 2021-2024 Alain Dumesny
2810
+ * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
2811
+ */
2812
+ const W = new ws();
2813
+ class b {
2814
+ /**
2815
+ * initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will
2816
+ * simply return the existing instance (ignore any passed options). There is also an initAll() version that support
2817
+ * multiple grids initialization at once. Or you can use addGrid() to create the entire grid from JSON.
2818
+ * @param options grid options (optional)
2819
+ * @param elOrString element or CSS selector (first one used) to convert to a grid (default to '.grid-stack' class selector)
2820
+ *
2821
+ * @example
2822
+ * const grid = GridStack.init();
2823
+ *
2824
+ * Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later
2825
+ * const grid = document.querySelector('.grid-stack').gridstack;
2826
+ */
2827
+ static init(e = {}, t = ".grid-stack") {
2828
+ if (typeof document > "u")
2829
+ return null;
2830
+ const i = b.getGridElement(t);
2831
+ return i ? (i.gridstack || (i.gridstack = new b(i, u.cloneDeep(e))), i.gridstack) : (console.error(typeof t == "string" ? 'GridStack.initAll() no grid was found with selector "' + t + `" - element missing or wrong selector ?
2832
+ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.` : "GridStack.init() no grid element was passed."), null);
2833
+ }
2834
+ /**
2835
+ * Will initialize a list of elements (given a selector) and return an array of grids.
2836
+ * @param options grid options (optional)
2837
+ * @param selector elements selector to convert to grids (default to '.grid-stack' class selector)
2838
+ *
2839
+ * @example
2840
+ * const grids = GridStack.initAll();
2841
+ * grids.forEach(...)
2842
+ */
2843
+ static initAll(e = {}, t = ".grid-stack") {
2844
+ const i = [];
2845
+ return typeof document > "u" || (b.getGridElements(t).forEach((s) => {
2846
+ s.gridstack || (s.gridstack = new b(s, u.cloneDeep(e))), i.push(s.gridstack);
2847
+ }), i.length === 0 && console.error('GridStack.initAll() no grid was found with selector "' + t + `" - element missing or wrong selector ?
2848
+ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)), i;
2849
+ }
2850
+ /**
2851
+ * call to create a grid with the given options, including loading any children from JSON structure. This will call GridStack.init(), then
2852
+ * grid.load() on any passed children (recursively). Great alternative to calling init() if you want entire grid to come from
2853
+ * JSON serialized data, including options.
2854
+ * @param parent HTML element parent to the grid
2855
+ * @param opt grids options used to initialize the grid, and list of children
2856
+ */
2857
+ static addGrid(e, t = {}) {
2858
+ if (!e)
2859
+ return null;
2860
+ let i = e;
2861
+ if (i.gridstack) {
2862
+ const o = i.gridstack;
2863
+ return t && (o.opts = { ...o.opts, ...t }), t.children !== void 0 && o.load(t.children), o;
2864
+ }
2865
+ return (!e.classList.contains("grid-stack") || b.addRemoveCB) && (b.addRemoveCB ? i = b.addRemoveCB(e, t, !0, !0) : i = u.createDiv(["grid-stack", t.class], e)), b.init(t, i);
2866
+ }
2867
+ /** call this method to register your engine instead of the default one.
2868
+ * See instead `GridStackOptions.engineClass` if you only need to
2869
+ * replace just one instance.
2870
+ */
2871
+ static registerEngine(e) {
2872
+ b.engineClass = e;
2873
+ }
2874
+ /** @internal create placeholder DIV as needed */
2875
+ get placeholder() {
2876
+ if (!this._placeholder) {
2877
+ this._placeholder = u.createDiv([this.opts.placeholderClass, j.itemClass, this.opts.itemClass]);
2878
+ const e = u.createDiv(["placeholder-content"], this._placeholder);
2879
+ this.opts.placeholderText && (e.textContent = this.opts.placeholderText);
2880
+ }
2881
+ return this._placeholder;
2882
+ }
2883
+ /**
2884
+ * Construct a grid item from the given element and options
2885
+ * @param el the HTML element tied to this grid after it's been initialized
2886
+ * @param opts grid options - public for classes to access, but use methods to modify!
2887
+ */
2888
+ constructor(e, t = {}) {
2889
+ var a, f, y;
2890
+ this.el = e, this.opts = t, this.animationDelay = 310, this._gsEventHandler = {}, this._extraDragRow = 0, this.dragTransform = { xScale: 1, yScale: 1, xOffset: 0, yOffset: 0 }, e.gridstack = this, this.opts = t = t || {}, e.classList.contains("grid-stack") || this.el.classList.add("grid-stack"), t.row && (t.minRow = t.maxRow = t.row, delete t.row);
2891
+ const i = u.toNumber(e.getAttribute("gs-row"));
2892
+ t.column === "auto" && delete t.column, t.alwaysShowResizeHandle !== void 0 && (t._alwaysShowResizeHandle = t.alwaysShowResizeHandle);
2893
+ let s = (a = t.columnOpts) == null ? void 0 : a.breakpoints;
2894
+ const r = t;
2895
+ if (r.oneColumnModeDomSort && (delete r.oneColumnModeDomSort, console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")), r.oneColumnSize || r.disableOneColumnMode === !1) {
2896
+ const g = r.oneColumnSize || 768;
2897
+ delete r.oneColumnSize, delete r.disableOneColumnMode, t.columnOpts = t.columnOpts || {}, s = t.columnOpts.breakpoints = t.columnOpts.breakpoints || [];
2898
+ let v = s.find((p) => p.c === 1);
2899
+ v ? v.w = g : (v = { c: 1, w: g }, s.push(v, { c: 12, w: g + 1 }));
2900
+ }
2901
+ const o = t.columnOpts;
2902
+ o && (!o.columnWidth && !((f = o.breakpoints) != null && f.length) ? (delete t.columnOpts, s = void 0) : o.columnMax = o.columnMax || 12), (s == null ? void 0 : s.length) > 1 && s.sort((g, v) => (v.w || 0) - (g.w || 0));
2903
+ const n = {
2904
+ ...u.cloneDeep(j),
2905
+ column: u.toNumber(e.getAttribute("gs-column")) || j.column,
2906
+ minRow: i || u.toNumber(e.getAttribute("gs-min-row")) || j.minRow,
2907
+ maxRow: i || u.toNumber(e.getAttribute("gs-max-row")) || j.maxRow,
2908
+ staticGrid: u.toBool(e.getAttribute("gs-static")) || j.staticGrid,
2909
+ sizeToContent: u.toBool(e.getAttribute("gs-size-to-content")) || void 0,
2910
+ draggable: {
2911
+ handle: (t.handleClass ? "." + t.handleClass : t.handle ? t.handle : "") || j.draggable.handle
2912
+ },
2913
+ removableOptions: {
2914
+ accept: t.itemClass || j.removableOptions.accept,
2915
+ decline: j.removableOptions.decline
2916
+ }
2917
+ };
2918
+ e.getAttribute("gs-animate") && (n.animate = u.toBool(e.getAttribute("gs-animate"))), t = u.defaults(t, n), this._initMargin(), this.checkDynamicColumn(), this.el.classList.add("gs-" + t.column), t.rtl === "auto" && (t.rtl = e.style.direction === "rtl"), t.rtl && this.el.classList.add("grid-stack-rtl");
2919
+ const h = this.el.closest("." + j.itemClass), l = h == null ? void 0 : h.gridstackNode;
2920
+ l && (l.subGrid = this, this.parentGridNode = l, this.el.classList.add("grid-stack-nested"), l.el.classList.add("grid-stack-sub-grid")), this._isAutoCellHeight = t.cellHeight === "auto", this._isAutoCellHeight || t.cellHeight === "initial" ? this.cellHeight(void 0, !1) : (typeof t.cellHeight == "number" && t.cellHeightUnit && t.cellHeightUnit !== j.cellHeightUnit && (t.cellHeight = t.cellHeight + t.cellHeightUnit, delete t.cellHeightUnit), this.cellHeight(t.cellHeight, !1)), t.alwaysShowResizeHandle === "mobile" && (t.alwaysShowResizeHandle = ie), this._styleSheetClass = "gs-id-" + re._idSeq++, this.el.classList.add(this._styleSheetClass), this._setStaticClass();
2921
+ const d = t.engineClass || b.engineClass || re;
2922
+ if (this.engine = new d({
2923
+ column: this.getColumn(),
2924
+ float: t.float,
2925
+ maxRow: t.maxRow,
2926
+ onChange: (g) => {
2927
+ let v = 0;
2928
+ this.engine.nodes.forEach((p) => {
2929
+ v = Math.max(v, p.y + p.h);
2930
+ }), g.forEach((p) => {
2931
+ const R = p.el;
2932
+ R && (p._removeDOM ? (R && R.remove(), delete p._removeDOM) : this._writePosAttr(R, p));
2933
+ }), this._updateStyles(!1, v);
2934
+ }
2935
+ }), this._updateStyles(!1, 0), t.auto && (this.batchUpdate(), this.engine._loading = !0, this.getGridItems().forEach((g) => this._prepareElement(g)), delete this.engine._loading, this.batchUpdate(!1)), t.children) {
2936
+ const g = t.children;
2937
+ delete t.children, g.length && this.load(g);
2938
+ }
2939
+ this.setAnimation(), t.subGridDynamic && !w.pauseDrag && (w.pauseDrag = !0), ((y = t.draggable) == null ? void 0 : y.pause) !== void 0 && (w.pauseDrag = t.draggable.pause), this._setupRemoveDrop(), this._setupAcceptWidget(), this._updateResizeEvent();
2940
+ }
2941
+ /**
2942
+ * add a new widget and returns it.
2943
+ *
2944
+ * Widget will be always placed even if result height is more than actual grid height.
2945
+ * You need to use `willItFit()` before calling addWidget for additional check.
2946
+ * See also `makeWidget(el)` for DOM element.
2947
+ *
2948
+ * @example
2949
+ * const grid = GridStack.init();
2950
+ * grid.addWidget({w: 3, content: 'hello'});
2951
+ *
2952
+ * @param w GridStackWidget definition. used MakeWidget(el) if you have dom element instead.
2953
+ */
2954
+ addWidget(e) {
2955
+ if (typeof e == "string") {
2956
+ console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");
2957
+ return;
2958
+ }
2959
+ if (e.ELEMENT_NODE)
2960
+ return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"), this.makeWidget(e);
2961
+ let t, i = e;
2962
+ if (i.grid = this, i != null && i.el ? t = i.el : b.addRemoveCB ? t = b.addRemoveCB(this.el, e, !0, !1) : t = this.createWidgetDivs(i), !t)
2963
+ return;
2964
+ if (i = t.gridstackNode, i && t.parentElement === this.el && this.engine.nodes.find((r) => r._id === i._id))
2965
+ return t;
2966
+ const s = this._readAttr(t);
2967
+ return u.defaults(e, s), this.engine.prepareNode(e), this.el.appendChild(t), this.makeWidget(t, e), t;
2968
+ }
2969
+ /** create the default grid item divs, and content (possibly lazy loaded) by using GridStack.renderCB() */
2970
+ createWidgetDivs(e) {
2971
+ const t = u.createDiv(["grid-stack-item", this.opts.itemClass]), i = u.createDiv(["grid-stack-item-content"], t);
2972
+ return u.lazyLoad(e) ? e.visibleObservable || (e.visibleObservable = new IntersectionObserver(([s]) => {
2973
+ var r, o;
2974
+ s.isIntersecting && ((r = e.visibleObservable) == null || r.disconnect(), delete e.visibleObservable, b.renderCB(i, e), (o = e.grid) == null || o.prepareDragDrop(e.el));
2975
+ }), window.setTimeout(() => {
2976
+ var s;
2977
+ return (s = e.visibleObservable) == null ? void 0 : s.observe(t);
2978
+ })) : b.renderCB(i, e), t;
2979
+ }
2980
+ /**
2981
+ * Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
2982
+ * from the parent's subGrid options.
2983
+ * @param el gridItem element to convert
2984
+ * @param ops (optional) sub-grid options, else default to node, then parent settings, else defaults
2985
+ * @param nodeToAdd (optional) node to add to the newly created sub grid (used when dragging over existing regular item)
2986
+ * @param saveContent if true (default) the html inside .grid-stack-content will be saved to child widget
2987
+ * @returns newly created grid
2988
+ */
2989
+ makeSubGrid(e, t, i, s = !0) {
2990
+ var y, g, v;
2991
+ let r = e.gridstackNode;
2992
+ if (r || (r = this.makeWidget(e).gridstackNode), (y = r.subGrid) != null && y.el)
2993
+ return r.subGrid;
2994
+ let o, n = this;
2995
+ for (; n && !o; )
2996
+ o = (g = n.opts) == null ? void 0 : g.subGridOpts, n = (v = n.parentGridNode) == null ? void 0 : v.grid;
2997
+ t = u.cloneDeep({
2998
+ // by default sub-grid inherit from us | parent, other than id, children, etc...
2999
+ ...this.opts,
3000
+ id: void 0,
3001
+ children: void 0,
3002
+ column: "auto",
3003
+ columnOpts: void 0,
3004
+ layout: "list",
3005
+ subGridOpts: void 0,
3006
+ ...o || {},
3007
+ ...t || r.subGridOpts || {}
3008
+ }), r.subGridOpts = t;
3009
+ let h;
3010
+ t.column === "auto" && (h = !0, t.column = Math.max(r.w || 1, (i == null ? void 0 : i.w) || 1), delete t.columnOpts);
3011
+ let l = r.el.querySelector(".grid-stack-item-content"), d, a;
3012
+ if (s && (this._removeDD(r.el), a = { ...r, x: 0, y: 0 }, u.removeInternalForSave(a), delete a.subGridOpts, r.content && (a.content = r.content, delete r.content), b.addRemoveCB ? d = b.addRemoveCB(this.el, a, !0, !1) : (d = u.createDiv(["grid-stack-item"]), d.appendChild(l), l = u.createDiv(["grid-stack-item-content"], r.el)), this.prepareDragDrop(r.el)), i) {
3013
+ const p = h ? t.column : r.w, R = r.h + i.h, H = r.el.style;
3014
+ H.transition = "none", this.update(r.el, { w: p, h: R }), setTimeout(() => H.transition = null);
3015
+ }
3016
+ const f = r.subGrid = b.addGrid(l, t);
3017
+ return i != null && i._moving && (f._isTemp = !0), h && (f._autoColumn = !0), s && f.makeWidget(d, a), i && (i._moving ? window.setTimeout(() => u.simulateMouseEvent(i._event, "mouseenter", f.el), 0) : f.makeWidget(r.el, r)), this.resizeToContentCheck(!1, r), f;
3018
+ }
3019
+ /**
3020
+ * called when an item was converted into a nested grid to accommodate a dragged over item, but then item leaves - return back
3021
+ * to the original grid-item. Also called to remove empty sub-grids when last item is dragged out (since re-creating is simple)
3022
+ */
3023
+ removeAsSubGrid(e) {
3024
+ var i;
3025
+ const t = (i = this.parentGridNode) == null ? void 0 : i.grid;
3026
+ t && (t.batchUpdate(), t.removeWidget(this.parentGridNode.el, !0, !0), this.engine.nodes.forEach((s) => {
3027
+ s.x += this.parentGridNode.x, s.y += this.parentGridNode.y, t.makeWidget(s.el, s);
3028
+ }), t.batchUpdate(!1), this.parentGridNode && delete this.parentGridNode.subGrid, delete this.parentGridNode, e && window.setTimeout(() => u.simulateMouseEvent(e._event, "mouseenter", t.el), 0));
3029
+ }
3030
+ /**
3031
+ * saves the current layout returning a list of widgets for serialization which might include any nested grids.
3032
+ * @param saveContent if true (default) the latest html inside .grid-stack-content will be saved to GridStackWidget.content field, else it will
3033
+ * be removed.
3034
+ * @param saveGridOpt if true (default false), save the grid options itself, so you can call the new GridStack.addGrid()
3035
+ * to recreate everything from scratch. GridStackOptions.children would then contain the widget list instead.
3036
+ * @param saveCB callback for each node -> widget, so application can insert additional data to be saved into the widget data structure.
3037
+ * @returns list of widgets or full grid option, including .children list of widgets
3038
+ */
3039
+ save(e = !0, t = !1, i = b.saveCB) {
3040
+ const s = this.engine.save(e, i);
3041
+ if (s.forEach((r) => {
3042
+ var o;
3043
+ if (e && r.el && !r.subGrid && !i) {
3044
+ const n = r.el.querySelector(".grid-stack-item-content");
3045
+ r.content = n == null ? void 0 : n.innerHTML, r.content || delete r.content;
3046
+ } else if (!e && !i && delete r.content, (o = r.subGrid) != null && o.el) {
3047
+ const n = r.subGrid.save(e, t, i);
3048
+ r.subGridOpts = t ? n : { children: n }, delete r.subGrid;
3049
+ }
3050
+ delete r.el;
3051
+ }), t) {
3052
+ const r = u.cloneDeep(this.opts);
3053
+ r.marginBottom === r.marginTop && r.marginRight === r.marginLeft && r.marginTop === r.marginRight && (r.margin = r.marginTop, delete r.marginTop, delete r.marginRight, delete r.marginBottom, delete r.marginLeft), r.rtl === (this.el.style.direction === "rtl") && (r.rtl = "auto"), this._isAutoCellHeight && (r.cellHeight = "auto"), this._autoColumn && (r.column = "auto");
3054
+ const o = r._alwaysShowResizeHandle;
3055
+ return delete r._alwaysShowResizeHandle, o !== void 0 ? r.alwaysShowResizeHandle = o : delete r.alwaysShowResizeHandle, u.removeInternalAndSame(r, j), r.children = s, r;
3056
+ }
3057
+ return s;
3058
+ }
3059
+ /**
3060
+ * load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.
3061
+ *
3062
+ * @param items list of widgets definition to update/create
3063
+ * @param addRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving
3064
+ * the user control of insertion.
3065
+ *
3066
+ * @example
3067
+ * see http://gridstackjs.com/demo/serialization.html
3068
+ */
3069
+ load(e, t = b.addRemoveCB || !0) {
3070
+ var l;
3071
+ e = u.cloneDeep(e);
3072
+ const i = this.getColumn();
3073
+ e.forEach((d) => {
3074
+ d.w = d.w || 1, d.h = d.h || 1;
3075
+ }), e = u.sort(e), this.engine.skipCacheUpdate = this._ignoreLayoutsNodeChange = !0;
3076
+ let s = 0;
3077
+ e.forEach((d) => {
3078
+ s = Math.max(s, (d.x || 0) + d.w);
3079
+ }), s > this.engine.defaultColumn && (this.engine.defaultColumn = s), s > i && this.engine.cacheLayout(e, s, !0);
3080
+ const r = b.addRemoveCB;
3081
+ typeof t == "function" && (b.addRemoveCB = t);
3082
+ const o = [];
3083
+ this.batchUpdate();
3084
+ const n = !this.engine.nodes.length;
3085
+ n && this.setAnimation(!1), !n && t && [...this.engine.nodes].forEach((a) => {
3086
+ if (!a.id)
3087
+ return;
3088
+ u.find(e, a.id) || (b.addRemoveCB && b.addRemoveCB(this.el, a, !1, !1), o.push(a), this.removeWidget(a.el, !0, !1));
3089
+ }), this.engine._loading = !0;
3090
+ const h = [];
3091
+ return this.engine.nodes = this.engine.nodes.filter((d) => u.find(e, d.id) ? (h.push(d), !1) : !0), e.forEach((d) => {
3092
+ var f;
3093
+ const a = u.find(h, d.id);
3094
+ if (a) {
3095
+ if (u.shouldSizeToContent(a) && (d.h = a.h), this.engine.nodeBoundFix(d), (d.autoPosition || d.x === void 0 || d.y === void 0) && (d.w = d.w || a.w, d.h = d.h || a.h, this.engine.findEmptyPosition(d)), this.engine.nodes.push(a), u.samePos(a, d) && this.engine.nodes.length > 1 && (this.moveNode(a, { ...d, forceCollide: !0 }), u.copyPos(d, a)), this.update(a.el, d), (f = d.subGridOpts) != null && f.children) {
3096
+ const y = a.el.querySelector(".grid-stack");
3097
+ y && y.gridstack && y.gridstack.load(d.subGridOpts.children);
3098
+ }
3099
+ } else t && this.addWidget(d);
3100
+ }), delete this.engine._loading, this.engine.removedNodes = o, this.batchUpdate(!1), delete this._ignoreLayoutsNodeChange, delete this.engine.skipCacheUpdate, r ? b.addRemoveCB = r : delete b.addRemoveCB, n && ((l = this.opts) != null && l.animate) && this.setAnimation(this.opts.animate, !0), this;
3101
+ }
3102
+ /**
3103
+ * use before calling a bunch of `addWidget()` to prevent un-necessary relayouts in between (more efficient)
3104
+ * and get a single event callback. You will see no changes until `batchUpdate(false)` is called.
3105
+ */
3106
+ batchUpdate(e = !0) {
3107
+ return this.engine.batchUpdate(e), e || (this._updateContainerHeight(), this._triggerRemoveEvent(), this._triggerAddEvent(), this._triggerChangeEvent()), this;
3108
+ }
3109
+ /**
3110
+ * Gets current cell height.
3111
+ */
3112
+ getCellHeight(e = !1) {
3113
+ if (this.opts.cellHeight && this.opts.cellHeight !== "auto" && (!e || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === "px"))
3114
+ return this.opts.cellHeight;
3115
+ if (this.opts.cellHeightUnit === "rem")
3116
+ return this.opts.cellHeight * parseFloat(getComputedStyle(document.documentElement).fontSize);
3117
+ if (this.opts.cellHeightUnit === "em")
3118
+ return this.opts.cellHeight * parseFloat(getComputedStyle(this.el).fontSize);
3119
+ if (this.opts.cellHeightUnit === "cm")
3120
+ return this.opts.cellHeight * (96 / 2.54);
3121
+ if (this.opts.cellHeightUnit === "mm")
3122
+ return this.opts.cellHeight * (96 / 2.54) / 10;
3123
+ const t = this.el.querySelector("." + this.opts.itemClass);
3124
+ if (t) {
3125
+ const s = u.toNumber(t.getAttribute("gs-h")) || 1;
3126
+ return Math.round(t.offsetHeight / s);
3127
+ }
3128
+ const i = parseInt(this.el.getAttribute("gs-current-row"));
3129
+ return i ? Math.round(this.el.getBoundingClientRect().height / i) : this.opts.cellHeight;
3130
+ }
3131
+ /**
3132
+ * Update current cell height - see `GridStackOptions.cellHeight` for format.
3133
+ * This method rebuilds an internal CSS style sheet.
3134
+ * Note: You can expect performance issues if call this method too often.
3135
+ *
3136
+ * @param val the cell height. If not passed (undefined), cells content will be made square (match width minus margin),
3137
+ * if pass 0 the CSS will be generated by the application instead.
3138
+ * @param update (Optional) if false, styles will not be updated
3139
+ *
3140
+ * @example
3141
+ * grid.cellHeight(100); // same as 100px
3142
+ * grid.cellHeight('70px');
3143
+ * grid.cellHeight(grid.cellWidth() * 1.2);
3144
+ */
3145
+ cellHeight(e, t = !0) {
3146
+ if (t && e !== void 0 && this._isAutoCellHeight !== (e === "auto") && (this._isAutoCellHeight = e === "auto", this._updateResizeEvent()), (e === "initial" || e === "auto") && (e = void 0), e === void 0) {
3147
+ const s = -this.opts.marginRight - this.opts.marginLeft + this.opts.marginTop + this.opts.marginBottom;
3148
+ e = this.cellWidth() + s;
3149
+ }
3150
+ const i = u.parseHeight(e);
3151
+ return this.opts.cellHeightUnit === i.unit && this.opts.cellHeight === i.h ? this : (this.opts.cellHeightUnit = i.unit, this.opts.cellHeight = i.h, this.resizeToContentCheck(), t && this._updateStyles(!0), this);
3152
+ }
3153
+ /** Gets current cell width. */
3154
+ cellWidth() {
3155
+ return this._widthOrContainer() / this.getColumn();
3156
+ }
3157
+ /** return our expected width (or parent) , and optionally of window for dynamic column check */
3158
+ _widthOrContainer(e = !1) {
3159
+ var t;
3160
+ return e && ((t = this.opts.columnOpts) != null && t.breakpointForWindow) ? window.innerWidth : this.el.clientWidth || this.el.parentElement.clientWidth || window.innerWidth;
3161
+ }
3162
+ /** checks for dynamic column count for our current size, returning true if changed */
3163
+ checkDynamicColumn() {
3164
+ var r, o;
3165
+ const e = this.opts.columnOpts;
3166
+ if (!e || !e.columnWidth && !((r = e.breakpoints) != null && r.length))
3167
+ return !1;
3168
+ const t = this.getColumn();
3169
+ let i = t;
3170
+ const s = this._widthOrContainer(!0);
3171
+ if (e.columnWidth)
3172
+ i = Math.min(Math.round(s / e.columnWidth) || 1, e.columnMax);
3173
+ else {
3174
+ i = e.columnMax;
3175
+ let n = 0;
3176
+ for (; n < e.breakpoints.length && s <= e.breakpoints[n].w; )
3177
+ i = e.breakpoints[n++].c || t;
3178
+ }
3179
+ if (i !== t) {
3180
+ const n = (o = e.breakpoints) == null ? void 0 : o.find((h) => h.c === i);
3181
+ return this.column(i, (n == null ? void 0 : n.layout) || e.layout), !0;
3182
+ }
3183
+ return !1;
3184
+ }
3185
+ /**
3186
+ * re-layout grid items to reclaim any empty space. Options are:
3187
+ * 'list' keep the widget left->right order the same, even if that means leaving an empty slot if things don't fit
3188
+ * 'compact' might re-order items to fill any empty space
3189
+ *
3190
+ * doSort - 'false' to let you do your own sorting ahead in case you need to control a different order. (default to sort)
3191
+ */
3192
+ compact(e = "compact", t = !0) {
3193
+ return this.engine.compact(e, t), this._triggerChangeEvent(), this;
3194
+ }
3195
+ /**
3196
+ * set the number of columns in the grid. Will update existing widgets to conform to new number of columns,
3197
+ * as well as cache the original layout so you can revert back to previous positions without loss.
3198
+ * Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11],
3199
+ * else you will need to generate correct CSS (see https://github.com/gridstack/gridstack.js#change-grid-columns)
3200
+ * @param column - Integer > 0 (default 12).
3201
+ * @param layout specify the type of re-layout that will happen (position, size, etc...).
3202
+ * Note: items will never be outside of the current column boundaries. default ('moveScale'). Ignored for 1 column
3203
+ */
3204
+ column(e, t = "moveScale") {
3205
+ if (!e || e < 1 || this.opts.column === e)
3206
+ return this;
3207
+ const i = this.getColumn();
3208
+ return this.opts.column = e, this.engine ? (this.engine.column = e, this.el.classList.remove("gs-" + i), this.el.classList.add("gs-" + e), this.engine.columnChanged(i, e, t), this._isAutoCellHeight && this.cellHeight(), this.resizeToContentCheck(!0), this._ignoreLayoutsNodeChange = !0, this._triggerChangeEvent(), delete this._ignoreLayoutsNodeChange, this) : this;
3209
+ }
3210
+ /**
3211
+ * get the number of columns in the grid (default 12)
3212
+ */
3213
+ getColumn() {
3214
+ return this.opts.column;
3215
+ }
3216
+ /** returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order */
3217
+ getGridItems() {
3218
+ return Array.from(this.el.children).filter((e) => e.matches("." + this.opts.itemClass) && !e.matches("." + this.opts.placeholderClass));
3219
+ }
3220
+ /** true if changeCB should be ignored due to column change, sizeToContent, loading, etc... which caller can ignore for dirty flag case */
3221
+ isIgnoreChangeCB() {
3222
+ return this._ignoreLayoutsNodeChange;
3223
+ }
3224
+ /**
3225
+ * Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.
3226
+ * @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).
3227
+ */
3228
+ destroy(e = !0) {
3229
+ var t, i;
3230
+ if (this.el)
3231
+ return this.offAll(), this._updateResizeEvent(!0), this.setStatic(!0, !1), this.setAnimation(!1), e ? this.el.parentNode.removeChild(this.el) : (this.removeAll(e), this.el.classList.remove(this._styleSheetClass), this.el.removeAttribute("gs-current-row")), this._removeStylesheet(), (t = this.parentGridNode) == null || delete t.subGrid, delete this.parentGridNode, delete this.opts, (i = this._placeholder) == null || delete i.gridstackNode, delete this._placeholder, delete this.engine, delete this.el.gridstack, delete this.el, this;
3232
+ }
3233
+ /**
3234
+ * enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html)
3235
+ */
3236
+ float(e) {
3237
+ return this.opts.float !== e && (this.opts.float = this.engine.float = e, this._triggerChangeEvent()), this;
3238
+ }
3239
+ /**
3240
+ * get the current float mode
3241
+ */
3242
+ getFloat() {
3243
+ return this.engine.float;
3244
+ }
3245
+ /**
3246
+ * Get the position of the cell under a pixel on screen.
3247
+ * @param position the position of the pixel to resolve in
3248
+ * absolute coordinates, as an object with top and left properties
3249
+ * @param useDocRelative if true, value will be based on document position vs parent position (Optional. Default false).
3250
+ * Useful when grid is within `position: relative` element
3251
+ *
3252
+ * Returns an object with properties `x` and `y` i.e. the column and row in the grid.
3253
+ */
3254
+ getCellFromPixel(e, t = !1) {
3255
+ const i = this.el.getBoundingClientRect();
3256
+ let s;
3257
+ t ? s = { top: i.top + document.documentElement.scrollTop, left: i.left } : s = { top: this.el.offsetTop, left: this.el.offsetLeft };
3258
+ const r = e.left - s.left, o = e.top - s.top, n = i.width / this.getColumn(), h = i.height / parseInt(this.el.getAttribute("gs-current-row"));
3259
+ return { x: Math.floor(r / n), y: Math.floor(o / h) };
3260
+ }
3261
+ /** returns the current number of rows, which will be at least `minRow` if set */
3262
+ getRow() {
3263
+ return Math.max(this.engine.getRow(), this.opts.minRow);
3264
+ }
3265
+ /**
3266
+ * Checks if specified area is empty.
3267
+ * @param x the position x.
3268
+ * @param y the position y.
3269
+ * @param w the width of to check
3270
+ * @param h the height of to check
3271
+ */
3272
+ isAreaEmpty(e, t, i, s) {
3273
+ return this.engine.isAreaEmpty(e, t, i, s);
3274
+ }
3275
+ /**
3276
+ * If you add elements to your grid by hand (or have some framework creating DOM), you have to tell gridstack afterwards to make them widgets.
3277
+ * If you want gridstack to add the elements for you, use `addWidget()` instead.
3278
+ * Makes the given element a widget and returns it.
3279
+ * @param els widget or single selector to convert.
3280
+ * @param options widget definition to use instead of reading attributes or using default sizing values
3281
+ *
3282
+ * @example
3283
+ * const grid = GridStack.init();
3284
+ * grid.el.innerHtml = '<div id="1" gs-w="3"></div><div id="2"></div>';
3285
+ * grid.makeWidget('1');
3286
+ * grid.makeWidget('2', {w:2, content: 'hello'});
3287
+ */
3288
+ makeWidget(e, t) {
3289
+ const i = b.getElement(e);
3290
+ if (!i)
3291
+ return;
3292
+ i.parentElement || this.el.appendChild(i), this._prepareElement(i, !0, t);
3293
+ const s = i.gridstackNode;
3294
+ this._updateContainerHeight(), s.subGridOpts && this.makeSubGrid(i, s.subGridOpts, void 0, !1);
3295
+ let r;
3296
+ return this.opts.column === 1 && !this._ignoreLayoutsNodeChange && (r = this._ignoreLayoutsNodeChange = !0), this._triggerAddEvent(), this._triggerChangeEvent(), r && delete this._ignoreLayoutsNodeChange, i;
3297
+ }
3298
+ on(e, t) {
3299
+ return e.indexOf(" ") !== -1 ? (e.split(" ").forEach((s) => this.on(s, t)), this) : (e === "change" || e === "added" || e === "removed" || e === "enable" || e === "disable" ? (e === "enable" || e === "disable" ? this._gsEventHandler[e] = (s) => t(s) : this._gsEventHandler[e] = (s) => {
3300
+ s.detail && t(s, s.detail);
3301
+ }, this.el.addEventListener(e, this._gsEventHandler[e])) : e === "drag" || e === "dragstart" || e === "dragstop" || e === "resizestart" || e === "resize" || e === "resizestop" || e === "dropped" || e === "resizecontent" ? this._gsEventHandler[e] = t : console.error("GridStack.on(" + e + ") event not supported"), this);
3302
+ }
3303
+ /**
3304
+ * unsubscribe from the 'on' event GridStackEvent
3305
+ * @param name of the event (see possible values) or list of names space separated
3306
+ */
3307
+ off(e) {
3308
+ return e.indexOf(" ") !== -1 ? (e.split(" ").forEach((i) => this.off(i)), this) : ((e === "change" || e === "added" || e === "removed" || e === "enable" || e === "disable") && this._gsEventHandler[e] && this.el.removeEventListener(e, this._gsEventHandler[e]), delete this._gsEventHandler[e], this);
3309
+ }
3310
+ /** remove all event handlers */
3311
+ offAll() {
3312
+ return Object.keys(this._gsEventHandler).forEach((e) => this.off(e)), this;
3313
+ }
3314
+ /**
3315
+ * Removes widget from the grid.
3316
+ * @param el widget or selector to modify
3317
+ * @param removeDOM if `false` DOM element won't be removed from the tree (Default? true).
3318
+ * @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).
3319
+ */
3320
+ removeWidget(e, t = !0, i = !0) {
3321
+ return e ? (b.getElements(e).forEach((s) => {
3322
+ if (s.parentElement && s.parentElement !== this.el)
3323
+ return;
3324
+ let r = s.gridstackNode;
3325
+ r || (r = this.engine.nodes.find((o) => s === o.el)), r && (t && b.addRemoveCB && b.addRemoveCB(this.el, r, !1, !1), delete s.gridstackNode, this._removeDD(s), this.engine.removeNode(r, t, i), t && s.parentElement && s.remove());
3326
+ }), i && (this._triggerRemoveEvent(), this._triggerChangeEvent()), this) : (console.error("Error: GridStack.removeWidget(undefined) called"), this);
3327
+ }
3328
+ /**
3329
+ * Removes all widgets from the grid.
3330
+ * @param removeDOM if `false` DOM elements won't be removed from the tree (Default? `true`).
3331
+ * @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).
3332
+ */
3333
+ removeAll(e = !0, t = !0) {
3334
+ return this.engine.nodes.forEach((i) => {
3335
+ e && b.addRemoveCB && b.addRemoveCB(this.el, i, !1, !1), delete i.el.gridstackNode, this.opts.staticGrid || this._removeDD(i.el);
3336
+ }), this.engine.removeAll(e, t), t && this._triggerRemoveEvent(), this;
3337
+ }
3338
+ /**
3339
+ * Toggle the grid animation state. Toggles the `grid-stack-animate` class.
3340
+ * @param doAnimate if true the grid will animate.
3341
+ * @param delay if true setting will be set on next event loop.
3342
+ */
3343
+ setAnimation(e = this.opts.animate, t) {
3344
+ return t ? setTimeout(() => {
3345
+ this.opts && this.setAnimation(e);
3346
+ }) : e ? this.el.classList.add("grid-stack-animate") : this.el.classList.remove("grid-stack-animate"), this;
3347
+ }
3348
+ /** @internal */
3349
+ hasAnimationCSS() {
3350
+ return this.el.classList.contains("grid-stack-animate");
3351
+ }
3352
+ /**
3353
+ * Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on.
3354
+ * Also toggle the grid-stack-static class.
3355
+ * @param val if true the grid become static.
3356
+ * @param updateClass true (default) if css class gets updated
3357
+ * @param recurse true (default) if sub-grids also get updated
3358
+ */
3359
+ setStatic(e, t = !0, i = !0) {
3360
+ return !!this.opts.staticGrid === e ? this : (e ? this.opts.staticGrid = !0 : delete this.opts.staticGrid, this._setupRemoveDrop(), this._setupAcceptWidget(), this.engine.nodes.forEach((s) => {
3361
+ this.prepareDragDrop(s.el), s.subGrid && i && s.subGrid.setStatic(e, t, i);
3362
+ }), t && this._setStaticClass(), this);
3363
+ }
3364
+ /**
3365
+ * Updates the passed in options on the grid (similar to update(widget) for for the grid options).
3366
+ * @param options PARTIAL grid options to update - only items specified will be updated.
3367
+ * NOTE: not all options updating are currently supported (lot of code, unlikely to change)
3368
+ */
3369
+ updateOptions(e) {
3370
+ var i;
3371
+ const t = this.opts;
3372
+ return e.acceptWidgets !== void 0 && this._setupAcceptWidget(), e.animate !== void 0 && this.setAnimation(), e.cellHeight && (this.cellHeight(e.cellHeight, !0), delete e.cellHeight), e.class && e.class !== t.class && (t.class && this.el.classList.remove(t.class), this.el.classList.add(e.class)), typeof e.column == "number" && !e.columnOpts && (this.column(e.column), delete e.column), e.margin !== void 0 && this.margin(e.margin), e.staticGrid !== void 0 && this.setStatic(e.staticGrid), e.disableDrag !== void 0 && !e.staticGrid && this.enableMove(!e.disableDrag), e.disableResize !== void 0 && !e.staticGrid && this.enableResize(!e.disableResize), e.float !== void 0 && this.float(e.float), e.row !== void 0 && (t.minRow = t.maxRow = e.row), (i = e.children) != null && i.length && (this.load(e.children), delete e.children), this.opts = { ...this.opts, ...e }, this;
3373
+ }
3374
+ /**
3375
+ * Updates widget position/size and other info. Note: if you need to call this on all nodes, use load() instead which will update what changed.
3376
+ * @param els widget or selector of objects to modify (note: setting the same x,y for multiple items will be indeterministic and likely unwanted)
3377
+ * @param opt new widget options (x,y,w,h, etc..). Only those set will be updated.
3378
+ */
3379
+ update(e, t) {
3380
+ return b.getElements(e).forEach((i) => {
3381
+ var d;
3382
+ const s = i == null ? void 0 : i.gridstackNode;
3383
+ if (!s)
3384
+ return;
3385
+ const r = { ...u.copyPos({}, s), ...u.cloneDeep(t) };
3386
+ this.engine.nodeBoundFix(r), delete r.autoPosition;
3387
+ const o = ["x", "y", "w", "h"];
3388
+ let n;
3389
+ if (o.some((a) => r[a] !== void 0 && r[a] !== s[a]) && (n = {}, o.forEach((a) => {
3390
+ n[a] = r[a] !== void 0 ? r[a] : s[a], delete r[a];
3391
+ })), !n && (r.minW || r.minH || r.maxW || r.maxH) && (n = {}), r.content !== void 0) {
3392
+ const a = i.querySelector(".grid-stack-item-content");
3393
+ a && a.textContent !== r.content && (s.content = r.content, b.renderCB(a, r), (d = s.subGrid) != null && d.el && (a.appendChild(s.subGrid.el), s.subGrid.opts.styleInHead || s.subGrid._updateStyles(!0))), delete r.content;
3394
+ }
3395
+ let h = !1, l = !1;
3396
+ for (const a in r)
3397
+ a[0] !== "_" && s[a] !== r[a] && (s[a] = r[a], h = !0, l = l || !this.opts.staticGrid && (a === "noResize" || a === "noMove" || a === "locked"));
3398
+ if (u.sanitizeMinMax(s), n) {
3399
+ const a = n.w !== void 0 && n.w !== s.w;
3400
+ this.moveNode(s, n), a && s.subGrid ? s.subGrid.onResize(this.hasAnimationCSS() ? s.w : void 0) : this.resizeToContentCheck(a, s), delete s._orig;
3401
+ }
3402
+ (n || h) && this._writeAttr(i, s), l && this.prepareDragDrop(s.el);
3403
+ }), this;
3404
+ }
3405
+ moveNode(e, t) {
3406
+ const i = e._updating;
3407
+ i || this.engine.cleanNodes().beginUpdate(e), this.engine.moveNode(e, t), this._updateContainerHeight(), i || (this._triggerChangeEvent(), this.engine.endUpdate());
3408
+ }
3409
+ /**
3410
+ * Updates widget height to match the content height to avoid v-scrollbar or dead space.
3411
+ * Note: this assumes only 1 child under resizeToContentParent='.grid-stack-item-content' (sized to gridItem minus padding) that is at the entire content size wanted.
3412
+ * @param el grid item element
3413
+ * @param useNodeH set to true if GridStackNode.h should be used instead of actual container height when we don't need to wait for animation to finish to get actual DOM heights
3414
+ */
3415
+ resizeToContent(e) {
3416
+ var f, y;
3417
+ if (!e || (e.classList.remove("size-to-content-max"), !e.clientHeight))
3418
+ return;
3419
+ const t = e.gridstackNode;
3420
+ if (!t)
3421
+ return;
3422
+ const i = t.grid;
3423
+ if (!i || e.parentElement !== i.el)
3424
+ return;
3425
+ const s = i.getCellHeight(!0);
3426
+ if (!s)
3427
+ return;
3428
+ let r = t.h ? t.h * s : e.clientHeight, o;
3429
+ if (t.resizeToContentParent && (o = e.querySelector(t.resizeToContentParent)), o || (o = e.querySelector(b.resizeToContentParent)), !o)
3430
+ return;
3431
+ const n = e.clientHeight - o.clientHeight, h = t.h ? t.h * s - n : o.clientHeight;
3432
+ let l;
3433
+ if (t.subGrid) {
3434
+ l = t.subGrid.getRow() * t.subGrid.getCellHeight(!0);
3435
+ const g = t.subGrid.el.getBoundingClientRect(), v = t.subGrid.el.parentElement.getBoundingClientRect();
3436
+ l += g.top - v.top;
3437
+ } else {
3438
+ if ((y = (f = t.subGridOpts) == null ? void 0 : f.children) != null && y.length)
3439
+ return;
3440
+ {
3441
+ const g = o.firstElementChild;
3442
+ if (!g) {
3443
+ console.error(`Error: GridStack.resizeToContent() widget id:${t.id} '${b.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);
3444
+ return;
3445
+ }
3446
+ l = g.getBoundingClientRect().height || h;
3447
+ }
3448
+ }
3449
+ if (h === l)
3450
+ return;
3451
+ r += l - h;
3452
+ let d = Math.ceil(r / s);
3453
+ const a = Number.isInteger(t.sizeToContent) ? t.sizeToContent : 0;
3454
+ a && d > a && (d = a, e.classList.add("size-to-content-max")), t.minH && d < t.minH ? d = t.minH : t.maxH && d > t.maxH && (d = t.maxH), d !== t.h && (i._ignoreLayoutsNodeChange = !0, i.moveNode(t, { h: d }), delete i._ignoreLayoutsNodeChange);
3455
+ }
3456
+ /** call the user resize (so they can do extra work) else our build in version */
3457
+ resizeToContentCBCheck(e) {
3458
+ b.resizeToContentCB ? b.resizeToContentCB(e) : this.resizeToContent(e);
3459
+ }
3460
+ /** rotate (by swapping w & h) the passed in node - called when user press 'r' during dragging
3461
+ * @param els widget or selector of objects to modify
3462
+ * @param relative optional pixel coord relative to upper/left corner to rotate around (will keep that cell under cursor)
3463
+ */
3464
+ rotate(e, t) {
3465
+ return b.getElements(e).forEach((i) => {
3466
+ const s = i.gridstackNode;
3467
+ if (!u.canBeRotated(s))
3468
+ return;
3469
+ const r = { w: s.h, h: s.w, minH: s.minW, minW: s.minH, maxH: s.maxW, maxW: s.maxH };
3470
+ if (t) {
3471
+ const n = t.left > 0 ? Math.floor(t.left / this.cellWidth()) : 0, h = t.top > 0 ? Math.floor(t.top / this.opts.cellHeight) : 0;
3472
+ r.x = s.x + n - (s.h - (h + 1)), r.y = s.y + h - n;
3473
+ }
3474
+ Object.keys(r).forEach((n) => {
3475
+ r[n] === void 0 && delete r[n];
3476
+ });
3477
+ const o = s._orig;
3478
+ this.update(i, r), s._orig = o;
3479
+ }), this;
3480
+ }
3481
+ /**
3482
+ * Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).
3483
+ * @param value margin value
3484
+ */
3485
+ margin(e) {
3486
+ if (!(typeof e == "string" && e.split(" ").length > 1)) {
3487
+ const i = u.parseHeight(e);
3488
+ if (this.opts.marginUnit === i.unit && this.opts.margin === i.h)
3489
+ return;
3490
+ }
3491
+ return this.opts.margin = e, this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = void 0, this._initMargin(), this._updateStyles(!0), this;
3492
+ }
3493
+ /** returns current margin number value (undefined if 4 sides don't match) */
3494
+ getMargin() {
3495
+ return this.opts.margin;
3496
+ }
3497
+ /**
3498
+ * Returns true if the height of the grid will be less than the vertical
3499
+ * constraint. Always returns true if grid doesn't have height constraint.
3500
+ * @param node contains x,y,w,h,auto-position options
3501
+ *
3502
+ * @example
3503
+ * if (grid.willItFit(newWidget)) {
3504
+ * grid.addWidget(newWidget);
3505
+ * } else {
3506
+ * alert('Not enough free space to place the widget');
3507
+ * }
3508
+ */
3509
+ willItFit(e) {
3510
+ if (arguments.length > 1) {
3511
+ console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");
3512
+ const t = arguments;
3513
+ let i = 0, s = { x: t[i++], y: t[i++], w: t[i++], h: t[i++], autoPosition: t[i++] };
3514
+ return this.willItFit(s);
3515
+ }
3516
+ return this.engine.willItFit(e);
3517
+ }
3518
+ /** @internal */
3519
+ _triggerChangeEvent() {
3520
+ if (this.engine.batchMode)
3521
+ return this;
3522
+ const e = this.engine.getDirtyNodes(!0);
3523
+ return e && e.length && (this._ignoreLayoutsNodeChange || this.engine.layoutsNodesChange(e), this._triggerEvent("change", e)), this.engine.saveInitial(), this;
3524
+ }
3525
+ /** @internal */
3526
+ _triggerAddEvent() {
3527
+ var e;
3528
+ if (this.engine.batchMode)
3529
+ return this;
3530
+ if ((e = this.engine.addedNodes) != null && e.length) {
3531
+ this._ignoreLayoutsNodeChange || this.engine.layoutsNodesChange(this.engine.addedNodes), this.engine.addedNodes.forEach((i) => {
3532
+ delete i._dirty;
3533
+ });
3534
+ const t = [...this.engine.addedNodes];
3535
+ this.engine.addedNodes = [], this._triggerEvent("added", t);
3536
+ }
3537
+ return this;
3538
+ }
3539
+ /** @internal */
3540
+ _triggerRemoveEvent() {
3541
+ var e;
3542
+ if (this.engine.batchMode)
3543
+ return this;
3544
+ if ((e = this.engine.removedNodes) != null && e.length) {
3545
+ const t = [...this.engine.removedNodes];
3546
+ this.engine.removedNodes = [], this._triggerEvent("removed", t);
3547
+ }
3548
+ return this;
3549
+ }
3550
+ /** @internal */
3551
+ _triggerEvent(e, t) {
3552
+ const i = t ? new CustomEvent(e, { bubbles: !1, detail: t }) : new Event(e);
3553
+ return this.el.dispatchEvent(i), this;
3554
+ }
3555
+ /** @internal called to delete the current dynamic style sheet used for our layout */
3556
+ _removeStylesheet() {
3557
+ if (this._styles) {
3558
+ const e = this.opts.styleInHead ? void 0 : this.el.parentNode;
3559
+ u.removeStylesheet(this._styleSheetClass, e), delete this._styles;
3560
+ }
3561
+ return this;
3562
+ }
3563
+ /** @internal updated/create the CSS styles for row based layout and initial margin setting */
3564
+ _updateStyles(e = !1, t) {
3565
+ if (e && this._removeStylesheet(), t === void 0 && (t = this.getRow()), this._updateContainerHeight(), this.opts.cellHeight === 0)
3566
+ return this;
3567
+ const i = this.opts.cellHeight, s = this.opts.cellHeightUnit, r = `.${this._styleSheetClass} > .${this.opts.itemClass}`;
3568
+ if (!this._styles) {
3569
+ const o = this.opts.styleInHead ? void 0 : this.el.parentNode;
3570
+ if (this._styles = u.createStylesheet(this._styleSheetClass, o, {
3571
+ nonce: this.opts.nonce
3572
+ }), !this._styles)
3573
+ return this;
3574
+ this._styles._max = 0, u.addCSSRule(this._styles, r, `height: ${i}${s}`);
3575
+ const n = this.opts.marginTop + this.opts.marginUnit, h = this.opts.marginBottom + this.opts.marginUnit, l = this.opts.marginRight + this.opts.marginUnit, d = this.opts.marginLeft + this.opts.marginUnit, a = `${r} > .grid-stack-item-content`, f = `.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;
3576
+ u.addCSSRule(this._styles, a, `top: ${n}; right: ${l}; bottom: ${h}; left: ${d};`), u.addCSSRule(this._styles, f, `top: ${n}; right: ${l}; bottom: ${h}; left: ${d};`), u.addCSSRule(this._styles, `${r} > .ui-resizable-n`, `top: ${n};`), u.addCSSRule(this._styles, `${r} > .ui-resizable-s`, `bottom: ${h}`), u.addCSSRule(this._styles, `${r} > .ui-resizable-ne`, `right: ${l}; top: ${n}`), u.addCSSRule(this._styles, `${r} > .ui-resizable-e`, `right: ${l}`), u.addCSSRule(this._styles, `${r} > .ui-resizable-se`, `right: ${l}; bottom: ${h}`), u.addCSSRule(this._styles, `${r} > .ui-resizable-nw`, `left: ${d}; top: ${n}`), u.addCSSRule(this._styles, `${r} > .ui-resizable-w`, `left: ${d}`), u.addCSSRule(this._styles, `${r} > .ui-resizable-sw`, `left: ${d}; bottom: ${h}`);
3577
+ }
3578
+ if (t = t || this._styles._max, t > this._styles._max) {
3579
+ const o = (n) => i * n + s;
3580
+ for (let n = this._styles._max + 1; n <= t; n++)
3581
+ u.addCSSRule(this._styles, `${r}[gs-y="${n}"]`, `top: ${o(n)}`), u.addCSSRule(this._styles, `${r}[gs-h="${n + 1}"]`, `height: ${o(n + 1)}`);
3582
+ this._styles._max = t;
3583
+ }
3584
+ return this;
3585
+ }
3586
+ /** @internal */
3587
+ _updateContainerHeight() {
3588
+ if (!this.engine || this.engine.batchMode)
3589
+ return this;
3590
+ const e = this.parentGridNode;
3591
+ let t = this.getRow() + this._extraDragRow;
3592
+ const i = this.opts.cellHeight, s = this.opts.cellHeightUnit;
3593
+ if (!i)
3594
+ return this;
3595
+ if (!e) {
3596
+ const r = u.parseHeight(getComputedStyle(this.el).minHeight);
3597
+ if (r.h > 0 && r.unit === s) {
3598
+ const o = Math.floor(r.h / i);
3599
+ t < o && (t = o);
3600
+ }
3601
+ }
3602
+ return this.el.setAttribute("gs-current-row", String(t)), this.el.style.removeProperty("min-height"), this.el.style.removeProperty("height"), t && (this.el.style[e ? "minHeight" : "height"] = t * i + s), e && !e.grid.engine.batchMode && u.shouldSizeToContent(e) && e.grid.resizeToContentCBCheck(e.el), this;
3603
+ }
3604
+ /** @internal */
3605
+ _prepareElement(e, t = !1, i) {
3606
+ i = i || this._readAttr(e), e.gridstackNode = i, i.el = e, i.grid = this, i = this.engine.addNode(i, t), this._writeAttr(e, i), e.classList.add(j.itemClass, this.opts.itemClass);
3607
+ const s = u.shouldSizeToContent(i);
3608
+ return s ? e.classList.add("size-to-content") : e.classList.remove("size-to-content"), s && this.resizeToContentCheck(!1, i), u.lazyLoad(i) || this.prepareDragDrop(i.el), this;
3609
+ }
3610
+ /** @internal call to write position x,y,w,h attributes back to element */
3611
+ _writePosAttr(e, t) {
3612
+ return t.x !== void 0 && t.x !== null && e.setAttribute("gs-x", String(t.x)), t.y !== void 0 && t.y !== null && e.setAttribute("gs-y", String(t.y)), t.w > 1 ? e.setAttribute("gs-w", String(t.w)) : e.removeAttribute("gs-w"), t.h > 1 ? e.setAttribute("gs-h", String(t.h)) : e.removeAttribute("gs-h"), this;
3613
+ }
3614
+ /** @internal call to write any default attributes back to element */
3615
+ _writeAttr(e, t) {
3616
+ if (!t)
3617
+ return this;
3618
+ this._writePosAttr(e, t);
3619
+ const i = {
3620
+ // autoPosition: 'gs-auto-position', // no need to write out as already in node and doesn't affect CSS
3621
+ noResize: "gs-no-resize",
3622
+ noMove: "gs-no-move",
3623
+ locked: "gs-locked",
3624
+ id: "gs-id",
3625
+ sizeToContent: "gs-size-to-content"
3626
+ };
3627
+ for (const s in i)
3628
+ t[s] ? e.setAttribute(i[s], String(t[s])) : e.removeAttribute(i[s]);
3629
+ return this;
3630
+ }
3631
+ /** @internal call to read any default attributes from element */
3632
+ _readAttr(e, t = !0) {
3633
+ const i = {};
3634
+ i.x = u.toNumber(e.getAttribute("gs-x")), i.y = u.toNumber(e.getAttribute("gs-y")), i.w = u.toNumber(e.getAttribute("gs-w")), i.h = u.toNumber(e.getAttribute("gs-h")), i.autoPosition = u.toBool(e.getAttribute("gs-auto-position")), i.noResize = u.toBool(e.getAttribute("gs-no-resize")), i.noMove = u.toBool(e.getAttribute("gs-no-move")), i.locked = u.toBool(e.getAttribute("gs-locked"));
3635
+ const s = e.getAttribute("gs-size-to-content");
3636
+ s && (s === "true" || s === "false" ? i.sizeToContent = u.toBool(s) : i.sizeToContent = parseInt(s, 10)), i.id = e.getAttribute("gs-id"), i.maxW = u.toNumber(e.getAttribute("gs-max-w")), i.minW = u.toNumber(e.getAttribute("gs-min-w")), i.maxH = u.toNumber(e.getAttribute("gs-max-h")), i.minH = u.toNumber(e.getAttribute("gs-min-h")), t && (i.w === 1 && e.removeAttribute("gs-w"), i.h === 1 && e.removeAttribute("gs-h"), i.maxW && e.removeAttribute("gs-max-w"), i.minW && e.removeAttribute("gs-min-w"), i.maxH && e.removeAttribute("gs-max-h"), i.minH && e.removeAttribute("gs-min-h"));
3637
+ for (const r in i) {
3638
+ if (!i.hasOwnProperty(r))
3639
+ return;
3640
+ !i[r] && i[r] !== 0 && r !== "gs-size-to-content" && delete i[r];
3641
+ }
3642
+ return i;
3643
+ }
3644
+ /** @internal */
3645
+ _setStaticClass() {
3646
+ const e = ["grid-stack-static"];
3647
+ return this.opts.staticGrid ? (this.el.classList.add(...e), this.el.setAttribute("gs-static", "true")) : (this.el.classList.remove(...e), this.el.removeAttribute("gs-static")), this;
3648
+ }
3649
+ /**
3650
+ * called when we are being resized - check if the one Column Mode needs to be turned on/off
3651
+ * and remember the prev columns we used, or get our count from parent, as well as check for cellHeight==='auto' (square)
3652
+ * or `sizeToContent` gridItem options.
3653
+ */
3654
+ onResize(e = ((t) => (t = this.el) == null ? void 0 : t.clientWidth)()) {
3655
+ if (!e || this.prevWidth === e)
3656
+ return;
3657
+ this.prevWidth = e, this.batchUpdate();
3658
+ let i = !1;
3659
+ return this._autoColumn && this.parentGridNode ? this.opts.column !== this.parentGridNode.w && (this.column(this.parentGridNode.w, this.opts.layout || "list"), i = !0) : i = this.checkDynamicColumn(), this._isAutoCellHeight && this.cellHeight(), this.engine.nodes.forEach((s) => {
3660
+ s.subGrid && s.subGrid.onResize();
3661
+ }), this._skipInitialResize || this.resizeToContentCheck(i), delete this._skipInitialResize, this.batchUpdate(!1), this;
3662
+ }
3663
+ /** resizes content for given node (or all) if shouldSizeToContent() is true */
3664
+ resizeToContentCheck(e = !1, t = void 0) {
3665
+ if (this.engine) {
3666
+ if (e && this.hasAnimationCSS())
3667
+ return setTimeout(() => this.resizeToContentCheck(!1, t), this.animationDelay);
3668
+ if (t)
3669
+ u.shouldSizeToContent(t) && this.resizeToContentCBCheck(t.el);
3670
+ else if (this.engine.nodes.some((i) => u.shouldSizeToContent(i))) {
3671
+ const i = [...this.engine.nodes];
3672
+ this.batchUpdate(), i.forEach((s) => {
3673
+ u.shouldSizeToContent(s) && this.resizeToContentCBCheck(s.el);
3674
+ }), this.batchUpdate(!1);
3675
+ }
3676
+ this._gsEventHandler.resizecontent && this._gsEventHandler.resizecontent(null, t ? [t] : this.engine.nodes);
3677
+ }
3678
+ }
3679
+ /** add or remove the grid element size event handler */
3680
+ _updateResizeEvent(e = !1) {
3681
+ const t = !this.parentGridNode && (this._isAutoCellHeight || this.opts.sizeToContent || this.opts.columnOpts || this.engine.nodes.find((i) => i.sizeToContent));
3682
+ return !e && t && !this.resizeObserver ? (this._sizeThrottle = u.throttle(() => this.onResize(), this.opts.cellHeightThrottle), this.resizeObserver = new ResizeObserver(() => this._sizeThrottle()), this.resizeObserver.observe(this.el), this._skipInitialResize = !0) : (e || !t) && this.resizeObserver && (this.resizeObserver.disconnect(), delete this.resizeObserver, delete this._sizeThrottle), this;
3683
+ }
3684
+ /** @internal convert a potential selector into actual element */
3685
+ static getElement(e = ".grid-stack-item") {
3686
+ return u.getElement(e);
3687
+ }
3688
+ /** @internal */
3689
+ static getElements(e = ".grid-stack-item") {
3690
+ return u.getElements(e);
3691
+ }
3692
+ /** @internal */
3693
+ static getGridElement(e) {
3694
+ return b.getElement(e);
3695
+ }
3696
+ /** @internal */
3697
+ static getGridElements(e) {
3698
+ return u.getElements(e);
3699
+ }
3700
+ /** @internal initialize margin top/bottom/left/right and units */
3701
+ _initMargin() {
3702
+ let e, t = 0, i = [];
3703
+ return typeof this.opts.margin == "string" && (i = this.opts.margin.split(" ")), i.length === 2 ? (this.opts.marginTop = this.opts.marginBottom = i[0], this.opts.marginLeft = this.opts.marginRight = i[1]) : i.length === 4 ? (this.opts.marginTop = i[0], this.opts.marginRight = i[1], this.opts.marginBottom = i[2], this.opts.marginLeft = i[3]) : (e = u.parseHeight(this.opts.margin), this.opts.marginUnit = e.unit, t = this.opts.margin = e.h), this.opts.marginTop === void 0 ? this.opts.marginTop = t : (e = u.parseHeight(this.opts.marginTop), this.opts.marginTop = e.h, delete this.opts.margin), this.opts.marginBottom === void 0 ? this.opts.marginBottom = t : (e = u.parseHeight(this.opts.marginBottom), this.opts.marginBottom = e.h, delete this.opts.margin), this.opts.marginRight === void 0 ? this.opts.marginRight = t : (e = u.parseHeight(this.opts.marginRight), this.opts.marginRight = e.h, delete this.opts.margin), this.opts.marginLeft === void 0 ? this.opts.marginLeft = t : (e = u.parseHeight(this.opts.marginLeft), this.opts.marginLeft = e.h, delete this.opts.margin), this.opts.marginUnit = e.unit, this.opts.marginTop === this.opts.marginBottom && this.opts.marginLeft === this.opts.marginRight && this.opts.marginTop === this.opts.marginRight && (this.opts.margin = this.opts.marginTop), this;
3704
+ }
3705
+ /* ===========================================================================================
3706
+ * drag&drop methods that used to be stubbed out and implemented in dd-gridstack.ts
3707
+ * but caused loading issues in prod - see https://github.com/gridstack/gridstack.js/issues/2039
3708
+ * ===========================================================================================
3709
+ */
3710
+ /** get the global (but static to this code) DD implementation */
3711
+ static getDD() {
3712
+ return W;
3713
+ }
3714
+ /**
3715
+ * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
3716
+ * Called during GridStack.init() as options, but can also be called directly (last param are used) in case the toolbar
3717
+ * is dynamically create and needs to be set later.
3718
+ * @param dragIn string selector (ex: '.sidebar-item') or list of dom elements
3719
+ * @param dragInOptions options - see DDDragOpt. (default: {handle: '.grid-stack-item-content', appendTo: 'body'}
3720
+ * @param widgets GridStackWidget def to assign to each element which defines what to create on drop
3721
+ * @param root optional root which defaults to document (for shadow dom pass the parent HTMLDocument)
3722
+ */
3723
+ static setupDragIn(e, t, i, s = document) {
3724
+ (t == null ? void 0 : t.pause) !== void 0 && (w.pauseDrag = t.pause), t = { appendTo: "body", helper: "clone", ...t || {} }, (typeof e == "string" ? u.getElements(e, s) : e).forEach((o, n) => {
3725
+ W.isDraggable(o) || W.dragIn(o, t), i != null && i[n] && (o.gridstackNode = i[n]);
3726
+ });
3727
+ }
3728
+ /**
3729
+ * Enables/Disables dragging by the user of specific grid element. If you want all items, and have it affect future items, use enableMove() instead. No-op for static grids.
3730
+ * IF you are looking to prevent an item from moving (due to being pushed around by another during collision) use locked property instead.
3731
+ * @param els widget or selector to modify.
3732
+ * @param val if true widget will be draggable, assuming the parent grid isn't noMove or static.
3733
+ */
3734
+ movable(e, t) {
3735
+ return this.opts.staticGrid ? this : (b.getElements(e).forEach((i) => {
3736
+ const s = i.gridstackNode;
3737
+ s && (t ? delete s.noMove : s.noMove = !0, this.prepareDragDrop(s.el));
3738
+ }), this);
3739
+ }
3740
+ /**
3741
+ * Enables/Disables user resizing of specific grid element. If you want all items, and have it affect future items, use enableResize() instead. No-op for static grids.
3742
+ * @param els widget or selector to modify
3743
+ * @param val if true widget will be resizable, assuming the parent grid isn't noResize or static.
3744
+ */
3745
+ resizable(e, t) {
3746
+ return this.opts.staticGrid ? this : (b.getElements(e).forEach((i) => {
3747
+ const s = i.gridstackNode;
3748
+ s && (t ? delete s.noResize : s.noResize = !0, this.prepareDragDrop(s.el));
3749
+ }), this);
3750
+ }
3751
+ /**
3752
+ * Temporarily disables widgets moving/resizing.
3753
+ * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.
3754
+ * Note: no-op for static grid
3755
+ * This is a shortcut for:
3756
+ * @example
3757
+ * grid.enableMove(false);
3758
+ * grid.enableResize(false);
3759
+ * @param recurse true (default) if sub-grids also get updated
3760
+ */
3761
+ disable(e = !0) {
3762
+ if (!this.opts.staticGrid)
3763
+ return this.enableMove(!1, e), this.enableResize(!1, e), this._triggerEvent("disable"), this;
3764
+ }
3765
+ /**
3766
+ * Re-enables widgets moving/resizing - see disable().
3767
+ * Note: no-op for static grid.
3768
+ * This is a shortcut for:
3769
+ * @example
3770
+ * grid.enableMove(true);
3771
+ * grid.enableResize(true);
3772
+ * @param recurse true (default) if sub-grids also get updated
3773
+ */
3774
+ enable(e = !0) {
3775
+ if (!this.opts.staticGrid)
3776
+ return this.enableMove(!0, e), this.enableResize(!0, e), this._triggerEvent("enable"), this;
3777
+ }
3778
+ /**
3779
+ * Enables/disables widget moving. No-op for static grids, and locally defined items still overrule
3780
+ * @param recurse true (default) if sub-grids also get updated
3781
+ */
3782
+ enableMove(e, t = !0) {
3783
+ return this.opts.staticGrid ? this : (e ? delete this.opts.disableDrag : this.opts.disableDrag = !0, this.engine.nodes.forEach((i) => {
3784
+ this.prepareDragDrop(i.el), i.subGrid && t && i.subGrid.enableMove(e, t);
3785
+ }), this);
3786
+ }
3787
+ /**
3788
+ * Enables/disables widget resizing. No-op for static grids.
3789
+ * @param recurse true (default) if sub-grids also get updated
3790
+ */
3791
+ enableResize(e, t = !0) {
3792
+ return this.opts.staticGrid ? this : (e ? delete this.opts.disableResize : this.opts.disableResize = !0, this.engine.nodes.forEach((i) => {
3793
+ this.prepareDragDrop(i.el), i.subGrid && t && i.subGrid.enableResize(e, t);
3794
+ }), this);
3795
+ }
3796
+ /** @internal call when drag (and drop) needs to be cancelled (Esc key) */
3797
+ cancelDrag() {
3798
+ var t;
3799
+ const e = (t = this._placeholder) == null ? void 0 : t.gridstackNode;
3800
+ e && (e._isExternal ? (e._isAboutToRemove = !0, this.engine.removeNode(e)) : e._isAboutToRemove && b._itemRemoving(e.el, !1), this.engine.restoreInitial());
3801
+ }
3802
+ /** @internal removes any drag&drop present (called during destroy) */
3803
+ _removeDD(e) {
3804
+ return W.draggable(e, "destroy").resizable(e, "destroy"), e.gridstackNode && delete e.gridstackNode._initDD, delete e.ddElement, this;
3805
+ }
3806
+ /** @internal called to add drag over to support widgets being added externally */
3807
+ _setupAcceptWidget() {
3808
+ if (this.opts.staticGrid || !this.opts.acceptWidgets && !this.opts.removable)
3809
+ return W.droppable(this.el, "destroy"), this;
3810
+ let e, t;
3811
+ const i = (s, r, o) => {
3812
+ var f;
3813
+ o = o || r;
3814
+ const n = o.gridstackNode;
3815
+ if (!n)
3816
+ return;
3817
+ if (!((f = n.grid) != null && f.el)) {
3818
+ o.style.transform = `scale(${1 / this.dragTransform.xScale},${1 / this.dragTransform.yScale})`;
3819
+ const y = o.getBoundingClientRect();
3820
+ o.style.left = y.x + (this.dragTransform.xScale - 1) * (s.clientX - y.x) / this.dragTransform.xScale + "px", o.style.top = y.y + (this.dragTransform.yScale - 1) * (s.clientY - y.y) / this.dragTransform.yScale + "px", o.style.transformOrigin = "0px 0px";
3821
+ }
3822
+ let { top: h, left: l } = o.getBoundingClientRect();
3823
+ const d = this.el.getBoundingClientRect();
3824
+ l -= d.left, h -= d.top;
3825
+ const a = {
3826
+ position: {
3827
+ top: h * this.dragTransform.xScale,
3828
+ left: l * this.dragTransform.yScale
3829
+ }
3830
+ };
3831
+ if (n._temporaryRemoved) {
3832
+ if (n.x = Math.max(0, Math.round(l / t)), n.y = Math.max(0, Math.round(h / e)), delete n.autoPosition, this.engine.nodeBoundFix(n), !this.engine.willItFit(n)) {
3833
+ if (n.autoPosition = !0, !this.engine.willItFit(n)) {
3834
+ W.off(r, "drag");
3835
+ return;
3836
+ }
3837
+ n._willFitPos && (u.copyPos(n, n._willFitPos), delete n._willFitPos);
3838
+ }
3839
+ this._onStartMoving(o, s, a, n, t, e);
3840
+ } else
3841
+ this._dragOrResize(o, s, a, n, t, e);
3842
+ };
3843
+ return W.droppable(this.el, {
3844
+ accept: (s) => {
3845
+ const r = s.gridstackNode || this._readAttr(s, !1);
3846
+ if ((r == null ? void 0 : r.grid) === this)
3847
+ return !0;
3848
+ if (!this.opts.acceptWidgets)
3849
+ return !1;
3850
+ let o = !0;
3851
+ if (typeof this.opts.acceptWidgets == "function")
3852
+ o = this.opts.acceptWidgets(s);
3853
+ else {
3854
+ const n = this.opts.acceptWidgets === !0 ? ".grid-stack-item" : this.opts.acceptWidgets;
3855
+ o = s.matches(n);
3856
+ }
3857
+ if (o && r && this.opts.maxRow) {
3858
+ const n = { w: r.w, h: r.h, minW: r.minW, minH: r.minH };
3859
+ o = this.engine.willItFit(n);
3860
+ }
3861
+ return o;
3862
+ }
3863
+ }).on(this.el, "dropover", (s, r, o) => {
3864
+ let n = (o == null ? void 0 : o.gridstackNode) || r.gridstackNode;
3865
+ if ((n == null ? void 0 : n.grid) === this && !n._temporaryRemoved)
3866
+ return !1;
3867
+ if (n != null && n._sidebarOrig && (n.w = n._sidebarOrig.w, n.h = n._sidebarOrig.h), n != null && n.grid && n.grid !== this && !n._temporaryRemoved && n.grid._leave(r, o), o = o || r, t = this.cellWidth(), e = this.getCellHeight(!0), !n) {
3868
+ const d = o.getAttribute("data-gs-widget") || o.getAttribute("gridstacknode");
3869
+ if (d) {
3870
+ try {
3871
+ n = JSON.parse(d);
3872
+ } catch {
3873
+ console.error("Gridstack dropover: Bad JSON format: ", d);
3874
+ }
3875
+ o.removeAttribute("data-gs-widget"), o.removeAttribute("gridstacknode");
3876
+ }
3877
+ n || (n = this._readAttr(o)), n._sidebarOrig = { w: n.w, h: n.h };
3878
+ }
3879
+ n.grid || (n.el || (n = { ...n }), n._isExternal = !0, o.gridstackNode = n);
3880
+ const h = n.w || Math.round(o.offsetWidth / t) || 1, l = n.h || Math.round(o.offsetHeight / e) || 1;
3881
+ return n.grid && n.grid !== this ? (r._gridstackNodeOrig || (r._gridstackNodeOrig = n), r.gridstackNode = n = { ...n, w: h, h: l, grid: this }, delete n.x, delete n.y, this.engine.cleanupNode(n).nodeBoundFix(n), n._initDD = n._isExternal = // DOM needs to be re-parented on a drop
3882
+ n._temporaryRemoved = !0) : (n.w = h, n.h = l, n._temporaryRemoved = !0), b._itemRemoving(n.el, !1), W.on(r, "drag", i), i(s, r, o), !1;
3883
+ }).on(this.el, "dropout", (s, r, o) => {
3884
+ const n = (o == null ? void 0 : o.gridstackNode) || r.gridstackNode;
3885
+ return n && (!n.grid || n.grid === this) && (this._leave(r, o), this._isTemp && this.removeAsSubGrid(n)), !1;
3886
+ }).on(this.el, "drop", (s, r, o) => {
3887
+ var y, g, v;
3888
+ const n = (o == null ? void 0 : o.gridstackNode) || r.gridstackNode;
3889
+ if ((n == null ? void 0 : n.grid) === this && !n._isExternal)
3890
+ return !1;
3891
+ const h = !!this.placeholder.parentElement, l = r !== o;
3892
+ this.placeholder.remove(), delete this.placeholder.gridstackNode;
3893
+ const d = h && this.opts.animate;
3894
+ d && this.setAnimation(!1);
3895
+ const a = r._gridstackNodeOrig;
3896
+ if (delete r._gridstackNodeOrig, h && (a != null && a.grid) && a.grid !== this) {
3897
+ const p = a.grid;
3898
+ p.engine.removeNodeFromLayoutCache(a), p.engine.removedNodes.push(a), p._triggerRemoveEvent()._triggerChangeEvent(), p.parentGridNode && !p.engine.nodes.length && p.opts.subGridDynamic && p.removeAsSubGrid();
3899
+ }
3900
+ if (!n || (h && (this.engine.cleanupNode(n), n.grid = this), (y = n.grid) == null || delete y._isTemp, W.off(r, "drag"), o !== r ? (o.remove(), r = o) : r.remove(), this._removeDD(r), !h))
3901
+ return !1;
3902
+ const f = (v = (g = n.subGrid) == null ? void 0 : g.el) == null ? void 0 : v.gridstack;
3903
+ return u.copyPos(n, this._readAttr(this.placeholder)), u.removePositioningStyles(r), l && (n.content || n.subGridOpts || b.addRemoveCB) ? (delete n.el, r = this.addWidget(n)) : (this._prepareElement(r, !0, n), this.el.appendChild(r), this.resizeToContentCheck(!1, n), f && (f.parentGridNode = n, f.opts.styleInHead || f._updateStyles(!0)), this._updateContainerHeight()), this.engine.addedNodes.push(n), this._triggerAddEvent(), this._triggerChangeEvent(), this.engine.endUpdate(), this._gsEventHandler.dropped && this._gsEventHandler.dropped({ ...s, type: "dropped" }, a && a.grid ? a : void 0, n), d && this.setAnimation(this.opts.animate, !0), !1;
3904
+ }), this;
3905
+ }
3906
+ /** @internal mark item for removal */
3907
+ static _itemRemoving(e, t) {
3908
+ if (!e)
3909
+ return;
3910
+ const i = e ? e.gridstackNode : void 0;
3911
+ !(i != null && i.grid) || e.classList.contains(i.grid.opts.removableOptions.decline) || (t ? i._isAboutToRemove = !0 : delete i._isAboutToRemove, t ? e.classList.add("grid-stack-item-removing") : e.classList.remove("grid-stack-item-removing"));
3912
+ }
3913
+ /** @internal called to setup a trash drop zone if the user specifies it */
3914
+ _setupRemoveDrop() {
3915
+ if (typeof this.opts.removable != "string")
3916
+ return this;
3917
+ const e = document.querySelector(this.opts.removable);
3918
+ return e ? (!this.opts.staticGrid && !W.isDroppable(e) && W.droppable(e, this.opts.removableOptions).on(e, "dropover", (t, i) => b._itemRemoving(i, !0)).on(e, "dropout", (t, i) => b._itemRemoving(i, !1)), this) : this;
3919
+ }
3920
+ /**
3921
+ * prepares the element for drag&drop - this is normally called by makeWidget() unless are are delay loading
3922
+ * @param el GridItemHTMLElement of the widget
3923
+ * @param [force=false]
3924
+ * */
3925
+ prepareDragDrop(e, t = !1) {
3926
+ const i = e == null ? void 0 : e.gridstackNode;
3927
+ if (!i)
3928
+ return;
3929
+ const s = i.noMove || this.opts.disableDrag, r = i.noResize || this.opts.disableResize, o = this.opts.staticGrid || s && r;
3930
+ if ((t || o) && (i._initDD && (this._removeDD(e), delete i._initDD), o && e.classList.add("ui-draggable-disabled", "ui-resizable-disabled"), !t))
3931
+ return this;
3932
+ if (!i._initDD) {
3933
+ let n, h;
3934
+ const l = (f, y) => {
3935
+ this._gsEventHandler[f.type] && this._gsEventHandler[f.type](f, f.target), n = this.cellWidth(), h = this.getCellHeight(!0), this._onStartMoving(e, f, y, i, n, h);
3936
+ }, d = (f, y) => {
3937
+ this._dragOrResize(e, f, y, i, n, h);
3938
+ }, a = (f) => {
3939
+ this.placeholder.remove(), delete this.placeholder.gridstackNode, delete i._moving, delete i._event, delete i._lastTried;
3940
+ const y = i.w !== i._orig.w, g = f.target;
3941
+ if (!(!g.gridstackNode || g.gridstackNode.grid !== this)) {
3942
+ if (i.el = g, i._isAboutToRemove) {
3943
+ const v = e.gridstackNode.grid;
3944
+ v._gsEventHandler[f.type] && v._gsEventHandler[f.type](f, g), v.engine.nodes.push(i), v.removeWidget(e, !0, !0);
3945
+ } else
3946
+ u.removePositioningStyles(g), i._temporaryRemoved ? (u.copyPos(i, i._orig), this._writePosAttr(g, i), this.engine.addNode(i)) : this._writePosAttr(g, i), this._gsEventHandler[f.type] && this._gsEventHandler[f.type](f, g);
3947
+ this._extraDragRow = 0, this._updateContainerHeight(), this._triggerChangeEvent(), this.engine.endUpdate(), f.type === "resizestop" && (Number.isInteger(i.sizeToContent) && (i.sizeToContent = i.h), this.resizeToContentCheck(y, i));
3948
+ }
3949
+ };
3950
+ W.draggable(e, {
3951
+ start: l,
3952
+ stop: a,
3953
+ drag: d
3954
+ }).resizable(e, {
3955
+ start: l,
3956
+ stop: a,
3957
+ resize: d
3958
+ }), i._initDD = !0;
3959
+ }
3960
+ return W.draggable(e, s ? "disable" : "enable").resizable(e, r ? "disable" : "enable"), this;
3961
+ }
3962
+ /** @internal handles actual drag/resize start */
3963
+ _onStartMoving(e, t, i, s, r, o) {
3964
+ var n;
3965
+ if (this.engine.cleanNodes().beginUpdate(s), this._writePosAttr(this.placeholder, s), this.el.appendChild(this.placeholder), this.placeholder.gridstackNode = s, (n = s.grid) != null && n.el)
3966
+ this.dragTransform = u.getValuesFromTransformedElement(e);
3967
+ else if (this.placeholder && this.placeholder.closest(".grid-stack")) {
3968
+ const h = this.placeholder.closest(".grid-stack");
3969
+ this.dragTransform = u.getValuesFromTransformedElement(h);
3970
+ } else
3971
+ this.dragTransform = {
3972
+ xScale: 1,
3973
+ xOffset: 0,
3974
+ yScale: 1,
3975
+ yOffset: 0
3976
+ };
3977
+ if (s.el = this.placeholder, s._lastUiPosition = i.position, s._prevYPix = i.position.top, s._moving = t.type === "dragstart", delete s._lastTried, t.type === "dropover" && s._temporaryRemoved && (this.engine.addNode(s), s._moving = !0), this.engine.cacheRects(r, o, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft), t.type === "resizestart") {
3978
+ const h = this.getColumn() - s.x, l = (this.opts.maxRow || Number.MAX_SAFE_INTEGER) - s.y;
3979
+ W.resizable(e, "option", "minWidth", r * Math.min(s.minW || 1, h)).resizable(e, "option", "minHeight", o * Math.min(s.minH || 1, l)).resizable(e, "option", "maxWidth", r * Math.min(s.maxW || Number.MAX_SAFE_INTEGER, h)).resizable(e, "option", "maxWidthMoveLeft", r * Math.min(s.maxW || Number.MAX_SAFE_INTEGER, s.x + s.w)).resizable(e, "option", "maxHeight", o * Math.min(s.maxH || Number.MAX_SAFE_INTEGER, l)).resizable(e, "option", "maxHeightMoveUp", o * Math.min(s.maxH || Number.MAX_SAFE_INTEGER, s.y + s.h));
3980
+ }
3981
+ }
3982
+ /** @internal handles actual drag/resize */
3983
+ _dragOrResize(e, t, i, s, r, o) {
3984
+ const n = { ...s._orig };
3985
+ let h, l = this.opts.marginLeft, d = this.opts.marginRight, a = this.opts.marginTop, f = this.opts.marginBottom;
3986
+ const y = Math.round(o * 0.1), g = Math.round(r * 0.1);
3987
+ if (l = Math.min(l, g), d = Math.min(d, g), a = Math.min(a, y), f = Math.min(f, y), t.type === "drag") {
3988
+ if (s._temporaryRemoved)
3989
+ return;
3990
+ const p = i.position.top - s._prevYPix;
3991
+ s._prevYPix = i.position.top, this.opts.draggable.scroll !== !1 && u.updateScrollPosition(e, i.position, p);
3992
+ const R = i.position.left + (i.position.left > s._lastUiPosition.left ? -d : l), H = i.position.top + (i.position.top > s._lastUiPosition.top ? -f : a);
3993
+ n.x = Math.round(R / r), n.y = Math.round(H / o);
3994
+ const T = this._extraDragRow;
3995
+ if (this.engine.collide(s, n)) {
3996
+ const q = this.getRow();
3997
+ let x = Math.max(0, n.y + s.h - q);
3998
+ this.opts.maxRow && q + x > this.opts.maxRow && (x = Math.max(0, this.opts.maxRow - q)), this._extraDragRow = x;
3999
+ } else
4000
+ this._extraDragRow = 0;
4001
+ if (this._extraDragRow !== T && this._updateContainerHeight(), s.x === n.x && s.y === n.y)
4002
+ return;
4003
+ } else if (t.type === "resize") {
4004
+ if (n.x < 0 || (u.updateScrollResize(t, e, o), n.w = Math.round((i.size.width - l) / r), n.h = Math.round((i.size.height - a) / o), s.w === n.w && s.h === n.h) || s._lastTried && s._lastTried.w === n.w && s._lastTried.h === n.h)
4005
+ return;
4006
+ const p = i.position.left + l, R = i.position.top + a;
4007
+ n.x = Math.round(p / r), n.y = Math.round(R / o), h = !0;
4008
+ }
4009
+ s._event = t, s._lastTried = n;
4010
+ const v = {
4011
+ x: i.position.left + l,
4012
+ y: i.position.top + a,
4013
+ w: (i.size ? i.size.width : s.w * r) - l - d,
4014
+ h: (i.size ? i.size.height : s.h * o) - a - f
4015
+ };
4016
+ if (this.engine.moveNodeCheck(s, { ...n, cellWidth: r, cellHeight: o, rect: v, resizing: h })) {
4017
+ s._lastUiPosition = i.position, this.engine.cacheRects(r, o, a, d, f, l), delete s._skipDown, h && s.subGrid && s.subGrid.onResize(), this._extraDragRow = 0, this._updateContainerHeight();
4018
+ const p = t.target;
4019
+ s._sidebarOrig || this._writePosAttr(p, s), this._gsEventHandler[t.type] && this._gsEventHandler[t.type](t, p);
4020
+ }
4021
+ }
4022
+ /** @internal called when item leaving our area by either cursor dropout event
4023
+ * or shape is outside our boundaries. remove it from us, and mark temporary if this was
4024
+ * our item to start with else restore prev node values from prev grid it came from.
4025
+ */
4026
+ _leave(e, t) {
4027
+ t = t || e;
4028
+ const i = t.gridstackNode;
4029
+ if (!i || (t.style.transform = t.style.transformOrigin = null, W.off(e, "drag"), i._temporaryRemoved))
4030
+ return;
4031
+ i._temporaryRemoved = !0, this.engine.removeNode(i), i.el = i._isExternal && t ? t : e;
4032
+ const s = i._sidebarOrig;
4033
+ i._isExternal && this.engine.cleanupNode(i), i._sidebarOrig = s, this.opts.removable === !0 && b._itemRemoving(e, !0), e._gridstackNodeOrig ? (e.gridstackNode = e._gridstackNodeOrig, delete e._gridstackNodeOrig) : i._isExternal && this.engine.restoreInitial();
4034
+ }
4035
+ // legacy method removed
4036
+ commit() {
4037
+ return vs(this, this.batchUpdate(!1), "commit", "batchUpdate", "5.2"), this;
4038
+ }
4039
+ }
4040
+ b.renderCB = (c, e) => {
4041
+ c && (e != null && e.content) && (c.textContent = e.content);
4042
+ };
4043
+ b.resizeToContentParent = ".grid-stack-item-content";
4044
+ b.Utils = u;
4045
+ b.Engine = re;
4046
+ b.GDRev = "11.5.1";
4047
+ const Es = ["data-id", "data-testid", "gs-h", "gs-w", "gs-x", "gs-y"], xs = { class: "grid-stack-item-content" }, Cs = /* @__PURE__ */ Q({
4048
+ __name: "DraggableGridLayout",
4049
+ props: {
4050
+ tiles: {},
4051
+ tileHeight: { default: $e }
4052
+ },
4053
+ emits: ["update-tiles"],
4054
+ setup(c, { expose: e, emit: t }) {
4055
+ const i = c, s = t, r = B(null), o = B(new Map(i.tiles.map((y) => [`${y.id}`, y])));
4056
+ let n = null;
4057
+ const h = (y) => `[data-id="${y}"]`, l = (y) => y.map((g) => {
4058
+ var p;
4059
+ const v = o.value.get(`${(p = g.el) == null ? void 0 : p.getAttribute("data-id")}`);
4060
+ if (v)
4061
+ return {
4062
+ ...v,
4063
+ layout: {
4064
+ position: { col: Number(g.x), row: Number(g.y) },
4065
+ size: { cols: Number(g.w), rows: Number(g.h) }
4066
+ }
4067
+ };
4068
+ }).filter((g) => g !== void 0), d = (y, g) => {
4069
+ n && (l(g).forEach((p) => {
4070
+ o.value.set(`${p.id}`, p);
4071
+ }), s("update-tiles", Array.from(o.value.values())));
4072
+ }, a = (y, g) => {
4073
+ g.forEach((v) => {
4074
+ var p;
4075
+ o.value.delete(`${(p = v.el) == null ? void 0 : p.getAttribute("data-id")}`);
4076
+ }), s("update-tiles", Array.from(o.value.values()));
4077
+ };
4078
+ Xe(() => {
4079
+ r.value && (n = b.init({
4080
+ margin: 10,
4081
+ column: At,
4082
+ cellHeight: i.tileHeight,
4083
+ resizable: { handles: "se, sw" },
4084
+ handle: ".tile-header"
4085
+ }, r.value), n.on("change", d), n.on("added", d), n.on("removed", a));
4086
+ }), We(() => {
4087
+ n && n.destroy(!1);
4088
+ });
4089
+ const f = (y) => {
4090
+ if (n && r.value) {
4091
+ const g = r.value.querySelector(h(y));
4092
+ g && n.removeWidget(g);
4093
+ }
4094
+ };
4095
+ return Ke(() => i.tiles.length, async (y, g) => {
4096
+ if (y > g && n) {
4097
+ const v = i.tiles.slice(g);
4098
+ for (const p of v)
4099
+ o.value.set(`${p.id}`, p), await Rt(), n.makeWidget(h(p.id), {
4100
+ autoPosition: !0,
4101
+ w: p.layout.size.cols,
4102
+ h: p.layout.size.rows
4103
+ });
4104
+ }
4105
+ }), Et(() => {
4106
+ i.tiles.forEach((y) => {
4107
+ o.value.set(`${y.id}`, y);
4108
+ });
4109
+ }), e({ removeWidget: f }), (y, g) => (C(), V("div", {
4110
+ ref_key: "gridContainer",
4111
+ ref: r,
4112
+ class: "grid-stack"
4113
+ }, [
4114
+ (C(!0), V(zt, null, Dt(i.tiles, (v) => (C(), V("div", {
4115
+ key: v.id,
4116
+ class: "grid-stack-item",
4117
+ "data-id": `${v.id}`,
4118
+ "data-testid": `grid-stack-item-${v.id}`,
4119
+ "gs-h": v.layout.size.rows,
4120
+ "gs-lazy-load": !0,
4121
+ "gs-w": v.layout.size.cols,
4122
+ "gs-x": v.layout.position.col,
4123
+ "gs-y": v.layout.position.row
4124
+ }, [
4125
+ le("div", xs, [
4126
+ Pe(y.$slots, "tile", { tile: v }, void 0, !0)
4127
+ ])
4128
+ ], 8, Es))), 128))
4129
+ ], 512));
4130
+ }
4131
+ }), Rs = /* @__PURE__ */ ce(Cs, [["__scopeId", "data-v-a68d6821"]]), Ts = { class: "kong-ui-public-dashboard-renderer" }, zs = {
4132
+ key: 0,
4133
+ class: "tile-container slottable-tile"
4134
+ }, Ds = /* @__PURE__ */ Q({
4135
+ __name: "DashboardRenderer",
4136
+ props: /* @__PURE__ */ lt({
4137
+ context: {}
4138
+ }, {
4139
+ modelValue: { required: !0 },
4140
+ modelModifiers: {}
4141
+ }),
4142
+ emits: /* @__PURE__ */ lt(["edit-tile", "tile-time-range-zoom"], ["update:modelValue"]),
4143
+ setup(c, { expose: e, emit: t }) {
4144
+ const i = c, s = t, r = oi(c, "modelValue"), { i18n: o } = _e.useI18n(), n = B(0), h = B(null), l = be(ue);
4145
+ l || (console.warn("Analytics dashboards require a query bridge supplied via provide / inject."), console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"), console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/dashboard-renderer/README.md#requirements")), _e.useRequestQueue();
4146
+ const d = St(), a = S(() => i.context.timeSpec ? i.context.timeSpec : {
4147
+ type: "relative",
4148
+ time_range: d.defaultQueryTimeForOrg
4149
+ }), f = S(() => !!i.context.timeSpec || !d.loading), y = (E, A) => {
4150
+ const N = E.layout.position.row - A.layout.position.row;
4151
+ return N !== 0 ? N : E.layout.position.col - A.layout.position.col;
4152
+ }, g = S(() => r.value.tiles.map((E) => {
4153
+ var N;
4154
+ let A = E.definition;
4155
+ if ("description" in A.chart) {
4156
+ const G = (N = A.chart.description) == null ? void 0 : N.replace(Ii, () => {
4157
+ const oe = `renderer.trendRange.${a.value.type === "absolute" ? "custom" : a.value.time_range}`;
4158
+ return o.te(oe) ? o.t(oe) : "";
4159
+ });
4160
+ A = {
4161
+ ...A,
4162
+ chart: {
4163
+ ...A.chart,
4164
+ description: G
4165
+ }
4166
+ };
4167
+ }
4168
+ return i.context.editable && !E.id && console.warn(
4169
+ "No id provided for tile. One will be generated automatically,",
4170
+ "however tracking changes to this tile may not work as expected.",
4171
+ E
4172
+ ), {
4173
+ layout: E.layout,
4174
+ meta: A,
4175
+ type: E.type,
4176
+ // Add a unique key to each tile internally.
4177
+ id: E.id ?? crypto.randomUUID()
4178
+ };
4179
+ })), v = S(() => {
4180
+ var oe, fe, ke;
4181
+ let { tz: E, refreshInterval: A, editable: N } = i.context;
4182
+ const G = [...i.context.filters ?? [], ...r.value.preset_filters ?? []];
4183
+ E || (E = new Intl.DateTimeFormat().resolvedOptions().timeZone), A === void 0 && (A = qi), N === void 0 && (N = !1);
4184
+ const U = !!((ke = (fe = (oe = ai()) == null ? void 0 : oe.vnode) == null ? void 0 : fe.props) != null && ke.onTileTimeRangeZoom);
4185
+ return {
4186
+ filters: G,
4187
+ tz: E,
4188
+ timeSpec: a.value,
4189
+ refreshInterval: A,
4190
+ editable: N,
4191
+ zoomable: U
4192
+ };
4193
+ }), p = (E) => {
4194
+ s("edit-tile", E);
4195
+ }, R = (E) => E.type === "slottable", H = (E) => {
4196
+ const A = R(E.meta.chart) ? { ...E.meta.chart } : {
4197
+ ...E.meta.chart,
4198
+ chart_title: E.meta.chart.chart_title ? `Copy of ${E.meta.chart.chart_title}` : ""
4199
+ }, N = {
4200
+ id: crypto.randomUUID(),
4201
+ type: "chart",
4202
+ definition: {
4203
+ ...E.meta,
4204
+ chart: A
4205
+ },
4206
+ layout: {
4207
+ position: {
4208
+ col: 0,
4209
+ row: 0
4210
+ },
4211
+ size: E.layout.size
4212
+ }
4213
+ };
4214
+ r.value.tiles.push(N);
4215
+ }, T = (E) => {
4216
+ h.value && h.value.removeWidget(E.id);
4217
+ }, q = () => {
4218
+ n.value++;
4219
+ }, x = (E) => {
4220
+ const A = E.map((N) => ({
4221
+ id: N.id,
4222
+ type: N.type,
4223
+ layout: N.layout,
4224
+ definition: N.meta
4225
+ }));
4226
+ r.value.tiles = A.sort(y);
4227
+ };
4228
+ return e({ refresh: q }), (E, A) => {
4229
+ const N = de("KAlert");
4230
+ return C(), V("div", Ts, [
4231
+ k(l) ? (C(), M(Tt(E.context.editable ? Rs : ys), {
4232
+ key: 1,
4233
+ ref_key: "gridLayoutRef",
4234
+ ref: h,
4235
+ "tile-height": r.value.tile_height,
4236
+ tiles: g.value,
4237
+ onUpdateTiles: x
4238
+ }, {
4239
+ tile: I(({ tile: G }) => [
4240
+ G.meta.chart.type === "slottable" ? (C(), V("div", zs, [
4241
+ Pe(E.$slots, G.meta.chart.id, {}, void 0, !0)
4242
+ ])) : (C(), M(gs, {
4243
+ key: 1,
4244
+ class: "tile-container",
4245
+ context: v.value,
4246
+ definition: G.meta,
4247
+ height: G.layout.size.rows * (r.value.tile_height || k($e)) + parseInt(k(Bt), 10),
4248
+ "query-ready": f.value,
4249
+ "refresh-counter": n.value,
4250
+ "tile-id": G.id,
4251
+ onDuplicateTile: (U) => H(G),
4252
+ onEditTile: (U) => p(G),
4253
+ onRemoveTile: (U) => T(G),
4254
+ onTileTimeRangeZoom: A[0] || (A[0] = (U) => s("tile-time-range-zoom", U))
4255
+ }, null, 8, ["context", "definition", "height", "query-ready", "refresh-counter", "tile-id", "onDuplicateTile", "onEditTile", "onRemoveTile"]))
4256
+ ]),
4257
+ _: 3
4258
+ }, 40, ["tile-height", "tiles"])) : (C(), M(N, {
4259
+ key: 0,
4260
+ appearance: "danger"
4261
+ }, {
4262
+ default: I(() => [
4263
+ Ee(te(k(o).t("renderer.noQueryBridge")), 1)
4264
+ ]),
4265
+ _: 1
4266
+ }))
4267
+ ]);
4268
+ };
4269
+ }
4270
+ }), Ps = /* @__PURE__ */ ce(Ds, [["__scopeId", "data-v-c16badc2"]]);
4271
+ export {
4272
+ Mi as C,
4273
+ Ps as D,
4274
+ ut as E,
4275
+ ys as G,
4276
+ ue as I,
4277
+ Ii as T,
4278
+ Qe as _,
4279
+ $e as a,
4280
+ At as b,
4281
+ qi as c
4282
+ };