rumious 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -225
- package/dist/index.cjs.min.js +1 -224
- package/dist/index.esm.js +1 -215
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -215
- package/dist/index.js +1 -230
- package/dist/index.min.js +1 -229
- package/package.json +5 -7
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.cjs.js
CHANGED
@@ -1,225 +1 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
function _arrayLikeToArray(r, a) {
|
4
|
-
(null == a || a > r.length) && (a = r.length);
|
5
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
6
|
-
return n;
|
7
|
-
}
|
8
|
-
function _arrayWithHoles(r) {
|
9
|
-
if (Array.isArray(r)) return r;
|
10
|
-
}
|
11
|
-
function _assertThisInitialized(e) {
|
12
|
-
if (undefined === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
13
|
-
return e;
|
14
|
-
}
|
15
|
-
function _callSuper(t, o, e) {
|
16
|
-
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
17
|
-
}
|
18
|
-
function _classCallCheck(a, n) {
|
19
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
20
|
-
}
|
21
|
-
function _construct(t, e, r) {
|
22
|
-
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
23
|
-
var o = [null];
|
24
|
-
o.push.apply(o, e);
|
25
|
-
var p = new (t.bind.apply(t, o))();
|
26
|
-
return r && _setPrototypeOf(p, r.prototype), p;
|
27
|
-
}
|
28
|
-
function _defineProperties(e, r) {
|
29
|
-
for (var t = 0; t < r.length; t++) {
|
30
|
-
var o = r[t];
|
31
|
-
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
function _createClass(e, r, t) {
|
35
|
-
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
36
|
-
writable: false
|
37
|
-
}), e;
|
38
|
-
}
|
39
|
-
function _defineProperty(e, r, t) {
|
40
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
41
|
-
value: t,
|
42
|
-
enumerable: true,
|
43
|
-
configurable: true,
|
44
|
-
writable: true
|
45
|
-
}) : e[r] = t, e;
|
46
|
-
}
|
47
|
-
function _getPrototypeOf(t) {
|
48
|
-
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
49
|
-
return t.__proto__ || Object.getPrototypeOf(t);
|
50
|
-
}, _getPrototypeOf(t);
|
51
|
-
}
|
52
|
-
function _inherits(t, e) {
|
53
|
-
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
54
|
-
t.prototype = Object.create(e && e.prototype, {
|
55
|
-
constructor: {
|
56
|
-
value: t,
|
57
|
-
writable: true,
|
58
|
-
configurable: true
|
59
|
-
}
|
60
|
-
}), Object.defineProperty(t, "prototype", {
|
61
|
-
writable: false
|
62
|
-
}), e && _setPrototypeOf(t, e);
|
63
|
-
}
|
64
|
-
function _isNativeFunction(t) {
|
65
|
-
try {
|
66
|
-
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
67
|
-
} catch (n) {
|
68
|
-
return "function" == typeof t;
|
69
|
-
}
|
70
|
-
}
|
71
|
-
function _isNativeReflectConstruct() {
|
72
|
-
try {
|
73
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
74
|
-
} catch (t) {}
|
75
|
-
return (_isNativeReflectConstruct = function () {
|
76
|
-
return !!t;
|
77
|
-
})();
|
78
|
-
}
|
79
|
-
function _iterableToArrayLimit(r, l) {
|
80
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
81
|
-
if (null != t) {
|
82
|
-
var e,
|
83
|
-
n,
|
84
|
-
i,
|
85
|
-
u,
|
86
|
-
a = [],
|
87
|
-
f = true,
|
88
|
-
o = false;
|
89
|
-
try {
|
90
|
-
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
91
|
-
} catch (r) {
|
92
|
-
o = true, n = r;
|
93
|
-
} finally {
|
94
|
-
try {
|
95
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
96
|
-
} finally {
|
97
|
-
if (o) throw n;
|
98
|
-
}
|
99
|
-
}
|
100
|
-
return a;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
function _nonIterableRest() {
|
104
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
105
|
-
}
|
106
|
-
function ownKeys(e, r) {
|
107
|
-
var t = Object.keys(e);
|
108
|
-
if (Object.getOwnPropertySymbols) {
|
109
|
-
var o = Object.getOwnPropertySymbols(e);
|
110
|
-
r && (o = o.filter(function (r) {
|
111
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
112
|
-
})), t.push.apply(t, o);
|
113
|
-
}
|
114
|
-
return t;
|
115
|
-
}
|
116
|
-
function _objectSpread2(e) {
|
117
|
-
for (var r = 1; r < arguments.length; r++) {
|
118
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
119
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
120
|
-
_defineProperty(e, r, t[r]);
|
121
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
122
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
123
|
-
});
|
124
|
-
}
|
125
|
-
return e;
|
126
|
-
}
|
127
|
-
function _possibleConstructorReturn(t, e) {
|
128
|
-
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
129
|
-
if (undefined !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
130
|
-
return _assertThisInitialized(t);
|
131
|
-
}
|
132
|
-
function _setPrototypeOf(t, e) {
|
133
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
134
|
-
return t.__proto__ = e, t;
|
135
|
-
}, _setPrototypeOf(t, e);
|
136
|
-
}
|
137
|
-
function _slicedToArray(r, e) {
|
138
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
139
|
-
}
|
140
|
-
function _toPrimitive(t, r) {
|
141
|
-
if ("object" != typeof t || !t) return t;
|
142
|
-
var e = t[Symbol.toPrimitive];
|
143
|
-
if (undefined !== e) {
|
144
|
-
var i = e.call(t, r || "default");
|
145
|
-
if ("object" != typeof i) return i;
|
146
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
147
|
-
}
|
148
|
-
return ("string" === r ? String : Number)(t);
|
149
|
-
}
|
150
|
-
function _toPropertyKey(t) {
|
151
|
-
var i = _toPrimitive(t, "string");
|
152
|
-
return "symbol" == typeof i ? i : i + "";
|
153
|
-
}
|
154
|
-
function _typeof(o) {
|
155
|
-
"@babel/helpers - typeof";
|
156
|
-
|
157
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
158
|
-
return typeof o;
|
159
|
-
} : function (o) {
|
160
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
161
|
-
}, _typeof(o);
|
162
|
-
}
|
163
|
-
function _unsupportedIterableToArray(r, a) {
|
164
|
-
if (r) {
|
165
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
166
|
-
var t = {}.toString.call(r).slice(8, -1);
|
167
|
-
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;
|
168
|
-
}
|
169
|
-
}
|
170
|
-
function _wrapNativeSuper(t) {
|
171
|
-
var r = "function" == typeof Map ? new Map() : undefined;
|
172
|
-
return _wrapNativeSuper = function (t) {
|
173
|
-
if (null === t || !_isNativeFunction(t)) return t;
|
174
|
-
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
175
|
-
if (undefined !== r) {
|
176
|
-
if (r.has(t)) return r.get(t);
|
177
|
-
r.set(t, Wrapper);
|
178
|
-
}
|
179
|
-
function Wrapper() {
|
180
|
-
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
181
|
-
}
|
182
|
-
return Wrapper.prototype = Object.create(t.prototype, {
|
183
|
-
constructor: {
|
184
|
-
value: Wrapper,
|
185
|
-
enumerable: false,
|
186
|
-
writable: true,
|
187
|
-
configurable: true
|
188
|
-
}
|
189
|
-
}), _setPrototypeOf(Wrapper, t);
|
190
|
-
}, _wrapNativeSuper(t);
|
191
|
-
}
|
192
|
-
|
193
|
-
var RumiousRenderContext=/*#__PURE__*/_createClass(function RumiousRenderContext(target){_classCallCheck(this,RumiousRenderContext);this.target=target;});
|
194
|
-
|
195
|
-
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:"onCreate",value:function onCreate(){}},{key:"onRender",value:function onRender(){}},{key:"onUpdate",value:function onUpdate(){}},{key:"onDestroy",value:function onDestroy(){}}]);}();function isComponent(constructor){return Object.getPrototypeOf(constructor)===RumiousComponent;}
|
196
|
-
|
197
|
-
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);}}]);}();
|
198
|
-
|
199
|
-
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};
|
200
|
-
|
201
|
-
function isCamelCase(str){var camelCaseRegex=/^[a-z]+([A-Z][a-z]*)*$/;return camelCaseRegex.test(str);}
|
202
|
-
|
203
|
-
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);}},{key:"connectedCallback",value:function connectedCallback(){this.instance.onCreate();this.instance.requestRender();}}]);}(/*#__PURE__*/_wrapNativeSuper(HTMLElement));function createComponentElement(){return document.createElement("a-component");}window.customElements.define("a-component",RumiousComponentElement);
|
204
|
-
|
205
|
-
function renderComponent(componentConstructor,props,wrapped,renderer){var componentElement=createComponentElement();componentElement.init(componentConstructor,props,wrapped,renderer);return componentElement;}
|
206
|
-
|
207
|
-
function render(element,container){var renderContext=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(!element)return container;var dom;if(element.type==="COMPONENT"){dom=renderComponent(element.props.component,element.props,element.children,render);container.appendChild(dom);return container;}if(element.type==="FRAGMENT"||element.type==="ELEMENT_LIST"){element.children.forEach(function(child){return render(child,container,renderContext);});return container;}if(element.type==="TEXT_ELEMENT"){dom=document.createTextNode(element.props.nodeValue);}else {dom=document.createElement(element.type);}Object.entries(element.props||{}).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),name=_ref2[0],value=_ref2[1];if(name==="ref"){var _renderContext$addRef;(_renderContext$addRef=renderContext.addRef)===null||_renderContext$addRef===undefined||_renderContext$addRef.call(renderContext,value);}else if(name.startsWith("on")&&isCamelCase(name)){dom.addEventListener(name.substring(2).toLowerCase(),value);}else if(dom.nodeType===Node.TEXT_NODE){dom.nodeValue=value;}else {dom.setAttribute(name,value);}});element.children.forEach(function(child){return render(child,dom,renderContext);});container.appendChild(dom);return container;}
|
208
|
-
|
209
|
-
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);}}]);}();
|
210
|
-
|
211
|
-
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);}}]);}();
|
212
|
-
|
213
|
-
var RumiousState=/*#__PURE__*/function(){function RumiousState(target){var reactor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;_classCallCheck(this,RumiousState);this.target=target;this.reactor=reactor!==null&&reactor!==undefined?reactor:new RumiousReactor(this,[]);if(target&&_typeof(target)==='object'){this.wrapProxy(target);}else {this._value=target;}}return _createClass(RumiousState,[{key:"wrapProxy",value:function wrapProxy(target){var _this=this;this._value=new Proxy(target,{get:function get(target,prop){var value=target[prop];return value&&_typeof(value)==='object'?new RumiousState(value,_this.reactor).value:value;},set:function set(target,prop,value){if(value&&_typeof(value)==='object'){value=new RumiousState(value,_this.reactor).proxy;}_this.reactor.react();target[prop]=value;return true;}});}},{key:"value",get:function get(){return this._value;},set:function set(val){if(val&&_typeof(val)==="object"){this.wrapProxy(val);}else {this._value=val;}this.reactor.react();}}]);}();function createState(value){return new RumiousState(value);}
|
214
|
-
|
215
|
-
function watcher(state,callback){state.reactor.addBinding(callback);}
|
216
|
-
|
217
|
-
exports.RumiousApp = RumiousApp;
|
218
|
-
exports.RumiousComponent = RumiousComponent;
|
219
|
-
exports.RumiousComponentElement = RumiousComponentElement;
|
220
|
-
exports.RumiousState = RumiousState;
|
221
|
-
exports.createComponentElement = createComponentElement;
|
222
|
-
exports.createState = createState;
|
223
|
-
exports.isComponent = isComponent;
|
224
|
-
exports.watcher = watcher;
|
225
|
-
//# sourceMappingURL=index.cjs.js.map
|
1
|
+
"use strict";class e{constructor(e){this.target=e}find(e){return this.target[e]}get(e){return this.target[e]}}class t{constructor(){this.element=null,this.props={},this.renderContext=new e(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 n(e){return Object.getPrototypeOf(e)===t}class r{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class o{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function i(e){return"function"==typeof e}class s{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){console.warn("Directive haven't handler !")}}class a extends s{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return console.warn(`Missing event handler for event: ${this.name}`),null;const n=t.get(e);if(!i(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,!i(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 l extends s{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){if("html"===this.name)e.innerHTML=this.normalizeValue(t)}}class c extends s{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 u extends s{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 p={on:(e,t)=>new a("on",e,t),bind:(e,t)=>new l("bind",e,t),ref:(e,t,n="element")=>new c("ref",e,t),childsRef:(e,t)=>new u("childsRef",e,t)};function f(...e){return new r("FRAGMENT",{},h(e))}function h(e){return e.map((e=>"object"==typeof e?e:new r("TEXT_ELEMENT",{nodeValue:e},[])))}window.RUMIOUS_JSX_SUPPORT={createElement:function(e,t,...i){return n(e)?function(e,t,n){return new r("COMPONENT",{component:e,...t},new o(h(n)))}(e,t,i):e===f?f(...i):new r(e,t||{},h(i))},createFragment:f,createDirective:function(e,t,n){return function(e,t,n){return p[e]?.(t,n)}(e,t,n)}};class d 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 y(){return document.createElement("a-component")}function g(e,t,n,r){const o=function(e,t,n,r){const o=y();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 s&&m(o,t,r)})),t.appendChild(o),t}function v(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 s?m(e,n,r):e.setAttribute(t,n)}(n,e,r,t)})),n}function m(e,t,n){t.init(e,n)}function b(e,t,n={}){if(!e)return t;let r;return"COMPONENT"===e.type?g(e,t,b,n):"FRAGMENT"===e.type||"ELEMENT_LIST"===e.type?function(e,t,n){return e.children.forEach((e=>b(e,t,n))),t}(e,t,n):(r="TEXT_ELEMENT"===e.type?function(e){return document.createTextNode(e.props.nodeValue)}(e):v(e,n),e.children.forEach((e=>b(e,r,n))),t.appendChild(r),t)}window.customElements.define("a-component",d);class w{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}addBinding(e){this.bindings.push(e)}}class O{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 M="remove",E="replace",j="add",S=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),k=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),R=Symbol.iterator,x={mutable:"mutable",immutable:"immutable"},A={};function P(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function C(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 z(e){return Object.getPrototypeOf(e)===Set.prototype}function D(e){return Object.getPrototypeOf(e)===Map.prototype}function T(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function _(e){return!!I(e)}function I(e){return"object"!=typeof e?null:null==e?void 0:e[S]}function N(e){var t;const n=I(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function F(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,x))===x.immutable||"function"==typeof n)}function V(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=I(q(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 V(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=q(3===L(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 L(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function q(e,t){return 2===L(e)?e.get(t):e[t]}function $(e,t,n){2===L(e)?e.set(t,n):e[t]=n}function U(e,t){const n=I(e);return(n?T(n):e)[t]}function W(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function B(e){if(e)for(;e.finalities.revoke.length>0;){e.finalities.revoke.pop()()}}function K(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 X=Object.prototype.propertyIsEnumerable;function H(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set){if(!z(e)){return new(0,Object.getPrototypeOf(e).constructor)(e.values())}return Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values())}if(e instanceof Map){if(!D(e)){return new(0,Object.getPrototypeOf(e).constructor)(e)}return new Map(e)}if((null==t?void 0:t.mark)&&(n=t.mark(e,x),void 0!==n)&&n!==x.mutable){if(n===x.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=>{X.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 Y(e){e.copy||(e.copy=H(e.original,e.options))}function G(e){if(!F(e))return N(e);if(Array.isArray(e))return e.map(G);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,G(t)]));if(!D(e)){return new(0,Object.getPrototypeOf(e).constructor)(t)}return new Map(t)}if(e instanceof Set){const t=Array.from(e).map(G);if(!z(e)){return new(0,Object.getPrototypeOf(e).constructor)(t)}return new Set(t)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=G(e[n]);return t}function Z(e){return _(e)?G(e):e}function J(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&J(e.parent))}function Q(){throw new Error("Cannot modify frozen object")}function ee(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)||_(e))return r.pop(),void o.pop();switch(L(e)){case 2:for(const[t,i]of e)ee(t,t,n,r,o),ee(i,t,n,r,o);e.set=e.clear=e.delete=Q;break;case 3:for(const t of e)ee(t,t,n,r,o);e.add=e.clear=e.delete=Q;break;case 1:Object.freeze(e);let t=0;for(const i of e)ee(i,t,n,r,o),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{ee(e[t],t,n,r,o)}))}r.pop(),o.pop()}function te(e,t){const n=L(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 ne(e,t,n){if(_(e)||!F(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,o=r?new Map:void 0;if(t.add(e),te(e,((i,s)=>{var a;if(_(s)){const t=I(s);Y(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;$(r?o:e,i,n)}else ne(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 re(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&ne(q(n,t),e.finalities.handledSet,e.options)}function oe(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(N(t))})))}function ie(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const o=V(e);o&&t(e,o,n,r)}e.finalized=!0}}function se(e,t,n,r){const o=I(n);o&&(o.callbacks||(o.callbacks=[]),o.callbacks.push(((i,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if(W(q(l,t),n)){let n=o.original;o.copy&&(n=o.copy),oe(e),ie(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)),$(l,t,n)}})),e.options.enableAutoFreeze&&o.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),F(n,e.options)&&e.finalities.draft.push((()=>{W(q(3===e.type?e.setMap:e.copy,t),n)&&re(e,t)}))}function ae(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=q(e,a),c=Z(q(t,a)),u=n?P(e,a)?E:j:M;if(W(l,c)&&u===E)return;const p=K(r.concat(a),s);o.push(u===M?{op:u,path:p}:{op:u,path:p,value:c}),i.push(u===j?{op:M,path:p}:u===M?{op:j,path:p,value:l}:{op:E,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=K(t.concat([e]),o);n.push({op:E,path:s,value:Z(l[e])}),r.push({op:E,path:s,value:Z(i[e])})}for(let e=i.length;e<l.length;e+=1){const r=K(t.concat([e]),o);n.push({op:j,path:r,value:Z(l[e])})}if(i.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=K(t.concat(["length"]),o);r.push({op:E,path:e,value:i.length})}else for(let e=l.length;i.length<e;e-=1){const n=K(t.concat([e-1]),o);r.push({op:M,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=K(n.concat([s]),i);r.push({op:M,path:t,value:e}),o.unshift({op:j,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=K(n.concat([s]),i);r.push({op:j,path:e,value:t}),o.unshift({op:M,path:e,value:t})}s+=1}))}(e,t,n,r,o)}}const le=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!F(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},ce={get size(){return T(I(this)).size},has(e){return T(I(this)).has(e)},set(e,t){const n=I(this),r=T(n);return r.has(e)&&W(r.get(e),t)||(Y(n),J(n),n.assignedMap.set(e,!0),n.copy.set(e,t),se(n,e,t,ae)),this},delete(e){if(!this.has(e))return!1;const t=I(this);return Y(t),J(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=I(this);if(this.size){Y(e),J(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){T(I(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=I(this),o=T(r).get(e),i=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,o,x))===x.mutable;if(r.options.strict&&le(o,r.options,i),i)return o;if(r.finalized||!F(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 Y(r),r.copy.set(e,s),s},keys(){return T(I(this)).keys()},values(){const e=this.keys();return{[R]:()=>this.values(),next:()=>{const t=e.next();if(t.done)return t;return{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[R]:()=>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]}}}},[R](){return this.entries()}},ue=Reflect.ownKeys(ce),pe=(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=I(a),c=(null===(o=(r=e.options).mark)||void 0===o?void 0:o.call(r,a,x))===x.mutable;if(e.options.strict&&le(s,e.options,c),c||l||!F(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]}},fe={get size(){return I(this).setMap.size},has(e){const t=I(this);if(t.setMap.has(e))return!0;Y(t);const n=I(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=I(this);return this.has(e)||(Y(t),J(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),se(t,e,e,ae)),this},delete(e){if(!this.has(e))return!1;const t=I(this);Y(t),J(t);const n=I(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=I(this);Y(e),J(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=I(this);Y(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:pe(e,t,{isValuesIterator:!0})}},entries(){const e=I(this);Y(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:pe(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[R](){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(fe,{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 he=Reflect.ownKeys(fe),de=new WeakSet,ye={get(e,t,n){var r,o;const i=null===(r=e.copy)||void 0===r?void 0:r[t];if(i&&de.has(i))return i;if(t===S)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,x),s===x.mutable)return e.options.strict&&le(r,e.options,!0),r}const a=T(e);if(a instanceof Map&&ue.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ce,"size").get.call(e.proxy);const n=ce[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&he.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(fe,"size").get.call(e.proxy);const n=fe[t];if(n)return n.bind(e.proxy)}if(!P(a,t)){const n=C(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&&le(l,e.options),e.finalized||!F(l,e.options))return l;if(l===U(e.original,t)){if(Y(e),e.copy[t]=ge({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=I(e.copy[t]);return Y(n),J(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=C(T(e),t);if(null==i?void 0:i.set)return i.set.call(e.proxy,n),!0;const s=U(T(e),t),a=I(s);return a&&W(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):(W(n,s)&&(void 0!==n||P(e.original,t))||(Y(e),J(e),P(e.original,t)&&W(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,se(e,t,n,ae)),!0)},has:(e,t)=>t in T(e),ownKeys:e=>Reflect.ownKeys(T(e)),getOwnPropertyDescriptor(e,t){const n=T(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?ye.set.call(this,e,t,void 0,e.proxy):(void 0!==U(e.original,t)||t in e.original?(Y(e),J(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 ge(e){const{original:t,parentDraft:n,key:r,finalities:o,options:i}=e,s=L(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,ye);if(o.revoke.push(c),de.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var o,i;const s=I(l);let a=3===e.type?e.setMap:e.copy;const c=q(a,r),u=I(c);if(u){let i=u.original;u.operated&&(i=N(c)),oe(u),ie(u,ae,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)),$(a,r,i)}null===(i=s.callbacks)||void 0===i||i.forEach((e=>{e(t,n)}))}))}else{const e=I(l);e.finalities.draft.push(((t,n)=>{oe(e),ie(e,ae,t,n)}))}return l}function ve(e,t,n,r,o){var i;const s=I(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&&B(s),o&&ee(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:E,path:[],value:t[0]}]:n,r&&l?[{op:E,path:[],value:a}]:r]}function me(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:o=!0}=e;te(n,((n,r,o)=>{const i=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 $(o,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,me(e))})),o&&(e.isContainDraft||console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."),r&&console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."))}function be(e){var t;const n=I(e);if(!F(e,null==n?void 0:n.options))return e;const r=L(e);if(n&&!n.operated)return n.original;let o;function i(){o=2===r?D(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):H(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{i()}finally{n.finalized=!1}}else o=e;if(te(o,((t,r)=>{if(n&&W(q(n.original,t),r))return;const s=be(r);s!==r&&(o===e&&i(),$(o,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:o;return z(e)?new Set(o):new(Object.getPrototypeOf(e).constructor)(o)}return o}function we(e){if(!_(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return be(e)}A.createDraft=ge;const Oe=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({},Me),c);const u=_(a)?we(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(!F(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,x))!==x.mutable&&F(e,t)?ge({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=ve(s,e,o,i,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!F(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 B(I(y)),e}const m=e=>{const t=I(y);if(!_(e)){if(void 0!==e&&!W(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[k];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&me({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&me({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=I(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([we(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw B(I(y)),e})):m(v)};var Me;Object.prototype.constructor.toString();class Ee{constructor(e,t=null){this.value=e,this.reactor=t??new w(this,[])}produce(e){return n=e,void(t=this).set(Oe(t.get(),n));var t,n}reducer(...e){let t;return t=1===e.length?new O(this,"",e[0]):new O(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 je{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 Se{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 ke{constructor(e){this.target=e}set(e){this.target=e,e.setRef(this)}}exports.RumiousApp=class{constructor(t=document.createElement("span"),n={}){this.root=t,this.configs=n,this.renderContext=new e(this)}render(e){b(e,this.root,this.renderContext)}},exports.RumiousChildrensRef=Se,exports.RumiousComponent=t,exports.RumiousComponentElement=d,exports.RumiousComponentRef=ke,exports.RumiousElementRef=je,exports.RumiousState=Ee,exports.createChildrensRef=function(e){return new Se(e)},exports.createComponentElement=y,exports.createComponentRef=function(e){return new ke(e)},exports.createElementRef=function(e){return new je(e)},exports.createState=function(e){return new Ee(e)},exports.isComponent=n,exports.isState=function(e){return e instanceof Ee},exports.watcher=function(e,t){e.reactor.addBinding(t)};
|
package/dist/index.cjs.min.js
CHANGED
@@ -1,224 +1 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
function _arrayLikeToArray(r, a) {
|
4
|
-
(null == a || a > r.length) && (a = r.length);
|
5
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
6
|
-
return n;
|
7
|
-
}
|
8
|
-
function _arrayWithHoles(r) {
|
9
|
-
if (Array.isArray(r)) return r;
|
10
|
-
}
|
11
|
-
function _assertThisInitialized(e) {
|
12
|
-
if (undefined === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
13
|
-
return e;
|
14
|
-
}
|
15
|
-
function _callSuper(t, o, e) {
|
16
|
-
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
17
|
-
}
|
18
|
-
function _classCallCheck(a, n) {
|
19
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
20
|
-
}
|
21
|
-
function _construct(t, e, r) {
|
22
|
-
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
23
|
-
var o = [null];
|
24
|
-
o.push.apply(o, e);
|
25
|
-
var p = new (t.bind.apply(t, o))();
|
26
|
-
return r && _setPrototypeOf(p, r.prototype), p;
|
27
|
-
}
|
28
|
-
function _defineProperties(e, r) {
|
29
|
-
for (var t = 0; t < r.length; t++) {
|
30
|
-
var o = r[t];
|
31
|
-
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
function _createClass(e, r, t) {
|
35
|
-
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
36
|
-
writable: false
|
37
|
-
}), e;
|
38
|
-
}
|
39
|
-
function _defineProperty(e, r, t) {
|
40
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
41
|
-
value: t,
|
42
|
-
enumerable: true,
|
43
|
-
configurable: true,
|
44
|
-
writable: true
|
45
|
-
}) : e[r] = t, e;
|
46
|
-
}
|
47
|
-
function _getPrototypeOf(t) {
|
48
|
-
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
49
|
-
return t.__proto__ || Object.getPrototypeOf(t);
|
50
|
-
}, _getPrototypeOf(t);
|
51
|
-
}
|
52
|
-
function _inherits(t, e) {
|
53
|
-
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
54
|
-
t.prototype = Object.create(e && e.prototype, {
|
55
|
-
constructor: {
|
56
|
-
value: t,
|
57
|
-
writable: true,
|
58
|
-
configurable: true
|
59
|
-
}
|
60
|
-
}), Object.defineProperty(t, "prototype", {
|
61
|
-
writable: false
|
62
|
-
}), e && _setPrototypeOf(t, e);
|
63
|
-
}
|
64
|
-
function _isNativeFunction(t) {
|
65
|
-
try {
|
66
|
-
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
67
|
-
} catch (n) {
|
68
|
-
return "function" == typeof t;
|
69
|
-
}
|
70
|
-
}
|
71
|
-
function _isNativeReflectConstruct() {
|
72
|
-
try {
|
73
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
74
|
-
} catch (t) {}
|
75
|
-
return (_isNativeReflectConstruct = function () {
|
76
|
-
return !!t;
|
77
|
-
})();
|
78
|
-
}
|
79
|
-
function _iterableToArrayLimit(r, l) {
|
80
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
81
|
-
if (null != t) {
|
82
|
-
var e,
|
83
|
-
n,
|
84
|
-
i,
|
85
|
-
u,
|
86
|
-
a = [],
|
87
|
-
f = true,
|
88
|
-
o = false;
|
89
|
-
try {
|
90
|
-
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
91
|
-
} catch (r) {
|
92
|
-
o = true, n = r;
|
93
|
-
} finally {
|
94
|
-
try {
|
95
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
96
|
-
} finally {
|
97
|
-
if (o) throw n;
|
98
|
-
}
|
99
|
-
}
|
100
|
-
return a;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
function _nonIterableRest() {
|
104
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
105
|
-
}
|
106
|
-
function ownKeys(e, r) {
|
107
|
-
var t = Object.keys(e);
|
108
|
-
if (Object.getOwnPropertySymbols) {
|
109
|
-
var o = Object.getOwnPropertySymbols(e);
|
110
|
-
r && (o = o.filter(function (r) {
|
111
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
112
|
-
})), t.push.apply(t, o);
|
113
|
-
}
|
114
|
-
return t;
|
115
|
-
}
|
116
|
-
function _objectSpread2(e) {
|
117
|
-
for (var r = 1; r < arguments.length; r++) {
|
118
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
119
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
120
|
-
_defineProperty(e, r, t[r]);
|
121
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
122
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
123
|
-
});
|
124
|
-
}
|
125
|
-
return e;
|
126
|
-
}
|
127
|
-
function _possibleConstructorReturn(t, e) {
|
128
|
-
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
129
|
-
if (undefined !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
130
|
-
return _assertThisInitialized(t);
|
131
|
-
}
|
132
|
-
function _setPrototypeOf(t, e) {
|
133
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
134
|
-
return t.__proto__ = e, t;
|
135
|
-
}, _setPrototypeOf(t, e);
|
136
|
-
}
|
137
|
-
function _slicedToArray(r, e) {
|
138
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
139
|
-
}
|
140
|
-
function _toPrimitive(t, r) {
|
141
|
-
if ("object" != typeof t || !t) return t;
|
142
|
-
var e = t[Symbol.toPrimitive];
|
143
|
-
if (undefined !== e) {
|
144
|
-
var i = e.call(t, r || "default");
|
145
|
-
if ("object" != typeof i) return i;
|
146
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
147
|
-
}
|
148
|
-
return ("string" === r ? String : Number)(t);
|
149
|
-
}
|
150
|
-
function _toPropertyKey(t) {
|
151
|
-
var i = _toPrimitive(t, "string");
|
152
|
-
return "symbol" == typeof i ? i : i + "";
|
153
|
-
}
|
154
|
-
function _typeof(o) {
|
155
|
-
"@babel/helpers - typeof";
|
156
|
-
|
157
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
158
|
-
return typeof o;
|
159
|
-
} : function (o) {
|
160
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
161
|
-
}, _typeof(o);
|
162
|
-
}
|
163
|
-
function _unsupportedIterableToArray(r, a) {
|
164
|
-
if (r) {
|
165
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
166
|
-
var t = {}.toString.call(r).slice(8, -1);
|
167
|
-
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;
|
168
|
-
}
|
169
|
-
}
|
170
|
-
function _wrapNativeSuper(t) {
|
171
|
-
var r = "function" == typeof Map ? new Map() : undefined;
|
172
|
-
return _wrapNativeSuper = function (t) {
|
173
|
-
if (null === t || !_isNativeFunction(t)) return t;
|
174
|
-
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
175
|
-
if (undefined !== r) {
|
176
|
-
if (r.has(t)) return r.get(t);
|
177
|
-
r.set(t, Wrapper);
|
178
|
-
}
|
179
|
-
function Wrapper() {
|
180
|
-
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
181
|
-
}
|
182
|
-
return Wrapper.prototype = Object.create(t.prototype, {
|
183
|
-
constructor: {
|
184
|
-
value: Wrapper,
|
185
|
-
enumerable: false,
|
186
|
-
writable: true,
|
187
|
-
configurable: true
|
188
|
-
}
|
189
|
-
}), _setPrototypeOf(Wrapper, t);
|
190
|
-
}, _wrapNativeSuper(t);
|
191
|
-
}
|
192
|
-
|
193
|
-
var RumiousRenderContext=/*#__PURE__*/_createClass(function RumiousRenderContext(target){_classCallCheck(this,RumiousRenderContext);this.target=target;});
|
194
|
-
|
195
|
-
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:"onCreate",value:function onCreate(){}},{key:"onRender",value:function onRender(){}},{key:"onUpdate",value:function onUpdate(){}},{key:"onDestroy",value:function onDestroy(){}}])}();function isComponent(constructor){return Object.getPrototypeOf(constructor)===RumiousComponent}
|
196
|
-
|
197
|
-
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);}}])}();
|
198
|
-
|
199
|
-
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};
|
200
|
-
|
201
|
-
function isCamelCase(str){var camelCaseRegex=/^[a-z]+([A-Z][a-z]*)*$/;return camelCaseRegex.test(str)}
|
202
|
-
|
203
|
-
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);}},{key:"connectedCallback",value:function connectedCallback(){this.instance.onCreate();this.instance.requestRender();}}])}(/*#__PURE__*/_wrapNativeSuper(HTMLElement));function createComponentElement(){return document.createElement("a-component")}window.customElements.define("a-component",RumiousComponentElement);
|
204
|
-
|
205
|
-
function renderComponent(componentConstructor,props,wrapped,renderer){var componentElement=createComponentElement();componentElement.init(componentConstructor,props,wrapped,renderer);return componentElement}
|
206
|
-
|
207
|
-
function render(element,container){var renderContext=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(!element)return container;var dom;if(element.type==="COMPONENT"){dom=renderComponent(element.props.component,element.props,element.children,render);container.appendChild(dom);return container}if(element.type==="FRAGMENT"||element.type==="ELEMENT_LIST"){element.children.forEach(function(child){return render(child,container,renderContext)});return container}if(element.type==="TEXT_ELEMENT"){dom=document.createTextNode(element.props.nodeValue);}else {dom=document.createElement(element.type);}Object.entries(element.props||{}).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),name=_ref2[0],value=_ref2[1];if(name==="ref"){var _renderContext$addRef;(_renderContext$addRef=renderContext.addRef)===null||_renderContext$addRef===undefined||_renderContext$addRef.call(renderContext,value);}else if(name.startsWith("on")&&isCamelCase(name)){dom.addEventListener(name.substring(2).toLowerCase(),value);}else if(dom.nodeType===Node.TEXT_NODE){dom.nodeValue=value;}else {dom.setAttribute(name,value);}});element.children.forEach(function(child){return render(child,dom,renderContext)});container.appendChild(dom);return container}
|
208
|
-
|
209
|
-
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);}}])}();
|
210
|
-
|
211
|
-
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);}}])}();
|
212
|
-
|
213
|
-
var RumiousState=/*#__PURE__*/function(){function RumiousState(target){var reactor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;_classCallCheck(this,RumiousState);this.target=target;this.reactor=reactor!==null&&reactor!==undefined?reactor:new RumiousReactor(this,[]);if(target&&_typeof(target)==="object"){this.wrapProxy(target);}else {this._value=target;}}return _createClass(RumiousState,[{key:"wrapProxy",value:function wrapProxy(target){var _this=this;this._value=new Proxy(target,{get:function get(target,prop){var value=target[prop];return value&&_typeof(value)==="object"?new RumiousState(value,_this.reactor).value:value},set:function set(target,prop,value){if(value&&_typeof(value)==="object"){value=new RumiousState(value,_this.reactor).proxy;}_this.reactor.react();target[prop]=value;return true}});}},{key:"value",get:function get(){return this._value},set:function set(val){if(val&&_typeof(val)==="object"){this.wrapProxy(val);}else {this._value=val;}this.reactor.react();}}])}();function createState(value){return new RumiousState(value)}
|
214
|
-
|
215
|
-
function watcher(state,callback){state.reactor.addBinding(callback);}
|
216
|
-
|
217
|
-
exports.RumiousApp = RumiousApp;
|
218
|
-
exports.RumiousComponent = RumiousComponent;
|
219
|
-
exports.RumiousComponentElement = RumiousComponentElement;
|
220
|
-
exports.RumiousState = RumiousState;
|
221
|
-
exports.createComponentElement = createComponentElement;
|
222
|
-
exports.createState = createState;
|
223
|
-
exports.isComponent = isComponent;
|
224
|
-
exports.watcher = watcher;
|
1
|
+
"use strict";class e{constructor(e){this.target=e}find(e){return this.target[e]}get(e){return this.target[e]}}class t{constructor(){this.element=null,this.props={},this.renderContext=new e(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 n(e){return Object.getPrototypeOf(e)===t}class r{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class o{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function i(e){return"function"==typeof e}class s{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){}}class a extends s{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return null;const n=t.get(e);if(!i(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,!i(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 l extends s{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 c extends s{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 u extends s{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 p={on:(e,t)=>new a("on",e,t),bind:(e,t)=>new l("bind",e,t),ref:(e,t,n="element")=>new c("ref",e,t),childsRef:(e,t)=>new u("childsRef",e,t)};function f(...e){return new r("FRAGMENT",{},h(e))}function h(e){return e.map((e=>"object"==typeof e?e:new r("TEXT_ELEMENT",{nodeValue:e},[])))}window.RUMIOUS_JSX_SUPPORT={createElement:function(e,t,...i){return n(e)?function(e,t,n){return new r("COMPONENT",{component:e,...t},new o(h(n)))}(e,t,i):e===f?f(...i):new r(e,t||{},h(i))},createFragment:f,createDirective:function(e,t,n){return function(e,t,n){return p[e]?.(t,n)}(e,t,n)}};class d 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 y(){return document.createElement("a-component")}function g(e,t,n){t.init(e,n)}function v(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=y();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 s&&g(o,t,r)})),t.appendChild(o),t}(e,t,v,n):"FRAGMENT"===e.type||"ELEMENT_LIST"===e.type?function(e,t,n){return e.children.forEach((e=>v(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 s?g(e,n,r):e.setAttribute(t,n)}(n,e,r,t)})),n}(e,n),e.children.forEach((e=>v(e,r,n))),t.appendChild(r),t)}window.customElements.define("a-component",d);class m{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}addBinding(e){this.bindings.push(e)}}class b{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 w="remove",O="replace",M="add",E=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),j=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),S=Symbol.iterator,k={mutable:"mutable",immutable:"immutable"},R={};function x(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function A(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 P(e){return Object.getPrototypeOf(e)===Set.prototype}function C(e){return Object.getPrototypeOf(e)===Map.prototype}function z(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function D(e){return!!T(e)}function T(e){return"object"!=typeof e?null:null==e?void 0:e[E]}function _(e){var t;const n=T(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function I(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,k))===k.immutable||"function"==typeof n)}function N(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=T(V(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||x(n,i)))return null;t.push(i)}if(e.parent)return N(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=V(3===F(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 F(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function V(e,t){return 2===F(e)?e.get(t):e[t]}function L(e,t,n){2===F(e)?e.set(t,n):e[t]=n}function q(e,t){const n=T(e);return(n?z(n):e)[t]}function U(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function $(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function W(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 B=Object.prototype.propertyIsEnumerable;function K(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return P(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 C(e)?new Map(e):new(0,Object.getPrototypeOf(e).constructor)(e);if((null==t?void 0:t.mark)&&(n=t.mark(e,k),void 0!==n)&&n!==k.mutable){if(n===k.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=>{B.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 X(e){e.copy||(e.copy=K(e.original,e.options))}function H(e){if(!I(e))return _(e);if(Array.isArray(e))return e.map(H);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,H(t)]));return C(e)?new Map(t):new(0,Object.getPrototypeOf(e).constructor)(t)}if(e instanceof Set){const t=Array.from(e).map(H);return P(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]=H(e[n]);return t}function Y(e){return D(e)?H(e):e}function G(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&G(e.parent))}function Z(){throw new Error("Cannot modify frozen object")}function J(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)||D(e))return r.pop(),void o.pop();switch(F(e)){case 2:for(const[t,i]of e)J(t,t,n,r,o),J(i,t,n,r,o);e.set=e.clear=e.delete=Z;break;case 3:for(const t of e)J(t,t,n,r,o);e.add=e.clear=e.delete=Z;break;case 1:Object.freeze(e);let t=0;for(const i of e)J(i,t,n,r,o),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{J(e[t],t,n,r,o)}))}r.pop(),o.pop()}function Q(e,t){const n=F(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 ee(e,t,n){if(D(e)||!I(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,o=r?new Map:void 0;if(t.add(e),Q(e,((i,s)=>{var a;if(D(s)){const t=T(s);X(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;L(r?o:e,i,n)}else ee(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 te(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&ee(V(n,t),e.finalities.handledSet,e.options)}function ne(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(_(t))})))}function re(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const o=N(e);o&&t(e,o,n,r)}e.finalized=!0}}function oe(e,t,n,r){const o=T(n);o&&(o.callbacks||(o.callbacks=[]),o.callbacks.push(((i,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if(U(V(l,t),n)){let n=o.original;o.copy&&(n=o.copy),ne(e),re(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)),L(l,t,n)}})),e.options.enableAutoFreeze&&o.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),I(n,e.options)&&e.finalities.draft.push((()=>{U(V(3===e.type?e.setMap:e.copy,t),n)&&te(e,t)}))}function ie(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=V(e,a),c=Y(V(t,a)),u=n?x(e,a)?O:M:w;if(U(l,c)&&u===O)return;const p=W(r.concat(a),s);o.push(u===w?{op:u,path:p}:{op:u,path:p,value:c}),i.push(u===M?{op:w,path:p}:u===w?{op:M,path:p,value:l}:{op:O,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=W(t.concat([e]),o);n.push({op:O,path:s,value:Y(l[e])}),r.push({op:O,path:s,value:Y(i[e])})}for(let e=i.length;e<l.length;e+=1){const r=W(t.concat([e]),o);n.push({op:M,path:r,value:Y(l[e])})}if(i.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=W(t.concat(["length"]),o);r.push({op:O,path:e,value:i.length})}else for(let e=l.length;i.length<e;e-=1){const n=W(t.concat([e-1]),o);r.push({op:w,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=W(n.concat([s]),i);r.push({op:w,path:t,value:e}),o.unshift({op:M,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=W(n.concat([s]),i);r.push({op:M,path:e,value:t}),o.unshift({op:w,path:e,value:t})}s+=1}))}(e,t,n,r,o)}}const se=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!I(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},ae={get size(){return z(T(this)).size},has(e){return z(T(this)).has(e)},set(e,t){const n=T(this),r=z(n);return r.has(e)&&U(r.get(e),t)||(X(n),G(n),n.assignedMap.set(e,!0),n.copy.set(e,t),oe(n,e,t,ie)),this},delete(e){if(!this.has(e))return!1;const t=T(this);return X(t),G(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=T(this);if(this.size){X(e),G(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){z(T(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=T(this),o=z(r).get(e),i=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,o,k))===k.mutable;if(r.options.strict&&se(o,r.options,i),i)return o;if(r.finalized||!I(o,r.options))return o;if(o!==r.original.get(e))return o;const s=R.createDraft({original:o,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return X(r),r.copy.set(e,s),s},keys(){return z(T(this)).keys()},values(){const e=this.keys();return{[S]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[S]:()=>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]}}}},[S](){return this.entries()}},le=Reflect.ownKeys(ae),ce=(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=T(a),c=(null===(o=(r=e.options).mark)||void 0===o?void 0:o.call(r,a,k))===k.mutable;if(e.options.strict&&se(s,e.options,c),c||l||!I(s,e.options)||e.finalized||!e.original.has(s))l&&(a=l.proxy);else{const t=R.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]}},ue={get size(){return T(this).setMap.size},has(e){const t=T(this);if(t.setMap.has(e))return!0;X(t);const n=T(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=T(this);return this.has(e)||(X(t),G(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),oe(t,e,e,ie)),this},delete(e){if(!this.has(e))return!1;const t=T(this);X(t),G(t);const n=T(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=T(this);X(e),G(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=T(this);X(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:ce(e,t,{isValuesIterator:!0})}},entries(){const e=T(this);X(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:ce(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[S](){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(ue,{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 pe=Reflect.ownKeys(ue),fe=new WeakSet,he={get(e,t,n){var r,o;const i=null===(r=e.copy)||void 0===r?void 0:r[t];if(i&&fe.has(i))return i;if(t===E)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,k),s===k.mutable)return e.options.strict&&se(r,e.options,!0),r}const a=z(e);if(a instanceof Map&&le.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ae,"size").get.call(e.proxy);const n=ae[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&pe.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ue,"size").get.call(e.proxy);const n=ue[t];if(n)return n.bind(e.proxy)}if(!x(a,t)){const n=A(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&&se(l,e.options),e.finalized||!I(l,e.options))return l;if(l===q(e.original,t)){if(X(e),e.copy[t]=de({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=T(e.copy[t]);return X(n),G(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=A(z(e),t);if(null==i?void 0:i.set)return i.set.call(e.proxy,n),!0;const s=q(z(e),t),a=T(s);return a&&U(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):(U(n,s)&&(void 0!==n||x(e.original,t))||(X(e),G(e),x(e.original,t)&&U(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,oe(e,t,n,ie)),!0)},has:(e,t)=>t in z(e),ownKeys:e=>Reflect.ownKeys(z(e)),getOwnPropertyDescriptor(e,t){const n=z(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?he.set.call(this,e,t,void 0,e.proxy):(void 0!==q(e.original,t)||t in e.original?(X(e),G(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 de(e){const{original:t,parentDraft:n,key:r,finalities:o,options:i}=e,s=F(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,he);if(o.revoke.push(c),fe.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var o,i;const s=T(l);let a=3===e.type?e.setMap:e.copy;const c=V(a,r),u=T(c);if(u){let i=u.original;u.operated&&(i=_(c)),ne(u),re(u,ie,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)),L(a,r,i)}null===(i=s.callbacks)||void 0===i||i.forEach((e=>{e(t,n)}))}))}else{const e=T(l);e.finalities.draft.push(((t,n)=>{ne(e),re(e,ie,t,n)}))}return l}function ye(e,t,n,r,o){var i;const s=T(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&&$(s),o&&J(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:O,path:[],value:t[0]}]:n,r&&l?[{op:O,path:[],value:a}]:r]}function ge(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:o=!0}=e;Q(n,((n,r,o)=>{const i=T(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 L(o,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,ge(e))})),o&&e.isContainDraft}function ve(e){var t;const n=T(e);if(!I(e,null==n?void 0:n.options))return e;const r=F(e);if(n&&!n.operated)return n.original;let o;function i(){o=2===r?C(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):K(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{i()}finally{n.finalized=!1}}else o=e;if(Q(o,((t,r)=>{if(n&&U(V(n.original,t),r))return;const s=ve(r);s!==r&&(o===e&&i(),L(o,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:o;return P(e)?new Set(o):new(Object.getPrototypeOf(e).constructor)(o)}return o}function me(e){if(!D(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return ve(e)}R.createDraft=de;const be=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=D(a)?me(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(!I(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,k))!==k.mutable&&I(e,t)?de({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=ye(s,e,o,i,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!I(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 $(T(y)),e}const m=e=>{const t=T(y);if(!D(e)){if(void 0!==e&&!U(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[j];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&ge({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&ge({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=T(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([me(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw $(T(y)),e})):m(v)};Object.prototype.constructor.toString();class we{constructor(e,t=null){this.value=e,this.reactor=t??new m(this,[])}produce(e){return n=e,void(t=this).set(be(t.get(),n));var t,n}reducer(...e){let t;return t=1===e.length?new b(this,"",e[0]):new b(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 Oe{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 Me{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 Ee{constructor(e){this.target=e}set(e){this.target=e,e.setRef(this)}}exports.RumiousApp=class{constructor(t=document.createElement("span"),n={}){this.root=t,this.configs=n,this.renderContext=new e(this)}render(e){v(e,this.root,this.renderContext)}},exports.RumiousChildrensRef=Me,exports.RumiousComponent=t,exports.RumiousComponentElement=d,exports.RumiousComponentRef=Ee,exports.RumiousElementRef=Oe,exports.RumiousState=we,exports.createChildrensRef=function(e){return new Me(e)},exports.createComponentElement=y,exports.createComponentRef=function(e){return new Ee(e)},exports.createElementRef=function(e){return new Oe(e)},exports.createState=function(e){return new we(e)},exports.isComponent=n,exports.isState=function(e){return e instanceof we},exports.watcher=function(e,t){e.reactor.addBinding(t)};
|