@floegence/floe-webapp-core 0.36.8 → 0.36.10

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.
@@ -1,10 +1,10 @@
1
- import { createSignal as z, createEffect as G } from "solid-js";
2
- import { createStore as H, produce as l, unwrap as J } from "solid-js/store";
3
- import { createSimpleContext as N } from "./createSimpleContext.js";
4
- import { useResolvedFloeConfig as Q } from "./FloeConfigContext.js";
5
- import { useWidgetRegistry as U } from "./WidgetRegistry.js";
6
- import { hasCollision as M, constrainPosition as V, findFreePosition as X } from "../utils/gridCollision.js";
7
- function Y() {
1
+ import { createSignal as h, createEffect as J, batch as W } from "solid-js";
2
+ import { createStore as N, produce as f, unwrap as Q } from "solid-js/store";
3
+ import { createSimpleContext as U } from "./createSimpleContext.js";
4
+ import { useResolvedFloeConfig as V } from "./FloeConfigContext.js";
5
+ import { useWidgetRegistry as Z } from "./WidgetRegistry.js";
6
+ import { hasCollision as k, sameGridPosition as B, constrainPosition as _, findFreePosition as tt } from "../utils/gridCollision.js";
7
+ function et() {
8
8
  const d = Date.now();
9
9
  return [{
10
10
  id: "preset-default",
@@ -135,8 +135,8 @@ function Y() {
135
135
  updatedAt: d
136
136
  }];
137
137
  }
138
- function Z(d) {
139
- if (!d || d.length === 0) return Y();
138
+ function it(d) {
139
+ if (!d || d.length === 0) return et();
140
140
  const m = Date.now();
141
141
  return d.map((y) => ({
142
142
  id: y.id,
@@ -154,362 +154,370 @@ function Z(d) {
154
154
  }));
155
155
  }
156
156
  const {
157
- Provider: at,
158
- use: dt
159
- } = N({
157
+ Provider: ut,
158
+ use: lt
159
+ } = U({
160
160
  name: "Deck",
161
- init: _
161
+ init: ot
162
162
  });
163
- function _() {
164
- const d = Q(), m = U(), y = () => d.config.deck.storageKey, u = (d.config.deck.presetsMode ?? "mutable") === "immutable", L = (e) => {
163
+ function ot() {
164
+ const d = V(), m = Z(), y = () => d.config.deck.storageKey, u = (d.config.deck.presetsMode ?? "mutable") === "immutable", L = (t) => {
165
165
  try {
166
- if (e === null || typeof e != "object") return e;
167
- if (e instanceof Date) return new Date(e.getTime());
168
- const i = J(e);
166
+ if (t === null || typeof t != "object") return t;
167
+ if (t instanceof Date) return new Date(t.getTime());
168
+ const i = Q(t);
169
169
  if (typeof structuredClone == "function")
170
170
  try {
171
171
  return structuredClone(i);
172
172
  } catch {
173
173
  }
174
- const s = /* @__PURE__ */ new WeakMap(), n = (t) => {
175
- if (t === null || typeof t != "object") return t;
176
- if (t instanceof Date) return new Date(t.getTime());
177
- if (Array.isArray(t)) {
178
- const a = new Array(t.length);
179
- for (let p = 0; p < t.length; p += 1)
180
- a[p] = n(t[p]);
181
- return a;
174
+ const o = /* @__PURE__ */ new WeakMap(), a = (e) => {
175
+ if (e === null || typeof e != "object") return e;
176
+ if (e instanceof Date) return new Date(e.getTime());
177
+ if (Array.isArray(e)) {
178
+ const s = new Array(e.length);
179
+ for (let p = 0; p < e.length; p += 1)
180
+ s[p] = a(e[p]);
181
+ return s;
182
182
  }
183
- if (t instanceof Map) {
184
- const a = /* @__PURE__ */ new Map();
185
- for (const [p, P] of t.entries())
186
- a.set(n(p), n(P));
187
- return a;
183
+ if (e instanceof Map) {
184
+ const s = /* @__PURE__ */ new Map();
185
+ for (const [p, P] of e.entries())
186
+ s.set(a(p), a(P));
187
+ return s;
188
188
  }
189
- if (t instanceof Set) {
190
- const a = /* @__PURE__ */ new Set();
191
- for (const p of t.values())
192
- a.add(n(p));
193
- return a;
189
+ if (e instanceof Set) {
190
+ const s = /* @__PURE__ */ new Set();
191
+ for (const p of e.values())
192
+ s.add(a(p));
193
+ return s;
194
194
  }
195
- if (s.has(t)) return s.get(t);
196
- const o = {};
197
- s.set(t, o);
198
- for (const a of Object.keys(t))
195
+ if (o.has(e)) return o.get(e);
196
+ const n = {};
197
+ o.set(e, n);
198
+ for (const s of Object.keys(e))
199
199
  try {
200
- o[a] = n(t[a]);
200
+ n[s] = a(e[s]);
201
201
  } catch {
202
202
  }
203
- return o;
203
+ return n;
204
204
  };
205
- return n(i);
205
+ return a(i);
206
206
  } catch {
207
- return e;
207
+ return t;
208
208
  }
209
- }, B = (e) => {
209
+ }, F = (t) => {
210
210
  const i = {};
211
- for (const s of e.widgets ?? [])
212
- !s?.id || !s.state || (i[s.id] = s.state);
211
+ for (const o of t.widgets ?? [])
212
+ !o?.id || !o.state || (i[o.id] = o.state);
213
213
  return i;
214
- }, h = Z(d.config.deck.presets), F = new Set(h.map((e) => e.id)), g = d.persist.load(y(), {}), W = Array.isArray(g.layouts) ? g.layouts : [], T = new Map(W.map((e) => [e.id, e])), j = h.map((e) => {
215
- const i = T.get(e.id);
214
+ }, C = it(d.config.deck.presets), T = new Set(C.map((t) => t.id)), g = d.persist.load(y(), {}), R = Array.isArray(g.layouts) ? g.layouts : [], j = new Map(R.map((t) => [t.id, t])), E = C.map((t) => {
215
+ const i = j.get(t.id);
216
216
  if (!u)
217
217
  return i ? {
218
218
  ...i,
219
- isPreset: e.isPreset
220
- } : e;
221
- if (!e.isPreset)
219
+ isPreset: t.isPreset
220
+ } : t;
221
+ if (!t.isPreset)
222
222
  return i ? {
223
223
  ...i,
224
224
  isPreset: !1
225
- } : e;
226
- const s = (g.presetWidgetStateByLayoutId ?? {})[e.id] ?? {}, t = {
227
- ...i ? B(i) : {},
228
- ...s
225
+ } : t;
226
+ const o = (g.presetWidgetStateByLayoutId ?? {})[t.id] ?? {}, e = {
227
+ ...i ? F(i) : {},
228
+ ...o
229
229
  };
230
230
  return {
231
- ...e,
232
- widgets: e.widgets.map((o) => ({
233
- ...o,
234
- state: t[o.id] ? L(t[o.id]) : void 0
231
+ ...t,
232
+ widgets: t.widgets.map((n) => ({
233
+ ...n,
234
+ state: e[n.id] ? L(e[n.id]) : void 0
235
235
  }))
236
236
  };
237
- }), E = W.filter((e) => !e.isPreset && !F.has(e.id)), I = [...j, ...E], k = new Set(I.map((e) => e.id)), K = g.activeLayoutId && k.has(g.activeLayoutId) ? g.activeLayoutId : d.config.deck.defaultActiveLayoutId && k.has(d.config.deck.defaultActiveLayoutId) ? d.config.deck.defaultActiveLayoutId : I[0]?.id ?? "", O = {
237
+ }), K = R.filter((t) => !t.isPreset && !T.has(t.id)), I = [...E, ...K], x = new Set(I.map((t) => t.id)), $ = g.activeLayoutId && x.has(g.activeLayoutId) ? g.activeLayoutId : d.config.deck.defaultActiveLayoutId && x.has(d.config.deck.defaultActiveLayoutId) ? d.config.deck.defaultActiveLayoutId : I[0]?.id ?? "", G = {
238
238
  layouts: I,
239
- activeLayoutId: K,
239
+ activeLayoutId: $,
240
240
  editMode: !1
241
- }, [r, c] = H(O), [x, A] = z(null), [C, D] = z(null), R = (e) => e;
242
- G(() => {
243
- R(r.layouts.length);
244
- for (const n of r.layouts) R(n.updatedAt);
241
+ }, [r, c] = N(G), [b, A] = h(null), [O, D] = h(null), [z, M] = h(null), X = (t) => t;
242
+ J(() => {
243
+ X(r.layouts.length);
244
+ for (const a of r.layouts) X(a.updatedAt);
245
245
  if (!u) {
246
- const n = {
246
+ const a = {
247
247
  layouts: r.layouts,
248
248
  activeLayoutId: r.activeLayoutId
249
249
  };
250
- d.persist.debouncedSave(y(), n);
250
+ d.persist.debouncedSave(y(), a);
251
251
  return;
252
252
  }
253
- const e = {}, i = [];
254
- for (const n of r.layouts) {
255
- if (n.isPreset) {
256
- const t = {};
257
- for (const o of n.widgets ?? [])
258
- !o?.id || !o.state || (t[o.id] = o.state);
259
- e[n.id] = t;
253
+ const t = {}, i = [];
254
+ for (const a of r.layouts) {
255
+ if (a.isPreset) {
256
+ const e = {};
257
+ for (const n of a.widgets ?? [])
258
+ !n?.id || !n.state || (e[n.id] = n.state);
259
+ t[a.id] = e;
260
260
  continue;
261
261
  }
262
- i.push(n);
262
+ i.push(a);
263
263
  }
264
- const s = {
264
+ const o = {
265
265
  layouts: i,
266
266
  activeLayoutId: r.activeLayoutId,
267
- presetWidgetStateByLayoutId: e
267
+ presetWidgetStateByLayoutId: t
268
268
  };
269
- d.persist.debouncedSave(y(), s);
269
+ d.persist.debouncedSave(y(), o);
270
270
  });
271
- const f = () => r.layouts.find((e) => e.id === r.activeLayoutId), S = () => `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
271
+ const l = () => r.layouts.find((t) => t.id === r.activeLayoutId), S = () => `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
272
272
  return {
273
273
  // Layout management
274
274
  layouts: () => r.layouts,
275
275
  activeLayoutId: () => r.activeLayoutId,
276
- activeLayout: f,
277
- setActiveLayout: (e) => {
278
- r.layouts.some((i) => i.id === e) && (c("activeLayoutId", e), u && r.layouts.find((s) => s.id === e)?.isPreset && c("editMode", !1));
276
+ activeLayout: l,
277
+ setActiveLayout: (t) => {
278
+ r.layouts.some((i) => i.id === t) && (c("activeLayoutId", t), u && r.layouts.find((o) => o.id === t)?.isPreset && c("editMode", !1));
279
279
  },
280
- createLayout: (e, i) => {
281
- const s = {
280
+ createLayout: (t, i) => {
281
+ const o = {
282
282
  id: S(),
283
- name: e,
283
+ name: t,
284
284
  widgets: i ?? [],
285
285
  createdAt: Date.now(),
286
286
  updatedAt: Date.now()
287
287
  };
288
- return c(l((n) => {
289
- n.layouts.push(s), n.activeLayoutId = s.id;
290
- })), s;
288
+ return c(f((a) => {
289
+ a.layouts.push(o), a.activeLayoutId = o.id;
290
+ })), o;
291
291
  },
292
- duplicateLayout: (e, i) => {
293
- const s = r.layouts.find((t) => t.id === e);
294
- if (!s) return;
295
- const n = {
292
+ duplicateLayout: (t, i) => {
293
+ const o = r.layouts.find((e) => e.id === t);
294
+ if (!o) return;
295
+ const a = {
296
296
  id: S(),
297
297
  name: i,
298
- widgets: s.widgets.map((t) => ({
299
- ...t,
298
+ widgets: o.widgets.map((e) => ({
299
+ ...e,
300
300
  id: S(),
301
301
  position: {
302
- ...t.position
302
+ ...e.position
303
303
  },
304
- config: t.config ? L(t.config) : void 0,
305
- state: t.state ? L(t.state) : void 0
304
+ config: e.config ? L(e.config) : void 0,
305
+ state: e.state ? L(e.state) : void 0
306
306
  })),
307
307
  createdAt: Date.now(),
308
308
  updatedAt: Date.now()
309
309
  };
310
- return c(l((t) => {
311
- t.layouts.push(n), t.activeLayoutId = n.id;
312
- })), n;
310
+ return c(f((e) => {
311
+ e.layouts.push(a), e.activeLayoutId = a.id;
312
+ })), a;
313
313
  },
314
- deleteLayout: (e) => {
315
- const i = r.layouts.find((s) => s.id === e);
316
- !i || i.isPreset || c(l((s) => {
317
- const n = s.layouts.findIndex((t) => t.id === e);
318
- n !== -1 && (s.layouts.splice(n, 1), s.activeLayoutId === e && (s.activeLayoutId = s.layouts[0]?.id ?? ""));
314
+ deleteLayout: (t) => {
315
+ const i = r.layouts.find((o) => o.id === t);
316
+ !i || i.isPreset || c(f((o) => {
317
+ const a = o.layouts.findIndex((e) => e.id === t);
318
+ a !== -1 && (o.layouts.splice(a, 1), o.activeLayoutId === t && (o.activeLayoutId = o.layouts[0]?.id ?? ""));
319
319
  }));
320
320
  },
321
- renameLayout: (e, i) => {
322
- const s = r.layouts.find((n) => n.id === e);
323
- !s || s.isPreset || c(l((n) => {
324
- const t = n.layouts.find((o) => o.id === e);
325
- t && (t.name = i, t.updatedAt = Date.now());
321
+ renameLayout: (t, i) => {
322
+ const o = r.layouts.find((a) => a.id === t);
323
+ !o || o.isPreset || c(f((a) => {
324
+ const e = a.layouts.find((n) => n.id === t);
325
+ e && (e.name = i, e.updatedAt = Date.now());
326
326
  }));
327
327
  },
328
328
  // Edit mode
329
329
  editMode: () => r.editMode,
330
- setEditMode: (e) => {
331
- e && u && f()?.isPreset || c("editMode", e);
330
+ setEditMode: (t) => {
331
+ t && u && l()?.isPreset || c("editMode", t);
332
332
  },
333
333
  toggleEditMode: () => {
334
- !r.editMode && u && f()?.isPreset || c("editMode", !r.editMode);
334
+ !r.editMode && u && l()?.isPreset || c("editMode", !r.editMode);
335
335
  },
336
336
  // Widget management
337
- addWidget: (e, i, s) => {
338
- const n = f();
339
- if (!n || u && n.isPreset) return;
340
- const t = m.getWidget(e), o = {
341
- minColSpan: t?.minColSpan ?? 2,
342
- minRowSpan: t?.minRowSpan ?? 2
343
- }, a = {
344
- colSpan: i?.colSpan ?? t?.defaultColSpan ?? Math.max(o.minColSpan, 4),
345
- rowSpan: i?.rowSpan ?? t?.defaultRowSpan ?? Math.max(o.minRowSpan, 3)
346
- }, p = i?.col !== void 0 && i?.row !== void 0 ? V({
347
- ...a,
337
+ addWidget: (t, i, o) => {
338
+ const a = l();
339
+ if (!a || u && a.isPreset) return;
340
+ const e = m.getWidget(t), n = {
341
+ minColSpan: e?.minColSpan ?? 2,
342
+ minRowSpan: e?.minRowSpan ?? 2
343
+ }, s = {
344
+ colSpan: i?.colSpan ?? e?.defaultColSpan ?? Math.max(n.minColSpan, 4),
345
+ rowSpan: i?.rowSpan ?? e?.defaultRowSpan ?? Math.max(n.minRowSpan, 3)
346
+ }, p = i?.col !== void 0 && i?.row !== void 0 ? _({
347
+ ...s,
348
348
  col: i.col,
349
349
  row: i.row
350
- }, o.minColSpan, o.minRowSpan) : X(n.widgets, a.colSpan, a.rowSpan), P = S(), $ = {
350
+ }, n.minColSpan, n.minRowSpan) : tt(a.widgets, s.colSpan, s.rowSpan), P = S(), q = {
351
351
  id: P,
352
- type: e,
352
+ type: t,
353
353
  position: p,
354
- config: s
354
+ config: o
355
355
  };
356
- return c(l((b) => {
357
- const v = b.layouts.find((q) => q.id === b.activeLayoutId);
358
- v && (v.widgets.push($), v.updatedAt = Date.now());
356
+ return c(f((Y) => {
357
+ const v = Y.layouts.find((H) => H.id === Y.activeLayoutId);
358
+ v && (v.widgets.push(q), v.updatedAt = Date.now());
359
359
  })), P;
360
360
  },
361
- removeWidget: (e) => {
362
- const i = f();
363
- u && i?.isPreset || c(l((s) => {
364
- const n = s.layouts.find((t) => t.id === s.activeLayoutId);
365
- if (n) {
366
- const t = n.widgets.findIndex((o) => o.id === e);
367
- t !== -1 && (n.widgets.splice(t, 1), n.updatedAt = Date.now());
361
+ removeWidget: (t) => {
362
+ const i = l();
363
+ u && i?.isPreset || c(f((o) => {
364
+ const a = o.layouts.find((e) => e.id === o.activeLayoutId);
365
+ if (a) {
366
+ const e = a.widgets.findIndex((n) => n.id === t);
367
+ e !== -1 && (a.widgets.splice(e, 1), a.updatedAt = Date.now());
368
368
  }
369
369
  }));
370
370
  },
371
- updateWidgetPosition: (e, i) => {
372
- const s = f();
373
- u && s?.isPreset || c(l((n) => {
374
- const t = n.layouts.find((o) => o.id === n.activeLayoutId);
375
- if (t) {
376
- const o = t.widgets.find((a) => a.id === e);
377
- o && (M(i, t.widgets, e) || (o.position = i, t.updatedAt = Date.now()));
371
+ updateWidgetPosition: (t, i) => {
372
+ const o = l();
373
+ u && o?.isPreset || c(f((a) => {
374
+ const e = a.layouts.find((n) => n.id === a.activeLayoutId);
375
+ if (e) {
376
+ const n = e.widgets.find((s) => s.id === t);
377
+ n && (k(i, e.widgets, t) || (n.position = i, e.updatedAt = Date.now()));
378
378
  }
379
379
  }));
380
380
  },
381
- updateWidgetConfig: (e, i) => {
382
- const s = f();
383
- u && s?.isPreset || c(l((n) => {
384
- const t = n.layouts.find((o) => o.id === n.activeLayoutId);
385
- if (t) {
386
- const o = t.widgets.find((a) => a.id === e);
387
- o && (o.config = {
388
- ...o.config,
381
+ updateWidgetConfig: (t, i) => {
382
+ const o = l();
383
+ u && o?.isPreset || c(f((a) => {
384
+ const e = a.layouts.find((n) => n.id === a.activeLayoutId);
385
+ if (e) {
386
+ const n = e.widgets.find((s) => s.id === t);
387
+ n && (n.config = {
388
+ ...n.config,
389
389
  ...i
390
- }, t.updatedAt = Date.now());
390
+ }, e.updatedAt = Date.now());
391
391
  }
392
392
  }));
393
393
  },
394
- updateWidgetTitle: (e, i) => {
395
- const s = f();
396
- u && s?.isPreset || c(l((n) => {
397
- const t = n.layouts.find((o) => o.id === n.activeLayoutId);
398
- if (t) {
399
- const o = t.widgets.find((a) => a.id === e);
400
- o && (o.title = i, t.updatedAt = Date.now());
394
+ updateWidgetTitle: (t, i) => {
395
+ const o = l();
396
+ u && o?.isPreset || c(f((a) => {
397
+ const e = a.layouts.find((n) => n.id === a.activeLayoutId);
398
+ if (e) {
399
+ const n = e.widgets.find((s) => s.id === t);
400
+ n && (n.title = i, e.updatedAt = Date.now());
401
401
  }
402
402
  }));
403
403
  },
404
- changeWidgetType: (e, i) => {
405
- const s = f();
406
- u && s?.isPreset || c(l((n) => {
407
- const t = n.layouts.find((o) => o.id === n.activeLayoutId);
408
- if (t) {
409
- const o = t.widgets.find((a) => a.id === e);
410
- o && (o.type = i, o.config = void 0, o.title = void 0, o.state = void 0, t.updatedAt = Date.now());
404
+ changeWidgetType: (t, i) => {
405
+ const o = l();
406
+ u && o?.isPreset || c(f((a) => {
407
+ const e = a.layouts.find((n) => n.id === a.activeLayoutId);
408
+ if (e) {
409
+ const n = e.widgets.find((s) => s.id === t);
410
+ n && (n.type = i, n.config = void 0, n.title = void 0, n.state = void 0, e.updatedAt = Date.now());
411
411
  }
412
412
  }));
413
413
  },
414
- updateWidgetState: (e, i, s) => {
415
- c(l((n) => {
416
- const t = n.layouts.find((o) => o.id === n.activeLayoutId);
417
- if (t) {
418
- const o = t.widgets.find((a) => a.id === e);
419
- o && (o.state || (o.state = {}), o.state[i] = s, t.updatedAt = Date.now());
414
+ updateWidgetState: (t, i, o) => {
415
+ c(f((a) => {
416
+ const e = a.layouts.find((n) => n.id === a.activeLayoutId);
417
+ if (e) {
418
+ const n = e.widgets.find((s) => s.id === t);
419
+ n && (n.state || (n.state = {}), n.state[i] = o, e.updatedAt = Date.now());
420
420
  }
421
421
  }));
422
422
  },
423
- getWidgetState: (e) => f()?.widgets.find((n) => n.id === e)?.state ?? {},
423
+ getWidgetState: (t) => l()?.widgets.find((a) => a.id === t)?.state ?? {},
424
424
  // Drag state
425
- dragState: x,
426
- startDrag: (e, i, s) => {
427
- const n = f();
428
- if (u && n?.isPreset) return;
429
- const t = n?.widgets.find((o) => o.id === e);
430
- t && A({
431
- widgetId: e,
432
- originalPosition: {
433
- ...t.position
434
- },
435
- currentPosition: {
436
- ...t.position
437
- },
438
- pixelOffset: {
439
- x: 0,
440
- y: 0
441
- },
442
- startX: i,
443
- startY: s
425
+ dragState: b,
426
+ dragMotion: O,
427
+ startDrag: (t, i, o) => {
428
+ const a = l();
429
+ if (u && a?.isPreset) return;
430
+ const e = a?.widgets.find((n) => n.id === t);
431
+ e && W(() => {
432
+ A({
433
+ widgetId: t,
434
+ originalPosition: {
435
+ ...e.position
436
+ },
437
+ currentPosition: {
438
+ ...e.position
439
+ },
440
+ startX: i,
441
+ startY: o
442
+ }), D({
443
+ widgetId: t,
444
+ deltaX: 0,
445
+ deltaY: 0
446
+ });
444
447
  });
445
448
  },
446
- updateDrag: (e, i) => {
447
- A((s) => s ? {
448
- ...s,
449
- currentPosition: e,
450
- pixelOffset: i
451
- } : null);
449
+ updateDrag: (t, i) => {
450
+ W(() => {
451
+ D((o) => !o || o.deltaX === i.deltaX && o.deltaY === i.deltaY ? o : {
452
+ ...o,
453
+ deltaX: i.deltaX,
454
+ deltaY: i.deltaY
455
+ }), A((o) => !o || B(o.currentPosition, t) ? o : {
456
+ ...o,
457
+ currentPosition: t
458
+ });
459
+ });
452
460
  },
453
- endDrag: (e) => {
454
- const i = x();
455
- if (i) {
456
- if (e) {
457
- const s = f();
458
- s && !(u && s.isPreset) && !M(i.currentPosition, s.widgets, i.widgetId) && c(l((n) => {
459
- const t = n.layouts.find((o) => o.id === n.activeLayoutId);
460
- if (t) {
461
- const o = t.widgets.find((a) => a.id === i.widgetId);
462
- o && (o.position = i.currentPosition, t.updatedAt = Date.now());
461
+ endDrag: (t) => {
462
+ const i = b();
463
+ i && W(() => {
464
+ if (t) {
465
+ const o = l();
466
+ o && !(u && o.isPreset) && !k(i.currentPosition, o.widgets, i.widgetId) && c(f((a) => {
467
+ const e = a.layouts.find((n) => n.id === a.activeLayoutId);
468
+ if (e) {
469
+ const n = e.widgets.find((s) => s.id === i.widgetId);
470
+ n && (n.position = i.currentPosition, e.updatedAt = Date.now());
463
471
  }
464
472
  }));
465
473
  }
466
- A(null);
467
- }
474
+ A(null), D(null);
475
+ });
468
476
  },
469
477
  // Resize state
470
- resizeState: C,
471
- startResize: (e, i, s, n) => {
472
- const t = f();
473
- if (u && t?.isPreset) return;
474
- const o = t?.widgets.find((a) => a.id === e);
475
- o && D({
476
- widgetId: e,
478
+ resizeState: z,
479
+ startResize: (t, i, o, a) => {
480
+ const e = l();
481
+ if (u && e?.isPreset) return;
482
+ const n = e?.widgets.find((s) => s.id === t);
483
+ n && M({
484
+ widgetId: t,
477
485
  edge: i,
478
486
  originalPosition: {
479
- ...o.position
487
+ ...n.position
480
488
  },
481
489
  currentPosition: {
482
- ...o.position
490
+ ...n.position
483
491
  },
484
- startX: s,
485
- startY: n
492
+ startX: o,
493
+ startY: a
486
494
  });
487
495
  },
488
- updateResize: (e) => {
489
- D((i) => i ? {
496
+ updateResize: (t) => {
497
+ M((i) => !i || B(i.currentPosition, t) ? i : {
490
498
  ...i,
491
- currentPosition: e
492
- } : null);
499
+ currentPosition: t
500
+ });
493
501
  },
494
- endResize: (e) => {
495
- const i = C();
502
+ endResize: (t) => {
503
+ const i = z();
496
504
  if (i) {
497
- if (e) {
498
- const s = f();
499
- s && !(u && s.isPreset) && !M(i.currentPosition, s.widgets, i.widgetId) && c(l((n) => {
500
- const t = n.layouts.find((o) => o.id === n.activeLayoutId);
501
- if (t) {
502
- const o = t.widgets.find((a) => a.id === i.widgetId);
503
- o && (o.position = i.currentPosition, t.updatedAt = Date.now());
505
+ if (t) {
506
+ const o = l();
507
+ o && !(u && o.isPreset) && !k(i.currentPosition, o.widgets, i.widgetId) && c(f((a) => {
508
+ const e = a.layouts.find((n) => n.id === a.activeLayoutId);
509
+ if (e) {
510
+ const n = e.widgets.find((s) => s.id === i.widgetId);
511
+ n && (n.position = i.currentPosition, e.updatedAt = Date.now());
504
512
  }
505
513
  }));
506
514
  }
507
- D(null);
515
+ M(null);
508
516
  }
509
517
  },
510
518
  // Utilities
511
- getWidgetMinConstraints: (e) => {
512
- const i = m.getWidget(e);
519
+ getWidgetMinConstraints: (t) => {
520
+ const i = m.getWidget(t);
513
521
  return {
514
522
  minColSpan: i?.minColSpan ?? 2,
515
523
  minRowSpan: i?.minRowSpan ?? 2
@@ -518,7 +526,7 @@ function _() {
518
526
  };
519
527
  }
520
528
  export {
521
- at as DeckProvider,
522
- _ as createDeckService,
523
- dt as useDeck
529
+ ut as DeckProvider,
530
+ ot as createDeckService,
531
+ lt as useDeck
524
532
  };