jj 2.8.0 → 2.9.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.
@@ -319,6 +319,39 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
319
319
  * @throws {TypeError} If `ref` is not a Node.
320
320
  */
321
321
  constructor(ref: T);
322
+ /**
323
+ * Gets the parent node wrapped in the most specific JJ wrapper available.
324
+ *
325
+ * @remarks
326
+ * Returns `null` when this node is detached and therefore has no parent.
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * const text = JJT.fromStr('hello')
331
+ * JJHE.create('div').addChild(text)
332
+ * const parent = text.parent // JJHE
333
+ * ```
334
+ *
335
+ * @returns The wrapped parent node, or `null` if this node has no parent.
336
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode | Node.parentNode}
337
+ */
338
+ get parent(): Wrapped | null;
339
+ /**
340
+ * Gets the child nodes wrapped in the most specific JJ wrappers available.
341
+ *
342
+ * @remarks
343
+ * Returns an empty array when this node has no children.
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * const el = JJHE.create('div').addChild('hello', JJHE.create('span'))
348
+ * const children = el.children // [JJT, JJHE]
349
+ * ```
350
+ *
351
+ * @returns The wrapped child nodes.
352
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes | Node.childNodes}
353
+ */
354
+ get children(): Wrapped[];
322
355
  /**
323
356
  * Clones the Node.
324
357
  *
@@ -327,6 +360,23 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
327
360
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
328
361
  */
329
362
  clone(deep?: boolean): Wrapped;
363
+ /**
364
+ * Removes this node from its parent.
365
+ *
366
+ * @remarks
367
+ * If the node has no parent, this method does nothing.
368
+ *
369
+ * @example
370
+ * ```ts
371
+ * const el = JJHE.create('div')
372
+ * doc.body.addChild(el)
373
+ * el.rm()
374
+ * ```
375
+ *
376
+ * @returns This instance for chaining.
377
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
378
+ */
379
+ rm(): this;
330
380
  /**
331
381
  * Creates a Text node from a string and appends it to this Node.
332
382
  *
@@ -319,6 +319,39 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
319
319
  * @throws {TypeError} If `ref` is not a Node.
320
320
  */
321
321
  constructor(ref: T);
322
+ /**
323
+ * Gets the parent node wrapped in the most specific JJ wrapper available.
324
+ *
325
+ * @remarks
326
+ * Returns `null` when this node is detached and therefore has no parent.
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * const text = JJT.fromStr('hello')
331
+ * JJHE.create('div').addChild(text)
332
+ * const parent = text.parent // JJHE
333
+ * ```
334
+ *
335
+ * @returns The wrapped parent node, or `null` if this node has no parent.
336
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode | Node.parentNode}
337
+ */
338
+ get parent(): Wrapped | null;
339
+ /**
340
+ * Gets the child nodes wrapped in the most specific JJ wrappers available.
341
+ *
342
+ * @remarks
343
+ * Returns an empty array when this node has no children.
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * const el = JJHE.create('div').addChild('hello', JJHE.create('span'))
348
+ * const children = el.children // [JJT, JJHE]
349
+ * ```
350
+ *
351
+ * @returns The wrapped child nodes.
352
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes | Node.childNodes}
353
+ */
354
+ get children(): Wrapped[];
322
355
  /**
323
356
  * Clones the Node.
324
357
  *
@@ -327,6 +360,23 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
327
360
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
328
361
  */
329
362
  clone(deep?: boolean): Wrapped;
363
+ /**
364
+ * Removes this node from its parent.
365
+ *
366
+ * @remarks
367
+ * If the node has no parent, this method does nothing.
368
+ *
369
+ * @example
370
+ * ```ts
371
+ * const el = JJHE.create('div')
372
+ * doc.body.addChild(el)
373
+ * el.rm()
374
+ * ```
375
+ *
376
+ * @returns This instance for chaining.
377
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
378
+ */
379
+ rm(): this;
330
380
  /**
331
381
  * Creates a Text node from a string and appends it to this Node.
332
382
  *
@@ -1,2 +1,2 @@
1
- "use strict";(()=>{var V=e=>{throw TypeError(e)};var P=(e,t,r)=>t.has(e)||V("Cannot "+r);var c=(e,t,r)=>(P(e,t,"read from private field"),r?r.call(e):t.get(e)),h=(e,t,r)=>t.has(e)?V("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),J=(e,t,r,o)=>(P(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),G=(e,t,r)=>(P(e,t,"access private method"),r);function v(e){return e!==void 0}function g(e){return typeof e=="function"}var{isNaN:K,isFinite:at,isInteger:ut}=Number;function M(e){return typeof e=="number"&&!K(e)}function F(e,t,r){if(!M(e))throw new TypeError(`inRange(): "x" must be a number. Got ${e} (${typeof e})`);if(v(t)){if(!M(t))throw new TypeError(`inRange(): "min" must be a number. Got ${t} (${typeof t})`);if(v(r)){if(!M(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return t>r?r<=e&&e<=t:t<=e&&e<=r}return e>=t}else if(v(r)){if(!M(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return e<=r}throw new TypeError(`inRange(): expected at least min or max to be defined. Got min=${t} and max=${r}`)}var{isArray:Z}=Array;function H(e,t=0,r){return Z(e)&&F(e.length,t,r)}var{hasOwnProperty:lt}=Object;function f(e){return!!e&&typeof e=="object"}function i(e,t){if(!g(t))throw new TypeError(`Expected a constructor function. Got ${t} (${typeof t})`);return e instanceof t}function w(e,...t){if(!f(e))return!1;for(let r of t)if(!(r in e))return!1;return!0}function s(e){return typeof e=="string"}var{hasOwnProperty:Jt}=Object,{isArray:At}=Array;function E(e,t,r){return`Expected '${e}' to be ${t}. Got ${r} (${typeof r})`}function n(e,t,r){return new TypeError(E(e,t,r))}function I(e){if(!s(e))throw n("path","a string",e);let t=e.lastIndexOf(".");if(t===-1)return"";let r=e.slice(t+1);return r.indexOf("/")!==-1?"":r.toLowerCase().trim()}function Pt(){return new Promise(e=>requestAnimationFrame(e))}function Gt(e=0){return new Promise(t=>setTimeout(t,e))}async function N(e){return await new CSSStyleSheet().replace(e)}function Ut(e){if(!s(e))throw n("str","a string",e);if(/[^a-zA-Z0-9_]/.test(e))throw new SyntaxError(E("str","alphanumeric characters and underscores",e));return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Vt(e){if(!s(e))throw n("str","a string",e);return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")||(e.length>0?e.charAt(0).toUpperCase()+e.slice(1):"")}function z(e){if(!s(e))throw n("str","a string",e);return e.replace(/^-+|-+$/g,"").replace(/-+([a-z])/g,(t,r)=>r.toUpperCase())}var A,$,L,O,j=class j{constructor(t){h(this,L);h(this,A);h(this,$,new WeakMap);if(!i(t,EventTarget))throw new TypeError(`JJET expects an EventTarget instance. Got ${t} (${typeof t}). `);J(this,A,t)}static from(t){return new j(t)}get ref(){return c(this,A)}on(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.addEventListener(t,a,o),this}off(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.removeEventListener(t,a,o),this}trigger(t){return this.ref.dispatchEvent(t),this}run(t,...r){return t.call(this,...r)}};A=new WeakMap,$=new WeakMap,L=new WeakSet,O=function(t){if(t===null)return null;let r=c(this,$).get(t);return r||(typeof t=="function"?r=t.bind(this):r={handleEvent:t.handleEvent.bind(this)},c(this,$).set(t,r)),r};var C=j;var u=class e extends C{static from(t){return new e(t)}static isWrappable(t){return s(t)||i(t,Node)||i(t,e)}static wrap(t){if(f(t)){if(i(t,e))return t;if(i(t,Node))return new e(t)}throw n("raw","a Node",t)}static unwrap(t){if(s(t))return document.createTextNode(t);if(!f(t))throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${t} (${typeof t}). `);if(i(t,Node))return t;if(i(t,e))return t.ref;throw new TypeError(`Could not unwrap ${t} (${typeof t}). Expected a string, Node, or JJ wrapper. Make sure you're passing a valid DOM element or JJ wrapper.`)}static wrapAll(t){return Array.from(t,e.wrap)}static unwrapAll(t){return Array.from(t,e.unwrap)}constructor(t){if(!i(t,Node))throw new TypeError(`JJN expects a Node instance. Got ${t} (${typeof t}). Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);super(t)}clone(t){return e.wrap(this.ref.cloneNode(t))}addText(...t){return t&&this.ref.appendChild(document.createTextNode(t.join(""))),this}};var m=class extends u{find(t,r=!1){let o=this.ref.querySelector(t);if(o)return u.wrap(o);if(r)throw new TypeError(`No element matched query "${t}"`);return null}findAll(t){return u.wrapAll(this.ref.querySelectorAll(t))}addChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.append(...r),this}preChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.prepend(...r),this}addChildMap(t,r){return this.addChild(...t.map(r))}preChildMap(t,r){return this.preChild(...t.map(r))}setChildren(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.replaceChildren(...r),this}empty(){return this.setChildren(),this}};var l=class e extends m{static from(t){return new e(t)}static create(){return new e(document.createDocumentFragment())}constructor(t){if(!i(t,DocumentFragment))throw n("ref","a DocumentFragment",t);super(t)}};var y=class e extends l{static from(t){return new e(t)}constructor(t){if(!i(t,ShadowRoot))throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${t} (${typeof t}). Access a shadow root using element.shadowRoot after calling element.attachShadow().`);super(t)}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}addStyleSheets(...t){return this.ref.adoptedStyleSheets.push(...t),this}};var T=class e extends m{static from(t){return new e(t)}constructor(t){if(!i(t,Element))throw new TypeError(`JJE expects an Element instance. Got ${t} (${typeof t}). Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);super(t)}getAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(t)}hasAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(t)}setAttr(t,r){if(typeof t=="string")this.ref.setAttribute(t,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(o,a);else throw n("nameOrObj","a string or object",t);return this}rmAttr(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(r)}return this}getAria(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(`aria-${t}`)}hasAria(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(`aria-${t}`)}setAria(t,r){if(s(t))this.ref.setAttribute(`aria-${t}`,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(`aria-${o}`,a);else throw n("nameOrObj","a string or object",t);return this}rmAria(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(`aria-${r}`)}return this}getClass(){return this.getAttr("class")}setClass(t){if(typeof t=="string")return this.setAttr("class",t);for(let[r,o]of Object.entries(t))o?this.ref.classList.add(r):this.ref.classList.remove(r);return this}addClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.add(...t),this}rmClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.remove(...t),this}hasClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.contains(t)}toggleClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.toggle(t),this}replaceClass(t,r){if(!s(t))throw n("oldClassName","a string",t);if(!s(r))throw n("newClassName","a string",r);return this.ref.classList.replace(t,r),this}closest(t){if(!s(t))throw n("selector","a string",t);let r=this.ref.closest(t);return r?u.wrap(r):null}hide(){return this.setAttr("hidden","").setAttr("aria-hidden","true")}show(){return this.rmAttr("hidden","aria-hidden")}disable(){return this.setAttr("disabled","").setAttr("aria-disabled","true")}enable(){return this.rmAttr("disabled","aria-disabled")}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}initShadow(t="open",r){let o=this.ref.shadowRoot??this.ref.attachShadow({mode:t});if(f(r)){let{template:a,styles:d}=r;a&&(s(a)?o.innerHTML=a:o.appendChild(a)),H(d)&&d.length&&o.adoptedStyleSheets.push(...d)}return this}get shadow(){return this.ref.shadowRoot?new y(this.ref.shadowRoot):null}};var S=class extends T{getData(t){if(!s(t))throw n("name","a string",t);return this.ref.dataset[t]}hasData(t){if(!s(t))throw n("name","a string",t);return w(this.ref.dataset,t)}setData(t,r){if(typeof t=="string")this.ref.dataset[t]=r;else if(f(t))for(let[o,a]of Object.entries(t))this.ref.dataset[o]=a;else throw n("nameOrObj","a string or object",t);return this}rmData(...t){for(let r of t){if(!s(r))throw n("name","a string",r);delete this.ref.dataset[r]}return this}};var p=class e extends S{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName","a string like 'div' or 'button'",t);return new e(document.createElement(t,r))}constructor(t){if(!i(t,HTMLElement))throw n("ref","an HTMLElement",t);super(t)}getValue(){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value}setValue(t){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value=t,this}focus(){return this.ref.focus(),this}click(){return this.ref.click(),this}getText(){return this.ref.innerText}setText(t){return this.ref.innerText=t,this}};var k=class e extends u{static from(t){return new e(t)}static fromStr(t){return new e(document.createTextNode(t))}constructor(t){if(!i(t,Text))throw new TypeError(`JJT expects a Text node. Got ${t} (${typeof t}). Create a Text node with JJT.fromStr() or document.createTextNode('text').`);super(t)}getText(){return this.ref.textContent}setText(t){return this.ref.textContent=t,this}addText(...t){return this.setText(this.getText()+t.join("")),this}empty(){return this.setText("")}};var x=class e extends m{static from(t){return new e(t)}constructor(t){if(!i(t,Document))throw new TypeError(`JJD expects a Document instance. Got ${t} (${typeof t}). `);super(t)}get head(){return p.from(this.ref.head)}get body(){return p.from(this.ref.body)}};var Q="http://www.w3.org/2000/svg",W=class e extends S{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName",'a string like "circle" or "path"',t);let o=document.createElementNS(Q,t,r);return new e(o)}constructor(t){if(!i(t,SVGElement))throw n("ref","an SVGElement",t);super(t)}getText(){return this.ref.textContent??""}setText(t){return this.ref.textContent=t,this}setFill(t){return this.setAttr("fill",t)}setStroke(t){return this.setAttr("stroke",t)}setStrokeWidth(t){return this.setAttr("stroke-width",String(t))}setViewBox(t,r,o,a){if(typeof t=="number"&&r!==void 0&&o!==void 0&&a!==void 0)return this.setAttr("viewBox",`${t} ${r} ${o} ${a}`);let d=t;return this.setAttr("viewBox",Array.isArray(d)?d.join(" "):d)}setWidth(t){return this.setAttr("width",String(t))}setHeight(t){return this.setAttr("height",String(t))}setD(t){return this.setAttr("d",Array.isArray(t)?t.join(" "):t)}setTransform(t){return this.setAttr("transform",t)}};u.wrap=function(t){if(s(t))return k.fromStr(t);if(!f(t))throw n("raw","an object",t);if(i(t,u))return t;if(i(t,HTMLElement))return p.from(t);if(i(t,SVGElement))return W.from(t);if(i(t,Element))return T.from(t);if(i(t,ShadowRoot))return y.from(t);if(i(t,DocumentFragment))return l.from(t);if(i(t,Document))return x.from(t);if(i(t,Text))return k.from(t);if(i(t,Node))return u.from(t);throw n("raw","a Node",t)};function sr(e,t,...r){let o=p.create(e).addChild(...r);return t&&o.setAttr(t),o}function X(e){switch(I(e)){case"html":case"htm":case"md":return"fetch";case"css":return"style";case"js":case"mjs":case"cjs":return"script";default:throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${e}`)}}function Y(e,t,r){if(!s(e)){if(!i(e,URL))throw n("href","a string or URL",e);e=e.toString()}if(!["prefetch","preload"].includes(t))throw new RangeError(E("rel","'prefetch' or 'preload'",t));if(!r&&(r=X(e),!r))throw new Error(`Could not guess 'as' attribute from URL: ${e}`);if(!["fetch","style","script"].includes(r))throw new RangeError(E("as","'fetch', 'style', or 'script'",r));return p.create("link").setAttr({href:e,rel:t,as:r})}function or(...e){let t=Y(...e);return document.head.append(t.ref),t}async function B(e,t="text/*"){if(!s(t))throw n("mime","a string",t);let r=await fetch(e,{headers:{Accept:t}});if(!r.ok)throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);return r.text()}async function ar(e){return await B(e,"text/html")}async function _(e){return await B(e,"text/css")}async function ur(e){return await N(await _(e))}function mr(e,t,r,o){if(!i(e,HTMLElement))throw n("instance","an HTMLElement",e);if(r!==o){let a=z(t);if(w(e,a))return e[a]=o,!0}return!1}async function lr(e,t,r){if(!s(e))throw n("name","a string",e);if(!g(t))throw n("constructor","a function",t);customElements.get(e)||(customElements.define(e,t,r),await customElements.whenDefined(e))}async function tt(e){if(e!==void 0){if(g(e)&&(e=await e()),e=await e,s(e))return e;if(i(e,l))return e.ref.cloneNode(!0);if(i(e,DocumentFragment))return e.cloneNode(!0);if(i(e,p))return e.ref instanceof HTMLTemplateElement?e.ref.content.cloneNode(!0):e.ref.outerHTML;if(i(e,HTMLElement))return e instanceof HTMLTemplateElement?e.content.cloneNode(!0):e.outerHTML;throw n("template","a string, JJHE, JJDF, HTMLElement, or DocumentFragment",e)}}async function et(e){if(g(e)&&(e=await e()),e=await e,i(e,CSSStyleSheet))return e;if(s(e))return await N(e);throw n("style","a CSS string or CSSStyleSheet",e)}function rt(e){return H(e)?e.map(et):[]}async function nt(e,t){let[r,...o]=await Promise.all([tt(e),...rt(t)]);return{template:r,styles:o}}var D,R,b,U=class U{constructor(){h(this,D);h(this,R,[]);h(this,b)}static create(){return new U}setTemplate(t){return J(this,D,t),this}addStyles(...t){return c(this,R).push(...t),this}async getResolved(){return c(this,b)||J(this,b,nt(c(this,D),c(this,R))),await c(this,b)}};D=new WeakMap,R=new WeakMap,b=new WeakMap;var q=U;var $r=x.from(document);})();
1
+ "use strict";(()=>{var V=e=>{throw TypeError(e)};var P=(e,t,r)=>t.has(e)||V("Cannot "+r);var h=(e,t,r)=>(P(e,t,"read from private field"),r?r.call(e):t.get(e)),c=(e,t,r)=>t.has(e)?V("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),J=(e,t,r,o)=>(P(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),G=(e,t,r)=>(P(e,t,"access private method"),r);function R(e){return e!==void 0}function g(e){return typeof e=="function"}var{isNaN:K,isFinite:at,isInteger:ut}=Number;function M(e){return typeof e=="number"&&!K(e)}function F(e,t,r){if(!M(e))throw new TypeError(`inRange(): "x" must be a number. Got ${e} (${typeof e})`);if(R(t)){if(!M(t))throw new TypeError(`inRange(): "min" must be a number. Got ${t} (${typeof t})`);if(R(r)){if(!M(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return t>r?r<=e&&e<=t:t<=e&&e<=r}return e>=t}else if(R(r)){if(!M(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return e<=r}throw new TypeError(`inRange(): expected at least min or max to be defined. Got min=${t} and max=${r}`)}var{isArray:Z}=Array;function N(e,t=0,r){return Z(e)&&F(e.length,t,r)}var{hasOwnProperty:lt}=Object;function f(e){return!!e&&typeof e=="object"}function i(e,t){if(!g(t))throw new TypeError(`Expected a constructor function. Got ${t} (${typeof t})`);return e instanceof t}function w(e,...t){if(!f(e))return!1;for(let r of t)if(!(r in e))return!1;return!0}function s(e){return typeof e=="string"}var{hasOwnProperty:Jt}=Object,{isArray:At}=Array;function E(e,t,r){return`Expected '${e}' to be ${t}. Got ${r} (${typeof r})`}function n(e,t,r){return new TypeError(E(e,t,r))}function I(e){if(!s(e))throw n("path","a string",e);let t=e.lastIndexOf(".");if(t===-1)return"";let r=e.slice(t+1);return r.indexOf("/")!==-1?"":r.toLowerCase().trim()}function Pt(){return new Promise(e=>requestAnimationFrame(e))}function Gt(e=0){return new Promise(t=>setTimeout(t,e))}async function H(e){return await new CSSStyleSheet().replace(e)}function Ut(e){if(!s(e))throw n("str","a string",e);if(/[^a-zA-Z0-9_]/.test(e))throw new SyntaxError(E("str","alphanumeric characters and underscores",e));return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Vt(e){if(!s(e))throw n("str","a string",e);return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")||(e.length>0?e.charAt(0).toUpperCase()+e.slice(1):"")}function z(e){if(!s(e))throw n("str","a string",e);return e.replace(/^-+|-+$/g,"").replace(/-+([a-z])/g,(t,r)=>r.toUpperCase())}var A,$,L,O,j=class j{constructor(t){c(this,L);c(this,A);c(this,$,new WeakMap);if(!i(t,EventTarget))throw new TypeError(`JJET expects an EventTarget instance. Got ${t} (${typeof t}). `);J(this,A,t)}static from(t){return new j(t)}get ref(){return h(this,A)}on(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.addEventListener(t,a,o),this}off(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.removeEventListener(t,a,o),this}trigger(t){return this.ref.dispatchEvent(t),this}run(t,...r){return t.call(this,...r)}};A=new WeakMap,$=new WeakMap,L=new WeakSet,O=function(t){if(t===null)return null;let r=h(this,$).get(t);return r||(typeof t=="function"?r=t.bind(this):r={handleEvent:t.handleEvent.bind(this)},h(this,$).set(t,r)),r};var W=j;var u=class e extends W{static from(t){return new e(t)}static isWrappable(t){return s(t)||i(t,Node)||i(t,e)}static wrap(t){if(f(t)){if(i(t,e))return t;if(i(t,Node))return new e(t)}throw n("raw","a Node",t)}static unwrap(t){if(s(t))return document.createTextNode(t);if(!f(t))throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${t} (${typeof t}). `);if(i(t,Node))return t;if(i(t,e))return t.ref;throw new TypeError(`Could not unwrap ${t} (${typeof t}). Expected a string, Node, or JJ wrapper. Make sure you're passing a valid DOM element or JJ wrapper.`)}static wrapAll(t){return Array.from(t,e.wrap)}static unwrapAll(t){return Array.from(t,e.unwrap)}constructor(t){if(!i(t,Node))throw new TypeError(`JJN expects a Node instance. Got ${t} (${typeof t}). Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);super(t)}get parent(){let{parentNode:t}=this.ref;return t?e.wrap(t):null}get children(){return e.wrapAll(this.ref.childNodes)}clone(t){return e.wrap(this.ref.cloneNode(t))}rm(){let{parentNode:t}=this.ref;return t&&t.removeChild(this.ref),this}addText(...t){return t&&this.ref.appendChild(document.createTextNode(t.join(""))),this}};var m=class extends u{find(t,r=!1){let o=this.ref.querySelector(t);if(o)return u.wrap(o);if(r)throw new TypeError(`No element matched query "${t}"`);return null}findAll(t){return u.wrapAll(this.ref.querySelectorAll(t))}addChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.append(...r),this}preChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.prepend(...r),this}addChildMap(t,r){return this.addChild(...t.map(r))}preChildMap(t,r){return this.preChild(...t.map(r))}setChildren(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.replaceChildren(...r),this}empty(){return this.setChildren(),this}};var l=class e extends m{static from(t){return new e(t)}static create(){return new e(document.createDocumentFragment())}constructor(t){if(!i(t,DocumentFragment))throw n("ref","a DocumentFragment",t);super(t)}};var y=class e extends l{static from(t){return new e(t)}constructor(t){if(!i(t,ShadowRoot))throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${t} (${typeof t}). Access a shadow root using element.shadowRoot after calling element.attachShadow().`);super(t)}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}addStyleSheets(...t){return this.ref.adoptedStyleSheets.push(...t),this}};var T=class e extends m{static from(t){return new e(t)}constructor(t){if(!i(t,Element))throw new TypeError(`JJE expects an Element instance. Got ${t} (${typeof t}). Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);super(t)}getAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(t)}hasAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(t)}setAttr(t,r){if(typeof t=="string")this.ref.setAttribute(t,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(o,a);else throw n("nameOrObj","a string or object",t);return this}rmAttr(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(r)}return this}getAria(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(`aria-${t}`)}hasAria(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(`aria-${t}`)}setAria(t,r){if(s(t))this.ref.setAttribute(`aria-${t}`,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(`aria-${o}`,a);else throw n("nameOrObj","a string or object",t);return this}rmAria(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(`aria-${r}`)}return this}getClass(){return this.getAttr("class")}setClass(t){if(typeof t=="string")return this.setAttr("class",t);for(let[r,o]of Object.entries(t))o?this.ref.classList.add(r):this.ref.classList.remove(r);return this}addClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.add(...t),this}rmClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.remove(...t),this}hasClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.contains(t)}toggleClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.toggle(t),this}replaceClass(t,r){if(!s(t))throw n("oldClassName","a string",t);if(!s(r))throw n("newClassName","a string",r);return this.ref.classList.replace(t,r),this}closest(t){if(!s(t))throw n("selector","a string",t);let r=this.ref.closest(t);return r?u.wrap(r):null}hide(){return this.setAttr("hidden","").setAttr("aria-hidden","true")}show(){return this.rmAttr("hidden","aria-hidden")}disable(){return this.setAttr("disabled","").setAttr("aria-disabled","true")}enable(){return this.rmAttr("disabled","aria-disabled")}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}initShadow(t="open",r){let o=this.ref.shadowRoot??this.ref.attachShadow({mode:t});if(f(r)){let{template:a,styles:d}=r;a&&(s(a)?o.innerHTML=a:o.appendChild(a)),N(d)&&d.length&&o.adoptedStyleSheets.push(...d)}return this}get shadow(){return this.ref.shadowRoot?new y(this.ref.shadowRoot):null}};var S=class extends T{getData(t){if(!s(t))throw n("name","a string",t);return this.ref.dataset[t]}hasData(t){if(!s(t))throw n("name","a string",t);return w(this.ref.dataset,t)}setData(t,r){if(typeof t=="string")this.ref.dataset[t]=r;else if(f(t))for(let[o,a]of Object.entries(t))this.ref.dataset[o]=a;else throw n("nameOrObj","a string or object",t);return this}rmData(...t){for(let r of t){if(!s(r))throw n("name","a string",r);delete this.ref.dataset[r]}return this}};var p=class e extends S{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName","a string like 'div' or 'button'",t);return new e(document.createElement(t,r))}constructor(t){if(!i(t,HTMLElement))throw n("ref","an HTMLElement",t);super(t)}getValue(){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value}setValue(t){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value=t,this}focus(){return this.ref.focus(),this}click(){return this.ref.click(),this}getText(){return this.ref.innerText}setText(t){return this.ref.innerText=t,this}};var k=class e extends u{static from(t){return new e(t)}static fromStr(t){return new e(document.createTextNode(t))}constructor(t){if(!i(t,Text))throw new TypeError(`JJT expects a Text node. Got ${t} (${typeof t}). Create a Text node with JJT.fromStr() or document.createTextNode('text').`);super(t)}getText(){return this.ref.textContent}setText(t){return this.ref.textContent=t,this}addText(...t){return this.setText(this.getText()+t.join("")),this}empty(){return this.setText("")}};var x=class e extends m{static from(t){return new e(t)}constructor(t){if(!i(t,Document))throw new TypeError(`JJD expects a Document instance. Got ${t} (${typeof t}). `);super(t)}get head(){return p.from(this.ref.head)}get body(){return p.from(this.ref.body)}};var Q="http://www.w3.org/2000/svg",C=class e extends S{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName",'a string like "circle" or "path"',t);let o=document.createElementNS(Q,t,r);return new e(o)}constructor(t){if(!i(t,SVGElement))throw n("ref","an SVGElement",t);super(t)}getText(){return this.ref.textContent??""}setText(t){return this.ref.textContent=t,this}setFill(t){return this.setAttr("fill",t)}setStroke(t){return this.setAttr("stroke",t)}setStrokeWidth(t){return this.setAttr("stroke-width",String(t))}setViewBox(t,r,o,a){if(typeof t=="number"&&r!==void 0&&o!==void 0&&a!==void 0)return this.setAttr("viewBox",`${t} ${r} ${o} ${a}`);let d=t;return this.setAttr("viewBox",Array.isArray(d)?d.join(" "):d)}setWidth(t){return this.setAttr("width",String(t))}setHeight(t){return this.setAttr("height",String(t))}setD(t){return this.setAttr("d",Array.isArray(t)?t.join(" "):t)}setTransform(t){return this.setAttr("transform",t)}};u.wrap=function(t){if(s(t))return k.fromStr(t);if(!f(t))throw n("raw","an object",t);if(i(t,u))return t;if(i(t,HTMLElement))return p.from(t);if(i(t,SVGElement))return C.from(t);if(i(t,Element))return T.from(t);if(i(t,ShadowRoot))return y.from(t);if(i(t,DocumentFragment))return l.from(t);if(i(t,Document))return x.from(t);if(i(t,Text))return k.from(t);if(i(t,Node))return u.from(t);throw n("raw","a Node",t)};function sr(e,t,...r){let o=p.create(e).addChild(...r);return t&&o.setAttr(t),o}function X(e){switch(I(e)){case"html":case"htm":case"md":return"fetch";case"css":return"style";case"js":case"mjs":case"cjs":return"script";default:throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${e}`)}}function Y(e,t,r){if(!s(e)){if(!i(e,URL))throw n("href","a string or URL",e);e=e.toString()}if(!["prefetch","preload"].includes(t))throw new RangeError(E("rel","'prefetch' or 'preload'",t));if(!r&&(r=X(e),!r))throw new Error(`Could not guess 'as' attribute from URL: ${e}`);if(!["fetch","style","script"].includes(r))throw new RangeError(E("as","'fetch', 'style', or 'script'",r));return p.create("link").setAttr({href:e,rel:t,as:r})}function or(...e){let t=Y(...e);return document.head.append(t.ref),t}async function B(e,t="text/*"){if(!s(t))throw n("mime","a string",t);let r=await fetch(e,{headers:{Accept:t}});if(!r.ok)throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);return r.text()}async function ar(e){return await B(e,"text/html")}async function _(e){return await B(e,"text/css")}async function ur(e){return await H(await _(e))}function mr(e,t,r,o){if(!i(e,HTMLElement))throw n("instance","an HTMLElement",e);if(r!==o){let a=z(t);if(w(e,a))return e[a]=o,!0}return!1}async function lr(e,t,r){if(!s(e))throw n("name","a string",e);if(!g(t))throw n("constructor","a function",t);customElements.get(e)||(customElements.define(e,t,r),await customElements.whenDefined(e))}async function tt(e){if(e!==void 0){if(g(e)&&(e=await e()),e=await e,s(e))return e;if(i(e,l))return e.ref.cloneNode(!0);if(i(e,DocumentFragment))return e.cloneNode(!0);if(i(e,p))return e.ref instanceof HTMLTemplateElement?e.ref.content.cloneNode(!0):e.ref.outerHTML;if(i(e,HTMLElement))return e instanceof HTMLTemplateElement?e.content.cloneNode(!0):e.outerHTML;throw n("template","a string, JJHE, JJDF, HTMLElement, or DocumentFragment",e)}}async function et(e){if(g(e)&&(e=await e()),e=await e,i(e,CSSStyleSheet))return e;if(s(e))return await H(e);throw n("style","a CSS string or CSSStyleSheet",e)}function rt(e){return N(e)?e.map(et):[]}async function nt(e,t){let[r,...o]=await Promise.all([tt(e),...rt(t)]);return{template:r,styles:o}}var D,v,b,U=class U{constructor(){c(this,D);c(this,v,[]);c(this,b)}static create(){return new U}setTemplate(t){return J(this,D,t),this}addStyles(...t){return h(this,v).push(...t),this}async getResolved(){return h(this,b)||J(this,b,nt(h(this,D),h(this,v))),await h(this,b)}};D=new WeakMap,v=new WeakMap,b=new WeakMap;var q=U;var $r=x.from(document);})();
2
2
  //# sourceMappingURL=bundle.min.global.js.map