ziko 0.49.7 → 0.50.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/ziko.cjs +817 -976
  2. package/dist/ziko.js +817 -976
  3. package/dist/ziko.min.js +2 -2
  4. package/dist/ziko.mjs +808 -961
  5. package/package.json +4 -1
  6. package/src/{reactivity → --reactivity-deprecated}/hooks/index.js +3 -3
  7. package/src/{reactivity → --reactivity-deprecated}/index.js +1 -1
  8. package/src/__ziko__/__state__.js +1 -1
  9. package/src/app/ziko-app.js +6 -6
  10. package/src/data/api/fetchdom.js +27 -11
  11. package/src/events/binders/custom-event.js +12 -8
  12. package/src/events/binders/index.js +97 -13
  13. package/src/events/custom-events-registry/index.js +3 -0
  14. package/src/events/custom-events-registry/swipe.js +76 -0
  15. package/src/events/custom-events-registry/view.js +74 -0
  16. package/src/events/details-setter/index.js +2 -0
  17. package/src/events/details-setter/key.js +14 -0
  18. package/src/events/{binders → details-setter}/pointer.js +1 -15
  19. package/src/events/{__Events__.js → events-map/index.js} +16 -4
  20. package/src/events/index.js +1 -1
  21. package/src/events/types/__Shared__.d.ts +3 -3
  22. package/src/events/types/clipboard.d.ts +2 -2
  23. package/src/events/types/focus.d.ts +2 -2
  24. package/src/events/types/pointer.d.ts +2 -2
  25. package/src/events/utils.js +31 -0
  26. package/src/events/ziko-event.js +108 -0
  27. package/src/hooks/index.js +1 -1
  28. package/src/hooks/{use-channel.js → use-ipc.js} +3 -3
  29. package/src/hooks/use-storage.js +2 -2
  30. package/src/index.js +1 -1
  31. package/src/ui/__methods__/dom.js +0 -20
  32. package/src/ui/__methods__/events.js +26 -8
  33. package/src/ui/__methods__/index.js +3 -0
  34. package/src/ui/__methods__/lifecycle.js +54 -0
  35. package/src/ui/constructors/UIElement.js +8 -32
  36. package/src/ui/constructors/UIElementCore.js +3 -136
  37. package/src/ui/{constructors/UIElement-lite.js → mini/UIElement.js} +1 -1
  38. package/src/ui/suspense/index.js +1 -2
  39. package/types/data/api/index.d.ts +15 -0
  40. package/types/data/index.d.ts +1 -0
  41. package/types/data/string/checkers.d.ts +51 -0
  42. package/types/data/string/converters.d.ts +101 -0
  43. package/types/data/string/index.d.ts +2 -0
  44. package/types/hooks/index.d.ts +1 -1
  45. package/types/hooks/{use-channel.d.ts → use-ipc.d.ts} +2 -2
  46. package/types/index.d.ts +2 -1
  47. package/src/events/__ZikoEvent__.js +0 -165
  48. package/src/events/binders/click.js +0 -20
  49. package/src/events/binders/clipboard.js +0 -16
  50. package/src/events/binders/drag.js +0 -16
  51. package/src/events/binders/focus.js +0 -16
  52. package/src/events/binders/hash.js +0 -16
  53. package/src/events/binders/key.js +0 -27
  54. package/src/events/binders/mouse.js +0 -16
  55. package/src/events/binders/touch.js +0 -16
  56. package/src/events/binders/wheel.js +0 -16
  57. package/src/events/custom-events/index.js +0 -1
  58. package/src/events/custom-events/swipe.js +0 -58
  59. package/src/events/custom-events/view.js +0 -43
  60. package/src/events/index.d.ts.txt +0 -3
  61. /package/src/{reactivity → --reactivity-deprecated}/events/Input.js +0 -0
  62. /package/src/{reactivity → --reactivity-deprecated}/events/ZikoEvent.js +0 -0
  63. /package/src/{reactivity → --reactivity-deprecated}/events/__note__ +0 -0
  64. /package/src/{reactivity → --reactivity-deprecated}/events/custom-event.js +0 -0
  65. /package/src/{reactivity → --reactivity-deprecated}/events/hash.js +0 -0
  66. /package/src/{reactivity → --reactivity-deprecated}/events/index.js +0 -0
  67. /package/src/{reactivity → --reactivity-deprecated}/events/media.js +0 -0
  68. /package/src/{reactivity → --reactivity-deprecated}/events/mouse.js +0 -0
  69. /package/src/{reactivity → --reactivity-deprecated}/events/swipe.js +0 -0
  70. /package/src/{reactivity → --reactivity-deprecated}/events/touch.js +0 -0
  71. /package/src/{reactivity → --reactivity-deprecated}/hooks/Contexte/index.js +0 -0
  72. /package/src/{reactivity → --reactivity-deprecated}/hooks/Contexte/useSuccesifKeys.js +0 -0
  73. /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/index.js +0 -0
  74. /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useCssLink.js +0 -0
  75. /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useLinearGradient.js +0 -0
  76. /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useMediaQuery.js +0 -0
  77. /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useRadialGradient.js +0 -0
  78. /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useRoot.js +0 -0
  79. /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useStyle.js +0 -0
  80. /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useTheme.js +0 -0
  81. /package/src/{reactivity → --reactivity-deprecated}/hooks/head/_useCssText.js +0 -0
  82. /package/src/{reactivity → --reactivity-deprecated}/hooks/head/index.js +0 -0
  83. /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useFavIcon.js +0 -0
  84. /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useHead.js +0 -0
  85. /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useMeta.js +0 -0
  86. /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useTitle.js +0 -0
  87. /package/src/{reactivity → --reactivity-deprecated}/hooks/todo.md +0 -0
  88. /package/src/{reactivity → --reactivity-deprecated}/idea +0 -0
  89. /package/src/{reactivity → --reactivity-deprecated}/observer/attributes.js +0 -0
  90. /package/src/{reactivity → --reactivity-deprecated}/observer/children.js +0 -0
  91. /package/src/{reactivity → --reactivity-deprecated}/observer/index.js +0 -0
  92. /package/src/{reactivity → --reactivity-deprecated}/observer/intersection.js +0 -0
  93. /package/src/{reactivity → --reactivity-deprecated}/observer/mutation.js +0 -0
  94. /package/src/{reactivity → --reactivity-deprecated}/observer/resize.js +0 -0
  95. /package/src/{reactivity → --reactivity-deprecated}/observer/screen.js +0 -0
  96. /package/src/{reactivity → --reactivity-deprecated}/observer/screen.js.txt +0 -0
  97. /package/src/{reactivity → --reactivity-deprecated}/observer/screen.txt +0 -0
  98. /package/src/{use → --use-deprecated}/index.js +0 -0
  99. /package/src/{use → --use-deprecated}/use-channel.js.txt +0 -0
  100. /package/src/{use → --use-deprecated}/use-event-emmiter.js.txt +0 -0
  101. /package/src/{use → --use-deprecated}/use-favicon.js +0 -0
  102. /package/src/{use → --use-deprecated}/use-link.js +0 -0
  103. /package/src/{use → --use-deprecated}/use-meta.js +0 -0
  104. /package/src/{use → --use-deprecated}/use-root.js +0 -0
  105. /package/src/{use → --use-deprecated}/use-storage.js.txt +0 -0
  106. /package/src/{use → --use-deprecated}/use-thread.js +0 -0
  107. /package/src/{use → --use-deprecated}/use-title.js +0 -0
  108. /package/src/events/{custom-events → custom-events-registry}/click-away.js +0 -0
package/dist/ziko.min.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  Project: ziko.js
3
3
  Author: Zakaria Elalaoui
4
- Date : Sat Nov 29 2025 19:48:11 GMT+0100 (UTC+01:00)
4
+ Date : Wed Dec 03 2025 10:48:15 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:c,asin:h,atan:l,cosh:u,sinh:f,tanh:m,acosh:p,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:c,asin:h,atan:l,acot:t=>n/2-l(t),cosh:u,sinh:f,tanh:m,coth:t=>.5*b((1+t)/(1-t)),acosh:p,asinh:d,atanh:g};w=new Proxy(w,{get(t,e){if(e in t)return s=>+t[e](s).toFixed(15)}});const y=(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=>y(t,e)));if(ArrayBuffer.isView(e))return e.map((e=>t(e)));if(e instanceof Set)return new Set(y(t,...e));if(e instanceof Map)return new Map([...e].map((e=>[e[0],y(t,e[1])])));if(e instanceof Je)return new Je(e.rows,e.cols,y(e.arr.flat(1)));if(e instanceof Ye){const[s,r,n,i]=[e.a,e.b,e.z,e.phi];switch(t){case Math.log:return Xe(is(n),i);case Math.exp:return Xe(ns(s)*as(r),ns(s)*os(r));case Math.abs:return n;case Math.sqrt:return Xe(es(n)*as(i/2),es(n)*os(i/2));case w.cos:return Xe(as(s)*hs(r),-os(s)*ls(r));case w.sin:return Xe(os(s)*hs(r),as(s)*ls(r));case w.tan:{const t=as(2*s)+hs(2*r);return Xe(os(2*s)/t,ls(2*r)/t)}case w.cosh:return Xe(hs(s)*as(r),ls(s)*os(r));case w.sinh:return Xe(ls(s)*as(r),hs(s)*os(r));case w.tanh:{const t=hs(2*s)+as(2*r);return Xe(ls(2*s)/t,os(2*r)/t)}default:return t(e)}}else if(e instanceof Object)return Object.fromEntries(Object.entries(e).map((e=>[e[0],y(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 Ye)return Xe(t+e.a,e.b);if(e instanceof Je)return Je.nums(e.rows,e.cols,t).add(e);if(e instanceof Array)return e.map((e=>A(e,t)))}else{if(t instanceof Ye||t instanceof Je)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])))}}},v=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t-e;if(e instanceof Ye)return Xe(t-e.a,-e.b);if(e instanceof Je)return Je.nums(e.rows,e.cols,t).sub(e);if(e instanceof Array)return e.map((e=>O(e,t)))}else{if(t instanceof Ye||t instanceof Je)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])))}}},x=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t*e;if(e instanceof Ye)return Xe(t*e.a,t*e.b);if(e instanceof Je)return Je.nums(e.rows,e.cols,t).mul(e);if(e instanceof Array)return e.map((e=>j(t,e)))}else{if(t instanceof Ye||t instanceof Je)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=>j(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>j(t,e[s])))}}},k=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t/e;if(e instanceof Ye)return Xe(t/e.a,t/e.b);if(e instanceof Je)return Je.nums(e.rows,e.cols,t).div(e);if(e instanceof Array)return e.map((e=>T(t,e)))}else{if(t instanceof Ye||t instanceof Je)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=>T(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>T(t,e[s])))}}},E=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t%e;if(e instanceof Ye)return Xe(t%e.a,t%e.b);if(e instanceof Je)return Je.nums(e.rows,e.cols,t).modulo(e);if(e instanceof Array)return e.map((e=>T(t,e)))}else{if(t instanceof Ye||t instanceof Je)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=v(s,e[t]);return s},j=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=x(s,e[t]);return s},T=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=k(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=>new Array(t).fill(0),I=t=>new Array(t).fill(1),M=(t,e)=>new Array(e).fill(t),D=(t,e,s)=>{if("number"==typeof t)return e!==s?(t-e)/(s-e):0;if(t instanceof Je)return new Je(t.rows,t.cols,D(t.arr.flat(1),e,s));if(t instanceof Ye)return new Ye(D(t.a,e,s),D(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>D(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=D(t[s])}}},P=(t,e,s)=>{if("number"==typeof t)return(s-e)*t+e;if(t instanceof Je)return new Je(t.rows,t.cols,P(t.arr.flat(1),e,s));if(t instanceof Ye)return new Ye(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])}}},$=(t,e,s,r,n)=>{if("number"==typeof t)return P(D(t,e,s),r,n);if(t instanceof Je)return new Je(t.rows,t.cols,$(t.arr.flat(1),e,s,r,n));if(t instanceof Ye)return new Ye($(t.a,s,r,n),$(t.b,e,s,r,n));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>$(t,e,s,r,n)));{let i=new Array(t.length);for(let a=0;a<t.length;a++)i[a]=$(t[a],e,s,r,n)}}},R=(t,e,s)=>{const[r,n]=[H(e,s),G(e,s)];if("number"==typeof t)return H(G(t,r),n);if(t instanceof Je)return new Je(t.rows,t.cols,R(t.arr.flat(1),r,n));if(t instanceof Ye)return new Ye(R(t.a,r,n),R(t.b,r,n));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>R(t,r,n)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=R(t[s],r,n)}}},F=(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},z=(t,e,s=ts(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 c;c=r?(a-o)/(s-1):(a-o)/s;for(var i=0;i<s;i++)t<e?n.push(o+c*i):n.push(a-c*i);return n}if([t,e].some((t=>t instanceof Ye))){const n=Xe(t),i=Xe(e);s=s||Math.abs(n.a-i.a)+1;const a=z(n.a,i.a,s,r),o=z(n.b,i.b,s,r);let c=new Array(s).fill(null);return c=c.map(((t,e)=>Xe(a[e],o[e]))),c}}},L=(t,e,r=e-t+1,n=s,i=!0)=>z(t,e,r,i).map((t=>ss(n,t))),q=(t,e,s=ts(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=rs(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 Ye))){const n=Xe(t),i=Xe(e);let a;s=s||Math.abs(n.a-i.a)+1,a=rs(i.div(n),r?s-1:s);const o=[n];for(let t=1;t<s;t++)o.push(j(o[t-1],a));return o}}},Z=(...t)=>mapfun((t=>t*Math.PI/180),...t),N=(...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},B=(...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(B(...t[s])):t[s]instanceof Object&&e.push(B(...Object.values(t[s])));return 1===e.length?e[0]:e},H=(...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(H(...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},G=(...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(H(...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},K=(...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(K(...t[s])):t[s]instanceof Object&&e.push(null);return 1===e.length?e[0]:e},W=(t,e,s)=>{const[r,n]=[Math.min(e,s),Math.max(e,s)];return t>=r&&t<=n},V=(t,e,s=1e-4)=>Math.abs(t-e)<=s,J=(t,e)=>t.reduce(((t,s)=>[...t,...e.map((t=>[s,t]))]),[]),Q=(t,e)=>{let s,r=1;if(t==us(t)&&e==us(e)){for(s=2;s<=t&&s<=e;++s)t%s==0&&e%s==0&&(r=s);return r}console.log("error")},Y=(t,e)=>{let s;if(t==us(t)&&e==us(e)){for(s=t>e?t:e;s%t!=0||s%e!=0;)++s;return s}console.log("error")},X={add:A,sub:O,mul:j,div:T,modulo:S,zeros:C,ones:I,nums:M,norm:D,lerp:P,map:$,clamp:R,arange:F,linspace:z,logspace:L,geomspace:q,sum:U,prod:B,accum:K,cartesianProduct:J,ppcm:Y,pgcd:Q,deg2rad:Z,rad2deg:N,inRange:W,isApproximatlyEqual:V},tt={_mode:Number,_map:function(t,e,s){return e instanceof Je?new Je(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof Ye?new Ye(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}},et={_mode:Number,_map:function(t,e,s){return e instanceof Je?new Je(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof Ye?new Ye(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)?et._mode(!t):this._map(this.not,t)},and:function(t,...e){return["number","boolean"].includes(typeof t)?et._mode(e.reduce(((t,e)=>t&e),t)):this._map(this.and,t,e)},or:function(t,...e){return["number","boolean"].includes(typeof t)?et._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 et.not(et.xor(t,e))}};class st{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 rt{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=X.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 Qe(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"#"+tt.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 Ye(this.float(t[0],t[1]),this.float(e[0],e[1])):new Ye(...this.floats(2,t,e))}static complexInt(t=[0,1],e=[0,1]){return new Ye(this.int(t[0],t[1]),this.int(e[0],e[1]))}static complexBin(){return new Ye(...this.bins(2))}static complexOct(){return new Ye(...this.octs(2))}static complexDec(){return new Ye(...this.decs(10))}static complexHex(){return new Ye(...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 Qe(t,e,this.floats(t*e,s,r))}static matrixInt(t,e,s,r){return Qe(t,e,this.ints(t*e,s,r))}static matrixBin(t,e){return Qe(t,e,this.bins(t*e))}static matrixOct(t,e){return Qe(t,e,this.octs(t*e))}static matrixDec(t,e){return Qe(t,e,this.decs(t*e))}static matrixHex(t,e){return Qe(t,e,this.hex(t*e))}static matrixColor(t,e){return Qe(t,e,this.colors(t*e))}static matrixComplex(t,e,s,r){return Qe(t,e,this.complexes(t*e,s,r))}static matrixComplexInt(t,e,s,r){return Qe(t,e,this.complexesInt(t*e,s,r))}static matrixComplexBin(t,e){return Qe(t,e,this.complexesBin(t*e))}static matrixComplexOct(t,e){return Qe(t,e,this.complexesBin(t*e))}static matrixComplexDec(t,e){return Qe(t,e,this.complexesBin(t*e))}static matrixComplexHex(t,e){return Qe(t,e,this.complexesBin(t*e))}}const nt=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=nt(t);return(new DOMParser).parseFromString(e,"text/xml").documentElement};const it=(t,e=",")=>t.trim().trimEnd().split("\n").map((t=>t.split(e))),at=(t,e=",")=>{const[s,...r]=it(t,e);return r.map((t=>{const e={};return s.forEach(((s,r)=>{e[s]=t[r]})),e}))},ot=t=>t instanceof Array?[Object.keys(t[0]),...t.map((t=>Object.values(t)))]:[Object.keys(t)],ct=(t,e)=>ot(t).map((t=>t.join(e))).join("\n"),ht=(t,e=",")=>ct(t instanceof Object?t:JSON.parse(t),e),lt=(t,e)=>{const s=[];if(Array.isArray(t))t.forEach((t=>{if("object"==typeof t&&null!==t){s.push(`${e}-`);const r=lt(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=lt(n,`${e} `);s.push(...t)}else s.push(`${e}${r}: ${n}`)}return s},ut=(t,e="")=>lt(t,e).join("\n"),ft=(t,e)=>ut(t instanceof Object?t:JSON.parse(t),e),mt=(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?mt(n,e+2):`${n}`,s+=`</${r}>`}return s.trim()};class pt{constructor(t){this.cache={node:t}}isZikoUINode(){return!0}get node(){return this.cache.node}}class dt extends Array{constructor(...t){super(...t)}clear(){return this.length=0,this}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 gt=new dt,bt={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},wt={store:new Map,index:0,register:function(t){this.store.set(this.index++,t)},reset(){this.index=0,this.store.clear()}},yt={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(t){}};class _t{#t;#e;#s;#r;#n;#i;constructor(t=""){this.#t=new BroadcastChannel(t),this.#e=new Map,this.#s=new Map,this.#r="ziko-channel:"+rt.string(10),this.#n=new Set([this.#r]),this.#i=new Set,this.#t.addEventListener("message",(t=>{const{last_sent_event:e,userId:s,eventData:r,rooms:n}=t.data;if(s===this.#r)return;if(n&&n.length&&!n.some((t=>this.#i.has(t))))return;this.#n.add(s),this.#e=new Map(r);const i=this.#s.get(e);i&&i.forEach((({fn:t,rooms:s})=>{s&&0!==s.length&&n&&!n.some((t=>s.includes(t)))||t(this.#e.get(e))}))}))}emit(t,e,s){return this.#e.set(t,e),"string"==typeof s&&(s=[s]),this.#t.postMessage({eventData:Array.from(this.#e.entries()),last_sent_event:t,userId:this.#r,rooms:s&&s.length?s:void 0}),this}on(t,e=console.log,s){return this.#s.has(t)||this.#s.set(t,[]),"string"==typeof s&&(s=[s]),this.#s.get(t).push({fn:e,rooms:s}),this}off(t,e){return this.#s.has(t)?(this.#s.set(t,this.#s.get(t).filter((t=>t.fn!==e))),this):this}once(t,e,s){const r=s=>{e(s),this.off(t,r)};return this.on(t,r,s),this}join(...t){return t.forEach((t=>this.#i.add(t))),this}leave(...t){return t.length?t.forEach((t=>this.#i.delete(t))):this.#i.clear(),this}close(){return this.#t.close(),this}}const vt=t=>new _t(t);class xt{constructor(t,e,s,r=!0){this.cache={storage:t,globalKey:e,channel:r?vt(`Ziko:useStorage-${e}`):null,oldItemKeys:new Set},this.#a(s,r)}get items(){const t=this.cache.storage.getItem(this.cache.globalKey);if(!t)return{};try{return JSON.parse(t)}catch{return{}}}#o(){const t=this.items;this.cache.oldItemKeys.forEach((t=>delete this[t]));for(const e in t)this[e]=t[e],this.cache.oldItemKeys.add(e)}#a(t,e){if(e&&this.cache.channel&&this.cache.channel.on("Ziko-Storage-Updated",(()=>this.#o())),t)if(this.cache.storage.getItem(this.cache.globalKey)){const t=this.items;Object.keys(t).forEach((t=>this.cache.oldItemKeys.add(t))),this.#o()}else this.set(t);else this.#o()}set(t){return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(t)),this.cache.channel&&this.cache.channel.emit("Ziko-Storage-Updated",t),this.#o(),this}add(t){return this.set({...this.items,...t}),this}remove(...t){const e={...this.items};return t.forEach((t=>{delete e[t],delete this[t],this.cache.oldItemKeys.delete(t)})),this.set(e),this}get(t){return this.items[t]}clear(){return this.cache.storage.removeItem(this.cache.globalKey),this.cache.oldItemKeys.forEach((t=>delete this[t])),this.cache.oldItemKeys.clear(),this.#o(),this}onStorageUpdated(t){return this.cache.channel&&this.cache.channel.on("Ziko-Storage-Updated",t),this}}const kt=(t,e,s=!0)=>new xt(sessionStorage,t,e,s),Et={store:new Map,index:0,session_storage:null,register:function(t){if(!(void 0).SSR&&(void 0).DEV){this.session||(this.session_storage=kt("ziko-state",{}));const e=this.session_storage.get(this.index);e?t.value=e:this.session_storage.add({[this.index]:t.value})}this.store.set(this.index++,t)},update:function(t,e){!(void 0).SSR&&(void 0).DEV&&this.session_storage.add({[t]:e})}};function At(){var t;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:gt,__HYDRATION__:wt,__State__:Et,__Config__:bt,__CACHE__:yt},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}}))}At();class Ot extends pt{constructor(){super()}init(t,e,s,r){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:!1,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 dt,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?.(),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 jt(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});let 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))),__Ziko__.__State__.update(s,t)))},{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__||At();const St=t=>"function"==typeof t&&t?.()?.isStateGetter?.(),Ct=(t="")=>t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase())),It=(t="")=>{if(0===t.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(t)};class Mt extends pt{constructor(...t){super("span","text",!1,...t),this.element=globalThis?.document?.createTextNode(...t)}isText(){return!0}}const Dt=(...t)=>new Mt(...t);async function Pt(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]=Dt(s[r])),s[r]instanceof Function){const t=s[r]();t.isStateGetter&&(s[r]=Dt(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 $t(t,e){if(globalThis.SVGAElement&&this.element instanceof globalThis.SVGAElement&&(t=It(t)?Ct(t):t),!this?.attr[t]||this?.attr[t]!==e){if(St(e)){e()._subscribe((e=>this.element?.setAttribute(t,e)),this)}else this.element?.setAttribute(t,e);Object.assign(this.cache.attributes,{[t]:e})}}var Rt=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(" ")),$t.call(this,s[t],r[t])}else e instanceof Array&&(e=e.join(" ")),$t.call(this,t,e);return this},setContentEditable:function(t=!0){return this.setAttr("contenteditable",t),this}});var Ft=Object.freeze({__proto__:null,after:function(t){return t?.isUIElement&&(t=t.element),this.element?.after(t),this},append:function(...t){return Pt.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.unmount())),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]=Dt(e[s])),this.element?.insertBefore(e[s].element,this.items[t].element),this.items.splice(t,0,e[s]);return this},mount:function(t=this.target){if(!this.isBody)return t?.isUIElement&&(t=t.element),this.target=t,this.target?.appendChild(this.element),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},renderAfter:function(t=1){return setTimeout((()=>this.mount()),t),this},replaceElementWith:function(t){return this.cache.element.replaceWith(t),this.cache.element=t,this},unmount: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.unmount()),t),this}});const zt={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 qt(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 Zt{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=>qt.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}#c(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.#c("preventDefault",t,e),this}stopPropagation(t={},e="default"){return this.#c("stopPropagation",t,e),this}stopImmediatePropagation(t={},e="default"){return this.#c("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 Nt extends Zt{constructor(t,e){super(t,zt.Click,Ut,e)}}function Ut(){"click"===this.currentEvent?this.dx=0:this.dx=1}const Bt=(t,e)=>new Nt(t,e);class Ht extends Zt{constructor(t,e){super(t,zt.Clipboard,Gt,e)}}function Gt(){}const Kt=(t,e)=>new Ht(t,e);class Wt extends Zt{constructor(t,e,s){super(t,e,Vt,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 Vt(){}class Jt extends Zt{constructor(t,e){super(t,zt.Drag,Qt,e)}}function Qt(){}const Yt=(t,e)=>new Jt(t,e);class Xt extends Zt{constructor(t,e){super(t,zt.Focus,te,e)}}function te(){}const ee=(t,e)=>new Xt(t,e);class se extends Zt{constructor(t,e){super(t,zt.Hash,re,e)}}function re(){}class ne extends Zt{constructor(t,e){super(t,zt.Key,ie,e)}}function ie(){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 ae=(t,e)=>new ne(t,e);class oe extends Zt{constructor(t,e){super(t,zt.Mouse,ce,e)}}function ce(){}const he=(t,e)=>new oe(t,e);class le extends Zt{constructor(t,e){super(t,zt.Ptr,ue,e),this.isDown=!1}}function ue(){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 fe=(t,e)=>new le(t,e);class me extends Zt{constructor(t,e){super(t,zt.Touch,pe,e)}}function pe(){}class de extends Zt{constructor(t,e){super(t,zt.Wheel,ge,e)}}function ge(){}const be=(t,e)=>new de(t,e),we={ptr:fe,mouse:he,key:ae,click:Bt,drag:Yt,clipboard:Kt,focus:ee,wheel:be},ye={};Object.entries(zt).forEach((([t,e])=>{e.forEach((e=>{const s=`on${e}`;ye[s]=function(...e){return this.events[t]||(this.events[t]=we[t.toLowerCase()](this)),this.events[t][s](...e),this}}))}));var _e=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 ve=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){if(!this.element?.style)return this;for(let e in t){const s=t[e];if(St(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 xe(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 ke{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}}const Ee=t=>function(e){xe.call(this,e,t,null,null)};class Ae extends ke{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{}},this.__controller={}}#a(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]=Ee(t).bind(this),this}on(t,...e){return this.__controller[t]||this.#a(t),this.__onEvent(t,{},...e),this}emit(t,e={}){this.__controller[t]||this.#a(t),this.detail=e;const s=new Event(t);return this.targetElement.dispatchEvent(s),this}}const Oe=t=>new Ae(t);let je=class extends Ot{constructor({element:t,name:e="",type:s="html",render:r=__Ziko__.__Config__.default.render}={}){super(),jt(this,Rt,Ft,ve,_e,ye),t&&this.init(t,e,s,r)}get element(){return this.cache.element}isInteractive(){return this.cache.isInteractive}useClient(t){return this.cache.isInteractive||(this.element.setAttribute("data-hydration-index",globalThis.__Ziko__.__HYDRATION__.index),globalThis.__Ziko__.__HYDRATION__.register((()=>this)),this.cache.isInteractive=!0),t&&this.element.setAttribute("data-hydration-directive",t),this}get st(){return this.cache.style}get attr(){return this.cache.attributes}get evt(){return this.events}get html(){return this.element.innerHTML}get text(){return this.element.textContent}get 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=Oe(this)),this.events.custom.on(t,...e),this}emit(t,e={}){return this.events.custom||(this.events.custom=Oe(this)),this.events.custom.emit(t,e),this}};class Te extends je{constructor(...t){super({element:"div",name:"view"}),this.append(...t)}}const Se=["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"],Ce=["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"],Ie=new Proxy({},{get(t,e){if("string"!=typeof e)return;let s,r=e.replaceAll("_","-").toLowerCase();return Se.includes(r)&&(s="html"),Ce.includes(r)&&(s="svg"),(...t)=>0===t.length?new je({element:r,name:r,type:s}):["string","number"].includes(typeof t[0])||t[0]instanceof je||"function"==typeof t[0]&&t[0]().isStateGetter()?new je({element:r,name:r,type:s}).append(...t):new je({element:r,type:s}).setAttr(t.shift()).append(...t)}});class Me extends je{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 De.call(this,s),this.style({alignItems:"number"==typeof t?$e.call(this,t):t,justifyContent:"number"==typeof e?Re.call(this,e):e}),this}horizontal(t,e,s=1){return Pe.call(this,s),this.style({alignItems:"number"==typeof e?Re.call(this,e):e,justifyContent:"number"==typeof t?$e.call(this,t):t}),this}show(){return this.isHidden=!1,this.style({display:"flex"}),this}}function De(t){return 1==t?this.style({flexDirection:"column"}):-1==t&&this.style({flexDirection:"column-reverse"}),this}function Pe(t){return 1==t?this.style({flexDirection:"row"}):-1==t&&this.style({flexDirection:"row-reverse"}),this}function $e(t){return"number"==typeof t&&(t=["flex-start","center","flex-end"][t+1]),t}function Re(t){return $e(-t)}class Fe extends Ot{constructor({element:t,name:e,type:s,render:r}){super({element:t,name:e,type:s,render:r})}}class ze extends Fe{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.unmount(),this.append(s)}catch(t){console.log({error:t})}})()}}class Le extends je{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 qe extends je{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 Ze extends je{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.unmount())),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 Ne=t=>(new XMLSerializer).serializeToString(t),Ue=t=>btoa(Ne(t)),Be=t=>"data:image/svg+xml;base64,"+Ue(t),He=t=>JSON.stringify(y((t=>["number","string","boolean","bigint"].includes(typeof t)?String(t):t instanceof Ye||t instanceof Je?t.toString():t instanceof Array?Ke(t):void 0),t),null," ").replace(/"([^"]+)":/g,"$1:").replace(/: "([^"]+)"/g,": $1"),Ge=t=>{if(!Array.isArray(t))return 0;let e=1;for(const s of t)if(Array.isArray(s)){const t=Ge(s);t+1>e&&(e=t+1)}return e},Ke=t=>{let e=0;return function t(s){let r=Ge(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 Ye?r.toString():r instanceof Array?`\n${" ".repeat(e)}${t(r)}${n===s.length-1?"\n":""}`:r instanceof Object?He(r):void 0))+`${" ".repeat((r+e+1)*n)}]`}(t)},We=(t,e=0)=>{t=Ve(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+=We({[t]:i[t]},e+1):s+=`${r} ${t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}: ${i[t]};\n`;s+=`${r}}\n`}return s};function Ve(t){return"object"!=typeof t||null===t?t:Object.keys(t).reduce(((e,s)=>(e[s.trim()]=Ve(t[s]),e)),Array.isArray(t)?[]:{})}class Je{constructor(t,e,s=[]){if(t instanceof Je)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.#o()}toString(){return Ke(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 Je(t,e,this.arr.flat(1));console.error("Err")}static eye(t){let e=new Je(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 Je(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 Je(this.cols,this.rows,this.arr.flat(1).reel)}get imag(){return new Je(this.cols,this.rows,this.arr.flat(1).imag)}[Symbol.iterator](){return this.arr[Symbol.iterator]()}#o(){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==Je.sub(e,t).max&&0==Je.sub(e,t).min}get isAntiSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==Je.add(e,t).max&&0==Je.add(e,t).min}get isDiag(){if(!this.isSquare)return!1;const t=this.T,e=this.clone,s=Je.mul(e,t),r=Je.dot(t,e);return 0==Je.sub(s,r).max&&0==Je.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=Je.dot(t,t);return 0==Je.sub(e,t).max&&0==Je.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 Je(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 Je))?void console.warn("Tensors are not completely supported yet ..."):X.sub(X.mul(s[0][0],s[1][1]),X.mul(s[0][1],s[1][0]));for(var r=0,n=0;n<s.length;n++){const i=X.add(X.mul(ss(-1,n),X.mul(s[0][n],e(t(s,n)))));r=X.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 Je(this.rows,this.cols,t.flat(1))}static zeros(t,e){let s=new Je(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 Je(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 Je(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 Je(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=rt.randInt(s,r);return n},bin:(t,e)=>{let s=new Je(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=rt.randBin;return s},hex:(t,e)=>{let s=new Je(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=rt.randHex;return s},choices:(t,e,s,r)=>{let n=new Je(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=rt.choice(s,r);return n},permutation:(t,e,s)=>{}}}static rands(t,e,s=1,r){let n=new Je(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=rt.rand(s,r);return n}map(t,e,s,r){return X.map(this,t,e,s,r)}lerp(t,e){return X.lerp(this,t,e)}norm(t,e){return X.norm(this,t,e)}clamp(t,e){return X.clamp(this,t,e)}static map(t,e,s,r,n){return X.map(t,e,s,r,n)}static lerp(t,e,s){return X.lerp(t,e,s)}static norm(t,e,s){return X.norm(t,e,s)}static clamp(t,e,s){return X.clamp(Qe,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 Je(this.rows,this.cols,t)}get toOct(){let t=this.arr.flat(1).toOct;return new Je(this.rows,this.cols,t)}get toHex(){let t=this.arr.flat(1).toHex;return new Je(this.rows,this.cols,t)}max2min(){let t=this.arr.flat(1).max2min;return new Je(this.rows,this.cols,t)}min2max(){let t=this.arr.flat(1).min2max;return new Je(this.rows,this.cols,t)}sortRows(t=void 0){let e=this.arr.map((e=>e.sort(t))).flat(1);return new Je(this.rows,this.cols,e)}sortCols(t=void 0){let e=this.T.arr.map((e=>e.sort(t))).flat(1);return new Je(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 Je(s)}filterByCols(t){return new Je(this.T.arr.filter((e=>e.includes(t))))}sortAll(t=void 0){let e=this.arr.flat(1).sort(t);return new Je(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 Je(this.rows,this.cols,e)}#h(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 Je(this.rows,this.cols,e.flat(1))}hstack(...t){const e=[this,...t].reduce(((t,e)=>t.#h(e)));return Object.assign(this,e),this}static hstack(t,...e){return t.clone.hstack(...e)}#l(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 Je(this.rows,this.cols,e.flat(1))}vstack(...t){const e=[this,...t].reduce(((t,e)=>t.#l(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.#h(e)));return Object.assign(this,e),this}vqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#l(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 Je(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 Ye)&&(t[s]=Je.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]=X.add(this.arr[r][e],t[s].arr[r][e])}return new Je(this.rows,this.cols,this.arr.flat(1))}sub(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=Je.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]=X.sub(this.arr[r][e],t[s].arr[r][e])}return new Je(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]=Je.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]=X.mul(this.arr[e][s],t[r].arr[e][s])}return new Je(this.rows,this.cols,this.arr.flat(1))}div(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=Je.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]=X.div(this.arr[r][e],t[s].arr[r][e])}return new Je(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]=Je.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]=X.modulo(this.arr[r][e],t[s].arr[r][e])}return new Je(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]=X.add(e[s][r],X.mul(this.arr[s][n],t.arr[n][r]))}}return new Je(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 Ye))}get min(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(H(...this.arr[e]));return H(...t)}get max(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(G(...this.arr[e]));return G(...t)}get minRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(H(...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(G(...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 Je(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 Je(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 Je(i).T}}const Qe=(t,e,s)=>new Je(t,e,s);class Ye{constructor(t=0,e=0){t instanceof Ye?(this.a=t.a,this.b=t.b):"object"==typeof t?"a"in t&&"b"in t?(this.a=t.a,this.b=t.b):"a"in t&&"z"in t?(this.a=t.a,this.b=es(t.z**2-t.a**2)):"a"in t&&"phi"in t?(this.a=t.a,this.b=t.a*cs(t.phi)):"b"in t&&"z"in t?(this.b=t.b,this.a=es(t.z**2-t.b**2)):"b"in t&&"phi"in t?(this.b=e,this.a=t.b/cs(t.phi)):"z"in t&&"phi"in t&&(this.a=t.z*as(t.phi),this.a=t.z*os(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 Ye(this.a,this.b)}get z(){return ms(this.a,this.b)}get phi(){return fs(this.b,this.a)}static Zero(){return new Ye(0,0)}get conj(){return new Ye(this.a,-this.b)}get inv(){return new Ye(this.a/(ss(this.a,2)+ss(this.b,2)),-this.b/(ss(this.a,2)+ss(this.b,2)))}add(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Ye(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 Ye(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 Ye(t[e],0));let e=+B(this.z,...t.map((t=>t.z))).toFixed(15),s=+U(this.phi,...t.map((t=>t.phi))).toFixed(15);return this.a=+(e*as(s).toFixed(15)).toFixed(14),this.b=+(e*os(s).toFixed(15)).toFixed(14),this}div(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Ye(t[e],0));let e=+(this.z/B(...t.map((t=>t.z)))).toFixed(15),s=+(this.phi-U(...t.map((t=>t.phi)))).toFixed(15);return this.a=+(e*as(s).toFixed(15)).toFixed(15),this.b=+(e*os(s).toFixed(15)).toFixed(15),this}pow(t){if(us(t)===t&&t>0){let e=+(this.z**t).toFixed(15),s=+(this.phi*t).toFixed(15);this.a=+(e*as(s).toFixed(15)).toFixed(15),this.b=+(e*os(s).toFixed(15)).toFixed(15)}return this}static fromExpo(t,e){return new Ye(+(t*as(e)).toFixed(13),+(t*os(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 Xe(t**this.a*as(this.b*is(t)),t**this.a*os(this.b*is(t)))}sqrtn(t=2){return Xe(rs(this.z,t)*as(this.phi/t),rs(this.z,t)*os(this.phi/t))}get sqrt(){return this.sqrtn(2)}get log(){return Xe(this.z,this.phi)}get cos(){return Xe(as(this.a)*hs(this.b),os(this.a)*ls(this.b))}get sin(){return Xe(os(this.a)*hs(this.b),as(this.a)*ls(this.b))}get tan(){const t=as(2*this.a)+hs(2*this.b);return Xe(os(2*this.a)/t,ls(2*this.b)/t)}}const Xe=(t,e)=>{if((t instanceof Array||ArrayBuffer.isView(t))&&(e instanceof Array||ArrayBuffer.isView(t)))return t.map(((s,r)=>Xe(t[r],e[r])));if(t instanceof Je&&e instanceof Je){if(t.shape[0]!==e.shape[0]||t.shape[1]!==e.shape[1])return Error(0);const s=t.arr.map(((s,r)=>Xe(t.arr[r],e.arr[r])));return new Je(t.rows,t.cols,...s)}return new Ye(t,e)},ts=(...t)=>y(Math.abs,...t),es=(...t)=>y(Math.sqrt,...t),ss=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,e):e instanceof Ye?Ye.fromExpo(t**e.a,e.b*is(t)):y((e=>ss(t,e)),...e);if(t instanceof Ye)return"number"==typeof e?Ye.fromExpo(t.z**e,t.phi*e):e instanceof Ye?Ye.fromExpo(t.z**e.a*ns(-t.phi*e.b),is(t.z)*e.b+e.a*t.phi):y((e=>ss(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return y((t=>ss(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(y((e=>ss(t[r],e)),...e));return s}}},rs=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,1/e):y((e=>rs(t,e)),...e);if(t instanceof Ye)return"number"==typeof e?Ye.fromExpo(rs(t.z,e),t.phi/e):y((e=>rs(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return y((t=>rs(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(y((e=>rs(t[r],e)),...e));return s}}},ns=(...t)=>y(Math.exp,...t),is=(...t)=>y(Math.log,...t),as=(...t)=>y(w.cos,...t),os=(...t)=>y(w.sin,...t),cs=(...t)=>y(w.tan,...t),hs=(...t)=>y(w.cosh,...t),ls=(...t)=>y(w.sinh,...t),us=(...t)=>y(Math.floor,...t),fs=(t,e,s=!0)=>{if("number"==typeof t)return"number"==typeof e?s?Math.atan2(t,e):180*Math.atan2(t,e)/Math.PI:y((e=>fs(t,e,s)),...e);if(t instanceof Array){if("number"==typeof e)return y((t=>fs(t,e,s)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(y((e=>ss(t[r],e)),...e));return s}}},ms=(...t)=>t.every((t=>"number"==typeof t))?Math.hypot(...t):t.every((t=>t instanceof Array))?y(Math.hypot,...t):void 0,{PI:ps,sqrt:ds,cos:gs,sin:bs,acos:ws,pow:ys}=Math,_s=t=>t,vs=(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 xs{constructor(t,{ease:e=_s,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()}#u=()=>{this.t+=this.state.step,this.i++,this.tx=$(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)};#f(t=!0){return this.state.isRunning||(t&&this.reset(!1),this.state.isRunning=!0,this.state.startTime=Date.now(),this.state.animationId=setInterval(this.#u,this.state.step)),this}start(){return this.#f(!0)}pause(){return this.state.isRunning&&(clearInterval(this.state.animationId),this.state.isRunning=!1),this}resume(){return this.#f(!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 ks{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 Es extends ks{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 As{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 Os{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 js{constructor(t=10){this.events={},this.maxListeners=t}on(t,e){return 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.`),this}once(t,e){const s=(...r)=>{this.off(t,s),e(...r)};return this.on(t,s)}off(t,e){const s=this.events[t];if(!s)return this;const r=s.indexOf(e);return-1!==r&&s.splice(r,1),this}emit(t,e){const s=this.events[t];return!!s&&([...s].forEach((s=>{try{s(e)}catch(e){console.error(`Error in listener for '${t}':`,e)}})),!0)}remove(t){return delete this.events[t],this}clear(){return this.events={},this}setMaxListeners(t){return this.maxListeners=t,this}}const Ts=t=>new js(t);class Ss{constructor(t,e=!0){this.#a(),this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}#a(){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=Ts(),this}}class Cs{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}}class Is{constructor(t=document.title,e=!0){this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.Emitter=Ts(),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}}class Ms{constructor({title:t,lang:e,icon:s,meta:r,noscript:n}){var i;this.html=globalThis?.document?.documentElement,this.head=globalThis?.document?.head,t&&((t,e)=>{new Is(t,e)})(t),e&&this.setLang(e),s&&new Ss(s,i),r&&(({viewport:t,charset:e,description:s,author:r,keywords:n})=>{new Cs({viewport:t,charset:e,description:s,author:r,keywords:n})})(r),n&&this.setNoScript()}setLang(t){this.html.setAttribute("lang",t)}setNoScript(t){}}class Ds{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.mount(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 Ms?t:(({title:t,lang:e,icon:s,meta:r,noscript:n})=>new Ms({title:t,lang:e,icon:s,meta:r,noscript:n}))(t),this}}function Ps(t){return/:\w+/.test(t)}class $s extends Ds{constructor({head:t,wrapper:e,target:s,routes:r}){super({head:t,wrapper:e,target:s}),this.routes=new Map([["404",Dt("Error 404")],...Object.entries(r)]),this.clear(),globalThis.onpopstate=this.mount(location.pathname)}clear(){return[...this.routes].forEach((t=>{!Ps(t[0])&&t[1]?.isUIElement&&t[1].unmount()})),this}mount(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(Ps(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.mount(this.wrapper),"function"==typeof s&&(r=s());return r?.isUIElement&&r.mount(this.wrapper),r instanceof Promise&&r.then((t=>t.mount(this.wrapper))),globalThis.history.pushState({},"",t),this}}const Rs=({head:t,wrapper:e,target:s,routes:r})=>new $s({head:t,wrapper:e,target:s,routes:r});function Fs(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 zs{#m;#p;#d=null;constructor(t=[],e=(()=>{})){this.#m=t,this.#p=e,this.#a()}#g(){return this.#m.some((({query:t})=>globalThis.matchMedia(t).matches))}#a(){this.#m.forEach((({query:t,callback:e})=>{const s=globalThis.matchMedia(t),r=()=>{const t=this.#g();s.matches?(e(),this.#d=e):t||this.#d===this.#p||(this.#p(),this.#d=this.#p)};r(),s.addEventListener("change",r)}))}}class Ls{constructor(t=document.title,e=!0){this.cache={emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.emitter=Ts(),this}setTitle(t){return t!==document.title&&(document.title=t,this.cache.emitter&&this.cache.emitter.emit("ziko:title-changed",t)),this}get current(){return document.title}onChange(t){return this.cache.emitter&&this.cache.emitter.on("ziko:title-changed",t),this}}let{sqrt:qs,cos:Zs,sin:Ns,exp:Us,log:Bs,cosh:Hs,sinh:Gs}=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,c=(t,e)=>new n.constructor(t,e);switch(e.name){case"abs":return n.z;case"sqrt":return c(qs(a)*Zs(o/2),qs(a)*Ns(o/2));case"log":return c(Bs(a),o);case"exp":return c(Us(t)*Zs(i),Us(t)*Ns(i));case"cos":return c(Zs(t)*Hs(i),-Ns(t)*Gs(i));case"sin":return c(Ns(t)*Hs(i),Zs(t)*Gs(i));case"tan":{const e=Zs(2*t)+Hs(2*i);return c(Ns(2*t)/e,Gs(2*i)/e)}case"cosh":return c(Hs(t)*Zs(i),Gs(t)*Ns(i));case"sinh":return c(Gs(t)*Zs(i),Hs(t)*Ns(i));case"tanh":{const e=Hs(2*t)+Zs(2*i);return c(Gs(2*t)/e,Ns(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 Ds({head:t,wrapper:e,target:s}),t.Base=tt,t.Clock=Es,t.Combinaison=st,t.Complex=Ye,t.E=s,t.EPSILON=r,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,{[Fs(e[n],s)]:a})}return Rs({target:document.body,routes:{"/":()=>{},...r},wrapper:Ie.section()})},t.Flex=(...t)=>{let e="div";return"string"==typeof t[0]&&(e=t[0],t.pop()),new Me(e).append(...t)},t.HTMLWrapper=t=>new Le(t),t.Logic=et,t.Matrix=Je,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=rt,t.SPA=Rs,t.SVGWrapper=t=>new qe(t),t.Scheduler=(t,{repeat:e=null}={})=>new As(t,{repeat:e}),t.Suspense=(t,e)=>new ze(t,e),t.Switch=({key:t,cases:e})=>new Ze(t,e),t.Tick=ks,t.TimeAnimation=xs,t.TimeLoop=Os,t.TimeScheduler=As,t.UIElement=je,t.UIHTMLWrapper=Le,t.UINode=pt,t.UISVGWrapper=qe,t.UISwitch=Ze,t.UIView=Te,t.UseThread=class{#b;#w=new Map;#y=0;constructor(){const t=new Blob(['\n this.onmessage = function(e) {\n const { id, funStr, args, close } = e.data;\n try {\n const func = new Function("return " + funStr)();\n const result = func(...args);\n postMessage({ id, result });\n } catch (error) {\n postMessage({ id, error: error.message });\n } finally {\n if (close) self.close();\n }\n }\n '],{type:"text/javascript"});this.#b=new Worker(URL.createObjectURL(t)),this.#b.addEventListener("message",(t=>{const{id:e,result:s,error:r}=t.data,n=this.#w.get(e);n&&(n(s,r),this.#w.delete(e))}))}call(t,e,s=[],r=!0){if("function"!=typeof t)throw new TypeError("func must be a function");const n=++this.#y;return this.#w.set(n,e),this.#b.postMessage({id:n,funStr:t.toString(),args:s,close:r}),this}terminate(){this.#b.terminate()}},t.Utils=X,t.View=(...t)=>new Te(...t),t.ZikoApp=Ds,t.ZikoEventClick=Nt,t.ZikoEventClipboard=Ht,t.ZikoEventCustom=Wt,t.ZikoEventDrag=Jt,t.ZikoEventFocus=Xt,t.ZikoEventHash=se,t.ZikoEventKey=ne,t.ZikoEventMouse=oe,t.ZikoEventPointer=le,t.ZikoEventTouch=me,t.ZikoEventWheel=de,t.ZikoSPA=$s,t.ZikoUIFlex=Me,t.ZikoUISuspense=ze,t.ZikoUIText=Mt,t.__ZikoEvent__=Zt,t.abs=ts,t.accum=K,t.acos=(...t)=>y(w.acos,...t),t.acosh=(...t)=>y(w.acosh,...t),t.acot=(...t)=>y(w.acot,...t),t.add=A,t.animation=(t,{ease:e,t0:s,t1:r,start:n,duration:i}={})=>new xs(t,{ease:e,t0:s,t1:r,start:n,duration:i}),t.arange=F,t.arc=t=>1-bs(ws(t)),t.arr2str=Ke,t.asin=(...t)=>y(w.asin,...t),t.asinh=(...t)=>y(w.asinh,...t),t.atan=(...t)=>y(w.atan,...t),t.atan2=fs,t.atanh=(...t)=>y(w.atanh,...t),t.back=(t,e=1)=>t**2*((e+1)*t-e),t.bindCustomEvent=(t,e,s)=>new Wt(t,e,s),t.bindHashEvent=(t,e)=>new se(t,e),t.bindTouchEvent=(t,e)=>new me(t,e),t.bind_click_event=Bt,t.bind_clipboard_event=Kt,t.bind_drag_event=Yt,t.bind_focus_event=ee,t.bind_key_event=ae,t.bind_mouse_event=he,t.bind_pointer_event=fe,t.bind_wheel_event=be,t.cartesianProduct=J,t.ceil=(...t)=>y(Math.ceil,...t),t.clamp=R,t.clock=t=>new Es(t),t.combinaison=(t,e,s=!1)=>st[s?"withDiscount":"withoutDiscount"](t,e),t.complex=Xe,t.cos=as,t.cosh=hs,t.cot=(...t)=>y(w.cot,...t),t.coth=(...t)=>y(w.coth,...t),t.csc=(...t)=>y(w.csc,...t),t.csv2arr=it,t.csv2json=(t,e=",")=>JSON.stringify(at(t,e)),t.csv2matrix=(t,e=",")=>new Je(it(t,e)),t.csv2object=at,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="";const t=e(this.props);t instanceof Array?t.forEach((t=>t.mount(this.shadowRoot))):t.mount(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.discret=(t,e=5)=>Math.ceil(t*e)/e,t.div=T,t.e=ns,t.elastic=t=>-2*ys(2,10*(t-1))*gs(20*ps*t/3*t),t.fact=(...t)=>y((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=us,t.geomspace=q,t.getEvent=Lt,t.hypot=ms,t.inRange=W,t.in_back=(t,e=1.70158,s=e+1)=>s*ys(t,3)-e*t**2,t.in_bounce=(t,e=7.5625,s=2.75)=>1-vs(1-t,e,s),t.in_circ=t=>1-ds(1-t**2),t.in_cubic=t=>t**3,t.in_elastic=(t,e=2*ps/3)=>0===t?0:1===t?1:-ys(2,10*t-10)*bs((10*t-10.75)*e),t.in_expo=t=>0===t?0:2**(10*t-10),t.in_out_back=(t,e=1.70158,s=1.525*e)=>t<.5?ys(2*t,2)*(2*(s+1)*t-s)/2:(ys(2*t-2,2)*((s+1)*(2*t-2)+s)+2)/2,t.in_out_bounce=(t,e=7.5625,s=2.75)=>t<.5?vs(1-2*t,e,s)/2:vs(2*t-1,e,s)/2,t.in_out_circ=t=>t<.5?(1-ds(1-(2*t)**2))/2:(ds(1-(-2*t+2)**2)+1)/2,t.in_out_cubic=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,t.in_out_elastic=(t,e=2*ps/4.5)=>0===t?0:1===t?1:t<.5?-ys(2,20*t-10)*bs((20*t-11.125)*e)/2:ys(2,-20*t+10)*bs((20*t-11.125)*e)/2+1,t.in_out_expo=t=>0===t?0:1===t?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,t.in_out_quad=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,t.in_out_quart=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,t.in_out_quint=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,t.in_out_sin=t=>-(gs(ps*t)-1)/2,t.in_quad=t=>t**2,t.in_quart=t=>t**4,t.in_quint=t=>t**5,t.in_sin=t=>1-gs(t*ps/2),t.isApproximatlyEqual=V,t.isStateGetter=St,t.json2arr=t=>ot(t instanceof Object?t:JSON.parse(t)),t.json2css=We,t.json2csv=ht,t.json2csvFile=(t,e)=>{const s=ht(t,e),r=new Blob([s],{type:"text/csv;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2xml=mt,t.json2xmlFile=(t,e)=>{const s=mt(t,e),r=new Blob([s],{type:"text/xml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2yml=ft,t.json2ymlFile=(t,e)=>{const s=ft(t,e),r=new Blob([s],{type:"text/yml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.lerp=P,t.linear=_s,t.linspace=z,t.ln=is,t.logspace=L,t.loop=(t,e={})=>new Os(t,e),t.map=$,t.mapfun=y,t.matrix=Qe,t.matrix2=(...t)=>new Je(2,2,t),t.matrix3=(...t)=>new Je(3,3,t),t.matrix4=(...t)=>new Je(4,4,t),t.max=G,t.min=H,t.modulo=S,t.mul=j,t.norm=D,t.nums=M,t.obj2str=He,t.ones=I,t.out_back=(t,e=1.70158,s=e+1)=>1+s*ys(t-1,3)+e*ys(t-1,2),t.out_bounce=vs,t.out_circ=t=>ds(1-(t-1)**2),t.out_cubic=t=>1-(1-t)**3,t.out_elastic=(t,e=2*ps/3)=>0===t?0:1===t?1:ys(2,-10*t)*bs((10*t-.75)*e)+1,t.out_expo=t=>1===t?1:1-2**(-10*t),t.out_quad=t=>1-(1-t)**2,t.out_quart=t=>1-(1-t)**4,t.out_quint=t=>1-(1-t)**5,t.out_sin=t=>bs(t*ps/2),t.pgcd=Q,t.pow=ss,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=Y,t.preload=nt,t.prod=B,t.rad2deg=N,t.round=(...t)=>y(Math.round,...t),t.sec=(...t)=>y(w.sec,...t),t.sig=(...t)=>y((t=>1/(1+ns(-t))),...t),t.sign=(...t)=>y(Math.sign,...t),t.sin=os,t.sinc=(...t)=>y(w.sinc,...t),t.sinh=ls,t.sleep=t=>new Promise((e=>setTimeout(e,t))),t.sqrt=es,t.sqrtn=rs,t.step=(t,e=5)=>Math.floor(t*e)/e,t.step_fps=t=>1e3/t,t.sub=O,t.subSet=null,t.sum=U,t.svg2ascii=Ue,t.svg2img=(t,e=!0)=>Ie.img(Be(t)).mount(e),t.svg2imgUrl=Be,t.svg2str=Ne,t.tags=Ie,t.tan=cs,t.tanh=(...t)=>y(w.tanh,...t),t.text=Dt,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 ks(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=vt,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=Ts,t.useLocaleStorage=(t,e,s=!0)=>new xt(localStorage,t,e,s),t.useMediaQuery=(t,e)=>new zs(t,e),t.useReactive=t=>y((t=>{const e=Tt(t);return{get:e[0],set:e[1]}}),t),t.useSessionStorage=kt,t.useState=Tt,t.useTitle=(t,e=!0)=>new Ls(t,e),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.zeros=C}));
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:c,asin:h,atan:l,cosh:u,sinh:f,tanh:m,acosh:p,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:c,asin:h,atan:l,acot:t=>n/2-l(t),cosh:u,sinh:f,tanh:m,coth:t=>.5*b((1+t)/(1-t)),acosh:p,asinh:d,atanh:g};w=new Proxy(w,{get(t,e){if(e in t)return s=>+t[e](s).toFixed(15)}});const y=(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=>y(t,e)));if(ArrayBuffer.isView(e))return e.map((e=>t(e)));if(e instanceof Set)return new Set(y(t,...e));if(e instanceof Map)return new Map([...e].map((e=>[e[0],y(t,e[1])])));if(e instanceof ze)return new ze(e.rows,e.cols,y(e.arr.flat(1)));if(e instanceof Fe){const[s,r,n,i]=[e.a,e.b,e.z,e.phi];switch(t){case Math.log:return Le(He(n),i);case Math.exp:return Le(Ze(s)*Ge(r),Ze(s)*Ve(r));case Math.abs:return n;case Math.sqrt:return Le(Ue(n)*Ge(i/2),Ue(n)*Ve(i/2));case w.cos:return Le(Ge(s)*Ke(r),-Ve(s)*Je(r));case w.sin:return Le(Ve(s)*Ke(r),Ge(s)*Je(r));case w.tan:{const t=Ge(2*s)+Ke(2*r);return Le(Ve(2*s)/t,Je(2*r)/t)}case w.cosh:return Le(Ke(s)*Ge(r),Je(s)*Ve(r));case w.sinh:return Le(Je(s)*Ge(r),Ke(s)*Ve(r));case w.tanh:{const t=Ke(2*s)+Ge(2*r);return Le(Je(2*s)/t,Ve(2*r)/t)}default:return t(e)}}else if(e instanceof Object)return Object.fromEntries(Object.entries(e).map((e=>[e[0],y(t,e[1])])))}));return 1==s.length?s[0]:s},v=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t+e;if(e instanceof Fe)return Le(t+e.a,e.b);if(e instanceof ze)return ze.nums(e.rows,e.cols,t).add(e);if(e instanceof Array)return e.map((e=>A(e,t)))}else{if(t instanceof Fe||t instanceof ze)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])))}}},_=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t-e;if(e instanceof Fe)return Le(t-e.a,-e.b);if(e instanceof ze)return ze.nums(e.rows,e.cols,t).sub(e);if(e instanceof Array)return e.map((e=>T(e,t)))}else{if(t instanceof Fe||t instanceof ze)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=>T(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>T(t,e[s])))}}},x=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t*e;if(e instanceof Fe)return Le(t*e.a,t*e.b);if(e instanceof ze)return ze.nums(e.rows,e.cols,t).mul(e);if(e instanceof Array)return e.map((e=>S(t,e)))}else{if(t instanceof Fe||t instanceof ze)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 Fe)return Le(t/e.a,t/e.b);if(e instanceof ze)return ze.nums(e.rows,e.cols,t).div(e);if(e instanceof Array)return e.map((e=>O(t,e)))}else{if(t instanceof Fe||t instanceof ze)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=>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 Fe)return Le(t%e.a,t%e.b);if(e instanceof ze)return ze.nums(e.rows,e.cols,t).modulo(e);if(e instanceof Array)return e.map((e=>O(t,e)))}else{if(t instanceof Fe||t instanceof ze)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=v(s,e[t]);return s},T=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=_(s,e[t]);return s},S=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=x(s,e[t]);return s},O=(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=E(s,e[t]);return s},C=t=>new Array(t).fill(0),M=t=>new Array(t).fill(1),I=(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 ze)return new ze(t.rows,t.cols,P(t.arr.flat(1),e,s));if(t instanceof Fe)return new Fe(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])}}},D=(t,e,s)=>{if("number"==typeof t)return(s-e)*t+e;if(t instanceof ze)return new ze(t.rows,t.cols,D(t.arr.flat(1),e,s));if(t instanceof Fe)return new Fe(D(t.a,e,s),D(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>D(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=D(t[s])}}},R=(t,e,s,r,n)=>{if("number"==typeof t)return D(P(t,e,s),r,n);if(t instanceof ze)return new ze(t.rows,t.cols,R(t.arr.flat(1),e,s,r,n));if(t instanceof Fe)return new Fe(R(t.a,s,r,n),R(t.b,e,s,r,n));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>R(t,e,s,r,n)));{let i=new Array(t.length);for(let a=0;a<t.length;a++)i[a]=R(t[a],e,s,r,n)}}},z=(t,e,s)=>{const[r,n]=[H(e,s),G(e,s)];if("number"==typeof t)return H(G(t,r),n);if(t instanceof ze)return new ze(t.rows,t.cols,z(t.arr.flat(1),r,n));if(t instanceof Fe)return new Fe(z(t.a,r,n),z(t.b,r,n));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>z(t,r,n)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=z(t[s],r,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},F=(t,e,s=qe(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 c;c=r?(a-o)/(s-1):(a-o)/s;for(var i=0;i<s;i++)t<e?n.push(o+c*i):n.push(a-c*i);return n}if([t,e].some((t=>t instanceof Fe))){const n=Le(t),i=Le(e);s=s||Math.abs(n.a-i.a)+1;const a=F(n.a,i.a,s,r),o=F(n.b,i.b,s,r);let c=new Array(s).fill(null);return c=c.map(((t,e)=>Le(a[e],o[e]))),c}}},L=(t,e,r=e-t+1,n=s,i=!0)=>F(t,e,r,i).map((t=>Be(n,t))),q=(t,e,s=qe(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=Ne(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 Fe))){const n=Le(t),i=Le(e);let a;s=s||Math.abs(n.a-i.a)+1,a=Ne(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}}},U=(...t)=>mapfun((t=>t*Math.PI/180),...t),B=(...t)=>mapfun((t=>t/Math.PI*180),...t),N=(...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(N(...t[s])):t[s]instanceof Object&&e.push(N(...Object.values(t[s])));return 1===e.length?e[0]:e},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},H=(...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(H(...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},G=(...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(H(...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},V=(...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(V(...t[s])):t[s]instanceof Object&&e.push(null);return 1===e.length?e[0]:e},W=(t,e,s)=>{const[r,n]=[Math.min(e,s),Math.max(e,s)];return t>=r&&t<=n},K=(t,e,s=1e-4)=>Math.abs(t-e)<=s,J=(t,e)=>t.reduce(((t,s)=>[...t,...e.map((t=>[s,t]))]),[]),Y=(t,e)=>{let s,r=1;if(t==Ye(t)&&e==Ye(e)){for(s=2;s<=t&&s<=e;++s)t%s==0&&e%s==0&&(r=s);return r}console.log("error")},X=(t,e)=>{let s;if(t==Ye(t)&&e==Ye(e)){for(s=t>e?t:e;s%t!=0||s%e!=0;)++s;return s}console.log("error")},Q={add:A,sub:T,mul:S,div:O,modulo:j,zeros:C,ones:M,nums:I,norm:P,lerp:D,map:R,clamp:z,arange:$,linspace:F,logspace:L,geomspace:q,sum:N,prod:Z,accum:V,cartesianProduct:J,ppcm:X,pgcd:Y,deg2rad:U,rad2deg:B,inRange:W,isApproximatlyEqual:K},tt={_mode:Number,_map:function(t,e,s){return e instanceof ze?new ze(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof Fe?new Fe(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}},et={_mode:Number,_map:function(t,e,s){return e instanceof ze?new ze(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof Fe?new Fe(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)?et._mode(!t):this._map(this.not,t)},and:function(t,...e){return["number","boolean"].includes(typeof t)?et._mode(e.reduce(((t,e)=>t&e),t)):this._map(this.and,t,e)},or:function(t,...e){return["number","boolean"].includes(typeof t)?et._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 et.not(et.xor(t,e))}};class st{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 rt{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=Q.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 $e(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"#"+tt.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 Fe(this.float(t[0],t[1]),this.float(e[0],e[1])):new Fe(...this.floats(2,t,e))}static complexInt(t=[0,1],e=[0,1]){return new Fe(this.int(t[0],t[1]),this.int(e[0],e[1]))}static complexBin(){return new Fe(...this.bins(2))}static complexOct(){return new Fe(...this.octs(2))}static complexDec(){return new Fe(...this.decs(10))}static complexHex(){return new Fe(...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 $e(t,e,this.floats(t*e,s,r))}static matrixInt(t,e,s,r){return $e(t,e,this.ints(t*e,s,r))}static matrixBin(t,e){return $e(t,e,this.bins(t*e))}static matrixOct(t,e){return $e(t,e,this.octs(t*e))}static matrixDec(t,e){return $e(t,e,this.decs(t*e))}static matrixHex(t,e){return $e(t,e,this.hex(t*e))}static matrixColor(t,e){return $e(t,e,this.colors(t*e))}static matrixComplex(t,e,s,r){return $e(t,e,this.complexes(t*e,s,r))}static matrixComplexInt(t,e,s,r){return $e(t,e,this.complexesInt(t*e,s,r))}static matrixComplexBin(t,e){return $e(t,e,this.complexesBin(t*e))}static matrixComplexOct(t,e){return $e(t,e,this.complexesBin(t*e))}static matrixComplexDec(t,e){return $e(t,e,this.complexesBin(t*e))}static matrixComplexHex(t,e){return $e(t,e,this.complexesBin(t*e))}}const nt=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"){try{const e=await fetch(t);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const s=await e.text();return(new DOMParser).parseFromString(s,"text/html").documentElement}catch(t){throw console.error("Failed to fetch DOM:",t),t}},globalThis.fetchdomSync=function(t="https://github.com/zakarialaoui10"){try{const e=nt(t);return(new DOMParser).parseFromString(e,"text/html").documentElement}catch(t){throw console.error("Failed to fetch DOM synchronously:",t),t}};const it=(t,e=",")=>t.trim().trimEnd().split("\n").map((t=>t.split(e))),at=(t,e=",")=>{const[s,...r]=it(t,e);return r.map((t=>{const e={};return s.forEach(((s,r)=>{e[s]=t[r]})),e}))},ot=t=>t instanceof Array?[Object.keys(t[0]),...t.map((t=>Object.values(t)))]:[Object.keys(t)],ct=(t,e)=>ot(t).map((t=>t.join(e))).join("\n"),ht=(t,e=",")=>ct(t instanceof Object?t:JSON.parse(t),e),lt=(t,e)=>{const s=[];if(Array.isArray(t))t.forEach((t=>{if("object"==typeof t&&null!==t){s.push(`${e}-`);const r=lt(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=lt(n,`${e} `);s.push(...t)}else s.push(`${e}${r}: ${n}`)}return s},ut=(t,e="")=>lt(t,e).join("\n"),ft=(t,e)=>ut(t instanceof Object?t:JSON.parse(t),e),mt=(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?mt(n,e+2):`${n}`,s+=`</${r}>`}return s.trim()};class pt{constructor(t){this.cache={node:t}}isZikoUINode(){return!0}get node(){return this.cache.node}}class dt extends Array{constructor(...t){super(...t)}clear(){return this.length=0,this}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 gt=new dt;class bt extends pt{constructor(){super()}init(t,e,s,r){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:!1,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 dt,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?.(),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 wt(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)))}var yt=Object.freeze({__proto__:null,mount:function(t=this.target,e=0){return e>0?(setTimeout((()=>this.mount(t,0)),e),this):(this.isBody||(t?.isUIElement&&(t=t.element),this.target=t,this.target?.appendChild(this.element)),this)},unmount:function(t=0){return t>0?(setTimeout((()=>this.unmount(0)),t),this):(this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target.children].includes(this.element)&&this.target.removeChild(this.element),this)}});const vt={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},_t={store:new Map,index:0,register:function(t){this.store.set(this.index++,t)},reset(){this.index=0,this.store.clear()}},xt={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(t){}};class kt{#t;#e;#s;#r;#n;#i;constructor(t=""){this.#t=new BroadcastChannel(t),this.#e=new Map,this.#s=new Map,this.#r="ziko-channel:"+rt.string(10),this.#n=new Set([this.#r]),this.#i=new Set,this.#t.addEventListener("message",(t=>{const{last_sent_event:e,userId:s,eventData:r,rooms:n}=t.data;if(s===this.#r)return;if(n&&n.length&&!n.some((t=>this.#i.has(t))))return;this.#n.add(s),this.#e=new Map(r);const i=this.#s.get(e);i&&i.forEach((({fn:t,rooms:s})=>{s&&0!==s.length&&n&&!n.some((t=>s.includes(t)))||t(this.#e.get(e))}))}))}emit(t,e,s){return this.#e.set(t,e),"string"==typeof s&&(s=[s]),this.#t.postMessage({eventData:Array.from(this.#e.entries()),last_sent_event:t,userId:this.#r,rooms:s&&s.length?s:void 0}),this}on(t,e=console.log,s){return this.#s.has(t)||this.#s.set(t,[]),"string"==typeof s&&(s=[s]),this.#s.get(t).push({fn:e,rooms:s}),this}off(t,e){return this.#s.has(t)?(this.#s.set(t,this.#s.get(t).filter((t=>t.fn!==e))),this):this}once(t,e,s){const r=s=>{e(s),this.off(t,r)};return this.on(t,r,s),this}join(...t){return t.forEach((t=>this.#i.add(t))),this}leave(...t){return t.length?t.forEach((t=>this.#i.delete(t))):this.#i.clear(),this}close(){return this.#t.close(),this}}const Et=t=>new kt(t);class At{constructor(t,e,s,r=!0){this.cache={storage:t,globalKey:e,channel:r?Et(`Ziko:useStorage-${e}`):null,oldItemKeys:new Set},this.#a(s,r)}get items(){const t=this.cache.storage.getItem(this.cache.globalKey);if(!t)return{};try{return JSON.parse(t)}catch{return{}}}#o(){const t=this.items;this.cache.oldItemKeys.forEach((t=>delete this[t]));for(const e in t)this[e]=t[e],this.cache.oldItemKeys.add(e)}#a(t,e){if(e&&this.cache.channel&&this.cache.channel.on("Ziko-Storage-Updated",(()=>this.#o())),t)if(this.cache.storage.getItem(this.cache.globalKey)){const t=this.items;Object.keys(t).forEach((t=>this.cache.oldItemKeys.add(t))),this.#o()}else this.set(t);else this.#o()}set(t){return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(t)),this.cache.channel&&this.cache.channel.emit("Ziko-Storage-Updated",t),this.#o(),this}add(t){return this.set({...this.items,...t}),this}remove(...t){const e={...this.items};return t.forEach((t=>{delete e[t],delete this[t],this.cache.oldItemKeys.delete(t)})),this.set(e),this}get(t){return this.items[t]}clear(){return this.cache.storage.removeItem(this.cache.globalKey),this.cache.oldItemKeys.forEach((t=>delete this[t])),this.cache.oldItemKeys.clear(),this.#o(),this}onStorageUpdated(t){return this.cache.channel&&this.cache.channel.on("Ziko-Storage-Updated",t),this}}const Tt=(t,e,s=!0)=>new At(sessionStorage,t,e,s);var St,Ot={store:new Map,index:0,session_storage:null,register:function(t){if(!(void 0).SSR&&(void 0).DEV){this.session||(this.session_storage=Tt("ziko-state",{}));const e=this.session_storage.get(this.index);e?t.value=e:this.session_storage.add({[this.index]:t.value})}this.store.set(this.index++,t)},update:function(t,e){!(void 0).SSR&&(void 0).DEV&&this.session_storage.add({[t]:e})}};function jt(t){const{store:e,index:s}=__Ziko__.__State__;__Ziko__.__State__.register({value:t,subscribers:new Set,paused:!1});let 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))),__Ziko__.__State__.update(s,t)))},{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__||globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:gt,__HYDRATION__:_t,__State__:Ot,__Config__:vt,__CACHE__:xt},St=__Ziko__,Object.defineProperties(St,{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}}));const Ct=t=>"function"==typeof t&&t?.()?.isStateGetter?.(),Mt=(t="")=>t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase())),It=(t="")=>{if(0===t.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(t)};class Pt extends pt{constructor(...t){super("span","text",!1,...t),this.element=globalThis?.document?.createTextNode(...t)}isText(){return!0}}const Dt=(...t)=>new Pt(...t);async function Rt(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]=Dt(s[r])),s[r]instanceof Function){const t=s[r]();t.isStateGetter&&(s[r]=Dt(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 zt(t,e){if(globalThis.SVGAElement&&this.element instanceof globalThis.SVGAElement&&(t=It(t)?Mt(t):t),!this?.attr[t]||this?.attr[t]!==e){if(Ct(e)){e()._subscribe((e=>this.element?.setAttribute(t,e)),this)}else this.element?.setAttribute(t,e);Object.assign(this.cache.attributes,{[t]:e})}}var $t=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(" ")),zt.call(this,s[t],r[t])}else e instanceof Array&&(e=e.join(" ")),zt.call(this,t,e);return this},setContentEditable:function(t=!0){return this.setAttr("contenteditable",t),this}});var Ft=Object.freeze({__proto__:null,after:function(t){return t?.isUIElement&&(t=t.element),this.element?.after(t),this},append:function(...t){return Rt.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.unmount())),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]=Dt(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},replaceElementWith:function(t){return this.cache.element.replaceWith(t),this.cache.element=t,this}});const Lt={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"],View:["EnterView","ExitView","ResizeView"],Swipe:["SwipeLeft","SwipeUp","SwipeRight","SwipeDown"]};function qt(t,e,s,r){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.callbacks[e]?.(this)}function Ut(t,...e){return(0===e.length?Object.keys(this.cache.paused):e).forEach((e=>{this.cache.paused.hasOwnProperty(e)&&(this.targetElement?.[t](e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]="removeEventListener"===t)})),this}const Bt=(t="")=>t.startsWith("Ptr")?`pointer${t.split("Ptr")[1].toLowerCase()}`:t.toLowerCase();class Nt{constructor(t,e=null,s=[],r,n){this.target=e,this.cache={signature:t,currentEvent:null,event:null,options:{},preventDefault:{},stopPropagation:{},stopImmediatePropagation:{},paused:{},callbacks:{},__controllers__:{}},s&&this._register_events(s,r,n)}_register_events(t,e,s,r=!0){const n=t?.map((t=>Bt(t)));return n?.forEach(((n,i)=>{this.cache.preventDefault[n]=!1,this.cache.options[n]={},this.cache.paused[n]=!1,this.cache.__controllers__[n]=t=>qt.call(this,t,n,e,s),r&&(this[`on${t[i]}`]=t=>this.__onEvent(n,this.cache.options[n],{},t))})),this}__onEvent(t,e,s,r){return r?(this.cache.callbacks[t]=r,this.__handle(t,this.cache.__controllers__[t],e,s),this):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}get detail(){return this.cache.event.detail}setTarget(t){return this.target=t,this}__handle(t,e,s){return this.targetElement?.addEventListener(t,e,s),this}#c(t,...e){return(0===e.length?Object.keys(this.cache[t]):e).forEach((e=>{this.cache[t].hasOwnProperty(e)&&(this.cache[t][e]=!0)})),this}preventDefault(...t){return this.#c("preventDefault",...t)}stopPropagation(...t){return this.#c("stopPropagation",...t)}stopImmediatePropagation(...t){return this.#c("stopImmediatePropagation",...t)}setEventOptions(t,e){const s=Bt(t);return this.pause(),Object.assign(this.cache.options[s],e),this.resume(),this}pause(...t){return Ut.call(this,"removeEventListener",...t)}resume(...t){return Ut.call(this,"addEventListener",...t)}dispose(){return this.pause(),this.target.events[this.cache.signature]=null,this}}function Zt(){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}}function Ht(){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}}}}class Gt extends Event{constructor(t,e){super("clickaway",{bubbles:!0,cancelable:!0}),this.originalEvent=t,this.targetElement=e}}const Vt=(t,e)=>{let s=0;return(...r)=>{const n=(new Date).getTime();n-s<e||(s=n,t(...r))}};class Wt extends CustomEvent{constructor(t,e,{bubbles:s=!0,cancelable:r=!0}={}){super(t,{detail:e,bubbles:s,cancelable:r})}}class Kt extends CustomEvent{constructor(t,e){super(t,{detail:e,bubbles:!0,cancelable:!0})}}const Jt=(t,e)=>(function(t){function e(e){if(!t.contains(e.target)){const s=new Gt(e,t);t.dispatchEvent(s)}}console.log(t),globalThis?.document?.addEventListener("click",e)}(t.element),new Nt("click",t,Lt.Click,null,e)),Yt=(t,e)=>new Nt("clipboard",t,Lt.Clipboard,null,e),Xt=(t,e)=>new Nt("drag",t,Lt.Drag,null,e),Qt=(t,e)=>new Nt("focus",t,Lt.Focus,null,e),te=(t,e)=>new Nt("key",t,Lt.Key,Zt,e),ee=(t,e)=>new Nt("mouse",t,Lt.Mouse,null,e),se=(t,e)=>new Nt("ptr",t,Lt.Ptr,Ht,e),re=(t,e)=>new Nt("wheel",t,Lt.Wheel,null,e),ne=(t,e)=>(function(t,{intersection:e=!0,resize:s=!0,threshold:r=0,throttleResize:n=100,throttleEnterExit:i=0}={}){let a,o;const c=e=>{for(let s of e){const{width:e,height:r}=s.contentRect;t.dispatchEvent(new Wt("resizeview",{width:e,height:r,entry:s}))}},h=n>0?Vt(c,n):c,l=e=>{for(let s of e){const e=s.isIntersecting?"enterview":"exitview";t.dispatchEvent(new Wt(e,s))}},u=i>0?Vt(l,i):l;e&&(a=new IntersectionObserver(u,{threshold:r}),a.observe(t)),s&&(o=new ResizeObserver(h),o.observe(t))}(t.element),new Nt("view",t,Lt.View,null,e)),ie=(t,e)=>(function(t,e=50,s=100,r=500){let n=0,i=0,a=0,o=!1;function c(t){n=t.clientX,i=t.clientY,a=performance.now(),o=!0}function h(c){if(!o)return;o=!1;const h=c.clientX-n,l=c.clientY-i;let u=null,f=null;performance.now()-a<=r&&(Math.abs(h)>=e&&Math.abs(l)<=s?(u=h<0?"left":"right",f="swipe"+u):Math.abs(l)>=e&&Math.abs(h)<=s&&(u=l<0?"up":"down",f="swipe"+u)),f&&t.dispatchEvent(new Kt(f,{direction:u,distX:h,distY:l,originalEvent:c}))}t.addEventListener("pointerdown",c,{passive:!0}),t.addEventListener("pointerup",h,{passive:!0})}(t.element),new Nt("swipe",t,Lt.Swipe,null,e));class ae extends Nt{constructor(t,e,s){super("custom",t,e,oe,s)}_register_events(t){return super._register_events(t,null,null,!1),this}emit(t,e={}){const s=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});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 oe(){}const ce=(t,e,s)=>new ae(t,e,s),he={ptr:se,mouse:ee,key:te,click:Jt,drag:Xt,clipboard:Yt,focus:Qt,wheel:re,view:ne,swipe:ie},le={on(t,...e){return this.events.custom||(this.events.custom=ce(this)),this.events.custom.on(t,...e),this},emit(t,e={}){return this.events.custom||(this.events.custom=ce(this)),this.events.custom.emit(t,e),this}};Object.entries(Lt).forEach((([t,e])=>{const s=t.toLowerCase();e.forEach((t=>{const e=`on${t}`;le[e]=function(t){return this.events[s]||(this.events[s]=he[s](this)),this.events[s][e](t),this}}))}));var ue=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 fe=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){if(!this.element?.style)return this;for(let e in t){const s=t[e];if(Ct(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}});let me=class extends bt{constructor({element:t,name:e="",type:s="html",render:r=__Ziko__.__Config__.default.render}={}){super(),wt(this,yt,$t,Ft,fe,ue,le),t&&this.init(t,e,s,r)}get element(){return this.cache.element}isInteractive(){return this.cache.isInteractive}useClient(t){return this.cache.isInteractive||(this.element.setAttribute("data-hydration-index",globalThis.__Ziko__.__HYDRATION__.index),globalThis.__Ziko__.__HYDRATION__.register((()=>this)),this.cache.isInteractive=!0),t&&this.element.setAttribute("data-hydration-directive",t),this}get st(){return this.cache.style}get attr(){return this.cache.attributes}get evt(){return this.events}get html(){return this.element.innerHTML}get text(){return this.element.textContent}get 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}};class pe extends me{constructor(...t){super({element:"div",name:"view"}),this.append(...t)}}const de=["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"],ge=["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"],be=new Proxy({},{get(t,e){if("string"!=typeof e)return;let s,r=e.replaceAll("_","-").toLowerCase();return de.includes(r)&&(s="html"),ge.includes(r)&&(s="svg"),(...t)=>0===t.length?new me({element:r,name:r,type:s}):["string","number"].includes(typeof t[0])||t[0]instanceof me||"function"==typeof t[0]&&t[0]().isStateGetter()?new me({element:r,name:r,type:s}).append(...t):new me({element:r,type:s}).setAttr(t.shift()).append(...t)}});class we extends me{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 ye.call(this,s),this.style({alignItems:"number"==typeof t?_e.call(this,t):t,justifyContent:"number"==typeof e?xe.call(this,e):e}),this}horizontal(t,e,s=1){return ve.call(this,s),this.style({alignItems:"number"==typeof e?xe.call(this,e):e,justifyContent:"number"==typeof t?_e.call(this,t):t}),this}show(){return this.isHidden=!1,this.style({display:"flex"}),this}}function ye(t){return 1==t?this.style({flexDirection:"column"}):-1==t&&this.style({flexDirection:"column-reverse"}),this}function ve(t){return 1==t?this.style({flexDirection:"row"}):-1==t&&this.style({flexDirection:"row-reverse"}),this}function _e(t){return"number"==typeof t&&(t=["flex-start","center","flex-end"][t+1]),t}function xe(t){return _e(-t)}class ke extends bt{constructor({element:t,name:e,type:s,render:r}){super({element:t,name:e,type:s,render:r})}}class Ee extends ke{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.unmount(),this.append(s)}catch(t){console.log({error:t})}})()}}class Ae extends me{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 Te extends me{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 Se extends me{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.unmount())),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 Oe=t=>(new XMLSerializer).serializeToString(t),je=t=>btoa(Oe(t)),Ce=t=>"data:image/svg+xml;base64,"+je(t),Me=t=>JSON.stringify(y((t=>["number","string","boolean","bigint"].includes(typeof t)?String(t):t instanceof Fe||t instanceof ze?t.toString():t instanceof Array?Pe(t):void 0),t),null," ").replace(/"([^"]+)":/g,"$1:").replace(/: "([^"]+)"/g,": $1"),Ie=t=>{if(!Array.isArray(t))return 0;let e=1;for(const s of t)if(Array.isArray(s)){const t=Ie(s);t+1>e&&(e=t+1)}return e},Pe=t=>{let e=0;return function t(s){let r=Ie(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 Fe?r.toString():r instanceof Array?`\n${" ".repeat(e)}${t(r)}${n===s.length-1?"\n":""}`:r instanceof Object?Me(r):void 0))+`${" ".repeat((r+e+1)*n)}]`}(t)},De=(t,e=0)=>{t=Re(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+=De({[t]:i[t]},e+1):s+=`${r} ${t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}: ${i[t]};\n`;s+=`${r}}\n`}return s};function Re(t){return"object"!=typeof t||null===t?t:Object.keys(t).reduce(((e,s)=>(e[s.trim()]=Re(t[s]),e)),Array.isArray(t)?[]:{})}class ze{constructor(t,e,s=[]){if(t instanceof ze)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.#o()}toString(){return Pe(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 ze(t,e,this.arr.flat(1));console.error("Err")}static eye(t){let e=new ze(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 ze(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 ze(this.cols,this.rows,this.arr.flat(1).reel)}get imag(){return new ze(this.cols,this.rows,this.arr.flat(1).imag)}[Symbol.iterator](){return this.arr[Symbol.iterator]()}#o(){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==ze.sub(e,t).max&&0==ze.sub(e,t).min}get isAntiSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==ze.add(e,t).max&&0==ze.add(e,t).min}get isDiag(){if(!this.isSquare)return!1;const t=this.T,e=this.clone,s=ze.mul(e,t),r=ze.dot(t,e);return 0==ze.sub(s,r).max&&0==ze.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=ze.dot(t,t);return 0==ze.sub(e,t).max&&0==ze.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 ze(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 ze))?void console.warn("Tensors are not completely supported yet ..."):Q.sub(Q.mul(s[0][0],s[1][1]),Q.mul(s[0][1],s[1][0]));for(var r=0,n=0;n<s.length;n++){const i=Q.add(Q.mul(Be(-1,n),Q.mul(s[0][n],e(t(s,n)))));r=Q.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 ze(this.rows,this.cols,t.flat(1))}static zeros(t,e){let s=new ze(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 ze(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 ze(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 ze(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=rt.randInt(s,r);return n},bin:(t,e)=>{let s=new ze(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=rt.randBin;return s},hex:(t,e)=>{let s=new ze(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=rt.randHex;return s},choices:(t,e,s,r)=>{let n=new ze(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=rt.choice(s,r);return n},permutation:(t,e,s)=>{}}}static rands(t,e,s=1,r){let n=new ze(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.arr[i][t]=rt.rand(s,r);return n}map(t,e,s,r){return Q.map(this,t,e,s,r)}lerp(t,e){return Q.lerp(this,t,e)}norm(t,e){return Q.norm(this,t,e)}clamp(t,e){return Q.clamp(this,t,e)}static map(t,e,s,r,n){return Q.map(t,e,s,r,n)}static lerp(t,e,s){return Q.lerp(t,e,s)}static norm(t,e,s){return Q.norm(t,e,s)}static clamp(t,e,s){return Q.clamp($e,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 ze(this.rows,this.cols,t)}get toOct(){let t=this.arr.flat(1).toOct;return new ze(this.rows,this.cols,t)}get toHex(){let t=this.arr.flat(1).toHex;return new ze(this.rows,this.cols,t)}max2min(){let t=this.arr.flat(1).max2min;return new ze(this.rows,this.cols,t)}min2max(){let t=this.arr.flat(1).min2max;return new ze(this.rows,this.cols,t)}sortRows(t=void 0){let e=this.arr.map((e=>e.sort(t))).flat(1);return new ze(this.rows,this.cols,e)}sortCols(t=void 0){let e=this.T.arr.map((e=>e.sort(t))).flat(1);return new ze(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 ze(s)}filterByCols(t){return new ze(this.T.arr.filter((e=>e.includes(t))))}sortAll(t=void 0){let e=this.arr.flat(1).sort(t);return new ze(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 ze(this.rows,this.cols,e)}#h(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 ze(this.rows,this.cols,e.flat(1))}hstack(...t){const e=[this,...t].reduce(((t,e)=>t.#h(e)));return Object.assign(this,e),this}static hstack(t,...e){return t.clone.hstack(...e)}#l(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 ze(this.rows,this.cols,e.flat(1))}vstack(...t){const e=[this,...t].reduce(((t,e)=>t.#l(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.#h(e)));return Object.assign(this,e),this}vqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#l(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 ze(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 Fe)&&(t[s]=ze.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]=Q.add(this.arr[r][e],t[s].arr[r][e])}return new ze(this.rows,this.cols,this.arr.flat(1))}sub(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=ze.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]=Q.sub(this.arr[r][e],t[s].arr[r][e])}return new ze(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]=ze.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]=Q.mul(this.arr[e][s],t[r].arr[e][s])}return new ze(this.rows,this.cols,this.arr.flat(1))}div(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=ze.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]=Q.div(this.arr[r][e],t[s].arr[r][e])}return new ze(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]=ze.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]=Q.modulo(this.arr[r][e],t[s].arr[r][e])}return new ze(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]=Q.add(e[s][r],Q.mul(this.arr[s][n],t.arr[n][r]))}}return new ze(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 Fe))}get min(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(H(...this.arr[e]));return H(...t)}get max(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(G(...this.arr[e]));return G(...t)}get minRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(H(...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(G(...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 ze(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 ze(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 ze(i).T}}const $e=(t,e,s)=>new ze(t,e,s);class Fe{constructor(t=0,e=0){t instanceof Fe?(this.a=t.a,this.b=t.b):"object"==typeof t?"a"in t&&"b"in t?(this.a=t.a,this.b=t.b):"a"in t&&"z"in t?(this.a=t.a,this.b=Ue(t.z**2-t.a**2)):"a"in t&&"phi"in t?(this.a=t.a,this.b=t.a*We(t.phi)):"b"in t&&"z"in t?(this.b=t.b,this.a=Ue(t.z**2-t.b**2)):"b"in t&&"phi"in t?(this.b=e,this.a=t.b/We(t.phi)):"z"in t&&"phi"in t&&(this.a=t.z*Ge(t.phi),this.a=t.z*Ve(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 Fe(this.a,this.b)}get z(){return Qe(this.a,this.b)}get phi(){return Xe(this.b,this.a)}static Zero(){return new Fe(0,0)}get conj(){return new Fe(this.a,-this.b)}get inv(){return new Fe(this.a/(Be(this.a,2)+Be(this.b,2)),-this.b/(Be(this.a,2)+Be(this.b,2)))}add(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Fe(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a+=+N(...e).toFixed(15),this.b+=+N(...s).toFixed(15),this}sub(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Fe(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a-=+N(...e).toFixed(15),this.b-=+N(...s).toFixed(15),this}mul(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Fe(t[e],0));let e=+Z(this.z,...t.map((t=>t.z))).toFixed(15),s=+N(this.phi,...t.map((t=>t.phi))).toFixed(15);return this.a=+(e*Ge(s).toFixed(15)).toFixed(14),this.b=+(e*Ve(s).toFixed(15)).toFixed(14),this}div(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Fe(t[e],0));let e=+(this.z/Z(...t.map((t=>t.z)))).toFixed(15),s=+(this.phi-N(...t.map((t=>t.phi)))).toFixed(15);return this.a=+(e*Ge(s).toFixed(15)).toFixed(15),this.b=+(e*Ve(s).toFixed(15)).toFixed(15),this}pow(t){if(Ye(t)===t&&t>0){let e=+(this.z**t).toFixed(15),s=+(this.phi*t).toFixed(15);this.a=+(e*Ge(s).toFixed(15)).toFixed(15),this.b=+(e*Ve(s).toFixed(15)).toFixed(15)}return this}static fromExpo(t,e){return new Fe(+(t*Ge(e)).toFixed(13),+(t*Ve(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 Le(t**this.a*Ge(this.b*He(t)),t**this.a*Ve(this.b*He(t)))}sqrtn(t=2){return Le(Ne(this.z,t)*Ge(this.phi/t),Ne(this.z,t)*Ve(this.phi/t))}get sqrt(){return this.sqrtn(2)}get log(){return Le(this.z,this.phi)}get cos(){return Le(Ge(this.a)*Ke(this.b),Ve(this.a)*Je(this.b))}get sin(){return Le(Ve(this.a)*Ke(this.b),Ge(this.a)*Je(this.b))}get tan(){const t=Ge(2*this.a)+Ke(2*this.b);return Le(Ve(2*this.a)/t,Je(2*this.b)/t)}}const Le=(t,e)=>{if((t instanceof Array||ArrayBuffer.isView(t))&&(e instanceof Array||ArrayBuffer.isView(t)))return t.map(((s,r)=>Le(t[r],e[r])));if(t instanceof ze&&e instanceof ze){if(t.shape[0]!==e.shape[0]||t.shape[1]!==e.shape[1])return Error(0);const s=t.arr.map(((s,r)=>Le(t.arr[r],e.arr[r])));return new ze(t.rows,t.cols,...s)}return new Fe(t,e)},qe=(...t)=>y(Math.abs,...t),Ue=(...t)=>y(Math.sqrt,...t),Be=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,e):e instanceof Fe?Fe.fromExpo(t**e.a,e.b*He(t)):y((e=>Be(t,e)),...e);if(t instanceof Fe)return"number"==typeof e?Fe.fromExpo(t.z**e,t.phi*e):e instanceof Fe?Fe.fromExpo(t.z**e.a*Ze(-t.phi*e.b),He(t.z)*e.b+e.a*t.phi):y((e=>Be(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return y((t=>Be(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(y((e=>Be(t[r],e)),...e));return s}}},Ne=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,1/e):y((e=>Ne(t,e)),...e);if(t instanceof Fe)return"number"==typeof e?Fe.fromExpo(Ne(t.z,e),t.phi/e):y((e=>Ne(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return y((t=>Ne(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(y((e=>Ne(t[r],e)),...e));return s}}},Ze=(...t)=>y(Math.exp,...t),He=(...t)=>y(Math.log,...t),Ge=(...t)=>y(w.cos,...t),Ve=(...t)=>y(w.sin,...t),We=(...t)=>y(w.tan,...t),Ke=(...t)=>y(w.cosh,...t),Je=(...t)=>y(w.sinh,...t),Ye=(...t)=>y(Math.floor,...t),Xe=(t,e,s=!0)=>{if("number"==typeof t)return"number"==typeof e?s?Math.atan2(t,e):180*Math.atan2(t,e)/Math.PI:y((e=>Xe(t,e,s)),...e);if(t instanceof Array){if("number"==typeof e)return y((t=>Xe(t,e,s)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(y((e=>Be(t[r],e)),...e));return s}}},Qe=(...t)=>t.every((t=>"number"==typeof t))?Math.hypot(...t):t.every((t=>t instanceof Array))?y(Math.hypot,...t):void 0,{PI:ts,sqrt:es,cos:ss,sin:rs,acos:ns,pow:is}=Math,as=t=>t,os=(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 cs{constructor(t,{ease:e=as,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()}#u=()=>{this.t+=this.state.step,this.i++,this.tx=R(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)};#f(t=!0){return this.state.isRunning||(t&&this.reset(!1),this.state.isRunning=!0,this.state.startTime=Date.now(),this.state.animationId=setInterval(this.#u,this.state.step)),this}start(){return this.#f(!0)}pause(){return this.state.isRunning&&(clearInterval(this.state.animationId),this.state.isRunning=!1),this}resume(){return this.#f(!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 hs{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 ls extends hs{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 us{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 fs{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 ms{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.mount(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}}function ps(t){return/:\w+/.test(t)}class ds extends ms{constructor({head:t,wrapper:e,target:s,routes:r}){super({head:t,wrapper:e,target:s}),this.routes=new Map([["404",Dt("Error 404")],...Object.entries(r)]),this.clear(),globalThis.onpopstate=this.mount(location.pathname)}clear(){return[...this.routes].forEach((t=>{!ps(t[0])&&t[1]?.isUIElement&&t[1].unmount()})),this}mount(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(ps(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.mount(this.wrapper),"function"==typeof s&&(r=s());return r?.isUIElement&&r.mount(this.wrapper),r instanceof Promise&&r.then((t=>t.mount(this.wrapper))),globalThis.history.pushState({},"",t),this}}const gs=({head:t,wrapper:e,target:s,routes:r})=>new ds({head:t,wrapper:e,target:s,routes:r});function bs(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 ws{#m;#p=new Map;#d=0;constructor(){const t=new Blob(['\n this.onmessage = function(e) {\n const { id, funStr, args, close } = e.data;\n try {\n const func = new Function("return " + funStr)();\n const result = func(...args);\n postMessage({ id, result });\n } catch (error) {\n postMessage({ id, error: error.message });\n } finally {\n if (close) self.close();\n }\n }\n '],{type:"text/javascript"});this.#m=new Worker(URL.createObjectURL(t)),this.#m.addEventListener("message",(t=>{const{id:e,result:s,error:r}=t.data,n=this.#p.get(e);n&&(n(s,r),this.#p.delete(e))}))}call(t,e,s=[],r=!0){if("function"!=typeof t)throw new TypeError("func must be a function");const n=++this.#d;return this.#p.set(n,e),this.#m.postMessage({id:n,funStr:t.toString(),args:s,close:r}),this}terminate(){this.#m.terminate()}}class ys{constructor(t=10){this.events={},this.maxListeners=t}on(t,e){return 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.`),this}once(t,e){const s=(...r)=>{this.off(t,s),e(...r)};return this.on(t,s)}off(t,e){const s=this.events[t];if(!s)return this;const r=s.indexOf(e);return-1!==r&&s.splice(r,1),this}emit(t,e){const s=this.events[t];return!!s&&([...s].forEach((s=>{try{s(e)}catch(e){console.error(`Error in listener for '${t}':`,e)}})),!0)}remove(t){return delete this.events[t],this}clear(){return this.events={},this}setMaxListeners(t){return this.maxListeners=t,this}}const vs=t=>new ys(t);class _s{#g;#b;#w=null;constructor(t=[],e=(()=>{})){this.#g=t,this.#b=e,this.#a()}#y(){return this.#g.some((({query:t})=>globalThis.matchMedia(t).matches))}#a(){this.#g.forEach((({query:t,callback:e})=>{const s=globalThis.matchMedia(t),r=()=>{const t=this.#y();s.matches?(e(),this.#w=e):t||this.#w===this.#b||(this.#b(),this.#w=this.#b)};r(),s.addEventListener("change",r)}))}}class xs{constructor(t=document.title,e=!0){this.cache={emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.emitter=vs(),this}setTitle(t){return t!==document.title&&(document.title=t,this.cache.emitter&&this.cache.emitter.emit("ziko:title-changed",t)),this}get current(){return document.title}onChange(t){return this.cache.emitter&&this.cache.emitter.on("ziko:title-changed",t),this}}class ks{constructor(t,{namespace:e="Ziko",ValidateCssProps:s=!1}={}){this.currentPropsMap=t,this.namespace=e,this.ValidateCssProps=s,this.use(t)}use(t){return this.ValidateCssProps&&function(t){const e=new Set(Object.keys(document.documentElement.style));for(const s in t)if(!e.has(s))throw new Error(`Invalid CSS property: "${s}"`)}(t),this.currentPropsMap=t,this.#o(),this}#o(){const t=globalThis?.document?.documentElement?.style;for(const 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})}}}let{sqrt:Es,cos:As,sin:Ts,exp:Ss,log:Os,cosh:js,sinh:Cs}=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,c=(t,e)=>new n.constructor(t,e);switch(e.name){case"abs":return n.z;case"sqrt":return c(Es(a)*As(o/2),Es(a)*Ts(o/2));case"log":return c(Os(a),o);case"exp":return c(Ss(t)*As(i),Ss(t)*Ts(i));case"cos":return c(As(t)*js(i),-Ts(t)*Cs(i));case"sin":return c(Ts(t)*js(i),As(t)*Cs(i));case"tan":{const e=As(2*t)+js(2*i);return c(Ts(2*t)/e,Cs(2*i)/e)}case"cosh":return c(js(t)*As(i),Cs(t)*Ts(i));case"sinh":return c(Cs(t)*As(i),js(t)*Ts(i));case"tanh":{const e=js(2*t)+As(2*i);return c(Cs(2*t)/e,Ts(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 ms({head:t,wrapper:e,target:s}),t.Base=tt,t.Clock=ls,t.Combinaison=st,t.Complex=Fe,t.E=s,t.EPSILON=r,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,{[bs(e[n],s)]:a})}return gs({target:document.body,routes:{"/":()=>{},...r},wrapper:be.section()})},t.Flex=(...t)=>{let e="div";return"string"==typeof t[0]&&(e=t[0],t.pop()),new we(e).append(...t)},t.HTMLWrapper=t=>new Ae(t),t.Logic=et,t.Matrix=ze,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=rt,t.SPA=gs,t.SVGWrapper=t=>new Te(t),t.Scheduler=(t,{repeat:e=null}={})=>new us(t,{repeat:e}),t.Suspense=(t,e)=>new Ee(t,e),t.Switch=({key:t,cases:e})=>new Se(t,e),t.Tick=hs,t.TimeAnimation=cs,t.TimeLoop=fs,t.TimeScheduler=us,t.UIElement=me,t.UIHTMLWrapper=Ae,t.UINode=pt,t.UISVGWrapper=Te,t.UISwitch=Se,t.UIView=pe,t.UseRoot=ks,t.UseThread=ws,t.Utils=Q,t.View=(...t)=>new pe(...t),t.ZikoApp=ms,t.ZikoEvent=Nt,t.ZikoSPA=ds,t.ZikoUIFlex=we,t.ZikoUISuspense=Ee,t.ZikoUIText=Pt,t.abs=qe,t.accum=V,t.acos=(...t)=>y(w.acos,...t),t.acosh=(...t)=>y(w.acosh,...t),t.acot=(...t)=>y(w.acot,...t),t.add=A,t.animation=(t,{ease:e,t0:s,t1:r,start:n,duration:i}={})=>new cs(t,{ease:e,t0:s,t1:r,start:n,duration:i}),t.arange=$,t.arc=t=>1-rs(ns(t)),t.arr2str=Pe,t.asin=(...t)=>y(w.asin,...t),t.asinh=(...t)=>y(w.asinh,...t),t.atan=(...t)=>y(w.atan,...t),t.atan2=Xe,t.atanh=(...t)=>y(w.atanh,...t),t.back=(t,e=1)=>t**2*((e+1)*t-e),t.bind_click_event=Jt,t.bind_clipboard_event=Yt,t.bind_drag_event=Xt,t.bind_focus_event=Qt,t.bind_key_event=te,t.bind_mouse_event=ee,t.bind_pointer_event=se,t.bind_swipe_event=ie,t.bind_touch_event=(t,e)=>new Nt("touch",t,Lt.Touch,null,e),t.bind_view_event=ne,t.bind_wheel_event=re,t.cartesianProduct=J,t.ceil=(...t)=>y(Math.ceil,...t),t.clamp=z,t.clock=t=>new ls(t),t.combinaison=(t,e,s=!1)=>st[s?"withDiscount":"withoutDiscount"](t,e),t.complex=Le,t.cos=Ge,t.cosh=Ke,t.cot=(...t)=>y(w.cot,...t),t.coth=(...t)=>y(w.coth,...t),t.csc=(...t)=>y(w.csc,...t),t.csv2arr=it,t.csv2json=(t,e=",")=>JSON.stringify(at(t,e)),t.csv2matrix=(t,e=",")=>new ze(it(t,e)),t.csv2object=at,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="";const t=e(this.props);t instanceof Array?t.forEach((t=>t.mount(this.shadowRoot))):t.mount(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=U,t.discret=(t,e=5)=>Math.ceil(t*e)/e,t.div=O,t.e=Ze,t.elastic=t=>-2*is(2,10*(t-1))*ss(20*ts*t/3*t),t.event_controller=qt,t.fact=(...t)=>y((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=Ye,t.geomspace=q,t.getEvent=Bt,t.hypot=Qe,t.inRange=W,t.in_back=(t,e=1.70158,s=e+1)=>s*is(t,3)-e*t**2,t.in_bounce=(t,e=7.5625,s=2.75)=>1-os(1-t,e,s),t.in_circ=t=>1-es(1-t**2),t.in_cubic=t=>t**3,t.in_elastic=(t,e=2*ts/3)=>0===t?0:1===t?1:-is(2,10*t-10)*rs((10*t-10.75)*e),t.in_expo=t=>0===t?0:2**(10*t-10),t.in_out_back=(t,e=1.70158,s=1.525*e)=>t<.5?is(2*t,2)*(2*(s+1)*t-s)/2:(is(2*t-2,2)*((s+1)*(2*t-2)+s)+2)/2,t.in_out_bounce=(t,e=7.5625,s=2.75)=>t<.5?os(1-2*t,e,s)/2:os(2*t-1,e,s)/2,t.in_out_circ=t=>t<.5?(1-es(1-(2*t)**2))/2:(es(1-(-2*t+2)**2)+1)/2,t.in_out_cubic=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,t.in_out_elastic=(t,e=2*ts/4.5)=>0===t?0:1===t?1:t<.5?-is(2,20*t-10)*rs((20*t-11.125)*e)/2:is(2,-20*t+10)*rs((20*t-11.125)*e)/2+1,t.in_out_expo=t=>0===t?0:1===t?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,t.in_out_quad=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,t.in_out_quart=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,t.in_out_quint=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,t.in_out_sin=t=>-(ss(ts*t)-1)/2,t.in_quad=t=>t**2,t.in_quart=t=>t**4,t.in_quint=t=>t**5,t.in_sin=t=>1-ss(t*ts/2),t.isApproximatlyEqual=K,t.isStateGetter=Ct,t.json2arr=t=>ot(t instanceof Object?t:JSON.parse(t)),t.json2css=De,t.json2csv=ht,t.json2csvFile=(t,e)=>{const s=ht(t,e),r=new Blob([s],{type:"text/csv;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2xml=mt,t.json2xmlFile=(t,e)=>{const s=mt(t,e),r=new Blob([s],{type:"text/xml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2yml=ft,t.json2ymlFile=(t,e)=>{const s=ft(t,e),r=new Blob([s],{type:"text/yml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.lerp=D,t.linear=as,t.linspace=F,t.ln=He,t.logspace=L,t.loop=(t,e={})=>new fs(t,e),t.map=R,t.mapfun=y,t.matrix=$e,t.matrix2=(...t)=>new ze(2,2,t),t.matrix3=(...t)=>new ze(3,3,t),t.matrix4=(...t)=>new ze(4,4,t),t.max=G,t.min=H,t.modulo=j,t.mul=S,t.norm=P,t.nums=I,t.obj2str=Me,t.ones=M,t.out_back=(t,e=1.70158,s=e+1)=>1+s*is(t-1,3)+e*is(t-1,2),t.out_bounce=os,t.out_circ=t=>es(1-(t-1)**2),t.out_cubic=t=>1-(1-t)**3,t.out_elastic=(t,e=2*ts/3)=>0===t?0:1===t?1:is(2,-10*t)*rs((10*t-.75)*e)+1,t.out_expo=t=>1===t?1:1-2**(-10*t),t.out_quad=t=>1-(1-t)**2,t.out_quart=t=>1-(1-t)**4,t.out_quint=t=>1-(1-t)**5,t.out_sin=t=>rs(t*ts/2),t.pgcd=Y,t.pow=Be,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=X,t.preload=nt,t.prod=Z,t.rad2deg=B,t.round=(...t)=>y(Math.round,...t),t.sec=(...t)=>y(w.sec,...t),t.sig=(...t)=>y((t=>1/(1+Ze(-t))),...t),t.sign=(...t)=>y(Math.sign,...t),t.sin=Ve,t.sinc=(...t)=>y(w.sinc,...t),t.sinh=Je,t.sleep=t=>new Promise((e=>setTimeout(e,t))),t.sqrt=Ue,t.sqrtn=Ne,t.step=(t,e=5)=>Math.floor(t*e)/e,t.step_fps=t=>1e3/t,t.sub=T,t.subSet=null,t.sum=N,t.svg2ascii=je,t.svg2img=(t,e=!0)=>be.img(Ce(t)).mount(e),t.svg2imgUrl=Ce,t.svg2str=Oe,t.tags=be,t.tan=We,t.tanh=(...t)=>y(w.tanh,...t),t.text=Dt,t.throttle=Vt,t.tick=(t,e,s=1/0,r=!0)=>new hs(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.toggle_event_listener=Ut,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=vs,t.useIPC=Et,t.useLocaleStorage=(t,e,s=!0)=>new At(localStorage,t,e,s),t.useMediaQuery=(t,e)=>new _s(t,e),t.useReactive=t=>y((t=>{const e=jt(t);return{get:e[0],set:e[1]}}),t),t.useRoot=(t,e={})=>new ks(t,e),t.useSessionStorage=Tt,t.useState=jt,t.useThread=(t,e,s=[],r=!0)=>(new ws).call(t,e,s,r),t.useTitle=(t,e=!0)=>new xs(t,e),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.zeros=C}));