@fragmentsx/render-react 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,3444 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const preact = require("preact");
4
- const require$$0$1 = require("react");
3
+ const renderCore = require("@fragmentsx/render-core");
4
+ const require$$0 = require("react");
5
5
  require("react/jsx-runtime");
6
- (function() {
7
- try {
8
- if (typeof document != "undefined") {
9
- var elementStyle = document.createElement("style");
10
- elementStyle.appendChild(document.createTextNode("._fragment_wbfy9_1 {\n width: 100%;\n height: 100%;\n}\n._text_1liuf_1 {\n white-space: pre;\n :where(p) {\n margin: 0;\n }\n}"));
11
- document.head.appendChild(elementStyle);
12
- }
13
- } catch (e2) {
14
- console.error("vite-plugin-css-injected-by-js", e2);
15
- }
16
- })();
17
- var f$1 = 0;
18
- function u$1(e2, t2, n2, o2, i2, u2) {
19
- t2 || (t2 = {});
20
- var a2, c2, p2 = t2;
21
- if ("ref" in p2) for (c2 in p2 = {}, t2) "ref" == c2 ? a2 = t2[c2] : p2[c2] = t2[c2];
22
- var l2 = { type: e2, props: p2, key: n2, ref: a2, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f$1, __i: -1, __u: 0, __source: i2, __self: u2 };
23
- if ("function" == typeof e2 && (a2 = e2.defaultProps)) for (c2 in a2) void 0 === p2[c2] && (p2[c2] = a2[c2]);
24
- return preact.options.vnode && preact.options.vnode(l2), l2;
25
- }
26
- var t$1, r$1, u, i$1, o = 0, f = [], c = preact.options, e = c.__b, a$1 = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s$1 = c.__;
27
- function p$1(n2, t2) {
28
- c.__h && c.__h(r$1, n2, o || t2), o = 0;
29
- var u2 = r$1.__H || (r$1.__H = { __: [], __h: [] });
30
- return n2 >= u2.__.length && u2.__.push({}), u2.__[n2];
31
- }
32
- function d(n2) {
33
- return o = 1, h(D$2, n2);
34
- }
35
- function h(n2, u2, i2) {
36
- var o2 = p$1(t$1++, 2);
37
- if (o2.t = n2, !o2.__c && (o2.__ = [i2 ? i2(u2) : D$2(void 0, u2), function(n3) {
38
- var t2 = o2.__N ? o2.__N[0] : o2.__[0], r2 = o2.t(t2, n3);
39
- t2 !== r2 && (o2.__N = [r2, o2.__[1]], o2.__c.setState({}));
40
- }], o2.__c = r$1, !r$1.__f)) {
41
- var f2 = function(n3, t2, r2) {
42
- if (!o2.__c.__H) return true;
43
- var u3 = o2.__c.__H.__.filter(function(n4) {
44
- return !!n4.__c;
45
- });
46
- if (u3.every(function(n4) {
47
- return !n4.__N;
48
- })) return !c2 || c2.call(this, n3, t2, r2);
49
- var i3 = o2.__c.props !== n3;
50
- return u3.forEach(function(n4) {
51
- if (n4.__N) {
52
- var t3 = n4.__[0];
53
- n4.__ = n4.__N, n4.__N = void 0, t3 !== n4.__[0] && (i3 = true);
54
- }
55
- }), c2 && c2.call(this, n3, t2, r2) || i3;
56
- };
57
- r$1.__f = true;
58
- var c2 = r$1.shouldComponentUpdate, e2 = r$1.componentWillUpdate;
59
- r$1.componentWillUpdate = function(n3, t2, r2) {
60
- if (this.__e) {
61
- var u3 = c2;
62
- c2 = void 0, f2(n3, t2, r2), c2 = u3;
63
- }
64
- e2 && e2.call(this, n3, t2, r2);
65
- }, r$1.shouldComponentUpdate = f2;
66
- }
67
- return o2.__N || o2.__;
68
- }
69
- function y$2(n2, u2) {
70
- var i2 = p$1(t$1++, 3);
71
- !c.__s && C$1(i2.__H, u2) && (i2.__ = n2, i2.u = u2, r$1.__H.__h.push(i2));
72
- }
73
- function _(n2, u2) {
74
- var i2 = p$1(t$1++, 4);
75
- !c.__s && C$1(i2.__H, u2) && (i2.__ = n2, i2.u = u2, r$1.__h.push(i2));
76
- }
77
- function A$1(n2) {
78
- return o = 5, T$1(function() {
79
- return { current: n2 };
80
- }, []);
81
- }
82
- function F$1(n2, t2, r2) {
83
- o = 6, _(function() {
84
- if ("function" == typeof n2) {
85
- var r3 = n2(t2());
86
- return function() {
87
- n2(null), r3 && "function" == typeof r3 && r3();
88
- };
89
- }
90
- if (n2) return n2.current = t2(), function() {
91
- return n2.current = null;
92
- };
93
- }, null == r2 ? r2 : r2.concat(n2));
94
- }
95
- function T$1(n2, r2) {
96
- var u2 = p$1(t$1++, 7);
97
- return C$1(u2.__H, r2) && (u2.__ = n2(), u2.__H = r2, u2.__h = n2), u2.__;
98
- }
99
- function q$1(n2, t2) {
100
- return o = 8, T$1(function() {
101
- return n2;
102
- }, t2);
103
- }
104
- function x$1(n2) {
105
- var u2 = r$1.context[n2.__c], i2 = p$1(t$1++, 9);
106
- return i2.c = n2, u2 ? (null == i2.__ && (i2.__ = true, u2.sub(r$1)), u2.props.value) : n2.__;
107
- }
108
- function P$1(n2, t2) {
109
- c.useDebugValue && c.useDebugValue(t2 ? t2(n2) : n2);
110
- }
111
- function b$1(n2) {
112
- var u2 = p$1(t$1++, 10), i2 = d();
113
- return u2.__ = n2, r$1.componentDidCatch || (r$1.componentDidCatch = function(n3, t2) {
114
- u2.__ && u2.__(n3, t2), i2[1](n3);
115
- }), [i2[0], function() {
116
- i2[1](void 0);
117
- }];
118
- }
119
- function g$2() {
120
- var n2 = p$1(t$1++, 11);
121
- if (!n2.__) {
122
- for (var u2 = r$1.__v; null !== u2 && !u2.__m && null !== u2.__; ) u2 = u2.__;
123
- var i2 = u2.__m || (u2.__m = [0, 0]);
124
- n2.__ = "P" + i2[0] + "-" + i2[1]++;
125
- }
126
- return n2.__;
127
- }
128
- function j$2() {
129
- for (var n2; n2 = f.shift(); ) if (n2.__P && n2.__H) try {
130
- n2.__H.__h.forEach(z$1), n2.__H.__h.forEach(B$1), n2.__H.__h = [];
131
- } catch (t2) {
132
- n2.__H.__h = [], c.__e(t2, n2.__v);
133
- }
134
- }
135
- c.__b = function(n2) {
136
- r$1 = null, e && e(n2);
137
- }, c.__ = function(n2, t2) {
138
- n2 && t2.__k && t2.__k.__m && (n2.__m = t2.__k.__m), s$1 && s$1(n2, t2);
139
- }, c.__r = function(n2) {
140
- a$1 && a$1(n2), t$1 = 0;
141
- var i2 = (r$1 = n2.__c).__H;
142
- i2 && (u === r$1 ? (i2.__h = [], r$1.__h = [], i2.__.forEach(function(n3) {
143
- n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
144
- })) : (i2.__h.forEach(z$1), i2.__h.forEach(B$1), i2.__h = [], t$1 = 0)), u = r$1;
145
- }, c.diffed = function(n2) {
146
- v && v(n2);
147
- var t2 = n2.__c;
148
- t2 && t2.__H && (t2.__H.__h.length && (1 !== f.push(t2) && i$1 === c.requestAnimationFrame || ((i$1 = c.requestAnimationFrame) || w$1)(j$2)), t2.__H.__.forEach(function(n3) {
149
- n3.u && (n3.__H = n3.u), n3.u = void 0;
150
- })), u = r$1 = null;
151
- }, c.__c = function(n2, t2) {
152
- t2.some(function(n3) {
153
- try {
154
- n3.__h.forEach(z$1), n3.__h = n3.__h.filter(function(n4) {
155
- return !n4.__ || B$1(n4);
156
- });
157
- } catch (r2) {
158
- t2.some(function(n4) {
159
- n4.__h && (n4.__h = []);
160
- }), t2 = [], c.__e(r2, n3.__v);
161
- }
162
- }), l && l(n2, t2);
163
- }, c.unmount = function(n2) {
164
- m && m(n2);
165
- var t2, r2 = n2.__c;
166
- r2 && r2.__H && (r2.__H.__.forEach(function(n3) {
167
- try {
168
- z$1(n3);
169
- } catch (n4) {
170
- t2 = n4;
171
- }
172
- }), r2.__H = void 0, t2 && c.__e(t2, r2.__v));
173
- };
174
- var k$2 = "function" == typeof requestAnimationFrame;
175
- function w$1(n2) {
176
- var t2, r2 = function() {
177
- clearTimeout(u2), k$2 && cancelAnimationFrame(t2), setTimeout(n2);
178
- }, u2 = setTimeout(r2, 100);
179
- k$2 && (t2 = requestAnimationFrame(r2));
180
- }
181
- function z$1(n2) {
182
- var t2 = r$1, u2 = n2.__c;
183
- "function" == typeof u2 && (n2.__c = void 0, u2()), r$1 = t2;
184
- }
185
- function B$1(n2) {
186
- var t2 = r$1;
187
- n2.__c = n2.__(), r$1 = t2;
188
- }
189
- function C$1(n2, t2) {
190
- return !n2 || n2.length !== t2.length || t2.some(function(t3, r2) {
191
- return t3 !== n2[r2];
192
- });
193
- }
194
- function D$2(n2, t2) {
195
- return "function" == typeof t2 ? t2(n2) : t2;
196
- }
197
- function g$1(n2, t2) {
198
- for (var e2 in t2) n2[e2] = t2[e2];
199
- return n2;
200
- }
201
- function E$1(n2, t2) {
202
- for (var e2 in n2) if ("__source" !== e2 && !(e2 in t2)) return true;
203
- for (var r2 in t2) if ("__source" !== r2 && n2[r2] !== t2[r2]) return true;
204
- return false;
205
- }
206
- function C(n2, t2) {
207
- var e2 = t2(), r2 = d({ t: { __: e2, u: t2 } }), u2 = r2[0].t, o2 = r2[1];
208
- return _(function() {
209
- u2.__ = e2, u2.u = t2, x(u2) && o2({ t: u2 });
210
- }, [n2, e2, t2]), y$2(function() {
211
- return x(u2) && o2({ t: u2 }), n2(function() {
212
- x(u2) && o2({ t: u2 });
213
- });
214
- }, [n2]), e2;
215
- }
216
- function x(n2) {
217
- var t2, e2, r2 = n2.u, u2 = n2.__;
218
- try {
219
- var o2 = r2();
220
- return !((t2 = u2) === (e2 = o2) && (0 !== t2 || 1 / t2 == 1 / e2) || t2 != t2 && e2 != e2);
221
- } catch (n3) {
222
- return true;
223
- }
224
- }
225
- function R(n2) {
226
- n2();
227
- }
228
- function w(n2) {
229
- return n2;
230
- }
231
- function k$1() {
232
- return [false, R];
233
- }
234
- var I = _;
235
- function N(n2, t2) {
236
- this.props = n2, this.context = t2;
237
- }
238
- function M(n2, e2) {
239
- function r2(n3) {
240
- var t2 = this.props.ref, r3 = t2 == n3.ref;
241
- return !r3 && t2 && (t2.call ? t2(null) : t2.current = null), e2 ? !e2(this.props, n3) || !r3 : E$1(this.props, n3);
242
- }
243
- function u2(e3) {
244
- return this.shouldComponentUpdate = r2, preact.createElement(n2, e3);
245
- }
246
- return u2.displayName = "Memo(" + (n2.displayName || n2.name) + ")", u2.prototype.isReactComponent = true, u2.__f = true, u2;
247
- }
248
- (N.prototype = new preact.Component()).isPureReactComponent = true, N.prototype.shouldComponentUpdate = function(n2, t2) {
249
- return E$1(this.props, n2) || E$1(this.state, t2);
250
- };
251
- var T = preact.options.__b;
252
- preact.options.__b = function(n2) {
253
- n2.type && n2.type.__f && n2.ref && (n2.props.ref = n2.ref, n2.ref = null), T && T(n2);
254
- };
255
- var A = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.forward_ref") || 3911;
256
- function D$1(n2) {
257
- function t2(t3) {
258
- var e2 = g$1({}, t3);
259
- return delete e2.ref, n2(e2, t3.ref || null);
260
- }
261
- return t2.$$typeof = A, t2.render = t2, t2.prototype.isReactComponent = t2.__f = true, t2.displayName = "ForwardRef(" + (n2.displayName || n2.name) + ")", t2;
262
- }
263
- var L = function(n2, t2) {
264
- return null == n2 ? null : preact.toChildArray(preact.toChildArray(n2).map(t2));
265
- }, O = { map: L, forEach: L, count: function(n2) {
266
- return n2 ? preact.toChildArray(n2).length : 0;
267
- }, only: function(n2) {
268
- var t2 = preact.toChildArray(n2);
269
- if (1 !== t2.length) throw "Children.only";
270
- return t2[0];
271
- }, toArray: preact.toChildArray }, F = preact.options.__e;
272
- preact.options.__e = function(n2, t2, e2, r2) {
273
- if (n2.then) {
274
- for (var u2, o2 = t2; o2 = o2.__; ) if ((u2 = o2.__c) && u2.__c) return null == t2.__e && (t2.__e = e2.__e, t2.__k = e2.__k), u2.__c(n2, t2);
275
- }
276
- F(n2, t2, e2, r2);
277
- };
278
- var U = preact.options.unmount;
279
- function V(n2, t2, e2) {
280
- return n2 && (n2.__c && n2.__c.__H && (n2.__c.__H.__.forEach(function(n3) {
281
- "function" == typeof n3.__c && n3.__c();
282
- }), n2.__c.__H = null), null != (n2 = g$1({}, n2)).__c && (n2.__c.__P === e2 && (n2.__c.__P = t2), n2.__c = null), n2.__k = n2.__k && n2.__k.map(function(n3) {
283
- return V(n3, t2, e2);
284
- })), n2;
285
- }
286
- function W$1(n2, t2, e2) {
287
- return n2 && e2 && (n2.__v = null, n2.__k = n2.__k && n2.__k.map(function(n3) {
288
- return W$1(n3, t2, e2);
289
- }), n2.__c && n2.__c.__P === t2 && (n2.__e && e2.appendChild(n2.__e), n2.__c.__e = true, n2.__c.__P = e2)), n2;
290
- }
291
- function P() {
292
- this.__u = 0, this.o = null, this.__b = null;
293
- }
294
- function j$1(n2) {
295
- var t2 = n2.__.__c;
296
- return t2 && t2.__a && t2.__a(n2);
297
- }
298
- function z(n2) {
299
- var e2, r2, u2;
300
- function o2(o3) {
301
- if (e2 || (e2 = n2()).then(function(n3) {
302
- r2 = n3.default || n3;
303
- }, function(n3) {
304
- u2 = n3;
305
- }), u2) throw u2;
306
- if (!r2) throw e2;
307
- return preact.createElement(r2, o3);
308
- }
309
- return o2.displayName = "Lazy", o2.__f = true, o2;
310
- }
311
- function B() {
312
- this.i = null, this.l = null;
313
- }
314
- preact.options.unmount = function(n2) {
315
- var t2 = n2.__c;
316
- t2 && t2.__R && t2.__R(), t2 && 32 & n2.__u && (n2.type = null), U && U(n2);
317
- }, (P.prototype = new preact.Component()).__c = function(n2, t2) {
318
- var e2 = t2.__c, r2 = this;
319
- null == r2.o && (r2.o = []), r2.o.push(e2);
320
- var u2 = j$1(r2.__v), o2 = false, i2 = function() {
321
- o2 || (o2 = true, e2.__R = null, u2 ? u2(c2) : c2());
322
- };
323
- e2.__R = i2;
324
- var c2 = function() {
325
- if (!--r2.__u) {
326
- if (r2.state.__a) {
327
- var n3 = r2.state.__a;
328
- r2.__v.__k[0] = W$1(n3, n3.__c.__P, n3.__c.__O);
329
- }
330
- var t3;
331
- for (r2.setState({ __a: r2.__b = null }); t3 = r2.o.pop(); ) t3.forceUpdate();
332
- }
333
- };
334
- r2.__u++ || 32 & t2.__u || r2.setState({ __a: r2.__b = r2.__v.__k[0] }), n2.then(i2, i2);
335
- }, P.prototype.componentWillUnmount = function() {
336
- this.o = [];
337
- }, P.prototype.render = function(n2, e2) {
338
- if (this.__b) {
339
- if (this.__v.__k) {
340
- var r2 = document.createElement("div"), o2 = this.__v.__k[0].__c;
341
- this.__v.__k[0] = V(this.__b, r2, o2.__O = o2.__P);
342
- }
343
- this.__b = null;
344
- }
345
- var i2 = e2.__a && preact.createElement(preact.Fragment, null, n2.fallback);
346
- return i2 && (i2.__u &= -33), [preact.createElement(preact.Fragment, null, e2.__a ? null : n2.children), i2];
347
- };
348
- var H = function(n2, t2, e2) {
349
- if (++e2[1] === e2[0] && n2.l.delete(t2), n2.props.revealOrder && ("t" !== n2.props.revealOrder[0] || !n2.l.size)) for (e2 = n2.i; e2; ) {
350
- for (; e2.length > 3; ) e2.pop()();
351
- if (e2[1] < e2[0]) break;
352
- n2.i = e2 = e2[2];
353
- }
354
- };
355
- function Z(n2) {
356
- return this.getChildContext = function() {
357
- return n2.context;
358
- }, n2.children;
359
- }
360
- function Y(n2) {
361
- var e2 = this, r2 = n2.h;
362
- e2.componentWillUnmount = function() {
363
- preact.render(null, e2.v), e2.v = null, e2.h = null;
364
- }, e2.h && e2.h !== r2 && e2.componentWillUnmount(), e2.v || (e2.h = r2, e2.v = { nodeType: 1, parentNode: r2, childNodes: [], contains: function() {
365
- return true;
366
- }, appendChild: function(n3) {
367
- this.childNodes.push(n3), e2.h.appendChild(n3);
368
- }, insertBefore: function(n3, t2) {
369
- this.childNodes.push(n3), e2.h.insertBefore(n3, t2);
370
- }, removeChild: function(n3) {
371
- this.childNodes.splice(this.childNodes.indexOf(n3) >>> 1, 1), e2.h.removeChild(n3);
372
- } }), preact.render(preact.createElement(Z, { context: e2.context }, n2.__v), e2.v);
373
- }
374
- function $(n2, e2) {
375
- var r2 = preact.createElement(Y, { __v: n2, h: e2 });
376
- return r2.containerInfo = e2, r2;
377
- }
378
- (B.prototype = new preact.Component()).__a = function(n2) {
379
- var t2 = this, e2 = j$1(t2.__v), r2 = t2.l.get(n2);
380
- return r2[0]++, function(u2) {
381
- var o2 = function() {
382
- t2.props.revealOrder ? (r2.push(u2), H(t2, n2, r2)) : u2();
383
- };
384
- e2 ? e2(o2) : o2();
385
- };
386
- }, B.prototype.render = function(n2) {
387
- this.i = null, this.l = /* @__PURE__ */ new Map();
388
- var t2 = preact.toChildArray(n2.children);
389
- n2.revealOrder && "b" === n2.revealOrder[0] && t2.reverse();
390
- for (var e2 = t2.length; e2--; ) this.l.set(t2[e2], this.i = [1, 0, this.i]);
391
- return n2.children;
392
- }, B.prototype.componentDidUpdate = B.prototype.componentDidMount = function() {
393
- var n2 = this;
394
- this.l.forEach(function(t2, e2) {
395
- H(n2, e2, t2);
396
- });
397
- };
398
- var q = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.element") || 60103, G = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/, J = /^on(Ani|Tra|Tou|BeforeInp|Compo)/, K = /[A-Z0-9]/g, Q = "undefined" != typeof document, X$1 = function(n2) {
399
- return ("undefined" != typeof Symbol && "symbol" == typeof Symbol() ? /fil|che|rad/ : /fil|che|ra/).test(n2);
400
- };
401
- function nn(n2, t2, e2) {
402
- return null == t2.__k && (t2.textContent = ""), preact.render(n2, t2), "function" == typeof e2 && e2(), n2 ? n2.__c : null;
403
- }
404
- function tn(n2, t2, e2) {
405
- return preact.hydrate(n2, t2), "function" == typeof e2 && e2(), n2 ? n2.__c : null;
406
- }
407
- preact.Component.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t2) {
408
- Object.defineProperty(preact.Component.prototype, t2, { configurable: true, get: function() {
409
- return this["UNSAFE_" + t2];
410
- }, set: function(n2) {
411
- Object.defineProperty(this, t2, { configurable: true, writable: true, value: n2 });
412
- } });
413
- });
414
- var en = preact.options.event;
415
- function rn() {
416
- }
417
- function un() {
418
- return this.cancelBubble;
419
- }
420
- function on() {
421
- return this.defaultPrevented;
422
- }
423
- preact.options.event = function(n2) {
424
- return en && (n2 = en(n2)), n2.persist = rn, n2.isPropagationStopped = un, n2.isDefaultPrevented = on, n2.nativeEvent = n2;
425
- };
426
- var cn, ln = { enumerable: false, configurable: true, get: function() {
427
- return this.class;
428
- } }, fn = preact.options.vnode;
429
- preact.options.vnode = function(n2) {
430
- "string" == typeof n2.type && function(n3) {
431
- var t2 = n3.props, e2 = n3.type, u2 = {}, o2 = -1 === e2.indexOf("-");
432
- for (var i2 in t2) {
433
- var c2 = t2[i2];
434
- if (!("value" === i2 && "defaultValue" in t2 && null == c2 || Q && "children" === i2 && "noscript" === e2 || "class" === i2 || "className" === i2)) {
435
- var l2 = i2.toLowerCase();
436
- "defaultValue" === i2 && "value" in t2 && null == t2.value ? i2 = "value" : "download" === i2 && true === c2 ? c2 = "" : "translate" === l2 && "no" === c2 ? c2 = false : "o" === l2[0] && "n" === l2[1] ? "ondoubleclick" === l2 ? i2 = "ondblclick" : "onchange" !== l2 || "input" !== e2 && "textarea" !== e2 || X$1(t2.type) ? "onfocus" === l2 ? i2 = "onfocusin" : "onblur" === l2 ? i2 = "onfocusout" : J.test(i2) && (i2 = l2) : l2 = i2 = "oninput" : o2 && G.test(i2) ? i2 = i2.replace(K, "-$&").toLowerCase() : null === c2 && (c2 = void 0), "oninput" === l2 && u2[i2 = l2] && (i2 = "oninputCapture"), u2[i2] = c2;
437
- }
438
- }
439
- "select" == e2 && u2.multiple && Array.isArray(u2.value) && (u2.value = preact.toChildArray(t2.children).forEach(function(n4) {
440
- n4.props.selected = -1 != u2.value.indexOf(n4.props.value);
441
- })), "select" == e2 && null != u2.defaultValue && (u2.value = preact.toChildArray(t2.children).forEach(function(n4) {
442
- n4.props.selected = u2.multiple ? -1 != u2.defaultValue.indexOf(n4.props.value) : u2.defaultValue == n4.props.value;
443
- })), t2.class && !t2.className ? (u2.class = t2.class, Object.defineProperty(u2, "className", ln)) : (t2.className && !t2.class || t2.class && t2.className) && (u2.class = u2.className = t2.className), n3.props = u2;
444
- }(n2), n2.$$typeof = q, fn && fn(n2);
445
- };
446
- var an = preact.options.__r;
447
- preact.options.__r = function(n2) {
448
- an && an(n2), cn = n2.__c;
449
- };
450
- var sn = preact.options.diffed;
451
- preact.options.diffed = function(n2) {
452
- sn && sn(n2);
453
- var t2 = n2.props, e2 = n2.__e;
454
- null != e2 && "textarea" === n2.type && "value" in t2 && t2.value !== e2.value && (e2.value = null == t2.value ? "" : t2.value), cn = null;
455
- };
456
- var hn = { ReactCurrentDispatcher: { current: { readContext: function(n2) {
457
- return cn.__n[n2.__c].props.value;
458
- }, useCallback: q$1, useContext: x$1, useDebugValue: P$1, useDeferredValue: w, useEffect: y$2, useId: g$2, useImperativeHandle: F$1, useInsertionEffect: I, useLayoutEffect: _, useMemo: T$1, useReducer: h, useRef: A$1, useState: d, useSyncExternalStore: C, useTransition: k$1 } } }, vn = "18.3.1";
459
- function dn(n2) {
460
- return preact.createElement.bind(null, n2);
461
- }
462
- function pn(n2) {
463
- return !!n2 && n2.$$typeof === q;
464
- }
465
- function mn(n2) {
466
- return pn(n2) && n2.type === preact.Fragment;
467
- }
468
- function yn(n2) {
469
- return !!n2 && !!n2.displayName && ("string" == typeof n2.displayName || n2.displayName instanceof String) && n2.displayName.startsWith("Memo(");
470
- }
471
- function _n(n2) {
472
- return pn(n2) ? preact.cloneElement.apply(null, arguments) : n2;
473
- }
474
- function bn(n2) {
475
- return !!n2.__k && (preact.render(null, n2), true);
476
- }
477
- function Sn(n2) {
478
- return n2 && (n2.base || 1 === n2.nodeType && n2) || null;
479
- }
480
- var gn = function(n2, t2) {
481
- return n2(t2);
482
- }, En = function(n2, t2) {
483
- return n2(t2);
484
- }, Cn = preact.Fragment, xn = pn, Rn = { useState: d, useId: g$2, useReducer: h, useEffect: y$2, useLayoutEffect: _, useInsertionEffect: I, useTransition: k$1, useDeferredValue: w, useSyncExternalStore: C, startTransition: R, useRef: A$1, useImperativeHandle: F$1, useMemo: T$1, useCallback: q$1, useContext: x$1, useDebugValue: P$1, version: "18.3.1", Children: O, render: nn, hydrate: tn, unmountComponentAtNode: bn, createPortal: $, createElement: preact.createElement, createContext: preact.createContext, createFactory: dn, cloneElement: _n, createRef: preact.createRef, Fragment: preact.Fragment, isValidElement: pn, isElement: xn, isFragment: mn, isMemo: yn, findDOMNode: Sn, Component: preact.Component, PureComponent: N, memo: M, forwardRef: D$1, flushSync: En, unstable_batchedUpdates: gn, StrictMode: Cn, Suspense: P, SuspenseList: B, lazy: z, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: hn };
485
- const compat_module = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
486
- __proto__: null,
487
- Children: O,
488
- Component: preact.Component,
489
- Fragment: preact.Fragment,
490
- PureComponent: N,
491
- StrictMode: Cn,
492
- Suspense: P,
493
- SuspenseList: B,
494
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: hn,
495
- cloneElement: _n,
496
- createContext: preact.createContext,
497
- createElement: preact.createElement,
498
- createFactory: dn,
499
- createPortal: $,
500
- createRef: preact.createRef,
501
- default: Rn,
502
- findDOMNode: Sn,
503
- flushSync: En,
504
- forwardRef: D$1,
505
- hydrate: tn,
506
- isElement: xn,
507
- isFragment: mn,
508
- isMemo: yn,
509
- isValidElement: pn,
510
- lazy: z,
511
- memo: M,
512
- render: nn,
513
- startTransition: R,
514
- unmountComponentAtNode: bn,
515
- unstable_batchedUpdates: gn,
516
- useCallback: q$1,
517
- useContext: x$1,
518
- useDebugValue: P$1,
519
- useDeferredValue: w,
520
- useEffect: y$2,
521
- useErrorBoundary: b$1,
522
- useId: g$2,
523
- useImperativeHandle: F$1,
524
- useInsertionEffect: I,
525
- useLayoutEffect: _,
526
- useMemo: T$1,
527
- useReducer: h,
528
- useRef: A$1,
529
- useState: d,
530
- useSyncExternalStore: C,
531
- useTransition: k$1,
532
- version: vn
533
- }, Symbol.toStringTag, { value: "Module" }));
534
- function g(n2, t2) {
535
- let o2;
536
- return (...i2) => {
537
- window.clearTimeout(o2), o2 = window.setTimeout(() => n2(...i2), t2);
538
- };
539
- }
540
- function j({ debounce: n2, scroll: t2, polyfill: o2, offsetSize: i2 } = { debounce: 0, scroll: false, offsetSize: false }) {
541
- const a2 = o2 || (typeof window == "undefined" ? class {
542
- } : window.ResizeObserver);
543
- if (!a2) throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");
544
- const [c2, h2] = d({ left: 0, top: 0, width: 0, height: 0, bottom: 0, right: 0, x: 0, y: 0 }), e2 = A$1({ element: null, scrollContainers: null, resizeObserver: null, lastBounds: c2, orientationHandler: null }), d$1 = n2 ? typeof n2 == "number" ? n2 : n2.scroll : null, f2 = n2 ? typeof n2 == "number" ? n2 : n2.resize : null, w2 = A$1(false);
545
- y$2(() => (w2.current = true, () => void (w2.current = false)));
546
- const [z2, m2, s2] = T$1(() => {
547
- const r2 = () => {
548
- if (!e2.current.element) return;
549
- const { left: y2, top: C2, width: H2, height: O2, bottom: S, right: x2, x: B2, y: R2 } = e2.current.element.getBoundingClientRect(), l2 = { left: y2, top: C2, width: H2, height: O2, bottom: S, right: x2, x: B2, y: R2 };
550
- e2.current.element instanceof HTMLElement && i2 && (l2.height = e2.current.element.offsetHeight, l2.width = e2.current.element.offsetWidth), Object.freeze(l2), w2.current && !D(e2.current.lastBounds, l2) && h2(e2.current.lastBounds = l2);
551
- };
552
- return [r2, f2 ? g(r2, f2) : r2, d$1 ? g(r2, d$1) : r2];
553
- }, [h2, i2, d$1, f2]);
554
- function v2() {
555
- e2.current.scrollContainers && (e2.current.scrollContainers.forEach((r2) => r2.removeEventListener("scroll", s2, true)), e2.current.scrollContainers = null), e2.current.resizeObserver && (e2.current.resizeObserver.disconnect(), e2.current.resizeObserver = null), e2.current.orientationHandler && ("orientation" in screen && "removeEventListener" in screen.orientation ? screen.orientation.removeEventListener("change", e2.current.orientationHandler) : "onorientationchange" in window && window.removeEventListener("orientationchange", e2.current.orientationHandler));
556
- }
557
- function b2() {
558
- e2.current.element && (e2.current.resizeObserver = new a2(s2), e2.current.resizeObserver.observe(e2.current.element), t2 && e2.current.scrollContainers && e2.current.scrollContainers.forEach((r2) => r2.addEventListener("scroll", s2, { capture: true, passive: true })), e2.current.orientationHandler = () => {
559
- s2();
560
- }, "orientation" in screen && "addEventListener" in screen.orientation ? screen.orientation.addEventListener("change", e2.current.orientationHandler) : "onorientationchange" in window && window.addEventListener("orientationchange", e2.current.orientationHandler));
561
- }
562
- const L2 = (r2) => {
563
- !r2 || r2 === e2.current.element || (v2(), e2.current.element = r2, e2.current.scrollContainers = E(r2), b2());
564
- };
565
- return X(s2, !!t2), W(m2), y$2(() => {
566
- v2(), b2();
567
- }, [t2, s2, m2]), y$2(() => v2, []), [L2, c2, z2];
568
- }
569
- function W(n2) {
570
- y$2(() => {
571
- const t2 = n2;
572
- return window.addEventListener("resize", t2), () => void window.removeEventListener("resize", t2);
573
- }, [n2]);
574
- }
575
- function X(n2, t2) {
576
- y$2(() => {
577
- if (t2) {
578
- const o2 = n2;
579
- return window.addEventListener("scroll", o2, { capture: true, passive: true }), () => void window.removeEventListener("scroll", o2, true);
580
- }
581
- }, [n2, t2]);
582
- }
583
- function E(n2) {
584
- const t2 = [];
585
- if (!n2 || n2 === document.body) return t2;
586
- const { overflow: o2, overflowX: i2, overflowY: a2 } = window.getComputedStyle(n2);
587
- return [o2, i2, a2].some((c2) => c2 === "auto" || c2 === "scroll") && t2.push(n2), [...t2, ...E(n2.parentElement)];
588
- }
589
- const k = ["x", "y", "top", "bottom", "left", "right", "width", "height"], D = (n2, t2) => k.every((o2) => n2[o2] === t2[o2]);
590
- function getAugmentedNamespace(n2) {
591
- if (n2.__esModule) return n2;
592
- var f2 = n2.default;
593
- if (typeof f2 == "function") {
594
- var a2 = function a3() {
595
- if (this instanceof a3) {
596
- return Reflect.construct(f2, arguments, this.constructor);
597
- }
598
- return f2.apply(this, arguments);
599
- };
600
- a2.prototype = f2.prototype;
601
- } else a2 = {};
602
- Object.defineProperty(a2, "__esModule", { value: true });
603
- Object.keys(n2).forEach(function(k2) {
604
- var d2 = Object.getOwnPropertyDescriptor(n2, k2);
605
- Object.defineProperty(a2, k2, d2.get ? d2 : {
606
- enumerable: true,
607
- get: function() {
608
- return n2[k2];
609
- }
610
- });
611
- });
612
- return a2;
613
- }
614
- var shim$1 = { exports: {} };
615
- var useSyncExternalStoreShim_production_min$1 = {};
616
- const require$$0 = /* @__PURE__ */ getAugmentedNamespace(compat_module);
617
- /**
618
- * @license React
619
- * use-sync-external-store-shim.production.min.js
620
- *
621
- * Copyright (c) Facebook, Inc. and its affiliates.
622
- *
623
- * This source code is licensed under the MIT license found in the
624
- * LICENSE file in the root directory of this source tree.
625
- */
626
- var hasRequiredUseSyncExternalStoreShim_production_min$1;
627
- function requireUseSyncExternalStoreShim_production_min$1() {
628
- if (hasRequiredUseSyncExternalStoreShim_production_min$1) return useSyncExternalStoreShim_production_min$1;
629
- hasRequiredUseSyncExternalStoreShim_production_min$1 = 1;
630
- var e2 = require$$0;
631
- function h2(a2, b2) {
632
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
633
- }
634
- var k2 = "function" === typeof Object.is ? Object.is : h2, l2 = e2.useState, m2 = e2.useEffect, n2 = e2.useLayoutEffect, p2 = e2.useDebugValue;
635
- function q2(a2, b2) {
636
- var d2 = b2(), f2 = l2({ inst: { value: d2, getSnapshot: b2 } }), c2 = f2[0].inst, g2 = f2[1];
637
- n2(function() {
638
- c2.value = d2;
639
- c2.getSnapshot = b2;
640
- r2(c2) && g2({ inst: c2 });
641
- }, [a2, d2, b2]);
642
- m2(function() {
643
- r2(c2) && g2({ inst: c2 });
644
- return a2(function() {
645
- r2(c2) && g2({ inst: c2 });
646
- });
647
- }, [a2]);
648
- p2(d2);
649
- return d2;
650
- }
651
- function r2(a2) {
652
- var b2 = a2.getSnapshot;
653
- a2 = a2.value;
654
- try {
655
- var d2 = b2();
656
- return !k2(a2, d2);
657
- } catch (f2) {
658
- return true;
659
- }
660
- }
661
- function t2(a2, b2) {
662
- return b2();
663
- }
664
- var u2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t2 : q2;
665
- useSyncExternalStoreShim_production_min$1.useSyncExternalStore = void 0 !== e2.useSyncExternalStore ? e2.useSyncExternalStore : u2;
666
- return useSyncExternalStoreShim_production_min$1;
667
- }
668
- var useSyncExternalStoreShim_development$1 = {};
669
- /**
670
- * @license React
671
- * use-sync-external-store-shim.development.js
672
- *
673
- * Copyright (c) Facebook, Inc. and its affiliates.
674
- *
675
- * This source code is licensed under the MIT license found in the
676
- * LICENSE file in the root directory of this source tree.
677
- */
678
- var hasRequiredUseSyncExternalStoreShim_development$1;
679
- function requireUseSyncExternalStoreShim_development$1() {
680
- if (hasRequiredUseSyncExternalStoreShim_development$1) return useSyncExternalStoreShim_development$1;
681
- hasRequiredUseSyncExternalStoreShim_development$1 = 1;
682
- if (process.env.NODE_ENV !== "production") {
683
- (function() {
684
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
685
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
686
- }
687
- var React = require$$0;
688
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
689
- function error(format) {
690
- {
691
- {
692
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
693
- args[_key2 - 1] = arguments[_key2];
694
- }
695
- printWarning("error", format, args);
696
- }
697
- }
698
- }
699
- function printWarning(level, format, args) {
700
- {
701
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
702
- var stack = ReactDebugCurrentFrame.getStackAddendum();
703
- if (stack !== "") {
704
- format += "%s";
705
- args = args.concat([stack]);
706
- }
707
- var argsWithFormat = args.map(function(item) {
708
- return String(item);
709
- });
710
- argsWithFormat.unshift("Warning: " + format);
711
- Function.prototype.apply.call(console[level], console, argsWithFormat);
712
- }
713
- }
714
- function is(x2, y2) {
715
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
716
- }
717
- var objectIs = typeof Object.is === "function" ? Object.is : is;
718
- var useState = React.useState, useEffect = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
719
- var didWarnOld18Alpha = false;
720
- var didWarnUncachedGetSnapshot = false;
721
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
722
- {
723
- if (!didWarnOld18Alpha) {
724
- if (React.startTransition !== void 0) {
725
- didWarnOld18Alpha = true;
726
- error("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.");
727
- }
728
- }
729
- }
730
- var value = getSnapshot();
731
- {
732
- if (!didWarnUncachedGetSnapshot) {
733
- var cachedValue = getSnapshot();
734
- if (!objectIs(value, cachedValue)) {
735
- error("The result of getSnapshot should be cached to avoid an infinite loop");
736
- didWarnUncachedGetSnapshot = true;
737
- }
738
- }
739
- }
740
- var _useState = useState({
741
- inst: {
742
- value,
743
- getSnapshot
744
- }
745
- }), inst = _useState[0].inst, forceUpdate = _useState[1];
746
- useLayoutEffect(function() {
747
- inst.value = value;
748
- inst.getSnapshot = getSnapshot;
749
- if (checkIfSnapshotChanged(inst)) {
750
- forceUpdate({
751
- inst
752
- });
753
- }
754
- }, [subscribe, value, getSnapshot]);
755
- useEffect(function() {
756
- if (checkIfSnapshotChanged(inst)) {
757
- forceUpdate({
758
- inst
759
- });
760
- }
761
- var handleStoreChange = function() {
762
- if (checkIfSnapshotChanged(inst)) {
763
- forceUpdate({
764
- inst
765
- });
766
- }
767
- };
768
- return subscribe(handleStoreChange);
769
- }, [subscribe]);
770
- useDebugValue(value);
771
- return value;
772
- }
773
- function checkIfSnapshotChanged(inst) {
774
- var latestGetSnapshot = inst.getSnapshot;
775
- var prevValue = inst.value;
776
- try {
777
- var nextValue = latestGetSnapshot();
778
- return !objectIs(prevValue, nextValue);
779
- } catch (error2) {
780
- return true;
781
- }
782
- }
783
- function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
784
- return getSnapshot();
785
- }
786
- var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
787
- var isServerEnvironment = !canUseDOM;
788
- var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
789
- var useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim2;
790
- useSyncExternalStoreShim_development$1.useSyncExternalStore = useSyncExternalStore$2;
791
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
792
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
793
- }
794
- })();
795
- }
796
- return useSyncExternalStoreShim_development$1;
797
- }
798
- var hasRequiredShim$1;
799
- function requireShim$1() {
800
- if (hasRequiredShim$1) return shim$1.exports;
801
- hasRequiredShim$1 = 1;
802
- if (process.env.NODE_ENV === "production") {
803
- shim$1.exports = requireUseSyncExternalStoreShim_production_min$1();
804
- } else {
805
- shim$1.exports = requireUseSyncExternalStoreShim_development$1();
806
- }
807
- return shim$1.exports;
808
- }
809
- var shimExports$1 = requireShim$1();
810
- var withSelector$1 = { exports: {} };
811
- var withSelector_production_min$1 = {};
812
- /**
813
- * @license React
814
- * use-sync-external-store-shim/with-selector.production.min.js
815
- *
816
- * Copyright (c) Facebook, Inc. and its affiliates.
817
- *
818
- * This source code is licensed under the MIT license found in the
819
- * LICENSE file in the root directory of this source tree.
820
- */
821
- var hasRequiredWithSelector_production_min$1;
822
- function requireWithSelector_production_min$1() {
823
- if (hasRequiredWithSelector_production_min$1) return withSelector_production_min$1;
824
- hasRequiredWithSelector_production_min$1 = 1;
825
- var h2 = require$$0, n2 = requireShim$1();
826
- function p2(a2, b2) {
827
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
828
- }
829
- var q2 = "function" === typeof Object.is ? Object.is : p2, r2 = n2.useSyncExternalStore, t2 = h2.useRef, u2 = h2.useEffect, v2 = h2.useMemo, w2 = h2.useDebugValue;
830
- withSelector_production_min$1.useSyncExternalStoreWithSelector = function(a2, b2, e2, l2, g2) {
831
- var c2 = t2(null);
832
- if (null === c2.current) {
833
- var f2 = { hasValue: false, value: null };
834
- c2.current = f2;
835
- } else f2 = c2.current;
836
- c2 = v2(function() {
837
- function a3(a4) {
838
- if (!c3) {
839
- c3 = true;
840
- d3 = a4;
841
- a4 = l2(a4);
842
- if (void 0 !== g2 && f2.hasValue) {
843
- var b3 = f2.value;
844
- if (g2(b3, a4)) return k2 = b3;
845
- }
846
- return k2 = a4;
847
- }
848
- b3 = k2;
849
- if (q2(d3, a4)) return b3;
850
- var e3 = l2(a4);
851
- if (void 0 !== g2 && g2(b3, e3)) return b3;
852
- d3 = a4;
853
- return k2 = e3;
854
- }
855
- var c3 = false, d3, k2, m2 = void 0 === e2 ? null : e2;
856
- return [function() {
857
- return a3(b2());
858
- }, null === m2 ? void 0 : function() {
859
- return a3(m2());
860
- }];
861
- }, [b2, e2, l2, g2]);
862
- var d2 = r2(a2, c2[0], c2[1]);
863
- u2(function() {
864
- f2.hasValue = true;
865
- f2.value = d2;
866
- }, [d2]);
867
- w2(d2);
868
- return d2;
869
- };
870
- return withSelector_production_min$1;
871
- }
872
- var withSelector_development$1 = {};
873
- /**
874
- * @license React
875
- * use-sync-external-store-shim/with-selector.development.js
876
- *
877
- * Copyright (c) Facebook, Inc. and its affiliates.
878
- *
879
- * This source code is licensed under the MIT license found in the
880
- * LICENSE file in the root directory of this source tree.
881
- */
882
- var hasRequiredWithSelector_development$1;
883
- function requireWithSelector_development$1() {
884
- if (hasRequiredWithSelector_development$1) return withSelector_development$1;
885
- hasRequiredWithSelector_development$1 = 1;
886
- if (process.env.NODE_ENV !== "production") {
887
- (function() {
888
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
889
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
890
- }
891
- var React = require$$0;
892
- var shim2 = requireShim$1();
893
- function is(x2, y2) {
894
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
895
- }
896
- var objectIs = typeof Object.is === "function" ? Object.is : is;
897
- var useSyncExternalStore = shim2.useSyncExternalStore;
898
- var useRef = React.useRef, useEffect = React.useEffect, useMemo = React.useMemo, useDebugValue = React.useDebugValue;
899
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
900
- var instRef = useRef(null);
901
- var inst;
902
- if (instRef.current === null) {
903
- inst = {
904
- hasValue: false,
905
- value: null
906
- };
907
- instRef.current = inst;
908
- } else {
909
- inst = instRef.current;
910
- }
911
- var _useMemo = useMemo(function() {
912
- var hasMemo = false;
913
- var memoizedSnapshot;
914
- var memoizedSelection;
915
- var memoizedSelector = function(nextSnapshot) {
916
- if (!hasMemo) {
917
- hasMemo = true;
918
- memoizedSnapshot = nextSnapshot;
919
- var _nextSelection = selector(nextSnapshot);
920
- if (isEqual !== void 0) {
921
- if (inst.hasValue) {
922
- var currentSelection = inst.value;
923
- if (isEqual(currentSelection, _nextSelection)) {
924
- memoizedSelection = currentSelection;
925
- return currentSelection;
926
- }
927
- }
928
- }
929
- memoizedSelection = _nextSelection;
930
- return _nextSelection;
931
- }
932
- var prevSnapshot = memoizedSnapshot;
933
- var prevSelection = memoizedSelection;
934
- if (objectIs(prevSnapshot, nextSnapshot)) {
935
- return prevSelection;
936
- }
937
- var nextSelection = selector(nextSnapshot);
938
- if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
939
- return prevSelection;
940
- }
941
- memoizedSnapshot = nextSnapshot;
942
- memoizedSelection = nextSelection;
943
- return nextSelection;
944
- };
945
- var maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
946
- var getSnapshotWithSelector = function() {
947
- return memoizedSelector(getSnapshot());
948
- };
949
- var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
950
- return memoizedSelector(maybeGetServerSnapshot());
951
- };
952
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
953
- }, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
954
- var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
955
- useEffect(function() {
956
- inst.hasValue = true;
957
- inst.value = value;
958
- }, [value]);
959
- useDebugValue(value);
960
- return value;
961
- }
962
- withSelector_development$1.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
963
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
964
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
965
- }
966
- })();
967
- }
968
- return withSelector_development$1;
969
- }
970
- var hasRequiredWithSelector$1;
971
- function requireWithSelector$1() {
972
- if (hasRequiredWithSelector$1) return withSelector$1.exports;
973
- hasRequiredWithSelector$1 = 1;
974
- if (process.env.NODE_ENV === "production") {
975
- withSelector$1.exports = requireWithSelector_production_min$1();
976
- } else {
977
- withSelector$1.exports = requireWithSelector_development$1();
978
- }
979
- return withSelector$1.exports;
980
- }
981
- requireWithSelector$1();
982
- var y$1 = (t2, e2, n2) => {
983
- var _a, _b;
984
- let r2 = A$1((_a = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a.call(t2, e2, n2)), s2 = ((_b = t2 == null ? void 0 : t2.keyOfEntity) == null ? void 0 : _b.call(t2, e2)) ?? e2, u2 = q$1((o2) => {
985
- var _a2, _b2;
986
- return s2 ? (r2.current = (_a2 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a2.call(t2, s2, n2), o2(), (_b2 = t2 == null ? void 0 : t2.subscribe) == null ? void 0 : _b2.call(t2, s2, () => {
987
- var _a3;
988
- return r2.current = (_a3 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a3.call(t2, s2, n2), o2();
989
- }, n2)) : () => {
990
- };
991
- }, [t2, s2]), i2 = q$1((o2) => {
992
- let p2 = typeof e2 == "string" ? e2 : t2.keyOfEntity(e2);
993
- e2 && p2 && t2.mutate(p2, o2);
994
- }, [t2, e2]), a2 = () => r2.current;
995
- return [shimExports$1.useSyncExternalStore(u2, a2, a2), i2];
996
- };
997
- const FragmentContext = preact.createContext({
998
- manager: null
999
- });
1000
- const FragmentProvider = ({ children, manager }) => {
1001
- return /* @__PURE__ */ u$1(FragmentContext.Provider, { value: { manager }, children });
1002
- };
1003
- const useLayerChildren = (layerKey, customManager) => {
1004
- const { manager: fragmentManager } = x$1(FragmentContext);
1005
- const [layerData] = y$1(customManager ?? fragmentManager, layerKey);
1006
- return (layerData == null ? void 0 : layerData.children) ?? [];
1007
- };
1008
- var toPx = (val) => typeof val === "string" || typeof val === "number" ? `${val}px` : "0px";
1009
- var isEmptyValue = (value) => !value && (value === null || value === void 0);
1010
- var isValue = (value) => !isEmptyValue(value);
1011
- var createConstants$1 = (...constants) => {
1012
- return constants.reduce((acc, constant) => {
1013
- acc[constant] = constant;
1014
- return acc;
1015
- }, {});
1016
- };
1017
- var toKebabCase = (value) => value.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($2, ofs) => (ofs ? "-" : "") + $2.toLowerCase());
1018
- var pick = (obj, ...props) => {
1019
- return props.reduce((result, prop) => {
1020
- result[prop] = obj[prop];
1021
- return result;
1022
- }, {});
1023
- };
1024
- var generateId = () => Math.random().toString(16).slice(2);
1025
- const nodes$1 = createConstants$1(
1026
- "Fragment",
1027
- "FragmentInstance",
1028
- "Instance",
1029
- "Breakpoint",
1030
- "Frame",
1031
- "Image",
1032
- "Text",
1033
- "SolidPaintStyle",
1034
- "CssLink",
1035
- "Variable",
1036
- "ComputedValue",
1037
- "TransformValue"
1038
- );
1039
- const fragmentGrowingMode$1 = createConstants$1("auto", "fill");
1040
- const borderType$1 = createConstants$1("None", "Solid", "Dashed", "Dotted");
1041
- createConstants$1("_blank");
1042
- const paintMode$1 = createConstants$1("None", "Solid", "Image");
1043
- createConstants$1(
1044
- "Fill",
1045
- "Fit",
1046
- "Crop",
1047
- "Tile"
1048
- );
1049
- createConstants$1(
1050
- "Min",
1051
- "Center",
1052
- "Max",
1053
- "Stretch",
1054
- "Scale"
1055
- );
1056
- const positionType$1 = createConstants$1("absolute", "relative");
1057
- const sizing$1 = createConstants$1("Fixed", "Hug", "Fill", "Relative");
1058
- const layerMode$1 = createConstants$1("none", "flex");
1059
- const layerDirection$1 = createConstants$1("vertical", "horizontal");
1060
- createConstants$1("start", "center", "end");
1061
- createConstants$1(
1062
- "start",
1063
- "center",
1064
- "end",
1065
- "space-between",
1066
- "space-around"
1067
- );
1068
- createConstants$1(
1069
- "none",
1070
- "uppercase",
1071
- "lowercase",
1072
- "capitalize"
1073
- );
1074
- createConstants$1(
1075
- "none",
1076
- "underline",
1077
- "line-through"
1078
- );
1079
- createConstants$1("loop", "appear", "hover", "tap");
1080
- createConstants$1(
1081
- "fade",
1082
- "slide",
1083
- "bounce",
1084
- "wiggle",
1085
- "increase"
1086
- );
1087
- createConstants$1(
1088
- "String",
1089
- "Boolean",
1090
- "Array",
1091
- "Color",
1092
- "ComponentInstance",
1093
- "Date",
1094
- "Enum",
1095
- "Number",
1096
- "Object"
1097
- );
1098
- createConstants$1(
1099
- "normal",
1100
- "nowrap",
1101
- "pre",
1102
- "pre-wrap",
1103
- "pre-line",
1104
- "break-spaces"
1105
- );
1106
- createConstants$1("visible", "hidden", "scroll");
1107
- createConstants$1(
1108
- "convert",
1109
- "exists",
1110
- "equals",
1111
- "startWith",
1112
- "endWith",
1113
- "contains",
1114
- "dateBefore",
1115
- "dateAfter",
1116
- "dateBetween",
1117
- "feature",
1118
- "notFeature",
1119
- "gt",
1120
- // Greater than
1121
- "gte",
1122
- // Greater than or equals
1123
- "lt",
1124
- // Less than
1125
- "lte",
1126
- // Less than or equals,
1127
- "convertFromBoolean",
1128
- "negative"
1129
- );
1130
- const renderTarget$1 = createConstants$1("canvas", "document");
1131
- createConstants$1("viewport", "parent", "fixed");
1132
- var t = (e2) => !e2 && e2 == null, s = (e2) => !t(e2), y$3 = (e2) => typeof e2 == "object" && !Array.isArray(e2) && s(e2), a = (e2) => typeof Node == "object" ? e2 instanceof Node : e2 && typeof e2 == "object" && typeof e2.nodeType == "number" && typeof e2.nodeName == "string", p = (e2) => typeof e2 == "string" || n(e2), n = (e2) => typeof e2 == "object" && typeof e2._type == "string", r = (e2) => typeof e2 == "string" && e2.split(":").length >= 2, i = (e2) => typeof e2 != "object" && typeof e2 != "function" || e2 === null, b = (e2) => typeof e2 == "string" ? /<\/?[a-z][\s\S]*>/i.test(e2) : false;
1133
- var isLinkKey = (input) => r(input);
1134
- var isGraphOrKey = (input) => p(input);
1135
- var isGraph = (input) => n(input);
1136
- var isObject = (input) => y$3(input);
1137
- var shallowEqual = (a2, b2) => {
1138
- if (a2 === b2)
1139
- return true;
1140
- if (Array.isArray(a2) && Array.isArray(b2)) {
1141
- return a2.length === b2.length && a2.every((val, index2) => b2[index2] === val);
1142
- }
1143
- if (!isObject(a2) || !isObject(b2))
1144
- return false;
1145
- const keysA = Object.keys(a2);
1146
- const keysB = Object.keys(b2);
1147
- if (keysA.length !== keysB.length)
1148
- return false;
1149
- for (const key of keysA) {
1150
- if (!keysB.includes(key))
1151
- return false;
1152
- }
1153
- return true;
1154
- };
1155
- var unique = (...values) => Array.from(new Set(values));
1156
- var uniqueLinks = (...values) => values.filter((item, index2, arr) => r(item) ? arr.indexOf(item) === index2 : true);
1157
- var isPartialKey = (key) => key && key.split(".").length > 1;
1158
- var isPartOfGraph = (entityKey, graphKey) => {
1159
- if (!entityKey || !graphKey)
1160
- return false;
1161
- if (typeof entityKey !== "string" || typeof graphKey !== "string")
1162
- return null;
1163
- const [entityType, entityId] = entityKey.split(":");
1164
- const [graphType, graphId] = graphKey.split(":");
1165
- if (entityType !== graphType)
1166
- return false;
1167
- return entityId.startsWith(graphId);
1168
- };
1169
- var getGraphLink = (input) => {
1170
- if (isLinkKey(input)) {
1171
- if (isPartialKey(input)) {
1172
- return input.split(".")[0];
1173
- }
1174
- }
1175
- return input;
1176
- };
1177
- var createCache = () => {
1178
- const listeners = /* @__PURE__ */ new Map();
1179
- const types = /* @__PURE__ */ new Map();
1180
- const links = /* @__PURE__ */ new Map();
1181
- const parentRefs = /* @__PURE__ */ new Map();
1182
- const childrenRefs = /* @__PURE__ */ new Map();
1183
- const refCount = /* @__PURE__ */ new Map();
1184
- const gbLinks = /* @__PURE__ */ new Set([]);
1185
- const addRefs = (targetKey, depKey) => {
1186
- var _a;
1187
- parentRefs.set(targetKey, unique(...parentRefs.get(targetKey) || [], depKey));
1188
- childrenRefs.set(depKey, unique(...childrenRefs.get(depKey) ?? [], targetKey));
1189
- updateRefCountForLink(targetKey, ((_a = parentRefs.get(targetKey)) == null ? void 0 : _a.length) || 0);
1190
- };
1191
- const removeRefs = (targetKey, depKey) => {
1192
- var _a;
1193
- parentRefs.set(
1194
- depKey,
1195
- (parentRefs.get(depKey) || []).filter((key) => key !== targetKey)
1196
- );
1197
- childrenRefs.set(
1198
- targetKey,
1199
- (childrenRefs.get(targetKey) ?? []).filter((key) => key !== depKey)
1200
- );
1201
- updateRefCountForLink(depKey, ((_a = parentRefs.get(depKey)) == null ? void 0 : _a.length) || 0);
1202
- };
1203
- const getLinkedRefs = (key, stack = []) => {
1204
- const deps = parentRefs.get(key) || [];
1205
- stack.push(...deps);
1206
- const deepDeps = deps.map((ref) => getLinkedRefs(ref, stack)).flat();
1207
- stack.push(...deepDeps);
1208
- return Array.from(new Set(stack).values());
1209
- };
1210
- const invalidate = (key) => {
1211
- updateRefCountForLink(key, 0);
1212
- runGarbageCollector();
1213
- };
1214
- const readLink = (key) => {
1215
- if (key) {
1216
- return links.get(key);
1217
- }
1218
- return null;
1219
- };
1220
- const writeLink = (key, value, depKey) => {
1221
- var _a;
1222
- if (typeof key === "string") {
1223
- links.set(key, value);
1224
- const [type] = key.split(":");
1225
- if (!isPartialKey(key)) {
1226
- if (!types.has(type)) {
1227
- types.set(type, /* @__PURE__ */ new Set([key]));
1228
- } else {
1229
- (_a = types.get(type)) == null ? void 0 : _a.add(key);
1230
- }
1231
- }
1232
- }
1233
- if (depKey && key && key !== depKey) {
1234
- addRefs(key, depKey);
1235
- }
1236
- };
1237
- const hasLink = (key) => {
1238
- if (key) {
1239
- return links.has(key);
1240
- }
1241
- return false;
1242
- };
1243
- const updateRefCountForLink = (link, count) => {
1244
- if (Array.isArray(link)) {
1245
- link.forEach((link2, index2) => updateRefCountForLink(link2, index2));
1246
- } else {
1247
- const prevCount = refCount.get(link);
1248
- refCount.set(link, count);
1249
- if (!count) {
1250
- gbLinks.add(link);
1251
- } else if (!prevCount && count) {
1252
- gbLinks.delete(link);
1253
- }
1254
- }
1255
- };
1256
- const getLinkEntries = () => Array.from(links.entries());
1257
- const getRefCount = (link) => refCount.get(link) ?? 0;
1258
- const runGarbageCollector = () => {
1259
- var _a, _b;
1260
- for (const link of gbLinks.keys()) {
1261
- const count = getRefCount(link);
1262
- if (count > 0)
1263
- continue;
1264
- const currentValue = links.get(link);
1265
- gbLinks.delete(link);
1266
- links.delete(link);
1267
- refCount.delete(link);
1268
- const parents = parentRefs.get(link) ?? [];
1269
- const children = childrenRefs.get(link) ?? [];
1270
- parents.forEach((parentKey) => {
1271
- var _a2, _b2;
1272
- childrenRefs.set(parentKey, ((_b2 = (_a2 = childrenRefs.get(parentKey)) == null ? void 0 : _a2.filter) == null ? void 0 : _b2.call(_a2, (childLink) => childLink !== link)) ?? []);
1273
- });
1274
- children.forEach((childKey) => {
1275
- updateRefCountForLink(childKey, getRefCount(childKey) - 1);
1276
- });
1277
- const [type] = link.split(":");
1278
- if (!isPartialKey(link)) {
1279
- (_a = types.get(type)) == null ? void 0 : _a.delete(link);
1280
- if (!((_b = types.get(type)) == null ? void 0 : _b.size)) {
1281
- types.delete(type);
1282
- }
1283
- }
1284
- parentRefs.delete(link);
1285
- (listeners.get("onRemoveLink") ?? []).forEach((listener) => listener(link, currentValue ?? null));
1286
- }
1287
- };
1288
- return {
1289
- readLink,
1290
- writeLink,
1291
- hasLink,
1292
- getLinkEntries,
1293
- parentRefs,
1294
- childrenRefs,
1295
- addRefs,
1296
- removeRefs,
1297
- getChildren: (key) => childrenRefs.get(key),
1298
- getParents: (key) => parentRefs.get(key),
1299
- getLinkedRefs,
1300
- invalidate,
1301
- links,
1302
- types,
1303
- refCount,
1304
- runGarbageCollector,
1305
- onRemoveLink: (callback) => listeners.set("onRemoveLink", [...(listeners == null ? void 0 : listeners.get("onRemoveLink")) ?? [], callback])
1306
- };
1307
- };
1308
- var joinKeys = (...keys) => {
1309
- var _a;
1310
- return (_a = keys == null ? void 0 : keys.filter(Boolean)) == null ? void 0 : _a.join(".");
1311
- };
1312
- var isDev = process.env.NODE_ENV !== "production";
1313
- var createPluginsState = (initialPlugins = []) => {
1314
- const plugins = [];
1315
- const use = (plugin) => {
1316
- plugins.push(plugin);
1317
- };
1318
- const runPlugins = (state) => {
1319
- return plugins.reduce((graphState, plugin) => plugin(graphState) ?? graphState, state);
1320
- };
1321
- initialPlugins.forEach(use);
1322
- return {
1323
- use,
1324
- runPlugins
1325
- };
1326
- };
1327
- var isGraphState = (input) => {
1328
- if (!input)
1329
- return false;
1330
- if (isObject(input)) {
1331
- const fields = ["_id", "_type", "key", "mutate", "resolve"];
1332
- return fields.every((field) => field in input);
1333
- }
1334
- return false;
1335
- };
1336
- var createDebugState = () => {
1337
- const listeners = /* @__PURE__ */ new Set();
1338
- const onDebugEvent = (callback) => {
1339
- listeners.add(callback);
1340
- };
1341
- const debug = (event) => {
1342
- listeners.forEach((callback) => {
1343
- callback({ ...event, timestamp: Date.now() });
1344
- });
1345
- };
1346
- return {
1347
- debug,
1348
- onDebugEvent
1349
- };
1350
- };
1351
- var ID = 0;
1352
- var DEEP_LIMIT = 100;
1353
- var STATE_TYPE = "State";
1354
- var EACH_UPDATED = "$EACH:ROOT$";
1355
- var createState = (options2) => {
1356
- const id = (options2 == null ? void 0 : options2._id) ?? `${ID++}`;
1357
- const type = (options2 == null ? void 0 : options2._type) ?? STATE_TYPE;
1358
- const keys = (options2 == null ? void 0 : options2.keys) ?? {};
1359
- const stateKey = `${type}:${id}`;
1360
- const skipPredictors = [isGraphState, ...(options2 == null ? void 0 : options2.skip) ?? []];
1361
- const cache = createCache();
1362
- const debugState = createDebugState();
1363
- const pluginsStore = createPluginsState(options2 == null ? void 0 : options2.plugins);
1364
- const subscribers = /* @__PURE__ */ new Map();
1365
- let deepIndex = 0;
1366
- const isSkipped = (entity) => {
1367
- return skipPredictors.some((predictor) => predictor(entity));
1368
- };
1369
- const resolve = (input, options22) => {
1370
- const isDeep = (options22 == null ? void 0 : options22.deep) ?? false;
1371
- const isSafe = (options22 == null ? void 0 : options22.safe) ?? false;
1372
- const { selector, ...coreOptions } = options22 || {};
1373
- const inputKey = s(input) ? keyOfEntity(input) : null;
1374
- debugState.debug({ type: "resolve", entity: input, options: options22 });
1375
- let value = inputKey ? cache.readLink(inputKey) : null;
1376
- if (isSkipped(value))
1377
- return value;
1378
- if (isObject(value) || Array.isArray(value)) {
1379
- value = Object.entries(value).reduce((acc, [key, value2]) => {
1380
- let resultValue = value2;
1381
- if (!isSkipped(resultValue)) {
1382
- if (Array.isArray(value2)) {
1383
- resultValue = value2.map((v2) => {
1384
- if (isSkipped(v2))
1385
- return v2;
1386
- if (isLinkKey(v2) && !isSafe && !cache.hasLink(v2)) {
1387
- return null;
1388
- }
1389
- return isPartOfGraph(v2, inputKey) || isDeep ? safeResolve(v2, coreOptions) : v2;
1390
- });
1391
- if (!isSafe) {
1392
- resultValue = resultValue.filter(s);
1393
- }
1394
- } else {
1395
- if (isLinkKey(value2) && !isSafe && !cache.hasLink(value2)) {
1396
- resultValue = null;
1397
- } else if (isPartOfGraph(keyOfEntity(value2), inputKey) || isDeep) {
1398
- resultValue = safeResolve(value2, coreOptions);
1399
- }
1400
- }
1401
- }
1402
- acc[key] = resultValue;
1403
- return acc;
1404
- }, {});
1405
- }
1406
- return value ? selector ? selector({ ...value }) : { ...value } : isSafe ? input : null;
1407
- };
1408
- const safeResolve = (input, options22) => resolve(input, options22) ?? input;
1409
- const unlinkGraph = (entity) => {
1410
- const graphKey = keyOfEntity(entity);
1411
- if (graphKey) {
1412
- const deps = cache.getChildren(graphKey) || [];
1413
- deps.forEach((depLink) => {
1414
- if (!isPartialKey(depLink)) {
1415
- cache.removeRefs(graphKey, depLink);
1416
- }
1417
- });
1418
- }
1419
- };
1420
- const mutateField = (input, parentFieldKey, options22) => {
1421
- var _a, _b, _c, _d;
1422
- if ((!input || i(input)) && !isLinkKey(input) || isSkipped(input)) {
1423
- return input;
1424
- }
1425
- const inputLinkKey = isGraphOrKey(input) ? keyOfEntity(input) : input;
1426
- if (isLinkKey(inputLinkKey)) {
1427
- const parentGraph = getGraphLink(parentFieldKey) ?? "";
1428
- const parentPaths = ((_a = options22 == null ? void 0 : options22.internal) == null ? void 0 : _a.visitors.get(parentGraph)) ?? [];
1429
- const visitorsPaths = ((_b = options22 == null ? void 0 : options22.internal) == null ? void 0 : _b.visitors.get(inputLinkKey)) ?? [];
1430
- if (parentPaths.includes(inputLinkKey) || inputLinkKey === parentGraph) {
1431
- return null;
1432
- }
1433
- (_d = (_c = options22 == null ? void 0 : options22.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(inputLinkKey, [...visitorsPaths, parentGraph]);
1434
- }
1435
- if (Array.isArray(input)) {
1436
- return input.map((item, index2) => {
1437
- const indexKey = parentFieldKey ? joinKeys(parentFieldKey, `${index2}`) : void 0;
1438
- return mutateField(item, indexKey, options22);
1439
- });
1440
- }
1441
- const entityKey = isLinkKey(input) ? input : isGraph(input) ? keyOfEntity(input) : null;
1442
- const childKey = entityKey ?? parentFieldKey;
1443
- const mutateMethod = (options22 == null ? void 0 : options22.overrideMutateMethod) || mutate;
1444
- return mutateMethod(childKey, input, options22);
1445
- };
1446
- const mutate = (entity, ...args) => {
1447
- const { graphKey: entityGraphKey, options: options22, data: rawData } = getArgumentsForMutate(entity, ...args);
1448
- debugState.debug({ type: "beforeMutate", entity: entityGraphKey, data: rawData, options: options22 });
1449
- const data = isLinkKey(rawData) ? entityOfKey(rawData) : rawData;
1450
- const graphKey = entityGraphKey ?? stateKey;
1451
- const partialKey = isPartialKey == null ? void 0 : isPartialKey(graphKey);
1452
- const parentKey = options22 == null ? void 0 : options22.parent;
1453
- const prevGraph = resolve(graphKey ?? "");
1454
- const internal = (options22 == null ? void 0 : options22.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]), updatedFields: [] };
1455
- let graphData = {
1456
- ...data,
1457
- ...entityOfKey(graphKey)
1458
- };
1459
- const isTopLevelGraph = !(options22 == null ? void 0 : options22.parent);
1460
- const isReplace = (options22 == null ? void 0 : options22.replace) ? typeof (options22 == null ? void 0 : options22.replace) === "function" ? options22.replace(graphData) : (options22 == null ? void 0 : options22.replace) === "deep" ? true : isTopLevelGraph || partialKey : false;
1461
- if (isSkipped(data)) {
1462
- cache.writeLink(graphKey, data, parentKey);
1463
- return graphKey;
1464
- }
1465
- if (!isReplace && isObject(prevGraph) && isObject(graphData)) {
1466
- graphData = {
1467
- ...prevGraph,
1468
- ...graphData
1469
- };
1470
- }
1471
- if (isReplace) {
1472
- unlinkGraph(graphKey);
1473
- }
1474
- const nextGraph = Object.entries(graphData).reduce((acc, [key, value]) => {
1475
- const fieldKey = joinKeys(graphKey, key);
1476
- let fieldValue = value;
1477
- const prevValue = prevGraph == null ? void 0 : prevGraph[key];
1478
- if (!isSkipped(fieldValue)) {
1479
- if (isObject(fieldValue) || Array.isArray(fieldValue) || isLinkKey(fieldValue)) {
1480
- fieldValue = mutateField(fieldValue, fieldKey, {
1481
- ...options22,
1482
- parent: graphKey,
1483
- internal
1484
- });
1485
- }
1486
- if (!isReplace && Array.isArray(fieldValue) && Array.isArray(prevValue)) {
1487
- fieldValue = [...prevValue, ...fieldValue];
1488
- }
1489
- if (Array.isArray(fieldValue) && (options22 == null ? void 0 : options22.dedup) !== false) {
1490
- fieldValue = uniqueLinks(...fieldValue);
1491
- }
1492
- }
1493
- const isEqual = shallowEqual(prevValue, fieldKey === fieldValue ? safeResolve(fieldValue) : fieldValue);
1494
- internal.hasChange = internal.hasChange || !isEqual;
1495
- if ((!parentKey || partialKey) && !isEqual) {
1496
- internal.updatedFields.push(partialKey ? graphKey : key);
1497
- }
1498
- if (!isReplace && isLinkKey(prevValue) && prevValue !== fieldValue) {
1499
- cache.removeRefs(graphKey, prevValue);
1500
- }
1501
- acc[key] = fieldValue;
1502
- return acc;
1503
- }, {});
1504
- cache.writeLink(graphKey, nextGraph, parentKey);
1505
- if (!parentKey) {
1506
- cache.runGarbageCollector();
1507
- }
1508
- if (internal.hasChange) {
1509
- notify(graphKey, prevGraph, internal.updatedFields);
1510
- }
1511
- debugState.debug({
1512
- type: "afterMutate",
1513
- entity: entityGraphKey,
1514
- data: rawData,
1515
- nextData: nextGraph,
1516
- options: options22,
1517
- hasChange: internal.hasChange
1518
- });
1519
- return graphKey;
1520
- };
1521
- const invalidate = (entity) => {
1522
- const key = keyOfEntity(entity);
1523
- debugState.debug({ type: "invalidate", entity: key });
1524
- if (key) {
1525
- const parents = cache.getParents(key) || [];
1526
- cache.invalidate(key);
1527
- parents.forEach((parentKey) => {
1528
- const prevParent = cache.readLink(parentKey);
1529
- const freshParent = resolve(parentKey, { safe: false });
1530
- cache.writeLink(parentKey, freshParent);
1531
- notify(parentKey, prevParent);
1532
- });
1533
- }
1534
- };
1535
- const notify = (entity, prevState, updatedFields = []) => {
1536
- var _a;
1537
- if (deepIndex > DEEP_LIMIT) {
1538
- throw new Error("Too deep notify.");
1539
- }
1540
- const key = keyOfEntity(entity);
1541
- debugState.debug({ type: "notify", entity: key });
1542
- if (key) {
1543
- deepIndex++;
1544
- const subs = subscribers.get(key) || [];
1545
- const deps = cache.getChildren(key) || [];
1546
- const nextResult = resolve(key);
1547
- const getSelectedValues = (selector) => {
1548
- const next = nextResult && (selector == null ? void 0 : selector(nextResult));
1549
- const prev = prevState && (selector == null ? void 0 : selector(prevState));
1550
- const hasChange = !!next !== !!prev || updatedFields.some((key2) => key2 in next);
1551
- return { next, prev, hasChange };
1552
- };
1553
- (_a = subscribers.get(EACH_UPDATED)) == null ? void 0 : _a.forEach(({ callback, selector }) => {
1554
- if (selector) {
1555
- const { next, prev, hasChange } = getSelectedValues(selector);
1556
- if (hasChange)
1557
- callback(next, prev);
1558
- } else {
1559
- callback(nextResult, prevState);
1560
- }
1561
- });
1562
- subs.forEach(({ callback, selector }) => {
1563
- if (selector) {
1564
- const { next, prev, hasChange } = getSelectedValues(selector);
1565
- if (hasChange)
1566
- callback(next, prev);
1567
- } else {
1568
- callback(nextResult, prevState);
1569
- }
1570
- });
1571
- deps.forEach((dep) => notify(dep, prevState));
1572
- }
1573
- deepIndex = 0;
1574
- };
1575
- const subscribe = (...args) => {
1576
- const input = typeof args[0] === "function" ? EACH_UPDATED : args[0];
1577
- const callback = typeof args[0] === "function" ? args[0] : args[1];
1578
- const options22 = typeof args[0] === "function" ? args[1] : args[2];
1579
- const key = keyOfEntity(input);
1580
- const selector = options22 == null ? void 0 : options22.selector;
1581
- if (key) {
1582
- if (subscribers.has(key)) {
1583
- subscribers.set(key, [...Array.from(subscribers.get(key) || []), { callback, selector }]);
1584
- } else {
1585
- subscribers.set(key, [{ callback, selector }]);
1586
- }
1587
- cache.onRemoveLink((link, prevValue) => {
1588
- if (link === key) {
1589
- notify(key, prevValue);
1590
- }
1591
- });
1592
- }
1593
- const unsubscribe = () => {
1594
- if (key) {
1595
- const subIndex = (subscribers.get(key) || []).findIndex((sub) => sub.callback === callback);
1596
- if (subIndex !== -1) {
1597
- const nextSubscribers = subscribers.get(key) || [];
1598
- nextSubscribers.splice(subIndex, 1);
1599
- subscribers.set(key, nextSubscribers);
1600
- }
1601
- }
1602
- };
1603
- if (options22 == null ? void 0 : options22.signal) {
1604
- options22.signal.addEventListener("abort", unsubscribe, { once: true });
1605
- }
1606
- return unsubscribe;
1607
- };
1608
- const inspectFields = (graphType) => [...cache.types.get(graphType) ?? []];
1609
- const resolveParents = (field) => {
1610
- const key = (typeof field === "string" ? field : keyOfEntity(field)) || "";
1611
- const refs = cache.getParents(key) ?? [];
1612
- return refs.map((ref) => resolve(ref));
1613
- };
1614
- const keyOfEntity = (entity) => {
1615
- var _a;
1616
- if (typeof entity === "string") {
1617
- return entityOfKey(entity) ? entity : null;
1618
- }
1619
- if (!(entity == null ? void 0 : entity._type)) {
1620
- return null;
1621
- }
1622
- let entityId = null;
1623
- if (entity._type in keys) {
1624
- entityId = ((_a = keys[entity._type]) == null ? void 0 : _a.call(keys, entity)) ?? null;
1625
- } else if (s(entity.id) || s(entity._id)) {
1626
- entityId = `${entity.id ?? entity._id}`;
1627
- }
1628
- return !entityId ? entityId : `${entity._type}:${entityId}`;
1629
- };
1630
- const entityOfKey = (entity) => {
1631
- if (isObject(entity) && (entity == null ? void 0 : entity._type) && keyOfEntity(entity)) {
1632
- return entity;
1633
- }
1634
- if (!entity || typeof entity !== "string")
1635
- return null;
1636
- const [typeName, ...restTypes] = entity.split(":");
1637
- if (!typeName || restTypes.length < 1)
1638
- return null;
1639
- return {
1640
- _type: typeName,
1641
- _id: restTypes.join(":")
1642
- };
1643
- };
1644
- const getArgumentsForMutate = (entity, ...args) => {
1645
- let data = typeof entity === "string" ? args[0] : entity;
1646
- if (typeof data === "function") {
1647
- data = data(resolve(entity));
1648
- } else if (isLinkKey(data)) {
1649
- data = entityOfKey(data);
1650
- }
1651
- return {
1652
- graphKey: typeof entity === "string" ? entity : keyOfEntity(entity),
1653
- options: typeof entity === "string" ? args[1] : args[0],
1654
- data
1655
- };
1656
- };
1657
- if (options2 == null ? void 0 : options2.initialState) {
1658
- mutate(options2.initialState, { replace: true });
1659
- }
1660
- const graphState = {
1661
- _type: type,
1662
- _id: id,
1663
- key: stateKey,
1664
- mutate,
1665
- subscribe,
1666
- resolve,
1667
- safeResolve,
1668
- resolveParents,
1669
- inspectFields,
1670
- invalidate,
1671
- keyOfEntity,
1672
- entityOfKey,
1673
- getArgumentsForMutate,
1674
- types: cache.types,
1675
- cache,
1676
- subscribers: isDev ? subscribers : void 0,
1677
- onDebugEvent: debugState.onDebugEvent
1678
- };
1679
- cache.onRemoveLink((link, prevValue) => debugState.debug({ type: "garbageRemove", entity: link, prevValue }));
1680
- return pluginsStore.runPlugins(graphState);
1681
- };
1682
- const createManager = (fragmentKey, initialDocument = {}) => {
1683
- const tempGraph = {
1684
- _type: "Temp",
1685
- _id: "root"
1686
- };
1687
- const springGraph = {
1688
- _type: "Spring",
1689
- _id: "root"
1690
- };
1691
- const manager = createState({
1692
- _type: "FragmentManager",
1693
- initialState: initialDocument,
1694
- plugins: [
1695
- (state) => {
1696
- state.$fragment = {
1697
- root: fragmentKey,
1698
- temp: "Temp:root"
1699
- };
1700
- }
1701
- ],
1702
- skip: [b, a]
1703
- });
1704
- manager.mutate(tempGraph);
1705
- manager.mutate(springGraph);
1706
- return manager;
1707
- };
1708
- const getFragmentQuery = (isSelf) => `
1709
- query FragmentDocument($fragmentSlug: Int!) {
1710
- ${isSelf ? "fragment" : "fragmentClient"}(fragmentIds: [$fragmentSlug]) {
1711
- id
1712
- document
1713
- linkedFragments {
1714
- id
1715
- document
1716
- }
1717
- }
1718
- }
1719
- `;
1720
- const getEmptyFragment = (fragmentId) => {
1721
- const layerId = generateId();
1722
- return {
1723
- [`Fragment:${fragmentId}`]: {
1724
- _type: "Fragment",
1725
- _id: fragmentId,
1726
- children: [`Frame:${layerId}`],
1727
- layoutSizingHorizontal: "Fixed",
1728
- layoutSizingVertical: "Fixed",
1729
- horizontalGrow: "auto",
1730
- verticalGrow: "auto",
1731
- renderMode: "parent",
1732
- opacity: 1,
1733
- visible: true,
1734
- overflow: "hidden",
1735
- overrides: [],
1736
- properties: ["Variable:62218c840bd111"]
1737
- },
1738
- [`Frame:${layerId}`]: {
1739
- _type: "Frame",
1740
- _id: layerId,
1741
- opacity: 1,
1742
- visible: true,
1743
- overflow: "visible",
1744
- children: [],
1745
- width: 320,
1746
- height: 200,
1747
- layoutSizingHorizontal: "Fixed",
1748
- layoutSizingVertical: "Fixed",
1749
- fillType: "Solid",
1750
- positionType: "absolute",
1751
- solidFill: "rgba(255, 255, 255, 1)",
1752
- name: "Frame",
1753
- isPrimary: true,
1754
- threshold: 320
1755
- }
1756
- };
1757
- };
1758
- const BASE_HEADERS = {
1759
- "Content-Type": "application/json"
1760
- };
1761
- const createFetcher = (baseUrl, defaultHeaders = {}) => {
1762
- const cache = /* @__PURE__ */ new Map();
1763
- const inflightRequests = /* @__PURE__ */ new Map();
1764
- const getCacheKey = (query2, variables, options2) => JSON.stringify({ query: query2, variables, options: options2 });
1765
- const query = async (query2, variables = {}, options2 = {}) => {
1766
- const cacheKey = getCacheKey(query2, variables, options2);
1767
- if (cache.has(cacheKey)) {
1768
- return cache.get(cacheKey);
1769
- }
1770
- if (inflightRequests.has(cacheKey)) {
1771
- return inflightRequests.get(cacheKey);
1772
- }
1773
- const request = fetch(baseUrl, {
1774
- ...options2,
1775
- method: "POST",
1776
- body: JSON.stringify({ query: query2, variables }),
1777
- headers: {
1778
- ...BASE_HEADERS,
1779
- ...defaultHeaders,
1780
- ...options2.headers
1781
- }
1782
- }).then(async (res) => {
1783
- if (!res.ok) throw new Error(`Fetch error: ${res.status}`);
1784
- const data = await res.json();
1785
- cache.set(cacheKey, data);
1786
- return data;
1787
- }).finally(() => {
1788
- inflightRequests.delete(cacheKey);
1789
- });
1790
- inflightRequests.set(cacheKey, request);
1791
- return request;
1792
- };
1793
- const invalidate = (endpoint, options2) => {
1794
- cache.delete(getCacheKey(endpoint, options2));
1795
- };
1796
- const clearCache = () => cache.clear();
1797
- return { query, invalidate, clearCache };
1798
- };
1799
- const createFetchManager = (apiToken, isSelf) => {
1800
- const fetcher = createFetcher("http://localhost/graphql", {
1801
- Authorization: `Bearer ${apiToken}`
1802
- });
1803
- return createState({
1804
- initialState: {},
1805
- plugins: [
1806
- (state) => {
1807
- state.cacheDocuments = /* @__PURE__ */ new Map();
1808
- state.queryFragment = async (fragmentId) => {
1809
- var _a, _b;
1810
- if (state.cacheDocuments.has(fragmentId)) {
1811
- return state.cacheDocuments.get(fragmentId);
1812
- }
1813
- const response = await fetcher.query(getFragmentQuery(isSelf), {
1814
- fragmentSlug: fragmentId
1815
- });
1816
- const fragment2 = (_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.fragment) == null ? void 0 : _b[0];
1817
- let fragmentDocument = fragment2 == null ? void 0 : fragment2.document;
1818
- if (typeof fragmentDocument === "string") {
1819
- try {
1820
- if (Object.keys(JSON.parse(fragmentDocument)).length === 0) {
1821
- fragmentDocument = getEmptyFragment(fragmentId);
1822
- }
1823
- } catch (e2) {
1824
- console.error(e2);
1825
- }
1826
- }
1827
- if (fragment2) {
1828
- state.cacheDocuments.set(fragmentId, fragmentDocument);
1829
- if (Array.isArray(fragment2.linkedFragments)) {
1830
- fragment2.linkedFragments.forEach(
1831
- (linkedFragment) => state.cacheDocuments.set(
1832
- linkedFragment.id,
1833
- linkedFragment.document
1834
- )
1835
- );
1836
- }
1837
- return state.cacheDocuments.get(fragmentId);
1838
- }
1839
- return null;
1840
- };
1841
- }
1842
- ]
1843
- });
1844
- };
1845
- const createGlobalManager = ({ apiToken, isSelf } = {}) => createState({
1846
- _type: "GlobalManager",
1847
- initialState: {
1848
- fetchManager: createFetchManager(apiToken, isSelf),
1849
- fragmentsManagers: {},
1850
- renderTarget: renderTarget$1.canvas
1851
- },
1852
- plugins: [
1853
- (state) => {
1854
- state.createFragmentManager = (fragmentId, document2) => {
1855
- var _a, _b;
1856
- const currentManager = (_b = (_a = state.resolve(state.key)) == null ? void 0 : _a.fragmentsManagers) == null ? void 0 : _b[fragmentId];
1857
- if (currentManager) {
1858
- return currentManager;
1859
- }
1860
- const manager = createManager(
1861
- `${nodes$1.Fragment}:${fragmentId}`,
1862
- document2
1863
- );
1864
- state.mutate(state.key, {
1865
- fragmentsManagers: {
1866
- [fragmentId]: manager
1867
- }
1868
- });
1869
- return manager;
1870
- };
1871
- state.setRenderTarget = (value) => {
1872
- state.mutate(state.key, {
1873
- renderTarget: value
1874
- });
1875
- };
1876
- }
1877
- ]
1878
- });
1879
- let GLOBAL_MANAGER = createGlobalManager();
1880
- const getGlobalManager = () => GLOBAL_MANAGER;
1881
- const GlobalManager$1 = preact.createContext(getGlobalManager());
1882
- const useGlobalManager$1 = (globalManager) => {
1883
- const currentGlobalManager = x$1(GlobalManager$1);
1884
- const resultManager = globalManager ?? currentGlobalManager;
1885
- const [globalManagerGraph] = y$1(resultManager, resultManager == null ? void 0 : resultManager.key);
1886
- const getFragmentManager = async (id) => {
1887
- const fragmentDocument = await globalManagerGraph.fetchManager.queryFragment(id);
1888
- return resultManager.createFragmentManager(id, fragmentDocument);
1889
- };
1890
- const setRenderTarget = (value) => {
1891
- resultManager == null ? void 0 : resultManager.setRenderTarget(value);
1892
- };
1893
- return {
1894
- globalManagerGraph,
1895
- manager: resultManager,
1896
- getFragmentManager,
1897
- setRenderTarget
1898
- };
1899
- };
1900
- const useRenderTarget$1 = (globalManager) => {
1901
- const { globalManagerGraph, setRenderTarget } = useGlobalManager$1(globalManager);
1902
- const renderTargetValue = (globalManagerGraph == null ? void 0 : globalManagerGraph.renderTarget) ?? renderTarget$1.canvas;
1903
- return {
1904
- renderTarget: renderTargetValue,
1905
- isCanvas: renderTargetValue === renderTarget$1.canvas,
1906
- isDocument: renderTargetValue === renderTarget$1.document,
1907
- setRenderTarget: (target) => {
1908
- setRenderTarget(target);
1909
- }
1910
- };
1911
- };
1912
- const findBreakpoint = (breakpoints = [], width) => {
1913
- if (!(breakpoints == null ? void 0 : breakpoints.length)) return null;
1914
- const sortBreakpoints = breakpoints.toSorted(
1915
- (a2, b2) => a2.threshold - b2.threshold
1916
- );
1917
- return sortBreakpoints.reduce(
1918
- (prev, curr) => width >= curr.threshold ? curr : prev
1919
- );
1920
- };
1921
- const useFragmentManager$1 = (fragmentId, globalContext) => {
1922
- const { globalManagerGraph, manager } = useGlobalManager$1(globalContext);
1923
- if (!globalManagerGraph) {
1924
- throw new Error("Need declare global context");
1925
- }
1926
- const [loading, setLoading] = d(false);
1927
- const getFragmentManager = (id) => {
1928
- var _a;
1929
- return (_a = globalManagerGraph == null ? void 0 : globalManagerGraph.fragmentsManagers) == null ? void 0 : _a[id];
1930
- };
1931
- const loadFragmentManager = async (id) => {
1932
- setLoading(true);
1933
- const fragmentDocument = await globalManagerGraph.fetchManager.queryFragment(id);
1934
- const res = manager == null ? void 0 : manager.createFragmentManager(id, fragmentDocument);
1935
- setLoading(false);
1936
- return res;
1937
- };
1938
- y$2(() => {
1939
- loadFragmentManager(fragmentId);
1940
- }, [fragmentId]);
1941
- return {
1942
- loading,
1943
- manager: getFragmentManager(fragmentId)
1944
- };
1945
- };
1946
- const useFragment = (fragmentId, globalManager) => {
1947
- const { manager } = useFragmentManager$1(fragmentId, globalManager);
1948
- const layerKey = `${nodes$1.Fragment}:${fragmentId}`;
1949
- const [ref, fragmentRect] = j();
1950
- const children = useLayerChildren(layerKey, manager);
1951
- const { isDocument } = useRenderTarget$1(globalManager);
1952
- const resultChildren = T$1(() => {
1953
- if (isDocument && manager) {
1954
- const breakpoints = children == null ? void 0 : children.map(manager.resolve);
1955
- const activeBreakpoint = findBreakpoint(breakpoints, fragmentRect.width);
1956
- return activeBreakpoint ? [manager.keyOfEntity(activeBreakpoint)] : [];
1957
- }
1958
- return children;
1959
- }, [children, manager, fragmentRect.width]);
1960
- return {
1961
- manager,
1962
- ref,
1963
- children: resultChildren
1964
- };
1965
- };
1966
- const fragment = "_fragment_wbfy9_1";
1967
- const styles = {
1968
- fragment
1969
- };
1970
- const isVariableLink = (value) => {
1971
- var _a;
1972
- return isLink(value) && ((_a = value == null ? void 0 : value.split(":")) == null ? void 0 : _a.at(0)) === nodes$1.Variable;
1973
- };
1974
- const isLink = (value) => {
1975
- var _a, _b;
1976
- return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
1977
- };
1978
- const useFragmentProperties$1 = (fragmentId) => {
1979
- var _a;
1980
- const { manager } = useFragmentManager$1(fragmentId);
1981
- const [instanceFragment] = y$1(manager, (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root);
1982
- return {
1983
- properties: (instanceFragment == null ? void 0 : instanceFragment.properties) ?? [],
1984
- manager
1985
- };
1986
- };
1987
- const useInstance = (instanceProps) => {
1988
- const { manager: parentManager } = x$1(FragmentContext);
1989
- const [instanceLayer] = y$1(parentManager, instanceProps.layerKey);
1990
- const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
1991
- const styles2 = useLayerStyles(instanceProps.layerKey);
1992
- const { manager: resultGlobalManager } = useGlobalManager$1(
1993
- instanceProps == null ? void 0 : instanceProps.globalManager
1994
- );
1995
- const resultProps = { ...instanceLayerProps, ...instanceProps.props ?? {} };
1996
- const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
1997
- const { properties: definitions2, manager: innerFragmentManager } = useFragmentProperties$1(resultFragmentId);
1998
- return {
1999
- styles: styles2,
2000
- definitions: definitions2,
2001
- props: resultProps,
2002
- parentManager,
2003
- innerManager: innerFragmentManager,
2004
- fragmentId: resultFragmentId,
2005
- globalManager: resultGlobalManager
2006
- };
2007
- };
2008
- const InstanceContext = preact.createContext({
2009
- layerKey: null,
2010
- parentManager: null,
2011
- innerManager: null,
2012
- props: {},
2013
- definitions: []
2014
- });
2015
- const Instance$1 = (instanceProps) => {
2016
- const {
2017
- styles: styles2,
2018
- fragmentId,
2019
- parentManager,
2020
- props,
2021
- innerManager,
2022
- definitions: definitions2,
2023
- globalManager
2024
- } = useInstance(instanceProps);
2025
- return /* @__PURE__ */ u$1(
2026
- InstanceContext,
2027
- {
2028
- value: {
2029
- layerKey: instanceProps.layerKey,
2030
- definitions: definitions2,
2031
- innerManager,
2032
- parentManager,
2033
- props
2034
- },
2035
- children: parentManager ? /* @__PURE__ */ u$1("div", { "data-key": instanceProps.layerKey, style: styles2, children: /* @__PURE__ */ u$1(Fragment$1, { fragmentId, globalManager }) }) : /* @__PURE__ */ u$1(Fragment$1, { fragmentId, globalManager })
2036
- }
2037
- );
2038
- };
2039
- const useReadVariable = (variableKey) => {
2040
- const isVariable = isVariableLink(variableKey);
2041
- const { manager: fragmentManager } = x$1(FragmentContext);
2042
- const { props, innerManager, layerKey } = x$1(InstanceContext);
2043
- const resultManager = fragmentManager;
2044
- const { _id: propertyId } = (resultManager == null ? void 0 : resultManager.entityOfKey(variableKey)) ?? {};
2045
- const [variableLayer] = y$1(
2046
- isVariable ? fragmentManager : null,
2047
- variableKey,
2048
- {
2049
- selector: (graph) => graph ? pick(graph, "defaultValue", "required") : graph
2050
- }
2051
- );
2052
- const currentValue = (props == null ? void 0 : props[propertyId]) ?? null;
2053
- const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
2054
- const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
2055
- const resultValue = required ? currentValue : currentValue ?? defaultValue;
2056
- return {
2057
- value: resultValue,
2058
- layer: variableLayer
2059
- };
2060
- };
2061
- const getParent = (manager, layerKey) => {
2062
- var _a;
2063
- const parents = ((_a = manager == null ? void 0 : manager.resolveParents) == null ? void 0 : _a.call(manager, layerKey)) ?? [];
2064
- return parents == null ? void 0 : parents.find((parent) => {
2065
- var _a2;
2066
- return (_a2 = parent == null ? void 0 : parent.children) == null ? void 0 : _a2.includes(layerKey);
2067
- });
2068
- };
2069
- const isTopLevel = (manager, layerKey) => {
2070
- var _a;
2071
- return ((_a = getParent(manager, layerKey)) == null ? void 0 : _a._type) === nodes$1.Fragment;
2072
- };
2073
- const getAllParents = (manager, layerKey, stack = []) => {
2074
- const parent = getParent(manager, layerKey);
2075
- if (parent) {
2076
- stack.push(parent);
2077
- getAllParents(manager, manager.keyOfEntity(parent), stack);
2078
- }
2079
- return stack;
2080
- };
2081
- const isPartOfPrimary = (manager, layerKey) => {
2082
- var _a;
2083
- const allParents = getAllParents(manager, manager.keyOfEntity(layerKey));
2084
- const layer = manager.resolve(layerKey);
2085
- return (layer == null ? void 0 : layer.isPrimary) ?? !!((_a = allParents == null ? void 0 : allParents.find) == null ? void 0 : _a.call(allParents, (parent) => !!(parent == null ? void 0 : parent.isPrimary)));
2086
- };
2087
- const getOverrider = (manager, layer) => {
2088
- const layerKey = manager.keyOfEntity(layer);
2089
- const layerParents = manager.resolveParents(layerKey);
2090
- const isPartialPrimary = isPartOfPrimary(manager, layerKey);
2091
- return isPartialPrimary ? manager.resolve(layerKey) : layerParents == null ? void 0 : layerParents.find((parent) => {
2092
- var _a;
2093
- return (_a = parent == null ? void 0 : parent.overrides) == null ? void 0 : _a.includes(layerKey);
2094
- });
2095
- };
2096
- const createConstants$2 = (...constants) => {
2097
- return constants.reduce((acc, constant) => {
2098
- acc[constant] = constant;
2099
- return acc;
2100
- }, {});
2101
- };
2102
- const nodes$2 = createConstants$2(
2103
- "Fragment",
2104
- "FragmentInstance",
2105
- "Instance",
2106
- "Breakpoint",
2107
- "Frame",
2108
- "Image",
2109
- "Text",
2110
- "SolidPaintStyle",
2111
- "CssLink",
2112
- "Variable",
2113
- "ComputedValue",
2114
- "TransformValue"
2115
- );
2116
- const fragmentGrowingMode$2 = createConstants$2("auto", "fill");
2117
- const borderType$2 = createConstants$2("None", "Solid", "Dashed", "Dotted");
2118
- createConstants$2("_blank");
2119
- const paintMode$2 = createConstants$2("None", "Solid", "Image");
2120
- createConstants$2(
2121
- "Fill",
2122
- "Fit",
2123
- "Crop",
2124
- "Tile"
2125
- );
2126
- createConstants$2(
2127
- "Min",
2128
- "Center",
2129
- "Max",
2130
- "Stretch",
2131
- "Scale"
2132
- );
2133
- const positionType$2 = createConstants$2("absolute", "relative");
2134
- const sizing$2 = createConstants$2("Fixed", "Hug", "Fill", "Relative");
2135
- const layerMode$2 = createConstants$2("none", "flex");
2136
- const layerDirection$2 = createConstants$2("vertical", "horizontal");
2137
- const layerAlign$1 = createConstants$2("start", "center", "end");
2138
- const layerDistribute$1 = createConstants$2(
2139
- "start",
2140
- "center",
2141
- "end",
2142
- "space-between",
2143
- "space-around"
2144
- );
2145
- createConstants$2(
2146
- "none",
2147
- "uppercase",
2148
- "lowercase",
2149
- "capitalize"
2150
- );
2151
- createConstants$2(
2152
- "none",
2153
- "underline",
2154
- "line-through"
2155
- );
2156
- createConstants$2("loop", "appear", "hover", "tap");
2157
- createConstants$2(
2158
- "fade",
2159
- "slide",
2160
- "bounce",
2161
- "wiggle",
2162
- "increase"
2163
- );
2164
- const variableType$1 = createConstants$2(
2165
- "String",
2166
- "Boolean",
2167
- "Array",
2168
- "Color",
2169
- "ComponentInstance",
2170
- "Date",
2171
- "Enum",
2172
- "Number",
2173
- "Object"
2174
- );
2175
- createConstants$2(
2176
- "normal",
2177
- "nowrap",
2178
- "pre",
2179
- "pre-wrap",
2180
- "pre-line",
2181
- "break-spaces"
2182
- );
2183
- const overflow$1 = createConstants$2("visible", "hidden", "scroll");
2184
- createConstants$2(
2185
- "convert",
2186
- "exists",
2187
- "equals",
2188
- "startWith",
2189
- "endWith",
2190
- "contains",
2191
- "dateBefore",
2192
- "dateAfter",
2193
- "dateBetween",
2194
- "feature",
2195
- "notFeature",
2196
- "gt",
2197
- // Greater than
2198
- "gte",
2199
- // Greater than or equals
2200
- "lt",
2201
- // Less than
2202
- "lte",
2203
- // Less than or equals,
2204
- "convertFromBoolean",
2205
- "negative"
2206
- );
2207
- createConstants$2("canvas", "document");
2208
- createConstants$2("viewport", "parent", "fixed");
2209
- // @__NO_SIDE_EFFECTS__
2210
- function getGlobalConfig$1(config2) {
2211
- return {
2212
- lang: (config2 == null ? void 0 : config2.lang) ?? void 0,
2213
- message: config2 == null ? void 0 : config2.message,
2214
- abortEarly: (config2 == null ? void 0 : config2.abortEarly) ?? void 0,
2215
- abortPipeEarly: (config2 == null ? void 0 : config2.abortPipeEarly) ?? void 0
2216
- };
2217
- }
2218
- // @__NO_SIDE_EFFECTS__
2219
- function getGlobalMessage$1(lang) {
2220
- return void 0;
2221
- }
2222
- // @__NO_SIDE_EFFECTS__
2223
- function getSchemaMessage$1(lang) {
2224
- return void 0;
2225
- }
2226
- // @__NO_SIDE_EFFECTS__
2227
- function getSpecificMessage$1(reference, lang) {
2228
- var _a;
2229
- return (_a = void 0) == null ? void 0 : _a.get(lang);
2230
- }
2231
- // @__NO_SIDE_EFFECTS__
2232
- function _stringify$1(input) {
2233
- var _a, _b;
2234
- const type = typeof input;
2235
- if (type === "string") {
2236
- return `"${input}"`;
2237
- }
2238
- if (type === "number" || type === "bigint" || type === "boolean") {
2239
- return `${input}`;
2240
- }
2241
- if (type === "object" || type === "function") {
2242
- return (input && ((_b = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name)) ?? "null";
2243
- }
2244
- return type;
2245
- }
2246
- function _addIssue$1(context, label, dataset, config2, other) {
2247
- const input = other && "input" in other ? other.input : dataset.value;
2248
- const expected = (other == null ? void 0 : other.expected) ?? context.expects ?? null;
2249
- const received = (other == null ? void 0 : other.received) ?? /* @__PURE__ */ _stringify$1(input);
2250
- const issue = {
2251
- kind: context.kind,
2252
- type: context.type,
2253
- input,
2254
- expected,
2255
- received,
2256
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
2257
- requirement: context.requirement,
2258
- path: other == null ? void 0 : other.path,
2259
- issues: other == null ? void 0 : other.issues,
2260
- lang: config2.lang,
2261
- abortEarly: config2.abortEarly,
2262
- abortPipeEarly: config2.abortPipeEarly
2263
- };
2264
- const isSchema = context.kind === "schema";
2265
- const message = (other == null ? void 0 : other.message) ?? context.message ?? /* @__PURE__ */ getSpecificMessage$1(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage$1(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage$1(issue.lang);
2266
- if (message !== void 0) {
2267
- issue.message = typeof message === "function" ? (
2268
- // @ts-expect-error
2269
- message(issue)
2270
- ) : message;
2271
- }
2272
- if (isSchema) {
2273
- dataset.typed = false;
2274
- }
2275
- if (dataset.issues) {
2276
- dataset.issues.push(issue);
2277
- } else {
2278
- dataset.issues = [issue];
2279
- }
2280
- }
2281
- // @__NO_SIDE_EFFECTS__
2282
- function _getStandardProps$1(context) {
2283
- return {
2284
- version: 1,
2285
- vendor: "valibot",
2286
- validate(value2) {
2287
- return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig$1());
2288
- }
2289
- };
2290
- }
2291
- // @__NO_SIDE_EFFECTS__
2292
- function _isValidObjectKey$1(object2, key) {
2293
- return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
2294
- }
2295
- // @__NO_SIDE_EFFECTS__
2296
- function _joinExpects$1(values2, separator) {
2297
- const list = [...new Set(values2)];
2298
- if (list.length > 1) {
2299
- return `(${list.join(` ${separator} `)})`;
2300
- }
2301
- return list[0] ?? "never";
2302
- }
2303
- // @__NO_SIDE_EFFECTS__
2304
- function isOfKind(kind, object2) {
2305
- return object2.kind === kind;
2306
- }
2307
- var ValiError = class extends Error {
2308
- /**
2309
- * Creates a Valibot error with useful information.
2310
- *
2311
- * @param issues The error issues.
2312
- */
2313
- constructor(issues) {
2314
- super(issues[0].message);
2315
- this.name = "ValiError";
2316
- this.issues = issues;
2317
- }
2318
- };
2319
- // @__NO_SIDE_EFFECTS__
2320
- function check$1(requirement, message) {
2321
- return {
2322
- kind: "validation",
2323
- type: "check",
2324
- reference: check$1,
2325
- async: false,
2326
- expects: null,
2327
- requirement,
2328
- message,
2329
- "~run"(dataset, config2) {
2330
- if (dataset.typed && !this.requirement(dataset.value)) {
2331
- _addIssue$1(this, "input", dataset, config2);
2332
- }
2333
- return dataset;
2334
- }
2335
- };
2336
- }
2337
- // @__NO_SIDE_EFFECTS__
2338
- function maxValue$1(requirement, message) {
2339
- return {
2340
- kind: "validation",
2341
- type: "max_value",
2342
- reference: maxValue$1,
2343
- async: false,
2344
- expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify$1(requirement)}`,
2345
- requirement,
2346
- message,
2347
- "~run"(dataset, config2) {
2348
- if (dataset.typed && !(dataset.value <= this.requirement)) {
2349
- _addIssue$1(this, "value", dataset, config2, {
2350
- received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify$1(dataset.value)
2351
- });
2352
- }
2353
- return dataset;
2354
- }
2355
- };
2356
- }
2357
- // @__NO_SIDE_EFFECTS__
2358
- function metadata$1(metadata_) {
2359
- return {
2360
- kind: "metadata",
2361
- type: "metadata",
2362
- reference: metadata$1,
2363
- metadata: metadata_
2364
- };
2365
- }
2366
- // @__NO_SIDE_EFFECTS__
2367
- function minValue$1(requirement, message) {
2368
- return {
2369
- kind: "validation",
2370
- type: "min_value",
2371
- reference: minValue$1,
2372
- async: false,
2373
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify$1(requirement)}`,
2374
- requirement,
2375
- message,
2376
- "~run"(dataset, config2) {
2377
- if (dataset.typed && !(dataset.value >= this.requirement)) {
2378
- _addIssue$1(this, "value", dataset, config2, {
2379
- received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify$1(dataset.value)
2380
- });
2381
- }
2382
- return dataset;
2383
- }
2384
- };
2385
- }
2386
- // @__NO_SIDE_EFFECTS__
2387
- function getFallback$1(schema, dataset, config2) {
2388
- return typeof schema.fallback === "function" ? (
2389
- // @ts-expect-error
2390
- schema.fallback(dataset, config2)
2391
- ) : (
2392
- // @ts-expect-error
2393
- schema.fallback
2394
- );
2395
- }
2396
- // @__NO_SIDE_EFFECTS__
2397
- function getDefault$1(schema, dataset, config2) {
2398
- return typeof schema.default === "function" ? (
2399
- // @ts-expect-error
2400
- schema.default(dataset, config2)
2401
- ) : (
2402
- // @ts-expect-error
2403
- schema.default
2404
- );
2405
- }
2406
- // @__NO_SIDE_EFFECTS__
2407
- function array$1(item, message) {
2408
- return {
2409
- kind: "schema",
2410
- type: "array",
2411
- reference: array$1,
2412
- expects: "Array",
2413
- async: false,
2414
- item,
2415
- message,
2416
- get "~standard"() {
2417
- return /* @__PURE__ */ _getStandardProps$1(this);
2418
- },
2419
- "~run"(dataset, config2) {
2420
- var _a;
2421
- const input = dataset.value;
2422
- if (Array.isArray(input)) {
2423
- dataset.typed = true;
2424
- dataset.value = [];
2425
- for (let key = 0; key < input.length; key++) {
2426
- const value2 = input[key];
2427
- const itemDataset = this.item["~run"]({ value: value2 }, config2);
2428
- if (itemDataset.issues) {
2429
- const pathItem = {
2430
- type: "array",
2431
- origin: "value",
2432
- input,
2433
- key,
2434
- value: value2
2435
- };
2436
- for (const issue of itemDataset.issues) {
2437
- if (issue.path) {
2438
- issue.path.unshift(pathItem);
2439
- } else {
2440
- issue.path = [pathItem];
2441
- }
2442
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
2443
- }
2444
- if (!dataset.issues) {
2445
- dataset.issues = itemDataset.issues;
2446
- }
2447
- if (config2.abortEarly) {
2448
- dataset.typed = false;
2449
- break;
2450
- }
2451
- }
2452
- if (!itemDataset.typed) {
2453
- dataset.typed = false;
2454
- }
2455
- dataset.value.push(itemDataset.value);
2456
- }
2457
- } else {
2458
- _addIssue$1(this, "type", dataset, config2);
2459
- }
2460
- return dataset;
2461
- }
2462
- };
2463
- }
2464
- // @__NO_SIDE_EFFECTS__
2465
- function boolean$1(message) {
2466
- return {
2467
- kind: "schema",
2468
- type: "boolean",
2469
- reference: boolean$1,
2470
- expects: "boolean",
2471
- async: false,
2472
- message,
2473
- get "~standard"() {
2474
- return /* @__PURE__ */ _getStandardProps$1(this);
2475
- },
2476
- "~run"(dataset, config2) {
2477
- if (typeof dataset.value === "boolean") {
2478
- dataset.typed = true;
2479
- } else {
2480
- _addIssue$1(this, "type", dataset, config2);
2481
- }
2482
- return dataset;
2483
- }
2484
- };
2485
- }
2486
- // @__NO_SIDE_EFFECTS__
2487
- function enum_$1(enum__, message) {
2488
- const options2 = [];
2489
- for (const key in enum__) {
2490
- if (`${+key}` !== key || typeof enum__[key] !== "string" || !Object.is(enum__[enum__[key]], +key)) {
2491
- options2.push(enum__[key]);
2492
- }
2493
- }
2494
- return {
2495
- kind: "schema",
2496
- type: "enum",
2497
- reference: enum_$1,
2498
- expects: /* @__PURE__ */ _joinExpects$1(options2.map(_stringify$1), "|"),
2499
- async: false,
2500
- enum: enum__,
2501
- options: options2,
2502
- message,
2503
- get "~standard"() {
2504
- return /* @__PURE__ */ _getStandardProps$1(this);
2505
- },
2506
- "~run"(dataset, config2) {
2507
- if (this.options.includes(dataset.value)) {
2508
- dataset.typed = true;
2509
- } else {
2510
- _addIssue$1(this, "type", dataset, config2);
2511
- }
2512
- return dataset;
2513
- }
2514
- };
2515
- }
2516
- // @__NO_SIDE_EFFECTS__
2517
- function literal$1(literal_, message) {
2518
- return {
2519
- kind: "schema",
2520
- type: "literal",
2521
- reference: literal$1,
2522
- expects: /* @__PURE__ */ _stringify$1(literal_),
2523
- async: false,
2524
- literal: literal_,
2525
- message,
2526
- get "~standard"() {
2527
- return /* @__PURE__ */ _getStandardProps$1(this);
2528
- },
2529
- "~run"(dataset, config2) {
2530
- if (dataset.value === this.literal) {
2531
- dataset.typed = true;
2532
- } else {
2533
- _addIssue$1(this, "type", dataset, config2);
2534
- }
2535
- return dataset;
2536
- }
2537
- };
2538
- }
2539
- // @__NO_SIDE_EFFECTS__
2540
- function number$1(message) {
2541
- return {
2542
- kind: "schema",
2543
- type: "number",
2544
- reference: number$1,
2545
- expects: "number",
2546
- async: false,
2547
- message,
2548
- get "~standard"() {
2549
- return /* @__PURE__ */ _getStandardProps$1(this);
2550
- },
2551
- "~run"(dataset, config2) {
2552
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
2553
- dataset.typed = true;
2554
- } else {
2555
- _addIssue$1(this, "type", dataset, config2);
2556
- }
2557
- return dataset;
2558
- }
2559
- };
2560
- }
2561
- // @__NO_SIDE_EFFECTS__
2562
- function object$1(entries, message) {
2563
- return {
2564
- kind: "schema",
2565
- type: "object",
2566
- reference: object$1,
2567
- expects: "Object",
2568
- async: false,
2569
- entries,
2570
- message,
2571
- get "~standard"() {
2572
- return /* @__PURE__ */ _getStandardProps$1(this);
2573
- },
2574
- "~run"(dataset, config2) {
2575
- var _a;
2576
- const input = dataset.value;
2577
- if (input && typeof input === "object") {
2578
- dataset.typed = true;
2579
- dataset.value = {};
2580
- for (const key in this.entries) {
2581
- const valueSchema = this.entries[key];
2582
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
2583
- valueSchema.default !== void 0) {
2584
- const value2 = key in input ? (
2585
- // @ts-expect-error
2586
- input[key]
2587
- ) : /* @__PURE__ */ getDefault$1(valueSchema);
2588
- const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
2589
- if (valueDataset.issues) {
2590
- const pathItem = {
2591
- type: "object",
2592
- origin: "value",
2593
- input,
2594
- key,
2595
- value: value2
2596
- };
2597
- for (const issue of valueDataset.issues) {
2598
- if (issue.path) {
2599
- issue.path.unshift(pathItem);
2600
- } else {
2601
- issue.path = [pathItem];
2602
- }
2603
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
2604
- }
2605
- if (!dataset.issues) {
2606
- dataset.issues = valueDataset.issues;
2607
- }
2608
- if (config2.abortEarly) {
2609
- dataset.typed = false;
2610
- break;
2611
- }
2612
- }
2613
- if (!valueDataset.typed) {
2614
- dataset.typed = false;
2615
- }
2616
- dataset.value[key] = valueDataset.value;
2617
- } else if (valueSchema.fallback !== void 0) {
2618
- dataset.value[key] = /* @__PURE__ */ getFallback$1(valueSchema);
2619
- } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2620
- _addIssue$1(this, "key", dataset, config2, {
2621
- input: void 0,
2622
- expected: `"${key}"`,
2623
- path: [
2624
- {
2625
- type: "object",
2626
- origin: "key",
2627
- input,
2628
- key,
2629
- // @ts-expect-error
2630
- value: input[key]
2631
- }
2632
- ]
2633
- });
2634
- if (config2.abortEarly) {
2635
- break;
2636
- }
2637
- }
2638
- }
2639
- } else {
2640
- _addIssue$1(this, "type", dataset, config2);
2641
- }
2642
- return dataset;
2643
- }
2644
- };
2645
- }
2646
- // @__NO_SIDE_EFFECTS__
2647
- function optional$1(wrapped, default_) {
2648
- return {
2649
- kind: "schema",
2650
- type: "optional",
2651
- reference: optional$1,
2652
- expects: `(${wrapped.expects} | undefined)`,
2653
- async: false,
2654
- wrapped,
2655
- default: default_,
2656
- get "~standard"() {
2657
- return /* @__PURE__ */ _getStandardProps$1(this);
2658
- },
2659
- "~run"(dataset, config2) {
2660
- if (dataset.value === void 0) {
2661
- if (this.default !== void 0) {
2662
- dataset.value = /* @__PURE__ */ getDefault$1(this, dataset, config2);
2663
- }
2664
- if (dataset.value === void 0) {
2665
- dataset.typed = true;
2666
- return dataset;
2667
- }
2668
- }
2669
- return this.wrapped["~run"](dataset, config2);
2670
- }
2671
- };
2672
- }
2673
- // @__NO_SIDE_EFFECTS__
2674
- function picklist$1(options2, message) {
2675
- return {
2676
- kind: "schema",
2677
- type: "picklist",
2678
- reference: picklist$1,
2679
- expects: /* @__PURE__ */ _joinExpects$1(options2.map(_stringify$1), "|"),
2680
- async: false,
2681
- options: options2,
2682
- message,
2683
- get "~standard"() {
2684
- return /* @__PURE__ */ _getStandardProps$1(this);
2685
- },
2686
- "~run"(dataset, config2) {
2687
- if (this.options.includes(dataset.value)) {
2688
- dataset.typed = true;
2689
- } else {
2690
- _addIssue$1(this, "type", dataset, config2);
2691
- }
2692
- return dataset;
2693
- }
2694
- };
2695
- }
2696
- // @__NO_SIDE_EFFECTS__
2697
- function record$1(key, value2, message) {
2698
- return {
2699
- kind: "schema",
2700
- type: "record",
2701
- reference: record$1,
2702
- expects: "Object",
2703
- async: false,
2704
- key,
2705
- value: value2,
2706
- message,
2707
- get "~standard"() {
2708
- return /* @__PURE__ */ _getStandardProps$1(this);
2709
- },
2710
- "~run"(dataset, config2) {
2711
- var _a, _b;
2712
- const input = dataset.value;
2713
- if (input && typeof input === "object") {
2714
- dataset.typed = true;
2715
- dataset.value = {};
2716
- for (const entryKey in input) {
2717
- if (/* @__PURE__ */ _isValidObjectKey$1(input, entryKey)) {
2718
- const entryValue = input[entryKey];
2719
- const keyDataset = this.key["~run"]({ value: entryKey }, config2);
2720
- if (keyDataset.issues) {
2721
- const pathItem = {
2722
- type: "object",
2723
- origin: "key",
2724
- input,
2725
- key: entryKey,
2726
- value: entryValue
2727
- };
2728
- for (const issue of keyDataset.issues) {
2729
- issue.path = [pathItem];
2730
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
2731
- }
2732
- if (!dataset.issues) {
2733
- dataset.issues = keyDataset.issues;
2734
- }
2735
- if (config2.abortEarly) {
2736
- dataset.typed = false;
2737
- break;
2738
- }
2739
- }
2740
- const valueDataset = this.value["~run"](
2741
- { value: entryValue },
2742
- config2
2743
- );
2744
- if (valueDataset.issues) {
2745
- const pathItem = {
2746
- type: "object",
2747
- origin: "value",
2748
- input,
2749
- key: entryKey,
2750
- value: entryValue
2751
- };
2752
- for (const issue of valueDataset.issues) {
2753
- if (issue.path) {
2754
- issue.path.unshift(pathItem);
2755
- } else {
2756
- issue.path = [pathItem];
2757
- }
2758
- (_b = dataset.issues) == null ? void 0 : _b.push(issue);
2759
- }
2760
- if (!dataset.issues) {
2761
- dataset.issues = valueDataset.issues;
2762
- }
2763
- if (config2.abortEarly) {
2764
- dataset.typed = false;
2765
- break;
2766
- }
2767
- }
2768
- if (!keyDataset.typed || !valueDataset.typed) {
2769
- dataset.typed = false;
2770
- }
2771
- if (keyDataset.typed) {
2772
- dataset.value[keyDataset.value] = valueDataset.value;
2773
- }
2774
- }
2775
- }
2776
- } else {
2777
- _addIssue$1(this, "type", dataset, config2);
2778
- }
2779
- return dataset;
2780
- }
2781
- };
2782
- }
2783
- // @__NO_SIDE_EFFECTS__
2784
- function string$1(message) {
2785
- return {
2786
- kind: "schema",
2787
- type: "string",
2788
- reference: string$1,
2789
- expects: "string",
2790
- async: false,
2791
- message,
2792
- get "~standard"() {
2793
- return /* @__PURE__ */ _getStandardProps$1(this);
2794
- },
2795
- "~run"(dataset, config2) {
2796
- if (typeof dataset.value === "string") {
2797
- dataset.typed = true;
2798
- } else {
2799
- _addIssue$1(this, "type", dataset, config2);
2800
- }
2801
- return dataset;
2802
- }
2803
- };
2804
- }
2805
- // @__NO_SIDE_EFFECTS__
2806
- function _subIssues$1(datasets) {
2807
- let issues;
2808
- if (datasets) {
2809
- for (const dataset of datasets) {
2810
- if (issues) {
2811
- issues.push(...dataset.issues);
2812
- } else {
2813
- issues = dataset.issues;
2814
- }
2815
- }
2816
- }
2817
- return issues;
2818
- }
2819
- // @__NO_SIDE_EFFECTS__
2820
- function union$1(options2, message) {
2821
- return {
2822
- kind: "schema",
2823
- type: "union",
2824
- reference: union$1,
2825
- expects: /* @__PURE__ */ _joinExpects$1(
2826
- options2.map((option) => option.expects),
2827
- "|"
2828
- ),
2829
- async: false,
2830
- options: options2,
2831
- message,
2832
- get "~standard"() {
2833
- return /* @__PURE__ */ _getStandardProps$1(this);
2834
- },
2835
- "~run"(dataset, config2) {
2836
- let validDataset;
2837
- let typedDatasets;
2838
- let untypedDatasets;
2839
- for (const schema of this.options) {
2840
- const optionDataset = schema["~run"]({ value: dataset.value }, config2);
2841
- if (optionDataset.typed) {
2842
- if (optionDataset.issues) {
2843
- if (typedDatasets) {
2844
- typedDatasets.push(optionDataset);
2845
- } else {
2846
- typedDatasets = [optionDataset];
2847
- }
2848
- } else {
2849
- validDataset = optionDataset;
2850
- break;
2851
- }
2852
- } else {
2853
- if (untypedDatasets) {
2854
- untypedDatasets.push(optionDataset);
2855
- } else {
2856
- untypedDatasets = [optionDataset];
2857
- }
2858
- }
2859
- }
2860
- if (validDataset) {
2861
- return validDataset;
2862
- }
2863
- if (typedDatasets) {
2864
- if (typedDatasets.length === 1) {
2865
- return typedDatasets[0];
2866
- }
2867
- _addIssue$1(this, "type", dataset, config2, {
2868
- issues: /* @__PURE__ */ _subIssues$1(typedDatasets)
2869
- });
2870
- dataset.typed = true;
2871
- } else if ((untypedDatasets == null ? void 0 : untypedDatasets.length) === 1) {
2872
- return untypedDatasets[0];
2873
- } else {
2874
- _addIssue$1(this, "type", dataset, config2, {
2875
- issues: /* @__PURE__ */ _subIssues$1(untypedDatasets)
2876
- });
2877
- }
2878
- return dataset;
2879
- }
2880
- };
2881
- }
2882
- function parse(schema, input, config2) {
2883
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig$1(config2));
2884
- if (dataset.issues) {
2885
- throw new ValiError(dataset.issues);
2886
- }
2887
- return dataset.value;
2888
- }
2889
- // @__NO_SIDE_EFFECTS__
2890
- function pipe$1(...pipe2) {
2891
- return {
2892
- ...pipe2[0],
2893
- pipe: pipe2,
2894
- get "~standard"() {
2895
- return /* @__PURE__ */ _getStandardProps$1(this);
2896
- },
2897
- "~run"(dataset, config2) {
2898
- for (const item of pipe2) {
2899
- if (item.kind !== "metadata") {
2900
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
2901
- dataset.typed = false;
2902
- break;
2903
- }
2904
- if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
2905
- dataset = item["~run"](dataset, config2);
2906
- }
2907
- }
2908
- }
2909
- return dataset;
2910
- }
2911
- };
2912
- }
2913
- const linkValidator$1 = /* @__PURE__ */ check$1(
2914
- (value) => {
2915
- var _a, _b;
2916
- return !!value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
2917
- }
2918
- );
2919
- const getMetadata = (schema) => {
2920
- var _a;
2921
- const pipelines = (schema == null ? void 0 : schema.pipe) ?? [];
2922
- return ((_a = pipelines == null ? void 0 : pipelines.find((pipe2) => /* @__PURE__ */ isOfKind("metadata", pipe2))) == null ? void 0 : _a.metadata) ?? null;
2923
- };
2924
- const layerField$1 = (schema, meta) => {
2925
- const modifiedSchema = (meta == null ? void 0 : meta.variable) ? /* @__PURE__ */ union$1([schema, /* @__PURE__ */ pipe$1(/* @__PURE__ */ string$1(), linkValidator$1)]) : schema;
2926
- return /* @__PURE__ */ pipe$1(/* @__PURE__ */ optional$1(modifiedSchema), /* @__PURE__ */ metadata$1(meta ?? {}));
2927
- };
2928
- const ChildrenSchema$1 = /* @__PURE__ */ object$1({
2929
- children: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ string$1()), {
2930
- fallback: [],
2931
- overridable: false
2932
- })
2933
- });
2934
- const GraphFieldSchema$1 = /* @__PURE__ */ object$1({
2935
- _id: /* @__PURE__ */ union$1([/* @__PURE__ */ string$1(), /* @__PURE__ */ number$1()]),
2936
- _type: /* @__PURE__ */ picklist$1(Object.keys(nodes$2))
2937
- });
2938
- const OverridesSchema$1 = /* @__PURE__ */ object$1({
2939
- overrides: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ string$1()), { overridable: false })
2940
- });
2941
- const PositionSchema$1 = /* @__PURE__ */ object$1({
2942
- position: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(positionType$2)), {
2943
- fallback: positionType$2.absolute
2944
- }),
2945
- top: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0 }),
2946
- left: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0 })
2947
- });
2948
- const SceneSchema$1 = /* @__PURE__ */ object$1({
2949
- opacity: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0), /* @__PURE__ */ maxValue$1(1)), {
2950
- fallback: 1,
2951
- variable: true
2952
- }),
2953
- visible: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: true, variable: true }),
2954
- zIndex: layerField$1(/* @__PURE__ */ number$1(), { fallback: -1 }),
2955
- borderRadius: layerField$1(/* @__PURE__ */ string$1(), { fallback: "0px" }),
2956
- overflow: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(overflow$1)), {
2957
- fallback: overflow$1.hidden
2958
- })
2959
- });
2960
- const FillSchema$1 = /* @__PURE__ */ object$1({
2961
- fillType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(paintMode$2)), {
2962
- fallback: paintMode$2.None
2963
- }),
2964
- solidFill: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#fff" })
2965
- });
2966
- const BorderSchema$1 = /* @__PURE__ */ object$1({
2967
- borderType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(borderType$2)), {
2968
- fallback: borderType$2.None
2969
- }),
2970
- borderWidth: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), { fallback: 0 }),
2971
- borderColor: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#fff" })
2972
- });
2973
- const SizeSchema$1 = /* @__PURE__ */ object$1({
2974
- widthType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(sizing$2)), {
2975
- fallback: sizing$2.Fixed
2976
- }),
2977
- heightType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(sizing$2)), {
2978
- fallback: sizing$2.Fixed
2979
- }),
2980
- width: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), { fallback: 0 }),
2981
- height: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), { fallback: 0 }),
2982
- aspectRatio: layerField$1(/* @__PURE__ */ number$1(), { fallback: -1 })
2983
- });
2984
- const LayerSchema$1 = /* @__PURE__ */ object$1({
2985
- layerMode: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(layerMode$2)), {
2986
- fallback: layerMode$2.none
2987
- }),
2988
- layerAlign: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(layerAlign$1)), {
2989
- fallback: layerAlign$1.start
2990
- }),
2991
- layerDirection: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(layerDirection$2)), {
2992
- fallback: layerDirection$2.horizontal
2993
- }),
2994
- layerDistribute: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(layerDistribute$1)), {
2995
- fallback: layerDistribute$1.start
2996
- }),
2997
- layerWrap: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
2998
- layerGap: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), { fallback: 0 }),
2999
- padding: layerField$1(/* @__PURE__ */ string$1(), { fallback: "0px" })
3000
- });
3001
- const FrameSchema = /* @__PURE__ */ pipe$1(
3002
- /* @__PURE__ */ object$1({
3003
- name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Frame", overridable: false }),
3004
- isBreakpoint: layerField$1(/* @__PURE__ */ boolean$1(), {
3005
- fallback: false,
3006
- overridable: false
3007
- }),
3008
- isPrimary: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false, overridable: false }),
3009
- threshold: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), {
3010
- fallback: 320,
3011
- overridable: false
3012
- }),
3013
- ...ChildrenSchema$1.entries,
3014
- ...GraphFieldSchema$1.entries,
3015
- ...OverridesSchema$1.entries,
3016
- ...PositionSchema$1.entries,
3017
- ...SceneSchema$1.entries,
3018
- ...FillSchema$1.entries,
3019
- ...BorderSchema$1.entries,
3020
- ...SizeSchema$1.entries,
3021
- ...LayerSchema$1.entries
3022
- })
3023
- );
3024
- const TextSchema = /* @__PURE__ */ object$1({
3025
- name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Text", overridable: false }),
3026
- content: layerField$1(/* @__PURE__ */ string$1(), {
3027
- fallback: ""
3028
- }),
3029
- variableContent: layerField$1(/* @__PURE__ */ string$1(), { fallback: null, variable: true }),
3030
- attributes: layerField$1(
3031
- /* @__PURE__ */ object$1({
3032
- fontSize: layerField$1(/* @__PURE__ */ string$1(), { fallback: "14px" }),
3033
- color: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#000" }),
3034
- lineHeight: layerField$1(/* @__PURE__ */ string$1(), { fallback: "14px" })
3035
- }),
3036
- { fallback: {} }
3037
- ),
3038
- ...GraphFieldSchema$1.entries,
3039
- ...OverridesSchema$1.entries,
3040
- ...PositionSchema$1.entries,
3041
- ...SceneSchema$1.entries,
3042
- ...SizeSchema$1.entries
3043
- });
3044
- const FragmentSchema = /* @__PURE__ */ object$1({
3045
- name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Fragment", overridable: false }),
3046
- horizontalGrow: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(fragmentGrowingMode$2)), {
3047
- fallback: fragmentGrowingMode$2.auto,
3048
- overridable: false
3049
- }),
3050
- verticalGrow: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(fragmentGrowingMode$2)), {
3051
- fallback: fragmentGrowingMode$2.auto,
3052
- overridable: false
3053
- }),
3054
- properties: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ string$1()), {
3055
- fallback: [],
3056
- overridable: false
3057
- }),
3058
- ...GraphFieldSchema$1.entries,
3059
- ...ChildrenSchema$1.entries
3060
- });
3061
- const InstanceSchema = /* @__PURE__ */ object$1({
3062
- name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Instance", overridable: false }),
3063
- fragment: layerField$1(/* @__PURE__ */ string$1()),
3064
- props: layerField$1(
3065
- /* @__PURE__ */ record$1(/* @__PURE__ */ string$1(), /* @__PURE__ */ union$1([/* @__PURE__ */ string$1(), /* @__PURE__ */ number$1(), /* @__PURE__ */ boolean$1()])),
3066
- {
3067
- fallback: {}
3068
- }
3069
- ),
3070
- ...GraphFieldSchema$1.entries,
3071
- ...OverridesSchema$1.entries,
3072
- ...PositionSchema$1.entries,
3073
- ...SizeSchema$1.entries,
3074
- ...SceneSchema$1.entries
3075
- });
3076
- const NumberVariableSchema = /* @__PURE__ */ object$1({
3077
- name: layerField$1(/* @__PURE__ */ string$1(), {
3078
- fallback: "Number",
3079
- overridable: false
3080
- }),
3081
- type: layerField$1(/* @__PURE__ */ literal$1(variableType$1.Number), {
3082
- fallback: variableType$1.Number
3083
- }),
3084
- defaultValue: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0 }),
3085
- required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3086
- min: layerField$1(/* @__PURE__ */ number$1(), { fallback: 1 }),
3087
- max: layerField$1(/* @__PURE__ */ number$1(), { fallback: 100 }),
3088
- step: layerField$1(/* @__PURE__ */ number$1(), { fallback: 1 }),
3089
- displayStepper: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: true }),
3090
- ...GraphFieldSchema$1.entries
3091
- });
3092
- const BooleanVariableSchema = /* @__PURE__ */ object$1({
3093
- name: layerField$1(/* @__PURE__ */ string$1(), {
3094
- fallback: "Boolean",
3095
- overridable: false
3096
- }),
3097
- type: layerField$1(/* @__PURE__ */ literal$1(variableType$1.Boolean), {
3098
- fallback: variableType$1.Boolean
3099
- }),
3100
- defaultValue: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3101
- required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3102
- ...GraphFieldSchema$1.entries
3103
- });
3104
- const ColorVariableSchema = /* @__PURE__ */ object$1({
3105
- name: layerField$1(/* @__PURE__ */ string$1(), {
3106
- fallback: "String",
3107
- overridable: false
3108
- }),
3109
- type: layerField$1(/* @__PURE__ */ literal$1(variableType$1.Color), {
3110
- fallback: variableType$1.Color
3111
- }),
3112
- // TODO Add color validator
3113
- defaultValue: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#000" }),
3114
- required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3115
- ...GraphFieldSchema$1.entries
3116
- });
3117
- const StringVariableSchema = /* @__PURE__ */ object$1({
3118
- name: layerField$1(/* @__PURE__ */ string$1(), {
3119
- fallback: "String",
3120
- overridable: false
3121
- }),
3122
- type: layerField$1(/* @__PURE__ */ literal$1(variableType$1.String), {
3123
- fallback: variableType$1.String
3124
- }),
3125
- defaultValue: layerField$1(/* @__PURE__ */ string$1(), { fallback: "" }),
3126
- required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3127
- placeholder: layerField$1(/* @__PURE__ */ string$1(), { fallback: "" }),
3128
- isTextarea: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3129
- ...GraphFieldSchema$1.entries
3130
- });
3131
- const getLayerSchema = (layer) => {
3132
- if (!(layer == null ? void 0 : layer._type)) return null;
3133
- if ((layer == null ? void 0 : layer._type) === nodes$2.Frame) return FrameSchema;
3134
- if ((layer == null ? void 0 : layer._type) === nodes$2.Text) return TextSchema;
3135
- if ((layer == null ? void 0 : layer._type) === nodes$2.Fragment) return FragmentSchema;
3136
- if ((layer == null ? void 0 : layer._type) === nodes$2.Instance) return InstanceSchema;
3137
- if (layer._type === nodes$2.Variable) {
3138
- const types = {
3139
- [variableType$1.Number]: NumberVariableSchema,
3140
- [variableType$1.Boolean]: BooleanVariableSchema,
3141
- [variableType$1.String]: StringVariableSchema,
3142
- [variableType$1.Color]: ColorVariableSchema
3143
- };
3144
- if (layer.type in types) {
3145
- return types[layer.type];
3146
- }
3147
- }
3148
- };
3149
- const normalizeLayer = (schema, rawLayer, options2) => {
3150
- try {
3151
- if (!rawLayer) return null;
3152
- const withFallback = (options2 == null ? void 0 : options2.withFallback) ?? true;
3153
- const overrideTarget = options2 == null ? void 0 : options2.overrideTarget;
3154
- const parsedLayer = parse(schema, rawLayer);
3155
- return Object.fromEntries(
3156
- Object.entries(schema.entries).map(([key, schemaEntity]) => {
3157
- const schemaMeta = getMetadata(schemaEntity);
3158
- const fallback = withFallback ? schemaMeta == null ? void 0 : schemaMeta.fallback : null;
3159
- const overrideValue = (schemaMeta == null ? void 0 : schemaMeta.overridable) !== false && overrideTarget ? overrideTarget == null ? void 0 : overrideTarget[key] : null;
3160
- return [key, parsedLayer[key] ?? overrideValue ?? fallback];
3161
- })
3162
- );
3163
- } catch (e2) {
3164
- console.error(e2);
3165
- return null;
3166
- }
3167
- };
3168
- const getNormalizeLayer = (layer, overrider) => {
3169
- if (!layer) return null;
3170
- const schema = getLayerSchema(layer);
3171
- if (!schema) return null;
3172
- return normalizeLayer(schema, layer, {
3173
- overrideTarget: overrider
3174
- });
3175
- };
3176
- const useNormalizeLayer = (layerKey) => {
3177
- const { manager: fragmentManager } = x$1(FragmentContext);
3178
- const layerData = fragmentManager.resolve(layerKey);
3179
- const overrider = getOverrider(fragmentManager, layerKey);
3180
- const parsedLayer = getNormalizeLayer(layerData, overrider);
3181
- return {
3182
- rawLayer: layerData,
3183
- layer: parsedLayer
3184
- };
3185
- };
3186
- const useLayerValue = (layerKey, fieldKey) => {
3187
- const { manager: fragmentManager } = x$1(FragmentContext);
3188
- const resultManager = fragmentManager;
3189
- const { layer: normalizeLayer2 } = useNormalizeLayer(layerKey);
3190
- const [layerData, updateLayerData] = y$1(resultManager, layerKey, {
3191
- selector: (data) => data ? pick(data, fieldKey) : data
3192
- });
3193
- let currentValue = normalizeLayer2 == null ? void 0 : normalizeLayer2[fieldKey];
3194
- const rawValue = layerData == null ? void 0 : layerData[fieldKey];
3195
- const { value: variableValue } = useReadVariable(rawValue);
3196
- const updateValue = q$1(
3197
- (value) => {
3198
- updateLayerData({ [fieldKey]: value });
3199
- },
3200
- [updateLayerData, fieldKey, currentValue]
3201
- );
3202
- currentValue = variableValue ?? currentValue;
3203
- return [
3204
- currentValue,
3205
- updateValue,
3206
- {
3207
- isVariable: false
3208
- }
3209
- ];
3210
- };
3211
- const autoSizes = [sizing$1.Hug];
3212
- const useLayerSize = (layerKey) => {
3213
- const { manager: fragmentManager } = x$1(FragmentContext);
3214
- const { layerKey: instanceLayerKey, parentManager: instanceManager } = x$1(InstanceContext);
3215
- const { isDocument } = useRenderTarget$1(fragmentManager);
3216
- const isTop = isTopLevel(fragmentManager, layerKey);
3217
- //!!instanceLayerKey;
3218
- const layerParent = getParent(fragmentManager, layerKey);
3219
- useLayerValue(instanceLayerKey, "widthType");
3220
- useLayerValue(instanceLayerKey, "heightType");
3221
- const [width] = useLayerValue(layerKey, "width");
3222
- const [height] = useLayerValue(layerKey, "height");
3223
- const [widthType] = useLayerValue(layerKey, "widthType");
3224
- const [heightType] = useLayerValue(layerKey, "heightType");
3225
- const toValue = (type, value, instanceType) => {
3226
- if (autoSizes.includes(type)) {
3227
- return "min-content";
3228
- }
3229
- if (type === sizing$1.Relative) {
3230
- return `${value}%`;
3231
- }
3232
- if (type === sizing$1.Fill) {
3233
- return `100%`;
3234
- }
3235
- return value;
3236
- };
3237
- return T$1(
3238
- () => ({
3239
- width: isTop && isDocument && (layerParent == null ? void 0 : layerParent.horizontalGrow) === fragmentGrowingMode$1.fill ? "100%" : toValue(widthType, width),
3240
- height: isTop && isDocument && (layerParent == null ? void 0 : layerParent.horizontalGrow) === fragmentGrowingMode$1.fill ? "100%" : toValue(heightType, height)
3241
- }),
3242
- [isTop, isDocument, width, height, heightType, heightType]
3243
- );
3244
- };
3245
- const useLayerPosition = (layerKey) => {
3246
- const { layerKey: instanceLayerKey } = x$1(InstanceContext);
3247
- const { manager: fragmentManager } = x$1(FragmentContext);
3248
- const { isDocument } = useRenderTarget$1();
3249
- const isTop = isTopLevel(fragmentManager, layerKey);
3250
- const skipPosition = isTop && isDocument || !!instanceLayerKey && isTop;
3251
- const [position] = useLayerValue(layerKey, "position");
3252
- const [top] = useLayerValue(layerKey, "top");
3253
- const [left] = useLayerValue(layerKey, "left");
3254
- return T$1(
3255
- () => ({
3256
- position: skipPosition ? positionType$1.relative : position,
3257
- top: position === positionType$1.absolute && !skipPosition ? top : null,
3258
- left: position === positionType$1.absolute && !skipPosition ? left : null
3259
- }),
3260
- [skipPosition, position, top]
3261
- );
3262
- };
3263
- const useLayerBackground = (layerKey) => {
3264
- const [fillType] = useLayerValue(layerKey, "fillType");
3265
- const [solidFill] = useLayerValue(layerKey, "solidFill");
3266
- return T$1(
3267
- () => ({
3268
- background: fillType === paintMode$1.Solid ? solidFill : "transparent"
3269
- }),
3270
- [fillType, solidFill]
3271
- );
3272
- };
3273
- const useLayerDisplay = (layerKey) => {
3274
- const [layerModeValue] = useLayerValue(layerKey, "layerMode");
3275
- const [visible] = useLayerValue(layerKey, "visible");
3276
- return T$1(() => {
3277
- if (!visible) {
3278
- return "none";
3279
- }
3280
- return layerModeValue === layerMode$1.flex ? "flex" : null;
3281
- }, [layerModeValue, visible]);
3282
- };
3283
- const useLayerBorder = (layerKey) => {
3284
- const [borderTypeValue] = useLayerValue(layerKey, "borderType");
3285
- const [borderWidth] = useLayerValue(layerKey, "borderWidth");
3286
- const [borderColor] = useLayerValue(layerKey, "borderColor");
3287
- return T$1(() => {
3288
- let value = "";
3289
- if (typeof borderTypeValue === "string" && borderTypeValue !== borderType$1.None) {
3290
- value = `${toPx(
3291
- borderWidth
3292
- )} ${borderTypeValue.toLowerCase()} ${borderColor}`;
3293
- }
3294
- return {
3295
- border: value
3296
- };
3297
- }, [borderTypeValue, borderWidth, borderColor]);
3298
- };
3299
- const useLayerLayout = (layerKey) => {
3300
- const [layerModeValue] = useLayerValue(layerKey, "layerMode");
3301
- const [layerGap] = useLayerValue(layerKey, "layerGap");
3302
- const [layerWrap] = useLayerValue(layerKey, "layerWrap");
3303
- const [layerDistribute2] = useLayerValue(layerKey, "layerDistribute");
3304
- const [layerDirectionValue] = useLayerValue(layerKey, "layerDirection");
3305
- const [layerAlign2] = useLayerValue(layerKey, "layerAlign");
3306
- const [padding] = useLayerValue(layerKey, "padding");
3307
- const isFlex = layerModeValue === layerMode$1.flex;
3308
- return {
3309
- gap: isFlex ? layerGap : null,
3310
- flexWrap: isFlex ? layerWrap : null,
3311
- justifyContent: isFlex ? layerDistribute2 : null,
3312
- flexDirection: isFlex ? layerDirectionValue === layerDirection$1.vertical ? "column" : "row" : null,
3313
- alignItems: isFlex ? layerAlign2 : null,
3314
- padding: isFlex ? padding : null
3315
- };
3316
- };
3317
- const useLayerStyles = (layerKey) => {
3318
- try {
3319
- if (!layerKey) {
3320
- throw new Error("Empty layer key");
3321
- }
3322
- const [opacity] = useLayerValue(layerKey, "opacity");
3323
- const { width, height } = useLayerSize(layerKey);
3324
- const { position, top, left } = useLayerPosition(layerKey);
3325
- const display = useLayerDisplay(layerKey);
3326
- const { background } = useLayerBackground(layerKey);
3327
- const { border } = useLayerBorder(layerKey);
3328
- const layout = useLayerLayout(layerKey);
3329
- const [zIndex] = useLayerValue(layerKey, "zIndex");
3330
- const [borderRadius] = useLayerValue(layerKey, "borderRadius");
3331
- return {
3332
- display,
3333
- border,
3334
- background,
3335
- position,
3336
- top,
3337
- left,
3338
- width,
3339
- height,
3340
- opacity,
3341
- borderRadius,
3342
- zIndex: zIndex !== -1 ? zIndex : null,
3343
- ...layout,
3344
- userSelect: "none"
3345
- };
3346
- } catch (e2) {
3347
- return {};
3348
- }
3349
- };
3350
- const useFrame = (layerKey) => {
3351
- const { manager: fragmentManager } = x$1(FragmentContext);
3352
- const layer = fragmentManager.entityOfKey(layerKey);
3353
- const styles2 = useLayerStyles(layerKey);
3354
- const children = useLayerChildren(layerKey);
3355
- return {
3356
- type: layer._type,
3357
- styles: styles2,
3358
- children
3359
- };
3360
- };
3361
- const text = "_text_1liuf_1";
3362
- const cssStyles = {
3363
- text
3364
- };
3365
- const allowAttributes = [
3366
- "fontSize",
3367
- "fontWeight",
3368
- "color",
3369
- "lineHeight",
3370
- "letterSpacing",
3371
- "textTransform",
3372
- "textDecoration",
3373
- "textAlign"
3374
- ];
3375
- const wrapTextInParagraphWithAttributes = (text2, attributes) => {
3376
- if (text2.startsWith("<p")) return text2;
3377
- const style = Object.entries(attributes).filter(
3378
- ([key, value]) => isValue(value) && allowAttributes.includes(key) && typeof value === "string" && !!value.length
3379
- ).map(([key, value]) => `${toKebabCase(key)}: ${value}`).join("; ");
3380
- return `<p style="${style}">${text2}</p>`;
3381
- };
3382
- const useTextContent = (layerKey, manager) => {
3383
- const [content, _2, contentInfo] = useLayerValue(layerKey, "content");
3384
- const [attributes] = useLayerValue(layerKey, "attributes");
3385
- return T$1(() => {
3386
- if (contentInfo.isVariable && isValue(attributes)) {
3387
- return wrapTextInParagraphWithAttributes(content, attributes);
3388
- }
3389
- return content;
3390
- }, [contentInfo, content, attributes]);
3391
- };
3392
- const useTextAttributes = (layerKey) => {
3393
- const styles2 = useLayerStyles(layerKey);
3394
- const content = useTextContent(layerKey);
3395
- return {
3396
- styles: styles2,
3397
- content
3398
- };
3399
- };
3400
- const Text = ({ layerKey }) => {
3401
- const { styles: styles2, content } = useTextAttributes(layerKey);
3402
- return /* @__PURE__ */ u$1("div", { style: styles2, "data-key": layerKey, children: /* @__PURE__ */ u$1(
3403
- "div",
3404
- {
3405
- className: cssStyles.text,
3406
- dangerouslySetInnerHTML: { __html: content }
3407
- }
3408
- ) });
3409
- };
3410
- const Frame = ({ layerKey }) => {
3411
- const { styles: styles2, children, type } = useFrame(layerKey);
3412
- if (type === nodes$1.Text) {
3413
- return /* @__PURE__ */ u$1(Text, { layerKey });
3414
- }
3415
- if (type === nodes$1.Instance) {
3416
- return /* @__PURE__ */ u$1(Instance$1, { layerKey });
3417
- }
3418
- return /* @__PURE__ */ u$1("div", { style: styles2, "data-key": layerKey, children: children.map((childLink) => /* @__PURE__ */ u$1(Frame, { layerKey: childLink }, childLink)) });
3419
- };
3420
- const Fragment$1 = ({ fragmentId, globalManager }) => {
3421
- const { manager: resultGlobalManager } = useGlobalManager$1(globalManager);
3422
- const { ref, children, manager } = useFragment(fragmentId, globalManager);
3423
- return /* @__PURE__ */ u$1(GlobalManager$1, { value: resultGlobalManager, children: /* @__PURE__ */ u$1(FragmentProvider, { manager, children: /* @__PURE__ */ u$1(
3424
- "div",
3425
- {
3426
- ref,
3427
- "data-key": `${nodes$1.Fragment}:${fragmentId}`,
3428
- className: styles.fragment,
3429
- children: children.map((childLink) => /* @__PURE__ */ u$1(Frame, { layerKey: childLink }, childLink))
3430
- }
3431
- ) }) });
3432
- };
3433
- const GlobalManager = require$$0$1.createContext(null);
6
+ const definition = require("@fragmentsx/definition");
7
+ const GlobalManager = require$$0.createContext(null);
3434
8
  function createReactComponent(PreactComponent) {
3435
9
  return function ReactWrapper(props) {
3436
- const globalManager = require$$0$1.useContext(GlobalManager);
3437
- const containerRef = require$$0$1.useRef(null);
3438
- require$$0$1.useEffect(() => {
10
+ const globalManager = require$$0.useContext(GlobalManager);
11
+ const containerRef = require$$0.useRef(null);
12
+ require$$0.useEffect(() => {
3439
13
  if (containerRef.current) {
3440
- preact.render(
3441
- preact.createElement(PreactComponent, {
14
+ renderCore.render(
15
+ renderCore.createElement(PreactComponent, {
3442
16
  ...props,
3443
17
  globalManager: (props == null ? void 0 : props.globalManager) ?? globalManager
3444
18
  }),
@@ -3447,14 +21,14 @@ function createReactComponent(PreactComponent) {
3447
21
  }
3448
22
  return () => {
3449
23
  if (containerRef.current) {
3450
- preact.render(null, containerRef.current);
24
+ renderCore.render(null, containerRef.current);
3451
25
  }
3452
26
  };
3453
27
  }, [props, globalManager]);
3454
- return require$$0$1.createElement("div", { ref: containerRef });
28
+ return require$$0.createElement("div", { ref: containerRef });
3455
29
  };
3456
30
  }
3457
- const useGlobalManager = () => require$$0$1.useContext(GlobalManager);
31
+ const useGlobalManager = () => require$$0.useContext(GlobalManager);
3458
32
  var shim = { exports: {} };
3459
33
  var useSyncExternalStoreShim_production_min = {};
3460
34
  /**
@@ -3470,42 +44,42 @@ var hasRequiredUseSyncExternalStoreShim_production_min;
3470
44
  function requireUseSyncExternalStoreShim_production_min() {
3471
45
  if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
3472
46
  hasRequiredUseSyncExternalStoreShim_production_min = 1;
3473
- var e2 = require$$0$1;
3474
- function h2(a2, b2) {
3475
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
3476
- }
3477
- var k2 = "function" === typeof Object.is ? Object.is : h2, l2 = e2.useState, m2 = e2.useEffect, n2 = e2.useLayoutEffect, p2 = e2.useDebugValue;
3478
- function q2(a2, b2) {
3479
- var d2 = b2(), f2 = l2({ inst: { value: d2, getSnapshot: b2 } }), c2 = f2[0].inst, g2 = f2[1];
3480
- n2(function() {
3481
- c2.value = d2;
3482
- c2.getSnapshot = b2;
3483
- r2(c2) && g2({ inst: c2 });
3484
- }, [a2, d2, b2]);
3485
- m2(function() {
3486
- r2(c2) && g2({ inst: c2 });
3487
- return a2(function() {
3488
- r2(c2) && g2({ inst: c2 });
47
+ var e = require$$0;
48
+ function h(a, b) {
49
+ return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
50
+ }
51
+ var k = "function" === typeof Object.is ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
52
+ function q(a, b) {
53
+ var d = b(), f = l({ inst: { value: d, getSnapshot: b } }), c = f[0].inst, g = f[1];
54
+ n(function() {
55
+ c.value = d;
56
+ c.getSnapshot = b;
57
+ r(c) && g({ inst: c });
58
+ }, [a, d, b]);
59
+ m(function() {
60
+ r(c) && g({ inst: c });
61
+ return a(function() {
62
+ r(c) && g({ inst: c });
3489
63
  });
3490
- }, [a2]);
3491
- p2(d2);
3492
- return d2;
64
+ }, [a]);
65
+ p(d);
66
+ return d;
3493
67
  }
3494
- function r2(a2) {
3495
- var b2 = a2.getSnapshot;
3496
- a2 = a2.value;
68
+ function r(a) {
69
+ var b = a.getSnapshot;
70
+ a = a.value;
3497
71
  try {
3498
- var d2 = b2();
3499
- return !k2(a2, d2);
3500
- } catch (f2) {
72
+ var d = b();
73
+ return !k(a, d);
74
+ } catch (f) {
3501
75
  return true;
3502
76
  }
3503
77
  }
3504
- function t2(a2, b2) {
3505
- return b2();
78
+ function t(a, b) {
79
+ return b();
3506
80
  }
3507
- var u2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t2 : q2;
3508
- useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e2.useSyncExternalStore ? e2.useSyncExternalStore : u2;
81
+ var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
82
+ useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
3509
83
  return useSyncExternalStoreShim_production_min;
3510
84
  }
3511
85
  var useSyncExternalStoreShim_development = {};
@@ -3527,7 +101,7 @@ function requireUseSyncExternalStoreShim_development() {
3527
101
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
3528
102
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
3529
103
  }
3530
- var React = require$$0$1;
104
+ var React = require$$0;
3531
105
  var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
3532
106
  function error(format) {
3533
107
  {
@@ -3554,8 +128,8 @@ function requireUseSyncExternalStoreShim_development() {
3554
128
  Function.prototype.apply.call(console[level], console, argsWithFormat);
3555
129
  }
3556
130
  }
3557
- function is(x2, y2) {
3558
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
131
+ function is(x, y2) {
132
+ return x === y2 && (x !== 0 || 1 / x === 1 / y2) || x !== x && y2 !== y2;
3559
133
  }
3560
134
  var objectIs = typeof Object.is === "function" ? Object.is : is;
3561
135
  var useState = React.useState, useEffect = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
@@ -3665,50 +239,50 @@ var hasRequiredWithSelector_production_min;
3665
239
  function requireWithSelector_production_min() {
3666
240
  if (hasRequiredWithSelector_production_min) return withSelector_production_min;
3667
241
  hasRequiredWithSelector_production_min = 1;
3668
- var h2 = require$$0$1, n2 = requireShim();
3669
- function p2(a2, b2) {
3670
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
3671
- }
3672
- var q2 = "function" === typeof Object.is ? Object.is : p2, r2 = n2.useSyncExternalStore, t2 = h2.useRef, u2 = h2.useEffect, v2 = h2.useMemo, w2 = h2.useDebugValue;
3673
- withSelector_production_min.useSyncExternalStoreWithSelector = function(a2, b2, e2, l2, g2) {
3674
- var c2 = t2(null);
3675
- if (null === c2.current) {
3676
- var f2 = { hasValue: false, value: null };
3677
- c2.current = f2;
3678
- } else f2 = c2.current;
3679
- c2 = v2(function() {
3680
- function a3(a4) {
3681
- if (!c3) {
3682
- c3 = true;
3683
- d3 = a4;
3684
- a4 = l2(a4);
3685
- if (void 0 !== g2 && f2.hasValue) {
3686
- var b3 = f2.value;
3687
- if (g2(b3, a4)) return k2 = b3;
3688
- }
3689
- return k2 = a4;
3690
- }
3691
- b3 = k2;
3692
- if (q2(d3, a4)) return b3;
3693
- var e3 = l2(a4);
3694
- if (void 0 !== g2 && g2(b3, e3)) return b3;
3695
- d3 = a4;
3696
- return k2 = e3;
3697
- }
3698
- var c3 = false, d3, k2, m2 = void 0 === e2 ? null : e2;
242
+ var h = require$$0, n = requireShim();
243
+ function p(a, b) {
244
+ return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
245
+ }
246
+ var q = "function" === typeof Object.is ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u = h.useEffect, v = h.useMemo, w = h.useDebugValue;
247
+ withSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, g) {
248
+ var c = t(null);
249
+ if (null === c.current) {
250
+ var f = { hasValue: false, value: null };
251
+ c.current = f;
252
+ } else f = c.current;
253
+ c = v(function() {
254
+ function a2(a3) {
255
+ if (!c2) {
256
+ c2 = true;
257
+ d2 = a3;
258
+ a3 = l(a3);
259
+ if (void 0 !== g && f.hasValue) {
260
+ var b2 = f.value;
261
+ if (g(b2, a3)) return k = b2;
262
+ }
263
+ return k = a3;
264
+ }
265
+ b2 = k;
266
+ if (q(d2, a3)) return b2;
267
+ var e2 = l(a3);
268
+ if (void 0 !== g && g(b2, e2)) return b2;
269
+ d2 = a3;
270
+ return k = e2;
271
+ }
272
+ var c2 = false, d2, k, m = void 0 === e ? null : e;
3699
273
  return [function() {
3700
- return a3(b2());
3701
- }, null === m2 ? void 0 : function() {
3702
- return a3(m2());
274
+ return a2(b());
275
+ }, null === m ? void 0 : function() {
276
+ return a2(m());
3703
277
  }];
3704
- }, [b2, e2, l2, g2]);
3705
- var d2 = r2(a2, c2[0], c2[1]);
3706
- u2(function() {
3707
- f2.hasValue = true;
3708
- f2.value = d2;
3709
- }, [d2]);
3710
- w2(d2);
3711
- return d2;
278
+ }, [b, e, l, g]);
279
+ var d = r(a, c[0], c[1]);
280
+ u(function() {
281
+ f.hasValue = true;
282
+ f.value = d;
283
+ }, [d]);
284
+ w(d);
285
+ return d;
3712
286
  };
3713
287
  return withSelector_production_min;
3714
288
  }
@@ -3731,10 +305,10 @@ function requireWithSelector_development() {
3731
305
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
3732
306
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
3733
307
  }
3734
- var React = require$$0$1;
308
+ var React = require$$0;
3735
309
  var shim2 = requireShim();
3736
- function is(x2, y2) {
3737
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
310
+ function is(x, y2) {
311
+ return x === y2 && (x !== 0 || 1 / x === 1 / y2) || x !== x && y2 !== y2;
3738
312
  }
3739
313
  var objectIs = typeof Object.is === "function" ? Object.is : is;
3740
314
  var useSyncExternalStore = shim2.useSyncExternalStore;
@@ -3822,25 +396,25 @@ function requireWithSelector() {
3822
396
  return withSelector.exports;
3823
397
  }
3824
398
  requireWithSelector();
3825
- var y = (t2, e2, n2) => {
399
+ var y = (t, e, n) => {
3826
400
  var _a, _b;
3827
- let r2 = require$$0$1.useRef((_a = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a.call(t2, e2, n2)), s2 = ((_b = t2 == null ? void 0 : t2.keyOfEntity) == null ? void 0 : _b.call(t2, e2)) ?? e2, u2 = require$$0$1.useCallback((o2) => {
401
+ let r = require$$0.useRef((_a = t == null ? void 0 : t.resolve) == null ? void 0 : _a.call(t, e, n)), s = ((_b = t == null ? void 0 : t.keyOfEntity) == null ? void 0 : _b.call(t, e)) ?? e, u = require$$0.useCallback((o) => {
3828
402
  var _a2, _b2;
3829
- return s2 ? (r2.current = (_a2 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a2.call(t2, s2, n2), o2(), (_b2 = t2 == null ? void 0 : t2.subscribe) == null ? void 0 : _b2.call(t2, s2, () => {
403
+ return s ? (r.current = (_a2 = t == null ? void 0 : t.resolve) == null ? void 0 : _a2.call(t, s, n), o(), (_b2 = t == null ? void 0 : t.subscribe) == null ? void 0 : _b2.call(t, s, () => {
3830
404
  var _a3;
3831
- return r2.current = (_a3 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a3.call(t2, s2, n2), o2();
3832
- }, n2)) : () => {
405
+ return r.current = (_a3 = t == null ? void 0 : t.resolve) == null ? void 0 : _a3.call(t, s, n), o();
406
+ }, n)) : () => {
3833
407
  };
3834
- }, [t2, s2]), i2 = require$$0$1.useCallback((o2) => {
3835
- let p2 = typeof e2 == "string" ? e2 : t2.keyOfEntity(e2);
3836
- e2 && p2 && t2.mutate(p2, o2);
3837
- }, [t2, e2]), a2 = () => r2.current;
3838
- return [shimExports.useSyncExternalStore(u2, a2, a2), i2];
408
+ }, [t, s]), i = require$$0.useCallback((o) => {
409
+ let p = typeof e == "string" ? e : t.keyOfEntity(e);
410
+ e && p && t.mutate(p, o);
411
+ }, [t, e]), a = () => r.current;
412
+ return [shimExports.useSyncExternalStore(u, a, a), i];
3839
413
  };
3840
414
  const useFragmentManager = (fragmentId) => {
3841
415
  const globalManager = useGlobalManager();
3842
416
  const [globalGraph] = y(globalManager, globalManager == null ? void 0 : globalManager.key);
3843
- const [loading, setLoading] = require$$0$1.useState(false);
417
+ const [loading, setLoading] = require$$0.useState(false);
3844
418
  const getFragmentManager = (id) => {
3845
419
  var _a;
3846
420
  return (_a = globalGraph == null ? void 0 : globalGraph.fragmentsManagers) == null ? void 0 : _a[id];
@@ -3852,7 +426,7 @@ const useFragmentManager = (fragmentId) => {
3852
426
  setLoading(false);
3853
427
  return res;
3854
428
  };
3855
- require$$0$1.useEffect(() => {
429
+ require$$0.useEffect(() => {
3856
430
  loadFragmentManager(fragmentId);
3857
431
  }, [fragmentId]);
3858
432
  return {
@@ -3866,1055 +440,21 @@ const useFragmentProperties = (fragmentId) => {
3866
440
  const [instanceFragment] = y(manager, (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root);
3867
441
  return (instanceFragment == null ? void 0 : instanceFragment.properties) ?? [];
3868
442
  };
3869
- const createConstants = (...constants) => {
3870
- return constants.reduce((acc, constant) => {
3871
- acc[constant] = constant;
3872
- return acc;
3873
- }, {});
3874
- };
3875
- const nodes = createConstants(
3876
- "Fragment",
3877
- "FragmentInstance",
3878
- "Instance",
3879
- "Breakpoint",
3880
- "Frame",
3881
- "Image",
3882
- "Text",
3883
- "SolidPaintStyle",
3884
- "CssLink",
3885
- "Variable",
3886
- "ComputedValue",
3887
- "TransformValue"
3888
- );
3889
- const fragmentGrowingMode = createConstants("auto", "fill");
3890
- const borderType = createConstants("None", "Solid", "Dashed", "Dotted");
3891
- const linkTarget = createConstants("_blank");
3892
- const paintMode = createConstants("None", "Solid", "Image");
3893
- const imagePaintScaleModes = createConstants(
3894
- "Fill",
3895
- "Fit",
3896
- "Crop",
3897
- "Tile"
3898
- );
3899
- const constrain = createConstants(
3900
- "Min",
3901
- "Center",
3902
- "Max",
3903
- "Stretch",
3904
- "Scale"
3905
- );
3906
- const positionType = createConstants("absolute", "relative");
3907
- const sizing = createConstants("Fixed", "Hug", "Fill", "Relative");
3908
- const layerMode = createConstants("none", "flex");
3909
- const layerDirection = createConstants("vertical", "horizontal");
3910
- const layerAlign = createConstants("start", "center", "end");
3911
- const layerDistribute = createConstants(
3912
- "start",
3913
- "center",
3914
- "end",
3915
- "space-between",
3916
- "space-around"
3917
- );
3918
- const textTransform = createConstants(
3919
- "none",
3920
- "uppercase",
3921
- "lowercase",
3922
- "capitalize"
3923
- );
3924
- const textDecorations = createConstants(
3925
- "none",
3926
- "underline",
3927
- "line-through"
3928
- );
3929
- const effectType = createConstants("loop", "appear", "hover", "tap");
3930
- const effectName = createConstants(
3931
- "fade",
3932
- "slide",
3933
- "bounce",
3934
- "wiggle",
3935
- "increase"
3936
- );
3937
- const variableType = createConstants(
3938
- "String",
3939
- "Boolean",
3940
- "Array",
3941
- "Color",
3942
- "ComponentInstance",
3943
- "Date",
3944
- "Enum",
3945
- "Number",
3946
- "Object"
3947
- );
3948
- const whiteSpace = createConstants(
3949
- "normal",
3950
- "nowrap",
3951
- "pre",
3952
- "pre-wrap",
3953
- "pre-line",
3954
- "break-spaces"
3955
- );
3956
- const overflow = createConstants("visible", "hidden", "scroll");
3957
- const variableTransforms = createConstants(
3958
- "convert",
3959
- "exists",
3960
- "equals",
3961
- "startWith",
3962
- "endWith",
3963
- "contains",
3964
- "dateBefore",
3965
- "dateAfter",
3966
- "dateBetween",
3967
- "feature",
3968
- "notFeature",
3969
- "gt",
3970
- // Greater than
3971
- "gte",
3972
- // Greater than or equals
3973
- "lt",
3974
- // Less than
3975
- "lte",
3976
- // Less than or equals,
3977
- "convertFromBoolean",
3978
- "negative"
3979
- );
3980
- const renderTarget = createConstants("canvas", "document");
3981
- const renderMode = createConstants("viewport", "parent", "fixed");
3982
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3983
- __proto__: null,
3984
- borderType,
3985
- constrain,
3986
- createConstants,
3987
- effectName,
3988
- effectType,
3989
- fragmentGrowingMode,
3990
- imagePaintScaleModes,
3991
- layerAlign,
3992
- layerDirection,
3993
- layerDistribute,
3994
- layerMode,
3995
- linkTarget,
3996
- nodes,
3997
- overflow,
3998
- paintMode,
3999
- positionType,
4000
- renderMode,
4001
- renderTarget,
4002
- sizing,
4003
- textDecorations,
4004
- textTransform,
4005
- variableTransforms,
4006
- variableType,
4007
- whiteSpace
4008
- }, Symbol.toStringTag, { value: "Module" }));
4009
- // @__NO_SIDE_EFFECTS__
4010
- function getGlobalConfig(config2) {
4011
- return {
4012
- lang: (config2 == null ? void 0 : config2.lang) ?? void 0,
4013
- message: config2 == null ? void 0 : config2.message,
4014
- abortEarly: (config2 == null ? void 0 : config2.abortEarly) ?? void 0,
4015
- abortPipeEarly: (config2 == null ? void 0 : config2.abortPipeEarly) ?? void 0
4016
- };
4017
- }
4018
- // @__NO_SIDE_EFFECTS__
4019
- function getGlobalMessage(lang) {
4020
- return void 0;
4021
- }
4022
- // @__NO_SIDE_EFFECTS__
4023
- function getSchemaMessage(lang) {
4024
- return void 0;
4025
- }
4026
- // @__NO_SIDE_EFFECTS__
4027
- function getSpecificMessage(reference, lang) {
4028
- var _a;
4029
- return (_a = void 0) == null ? void 0 : _a.get(lang);
4030
- }
4031
- // @__NO_SIDE_EFFECTS__
4032
- function _stringify(input) {
4033
- var _a, _b;
4034
- const type = typeof input;
4035
- if (type === "string") {
4036
- return `"${input}"`;
4037
- }
4038
- if (type === "number" || type === "bigint" || type === "boolean") {
4039
- return `${input}`;
4040
- }
4041
- if (type === "object" || type === "function") {
4042
- return (input && ((_b = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name)) ?? "null";
4043
- }
4044
- return type;
4045
- }
4046
- function _addIssue(context, label, dataset, config2, other) {
4047
- const input = other && "input" in other ? other.input : dataset.value;
4048
- const expected = (other == null ? void 0 : other.expected) ?? context.expects ?? null;
4049
- const received = (other == null ? void 0 : other.received) ?? /* @__PURE__ */ _stringify(input);
4050
- const issue = {
4051
- kind: context.kind,
4052
- type: context.type,
4053
- input,
4054
- expected,
4055
- received,
4056
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
4057
- requirement: context.requirement,
4058
- path: other == null ? void 0 : other.path,
4059
- issues: other == null ? void 0 : other.issues,
4060
- lang: config2.lang,
4061
- abortEarly: config2.abortEarly,
4062
- abortPipeEarly: config2.abortPipeEarly
4063
- };
4064
- const isSchema = context.kind === "schema";
4065
- const message = (other == null ? void 0 : other.message) ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
4066
- if (message !== void 0) {
4067
- issue.message = typeof message === "function" ? (
4068
- // @ts-expect-error
4069
- message(issue)
4070
- ) : message;
4071
- }
4072
- if (isSchema) {
4073
- dataset.typed = false;
4074
- }
4075
- if (dataset.issues) {
4076
- dataset.issues.push(issue);
4077
- } else {
4078
- dataset.issues = [issue];
4079
- }
4080
- }
4081
- // @__NO_SIDE_EFFECTS__
4082
- function _getStandardProps(context) {
4083
- return {
4084
- version: 1,
4085
- vendor: "valibot",
4086
- validate(value2) {
4087
- return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
4088
- }
4089
- };
4090
- }
4091
- // @__NO_SIDE_EFFECTS__
4092
- function _isValidObjectKey(object2, key) {
4093
- return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
4094
- }
4095
- // @__NO_SIDE_EFFECTS__
4096
- function _joinExpects(values2, separator) {
4097
- const list = [...new Set(values2)];
4098
- if (list.length > 1) {
4099
- return `(${list.join(` ${separator} `)})`;
4100
- }
4101
- return list[0] ?? "never";
4102
- }
4103
- // @__NO_SIDE_EFFECTS__
4104
- function check(requirement, message) {
4105
- return {
4106
- kind: "validation",
4107
- type: "check",
4108
- reference: check,
4109
- async: false,
4110
- expects: null,
4111
- requirement,
4112
- message,
4113
- "~run"(dataset, config2) {
4114
- if (dataset.typed && !this.requirement(dataset.value)) {
4115
- _addIssue(this, "input", dataset, config2);
4116
- }
4117
- return dataset;
4118
- }
4119
- };
4120
- }
4121
- // @__NO_SIDE_EFFECTS__
4122
- function maxValue(requirement, message) {
4123
- return {
4124
- kind: "validation",
4125
- type: "max_value",
4126
- reference: maxValue,
4127
- async: false,
4128
- expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
4129
- requirement,
4130
- message,
4131
- "~run"(dataset, config2) {
4132
- if (dataset.typed && !(dataset.value <= this.requirement)) {
4133
- _addIssue(this, "value", dataset, config2, {
4134
- received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value)
4135
- });
4136
- }
4137
- return dataset;
4138
- }
4139
- };
4140
- }
4141
- // @__NO_SIDE_EFFECTS__
4142
- function metadata(metadata_) {
4143
- return {
4144
- kind: "metadata",
4145
- type: "metadata",
4146
- reference: metadata,
4147
- metadata: metadata_
4148
- };
4149
- }
4150
- // @__NO_SIDE_EFFECTS__
4151
- function minValue(requirement, message) {
4152
- return {
4153
- kind: "validation",
4154
- type: "min_value",
4155
- reference: minValue,
4156
- async: false,
4157
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
4158
- requirement,
4159
- message,
4160
- "~run"(dataset, config2) {
4161
- if (dataset.typed && !(dataset.value >= this.requirement)) {
4162
- _addIssue(this, "value", dataset, config2, {
4163
- received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value)
4164
- });
4165
- }
4166
- return dataset;
4167
- }
4168
- };
4169
- }
4170
- // @__NO_SIDE_EFFECTS__
4171
- function getFallback(schema, dataset, config2) {
4172
- return typeof schema.fallback === "function" ? (
4173
- // @ts-expect-error
4174
- schema.fallback(dataset, config2)
4175
- ) : (
4176
- // @ts-expect-error
4177
- schema.fallback
4178
- );
4179
- }
4180
- // @__NO_SIDE_EFFECTS__
4181
- function getDefault(schema, dataset, config2) {
4182
- return typeof schema.default === "function" ? (
4183
- // @ts-expect-error
4184
- schema.default(dataset, config2)
4185
- ) : (
4186
- // @ts-expect-error
4187
- schema.default
4188
- );
4189
- }
4190
- // @__NO_SIDE_EFFECTS__
4191
- function array(item, message) {
4192
- return {
4193
- kind: "schema",
4194
- type: "array",
4195
- reference: array,
4196
- expects: "Array",
4197
- async: false,
4198
- item,
4199
- message,
4200
- get "~standard"() {
4201
- return /* @__PURE__ */ _getStandardProps(this);
4202
- },
4203
- "~run"(dataset, config2) {
4204
- var _a;
4205
- const input = dataset.value;
4206
- if (Array.isArray(input)) {
4207
- dataset.typed = true;
4208
- dataset.value = [];
4209
- for (let key = 0; key < input.length; key++) {
4210
- const value2 = input[key];
4211
- const itemDataset = this.item["~run"]({ value: value2 }, config2);
4212
- if (itemDataset.issues) {
4213
- const pathItem = {
4214
- type: "array",
4215
- origin: "value",
4216
- input,
4217
- key,
4218
- value: value2
4219
- };
4220
- for (const issue of itemDataset.issues) {
4221
- if (issue.path) {
4222
- issue.path.unshift(pathItem);
4223
- } else {
4224
- issue.path = [pathItem];
4225
- }
4226
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
4227
- }
4228
- if (!dataset.issues) {
4229
- dataset.issues = itemDataset.issues;
4230
- }
4231
- if (config2.abortEarly) {
4232
- dataset.typed = false;
4233
- break;
4234
- }
4235
- }
4236
- if (!itemDataset.typed) {
4237
- dataset.typed = false;
4238
- }
4239
- dataset.value.push(itemDataset.value);
4240
- }
4241
- } else {
4242
- _addIssue(this, "type", dataset, config2);
4243
- }
4244
- return dataset;
4245
- }
4246
- };
4247
- }
4248
- // @__NO_SIDE_EFFECTS__
4249
- function boolean(message) {
4250
- return {
4251
- kind: "schema",
4252
- type: "boolean",
4253
- reference: boolean,
4254
- expects: "boolean",
4255
- async: false,
4256
- message,
4257
- get "~standard"() {
4258
- return /* @__PURE__ */ _getStandardProps(this);
4259
- },
4260
- "~run"(dataset, config2) {
4261
- if (typeof dataset.value === "boolean") {
4262
- dataset.typed = true;
4263
- } else {
4264
- _addIssue(this, "type", dataset, config2);
4265
- }
4266
- return dataset;
4267
- }
4268
- };
4269
- }
4270
- // @__NO_SIDE_EFFECTS__
4271
- function enum_(enum__, message) {
4272
- const options = [];
4273
- for (const key in enum__) {
4274
- if (`${+key}` !== key || typeof enum__[key] !== "string" || !Object.is(enum__[enum__[key]], +key)) {
4275
- options.push(enum__[key]);
4276
- }
4277
- }
4278
- return {
4279
- kind: "schema",
4280
- type: "enum",
4281
- reference: enum_,
4282
- expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
4283
- async: false,
4284
- enum: enum__,
4285
- options,
4286
- message,
4287
- get "~standard"() {
4288
- return /* @__PURE__ */ _getStandardProps(this);
4289
- },
4290
- "~run"(dataset, config2) {
4291
- if (this.options.includes(dataset.value)) {
4292
- dataset.typed = true;
4293
- } else {
4294
- _addIssue(this, "type", dataset, config2);
4295
- }
4296
- return dataset;
4297
- }
4298
- };
4299
- }
4300
- // @__NO_SIDE_EFFECTS__
4301
- function literal(literal_, message) {
4302
- return {
4303
- kind: "schema",
4304
- type: "literal",
4305
- reference: literal,
4306
- expects: /* @__PURE__ */ _stringify(literal_),
4307
- async: false,
4308
- literal: literal_,
4309
- message,
4310
- get "~standard"() {
4311
- return /* @__PURE__ */ _getStandardProps(this);
4312
- },
4313
- "~run"(dataset, config2) {
4314
- if (dataset.value === this.literal) {
4315
- dataset.typed = true;
4316
- } else {
4317
- _addIssue(this, "type", dataset, config2);
4318
- }
4319
- return dataset;
4320
- }
4321
- };
4322
- }
4323
- // @__NO_SIDE_EFFECTS__
4324
- function number(message) {
4325
- return {
4326
- kind: "schema",
4327
- type: "number",
4328
- reference: number,
4329
- expects: "number",
4330
- async: false,
4331
- message,
4332
- get "~standard"() {
4333
- return /* @__PURE__ */ _getStandardProps(this);
4334
- },
4335
- "~run"(dataset, config2) {
4336
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
4337
- dataset.typed = true;
4338
- } else {
4339
- _addIssue(this, "type", dataset, config2);
4340
- }
4341
- return dataset;
4342
- }
4343
- };
4344
- }
4345
- // @__NO_SIDE_EFFECTS__
4346
- function object(entries, message) {
4347
- return {
4348
- kind: "schema",
4349
- type: "object",
4350
- reference: object,
4351
- expects: "Object",
4352
- async: false,
4353
- entries,
4354
- message,
4355
- get "~standard"() {
4356
- return /* @__PURE__ */ _getStandardProps(this);
4357
- },
4358
- "~run"(dataset, config2) {
4359
- var _a;
4360
- const input = dataset.value;
4361
- if (input && typeof input === "object") {
4362
- dataset.typed = true;
4363
- dataset.value = {};
4364
- for (const key in this.entries) {
4365
- const valueSchema = this.entries[key];
4366
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
4367
- valueSchema.default !== void 0) {
4368
- const value2 = key in input ? (
4369
- // @ts-expect-error
4370
- input[key]
4371
- ) : /* @__PURE__ */ getDefault(valueSchema);
4372
- const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
4373
- if (valueDataset.issues) {
4374
- const pathItem = {
4375
- type: "object",
4376
- origin: "value",
4377
- input,
4378
- key,
4379
- value: value2
4380
- };
4381
- for (const issue of valueDataset.issues) {
4382
- if (issue.path) {
4383
- issue.path.unshift(pathItem);
4384
- } else {
4385
- issue.path = [pathItem];
4386
- }
4387
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
4388
- }
4389
- if (!dataset.issues) {
4390
- dataset.issues = valueDataset.issues;
4391
- }
4392
- if (config2.abortEarly) {
4393
- dataset.typed = false;
4394
- break;
4395
- }
4396
- }
4397
- if (!valueDataset.typed) {
4398
- dataset.typed = false;
4399
- }
4400
- dataset.value[key] = valueDataset.value;
4401
- } else if (valueSchema.fallback !== void 0) {
4402
- dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
4403
- } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
4404
- _addIssue(this, "key", dataset, config2, {
4405
- input: void 0,
4406
- expected: `"${key}"`,
4407
- path: [
4408
- {
4409
- type: "object",
4410
- origin: "key",
4411
- input,
4412
- key,
4413
- // @ts-expect-error
4414
- value: input[key]
4415
- }
4416
- ]
4417
- });
4418
- if (config2.abortEarly) {
4419
- break;
4420
- }
4421
- }
4422
- }
4423
- } else {
4424
- _addIssue(this, "type", dataset, config2);
4425
- }
4426
- return dataset;
4427
- }
4428
- };
4429
- }
4430
- // @__NO_SIDE_EFFECTS__
4431
- function optional(wrapped, default_) {
4432
- return {
4433
- kind: "schema",
4434
- type: "optional",
4435
- reference: optional,
4436
- expects: `(${wrapped.expects} | undefined)`,
4437
- async: false,
4438
- wrapped,
4439
- default: default_,
4440
- get "~standard"() {
4441
- return /* @__PURE__ */ _getStandardProps(this);
4442
- },
4443
- "~run"(dataset, config2) {
4444
- if (dataset.value === void 0) {
4445
- if (this.default !== void 0) {
4446
- dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
4447
- }
4448
- if (dataset.value === void 0) {
4449
- dataset.typed = true;
4450
- return dataset;
4451
- }
4452
- }
4453
- return this.wrapped["~run"](dataset, config2);
4454
- }
4455
- };
4456
- }
4457
- // @__NO_SIDE_EFFECTS__
4458
- function picklist(options, message) {
4459
- return {
4460
- kind: "schema",
4461
- type: "picklist",
4462
- reference: picklist,
4463
- expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
4464
- async: false,
4465
- options,
4466
- message,
4467
- get "~standard"() {
4468
- return /* @__PURE__ */ _getStandardProps(this);
4469
- },
4470
- "~run"(dataset, config2) {
4471
- if (this.options.includes(dataset.value)) {
4472
- dataset.typed = true;
4473
- } else {
4474
- _addIssue(this, "type", dataset, config2);
4475
- }
4476
- return dataset;
4477
- }
4478
- };
4479
- }
4480
- // @__NO_SIDE_EFFECTS__
4481
- function record(key, value2, message) {
4482
- return {
4483
- kind: "schema",
4484
- type: "record",
4485
- reference: record,
4486
- expects: "Object",
4487
- async: false,
4488
- key,
4489
- value: value2,
4490
- message,
4491
- get "~standard"() {
4492
- return /* @__PURE__ */ _getStandardProps(this);
4493
- },
4494
- "~run"(dataset, config2) {
4495
- var _a, _b;
4496
- const input = dataset.value;
4497
- if (input && typeof input === "object") {
4498
- dataset.typed = true;
4499
- dataset.value = {};
4500
- for (const entryKey in input) {
4501
- if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
4502
- const entryValue = input[entryKey];
4503
- const keyDataset = this.key["~run"]({ value: entryKey }, config2);
4504
- if (keyDataset.issues) {
4505
- const pathItem = {
4506
- type: "object",
4507
- origin: "key",
4508
- input,
4509
- key: entryKey,
4510
- value: entryValue
4511
- };
4512
- for (const issue of keyDataset.issues) {
4513
- issue.path = [pathItem];
4514
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
4515
- }
4516
- if (!dataset.issues) {
4517
- dataset.issues = keyDataset.issues;
4518
- }
4519
- if (config2.abortEarly) {
4520
- dataset.typed = false;
4521
- break;
4522
- }
4523
- }
4524
- const valueDataset = this.value["~run"](
4525
- { value: entryValue },
4526
- config2
4527
- );
4528
- if (valueDataset.issues) {
4529
- const pathItem = {
4530
- type: "object",
4531
- origin: "value",
4532
- input,
4533
- key: entryKey,
4534
- value: entryValue
4535
- };
4536
- for (const issue of valueDataset.issues) {
4537
- if (issue.path) {
4538
- issue.path.unshift(pathItem);
4539
- } else {
4540
- issue.path = [pathItem];
4541
- }
4542
- (_b = dataset.issues) == null ? void 0 : _b.push(issue);
4543
- }
4544
- if (!dataset.issues) {
4545
- dataset.issues = valueDataset.issues;
4546
- }
4547
- if (config2.abortEarly) {
4548
- dataset.typed = false;
4549
- break;
4550
- }
4551
- }
4552
- if (!keyDataset.typed || !valueDataset.typed) {
4553
- dataset.typed = false;
4554
- }
4555
- if (keyDataset.typed) {
4556
- dataset.value[keyDataset.value] = valueDataset.value;
4557
- }
4558
- }
4559
- }
4560
- } else {
4561
- _addIssue(this, "type", dataset, config2);
4562
- }
4563
- return dataset;
4564
- }
4565
- };
4566
- }
4567
- // @__NO_SIDE_EFFECTS__
4568
- function string(message) {
4569
- return {
4570
- kind: "schema",
4571
- type: "string",
4572
- reference: string,
4573
- expects: "string",
4574
- async: false,
4575
- message,
4576
- get "~standard"() {
4577
- return /* @__PURE__ */ _getStandardProps(this);
4578
- },
4579
- "~run"(dataset, config2) {
4580
- if (typeof dataset.value === "string") {
4581
- dataset.typed = true;
4582
- } else {
4583
- _addIssue(this, "type", dataset, config2);
4584
- }
4585
- return dataset;
4586
- }
4587
- };
4588
- }
4589
- // @__NO_SIDE_EFFECTS__
4590
- function _subIssues(datasets) {
4591
- let issues;
4592
- if (datasets) {
4593
- for (const dataset of datasets) {
4594
- if (issues) {
4595
- issues.push(...dataset.issues);
4596
- } else {
4597
- issues = dataset.issues;
4598
- }
4599
- }
4600
- }
4601
- return issues;
4602
- }
4603
- // @__NO_SIDE_EFFECTS__
4604
- function union(options, message) {
4605
- return {
4606
- kind: "schema",
4607
- type: "union",
4608
- reference: union,
4609
- expects: /* @__PURE__ */ _joinExpects(
4610
- options.map((option) => option.expects),
4611
- "|"
4612
- ),
4613
- async: false,
4614
- options,
4615
- message,
4616
- get "~standard"() {
4617
- return /* @__PURE__ */ _getStandardProps(this);
4618
- },
4619
- "~run"(dataset, config2) {
4620
- let validDataset;
4621
- let typedDatasets;
4622
- let untypedDatasets;
4623
- for (const schema of this.options) {
4624
- const optionDataset = schema["~run"]({ value: dataset.value }, config2);
4625
- if (optionDataset.typed) {
4626
- if (optionDataset.issues) {
4627
- if (typedDatasets) {
4628
- typedDatasets.push(optionDataset);
4629
- } else {
4630
- typedDatasets = [optionDataset];
4631
- }
4632
- } else {
4633
- validDataset = optionDataset;
4634
- break;
4635
- }
4636
- } else {
4637
- if (untypedDatasets) {
4638
- untypedDatasets.push(optionDataset);
4639
- } else {
4640
- untypedDatasets = [optionDataset];
4641
- }
4642
- }
4643
- }
4644
- if (validDataset) {
4645
- return validDataset;
4646
- }
4647
- if (typedDatasets) {
4648
- if (typedDatasets.length === 1) {
4649
- return typedDatasets[0];
4650
- }
4651
- _addIssue(this, "type", dataset, config2, {
4652
- issues: /* @__PURE__ */ _subIssues(typedDatasets)
4653
- });
4654
- dataset.typed = true;
4655
- } else if ((untypedDatasets == null ? void 0 : untypedDatasets.length) === 1) {
4656
- return untypedDatasets[0];
4657
- } else {
4658
- _addIssue(this, "type", dataset, config2, {
4659
- issues: /* @__PURE__ */ _subIssues(untypedDatasets)
4660
- });
4661
- }
4662
- return dataset;
4663
- }
4664
- };
4665
- }
4666
- // @__NO_SIDE_EFFECTS__
4667
- function pipe(...pipe2) {
4668
- return {
4669
- ...pipe2[0],
4670
- pipe: pipe2,
4671
- get "~standard"() {
4672
- return /* @__PURE__ */ _getStandardProps(this);
4673
- },
4674
- "~run"(dataset, config2) {
4675
- for (const item of pipe2) {
4676
- if (item.kind !== "metadata") {
4677
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
4678
- dataset.typed = false;
4679
- break;
4680
- }
4681
- if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
4682
- dataset = item["~run"](dataset, config2);
4683
- }
4684
- }
4685
- }
4686
- return dataset;
4687
- }
4688
- };
4689
- }
4690
- const linkValidator = /* @__PURE__ */ check(
4691
- (value) => {
4692
- var _a, _b;
4693
- return !!value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
4694
- }
4695
- );
4696
- const layerField = (schema, meta) => {
4697
- const modifiedSchema = (meta == null ? void 0 : meta.variable) ? /* @__PURE__ */ union([schema, /* @__PURE__ */ pipe(/* @__PURE__ */ string(), linkValidator)]) : schema;
4698
- return /* @__PURE__ */ pipe(/* @__PURE__ */ optional(modifiedSchema), /* @__PURE__ */ metadata(meta ?? {}));
4699
- };
4700
- const ChildrenSchema = /* @__PURE__ */ object({
4701
- children: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), {
4702
- fallback: [],
4703
- overridable: false
4704
- })
4705
- });
4706
- const GraphFieldSchema = /* @__PURE__ */ object({
4707
- _id: /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ number()]),
4708
- _type: /* @__PURE__ */ picklist(Object.keys(nodes))
4709
- });
4710
- const OverridesSchema = /* @__PURE__ */ object({
4711
- overrides: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), { overridable: false })
4712
- });
4713
- const PositionSchema = /* @__PURE__ */ object({
4714
- position: layerField(/* @__PURE__ */ enum_(Object.keys(positionType)), {
4715
- fallback: positionType.absolute
4716
- }),
4717
- top: layerField(/* @__PURE__ */ number(), { fallback: 0 }),
4718
- left: layerField(/* @__PURE__ */ number(), { fallback: 0 })
4719
- });
4720
- const SceneSchema = /* @__PURE__ */ object({
4721
- opacity: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0), /* @__PURE__ */ maxValue(1)), {
4722
- fallback: 1,
4723
- variable: true
4724
- }),
4725
- visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
4726
- zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 }),
4727
- borderRadius: layerField(/* @__PURE__ */ string(), { fallback: "0px" }),
4728
- overflow: layerField(/* @__PURE__ */ picklist(Object.keys(overflow)), {
4729
- fallback: overflow.hidden
4730
- })
4731
- });
4732
- const FillSchema = /* @__PURE__ */ object({
4733
- fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
4734
- fallback: paintMode.None
4735
- }),
4736
- solidFill: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
4737
- });
4738
- const BorderSchema = /* @__PURE__ */ object({
4739
- borderType: layerField(/* @__PURE__ */ picklist(Object.keys(borderType)), {
4740
- fallback: borderType.None
4741
- }),
4742
- borderWidth: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
4743
- borderColor: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
4744
- });
4745
- const SizeSchema = /* @__PURE__ */ object({
4746
- widthType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
4747
- fallback: sizing.Fixed
4748
- }),
4749
- heightType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
4750
- fallback: sizing.Fixed
4751
- }),
4752
- width: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
4753
- height: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
4754
- aspectRatio: layerField(/* @__PURE__ */ number(), { fallback: -1 })
4755
- });
4756
- const LayerSchema = /* @__PURE__ */ object({
4757
- layerMode: layerField(/* @__PURE__ */ picklist(Object.keys(layerMode)), {
4758
- fallback: layerMode.none
4759
- }),
4760
- layerAlign: layerField(/* @__PURE__ */ picklist(Object.keys(layerAlign)), {
4761
- fallback: layerAlign.start
4762
- }),
4763
- layerDirection: layerField(/* @__PURE__ */ picklist(Object.keys(layerDirection)), {
4764
- fallback: layerDirection.horizontal
4765
- }),
4766
- layerDistribute: layerField(/* @__PURE__ */ picklist(Object.keys(layerDistribute)), {
4767
- fallback: layerDistribute.start
4768
- }),
4769
- layerWrap: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4770
- layerGap: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
4771
- padding: layerField(/* @__PURE__ */ string(), { fallback: "0px" })
4772
- });
4773
- /* @__PURE__ */ pipe(
4774
- /* @__PURE__ */ object({
4775
- name: layerField(/* @__PURE__ */ string(), { fallback: "Frame", overridable: false }),
4776
- isBreakpoint: layerField(/* @__PURE__ */ boolean(), {
4777
- fallback: false,
4778
- overridable: false
4779
- }),
4780
- isPrimary: layerField(/* @__PURE__ */ boolean(), { fallback: false, overridable: false }),
4781
- threshold: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), {
4782
- fallback: 320,
4783
- overridable: false
4784
- }),
4785
- ...ChildrenSchema.entries,
4786
- ...GraphFieldSchema.entries,
4787
- ...OverridesSchema.entries,
4788
- ...PositionSchema.entries,
4789
- ...SceneSchema.entries,
4790
- ...FillSchema.entries,
4791
- ...BorderSchema.entries,
4792
- ...SizeSchema.entries,
4793
- ...LayerSchema.entries
4794
- })
4795
- );
4796
- /* @__PURE__ */ object({
4797
- name: layerField(/* @__PURE__ */ string(), { fallback: "Text", overridable: false }),
4798
- content: layerField(/* @__PURE__ */ string(), {
4799
- fallback: ""
4800
- }),
4801
- variableContent: layerField(/* @__PURE__ */ string(), { fallback: null, variable: true }),
4802
- attributes: layerField(
4803
- /* @__PURE__ */ object({
4804
- fontSize: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
4805
- color: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
4806
- lineHeight: layerField(/* @__PURE__ */ string(), { fallback: "14px" })
4807
- }),
4808
- { fallback: {} }
4809
- ),
4810
- ...GraphFieldSchema.entries,
4811
- ...OverridesSchema.entries,
4812
- ...PositionSchema.entries,
4813
- ...SceneSchema.entries,
4814
- ...SizeSchema.entries
4815
- });
4816
- /* @__PURE__ */ object({
4817
- name: layerField(/* @__PURE__ */ string(), { fallback: "Fragment", overridable: false }),
4818
- horizontalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
4819
- fallback: fragmentGrowingMode.auto,
4820
- overridable: false
4821
- }),
4822
- verticalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
4823
- fallback: fragmentGrowingMode.auto,
4824
- overridable: false
4825
- }),
4826
- properties: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), {
4827
- fallback: [],
4828
- overridable: false
4829
- }),
4830
- ...GraphFieldSchema.entries,
4831
- ...ChildrenSchema.entries
4832
- });
4833
- /* @__PURE__ */ object({
4834
- name: layerField(/* @__PURE__ */ string(), { fallback: "Instance", overridable: false }),
4835
- fragment: layerField(/* @__PURE__ */ string()),
4836
- props: layerField(
4837
- /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ number(), /* @__PURE__ */ boolean()])),
4838
- {
4839
- fallback: {}
4840
- }
4841
- ),
4842
- ...GraphFieldSchema.entries,
4843
- ...OverridesSchema.entries,
4844
- ...PositionSchema.entries,
4845
- ...SizeSchema.entries,
4846
- ...SceneSchema.entries
4847
- });
4848
- /* @__PURE__ */ object({
4849
- name: layerField(/* @__PURE__ */ string(), {
4850
- fallback: "Number",
4851
- overridable: false
4852
- }),
4853
- type: layerField(/* @__PURE__ */ literal(variableType.Number), {
4854
- fallback: variableType.Number
4855
- }),
4856
- defaultValue: layerField(/* @__PURE__ */ number(), { fallback: 0 }),
4857
- required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4858
- min: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
4859
- max: layerField(/* @__PURE__ */ number(), { fallback: 100 }),
4860
- step: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
4861
- displayStepper: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
4862
- ...GraphFieldSchema.entries
4863
- });
4864
- /* @__PURE__ */ object({
4865
- name: layerField(/* @__PURE__ */ string(), {
4866
- fallback: "Boolean",
4867
- overridable: false
4868
- }),
4869
- type: layerField(/* @__PURE__ */ literal(variableType.Boolean), {
4870
- fallback: variableType.Boolean
4871
- }),
4872
- defaultValue: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4873
- required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4874
- ...GraphFieldSchema.entries
4875
- });
4876
- /* @__PURE__ */ object({
4877
- name: layerField(/* @__PURE__ */ string(), {
4878
- fallback: "String",
4879
- overridable: false
4880
- }),
4881
- type: layerField(/* @__PURE__ */ literal(variableType.Color), {
4882
- fallback: variableType.Color
4883
- }),
4884
- // TODO Add color validator
4885
- defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
4886
- required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4887
- ...GraphFieldSchema.entries
4888
- });
4889
- /* @__PURE__ */ object({
4890
- name: layerField(/* @__PURE__ */ string(), {
4891
- fallback: "String",
4892
- overridable: false
4893
- }),
4894
- type: layerField(/* @__PURE__ */ literal(variableType.String), {
4895
- fallback: variableType.String
4896
- }),
4897
- defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
4898
- required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4899
- placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
4900
- isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4901
- ...GraphFieldSchema.entries
4902
- });
4903
443
  const useRenderTarget = () => {
4904
444
  const globalManager = useGlobalManager();
4905
445
  const [globalManagerGraph] = y(globalManager, globalManager == null ? void 0 : globalManager.key);
4906
- const renderTargetValue = (globalManagerGraph == null ? void 0 : globalManagerGraph.renderTarget) ?? index.renderTarget.canvas;
446
+ const renderTargetValue = (globalManagerGraph == null ? void 0 : globalManagerGraph.renderTarget) ?? definition.definition.renderTarget.canvas;
4907
447
  return {
4908
448
  renderTarget: renderTargetValue,
4909
- isCanvas: renderTargetValue === index.renderTarget.canvas,
4910
- isDocument: renderTargetValue === index.renderTarget.document,
449
+ isCanvas: renderTargetValue === definition.definition.renderTarget.canvas,
450
+ isDocument: renderTargetValue === definition.definition.renderTarget.document,
4911
451
  setRenderTarget: (target) => {
4912
452
  globalManager == null ? void 0 : globalManager.setRenderTarget(target);
4913
453
  }
4914
454
  };
4915
455
  };
4916
- const Fragment = createReactComponent(Fragment$1);
4917
- const Instance = createReactComponent(Instance$1);
456
+ const Fragment = createReactComponent(renderCore.Fragment);
457
+ const Instance = createReactComponent(renderCore.Instance);
4918
458
  exports.Fragment = Fragment;
4919
459
  exports.GlobalManager = GlobalManager;
4920
460
  exports.Instance = Instance;