ziko 2.0.0-beta.8 → 2.0.0-beta.9

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/ziko.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sat Sep 05 2026 12:37:55 GMT+0100 (UTC+01:00)
5
+ Date : Mon Sep 07 2026 22:41:50 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -278,16 +278,12 @@ let UIElement$1 = class UIElement extends UINode{
278
278
  constructor(){
279
279
  super();
280
280
  }
281
- init({element, name, type, render, props = {}, items = []} = {}){
281
+ init({element, name, type, mount, props = {}, items = []} = {}){
282
282
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
283
283
  if(typeof element === "string") {
284
284
  switch(type){
285
- case "html" : {
286
- element = globalThis?.document?.createElement(element);
287
- } break;
288
- case "svg" : {
289
- element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
290
- } break;
285
+ case "html" : element = globalThis?.document?.createElement(element); break;
286
+ case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element); break;
291
287
  default : throw Error("Not supported")
292
288
  }
293
289
  }
@@ -297,37 +293,37 @@ let UIElement$1 = class UIElement extends UINode{
297
293
  itemsTarget : this,
298
294
  isInteractive : false,
299
295
  parent:null,
300
- isBody:false,
301
- isRoot:false,
302
- isHidden: false,
303
- isFrozzen:false,
304
- attributes: {},
305
- filters: {},
306
- temp:{}
296
+ // isBody:false,
297
+ // isRoot:false,
298
+ // isHidden: false,
299
+ // isFrozzen:false,
300
+ // attributes: {},
301
+ // filters: {},
302
+ // temp:{}
307
303
  });
308
- this.events = {
309
- ptr:null,
310
- mouse:null,
311
- wheel:null,
312
- key:null,
313
- drag:null,
314
- drop:null,
315
- click:null,
316
- clipboard:null,
317
- focus:null,
318
- swipe:null,
319
- custom:null,
320
- };
321
- this.observer={
322
- resize:null,
323
- intersection:null
324
- };
304
+ // this.events = {
305
+ // ptr:null,
306
+ // mouse:null,
307
+ // wheel:null,
308
+ // key:null,
309
+ // drag:null,
310
+ // drop:null,
311
+ // click:null,
312
+ // clipboard:null,
313
+ // focus:null,
314
+ // swipe:null,
315
+ // custom:null,
316
+ // }
317
+ // this.observer={
318
+ // resize:null,
319
+ // intersection:null
320
+ // }
325
321
  if(element) Object.assign(this.cache,{element});
326
322
  this.items = new UIStore();
327
323
  globalThis.__Ziko__.__UI__[this.cache.name]
328
324
  ? globalThis.__Ziko__.__UI__[this.cache.name]?.push(this)
329
325
  : globalThis.__Ziko__.__UI__[this.cache.name]=[this];
330
- element && render && this?.render?.();
326
+ element && mount && this?.mount?.();
331
327
  globalThis.__Ziko__.__UI__.push(this);
332
328
 
333
329
  const parsed_props = parse_props(props);
@@ -384,12 +380,9 @@ function mount(target = this.target, delay = 0) {
384
380
  setTimeout(() => this.mount(target, 0), delay);
385
381
  return this;
386
382
  }
387
-
388
383
  if (this.isBody) return this;
389
-
390
384
  if (target?.isUIElement) target = target.element;
391
385
  this.target = target;
392
-
393
386
  this.target?.appendChild(this.element);
394
387
  return this;
395
388
  }
@@ -399,7 +392,6 @@ function unmount(delay = 0) {
399
392
  setTimeout(() => this.unmount(0), delay);
400
393
  return this;
401
394
  }
402
-
403
395
  if (this.cache.parent) {
404
396
  this.cache.parent.remove(this);
405
397
  } else if (
@@ -540,11 +532,11 @@ class UIText extends UINode {
540
532
  const text = (...str) => new UIText(...str);
541
533
 
542
534
  function append(...ele) {
543
- __addItem__.call(this, "append", "push", ...ele);
535
+ __addItems__.call(this, "append", "push", ...ele);
544
536
  return this;
545
537
  }
546
538
  function prepend(...ele) {
547
- this.__addItem__.call(this, "prepend", "unshift", ...ele);
539
+ this.__addItems__.call(this, "prepend", "unshift", ...ele);
548
540
  return this;
549
541
  }
550
542
  function insertAt(index, ...ele) {
@@ -586,58 +578,46 @@ function replaceElementWith(new_element){
586
578
  return this
587
579
  }
588
580
  function after(ui){
589
- if(ui?.isUIElement) ui=ui.element;
581
+ if(ui?.isUIElement) ui = ui.element;
590
582
  this.itemsTarget.element?.after(ui);
591
583
  return this;
592
584
  }
593
585
  function before(ui){
594
- if(ui?.isUIElement) ui=ui.element;
586
+ if(ui?.isUIElement) ui = ui.element;
595
587
  this.itemsTarget.element?.before(ui);
596
588
  return this;
597
589
  }
598
- async function __addItem__(adder, pusher, ...ele) {
599
- const itemsTarget_el = this.itemsTarget.element;
600
- const itemsTarget = this.itemsTarget;
601
- if (this.cache.isFrozzen) {
602
- console.warn("You can't append new item to frozzen element");
603
- return this;
590
+
591
+ async function __addItem__(adder, pusher, item, referenceNode = null, index = null) {
592
+ const { element: itemsTargetEl, items } = this.itemsTarget;
593
+ if (["number", "string"].includes(typeof item)) item = text(item);
594
+ if (typeof item === "function" && isStateGetter(item)) {
595
+ const getter = item();
596
+ item = text(getter.value);
597
+ getter._subscribe(
598
+ (newValue) => { item.element.textContent = newValue; },
599
+ item
600
+ );
604
601
  }
605
- for (let i = 0; i < ele.length; i++) {
606
- if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
607
- // Fix Items Latter
608
- if (ele[i] instanceof Function) {
609
- if (isStateGetter(ele[i])) {
610
- const getter = ele[i]();
611
- ele[i] = text(getter.value);
612
- getter._subscribe(
613
- (newValue) => (ele[i].element.textContent = newValue),
614
- ele[i]
615
- );
616
- // this.itemsTarget.element.appendChild(textNode);
617
- }
618
- }
619
- if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
620
- if (ele[i]?.isUINode) {
621
- ele[i].cache.parent = this;
622
- itemsTarget_el?.[adder](ele[i].element);
623
- ele[i].target = this.itemsTarget.element;
624
- itemsTarget.items[pusher](ele[i]);
625
- }
626
- else if(ele[i] instanceof Promise){
627
- const UIEle = await ele[i];
628
- UIEle.cache.parent = this;
629
- itemsTarget_el?.[adder](UIEle.element);
630
- UIEle.target = this.itemsTarget.element;
631
- itemsTarget.items[pusher](UIEle);
632
- }
633
- else if (ele[i] instanceof Object) {
634
- if (ele[i]?.style) this.style(ele[i]?.style);
635
- if (ele[i]?.attr) {
636
- Object.entries(ele[i].attr).forEach((n) =>
637
- this.setAttr("" + n[0], n[1]),
638
- );
639
- }
640
- }
602
+ if (typeof globalThis?.Node === "function" && item instanceof globalThis.Node)
603
+ item = new this.constructor(item);
604
+ if (item instanceof Promise) item = await item;
605
+ if (item?.isUINode) {
606
+ item.cache.parent = this;
607
+ item.target = itemsTargetEl;
608
+ if (adder === "insertBefore" && itemsTargetEl)
609
+ itemsTargetEl.insertBefore(item.element, referenceNode);
610
+ else if (typeof itemsTargetEl?.[adder] === "function")
611
+ itemsTargetEl[adder](item.element);
612
+ if (pusher === "splice" && index !== null) items.splice(index, 0, item);
613
+ else if (typeof items?.[pusher] === "function") items[pusher](item);
614
+ return;
615
+ }
616
+ }
617
+
618
+ async function __addItems__(adder, pusher, ...elements) {
619
+ for (const item of elements) {
620
+ await this.__addItem__(adder, pusher, item);
641
621
  }
642
622
  this.maintain();
643
623
  return this;
@@ -646,6 +626,7 @@ async function __addItem__(adder, pusher, ...ele) {
646
626
  var DomMethods = /*#__PURE__*/Object.freeze({
647
627
  __proto__: null,
648
628
  __addItem__: __addItem__,
629
+ __addItems__: __addItems__,
649
630
  after: after,
650
631
  append: append,
651
632
  before: before,
@@ -1358,9 +1339,9 @@ class UIElement extends UIElement$1{
1358
1339
  if(directive)this.element.setAttribute('data-hydration-directive', directive);
1359
1340
  return this;
1360
1341
  }
1361
- get st(){
1362
- return this.cache.style;
1363
- }
1342
+ // get st(){
1343
+ // return this.cache.style;
1344
+ // }
1364
1345
  get attr(){
1365
1346
  return this.cache.attributes;
1366
1347
  }
@@ -1755,7 +1736,7 @@ const is_anagram = (word, words) =>{
1755
1736
  const is_isogram = (text = '') => [...new Set(text.toLowerCase())].length === text.length;
1756
1737
 
1757
1738
  if(globalThis?.document){
1758
- document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
1739
+ document?.addEventListener('DOMContentLoaded', __Ziko__.__Config__.init());
1759
1740
  }
1760
1741
 
1761
1742
  // import './math/functions/proxy.js'
package/dist/ziko.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sat Sep 05 2026 12:37:55 GMT+0100 (UTC+01:00)
5
+ Date : Mon Sep 07 2026 22:41:50 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -282,16 +282,12 @@
282
282
  constructor(){
283
283
  super();
284
284
  }
285
- init({element, name, type, render, props = {}, items = []} = {}){
285
+ init({element, name, type, mount, props = {}, items = []} = {}){
286
286
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
287
287
  if(typeof element === "string") {
288
288
  switch(type){
289
- case "html" : {
290
- element = globalThis?.document?.createElement(element);
291
- } break;
292
- case "svg" : {
293
- element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
294
- } break;
289
+ case "html" : element = globalThis?.document?.createElement(element); break;
290
+ case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element); break;
295
291
  default : throw Error("Not supported")
296
292
  }
297
293
  }
@@ -301,37 +297,37 @@
301
297
  itemsTarget : this,
302
298
  isInteractive : false,
303
299
  parent:null,
304
- isBody:false,
305
- isRoot:false,
306
- isHidden: false,
307
- isFrozzen:false,
308
- attributes: {},
309
- filters: {},
310
- temp:{}
300
+ // isBody:false,
301
+ // isRoot:false,
302
+ // isHidden: false,
303
+ // isFrozzen:false,
304
+ // attributes: {},
305
+ // filters: {},
306
+ // temp:{}
311
307
  });
312
- this.events = {
313
- ptr:null,
314
- mouse:null,
315
- wheel:null,
316
- key:null,
317
- drag:null,
318
- drop:null,
319
- click:null,
320
- clipboard:null,
321
- focus:null,
322
- swipe:null,
323
- custom:null,
324
- };
325
- this.observer={
326
- resize:null,
327
- intersection:null
328
- };
308
+ // this.events = {
309
+ // ptr:null,
310
+ // mouse:null,
311
+ // wheel:null,
312
+ // key:null,
313
+ // drag:null,
314
+ // drop:null,
315
+ // click:null,
316
+ // clipboard:null,
317
+ // focus:null,
318
+ // swipe:null,
319
+ // custom:null,
320
+ // }
321
+ // this.observer={
322
+ // resize:null,
323
+ // intersection:null
324
+ // }
329
325
  if(element) Object.assign(this.cache,{element});
330
326
  this.items = new UIStore();
331
327
  globalThis.__Ziko__.__UI__[this.cache.name]
332
328
  ? globalThis.__Ziko__.__UI__[this.cache.name]?.push(this)
333
329
  : globalThis.__Ziko__.__UI__[this.cache.name]=[this];
334
- element && render && this?.render?.();
330
+ element && mount && this?.mount?.();
335
331
  globalThis.__Ziko__.__UI__.push(this);
336
332
 
337
333
  const parsed_props = parse_props(props);
@@ -388,12 +384,9 @@
388
384
  setTimeout(() => this.mount(target, 0), delay);
389
385
  return this;
390
386
  }
391
-
392
387
  if (this.isBody) return this;
393
-
394
388
  if (target?.isUIElement) target = target.element;
395
389
  this.target = target;
396
-
397
390
  this.target?.appendChild(this.element);
398
391
  return this;
399
392
  }
@@ -403,7 +396,6 @@
403
396
  setTimeout(() => this.unmount(0), delay);
404
397
  return this;
405
398
  }
406
-
407
399
  if (this.cache.parent) {
408
400
  this.cache.parent.remove(this);
409
401
  } else if (
@@ -544,11 +536,11 @@
544
536
  const text = (...str) => new UIText(...str);
545
537
 
546
538
  function append(...ele) {
547
- __addItem__.call(this, "append", "push", ...ele);
539
+ __addItems__.call(this, "append", "push", ...ele);
548
540
  return this;
549
541
  }
550
542
  function prepend(...ele) {
551
- this.__addItem__.call(this, "prepend", "unshift", ...ele);
543
+ this.__addItems__.call(this, "prepend", "unshift", ...ele);
552
544
  return this;
553
545
  }
554
546
  function insertAt(index, ...ele) {
@@ -590,58 +582,46 @@
590
582
  return this
591
583
  }
592
584
  function after(ui){
593
- if(ui?.isUIElement) ui=ui.element;
585
+ if(ui?.isUIElement) ui = ui.element;
594
586
  this.itemsTarget.element?.after(ui);
595
587
  return this;
596
588
  }
597
589
  function before(ui){
598
- if(ui?.isUIElement) ui=ui.element;
590
+ if(ui?.isUIElement) ui = ui.element;
599
591
  this.itemsTarget.element?.before(ui);
600
592
  return this;
601
593
  }
602
- async function __addItem__(adder, pusher, ...ele) {
603
- const itemsTarget_el = this.itemsTarget.element;
604
- const itemsTarget = this.itemsTarget;
605
- if (this.cache.isFrozzen) {
606
- console.warn("You can't append new item to frozzen element");
607
- return this;
594
+
595
+ async function __addItem__(adder, pusher, item, referenceNode = null, index = null) {
596
+ const { element: itemsTargetEl, items } = this.itemsTarget;
597
+ if (["number", "string"].includes(typeof item)) item = text(item);
598
+ if (typeof item === "function" && isStateGetter(item)) {
599
+ const getter = item();
600
+ item = text(getter.value);
601
+ getter._subscribe(
602
+ (newValue) => { item.element.textContent = newValue; },
603
+ item
604
+ );
608
605
  }
609
- for (let i = 0; i < ele.length; i++) {
610
- if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
611
- // Fix Items Latter
612
- if (ele[i] instanceof Function) {
613
- if (isStateGetter(ele[i])) {
614
- const getter = ele[i]();
615
- ele[i] = text(getter.value);
616
- getter._subscribe(
617
- (newValue) => (ele[i].element.textContent = newValue),
618
- ele[i]
619
- );
620
- // this.itemsTarget.element.appendChild(textNode);
621
- }
622
- }
623
- if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
624
- if (ele[i]?.isUINode) {
625
- ele[i].cache.parent = this;
626
- itemsTarget_el?.[adder](ele[i].element);
627
- ele[i].target = this.itemsTarget.element;
628
- itemsTarget.items[pusher](ele[i]);
629
- }
630
- else if(ele[i] instanceof Promise){
631
- const UIEle = await ele[i];
632
- UIEle.cache.parent = this;
633
- itemsTarget_el?.[adder](UIEle.element);
634
- UIEle.target = this.itemsTarget.element;
635
- itemsTarget.items[pusher](UIEle);
636
- }
637
- else if (ele[i] instanceof Object) {
638
- if (ele[i]?.style) this.style(ele[i]?.style);
639
- if (ele[i]?.attr) {
640
- Object.entries(ele[i].attr).forEach((n) =>
641
- this.setAttr("" + n[0], n[1]),
642
- );
643
- }
644
- }
606
+ if (typeof globalThis?.Node === "function" && item instanceof globalThis.Node)
607
+ item = new this.constructor(item);
608
+ if (item instanceof Promise) item = await item;
609
+ if (item?.isUINode) {
610
+ item.cache.parent = this;
611
+ item.target = itemsTargetEl;
612
+ if (adder === "insertBefore" && itemsTargetEl)
613
+ itemsTargetEl.insertBefore(item.element, referenceNode);
614
+ else if (typeof itemsTargetEl?.[adder] === "function")
615
+ itemsTargetEl[adder](item.element);
616
+ if (pusher === "splice" && index !== null) items.splice(index, 0, item);
617
+ else if (typeof items?.[pusher] === "function") items[pusher](item);
618
+ return;
619
+ }
620
+ }
621
+
622
+ async function __addItems__(adder, pusher, ...elements) {
623
+ for (const item of elements) {
624
+ await this.__addItem__(adder, pusher, item);
645
625
  }
646
626
  this.maintain();
647
627
  return this;
@@ -650,6 +630,7 @@
650
630
  var DomMethods = /*#__PURE__*/Object.freeze({
651
631
  __proto__: null,
652
632
  __addItem__: __addItem__,
633
+ __addItems__: __addItems__,
653
634
  after: after,
654
635
  append: append,
655
636
  before: before,
@@ -1362,9 +1343,9 @@
1362
1343
  if(directive)this.element.setAttribute('data-hydration-directive', directive);
1363
1344
  return this;
1364
1345
  }
1365
- get st(){
1366
- return this.cache.style;
1367
- }
1346
+ // get st(){
1347
+ // return this.cache.style;
1348
+ // }
1368
1349
  get attr(){
1369
1350
  return this.cache.attributes;
1370
1351
  }
@@ -1759,7 +1740,7 @@
1759
1740
  const is_isogram = (text = '') => [...new Set(text.toLowerCase())].length === text.length;
1760
1741
 
1761
1742
  if(globalThis?.document){
1762
- document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
1743
+ document?.addEventListener('DOMContentLoaded', __Ziko__.__Config__.init());
1763
1744
  }
1764
1745
 
1765
1746
  // import './math/functions/proxy.js'
package/dist/ziko.min.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  Project: ziko.js
3
3
  Author: Zakaria Elalaoui
4
- Date : Sat Sep 05 2026 12:37:55 GMT+0100 (UTC+01:00)
4
+ Date : Mon Sep 07 2026 22:41:50 GMT+0100 (UTC+01:00)
5
5
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
6
6
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
7
7
  Released under MIT License
8
8
  */
9
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ziko={})}(this,function(e){"use strict";const{PI:t,E:s}=Math,n=Number.EPSILON,i=(e,...t)=>{const s=t.map(t=>{return"object"!=typeof(s=t)&&"function"!=typeof s||null===s||t?.__mapfun__?e(t):t instanceof Array?t.map(t=>i(e,t)):ArrayBuffer.isView(t)?t.map(t=>e(t)):t instanceof Set?new Set(i(e,...t)):t instanceof Map?new Map([...t].map(t=>[t[0],i(e,t[1])])):t.isMatrix?.()?new t.constructor(t.rows,t.cols,i(t.arr.flat(1))):t instanceof Object?Object.fromEntries(Object.entries(t).map(t=>[t[0],i(e,t[1])])):void 0;var s});return 1==s.length?s[0]:s},r=(e,t)=>e.isComplex?.()?new e.constructor(t(e.a),t(e.b)):e.isMatrix?.()?new e.constructor(e.rows,e.cols,e.arr.flat(1).map(t)):(e instanceof Array&&i(t,...e),t(e)),a=(e,t,s)=>r(e,e=>t!==s?(e-t)/(s-t):0),o=(e,t,s)=>r(e,e=>(s-t)*e+t),c=(e,t,s=!0)=>{if(e instanceof Array&&!(t instanceof Array))return i(e=>c(e,t,s),...e);if(t instanceof Array&&!(e instanceof Array))return i(t=>c(e,t,s),...t);if(e instanceof Array&&t instanceof Array)return e.map((e,n)=>c(e,t[n],s));const n=Math.atan2(e,t);return s?n:180*n/Math.PI};class l{constructor(e){this.cache={node:e}}isUINode(){return!0}get node(){return this.cache.node}}class h extends Array{constructor(...e){super(...e)}clear(){return this.length=0,this}getItemById(e){return this.find(t=>t.element.id===e)}getItemsByTagName(e){return this.filter(t=>t.element.tagName.toLowerCase()===e.toLowerCase())}getElementsByClassName(e){return this.filter(t=>t.element.classList?.contains(e))}querySelector(e){const t=globalThis?.document?.querySelector(e);return t&&this.find(e=>e.element===t)||null}querySelectorAll(e){const t=globalThis?.document?.querySelectorAll(e);return Array.from(t).map(e=>this.find(t=>t.element===e)).filter(Boolean)}}const u=new h,m={default:{target:null,render:!0},setDefault:function(e){const t=Object.keys(e),s=Object.values(e);for(let e=0;e<t.length;e++)this.default[t[e]]=s[e]},init:()=>{},renderingMode:"spa",isSSC:!1},p={store:new Map,index:0,register:function(e){this.store.set(this.index++,e)},reset(){this.index=0,this.store.clear()}},f={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(e){}};var d={store:new Map,index:0,session_storage:null,register:function(e){},update:function(e,t){}};var g;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:u,__HYDRATION__:p,__State__:d,__Config__:m,__CACHE__:f,__PROVIDERS__:{}},g=__Ziko__,Object.defineProperties(g,{QueryParams:{get:function(){return function(e){const t={};return e.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi,e=>{const[s,n]=e.split("=");t[s]=n}),t}(globalThis.location.search.substring(1))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}}));let _=class extends l{constructor(){super()}init({element:e,name:t,type:s,render:n,props:i={},items:r=[]}={}){if(this.target=globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body,"string"==typeof e)switch(s){case"html":e=globalThis?.document?.createElement(e);break;case"svg":e=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg",e);break;default:throw Error("Not supported")}else this.target=e?.parentElement;Object.assign(this.cache,{name:t,itemsTarget:this,isInteractive:!1,parent:null,isBody:!1,isRoot:!1,isHidden:!1,isFrozzen:!1,attributes:{},filters:{},temp:{}}),this.events={ptr:null,mouse:null,wheel:null,key:null,drag:null,drop:null,click:null,clipboard:null,focus:null,swipe:null,custom:null},this.observer={resize:null,intersection:null},e&&Object.assign(this.cache,{element:e}),this.items=new h,globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this],e&&n&&this?.render?.(),globalThis.__Ziko__.__UI__.push(this);const a=((e={})=>{const t={methods:{},events:{},style:{},attrs:{}};for(const[s,n]of Object.entries(e))"style"===s?t.style=n:s.startsWith("$")?t.methods[s.slice(1)]=n:/^on[A-Z]/.test(s)?t.events[s]=n:t.attrs[s]=n;return t})(i);this.parsed_props=a,this.style(a.style),this.setAttr(a.attrs);Object.entries(a.events).forEach(([e,t])=>this[e](t.bind(this))),r.length>0&&this.append(...r)}get element(){return this.cache.element}[Symbol.iterator](){return this.items[Symbol.iterator]()}maintain(){for(let e=0;e<this.items.length;e++)Object.defineProperty(this,e,{value:this.items[e],writable:!0,configurable:!0,enumerable:!1})}isInteractive(){return this.cache.isInteractive}isUIElement(){return!0}};function b(e,...t){t.forEach(t=>function(e,t){const s=Object.getOwnPropertyDescriptors(t);for(const t of Reflect.ownKeys(s)){const n=s[t];"get"in n||"set"in n||"function"!=typeof n.value?Object.defineProperty(Object.getPrototypeOf(e),t,n):"function"==typeof n.value&&(Object.getPrototypeOf(e).hasOwnProperty(t)||Object.defineProperty(Object.getPrototypeOf(e),t,n))}}(e,t))}var v=Object.freeze({__proto__:null,mount:function(e=this.target,t=0){return t>0?(setTimeout(()=>this.mount(e,0),t),this):(this.isBody||(e?.isUIElement&&(e=e.element),this.target=e,this.target?.appendChild(this.element)),this)},unmount:function(e=0){return e>0?(setTimeout(()=>this.unmount(0),e),this):(this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target.children].includes(this.element)&&this.target.removeChild(this.element),this)}});const y=Symbol.for("ziko/hooks/STATE_GETTER");function w(e){const t={value:e,subscribers:new Set,paused:!1};function s(){return{value:t.value,_subscribe:e=>(t.subscribers.add(e),()=>t.subscribers.delete(e))}}s[y]=!0;return[s,function(e){t.paused||("function"==typeof e&&(e=e(t.value)),Object.is(e,t.value)||(t.value=e,t.subscribers.forEach(e=>e(t.value))))},{pause:()=>{t.paused=!0},resume:()=>{t.paused=!1},clear:()=>{t.subscribers.clear()},force:e=>{"function"==typeof e&&(e=e(t.value)),t.value=e,t.subscribers.forEach(e=>e(t.value))},getSubscribers:()=>new Set(t.subscribers)}]}const k=e=>"function"==typeof e&&!0===e[y];function T(e,t){if(globalThis.SVGAElement&&this.element instanceof globalThis.SVGAElement&&(e=is_camelcase(e)?camel2hyphencase(e):e),!this?.attr[e]||this?.attr[e]!==t){if(k(t)){t()._subscribe(t=>this.element?.setAttribute(e,t),this)}else this.element?.setAttribute(e,t);Object.assign(this.cache.attributes,{[e]:t})}}var E=Object.freeze({__proto__:null,_set_attrs_:T,getAttr:function(e){return this.element.attributes[e].value},removeAttr:function(...e){for(let t=0;t<e.length;t++)this.element?.removeAttribute(e[t]);return this},setAttr:function(e,t){if(e instanceof Object){const[s,n]=[Object.keys(e),Object.values(e)];for(let e=0;e<s.length;e++)n[e]instanceof Array&&(t[e]=n[e].join(" ")),T.call(this,s[e],n[e])}else t instanceof Array&&(t=t.join(" ")),T.call(this,e,t);return this},setContentEditable:function(e=!0){return this.setAttr("contenteditable",e),this}});class C extends l{constructor(...e){super("span","text",!1,...e),this.element=globalThis?.document?.createTextNode(...e)}isText(){return!0}}const x=(...e)=>new C(...e);async function A(e,t,...s){const n=this.itemsTarget.element,i=this.itemsTarget;if(this.cache.isFrozzen)return console.warn("You can't append new item to frozzen element"),this;for(let r=0;r<s.length;r++){if(["number","string"].includes(typeof s[r])&&(s[r]=x(s[r])),s[r]instanceof Function&&k(s[r])){const e=s[r]();s[r]=x(e.value),e._subscribe(e=>s[r].element.textContent=e,s[r])}if("function"==typeof globalThis?.Node&&s[r]instanceof globalThis?.Node&&(s[r]=new this.constructor(s[r])),s[r]?.isUINode)s[r].cache.parent=this,n?.[e](s[r].element),s[r].target=this.itemsTarget.element,i.items[t](s[r]);else if(s[r]instanceof Promise){const a=await s[r];a.cache.parent=this,n?.[e](a.element),a.target=this.itemsTarget.element,i.items[t](a)}else s[r]instanceof Object&&(s[r]?.style&&this.style(s[r]?.style),s[r]?.attr&&Object.entries(s[r].attr).forEach(e=>this.setAttr(""+e[0],e[1])))}return this.maintain(),this}var O=Object.freeze({__proto__:null,__addItem__:A,after:function(e){return e?.isUIElement&&(e=e.element),this.itemsTarget.element?.after(e),this},append:function(...e){return A.call(this,"append","push",...e),this},before:function(e){return e?.isUIElement&&(e=e.element),this.itemsTarget.element?.before(e),this},clear:function(){return this?.items?.forEach(e=>e.unmount()),this.itemsTarget.element.innerHTML="",this},insertAt:function(e,...t){const s=this.itemsTarget;if(e>=s.items.length)return this.append(...t);for(let n=0;n<t.length;n++)["number","string"].includes(typeof t[n])&&(t[n]=x(t[n])),s.element?.insertBefore(t[n].element,s.items[e].element),s.items.splice(e,0,t[n]);return s.maintain(),this},prepend:function(...e){return this.__addItem__.call(this,"prepend","unshift",...e),this},remove:function(...e){const t=e=>{"number"==typeof e&&(e=this.items[e]),e?.isUIElement&&this.itemsTarget.element?.removeChild(e.element),this.items=this.items.filter(t=>t!==e)};for(let s=0;s<e.length;s++)t(e[s]);for(let e=0;e<this.items.length;e++)Object.assign(this,{[[e]]:this.items[e]});return this},replaceElementWith:function(e){return this.cache.element.replaceWith(e),this.cache.element=e,this}});var L=Object.freeze({__proto__:null,at:function(e){return this.items.at(e)},find:function(e){return this.items.filter(e)},forEach:function(e){return this.items.forEach(e),this},map:function(e){return this.items.map(e)}});var j=Object.freeze({__proto__:null,animate:function(e,{duration:t=1e3,iterations:s=1,easing:n="ease"}={}){return this.element?.animate(e,{duration:t,iterations:s,easing:n}),this},hide:function(){},show:function(){},size:function(e,t){return this.style({width:e,height:t})},style:function(e){if(!this.element?.style)return this;for(let t in e){const s=e[t];if(k(s)){const e=s();Object.assign(this.element.style,{[t]:e.value}),e._subscribe(e=>{console.log({newValue:e}),Object.assign(this.element.style,{[t]:e})})}else Object.assign(this.element.style,{[t]:s})}return this}});class I{constructor(e,t){this.cache={category:t,target:e,listeners:{},currentEvent:null,event:null,customEvents:new Set}}get event(){return this.cache.event}get target(){return this.cache.target}get element(){return this.cache.target.element}get currentEvent(){return this.cache.currentEvent}addListener(e,t,{preventDefault:s=!1,paused:n=!1}={}){return this.cache.listeners[e]={callback:s=>{this.cache.event=s,this.cache.listeners[e].preventDefault&&s.preventDefault(),this.cache.listeners[e].paused||(this.cache.currentEvent=e,t.call(this,this))},preventDefault:s,paused:n},this.element.addEventListener(e,this.cache.listeners[e].callback),this}removeListener(e){return this.element.removeEventListener(e,this.cache.listeners[e].callback),this}pause(e){return this.cache.listeners[e].paused=!0,this}resume(e){return this.cache.listeners[e].paused=!1,this}preventDefault(e){return this.cache.listeners[e].preventDefault=!0,this}useDefault(e){return this.cache.listeners[e].preventDefault=!1,this}}class S extends Event{constructor(e,t){super("clickaway",{bubbles:!0,cancelable:!0}),this.originalEvent=e,this.targetElement=t}}function M(e){function t(t){if(!e.contains(t.target)){const s=new S(t,e);e.dispatchEvent(s)}}return globalThis?.document?.addEventListener("click",t),()=>globalThis?.document?.removeEventListener("click",t)}const P=(e,t=!1)=>{const s=e.element.getBoundingClientRect(),n=e.event;let i=n?.clientX-s.left|0,r=n?.clientY-s.top|0;if(t){const t=e.element.clientWidth,s=e.element.clientHeight;i=+(i/t*2-1).toFixed(8),r=+(r/s*-2+1).toFixed(8)}return{x:i,y:r}},D="click",z={onClick(e){return this.on("click",e,{category:D})},onDblClick(e){return this.on("dblclick",e,{category:D})},onClickAway(e){var t,s,n;return t=this,s=D,n="clickaway",t.exp.events?.[s]?.cache?.customEvents?.has(n)||M(this.element),this.on("clickaway",e,{category:D,isCustom:!0})}},U="ptr",Z={onPtrDown(e,t=!1){return this.on("pointerdown",e,{category:U,details_setter:e=>{const{x:s,y:n}=P(e,t);e.dx=s,e.dy=n,e.isDown=!0,e.isDragging=e.isMoving??!1}})},onPtrMove(e,t=!1){return this.on("pointermove",e,{category:U,details_setter:e=>{const{x:s,y:n}=P(e,t);e.mx=s,e.my=n,e.isMoving=!0,e.isDragging=e.isDown??!1}})},onPtrUp(e,t=!1){return this.on("pointerup",e,{category:U,details_setter:e=>{const{x:s,y:n}=P(e,t);e.ux=s,e.uy=n,e.isDown=!1,e.isMoving=!1,e.isDragging=!1}})}},R="key",N={onKeyDown(e){return this.on("keydown",e,{category:R,details_setter:e=>{e.kd=e.event.key}})},onKeyPress(e){return this.on("keypress",e,{category:R,details_setter:e=>{e.kp=e.event.key}})},onKeyUp(e){return this.on("keydown",e,{category:R,details_setter:e=>{e.ku=e.event.key}})}};class B{constructor(e,t,s=1/0,n){this.ms=t,this.fn=e,this.count=s,this.frame=1,this.id=null,this.running=!1,n&&this.start()}start(){return this.running||(this.running=!0,this.frame=1,this.id=setInterval(()=>{this.frame>this.count?this.stop():(this.fn.call(null,this),this.frame++)},this.ms)),this}stop(){return this.running&&(this.running=!1,clearInterval(this.id),this.id=null),this}isRunning(){return this.running}}class G extends B{constructor(e=1e3/60){super(e,()=>this._tick()),this.elapsed=0,this._lastTime=performance.now(),this._callbacks=new Set}_tick(){const e=performance.now(),t=e-this._lastTime;this.elapsed+=t,this._lastTime=e;for(const e of this._callbacks)e({elapsed:this.elapsed,delta:t})}onTick(e){return this._callbacks.add(e),()=>this._callbacks.delete(e)}reset(){this.elapsed=0,this._lastTime=performance.now()}pause(){super.stop()}resume(){this._lastTime=performance.now(),super.start()}}class F{constructor(e=[],{repeat:t=1,loop:s=!1}={}){this.tasks=e,this.repeat=t,this.loop=s,this.stopped=!1,this.running=!1,this.onStart=null,this.onTask=null,this.onEnd=null}async run(){if(this.running)return;this.running=!0,this.stopped=!1,this.onStart&&this.onStart();let e=this.repeat;do{for(const e of this.tasks){if(this.stopped)return;if(Array.isArray(e))await Promise.all(e.map(({fn:e,delay:t=0})=>new Promise(async s=>{t>0&&await new Promise(e=>setTimeout(e,t)),this.onTask&&this.onTask(e),await e(),s()})));else{const{fn:t,delay:s=0}=e;s>0&&await new Promise(e=>setTimeout(e,s)),this.onTask&&this.onTask(t),await t()}}}while(this.loop&&!this.stopped&&(e===1/0||e-- >1));!this.stopped&&this.onEnd&&this.onEnd(),this.running=!1}stop(){this.stopped=!0,this.running=!1}addTask(e){this.tasks.push(e)}clearTasks(){this.tasks=[]}}const H=(e,t)=>{let s=0;return(...n)=>{const i=(new Date).getTime();i-s<t||(s=i,e(...n))}};class V extends CustomEvent{constructor(e,t,{bubbles:s=!0,cancelable:n=!0}={}){super(e,{detail:t,bubbles:s,cancelable:n})}}function Y(e,{intersection:t=!0,resize:s=!0,threshold:n=0,throttleResize:i=100,throttleEnterExit:r=0}={}){let a,o;const c=t=>{for(let s of t){const{width:t,height:n}=s.contentRect;e.dispatchEvent(new V("resizeview",{width:t,height:n,entry:s}))}},l=i>0?H(c,i):c,h=t=>{for(let s of t){const t=s.isIntersecting?"enterview":"exitview";e.dispatchEvent(new V(t,s))}},u=r>0?H(h,r):h;return t&&(a=new IntersectionObserver(u,{threshold:n}),a.observe(e)),s&&(o=new ResizeObserver(l),o.observe(e)),()=>{a&&(a.unobserve(e),a.disconnect()),o&&(o.unobserve(e),o.disconnect())}}const q="view",$={onEnterView(e){return this.exp.events?.[q]||Y(this.element),this.on("enterview",e,{category:q,isCustom:!0})},onExitView(e){return this.exp.events?.[q]||Y(this.element),this.on("exitview",e,{category:q,isCustom:!0})},onResizeView(e){return this.exp.events?.[q]||Y(this.element),this.on("resizeview",e,{category:q,isCustom:!0})}};class K extends CustomEvent{constructor(e,t){super(e,{detail:t,bubbles:!0,cancelable:!0})}}class W extends _{constructor({element:e,name:t="",type:s="html",render:n=__Ziko__.__Config__.default.render,props:i}={}){super(),this.exp={events:{}},b(this,v,E,O,j,L,Z,z,N,$),e&&this.init({element:e,name:t,type:s,render:n,props:i})}on(e,t,{details_setter:s,category:n="global",isCustom:i=!1,preventDefault:r=!1}={}){e instanceof Array&&e.forEach(e=>this.on(e,t,{details_setter:s,category:n,isCustom:i,preventDefault:r})),n&&!this.exp.events.hasOwnProperty(n)&&(this.exp.events[n]=new I(this,n)),i&&this.exp.events[n].cache.customEvents.add(e);const a=this.exp.events[n];return a.addListener(e,e=>{s&&s(a),t(e)},{preventDefault:r}),this}_off(e,t="global"){return this.exp.events[t].removeListener(e),this}get element(){return this.cache.element}get itemsTarget(){return this.cache.itemsTarget}get itemsTargetElement(){return this.itemsTarget.element}setItemsTarget(e){return this.cache.itemsTarget=e,this.items=e.items,this}isInteractive(){return this.cache.isInteractive}useClient(e){return this.cache.isInteractive||(this.element.setAttribute("data-hydration-index",globalThis.__Ziko__.__HYDRATION__.index),globalThis.__Ziko__.__HYDRATION__.register(()=>this),this.cache.isInteractive=!0),e&&this.element.setAttribute("data-hydration-directive",e),this}get st(){return this.cache.style}get attr(){return this.cache.attributes}get evt(){return this.events}get html(){return this.element.innerHTML}get text(){return this.element.textContent}get parent(){return this.cache.parent}get width(){return this.element.getBoundingClientRect().width}get height(){return this.element.getBoundingClientRect().height}get top(){return this.element.getBoundingClientRect().top}get right(){return this.element.getBoundingClientRect().right}get bottom(){return this.element.getBoundingClientRect().bottom}get left(){return this.element.getBoundingClientRect().left}}const X=["a","abb","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","ipnut","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],J=["svg","g","defs","symbol","use","image","switch","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","textPath","altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","linearGradient","radialGradient","pattern","solidColor","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncR","feFuncG","feFuncB","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","animate","animateMotion","animateTransform","set","script","desc","title","metadata","foreignObject"],Q=["math","annotation","merror","mfrac","mi","mprescripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","semantics","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"],ee=new Proxy({},{get(e,t){if("string"!=typeof t)return;let s,n=t.replaceAll("_","-").toLowerCase();return X.includes(n)&&(s="html"),J.includes(n)&&(s="svg"),Q.includes(n)&&(s="mathml"),(...e)=>0===e.length?new W({element:n,name:n,type:s}):["string","number"].includes(typeof e[0])||e[0]instanceof W||k(e[0])||e[0]instanceof HTMLElement?new W({element:n,name:n,type:s}).append(...e):new W({element:n,type:s,props:e.shift()}).append(...e)}});class te{constructor(e=10){this.events={},this.maxListeners=e}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),this.events[e].length>this.maxListeners&&console.warn(`Warning: Possible memory leak. Event '${e}' has more than ${this.maxListeners} listeners.`),this}once(e,t){const s=(...n)=>{this.off(e,s),t(...n)};return this.on(e,s)}off(e,t){const s=this.events[e];if(!s)return this;const n=s.indexOf(t);return-1!==n&&s.splice(n,1),this}emit(e,t){const s=this.events[e];return!!s&&([...s].forEach(s=>{try{s(t)}catch(t){console.error(`Error in listener for '${e}':`,t)}}),!0)}remove(e){return delete this.events[e],this}clear(){return this.events={},this}setMaxListeners(e){return this.maxListeners=e,this}}globalThis?.document&&document?.addEventListener("DOMContentLoaded",__Ziko__.__Config__.init()),e.ClickAwayEvent=S,e.ClickListeners=z,e.Clock=G,e.E=s,e.EPSILON=n,e.EventController=I,e.KeyListeners=N,e.PI=t,e.PtrListeners=Z,e.Scheduler=(e,{repeat:t=null}={})=>new F(e,{repeat:t}),e.SwipeEvent=K,e.Tick=B,e.TimeScheduler=F,e.UIElement=W,e.ViewEvent=V,e.ViewListeners=$,e.apply_fun=r,e.atan2=c,e.camel2constantcase=(e="")=>e.replace(/[A-Z]/g,e=>"_"+e).toUpperCase(),e.camel2hyphencase=(e="")=>e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),e.camel2pascalcase=(e="")=>e.charAt(0).toUpperCase()+e.slice(1),e.camel2snakecase=(e="")=>e.replace(/[A-Z]/g,e=>"_"+e.toLowerCase()),e.clamp=(e,t,s)=>r(e,e=>Math.min(Math.max(e,t),s)),e.clock=e=>new G(e),e.constant2camelcase=(e="")=>e.toLowerCase().replace(/_([a-z])/g,e=>e[1].toUpperCase()),e.constant2hyphencase=(e="")=>e.toLowerCase().replace(/_/g,"-"),e.constant2pascalcase=(e="")=>e.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(""),e.constant2snakecase=(e="")=>e.toLowerCase(),e.debounce=(e,t=1e3)=>(...s)=>setTimeout(()=>e(...s),t),e.deg2rad=(...e)=>i(e=>e*Math.PI/180,...e),e.hyphen2camelcase=(e="")=>e.replace(/-([a-z])/g,e=>e[1].toUpperCase()),e.hyphen2constantcase=(e="")=>e.replace(/-/g,"_").toUpperCase(),e.hyphen2pascalcase=(e="")=>e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(""),e.hyphen2snakecase=(e="")=>e.replace(/-/g,"_"),e.hypot=(...e)=>{const t=e.find(e=>e.isComplex?.());if(t){const s=e.map(e=>e.isComplex?.()?e:new t.constructor(e,0));return Math.hypot(...s.map(e=>e.z))}return Math.hypot(...e)},e.isStateGetter=k,e.is_anagram=(e,t)=>(e=e.split("").sort(),t=t.split("").sort(),JSON.stringify(e)===JSON.stringify(t)),e.is_camelcase=(e="")=>{if(0===e.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(e)},e.is_hyphencase=(e="")=>e.split("-").length>0,e.is_isogram=(e="")=>[...new Set(e.toLowerCase())].length===e.length,e.is_palindrome=e=>{const t=e.toLocaleLowerCase();let s,n=t.length;for(s=0;s<n/2;s++)if(t[s]!=t[n-s-1])return!1;return!0},e.is_pascalcalse=(e="")=>{if(0===e.length)return!1;return/^[A-Z][a-zA-Z0-9]*$/.test(e)},e.is_snakeCase=(e="")=>e.split("_").length>0,e.lerp=o,e.map=(e,t,s,n,i)=>r(e,e=>o(a(e,t,s),n,i)),e.mapfun=i,e.norm=a,e.pascal2camelcase=(e="")=>e.charAt(0).toLowerCase()+e.slice(1),e.pascal2constantcase=(e="")=>e.replace(/([A-Z])/g,(e,t)=>t?"_"+e:e).toUpperCase(),e.pascal2hyphencase=(e="")=>e.replace(/([A-Z])/g,(e,t)=>t?"-"+e.toLowerCase():e.toLowerCase()),e.pascal2snakecase=(e="")=>e.replace(/([A-Z])/g,(e,t)=>t?"_"+e.toLowerCase():e.toLowerCase()),e.rad2deg=(...e)=>i(e=>e/Math.PI*180,...e),e.register_click_away_event=M,e.register_swipe_event=function(e,t=5,s=100,n=500){let i=0,r=0,a=0,o=!1;function c(e){i=e.clientX,r=e.clientY,a=performance.now(),o=!0}function l(c){if(!o)return;o=!1;const l=c.clientX-i,h=c.clientY-r;let u=null,m=null;performance.now()-a<=n&&(Math.abs(l)>=t&&Math.abs(h)<=s?(u=l<0?"left":"right",m="swipe"+u):Math.abs(h)>=t&&Math.abs(l)<=s&&(u=h<0?"up":"down",m="swipe"+u)),m&&e.dispatchEvent(new K(m,{direction:u,distX:l,distY:h,originalEvent:c}))}return e.addEventListener("pointerdown",c,{passive:!0}),e.addEventListener("pointerup",l,{passive:!0}),()=>{e.removeEventListener("pointerdown",c),e.removeEventListener("pointerup",l)}},e.register_view_event=Y,e.sleep=e=>new Promise(t=>setTimeout(t,e)),e.snake2camelcase=(e="")=>e.replace(/(_\w)/g,e=>e[1].toUpperCase()),e.snake2constantcase=(e="")=>e.toUpperCase(),e.snake2hyphencase=(e="")=>e.replace(/_/g,"-"),e.snake2pascalcase=(e="")=>e.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(""),e.tags=ee,e.throttle=H,e.tick=(e,t,s=1/0,n=!0)=>new B(e,t,s,n),e.timeout=function(e,t){let s;const n=new Promise(n=>{s=setTimeout(()=>{t&&t(),n()},e)});return{id:s,clear:()=>clearTimeout(s),promise:n}},e.useDerived=function(e,t){const s=()=>e(...t.map(e=>e().value));let n=s();const i=new Set,r=()=>{const e=s();Object.is(e,n)||(n=e,i.forEach(e=>e(n)))};t.map(e=>e()._subscribe(r));const a=()=>({value:n,_subscribe:e=>(i.add(e),()=>i.delete(e))});return a[y]=!0,a},e.useEffect=(e,t=[])=>{const s=t.filter(k);let n;const i=()=>{"function"==typeof n&&n(),n=e(s.map(e=>e().value))},r=s.map(e=>e()._subscribe(i));return i(),()=>{r.forEach(e=>e()),"function"==typeof n&&(n(),n=void 0)}},e.useEventEmitter=e=>new te(e),e.useReactive=e=>i(e=>{const t=w(e);return{get:t[0],set:t[1]}},e),e.useState=w});
9
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ziko={})}(this,function(e){"use strict";const{PI:t,E:s}=Math,n=Number.EPSILON,i=(e,...t)=>{const s=t.map(t=>{return"object"!=typeof(s=t)&&"function"!=typeof s||null===s||t?.__mapfun__?e(t):t instanceof Array?t.map(t=>i(e,t)):ArrayBuffer.isView(t)?t.map(t=>e(t)):t instanceof Set?new Set(i(e,...t)):t instanceof Map?new Map([...t].map(t=>[t[0],i(e,t[1])])):t.isMatrix?.()?new t.constructor(t.rows,t.cols,i(t.arr.flat(1))):t instanceof Object?Object.fromEntries(Object.entries(t).map(t=>[t[0],i(e,t[1])])):void 0;var s});return 1==s.length?s[0]:s},r=(e,t)=>e.isComplex?.()?new e.constructor(t(e.a),t(e.b)):e.isMatrix?.()?new e.constructor(e.rows,e.cols,e.arr.flat(1).map(t)):(e instanceof Array&&i(t,...e),t(e)),a=(e,t,s)=>r(e,e=>t!==s?(e-t)/(s-t):0),o=(e,t,s)=>r(e,e=>(s-t)*e+t),c=(e,t,s=!0)=>{if(e instanceof Array&&!(t instanceof Array))return i(e=>c(e,t,s),...e);if(t instanceof Array&&!(e instanceof Array))return i(t=>c(e,t,s),...t);if(e instanceof Array&&t instanceof Array)return e.map((e,n)=>c(e,t[n],s));const n=Math.atan2(e,t);return s?n:180*n/Math.PI};class l{constructor(e){this.cache={node:e}}isUINode(){return!0}get node(){return this.cache.node}}class h extends Array{constructor(...e){super(...e)}clear(){return this.length=0,this}getItemById(e){return this.find(t=>t.element.id===e)}getItemsByTagName(e){return this.filter(t=>t.element.tagName.toLowerCase()===e.toLowerCase())}getElementsByClassName(e){return this.filter(t=>t.element.classList?.contains(e))}querySelector(e){const t=globalThis?.document?.querySelector(e);return t&&this.find(e=>e.element===t)||null}querySelectorAll(e){const t=globalThis?.document?.querySelectorAll(e);return Array.from(t).map(e=>this.find(t=>t.element===e)).filter(Boolean)}}const u=new h,m={default:{target:null,render:!0},setDefault:function(e){const t=Object.keys(e),s=Object.values(e);for(let e=0;e<t.length;e++)this.default[t[e]]=s[e]},init:()=>{},renderingMode:"spa",isSSC:!1},p={store:new Map,index:0,register:function(e){this.store.set(this.index++,e)},reset(){this.index=0,this.store.clear()}},f={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(e){}};var d={store:new Map,index:0,session_storage:null,register:function(e){},update:function(e,t){}};var g;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:u,__HYDRATION__:p,__State__:d,__Config__:m,__CACHE__:f,__PROVIDERS__:{}},g=__Ziko__,Object.defineProperties(g,{QueryParams:{get:function(){return function(e){const t={};return e.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi,e=>{const[s,n]=e.split("=");t[s]=n}),t}(globalThis.location.search.substring(1))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}}));let _=class extends l{constructor(){super()}init({element:e,name:t,type:s,mount:n,props:i={},items:r=[]}={}){if(this.target=globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body,"string"==typeof e)switch(s){case"html":e=globalThis?.document?.createElement(e);break;case"svg":e=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg",e);break;default:throw Error("Not supported")}else this.target=e?.parentElement;Object.assign(this.cache,{name:t,itemsTarget:this,isInteractive:!1,parent:null}),e&&Object.assign(this.cache,{element:e}),this.items=new h,globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this],e&&n&&this?.mount?.(),globalThis.__Ziko__.__UI__.push(this);const a=((e={})=>{const t={methods:{},events:{},style:{},attrs:{}};for(const[s,n]of Object.entries(e))"style"===s?t.style=n:s.startsWith("$")?t.methods[s.slice(1)]=n:/^on[A-Z]/.test(s)?t.events[s]=n:t.attrs[s]=n;return t})(i);this.parsed_props=a,this.style(a.style),this.setAttr(a.attrs);Object.entries(a.events).forEach(([e,t])=>this[e](t.bind(this))),r.length>0&&this.append(...r)}get element(){return this.cache.element}[Symbol.iterator](){return this.items[Symbol.iterator]()}maintain(){for(let e=0;e<this.items.length;e++)Object.defineProperty(this,e,{value:this.items[e],writable:!0,configurable:!0,enumerable:!1})}isInteractive(){return this.cache.isInteractive}isUIElement(){return!0}};function b(e,...t){t.forEach(t=>function(e,t){const s=Object.getOwnPropertyDescriptors(t);for(const t of Reflect.ownKeys(s)){const n=s[t];"get"in n||"set"in n||"function"!=typeof n.value?Object.defineProperty(Object.getPrototypeOf(e),t,n):"function"==typeof n.value&&(Object.getPrototypeOf(e).hasOwnProperty(t)||Object.defineProperty(Object.getPrototypeOf(e),t,n))}}(e,t))}var v=Object.freeze({__proto__:null,mount:function(e=this.target,t=0){return t>0?(setTimeout(()=>this.mount(e,0),t),this):(this.isBody||(e?.isUIElement&&(e=e.element),this.target=e,this.target?.appendChild(this.element)),this)},unmount:function(e=0){return e>0?(setTimeout(()=>this.unmount(0),e),this):(this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target.children].includes(this.element)&&this.target.removeChild(this.element),this)}});const y=Symbol.for("ziko/hooks/STATE_GETTER");function w(e){const t={value:e,subscribers:new Set,paused:!1};function s(){return{value:t.value,_subscribe:e=>(t.subscribers.add(e),()=>t.subscribers.delete(e))}}s[y]=!0;return[s,function(e){t.paused||("function"==typeof e&&(e=e(t.value)),Object.is(e,t.value)||(t.value=e,t.subscribers.forEach(e=>e(t.value))))},{pause:()=>{t.paused=!0},resume:()=>{t.paused=!1},clear:()=>{t.subscribers.clear()},force:e=>{"function"==typeof e&&(e=e(t.value)),t.value=e,t.subscribers.forEach(e=>e(t.value))},getSubscribers:()=>new Set(t.subscribers)}]}const k=e=>"function"==typeof e&&!0===e[y];function E(e,t){if(globalThis.SVGAElement&&this.element instanceof globalThis.SVGAElement&&(e=is_camelcase(e)?camel2hyphencase(e):e),!this?.attr[e]||this?.attr[e]!==t){if(k(t)){t()._subscribe(t=>this.element?.setAttribute(e,t),this)}else this.element?.setAttribute(e,t);Object.assign(this.cache.attributes,{[e]:t})}}var T=Object.freeze({__proto__:null,_set_attrs_:E,getAttr:function(e){return this.element.attributes[e].value},removeAttr:function(...e){for(let t=0;t<e.length;t++)this.element?.removeAttribute(e[t]);return this},setAttr:function(e,t){if(e instanceof Object){const[s,n]=[Object.keys(e),Object.values(e)];for(let e=0;e<s.length;e++)n[e]instanceof Array&&(t[e]=n[e].join(" ")),E.call(this,s[e],n[e])}else t instanceof Array&&(t=t.join(" ")),E.call(this,e,t);return this},setContentEditable:function(e=!0){return this.setAttr("contenteditable",e),this}});class C extends l{constructor(...e){super("span","text",!1,...e),this.element=globalThis?.document?.createTextNode(...e)}isText(){return!0}}const x=(...e)=>new C(...e);async function A(e,t,...s){for(const n of s)await this.__addItem__(e,t,n);return this.maintain(),this}var O=Object.freeze({__proto__:null,__addItem__:async function(e,t,s,n=null,i=null){const{element:r,items:a}=this.itemsTarget;if(["number","string"].includes(typeof s)&&(s=x(s)),"function"==typeof s&&k(s)){const e=s();s=x(e.value),e._subscribe(e=>{s.element.textContent=e},s)}if("function"==typeof globalThis?.Node&&s instanceof globalThis.Node&&(s=new this.constructor(s)),s instanceof Promise&&(s=await s),s?.isUINode)return s.cache.parent=this,s.target=r,"insertBefore"===e&&r?r.insertBefore(s.element,n):"function"==typeof r?.[e]&&r[e](s.element),void("splice"===t&&null!==i?a.splice(i,0,s):"function"==typeof a?.[t]&&a[t](s))},__addItems__:A,after:function(e){return e?.isUIElement&&(e=e.element),this.itemsTarget.element?.after(e),this},append:function(...e){return A.call(this,"append","push",...e),this},before:function(e){return e?.isUIElement&&(e=e.element),this.itemsTarget.element?.before(e),this},clear:function(){return this?.items?.forEach(e=>e.unmount()),this.itemsTarget.element.innerHTML="",this},insertAt:function(e,...t){const s=this.itemsTarget;if(e>=s.items.length)return this.append(...t);for(let n=0;n<t.length;n++)["number","string"].includes(typeof t[n])&&(t[n]=x(t[n])),s.element?.insertBefore(t[n].element,s.items[e].element),s.items.splice(e,0,t[n]);return s.maintain(),this},prepend:function(...e){return this.__addItems__.call(this,"prepend","unshift",...e),this},remove:function(...e){const t=e=>{"number"==typeof e&&(e=this.items[e]),e?.isUIElement&&this.itemsTarget.element?.removeChild(e.element),this.items=this.items.filter(t=>t!==e)};for(let s=0;s<e.length;s++)t(e[s]);for(let e=0;e<this.items.length;e++)Object.assign(this,{[[e]]:this.items[e]});return this},replaceElementWith:function(e){return this.cache.element.replaceWith(e),this.cache.element=e,this}});var L=Object.freeze({__proto__:null,at:function(e){return this.items.at(e)},find:function(e){return this.items.filter(e)},forEach:function(e){return this.items.forEach(e),this},map:function(e){return this.items.map(e)}});var I=Object.freeze({__proto__:null,animate:function(e,{duration:t=1e3,iterations:s=1,easing:n="ease"}={}){return this.element?.animate(e,{duration:t,iterations:s,easing:n}),this},hide:function(){},show:function(){},size:function(e,t){return this.style({width:e,height:t})},style:function(e){if(!this.element?.style)return this;for(let t in e){const s=e[t];if(k(s)){const e=s();Object.assign(this.element.style,{[t]:e.value}),e._subscribe(e=>{console.log({newValue:e}),Object.assign(this.element.style,{[t]:e})})}else Object.assign(this.element.style,{[t]:s})}return this}});class j{constructor(e,t){this.cache={category:t,target:e,listeners:{},currentEvent:null,event:null,customEvents:new Set}}get event(){return this.cache.event}get target(){return this.cache.target}get element(){return this.cache.target.element}get currentEvent(){return this.cache.currentEvent}addListener(e,t,{preventDefault:s=!1,paused:n=!1}={}){return this.cache.listeners[e]={callback:s=>{this.cache.event=s,this.cache.listeners[e].preventDefault&&s.preventDefault(),this.cache.listeners[e].paused||(this.cache.currentEvent=e,t.call(this,this))},preventDefault:s,paused:n},this.element.addEventListener(e,this.cache.listeners[e].callback),this}removeListener(e){return this.element.removeEventListener(e,this.cache.listeners[e].callback),this}pause(e){return this.cache.listeners[e].paused=!0,this}resume(e){return this.cache.listeners[e].paused=!1,this}preventDefault(e){return this.cache.listeners[e].preventDefault=!0,this}useDefault(e){return this.cache.listeners[e].preventDefault=!1,this}}class S extends Event{constructor(e,t){super("clickaway",{bubbles:!0,cancelable:!0}),this.originalEvent=e,this.targetElement=t}}function M(e){function t(t){if(!e.contains(t.target)){const s=new S(t,e);e.dispatchEvent(s)}}return globalThis?.document?.addEventListener("click",t),()=>globalThis?.document?.removeEventListener("click",t)}const P=(e,t=!1)=>{const s=e.element.getBoundingClientRect(),n=e.event;let i=n?.clientX-s.left|0,r=n?.clientY-s.top|0;if(t){const t=e.element.clientWidth,s=e.element.clientHeight;i=+(i/t*2-1).toFixed(8),r=+(r/s*-2+1).toFixed(8)}return{x:i,y:r}},D="click",U={onClick(e){return this.on("click",e,{category:D})},onDblClick(e){return this.on("dblclick",e,{category:D})},onClickAway(e){var t,s,n;return t=this,s=D,n="clickaway",t.exp.events?.[s]?.cache?.customEvents?.has(n)||M(this.element),this.on("clickaway",e,{category:D,isCustom:!0})}},Z="ptr",R={onPtrDown(e,t=!1){return this.on("pointerdown",e,{category:Z,details_setter:e=>{const{x:s,y:n}=P(e,t);e.dx=s,e.dy=n,e.isDown=!0,e.isDragging=e.isMoving??!1}})},onPtrMove(e,t=!1){return this.on("pointermove",e,{category:Z,details_setter:e=>{const{x:s,y:n}=P(e,t);e.mx=s,e.my=n,e.isMoving=!0,e.isDragging=e.isDown??!1}})},onPtrUp(e,t=!1){return this.on("pointerup",e,{category:Z,details_setter:e=>{const{x:s,y:n}=P(e,t);e.ux=s,e.uy=n,e.isDown=!1,e.isMoving=!1,e.isDragging=!1}})}},z="key",B={onKeyDown(e){return this.on("keydown",e,{category:z,details_setter:e=>{e.kd=e.event.key}})},onKeyPress(e){return this.on("keypress",e,{category:z,details_setter:e=>{e.kp=e.event.key}})},onKeyUp(e){return this.on("keydown",e,{category:z,details_setter:e=>{e.ku=e.event.key}})}};class N{constructor(e,t,s=1/0,n){this.ms=t,this.fn=e,this.count=s,this.frame=1,this.id=null,this.running=!1,n&&this.start()}start(){return this.running||(this.running=!0,this.frame=1,this.id=setInterval(()=>{this.frame>this.count?this.stop():(this.fn.call(null,this),this.frame++)},this.ms)),this}stop(){return this.running&&(this.running=!1,clearInterval(this.id),this.id=null),this}isRunning(){return this.running}}class G extends N{constructor(e=1e3/60){super(e,()=>this._tick()),this.elapsed=0,this._lastTime=performance.now(),this._callbacks=new Set}_tick(){const e=performance.now(),t=e-this._lastTime;this.elapsed+=t,this._lastTime=e;for(const e of this._callbacks)e({elapsed:this.elapsed,delta:t})}onTick(e){return this._callbacks.add(e),()=>this._callbacks.delete(e)}reset(){this.elapsed=0,this._lastTime=performance.now()}pause(){super.stop()}resume(){this._lastTime=performance.now(),super.start()}}class V{constructor(e=[],{repeat:t=1,loop:s=!1}={}){this.tasks=e,this.repeat=t,this.loop=s,this.stopped=!1,this.running=!1,this.onStart=null,this.onTask=null,this.onEnd=null}async run(){if(this.running)return;this.running=!0,this.stopped=!1,this.onStart&&this.onStart();let e=this.repeat;do{for(const e of this.tasks){if(this.stopped)return;if(Array.isArray(e))await Promise.all(e.map(({fn:e,delay:t=0})=>new Promise(async s=>{t>0&&await new Promise(e=>setTimeout(e,t)),this.onTask&&this.onTask(e),await e(),s()})));else{const{fn:t,delay:s=0}=e;s>0&&await new Promise(e=>setTimeout(e,s)),this.onTask&&this.onTask(t),await t()}}}while(this.loop&&!this.stopped&&(e===1/0||e-- >1));!this.stopped&&this.onEnd&&this.onEnd(),this.running=!1}stop(){this.stopped=!0,this.running=!1}addTask(e){this.tasks.push(e)}clearTasks(){this.tasks=[]}}const H=(e,t)=>{let s=0;return(...n)=>{const i=(new Date).getTime();i-s<t||(s=i,e(...n))}};class q extends CustomEvent{constructor(e,t,{bubbles:s=!0,cancelable:n=!0}={}){super(e,{detail:t,bubbles:s,cancelable:n})}}function F(e,{intersection:t=!0,resize:s=!0,threshold:n=0,throttleResize:i=100,throttleEnterExit:r=0}={}){let a,o;const c=t=>{for(let s of t){const{width:t,height:n}=s.contentRect;e.dispatchEvent(new q("resizeview",{width:t,height:n,entry:s}))}},l=i>0?H(c,i):c,h=t=>{for(let s of t){const t=s.isIntersecting?"enterview":"exitview";e.dispatchEvent(new q(t,s))}},u=r>0?H(h,r):h;return t&&(a=new IntersectionObserver(u,{threshold:n}),a.observe(e)),s&&(o=new ResizeObserver(l),o.observe(e)),()=>{a&&(a.unobserve(e),a.disconnect()),o&&(o.unobserve(e),o.disconnect())}}const Y="view",$={onEnterView(e){return this.exp.events?.[Y]||F(this.element),this.on("enterview",e,{category:Y,isCustom:!0})},onExitView(e){return this.exp.events?.[Y]||F(this.element),this.on("exitview",e,{category:Y,isCustom:!0})},onResizeView(e){return this.exp.events?.[Y]||F(this.element),this.on("resizeview",e,{category:Y,isCustom:!0})}};class K extends CustomEvent{constructor(e,t){super(e,{detail:t,bubbles:!0,cancelable:!0})}}class W extends _{constructor({element:e,name:t="",type:s="html",render:n=__Ziko__.__Config__.default.render,props:i}={}){super(),this.exp={events:{}},b(this,v,T,O,I,L,R,U,B,$),e&&this.init({element:e,name:t,type:s,render:n,props:i})}on(e,t,{details_setter:s,category:n="global",isCustom:i=!1,preventDefault:r=!1}={}){e instanceof Array&&e.forEach(e=>this.on(e,t,{details_setter:s,category:n,isCustom:i,preventDefault:r})),n&&!this.exp.events.hasOwnProperty(n)&&(this.exp.events[n]=new j(this,n)),i&&this.exp.events[n].cache.customEvents.add(e);const a=this.exp.events[n];return a.addListener(e,e=>{s&&s(a),t(e)},{preventDefault:r}),this}_off(e,t="global"){return this.exp.events[t].removeListener(e),this}get element(){return this.cache.element}get itemsTarget(){return this.cache.itemsTarget}get itemsTargetElement(){return this.itemsTarget.element}setItemsTarget(e){return this.cache.itemsTarget=e,this.items=e.items,this}isInteractive(){return this.cache.isInteractive}useClient(e){return this.cache.isInteractive||(this.element.setAttribute("data-hydration-index",globalThis.__Ziko__.__HYDRATION__.index),globalThis.__Ziko__.__HYDRATION__.register(()=>this),this.cache.isInteractive=!0),e&&this.element.setAttribute("data-hydration-directive",e),this}get attr(){return this.cache.attributes}get evt(){return this.events}get html(){return this.element.innerHTML}get text(){return this.element.textContent}get parent(){return this.cache.parent}get width(){return this.element.getBoundingClientRect().width}get height(){return this.element.getBoundingClientRect().height}get top(){return this.element.getBoundingClientRect().top}get right(){return this.element.getBoundingClientRect().right}get bottom(){return this.element.getBoundingClientRect().bottom}get left(){return this.element.getBoundingClientRect().left}}const X=["a","abb","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","ipnut","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],J=["svg","g","defs","symbol","use","image","switch","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","textPath","altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","linearGradient","radialGradient","pattern","solidColor","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncR","feFuncG","feFuncB","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","animate","animateMotion","animateTransform","set","script","desc","title","metadata","foreignObject"],Q=["math","annotation","merror","mfrac","mi","mprescripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","semantics","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"],ee=new Proxy({},{get(e,t){if("string"!=typeof t)return;let s,n=t.replaceAll("_","-").toLowerCase();return X.includes(n)&&(s="html"),J.includes(n)&&(s="svg"),Q.includes(n)&&(s="mathml"),(...e)=>0===e.length?new W({element:n,name:n,type:s}):["string","number"].includes(typeof e[0])||e[0]instanceof W||k(e[0])||e[0]instanceof HTMLElement?new W({element:n,name:n,type:s}).append(...e):new W({element:n,type:s,props:e.shift()}).append(...e)}});class te{constructor(e=10){this.events={},this.maxListeners=e}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),this.events[e].length>this.maxListeners&&console.warn(`Warning: Possible memory leak. Event '${e}' has more than ${this.maxListeners} listeners.`),this}once(e,t){const s=(...n)=>{this.off(e,s),t(...n)};return this.on(e,s)}off(e,t){const s=this.events[e];if(!s)return this;const n=s.indexOf(t);return-1!==n&&s.splice(n,1),this}emit(e,t){const s=this.events[e];return!!s&&([...s].forEach(s=>{try{s(t)}catch(t){console.error(`Error in listener for '${e}':`,t)}}),!0)}remove(e){return delete this.events[e],this}clear(){return this.events={},this}setMaxListeners(e){return this.maxListeners=e,this}}globalThis?.document&&document?.addEventListener("DOMContentLoaded",__Ziko__.__Config__.init()),e.ClickAwayEvent=S,e.ClickListeners=U,e.Clock=G,e.E=s,e.EPSILON=n,e.EventController=j,e.KeyListeners=B,e.PI=t,e.PtrListeners=R,e.Scheduler=(e,{repeat:t=null}={})=>new V(e,{repeat:t}),e.SwipeEvent=K,e.Tick=N,e.TimeScheduler=V,e.UIElement=W,e.ViewEvent=q,e.ViewListeners=$,e.apply_fun=r,e.atan2=c,e.camel2constantcase=(e="")=>e.replace(/[A-Z]/g,e=>"_"+e).toUpperCase(),e.camel2hyphencase=(e="")=>e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),e.camel2pascalcase=(e="")=>e.charAt(0).toUpperCase()+e.slice(1),e.camel2snakecase=(e="")=>e.replace(/[A-Z]/g,e=>"_"+e.toLowerCase()),e.clamp=(e,t,s)=>r(e,e=>Math.min(Math.max(e,t),s)),e.clock=e=>new G(e),e.constant2camelcase=(e="")=>e.toLowerCase().replace(/_([a-z])/g,e=>e[1].toUpperCase()),e.constant2hyphencase=(e="")=>e.toLowerCase().replace(/_/g,"-"),e.constant2pascalcase=(e="")=>e.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(""),e.constant2snakecase=(e="")=>e.toLowerCase(),e.debounce=(e,t=1e3)=>(...s)=>setTimeout(()=>e(...s),t),e.deg2rad=(...e)=>i(e=>e*Math.PI/180,...e),e.hyphen2camelcase=(e="")=>e.replace(/-([a-z])/g,e=>e[1].toUpperCase()),e.hyphen2constantcase=(e="")=>e.replace(/-/g,"_").toUpperCase(),e.hyphen2pascalcase=(e="")=>e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(""),e.hyphen2snakecase=(e="")=>e.replace(/-/g,"_"),e.hypot=(...e)=>{const t=e.find(e=>e.isComplex?.());if(t){const s=e.map(e=>e.isComplex?.()?e:new t.constructor(e,0));return Math.hypot(...s.map(e=>e.z))}return Math.hypot(...e)},e.isStateGetter=k,e.is_anagram=(e,t)=>(e=e.split("").sort(),t=t.split("").sort(),JSON.stringify(e)===JSON.stringify(t)),e.is_camelcase=(e="")=>{if(0===e.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(e)},e.is_hyphencase=(e="")=>e.split("-").length>0,e.is_isogram=(e="")=>[...new Set(e.toLowerCase())].length===e.length,e.is_palindrome=e=>{const t=e.toLocaleLowerCase();let s,n=t.length;for(s=0;s<n/2;s++)if(t[s]!=t[n-s-1])return!1;return!0},e.is_pascalcalse=(e="")=>{if(0===e.length)return!1;return/^[A-Z][a-zA-Z0-9]*$/.test(e)},e.is_snakeCase=(e="")=>e.split("_").length>0,e.lerp=o,e.map=(e,t,s,n,i)=>r(e,e=>o(a(e,t,s),n,i)),e.mapfun=i,e.norm=a,e.pascal2camelcase=(e="")=>e.charAt(0).toLowerCase()+e.slice(1),e.pascal2constantcase=(e="")=>e.replace(/([A-Z])/g,(e,t)=>t?"_"+e:e).toUpperCase(),e.pascal2hyphencase=(e="")=>e.replace(/([A-Z])/g,(e,t)=>t?"-"+e.toLowerCase():e.toLowerCase()),e.pascal2snakecase=(e="")=>e.replace(/([A-Z])/g,(e,t)=>t?"_"+e.toLowerCase():e.toLowerCase()),e.rad2deg=(...e)=>i(e=>e/Math.PI*180,...e),e.register_click_away_event=M,e.register_swipe_event=function(e,t=5,s=100,n=500){let i=0,r=0,a=0,o=!1;function c(e){i=e.clientX,r=e.clientY,a=performance.now(),o=!0}function l(c){if(!o)return;o=!1;const l=c.clientX-i,h=c.clientY-r;let u=null,m=null;performance.now()-a<=n&&(Math.abs(l)>=t&&Math.abs(h)<=s?(u=l<0?"left":"right",m="swipe"+u):Math.abs(h)>=t&&Math.abs(l)<=s&&(u=h<0?"up":"down",m="swipe"+u)),m&&e.dispatchEvent(new K(m,{direction:u,distX:l,distY:h,originalEvent:c}))}return e.addEventListener("pointerdown",c,{passive:!0}),e.addEventListener("pointerup",l,{passive:!0}),()=>{e.removeEventListener("pointerdown",c),e.removeEventListener("pointerup",l)}},e.register_view_event=F,e.sleep=e=>new Promise(t=>setTimeout(t,e)),e.snake2camelcase=(e="")=>e.replace(/(_\w)/g,e=>e[1].toUpperCase()),e.snake2constantcase=(e="")=>e.toUpperCase(),e.snake2hyphencase=(e="")=>e.replace(/_/g,"-"),e.snake2pascalcase=(e="")=>e.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(""),e.tags=ee,e.throttle=H,e.tick=(e,t,s=1/0,n=!0)=>new N(e,t,s,n),e.timeout=function(e,t){let s;const n=new Promise(n=>{s=setTimeout(()=>{t&&t(),n()},e)});return{id:s,clear:()=>clearTimeout(s),promise:n}},e.useDerived=function(e,t){const s=()=>e(...t.map(e=>e().value));let n=s();const i=new Set,r=()=>{const e=s();Object.is(e,n)||(n=e,i.forEach(e=>e(n)))};t.map(e=>e()._subscribe(r));const a=()=>({value:n,_subscribe:e=>(i.add(e),()=>i.delete(e))});return a[y]=!0,a},e.useEffect=(e,t=[])=>{const s=t.filter(k);let n;const i=()=>{"function"==typeof n&&n(),n=e(s.map(e=>e().value))},r=s.map(e=>e()._subscribe(i));return i(),()=>{r.forEach(e=>e()),"function"==typeof n&&(n(),n=void 0)}},e.useEventEmitter=e=>new te(e),e.useReactive=e=>i(e=>{const t=w(e);return{get:t[0],set:t[1]}},e),e.useState=w});
package/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sat Sep 05 2026 12:37:55 GMT+0100 (UTC+01:00)
5
+ Date : Mon Sep 07 2026 22:41:50 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -276,16 +276,12 @@ let UIElement$1 = class UIElement extends UINode{
276
276
  constructor(){
277
277
  super();
278
278
  }
279
- init({element, name, type, render, props = {}, items = []} = {}){
279
+ init({element, name, type, mount, props = {}, items = []} = {}){
280
280
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
281
281
  if(typeof element === "string") {
282
282
  switch(type){
283
- case "html" : {
284
- element = globalThis?.document?.createElement(element);
285
- } break;
286
- case "svg" : {
287
- element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
288
- } break;
283
+ case "html" : element = globalThis?.document?.createElement(element); break;
284
+ case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element); break;
289
285
  default : throw Error("Not supported")
290
286
  }
291
287
  }
@@ -295,37 +291,37 @@ let UIElement$1 = class UIElement extends UINode{
295
291
  itemsTarget : this,
296
292
  isInteractive : false,
297
293
  parent:null,
298
- isBody:false,
299
- isRoot:false,
300
- isHidden: false,
301
- isFrozzen:false,
302
- attributes: {},
303
- filters: {},
304
- temp:{}
294
+ // isBody:false,
295
+ // isRoot:false,
296
+ // isHidden: false,
297
+ // isFrozzen:false,
298
+ // attributes: {},
299
+ // filters: {},
300
+ // temp:{}
305
301
  });
306
- this.events = {
307
- ptr:null,
308
- mouse:null,
309
- wheel:null,
310
- key:null,
311
- drag:null,
312
- drop:null,
313
- click:null,
314
- clipboard:null,
315
- focus:null,
316
- swipe:null,
317
- custom:null,
318
- };
319
- this.observer={
320
- resize:null,
321
- intersection:null
322
- };
302
+ // this.events = {
303
+ // ptr:null,
304
+ // mouse:null,
305
+ // wheel:null,
306
+ // key:null,
307
+ // drag:null,
308
+ // drop:null,
309
+ // click:null,
310
+ // clipboard:null,
311
+ // focus:null,
312
+ // swipe:null,
313
+ // custom:null,
314
+ // }
315
+ // this.observer={
316
+ // resize:null,
317
+ // intersection:null
318
+ // }
323
319
  if(element) Object.assign(this.cache,{element});
324
320
  this.items = new UIStore();
325
321
  globalThis.__Ziko__.__UI__[this.cache.name]
326
322
  ? globalThis.__Ziko__.__UI__[this.cache.name]?.push(this)
327
323
  : globalThis.__Ziko__.__UI__[this.cache.name]=[this];
328
- element && render && this?.render?.();
324
+ element && mount && this?.mount?.();
329
325
  globalThis.__Ziko__.__UI__.push(this);
330
326
 
331
327
  const parsed_props = parse_props(props);
@@ -382,12 +378,9 @@ function mount(target = this.target, delay = 0) {
382
378
  setTimeout(() => this.mount(target, 0), delay);
383
379
  return this;
384
380
  }
385
-
386
381
  if (this.isBody) return this;
387
-
388
382
  if (target?.isUIElement) target = target.element;
389
383
  this.target = target;
390
-
391
384
  this.target?.appendChild(this.element);
392
385
  return this;
393
386
  }
@@ -397,7 +390,6 @@ function unmount(delay = 0) {
397
390
  setTimeout(() => this.unmount(0), delay);
398
391
  return this;
399
392
  }
400
-
401
393
  if (this.cache.parent) {
402
394
  this.cache.parent.remove(this);
403
395
  } else if (
@@ -538,11 +530,11 @@ class UIText extends UINode {
538
530
  const text = (...str) => new UIText(...str);
539
531
 
540
532
  function append(...ele) {
541
- __addItem__.call(this, "append", "push", ...ele);
533
+ __addItems__.call(this, "append", "push", ...ele);
542
534
  return this;
543
535
  }
544
536
  function prepend(...ele) {
545
- this.__addItem__.call(this, "prepend", "unshift", ...ele);
537
+ this.__addItems__.call(this, "prepend", "unshift", ...ele);
546
538
  return this;
547
539
  }
548
540
  function insertAt(index, ...ele) {
@@ -584,58 +576,46 @@ function replaceElementWith(new_element){
584
576
  return this
585
577
  }
586
578
  function after(ui){
587
- if(ui?.isUIElement) ui=ui.element;
579
+ if(ui?.isUIElement) ui = ui.element;
588
580
  this.itemsTarget.element?.after(ui);
589
581
  return this;
590
582
  }
591
583
  function before(ui){
592
- if(ui?.isUIElement) ui=ui.element;
584
+ if(ui?.isUIElement) ui = ui.element;
593
585
  this.itemsTarget.element?.before(ui);
594
586
  return this;
595
587
  }
596
- async function __addItem__(adder, pusher, ...ele) {
597
- const itemsTarget_el = this.itemsTarget.element;
598
- const itemsTarget = this.itemsTarget;
599
- if (this.cache.isFrozzen) {
600
- console.warn("You can't append new item to frozzen element");
601
- return this;
588
+
589
+ async function __addItem__(adder, pusher, item, referenceNode = null, index = null) {
590
+ const { element: itemsTargetEl, items } = this.itemsTarget;
591
+ if (["number", "string"].includes(typeof item)) item = text(item);
592
+ if (typeof item === "function" && isStateGetter(item)) {
593
+ const getter = item();
594
+ item = text(getter.value);
595
+ getter._subscribe(
596
+ (newValue) => { item.element.textContent = newValue; },
597
+ item
598
+ );
602
599
  }
603
- for (let i = 0; i < ele.length; i++) {
604
- if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
605
- // Fix Items Latter
606
- if (ele[i] instanceof Function) {
607
- if (isStateGetter(ele[i])) {
608
- const getter = ele[i]();
609
- ele[i] = text(getter.value);
610
- getter._subscribe(
611
- (newValue) => (ele[i].element.textContent = newValue),
612
- ele[i]
613
- );
614
- // this.itemsTarget.element.appendChild(textNode);
615
- }
616
- }
617
- if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
618
- if (ele[i]?.isUINode) {
619
- ele[i].cache.parent = this;
620
- itemsTarget_el?.[adder](ele[i].element);
621
- ele[i].target = this.itemsTarget.element;
622
- itemsTarget.items[pusher](ele[i]);
623
- }
624
- else if(ele[i] instanceof Promise){
625
- const UIEle = await ele[i];
626
- UIEle.cache.parent = this;
627
- itemsTarget_el?.[adder](UIEle.element);
628
- UIEle.target = this.itemsTarget.element;
629
- itemsTarget.items[pusher](UIEle);
630
- }
631
- else if (ele[i] instanceof Object) {
632
- if (ele[i]?.style) this.style(ele[i]?.style);
633
- if (ele[i]?.attr) {
634
- Object.entries(ele[i].attr).forEach((n) =>
635
- this.setAttr("" + n[0], n[1]),
636
- );
637
- }
638
- }
600
+ if (typeof globalThis?.Node === "function" && item instanceof globalThis.Node)
601
+ item = new this.constructor(item);
602
+ if (item instanceof Promise) item = await item;
603
+ if (item?.isUINode) {
604
+ item.cache.parent = this;
605
+ item.target = itemsTargetEl;
606
+ if (adder === "insertBefore" && itemsTargetEl)
607
+ itemsTargetEl.insertBefore(item.element, referenceNode);
608
+ else if (typeof itemsTargetEl?.[adder] === "function")
609
+ itemsTargetEl[adder](item.element);
610
+ if (pusher === "splice" && index !== null) items.splice(index, 0, item);
611
+ else if (typeof items?.[pusher] === "function") items[pusher](item);
612
+ return;
613
+ }
614
+ }
615
+
616
+ async function __addItems__(adder, pusher, ...elements) {
617
+ for (const item of elements) {
618
+ await this.__addItem__(adder, pusher, item);
639
619
  }
640
620
  this.maintain();
641
621
  return this;
@@ -644,6 +624,7 @@ async function __addItem__(adder, pusher, ...ele) {
644
624
  var DomMethods = /*#__PURE__*/Object.freeze({
645
625
  __proto__: null,
646
626
  __addItem__: __addItem__,
627
+ __addItems__: __addItems__,
647
628
  after: after,
648
629
  append: append,
649
630
  before: before,
@@ -1356,9 +1337,9 @@ class UIElement extends UIElement$1{
1356
1337
  if(directive)this.element.setAttribute('data-hydration-directive', directive);
1357
1338
  return this;
1358
1339
  }
1359
- get st(){
1360
- return this.cache.style;
1361
- }
1340
+ // get st(){
1341
+ // return this.cache.style;
1342
+ // }
1362
1343
  get attr(){
1363
1344
  return this.cache.attributes;
1364
1345
  }
@@ -1753,7 +1734,7 @@ const is_anagram = (word, words) =>{
1753
1734
  const is_isogram = (text = '') => [...new Set(text.toLowerCase())].length === text.length;
1754
1735
 
1755
1736
  if(globalThis?.document){
1756
- document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
1737
+ document?.addEventListener('DOMContentLoaded', __Ziko__.__Config__.init());
1757
1738
  }
1758
1739
 
1759
1740
  // import './math/functions/proxy.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "2.0.0-beta.8",
3
+ "version": "2.0.0-beta.9",
4
4
  "description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
5
5
  "keywords": [
6
6
  "front-end",
@@ -87,9 +87,9 @@ class UIElement extends UIElementCore{
87
87
  if(directive)this.element.setAttribute('data-hydration-directive', directive);
88
88
  return this;
89
89
  }
90
- get st(){
91
- return this.cache.style;
92
- }
90
+ // get st(){
91
+ // return this.cache.style;
92
+ // }
93
93
  get attr(){
94
94
  return this.cache.attributes;
95
95
  }
@@ -7,16 +7,12 @@ class UIElement extends UINode{
7
7
  constructor(){
8
8
  super()
9
9
  }
10
- init({element, name, type, render, props = {}, items = []} = {}){
10
+ init({element, name, type, mount, props = {}, items = []} = {}){
11
11
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
12
12
  if(typeof element === "string") {
13
13
  switch(type){
14
- case "html" : {
15
- element = globalThis?.document?.createElement(element);
16
- }; break;
17
- case "svg" : {
18
- element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
19
- }; break;
14
+ case "html" : element = globalThis?.document?.createElement(element); break;
15
+ case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element); break;
20
16
  default : throw Error("Not supported")
21
17
  }
22
18
  }
@@ -26,37 +22,37 @@ class UIElement extends UINode{
26
22
  itemsTarget : this,
27
23
  isInteractive : false,
28
24
  parent:null,
29
- isBody:false,
30
- isRoot:false,
31
- isHidden: false,
32
- isFrozzen:false,
33
- attributes: {},
34
- filters: {},
35
- temp:{}
25
+ // isBody:false,
26
+ // isRoot:false,
27
+ // isHidden: false,
28
+ // isFrozzen:false,
29
+ // attributes: {},
30
+ // filters: {},
31
+ // temp:{}
36
32
  })
37
- this.events = {
38
- ptr:null,
39
- mouse:null,
40
- wheel:null,
41
- key:null,
42
- drag:null,
43
- drop:null,
44
- click:null,
45
- clipboard:null,
46
- focus:null,
47
- swipe:null,
48
- custom:null,
49
- }
50
- this.observer={
51
- resize:null,
52
- intersection:null
53
- }
33
+ // this.events = {
34
+ // ptr:null,
35
+ // mouse:null,
36
+ // wheel:null,
37
+ // key:null,
38
+ // drag:null,
39
+ // drop:null,
40
+ // click:null,
41
+ // clipboard:null,
42
+ // focus:null,
43
+ // swipe:null,
44
+ // custom:null,
45
+ // }
46
+ // this.observer={
47
+ // resize:null,
48
+ // intersection:null
49
+ // }
54
50
  if(element) Object.assign(this.cache,{element});
55
51
  this.items = new UIStore();
56
52
  globalThis.__Ziko__.__UI__[this.cache.name]
57
53
  ? globalThis.__Ziko__.__UI__[this.cache.name]?.push(this)
58
54
  : globalThis.__Ziko__.__UI__[this.cache.name]=[this];
59
- element && render && this?.render?.()
55
+ element && mount && this?.mount?.()
60
56
  globalThis.__Ziko__.__UI__.push(this)
61
57
 
62
58
  const parsed_props = parse_props(props);