@fragmentsx/render-web 0.0.1 → 0.1.1

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.
Files changed (3) hide show
  1. package/dist/index.cjs.js +1406 -684
  2. package/dist/index.es.js +1406 -684
  3. package/package.json +9 -6
package/dist/index.cjs.js CHANGED
@@ -1,222 +1,623 @@
1
1
  "use strict";
2
2
  var isBrowser_default$2 = typeof window !== "undefined";
3
- var r$3 = (e2) => !e2 && e2 == null, y$4 = (e2) => !r$3(e2), a$3 = (e2) => typeof e2 == "object" && !Array.isArray(e2) && y$4(e2), f$3 = (e2) => typeof Node == "object" ? e2 instanceof Node : e2 && typeof e2 == "object" && typeof e2.nodeType == "number" && typeof e2.nodeName == "string", i$2 = (e2) => typeof e2 == "string" || t$2(e2), t$2 = (e2) => typeof e2 == "object" && typeof e2._type == "string", s$3 = (e2) => typeof e2 == "string" && e2.split(":").length >= 2, l$2 = (e2) => typeof e2 != "object" && typeof e2 != "function" || e2 === null, g$2 = (e2) => typeof e2 == "string" ? /<\/?[a-z][\s\S]*>/i.test(e2) : false, u$2 = (e2) => (n2) => {
3
+ var r$3 = (e2) => !e2 && e2 == null, y$4 = (e2) => !r$3(e2), a$3 = (e2) => typeof e2 == "object" && !Array.isArray(e2) && y$4(e2), f$3 = (e2) => typeof Node == "object" ? e2 instanceof Node : e2 && typeof e2 == "object" && typeof e2.nodeType == "number" && typeof e2.nodeName == "string", i$2 = (e2) => typeof e2 == "string" || t$2(e2), t$2 = (e2) => typeof e2 == "object" && typeof e2._type == "string", s$2 = (e2) => typeof e2 == "string" && e2.split(":").length >= 2, l$2 = (e2) => typeof e2 != "object" && typeof e2 != "function" || e2 === null, g$2 = (e2) => typeof e2 == "string" ? /<\/?[a-z][\s\S]*>/i.test(e2) : false, u$2 = (e2) => (n2) => {
4
4
  var _a;
5
5
  if (!n2) return false;
6
6
  let o2 = null;
7
- return s$3(n2) && (o2 = (_a = n2.split(":")) == null ? void 0 : _a[0]), t$2(n2) && (o2 = n2._type), o2 ? !e2.includes(o2) : false;
8
- };
9
- var G$2 = (e2) => s$3(e2), re = (e2) => i$2(e2), se = (e2) => t$2(e2), O$2 = (e2) => a$3(e2), ie = (e2, r2) => {
10
- if (e2 === r2) return true;
11
- if (Array.isArray(e2) && Array.isArray(r2)) return e2.length === r2.length && e2.every((c2, i2) => r2[i2] === c2);
12
- if (!O$2(e2) || !O$2(r2)) return false;
13
- let u2 = Object.keys(e2), p2 = Object.keys(r2);
14
- if (u2.length !== p2.length) return false;
15
- for (let c2 of u2) {
16
- if (!p2.includes(c2)) return false;
17
- let i2 = e2[c2], E2 = r2[c2];
18
- if (l$2(i2) && l$2(E2) && i2 !== E2) return false;
7
+ return s$2(n2) && (o2 = (_a = n2.split(":")) == null ? void 0 : _a[0]), t$2(n2) && (o2 = n2._type), o2 ? !e2.includes(o2) : false;
8
+ };
9
+ var isLinkKey = (input) => s$2(input);
10
+ var isGraphOrKey = (input) => i$2(input);
11
+ var isGraph = (input) => t$2(input);
12
+ var isObject$1$1 = (input) => a$3(input);
13
+ var shallowEqual = (a2, b) => {
14
+ if (a2 === b)
15
+ return true;
16
+ if (Array.isArray(a2) && Array.isArray(b)) {
17
+ return a2.length === b.length && a2.every((val, index2) => b[index2] === val);
18
+ }
19
+ if (!isObject$1$1(a2) || !isObject$1$1(b))
20
+ return false;
21
+ const keysA = Object.keys(a2);
22
+ const keysB = Object.keys(b);
23
+ if (keysA.length !== keysB.length)
24
+ return false;
25
+ for (const key of keysA) {
26
+ if (!keysB.includes(key))
27
+ return false;
28
+ const aValue = a2[key];
29
+ const bValue = b[key];
30
+ if (l$2(aValue) && l$2(bValue) && aValue !== bValue)
31
+ return false;
19
32
  }
20
33
  return true;
21
- }, W$1 = (e2, r2) => {
22
- if (e2 === r2) return true;
23
- if (Array.isArray(e2) && Array.isArray(r2)) return e2.length === r2.length && e2.every((c2, i2) => W$1(c2, r2[i2]));
24
- if (!O$2(r2) || !O$2(e2)) return e2 === r2;
25
- let u2 = Object.keys(e2), p2 = Object.keys(r2);
26
- if (u2.length !== p2.length) return false;
27
- for (let c2 of u2) if (!p2.includes(c2) || !W$1(e2[c2], r2[c2])) return false;
34
+ };
35
+ var deepEqual = (a2, b) => {
36
+ if (a2 === b)
37
+ return true;
38
+ if (Array.isArray(a2) && Array.isArray(b)) {
39
+ return a2.length === b.length && a2.every((val, i2) => deepEqual(val, b[i2]));
40
+ }
41
+ if (!isObject$1$1(b) || !isObject$1$1(a2))
42
+ return a2 === b;
43
+ const keysA = Object.keys(a2);
44
+ const keysB = Object.keys(b);
45
+ if (keysA.length !== keysB.length)
46
+ return false;
47
+ for (const key of keysA) {
48
+ if (!keysB.includes(key))
49
+ return false;
50
+ if (!deepEqual(a2[key], b[key]))
51
+ return false;
52
+ }
28
53
  return true;
29
54
  };
30
- var Y = (...e2) => Array.from(new Set(e2)), oe = (...e2) => e2.filter((r2, u2, p2) => s$3(r2) ? p2.indexOf(r2) === u2 : true);
31
- var M$1 = (e2) => e2 && e2.split(".").length > 1, J$1 = (e2, r2) => {
32
- if (!e2 || !r2) return false;
33
- if (typeof e2 != "string" || typeof r2 != "string") return null;
34
- let [u2, p2] = e2.split(":"), [c2, i2] = r2.split(":");
35
- return u2 !== c2 ? false : p2.startsWith(i2);
36
- }, ae = (e2) => G$2(e2) && M$1(e2) ? e2.split(".")[0] : e2;
37
- var ce = () => {
38
- let e2 = /* @__PURE__ */ new Map(), r2 = /* @__PURE__ */ new Map(), u2 = /* @__PURE__ */ new Map(), p2 = /* @__PURE__ */ new Map(), c2 = /* @__PURE__ */ new Map(), i2 = /* @__PURE__ */ new Map(), E2 = /* @__PURE__ */ new Set([]), V2 = (n2, d2) => {
55
+ var unique = (...values) => Array.from(new Set(values));
56
+ var uniqueLinks = (...values) => values.filter((item, index2, arr) => s$2(item) ? arr.indexOf(item) === index2 : true);
57
+ var isPartialKey = (key) => key && key.split(".").length > 1;
58
+ var isPartialGraph = (entity) => {
59
+ if (isObject$1$1(entity) && "_id" in entity && typeof entity._id === "string") {
60
+ return entity._id.includes(".");
61
+ }
62
+ return false;
63
+ };
64
+ var isPartOfGraph = (entityKey, graphKey) => {
65
+ if (!entityKey || !graphKey)
66
+ return false;
67
+ if (typeof entityKey !== "string" || typeof graphKey !== "string")
68
+ return null;
69
+ const [entityType, entityId] = entityKey.split(":");
70
+ const [graphType, graphId] = graphKey.split(":");
71
+ if (entityType !== graphType)
72
+ return false;
73
+ return entityId.startsWith(graphId);
74
+ };
75
+ var getGraphLink = (input) => {
76
+ if (isLinkKey(input)) {
77
+ if (isPartialKey(input)) {
78
+ return input.split(".")[0];
79
+ }
80
+ }
81
+ return input;
82
+ };
83
+ var createCache = () => {
84
+ const listeners = /* @__PURE__ */ new Map();
85
+ const types2 = /* @__PURE__ */ new Map();
86
+ const links = /* @__PURE__ */ new Map();
87
+ const parentRefs = /* @__PURE__ */ new Map();
88
+ const childrenRefs = /* @__PURE__ */ new Map();
89
+ const refCount = /* @__PURE__ */ new Map();
90
+ const gbLinks = /* @__PURE__ */ new Set([]);
91
+ const addRefs = (targetKey, depKey) => {
39
92
  var _a;
40
- p2.set(n2, Y(...p2.get(n2) || [], d2)), c2.set(d2, Y(...c2.get(d2) ?? [], n2)), R(n2, ((_a = p2.get(n2)) == null ? void 0 : _a.length) || 0);
41
- }, D2 = (n2, d2) => {
93
+ parentRefs.set(targetKey, unique(...parentRefs.get(targetKey) || [], depKey));
94
+ childrenRefs.set(depKey, unique(...childrenRefs.get(depKey) ?? [], targetKey));
95
+ updateRefCountForLink(targetKey, ((_a = parentRefs.get(targetKey)) == null ? void 0 : _a.length) || 0);
96
+ };
97
+ const removeRefs = (targetKey, depKey) => {
42
98
  var _a;
43
- p2.set(d2, (p2.get(d2) || []).filter((k2) => k2 !== n2)), c2.set(n2, (c2.get(n2) ?? []).filter((k2) => k2 !== d2)), R(d2, ((_a = p2.get(d2)) == null ? void 0 : _a.length) || 0);
44
- }, I2 = (n2, d2 = []) => {
45
- let k2 = p2.get(n2) || [];
46
- d2.push(...k2);
47
- let g2 = k2.map((C2) => I2(C2, d2)).flat();
48
- return d2.push(...g2), Array.from(new Set(d2).values());
49
- }, w2 = (n2) => {
50
- R(n2, 0), P2();
51
- }, S2 = (n2) => n2 ? u2.get(n2) : null, j2 = (n2, d2, k2) => {
99
+ parentRefs.set(
100
+ depKey,
101
+ (parentRefs.get(depKey) || []).filter((key) => key !== targetKey)
102
+ );
103
+ childrenRefs.set(
104
+ targetKey,
105
+ (childrenRefs.get(targetKey) ?? []).filter((key) => key !== depKey)
106
+ );
107
+ updateRefCountForLink(depKey, ((_a = parentRefs.get(depKey)) == null ? void 0 : _a.length) || 0);
108
+ };
109
+ const getLinkedRefs = (key, stack = []) => {
110
+ const deps = parentRefs.get(key) || [];
111
+ stack.push(...deps);
112
+ const deepDeps = deps.map((ref) => getLinkedRefs(ref, stack)).flat();
113
+ stack.push(...deepDeps);
114
+ return Array.from(new Set(stack).values());
115
+ };
116
+ const invalidate = (key) => {
117
+ updateRefCountForLink(key, 0);
118
+ runGarbageCollector();
119
+ };
120
+ const readLink = (key) => {
121
+ if (key) {
122
+ return links.get(key);
123
+ }
124
+ return null;
125
+ };
126
+ const writeLink = (key, value, depKey) => {
52
127
  var _a;
53
- if (typeof n2 == "string") {
54
- u2.set(n2, d2);
55
- let [g2] = n2.split(":");
56
- M$1(n2) || (r2.has(g2) ? (_a = r2.get(g2)) == null ? void 0 : _a.add(n2) : r2.set(g2, /* @__PURE__ */ new Set([n2])));
57
- }
58
- k2 && n2 && n2 !== k2 && V2(n2, k2);
59
- }, H2 = (n2) => n2 ? u2.has(n2) : false, R = (n2, d2) => {
60
- if (Array.isArray(n2)) n2.forEach((k2, g2) => R(k2, g2));
61
- else {
62
- let k2 = i2.get(n2);
63
- i2.set(n2, d2), d2 ? !k2 && d2 && E2.delete(n2) : E2.add(n2);
128
+ if (typeof key === "string") {
129
+ links.set(key, value);
130
+ const [type] = key.split(":");
131
+ if (!isPartialKey(key)) {
132
+ if (!types2.has(type)) {
133
+ types2.set(type, /* @__PURE__ */ new Set([key]));
134
+ } else {
135
+ (_a = types2.get(type)) == null ? void 0 : _a.add(key);
136
+ }
137
+ }
138
+ }
139
+ if (depKey && key && key !== depKey) {
140
+ addRefs(key, depKey);
141
+ }
142
+ };
143
+ const hasLink = (key) => {
144
+ if (key) {
145
+ return links.has(key);
146
+ }
147
+ return false;
148
+ };
149
+ const updateRefCountForLink = (link, count) => {
150
+ if (Array.isArray(link)) {
151
+ link.forEach((link2, index2) => updateRefCountForLink(link2, index2));
152
+ } else {
153
+ const prevCount = refCount.get(link);
154
+ refCount.set(link, count);
155
+ if (!count) {
156
+ gbLinks.add(link);
157
+ } else if (!prevCount && count) {
158
+ gbLinks.delete(link);
159
+ }
64
160
  }
65
- }, $2 = () => Array.from(u2.entries()), N2 = (n2) => i2.get(n2) ?? 0, P2 = () => {
161
+ };
162
+ const getLinkEntries = () => Array.from(links.entries());
163
+ const getRefCount = (link) => refCount.get(link) ?? 0;
164
+ const runGarbageCollector = () => {
66
165
  var _a, _b;
67
- for (let n2 of E2.keys()) {
68
- if (N2(n2) > 0) continue;
69
- let k2 = u2.get(n2);
70
- E2.delete(n2), u2.delete(n2), i2.delete(n2);
71
- let g2 = p2.get(n2) ?? [], C2 = c2.get(n2) ?? [];
72
- g2.forEach((x2) => {
166
+ for (const link of gbLinks.keys()) {
167
+ const count = getRefCount(link);
168
+ if (count > 0)
169
+ continue;
170
+ const currentValue = links.get(link);
171
+ gbLinks.delete(link);
172
+ links.delete(link);
173
+ refCount.delete(link);
174
+ const parents = parentRefs.get(link) ?? [];
175
+ const children = childrenRefs.get(link) ?? [];
176
+ parents.forEach((parentKey) => {
73
177
  var _a2, _b2;
74
- c2.set(x2, ((_b2 = (_a2 = c2.get(x2)) == null ? void 0 : _a2.filter) == null ? void 0 : _b2.call(_a2, (z2) => z2 !== n2)) ?? []);
75
- }), C2.forEach((x2) => {
76
- R(x2, N2(x2) - 1);
178
+ childrenRefs.set(parentKey, ((_b2 = (_a2 = childrenRefs.get(parentKey)) == null ? void 0 : _a2.filter) == null ? void 0 : _b2.call(_a2, (childLink) => childLink !== link)) ?? []);
179
+ });
180
+ children.forEach((childKey) => {
181
+ updateRefCountForLink(childKey, getRefCount(childKey) - 1);
77
182
  });
78
- let [_2] = n2.split(":");
79
- M$1(n2) || ((_a = r2.get(_2)) == null ? void 0 : _a.delete(n2), ((_b = r2.get(_2)) == null ? void 0 : _b.size) || r2.delete(_2)), p2.delete(n2), (e2.get("onRemoveLink") ?? []).forEach((x2) => x2(n2, k2 ?? null));
183
+ const [type] = link.split(":");
184
+ if (!isPartialKey(link)) {
185
+ (_a = types2.get(type)) == null ? void 0 : _a.delete(link);
186
+ if (!((_b = types2.get(type)) == null ? void 0 : _b.size)) {
187
+ types2.delete(type);
188
+ }
189
+ }
190
+ parentRefs.delete(link);
191
+ (listeners.get("onRemoveLink") ?? []).forEach((listener) => listener(link, currentValue ?? null));
80
192
  }
81
193
  };
82
- return { readLink: S2, writeLink: j2, hasLink: H2, getLinkEntries: $2, parentRefs: p2, childrenRefs: c2, addRefs: V2, removeRefs: D2, getChildren: (n2) => c2.get(n2), getParents: (n2) => p2.get(n2), getLinkedRefs: I2, invalidate: w2, links: u2, types: r2, refCount: i2, runGarbageCollector: P2, onRemoveLink: (n2) => e2.set("onRemoveLink", [...(e2 == null ? void 0 : e2.get("onRemoveLink")) ?? [], n2]) };
194
+ return {
195
+ readLink,
196
+ writeLink,
197
+ hasLink,
198
+ getLinkEntries,
199
+ parentRefs,
200
+ childrenRefs,
201
+ addRefs,
202
+ removeRefs,
203
+ getChildren: (key) => childrenRefs.get(key),
204
+ getParents: (key) => parentRefs.get(key),
205
+ getLinkedRefs,
206
+ invalidate,
207
+ links,
208
+ types: types2,
209
+ refCount,
210
+ runGarbageCollector,
211
+ onRemoveLink: (callback) => listeners.set("onRemoveLink", [...(listeners == null ? void 0 : listeners.get("onRemoveLink")) ?? [], callback])
212
+ };
83
213
  };
84
- var Q$1 = (...e2) => {
214
+ var joinKeys = (...keys) => {
85
215
  var _a;
86
- return (_a = e2 == null ? void 0 : e2.filter(Boolean)) == null ? void 0 : _a.join(".");
87
- };
88
- var fe = (e2 = []) => {
89
- let r2 = [], u2 = (c2) => {
90
- r2.push(c2);
91
- }, p2 = (c2) => r2.reduce((i2, E2) => E2(i2) ?? i2, c2);
92
- return e2.forEach(u2), { use: u2, runPlugins: p2 };
93
- };
94
- var ue = (e2) => e2 && O$2(e2) ? ["_id", "_type", "key", "mutate", "resolve"].every((u2) => u2 in e2) : false;
95
- var le = () => {
96
- let e2 = /* @__PURE__ */ new Set();
97
- return { debug: (p2) => {
98
- e2.forEach((c2) => {
99
- c2({ ...p2, timestamp: Date.now() });
100
- });
101
- }, onDebugEvent: (p2) => {
102
- e2.add(p2);
103
- } };
104
- };
105
- var ye = /* @__PURE__ */ new Set(), Se = (e2) => `[GraphState]: ${e2}`;
106
- function X$1(e2) {
107
- ye.has(e2) || (console.warn(Se(e2)), ye.add(e2));
108
- }
109
- var q$4 = (e2) => {
110
- if (typeof e2 == "string") return B$4(e2) ? e2 : null;
111
- if (!(e2 == null ? void 0 : e2._type)) return null;
112
- let r2 = null;
113
- return (y$4(e2.id) || y$4(e2._id)) && (r2 = `${e2.id ?? e2._id}`), r2 && `${e2._type}:${r2}`;
114
- };
115
- var B$4 = (e2) => {
116
- if (O$2(e2) && (e2 == null ? void 0 : e2._type) && q$4(e2)) return e2;
117
- if (!e2 || typeof e2 != "string") return null;
118
- let [r2, ...u2] = e2.split(":");
119
- return !r2 || u2.length < 1 ? null : { _type: r2, _id: u2.join(":") };
120
- };
121
- var he = 0, Ae = 100, Ke = "State", me = "$EACH:ROOT$", mt = (e2) => {
122
- let r2 = (e2 == null ? void 0 : e2._id) ?? `${he++}`, u2 = (e2 == null ? void 0 : e2._type) ?? Ke, p2 = `${u2}:${r2}`, c2 = [ue, ...(e2 == null ? void 0 : e2.skip) ?? []], i2 = ce(), E2 = le(), V2 = fe(e2 == null ? void 0 : e2.plugins), D2 = /* @__PURE__ */ new Map(), I2 = 0, w2 = (t2) => c2.some((s2) => s2(t2)), S2 = (t2, s2) => {
123
- let a2 = (s2 == null ? void 0 : s2.deep) ?? false, o2 = (s2 == null ? void 0 : s2.safe) ?? false, l2 = (s2 == null ? void 0 : s2.keepLinks) ?? false, { selector: m2, ...h3 } = s2 || {}, y$12 = y$4(t2) ? g2(t2) : null;
124
- E2.debug({ type: "resolve", entity: t2, options: s2 });
125
- let f2 = y$12 ? i2.readLink(y$12) : null;
126
- return w2(f2) ? f2 : ((O$2(f2) || Array.isArray(f2)) && (f2 = Object.entries(f2).reduce((L2, [A2, v2]) => {
127
- let K2 = v2;
128
- return w2(K2) || (Array.isArray(v2) ? (K2 = v2.map((T2) => w2(T2) ? T2 : G$2(T2) && !o2 && !i2.hasLink(T2) ? null : J$1(T2, y$12) && !l2 || a2 ? j2(T2, h3) : T2), o2 || (K2 = K2.filter(y$4))) : G$2(v2) && !o2 && !i2.hasLink(v2) ? K2 = null : (J$1(g2(v2), y$12) && !l2 || a2) && (K2 = j2(v2, h3))), L2[A2] = K2, L2;
129
- }, {})), f2 ? m2 ? m2({ ...f2 }) : { ...f2 } : o2 ? t2 : null);
130
- }, j2 = (t2, s2) => S2(t2, s2) ?? t2, H2 = (t2) => {
131
- let s2 = g2(t2);
132
- s2 && (i2.getChildren(s2) || []).forEach((o2) => {
133
- M$1(o2) || i2.removeRefs(s2, o2);
216
+ return (_a = keys == null ? void 0 : keys.filter(Boolean)) == null ? void 0 : _a.join(".");
217
+ };
218
+ var createPluginsState = (initialPlugins = []) => {
219
+ const plugins = [];
220
+ const use = (plugin) => {
221
+ plugins.push(plugin);
222
+ };
223
+ const runPlugins = (state) => {
224
+ return plugins.reduce((graphState, plugin) => plugin(graphState) ?? graphState, state);
225
+ };
226
+ initialPlugins.forEach(use);
227
+ return {
228
+ use,
229
+ runPlugins
230
+ };
231
+ };
232
+ var isGraphState = (input) => {
233
+ if (!input)
234
+ return false;
235
+ if (isObject$1$1(input)) {
236
+ const fields = ["_id", "_type", "key", "mutate", "resolve"];
237
+ return fields.every((field) => field in input);
238
+ }
239
+ return false;
240
+ };
241
+ var createDebugState = () => {
242
+ const listeners = /* @__PURE__ */ new Set();
243
+ const onDebugEvent = (callback) => {
244
+ listeners.add(callback);
245
+ };
246
+ const debug = (event) => {
247
+ listeners.forEach((callback) => {
248
+ callback({ ...event, timestamp: Date.now() });
134
249
  });
135
- }, R = (t2, s2, a2) => {
250
+ };
251
+ return {
252
+ debug,
253
+ onDebugEvent
254
+ };
255
+ };
256
+ var cache = /* @__PURE__ */ new Set();
257
+ var wrapMessage = (message) => `[GraphState]: ${message}`;
258
+ function warn(message) {
259
+ if (!cache.has(message)) {
260
+ console.warn(wrapMessage(message));
261
+ cache.add(message);
262
+ }
263
+ }
264
+ var keyOfEntity$1 = (entity) => {
265
+ if (typeof entity === "string") {
266
+ return entityOfKey$1(entity) ? entity : null;
267
+ }
268
+ if (!(entity == null ? void 0 : entity._type)) {
269
+ return null;
270
+ }
271
+ let entityId = null;
272
+ if (y$4(entity.id) || y$4(entity._id)) {
273
+ entityId = `${entity.id ?? entity._id}`;
274
+ }
275
+ return !entityId ? entityId : `${entity._type}:${entityId}`;
276
+ };
277
+ var entityOfKey$1 = (entity) => {
278
+ if (isObject$1$1(entity) && (entity == null ? void 0 : entity._type) && keyOfEntity$1(entity)) {
279
+ return entity;
280
+ }
281
+ if (!entity || typeof entity !== "string")
282
+ return null;
283
+ const [typeName, ...restTypes] = entity.split(":");
284
+ if (!typeName || restTypes.length < 1)
285
+ return null;
286
+ return {
287
+ _type: typeName,
288
+ _id: restTypes.join(":")
289
+ };
290
+ };
291
+ function omit$1(obj, ...props) {
292
+ const result = { ...obj };
293
+ props.forEach((prop) => {
294
+ delete result[prop];
295
+ });
296
+ return result;
297
+ }
298
+ var ID = 0;
299
+ var DEEP_LIMIT = 100;
300
+ var STATE_TYPE = "State";
301
+ var EACH_UPDATED = "$EACH:ROOT$";
302
+ var createState = (options) => {
303
+ const id = (options == null ? void 0 : options._id) ?? `${ID++}`;
304
+ const type = (options == null ? void 0 : options._type) ?? STATE_TYPE;
305
+ const stateKey = `${type}:${id}`;
306
+ const skipPredictors = [isGraphState, ...(options == null ? void 0 : options.skip) ?? []];
307
+ const cache2 = createCache();
308
+ const debugState = createDebugState();
309
+ const pluginsStore = createPluginsState(options == null ? void 0 : options.plugins);
310
+ const subscribers = /* @__PURE__ */ new Map();
311
+ let deepIndex = 0;
312
+ const isSkipped = (entity) => {
313
+ return skipPredictors.some((predictor) => predictor(entity));
314
+ };
315
+ const getReferences = (entity, options2) => {
316
+ const withPartialKeys = (options2 == null ? void 0 : options2.withPartialKeys) ?? false;
317
+ const key = keyOfEntity2(entity);
318
+ if (!key)
319
+ return [];
320
+ const values = cache2.getParents(key) ?? [];
321
+ return values.filter((v2) => withPartialKeys ? !isPartialKey(v2) : v2);
322
+ };
323
+ const resolve = (input, options2) => {
324
+ const isDeep = (options2 == null ? void 0 : options2.deep) ?? false;
325
+ const isSafe = (options2 == null ? void 0 : options2.safe) ?? false;
326
+ const keepLinks = (options2 == null ? void 0 : options2.keepLinks) ?? false;
327
+ const removeLinkFromSubGraph = (options2 == null ? void 0 : options2.removeLinkFromSubGraph) ?? true;
328
+ const { selector, ...coreOptions } = options2 || {};
329
+ const inputKey = y$4(input) ? keyOfEntity2(input) : null;
330
+ debugState.debug({ type: "resolve", entity: input, options: options2 });
331
+ let value = inputKey ? cache2.readLink(inputKey) : null;
332
+ if (isSkipped(value))
333
+ return value;
334
+ if (isObject$1$1(value) || Array.isArray(value)) {
335
+ value = Object.entries(value).reduce((acc, [key, value2]) => {
336
+ let resultValue = value2;
337
+ if (!isSkipped(resultValue)) {
338
+ if (Array.isArray(value2)) {
339
+ resultValue = value2.map((v2) => {
340
+ if (isSkipped(v2))
341
+ return v2;
342
+ if (isLinkKey(v2) && !isSafe && !cache2.hasLink(v2)) {
343
+ return null;
344
+ }
345
+ return isPartOfGraph(v2, inputKey) && !keepLinks || isDeep ? safeResolve(v2, coreOptions) : v2;
346
+ });
347
+ if (!isSafe) {
348
+ resultValue = resultValue.filter(y$4);
349
+ }
350
+ } else {
351
+ if (isLinkKey(value2) && !isSafe && !cache2.hasLink(value2)) {
352
+ resultValue = null;
353
+ } else if (isPartOfGraph(keyOfEntity2(value2), inputKey) && !keepLinks || isDeep) {
354
+ resultValue = safeResolve(value2, coreOptions);
355
+ }
356
+ }
357
+ }
358
+ acc[key] = isPartialGraph(resultValue) && removeLinkFromSubGraph ? omit$1(resultValue, "_type", "_id") : resultValue;
359
+ return acc;
360
+ }, {});
361
+ }
362
+ return value ? selector ? selector({ ...value }) : { ...value } : isSafe ? input : null;
363
+ };
364
+ const safeResolve = (input, options2) => resolve(input, options2) ?? input;
365
+ const unlinkGraph = (entity) => {
366
+ const graphKey = keyOfEntity2(entity);
367
+ if (graphKey) {
368
+ const deps = cache2.getChildren(graphKey) || [];
369
+ deps.forEach((depLink) => {
370
+ if (!isPartialKey(depLink)) {
371
+ cache2.removeRefs(graphKey, depLink);
372
+ }
373
+ });
374
+ }
375
+ };
376
+ const mutateField = (input, parentFieldKey, options2) => {
136
377
  var _a, _b, _c, _d;
137
- if ((!t2 || l$2(t2)) && !G$2(t2) || w2(t2)) return t2;
138
- let o2 = re(t2) ? g2(t2) : t2;
139
- if (G$2(o2)) {
140
- let y2 = ae(s2) ?? "", f2 = ((_a = a2 == null ? void 0 : a2.internal) == null ? void 0 : _a.visitors.get(y2)) ?? [], L2 = ((_b = a2 == null ? void 0 : a2.internal) == null ? void 0 : _b.visitors.get(o2)) ?? [];
141
- if (f2.includes(o2) || o2 === y2) return null;
142
- (_d = (_c = a2 == null ? void 0 : a2.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(o2, [...L2, y2]);
143
- }
144
- if (Array.isArray(t2)) return t2.map((y2) => {
145
- let f2 = s2 ? Q$1(s2, `${he++}`) : void 0;
146
- return R(y2, f2, a2);
147
- });
148
- let m2 = (G$2(t2) ? t2 : se(t2) ? g2(t2) : null) ?? s2;
149
- return ((a2 == null ? void 0 : a2.overrideMutateMethod) || $2)(m2, t2, a2);
150
- }, $2 = (t2, ...s2) => {
151
- let { graphKey: a2, options: o2, data: l2 } = _2(t2, ...s2);
152
- E2.debug({ type: "beforeMutate", entity: a2, data: l2, options: o2 });
153
- let m2 = G$2(l2) ? C2(l2) : l2, h3 = a2 ?? p2, y2 = M$1 == null ? void 0 : M$1(h3), f2 = o2 == null ? void 0 : o2.parent, L2 = S2(h3 ?? ""), A2 = (o2 == null ? void 0 : o2.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]) }, v2 = { ...m2, ...C2(h3) }, K2 = !(o2 == null ? void 0 : o2.parent), T2 = (o2 == null ? void 0 : o2.replace) ? typeof (o2 == null ? void 0 : o2.replace) == "function" ? o2.replace(v2) : (o2 == null ? void 0 : o2.replace) === "deep" ? true : K2 || y2 : false;
154
- if (w2(m2)) return i2.writeLink(h3, m2, f2), h3;
155
- !T2 && O$2(L2) && O$2(v2) && (v2 = { ...L2, ...v2 }), T2 && H2(h3);
156
- let Z = Object.entries(v2).reduce((ee, [U2, Ee]) => {
157
- let te = Q$1(h3, U2), b2 = Ee, F2 = L2 == null ? void 0 : L2[U2], be = O$2(m2) && U2 in m2;
158
- w2(b2) || (!T2 && be && Array.isArray(b2) && Array.isArray(F2) && (b2 = [...F2, ...b2]), (O$2(b2) || Array.isArray(b2) || G$2(b2)) && (b2 = R(b2, te, { ...o2, parent: h3, internal: A2 })), Array.isArray(b2) && (o2 == null ? void 0 : o2.dedup) !== false && (b2 = oe(...b2)));
159
- let ve = ie(F2, te === b2 ? j2(b2) : b2);
160
- return A2.hasChange = A2.hasChange || !ve, !T2 && G$2(F2) && F2 !== b2 && i2.removeRefs(h3, F2), ee[U2] = b2, ee;
378
+ if ((!input || l$2(input)) && !isLinkKey(input) || isSkipped(input)) {
379
+ return input;
380
+ }
381
+ const inputLinkKey = isGraphOrKey(input) ? keyOfEntity2(input) : input;
382
+ if (isLinkKey(inputLinkKey)) {
383
+ const parentGraph = getGraphLink(parentFieldKey) ?? "";
384
+ const parentPaths = ((_a = options2 == null ? void 0 : options2.internal) == null ? void 0 : _a.visitors.get(parentGraph)) ?? [];
385
+ const visitorsPaths = ((_b = options2 == null ? void 0 : options2.internal) == null ? void 0 : _b.visitors.get(inputLinkKey)) ?? [];
386
+ if (parentPaths.includes(inputLinkKey) || inputLinkKey === parentGraph) {
387
+ return null;
388
+ }
389
+ (_d = (_c = options2 == null ? void 0 : options2.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(inputLinkKey, [...visitorsPaths, parentGraph]);
390
+ }
391
+ if (Array.isArray(input)) {
392
+ return input.map((item) => {
393
+ const indexKey = parentFieldKey ? joinKeys(parentFieldKey, `${ID++}`) : void 0;
394
+ return mutateField(item, indexKey, options2);
395
+ });
396
+ }
397
+ const entityKey = isLinkKey(input) ? input : isGraph(input) ? keyOfEntity2(input) : null;
398
+ const childKey = entityKey ?? parentFieldKey;
399
+ const mutateMethod = (options2 == null ? void 0 : options2.overrideMutateMethod) || mutate;
400
+ return mutateMethod(childKey, input, options2);
401
+ };
402
+ const mutate = (entity, ...args) => {
403
+ const { graphKey: entityGraphKey, options: options2, data: rawData } = getArgumentsForMutate(entity, ...args);
404
+ debugState.debug({ type: "beforeMutate", entity: entityGraphKey, data: rawData, options: options2 });
405
+ const data = isLinkKey(rawData) ? entityOfKey2(rawData) : rawData;
406
+ const graphKey = entityGraphKey ?? stateKey;
407
+ const partialKey = isPartialKey == null ? void 0 : isPartialKey(graphKey);
408
+ const parentKey = options2 == null ? void 0 : options2.parent;
409
+ const prevGraph = resolve(graphKey ?? "", { removeLinkFromSubGraph: false });
410
+ const internal = (options2 == null ? void 0 : options2.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]) };
411
+ let graphData = {
412
+ ...data,
413
+ ...entityOfKey2(graphKey)
414
+ };
415
+ const isTopLevelGraph = !(options2 == null ? void 0 : options2.parent);
416
+ const isReplace = (options2 == null ? void 0 : options2.replace) ? typeof (options2 == null ? void 0 : options2.replace) === "function" ? options2.replace(graphData) : (options2 == null ? void 0 : options2.replace) === "deep" ? true : isTopLevelGraph || partialKey : false;
417
+ if (isSkipped(data)) {
418
+ cache2.writeLink(graphKey, data, parentKey);
419
+ return graphKey;
420
+ }
421
+ if (!isReplace && isObject$1$1(prevGraph) && isObject$1$1(graphData)) {
422
+ graphData = {
423
+ ...prevGraph,
424
+ ...graphData
425
+ };
426
+ }
427
+ if (isReplace) {
428
+ unlinkGraph(graphKey);
429
+ }
430
+ const nextGraph = Object.entries(graphData).reduce((acc, [key, value]) => {
431
+ const fieldKey = joinKeys(graphKey, key);
432
+ let fieldValue = value;
433
+ const prevValue = prevGraph == null ? void 0 : prevGraph[key];
434
+ const isUpdateField = isObject$1$1(data) && key in data;
435
+ if (!isSkipped(fieldValue)) {
436
+ if (!isReplace && isUpdateField && Array.isArray(fieldValue) && Array.isArray(prevValue)) {
437
+ fieldValue = [...prevValue, ...fieldValue];
438
+ }
439
+ if (isObject$1$1(fieldValue) || Array.isArray(fieldValue) || isLinkKey(fieldValue)) {
440
+ fieldValue = mutateField(fieldValue, fieldKey, {
441
+ ...options2,
442
+ parent: graphKey,
443
+ internal
444
+ });
445
+ }
446
+ if (Array.isArray(fieldValue) && (options2 == null ? void 0 : options2.dedup) !== false) {
447
+ fieldValue = uniqueLinks(...fieldValue);
448
+ }
449
+ }
450
+ const isEqual = shallowEqual(prevValue, fieldKey === fieldValue ? safeResolve(fieldValue) : fieldValue);
451
+ internal.hasChange = internal.hasChange || !isEqual;
452
+ if (!isReplace && isLinkKey(prevValue) && prevValue !== fieldValue) {
453
+ cache2.removeRefs(graphKey, prevValue);
454
+ }
455
+ acc[key] = fieldValue;
456
+ return acc;
161
457
  }, {});
162
- return i2.writeLink(h3, Z, f2), f2 || i2.runGarbageCollector(), (A2.hasChange || T2) && P2(h3, L2), E2.debug({ type: "afterMutate", entity: a2, data: l2, nextData: Z, options: o2, hasChange: A2.hasChange }), h3;
163
- }, N2 = (t2) => {
164
- let s2 = g2(t2);
165
- if (E2.debug({ type: "invalidate", entity: s2 }), s2) {
166
- let a2 = i2.getParents(s2) || [];
167
- i2.invalidate(s2), a2.forEach((o2) => {
168
- let l2 = i2.readLink(o2), m2 = S2(o2, { safe: false, keepLinks: true });
169
- i2.writeLink(o2, m2), P2(o2, l2);
458
+ cache2.writeLink(graphKey, nextGraph, parentKey);
459
+ if (!parentKey) {
460
+ cache2.runGarbageCollector();
461
+ }
462
+ if ((internal.hasChange || isReplace) && !parentKey) {
463
+ notify(graphKey, prevGraph);
464
+ }
465
+ debugState.debug({
466
+ type: "afterMutate",
467
+ entity: entityGraphKey,
468
+ data: rawData,
469
+ nextData: nextGraph,
470
+ options: options2,
471
+ hasChange: internal.hasChange
472
+ });
473
+ return graphKey;
474
+ };
475
+ const invalidate = (entity) => {
476
+ const key = keyOfEntity2(entity);
477
+ debugState.debug({ type: "invalidate", entity: key });
478
+ if (key) {
479
+ const parents = cache2.getParents(key) || [];
480
+ cache2.invalidate(key);
481
+ parents.forEach((parentKey) => {
482
+ const prevParent = cache2.readLink(parentKey);
483
+ const freshParent = resolve(parentKey, { safe: false, keepLinks: true, removeLinkFromSubGraph: false });
484
+ cache2.writeLink(parentKey, freshParent);
485
+ notify(parentKey, prevParent);
170
486
  });
171
487
  }
172
- }, P2 = (t2, s2) => {
173
- if (I2 > Ae) throw new Error("Too deep notify.");
174
- let a2 = g2(t2);
175
- if (E2.debug({ type: "notify", entity: a2 }), a2) {
176
- I2++;
177
- let o2 = [...D2.get(a2) || [], ...D2.get(me) || []], l2 = i2.getChildren(a2) || [], m2 = S2(a2), h3 = (y2) => {
178
- let f2 = m2 && (y2 == null ? void 0 : y2(m2)), L2 = s2 && (y2 == null ? void 0 : y2(s2));
179
- return { next: f2, prev: L2, hasChange: !W$1(f2, L2) };
488
+ };
489
+ const notify = (entity, prevState, _internal) => {
490
+ if (deepIndex > DEEP_LIMIT) {
491
+ throw new Error("Too deep notify.");
492
+ }
493
+ const depth = (_internal == null ? void 0 : _internal.depth) ?? 0;
494
+ const key = keyOfEntity2(entity);
495
+ debugState.debug({ type: "notify", entity: key });
496
+ if (key) {
497
+ deepIndex++;
498
+ const subs = [...subscribers.get(key) || [], ...subscribers.get(EACH_UPDATED) || []];
499
+ const deps = cache2.getChildren(key) || [];
500
+ const nextResult = resolve(key);
501
+ const getSelectedValues = (selector) => {
502
+ const next = nextResult && (selector == null ? void 0 : selector(nextResult));
503
+ const prev = prevState && (selector == null ? void 0 : selector(prevState));
504
+ return { next, prev, hasChange: !deepEqual(next, prev) };
180
505
  };
181
- o2.forEach(({ callback: y2, selector: f2 }) => {
182
- if (f2) {
183
- let { next: L2, prev: A2, hasChange: v2 } = h3(f2);
184
- v2 && y2(L2, A2);
185
- } else y2(m2, s2);
186
- }), l2.forEach((y2) => P2(y2, s2));
187
- }
188
- I2 = 0;
189
- }, n2 = (...t2) => {
190
- let s2 = typeof t2[0] == "function" ? me : t2[0], a2 = typeof t2[0] == "function" ? t2[0] : t2[1], o2 = typeof t2[0] == "function" ? t2[1] : t2[2], l2 = g2(s2), m2 = o2 == null ? void 0 : o2.selector;
191
- l2 && (D2.has(l2) ? D2.set(l2, [...Array.from(D2.get(l2) || []), { callback: a2, selector: m2 }]) : D2.set(l2, [{ callback: a2, selector: m2 }]), i2.onRemoveLink((y2, f2) => {
192
- y2 === l2 && P2(l2, f2);
193
- }));
194
- let h3 = () => {
195
- if (l2) {
196
- let y2 = (D2.get(l2) || []).findIndex((f2) => f2.callback === a2);
197
- if (y2 !== -1) {
198
- let f2 = D2.get(l2) || [];
199
- f2.splice(y2, 1), D2.set(l2, f2);
506
+ subs.forEach(({ callback, options: options2 }) => {
507
+ const selector = options2 == null ? void 0 : options2.selector;
508
+ const directChangesOnly = (options2 == null ? void 0 : options2.directChangesOnly) ?? false;
509
+ if (directChangesOnly && depth > 0) {
510
+ return;
511
+ }
512
+ if (selector) {
513
+ const { next, prev, hasChange } = getSelectedValues(selector);
514
+ if (hasChange)
515
+ callback(next, prev);
516
+ } else {
517
+ callback(nextResult, prevState);
518
+ }
519
+ });
520
+ deps.forEach(
521
+ (dep) => notify(dep, prevState, {
522
+ depth: depth + 1
523
+ })
524
+ );
525
+ }
526
+ deepIndex = 0;
527
+ };
528
+ const subscribe = (...args) => {
529
+ const input = typeof args[0] === "function" ? EACH_UPDATED : args[0];
530
+ const callback = typeof args[0] === "function" ? args[0] : args[1];
531
+ const options2 = typeof args[0] === "function" ? args[1] : args[2];
532
+ const key = keyOfEntity2(input);
533
+ if (key) {
534
+ if (subscribers.has(key)) {
535
+ subscribers.set(key, [...Array.from(subscribers.get(key) || []), { callback, options: options2 }]);
536
+ } else {
537
+ subscribers.set(key, [{ callback, options: options2 }]);
538
+ }
539
+ cache2.onRemoveLink((link, prevValue) => {
540
+ if (link === key) {
541
+ notify(key, prevValue);
542
+ }
543
+ });
544
+ }
545
+ const unsubscribe = () => {
546
+ if (key) {
547
+ const subIndex = (subscribers.get(key) || []).findIndex((sub) => sub.callback === callback);
548
+ if (subIndex !== -1) {
549
+ const nextSubscribers = subscribers.get(key) || [];
550
+ nextSubscribers.splice(subIndex, 1);
551
+ subscribers.set(key, nextSubscribers);
200
552
  }
201
553
  }
202
554
  };
203
- return (o2 == null ? void 0 : o2.signal) && o2.signal.addEventListener("abort", h3, { once: true }), h3;
204
- }, d2 = (t2) => [...i2.types.get(t2) ?? []], k2 = (t2) => {
205
- let s2 = (typeof t2 == "string" ? t2 : g2(t2)) || "";
206
- return (i2.getParents(s2) ?? []).map((o2) => S2(o2));
207
- }, g2 = (t2) => (X$1("Instance keyOfEntity is deprecated. Use static method keyOfEntity."), q$4(t2)), C2 = (t2) => (X$1("Instance entityOfKey is deprecated. Use static method entityOfKey."), B$4(t2)), _2 = (t2, ...s2) => {
208
- let a2 = typeof t2 == "string" ? s2[0] : t2;
209
- return typeof a2 == "function" ? a2 = a2(S2(t2)) : G$2(a2) && (a2 = C2(a2)), { graphKey: typeof t2 == "string" ? t2 : g2(t2), options: typeof t2 == "string" ? s2[1] : s2[0], data: a2 };
210
- };
211
- function x2(t2) {
212
- V2.use(t2), t2(this);
555
+ if (options2 == null ? void 0 : options2.signal) {
556
+ options2.signal.addEventListener("abort", unsubscribe, { once: true });
557
+ }
558
+ return unsubscribe;
559
+ };
560
+ const inspectFields = (graphType) => [...cache2.types.get(graphType) ?? []];
561
+ const resolveParents = (field) => {
562
+ const key = (typeof field === "string" ? field : keyOfEntity2(field)) || "";
563
+ const refs = cache2.getParents(key) ?? [];
564
+ return refs.map((ref) => resolve(ref));
565
+ };
566
+ const keyOfEntity2 = (entity) => {
567
+ warn("Instance keyOfEntity is deprecated. Use static method keyOfEntity.");
568
+ return keyOfEntity$1(entity);
569
+ };
570
+ const entityOfKey2 = (entity) => {
571
+ warn("Instance entityOfKey is deprecated. Use static method entityOfKey.");
572
+ return entityOfKey$1(entity);
573
+ };
574
+ const getArgumentsForMutate = (entity, ...args) => {
575
+ let data = typeof entity === "string" ? args[0] : entity;
576
+ if (typeof data === "function") {
577
+ data = data(resolve(entity));
578
+ } else if (isLinkKey(data)) {
579
+ data = entityOfKey2(data);
580
+ }
581
+ return {
582
+ graphKey: typeof entity === "string" ? entity : keyOfEntity2(entity),
583
+ options: typeof entity === "string" ? args[1] : args[0],
584
+ data
585
+ };
586
+ };
587
+ function use(plugin) {
588
+ pluginsStore.use(plugin);
589
+ plugin(this);
213
590
  }
214
- let z2 = (t2) => {
215
- c2.push(t2);
591
+ const addSkip = (predictor) => {
592
+ skipPredictors.push(predictor);
216
593
  };
217
- (e2 == null ? void 0 : e2.initialState) && $2(e2.initialState, { replace: true });
218
- let ke = { _type: u2, _id: r2, key: p2, mutate: $2, subscribe: n2, resolve: S2, safeResolve: j2, resolveParents: k2, inspectFields: d2, invalidate: N2, keyOfEntity: g2, entityOfKey: C2, getArgumentsForMutate: _2, types: i2.types, cache: i2, use: x2, addSkip: z2, subscribers: void 0, onDebugEvent: E2.onDebugEvent };
219
- return i2.onRemoveLink((t2, s2) => E2.debug({ type: "garbageRemove", entity: t2, prevValue: s2 })), V2.runPlugins(ke);
594
+ if (options == null ? void 0 : options.initialState) {
595
+ mutate(options.initialState, { replace: "deep" });
596
+ }
597
+ const graphState = {
598
+ _type: type,
599
+ _id: id,
600
+ key: stateKey,
601
+ getReferences,
602
+ mutate,
603
+ subscribe,
604
+ resolve,
605
+ safeResolve,
606
+ resolveParents,
607
+ inspectFields,
608
+ invalidate,
609
+ keyOfEntity: keyOfEntity2,
610
+ entityOfKey: entityOfKey2,
611
+ getArgumentsForMutate,
612
+ types: cache2.types,
613
+ cache: cache2,
614
+ use,
615
+ addSkip,
616
+ subscribers: void 0,
617
+ onDebugEvent: debugState.onDebugEvent
618
+ };
619
+ cache2.onRemoveLink((link, prevValue) => debugState.debug({ type: "garbageRemove", entity: link, prevValue }));
620
+ return pluginsStore.runPlugins(graphState);
220
621
  };
221
622
  const createConstants$1 = (...constants) => {
222
623
  return constants.reduce((acc, constant) => {
@@ -330,12 +731,13 @@ const variableTransforms$1 = createConstants$1(
330
731
  );
331
732
  const renderTarget$1 = createConstants$1("canvas", "document");
332
733
  const renderMode$1 = createConstants$1("viewport", "parent", "fixed");
333
- const interactions$1 = createConstants$1("click", "mouseover");
334
- const eventMode$1 = createConstants$1("goal", "callback");
734
+ const interactions$1 = createConstants$1("click", "mouseover", "appear");
735
+ const eventMode$1 = createConstants$1("goal", "callback", "tracker");
335
736
  const scopeTypes$1 = createConstants$1(
336
737
  "InstanceScope",
337
738
  "FragmentScope",
338
- "CollectionScope"
739
+ "CollectionScope",
740
+ "CollectionItemScope"
339
741
  );
340
742
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
341
743
  __proto__: null,
@@ -1146,8 +1548,28 @@ const PositionSchema$1 = /* @__PURE__ */ object$1({
1146
1548
  position: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(positionType$1)), {
1147
1549
  fallback: positionType$1.absolute
1148
1550
  }),
1149
- top: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0, transform: Math.ceil }),
1150
- left: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0, transform: Math.ceil })
1551
+ top: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ number$1()), {
1552
+ fallback: null,
1553
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
1554
+ }),
1555
+ left: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ number$1()), {
1556
+ fallback: null,
1557
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
1558
+ }),
1559
+ right: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ number$1()), {
1560
+ fallback: null,
1561
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
1562
+ }),
1563
+ bottom: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ number$1()), {
1564
+ fallback: null,
1565
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
1566
+ }),
1567
+ centerAnchorX: layerField$1(/* @__PURE__ */ number$1(), {
1568
+ fallback: 0.5
1569
+ }),
1570
+ centerAnchorY: layerField$1(/* @__PURE__ */ number$1(), {
1571
+ fallback: 0.5
1572
+ })
1151
1573
  });
1152
1574
  const SceneSchema$1 = /* @__PURE__ */ object$1({
1153
1575
  opacity: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0), /* @__PURE__ */ maxValue$1(1)), {
@@ -1155,6 +1577,7 @@ const SceneSchema$1 = /* @__PURE__ */ object$1({
1155
1577
  variable: true
1156
1578
  }),
1157
1579
  visible: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: true, variable: true }),
1580
+ rotate: layerField$1(/* @__PURE__ */ number$1(), { fallback: null }),
1158
1581
  zIndex: layerField$1(/* @__PURE__ */ number$1(), { fallback: -1 })
1159
1582
  });
1160
1583
  const FillSchema$1 = /* @__PURE__ */ object$1({
@@ -1304,33 +1727,22 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
1304
1727
  whiteSpace: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(whiteSpace$1)), {
1305
1728
  fallback: whiteSpace$1.pre
1306
1729
  }),
1307
- variableContent: layerField$1(/* @__PURE__ */ string$1(), { fallback: null, variable: true }),
1730
+ textAlign: layerField$1(/* @__PURE__ */ string$1(), { fallback: "left" }),
1308
1731
  parent: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ string$1()), { overridable: false }),
1309
- attributes: /* @__PURE__ */ optional$1(
1310
- /* @__PURE__ */ object$1({
1311
- fontSize: layerField$1(/* @__PURE__ */ string$1(), { fallback: "14px" }),
1312
- color: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#000", variable: true }),
1313
- lineHeight: layerField$1(/* @__PURE__ */ string$1(), { fallback: "14px" }),
1314
- fontWeight: layerField$1(/* @__PURE__ */ string$1(), { fallback: "normal" }),
1315
- letterSpacing: layerField$1(/* @__PURE__ */ string$1(), { fallback: "0px" }),
1316
- textTransform: layerField$1(/* @__PURE__ */ string$1(), { fallback: "none" }),
1317
- textDecoration: layerField$1(/* @__PURE__ */ string$1(), { fallback: "none" }),
1318
- whiteSpace: layerField$1(/* @__PURE__ */ string$1(), { fallback: "pre" }),
1319
- textAlign: layerField$1(/* @__PURE__ */ string$1(), { fallback: "left" })
1320
- })
1321
- ),
1322
1732
  ...GraphFieldSchema$1.entries,
1323
1733
  ...OverridesSchema$1.entries,
1324
1734
  ...CssOverrideSchema$1.entries,
1325
1735
  ...PositionSchema$1.entries,
1326
1736
  ...SceneSchema$1.entries,
1327
- ...SizeSchema$1.entries
1737
+ ...SizeSchema$1.entries,
1738
+ ...InteractionsSchema$1.entries,
1739
+ ...LinkSchema$1.entries
1328
1740
  });
1329
1741
  /* @__PURE__ */ object$1({
1330
1742
  name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Fragment", overridable: false }),
1331
1743
  parent: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ string$1()), { overridable: false }),
1332
1744
  horizontalGrow: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(fragmentGrowingMode$1)), {
1333
- fallback: fragmentGrowingMode$1.auto,
1745
+ fallback: fragmentGrowingMode$1.fill,
1334
1746
  overridable: false
1335
1747
  }),
1336
1748
  verticalGrow: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(fragmentGrowingMode$1)), {
@@ -1371,6 +1783,7 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
1371
1783
  ...PositionSchema$1.entries,
1372
1784
  ...SizeSchema$1.entries,
1373
1785
  ...SceneSchema$1.entries,
1786
+ ...InteractionsSchema$1.entries,
1374
1787
  ...LinkSchema$1.entries
1375
1788
  });
1376
1789
  /* @__PURE__ */ object$1({
@@ -1555,7 +1968,7 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
1555
1968
  }),
1556
1969
  parent: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ string$1()), { overridable: false }),
1557
1970
  defaultValue: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ any$1()), { fallback: [] }),
1558
- definition: layerField$1(/* @__PURE__ */ nullable$1(linkValidator$1), { fallback: null }),
1971
+ definition: layerField$1(linkValidator$1, { fallback: null }),
1559
1972
  required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
1560
1973
  ...GraphFieldSchema$1.entries
1561
1974
  });
@@ -1563,13 +1976,13 @@ const BASE_HEADERS = {
1563
1976
  "Content-Type": "application/json"
1564
1977
  };
1565
1978
  const createFetcher = (baseUrl, defaultHeaders = {}) => {
1566
- const cache = /* @__PURE__ */ new Map();
1979
+ const cache2 = /* @__PURE__ */ new Map();
1567
1980
  const inflightRequests = /* @__PURE__ */ new Map();
1568
1981
  const getCacheKey = (query2, variables, options) => JSON.stringify({ query: query2, variables, options });
1569
1982
  const query = async (query2, variables = {}, options = {}) => {
1570
1983
  const cacheKey = getCacheKey(query2, variables, options);
1571
- if (cache.has(cacheKey)) {
1572
- return cache.get(cacheKey);
1984
+ if (cache2.has(cacheKey)) {
1985
+ return cache2.get(cacheKey);
1573
1986
  }
1574
1987
  if (inflightRequests.has(cacheKey)) {
1575
1988
  return inflightRequests.get(cacheKey);
@@ -1588,7 +2001,7 @@ const createFetcher = (baseUrl, defaultHeaders = {}) => {
1588
2001
  if (!res.ok) throw new Error(`Fetch error: ${res.status}`);
1589
2002
  const data = await res.json();
1590
2003
  if (!query2.includes("mutation")) {
1591
- cache.set(cacheKey, data);
2004
+ cache2.set(cacheKey, data);
1592
2005
  }
1593
2006
  return data;
1594
2007
  }).finally(() => {
@@ -1598,9 +2011,9 @@ const createFetcher = (baseUrl, defaultHeaders = {}) => {
1598
2011
  return request;
1599
2012
  };
1600
2013
  const invalidate = (endpoint, options) => {
1601
- cache.delete(getCacheKey(endpoint, options));
2014
+ cache2.delete(getCacheKey(endpoint, options));
1602
2015
  };
1603
- const clearCache = () => cache.clear();
2016
+ const clearCache = () => cache2.clear();
1604
2017
  return { query, invalidate, clearCache };
1605
2018
  };
1606
2019
  const getFragmentQuery = (fragmentId, isSelf) => {
@@ -1666,10 +2079,10 @@ const fetchBeacon = (baseUrl) => {
1666
2079
  sendBeacon
1667
2080
  };
1668
2081
  };
1669
- const getAreaQuery = (areaCode) => {
2082
+ const getAreaListQuery = (areaCodes) => {
1670
2083
  return {
1671
- query: `query($areaCode: String!) {
1672
- clientArea(areaCode: $areaCode) {
2084
+ query: `query($areaCodes: [String!]!) {
2085
+ clientAreas(areaCodes: $areaCodes) {
1673
2086
  variant {
1674
2087
  fragment {
1675
2088
  props
@@ -1686,18 +2099,23 @@ const getAreaQuery = (areaCode) => {
1686
2099
  }
1687
2100
  }`,
1688
2101
  variables: {
1689
- areaCode
2102
+ areaCodes
1690
2103
  }
1691
2104
  };
1692
2105
  };
1693
2106
  const fetchPlugin = (state) => {
1694
- var _a, _b, _c;
2107
+ var _a, _b, _c, _d;
1695
2108
  const isSelf = ((_a = state == null ? void 0 : state.env) == null ? void 0 : _a.isSelf) ?? false;
1696
2109
  const url = (_b = state == null ? void 0 : state.env) == null ? void 0 : _b.backendEndpoint;
1697
2110
  const apiToken = (_c = state == null ? void 0 : state.env) == null ? void 0 : _c.apiToken;
1698
- const fetcher = createFetcher(url, {
2111
+ const referer = (_d = state == null ? void 0 : state.env) == null ? void 0 : _d.referer;
2112
+ let headers = {
1699
2113
  Authorization: `Bearer ${apiToken}`
1700
- });
2114
+ };
2115
+ if (referer) {
2116
+ headers.Referer = referer;
2117
+ }
2118
+ const fetcher = createFetcher(url, headers);
1701
2119
  const beaconFetcher = fetchBeacon();
1702
2120
  const queryFragment = async (fragmentId) => {
1703
2121
  var _a2;
@@ -1708,7 +2126,8 @@ const fetchPlugin = (state) => {
1708
2126
  const fragmentQuery = getFragmentQuery(fragmentId, isSelf);
1709
2127
  const response = await fetcher.query(
1710
2128
  fragmentQuery.query,
1711
- fragmentQuery.variables
2129
+ fragmentQuery.variables,
2130
+ { referrerPolicy: "unsafe-url" }
1712
2131
  );
1713
2132
  let fragment2 = null;
1714
2133
  if (!!(response == null ? void 0 : response.data) && "clientFragment" in response.data) {
@@ -1737,36 +2156,46 @@ const fetchPlugin = (state) => {
1737
2156
  return null;
1738
2157
  };
1739
2158
  const queryArea = async (areaCode) => {
2159
+ return queryAreaList([areaCode]).then((res) => res == null ? void 0 : res.at(0));
2160
+ };
2161
+ const queryAreaList = async (areaCodes) => {
1740
2162
  var _a2;
1741
- if (!apiToken || !areaCode) return null;
1742
- if (state.$fetch.cacheAreaDocuments.has(areaCode)) {
1743
- return state.$fetch.cacheAreaDocuments.get(areaCode);
2163
+ if (!apiToken || !areaCodes) return null;
2164
+ const nonLoadedAreas = areaCodes.filter(
2165
+ (code) => !state.$fetch.cacheAreaDocuments.has(code)
2166
+ );
2167
+ if (!nonLoadedAreas.length) {
2168
+ return areaCodes.map(state.$fetch.cacheAreaDocuments.get);
1744
2169
  }
1745
- const areaQuery = getAreaQuery(areaCode);
2170
+ const areaQuery = getAreaListQuery(areaCodes);
1746
2171
  const response = await fetcher.query(
1747
2172
  areaQuery.query,
1748
- areaQuery.variables
2173
+ areaQuery.variables,
2174
+ { referrerPolicy: "unsafe-url" }
1749
2175
  );
1750
- const area = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.clientArea;
1751
- if (area) {
1752
- state.$fetch.cacheDocuments.set(
1753
- area.variant.fragment.fragment.id,
1754
- area.variant.fragment.fragment.document
1755
- );
1756
- if (Array.isArray(area.variant.fragment.fragment.linkedFragments)) {
1757
- area.variant.fragment.fragment.linkedFragments.forEach(
1758
- (linkedFragment) => state.$fetch.cacheDocuments.set(
1759
- linkedFragment.id,
1760
- linkedFragment.document
1761
- )
2176
+ const areas = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.clientAreas;
2177
+ if (areas) {
2178
+ areas.forEach((area, index2) => {
2179
+ const areaCode = areaCodes == null ? void 0 : areaCodes.at(index2);
2180
+ state.$fetch.cacheDocuments.set(
2181
+ area.variant.fragment.fragment.id,
2182
+ area.variant.fragment.fragment.document
1762
2183
  );
1763
- }
1764
- const entity = {
1765
- fragmentId: area.variant.fragment.fragment.id,
1766
- props: area.variant.fragment.props
1767
- };
1768
- state.$fetch.cacheAreaDocuments.set(areaCode, entity);
1769
- return entity;
2184
+ if (Array.isArray(area.variant.fragment.fragment.linkedFragments)) {
2185
+ area.variant.fragment.fragment.linkedFragments.forEach(
2186
+ (linkedFragment) => state.$fetch.cacheDocuments.set(
2187
+ linkedFragment.id,
2188
+ linkedFragment.document
2189
+ )
2190
+ );
2191
+ }
2192
+ const entity = {
2193
+ fragmentId: area.variant.fragment.fragment.id,
2194
+ props: area.variant.fragment.props
2195
+ };
2196
+ state.$fetch.cacheAreaDocuments.set(areaCode, entity);
2197
+ });
2198
+ return areaCodes.map((code) => state.$fetch.cacheAreaDocuments.get(code));
1770
2199
  }
1771
2200
  return null;
1772
2201
  };
@@ -1775,6 +2204,7 @@ const fetchPlugin = (state) => {
1775
2204
  cacheAreaDocuments: /* @__PURE__ */ new Map(),
1776
2205
  queryFragment,
1777
2206
  queryArea,
2207
+ queryAreaList,
1778
2208
  query: fetcher.query,
1779
2209
  sendBeacon: beaconFetcher.sendBeacon,
1780
2210
  readFragment: (fragmentId) => state.$fetch.cacheDocuments.get(fragmentId) ?? null,
@@ -1785,11 +2215,11 @@ const getAllChildren = (layerResolver, layerKey, acc = []) => {
1785
2215
  var _a;
1786
2216
  const layer = layerResolver(layerKey) ?? {};
1787
2217
  if (acc.length === 0) {
1788
- acc.push(layerKey);
2218
+ acc.push(keyOfEntity$1(layerKey));
1789
2219
  }
1790
2220
  (_a = layer == null ? void 0 : layer.children) == null ? void 0 : _a.forEach((child) => {
1791
2221
  if (child) {
1792
- acc.push(child);
2222
+ acc.push(keyOfEntity$1(child));
1793
2223
  getAllChildren(layerResolver, child, acc);
1794
2224
  }
1795
2225
  });
@@ -1811,8 +2241,8 @@ const findGroups = (styles2, layerResolver) => {
1811
2241
  const primaryBreakpoint = breakpoints.find(
1812
2242
  (breakpoint) => breakpoint == null ? void 0 : breakpoint.isPrimary
1813
2243
  );
1814
- const smaller = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) < (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b2) => b2.width - a2.width);
1815
- const larger = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) > (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b2) => a2.width - b2.width);
2244
+ const smaller = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) < (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b) => b.width - a2.width);
2245
+ const larger = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) > (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b) => a2.width - b.width);
1816
2246
  return {
1817
2247
  fragmentLayerKey,
1818
2248
  fragment: rootLayer,
@@ -1848,27 +2278,59 @@ const makeCss = (styles2, layerResolver) => (layerKey) => {
1848
2278
  const cssOverride = (cacheLayer == null ? void 0 : cacheLayer.cssOverride) ?? "";
1849
2279
  return {
1850
2280
  hash: layerHash,
1851
- css: cssOverride + toCSS(resultCssRules)
2281
+ css: toCSS(resultCssRules) + cssOverride
1852
2282
  };
1853
2283
  };
1854
2284
  const autoInjector = (key, state, graphKey, transformStyles) => {
2285
+ const removeStyle = () => {
2286
+ if (!isBrowser_default$1) return;
2287
+ const el = document.getElementById(key);
2288
+ if (el) el.remove();
2289
+ };
1855
2290
  const injectStyle = (styles2) => {
1856
- if (isBrowser_default$1 && styles2) {
1857
- if (document.getElementById(key)) {
1858
- const el = document.getElementById(key);
1859
- if (el) el.remove();
2291
+ if (!isBrowser_default$1) return;
2292
+ if (!styles2) {
2293
+ removeStyle();
2294
+ return;
2295
+ }
2296
+ const existing = document.getElementById(key);
2297
+ if (existing && existing.tagName === "STYLE") {
2298
+ existing.textContent = styles2;
2299
+ return;
2300
+ }
2301
+ if (existing) existing.remove();
2302
+ const style = document.createElement("style");
2303
+ style.id = key;
2304
+ style.textContent = styles2;
2305
+ document.head.appendChild(style);
2306
+ };
2307
+ let isMounted = false;
2308
+ let pendingStyles = "";
2309
+ state.subscribe(
2310
+ graphKey,
2311
+ (next) => {
2312
+ const styles2 = (transformStyles == null ? void 0 : transformStyles(next)) ?? (next == null ? void 0 : next.styles) ?? [];
2313
+ const resultStyle = styles2.join("\n");
2314
+ pendingStyles = resultStyle;
2315
+ if (isMounted) {
2316
+ injectStyle(resultStyle);
1860
2317
  }
1861
- const style = document.createElement("style");
1862
- style.id = key;
1863
- style.textContent = styles2;
1864
- document.head.appendChild(style);
2318
+ },
2319
+ { directChangesOnly: true }
2320
+ );
2321
+ const mount = () => {
2322
+ isMounted = true;
2323
+ if (pendingStyles) {
2324
+ injectStyle(pendingStyles);
2325
+ } else {
2326
+ removeStyle();
1865
2327
  }
1866
2328
  };
1867
- state.subscribe(graphKey, (next) => {
1868
- const styles2 = (transformStyles == null ? void 0 : transformStyles(next)) ?? (next == null ? void 0 : next.styles) ?? [];
1869
- const resultStyle = styles2.join("\n");
1870
- injectStyle(resultStyle);
1871
- });
2329
+ const unmount = () => {
2330
+ isMounted = false;
2331
+ removeStyle();
2332
+ };
2333
+ return { mount, unmount };
1872
2334
  };
1873
2335
  function generatePrimaryCssBlocks(layerResolver, group, cssMaker) {
1874
2336
  const children = getAllChildren(layerResolver, group.primary);
@@ -1930,12 +2392,24 @@ const fragmentStylesheetPlugin = (state) => {
1930
2392
  state.mutate(KEY, {
1931
2393
  styles: {}
1932
2394
  });
1933
- autoInjector(state.key, state, KEY, (graph) => {
2395
+ const fragmentStyleInjector = autoInjector(state.key, state, KEY, (graph) => {
1934
2396
  return extractStyleSheet(graph.styles, state.resolve);
1935
2397
  });
2398
+ const destroyStyles = () => {
2399
+ state.mutate(
2400
+ KEY,
2401
+ {
2402
+ styles: {}
2403
+ },
2404
+ { replace: true }
2405
+ );
2406
+ fragmentStyleInjector.unmount();
2407
+ };
1936
2408
  state.$styleSheet = {
1937
2409
  key: KEY,
1938
2410
  addStyle,
2411
+ mount: fragmentStyleInjector.mount,
2412
+ unmount: destroyStyles,
1939
2413
  extract: (withTag) => {
1940
2414
  var _a;
1941
2415
  const graph = state.resolve(KEY);
@@ -1950,7 +2424,7 @@ const fragmentStylesheetPlugin = (state) => {
1950
2424
  };
1951
2425
  return state;
1952
2426
  };
1953
- const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n }\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
2427
+ const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
1954
2428
  const globalStylesheetPlugin = (state) => {
1955
2429
  if (!("$fragments" in state)) {
1956
2430
  throw new Error("GlobalStylesheetPlugin need $fragments plugin");
@@ -1966,10 +2440,12 @@ const globalStylesheetPlugin = (state) => {
1966
2440
  _id: "root",
1967
2441
  styles: []
1968
2442
  });
1969
- autoInjector("global", state, KEY);
2443
+ const globalStyleInjector = autoInjector("global", state, KEY);
1970
2444
  state.$globalStylesheet = {
1971
2445
  key: KEY,
1972
2446
  addStyle,
2447
+ mount: globalStyleInjector.mount,
2448
+ unmount: globalStyleInjector.unmount,
1973
2449
  extractStyles: () => {
1974
2450
  const allFragments = state.$fragments.getManagers();
1975
2451
  const styles2 = Object.entries(allFragments).filter(([, value]) => !!(value == null ? void 0 : value.resolve)).map(([, manager]) => manager.$styleSheet.extract(true));
@@ -1977,6 +2453,7 @@ const globalStylesheetPlugin = (state) => {
1977
2453
  }
1978
2454
  };
1979
2455
  addStyle(globalCss);
2456
+ globalStyleInjector.mount();
1980
2457
  return state;
1981
2458
  };
1982
2459
  const scopesPlugin = (state) => {
@@ -1990,7 +2467,8 @@ const scopesPlugin = (state) => {
1990
2467
  };
1991
2468
  return state;
1992
2469
  };
1993
- const fragmentsPlugin = (state) => {
2470
+ const fragmentsPlugin = (options) => (state) => {
2471
+ const plugins = (options == null ? void 0 : options.plugins) ?? [];
1994
2472
  const createFragmentManager = (fragmentId, initialDocument = {}) => {
1995
2473
  var _a, _b;
1996
2474
  if (!fragmentId || !initialDocument) return null;
@@ -2011,7 +2489,7 @@ const fragmentsPlugin = (state) => {
2011
2489
  _type: "Spring",
2012
2490
  _id: "root"
2013
2491
  };
2014
- const manager = mt({
2492
+ const manager = createState({
2015
2493
  _type: "FragmentManager",
2016
2494
  _id: fragmentId,
2017
2495
  initialState: initialDocument,
@@ -2024,7 +2502,8 @@ const fragmentsPlugin = (state) => {
2024
2502
  },
2025
2503
  // cssPlugin,
2026
2504
  fragmentStylesheetPlugin,
2027
- scopesPlugin
2505
+ scopesPlugin,
2506
+ ...plugins
2028
2507
  ],
2029
2508
  skip: [
2030
2509
  g$2,
@@ -2070,34 +2549,94 @@ const fragmentsPlugin = (state) => {
2070
2549
  const addClientMetric = `mutation AddClientMetric($type: ClientMetricType!, $value: String) {
2071
2550
  addClientMetric(metric: {metricType: $type, metricValue: $value})
2072
2551
  }`;
2552
+ const pendingPixels = /* @__PURE__ */ new Set();
2553
+ const sendWithImage = (url) => {
2554
+ try {
2555
+ const pixel = new Image();
2556
+ pixel.referrerPolicy = "no-referrer";
2557
+ const handleCleanup = () => {
2558
+ pixel.removeEventListener("load", handleCleanup);
2559
+ pixel.removeEventListener("error", handleCleanup);
2560
+ pendingPixels.delete(pixel);
2561
+ };
2562
+ pixel.addEventListener("load", handleCleanup, { once: true });
2563
+ pixel.addEventListener("error", handleCleanup, { once: true });
2564
+ pendingPixels.add(pixel);
2565
+ pixel.src = url;
2566
+ } catch {
2567
+ }
2568
+ };
2569
+ const sendWithFetch = (url) => {
2570
+ if (typeof fetch !== "function") {
2571
+ return false;
2572
+ }
2573
+ try {
2574
+ fetch(url, {
2575
+ method: "GET",
2576
+ mode: "no-cors",
2577
+ keepalive: true
2578
+ }).catch(() => void 0);
2579
+ return true;
2580
+ } catch {
2581
+ return false;
2582
+ }
2583
+ };
2584
+ const sendWithNavigatorBeacon = (url) => {
2585
+ if (typeof navigator === "undefined" || typeof navigator.sendBeacon !== "function") {
2586
+ return false;
2587
+ }
2588
+ try {
2589
+ return navigator.sendBeacon(url);
2590
+ } catch {
2591
+ return false;
2592
+ }
2593
+ };
2594
+ const trackAdPixel = (pixelUrl, customBeacon) => {
2595
+ if (!isBrowser_default$1) {
2596
+ return;
2597
+ }
2598
+ const url = pixelUrl == null ? void 0 : pixelUrl.trim();
2599
+ if (!url) {
2600
+ return;
2601
+ }
2602
+ if (typeof customBeacon === "function") {
2603
+ try {
2604
+ const result = customBeacon(url);
2605
+ if (result === true) {
2606
+ return;
2607
+ }
2608
+ } catch {
2609
+ }
2610
+ }
2611
+ if (sendWithNavigatorBeacon(url)) {
2612
+ return;
2613
+ }
2614
+ if (sendWithFetch(url)) {
2615
+ return;
2616
+ }
2617
+ sendWithImage(url);
2618
+ };
2073
2619
  const types = createConstants$2(
2074
2620
  "INIT_SESSION",
2075
2621
  "RELEASE_SESSION",
2076
2622
  "REACH_PROJECT_GOAL"
2077
2623
  );
2078
2624
  const globalMetricsPlugin = (state) => {
2079
- var _a;
2080
- const history = /* @__PURE__ */ new Set([]);
2081
2625
  const sendMetric = async (type, value) => {
2082
- var _a2;
2083
- if ([types.INIT_SESSION, types.RELEASE_SESSION].some((v2) => history.has(v2))) {
2084
- return;
2085
- }
2086
- const query = (_a2 = state == null ? void 0 : state.$fetch) == null ? void 0 : _a2.query;
2626
+ var _a;
2627
+ const query = (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.query;
2087
2628
  await query(addClientMetric, { type, value });
2088
- history.add(type);
2089
2629
  };
2090
2630
  const reachGoal = (goal) => {
2091
2631
  sendMetric(types.REACH_PROJECT_GOAL, goal);
2092
2632
  };
2093
- if (isBrowser_default$1 && !((_a = state == null ? void 0 : state.env) == null ? void 0 : _a.isSelf)) {
2094
- sendMetric(types.INIT_SESSION);
2095
- window.addEventListener("beforeunload", () => {
2096
- sendMetric(types.RELEASE_SESSION);
2097
- });
2098
- }
2633
+ const sendAdPixel = (pixelUrl) => {
2634
+ var _a;
2635
+ trackAdPixel(pixelUrl, (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.sendBeacon);
2636
+ };
2099
2637
  state.$metrics = {
2100
- reachGoal
2638
+ reachGoal,
2639
+ trackAdPixel: sendAdPixel
2101
2640
  };
2102
2641
  };
2103
2642
  const loadPlugin = (state) => {
@@ -2161,6 +2700,7 @@ const loadPlugin = (state) => {
2161
2700
  const loader = async () => {
2162
2701
  var _a2;
2163
2702
  const areaEntity = await ((_a2 = state == null ? void 0 : state.$fetch) == null ? void 0 : _a2.queryArea(areaCode));
2703
+ console.log(areaEntity);
2164
2704
  await loadFragment(areaEntity == null ? void 0 : areaEntity.fragmentId, {
2165
2705
  suspense: false
2166
2706
  });
@@ -2188,7 +2728,7 @@ const PLUGIN_TYPES = createConstants$2(
2188
2728
  );
2189
2729
  const createFragmentsClient = (options) => {
2190
2730
  const BACKEND_TARGET = (options == null ? void 0 : options.isSelf) ? "/graphql" : "http://85.192.29.65/graphql";
2191
- return mt({
2731
+ return createState({
2192
2732
  _type: "GlobalManager",
2193
2733
  initialState: {},
2194
2734
  skip: [
@@ -2201,19 +2741,22 @@ const createFragmentsClient = (options) => {
2201
2741
  (state) => {
2202
2742
  state.env = {
2203
2743
  isSelf: (options == null ? void 0 : options.isSelf) ?? false,
2204
- backendEndpoint: BACKEND_TARGET,
2205
- apiToken: options == null ? void 0 : options.apiToken
2744
+ backendEndpoint: (options == null ? void 0 : options.backendEndpoint) ?? BACKEND_TARGET,
2745
+ apiToken: options == null ? void 0 : options.apiToken,
2746
+ referer: options == null ? void 0 : options.referer
2206
2747
  };
2207
2748
  },
2208
2749
  fetchPlugin,
2209
- fragmentsPlugin,
2750
+ fragmentsPlugin({
2751
+ plugins: options == null ? void 0 : options.fragmentPlugins
2752
+ }),
2210
2753
  loadPlugin,
2211
2754
  globalMetricsPlugin,
2212
2755
  globalStylesheetPlugin
2213
2756
  ]
2214
2757
  });
2215
2758
  };
2216
- var n, l$1, t$1, i$1, r$2, o$1, e$1, f$2, c$1, s$2, a$2, h$1, p$1 = {}, v$1 = [], y$3 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, d$1 = Array.isArray;
2759
+ var n, l$1, t$1, i$1, r$2, o$1, e$1, f$2, c$1, s$1, a$2, h$1, p$1 = {}, v$1 = [], y$3 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, d$1 = Array.isArray;
2217
2760
  function w$1(n2, l2) {
2218
2761
  for (var t2 in l2) n2[t2] = l2[t2];
2219
2762
  return n2;
@@ -2234,7 +2777,7 @@ function m$1(n2, u2, i2, r2, o2) {
2234
2777
  function k$1(n2) {
2235
2778
  return n2.children;
2236
2779
  }
2237
- function x$2(n2, l2) {
2780
+ function x$3(n2, l2) {
2238
2781
  this.props = n2, this.context = l2;
2239
2782
  }
2240
2783
  function S$1(n2, l2) {
@@ -2256,18 +2799,18 @@ function M(n2) {
2256
2799
  (!n2.__d && (n2.__d = true) && i$1.push(n2) && !$.__r++ || r$2 !== l$1.debounceRendering) && ((r$2 = l$1.debounceRendering) || o$1)($);
2257
2800
  }
2258
2801
  function $() {
2259
- for (var n2, t2, u2, r2, o2, f2, c2, s2 = 1; i$1.length; ) i$1.length > s2 && i$1.sort(e$1), n2 = i$1.shift(), s2 = i$1.length, n2.__d && (u2 = void 0, o2 = (r2 = (t2 = n2).__v).__e, f2 = [], c2 = [], t2.__P && ((u2 = w$1({}, r2)).__v = r2.__v + 1, l$1.vnode && l$1.vnode(u2), O$1(t2.__P, u2, r2, t2.__n, t2.__P.namespaceURI, 32 & r2.__u ? [o2] : null, f2, null == o2 ? S$1(r2) : o2, !!(32 & r2.__u), c2), u2.__v = r2.__v, u2.__.__k[u2.__i] = u2, z$1(f2, u2, c2), u2.__e != o2 && C$2(u2)));
2802
+ for (var n2, t2, u2, r2, o2, f2, c2, s2 = 1; i$1.length; ) i$1.length > s2 && i$1.sort(e$1), n2 = i$1.shift(), s2 = i$1.length, n2.__d && (u2 = void 0, o2 = (r2 = (t2 = n2).__v).__e, f2 = [], c2 = [], t2.__P && ((u2 = w$1({}, r2)).__v = r2.__v + 1, l$1.vnode && l$1.vnode(u2), O(t2.__P, u2, r2, t2.__n, t2.__P.namespaceURI, 32 & r2.__u ? [o2] : null, f2, null == o2 ? S$1(r2) : o2, !!(32 & r2.__u), c2), u2.__v = r2.__v, u2.__.__k[u2.__i] = u2, z$1(f2, u2, c2), u2.__e != o2 && C$2(u2)));
2260
2803
  $.__r = 0;
2261
2804
  }
2262
2805
  function I(n2, l2, t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2263
- var a2, h3, y2, d2, w2, g2, _2 = u2 && u2.__k || v$1, m2 = l2.length;
2264
- for (f2 = P$2(t2, l2, _2, f2, m2), a2 = 0; a2 < m2; a2++) null != (y2 = t2.__k[a2]) && (h3 = -1 === y2.__i ? p$1 : _2[y2.__i] || p$1, y2.__i = a2, g2 = O$1(n2, y2, h3, i2, r2, o2, e2, f2, c2, s2), d2 = y2.__e, y2.ref && h3.ref != y2.ref && (h3.ref && q$3(h3.ref, null, y2), s2.push(y2.ref, y2.__c || d2, y2)), null == w2 && null != d2 && (w2 = d2), 4 & y2.__u || h3.__k === y2.__k ? f2 = A$1(y2, f2, n2) : "function" == typeof y2.type && void 0 !== g2 ? f2 = g2 : d2 && (f2 = d2.nextSibling), y2.__u &= -7);
2806
+ var a2, h2, y2, d2, w2, g2, _2 = u2 && u2.__k || v$1, m2 = l2.length;
2807
+ for (f2 = P$2(t2, l2, _2, f2, m2), a2 = 0; a2 < m2; a2++) null != (y2 = t2.__k[a2]) && (h2 = -1 === y2.__i ? p$1 : _2[y2.__i] || p$1, y2.__i = a2, g2 = O(n2, y2, h2, i2, r2, o2, e2, f2, c2, s2), d2 = y2.__e, y2.ref && h2.ref != y2.ref && (h2.ref && q$2(h2.ref, null, y2), s2.push(y2.ref, y2.__c || d2, y2)), null == w2 && null != d2 && (w2 = d2), 4 & y2.__u || h2.__k === y2.__k ? f2 = A$1(y2, f2, n2) : "function" == typeof y2.type && void 0 !== g2 ? f2 = g2 : d2 && (f2 = d2.nextSibling), y2.__u &= -7);
2265
2808
  return t2.__e = w2, f2;
2266
2809
  }
2267
2810
  function P$2(n2, l2, t2, u2, i2) {
2268
- var r2, o2, e2, f2, c2, s2 = t2.length, a2 = s2, h3 = 0;
2269
- for (n2.__k = new Array(i2), r2 = 0; r2 < i2; r2++) null != (o2 = l2[r2]) && "boolean" != typeof o2 && "function" != typeof o2 ? (f2 = r2 + h3, (o2 = n2.__k[r2] = "string" == typeof o2 || "number" == typeof o2 || "bigint" == typeof o2 || o2.constructor == String ? m$1(null, o2, null, null, null) : d$1(o2) ? m$1(k$1, { children: o2 }, null, null, null) : void 0 === o2.constructor && o2.__b > 0 ? m$1(o2.type, o2.props, o2.key, o2.ref ? o2.ref : null, o2.__v) : o2).__ = n2, o2.__b = n2.__b + 1, e2 = null, -1 !== (c2 = o2.__i = L(o2, t2, f2, a2)) && (a2--, (e2 = t2[c2]) && (e2.__u |= 2)), null == e2 || null === e2.__v ? (-1 == c2 && (i2 > s2 ? h3-- : i2 < s2 && h3++), "function" != typeof o2.type && (o2.__u |= 4)) : c2 != f2 && (c2 == f2 - 1 ? h3-- : c2 == f2 + 1 ? h3++ : (c2 > f2 ? h3-- : h3++, o2.__u |= 4))) : n2.__k[r2] = null;
2270
- if (a2) for (r2 = 0; r2 < s2; r2++) null != (e2 = t2[r2]) && 0 == (2 & e2.__u) && (e2.__e == u2 && (u2 = S$1(e2)), B$3(e2, e2));
2811
+ var r2, o2, e2, f2, c2, s2 = t2.length, a2 = s2, h2 = 0;
2812
+ for (n2.__k = new Array(i2), r2 = 0; r2 < i2; r2++) null != (o2 = l2[r2]) && "boolean" != typeof o2 && "function" != typeof o2 ? (f2 = r2 + h2, (o2 = n2.__k[r2] = "string" == typeof o2 || "number" == typeof o2 || "bigint" == typeof o2 || o2.constructor == String ? m$1(null, o2, null, null, null) : d$1(o2) ? m$1(k$1, { children: o2 }, null, null, null) : void 0 === o2.constructor && o2.__b > 0 ? m$1(o2.type, o2.props, o2.key, o2.ref ? o2.ref : null, o2.__v) : o2).__ = n2, o2.__b = n2.__b + 1, e2 = null, -1 !== (c2 = o2.__i = L(o2, t2, f2, a2)) && (a2--, (e2 = t2[c2]) && (e2.__u |= 2)), null == e2 || null === e2.__v ? (-1 == c2 && (i2 > s2 ? h2-- : i2 < s2 && h2++), "function" != typeof o2.type && (o2.__u |= 4)) : c2 != f2 && (c2 == f2 - 1 ? h2-- : c2 == f2 + 1 ? h2++ : (c2 > f2 ? h2-- : h2++, o2.__u |= 4))) : n2.__k[r2] = null;
2813
+ if (a2) for (r2 = 0; r2 < s2; r2++) null != (e2 = t2[r2]) && 0 == (2 & e2.__u) && (e2.__e == u2 && (u2 = S$1(e2)), B$2(e2, e2));
2271
2814
  return u2;
2272
2815
  }
2273
2816
  function A$1(n2, l2, t2) {
@@ -2312,7 +2855,7 @@ function j$2(n2, l2, t2, u2, i2) {
2312
2855
  if ("string" == typeof u2 && (n2.style.cssText = u2 = ""), u2) for (l2 in u2) t2 && l2 in t2 || T$2(n2.style, l2, "");
2313
2856
  if (t2) for (l2 in t2) u2 && t2[l2] === u2[l2] || T$2(n2.style, l2, t2[l2]);
2314
2857
  }
2315
- else if ("o" == l2[0] && "n" == l2[1]) r2 = l2 != (l2 = l2.replace(f$2, "$1")), l2 = l2.toLowerCase() in n2 || "onFocusOut" == l2 || "onFocusIn" == l2 ? l2.toLowerCase().slice(2) : l2.slice(2), n2.l || (n2.l = {}), n2.l[l2 + r2] = t2, t2 ? u2 ? t2.t = u2.t : (t2.t = c$1, n2.addEventListener(l2, r2 ? a$2 : s$2, r2)) : n2.removeEventListener(l2, r2 ? a$2 : s$2, r2);
2858
+ else if ("o" == l2[0] && "n" == l2[1]) r2 = l2 != (l2 = l2.replace(f$2, "$1")), l2 = l2.toLowerCase() in n2 || "onFocusOut" == l2 || "onFocusIn" == l2 ? l2.toLowerCase().slice(2) : l2.slice(2), n2.l || (n2.l = {}), n2.l[l2 + r2] = t2, t2 ? u2 ? t2.t = u2.t : (t2.t = c$1, n2.addEventListener(l2, r2 ? a$2 : s$1, r2)) : n2.removeEventListener(l2, r2 ? a$2 : s$1, r2);
2316
2859
  else {
2317
2860
  if ("http://www.w3.org/2000/svg" == i2) l2 = l2.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
2318
2861
  else if ("width" != l2 && "height" != l2 && "href" != l2 && "list" != l2 && "form" != l2 && "tabIndex" != l2 && "download" != l2 && "rowSpan" != l2 && "colSpan" != l2 && "role" != l2 && "popover" != l2 && l2 in n2) try {
@@ -2333,31 +2876,31 @@ function F$1(n2) {
2333
2876
  }
2334
2877
  };
2335
2878
  }
2336
- function O$1(n2, t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2337
- var a2, h3, p2, v2, y2, _2, m2, b2, S2, C2, M2, $2, P2, A2, H2, L2, T2, j2 = t2.type;
2879
+ function O(n2, t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2880
+ var a2, h2, p2, v2, y2, _2, m2, b, S2, C2, M2, $2, P2, A2, H2, L2, T2, j2 = t2.type;
2338
2881
  if (void 0 !== t2.constructor) return null;
2339
2882
  128 & u2.__u && (c2 = !!(32 & u2.__u), o2 = [f2 = t2.__e = u2.__e]), (a2 = l$1.__b) && a2(t2);
2340
2883
  n: if ("function" == typeof j2) try {
2341
- if (b2 = t2.props, S2 = "prototype" in j2 && j2.prototype.render, C2 = (a2 = j2.contextType) && i2[a2.__c], M2 = a2 ? C2 ? C2.props.value : a2.__ : i2, u2.__c ? m2 = (h3 = t2.__c = u2.__c).__ = h3.__E : (S2 ? t2.__c = h3 = new j2(b2, M2) : (t2.__c = h3 = new x$2(b2, M2), h3.constructor = j2, h3.render = D$1), C2 && C2.sub(h3), h3.props = b2, h3.state || (h3.state = {}), h3.context = M2, h3.__n = i2, p2 = h3.__d = true, h3.__h = [], h3._sb = []), S2 && null == h3.__s && (h3.__s = h3.state), S2 && null != j2.getDerivedStateFromProps && (h3.__s == h3.state && (h3.__s = w$1({}, h3.__s)), w$1(h3.__s, j2.getDerivedStateFromProps(b2, h3.__s))), v2 = h3.props, y2 = h3.state, h3.__v = t2, p2) S2 && null == j2.getDerivedStateFromProps && null != h3.componentWillMount && h3.componentWillMount(), S2 && null != h3.componentDidMount && h3.__h.push(h3.componentDidMount);
2884
+ if (b = t2.props, S2 = "prototype" in j2 && j2.prototype.render, C2 = (a2 = j2.contextType) && i2[a2.__c], M2 = a2 ? C2 ? C2.props.value : a2.__ : i2, u2.__c ? m2 = (h2 = t2.__c = u2.__c).__ = h2.__E : (S2 ? t2.__c = h2 = new j2(b, M2) : (t2.__c = h2 = new x$3(b, M2), h2.constructor = j2, h2.render = D$1), C2 && C2.sub(h2), h2.props = b, h2.state || (h2.state = {}), h2.context = M2, h2.__n = i2, p2 = h2.__d = true, h2.__h = [], h2._sb = []), S2 && null == h2.__s && (h2.__s = h2.state), S2 && null != j2.getDerivedStateFromProps && (h2.__s == h2.state && (h2.__s = w$1({}, h2.__s)), w$1(h2.__s, j2.getDerivedStateFromProps(b, h2.__s))), v2 = h2.props, y2 = h2.state, h2.__v = t2, p2) S2 && null == j2.getDerivedStateFromProps && null != h2.componentWillMount && h2.componentWillMount(), S2 && null != h2.componentDidMount && h2.__h.push(h2.componentDidMount);
2342
2885
  else {
2343
- if (S2 && null == j2.getDerivedStateFromProps && b2 !== v2 && null != h3.componentWillReceiveProps && h3.componentWillReceiveProps(b2, M2), !h3.__e && (null != h3.shouldComponentUpdate && false === h3.shouldComponentUpdate(b2, h3.__s, M2) || t2.__v == u2.__v)) {
2344
- for (t2.__v != u2.__v && (h3.props = b2, h3.state = h3.__s, h3.__d = false), t2.__e = u2.__e, t2.__k = u2.__k, t2.__k.some(function(n3) {
2886
+ if (S2 && null == j2.getDerivedStateFromProps && b !== v2 && null != h2.componentWillReceiveProps && h2.componentWillReceiveProps(b, M2), !h2.__e && (null != h2.shouldComponentUpdate && false === h2.shouldComponentUpdate(b, h2.__s, M2) || t2.__v == u2.__v)) {
2887
+ for (t2.__v != u2.__v && (h2.props = b, h2.state = h2.__s, h2.__d = false), t2.__e = u2.__e, t2.__k = u2.__k, t2.__k.some(function(n3) {
2345
2888
  n3 && (n3.__ = t2);
2346
- }), $2 = 0; $2 < h3._sb.length; $2++) h3.__h.push(h3._sb[$2]);
2347
- h3._sb = [], h3.__h.length && e2.push(h3);
2889
+ }), $2 = 0; $2 < h2._sb.length; $2++) h2.__h.push(h2._sb[$2]);
2890
+ h2._sb = [], h2.__h.length && e2.push(h2);
2348
2891
  break n;
2349
2892
  }
2350
- null != h3.componentWillUpdate && h3.componentWillUpdate(b2, h3.__s, M2), S2 && null != h3.componentDidUpdate && h3.__h.push(function() {
2351
- h3.componentDidUpdate(v2, y2, _2);
2893
+ null != h2.componentWillUpdate && h2.componentWillUpdate(b, h2.__s, M2), S2 && null != h2.componentDidUpdate && h2.__h.push(function() {
2894
+ h2.componentDidUpdate(v2, y2, _2);
2352
2895
  });
2353
2896
  }
2354
- if (h3.context = M2, h3.props = b2, h3.__P = n2, h3.__e = false, P2 = l$1.__r, A2 = 0, S2) {
2355
- for (h3.state = h3.__s, h3.__d = false, P2 && P2(t2), a2 = h3.render(h3.props, h3.state, h3.context), H2 = 0; H2 < h3._sb.length; H2++) h3.__h.push(h3._sb[H2]);
2356
- h3._sb = [];
2897
+ if (h2.context = M2, h2.props = b, h2.__P = n2, h2.__e = false, P2 = l$1.__r, A2 = 0, S2) {
2898
+ for (h2.state = h2.__s, h2.__d = false, P2 && P2(t2), a2 = h2.render(h2.props, h2.state, h2.context), H2 = 0; H2 < h2._sb.length; H2++) h2.__h.push(h2._sb[H2]);
2899
+ h2._sb = [];
2357
2900
  } else do {
2358
- h3.__d = false, P2 && P2(t2), a2 = h3.render(h3.props, h3.state, h3.context), h3.state = h3.__s;
2359
- } while (h3.__d && ++A2 < 25);
2360
- h3.state = h3.__s, null != h3.getChildContext && (i2 = w$1(w$1({}, i2), h3.getChildContext())), S2 && !p2 && null != h3.getSnapshotBeforeUpdate && (_2 = h3.getSnapshotBeforeUpdate(v2, y2)), L2 = a2, null != a2 && a2.type === k$1 && null == a2.key && (L2 = N$1(a2.props.children)), f2 = I(n2, d$1(L2) ? L2 : [L2], t2, u2, i2, r2, o2, e2, f2, c2, s2), h3.base = t2.__e, t2.__u &= -161, h3.__h.length && e2.push(h3), m2 && (h3.__E = h3.__ = null);
2901
+ h2.__d = false, P2 && P2(t2), a2 = h2.render(h2.props, h2.state, h2.context), h2.state = h2.__s;
2902
+ } while (h2.__d && ++A2 < 25);
2903
+ h2.state = h2.__s, null != h2.getChildContext && (i2 = w$1(w$1({}, i2), h2.getChildContext())), S2 && !p2 && null != h2.getSnapshotBeforeUpdate && (_2 = h2.getSnapshotBeforeUpdate(v2, y2)), L2 = a2, null != a2 && a2.type === k$1 && null == a2.key && (L2 = N$1(a2.props.children)), f2 = I(n2, d$1(L2) ? L2 : [L2], t2, u2, i2, r2, o2, e2, f2, c2, s2), h2.base = t2.__e, t2.__u &= -161, h2.__h.length && e2.push(h2), m2 && (h2.__E = h2.__ = null);
2361
2904
  } catch (n3) {
2362
2905
  if (t2.__v = null, c2 || null != o2) if (n3.then) {
2363
2906
  for (t2.__u |= c2 ? 160 : 128; f2 && 8 == f2.nodeType && f2.nextSibling; ) f2 = f2.nextSibling;
@@ -2370,7 +2913,7 @@ function O$1(n2, t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2370
2913
  return (a2 = l$1.diffed) && a2(t2), 128 & t2.__u ? void 0 : f2;
2371
2914
  }
2372
2915
  function z$1(n2, t2, u2) {
2373
- for (var i2 = 0; i2 < u2.length; i2++) q$3(u2[i2], u2[++i2], u2[++i2]);
2916
+ for (var i2 = 0; i2 < u2.length; i2++) q$2(u2[i2], u2[++i2], u2[++i2]);
2374
2917
  l$1.__c && l$1.__c(t2, n2), n2.some(function(t3) {
2375
2918
  try {
2376
2919
  n2 = t3.__h, t3.__h = [], n2.some(function(n3) {
@@ -2385,7 +2928,7 @@ function N$1(n2) {
2385
2928
  return "object" != typeof n2 || null == n2 ? n2 : d$1(n2) ? n2.map(N$1) : w$1({}, n2);
2386
2929
  }
2387
2930
  function V$1(t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2388
- var a2, h3, v2, y2, w2, _2, m2, b2 = i2.props, k2 = u2.props, x2 = u2.type;
2931
+ var a2, h2, v2, y2, w2, _2, m2, b = i2.props, k2 = u2.props, x2 = u2.type;
2389
2932
  if ("svg" == x2 ? o2 = "http://www.w3.org/2000/svg" : "math" == x2 ? o2 = "http://www.w3.org/1998/Math/MathML" : o2 || (o2 = "http://www.w3.org/1999/xhtml"), null != e2) {
2390
2933
  for (a2 = 0; a2 < e2.length; a2++) if ((w2 = e2[a2]) && "setAttribute" in w2 == !!x2 && (x2 ? w2.localName == x2 : 3 == w2.nodeType)) {
2391
2934
  t2 = w2, e2[a2] = null;
@@ -2396,23 +2939,23 @@ function V$1(t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2396
2939
  if (null == x2) return document.createTextNode(k2);
2397
2940
  t2 = document.createElementNS(o2, x2, k2.is && k2), c2 && (l$1.__m && l$1.__m(u2, e2), c2 = false), e2 = null;
2398
2941
  }
2399
- if (null === x2) b2 === k2 || c2 && t2.data === k2 || (t2.data = k2);
2942
+ if (null === x2) b === k2 || c2 && t2.data === k2 || (t2.data = k2);
2400
2943
  else {
2401
- if (e2 = e2 && n.call(t2.childNodes), b2 = i2.props || p$1, !c2 && null != e2) for (b2 = {}, a2 = 0; a2 < t2.attributes.length; a2++) b2[(w2 = t2.attributes[a2]).name] = w2.value;
2402
- for (a2 in b2) if (w2 = b2[a2], "children" == a2) ;
2944
+ if (e2 = e2 && n.call(t2.childNodes), b = i2.props || p$1, !c2 && null != e2) for (b = {}, a2 = 0; a2 < t2.attributes.length; a2++) b[(w2 = t2.attributes[a2]).name] = w2.value;
2945
+ for (a2 in b) if (w2 = b[a2], "children" == a2) ;
2403
2946
  else if ("dangerouslySetInnerHTML" == a2) v2 = w2;
2404
2947
  else if (!(a2 in k2)) {
2405
2948
  if ("value" == a2 && "defaultValue" in k2 || "checked" == a2 && "defaultChecked" in k2) continue;
2406
2949
  j$2(t2, a2, null, w2, o2);
2407
2950
  }
2408
- for (a2 in k2) w2 = k2[a2], "children" == a2 ? y2 = w2 : "dangerouslySetInnerHTML" == a2 ? h3 = w2 : "value" == a2 ? _2 = w2 : "checked" == a2 ? m2 = w2 : c2 && "function" != typeof w2 || b2[a2] === w2 || j$2(t2, a2, w2, b2[a2], o2);
2409
- if (h3) c2 || v2 && (h3.__html === v2.__html || h3.__html === t2.innerHTML) || (t2.innerHTML = h3.__html), u2.__k = [];
2951
+ for (a2 in k2) w2 = k2[a2], "children" == a2 ? y2 = w2 : "dangerouslySetInnerHTML" == a2 ? h2 = w2 : "value" == a2 ? _2 = w2 : "checked" == a2 ? m2 = w2 : c2 && "function" != typeof w2 || b[a2] === w2 || j$2(t2, a2, w2, b[a2], o2);
2952
+ if (h2) c2 || v2 && (h2.__html === v2.__html || h2.__html === t2.innerHTML) || (t2.innerHTML = h2.__html), u2.__k = [];
2410
2953
  else if (v2 && (t2.innerHTML = ""), I("template" === u2.type ? t2.content : t2, d$1(y2) ? y2 : [y2], u2, i2, r2, "foreignObject" == x2 ? "http://www.w3.org/1999/xhtml" : o2, e2, f2, e2 ? e2[0] : i2.__k && S$1(i2, 0), c2, s2), null != e2) for (a2 = e2.length; a2--; ) g$1(e2[a2]);
2411
- c2 || (a2 = "value", "progress" == x2 && null == _2 ? t2.removeAttribute("value") : void 0 !== _2 && (_2 !== t2[a2] || "progress" == x2 && !_2 || "option" == x2 && _2 !== b2[a2]) && j$2(t2, a2, _2, b2[a2], o2), a2 = "checked", void 0 !== m2 && m2 !== t2[a2] && j$2(t2, a2, m2, b2[a2], o2));
2954
+ c2 || (a2 = "value", "progress" == x2 && null == _2 ? t2.removeAttribute("value") : void 0 !== _2 && (_2 !== t2[a2] || "progress" == x2 && !_2 || "option" == x2 && _2 !== b[a2]) && j$2(t2, a2, _2, b[a2], o2), a2 = "checked", void 0 !== m2 && m2 !== t2[a2] && j$2(t2, a2, m2, b[a2], o2));
2412
2955
  }
2413
2956
  return t2;
2414
2957
  }
2415
- function q$3(n2, t2, u2) {
2958
+ function q$2(n2, t2, u2) {
2416
2959
  try {
2417
2960
  if ("function" == typeof n2) {
2418
2961
  var i2 = "function" == typeof n2.__u;
@@ -2422,9 +2965,9 @@ function q$3(n2, t2, u2) {
2422
2965
  l$1.__e(n3, u2);
2423
2966
  }
2424
2967
  }
2425
- function B$3(n2, t2, u2) {
2968
+ function B$2(n2, t2, u2) {
2426
2969
  var i2, r2;
2427
- if (l$1.unmount && l$1.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current !== n2.__e || q$3(i2, null, t2)), null != (i2 = n2.__c)) {
2970
+ if (l$1.unmount && l$1.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current !== n2.__e || q$2(i2, null, t2)), null != (i2 = n2.__c)) {
2428
2971
  if (i2.componentWillUnmount) try {
2429
2972
  i2.componentWillUnmount();
2430
2973
  } catch (n3) {
@@ -2432,7 +2975,7 @@ function B$3(n2, t2, u2) {
2432
2975
  }
2433
2976
  i2.base = i2.__P = null;
2434
2977
  }
2435
- if (i2 = n2.__k) for (r2 = 0; r2 < i2.length; r2++) i2[r2] && B$3(i2[r2], t2, u2 || "function" != typeof n2.type);
2978
+ if (i2 = n2.__k) for (r2 = 0; r2 < i2.length; r2++) i2[r2] && B$2(i2[r2], t2, u2 || "function" != typeof n2.type);
2436
2979
  u2 || g$1(n2.__e), n2.__c = n2.__ = n2.__e = void 0;
2437
2980
  }
2438
2981
  function D$1(n2, l2, t2) {
@@ -2440,7 +2983,7 @@ function D$1(n2, l2, t2) {
2440
2983
  }
2441
2984
  function E$1(t2, u2, i2) {
2442
2985
  var r2, o2, e2, f2;
2443
- u2 == document && (u2 = document.documentElement), l$1.__ && l$1.__(t2, u2), o2 = (r2 = false) ? null : u2.__k, e2 = [], f2 = [], O$1(u2, t2 = u2.__k = _$1(k$1, null, [t2]), o2 || p$1, p$1, u2.namespaceURI, o2 ? null : u2.firstChild ? n.call(u2.childNodes) : null, e2, o2 ? o2.__e : u2.firstChild, r2, f2), z$1(e2, t2, f2);
2986
+ u2 == document && (u2 = document.documentElement), l$1.__ && l$1.__(t2, u2), o2 = (r2 = false) ? null : u2.__k, e2 = [], f2 = [], O(u2, t2 = u2.__k = _$1(k$1, null, [t2]), o2 || p$1, p$1, u2.namespaceURI, o2 ? null : u2.firstChild ? n.call(u2.childNodes) : null, e2, o2 ? o2.__e : u2.firstChild, r2, f2), z$1(e2, t2, f2);
2444
2987
  }
2445
2988
  function K$1(n2) {
2446
2989
  function l2(n3) {
@@ -2472,15 +3015,15 @@ n = v$1.slice, l$1 = { __e: function(n2, l2, t2, u2) {
2472
3015
  n2 = l3;
2473
3016
  }
2474
3017
  throw n2;
2475
- } }, t$1 = 0, x$2.prototype.setState = function(n2, l2) {
3018
+ } }, t$1 = 0, x$3.prototype.setState = function(n2, l2) {
2476
3019
  var t2;
2477
3020
  t2 = null != this.__s && this.__s !== this.state ? this.__s : this.__s = w$1({}, this.state), "function" == typeof n2 && (n2 = n2(w$1({}, t2), this.props)), n2 && w$1(t2, n2), null != n2 && this.__v && (l2 && this._sb.push(l2), M(this));
2478
- }, x$2.prototype.forceUpdate = function(n2) {
3021
+ }, x$3.prototype.forceUpdate = function(n2) {
2479
3022
  this.__v && (this.__e = true, n2 && this.__h.push(n2), M(this));
2480
- }, x$2.prototype.render = k$1, i$1 = [], o$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e$1 = function(n2, l2) {
3023
+ }, x$3.prototype.render = k$1, i$1 = [], o$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e$1 = function(n2, l2) {
2481
3024
  return n2.__v.__b - l2.__v.__b;
2482
- }, $.__r = 0, f$2 = /(PointerCapture)$|Capture$/i, c$1 = 0, s$2 = F$1(false), a$2 = F$1(true), h$1 = 0;
2483
- var t, r$1, u$1, i, o = 0, f$1 = [], c = l$1, e = c.__b, a$1 = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s$1 = c.__;
3025
+ }, $.__r = 0, f$2 = /(PointerCapture)$|Capture$/i, c$1 = 0, s$1 = F$1(false), a$2 = F$1(true), h$1 = 0;
3026
+ var t, r$1, u$1, i, o = 0, f$1 = [], c = l$1, e = c.__b, a$1 = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s = c.__;
2484
3027
  function p(n2, t2) {
2485
3028
  c.__h && c.__h(r$1, n2, o || t2), o = 0;
2486
3029
  var u2 = r$1.__H || (r$1.__H = { __: [], __h: [] });
@@ -2540,12 +3083,12 @@ function T$1(n2, r2) {
2540
3083
  var u2 = p(t++, 7);
2541
3084
  return C$1(u2.__H, r2) && (u2.__ = n2(), u2.__H = r2, u2.__h = n2), u2.__;
2542
3085
  }
2543
- function q$2(n2, t2) {
3086
+ function q$1(n2, t2) {
2544
3087
  return o = 8, T$1(function() {
2545
3088
  return n2;
2546
3089
  }, t2);
2547
3090
  }
2548
- function x$1(n2) {
3091
+ function x$2(n2) {
2549
3092
  var u2 = r$1.context[n2.__c], i2 = p(t++, 9);
2550
3093
  return i2.c = n2, u2 ? (null == i2.__ && (i2.__ = true, u2.sub(r$1)), u2.props.value) : n2.__;
2551
3094
  }
@@ -2554,7 +3097,7 @@ function P$1(n2, t2) {
2554
3097
  }
2555
3098
  function j$1() {
2556
3099
  for (var n2; n2 = f$1.shift(); ) if (n2.__P && n2.__H) try {
2557
- n2.__H.__h.forEach(z), n2.__H.__h.forEach(B$2), n2.__H.__h = [];
3100
+ n2.__H.__h.forEach(z), n2.__H.__h.forEach(B$1), n2.__H.__h = [];
2558
3101
  } catch (t2) {
2559
3102
  n2.__H.__h = [], c.__e(t2, n2.__v);
2560
3103
  }
@@ -2562,13 +3105,13 @@ function j$1() {
2562
3105
  c.__b = function(n2) {
2563
3106
  r$1 = null, e && e(n2);
2564
3107
  }, c.__ = function(n2, t2) {
2565
- n2 && t2.__k && t2.__k.__m && (n2.__m = t2.__k.__m), s$1 && s$1(n2, t2);
3108
+ n2 && t2.__k && t2.__k.__m && (n2.__m = t2.__k.__m), s && s(n2, t2);
2566
3109
  }, c.__r = function(n2) {
2567
3110
  a$1 && a$1(n2), t = 0;
2568
3111
  var i2 = (r$1 = n2.__c).__H;
2569
3112
  i2 && (u$1 === r$1 ? (i2.__h = [], r$1.__h = [], i2.__.forEach(function(n3) {
2570
3113
  n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
2571
- })) : (i2.__h.forEach(z), i2.__h.forEach(B$2), i2.__h = [], t = 0)), u$1 = r$1;
3114
+ })) : (i2.__h.forEach(z), i2.__h.forEach(B$1), i2.__h = [], t = 0)), u$1 = r$1;
2572
3115
  }, c.diffed = function(n2) {
2573
3116
  v && v(n2);
2574
3117
  var t2 = n2.__c;
@@ -2579,7 +3122,7 @@ c.__b = function(n2) {
2579
3122
  t2.some(function(n3) {
2580
3123
  try {
2581
3124
  n3.__h.forEach(z), n3.__h = n3.__h.filter(function(n4) {
2582
- return !n4.__ || B$2(n4);
3125
+ return !n4.__ || B$1(n4);
2583
3126
  });
2584
3127
  } catch (r2) {
2585
3128
  t2.some(function(n4) {
@@ -2609,7 +3152,7 @@ function z(n2) {
2609
3152
  var t2 = r$1, u2 = n2.__c;
2610
3153
  "function" == typeof u2 && (n2.__c = void 0, u2()), r$1 = t2;
2611
3154
  }
2612
- function B$2(n2) {
3155
+ function B$1(n2) {
2613
3156
  var t2 = r$1;
2614
3157
  n2.__c = n2.__(), r$1 = t2;
2615
3158
  }
@@ -2633,14 +3176,14 @@ function E(n2, t2) {
2633
3176
  function C(n2, t2) {
2634
3177
  var e2 = t2(), r2 = d({ t: { __: e2, u: t2 } }), u2 = r2[0].t, o2 = r2[1];
2635
3178
  return _(function() {
2636
- u2.__ = e2, u2.u = t2, x(u2) && o2({ t: u2 });
3179
+ u2.__ = e2, u2.u = t2, x$1(u2) && o2({ t: u2 });
2637
3180
  }, [n2, e2, t2]), y$2(function() {
2638
- return x(u2) && o2({ t: u2 }), n2(function() {
2639
- x(u2) && o2({ t: u2 });
3181
+ return x$1(u2) && o2({ t: u2 }), n2(function() {
3182
+ x$1(u2) && o2({ t: u2 });
2640
3183
  });
2641
3184
  }, [n2]), e2;
2642
3185
  }
2643
- function x(n2) {
3186
+ function x$1(n2) {
2644
3187
  var t2, e2, r2 = n2.u, u2 = n2.__;
2645
3188
  try {
2646
3189
  var o2 = r2();
@@ -2652,7 +3195,7 @@ function x(n2) {
2652
3195
  function N(n2, t2) {
2653
3196
  this.props = n2, this.context = t2;
2654
3197
  }
2655
- (N.prototype = new x$2()).isPureReactComponent = true, N.prototype.shouldComponentUpdate = function(n2, t2) {
3198
+ (N.prototype = new x$3()).isPureReactComponent = true, N.prototype.shouldComponentUpdate = function(n2, t2) {
2656
3199
  return E(this.props, n2) || E(this.state, t2);
2657
3200
  };
2658
3201
  var T = l$1.__b;
@@ -2686,13 +3229,13 @@ function j(n2) {
2686
3229
  var t2 = n2.__.__c;
2687
3230
  return t2 && t2.__a && t2.__a(n2);
2688
3231
  }
2689
- function B$1() {
3232
+ function B() {
2690
3233
  this.i = null, this.l = null;
2691
3234
  }
2692
3235
  l$1.unmount = function(n2) {
2693
3236
  var t2 = n2.__c;
2694
3237
  t2 && t2.__R && t2.__R(), t2 && 32 & n2.__u && (n2.type = null), U && U(n2);
2695
- }, (P.prototype = new x$2()).__c = function(n2, t2) {
3238
+ }, (P.prototype = new x$3()).__c = function(n2, t2) {
2696
3239
  var e2 = t2.__c, r2 = this;
2697
3240
  null == r2.o && (r2.o = []), r2.o.push(e2);
2698
3241
  var u2 = j(r2.__v), o2 = false, i2 = function() {
@@ -2730,7 +3273,7 @@ var H = function(n2, t2, e2) {
2730
3273
  n2.i = e2 = e2[2];
2731
3274
  }
2732
3275
  };
2733
- (B$1.prototype = new x$2()).__a = function(n2) {
3276
+ (B.prototype = new x$3()).__a = function(n2) {
2734
3277
  var t2 = this, e2 = j(t2.__v), r2 = t2.l.get(n2);
2735
3278
  return r2[0]++, function(u2) {
2736
3279
  var o2 = function() {
@@ -2738,23 +3281,23 @@ var H = function(n2, t2, e2) {
2738
3281
  };
2739
3282
  e2 ? e2(o2) : o2();
2740
3283
  };
2741
- }, B$1.prototype.render = function(n2) {
3284
+ }, B.prototype.render = function(n2) {
2742
3285
  this.i = null, this.l = /* @__PURE__ */ new Map();
2743
3286
  var t2 = H$1(n2.children);
2744
3287
  n2.revealOrder && "b" === n2.revealOrder[0] && t2.reverse();
2745
3288
  for (var e2 = t2.length; e2--; ) this.l.set(t2[e2], this.i = [1, 0, this.i]);
2746
3289
  return n2.children;
2747
- }, B$1.prototype.componentDidUpdate = B$1.prototype.componentDidMount = function() {
3290
+ }, B.prototype.componentDidUpdate = B.prototype.componentDidMount = function() {
2748
3291
  var n2 = this;
2749
3292
  this.l.forEach(function(t2, e2) {
2750
3293
  H(n2, e2, t2);
2751
3294
  });
2752
3295
  };
2753
- var q$1 = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.element") || 60103, G$1 = /^(?: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 = function(n2) {
3296
+ 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 = function(n2) {
2754
3297
  return ("undefined" != typeof Symbol && "symbol" == typeof Symbol() ? /fil|che|rad/ : /fil|che|ra/).test(n2);
2755
3298
  };
2756
- x$2.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t2) {
2757
- Object.defineProperty(x$2.prototype, t2, { configurable: true, get: function() {
3299
+ x$3.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t2) {
3300
+ Object.defineProperty(x$3.prototype, t2, { configurable: true, get: function() {
2758
3301
  return this["UNSAFE_" + t2];
2759
3302
  }, set: function(n2) {
2760
3303
  Object.defineProperty(this, t2, { configurable: true, writable: true, value: n2 });
@@ -2782,7 +3325,7 @@ l$1.vnode = function(n2) {
2782
3325
  var c2 = t2[i2];
2783
3326
  if (!("value" === i2 && "defaultValue" in t2 && null == c2 || Q && "children" === i2 && "noscript" === e2 || "class" === i2 || "className" === i2)) {
2784
3327
  var l2 = i2.toLowerCase();
2785
- "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(t2.type) ? "onfocus" === l2 ? i2 = "onfocusin" : "onblur" === l2 ? i2 = "onfocusout" : J.test(i2) && (i2 = l2) : l2 = i2 = "oninput" : o2 && G$1.test(i2) ? i2 = i2.replace(K, "-$&").toLowerCase() : null === c2 && (c2 = void 0), "oninput" === l2 && u2[i2 = l2] && (i2 = "oninputCapture"), u2[i2] = c2;
3328
+ "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(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;
2786
3329
  }
2787
3330
  }
2788
3331
  "select" == e2 && u2.multiple && Array.isArray(u2.value) && (u2.value = H$1(t2.children).forEach(function(n4) {
@@ -2790,7 +3333,7 @@ l$1.vnode = function(n2) {
2790
3333
  })), "select" == e2 && null != u2.defaultValue && (u2.value = H$1(t2.children).forEach(function(n4) {
2791
3334
  n4.props.selected = u2.multiple ? -1 != u2.defaultValue.indexOf(n4.props.value) : u2.defaultValue == n4.props.value;
2792
3335
  })), 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;
2793
- }(n2), n2.$$typeof = q$1, fn && fn(n2);
3336
+ }(n2), n2.$$typeof = q, fn && fn(n2);
2794
3337
  };
2795
3338
  var an = l$1.__r;
2796
3339
  l$1.__r = function(n2) {
@@ -2803,19 +3346,34 @@ l$1.diffed = function(n2) {
2803
3346
  null != e2 && "textarea" === n2.type && "value" in t2 && t2.value !== e2.value && (e2.value = null == t2.value ? "" : t2.value);
2804
3347
  };
2805
3348
  var Rn = { useState: d, useEffect: y$2, useLayoutEffect: _, useSyncExternalStore: C, useRef: A, useMemo: T$1, useDebugValue: P$1 };
2806
- var r = (e2) => !e2 && e2 == null, y$1 = (e2) => !r(e2), a = (e2) => typeof e2 == "object" && !Array.isArray(e2) && y$1(e2), s = (e2) => typeof e2 == "string" && e2.split(":").length >= 2;
2807
- var G = (e2) => s(e2), O = (e2) => a(e2);
2808
- var q = (e2) => {
2809
- if (typeof e2 == "string") return B(e2) ? e2 : null;
2810
- if (!(e2 == null ? void 0 : e2._type)) return null;
2811
- let r2 = null;
2812
- return (y$1(e2.id) || y$1(e2._id)) && (r2 = `${e2.id ?? e2._id}`), r2 && `${e2._type}:${r2}`;
2813
- };
2814
- var B = (e2) => {
2815
- if (O(e2) && (e2 == null ? void 0 : e2._type) && q(e2)) return e2;
2816
- if (!e2 || typeof e2 != "string") return null;
2817
- let [r2, ...u2] = e2.split(":");
2818
- return !r2 || u2.length < 1 ? null : { _type: r2, _id: u2.join(":") };
3349
+ var r = (e2) => !e2 && e2 == null, y$1 = (e2) => !r(e2), a = (e2) => typeof e2 == "object" && !Array.isArray(e2) && y$1(e2);
3350
+ var isObject$2 = (input) => a(input);
3351
+ var keyOfEntity = (entity) => {
3352
+ if (typeof entity === "string") {
3353
+ return entityOfKey(entity) ? entity : null;
3354
+ }
3355
+ if (!(entity == null ? void 0 : entity._type)) {
3356
+ return null;
3357
+ }
3358
+ let entityId = null;
3359
+ if (y$1(entity.id) || y$1(entity._id)) {
3360
+ entityId = `${entity.id ?? entity._id}`;
3361
+ }
3362
+ return !entityId ? entityId : `${entity._type}:${entityId}`;
3363
+ };
3364
+ var entityOfKey = (entity) => {
3365
+ if (isObject$2(entity) && (entity == null ? void 0 : entity._type) && keyOfEntity(entity)) {
3366
+ return entity;
3367
+ }
3368
+ if (!entity || typeof entity !== "string")
3369
+ return null;
3370
+ const [typeName, ...restTypes] = entity.split(":");
3371
+ if (!typeName || restTypes.length < 1)
3372
+ return null;
3373
+ return {
3374
+ _type: typeName,
3375
+ _id: restTypes.join(":")
3376
+ };
2819
3377
  };
2820
3378
  (function() {
2821
3379
  try {
@@ -2949,12 +3507,13 @@ const variableTransforms = createConstants(
2949
3507
  );
2950
3508
  const renderTarget = createConstants("canvas", "document");
2951
3509
  const renderMode = createConstants("viewport", "parent", "fixed");
2952
- const interactions = createConstants("click", "mouseover");
2953
- const eventMode = createConstants("goal", "callback");
3510
+ const interactions = createConstants("click", "mouseover", "appear");
3511
+ const eventMode = createConstants("goal", "callback", "tracker");
2954
3512
  const scopeTypes = createConstants(
2955
3513
  "InstanceScope",
2956
3514
  "FragmentScope",
2957
- "CollectionScope"
3515
+ "CollectionScope",
3516
+ "CollectionItemScope"
2958
3517
  );
2959
3518
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2960
3519
  __proto__: null,
@@ -3811,8 +4370,28 @@ const PositionSchema = /* @__PURE__ */ object({
3811
4370
  position: layerField(/* @__PURE__ */ enum_(Object.keys(positionType)), {
3812
4371
  fallback: positionType.absolute
3813
4372
  }),
3814
- top: layerField(/* @__PURE__ */ number(), { fallback: 0, transform: Math.ceil }),
3815
- left: layerField(/* @__PURE__ */ number(), { fallback: 0, transform: Math.ceil })
4373
+ top: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
4374
+ fallback: null,
4375
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
4376
+ }),
4377
+ left: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
4378
+ fallback: null,
4379
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
4380
+ }),
4381
+ right: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
4382
+ fallback: null,
4383
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
4384
+ }),
4385
+ bottom: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
4386
+ fallback: null,
4387
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
4388
+ }),
4389
+ centerAnchorX: layerField(/* @__PURE__ */ number(), {
4390
+ fallback: 0.5
4391
+ }),
4392
+ centerAnchorY: layerField(/* @__PURE__ */ number(), {
4393
+ fallback: 0.5
4394
+ })
3816
4395
  });
3817
4396
  const SceneSchema = /* @__PURE__ */ object({
3818
4397
  opacity: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0), /* @__PURE__ */ maxValue(1)), {
@@ -3820,6 +4399,7 @@ const SceneSchema = /* @__PURE__ */ object({
3820
4399
  variable: true
3821
4400
  }),
3822
4401
  visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
4402
+ rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
3823
4403
  zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 })
3824
4404
  });
3825
4405
  const FillSchema = /* @__PURE__ */ object({
@@ -3969,33 +4549,22 @@ const TextSchema = /* @__PURE__ */ object({
3969
4549
  whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
3970
4550
  fallback: whiteSpace.pre
3971
4551
  }),
3972
- variableContent: layerField(/* @__PURE__ */ string(), { fallback: null, variable: true }),
4552
+ textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
3973
4553
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
3974
- attributes: /* @__PURE__ */ optional(
3975
- /* @__PURE__ */ object({
3976
- fontSize: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
3977
- color: layerField(/* @__PURE__ */ string(), { fallback: "#000", variable: true }),
3978
- lineHeight: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
3979
- fontWeight: layerField(/* @__PURE__ */ string(), { fallback: "normal" }),
3980
- letterSpacing: layerField(/* @__PURE__ */ string(), { fallback: "0px" }),
3981
- textTransform: layerField(/* @__PURE__ */ string(), { fallback: "none" }),
3982
- textDecoration: layerField(/* @__PURE__ */ string(), { fallback: "none" }),
3983
- whiteSpace: layerField(/* @__PURE__ */ string(), { fallback: "pre" }),
3984
- textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" })
3985
- })
3986
- ),
3987
4554
  ...GraphFieldSchema.entries,
3988
4555
  ...OverridesSchema.entries,
3989
4556
  ...CssOverrideSchema.entries,
3990
4557
  ...PositionSchema.entries,
3991
4558
  ...SceneSchema.entries,
3992
- ...SizeSchema.entries
4559
+ ...SizeSchema.entries,
4560
+ ...InteractionsSchema.entries,
4561
+ ...LinkSchema.entries
3993
4562
  });
3994
4563
  const FragmentSchema = /* @__PURE__ */ object({
3995
4564
  name: layerField(/* @__PURE__ */ string(), { fallback: "Fragment", overridable: false }),
3996
4565
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
3997
4566
  horizontalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
3998
- fallback: fragmentGrowingMode.auto,
4567
+ fallback: fragmentGrowingMode.fill,
3999
4568
  overridable: false
4000
4569
  }),
4001
4570
  verticalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
@@ -4036,6 +4605,7 @@ const InstanceSchema = /* @__PURE__ */ object({
4036
4605
  ...PositionSchema.entries,
4037
4606
  ...SizeSchema.entries,
4038
4607
  ...SceneSchema.entries,
4608
+ ...InteractionsSchema.entries,
4039
4609
  ...LinkSchema.entries
4040
4610
  });
4041
4611
  const NumberVariableSchema = /* @__PURE__ */ object({
@@ -4220,7 +4790,7 @@ const ArrayVariableSchema = /* @__PURE__ */ object({
4220
4790
  }),
4221
4791
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
4222
4792
  defaultValue: layerField(/* @__PURE__ */ array(/* @__PURE__ */ any()), { fallback: [] }),
4223
- definition: layerField(/* @__PURE__ */ nullable(linkValidator), { fallback: null }),
4793
+ definition: layerField(linkValidator, { fallback: null }),
4224
4794
  required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4225
4795
  ...GraphFieldSchema.entries
4226
4796
  });
@@ -4252,7 +4822,7 @@ const getLayerSchema = (layer) => {
4252
4822
  const isObject$1 = (x2) => !!x2 && typeof x2 === "object" && !Array.isArray(x2);
4253
4823
  const normalizeLayer = (schema, rawLayer, options2) => {
4254
4824
  try {
4255
- if (!rawLayer) return null;
4825
+ if (!rawLayer || !schema.entries) return null;
4256
4826
  const withFallback = (options2 == null ? void 0 : options2.withFallback) ?? true;
4257
4827
  const overrideTarget = options2 == null ? void 0 : options2.overrideTarget;
4258
4828
  const parsedLayer = parse(schema, rawLayer);
@@ -4265,6 +4835,13 @@ const normalizeLayer = (schema, rawLayer, options2) => {
4265
4835
  if (isObject$1(layerValue) && isObject$1(overrideValue)) {
4266
4836
  layerValue = { ...overrideValue, ...layerValue };
4267
4837
  }
4838
+ if (schemaEntity && "wrapped" in schemaEntity && "entries" in schemaEntity.wrapped && isObject$1(schemaEntity.wrapped.entries)) {
4839
+ layerValue = normalizeLayer(
4840
+ schemaEntity.wrapped,
4841
+ layerValue,
4842
+ options2
4843
+ );
4844
+ }
4268
4845
  const resultValue = layerValue ?? overrideValue ?? fallback;
4269
4846
  return [key, resultValue];
4270
4847
  })
@@ -4274,12 +4851,13 @@ const normalizeLayer = (schema, rawLayer, options2) => {
4274
4851
  return null;
4275
4852
  }
4276
4853
  };
4277
- const getNormalizeLayer$1 = (layer, overrider) => {
4854
+ const getNormalizeLayer$1 = (layer, overrider, withFallback) => {
4278
4855
  if (!layer) return null;
4279
4856
  const schema = getLayerSchema(layer);
4280
4857
  if (!schema) return null;
4281
4858
  return normalizeLayer(schema, layer, {
4282
- overrideTarget: overrider
4859
+ overrideTarget: overrider,
4860
+ withFallback
4283
4861
  });
4284
4862
  };
4285
4863
  function findSchemaByPath(schema, path) {
@@ -4310,7 +4888,7 @@ const RenderTargetContext = K$1(
4310
4888
  );
4311
4889
  RenderTargetContext.Provider;
4312
4890
  const useRenderTarget = () => {
4313
- const renderTarget2 = x$1(RenderTargetContext);
4891
+ const renderTarget2 = x$2(RenderTargetContext);
4314
4892
  return {
4315
4893
  renderTarget: renderTarget2,
4316
4894
  isCanvas: renderTarget2 === index.renderTarget.canvas,
@@ -4468,35 +5046,37 @@ function requireWithSelector() {
4468
5046
  return withSelector.exports;
4469
5047
  }
4470
5048
  var withSelectorExports = requireWithSelector();
4471
- var b = (t2) => t2, y = (t2, e2, n2) => {
5049
+ var x = (t2) => t2, y = (t2, e2, n2) => {
4472
5050
  var _a, _b;
4473
- let r2 = A((_a = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a.call(t2, e2, n2)), o2 = ((_b = t2 == null ? void 0 : t2.keyOfEntity) == null ? void 0 : _b.call(t2, e2)) ?? e2, p2 = q$2((s2) => {
5051
+ let r2 = A((_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, o2 = q$1((p2) => {
4474
5052
  var _a2, _b2;
4475
- return o2 ? (r2.current = (_a2 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a2.call(t2, o2, n2), s2(), (_b2 = t2 == null ? void 0 : t2.subscribe) == null ? void 0 : _b2.call(t2, o2, () => {
5053
+ return s2 ? (r2.current = (_a2 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a2.call(t2, s2, n2), p2(), (_b2 = t2 == null ? void 0 : t2.subscribe) == null ? void 0 : _b2.call(t2, s2, () => {
4476
5054
  var _a3;
4477
- return r2.current = (_a3 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a3.call(t2, o2, n2), s2();
5055
+ return r2.current = (_a3 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a3.call(t2, s2, n2), p2();
4478
5056
  }, n2)) : () => {
4479
5057
  };
4480
- }, [t2, o2]), i2 = q$2((s2, u2) => {
4481
- let c2 = typeof e2 == "string" ? e2 : t2.keyOfEntity(e2);
4482
- e2 && c2 && t2.mutate(c2, s2, u2);
4483
- }, [t2, e2]), a2 = () => r2.current;
4484
- return [withSelectorExports.useSyncExternalStoreWithSelector(p2, a2, a2, b), i2];
4485
- };
4486
- var h2 = (t2) => t2, S = (t2, e2, n2) => {
4487
- let r2 = q$2((s2) => s2.map((u2) => t2.resolve(u2, n2)).filter(Boolean), [t2, n2]), o2 = T$1(() => e2.map((s2) => t2.keyOfEntity(s2) || s2).join(), [e2]), p2 = A(r2(e2)), i2 = q$2((s2) => {
5058
+ }, [t2, s2]), a2 = q$1((p2, c2) => {
5059
+ let u2 = typeof e2 == "string" ? e2 : keyOfEntity(e2);
5060
+ e2 && u2 && t2.mutate(u2, p2, c2);
5061
+ }, [t2, e2]), i2 = () => (n2 == null ? void 0 : n2.pause) ? null : r2.current;
5062
+ return [withSelectorExports.useSyncExternalStoreWithSelector(o2, i2, i2, x), a2];
5063
+ };
5064
+ var R = (t2) => t2, S = (t2, e2, n2) => {
5065
+ let r2 = q$1((c2) => c2.map((u2) => t2.resolve(u2, n2)).filter(Boolean), [t2, n2]), s2 = T$1(() => e2.map((c2) => t2.keyOfEntity(c2) || c2).join(), [e2]), o2 = A(r2(e2));
5066
+ A([]);
5067
+ let i2 = q$1((c2) => {
4488
5068
  if (e2) {
4489
5069
  let u2 = () => {
4490
- p2.current = r2(e2), s2();
4491
- }, c2 = new AbortController();
4492
- return e2.forEach((l2) => {
4493
- l2 && t2.subscribe(l2, u2, { signal: c2.signal, ...n2 });
4494
- }), u2(), () => c2.abort("unsubscribe");
5070
+ o2.current = r2(e2), c2();
5071
+ }, l2 = new AbortController();
5072
+ return e2.forEach((f2) => {
5073
+ f2 && t2.subscribe(f2, u2, { signal: l2.signal, ...n2 });
5074
+ }), u2(), () => l2.abort("unsubscribe");
4495
5075
  }
4496
5076
  return () => {
4497
5077
  };
4498
- }, [t2, o2]), a2 = () => p2.current;
4499
- return withSelectorExports.useSyncExternalStoreWithSelector(i2, a2, a2, h2);
5078
+ }, [t2, s2]), p2 = () => o2.current;
5079
+ return withSelectorExports.useSyncExternalStoreWithSelector(i2, p2, p2, R);
4500
5080
  };
4501
5081
  const GlobalManager = K$1(null);
4502
5082
  var __defProp = Object.defineProperty;
@@ -4504,14 +5084,14 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4504
5084
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4505
5085
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
4506
5086
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4507
- var __spreadValues = (a2, b2) => {
4508
- for (var prop in b2 || (b2 = {}))
4509
- if (__hasOwnProp.call(b2, prop))
4510
- __defNormalProp(a2, prop, b2[prop]);
5087
+ var __spreadValues = (a2, b) => {
5088
+ for (var prop in b || (b = {}))
5089
+ if (__hasOwnProp.call(b, prop))
5090
+ __defNormalProp(a2, prop, b[prop]);
4511
5091
  if (__getOwnPropSymbols)
4512
- for (var prop of __getOwnPropSymbols(b2)) {
4513
- if (__propIsEnum.call(b2, prop))
4514
- __defNormalProp(a2, prop, b2[prop]);
5092
+ for (var prop of __getOwnPropSymbols(b)) {
5093
+ if (__propIsEnum.call(b, prop))
5094
+ __defNormalProp(a2, prop, b[prop]);
4515
5095
  }
4516
5096
  return a2;
4517
5097
  };
@@ -4538,7 +5118,7 @@ var set = (obj, path, value) => {
4538
5118
  return acc[key];
4539
5119
  }, obj);
4540
5120
  };
4541
- var toKebabCase = (value) => value.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($2, ofs) => (ofs ? "-" : "") + $2.toLowerCase());
5121
+ var isPrimitive = (value) => typeof value !== "object" && typeof value !== "function" || value === null;
4542
5122
  var noop = () => void 0;
4543
5123
  var pick = (obj, ...props) => {
4544
5124
  return props.reduce((result, prop) => {
@@ -4553,7 +5133,28 @@ function omit(obj, ...props) {
4553
5133
  });
4554
5134
  return result;
4555
5135
  }
5136
+ var cleanGraph = (input) => isObject(input) ? omit(input, "_type", "_id") : input;
4556
5137
  var isBrowser_default = typeof window !== "undefined";
5138
+ var flattenObject = (obj) => {
5139
+ const result = {};
5140
+ function flatten(current) {
5141
+ for (let key in current) {
5142
+ if (current.hasOwnProperty(key)) {
5143
+ const value = current[key];
5144
+ if (value && typeof value === "object" && !Array.isArray(value)) {
5145
+ flatten(value);
5146
+ } else {
5147
+ result[key] = value;
5148
+ }
5149
+ }
5150
+ }
5151
+ }
5152
+ flatten(obj);
5153
+ return result;
5154
+ };
5155
+ function isFiniteNumber(value) {
5156
+ return typeof value === "number" && isFinite(value);
5157
+ }
4557
5158
  function hashGenerator(layerKey) {
4558
5159
  let hash = 0;
4559
5160
  for (let i2 = 0; i2 < layerKey.length; i2++) {
@@ -4565,7 +5166,7 @@ function hashGenerator(layerKey) {
4565
5166
  }
4566
5167
  const useGlobalManager = (globalManager) => {
4567
5168
  var _a, _b;
4568
- const currentGlobalManager = x$1(GlobalManager);
5169
+ const currentGlobalManager = x$2(GlobalManager);
4569
5170
  const resultManager = globalManager ?? currentGlobalManager;
4570
5171
  const [fragmentsGraph] = y(
4571
5172
  resultManager,
@@ -4657,58 +5258,189 @@ const isInheritField = (manager, layerEntity, field) => {
4657
5258
  }
4658
5259
  return false;
4659
5260
  };
4660
- const getLayer = (manager, layer) => {
5261
+ const isVariableLink = (value) => {
5262
+ var _a;
5263
+ return isLink(value) && ((_a = value == null ? void 0 : value.split(":")) == null ? void 0 : _a.at(0)) === index.nodes.Variable;
5264
+ };
5265
+ const isLink = (value) => {
5266
+ var _a, _b;
5267
+ return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
5268
+ };
5269
+ const getCssVariables = (props) => {
5270
+ return Object.entries(cleanGraph(flattenObject(props))).reduce(
5271
+ (acc, [key, value]) => {
5272
+ var _a;
5273
+ if (isVariableLink(value)) {
5274
+ const nestedVariableId = (_a = entityOfKey(value)) == null ? void 0 : _a._id;
5275
+ value = `var(--${nestedVariableId})`;
5276
+ }
5277
+ acc[`--${key}`] = value;
5278
+ return acc;
5279
+ },
5280
+ {}
5281
+ );
5282
+ };
5283
+ const layerFieldSetter = (manager, layerKey, fieldKey, currentValue) => (value, options2) => {
5284
+ var _a;
5285
+ const { success, output } = parseLayerField(
5286
+ manager.resolve(layerKey),
5287
+ fieldKey,
5288
+ value
5289
+ );
5290
+ if (success) {
5291
+ if (isVariableLink$1(value)) {
5292
+ manager.mutate((_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.temp, {
5293
+ [layerKey]: {
5294
+ [fieldKey]: currentValue
5295
+ }
5296
+ });
5297
+ }
5298
+ manager.mutate(
5299
+ layerKey,
5300
+ (prev) => {
5301
+ set(prev, fieldKey, output);
5302
+ return prev;
5303
+ },
5304
+ options2
5305
+ );
5306
+ }
5307
+ };
5308
+ const getLayer = (manager, layer, options2) => {
4661
5309
  if (!manager || !layer) return null;
4662
5310
  const layerKey = manager.keyOfEntity(layer);
4663
5311
  const layerData = manager.resolve(layerKey);
4664
5312
  const overrider = getOverrider(manager, layerKey);
4665
- return getNormalizeLayer$1(layerData, overrider);
5313
+ return getNormalizeLayer$1(layerData, overrider, options2 == null ? void 0 : options2.withFallback);
4666
5314
  };
4667
- const getNormalizeLayer = (layerKey, manager) => {
5315
+ const getNormalizeLayer = (layerKey, manager, options2) => {
4668
5316
  const layer = manager == null ? void 0 : manager.resolve(layerKey);
4669
- const parsedLayer = getLayer(manager, layerKey);
5317
+ const parsedLayer = getLayer(manager, layerKey, options2);
4670
5318
  return {
4671
5319
  rawLayer: layer,
4672
5320
  layer: parsedLayer
4673
5321
  };
4674
5322
  };
4675
- const useNormalizeLayer = (layerKey, manager) => {
4676
- const { manager: fragmentManager } = x$1(FragmentContext);
5323
+ const useNormalizeLayer = (layerKey, manager, options2) => {
5324
+ const { manager: fragmentManager } = x$2(FragmentContext);
4677
5325
  const resultManager = manager ?? fragmentManager;
4678
- return getNormalizeLayer(layerKey, resultManager);
5326
+ return getNormalizeLayer(layerKey, resultManager, options2);
4679
5327
  };
4680
5328
  const ScopeContext = K$1([]);
4681
- const useReadVariable = (variableKey) => {
4682
- var _a;
4683
- const scopes = x$1(ScopeContext);
4684
- const variableId = (_a = B(variableKey)) == null ? void 0 : _a._id;
4685
- const readVariable = (variableKey2) => {
4686
- var _a2, _b, _c;
4687
- const isVariable = isVariableLink$1(variableKey2);
4688
- const instanceProp = (_b = (_a2 = scopes.findLast(
4689
- (scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.InstanceScope
4690
- )) == null ? void 0 : _a2.props) == null ? void 0 : _b[variableId];
4691
- const fragmentDefinition = scopes.findLast(
4692
- (scope) => {
4693
- var _a3;
4694
- return scope.type === index.scopeTypes.FragmentScope && ((_a3 = scope == null ? void 0 : scope.definitions) == null ? void 0 : _a3.find((def) => def === variableKey2));
5329
+ const extractVariableValue = (input, variableId) => {
5330
+ if (isObject(input)) {
5331
+ if (variableId in input) {
5332
+ return input[variableId];
5333
+ }
5334
+ for (let key in input) {
5335
+ if (input.hasOwnProperty(key)) {
5336
+ const result = extractVariableValue(input[key], variableId);
5337
+ if (result !== void 0) {
5338
+ return result;
5339
+ }
4695
5340
  }
5341
+ }
5342
+ }
5343
+ return void 0;
5344
+ };
5345
+ function deepMerge(a2, b) {
5346
+ if (!isObject(a2) || !isObject(b)) return a2;
5347
+ const result = { ...b };
5348
+ for (const [key, value] of Object.entries(a2)) {
5349
+ if (key in result && typeof result[key] === "object" && typeof value === "object") {
5350
+ result[key] = deepMerge(value, result[key]);
5351
+ } else {
5352
+ result[key] = value;
5353
+ }
5354
+ }
5355
+ return result;
5356
+ }
5357
+ const useReadVariable = (variableKey) => {
5358
+ const scopes = x$2(ScopeContext);
5359
+ const extractVariableDefaultValue = (manager, variableEntity) => {
5360
+ const variableLayer = manager.resolve(variableEntity);
5361
+ if ((variableLayer == null ? void 0 : variableLayer.type) !== index.variableType.Object)
5362
+ return variableLayer == null ? void 0 : variableLayer.defaultValue;
5363
+ return Object.values((variableLayer == null ? void 0 : variableLayer.fields) ?? {}).reduce(
5364
+ (acc, fieldLink) => {
5365
+ var _a;
5366
+ if (!!fieldLink && isVariableLink$1(fieldLink)) {
5367
+ const _id = (_a = entityOfKey(fieldLink)) == null ? void 0 : _a._id;
5368
+ if (_id) {
5369
+ acc[_id] = extractVariableDefaultValue(manager, fieldLink);
5370
+ }
5371
+ }
5372
+ return acc;
5373
+ },
5374
+ {}
4696
5375
  );
4697
- if (!isVariable) {
5376
+ };
5377
+ const resolveVariableLayer = (manager, variableLink, customProps) => {
5378
+ var _a;
5379
+ const variableLayer = manager == null ? void 0 : manager.resolve(variableLink);
5380
+ if (!variableLayer) return null;
5381
+ if ((variableLayer == null ? void 0 : variableLayer.type) === index.variableType.Array) {
5382
+ const definitionLayer = manager.resolve(variableLayer == null ? void 0 : variableLayer.definition);
5383
+ if (!((_a = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== index.variableType.Object)
5384
+ return variableLayer;
5385
+ const definitionDefaultValue = extractVariableDefaultValue(
5386
+ manager,
5387
+ definitionLayer
5388
+ );
5389
+ const customValue = customProps == null ? void 0 : customProps[variableLayer == null ? void 0 : variableLayer._id];
5390
+ return {
5391
+ ...variableLayer,
5392
+ defaultValue: (variableLayer == null ? void 0 : variableLayer.defaultValue).map((item, index2) => {
5393
+ const customItemValue = Array.isArray(customValue) ? customValue.at(index2) : null;
5394
+ return deepMerge(
5395
+ customItemValue ? { ...item, ...customItemValue } : item,
5396
+ definitionDefaultValue
5397
+ );
5398
+ })
5399
+ };
5400
+ }
5401
+ return variableLayer;
5402
+ };
5403
+ const readVariable = (variableKey2) => {
5404
+ var _a, _b, _c;
5405
+ const variableId = (_a = entityOfKey(variableKey2)) == null ? void 0 : _a._id;
5406
+ if (!isVariableLink$1(variableKey2)) {
4698
5407
  return {
4699
5408
  value: null,
4700
5409
  layer: null
4701
5410
  };
4702
5411
  }
4703
- const variableLayer = pick(
4704
- ((_c = fragmentDefinition == null ? void 0 : fragmentDefinition.manager) == null ? void 0 : _c.resolve(variableKey2)) ?? {},
4705
- "defaultValue",
4706
- "required"
5412
+ const instanceScope = scopes.findLast(
5413
+ (scope) => {
5414
+ var _a2;
5415
+ return (scope == null ? void 0 : scope.type) === index.scopeTypes.InstanceScope && !!((_a2 = scope.documentManager) == null ? void 0 : _a2.resolve(variableKey2));
5416
+ }
4707
5417
  );
4708
- const currentValue = variableKey2 === instanceProp ? null : instanceProp ?? null;
5418
+ const variableLayer = resolveVariableLayer(
5419
+ instanceScope == null ? void 0 : instanceScope.documentManager,
5420
+ variableKey2
5421
+ );
5422
+ let instanceProp = (_b = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _b[variableId];
5423
+ if (Array.isArray(instanceProp)) {
5424
+ instanceProp = instanceProp.map(
5425
+ (rawProp, index2) => {
5426
+ var _a2;
5427
+ return deepMerge(rawProp, (_a2 = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a2.at(index2));
5428
+ }
5429
+ );
5430
+ }
5431
+ const lastCollectionItem = scopes.findLast(
5432
+ (scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.CollectionItemScope
5433
+ );
5434
+ resolveVariableLayer(
5435
+ lastCollectionItem == null ? void 0 : lastCollectionItem.manager,
5436
+ lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
5437
+ lastCollectionItem == null ? void 0 : lastCollectionItem.value
5438
+ );
5439
+ const collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_c = entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _c._id) === variableId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, variableId);
5440
+ const currentValue = variableKey2 === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
4709
5441
  const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
4710
5442
  const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
4711
- const resultValue = required ? currentValue : currentValue ?? defaultValue;
5443
+ const resultValue = required ? currentValue : currentValue ?? collectionItemProp ?? defaultValue;
4712
5444
  if (isVariableLink$1(resultValue)) {
4713
5445
  return readVariable(resultValue);
4714
5446
  }
@@ -4725,7 +5457,7 @@ const useReadVariable = (variableKey) => {
4725
5457
  };
4726
5458
  };
4727
5459
  const useLayerCssVariable = (inputValue) => {
4728
- const { manager } = x$1(FragmentContext);
5460
+ const { manager } = x$2(FragmentContext);
4729
5461
  const isVariable = isVariableLink$1(inputValue);
4730
5462
  const [variableValue] = y(isVariable ? manager : null, inputValue, {
4731
5463
  selector: (graph) => pick(graph, "defaultValue", "_id")
@@ -4734,22 +5466,27 @@ const useLayerCssVariable = (inputValue) => {
4734
5466
  value: isVariable ? `var(--${variableValue == null ? void 0 : variableValue._id}, ${variableValue == null ? void 0 : variableValue.defaultValue})` : null
4735
5467
  };
4736
5468
  };
4737
- const useLayerValue = (layerKey, fieldKey, manager) => {
4738
- const resultManager = manager;
4739
- const key = layerKey;
5469
+ const useLayerValue = (layerKey, fieldKey, options2) => {
5470
+ const { manager: fragmentManager } = x$2(FragmentContext);
5471
+ const resultManager = (options2 == null ? void 0 : options2.manager) ?? fragmentManager;
5472
+ if (!resultManager) {
5473
+ return [null, noop, {}];
5474
+ }
5475
+ const key = keyOfEntity(layerKey);
4740
5476
  const [, updateLayerData] = y(resultManager, key, {
4741
- selector: (data) => data ? pick(data, fieldKey) : data
5477
+ // selector: (data) => (data ? pick(data, fieldKey) : data),
4742
5478
  });
4743
- const { layer, rawLayer } = useNormalizeLayer(key, resultManager);
5479
+ const { layer, rawLayer } = useNormalizeLayer(key, resultManager, options2);
4744
5480
  const rawValue = get(rawLayer, fieldKey);
4745
5481
  const layerValue = get(layer, fieldKey);
4746
5482
  const { value: variableValue } = useReadVariable(layerValue);
4747
5483
  const currentValue = variableValue ?? layerValue;
4748
5484
  const isInherit = isInheritField(resultManager, key, fieldKey);
4749
5485
  const isOverride = !isInherit && !isPartOfPrimary(resultManager, key);
4750
- const resetOverride = q$2(() => {
5486
+ const setter = layerFieldSetter(resultManager, key, fieldKey, currentValue);
5487
+ const resetOverride = q$1(() => {
4751
5488
  resultManager.mutate(
4752
- layerKey,
5489
+ key,
4753
5490
  (prev) => {
4754
5491
  const r2 = omit(prev, fieldKey);
4755
5492
  return r2;
@@ -4757,34 +5494,20 @@ const useLayerValue = (layerKey, fieldKey, manager) => {
4757
5494
  { replace: true }
4758
5495
  );
4759
5496
  }, [updateLayerData]);
4760
- const restore = q$2(
5497
+ const restore = q$1(
4761
5498
  (fallbackValue) => {
4762
5499
  var _a, _b, _c;
4763
- const tempValue = (_c = (_b = resultManager.resolve((_a = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a.temp)) == null ? void 0 : _b[layerKey]) == null ? void 0 : _c[fieldKey];
4764
- updateLayerData({ [fieldKey]: tempValue ?? fallbackValue });
5500
+ const tempValue = ((_c = (_b = resultManager.resolve((_a = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a.temp)) == null ? void 0 : _b[key]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
5501
+ updateLayerData({ [fieldKey]: tempValue });
5502
+ return tempValue;
4765
5503
  },
4766
5504
  [updateLayerData, resultManager]
4767
5505
  );
4768
- const updateValue = q$2(
4769
- (value, options2) => {
4770
- var _a, _b;
4771
- const { success, output } = parseLayerField(layer, fieldKey, value);
4772
- if (success) {
4773
- if (isVariableLink$1(value)) {
4774
- resultManager.mutate((_a = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a.temp, {
4775
- [layerKey]: {
4776
- [fieldKey]: currentValue
4777
- }
4778
- });
4779
- resultManager.resolve((_b = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _b.temp);
4780
- }
4781
- updateLayerData((prev) => {
4782
- set(prev, fieldKey, output);
4783
- return prev;
4784
- }, options2);
4785
- }
5506
+ const updateValue = q$1(
5507
+ (value, options22) => {
5508
+ setter(value, options22);
4786
5509
  },
4787
- [layer, fieldKey, updateLayerData, resultManager, layerKey, currentValue]
5510
+ [setter]
4788
5511
  );
4789
5512
  const { value: cssValue } = useLayerCssVariable(rawValue ?? layerValue);
4790
5513
  return [
@@ -4801,14 +5524,48 @@ const useLayerValue = (layerKey, fieldKey, manager) => {
4801
5524
  }
4802
5525
  ];
4803
5526
  };
5527
+ const processOptionalSize = (value, type) => {
5528
+ if (value === -1) return "";
5529
+ if (type === index.sizing.Fixed) return toPx(value);
5530
+ if (type === index.sizing.Relative) return `${value}%`;
5531
+ return "";
5532
+ };
5533
+ const useOptionalSize = (type, layerKey) => {
5534
+ const { manager: fragmentManager } = x$2(FragmentContext);
5535
+ const [value] = useLayerValue(layerKey, type, fragmentManager);
5536
+ const [valueType] = useLayerValue(layerKey, `${type}Type`, fragmentManager);
5537
+ return T$1(
5538
+ () => processOptionalSize(value, valueType),
5539
+ [valueType, value]
5540
+ );
5541
+ };
5542
+ const useLayerSize = (layerKey) => {
5543
+ const { manager } = x$2(FragmentContext);
5544
+ const minWidth = useOptionalSize("minWidth", layerKey);
5545
+ const minHeight = useOptionalSize("minHeight", layerKey);
5546
+ const maxWidth = useOptionalSize("maxWidth", layerKey);
5547
+ const maxHeight = useOptionalSize("maxHeight", layerKey);
5548
+ return {
5549
+ // width: widthCalc(widthValue),
5550
+ // height: heightCalc(heightValue),
5551
+ minWidth,
5552
+ minHeight,
5553
+ maxWidth,
5554
+ maxHeight
5555
+ };
5556
+ };
4804
5557
  const autoSizes = [index.sizing.Hug];
4805
5558
  const useLayerSizeValue = (layerKey, sizeType) => {
4806
- const { manager: fragmentManager } = x$1(FragmentContext);
4807
- const { layerKey: instanceLayerKey } = x$1(InstanceContext);
5559
+ const { manager: fragmentManager } = x$2(FragmentContext);
5560
+ const { layerKey: instanceLayerKey } = x$2(InstanceContext);
4808
5561
  const { isDocument } = useRenderTarget();
4809
5562
  const isTop = isTopLevel(fragmentManager, layerKey);
4810
5563
  const isPartOfInstance = !!instanceLayerKey;
4811
5564
  const layerParent = getParent(fragmentManager, layerKey);
5565
+ const { layer: normalizeParentLayer } = useNormalizeLayer(
5566
+ layerParent,
5567
+ fragmentManager
5568
+ );
4812
5569
  const layerNode = fragmentManager.resolve(layerKey);
4813
5570
  const [instanceType] = useLayerValue(
4814
5571
  instanceLayerKey,
@@ -4821,9 +5578,9 @@ const useLayerSizeValue = (layerKey, sizeType) => {
4821
5578
  fragmentManager
4822
5579
  );
4823
5580
  const growType = sizeType === "width" ? "horizontalGrow" : "verticalGrow";
4824
- return q$2(
5581
+ return q$1(
4825
5582
  (value) => {
4826
- if (isTop && isDocument && (layerParent == null ? void 0 : layerParent[growType]) === index.fragmentGrowingMode.fill) {
5583
+ if (isTop && isDocument && (normalizeParentLayer == null ? void 0 : normalizeParentLayer[growType]) === index.fragmentGrowingMode.fill) {
4827
5584
  return "100%";
4828
5585
  }
4829
5586
  if (isTop && isPartOfInstance && !autoSizes.includes(instanceType)) {
@@ -4852,67 +5609,63 @@ const useLayerSizeValue = (layerKey, sizeType) => {
4852
5609
  ]
4853
5610
  );
4854
5611
  };
4855
- const processOptionalSize = (value, type) => {
4856
- if (value === -1) return "";
4857
- if (type === index.sizing.Fixed) return toPx(value);
4858
- if (type === index.sizing.Relative) return `${value}%`;
4859
- return "";
4860
- };
4861
- const useOptionalSize = (type, layerKey) => {
4862
- const { manager: fragmentManager } = x$1(FragmentContext);
4863
- const [value] = useLayerValue(layerKey, type, fragmentManager);
4864
- const [valueType] = useLayerValue(layerKey, `${type}Type`, fragmentManager);
4865
- return T$1(
4866
- () => processOptionalSize(value, valueType),
4867
- [valueType, value]
4868
- );
4869
- };
4870
- const useLayerSize = (layerKey) => {
4871
- const { manager } = x$1(FragmentContext);
4872
- const [widthValue] = useLayerValue(layerKey, "width", manager);
4873
- const [heightValue] = useLayerValue(layerKey, "height", manager);
4874
- const widthCalc = useLayerSizeValue(layerKey, "width");
4875
- const heightCalc = useLayerSizeValue(layerKey, "height");
4876
- const minWidth = useOptionalSize("minWidth", layerKey);
4877
- const minHeight = useOptionalSize("minHeight", layerKey);
4878
- const maxWidth = useOptionalSize("maxWidth", layerKey);
4879
- const maxHeight = useOptionalSize("maxHeight", layerKey);
4880
- return {
4881
- width: widthCalc(widthValue),
4882
- height: heightCalc(heightValue),
4883
- minWidth,
4884
- minHeight,
4885
- maxWidth,
4886
- maxHeight
4887
- };
4888
- };
4889
5612
  const useLayerPosition = (layerKey) => {
4890
- const { layerKey: instanceLayerKey } = x$1(InstanceContext);
4891
- const { manager: fragmentManager } = x$1(FragmentContext);
5613
+ const { layerKey: instanceLayerKey } = x$2(InstanceContext);
5614
+ const { manager: fragmentManager } = x$2(FragmentContext);
4892
5615
  const { isDocument } = useRenderTarget();
4893
5616
  const isTop = isTopLevel(fragmentManager, layerKey);
5617
+ const [width] = useLayerValue(layerKey, "width");
5618
+ const [height] = useLayerValue(layerKey, "height");
5619
+ const widthCalc = useLayerSizeValue(layerKey, "width")(width);
5620
+ const heightCalc = useLayerSizeValue(layerKey, "height")(height);
5621
+ const [position] = useLayerValue(layerKey, "position");
5622
+ const [centerAnchorX] = useLayerValue(layerKey, "centerAnchorX");
5623
+ const [centerAnchorY] = useLayerValue(layerKey, "centerAnchorY");
5624
+ const [top] = useLayerValue(layerKey, "top");
5625
+ const [left] = useLayerValue(layerKey, "left");
5626
+ const [right] = useLayerValue(layerKey, "right");
5627
+ const [bottom] = useLayerValue(layerKey, "bottom");
4894
5628
  const skipPosition = isTop && isDocument || !!instanceLayerKey && isTop;
4895
- const [position] = useLayerValue(layerKey, "position", fragmentManager);
4896
- const [top] = useLayerValue(layerKey, "top", fragmentManager);
4897
- const [left] = useLayerValue(layerKey, "left", fragmentManager);
4898
- return T$1(
4899
- () => ({
4900
- position: skipPosition ? index.positionType.relative : position,
4901
- top: position === index.positionType.absolute && !skipPosition ? toPx(top) : null,
4902
- left: position === index.positionType.absolute && !skipPosition ? toPx(left) : null
4903
- }),
4904
- [skipPosition, position, top]
4905
- );
5629
+ if (isTop && !skipPosition) {
5630
+ return {
5631
+ position: index.positionType.absolute,
5632
+ top: toPx(top),
5633
+ left: toPx(left),
5634
+ width,
5635
+ height
5636
+ };
5637
+ }
5638
+ if (position === index.positionType.relative || skipPosition) {
5639
+ return {
5640
+ position: index.positionType.relative,
5641
+ width: widthCalc,
5642
+ height: heightCalc
5643
+ };
5644
+ }
5645
+ const hasConstrainX = isFiniteNumber(left) && isFiniteNumber(right);
5646
+ const hasConstrainY = isFiniteNumber(top) && isFiniteNumber(bottom);
5647
+ const hasAnyConstrainX = isFiniteNumber(left) || isFiniteNumber(right);
5648
+ const hasAnyConstrainY = isFiniteNumber(top) || isFiniteNumber(bottom);
5649
+ return {
5650
+ position,
5651
+ left: isFiniteNumber(left) ? toPx(left) : !isFiniteNumber(right) ? `${centerAnchorX * 100}%` : null,
5652
+ top: isFiniteNumber(top) ? toPx(top) : !isFiniteNumber(bottom) ? `${centerAnchorY * 100}%` : null,
5653
+ right: isFiniteNumber(right) ? toPx(right) : null,
5654
+ bottom: isFiniteNumber(bottom) ? toPx(bottom) : null,
5655
+ width: hasConstrainX ? null : widthCalc,
5656
+ height: hasConstrainY ? null : heightCalc,
5657
+ transform: !hasAnyConstrainX || !hasAnyConstrainY ? `translate3d(${!hasAnyConstrainX ? "-50%" : 0}, ${!hasAnyConstrainY ? "-50%" : 0}, 0px)` : null
5658
+ };
4906
5659
  };
4907
5660
  const useLayerBackground = (layerKey) => {
4908
- const { manager: fragmentManager } = x$1(FragmentContext);
5661
+ const { manager: fragmentManager } = x$2(FragmentContext);
4909
5662
  const [fillType] = useLayerValue(layerKey, "fillType", fragmentManager);
4910
5663
  const [, , { cssVariableValue: cssSolidFill }] = useLayerValue(
4911
5664
  layerKey,
4912
5665
  "solidFill",
4913
5666
  fragmentManager
4914
5667
  );
4915
- const [, , { cssVariableValue: cssImageFill }] = useLayerValue(
5668
+ const [imageFill, , { cssVariableValue: cssImageFill }] = useLayerValue(
4916
5669
  layerKey,
4917
5670
  "imageFill",
4918
5671
  fragmentManager
@@ -4930,7 +5683,7 @@ const useLayerBackground = (layerKey) => {
4930
5683
  }
4931
5684
  if (fillType === index.paintMode.Image && cssImageFill) {
4932
5685
  return {
4933
- background: `url(${cssImageFill})`,
5686
+ background: `url(${imageFill})`,
4934
5687
  backgroundSize: cssImageSize == null ? void 0 : cssImageSize.toLowerCase(),
4935
5688
  backgroundRepeat: "no-repeat"
4936
5689
  };
@@ -4941,7 +5694,7 @@ const useLayerBackground = (layerKey) => {
4941
5694
  }, [fillType, cssImageFill, cssSolidFill]);
4942
5695
  };
4943
5696
  const useLayerDisplay = (layerKey) => {
4944
- const { manager } = x$1(FragmentContext);
5697
+ const { manager } = x$2(FragmentContext);
4945
5698
  const [layerModeValue] = useLayerValue(layerKey, "layerMode", manager);
4946
5699
  const [visible] = useLayerValue(layerKey, "visible", manager);
4947
5700
  return T$1(() => {
@@ -4952,7 +5705,7 @@ const useLayerDisplay = (layerKey) => {
4952
5705
  }, [layerModeValue, visible]);
4953
5706
  };
4954
5707
  const useCalcLayerBorder = (layerKey) => {
4955
- const { manager: fragmentManager } = x$1(FragmentContext);
5708
+ const { manager: fragmentManager } = x$2(FragmentContext);
4956
5709
  const [borderTypeValue] = useLayerValue(
4957
5710
  layerKey,
4958
5711
  "borderType",
@@ -4989,7 +5742,7 @@ const useCalcLayerBorder = (layerKey) => {
4989
5742
  };
4990
5743
  };
4991
5744
  const useLayerBorder = (layerKey) => {
4992
- const { manager: fragmentManager } = x$1(FragmentContext);
5745
+ const { manager: fragmentManager } = x$2(FragmentContext);
4993
5746
  const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
4994
5747
  const [borderColor] = useLayerValue(layerKey, "borderColor", fragmentManager);
4995
5748
  const calcBorder = useCalcLayerBorder(layerKey);
@@ -4999,7 +5752,7 @@ const useLayerBorder = (layerKey) => {
4999
5752
  );
5000
5753
  };
5001
5754
  const useLayerLayout = (layerKey) => {
5002
- const { manager: fragmentManager } = x$1(FragmentContext);
5755
+ const { manager: fragmentManager } = x$2(FragmentContext);
5003
5756
  const [layerModeValue] = useLayerValue(
5004
5757
  layerKey,
5005
5758
  "layerMode",
@@ -5041,7 +5794,7 @@ const useLayerLayout = (layerKey) => {
5041
5794
  );
5042
5795
  };
5043
5796
  const useLayerTextStyles = (layerKey) => {
5044
- const { manager: fragmentManager } = x$1(FragmentContext);
5797
+ const { manager: fragmentManager } = x$2(FragmentContext);
5045
5798
  const [attributes] = useLayerValue(layerKey, "attributes", fragmentManager);
5046
5799
  const [color] = useLayerValue(layerKey, "attributes.color", fragmentManager);
5047
5800
  const cleanAttributes = omit(attributes, "_id", "_type");
@@ -5055,15 +5808,16 @@ const useLayerStyles = (layerKey) => {
5055
5808
  if (!layerKey) {
5056
5809
  throw new Error("Empty layer key");
5057
5810
  }
5058
- const { manager: fragmentManager } = x$1(FragmentContext);
5811
+ const { manager: fragmentManager } = x$2(FragmentContext);
5059
5812
  const [opacity] = useLayerValue(layerKey, "opacity", fragmentManager);
5060
5813
  const layerSize = useLayerSize(layerKey);
5061
- const { position, top, left } = useLayerPosition(layerKey);
5814
+ const position = useLayerPosition(layerKey);
5062
5815
  const display = useLayerDisplay(layerKey);
5063
5816
  const background = useLayerBackground(layerKey);
5064
5817
  const border = useLayerBorder(layerKey);
5065
5818
  const layout = useLayerLayout(layerKey);
5066
5819
  const [zIndex] = useLayerValue(layerKey, "zIndex", fragmentManager);
5820
+ const [rotate] = useLayerValue(layerKey, "rotate", fragmentManager);
5067
5821
  const [borderRadius] = useLayerValue(
5068
5822
  layerKey,
5069
5823
  "borderRadius",
@@ -5075,10 +5829,9 @@ const useLayerStyles = (layerKey) => {
5075
5829
  // ...(props ?? {}),
5076
5830
  ...border,
5077
5831
  ...background,
5078
- position,
5079
- top,
5080
- left,
5832
+ ...position,
5081
5833
  opacity,
5834
+ rotate: isValue(rotate) ? `${rotate}deg` : null,
5082
5835
  "border-radius": borderRadius,
5083
5836
  "white-space": whiteSpace2,
5084
5837
  "z-index": zIndex !== -1 ? zIndex : null,
@@ -5090,7 +5843,6 @@ const useLayerStyles = (layerKey) => {
5090
5843
  // ...cssOverride,
5091
5844
  };
5092
5845
  } catch (e2) {
5093
- console.debug(e2);
5094
5846
  return {};
5095
5847
  }
5096
5848
  };
@@ -5099,7 +5851,7 @@ const useFragmentProperties = (fragmentId) => {
5099
5851
  const { manager } = useFragmentManager(fragmentId);
5100
5852
  const [instanceFragment] = y(manager, (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root);
5101
5853
  return {
5102
- properties: (instanceFragment == null ? void 0 : instanceFragment.properties) ?? [],
5854
+ properties: ((instanceFragment == null ? void 0 : instanceFragment.properties) ?? []).map((manager == null ? void 0 : manager.resolve) ?? noop).filter((prop) => !(prop == null ? void 0 : prop.parent)).map(keyOfEntity),
5103
5855
  manager
5104
5856
  };
5105
5857
  };
@@ -5109,24 +5861,15 @@ const useHash = (layerKey, manager) => {
5109
5861
  const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
5110
5862
  return hashGenerator(overrideFrom ?? layerKey);
5111
5863
  };
5112
- const isVariableLink = (value) => {
5113
- var _a;
5114
- return isLink(value) && ((_a = value == null ? void 0 : value.split(":")) == null ? void 0 : _a.at(0)) === index.nodes.Variable;
5115
- };
5116
- const isLink = (value) => {
5117
- var _a, _b;
5118
- return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
5119
- };
5120
5864
  const useInstanceProps = (instanceProps) => {
5121
5865
  const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
5122
5866
  const { manager: loadedManager } = useFragmentManager(
5123
5867
  isTopInstance ? instanceProps == null ? void 0 : instanceProps.fragmentId : null
5124
5868
  );
5125
- const { manager: fragmentContextManager } = x$1(FragmentContext);
5869
+ const { manager: fragmentContextManager } = x$2(FragmentContext);
5126
5870
  const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(instanceProps == null ? void 0 : instanceProps.fragmentId);
5127
5871
  const definitionsData = S(innerFragmentManager, definitions);
5128
5872
  const fragmentManager = isTopInstance ? loadedManager : fragmentContextManager;
5129
- useReadVariable(null);
5130
5873
  const [instanceLayer] = y(fragmentManager, instanceProps.layerKey);
5131
5874
  const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
5132
5875
  const mergedProps = T$1(() => {
@@ -5146,30 +5889,59 @@ const useInstanceProps = (instanceProps) => {
5146
5889
  }
5147
5890
  return omit(base, "_type", "_id");
5148
5891
  }, [isTopInstance, fragmentManager, instanceLayerProps, definitionsData]);
5149
- const drilledProps = Object.values(mergedProps).filter(isVariableLink);
5150
- const resolveDrilledProps = S(fragmentManager, drilledProps);
5151
- const resultProps = T$1(() => {
5152
- const props = { ...mergedProps };
5153
- return props;
5154
- }, [resolveDrilledProps, mergedProps]);
5155
- const cssProps = Object.entries(resultProps).reduce((acc, [key, value]) => {
5156
- var _a;
5157
- if (isVariableLink(value)) {
5158
- const nestedVariableId = (_a = fragmentManager.entityOfKey(value)) == null ? void 0 : _a._id;
5159
- value = `var(--${nestedVariableId})`;
5160
- }
5161
- acc[`--${key}`] = value;
5162
- return acc;
5163
- }, {});
5164
5892
  return {
5165
- props: resultProps,
5166
- cssProps
5893
+ props: mergedProps,
5894
+ cssProps: getCssVariables(mergedProps)
5167
5895
  };
5168
5896
  };
5897
+ const useLayerInteractions = (layerKey, options2) => {
5898
+ const pause = (options2 == null ? void 0 : options2.pauseInteractions) ?? false;
5899
+ const { manager: globalManager } = useGlobalManager();
5900
+ const { manager: fragmentManager } = x$2(FragmentContext);
5901
+ const [interactions2] = useLayerValue(
5902
+ layerKey,
5903
+ "interactions",
5904
+ fragmentManager
5905
+ );
5906
+ const { readVariable } = useReadVariable();
5907
+ const fireEvent = q$1(
5908
+ (eventLink) => {
5909
+ var _a, _b, _c, _d;
5910
+ const event = fragmentManager.resolve(eventLink);
5911
+ const { value: eventValue } = readVariable(eventLink);
5912
+ if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.code)) {
5913
+ (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, eventValue == null ? void 0 : eventValue.code);
5914
+ }
5915
+ if ((event == null ? void 0 : event.mode) === index.eventMode.tracker && eventValue) {
5916
+ (_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
5917
+ }
5918
+ if ((event == null ? void 0 : event.mode) === index.eventMode.callback && typeof eventValue === "function") {
5919
+ eventValue();
5920
+ }
5921
+ },
5922
+ [globalManager, fragmentManager]
5923
+ );
5924
+ y$2(() => {
5925
+ if (!pause && Array.isArray(interactions2)) {
5926
+ interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.appear).map((el) => el.event).forEach(fireEvent);
5927
+ }
5928
+ }, [pause]);
5929
+ return T$1(() => {
5930
+ if (!pause && !interactions2 || !Array.isArray(interactions2)) return {};
5931
+ if (pause) return {};
5932
+ const clickEvents = interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.click).map((el) => el.event);
5933
+ return {
5934
+ onClick: () => {
5935
+ clickEvents.map(fireEvent);
5936
+ }
5937
+ };
5938
+ }, [interactions2, fireEvent, pause]);
5939
+ };
5169
5940
  const useInstance = (instanceProps) => {
5170
- const { manager: parentManager } = x$1(FragmentContext);
5941
+ const { manager: parentManager } = x$2(FragmentContext);
5171
5942
  const [instanceLayer] = y(parentManager, instanceProps.layerKey);
5172
5943
  const styles2 = useLayerStyles(instanceProps.layerKey);
5944
+ const events = useLayerInteractions(instanceProps.layerKey, instanceProps);
5173
5945
  const { manager: resultGlobalManager } = useGlobalManager(
5174
5946
  instanceProps == null ? void 0 : instanceProps.globalManager
5175
5947
  );
@@ -5180,6 +5952,7 @@ const useInstance = (instanceProps) => {
5180
5952
  return {
5181
5953
  hash,
5182
5954
  styles: styles2,
5955
+ events,
5183
5956
  definitions,
5184
5957
  props,
5185
5958
  cssProps,
@@ -5196,7 +5969,7 @@ const Scope = ({
5196
5969
  layerKey
5197
5970
  }) => {
5198
5971
  var _a, _b;
5199
- const currentScope = x$1(ScopeContext) ?? [];
5972
+ const currentScope = x$2(ScopeContext) ?? [];
5200
5973
  const nextScope = [...currentScope, value];
5201
5974
  (_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.registerScope) == null ? void 0 : _b.call(_a, layerKey, nextScope);
5202
5975
  return /* @__PURE__ */ u(ScopeContext.Provider, { value: nextScope, children });
@@ -5270,20 +6043,20 @@ const Instance = (props) => {
5270
6043
  return "globalManager" in props ? /* @__PURE__ */ u(GlobalManager, { value: props.globalManager, children: /* @__PURE__ */ u(InstanceInitial, { ...props }) }) : /* @__PURE__ */ u(InstanceInitial, { ...props });
5271
6044
  };
5272
6045
  const useLayerChildren = (layerKey, customManager) => {
5273
- const { manager: fragmentManager } = x$1(FragmentContext);
6046
+ const { manager: fragmentManager } = x$2(FragmentContext);
5274
6047
  const [layerData] = y(customManager ?? fragmentManager, layerKey, {
5275
6048
  selector: (data) => pick(data, "children")
5276
6049
  });
5277
6050
  return (layerData == null ? void 0 : layerData.children) ?? [];
5278
6051
  };
5279
6052
  const useFragmentChildren = (fragmentId) => {
5280
- const { layerKey: instanceLayerKey } = x$1(InstanceContext);
6053
+ const { layerKey: instanceLayerKey } = x$2(InstanceContext);
5281
6054
  const { manager, fragmentLayerKey } = useFragmentManager(fragmentId);
5282
6055
  const children = useLayerChildren(fragmentLayerKey, manager);
5283
6056
  const { isDocument } = useRenderTarget();
5284
6057
  const [resizeChildren, setResizeChildren] = d(null);
5285
6058
  A();
5286
- const setRef = q$2(
6059
+ const setRef = q$1(
5287
6060
  (node) => {
5288
6061
  },
5289
6062
  [isDocument, instanceLayerKey, manager, children]
@@ -5302,56 +6075,26 @@ const useFragmentChildren = (fragmentId) => {
5302
6075
  setRef
5303
6076
  };
5304
6077
  };
5305
- const getStylesheetKey = (fragmentKey) => {
5306
- const isLink2 = G(fragmentKey);
5307
- if (isLink2) {
5308
- const [type, id] = fragmentKey.split(":");
5309
- return `stylesheet-${id}`;
5310
- }
5311
- return `stylesheet-${fragmentKey ?? "unknown"}`;
5312
- };
5313
- function useInjectedStyle() {
5314
- const { manager } = x$1(FragmentContext);
5315
- const injectStyle = () => {
5316
- var _a, _b;
5317
- const styles2 = (_b = (_a = manager == null ? void 0 : manager.$styleSheet.extract()) == null ? void 0 : _a.at(0)) == null ? void 0 : _b.styles;
5318
- if (isBrowser_default && styles2) {
5319
- const stylesheetKey = getStylesheetKey(manager == null ? void 0 : manager.key);
5320
- if (document.getElementById(stylesheetKey)) {
5321
- const el = document.getElementById(stylesheetKey);
5322
- if (el) el.remove();
5323
- }
5324
- const style = document.createElement("style");
5325
- style.id = stylesheetKey;
5326
- style.textContent = styles2.join("");
5327
- document.head.appendChild(style);
5328
- }
5329
- };
5330
- return {
5331
- injectStyle
5332
- };
5333
- }
5334
6078
  const useStyleSheet = (manager) => {
5335
- const { injectStyle } = useInjectedStyle();
5336
- const addLayerStyle = q$2(
6079
+ var _a, _b;
6080
+ const addLayerStyle = q$1(
5337
6081
  (layerKey, styles2, layer) => {
5338
- var _a, _b;
6082
+ var _a2, _b2;
5339
6083
  if (!!(manager == null ? void 0 : manager.$styleSheet) && manager && "addStyle" in (manager == null ? void 0 : manager.$styleSheet)) {
5340
- (_b = (_a = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a.addStyle) == null ? void 0 : _b.call(_a, layerKey, styles2, layer);
5341
- if (isBrowser_default) {
5342
- injectStyle();
5343
- }
6084
+ (_b2 = (_a2 = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a2.addStyle) == null ? void 0 : _b2.call(_a2, layerKey, styles2, layer);
5344
6085
  }
5345
6086
  },
5346
6087
  [manager]
5347
6088
  );
5348
6089
  return {
5349
- addLayerStyle
6090
+ addLayerStyle,
6091
+ mount: ((_a = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a.mount) ?? noop,
6092
+ unmount: ((_b = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _b.unmount) ?? noop
5350
6093
  };
5351
6094
  };
5352
6095
  const useFragment = (fragmentId, globalManager) => {
5353
6096
  var _a, _b;
5354
- const instanceContext = x$1(InstanceContext);
6097
+ const instanceContext = x$2(InstanceContext);
5355
6098
  const fragmentContext = useFragmentManager(fragmentId);
5356
6099
  const { isDocument } = useRenderTarget();
5357
6100
  const { setRef, children, isResize } = useFragmentChildren(fragmentId);
@@ -5360,9 +6103,11 @@ const useFragment = (fragmentId, globalManager) => {
5360
6103
  fragmentContext.manager
5361
6104
  );
5362
6105
  const { properties: definitions } = useFragmentProperties(fragmentId);
5363
- const scopes = x$1(ScopeContext);
6106
+ const scopes = x$2(ScopeContext);
5364
6107
  !(scopes == null ? void 0 : scopes.length);
5365
- const { addLayerStyle } = useStyleSheet(fragmentContext.manager);
6108
+ const { addLayerStyle, mount, unmount } = useStyleSheet(
6109
+ fragmentContext.manager
6110
+ );
5366
6111
  if (fragmentContext.manager) {
5367
6112
  addLayerStyle(
5368
6113
  fragmentContext.fragmentLayerKey,
@@ -5374,7 +6119,13 @@ const useFragment = (fragmentId, globalManager) => {
5374
6119
  (_a = fragmentContext.manager) == null ? void 0 : _a.resolve(fragmentContext.fragmentLayerKey),
5375
6120
  (_b = fragmentContext.manager) == null ? void 0 : _b.key
5376
6121
  );
6122
+ mount();
5377
6123
  }
6124
+ y$2(() => {
6125
+ return () => {
6126
+ unmount();
6127
+ };
6128
+ }, []);
5378
6129
  return {
5379
6130
  hash,
5380
6131
  isDocument,
@@ -5391,41 +6142,8 @@ const fragment = "_fragment_1c708_1";
5391
6142
  const styles = {
5392
6143
  fragment
5393
6144
  };
5394
- const useLayerInteractions = (layerKey) => {
5395
- const { manager: globalManager } = useGlobalManager();
5396
- const { manager: fragmentManager } = x$1(FragmentContext);
5397
- const [interactions2] = useLayerValue(
5398
- layerKey,
5399
- "interactions",
5400
- fragmentManager
5401
- );
5402
- const { readVariable } = useReadVariable();
5403
- const fireEvent = q$2(
5404
- (eventLink) => {
5405
- var _a, _b;
5406
- const event = fragmentManager.resolve(eventLink);
5407
- const { value: eventValue } = readVariable(eventLink);
5408
- if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.code)) {
5409
- (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, eventValue == null ? void 0 : eventValue.code);
5410
- }
5411
- if ((event == null ? void 0 : event.mode) === index.eventMode.callback && typeof eventValue === "function") {
5412
- eventValue();
5413
- }
5414
- },
5415
- [globalManager, fragmentManager]
5416
- );
5417
- return T$1(() => {
5418
- if (!interactions2 || !Array.isArray(interactions2)) return {};
5419
- const clickEvents = interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.click).map((el) => el.event);
5420
- return {
5421
- onClick: () => {
5422
- clickEvents.map(fireEvent);
5423
- }
5424
- };
5425
- }, [interactions2, fireEvent]);
5426
- };
5427
6145
  const useLayerLink = (layerKey) => {
5428
- const { manager: fragmentManager } = x$1(FragmentContext);
6146
+ const { manager: fragmentManager } = x$2(FragmentContext);
5429
6147
  const [href] = useLayerValue(layerKey, "href", fragmentManager);
5430
6148
  const [hrefNewTab] = useLayerValue(layerKey, "hrefNewTab", fragmentManager);
5431
6149
  const isLink2 = isValue(href) && typeof href === "string" && !!(href == null ? void 0 : href.length);
@@ -5447,13 +6165,13 @@ const useLayerLink = (layerKey) => {
5447
6165
  };
5448
6166
  };
5449
6167
  const useFrame = (layerKey, options2) => {
5450
- const { manager: fragmentManager } = x$1(FragmentContext);
6168
+ const { manager: fragmentManager } = x$2(FragmentContext);
5451
6169
  const layer = fragmentManager.entityOfKey(layerKey);
5452
6170
  const styles2 = useLayerStyles(layerKey);
5453
6171
  const children = useLayerChildren(layerKey);
5454
6172
  const hash = useHash(layerKey, fragmentManager);
5455
6173
  const { addLayerStyle } = useStyleSheet(fragmentManager);
5456
- const events = useLayerInteractions(layerKey);
6174
+ const events = useLayerInteractions(layerKey, options2);
5457
6175
  const link = useLayerLink(layerKey);
5458
6176
  {
5459
6177
  addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
@@ -5473,44 +6191,48 @@ const text = "_text_1liuf_1";
5473
6191
  const cssStyles = {
5474
6192
  text
5475
6193
  };
5476
- const allowAttributes = [
5477
- "fontSize",
5478
- "fontWeight",
5479
- "color",
5480
- "lineHeight",
5481
- "letterSpacing",
5482
- "textTransform",
5483
- "textDecoration",
5484
- "textAlign"
5485
- ];
5486
- const wrapTextInParagraphWithAttributes = (text2, attributes) => {
5487
- if (text2.startsWith("<p")) return text2;
5488
- const style = Object.entries(attributes).filter(
5489
- ([key, value]) => isValue(value) && allowAttributes.includes(key) && typeof value === "string" && !!value.length
5490
- ).map(([key, value]) => `${toKebabCase(key)}: ${value}`).join("; ");
5491
- return `<p style="${style}">${text2}</p>`;
5492
- };
6194
+ function extractVariablesFromHtml(html) {
6195
+ if (!html) return [];
6196
+ const regex = /<span(?=\s)(?=(?:[^>]*?\s)?class="[^"]*variable[^"]*")(?=(?:[^>]*?\s)?data-type="mention")(?=(?:[^>]*?\s)?data-id="([^"]+)")[^>]*>.*?<\/span>/gi;
6197
+ const mentions = [];
6198
+ let match;
6199
+ while ((match = regex.exec(html)) !== null) {
6200
+ mentions.push({
6201
+ fullMatch: match[0],
6202
+ dataId: match[1],
6203
+ variableKey: keyOfEntity({
6204
+ _type: index.nodes.Variable,
6205
+ _id: match[1]
6206
+ }),
6207
+ position: match.index
6208
+ });
6209
+ }
6210
+ return mentions;
6211
+ }
5493
6212
  const useTextContent = (layerKey, manager) => {
5494
- const { manager: fragmentManager } = x$1(FragmentContext);
6213
+ const { manager: fragmentManager } = x$2(FragmentContext);
5495
6214
  const [content, , contentInfo] = useLayerValue(
5496
6215
  layerKey,
5497
6216
  "content",
5498
6217
  fragmentManager
5499
6218
  );
5500
- const [attributes] = useLayerValue(layerKey, "attributes", fragmentManager);
5501
- const resultAttributes = {
5502
- ...attributes,
5503
- color: (attributes == null ? void 0 : attributes.color) ?? "rgb(0, 0, 0)"
5504
- };
5505
- return T$1(() => {
5506
- if (typeof content === "string" && isValue(attributes)) {
5507
- return wrapTextInParagraphWithAttributes(content, resultAttributes);
5508
- }
5509
- return content;
5510
- }, [contentInfo, content, attributes]);
6219
+ const variables = extractVariablesFromHtml(content);
6220
+ const { readVariable } = useReadVariable();
6221
+ S(
6222
+ fragmentManager,
6223
+ variables.map((variable) => variable.variableKey)
6224
+ );
6225
+ let nextContent = content;
6226
+ variables.forEach((variable) => {
6227
+ nextContent = nextContent.replace(
6228
+ variable.fullMatch,
6229
+ readVariable(variable.variableKey).value
6230
+ );
6231
+ });
6232
+ return nextContent;
5511
6233
  };
5512
6234
  const useTextAttributes = (layerKey, options2) => {
5513
- const { manager: fragmentManager } = x$1(FragmentContext);
6235
+ const { manager: fragmentManager } = x$2(FragmentContext);
5514
6236
  const styles2 = useLayerStyles(layerKey);
5515
6237
  const content = useTextContent(layerKey);
5516
6238
  const hash = useHash(layerKey, fragmentManager);