eyjs 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/eye.min.js CHANGED
@@ -1 +1 @@
1
- const unitlessProps=new Set(["opacity","zIndex","fontWeight","lineHeight","flex","flexGrow","flexShrink","order"]);function getEvent(e,t={}){switch(e){case"click":case"dblclick":case"mousedown":case"mouseup":case"mousemove":case"mouseenter":case"mouseleave":case"mouseover":case"mouseout":return new MouseEvent(e,t);case"pointerdown":case"pointerup":case"pointermove":case"pointerenter":case"pointerleave":case"pointerover":case"pointerout":return new PointerEvent(e,t);case"keydown":case"keyup":case"keypress":return new KeyboardEvent(e,t);case"focus":case"blur":case"focusin":case"focusout":return new FocusEvent(e,t);case"input":case"change":case"submit":case"reset":return new Event(e,t);case"wheel":return new WheelEvent(e,t);case"copy":case"cut":case"paste":return new ClipboardEvent(e,t);case"scroll":case"resize":return new UIEvent(e,t);default:return new CustomEvent(e,t)}}const events=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","keydown","keypress","keyup","focus","blur","focusin","focusout","submit","change","input","reset","select","touchstart","touchend","touchmove","touchcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","dragstart","dragend","dragenter","dragover","dragleave","drop","resize","scroll","load","beforeunload","unload","play","pause","ended","volumechange","timeupdate","copy","cut","paste","animationstart","animationend","animationiteration","transitionstart","transitionend","DOMSubtreeModified","DOMNodeInserted","DOMNodeRemoved","error","hashchange","popstate"],htmlElements=["<base>","<head>","<link>","<meta>","<style>","<title>","<body>","<address>","<article>","<aside>","<footer>","<header>","<h1>","<h2>","<h3>","<h4>","<h5>","<h6>","<main>","<nav>","<section>","<blockquote>","<dd>","<div>","<dl>","<dt>","<figcaption>","<figure>","<hr>","<li>","<ol>","<p>","<pre>","<ul>","<a>","<abbr>","<b>","<bdi>","<bdo>","<br>","<cite>","<code>","<data>","<dfn>","<em>","<i>","<kbd>","<mark>","<q>","<rp>","<rt>","<ruby>","<s>","<samp>","<small>","<span>","<strong>","<sub>","<sup>","<time>","<u>","<var>","<wbr>","<area>","<audio>","<img>","<map>","<track>","<video>","<embed>","<iframe>","<object>","<picture>","<portal>","<source>","<canvas>","<noscript>","<script>","<del>","<ins>","<caption>","<col>","<colgroup>","<table>","<tbody>","<td>","<tfoot>","<th>","<thead>","<tr>","<button>","<datalist>","<fieldset>","<form>","<input>","<label>","<legend>","<meter>","<optgroup>","<option>","<output>","<progress>","<select>","<textarea>","<details>","<dialog>","<summary>","<slot>","<template>"],quickexec=["click","focus","blur","select","submit","reset"];function flat(e){let t="";for(let n=0;n<e.length;n++){const r=e[n];r===r.toUpperCase()&&r!==r.toLowerCase()?t+="-"+r:t+=r}return t.toLowerCase()}const localdata=new WeakMap;function cmcl(t,n){let r=[];for(const s in n){const i=n[s],[a,o]=s.split(":"),[l,...c]=a.split(".");let[u=null,h=null]=(o||"").split("-").map((e=>e.trim())),f=e(l.trim(),{class:c,parent:t,data:o?{value:u}:void 0});o&&u&&r.push({name:u,set(e,t){let n=e.find(`[data-value="${u}"]`);n&&(n[0].textContent=t??h)}}),!i||"object"!=typeof i||i instanceof Array||(r=r.concat(cmcl(f,i)))}return r}let delegationEvents=["click","dblclick","submit","input","change","keydown","keyup","keypress","focusin","focusout","mousedown","mouseup","mousemove","contextmenu","auxclick","wheel","mouseover","mouseout","pointerdown","pointerup","pointermove","pointerover","pointerout","gotpointercapture","lostpointercapture","pointercancel"],normalSetterGetter=(e,t,n)=>t;export class EyeElement{#e=null;#t=new Map;#n={value:normalSetterGetter,text:normalSetterGetter};constructor(e,t,n){let r=this;if(e instanceof HTMLElement)this.#e=[e];else if(htmlElements.includes(e))this.#e=[document.createElement(e.substring(1,e.length-1))];else if(Array.isArray(e))this.#e=[],e.forEach((e=>{e instanceof EyeElement?r.#e=r.#e.concat(...e.raw):e instanceof HTMLElement&&r.#e.push(e)}));else{let t="!"===e.slice(-1);this.#e=[...document.querySelectorAll(t?e.slice(0,-1):e)]}function s(e){let t=e.type,n=r.#t,s=e.target,i=this;if(n.has(t)){let r=n.get(t);r?.forEach((({callback:t,target:n})=>{s.closest(n)&&t(e,i)}))}}return this.each(((e,r)=>{let i=null;if(t)for(const n in t){const r=t[n];if("class"==n)e.classList.add.apply(e.classList,(r instanceof Array?r:r.split(" ")).filter((e=>""!=e)));else if("text"==n)e.textContent=r;else if("html"==n)e.innerHTML=r;else if("data"==n)for(const t in r)e.dataset[t]=r[t];else"parent"==n?i=r:n in e?e[n]=r:"_"!=n[0]&&e.setAttribute(n,r)}if(n)for(const t in n)-1!=t.indexOf("-")?e.style[t]=n[t]:e.style[flat(t)]=n[t];(i instanceof EyeElement||i instanceof HTMLElement)&&i.append(e),delegationEvents.forEach((t=>{e.addEventListener(t,s)}))})),events.forEach((e=>{r[e]=function(t){return t?"function"==typeof t&&r.on(e,t):quickexec.includes(e)?r.each((t=>t[e]())):r.trigger(e),r}})),this}get length(){return this.#e.length}get raw(){return this.#e}each(e){for(let t=0;t<this.#e.length;t++){if(!1===e(this.#e[t],t,this))break}return this}eachChild(e){let t=this;return this.each((function(n,r,s){let i=!0;for(let r=0;r<n.children.length&&(i=e(n.children[r],r,n,t),!1!==i);r++);}))}html(e){let t;return this.each(((n,r)=>{if(void 0===e)return t=n.innerHTML;n.innerHTML=e})),null!=t?t:this}text(e){let t;return this.each(((n,r)=>{if(void 0===e)return t=this.#n.text("get",n.textContent,n);n.textContent=this.#n.text("set",e,n)})),null!=t?t:this}data(e,t){if(localdata.has(this)||localdata.set(this,{}),e){if(null==t)return localdata.get(this)[e];localdata.get(this)[e]=t}return this}attr(e,t){let n="";return this.each(((r,s)=>{if(0===e.indexOf("data-")){let[s,i]=e.split("-").map((e=>e.trim()));if(null==t)return n=r.dataset[i];r.dataset[i]=t}else if(e in r){if(null==t)return n=r[e];r[e]=t}else if("_"!=e[0]){if(null==t)return n=r.getAttribute(e);r.setAttribute(e,t)}})),n||this}rAttr(e){return e&&this.each(((t,n)=>{t.removeAttribute(e)})),this}class(e){let t;return this.each(((n,r)=>{if("number"==typeof e)return t=n.classList.item(e);e.split(" ").forEach((e=>{if("-"==e[0])n.classList.remove(e.substring(1,e.length));else if("%"==e[0])n.classList.toggle(e.substring(1,e.length));else if("?"==e[0])t=n.classList.contains(e.substring(1,e.length));else if(-1!=e.indexOf("/")){let[t,r]=e.split("/");n.classList.replace(t,r)}else n.classList.add(e)}))})),null!=t?t:this}show(e){return this.each(((t,n)=>{t.style.display=e??"inline-block"})),this}hide(e){return this.each(((t,n)=>{e?t.style.opacity=0:t.style.display="none"})),this}append(e,t){return(Array.isArray(e)?e:[e]).forEach((e=>{let n=[];e instanceof EyeElement?n=[...e.raw]:e instanceof HTMLElement&&(n=[e]),n.forEach((e=>{switch(t){case"next":case"after":this.#e[0].after(e);break;case"previous":case"before":this.#e[0].before(e);break;case"afterbegin":case"first":this.#e[0].prepend(e);break;default:this.#e[0].append(e)}}))})),this}after(t){return t instanceof HTMLElement||t instanceof EyeElement||t instanceof Node?(this.#e[0].after(t instanceof EyeElement?t.raw[0]:t),this):this.#e[0].nextElementSibling?e(this.#e[0].nextElementSibling,t):null}before(t){return t instanceof HTMLElement||t instanceof EyeElement||t instanceof Node?(this.#e[0].before(t instanceof EyeElement?t.raw[0]:t),this):this.#e[0].previousElementSibling?e(this.#e[0].previousElementSibling,t):null}replaceWith(...e){let t=[];return(Array.isArray(e)?e:[e]).forEach((e=>{e instanceof EyeElement?t=t.concat(...e.raw):e instanceof HTMLElement&&t.push(e)})),this.#e[0].replaceWith(...t),this}parent(t,n){if(t){if(!(t instanceof HTMLElement||t instanceof EyeElement))throw new Error("[EyeJS] Unable to append current element to parent because it's not HTMLElement");return this.each((e=>{t.append(!0===n?e.cloneNode(!0):e)})),this}return e(this.#e[0].parentElement)}is(e,t){if("connected"===(e=e instanceof EyeElement?e.#e[0]:e))return this.#e[0].isConnected;switch(t){case"same":return this.#e[0].isSameNode(e);case"equal":return this.#e[0].isEqualNode(e);default:return console.error(`[EyeJS] Unknown check "${t}", possible values are ["same","equal","connected"]`),!1}}has(e){if("string"==typeof e)switch(e){case"next":return null!=this.#e[0].nextElementSibling;case"previous":return null!=this.#e[0].previousElementSibling;default:return null!=this.#e[0].querySelector(e)}}css(e,t){if(e){let n;return unitlessProps.has(e)||"number"!=typeof t||0==t||(t=`${t}px`),e=flat(e),this.each(((r,s)=>{if(void 0===t)return n=r.style[e];r.style[e]=t})),null!=n?n:this}return console.error('[EyeJS] missing argument "attr" in function .css')}remove(t,n){return this.each(((r,s)=>{"string"==typeof t?r.querySelectorAll(t).forEach((t=>{"function"==typeof n&&n(e(t)),t.remove()})):r.remove()})),this}on(e,t,n){return"function"!=typeof t?console.error("[EyeJS] .on method is missing the actuall callback `cb` or not of type function"):(e.split(" ").forEach((e=>{this.each((r=>{r.addEventListener(e,t,n)}))})),this)}delegate(e,t,n){let r=null;if(e.split(" ").forEach((e=>{if(!delegationEvents.includes(e))return r=e;_this.#t.has(e)||_this.#t.set(e,new Set),_this.#t.get(e).add({callback:n,target:t})})),null!==r)return console.warn(`[EyeJS] trying to use delegation with an inappropriate event "${r}"`)}once(e,t){this.on(e,t,{once:!0})}off(e,t){let n=this.#t;if("function"!=typeof t)return console.error("[EyeJS] .off method is missing the actuall callback `cb` or not of type function");e=e.split(" "),this.each(((n,r)=>{e.forEach((e=>n.removeEventListener(e,t)))})),e.forEach((e=>{if(n.has(e)){let r=n.get(e);for(const e of r)t===e.callback&&r.delete(e)}}))}trigger(e){return this.each(((t,n)=>{t.dispatchEvent(e instanceof Event?e:getEvent(e))})),this}find(t,n){let r=[];return this.each(((s,i)=>{s.querySelectorAll(t).forEach((t=>{"function"==typeof n&&n(e(t),e(s)),r.push(t)}))})),0==r.length?null:r}clone(e){let t=[];return this.each((e=>{t.push(e.cloneNode(!0))})),(e instanceof HTMLElement||e instanceof EyeElement)&&t.forEach((t=>e.append(t))),t}compute(e){return"bounds"===(e=e||"bounds")?this.#e[0].getBoundingClientRect():"style"==e?getComputedStyle(this.#e[0]):void console.error(`[EyeJS] unknown type "${e}" in function .compute, possible values are "bounds" "style"`)}client(e){return["width","height","left","top"].includes(e)?this.#e[0][`client${e[0].toUpperCase()}${e.substring(1,e.length)}`]:(console.error(`[EyeJS] Unknown client* attribute "${e}" in .client(attr)`),this)}pointer(e,t,n){return this.each(((r,s)=>{"capture"===e?!0===t?r.setPointerCapture(n):r.releasePointerCapture(n):"lock"===e&&(!0===t?r.requestPointerLock():document.exitPointerLock())})),this}get childlen(){return this.#e[0].children.length}child(t){return void 0===t?this.#e[0].children.length:this.#e[0].children[t]?e(this.#e[0].children[t]):null}val(e){return null==e?this.#n.value("get",this.#e[0].value,this.#e[0]):(this.each((t=>t.value=this.#n.value("set",e,t))),this)}serialize(e){e=e||{};let{inputs:t=["input","textarea","select"]}=e,n={json:{},url:"",fd:new FormData};return this.#e[0].querySelectorAll(t.join(",")).forEach(((t,r)=>{let s=t.name||t.dataset.name,i=t.value||t.textContent;"function"==typeof e[s]&&(i=e[s](t)),"file"==t.type?t.files.forEach((e=>{n.fd.append(s,e)})):(n.json[s]=i,n.fd.append(s,i))})),n.url=new URLSearchParams(n.json).toString(),n}redefine(e,t){return["text","value"].includes(e)&&"function"==typeof t&&(this.#n[e]=t),this}animate(e,t){let n=[];return t.duration=t.duration||1e3,this.each(((r,s)=>{n.push(r.animate(e,t))})),1==n.length?n[0]:n}position(){let e=-1;for(let t=0;t<this.#e[0].parentNode.children.length;t++){const n=this.#e[0].parentNode.children[t];if(this.#e[0].isSameNode(n)){e=t;break}}return e}getctx(e,t){return"function"==typeof this.#e[0].getContext?this.#e[0].getContext(e,t):this}}function e(t,n,r){if("string"==typeof t&&0===t.indexOf("model:")||"model"===t){if(!n)return console.error("[EyeJS] Model creation requires parameter 'attr' as prototype, none delivered!");let r=["eye-model"];(t=t.split(":"))[1]&&(r=r.concat(t[1].split(" ").filter((e=>""!=e))));let s=e("<div>",{class:r.join(" ")}),i=cmcl(s,n);return t=>{let n=e(s.clone(t?.parent));return n.refresh=function(e={}){let t=!1!==e.default;return i.forEach((r=>{(!0===t||!t&&e.hasOwnProperty(r.name))&&r.set(n,e[r.name])})),this},n.refresh(t)}}if(null!=t){let e=new EyeElement(t,n,r);return 0===e.length?null:e}}window.e=e,window.EyeElement=EyeElement;export default e;
1
+ const unitlessProps=new Set(["opacity","zIndex","fontWeight","lineHeight","flex","flexGrow","flexShrink","order"]);function getEvent(e,t={}){switch(e){case"click":case"dblclick":case"mousedown":case"mouseup":case"mousemove":case"mouseenter":case"mouseleave":case"mouseover":case"mouseout":return new MouseEvent(e,t);case"pointerdown":case"pointerup":case"pointermove":case"pointerenter":case"pointerleave":case"pointerover":case"pointerout":return new PointerEvent(e,t);case"keydown":case"keyup":case"keypress":return new KeyboardEvent(e,t);case"focus":case"blur":case"focusin":case"focusout":return new FocusEvent(e,t);case"input":case"change":case"submit":case"reset":return new Event(e,t);case"wheel":return new WheelEvent(e,t);case"copy":case"cut":case"paste":return new ClipboardEvent(e,t);case"scroll":case"resize":return new UIEvent(e,t);default:return new CustomEvent(e,t)}}const events=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","keydown","keypress","keyup","focus","blur","focusin","focusout","submit","change","input","reset","select","touchstart","touchend","touchmove","touchcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","dragstart","dragend","dragenter","dragover","dragleave","drop","resize","scroll","load","beforeunload","unload","play","pause","ended","volumechange","timeupdate","copy","cut","paste","animationstart","animationend","animationiteration","transitionstart","transitionend","DOMSubtreeModified","DOMNodeInserted","DOMNodeRemoved","error","hashchange","popstate"],htmlElements=["<base>","<head>","<link>","<meta>","<style>","<title>","<body>","<address>","<article>","<aside>","<footer>","<header>","<h1>","<h2>","<h3>","<h4>","<h5>","<h6>","<main>","<nav>","<section>","<blockquote>","<dd>","<div>","<dl>","<dt>","<figcaption>","<figure>","<hr>","<li>","<ol>","<p>","<pre>","<ul>","<a>","<abbr>","<b>","<bdi>","<bdo>","<br>","<cite>","<code>","<data>","<dfn>","<em>","<i>","<kbd>","<mark>","<q>","<rp>","<rt>","<ruby>","<s>","<samp>","<small>","<span>","<strong>","<sub>","<sup>","<time>","<u>","<var>","<wbr>","<area>","<audio>","<img>","<map>","<track>","<video>","<embed>","<iframe>","<object>","<picture>","<portal>","<source>","<canvas>","<noscript>","<script>","<del>","<ins>","<caption>","<col>","<colgroup>","<table>","<tbody>","<td>","<tfoot>","<th>","<thead>","<tr>","<button>","<datalist>","<fieldset>","<form>","<input>","<label>","<legend>","<meter>","<optgroup>","<option>","<output>","<progress>","<select>","<textarea>","<details>","<dialog>","<summary>","<slot>","<template>"],quickexec=["click","focus","blur","select","submit","reset"];function flat(e){let t="";for(let n=0;n<e.length;n++){const r=e[n];r===r.toUpperCase()&&r!==r.toLowerCase()?t+="-"+r:t+=r}return t.toLowerCase()}const localdata=new WeakMap;function cmcl(t,n){let r=[];for(const s in n){const i=n[s],[a,o]=s.split(":"),[l,...c]=a.split(".");let[u=null,h=null]=(o||"").split("-").map((e=>e.trim())),f=e(l.trim(),{class:c,parent:t,data:o?{value:u}:void 0});o&&u&&r.push({name:u,set(e,t){let n=e.find(`[data-value="${u}"]`);n&&(n[0].textContent=t??h)}}),!i||"object"!=typeof i||i instanceof Array||(r=r.concat(cmcl(f,i)))}return r}let delegationEvents=["click","dblclick","submit","input","change","keydown","keyup","keypress","focusin","focusout","mousedown","mouseup","mousemove","contextmenu","auxclick","wheel","mouseover","mouseout","pointerdown","pointerup","pointermove","pointerover","pointerout","gotpointercapture","lostpointercapture","pointercancel"],normalSetterGetter=(e,t,n)=>t;export class EyeElement{#e=null;#t=new Map;#n={value:normalSetterGetter,text:normalSetterGetter};constructor(t,n,r){let s=this;if(t instanceof HTMLElement)this.#e=[t];else if(htmlElements.includes(t))this.#e=[document.createElement(t.substring(1,t.length-1))];else if(Array.isArray(t))this.#e=[],t.forEach((e=>{e instanceof EyeElement?s.#e=s.#e.concat(...e.raw):e instanceof HTMLElement&&s.#e.push(e)}));else{let e="!"===t.slice(-1);this.#e=[...document.querySelectorAll(e?t.slice(0,-1):t)]}function i(t){let n=t.type,r=s.#t,i=t.target,a=s;if(r.has(n)){let s=r.get(n);s?.forEach((({callback:n,target:r})=>{if(i.closest(r)){const s=e(i.closest(r));n.call(i.closest(r),t,s,a)}}))}}return this.each(((e,t)=>{let s=null;if(n)for(const t in n){const r=n[t];if("class"==t)e.classList.add.apply(e.classList,(r instanceof Array?r:r.split(" ")).filter((e=>""!=e)));else if("text"==t)e.textContent=r;else if("html"==t)e.innerHTML=r;else if("data"==t)for(const t in r)e.dataset[t]=r[t];else"parent"==t?s=r:t in e?e[t]=r:"_"!=t[0]&&e.setAttribute(t,r)}if(r)for(const t in r)-1!=t.indexOf("-")?e.style[t]=r[t]:e.style[flat(t)]=r[t];(s instanceof EyeElement||s instanceof HTMLElement)&&s.append(e),delegationEvents.forEach((t=>{e.addEventListener(t,i)}))})),events.forEach((e=>{s[e]=function(t){return t?"function"==typeof t&&s.on(e,t):quickexec.includes(e)?s.each((t=>t[e]())):s.trigger(e),s}})),this}get length(){return this.#e.length}get raw(){return this.#e}each(e){for(let t=0;t<this.#e.length;t++){if(!1===e(this.#e[t],t,this))break}return this}eachChild(e){let t=this;return this.each((function(n,r,s){let i=!0;for(let r=0;r<n.children.length&&(i=e(n.children[r],r,n,t),!1!==i);r++);}))}html(e){let t="";return this.each(((n,r)=>{if(void 0===e)return t=n.innerHTML;n.innerHTML=e})),null==e?t:this}text(e){let t="";return this.each(((n,r)=>{if(void 0===e)return t=this.#n.text("get",n.textContent,n);n.textContent=this.#n.text("set",e,n)})),null==e?t:this}data(e,t){if(localdata.has(this)||localdata.set(this,{}),e){if(null==t)return localdata.get(this)[e];localdata.get(this)[e]=t}return this}attr(e,t){let n=null;return this.each(((r,s)=>{if(0===e.indexOf("data-")){let[s,i]=e.split("-").map((e=>e.trim()));if(null==t)return n=r.dataset[i];r.dataset[i]=t}else if(e in r){if(null==t)return n=r[e];r[e]=t}else if("_"!=e[0]){if(null==t)return n=r.getAttribute(e);r.setAttribute(e,t)}})),null==t?n:this}rAttr(e){return e&&this.each(((t,n)=>{t.removeAttribute(e)})),this}class(e){let t;return this.each(((n,r)=>{if("number"==typeof e)return t=n.classList.item(e);e.split(" ").forEach((e=>{if("-"==e[0])n.classList.remove(e.substring(1,e.length));else if("%"==e[0])n.classList.toggle(e.substring(1,e.length));else if("?"==e[0])t=n.classList.contains(e.substring(1,e.length));else if(-1!=e.indexOf("/")){let[t,r]=e.split("/");n.classList.replace(t,r)}else n.classList.add(e)}))})),null!=t?t:this}show(e){return this.each(((t,n)=>{t.style.display=e??"inline-block"})),this}hide(e){return this.each(((t,n)=>{e?t.style.opacity=0:t.style.display="none"})),this}append(e,t){return(Array.isArray(e)?e:[e]).forEach((e=>{let n=[];e instanceof EyeElement?n=[...e.raw]:e instanceof HTMLElement&&(n=[e]),n.forEach((e=>{switch(t){case"next":case"after":this.#e[0].after(e);break;case"previous":case"before":this.#e[0].before(e);break;case"afterbegin":case"first":this.#e[0].prepend(e);break;default:this.#e[0].append(e)}}))})),this}after(t){return t instanceof HTMLElement||t instanceof EyeElement||t instanceof Node?(this.#e[0].after(t instanceof EyeElement?t.raw[0]:t),this):this.#e[0].nextElementSibling?e(this.#e[0].nextElementSibling,t):null}before(t){return t instanceof HTMLElement||t instanceof EyeElement||t instanceof Node?(this.#e[0].before(t instanceof EyeElement?t.raw[0]:t),this):this.#e[0].previousElementSibling?e(this.#e[0].previousElementSibling,t):null}replaceWith(...e){let t=[];return(Array.isArray(e)?e:[e]).forEach((e=>{e instanceof EyeElement?t=t.concat(...e.raw):e instanceof HTMLElement&&t.push(e)})),this.#e[0].replaceWith(...t),this}parent(t,n){if(t){if(!(t instanceof HTMLElement||t instanceof EyeElement))throw new Error("[EyeJS] Unable to append current element to parent because it's not HTMLElement");return this.each((e=>{t.append(!0===n?e.cloneNode(!0):e)})),this}return e(this.#e[0].parentElement)}is(e,t){if("connected"===(e=e instanceof EyeElement?e.#e[0]:e))return this.#e[0].isConnected;switch(t){case"same":return this.#e[0].isSameNode(e);case"equal":return this.#e[0].isEqualNode(e);default:return console.error(`[EyeJS] Unknown check "${t}", possible values are ["same","equal","connected"]`),!1}}has(e){if("string"==typeof e)switch(e){case"next":return null!=this.#e[0].nextElementSibling;case"previous":return null!=this.#e[0].previousElementSibling;default:return null!=this.#e[0].querySelector(e)}}css(e,t){if(e){unitlessProps.has(e)||"number"!=typeof t||0==t||(t=`${t}px`);let n=null;return e=flat(e),this.each(((r,s)=>{if(void 0===t)return n=r.style[e];r.style[e]=t})),null==t?n:this}return console.error('[EyeJS] missing argument "attr" in function .css')}remove(t,n){return this.each(((r,s)=>{"string"==typeof t?r.querySelectorAll(t).forEach((t=>{"function"==typeof n&&n(e(t)),t.remove()})):r.remove()})),this}on(e,t,n){return"function"!=typeof t?console.error("[EyeJS] .on method is missing the actuall callback `cb` or not of type function"):(e.split(" ").forEach((e=>{this.each((r=>{r.addEventListener(e,t,n)}))})),this)}delegate(e,t,n){let r=null;if(e.split(" ").forEach((e=>{if(!delegationEvents.includes(e))return r=e;this.#t.has(e)||this.#t.set(e,new Set),this.#t.get(e).add({callback:n,target:t})})),null!==r)return console.warn(`[EyeJS] trying to use delegation with an inappropriate event "${r}"`)}once(e,t){this.on(e,t,{once:!0})}off(e,t){let n=this.#t;if("function"!=typeof t)return console.error("[EyeJS] .off method is missing the actuall callback `cb` or not of type function");e=e.split(" "),this.each(((n,r)=>{e.forEach((e=>n.removeEventListener(e,t)))})),e.forEach((e=>{if(n.has(e)){let r=n.get(e);for(const e of r)t===e.callback&&r.delete(e)}}))}trigger(e){return this.each(((t,n)=>{t.dispatchEvent(e instanceof Event?e:getEvent(e))})),this}find(t,n){let r=[];return this.each(((s,i)=>{s.querySelectorAll(t).forEach((t=>{"function"==typeof n&&n(e(t),e(s)),r.push(t)}))})),0==r.length?null:r}clone(e){let t=[];return this.each((e=>{t.push(e.cloneNode(!0))})),(e instanceof HTMLElement||e instanceof EyeElement)&&t.forEach((t=>e.append(t))),t}compute(e){return"bounds"===(e=e||"bounds")?this.#e[0].getBoundingClientRect():"style"==e?getComputedStyle(this.#e[0]):void console.error(`[EyeJS] unknown type "${e}" in function .compute, possible values are "bounds" "style"`)}client(e){return["width","height","left","top"].includes(e)?this.#e[0][`client${e[0].toUpperCase()}${e.substring(1,e.length)}`]:(console.error(`[EyeJS] Unknown client* attribute "${e}" in .client(attr)`),this)}pointer(e,t,n){return this.each(((r,s)=>{"capture"===e?!0===t?r.setPointerCapture(n):r.releasePointerCapture(n):"lock"===e&&(!0===t?r.requestPointerLock():document.exitPointerLock())})),this}get childlen(){return this.#e[0].children.length}child(t){return void 0===t?this.#e[0].children.length:this.#e[0].children[t]?e(this.#e[0].children[t]):null}val(e){return null==e?this.#n.value("get",this.#e[0].value,this.#e[0]):(this.each((t=>t.value=this.#n.value("set",e,t))),this)}serialize(e){e=e||{};let{inputs:t=["input","textarea","select"]}=e,n={json:{},url:"",fd:new FormData};return this.#e[0].querySelectorAll(t.join(",")).forEach(((t,r)=>{let s=t.name||t.dataset.name,i=t.value||t.textContent;"function"==typeof e[s]&&(i=e[s](t)),"file"==t.type?t.files.forEach((e=>{n.fd.append(s,e)})):(n.json[s]=i,n.fd.append(s,i))})),n.url=new URLSearchParams(n.json).toString(),n}redefine(e,t){return["text","value"].includes(e)&&"function"==typeof t&&(this.#n[e]=t),this}animate(e,t){let n=[];return t.duration=t.duration||1e3,this.each(((r,s)=>{n.push(r.animate(e,t))})),1==n.length?n[0]:n}position(){let e=-1;for(let t=0;t<this.#e[0].parentNode.children.length;t++){const n=this.#e[0].parentNode.children[t];if(this.#e[0].isSameNode(n)){e=t;break}}return e}getctx(e,t){return"function"==typeof this.#e[0].getContext?this.#e[0].getContext(e,t):this}}function e(t,n,r){if("string"==typeof t&&0===t.indexOf("model:")||"model"===t){if(!n)return console.error("[EyeJS] Model creation requires parameter 'attr' as prototype, none delivered!");let r=["eye-model"];(t=t.split(":"))[1]&&(r=r.concat(t[1].split(" ").filter((e=>""!=e))));let s=e("<div>",{class:r.join(" ")}),i=cmcl(s,n);return t=>{let n=e(s.clone(t?.parent));return n.refresh=function(e={}){let t=!1!==e.default;return i.forEach((r=>{(!0===t||!t&&e.hasOwnProperty(r.name))&&r.set(n,e[r.name])})),this},n.refresh(t)}}if(null!=t){let e=new EyeElement(t,n,r);return 0===e.length?null:e}}window.e=e,window.EyeElement=EyeElement;export default e;