UNPKG

almostnojs

Version:

A minimalist, dependency-free JavaScript framework featuring tagged template rendering, DOM morphing, custom elements, state management, event handling, animations, and HTTP requests.

4 lines (3 loc) 21.1 kB
/* AlmostNo.js v1.3.0 Full */ (()=>{var ft=Object.defineProperty;var y=(t,n)=>()=>(t&&(n=t(t=0)),n);var v=(t,n)=>{for(var e in n)ft(t,e,{get:n[e],enumerable:!0})};var M,a,g=y(()=>{M=typeof window<"u"?window:global;if(!M.__AnJS__){class t extends Array{constructor(e){super(),e&&(e instanceof HTMLElement||e.nodeType===1?this.push(e):e instanceof NodeList||Array.isArray(e)?this.push(...e):typeof e=="string"&&this.push(...document.querySelectorAll(e)))}each(e){return this.forEach(e),this}get(e){return e===void 0?this:this.at(e)}clone(e=!0){return this[0]?this[0].cloneNode(e):null}}M.__AnJS__=t}a=M.__AnJS__});var _t={};var U=y(()=>{g();Object.assign(a.prototype,{filter(t){return typeof t=="function"?new a([...this].filter(t)):new a([...this].filter(n=>n.matches(t)))},find(t){return new a(this.flatMap(n=>[...n.querySelectorAll(t)]))},first(){return new a(this.length?[this[0]]:[])},last(){return new a(this.length?[this[this.length-1]]:[])},even(){return new a(this.filter((t,n)=>!(n%2)))},odd(){return new a(this.filter((t,n)=>n%2))}})});var wt={};var I=y(()=>{g();Object.assign(a.prototype,{next(){return new a(this[0]?.nextElementSibling?[this[0].nextElementSibling]:[])},prev(){return new a(this[0]?.previousElementSibling?[this[0].previousElementSibling]:[])},parent(){return new a(this[0]?.parentElement?[this[0].parentElement]:[])},children(){return new a(this[0]?[...this[0].children]:[])},siblings(){let t=this[0]?.parentElement;return new a(t?[...t.children].filter(n=>n!==this[0]):[])},closest(t){return new a(this[0]?.closest(t)?[this[0].closest(t)]:[])}})});var J={};v(J,{bindings:()=>A,localBindings:()=>_});function St(t,n,e){return new Proxy(n,{get:(i,o)=>i[o],set:(i,o,s)=>(i[o]=s,e&&(e==="session"?sessionStorage:localStorage).setItem(t,JSON.stringify(i)),!0)})}var A,_,p,N,H,G=y(()=>{g();A={},_=new Map,p=typeof window<"u"&&(window.__AnJS_GLOBAL_STATES__||(window.__AnJS_GLOBAL_STATES__={}))||{},N={},H=new Set(["disabled","checked","selected","readonly","multiple","hidden","autoplay","controls","loop","muted"]);a.prototype.global=function(t,n,e={}){if(!t||typeof t!="string")throw new Error("Global state must have a unique name.");if(!p[t]&&n===void 0)throw new Error(`Global state "${t}" does not exist. Provide an initial state.`);if(e.persist){let o=(e.persist==="session"?sessionStorage:localStorage).getItem(t);o&&(n=JSON.parse(o))}return!p[t]&&n!==void 0&&(p[t]=$.state(St(t,n,e.persist))),p[t]};a.prototype.clearGlobal=function(t){p[t]&&(delete p[t],localStorage.removeItem(t),sessionStorage.removeItem(t))};a.prototype.hasGlobal=function(t){return!!p[t]};a.prototype.state=function(t={},n={}){var u;let e=!!n.global;if(e){if(!n.name)throw new Error("Global state must have a name.");t=p[u=n.name]??(p[u]=t)}let i=new Map,o=null;function s(f,c){let d=i.get(f);d&&d.forEach(h=>h(c,f));let l=i.get("*");l&&l.forEach(h=>h(c,f))}let r=new Proxy(t,{get:(f,c)=>c==="onChange"?(d,l)=>(i.has(d)||i.set(d,new Set),i.get(d).add(l),()=>i.get(d)?.delete(l)):c==="onAny"?d=>(i.has("*")||i.set("*",new Set),i.get("*").add(d),()=>i.get("*")?.delete(d)):c==="patch"?d=>{o=new Set;for(let[h,b]of Object.entries(d))r[h]=b;let l=o;o=null;for(let h of l)s(h,f[h])}:f[c],set:(f,c,d)=>(f[c]=d,e&&Object.keys(A).forEach(l=>{let[h,...b]=l.split(".");if(!A[l])return;let ct=b.reduce((R,ut)=>R?.[ut],p[h]);A[l].forEach(R=>R.textContent=ct??"")}),A[c]?.forEach(l=>l.textContent=d??""),_.get(r)?.[c]?.forEach(l=>l.textContent=d??""),N[c]?.forEach(({el:l,attr:h})=>{d==null?l.removeAttribute(h):H.has(h.toLowerCase())?l.toggleAttribute(h,!!d):l.setAttribute(h,d)}),o?o.add(c):s(c,d),!0)});return _.set(r,{}),this.bind(r),r};a.prototype.bind=function(t,n=document){n.querySelectorAll("[data-bind], [data-bind-this], [data-bind-attr]").forEach(e=>{var u;if(e.dataset.bound)return;e.dataset.bound="true";let[i,o]=e.getAttribute("data-bind-attr")?.split(":")||[null,e.getAttribute("data-bind")||e.getAttribute("data-bind-this")],s=o?.split("."),r=s?.length>1?s.slice(1).reduce((f,c)=>f?.[c],p[s[0]]??t):t[o]??p[o];e.hasAttribute("data-bind")?((A[o]||(A[o]=[])).push(e),e.textContent=r??""):e.hasAttribute("data-bind-this")?(((u=_.get(t))[o]||(u[o]=[])).push(e),e.textContent=r??""):((N[o]||(N[o]=[])).push({el:e,attr:i}),H.has(i.toLowerCase())?e.toggleAttribute(i,!!r):e.setAttribute(i,r??""),i==="value"&&["INPUT","TEXTAREA"].includes(e.tagName)&&e.addEventListener("input",()=>t[o]=e.value))}),this.autoEvents(t,n)};a.prototype.autoEvents=function(t,n=document){n.querySelectorAll("[data-on]").forEach(e=>{var s;let[i,o]=e.getAttribute("data-on")?.split(":");if(!e.dataset.boundEvent&&typeof t[o]=="function"){e.dataset.boundEvent="true";let r=u=>t[o]?.(u,t);e.addEventListener(i,r),_.has(t)||_.set(t,{}),((s=_.get(t))[i]||(s[i]=[])).push({el:e,event:i,handler:r})}}),n.querySelectorAll("[data-action]").forEach(e=>{let i=e.dataset.action;e.dataset.boundAction||(e.dataset.boundAction="true",e.addEventListener("click",o=>{if(typeof t[i]=="function")return t[i](o,t);let[s,r]=(i||"").split(".");typeof p[s]?.[r]=="function"&&p[s][r](o,p[s])}))})};a.prototype.unbind=function(t){Object.values(_.get(t)).forEach(n=>n.forEach(({el:e,event:i,handler:o})=>e.removeEventListener(i,o))),[A,N].forEach(n=>Object.keys(t).forEach(e=>delete n[e])),_.delete(t)}});var B={};v(B,{default:()=>xt,startObserver:()=>D});function D(){document.readyState!=="loading"?C.observer():document.addEventListener("DOMContentLoaded",()=>C.observer())}var C,xt,V=y(()=>{g();C={registry:{},observer(){new MutationObserver(t=>{t.forEach(({addedNodes:n})=>{n.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this.registry[e.tagName.toLowerCase()]&&this.mount(e,e.tagName.toLowerCase())})})}).observe(document.body,{childList:!0,subtree:!0})},register(t,n,e,i){if(!e&&!i)return;let o=()=>$.state({}),s=()=>{};if(typeof e=="function")try{o=typeof e()=="object"?e:o}catch{s=e}typeof i=="function"&&(s=i),this.registry[t.toLowerCase()]={template:n,state:o,handlers:s},document.querySelectorAll(t.toLowerCase()).forEach(r=>this.mount(r,t))},mount(t,n){let{template:e,state:i,handlers:o}=this.registry[n.toLowerCase()];if(t.dataset.__mounted)return;t.dataset.__mounted="true";let s=Object.fromEntries([...t.attributes].map(f=>[f.name,f.value])),r=a.prototype.state({...i(),...s}),u=this.render(e({state:r,props:s}),r);t.replaceWith(u),$(u).bind(r),u.querySelectorAll(Object.keys(this.registry).join(",")).forEach(f=>this.mount(f,f.tagName.toLowerCase())),this.bind(u,o,r)},render(t,n={}){let e=document.createElement("div");e.innerHTML=t.trim();let i=e.firstElementChild||null;return i?(n&&$(i).bind(n),i):null},bind(t,n,e){if(typeof n=="function")return n($(t),e);Object.entries(n).forEach(([i,o])=>{$(t).on(i,"[data-action]",s=>{let r=s.target.dataset.action;o[r]&&(o[r](e,s),$(t).bind(e))})})}};a.prototype.component=function(t,n,e,i){C.register(t,n,e,i)};a.prototype.render=C.render;D();xt=C});function z(t){return typeof console<"u"&&console.warn("[AnJS] unsafeHTML() is an escape hatch \u2014 convert this call site to use html`...` instead."),new L(t)}function W(t,...n){return new E(t,n)}function S(t,n){if(!(t instanceof E))throw new TypeError(`render() expects a TemplateResult, got ${Array.isArray(t)?"Array":typeof t}. Wrap with html\`...\` first.`);let e=q.get(n);if(!e||e.strings!==t.strings){let i=t.strings.reduce((u,f,c)=>{if(c>=t.values.length)return u+f;let d=Lt(c);return/=\s*$/.test(f)?u+f+'"'+d+'"':u+f+d},""),o=document.createElement("template");o.innerHTML=i;let s=[];K(o.content,s),n.innerHTML="",n.appendChild(o.content.cloneNode(!0));let r=Rt(s,n);e={strings:t.strings,parts:r,values:t.values.map(()=>Nt)},q.set(n,e)}Mt(e,t.values)}function Lt(t){return`${Ct}${t}${vt}`}function K(t,n,e=[]){let i=0;for(let o=t.firstChild;o;o=o.nextSibling){if(o.nodeType===8){let s=o.data.trim();if(s.startsWith("anjs-")){let r=parseInt(s.slice(5),10);isNaN(r)||n.push({type:"node",index:r,path:[...e,i]})}}else if(o.nodeType===1){let s=[...o.attributes];for(let r of s){let u=/<!--anjs-(\d+)-->/g,f=r.value.split(u);if(f.length<=1)continue;let c=[],d=[];for(let l=0;l<f.length;l++)l%2===0?c.push(f[l]):d.push(parseInt(f[l],10));for(let l=0;l<d.length;l++)n.push({type:"attr",index:d[l],path:[...e,i],name:r.name,statics:c,attrIndices:d,slotIndex:l});o.setAttribute(r.name,c.join(""))}K(o,n,[...e,i])}i++}}function Rt(t,n){return t.map(e=>{let i=n;for(let s of e.path)if(i=i.childNodes[s],!i)return null;if(e.type==="node"){let s=document.createTextNode("");return i.parentNode.replaceChild(s,i),{type:"node",index:e.index,node:s}}let o={type:"attr",index:e.index,node:i,name:e.name};return e.statics&&(o.statics=e.statics,o.attrIndices=e.attrIndices,o.slotIndex=e.slotIndex),o}).filter(Boolean)}function Mt(t,n){for(let e of t.parts){let i=n[e.index],o=t.values[e.index];if(i!==o){if(e.type==="node")if(i instanceof E)e._container||(e._container=document.createElement("span"),e._container.style.display="contents",e.node.parentNode.replaceChild(e._container,e.node)),S(i,e._container);else if(i instanceof L)e._container||(e._container=document.createElement("span"),e._container.style.display="contents",e.node.parentNode.replaceChild(e._container,e.node)),e._container.innerHTML=i.value;else if(Array.isArray(i))Ot(e,i);else if(i==null||i===!1)if(e._container){let s=document.createTextNode("");e._container.parentNode.replaceChild(s,e._container),e.node=s,delete e._container,delete e._items}else e.node.data="";else if(e._container){let s=document.createTextNode(String(i));e._container.parentNode.replaceChild(s,e._container),e.node=s,delete e._container}else e.node.data=String(i);else if(e.type==="attr")if(e.statics){let s=e.statics,r=e.attrIndices;if(r.length===1&&s[0]===""&&s[1]===""&&typeof i=="boolean")i?e.node.setAttribute(e.name,""):e.node.removeAttribute(e.name);else{let u=s[0];for(let f=0;f<r.length;f++){let c=n[r[f]];u+=c==null||c===!1?"":String(c),u+=s[f+1]}e.node.setAttribute(e.name,u)}}else i===!0?e.node.setAttribute(e.name,""):i===!1||i==null?e.node.removeAttribute(e.name):e.node.setAttribute(e.name,String(i))}}t.values=[...n]}function Ot(t,n){t._items||(t._items=[],t._keys=[],t._container||(t._container=document.createElement("span"),t._container.style.display="contents",t.node.parentNode.replaceChild(t._container,t.node)));let e=t._container,i=t._items,o=t._keys;if(n.length>0&&n[0]&&n[0]._key!==void 0){let r=new Map;for(let c=0;c<o.length;c++)r.set(o[c],i[c]);let u=[],f=[];for(let c=0;c<n.length;c++){let d=n[c],l=d._key;f.push(l);let h=r.get(l);if(h)d instanceof E?S(d,h):h.textContent=String(d??""),u.push(h),r.delete(l);else{let b=document.createElement("span");b.style.display="contents",d instanceof E?S(d,b):b.textContent=String(d??""),u.push(b)}}for(let c of r.values())c.remove();for(let c=0;c<u.length;c++){let d=u[c],l=e.childNodes[c];l!==d&&e.insertBefore(d,l||null)}t._items=u,t._keys=f;return}for(let r=0;r<n.length;r++){let u=n[r];if(r<i.length)u instanceof E?S(u,i[r]):i[r].textContent=String(u??"");else{let f=document.createElement("span");f.style.display="contents",u instanceof E?S(u,f):f.textContent=String(u??""),e.appendChild(f),i.push(f)}}for(;i.length>n.length;)i.pop().remove()}var q,Nt,E,L,Ct,vt,X=y(()=>{q=new WeakMap,Nt=Symbol("empty"),E=class{constructor(n,e){this.strings=n,this.values=e}},L=class{constructor(n){this.value=String(n??"")}};Ct="<!--anjs-",vt="-->"});function Q(t,n){let e=document.createElement("template");e.innerHTML=n,Y(t,t.childNodes,e.content.childNodes)}function Y(t,n,e){let i=e.length;for(let o=0;o<i;o++){let s=n[o],r=e[o];if(!s){t.appendChild(r.cloneNode(!0));continue}if(s.nodeType===r.nodeType){if(s.nodeType===3||s.nodeType===8){s.data!==r.data&&(s.data=r.data);continue}if(s.nodeType===1&&s.tagName===r.tagName){Pt(s,r),Y(s,s.childNodes,r.childNodes);continue}}t.replaceChild(r.cloneNode(!0),s)}for(;t.childNodes.length>i;)t.removeChild(t.lastChild)}function Pt(t,n){for(let{name:o,value:s}of n.attributes)t.getAttribute(o)!==s&&t.setAttribute(o,s);for(let{name:o}of[...t.attributes])n.hasAttribute(o)||t.removeAttribute(o);let e=t.tagName,i=document.activeElement===t;(e==="INPUT"||e==="TEXTAREA")&&(t.value!==n.value&&!i&&(t.value=n.value||""),(t.type==="checkbox"||t.type==="radio")&&t.checked!==n.checked&&!i&&(t.checked=n.checked)),e==="SELECT"&&!i&&t.value!==n.value&&(t.value=n.value)}var Z=y(()=>{});function tt(t,n,e){let i=[],o=0;for(let s of t){let r=e(s,o);r&&typeof r=="object"&&(r._key=n(s,o)),i.push(r),o++}return i}var et=y(()=>{});var nt={};v(nt,{AnJSElement:()=>P,html:()=>W,registerComponent:()=>jt,repeat:()=>tt,unsafeHTML:()=>z});var jt,P,it=y(()=>{X();Z();et();jt=(t,n)=>{customElements.get(t)||customElements.define(t,n)},P=class t extends HTMLElement{static get observedAttributes(){return[]}static get updateStrategy(){return"microtask"}constructor(){super(),this._updatePending=!1,this._initialized=!1,this._computedDefs=new Map,this._disposers=[];let n=this.constructor.updateStrategy==="raf";this._schedule=n?e=>requestAnimationFrame(e):e=>queueMicrotask(e),this._setupUpdatePromise(),this.state=new Proxy($.state({}),{set:(e,i,o)=>(e[i]=o,this._recompute(i),this._updatePending||(this._updatePending=!0,this._schedule(()=>{this._updatePending&&(this._updatePending=!1,this.update())})),!0)})}connectedCallback(){this.constructor.observedAttributes.forEach(n=>{this.state[n]=this.getAttribute(n)??""}),this.update()}disconnectedCallback(){this._updatePending=!1,this.destroy();for(let n of this._disposers)n();this._disposers.length=0}attributeChangedCallback(n,e,i){this.state[n]!==i&&(this.state[n]=i)}computed(n,e,i){this._computedDefs.set(n,{deps:e,fn:i});let o=e.map(s=>this.state[s]);this.state[n]=i(...o)}_recompute(n){if(!this._computing){for(let[e,{deps:i,fn:o}]of this._computedDefs)if(i.includes(n)){let s=i.map(u=>this.state[u]),r=o(...s);this.state[e]!==r&&(this._computing=!0,this.state[e]=r,this._computing=!1)}}}own(n){return this._disposers.push(n),n}_setupUpdatePromise(){this.updateComplete=new Promise(n=>{this._resolveUpdate=n})}update(){this._updatePending=!1;let n=!this._initialized,e=this.render();e instanceof E?S(e,this):typeof e=="string"&&this._initialized?Q(this,e):typeof e=="string"&&(this.innerHTML=e),this._initialized=!0,$.bind(this.state,this),n&&this.init(),this.updated(),this._resolveUpdate&&this._resolveUpdate(),this._setupUpdatePromise()}init(){this.setup!==t.prototype.setup&&this.setup()}setup(){}updated(){}destroy(){}render(){return`<p>${this.constructor.name} is not implemented yet.</p>`}}});var st={};v(st,{default:()=>It,http:()=>ot,request:()=>w});function Ft(t={},n){let e={Accept:"application/json",...t};return n&&!e["Content-Type"]&&(e["Content-Type"]="application/json"),e}function kt(t,n){return t instanceof FormData?(delete n["Content-Type"],t):n["Content-Type"]==="application/x-www-form-urlencoded"?new URLSearchParams(t).toString():JSON.stringify(t)}function Ut(t,n,e){return n===0||n==null?t:Promise.race([t,new Promise((i,o)=>setTimeout(()=>o(new Error(`Request timed out: ${e}`)),n))])}function w(t,n="GET",e=null,i={}){let{timeout:o=5e3,signal:s}=i,r=new URL(t,window.location.origin),u=e&&!["GET","DELETE"].includes(n),f=Ft(i.headers,u),c=u?kt(e,f):void 0,d={method:n,headers:f,...c&&{body:c},...s&&{signal:s}},l=fetch(r.toString(),d).then(h=>{if(!h.ok)throw new Error(`HTTP ${h.status} at ${t}`);return(h.headers?.get("Content-Type")||"").includes("application/json")?h.json():h.text()});return Ut(l,o,t)}var ot,It,rt=y(()=>{g();a.prototype.request=function(t,n="GET",e=null,i={}){return w(t,n,e,i)};ot={head:(t,n={})=>w(t,"HEAD",null,n),get:(t,n={})=>w(t,"GET",null,n),options:(t,n={})=>w(t,"OPTIONS",null,n),post:(t,n,e={})=>w(t,"POST",n,e),put:(t,n,e={})=>w(t,"PUT",n,e),patch:(t,n,e={})=>w(t,"PATCH",n,e),delete:(t,n={})=>w(t,"DELETE",null,n),abortController:()=>new AbortController},It=ot});var Ht={};var at=y(()=>{g();Object.assign(a.prototype,{animate(t,n=400,e="ease"){return this.each(i=>{i.style.transition=`all ${n}ms ${e}`,Object.assign(i.style,t),n>0&&setTimeout(()=>i.style.transition="",n)})},fade(t=+(this[0]?.style.opacity==="0"),n=400){return this.animate({opacity:t},n)},fadeIn(t){return this.fade(1,t)},fadeOut(t){return this.fade(0,t)}})});g();g();Object.assign(a.prototype,{content(t,n=!1){return t===void 0?this[0]?n?this[0].innerHTML:this[0].textContent:"":this.each(e=>n?e.innerHTML=t:e.textContent=t)},text(t){return this.content(t,!1)},html(t){return this.content(t,!0)},css(t,n){return n===void 0?this[0]?.style.getPropertyValue(t)||"":this.each(e=>e.style[t]=n)},class(t,n){return this.each(e=>e.classList[n===void 0?"toggle":n?"add":"remove"](t))},display(t){return this.each(n=>n.style.display=t?"":"none")},hide(){return this.display(!1)},show(){return this.display(!0)},remove(){return this.each(t=>t.remove())},empty(){return this.each(t=>t.innerHTML="")},insert(t,n="before"){let e={before:"beforeBegin",prepend:"afterBegin",append:"beforeEnd",after:"afterEnd"};return e[n]?this.each(i=>{if(typeof t=="string")return i.insertAdjacentHTML(e[n],t);(Array.isArray(t)?t:[t]).forEach(o=>i.insertAdjacentElement(e[n],o.cloneNode(!0)))}):this},prop(t,n){return arguments.length===1?this[0]?.[t]:this.each(e=>e[t]=n)},val(t){return arguments.length===0?this[0]?.value:this.each(n=>n.value=t)},has(t){return this[0]?.classList.contains(t)??!1},focus(){return this[0]?.focus(),this},blur(){return this[0]?.blur(),this}});g();Object.assign(a.prototype,{attr(t,n){return n===void 0?this[0]?.getAttribute(t):n===null?this.each(e=>e.removeAttribute(t)):this.each(e=>e.setAttribute(t,n))},id(t){return t===void 0?this.attr("id"):this.attr("id",t)},removeAttr(t){return this.attr(t,null)},serialize(){return this[0]instanceof HTMLFormElement?new URLSearchParams(new FormData(this[0])).toString():""}});g();var x=new WeakMap;Object.assign(a.prototype,{on(t,n,e){return typeof n=="function"?this.delegate(t,null,n):this.delegate(t,n,e)},off(t,n,e){return typeof n=="function"?this.undelegate(t,null,n):this.undelegate(t,n,e)},delegate(t,n,e){return this.each(i=>{x.has(i)||x.set(i,{});let o=x.get(i);o[t]||(o[t]=[]);let s=r=>{let u=n?r.target.closest(n):i;u&&i.contains(u)&&e.call(u,r)};o[t].push({selector:n,handler:e,delegateHandler:s}),i.addEventListener(t,s)})},undelegate(t,n,e){return this.each(i=>{if(!x.has(i))return;let o=x.get(i);o[t]&&(e?(o[t]=o[t].filter(s=>s.selector===n&&s.handler===e?(i.removeEventListener(t,s.delegateHandler),!1):!0),o[t].length===0&&delete o[t]):(o[t].forEach(s=>i.removeEventListener(t,s.delegateHandler)),delete o[t]),Object.keys(o).length===0&&x.delete(i))})},trigger(t){return this.each(n=>n.dispatchEvent(new Event(t,{bubbles:!0})))}});var T={},O={emit(t,n){T[t]?.forEach(e=>e(n))},listen(t,n){return T[t]||(T[t]=[]),T[t].push(n),()=>O.forget(t,n)},forget(t,n){T[t]&&(T[t]=T[t].filter(e=>e!==n),T[t].length===0&&delete T[t])}};g();["append","prepend","before","after"].forEach(t=>a.prototype[t]=function(n){return this.insert(n,t)});["click","change","submit","keydown","keyup","mouseover","mouseout"].forEach(t=>{a.prototype[t]=function(n){return n?this.on(t,n):this.trigger(t)}});var dt=t=>t.trim(),lt=t=>{try{return JSON.parse(t)}catch{return null}},ht=(t,n,e)=>(t-n)*(t-e)<=0,pt=t=>typeof t=="function",mt=t=>t!==null&&typeof t=="object",gt=t=>typeof t=="string",yt=t=>typeof t=="number"&&!isNaN(t),Et=(t,n)=>t!==n&&t.contains(n),bt=(t,n)=>{let e;return(...i)=>{clearTimeout(e),e=setTimeout(()=>t(...i),n)}},Tt=(t,n)=>{let e=0;return(...i)=>{let o=Date.now();o-e>=n&&(e=o,t(...i))}},At=(t,n={},e=[])=>{let i=document.createElement(t);return Object.entries(n).forEach(([o,s])=>i.setAttribute(o,s)),e.forEach(o=>i.append(o instanceof Node?o:document.createTextNode(o))),i},j={trim:dt,json:lt,range:ht,isFunction:pt,isObject:mt,isString:gt,isNumber:yt,contains:Et,debounce:bt,throttle:Tt,element:At};g();var F=function(t,n,e=!1){if(typeof t=="object")return typeof n=="boolean"&&(e=n),Object.keys(t).forEach(i=>F(i,t[i],e));!e&&a.prototype.hasOwnProperty(t)||(a.prototype[t]=n)},k={extend:F};typeof FEATURE_HTTP>"u"&&(globalThis.FEATURE_HTTP=!0);typeof FEATURE_ANIMATE>"u"&&(globalThis.FEATURE_ANIMATE=!0);typeof FEATURE_SELECTION>"u"&&(globalThis.FEATURE_SELECTION=!0);typeof FEATURE_FILTERING>"u"&&(globalThis.FEATURE_FILTERING=!0);typeof FEATURE_TRAVERSAL>"u"&&(globalThis.FEATURE_TRAVERSAL=!0);function m(t){return new a(t)}["on","off","trigger"].forEach(t=>{m[t]=(...n)=>a.prototype[t].apply(m(),n)});FEATURE_SELECTION&&(Promise.resolve().then(()=>(U(),_t)).then(t=>Object.assign(m,t)),Promise.resolve().then(()=>(I(),wt)).then(t=>Object.assign(m,t)));Promise.resolve().then(()=>(G(),J)).then(()=>{["state","global"].forEach(t=>{m[t]=(...n)=>a.prototype[t].apply(m(),n)})});Promise.resolve().then(()=>(V(),B)).then(t=>{["component"].forEach(n=>{m[n]=(...e)=>a.prototype[n].apply(m(),e)}),m.define=(n,e)=>customElements.define(n,e)});Promise.resolve().then(()=>it());FEATURE_HTTP&&Promise.resolve().then(()=>(rt(),st)).then(t=>{Object.assign(m,t.http)});FEATURE_ANIMATE&&Promise.resolve().then(()=>(at(),Ht));Object.assign(m,O,j,k);m.define=(t,n)=>customElements.define(t,n);typeof window<"u"&&(window.$=m);var Ee=m;})(); window.$ = $;