tiny-essentials
Version:
Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.
1 lines • 93.9 kB
JavaScript
(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{TinySmartScroller:()=>I});var r={};t.r(r),t.d(r,{areElsCollBottom:()=>o,areElsCollLeft:()=>s,areElsCollPerfBottom:()=>l,areElsCollPerfLeft:()=>c,areElsCollPerfRight:()=>u,areElsCollPerfTop:()=>a,areElsCollRight:()=>i,areElsCollTop:()=>n,areElsColliding:()=>p,areElsPerfColliding:()=>f,getElsCollDetails:()=>w,getElsCollDirDepth:()=>E,getElsCollOverlap:()=>d,getElsCollOverlapPos:()=>g,getElsColliding:()=>m,getElsPerfColliding:()=>h,getElsRelativeCenterOffset:()=>b,getRectCenter:()=>y});const n=(t,e)=>t.bottom<e.top,o=(t,e)=>t.top>e.bottom,s=(t,e)=>t.right<e.left,i=(t,e)=>t.left>e.right,a=(t,e)=>t.bottom<=e.top,l=(t,e)=>t.top>=e.bottom,c=(t,e)=>t.right<=e.left,u=(t,e)=>t.left>=e.right,p=(t,e)=>!(s(t,e)||i(t,e)||n(t,e)||o(t,e)),f=(t,e)=>!(c(t,e)||u(t,e)||a(t,e)||l(t,e)),m=(t,e)=>s(t,e)?"left":i(t,e)?"right":n(t,e)?"top":o(t,e)?"bottom":null,h=(t,e)=>c(t,e)?"left":u(t,e)?"right":a(t,e)?"top":l(t,e)?"bottom":null,d=(t,e)=>({overlapLeft:e.right-t.left,overlapRight:t.right-e.left,overlapTop:e.bottom-t.top,overlapBottom:t.bottom-e.top}),g=({overlapLeft:t=-1,overlapRight:e=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:t<e?"right":"left",dirY:r<n?"bottom":"top"}),y=t=>({x:t.left+t.width/2,y:t.top+t.height/2});function b(t,e){const r=t.left+t.width/2,n=t.top+t.height/2;return{x:e.left+e.width/2-r,y:e.top+e.height/2-n}}function E(t,e){if(!f(t,e))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:s}=d(t,e),{dirX:i,dirY:a}=g({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:s}),l=Math.min(r,n),c=Math.min(o,s);let u;return u=l<c?i:a,{inDir:u,dirX:i,dirY:a,depthX:l,depthY:c}}function w(t,e){const r=f(t,e),n={in:null,x:null,y:null},o={y:null,x:null},s={top:0,bottom:0,left:0,right:0},{overlapLeft:i,overlapRight:a,overlapTop:l,overlapBottom:c}=d(e,t);s.top=l,s.bottom=c,s.left=i,s.right=a;const u=Object.entries(s).filter(([,t])=>t>0).sort((t,e)=>t[1]-e[1]),{dirX:p,dirY:m}=g({overlapLeft:a,overlapRight:i,overlapTop:c,overlapBottom:l});return n.y=m,n.x=p,s.bottom<0?o.y="bottom":s.top<0&&(o.y="top"),s.left<0?o.x="left":s.right<0&&(o.x="right"),n.in=r?s.top===s.bottom&&s.bottom===s.left&&s.left===s.right?"center":u.length?u[0][0]:"top":null,{dirs:n,depth:s,isNeg:o}}const T=class{#t;get el(){return this.#t}set el(t){if(this.#t)throw new Error("The observed element has already been set and cannot be reassigned.");if(void 0!==t&&!(t instanceof Element))throw new TypeError("The observed element must be a valid DOM Element.");this.#t=t}#e={};get settings(){return this.#e}set settings(t){if("object"!=typeof t||null===t)throw new TypeError("settings must be a non-null object.");this.#e=t}#r=null;get observer(){return this.#r}#n=[];get detectors(){return this.#n.map(t=>[t[0],t[1]])}set detectors(t){if(!Array.isArray(t))throw new TypeError("detectors must be an array.");const e=[];for(const[r,n]of t){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof n)throw new TypeError(`Detector handler for "${r}" must be a function.`);e.push([r,n])}this.#n=e}get isActive(){return!!this.#r}get size(){return this.#n.length}constructor({el:t,initDetectors:e=[],initCfg:r={}}={}){this.el=t,e.length&&(this.detectors=e),r&&(this.settings=r)}clear(){this.#n=[]}start(){if(!this.#t)throw new Error("Cannot start observation: no target element has been set.");this.#r||(this.#r=new MutationObserver(t=>{t.forEach((t,e,r)=>this.#n.forEach(n=>n[1](t,e,r)))}),this.#r.observe(this.#t,this.#e))}stop(){this.#r&&(this.#r.disconnect(),this.#r=null)}add(t,e){this.#o(t,e),this.#n.push([t,e])}insertAtStart(t,e){this.#o(t,e),this.#n.unshift([t,e])}insertAt(t,e,r,n="after"){if(this.#o(e,r),"number"!=typeof t||t<0||t>=this.#n.length)throw new RangeError("Invalid index for insertDetectorAt.");const o="before"===n?t:t+1;this.#n.splice(o,0,[e,r])}removeAt(t){if("number"!=typeof t||t<0||t>=this.#n.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#n.splice(t,1)}removeAround(t,e=0,r=0){if("number"!=typeof t||t<0||t>=this.#n.length)throw new RangeError("Invalid index for removeDetectorsAround.");const n=Math.max(0,t-e),o=e+1+r;this.#n.splice(n,o)}isIndexUsed(t){return t>=0&&t<this.#n.length}hasHandler(t){if("function"!=typeof t)throw new TypeError("Handler must be a function.");return this.#n.some(([e,r])=>r===t)}#o(t,e){if("string"!=typeof t||!t.trim())throw new TypeError("Detector name must be a non-empty string.");if("function"!=typeof e)throw new TypeError(`Detector handler for "${t}" must be a function.`)}destroy(){this.stop(),this.clear()}},{areElsColliding:v,areElsPerfColliding:A,areElsCollTop:S,areElsCollBottom:_,areElsCollLeft:x,areElsCollRight:C}=r,L=new WeakMap,N=new WeakMap,D=new WeakMap,B=new WeakMap,W={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class k{static Utils={...r};static#s=1;static get version(){return this.#s}static#i=!1;static get elemDebug(){return k.#i}static set elemDebug(t){if("boolean"!=typeof t)throw new TypeError("Expected a boolean value for elemDebug");k.#i=t}static _debugElemError(t,e){if(!k.#i)return;const r="[TinyHtml Debug] Element validation error";if(console.groupCollapsed(`${r}${e?" — details below":""}`),console.error(r),"undefined"!=typeof Error&&"function"==typeof Error.captureStackTrace){const t=new Error(r);Error.captureStackTrace(t,k._debugElemError),console.error(t.stack)}else console.trace(r);if(Array.isArray(t)){const e=t.map((t,e)=>({index:e,typeOf:null===t?"null":typeof t,constructor:t?.constructor?.name??(null===t?"null":"primitive"),summary:"undefined"!=typeof Element&&t instanceof Element?`${t.tagName?.toLowerCase?.()??"element"}#${t.id||""}.${String(t.className||"").trim().replace(/\s+/g,".")}`:t&&"object"==typeof t&&"nodeType"in t?`nodeType:${t.nodeType}`:"",value:t}));console.table(e)}else console.warn('[TinyHtml Debug] "elems" is not an array:',t);arguments.length>1&&(console.error("[TinyHtml Debug] Problematic element:",e),e&&"object"==typeof e&&console.dir(e)),console.groupEnd()}static parseStyle(t){const e={};return t.split(";").forEach(t=>{const[r,n]=t.split(":").map(t=>t&&t.trim());r&&n&&(e[r]=n)}),e}static#a=!0;static get autoStartElemObserver(){return k.#a}static set autoStartElemObserver(t){if("boolean"!=typeof t)throw new TypeError("autoStartElemObserver must be a boolean.");k.#a=t}static#l=new T({el:"undefined"!=typeof window&&void 0!==window.document?window.document.documentElement:void 0,initDetectors:[["tinyStyleEvent",t=>{if("attributes"!==t.type||"style"!==t.attributeName||!(t.target instanceof HTMLElement))return;const e=t.oldValue||"",r=t.target.getAttribute("style")||"",n=function(t,e){const r={added:{},removed:{},modified:{}};for(const n in t)n in e?t[n]!==e[n]&&(r.modified[n]={old:t[n],new:e[n]}):r.removed[n]=t[n];for(const n in e)n in t||(r.added[n]=e[n]);return r}(k.parseStyle(e),k.parseStyle(r));(Object.keys(n.added).length||Object.keys(n.removed).length||Object.keys(n.modified).length)&&t.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:n}))}],["tinyClassEvent",t=>{if("attributes"!==t.type||"class"!==t.attributeName||!(t.target instanceof HTMLElement))return;const e=t.oldValue||"",r=t.target.className||"",n=function(t,e){const r=t.filter(t=>!e.includes(t));return{added:e.filter(e=>!t.includes(e)),removed:r}}(e.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(n.added.length||n.removed.length)&&t.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:n}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}});static get tinyObserver(){return k.#l}static async fetchHtmlFile(t,e={method:"GET"}){const r=await fetch(t,e),n=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!n.includes("text/html"))throw new Error(`Invalid content type: ${n} (expected text/html)`);const o=await r.text();return k.htmlToJson(o)}static async fetchHtmlNodes(t,e){const r=await k.fetchHtmlFile(t,e);return k.jsonToNodes(r)}static async fetchHtmlTinyElems(t,e){const r=await k.fetchHtmlNodes(t,e);return k.toTinyElm(r)}static templateToJson(t){return k.htmlToJson([...t.content.childNodes].map(t=>t instanceof Element?t.getHTML():t instanceof Text?t.textContent:"").join(""))}static templateToNodes(t){const e=[];return[...t.content.cloneNode(!0).childNodes].map(t=>{if(!(t instanceof Element||t instanceof Text||t instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${t.constructor.name}`);t instanceof Comment||e.push(t)}),e}static templateToTinyElems(t){return k.toTinyElm(k.templateToNodes(t))}static htmlToJson(t){const e=document.createElement("div");e.innerHTML=t.trim();const r=[],n=t=>{if(t instanceof Comment)return null;if(t instanceof Text){const e=t.textContent?.trim();return e||null}if(!(t instanceof Element))return null;const e=t.tagName.toLowerCase(),r={};for(const e of t.attributes)r[k.getPropName(e.name)]=e.value;const o=Array.from(t.childNodes).map(n).filter(Boolean);return o.length>0?[e,r,...o]:[e,r]};for(const t of e.childNodes){const e=n(t);e&&r.push(e)}return e.innerHTML="",r}static jsonToNodes(t){const e=t=>{if("string"==typeof t)return document.createTextNode(t);if(!Array.isArray(t))return document.createTextNode("");const[r,n,...o]=t,s=document.createElement(r);for(const[t,e]of Object.entries(n))s.setAttribute(k.getAttrName(t),e);for(const t of o){const r=e(t);r instanceof Comment||s.appendChild(r)}return s};return t.map(e).filter(t=>!(t instanceof Comment))}static jsonToTinyElems(t){return k.toTinyElm(k.jsonToNodes(t))}static createFrom(t,e){if("string"!=typeof t)throw new TypeError('The "tagName" must be a string.');if(void 0!==e&&"object"!=typeof e)throw new TypeError('The "attrs" must be a object.');const r=k.createElement(t);if("object"==typeof e)for(const t in e)r.setAttr(t,e[t]);return r}static createElement(t,e){if("string"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==e&&"object"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new k(document.createElement(t,e))}static createTextNode(t){if("string"!=typeof t)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new k(document.createTextNode(t))}static createElementFromHTML(t){const e=document.createElement("template");if(!(t=t.trim()).startsWith("<"))return k.createTextNode(t);if(e.innerHTML=t,!(e.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new k(e.content.firstChild)}static createFromHTML(t){const e=document.createElement("template");t=t.trim(),e.innerHTML=t;const r=Array.from(e.content.childNodes);if(!r.every(t=>t instanceof Element||t instanceof Text))throw new Error("The HTML string must contain a valid HTML element.");return new k(r)}static createFromHtml(t){return k.createFromHTML(t)}static query(t,e=document){const r=e.querySelector(t);return r?new k(r):null}querySelector(t){return k.query(t,k._preElem(this,"query"))}static queryAll(t,e=document){return new k(e.querySelectorAll(t))}querySelectorAll(t){return k.queryAll(t,k._preElem(this,"queryAll"))}static getById(t){const e=document.getElementById(t);return e?new k(e):null}static getByClassName(t,e=document){return new k(e.getElementsByClassName(t))}getElementsByClassName(t){return k.getByClassName(t,k._preElem(this,"getByClassName"))}static getByName(t){return new k(document.getElementsByName(t))}static getByTagNameNS(t,e="http://www.w3.org/1999/xhtml",r=document){return new k(r.getElementsByTagNameNS(e,t))}getElementsByTagNameNS(t,e="http://www.w3.org/1999/xhtml"){return k.getByTagNameNS(t,e,k._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#t]}forEach(t){const e=this.elements.map((t,e)=>this.extract(e));for(const r in e)t(e[r],Number(r),e);return this}get(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");if(!this.#t[t])throw new Error(`No element found at index ${t}.`);return this.#t[t]}extract(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");if(!this.#t[t])throw new Error(`Cannot extract: no element exists at index ${t}.`);return new k(this.#t[t])}exists(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");return!!this.#t[t]}getAll(){return[...this.#t]}_getElement(t,e){if(!(this.#t[e]instanceof Element||this.#t[e]instanceof Window||this.#t[e]instanceof Document||this.#t[e]instanceof Text))throw k._debugElemError([...this.#t],this.#t[e]),new Error(`[TinyHtml] Invalid Element in ${t}().`);return this.#t[e]}_getElements(t){if(!this.#t.every(t=>t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw k._debugElemError([...this.#t]),new Error(`[TinyHtml] Invalid Element in ${t}().`);return[...this.#t]}static _preElemsTemplate(t,e,r,n){const o=t=>{const o=[];return t.map(s=>(s instanceof k?s._getElements(e):[s]).map(s=>{let i=!1;for(const t of r)if(s instanceof t){i=!0;break}if(!i)throw k._debugElemError([...t],s),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${e}().`);return o.push(s),s})),o};return Array.isArray(t)?o(t):o([t])}_preElemsTemplate(t,e,r){return k._preElemsTemplate(this,t,e,r)}static _preElemTemplate(t,e,r,n,o=!1){const s=t=>{const s=t[0],i=s instanceof k?s._getElements(e):[s];if(i.length>1)throw k._debugElemError([...t]),new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${i.length}/1).`);let a=!1;for(const t of r)if(i[0]instanceof t){a=!0;break}if(!o||null!==i[0]&&void 0!==i[0]||(i[0]=null,a=!0),!a)throw k._debugElemError([...t],i[0]),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${e}().`);return i[0]};if(!Array.isArray(t))return s([t]);if(t.length>1)throw k._debugElemError([...t]),new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${t.length}/1).`);return s(t)}_preElemTemplate(t,e,r,n=!1){return k._preElemTemplate(this,t,e,r,n)}static _preElems(t,e){return k._preElemsTemplate(t,e,[Element],["Element"])}_preElems(t){return k._preElems(this,t)}static _preElem(t,e){return k._preElemTemplate(t,e,[Element],["Element"])}_preElem(t){return k._preElem(this,t)}static _preNodeElems(t,e){return k._preElemsTemplate(t,e,[Node],["Node"])}_preNodeElems(t){return k._preNodeElems(this,t)}static _preNodeElem(t,e){return k._preElemTemplate(t,e,[Node],["Node"])}_preNodeElem(t){return k._preNodeElem(this,t)}static _preNodeElemWithNull(t,e){return k._preElemTemplate(t,e,[Node],["Node"],!0)}_preNodeElemWithNull(t){return k._preNodeElemWithNull(this,t)}static _preHtmlElems(t,e){return k._preElemsTemplate(t,e,[HTMLElement],["HTMLElement"])}_preHtmlElems(t){return k._preHtmlElems(this,t)}static _preHtmlElem(t,e){return k._preElemTemplate(t,e,[HTMLElement],["HTMLElement"])}_preHtmlElem(t){return k._preHtmlElem(this,t)}static _preInputElems(t,e){return k._preElemsTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(t){return k._preInputElems(this,t)}static _preInputElem(t,e){return k._preElemTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(t){return k._preInputElem(this,t)}static _preEventTargetElems(t,e){return k._preElemsTemplate(t,e,[EventTarget],["EventTarget"])}_preEventTargetElems(t){return k._preEventTargetElems(this,t)}static _preEventTargetElem(t,e){return k._preElemTemplate(t,e,[EventTarget],["EventTarget"])}_preEventTargetElem(t){return k._preEventTargetElem(this,t)}static _preElemsAndWindow(t,e){return k._preElemsTemplate(t,e,[Element,Window],["Element","Window"])}_preElemsAndWindow(t){return k._preElemsAndWindow(this,t)}static _preElemAndWindow(t,e){return k._preElemTemplate(t,e,[Element,Window],["Element","Window"])}_preElemAndWindow(t){return k._preElemAndWindow(this,t)}static _preElemsAndWinAndDoc(t,e){return k._preElemsTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]).map(t=>t instanceof Document?t.documentElement:t)}_preElemsAndWinAndDoc(t){return k._preElemsAndWinAndDoc(this,t)}static _preElemAndWinAndDoc(t,e){const r=k._preElemTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(t){return k._preElemAndWinAndDoc(this,t)}static _preElemsWithDoc(t,e){return k._preElemsTemplate(t,e,[Element,Document],["Element","Document"])}_preElemsWithDoc(t){return k._preElemsWithDoc(this,t)}static _preElemWithDoc(t,e){return k._preElemTemplate(t,e,[Element,Document],["Element","Document"])}_preElemWithDoc(t){return k._preElemWithDoc(this,t)}static toTinyElm(t){const e=t=>t.map(t=>t instanceof k?t:new k(t));return Array.isArray(t)?e(t):e([t])}static fromTinyElm(t){const e=t=>{const e=[];return t.map(t=>(t instanceof k?t._getElements("fromTinyElm"):[t]).map(t=>e.push(t))),e};return Array.isArray(t)?e(t):e([t])}static winnow(t,e,r,n=!1){if("boolean"!=typeof n)throw new TypeError('The "not" must be a boolean.');if("function"==typeof e)return k._preElems(t,r).filter((t,r)=>!!e.call(t,r,t)!==n);if(e instanceof Element)return k._preElems(t,r).filter(t=>t===e!==n);if(Array.isArray(e)||"string"!=typeof e&&null!=e.length)return k._preElems(t,r).filter(t=>e.includes(t)!==n);let o=e;return n&&(o=`:not(${o})`),k._preElems(t,r).filter(t=>1===t.nodeType&&t.matches(o))}static filter(t,e,r=!1){return r&&(e=`:not(${e})`),k._preElems(t,"filter").filter(t=>1===t.nodeType&&t.matches(e))}static filterOnly(t,e){return k.winnow(t,e,"filterOnly",!1)}static not(t,e){return k.winnow(t,e,"not",!0)}not(t){return k.not(this,t)}static find(t,e){const r=[];for(const n of k._preElems(t,"find"))r.push(...n.querySelectorAll(e));return[...new Set(r)]}find(t){return k.find(this,t)}static is(t,e){return k.winnow(t,e,"is",!1).length>0}is(t){return k.is(this,t)}static has(t,e){const r="string"==typeof e?[...document.querySelectorAll(e)]:k._preElems(e,"has");return k._preElems(t,"has").filter(t=>r.some(e=>t&&t.contains(e)))}has(t){return k.has(this,t)}static closest(t,e,r){const n=[];for(const o of k._preElems(t,"closest")){let t=o;for(;t&&t!==r;){if(1===t.nodeType&&("string"==typeof e?t.matches(e):t===e)){n.push(t);break}t=t.parentElement}}return[...new Set(n)]}closest(t,e){return k.closest(this,t,e)}static isSameDom(t,e){return k._preNodeElem(t,"isSameDom")===k._preNodeElem(e,"isSameDom")}isSameDom(t){return k.isSameDom(this,t)}#c={};get _data(){return{...this.#c}}set _data(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("value must be a non-null object.");this.#c=t}static _dataSelector={public:(t,e)=>{const r=k._preElem(e,t);let n=N.get(r);return n||(n={},N.set(r,n)),n},private:(t,e)=>{if(!(e instanceof k))throw new Error(`Element must be a TinyHtml instance to execute ${t}().`);return e.#c}};static data(t,e,r=!1){const n=k._dataSelector[r?"private":"public"]("data",t);if(null==e)return{...n};if("string"!=typeof e)throw new TypeError("The key must be a string.");return n.hasOwnProperty(e)?n[e]:void 0}data(t,e){return k.data(this,t,e)}static setData(t,e,r,n=!1){const o=k._dataSelector[n?"private":"public"]("setData",t);if("string"!=typeof e)throw new TypeError("The key must be a string.");return void 0!==r?o[e]=r:k.removeData(t,e),t}setData(t,e,r=!1){return k.setData(this,t,e,r)}static hasData(t,e,r=!1){if("string"!=typeof e)throw new TypeError("The key must be a string.");const n=k._dataSelector[r?"private":"public"]("hasData",t);return Object.prototype.hasOwnProperty.call(n,e)}hasData(t,e=!1){return k.hasData(this,t,e)}static removeData(t,e,r=!1){if("string"!=typeof e)throw new TypeError("The key must be a string.");return delete k._dataSelector[r?"private":"public"]("removeData",t)[e]}removeData(t,e=!1){return k.removeData(this,t,e)}static _getSibling(t,e,r){let n=k._preNodeElemWithNull(t,r);for(;n&&(n=n[e])&&1!==n.nodeType;);return n instanceof Node?n:null}static _getSiblings(t,e){let r=t;const n=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==e&&n.push(r);return n}static domDir(t,e,r,n="domDir"){if("string"!=typeof e)throw new TypeError('The "direction" must be a string.');let o=k._preNodeElemWithNull(t,n);const s=[];for(;o&&(o=o[e]);)if(1===o.nodeType){if(r&&("string"==typeof r?o.matches(r):o===r))break;s.push(o)}return s}static parent(t){let e=k._preNodeElemWithNull(t,"parent");const r=e?e.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return k.parent(this)}static parents(t,e){return k.domDir(t,"parentNode",e,"parents")}parents(t){return k.parents(this,t)}static next(t){return k._getSibling(t,"nextSibling","next")}next(){return k.next(this)}static prev(t){return k._getSibling(t,"previousSibling","prev")}prev(){return k.prev(this)}static nextAll(t){return k.domDir(t,"nextSibling",void 0,"nextAll")}nextAll(){return k.nextAll(this)}static prevAll(t){return k.domDir(t,"previousSibling",void 0,"prevAll")}prevAll(){return k.prevAll(this)}static nextUntil(t,e){return k.domDir(t,"nextSibling",e,"nextUtil")}nextUntil(t){return k.nextUntil(this,t)}static prevUntil(t,e){return k.domDir(t,"previousSibling",e,"prevUtil")}prevUntil(t){return k.prevUntil(this,t)}static siblings(t){const e=k._preNodeElemWithNull(t,"siblings");return k._getSiblings(e&&e.parentNode?e.parentNode.firstChild:null,e)}siblings(){return k.siblings(this)}static children(t){const e=k._preNodeElemWithNull(t,"children");return k._getSiblings(e?e.firstChild:null)}children(){return k.children(this)}static contents(t){const e=k._preNodeElemWithNull(t,"contents");return e instanceof HTMLIFrameElement&&null!=e.contentDocument&&Object.getPrototypeOf(e.contentDocument)?[e.contentDocument]:e instanceof HTMLTemplateElement?Array.from((e.content||e).childNodes):e?Array.from(e.childNodes):[]}contents(){return k.contents(this)}static clone(t,e=!0){if("boolean"!=typeof e)throw new TypeError('The "deep" must be a boolean.');return k._preNodeElems(t,"clone").map(t=>t.cloneNode(e))}clone(t){return k.clone(this,t)[0]}static _appendChecker(t,...e){const r=[];for(const n of e)if(null!=n&&!1!==n)if("string"!=typeof n&&"number"!=typeof n)if(n instanceof Node||n instanceof k)r.push(...k._preNodeElems(n,t));else if(Array.isArray(n))r.push(...k._appendChecker(t,...n));else for(const e in n){const o=n[e];r.push(...k._appendChecker(t,o))}else r.push(n);return r}static append(t,...e){return k._preElem(t,"append").append(...k._appendChecker("append",...e)),t}append(...t){return k.append(this,...t)}static prepend(t,...e){return k._preElem(t,"prepend").prepend(...k._appendChecker("prepend",...e)),t}prepend(...t){return k.prepend(this,...t)}static before(t,...e){return k._preElem(t,"before").before(...k._appendChecker("before",...e)),t}before(...t){return k.before(this,...t)}static after(t,...e){return k._preElem(t,"after").after(...k._appendChecker("after",...e)),t}after(...t){return k.after(this,...t)}static replaceWith(t,...e){return k._preElem(t,"replaceWith").replaceWith(...k._appendChecker("replaceWith",...e)),t}replaceWith(...t){return k.replaceWith(this,...t)}static appendTo(t,e){const r=k._preNodeElems(t,"appendTo"),n=k._preNodeElems(e,"appendTo");return n.forEach((t,e)=>{r.forEach(r=>t.appendChild(e===n.length-1?r:r.cloneNode(!0)))}),t}appendTo(t){return k.appendTo(this,t)}static prependTo(t,e){const r=k._preElems(t,"prependTo"),n=k._preElems(e,"prependTo");return n.forEach((t,e)=>{r.slice().reverse().forEach(r=>t.prepend(e===n.length-1?r:r.cloneNode(!0)))}),t}prependTo(t){return k.prependTo(this,t)}static insertBefore(t,e,r=null){const n=k._preNodeElem(t,"insertBefore"),o=k._preNodeElem(e,"insertBefore"),s=k._preNodeElemWithNull(r,"insertBefore");if(!o.parentNode)throw new Error("The target element has no parent node to insert before.");return o.parentNode.insertBefore(n,s||o),t}insertBefore(t,e){return k.insertBefore(this,t,e)}static insertAfter(t,e,r=null){const n=k._preNodeElem(t,"insertAfter"),o=k._preNodeElem(e,"insertBefore"),s=k._preNodeElemWithNull(r,"insertBefore");if(!o.parentNode)throw new Error("The target element has no parent node to insert after.");return o.parentNode.insertBefore(n,s||o.nextSibling),t}insertAfter(t,e){return k.insertAfter(this,t,e)}static replaceAll(t,e){const r=k._preNodeElems(t,"replaceAll"),n=k._preNodeElems(e,"replaceAll");return n.forEach((t,e)=>{const o=t.parentNode;r.forEach(r=>{o&&o.replaceChild(e===n.length-1?r:r.cloneNode(!0),t)})}),t}replaceAll(t){return k.replaceAll(this,t)}#t;get size(){return this.#t.length}static _elCheck(t){for(const e of t)if(!(e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")}add(t){return new k([...this.#t,...k._selector(t)])}static _selector(t){if(t instanceof k)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const e=t=>Array.from(new Set(t)),r="string"!=typeof t?t:document.querySelectorAll(t);if(Array.isArray(r))return k._elCheck(r),e(r);if(r instanceof NodeList||r instanceof HTMLCollection){const t=[...r];return k._elCheck(t),e(t)}{const t=[r];return k._elCheck(t),e(t)}}constructor(t){this.#t=k._selector(t),this.#u=k.#p}static isWindow(t){return null!=t&&t===t.window}static css(t){const e=k._preElem(t,"css");return window.getComputedStyle(e)}css(){return k.css(this)}static cssString(t,e){const r=k._preElem(t,"cssString");if("string"!=typeof e)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[e];return"string"==typeof n?n:"number"==typeof n?n.toString():null}cssString(t){return k.cssString(this,t)}static cssList(t,e){const r=k._preElem(t,"cssList");if(!Array.isArray(e))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),o={};for(const t of e)void 0!==t&&(o[t]=n.getPropertyValue(t));return o}cssList(t){return k.cssList(this,t)}static cssFloat(t,e){const r=k._preElem(t,"cssFloat");if("string"!=typeof e)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[e];return parseFloat(n)||0}cssFloat(t){return k.cssFloat(this,t)}static cssFloats(t,e){const r=k._preElem(t,"cssFloats");if(!Array.isArray(e))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),o={};for(const t of e)o[t]=parseFloat(n[t])||0;return o}cssFloats(t){return k.cssFloats(this,t)}static#f={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(k.#f,{set:(t,e,r)=>(t[e]=r,k.cssPropRevAliases[r]=e,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(k.#f).map(([t,e])=>[e,t]));static toStyleKc(t){return"string"==typeof k.cssPropAliases[t]?k.cssPropAliases[t]:t}static toStyleCc(t){return"string"==typeof k.cssPropRevAliases[t]?k.cssPropRevAliases[t]:t}static setStyle(t,e,r=null){return k._preHtmlElems(t,"setStyle").forEach(t=>{if("object"==typeof e)for(const[r,n]of Object.entries(e))t.style.setProperty(k.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else t.style.setProperty(k.toStyleKc(e),r)}),t}setStyle(t,e){return k.setStyle(this,t,e)}static getStyle(t,e){return k._preHtmlElem(t,"getStyle").style.getPropertyValue(k.toStyleKc(e))}getStyle(t){return k.getStyle(this,t)}static style(t,{camelCase:e=!1,rawAttr:r=!1}={}){if("boolean"!=typeof e)throw new TypeError('"camelCase" must be a boolean. Received: '+typeof e);if("boolean"!=typeof r)throw new TypeError('"rawAttr" must be a boolean. Received: '+typeof r);const n=k._preHtmlElem(t,"style"),o={};if(r){const t=(n.getAttribute("style")||"").split(";");for(const r of t){const[t,n]=r.split(":");if(!t||!n)continue;const s=t.trim(),i=n.trim();o[e?k.toStyleCc(s):s]=i}}else{const t=n.style;for(let r=0;r<t.length;r++){const n=t[r],s=t.getPropertyValue(n);o[e?k.toStyleCc(n):n]=s}}return o}style(t){return k.style(this,t)}static removeStyle(t,e){return k._preHtmlElems(t,"removeStyle").forEach(t=>{if(Array.isArray(e))for(const r of e)t.style.removeProperty(k.toStyleKc(r));else t.style.removeProperty(k.toStyleKc(e))}),t}removeStyle(t){return k.removeStyle(this,t)}static toggleStyle(t,e,r,n){return k._preHtmlElems(t,"toggleStyle").forEach(t=>{const o=k.getStyle(t,e).trim()===k.toStyleKc(r)?n:r;k.setStyle(t,e,o)}),t}toggleStyle(t,e,r){return k.toggleStyle(this,t,e,r)}static clearStyle(t){return k._preElems(t,"clearStyle").forEach(t=>t.removeAttribute("style")),t}clearStyle(){return k.clearStyle(this)}static focus(t){return k._preHtmlElem(t,"focus").focus(),t}focus(){return k.focus(this)}static blur(t){return k._preHtmlElem(t,"blur").blur(),t}blur(){return k.blur(this)}static select(t){const e=k._preHtmlElem(t,"select");if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("Element must be an <input> or <textarea> to use select().");return e.select(),t}select(){return k.select(this)}static boolCheck(t){return void 0!==t&&("true"===t||"1"===t||!0===t||"on"===t||"number"==typeof t&&t>0)}static setWinScrollTop(t){if("number"!=typeof t)throw new TypeError("The value must be a number.");k.setScrollTop(window,t)}static setWinScrollLeft(t){if("number"!=typeof t)throw new TypeError("The value must be a number.");k.setScrollLeft(window,t)}static winScrollTop(){return window.scrollY||document.documentElement.scrollTop}static winScrollLeft(){return window.scrollX||document.documentElement.scrollLeft}static winInnerHeight(){return window.innerHeight||document.documentElement.clientHeight}static winInnerWidth(){return window.innerWidth||document.documentElement.clientWidth}static isPageTop(){return 0===window.scrollY}static isPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}static getDimension(t,e,r="content"){const n=k._preElemAndWinAndDoc(t,"getDimension");if("string"!=typeof e)throw new TypeError("The type must be a string.");if("string"!=typeof r)throw new TypeError("The extra must be a string.");const o="width"===e?"Width":"Height";if(k.isWindow(n))return"margin"===r?n["inner"+o]:n.document.documentElement["client"+o];const s=n;if(9===s.nodeType){const t=s.documentElement;return Math.max(s.body["scroll"+o],t["scroll"+o],s.body["offset"+o],t["offset"+o],t["client"+o])}let i=s.getBoundingClientRect()[e];function a(t){return"width"===e?k.cssFloat(s,t+"Left")+k.cssFloat(s,t+"Right"):k.cssFloat(s,t+"Top")+k.cssFloat(s,t+"Bottom")}switch(r){case"content":i-=a("padding"),i-=a("border");break;case"padding":i-=a("border");break;case"border":break;case"margin":i+=a("margin")}return i}getDimension(t,e){return k.getDimension(this,t,e)}static setHeight(t,e){const r=k._preHtmlElem(t,"setHeight");if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("The value must be a string or number.");return r.style.height="number"==typeof e?`${e}px`:e,t}setHeight(t){return k.setHeight(this,t)}set height(t){k.setHeight(this,t)}static setWidth(t,e){const r=k._preHtmlElem(t,"setWidth");if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("The value must be a string or number.");return r.style.width="number"==typeof e?`${e}px`:e,t}setWidth(t){return k.setWidth(this,t)}set width(t){k.setWidth(this,t)}static height(t){const e=k._preElemAndWinAndDoc(t,"height");return k.getDimension(e,"height","content")}get height(){return k.height(this)}static width(t){const e=k._preElemAndWinAndDoc(t,"width");return k.getDimension(e,"width","content")}get width(){return k.width(this)}static innerHeight(t){const e=k._preElemAndWinAndDoc(t,"innerHeight");return k.getDimension(e,"height","padding")}innerHeight(){return k.innerHeight(this)}static innerWidth(t){const e=k._preElemAndWinAndDoc(t,"innerWidth");return k.getDimension(e,"width","padding")}innerWidth(){return k.innerWidth(this)}static outerHeight(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=k._preElemAndWinAndDoc(t,"outerHeight");return k.getDimension(r,"height",e?"margin":"border")}outerHeight(t){return k.outerHeight(this,t)}static outerWidth(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=k._preElemAndWinAndDoc(t,"outerWidth");return k.getDimension(r,"width",e?"margin":"border")}outerWidth(t){return k.outerWidth(this,t)}#u="";get mainDisplay(){return this.#u}set mainDisplay(t){if("string"!=typeof t)throw new TypeError("mainDisplay must be a string.");this.#u=t}static#p="block";static get defaultDisplay(){return k.#p}static set defaultDisplay(t){if("string"!=typeof t)throw new TypeError("defaultDisplay must be a string.");k.#p=t}static getAnimateData(t,e){let r=D.get(t);return r||(r={},D.set(t,r)),r[e]}static setAnimateData(t,e,r){if(!(t instanceof HTMLElement))throw new TypeError("setAnimateData: el must be an HTMLElement.");if("string"!=typeof e)throw new TypeError("setAnimateData: where must be a string.");if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("setAnimateData: value must be a string or number.");let n=D.get(t);n||(n={},D.set(t,n)),n[e]=r}static#m=!0;static get cancelOldStyleFx(){return k.#m}static set cancelOldStyleFx(t){if("boolean"!=typeof t)throw new TypeError("Expected a boolean value.");k.#m=t}static#h={slow:{duration:600,easing:"ease"},fast:{duration:200,easing:"ease-out"},_default:{duration:400,easing:"linear"}};static get styleFxSpeeds(){const t={};for(const e in k.#h){const r=k.#h[e];t[e]="object"==typeof r?{...r}:r}return t}static set styleFxSpeeds(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleFxSpeeds must be an object.");for(const[e,r]of Object.entries(t))if("number"!=typeof r&&"object"!=typeof r)throw new TypeError(`styleFxSpeeds["${e}"] must be a number or KeyframeAnimationOptions.`);k.#h={};for(const[e,r]of Object.entries(t))k.setStyleFxSpeed(e,r)}static getStyleFxSpeed(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');const e=k.#h[t];return"object"==typeof e?{...e}:e}static setStyleFxSpeed(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("number"!=typeof e&&"object"!=typeof e)throw new TypeError("styleFxSpeed must be a number or KeyframeAnimationOptions");k.#h[t]="object"==typeof e?{...e}:e}static deleteStyleFxSpeed(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete k.#h[t]}static hasStyleFxSpeed(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(k.#h,t)}static#d=["Top","Right","Bottom","Left"];static#g={slideDown:k.genStyleFx("show"),slideUp:k.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(k.#g))}static set styleEffects(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffects must be an object");for(const e in t)for(const[r,n]of Object.entries(t[e]))if(!("string"==typeof n||Array.isArray(n)&&n.every(t=>"string"==typeof t||"number"==typeof t)))throw new TypeError(`Invalid styleEffect["${r}"]`);k.#g={};for(const e in t)k.setStyleEffect(e,t[e])}static getStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');const e=k.#g[t];return e?JSON.parse(JSON.stringify(e)):void 0}static setStyleEffect(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffect must be an object");const r={};for(const[t,n]of Object.entries(e))if("string"==typeof n)r[t]=n;else{if(!Array.isArray(n)||!n.every(t=>"string"==typeof t||"number"==typeof t))throw new TypeError(`Invalid styleEffect["${t}"]`);r[t]=[...n]}k.#g[t]=r}static deleteStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete k.#g[t]}static hasStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(k.#g,t)}static#y={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...k.#y}}static set styleEffectInverse(t){if("object"!=typeof t||null===t)throw new TypeError("styleEffectInverse must be an object.");for(const[e,r]of Object.entries(t))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);k.#y={};for(const[e,r]of Object.entries(t))k.setStyleEffectInverse(e,r)}static getStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return k.#y[t]||null}static setStyleEffectInverse(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof e)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);k.#y[t]=e}static deleteStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete k.#y[t]}static hasStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(k.#y,t)}static#b={slideDown:t=>t.height[0]===t.height[1]&&(!t.width||t.width[0]===t.width[1]),slideUp:t=>t.height[0]===t.height[1]&&(!t.width||t.width[0]===t.width[1]),fadeIn:t=>Number(t.opacity[0])===Number(t.opacity[1]),fadeOut:t=>Number(t.opacity[0])===Number(t.opacity[1])};static get styleEffectsRd(){return{...k.#b}}static set styleEffectsRd(t){if("object"!=typeof t||null===t)throw new TypeError("styleEffectsRd must be an object.");for(const[e,r]of Object.entries(t))if("function"!=typeof r)throw new TypeError(`styleEffectsRd["${e}"] must be a function.`);k.#b={};for(const[e,r]of Object.entries(t))k.setStyleEffectRd(e,r)}static getStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return k.#b[t]||null}static setStyleEffectRd(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof e)throw new TypeError(`styleEffectsRd["${t}"] must be a function.`);k.#b[t]=e}static deleteStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete k.#b[t]}static hasStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(k.#b,t)}static#E={show:(t,e,r,n)=>{if("height"===r||"width"===r){const o=k.getAnimateData(t,`orig${r}`)||t.scrollHeight+"px";k.setAnimateData(t,`orig${r}`,o);const s=n[r];e[r]=[s,o]}else if(r.startsWith("margin")||r.startsWith("padding")){const o=k.getAnimateData(t,r)||n[r];k.setAnimateData(t,r,o),e[r]=["0px",o]}else if("opacity"===r){const t=n.opacity;e[r]=[t,1]}else{const o=k.getAnimateData(t,r)||n[r];k.setAnimateData(t,r,o),e[r]=[o,n[r]||1]}},hide:(t,e,r,n)=>{if("height"===r||"width"===r){const o=k.getAnimateData(t,`orig${r}`)||n[r];k.setAnimateData(t,`orig${r}`,o);const s=n[r];e[r]=[s,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const o=k.getAnimateData(t,r)||n[r];k.setAnimateData(t,r,o),e[r]=[n[r],"0px"]}else if("opacity"===r){const t=n.opacity;e[r]=[t,0]}else{const o=k.getAnimateData(t,r)||n[r];k.setAnimateData(t,r,o),e[r]=[o,0]}}};static get styleEffectsProps(){return{...k.#E}}static set styleEffectsProps(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffectsProps must be an object");for(const[e,r]of Object.entries(t))if("function"!=typeof r)throw new TypeError(`styleEffectsProps["${e}"] must be a function`);k.#E={};for(const[e,r]of Object.entries(t))k.setStyleEffectProp(e,r)}static getStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return k.#E[t]||null}static setStyleEffectProp(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof e)throw new TypeError(`styleEffectsProps["${t}"] must be a function`);k.#E[t]=e}static deleteStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete k.#E[t]}static hasStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(k.#E,t)}static genStyleFx(t,e=!1){if("string"!=typeof t)throw new TypeError("genStyleFx: type must be a string.");if("boolean"!=typeof e)throw new TypeError("genStyleFx: includeWidth must be a boolean.");let r,n=0;const o={height:t},s=e?1:0;for(;n<4;n+=2-s)r=k.#d[n],o["margin"+r]=t,o["padding"+r]=t;return e&&(o.opacity=t,o.width=t),o}static applyStyleFx(t,e,r,n){if("string"!=typeof e)throw new TypeError("applyStyleFx: id must be a string.");if("object"!=typeof r||null===r)throw new TypeError("applyStyleFx: props must be a non-null object.");if(void 0!==n&&"number"!=typeof n&&"string"!=typeof n&&("object"!=typeof n||null===n))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const o=new Map;return k._preHtmlElems(t,"applyStyleFx").forEach(s=>{const i={};for(const[t,e]of Object.entries(r))if("string"==typeof e&&this.#E[e]){const r=getComputedStyle(s);this.#E[e](s,i,t,r)}else{if("object"!=typeof e)throw new TypeError(`applyStyleFx: invalid action for prop "${t}". Must be string or array.`);i[t]=e}if("function"==typeof k.#b[e]&&k.#b[e](i))return void o.set(s,null);const a=[],l=i[Object.keys(i)[0]].length;for(let t=0;t<l;t++){const e={};for(const r in i)e[r]=i[r][t];a.push(e)}o.set(s,k.animate(t,a,n,e)[0])}),o}applyStyleFx(t,e,r){return k.applyStyleFx(this,t,e,r)}static getCurrentAnimationId(t){if(!(t instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return B.get(t)?.id??void 0}static animate(t,e,r=k.#h._default,n