rumious 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.min.js CHANGED
@@ -1,725 +1 @@
1
- var Rumious = (function (exports) {
2
- 'use strict';
3
-
4
- function _arrayLikeToArray(r, a) {
5
- (null == a || a > r.length) && (a = r.length);
6
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
7
- return n;
8
- }
9
- function _arrayWithHoles(r) {
10
- if (Array.isArray(r)) return r;
11
- }
12
- function _assertThisInitialized(e) {
13
- if (undefined === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
14
- return e;
15
- }
16
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
17
- try {
18
- var i = n[a](c),
19
- u = i.value;
20
- } catch (n) {
21
- return void e(n);
22
- }
23
- i.done ? t(u) : Promise.resolve(u).then(r, o);
24
- }
25
- function _asyncToGenerator(n) {
26
- return function () {
27
- var t = this,
28
- e = arguments;
29
- return new Promise(function (r, o) {
30
- var a = n.apply(t, e);
31
- function _next(n) {
32
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
33
- }
34
- function _throw(n) {
35
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
36
- }
37
- _next(undefined);
38
- });
39
- };
40
- }
41
- function _callSuper(t, o, e) {
42
- return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
43
- }
44
- function _classCallCheck(a, n) {
45
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
46
- }
47
- function _construct(t, e, r) {
48
- if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
49
- var o = [null];
50
- o.push.apply(o, e);
51
- var p = new (t.bind.apply(t, o))();
52
- return r && _setPrototypeOf(p, r.prototype), p;
53
- }
54
- function _defineProperties(e, r) {
55
- for (var t = 0; t < r.length; t++) {
56
- var o = r[t];
57
- o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
58
- }
59
- }
60
- function _createClass(e, r, t) {
61
- return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
62
- writable: false
63
- }), e;
64
- }
65
- function _createForOfIteratorHelper(r, e) {
66
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
67
- if (!t) {
68
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
69
- t && (r = t);
70
- var n = 0,
71
- F = function () {};
72
- return {
73
- s: F,
74
- n: function () {
75
- return n >= r.length ? {
76
- done: true
77
- } : {
78
- done: false,
79
- value: r[n++]
80
- };
81
- },
82
- e: function (r) {
83
- throw r;
84
- },
85
- f: F
86
- };
87
- }
88
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
89
- }
90
- var o,
91
- a = true,
92
- u = false;
93
- return {
94
- s: function () {
95
- t = t.call(r);
96
- },
97
- n: function () {
98
- var r = t.next();
99
- return a = r.done, r;
100
- },
101
- e: function (r) {
102
- u = true, o = r;
103
- },
104
- f: function () {
105
- try {
106
- a || null == t.return || t.return();
107
- } finally {
108
- if (u) throw o;
109
- }
110
- }
111
- };
112
- }
113
- function _defineProperty(e, r, t) {
114
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
115
- value: t,
116
- enumerable: true,
117
- configurable: true,
118
- writable: true
119
- }) : e[r] = t, e;
120
- }
121
- function _getPrototypeOf(t) {
122
- return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
123
- return t.__proto__ || Object.getPrototypeOf(t);
124
- }, _getPrototypeOf(t);
125
- }
126
- function _inherits(t, e) {
127
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
128
- t.prototype = Object.create(e && e.prototype, {
129
- constructor: {
130
- value: t,
131
- writable: true,
132
- configurable: true
133
- }
134
- }), Object.defineProperty(t, "prototype", {
135
- writable: false
136
- }), e && _setPrototypeOf(t, e);
137
- }
138
- function _isNativeFunction(t) {
139
- try {
140
- return -1 !== Function.toString.call(t).indexOf("[native code]");
141
- } catch (n) {
142
- return "function" == typeof t;
143
- }
144
- }
145
- function _isNativeReflectConstruct() {
146
- try {
147
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
148
- } catch (t) {}
149
- return (_isNativeReflectConstruct = function () {
150
- return !!t;
151
- })();
152
- }
153
- function _iterableToArrayLimit(r, l) {
154
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
155
- if (null != t) {
156
- var e,
157
- n,
158
- i,
159
- u,
160
- a = [],
161
- f = true,
162
- o = false;
163
- try {
164
- if (i = (t = t.call(r)).next, 0 === l) {
165
- if (Object(t) !== t) return;
166
- f = !1;
167
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
168
- } catch (r) {
169
- o = true, n = r;
170
- } finally {
171
- try {
172
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
173
- } finally {
174
- if (o) throw n;
175
- }
176
- }
177
- return a;
178
- }
179
- }
180
- function _nonIterableRest() {
181
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
182
- }
183
- function ownKeys(e, r) {
184
- var t = Object.keys(e);
185
- if (Object.getOwnPropertySymbols) {
186
- var o = Object.getOwnPropertySymbols(e);
187
- r && (o = o.filter(function (r) {
188
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
189
- })), t.push.apply(t, o);
190
- }
191
- return t;
192
- }
193
- function _objectSpread2(e) {
194
- for (var r = 1; r < arguments.length; r++) {
195
- var t = null != arguments[r] ? arguments[r] : {};
196
- r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
197
- _defineProperty(e, r, t[r]);
198
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
199
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
200
- });
201
- }
202
- return e;
203
- }
204
- function _possibleConstructorReturn(t, e) {
205
- if (e && ("object" == typeof e || "function" == typeof e)) return e;
206
- if (undefined !== e) throw new TypeError("Derived constructors may only return object or undefined");
207
- return _assertThisInitialized(t);
208
- }
209
- function _regeneratorRuntime() {
210
- _regeneratorRuntime = function () {
211
- return e;
212
- };
213
- var t,
214
- e = {},
215
- r = Object.prototype,
216
- n = r.hasOwnProperty,
217
- o = Object.defineProperty || function (t, e, r) {
218
- t[e] = r.value;
219
- },
220
- i = "function" == typeof Symbol ? Symbol : {},
221
- a = i.iterator || "@@iterator",
222
- c = i.asyncIterator || "@@asyncIterator",
223
- u = i.toStringTag || "@@toStringTag";
224
- function define(t, e, r) {
225
- return Object.defineProperty(t, e, {
226
- value: r,
227
- enumerable: true,
228
- configurable: true,
229
- writable: true
230
- }), t[e];
231
- }
232
- try {
233
- define({}, "");
234
- } catch (t) {
235
- define = function (t, e, r) {
236
- return t[e] = r;
237
- };
238
- }
239
- function wrap(t, e, r, n) {
240
- var i = e && e.prototype instanceof Generator ? e : Generator,
241
- a = Object.create(i.prototype),
242
- c = new Context(n || []);
243
- return o(a, "_invoke", {
244
- value: makeInvokeMethod(t, r, c)
245
- }), a;
246
- }
247
- function tryCatch(t, e, r) {
248
- try {
249
- return {
250
- type: "normal",
251
- arg: t.call(e, r)
252
- };
253
- } catch (t) {
254
- return {
255
- type: "throw",
256
- arg: t
257
- };
258
- }
259
- }
260
- e.wrap = wrap;
261
- var h = "suspendedStart",
262
- l = "suspendedYield",
263
- f = "executing",
264
- s = "completed",
265
- y = {};
266
- function Generator() {}
267
- function GeneratorFunction() {}
268
- function GeneratorFunctionPrototype() {}
269
- var p = {};
270
- define(p, a, function () {
271
- return this;
272
- });
273
- var d = Object.getPrototypeOf,
274
- v = d && d(d(values([])));
275
- v && v !== r && n.call(v, a) && (p = v);
276
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
277
- function defineIteratorMethods(t) {
278
- ["next", "throw", "return"].forEach(function (e) {
279
- define(t, e, function (t) {
280
- return this._invoke(e, t);
281
- });
282
- });
283
- }
284
- function AsyncIterator(t, e) {
285
- function invoke(r, o, i, a) {
286
- var c = tryCatch(t[r], t, o);
287
- if ("throw" !== c.type) {
288
- var u = c.arg,
289
- h = u.value;
290
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
291
- invoke("next", t, i, a);
292
- }, function (t) {
293
- invoke("throw", t, i, a);
294
- }) : e.resolve(h).then(function (t) {
295
- u.value = t, i(u);
296
- }, function (t) {
297
- return invoke("throw", t, i, a);
298
- });
299
- }
300
- a(c.arg);
301
- }
302
- var r;
303
- o(this, "_invoke", {
304
- value: function (t, n) {
305
- function callInvokeWithMethodAndArg() {
306
- return new e(function (e, r) {
307
- invoke(t, n, e, r);
308
- });
309
- }
310
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
311
- }
312
- });
313
- }
314
- function makeInvokeMethod(e, r, n) {
315
- var o = h;
316
- return function (i, a) {
317
- if (o === f) throw Error("Generator is already running");
318
- if (o === s) {
319
- if ("throw" === i) throw a;
320
- return {
321
- value: t,
322
- done: true
323
- };
324
- }
325
- for (n.method = i, n.arg = a;;) {
326
- var c = n.delegate;
327
- if (c) {
328
- var u = maybeInvokeDelegate(c, n);
329
- if (u) {
330
- if (u === y) continue;
331
- return u;
332
- }
333
- }
334
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
335
- if (o === h) throw o = s, n.arg;
336
- n.dispatchException(n.arg);
337
- } else "return" === n.method && n.abrupt("return", n.arg);
338
- o = f;
339
- var p = tryCatch(e, r, n);
340
- if ("normal" === p.type) {
341
- if (o = n.done ? s : l, p.arg === y) continue;
342
- return {
343
- value: p.arg,
344
- done: n.done
345
- };
346
- }
347
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
348
- }
349
- };
350
- }
351
- function maybeInvokeDelegate(e, r) {
352
- var n = r.method,
353
- o = e.iterator[n];
354
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
355
- var i = tryCatch(o, e.iterator, r.arg);
356
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
357
- var a = i.arg;
358
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
359
- }
360
- function pushTryEntry(t) {
361
- var e = {
362
- tryLoc: t[0]
363
- };
364
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
365
- }
366
- function resetTryEntry(t) {
367
- var e = t.completion || {};
368
- e.type = "normal", delete e.arg, t.completion = e;
369
- }
370
- function Context(t) {
371
- this.tryEntries = [{
372
- tryLoc: "root"
373
- }], t.forEach(pushTryEntry, this), this.reset(true);
374
- }
375
- function values(e) {
376
- if (e || "" === e) {
377
- var r = e[a];
378
- if (r) return r.call(e);
379
- if ("function" == typeof e.next) return e;
380
- if (!isNaN(e.length)) {
381
- var o = -1,
382
- i = function next() {
383
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = false, next;
384
- return next.value = t, next.done = true, next;
385
- };
386
- return i.next = i;
387
- }
388
- }
389
- throw new TypeError(typeof e + " is not iterable");
390
- }
391
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
392
- value: GeneratorFunctionPrototype,
393
- configurable: true
394
- }), o(GeneratorFunctionPrototype, "constructor", {
395
- value: GeneratorFunction,
396
- configurable: true
397
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
398
- var e = "function" == typeof t && t.constructor;
399
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
400
- }, e.mark = function (t) {
401
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
402
- }, e.awrap = function (t) {
403
- return {
404
- __await: t
405
- };
406
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
407
- return this;
408
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
409
- undefined === i && (i = Promise);
410
- var a = new AsyncIterator(wrap(t, r, n, o), i);
411
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
412
- return t.done ? t.value : a.next();
413
- });
414
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
415
- return this;
416
- }), define(g, "toString", function () {
417
- return "[object Generator]";
418
- }), e.keys = function (t) {
419
- var e = Object(t),
420
- r = [];
421
- for (var n in e) r.push(n);
422
- return r.reverse(), function next() {
423
- for (; r.length;) {
424
- var t = r.pop();
425
- if (t in e) return next.value = t, next.done = false, next;
426
- }
427
- return next.done = true, next;
428
- };
429
- }, e.values = values, Context.prototype = {
430
- constructor: Context,
431
- reset: function (e) {
432
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
433
- },
434
- stop: function () {
435
- this.done = true;
436
- var t = this.tryEntries[0].completion;
437
- if ("throw" === t.type) throw t.arg;
438
- return this.rval;
439
- },
440
- dispatchException: function (e) {
441
- if (this.done) throw e;
442
- var r = this;
443
- function handle(n, o) {
444
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
445
- }
446
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
447
- var i = this.tryEntries[o],
448
- a = i.completion;
449
- if ("root" === i.tryLoc) return handle("end");
450
- if (i.tryLoc <= this.prev) {
451
- var c = n.call(i, "catchLoc"),
452
- u = n.call(i, "finallyLoc");
453
- if (c && u) {
454
- if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
455
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
456
- } else if (c) {
457
- if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
458
- } else {
459
- if (!u) throw Error("try statement without catch or finally");
460
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
461
- }
462
- }
463
- }
464
- },
465
- abrupt: function (t, e) {
466
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
467
- var o = this.tryEntries[r];
468
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
469
- var i = o;
470
- break;
471
- }
472
- }
473
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
474
- var a = i ? i.completion : {};
475
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
476
- },
477
- complete: function (t, e) {
478
- if ("throw" === t.type) throw t.arg;
479
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
480
- },
481
- finish: function (t) {
482
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
483
- var r = this.tryEntries[e];
484
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
485
- }
486
- },
487
- catch: function (t) {
488
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
489
- var r = this.tryEntries[e];
490
- if (r.tryLoc === t) {
491
- var n = r.completion;
492
- if ("throw" === n.type) {
493
- var o = n.arg;
494
- resetTryEntry(r);
495
- }
496
- return o;
497
- }
498
- }
499
- throw Error("illegal catch attempt");
500
- },
501
- delegateYield: function (e, r, n) {
502
- return this.delegate = {
503
- iterator: values(e),
504
- resultName: r,
505
- nextLoc: n
506
- }, "next" === this.method && (this.arg = t), y;
507
- }
508
- }, e;
509
- }
510
- function _setPrototypeOf(t, e) {
511
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
512
- return t.__proto__ = e, t;
513
- }, _setPrototypeOf(t, e);
514
- }
515
- function _slicedToArray(r, e) {
516
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
517
- }
518
- function _toPrimitive(t, r) {
519
- if ("object" != typeof t || !t) return t;
520
- var e = t[Symbol.toPrimitive];
521
- if (undefined !== e) {
522
- var i = e.call(t, r || "default");
523
- if ("object" != typeof i) return i;
524
- throw new TypeError("@@toPrimitive must return a primitive value.");
525
- }
526
- return ("string" === r ? String : Number)(t);
527
- }
528
- function _toPropertyKey(t) {
529
- var i = _toPrimitive(t, "string");
530
- return "symbol" == typeof i ? i : i + "";
531
- }
532
- function _typeof(o) {
533
- "@babel/helpers - typeof";
534
-
535
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
536
- return typeof o;
537
- } : function (o) {
538
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
539
- }, _typeof(o);
540
- }
541
- function _unsupportedIterableToArray(r, a) {
542
- if (r) {
543
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
544
- var t = {}.toString.call(r).slice(8, -1);
545
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
546
- }
547
- }
548
- function _wrapNativeSuper(t) {
549
- var r = "function" == typeof Map ? new Map() : undefined;
550
- return _wrapNativeSuper = function (t) {
551
- if (null === t || !_isNativeFunction(t)) return t;
552
- if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
553
- if (undefined !== r) {
554
- if (r.has(t)) return r.get(t);
555
- r.set(t, Wrapper);
556
- }
557
- function Wrapper() {
558
- return _construct(t, arguments, _getPrototypeOf(this).constructor);
559
- }
560
- return Wrapper.prototype = Object.create(t.prototype, {
561
- constructor: {
562
- value: Wrapper,
563
- enumerable: false,
564
- writable: true,
565
- configurable: true
566
- }
567
- }), _setPrototypeOf(Wrapper, t);
568
- }, _wrapNativeSuper(t);
569
- }
570
-
571
- var RumiousRenderContext=/*#__PURE__*/function(){function RumiousRenderContext(target){_classCallCheck(this,RumiousRenderContext);this.target=target;}return _createClass(RumiousRenderContext,[{key:"find",value:function find(name){return this.target[name]}},{key:"get",value:function get(name){return this.target[name]}}])}();
572
-
573
- var RumiousComponent=/*#__PURE__*/function(){function RumiousComponent(){_classCallCheck(this,RumiousComponent);this.element=null;this.props={};this.renderContext=new RumiousRenderContext(this);this.renderer=null;this.wrapped=null;}return _createClass(RumiousComponent,[{key:"prepare",value:function prepare(element,props){var wrapped=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var renderer=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;this.element=element;this.props=props;this.renderer=renderer;this.wrapped=wrapped;}},{key:"template",value:function template(){return {}}},{key:"requestRender",value:function requestRender(){var template=this.template();var fragment=this.renderer(template,document.createDocumentFragment(),this.renderContext);this.element.appendChild(fragment);this.onRender();}},{key:"requestCleanUp",value:function(){var _requestCleanUp=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var cloned;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(this.element){cloned=this.element.cloneNode(true);this.element.replaceWith(cloned);this.element=cloned;while(this.element.firstChild){this.element.removeChild(this.element.firstChild);}}case 1:case "end":return _context.stop()}},_callee,this)}));function requestCleanUp(){return _requestCleanUp.apply(this,arguments)}return requestCleanUp}()},{key:"onInit",value:function onInit(){}},{key:"onCreate",value:function onCreate(){}},{key:"onRender",value:function onRender(){}},{key:"onUpdate",value:function onUpdate(){}},{key:"onDestroy",value:function onDestroy(){}}])}();function isComponent(component){return Object.getPrototypeOf(component)===RumiousComponent}
574
-
575
- var RumiousElement=/*#__PURE__*/_createClass(function RumiousElement(type,props){var children=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];_classCallCheck(this,RumiousElement);this.type=type;this.props=props;this.children=children;});var RumiousElementList=/*#__PURE__*/function(){function RumiousElementList(list){_classCallCheck(this,RumiousElementList);this.type="ELEMENT_LIST";this.children=list;}return _createClass(RumiousElementList,[{key:"forEach",value:function forEach(callback){this.children.forEach(callback);}}])}();
576
-
577
- function isCamelCase(str){var camelCaseRegex=/^[a-zA-Z]+([A-Z][a-z]*)*$/;return camelCaseRegex.test(str)}function isFunction(object){return typeof object==="function"}
578
-
579
- var RumiousDirective=/*#__PURE__*/function(){function RumiousDirective(type,name,value){_classCallCheck(this,RumiousDirective);this.type=type;this.name=name;this.value=value;}return _createClass(RumiousDirective,[{key:"init",value:function init(){console.warn("Directive haven't handler !");}}])}();var RumiousEventBindingDirective=/*#__PURE__*/function(_RumiousDirective){function RumiousEventBindingDirective(){_classCallCheck(this,RumiousEventBindingDirective);return _callSuper(this,RumiousEventBindingDirective,arguments)}_inherits(RumiousEventBindingDirective,_RumiousDirective);return _createClass(RumiousEventBindingDirective,[{key:"init",value:function(){var _init=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(dom,renderContext){var _this=this;var fn,getHandler;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:fn=null;getHandler=function getHandler(value){if(!renderContext.find(value)){console.warn("Missing event handler for event: ".concat(_this.name));return null}var handler=renderContext.get(value);if(!isFunction(handler)){throw "".concat(value," is not a function!")}return handler.bind(renderContext.target)};if(!(this.value.type==="string")){_context.next=6;break}fn=getHandler(this.value.value);_context.next=13;break;case 6:if(!(this.value.type==="expression")){_context.next=12;break}fn=this.value.value;if(isFunction(fn)){_context.next=10;break}throw "Event handler requires a function!";case 10:_context.next=13;break;case 12:if(this.value.type==="dynamic_value"){fn=getHandler(this.value.value.objectName);}case 13:if(fn){dom.addEventListener(this.name,fn);}case 14:case "end":return _context.stop()}},_callee,this)}));function init(_x,_x2){return _init.apply(this,arguments)}return init}()}])}(RumiousDirective);var RumiousPropsBindingDirective=/*#__PURE__*/function(_RumiousDirective2){function RumiousPropsBindingDirective(){_classCallCheck(this,RumiousPropsBindingDirective);return _callSuper(this,RumiousPropsBindingDirective,arguments)}_inherits(RumiousPropsBindingDirective,_RumiousDirective2);return _createClass(RumiousPropsBindingDirective,[{key:"init",value:function(){var _init2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(dom,renderContext){var _this2=this;var _this$value$evaluator,_this$value,currentStateValue,currentState;return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(this.value.type==="expression")){_context2.next=4;break}_context2.next=13;break;case 4:if(!(this.value.type==="dynamic_value")){_context2.next=13;break}currentStateValue=(_this$value$evaluator=(_this$value=this.value).evaluator)===null||_this$value$evaluator===undefined?undefined:_this$value$evaluator.call(_this$value,renderContext.target);currentState=renderContext.find(this.value.value.objectName);if(currentState){_context2.next=11;break}throw "Invalid props value: Directive bind: require a RumiousState Object !";case 11:currentState.reactor.addBinding(function(){var _this2$value$evaluato,_this2$value;var currentStateValue=(_this2$value$evaluato=(_this2$value=_this2.value).evaluator)===null||_this2$value$evaluato===undefined?undefined:_this2$value$evaluato.call(_this2$value,renderContext.target);_this2.bindAttr(dom,currentStateValue);});case 12:this.bindAttr(dom,currentStateValue);case 13:case "end":return _context2.stop()}},_callee2,this)}));function init(_x3,_x4){return _init2.apply(this,arguments)}return init}()},{key:"normalizeValue",value:function normalizeValue(value){if(_typeof(value)==="object"){var _value$toString,_value$toString2;return (_value$toString=(_value$toString2=value.toString)===null||_value$toString2===undefined?undefined:_value$toString2.call(value))!==null&&_value$toString!==undefined?_value$toString:""}return value}},{key:"bindAttr",value:function(){var _bindAttr=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(dom,value){return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.t0=this.name;_context3.next=_context3.t0==="html"?3:5;break;case 3:dom.innerHTML=this.normalizeValue(value);return _context3.abrupt("break",5);case 5:case "end":return _context3.stop()}},_callee3,this)}));function bindAttr(_x5,_x6){return _bindAttr.apply(this,arguments)}return bindAttr}()}])}(RumiousDirective);var directives={on:function on(event,value){return new RumiousEventBindingDirective("on",event,value)},bind:function bind(attr,value){return new RumiousPropsBindingDirective("bind",attr,value)}};function registerDirective(type,name,value){var _directives$type;return (_directives$type=directives[type])===null||_directives$type===undefined?undefined:_directives$type.call(directives,name,value)}
580
-
581
- function createDirective(type,name,value){return registerDirective(type,name,value)}function createElement(type,props){for(var _len=arguments.length,children=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){children[_key-2]=arguments[_key];}if(isComponent(type)){return createComponent(type,props,children)}if(type===createFragment){return createFragment.apply(undefined,children)}return new RumiousElement(type,props||{},normalizeChildren(children))}function createTextElement(text){return new RumiousElement("TEXT_ELEMENT",{nodeValue:text},[])}function createComponent(type,props,children){return new RumiousElement("COMPONENT",_objectSpread2({component:type},props),new RumiousElementList(normalizeChildren(children)))}function createFragment(){for(var _len2=arguments.length,children=new Array(_len2),_key2=0;_key2<_len2;_key2++){children[_key2]=arguments[_key2];}return new RumiousElement("FRAGMENT",{},normalizeChildren(children))}function normalizeChildren(children){return children.map(function(child){return _typeof(child)==="object"?child:createTextElement(child)})}window.RUMIOUS_JSX_SUPPORT={createElement:createElement,createFragment:createFragment,createDirective:createDirective};
582
-
583
- var RumiousComponentElement=/*#__PURE__*/function(_HTMLElement){function RumiousComponentElement(){var _this;_classCallCheck(this,RumiousComponentElement);_this=_callSuper(this,RumiousComponentElement);_this.instance=null;return _this}_inherits(RumiousComponentElement,_HTMLElement);return _createClass(RumiousComponentElement,[{key:"init",value:function init(componentConstructor,props){var wrapped=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var renderer=arguments.length>3?arguments[3]:undefined;this.instance=new componentConstructor;this.instance.prepare(this,props,wrapped,renderer);this.instance.onInit();}},{key:"connectedCallback",value:function connectedCallback(){this.instance.onCreate();this.instance.requestRender();}},{key:"disconnectCallback",value:function disconnectCallback(){this.instance.onDestroy();this.instance.requestCleanUp();}}])}(/*#__PURE__*/_wrapNativeSuper(HTMLElement));function createComponentElement(){return document.createElement("a-component")}window.customElements.define("a-component",RumiousComponentElement);
584
-
585
- function renderComponent(componentConstructor,props,wrapped,renderer){var componentElement=createComponentElement();componentElement.init(componentConstructor,props,wrapped,renderer);return componentElement}
586
-
587
- function handleComponentElement(element,container,render){var dom=renderComponent(element.props.component,element.props,element.children,render);container.appendChild(dom);return container}function handleFragmentOrElementList(element,container,renderContext){element.children.forEach(function(child){return render(child,container,renderContext)});return container}function handleTextElement(element){return document.createTextNode(element.props.nodeValue)}function handleRegularElement(element,renderContext){var dom=document.createElement(element.type);Object.entries(element.props||{}).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),name=_ref2[0],propValue=_ref2[1];if(name.startsWith("on")&&isCamelCase(name)){dom.addEventListener(name.substring(2).toLowerCase(),propValue);}else {setElementProps(dom,name,propValue,renderContext);}});return dom}function handleDirective(dom,directive,renderContext){directive.init(dom,renderContext);}function setElementProps(dom,name,propValue,renderContext){if(dom.nodeType===Node.TEXT_NODE){dom.nodeValue=propValue;}else if(propValue instanceof RumiousDirective){handleDirective(dom,propValue,renderContext);}else {dom.setAttribute(name,propValue);}}function render(element,container){var renderContext=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(!element)return container;var dom;if(element.type==="COMPONENT"){return handleComponentElement(element,container,render)}if(element.type==="FRAGMENT"||element.type==="ELEMENT_LIST"){return handleFragmentOrElementList(element,container,renderContext)}if(element.type==="TEXT_ELEMENT"){dom=handleTextElement(element);}else {dom=handleRegularElement(element,renderContext);}element.children.forEach(function(child){return render(child,dom,renderContext)});container.appendChild(dom);return container}
588
-
589
- var RumiousApp=/*#__PURE__*/function(){function RumiousApp(){var root=arguments.length>0&&arguments[0]!==undefined?arguments[0]:document.createElement("span");var configs=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,RumiousApp);this.root=root;this.configs=configs;this.renderContext=new RumiousRenderContext(this);}return _createClass(RumiousApp,[{key:"render",value:function render$1(element){render(element,this.root,this.renderContext);}}])}();
590
-
591
- var RumiousReactor=/*#__PURE__*/function(){function RumiousReactor(){var target=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var bindings=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];_classCallCheck(this,RumiousReactor);this.target=target;this.bindings=bindings;}return _createClass(RumiousReactor,[{key:"react",value:function react(){this.bindings.forEach(function(callback){return callback()});}},{key:"addBinding",value:function addBinding(fn){this.bindings.push(fn);}}])}();
592
-
593
- var RumiousReducer=/*#__PURE__*/function(){function RumiousReducer(state){var path=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";var fn=arguments.length>2?arguments[2]:undefined;_classCallCheck(this,RumiousReducer);this.state=state;this.path=path;this.fn=fn;}return _createClass(RumiousReducer,[{key:"trigger",value:function trigger(){var value=this.fn.apply(this,arguments);this.state.set(this.path,value);}}])}();
594
-
595
- var Operation={Remove:"remove",Replace:"replace",Add:"add"};// Don't use `Symbol()` just for 3rd party access the draft
596
- var PROXY_DRAFT=Symbol["for"]("__MUTATIVE_PROXY_DRAFT__");var RAW_RETURN_SYMBOL=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__");var iteratorSymbol=Symbol.iterator;var dataTypes={mutable:"mutable",immutable:"immutable"};var internal={};function has(target,key){return target instanceof Map?target.has(key):Object.prototype.hasOwnProperty.call(target,key)}function getDescriptor(target,key){if(key in target){var prototype=Reflect.getPrototypeOf(target);while(prototype){var descriptor=Reflect.getOwnPropertyDescriptor(prototype,key);if(descriptor)return descriptor;prototype=Reflect.getPrototypeOf(prototype);}}return}function isBaseSetInstance(obj){return Object.getPrototypeOf(obj)===Set.prototype}function isBaseMapInstance(obj){return Object.getPrototypeOf(obj)===Map.prototype}function latest(proxyDraft){var _a;return (_a=proxyDraft.copy)!==null&&_a!==undefined?_a:proxyDraft.original}/**
597
- * Check if the value is a draft
598
- */function isDraft(target){return !!getProxyDraft(target)}function getProxyDraft(value){if(_typeof(value)!=="object")return null;return value===null||value===undefined?undefined:value[PROXY_DRAFT]}function getValue(value){var _a;var proxyDraft=getProxyDraft(value);return proxyDraft?(_a=proxyDraft.copy)!==null&&_a!==undefined?_a:proxyDraft.original:value}/**
599
- * Check if a value is draftable
600
- */function isDraftable(value,options){if(!value||_typeof(value)!=="object")return false;var markResult;return Object.getPrototypeOf(value)===Object.prototype||Array.isArray(value)||value instanceof Map||value instanceof Set||!!(options===null||options===undefined?undefined:options.mark)&&((markResult=options.mark(value,dataTypes))===dataTypes.immutable||typeof markResult==="function")}function getPath(target){var path=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];if(Object.hasOwnProperty.call(target,"key")){// check if the parent is a draft and the original value is not equal to the current value
601
- var parentCopy=target.parent.copy;var proxyDraft=getProxyDraft(get(parentCopy,target.key));if(proxyDraft!==null&&(proxyDraft===null||proxyDraft===undefined?undefined:proxyDraft.original)!==target.original){return null}var isSet=target.parent.type===3/* DraftType.Set */;var key=isSet?Array.from(target.parent.setMap.keys()).indexOf(target.key):target.key;// check if the key is still in the next state parent
602
- if(!(isSet&&parentCopy.size>key||has(parentCopy,key)))return null;path.push(key);}if(target.parent){return getPath(target.parent,path)}// `target` is root draft.
603
- path.reverse();try{// check if the path is valid
604
- resolvePath(target.copy,path);}catch(e){return null}return path}function getType(target){if(Array.isArray(target))return 1/* DraftType.Array */;if(target instanceof Map)return 2/* DraftType.Map */;if(target instanceof Set)return 3/* DraftType.Set */;return 0/* DraftType.Object */}function get(target,key){return getType(target)===2/* DraftType.Map */?target.get(key):target[key]}function set(target,key,value){var type=getType(target);if(type===2/* DraftType.Map */){target.set(key,value);}else {target[key]=value;}}function peek(target,key){var state=getProxyDraft(target);var source=state?latest(state):target;return source[key]}function isEqual(x,y){if(x===y){return x!==0||1/x===1/y}else {return x!==x&&y!==y}}function revokeProxy(proxyDraft){if(!proxyDraft)return;while(proxyDraft.finalities.revoke.length>0){var revoke=proxyDraft.finalities.revoke.pop();revoke();}}// handle JSON Pointer path with spec https://www.rfc-editor.org/rfc/rfc6901
605
- function escapePath(path,pathAsArray){return pathAsArray?path:[""].concat(path).map(function(_item){var item="".concat(_item);if(item.indexOf("/")===-1&&item.indexOf("~")===-1)return item;return item.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function resolvePath(base,path){for(var index=0;index<path.length-1;index+=1){var key=path[index];// use `index` in Set draft
606
- base=get(getType(base)===3/* DraftType.Set */?Array.from(base):base,key);if(_typeof(base)!=="object"){throw new Error("Cannot resolve patch at '".concat(path.join("/"),"'."))}}return base}function strictCopy(target){var copy=Object.create(Object.getPrototypeOf(target));Reflect.ownKeys(target).forEach(function(key){var desc=Reflect.getOwnPropertyDescriptor(target,key);if(desc.enumerable&&desc.configurable&&desc.writable){copy[key]=target[key];return}// for freeze
607
- if(!desc.writable){desc.writable=true;desc.configurable=true;}if(desc.get||desc.set)desc={configurable:true,writable:true,enumerable:desc.enumerable,value:target[key]};Reflect.defineProperty(copy,key,desc);});return copy}var propIsEnum=Object.prototype.propertyIsEnumerable;function shallowCopy(original,options){var markResult;if(Array.isArray(original)){return Array.prototype.concat.call(original)}else if(original instanceof Set){if(!isBaseSetInstance(original)){var SubClass=Object.getPrototypeOf(original).constructor;return new SubClass(original.values())}return Set.prototype.difference?Set.prototype.difference.call(original,new Set):new Set(original.values())}else if(original instanceof Map){if(!isBaseMapInstance(original)){var _SubClass=Object.getPrototypeOf(original).constructor;return new _SubClass(original)}return new Map(original)}else if((options===null||options===undefined?undefined:options.mark)&&(markResult=options.mark(original,dataTypes),markResult!==undefined)&&markResult!==dataTypes.mutable){if(markResult===dataTypes.immutable){return strictCopy(original)}else if(typeof markResult==="function"){if(options.enablePatches||options.enableAutoFreeze){throw new Error("You can't use mark and patches or auto freeze together.")}return markResult()}throw new Error("Unsupported mark result: ".concat(markResult))}else if(_typeof(original)==="object"&&Object.getPrototypeOf(original)===Object.prototype){// For best performance with shallow copies,
608
- // don't use `Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));` by default.
609
- var copy={};Object.keys(original).forEach(function(key){copy[key]=original[key];});Object.getOwnPropertySymbols(original).forEach(function(key){if(propIsEnum.call(original,key)){copy[key]=original[key];}});return copy}else {throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}}function ensureShallowCopy(target){if(target.copy)return;target.copy=shallowCopy(target.original,target.options);}function deepClone(target){if(!isDraftable(target))return getValue(target);if(Array.isArray(target))return target.map(deepClone);if(target instanceof Map){var iterable=Array.from(target.entries()).map(function(_ref){var _ref2=_slicedToArray(_ref,2),k=_ref2[0],v=_ref2[1];return [k,deepClone(v)]});if(!isBaseMapInstance(target)){var SubClass=Object.getPrototypeOf(target).constructor;return new SubClass(iterable)}return new Map(iterable)}if(target instanceof Set){var _iterable=Array.from(target).map(deepClone);if(!isBaseSetInstance(target)){var _SubClass2=Object.getPrototypeOf(target).constructor;return new _SubClass2(_iterable)}return new Set(_iterable)}var copy=Object.create(Object.getPrototypeOf(target));for(var key in target)copy[key]=deepClone(target[key]);return copy}function cloneIfNeeded(target){return isDraft(target)?deepClone(target):target}function markChanged(proxyDraft){var _a;proxyDraft.assignedMap=(_a=proxyDraft.assignedMap)!==null&&_a!==undefined?_a:new Map;if(!proxyDraft.operated){proxyDraft.operated=true;if(proxyDraft.parent){markChanged(proxyDraft.parent);}}}function throwFrozenError(){throw new Error("Cannot modify frozen object")}function deepFreeze(target,subKey,updatedValues,stack,keys){{updatedValues=updatedValues!==null&&updatedValues!==undefined?updatedValues:new WeakMap;stack=stack!==null&&stack!==undefined?stack:[];keys=keys!==null&&keys!==undefined?keys:[];var value=updatedValues.has(target)?updatedValues.get(target):target;if(stack.length>0){var index=stack.indexOf(value);if(value&&_typeof(value)==="object"&&index!==-1){if(stack[0]===value){throw new Error("Forbids circular reference")}throw new Error("Forbids circular reference: ~/".concat(keys.slice(0,index).map(function(key,index){if(_typeof(key)==="symbol")return "[".concat(key.toString(),"]");var parent=stack[index];if(_typeof(key)==="object"&&(parent instanceof Map||parent instanceof Set))return Array.from(parent.keys()).indexOf(key);return key}).join("/")))}stack.push(value);keys.push(subKey);}else {stack.push(value);}}if(Object.isFrozen(target)||isDraft(target)){{stack.pop();keys.pop();}return}var type=getType(target);switch(type){case 2/* DraftType.Map */:var _iterator=_createForOfIteratorHelper(target),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _step$value=_slicedToArray(_step.value,2),key=_step$value[0],_value2=_step$value[1];deepFreeze(key,key,updatedValues,stack,keys);deepFreeze(_value2,key,updatedValues,stack,keys);}}catch(err){_iterator.e(err);}finally{_iterator.f();}target.set=target.clear=target["delete"]=throwFrozenError;break;case 3/* DraftType.Set */:var _iterator2=_createForOfIteratorHelper(target),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var _value3=_step2.value;deepFreeze(_value3,_value3,updatedValues,stack,keys);}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}target.add=target.clear=target["delete"]=throwFrozenError;break;case 1/* DraftType.Array */:Object.freeze(target);var _index=0;var _iterator3=_createForOfIteratorHelper(target),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var _value4=_step3.value;deepFreeze(_value4,_index,updatedValues,stack,keys);_index+=1;}}catch(err){_iterator3.e(err);}finally{_iterator3.f();}break;default:Object.freeze(target);// ignore non-enumerable or symbol properties
610
- Object.keys(target).forEach(function(name){var value=target[name];deepFreeze(value,name,updatedValues,stack,keys);});}{stack.pop();keys.pop();}}function forEach(target,iter){var type=getType(target);if(type===0/* DraftType.Object */){Reflect.ownKeys(target).forEach(function(key){iter(key,target[key],target);});}else if(type===1/* DraftType.Array */){var index=0;var _iterator4=_createForOfIteratorHelper(target),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var entry=_step4.value;iter(index,entry,target);index+=1;}}catch(err){_iterator4.e(err);}finally{_iterator4.f();}}else {target.forEach(function(entry,index){return iter(index,entry,target)});}}function handleValue(target,handledSet,options){if(isDraft(target)||!isDraftable(target,options)||handledSet.has(target)||Object.isFrozen(target))return;var isSet=target instanceof Set;var setMap=isSet?new Map:undefined;handledSet.add(target);forEach(target,function(key,value){var _a;if(isDraft(value)){var proxyDraft=getProxyDraft(value);ensureShallowCopy(proxyDraft);// A draft where a child node has been changed, or assigned a value
611
- var updatedValue=((_a=proxyDraft.assignedMap)===null||_a===void 0?void 0:_a.size)||proxyDraft.operated?proxyDraft.copy:proxyDraft.original;// final update value
612
- set(isSet?setMap:target,key,updatedValue);}else {handleValue(value,handledSet,options);}});if(setMap){var _set=target;var values=Array.from(_set);_set.clear();values.forEach(function(value){_set.add(setMap.has(value)?setMap.get(value):value);});}}function finalizeAssigned(proxyDraft,key){// handle the draftable assigned values, and the value is not a draft
613
- var copy=proxyDraft.type===3/* DraftType.Set */?proxyDraft.setMap:proxyDraft.copy;if(proxyDraft.finalities.revoke.length>1&&proxyDraft.assignedMap.get(key)&&copy){handleValue(get(copy,key),proxyDraft.finalities.handledSet,proxyDraft.options);}}function finalizeSetValue(target){if(target.type===3/* DraftType.Set */&&target.copy){target.copy.clear();target.setMap.forEach(function(value){target.copy.add(getValue(value));});}}function finalizePatches(target,generatePatches,patches,inversePatches){var shouldFinalize=target.operated&&target.assignedMap&&target.assignedMap.size>0&&!target.finalized;if(shouldFinalize){if(patches&&inversePatches){var basePath=getPath(target);if(basePath){generatePatches(target,basePath,patches,inversePatches);}}target.finalized=true;}}function markFinalization(target,key,value,generatePatches){var proxyDraft=getProxyDraft(value);if(proxyDraft){// !case: assign the draft value
614
- if(!proxyDraft.callbacks){proxyDraft.callbacks=[];}proxyDraft.callbacks.push(function(patches,inversePatches){var _a;var copy=target.type===3/* DraftType.Set */?target.setMap:target.copy;if(isEqual(get(copy,key),value)){var updatedValue=proxyDraft.original;if(proxyDraft.copy){updatedValue=proxyDraft.copy;}finalizeSetValue(target);finalizePatches(target,generatePatches,patches,inversePatches);if(target.options.enableAutoFreeze){target.options.updatedValues=(_a=target.options.updatedValues)!==null&&_a!==undefined?_a:new WeakMap;target.options.updatedValues.set(updatedValue,proxyDraft.original);}// final update value
615
- set(copy,key,updatedValue);}});if(target.options.enableAutoFreeze){// !case: assign the draft value in cross draft tree
616
- if(proxyDraft.finalities!==target.finalities){target.options.enableAutoFreeze=false;}}}if(isDraftable(value,target.options)){// !case: assign the non-draft value
617
- target.finalities.draft.push(function(){var copy=target.type===3/* DraftType.Set */?target.setMap:target.copy;if(isEqual(get(copy,key),value)){finalizeAssigned(target,key);}});}}function generateArrayPatches(proxyState,basePath,patches,inversePatches,pathAsArray){var original=proxyState.original,assignedMap=proxyState.assignedMap,options=proxyState.options;var copy=proxyState.copy;if(copy.length<original.length){var _ref3=[copy,original];original=_ref3[0];copy=_ref3[1];var _ref4=[inversePatches,patches];patches=_ref4[0];inversePatches=_ref4[1];}for(var index=0;index<original.length;index+=1){if(assignedMap.get(index.toString())&&copy[index]!==original[index]){var _path=basePath.concat([index]);var path=escapePath(_path,pathAsArray);patches.push({op:Operation.Replace,path:path,// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
618
- value:cloneIfNeeded(copy[index])});inversePatches.push({op:Operation.Replace,path:path,// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
619
- value:cloneIfNeeded(original[index])});}}for(var _index2=original.length;_index2<copy.length;_index2+=1){var _path2=basePath.concat([_index2]);var _path3=escapePath(_path2,pathAsArray);patches.push({op:Operation.Add,path:_path3,// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
620
- value:cloneIfNeeded(copy[_index2])});}if(original.length<copy.length){// https://www.rfc-editor.org/rfc/rfc6902#appendix-A.4
621
- // For performance, here we only generate an operation that replaces the length of the array,
622
- // which is inconsistent with JSON Patch specification
623
- var _options$enablePatche=options.enablePatches.arrayLengthAssignment,arrayLengthAssignment=_options$enablePatche===undefined?true:_options$enablePatche;if(arrayLengthAssignment){var _path4=basePath.concat(["length"]);var _path5=escapePath(_path4,pathAsArray);inversePatches.push({op:Operation.Replace,path:_path5,value:original.length});}else {for(var _index3=copy.length;original.length<_index3;_index3-=1){var _path6=basePath.concat([_index3-1]);var _path7=escapePath(_path6,pathAsArray);inversePatches.push({op:Operation.Remove,path:_path7});}}}}function generatePatchesFromAssigned(_ref5,basePath,patches,inversePatches,pathAsArray){var original=_ref5.original,copy=_ref5.copy,assignedMap=_ref5.assignedMap;assignedMap.forEach(function(assignedValue,key){var originalValue=get(original,key);var value=cloneIfNeeded(get(copy,key));var op=!assignedValue?Operation.Remove:has(original,key)?Operation.Replace:Operation.Add;if(isEqual(originalValue,value)&&op===Operation.Replace)return;var _path=basePath.concat(key);var path=escapePath(_path,pathAsArray);patches.push(op===Operation.Remove?{op:op,path:path}:{op:op,path:path,value:value});inversePatches.push(op===Operation.Add?{op:Operation.Remove,path:path}:op===Operation.Remove?{op:Operation.Add,path:path,value:originalValue}:{op:Operation.Replace,path:path,value:originalValue});});}function generateSetPatches(_ref6,basePath,patches,inversePatches,pathAsArray){var original=_ref6.original,copy=_ref6.copy;var index=0;original.forEach(function(value){if(!copy.has(value)){var _path=basePath.concat([index]);var path=escapePath(_path,pathAsArray);patches.push({op:Operation.Remove,path:path,value:value});inversePatches.unshift({op:Operation.Add,path:path,value:value});}index+=1;});index=0;copy.forEach(function(value){if(!original.has(value)){var _path=basePath.concat([index]);var path=escapePath(_path,pathAsArray);patches.push({op:Operation.Add,path:path,value:value});inversePatches.unshift({op:Operation.Remove,path:path,value:value});}index+=1;});}function generatePatches(proxyState,basePath,patches,inversePatches){var _proxyState$options$e=proxyState.options.enablePatches.pathAsArray,pathAsArray=_proxyState$options$e===undefined?true:_proxyState$options$e;switch(proxyState.type){case 0/* DraftType.Object */:case 2/* DraftType.Map */:return generatePatchesFromAssigned(proxyState,basePath,patches,inversePatches,pathAsArray);case 1/* DraftType.Array */:return generateArrayPatches(proxyState,basePath,patches,inversePatches,pathAsArray);case 3/* DraftType.Set */:return generateSetPatches(proxyState,basePath,patches,inversePatches,pathAsArray)}}var checkReadable=function checkReadable(value,options){var ignoreCheckDraftable=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(_typeof(value)==="object"&&value!==null&&(!isDraftable(value,options)||ignoreCheckDraftable)&&true){throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")}};var mapHandler=_defineProperty({get size(){var current=latest(getProxyDraft(this));return current.size},has:function has(key){return latest(getProxyDraft(this)).has(key)},set:function set(key,value){var target=getProxyDraft(this);var source=latest(target);if(!source.has(key)||!isEqual(source.get(key),value)){ensureShallowCopy(target);markChanged(target);target.assignedMap.set(key,true);target.copy.set(key,value);markFinalization(target,key,value,generatePatches);}return this},"delete":function _delete(key){if(!this.has(key)){return false}var target=getProxyDraft(this);ensureShallowCopy(target);markChanged(target);if(target.original.has(key)){target.assignedMap.set(key,false);}else {target.assignedMap["delete"](key);}target.copy["delete"](key);return true},clear:function clear(){var target=getProxyDraft(this);if(!this.size)return;ensureShallowCopy(target);markChanged(target);target.assignedMap=new Map;var _iterator5=_createForOfIteratorHelper(target.original),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var _step5$value=_slicedToArray(_step5.value,1),key=_step5$value[0];target.assignedMap.set(key,false);}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}target.copy.clear();},forEach:function forEach(callback,thisArg){var _this=this;var target=getProxyDraft(this);latest(target).forEach(function(_value,_key){callback.call(thisArg,_this.get(_key),_key,_this);});},get:function get(key){var _a,_b;var target=getProxyDraft(this);var value=latest(target).get(key);var mutable=((_b=(_a=target.options).mark)===null||_b===undefined?undefined:_b.call(_a,value,dataTypes))===dataTypes.mutable;if(target.options.strict){checkReadable(value,target.options,mutable);}if(mutable){return value}if(target.finalized||!isDraftable(value,target.options)){return value}// drafted or reassigned
624
- if(value!==target.original.get(key)){return value}var draft=internal.createDraft({original:value,parentDraft:target,key:key,finalities:target.finalities,options:target.options});ensureShallowCopy(target);target.copy.set(key,draft);return draft},keys:function keys(){return latest(getProxyDraft(this)).keys()},values:function values(){var _this2=this;var iterator=this.keys();return _defineProperty(_defineProperty({},iteratorSymbol,function(){return _this2.values()}),"next",function next(){var result=iterator.next();if(result.done)return result;var value=_this2.get(result.value);return {done:false,value:value}})},entries:function entries(){var _this3=this;var iterator=this.keys();return _defineProperty(_defineProperty({},iteratorSymbol,function(){return _this3.entries()}),"next",function next(){var result=iterator.next();if(result.done)return result;var value=_this3.get(result.value);return {done:false,value:[result.value,value]}})}},iteratorSymbol,function(){return this.entries()});var mapHandlerKeys=Reflect.ownKeys(mapHandler);var getNextIterator=function getNextIterator(target,iterator,_ref9){var isValuesIterator=_ref9.isValuesIterator;return function(){var _a,_b;var result=iterator.next();if(result.done)return result;var key=result.value;var value=target.setMap.get(key);var currentDraft=getProxyDraft(value);var mutable=((_b=(_a=target.options).mark)===null||_b===undefined?undefined:_b.call(_a,value,dataTypes))===dataTypes.mutable;if(target.options.strict){checkReadable(key,target.options,mutable);}if(!mutable&&!currentDraft&&isDraftable(key,target.options)&&!target.finalized&&target.original.has(key)){// draft a draftable original set item
625
- var proxy=internal.createDraft({original:key,parentDraft:target,key:key,finalities:target.finalities,options:target.options});target.setMap.set(key,proxy);value=proxy;}else if(currentDraft){// drafted
626
- value=currentDraft.proxy;}return {done:false,value:isValuesIterator?value:[value,value]}}};var setHandler=_defineProperty(_defineProperty({get size(){var target=getProxyDraft(this);return target.setMap.size},has:function has(value){var target=getProxyDraft(this);// reassigned or non-draftable values
627
- if(target.setMap.has(value))return true;ensureShallowCopy(target);var valueProxyDraft=getProxyDraft(value);// drafted
628
- if(valueProxyDraft&&target.setMap.has(valueProxyDraft.original))return true;return false},add:function add(value){var target=getProxyDraft(this);if(!this.has(value)){ensureShallowCopy(target);markChanged(target);target.assignedMap.set(value,true);target.setMap.set(value,value);markFinalization(target,value,value,generatePatches);}return this},"delete":function _delete(value){if(!this.has(value)){return false}var target=getProxyDraft(this);ensureShallowCopy(target);markChanged(target);var valueProxyDraft=getProxyDraft(value);if(valueProxyDraft&&target.setMap.has(valueProxyDraft.original)){// delete drafted
629
- target.assignedMap.set(valueProxyDraft.original,false);return target.setMap["delete"](valueProxyDraft.original)}if(!valueProxyDraft&&target.setMap.has(value)){// non-draftable values
630
- target.assignedMap.set(value,false);}else {// reassigned
631
- target.assignedMap["delete"](value);}// delete reassigned or non-draftable values
632
- return target.setMap["delete"](value)},clear:function clear(){if(!this.size)return;var target=getProxyDraft(this);ensureShallowCopy(target);markChanged(target);var _iterator6=_createForOfIteratorHelper(target.original),_step6;try{for(_iterator6.s();!(_step6=_iterator6.n()).done;){var value=_step6.value;target.assignedMap.set(value,false);}}catch(err){_iterator6.e(err);}finally{_iterator6.f();}target.setMap.clear();},values:function values(){var _this4=this;var target=getProxyDraft(this);ensureShallowCopy(target);var iterator=target.setMap.keys();return _defineProperty(_defineProperty({},Symbol.iterator,function(){return _this4.values()}),"next",getNextIterator(target,iterator,{isValuesIterator:true}))},entries:function entries(){var _this5=this;var target=getProxyDraft(this);ensureShallowCopy(target);var iterator=target.setMap.keys();return _defineProperty(_defineProperty({},Symbol.iterator,function(){return _this5.entries()}),"next",getNextIterator(target,iterator,{isValuesIterator:false}))},keys:function keys(){return this.values()}},iteratorSymbol,function(){return this.values()}),"forEach",function forEach(callback,thisArg){var iterator=this.values();var result=iterator.next();while(!result.done){callback.call(thisArg,result.value,result.value,this);result=iterator.next();}});if(Set.prototype.difference){// for compatibility with new Set methods
633
- // https://github.com/tc39/proposal-set-methods
634
- // And `https://github.com/tc39/proposal-set-methods/blob/main/details.md#symbolspecies` has some details about the `@@species` symbol.
635
- // So we can't use SubSet instance constructor to get the constructor of the SubSet instance.
636
- Object.assign(setHandler,{intersection:function intersection(other){return Set.prototype.intersection.call(new Set(this.values()),other)},union:function union(other){return Set.prototype.union.call(new Set(this.values()),other)},difference:function difference(other){return Set.prototype.difference.call(new Set(this.values()),other)},symmetricDifference:function symmetricDifference(other){return Set.prototype.symmetricDifference.call(new Set(this.values()),other)},isSubsetOf:function isSubsetOf(other){return Set.prototype.isSubsetOf.call(new Set(this.values()),other)},isSupersetOf:function isSupersetOf(other){return Set.prototype.isSupersetOf.call(new Set(this.values()),other)},isDisjointFrom:function isDisjointFrom(other){return Set.prototype.isDisjointFrom.call(new Set(this.values()),other)}});}var setHandlerKeys=Reflect.ownKeys(setHandler);var draftsCache=new WeakSet;var proxyHandler={get:function get(target,key,receiver){var _a,_b;var copy=(_a=target.copy)===null||_a===undefined?undefined:_a[key];// Improve draft reading performance by caching the draft copy.
637
- if(copy&&draftsCache.has(copy)){return copy}if(key===PROXY_DRAFT)return target;var markResult;if(target.options.mark){// handle `Uncaught TypeError: Method get Map.prototype.size called on incompatible receiver #<Map>`
638
- // or `Uncaught TypeError: Method get Set.prototype.size called on incompatible receiver #<Set>`
639
- var _value5=key==="size"&&(target.original instanceof Map||target.original instanceof Set)?Reflect.get(target.original,key):Reflect.get(target.original,key,receiver);markResult=target.options.mark(_value5,dataTypes);if(markResult===dataTypes.mutable){if(target.options.strict){checkReadable(_value5,target.options,true);}return _value5}}var source=latest(target);if(source instanceof Map&&mapHandlerKeys.includes(key)){if(key==="size"){return Object.getOwnPropertyDescriptor(mapHandler,"size").get.call(target.proxy)}var handle=mapHandler[key];if(handle){return handle.bind(target.proxy)}}if(source instanceof Set&&setHandlerKeys.includes(key)){if(key==="size"){return Object.getOwnPropertyDescriptor(setHandler,"size").get.call(target.proxy)}var _handle=setHandler[key];if(_handle){return _handle.bind(target.proxy)}}if(!has(source,key)){var desc=getDescriptor(source,key);return desc?"value"in desc?desc.value:// !case: support for getter
640
- (_b=desc.get)===null||_b===undefined?undefined:_b.call(target.proxy):undefined}var value=source[key];if(target.options.strict){checkReadable(value,target.options);}if(target.finalized||!isDraftable(value,target.options)){return value}// Ensure that the assigned values are not drafted
641
- if(value===peek(target.original,key)){ensureShallowCopy(target);target.copy[key]=createDraft({original:target.original[key],parentDraft:target,key:target.type===1/* DraftType.Array */?Number(key):key,finalities:target.finalities,options:target.options});// !case: support for custom shallow copy function
642
- if(typeof markResult==="function"){var subProxyDraft=getProxyDraft(target.copy[key]);ensureShallowCopy(subProxyDraft);// Trigger a custom shallow copy to update to a new copy
643
- markChanged(subProxyDraft);return subProxyDraft.copy}return target.copy[key]}return value},set:function set(target,key,value){var _a;if(target.type===3/* DraftType.Set */||target.type===2/* DraftType.Map */){throw new Error("Map/Set draft does not support any property assignment.")}var _key;if(target.type===1/* DraftType.Array */&&key!=="length"&&!(Number.isInteger(_key=Number(key))&&_key>=0&&(key===0||_key===0||String(_key)===String(key)))){throw new Error("Only supports setting array indices and the 'length' property.")}var desc=getDescriptor(latest(target),key);if(desc===null||desc===undefined?undefined:desc.set){// !case: cover the case of setter
644
- desc.set.call(target.proxy,value);return true}var current=peek(latest(target),key);var currentProxyDraft=getProxyDraft(current);if(currentProxyDraft&&isEqual(currentProxyDraft.original,value)){// !case: ignore the case of assigning the original draftable value to a draft
645
- target.copy[key]=value;target.assignedMap=(_a=target.assignedMap)!==null&&_a!==undefined?_a:new Map;target.assignedMap.set(key,false);return true}// !case: handle new props with value 'undefined'
646
- if(isEqual(value,current)&&(value!==undefined||has(target.original,key)))return true;ensureShallowCopy(target);markChanged(target);if(has(target.original,key)&&isEqual(value,target.original[key])){// !case: handle the case of assigning the original non-draftable value to a draft
647
- target.assignedMap["delete"](key);}else {target.assignedMap.set(key,true);}target.copy[key]=value;markFinalization(target,key,value,generatePatches);return true},has:function has(target,key){return key in latest(target)},ownKeys:function ownKeys(target){return Reflect.ownKeys(latest(target))},getOwnPropertyDescriptor:function getOwnPropertyDescriptor(target,key){var source=latest(target);var descriptor=Reflect.getOwnPropertyDescriptor(source,key);if(!descriptor)return descriptor;return {writable:true,configurable:target.type!==1/* DraftType.Array */||key!=="length",enumerable:descriptor.enumerable,value:source[key]}},getPrototypeOf:function getPrototypeOf(target){return Reflect.getPrototypeOf(target.original)},setPrototypeOf:function setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty:function defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty:function deleteProperty(target,key){var _a;if(target.type===1/* DraftType.Array */){return proxyHandler.set.call(this,target,key,undefined,target.proxy)}if(peek(target.original,key)!==undefined||key in target.original){// !case: delete an existing key
648
- ensureShallowCopy(target);markChanged(target);target.assignedMap.set(key,false);}else {target.assignedMap=(_a=target.assignedMap)!==null&&_a!==undefined?_a:new Map;// The original non-existent key has been deleted
649
- target.assignedMap["delete"](key);}if(target.copy)delete target.copy[key];return true}};function createDraft(createDraftOptions){var original=createDraftOptions.original,parentDraft=createDraftOptions.parentDraft,key=createDraftOptions.key,finalities=createDraftOptions.finalities,options=createDraftOptions.options;var type=getType(original);var proxyDraft={type:type,finalized:false,parent:parentDraft,original:original,copy:null,proxy:null,finalities:finalities,options:options,// Mapping of draft Set items to their corresponding draft values.
650
- setMap:type===3/* DraftType.Set */?new Map(original.entries()):undefined};// !case: undefined as a draft map key
651
- if(key||"key"in createDraftOptions){proxyDraft.key=key;}var _Proxy$revocable=Proxy.revocable(type===1/* DraftType.Array */?Object.assign([],proxyDraft):proxyDraft,proxyHandler),proxy=_Proxy$revocable.proxy,revoke=_Proxy$revocable.revoke;finalities.revoke.push(revoke);draftsCache.add(proxy);proxyDraft.proxy=proxy;if(parentDraft){var target=parentDraft;target.finalities.draft.push(function(patches,inversePatches){var _a,_b;var oldProxyDraft=getProxyDraft(proxy);// if target is a Set draft, `setMap` is the real Set copies proxy mapping.
652
- var copy=target.type===3/* DraftType.Set */?target.setMap:target.copy;var draft=get(copy,key);var proxyDraft=getProxyDraft(draft);if(proxyDraft){// assign the updated value to the copy object
653
- var updatedValue=proxyDraft.original;if(proxyDraft.operated){updatedValue=getValue(draft);}finalizeSetValue(proxyDraft);finalizePatches(proxyDraft,generatePatches,patches,inversePatches);if(target.options.enableAutoFreeze){target.options.updatedValues=(_a=target.options.updatedValues)!==null&&_a!==undefined?_a:new WeakMap;target.options.updatedValues.set(updatedValue,proxyDraft.original);}// final update value
654
- set(copy,key,updatedValue);}// !case: handle the deleted key
655
- (_b=oldProxyDraft.callbacks)===null||_b===undefined?undefined:_b.forEach(function(callback){callback(patches,inversePatches);});});}else {// !case: handle the root draft
656
- var _target=getProxyDraft(proxy);_target.finalities.draft.push(function(patches,inversePatches){finalizeSetValue(_target);finalizePatches(_target,generatePatches,patches,inversePatches);});}return proxy}internal.createDraft=createDraft;function finalizeDraft(result,returnedValue,patches,inversePatches,enableAutoFreeze){var _a;var proxyDraft=getProxyDraft(result);var original=(_a=proxyDraft===null||proxyDraft===undefined?undefined:proxyDraft.original)!==null&&_a!==undefined?_a:result;var hasReturnedValue=!!returnedValue.length;if(proxyDraft===null||proxyDraft===undefined?undefined:proxyDraft.operated){while(proxyDraft.finalities.draft.length>0){var finalize=proxyDraft.finalities.draft.pop();finalize(patches,inversePatches);}}var state=hasReturnedValue?returnedValue[0]:proxyDraft?proxyDraft.operated?proxyDraft.copy:proxyDraft.original:result;if(proxyDraft)revokeProxy(proxyDraft);if(enableAutoFreeze){deepFreeze(state,state,proxyDraft===null||proxyDraft===undefined?undefined:proxyDraft.options.updatedValues);}return [state,patches&&hasReturnedValue?[{op:Operation.Replace,path:[],value:returnedValue[0]}]:patches,inversePatches&&hasReturnedValue?[{op:Operation.Replace,path:[],value:original}]:inversePatches]}function draftify(baseState,options){var _a;var finalities={draft:[],revoke:[],handledSet:new WeakSet};var patches;var inversePatches;if(options.enablePatches){patches=[];inversePatches=[];}var isMutable=((_a=options.mark)===null||_a===undefined?undefined:_a.call(options,baseState,dataTypes))===dataTypes.mutable||!isDraftable(baseState,options);var draft=isMutable?baseState:createDraft({original:baseState,parentDraft:null,finalities:finalities,options:options});return [draft,function(){var returnedValue=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var _finalizeDraft=finalizeDraft(draft,returnedValue,patches,inversePatches,options.enableAutoFreeze),_finalizeDraft2=_slicedToArray(_finalizeDraft,3),finalizedState=_finalizeDraft2[0],finalizedPatches=_finalizeDraft2[1],finalizedInversePatches=_finalizeDraft2[2];return options.enablePatches?[finalizedState,finalizedPatches,finalizedInversePatches]:finalizedState}]}function handleReturnValue(options){var rootDraft=options.rootDraft,value=options.value,_options$useRawReturn=options.useRawReturn,useRawReturn=_options$useRawReturn===undefined?false:_options$useRawReturn,_options$isRoot=options.isRoot,isRoot=_options$isRoot===undefined?true:_options$isRoot;forEach(value,function(key,item,source){var proxyDraft=getProxyDraft(item);// just handle the draft which is created by the same rootDraft
657
- if(proxyDraft&&rootDraft&&proxyDraft.finalities===rootDraft.finalities){options.isContainDraft=true;var currentValue=proxyDraft.original;// final update value, but just handle return value
658
- if(source instanceof Set){var arr=Array.from(source);source.clear();arr.forEach(function(_item){return source.add(key===_item?currentValue:_item)});}else {set(source,key,currentValue);}}else if(_typeof(item)==="object"&&item!==null){options.value=item;options.isRoot=false;handleReturnValue(options);}});if(isRoot){if(!options.isContainDraft)console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance.");if(useRawReturn){console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value.");}}}function getCurrent(target){var _a;var proxyDraft=getProxyDraft(target);if(!isDraftable(target,proxyDraft===null||proxyDraft===undefined?undefined:proxyDraft.options))return target;var type=getType(target);if(proxyDraft&&!proxyDraft.operated)return proxyDraft.original;var currentValue;function ensureShallowCopy(){currentValue=type===2/* DraftType.Map */?!isBaseMapInstance(target)?new(Object.getPrototypeOf(target).constructor)(target):new Map(target):type===3/* DraftType.Set */?Array.from(proxyDraft.setMap.values()):shallowCopy(target,proxyDraft===null||proxyDraft===undefined?undefined:proxyDraft.options);}if(proxyDraft){// It's a proxy draft, let's create a shallow copy eagerly
659
- proxyDraft.finalized=true;try{ensureShallowCopy();}finally{proxyDraft.finalized=false;}}else {// It's not a proxy draft, let's use the target directly and let's see
660
- // lazily if we need to create a shallow copy
661
- currentValue=target;}forEach(currentValue,function(key,value){if(proxyDraft&&isEqual(get(proxyDraft.original,key),value))return;var newValue=getCurrent(value);if(newValue!==value){if(currentValue===target)ensureShallowCopy();set(currentValue,key,newValue);}});if(type===3/* DraftType.Set */){var value=(_a=proxyDraft===null||proxyDraft===undefined?undefined:proxyDraft.original)!==null&&_a!==undefined?_a:currentValue;return !isBaseSetInstance(value)?new(Object.getPrototypeOf(value).constructor)(currentValue):new Set(currentValue)}return currentValue}function current(target){if(!isDraft(target)){throw new Error("current() is only used for Draft, parameter: ".concat(target))}return getCurrent(target)}/**
662
- * `makeCreator(options)` to make a creator function.
663
- *
664
- * ## Example
665
- *
666
- * ```ts
667
- * import { makeCreator } from '../index';
668
- *
669
- * const baseState = { foo: { bar: 'str' }, arr: [] };
670
- * const create = makeCreator({ enableAutoFreeze: true });
671
- * const state = create(
672
- * baseState,
673
- * (draft) => {
674
- * draft.foo.bar = 'str2';
675
- * },
676
- * );
677
- *
678
- * expect(state).toEqual({ foo: { bar: 'str2' }, arr: [] });
679
- * expect(state).not.toBe(baseState);
680
- * expect(state.foo).not.toBe(baseState.foo);
681
- * expect(state.arr).toBe(baseState.arr);
682
- * expect(Object.isFrozen(state)).toBeTruthy();
683
- * ```
684
- */var makeCreator=function makeCreator(arg){return function create(arg0,arg1,arg2){var _a,_b,_c;if(typeof arg0==="function"&&typeof arg1!=="function"){return function(base){var _this6=this;for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key2=1;_key2<_len;_key2++){args[_key2-1]=arguments[_key2];}return create(base,function(draft){return arg0.call.apply(arg0,[_this6,draft].concat(args))},arg1)}}var base=arg0;var mutate=arg1;var options=arg2;if(typeof arg1!=="function"){options=arg1;}if(options!==undefined&&Object.prototype.toString.call(options)!=="[object Object]"){throw new Error("Invalid options: ".concat(options,", 'options' should be an object."))}options=Object.assign(Object.assign({},arg),options);var state=isDraft(base)?current(base):base;var mark=Array.isArray(options.mark)?function(value,types){var _iterator7=_createForOfIteratorHelper(options.mark),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var _mark=_step7.value;if(typeof _mark!=="function"){throw new Error("Invalid mark: ".concat(_mark,", 'mark' should be a function."))}var _result=_mark(value,types);if(_result){return _result}}}catch(err){_iterator7.e(err);}finally{_iterator7.f();}return}:options.mark;var enablePatches=(_a=options.enablePatches)!==null&&_a!==undefined?_a:false;var strict=(_b=options.strict)!==null&&_b!==undefined?_b:false;var enableAutoFreeze=(_c=options.enableAutoFreeze)!==null&&_c!==undefined?_c:false;var _options={enableAutoFreeze:enableAutoFreeze,mark:mark,strict:strict,enablePatches:enablePatches};if(!isDraftable(state,_options)&&_typeof(state)==="object"&&state!==null){throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.")}var _draftify=draftify(state,_options),_draftify2=_slicedToArray(_draftify,2),draft=_draftify2[0],finalize=_draftify2[1];if(typeof arg1!=="function"){if(!isDraftable(state,_options)){throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.")}return [draft,finalize]}var result;try{result=mutate(draft);}catch(error){revokeProxy(getProxyDraft(draft));throw error}var returnValue=function returnValue(value){var proxyDraft=getProxyDraft(draft);if(!isDraft(value)){if(value!==undefined&&!isEqual(value,draft)&&(proxyDraft===null||proxyDraft===undefined?undefined:proxyDraft.operated)){throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.")}var rawReturnValue=value===null||value===undefined?undefined:value[RAW_RETURN_SYMBOL];if(rawReturnValue){var _value=rawReturnValue[0];if(_options.strict&&_typeof(value)==="object"&&value!==null){handleReturnValue({rootDraft:proxyDraft,value:value,useRawReturn:true});}return finalize([_value])}if(value!==undefined){if(_typeof(value)==="object"&&value!==null){handleReturnValue({rootDraft:proxyDraft,value:value});}return finalize([value])}}if(value===draft||value===undefined){return finalize([])}var returnedProxyDraft=getProxyDraft(value);if(_options===returnedProxyDraft.options){if(returnedProxyDraft.operated){throw new Error("Cannot return a modified child draft.")}return finalize([current(value)])}return finalize([value])};if(result instanceof Promise){return result.then(returnValue,function(error){revokeProxy(getProxyDraft(draft));throw error})}return returnValue(result)}};/**
685
- * `create(baseState, callback, options)` to create the next state
686
- *
687
- * ## Example
688
- *
689
- * ```ts
690
- * import { create } from '../index';
691
- *
692
- * const baseState = { foo: { bar: 'str' }, arr: [] };
693
- * const state = create(
694
- * baseState,
695
- * (draft) => {
696
- * draft.foo.bar = 'str2';
697
- * },
698
- * );
699
- *
700
- * expect(state).toEqual({ foo: { bar: 'str2' }, arr: [] });
701
- * expect(state).not.toBe(baseState);
702
- * expect(state.foo).not.toBe(baseState.foo);
703
- * expect(state.arr).toBe(baseState.arr);
704
- * ```
705
- */var create=makeCreator();Object.prototype.constructor.toString();
706
-
707
- function produceState(state,fn){state.set(create(state.get(),fn));}
708
-
709
- var RumiousState=/*#__PURE__*/function(){function RumiousState(target){var reactor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;_classCallCheck(this,RumiousState);this.value=target;this.reactor=reactor!==null&&reactor!==undefined?reactor:new RumiousReactor(this,[]);}return _createClass(RumiousState,[{key:"produce",value:function produce(recipe){return produceState(this,recipe)}},{key:"reducer",value:function reducer(){var computedObj;if(arguments.length===1){computedObj=new RumiousReducer(this,"",arguments.length<=0?undefined:arguments[0]);}else {computedObj=new RumiousReducer(this,arguments.length<=0?undefined:arguments[0],arguments.length<=1?undefined:arguments[1]);}return computedObj.trigger.bind(computedObj)}},{key:"setObjectByPath",value:function setObjectByPath(){var path=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var value=arguments.length>1?arguments[1]:undefined;if(path.length==0){this.value=value;return}if(typeof path!=="string"||!path){throw new Error("Invalid path")}var keys=path.split(".");var obj=this.value;for(var i=0;i<keys.length-1;i++){var key=keys[i];if(!(key in obj)){obj[key]={};}obj=obj[key];}obj[keys[keys.length-1]]=value;}},{key:"set",value:function set(){if(arguments.length===1){this.value=arguments.length<=0?undefined:arguments[0];}else {var path=arguments.length<=0?undefined:arguments[0];var value=arguments.length<=1?undefined:arguments[1];this.setObjectByPath(path,value);}this.reactor.react();}},{key:"get",value:function get(){return this.value}}])}();function createState(value){return new RumiousState(value)}function isState(obj){return obj instanceof RumiousState}
710
-
711
- function watcher(state,callback){state.reactor.addBinding(callback);}
712
-
713
- exports.RumiousApp = RumiousApp;
714
- exports.RumiousComponent = RumiousComponent;
715
- exports.RumiousComponentElement = RumiousComponentElement;
716
- exports.RumiousState = RumiousState;
717
- exports.createComponentElement = createComponentElement;
718
- exports.createState = createState;
719
- exports.isComponent = isComponent;
720
- exports.isState = isState;
721
- exports.watcher = watcher;
722
-
723
- return exports;
724
-
725
- })({});
1
+ var Rumious=function(e){"use strict";class t{constructor(e){this.target=e}find(e){return this.target[e]}get(e){return this.target[e]}}class n{constructor(){this.element=null,this.props={},this.renderContext=new t(this),this.renderer=null,this.wrapped=null}prepare(e,t,n={},r=null){this.element=e,this.props=t,this.renderer=r,this.wrapped=n}template(){return{}}requestRender(){let e=this.template(),t=this.renderer(e,document.createDocumentFragment(),this.renderContext);this.element.appendChild(t),this.onRender()}async requestCleanUp(){if(this.element){let e=this.element.cloneNode(!0);for(this.element.replaceWith(e),this.element=e;this.element.firstChild;)this.element.removeChild(this.element.firstChild)}}onInit(){}onCreate(){}onRender(){}onUpdate(){}onDestroy(){}}function r(e){return Object.getPrototypeOf(e)===n}class o{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class i{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function s(e){return"function"==typeof e}class a{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){}}class l extends a{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return null;const n=t.get(e);if(!s(n))throw`${e} is not a function!`;return n.bind(t.target)};if("string"===this.value.type)n=r(this.value.value);else if("expression"===this.value.type){if(n=this.value.value,!s(n))throw"Event handler requires a function!"}else"dynamic_value"===this.value.type&&(n=r(this.value.value.objectName));n&&e.addEventListener(this.name,n)}}class c extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw"Invalid props value: Directive bind: require a RumiousState Object !";t.reactor.addBinding((()=>{let n=t.get();this.bindAttr(e,n)})),this.bindAttr(e,t.get())}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target),r=t.find(this.value.value.objectName);if(!r)throw"Invalid props value: Directive bind: require a RumiousState Object !";r.reactor.addBinding((()=>{let n=this.value.evaluator?.(t.target);this.bindAttr(e,n)})),this.bindAttr(e,n)}}normalizeValue(e){return"object"==typeof e?e.toString?.()??"":e}async bindAttr(e,t){"html"===this.name&&(e.innerHTML=this.normalizeValue(t))}}class u extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw"Invalid props value: Directive ref: require a RumiousRef Object !";t.set(e)}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target);if(!n)throw"Invalid props value: Directive ref: require a RumiousRef Object !";n.set(e)}}}class p extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw"Invalid props value: Directive childsRef: require a RumiousChildRef Object !";t.set(e)}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target);if(!n)throw"Invalid props value: Directive childsRef: require a RumiousChildRef Object !";n.set(e)}}}const f={on:(e,t)=>new l("on",e,t),bind:(e,t)=>new c("bind",e,t),ref:(e,t,n="element")=>new u("ref",e,t),childsRef:(e,t)=>new p("childsRef",e,t)};function h(...e){return new o("FRAGMENT",{},d(e))}function d(e){return e.map((e=>"object"==typeof e?e:new o("TEXT_ELEMENT",{nodeValue:e},[])))}window.RUMIOUS_JSX_SUPPORT={createElement:function(e,t,...n){return r(e)?function(e,t,n){return new o("COMPONENT",{component:e,...t},new i(d(n)))}(e,t,n):e===h?h(...n):new o(e,t||{},d(n))},createFragment:h,createDirective:function(e,t,n){return function(e,t,n){return f[e]?.(t,n)}(e,t,n)}};class y extends HTMLElement{constructor(){super(),this.instance=null,this.ref=null}setRef(e){this.ref=e}init(e,t,n={},r){this.instance=new e,this.instance.prepare(this,t,n,r),this.instance.onInit()}connectedCallback(){this.instance.onCreate(),this.instance.requestRender(),this.instance.forwardRef=this.ref??{}}disconnectCallback(){this.instance.onDestroy(),this.instance.requestCleanUp()}}function g(){return document.createElement("a-component")}function v(e,t,n){t.init(e,n)}function m(e,t,n={}){if(!e)return t;let r;return"COMPONENT"===e.type?function(e,t,n,r){const o=function(e,t,n,r){const o=g();return o.init(e,t,n,r),o}(e.props.component,e.props,e.children,n);return Object.entries(e.props||{}).forEach((([e,t])=>{t instanceof a&&v(o,t,r)})),t.appendChild(o),t}(e,t,m,n):"FRAGMENT"===e.type||"ELEMENT_LIST"===e.type?function(e,t,n){return e.children.forEach((e=>m(e,t,n))),t}(e,t,n):(r="TEXT_ELEMENT"===e.type?function(e){return document.createTextNode(e.props.nodeValue)}(e):function(e,t){const n=document.createElement(e.type);return Object.entries(e.props||{}).forEach((([e,r])=>{e.startsWith("on")&&/^[a-zA-Z]+([A-Z][a-z]*)*$/.test(e)?n.addEventListener(e.substring(2).toLowerCase(),r):function(e,t,n,r){e.nodeType===Node.TEXT_NODE?e.nodeValue=n:n instanceof a?v(e,n,r):e.setAttribute(t,n)}(n,e,r,t)})),n}(e,n),e.children.forEach((e=>m(e,r,n))),t.appendChild(r),t)}window.customElements.define("a-component",y);class b{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}addBinding(e){this.bindings.push(e)}}class w{constructor(e,t="",n){this.state=e,this.path=t,this.fn=n}trigger(...e){let t=this.fn(...e);this.state.set(this.path,t)}}const O="remove",M="replace",E="add",j=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),S=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),k=Symbol.iterator,R={mutable:"mutable",immutable:"immutable"},A={};function P(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function x(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const e=Reflect.getOwnPropertyDescriptor(n,t);if(e)return e;n=Reflect.getPrototypeOf(n)}}}function C(e){return Object.getPrototypeOf(e)===Set.prototype}function z(e){return Object.getPrototypeOf(e)===Map.prototype}function D(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function T(e){return!!_(e)}function _(e){return"object"!=typeof e?null:null==e?void 0:e[j]}function I(e){var t;const n=_(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function N(e,t){if(!e||"object"!=typeof e)return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(null==t?void 0:t.mark)&&((n=t.mark(e,R))===R.immutable||"function"==typeof n)}function F(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=_(L(n,e.key));if(null!==r&&(null==r?void 0:r.original)!==e.original)return null;const o=3===e.parent.type,i=o?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(o&&n.size>i||P(n,i)))return null;t.push(i)}if(e.parent)return F(e.parent,t);t.reverse();try{!function(e,t){for(let n=0;n<t.length-1;n+=1){const r=t[n];if("object"!=typeof(e=L(3===V(e)?Array.from(e):e,r)))throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}}(e.copy,t)}catch(e){return null}return t}function V(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function L(e,t){return 2===V(e)?e.get(t):e[t]}function q(e,t,n){2===V(e)?e.set(t,n):e[t]=n}function U(e,t){const n=_(e);return(n?D(n):e)[t]}function $(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function W(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function B(e,t){return t?e:[""].concat(e).map((e=>{const t=`${e}`;return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}const K=Object.prototype.propertyIsEnumerable;function X(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return C(e)?Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values()):new(0,Object.getPrototypeOf(e).constructor)(e.values());if(e instanceof Map)return z(e)?new Map(e):new(0,Object.getPrototypeOf(e).constructor)(e);if((null==t?void 0:t.mark)&&(n=t.mark(e,R),void 0!==n)&&n!==R.mutable){if(n===R.immutable)return function(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);r.enumerable&&r.configurable&&r.writable?t[n]=e[n]:(r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r))})),t}(e);if("function"==typeof n){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype){const t={};return Object.keys(e).forEach((n=>{t[n]=e[n]})),Object.getOwnPropertySymbols(e).forEach((n=>{K.call(e,n)&&(t[n]=e[n])})),t}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function H(e){e.copy||(e.copy=X(e.original,e.options))}function Y(e){if(!N(e))return I(e);if(Array.isArray(e))return e.map(Y);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,Y(t)]));return z(e)?new Map(t):new(0,Object.getPrototypeOf(e).constructor)(t)}if(e instanceof Set){const t=Array.from(e).map(Y);return C(e)?new Set(t):new(0,Object.getPrototypeOf(e).constructor)(t)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=Y(e[n]);return t}function G(e){return T(e)?Y(e):e}function Z(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&Z(e.parent))}function J(){throw new Error("Cannot modify frozen object")}function Q(e,t,n,r,o){{n=null!=n?n:new WeakMap,r=null!=r?r:[],o=null!=o?o:[];const i=n.has(e)?n.get(e):e;if(r.length>0){const e=r.indexOf(i);if(i&&"object"==typeof i&&-1!==e){if(r[0]===i)throw new Error("Forbids circular reference");throw new Error(`Forbids circular reference: ~/${o.slice(0,e).map(((e,t)=>{if("symbol"==typeof e)return`[${e.toString()}]`;const n=r[t];return"object"==typeof e&&(n instanceof Map||n instanceof Set)?Array.from(n.keys()).indexOf(e):e})).join("/")}`)}r.push(i),o.push(t)}else r.push(i)}if(Object.isFrozen(e)||T(e))return r.pop(),void o.pop();switch(V(e)){case 2:for(const[t,i]of e)Q(t,t,n,r,o),Q(i,t,n,r,o);e.set=e.clear=e.delete=J;break;case 3:for(const t of e)Q(t,t,n,r,o);e.add=e.clear=e.delete=J;break;case 1:Object.freeze(e);let t=0;for(const i of e)Q(i,t,n,r,o),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{Q(e[t],t,n,r,o)}))}r.pop(),o.pop()}function ee(e,t){const n=V(e);if(0===n)Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)}));else if(1===n){let n=0;for(const r of e)t(n,r,e),n+=1}else e.forEach(((n,r)=>t(r,n,e)))}function te(e,t,n){if(T(e)||!N(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,o=r?new Map:void 0;if(t.add(e),ee(e,((i,s)=>{var a;if(T(s)){const t=_(s);H(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;q(r?o:e,i,n)}else te(s,t,n)})),o){const t=e,n=Array.from(t);t.clear(),n.forEach((e=>{t.add(o.has(e)?o.get(e):e)}))}}function ne(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&te(L(n,t),e.finalities.handledSet,e.options)}function re(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(I(t))})))}function oe(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const o=F(e);o&&t(e,o,n,r)}e.finalized=!0}}function ie(e,t,n,r){const o=_(n);o&&(o.callbacks||(o.callbacks=[]),o.callbacks.push(((i,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if($(L(l,t),n)){let n=o.original;o.copy&&(n=o.copy),re(e),oe(e,r,i,s),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(a=e.options.updatedValues)&&void 0!==a?a:new WeakMap,e.options.updatedValues.set(n,o.original)),q(l,t,n)}})),e.options.enableAutoFreeze&&o.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),N(n,e.options)&&e.finalities.draft.push((()=>{$(L(3===e.type?e.setMap:e.copy,t),n)&&ne(e,t)}))}function se(e,t,n,r){const{pathAsArray:o=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return function({original:e,copy:t,assignedMap:n},r,o,i,s){n.forEach(((n,a)=>{const l=L(e,a),c=G(L(t,a)),u=n?P(e,a)?M:E:O;if($(l,c)&&u===M)return;const p=B(r.concat(a),s);o.push(u===O?{op:u,path:p}:{op:u,path:p,value:c}),i.push(u===E?{op:O,path:p}:u===O?{op:E,path:p,value:l}:{op:M,path:p,value:l})}))}(e,t,n,r,o);case 1:return function(e,t,n,r,o){let{original:i,assignedMap:s,options:a}=e,l=e.copy;l.length<i.length&&([i,l]=[l,i],[n,r]=[r,n]);for(let e=0;e<i.length;e+=1)if(s.get(e.toString())&&l[e]!==i[e]){const s=B(t.concat([e]),o);n.push({op:M,path:s,value:G(l[e])}),r.push({op:M,path:s,value:G(i[e])})}for(let e=i.length;e<l.length;e+=1){const r=B(t.concat([e]),o);n.push({op:E,path:r,value:G(l[e])})}if(i.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=B(t.concat(["length"]),o);r.push({op:M,path:e,value:i.length})}else for(let e=l.length;i.length<e;e-=1){const n=B(t.concat([e-1]),o);r.push({op:O,path:n})}}}(e,t,n,r,o);case 3:return function({original:e,copy:t},n,r,o,i){let s=0;e.forEach((e=>{if(!t.has(e)){const t=B(n.concat([s]),i);r.push({op:O,path:t,value:e}),o.unshift({op:E,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=B(n.concat([s]),i);r.push({op:E,path:e,value:t}),o.unshift({op:O,path:e,value:t})}s+=1}))}(e,t,n,r,o)}}const ae=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!N(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},le={get size(){return D(_(this)).size},has(e){return D(_(this)).has(e)},set(e,t){const n=_(this),r=D(n);return r.has(e)&&$(r.get(e),t)||(H(n),Z(n),n.assignedMap.set(e,!0),n.copy.set(e,t),ie(n,e,t,se)),this},delete(e){if(!this.has(e))return!1;const t=_(this);return H(t),Z(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=_(this);if(this.size){H(e),Z(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){D(_(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=_(this),o=D(r).get(e),i=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,o,R))===R.mutable;if(r.options.strict&&ae(o,r.options,i),i)return o;if(r.finalized||!N(o,r.options))return o;if(o!==r.original.get(e))return o;const s=A.createDraft({original:o,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return H(r),r.copy.set(e,s),s},keys(){return D(_(this)).keys()},values(){const e=this.keys();return{[k]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[k]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[k](){return this.entries()}},ce=Reflect.ownKeys(le),ue=(e,t,{isValuesIterator:n})=>()=>{var r,o;const i=t.next();if(i.done)return i;const s=i.value;let a=e.setMap.get(s);const l=_(a),c=(null===(o=(r=e.options).mark)||void 0===o?void 0:o.call(r,a,R))===R.mutable;if(e.options.strict&&ae(s,e.options,c),c||l||!N(s,e.options)||e.finalized||!e.original.has(s))l&&(a=l.proxy);else{const t=A.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,t),a=t}return{done:!1,value:n?a:[a,a]}},pe={get size(){return _(this).setMap.size},has(e){const t=_(this);if(t.setMap.has(e))return!0;H(t);const n=_(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=_(this);return this.has(e)||(H(t),Z(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),ie(t,e,e,se)),this},delete(e){if(!this.has(e))return!1;const t=_(this);H(t),Z(t);const n=_(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=_(this);H(e),Z(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=_(this);H(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:ue(e,t,{isValuesIterator:!0})}},entries(){const e=_(this);H(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:ue(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[k](){return this.values()},forEach(e,t){const n=this.values();let r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(pe,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const fe=Reflect.ownKeys(pe),he=new WeakSet,de={get(e,t,n){var r,o;const i=null===(r=e.copy)||void 0===r?void 0:r[t];if(i&&he.has(i))return i;if(t===j)return e;let s;if(e.options.mark){const r="size"===t&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(r,R),s===R.mutable)return e.options.strict&&ae(r,e.options,!0),r}const a=D(e);if(a instanceof Map&&ce.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(le,"size").get.call(e.proxy);const n=le[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&fe.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(pe,"size").get.call(e.proxy);const n=pe[t];if(n)return n.bind(e.proxy)}if(!P(a,t)){const n=x(a,t);return n?"value"in n?n.value:null===(o=n.get)||void 0===o?void 0:o.call(e.proxy):void 0}const l=a[t];if(e.options.strict&&ae(l,e.options),e.finalized||!N(l,e.options))return l;if(l===U(e.original,t)){if(H(e),e.copy[t]=ye({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=_(e.copy[t]);return H(n),Z(n),n.copy}return e.copy[t]}return l},set(e,t,n){var r;if(3===e.type||2===e.type)throw new Error("Map/Set draft does not support any property assignment.");let o;if(1===e.type&&"length"!==t&&(!(Number.isInteger(o=Number(t))&&o>=0)||0!==t&&0!==o&&String(o)!==String(t)))throw new Error("Only supports setting array indices and the 'length' property.");const i=x(D(e),t);if(null==i?void 0:i.set)return i.set.call(e.proxy,n),!0;const s=U(D(e),t),a=_(s);return a&&$(a.original,n)?(e.copy[t]=n,e.assignedMap=null!==(r=e.assignedMap)&&void 0!==r?r:new Map,e.assignedMap.set(t,!1),!0):($(n,s)&&(void 0!==n||P(e.original,t))||(H(e),Z(e),P(e.original,t)&&$(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,ie(e,t,n,se)),!0)},has:(e,t)=>t in D(e),ownKeys:e=>Reflect.ownKeys(D(e)),getOwnPropertyDescriptor(e,t){const n=D(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},getPrototypeOf:e=>Reflect.getPrototypeOf(e.original),setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return 1===e.type?de.set.call(this,e,t,void 0,e.proxy):(void 0!==U(e.original,t)||t in e.original?(H(e),Z(e),e.assignedMap.set(t,!1)):(e.assignedMap=null!==(n=e.assignedMap)&&void 0!==n?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function ye(e){const{original:t,parentDraft:n,key:r,finalities:o,options:i}=e,s=V(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:o,options:i,setMap:3===s?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);const{proxy:l,revoke:c}=Proxy.revocable(1===s?Object.assign([],a):a,de);if(o.revoke.push(c),he.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var o,i;const s=_(l);let a=3===e.type?e.setMap:e.copy;const c=L(a,r),u=_(c);if(u){let i=u.original;u.operated&&(i=I(c)),re(u),oe(u,se,t,n),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(o=e.options.updatedValues)&&void 0!==o?o:new WeakMap,e.options.updatedValues.set(i,u.original)),q(a,r,i)}null===(i=s.callbacks)||void 0===i||i.forEach((e=>{e(t,n)}))}))}else{const e=_(l);e.finalities.draft.push(((t,n)=>{re(e),oe(e,se,t,n)}))}return l}function ge(e,t,n,r,o){var i;const s=_(e),a=null!==(i=null==s?void 0:s.original)&&void 0!==i?i:e,l=!!t.length;if(null==s?void 0:s.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);const c=l?t[0]:s?s.operated?s.copy:s.original:e;return s&&W(s),o&&Q(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:M,path:[],value:t[0]}]:n,r&&l?[{op:M,path:[],value:a}]:r]}function ve(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:o=!0}=e;ee(n,((n,r,o)=>{const i=_(r);if(i&&t&&i.finalities===t.finalities){e.isContainDraft=!0;const t=i.original;if(o instanceof Set){const e=Array.from(o);o.clear(),e.forEach((e=>o.add(n===e?t:e)))}else q(o,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,ve(e))})),o&&e.isContainDraft}function me(e){var t;const n=_(e);if(!N(e,null==n?void 0:n.options))return e;const r=V(e);if(n&&!n.operated)return n.original;let o;function i(){o=2===r?z(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):X(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{i()}finally{n.finalized=!1}}else o=e;if(ee(o,((t,r)=>{if(n&&$(L(n.original,t),r))return;const s=me(r);s!==r&&(o===e&&i(),q(o,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:o;return C(e)?new Set(o):new(Object.getPrototypeOf(e).constructor)(o)}return o}function be(e){if(!T(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return me(e)}A.createDraft=ye;const we=function e(t,n,r){var o,i,s;if("function"==typeof t&&"function"!=typeof n)return function(r,...o){return e(r,(e=>t.call(this,e,...o)),n)};const a=t,l=n;let c=r;if("function"!=typeof n&&(c=n),void 0!==c&&"[object Object]"!==Object.prototype.toString.call(c))throw new Error(`Invalid options: ${c}, 'options' should be an object.`);c=Object.assign(Object.assign({},void 0),c);const u=T(a)?be(a):a,p=Array.isArray(c.mark)?(e,t)=>{for(const n of c.mark){if("function"!=typeof n)throw new Error(`Invalid mark: ${n}, 'mark' should be a function.`);const r=n(e,t);if(r)return r}}:c.mark,f=null!==(o=c.enablePatches)&&void 0!==o&&o,h=null!==(i=c.strict)&&void 0!==i&&i,d={enableAutoFreeze:null!==(s=c.enableAutoFreeze)&&void 0!==s&&s,mark:p,strict:h,enablePatches:f};if(!N(u,d)&&"object"==typeof u&&null!==u)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[y,g]=function(e,t){var n;const r={draft:[],revoke:[],handledSet:new WeakSet};let o,i;t.enablePatches&&(o=[],i=[]);const s=(null===(n=t.mark)||void 0===n?void 0:n.call(t,e,R))!==R.mutable&&N(e,t)?ye({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=ge(s,e,o,i,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!N(u,d))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[y,g]}let v;try{v=l(y)}catch(e){throw W(_(y)),e}const m=e=>{const t=_(y);if(!T(e)){if(void 0!==e&&!$(e,y)&&(null==t?void 0:t.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const n=null==e?void 0:e[S];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&ve({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&ve({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=_(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([be(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw W(_(y)),e})):m(v)};Object.prototype.constructor.toString();class Oe{constructor(e,t=null){this.value=e,this.reactor=t??new b(this,[])}produce(e){return n=e,void(t=this).set(we(t.get(),n));var t,n}reducer(...e){let t;return t=1===e.length?new w(this,"",e[0]):new w(this,e[0],e[1]),t.trigger.bind(t)}setObjectByPath(e="",t){if(0==e.length)return void(this.value=t);if("string"!=typeof e||!e)throw new Error("Invalid path");let n=e.split("."),r=this.value;for(let e=0;e<n.length-1;e++){let t=n[e];t in r||(r[t]={}),r=r[t]}r[n[n.length-1]]=t}set(...e){if(1===e.length)this.value=e[0];else{let t=e[0],n=e[1];this.setObjectByPath(t,n)}this.reactor.react()}get(){return this.value}}class Me{constructor(e){this.target=e}set html(e){this.target.innerHTML=e}query(e){return this.target.querySelectorAll(e)}set text(e){this.target.textContent=e}on(e,t){this.target.addEventListener(e,t)}off(e,t){this.target.removeEventListener(e,t)}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Ee{constructor(e){this.target=e}query(e){return this.target.querySelectorAll(e)}index(e){return Array.from(this.target.children)[e]}list(){return Array.from(this.target.children)}get parent(){return this.target}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class je{constructor(e){this.target=e}set(e){this.target=e,e.setRef(this)}}return e.RumiousApp=class{constructor(e=document.createElement("span"),n={}){this.root=e,this.configs=n,this.renderContext=new t(this)}render(e){m(e,this.root,this.renderContext)}},e.RumiousChildrensRef=Ee,e.RumiousComponent=n,e.RumiousComponentElement=y,e.RumiousComponentRef=je,e.RumiousElementRef=Me,e.RumiousState=Oe,e.createChildrensRef=function(e){return new Ee(e)},e.createComponentElement=g,e.createComponentRef=function(e){return new je(e)},e.createElementRef=function(e){return new Me(e)},e.createState=function(e){return new Oe(e)},e.isComponent=r,e.isState=function(e){return e instanceof Oe},e.watcher=function(e,t){e.reactor.addBinding(t)},e}({});