ziko 0.45.3 → 0.45.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ziko.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Wed Sep 03 2025 15:22:46 GMT+0100 (UTC+01:00)
5
+ Date : Thu Sep 04 2025 20:47:52 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
@@ -1209,11 +1209,11 @@ class UIElementCore extends UINode{
1209
1209
  switch(type){
1210
1210
  case "html" : {
1211
1211
  element = globalThis?.document?.createElement(element);
1212
- console.log('1');
1212
+ // console.log('1')
1213
1213
  } break;
1214
1214
  case "svg" : {
1215
1215
  element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
1216
- console.log('2');
1216
+ // console.log('2')
1217
1217
  } break;
1218
1218
  default : throw Error("Not supported")
1219
1219
  }
@@ -1675,6 +1675,13 @@ function unrender(){
1675
1675
  else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
1676
1676
  return this;
1677
1677
  }
1678
+ function replaceElementWith(new_element){
1679
+ this.cache.element.replaceWith(new_element);
1680
+ this.cache.element = new_element;
1681
+
1682
+ // To do : Dispose Events and States
1683
+ return this
1684
+ }
1678
1685
  function renderAfter(t = 1) {
1679
1686
  setTimeout(() => this.render(), t);
1680
1687
  return this;
@@ -1705,6 +1712,7 @@ var DomMethods = /*#__PURE__*/Object.freeze({
1705
1712
  remove: remove,
1706
1713
  render: render,
1707
1714
  renderAfter: renderAfter,
1715
+ replaceElementWith: replaceElementWith,
1708
1716
  unrender: unrender,
1709
1717
  unrenderAfter: unrenderAfter
1710
1718
  });
@@ -3136,7 +3144,7 @@ let UIElement$1 = class UIElement extends UIElementCore{
3136
3144
  IndexingMethods,
3137
3145
  EventsMethodes
3138
3146
  );
3139
- this.init(element, name, type, render);
3147
+ if(element)this.init(element, name, type, render);
3140
3148
  }
3141
3149
  get element(){
3142
3150
  return this.cache.element;
@@ -3700,6 +3708,38 @@ function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
3700
3708
  );
3701
3709
  }
3702
3710
 
3711
+ class UISwitch extends UIElement$1{
3712
+ constructor(key, cases){
3713
+ super();
3714
+ this.key = key;
3715
+ this.cases = cases;
3716
+ this.init();
3717
+ }
3718
+ init(){
3719
+ Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender());
3720
+ super.init(this.current.element);
3721
+ }
3722
+ get current(){
3723
+ const matched = Object.keys(this.cases).find(n => n == this.key) ?? 'default';
3724
+ return this.cases[matched]
3725
+ }
3726
+ updateKey(key){
3727
+ this.key = key;
3728
+ this.replaceElementWith(this.current.element);
3729
+ // this.cache.element.replaceWith(this.current.element)
3730
+ // this.cache.element = this.current.element;
3731
+ return this;
3732
+ }
3733
+
3734
+ }
3735
+
3736
+ const Switch=({key, cases})=> new UISwitch(key, cases);
3737
+
3738
+ // export const Switch=({key, cases}) => {
3739
+ // const matched = Object.keys(cases).find(n => n == key) ?? 'default';
3740
+ // return this.cases[matched]()
3741
+ // }
3742
+
3703
3743
  const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
3704
3744
  const svg2ascii=svg=>btoa(svg2str(svg));
3705
3745
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
@@ -5949,6 +5989,7 @@ exports.SVGWrapper = SVGWrapper;
5949
5989
  exports.Scheduler = Scheduler;
5950
5990
  exports.Step = Step;
5951
5991
  exports.Suspense = Suspense;
5992
+ exports.Switch = Switch;
5952
5993
  exports.Tick = Tick;
5953
5994
  exports.TimeAnimation = TimeAnimation;
5954
5995
  exports.TimeLoop = TimeLoop;
@@ -5957,6 +5998,7 @@ exports.UIElement = UIElement$1;
5957
5998
  exports.UIHTMLWrapper = UIHTMLWrapper;
5958
5999
  exports.UINode = UINode;
5959
6000
  exports.UISVGWrapper = UISVGWrapper;
6001
+ exports.UISwitch = UISwitch;
5960
6002
  exports.Utils = Utils;
5961
6003
  exports.ZikoApp = ZikoApp;
5962
6004
  exports.ZikoCustomEvent = ZikoCustomEvent;
package/dist/ziko.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Wed Sep 03 2025 15:22:46 GMT+0100 (UTC+01:00)
5
+ Date : Thu Sep 04 2025 20:47:52 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
@@ -1213,11 +1213,11 @@
1213
1213
  switch(type){
1214
1214
  case "html" : {
1215
1215
  element = globalThis?.document?.createElement(element);
1216
- console.log('1');
1216
+ // console.log('1')
1217
1217
  } break;
1218
1218
  case "svg" : {
1219
1219
  element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
1220
- console.log('2');
1220
+ // console.log('2')
1221
1221
  } break;
1222
1222
  default : throw Error("Not supported")
1223
1223
  }
@@ -1679,6 +1679,13 @@
1679
1679
  else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
1680
1680
  return this;
1681
1681
  }
1682
+ function replaceElementWith(new_element){
1683
+ this.cache.element.replaceWith(new_element);
1684
+ this.cache.element = new_element;
1685
+
1686
+ // To do : Dispose Events and States
1687
+ return this
1688
+ }
1682
1689
  function renderAfter(t = 1) {
1683
1690
  setTimeout(() => this.render(), t);
1684
1691
  return this;
@@ -1709,6 +1716,7 @@
1709
1716
  remove: remove,
1710
1717
  render: render,
1711
1718
  renderAfter: renderAfter,
1719
+ replaceElementWith: replaceElementWith,
1712
1720
  unrender: unrender,
1713
1721
  unrenderAfter: unrenderAfter
1714
1722
  });
@@ -3140,7 +3148,7 @@
3140
3148
  IndexingMethods,
3141
3149
  EventsMethodes
3142
3150
  );
3143
- this.init(element, name, type, render);
3151
+ if(element)this.init(element, name, type, render);
3144
3152
  }
3145
3153
  get element(){
3146
3154
  return this.cache.element;
@@ -3704,6 +3712,38 @@
3704
3712
  );
3705
3713
  }
3706
3714
 
3715
+ class UISwitch extends UIElement$1{
3716
+ constructor(key, cases){
3717
+ super();
3718
+ this.key = key;
3719
+ this.cases = cases;
3720
+ this.init();
3721
+ }
3722
+ init(){
3723
+ Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender());
3724
+ super.init(this.current.element);
3725
+ }
3726
+ get current(){
3727
+ const matched = Object.keys(this.cases).find(n => n == this.key) ?? 'default';
3728
+ return this.cases[matched]
3729
+ }
3730
+ updateKey(key){
3731
+ this.key = key;
3732
+ this.replaceElementWith(this.current.element);
3733
+ // this.cache.element.replaceWith(this.current.element)
3734
+ // this.cache.element = this.current.element;
3735
+ return this;
3736
+ }
3737
+
3738
+ }
3739
+
3740
+ const Switch=({key, cases})=> new UISwitch(key, cases);
3741
+
3742
+ // export const Switch=({key, cases}) => {
3743
+ // const matched = Object.keys(cases).find(n => n == key) ?? 'default';
3744
+ // return this.cases[matched]()
3745
+ // }
3746
+
3707
3747
  const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
3708
3748
  const svg2ascii=svg=>btoa(svg2str(svg));
3709
3749
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
@@ -5953,6 +5993,7 @@
5953
5993
  exports.Scheduler = Scheduler;
5954
5994
  exports.Step = Step;
5955
5995
  exports.Suspense = Suspense;
5996
+ exports.Switch = Switch;
5956
5997
  exports.Tick = Tick;
5957
5998
  exports.TimeAnimation = TimeAnimation;
5958
5999
  exports.TimeLoop = TimeLoop;
@@ -5961,6 +6002,7 @@
5961
6002
  exports.UIHTMLWrapper = UIHTMLWrapper;
5962
6003
  exports.UINode = UINode;
5963
6004
  exports.UISVGWrapper = UISVGWrapper;
6005
+ exports.UISwitch = UISwitch;
5964
6006
  exports.Utils = Utils;
5965
6007
  exports.ZikoApp = ZikoApp;
5966
6008
  exports.ZikoCustomEvent = ZikoCustomEvent;
package/dist/ziko.min.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  Project: ziko.js
3
3
  Author: Zakaria Elalaoui
4
- Date : Wed Sep 03 2025 15:22:46 GMT+0100 (UTC+01:00)
4
+ Date : Thu Sep 04 2025 20:47:52 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(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Ziko={})}(this,(function(t){"use strict";const{PI:e,E:s}=Math,r=Number.EPSILON,{PI:n,cos:i,sin:a,tan:o,acos:h,asin:c,atan:l,cosh:u,sinh:m,tanh:p,acosh:f,asinh:d,atanh:g,log:b}=Math;let w={cos:i,sin:a,tan:o,sinc:t=>a(n*t)/(n*t),sec:t=>1/i(t),csc:t=>1/a(t),cot:t=>1/o(t),acos:h,asin:c,atan:l,acot:t=>n/2-l(t),cosh:u,sinh:m,tanh:p,coth:t=>.5*b((1+t)/(1-t)),acosh:f,asinh:d,atanh:g};w=new Proxy(w,{get(t,e){if(e in t)return s=>+t[e](s).toFixed(15)}});class y{}const v=(t,...e)=>{const s=e.map((e=>{if(null===e)return t(null);if(["number","string","boolean","bigint","undefined"].includes(typeof e))return t(e);if(e instanceof Array)return e.map((e=>v(t,e)));if(ArrayBuffer.isView(e))return e.map((e=>t(e)));if(e instanceof Set)return new Set(v(t,...e));if(e instanceof Map)return new Map([...e].map((e=>[e[0],v(t,e[1])])));if(e instanceof ds)return new ds(e.rows,e.cols,v(e.arr.flat(1)));if(e instanceof bs){const[s,r,n,i]=[e.a,e.b,e.z,e.phi];switch(t){case Math.log:return ws(ks(n),i);case Math.exp:return ws(Es(s)*Ts(r),Es(s)*As(r));case Math.abs:return n;case Math.sqrt:return ws(vs(n)*Ts(i/2),vs(n)*As(i/2));case w.cos:return ws(Ts(s)*Ss(r),-As(s)*Cs(r));case w.sin:return ws(As(s)*Ss(r),Ts(s)*Cs(r));case w.tan:{const t=Ts(2*s)+Ss(2*r);return ws(As(2*s)/t,Cs(2*r)/t)}case w.cosh:return ws(Ss(s)*Ts(r),Cs(s)*As(r));case w.sinh:return ws(Cs(s)*Ts(r),Ss(s)*As(r));case w.tanh:{const t=Ss(2*s)+Ts(2*r);return ws(Cs(2*s)/t,As(2*r)/t)}default:return t(e)}}else if(e instanceof Object)return Object.fromEntries(Object.entries(e).map((e=>[e[0],v(t,e[1])])))}));return 1==s.length?s[0]:s},_=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t+e;if(e instanceof bs)return ws(t+e.a,e.b);if(e instanceof ds)return ds.nums(e.rows,e.cols,t).add(e);if(e instanceof Array)return e.map((e=>A(e,t)))}else{if(t instanceof bs||t instanceof ds)return e instanceof Array?e.map((e=>t.clone.add(e))):t.clone.add(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>A(t,e)));if(t.length===e.length)return t.map(((t,s)=>A(t,e[s])))}}},x=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t-e;if(e instanceof bs)return ws(t-e.a,-e.b);if(e instanceof ds)return ds.nums(e.rows,e.cols,t).sub(e);if(e instanceof Array)return e.map((e=>O(e,t)))}else{if(t instanceof bs||t instanceof ds)return e instanceof Array?e.map((e=>t.clone.sub(e))):t.clone.sub(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>O(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>O(t,e[s])))}}},E=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t*e;if(e instanceof bs)return ws(t*e.a,t*e.b);if(e instanceof ds)return ds.nums(e.rows,e.cols,t).mul(e);if(e instanceof Array)return e.map((e=>S(t,e)))}else{if(t instanceof bs||t instanceof ds)return e instanceof Array?e.map((e=>t.clone.mul(e))):t.clone.mul(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>S(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>S(t,e[s])))}}},k=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t/e;if(e instanceof bs)return ws(t/e.a,t/e.b);if(e instanceof ds)return ds.nums(e.rows,e.cols,t).div(e);if(e instanceof Array)return e.map((e=>C(t,e)))}else{if(t instanceof bs||t instanceof ds)return e instanceof Array?e.map((e=>t.clone.div(e))):t.clone.div(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>C(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>C(t,e[s])))}}},T=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t%e;if(e instanceof bs)return ws(t%e.a,t%e.b);if(e instanceof ds)return ds.nums(e.rows,e.cols,t).modulo(e);if(e instanceof Array)return e.map((e=>C(t,e)))}else{if(t instanceof bs||t instanceof ds)return e instanceof Array?e.map((e=>t.clone.div(e))):t.clone.div(e);if(t instanceof Array&&!(e instanceof Array))return t.map((t=>A(t,e)))}},A=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=_(s,e[t]);return s},O=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=x(s,e[t]);return s},S=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=E(s,e[t]);return s},C=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=k(s,e[t]);return s},j=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=T(s,e[t]);return s},I=t=>new Array(t).fill(0),M=t=>new Array(t).fill(1),D=(t,e)=>new Array(e).fill(t),P=(t,e,s)=>{if("number"==typeof t)return e!==s?(t-e)/(s-e):0;if(t instanceof ds)return new ds(t.rows,t.cols,P(t.arr.flat(1),e,s));if(t instanceof bs)return new bs(P(t.a,e,s),P(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>P(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=P(t[s])}}},R=(t,e,s)=>{if("number"==typeof t)return(s-e)*t+e;if(t instanceof ds)return new ds(t.rows,t.cols,R(t.arr.flat(1),e,s));if(t instanceof bs)return new bs(R(t.a,e,s),R(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>R(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=R(t[s])}}},L=(t,e,s,r,n)=>{if("number"==typeof t)return R(P(t,e,s),r,n);if(t instanceof ds)return new ds(t.rows,t.cols,L(t.arr.flat(1),e,s,r,n));if(t instanceof bs)return new bs(L(t.a,s,r,n),L(t.b,e,s,r,n));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>L(t,e,s,r,n)));{let i=new Array(t.length);for(let a=0;a<t.length;a++)i[a]=L(t[a],e,s,r,n)}}},$=(t,e,s)=>{const[r,n]=[W(e,s),V(e,s)];if("number"==typeof t)return W(V(t,r),n);if(t instanceof ds)return new ds(t.rows,t.cols,$(t.arr.flat(1),r,n));if(t instanceof bs)return new bs($(t.a,r,n),$(t.b,r,n));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>$(t,r,n)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=$(t[s],r,n)}}},N=(t,e,s,r=!1)=>{let n=[];if(t<e)for(let i=t;r?i<=e:i<e;i+=s)n.push(10*i/10);else for(let i=t;r?i>=e:i>e;i-=s)n.push(10*i/10);return n},B=(t,e,s=ys(e-t)+1,r=!0)=>{if(Math.floor(s)===s){if([t,e].every((t=>"number"==typeof t))){const[a,o]=[t,e].sort(((t,e)=>e-t));var n=[];let h;h=r?(a-o)/(s-1):(a-o)/s;for(var i=0;i<s;i++)t<e?n.push(o+h*i):n.push(a-h*i);return n}if([t,e].some((t=>t instanceof bs))){const n=ws(t),i=ws(e);s=s||Math.abs(n.a-i.a)+1;const a=B(n.a,i.a,s,r),o=B(n.b,i.b,s,r);let h=new Array(s).fill(null);return h=h.map(((t,e)=>ws(a[e],o[e]))),h}}},F=(t,e,r=e-t+1,n=s,i=!0)=>B(t,e,r,i).map((t=>_s(n,t))),H=(t,e,s=ys(e-t)+1,r=!0)=>{if(Math.floor(s)===s){if([t,e].every((t=>"number"==typeof t))){const[n,i]=[t,e].sort(((t,e)=>e-t));let a;a=xs(n/i,r?s-1:s);const o=[i];for(let t=1;t<s;t++)o.push(o[t-1]*a);return t<e?o:o.reverse()}if([t,e].some((t=>t instanceof bs))){const n=ws(t),i=ws(e);let a;s=s||Math.abs(n.a-i.a)+1,a=xs(i.div(n),r?s-1:s);const o=[n];for(let t=1;t<s;t++)o.push(S(o[t-1],a));return o}}},z=(...t)=>mapfun((t=>t*Math.PI/180),...t),Z=(...t)=>mapfun((t=>t/Math.PI*180),...t),U=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t[0];for(let s=1;s<t.length;s++)e+=t[s];return e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(U(...t[s])):t[s]instanceof Object&&e.push(U(...Object.values(t[s])));return 1===e.length?e[0]:e},q=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t[0];for(let s=1;s<t.length;s++)e*=t[s];return e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(q(...t[s])):t[s]instanceof Object&&e.push(q(...Object.values(t[s])));return 1===e.length?e[0]:e},W=(...t)=>{if(t.every((t=>"number"==typeof t)))return Math.min(...t);const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(W(...t[s])):t[s]instanceof Object&&e.push(Object.fromEntries([Object.entries(t[s]).sort(((t,e)=>t[1]-e[1]))[0]]));return 1===e.length?e[0]:e},V=(...t)=>{if(t.every((t=>"number"==typeof t)))return Math.max(...t);const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(W(...t[s])):t[s]instanceof Object&&e.push(Object.fromEntries([Object.entries(t[s]).sort(((t,e)=>e[1]-t[1]))[0]]));return 1===e.length?e[0]:e},G=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t.reduce(((t,e)=>[...t,t[t.length-1]+e]),[0]);return e.shift(),e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(G(...t[s])):t[s]instanceof Object&&e.push(null);return 1===e.length?e[0]:e},X=(t,e,s)=>{const[r,n]=[Math.min(e,s),Math.max(e,s)];return t>=r&&t<=n},Y=(t,e,s=1e-4)=>Math.abs(t-e)<=s,K=(t,e)=>t.reduce(((t,s)=>[...t,...e.map((t=>[s,t]))]),[]),Q=(t,e)=>{let s,r=1;if(t==js(t)&&e==js(e)){for(s=2;s<=t&&s<=e;++s)t%s==0&&e%s==0&&(r=s);return r}console.log("error")},J=(t,e)=>{let s;if(t==js(t)&&e==js(e)){for(s=t>e?t:e;s%t!=0||s%e!=0;)++s;return s}console.log("error")},tt={add:A,sub:O,mul:S,div:C,modulo:j,zeros:I,ones:M,nums:D,norm:P,lerp:R,map:L,clamp:$,arange:N,linspace:B,logspace:F,geomspace:H,sum:U,prod:q,accum:G,cartesianProduct:K,ppcm:J,pgcd:Q,deg2rad:z,rad2deg:Z,inRange:X,isApproximatlyEqual:Y},et={_mode:Number,_map:function(t,e,s){return e instanceof ds?new ds(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof bs?new bs(t(e.a,s),t(e.b,s)):e instanceof Array?e.map((e=>t(e,s))):void 0},dec2base(t,e){return this._mode=e<=10?Number:String,"number"==typeof t?this._mode((t>>>0).toString(e)):this._map(this.dec2base,t,e)},dec2bin(t){return this.dec2base(t,2)},dec2oct(t){return this.dec2base(t,8)},dec2hex(t){return this.dec2base(t,16)},bin2base(t,e){return this.dec2base(this.bin2dec(t),e)},bin2dec(t){return this._mode("0b"+t)},bin2oct(t){return this.bin2base(t,8)},bin2hex(t){return this.bin2base(t,16)},oct2dec(t){return this._mode("0o"+t)},oct2bin(t){return this.dec2bin(this.oct2dec(t))},oct2hex(t){return this.dec2hex(this.oct2dec(t))},oct2base(t,e){return this.dec2base(this.oct2dec(t),e)},hex2dec(t){return this._mode("0x"+t)},hex2bin(t){return this.dec2bin(this.hex2dec(t))},hex2oct(t){return this.dec2oct(this.hex2dec(t))},hex2base(t,e){return this.dec2base(this.hex2dec(t),e)},IEEE32toDec(t){let e=t.split(" ").join("").padEnd(32,"0"),s=e[0],r=2**(+("0b"+e.slice(1,9))-127);return(-1)**s*(1+e.slice(9,32).split("").map((t=>+t)).map(((t,e)=>t*2**(-e-1))).reduce(((t,e)=>t+e),0))*r},IEEE64toDec(t){let e=t.split(" ").join("").padEnd(64,"0"),s=e[0],r=2**(+("0b"+e.slice(1,12))-1023);return(-1)**s*(1+e.slice(13,64).split("").map((t=>+t)).map(((t,e)=>t*2**(-e-1))).reduce(((t,e)=>t+e),0))*r}},st={_mode:Number,_map:function(t,e,s){return e instanceof ds?new ds(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof bs?new bs(t(e.a,s),t(e.b,s)):e instanceof Array?e.map((e=>t(e,s))):void 0},not:function(t){return["number","boolean"].includes(typeof t)?st._mode(!t):this._map(this.not,t)},and:function(t,...e){return["number","boolean"].includes(typeof t)?st._mode(e.reduce(((t,e)=>t&e),t)):this._map(this.and,t,e)},or:function(t,...e){return["number","boolean"].includes(typeof t)?st._mode(e.reduce(((t,e)=>t|e),t)):this._map(this.or,t,e)},nand:function(t,...e){return this.not(this.and(t,e))},nor:function(t,...e){return this.not(this.or(t,e))},xor:function(t,...e){let s=[t,...e];return["number","boolean"].includes(typeof t)?this._mode(1===s.reduce(((t,e)=>(1==+e&&(t+=1),t)),0)):this._map(this.xor,t,e)},xnor:function(t,...e){return st.not(st.xor(t,e))}};class rt{static withDiscount(t,e){if(1===e)return t.map((t=>[t]));const s=[];return t.forEach(((r,n)=>{this.withDiscount(t.slice(n),e-1).forEach((t=>{s.push([r].concat(t))}))})),s}static withoutDiscount(t,e){if(1===e)return t.map((t=>[t]));const s=[];return t.forEach(((r,n)=>{this.withoutDiscount(t.slice(n+1),e-1).forEach((t=>{s.push([r].concat(t))}))})),s}}class nt{static float(t=1,e){return e?Math.random()*(e-t)+t:t*Math.random()}static int(t,e){return Math.floor(this.float(t,e))}static char(t){t=t??this.bool();const e=String.fromCharCode(this.int(97,120));return t?e.toUpperCase():e}static bool(){return[!1,!0][Math.floor(2*Math.random())]}static string(t,e){return t instanceof Array?new Array(this.int(...t)).fill(0).map((()=>this.char(e))).join(""):new Array(t).fill(0).map((()=>this.char(e))).join("")}static bin(){return this.int(2)}static oct(){return this.int(8)}static dec(){return this.int(8)}static hex(){return this.int(16)}static choice(t=[1,2,3],e=new Array(t.length).fill(1/t.length)){let s=new Array(100);e=tt.accum(...e).map((t=>100*t)),s.fill(t[0],0,e[0]);for(let r=1;r<t.length;r++)s.fill(t[r],e[r-1],e[r]);return s[this.int(s.length-1)]}static shuffleArr(t){return t.sort((()=>.5-Math.random()))}static shuffleMatrix(t){const{rows:e,cols:s,arr:r}=t;return gs(e,s,r.flat().sort((()=>.5-Math.random())))}static floats(t,e,s){return new Array(t).fill(0).map((()=>this.float(e,s)))}static ints(t,e,s){return new Array(t).fill(0).map((()=>this.int(e,s)))}static bools(t){return new Array(t).fill(0).map((()=>this.bool()))}static bins(t){return new Array(t).fill(0).map((()=>this.int(2)))}static octs(t){return new Array(t).fill(0).map((()=>this.int(8)))}static decs(t){return new Array(t).fill(0).map((()=>this.int(10)))}static hexs(t){return new Array(t).fill(0).map((()=>this.int(16)))}static choices(t,e,s){return new Array(t).fill(0).map((()=>this.choice(e,s)))}static perm(...t){return t.permS[this.int(t.length)]}static color(){return"#"+et.dec2hex(this.float(16777216)).padStart(6,0)}static colors(t){return new Array(t).fill(null).map((()=>this.color()))}static complex(t=[0,1],e=[0,1]){return t instanceof Array?new bs(this.float(t[0],t[1]),this.float(e[0],e[1])):new bs(...this.floats(2,t,e))}static complexInt(t=[0,1],e=[0,1]){return new bs(this.int(t[0],t[1]),this.int(e[0],e[1]))}static complexBin(){return new bs(...this.bins(2))}static complexOct(){return new bs(...this.octs(2))}static complexDec(){return new bs(...this.decs(10))}static complexHex(){return new bs(...this.octs(2))}static complexes(t,e=0,s=1){return new Array(t).fill(0).map((()=>this.complex(e,s)))}static complexesInt(t,e=0,s=1){return new Array(t).fill(0).map((()=>this.complexInt(e,s)))}static complexesBin(t){return new Array(t).fill(0).map((()=>this.complexBin()))}static complexesOct(t){return new Array(t).fill(0).map((()=>this.complexOct()))}static complexesDec(t){return new Array(t).fill(0).map((()=>this.complexDec()))}static complexesHex(t){return new Array(t).fill(0).map((()=>this.complexHex()))}static matrix(t,e,s,r){return gs(t,e,this.floats(t*e,s,r))}static matrixInt(t,e,s,r){return gs(t,e,this.ints(t*e,s,r))}static matrixBin(t,e){return gs(t,e,this.bins(t*e))}static matrixOct(t,e){return gs(t,e,this.octs(t*e))}static matrixDec(t,e){return gs(t,e,this.decs(t*e))}static matrixHex(t,e){return gs(t,e,this.hex(t*e))}static matrixColor(t,e){return gs(t,e,this.colors(t*e))}static matrixComplex(t,e,s,r){return gs(t,e,this.complexes(t*e,s,r))}static matrixComplexInt(t,e,s,r){return gs(t,e,this.complexesInt(t*e,s,r))}static matrixComplexBin(t,e){return gs(t,e,this.complexesBin(t*e))}static matrixComplexOct(t,e){return gs(t,e,this.complexesBin(t*e))}static matrixComplexDec(t,e){return gs(t,e,this.complexesBin(t*e))}static matrixComplexHex(t,e){return gs(t,e,this.complexesBin(t*e))}}const it=t=>{const e=new XMLHttpRequest;if(e.open("GET",t,!1),e.send(),200===e.status)return e.responseText;throw new Error(`Failed to fetch data from ${t}. Status: ${e.status}`)};globalThis.fetchdom=async function(t="https://github.com/zakarialaoui10"){const e=await fetch(t),s=await e.text();return(new DOMParser).parseFromString(s,"text/xml").documentElement},globalThis.fetchdomSync=function(t="https://github.com/zakarialaoui10"){const e=it(t);return(new DOMParser).parseFromString(e,"text/xml").documentElement};const at=(t,e=",")=>t.trim().trimEnd().split("\n").map((t=>t.split(e))),ot=(t,e=",")=>{const[s,...r]=at(t,e);return r.map((t=>{const e={};return s.forEach(((s,r)=>{e[s]=t[r]})),e}))},ht=t=>t instanceof Array?[Object.keys(t[0]),...t.map((t=>Object.values(t)))]:[Object.keys(t)],ct=(t,e)=>ht(t).map((t=>t.join(e))).join("\n"),lt=(t,e=",")=>ct(t instanceof Object?t:JSON.parse(t),e),ut=(t,e)=>{const s=[];if(Array.isArray(t))t.forEach((t=>{if("object"==typeof t&&null!==t){s.push(`${e}-`);const r=ut(t,`${e} `);s.push(...r)}else s.push(`${e}- ${t}`)}));else for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];if("object"==typeof n&&null!==n){s.push(`${e}${r}:`);const t=ut(n,`${e} `);s.push(...t)}else s.push(`${e}${r}: ${n}`)}return s},mt=(t,e="")=>ut(t,e).join("\n"),pt=(t,e)=>mt(t instanceof Object?t:JSON.parse(t),e),ft=(t,e=1)=>{let s="";for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];s+="\n"+" ".repeat(e)+`<${r}>`,s+="object"==typeof n?ft(n,e+2):`${n}`,s+=`</${r}>`}return s.trim()};class dt{constructor(t){this.cache={node:t}}isZikoUINode(){return!0}get node(){return this.cache.node}}class gt extends Array{constructor(...t){super(...t)}getItemById(t){return this.find((e=>e.element.id===t))}getItemsByTagName(t){return this.filter((e=>e.element.tagName.toLowerCase()===t.toLowerCase()))}getElementsByClassName(t){return this.filter((e=>e.element.classList?.contains(t)))}querySelector(t){const e=globalThis?.document?.querySelector(t);return e&&this.find((t=>t.element===e))||null}querySelectorAll(t){const e=globalThis?.document?.querySelectorAll(t);return Array.from(e).map((t=>this.find((e=>e.element===t)))).filter(Boolean)}}const bt=new gt,wt={default:{target:null,render:!0,math:{mode:"deg"}},setDefault:function(t){const e=Object.keys(t),s=Object.values(t);for(let t=0;t<e.length;t++)this.default[e[t]]=s[t]},init:()=>{},renderingMode:"spa",isSSC:!1},yt={store:new Map,index:0,register:function(t){this.store.set(this.index++,t)}},vt={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(t){}},_t={store:new Map,index:0,register:function(t){console.log({index:this.index}),this.store.set(this.index++,t)}};function xt(){var t;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:bt,__HYDRATION__:yt,__State__:_t,__Config__:wt,__CACHE__:vt},t=__Ziko__,Object.defineProperties(t,{QueryParams:{get:function(){return function(t){const e={};return t.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi,(t=>{const[s,r]=t.split("=");e[s]=r})),e}(globalThis.location.search.substring(1))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}}))}xt();class Et extends dt{constructor(){super()}init(t,e,s,r,n=[!0,!1][Math.floor(2*Math.random())]){if(this.target=globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body,"string"==typeof t)switch(s){case"html":t=globalThis?.document?.createElement(t),console.log("1");break;case"svg":t=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg",t),console.log("2");break;default:throw Error("Not supported")}else this.target=t?.parentElement;Object.assign(this.cache,{name:e,isInteractive:n,parent:null,isBody:!1,isRoot:!1,isHidden:!1,isFrozzen:!1,legacyParent:null,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},t&&Object.assign(this.cache,{element:t}),this.items=new gt,globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this],t&&r&&this?.render?.(),this.isInteractive()&&globalThis.__Ziko__.__HYDRATION__.register((()=>this)),globalThis.__Ziko__.__UI__.push(this)}get element(){return this.cache.element}[Symbol.iterator](){return this.items[Symbol.iterator]()}maintain(){for(let t=0;t<this.items.length;t++)Object.defineProperty(this,t,{value:this.items[t],writable:!0,configurable:!0,enumerable:!1})}isInteractive(){return this.cache.isInteractive}isUIElement(){return!0}}function kt(t,...e){e.forEach((e=>function(t,e){const s=Object.getOwnPropertyDescriptors(e);for(const e of Reflect.ownKeys(s)){const r=s[e];"get"in r||"set"in r||"function"!=typeof r.value?Object.defineProperty(Object.getPrototypeOf(t),e,r):"function"==typeof r.value&&(Object.getPrototypeOf(t).hasOwnProperty(e)||Object.defineProperty(Object.getPrototypeOf(t),e,r))}}(t,e)))}function Tt(t){const{store:e,index:s}=__Ziko__.__State__;__Ziko__.__State__.register({value:t,subscribers:new Set,paused:!1});const r=e.get(s);return[function(){return{value:r.value,isStateGetter:()=>!0,_subscribe:t=>r.subscribers.add(t)}},function(t){r.paused||("function"==typeof t&&(t=t(r.value)),t!==r.value&&(r.value=t,r.subscribers.forEach((t=>t(r.value)))))},{pause:()=>{r.paused=!0},resume:()=>{r.paused=!1},clear:()=>{r.subscribers.clear()},force:t=>{"function"==typeof t&&(t=t(r.value)),r.value=t,r.subscribers.forEach((t=>t(r.value)))},getSubscribers:()=>new Set(r.subscribers)}]}globalThis.__Ziko__||xt();const At=t=>"function"==typeof t&&t?.()?.isStateGetter?.(),Ot=(t="")=>t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase())),St=(t="")=>{if(0===t.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(t)};class Ct extends dt{constructor(...t){super("span","text",!1,...t),this.element=globalThis?.document?.createTextNode(...t)}isText(){return!0}}const jt=(...t)=>new Ct(...t);async function It(t,e,...s){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]=jt(s[r])),s[r]instanceof Function){const t=s[r]();t.isStateGetter&&(s[r]=jt(t.value),t._subscribe((t=>s[r].element.textContent=t),s[r]))}if("function"==typeof globalThis?.Node&&s[r]instanceof globalThis?.Node&&(s[r]=new this.constructor(s[r])),s[r]?.isZikoUINode)s[r].cache.parent=this,this.element?.[t](s[r].element),s[r].target=this.element,this.items[e](s[r]);else if(s[r]instanceof Promise){const n=await s[r];n.cache.parent=this,this.element?.[t](n.element),n.target=this.element,this.items[e](n)}else s[r]instanceof Object&&(s[r]?.style&&this.style(s[r]?.style),s[r]?.attr&&Object.entries(s[r].attr).forEach((t=>this.setAttr(""+t[0],t[1]))))}return this.maintain(),this}function Mt(t,e){if(this.element instanceof globalThis?.SVGAElement&&(t=St(t)?Ot(t):t),!this?.attr[t]||this?.attr[t]!==e){if(At(e)){e()._subscribe((e=>this.element?.setAttribute(t,e)),this)}else this.element?.setAttribute(t,e);Object.assign(this.cache.attributes,{[t]:e})}}var Dt=Object.freeze({__proto__:null,getAttr:function(t){return t=is_camelcase(t)?camel2hyphencase(t):t,this.element.attributes[t].value},removeAttr:function(...t){for(let e=0;e<t.length;e++)this.element?.removeAttribute(t[e]);return this},setAttr:function(t,e){if(t instanceof Object){const[s,r]=[Object.keys(t),Object.values(t)];for(let t=0;t<s.length;t++)r[t]instanceof Array&&(e[t]=r[t].join(" ")),Mt.call(this,s[t],r[t])}else e instanceof Array&&(e=e.join(" ")),Mt.call(this,t,e);return this},setContentEditable:function(t=!0){return this.setAttr("contenteditable",t),this}});var Pt=Object.freeze({__proto__:null,after:function(t){return t?.isUIElement&&(t=t.element),this.element?.after(t),this},append:function(...t){return It.call(this,"append","push",...t),this},before:function(t){return t?.isUIElement&&(t=t.element),this.element?.before(t),this},clear:function(){return this?.items?.forEach((t=>t.unrender())),this.element.innerHTML="",this},insertAt:function(t,...e){if(t>=this.element.children.length)this.append(...e);else for(let s=0;s<e.length;s++)["number","string"].includes(typeof e[s])&&(e[s]=jt(e[s])),this.element?.insertBefore(e[s].element,this.items[t].element),this.items.splice(t,0,e[s]);return this},prepend:function(...t){return this.__addItem__.call(this,"prepend","unshift",...t),this},remove:function(...t){const e=t=>{"number"==typeof t&&(t=this.items[t]),t?.isUIElement&&this.element?.removeChild(t.element),this.items=this.items.filter((e=>e!==t))};for(let s=0;s<t.length;s++)e(t[s]);for(let t=0;t<this.items.length;t++)Object.assign(this,{[[t]]:this.items[t]});return this},render:function(t=this.target){if(!this.isBody)return t?.isUIElement&&(t=t.element),this.target=t,this.target?.appendChild(this.element),this},renderAfter:function(t=1){return setTimeout((()=>this.render()),t),this},unrender:function(){return this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target?.children].includes(this.element)&&this.target.removeChild(this.element),this},unrenderAfter:function(t=1){return setTimeout((()=>this.unrender()),t),this}});const Rt={Click:["Click","DblClick","ClickAway"],Ptr:["PtrMove","PtrDown","PtrUp","PtrLeave","PtrEnter","PtrOut","PtrCancel"],Mouse:["MouseMove","MouseDown","MouseUp","MouseEnter","MouseLeave","MouseOut"],Key:["KeyDown","KeyPress","KeyUp"],Clipboard:["Copy","Cut","Paste"],Focus:["focus","blur"],Drag:["Drag","DragStart","DragEnd","Drop"],Wheel:["Wheel"]},Lt=(t="")=>t.startsWith("Ptr")?`pointer${t.split("Ptr")[1].toLowerCase()}`:t.toLowerCase();function $t(t,e,s,r,n){this.cache.currentEvent=e,this.cache.event=t,s?.call(this),r?.hasOwnProperty("prototype")?r?.call(this):r?.call(null,this),this.cache.preventDefault[e]&&t.preventDefault(),this.cache.stopPropagation[e]&&t.stopPropagation(),this.cache.stopImmediatePropagation[e]&&t.stopImmediatePropagation(),this.cache.stream.enabled[e]&&n&&this.cache.stream.history[e].push(n),this.cache.callbacks[e]?.map((t=>t(this)))}class Nt{constructor(t=null,e=[],s,r){this.target=t,this.cache={currentEvent:null,event:null,options:{},preventDefault:{},stopPropagation:{},stopImmediatePropagation:{},event_flow:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{},__controllers__:{}},e&&this._register_events(e,s,r)}_register_events(t,e,s,r=!0){const n=t?.map((t=>Lt(t)));return n?.forEach(((n,i)=>{Object.assign(this.cache.preventDefault,{[n]:!1}),Object.assign(this.cache.options,{[n]:{}}),Object.assign(this.cache.paused,{[n]:!1}),Object.assign(this.cache.stream.enabled,{[n]:!1}),Object.assign(this.cache.stream.clear,{[n]:!1}),Object.assign(this.cache.stream.history,{[n]:[]}),Object.assign(this.cache.__controllers__,{[n]:t=>$t.call(this,t,n,e,s)}),r&&Object.assign(this,{[`on${t[i]}`]:(...t)=>this.__onEvent(n,this.cache.options[n],{},...t)})})),this}get targetElement(){return this.target?.element}get isParent(){return this.target?.element===this.event.srcElement}get item(){return this.target.find((t=>t.element==this.event?.srcElement))?.[0]}get currentEvent(){return this.cache.currentEvent}get event(){return this.cache.event}setTarget(t){return this.target=t,this}__handle(t,e,s,r){return this.targetElement?.addEventListener(t,e,s),this}__onEvent(t,e,s,...r){if(0===r.length){if(console.log("00"),!this.cache.callbacks[t])return this;console.log("Call"),this.cache.callbacks[t].map((t=>e=>t.call(this,e)))}else this.cache.callbacks[t]=r.map((t=>e=>t.call(this,e)));return this.__handle(t,this.cache.__controllers__[t],e,s),this}#t(t,e,s){"default"===s&&Object.assign(this.cache[t],{...this.cache[t],...e});const r="default"===s?this.cache[t]:Object.fromEntries(Object.keys(this.cache.preventDefault).map((t=>[t,s])));return Object.assign(this.cache[t],{...r,...e}),this}preventDefault(t={},e="default"){return this.#t("preventDefault",t,e),this}stopPropagation(t={},e="default"){return this.#t("stopPropagation",t,e),this}stopImmediatePropagation(t={},e="default"){return this.#t("stopImmediatePropagation",t,e),this}setEventOptions(t,e){return this.pause({[t]:!0},"default"),Object.assign(this.cache.options[Lt(t)],e),this.resume({[t]:!0},"default"),this}pause(t={},e="default"){t={..."default"===e?this.cache.stream.enabled:Object.entries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t};for(let e in t)t[e]&&(this.targetElement?.removeEventListener(e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]=!0);return this}resume(t={},e="default"){t={..."default"===e?this.cache.stream.enabled:Object.entries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t};for(let e in t)t[e]&&(this.targetElement?.addEventListener(e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]=!1);return this}stream(t={},e="default"){this.cache.stream.t0=Date.now();return t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t},Object.assign(this.cache.stream.enabled,t),this}clear(){return this}dispose(t={},e="default"){return this.pause(t,e),this}}class Bt extends Nt{constructor(t,e){super(t,Rt.Click,Ft,e)}}function Ft(){"click"===this.currentEvent?this.dx=0:this.dx=1}const Ht=(t,e)=>new Bt(t,e);class zt extends Nt{constructor(t,e){super(t,Rt.Clipboard,Zt,e)}}function Zt(){}const Ut=(t,e)=>new zt(t,e);class qt extends Nt{constructor(t,e,s){super(t,e,Wt,s)}_register_events(t){return super._register_events(t,null,null,!1),this}emit(t,e={}){const s=new Event(t);return this.targetElement.dispatchEvent(s),this}on(t,...e){return this.cache.options.hasOwnProperty(t)||this._register_events([t]),this.__onEvent(t,this.cache.options[t],{},...e),this}}function Wt(){}class Vt extends Nt{constructor(t,e){super(t,Rt.Drag,Gt,e)}}function Gt(){}const Xt=(t,e)=>new Vt(t,e);class Yt extends Nt{constructor(t,e){super(t,Rt.Focus,Kt,e)}}function Kt(){}const Qt=(t,e)=>new Yt(t,e);let Jt=class extends Nt{constructor(t,e){super(t,Rt.Hash,te,e)}};function te(){}class ee extends Nt{constructor(t,e){super(t,Rt.Key,se,e)}}function se(){switch(this.currentEvent){case"keydown":this.kd=this.event.key;break;case"keypress":this.kp=this.event.key;break;case"keyup":this.ku=this.event.key}}const re=(t,e)=>new ee(t,e);class ne extends Nt{constructor(t,e){super(t,Rt.Mouse,ie,e)}}function ie(){}const ae=(t,e)=>new ne(t,e);class oe extends Nt{constructor(t,e){super(t,Rt.Ptr,he,e),this.isDown=!1}}function he(){switch(this.currentEvent){case"pointerdown":this.dx=parseInt(this.event.offsetX),this.dy=parseInt(this.event.offsetY),this.isDown=!0;break;case"pointermove":this.mx=parseInt(this.event.offsetX),this.my=parseInt(this.event.offsetY),this.isMoving=!0;break;case"pointerup":{this.ux=parseInt(this.event.offsetX),this.uy=parseInt(this.event.offsetY),this.isDown=!1,console.log(this.target.width);const t=(this.ux-this.dx)/this.target.width,e=(this.dy-this.uy)/this.target.height,s=t<0?"left":t>0?"right":"none",r=e<0?"bottom":e>0?"top":"none";this.swippe={h:s,v:r,delta_x:t,delta_y:e}}}}const ce=(t,e)=>new oe(t,e);class le extends Nt{constructor(t,e){super(t,Rt.Touch,ue,e)}}function ue(){}class me extends Nt{constructor(t,e){super(t,Rt.Wheel,pe,e)}}function pe(){}const fe=(t,e)=>new me(t,e),de={ptr:ce,mouse:ae,key:re,click:Ht,drag:Xt,clipboard:Ut,focus:Qt,wheel:fe},ge={};Object.entries(Rt).forEach((([t,e])=>{e.forEach((e=>{const s=`on${e}`;ge[s]=function(...e){return this.events[t]||(this.events[t]=de[t.toLowerCase()](this)),this.events[t][s](...e),this}}))}));var be=Object.freeze({__proto__:null,at:function(t){return this.items.at(t)},find:function(t){return this.items.filter(t)},forEach:function(t){return this.items.forEach(t),this},map:function(t){return this.items.map(t)}});var we=Object.freeze({__proto__:null,animate:function(t,{duration:e=1e3,iterations:s=1,easing:r="ease"}={}){return this.element?.animate(t,{duration:e,iterations:s,easing:r}),this},hide:function(){},show:function(){},size:function(t,e){return this.style({width:t,height:e})},style:function(t){for(let e in t){const s=t[e];if(At(s)){const t=s();Object.assign(this.element.style,{[e]:t.value}),t._subscribe((t=>{console.log({newValue:t}),Object.assign(this.element.style,{[e]:t})}))}else Object.assign(this.element.style,{[e]:s})}return this}});function ye(t,e,s,r){return this.event=t,this.cache.preventDefault[e]&&t.preventDefault(),console.log({setter:s}),s&&s(),this.cache.stream.enabled[e]&&r&&this.cache.stream.history[e].push(r),this.cache.callbacks[e].map((t=>t(this))),this}class ve{constructor(t){this.target=null,this.setTarget(t),this.__dispose=this.dispose.bind(this)}get targetElement(){return this.target.element}setTarget(t){return this.target=t,this}__handle(t,e,s){const r="drag"===t?t:`${this.cache.prefixe}${t}`;return this.dispose(s),this.targetElement?.addEventListener(r,e),this}__onEvent(t,e,...s){if(0===s.length){if(!(this.cache.callbacks.length>1))return this;this.cache.callbacks.map((t=>e=>t.call(this,e)))}else this.cache.callbacks[t]=s.map((t=>e=>t.call(this,e)));return this.__handle(t,this.__controller[t],e),this}preventDefault(t={}){return Object.assign(this.cache.preventDefault,t),this}pause(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.targetElement?.removeEventListener(`${this.cache.prefixe}${e}`,this.__controller[`${this.cache.prefixe}${e}`]),this.cache.paused[`${this.cache.prefixe}${e}`]=!0);return this}resume(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.targetElement?.addEventListener(`${this.cache.prefixe}${e}`,this.__controller[`${this.cache.prefixe}${e}`]),this.cache.paused[`${this.cache.prefixe}${e}`]=!1);return this}dispose(t={}){return this.pause(t),this}stream(t={}){this.cache.stream.t0=Date.now();return t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t},Object.assign(this.cache.stream.enabled,t),this}clear(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.clear).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.cache.stream.history[e]=[]);return this}}function _e(t){ye.call(this,t,"input",null,null)}function xe(t){ye.call(this,t,"change",null,null)}class Ee extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{input:!1,change:!1},paused:{input:!1,change:!1},stream:{enabled:{input:!1,change:!1},clear:{input:!1,change:!1},history:{input:[],change:[]}},callbacks:{input:[],change:[]}},this.__controller={input:_e.bind(this),change:xe.bind(this)}}get value(){return this.target.value}onInput(...t){return this.__onEvent("input",{},...t),this}onChange(...t){return this.__onEvent("change",{},...t),this}}function ke(t){ye.call(this,t,"hashchange",null,null)}class Te extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{hashchange:!1},paused:{hashchange:!1},stream:{enabled:{hashchange:!1},clear:{hashchange:!1},history:{hashchange:[]}},callbacks:{hashchange:[]}},this.__controller={hashchange:ke.bind(this)}}onChange(...t){return this.__onEvent("hashchange",{},...t),this}}const Ae=t=>function(e){ye.call(this,e,t,null,null)};class Oe extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{}},this.__controller={}}#e(t){return this.cache.preventDefault[t]=!1,this.cache.paused[t]=!1,this.cache.stream.enabled=!1,this.cache.stream.clear=!1,this.cache.stream.history=[],this.cache.callbacks[t]=[],this.__controller[t]=Ae(t).bind(this),this}on(t,...e){return this.__controller[t]||this.#e(t),this.__onEvent(t,{},...e),this}emit(t,e={}){this.__controller[t]||this.#e(t),this.detail=e;const s=new Event(t);return this.targetElement.dispatchEvent(s),this}}const Se=t=>new Oe(t);class Ce extends ve{constructor(t,e=.3,s=.3){super(t);const{removeListener:r,setWidthThreshold:n,setHeightThreshold:i}=function(t,e=.5,s=.5,r,n){let i=R(e,0,r),a=R(s,0,n),o=0,h=0,c=0,l=0;const u=t=>{o=t.clientX,h=t.clientY},m=t=>{c=t.clientX,l=t.clientY,p()};function p(){const t=c-o,e=l-h;(Math.abs(t)>i||Math.abs(e)>a)&&f(t,e)}function f(e,s){const o=globalThis?.CustomEvent?new CustomEvent("swipe",{detail:{deltaX:ys(e)<i?0:Ms(e)*P(ys(e),0,r),deltaY:ys(s)<a?0:Ms(s)*P(ys(s),0,n),direction:{x:ys(e)<i?"none":e>0?"right":"left",y:ys(s)<a?"none":s>0?"down":"up"}}}):null;t?.dispatchEvent(o)}function d(t){i=R(t,0,r)}function g(t){a=R(t,0,n)}return t?.addEventListener("pointerdown",u),t?.addEventListener("pointerup",m),{removeListener(){t?.removeEventListener("pointerdown",u),t?.removeEventListener("pointerup",m),console.log("Swipe event listeners removed")},setWidthThreshold:d,setHeightThreshold:g}}(this.target?.element,e,s,this.target.width,this.target.height);this.cache={width_threshold:e,height_threshold:s,removeListener:r,setWidthThreshold:n,setHeightThreshold:i,legacyTouchAction:globalThis?.document?.body?.style?.touchAction,prefixe:"",preventDefault:{swipe:!1},paused:{swipe:!1},stream:{enabled:{swipe:!1},clear:{swipe:!1},history:{swipe:[]}},callbacks:{swipe:[]}},this.__controller={swipe:je.bind(this)}}onSwipe(...t){return Object.assign(globalThis?.document?.body?.style,{touchAction:"none"}),this.__onEvent("swipe",{},...t),this}updateThresholds(t=this.cache.width_threshold,e=this.cache.height_threshold){return void 0!==t&&this.cache.setWidthThreshold(t),void 0!==e&&this.cache.setHeightThreshold(e),this}destroy(){return this.cache.removeListener(),Object.assign(globalThis?.document?.body?.style,{touchAction:this.cache.legacyTouchAction}),this}}function je(t){ye.call(this,t,"swipe",null,null)}class Ie{constructor(t,e){this.target=t,this.observer=null,this.cache={options:e||{attributes:!0,childList:!0,subtree:!0},streamingEnabled:!0,lastMutation:null,mutationHistory:{}},this.observeCallback=(t,e)=>{if(this.cache.streamingEnabled)for(const e of t)switch(e.type){case"attributes":this.cache.mutationHistory.attributes.push(e.target.getAttribute(e.attributeName));break;case"childList":this.cache.mutationHistory.childList.push(e);break;case"subtree":this.cache.mutationHistory.subtree.push(e)}this.callback&&this.callback(t,e)}}observe(t){if(!this.observer){if(!globalThis.MutationObserver)return void console.log("MutationObserver Nor Supported");this.observer=new MutationObserver(this.cache.observeCallback),this.observer.observe(this.target.element,this.cache.options),this.callback=([e])=>t.call(e,this),this.cache.streamingEnabled=!0}}pause(t){this.observer&&(this.observer.disconnect(),t&&this.observer.observe(this.target,t))}reset(t){this.observer&&(this.observer.disconnect(),this.observer.observe(this.target,t||this.cache.options))}clear(){return this.observer&&(this.observer.disconnect(),this.observer=null,this.cache.mutationHistory={attributes:[],childList:[],subtree:[]}),this.cache.streamingEnabled=!1,this}getMutationHistory(){return this.cache.mutationHistory}enableStreaming(){return this.cache.streamingEnabled=!0,this}disableStreaming(){return this.cache.streamingEnabled=!1,this}}class Me extends Ie{constructor(t,e){super(t,{attributes:!0,childList:!1,subtree:!1}),Object.assign(this.cache,{observeCallback:(t,e)=>{for(const e of t)this.cache.lastMutation={name:e.attributeName,value:e.target.getAttribute(e.attributeName)},this.cache.streamingEnabled&&this.cache.mutationHistory.attributes.push(this.cache.lastMutation);this.callback&&this.callback(t,e)}}),this.cache.mutationHistory.attributes=[],e&&this.observe(e)}get history(){return this.cache.mutationHistory.attributes}}class De extends Ie{constructor(t,e){super(t,{attributes:!1,childList:!0,subtree:!1}),Object.assign(this.cache,{observeCallback:(t,e)=>{for(const e of t)e.addedNodes?this.cache.lastMutation={type:"add",item:this.target.find((t=>t.element===e.addedNodes[0]))[0],previous:this.target.find((t=>t.element===e.previousSibling))[0]}:e.addedNodes&&(this.cache.lastMutation={type:"remove",item:this.target.find((t=>t.element===e.removedNodes[0]))[0],previous:this.target.find((t=>t.element===e.previousSibling))[0]}),this.cache.streamingEnabled&&this.cache.mutationHistory.children.push(this.cache.lastMutation);this.callback&&this.callback(t,e)}}),this.cache.mutationHistory.children=[],e&&this.observe(e)}get item(){return this.cache.lastMutation.item}get history(){return this.cache.mutationHistory.children}}class Pe{constructor(t,e,{threshold:s=0,margin:r=0}={}){this.target=t,this.config={threshold:s,margin:r},globalThis.IntersectionObserver?this.observer=new IntersectionObserver((t=>{this.entrie=t[0],e(this)}),{threshold:this.threshold}):console.log("IntersectionObserver Not Supported")}get ratio(){return this.entrie.intersectionRatio}get isIntersecting(){return this.entrie.isIntersecting}setThreshould(t){return this.config.threshold=t,this}setMargin(t){return t="number"==typeof t?t+"px":t,this.config.margin=t,this}start(){return this.observer.observe(this.target.element),this}stop(){return this}}class Re{constructor(t,e){this.target=t,this.contentRect=null,this.observer=new ResizeObserver((()=>{e(this)}))}get BoundingRect(){return this.target.element.getBoundingClientRect()}get width(){return this.BoundingRect.width}get height(){return this.BoundingRect.height}get top(){return this.BoundingRect.top}get bottom(){return this.BoundingRect.bottom}get right(){return this.BoundingRect.right}get left(){return this.BoundingRect.left}get x(){return this.BoundingRect.x}get y(){return this.BoundingRect.y}start(){return this.observer.observe(this.target.element),this}stop(){return this.observer.unobserve(this.target.element),this}}class Le{constructor(t=(t=>console.log({x:t.x,y:t.y}))){this.cache={},this.previousX=globalThis?.screenX,this.previousY=globalThis?.screenY}update(){Object.assign(this.cache,{screenXLeft:globalThis?.screenX,screenXRight:globalThis?.screen.availWidth-globalThis?.screenX,screenYTop:globalThis?.screenY,screenYBottom:globalThis?.screen.availHeight-globalThis?.screenY-globalThis?.outerHeight,screenCenterX:globalThis?.screen.availWidth/2,screenCenterY:globalThis?.screen.availHeight/2,windowCenterX:globalThis?.outerWidth/2+globalThis?.screenX,windowCenterY:globalThis?.outerHeight/2+globalThis?.screenY,deltaCenterX:globalThis?.screen.availWidth/2-globalThis?.outerWidth/2+globalThis?.screenX,deltaCenterY:null})}get x0(){return L(globalThis?.screenX,0,globalThis.screen.availWidth,-1,1)}get y0(){return-L(globalThis?.screenY,0,globalThis.screen.availHeight,-1,1)}get x1(){return L(globalThis?.screenX+globalThis?.outerWidth,0,globalThis.screen.availWidth,-1,1)}get y1(){return-L(globalThis?.screenY+globalThis?.outerHeight,0,globalThis.screen.availHeight,-1,1)}get cx(){return L(globalThis?.outerWidth/2+globalThis?.screenX,0,globalThis.screen.availWidth,-1,1)}get cy(){return-L(globalThis?.outerHeight/2+globalThis?.screenY,0,globalThis.screen.availHeight,-1,1)}}class $e{constructor(){this.events={},this.maxListeners=10}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e),this.events[t].length>this.maxListeners&&console.warn(`Warning: Possible memory leak. Event '${t}' has more than ${this.maxListeners} listeners.`)}once(t,e){const s=r=>{this.off(t,s),e(r)};this.on(t,s)}off(t,e){const s=this.events[t];if(s){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}emit(t,e){const s=this.events[t];s&&s.forEach((t=>{t(e)}))}clear(t){t?delete this.events[t]:this.events={}}setMaxListener(t,e){this.maxListeners=e}removeAllListeners(t){t?this.events[t]=[]:this.events={}}}const Ne=()=>new $e;class Be{constructor(t,e=!0){this.#e(),this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}#e(){return this.__FavIcon__=document.querySelector("link[rel*='icon']")||document?.createElement("link"),this.__FavIcon__.type="image/x-icon",this.__FavIcon__.rel="shortcut icon",this}set(t){return t!==this.__FavIcon__.href&&(this.__FavIcon__.href=t,this.cache.Emitter&&this.cache.Emitter.emit("ziko:favicon-changed")),this}get current(){return document.__FavIcon__.href}onChange(t){return this.cache.Emitter&&this.cache.Emitter.on("ziko:favicon-changed",t),this}useEventEmitter(){return this.cache.Emitter=Ne(),this}}const Fe=(t,e)=>new Be(t,e);class He{constructor({viewport:t,charset:e,description:s,author:r,keywords:n}){this.document=globalThis?.document,this.meta={},this.init({viewport:t,charset:e,description:s,author:r,keywords:n})}init({viewport:t,charset:e,description:s,author:r,keywords:n}){t&&this.setViewport(t),e&&this.setCharset(e),s&&this.describe(s),r&&this.setAuthor(r),n&&this.setKeywords(n)}set(t,e){const s="charset"===(t=t.toLowerCase()),r=s?document.querySelector("meta[charset]"):document.querySelector(`meta[name=${t}]`);return this.meta=r??document?.createElement("meta"),s?this.meta.setAttribute("charset",e):(this.meta.setAttribute("name",t),this.meta.setAttribute("content",e)),r||this.document.head.append(this.meta),this}setCharset(t="utf-8"){return this.set("charset",t),this}describe(t){return this.set("description",t),this}setViewport(t="width=device-width, initial-scale=1.0"){return this.set("viewport",t),this}setKeywords(...t){return t=[...new Set(t)].join(", "),this.set("keywords",t),this}setAuthor(t){return this.set("author",t),this}}const ze=({viewport:t,charset:e,description:s,author:r,keywords:n})=>new He({viewport:t,charset:e,description:s,author:r,keywords:n});class Ze{constructor(t=document.title,e=!0){this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.Emitter=Ne(),this}set(t){return t!==document.title&&(document.title=t,this.cache.Emitter&&this.cache.Emitter.emit("ziko:title-changed")),this}get current(){return document.title}onChange(t){return this.cache.Emitter&&this.cache.Emitter.on("ziko:title-changed",t),this}}const Ue=(t,e)=>new Ze(t,e);class qe{constructor({title:t,lang:e,icon:s,meta:r,noscript:n}){this.html=globalThis?.document?.documentElement,this.head=globalThis?.document?.head,t&&Ue(t),e&&this.setLang(e),s&&Fe(s),r&&ze(r),n&&this.setNoScript()}setLang(t){this.html.setAttribute("lang",t)}setNoScript(t){}}const We=({title:t,lang:e,icon:s,meta:r,noscript:n})=>new qe({title:t,lang:e,icon:s,meta:r,noscript:n});class Ve{constructor(t=[],e=(()=>{})){this.mediaQueryRules=t,this.fallback=e,this.lastCalledCallback=null,this.init()}init(){this.mediaQueryRules.forEach((({query:t,callback:e})=>{const s=globalThis.matchMedia(t),r=()=>{const t=this.mediaQueryRules.some((({query:t})=>globalThis.matchMedia(t).matches));s.matches?(e(),this.lastCalledCallback=e):t||this.lastCalledCallback===this.fallback||(this.fallback(),this.lastCalledCallback=this.fallback)};r(),s.addListener(r)}))}}let Ge=class extends Et{constructor({element:t,name:e="",type:s="html",render:r=__Ziko__.__Config__.default.render}={}){super(),kt(this,Dt,Pt,we,be,ge),this.init(t,e,s,r)}get element(){return this.cache.element}isInteractive(){return this.cache.isInteractive}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 isBody(){return this.element===globalThis?.document.body}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}on(t,...e){return this.events.custom||(this.events.custom=Se(this)),this.events.custom.on(t,...e),this}emit(t,e={}){return this.events.custom||(this.events.custom=Se(this)),this.events.custom.emit(t,e),this}};const Xe=["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"],Ye=["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"],Ke=new Proxy({},{get(t,e){if("string"!=typeof e)return;let s,r=e.replaceAll("_","-").toLowerCase();return Xe.includes(r)&&(s="html"),Ye.includes(r)&&(s="svg"),(...t)=>0===t.length?new Ge({element:r,name:r,type:s}):["string","number"].includes(typeof t[0])||t[0]instanceof Ge||"function"==typeof t[0]&&t[0]().isStateGetter()?new Ge({element:r,name:r,type:s}).append(...t):new Ge({element:r,type:s}).setAttr(t.shift()).append(...t)}});class Qe extends Ge{constructor(t="div",e="100%",s="100%"){super({element:t,name:"Flex"}),this.direction="cols","number"==typeof e&&(e+="%"),"number"==typeof s&&(s+="%"),this.style({width:e,height:s}),this.style({display:"flex"})}get isFlex(){return!0}resp(t,e=!0){return this.wrap(e),this.element.clientWidth<t?this.vertical():this.horizontal(),this}setSpaceAround(){return this.style({justifyContent:"space-around"}),this}setSpaceBetween(){return this.style({justifyContent:"space-between"}),this}setBaseline(){return this.style({alignItems:"baseline"}),this}gap(t){return"row"===this.direction?this.style({columnGap:t}):"column"===this.direction&&this.style({rowGap:t}),this}wrap(t="wrap"){return this.style({flexWrap:"string"==typeof t?t:["no-wrap","wrap","wrap-reverse"][+t]}),this}_justifyContent(t="center"){return this.style({justifyContent:t}),this}vertical(t,e,s=1){return Je.call(this,s),this.style({alignItems:"number"==typeof t?es.call(this,t):t,justifyContent:"number"==typeof e?ss.call(this,e):e}),this}horizontal(t,e,s=1){return ts.call(this,s),this.style({alignItems:"number"==typeof e?ss.call(this,e):e,justifyContent:"number"==typeof t?es.call(this,t):t}),this}show(){return this.isHidden=!1,this.style({display:"flex"}),this}}function Je(t){return 1==t?this.style({flexDirection:"column"}):-1==t&&this.style({flexDirection:"column-reverse"}),this}function ts(t){return 1==t?this.style({flexDirection:"row"}):-1==t&&this.style({flexDirection:"row-reverse"}),this}function es(t){return"number"==typeof t&&(t=["flex-start","center","flex-end"][t+1]),t}function ss(t){return es(-t)}class rs extends Et{constructor({element:t,name:e,type:s,render:r}){super({element:t,name:e,type:s,render:r})}}class ns extends rs{constructor(t,e){super({element:"div",name:"suspense"}),this.setAttr({dataTemp:"suspense"}),this.fallback_ui=t,this.append(t),(async()=>{try{const s=await e();t.unrender(),this.append(s)}catch(t){console.log({error:t})}})()}}class is extends Ge{constructor(t){super({element:"div",name:"html_wrappper"}),this.element.append(function(t){if(globalThis?.DOMParser){const e=(new DOMParser).parseFromString(`<div>${t}</div>`,"text/html");return e.body.firstChild.style.display="contents",e.body.firstChild}}(t)),this.style({display:"contents"})}}class as extends Ge{constructor(t){super({element:"div",name:"html_wrappper"}),this.element.append(function(t){if("undefined"!=typeof DOMParser){const e=(new DOMParser).parseFromString(t.trim(),"image/svg+xml").documentElement;if("parsererror"===e.nodeName)throw new Error("Invalid SVG string");if(e.hasAttribute("xmlns"))return e;const{children:s,attributes:r}=e,n=document.createElementNS("http://www.w3.org/2000/svg","svg");for(let{name:t,value:e}of r)n.setAttribute(t,e);return n.append(...s),globalThis.svg=e,globalThis.children=s,globalThis.attributes=r,globalThis.element=n,n}throw new Error("DOMParser is not available in this environment")}(t)),this.style({display:"contents"})}}const os=t=>(new XMLSerializer).serializeToString(t),hs=t=>btoa(os(t)),cs=t=>"data:image/svg+xml;base64,"+hs(t),ls=t=>JSON.stringify(v((t=>["number","string","boolean","bigint"].includes(typeof t)?String(t):t instanceof bs||t instanceof ds?t.toString():t instanceof Array?ms(t):void 0),t),null," ").replace(/"([^"]+)":/g,"$1:").replace(/: "([^"]+)"/g,": $1"),us=t=>{if(!Array.isArray(t))return 0;let e=1;for(const s of t)if(Array.isArray(s)){const t=us(s);t+1>e&&(e=t+1)}return e},ms=t=>{let e=0;return function t(s){let r=us(s),n=0;return s.some((t=>Array.isArray(t)))&&(e++,n=1),"["+s.map(((r,n)=>["number","string","boolean","bigint"].includes(typeof r)?String(r):r instanceof bs?r.toString():r instanceof Array?`\n${" ".repeat(e)}${t(r)}${n===s.length-1?"\n":""}`:r instanceof Object?ls(r):void 0))+`${" ".repeat((r+e+1)*n)}]`}(t)},ps=(t,e=0)=>{t=fs(t);let s="";const r=" ".repeat(e);for(let n in t)if("object"==typeof t[n]){s+=`${r}${n} {\n`;const i=t[n];for(let t in i)"object"==typeof i[t]?s+=ps({[t]:i[t]},e+1):s+=`${r} ${t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}: ${i[t]};\n`;s+=`${r}}\n`}return s};function fs(t){return"object"!=typeof t||null===t?t:Object.keys(t).reduce(((e,s)=>(e[s.trim()]=fs(t[s]),e)),Array.isArray(t)?[]:{})}class ds extends y{constructor(t,e,s=[]){if(super(),t instanceof ds)this.arr=t.arr,this.rows=t.rows,this.cols=t.cols;else{let r,n,i=[];if(arguments[0]instanceof Array)t=arguments[0].length,e=arguments[0][0].length,i=arguments[0];else for(r=0;r<t;r++)for(i.push([]),i[r].push(new Array(e)),n=0;n<e;n++)i[r][n]=s[r*e+n],null==s[r*e+n]&&(i[r][n]=0);this.rows=t,this.cols=e,this.arr=i}this.#s()}toString(){return ms(this.arr)}at(t=0,e=void 0){return t<0&&(t=this.rows+t),null==e?this.arr[t]:(e<0&&(e=this.cols+e),this.arr[t][e])}reshape(t,e){if(t*e==this.rows*this.cols)return new ds(t,e,this.arr.flat(1));console.error("Err")}static eye(t){let e=new ds(t,t);for(let s=0;s<t;s++)for(let r=0;r<t;r++)e.arr[s][r]=s===r?1:0;return e}get clone(){return new ds(this.rows,this.cols,this.arr.flat(1))}get size(){return this.rows*this.cols}get shape(){return[this.rows,this.cols]}get reel(){return new ds(this.cols,this.rows,this.arr.flat(1).reel)}get imag(){return new ds(this.cols,this.rows,this.arr.flat(1).imag)}[Symbol.iterator](){return this.arr[Symbol.iterator]()}#s(){for(let t=0;t<this.arr.length;t++)Object.defineProperty(this,t,{value:this.arr[t],writable:!0,configurable:!0,enumerable:!1})}get(t=0,e=0){return-1==e?this.arr[t]:-1==t?this.arr.map((t=>t[e])):this.arr[t][e]}set(t=0,e=0,s){if(-1==e)return this.arr[t]=s;if(-1==t){for(let t=0;t<this.cols;t++)this.arr[t][e]=s[t]||0;return this.arr}return this.arr[t][e]=s}get isSquare(){return this.rows/this.cols==1}get isSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==ds.sub(e,t).max&&0==ds.sub(e,t).min}get isAntiSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==ds.add(e,t).max&&0==ds.add(e,t).min}get isDiag(){if(!this.isSquare)return!1;const t=this.T,e=this.clone,s=ds.mul(e,t),r=ds.dot(t,e);return 0==ds.sub(s,r).max&&0==ds.sub(s,r).min}get isOrtho(){return!!this.isSquare&&(this.isDiag&&(1==this.det||-1==this.det))}get isIdemp(){if(!this.isSquare)return!1;const t=this.clone,e=ds.dot(t,t);return 0==ds.sub(e,t).max&&0==ds.sub(e,t).min}get T(){let t=[];for(let e=0;e<this.arr[0].length;e++){t[e]=[];for(let s=0;s<this.arr.length;s++)t[e][s]=this.arr[s][e]}return new ds(this.cols,this.rows,t.flat(1))}get det(){if(!this.isSquare)return new Error("is not square matrix");if(1==this.rows)return this.arr[0][0];function t(t,e){var s=[];for(let e=0;e<t.length;e++)s.push(t[e].slice(0));s.splice(0,1);for(let t=0;t<s.length;t++)s[t].splice(e,1);return s}return function e(s){if(2==s.length)return s.flat(1).some((t=>t instanceof ds))?void console.warn("Tensors are not completely supported yet ..."):tt.sub(tt.mul(s[0][0],s[1][1]),tt.mul(s[0][1],s[1][0]));for(var r=0,n=0;n<s.length;n++){const i=tt.add(tt.mul(_s(-1,n),tt.mul(s[0][n],e(t(s,n)))));r=tt.add(r,i)}return r}(this.arr)}get inv(){if(!this.isSquare)return new Error("is not square matrix");if(0===this.det)return"determinat = 0 !!!";let t=function(t){if(t.length!==t[0].length)return;var e=0,s=0,r=0,n=t.length,i=0,a=[],o=[];for(e=0;e<n;e+=1)for(a[a.length]=[],o[o.length]=[],r=0;r<n;r+=1)a[e][r]=e==r?1:0,o[e][r]=t[e][r];for(e=0;e<n;e+=1){if(0==(i=o[e][e])){for(s=e+1;s<n;s+=1)if(0!=o[s][e]){for(r=0;r<n;r++)i=o[e][r],o[e][r]=o[s][r],o[s][r]=i,i=a[e][r],a[e][r]=a[s][r],a[s][r]=i;break}if(0==(i=o[e][e]))return}for(r=0;r<n;r++)o[e][r]=o[e][r]/i,a[e][r]=a[e][r]/i;for(s=0;s<n;s++)if(s!=e)for(i=o[s][e],r=0;r<n;r++)o[s][r]-=i*o[e][r],a[s][r]-=i*a[e][r]}return a}(this.arr);return new ds(this.rows,this.cols,t.flat(1))}static zeros(t,e){let s=new ds(t,e);for(let n=0;n<t;n++)for(var r=0;r<e;r++)s.arr[n][r]=0;return s}static ones(t,e){let s=new ds(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=1;return s}static nums(t,e,s){let r=new ds(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)r.arr[n][t]=s;return r}static get rand(){return{int:(t,e,s,r)=>{let n=new ds(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=nt.randInt(s,r);return n},bin:(t,e)=>{let s=new ds(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=nt.randBin;return s},hex:(t,e)=>{let s=new ds(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=nt.randHex;return s},choices:(t,e,s,r)=>{let n=new ds(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=nt.choice(s,r);return n},permutation:(t,e,s)=>{}}}static rands(t,e,s=1,r){let n=new ds(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=nt.rand(s,r);return n}map(t,e,s,r){return tt.map(this,t,e,s,r)}lerp(t,e){return tt.lerp(this,t,e)}norm(t,e){return tt.norm(this,t,e)}clamp(t,e){return tt.clamp(this,t,e)}static map(t,e,s,r,n){return tt.map(t,e,s,r,n)}static lerp(t,e,s){return tt.lerp(t,e,s)}static norm(t,e,s){return tt.norm(t,e,s)}static clamp(t,e,s){return tt.clamp(gs,e,s)}toPrecision(t){for(let e=0;e<this.cols;e++)for(let s=0;s<this.rows;s++)this.arr[e][s]=+this.arr[e][s].toPrecision(t);return this}get toBin(){let t=this.arr.flat(1).toBin;return new ds(this.rows,this.cols,t)}get toOct(){let t=this.arr.flat(1).toOct;return new ds(this.rows,this.cols,t)}get toHex(){let t=this.arr.flat(1).toHex;return new ds(this.rows,this.cols,t)}max2min(){let t=this.arr.flat(1).max2min;return new ds(this.rows,this.cols,t)}min2max(){let t=this.arr.flat(1).min2max;return new ds(this.rows,this.cols,t)}sortRows(t=void 0){let e=this.arr.map((e=>e.sort(t))).flat(1);return new ds(this.rows,this.cols,e)}sortCols(t=void 0){let e=this.T.arr.map((e=>e.sort(t))).flat(1);return new ds(this.rows,this.cols,e).T}filterByRows(t){var e=this.arr.map((e=>e.map((e=>+(""+e).includes(t))))).map((t=>!!Logic.or(...t))),s=this.arr.filter(((t,s)=>!0===e[s]));return 0===s.length&&s.push([]),console.log(s),new ds(s)}filterByCols(t){return new ds(this.T.arr.filter((e=>e.includes(t))))}sortAll(t=void 0){let e=this.arr.flat(1).sort(t);return new ds(this.rows,this.cols,e)}count(t){return this.arr.flat(1).count(t)}toBase(t){let e=this.arr.flat(1).toBase(t);return new ds(this.rows,this.cols,e)}#r(t){if(this.rows!==t.rows)return;let e=this.arr;for(let s=0;s<this.rows;s++)for(let r=this.cols;r<this.cols+t.cols;r++)e[s][r]=t.arr[s][r-this.cols];return this.cols+=t.cols,new ds(this.rows,this.cols,e.flat(1))}hstack(...t){const e=[this,...t].reduce(((t,e)=>t.#r(e)));return Object.assign(this,e),this}static hstack(t,...e){return t.clone.hstack(...e)}#n(t){if(this.cols!==t.cols)return;let e=this.arr;for(let s=this.rows;s<this.rows+t.rows;s++){e[s]=[];for(let r=0;r<this.cols;r++)e[s][r]=t.arr[s-this.rows][r]}return this.rows+=t.rows,new ds(this.rows,this.cols,e.flat(1))}vstack(...t){const e=[this,...t].reduce(((t,e)=>t.#n(e)));return Object.assign(this,e),this}static vstack(t,...e){return t.clone.vstack(...e)}hqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#r(e)));return Object.assign(this,e),this}vqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#n(e)));return Object.assign(this,e),this}static hqueue(t,...e){return t.clone.hqueue(...e)}static vqueue(t,...e){return t.clone.vqueue(...e)}slice(t=0,e=0,s=this.rows-1,r=this.cols-1){let n=s-t,i=r-e,a=new Array(i);for(let s=0;s<n;s++){a[s]=[];for(let r=0;r<i;r++)a[s][r]=this.arr[s+t][r+e]}return new ds(n,i,a.flat(1))}static slice(t,e=0,s=0,r=this.rows-1,n=this.cols-1){return t.slice(e,s,r,n)}splice(t,e,s,...r){}getRows(t,e=t+1){return this.slice(t,0,e,this.cols)}getCols(t,e=t+1){return this.slice(0,t,this.rows,e)}static getRows(t,e,s=e+1){return t.slice(e,0,s,t.cols)}static getCols(t,e,s=e+1){return t.slice(0,e,t.rows,s)}add(...t){for(let s=0;s<t.length;s++){("number"==typeof t[s]||t[s]instanceof bs)&&(t[s]=ds.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=tt.add(this.arr[r][e],t[s].arr[r][e])}return new ds(this.rows,this.cols,this.arr.flat(1))}sub(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=ds.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=tt.sub(this.arr[r][e],t[s].arr[r][e])}return new ds(this.rows,this.cols,this.arr.flat(1))}static add(t,...e){return t.clone.add(...e)}static sub(t,...e){return t.clone.sub(...e)}mul(...t){for(let r=0;r<t.length;r++){"number"==typeof t[r]&&(t[r]=ds.nums(this.rows,this.cols,t[r]));for(var e=0;e<this.rows;e++)for(var s=0;s<this.cols;s++)this.arr[e][s]=tt.mul(this.arr[e][s],t[r].arr[e][s])}return new ds(this.rows,this.cols,this.arr.flat(1))}div(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=ds.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=tt.div(this.arr[r][e],t[s].arr[r][e])}return new ds(this.rows,this.cols,this.arr.flat(1))}static div(t,...e){return t.clone.div(...e)}static mul(t,...e){return t.clone.mul(...e)}modulo(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=ds.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=tt.modulo(this.arr[r][e],t[s].arr[r][e])}return new ds(this.rows,this.cols,this.arr.flat(1))}static modulo(t,...e){return t.clone.modulo(...e)}dot(t){for(var e=[],s=0;s<this.arr.length;s++){e[s]=[];for(var r=0;r<t.arr[0].length;r++){e[s][r]=0;for(var n=0;n<this.arr[0].length;n++)e[s][r]=tt.add(e[s][r],tt.mul(this.arr[s][n],t.arr[n][r]))}}return new ds(this.arr.length,t.arr[0].length,e.flat(1))}static dot(t,e){return t.dot(e)}pow(t){let e=this.clone,s=this.clone;for(let r=0;r<t-1;r++)s=s.dot(e);return s}static pow(t,e){return t.clone.pow(e)}get somme(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t+=this.arr[e][s];return t}get DoesItContainComplexNumbers(){return this.arr.flat(1/0).some((t=>t instanceof bs))}get min(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(W(...this.arr[e]));return W(...t)}get max(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(V(...this.arr[e]));return V(...t)}get minRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(W(...this.arr[e]));return t}get maxRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(V(...this.arr[e]));return t}get minCols(){return this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable"),this.T.minRows}get maxCols(){return this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable"),this.T.maxRows}static fromVector(t){return new ds(t.length,1,t)}get toArray(){let t=[];for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t.push(this.arr[e][s]);return t}get print(){let t="[";for(let e=0;e<this.arr.length;e++)t+=(0!=e?" ":"")+` [${this.arr[e].map((t=>" "+t.toString()+" "))}],\n`;console.log(t.substring(0,t.length-2)+" ]"),document.write(t.substring(0,t.length-2)+" ]")}get table(){console.table(this.arr)}get serialize(){return JSON.stringify(this)}static deserialize(t){"string"==typeof t&&(t=JSON.parse(t));let e=new ds(t.rows,t.cols);return e.arr=t.arr,e}toTable(){var t=new DocumentFragment,e=new Array(this.rows).fill(null).map((()=>document?.createElement("tr"))),s=this.arr.map((t=>t.map((()=>document?.createElement("td")))));for(let t=0;t<s.length;t++)for(let r=0;r<s[0].length;r++)s[t][r].innerHTML=this.arr[t][r],e[t].appendChild(s[t][r]);return e.map((e=>t.appendChild(e))),t}toGrid(t,e={}){let s=Grid();return s.append(...this.map(t).arr.flat(1).map((t=>t.style(e)))),s.Columns(this.cols),s}sortTable(t=0,{type:e="num",order:s="asc"}={}){var r=this.T.arr.map((t=>t.map(((t,e)=>Object.assign({},{x:t,y:e}))))),n=this.T.arr.map((t=>t.map(((t,e)=>Object.assign({},{x:t,y:e})))));"num"===e?"asc"===s?r[t].sort(((t,e)=>t.x-e.x)):"desc"===s?r[t].sort(((t,e)=>e.x-t.x)):"toggle"===s&&(r[t][0].x>r[t][1].x?r[t].sort(((t,e)=>e.x-t.x)):r[t].sort(((t,e)=>t.x-e.x))):"alpha"===e&&("asc"===s?r[t].sort(((t,e)=>(""+t.x).localeCompare(""+e.x))):"desc"===s&&r[t].sort(((t,e)=>(""+e.x).localeCompare(""+t.x)))),s=r[t].map((t=>t.y));for(let e=0;e<r.length;e++)e!==t&&r[e].map(((t,e)=>t.y=s[e]));for(let e=0;e<r.length;e++)e!==t&&n[e].map(((t,n)=>t.x=r[e][s[n]].x));n[t]=r[t];var i=n.map((t=>t.map((t=>t.x))));return new ds(i).T}}const gs=(t,e,s)=>new ds(t,e,s);class bs extends y{constructor(t=0,e=0){super(),t instanceof bs?(this.a=t.a,this.b=t.b):"object"==typeof t?"a"in e&&"b"in t?(this.a=t.a,this.b=t.b):"a"in e&&"z"in t?(this.a=t.a,this.b=vs(t.z**2-t.a**2)):"a"in e&&"phi"in t?(this.a=t.a,this.b=t.a*Os(t.phi)):"b"in e&&"z"in t?(this.b=t.b,this.a=vs(t.z**2-t.b**2)):"b"in e&&"phi"in t?(this.b=e,this.a=t.b/Os(t.phi)):"z"in e&&"phi"in t&&(this.a=t.z*Ts(t.phi),this.a=t.z*As(t.phi)):"number"==typeof t&&"number"==typeof e&&(this.a=+t.toFixed(32),this.b=+e.toFixed(32))}isComplex(){return!0}toString(){let t="";return t=0!==this.a?this.b>=0?`${this.a}+${this.b}*i`:`${this.a}-${Math.abs(this.b)}*i`:this.b>=0?`${this.b}*i`:`-${Math.abs(this.b)}*i`,t}get clone(){return new bs(this.a,this.b)}get z(){return Ds(this.a,this.b)}get phi(){return Is(this.b,this.a)}static Zero(){return new bs(0,0)}get conj(){return new bs(this.a,-this.b)}get inv(){return new bs(this.a/(_s(this.a,2)+_s(this.b,2)),-this.b/(_s(this.a,2)+_s(this.b,2)))}add(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new bs(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a+=+U(...e).toFixed(15),this.b+=+U(...s).toFixed(15),this}sub(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new bs(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a-=+U(...e).toFixed(15),this.b-=+U(...s).toFixed(15),this}mul(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new bs(t[e],0));let e=+q(this.z,...t.map((t=>t.z))).toFixed(15),s=+U(this.phi,...t.map((t=>t.phi))).toFixed(15);return this.a=+(e*Ts(s).toFixed(15)).toFixed(14),this.b=+(e*As(s).toFixed(15)).toFixed(14),this}div(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new bs(t[e],0));let e=+(this.z/q(...t.map((t=>t.z)))).toFixed(15),s=+(this.phi-U(...t.map((t=>t.phi)))).toFixed(15);return this.a=+(e*Ts(s).toFixed(15)).toFixed(15),this.b=+(e*As(s).toFixed(15)).toFixed(15),this}pow(t){if(js(t)===t&&t>0){let e=+(this.z**t).toFixed(15),s=+(this.phi*t).toFixed(15);this.a=+(e*Ts(s).toFixed(15)).toFixed(15),this.b=+(e*As(s).toFixed(15)).toFixed(15)}return this}static fromExpo(t,e){return new bs(+(t*Ts(e)).toFixed(13),+(t*As(e)).toFixed(13))}get expo(){return[this.z,this.phi]}static add(t,...e){return t.clone.add(...e)}static sub(t,...e){return t.clone.sub(...e)}static mul(t,...e){return t.clone.mul(...e)}static div(t,...e){return t.clone.div(...e)}static pow(t,e){return t.clone.pow(e)}static xpowZ(t){return ws(t**this.a*Ts(this.b*ks(t)),t**this.a*As(this.b*ks(t)))}sqrtn(t=2){return ws(xs(this.z,t)*Ts(this.phi/t),xs(this.z,t)*As(this.phi/t))}get sqrt(){return this.sqrtn(2)}get log(){return ws(this.z,this.phi)}get cos(){return ws(Ts(this.a)*Ss(this.b),As(this.a)*Cs(this.b))}get sin(){return ws(As(this.a)*Ss(this.b),Ts(this.a)*Cs(this.b))}get tan(){const t=Ts(2*this.a)+Ss(2*this.b);return ws(As(2*this.a)/t,Cs(2*this.b)/t)}printInConsole(){let t=this.a+" + "+this.b+" * i";return console.log(t),t}print(){}UI(){return"<span>"+this.a+" + i * "+this.b+"</span>"}}const ws=(t,e)=>{if((t instanceof Array||ArrayBuffer.isView(t))&&(e instanceof Array||ArrayBuffer.isView(t)))return t.map(((s,r)=>ws(t[r],e[r])));if(t instanceof ds&&e instanceof ds){if(t.shape[0]!==e.shape[0]||t.shape[1]!==e.shape[1])return Error(0);const s=t.arr.map(((s,r)=>ws(t.arr[r],e.arr[r])));return new ds(t.rows,t.cols,...s)}return new bs(t,e)},ys=(...t)=>v(Math.abs,...t),vs=(...t)=>v(Math.sqrt,...t),_s=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,e):e instanceof bs?bs.fromExpo(t**e.a,e.b*ks(t)):v((e=>_s(t,e)),...e);if(t instanceof bs)return"number"==typeof e?bs.fromExpo(t.z**e,t.phi*e):e instanceof bs?bs.fromExpo(t.z**e.a*Es(-t.phi*e.b),ks(t.z)*e.b+e.a*t.phi):v((e=>_s(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return v((t=>_s(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(v((e=>_s(t[r],e)),...e));return s}}},xs=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,1/e):v((e=>xs(t,e)),...e);if(t instanceof bs)return"number"==typeof e?bs.fromExpo(xs(t.z,e),t.phi/e):v((e=>xs(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return v((t=>xs(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(v((e=>xs(t[r],e)),...e));return s}}},Es=(...t)=>v(Math.exp,...t),ks=(...t)=>v(Math.log,...t),Ts=(...t)=>v(w.cos,...t),As=(...t)=>v(w.sin,...t),Os=(...t)=>v(w.tan,...t),Ss=(...t)=>v(w.cosh,...t),Cs=(...t)=>v(w.sinh,...t),js=(...t)=>v(Math.floor,...t),Is=(t,e,s=!0)=>{if("number"==typeof t)return"number"==typeof e?s?Math.atan2(t,e):180*Math.atan2(t,e)/Math.PI:v((e=>Is(t,e,s)),...e);if(t instanceof Array){if("number"==typeof e)return v((t=>Is(t,e,s)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(v((e=>_s(t[r],e)),...e));return s}}},Ms=(...t)=>v(Math.sign,...t),Ds=(...t)=>t.every((t=>"number"==typeof t))?Math.hypot(...t):t.every((t=>t instanceof Array))?v(Math.hypot,...t):void 0,{PI:Ps,sqrt:Rs,cos:Ls,sin:$s,acos:Ns,pow:Bs}=Math,Fs=t=>t,Hs=(t,e=7.5625,s=2.75)=>t<1/s?e*t*t:t<2/s?e*(t-=1.5/s)*t+.75:t<2.5/s?e*(t-=2.25/s)*t+.9375:e*(t-=2.625/s)*t+.984375;class zs{constructor(t,{ease:e=Fs,step:s=50,t0:r=0,start:n=!0,duration:i=3e3}={}){this.callback=t,this.state={isRunning:!1,animationId:null,startTime:null,ease:e,step:s,autoStart:n,duration:i},this.t=0,this.tx=0,this.ty=0,this.i=0,this.state.autoStart&&this.start()}#i=()=>{this.t+=this.state.step,this.i++,this.tx=L(this.t,0,this.state.duration,0,1),this.ty=this.state.ease(this.tx),this.callback(this),this.t>=this.state.duration&&(clearInterval(this.state.animationId),this.state.isRunning=!1)};#a(t=!0){return this.state.isRunning||(t&&this.reset(!1),this.state.isRunning=!0,this.state.startTime=Date.now(),this.state.animationId=setInterval(this.#i,this.state.step)),this}start(){return this.#a(!0)}pause(){return this.state.isRunning&&(clearInterval(this.state.animationId),this.state.isRunning=!1),this}resume(){return this.#a(!1)}stop(){return this.pause(),this.reset(!1),this}reset(t=!0){return this.t=0,this.tx=0,this.ty=0,this.i=0,t&&this.start(),this}}class Zs{constructor(t,e,s=1/0,r){this.ms=e,this.fn=t,this.count=s,this.frame=1,this.id=null,this.running=!1,r&&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 Us extends Zs{constructor(t=1e3/60){super(t,(()=>this._tick())),this.elapsed=0,this._lastTime=performance.now(),this._callbacks=new Set}_tick(){const t=performance.now(),e=t-this._lastTime;this.elapsed+=e,this._lastTime=t;for(const t of this._callbacks)t({elapsed:this.elapsed,delta:e})}onTick(t){return this._callbacks.add(t),()=>this._callbacks.delete(t)}reset(){this.elapsed=0,this._lastTime=performance.now()}pause(){super.stop()}resume(){this._lastTime=performance.now(),super.start()}}class qs{constructor(t=[],{repeat:e=1,loop:s=!1}={}){this.tasks=t,this.repeat=e,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 t=this.repeat;do{for(const t of this.tasks){if(this.stopped)return;if(Array.isArray(t))await Promise.all(t.map((({fn:t,delay:e=0})=>new Promise((async s=>{e>0&&await new Promise((t=>setTimeout(t,e))),this.onTask&&this.onTask(t),await t(),s()})))));else{const{fn:e,delay:s=0}=t;s>0&&await new Promise((t=>setTimeout(t,s))),this.onTask&&this.onTask(e),await e()}}}while(this.loop&&!this.stopped&&(t===1/0||t-- >1));!this.stopped&&this.onEnd&&this.onEnd(),this.running=!1}stop(){this.stopped=!0,this.running=!1}addTask(t){this.tasks.push(t)}clearTasks(){this.tasks=[]}}class Ws{constructor(t,{step:e=1e3,t0:s=0,t1:r=1/0,autoplay:n=!0}={}){this.callback=t,this.cache={isRunning:!1,id:null,last_tick:null,step:e,t0:s,t1:r,autoplay:n,pauseTime:null,frame:0},n&&(s?this.startAfter(s):this.start(),r!==1/0&&this.stopAfter(r))}get frame(){return this.cache.frame}get elapsed(){return this.cache.elapsed}start(){return this.cache.isRunning||(this.cache.frame=0,this.cache.isRunning=!0,this.cache.last_tick=Date.now(),this.animate()),this}pause(){return this.cache.isRunning&&(clearTimeout(this.cache.id),this.cache.isRunning=!1,this.cache.pauseTime=Date.now()),this}resume(){if(!this.cache.isRunning){if(this.cache.isRunning=!0,this.cache.pauseTime){const t=Date.now()-this.cache.pauseTime;this.cache.last_tick+=t}this.animate()}return this}stop(){return this.pause(),this.cache.frame=0,this}startAfter(t=1e3){return setTimeout((()=>this.start()),t),this}stopAfter(t=1e3){return setTimeout((()=>this.stop()),t),this}animate=()=>{if(this.cache.isRunning){const t=Date.now(),e=t-this.cache.last_tick;e>=this.cache.step&&(this.cache.elapsed=t-(this.cache.t0||0),this.callback(this),this.cache.frame++,this.cache.last_tick=t-e%this.cache.step),this.cache.id=setTimeout(this.animate,0)}}}class Vs{constructor({head:t=null,wrapper:e=null,target:s=null}){this.head=t,this.wrapper=e,this.target=s,this.init()}get isZikoApp(){return!0}init(){this.head&&this.setHead(this.head),this.wrapper&&this.setWrapper(this.wrapper),this.target&&this.setTarget(this.target),this.wrapper&&this.target&&this.wrapper.render(this.target)}setTarget(t){return t instanceof HTMLElement?this.target=t:"string"==typeof t&&(this.target=globalThis?.document?.querySelector(t)),this}setWrapper(t){return t?.isUIElement?this.wrapper=t:"function"==typeof t&&(this.wrapper=t()),this}setHead(t){return this.head=t instanceof qe?t:We(t),this}}function Gs(t){return/:\w+/.test(t)}class Xs extends Vs{constructor({head:t,wrapper:e,target:s,routes:r}){super({head:t,wrapper:e,target:s}),this.routes=new Map([["404",jt("Error 404")],...Object.entries(r)]),this.clear(),globalThis.onpopstate=this.render(location.pathname)}clear(){return[...this.routes].forEach((t=>{!Gs(t[0])&&t[1]?.isUIElement&&t[1].unrender()})),this}render(t){const[e,s]=[...this.routes].find((e=>function(t,e){const s=t.split("/"),r=e.split("/");if(s.length!==r.length)return!1;for(let t=0;t<s.length;t++){const e=s[t],n=r[t];if(!e.startsWith(":")&&e!==n)return!1}return!0}(e[0],t)));let r;if(Gs(e)){const n=function(t,e){const s=t.split("/"),r=e.split("/"),n={};if(s.length!==r.length)return n;for(let t=0;t<s.length;t++){const e=s[t],i=r[t];if(e.startsWith(":"))n[e.slice(1)]=i;else if(e!==i)return{}}return n}(e,t);r=s.call(this,n)}else s?.isUIElement&&s.render(this.wrapper),"function"==typeof s&&(r=s());return r?.isUIElement&&r.render(this.wrapper),r instanceof Promise&&r.then((t=>t.render(this.wrapper))),globalThis.history.pushState({},"",t),this}}const Ys=({head:t,wrapper:e,target:s,routes:r})=>new Xs({head:t,wrapper:e,target:s,routes:r});function Ks(t,e="./src/pages",s=["js","ts"]){"/"===e.at(-1)&&(e=e.slice(0,-1));const r=t.replace(/\\/g,"/").replace(/\[(\w+)\]/g,"$1/:$1").split("/"),n=e.split("/"),i=r.indexOf(n.at(-1));if(-1!==i){const t=r.slice(i+1),e=r.at(-1),n="index.js"===e||"index.ts"===e,a=s.some((t=>e===`.${t}`||e.endsWith(`.${t}`)));if(n)return"/"+(t.length>1?t.slice(0,-1).join("/"):"");if(a)return"/"+t.join("/").replace(/\.(js|ts)$/,"")}return""}class Qs{constructor(t=""){this.channel=new BroadcastChannel(t),this.EVENTS_DATAS_PAIRS=new Map,this.EVENTS_HANDLERS_PAIRS=new Map,this.LAST_RECEIVED_EVENT="",this.UUID="ziko-channel"+nt.string(10),this.SUBSCRIBERS=new Set([this.UUID])}get broadcast(){return this}emit(t,e){return this.EVENTS_DATAS_PAIRS.set(t,e),this.#o(t),this}on(t,e=console.log){return this.EVENTS_HANDLERS_PAIRS.set(t,e),this.#h(),this}#h(){return this.channel.onmessage=t=>{this.LAST_RECEIVED_EVENT=t.data.last_sended_event;const e=t.data.userId;this.SUBSCRIBERS.add(e);const s=t.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT),r=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT);s&&r&&r(s)},this}#o(t){return this.channel.postMessage({EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,last_sended_event:t,userId:this.UUID}),this}close(){return this.channel.close(),this}}const Js=t=>new Qs(t);class tr{#c;constructor(){this.#c=function(t){try{let e=new Function("return "+t.data.fun)()();postMessage({result:e})}catch(t){postMessage({error:t.message})}finally{t.data.close&&self.close()}}.toString(),this.blob=new Blob(["this.onmessage = "+this.#c],{type:"text/javascript"}),this.worker=new Worker(window.URL.createObjectURL(this.blob))}call(t,e,s=!0){return this.worker.postMessage({fun:t.toString(),close:s}),this.worker.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data.result)},this}}class er{constructor(t,{namespace:e="Ziko",register:s,ValidateCssProps:r=!1}={}){this.currentPropsMap=t,this.namespace=e,this.ValidateCssProps=r,this.use(t)}use(t){return this.ValidateCssProps&&function(t){const e=new Set(Object.keys(document.documentElement.style));for(let s in t)if(!e.has(s))throw new Error(`Invalid CSS property: "${s}"`)}(t),this.currentPropsMap=t,this.#s(),this}#s(){const t=globalThis?.document?.documentElement?.style;for(let e in this.currentPropsMap){const s=this.namespace?`--${this.namespace}-${e}`:`--${e}`;t.setProperty(s,this.currentPropsMap[e]),Object.defineProperty(this,e,{value:`var(${s})`,writable:!0,configurable:!0,enumerable:!1})}}}class sr{constructor(t,e,s){this.cache={storage:t,globalKey:e,channel:Js(`Ziko:useStorage-${e}`),oldItemKeys:new Set},this.#e(s),this.#s()}get items(){return JSON.parse(this.cache.storage[this.cache.globalKey]??null)}#s(){for(let t in this.items)Object.assign(this,{[[t]]:this.items[t]})}#e(t){this.cache.channel=Js(`Ziko:useStorage-${this.cache.globalKey}`),this.cache.channel.on("Ziko-Storage-Updated",(()=>this.#s())),t&&(this.cache.storage[this.cache.globalKey]?(Object.keys(this.items).forEach((t=>this.cache.oldItemKeys.add(t))),console.group("Ziko:useStorage"),console.warn(`Storage key '${this.cache.globalKey}' already exists. we will not overwrite it.`),console.info("%cWe'll keep the existing data.","background-color:#2222dd; color:gold;"),console.group("")):this.set(t))}set(t){return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(t)),this.cache.channel.emit("Ziko-Storage-Updated",{}),Object.keys(t).forEach((t=>this.cache.oldItemKeys.add(t))),this.#s(),this}add(t){const e={...this.items,...t};return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(e)),this.#s(),this}remove(...t){const e={...this.items};for(let s=0;s<t.length;s++)delete e[t[s]],delete this[t[s]];return this.set(e),this}get(t){return this.items[t]}clear(){return this.cache.storage.removeItem(this.cache.globalKey),this.#s(),this}}let{sqrt:rr,cos:nr,sin:ir,exp:ar,log:or,cosh:hr,sinh:cr}=Math;for(const t of Object.getOwnPropertyNames(Math)){const e=Math[t];"function"==typeof e&&(Math[t]=new Proxy(e,{apply(e,s,r){const n=r[0];if("number"==typeof n||0===r.length)return e.apply(s,r);if(n?.isComplex?.()){const{a:t,b:i,z:a,phi:o}=n,h=(t,e)=>new n.constructor(t,e);switch(e.name){case"abs":return n.z;case"sqrt":return h(rr(a)*nr(o/2),rr(a)*ir(o/2));case"log":return h(or(a),o);case"exp":return h(ar(t)*nr(i),ar(t)*ir(i));case"cos":return h(nr(t)*hr(i),-ir(t)*cr(i));case"sin":return h(ir(t)*hr(i),nr(t)*cr(i));case"tan":{const e=nr(2*t)+hr(2*i);return h(ir(2*t)/e,cr(2*i)/e)}case"cosh":return h(hr(t)*nr(i),cr(t)*ir(i));case"sinh":return h(cr(t)*nr(i),hr(t)*ir(i));case"tanh":{const e=hr(2*t)+nr(2*i);return h(cr(2*t)/e,ir(2*i)/e)}default:return e.apply(s,r)}}throw new TypeError(`Math.${t} expects only numbers`)}}))}globalThis?.document&&document?.addEventListener("DOMContentLoaded",__Ziko__.__Config__.init()),t.App=({head:t,wrapper:e,target:s})=>new Vs({head:t,wrapper:e,target:s}),t.Arc=t=>1-$s(Ns(t)),t.Back=(t,e=1)=>t**2*((e+1)*t-e),t.Base=et,t.Clock=Us,t.Combinaison=rt,t.Complex=bs,t.Discret=(t,e=5)=>Math.ceil(t*e)/e,t.E=s,t.EPSILON=r,t.Elastic=t=>-2*Bs(2,10*(t-1))*Ls(20*Ps*t/3*t),t.FileBasedRouting=async function(t){const e=Object.keys(t),s=function(t){if(0===t.length)return"";const e=t.map((t=>t.split("/"))),s=Math.min(...e.map((t=>t.length)));let r=[];for(let t=0;t<s;t++){const s=e[0][t];if(!e.every((e=>e[t]===s||e[t].startsWith("["))))break;r.push(s)}return r.join("/")+(r.length?"/":"")}(e),r={};for(let n=0;n<e.length;n++){const i=await t[e[n]](),a=await i.default;Object.assign(r,{[Ks(e[n],s)]:a})}return Ys({target:document.body,routes:{"/":()=>{},...r},wrapper:Ke.section()})},t.Flex=(...t)=>{let e="div";return"string"==typeof t[0]&&(e=t[0],t.pop()),new Qe(e).append(...t)},t.HTMLWrapper=t=>new is(t),t.InBack=(t,e=1.70158,s=e+1)=>s*Bs(t,3)-e*t**2,t.InBounce=(t,e=7.5625,s=2.75)=>1-Hs(1-t,e,s),t.InCirc=t=>1-Rs(1-t**2),t.InCubic=t=>t**3,t.InElastic=(t,e=2*Ps/3)=>0===t?0:1===t?1:-Bs(2,10*t-10)*$s((10*t-10.75)*e),t.InExpo=t=>0===t?0:2**(10*t-10),t.InOutBack=(t,e=1.70158,s=1.525*e)=>t<.5?Bs(2*t,2)*(2*(s+1)*t-s)/2:(Bs(2*t-2,2)*((s+1)*(2*t-2)+s)+2)/2,t.InOutBounce=(t,e=7.5625,s=2.75)=>t<.5?Hs(1-2*t,e,s)/2:Hs(2*t-1,e,s)/2,t.InOutCirc=t=>t<.5?(1-Rs(1-(2*t)**2))/2:(Rs(1-(-2*t+2)**2)+1)/2,t.InOutCubic=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,t.InOutElastic=(t,e=2*Ps/4.5)=>0===t?0:1===t?1:t<.5?-Bs(2,20*t-10)*$s((20*t-11.125)*e)/2:Bs(2,-20*t+10)*$s((20*t-11.125)*e)/2+1,t.InOutExpo=t=>0===t?0:1===t?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,t.InOutQuad=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,t.InOutQuart=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,t.InOutQuint=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,t.InOutSin=t=>-(Ls(Ps*t)-1)/2,t.InQuad=t=>t**2,t.InQuart=t=>t**4,t.InQuint=t=>t**5,t.InSin=t=>1-Ls(t*Ps/2),t.Linear=Fs,t.Logic=st,t.Matrix=ds,t.OutBack=(t,e=1.70158,s=e+1)=>1+s*Bs(t-1,3)+e*Bs(t-1,2),t.OutBounce=Hs,t.OutCirc=t=>Rs(1-(t-1)**2),t.OutCubic=t=>1-(1-t)**3,t.OutElastic=(t,e=2*Ps/3)=>0===t?0:1===t?1:Bs(2,-10*t)*$s((10*t-.75)*e)+1,t.OutExpo=t=>1===t?1:1-2**(-10*t),t.OutQuad=t=>1-(1-t)**2,t.OutQuart=t=>1-(1-t)**4,t.OutQuint=t=>1-(1-t)**5,t.OutSin=t=>$s(t*Ps/2),t.PI=e,t.Permutation=class{static withDiscount(t,e=t.length){if(1===e)return t.map((t=>[t]));const s=[];let r;return r=this.withDiscount(t,e-1),t.forEach((t=>{r.forEach((e=>{s.push([t].concat(e))}))})),s}static withoutDiscount(t){if(1===t.length)return t.map((t=>[t]));const e=[],s=this.withoutDiscount(t.slice(1)),r=t[0];for(let t=0;t<s.length;t++){const n=s[t];for(let t=0;t<=n.length;t++){const s=n.slice(0,t),i=n.slice(t);e.push(s.concat([r],i))}}return e}},t.Random=nt,t.SPA=Ys,t.SVGWrapper=t=>new as(t),t.Scheduler=(t,{repeat:e=null}={})=>new qs(t,{repeat:e}),t.Step=(t,e=5)=>Math.floor(t*e)/e,t.Suspense=(t,e)=>new ns(t,e),t.Tick=Zs,t.TimeAnimation=zs,t.TimeLoop=Ws,t.TimeScheduler=qs,t.UIElement=Ge,t.UIHTMLWrapper=is,t.UINode=dt,t.UISVGWrapper=as,t.Utils=tt,t.ZikoApp=Vs,t.ZikoCustomEvent=Oe,t.ZikoEventClick=Bt,t.ZikoEventClipboard=zt,t.ZikoEventCustom=qt,t.ZikoEventDrag=Vt,t.ZikoEventFocus=Yt,t.ZikoEventInput=Ee,t.ZikoEventKey=ee,t.ZikoEventMouse=ne,t.ZikoEventPointer=oe,t.ZikoEventSwipe=Ce,t.ZikoEventTouch=le,t.ZikoEventWheel=me,t.ZikoHead=qe,t.ZikoMutationObserver=Ie,t.ZikoSPA=Xs,t.ZikoUIFlex=Qe,t.ZikoUISuspense=ns,t.ZikoUIText=Ct,t.ZikoUseRoot=er,t.__ZikoEvent__=Nt,t.abs=ys,t.accum=G,t.acos=(...t)=>v(w.acos,...t),t.acosh=(...t)=>v(w.acosh,...t),t.acot=(...t)=>v(w.acot,...t),t.add=A,t.animation=(t,{ease:e,t0:s,t1:r,start:n,duration:i}={})=>new zs(t,{ease:e,t0:s,t1:r,start:n,duration:i}),t.arange=N,t.arr2str=ms,t.asin=(...t)=>v(w.asin,...t),t.asinh=(...t)=>v(w.asinh,...t),t.atan=(...t)=>v(w.atan,...t),t.atan2=Is,t.atanh=(...t)=>v(w.atanh,...t),t.bindCustomEvent=(t,e,s)=>new qt(t,e,s),t.bindHashEvent=(t,e)=>new Jt(t,e),t.bindTouchEvent=(t,e)=>new le(t,e),t.bind_click_event=Ht,t.bind_clipboard_event=Ut,t.bind_drag_event=Xt,t.bind_focus_event=Qt,t.bind_key_event=re,t.bind_mouse_event=ae,t.bind_pointer_event=ce,t.bind_wheel_event=fe,t.cartesianProduct=K,t.ceil=(...t)=>v(Math.ceil,...t),t.clamp=$,t.clock=t=>new Us(t),t.combinaison=(t,e,s=!1)=>rt[s?"withDiscount":"withoutDiscount"](t,e),t.complex=ws,t.cos=Ts,t.cosh=Ss,t.cot=(...t)=>v(w.cot,...t),t.coth=(...t)=>v(w.coth,...t),t.csc=(...t)=>v(w.csc,...t),t.csv2arr=at,t.csv2json=(t,e=",")=>JSON.stringify(ot(t,e)),t.csv2matrix=(t,e=",")=>new ds(at(t,e)),t.csv2object=ot,t.csv2sql=(t,e)=>{const s=t.trim().trimEnd().split("\n").filter((t=>t));let r=`INSERT INTO ${e} (${s[0].split(",").join(", ")}) Values `,n=[];for(let t=1;t<s.length;t++){const e=s[t].split(",");n.push(`(${e})`)}return r+n.join(",\n")},t.debounce=(t,e=1e3)=>(...s)=>setTimeout((()=>t(...s)),e),t.defineParamsGetter=function(t){Object.defineProperties(t,{QueryParams:{get:function(){return function(t){const e={};return t.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi,(t=>{const[s,r]=t.split("=");e[s]=r})),e}(globalThis.location.search.substring(1))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}})},t.define_wc=function(t,e,s={},{mode:r="open"}={}){globalThis.customElements?.get(t)?console.warn(`Custom element "${t}" is already defined`):-1!==t.search("-")?globalThis.customElements?.define(t,class extends HTMLElement{static get observedAttributes(){return["style",...Object.keys(s)]}constructor(){super(),this.attachShadow({mode:r}),this.props={},this.mask={...s}}connectedCallback(){this.render()}render(){this.shadowRoot.innerHTML="",this.UIElement=e(this.props).render(this.shadowRoot)}attributeChangedCallback(t,e,s){Object.assign(this.props,{[t]:this.mask[t].type(s)}),this.render()}}):console.warn(`"${t}" is not a valid custom element name`)},t.deg2rad=z,t.div=C,t.e=Es,t.fact=(...t)=>v((t=>{let e,s=1;if(0==t)s=1;else if(t>0)for(e=1;e<=t;e++)s*=e;else s=NaN;return s}),...t),t.floor=js,t.geomspace=H,t.getEvent=Lt,t.hypot=Ds,t.inRange=X,t.isApproximatlyEqual=Y,t.isStateGetter=At,t.json2arr=t=>ht(t instanceof Object?t:JSON.parse(t)),t.json2css=ps,t.json2csv=lt,t.json2csvFile=(t,e)=>{const s=lt(t,e),r=new Blob([s],{type:"text/csv;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2xml=ft,t.json2xmlFile=(t,e)=>{const s=ft(t,e),r=new Blob([s],{type:"text/xml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2yml=pt,t.json2ymlFile=(t,e)=>{const s=pt(t,e),r=new Blob([s],{type:"text/yml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.lerp=R,t.linspace=B,t.ln=ks,t.logspace=F,t.loop=(t,e={})=>new Ws(t,e),t.map=L,t.mapfun=v,t.matrix=gs,t.matrix2=(...t)=>new ds(2,2,t),t.matrix3=(...t)=>new ds(3,3,t),t.matrix4=(...t)=>new ds(4,4,t),t.max=V,t.min=W,t.modulo=j,t.mul=S,t.norm=P,t.nums=D,t.obj2str=ls,t.ones=M,t.pgcd=Q,t.pow=_s,t.powerSet=t=>{const e=[],s=2**t.length;for(let r=0;r<s;r+=1){const s=[];for(let e=0;e<t.length;e+=1)r&1<<e&&s.push(t[e]);e.push(s)}return e},t.ppcm=J,t.preload=it,t.prod=q,t.rad2deg=Z,t.round=(...t)=>v(Math.round,...t),t.sec=(...t)=>v(w.sec,...t),t.sig=(...t)=>v((t=>1/(1+Es(-t))),...t),t.sign=Ms,t.sin=As,t.sinc=(...t)=>v(w.sinc,...t),t.sinh=Cs,t.sleep=t=>new Promise((e=>setTimeout(e,t))),t.sqrt=vs,t.sqrtn=xs,t.step_fps=t=>1e3/t,t.sub=O,t.subSet=null,t.sum=U,t.svg2ascii=hs,t.svg2img=(t,e=!0)=>Ke.img(cs(t)).render(e),t.svg2imgUrl=cs,t.svg2str=os,t.tags=Ke,t.tan=Os,t.tanh=(...t)=>v(w.tanh,...t),t.text=jt,t.throttle=(t,e)=>{let s=0;return(...r)=>{const n=(new Date).getTime();n-s<e||(s=n,t(...r))}},t.tick=(t,e,s=1/0,r=!0)=>new Zs(t,e,s,r),t.timeTaken=t=>{console.time("timeTaken");const e=t();return console.timeEnd("timeTaken"),e},t.time_memory_Taken=t=>{const e=Date.now(),s=performance.memory.usedJSHeapSize,r=t();return{elapsedTime:Date.now()-e,usedMemory:performance.memory.usedJSHeapSize-s,result:r}},t.timeout=function(t,e){let s;const r=new Promise((r=>{s=setTimeout((()=>{e&&e(),r()}),t)}));return{id:s,clear:()=>clearTimeout(s),promise:r}},t.useChannel=Js,t.useCustomEvent=Se,t.useDerived=function(t,e){let s=t(...e.map((t=>t().value)));const r=new Set;return e.forEach((n=>{n()._subscribe((()=>{{const n=t(...e.map((t=>t().value)));n!==s&&(s=n,r.forEach((t=>t(s))))}}))})),()=>({value:s,isStateGetter:()=>!0,_subscribe:t=>r.add(t)})},t.useEventEmitter=Ne,t.useFavIcon=Fe,t.useHashEvent=t=>new Te(t),t.useHead=We,t.useInputEvent=t=>new Ee(t),t.useLocaleStorage=(t,e)=>new sr(localStorage,t,e),t.useMediaQuery=(t,e)=>new Ve(t,e),t.useMeta=ze,t.useReactive=t=>v((t=>{const e=Tt(t);return{get:e[0],set:e[1]}}),t),t.useRoot=(t,{namespace:e,register:s,ValidateCssProps:r}={})=>new er(t,{namespace:e,register:s,ValidateCssProps:r}),t.useSessionStorage=(t,e)=>new sr(sessionStorage,t,e),t.useState=Tt,t.useSuccesifKeys=(t,e=[],s=(()=>{}))=>{t.cache.stream.enabled.down=!0;const r=e.length,n=t.cache.stream.history.down.slice(-r).map((t=>t.key));e.join("")===n.join("")&&(t.event.preventDefault(),s.call(t,t))},t.useSwipeEvent=(t,e,s)=>new Ce(t,e,s),t.useThread=(t,e,s)=>{const r=new tr;return t&&r.call(t,e,s),r},t.useTitle=Ue,t.wait=t=>new Promise((e=>setTimeout(e,t))),t.waitForUIElm=t=>new Promise((e=>{if(t.element)return e(t.element);const s=new MutationObserver((()=>{t.element&&(e(t.element),s.disconnect())}));s.observe(document?.body,{childList:!0,subtree:!0})})),t.waitForUIElmSync=(t,e=2e3)=>{const s=Date.now();for(;Date.now()-s<e;)if(t.element)return t.element},t.watch=(t,e={},s=null)=>{const r=new Ie(t,e);return s&&r.observe(s),r},t.watchAttr=(t,e)=>new Me(t,e),t.watchChildren=(t,e)=>new De(t,e),t.watchIntersection=(t,e,s)=>new Pe(t,e,s),t.watchScreen=t=>new Le(t),t.watchSize=(t,e)=>new Re(t,e),t.zeros=I}));
9
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Ziko={})}(this,(function(t){"use strict";const{PI:e,E:s}=Math,r=Number.EPSILON,{PI:n,cos:i,sin:a,tan:o,acos:h,asin:c,atan:l,cosh:u,sinh:m,tanh:p,acosh:f,asinh:d,atanh:g,log:b}=Math;let w={cos:i,sin:a,tan:o,sinc:t=>a(n*t)/(n*t),sec:t=>1/i(t),csc:t=>1/a(t),cot:t=>1/o(t),acos:h,asin:c,atan:l,acot:t=>n/2-l(t),cosh:u,sinh:m,tanh:p,coth:t=>.5*b((1+t)/(1-t)),acosh:f,asinh:d,atanh:g};w=new Proxy(w,{get(t,e){if(e in t)return s=>+t[e](s).toFixed(15)}});class y{}const v=(t,...e)=>{const s=e.map((e=>{if(null===e)return t(null);if(["number","string","boolean","bigint","undefined"].includes(typeof e))return t(e);if(e instanceof Array)return e.map((e=>v(t,e)));if(ArrayBuffer.isView(e))return e.map((e=>t(e)));if(e instanceof Set)return new Set(v(t,...e));if(e instanceof Map)return new Map([...e].map((e=>[e[0],v(t,e[1])])));if(e instanceof gs)return new gs(e.rows,e.cols,v(e.arr.flat(1)));if(e instanceof ws){const[s,r,n,i]=[e.a,e.b,e.z,e.phi];switch(t){case Math.log:return ys(Ts(n),i);case Math.exp:return ys(ks(s)*Os(r),ks(s)*As(r));case Math.abs:return n;case Math.sqrt:return ys(_s(n)*Os(i/2),_s(n)*As(i/2));case w.cos:return ys(Os(s)*Cs(r),-As(s)*js(r));case w.sin:return ys(As(s)*Cs(r),Os(s)*js(r));case w.tan:{const t=Os(2*s)+Cs(2*r);return ys(As(2*s)/t,js(2*r)/t)}case w.cosh:return ys(Cs(s)*Os(r),js(s)*As(r));case w.sinh:return ys(js(s)*Os(r),Cs(s)*As(r));case w.tanh:{const t=Cs(2*s)+Os(2*r);return ys(js(2*s)/t,As(2*r)/t)}default:return t(e)}}else if(e instanceof Object)return Object.fromEntries(Object.entries(e).map((e=>[e[0],v(t,e[1])])))}));return 1==s.length?s[0]:s},_=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t+e;if(e instanceof ws)return ys(t+e.a,e.b);if(e instanceof gs)return gs.nums(e.rows,e.cols,t).add(e);if(e instanceof Array)return e.map((e=>O(e,t)))}else{if(t instanceof ws||t instanceof gs)return e instanceof Array?e.map((e=>t.clone.add(e))):t.clone.add(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>O(t,e)));if(t.length===e.length)return t.map(((t,s)=>O(t,e[s])))}}},x=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t-e;if(e instanceof ws)return ys(t-e.a,-e.b);if(e instanceof gs)return gs.nums(e.rows,e.cols,t).sub(e);if(e instanceof Array)return e.map((e=>A(e,t)))}else{if(t instanceof ws||t instanceof gs)return e instanceof Array?e.map((e=>t.clone.sub(e))):t.clone.sub(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>A(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>A(t,e[s])))}}},E=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t*e;if(e instanceof ws)return ys(t*e.a,t*e.b);if(e instanceof gs)return gs.nums(e.rows,e.cols,t).mul(e);if(e instanceof Array)return e.map((e=>S(t,e)))}else{if(t instanceof ws||t instanceof gs)return e instanceof Array?e.map((e=>t.clone.mul(e))):t.clone.mul(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>S(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>S(t,e[s])))}}},k=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t/e;if(e instanceof ws)return ys(t/e.a,t/e.b);if(e instanceof gs)return gs.nums(e.rows,e.cols,t).div(e);if(e instanceof Array)return e.map((e=>C(t,e)))}else{if(t instanceof ws||t instanceof gs)return e instanceof Array?e.map((e=>t.clone.div(e))):t.clone.div(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>C(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>C(t,e[s])))}}},T=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t%e;if(e instanceof ws)return ys(t%e.a,t%e.b);if(e instanceof gs)return gs.nums(e.rows,e.cols,t).modulo(e);if(e instanceof Array)return e.map((e=>C(t,e)))}else{if(t instanceof ws||t instanceof gs)return e instanceof Array?e.map((e=>t.clone.div(e))):t.clone.div(e);if(t instanceof Array&&!(e instanceof Array))return t.map((t=>O(t,e)))}},O=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=_(s,e[t]);return s},A=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=x(s,e[t]);return s},S=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=E(s,e[t]);return s},C=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=k(s,e[t]);return s},j=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=T(s,e[t]);return s},I=t=>new Array(t).fill(0),M=t=>new Array(t).fill(1),D=(t,e)=>new Array(e).fill(t),P=(t,e,s)=>{if("number"==typeof t)return e!==s?(t-e)/(s-e):0;if(t instanceof gs)return new gs(t.rows,t.cols,P(t.arr.flat(1),e,s));if(t instanceof ws)return new ws(P(t.a,e,s),P(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>P(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=P(t[s])}}},R=(t,e,s)=>{if("number"==typeof t)return(s-e)*t+e;if(t instanceof gs)return new gs(t.rows,t.cols,R(t.arr.flat(1),e,s));if(t instanceof ws)return new ws(R(t.a,e,s),R(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>R(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=R(t[s])}}},L=(t,e,s,r,n)=>{if("number"==typeof t)return R(P(t,e,s),r,n);if(t instanceof gs)return new gs(t.rows,t.cols,L(t.arr.flat(1),e,s,r,n));if(t instanceof ws)return new ws(L(t.a,s,r,n),L(t.b,e,s,r,n));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>L(t,e,s,r,n)));{let i=new Array(t.length);for(let a=0;a<t.length;a++)i[a]=L(t[a],e,s,r,n)}}},$=(t,e,s)=>{const[r,n]=[W(e,s),V(e,s)];if("number"==typeof t)return W(V(t,r),n);if(t instanceof gs)return new gs(t.rows,t.cols,$(t.arr.flat(1),r,n));if(t instanceof ws)return new ws($(t.a,r,n),$(t.b,r,n));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>$(t,r,n)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=$(t[s],r,n)}}},N=(t,e,s,r=!1)=>{let n=[];if(t<e)for(let i=t;r?i<=e:i<e;i+=s)n.push(10*i/10);else for(let i=t;r?i>=e:i>e;i-=s)n.push(10*i/10);return n},B=(t,e,s=vs(e-t)+1,r=!0)=>{if(Math.floor(s)===s){if([t,e].every((t=>"number"==typeof t))){const[a,o]=[t,e].sort(((t,e)=>e-t));var n=[];let h;h=r?(a-o)/(s-1):(a-o)/s;for(var i=0;i<s;i++)t<e?n.push(o+h*i):n.push(a-h*i);return n}if([t,e].some((t=>t instanceof ws))){const n=ys(t),i=ys(e);s=s||Math.abs(n.a-i.a)+1;const a=B(n.a,i.a,s,r),o=B(n.b,i.b,s,r);let h=new Array(s).fill(null);return h=h.map(((t,e)=>ys(a[e],o[e]))),h}}},F=(t,e,r=e-t+1,n=s,i=!0)=>B(t,e,r,i).map((t=>xs(n,t))),H=(t,e,s=vs(e-t)+1,r=!0)=>{if(Math.floor(s)===s){if([t,e].every((t=>"number"==typeof t))){const[n,i]=[t,e].sort(((t,e)=>e-t));let a;a=Es(n/i,r?s-1:s);const o=[i];for(let t=1;t<s;t++)o.push(o[t-1]*a);return t<e?o:o.reverse()}if([t,e].some((t=>t instanceof ws))){const n=ys(t),i=ys(e);let a;s=s||Math.abs(n.a-i.a)+1,a=Es(i.div(n),r?s-1:s);const o=[n];for(let t=1;t<s;t++)o.push(S(o[t-1],a));return o}}},z=(...t)=>mapfun((t=>t*Math.PI/180),...t),U=(...t)=>mapfun((t=>t/Math.PI*180),...t),Z=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t[0];for(let s=1;s<t.length;s++)e+=t[s];return e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(Z(...t[s])):t[s]instanceof Object&&e.push(Z(...Object.values(t[s])));return 1===e.length?e[0]:e},q=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t[0];for(let s=1;s<t.length;s++)e*=t[s];return e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(q(...t[s])):t[s]instanceof Object&&e.push(q(...Object.values(t[s])));return 1===e.length?e[0]:e},W=(...t)=>{if(t.every((t=>"number"==typeof t)))return Math.min(...t);const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(W(...t[s])):t[s]instanceof Object&&e.push(Object.fromEntries([Object.entries(t[s]).sort(((t,e)=>t[1]-e[1]))[0]]));return 1===e.length?e[0]:e},V=(...t)=>{if(t.every((t=>"number"==typeof t)))return Math.max(...t);const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(W(...t[s])):t[s]instanceof Object&&e.push(Object.fromEntries([Object.entries(t[s]).sort(((t,e)=>e[1]-t[1]))[0]]));return 1===e.length?e[0]:e},G=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t.reduce(((t,e)=>[...t,t[t.length-1]+e]),[0]);return e.shift(),e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(G(...t[s])):t[s]instanceof Object&&e.push(null);return 1===e.length?e[0]:e},K=(t,e,s)=>{const[r,n]=[Math.min(e,s),Math.max(e,s)];return t>=r&&t<=n},X=(t,e,s=1e-4)=>Math.abs(t-e)<=s,Y=(t,e)=>t.reduce(((t,s)=>[...t,...e.map((t=>[s,t]))]),[]),Q=(t,e)=>{let s,r=1;if(t==Is(t)&&e==Is(e)){for(s=2;s<=t&&s<=e;++s)t%s==0&&e%s==0&&(r=s);return r}console.log("error")},J=(t,e)=>{let s;if(t==Is(t)&&e==Is(e)){for(s=t>e?t:e;s%t!=0||s%e!=0;)++s;return s}console.log("error")},tt={add:O,sub:A,mul:S,div:C,modulo:j,zeros:I,ones:M,nums:D,norm:P,lerp:R,map:L,clamp:$,arange:N,linspace:B,logspace:F,geomspace:H,sum:Z,prod:q,accum:G,cartesianProduct:Y,ppcm:J,pgcd:Q,deg2rad:z,rad2deg:U,inRange:K,isApproximatlyEqual:X},et={_mode:Number,_map:function(t,e,s){return e instanceof gs?new gs(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof ws?new ws(t(e.a,s),t(e.b,s)):e instanceof Array?e.map((e=>t(e,s))):void 0},dec2base(t,e){return this._mode=e<=10?Number:String,"number"==typeof t?this._mode((t>>>0).toString(e)):this._map(this.dec2base,t,e)},dec2bin(t){return this.dec2base(t,2)},dec2oct(t){return this.dec2base(t,8)},dec2hex(t){return this.dec2base(t,16)},bin2base(t,e){return this.dec2base(this.bin2dec(t),e)},bin2dec(t){return this._mode("0b"+t)},bin2oct(t){return this.bin2base(t,8)},bin2hex(t){return this.bin2base(t,16)},oct2dec(t){return this._mode("0o"+t)},oct2bin(t){return this.dec2bin(this.oct2dec(t))},oct2hex(t){return this.dec2hex(this.oct2dec(t))},oct2base(t,e){return this.dec2base(this.oct2dec(t),e)},hex2dec(t){return this._mode("0x"+t)},hex2bin(t){return this.dec2bin(this.hex2dec(t))},hex2oct(t){return this.dec2oct(this.hex2dec(t))},hex2base(t,e){return this.dec2base(this.hex2dec(t),e)},IEEE32toDec(t){let e=t.split(" ").join("").padEnd(32,"0"),s=e[0],r=2**(+("0b"+e.slice(1,9))-127);return(-1)**s*(1+e.slice(9,32).split("").map((t=>+t)).map(((t,e)=>t*2**(-e-1))).reduce(((t,e)=>t+e),0))*r},IEEE64toDec(t){let e=t.split(" ").join("").padEnd(64,"0"),s=e[0],r=2**(+("0b"+e.slice(1,12))-1023);return(-1)**s*(1+e.slice(13,64).split("").map((t=>+t)).map(((t,e)=>t*2**(-e-1))).reduce(((t,e)=>t+e),0))*r}},st={_mode:Number,_map:function(t,e,s){return e instanceof gs?new gs(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof ws?new ws(t(e.a,s),t(e.b,s)):e instanceof Array?e.map((e=>t(e,s))):void 0},not:function(t){return["number","boolean"].includes(typeof t)?st._mode(!t):this._map(this.not,t)},and:function(t,...e){return["number","boolean"].includes(typeof t)?st._mode(e.reduce(((t,e)=>t&e),t)):this._map(this.and,t,e)},or:function(t,...e){return["number","boolean"].includes(typeof t)?st._mode(e.reduce(((t,e)=>t|e),t)):this._map(this.or,t,e)},nand:function(t,...e){return this.not(this.and(t,e))},nor:function(t,...e){return this.not(this.or(t,e))},xor:function(t,...e){let s=[t,...e];return["number","boolean"].includes(typeof t)?this._mode(1===s.reduce(((t,e)=>(1==+e&&(t+=1),t)),0)):this._map(this.xor,t,e)},xnor:function(t,...e){return st.not(st.xor(t,e))}};class rt{static withDiscount(t,e){if(1===e)return t.map((t=>[t]));const s=[];return t.forEach(((r,n)=>{this.withDiscount(t.slice(n),e-1).forEach((t=>{s.push([r].concat(t))}))})),s}static withoutDiscount(t,e){if(1===e)return t.map((t=>[t]));const s=[];return t.forEach(((r,n)=>{this.withoutDiscount(t.slice(n+1),e-1).forEach((t=>{s.push([r].concat(t))}))})),s}}class nt{static float(t=1,e){return e?Math.random()*(e-t)+t:t*Math.random()}static int(t,e){return Math.floor(this.float(t,e))}static char(t){t=t??this.bool();const e=String.fromCharCode(this.int(97,120));return t?e.toUpperCase():e}static bool(){return[!1,!0][Math.floor(2*Math.random())]}static string(t,e){return t instanceof Array?new Array(this.int(...t)).fill(0).map((()=>this.char(e))).join(""):new Array(t).fill(0).map((()=>this.char(e))).join("")}static bin(){return this.int(2)}static oct(){return this.int(8)}static dec(){return this.int(8)}static hex(){return this.int(16)}static choice(t=[1,2,3],e=new Array(t.length).fill(1/t.length)){let s=new Array(100);e=tt.accum(...e).map((t=>100*t)),s.fill(t[0],0,e[0]);for(let r=1;r<t.length;r++)s.fill(t[r],e[r-1],e[r]);return s[this.int(s.length-1)]}static shuffleArr(t){return t.sort((()=>.5-Math.random()))}static shuffleMatrix(t){const{rows:e,cols:s,arr:r}=t;return bs(e,s,r.flat().sort((()=>.5-Math.random())))}static floats(t,e,s){return new Array(t).fill(0).map((()=>this.float(e,s)))}static ints(t,e,s){return new Array(t).fill(0).map((()=>this.int(e,s)))}static bools(t){return new Array(t).fill(0).map((()=>this.bool()))}static bins(t){return new Array(t).fill(0).map((()=>this.int(2)))}static octs(t){return new Array(t).fill(0).map((()=>this.int(8)))}static decs(t){return new Array(t).fill(0).map((()=>this.int(10)))}static hexs(t){return new Array(t).fill(0).map((()=>this.int(16)))}static choices(t,e,s){return new Array(t).fill(0).map((()=>this.choice(e,s)))}static perm(...t){return t.permS[this.int(t.length)]}static color(){return"#"+et.dec2hex(this.float(16777216)).padStart(6,0)}static colors(t){return new Array(t).fill(null).map((()=>this.color()))}static complex(t=[0,1],e=[0,1]){return t instanceof Array?new ws(this.float(t[0],t[1]),this.float(e[0],e[1])):new ws(...this.floats(2,t,e))}static complexInt(t=[0,1],e=[0,1]){return new ws(this.int(t[0],t[1]),this.int(e[0],e[1]))}static complexBin(){return new ws(...this.bins(2))}static complexOct(){return new ws(...this.octs(2))}static complexDec(){return new ws(...this.decs(10))}static complexHex(){return new ws(...this.octs(2))}static complexes(t,e=0,s=1){return new Array(t).fill(0).map((()=>this.complex(e,s)))}static complexesInt(t,e=0,s=1){return new Array(t).fill(0).map((()=>this.complexInt(e,s)))}static complexesBin(t){return new Array(t).fill(0).map((()=>this.complexBin()))}static complexesOct(t){return new Array(t).fill(0).map((()=>this.complexOct()))}static complexesDec(t){return new Array(t).fill(0).map((()=>this.complexDec()))}static complexesHex(t){return new Array(t).fill(0).map((()=>this.complexHex()))}static matrix(t,e,s,r){return bs(t,e,this.floats(t*e,s,r))}static matrixInt(t,e,s,r){return bs(t,e,this.ints(t*e,s,r))}static matrixBin(t,e){return bs(t,e,this.bins(t*e))}static matrixOct(t,e){return bs(t,e,this.octs(t*e))}static matrixDec(t,e){return bs(t,e,this.decs(t*e))}static matrixHex(t,e){return bs(t,e,this.hex(t*e))}static matrixColor(t,e){return bs(t,e,this.colors(t*e))}static matrixComplex(t,e,s,r){return bs(t,e,this.complexes(t*e,s,r))}static matrixComplexInt(t,e,s,r){return bs(t,e,this.complexesInt(t*e,s,r))}static matrixComplexBin(t,e){return bs(t,e,this.complexesBin(t*e))}static matrixComplexOct(t,e){return bs(t,e,this.complexesBin(t*e))}static matrixComplexDec(t,e){return bs(t,e,this.complexesBin(t*e))}static matrixComplexHex(t,e){return bs(t,e,this.complexesBin(t*e))}}const it=t=>{const e=new XMLHttpRequest;if(e.open("GET",t,!1),e.send(),200===e.status)return e.responseText;throw new Error(`Failed to fetch data from ${t}. Status: ${e.status}`)};globalThis.fetchdom=async function(t="https://github.com/zakarialaoui10"){const e=await fetch(t),s=await e.text();return(new DOMParser).parseFromString(s,"text/xml").documentElement},globalThis.fetchdomSync=function(t="https://github.com/zakarialaoui10"){const e=it(t);return(new DOMParser).parseFromString(e,"text/xml").documentElement};const at=(t,e=",")=>t.trim().trimEnd().split("\n").map((t=>t.split(e))),ot=(t,e=",")=>{const[s,...r]=at(t,e);return r.map((t=>{const e={};return s.forEach(((s,r)=>{e[s]=t[r]})),e}))},ht=t=>t instanceof Array?[Object.keys(t[0]),...t.map((t=>Object.values(t)))]:[Object.keys(t)],ct=(t,e)=>ht(t).map((t=>t.join(e))).join("\n"),lt=(t,e=",")=>ct(t instanceof Object?t:JSON.parse(t),e),ut=(t,e)=>{const s=[];if(Array.isArray(t))t.forEach((t=>{if("object"==typeof t&&null!==t){s.push(`${e}-`);const r=ut(t,`${e} `);s.push(...r)}else s.push(`${e}- ${t}`)}));else for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];if("object"==typeof n&&null!==n){s.push(`${e}${r}:`);const t=ut(n,`${e} `);s.push(...t)}else s.push(`${e}${r}: ${n}`)}return s},mt=(t,e="")=>ut(t,e).join("\n"),pt=(t,e)=>mt(t instanceof Object?t:JSON.parse(t),e),ft=(t,e=1)=>{let s="";for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];s+="\n"+" ".repeat(e)+`<${r}>`,s+="object"==typeof n?ft(n,e+2):`${n}`,s+=`</${r}>`}return s.trim()};class dt{constructor(t){this.cache={node:t}}isZikoUINode(){return!0}get node(){return this.cache.node}}class gt extends Array{constructor(...t){super(...t)}getItemById(t){return this.find((e=>e.element.id===t))}getItemsByTagName(t){return this.filter((e=>e.element.tagName.toLowerCase()===t.toLowerCase()))}getElementsByClassName(t){return this.filter((e=>e.element.classList?.contains(t)))}querySelector(t){const e=globalThis?.document?.querySelector(t);return e&&this.find((t=>t.element===e))||null}querySelectorAll(t){const e=globalThis?.document?.querySelectorAll(t);return Array.from(e).map((t=>this.find((e=>e.element===t)))).filter(Boolean)}}const bt=new gt,wt={default:{target:null,render:!0,math:{mode:"deg"}},setDefault:function(t){const e=Object.keys(t),s=Object.values(t);for(let t=0;t<e.length;t++)this.default[e[t]]=s[t]},init:()=>{},renderingMode:"spa",isSSC:!1},yt={store:new Map,index:0,register:function(t){this.store.set(this.index++,t)}},vt={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(t){}},_t={store:new Map,index:0,register:function(t){console.log({index:this.index}),this.store.set(this.index++,t)}};function xt(){var t;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:bt,__HYDRATION__:yt,__State__:_t,__Config__:wt,__CACHE__:vt},t=__Ziko__,Object.defineProperties(t,{QueryParams:{get:function(){return function(t){const e={};return t.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi,(t=>{const[s,r]=t.split("=");e[s]=r})),e}(globalThis.location.search.substring(1))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}}))}xt();class Et extends dt{constructor(){super()}init(t,e,s,r,n=[!0,!1][Math.floor(2*Math.random())]){if(this.target=globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body,"string"==typeof t)switch(s){case"html":t=globalThis?.document?.createElement(t);break;case"svg":t=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg",t);break;default:throw Error("Not supported")}else this.target=t?.parentElement;Object.assign(this.cache,{name:e,isInteractive:n,parent:null,isBody:!1,isRoot:!1,isHidden:!1,isFrozzen:!1,legacyParent:null,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},t&&Object.assign(this.cache,{element:t}),this.items=new gt,globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this],t&&r&&this?.render?.(),this.isInteractive()&&globalThis.__Ziko__.__HYDRATION__.register((()=>this)),globalThis.__Ziko__.__UI__.push(this)}get element(){return this.cache.element}[Symbol.iterator](){return this.items[Symbol.iterator]()}maintain(){for(let t=0;t<this.items.length;t++)Object.defineProperty(this,t,{value:this.items[t],writable:!0,configurable:!0,enumerable:!1})}isInteractive(){return this.cache.isInteractive}isUIElement(){return!0}}function kt(t,...e){e.forEach((e=>function(t,e){const s=Object.getOwnPropertyDescriptors(e);for(const e of Reflect.ownKeys(s)){const r=s[e];"get"in r||"set"in r||"function"!=typeof r.value?Object.defineProperty(Object.getPrototypeOf(t),e,r):"function"==typeof r.value&&(Object.getPrototypeOf(t).hasOwnProperty(e)||Object.defineProperty(Object.getPrototypeOf(t),e,r))}}(t,e)))}function Tt(t){const{store:e,index:s}=__Ziko__.__State__;__Ziko__.__State__.register({value:t,subscribers:new Set,paused:!1});const r=e.get(s);return[function(){return{value:r.value,isStateGetter:()=>!0,_subscribe:t=>r.subscribers.add(t)}},function(t){r.paused||("function"==typeof t&&(t=t(r.value)),t!==r.value&&(r.value=t,r.subscribers.forEach((t=>t(r.value)))))},{pause:()=>{r.paused=!0},resume:()=>{r.paused=!1},clear:()=>{r.subscribers.clear()},force:t=>{"function"==typeof t&&(t=t(r.value)),r.value=t,r.subscribers.forEach((t=>t(r.value)))},getSubscribers:()=>new Set(r.subscribers)}]}globalThis.__Ziko__||xt();const Ot=t=>"function"==typeof t&&t?.()?.isStateGetter?.(),At=(t="")=>t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase())),St=(t="")=>{if(0===t.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(t)};class Ct extends dt{constructor(...t){super("span","text",!1,...t),this.element=globalThis?.document?.createTextNode(...t)}isText(){return!0}}const jt=(...t)=>new Ct(...t);async function It(t,e,...s){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]=jt(s[r])),s[r]instanceof Function){const t=s[r]();t.isStateGetter&&(s[r]=jt(t.value),t._subscribe((t=>s[r].element.textContent=t),s[r]))}if("function"==typeof globalThis?.Node&&s[r]instanceof globalThis?.Node&&(s[r]=new this.constructor(s[r])),s[r]?.isZikoUINode)s[r].cache.parent=this,this.element?.[t](s[r].element),s[r].target=this.element,this.items[e](s[r]);else if(s[r]instanceof Promise){const n=await s[r];n.cache.parent=this,this.element?.[t](n.element),n.target=this.element,this.items[e](n)}else s[r]instanceof Object&&(s[r]?.style&&this.style(s[r]?.style),s[r]?.attr&&Object.entries(s[r].attr).forEach((t=>this.setAttr(""+t[0],t[1]))))}return this.maintain(),this}function Mt(t,e){if(this.element instanceof globalThis?.SVGAElement&&(t=St(t)?At(t):t),!this?.attr[t]||this?.attr[t]!==e){if(Ot(e)){e()._subscribe((e=>this.element?.setAttribute(t,e)),this)}else this.element?.setAttribute(t,e);Object.assign(this.cache.attributes,{[t]:e})}}var Dt=Object.freeze({__proto__:null,getAttr:function(t){return t=is_camelcase(t)?camel2hyphencase(t):t,this.element.attributes[t].value},removeAttr:function(...t){for(let e=0;e<t.length;e++)this.element?.removeAttribute(t[e]);return this},setAttr:function(t,e){if(t instanceof Object){const[s,r]=[Object.keys(t),Object.values(t)];for(let t=0;t<s.length;t++)r[t]instanceof Array&&(e[t]=r[t].join(" ")),Mt.call(this,s[t],r[t])}else e instanceof Array&&(e=e.join(" ")),Mt.call(this,t,e);return this},setContentEditable:function(t=!0){return this.setAttr("contenteditable",t),this}});var Pt=Object.freeze({__proto__:null,after:function(t){return t?.isUIElement&&(t=t.element),this.element?.after(t),this},append:function(...t){return It.call(this,"append","push",...t),this},before:function(t){return t?.isUIElement&&(t=t.element),this.element?.before(t),this},clear:function(){return this?.items?.forEach((t=>t.unrender())),this.element.innerHTML="",this},insertAt:function(t,...e){if(t>=this.element.children.length)this.append(...e);else for(let s=0;s<e.length;s++)["number","string"].includes(typeof e[s])&&(e[s]=jt(e[s])),this.element?.insertBefore(e[s].element,this.items[t].element),this.items.splice(t,0,e[s]);return this},prepend:function(...t){return this.__addItem__.call(this,"prepend","unshift",...t),this},remove:function(...t){const e=t=>{"number"==typeof t&&(t=this.items[t]),t?.isUIElement&&this.element?.removeChild(t.element),this.items=this.items.filter((e=>e!==t))};for(let s=0;s<t.length;s++)e(t[s]);for(let t=0;t<this.items.length;t++)Object.assign(this,{[[t]]:this.items[t]});return this},render:function(t=this.target){if(!this.isBody)return t?.isUIElement&&(t=t.element),this.target=t,this.target?.appendChild(this.element),this},renderAfter:function(t=1){return setTimeout((()=>this.render()),t),this},replaceElementWith:function(t){return this.cache.element.replaceWith(t),this.cache.element=t,this},unrender:function(){return this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target?.children].includes(this.element)&&this.target.removeChild(this.element),this},unrenderAfter:function(t=1){return setTimeout((()=>this.unrender()),t),this}});const Rt={Click:["Click","DblClick","ClickAway"],Ptr:["PtrMove","PtrDown","PtrUp","PtrLeave","PtrEnter","PtrOut","PtrCancel"],Mouse:["MouseMove","MouseDown","MouseUp","MouseEnter","MouseLeave","MouseOut"],Key:["KeyDown","KeyPress","KeyUp"],Clipboard:["Copy","Cut","Paste"],Focus:["focus","blur"],Drag:["Drag","DragStart","DragEnd","Drop"],Wheel:["Wheel"]},Lt=(t="")=>t.startsWith("Ptr")?`pointer${t.split("Ptr")[1].toLowerCase()}`:t.toLowerCase();function $t(t,e,s,r,n){this.cache.currentEvent=e,this.cache.event=t,s?.call(this),r?.hasOwnProperty("prototype")?r?.call(this):r?.call(null,this),this.cache.preventDefault[e]&&t.preventDefault(),this.cache.stopPropagation[e]&&t.stopPropagation(),this.cache.stopImmediatePropagation[e]&&t.stopImmediatePropagation(),this.cache.stream.enabled[e]&&n&&this.cache.stream.history[e].push(n),this.cache.callbacks[e]?.map((t=>t(this)))}class Nt{constructor(t=null,e=[],s,r){this.target=t,this.cache={currentEvent:null,event:null,options:{},preventDefault:{},stopPropagation:{},stopImmediatePropagation:{},event_flow:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{},__controllers__:{}},e&&this._register_events(e,s,r)}_register_events(t,e,s,r=!0){const n=t?.map((t=>Lt(t)));return n?.forEach(((n,i)=>{Object.assign(this.cache.preventDefault,{[n]:!1}),Object.assign(this.cache.options,{[n]:{}}),Object.assign(this.cache.paused,{[n]:!1}),Object.assign(this.cache.stream.enabled,{[n]:!1}),Object.assign(this.cache.stream.clear,{[n]:!1}),Object.assign(this.cache.stream.history,{[n]:[]}),Object.assign(this.cache.__controllers__,{[n]:t=>$t.call(this,t,n,e,s)}),r&&Object.assign(this,{[`on${t[i]}`]:(...t)=>this.__onEvent(n,this.cache.options[n],{},...t)})})),this}get targetElement(){return this.target?.element}get isParent(){return this.target?.element===this.event.srcElement}get item(){return this.target.find((t=>t.element==this.event?.srcElement))?.[0]}get currentEvent(){return this.cache.currentEvent}get event(){return this.cache.event}setTarget(t){return this.target=t,this}__handle(t,e,s,r){return this.targetElement?.addEventListener(t,e,s),this}__onEvent(t,e,s,...r){if(0===r.length){if(console.log("00"),!this.cache.callbacks[t])return this;console.log("Call"),this.cache.callbacks[t].map((t=>e=>t.call(this,e)))}else this.cache.callbacks[t]=r.map((t=>e=>t.call(this,e)));return this.__handle(t,this.cache.__controllers__[t],e,s),this}#t(t,e,s){"default"===s&&Object.assign(this.cache[t],{...this.cache[t],...e});const r="default"===s?this.cache[t]:Object.fromEntries(Object.keys(this.cache.preventDefault).map((t=>[t,s])));return Object.assign(this.cache[t],{...r,...e}),this}preventDefault(t={},e="default"){return this.#t("preventDefault",t,e),this}stopPropagation(t={},e="default"){return this.#t("stopPropagation",t,e),this}stopImmediatePropagation(t={},e="default"){return this.#t("stopImmediatePropagation",t,e),this}setEventOptions(t,e){return this.pause({[t]:!0},"default"),Object.assign(this.cache.options[Lt(t)],e),this.resume({[t]:!0},"default"),this}pause(t={},e="default"){t={..."default"===e?this.cache.stream.enabled:Object.entries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t};for(let e in t)t[e]&&(this.targetElement?.removeEventListener(e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]=!0);return this}resume(t={},e="default"){t={..."default"===e?this.cache.stream.enabled:Object.entries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t};for(let e in t)t[e]&&(this.targetElement?.addEventListener(e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]=!1);return this}stream(t={},e="default"){this.cache.stream.t0=Date.now();return t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t},Object.assign(this.cache.stream.enabled,t),this}clear(){return this}dispose(t={},e="default"){return this.pause(t,e),this}}class Bt extends Nt{constructor(t,e){super(t,Rt.Click,Ft,e)}}function Ft(){"click"===this.currentEvent?this.dx=0:this.dx=1}const Ht=(t,e)=>new Bt(t,e);class zt extends Nt{constructor(t,e){super(t,Rt.Clipboard,Ut,e)}}function Ut(){}const Zt=(t,e)=>new zt(t,e);class qt extends Nt{constructor(t,e,s){super(t,e,Wt,s)}_register_events(t){return super._register_events(t,null,null,!1),this}emit(t,e={}){const s=new Event(t);return this.targetElement.dispatchEvent(s),this}on(t,...e){return this.cache.options.hasOwnProperty(t)||this._register_events([t]),this.__onEvent(t,this.cache.options[t],{},...e),this}}function Wt(){}class Vt extends Nt{constructor(t,e){super(t,Rt.Drag,Gt,e)}}function Gt(){}const Kt=(t,e)=>new Vt(t,e);class Xt extends Nt{constructor(t,e){super(t,Rt.Focus,Yt,e)}}function Yt(){}const Qt=(t,e)=>new Xt(t,e);let Jt=class extends Nt{constructor(t,e){super(t,Rt.Hash,te,e)}};function te(){}class ee extends Nt{constructor(t,e){super(t,Rt.Key,se,e)}}function se(){switch(this.currentEvent){case"keydown":this.kd=this.event.key;break;case"keypress":this.kp=this.event.key;break;case"keyup":this.ku=this.event.key}}const re=(t,e)=>new ee(t,e);class ne extends Nt{constructor(t,e){super(t,Rt.Mouse,ie,e)}}function ie(){}const ae=(t,e)=>new ne(t,e);class oe extends Nt{constructor(t,e){super(t,Rt.Ptr,he,e),this.isDown=!1}}function he(){switch(this.currentEvent){case"pointerdown":this.dx=parseInt(this.event.offsetX),this.dy=parseInt(this.event.offsetY),this.isDown=!0;break;case"pointermove":this.mx=parseInt(this.event.offsetX),this.my=parseInt(this.event.offsetY),this.isMoving=!0;break;case"pointerup":{this.ux=parseInt(this.event.offsetX),this.uy=parseInt(this.event.offsetY),this.isDown=!1,console.log(this.target.width);const t=(this.ux-this.dx)/this.target.width,e=(this.dy-this.uy)/this.target.height,s=t<0?"left":t>0?"right":"none",r=e<0?"bottom":e>0?"top":"none";this.swippe={h:s,v:r,delta_x:t,delta_y:e}}}}const ce=(t,e)=>new oe(t,e);class le extends Nt{constructor(t,e){super(t,Rt.Touch,ue,e)}}function ue(){}class me extends Nt{constructor(t,e){super(t,Rt.Wheel,pe,e)}}function pe(){}const fe=(t,e)=>new me(t,e),de={ptr:ce,mouse:ae,key:re,click:Ht,drag:Kt,clipboard:Zt,focus:Qt,wheel:fe},ge={};Object.entries(Rt).forEach((([t,e])=>{e.forEach((e=>{const s=`on${e}`;ge[s]=function(...e){return this.events[t]||(this.events[t]=de[t.toLowerCase()](this)),this.events[t][s](...e),this}}))}));var be=Object.freeze({__proto__:null,at:function(t){return this.items.at(t)},find:function(t){return this.items.filter(t)},forEach:function(t){return this.items.forEach(t),this},map:function(t){return this.items.map(t)}});var we=Object.freeze({__proto__:null,animate:function(t,{duration:e=1e3,iterations:s=1,easing:r="ease"}={}){return this.element?.animate(t,{duration:e,iterations:s,easing:r}),this},hide:function(){},show:function(){},size:function(t,e){return this.style({width:t,height:e})},style:function(t){for(let e in t){const s=t[e];if(Ot(s)){const t=s();Object.assign(this.element.style,{[e]:t.value}),t._subscribe((t=>{console.log({newValue:t}),Object.assign(this.element.style,{[e]:t})}))}else Object.assign(this.element.style,{[e]:s})}return this}});function ye(t,e,s,r){return this.event=t,this.cache.preventDefault[e]&&t.preventDefault(),console.log({setter:s}),s&&s(),this.cache.stream.enabled[e]&&r&&this.cache.stream.history[e].push(r),this.cache.callbacks[e].map((t=>t(this))),this}class ve{constructor(t){this.target=null,this.setTarget(t),this.__dispose=this.dispose.bind(this)}get targetElement(){return this.target.element}setTarget(t){return this.target=t,this}__handle(t,e,s){const r="drag"===t?t:`${this.cache.prefixe}${t}`;return this.dispose(s),this.targetElement?.addEventListener(r,e),this}__onEvent(t,e,...s){if(0===s.length){if(!(this.cache.callbacks.length>1))return this;this.cache.callbacks.map((t=>e=>t.call(this,e)))}else this.cache.callbacks[t]=s.map((t=>e=>t.call(this,e)));return this.__handle(t,this.__controller[t],e),this}preventDefault(t={}){return Object.assign(this.cache.preventDefault,t),this}pause(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.targetElement?.removeEventListener(`${this.cache.prefixe}${e}`,this.__controller[`${this.cache.prefixe}${e}`]),this.cache.paused[`${this.cache.prefixe}${e}`]=!0);return this}resume(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.targetElement?.addEventListener(`${this.cache.prefixe}${e}`,this.__controller[`${this.cache.prefixe}${e}`]),this.cache.paused[`${this.cache.prefixe}${e}`]=!1);return this}dispose(t={}){return this.pause(t),this}stream(t={}){this.cache.stream.t0=Date.now();return t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t},Object.assign(this.cache.stream.enabled,t),this}clear(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.clear).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.cache.stream.history[e]=[]);return this}}function _e(t){ye.call(this,t,"input",null,null)}function xe(t){ye.call(this,t,"change",null,null)}class Ee extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{input:!1,change:!1},paused:{input:!1,change:!1},stream:{enabled:{input:!1,change:!1},clear:{input:!1,change:!1},history:{input:[],change:[]}},callbacks:{input:[],change:[]}},this.__controller={input:_e.bind(this),change:xe.bind(this)}}get value(){return this.target.value}onInput(...t){return this.__onEvent("input",{},...t),this}onChange(...t){return this.__onEvent("change",{},...t),this}}function ke(t){ye.call(this,t,"hashchange",null,null)}class Te extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{hashchange:!1},paused:{hashchange:!1},stream:{enabled:{hashchange:!1},clear:{hashchange:!1},history:{hashchange:[]}},callbacks:{hashchange:[]}},this.__controller={hashchange:ke.bind(this)}}onChange(...t){return this.__onEvent("hashchange",{},...t),this}}const Oe=t=>function(e){ye.call(this,e,t,null,null)};class Ae extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{}},this.__controller={}}#e(t){return this.cache.preventDefault[t]=!1,this.cache.paused[t]=!1,this.cache.stream.enabled=!1,this.cache.stream.clear=!1,this.cache.stream.history=[],this.cache.callbacks[t]=[],this.__controller[t]=Oe(t).bind(this),this}on(t,...e){return this.__controller[t]||this.#e(t),this.__onEvent(t,{},...e),this}emit(t,e={}){this.__controller[t]||this.#e(t),this.detail=e;const s=new Event(t);return this.targetElement.dispatchEvent(s),this}}const Se=t=>new Ae(t);class Ce extends ve{constructor(t,e=.3,s=.3){super(t);const{removeListener:r,setWidthThreshold:n,setHeightThreshold:i}=function(t,e=.5,s=.5,r,n){let i=R(e,0,r),a=R(s,0,n),o=0,h=0,c=0,l=0;const u=t=>{o=t.clientX,h=t.clientY},m=t=>{c=t.clientX,l=t.clientY,p()};function p(){const t=c-o,e=l-h;(Math.abs(t)>i||Math.abs(e)>a)&&f(t,e)}function f(e,s){const o=globalThis?.CustomEvent?new CustomEvent("swipe",{detail:{deltaX:vs(e)<i?0:Ds(e)*P(vs(e),0,r),deltaY:vs(s)<a?0:Ds(s)*P(vs(s),0,n),direction:{x:vs(e)<i?"none":e>0?"right":"left",y:vs(s)<a?"none":s>0?"down":"up"}}}):null;t?.dispatchEvent(o)}function d(t){i=R(t,0,r)}function g(t){a=R(t,0,n)}return t?.addEventListener("pointerdown",u),t?.addEventListener("pointerup",m),{removeListener(){t?.removeEventListener("pointerdown",u),t?.removeEventListener("pointerup",m),console.log("Swipe event listeners removed")},setWidthThreshold:d,setHeightThreshold:g}}(this.target?.element,e,s,this.target.width,this.target.height);this.cache={width_threshold:e,height_threshold:s,removeListener:r,setWidthThreshold:n,setHeightThreshold:i,legacyTouchAction:globalThis?.document?.body?.style?.touchAction,prefixe:"",preventDefault:{swipe:!1},paused:{swipe:!1},stream:{enabled:{swipe:!1},clear:{swipe:!1},history:{swipe:[]}},callbacks:{swipe:[]}},this.__controller={swipe:je.bind(this)}}onSwipe(...t){return Object.assign(globalThis?.document?.body?.style,{touchAction:"none"}),this.__onEvent("swipe",{},...t),this}updateThresholds(t=this.cache.width_threshold,e=this.cache.height_threshold){return void 0!==t&&this.cache.setWidthThreshold(t),void 0!==e&&this.cache.setHeightThreshold(e),this}destroy(){return this.cache.removeListener(),Object.assign(globalThis?.document?.body?.style,{touchAction:this.cache.legacyTouchAction}),this}}function je(t){ye.call(this,t,"swipe",null,null)}class Ie{constructor(t,e){this.target=t,this.observer=null,this.cache={options:e||{attributes:!0,childList:!0,subtree:!0},streamingEnabled:!0,lastMutation:null,mutationHistory:{}},this.observeCallback=(t,e)=>{if(this.cache.streamingEnabled)for(const e of t)switch(e.type){case"attributes":this.cache.mutationHistory.attributes.push(e.target.getAttribute(e.attributeName));break;case"childList":this.cache.mutationHistory.childList.push(e);break;case"subtree":this.cache.mutationHistory.subtree.push(e)}this.callback&&this.callback(t,e)}}observe(t){if(!this.observer){if(!globalThis.MutationObserver)return void console.log("MutationObserver Nor Supported");this.observer=new MutationObserver(this.cache.observeCallback),this.observer.observe(this.target.element,this.cache.options),this.callback=([e])=>t.call(e,this),this.cache.streamingEnabled=!0}}pause(t){this.observer&&(this.observer.disconnect(),t&&this.observer.observe(this.target,t))}reset(t){this.observer&&(this.observer.disconnect(),this.observer.observe(this.target,t||this.cache.options))}clear(){return this.observer&&(this.observer.disconnect(),this.observer=null,this.cache.mutationHistory={attributes:[],childList:[],subtree:[]}),this.cache.streamingEnabled=!1,this}getMutationHistory(){return this.cache.mutationHistory}enableStreaming(){return this.cache.streamingEnabled=!0,this}disableStreaming(){return this.cache.streamingEnabled=!1,this}}class Me extends Ie{constructor(t,e){super(t,{attributes:!0,childList:!1,subtree:!1}),Object.assign(this.cache,{observeCallback:(t,e)=>{for(const e of t)this.cache.lastMutation={name:e.attributeName,value:e.target.getAttribute(e.attributeName)},this.cache.streamingEnabled&&this.cache.mutationHistory.attributes.push(this.cache.lastMutation);this.callback&&this.callback(t,e)}}),this.cache.mutationHistory.attributes=[],e&&this.observe(e)}get history(){return this.cache.mutationHistory.attributes}}class De extends Ie{constructor(t,e){super(t,{attributes:!1,childList:!0,subtree:!1}),Object.assign(this.cache,{observeCallback:(t,e)=>{for(const e of t)e.addedNodes?this.cache.lastMutation={type:"add",item:this.target.find((t=>t.element===e.addedNodes[0]))[0],previous:this.target.find((t=>t.element===e.previousSibling))[0]}:e.addedNodes&&(this.cache.lastMutation={type:"remove",item:this.target.find((t=>t.element===e.removedNodes[0]))[0],previous:this.target.find((t=>t.element===e.previousSibling))[0]}),this.cache.streamingEnabled&&this.cache.mutationHistory.children.push(this.cache.lastMutation);this.callback&&this.callback(t,e)}}),this.cache.mutationHistory.children=[],e&&this.observe(e)}get item(){return this.cache.lastMutation.item}get history(){return this.cache.mutationHistory.children}}class Pe{constructor(t,e,{threshold:s=0,margin:r=0}={}){this.target=t,this.config={threshold:s,margin:r},globalThis.IntersectionObserver?this.observer=new IntersectionObserver((t=>{this.entrie=t[0],e(this)}),{threshold:this.threshold}):console.log("IntersectionObserver Not Supported")}get ratio(){return this.entrie.intersectionRatio}get isIntersecting(){return this.entrie.isIntersecting}setThreshould(t){return this.config.threshold=t,this}setMargin(t){return t="number"==typeof t?t+"px":t,this.config.margin=t,this}start(){return this.observer.observe(this.target.element),this}stop(){return this}}class Re{constructor(t,e){this.target=t,this.contentRect=null,this.observer=new ResizeObserver((()=>{e(this)}))}get BoundingRect(){return this.target.element.getBoundingClientRect()}get width(){return this.BoundingRect.width}get height(){return this.BoundingRect.height}get top(){return this.BoundingRect.top}get bottom(){return this.BoundingRect.bottom}get right(){return this.BoundingRect.right}get left(){return this.BoundingRect.left}get x(){return this.BoundingRect.x}get y(){return this.BoundingRect.y}start(){return this.observer.observe(this.target.element),this}stop(){return this.observer.unobserve(this.target.element),this}}class Le{constructor(t=(t=>console.log({x:t.x,y:t.y}))){this.cache={},this.previousX=globalThis?.screenX,this.previousY=globalThis?.screenY}update(){Object.assign(this.cache,{screenXLeft:globalThis?.screenX,screenXRight:globalThis?.screen.availWidth-globalThis?.screenX,screenYTop:globalThis?.screenY,screenYBottom:globalThis?.screen.availHeight-globalThis?.screenY-globalThis?.outerHeight,screenCenterX:globalThis?.screen.availWidth/2,screenCenterY:globalThis?.screen.availHeight/2,windowCenterX:globalThis?.outerWidth/2+globalThis?.screenX,windowCenterY:globalThis?.outerHeight/2+globalThis?.screenY,deltaCenterX:globalThis?.screen.availWidth/2-globalThis?.outerWidth/2+globalThis?.screenX,deltaCenterY:null})}get x0(){return L(globalThis?.screenX,0,globalThis.screen.availWidth,-1,1)}get y0(){return-L(globalThis?.screenY,0,globalThis.screen.availHeight,-1,1)}get x1(){return L(globalThis?.screenX+globalThis?.outerWidth,0,globalThis.screen.availWidth,-1,1)}get y1(){return-L(globalThis?.screenY+globalThis?.outerHeight,0,globalThis.screen.availHeight,-1,1)}get cx(){return L(globalThis?.outerWidth/2+globalThis?.screenX,0,globalThis.screen.availWidth,-1,1)}get cy(){return-L(globalThis?.outerHeight/2+globalThis?.screenY,0,globalThis.screen.availHeight,-1,1)}}class $e{constructor(){this.events={},this.maxListeners=10}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e),this.events[t].length>this.maxListeners&&console.warn(`Warning: Possible memory leak. Event '${t}' has more than ${this.maxListeners} listeners.`)}once(t,e){const s=r=>{this.off(t,s),e(r)};this.on(t,s)}off(t,e){const s=this.events[t];if(s){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}emit(t,e){const s=this.events[t];s&&s.forEach((t=>{t(e)}))}clear(t){t?delete this.events[t]:this.events={}}setMaxListener(t,e){this.maxListeners=e}removeAllListeners(t){t?this.events[t]=[]:this.events={}}}const Ne=()=>new $e;class Be{constructor(t,e=!0){this.#e(),this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}#e(){return this.__FavIcon__=document.querySelector("link[rel*='icon']")||document?.createElement("link"),this.__FavIcon__.type="image/x-icon",this.__FavIcon__.rel="shortcut icon",this}set(t){return t!==this.__FavIcon__.href&&(this.__FavIcon__.href=t,this.cache.Emitter&&this.cache.Emitter.emit("ziko:favicon-changed")),this}get current(){return document.__FavIcon__.href}onChange(t){return this.cache.Emitter&&this.cache.Emitter.on("ziko:favicon-changed",t),this}useEventEmitter(){return this.cache.Emitter=Ne(),this}}const Fe=(t,e)=>new Be(t,e);class He{constructor({viewport:t,charset:e,description:s,author:r,keywords:n}){this.document=globalThis?.document,this.meta={},this.init({viewport:t,charset:e,description:s,author:r,keywords:n})}init({viewport:t,charset:e,description:s,author:r,keywords:n}){t&&this.setViewport(t),e&&this.setCharset(e),s&&this.describe(s),r&&this.setAuthor(r),n&&this.setKeywords(n)}set(t,e){const s="charset"===(t=t.toLowerCase()),r=s?document.querySelector("meta[charset]"):document.querySelector(`meta[name=${t}]`);return this.meta=r??document?.createElement("meta"),s?this.meta.setAttribute("charset",e):(this.meta.setAttribute("name",t),this.meta.setAttribute("content",e)),r||this.document.head.append(this.meta),this}setCharset(t="utf-8"){return this.set("charset",t),this}describe(t){return this.set("description",t),this}setViewport(t="width=device-width, initial-scale=1.0"){return this.set("viewport",t),this}setKeywords(...t){return t=[...new Set(t)].join(", "),this.set("keywords",t),this}setAuthor(t){return this.set("author",t),this}}const ze=({viewport:t,charset:e,description:s,author:r,keywords:n})=>new He({viewport:t,charset:e,description:s,author:r,keywords:n});class Ue{constructor(t=document.title,e=!0){this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.Emitter=Ne(),this}set(t){return t!==document.title&&(document.title=t,this.cache.Emitter&&this.cache.Emitter.emit("ziko:title-changed")),this}get current(){return document.title}onChange(t){return this.cache.Emitter&&this.cache.Emitter.on("ziko:title-changed",t),this}}const Ze=(t,e)=>new Ue(t,e);class qe{constructor({title:t,lang:e,icon:s,meta:r,noscript:n}){this.html=globalThis?.document?.documentElement,this.head=globalThis?.document?.head,t&&Ze(t),e&&this.setLang(e),s&&Fe(s),r&&ze(r),n&&this.setNoScript()}setLang(t){this.html.setAttribute("lang",t)}setNoScript(t){}}const We=({title:t,lang:e,icon:s,meta:r,noscript:n})=>new qe({title:t,lang:e,icon:s,meta:r,noscript:n});class Ve{constructor(t=[],e=(()=>{})){this.mediaQueryRules=t,this.fallback=e,this.lastCalledCallback=null,this.init()}init(){this.mediaQueryRules.forEach((({query:t,callback:e})=>{const s=globalThis.matchMedia(t),r=()=>{const t=this.mediaQueryRules.some((({query:t})=>globalThis.matchMedia(t).matches));s.matches?(e(),this.lastCalledCallback=e):t||this.lastCalledCallback===this.fallback||(this.fallback(),this.lastCalledCallback=this.fallback)};r(),s.addListener(r)}))}}let Ge=class extends Et{constructor({element:t,name:e="",type:s="html",render:r=__Ziko__.__Config__.default.render}={}){super(),kt(this,Dt,Pt,we,be,ge),t&&this.init(t,e,s,r)}get element(){return this.cache.element}isInteractive(){return this.cache.isInteractive}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 isBody(){return this.element===globalThis?.document.body}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}on(t,...e){return this.events.custom||(this.events.custom=Se(this)),this.events.custom.on(t,...e),this}emit(t,e={}){return this.events.custom||(this.events.custom=Se(this)),this.events.custom.emit(t,e),this}};const Ke=["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"],Xe=["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"],Ye=new Proxy({},{get(t,e){if("string"!=typeof e)return;let s,r=e.replaceAll("_","-").toLowerCase();return Ke.includes(r)&&(s="html"),Xe.includes(r)&&(s="svg"),(...t)=>0===t.length?new Ge({element:r,name:r,type:s}):["string","number"].includes(typeof t[0])||t[0]instanceof Ge||"function"==typeof t[0]&&t[0]().isStateGetter()?new Ge({element:r,name:r,type:s}).append(...t):new Ge({element:r,type:s}).setAttr(t.shift()).append(...t)}});class Qe extends Ge{constructor(t="div",e="100%",s="100%"){super({element:t,name:"Flex"}),this.direction="cols","number"==typeof e&&(e+="%"),"number"==typeof s&&(s+="%"),this.style({width:e,height:s}),this.style({display:"flex"})}get isFlex(){return!0}resp(t,e=!0){return this.wrap(e),this.element.clientWidth<t?this.vertical():this.horizontal(),this}setSpaceAround(){return this.style({justifyContent:"space-around"}),this}setSpaceBetween(){return this.style({justifyContent:"space-between"}),this}setBaseline(){return this.style({alignItems:"baseline"}),this}gap(t){return"row"===this.direction?this.style({columnGap:t}):"column"===this.direction&&this.style({rowGap:t}),this}wrap(t="wrap"){return this.style({flexWrap:"string"==typeof t?t:["no-wrap","wrap","wrap-reverse"][+t]}),this}_justifyContent(t="center"){return this.style({justifyContent:t}),this}vertical(t,e,s=1){return Je.call(this,s),this.style({alignItems:"number"==typeof t?es.call(this,t):t,justifyContent:"number"==typeof e?ss.call(this,e):e}),this}horizontal(t,e,s=1){return ts.call(this,s),this.style({alignItems:"number"==typeof e?ss.call(this,e):e,justifyContent:"number"==typeof t?es.call(this,t):t}),this}show(){return this.isHidden=!1,this.style({display:"flex"}),this}}function Je(t){return 1==t?this.style({flexDirection:"column"}):-1==t&&this.style({flexDirection:"column-reverse"}),this}function ts(t){return 1==t?this.style({flexDirection:"row"}):-1==t&&this.style({flexDirection:"row-reverse"}),this}function es(t){return"number"==typeof t&&(t=["flex-start","center","flex-end"][t+1]),t}function ss(t){return es(-t)}class rs extends Et{constructor({element:t,name:e,type:s,render:r}){super({element:t,name:e,type:s,render:r})}}class ns extends rs{constructor(t,e){super({element:"div",name:"suspense"}),this.setAttr({dataTemp:"suspense"}),this.fallback_ui=t,this.append(t),(async()=>{try{const s=await e();t.unrender(),this.append(s)}catch(t){console.log({error:t})}})()}}class is extends Ge{constructor(t){super({element:"div",name:"html_wrappper"}),this.element.append(function(t){if(globalThis?.DOMParser){const e=(new DOMParser).parseFromString(`<div>${t}</div>`,"text/html");return e.body.firstChild.style.display="contents",e.body.firstChild}}(t)),this.style({display:"contents"})}}class as extends Ge{constructor(t){super({element:"div",name:"html_wrappper"}),this.element.append(function(t){if("undefined"!=typeof DOMParser){const e=(new DOMParser).parseFromString(t.trim(),"image/svg+xml").documentElement;if("parsererror"===e.nodeName)throw new Error("Invalid SVG string");if(e.hasAttribute("xmlns"))return e;const{children:s,attributes:r}=e,n=document.createElementNS("http://www.w3.org/2000/svg","svg");for(let{name:t,value:e}of r)n.setAttribute(t,e);return n.append(...s),globalThis.svg=e,globalThis.children=s,globalThis.attributes=r,globalThis.element=n,n}throw new Error("DOMParser is not available in this environment")}(t)),this.style({display:"contents"})}}class os extends Ge{constructor(t,e){super(),this.key=t,this.cases=e,this.init()}init(){Object.values(this.cases).filter((t=>t!=this.current)).forEach((t=>t.unrender())),super.init(this.current.element)}get current(){const t=Object.keys(this.cases).find((t=>t==this.key))??"default";return this.cases[t]}updateKey(t){return this.key=t,this.replaceElementWith(this.current.element),this}}const hs=t=>(new XMLSerializer).serializeToString(t),cs=t=>btoa(hs(t)),ls=t=>"data:image/svg+xml;base64,"+cs(t),us=t=>JSON.stringify(v((t=>["number","string","boolean","bigint"].includes(typeof t)?String(t):t instanceof ws||t instanceof gs?t.toString():t instanceof Array?ps(t):void 0),t),null," ").replace(/"([^"]+)":/g,"$1:").replace(/: "([^"]+)"/g,": $1"),ms=t=>{if(!Array.isArray(t))return 0;let e=1;for(const s of t)if(Array.isArray(s)){const t=ms(s);t+1>e&&(e=t+1)}return e},ps=t=>{let e=0;return function t(s){let r=ms(s),n=0;return s.some((t=>Array.isArray(t)))&&(e++,n=1),"["+s.map(((r,n)=>["number","string","boolean","bigint"].includes(typeof r)?String(r):r instanceof ws?r.toString():r instanceof Array?`\n${" ".repeat(e)}${t(r)}${n===s.length-1?"\n":""}`:r instanceof Object?us(r):void 0))+`${" ".repeat((r+e+1)*n)}]`}(t)},fs=(t,e=0)=>{t=ds(t);let s="";const r=" ".repeat(e);for(let n in t)if("object"==typeof t[n]){s+=`${r}${n} {\n`;const i=t[n];for(let t in i)"object"==typeof i[t]?s+=fs({[t]:i[t]},e+1):s+=`${r} ${t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}: ${i[t]};\n`;s+=`${r}}\n`}return s};function ds(t){return"object"!=typeof t||null===t?t:Object.keys(t).reduce(((e,s)=>(e[s.trim()]=ds(t[s]),e)),Array.isArray(t)?[]:{})}class gs extends y{constructor(t,e,s=[]){if(super(),t instanceof gs)this.arr=t.arr,this.rows=t.rows,this.cols=t.cols;else{let r,n,i=[];if(arguments[0]instanceof Array)t=arguments[0].length,e=arguments[0][0].length,i=arguments[0];else for(r=0;r<t;r++)for(i.push([]),i[r].push(new Array(e)),n=0;n<e;n++)i[r][n]=s[r*e+n],null==s[r*e+n]&&(i[r][n]=0);this.rows=t,this.cols=e,this.arr=i}this.#s()}toString(){return ps(this.arr)}at(t=0,e=void 0){return t<0&&(t=this.rows+t),null==e?this.arr[t]:(e<0&&(e=this.cols+e),this.arr[t][e])}reshape(t,e){if(t*e==this.rows*this.cols)return new gs(t,e,this.arr.flat(1));console.error("Err")}static eye(t){let e=new gs(t,t);for(let s=0;s<t;s++)for(let r=0;r<t;r++)e.arr[s][r]=s===r?1:0;return e}get clone(){return new gs(this.rows,this.cols,this.arr.flat(1))}get size(){return this.rows*this.cols}get shape(){return[this.rows,this.cols]}get reel(){return new gs(this.cols,this.rows,this.arr.flat(1).reel)}get imag(){return new gs(this.cols,this.rows,this.arr.flat(1).imag)}[Symbol.iterator](){return this.arr[Symbol.iterator]()}#s(){for(let t=0;t<this.arr.length;t++)Object.defineProperty(this,t,{value:this.arr[t],writable:!0,configurable:!0,enumerable:!1})}get(t=0,e=0){return-1==e?this.arr[t]:-1==t?this.arr.map((t=>t[e])):this.arr[t][e]}set(t=0,e=0,s){if(-1==e)return this.arr[t]=s;if(-1==t){for(let t=0;t<this.cols;t++)this.arr[t][e]=s[t]||0;return this.arr}return this.arr[t][e]=s}get isSquare(){return this.rows/this.cols==1}get isSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==gs.sub(e,t).max&&0==gs.sub(e,t).min}get isAntiSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==gs.add(e,t).max&&0==gs.add(e,t).min}get isDiag(){if(!this.isSquare)return!1;const t=this.T,e=this.clone,s=gs.mul(e,t),r=gs.dot(t,e);return 0==gs.sub(s,r).max&&0==gs.sub(s,r).min}get isOrtho(){return!!this.isSquare&&(this.isDiag&&(1==this.det||-1==this.det))}get isIdemp(){if(!this.isSquare)return!1;const t=this.clone,e=gs.dot(t,t);return 0==gs.sub(e,t).max&&0==gs.sub(e,t).min}get T(){let t=[];for(let e=0;e<this.arr[0].length;e++){t[e]=[];for(let s=0;s<this.arr.length;s++)t[e][s]=this.arr[s][e]}return new gs(this.cols,this.rows,t.flat(1))}get det(){if(!this.isSquare)return new Error("is not square matrix");if(1==this.rows)return this.arr[0][0];function t(t,e){var s=[];for(let e=0;e<t.length;e++)s.push(t[e].slice(0));s.splice(0,1);for(let t=0;t<s.length;t++)s[t].splice(e,1);return s}return function e(s){if(2==s.length)return s.flat(1).some((t=>t instanceof gs))?void console.warn("Tensors are not completely supported yet ..."):tt.sub(tt.mul(s[0][0],s[1][1]),tt.mul(s[0][1],s[1][0]));for(var r=0,n=0;n<s.length;n++){const i=tt.add(tt.mul(xs(-1,n),tt.mul(s[0][n],e(t(s,n)))));r=tt.add(r,i)}return r}(this.arr)}get inv(){if(!this.isSquare)return new Error("is not square matrix");if(0===this.det)return"determinat = 0 !!!";let t=function(t){if(t.length!==t[0].length)return;var e=0,s=0,r=0,n=t.length,i=0,a=[],o=[];for(e=0;e<n;e+=1)for(a[a.length]=[],o[o.length]=[],r=0;r<n;r+=1)a[e][r]=e==r?1:0,o[e][r]=t[e][r];for(e=0;e<n;e+=1){if(0==(i=o[e][e])){for(s=e+1;s<n;s+=1)if(0!=o[s][e]){for(r=0;r<n;r++)i=o[e][r],o[e][r]=o[s][r],o[s][r]=i,i=a[e][r],a[e][r]=a[s][r],a[s][r]=i;break}if(0==(i=o[e][e]))return}for(r=0;r<n;r++)o[e][r]=o[e][r]/i,a[e][r]=a[e][r]/i;for(s=0;s<n;s++)if(s!=e)for(i=o[s][e],r=0;r<n;r++)o[s][r]-=i*o[e][r],a[s][r]-=i*a[e][r]}return a}(this.arr);return new gs(this.rows,this.cols,t.flat(1))}static zeros(t,e){let s=new gs(t,e);for(let n=0;n<t;n++)for(var r=0;r<e;r++)s.arr[n][r]=0;return s}static ones(t,e){let s=new gs(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=1;return s}static nums(t,e,s){let r=new gs(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)r.arr[n][t]=s;return r}static get rand(){return{int:(t,e,s,r)=>{let n=new gs(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=nt.randInt(s,r);return n},bin:(t,e)=>{let s=new gs(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=nt.randBin;return s},hex:(t,e)=>{let s=new gs(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=nt.randHex;return s},choices:(t,e,s,r)=>{let n=new gs(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=nt.choice(s,r);return n},permutation:(t,e,s)=>{}}}static rands(t,e,s=1,r){let n=new gs(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=nt.rand(s,r);return n}map(t,e,s,r){return tt.map(this,t,e,s,r)}lerp(t,e){return tt.lerp(this,t,e)}norm(t,e){return tt.norm(this,t,e)}clamp(t,e){return tt.clamp(this,t,e)}static map(t,e,s,r,n){return tt.map(t,e,s,r,n)}static lerp(t,e,s){return tt.lerp(t,e,s)}static norm(t,e,s){return tt.norm(t,e,s)}static clamp(t,e,s){return tt.clamp(bs,e,s)}toPrecision(t){for(let e=0;e<this.cols;e++)for(let s=0;s<this.rows;s++)this.arr[e][s]=+this.arr[e][s].toPrecision(t);return this}get toBin(){let t=this.arr.flat(1).toBin;return new gs(this.rows,this.cols,t)}get toOct(){let t=this.arr.flat(1).toOct;return new gs(this.rows,this.cols,t)}get toHex(){let t=this.arr.flat(1).toHex;return new gs(this.rows,this.cols,t)}max2min(){let t=this.arr.flat(1).max2min;return new gs(this.rows,this.cols,t)}min2max(){let t=this.arr.flat(1).min2max;return new gs(this.rows,this.cols,t)}sortRows(t=void 0){let e=this.arr.map((e=>e.sort(t))).flat(1);return new gs(this.rows,this.cols,e)}sortCols(t=void 0){let e=this.T.arr.map((e=>e.sort(t))).flat(1);return new gs(this.rows,this.cols,e).T}filterByRows(t){var e=this.arr.map((e=>e.map((e=>+(""+e).includes(t))))).map((t=>!!Logic.or(...t))),s=this.arr.filter(((t,s)=>!0===e[s]));return 0===s.length&&s.push([]),console.log(s),new gs(s)}filterByCols(t){return new gs(this.T.arr.filter((e=>e.includes(t))))}sortAll(t=void 0){let e=this.arr.flat(1).sort(t);return new gs(this.rows,this.cols,e)}count(t){return this.arr.flat(1).count(t)}toBase(t){let e=this.arr.flat(1).toBase(t);return new gs(this.rows,this.cols,e)}#r(t){if(this.rows!==t.rows)return;let e=this.arr;for(let s=0;s<this.rows;s++)for(let r=this.cols;r<this.cols+t.cols;r++)e[s][r]=t.arr[s][r-this.cols];return this.cols+=t.cols,new gs(this.rows,this.cols,e.flat(1))}hstack(...t){const e=[this,...t].reduce(((t,e)=>t.#r(e)));return Object.assign(this,e),this}static hstack(t,...e){return t.clone.hstack(...e)}#n(t){if(this.cols!==t.cols)return;let e=this.arr;for(let s=this.rows;s<this.rows+t.rows;s++){e[s]=[];for(let r=0;r<this.cols;r++)e[s][r]=t.arr[s-this.rows][r]}return this.rows+=t.rows,new gs(this.rows,this.cols,e.flat(1))}vstack(...t){const e=[this,...t].reduce(((t,e)=>t.#n(e)));return Object.assign(this,e),this}static vstack(t,...e){return t.clone.vstack(...e)}hqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#r(e)));return Object.assign(this,e),this}vqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#n(e)));return Object.assign(this,e),this}static hqueue(t,...e){return t.clone.hqueue(...e)}static vqueue(t,...e){return t.clone.vqueue(...e)}slice(t=0,e=0,s=this.rows-1,r=this.cols-1){let n=s-t,i=r-e,a=new Array(i);for(let s=0;s<n;s++){a[s]=[];for(let r=0;r<i;r++)a[s][r]=this.arr[s+t][r+e]}return new gs(n,i,a.flat(1))}static slice(t,e=0,s=0,r=this.rows-1,n=this.cols-1){return t.slice(e,s,r,n)}splice(t,e,s,...r){}getRows(t,e=t+1){return this.slice(t,0,e,this.cols)}getCols(t,e=t+1){return this.slice(0,t,this.rows,e)}static getRows(t,e,s=e+1){return t.slice(e,0,s,t.cols)}static getCols(t,e,s=e+1){return t.slice(0,e,t.rows,s)}add(...t){for(let s=0;s<t.length;s++){("number"==typeof t[s]||t[s]instanceof ws)&&(t[s]=gs.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=tt.add(this.arr[r][e],t[s].arr[r][e])}return new gs(this.rows,this.cols,this.arr.flat(1))}sub(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=gs.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=tt.sub(this.arr[r][e],t[s].arr[r][e])}return new gs(this.rows,this.cols,this.arr.flat(1))}static add(t,...e){return t.clone.add(...e)}static sub(t,...e){return t.clone.sub(...e)}mul(...t){for(let r=0;r<t.length;r++){"number"==typeof t[r]&&(t[r]=gs.nums(this.rows,this.cols,t[r]));for(var e=0;e<this.rows;e++)for(var s=0;s<this.cols;s++)this.arr[e][s]=tt.mul(this.arr[e][s],t[r].arr[e][s])}return new gs(this.rows,this.cols,this.arr.flat(1))}div(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=gs.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=tt.div(this.arr[r][e],t[s].arr[r][e])}return new gs(this.rows,this.cols,this.arr.flat(1))}static div(t,...e){return t.clone.div(...e)}static mul(t,...e){return t.clone.mul(...e)}modulo(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=gs.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=tt.modulo(this.arr[r][e],t[s].arr[r][e])}return new gs(this.rows,this.cols,this.arr.flat(1))}static modulo(t,...e){return t.clone.modulo(...e)}dot(t){for(var e=[],s=0;s<this.arr.length;s++){e[s]=[];for(var r=0;r<t.arr[0].length;r++){e[s][r]=0;for(var n=0;n<this.arr[0].length;n++)e[s][r]=tt.add(e[s][r],tt.mul(this.arr[s][n],t.arr[n][r]))}}return new gs(this.arr.length,t.arr[0].length,e.flat(1))}static dot(t,e){return t.dot(e)}pow(t){let e=this.clone,s=this.clone;for(let r=0;r<t-1;r++)s=s.dot(e);return s}static pow(t,e){return t.clone.pow(e)}get somme(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t+=this.arr[e][s];return t}get DoesItContainComplexNumbers(){return this.arr.flat(1/0).some((t=>t instanceof ws))}get min(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(W(...this.arr[e]));return W(...t)}get max(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(V(...this.arr[e]));return V(...t)}get minRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(W(...this.arr[e]));return t}get maxRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(V(...this.arr[e]));return t}get minCols(){return this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable"),this.T.minRows}get maxCols(){return this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable"),this.T.maxRows}static fromVector(t){return new gs(t.length,1,t)}get toArray(){let t=[];for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t.push(this.arr[e][s]);return t}get print(){let t="[";for(let e=0;e<this.arr.length;e++)t+=(0!=e?" ":"")+` [${this.arr[e].map((t=>" "+t.toString()+" "))}],\n`;console.log(t.substring(0,t.length-2)+" ]"),document.write(t.substring(0,t.length-2)+" ]")}get table(){console.table(this.arr)}get serialize(){return JSON.stringify(this)}static deserialize(t){"string"==typeof t&&(t=JSON.parse(t));let e=new gs(t.rows,t.cols);return e.arr=t.arr,e}toTable(){var t=new DocumentFragment,e=new Array(this.rows).fill(null).map((()=>document?.createElement("tr"))),s=this.arr.map((t=>t.map((()=>document?.createElement("td")))));for(let t=0;t<s.length;t++)for(let r=0;r<s[0].length;r++)s[t][r].innerHTML=this.arr[t][r],e[t].appendChild(s[t][r]);return e.map((e=>t.appendChild(e))),t}toGrid(t,e={}){let s=Grid();return s.append(...this.map(t).arr.flat(1).map((t=>t.style(e)))),s.Columns(this.cols),s}sortTable(t=0,{type:e="num",order:s="asc"}={}){var r=this.T.arr.map((t=>t.map(((t,e)=>Object.assign({},{x:t,y:e}))))),n=this.T.arr.map((t=>t.map(((t,e)=>Object.assign({},{x:t,y:e})))));"num"===e?"asc"===s?r[t].sort(((t,e)=>t.x-e.x)):"desc"===s?r[t].sort(((t,e)=>e.x-t.x)):"toggle"===s&&(r[t][0].x>r[t][1].x?r[t].sort(((t,e)=>e.x-t.x)):r[t].sort(((t,e)=>t.x-e.x))):"alpha"===e&&("asc"===s?r[t].sort(((t,e)=>(""+t.x).localeCompare(""+e.x))):"desc"===s&&r[t].sort(((t,e)=>(""+e.x).localeCompare(""+t.x)))),s=r[t].map((t=>t.y));for(let e=0;e<r.length;e++)e!==t&&r[e].map(((t,e)=>t.y=s[e]));for(let e=0;e<r.length;e++)e!==t&&n[e].map(((t,n)=>t.x=r[e][s[n]].x));n[t]=r[t];var i=n.map((t=>t.map((t=>t.x))));return new gs(i).T}}const bs=(t,e,s)=>new gs(t,e,s);class ws extends y{constructor(t=0,e=0){super(),t instanceof ws?(this.a=t.a,this.b=t.b):"object"==typeof t?"a"in e&&"b"in t?(this.a=t.a,this.b=t.b):"a"in e&&"z"in t?(this.a=t.a,this.b=_s(t.z**2-t.a**2)):"a"in e&&"phi"in t?(this.a=t.a,this.b=t.a*Ss(t.phi)):"b"in e&&"z"in t?(this.b=t.b,this.a=_s(t.z**2-t.b**2)):"b"in e&&"phi"in t?(this.b=e,this.a=t.b/Ss(t.phi)):"z"in e&&"phi"in t&&(this.a=t.z*Os(t.phi),this.a=t.z*As(t.phi)):"number"==typeof t&&"number"==typeof e&&(this.a=+t.toFixed(32),this.b=+e.toFixed(32))}isComplex(){return!0}toString(){let t="";return t=0!==this.a?this.b>=0?`${this.a}+${this.b}*i`:`${this.a}-${Math.abs(this.b)}*i`:this.b>=0?`${this.b}*i`:`-${Math.abs(this.b)}*i`,t}get clone(){return new ws(this.a,this.b)}get z(){return Ps(this.a,this.b)}get phi(){return Ms(this.b,this.a)}static Zero(){return new ws(0,0)}get conj(){return new ws(this.a,-this.b)}get inv(){return new ws(this.a/(xs(this.a,2)+xs(this.b,2)),-this.b/(xs(this.a,2)+xs(this.b,2)))}add(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new ws(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a+=+Z(...e).toFixed(15),this.b+=+Z(...s).toFixed(15),this}sub(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new ws(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a-=+Z(...e).toFixed(15),this.b-=+Z(...s).toFixed(15),this}mul(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new ws(t[e],0));let e=+q(this.z,...t.map((t=>t.z))).toFixed(15),s=+Z(this.phi,...t.map((t=>t.phi))).toFixed(15);return this.a=+(e*Os(s).toFixed(15)).toFixed(14),this.b=+(e*As(s).toFixed(15)).toFixed(14),this}div(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new ws(t[e],0));let e=+(this.z/q(...t.map((t=>t.z)))).toFixed(15),s=+(this.phi-Z(...t.map((t=>t.phi)))).toFixed(15);return this.a=+(e*Os(s).toFixed(15)).toFixed(15),this.b=+(e*As(s).toFixed(15)).toFixed(15),this}pow(t){if(Is(t)===t&&t>0){let e=+(this.z**t).toFixed(15),s=+(this.phi*t).toFixed(15);this.a=+(e*Os(s).toFixed(15)).toFixed(15),this.b=+(e*As(s).toFixed(15)).toFixed(15)}return this}static fromExpo(t,e){return new ws(+(t*Os(e)).toFixed(13),+(t*As(e)).toFixed(13))}get expo(){return[this.z,this.phi]}static add(t,...e){return t.clone.add(...e)}static sub(t,...e){return t.clone.sub(...e)}static mul(t,...e){return t.clone.mul(...e)}static div(t,...e){return t.clone.div(...e)}static pow(t,e){return t.clone.pow(e)}static xpowZ(t){return ys(t**this.a*Os(this.b*Ts(t)),t**this.a*As(this.b*Ts(t)))}sqrtn(t=2){return ys(Es(this.z,t)*Os(this.phi/t),Es(this.z,t)*As(this.phi/t))}get sqrt(){return this.sqrtn(2)}get log(){return ys(this.z,this.phi)}get cos(){return ys(Os(this.a)*Cs(this.b),As(this.a)*js(this.b))}get sin(){return ys(As(this.a)*Cs(this.b),Os(this.a)*js(this.b))}get tan(){const t=Os(2*this.a)+Cs(2*this.b);return ys(As(2*this.a)/t,js(2*this.b)/t)}printInConsole(){let t=this.a+" + "+this.b+" * i";return console.log(t),t}print(){}UI(){return"<span>"+this.a+" + i * "+this.b+"</span>"}}const ys=(t,e)=>{if((t instanceof Array||ArrayBuffer.isView(t))&&(e instanceof Array||ArrayBuffer.isView(t)))return t.map(((s,r)=>ys(t[r],e[r])));if(t instanceof gs&&e instanceof gs){if(t.shape[0]!==e.shape[0]||t.shape[1]!==e.shape[1])return Error(0);const s=t.arr.map(((s,r)=>ys(t.arr[r],e.arr[r])));return new gs(t.rows,t.cols,...s)}return new ws(t,e)},vs=(...t)=>v(Math.abs,...t),_s=(...t)=>v(Math.sqrt,...t),xs=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,e):e instanceof ws?ws.fromExpo(t**e.a,e.b*Ts(t)):v((e=>xs(t,e)),...e);if(t instanceof ws)return"number"==typeof e?ws.fromExpo(t.z**e,t.phi*e):e instanceof ws?ws.fromExpo(t.z**e.a*ks(-t.phi*e.b),Ts(t.z)*e.b+e.a*t.phi):v((e=>xs(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return v((t=>xs(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(v((e=>xs(t[r],e)),...e));return s}}},Es=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,1/e):v((e=>Es(t,e)),...e);if(t instanceof ws)return"number"==typeof e?ws.fromExpo(Es(t.z,e),t.phi/e):v((e=>Es(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return v((t=>Es(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(v((e=>Es(t[r],e)),...e));return s}}},ks=(...t)=>v(Math.exp,...t),Ts=(...t)=>v(Math.log,...t),Os=(...t)=>v(w.cos,...t),As=(...t)=>v(w.sin,...t),Ss=(...t)=>v(w.tan,...t),Cs=(...t)=>v(w.cosh,...t),js=(...t)=>v(w.sinh,...t),Is=(...t)=>v(Math.floor,...t),Ms=(t,e,s=!0)=>{if("number"==typeof t)return"number"==typeof e?s?Math.atan2(t,e):180*Math.atan2(t,e)/Math.PI:v((e=>Ms(t,e,s)),...e);if(t instanceof Array){if("number"==typeof e)return v((t=>Ms(t,e,s)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(v((e=>xs(t[r],e)),...e));return s}}},Ds=(...t)=>v(Math.sign,...t),Ps=(...t)=>t.every((t=>"number"==typeof t))?Math.hypot(...t):t.every((t=>t instanceof Array))?v(Math.hypot,...t):void 0,{PI:Rs,sqrt:Ls,cos:$s,sin:Ns,acos:Bs,pow:Fs}=Math,Hs=t=>t,zs=(t,e=7.5625,s=2.75)=>t<1/s?e*t*t:t<2/s?e*(t-=1.5/s)*t+.75:t<2.5/s?e*(t-=2.25/s)*t+.9375:e*(t-=2.625/s)*t+.984375;class Us{constructor(t,{ease:e=Hs,step:s=50,t0:r=0,start:n=!0,duration:i=3e3}={}){this.callback=t,this.state={isRunning:!1,animationId:null,startTime:null,ease:e,step:s,autoStart:n,duration:i},this.t=0,this.tx=0,this.ty=0,this.i=0,this.state.autoStart&&this.start()}#i=()=>{this.t+=this.state.step,this.i++,this.tx=L(this.t,0,this.state.duration,0,1),this.ty=this.state.ease(this.tx),this.callback(this),this.t>=this.state.duration&&(clearInterval(this.state.animationId),this.state.isRunning=!1)};#a(t=!0){return this.state.isRunning||(t&&this.reset(!1),this.state.isRunning=!0,this.state.startTime=Date.now(),this.state.animationId=setInterval(this.#i,this.state.step)),this}start(){return this.#a(!0)}pause(){return this.state.isRunning&&(clearInterval(this.state.animationId),this.state.isRunning=!1),this}resume(){return this.#a(!1)}stop(){return this.pause(),this.reset(!1),this}reset(t=!0){return this.t=0,this.tx=0,this.ty=0,this.i=0,t&&this.start(),this}}class Zs{constructor(t,e,s=1/0,r){this.ms=e,this.fn=t,this.count=s,this.frame=1,this.id=null,this.running=!1,r&&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 qs extends Zs{constructor(t=1e3/60){super(t,(()=>this._tick())),this.elapsed=0,this._lastTime=performance.now(),this._callbacks=new Set}_tick(){const t=performance.now(),e=t-this._lastTime;this.elapsed+=e,this._lastTime=t;for(const t of this._callbacks)t({elapsed:this.elapsed,delta:e})}onTick(t){return this._callbacks.add(t),()=>this._callbacks.delete(t)}reset(){this.elapsed=0,this._lastTime=performance.now()}pause(){super.stop()}resume(){this._lastTime=performance.now(),super.start()}}class Ws{constructor(t=[],{repeat:e=1,loop:s=!1}={}){this.tasks=t,this.repeat=e,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 t=this.repeat;do{for(const t of this.tasks){if(this.stopped)return;if(Array.isArray(t))await Promise.all(t.map((({fn:t,delay:e=0})=>new Promise((async s=>{e>0&&await new Promise((t=>setTimeout(t,e))),this.onTask&&this.onTask(t),await t(),s()})))));else{const{fn:e,delay:s=0}=t;s>0&&await new Promise((t=>setTimeout(t,s))),this.onTask&&this.onTask(e),await e()}}}while(this.loop&&!this.stopped&&(t===1/0||t-- >1));!this.stopped&&this.onEnd&&this.onEnd(),this.running=!1}stop(){this.stopped=!0,this.running=!1}addTask(t){this.tasks.push(t)}clearTasks(){this.tasks=[]}}class Vs{constructor(t,{step:e=1e3,t0:s=0,t1:r=1/0,autoplay:n=!0}={}){this.callback=t,this.cache={isRunning:!1,id:null,last_tick:null,step:e,t0:s,t1:r,autoplay:n,pauseTime:null,frame:0},n&&(s?this.startAfter(s):this.start(),r!==1/0&&this.stopAfter(r))}get frame(){return this.cache.frame}get elapsed(){return this.cache.elapsed}start(){return this.cache.isRunning||(this.cache.frame=0,this.cache.isRunning=!0,this.cache.last_tick=Date.now(),this.animate()),this}pause(){return this.cache.isRunning&&(clearTimeout(this.cache.id),this.cache.isRunning=!1,this.cache.pauseTime=Date.now()),this}resume(){if(!this.cache.isRunning){if(this.cache.isRunning=!0,this.cache.pauseTime){const t=Date.now()-this.cache.pauseTime;this.cache.last_tick+=t}this.animate()}return this}stop(){return this.pause(),this.cache.frame=0,this}startAfter(t=1e3){return setTimeout((()=>this.start()),t),this}stopAfter(t=1e3){return setTimeout((()=>this.stop()),t),this}animate=()=>{if(this.cache.isRunning){const t=Date.now(),e=t-this.cache.last_tick;e>=this.cache.step&&(this.cache.elapsed=t-(this.cache.t0||0),this.callback(this),this.cache.frame++,this.cache.last_tick=t-e%this.cache.step),this.cache.id=setTimeout(this.animate,0)}}}class Gs{constructor({head:t=null,wrapper:e=null,target:s=null}){this.head=t,this.wrapper=e,this.target=s,this.init()}get isZikoApp(){return!0}init(){this.head&&this.setHead(this.head),this.wrapper&&this.setWrapper(this.wrapper),this.target&&this.setTarget(this.target),this.wrapper&&this.target&&this.wrapper.render(this.target)}setTarget(t){return t instanceof HTMLElement?this.target=t:"string"==typeof t&&(this.target=globalThis?.document?.querySelector(t)),this}setWrapper(t){return t?.isUIElement?this.wrapper=t:"function"==typeof t&&(this.wrapper=t()),this}setHead(t){return this.head=t instanceof qe?t:We(t),this}}function Ks(t){return/:\w+/.test(t)}class Xs extends Gs{constructor({head:t,wrapper:e,target:s,routes:r}){super({head:t,wrapper:e,target:s}),this.routes=new Map([["404",jt("Error 404")],...Object.entries(r)]),this.clear(),globalThis.onpopstate=this.render(location.pathname)}clear(){return[...this.routes].forEach((t=>{!Ks(t[0])&&t[1]?.isUIElement&&t[1].unrender()})),this}render(t){const[e,s]=[...this.routes].find((e=>function(t,e){const s=t.split("/"),r=e.split("/");if(s.length!==r.length)return!1;for(let t=0;t<s.length;t++){const e=s[t],n=r[t];if(!e.startsWith(":")&&e!==n)return!1}return!0}(e[0],t)));let r;if(Ks(e)){const n=function(t,e){const s=t.split("/"),r=e.split("/"),n={};if(s.length!==r.length)return n;for(let t=0;t<s.length;t++){const e=s[t],i=r[t];if(e.startsWith(":"))n[e.slice(1)]=i;else if(e!==i)return{}}return n}(e,t);r=s.call(this,n)}else s?.isUIElement&&s.render(this.wrapper),"function"==typeof s&&(r=s());return r?.isUIElement&&r.render(this.wrapper),r instanceof Promise&&r.then((t=>t.render(this.wrapper))),globalThis.history.pushState({},"",t),this}}const Ys=({head:t,wrapper:e,target:s,routes:r})=>new Xs({head:t,wrapper:e,target:s,routes:r});function Qs(t,e="./src/pages",s=["js","ts"]){"/"===e.at(-1)&&(e=e.slice(0,-1));const r=t.replace(/\\/g,"/").replace(/\[(\w+)\]/g,"$1/:$1").split("/"),n=e.split("/"),i=r.indexOf(n.at(-1));if(-1!==i){const t=r.slice(i+1),e=r.at(-1),n="index.js"===e||"index.ts"===e,a=s.some((t=>e===`.${t}`||e.endsWith(`.${t}`)));if(n)return"/"+(t.length>1?t.slice(0,-1).join("/"):"");if(a)return"/"+t.join("/").replace(/\.(js|ts)$/,"")}return""}class Js{constructor(t=""){this.channel=new BroadcastChannel(t),this.EVENTS_DATAS_PAIRS=new Map,this.EVENTS_HANDLERS_PAIRS=new Map,this.LAST_RECEIVED_EVENT="",this.UUID="ziko-channel"+nt.string(10),this.SUBSCRIBERS=new Set([this.UUID])}get broadcast(){return this}emit(t,e){return this.EVENTS_DATAS_PAIRS.set(t,e),this.#o(t),this}on(t,e=console.log){return this.EVENTS_HANDLERS_PAIRS.set(t,e),this.#h(),this}#h(){return this.channel.onmessage=t=>{this.LAST_RECEIVED_EVENT=t.data.last_sended_event;const e=t.data.userId;this.SUBSCRIBERS.add(e);const s=t.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT),r=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT);s&&r&&r(s)},this}#o(t){return this.channel.postMessage({EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,last_sended_event:t,userId:this.UUID}),this}close(){return this.channel.close(),this}}const tr=t=>new Js(t);class er{#c;constructor(){this.#c=function(t){try{let e=new Function("return "+t.data.fun)()();postMessage({result:e})}catch(t){postMessage({error:t.message})}finally{t.data.close&&self.close()}}.toString(),this.blob=new Blob(["this.onmessage = "+this.#c],{type:"text/javascript"}),this.worker=new Worker(window.URL.createObjectURL(this.blob))}call(t,e,s=!0){return this.worker.postMessage({fun:t.toString(),close:s}),this.worker.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data.result)},this}}class sr{constructor(t,{namespace:e="Ziko",register:s,ValidateCssProps:r=!1}={}){this.currentPropsMap=t,this.namespace=e,this.ValidateCssProps=r,this.use(t)}use(t){return this.ValidateCssProps&&function(t){const e=new Set(Object.keys(document.documentElement.style));for(let s in t)if(!e.has(s))throw new Error(`Invalid CSS property: "${s}"`)}(t),this.currentPropsMap=t,this.#s(),this}#s(){const t=globalThis?.document?.documentElement?.style;for(let e in this.currentPropsMap){const s=this.namespace?`--${this.namespace}-${e}`:`--${e}`;t.setProperty(s,this.currentPropsMap[e]),Object.defineProperty(this,e,{value:`var(${s})`,writable:!0,configurable:!0,enumerable:!1})}}}class rr{constructor(t,e,s){this.cache={storage:t,globalKey:e,channel:tr(`Ziko:useStorage-${e}`),oldItemKeys:new Set},this.#e(s),this.#s()}get items(){return JSON.parse(this.cache.storage[this.cache.globalKey]??null)}#s(){for(let t in this.items)Object.assign(this,{[[t]]:this.items[t]})}#e(t){this.cache.channel=tr(`Ziko:useStorage-${this.cache.globalKey}`),this.cache.channel.on("Ziko-Storage-Updated",(()=>this.#s())),t&&(this.cache.storage[this.cache.globalKey]?(Object.keys(this.items).forEach((t=>this.cache.oldItemKeys.add(t))),console.group("Ziko:useStorage"),console.warn(`Storage key '${this.cache.globalKey}' already exists. we will not overwrite it.`),console.info("%cWe'll keep the existing data.","background-color:#2222dd; color:gold;"),console.group("")):this.set(t))}set(t){return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(t)),this.cache.channel.emit("Ziko-Storage-Updated",{}),Object.keys(t).forEach((t=>this.cache.oldItemKeys.add(t))),this.#s(),this}add(t){const e={...this.items,...t};return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(e)),this.#s(),this}remove(...t){const e={...this.items};for(let s=0;s<t.length;s++)delete e[t[s]],delete this[t[s]];return this.set(e),this}get(t){return this.items[t]}clear(){return this.cache.storage.removeItem(this.cache.globalKey),this.#s(),this}}let{sqrt:nr,cos:ir,sin:ar,exp:or,log:hr,cosh:cr,sinh:lr}=Math;for(const t of Object.getOwnPropertyNames(Math)){const e=Math[t];"function"==typeof e&&(Math[t]=new Proxy(e,{apply(e,s,r){const n=r[0];if("number"==typeof n||0===r.length)return e.apply(s,r);if(n?.isComplex?.()){const{a:t,b:i,z:a,phi:o}=n,h=(t,e)=>new n.constructor(t,e);switch(e.name){case"abs":return n.z;case"sqrt":return h(nr(a)*ir(o/2),nr(a)*ar(o/2));case"log":return h(hr(a),o);case"exp":return h(or(t)*ir(i),or(t)*ar(i));case"cos":return h(ir(t)*cr(i),-ar(t)*lr(i));case"sin":return h(ar(t)*cr(i),ir(t)*lr(i));case"tan":{const e=ir(2*t)+cr(2*i);return h(ar(2*t)/e,lr(2*i)/e)}case"cosh":return h(cr(t)*ir(i),lr(t)*ar(i));case"sinh":return h(lr(t)*ir(i),cr(t)*ar(i));case"tanh":{const e=cr(2*t)+ir(2*i);return h(lr(2*t)/e,ar(2*i)/e)}default:return e.apply(s,r)}}throw new TypeError(`Math.${t} expects only numbers`)}}))}globalThis?.document&&document?.addEventListener("DOMContentLoaded",__Ziko__.__Config__.init()),t.App=({head:t,wrapper:e,target:s})=>new Gs({head:t,wrapper:e,target:s}),t.Arc=t=>1-Ns(Bs(t)),t.Back=(t,e=1)=>t**2*((e+1)*t-e),t.Base=et,t.Clock=qs,t.Combinaison=rt,t.Complex=ws,t.Discret=(t,e=5)=>Math.ceil(t*e)/e,t.E=s,t.EPSILON=r,t.Elastic=t=>-2*Fs(2,10*(t-1))*$s(20*Rs*t/3*t),t.FileBasedRouting=async function(t){const e=Object.keys(t),s=function(t){if(0===t.length)return"";const e=t.map((t=>t.split("/"))),s=Math.min(...e.map((t=>t.length)));let r=[];for(let t=0;t<s;t++){const s=e[0][t];if(!e.every((e=>e[t]===s||e[t].startsWith("["))))break;r.push(s)}return r.join("/")+(r.length?"/":"")}(e),r={};for(let n=0;n<e.length;n++){const i=await t[e[n]](),a=await i.default;Object.assign(r,{[Qs(e[n],s)]:a})}return Ys({target:document.body,routes:{"/":()=>{},...r},wrapper:Ye.section()})},t.Flex=(...t)=>{let e="div";return"string"==typeof t[0]&&(e=t[0],t.pop()),new Qe(e).append(...t)},t.HTMLWrapper=t=>new is(t),t.InBack=(t,e=1.70158,s=e+1)=>s*Fs(t,3)-e*t**2,t.InBounce=(t,e=7.5625,s=2.75)=>1-zs(1-t,e,s),t.InCirc=t=>1-Ls(1-t**2),t.InCubic=t=>t**3,t.InElastic=(t,e=2*Rs/3)=>0===t?0:1===t?1:-Fs(2,10*t-10)*Ns((10*t-10.75)*e),t.InExpo=t=>0===t?0:2**(10*t-10),t.InOutBack=(t,e=1.70158,s=1.525*e)=>t<.5?Fs(2*t,2)*(2*(s+1)*t-s)/2:(Fs(2*t-2,2)*((s+1)*(2*t-2)+s)+2)/2,t.InOutBounce=(t,e=7.5625,s=2.75)=>t<.5?zs(1-2*t,e,s)/2:zs(2*t-1,e,s)/2,t.InOutCirc=t=>t<.5?(1-Ls(1-(2*t)**2))/2:(Ls(1-(-2*t+2)**2)+1)/2,t.InOutCubic=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,t.InOutElastic=(t,e=2*Rs/4.5)=>0===t?0:1===t?1:t<.5?-Fs(2,20*t-10)*Ns((20*t-11.125)*e)/2:Fs(2,-20*t+10)*Ns((20*t-11.125)*e)/2+1,t.InOutExpo=t=>0===t?0:1===t?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,t.InOutQuad=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,t.InOutQuart=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,t.InOutQuint=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,t.InOutSin=t=>-($s(Rs*t)-1)/2,t.InQuad=t=>t**2,t.InQuart=t=>t**4,t.InQuint=t=>t**5,t.InSin=t=>1-$s(t*Rs/2),t.Linear=Hs,t.Logic=st,t.Matrix=gs,t.OutBack=(t,e=1.70158,s=e+1)=>1+s*Fs(t-1,3)+e*Fs(t-1,2),t.OutBounce=zs,t.OutCirc=t=>Ls(1-(t-1)**2),t.OutCubic=t=>1-(1-t)**3,t.OutElastic=(t,e=2*Rs/3)=>0===t?0:1===t?1:Fs(2,-10*t)*Ns((10*t-.75)*e)+1,t.OutExpo=t=>1===t?1:1-2**(-10*t),t.OutQuad=t=>1-(1-t)**2,t.OutQuart=t=>1-(1-t)**4,t.OutQuint=t=>1-(1-t)**5,t.OutSin=t=>Ns(t*Rs/2),t.PI=e,t.Permutation=class{static withDiscount(t,e=t.length){if(1===e)return t.map((t=>[t]));const s=[];let r;return r=this.withDiscount(t,e-1),t.forEach((t=>{r.forEach((e=>{s.push([t].concat(e))}))})),s}static withoutDiscount(t){if(1===t.length)return t.map((t=>[t]));const e=[],s=this.withoutDiscount(t.slice(1)),r=t[0];for(let t=0;t<s.length;t++){const n=s[t];for(let t=0;t<=n.length;t++){const s=n.slice(0,t),i=n.slice(t);e.push(s.concat([r],i))}}return e}},t.Random=nt,t.SPA=Ys,t.SVGWrapper=t=>new as(t),t.Scheduler=(t,{repeat:e=null}={})=>new Ws(t,{repeat:e}),t.Step=(t,e=5)=>Math.floor(t*e)/e,t.Suspense=(t,e)=>new ns(t,e),t.Switch=({key:t,cases:e})=>new os(t,e),t.Tick=Zs,t.TimeAnimation=Us,t.TimeLoop=Vs,t.TimeScheduler=Ws,t.UIElement=Ge,t.UIHTMLWrapper=is,t.UINode=dt,t.UISVGWrapper=as,t.UISwitch=os,t.Utils=tt,t.ZikoApp=Gs,t.ZikoCustomEvent=Ae,t.ZikoEventClick=Bt,t.ZikoEventClipboard=zt,t.ZikoEventCustom=qt,t.ZikoEventDrag=Vt,t.ZikoEventFocus=Xt,t.ZikoEventInput=Ee,t.ZikoEventKey=ee,t.ZikoEventMouse=ne,t.ZikoEventPointer=oe,t.ZikoEventSwipe=Ce,t.ZikoEventTouch=le,t.ZikoEventWheel=me,t.ZikoHead=qe,t.ZikoMutationObserver=Ie,t.ZikoSPA=Xs,t.ZikoUIFlex=Qe,t.ZikoUISuspense=ns,t.ZikoUIText=Ct,t.ZikoUseRoot=sr,t.__ZikoEvent__=Nt,t.abs=vs,t.accum=G,t.acos=(...t)=>v(w.acos,...t),t.acosh=(...t)=>v(w.acosh,...t),t.acot=(...t)=>v(w.acot,...t),t.add=O,t.animation=(t,{ease:e,t0:s,t1:r,start:n,duration:i}={})=>new Us(t,{ease:e,t0:s,t1:r,start:n,duration:i}),t.arange=N,t.arr2str=ps,t.asin=(...t)=>v(w.asin,...t),t.asinh=(...t)=>v(w.asinh,...t),t.atan=(...t)=>v(w.atan,...t),t.atan2=Ms,t.atanh=(...t)=>v(w.atanh,...t),t.bindCustomEvent=(t,e,s)=>new qt(t,e,s),t.bindHashEvent=(t,e)=>new Jt(t,e),t.bindTouchEvent=(t,e)=>new le(t,e),t.bind_click_event=Ht,t.bind_clipboard_event=Zt,t.bind_drag_event=Kt,t.bind_focus_event=Qt,t.bind_key_event=re,t.bind_mouse_event=ae,t.bind_pointer_event=ce,t.bind_wheel_event=fe,t.cartesianProduct=Y,t.ceil=(...t)=>v(Math.ceil,...t),t.clamp=$,t.clock=t=>new qs(t),t.combinaison=(t,e,s=!1)=>rt[s?"withDiscount":"withoutDiscount"](t,e),t.complex=ys,t.cos=Os,t.cosh=Cs,t.cot=(...t)=>v(w.cot,...t),t.coth=(...t)=>v(w.coth,...t),t.csc=(...t)=>v(w.csc,...t),t.csv2arr=at,t.csv2json=(t,e=",")=>JSON.stringify(ot(t,e)),t.csv2matrix=(t,e=",")=>new gs(at(t,e)),t.csv2object=ot,t.csv2sql=(t,e)=>{const s=t.trim().trimEnd().split("\n").filter((t=>t));let r=`INSERT INTO ${e} (${s[0].split(",").join(", ")}) Values `,n=[];for(let t=1;t<s.length;t++){const e=s[t].split(",");n.push(`(${e})`)}return r+n.join(",\n")},t.debounce=(t,e=1e3)=>(...s)=>setTimeout((()=>t(...s)),e),t.defineParamsGetter=function(t){Object.defineProperties(t,{QueryParams:{get:function(){return function(t){const e={};return t.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi,(t=>{const[s,r]=t.split("=");e[s]=r})),e}(globalThis.location.search.substring(1))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}})},t.define_wc=function(t,e,s={},{mode:r="open"}={}){globalThis.customElements?.get(t)?console.warn(`Custom element "${t}" is already defined`):-1!==t.search("-")?globalThis.customElements?.define(t,class extends HTMLElement{static get observedAttributes(){return["style",...Object.keys(s)]}constructor(){super(),this.attachShadow({mode:r}),this.props={},this.mask={...s}}connectedCallback(){this.render()}render(){this.shadowRoot.innerHTML="",this.UIElement=e(this.props).render(this.shadowRoot)}attributeChangedCallback(t,e,s){Object.assign(this.props,{[t]:this.mask[t].type(s)}),this.render()}}):console.warn(`"${t}" is not a valid custom element name`)},t.deg2rad=z,t.div=C,t.e=ks,t.fact=(...t)=>v((t=>{let e,s=1;if(0==t)s=1;else if(t>0)for(e=1;e<=t;e++)s*=e;else s=NaN;return s}),...t),t.floor=Is,t.geomspace=H,t.getEvent=Lt,t.hypot=Ps,t.inRange=K,t.isApproximatlyEqual=X,t.isStateGetter=Ot,t.json2arr=t=>ht(t instanceof Object?t:JSON.parse(t)),t.json2css=fs,t.json2csv=lt,t.json2csvFile=(t,e)=>{const s=lt(t,e),r=new Blob([s],{type:"text/csv;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2xml=ft,t.json2xmlFile=(t,e)=>{const s=ft(t,e),r=new Blob([s],{type:"text/xml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2yml=pt,t.json2ymlFile=(t,e)=>{const s=pt(t,e),r=new Blob([s],{type:"text/yml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.lerp=R,t.linspace=B,t.ln=Ts,t.logspace=F,t.loop=(t,e={})=>new Vs(t,e),t.map=L,t.mapfun=v,t.matrix=bs,t.matrix2=(...t)=>new gs(2,2,t),t.matrix3=(...t)=>new gs(3,3,t),t.matrix4=(...t)=>new gs(4,4,t),t.max=V,t.min=W,t.modulo=j,t.mul=S,t.norm=P,t.nums=D,t.obj2str=us,t.ones=M,t.pgcd=Q,t.pow=xs,t.powerSet=t=>{const e=[],s=2**t.length;for(let r=0;r<s;r+=1){const s=[];for(let e=0;e<t.length;e+=1)r&1<<e&&s.push(t[e]);e.push(s)}return e},t.ppcm=J,t.preload=it,t.prod=q,t.rad2deg=U,t.round=(...t)=>v(Math.round,...t),t.sec=(...t)=>v(w.sec,...t),t.sig=(...t)=>v((t=>1/(1+ks(-t))),...t),t.sign=Ds,t.sin=As,t.sinc=(...t)=>v(w.sinc,...t),t.sinh=js,t.sleep=t=>new Promise((e=>setTimeout(e,t))),t.sqrt=_s,t.sqrtn=Es,t.step_fps=t=>1e3/t,t.sub=A,t.subSet=null,t.sum=Z,t.svg2ascii=cs,t.svg2img=(t,e=!0)=>Ye.img(ls(t)).render(e),t.svg2imgUrl=ls,t.svg2str=hs,t.tags=Ye,t.tan=Ss,t.tanh=(...t)=>v(w.tanh,...t),t.text=jt,t.throttle=(t,e)=>{let s=0;return(...r)=>{const n=(new Date).getTime();n-s<e||(s=n,t(...r))}},t.tick=(t,e,s=1/0,r=!0)=>new Zs(t,e,s,r),t.timeTaken=t=>{console.time("timeTaken");const e=t();return console.timeEnd("timeTaken"),e},t.time_memory_Taken=t=>{const e=Date.now(),s=performance.memory.usedJSHeapSize,r=t();return{elapsedTime:Date.now()-e,usedMemory:performance.memory.usedJSHeapSize-s,result:r}},t.timeout=function(t,e){let s;const r=new Promise((r=>{s=setTimeout((()=>{e&&e(),r()}),t)}));return{id:s,clear:()=>clearTimeout(s),promise:r}},t.useChannel=tr,t.useCustomEvent=Se,t.useDerived=function(t,e){let s=t(...e.map((t=>t().value)));const r=new Set;return e.forEach((n=>{n()._subscribe((()=>{{const n=t(...e.map((t=>t().value)));n!==s&&(s=n,r.forEach((t=>t(s))))}}))})),()=>({value:s,isStateGetter:()=>!0,_subscribe:t=>r.add(t)})},t.useEventEmitter=Ne,t.useFavIcon=Fe,t.useHashEvent=t=>new Te(t),t.useHead=We,t.useInputEvent=t=>new Ee(t),t.useLocaleStorage=(t,e)=>new rr(localStorage,t,e),t.useMediaQuery=(t,e)=>new Ve(t,e),t.useMeta=ze,t.useReactive=t=>v((t=>{const e=Tt(t);return{get:e[0],set:e[1]}}),t),t.useRoot=(t,{namespace:e,register:s,ValidateCssProps:r}={})=>new sr(t,{namespace:e,register:s,ValidateCssProps:r}),t.useSessionStorage=(t,e)=>new rr(sessionStorage,t,e),t.useState=Tt,t.useSuccesifKeys=(t,e=[],s=(()=>{}))=>{t.cache.stream.enabled.down=!0;const r=e.length,n=t.cache.stream.history.down.slice(-r).map((t=>t.key));e.join("")===n.join("")&&(t.event.preventDefault(),s.call(t,t))},t.useSwipeEvent=(t,e,s)=>new Ce(t,e,s),t.useThread=(t,e,s)=>{const r=new er;return t&&r.call(t,e,s),r},t.useTitle=Ze,t.wait=t=>new Promise((e=>setTimeout(e,t))),t.waitForUIElm=t=>new Promise((e=>{if(t.element)return e(t.element);const s=new MutationObserver((()=>{t.element&&(e(t.element),s.disconnect())}));s.observe(document?.body,{childList:!0,subtree:!0})})),t.waitForUIElmSync=(t,e=2e3)=>{const s=Date.now();for(;Date.now()-s<e;)if(t.element)return t.element},t.watch=(t,e={},s=null)=>{const r=new Ie(t,e);return s&&r.observe(s),r},t.watchAttr=(t,e)=>new Me(t,e),t.watchChildren=(t,e)=>new De(t,e),t.watchIntersection=(t,e,s)=>new Pe(t,e,s),t.watchScreen=t=>new Le(t),t.watchSize=(t,e)=>new Re(t,e),t.zeros=I}));
package/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Wed Sep 03 2025 15:22:46 GMT+0100 (UTC+01:00)
5
+ Date : Thu Sep 04 2025 20:47:52 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
@@ -1207,11 +1207,11 @@ class UIElementCore extends UINode{
1207
1207
  switch(type){
1208
1208
  case "html" : {
1209
1209
  element = globalThis?.document?.createElement(element);
1210
- console.log('1');
1210
+ // console.log('1')
1211
1211
  } break;
1212
1212
  case "svg" : {
1213
1213
  element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
1214
- console.log('2');
1214
+ // console.log('2')
1215
1215
  } break;
1216
1216
  default : throw Error("Not supported")
1217
1217
  }
@@ -1673,6 +1673,13 @@ function unrender(){
1673
1673
  else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
1674
1674
  return this;
1675
1675
  }
1676
+ function replaceElementWith(new_element){
1677
+ this.cache.element.replaceWith(new_element);
1678
+ this.cache.element = new_element;
1679
+
1680
+ // To do : Dispose Events and States
1681
+ return this
1682
+ }
1676
1683
  function renderAfter(t = 1) {
1677
1684
  setTimeout(() => this.render(), t);
1678
1685
  return this;
@@ -1703,6 +1710,7 @@ var DomMethods = /*#__PURE__*/Object.freeze({
1703
1710
  remove: remove,
1704
1711
  render: render,
1705
1712
  renderAfter: renderAfter,
1713
+ replaceElementWith: replaceElementWith,
1706
1714
  unrender: unrender,
1707
1715
  unrenderAfter: unrenderAfter
1708
1716
  });
@@ -3134,7 +3142,7 @@ let UIElement$1 = class UIElement extends UIElementCore{
3134
3142
  IndexingMethods,
3135
3143
  EventsMethodes
3136
3144
  );
3137
- this.init(element, name, type, render);
3145
+ if(element)this.init(element, name, type, render);
3138
3146
  }
3139
3147
  get element(){
3140
3148
  return this.cache.element;
@@ -3698,6 +3706,38 @@ function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
3698
3706
  );
3699
3707
  }
3700
3708
 
3709
+ class UISwitch extends UIElement$1{
3710
+ constructor(key, cases){
3711
+ super();
3712
+ this.key = key;
3713
+ this.cases = cases;
3714
+ this.init();
3715
+ }
3716
+ init(){
3717
+ Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender());
3718
+ super.init(this.current.element);
3719
+ }
3720
+ get current(){
3721
+ const matched = Object.keys(this.cases).find(n => n == this.key) ?? 'default';
3722
+ return this.cases[matched]
3723
+ }
3724
+ updateKey(key){
3725
+ this.key = key;
3726
+ this.replaceElementWith(this.current.element);
3727
+ // this.cache.element.replaceWith(this.current.element)
3728
+ // this.cache.element = this.current.element;
3729
+ return this;
3730
+ }
3731
+
3732
+ }
3733
+
3734
+ const Switch=({key, cases})=> new UISwitch(key, cases);
3735
+
3736
+ // export const Switch=({key, cases}) => {
3737
+ // const matched = Object.keys(cases).find(n => n == key) ?? 'default';
3738
+ // return this.cases[matched]()
3739
+ // }
3740
+
3701
3741
  const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
3702
3742
  const svg2ascii=svg=>btoa(svg2str(svg));
3703
3743
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
@@ -5892,4 +5932,4 @@ if(globalThis?.document){
5892
5932
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5893
5933
  }
5894
5934
 
5895
- export { App, Arc, Back, Base, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
5935
+ export { App, Arc, Back, Base, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "0.45.3",
3
+ "version": "0.45.4",
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",
@@ -47,6 +47,13 @@ export function unrender(){
47
47
  else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
48
48
  return this;
49
49
  }
50
+ export function replaceElementWith(new_element){
51
+ this.cache.element.replaceWith(new_element)
52
+ this.cache.element = new_element;
53
+
54
+ // To do : Dispose Events and States
55
+ return this
56
+ }
50
57
  export function renderAfter(t = 1) {
51
58
  setTimeout(() => this.render(), t);
52
59
  return this;
@@ -28,7 +28,7 @@ class UIElement extends UIElementCore{
28
28
  IndexingMethods,
29
29
  EventsMethodes
30
30
  );
31
- this.init(element, name, type, render)
31
+ if(element)this.init(element, name, type, render)
32
32
  }
33
33
  get element(){
34
34
  return this.cache.element;
@@ -11,11 +11,11 @@ class UIElementCore extends UINode{
11
11
  switch(type){
12
12
  case "html" : {
13
13
  element = globalThis?.document?.createElement(element);
14
- console.log('1')
14
+ // console.log('1')
15
15
  }; break;
16
16
  case "svg" : {
17
17
  element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
18
- console.log('2')
18
+ // console.log('2')
19
19
  }; break;
20
20
  default : throw Error("Not supported")
21
21
  }
package/src/ui/index.js CHANGED
@@ -7,4 +7,5 @@ export * from './flex/index.js';
7
7
  export * from './suspense/index.js';
8
8
  export * from './wrappers/index.js';
9
9
  // export * from './graphics/index.js'
10
- export * from './web-component/index.js'
10
+ export * from './web-component/index.js'
11
+ export * from './logic/index.js'
@@ -0,0 +1 @@
1
+ export * from './switch/index.js'
@@ -1,16 +1,26 @@
1
1
  import { UIElement } from "../../constructors/UIElement.js";
2
2
 
3
- class UISwitch{
3
+ class UISwitch extends UIElement{
4
4
  constructor(key, cases){
5
+ super()
5
6
  this.key = key;
6
7
  this.cases = cases;
8
+ this.init()
7
9
  }
8
- current_ui(){
10
+ init(){
11
+ Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender())
12
+ super.init(this.current.element)
13
+ }
14
+ get current(){
9
15
  const matched = Object.keys(this.cases).find(n => n == this.key) ?? 'default'
10
- return this.cases[matched]()
16
+ return this.cases[matched]
11
17
  }
12
18
  updateKey(key){
13
- this.key
19
+ this.key = key;
20
+ this.replaceElementWith(this.current.element)
21
+ // this.cache.element.replaceWith(this.current.element)
22
+ // this.cache.element = this.current.element;
23
+ return this;
14
24
  }
15
25
 
16
26
  }