ueca-react 2.0.1 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1453 +1,3 @@
1
- import * as $ from "react";
2
- import Le from "react";
3
- import * as d from "mobx";
4
- import * as B from "mobx-react";
5
- var L = { exports: {} }, j = {};
6
- /**
7
- * @license React
8
- * react-jsx-runtime.production.js
9
- *
10
- * Copyright (c) Meta Platforms, Inc. and affiliates.
11
- *
12
- * This source code is licensed under the MIT license found in the
13
- * LICENSE file in the root directory of this source tree.
14
- */
15
- var be;
16
- function We() {
17
- if (be) return j;
18
- be = 1;
19
- var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
20
- function t(i, r, o) {
21
- var c = null;
22
- if (o !== void 0 && (c = "" + o), r.key !== void 0 && (c = "" + r.key), "key" in r) {
23
- o = {};
24
- for (var a in r)
25
- a !== "key" && (o[a] = r[a]);
26
- } else o = r;
27
- return r = o.ref, {
28
- $$typeof: n,
29
- type: i,
30
- key: c,
31
- ref: r !== void 0 ? r : null,
32
- props: o
33
- };
34
- }
35
- return j.Fragment = e, j.jsx = t, j.jsxs = t, j;
36
- }
37
- var S = {};
38
- /**
39
- * @license React
40
- * react-jsx-runtime.development.js
41
- *
42
- * Copyright (c) Meta Platforms, Inc. and affiliates.
43
- *
44
- * This source code is licensed under the MIT license found in the
45
- * LICENSE file in the root directory of this source tree.
46
- */
47
- var $e;
48
- function Ve() {
49
- return $e || ($e = 1, process.env.NODE_ENV !== "production" && (function() {
50
- function n(s) {
51
- if (s == null) return null;
52
- if (typeof s == "function")
53
- return s.$$typeof === De ? null : s.displayName || s.name || null;
54
- if (typeof s == "string") return s;
55
- switch (s) {
56
- case H:
57
- return "Fragment";
58
- case ke:
59
- return "Profiler";
60
- case Pe:
61
- return "StrictMode";
62
- case je:
63
- return "Suspense";
64
- case Se:
65
- return "SuspenseList";
66
- case xe:
67
- return "Activity";
68
- }
69
- if (typeof s == "object")
70
- switch (typeof s.tag == "number" && console.error(
71
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
72
- ), s.$$typeof) {
73
- case Oe:
74
- return "Portal";
75
- case Ie:
76
- return (s.displayName || "Context") + ".Provider";
77
- case Te:
78
- return (s._context.displayName || "Context") + ".Consumer";
79
- case Be:
80
- var l = s.render;
81
- return s = s.displayName, s || (s = l.displayName || l.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
82
- case Ae:
83
- return l = s.displayName || null, l !== null ? l : n(s.type) || "Memo";
84
- case de:
85
- l = s._payload, s = s._init;
86
- try {
87
- return n(s(l));
88
- } catch {
89
- }
90
- }
91
- return null;
92
- }
93
- function e(s) {
94
- return "" + s;
95
- }
96
- function t(s) {
97
- try {
98
- e(s);
99
- var l = !1;
100
- } catch {
101
- l = !0;
102
- }
103
- if (l) {
104
- l = console;
105
- var _ = l.error, m = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
106
- return _.call(
107
- l,
108
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
109
- m
110
- ), e(s);
111
- }
112
- }
113
- function i(s) {
114
- if (s === H) return "<>";
115
- if (typeof s == "object" && s !== null && s.$$typeof === de)
116
- return "<...>";
117
- try {
118
- var l = n(s);
119
- return l ? "<" + l + ">" : "<...>";
120
- } catch {
121
- return "<...>";
122
- }
123
- }
124
- function r() {
125
- var s = K.A;
126
- return s === null ? null : s.getOwner();
127
- }
128
- function o() {
129
- return Error("react-stack-top-frame");
130
- }
131
- function c(s) {
132
- if (ue.call(s, "key")) {
133
- var l = Object.getOwnPropertyDescriptor(s, "key").get;
134
- if (l && l.isReactWarning) return !1;
135
- }
136
- return s.key !== void 0;
137
- }
138
- function a(s, l) {
139
- function _() {
140
- _e || (_e = !0, console.error(
141
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
142
- l
143
- ));
144
- }
145
- _.isReactWarning = !0, Object.defineProperty(s, "key", {
146
- get: _,
147
- configurable: !0
148
- });
149
- }
150
- function u() {
151
- var s = n(this.type);
152
- return fe[s] || (fe[s] = !0, console.error(
153
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
154
- )), s = this.props.ref, s !== void 0 ? s : null;
155
- }
156
- function R(s, l, _, m, M, v, Q, ee) {
157
- return _ = v.ref, s = {
158
- $$typeof: le,
159
- type: s,
160
- key: l,
161
- props: v,
162
- _owner: M
163
- }, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(s, "ref", {
164
- enumerable: !1,
165
- get: u
166
- }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
167
- configurable: !1,
168
- enumerable: !1,
169
- writable: !0,
170
- value: 0
171
- }), Object.defineProperty(s, "_debugInfo", {
172
- configurable: !1,
173
- enumerable: !1,
174
- writable: !0,
175
- value: null
176
- }), Object.defineProperty(s, "_debugStack", {
177
- configurable: !1,
178
- enumerable: !1,
179
- writable: !0,
180
- value: Q
181
- }), Object.defineProperty(s, "_debugTask", {
182
- configurable: !1,
183
- enumerable: !1,
184
- writable: !0,
185
- value: ee
186
- }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
187
- }
188
- function ce(s, l, _, m, M, v, Q, ee) {
189
- var g = l.children;
190
- if (g !== void 0)
191
- if (m)
192
- if (Ne(g)) {
193
- for (m = 0; m < g.length; m++)
194
- he(g[m]);
195
- Object.freeze && Object.freeze(g);
196
- } else
197
- console.error(
198
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
199
- );
200
- else he(g);
201
- if (ue.call(l, "key")) {
202
- g = n(s);
203
- var P = Object.keys(l).filter(function(Fe) {
204
- return Fe !== "key";
205
- });
206
- m = 0 < P.length ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}", pe[g + m] || (P = 0 < P.length ? "{" + P.join(": ..., ") + ": ...}" : "{}", console.error(
207
- `A props object containing a "key" prop is being spread into JSX:
208
- let props = %s;
209
- <%s {...props} />
210
- React keys must be passed directly to JSX without using spread:
211
- let props = %s;
212
- <%s key={someKey} {...props} />`,
213
- m,
214
- g,
215
- P,
216
- g
217
- ), pe[g + m] = !0);
218
- }
219
- if (g = null, _ !== void 0 && (t(_), g = "" + _), c(l) && (t(l.key), g = "" + l.key), "key" in l) {
220
- _ = {};
221
- for (var te in l)
222
- te !== "key" && (_[te] = l[te]);
223
- } else _ = l;
224
- return g && a(
225
- _,
226
- typeof s == "function" ? s.displayName || s.name || "Unknown" : s
227
- ), R(
228
- s,
229
- g,
230
- v,
231
- M,
232
- r(),
233
- _,
234
- Q,
235
- ee
236
- );
237
- }
238
- function he(s) {
239
- typeof s == "object" && s !== null && s.$$typeof === le && s._store && (s._store.validated = 1);
240
- }
241
- var F = Le, le = Symbol.for("react.transitional.element"), Oe = Symbol.for("react.portal"), H = Symbol.for("react.fragment"), Pe = Symbol.for("react.strict_mode"), ke = Symbol.for("react.profiler"), Te = Symbol.for("react.consumer"), Ie = Symbol.for("react.context"), Be = Symbol.for("react.forward_ref"), je = Symbol.for("react.suspense"), Se = Symbol.for("react.suspense_list"), Ae = Symbol.for("react.memo"), de = Symbol.for("react.lazy"), xe = Symbol.for("react.activity"), De = Symbol.for("react.client.reference"), K = F.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ue = Object.prototype.hasOwnProperty, Ne = Array.isArray, Z = console.createTask ? console.createTask : function() {
242
- return null;
243
- };
244
- F = {
245
- react_stack_bottom_frame: function(s) {
246
- return s();
247
- }
248
- };
249
- var _e, fe = {}, me = F.react_stack_bottom_frame.bind(
250
- F,
251
- o
252
- )(), ge = Z(i(o)), pe = {};
253
- S.Fragment = H, S.jsx = function(s, l, _, m, M) {
254
- var v = 1e4 > K.recentlyCreatedOwnerStacks++;
255
- return ce(
256
- s,
257
- l,
258
- _,
259
- !1,
260
- m,
261
- M,
262
- v ? Error("react-stack-top-frame") : me,
263
- v ? Z(i(s)) : ge
264
- );
265
- }, S.jsxs = function(s, l, _, m, M) {
266
- var v = 1e4 > K.recentlyCreatedOwnerStacks++;
267
- return ce(
268
- s,
269
- l,
270
- _,
271
- !0,
272
- m,
273
- M,
274
- v ? Error("react-stack-top-frame") : me,
275
- v ? Z(i(s)) : ge
276
- );
277
- };
278
- })()), S;
279
- }
280
- var ve;
281
- function ze() {
282
- return ve || (ve = 1, process.env.NODE_ENV === "production" ? L.exports = We() : L.exports = Ve()), L.exports;
283
- }
284
- var p = ze();
285
- function lt(n) {
286
- if (n)
287
- return JSON.parse(JSON.stringify(n));
288
- }
289
- function b(n) {
290
- return typeof n > "u";
291
- }
292
- function Ye(n) {
293
- return n === null;
294
- }
295
- function X(n) {
296
- return typeof n == "string";
297
- }
298
- function dt(n) {
299
- return typeof n == "number";
300
- }
301
- function ut(n) {
302
- return typeof n == "boolean";
303
- }
304
- function T(n) {
305
- return Array.isArray(n);
306
- }
307
- function f(n) {
308
- return typeof n == "function";
309
- }
310
- function O(n) {
311
- return n !== null && typeof n == "object";
312
- }
313
- function Ue(n) {
314
- return n instanceof Map;
315
- }
316
- function ie(n) {
317
- return typeof n == "symbol";
318
- }
319
- function ye(n, e) {
320
- if (n === e)
321
- return !0;
322
- if (O(n) && O(e)) {
323
- const t = Object.keys(n), i = Object.keys(e);
324
- if (t.length !== i.length)
325
- return !1;
326
- for (const r of t)
327
- if (!i.includes(r) || !ye(n[r], e[r]))
328
- return !1;
329
- return !0;
330
- }
331
- return !1;
332
- }
333
- function k(n, e) {
334
- return n.filter((t) => e.includes(t));
335
- }
336
- function _t(n) {
337
- return n.condition ? /* @__PURE__ */ p.jsx(p.Fragment, { children: oe(n.children) }) : null;
338
- }
339
- function oe(n) {
340
- if (f(n)) {
341
- const e = B.observer(n);
342
- return /* @__PURE__ */ p.jsx(e, {});
343
- }
344
- if (N(n)) {
345
- const e = n;
346
- return /* @__PURE__ */ p.jsx(e, {});
347
- }
348
- return n;
349
- }
350
- const ft = B.observer((n) => n.render === !1 ? null : /* @__PURE__ */ p.jsx(p.Fragment, { children: oe(n.node) }));
351
- function x(n, e = "Invalid condition") {
352
- if (n)
353
- throw Error(e);
354
- }
355
- function mt(n, e) {
356
- if (!n)
357
- throw Error(e || "Invalid condition");
358
- }
359
- async function gt(n) {
360
- await new Promise((e) => setTimeout(e, n));
361
- }
362
- function pt(n) {
363
- return f(n) ? B.observer(n) : d.observable(n);
364
- }
365
- function C(n) {
366
- return !!(n && O(n) && Object.keys(n).length === 2 && f(n[0]) && (f(n[1]) || b(n[1])));
367
- }
368
- function qe(n) {
369
- return C(n) && b(n[1]);
370
- }
371
- function D(n) {
372
- return C(n) && f(n[1]);
373
- }
374
- function Je(n, e) {
375
- return [
376
- n ? () => {
377
- let i;
378
- try {
379
- i = n();
380
- } catch (r) {
381
- h(r.message, "error");
382
- }
383
- return i;
384
- } : void 0,
385
- e ? (i) => {
386
- try {
387
- e(i);
388
- } catch (r) {
389
- h(r.message, "error");
390
- }
391
- } : void 0
392
- ];
393
- }
394
- function Xe(n, e) {
395
- return [
396
- () => {
397
- let i;
398
- try {
399
- i = n();
400
- } catch (r) {
401
- h(r.message, "error");
402
- }
403
- return i || h(`Attempt to get bound property "${e.toString()}" of undefined`, "warn"), i ? i[e] : void 0;
404
- },
405
- (i) => {
406
- let r;
407
- try {
408
- r = n();
409
- } catch (o) {
410
- h(o.message, "error");
411
- }
412
- r ? r[e] = i : h(`Attempt to set bound property "${e.toString()}" of undefined`, "warn");
413
- }
414
- ];
415
- }
416
- function we(n, e) {
417
- if (f(n) && (f(e) || e === void 0))
418
- return Je(n, e);
419
- if (f(n) && X(e))
420
- return Xe(n, e);
421
- throw new Error("Invalid arguments for bind()");
422
- }
423
- class G {
424
- _target;
425
- _name;
426
- constructor(e, t) {
427
- this._target = e, this._name = t;
428
- }
429
- }
430
- const W = { Deep: 0, Shallow: 1, Reference: 2 };
431
- class w extends G {
432
- _observableKind = W.Deep;
433
- //@MobX.observable
434
- _value = void 0;
435
- //@MobX.observable.shallow
436
- _valueShallow = void 0;
437
- //@MobX.observable.ref
438
- _valueRef = void 0;
439
- //@MobX.observable.ref
440
- _forceReactionToggle = void 0;
441
- _onValueChangeReactionDisposer;
442
- _structBindingReactionDisposer;
443
- _paramsBindingReactionDisposer;
444
- constructor(e, t) {
445
- super(e, t), d.makeObservable(this, {
446
- _value: d.observable,
447
- _valueShallow: d.observable.shallow,
448
- _valueRef: d.observable.ref,
449
- _forceReactionToggle: d.observable.ref,
450
- _forceReaction: d.action
451
- });
452
- }
453
- initBindings() {
454
- this._setupOnValueChangeReaction(), this._setupStructBindingReaction(), this._setupParamsBindingReaction();
455
- }
456
- deinitBindings() {
457
- this._onValueChangeReactionDisposer?.(), this._onValueChangeReactionDisposer = void 0, this._structBindingReactionDisposer?.(), this._structBindingReactionDisposer = void 0, this._paramsBindingReactionDisposer?.(), this._paramsBindingReactionDisposer = void 0;
458
- }
459
- get value() {
460
- return this._getObservable();
461
- }
462
- set value(e) {
463
- if (C(e))
464
- throw Error("Attempt to assign binding as a value");
465
- d.runInAction(() => {
466
- this._paramsBinding || this._structBinding ? this._modelIsNew() ? this._setValue(e) : (this._structBinding && D(this._structBinding) && (this._structBinding[1]?.(e), e = this._structBinding[0]?.()), this._paramsBinding && D(this._paramsBinding) && this._paramsBinding[1]?.(e)) : this._setValue(e);
467
- });
468
- }
469
- _setValue(e) {
470
- let t = this._getObservable();
471
- T(t) && (t = t.slice());
472
- const i = this._target;
473
- if (!w._isEqual(e, t)) {
474
- if (!this._modelIsNew() && !i.changeNotifyDisabled()) {
475
- const r = this._name;
476
- this._structOnPropChanging && (e = this._structOnPropChanging(r, e, t), x(e instanceof Promise, "Asynchronous OnPropChanging event is not allowed"));
477
- let o = this._getStructOnChangingEvent(r);
478
- if (o && (e = o(e, t), x(e instanceof Promise, "Asynchronous OnChanging<Prop> event is not allowed")), this._customOnPropChanging && (e = this._customOnPropChanging(r, e, t), x(e instanceof Promise, "Asynchronous OnPropChanging event is not allowed")), o = this._getCustomOnChangingEvent(r), o && (e = o(e, t), x(e instanceof Promise, "Asynchronous OnChanging<Prop> event is not allowed")), w._isEqual(e, t)) {
479
- setTimeout(() => this._forceReaction());
480
- return;
481
- }
482
- }
483
- this._setObservable(e);
484
- }
485
- }
486
- _setupStructBindingReaction() {
487
- if (this._structBindingReactionDisposer?.(), this._structBindingReactionDisposer = void 0, !this._structBinding)
488
- return;
489
- const e = this._name, t = this._target, i = (r) => {
490
- try {
491
- r = this._structBinding[0](), this._paramsBindingReactionDisposer && D(this._paramsBinding) && (this._paramsBinding[1](r), r = this._paramsBinding[0]()), this._setValue(r);
492
- } catch (o) {
493
- h(`Struct binding error: ${e}.set(${A(r)}) model=#${t.birthMark()} path=${t.htmlId()}
494
- ${o}`, "error");
495
- }
496
- };
497
- this._structBindingReactionDisposer = d.reaction(
498
- () => {
499
- let r = this._structBinding[0]();
500
- return T(r) && (r = r.slice()), [r, this._forceReactionToggle];
501
- },
502
- ([r]) => i(r),
503
- {
504
- name: `Struct binding model=#${t.birthMark()} path=${t.htmlId()}.${e}`,
505
- fireImmediately: !0
506
- }
507
- );
508
- }
509
- _setupParamsBindingReaction() {
510
- if (this._paramsBindingReactionDisposer?.(), this._paramsBindingReactionDisposer = void 0, !this._paramsBinding)
511
- return;
512
- const e = this._name, t = this._target, i = (r) => {
513
- try {
514
- this._structBindingReactionDisposer && D(this._structBinding) && (this._structBinding[1](r), r = this._structBinding[0]()), this._setValue(r);
515
- } catch (o) {
516
- h(`Param binding error: ${e}.set(${A(r)}) model=#${t.birthMark()} path=${t.htmlId()}${o}`, "error");
517
- }
518
- };
519
- this._paramsBindingReactionDisposer = d.reaction(
520
- () => {
521
- let r = this._paramsBinding[0]();
522
- return T(r) && (r = r.slice()), [r, this._forceReactionToggle];
523
- },
524
- ([r]) => i(r),
525
- {
526
- name: `Param binding model=#${t.birthMark()} path=${t.htmlId()}.${e}`,
527
- fireImmediately: !0
528
- }
529
- );
530
- }
531
- _setupOnValueChangeReaction() {
532
- this._onValueChangeReactionDisposer?.(), this._onValueChangeReactionDisposer = void 0;
533
- const e = this._name, t = this._target;
534
- this._onValueChangeReactionDisposer = d.reaction(
535
- () => {
536
- let i = this._getObservable();
537
- return T(i) && (i = i.slice()), [i, this._forceReactionToggle];
538
- },
539
- ([i], [r]) => {
540
- try {
541
- if (this._modelIsNew())
542
- throw Error("???");
543
- if (w._isEqual(i, r))
544
- return;
545
- h(`change prop model=#${t.birthMark()} path=${t.htmlId()}[${e}] ${A(r)}➝${A(i)}`), t.changeNotifyDisabled() || (this._structOnPropChange?.(e, i, r), this._getStructOnChangeEvent(e)?.(i, r), this._customOnPropChange?.(e, i, r), this._getCustomOnChangeEvent(e)?.(i, r));
546
- } catch (o) {
547
- h(`Prop change error: ${e}.set(${A(i)}) model=#${t.birthMark()} path=${t.htmlId()}
548
- ${o}`, "error");
549
- }
550
- },
551
- { name: `Prop change model=#${t.birthMark()} path=${t.htmlId()}.${e}` }
552
- );
553
- }
554
- get _structBinding() {
555
- const e = this._name, t = this._target;
556
- if (C(t.$.__struct.props?.[e]))
557
- return t.$.__struct.props[e];
558
- }
559
- get _paramsBinding() {
560
- const e = this._name, t = this._target;
561
- if (C(t.$.__params?.[e]))
562
- return t.$.__params[e];
563
- }
564
- get _structOnPropChanging() {
565
- return this._target.$.__struct.events?.onPropChanging;
566
- }
567
- get _structOnPropChange() {
568
- return this._target.$.__struct.events?.onPropChange;
569
- }
570
- _getStructOnChangingEvent(e) {
571
- return this._target.$.__struct.events?.[`onChanging${V(e)}`];
572
- }
573
- _getStructOnChangeEvent(e) {
574
- return this._target.$.__struct.events?.[`onChange${V(e)}`];
575
- }
576
- get _customOnPropChanging() {
577
- const e = this._target.onPropChanging;
578
- if (e instanceof E)
579
- return e.event;
580
- }
581
- get _customOnPropChange() {
582
- const e = this._target.onPropChange;
583
- if (e instanceof E)
584
- return e.event;
585
- }
586
- _getCustomOnChangingEvent(e) {
587
- const t = this._target[`onChanging${V(e)}`];
588
- if (t instanceof E)
589
- return t.event;
590
- }
591
- _getCustomOnChangeEvent(e) {
592
- const t = this._target[`onChange${V(e)}`];
593
- if (t instanceof E)
594
- return t.event;
595
- }
596
- _modelIsNew() {
597
- return !this._target.$.__status.initPhase;
598
- }
599
- // @MobX.action
600
- _forceReaction() {
601
- this._forceReactionToggle = !this._forceReactionToggle;
602
- }
603
- _getObservable() {
604
- return [this._value, this._valueShallow, this._valueRef, this._forceReactionToggle][this._observableKind];
605
- }
606
- _setObservable(e) {
607
- this._getObservable(), d.transaction(() => {
608
- const t = this._prepareValueToObserve(e, this._name);
609
- t.observable === "ref" ? (this._value = void 0, this._valueShallow = void 0, this._valueRef = t.value, this._observableKind = W.Reference) : t.observable === "shallow" ? (this._value = void 0, this._valueRef = void 0, this._valueShallow = t.value, this._observableKind = W.Shallow) : (this._valueShallow = void 0, this._valueRef = void 0, this._value = t.value, this._observableKind = W.Deep);
610
- });
611
- }
612
- _prepareObjectToObserve(e) {
613
- if (d.isObservable(e)) return { value: e, observable: "ref" };
614
- const t = Object.keys(e).reduce((r, o) => {
615
- if (d.isObservableProp(e, o)) return r;
616
- const c = this._prepareValueToObserve(e[o], o);
617
- return e[o] = c.value, c.observable === "ref" ? r[o] = d.observable.ref : c.observable === "shallow" ? r[o] = d.observable.shallow : r[o] = d.observable.deep, r;
618
- }, {});
619
- return { value: d.observable(e, t), observable: "ref" };
620
- }
621
- _prepareValueToObserve(e, t) {
622
- if (U(e))
623
- return { value: e, observable: "ref" };
624
- if (T(e) || Ue(e))
625
- return { value: e, observable: "shallow" };
626
- if (at(e) || Y(e) || N(e))
627
- return { value: e, observable: "ref" };
628
- if (f(e)) {
629
- if (ae(t) && !w._isWrappedView(e)) {
630
- const i = B.observer(e), r = (o) => /* @__PURE__ */ p.jsx(i, { ...o });
631
- r.__ueca_ViewFn = e, e = r;
632
- }
633
- return { value: e, observable: "ref" };
634
- } else if (O(e))
635
- return this._prepareObjectToObserve(e);
636
- return { value: e, observable: "deep" };
637
- }
638
- static _isEqual(e, t) {
639
- return Y(e) || Y(t) || N(e) || N(t) || U(e) || U(t) ? e === t : f(e) || f(t) ? (w._isWrappedView(e) && (e = e.__ueca_ViewFn), w._isWrappedView(t) && (t = t.__ueca_ViewFn), e === t) : ye(e, t);
640
- }
641
- static _isWrappedView(e) {
642
- return f(e) && Reflect.has(e, "__ueca_ViewFn");
643
- }
644
- }
645
- class re extends G {
646
- //@MobX.observable.ref
647
- child;
648
- constructor(e, t, i) {
649
- super(e, t), d.makeObservable(this, {
650
- child: d.observable.ref
651
- }), this.child = i;
652
- }
653
- }
654
- class se extends G {
655
- method;
656
- constructor(e, t, i) {
657
- if (super(e, t), ae(t)) {
658
- const r = B.observer(i);
659
- this.method = (o) => /* @__PURE__ */ p.jsx(r, { ...o });
660
- } else
661
- this.method = i;
662
- }
663
- }
664
- class E extends G {
665
- // @MobX.observable.ref
666
- _event;
667
- constructor(e, t) {
668
- super(e, t), d.makeObservable(this, {
669
- _event: d.observable.ref
670
- });
671
- }
672
- //@MobX.computed ??? This was not used. TODO: delete it?
673
- get event() {
674
- const e = this._target.$.__struct.events?.[this._name];
675
- return e && !Ce(this._name, this._target.$.__struct) && !Ge(this._name, this._target.$.__struct) ? async (...i) => {
676
- const r = this._target.$.__status.baseResult;
677
- try {
678
- let o = await e(...i);
679
- return this._event && (this._target.$.__status.baseResult = o, o = await this._event(...i)), o;
680
- } finally {
681
- this._target.$.__status.baseResult = r;
682
- }
683
- } : this._event;
684
- }
685
- // TODO: Why does this code break MobX reactions?
686
- // public get event() {
687
- // const structEvent = (this._target.$.__struct.events as AnyObject)?.[this._name] as AnyMethod;
688
- // if (structEvent && !isPropChangingEvent(this._name, this._target.$.__struct)) {
689
- // const chainedEvent = async (...args: unknown[]) => {
690
- // const baseResult = this._target.$.__status.baseResult;
691
- // try {
692
- // let res: unknown;
693
- // await MobX.runInAction(async () => {
694
- // res = await structEvent(...args);
695
- // });
696
- // this._target.$.__status.baseResult = res;
697
- // if (this._event) {
698
- // this._target.$.__status.baseResult = res;
699
- // await MobX.runInAction(async () => {
700
- // res = await this._event(...args);
701
- // });
702
- // }
703
- // return res;
704
- // } finally {
705
- // this._target.$.__status.baseResult = baseResult;
706
- // }
707
- // }
708
- // return chainedEvent;
709
- // }
710
- // return this._event;
711
- // };
712
- set event(e) {
713
- this._event = e;
714
- }
715
- }
716
- function ae(n) {
717
- return n?.endsWith("View");
718
- }
719
- function Ce(n, e) {
720
- if (n === "onPropChanging")
721
- return !0;
722
- if (!n.startsWith("onChanging"))
723
- return !1;
724
- let t = n.substring(10);
725
- return t = t[0].toLowerCase() + t.slice(1), !!Reflect.has(e.props, t);
726
- }
727
- function Ge(n, e) {
728
- if (n === "onPropChange")
729
- return !0;
730
- if (!n.startsWith("onChange"))
731
- return !1;
732
- let t = n.substring(8);
733
- return t = t[0].toLowerCase() + t.slice(1), !!Reflect.has(e.props, t);
734
- }
735
- class He {
736
- _registry;
737
- name;
738
- constructor(e) {
739
- this.name = e, this._registry = /* @__PURE__ */ new Map();
740
- }
741
- subscribe(e) {
742
- const t = e.$.__struct.messages;
743
- t && Object.keys(t).forEach((i) => {
744
- let r = this._registry.get(i);
745
- r || (r = /* @__PURE__ */ new Set(), this._registry.set(i, r)), r.add(e);
746
- });
747
- }
748
- unsubscribe(e) {
749
- const t = e.$.__struct.messages;
750
- if (!t)
751
- return;
752
- const i = [];
753
- Object.keys(t).forEach((r) => {
754
- const o = this._registry.get(r);
755
- o && (o.delete(e), o.size || i.push(r));
756
- }), i.forEach((r) => {
757
- this._registry.delete(r);
758
- });
759
- }
760
- async broadcast(e, t, i) {
761
- const r = this._registry.get(t);
762
- if (!r || !r.size)
763
- return h(`MessageBus (${this.name}): no subscribers for message "${t}"`, "warn"), [];
764
- const o = [];
765
- for (const c of r) {
766
- if (!(b(e) || Ye(e) || e === "")) if (X(e)) {
767
- if (e && c.fullId() != e)
768
- continue;
769
- } else if (e instanceof RegExp) {
770
- if (!e.test(c.fullId()))
771
- continue;
772
- } else
773
- break;
774
- const a = c.$.__struct.messages?.[t];
775
- if (a) {
776
- const u = a(i);
777
- o.push(u);
778
- }
779
- }
780
- return await Promise.all(o);
781
- }
782
- async castTo(e, t, i) {
783
- const r = await this.broadcast(e, t, i);
784
- return r?.length > 1 && h(`MessageBus (${this.name}): Ambiguous unicast by message "${t}"`, "warn"), r ? r[0] : void 0;
785
- }
786
- async unicast(e, t) {
787
- return await this.castTo("", e, t);
788
- }
789
- /**
790
- * @deprecated Use the `unicast` function instead.
791
- */
792
- async getAsync(e, t) {
793
- return await this.unicast(e, t);
794
- }
795
- /**
796
- * @deprecated Use the `unicast` function instead.
797
- */
798
- async postAsync(e, t) {
799
- return await this.unicast(e, t);
800
- }
801
- }
802
- const Ke = "messagebus.post";
803
- function Ze() {
804
- const n = new He("Default Message Bus");
805
- return window.addEventListener(Ke, e), n;
806
- function e(t) {
807
- n.broadcast(null, t.detail.message, t.detail.params);
808
- }
809
- }
810
- const Re = Ze(), Qe = $.createContext(Re);
811
- function bt() {
812
- return Re;
813
- }
814
- function et(n) {
815
- return tt($.useContext(Qe), n);
816
- }
817
- function tt(n, e) {
818
- return $.useEffect(
819
- () => (n.subscribe(e), () => n.unsubscribe(e)),
820
- // it never changes bus or model
821
- // eslint-disable-next-line react-hooks/exhaustive-deps
822
- []
823
- ), n;
824
- }
825
- d._getGlobalState().allowStateChanges = !0;
826
- class q {
827
- // Add index signature to allow dynamic property assignment
828
- _privateMembers;
829
- _birthMark;
830
- _disableOnChangeCount = 0;
831
- _bus;
832
- // @MobX.observable
833
- _renderToggle;
834
- constructor(e) {
835
- d.makeObservable(this, {
836
- _renderToggle: d.observable,
837
- View: d.computed,
838
- BaseView: d.computed,
839
- clearModelCache: d.action,
840
- invalidateView: d.action,
841
- _assignParams: d.action,
842
- _constr: d.action,
843
- _init: d.action,
844
- _mount: d.action,
845
- _unmount: d.action,
846
- _deinit: d.action,
847
- _draw: d.action,
848
- _erase: d.action,
849
- _deleteMember: d.action
850
- }), q._checkUniqueNamesInStructSections(e), this._privateMembers = {
851
- __status: {
852
- initPhase: void 0,
853
- mountPhase: void 0,
854
- cached: !1,
855
- initCount: 0,
856
- mountCount: 0,
857
- baseResult: void 0
858
- },
859
- __struct: void 0,
860
- __params: void 0,
861
- __owner: void 0,
862
- __dynamicChildrenIds: [],
863
- __staticChildrenCache: void 0,
864
- __proxy: void 0,
865
- __settersInProgress: [],
866
- __assignParams: void 0,
867
- __initializeModel: void 0
868
- }, e = { ...e }, this._birthMark = Math.round(Math.random() * 1e6).toString(), this.$.__struct = e, this.$.__dynamicChildrenIds = [], this.$.__staticChildrenCache = [], this.$.__settersInProgress = [], this.$.__assignParams = this._assignParams.bind(this), this.$.__initializeModel = this._initializeModel.bind(this);
869
- for (const t in e.props) {
870
- if (t.startsWith("__")) {
871
- this[t] = e.props[t], delete e.props[t];
872
- continue;
873
- }
874
- const i = new w(this, t), r = e.props[t];
875
- f(r) && (e.props[t] = we(r, void 0)), C(e.props[t]) ? ae(t) ? i.value = z : i.value = void 0 : i.value = e.props[t], this[t] = i;
876
- }
877
- for (const t in e.children) {
878
- const i = new re(this, t, e.children[t]);
879
- i.child.$.__owner = this, i.child.disableOnChange(), i.child.id = t, i.child.enableOnChange(), this[t] = i;
880
- }
881
- for (const t in e.methods) {
882
- const i = e.methods[t];
883
- this[t] = new se(this, t, i);
884
- }
885
- for (const t in e.events) {
886
- if (t.startsWith("onChanging") || t.startsWith("onChange") || t === "onPropChanging" || t === "onPropChange")
887
- return;
888
- this[t] = new E(this, t);
889
- }
890
- this._renderToggle = void 0;
891
- }
892
- get $() {
893
- return this._privateMembers;
894
- }
895
- get bus() {
896
- return this._bus;
897
- }
898
- // @MobX.computed
899
- get View() {
900
- return this._view();
901
- }
902
- // @MobX.computed
903
- get BaseView() {
904
- return this._view(!0);
905
- }
906
- disableOnChange() {
907
- this._disableOnChangeCount++;
908
- }
909
- enableOnChange() {
910
- if (this._disableOnChangeCount === 0)
911
- throw new Error("enableOnChange() requires disableOnChange() pair");
912
- this._disableOnChangeCount--;
913
- }
914
- changeNotifyDisabled() {
915
- return this._disableOnChangeCount > 0;
916
- }
917
- birthMark() {
918
- return this._birthMark;
919
- }
920
- fullId() {
921
- let e = "";
922
- return this.$.__owner && (e = this.$.__owner.fullId() + "."), e + (this.id?.value ?? "<empty>");
923
- }
924
- //@computed
925
- htmlId() {
926
- const e = this.fullId();
927
- return e === "<empty>" ? void 0 : window.hashHtmlId ? q._getHashCode(e) : e;
928
- }
929
- //@computed
930
- getChildrenModels(e) {
931
- const t = [];
932
- if (!e || e === "static")
933
- for (const i in this.$.__struct.children)
934
- t.push(this.$.__proxy[i]);
935
- return (!e || e === "dynamic") && this.$.__dynamicChildrenIds.forEach((i) => t.push(this.$.__proxy[i])), t;
936
- }
937
- //@MobX.action
938
- clearModelCache() {
939
- for (const e of this.$.__dynamicChildrenIds) {
940
- const t = this.$.__proxy[e];
941
- if (t && (h(`uncache dynamic model=#${t.birthMark()} path=${t.htmlId()} cache=#${this.birthMark()}`), this._deleteMember(e), t.$.__status.cached = !1, t.$.__staticChildrenCache.length)) {
942
- for (const i of t.$.__staticChildrenCache) {
943
- if (!i) return;
944
- h(`uncache static model=#${i.birthMark()} path=${i.htmlId()} cache=#${t.birthMark}`), i.$.__status.cached = !1;
945
- }
946
- for (const i of t.$.__staticChildrenCache) {
947
- if (!i) return;
948
- i.clearModelCache();
949
- }
950
- this.$.__staticChildrenCache.splice(0);
951
- }
952
- }
953
- this.$.__dynamicChildrenIds.splice(0);
954
- }
955
- //@MobX.action
956
- invalidateView() {
957
- this._renderToggle = !this._renderToggle;
958
- }
959
- _view(e = !1) {
960
- const t = B.observer(((i) => {
961
- const r = !b(this._renderToggle) && (b(i?.render) || i.render), o = r ? this.$.__proxy : void 0;
962
- r && this.$.__status.mountCount++, $.useEffect(() => (r && b(this.$.__status.mountPhase) && this._mount(), () => {
963
- r && this.$.__status.mountCount--, this.$.__status.mountCount || this._unmount();
964
- }));
965
- const c = (a) => {
966
- const u = e ? o?.$.__struct.BaseView : o?.$.__struct.View;
967
- return $.useLayoutEffect(() => {
968
- if (a && u)
969
- return this._draw(), () => {
970
- this._erase();
971
- };
972
- }), a && u ? (h(`render view model=#${o?.birthMark()} path=${o?.htmlId()}`), u(i)) : null;
973
- };
974
- return r ? /* @__PURE__ */ p.jsx(nt, { componentModel: o, children: /* @__PURE__ */ p.jsx(Me.Provider, { value: ct(o), children: c(!0) }) }) : c(!1);
975
- }).bind(this));
976
- return ((i) => /* @__PURE__ */ p.jsx(t, { ...i }));
977
- }
978
- //@MobX.action // TODO: remove the attribute?
979
- _assignParams(e) {
980
- e = { ...e }, delete e.cacheable;
981
- for (const t in this.$.__struct.props)
982
- if (f(e[t]) && Reflect.has(e, t)) {
983
- const i = e[t];
984
- e[t] = we(i, void 0);
985
- }
986
- this.$.__params = e;
987
- for (const t in e)
988
- t === "constr" || t === "init" || t === "deinit" || t === "mount" || t === "unmount" || t === "draw" || t === "erase" || C(e[t]) || (this.$.__proxy[t] = e[t]);
989
- }
990
- _initBindings() {
991
- for (const e in this.$.__struct.props)
992
- this[e]?.initBindings();
993
- }
994
- _deInitBindings() {
995
- for (const e in this.$.__struct.props)
996
- this[e]?.deinitBindings();
997
- }
998
- //@MobX.action
999
- async _constr() {
1000
- this.$.__status.initPhase = "constructing";
1001
- try {
1002
- const e = this.$.__proxy;
1003
- h(`constr model=#${e.birthMark()} path=${e.htmlId()}`), await this.$.__struct.constr?.(this.$.__proxy), await this.$.__params?.constr?.(this.$.__proxy);
1004
- } finally {
1005
- this.$.__status.initPhase = "constructed";
1006
- }
1007
- }
1008
- //@MobX.action
1009
- async _init(e) {
1010
- if (this.$.__status.initPhase || await this._constr(), this._assignParams(e), this.$.__status.initPhase === "constructed") {
1011
- this.$.__status.initPhase = "initializing";
1012
- try {
1013
- const t = this.$.__proxy;
1014
- h(`init model=#${t.birthMark()} path=${t.htmlId()}`), this._initBindings(), await this.$.__struct.init?.(t), await this.$.__params?.init?.(t);
1015
- } finally {
1016
- this.$.__status.initPhase = "initialized";
1017
- try {
1018
- this.$.__status.mountPhase === "init-mount" && await this._mount();
1019
- } finally {
1020
- b(this._renderToggle) && this.invalidateView();
1021
- }
1022
- }
1023
- }
1024
- }
1025
- //@MobX.action
1026
- async _mount() {
1027
- if (this.$.__status.mountPhase === "mounted")
1028
- return;
1029
- if (this.$.__status.initPhase != "initialized") {
1030
- this.$.__status.mountPhase = "init-mount";
1031
- return;
1032
- }
1033
- this.$.__status.mountPhase = "mounting";
1034
- const e = this.$.__proxy;
1035
- h(`mount model=#${e.birthMark()} path=${e.htmlId()}`), await this.$.__struct.mount?.(e), await this.$.__params?.mount?.(e), this.$.__status.mountPhase = "mounted";
1036
- }
1037
- //@MobX.action
1038
- async _unmount() {
1039
- if (this.$.__status.mountPhase == "mounted") {
1040
- this.$.__status.mountPhase = "unmounting";
1041
- try {
1042
- const e = this.$.__proxy;
1043
- h(`unmount model=#${e.birthMark()} path=${e.htmlId()}`), await this.$.__params?.unmount?.(e), await this.$.__struct.unmount?.(e);
1044
- } finally {
1045
- this.$.__status.mountPhase = void 0, this.$.__status.initPhase === "unmount-deinit" && (this.$.__status.initPhase = "initialized", await this._deinit());
1046
- }
1047
- }
1048
- }
1049
- //@MobX.action
1050
- async _deinit() {
1051
- if (this.$.__status.initCount--, !this.$.__status.initCount && this.$.__status.initPhase === "initialized") {
1052
- if (this.$.__status.mountPhase === "mounted" || this.$.__status.mountPhase === "unmounting") {
1053
- this.$.__status.initCount++, this.$.__status.initPhase = "unmount-deinit";
1054
- return;
1055
- }
1056
- this.$.__status.initPhase = "deinitializing";
1057
- try {
1058
- const e = this.$.__proxy;
1059
- h(`deinit model=#${e.birthMark()} path=${e.htmlId()}`), this._renderToggle = void 0, await this.$.__params?.deinit?.(e), await this.$.__struct.deinit?.(e), this._deInitBindings();
1060
- } finally {
1061
- this.$.__status.initPhase = "constructed";
1062
- }
1063
- }
1064
- }
1065
- //@MobX.action
1066
- async _draw() {
1067
- const e = this.$.__proxy;
1068
- await this.$.__struct.draw?.(e), await this.$.__params?.draw?.(e);
1069
- }
1070
- //@MobX.action
1071
- async _erase() {
1072
- const e = this.$.__proxy;
1073
- await this.$.__params?.erase?.(e), await this.$.__struct.erase?.(e);
1074
- }
1075
- //@MobX.action
1076
- _deleteMember(e) {
1077
- let t = !1;
1078
- return Reflect.has(this, e) && (delete this[e], t = !0), Reflect.has(this, e) && (delete this[e], t = !0), t;
1079
- }
1080
- _initializeModel(e) {
1081
- this.$.__status.initCount++, this._bus = et(this), $.useEffect(() => (this._init(e), () => {
1082
- this._deinit();
1083
- }));
1084
- }
1085
- static _getHashCode(e) {
1086
- const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
1087
- let i = "";
1088
- const r = Array.from(e).reduce((o, c) => Math.imul(31, o) + c.charCodeAt(0) | 0, 0);
1089
- for (let o = 0; o < 32; o += 6)
1090
- i += t.charAt(r >>> o & 63);
1091
- return i;
1092
- }
1093
- static _checkUniqueNamesInStructSections(e) {
1094
- const t = k(Object.keys(e.props ?? {}), Object.keys(e.children ?? {}));
1095
- if (t.concat(k(Object.keys(e.props ?? {}), Object.keys(e.methods ?? {}))), t.concat(k(Object.keys(e.props ?? {}), Object.keys(e.events ?? {}))), t.concat(k(Object.keys(e.children ?? {}), Object.keys(e.methods ?? {}))), t.concat(k(Object.keys(e.children ?? {}), Object.keys(e.events ?? {}))), t.concat(k(Object.keys(e.methods ?? {}), Object.keys(e.events ?? {}))), t.length > 0)
1096
- throw new Error(`The component structure${e.props?.id ? " " + e.props.id + " " : ""}contains not unique members: ${t}`);
1097
- }
1098
- }
1099
- class nt extends $.PureComponent {
1100
- _retryStarted = !1;
1101
- _retriesLeft;
1102
- constructor(e) {
1103
- super(e), this.state = { renderingFailed: !1 }, this._retriesLeft = e.maxRenderRetries, b(this._retriesLeft) && (this._retriesLeft = 1);
1104
- }
1105
- static getDerivedStateFromError(e) {
1106
- return { renderingFailed: !0, error: e };
1107
- }
1108
- componentDidCatch(e) {
1109
- this._retriesLeft === 0 && (this.props.componentModel && h(`JSX Rendering Error model=#${this.props.componentModel.birthMark()} path=${this.props.componentModel.htmlId()}
1110
- ${e}`, "error"), this.props?.onRenderError?.(e));
1111
- }
1112
- render() {
1113
- if (!this.state.renderingFailed)
1114
- return /* @__PURE__ */ p.jsx(p.Fragment, { children: oe(this.props.children) });
1115
- let e = null;
1116
- if (this._retriesLeft > 0)
1117
- this._retryStarted || (setTimeout(() => {
1118
- this._retriesLeft--, this._retryStarted = !1, this.setState({ renderingFailed: !1 });
1119
- }), this._retryStarted = !0);
1120
- else if (y.traceLog) {
1121
- const t = {
1122
- display: "flex",
1123
- placeContent: "center",
1124
- fontSize: "large",
1125
- minWidth: "fit-content",
1126
- minHeight: "fit-content",
1127
- overflow: "overlay",
1128
- backgroundColor: "red",
1129
- color: "yellow"
1130
- };
1131
- e = /* @__PURE__ */ p.jsx("div", { style: t, title: this._getErrorTitleInfo(), children: "⚠" });
1132
- }
1133
- return e;
1134
- }
1135
- _getErrorTitleInfo() {
1136
- let e = "";
1137
- return this.props.description && (e = `${e}• Description
1138
- ${this.props.description}
1139
-
1140
- `), this.props.componentModel && (e = `${e}• UECA Component
1141
- model: #${this.props.componentModel.birthMark()}
1142
- path: ${this.props.componentModel.htmlId()}
1143
-
1144
- `), this.state.error && (e = `${e}• Error Details
1145
- ${this.state.error?.message}`), `JSX RENDERING ERROR
1146
-
1147
- ${e}`;
1148
- }
1149
- }
1150
- class J {
1151
- constructor(e) {
1152
- const t = new q(e), i = new Proxy(t, { get: J._get, set: J._set });
1153
- return t.$.__proxy = i, i;
1154
- }
1155
- static _get(e, t) {
1156
- if (ie(t) && t === rt || t === I)
1157
- return e[I];
1158
- let i = e[t];
1159
- return i instanceof w ? i = i.value : i instanceof se ? i = i.method : i instanceof E ? i = i.event : i instanceof re ? i = i.child : f(i) && (i = i.bind(e)), i;
1160
- }
1161
- static _set(e, t, i) {
1162
- if (ie(t) || t === I)
1163
- return !1;
1164
- if (e.$.__settersInProgress.indexOf(t) !== -1)
1165
- return !0;
1166
- e.$.__settersInProgress.push(t);
1167
- try {
1168
- if (e[t] instanceof w)
1169
- e[t].value = i;
1170
- else if (e[t] instanceof E)
1171
- b(i) || f(i) ? e[t].event = i : console.error(`Attempt to assign non-function value to event "${t}"`);
1172
- else if (f(i)) {
1173
- const r = new E(e, t);
1174
- r.event = i, e[t] = r;
1175
- } else {
1176
- if (e[t] instanceof se || e[t] instanceof re)
1177
- return !1;
1178
- e[t] = i;
1179
- }
1180
- } finally {
1181
- e.$.__settersInProgress.pop();
1182
- }
1183
- return !0;
1184
- }
1185
- }
1186
- function it(n, e) {
1187
- const t = new J(n);
1188
- return t.$.__assignParams(e), t;
1189
- }
1190
- const I = "$", rt = Symbol(I), z = () => /* @__PURE__ */ p.jsx(p.Fragment, {});
1191
- function $t(n, e, t, i) {
1192
- i || (i = st);
1193
- const r = i(ot(n, e, () => r), t);
1194
- return r;
1195
- }
1196
- function st(n, e) {
1197
- const t = Ee();
1198
- let i = !0;
1199
- const [r] = $.useState(() => (i = !1, o()));
1200
- if (!r)
1201
- throw Error("BUG: Component model is undefined");
1202
- return i && h(`use React cached model=#${r.birthMark()} path=${r.htmlId()} cache=React.useState()`), r.$.__initializeModel(e), r;
1203
- function o() {
1204
- const a = c();
1205
- let u = t?.staticModelsTrap?.getNextCachedModel();
1206
- const R = u === null;
1207
- return u ? t.staticModelsTrap && u != t.staticModelsTrap.owner && (h(`use cached static model=#${u.birthMark()} path=${u.htmlId()} cache=#${t.staticModelsTrap.owner?.birthMark()}`), u.cacheable && h(`remove cached static model=#${u.birthMark()} path=${u.htmlId()} cache=#${t.staticModelsTrap.owner?.birthMark()}`)) : (x(!n.props), n.props.cacheable = a, u = it(n, e ?? {}), h(`create model=#${u.birthMark()} path=${u.htmlId()}`), u.fullId() || h("Set a default id in the struct of the component model hook", "warn"), t?.staticModelsTrap && a && (t.staticModelsTrap.cacheModel(a ? u : null, R), R && h(`recache static model=#${u.birthMark()} path=${u.htmlId()} cache=#${t.staticModelsTrap.owner?.birthMark()}`))), u;
1208
- }
1209
- function c() {
1210
- if (y.modelCacheMode == "no-cache")
1211
- return !1;
1212
- let a;
1213
- return b(e?.cacheable) || (C(e.cacheable) ? h('Bindings are not permitted for the property "cacheable"', "error") : a = e.cacheable), b(a) && !b(n.props?.cacheable) && (C(n.props.cacheable) ? h('Bindings are not permitted for the property "cacheable"', "error") : a = n.props.cacheable), b(a) && y.modelCacheMode == "auto-cache" && (a = !0), !!a;
1214
- }
1215
- }
1216
- function ot(n, e, t) {
1217
- e || (e = {});
1218
- const i = {
1219
- props: {
1220
- ...n.props,
1221
- ...e.props
1222
- },
1223
- children: {
1224
- ...n.children,
1225
- ...e.children
1226
- },
1227
- // TODO: Chain the methods
1228
- methods: {
1229
- ...n.methods,
1230
- ...e.methods
1231
- },
1232
- // TODO: Chain the events
1233
- events: {
1234
- ...n.events,
1235
- ...e.events
1236
- },
1237
- messages: {
1238
- ...n.messages,
1239
- ...e.messages
1240
- },
1241
- View: e.View && e.View !== z ? e.View : n.View ? n.View : z,
1242
- BaseView: n.View ?? z
1243
- };
1244
- if (n.methods && e.methods)
1245
- for (const r in i.methods)
1246
- Reflect.has(n.methods, r) && Reflect.has(e.methods, r) && (i.methods[r] = async (...o) => {
1247
- const c = t(), a = c.$.__status.baseResult;
1248
- try {
1249
- c.$.__status.baseResult = await n.methods[r](...o), await e.methods[r](...o);
1250
- } finally {
1251
- c.$.__status.baseResult = a;
1252
- }
1253
- });
1254
- if (n.events && e.events) {
1255
- for (const r in i.events)
1256
- if (Reflect.has(n.events, r) && Reflect.has(e.events, r)) {
1257
- let o;
1258
- r === "onPropChanging" ? o = (c, a, u) => (a = n.events[r](c, a, u), a = e.events[r](c, a, u), a) : Ce(r, i) ? o = (c, a) => (c = n.events[r](c, a), c = e.events[r](c, a), c) : o = async (...c) => {
1259
- const a = t(), u = a.$.__status.baseResult;
1260
- try {
1261
- let R = await n.events[r](...c);
1262
- return a.$.__status.baseResult = R, R = await e.events[r](...c), R;
1263
- } finally {
1264
- a.$.__status.baseResult = u;
1265
- }
1266
- }, i.events[r] = o;
1267
- }
1268
- }
1269
- return e?.constr ? i.constr = async () => {
1270
- await n.constr?.(t()), await e.constr?.(t());
1271
- } : i.constr = n.constr, e?.init ? i.init = async () => {
1272
- await n.init?.(t()), await e.init?.(t());
1273
- } : i.init = n.init, e?.deinit ? i.deinit = async () => {
1274
- await e.deinit?.(t()), await n.deinit?.(t());
1275
- } : i.deinit = n.deinit, e?.mount ? i.mount = async () => {
1276
- await n.mount?.(t()), await e.mount?.(t());
1277
- } : i.mount = n.mount, e?.unmount ? i.unmount = async () => {
1278
- await e.unmount?.(t()), await n.unmount?.(t());
1279
- } : i.unmount = n.unmount, e?.draw ? i.draw = async () => {
1280
- await n.draw?.(t()), await e.draw?.(t());
1281
- } : i.draw = n.draw, e?.erase ? i.erase = async () => {
1282
- await e.erase?.(t()), await n.erase?.(t());
1283
- } : i.erase = n.erase, i;
1284
- }
1285
- function A(n) {
1286
- return U(n) ? `[model #${n.birthMark()}]` : D(n) ? "[binding_rw]" : qe(n) ? "[binding_ro]" : Y(n) ? "[jsx]" : N(n) ? `[()=>jsx${n.displayName ? " " + n.displayName : ""}]` : T(n) ? `[array ${n.length}]` : f(n) ? `[funct${n.name ? " " + n.name : ""}]` : O(n) ? "[object]" : X(n) ? n.length > 32 ? `"${n.substring(0, 31)}... [${n.length}]"` : `"${n}"` : n;
1287
- }
1288
- function at(n) {
1289
- return n instanceof Element;
1290
- }
1291
- function Y(n) {
1292
- return $.isValidElement(n);
1293
- }
1294
- function N(n) {
1295
- return ie(n?.$$typeof) && n.$$typeof.description === "react.memo";
1296
- }
1297
- function U(n) {
1298
- return O(n) && Reflect.has(n, I) && O(n[I]) && Reflect.has(n, "birthMark") && f(n.birthMark) && Reflect.has(n, "fullId") && f(n.fullId) && Reflect.has(n, "htmlId") && f(n.htmlId);
1299
- }
1300
- function V(n) {
1301
- return n.replace(/^./, n[0].toUpperCase());
1302
- }
1303
- function ct(n) {
1304
- const e = {
1305
- owner: n,
1306
- cacheModel: (t) => {
1307
- if (!t.id) {
1308
- h(`Can't cache dynamic model=#${t.birthMark()}, "id" is empty.`, "error");
1309
- return;
1310
- }
1311
- if (t.$.__owner && t.$.__owner !== e.owner) {
1312
- h(`Can't cache dynamic model=#${t.birthMark()} because it belongs to other model=#${t.$.__owner.birthMark()}`, "error");
1313
- return;
1314
- }
1315
- const i = e.getCachedModel(t.id);
1316
- if (i) {
1317
- i != t && h(`Can't cache dynamic model=#${t.birthMark()}. Id "${t.id}" already in cache=#${e.owner.birthMark()}.`, "error");
1318
- return;
1319
- }
1320
- t.$.__owner || (t.$.__owner = e.owner);
1321
- const r = e.owner;
1322
- if (r[t.id])
1323
- r[t.id] !== t && h(`Can't cache dynamic model=#${t.birthMark()}. Id "${t.id}" already exists in cache=#${e.owner.birthMark()}.`, "error");
1324
- else if (t.$.__struct.props.cacheable) {
1325
- if (e.owner.$.__dynamicChildrenIds.indexOf(t.id) != -1)
1326
- throw Error(`Can't cache dynamic model=#${t.birthMark()} in cache=#${t.$.__owner.birthMark()}. Id "${t.id}" already registered.`);
1327
- h(`cache dynamic model=#${t.birthMark()} path=${t.htmlId()} cache=#${e.owner.birthMark()}`), r[t.id] = t, e.owner.$.__dynamicChildrenIds.push(t.id), t.$.__status.cached = !0;
1328
- }
1329
- },
1330
- getCachedModel: (t) => {
1331
- const r = e.owner[t];
1332
- if (r && !r.$.__status.cached)
1333
- throw Error("Dynamic cache corrution");
1334
- return r;
1335
- }
1336
- };
1337
- return e;
1338
- }
1339
- const Me = $.createContext(void 0);
1340
- function Ee() {
1341
- return $.useContext(Me);
1342
- }
1343
- function ne(n) {
1344
- const e = {
1345
- models: n,
1346
- pointer: -1,
1347
- getNextCachedModel: () => {
1348
- if (e.pointer === e.models.length - 1 || (e.pointer++, !e.models[e.pointer]))
1349
- return;
1350
- const t = e.models[e.pointer];
1351
- if (!t.$.__status.cached)
1352
- throw Error("Static cache corrution");
1353
- return t.cacheable || (e.models[e.pointer] = null, t.$.__status.cached = !1), t;
1354
- },
1355
- cacheModel: (t, i) => {
1356
- if (i) {
1357
- if (e.pointer >= 0 && e.pointer < e.models.length) {
1358
- const r = e.models[e.pointer];
1359
- r && (r.$.__status.cached = !1, r.cacheable = !1), e.models[e.pointer] = t;
1360
- }
1361
- } else
1362
- e.models.push(t), e.pointer++;
1363
- t && (t.$.__status.cached = !0);
1364
- }
1365
- };
1366
- return e;
1367
- }
1368
- $.createContext(void 0);
1369
- function vt(n) {
1370
- return (t) => {
1371
- h(`FC begin hook=${n.name}`);
1372
- const i = Ee();
1373
- let r;
1374
- if (i) {
1375
- if (i.staticModelsTrap)
1376
- throw Error(`Hook "${n.name}" called recursively.`);
1377
- X(t.id) && t.id ? (r = i.getCachedModel(t.id), r ? (i.staticModelsTrap = ne(r.$.__staticChildrenCache), i.staticModelsTrap.owner = r, h(`use cached dynamic model=#${r.birthMark()} path=${r.htmlId()} cache=#${i.owner.birthMark()}`)) : i.staticModelsTrap = ne([])) : (i.staticModelsTrap = ne([]), h('Set property "id" in JSX for caching the model by the parent component.', "warn"));
1378
- }
1379
- const o = n(t);
1380
- let c = !1;
1381
- if (r) {
1382
- if (r != o) throw Error("The cached models don't match");
1383
- c = !0;
1384
- } else
1385
- r = o, !t.id && r.id === n.name && (r.id = void 0), i && r.id && r.id === t.id && (c = i.getCachedModel(r.id) === r, !c && r.cacheable && i.cacheModel(r));
1386
- if (i?.staticModelsTrap) {
1387
- if (r.$.__staticChildrenCache.length && i.staticModelsTrap.models.length && r.$.__staticChildrenCache != i.staticModelsTrap.models)
1388
- throw Error("something's wrong");
1389
- t.id && !c && (r.$.__staticChildrenCache = i.staticModelsTrap.models, y.traceLog && r.$.__staticChildrenCache.forEach((a) => {
1390
- a && (a.$.__owner || (a.$.__owner = r), h(`cache static model=#${a.birthMark()} path=${a.htmlId()} cache=#${r.birthMark()}`));
1391
- })), i.staticModelsTrap = void 0;
1392
- }
1393
- return h(`FC end hook=${n.name}`), r.View();
1394
- };
1395
- }
1396
- window.addEventListener("unhandledrejection", (n) => {
1397
- y.errorHandler && (n.preventDefault(), y.errorHandler(n.reason));
1398
- });
1399
- window.addEventListener("error", (n) => {
1400
- y.errorHandler && (n.preventDefault(), y.errorHandler(n.error));
1401
- });
1402
- const y = {
1403
- traceLog: !1,
1404
- hashHtmlId: !1,
1405
- modelCacheMode: "auto-cache"
1406
- };
1407
- function h(n, e = "info") {
1408
- if (y.traceLog)
1409
- switch (e) {
1410
- case "warn":
1411
- console.warn(n);
1412
- break;
1413
- case "error":
1414
- console.error(n);
1415
- break;
1416
- default:
1417
- console.debug(n);
1418
- }
1419
- }
1420
- window.UECA = y;
1421
- export {
1422
- rt as $,
1423
- I as $name,
1424
- _t as IF,
1425
- ft as RenderNode,
1426
- we as bind,
1427
- Xe as bindProp,
1428
- lt as clone,
1429
- bt as defaultMessageBus,
1430
- x as errorIf,
1431
- mt as errorIfNot,
1432
- vt as getFC,
1433
- y as globalSettings,
1434
- k as intersection,
1435
- T as isArray,
1436
- ut as isBoolean,
1437
- U as isComponentModel,
1438
- ye as isEqual,
1439
- f as isFunction,
1440
- Ue as isMap,
1441
- Ye as isNull,
1442
- dt as isNumber,
1443
- O as isObject,
1444
- X as isString,
1445
- ie as isSymbol,
1446
- b as isUndefined,
1447
- pt as observe,
1448
- oe as renderNode,
1449
- gt as sleep,
1450
- st as useComponent,
1451
- $t as useExtendedComponent,
1452
- et as useMessaging
1453
- };
1
+ import{jsx as t,Fragment as e}from"react/jsx-runtime";import*as i from"react";import*as n from"mobx";import*as s from"mobx-react";function r(t){if(t){return JSON.parse(JSON.stringify(t))}}function a(t){return void 0===t}function o(t){return null===t}function c(t){return"string"==typeof t}function h(t){return"number"==typeof t}function u(t){return"boolean"==typeof t}function d(t){return Array.isArray(t)}function l(t){return"function"==typeof t}function _(t){return null!==t&&"object"==typeof t}function m(t){return t instanceof Map}function p(t){return"symbol"==typeof t}function g(t,e){if(t===e){return!0}if(_(t)&&_(e)){const i=Object.keys(t),n=Object.keys(e);if(i.length!==n.length){return!1}for(const s of i){if(!n.includes(s)||!g(t[s],e[s])){return!1}}return!0}return!1}function f(t,e){return t.filter(t=>e.includes(t))}function b(i){return i.condition?t(e,{children:$(i.children)}):null}function $(e){if(l(e)){const i=s.observer(e);
2
+ return t(i,{})}return Y(e)?t(e,{}):e}const v=s.observer(i=>!1===i.render?null:t(e,{children:$(i.node)}));function w(t,e="Invalid condition"){if(t){throw Error(e)}}function y(t,e){if(!t){throw Error(e||"Invalid condition")}}async function C(t){await new Promise(e=>setTimeout(e,t))}function M(t){return l(t)?s.observer(t):n.observable(t)}function k(t){return!!(t&&_(t)&&2===Object.keys(t).length&&l(t[0])&&(l(t[1])||a(t[1])))}function R(t){return k(t)&&l(t[1])}function O(t,e){return[()=>{let i;try{i=t()}catch(n){ot(n.message,"error")}return i||ot(`Attempt to get bound property "${e.toString()}" of undefined`,"warn"),i?i[e]:void 0},i=>{let n;try{n=t()}catch(s){ot(s.message,"error")}n?n[e]=i:ot(`Attempt to set bound property "${e.toString()}" of undefined`,"warn")}]}function P(t,e){if(l(t)&&(l(e)||void 0===e)){return[(i=t)?()=>{let t;try{t=i()}catch(e){ot(e.message,"error")}return t}:void 0,(n=e)?t=>{try{n(t)}catch(e){ot(e.message,"error")}}:void 0]}var i,n;if(l(t)&&c(e)){return O(t,e)}throw new Error("Invalid arguments for bind()")}class I{_target;_name;constructor(t,e){this._target=t,this._name=e}}class B extends I{_observableKind=0;_value=void 0;_valueShallow=void 0;_valueRef=void 0;_forceReactionToggle=void 0;_onValueChangeReactionDisposer;_structBindingReactionDisposer;_paramsBindingReactionDisposer;constructor(t,e){super(t,e),n.makeObservable(this,{_value:n.observable,_valueShallow:n.observable.shallow,_valueRef:n.observable.ref,_forceReactionToggle:n.observable.ref,_forceReaction:n.action})}initBindings(){this._setupOnValueChangeReaction(),this._setupStructBindingReaction(),this._setupParamsBindingReaction()}deinitBindings(){this._onValueChangeReactionDisposer?.(),this._onValueChangeReactionDisposer=void 0,this._structBindingReactionDisposer?.(),this._structBindingReactionDisposer=void 0,this._paramsBindingReactionDisposer?.(),this._paramsBindingReactionDisposer=void 0}get value(){return this._getObservable()}set value(t){if(k(t)){throw Error("Attempt to assign binding as a value")}n.runInAction(()=>{this._paramsBinding||this._structBinding?this._modelIsNew()?this._setValue(t):(this._structBinding&&R(this._structBinding)&&(this._structBinding[1]?.(t),t=this._structBinding[0]?.()),this._paramsBinding&&R(this._paramsBinding)&&this._paramsBinding[1]?.(t)):this._setValue(t)})}_setValue(t){let e=this._getObservable();d(e)&&(e=e.slice());const i=this._target;if(!B._isEqual(t,e)){if(!this._modelIsNew()&&!i.changeNotifyDisabled()){const i=this._name;this._structOnPropChanging&&w((t=this._structOnPropChanging(i,t,e))instanceof Promise,"Asynchronous OnPropChanging event is not allowed");let n=this._getStructOnChangingEvent(i);if(n&&w((t=n(t,e))instanceof Promise,"Asynchronous OnChanging<Prop> event is not allowed"),this._customOnPropChanging&&w((t=this._customOnPropChanging(i,t,e))instanceof Promise,"Asynchronous OnPropChanging event is not allowed"),n=this._getCustomOnChangingEvent(i),n&&w((t=n(t,e))instanceof Promise,"Asynchronous OnChanging<Prop> event is not allowed"),B._isEqual(t,e)){return void setTimeout(()=>this._forceReaction())}}this._setObservable(t)}}_setupStructBindingReaction(){if(this._structBindingReactionDisposer?.(),this._structBindingReactionDisposer=void 0,!this._structBinding){return}const t=this._name,e=this._target,i=i=>{try{i=this._structBinding[0](),this._paramsBindingReactionDisposer&&R(this._paramsBinding)&&(this._paramsBinding[1](i),i=this._paramsBinding[0]()),this._setValue(i)}catch(n){ot(`Struct binding error: ${t}.set(${X(i)}) model=#${e.birthMark()} path=${e.htmlId()}\n${n}`,"error")}};this._structBindingReactionDisposer=n.reaction(()=>{let t=this._structBinding[0]();return d(t)&&(t=t.slice()),[t,this._forceReactionToggle]},([t])=>i(t),{name:`Struct binding model=#${e.birthMark()} path=${e.htmlId()}.${t}`,fireImmediately:!0})}_setupParamsBindingReaction(){if(this._paramsBindingReactionDisposer?.(),this._paramsBindingReactionDisposer=void 0,!this._paramsBinding){return}const t=this._name,e=this._target,i=i=>{try{this._structBindingReactionDisposer&&R(this._structBinding)&&(this._structBinding[1](i),i=this._structBinding[0]()),this._setValue(i)}catch(n){ot(`Param binding error: ${t}.set(${X(i)}) model=#${e.birthMark()} path=${e.htmlId()}${n}`,"error")}};this._paramsBindingReactionDisposer=n.reaction(()=>{let t=this._paramsBinding[0]();return d(t)&&(t=t.slice()),[t,this._forceReactionToggle]},([t])=>i(t),{name:`Param binding model=#${e.birthMark()} path=${e.htmlId()}.${t}`,fireImmediately:!0})}_setupOnValueChangeReaction(){this._onValueChangeReactionDisposer?.(),this._onValueChangeReactionDisposer=void 0;const t=this._name,e=this._target;this._onValueChangeReactionDisposer=n.reaction(()=>{let t=this._getObservable();return d(t)&&(t=t.slice()),[t,this._forceReactionToggle]},([i],[n])=>{try{if(this._modelIsNew()){throw Error("???")}if(B._isEqual(i,n)){return}ot(`change prop model=#${e.birthMark()} path=${e.htmlId()}[${t}] ${X(n)}➝${X(i)}`),e.changeNotifyDisabled()||(this._structOnPropChange?.(t,i,n),this._getStructOnChangeEvent(t)?.(i,n),this._customOnPropChange?.(t,i,n),this._getCustomOnChangeEvent(t)?.(i,n))}catch(s){ot(`Prop change error: ${t}.set(${X(i)}) model=#${e.birthMark()} path=${e.htmlId()}\n${s}`,"error")}},{name:`Prop change model=#${e.birthMark()} path=${e.htmlId()}.${t}`})}get _structBinding(){const t=this._name,e=this._target;if(k(e.$.__struct.props?.[t])){return e.$.__struct.props[t]}}get _paramsBinding(){const t=this._name,e=this._target;if(k(e.$.__params?.[t])){return e.$.__params[t]}}get _structOnPropChanging(){return this._target.$.__struct.events?.onPropChanging}get _structOnPropChange(){return this._target.$.__struct.events?.onPropChange}_getStructOnChangingEvent(t){return this._target.$.__struct.events?.[`onChanging${tt(t)}`]}_getStructOnChangeEvent(t){return this._target.$.__struct.events?.[`onChange${tt(t)}`]}get _customOnPropChanging(){const t=this._target.onPropChanging;if(t instanceof V){return t.event}}get _customOnPropChange(){const t=this._target.onPropChange;if(t instanceof V){return t.event}}_getCustomOnChangingEvent(t){const e=this._target[`onChanging${tt(t)}`];if(e instanceof V){return e.event}}_getCustomOnChangeEvent(t){const e=this._target[`onChange${tt(t)}`];if(e instanceof V){return e.event}}_modelIsNew(){return!this._target.$.__status.initPhase}_forceReaction(){this._forceReactionToggle=!this._forceReactionToggle}_getObservable(){return[this._value,this._valueShallow,this._valueRef,this._forceReactionToggle][this._observableKind]}_setObservable(t){this._getObservable(),n.transaction(()=>{const e=this._prepareValueToObserve(t,this._name);"ref"===e.observable?(this._value=void 0,this._valueShallow=void 0,this._valueRef=e.value,this._observableKind=2):"shallow"===e.observable?(this._value=void 0,this._valueRef=void 0,this._valueShallow=e.value,this._observableKind=1):(this._valueShallow=void 0,this._valueRef=void 0,this._value=e.value,this._observableKind=0)})}_prepareObjectToObserve(t){if(n.isObservable(t)){return{value:t,observable:"ref"}}const e=Object.keys(t).reduce((e,i)=>{if(n.isObservableProp(t,i)){return e}const s=this._prepareValueToObserve(t[i],i);return t[i]=s.value,"ref"===s.observable?e[i]=n.observable.ref:"shallow"===s.observable?e[i]=n.observable.shallow:e[i]=n.observable.deep,e},{});return{value:n.observable(t,e),observable:"ref"}}_prepareValueToObserve(e,i){if(Z(e)){return{value:e,observable:"ref"}}if(d(e)||m(e)){return{value:e,observable:"shallow"}}if(function(t){return t instanceof Element}(e)||Q(e)||Y(e)){return{value:e,observable:"ref"}}if(l(e)){if(S(i)&&!B._isWrappedView(e)){const i=s.observer(e),n=e=>t(i,{...e});n.__ueca_ViewFn=e,e=n}return{value:e,observable:"ref"}}return _(e)?this._prepareObjectToObserve(e):{value:e,observable:"deep"}}static _isEqual(t,e){return Q(t)||Q(e)||Y(t)||Y(e)||Z(t)||Z(e)?t===e:l(t)||l(e)?(B._isWrappedView(t)&&(t=t.__ueca_ViewFn),B._isWrappedView(e)&&(e=e.__ueca_ViewFn),t===e):g(t,e)}static _isWrappedView(t){return l(t)&&Reflect.has(t,"__ueca_ViewFn")}}class E extends I{child;constructor(t,e,i){super(t,e),n.makeObservable(this,{child:n.observable.ref}),this.child=i}}class T extends I{method;constructor(e,i,n){if(super(e,i),S(i)){const e=s.observer(n);this.method=i=>t(e,{...i})}else{this.method=n}}}class V extends I{_event;constructor(t,e){super(t,e),n.makeObservable(this,{_event:n.observable.ref})}get event(){const t=this._target.$.__struct.events?.[this._name];return!t||x(this._name,this._target.$.__struct)||function(t,e){if("onPropChange"===t){return!0}if(!t.startsWith("onChange")){return!1}let i=t.substring(8);return i=i[0].toLowerCase()+i.slice(1),!!Reflect.has(e.props,i)}(this._name,this._target.$.__struct)?this._event:async(...e)=>{const i=this._target.$.__status.baseResult;try{let i=await t(...e);return this._event&&(this._target.$.__status.baseResult=i,i=await this._event(...e)),i}finally{this._target.$.__status.baseResult=i}}}set event(t){this._event=t}}function S(t){return t?.endsWith("View")}function x(t,e){if("onPropChanging"===t){return!0}if(!t.startsWith("onChanging")){return!1}let i=t.substring(10);return i=i[0].toLowerCase()+i.slice(1),!!Reflect.has(e.props,i)}class D{_registry;name;constructor(t){this.name=t,this._registry=new Map}subscribe(t){const e=t.$.__struct.messages;e&&Object.keys(e).forEach(e=>{let i=this._registry.get(e);i||(i=new Set,this._registry.set(e,i)),i.add(t)})}unsubscribe(t){const e=t.$.__struct.messages;if(!e){return}const i=[];Object.keys(e).forEach(e=>{const n=this._registry.get(e);n&&(n.delete(t),n.size||i.push(e))}),i.forEach(t=>{this._registry.delete(t)})}async broadcast(t,e,i){const n=this._registry.get(e);if(!n||!n.size){return ot(`MessageBus (${this.name}): no subscribers for message "${e}"`,"warn"),[]}const s=[];for(const r of n){if(a(t)||o(t)||""===t){}else if(c(t)){if(t&&r.fullId()!=t){continue}}else{if(!(t instanceof RegExp)){break}if(!t.test(r.fullId())){continue}}const n=r.$.__struct.messages?.[e];if(n){const t=n(i);s.push(t)}}return await Promise.all(s)}async castTo(t,e,i){const n=await this.broadcast(t,e,i);return n?.length>1&&ot(`MessageBus (${this.name}): Ambiguous unicast by message "${e}"`,"warn"),n?n[0]:void 0}async unicast(t,e){return await this.castTo("",t,e)}async getAsync(t,e){return await this.unicast(t,e)}async postAsync(t,e){return await this.unicast(t,e)}}const j=function(){const t=new D("Default Message Bus");return window.addEventListener("messagebus.post",function(e){t.broadcast(null,e.detail.message,e.detail.params)}),t}(),A=i.createContext(j);function L(){return j}function N(t){return function(t,e){return i.useEffect(()=>(t.subscribe(e),()=>t.unsubscribe(e)),[]),t}(i.useContext(A),t)}n._getGlobalState().allowStateChanges=!0;class z{_privateMembers;_birthMark;_disableOnChangeCount=0;_bus;_renderToggle;constructor(t){n.makeObservable(this,{_renderToggle:n.observable,View:n.computed,BaseView:n.computed,clearModelCache:n.action,invalidateView:n.action,_assignParams:n.action,_constr:n.action,_init:n.action,_mount:n.action,_unmount:n.action,_deinit:n.action,_draw:n.action,_erase:n.action,_deleteMember:n.action}),z._checkUniqueNamesInStructSections(t),this._privateMembers={__status:{initPhase:void 0,mountPhase:void 0,cached:!1,initCount:0,mountCount:0,baseResult:void 0},__struct:void 0,__params:void 0,__owner:void 0,__dynamicChildrenIds:[],__staticChildrenCache:void 0,__proxy:void 0,__settersInProgress:[],__assignParams:void 0,__initializeModel:void 0},t={...t},this._birthMark=Math.round(1e6*Math.random()).toString(),this.$.__struct=t,this.$.__dynamicChildrenIds=[],this.$.__staticChildrenCache=[],this.$.__settersInProgress=[],this.$.__assignParams=this._assignParams.bind(this),this.$.__initializeModel=this._initializeModel.bind(this);for(const e in t.props){if(e.startsWith("__")){this[e]=t.props[e],delete t.props[e];continue}const i=new B(this,e),n=t.props[e];l(n)&&(t.props[e]=P(n,void 0)),k(t.props[e])?S(e)?i.value=J:i.value=void 0:i.value=t.props[e],this[e]=i}for(const e in t.children){const i=new E(this,e,t.children[e]);i.child.$.__owner=this,i.child.disableOnChange(),i.child.id=e,i.child.enableOnChange(),this[e]=i}for(const e in t.methods){const i=t.methods[e];this[e]=new T(this,e,i)}for(const e in t.events){if(e.startsWith("onChanging")||e.startsWith("onChange")||"onPropChanging"===e||"onPropChange"===e){return}this[e]=new V(this,e)}this._renderToggle=void 0}get $(){return this._privateMembers}get bus(){return this._bus}get View(){return this._view()}get BaseView(){return this._view(!0)}disableOnChange(){this._disableOnChangeCount++}enableOnChange(){if(0===this._disableOnChangeCount){throw new Error("enableOnChange() requires disableOnChange() pair")}this._disableOnChangeCount--}changeNotifyDisabled(){return this._disableOnChangeCount>0}birthMark(){return this._birthMark}fullId(){let t="";return this.$.__owner&&(t=this.$.__owner.fullId()+"."),t+(this.id?.value??"<empty>")}htmlId(){const t=this.fullId();return"<empty>"===t?void 0:window.hashHtmlId?z._getHashCode(t):t}getChildrenModels(t){const e=[];if(!t||"static"===t){for(const i in this.$.__struct.children){e.push(this.$.__proxy[i])}}return t&&"dynamic"!==t||this.$.__dynamicChildrenIds.forEach(t=>e.push(this.$.__proxy[t])),e}clearModelCache(){for(const t of this.$.__dynamicChildrenIds){const e=this.$.__proxy[t];if(e&&(ot(`uncache dynamic model=#${e.birthMark()} path=${e.htmlId()} cache=#${this.birthMark()}`),this._deleteMember(t),e.$.__status.cached=!1,e.$.__staticChildrenCache.length)){for(const t of e.$.__staticChildrenCache){if(!t){return}ot(`uncache static model=#${t.birthMark()} path=${t.htmlId()} cache=#${e.birthMark}`),t.$.__status.cached=!1}for(const t of e.$.__staticChildrenCache){if(!t){return}t.clearModelCache()}this.$.__staticChildrenCache.splice(0)}}this.$.__dynamicChildrenIds.splice(0)}invalidateView(){this._renderToggle=!this._renderToggle}_view(e=!1){const n=s.observer((n=>{const s=!a(this._renderToggle)&&(a(n?.render)||n.render),r=s?this.$.__proxy:void 0;s&&this.$.__status.mountCount++,i.useEffect(()=>(s&&a(this.$.__status.mountPhase)&&this._mount(),()=>{s&&this.$.__status.mountCount--,this.$.__status.mountCount||this._unmount()}));const o=t=>{const s=e?r?.$.__struct.BaseView:r?.$.__struct.View;return i.useLayoutEffect(()=>{if(t&&s){return this._draw(),()=>{this._erase()}}}),t&&s?(ot(`render view model=#${r?.birthMark()} path=${r?.htmlId()}`),s(n)):null};return s?t(W,{componentModel:r,children:t(it.Provider,{value:et(r),children:o(!0)})}):o(!1)}).bind(this));return e=>t(n,{...e})}_assignParams(t){delete(t={...t}).cacheable;for(const e in this.$.__struct.props){if(l(t[e])&&Reflect.has(t,e)){const i=t[e];t[e]=P(i,void 0)}}this.$.__params=t;for(const e in t){"constr"===e||"init"===e||"deinit"===e||"mount"===e||"unmount"===e||"draw"===e||"erase"===e||k(t[e])||(this.$.__proxy[e]=t[e])}}_initBindings(){for(const t in this.$.__struct.props){this[t]?.initBindings()}}_deInitBindings(){for(const t in this.$.__struct.props){this[t]?.deinitBindings()}}async _constr(){this.$.__status.initPhase="constructing";try{const t=this.$.__proxy;ot(`constr model=#${t.birthMark()} path=${t.htmlId()}`),await(this.$.__struct.constr?.(this.$.__proxy)),await(this.$.__params?.constr?.(this.$.__proxy))}finally{this.$.__status.initPhase="constructed"}}async _init(t){if(this.$.__status.initPhase||await this._constr(),this._assignParams(t),"constructed"===this.$.__status.initPhase){this.$.__status.initPhase="initializing";try{const t=this.$.__proxy;ot(`init model=#${t.birthMark()} path=${t.htmlId()}`),this._initBindings(),await(this.$.__struct.init?.(t)),await(this.$.__params?.init?.(t))}finally{this.$.__status.initPhase="initialized";try{"init-mount"===this.$.__status.mountPhase&&await this._mount()}finally{a(this._renderToggle)&&this.invalidateView()}}}}async _mount(){if("mounted"===this.$.__status.mountPhase){return}if("initialized"!=this.$.__status.initPhase){return void(this.$.__status.mountPhase="init-mount")}this.$.__status.mountPhase="mounting";const t=this.$.__proxy;ot(`mount model=#${t.birthMark()} path=${t.htmlId()}`),await(this.$.__struct.mount?.(t)),await(this.$.__params?.mount?.(t)),this.$.__status.mountPhase="mounted"}async _unmount(){if("mounted"==this.$.__status.mountPhase){this.$.__status.mountPhase="unmounting";try{const t=this.$.__proxy;ot(`unmount model=#${t.birthMark()} path=${t.htmlId()}`),await(this.$.__params?.unmount?.(t)),await(this.$.__struct.unmount?.(t))}finally{this.$.__status.mountPhase=void 0,"unmount-deinit"===this.$.__status.initPhase&&(this.$.__status.initPhase="initialized",await this._deinit())}}}async _deinit(){if(this.$.__status.initCount--,!this.$.__status.initCount&&"initialized"===this.$.__status.initPhase){if("mounted"===this.$.__status.mountPhase||"unmounting"===this.$.__status.mountPhase){return this.$.__status.initCount++,void(this.$.__status.initPhase="unmount-deinit")}this.$.__status.initPhase="deinitializing";try{const t=this.$.__proxy;ot(`deinit model=#${t.birthMark()} path=${t.htmlId()}`),this._renderToggle=void 0,await(this.$.__params?.deinit?.(t)),await(this.$.__struct.deinit?.(t)),this._deInitBindings()}finally{this.$.__status.initPhase="constructed"}}}async _draw(){const t=this.$.__proxy;await(this.$.__struct.draw?.(t)),await(this.$.__params?.draw?.(t))}async _erase(){const t=this.$.__proxy;await(this.$.__params?.erase?.(t)),await(this.$.__struct.erase?.(t))}_deleteMember(t){let e=!1;return Reflect.has(this,t)&&(delete this[t],e=!0),Reflect.has(this,t)&&(delete this[t],e=!0),e}_initializeModel(t){this.$.__status.initCount++,this._bus=N(this),i.useEffect(()=>(this._init(t),()=>{this._deinit()}))}static _getHashCode(t){let e="";const i=Array.from(t).reduce((t,e)=>Math.imul(31,t)+e.charCodeAt(0)|0,0);for(let n=0;n<32;n+=6){e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-".charAt(i>>>n&63)}return e}static _checkUniqueNamesInStructSections(t){const e=f(Object.keys(t.props??{}),Object.keys(t.children??{}));if(e.concat(f(Object.keys(t.props??{}),Object.keys(t.methods??{}))),e.concat(f(Object.keys(t.props??{}),Object.keys(t.events??{}))),e.concat(f(Object.keys(t.children??{}),Object.keys(t.methods??{}))),e.concat(f(Object.keys(t.children??{}),Object.keys(t.events??{}))),e.concat(f(Object.keys(t.methods??{}),Object.keys(t.events??{}))),e.length>0){throw new Error(`The component structure${t.props?.id?" "+t.props.id+" ":""}contains not unique members: ${e}`)}}}class W extends i.PureComponent{_retryStarted=!1;_retriesLeft;constructor(t){super(t),this.state={renderingFailed:!1},this._retriesLeft=t.maxRenderRetries,a(this._retriesLeft)&&(this._retriesLeft=1)}static getDerivedStateFromError(t){return{renderingFailed:!0,error:t}}componentDidCatch(t){0===this._retriesLeft&&(this.props.componentModel&&ot(`JSX Rendering Error model=#${this.props.componentModel.birthMark()} path=${this.props.componentModel.htmlId()}\n${t}`,"error"),this.props?.onRenderError?.(t))}render(){if(!this.state.renderingFailed){
3
+ return t(e,{children:$(this.props.children)})}let i=null;return this._retriesLeft>0?this._retryStarted||(setTimeout(()=>{this._retriesLeft--,this._retryStarted=!1,this.setState({renderingFailed:!1})}),this._retryStarted=!0):at.traceLog&&(i=t("div",{style:{display:"flex",placeContent:"center",fontSize:"large",minWidth:"fit-content",minHeight:"fit-content",overflow:"overlay",backgroundColor:"red",color:"yellow"},title:this._getErrorTitleInfo(),children:"⚠"})),i}_getErrorTitleInfo(){let t="";return this.props.description&&(t=`${t}• Description\n${this.props.description}\n\n`),this.props.componentModel&&(t=`${t}• UECA Component\nmodel: #${this.props.componentModel.birthMark()}\npath: ${this.props.componentModel.htmlId()}\n\n`),this.state.error&&(t=`${t}• Error Details\n${this.state.error?.message}`),`JSX RENDERING ERROR\n\n${t}`}}class F{constructor(t){const e=new z(t),i=new Proxy(e,{get:F._get,set:F._set});return e.$.__proxy=i,i}static _get(t,e){if(p(e)&&e===U||e===q){return t[q]}let i=t[e];return i instanceof B?i=i.value:i instanceof T?i=i.method:i instanceof V?i=i.event:i instanceof E?i=i.child:l(i)&&(i=i.bind(t)),i}static _set(t,e,i){if(p(e)||e===q){return!1}if(-1!==t.$.__settersInProgress.indexOf(e)){return!0}t.$.__settersInProgress.push(e);try{if(t[e]instanceof B){t[e].value=i}else if(t[e]instanceof V){a(i)||l(i)?t[e].event=i:console.error(`Attempt to assign non-function value to event "${e}"`)}else if(l(i)){const n=new V(t,e);n.event=i,t[e]=n}else{if(t[e]instanceof T||t[e]instanceof E){return!1}t[e]=i}}finally{t.$.__settersInProgress.pop()}return!0}}const H=i.version.startsWith("19."),q="$",U=Symbol(q),J=()=>t(e,{});function K(t,e,i,n){n||(n=G);const s=n(function(t,e,i){e||(e={});const n={props:{...t.props,...e.props},children:{...t.children,...e.children},methods:{...t.methods,...e.methods},events:{...t.events,...e.events},messages:{...t.messages,...e.messages},View:e.View&&e.View!==J?e.View:t.View?t.View:J,BaseView:t.View??J};if(t.methods&&e.methods){for(const s in n.methods){Reflect.has(t.methods,s)&&Reflect.has(e.methods,s)&&(n.methods[s]=async(...n)=>{const r=i(),a=r.$.__status.baseResult;try{r.$.__status.baseResult=await t.methods[s](...n),await e.methods[s](...n)}finally{r.$.__status.baseResult=a}})}}if(t.events&&e.events){for(const s in n.events){if(Reflect.has(t.events,s)&&Reflect.has(e.events,s)){let r;r="onPropChanging"===s?(i,n,r)=>(n=t.events[s](i,n,r),e.events[s](i,n,r)):x(s,n)?(i,n)=>(i=t.events[s](i,n),e.events[s](i,n)):async(...n)=>{const r=i(),a=r.$.__status.baseResult;try{let i=await t.events[s](...n);return r.$.__status.baseResult=i,i=await e.events[s](...n),i}finally{r.$.__status.baseResult=a}},n.events[s]=r}}}return n.constr=e?.constr?async()=>{await(t.constr?.(i())),await(e.constr?.(i()))}:t.constr,n.init=e?.init?async()=>{await(t.init?.(i())),await(e.init?.(i()))}:t.init,n.deinit=e?.deinit?async()=>{await(e.deinit?.(i())),await(t.deinit?.(i()))}:t.deinit,n.mount=e?.mount?async()=>{await(t.mount?.(i())),await(e.mount?.(i()))}:t.mount,n.unmount=e?.unmount?async()=>{await(e.unmount?.(i())),await(t.unmount?.(i()))}:t.unmount,n.draw=e?.draw?async()=>{await(t.draw?.(i())),await(e.draw?.(i()))}:t.draw,n.erase=e?.erase?async()=>{await(e.erase?.(i())),await(t.erase?.(i()))}:t.erase,n}(t,e,()=>s),i);return s}function G(t,e){const n=nt();let s=!0;const[r]=i.useState(()=>(s=!1,function(){const i=function(){if("no-cache"==at.modelCacheMode){return!1}let i;return a(e?.cacheable)||(k(e.cacheable)?ot('Bindings are not permitted for the property "cacheable"',"error"):i=e.cacheable),a(i)&&!a(t.props?.cacheable)&&(k(t.props.cacheable)?ot('Bindings are not permitted for the property "cacheable"',"error"):i=t.props.cacheable),a(i)&&"auto-cache"==at.modelCacheMode&&(i=!0),!!i}();let s=n?.staticModelsTrap?.getNextCachedModel();const r=null===s;return s?n.staticModelsTrap&&s!=n.staticModelsTrap.owner&&(ot(`use cached static model=#${s.birthMark()} path=${s.htmlId()} cache=#${n.staticModelsTrap.owner?.birthMark()}`),s.cacheable&&ot(`remove cached static model=#${s.birthMark()} path=${s.htmlId()} cache=#${n.staticModelsTrap.owner?.birthMark()}`)):(w(!t.props),t.props.cacheable=i,s=function(t,e){const i=new F(t);return i.$.__assignParams(e),i}(t,e??{}),ot(`create model=#${s.birthMark()} path=${s.htmlId()}`),s.fullId()||ot("Set a default id in the struct of the component model hook","warn"),n?.staticModelsTrap&&i&&(n.staticModelsTrap.cacheModel(i?s:null,r),r&&ot(`recache static model=#${s.birthMark()} path=${s.htmlId()} cache=#${n.staticModelsTrap.owner?.birthMark()}`))),s}()));if(!r){throw Error("BUG: Component model is undefined")}return s&&ot(`use React cached model=#${r.birthMark()} path=${r.htmlId()} cache=React.useState()`),r.$.__initializeModel(e),r}function X(t){return Z(t)?`[model #${t.birthMark()}]`:R(t)?"[binding_rw]":function(t){return k(t)&&a(t[1])}(t)?"[binding_ro]":Q(t)?"[jsx]":Y(t)?`[()=>jsx${t.displayName?" "+t.displayName:""}]`:d(t)?`[array ${t.length}]`:l(t)?`[funct${t.name?" "+t.name:""}]`:_(t)?"[object]":c(t)?t.length>32?`"${t.substring(0,31)}... [${t.length}]"`:`"${t}"`:t}function Q(t){return H?i.isValidElement(t):p(t?.$$typeof)&&"react.element"===t.$$typeof.description}function Y(t){return p(t?.$$typeof)&&"react.memo"===t.$$typeof.description}function Z(t){return _(t)&&Reflect.has(t,q)&&_(t[q])&&Reflect.has(t,"birthMark")&&l(t.birthMark)&&Reflect.has(t,"fullId")&&l(t.fullId)&&Reflect.has(t,"htmlId")&&l(t.htmlId)}function tt(t){return t.replace(/^./,t[0].toUpperCase())}function et(t){const e={owner:t,cacheModel:t=>{if(!t.id){return void ot(`Can't cache dynamic model=#${t.birthMark()}, "id" is empty.`,"error")}if(t.$.__owner&&t.$.__owner!==e.owner){return void ot(`Can't cache dynamic model=#${t.birthMark()} because it belongs to other model=#${t.$.__owner.birthMark()}`,"error")}const i=e.getCachedModel(t.id);if(i){return void(i!=t&&ot(`Can't cache dynamic model=#${t.birthMark()}. Id "${t.id}" already in cache=#${e.owner.birthMark()}.`,"error"))}t.$.__owner||(t.$.__owner=e.owner);const n=e.owner;if(n[t.id]){n[t.id]!==t&&ot(`Can't cache dynamic model=#${t.birthMark()}. Id "${t.id}" already exists in cache=#${e.owner.birthMark()}.`,"error")}else if(t.$.__struct.props.cacheable){if(-1!=e.owner.$.__dynamicChildrenIds.indexOf(t.id)){throw Error(`Can't cache dynamic model=#${t.birthMark()} in cache=#${t.$.__owner.birthMark()}. Id "${t.id}" already registered.`)}ot(`cache dynamic model=#${t.birthMark()} path=${t.htmlId()} cache=#${e.owner.birthMark()}`),n[t.id]=t,e.owner.$.__dynamicChildrenIds.push(t.id),t.$.__status.cached=!0}},getCachedModel:t=>{const i=e.owner[t];if(i&&!i.$.__status.cached){throw Error("Dynamic cache corrution")}return i}};return e}const it=i.createContext(void 0);function nt(){return i.useContext(it)}function st(t){const e={models:t,pointer:-1,getNextCachedModel:()=>{if(e.pointer===e.models.length-1){return}if(e.pointer++,!e.models[e.pointer]){return}const t=e.models[e.pointer];if(!t.$.__status.cached){throw Error("Static cache corrution")}return t.cacheable||(e.models[e.pointer]=null,t.$.__status.cached=!1),t},cacheModel:(t,i)=>{if(i){if(e.pointer>=0&&e.pointer<e.models.length){const i=e.models[e.pointer];i&&(i.$.__status.cached=!1,i.cacheable=!1),e.models[e.pointer]=t}}else{e.models.push(t),e.pointer++}t&&(t.$.__status.cached=!0)}};return e}function rt(t){return e=>{ot(`FC begin hook=${t.name}`);const i=nt();let n;if(i){if(i.staticModelsTrap){throw Error(`Hook "${t.name}" called recursively.`)}c(e.id)&&e.id?(n=i.getCachedModel(e.id),n?(i.staticModelsTrap=st(n.$.__staticChildrenCache),i.staticModelsTrap.owner=n,ot(`use cached dynamic model=#${n.birthMark()} path=${n.htmlId()} cache=#${i.owner.birthMark()}`)):i.staticModelsTrap=st([])):(i.staticModelsTrap=st([]),ot('Set property "id" in JSX for caching the model by the parent component.',"warn"))}const s=t(e);let r=!1;if(n){if(n!=s){throw Error("The cached models don't match")}r=!0}else{n=s,e.id||n.id!==t.name||(n.id=void 0),i&&n.id&&n.id===e.id&&(r=i.getCachedModel(n.id)===n,!r&&n.cacheable&&i.cacheModel(n))}if(i?.staticModelsTrap){if(n.$.__staticChildrenCache.length&&i.staticModelsTrap.models.length&&n.$.__staticChildrenCache!=i.staticModelsTrap.models){throw Error("something's wrong")}e.id&&!r&&(n.$.__staticChildrenCache=i.staticModelsTrap.models,at.traceLog&&n.$.__staticChildrenCache.forEach(t=>{t&&(t.$.__owner||(t.$.__owner=n),ot(`cache static model=#${t.birthMark()} path=${t.htmlId()} cache=#${n.birthMark()}`))})),i.staticModelsTrap=void 0}return ot(`FC end hook=${t.name}`),n.View()}}i.createContext(void 0),window.addEventListener("unhandledrejection",t=>{at.errorHandler&&(t.preventDefault(),at.errorHandler(t.reason))}),window.addEventListener("error",t=>{at.errorHandler&&(t.preventDefault(),at.errorHandler(t.error))});const at={traceLog:!1,hashHtmlId:!1,modelCacheMode:"auto-cache"};function ot(t,e="info"){if(at.traceLog){switch(e){case"warn":console.warn(t);break;case"error":console.error(t);break;default:console.debug(t)}}}window.UECA=at;export{U as $,q as $name,b as IF,v as RenderNode,P as bind,O as bindProp,r as clone,L as defaultMessageBus,w as errorIf,y as errorIfNot,rt as getFC,at as globalSettings,f as intersection,d as isArray,u as isBoolean,Z as isComponentModel,g as isEqual,l as isFunction,m as isMap,o as isNull,h as isNumber,_ as isObject,c as isString,p as isSymbol,a as isUndefined,M as observe,$ as renderNode,C as sleep,G as useComponent,K as useExtendedComponent,N as useMessaging};