@twobirds/microcomponents 0.0.27 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/assets/3d.html +42 -0
  2. package/assets/documentation/MicroComponents.md +39 -20
  3. package/assets/test.html +0 -1
  4. package/dist/MC.d.ts +6 -2
  5. package/dist/MC.d.ts.map +1 -1
  6. package/dist/MC.min.js +61 -85
  7. package/dist/MC.ts +85 -112
  8. package/dist/customElements.min.js +1 -1
  9. package/dist/customObservables.d.ts +1 -1
  10. package/dist/customObservables.d.ts.map +1 -1
  11. package/dist/customObservables.min.js +1 -1
  12. package/dist/customObservables.ts +2 -2
  13. package/dist/microcomponents.min.js +1 -1
  14. package/dist/test.ts +22 -5
  15. package/package.json +3 -3
  16. package/public/3d.html +42 -0
  17. package/public/MC.js +61 -85
  18. package/public/MC.js.map +1 -1
  19. package/public/MC.min.js +61 -85
  20. package/public/assets/search.js +1 -1
  21. package/public/classes/DC.html +26 -37
  22. package/public/classes/MC.html +19 -30
  23. package/public/classes/McBase.html +5 -17
  24. package/public/classes/McEvent.html +13 -13
  25. package/public/customElements.min.js +1 -1
  26. package/public/customObservables.js +1 -1
  27. package/public/customObservables.js.map +1 -1
  28. package/public/customObservables.min.js +1 -1
  29. package/public/documentation/MicroComponents.md +39 -20
  30. package/public/functions/addListener.html +1 -1
  31. package/public/functions/removeListener.html +1 -1
  32. package/public/interfaces/HTMLMcElement.html +2 -2
  33. package/public/microcomponents.min.js +1 -1
  34. package/public/test.html +0 -1
  35. package/public/test.js +16 -5
  36. package/public/test.js.map +1 -1
  37. package/src/MC.ts +85 -112
  38. package/src/customObservables.ts +2 -2
  39. package/src/test.ts +22 -5
@@ -27,16 +27,27 @@ As an application programmer you should understand **MC** and **DC** methods and
27
27
  - **DC** use observables and formValues to provide 1-way and 2-way binding to the DOM.
28
28
  - **DC** have selectors to find other DCs in the DOM.
29
29
 
30
- ## MC() Class overview
30
+ ## McBase() Superclass (not exported), Overview
31
31
 
32
32
  **Instance Properties**
33
33
  - `.target`: readonly, a getter returning the DOM element or parent MC instance your instance resides in
34
+
35
+ **Constructor:**
36
+ - calls `init()`: triggers the 'init' lifecycle event, also recursively into the inner '._mc' structure.
37
+ - calls `autoAttachListeners()`: methods in your MC that start with "on[A-Z]" or "one[A-Z]" and describe native DOM events (e.g. "onClick") will be added to the DOM Element as listeners.
38
+
39
+ # Exported:
40
+
41
+ ## MC() Class, extends McBase
42
+
43
+ **Instance Properties**
44
+ - `.target`: (inherited from McBase)
34
45
  - `._mc`: a hash object that contains inner micro components
35
46
 
36
47
  - **Instance Methods:**
37
- - `.trigger( eventName, data )`: trigger an event on this instance
48
+ - `.trigger( eventName, data )`: (inherited from McBase)
38
49
 
39
- ## DC() Class Overview
50
+ ## DC() Class, extends McBase
40
51
 
41
52
  - **Static Methods:**
42
53
  - `DC.add( DomElement, key, mc)`: Add a DC to an HTMLElement.
@@ -44,27 +55,24 @@ As an application programmer you should understand **MC** and **DC** methods and
44
55
  - `DC.trigger( eventName, DomElement, data, bubble )`: trigger an event, handles directional traversal in the DOM.
45
56
 
46
57
  **Instance Properties**
47
-
48
- ( inherited from MC )
49
- - `.target`: readonly, a getter returning the DOM element the instance resides in
50
- - `._mc`: a hash object that contains inner MCs
58
+ - `.target`: (inherited from McBase)
59
+ - `._mc`: a hash object that contains inner micro components
51
60
 
52
61
  - **Instance Methods:**
53
62
  - `.parent(search?)`: Get parent DCs.
54
63
  - `.ancestors(search?)`: Get ancestor DCs.
55
64
  - `.children(search?)`: Get child DCs.
56
65
  - `.descendants(search?)`: Get descendant DCs.
57
- - `.autoAttachListeners()`: methods in your MC that start with "on[A-Z]" or "one[A-Z]" and describe native DOM events (e.g. "onClick") will be added to the DOM Element as listeners.
58
-
59
- (inherited from MC )
60
66
  - `.trigger( eventName, data, bubble )`: trigger an event on "this", handles directional bubbling in the DOM.
61
67
 
62
- ### Typical Workflow
68
+ # Usage
69
+
70
+ ## Typical Workflow
63
71
 
64
72
  1. **Attach DCs** to HTMLElements using `DC.add()`.
65
73
  2. **Access** other DCs by their property key or navigating through DOM (e.g., `ancestors()`, `children()`, etc.) **and use their inner functionality**.
66
74
 
67
- # Attaching Micro Components to a DOM element
75
+ ### Attach Micro Components to a DOM element
68
76
 
69
77
  To attach a micro component to an HTML element, use the `DC.add()` static function.
70
78
 
@@ -96,7 +104,7 @@ DC.add( myElement, 'myDcComponent', new MyClass( myElement ) );
96
104
  - After you added a micro component using this function, the **HTMLElement will contain a property `_mc`** which contains the external MC instances.
97
105
  - Also the **HTMLElement then has an attribute '_mc'** which will indicate that at least one micro component is attached to this dom element.
98
106
 
99
- # Removing a top level Micro Component from a DOM element
107
+ ### Remove a top level Micro Component from a DOM element
100
108
 
101
109
  Micro components can be removed using the `DC.remove()` static method.
102
110
 
@@ -106,7 +114,7 @@ DC.remove( myDomElement, 'myComponent');
106
114
 
107
115
  **When all micro components are removed** (the _mc object has no more properties), the **`_mc` attribute is also removed** from the HTML element.
108
116
 
109
- # Retrieve all top level Micro Components from a DOM element
117
+ ### Retrieve Micro Components from a DOM element
110
118
 
111
119
  ```javascript
112
120
  const target = document.querySelector( 'div' );
@@ -120,7 +128,7 @@ const specificInstance = target._mc?.myPublicComponent;
120
128
  console.log(specificInstance);
121
129
  ```
122
130
 
123
- ### Trigger an Event on all DCs
131
+ ### Trigger an Event
124
132
 
125
133
  ```javascript
126
134
  const target = document.querySelector( 'div' );
@@ -132,7 +140,7 @@ DC.trigger( target, '<eventName>', data | null, bubble );
132
140
 
133
141
  # Methods you can use in your Micro Component Instances
134
142
 
135
- ## Retrieving Inner Micro Components
143
+ ## Retrieve Inner Micro Components
136
144
 
137
145
  You can retrieve an inner micro component by using the ._mc property.
138
146
 
@@ -144,7 +152,7 @@ console.log(innerComponent);
144
152
  **The following methods hop over HTMLElements that DO NOT contain micro components.**
145
153
 
146
154
 
147
- ## Navigating Parent and Ancestor Micro Components
155
+ ## Navigate Parent and Ancestor Micro Components
148
156
 
149
157
  The `.parent()` and `.ancestors()` methods allow you to retrieve micro components attached to parent elements.
150
158
 
@@ -161,7 +169,7 @@ To retrieve specific micro component(s) attached to ancestors:
161
169
  const specificAncestorMc = this.ancestors('myComponent');
162
170
  ```
163
171
 
164
- ## Retrieving Child and Descendant Micro Components
172
+ ## Retrieve Child and Descendant Micro Components
165
173
 
166
174
  The `.children()` and `.descendants()` methods retrieve micro components attached to child elements or any descendants.
167
175
  ```javascript
@@ -175,7 +183,7 @@ console.log(descendantComponents); // an array of all descendant micro componen
175
183
  const specificMcs = this.descenants('specificMc');
176
184
  ```
177
185
 
178
- ### Trigger Events on MCs
186
+ ## Trigger an Event
179
187
  ```javascript
180
188
  // trigger an event on yourself
181
189
  this
@@ -206,7 +214,7 @@ this
206
214
 
207
215
  ## Automatically attach Listener Methods to the DOM
208
216
 
209
- On any **DC** instance, you can call **.autoAttachListeners()** in the constructor.
217
+ On any **MC** and **DC** instance, the Superclass McBase calls **autoAttachListeners()** in the constructor.
210
218
 
211
219
  Any methods you define in your code that start with **"on"** or **"one"**, and also match DOM event names, will be called accordingly:
212
220
 
@@ -226,3 +234,14 @@ let myFirstDiv = document.querySelector('div');
226
234
  DC.add( myFirstDiv, 'myEventTarget', new MyEventTarget( myFirstDiv ) );
227
235
  // now wait for somebody to click on that <div>
228
236
  ```
237
+ # Lifecycle Events on **MC** and **DC**
238
+
239
+ ## Init
240
+ - "this" first
241
+ - traverses recursively into the _mc structure
242
+ - requires **method .oneInit()** to be present in your class definition.
243
+
244
+ ## Destroy ( TBD )
245
+ - recursive "_mc" first
246
+ - then "this"
247
+ - requires **method .oneDestroy()** to be present in your class definition.
@@ -34,7 +34,7 @@
34
34
  <h5>once: <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> = false</span></h5></li></ul></div>
35
35
  <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources">
36
36
  <ul>
37
- <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/25cd260/src/MC.ts#L62">src/MC.ts:62</a></li></ul></aside></li></ul></section></div>
37
+ <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/6e5722c/src/MC.ts#L62">src/MC.ts:62</a></li></ul></aside></li></ul></section></div>
38
38
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
39
39
  <div class="tsd-navigation settings">
40
40
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -30,7 +30,7 @@
30
30
  <h5>handler: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">EventListenerOrEventListenerObject</span></h5></li></ul></div>
31
31
  <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources">
32
32
  <ul>
33
- <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/25cd260/src/MC.ts#L79">src/MC.ts:79</a></li></ul></aside></li></ul></section></div>
33
+ <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/6e5722c/src/MC.ts#L79">src/MC.ts:79</a></li></ul></aside></li></ul></section></div>
34
34
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
35
35
  <div class="tsd-navigation settings">
36
36
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -22,7 +22,7 @@
22
22
  <ul class="tsd-hierarchy">
23
23
  <li><span class="target">HTMLMcElement</span></li></ul></li></ul></section><aside class="tsd-sources">
24
24
  <ul>
25
- <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/25cd260/src/MC.ts#L15">src/MC.ts:15</a></li></ul></aside>
25
+ <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/6e5722c/src/MC.ts#L15">src/MC.ts:15</a></li></ul></aside>
26
26
  <section class="tsd-panel-group tsd-index-group">
27
27
  <section class="tsd-panel tsd-index-panel">
28
28
  <details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
@@ -468,7 +468,7 @@
468
468
  <h3 class="tsd-anchor-link"><span>_mc</span><a href="#_mc" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
469
469
  <div class="tsd-signature">_mc<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">LooseObject</span></div><aside class="tsd-sources">
470
470
  <ul>
471
- <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/25cd260/src/MC.ts#L16">src/MC.ts:16</a></li></ul></aside></section>
471
+ <li>Defined in <a href="https://gitlab.com/twoBirds/microcomponents/-/blob/6e5722c/src/MC.ts#L16">src/MC.ts:16</a></li></ul></aside></section>
472
472
  <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-inherited tsd-is-external"><a id="accessKey" class="tsd-anchor"></a>
473
473
  <h3 class="tsd-anchor-link"><span>access<wbr/>Key</span><a href="#accessKey" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
474
474
  <div class="tsd-signature">access<wbr/>Key<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.microcomponents=t():e.microcomponents=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return null!=e&&"object"==typeof e}function n(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("")}function s(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}function a(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const s of n){const n=e[s],o=t[s],i=r(n)&&r(o);if(i&&!a(n,o)||!i&&n!==o)return!1}return!0}function o(e,t,n=null,s){let a=e.split(".");s||(s=t);let i=a.shift(),c=a.join(".");null!==n&&i.length&&void 0===t[i]&&(t[i]={});let l=t[i];return 0===c.length?null!==n?(t[i]=n,s):t[i]:r(t[i])?o(c,t[i],n,s):n?s:l[i]}function i(e,t){var n=Array.from(arguments);if(n.length){if(1===n.length)return n[1];if(n.length>2){for(;n.length>1;)n[0]=i(n[0],n[1]),n.splice(1,1);return n[0]}if("string"==typeof e){var s=e.match(/\{[^\{\}]*\}/g);s&&s.forEach((function(r){var n=o(r.substr(1,r.length-2),t);void 0!==n&&(e=e.replace(r,n))}))}else if(r(e))switch(e.constructor){case Object:Object.keys(e).forEach((function(r){e.hasOwnProperty(r)&&(e[r]=i(e[r],t))}));break;case Array:e.forEach((function(r,n,s){s[n]=i(e[n],t)}))}return e}console.error("no arguments give to parse")}function c(e){let t=document.createElement("template");return e=e.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi,"<$1$2></$1>"),t.innerHTML=e,t.content.normalize(),Array.from(t.content.childNodes)}e.r(t),e.d(t,{$d:()=>I,$t:()=>B,DC:()=>S,MC:()=>A,McBase:()=>w,McEvent:()=>h,addListener:()=>b,debounce:()=>s,deepEqual:()=>a,defineCE:()=>k,formValues:()=>F,getCE:()=>x,htmlToElements:()=>c,isObject:()=>r,kebabToPascal:()=>n,makeCO:()=>T,nameSpace:()=>o,parse:()=>i,removeListener:()=>g});var l=new Function("try {return this===window;}catch(e){ return false;}");let u=new Set;l()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>u.add(e)));class h{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var f=new Function("try {return this===window;}catch(e){ return false;}");let d=new Set;function p(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function m(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function y(e){return e&&e instanceof HTMLElement}function b(e,t,r,n=!1,s=!1){let a={once:!1};n&&(a.capture=n),s&&(a.once=s),e.addEventListener(t,r,a)}function g(e,t,r){e.removeEventListener(t,r)}function E(e,t,r={}){let n=e;if(!n._mc){let t=S?.debug;S.debug=!1,n._mc=new S(e),S.debug=t}const s=n._mc;return t.length&&!s[t]&&(s[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function v(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function O(e,t,r={}){let n=e?._mc;n&&[...Object.values(n)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(t,r)}))}f()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>d.add(e)));class w{#n;#s={};constructor(e){this.#n=new WeakRef(e),this.constructor!==S&&Object.defineProperty(this,"_mc",{get(){return this.#s}})}get target(){return this.#n.deref()}}class A extends w{constructor(e){super(e);let t=this;setTimeout((()=>{t.trigger("Init"),setTimeout((()=>{let e=Object.keys(t?._mc);e.length&&e?.forEach((e=>{let r=t?._mc?.[e];r?.oneInit&&"function"==typeof r?.oneInit&&r.oneInit(new h("Init"))}))}),0)}),0),this.autoAttachListeners()}static trigger=O;trigger(e,t={},r){let n=this;if(r=r||"l",n.constructor!==A&&n.constructor!==S){if(n instanceof A||n instanceof S){const n=this,s="string"!=typeof e?e:new h(e,t,r),a="on"+s.type[0].toUpperCase()+s.type.slice(1);if(s.bubble.indexOf("l")>-1&&(s.immediateStopped||"function"!=typeof n[a]||(n[a](s),n.hasOwnProperty(a)&&delete n[a])),s.stopped||"l"===s.bubble)return n;f()&&/[ud]/.test(s.bubble)&&n instanceof A&&setTimeout((()=>{-1===s.bubble.indexOf("l")&&(s.bubble+="l"),s.bubble.indexOf("u")>-1&&n.parent().forEach((e=>{e instanceof A&&e.trigger(s)})),s.bubble.indexOf("d")>-1&&n.children().forEach((e=>{e instanceof A&&e.trigger(s)}))}),0)}}else[...Object.getOwnPropertyNames(n)].forEach((s=>{n[s]?.trigger&&"function"==typeof n[s]?.trigger&&n[s]?.trigger(e,t,r)}))}autoAttachListeners(){if(!f())return;const e=this.target;if(e instanceof HTMLElement){let t=this;Object.getOwnPropertyNames(t.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof t.constructor.prototype[e])).forEach((r=>{let n=/^one/.test(r),s=r.replace(/^on[e]{0,1}/,""),a=s.toLowerCase();n&&Object.defineProperty(this,"on"+s,{configurable:!0,enumerable:!1,writable:!0,value:e=>{t.constructor.prototype[r].bind(t)(e)}}),d.has("on"+a)&&b(e,a,(e=>{t.trigger(s,e)}),!1,n)}))}}}class S extends w{constructor(e){super(e);let t=this,r=t.constructor===S;setTimeout((()=>{t.trigger("Init"),r||setTimeout((()=>{let e=Object.keys(t?._mc);e.length&&e?.forEach((e=>{let r=t?._mc?.[e];r?.oneInit&&"function"==typeof r?.oneInit&&r.oneInit(new h("Init"))}))}),0)}),0),this.autoAttachListeners()}static debug=!1;static add=E;static remove=v;static trigger=O;get _mc(){return this._mc}trigger(e,t={},r){A.prototype.trigger.call(this,e,t,r)}autoAttachListeners(){A.prototype.autoAttachListeners.call(this)}parent(e=""){let t=this.target;return y(t)?m(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return y(t)?m(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!y(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const s=p([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),s}descendants(e=""){let t=this?.target;return y(t)?p([...t.querySelectorAll("*[_mc]")],e):[]}}class j extends HTMLElement{constructor(){super()}connectedCallback(){S.trigger(this,"Connected")}disconnectedCallback(){S.trigger(this,"Disconnected")}adoptedCallback(){S.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){S.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function k(e,t,r=[]){if(customElements.get(e))return void console.warn(`IGNORED: Custom element "${e}" is already defined!`);if(!e.includes("-"))throw new Error('createCustomElement: tagName must contain at least one hyphen ("-").');let s=n(e);customElements.define(e,function(e,t){return Object.defineProperty(t,"name",{value:e})}(s,class extends j{instance;constructor(e){super();let r=new t(this,e);S.add(this,s,r)}static get observedAttributes(){return r}}))}function x(e){return customElements.get(e)}const T=(e,t)=>{(t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return;let n,o=e[t];if(!o.prototype)switch(typeof o){case"string":n=String;break;case"number":n=Number;break;case"boolean":n=Boolean;break;case"object":n=o instanceof Array?Array:Object;break;default:return}let c=class extends n{constructor(e){super(e),this.constructor.callbacks=[],r(e)&&(this.constructor.bound=[],Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]})))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this,n=r(t.valueOf()),s=t.constructor.bound;if(n){function a(e){if(e.nodeType&&3===e.nodeType){var r=Array.from(e.nodeValue&&e.nodeValue.match(/\{[^\{\}]*\}/g)||[]);if(r.length>0){var o=(c=e.nodeValue||"",function(t){var s,a=!1;return r&&(n?r.forEach((function(e){o.values[e]!==t[e]&&(o.values[e]=t[e],a=!0)})):(o.values=t,a=!0)),a&&(s=c,e.nodeValue=n?i(s,o.values):s.replace(/\{.*\}/g,o.values)),t});o.values=n?{}:void 0,r=Array.from(r).map((e=>e.replace(/[\{\}]/g,"").trim()));let t=n?{}:void 0;r.forEach((function(e){n&&(t[e]="")})),s.push(o)}Array.from(e.childNodes).forEach((function(e){a(e)})),t.notify()}var c;e.nodeType&&1===e.nodeType&&(Array.from(e.attributes).forEach((function(t){var r=Array.from(t.value&&t.value.match(/\{[^\{\}]*\}/g)||[]);if(r.length>0){var n=function(t){return function(s){var a,o=!1;return r&&r.forEach((function(e){n.values[e]!==s[e]&&(n.values[e]=s[e],o=!0)})),o&&(a=t,e.nodeValue=i(a,n.values)),s}}(t.value||"");n.values={},r=Array.from(r).map((e=>e.replace(/[\{\}]/g,"").trim()));let a={};r.forEach((function(e){a[e]=""})),s.push(n)}})),Array.from(e.childNodes).forEach((function(e){a(e)})),t.notify()),e.nodeType&&11===e.nodeType&&Array.from(e.childNodes).forEach((function(e){a(e)}))}a(e),s.length>0&&t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf());return this}notify(){let e=this,t=r(e.valueOf())&&e.valueOf()instanceof Array==0?structuredClone(Object.assign({},e)):e.valueOf();return e.constructor.callbacks.forEach((e=>{e(t)})),r(e.valueOf())&&e.constructor.bound.forEach((e=>{e(t)})),this}},l=new c(o);Object.defineProperty(e,t,{enumerable:!0,get(){if(r(l.valueOf())){let e=structuredClone(Object.assign({},l));setTimeout(s((function(){a(structuredClone(Object.assign({},l)),e)||l.notify()}),0),0)}return l},set(e){if(typeof e==typeof l.valueOf())if(r(l.valueOf())&&l.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},l));e=structuredClone(Object.assign({},e));let r=l.constructor?.hasFormHandler??!1,n=l.constructor.callbacks,o=l.constructor.bound;l=new c(structuredClone(Object.assign({},e))),l.constructor.callbacks=r,l.constructor.callbacks=n,l.constructor.bound=o,setTimeout(s((function(){a(structuredClone(Object.assign({},l)),t)||l.notify()}),0),0)}else{let t=l.valueOf(),r=l.constructor.callbacks;l=new c(e),l.constructor.callbacks=r,e!==t&&l.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof l.valueOf(),"- CANNOT BECOME:",typeof e)}}),e[t]=o}))},_=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},C=e=>{let t=I("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let s;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":s=new N(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"select":s=new M(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"textarea":s=new P(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class L{constructor(e){}}class N extends L{#a;#e;#o;constructor(e,t){super(e),this.#a=e,this.#e=e.type,this.#o=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=I(`input[type="radio"][name="${this.#a.getAttribute("name")}"]`,this.#o).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#a.checked;default:return t.#a.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=`input[type="radio"][name="${this.#a.getAttribute("name")}"]`,n=I(r,this.#o);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const s=n.filter((t=>t.getAttribute("value")===e));if(!s.length)return;return void(s.array[0].checked=!0);case"checkbox":t.#a.checked=e;break;default:t.#a.value=e}}}class M extends L{#a;#i=!1;constructor(e){super(e),this.#a=e,this.#i="select-multiple"===e.type}get val(){const e=[];return I(this.#a.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#i?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,I(this.#a.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class P extends L{#a;constructor(e){super(e),this.#a=e}get val(){return this.#a.value}set val(e){this.#a.value=e}}class H{#c=new Set;get set(){return this.#c}get array(){return Array.from(this.#c)}set set(e){this.#c=e}get length(){return this.#c.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new $;return this.#c.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return I(e,t).forEach((e=>{r.#c.add(e)})),r}addClass(...e){return e=_(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=I(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=I(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=I(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{I(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=I(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,s=!1;return e&&(s=I(e,t)),r.#c.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=I([...n]),e&&r.filter((e=>s.has(e))),r}has(e){return this.#c.has(e)}hasClass(...e){return e=_(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),s=r.indexOf(e)+1;s<r.length&&n.add(r.at(s))}})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#c.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){g(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let s=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(s,Array.from(arguments))}return o.cb=t,s.forEach((e=>{a.forEach((function(t){b(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(n,Array.from(arguments))}return a.cb=t,n.forEach((e=>{s.forEach((function(t){b(e,t,a,r,!0)}))})),a}parent(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=I(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),s=r.indexOf(e)-1;s>-1&&n.add(r.at(s))}})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=_(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=_(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,s=!1){let a,o={bubbles:r,cancelable:n,composed:s},i=e.indexOf(" ")>-1?e.split(" "):[e];return this.#c.forEach((e=>{i.forEach((function(r){a=new Event(r,o),a.data=t,e.dispatchEvent(a)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,s=C(r.array[0]);var a;return e?null!=(a=e)&&"object"==typeof a?(Object.assign(s,e),n=r):"string"==typeof e&&(void 0===t?n=s[e]:(s[e]=t,n=r)):n=Object.assign({},s),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=C(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return I(this.array.at(e))}concat(e){let t=this;return(e instanceof H?e.array:e).forEach((e=>{t.#c.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#c=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#c.add(e)})),this}shift(){let e=this,t=e.#c.size?e.array[0]:void 0;return t&&e.#c.delete(t),t}slice(e,t){return I(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),I(n)}}class ${#c=new Set;get set(){return this.#c}get array(){return Array.from(this.#c)}set set(e){this.#c=e}get length(){return this.#c.size}set length(e){}constructor(e,t=document.body){if(!e)return this;I(e,t).forEach((e=>{B(e).forEach((e=>{this.#c.add(e)}))}))}$d(e,t=document.body){let r=new H,n=new Set,s=!!e||!1,a=new Set;return s&&(a=I(e,t).set),this.#c.forEach((e=>{s&&!a.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}descendants(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}first(e){let t=this,r=new Set;return t.#c.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#c.has(e)}last(e){let t=this,r=new Set;return t.#c.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#c.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);B([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){g(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(n,Array.from(arguments))}return a.cb=t,n.forEach((e=>{s.forEach((function(t){b(e._tg,`[TB]${t}`,a,!1,r)}))})),a}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(r,Array.from(arguments))}return s.cb=t,r.forEach((e=>{n.forEach((function(t){b(e._tg,`[TB]${t}`,s,!1,!0)}))})),s}parent(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}parents(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}prev(e){let t=this,r=new Set;return t.#c.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);B([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return B(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#c.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return B(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#c=new Set(e),t}push(e){return this.#c.add(e),this}shift(){let e=this.array.shift();return this.#c.delete(e),e}slice(e,t){return B(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return B(n)}}const I=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{I(e,t).forEach((e=>{r.add(e)}))})),new H([...r])):new H(e,t)},B=(e,t=document)=>I(e,t).$t();class q{constructor(e){}}class V extends q{#a;#e;#o;constructor(e,t){super(e),this.#a=e,this.#e=e.type,this.#o=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=[...(this.#o||document).querySelectorAll(`input[type="radio"][name="${this.#a.getAttribute("name")}"]`)].filter((e=>e.checked));return r.length?(e=r?.[0],e.value):"";case"checkbox":return t.#a.checked;default:return t.#a.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=[...(this.#o||document).querySelectorAll(`input[type="radio"][name="${this.#a.getAttribute("name")}"]`)];if(!r.length)return;if(""===e)return void r.forEach((e=>{e.checked&&(e.checked=!1)}));const n=r.filter((t=>t.getAttribute("value")===e));if(!n.length)return;return void((n?.[0]).checked=!0);case"checkbox":t.#a.checked=e;break;default:t.#a.value=e}}}class z extends q{#a;#i=!1;constructor(e){super(e),this.#a=e,this.#i="select-multiple"===e.type}get val(){const e=[];return[...this.#a.querySelectorAll("option")].filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#i?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,[...this.#a.querySelectorAll("option")].forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected","selected"),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class D extends q{#a;constructor(e){super(e),this.#a=e}get val(){return this.#a.value}set val(e){this.#a.value=e}}const F=(e,t={},r,n)=>{let s=(e=>{let t=[...(e||document).querySelectorAll("input,select,textarea")],r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let s;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":s=new V(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"select":s=new z(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"textarea":s=new D(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r})(e);function a(e){Object.keys(e).forEach((t=>{s.hasOwnProperty(t)&&e.hasOwnProperty(t)&&(s[t]=e[t])}))}if(Object.keys(t).length>0&&a(t),void 0!==n){let t=r[n];t.constructor?.hasFormHandler||(t.constructor.hasFormHandler=!0,t.observe(a)),r[n].observe((()=>{})),[...e.querySelectorAll("input, textarea, select")].forEach((e=>{b(e,"keyup",(()=>{r[n]=structuredClone(Object.assign(s))})),b(e,"change",(()=>{r[n]=structuredClone(Object.assign(s))})),e instanceof HTMLSelectElement&&b(e,"select",(()=>{r[n]=structuredClone(Object.assign(s))}))}))}return n?r[n]:Object.assign({},s)};return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.microcomponents=t():e.microcomponents=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return null!=e&&"object"==typeof e}function n(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("")}function s(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}function a(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const s of n){const n=e[s],o=t[s],c=r(n)&&r(o);if(c&&!a(n,o)||!c&&n!==o)return!1}return!0}function o(e,t,n=null,s){let a=e.split(".");s||(s=t);let c=a.shift(),i=a.join(".");null!==n&&c.length&&void 0===t[c]&&(t[c]={});let l=t[c];return 0===i.length?null!==n?(t[c]=n,s):t[c]:r(t[c])?o(i,t[c],n,s):n?s:l[c]}function c(e,t){var n=Array.from(arguments);if(n.length){if(1===n.length)return n[1];if(n.length>2){for(;n.length>1;)n[0]=c(n[0],n[1]),n.splice(1,1);return n[0]}if("string"==typeof e){var s=e.match(/\{[^\{\}]*\}/g);s&&s.forEach((function(r){var n=o(r.substr(1,r.length-2),t);void 0!==n&&(e=e.replace(r,n))}))}else if(r(e))switch(e.constructor){case Object:Object.keys(e).forEach((function(r){e.hasOwnProperty(r)&&(e[r]=c(e[r],t))}));break;case Array:e.forEach((function(r,n,s){s[n]=c(e[n],t)}))}return e}console.error("no arguments give to parse")}function i(e){let t=document.createElement("template");return e=e.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi,"<$1$2></$1>"),t.innerHTML=e,t.content.normalize(),Array.from(t.content.childNodes)}e.r(t),e.d(t,{$d:()=>I,$t:()=>B,DC:()=>S,MC:()=>A,McBase:()=>w,McEvent:()=>f,addListener:()=>b,debounce:()=>s,deepEqual:()=>a,defineCE:()=>k,formValues:()=>F,getCE:()=>x,htmlToElements:()=>i,isObject:()=>r,kebabToPascal:()=>n,nameSpace:()=>o,observe:()=>T,parse:()=>c,removeListener:()=>g});var l=new Function("try {return this===window;}catch(e){ return false;}");let u=new Set;l()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>u.add(e)));class f{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var h=new Function("try {return this===window;}catch(e){ return false;}");let d=new Set;function p(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function m(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function y(e){return e&&e instanceof HTMLElement}function b(e,t,r,n=!1,s=!1){let a={once:!1};n&&(a.capture=n),s&&(a.once=s),e.addEventListener(t,r,a)}function g(e,t,r){e.removeEventListener(t,r)}function E(e,t,r={}){let n=e;if(!n._mc){let t=S?.debug;S.debug=!1,n._mc=new S(e),S.debug=t}const s=n._mc;return t.length&&!s[t]&&(s[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function v(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function O(e,t,r={}){let n=e?._mc;n&&[...Object.values(n)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(t,r)}))}h()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>d.add(e)));class w{#n;constructor(e){this.#n=new WeakRef(e),function(e){let t=e.constructor===S;setTimeout((()=>{e.trigger("Init"),t||setTimeout((()=>{let t=Object.keys(e?._mc);t.length&&t?.forEach((t=>{let r=e?._mc?.[t];r.oneInit&&"function"==typeof r.oneInit&&r.oneInit(new f("Init"))}))}),0)}),0)}(this),function(e){if(!h()||e.constructor===S)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let s=/^one/.test(n),a=n.replace(/^on[e]{0,1}/,""),o=a.toLowerCase();s&&Object.defineProperty(e,"on"+a,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),d.has("on"+o)&&b(t,o,(e=>{r.trigger(a,e)}),!1,s)}))}}(this)}get target(){return this.#n.deref()}}class A extends w{_mc={};constructor(e){super(e)}static trigger=O;trigger(e,t={},r){let n=this;if(r=r||"l",n.constructor!==A&&n.constructor!==S){if(n instanceof A||n instanceof S){const n=this,s="string"!=typeof e?e:new f(e,t,r),a="on"+s.type[0].toUpperCase()+s.type.slice(1);if(s.bubble.indexOf("l")>-1&&(s.immediateStopped||"function"!=typeof n[a]||(n[a](s),n.hasOwnProperty(a)&&delete n[a])),s.stopped||"l"===s.bubble)return n;h()&&/[ud]/.test(s.bubble)&&n instanceof A&&setTimeout((()=>{-1===s.bubble.indexOf("l")&&(s.bubble+="l"),s.bubble.indexOf("u")>-1&&n.parent().forEach((e=>{e instanceof A&&e.trigger(s)})),s.bubble.indexOf("d")>-1&&n.children().forEach((e=>{e instanceof A&&e.trigger(s)}))}),0)}}else[...Object.getOwnPropertyNames(n)].forEach((s=>{n[s]?.trigger&&"function"==typeof n[s]?.trigger&&n[s]?.trigger(e,t,r)}))}}class S extends w{__mc={};constructor(e){super(e)}static debug=!1;static add=E;static remove=v;static trigger=O;get _mc(){return this.__mc}trigger(e,t={},r){A.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return y(t)?m(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return y(t)?m(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!y(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const s=p([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),s}descendants(e=""){let t=this?.target;return y(t)?p([...t.querySelectorAll("*[_mc]")],e):[]}}class j extends HTMLElement{constructor(){super()}connectedCallback(){S.trigger(this,"Connected")}disconnectedCallback(){S.trigger(this,"Disconnected")}adoptedCallback(){S.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){S.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function k(e,t,r=[]){if(customElements.get(e))return void console.warn(`IGNORED: Custom element "${e}" is already defined!`);if(!e.includes("-"))throw new Error('createCustomElement: tagName must contain at least one hyphen ("-").');let s=n(e);customElements.define(e,function(e,t){return Object.defineProperty(t,"name",{value:e})}(s,class extends j{instance;constructor(e){super();let r=new t(this,e);S.add(this,s,r)}static get observedAttributes(){return r}}))}function x(e){return customElements.get(e)}const T=(e,t)=>{(t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return;let n,o=e[t];if(!o.prototype)switch(typeof o){case"string":n=String;break;case"number":n=Number;break;case"boolean":n=Boolean;break;case"object":n=o instanceof Array?Array:Object;break;default:return}let i=class extends n{constructor(e){super(e),this.constructor.callbacks=[],r(e)&&(this.constructor.bound=[],Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]})))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this,n=r(t.valueOf()),s=t.constructor.bound;if(n){function a(e){if(e.nodeType&&3===e.nodeType){var r=Array.from(e.nodeValue&&e.nodeValue.match(/\{[^\{\}]*\}/g)||[]);if(r.length>0){var o=(i=e.nodeValue||"",function(t){var s,a=!1;return r&&(n?r.forEach((function(e){o.values[e]!==t[e]&&(o.values[e]=t[e],a=!0)})):(o.values=t,a=!0)),a&&(s=i,e.nodeValue=n?c(s,o.values):s.replace(/\{.*\}/g,o.values)),t});o.values=n?{}:void 0,r=Array.from(r).map((e=>e.replace(/[\{\}]/g,"").trim()));let t=n?{}:void 0;r.forEach((function(e){n&&(t[e]="")})),s.push(o)}Array.from(e.childNodes).forEach((function(e){a(e)})),t.notify()}var i;e.nodeType&&1===e.nodeType&&(Array.from(e.attributes).forEach((function(t){var r=Array.from(t.value&&t.value.match(/\{[^\{\}]*\}/g)||[]);if(r.length>0){var n=function(t){return function(s){var a,o=!1;return r&&r.forEach((function(e){n.values[e]!==s[e]&&(n.values[e]=s[e],o=!0)})),o&&(a=t,e.nodeValue=c(a,n.values)),s}}(t.value||"");n.values={},r=Array.from(r).map((e=>e.replace(/[\{\}]/g,"").trim()));let a={};r.forEach((function(e){a[e]=""})),s.push(n)}})),Array.from(e.childNodes).forEach((function(e){a(e)})),t.notify()),e.nodeType&&11===e.nodeType&&Array.from(e.childNodes).forEach((function(e){a(e)}))}a(e),s.length>0&&t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf());return this}notify(){let e=this,t=r(e.valueOf())&&e.valueOf()instanceof Array==0?structuredClone(Object.assign({},e)):e.valueOf();return e.constructor.callbacks.forEach((e=>{e(t)})),r(e.valueOf())&&e.constructor.bound.forEach((e=>{e(t)})),this}},l=new i(o);Object.defineProperty(e,t,{enumerable:!0,get(){if(r(l.valueOf())){let e=structuredClone(Object.assign({},l));setTimeout(s((function(){a(structuredClone(Object.assign({},l)),e)||l.notify()}),0),0)}return l},set(e){if(typeof e==typeof l.valueOf())if(r(l.valueOf())&&l.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},l));e=structuredClone(Object.assign({},e));let r=l.constructor?.hasFormHandler??!1,n=l.constructor.callbacks,o=l.constructor.bound;l=new i(structuredClone(Object.assign({},e))),l.constructor.callbacks=r,l.constructor.callbacks=n,l.constructor.bound=o,setTimeout(s((function(){a(structuredClone(Object.assign({},l)),t)||l.notify()}),0),0)}else{let t=l.valueOf(),r=l.constructor.callbacks;l=new i(e),l.constructor.callbacks=r,e!==t&&l.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof l.valueOf(),"- CANNOT BECOME:",typeof e)}}),e[t]=o}))},_=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},C=e=>{let t=I("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let s;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":s=new L(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"select":s=new M(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"textarea":s=new H(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class N{constructor(e){}}class L extends N{#s;#e;#a;constructor(e,t){super(e),this.#s=e,this.#e=e.type,this.#a=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=I(`input[type="radio"][name="${this.#s.getAttribute("name")}"]`,this.#a).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#s.checked;default:return t.#s.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=`input[type="radio"][name="${this.#s.getAttribute("name")}"]`,n=I(r,this.#a);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const s=n.filter((t=>t.getAttribute("value")===e));if(!s.length)return;return void(s.array[0].checked=!0);case"checkbox":t.#s.checked=e;break;default:t.#s.value=e}}}class M extends N{#s;#o=!1;constructor(e){super(e),this.#s=e,this.#o="select-multiple"===e.type}get val(){const e=[];return I(this.#s.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#o?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,I(this.#s.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class H extends N{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}class P{#c=new Set;get set(){return this.#c}get array(){return Array.from(this.#c)}set set(e){this.#c=e}get length(){return this.#c.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new $;return this.#c.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return I(e,t).forEach((e=>{r.#c.add(e)})),r}addClass(...e){return e=_(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=I(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=I(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=I(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{I(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=I(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,s=!1;return e&&(s=I(e,t)),r.#c.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=I([...n]),e&&r.filter((e=>s.has(e))),r}has(e){return this.#c.has(e)}hasClass(...e){return e=_(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),s=r.indexOf(e)+1;s<r.length&&n.add(r.at(s))}})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#c.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){g(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let s=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(s,Array.from(arguments))}return o.cb=t,s.forEach((e=>{a.forEach((function(t){b(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(n,Array.from(arguments))}return a.cb=t,n.forEach((e=>{s.forEach((function(t){b(e,t,a,r,!0)}))})),a}parent(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=I(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),s=r.indexOf(e)-1;s>-1&&n.add(r.at(s))}})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=_(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=_(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,s=!1){let a,o={bubbles:r,cancelable:n,composed:s},c=e.indexOf(" ")>-1?e.split(" "):[e];return this.#c.forEach((e=>{c.forEach((function(r){a=new Event(r,o),a.data=t,e.dispatchEvent(a)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,s=C(r.array[0]);var a;return e?null!=(a=e)&&"object"==typeof a?(Object.assign(s,e),n=r):"string"==typeof e&&(void 0===t?n=s[e]:(s[e]=t,n=r)):n=Object.assign({},s),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=C(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return I(this.array.at(e))}concat(e){let t=this;return(e instanceof P?e.array:e).forEach((e=>{t.#c.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#c=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#c.add(e)})),this}shift(){let e=this,t=e.#c.size?e.array[0]:void 0;return t&&e.#c.delete(t),t}slice(e,t){return I(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),I(n)}}class ${#c=new Set;get set(){return this.#c}get array(){return Array.from(this.#c)}set set(e){this.#c=e}get length(){return this.#c.size}set length(e){}constructor(e,t=document.body){if(!e)return this;I(e,t).forEach((e=>{B(e).forEach((e=>{this.#c.add(e)}))}))}$d(e,t=document.body){let r=new P,n=new Set,s=!!e||!1,a=new Set;return s&&(a=I(e,t).set),this.#c.forEach((e=>{s&&!a.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}descendants(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}first(e){let t=this,r=new Set;return t.#c.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#c.has(e)}last(e){let t=this,r=new Set;return t.#c.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#c.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);B([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){g(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(n,Array.from(arguments))}return a.cb=t,n.forEach((e=>{s.forEach((function(t){b(e._tg,`[TB]${t}`,a,!1,r)}))})),a}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(r,Array.from(arguments))}return s.cb=t,r.forEach((e=>{n.forEach((function(t){b(e._tg,`[TB]${t}`,s,!1,!0)}))})),s}parent(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}parents(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}prev(e){let t=this,r=new Set;return t.#c.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);B([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return B(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#c.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return B(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#c=new Set(e),t}push(e){return this.#c.add(e),this}shift(){let e=this.array.shift();return this.#c.delete(e),e}slice(e,t){return B(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return B(n)}}const I=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{I(e,t).forEach((e=>{r.add(e)}))})),new P([...r])):new P(e,t)},B=(e,t=document)=>I(e,t).$t();class q{constructor(e){}}class V extends q{#s;#e;#a;constructor(e,t){super(e),this.#s=e,this.#e=e.type,this.#a=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=[...(this.#a||document).querySelectorAll(`input[type="radio"][name="${this.#s.getAttribute("name")}"]`)].filter((e=>e.checked));return r.length?(e=r?.[0],e.value):"";case"checkbox":return t.#s.checked;default:return t.#s.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=[...(this.#a||document).querySelectorAll(`input[type="radio"][name="${this.#s.getAttribute("name")}"]`)];if(!r.length)return;if(""===e)return void r.forEach((e=>{e.checked&&(e.checked=!1)}));const n=r.filter((t=>t.getAttribute("value")===e));if(!n.length)return;return void((n?.[0]).checked=!0);case"checkbox":t.#s.checked=e;break;default:t.#s.value=e}}}class z extends q{#s;#o=!1;constructor(e){super(e),this.#s=e,this.#o="select-multiple"===e.type}get val(){const e=[];return[...this.#s.querySelectorAll("option")].filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#o?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,[...this.#s.querySelectorAll("option")].forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected","selected"),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class D extends q{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}const F=(e,t={},r,n)=>{let s=(e=>{let t=[...(e||document).querySelectorAll("input,select,textarea")],r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let s;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":s=new V(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"select":s=new z(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"textarea":s=new D(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r})(e);function a(e){Object.keys(e).forEach((t=>{s.hasOwnProperty(t)&&e.hasOwnProperty(t)&&(s[t]=e[t])}))}if(Object.keys(t).length>0&&a(t),void 0!==n){let t=r[n];t.constructor?.hasFormHandler||(t.constructor.hasFormHandler=!0,t.observe(a)),r[n].observe((()=>{})),[...e.querySelectorAll("input, textarea, select")].forEach((e=>{b(e,"keyup",(()=>{r[n]=structuredClone(Object.assign(s))})),b(e,"change",(()=>{r[n]=structuredClone(Object.assign(s))})),e instanceof HTMLSelectElement&&b(e,"select",(()=>{r[n]=structuredClone(Object.assign(s))}))}))}return n?r[n]:Object.assign({},s)};return t})()));
package/public/test.html CHANGED
@@ -7,7 +7,6 @@
7
7
  <link rel="icon" type="image/svg+xml" sizes="any" href="MicroComponents.svg" />
8
8
  <link href="./my-tag.css" rel="stylesheet" />
9
9
  <script type="module" src="./test.js"></script>
10
- <script src="./customSelectors.min.js"></script>
11
10
  </head>
12
11
  <body>
13
12
  Open the debugger, read console, then:&nbsp;
package/public/test.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
- import { MC, DC } from "./MC.js";
3
- import { defineCE, getCE } from "./customElements.js";
4
- import { makeCO } from "./customObservables.js";
2
+ import { MC, DC, defineCE, getCE, observe } from "./microcomponents.js";
3
+ //import { MC, DC, McEvent } from "./MC.js";
4
+ //import { defineCE, getCE } from "./customElements.js";
5
+ //import { observe } from "./customObservables.js";
5
6
  //MC.debug = true;
6
7
  class Adder {
7
8
  constructor() { }
@@ -9,6 +10,15 @@ class Adder {
9
10
  return numbers.reduce((acc, curr) => acc + curr, 0);
10
11
  }
11
12
  }
13
+ class DeeplyNestedEvTarget extends MC {
14
+ constructor(target) {
15
+ super(target);
16
+ }
17
+ oneInit(ev) {
18
+ let logger = this.target?.target?.target?._mc?.logger;
19
+ logger?.warn("DeeplyNestedEvTarget .oneInit(ev)", ev);
20
+ }
21
+ }
12
22
  class EvTarget extends MC {
13
23
  constructor(target) {
14
24
  super(target);
@@ -18,8 +28,9 @@ class EvTarget extends MC {
18
28
  logger?.log("onCustomEvent", ev);
19
29
  }
20
30
  oneInit(ev) {
21
- let logger = this.target?.target?._mc?.logger;
31
+ let that = this, _mc = that._mc, logger = this.target?.target?._mc?.logger;
22
32
  logger?.warn("EvTarget .oneInit(ev)", ev);
33
+ _mc.deeplyNestedEvTarget = new DeeplyNestedEvTarget(that);
23
34
  }
24
35
  }
25
36
  class Logger extends DC {
@@ -55,7 +66,7 @@ defineCE(
55
66
  that.In = data;
56
67
  that.Counter = 0;
57
68
  // convert all props defined so far into custom observables
58
- makeCO(that);
69
+ observe(that);
59
70
  DC.add(target, "logger", new Logger(target, console, "[logger]"));
60
71
  // render
61
72
  target.innerHTML = "Click Me";
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,EAAE,EAAE,EAAE,EAAW,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,kBAAkB;AAElB,MAAM,KAAK;IACV,gBAAe,CAAC;IAEhB,GAAG,CAAC,GAAG,OAAiB;QACvB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;CACD;AAED,MAAM,QAAS,SAAQ,EAAE;IACxB,YAAY,MAAW;QACtB,KAAK,CAAC,M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AAC,IAAI,CAAC,WAAW,CAAE,IAAI,KAAK,CAAC,SAAS,CAAC,CAAE,CAAC;AAElD,IAAI,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;AAE/C,OAAO,CAAC,GAAG,CACV,mGAAmG,EACnG,oBAAoB,EACpB,sBAAsB,EACtB,OAAO,EACP,oBAAoB,EACpB,+CAA+C,CAC/C,CAAC;AAEF,uEAAuE;AACvE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC"}
package/src/MC.ts CHANGED
@@ -137,22 +137,94 @@ function trigger( target: unknown, ev: McEvent | string, data: any = {}) {
137
137
  return;
138
138
  }
139
139
 
140
+ // run the "init" lifecycle event on the completemcr structure
141
+ function init( element: MC | DC ){
142
+ let isDomMcInstance = element.constructor === DC;
143
+
144
+ setTimeout(
145
+ () => {
146
+ element.trigger('Init');
147
+ if ( !isDomMcInstance ) {
148
+ setTimeout(
149
+ () => {
150
+ let keys = Object.keys( element?._mc );
151
+ if ( keys.length ){
152
+ //console.log( 'inner Inits on [', mc.constructor.name, ']', keys );
153
+ keys?.forEach( (key: string) => {
154
+ let mc = element?._mc?.[key];
155
+ //console.log( key, typeof mc?.oneInit, mc );
156
+ if ( ( mc as any )['oneInit'] && typeof ( mc as any ).oneInit == 'function' ){
157
+ ( mc as any ).oneInit( new McEvent('Init') );
158
+ }
159
+ });
160
+ };
161
+ }
162
+ , 0
163
+ );
164
+ }
165
+ }
166
+ , 0
167
+ );
168
+
169
+ }
170
+
171
+ function autoAttachListeners( element: MC | DC ){
172
+ if ( !isBrowser() || element.constructor === DC ) return;
173
+
174
+ const target = element.target;
175
+
176
+ if ( target instanceof HTMLElement ){
177
+ let that: LooseObject = element;
178
+ Object
179
+ .getOwnPropertyNames( that.constructor.prototype )
180
+ .filter( key => /^on[A-Z]|one[A-Z]/.test(key) && typeof that.constructor.prototype[key] === 'function' )
181
+ .forEach( key => {
182
+ let
183
+ once = /^one/.test(key),
184
+ withoutOnOne = key.replace( /^on[e]{0,1}/, '' ), // preserves upper/lowercase for non-native events
185
+ nativeEventName = withoutOnOne.toLowerCase(),
186
+ listener = ( ev: McEvent | Event | CustomEvent ) => { that.trigger( withoutOnOne, ev ); };
187
+ ;
188
+
189
+ if ( once ){
190
+ // console.log( '...is only called once', that.constructor.prototype[key] );
191
+ Object.defineProperty(
192
+ element,
193
+ 'on' + withoutOnOne,
194
+ {
195
+ configurable: true,
196
+ enumerable: false,
197
+ writable: true,
198
+ value: (ev: any) => {
199
+ // console.log( 'onceHandler execute:', that.constructor.prototype[key] );
200
+ ( that.constructor.prototype[key] ).bind(that)(ev);
201
+ }
202
+ }
203
+ );
204
+ }
205
+
206
+ if ( nativeEventNames.has( 'on' + nativeEventName ) ){ // native event defined in HTMLElement
207
+ // console.log('added as native listener', target, nativeEventName );
208
+ addListener( target, nativeEventName, listener, false, once );
209
+ }
210
+ });
211
+ }
212
+ }
213
+
140
214
  class McBase {
141
215
 
142
216
  #target: WeakRef<any>; // avoid circular reference
143
217
 
144
- #_mc: { [key:string]: any } = {};
145
-
146
218
  constructor( target: { [key:string]: any } ) {
147
- let that = this;
219
+ let that: unknown = this,
220
+ element = (that as MC | DC );
148
221
 
149
222
  this.#target = new WeakRef( target );
150
223
 
151
- if ( this.constructor !== DC){
152
- Object.defineProperty( this, "_mc", {
153
- get(){ return this.#_mc }
154
- });
155
- };
224
+
225
+ init( element ); // async lifecycle event
226
+
227
+ autoAttachListeners( element );
156
228
  }
157
229
 
158
230
  get target(): any {
@@ -163,34 +235,10 @@ class McBase {
163
235
 
164
236
  class MC extends McBase {
165
237
 
238
+ _mc: { [key:string]: any } = {};
239
+
166
240
  constructor(target: any) {
167
241
  super(target);
168
- let that = this;
169
-
170
- setTimeout(
171
- () => {
172
- that.trigger('Init');
173
- setTimeout(
174
- () => {
175
- let keys = Object.keys( (that as any)?._mc );
176
- if ( keys.length ){
177
- //console.log( 'inner Inits on [', that.constructor.name, ']', keys );
178
- keys?.forEach( (key: string) => {
179
- let mc = (that as any)?._mc?.[key];
180
- //console.log( key, typeof mc?.oneInit, mc );
181
- if ( mc?.oneInit && typeof mc?.oneInit == 'function' ){
182
- mc.oneInit( new McEvent('Init') );
183
- }
184
- });
185
- };
186
- }
187
- , 0
188
- );
189
- }
190
- ,0
191
- );
192
-
193
- this.autoAttachListeners();
194
242
  }
195
243
 
196
244
  static trigger = trigger;
@@ -276,85 +324,14 @@ class MC extends McBase {
276
324
 
277
325
  }
278
326
 
279
- autoAttachListeners(){
280
- if ( !isBrowser() ) return;
281
-
282
- const target = this.target;
283
-
284
- if ( target instanceof HTMLElement ){
285
- let that: LooseObject = this;
286
- Object
287
- .getOwnPropertyNames( that.constructor.prototype )
288
- .filter( key => /^on[A-Z]|one[A-Z]/.test(key) && typeof that.constructor.prototype[key] === 'function' )
289
- .forEach( key => {
290
- let
291
- once = /^one/.test(key),
292
- withoutOnOne = key.replace( /^on[e]{0,1}/, '' ), // preserves upper/lowercase for non-native events
293
- nativeEventName = withoutOnOne.toLowerCase(),
294
- listener = ( ev: McEvent | Event | CustomEvent ) => { that.trigger( withoutOnOne, ev ); };
295
- ;
296
-
297
- if ( once ){
298
- // console.log( '...is only called once', that.constructor.prototype[key] );
299
- Object.defineProperty(
300
- this,
301
- 'on' + withoutOnOne,
302
- {
303
- configurable: true,
304
- enumerable: false,
305
- writable: true,
306
- value: (ev: any) => {
307
- // console.log( 'onceHandler execute:', that.constructor.prototype[key] );
308
- ( that.constructor.prototype[key] ).bind(that)(ev);
309
- }
310
- }
311
- );
312
- }
313
-
314
- if ( nativeEventNames.has( 'on' + nativeEventName ) ){ // native event defined in HTMLElement
315
- // console.log('added as native listener', target, nativeEventName );
316
- addListener( target, nativeEventName, listener, false, once );
317
- }
318
- });
319
- }
320
- }
321
-
322
327
  };
323
328
 
324
329
  class DC extends McBase {
325
330
 
331
+ protected __mc: { [key:string]: any } = {};
332
+
326
333
  constructor(target: HTMLElement ) {
327
334
  super(target);
328
-
329
- let that = this,
330
- isDomMcInstance = that.constructor === DC;
331
-
332
- setTimeout(
333
- () => {
334
- that.trigger('Init');
335
- if ( !isDomMcInstance ) {
336
- setTimeout(
337
- () => {
338
- let keys = Object.keys( (that as any)?._mc );
339
- if ( keys.length ){
340
- //console.log( 'inner Inits on [', that.constructor.name, ']', keys );
341
- keys?.forEach( (key: string) => {
342
- let mc = (that as any)?._mc?.[key];
343
- //console.log( key, typeof mc?.oneInit, mc );
344
- if ( mc?.oneInit && typeof mc?.oneInit == 'function' ){
345
- mc.oneInit( new McEvent('Init') );
346
- }
347
- });
348
- };
349
- }
350
- , 0
351
- );
352
- }
353
- }
354
- , 0
355
- );
356
-
357
- this.autoAttachListeners();
358
335
  }
359
336
 
360
337
  static debug: boolean = false;
@@ -364,17 +341,13 @@ class DC extends McBase {
364
341
  static trigger: Function = trigger;
365
342
 
366
343
  get _mc(): { [key:string]: any } {
367
- return this._mc;
344
+ return this.__mc;
368
345
  }
369
346
 
370
347
  trigger( ev: McEvent | string, data: any = {}, bubble?: string ) {
371
348
  MC.prototype.trigger.call( this, ev, data, bubble );
372
349
  };
373
350
 
374
- autoAttachListeners() {
375
- MC.prototype.autoAttachListeners.call( this );
376
- };
377
-
378
351
  parent(search: string = ''): any[] {
379
352
  let target: HTMLElement = (this as any).target;
380
353
  if (!isDOM(target)) return [];