react-sync-board 1.0.0 → 1.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,3751 @@
1
+ var Dr = Object.defineProperty;
2
+ var $r = (e, t, r) => t in e ? Dr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var Ot = (e, t, r) => ($r(e, typeof t != "symbol" ? t + "" : t, r), r);
4
+ import g, { useContext as be, useDebugValue as Ar, useRef as Ie, useMemo as ct, useEffect as Me, useCallback as Jt, memo as Zt } from "react";
5
+ function zr(e) {
6
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
+ }
8
+ var Oe = {}, Lr = {
9
+ get exports() {
10
+ return Oe;
11
+ },
12
+ set exports(e) {
13
+ Oe = e;
14
+ }
15
+ }, we = {};
16
+ /**
17
+ * @license React
18
+ * react-jsx-runtime.production.min.js
19
+ *
20
+ * Copyright (c) Facebook, Inc. and its affiliates.
21
+ *
22
+ * This source code is licensed under the MIT license found in the
23
+ * LICENSE file in the root directory of this source tree.
24
+ */
25
+ var Tt;
26
+ function Yr() {
27
+ if (Tt)
28
+ return we;
29
+ Tt = 1;
30
+ var e = g, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
31
+ function a(u, l, f) {
32
+ var d, c = {}, b = null, _ = null;
33
+ f !== void 0 && (b = "" + f), l.key !== void 0 && (b = "" + l.key), l.ref !== void 0 && (_ = l.ref);
34
+ for (d in l)
35
+ n.call(l, d) && !s.hasOwnProperty(d) && (c[d] = l[d]);
36
+ if (u && u.defaultProps)
37
+ for (d in l = u.defaultProps, l)
38
+ c[d] === void 0 && (c[d] = l[d]);
39
+ return { $$typeof: t, type: u, key: b, ref: _, props: c, _owner: o.current };
40
+ }
41
+ return we.Fragment = r, we.jsx = a, we.jsxs = a, we;
42
+ }
43
+ var Ce = {};
44
+ /**
45
+ * @license React
46
+ * react-jsx-runtime.development.js
47
+ *
48
+ * Copyright (c) Facebook, Inc. and its affiliates.
49
+ *
50
+ * This source code is licensed under the MIT license found in the
51
+ * LICENSE file in the root directory of this source tree.
52
+ */
53
+ var kt;
54
+ function Br() {
55
+ return kt || (kt = 1, process.env.NODE_ENV !== "production" && function() {
56
+ var e = g, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), o = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), f = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), c = Symbol.for("react.memo"), b = Symbol.for("react.lazy"), _ = Symbol.for("react.offscreen"), w = Symbol.iterator, m = "@@iterator";
57
+ function E(i) {
58
+ if (i === null || typeof i != "object")
59
+ return null;
60
+ var S = w && i[w] || i[m];
61
+ return typeof S == "function" ? S : null;
62
+ }
63
+ var R = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
64
+ function x(i) {
65
+ {
66
+ for (var S = arguments.length, I = new Array(S > 1 ? S - 1 : 0), j = 1; j < S; j++)
67
+ I[j - 1] = arguments[j];
68
+ y("error", i, I);
69
+ }
70
+ }
71
+ function y(i, S, I) {
72
+ {
73
+ var j = R.ReactDebugCurrentFrame, B = j.getStackAddendum();
74
+ B !== "" && (S += "%s", I = I.concat([B]));
75
+ var X = I.map(function(L) {
76
+ return String(L);
77
+ });
78
+ X.unshift("Warning: " + S), Function.prototype.apply.call(console[i], console, X);
79
+ }
80
+ }
81
+ var p = !1, h = !1, v = !1, C = !1, D = !1, k;
82
+ k = Symbol.for("react.module.reference");
83
+ function P(i) {
84
+ return !!(typeof i == "string" || typeof i == "function" || i === n || i === s || D || i === o || i === f || i === d || C || i === _ || p || h || v || typeof i == "object" && i !== null && (i.$$typeof === b || i.$$typeof === c || i.$$typeof === a || i.$$typeof === u || i.$$typeof === l || // This needs to include all possible module reference object
85
+ // types supported by any Flight configuration anywhere since
86
+ // we don't know which Flight build this will end up being used
87
+ // with.
88
+ i.$$typeof === k || i.getModuleId !== void 0));
89
+ }
90
+ function M(i, S, I) {
91
+ var j = i.displayName;
92
+ if (j)
93
+ return j;
94
+ var B = S.displayName || S.name || "";
95
+ return B !== "" ? I + "(" + B + ")" : I;
96
+ }
97
+ function N(i) {
98
+ return i.displayName || "Context";
99
+ }
100
+ function F(i) {
101
+ if (i == null)
102
+ return null;
103
+ if (typeof i.tag == "number" && x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof i == "function")
104
+ return i.displayName || i.name || null;
105
+ if (typeof i == "string")
106
+ return i;
107
+ switch (i) {
108
+ case n:
109
+ return "Fragment";
110
+ case r:
111
+ return "Portal";
112
+ case s:
113
+ return "Profiler";
114
+ case o:
115
+ return "StrictMode";
116
+ case f:
117
+ return "Suspense";
118
+ case d:
119
+ return "SuspenseList";
120
+ }
121
+ if (typeof i == "object")
122
+ switch (i.$$typeof) {
123
+ case u:
124
+ var S = i;
125
+ return N(S) + ".Consumer";
126
+ case a:
127
+ var I = i;
128
+ return N(I._context) + ".Provider";
129
+ case l:
130
+ return M(i, i.render, "ForwardRef");
131
+ case c:
132
+ var j = i.displayName || null;
133
+ return j !== null ? j : F(i.type) || "Memo";
134
+ case b: {
135
+ var B = i, X = B._payload, L = B._init;
136
+ try {
137
+ return F(L(X));
138
+ } catch {
139
+ return null;
140
+ }
141
+ }
142
+ }
143
+ return null;
144
+ }
145
+ var K = Object.assign, O = 0, $, A, U, Y, W, J, te;
146
+ function re() {
147
+ }
148
+ re.__reactDisabledLog = !0;
149
+ function ne() {
150
+ {
151
+ if (O === 0) {
152
+ $ = console.log, A = console.info, U = console.warn, Y = console.error, W = console.group, J = console.groupCollapsed, te = console.groupEnd;
153
+ var i = {
154
+ configurable: !0,
155
+ enumerable: !0,
156
+ value: re,
157
+ writable: !0
158
+ };
159
+ Object.defineProperties(console, {
160
+ info: i,
161
+ log: i,
162
+ warn: i,
163
+ error: i,
164
+ group: i,
165
+ groupCollapsed: i,
166
+ groupEnd: i
167
+ });
168
+ }
169
+ O++;
170
+ }
171
+ }
172
+ function V() {
173
+ {
174
+ if (O--, O === 0) {
175
+ var i = {
176
+ configurable: !0,
177
+ enumerable: !0,
178
+ writable: !0
179
+ };
180
+ Object.defineProperties(console, {
181
+ log: K({}, i, {
182
+ value: $
183
+ }),
184
+ info: K({}, i, {
185
+ value: A
186
+ }),
187
+ warn: K({}, i, {
188
+ value: U
189
+ }),
190
+ error: K({}, i, {
191
+ value: Y
192
+ }),
193
+ group: K({}, i, {
194
+ value: W
195
+ }),
196
+ groupCollapsed: K({}, i, {
197
+ value: J
198
+ }),
199
+ groupEnd: K({}, i, {
200
+ value: te
201
+ })
202
+ });
203
+ }
204
+ O < 0 && x("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
205
+ }
206
+ }
207
+ var ee = R.ReactCurrentDispatcher, le;
208
+ function he(i, S, I) {
209
+ {
210
+ if (le === void 0)
211
+ try {
212
+ throw Error();
213
+ } catch (B) {
214
+ var j = B.stack.trim().match(/\n( *(at )?)/);
215
+ le = j && j[1] || "";
216
+ }
217
+ return `
218
+ ` + le + i;
219
+ }
220
+ }
221
+ var Ve = !1, je;
222
+ {
223
+ var fr = typeof WeakMap == "function" ? WeakMap : Map;
224
+ je = new fr();
225
+ }
226
+ function mt(i, S) {
227
+ if (!i || Ve)
228
+ return "";
229
+ {
230
+ var I = je.get(i);
231
+ if (I !== void 0)
232
+ return I;
233
+ }
234
+ var j;
235
+ Ve = !0;
236
+ var B = Error.prepareStackTrace;
237
+ Error.prepareStackTrace = void 0;
238
+ var X;
239
+ X = ee.current, ee.current = null, ne();
240
+ try {
241
+ if (S) {
242
+ var L = function() {
243
+ throw Error();
244
+ };
245
+ if (Object.defineProperty(L.prototype, "props", {
246
+ set: function() {
247
+ throw Error();
248
+ }
249
+ }), typeof Reflect == "object" && Reflect.construct) {
250
+ try {
251
+ Reflect.construct(L, []);
252
+ } catch (ae) {
253
+ j = ae;
254
+ }
255
+ Reflect.construct(i, [], L);
256
+ } else {
257
+ try {
258
+ L.call();
259
+ } catch (ae) {
260
+ j = ae;
261
+ }
262
+ i.call(L.prototype);
263
+ }
264
+ } else {
265
+ try {
266
+ throw Error();
267
+ } catch (ae) {
268
+ j = ae;
269
+ }
270
+ i();
271
+ }
272
+ } catch (ae) {
273
+ if (ae && j && typeof ae.stack == "string") {
274
+ for (var z = ae.stack.split(`
275
+ `), Q = j.stack.split(`
276
+ `), q = z.length - 1, G = Q.length - 1; q >= 1 && G >= 0 && z[q] !== Q[G]; )
277
+ G--;
278
+ for (; q >= 1 && G >= 0; q--, G--)
279
+ if (z[q] !== Q[G]) {
280
+ if (q !== 1 || G !== 1)
281
+ do
282
+ if (q--, G--, G < 0 || z[q] !== Q[G]) {
283
+ var oe = `
284
+ ` + z[q].replace(" at new ", " at ");
285
+ return i.displayName && oe.includes("<anonymous>") && (oe = oe.replace("<anonymous>", i.displayName)), typeof i == "function" && je.set(i, oe), oe;
286
+ }
287
+ while (q >= 1 && G >= 0);
288
+ break;
289
+ }
290
+ }
291
+ } finally {
292
+ Ve = !1, ee.current = X, V(), Error.prepareStackTrace = B;
293
+ }
294
+ var ye = i ? i.displayName || i.name : "", It = ye ? he(ye) : "";
295
+ return typeof i == "function" && je.set(i, It), It;
296
+ }
297
+ function dr(i, S, I) {
298
+ return mt(i, !1);
299
+ }
300
+ function pr(i) {
301
+ var S = i.prototype;
302
+ return !!(S && S.isReactComponent);
303
+ }
304
+ function De(i, S, I) {
305
+ if (i == null)
306
+ return "";
307
+ if (typeof i == "function")
308
+ return mt(i, pr(i));
309
+ if (typeof i == "string")
310
+ return he(i);
311
+ switch (i) {
312
+ case f:
313
+ return he("Suspense");
314
+ case d:
315
+ return he("SuspenseList");
316
+ }
317
+ if (typeof i == "object")
318
+ switch (i.$$typeof) {
319
+ case l:
320
+ return dr(i.render);
321
+ case c:
322
+ return De(i.type, S, I);
323
+ case b: {
324
+ var j = i, B = j._payload, X = j._init;
325
+ try {
326
+ return De(X(B), S, I);
327
+ } catch {
328
+ }
329
+ }
330
+ }
331
+ return "";
332
+ }
333
+ var $e = Object.prototype.hasOwnProperty, gt = {}, ht = R.ReactDebugCurrentFrame;
334
+ function Ae(i) {
335
+ if (i) {
336
+ var S = i._owner, I = De(i.type, i._source, S ? S.type : null);
337
+ ht.setExtraStackFrame(I);
338
+ } else
339
+ ht.setExtraStackFrame(null);
340
+ }
341
+ function mr(i, S, I, j, B) {
342
+ {
343
+ var X = Function.call.bind($e);
344
+ for (var L in i)
345
+ if (X(i, L)) {
346
+ var z = void 0;
347
+ try {
348
+ if (typeof i[L] != "function") {
349
+ var Q = Error((j || "React class") + ": " + I + " type `" + L + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof i[L] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
350
+ throw Q.name = "Invariant Violation", Q;
351
+ }
352
+ z = i[L](S, L, j, I, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
353
+ } catch (q) {
354
+ z = q;
355
+ }
356
+ z && !(z instanceof Error) && (Ae(B), x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", j || "React class", I, L, typeof z), Ae(null)), z instanceof Error && !(z.message in gt) && (gt[z.message] = !0, Ae(B), x("Failed %s type: %s", I, z.message), Ae(null));
357
+ }
358
+ }
359
+ }
360
+ var gr = Array.isArray;
361
+ function Fe(i) {
362
+ return gr(i);
363
+ }
364
+ function hr(i) {
365
+ {
366
+ var S = typeof Symbol == "function" && Symbol.toStringTag, I = S && i[Symbol.toStringTag] || i.constructor.name || "Object";
367
+ return I;
368
+ }
369
+ }
370
+ function vr(i) {
371
+ try {
372
+ return vt(i), !1;
373
+ } catch {
374
+ return !0;
375
+ }
376
+ }
377
+ function vt(i) {
378
+ return "" + i;
379
+ }
380
+ function yt(i) {
381
+ if (vr(i))
382
+ return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", hr(i)), vt(i);
383
+ }
384
+ var Ee = R.ReactCurrentOwner, yr = {
385
+ key: !0,
386
+ ref: !0,
387
+ __self: !0,
388
+ __source: !0
389
+ }, St, _t, Ke;
390
+ Ke = {};
391
+ function Sr(i) {
392
+ if ($e.call(i, "ref")) {
393
+ var S = Object.getOwnPropertyDescriptor(i, "ref").get;
394
+ if (S && S.isReactWarning)
395
+ return !1;
396
+ }
397
+ return i.ref !== void 0;
398
+ }
399
+ function _r(i) {
400
+ if ($e.call(i, "key")) {
401
+ var S = Object.getOwnPropertyDescriptor(i, "key").get;
402
+ if (S && S.isReactWarning)
403
+ return !1;
404
+ }
405
+ return i.key !== void 0;
406
+ }
407
+ function br(i, S) {
408
+ if (typeof i.ref == "string" && Ee.current && S && Ee.current.stateNode !== S) {
409
+ var I = F(Ee.current.type);
410
+ Ke[I] || (x('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', F(Ee.current.type), i.ref), Ke[I] = !0);
411
+ }
412
+ }
413
+ function Er(i, S) {
414
+ {
415
+ var I = function() {
416
+ St || (St = !0, x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", S));
417
+ };
418
+ I.isReactWarning = !0, Object.defineProperty(i, "key", {
419
+ get: I,
420
+ configurable: !0
421
+ });
422
+ }
423
+ }
424
+ function wr(i, S) {
425
+ {
426
+ var I = function() {
427
+ _t || (_t = !0, x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", S));
428
+ };
429
+ I.isReactWarning = !0, Object.defineProperty(i, "ref", {
430
+ get: I,
431
+ configurable: !0
432
+ });
433
+ }
434
+ }
435
+ var Cr = function(i, S, I, j, B, X, L) {
436
+ var z = {
437
+ // This tag allows us to uniquely identify this as a React Element
438
+ $$typeof: t,
439
+ // Built-in properties that belong on the element
440
+ type: i,
441
+ key: S,
442
+ ref: I,
443
+ props: L,
444
+ // Record the component responsible for creating this element.
445
+ _owner: X
446
+ };
447
+ return z._store = {}, Object.defineProperty(z._store, "validated", {
448
+ configurable: !1,
449
+ enumerable: !1,
450
+ writable: !0,
451
+ value: !1
452
+ }), Object.defineProperty(z, "_self", {
453
+ configurable: !1,
454
+ enumerable: !1,
455
+ writable: !1,
456
+ value: j
457
+ }), Object.defineProperty(z, "_source", {
458
+ configurable: !1,
459
+ enumerable: !1,
460
+ writable: !1,
461
+ value: B
462
+ }), Object.freeze && (Object.freeze(z.props), Object.freeze(z)), z;
463
+ };
464
+ function xr(i, S, I, j, B) {
465
+ {
466
+ var X, L = {}, z = null, Q = null;
467
+ I !== void 0 && (yt(I), z = "" + I), _r(S) && (yt(S.key), z = "" + S.key), Sr(S) && (Q = S.ref, br(S, B));
468
+ for (X in S)
469
+ $e.call(S, X) && !yr.hasOwnProperty(X) && (L[X] = S[X]);
470
+ if (i && i.defaultProps) {
471
+ var q = i.defaultProps;
472
+ for (X in q)
473
+ L[X] === void 0 && (L[X] = q[X]);
474
+ }
475
+ if (z || Q) {
476
+ var G = typeof i == "function" ? i.displayName || i.name || "Unknown" : i;
477
+ z && Er(L, G), Q && wr(L, G);
478
+ }
479
+ return Cr(i, z, Q, B, j, Ee.current, L);
480
+ }
481
+ }
482
+ var He = R.ReactCurrentOwner, bt = R.ReactDebugCurrentFrame;
483
+ function ve(i) {
484
+ if (i) {
485
+ var S = i._owner, I = De(i.type, i._source, S ? S.type : null);
486
+ bt.setExtraStackFrame(I);
487
+ } else
488
+ bt.setExtraStackFrame(null);
489
+ }
490
+ var qe;
491
+ qe = !1;
492
+ function Ge(i) {
493
+ return typeof i == "object" && i !== null && i.$$typeof === t;
494
+ }
495
+ function Et() {
496
+ {
497
+ if (He.current) {
498
+ var i = F(He.current.type);
499
+ if (i)
500
+ return `
501
+
502
+ Check the render method of \`` + i + "`.";
503
+ }
504
+ return "";
505
+ }
506
+ }
507
+ function Rr(i) {
508
+ {
509
+ if (i !== void 0) {
510
+ var S = i.fileName.replace(/^.*[\\\/]/, ""), I = i.lineNumber;
511
+ return `
512
+
513
+ Check your code at ` + S + ":" + I + ".";
514
+ }
515
+ return "";
516
+ }
517
+ }
518
+ var wt = {};
519
+ function Ir(i) {
520
+ {
521
+ var S = Et();
522
+ if (!S) {
523
+ var I = typeof i == "string" ? i : i.displayName || i.name;
524
+ I && (S = `
525
+
526
+ Check the top-level render call using <` + I + ">.");
527
+ }
528
+ return S;
529
+ }
530
+ }
531
+ function Ct(i, S) {
532
+ {
533
+ if (!i._store || i._store.validated || i.key != null)
534
+ return;
535
+ i._store.validated = !0;
536
+ var I = Ir(S);
537
+ if (wt[I])
538
+ return;
539
+ wt[I] = !0;
540
+ var j = "";
541
+ i && i._owner && i._owner !== He.current && (j = " It was passed a child from " + F(i._owner.type) + "."), ve(i), x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', I, j), ve(null);
542
+ }
543
+ }
544
+ function xt(i, S) {
545
+ {
546
+ if (typeof i != "object")
547
+ return;
548
+ if (Fe(i))
549
+ for (var I = 0; I < i.length; I++) {
550
+ var j = i[I];
551
+ Ge(j) && Ct(j, S);
552
+ }
553
+ else if (Ge(i))
554
+ i._store && (i._store.validated = !0);
555
+ else if (i) {
556
+ var B = E(i);
557
+ if (typeof B == "function" && B !== i.entries)
558
+ for (var X = B.call(i), L; !(L = X.next()).done; )
559
+ Ge(L.value) && Ct(L.value, S);
560
+ }
561
+ }
562
+ }
563
+ function Or(i) {
564
+ {
565
+ var S = i.type;
566
+ if (S == null || typeof S == "string")
567
+ return;
568
+ var I;
569
+ if (typeof S == "function")
570
+ I = S.propTypes;
571
+ else if (typeof S == "object" && (S.$$typeof === l || // Note: Memo only checks outer props here.
572
+ // Inner props are checked in the reconciler.
573
+ S.$$typeof === c))
574
+ I = S.propTypes;
575
+ else
576
+ return;
577
+ if (I) {
578
+ var j = F(S);
579
+ mr(I, i.props, "prop", j, i);
580
+ } else if (S.PropTypes !== void 0 && !qe) {
581
+ qe = !0;
582
+ var B = F(S);
583
+ x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", B || "Unknown");
584
+ }
585
+ typeof S.getDefaultProps == "function" && !S.getDefaultProps.isReactClassApproved && x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
586
+ }
587
+ }
588
+ function Tr(i) {
589
+ {
590
+ for (var S = Object.keys(i.props), I = 0; I < S.length; I++) {
591
+ var j = S[I];
592
+ if (j !== "children" && j !== "key") {
593
+ ve(i), x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", j), ve(null);
594
+ break;
595
+ }
596
+ }
597
+ i.ref !== null && (ve(i), x("Invalid attribute `ref` supplied to `React.Fragment`."), ve(null));
598
+ }
599
+ }
600
+ function Rt(i, S, I, j, B, X) {
601
+ {
602
+ var L = P(i);
603
+ if (!L) {
604
+ var z = "";
605
+ (i === void 0 || typeof i == "object" && i !== null && Object.keys(i).length === 0) && (z += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
606
+ var Q = Rr(B);
607
+ Q ? z += Q : z += Et();
608
+ var q;
609
+ i === null ? q = "null" : Fe(i) ? q = "array" : i !== void 0 && i.$$typeof === t ? (q = "<" + (F(i.type) || "Unknown") + " />", z = " Did you accidentally export a JSX literal instead of a component?") : q = typeof i, x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", q, z);
610
+ }
611
+ var G = xr(i, S, I, B, X);
612
+ if (G == null)
613
+ return G;
614
+ if (L) {
615
+ var oe = S.children;
616
+ if (oe !== void 0)
617
+ if (j)
618
+ if (Fe(oe)) {
619
+ for (var ye = 0; ye < oe.length; ye++)
620
+ xt(oe[ye], i);
621
+ Object.freeze && Object.freeze(oe);
622
+ } else
623
+ x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
624
+ else
625
+ xt(oe, i);
626
+ }
627
+ return i === n ? Tr(G) : Or(G), G;
628
+ }
629
+ }
630
+ function kr(i, S, I) {
631
+ return Rt(i, S, I, !0);
632
+ }
633
+ function Pr(i, S, I) {
634
+ return Rt(i, S, I, !1);
635
+ }
636
+ var Mr = Pr, jr = kr;
637
+ Ce.Fragment = n, Ce.jsx = Mr, Ce.jsxs = jr;
638
+ }()), Ce;
639
+ }
640
+ (function(e) {
641
+ process.env.NODE_ENV === "production" ? e.exports = Yr() : e.exports = Br();
642
+ })(Lr);
643
+ const Qt = Oe.Fragment, T = Oe.jsx, ue = Oe.jsxs;
644
+ let Nr = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((t, r) => (r &= 63, r < 36 ? t += r.toString(36) : r < 62 ? t += (r - 26).toString(36).toUpperCase() : r > 62 ? t += "-" : t += "_", t), "");
645
+ class Ur {
646
+ constructor(t, r, n = null) {
647
+ this._socket = t, this.userId = n, this.room = r, this.toUnregister = [
648
+ () => {
649
+ this._socket.off(`${this.room}.isMaster`), this._socket.off(`${this.room}.roomJoined`), this._socket.off(`${this.room}._call`);
650
+ }
651
+ ], this._left = !1, this.registeredRPC = {}, this._socket.on(`${this.room}._call`, async ({ callId: o, name: s, params: a }) => {
652
+ try {
653
+ const u = await this.registeredRPC[s](a);
654
+ t.emit(`${this.room}._result.${o}`, {
655
+ ok: u || null
656
+ });
657
+ } catch (u) {
658
+ t.emit(`${this.room}._result.${o}`, {
659
+ err: `${u.message}`
660
+ });
661
+ }
662
+ });
663
+ }
664
+ /**
665
+ * Call a server procedure.
666
+ *
667
+ * @param {string} action name of the operation to call on the server.
668
+ * @param {*} params the params of the action.
669
+ * @returns the result of the call.
670
+ */
671
+ async _callServerRPC(t, r) {
672
+ const n = Nr();
673
+ return new Promise((o, s) => {
674
+ this._socket.once(`${this.room}._result.${n}`, (a) => {
675
+ a.hasOwnProperty("ok") ? o(a.ok) : s(a.err);
676
+ }), this._socket.emit(`${this.room}._call`, { callId: n, name: t, params: r });
677
+ });
678
+ }
679
+ /**
680
+ * Leave current room
681
+ * @param {string} room name.
682
+ */
683
+ leave() {
684
+ this._left = !0, this.toUnregister.forEach((t) => {
685
+ t();
686
+ }), this._socket.emit(`${this.room}.leave`);
687
+ }
688
+ /**
689
+ * Send an event to all other client in room. Also to self if true.
690
+ * @param {string} name Name of event
691
+ * @param {*} params arguments of event
692
+ * @param {boolean} self if true, the publish get the event too
693
+ */
694
+ publish(t, r, n = !1) {
695
+ this._socket.emit(`${this.room}.publish`, { name: t, params: r, self: n });
696
+ }
697
+ /**
698
+ * Subscribe to an event.
699
+ * @param {string} event Name of event
700
+ * @param {function} callback Called when the event is received. First param
701
+ * of the function is the params sent with the event.
702
+ */
703
+ subscribe(t, r) {
704
+ this._socket.on(`${this.room}.${t}`, r);
705
+ const n = () => {
706
+ this._socket.off(`${this.room}.${t}`, r);
707
+ };
708
+ return this.toUnregister.push(n), n;
709
+ }
710
+ /**
711
+ * Register a new RPC function.
712
+ * @param {string} name of function
713
+ * @param {function} callback the function that handle the function result
714
+ * @param {object} params the configuration of the RPC. For now only `invoke`
715
+ * parameter is allowed with the following values:
716
+ * - 'single' for a RPC that can be registered only once.
717
+ * - 'first' The first registered client is called.
718
+ * - 'last' The last registered client is called.
719
+ * - 'random' A random RPC is called.
720
+ */
721
+ async register(t, r, { invoke: n = "single" } = {}) {
722
+ this.registeredRPC[t] = r, await this._callServerRPC("register", {
723
+ name: t,
724
+ invoke: n
725
+ });
726
+ const o = () => {
727
+ if (this.registeredRPC[t] === r)
728
+ return delete this.registeredRPC[t], this._callServerRPC("unregister", { name: t });
729
+ };
730
+ return this.toUnregister.push(o), o;
731
+ }
732
+ /**
733
+ * Call a previously registered function with `params` arguments.
734
+ * @param {string} name of function
735
+ * @param {*} params parameters of the called function.
736
+ */
737
+ async call(t, r) {
738
+ return await this._callServerRPC("call", { name: t, params: r });
739
+ }
740
+ }
741
+ const Xr = ({
742
+ socket: e,
743
+ room: t,
744
+ onJoined: r = () => {
745
+ },
746
+ onMaster: n = () => {
747
+ },
748
+ userId: o = null
749
+ }) => {
750
+ const s = new Ur(e, t, o);
751
+ return new Promise((a) => {
752
+ let u = !0;
753
+ e.on(`${t}.isMaster`, () => {
754
+ s._left || n(t);
755
+ }), e.on(`${t}.roomJoined`, (l) => {
756
+ s._left || (s.userId = l, u = !1, r(s), a(s));
757
+ }), e.on("connect", () => {
758
+ s._left || u || e.emit("joinSuperSocket", {
759
+ room: t,
760
+ userId: s.userId
761
+ });
762
+ }), e.emit("joinSuperSocket", { room: t, userId: o });
763
+ });
764
+ }, ot = g.createContext(), Wr = () => /* @__PURE__ */ T(
765
+ "div",
766
+ {
767
+ style: {
768
+ position: "absolute",
769
+ top: "0",
770
+ bottom: "0",
771
+ width: "100%",
772
+ display: "flex",
773
+ justifyContent: "center",
774
+ alignItems: "center"
775
+ },
776
+ children: /* @__PURE__ */ T("h2", { children: "🌀 Loading..." })
777
+ }
778
+ ), er = ({
779
+ socket: e,
780
+ room: t,
781
+ channel: r = "default",
782
+ LoadingComponent: n = Wr,
783
+ children: o
784
+ }) => {
785
+ const [s, a] = g.useState(!1), [u, l] = g.useState(!1), [f, d] = g.useState(null), c = g.useRef(null), b = g.useRef(!1), _ = be(ot), w = g.useRef(!1);
786
+ return g.useEffect(() => (b.current = !0, () => {
787
+ b.current = !1;
788
+ }), []), g.useEffect(() => {
789
+ if (!e)
790
+ return null;
791
+ const m = () => {
792
+ console.log(`Disconnected from ${r}…`), b.current && (a(!1), l(!1));
793
+ };
794
+ return e.on("disconnect", m), () => {
795
+ e.off("disconnect", m);
796
+ };
797
+ }, [r, e]), g.useEffect(() => e ? (e.connected || e.connect(), console.log(`Try to connect to wire ${t} on channel ${r}`), w.current || (w.current = !0, Xr({
798
+ socket: e,
799
+ room: t,
800
+ onMaster: () => {
801
+ console.log(`Is now master on channel ${r}…`), b.current && l(!0);
802
+ },
803
+ onJoined: (m) => {
804
+ console.log(`Connected on channel ${r}…`), c.current = m, b.current && (d(m), a(!0));
805
+ }
806
+ })), () => {
807
+ var m;
808
+ (m = c.current) == null || m.leave();
809
+ }) : null, [r, t, e]), !s || !f ? /* @__PURE__ */ T(n, {}) : /* @__PURE__ */ T(
810
+ ot.Provider,
811
+ {
812
+ value: { ..._, [r]: { wire: f, joined: s, isMaster: u, room: t } },
813
+ children: o
814
+ }
815
+ );
816
+ }, Be = (e = "default") => (be(ot) || {})[e], Pt = (e) => {
817
+ let t;
818
+ const r = /* @__PURE__ */ new Set(), n = (l, f) => {
819
+ const d = typeof l == "function" ? l(t) : l;
820
+ if (!Object.is(d, t)) {
821
+ const c = t;
822
+ t = f ?? typeof d != "object" ? d : Object.assign({}, t, d), r.forEach((b) => b(t, c));
823
+ }
824
+ }, o = () => t, u = { setState: n, getState: o, subscribe: (l) => (r.add(l), () => r.delete(l)), destroy: () => {
825
+ ({ BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0 } && "production") !== "production" && console.warn(
826
+ "[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected."
827
+ ), r.clear();
828
+ } };
829
+ return t = e(n, o, u), u;
830
+ }, Ne = (e) => e ? Pt(e) : Pt;
831
+ var st = {}, Vr = {
832
+ get exports() {
833
+ return st;
834
+ },
835
+ set exports(e) {
836
+ st = e;
837
+ }
838
+ }, Je = {}, Ye = {}, Fr = {
839
+ get exports() {
840
+ return Ye;
841
+ },
842
+ set exports(e) {
843
+ Ye = e;
844
+ }
845
+ }, Ze = {};
846
+ /**
847
+ * @license React
848
+ * use-sync-external-store-shim.production.min.js
849
+ *
850
+ * Copyright (c) Facebook, Inc. and its affiliates.
851
+ *
852
+ * This source code is licensed under the MIT license found in the
853
+ * LICENSE file in the root directory of this source tree.
854
+ */
855
+ var Mt;
856
+ function Kr() {
857
+ if (Mt)
858
+ return Ze;
859
+ Mt = 1;
860
+ var e = g;
861
+ function t(c, b) {
862
+ return c === b && (c !== 0 || 1 / c === 1 / b) || c !== c && b !== b;
863
+ }
864
+ var r = typeof Object.is == "function" ? Object.is : t, n = e.useState, o = e.useEffect, s = e.useLayoutEffect, a = e.useDebugValue;
865
+ function u(c, b) {
866
+ var _ = b(), w = n({ inst: { value: _, getSnapshot: b } }), m = w[0].inst, E = w[1];
867
+ return s(function() {
868
+ m.value = _, m.getSnapshot = b, l(m) && E({ inst: m });
869
+ }, [c, _, b]), o(function() {
870
+ return l(m) && E({ inst: m }), c(function() {
871
+ l(m) && E({ inst: m });
872
+ });
873
+ }, [c]), a(_), _;
874
+ }
875
+ function l(c) {
876
+ var b = c.getSnapshot;
877
+ c = c.value;
878
+ try {
879
+ var _ = b();
880
+ return !r(c, _);
881
+ } catch {
882
+ return !0;
883
+ }
884
+ }
885
+ function f(c, b) {
886
+ return b();
887
+ }
888
+ var d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? f : u;
889
+ return Ze.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : d, Ze;
890
+ }
891
+ var Qe = {};
892
+ /**
893
+ * @license React
894
+ * use-sync-external-store-shim.development.js
895
+ *
896
+ * Copyright (c) Facebook, Inc. and its affiliates.
897
+ *
898
+ * This source code is licensed under the MIT license found in the
899
+ * LICENSE file in the root directory of this source tree.
900
+ */
901
+ var jt;
902
+ function Hr() {
903
+ return jt || (jt = 1, process.env.NODE_ENV !== "production" && function() {
904
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
905
+ var e = g, t = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
906
+ function r(y) {
907
+ {
908
+ for (var p = arguments.length, h = new Array(p > 1 ? p - 1 : 0), v = 1; v < p; v++)
909
+ h[v - 1] = arguments[v];
910
+ n("error", y, h);
911
+ }
912
+ }
913
+ function n(y, p, h) {
914
+ {
915
+ var v = t.ReactDebugCurrentFrame, C = v.getStackAddendum();
916
+ C !== "" && (p += "%s", h = h.concat([C]));
917
+ var D = h.map(function(k) {
918
+ return String(k);
919
+ });
920
+ D.unshift("Warning: " + p), Function.prototype.apply.call(console[y], console, D);
921
+ }
922
+ }
923
+ function o(y, p) {
924
+ return y === p && (y !== 0 || 1 / y === 1 / p) || y !== y && p !== p;
925
+ }
926
+ var s = typeof Object.is == "function" ? Object.is : o, a = e.useState, u = e.useEffect, l = e.useLayoutEffect, f = e.useDebugValue, d = !1, c = !1;
927
+ function b(y, p, h) {
928
+ d || e.startTransition !== void 0 && (d = !0, r("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
929
+ var v = p();
930
+ if (!c) {
931
+ var C = p();
932
+ s(v, C) || (r("The result of getSnapshot should be cached to avoid an infinite loop"), c = !0);
933
+ }
934
+ var D = a({
935
+ inst: {
936
+ value: v,
937
+ getSnapshot: p
938
+ }
939
+ }), k = D[0].inst, P = D[1];
940
+ return l(function() {
941
+ k.value = v, k.getSnapshot = p, _(k) && P({
942
+ inst: k
943
+ });
944
+ }, [y, v, p]), u(function() {
945
+ _(k) && P({
946
+ inst: k
947
+ });
948
+ var M = function() {
949
+ _(k) && P({
950
+ inst: k
951
+ });
952
+ };
953
+ return y(M);
954
+ }, [y]), f(v), v;
955
+ }
956
+ function _(y) {
957
+ var p = y.getSnapshot, h = y.value;
958
+ try {
959
+ var v = p();
960
+ return !s(h, v);
961
+ } catch {
962
+ return !0;
963
+ }
964
+ }
965
+ function w(y, p, h) {
966
+ return p();
967
+ }
968
+ var m = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", E = !m, R = E ? w : b, x = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : R;
969
+ Qe.useSyncExternalStore = x, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
970
+ }()), Qe;
971
+ }
972
+ var Dt;
973
+ function tr() {
974
+ return Dt || (Dt = 1, function(e) {
975
+ process.env.NODE_ENV === "production" ? e.exports = Kr() : e.exports = Hr();
976
+ }(Fr)), Ye;
977
+ }
978
+ /**
979
+ * @license React
980
+ * use-sync-external-store-shim/with-selector.production.min.js
981
+ *
982
+ * Copyright (c) Facebook, Inc. and its affiliates.
983
+ *
984
+ * This source code is licensed under the MIT license found in the
985
+ * LICENSE file in the root directory of this source tree.
986
+ */
987
+ var $t;
988
+ function qr() {
989
+ if ($t)
990
+ return Je;
991
+ $t = 1;
992
+ var e = g, t = tr();
993
+ function r(f, d) {
994
+ return f === d && (f !== 0 || 1 / f === 1 / d) || f !== f && d !== d;
995
+ }
996
+ var n = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, s = e.useRef, a = e.useEffect, u = e.useMemo, l = e.useDebugValue;
997
+ return Je.useSyncExternalStoreWithSelector = function(f, d, c, b, _) {
998
+ var w = s(null);
999
+ if (w.current === null) {
1000
+ var m = { hasValue: !1, value: null };
1001
+ w.current = m;
1002
+ } else
1003
+ m = w.current;
1004
+ w = u(function() {
1005
+ function R(v) {
1006
+ if (!x) {
1007
+ if (x = !0, y = v, v = b(v), _ !== void 0 && m.hasValue) {
1008
+ var C = m.value;
1009
+ if (_(C, v))
1010
+ return p = C;
1011
+ }
1012
+ return p = v;
1013
+ }
1014
+ if (C = p, n(y, v))
1015
+ return C;
1016
+ var D = b(v);
1017
+ return _ !== void 0 && _(C, D) ? C : (y = v, p = D);
1018
+ }
1019
+ var x = !1, y, p, h = c === void 0 ? null : c;
1020
+ return [function() {
1021
+ return R(d());
1022
+ }, h === null ? void 0 : function() {
1023
+ return R(h());
1024
+ }];
1025
+ }, [d, c, b, _]);
1026
+ var E = o(f, w[0], w[1]);
1027
+ return a(function() {
1028
+ m.hasValue = !0, m.value = E;
1029
+ }, [E]), l(E), E;
1030
+ }, Je;
1031
+ }
1032
+ var et = {};
1033
+ /**
1034
+ * @license React
1035
+ * use-sync-external-store-shim/with-selector.development.js
1036
+ *
1037
+ * Copyright (c) Facebook, Inc. and its affiliates.
1038
+ *
1039
+ * This source code is licensed under the MIT license found in the
1040
+ * LICENSE file in the root directory of this source tree.
1041
+ */
1042
+ var At;
1043
+ function Gr() {
1044
+ return At || (At = 1, process.env.NODE_ENV !== "production" && function() {
1045
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
1046
+ var e = g, t = tr();
1047
+ function r(d, c) {
1048
+ return d === c && (d !== 0 || 1 / d === 1 / c) || d !== d && c !== c;
1049
+ }
1050
+ var n = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, s = e.useRef, a = e.useEffect, u = e.useMemo, l = e.useDebugValue;
1051
+ function f(d, c, b, _, w) {
1052
+ var m = s(null), E;
1053
+ m.current === null ? (E = {
1054
+ hasValue: !1,
1055
+ value: null
1056
+ }, m.current = E) : E = m.current;
1057
+ var R = u(function() {
1058
+ var h = !1, v, C, D = function(N) {
1059
+ if (!h) {
1060
+ h = !0, v = N;
1061
+ var F = _(N);
1062
+ if (w !== void 0 && E.hasValue) {
1063
+ var K = E.value;
1064
+ if (w(K, F))
1065
+ return C = K, K;
1066
+ }
1067
+ return C = F, F;
1068
+ }
1069
+ var O = v, $ = C;
1070
+ if (n(O, N))
1071
+ return $;
1072
+ var A = _(N);
1073
+ return w !== void 0 && w($, A) ? $ : (v = N, C = A, A);
1074
+ }, k = b === void 0 ? null : b, P = function() {
1075
+ return D(c());
1076
+ }, M = k === null ? void 0 : function() {
1077
+ return D(k());
1078
+ };
1079
+ return [P, M];
1080
+ }, [c, b, _, w]), x = R[0], y = R[1], p = o(d, x, y);
1081
+ return a(function() {
1082
+ E.hasValue = !0, E.value = p;
1083
+ }, [p]), l(p), p;
1084
+ }
1085
+ et.useSyncExternalStoreWithSelector = f, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
1086
+ }()), et;
1087
+ }
1088
+ (function(e) {
1089
+ process.env.NODE_ENV === "production" ? e.exports = qr() : e.exports = Gr();
1090
+ })(Vr);
1091
+ const Jr = /* @__PURE__ */ zr(st), { useSyncExternalStoreWithSelector: Zr } = Jr;
1092
+ function Ue(e, t = e.getState, r) {
1093
+ const n = Zr(
1094
+ e.subscribe,
1095
+ e.getState,
1096
+ e.getServerState || e.getState,
1097
+ t,
1098
+ r
1099
+ );
1100
+ return Ar(n), n;
1101
+ }
1102
+ const _e = (e, t) => e.classList && e.classList.contains(t), Te = (e, t) => _e(e, t) ? e : e.parentNode ? Te(e.parentNode, t) : !1, rr = (e, t) => e.x > t.left && e.x < t.left + t.width && e.y > t.top && e.y < t.top + t.height, Qr = (e, t) => Array.from(e.querySelectorAll(".corner")).every((n) => {
1103
+ const { top: o, left: s } = n.getBoundingClientRect();
1104
+ return rr({ x: s, y: o }, t);
1105
+ }), en = (e, t) => {
1106
+ const r = t.getBoundingClientRect();
1107
+ return Qr(e, r);
1108
+ }, it = (e, t) => {
1109
+ const n = e.getElementsByClassName(`item ${t}`)[0];
1110
+ return n || console.error(`Missing item ${t}`), n;
1111
+ }, ke = (e) => {
1112
+ var r, n;
1113
+ const t = (r = e == null ? void 0 : e.dataset) == null ? void 0 : r.id;
1114
+ return t || console.error(
1115
+ "getIdFromElem call fails",
1116
+ e,
1117
+ JSON.stringify(e == null ? void 0 : e.dataset),
1118
+ (n = e == null ? void 0 : e.dataset) == null ? void 0 : n.id
1119
+ ), t;
1120
+ }, nr = (e, t = document) => {
1121
+ const r = e.reduce((n, o) => {
1122
+ const s = it(t, o);
1123
+ if (!s)
1124
+ return null;
1125
+ const { left: a, right: u, top: l, bottom: f } = s.getBoundingClientRect();
1126
+ let d;
1127
+ return n ? d = n : d = {
1128
+ left: a,
1129
+ top: l,
1130
+ right: u,
1131
+ bottom: f
1132
+ }, d.left = Math.min(a, d.left), d.top = Math.min(l, d.top), d.right = Math.max(u, d.right), d.bottom = Math.max(f, d.bottom), d;
1133
+ }, null);
1134
+ return r && (r.width = r.right - r.left, r.height = r.bottom - r.top, r);
1135
+ }, tn = ({ x: e, y: t, width: r, height: n }, { type: o = "grid", size: s = 1, offset: a = { x: 0, y: 0 } }) => {
1136
+ const [u, l] = [
1137
+ e + r / 2 - a.x,
1138
+ t + n / 2 - a.y
1139
+ ];
1140
+ let f, d, c, b, _, w, m, E, R, x;
1141
+ const y = s / 1.1547;
1142
+ switch (o) {
1143
+ case "grid":
1144
+ f = Math.round(u / s) * s, d = Math.round(l / s) * s;
1145
+ break;
1146
+ case "hexH":
1147
+ c = 2 * y, b = 3 * s, _ = Math.round(u / c) * c, m = Math.round(l / b) * b, w = _ > u ? _ - y : _ + y, E = m > l ? m - 1.5 * s : m + 1.5 * s, R = Math.hypot(_ - u, m - l), x = Math.hypot(w - u, E - l), R < x ? (f = _, d = m) : (f = w, d = E);
1148
+ break;
1149
+ case "hexV":
1150
+ c = 3 * s, b = 2 * y, _ = Math.round(u / c) * c, m = Math.round(l / b) * b, w = _ > u ? _ - 1.5 * s : _ + 1.5 * s, E = m > l ? m - y : m + y, R = Math.hypot(_ - u, m - l), x = Math.hypot(w - u, E - l), R < x ? (f = _, d = m) : (f = w, d = E);
1151
+ break;
1152
+ default:
1153
+ f = e + r / 2, d = t + n / 2;
1154
+ }
1155
+ return {
1156
+ x: f + a.x - r / 2,
1157
+ y: d + a.y - n / 2
1158
+ };
1159
+ }, zt = [
1160
+ "#037758",
1161
+ "#99092a",
1162
+ "#067070",
1163
+ "#c6650f",
1164
+ "#008726",
1165
+ "#3d7004",
1166
+ "#348402",
1167
+ "#057f58",
1168
+ "#b58612",
1169
+ "#c44c01",
1170
+ "#0a7704",
1171
+ "#0e910e",
1172
+ "#027377",
1173
+ "#c99e02",
1174
+ "#054160",
1175
+ "#157a01",
1176
+ "#b10de2",
1177
+ "#0d6289",
1178
+ "#bc5d03",
1179
+ "#ba0cd1",
1180
+ "#d39f10",
1181
+ "#0c4c7a",
1182
+ "#460782",
1183
+ "#a51f10",
1184
+ "#cecb10",
1185
+ "#9b0943",
1186
+ "#607f0c",
1187
+ "#007a4b",
1188
+ "#bf0daa",
1189
+ "#af0ad8"
1190
+ ], Lt = () => zt[Math.floor(Math.random() * zt.length)], rn = !1, ut = ({ wire: e, storeName: t, noSync: r = [], defaultValue: n }, o) => (s, a, u) => {
1191
+ s({ ready: !1 });
1192
+ const l = [];
1193
+ (async () => {
1194
+ try {
1195
+ const _ = await e.call(`${t}_getValue`);
1196
+ rn && console.log("init from peer with value", _), s((w) => ({ ...w, ..._ }));
1197
+ } catch {
1198
+ n !== void 0 && s(n);
1199
+ }
1200
+ l.push(
1201
+ await e.register(
1202
+ `${t}_getValue`,
1203
+ () => Object.fromEntries(
1204
+ Object.entries(a()).filter(
1205
+ ([_, w]) => typeof w != "function" && !r.includes(_)
1206
+ )
1207
+ ),
1208
+ { invoke: "first" }
1209
+ )
1210
+ ), l.push(
1211
+ e.subscribe(`${t}_call`, ([_, w]) => {
1212
+ c[_](...w);
1213
+ })
1214
+ ), s({ ready: !0 });
1215
+ })();
1216
+ const d = o(s, a, u), c = { ...d }, b = Object.fromEntries(
1217
+ // Send the update message on all method calls
1218
+ Object.entries(d).map(([_, w]) => typeof w == "function" && !_.startsWith("get") && !r.includes(_) ? [_, (...E) => {
1219
+ const R = w(...E);
1220
+ return e.publish(`${t}_call`, [_, E]), R;
1221
+ }] : [_, w])
1222
+ );
1223
+ return b.unsub = () => {
1224
+ l.forEach((_) => _());
1225
+ }, b;
1226
+ };
1227
+ function Xe(e, t) {
1228
+ if (Object.is(e, t))
1229
+ return !0;
1230
+ if (typeof e != "object" || e === null || typeof t != "object" || t === null)
1231
+ return !1;
1232
+ if (e instanceof Map && t instanceof Map) {
1233
+ if (e.size !== t.size)
1234
+ return !1;
1235
+ for (const [n, o] of e)
1236
+ if (!Object.is(o, t.get(n)))
1237
+ return !1;
1238
+ return !0;
1239
+ }
1240
+ if (e instanceof Set && t instanceof Set) {
1241
+ if (e.size !== t.size)
1242
+ return !1;
1243
+ for (const n of e)
1244
+ if (!t.has(n))
1245
+ return !1;
1246
+ return !0;
1247
+ }
1248
+ const r = Object.keys(e);
1249
+ if (r.length !== Object.keys(t).length)
1250
+ return !1;
1251
+ for (let n = 0; n < r.length; n++)
1252
+ if (!Object.prototype.hasOwnProperty.call(t, r[n]) || !Object.is(e[r[n]], t[r[n]]))
1253
+ return !1;
1254
+ return !0;
1255
+ }
1256
+ const or = g.createContext(), nn = (e, t) => ({
1257
+ items: {},
1258
+ getItems: () => t().items,
1259
+ setItems: (r) => e({ items: r }),
1260
+ updateItems: (r) => e((n) => ({ items: { ...n.items, ...r } })),
1261
+ moveItems: (r, n) => e(({ items: o }) => {
1262
+ const s = { ...o };
1263
+ return r.forEach((a) => {
1264
+ const u = o[a];
1265
+ u && (s[a] = {
1266
+ ...u,
1267
+ x: (u.x || 0) + n.x,
1268
+ y: (u.y || 0) + n.y,
1269
+ moving: !0
1270
+ });
1271
+ }), { items: s };
1272
+ })
1273
+ }), on = (e, t) => ({
1274
+ itemIds: [],
1275
+ setItemIds: (r) => e({ itemIds: r }),
1276
+ getItemIds: () => t().itemIds,
1277
+ insert: (r, n) => e((o) => {
1278
+ const s = [...o.itemIds];
1279
+ return s.splice(r, 0, n), { itemIds: s };
1280
+ }),
1281
+ remove: (r) => e((n) => {
1282
+ const o = [...n.itemIds];
1283
+ return o.splice(r, 1), { itemIds: o };
1284
+ }),
1285
+ updateItemIds: (r, n) => e((o) => {
1286
+ const s = [...o.itemIds];
1287
+ return s[r] = n, { items: s };
1288
+ }),
1289
+ updateManyItemIds: (r) => e((n) => ({
1290
+ items: n.itemIds.map((o, s) => r[s] !== void 0 ? r[s] : o)
1291
+ }))
1292
+ }), sn = (e, t) => ({
1293
+ removeItemsById: (r) => e((n) => ({
1294
+ itemIds: n.itemIds.filter((o) => !r.includes(o)),
1295
+ items: Object.fromEntries(
1296
+ Object.entries(n.items).filter(
1297
+ ([o]) => !r.includes(o)
1298
+ )
1299
+ )
1300
+ })),
1301
+ getItemList: () => {
1302
+ const r = t().items;
1303
+ return t().itemIds.map((n) => r[n]);
1304
+ },
1305
+ setItemList: (r) => e({
1306
+ items: Object.fromEntries(r.map((n) => [n.id, n])),
1307
+ itemIds: r.map(({ id: n }) => n)
1308
+ }),
1309
+ insertItems: (r, n) => e((o) => {
1310
+ let s;
1311
+ const a = r.map(({ id: u }) => u);
1312
+ if (n) {
1313
+ const u = o.itemIds.findIndex((l) => l === n);
1314
+ s = [...o.itemIds], s.splice(u, 0, ...a);
1315
+ } else
1316
+ s = [...o.itemIds, ...a];
1317
+ return {
1318
+ items: {
1319
+ ...o.items,
1320
+ ...Object.fromEntries(r.map((u) => [u.id, u]))
1321
+ },
1322
+ itemIds: s
1323
+ };
1324
+ })
1325
+ }), an = (e, t) => ({
1326
+ boardConfig: {},
1327
+ getBoardConfig: () => t().boardConfig,
1328
+ setBoardConfig: (r) => e({ boardConfig: r }),
1329
+ updateBoardConfig: (r) => e((n) => ({ boardConfig: { ...n.boardConfig, ...r } }))
1330
+ }), cn = (e, t) => ({
1331
+ session: {},
1332
+ getSessionInfo: () => t().session,
1333
+ setSessionInfo: (r) => e({ session: r }),
1334
+ updateSessionInfo: (r) => e((n) => ({ session: { ...n.session, ...r } }))
1335
+ }), Yt = ({ storeName: e, children: t, defaultValue: r }) => {
1336
+ const { wire: n } = Be("room"), [o] = g.useState(
1337
+ () => Ne(
1338
+ ut({ wire: n, storeName: e, defaultValue: r }, (...s) => ({
1339
+ ...nn(...s),
1340
+ ...on(...s),
1341
+ ...sn(...s),
1342
+ ...an(...s),
1343
+ ...cn(...s)
1344
+ }))
1345
+ )
1346
+ );
1347
+ return /* @__PURE__ */ T(or.Provider, { value: o, children: t });
1348
+ }, se = (e, t) => {
1349
+ const r = be(or);
1350
+ return Ue(r, e, t || Xe);
1351
+ }, Jo = () => {
1352
+ const [e, t] = se((n) => [
1353
+ n.itemIds,
1354
+ n.items
1355
+ ]);
1356
+ return g.useMemo(
1357
+ () => e.map((n) => t[n]),
1358
+ [e, t]
1359
+ );
1360
+ }, Zo = () => {
1361
+ const [e, t, r] = se((a) => [
1362
+ a.items,
1363
+ a.itemIds,
1364
+ a.getItemList
1365
+ ]), [n, o] = g.useState(r()), [, s] = g.useTransition();
1366
+ return g.useEffect(() => {
1367
+ const a = r();
1368
+ s(() => {
1369
+ o(a);
1370
+ });
1371
+ }, [e, t, r]), n;
1372
+ }, sr = 5e4, ir = g.createContext(), un = (e, t) => ({
1373
+ config: {
1374
+ itemTemplates: {},
1375
+ actions: {},
1376
+ uid: null,
1377
+ itemExtent: {},
1378
+ boardWrapperRect: {},
1379
+ boardSize: sr
1380
+ },
1381
+ // TODO optimize when same value as before
1382
+ updateConfiguration: (r) => e((n) => ({ config: { ...n.config, ...r } })),
1383
+ getConfiguration: () => t().config
1384
+ }), ln = (e, t) => ({
1385
+ boardState: {
1386
+ movingItems: !1,
1387
+ selecting: !1,
1388
+ zooming: !1,
1389
+ panning: !1,
1390
+ translateX: 0,
1391
+ translateY: 0,
1392
+ scale: 1
1393
+ },
1394
+ updateBoardState: (r) => e((n) => ({ boardState: { ...n.boardState, ...r } })),
1395
+ getBoardState: () => t().boardState
1396
+ }), fn = (e, t) => ({
1397
+ interactions: {},
1398
+ getInteractions: () => t().interactions,
1399
+ register: (r, n) => e((o) => {
1400
+ const s = [...o.interactions[r] || []];
1401
+ return s.push(n), {
1402
+ interactions: { ...o.interaction, [r]: s }
1403
+ };
1404
+ }),
1405
+ unregister: (r, n) => e((o) => {
1406
+ const s = (o.interactions[r] || []).filter(
1407
+ (a) => a !== n
1408
+ );
1409
+ return {
1410
+ interactions: { ...o.interaction, [r]: s }
1411
+ };
1412
+ }),
1413
+ callInteractions: (r, n) => {
1414
+ t().interactions[r] && t().interactions[r].forEach((o) => {
1415
+ o(n);
1416
+ });
1417
+ }
1418
+ }), dn = (e, t) => ({
1419
+ selection: [],
1420
+ setSelection: (r) => e((n) => JSON.stringify(n.selection) !== JSON.stringify(r) ? { selection: r } : {}),
1421
+ getSelection: () => t().selection,
1422
+ select: (r) => e((n) => ({
1423
+ selection: [...n.selection, ...r]
1424
+ })),
1425
+ unselect: (r) => e((n) => ({
1426
+ selection: n.selection.filter((o) => !r.includes(o))
1427
+ })),
1428
+ clear: () => e((r) => r.selection.length > 0 ? { selection: [] } : {}),
1429
+ reverse: () => e((r) => {
1430
+ const n = [...r.selection];
1431
+ return n.reverse(), { selection: n };
1432
+ }),
1433
+ selectionBox: null,
1434
+ setSelectionBox: (r) => e((n) => {
1435
+ const o = n.selectionBox;
1436
+ return !o || !r || o.top !== r.top || o.left !== r.left || o.width !== r.width || o.height !== r.height ? { selectionBox: r } : {};
1437
+ })
1438
+ }), Bt = ({ children: e }) => {
1439
+ const [t] = g.useState(
1440
+ () => Ne((...r) => ({
1441
+ ...un(...r),
1442
+ ...ln(...r),
1443
+ ...fn(...r),
1444
+ ...dn(...r)
1445
+ }))
1446
+ );
1447
+ return /* @__PURE__ */ T(ir.Provider, { value: t, children: e });
1448
+ }, Z = (e, t) => {
1449
+ const r = be(ir);
1450
+ return Ue(r, e, t || Xe);
1451
+ }, Qo = () => {
1452
+ const [e] = Z((t) => [t.selection]);
1453
+ return e;
1454
+ };
1455
+ function lt(e) {
1456
+ const t = Ie(e);
1457
+ return t.current = e, ct(() => Object.freeze({
1458
+ get current() {
1459
+ return t.current;
1460
+ }
1461
+ }), []);
1462
+ }
1463
+ function pn(e) {
1464
+ const t = lt(e);
1465
+ Me(
1466
+ () => () => {
1467
+ t.current();
1468
+ },
1469
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1470
+ []
1471
+ );
1472
+ }
1473
+ function ft(e, t, r, n = 0) {
1474
+ const o = Ie(), s = Ie(), a = Ie(), u = () => {
1475
+ o.current && (clearTimeout(o.current), o.current = void 0), s.current && (clearTimeout(s.current), s.current = void 0);
1476
+ };
1477
+ return pn(u), ct(
1478
+ () => {
1479
+ const l = () => {
1480
+ if (!a.current)
1481
+ return;
1482
+ const d = a.current;
1483
+ a.current = void 0, e.apply(d.this, d.args), u();
1484
+ }, f = function(...d) {
1485
+ o.current && clearTimeout(o.current), a.current = { args: d, this: this }, o.current = setTimeout(l, r), n > 0 && !s.current && (s.current = setTimeout(l, n));
1486
+ };
1487
+ return Object.defineProperties(f, {
1488
+ length: { value: e.length },
1489
+ name: { value: `${e.name || "anonymous"}__debounced__${r}` }
1490
+ }), f;
1491
+ },
1492
+ // eslint-disable-next-line react-hooks/exhaustive-deps,@typescript-eslint/no-unsafe-assignment
1493
+ [r, n, ...t]
1494
+ );
1495
+ }
1496
+ const ze = 100, Se = 1e3, mn = 0.8, Nt = ({
1497
+ x: e,
1498
+ y: t,
1499
+ scale: r,
1500
+ itemExtent: { right: n, left: o, top: s, bottom: a },
1501
+ boardWrapperRect: u,
1502
+ boardSize: l
1503
+ }) => {
1504
+ const f = {
1505
+ left: -n * r + ze * r,
1506
+ right: u.width - o * r - ze * r,
1507
+ top: -a * r + ze * r,
1508
+ bottom: u.height - s * r - ze * r,
1509
+ maxRight: u.width - l * r,
1510
+ maxLeft: u.height - l * r
1511
+ }, d = Math.min(
1512
+ Math.max(e, f.left, f.maxRight),
1513
+ f.right,
1514
+ 0
1515
+ ), c = Math.min(
1516
+ Math.max(t, f.top, f.maxLeft),
1517
+ f.bottom,
1518
+ 0
1519
+ );
1520
+ return [d, c];
1521
+ }, dt = () => {
1522
+ const [
1523
+ e,
1524
+ t,
1525
+ r,
1526
+ n,
1527
+ o
1528
+ ] = Z((m) => [
1529
+ m.getBoardState,
1530
+ m.updateBoardState,
1531
+ m.config.itemExtent,
1532
+ m.getConfiguration,
1533
+ m.updateConfiguration
1534
+ ]), s = g.useRef([0.1, 8]), [a] = se((m) => [m.getItemList]), u = g.useCallback(() => {
1535
+ const { translateX: m, translateY: E, scale: R } = e();
1536
+ return { translateX: m, translateY: E, scale: R };
1537
+ }, [e]), l = g.useCallback(
1538
+ (m) => {
1539
+ const { itemExtent: E, boardWrapperRect: R, boardSize: x } = n(), y = e(), { translateX: p, translateY: h, scale: v } = {
1540
+ ...y,
1541
+ ...m(y)
1542
+ };
1543
+ let C = v;
1544
+ v !== y.scale && (C > s.current[1] && ([, C] = s.current), C < s.current[0] && ([C] = s.current));
1545
+ let [D, k] = [p, h];
1546
+ (p !== y.translateX || h !== y.translateY) && ([D, k] = Nt({
1547
+ x: p,
1548
+ y: h,
1549
+ scale: C,
1550
+ itemExtent: E,
1551
+ boardWrapperRect: R,
1552
+ boardSize: x
1553
+ })), t({
1554
+ translateX: D,
1555
+ translateY: k,
1556
+ scale: C
1557
+ });
1558
+ },
1559
+ [e, n, t]
1560
+ ), f = g.useCallback(
1561
+ (m, E) => {
1562
+ const { itemExtent: R, boardWrapperRect: x, boardSize: y } = n();
1563
+ let p = E;
1564
+ p || (p = {
1565
+ x: x.width / 2,
1566
+ y: x.height / 2
1567
+ });
1568
+ const h = e();
1569
+ let v = h.scale * m;
1570
+ v > s.current[1] && ([, v] = s.current), v < s.current[0] && ([v] = s.current);
1571
+ const C = p.x - x.left, D = p.y - x.top, k = C - (C - h.translateX) * v / h.scale, P = D - (D - h.translateY) * v / h.scale, [M, N] = Nt({
1572
+ x: k,
1573
+ y: P,
1574
+ scale: v,
1575
+ itemExtent: R,
1576
+ boardWrapperRect: x,
1577
+ boardSize: y
1578
+ });
1579
+ t({
1580
+ scale: v,
1581
+ translateX: M,
1582
+ translateY: N
1583
+ });
1584
+ },
1585
+ [e, n, t]
1586
+ ), d = g.useCallback(
1587
+ ({ left: m, top: E, width: R, height: x }) => {
1588
+ const { boardWrapperRect: y } = n(), p = y.width / R, h = y.height / x, C = Math.min(p, h) * mn, D = y.width / 2 - (m + R / 2) * C, k = y.height / 2 - (E + x / 2) * C;
1589
+ t({
1590
+ translateX: D,
1591
+ translateY: k,
1592
+ scale: C
1593
+ });
1594
+ },
1595
+ [n, t]
1596
+ ), c = g.useCallback(async () => {
1597
+ const {
1598
+ itemExtent: { width: m, height: E },
1599
+ boardWrapperRect: R
1600
+ } = n(), x = R.width / m, y = R.height / E, p = Math.min(x, y);
1601
+ s.current = [
1602
+ Math.max(p * 0.5, 0.05),
1603
+ Math.max(p * 10, 10)
1604
+ ];
1605
+ }, [n]), b = g.useCallback(() => {
1606
+ const { boardWrapperRect: m, boardSize: E } = n(), { translateX: R, translateY: x, scale: y } = e();
1607
+ return {
1608
+ x: (m.width / 2 - R) / y - E / 2,
1609
+ y: (m.height / 2 - x) / y - E / 2
1610
+ };
1611
+ }, [e, n]), _ = g.useCallback(() => {
1612
+ const m = a(), { boardWrapperRect: E, boardWrapper: R, boardSize: x } = n(), { scale: y, translateX: p, translateY: h } = e(), { left: v, top: C, width: D, height: k } = nr(
1613
+ m.map(({ id: M }) => M),
1614
+ R
1615
+ ) || {
1616
+ left: x / 2 * y + E.left + p,
1617
+ top: x / 2 * y + E.top + h,
1618
+ width: 0,
1619
+ height: 0
1620
+ }, P = {
1621
+ left: (v - E.left - p) / y,
1622
+ top: (C - E.top - h) / y,
1623
+ width: D / y,
1624
+ height: k / y
1625
+ };
1626
+ if (P.right = P.left + P.width, P.bottom = P.top + P.height, P.width < Se) {
1627
+ const M = (Se - P.width) / 2;
1628
+ P.left -= M, P.right += M, P.width = Se;
1629
+ }
1630
+ if (P.height < Se) {
1631
+ const M = (Se - P.height) / 2;
1632
+ P.top -= M, P.bottom += M, P.height = Se;
1633
+ }
1634
+ o({ itemExtent: P });
1635
+ }, [e, n, a, o]), w = ft(
1636
+ () => _(),
1637
+ [_],
1638
+ 200
1639
+ );
1640
+ return g.useEffect(() => {
1641
+ r.left && c();
1642
+ }, [c, r]), {
1643
+ setDim: l,
1644
+ getDim: u,
1645
+ zoomTo: f,
1646
+ zoomToCenter: f,
1647
+ zoomToExtent: d,
1648
+ getCenter: b,
1649
+ updateItemExtent: w
1650
+ };
1651
+ }, gn = (e) => {
1652
+ const [t, r, n] = Z(
1653
+ ({ register: a, unregister: u, callInteractions: l }) => [
1654
+ a,
1655
+ u,
1656
+ l
1657
+ ]
1658
+ ), o = g.useCallback(
1659
+ (a) => (t(e, a), () => {
1660
+ r(e, a);
1661
+ }),
1662
+ [e, t, r]
1663
+ ), s = g.useCallback(
1664
+ (a) => {
1665
+ n(e, a);
1666
+ },
1667
+ [n, e]
1668
+ );
1669
+ return { register: o, call: s };
1670
+ }, pt = () => {
1671
+ const { call: e } = gn("place"), { getCenter: t, updateItemExtent: r } = dt(), [n, o, s, a] = Z((O) => [
1672
+ O.clear,
1673
+ O.reverse,
1674
+ O.unselect,
1675
+ O.getConfiguration
1676
+ ]), {
1677
+ getItems: u,
1678
+ getItemIds: l,
1679
+ setItemIds: f,
1680
+ updateItems: d,
1681
+ moveItems: c,
1682
+ removeItemsById: b,
1683
+ getItemList: _,
1684
+ insertItems: w,
1685
+ setItemList: m
1686
+ } = se(
1687
+ ({
1688
+ getItems: O,
1689
+ getItemIds: $,
1690
+ setItemIds: A,
1691
+ updateItems: U,
1692
+ moveItems: Y,
1693
+ removeItemsById: W,
1694
+ getItemList: J,
1695
+ insertItems: te,
1696
+ setItemList: re
1697
+ }) => ({
1698
+ getItems: O,
1699
+ getItemIds: $,
1700
+ setItemIds: A,
1701
+ updateItems: U,
1702
+ moveItems: Y,
1703
+ removeItemsById: W,
1704
+ getItemList: J,
1705
+ insertItems: te,
1706
+ setItemList: re
1707
+ })
1708
+ ), E = g.useCallback(
1709
+ (O, $) => {
1710
+ let A = $;
1711
+ typeof $ == "object" && (A = () => $);
1712
+ const U = l().filter((J) => O.includes(J)), Y = u(), W = Object.fromEntries(
1713
+ U.map((J) => [J, A({ ...Y[J] })])
1714
+ );
1715
+ d(W), r();
1716
+ },
1717
+ [l, u, r, d]
1718
+ ), R = g.useCallback(
1719
+ (O) => {
1720
+ m(O), n(), r();
1721
+ },
1722
+ [n, m, r]
1723
+ ), x = g.useCallback(
1724
+ (O, $) => {
1725
+ E([O], $);
1726
+ },
1727
+ [E]
1728
+ ), y = g.useCallback(
1729
+ (O, $) => {
1730
+ c(O, $), r();
1731
+ },
1732
+ [c, r]
1733
+ ), p = g.useCallback(
1734
+ (O) => {
1735
+ const $ = l(), A = $.filter((Y) => !O.includes(Y)), U = $.filter(
1736
+ (Y) => O.includes(Y)
1737
+ );
1738
+ f([...A, ...U]);
1739
+ },
1740
+ [l, f]
1741
+ ), h = g.useCallback(
1742
+ (O, { type: $, size: A } = {}) => {
1743
+ const { boardWrapper: U } = a(), Y = {}, W = u();
1744
+ O.forEach((J) => {
1745
+ const te = W[J], re = it(U, J);
1746
+ if (!re)
1747
+ return;
1748
+ const ne = {
1749
+ type: $ || "grid",
1750
+ size: A || 1,
1751
+ offset: { x: 0, y: 0 },
1752
+ ...te.grid
1753
+ }, V = tn(
1754
+ {
1755
+ x: te.x,
1756
+ y: te.y,
1757
+ width: re.clientWidth,
1758
+ height: re.clientHeight
1759
+ },
1760
+ ne
1761
+ );
1762
+ Y[J] = { ...te, ...V };
1763
+ }), d(Y);
1764
+ },
1765
+ [a, u, d]
1766
+ ), v = g.useCallback(
1767
+ (O, $) => {
1768
+ p(O), E(O, (A) => {
1769
+ const U = { ...A };
1770
+ return delete U.moving, U;
1771
+ }), h(O, $), e(O), r();
1772
+ },
1773
+ [
1774
+ E,
1775
+ e,
1776
+ p,
1777
+ h,
1778
+ r
1779
+ ]
1780
+ ), C = g.useCallback(
1781
+ (O) => {
1782
+ f(O);
1783
+ },
1784
+ [f]
1785
+ ), D = g.useCallback(
1786
+ (O) => {
1787
+ const $ = l(), A = $.filter(
1788
+ (Y) => O.includes(Y)
1789
+ ), U = $.map((Y) => O.includes(Y) ? A.pop() : Y);
1790
+ f(U), o();
1791
+ },
1792
+ [l, o, f]
1793
+ ), k = g.useCallback(
1794
+ (O, $) => {
1795
+ const A = u(), U = O.map((V) => A[V]), Y = $.map((V) => A[V]), W = $.reduce((V, ee) => (V[ee] = U.shift(), V), {}), J = Y.reduce((V, ee) => {
1796
+ const le = W[ee.id], he = {
1797
+ ...ee,
1798
+ x: le.x,
1799
+ y: le.y
1800
+ };
1801
+ return V[ee.id] = he, V;
1802
+ }, {});
1803
+ d(J);
1804
+ const te = O.reduce((V, ee) => (V[ee] = $.shift(), V), {}), ne = l().map((V) => O.includes(V) ? te[V] : V);
1805
+ f(ne);
1806
+ },
1807
+ [u, d, l, f]
1808
+ ), P = g.useCallback(
1809
+ (O, $) => {
1810
+ const A = t(), U = O.map((Y, W) => !Y.x || !Y.y ? { ...Y, x: A.x + 2 * W, y: A.y + 2 * W } : Y);
1811
+ w(U, $), r();
1812
+ },
1813
+ [t, w, r]
1814
+ ), M = g.useCallback(
1815
+ (O, $) => {
1816
+ P([O], $);
1817
+ },
1818
+ [P]
1819
+ ), N = g.useCallback(
1820
+ (O) => {
1821
+ s(O), b(O);
1822
+ },
1823
+ [s, b]
1824
+ ), F = g.useCallback(
1825
+ (O) => {
1826
+ const $ = u();
1827
+ return O.map((A) => $[A]);
1828
+ },
1829
+ [u]
1830
+ ), K = g.useCallback(
1831
+ ({ target: O, clientX: $, clientY: A }, { returnLocked: U = !1, passLocked: Y = !1 } = {}) => {
1832
+ if (["INPUT", "TEXTAREA"].includes(O.tagName))
1833
+ return null;
1834
+ const W = Te(O, "item");
1835
+ if (W) {
1836
+ if (_e(W, "selected"))
1837
+ return W;
1838
+ if (!Y && _e(W, "locked") && !_e(O, "passthrough"))
1839
+ return U ? W : null;
1840
+ if (_e(O, "passthrough")) {
1841
+ const J = l(), { boardWrapper: te } = a(), re = J.reduce((ne, V) => {
1842
+ const ee = it(te, V), le = ee.getBoundingClientRect();
1843
+ return rr({ x: $, y: A }, le) && ne.unshift(ee), ne;
1844
+ }, []);
1845
+ for (let ne = 0; ne < re.length; ne += 1) {
1846
+ const V = re[ne];
1847
+ if (V !== W && (Y || !_e(V, "locked")))
1848
+ return V;
1849
+ }
1850
+ return null;
1851
+ }
1852
+ }
1853
+ return W;
1854
+ },
1855
+ [a, l]
1856
+ );
1857
+ return {
1858
+ putItemsOnTop: p,
1859
+ batchUpdateItems: E,
1860
+ updateItemOrder: C,
1861
+ moveItems: y,
1862
+ placeItems: v,
1863
+ updateItem: x,
1864
+ swapItems: k,
1865
+ reverseItemsOrder: D,
1866
+ setItemList: R,
1867
+ pushItem: M,
1868
+ pushItems: P,
1869
+ removeItems: N,
1870
+ getItemList: _,
1871
+ findElementUnderPointer: K,
1872
+ getItems: F
1873
+ };
1874
+ };
1875
+ var hn = function e(t, r) {
1876
+ if (t === r)
1877
+ return !0;
1878
+ if (t && r && typeof t == "object" && typeof r == "object") {
1879
+ if (t.constructor !== r.constructor)
1880
+ return !1;
1881
+ var n, o, s;
1882
+ if (Array.isArray(t)) {
1883
+ if (n = t.length, n != r.length)
1884
+ return !1;
1885
+ for (o = n; o-- !== 0; )
1886
+ if (!e(t[o], r[o]))
1887
+ return !1;
1888
+ return !0;
1889
+ }
1890
+ if (t instanceof Map && r instanceof Map) {
1891
+ if (t.size !== r.size)
1892
+ return !1;
1893
+ for (o of t.entries())
1894
+ if (!r.has(o[0]))
1895
+ return !1;
1896
+ for (o of t.entries())
1897
+ if (!e(o[1], r.get(o[0])))
1898
+ return !1;
1899
+ return !0;
1900
+ }
1901
+ if (t instanceof Set && r instanceof Set) {
1902
+ if (t.size !== r.size)
1903
+ return !1;
1904
+ for (o of t.entries())
1905
+ if (!r.has(o[0]))
1906
+ return !1;
1907
+ return !0;
1908
+ }
1909
+ if (ArrayBuffer.isView(t) && ArrayBuffer.isView(r)) {
1910
+ if (n = t.length, n != r.length)
1911
+ return !1;
1912
+ for (o = n; o-- !== 0; )
1913
+ if (t[o] !== r[o])
1914
+ return !1;
1915
+ return !0;
1916
+ }
1917
+ if (t.constructor === RegExp)
1918
+ return t.source === r.source && t.flags === r.flags;
1919
+ if (t.valueOf !== Object.prototype.valueOf)
1920
+ return t.valueOf() === r.valueOf();
1921
+ if (t.toString !== Object.prototype.toString)
1922
+ return t.toString() === r.toString();
1923
+ if (s = Object.keys(t), n = s.length, n !== Object.keys(r).length)
1924
+ return !1;
1925
+ for (o = n; o-- !== 0; )
1926
+ if (!Object.prototype.hasOwnProperty.call(r, s[o]))
1927
+ return !1;
1928
+ for (o = n; o-- !== 0; ) {
1929
+ var a = s[o];
1930
+ if (!e(t[a], r[a]))
1931
+ return !1;
1932
+ }
1933
+ return !0;
1934
+ }
1935
+ return t !== t && r !== r;
1936
+ };
1937
+ function vn(e, t, r, n = 0) {
1938
+ Me(ft(e, t, r, n), t);
1939
+ }
1940
+ const yn = (e, t) => {
1941
+ if (e.type in t) {
1942
+ const r = t[e.type].defaultActions;
1943
+ return typeof r == "function" ? r(e) : r;
1944
+ }
1945
+ return [];
1946
+ }, Ut = (e, t) => {
1947
+ const { actions: r = yn(e, t) } = e;
1948
+ return r.map((n) => typeof n == "string" ? { name: n } : n);
1949
+ }, es = () => {
1950
+ const [e, t] = se((c) => [
1951
+ c.items,
1952
+ c.getItems
1953
+ ]), [r, n, o] = Z((c) => [
1954
+ c.config.itemTemplates,
1955
+ c.selection,
1956
+ c.getSelection
1957
+ ]), [s, a] = g.useState([]), u = g.useRef(!1), [, l] = g.useTransition();
1958
+ g.useEffect(() => (u.current = !0, () => {
1959
+ u.current = !1;
1960
+ }), []);
1961
+ const f = g.useCallback(
1962
+ (c) => {
1963
+ const b = t();
1964
+ if (c)
1965
+ return [c, c.map((w) => b[w])];
1966
+ const _ = o();
1967
+ return [_, _.map((w) => b[w])];
1968
+ },
1969
+ [t, o]
1970
+ ), d = Jt(() => {
1971
+ const [c, b] = f();
1972
+ if (c.length > 0) {
1973
+ if (!u.current)
1974
+ return;
1975
+ const _ = b.reduce((w, m) => {
1976
+ const E = Ut(m, r);
1977
+ return w.filter(
1978
+ (R) => E.some((x) => hn(R, x))
1979
+ );
1980
+ }, Ut(b[0], r));
1981
+ l(() => {
1982
+ a(_);
1983
+ });
1984
+ } else
1985
+ l(() => {
1986
+ a([]);
1987
+ });
1988
+ }, [f, r]);
1989
+ return vn(
1990
+ () => d(),
1991
+ [e, n, d],
1992
+ 100
1993
+ ), {
1994
+ availableActions: s
1995
+ };
1996
+ }, ts = () => {
1997
+ const [e] = Z((t) => [t.selectionBox]);
1998
+ return e;
1999
+ };
2000
+ let me = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((t, r) => (r &= 63, r < 36 ? t += r.toString(36) : r < 62 ? t += (r - 26).toString(36).toUpperCase() : r > 62 ? t += "-" : t += "_", t), "");
2001
+ const ar = g.createContext(), at = (e) => {
2002
+ localStorage.setItem("user", JSON.stringify(e));
2003
+ }, Sn = () => {
2004
+ if (localStorage.user) {
2005
+ const t = {
2006
+ name: "Player",
2007
+ color: Lt(),
2008
+ uid: me(),
2009
+ ...JSON.parse(localStorage.user)
2010
+ };
2011
+ return at(t), t;
2012
+ }
2013
+ const e = {
2014
+ name: "Player",
2015
+ color: Lt(),
2016
+ uid: me()
2017
+ };
2018
+ return at(e), e;
2019
+ }, _n = (e) => (t, r) => ({
2020
+ isSpaceMaster: !1,
2021
+ users: {},
2022
+ getUser: () => r().users[e],
2023
+ getUsers: () => r().users,
2024
+ getUserList: () => Object.values(r().users),
2025
+ getLocalUsers: () => {
2026
+ if (!r().users[e])
2027
+ return [];
2028
+ const { space: n } = r().users[e];
2029
+ return r().getUserList().filter(({ space: o }) => o === n);
2030
+ },
2031
+ addUser: (n) => t((o) => ({ users: { ...o.users, [n.id]: n } })),
2032
+ updateUser: (n, o) => t((s) => {
2033
+ if (!s.users[n])
2034
+ return {};
2035
+ const a = {
2036
+ ...s.users[n],
2037
+ ...o,
2038
+ id: n,
2039
+ uid: s.users[n].uid
2040
+ };
2041
+ return a.id === e && at(a), setTimeout(() => r().electSpaceMaster(), 100), {
2042
+ users: {
2043
+ ...s.users,
2044
+ [n]: a
2045
+ }
2046
+ };
2047
+ }),
2048
+ removeUser: (n) => t((o) => {
2049
+ const s = { ...o.users };
2050
+ return delete s[n], setTimeout(() => r().electSpaceMaster(), 100), { users: s };
2051
+ }),
2052
+ // Not synchronized methods
2053
+ updateCurrentUser: (n) => r().updateUser(e, n),
2054
+ joinSpace: (n) => r().updateUser(e, { space: n, spaceJoinedTimestamp: Date.now() }),
2055
+ electSpaceMaster: () => {
2056
+ const n = r().getLocalUsers(), o = {
2057
+ uid: null,
2058
+ timestamp: Date.now()
2059
+ };
2060
+ Object.values(n).forEach(({ spaceJoinedTimestamp: s, id: a }) => {
2061
+ s < o.timestamp && (o.id = a, o.timestamp = s);
2062
+ }), t({ isSpaceMaster: o.id === e });
2063
+ }
2064
+ }), bn = (e) => ({
2065
+ cursors: {},
2066
+ moveCursor: (t, r) => e((n) => ({ cursors: { ...n.cursors, [t]: r } })),
2067
+ removeCursor: (t) => e((r) => {
2068
+ const n = { ...r.cursors };
2069
+ return delete n[t], { cursors: n };
2070
+ })
2071
+ }), cr = ({ storeName: e, children: t }) => {
2072
+ const { wire: r, isMaster: n } = Be("room"), [o, s] = g.useState(null), [a, u] = g.useState(!1), l = g.useRef(!1);
2073
+ return g.useEffect(() => {
2074
+ let f = !0;
2075
+ const d = [];
2076
+ if (!o && !l.current)
2077
+ return l.current = !0, (() => {
2078
+ const b = Ne(
2079
+ ut(
2080
+ {
2081
+ wire: r,
2082
+ storeName: e,
2083
+ noSync: [
2084
+ "updateCurrentUser",
2085
+ "joinSpace",
2086
+ "isSpaceMaster",
2087
+ "electSpaceMaster"
2088
+ ]
2089
+ },
2090
+ (...w) => ({
2091
+ ..._n(r.userId)(...w),
2092
+ ...bn(...w)
2093
+ })
2094
+ )
2095
+ ), _ = b.subscribe((w) => {
2096
+ w.ready && (_(), f && s(b));
2097
+ });
2098
+ })(), () => {
2099
+ f = !1, l.current = !1, d.forEach((b) => b());
2100
+ };
2101
+ }, [o, e, r, r.userId]), g.useEffect(() => {
2102
+ if (o)
2103
+ return o.getState().addUser({
2104
+ ...Sn(),
2105
+ id: r.userId
2106
+ }), u(!0), () => {
2107
+ o.getState().removeUser(r.userId);
2108
+ };
2109
+ }, [n, o, r]), g.useEffect(() => {
2110
+ if (o) {
2111
+ const f = r.subscribe("userLeave", (d) => {
2112
+ o.getState().removeUser(d);
2113
+ });
2114
+ return () => {
2115
+ f();
2116
+ };
2117
+ }
2118
+ }, [n, o, r]), g.useEffect(() => {
2119
+ n && o && o.getState().updateCurrentUser({ isMaster: n });
2120
+ }, [n, o, r]), a ? /* @__PURE__ */ T(ar.Provider, { value: o, children: t }) : null;
2121
+ }, ge = (e, t) => {
2122
+ const r = be(ar);
2123
+ return Ue(r, e, t || Xe);
2124
+ }, rs = () => {
2125
+ const [e, t, r, n, o] = ge((u) => [
2126
+ u.isSpaceMaster,
2127
+ u.getUser(),
2128
+ u.users,
2129
+ u.updateCurrentUser,
2130
+ u.joinSpace
2131
+ ]), s = g.useMemo(() => Object.values(r), [r]), a = g.useMemo(() => {
2132
+ const { space: u } = t;
2133
+ return s.filter(({ space: l }) => l === u);
2134
+ }, [t, s]);
2135
+ return {
2136
+ isSpaceMaster: e,
2137
+ currentUser: t,
2138
+ updateCurrentUser: n,
2139
+ users: s,
2140
+ localUsers: a,
2141
+ joinSpace: o
2142
+ };
2143
+ }, ns = () => {
2144
+ const [e, t, r] = se(
2145
+ (o) => [o.boardConfig, o.getBoardConfig, o.setBoardConfig]
2146
+ ), n = g.useCallback(
2147
+ (o) => {
2148
+ let s = o;
2149
+ typeof o == "object" && (s = () => o);
2150
+ const a = t(), u = s(a);
2151
+ r(u);
2152
+ },
2153
+ [t, r]
2154
+ );
2155
+ return [e, n];
2156
+ }, os = () => {
2157
+ const [e] = Z((t) => [t.boardState]);
2158
+ return e;
2159
+ }, ss = () => {
2160
+ const [e, t, r, n] = se((o) => [
2161
+ o.getSessionInfo,
2162
+ o.setSessionInfo,
2163
+ o.updateSessionInfo,
2164
+ o.session
2165
+ ]);
2166
+ return { getSessionInfo: e, setSessionInfo: t, sessionInfo: n, updateSessionInfo: r };
2167
+ }, ur = g.createContext(), En = ({ user: { name: e, uid: t, color: r }, content: n }) => ({
2168
+ type: "message",
2169
+ user: { name: e, uid: t, color: r },
2170
+ content: n,
2171
+ uid: me(),
2172
+ timestamp: new Date().toISOString()
2173
+ }), wn = (e, t) => ({
2174
+ messages: [],
2175
+ setMessages: (r) => e({
2176
+ messages: r.map((n) => ({
2177
+ ...n,
2178
+ timestamp: Date.parse(n.timestamp)
2179
+ }))
2180
+ }),
2181
+ addMessage: (r) => e((n) => ({
2182
+ messages: [
2183
+ ...n.messages,
2184
+ { ...r, timestamp: Date.parse(r.timestamp) }
2185
+ ]
2186
+ })),
2187
+ sendMessage: (r, n) => {
2188
+ const o = En({
2189
+ user: r,
2190
+ content: n
2191
+ });
2192
+ o && t().addMessage(o);
2193
+ }
2194
+ }), Xt = ({
2195
+ storeName: e,
2196
+ children: t,
2197
+ defaultValue: r = []
2198
+ }) => {
2199
+ const { wire: n } = Be("room"), [o] = g.useState(
2200
+ () => Ne(
2201
+ ut(
2202
+ { wire: n, storeName: e, defaultValue: r, noSync: ["sendMessage"] },
2203
+ (...s) => ({
2204
+ ...wn(...s)
2205
+ })
2206
+ )
2207
+ )
2208
+ );
2209
+ return /* @__PURE__ */ T(ur.Provider, { value: o, children: t });
2210
+ }, Cn = (e, t) => {
2211
+ const r = be(ur);
2212
+ return Ue(r, e, t || Xe);
2213
+ }, xn = () => {
2214
+ }, is = (e = xn) => {
2215
+ const t = ge((a) => a.getUser()), [r, n, o] = Cn((a) => [
2216
+ a.messages,
2217
+ a.setMessages,
2218
+ a.sendMessage
2219
+ ]);
2220
+ g.useEffect(() => {
2221
+ r.length && e();
2222
+ }, [r, e]);
2223
+ const s = g.useCallback(
2224
+ (a) => {
2225
+ o(t, a);
2226
+ },
2227
+ [t, o]
2228
+ );
2229
+ return { messages: r, setMessages: n, sendMessage: s };
2230
+ }, Wt = ({ children: e, session: t }) => {
2231
+ const r = ge((n) => n.joinSpace);
2232
+ return g.useEffect(() => (r(t), () => {
2233
+ r(null);
2234
+ }), [r, t]), e;
2235
+ }, as = ({
2236
+ socket: e,
2237
+ room: t,
2238
+ session: r,
2239
+ items: n = [],
2240
+ messages: o = [],
2241
+ LoadingComponent: s,
2242
+ ...a
2243
+ }) => {
2244
+ const [u] = g.useState(t || me()), [l] = g.useState(r || me()), [f] = g.useState(() => ({
2245
+ itemIds: n.map(({ id: c }) => c),
2246
+ items: Object.fromEntries(n.map((c) => [c.id, c]))
2247
+ }));
2248
+ return Be("room") ? /* @__PURE__ */ T(
2249
+ Xt,
2250
+ {
2251
+ storeName: `${l}_messages`,
2252
+ defaultValue: o,
2253
+ children: /* @__PURE__ */ T(Bt, { children: /* @__PURE__ */ T(
2254
+ Yt,
2255
+ {
2256
+ storeName: `${l}_item`,
2257
+ defaultValue: f,
2258
+ children: /* @__PURE__ */ T(Wt, { ...a, session: l })
2259
+ }
2260
+ ) })
2261
+ }
2262
+ ) : /* @__PURE__ */ T(
2263
+ er,
2264
+ {
2265
+ room: u,
2266
+ channel: "room",
2267
+ socket: e,
2268
+ LoadingComponent: s,
2269
+ children: /* @__PURE__ */ T(cr, { storeName: `${u}_users`, children: /* @__PURE__ */ T(
2270
+ Xt,
2271
+ {
2272
+ storeName: `${l}_messages`,
2273
+ defaultValue: o,
2274
+ children: /* @__PURE__ */ T(Bt, { children: /* @__PURE__ */ T(
2275
+ Yt,
2276
+ {
2277
+ storeName: `${l}_item`,
2278
+ defaultValue: f,
2279
+ children: /* @__PURE__ */ T(Wt, { ...a, session: l })
2280
+ }
2281
+ ) })
2282
+ }
2283
+ ) })
2284
+ }
2285
+ );
2286
+ }, cs = ({ socket: e, room: t, children: r, LoadingComponent: n }) => {
2287
+ const [o] = g.useState(t || me());
2288
+ return /* @__PURE__ */ T(
2289
+ er,
2290
+ {
2291
+ room: o,
2292
+ channel: "room",
2293
+ socket: e,
2294
+ LoadingComponent: n,
2295
+ children: /* @__PURE__ */ T(cr, { storeName: `${o}_users`, children: r })
2296
+ }
2297
+ );
2298
+ }, tt = () => {
2299
+ const e = navigator.userAgent.toLowerCase();
2300
+ return /mac os ?x 10/.test(e);
2301
+ }, Rn = () => {
2302
+ const e = document.createElement("iframe");
2303
+ e.src = "#", document.body.appendChild(e);
2304
+ const t = e.contentWindow.document;
2305
+ t.open(), t.write(
2306
+ "<!DOCTYPE html><html><head></head><body><span>a</span></body></html>"
2307
+ ), t.close();
2308
+ const r = t.body.firstElementChild.offsetHeight;
2309
+ return document.body.removeChild(e), r;
2310
+ }, In = Rn(), On = 800, Vt = (e, t) => {
2311
+ const r = Object.keys(e).map((n) => Number(n)).find((n) => n !== t);
2312
+ return e[r];
2313
+ }, Ft = ([e, t], [r, n]) => {
2314
+ const o = Math.abs(e - r), s = Math.abs(t - n);
2315
+ return Math.hypot(o, s);
2316
+ }, de = () => {
2317
+ }, Tn = (e) => (t) => {
2318
+ const { event: r } = t;
2319
+ return r.isPropagationStopped() ? null : e(t);
2320
+ }, kn = (e) => async (...t) => {
2321
+ try {
2322
+ await e(...t);
2323
+ } catch (r) {
2324
+ console.error(r);
2325
+ }
2326
+ };
2327
+ class Pn {
2328
+ constructor() {
2329
+ Ot(this, "lastPromise", Promise.resolve(!0));
2330
+ }
2331
+ add(t, ...r) {
2332
+ return new Promise((n, o) => {
2333
+ this.lastPromise = this.lastPromise.then(() => Tn(kn(t))(...r)).then(n).catch(o);
2334
+ });
2335
+ }
2336
+ }
2337
+ const ie = new Pn(), We = ({
2338
+ children: e,
2339
+ onDrag: t = de,
2340
+ onDragStart: r = de,
2341
+ onDragEnd: n = de,
2342
+ onPan: o = de,
2343
+ onTap: s = de,
2344
+ onLongTap: a = de,
2345
+ onDoubleTap: u = de,
2346
+ onZoom: l,
2347
+ mainAction: f = "drag"
2348
+ }) => {
2349
+ const d = g.useRef(null), c = g.useRef({
2350
+ moving: !1,
2351
+ pointers: {},
2352
+ mainPointer: void 0
2353
+ }), b = (R) => {
2354
+ const {
2355
+ deltaX: x,
2356
+ deltaY: y,
2357
+ clientX: p,
2358
+ clientY: h,
2359
+ deltaMode: v,
2360
+ ctrlKey: C,
2361
+ altKey: D,
2362
+ metaKey: k,
2363
+ target: P
2364
+ } = R;
2365
+ if (!(D || C && !tt()))
2366
+ if (tt() && !C)
2367
+ ie.add(o, {
2368
+ deltaX: -2 * x,
2369
+ deltaY: -2 * y,
2370
+ button: 1,
2371
+ ctrlKey: C,
2372
+ metaKey: k,
2373
+ target: P,
2374
+ event: R
2375
+ });
2376
+ else {
2377
+ if (l === void 0 || !y)
2378
+ return;
2379
+ let M = y;
2380
+ switch (v) {
2381
+ case 1:
2382
+ M *= In;
2383
+ break;
2384
+ case 2:
2385
+ M *= On;
2386
+ break;
2387
+ }
2388
+ tt() && (M *= 2), ie.add(l, { scale: M, clientX: p, clientY: h, event: R });
2389
+ }
2390
+ }, _ = (R) => {
2391
+ const {
2392
+ target: x,
2393
+ button: y,
2394
+ clientX: p,
2395
+ clientY: h,
2396
+ pointerId: v,
2397
+ altKey: C,
2398
+ ctrlKey: D,
2399
+ metaKey: k,
2400
+ isPrimary: P
2401
+ } = R;
2402
+ if (c.current.pointers[v] = { clientX: p, clientY: h }, P && (c.current.mainPointer = void 0), c.current.mainPointer !== void 0) {
2403
+ if (c.current.mainPointer !== v)
2404
+ try {
2405
+ const { clientX: M, clientY: N } = Vt(
2406
+ c.current.pointers,
2407
+ v
2408
+ ), F = (M + p) / 2, K = (N + h) / 2, O = Ft(
2409
+ [M, N],
2410
+ [p, h]
2411
+ );
2412
+ Object.assign(c.current, {
2413
+ pressed: !0,
2414
+ moving: !1,
2415
+ gestureStart: !1,
2416
+ startX: p,
2417
+ startY: h,
2418
+ prevX: F,
2419
+ prevY: K,
2420
+ startDistance: O,
2421
+ prevDistance: O
2422
+ });
2423
+ } catch (M) {
2424
+ console.log("Error while getting other pointer. Ignoring", M), c.current.mainPointer;
2425
+ }
2426
+ return;
2427
+ }
2428
+ c.current.mainPointer = v, Object.assign(c.current, {
2429
+ pressed: !0,
2430
+ moving: !1,
2431
+ gestureStart: !1,
2432
+ startX: p,
2433
+ startY: h,
2434
+ prevX: p,
2435
+ prevY: h,
2436
+ currentButton: y,
2437
+ pointerDownEvent: R,
2438
+ target: x,
2439
+ timeStart: Date.now(),
2440
+ longTapTimeout: setTimeout(async () => {
2441
+ c.current.noTap = !0, ie.add(a, {
2442
+ clientX: p,
2443
+ clientY: h,
2444
+ altKey: C,
2445
+ ctrlKey: D,
2446
+ metaKey: k,
2447
+ target: x,
2448
+ event: R
2449
+ });
2450
+ }, 750)
2451
+ });
2452
+ try {
2453
+ x.setPointerCapture(v);
2454
+ } catch (M) {
2455
+ console.log("Fail to capture pointer", M);
2456
+ }
2457
+ }, w = (R) => {
2458
+ if (c.current.pressed) {
2459
+ const {
2460
+ pointerId: x,
2461
+ clientX: y,
2462
+ clientY: p,
2463
+ altKey: h,
2464
+ ctrlKey: v,
2465
+ metaKey: C,
2466
+ buttons: D,
2467
+ pointerType: k
2468
+ } = R;
2469
+ c.current.pointers[x] = {
2470
+ clientX: y,
2471
+ clientY: p
2472
+ }, c.current.moving = !0;
2473
+ const P = Object.keys(c.current.pointers).length === 2;
2474
+ let M, N, F;
2475
+ if (P) {
2476
+ const { clientX: A, clientY: U } = Vt(
2477
+ c.current.pointers,
2478
+ x
2479
+ );
2480
+ M = (A + y) / 2, N = (U + p) / 2, F = Ft(
2481
+ [A, U],
2482
+ [y, p]
2483
+ );
2484
+ } else
2485
+ M = y, N = p;
2486
+ let K = h || v || C || D !== 1;
2487
+ f !== "drag" && (K = !K);
2488
+ const O = k !== "touch" ? !K : !P, $ = k !== "touch" ? K : P;
2489
+ if (O) {
2490
+ c.current.gestureStart || (d.current.style.cursor = "move", c.current.gestureStart = !0, clearTimeout(c.current.longTapTimeout), ie.add(r, {
2491
+ deltaX: 0,
2492
+ deltaY: 0,
2493
+ startX: c.current.startX,
2494
+ startY: c.current.startY,
2495
+ clientX: c.current.startX,
2496
+ clientY: c.current.startY,
2497
+ distanceX: 0,
2498
+ distanceY: 0,
2499
+ button: c.current.currentButton,
2500
+ altKey: h,
2501
+ ctrlKey: v,
2502
+ metaKey: C,
2503
+ target: c.current.target,
2504
+ event: c.current.pointerDownEvent
2505
+ }));
2506
+ const A = M - c.current.prevX, U = N - c.current.prevY, Y = M - c.current.startX, W = N - c.current.startY;
2507
+ ie.add(t, {
2508
+ deltaX: A,
2509
+ deltaY: U,
2510
+ startX: c.current.startX,
2511
+ startY: c.current.startY,
2512
+ clientX: M,
2513
+ clientY: N,
2514
+ distanceX: Y,
2515
+ distanceY: W,
2516
+ button: c.current.currentButton,
2517
+ altKey: h,
2518
+ ctrlKey: v,
2519
+ metaKey: C,
2520
+ target: c.current.target,
2521
+ event: R
2522
+ });
2523
+ }
2524
+ if ($) {
2525
+ c.current.gestureStart || (d.current.style.cursor = "move", c.current.gestureStart = !0, clearTimeout(c.current.longTapTimeout));
2526
+ const A = M - c.current.prevX, U = N - c.current.prevY, { target: Y } = c.current;
2527
+ if (ie.add(o, {
2528
+ deltaX: A,
2529
+ deltaY: U,
2530
+ button: c.current.currentButton,
2531
+ altKey: h,
2532
+ ctrlKey: v,
2533
+ metaKey: C,
2534
+ target: Y,
2535
+ event: R
2536
+ }), F !== c.current.prevDistance && l) {
2537
+ const W = c.current.prevDistance - F;
2538
+ Math.abs(W) > 0 && (ie.add(l, {
2539
+ scale: W * 3,
2540
+ clientX: M,
2541
+ clientY: N,
2542
+ event: R
2543
+ }), c.current.prevDistance = F);
2544
+ }
2545
+ }
2546
+ c.current.prevX = M, c.current.prevY = N;
2547
+ }
2548
+ }, m = (R) => {
2549
+ const { clientX: x, clientY: y, altKey: p, ctrlKey: h, metaKey: v, target: C, pointerId: D } = R;
2550
+ if (c.current.pointers[D] && (delete c.current.pointers[D], c.current.mainPointer === D)) {
2551
+ for (; Object.keys(c.current.pointers).length > 0; ) {
2552
+ c.current.mainPointer = Number(
2553
+ Object.keys(c.current.pointers)[0]
2554
+ );
2555
+ try {
2556
+ c.current.target.setPointerCapture(c.current.mainPointer);
2557
+ return;
2558
+ } catch (k) {
2559
+ console.log("Fails to set pointer capture", k), c.current.mainPointer = void 0, delete c.current.pointers[Object.keys(c.current.pointers)[0]];
2560
+ }
2561
+ }
2562
+ if (c.current.mainPointer = void 0, c.current.pressed = !1, clearTimeout(c.current.longTapTimeout), c.current.moving)
2563
+ c.current.moving = !1, ie.add(n, {
2564
+ deltaX: x - c.current.prevX,
2565
+ deltaY: y - c.current.prevY,
2566
+ startX: c.current.startX,
2567
+ startY: c.current.startY,
2568
+ clientX: x,
2569
+ clientY: y,
2570
+ distanceX: x - c.current.startX,
2571
+ distanceY: y - c.current.startY,
2572
+ button: c.current.currentButton,
2573
+ altKey: p,
2574
+ ctrlKey: h,
2575
+ metaKey: v,
2576
+ event: R
2577
+ }), d.current.style.cursor = "auto";
2578
+ else {
2579
+ const k = Date.now();
2580
+ c.current.noTap ? c.current.noTap = !1 : c.current.timeStart - k < 300 && ie.add(s, {
2581
+ clientX: x,
2582
+ clientY: y,
2583
+ altKey: p,
2584
+ ctrlKey: h,
2585
+ metaKey: v,
2586
+ target: C,
2587
+ event: R
2588
+ });
2589
+ }
2590
+ }
2591
+ };
2592
+ return /* @__PURE__ */ T(
2593
+ "div",
2594
+ {
2595
+ onWheel: b,
2596
+ onPointerDown: _,
2597
+ onPointerMove: w,
2598
+ onPointerUp: m,
2599
+ onPointerOut: m,
2600
+ onPointerLeave: m,
2601
+ onPointerCancel: m,
2602
+ onDoubleClick: (R) => {
2603
+ const { clientX: x, clientY: y, altKey: p, ctrlKey: h, metaKey: v, target: C } = R;
2604
+ ie.add(u, {
2605
+ clientX: x,
2606
+ clientY: y,
2607
+ altKey: p,
2608
+ ctrlKey: h,
2609
+ metaKey: v,
2610
+ target: C,
2611
+ event: R
2612
+ });
2613
+ },
2614
+ style: { touchAction: "none" },
2615
+ ref: d,
2616
+ children: e
2617
+ }
2618
+ );
2619
+ }, rt = ({ onResize: e, ...t }) => {
2620
+ const [r] = Z((o) => [o.getBoardState]);
2621
+ return /* @__PURE__ */ T(We, { onDrag: ({ deltaX: o, deltaY: s, event: a }) => {
2622
+ a.stopPropagation();
2623
+ const { scale: u } = r();
2624
+ e({
2625
+ width: o / u,
2626
+ height: s / u
2627
+ });
2628
+ }, children: /* @__PURE__ */ T("div", { ...t }) });
2629
+ };
2630
+ let Mn = { data: "" }, jn = (e) => typeof window == "object" ? ((e ? e.querySelector("#_goober") : window._goober) || Object.assign((e || document.head).appendChild(document.createElement("style")), { innerHTML: " ", id: "_goober" })).firstChild : e || Mn, Dn = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g, $n = /\/\*[^]*?\*\/| +/g, Kt = /\n+/g, fe = (e, t) => {
2631
+ let r = "", n = "", o = "";
2632
+ for (let s in e) {
2633
+ let a = e[s];
2634
+ s[0] == "@" ? s[1] == "i" ? r = s + " " + a + ";" : n += s[1] == "f" ? fe(a, s) : s + "{" + fe(a, s[1] == "k" ? "" : t) + "}" : typeof a == "object" ? n += fe(a, t ? t.replace(/([^,])+/g, (u) => s.replace(/(^:.*)|([^,])+/g, (l) => /&/.test(l) ? l.replace(/&/g, u) : u ? u + " " + l : l)) : s) : a != null && (s = /^--/.test(s) ? s : s.replace(/[A-Z]/g, "-$&").toLowerCase(), o += fe.p ? fe.p(s, a) : s + ":" + a + ";");
2635
+ }
2636
+ return r + (t && o ? t + "{" + o + "}" : o) + n;
2637
+ }, ce = {}, lr = (e) => {
2638
+ if (typeof e == "object") {
2639
+ let t = "";
2640
+ for (let r in e)
2641
+ t += r + lr(e[r]);
2642
+ return t;
2643
+ }
2644
+ return e;
2645
+ }, An = (e, t, r, n, o) => {
2646
+ let s = lr(e), a = ce[s] || (ce[s] = ((l) => {
2647
+ let f = 0, d = 11;
2648
+ for (; f < l.length; )
2649
+ d = 101 * d + l.charCodeAt(f++) >>> 0;
2650
+ return "go" + d;
2651
+ })(s));
2652
+ if (!ce[a]) {
2653
+ let l = s !== e ? e : ((f) => {
2654
+ let d, c, b = [{}];
2655
+ for (; d = Dn.exec(f.replace($n, "")); )
2656
+ d[4] ? b.shift() : d[3] ? (c = d[3].replace(Kt, " ").trim(), b.unshift(b[0][c] = b[0][c] || {})) : b[0][d[1]] = d[2].replace(Kt, " ").trim();
2657
+ return b[0];
2658
+ })(e);
2659
+ ce[a] = fe(o ? { ["@keyframes " + a]: l } : l, r ? "" : "." + a);
2660
+ }
2661
+ let u = r && ce.g ? ce.g : null;
2662
+ return r && (ce.g = ce[a]), ((l, f, d, c) => {
2663
+ c ? f.data = f.data.replace(c, l) : f.data.indexOf(l) === -1 && (f.data = d ? l + f.data : f.data + l);
2664
+ })(ce[a], t, n, u), a;
2665
+ }, zn = (e, t, r) => e.reduce((n, o, s) => {
2666
+ let a = t[s];
2667
+ if (a && a.call) {
2668
+ let u = a(r), l = u && u.props && u.props.className || /^go/.test(u) && u;
2669
+ a = l ? "." + l : u && typeof u == "object" ? u.props ? "" : fe(u, "") : u === !1 ? "" : u;
2670
+ }
2671
+ return n + o + (a ?? "");
2672
+ }, "");
2673
+ function H(e) {
2674
+ let t = this || {}, r = e.call ? e(t.p) : e;
2675
+ return An(r.unshift ? r.raw ? zn(r, [].slice.call(arguments, 1), t.p) : r.reduce((n, o) => Object.assign(n, o && o.call ? o(t.p) : o), {}) : r, jn(t.target), t.g, t.o, t.k);
2676
+ }
2677
+ H.bind({ g: 1 });
2678
+ H.bind({ k: 1 });
2679
+ function Ln(e, t, r, n) {
2680
+ fe.p = t;
2681
+ }
2682
+ var Yn = function e(t, r) {
2683
+ if (t === r)
2684
+ return !0;
2685
+ if (t && r && typeof t == "object" && typeof r == "object") {
2686
+ if (t.constructor !== r.constructor)
2687
+ return !1;
2688
+ var n, o, s;
2689
+ if (Array.isArray(t)) {
2690
+ if (n = t.length, n != r.length)
2691
+ return !1;
2692
+ for (o = n; o-- !== 0; )
2693
+ if (!e(t[o], r[o]))
2694
+ return !1;
2695
+ return !0;
2696
+ }
2697
+ if (t.constructor === RegExp)
2698
+ return t.source === r.source && t.flags === r.flags;
2699
+ if (t.valueOf !== Object.prototype.valueOf)
2700
+ return t.valueOf() === r.valueOf();
2701
+ if (t.toString !== Object.prototype.toString)
2702
+ return t.toString() === r.toString();
2703
+ if (s = Object.keys(t), n = s.length, n !== Object.keys(r).length)
2704
+ return !1;
2705
+ for (o = n; o-- !== 0; )
2706
+ if (!Object.prototype.hasOwnProperty.call(r, s[o]))
2707
+ return !1;
2708
+ for (o = n; o-- !== 0; ) {
2709
+ var a = s[o];
2710
+ if (!e(t[a], r[a]))
2711
+ return !1;
2712
+ }
2713
+ return !0;
2714
+ }
2715
+ return t !== t && r !== r;
2716
+ };
2717
+ const Bn = H`
2718
+ display: inline-block;
2719
+ transition: transform 150ms;
2720
+ user-select: none;
2721
+ padding: 2px;
2722
+ box-sizing: border-box;
2723
+ `, Nn = H`
2724
+ border: 2px dashed #db5034;
2725
+ padding: 0px;
2726
+ cursor: pointer;
2727
+ `, xe = H`
2728
+ position: absolute;
2729
+ width: 0px;
2730
+ height: 0px;
2731
+ `, Un = H`
2732
+ top: 0;
2733
+ left: 0;
2734
+ `, Xn = H`
2735
+ top: 0;
2736
+ right: 0;
2737
+ `, Wn = H`
2738
+ bottom: 0;
2739
+ left: 0;
2740
+ `, Vn = H`
2741
+ bottom: 0;
2742
+ right: 0;
2743
+ `, Fn = H`
2744
+ top: 50%;
2745
+ left: 50%;
2746
+ `, nt = H`
2747
+ position: absolute;
2748
+
2749
+ width: 10px;
2750
+ height: 10px;
2751
+ border: 2px solid #db5034;
2752
+ background-color: #db5034;
2753
+ cursor: move;
2754
+ `, Kn = H`
2755
+ cursor: ew-resize;
2756
+ right: -6px;
2757
+ top: calc(50% - 5px);
2758
+ `, Hn = H`
2759
+ cursor: ns-resize;
2760
+ bottom: -6px;
2761
+ left: calc(50% - 5px);
2762
+ `, qn = H`
2763
+ cursor: nwse-resize;
2764
+ bottom: -6px;
2765
+ right: -6px;
2766
+ `, Gn = ({ onReload: e }) => /* @__PURE__ */ ue(
2767
+ "div",
2768
+ {
2769
+ className: `syncboard-error-item ${H({
2770
+ width: "100px",
2771
+ display: "flex",
2772
+ flexDirection: "column",
2773
+ justifyContent: "center",
2774
+ textAlign: "center",
2775
+ color: "red"
2776
+ })}`,
2777
+ children: [
2778
+ "Sorry, this item seems broken.",
2779
+ /* @__PURE__ */ T("button", { onClick: e, children: "Reload it" })
2780
+ ]
2781
+ }
2782
+ );
2783
+ class Jn extends g.Component {
2784
+ constructor(t) {
2785
+ super(t), this.state = { hasError: !1, itemId: t.itemId }, this.onReload = this.onReload.bind(this);
2786
+ }
2787
+ static getDerivedStateFromError() {
2788
+ return { hasError: !0 };
2789
+ }
2790
+ componentDidCatch(t) {
2791
+ console.error(
2792
+ `Error for item ${this.state.itemId}`,
2793
+ t,
2794
+ this.props.state
2795
+ );
2796
+ }
2797
+ onReload() {
2798
+ this.setState({ hasError: !1 });
2799
+ }
2800
+ render() {
2801
+ const { ErrorComponent: t } = this.props;
2802
+ return this.state.hasError ? /* @__PURE__ */ T(t, { onReload: this.onReload }) : this.props.children;
2803
+ }
2804
+ }
2805
+ const Zn = (e) => {
2806
+ e.target.className = "";
2807
+ }, Qn = ({
2808
+ width: e,
2809
+ height: t,
2810
+ actualWidth: r,
2811
+ actualHeight: n,
2812
+ prevState: o,
2813
+ keepRatio: s
2814
+ }) => {
2815
+ let { width: a, height: u } = o;
2816
+ if ([a, u] = [
2817
+ parseFloat(a),
2818
+ parseFloat(u)
2819
+ ], (!a || Number.isNaN(Number(a))) && (a = r), (!u || Number.isNaN(Number(u))) && (u = n), s) {
2820
+ const l = a / u;
2821
+ return {
2822
+ ...o,
2823
+ width: (a + e).toFixed(1),
2824
+ height: (u + t / l).toFixed(1)
2825
+ };
2826
+ }
2827
+ return {
2828
+ ...o,
2829
+ width: (a + e).toFixed(1),
2830
+ height: (u + t).toFixed(1)
2831
+ };
2832
+ }, eo = {
2833
+ w: !0,
2834
+ h: !0,
2835
+ b: !0
2836
+ }, to = ({
2837
+ setState: e,
2838
+ state: { type: t, rotation: r = 0, id: n, locked: o, extraClasses: s, ...a } = {},
2839
+ animate: u = "hvr-pop",
2840
+ isSelected: l,
2841
+ itemMap: f,
2842
+ showResizeHandle: d = !0
2843
+ }) => {
2844
+ var v;
2845
+ const c = g.useRef(null), {
2846
+ component: b = () => null,
2847
+ resizeDirections: _ = eo,
2848
+ resize: w = Qn
2849
+ } = f[t], m = g.useCallback(
2850
+ (C) => e(n, C),
2851
+ [e, n]
2852
+ );
2853
+ g.useEffect(() => {
2854
+ c.current.className = u;
2855
+ }, [u]);
2856
+ const E = ["item", n, Bn];
2857
+ o && E.push("locked"), l && (E.push("selected"), E.push(Nn));
2858
+ const R = E.join(" "), x = ({ width: C = 0, height: D = 0, keepRatio: k }) => {
2859
+ m((P) => {
2860
+ const { offsetWidth: M, offsetHeight: N } = c.current;
2861
+ return w({
2862
+ prevState: P,
2863
+ width: C,
2864
+ height: D,
2865
+ actualHeight: N,
2866
+ actualWidth: M,
2867
+ keepRatio: k
2868
+ });
2869
+ });
2870
+ }, y = ({ width: C }) => {
2871
+ x({ width: C });
2872
+ }, p = ({ height: C }) => {
2873
+ x({ height: C });
2874
+ }, h = ({ width: C }) => {
2875
+ x({ height: C, width: C, keepRatio: !0 });
2876
+ };
2877
+ return /* @__PURE__ */ T(
2878
+ "div",
2879
+ {
2880
+ style: { transform: `rotate(${r}deg` },
2881
+ "data-id": n,
2882
+ className: R,
2883
+ children: /* @__PURE__ */ ue(
2884
+ "div",
2885
+ {
2886
+ style: { display: "flex" },
2887
+ ref: c,
2888
+ onAnimationEnd: Zn,
2889
+ onKeyDown: (C) => C.stopPropagation(),
2890
+ onKeyUp: (C) => C.stopPropagation(),
2891
+ children: [
2892
+ /* @__PURE__ */ T(
2893
+ Jn,
2894
+ {
2895
+ itemId: n,
2896
+ state: a,
2897
+ ErrorComponent: ((v = f == null ? void 0 : f.error) == null ? void 0 : v.component) || Gn,
2898
+ children: /* @__PURE__ */ T(b, { ...a, id: n, setState: m })
2899
+ }
2900
+ ),
2901
+ /* @__PURE__ */ T("div", { className: `corner ${xe} ${Un}` }),
2902
+ /* @__PURE__ */ T("div", { className: `corner ${xe} ${Xn}` }),
2903
+ /* @__PURE__ */ T("div", { className: `corner ${xe} ${Vn}` }),
2904
+ /* @__PURE__ */ T("div", { className: `corner ${xe} ${Wn}` }),
2905
+ /* @__PURE__ */ T("div", { className: `${xe} ${Fn}` }),
2906
+ d && /* @__PURE__ */ ue(Qt, { children: [
2907
+ _.b && /* @__PURE__ */ T(
2908
+ rt,
2909
+ {
2910
+ className: `${nt} ${qn}`,
2911
+ onResize: h
2912
+ }
2913
+ ),
2914
+ _.h && /* @__PURE__ */ T(
2915
+ rt,
2916
+ {
2917
+ className: `${nt} ${Hn}`,
2918
+ onResize: p
2919
+ }
2920
+ ),
2921
+ _.w && /* @__PURE__ */ T(
2922
+ rt,
2923
+ {
2924
+ className: `${nt} ${Kn}`,
2925
+ onResize: y
2926
+ }
2927
+ )
2928
+ ] })
2929
+ ]
2930
+ }
2931
+ )
2932
+ }
2933
+ );
2934
+ }, ro = Zt(
2935
+ to,
2936
+ ({
2937
+ state: e,
2938
+ setState: t,
2939
+ isSelected: r,
2940
+ showResizeHandle: n
2941
+ }, {
2942
+ state: o,
2943
+ setState: s,
2944
+ isSelected: a,
2945
+ showResizeHandle: u
2946
+ }) => r === a && n === u && t === s && Yn(e, o)
2947
+ ), no = (e) => e, oo = ({ state: e = {}, getCurrentUser: t, className: r, ...n }) => {
2948
+ if (!n.itemMap[e.type])
2949
+ return null;
2950
+ const { stateHook: o = no } = n.itemMap[e.type], {
2951
+ x: s = 0,
2952
+ y: a = 0,
2953
+ layer: u = 0,
2954
+ moving: l,
2955
+ ...f
2956
+ } = o(e, { getCurrentUser: t }), d = (u + 4) * 10 + 100 + (l ? 5 : 0);
2957
+ return /* @__PURE__ */ T(
2958
+ "div",
2959
+ {
2960
+ className: r,
2961
+ style: {
2962
+ transform: `translate(${s}px, ${a}px)`,
2963
+ zIndex: d
2964
+ },
2965
+ children: /* @__PURE__ */ T(
2966
+ ro,
2967
+ {
2968
+ ...n,
2969
+ showResizeHandle: n.isSelected && n.showResizeHandle,
2970
+ state: f
2971
+ }
2972
+ )
2973
+ }
2974
+ );
2975
+ }, so = Zt(oo), io = () => {
2976
+ const { updateItem: e } = pt(), [t, r] = se((f) => [
2977
+ f.itemIds,
2978
+ f.items
2979
+ ]), [n, o, s, a] = Z(
2980
+ (f) => [
2981
+ f.config.boardSize,
2982
+ f.config.showResizeHandle,
2983
+ f.config.itemTemplates,
2984
+ f.selection
2985
+ ]
2986
+ ), [u] = ge((f) => [f.getUser]), l = H({
2987
+ position: "absolute",
2988
+ top: `${n / 2}px`,
2989
+ left: `${n / 2}px`,
2990
+ display: "inline-block"
2991
+ });
2992
+ return t.map((f) => /* @__PURE__ */ T(
2993
+ so,
2994
+ {
2995
+ state: r[f],
2996
+ setState: e,
2997
+ isSelected: a.includes(f),
2998
+ itemMap: s,
2999
+ boardSize: n,
3000
+ getCurrentUser: u,
3001
+ showResizeHandle: o,
3002
+ className: l
3003
+ },
3004
+ f
3005
+ ));
3006
+ }, ao = H({
3007
+ zIndex: 210,
3008
+ position: "absolute",
3009
+ backgroundColor: "hsla(0, 40%, 50%, 10%)",
3010
+ border: "2px solid hsl(0, 55%, 40%)"
3011
+ }), co = (e, t) => {
3012
+ const r = t.getElementsByClassName("selector");
3013
+ if (!r.length)
3014
+ return [];
3015
+ const n = r[0];
3016
+ return Array.from(t.getElementsByClassName("item")).filter((o) => {
3017
+ const s = ke(o), a = e[s];
3018
+ return !a || a.locked ? !1 : en(o, n);
3019
+ }).map((o) => ke(o));
3020
+ }, uo = ({ children: e, moveFirst: t }) => {
3021
+ const [
3022
+ r,
3023
+ n,
3024
+ o,
3025
+ s,
3026
+ a,
3027
+ u,
3028
+ l
3029
+ ] = Z((h) => [
3030
+ h.getSelection,
3031
+ h.clear,
3032
+ h.setSelection,
3033
+ h.select,
3034
+ h.getConfiguration,
3035
+ h.getBoardState,
3036
+ h.updateBoardState
3037
+ ]), { findElementUnderPointer: f } = pt(), [d] = se((h) => [h.getItems]), [c, b] = g.useState({}), [, _] = g.useTransition(), w = g.useRef(null), m = g.useRef({
3038
+ moving: !1
3039
+ });
3040
+ return g.useEffect(() => (n(), () => {
3041
+ n();
3042
+ }), [n]), g.useEffect(() => {
3043
+ if (m.current.moving) {
3044
+ const h = d(), { boardWrapper: v } = a(), C = co(h, v);
3045
+ _(() => {
3046
+ o(C);
3047
+ });
3048
+ }
3049
+ }, [a, d, c, o]), /* @__PURE__ */ T(
3050
+ We,
3051
+ {
3052
+ onDragStart: async (h) => {
3053
+ await f(h) || (m.current.moving = !0, _(() => {
3054
+ l({ selecting: !0 });
3055
+ }), w.current.style.cursor = "crosshair");
3056
+ },
3057
+ onDrag: ({ distanceY: h, distanceX: v, startX: C, startY: D }) => {
3058
+ if (m.current.moving) {
3059
+ const { top: k, left: P } = w.current.getBoundingClientRect(), { scale: M } = u(), N = (C - P) / M, F = (D - k) / M, K = v / M, O = h / M;
3060
+ K > 0 ? (m.current.left = N, m.current.width = K) : (m.current.left = N + K, m.current.width = -K), O > 0 ? (m.current.top = F, m.current.height = O) : (m.current.top = F + O, m.current.height = -O), b({ ...m.current, moving: !0 });
3061
+ }
3062
+ },
3063
+ onDragEnd: () => {
3064
+ m.current.moving && (_(() => {
3065
+ l({ selecting: !1 });
3066
+ }), m.current.moving = !1, b({ moving: !1 }), w.current.style.cursor = "auto");
3067
+ },
3068
+ onTap: (h) => {
3069
+ const { target: v, ctrlKey: C, metaKey: D } = h, k = f(h);
3070
+ if (!k && Te(v, "board"))
3071
+ n();
3072
+ else {
3073
+ const P = ke(k);
3074
+ if (!P) {
3075
+ n();
3076
+ return;
3077
+ }
3078
+ const M = r();
3079
+ k && !M.includes(P) && (C || D ? s([P]) : o([P]));
3080
+ }
3081
+ },
3082
+ onLongTap: ({ target: h }) => {
3083
+ const v = Te(h, "item");
3084
+ if (v) {
3085
+ const C = ke(v);
3086
+ o([C]);
3087
+ }
3088
+ },
3089
+ mainAction: t ? "pan" : "drag",
3090
+ children: /* @__PURE__ */ ue("div", { ref: w, children: [
3091
+ c.moving && /* @__PURE__ */ T(
3092
+ "div",
3093
+ {
3094
+ style: {
3095
+ transform: `translate(${c.left}px, ${c.top}px)`,
3096
+ height: `${c.height}px`,
3097
+ width: `${c.width}px`
3098
+ },
3099
+ className: `selector ${ao}`
3100
+ }
3101
+ ),
3102
+ e
3103
+ ] })
3104
+ }
3105
+ );
3106
+ };
3107
+ function lo(e = !1) {
3108
+ const t = Ie(e), r = Jt(() => t.current, []);
3109
+ return Me(() => (t.current = !0, () => {
3110
+ t.current = !1;
3111
+ }), []), r;
3112
+ }
3113
+ function fo(e, ...t) {
3114
+ e && e.addEventListener && e.addEventListener(...t);
3115
+ }
3116
+ function po(e, ...t) {
3117
+ e && e.removeEventListener && e.removeEventListener(...t);
3118
+ }
3119
+ const mo = (e, t) => Object.prototype.hasOwnProperty.call(e, t);
3120
+ function pe(e, ...t) {
3121
+ const r = lo(), n = lt(t[1]), o = ct(
3122
+ () => (
3123
+ // as some event listeners designed to be used through `this`
3124
+ // it is better to make listener a conventional function as it
3125
+ // infers call context
3126
+ // eslint-disable-next-line func-names
3127
+ function(...s) {
3128
+ r() && (typeof n.current == "function" ? n.current.apply(this, s) : typeof n.current.handleEvent == "function" && n.current.handleEvent.apply(this, s));
3129
+ }
3130
+ ),
3131
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3132
+ []
3133
+ );
3134
+ Me(() => {
3135
+ const s = e && mo(e, "current") ? e.current : e;
3136
+ if (!s)
3137
+ return;
3138
+ const a = t.slice(2);
3139
+ return fo(s, t[0], o, ...a), () => po(s, t[0], o, ...a);
3140
+ }, [e, t[0]]);
3141
+ }
3142
+ const go = ({ children: e }) => {
3143
+ const { moveItems: t, placeItems: r, findElementUnderPointer: n } = pt(), [o, s, a, u, l] = Z((E) => [
3144
+ E.select,
3145
+ E.setSelection,
3146
+ E.getSelection,
3147
+ E.getBoardState,
3148
+ E.updateBoardState
3149
+ ]), [f] = se((E) => [E.getBoardConfig]), d = g.useRef({}), c = g.useRef({
3150
+ items: []
3151
+ }), b = (E) => {
3152
+ const { ctrlKey: R, metaKey: x, event: y } = E, p = n(E);
3153
+ if (p) {
3154
+ y.stopPropagation();
3155
+ const h = a();
3156
+ c.current.items = h;
3157
+ const v = ke(p);
3158
+ h.includes(v) || (R || x ? (c.current.items = [...h, v], o([v])) : (c.current.items = [v], s([v]))), Object.assign(d.current, {
3159
+ moving: !0,
3160
+ remainX: 0,
3161
+ remainY: 0
3162
+ });
3163
+ }
3164
+ }, _ = ({ deltaX: E, deltaY: R, event: x }) => {
3165
+ if (d.current.moving) {
3166
+ x.stopPropagation();
3167
+ const { scale: y } = u(), p = d.current.remainX + E / y, h = d.current.remainY + R / y;
3168
+ t(
3169
+ c.current.items,
3170
+ {
3171
+ x: p,
3172
+ y: h
3173
+ },
3174
+ !0
3175
+ ), l({ movingItems: !0 });
3176
+ }
3177
+ }, w = () => {
3178
+ if (d.current.moving) {
3179
+ const { gridSize: E = 1 } = f(), R = E || 1;
3180
+ d.current = { moving: !1 }, r(c.current.items, {
3181
+ type: "grid",
3182
+ size: R
3183
+ }), l({ movingItems: !1 });
3184
+ }
3185
+ };
3186
+ return pe(document, "keydown", (E) => {
3187
+ if (["INPUT", "TEXTAREA"].includes(E.target.tagName))
3188
+ return;
3189
+ const R = a();
3190
+ if (R.length) {
3191
+ const { gridSize: x = 1 } = f();
3192
+ let y = 0, p = 0;
3193
+ switch (E.key) {
3194
+ case "ArrowLeft":
3195
+ y = -10;
3196
+ break;
3197
+ case "ArrowRight":
3198
+ y = 10;
3199
+ break;
3200
+ case "ArrowUp":
3201
+ p = -10;
3202
+ break;
3203
+ case "ArrowDown":
3204
+ p = 10;
3205
+ break;
3206
+ }
3207
+ (y || p) && (E.shiftKey && (y *= 5, p *= 5), (E.ctrlKey || E.altKey || E.metaKey) && (y /= 10, p /= 10), t(
3208
+ R,
3209
+ {
3210
+ x: y,
3211
+ y: p
3212
+ },
3213
+ !0
3214
+ ), r(R, {
3215
+ type: "grid",
3216
+ size: x || 1
3217
+ }), E.preventDefault());
3218
+ }
3219
+ }), /* @__PURE__ */ T(We, { onDragStart: b, onDrag: _, onDragEnd: w, children: e });
3220
+ }, ho = (e) => {
3221
+ const t = g.useRef({ hover: !1, x: 0, y: 0 });
3222
+ return pe(e.current, "mousemove", (n) => {
3223
+ const { clientX: o, clientY: s } = n;
3224
+ t.current.x = o, t.current.y = s;
3225
+ }), pe(e.current, "mouseenter", () => {
3226
+ t.current.hover = !0;
3227
+ }), pe(e.current, "mouseleave", () => {
3228
+ t.current.hover = !1;
3229
+ }), g.useCallback(() => t.current, []);
3230
+ }, vo = [...Array(5).keys()].map((e) => `Digit${e + 1}`), yo = () => {
3231
+ const [e, t] = g.useState({}), [r, n] = Z((o) => [
3232
+ o.getBoardState,
3233
+ o.updateBoardState
3234
+ ]);
3235
+ return pe(document, "keydown", (o) => {
3236
+ if (!["INPUT", "TEXTAREA"].includes(o.target.tagName) && vo.includes(o.code)) {
3237
+ const s = o.code, { translateX: a, translateY: u, scale: l } = r();
3238
+ o.altKey || o.metaKey || o.ctrlKey ? t((f) => ({
3239
+ ...f,
3240
+ [s]: { translateX: a, translateY: u, scale: l }
3241
+ })) : e[s] && n(e[s]), o.preventDefault();
3242
+ }
3243
+ }), null;
3244
+ }, So = ({ children: e, moveFirst: t = !1 }) => {
3245
+ const r = g.useRef(null), [
3246
+ n,
3247
+ o,
3248
+ s,
3249
+ a,
3250
+ u
3251
+ ] = Z((p) => [
3252
+ {
3253
+ translateX: p.boardState.translateX,
3254
+ translateY: p.boardState.translateY,
3255
+ scale: p.boardState.scale
3256
+ },
3257
+ p.config.itemExtent,
3258
+ p.getConfiguration,
3259
+ p.updateBoardState,
3260
+ p.getSelection
3261
+ ]), { setDim: l, zoomToCenter: f, zoomToExtent: d } = dt(), [c, b] = g.useState(!1), _ = g.useRef({}), w = ho(r);
3262
+ yo();
3263
+ const m = g.useCallback(() => {
3264
+ const { itemExtent: p } = s();
3265
+ d(p);
3266
+ }, [s, d]);
3267
+ g.useEffect(() => {
3268
+ !c && o.left && (m(), b(!0));
3269
+ }, [m, c, o]);
3270
+ const E = ({ clientX: p, clientY: h, scale: v }) => {
3271
+ f(1 - v / 500, { x: p, y: h }), clearTimeout(_.current.zoom), _.current.zoom = setTimeout(() => {
3272
+ a({ zooming: !1 });
3273
+ }, 200), a({ zooming: !0 });
3274
+ }, R = ({ deltaX: p, deltaY: h }) => {
3275
+ l((v) => ({
3276
+ ...v,
3277
+ translateX: v.translateX + p,
3278
+ translateY: v.translateY + h
3279
+ })), clearTimeout(_.current.pan), _.current.pan = setTimeout(() => {
3280
+ a({ panning: !1 });
3281
+ }, 200), a({ panning: !0 });
3282
+ }, x = (p) => {
3283
+ if (["INPUT", "TEXTAREA"].includes(p.target.tagName))
3284
+ return;
3285
+ let h = 0, v = 0, C = 1;
3286
+ switch (p.key) {
3287
+ case "ArrowLeft":
3288
+ h = -10;
3289
+ break;
3290
+ case "ArrowRight":
3291
+ h = 10;
3292
+ break;
3293
+ case "ArrowUp":
3294
+ v = -10;
3295
+ break;
3296
+ case "ArrowDown":
3297
+ v = 10;
3298
+ break;
3299
+ case "PageUp":
3300
+ C = 1.2;
3301
+ break;
3302
+ case "PageDown":
3303
+ C = 0.8;
3304
+ break;
3305
+ }
3306
+ if (h || v || C !== 1) {
3307
+ const D = u();
3308
+ if (C === 1 && D.length)
3309
+ return;
3310
+ p.shiftKey && (h *= 5, v *= 5), (p.ctrlKey || p.altKey || p.metaKey) && (h /= 5, v /= 5), l((k) => ({
3311
+ ...k,
3312
+ translateY: k.translateY + v,
3313
+ translateX: k.translateX + h
3314
+ })), f(C), p.preventDefault();
3315
+ }
3316
+ p.key === " " && !p.repeat && w().hover && f(3, w());
3317
+ }, y = (p) => {
3318
+ ["INPUT", "TEXTAREA"].includes(p.target.tagName) || p.key === " " && w().hover && f(1 / 3, w());
3319
+ };
3320
+ return pe(document, "keydown", x), pe(document, "keyup", y), /* @__PURE__ */ T(
3321
+ We,
3322
+ {
3323
+ onPan: R,
3324
+ onZoom: E,
3325
+ mainAction: t ? "pan" : "drag",
3326
+ children: /* @__PURE__ */ T(
3327
+ "div",
3328
+ {
3329
+ style: {
3330
+ display: "inline-block",
3331
+ transformOrigin: "top left",
3332
+ transform: `translate(${n.translateX}px, ${n.translateY}px) scale(${n.scale})`
3333
+ },
3334
+ className: `board-pane${n.scale < 0.5 ? " board-pane__far" : ""}`,
3335
+ ref: r,
3336
+ children: e
3337
+ }
3338
+ )
3339
+ }
3340
+ );
3341
+ }, _o = H({
3342
+ position: "absolute",
3343
+ top: 0,
3344
+ left: 0,
3345
+ zIndex: 210,
3346
+ backgroundColor: "hsla(0, 40%, 50%, 0%)",
3347
+ border: "2px dashed hsl(20, 55%, 40%)",
3348
+ pointerEvents: "none"
3349
+ }), bo = () => {
3350
+ const [
3351
+ e,
3352
+ t,
3353
+ r,
3354
+ n,
3355
+ o,
3356
+ { translateX: s, translateY: a, scale: u }
3357
+ ] = Z((c) => [
3358
+ c.selection,
3359
+ c.getSelection,
3360
+ c.selectionBox,
3361
+ c.setSelectionBox,
3362
+ c.getConfiguration,
3363
+ {
3364
+ translateX: c.boardState.translateX,
3365
+ translateY: c.boardState.translateY,
3366
+ scale: c.boardState.scale
3367
+ }
3368
+ ]), [l] = se((c) => [c.items]), f = g.useCallback(() => {
3369
+ const c = t(), { boardWrapperRect: b, boardWrapper: _ } = o();
3370
+ if (c.length === 0) {
3371
+ n(null);
3372
+ return;
3373
+ }
3374
+ const w = nr(c, _);
3375
+ if (!w) {
3376
+ n(null);
3377
+ return;
3378
+ }
3379
+ const { left: m, top: E, width: R, height: x } = w, y = {
3380
+ left: m - b.left,
3381
+ top: E - b.top,
3382
+ height: x,
3383
+ width: R
3384
+ };
3385
+ n(y);
3386
+ }, [o, t, n]), d = ft(f, [f], 300);
3387
+ return g.useEffect(() => {
3388
+ f(), d();
3389
+ }, [
3390
+ e,
3391
+ l,
3392
+ s,
3393
+ a,
3394
+ u,
3395
+ f,
3396
+ d
3397
+ ]), !r || e.length < 2 ? null : /* @__PURE__ */ T(
3398
+ "div",
3399
+ {
3400
+ style: {
3401
+ transform: `translate(${r.left}px, ${r.top}px)`,
3402
+ height: `${r.height}px`,
3403
+ width: `${r.width}px`
3404
+ },
3405
+ className: `selection ${_o}`
3406
+ }
3407
+ );
3408
+ }, Eo = () => {
3409
+ const [e] = Z((t) => [t.boardState.movingItems]);
3410
+ return e ? null : /* @__PURE__ */ T(bo, {});
3411
+ }, wo = typeof window < "u" && typeof navigator < "u" && typeof document < "u";
3412
+ let Le;
3413
+ function Co() {
3414
+ if (!wo)
3415
+ return;
3416
+ if (Le)
3417
+ return Le;
3418
+ const e = /* @__PURE__ */ new Map(), t = new ResizeObserver((r) => {
3419
+ r.forEach((n) => {
3420
+ var o;
3421
+ return (o = e.get(n.target)) == null ? void 0 : o.forEach((s) => setTimeout(() => s(n), 0));
3422
+ });
3423
+ });
3424
+ return Le = {
3425
+ observer: t,
3426
+ subscribe: (r, n) => {
3427
+ let o = e.get(r);
3428
+ o || (o = /* @__PURE__ */ new Set(), e.set(r, o), t.observe(r)), o.add(n);
3429
+ },
3430
+ unsubscribe: (r, n) => {
3431
+ const o = e.get(r);
3432
+ o && (o.delete(n), o.size || (e.delete(r), t.unobserve(r)));
3433
+ }
3434
+ }, Le;
3435
+ }
3436
+ function xo(e, t, r = !0) {
3437
+ const n = r && Co(), o = lt(t), s = e && "current" in e ? e.current : e;
3438
+ Me(() => {
3439
+ const a = e && "current" in e ? e.current : e;
3440
+ if (!n || !a)
3441
+ return;
3442
+ let u = !0;
3443
+ const l = (...f) => {
3444
+ u && o.current(...f);
3445
+ };
3446
+ return n.subscribe(a, l), () => {
3447
+ u = !1, n.unsubscribe(a, l);
3448
+ };
3449
+ }, [s, n]);
3450
+ }
3451
+ function Ht(e, t, r) {
3452
+ return Math.min(Math.max(e, r), t);
3453
+ }
3454
+ class Ro extends Error {
3455
+ constructor(t) {
3456
+ super(`Failed to parse color: "${t}"`);
3457
+ }
3458
+ }
3459
+ var Re = Ro;
3460
+ function Io(e) {
3461
+ if (typeof e != "string")
3462
+ throw new Re(e);
3463
+ if (e.trim().toLowerCase() === "transparent")
3464
+ return [0, 0, 0, 0];
3465
+ let t = e.trim();
3466
+ t = $o.test(e) ? ko(e) : e;
3467
+ const r = Po.exec(t);
3468
+ if (r) {
3469
+ const a = Array.from(r).slice(1);
3470
+ return [...a.slice(0, 3).map((u) => parseInt(Pe(u, 2), 16)), parseInt(Pe(a[3] || "f", 2), 16) / 255];
3471
+ }
3472
+ const n = Mo.exec(t);
3473
+ if (n) {
3474
+ const a = Array.from(n).slice(1);
3475
+ return [...a.slice(0, 3).map((u) => parseInt(u, 16)), parseInt(a[3] || "ff", 16) / 255];
3476
+ }
3477
+ const o = jo.exec(t);
3478
+ if (o) {
3479
+ const a = Array.from(o).slice(1);
3480
+ return [...a.slice(0, 3).map((u) => parseInt(u, 10)), parseFloat(a[3] || "1")];
3481
+ }
3482
+ const s = Do.exec(t);
3483
+ if (s) {
3484
+ const [a, u, l, f] = Array.from(s).slice(1).map(parseFloat);
3485
+ if (Ht(0, 100, u) !== u)
3486
+ throw new Re(e);
3487
+ if (Ht(0, 100, l) !== l)
3488
+ throw new Re(e);
3489
+ return [...Ao(a, u, l), Number.isNaN(f) ? 1 : f];
3490
+ }
3491
+ throw new Re(e);
3492
+ }
3493
+ function Oo(e) {
3494
+ let t = 5381, r = e.length;
3495
+ for (; r; )
3496
+ t = t * 33 ^ e.charCodeAt(--r);
3497
+ return (t >>> 0) % 2341;
3498
+ }
3499
+ const qt = (e) => parseInt(e.replace(/_/g, ""), 36), To = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((e, t) => {
3500
+ const r = qt(t.substring(0, 3)), n = qt(t.substring(3)).toString(16);
3501
+ let o = "";
3502
+ for (let s = 0; s < 6 - n.length; s++)
3503
+ o += "0";
3504
+ return e[r] = `${o}${n}`, e;
3505
+ }, {});
3506
+ function ko(e) {
3507
+ const t = e.toLowerCase().trim(), r = To[Oo(t)];
3508
+ if (!r)
3509
+ throw new Re(e);
3510
+ return `#${r}`;
3511
+ }
3512
+ const Pe = (e, t) => Array.from(Array(t)).map(() => e).join(""), Po = new RegExp(`^#${Pe("([a-f0-9])", 3)}([a-f0-9])?$`, "i"), Mo = new RegExp(`^#${Pe("([a-f0-9]{2})", 3)}([a-f0-9]{2})?$`, "i"), jo = new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${Pe(",\\s*(\\d+)\\s*", 2)}(?:,\\s*([\\d.]+))?\\s*\\)$`, "i"), Do = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i, $o = /^[a-z]+$/i, Gt = (e) => Math.round(e * 255), Ao = (e, t, r) => {
3513
+ let n = r / 100;
3514
+ if (t === 0)
3515
+ return [n, n, n].map(Gt);
3516
+ const o = (e % 360 + 360) % 360 / 60, s = (1 - Math.abs(2 * n - 1)) * (t / 100), a = s * (1 - Math.abs(o % 2 - 1));
3517
+ let u = 0, l = 0, f = 0;
3518
+ o >= 0 && o < 1 ? (u = s, l = a) : o >= 1 && o < 2 ? (u = a, l = s) : o >= 2 && o < 3 ? (l = s, f = a) : o >= 3 && o < 4 ? (l = a, f = s) : o >= 4 && o < 5 ? (u = a, f = s) : o >= 5 && o < 6 && (u = s, f = a);
3519
+ const d = n - s / 2, c = u + d, b = l + d, _ = f + d;
3520
+ return [c, b, _].map(Gt);
3521
+ };
3522
+ function zo(e) {
3523
+ if (e === "transparent")
3524
+ return 0;
3525
+ function t(s) {
3526
+ const a = s / 255;
3527
+ return a <= 0.03928 ? a / 12.92 : Math.pow((a + 0.055) / 1.055, 2.4);
3528
+ }
3529
+ const [r, n, o] = Io(e);
3530
+ return 0.2126 * t(r) + 0.7152 * t(n) + 0.0722 * t(o);
3531
+ }
3532
+ function Lo(e) {
3533
+ return zo(e) > 0.179;
3534
+ }
3535
+ const Yo = H({
3536
+ display: "flex",
3537
+ flexDirection: "row",
3538
+ alignItems: "center",
3539
+ zIndex: 210,
3540
+ pointerEvents: "none"
3541
+ }), Bo = H({
3542
+ fontWeight: "bold",
3543
+ padding: "0 0.5em",
3544
+ borderRadius: "2px",
3545
+ maxWidth: "5em",
3546
+ overflow: "hidden",
3547
+ textOverflow: "ellipsis",
3548
+ marginLeft: "-0.5em",
3549
+ marginTop: "1.7em",
3550
+ whitespace: "nowrap",
3551
+ pointerEvents: "none"
3552
+ }), No = ({ color: e = "#666", size: t = 40, text: r }) => {
3553
+ const n = Lo(e) ? "#222" : "#EEE";
3554
+ return /* @__PURE__ */ ue("div", { className: Yo, children: [
3555
+ /* @__PURE__ */ ue(
3556
+ "svg",
3557
+ {
3558
+ version: "1.1",
3559
+ xmlns: "http://www.w3.org/2000/svg",
3560
+ viewBox: "1064.7701 445.5539 419.8101 717.0565",
3561
+ width: t,
3562
+ height: t,
3563
+ children: [
3564
+ /* @__PURE__ */ T(
3565
+ "path",
3566
+ {
3567
+ d: "m 1197.1015,869.718 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",
3568
+ style: {
3569
+ fill: n
3570
+ }
3571
+ }
3572
+ ),
3573
+ /* @__PURE__ */ T(
3574
+ "path",
3575
+ {
3576
+ d: "m 1193.0939,861.12419 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",
3577
+ style: {
3578
+ fill: "white",
3579
+ stroke: "#111",
3580
+ strokeWidth: 20
3581
+ }
3582
+ }
3583
+ )
3584
+ ]
3585
+ }
3586
+ ),
3587
+ /* @__PURE__ */ T(
3588
+ "div",
3589
+ {
3590
+ style: {
3591
+ color: n,
3592
+ backgroundColor: e
3593
+ },
3594
+ className: Bo,
3595
+ children: r
3596
+ }
3597
+ )
3598
+ ] });
3599
+ }, Uo = g.memo(No), Xo = H({
3600
+ top: 0,
3601
+ left: 0,
3602
+ zIndex: 210,
3603
+ position: "fixed",
3604
+ pointerEvents: "none"
3605
+ }), Wo = ({ pos: e, ...t }) => /* @__PURE__ */ T(
3606
+ "div",
3607
+ {
3608
+ className: Xo,
3609
+ style: { transform: `translate(${e.x - 5}px, ${e.y - 3}px)` },
3610
+ children: /* @__PURE__ */ T(Uo, { ...t })
3611
+ }
3612
+ ), Vo = () => {
3613
+ const [e, t, r, n] = ge(
3614
+ (s) => [
3615
+ s.getUser(),
3616
+ s.getLocalUsers(),
3617
+ s.cursors,
3618
+ s.users
3619
+ ]
3620
+ ), o = t.reduce((s, a) => (a.id !== e.id && r[a.id] && (s[a.id] = r[a.id]), s), {});
3621
+ return /* @__PURE__ */ T(Qt, { children: Object.entries(o).map(([s, a]) => /* @__PURE__ */ T(
3622
+ Wo,
3623
+ {
3624
+ pos: a,
3625
+ text: n[s].name,
3626
+ color: n[s].color
3627
+ },
3628
+ s
3629
+ )) });
3630
+ }, Fo = ({ children: e }) => {
3631
+ const t = ge((l) => l.getUser()), [r, n] = ge((l) => [
3632
+ l.moveCursor,
3633
+ l.removeCursor
3634
+ ]), [o, s] = Z((l) => [
3635
+ l.getConfiguration,
3636
+ l.getBoardState
3637
+ ]);
3638
+ return /* @__PURE__ */ ue("div", { onPointerMove: ({ clientX: l, clientY: f }) => {
3639
+ const { scale: d, translateX: c, translateY: b } = s(), {
3640
+ boardWrapperRect: { left: _, top: w }
3641
+ } = o(), m = {
3642
+ x: (l - _ - c) / d,
3643
+ y: (f - w - b) / d
3644
+ };
3645
+ r(t.id, m);
3646
+ }, onPointerLeave: () => {
3647
+ n(t.id);
3648
+ }, children: [
3649
+ e,
3650
+ /* @__PURE__ */ T(Vo, {})
3651
+ ] });
3652
+ }, Ko = ({ children: e }) => e, Ho = {
3653
+ overflow: "hidden",
3654
+ position: "absolute",
3655
+ inset: 0
3656
+ }, us = ({
3657
+ moveFirst: e = !0,
3658
+ style: t,
3659
+ wrapperStyle: r,
3660
+ itemTemplates: n = {},
3661
+ boardSize: o = sr,
3662
+ children: s,
3663
+ showResizeHandle: a = !1,
3664
+ Wrapper: u = Ko
3665
+ }) => {
3666
+ const l = g.useRef(null), [f, d] = Z((w) => [
3667
+ w.config.uid,
3668
+ w.updateConfiguration
3669
+ ]), { updateItemExtent: c } = dt(), b = {
3670
+ userSelect: "none",
3671
+ width: `${o}px`,
3672
+ height: `${o}px`,
3673
+ backgroundColor: "#333",
3674
+ ...t
3675
+ };
3676
+ g.useEffect(() => {
3677
+ const w = (m) => {
3678
+ Te(m.target, "board") && m.preventDefault();
3679
+ };
3680
+ return document.body.addEventListener("wheel", w, { passive: !1 }), () => {
3681
+ document.body.removeEventListener("wheel", w);
3682
+ };
3683
+ }, []), g.useEffect(() => {
3684
+ d({
3685
+ boardWrapper: l.current
3686
+ });
3687
+ }, [d]), g.useEffect(() => {
3688
+ f || d({
3689
+ uid: me()
3690
+ });
3691
+ }, [f, d]), g.useEffect(() => {
3692
+ d({
3693
+ itemTemplates: n,
3694
+ boardSize: o,
3695
+ showResizeHandle: a
3696
+ });
3697
+ }, [n, o, a, d]), g.useEffect(() => {
3698
+ c(), setTimeout(c, 2e3);
3699
+ }, [c]), xo(l, () => {
3700
+ l.current && d({
3701
+ boardWrapperRect: l.current.getBoundingClientRect()
3702
+ });
3703
+ });
3704
+ const _ = H({ ...Ho, ...r });
3705
+ return /* @__PURE__ */ ue(
3706
+ "div",
3707
+ {
3708
+ ref: l,
3709
+ id: f,
3710
+ className: `sync-board ${_}`,
3711
+ children: [
3712
+ /* @__PURE__ */ T(So, { moveFirst: e, children: /* @__PURE__ */ T(uo, { moveFirst: e, children: /* @__PURE__ */ T(go, { moveFirst: e, children: /* @__PURE__ */ T(Fo, { children: /* @__PURE__ */ T(u, { children: /* @__PURE__ */ ue(
3713
+ "div",
3714
+ {
3715
+ onContextMenu: (w) => {
3716
+ w.preventDefault();
3717
+ },
3718
+ style: b,
3719
+ className: "board",
3720
+ children: [
3721
+ /* @__PURE__ */ T(io, {}),
3722
+ s
3723
+ ]
3724
+ }
3725
+ ) }) }) }) }) }),
3726
+ /* @__PURE__ */ T(Eo, {})
3727
+ ]
3728
+ }
3729
+ );
3730
+ };
3731
+ Ln(g.createElement);
3732
+ export {
3733
+ us as Board,
3734
+ as as BoardWrapper,
3735
+ cs as RoomWrapper,
3736
+ es as useAvailableActions,
3737
+ ns as useBoardConfig,
3738
+ dt as useBoardPosition,
3739
+ os as useBoardState,
3740
+ Zo as useDebouncedItems,
3741
+ pt as useItemActions,
3742
+ gn as useItemInteraction,
3743
+ Jo as useItems,
3744
+ is as useMessage,
3745
+ Qo as useSelectedItems,
3746
+ ts as useSelectionBox,
3747
+ ss as useSessionInfo,
3748
+ rs as useUsers,
3749
+ Be as useWire
3750
+ };
3751
+ //# sourceMappingURL=react-sync-board.js.map