@alekstar79/draggable-resizable-container 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,11 +1,11 @@
1
- import './index.css';var z = Object.defineProperty;
2
- var S = (o, t, e) => t in o ? z(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var a = (o, t, e) => S(o, typeof t != "symbol" ? t + "" : t, e);
4
- import f, { reactive as b, computed as x, effect as p } from "@alekstar79/reactive-event-system";
5
- import { clamp as m, deepMerge as M } from "@alekstar79/utility";
6
- class R {
1
+ import './index.css';var Z = Object.defineProperty;
2
+ var _ = (c, t, e) => t in c ? Z(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
+ var r = (c, t, e) => _(c, typeof t != "symbol" ? t + "" : t, e);
4
+ import Q, { reactive as I, computed as tt, effect as x, batch as T } from "@alekstar79/reactive-event-system";
5
+ import { clamp as f, deepMerge as et, debounce as z } from "@alekstar79/utility";
6
+ class it {
7
7
  constructor(t) {
8
- a(this, "container");
8
+ r(this, "container");
9
9
  this.container = t || this.createContainer();
10
10
  }
11
11
  /**
@@ -24,8 +24,8 @@ class R {
24
24
  show(t, e = "info") {
25
25
  const i = document.createElement("li"), s = this.removeToast.bind(this, i);
26
26
  i.innerHTML = this.getToastHTML(t, e), i.className = `toast ${e}`, i.timeoutId = window.setTimeout(s, 4e3);
27
- const r = i.querySelector(".icon");
28
- r && r.addEventListener("click", s), this.container.appendChild(i);
27
+ const a = i.querySelector(".icon");
28
+ a && a.addEventListener("click", s), this.container.appendChild(i);
29
29
  }
30
30
  /**
31
31
  * Generate toast HTML based on type
@@ -60,19 +60,19 @@ class R {
60
60
  this.container.removeChild(this.container.firstChild);
61
61
  }
62
62
  }
63
- new R();
64
- class I {
63
+ new it();
64
+ class pt {
65
65
  /**
66
66
  * Create container element with proper initialization
67
67
  */
68
- static createContainerElement(t, e, i, s, r) {
69
- const n = document.createElement("div");
70
- return n.className = "container advanced-container new", n.style.position = "absolute", n.style.width = `${t}px`, n.style.height = `${e}px`, i !== void 0 && (n.style.left = `${i}px`), s !== void 0 && (n.style.top = `${s}px`), r && (n.style.borderColor = r), n;
68
+ static createContainerElement(t, e, i, s, a) {
69
+ const o = document.createElement("div");
70
+ return o.className = "container advanced-container new", o.style.position = "absolute", o.style.width = `${t}px`, o.style.height = `${e}px`, i !== void 0 && (o.style.left = `${i}px`), s !== void 0 && (o.style.top = `${s}px`), a && (o.style.borderColor = a), o;
71
71
  }
72
72
  }
73
- class k {
73
+ class ft {
74
74
  constructor(t) {
75
- a(this, "templateLoader");
75
+ r(this, "templateLoader");
76
76
  this.templateLoader = t;
77
77
  }
78
78
  /**
@@ -91,8 +91,8 @@ class k {
91
91
  else if (t.template)
92
92
  try {
93
93
  s.innerHTML = await this.templateLoader.loadTemplate(t.template);
94
- } catch (r) {
95
- console.error(`[ContentCreator] Failed to load template: ${t.template}`, r), s.innerHTML = `<div class="template-error">Failed to load template: ${t.template}</div>`;
94
+ } catch (a) {
95
+ console.error(`[ContentCreator] Failed to load template: ${t.template}`, a), s.innerHTML = `<div class="template-error">Failed to load template: ${t.template}</div>`;
96
96
  }
97
97
  return s;
98
98
  } catch (i) {
@@ -106,10 +106,10 @@ class k {
106
106
  this.templateLoader = t;
107
107
  }
108
108
  }
109
- var T = Object.defineProperty, H = (o, t, e) => t in o ? T(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, d = (o, t, e) => H(o, typeof t != "symbol" ? t + "" : t, e);
110
- class C {
109
+ var st = Object.defineProperty, nt = (c, t, e) => t in c ? st(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e, m = (c, t, e) => nt(c, typeof t != "symbol" ? t + "" : t, e);
110
+ class $ {
111
111
  constructor() {
112
- d(this, "templates", /* @__PURE__ */ new Map()), d(this, "lastUpdated", /* @__PURE__ */ new Map());
112
+ m(this, "templates", /* @__PURE__ */ new Map()), m(this, "lastUpdated", /* @__PURE__ */ new Map());
113
113
  }
114
114
  register(t) {
115
115
  if (!t.name.trim()) throw new Error("Template name cannot be empty");
@@ -138,9 +138,9 @@ class C {
138
138
  return (e = this.templates.get(t)) == null ? void 0 : e.metadata;
139
139
  }
140
140
  }
141
- class L {
141
+ class rt {
142
142
  constructor(t = 36e5) {
143
- d(this, "cache", /* @__PURE__ */ new Map()), d(this, "ttl"), this.ttl = t;
143
+ m(this, "cache", /* @__PURE__ */ new Map()), m(this, "ttl"), this.ttl = t;
144
144
  }
145
145
  set(t, e) {
146
146
  this.cache.set(t, { content: e, timestamp: Date.now() });
@@ -159,9 +159,9 @@ class L {
159
159
  return this.cache.size;
160
160
  }
161
161
  }
162
- class A {
162
+ class J {
163
163
  constructor(t, e = {}) {
164
- d(this, "cache"), d(this, "config"), d(this, "metrics"), d(this, "retryQueue", /* @__PURE__ */ new Map()), d(this, "registry"), this.registry = t ?? new C(), this.cache = new L(e == null ? void 0 : e.cacheTTL), this.config = this.normalizeConfig(e), this.metrics = { totalLoads: 0, totalHits: 0, totalMisses: 0, totalErrors: 0, averageLoadTime: 0, cacheHitRate: 0 };
164
+ m(this, "cache"), m(this, "config"), m(this, "metrics"), m(this, "retryQueue", /* @__PURE__ */ new Map()), m(this, "registry"), this.registry = t ?? new $(), this.cache = new rt(e == null ? void 0 : e.cacheTTL), this.config = this.normalizeConfig(e), this.metrics = { totalLoads: 0, totalHits: 0, totalMisses: 0, totalErrors: 0, averageLoadTime: 0, cacheHitRate: 0 };
165
165
  }
166
166
  normalizeConfig(t = {}) {
167
167
  var i;
@@ -173,27 +173,27 @@ class A {
173
173
  async loadTemplate(t, e = 2) {
174
174
  const i = performance.now(), s = this.retryQueue.get(t) ?? 0;
175
175
  if (this.metrics.totalLoads++, this.config.cache) {
176
- const n = this.cache.get(t);
177
- if (n) return this.metrics.totalHits++, this.updateCacheHitRate(), n;
176
+ const o = this.cache.get(t);
177
+ if (o) return this.metrics.totalHits++, this.updateCacheHitRate(), o;
178
178
  }
179
179
  this.metrics.totalMisses++;
180
- const r = this.registry.get(t);
181
- if (!r) {
182
- const n = this.createError(`Template "${t}" not found. Available: ${this.registry.list().join(", ")}`, t, s);
183
- return this.metrics.totalErrors++, this.config.onError(n), this.config.fallbackTemplate;
180
+ const a = this.registry.get(t);
181
+ if (!a) {
182
+ const o = this.createError(`Template "${t}" not found. Available: ${this.registry.list().join(", ")}`, t, s);
183
+ return this.metrics.totalErrors++, this.config.onError(o), this.config.fallbackTemplate;
184
184
  }
185
185
  try {
186
- let n = typeof r.source == "function" ? await r.source() : r.source;
187
- if (typeof n != "string") {
188
- const h = this.createError("Template source must return a string, got " + typeof n, t, s);
186
+ let o = typeof a.source == "function" ? await a.source() : a.source;
187
+ if (typeof o != "string") {
188
+ const h = this.createError("Template source must return a string, got " + typeof o, t, s);
189
189
  return this.metrics.totalErrors++, this.config.onError(h), this.config.fallbackTemplate;
190
190
  }
191
- return this.config.cache && this.cache.set(t, n), this.retryQueue.delete(t), this.recordLoadTime(i), n;
192
- } catch (n) {
193
- const h = n instanceof Error ? n : new Error(String(n));
194
- if (s < e) return this.retryQueue.set(t, s + 1), this.config.onWarn(`Retrying template "${t}" (attempt ${s + 1}/${e})`), await new Promise((u) => setTimeout(u, 100 * Math.pow(2, s))), this.loadTemplate(t, e);
195
- const l = this.createError(`Failed to load template "${t}": ${h.message}`, t, s);
196
- return this.metrics.totalErrors++, this.config.onError(l), this.retryQueue.delete(t), this.config.fallbackTemplate;
191
+ return this.config.cache && this.cache.set(t, o), this.retryQueue.delete(t), this.recordLoadTime(i), o;
192
+ } catch (o) {
193
+ const h = o instanceof Error ? o : new Error(String(o));
194
+ if (s < e) return this.retryQueue.set(t, s + 1), this.config.onWarn(`Retrying template "${t}" (attempt ${s + 1}/${e})`), await new Promise((l) => setTimeout(l, 100 * Math.pow(2, s))), this.loadTemplate(t, e);
195
+ const d = this.createError(`Failed to load template "${t}": ${h.message}`, t, s);
196
+ return this.metrics.totalErrors++, this.config.onError(d), this.retryQueue.delete(t), this.config.fallbackTemplate;
197
197
  }
198
198
  }
199
199
  async loadTemplates(t) {
@@ -233,12 +233,373 @@ class A {
233
233
  this.config.enableMetrics && (this.metrics.cacheHitRate = this.metrics.totalHits / this.metrics.totalLoads);
234
234
  }
235
235
  }
236
- const c = class c {
236
+ let u;
237
+ async function at(c = []) {
238
+ const t = new $();
239
+ let e = {};
240
+ try {
241
+ e = /* @__PURE__ */ Object.assign({
242
+ "../demo/templates/media.html": () => import("./media-BMYuYfio.js").then((s) => s.default),
243
+ "../demo/templates/stats.html": () => import("./stats-CfbjjoNm.js").then((s) => s.default),
244
+ "../demo/templates/tasks.html": () => import("./tasks-dygJ8dHT.js").then((s) => s.default)
245
+ });
246
+ const i = {};
247
+ Object.entries(e).forEach(([s, a]) => {
248
+ var h;
249
+ const o = (h = s.split("/").pop()) == null ? void 0 : h.replace(/\.html$/, "");
250
+ o && (i[o] = async () => typeof a == "function" ? await a() : String(a));
251
+ }), await t.registerBulk(i);
252
+ } catch (i) {
253
+ console.error("[TemplateLoader] Failed to load templates:", i), c.forEach(({ name: s, source: a }) => {
254
+ t.register({ name: s, source: a });
255
+ });
256
+ }
257
+ return new J(t, {
258
+ environment: "development",
259
+ cache: !0,
260
+ cacheTTL: 36e5,
261
+ enableMetrics: !0,
262
+ fallbackTemplate: '<div class="template-error">Template not found</div>',
263
+ onError: (i) => console.error(`[TemplateLoader Error] ${i.templateName}:`, i.message),
264
+ onWarn: (i) => console.warn(`[TemplateLoader] ${i}`)
265
+ });
266
+ }
267
+ function ot() {
268
+ const c = new $();
269
+ return new J(c, {
270
+ environment: "production",
271
+ cache: !0,
272
+ cacheTTL: 36e5,
273
+ enableMetrics: !1,
274
+ onWarn: (t) => console.warn(`[TemplateLoader] ${t}`),
275
+ onError: (t) => {
276
+ console.warn(`Template load failed: ${t.templateName}`);
277
+ }
278
+ });
279
+ }
280
+ async function vt() {
281
+ return u || (// @ts-ignore - Vite environment variable
282
+ typeof process < "u" && process.env && process.env.NODE_ENV === "development" ? u = await at() : (u = ot(), u.registry.register({
283
+ name: "media",
284
+ source: async () => (await fetch("./templates/media.html")).text(),
285
+ metadata: {
286
+ version: "1.0",
287
+ description: "Media card",
288
+ cached: !0
289
+ }
290
+ }), u.registry.register({
291
+ name: "userProfile",
292
+ source: '<div class="user-profile"><h2>Profile</h2></div>',
293
+ metadata: {
294
+ version: "1.0",
295
+ description: "User profile card",
296
+ cached: !0
297
+ }
298
+ })), u);
299
+ }
300
+ function St() {
301
+ if (!u)
302
+ throw new Error("Template system not initialized. Call initializeTemplateSystem() first.");
303
+ return u;
304
+ }
305
+ function ct(c, [t, e]) {
306
+ return e ? { ...c, [t]: e } : c;
307
+ }
308
+ class W {
309
+ constructor(t) {
310
+ r(this, "source", "cursor");
311
+ r(this, "element", null);
312
+ r(this, "top", !1);
313
+ r(this, "right", !1);
314
+ r(this, "bottom", !1);
315
+ r(this, "left", !1);
316
+ r(this, "edge", null);
317
+ Object.assign(this, t);
318
+ }
319
+ }
320
+ class X {
237
321
  constructor() {
238
- a(this, "draggable", []);
322
+ r(this, "listeners", {});
323
+ }
324
+ on(t, e) {
325
+ return this.listeners[t] || (this.listeners[t] = /* @__PURE__ */ new Set()), this.listeners[t].add(e), () => {
326
+ var i;
327
+ (i = this.off) == null || i.call(this, t, e);
328
+ };
329
+ }
330
+ emit(t, e) {
331
+ var i;
332
+ (i = this.listeners[t]) == null || i.forEach((s) => {
333
+ try {
334
+ s(e);
335
+ } catch (a) {
336
+ console.error(`Error in event listener for ${String(t)}:`, a);
337
+ }
338
+ });
339
+ }
340
+ off(t, e) {
341
+ var i;
342
+ (i = this.listeners[t]) == null || i.delete(e);
343
+ }
344
+ destroy() {
345
+ this.listeners = {};
346
+ }
347
+ }
348
+ class ht {
349
+ constructor(t = 50, e, i = null) {
350
+ r(this, "root");
351
+ r(this, "edgeThreshold");
352
+ r(this, "targets", /* @__PURE__ */ new Set());
353
+ r(this, "currentEdges", /* @__PURE__ */ new Map());
354
+ r(this, "rafId", null);
355
+ r(this, "isActive", !1);
356
+ r(this, "callbacks", /* @__PURE__ */ new Set());
357
+ r(this, "currentMousePos", { x: 0, y: 0 });
358
+ r(this, "currentCursorEdge", {
359
+ top: !1,
360
+ right: !1,
361
+ bottom: !1,
362
+ left: !1,
363
+ edge: null
364
+ });
365
+ this.edgeThreshold = t, this.targets = e instanceof Set ? e : new Set(e), this.root = i, e && e.forEach((s) => this.targets.add(s)), this.checkBoundaries = this.checkBoundaries.bind(this);
366
+ }
367
+ /**
368
+ * Start tracking the approach to the edges
369
+ */
370
+ start() {
371
+ this.isActive || (this.isActive = !0, this.setupMouseTracking(), this.checkBoundaries());
372
+ }
373
+ /**
374
+ * Stop tracking
375
+ */
376
+ stop() {
377
+ this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.isActive = !1;
378
+ }
379
+ addTarget(t) {
380
+ this.targets.add(t);
381
+ }
382
+ removeTarget(t) {
383
+ this.targets.delete(t), this.currentEdges.delete(t);
384
+ }
385
+ /**
386
+ * Subscribe to boundary changes
387
+ */
388
+ onChange(t) {
389
+ return this.callbacks.add(t), () => {
390
+ this.callbacks.delete(t);
391
+ };
392
+ }
393
+ /**
394
+ * Get current information about cursor boundaries
395
+ */
396
+ getCursorEdgeInfo() {
397
+ return { ...this.currentCursorEdge };
398
+ }
399
+ /**
400
+ * Update threshold (distance to edge)
401
+ */
402
+ setEdgeThreshold(t) {
403
+ if (t < 0)
404
+ throw new Error("Edge threshold must be non-negative");
405
+ this.edgeThreshold = t;
406
+ }
407
+ /**
408
+ * Set up Mouse Tracking
409
+ */
410
+ setupMouseTracking() {
411
+ document.addEventListener("mousemove", (t) => {
412
+ this.currentMousePos = { x: t.clientX, y: t.clientY };
413
+ });
414
+ }
415
+ getViewportSize() {
416
+ return this.root ? { width: this.root.clientWidth, height: this.root.clientHeight } : { width: window.innerWidth, height: window.innerHeight };
417
+ }
418
+ getRelativeRect(t) {
419
+ const e = t.getBoundingClientRect();
420
+ if (!this.root) return e;
421
+ const i = this.root.getBoundingClientRect();
422
+ return {
423
+ x: e.left - i.left,
424
+ y: e.top - i.top,
425
+ top: e.top - i.top,
426
+ bottom: e.bottom - i.top,
427
+ left: e.left - i.left,
428
+ right: e.right - i.left,
429
+ height: e.height,
430
+ width: e.width,
431
+ toJSON: () => {
432
+ }
433
+ };
434
+ }
435
+ getCursorPosition() {
436
+ if (!this.root) return this.currentMousePos;
437
+ const t = this.root.getBoundingClientRect();
438
+ return {
439
+ x: this.currentMousePos.x - t.left,
440
+ y: this.currentMousePos.y - t.top
441
+ };
442
+ }
443
+ /**
444
+ * Check the proximity to the borders (element and cursor)
445
+ */
446
+ checkBoundaries() {
447
+ this.targets.forEach((e) => {
448
+ const i = this.checkElementBoundaries(e), s = this.currentEdges.get(e);
449
+ (!s || this.hasEdgeChanged(s, i)) && (this.currentEdges.set(e, i), this.notifyCallbacks(new W({ ...i, source: "element", element: e })));
450
+ });
451
+ const t = this.checkCursorBoundaries();
452
+ this.hasEdgeChanged(this.currentCursorEdge, t) && (this.currentCursorEdge = t, this.notifyCallbacks(new W({ ...t, source: "cursor", element: null }))), this.isActive && (this.rafId = requestAnimationFrame(
453
+ this.checkBoundaries
454
+ ));
455
+ }
456
+ /**
457
+ * Emulating Bounding Rect for cursor
458
+ */
459
+ getCursorBoundingClientRect() {
460
+ const { x: t, y: e } = this.getCursorPosition();
461
+ return {
462
+ x: t,
463
+ y: e,
464
+ top: e,
465
+ bottom: e,
466
+ left: t,
467
+ right: t,
468
+ width: 0,
469
+ height: 0,
470
+ toJSON: () => {
471
+ }
472
+ };
473
+ }
474
+ /**
475
+ * Check the boundaries of an element
476
+ */
477
+ checkElementBoundaries(t) {
478
+ const { width: e, height: i } = this.getViewportSize(), s = this.getRelativeRect(t), a = {
479
+ top: s.top < this.edgeThreshold,
480
+ right: s.right > e - this.edgeThreshold,
481
+ bottom: s.bottom > i - this.edgeThreshold,
482
+ left: s.left < this.edgeThreshold,
483
+ edge: null
484
+ };
485
+ return this.determineEdge(a, s, e, i), a;
486
+ }
487
+ /**
488
+ * Check the boundaries of a cursor
489
+ */
490
+ checkCursorBoundaries() {
491
+ const t = this.getCursorBoundingClientRect(), e = window.innerWidth, i = window.innerHeight, s = {
492
+ top: t.top < this.edgeThreshold,
493
+ right: t.right > e - this.edgeThreshold,
494
+ bottom: t.bottom > i - this.edgeThreshold,
495
+ left: t.left < this.edgeThreshold,
496
+ edge: null
497
+ };
498
+ return this.determineEdge(s, t, e, i), s;
499
+ }
500
+ /**
501
+ * Check if the state has changed
502
+ */
503
+ hasEdgeChanged(t, e) {
504
+ return t.top !== e.top || t.right !== e.right || t.bottom !== e.bottom || t.left !== e.left;
505
+ }
506
+ /**
507
+ * Determine a priority edge-side (or several)
508
+ */
509
+ determineEdge(t, e, i, s) {
510
+ const a = [];
511
+ if (t.top && a.push("top"), t.right && a.push("right"), t.bottom && a.push("bottom"), t.left && a.push("left"), a.length === 0)
512
+ t.edge = null;
513
+ else if (a.length === 1)
514
+ t.edge = a[0];
515
+ else {
516
+ const o = {
517
+ top: e.top,
518
+ right: i - e.right,
519
+ bottom: s - e.bottom,
520
+ left: e.left
521
+ };
522
+ t.edge = a.reduce(
523
+ (h, d) => o[d] < o[h] ? d : h
524
+ );
525
+ }
526
+ }
527
+ /**
528
+ * Notify all subscribers of the change
529
+ */
530
+ notifyCallbacks(t) {
531
+ this.callbacks.forEach((e) => {
532
+ try {
533
+ e(t);
534
+ } catch (i) {
535
+ console.error("Error in boundary change callback:", i);
536
+ }
537
+ });
538
+ }
539
+ /**
540
+ * Clear resources
541
+ */
542
+ destroy() {
543
+ this.stop(), this.callbacks.clear();
544
+ }
545
+ }
546
+ const y = class y extends ht {
547
+ constructor(e, i) {
548
+ super(e, i);
549
+ r(this, "lastEdge", {});
550
+ r(this, "emitter", null);
551
+ this.onChange(this.onBoundaryChange.bind(this)), this.start();
552
+ }
553
+ static init(e, i) {
554
+ return y.instance ?? (y.instance = new y(e, i));
555
+ }
556
+ changed({ edge: e, source: i, element: s }) {
557
+ return e !== this.lastEdge.edge || i !== this.lastEdge.source || s !== this.lastEdge.element;
558
+ }
559
+ onBoundaryChange({ edge: e, source: i, element: s }) {
560
+ this.changed({ edge: e, source: i, element: s }) && (this.lastEdge = Object.entries({ edge: e, source: i, element: s }).reduce(ct, {}), s ? e ? this.onEdgeEnter({ edge: e, source: i, element: s }) : this.onEdgeLeave(this.lastEdge) : e ? this.onCursorEnter({ edge: e, source: i }) : this.onCursorLeave(this.lastEdge));
561
+ }
562
+ onEdgeEnter(e) {
563
+ var i;
564
+ (i = this.emitter) == null || i.emit("edge:enter", e);
565
+ }
566
+ onEdgeLeave(e) {
567
+ var i;
568
+ (i = this.emitter) == null || i.emit("edge:leave", e);
569
+ }
570
+ onCursorEnter(e) {
571
+ var i;
572
+ (i = this.emitter) == null || i.emit("cursor:enter", e);
573
+ }
574
+ onCursorLeave(e) {
575
+ var i;
576
+ (i = this.emitter) == null || i.emit("cursor:leave", e);
577
+ }
578
+ setEmitter(e) {
579
+ this.emitter = e;
580
+ }
581
+ on(e, i) {
582
+ var s;
583
+ (s = this.emitter) == null || s.on(e, i);
584
+ }
585
+ getCurrentEdge() {
586
+ return this.lastEdge;
587
+ }
588
+ };
589
+ r(y, "instance");
590
+ let P = y;
591
+ function dt(c = {}, t = []) {
592
+ const e = P.init(c.edgeThreshold, t);
593
+ return c.emitter && e.setEmitter(
594
+ c.emitter instanceof X ? c.emitter : new X()
595
+ ), e;
596
+ }
597
+ const g = class g {
598
+ constructor() {
599
+ r(this, "draggable", []);
239
600
  }
240
601
  zIndex(t) {
241
- return `${c.highestZIndex + this.draggable.findIndex((e) => e === t)}`;
602
+ return `${g.highestZIndex + this.draggable.findIndex((e) => e === t)}`;
242
603
  }
243
604
  push(t) {
244
605
  return this.draggable = [.../* @__PURE__ */ new Set([...this.draggable, t])], this;
@@ -250,18 +611,18 @@ const c = class c {
250
611
  return this.draggable.sort((e, i) => e === t ? 1 : i === t ? -1 : 0), this;
251
612
  }
252
613
  };
253
- a(c, "inatance"), a(c, "highestZIndex", 1e3), a(c, "init", () => c.inatance ?? (c.inatance = new c()));
254
- let v = c;
255
- function w() {
614
+ r(g, "inatance"), r(g, "highestZIndex", 1e3), r(g, "init", () => g.inatance ?? (g.inatance = new g()));
615
+ let O = g;
616
+ function V() {
256
617
  return {
257
618
  width: window.innerWidth || document.documentElement.clientWidth,
258
619
  height: window.innerHeight || document.documentElement.clientHeight
259
620
  };
260
621
  }
261
- function D() {
262
- return v.init();
622
+ function lt() {
623
+ return O.init();
263
624
  }
264
- const g = class g {
625
+ const v = class v {
265
626
  /**
266
627
  * Create a new container manager instance with reactive state management
267
628
  * @param container - HTML element to manage
@@ -269,27 +630,27 @@ const g = class g {
269
630
  */
270
631
  constructor(t, e = {}) {
271
632
  // Streams for reactive event handling
272
- a(this, "dragStream");
273
- a(this, "resizeStream");
274
- a(this, "stateChangeStream");
275
- a(this, "eventEmitter");
276
- a(this, "pluginEventEmitter");
277
- a(this, "config");
278
- a(this, "container");
279
- a(this, "dragHandle");
280
- a(this, "resizeHandles", /* @__PURE__ */ new Map());
281
- a(this, "installedPlugins", /* @__PURE__ */ new Set());
282
- a(this, "reactiveEffects", []);
283
- a(this, "isDragging", !1);
284
- a(this, "isResizing", !1);
285
- a(this, "resizeDirection", null);
286
- a(this, "startX", 0);
287
- a(this, "startY", 0);
288
- a(this, "startState");
289
- a(this, "resizeObserver", null);
290
- a(this, "parentResizeObserver", null);
291
- a(this, "zIndexState");
292
- a(this, "reactiveState", b({
633
+ r(this, "dragStream");
634
+ r(this, "resizeStream");
635
+ r(this, "stateChangeStream");
636
+ r(this, "eventEmitter");
637
+ r(this, "pluginEventEmitter");
638
+ r(this, "config");
639
+ r(this, "container");
640
+ r(this, "dragHandle");
641
+ r(this, "resizeHandles", /* @__PURE__ */ new Map());
642
+ r(this, "installedPlugins", /* @__PURE__ */ new Set());
643
+ r(this, "reactiveEffects", []);
644
+ r(this, "isDragging", !1);
645
+ r(this, "isResizing", !1);
646
+ r(this, "resizeDirection", null);
647
+ r(this, "startX", 0);
648
+ r(this, "startY", 0);
649
+ r(this, "startState");
650
+ r(this, "resizeObserver", null);
651
+ r(this, "parentResizeObserver", null);
652
+ r(this, "zIndexState");
653
+ r(this, "reactiveState", I({
293
654
  x: 0,
294
655
  y: 0,
295
656
  width: 0,
@@ -298,28 +659,28 @@ const g = class g {
298
659
  draggingDirection: "all"
299
660
  }));
300
661
  // Computed state with applied constraints
301
- a(this, "constrainedState", x(() => {
662
+ r(this, "constrainedState", tt(() => {
302
663
  var s;
303
664
  const t = this.reactiveState;
304
665
  if (!this.config) return { ...t };
305
666
  let e = { ...t };
306
667
  const { boundaries: i } = this.config;
307
- if (e.width = m(
668
+ if (e.width = f(
308
669
  t.width,
309
- i.minWidth || g.MINWIDTH,
670
+ i.minWidth || v.MINWIDTH,
310
671
  i.maxWidth || 1 / 0
311
- ), e.height = m(
672
+ ), e.height = f(
312
673
  t.height,
313
- i.minHeight || g.MINHEIGHT,
674
+ i.minHeight || v.MINHEIGHT,
314
675
  i.maxHeight || 1 / 0
315
676
  ), this.shouldConstrainToViewport()) {
316
- const r = w();
317
- e.x = m(t.x, 0, r.width - e.width), e.y = m(t.y, 0, r.height - e.height);
677
+ const a = V();
678
+ e.x = f(t.x, 0, a.width - e.width), e.y = f(t.y, 0, a.height - e.height);
318
679
  }
319
680
  return (s = this.config) != null && s.constrainToParent && (e = this.constrainToParent(e)), e;
320
681
  }));
321
682
  // Automatic DOM updates with reactive effect
322
- a(this, "domUpdateEffect", p(() => {
683
+ r(this, "domUpdateEffect", x(() => {
323
684
  var e;
324
685
  const t = this.constrainedState.value;
325
686
  this.container && (this.container.style.left = `${t.x}px`, this.container.style.top = `${t.y}px`, this.container.style.width = `${t.width}px`, this.container.style.height = `${t.height}px`, (e = this.eventEmitter) == null || e.emit("stateChange", {
@@ -329,15 +690,15 @@ const g = class g {
329
690
  element: this.container
330
691
  }));
331
692
  }));
332
- this.config = M({
693
+ this.config = et({
333
694
  _uid: "",
334
695
  mode: "smooth",
335
696
  constrainToViewport: !1,
336
697
  draggingDirection: "all",
337
698
  constrainToParent: !1,
338
699
  boundaries: {
339
- minWidth: g.MINWIDTH,
340
- minHeight: g.MINHEIGHT
700
+ minWidth: v.MINWIDTH,
701
+ minHeight: v.MINHEIGHT
341
702
  },
342
703
  autoAdjust: {
343
704
  enabled: !1,
@@ -348,9 +709,9 @@ const g = class g {
348
709
  enabled: !0,
349
710
  directions: ["se"]
350
711
  }
351
- }, e), this.container = t, this.zIndexState = D();
712
+ }, e), this.container = t, this.zIndexState = lt();
352
713
  const i = this.getCurrentState();
353
- this.reactiveState.x = i.x, this.reactiveState.y = i.y, this.reactiveState.width = i.width, this.reactiveState.height = i.height, this.reactiveState.mode = this.config.mode, this.reactiveState.draggingDirection = this.config.draggingDirection, this.eventEmitter = new f({ enableMetrics: !0 }), this.pluginEventEmitter = new f({ enableMetrics: !0 }), this.stateChangeStream = this.eventEmitter.stream("stateChange"), this.dragStream = this.eventEmitter.stream("drag"), this.resizeStream = this.eventEmitter.stream("resize"), this.startState = this.getState(), this.setupEventMiddleware(), this.initializeHandles(), this.bindEvents(), this.setupResizeObservers(), this.setupReactiveMonitoring();
714
+ this.reactiveState.x = i.x, this.reactiveState.y = i.y, this.reactiveState.width = i.width, this.reactiveState.height = i.height, this.reactiveState.mode = this.config.mode, this.reactiveState.draggingDirection = this.config.draggingDirection, this.eventEmitter = new Q({ enableMetrics: !0 }), this.pluginEventEmitter = new Q({ enableMetrics: !0 }), this.stateChangeStream = this.eventEmitter.stream("stateChange"), this.dragStream = this.eventEmitter.stream("drag"), this.resizeStream = this.eventEmitter.stream("resize"), this.startState = this.getState(), this.setupEventMiddleware(), this.initializeHandles(), this.bindEvents(), this.setupResizeObservers(), this.setupReactiveMonitoring();
354
715
  }
355
716
  /**
356
717
  * Set up ResizeObserver to track viewport and parent size changes
@@ -381,7 +742,7 @@ const g = class g {
381
742
  */
382
743
  handleViewportResize() {
383
744
  if (!this.shouldConstrainToViewport()) return;
384
- const t = w(), i = { ...this.getState() };
745
+ const t = V(), i = { ...this.getState() };
385
746
  let s = !1;
386
747
  i.x + i.width > t.width && (i.x = Math.max(0, t.width - i.width), s = !0), i.y + i.height > t.height && (i.y = Math.max(0, t.height - i.height), s = !0), i.x < 0 && (i.x = 0, s = !0), i.y < 0 && (i.y = 0, s = !0), s && (this.setState(i), this.eventEmitter.emit("viewportResize", {
387
748
  type: "viewportResize",
@@ -406,17 +767,17 @@ const g = class g {
406
767
  handleParentResize(t) {
407
768
  const { autoAdjust: e } = this.config;
408
769
  if (!(e != null && e.enabled)) return;
409
- const i = t.contentRect, r = { ...this.getState() };
410
- let n = !1;
770
+ const i = t.contentRect, a = { ...this.getState() };
771
+ let o = !1;
411
772
  if (e.width) {
412
- const h = this.getMaxWidthConstraint(), l = Math.min(i.width, h);
413
- Math.abs(r.width - l) > 1 && (r.width = l, n = !0);
773
+ const h = this.getMaxWidthConstraint(), d = Math.min(i.width, h);
774
+ Math.abs(a.width - d) > 1 && (a.width = d, o = !0);
414
775
  }
415
776
  if (e.height) {
416
- const h = this.getMaxHeightConstraint(), l = Math.min(i.height, h);
417
- Math.abs(r.height - l) > 1 && (r.height = l, n = !0);
777
+ const h = this.getMaxHeightConstraint(), d = Math.min(i.height, h);
778
+ Math.abs(a.height - d) > 1 && (a.height = d, o = !0);
418
779
  }
419
- n && (this.setState(r), this.eventEmitter.emit("autoAdjust", {
780
+ o && (this.setState(a), this.eventEmitter.emit("autoAdjust", {
420
781
  type: "autoAdjust",
421
782
  state: this.getState(),
422
783
  mode: this.reactiveState.mode,
@@ -558,12 +919,12 @@ const g = class g {
558
919
  const i = e.getBoundingClientRect();
559
920
  if (i.width === 0 || i.height === 0)
560
921
  return t;
561
- const s = Math.max(0, i.width - t.width), r = Math.max(0, i.height - t.height), n = i.width - t.x, h = i.height - t.y;
922
+ const s = Math.max(0, i.width - t.width), a = Math.max(0, i.height - t.height), o = i.width - t.x, h = i.height - t.y;
562
923
  return {
563
- x: m(t.x, 0, s),
564
- y: m(t.y, 0, r),
565
- width: m(t.width, 0, n),
566
- height: m(t.height, 0, h)
924
+ x: f(t.x, 0, s),
925
+ y: f(t.y, 0, a),
926
+ width: f(t.width, 0, o),
927
+ height: f(t.height, 0, h)
567
928
  };
568
929
  }
569
930
  /**
@@ -628,11 +989,11 @@ const g = class g {
628
989
  * Setup reactive monitoring for container metrics
629
990
  */
630
991
  setupReactiveMonitoring() {
631
- const t = p(() => {
992
+ const t = x(() => {
632
993
  const { state: i } = this.stateChangeStream;
633
994
  });
634
995
  this.reactiveEffects.push(t);
635
- const e = p(() => {
996
+ const e = x(() => {
636
997
  const i = this.eventEmitter.getMetrics();
637
998
  i.state.errorCount > 10 && console.warn("[ContainerManager] High error count in event system:", i.state.errorCount);
638
999
  });
@@ -738,8 +1099,8 @@ const g = class g {
738
1099
  const { clientX: e, clientY: i } = this.directionResolver(
739
1100
  t instanceof MouseEvent ? t.clientX : t.touches[0].clientX,
740
1101
  t instanceof MouseEvent ? t.clientY : t.touches[0].clientY
741
- ), s = e - this.startX, r = i - this.startY, n = this.applyMovementMode(s, r);
742
- this.setState(n), this.eventEmitter.emit("drag", {
1102
+ ), s = e - this.startX, a = i - this.startY, o = this.applyMovementMode(s, a);
1103
+ this.setState(o), this.eventEmitter.emit("drag", {
743
1104
  type: "drag",
744
1105
  state: this.getState(),
745
1106
  mode: this.reactiveState.mode,
@@ -776,8 +1137,8 @@ const g = class g {
776
1137
  */
777
1138
  onResizeMove(t) {
778
1139
  if (!this.isResizing || !this.resizeDirection) return;
779
- const e = t instanceof MouseEvent ? t.clientX : t.touches[0].clientX, i = t instanceof MouseEvent ? t.clientY : t.touches[0].clientY, s = e - this.startX, r = i - this.startY, n = this.calculateResizeState(s, r, this.resizeDirection);
780
- this.setState(n), this.eventEmitter.emit("resize", {
1140
+ const e = t instanceof MouseEvent ? t.clientX : t.touches[0].clientX, i = t instanceof MouseEvent ? t.clientY : t.touches[0].clientY, s = e - this.startX, a = i - this.startY, o = this.calculateResizeState(s, a, this.resizeDirection);
1141
+ this.setState(o), this.eventEmitter.emit("resize", {
781
1142
  type: "resize",
782
1143
  state: this.getState(),
783
1144
  mode: this.reactiveState.mode,
@@ -812,10 +1173,10 @@ const g = class g {
812
1173
  * Resolve coordinates based on current direction mode
813
1174
  */
814
1175
  directionResolver(t, e) {
815
- const i = this.reactiveState.draggingDirection, s = i === "vertical", r = i === "horizontal";
1176
+ const i = this.reactiveState.draggingDirection, s = i === "vertical", a = i === "horizontal";
816
1177
  return {
817
1178
  clientX: s ? this.startX : t,
818
- clientY: r ? this.startY : e
1179
+ clientY: a ? this.startY : e
819
1180
  };
820
1181
  }
821
1182
  /**
@@ -913,12 +1274,12 @@ const g = class g {
913
1274
  const t = this.container.parentElement.getBoundingClientRect(), e = this.getState();
914
1275
  if (t.width === 0 || t.height === 0)
915
1276
  return;
916
- const i = e.width, s = e.height, r = Math.min(i, t.width), n = Math.min(s, t.height), h = e.x, l = e.y, u = Math.min(h, t.width - r), y = Math.min(l, t.height - n);
1277
+ const i = e.width, s = e.height, a = Math.min(i, t.width), o = Math.min(s, t.height), h = e.x, d = e.y, l = Math.min(h, t.width - a), S = Math.min(d, t.height - o);
917
1278
  this.setState({
918
- x: u,
919
- y,
920
- width: r,
921
- height: n
1279
+ x: l,
1280
+ y: S,
1281
+ width: a,
1282
+ height: o
922
1283
  }), this.eventEmitter.emit("parentRecalculated", {
923
1284
  type: "parentRecalculated",
924
1285
  state: this.getState(),
@@ -959,12 +1320,899 @@ const g = class g {
959
1320
  }), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.parentResizeObserver && (this.parentResizeObserver.disconnect(), this.parentResizeObserver = null), this.installedPlugins.clear(), this.zIndexState.remove(this.config._uid);
960
1321
  }
961
1322
  };
962
- a(g, "MINWIDTH", 200), a(g, "MINHEIGHT", 45);
963
- let E = g;
1323
+ r(v, "MINWIDTH", 200), r(v, "MINHEIGHT", 45);
1324
+ let G = v;
1325
+ const k = class k {
1326
+ constructor(t = {}) {
1327
+ // Plugin state
1328
+ r(this, "reactiveState", I({
1329
+ snapStep: 10,
1330
+ enabled: !0,
1331
+ isActive: !1,
1332
+ lastPosition: null
1333
+ }));
1334
+ r(this, "manager");
1335
+ r(this, "startState", null);
1336
+ r(this, "startX", 0);
1337
+ r(this, "startY", 0);
1338
+ this.reactiveState.snapStep = t.snapStep ?? 10, this.reactiveState.enabled = t.enabled ?? !0, this.onDragMove = this.onDragMove.bind(this), this.onDragEnd = this.onDragEnd.bind(this);
1339
+ }
1340
+ get pluginId() {
1341
+ return k._pluginId;
1342
+ }
1343
+ /**
1344
+ * Install plugin on container manager instance with reactive state
1345
+ */
1346
+ install(t, e) {
1347
+ this.manager = t, e && (this.reactiveState.snapStep = e.snapStep ?? this.reactiveState.snapStep, this.reactiveState.enabled = e.enabled ?? this.reactiveState.enabled), this.overrideDragMethods(), this.addPluginMethods();
1348
+ }
1349
+ /**
1350
+ * Override drag handling methods to add snapping functionality
1351
+ */
1352
+ overrideDragMethods() {
1353
+ if (!this.manager) return;
1354
+ const t = this.manager.getContainer().querySelector(".drag-handle");
1355
+ t && (t.onmousedown = (e) => {
1356
+ this.onDragStart(e);
1357
+ }, t.ontouchstart = (e) => {
1358
+ this.onDragStart(e);
1359
+ });
1360
+ }
1361
+ /**
1362
+ * Handle drag start event with snapping support
1363
+ */
1364
+ onDragStart(t) {
1365
+ var s, a;
1366
+ if (!this.manager || this.manager.getMode() === "pinned") return;
1367
+ t.preventDefault(), (a = (s = this.manager).bringToFront) == null || a.call(s), this.reactiveState.isActive = !0;
1368
+ const e = t instanceof MouseEvent ? t.clientX : t.touches[0].clientX, i = t instanceof MouseEvent ? t.clientY : t.touches[0].clientY;
1369
+ this.startX = e, this.startY = i, this.startState = this.manager.getState(), this.reactiveState.lastPosition = { x: this.startState.x, y: this.startState.y }, document.addEventListener("mousemove", this.onDragMove), document.addEventListener("mouseup", this.onDragEnd), document.addEventListener("touchmove", this.onDragMove), document.addEventListener("touchend", this.onDragEnd), this.manager.emitPluginEvent("dragStart", {
1370
+ type: "drag",
1371
+ state: this.startState,
1372
+ mode: this.manager.getMode()
1373
+ });
1374
+ }
1375
+ /**
1376
+ * Handle drag movement with reactive snapping
1377
+ */
1378
+ onDragMove(t) {
1379
+ if (!this.reactiveState.isActive || !this.manager || !this.startState) return;
1380
+ const { clientX: e, clientY: i } = this.manager.directionResolver(
1381
+ t instanceof MouseEvent ? t.clientX : t.touches[0].clientX,
1382
+ t instanceof MouseEvent ? t.clientY : t.touches[0].clientY
1383
+ );
1384
+ let s = e - this.startX, a = i - this.startY;
1385
+ if (this.reactiveState.enabled) {
1386
+ const d = this.applySnapping(s, a);
1387
+ s = d.deltaX, a = d.deltaY;
1388
+ }
1389
+ const o = {
1390
+ x: this.startState.x + s,
1391
+ y: this.startState.y + a,
1392
+ width: this.startState.width,
1393
+ height: this.startState.height
1394
+ }, h = this.manager.config;
1395
+ h != null && h.constrainToViewport && this.constrainToViewport(o), this.manager.setState(o), this.reactiveState.lastPosition = { x: o.x, y: o.y }, this.manager.emitPluginEvent("drag", {
1396
+ type: "drag",
1397
+ state: o,
1398
+ mode: this.manager.getMode()
1399
+ });
1400
+ }
1401
+ /**
1402
+ * Handle drag end event
1403
+ */
1404
+ onDragEnd() {
1405
+ this.manager && (this.reactiveState.isActive = !1, this.reactiveState.lastPosition = null, this.startState = null, document.removeEventListener("mousemove", this.onDragMove), document.removeEventListener("mouseup", this.onDragEnd), document.removeEventListener("touchmove", this.onDragMove), document.removeEventListener("touchend", this.onDragEnd), this.manager.emitPluginEvent("dragEnd", {
1406
+ type: "drag",
1407
+ state: this.manager.getState(),
1408
+ mode: this.manager.getMode()
1409
+ }));
1410
+ }
1411
+ /**
1412
+ * Apply snapping to drag movement based on current mode
1413
+ */
1414
+ applySnapping(t, e) {
1415
+ return {
1416
+ deltaX: this.snapToGrid(t, this.reactiveState.snapStep),
1417
+ deltaY: this.snapToGrid(e, this.reactiveState.snapStep)
1418
+ };
1419
+ }
1420
+ /**
1421
+ * Snap value to grid using reactive step
1422
+ */
1423
+ snapToGrid(t, e) {
1424
+ return Math.round(t / e) * e;
1425
+ }
1426
+ /**
1427
+ * Constrain container to viewport boundaries
1428
+ */
1429
+ constrainToViewport(t) {
1430
+ const e = window.innerWidth || document.documentElement.clientWidth, i = window.innerHeight || document.documentElement.clientHeight;
1431
+ t.x = Math.max(0, Math.min(t.x, e - t.width)), t.y = Math.max(0, Math.min(t.y, i - t.height));
1432
+ }
1433
+ /**
1434
+ * Add plugin methods to container manager
1435
+ */
1436
+ addPluginMethods() {
1437
+ this.manager.setSnapStep = (t) => {
1438
+ this.reactiveState.snapStep = t, this.manager.emitPluginEvent("snapStepChanged", { snapStep: t });
1439
+ }, this.manager.setSnappingEnabled = (t) => {
1440
+ this.reactiveState.enabled = t, this.manager.emitPluginEvent("snappingEnabledChanged", { enabled: t });
1441
+ }, this.manager.getSnappingConfig = () => ({
1442
+ snapStep: this.reactiveState.snapStep,
1443
+ enabled: this.reactiveState.enabled
1444
+ });
1445
+ }
1446
+ /**
1447
+ * Clean up plugin resources
1448
+ */
1449
+ destroy() {
1450
+ this.reactiveState.isActive = !1, this.reactiveState.lastPosition = null;
1451
+ }
1452
+ };
1453
+ r(k, "_pluginId", Symbol("SnappingPlugin"));
1454
+ let U = k;
1455
+ const R = class R {
1456
+ constructor(t = {}) {
1457
+ r(this, "dockedContainers", /* @__PURE__ */ new Map());
1458
+ r(this, "occupiedEdges", /* @__PURE__ */ new Map());
1459
+ r(this, "tracker", dt({ emitter: !0, edgeThreshold: 20 }));
1460
+ r(this, "manager");
1461
+ r(this, "edgeThreshold");
1462
+ this.edgeThreshold = t.edgeThreshold ?? 30, this.occupiedEdges.set("top", null), this.occupiedEdges.set("bottom", null), this.occupiedEdges.set("left", null), this.occupiedEdges.set("right", null);
1463
+ }
1464
+ get pluginId() {
1465
+ return R._pluginId;
1466
+ }
1467
+ install(t) {
1468
+ this.manager = t, this.tracker.addTarget(this.manager.getContainer()), this.tracker.on("edge:enter", (e) => {
1469
+ e.source === "element" && e.element === this.manager.getContainer() && this.handleEdgeEnter(e.edge);
1470
+ }), this.tracker.on("edge:leave", (e) => {
1471
+ e.source === "element" && e.element === this.manager.getContainer() && this.handleEdgeLeave(e.edge);
1472
+ }), this.attachEventHandlers();
1473
+ }
1474
+ /**
1475
+ * Handle edge enter for visual feedback
1476
+ */
1477
+ handleEdgeEnter(t) {
1478
+ const e = this.manager.getContainer();
1479
+ this.isEdgeOccupied(t) ? e.classList.add("edge-dock-hint", `edge-dock-hint-${t}`, "edge-dock-blocked") : e.classList.add("edge-dock-hint", `edge-dock-hint-${t}`);
1480
+ }
1481
+ /**
1482
+ * Handle edge leave - remove visual feedback
1483
+ */
1484
+ handleEdgeLeave(t) {
1485
+ this.manager.getContainer().classList.remove("edge-dock-hint", `edge-dock-hint-${t}`, "edge-dock-blocked");
1486
+ }
1487
+ /**
1488
+ * Check if an edge is occupied by another container
1489
+ */
1490
+ isEdgeOccupied(t) {
1491
+ return this.occupiedEdges.get(t) !== null;
1492
+ }
1493
+ /**
1494
+ * Attach event handlers to container manager
1495
+ */
1496
+ attachEventHandlers() {
1497
+ const t = this.manager.getContainer();
1498
+ t.addEventListener("mouseenter", this.onMouseEnter.bind(this)), t.addEventListener("mouseleave", this.onMouseLeave.bind(this)), this.manager.on("dragStart", (e) => {
1499
+ this.onDragStart(e.element);
1500
+ }), this.manager.on("drag", (e) => {
1501
+ this.onDrag(e.element);
1502
+ }), this.manager.on("dragEnd", (e) => {
1503
+ this.onDragEnd(e.element);
1504
+ });
1505
+ }
1506
+ /**
1507
+ * Handle mouse enter - show docked container
1508
+ */
1509
+ onMouseEnter() {
1510
+ const t = this.manager.getContainer();
1511
+ this.isContainerDocked(t) && t.classList.add("edge-docked-visible");
1512
+ }
1513
+ /**
1514
+ * Handle mouse leave - hide docked container
1515
+ */
1516
+ onMouseLeave() {
1517
+ const t = this.manager.getContainer();
1518
+ this.isContainerDocked(t) && t.classList.remove("edge-docked-visible");
1519
+ }
1520
+ /**
1521
+ * Handle drag start - undock if docked
1522
+ */
1523
+ onDragStart(t) {
1524
+ t.classList.remove(
1525
+ "edge-dock-hint",
1526
+ "edge-dock-blocked",
1527
+ "edge-docked-visible",
1528
+ "edge-dock-hint-top",
1529
+ "edge-dock-hint-bottom",
1530
+ "edge-dock-hint-left",
1531
+ "edge-dock-hint-right"
1532
+ );
1533
+ const e = this.dockedContainers.get(t);
1534
+ e && this.undockContainer(t, e);
1535
+ }
1536
+ /**
1537
+ * Handle drag - update edge hints based on position
1538
+ */
1539
+ onDrag(t) {
1540
+ const e = t.getBoundingClientRect(), i = this.getClosestEdge(e);
1541
+ this.updateEdgeHints(t, i);
1542
+ }
1543
+ /**
1544
+ * Handle drag end - dock if close to edge
1545
+ */
1546
+ onDragEnd(t) {
1547
+ const e = t.getBoundingClientRect(), i = this.getClosestEdge(e);
1548
+ t.classList.remove(
1549
+ "edge-dock-hint",
1550
+ "edge-dock-blocked",
1551
+ "edge-dock-hint-top",
1552
+ "edge-dock-hint-bottom",
1553
+ "edge-dock-hint-left",
1554
+ "edge-dock-hint-right"
1555
+ ), i && !this.isEdgeOccupied(i) && this.dockContainer(t, i);
1556
+ }
1557
+ /**
1558
+ * Update visual hints for edge docking
1559
+ */
1560
+ updateEdgeHints(t, e) {
1561
+ t.classList.remove(
1562
+ "edge-dock-hint",
1563
+ "edge-dock-blocked",
1564
+ "edge-dock-hint-top",
1565
+ "edge-dock-hint-bottom",
1566
+ "edge-dock-hint-left",
1567
+ "edge-dock-hint-right"
1568
+ ), e && (this.isEdgeOccupied(e) ? t.classList.add("edge-dock-hint", `edge-dock-hint-${e}`, "edge-dock-blocked") : t.classList.add("edge-dock-hint", `edge-dock-hint-${e}`));
1569
+ }
1570
+ /**
1571
+ * Get the closest edge to the container
1572
+ */
1573
+ getClosestEdge(t) {
1574
+ const e = t.top, i = t.left, s = window.innerHeight - t.bottom, a = window.innerWidth - t.right, h = Object.entries({
1575
+ top: e,
1576
+ bottom: s,
1577
+ left: i,
1578
+ right: a
1579
+ }).filter(([d, l]) => l >= -this.edgeThreshold && l <= this.edgeThreshold).sort((d, l) => d[1] - l[1]);
1580
+ return h.length > 0 ? h[0][0] : null;
1581
+ }
1582
+ /**
1583
+ * Dock container to specified edge
1584
+ */
1585
+ dockContainer(t, e) {
1586
+ const i = window.getComputedStyle(t), s = t.getBoundingClientRect(), a = {
1587
+ x: s.left,
1588
+ y: s.top
1589
+ };
1590
+ this.dockedContainers.set(t, {
1591
+ element: t,
1592
+ edge: e,
1593
+ screenPosition: a,
1594
+ originalPosition: {
1595
+ top: parseFloat(i.top) || s.top,
1596
+ left: parseFloat(i.left) || s.left,
1597
+ width: s.width,
1598
+ height: s.height,
1599
+ transform: i.transform,
1600
+ position: i.position
1601
+ }
1602
+ }), this.occupiedEdges.set(e, t), t.style.top = "", t.style.bottom = "", t.style.left = "", t.style.right = "", t.style.width = "", t.style.height = "", t.style.transform = "", t.classList.add("edge-docked", `edge-docked-${e}`), this.applyEdgePositioning(t, e, a), t.setAttribute("data-docked", "true"), t.setAttribute("data-docked-edge", e);
1603
+ }
1604
+ /**
1605
+ * Apply proper positioning for each edge to prevent shifting
1606
+ */
1607
+ applyEdgePositioning(t, e, i) {
1608
+ const s = t.getBoundingClientRect();
1609
+ switch (e) {
1610
+ case "top":
1611
+ t.style.left = `${i.x}px`, t.style.width = `${s.width}px`;
1612
+ break;
1613
+ case "bottom":
1614
+ t.style.left = `${i.x}px`, t.style.width = `${s.width}px`;
1615
+ break;
1616
+ case "left":
1617
+ t.style.top = `${i.y}px`, t.style.height = `${s.height}px`;
1618
+ break;
1619
+ case "right":
1620
+ t.style.top = `${i.y}px`, t.style.height = `${s.height}px`;
1621
+ break;
1622
+ }
1623
+ }
1624
+ /**
1625
+ * Undock container from edge
1626
+ */
1627
+ undockContainer(t, e) {
1628
+ this.dockedContainers.delete(t), this.occupiedEdges.set(e.edge, null), t.classList.remove(
1629
+ "edge-docked",
1630
+ "edge-docked-visible",
1631
+ "edge-docked-top",
1632
+ "edge-docked-bottom",
1633
+ "edge-docked-left",
1634
+ "edge-docked-right"
1635
+ ), t.removeAttribute("data-docked"), t.removeAttribute("data-docked-edge"), t.style.top = "", t.style.bottom = "", t.style.left = "", t.style.right = "", t.style.width = "", t.style.height = "", t.style.transform = "", t.style.position = "", this.restoreOriginalPosition(t, e);
1636
+ }
1637
+ /**
1638
+ * Restore container to its original position without shifting
1639
+ */
1640
+ restoreOriginalPosition(t, e) {
1641
+ this.manager.setState({
1642
+ x: e.screenPosition.x,
1643
+ y: e.screenPosition.y,
1644
+ width: e.originalPosition.width,
1645
+ height: e.originalPosition.height
1646
+ });
1647
+ }
1648
+ /**
1649
+ * Get the docked container for a specific edge
1650
+ */
1651
+ getDockedContainer(t) {
1652
+ const e = this.occupiedEdges.get(t);
1653
+ return e && this.dockedContainers.get(e) || null;
1654
+ }
1655
+ /**
1656
+ * Check if container is docked
1657
+ */
1658
+ isContainerDocked(t) {
1659
+ return this.dockedContainers.has(t);
1660
+ }
1661
+ /**
1662
+ * Get the edge where container is docked
1663
+ */
1664
+ getContainerDockEdge(t) {
1665
+ const e = this.dockedContainers.get(t);
1666
+ return e ? e.edge : null;
1667
+ }
1668
+ /**
1669
+ * Clean up resources
1670
+ */
1671
+ destroy() {
1672
+ const t = this.manager.getContainer();
1673
+ t.removeEventListener("mouseenter", this.onMouseEnter.bind(this)), t.removeEventListener("mouseleave", this.onMouseLeave.bind(this)), this.dockedContainers.forEach((e, i) => {
1674
+ this.undockContainer(i, e);
1675
+ }), this.dockedContainers.clear(), this.occupiedEdges.forEach((e, i) => {
1676
+ this.occupiedEdges.set(i, null);
1677
+ });
1678
+ }
1679
+ };
1680
+ r(R, "_pluginId", Symbol("EdgeDockingPlugin"));
1681
+ let j = R;
1682
+ const n = class n {
1683
+ constructor() {
1684
+ r(this, "manager");
1685
+ r(this, "containerId");
1686
+ r(this, "isDemoContainer", !1);
1687
+ // Эффект для автоматического сохранения при изменении состояния
1688
+ r(this, "autoSaveEffect");
1689
+ }
1690
+ get pluginId() {
1691
+ return n._pluginId;
1692
+ }
1693
+ // Вычисляемое свойство для доступа к состояниям
1694
+ static get containerStates() {
1695
+ return n.reactiveState.containerStates;
1696
+ }
1697
+ static get closedQueue() {
1698
+ return n.reactiveState.closedQueue;
1699
+ }
1700
+ static get demoContainers() {
1701
+ return n.reactiveState.demoContainers;
1702
+ }
1703
+ /**
1704
+ * Install plugin on container manager instance with reactive state management
1705
+ */
1706
+ install(t, e) {
1707
+ if (this.manager = t, this.containerId = e == null ? void 0 : e.containerId, this.isDemoContainer = (e == null ? void 0 : e.isDemo) || !1, !this.containerId) {
1708
+ console.warn("[StatePersistencePlugin] containerId is required for state persistence");
1709
+ return;
1710
+ }
1711
+ n.containers.push({
1712
+ manager: t,
1713
+ containerId: this.containerId,
1714
+ isDemo: this.isDemoContainer
1715
+ }), this.isDemoContainer && n.registerDemoContainer(this.containerId), n.isGlobalEventsInitialized || (n.initializeGlobalEvents(), n.isGlobalEventsInitialized = !0), this.isDemoContainer && this.setupAutoSaveEffect(), this.bindContainerEvents();
1716
+ }
1717
+ /**
1718
+ * Set up reactive auto-save effect for container state changes
1719
+ */
1720
+ setupAutoSaveEffect() {
1721
+ if (!this.manager || !this.containerId) return;
1722
+ const t = z(() => {
1723
+ this.isDemoContainer && this.saveState();
1724
+ }, 300);
1725
+ this.autoSaveEffect = x(() => {
1726
+ this.manager.getState(), this.manager.getMode(), t();
1727
+ });
1728
+ }
1729
+ /**
1730
+ * Bind to container-specific events to save state on changes
1731
+ * Simplified since most saving handled using effects
1732
+ */
1733
+ bindContainerEvents() {
1734
+ this.manager && (this.manager.on("dragStart", () => {
1735
+ }), this.manager.on("dragEnd", () => {
1736
+ this.isDemoContainer && this.saveState();
1737
+ }), this.manager.on("resizeEnd", () => {
1738
+ this.isDemoContainer && this.saveState();
1739
+ }), this.manager.onPluginEvent("maximizeChanged", () => {
1740
+ this.isDemoContainer && this.saveState();
1741
+ }), this.manager.onPluginEvent("directionChanged", () => {
1742
+ this.isDemoContainer && this.saveState();
1743
+ }));
1744
+ }
1745
+ /**
1746
+ * Initialize global event handlers for all containers
1747
+ */
1748
+ static initializeGlobalEvents() {
1749
+ window.addEventListener("beforeunload", () => {
1750
+ n.saveAllContainers();
1751
+ }), document.addEventListener("visibilitychange", () => {
1752
+ document.hidden && n.saveAllContainers();
1753
+ }), window.addEventListener("resize", z(() => {
1754
+ n.saveAllContainers();
1755
+ }, 500));
1756
+ }
1757
+ /**
1758
+ * Register a container as a demo container
1759
+ */
1760
+ static registerDemoContainer(t) {
1761
+ try {
1762
+ n.demoContainers.includes(t) || (n.demoContainers.push(t), n.saveDemoContainersToStorage());
1763
+ } catch (e) {
1764
+ console.error("[StatePersistencePlugin] Failed to register demo container:", e);
1765
+ }
1766
+ }
1767
+ /**
1768
+ * Save demo containers to localStorage
1769
+ */
1770
+ static saveDemoContainersToStorage() {
1771
+ try {
1772
+ localStorage.setItem(
1773
+ n.DEMO_CONTAINERS_KEY,
1774
+ JSON.stringify(n.demoContainers)
1775
+ );
1776
+ } catch (t) {
1777
+ console.error("[StatePersistencePlugin] Failed to save demo containers:", t);
1778
+ }
1779
+ }
1780
+ /**
1781
+ * Get list of all demo containers
1782
+ */
1783
+ static getDemoContainers() {
1784
+ try {
1785
+ const t = localStorage.getItem(n.DEMO_CONTAINERS_KEY);
1786
+ return t ? JSON.parse(t) : [];
1787
+ } catch (t) {
1788
+ return console.error("[StatePersistencePlugin] Failed to parse demo containers:", t), [];
1789
+ }
1790
+ }
1791
+ /**
1792
+ * Check if a container is a demo container
1793
+ */
1794
+ static isDemoContainer(t) {
1795
+ return n.getDemoContainers().includes(t);
1796
+ }
1797
+ /**
1798
+ * Get all saved states from localStorage
1799
+ */
1800
+ static getAllStates() {
1801
+ try {
1802
+ const t = localStorage.getItem(n.STORAGE_KEY);
1803
+ return t ? JSON.parse(t) : {};
1804
+ } catch (t) {
1805
+ return console.error("[StatePersistencePlugin] Failed to parse stored states:", t), {};
1806
+ }
1807
+ }
1808
+ /**
1809
+ * Add container ID to closed containers queue
1810
+ */
1811
+ static addToClosedQueue(t) {
1812
+ if (!n.isDemoContainer(t)) {
1813
+ console.log(`[StatePersistencePlugin] Skipping closed queue for non-demo container: ${t}`);
1814
+ return;
1815
+ }
1816
+ if (!n.getContainerState(t)) {
1817
+ console.error(`[StatePersistencePlugin] Cannot add ${t} to closed queue: state not found`);
1818
+ return;
1819
+ }
1820
+ const i = n.closedQueue, s = i.indexOf(t);
1821
+ s > -1 && i.splice(s, 1), i.push(t), n.saveClosedQueueToStorage();
1822
+ }
1823
+ /**
1824
+ * Save closed queue to localStorage
1825
+ */
1826
+ static saveClosedQueueToStorage() {
1827
+ try {
1828
+ localStorage.setItem(
1829
+ n.CLOSED_QUEUE_KEY,
1830
+ JSON.stringify(n.closedQueue)
1831
+ );
1832
+ } catch (t) {
1833
+ console.error("[StatePersistencePlugin] Failed to save closed queue:", t);
1834
+ }
1835
+ }
1836
+ /**
1837
+ * Get closed containers queue (LIFO - last in first out)
1838
+ */
1839
+ static getClosedQueue() {
1840
+ try {
1841
+ const t = localStorage.getItem(n.CLOSED_QUEUE_KEY);
1842
+ return t ? JSON.parse(t) : [];
1843
+ } catch (t) {
1844
+ return console.error("[StatePersistencePlugin] Failed to parse closed queue:", t), [];
1845
+ }
1846
+ }
1847
+ saveState() {
1848
+ !this.manager || !this.containerId || !this.isDemoContainer || T(() => {
1849
+ var C;
1850
+ n.reactiveState.isSaving = !0, n.reactiveState.pendingChanges = !0;
1851
+ const t = this.manager.getContainer(), e = t.dataset.maximized === "true", i = this.manager.getState(), s = this.manager.getMode(), a = this.manager.getDirection(), o = t.dataset.containerType || "unknown", h = t.dataset.title, d = t.dataset.color, l = t.dataset.useSnapping === "true", S = (C = this.manager.config) == null ? void 0 : C.resize, E = t.parentElement, M = E && E !== document.body ? E.id || `parent-${this.containerId}` : void 0, w = {
1852
+ ...i,
1853
+ mode: s,
1854
+ draggingDirection: a,
1855
+ isMaximized: e,
1856
+ containerType: o,
1857
+ title: h,
1858
+ color: d,
1859
+ useSnapping: l,
1860
+ isClosed: !1,
1861
+ parentElementId: M,
1862
+ closedTimestamp: 0,
1863
+ resize: S,
1864
+ isDemoContainer: !0
1865
+ };
1866
+ n.reactiveState.containerStates[this.containerId] = w;
1867
+ const p = n.getAllStates();
1868
+ p[this.containerId] = w, localStorage.setItem(
1869
+ n.STORAGE_KEY,
1870
+ JSON.stringify(p)
1871
+ ), n.reactiveState.lastSaved = Date.now(), n.reactiveState.isSaving = !1;
1872
+ });
1873
+ }
1874
+ /**
1875
+ * Save container state with current manager state before closing
1876
+ */
1877
+ static saveContainerStateBeforeClose(t, e) {
1878
+ var Y, B, F;
1879
+ const i = t.getState(), s = t.getMode();
1880
+ if (!n.isDemoContainer(e)) {
1881
+ n.containers = n.containers.filter(
1882
+ (D) => D.containerId !== e
1883
+ );
1884
+ return;
1885
+ }
1886
+ const o = t.getContainer(), h = t.getDirection(), d = o.dataset.maximized === "true", l = o.dataset.containerType || "unknown", S = o.dataset.title, E = o.dataset.color, M = o.dataset.useSnapping === "true", w = (Y = t.config) == null ? void 0 : Y.resize, p = ((B = t.isEdgeDocked) == null ? void 0 : B.call(t)) || !1, C = ((F = t.getDockEdge) == null ? void 0 : F.call(t)) || null, b = o.parentElement, q = b && b !== document.body ? b.id || `parent-${e}` : void 0, A = {
1887
+ ...i,
1888
+ mode: s,
1889
+ draggingDirection: h,
1890
+ isMaximized: d,
1891
+ isEdgeDocked: p,
1892
+ dockEdge: C || void 0,
1893
+ containerType: l,
1894
+ title: S,
1895
+ color: E,
1896
+ useSnapping: M,
1897
+ isClosed: !0,
1898
+ parentElementId: q,
1899
+ closedTimestamp: Date.now(),
1900
+ resize: w,
1901
+ isDemoContainer: !0
1902
+ }, N = n.getAllStates();
1903
+ N[e] = A;
1904
+ try {
1905
+ localStorage.setItem(
1906
+ n.STORAGE_KEY,
1907
+ JSON.stringify(N)
1908
+ );
1909
+ } catch (D) {
1910
+ console.error("[StatePersistencePlugin] Failed to save to localStorage:", D);
1911
+ }
1912
+ n.reactiveState.containerStates[e] = A, n.containers = n.containers.filter(
1913
+ (D) => D.containerId !== e
1914
+ ), n.addToClosedQueue(e);
1915
+ }
1916
+ /**
1917
+ * Save all containers state (for global events) - including closed ones
1918
+ */
1919
+ static saveAllContainers() {
1920
+ T(() => {
1921
+ const t = n.getAllStates();
1922
+ n.containers.filter(({ isDemo: e }) => e).forEach(({ manager: e, containerId: i }) => {
1923
+ var b;
1924
+ const s = e.getState(), a = e.getMode(), o = e.getContainer(), h = e.getDirection(), d = o.dataset.maximized === "true", l = o.dataset.containerType || "unknown", S = o.dataset.title, E = o.dataset.color, M = o.dataset.useSnapping === "true", w = (b = e.config) == null ? void 0 : b.resize, p = o.parentElement, C = p && p !== document.body ? p.id || `parent-${i}` : void 0;
1925
+ t[i] = {
1926
+ ...s,
1927
+ mode: a,
1928
+ draggingDirection: h,
1929
+ isMaximized: d,
1930
+ containerType: l,
1931
+ title: S,
1932
+ color: E,
1933
+ useSnapping: M,
1934
+ isClosed: !1,
1935
+ parentElementId: C,
1936
+ closedTimestamp: 0,
1937
+ resize: w,
1938
+ isDemoContainer: !0
1939
+ };
1940
+ }), n.reactiveState.containerStates = t, localStorage.setItem(
1941
+ n.STORAGE_KEY,
1942
+ JSON.stringify(t)
1943
+ ), n.reactiveState.lastSaved = Date.now();
1944
+ });
1945
+ }
1946
+ /**
1947
+ * Remove the most recently closed container from queue and return its ID
1948
+ */
1949
+ static popLastClosedContainer() {
1950
+ try {
1951
+ const t = n.closedQueue;
1952
+ if (t.length === 0) return null;
1953
+ const e = t.pop();
1954
+ return n.saveClosedQueueToStorage(), e;
1955
+ } catch (t) {
1956
+ return console.error("[StatePersistencePlugin] Failed to pop last closed container:", t), null;
1957
+ }
1958
+ }
1959
+ /**
1960
+ * Check if there are any closed containers that can be restored
1961
+ */
1962
+ static hasClosedContainers() {
1963
+ return n.closedQueue.length > 0;
1964
+ }
1965
+ /**
1966
+ * Get saved state for specific container (including closed ones)
1967
+ */
1968
+ static getContainerState(t) {
1969
+ try {
1970
+ const e = n.containerStates[t];
1971
+ if (e) return e;
1972
+ const s = n.getAllStates()[t];
1973
+ return s ? (n.reactiveState.containerStates[t] = s, s) : null;
1974
+ } catch (e) {
1975
+ return console.error("[StatePersistencePlugin] Failed to get container state:", e), null;
1976
+ }
1977
+ }
1978
+ /**
1979
+ * Get all container states including closed ones
1980
+ */
1981
+ static getAllContainerStates() {
1982
+ return n.getAllStates();
1983
+ }
1984
+ /**
1985
+ * Check if container state exists (including closed)
1986
+ */
1987
+ static hasContainerState(t) {
1988
+ return n.getContainerState(t) !== null;
1989
+ }
1990
+ /**
1991
+ * Update container state in storage
1992
+ */
1993
+ static updateContainerState(t, e) {
1994
+ try {
1995
+ const i = n.getAllStates(), s = i[t];
1996
+ if (s) {
1997
+ const a = { ...s, ...e };
1998
+ i[t] = a, localStorage.setItem(
1999
+ n.STORAGE_KEY,
2000
+ JSON.stringify(i)
2001
+ ), n.reactiveState.containerStates[t] = a;
2002
+ } else {
2003
+ console.warn(`[StatePersistencePlugin] No state found for container ${t}, creating new state`);
2004
+ const a = {
2005
+ x: 0,
2006
+ y: 0,
2007
+ width: 300,
2008
+ height: 200,
2009
+ mode: "smooth",
2010
+ draggingDirection: "all",
2011
+ isMaximized: !1,
2012
+ containerType: "unknown",
2013
+ isClosed: !1,
2014
+ isDemoContainer: n.isDemoContainer(t),
2015
+ ...e
2016
+ };
2017
+ i[t] = a, localStorage.setItem(
2018
+ n.STORAGE_KEY,
2019
+ JSON.stringify(i)
2020
+ ), n.reactiveState.containerStates[t] = a;
2021
+ }
2022
+ } catch (i) {
2023
+ console.error("[StatePersistencePlugin] Failed to update container state:", i);
2024
+ }
2025
+ }
2026
+ /**
2027
+ * Clear all saved states from localStorage
2028
+ */
2029
+ static clearStorage() {
2030
+ T(() => {
2031
+ n.reactiveState.containerStates = {}, n.closedQueue.length = 0, n.demoContainers.length = 0, n.reactiveState.isSaving = !1, n.reactiveState.lastSaved = null, n.reactiveState.pendingChanges = !1;
2032
+ }), localStorage.removeItem(n.STORAGE_KEY), localStorage.removeItem(n.CLOSED_QUEUE_KEY), localStorage.removeItem(n.DEMO_CONTAINERS_KEY), n.containers = [];
2033
+ }
2034
+ /**
2035
+ * Initialize reactive state from localStorage on plugin load
2036
+ */
2037
+ static initializeReactiveState() {
2038
+ try {
2039
+ const t = n.getAllStates(), e = n.getClosedQueue(), i = n.getDemoContainers();
2040
+ T(() => {
2041
+ n.reactiveState.containerStates = t, n.closedQueue.length = 0, n.closedQueue.push(...e), n.demoContainers.length = 0, n.demoContainers.push(...i);
2042
+ });
2043
+ } catch (t) {
2044
+ console.error("[StatePersistencePlugin] Failed to initialize reactive state:", t);
2045
+ }
2046
+ }
2047
+ /**
2048
+ * Get plugin metrics and statistics
2049
+ */
2050
+ static getMetrics() {
2051
+ return {
2052
+ totalContainers: Object.keys(n.containerStates).length,
2053
+ demoContainers: n.demoContainers.length,
2054
+ closedContainers: n.closedQueue.length,
2055
+ lastSaved: n.reactiveState.lastSaved,
2056
+ isSaving: n.reactiveState.isSaving
2057
+ };
2058
+ }
2059
+ /**
2060
+ * Debug method to check the current state of localStorage
2061
+ */
2062
+ static debugStorage() {
2063
+ console.log("[StatePersistencePlugin] === START DEBUG INFO ===");
2064
+ try {
2065
+ const t = localStorage.getItem(n.STORAGE_KEY);
2066
+ if (t) {
2067
+ const s = JSON.parse(t);
2068
+ console.log(`[StatePersistencePlugin] Number of states: ${Object.keys(s).length}`), console.log("[StatePersistencePlugin] State keys:", Object.keys(s));
2069
+ for (const [a, o] of Object.entries(s))
2070
+ console.log(`[StatePersistencePlugin] State ${a}:`, {
2071
+ isDemoContainer: o.isDemoContainer,
2072
+ isClosed: o.isClosed,
2073
+ title: o.title
2074
+ });
2075
+ }
2076
+ const e = localStorage.getItem(n.CLOSED_QUEUE_KEY);
2077
+ console.log("[StatePersistencePlugin] Closed queue:", e ? JSON.parse(e) : []);
2078
+ const i = localStorage.getItem(n.DEMO_CONTAINERS_KEY);
2079
+ console.log("[StatePersistencePlugin] Demo containers:", i ? JSON.parse(i) : []);
2080
+ } catch (t) {
2081
+ console.error("[StatePersistencePlugin] Debug error:", t);
2082
+ }
2083
+ console.log("[StatePersistencePlugin] === END DEBUG INFO ===");
2084
+ }
2085
+ /**
2086
+ * Clean up plugin resources
2087
+ */
2088
+ destroy() {
2089
+ this.autoSaveEffect && (this.autoSaveEffect(), this.autoSaveEffect = void 0), this.containerId && (n.containers = n.containers.filter(
2090
+ (t) => t.containerId !== this.containerId
2091
+ ));
2092
+ }
2093
+ };
2094
+ r(n, "_pluginId", Symbol("StatePersistencePlugin")), r(n, "STORAGE_KEY", "containerManagerState"), r(n, "CLOSED_QUEUE_KEY", "containerManagerClosedQueue"), r(n, "DEMO_CONTAINERS_KEY", "containerManagerDemoContainers"), // Статическое реактивное состояние для всех плагинов
2095
+ r(n, "reactiveState", I({
2096
+ isSaving: !1,
2097
+ lastSaved: null,
2098
+ pendingChanges: !1,
2099
+ containerStates: {},
2100
+ closedQueue: [],
2101
+ demoContainers: []
2102
+ })), r(n, "isGlobalEventsInitialized", !1), r(n, "containers", []);
2103
+ let H = n;
2104
+ H.initializeReactiveState();
2105
+ const L = class L {
2106
+ constructor() {
2107
+ r(this, "manager");
2108
+ r(this, "containerName", "");
2109
+ r(this, "notificationSystem", null);
2110
+ }
2111
+ get pluginId() {
2112
+ return L._pluginId;
2113
+ }
2114
+ /**
2115
+ * Install plugin on container manager instance
2116
+ */
2117
+ install(t, e) {
2118
+ this.manager = t, this.containerName = (e == null ? void 0 : e.containerName) || `Container-${Math.random().toString(36).substring(2, 11)}`, this.notificationSystem = e == null ? void 0 : e.notificationSystem, this.bindEvents();
2119
+ }
2120
+ /**
2121
+ * Bind to container events
2122
+ */
2123
+ bindEvents() {
2124
+ this.manager && (this.logResize = z(this.logResize.bind(this), 250), this.logDrag = z(this.logDrag.bind(this), 250), this.logViewportResize = z(this.logViewportResize.bind(this), 250), this.logSnapStep = z(this.logSnapStep.bind(this), 250), this.manager.on("modeChange", (t) => {
2125
+ this.logModeChange(t.mode);
2126
+ }), this.manager.on("resize", (t) => {
2127
+ this.logResize(t.state);
2128
+ }), this.manager.on("resizeEnd", (t) => {
2129
+ this.logResize(t.state);
2130
+ }), this.manager.on("drag", (t) => {
2131
+ this.logDrag(t.state);
2132
+ }), this.manager.on("dragEnd", (t) => {
2133
+ this.logDrag(t.state);
2134
+ }), this.manager.on("viewportResize", (t) => {
2135
+ this.logViewportResize(t.state);
2136
+ }), this.manager.onPluginEvent("snappingEnabledChanged", (t) => {
2137
+ this.logSnappingEnabled(t.enabled);
2138
+ }), this.manager.onPluginEvent("snapStepChanged", (t) => {
2139
+ this.logSnapStep(t.snapStep);
2140
+ }), this.manager.onPluginEvent("directionChanged", (t) => {
2141
+ this.logDirectionChange(t.direction);
2142
+ }));
2143
+ }
2144
+ /**
2145
+ * Log resize event
2146
+ */
2147
+ logResize(t) {
2148
+ const e = `Resized to ${Math.round(t.width)}×${Math.round(t.height)}`;
2149
+ this.showNotification(e, "info");
2150
+ }
2151
+ /**
2152
+ * Log drag event
2153
+ */
2154
+ logDrag(t) {
2155
+ const e = `Moved to (${Math.round(t.x)}, ${Math.round(t.y)})`;
2156
+ this.showNotification(e, "info");
2157
+ }
2158
+ /**
2159
+ * Log mode change event
2160
+ */
2161
+ logModeChange(t) {
2162
+ const e = `Mode changed to ${t}`;
2163
+ this.showNotification(e, "warning");
2164
+ }
2165
+ /**
2166
+ * Log viewport resize adjustment event
2167
+ */
2168
+ logViewportResize(t) {
2169
+ const e = `Adjusted position to (${Math.round(t.x)}, ${Math.round(t.y)}) due to window resize`;
2170
+ this.showNotification(e, "info");
2171
+ }
2172
+ /**
2173
+ * Log snapping enabled/disabled
2174
+ */
2175
+ logSnappingEnabled(t) {
2176
+ const e = `Snapping ${t ? "enabled" : "disabled"}`;
2177
+ this.showNotification(e, t ? "success" : "warning");
2178
+ }
2179
+ /**
2180
+ * Log snap step change
2181
+ */
2182
+ logSnapStep(t) {
2183
+ const e = `Snap step changed to ${t}px`;
2184
+ this.showNotification(e, "info");
2185
+ }
2186
+ /**
2187
+ * Log direction change
2188
+ */
2189
+ logDirectionChange(t) {
2190
+ const e = `Drag direction: ${t}`;
2191
+ this.showNotification(e, "info");
2192
+ }
2193
+ /**
2194
+ * Show notification using notification system
2195
+ */
2196
+ showNotification(t, e) {
2197
+ if (this.notificationSystem) {
2198
+ const i = `${this.containerName}: ${t}`;
2199
+ this.notificationSystem.show(i, e);
2200
+ }
2201
+ }
2202
+ };
2203
+ r(L, "_pluginId", Symbol("LoggingPlugin"));
2204
+ let K = L;
964
2205
  export {
965
- I as ContainerInitializer,
966
- E as ContainerManager,
967
- k as ContentCreator,
968
- A as TemplateLoader
2206
+ pt as ContainerInitializer,
2207
+ G as ContainerManager,
2208
+ ft as ContentCreator,
2209
+ j as EdgeDockingPlugin,
2210
+ K as LoggingPlugin,
2211
+ it as NotificationSystem,
2212
+ U as SnappingPlugin,
2213
+ H as StatePersistencePlugin,
2214
+ J as TemplateLoader,
2215
+ St as getTemplateLoader,
2216
+ vt as initializeTemplateSystem
969
2217
  };
970
2218
  //# sourceMappingURL=index.es.js.map