@bquery/bquery 1.3.0 → 1.4.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.
Files changed (71) hide show
  1. package/README.md +527 -501
  2. package/dist/{batch-4LAvfLE7.js → batch-x7b2eZST.js} +2 -2
  3. package/dist/{batch-4LAvfLE7.js.map → batch-x7b2eZST.js.map} +1 -1
  4. package/dist/component.es.mjs +1 -1
  5. package/dist/core/collection.d.ts +19 -3
  6. package/dist/core/collection.d.ts.map +1 -1
  7. package/dist/core/element.d.ts +23 -4
  8. package/dist/core/element.d.ts.map +1 -1
  9. package/dist/core/index.d.ts +1 -0
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/utils/function.d.ts +21 -4
  12. package/dist/core/utils/function.d.ts.map +1 -1
  13. package/dist/{core-COenAZjD.js → core-BhpuvPhy.js} +62 -37
  14. package/dist/core-BhpuvPhy.js.map +1 -0
  15. package/dist/core.es.mjs +174 -131
  16. package/dist/core.es.mjs.map +1 -1
  17. package/dist/full.es.mjs +7 -7
  18. package/dist/full.iife.js +2 -2
  19. package/dist/full.iife.js.map +1 -1
  20. package/dist/full.umd.js +2 -2
  21. package/dist/full.umd.js.map +1 -1
  22. package/dist/index.es.mjs +7 -7
  23. package/dist/motion.es.mjs.map +1 -1
  24. package/dist/{persisted-Dz_ryNuC.js → persisted-DHoi3uEs.js} +4 -4
  25. package/dist/{persisted-Dz_ryNuC.js.map → persisted-DHoi3uEs.js.map} +1 -1
  26. package/dist/platform/storage.d.ts.map +1 -1
  27. package/dist/platform.es.mjs +12 -7
  28. package/dist/platform.es.mjs.map +1 -1
  29. package/dist/reactive/core.d.ts +12 -0
  30. package/dist/reactive/core.d.ts.map +1 -1
  31. package/dist/reactive/effect.d.ts.map +1 -1
  32. package/dist/reactive/internals.d.ts +6 -0
  33. package/dist/reactive/internals.d.ts.map +1 -1
  34. package/dist/reactive.es.mjs +6 -6
  35. package/dist/router.es.mjs +1 -1
  36. package/dist/{sanitize-1FBEPAFH.js → sanitize-Cxvxa-DX.js} +50 -39
  37. package/dist/sanitize-Cxvxa-DX.js.map +1 -0
  38. package/dist/security/sanitize-core.d.ts.map +1 -1
  39. package/dist/security.es.mjs +2 -2
  40. package/dist/store.es.mjs +2 -2
  41. package/dist/type-guards-BdKlYYlS.js +32 -0
  42. package/dist/type-guards-BdKlYYlS.js.map +1 -0
  43. package/dist/untrack-DNnnqdlR.js +6 -0
  44. package/dist/{untrack-BuEQKH7_.js.map → untrack-DNnnqdlR.js.map} +1 -1
  45. package/dist/view/evaluate.d.ts.map +1 -1
  46. package/dist/view.es.mjs +157 -151
  47. package/dist/view.es.mjs.map +1 -1
  48. package/dist/{watch-CXyaBC_9.js → watch-DXXv3iAI.js} +3 -3
  49. package/dist/{watch-CXyaBC_9.js.map → watch-DXXv3iAI.js.map} +1 -1
  50. package/package.json +132 -132
  51. package/src/core/collection.ts +628 -588
  52. package/src/core/element.ts +774 -746
  53. package/src/core/index.ts +48 -47
  54. package/src/core/utils/function.ts +151 -110
  55. package/src/motion/animate.ts +113 -113
  56. package/src/motion/flip.ts +176 -176
  57. package/src/motion/scroll.ts +57 -57
  58. package/src/motion/spring.ts +150 -150
  59. package/src/motion/timeline.ts +246 -246
  60. package/src/motion/transition.ts +51 -51
  61. package/src/platform/storage.ts +215 -208
  62. package/src/reactive/core.ts +114 -93
  63. package/src/reactive/effect.ts +54 -43
  64. package/src/reactive/internals.ts +122 -105
  65. package/src/security/sanitize-core.ts +364 -343
  66. package/src/view/evaluate.ts +290 -274
  67. package/dist/core-COenAZjD.js.map +0 -1
  68. package/dist/sanitize-1FBEPAFH.js.map +0 -1
  69. package/dist/type-guards-DRma3-Kc.js +0 -16
  70. package/dist/type-guards-DRma3-Kc.js.map +0 -1
  71. package/dist/untrack-BuEQKH7_.js +0 -6
@@ -1 +1 @@
1
- {"version":3,"file":"core.es.mjs","sources":["../src/core/shared.ts","../src/core/dom.ts","../src/core/element.ts","../src/core/collection.ts","../src/core/selector.ts","../src/core/utils/array.ts","../src/core/utils/function.ts","../src/core/utils/misc.ts","../src/core/utils/number.ts","../src/core/utils/object.ts","../src/core/utils/string.ts","../src/core/utils/type-guards.ts","../src/core/utils/index.ts"],"sourcesContent":["/**\n * Shared helpers for element wrappers.\n */\nexport type ElementList = Element[];\n\nexport const toElementList = (input: Element | ElementList): ElementList =>\n Array.isArray(input) ? input : [input];\n\nexport const applyAll = (elements: ElementList, action: (el: Element) => void) => {\n for (const el of elements) {\n action(el);\n }\n};\n","import { sanitizeHtml } from '../security/sanitize';\nimport { applyAll, toElementList } from './shared';\n\nexport type InsertableContent = string | Element | Element[];\n\nexport const sanitizeContent = (html: string): string => sanitizeHtml(html);\n\nexport const setHtml = (element: Element, html: string): void => {\n element.innerHTML = sanitizeHtml(html);\n};\n\nexport const createElementFromHtml = (html: string): Element => {\n const template = document.createElement('template');\n template.innerHTML = sanitizeHtml(html);\n return template.content.firstElementChild ?? document.createElement('div');\n};\n\nexport const insertContent = (\n target: Element,\n content: InsertableContent,\n position: InsertPosition\n): void => {\n if (typeof content === 'string') {\n target.insertAdjacentHTML(position, sanitizeHtml(content));\n return;\n }\n\n const elements = toElementList(content);\n\n // For positions that insert at the beginning (afterbegin, afterend), reverse\n // the array to maintain the caller's order. For beforeend/beforebegin, keep order.\n const needsReverse = position === 'afterbegin' || position === 'afterend';\n const orderedElements = needsReverse ? elements.slice().reverse() : elements;\n\n applyAll(orderedElements, (el) => {\n target.insertAdjacentElement(position, el);\n });\n};\n","import { createElementFromHtml, insertContent, setHtml } from './dom';\n\n/**\n * Wrapper for a single DOM element.\n * Provides a chainable, jQuery-like API for DOM manipulation.\n *\n * This class encapsulates a DOM element and provides methods for:\n * - Class manipulation (addClass, removeClass, toggleClass)\n * - Attribute and property access (attr, prop, data)\n * - Content manipulation (text, html, append, prepend)\n * - Style manipulation (css)\n * - Event handling (on, off, once, trigger)\n * - DOM traversal (find, closest, parent, children, siblings)\n *\n * All mutating methods return `this` for method chaining.\n *\n * @example\n * ```ts\n * $('#button')\n * .addClass('active')\n * .css({ color: 'blue' })\n * .on('click', () => console.log('clicked'));\n * ```\n */\n/** Handler signature for delegated events */\ntype DelegatedHandler = (event: Event, target: Element) => void;\n\nexport class BQueryElement {\n /**\n * Stores delegated event handlers for cleanup via undelegate().\n * Key format: `${event}:${selector}`\n * @internal\n */\n private readonly delegatedHandlers = new Map<string, Map<DelegatedHandler, EventListener>>();\n\n /**\n * Creates a new BQueryElement wrapper.\n * @param element - The DOM element to wrap\n */\n constructor(private readonly element: Element) {}\n\n /**\n * Exposes the raw DOM element when direct access is needed.\n * Use sparingly; prefer the wrapper methods for consistency.\n */\n get raw(): Element {\n return this.element;\n }\n\n /**\n * Exposes the underlying DOM element.\n * Provided for spec compatibility and read-only access.\n */\n get node(): Element {\n return this.element;\n }\n\n /** Add one or more classes. */\n addClass(...classNames: string[]): this {\n this.element.classList.add(...classNames);\n return this;\n }\n\n /** Remove one or more classes. */\n removeClass(...classNames: string[]): this {\n this.element.classList.remove(...classNames);\n return this;\n }\n\n /** Toggle a class by name. */\n toggleClass(className: string, force?: boolean): this {\n this.element.classList.toggle(className, force);\n return this;\n }\n\n /** Get or set an attribute. */\n attr(name: string, value?: string): string | this {\n if (value === undefined) {\n return this.element.getAttribute(name) ?? '';\n }\n this.element.setAttribute(name, value);\n return this;\n }\n\n /** Remove an attribute. */\n removeAttr(name: string): this {\n this.element.removeAttribute(name);\n return this;\n }\n\n /** Toggle an attribute on/off. */\n toggleAttr(name: string, force?: boolean): this {\n const hasAttr = this.element.hasAttribute(name);\n const shouldAdd = force ?? !hasAttr;\n if (shouldAdd) {\n this.element.setAttribute(name, '');\n } else {\n this.element.removeAttribute(name);\n }\n return this;\n }\n\n /** Get or set a property. */\n prop<T extends keyof Element>(name: T, value?: Element[T]): Element[T] | this {\n if (value === undefined) {\n return this.element[name];\n }\n this.element[name] = value;\n return this;\n }\n\n /** Read or write data attributes in camelCase. */\n data(name: string, value?: string): string | this {\n const key = name.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\n if (value === undefined) {\n return this.element.getAttribute(`data-${key}`) ?? '';\n }\n this.element.setAttribute(`data-${key}`, value);\n return this;\n }\n\n /** Get or set text content. */\n text(value?: string): string | this {\n if (value === undefined) {\n return this.element.textContent ?? '';\n }\n this.element.textContent = value;\n return this;\n }\n\n /** Set HTML content using a sanitized string. */\n /**\n * Sets sanitized HTML content on the element.\n * Uses the security module to sanitize input and prevent XSS attacks.\n *\n * @param value - The HTML string to set (will be sanitized)\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * $('#content').html('<strong>Hello</strong>');\n * ```\n */\n html(value: string): this {\n setHtml(this.element, value);\n return this;\n }\n\n /**\n * Sets HTML content without sanitization.\n * Use only when you trust the HTML source completely.\n *\n * @param value - The raw HTML string to set\n * @returns The instance for method chaining\n *\n * @warning This method bypasses XSS protection. Use with caution.\n */\n htmlUnsafe(value: string): this {\n this.element.innerHTML = value;\n return this;\n }\n\n /**\n * Gets or sets CSS styles on the element.\n *\n * @param property - A CSS property name or an object of property-value pairs\n * @param value - The value when setting a single property\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * // Single property\n * $('#box').css('color', 'red');\n *\n * // Multiple properties\n * $('#box').css({ color: 'red', 'font-size': '16px' });\n * ```\n */\n css(property: string | Record<string, string>, value?: string): this {\n if (typeof property === 'string') {\n if (value !== undefined) {\n (this.element as HTMLElement).style.setProperty(property, value);\n }\n return this;\n }\n\n for (const [key, val] of Object.entries(property)) {\n (this.element as HTMLElement).style.setProperty(key, val);\n }\n return this;\n }\n\n /**\n * Appends HTML or elements to the end of the element.\n *\n * @param content - HTML string or element(s) to append\n * @returns The instance for method chaining\n */\n append(content: string | Element | Element[]): this {\n this.insertContent(content, 'beforeend');\n return this;\n }\n\n /**\n * Prepends HTML or elements to the beginning of the element.\n *\n * @param content - HTML string or element(s) to prepend\n * @returns The instance for method chaining\n */\n prepend(content: string | Element | Element[]): this {\n this.insertContent(content, 'afterbegin');\n return this;\n }\n\n /**\n * Inserts content before this element.\n *\n * @param content - HTML string or element(s) to insert\n * @returns The instance for method chaining\n */\n before(content: string | Element | Element[]): this {\n this.insertContent(content, 'beforebegin');\n return this;\n }\n\n /**\n * Inserts content after this element.\n *\n * @param content - HTML string or element(s) to insert\n * @returns The instance for method chaining\n */\n after(content: string | Element | Element[]): this {\n this.insertContent(content, 'afterend');\n return this;\n }\n\n /**\n * Wraps the element with the specified wrapper element or tag.\n *\n * @param wrapper - Tag name string or Element to wrap with\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * $('#content').wrap('div'); // Wraps with <div>\n * $('#content').wrap(document.createElement('section'));\n * ```\n */\n wrap(wrapper: string | Element): this {\n const wrapperEl = typeof wrapper === 'string' ? document.createElement(wrapper) : wrapper;\n this.element.parentNode?.insertBefore(wrapperEl, this.element);\n wrapperEl.appendChild(this.element);\n return this;\n }\n\n /**\n * Removes the parent element, keeping this element in its place.\n * Essentially the opposite of wrap().\n *\n * **Important**: This method only moves the current element out of its parent\n * before removing the parent. Any sibling elements will be removed along with\n * the parent. For unwrapping multiple siblings, use a collection: `$$(siblings).unwrap()`.\n *\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * // Before: <div><span id=\"text\">Hello</span></div>\n * $('#text').unwrap();\n * // After: <span id=\"text\">Hello</span>\n * ```\n */\n unwrap(): this {\n const parent = this.element.parentElement;\n if (parent && parent.parentNode) {\n parent.parentNode.insertBefore(this.element, parent);\n parent.remove();\n }\n return this;\n }\n\n /**\n * Replaces this element with new content.\n *\n * @param content - HTML string (sanitized) or Element to replace with\n * @returns A new BQueryElement wrapping the replacement element\n *\n * @example\n * ```ts\n * const newEl = $('#old').replaceWith('<div id=\"new\">Replaced</div>');\n * ```\n */\n replaceWith(content: string | Element): BQueryElement {\n const newEl = typeof content === 'string' ? createElementFromHtml(content) : content;\n this.element.replaceWith(newEl);\n return new BQueryElement(newEl);\n }\n\n /**\n * Scrolls the element into view with configurable behavior.\n *\n * @param options - ScrollIntoView options or boolean for legacy behavior\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * $('#section').scrollTo(); // Smooth scroll\n * $('#section').scrollTo({ behavior: 'instant', block: 'start' });\n * ```\n */\n scrollTo(options: ScrollIntoViewOptions | boolean = { behavior: 'smooth' }): this {\n this.element.scrollIntoView(options);\n return this;\n }\n\n /**\n * Removes the element from the DOM.\n *\n * @returns The instance for method chaining (though element is now detached)\n */\n remove(): this {\n this.element.remove();\n return this;\n }\n\n /**\n * Clears all child nodes from the element.\n *\n * @returns The instance for method chaining\n */\n empty(): this {\n this.element.innerHTML = '';\n return this;\n }\n\n /**\n * Clones the element, optionally with all descendants.\n *\n * @param deep - If true, clone all descendants (default: true)\n * @returns A new BQueryElement wrapping the cloned element\n */\n clone(deep: boolean = true): BQueryElement {\n return new BQueryElement(this.element.cloneNode(deep) as Element);\n }\n\n /**\n * Finds all descendant elements matching the selector.\n *\n * @param selector - CSS selector to match\n * @returns Array of matching elements\n */\n find(selector: string): Element[] {\n return Array.from(this.element.querySelectorAll(selector));\n }\n\n /**\n * Finds the first descendant element matching the selector.\n *\n * @param selector - CSS selector to match\n * @returns The first matching element or null\n */\n findOne(selector: string): Element | null {\n return this.element.querySelector(selector);\n }\n\n /**\n * Finds the closest ancestor matching the selector.\n *\n * @param selector - CSS selector to match\n * @returns The matching ancestor or null\n */\n closest(selector: string): Element | null {\n return this.element.closest(selector);\n }\n\n /**\n * Gets the parent element.\n *\n * @returns The parent element or null\n */\n parent(): Element | null {\n return this.element.parentElement;\n }\n\n /**\n * Gets all child elements.\n *\n * @returns Array of child elements\n */\n children(): Element[] {\n return Array.from(this.element.children);\n }\n\n /**\n * Gets all sibling elements.\n *\n * @returns Array of sibling elements (excluding this element)\n */\n siblings(): Element[] {\n const parent = this.element.parentElement;\n if (!parent) return [];\n return Array.from(parent.children).filter((child) => child !== this.element);\n }\n\n /**\n * Gets the next sibling element.\n *\n * @returns The next sibling element or null\n */\n next(): Element | null {\n return this.element.nextElementSibling;\n }\n\n /**\n * Gets the previous sibling element.\n *\n * @returns The previous sibling element or null\n */\n prev(): Element | null {\n return this.element.previousElementSibling;\n }\n\n /**\n * Adds an event listener.\n *\n * @param event - Event type to listen for\n * @param handler - Event handler function\n * @returns The instance for method chaining\n */\n on(event: string, handler: EventListenerOrEventListenerObject): this {\n this.element.addEventListener(event, handler);\n return this;\n }\n\n /**\n * Adds a one-time event listener that removes itself after firing.\n *\n * @param event - Event type to listen for\n * @param handler - Event handler function\n * @returns The instance for method chaining\n */\n once(event: string, handler: EventListener): this {\n this.element.addEventListener(event, handler, { once: true });\n return this;\n }\n\n /**\n * Removes an event listener.\n *\n * @param event - Event type\n * @param handler - The handler to remove\n * @returns The instance for method chaining\n */\n off(event: string, handler: EventListenerOrEventListenerObject): this {\n this.element.removeEventListener(event, handler);\n return this;\n }\n\n /**\n * Triggers a custom event on the element.\n *\n * @param event - Event type to trigger\n * @param detail - Optional detail data to include with the event\n * @returns The instance for method chaining\n */\n trigger(event: string, detail?: unknown): this {\n this.element.dispatchEvent(new CustomEvent(event, { detail, bubbles: true, cancelable: true }));\n return this;\n }\n\n /**\n * Adds a delegated event listener that only triggers for matching descendants.\n * More efficient than adding listeners to many elements individually.\n *\n * Use `undelegate()` to remove the listener later.\n *\n * @param event - Event type to listen for\n * @param selector - CSS selector to match against event targets\n * @param handler - Event handler function, receives the matched element as context\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * // Instead of adding listeners to each button:\n * const handler = (e, target) => console.log('Clicked:', target.textContent);\n * $('#list').delegate('click', '.item', handler);\n *\n * // Later, remove the delegated listener:\n * $('#list').undelegate('click', '.item', handler);\n * ```\n */\n delegate(\n event: string,\n selector: string,\n handler: (event: Event, target: Element) => void\n ): this {\n const key = `${event}:${selector}`;\n const wrapper: EventListener = (e: Event) => {\n const target = (e.target as Element).closest(selector);\n if (target && this.element.contains(target)) {\n handler(e, target);\n }\n };\n\n // Store the wrapper so it can be removed later\n if (!this.delegatedHandlers.has(key)) {\n this.delegatedHandlers.set(key, new Map());\n }\n this.delegatedHandlers.get(key)!.set(handler, wrapper);\n\n this.element.addEventListener(event, wrapper);\n return this;\n }\n\n /**\n * Removes a delegated event listener previously added with `delegate()`.\n *\n * @param event - Event type that was registered\n * @param selector - CSS selector that was used\n * @param handler - The original handler function passed to delegate()\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * const handler = (e, target) => console.log('Clicked:', target.textContent);\n * $('#list').delegate('click', '.item', handler);\n *\n * // Remove the delegated listener:\n * $('#list').undelegate('click', '.item', handler);\n * ```\n */\n undelegate(\n event: string,\n selector: string,\n handler: (event: Event, target: Element) => void\n ): this {\n const key = `${event}:${selector}`;\n const handlers = this.delegatedHandlers.get(key);\n\n if (handlers) {\n const wrapper = handlers.get(handler);\n if (wrapper) {\n this.element.removeEventListener(event, wrapper);\n handlers.delete(handler);\n\n // Clean up empty maps\n if (handlers.size === 0) {\n this.delegatedHandlers.delete(key);\n }\n }\n }\n\n return this;\n }\n\n /**\n * Checks if the element matches a CSS selector.\n *\n * @param selector - CSS selector to match against\n * @returns True if the element matches the selector\n */\n matches(selector: string): boolean {\n return this.element.matches(selector);\n }\n\n /**\n * Checks if the element has a specific class.\n *\n * @param className - Class name to check\n * @returns True if the element has the class\n */\n hasClass(className: string): boolean {\n return this.element.classList.contains(className);\n }\n\n /**\n * Shows the element by removing the hidden attribute and setting display.\n *\n * @param display - Optional display value (default: '')\n * @returns The instance for method chaining\n */\n show(display: string = ''): this {\n this.element.removeAttribute('hidden');\n (this.element as HTMLElement).style.display = display;\n return this;\n }\n\n /**\n * Hides the element by setting display to 'none'.\n *\n * @returns The instance for method chaining\n */\n hide(): this {\n (this.element as HTMLElement).style.display = 'none';\n return this;\n }\n\n /**\n * Toggles the visibility of the element.\n *\n * @param force - Optional force show (true) or hide (false)\n * @returns The instance for method chaining\n */\n toggle(force?: boolean): this {\n const isHidden = (this.element as HTMLElement).style.display === 'none';\n const shouldShow = force ?? isHidden;\n return shouldShow ? this.show() : this.hide();\n }\n\n /**\n * Focuses the element.\n *\n * @returns The instance for method chaining\n */\n focus(): this {\n (this.element as HTMLElement).focus();\n return this;\n }\n\n /**\n * Blurs (unfocuses) the element.\n *\n * @returns The instance for method chaining\n */\n blur(): this {\n (this.element as HTMLElement).blur();\n return this;\n }\n\n /**\n * Gets or sets the value of form elements.\n *\n * @param newValue - Optional value to set\n * @returns The current value when getting, or the instance when setting\n */\n val(newValue?: string): string | this {\n const input = this.element as HTMLInputElement;\n if (newValue === undefined) {\n return input.value ?? '';\n }\n input.value = newValue;\n return this;\n }\n\n /**\n * Serializes form data to a plain object.\n * Only works on form elements; returns empty object for non-forms.\n *\n * @returns Object with form field names as keys and values\n *\n * @example\n * ```ts\n * // For a form with <input name=\"email\" value=\"test@example.com\">\n * const data = $('#myForm').serialize();\n * // { email: 'test@example.com' }\n * ```\n */\n serialize(): Record<string, string | string[]> {\n const form = this.element as HTMLFormElement;\n if (form.tagName.toLowerCase() !== 'form') {\n return {};\n }\n\n const result: Record<string, string | string[]> = {};\n const formData = new FormData(form);\n\n for (const [key, value] of formData.entries()) {\n if (typeof value !== 'string') continue; // Skip File objects\n\n if (key in result) {\n // Handle multiple values (e.g., checkboxes)\n const existing = result[key];\n if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n result[key] = [existing, value];\n }\n } else {\n result[key] = value;\n }\n }\n\n return result;\n }\n\n /**\n * Serializes form data to a URL-encoded query string.\n *\n * @returns URL-encoded string suitable for form submission\n *\n * @example\n * ```ts\n * const queryString = $('#myForm').serializeString();\n * // 'email=test%40example.com&name=John'\n * ```\n */\n serializeString(): string {\n const form = this.element as HTMLFormElement;\n if (form.tagName.toLowerCase() !== 'form') {\n return '';\n }\n\n const formData = new FormData(form);\n const params = new URLSearchParams();\n\n for (const [key, value] of formData.entries()) {\n if (typeof value === 'string') {\n params.append(key, value);\n }\n }\n\n return params.toString();\n }\n\n /**\n * Gets the bounding client rectangle of the element.\n *\n * @returns The element's bounding rectangle\n */\n rect(): DOMRect {\n return this.element.getBoundingClientRect();\n }\n\n /**\n * Gets the offset dimensions (width, height, top, left).\n *\n * @returns Object with offset dimensions\n */\n offset(): { width: number; height: number; top: number; left: number } {\n const el = this.element as HTMLElement;\n return {\n width: el.offsetWidth,\n height: el.offsetHeight,\n top: el.offsetTop,\n left: el.offsetLeft,\n };\n }\n\n /**\n * Internal method to insert content at a specified position.\n * @internal\n */\n private insertContent(content: string | Element | Element[], position: InsertPosition) {\n insertContent(this.element, content, position);\n }\n}\n","import {\n createElementFromHtml,\n insertContent,\n sanitizeContent,\n type InsertableContent,\n} from './dom';\nimport { BQueryElement } from './element';\nimport { applyAll, toElementList } from './shared';\n\n/** Handler signature for delegated events */\ntype DelegatedHandler = (event: Event, target: Element) => void;\n\n/**\n * Wrapper for multiple DOM elements.\n * Provides batch operations on a collection of elements with chainable API.\n *\n * This class enables jQuery-like operations across multiple elements:\n * - All mutating methods apply to every element in the collection\n * - Getter methods return data from the first element\n * - Supports iteration via forEach, map, filter, and reduce\n *\n * @example\n * ```ts\n * $$('.items')\n * .addClass('highlight')\n * .css({ opacity: '0.8' })\n * .on('click', () => console.log('clicked'));\n * ```\n */\nexport class BQueryCollection {\n /**\n * Stores delegated event handlers for cleanup via undelegate().\n * Outer map: element -> (key -> (handler -> wrapper))\n * Key format: `${event}:${selector}`\n * @internal\n */\n private readonly delegatedHandlers = new WeakMap<\n Element,\n Map<string, Map<DelegatedHandler, EventListener>>\n >();\n\n /**\n * Creates a new collection wrapper.\n * @param elements - Array of DOM elements to wrap\n */\n constructor(public readonly elements: Element[]) {}\n\n /**\n * Gets the number of elements in the collection.\n */\n get length(): number {\n return this.elements.length;\n }\n\n /**\n * Gets the first element in the collection, if any.\n * @internal\n */\n private first(): Element | undefined {\n return this.elements[0];\n }\n\n /**\n * Gets a single element as a BQueryElement wrapper.\n *\n * @param index - Zero-based index of the element\n * @returns BQueryElement wrapper or undefined if out of range\n */\n eq(index: number): BQueryElement | undefined {\n const el = this.elements[index];\n return el ? new BQueryElement(el) : undefined;\n }\n\n /**\n * Gets the first element as a BQueryElement wrapper.\n *\n * @returns BQueryElement wrapper or undefined if empty\n */\n firstEl(): BQueryElement | undefined {\n return this.eq(0);\n }\n\n /**\n * Gets the last element as a BQueryElement wrapper.\n *\n * @returns BQueryElement wrapper or undefined if empty\n */\n lastEl(): BQueryElement | undefined {\n return this.eq(this.elements.length - 1);\n }\n\n /**\n * Iterates over each element in the collection.\n *\n * @param callback - Function to call for each wrapped element\n * @returns The instance for method chaining\n */\n each(callback: (element: BQueryElement, index: number) => void): this {\n this.elements.forEach((element, index) => {\n callback(new BQueryElement(element), index);\n });\n return this;\n }\n\n /**\n * Maps each element to a new value.\n *\n * @param callback - Function to transform each element\n * @returns Array of transformed values\n */\n map<T>(callback: (element: Element, index: number) => T): T[] {\n return this.elements.map(callback);\n }\n\n /**\n * Filters elements based on a predicate.\n *\n * @param predicate - Function to test each element\n * @returns New BQueryCollection with matching elements\n */\n filter(predicate: (element: Element, index: number) => boolean): BQueryCollection {\n return new BQueryCollection(this.elements.filter(predicate));\n }\n\n /**\n * Reduces the collection to a single value.\n *\n * @param callback - Reducer function\n * @param initialValue - Initial accumulator value\n * @returns Accumulated result\n */\n reduce<T>(callback: (accumulator: T, element: Element, index: number) => T, initialValue: T): T {\n return this.elements.reduce(callback, initialValue);\n }\n\n /**\n * Converts the collection to an array of BQueryElement wrappers.\n *\n * @returns Array of BQueryElement instances\n */\n toArray(): BQueryElement[] {\n return this.elements.map((el) => new BQueryElement(el));\n }\n\n /** Add one or more classes to all elements. */\n addClass(...classNames: string[]): this {\n applyAll(this.elements, (el) => el.classList.add(...classNames));\n return this;\n }\n\n /** Remove one or more classes from all elements. */\n removeClass(...classNames: string[]): this {\n applyAll(this.elements, (el) => el.classList.remove(...classNames));\n return this;\n }\n\n /** Toggle a class on all elements. */\n toggleClass(className: string, force?: boolean): this {\n applyAll(this.elements, (el) => el.classList.toggle(className, force));\n return this;\n }\n\n /**\n * Sets an attribute on all elements or gets from first.\n *\n * @param name - Attribute name\n * @param value - Value to set (optional)\n * @returns Attribute value when getting, instance when setting\n */\n attr(name: string, value?: string): string | this {\n if (value === undefined) {\n return this.first()?.getAttribute(name) ?? '';\n }\n applyAll(this.elements, (el) => el.setAttribute(name, value));\n return this;\n }\n\n /**\n * Removes an attribute from all elements.\n *\n * @param name - Attribute name to remove\n * @returns The instance for method chaining\n */\n removeAttr(name: string): this {\n applyAll(this.elements, (el) => el.removeAttribute(name));\n return this;\n }\n\n /** Toggle an attribute on all elements. */\n toggleAttr(name: string, force?: boolean): this {\n applyAll(this.elements, (el) => {\n const hasAttr = el.hasAttribute(name);\n const shouldAdd = force ?? !hasAttr;\n if (shouldAdd) {\n el.setAttribute(name, '');\n } else {\n el.removeAttribute(name);\n }\n });\n return this;\n }\n\n /**\n * Sets text content on all elements or gets from first.\n *\n * @param value - Text to set (optional)\n * @returns Text content when getting, instance when setting\n */\n text(value?: string): string | this {\n if (value === undefined) {\n return this.first()?.textContent ?? '';\n }\n applyAll(this.elements, (el) => {\n el.textContent = value;\n });\n return this;\n }\n\n /**\n * Sets sanitized HTML on all elements or gets from first.\n *\n * @param value - HTML to set (optional, will be sanitized)\n * @returns HTML content when getting, instance when setting\n */\n html(value?: string): string | this {\n if (value === undefined) {\n return this.first()?.innerHTML ?? '';\n }\n const sanitized = sanitizeContent(value);\n applyAll(this.elements, (el) => {\n el.innerHTML = sanitized;\n });\n return this;\n }\n\n /**\n * Sets HTML on all elements without sanitization.\n *\n * @param value - Raw HTML to set\n * @returns The instance for method chaining\n * @warning Bypasses XSS protection\n */\n htmlUnsafe(value: string): this {\n applyAll(this.elements, (el) => {\n el.innerHTML = value;\n });\n return this;\n }\n\n /** Append content to all elements. */\n append(content: InsertableContent): this {\n this.insertAll(content, 'beforeend');\n return this;\n }\n\n /** Prepend content to all elements. */\n prepend(content: InsertableContent): this {\n this.insertAll(content, 'afterbegin');\n return this;\n }\n\n /** Insert content before all elements. */\n before(content: InsertableContent): this {\n this.insertAll(content, 'beforebegin');\n return this;\n }\n\n /** Insert content after all elements. */\n after(content: InsertableContent): this {\n this.insertAll(content, 'afterend');\n return this;\n }\n\n /**\n * Applies CSS styles to all elements.\n *\n * @param property - Property name or object of properties\n * @param value - Value when setting single property\n * @returns The instance for method chaining\n */\n css(property: string | Record<string, string>, value?: string): this {\n if (typeof property === 'string') {\n if (value !== undefined) {\n applyAll(this.elements, (el) => {\n (el as HTMLElement).style.setProperty(property, value);\n });\n }\n return this;\n }\n\n applyAll(this.elements, (el) => {\n for (const [key, val] of Object.entries(property)) {\n (el as HTMLElement).style.setProperty(key, val);\n }\n });\n return this;\n }\n\n /** Wrap each element with a wrapper element or tag. */\n wrap(wrapper: string | Element): this {\n this.elements.forEach((el, index) => {\n const wrapperEl =\n typeof wrapper === 'string'\n ? document.createElement(wrapper)\n : index === 0\n ? wrapper\n : (wrapper.cloneNode(true) as Element);\n el.parentNode?.insertBefore(wrapperEl, el);\n wrapperEl.appendChild(el);\n });\n return this;\n }\n\n /**\n * Remove the parent element of each element, keeping the elements in place.\n *\n * **Important**: This method unwraps ALL children of each parent element,\n * not just the elements in the collection. If you call `unwrap()` on a\n * collection containing only some children of a parent, all siblings will\n * also be unwrapped. This behavior is consistent with jQuery's `.unwrap()`.\n *\n * @returns The collection for chaining\n *\n * @example\n * ```ts\n * // HTML: <div><section><span>A</span><span>B</span></section></div>\n * const spans = $$('span');\n * spans.unwrap(); // Removes <section>, both spans move to <div>\n * // Result: <div><span>A</span><span>B</span></div>\n * ```\n */\n unwrap(): this {\n // Collect unique parent elements to avoid removing the same parent multiple times.\n const parents = new Set<Element>();\n for (const el of this.elements) {\n if (el.parentElement) {\n parents.add(el.parentElement);\n }\n }\n\n // Unwrap each parent once: move all children out, then remove the wrapper.\n parents.forEach((parent) => {\n const grandParent = parent.parentNode;\n if (!grandParent) return;\n\n while (parent.firstChild) {\n grandParent.insertBefore(parent.firstChild, parent);\n }\n\n parent.remove();\n });\n return this;\n }\n\n /** Replace each element with provided content. */\n replaceWith(content: string | Element): BQueryCollection {\n const replacements: Element[] = [];\n this.elements.forEach((el, index) => {\n const replacement =\n typeof content === 'string'\n ? createElementFromHtml(content)\n : index === 0\n ? content\n : (content.cloneNode(true) as Element);\n el.replaceWith(replacement);\n replacements.push(replacement);\n });\n return new BQueryCollection(replacements);\n }\n\n /**\n * Shows all elements.\n *\n * @param display - Optional display value (default: '')\n * @returns The instance for method chaining\n */\n show(display: string = ''): this {\n applyAll(this.elements, (el) => {\n el.removeAttribute('hidden');\n (el as HTMLElement).style.display = display;\n });\n return this;\n }\n\n /**\n * Hides all elements.\n *\n * @returns The instance for method chaining\n */\n hide(): this {\n applyAll(this.elements, (el) => {\n (el as HTMLElement).style.display = 'none';\n });\n return this;\n }\n\n /**\n * Adds an event listener to all elements.\n *\n * @param event - Event type\n * @param handler - Event handler\n * @returns The instance for method chaining\n */\n on(event: string, handler: EventListenerOrEventListenerObject): this {\n applyAll(this.elements, (el) => el.addEventListener(event, handler));\n return this;\n }\n\n /**\n * Adds a one-time event listener to all elements.\n *\n * @param event - Event type\n * @param handler - Event handler\n * @returns The instance for method chaining\n */\n once(event: string, handler: EventListener): this {\n applyAll(this.elements, (el) => el.addEventListener(event, handler, { once: true }));\n return this;\n }\n\n /**\n * Removes an event listener from all elements.\n *\n * @param event - Event type\n * @param handler - The handler to remove\n * @returns The instance for method chaining\n */\n off(event: string, handler: EventListenerOrEventListenerObject): this {\n applyAll(this.elements, (el) => el.removeEventListener(event, handler));\n return this;\n }\n\n /**\n * Triggers a custom event on all elements.\n *\n * @param event - Event type\n * @param detail - Optional event detail\n * @returns The instance for method chaining\n */\n trigger(event: string, detail?: unknown): this {\n applyAll(this.elements, (el) => {\n el.dispatchEvent(new CustomEvent(event, { detail, bubbles: true, cancelable: true }));\n });\n return this;\n }\n\n /**\n * Adds a delegated event listener to all elements.\n * Events are delegated to matching descendants.\n *\n * Use `undelegate()` to remove the listener later.\n *\n * @param event - Event type to listen for\n * @param selector - CSS selector to match against event targets\n * @param handler - Event handler function\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * const handler = (e, target) => console.log('Clicked:', target.textContent);\n * $$('.container').delegate('click', '.item', handler);\n *\n * // Later, remove the delegated listener:\n * $$('.container').undelegate('click', '.item', handler);\n * ```\n */\n delegate(\n event: string,\n selector: string,\n handler: (event: Event, target: Element) => void\n ): this {\n const key = `${event}:${selector}`;\n\n applyAll(this.elements, (el) => {\n const wrapper: EventListener = (e: Event) => {\n const target = (e.target as Element).closest(selector);\n if (target && el.contains(target)) {\n handler(e, target);\n }\n };\n\n // Get or create the handler maps for this element\n if (!this.delegatedHandlers.has(el)) {\n this.delegatedHandlers.set(el, new Map());\n }\n const elementHandlers = this.delegatedHandlers.get(el)!;\n\n if (!elementHandlers.has(key)) {\n elementHandlers.set(key, new Map());\n }\n elementHandlers.get(key)!.set(handler, wrapper);\n\n el.addEventListener(event, wrapper);\n });\n\n return this;\n }\n\n /**\n * Removes a delegated event listener previously added with `delegate()`.\n *\n * @param event - Event type that was registered\n * @param selector - CSS selector that was used\n * @param handler - The original handler function passed to delegate()\n * @returns The instance for method chaining\n *\n * @example\n * ```ts\n * const handler = (e, target) => console.log('Clicked:', target.textContent);\n * $$('.container').delegate('click', '.item', handler);\n *\n * // Remove the delegated listener:\n * $$('.container').undelegate('click', '.item', handler);\n * ```\n */\n undelegate(\n event: string,\n selector: string,\n handler: (event: Event, target: Element) => void\n ): this {\n const key = `${event}:${selector}`;\n\n applyAll(this.elements, (el) => {\n const elementHandlers = this.delegatedHandlers.get(el);\n if (!elementHandlers) return;\n\n const handlers = elementHandlers.get(key);\n if (!handlers) return;\n\n const wrapper = handlers.get(handler);\n if (wrapper) {\n el.removeEventListener(event, wrapper);\n handlers.delete(handler);\n\n // Clean up empty maps\n if (handlers.size === 0) {\n elementHandlers.delete(key);\n }\n if (elementHandlers.size === 0) {\n this.delegatedHandlers.delete(el);\n }\n }\n });\n\n return this;\n }\n\n /**\n * Removes all elements from the DOM.\n *\n * @returns The instance for method chaining\n */\n remove(): this {\n applyAll(this.elements, (el) => el.remove());\n return this;\n }\n\n /**\n * Clears all child nodes from all elements.\n *\n * @returns The instance for method chaining\n */\n empty(): this {\n applyAll(this.elements, (el) => {\n el.innerHTML = '';\n });\n return this;\n }\n\n /** @internal */\n private insertAll(content: InsertableContent, position: InsertPosition): void {\n if (typeof content === 'string') {\n // Sanitize once and reuse for all elements\n const sanitized = sanitizeContent(content);\n applyAll(this.elements, (el) => {\n el.insertAdjacentHTML(position, sanitized);\n });\n return;\n }\n\n const elements = toElementList(content);\n this.elements.forEach((el, index) => {\n const nodes =\n index === 0 ? elements : elements.map((node) => node.cloneNode(true) as Element);\n insertContent(el, nodes, position);\n });\n }\n}\n","import { BQueryCollection } from './collection';\nimport { BQueryElement } from './element';\n\n/**\n * Select a single element. Returns a wrapper for chainable operations.\n */\nexport const $ = (selector: string | Element): BQueryElement => {\n if (typeof selector !== 'string') {\n return new BQueryElement(selector);\n }\n const element = document.querySelector(selector);\n if (!element) {\n throw new Error(`bQuery: element not found for selector \"${selector}\"`);\n }\n return new BQueryElement(element);\n};\n\n/**\n * Select multiple elements. Returns a collection wrapper.\n */\nexport const $$ = (selector: string | Element[] | NodeListOf<Element>): BQueryCollection => {\n if (Array.isArray(selector)) {\n return new BQueryCollection(selector);\n }\n if (selector instanceof NodeList) {\n return new BQueryCollection(Array.from(selector));\n }\n return new BQueryCollection(Array.from(document.querySelectorAll(selector)));\n};\n","/**\n * Array-focused utility helpers.\n *\n * @module bquery/core/utils/array\n */\n\n/**\n * Ensures the input is always returned as an array.\n *\n * @template T - The item type\n * @param value - A single value, array, or nullish value\n * @returns An array (empty if nullish)\n *\n * @example\n * ```ts\n * ensureArray('a'); // ['a']\n * ensureArray(['a', 'b']); // ['a', 'b']\n * ensureArray(null); // []\n * ```\n */\nexport function ensureArray<T>(value: T | T[] | null | undefined): T[] {\n if (value == null) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Removes duplicate entries from an array.\n *\n * @template T - The item type\n * @param items - The array to deduplicate\n * @returns A new array with unique items\n *\n * @example\n * ```ts\n * unique([1, 2, 2, 3]); // [1, 2, 3]\n * ```\n */\nexport function unique<T>(items: T[]): T[] {\n return Array.from(new Set(items));\n}\n\n/**\n * Splits an array into chunks of a given size.\n *\n * @template T - The item type\n * @param items - The array to chunk\n * @param size - The maximum size of each chunk\n * @returns An array of chunks\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]]\n * ```\n */\nexport function chunk<T>(items: T[], size: number): T[][] {\n if (size <= 0) return [];\n const result: T[][] = [];\n for (let i = 0; i < items.length; i += size) {\n result.push(items.slice(i, i + size));\n }\n return result;\n}\n\n/**\n * Removes falsy values from an array.\n *\n * @template T - The item type\n * @param items - The array to compact\n * @returns A new array without falsy values\n *\n * @example\n * ```ts\n * compact([0, 1, '', 'ok', null]); // [1, 'ok']\n * ```\n */\nexport function compact<T>(items: Array<T | null | undefined | false | 0 | ''>): T[] {\n return items.filter(Boolean) as T[];\n}\n\n/**\n * Flattens a single level of nested arrays.\n *\n * @template T - The item type\n * @param items - The array to flatten\n * @returns A new flattened array\n *\n * @example\n * ```ts\n * flatten([1, [2, 3], 4]); // [1, 2, 3, 4]\n * ```\n */\nexport function flatten<T>(items: Array<T | T[]>): T[] {\n const result: T[] = [];\n for (const item of items) {\n if (Array.isArray(item)) {\n result.push(...item);\n } else {\n result.push(item);\n }\n }\n return result;\n}\n","/**\n * Function-focused utility helpers.\n *\n * @module bquery/core/utils/function\n */\n\n/**\n * Creates a debounced function that delays execution until after\n * the specified delay has elapsed since the last call.\n *\n * @template TArgs - The argument types of the function\n * @param fn - The function to debounce\n * @param delayMs - Delay in milliseconds\n * @returns A debounced version of the function\n *\n * @example\n * ```ts\n * const search = debounce((query: string) => {\n * console.log('Searching:', query);\n * }, 300);\n *\n * search('h');\n * search('he');\n * search('hello'); // Only this call executes after 300ms\n * ```\n */\nexport function debounce<TArgs extends unknown[]>(\n fn: (...args: TArgs) => void,\n delayMs: number\n): (...args: TArgs) => void {\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n return (...args: TArgs) => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n timeoutId = setTimeout(() => fn(...args), delayMs);\n };\n}\n\n/**\n * Creates a throttled function that runs at most once per interval.\n *\n * @template TArgs - The argument types of the function\n * @param fn - The function to throttle\n * @param intervalMs - Minimum interval between calls in milliseconds\n * @returns A throttled version of the function\n *\n * @example\n * ```ts\n * const handleScroll = throttle(() => {\n * console.log('Scroll position:', window.scrollY);\n * }, 100);\n *\n * window.addEventListener('scroll', handleScroll);\n * ```\n */\nexport function throttle<TArgs extends unknown[]>(\n fn: (...args: TArgs) => void,\n intervalMs: number\n): (...args: TArgs) => void {\n let lastRun = 0;\n return (...args: TArgs) => {\n const now = Date.now();\n if (now - lastRun >= intervalMs) {\n lastRun = now;\n fn(...args);\n }\n };\n}\n\n/**\n * Ensures a function only runs once. Subsequent calls return the first result.\n *\n * @template TArgs - The argument types of the function\n * @template TResult - The return type of the function\n * @param fn - The function to wrap\n * @returns A function that only runs once\n *\n * @example\n * ```ts\n * const init = once(() => ({ ready: true }));\n * init();\n * init(); // only runs once\n * ```\n */\nexport function once<TArgs extends unknown[], TResult>(\n fn: (...args: TArgs) => TResult\n): (...args: TArgs) => TResult {\n let hasRun = false;\n let result!: TResult;\n return (...args: TArgs) => {\n if (!hasRun) {\n result = fn(...args);\n hasRun = true;\n }\n return result;\n };\n}\n\n/**\n * A no-operation function.\n *\n * @example\n * ```ts\n * noop();\n * ```\n */\nexport function noop(): void {\n // Intentionally empty\n}\n","/**\n * Miscellaneous utility helpers.\n *\n * @module bquery/core/utils/misc\n */\n\n/**\n * Creates a stable unique ID for DOM usage.\n *\n * @param prefix - Optional prefix for the ID (default: 'bQuery')\n * @returns A unique identifier string\n *\n * @example\n * ```ts\n * const id = uid('modal'); // 'modal_x7k2m9p'\n * ```\n */\nexport function uid(prefix = 'bQuery'): string {\n return `${prefix}_${Math.random().toString(36).slice(2, 9)}`;\n}\n\n/**\n * Delays execution for a specified number of milliseconds.\n *\n * @param ms - Milliseconds to delay\n * @returns A promise that resolves after the delay\n *\n * @example\n * ```ts\n * await sleep(1000); // Wait 1 second\n * console.log('Done!');\n * ```\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Safely parses a JSON string, returning a default value on error.\n *\n * @template T - The expected type of the parsed value\n * @param json - The JSON string to parse\n * @param fallback - The default value if parsing fails\n * @returns The parsed value or the fallback\n *\n * @example\n * ```ts\n * parseJson('{\"name\":\"bQuery\"}', {}); // { name: 'bQuery' }\n * parseJson('invalid', {}); // {}\n * ```\n */\nexport function parseJson<T>(json: string, fallback: T): T {\n try {\n return JSON.parse(json) as T;\n } catch {\n return fallback;\n }\n}\n\n/**\n * Checks for emptiness across common value types.\n *\n * @param value - The value to check\n * @returns True if the value is empty (null, undefined, empty string, empty array, or empty object)\n *\n * @example\n * ```ts\n * isEmpty(''); // true\n * isEmpty([]); // true\n * isEmpty({}); // true\n * isEmpty(null); // true\n * isEmpty('hello'); // false\n * isEmpty([1, 2]); // false\n * ```\n */\nexport function isEmpty(value: unknown): boolean {\n if (value == null) return true;\n if (typeof value === 'string') return value.trim().length === 0;\n if (Array.isArray(value)) return value.length === 0;\n if (typeof value === 'object') return Object.keys(value as object).length === 0;\n return false;\n}\n","/**\n * Number-focused utility helpers.\n *\n * @module bquery/core/utils/number\n */\n\n/**\n * Generates a random integer between min and max (inclusive).\n *\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns A random integer in the range [min, max]\n *\n * @example\n * ```ts\n * const roll = randomInt(1, 6); // Random dice roll\n * ```\n */\nexport function randomInt(min: number, max: number): number {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\n/**\n * Clamps a number between a minimum and maximum value.\n *\n * @param value - The value to clamp\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns The clamped value\n *\n * @example\n * ```ts\n * clamp(150, 0, 100); // 100\n * clamp(-10, 0, 100); // 0\n * clamp(50, 0, 100); // 50\n * ```\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Checks if a number is within a range.\n *\n * @param value - The value to check\n * @param min - Minimum value\n * @param max - Maximum value\n * @param inclusive - Whether the range is inclusive (default: true)\n * @returns True if the value is within the range\n *\n * @example\n * ```ts\n * inRange(5, 1, 10); // true\n * inRange(10, 1, 10, false); // false\n * ```\n */\nexport function inRange(value: number, min: number, max: number, inclusive = true): boolean {\n if (inclusive) return value >= min && value <= max;\n return value > min && value < max;\n}\n\n/**\n * Converts a value to a number with a fallback on NaN.\n *\n * @param value - The value to convert\n * @param fallback - The fallback value if conversion fails (default: 0)\n * @returns The parsed number or the fallback\n *\n * @example\n * ```ts\n * toNumber('42'); // 42\n * toNumber('nope', 10); // 10\n * ```\n */\nexport function toNumber(value: unknown, fallback = 0): number {\n const parsed = typeof value === 'number' ? value : Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n}\n","/**\n * Object-focused utility helpers.\n *\n * @module bquery/core/utils/object\n */\n\n/**\n * Checks if a value is a plain object (not null, array, or class instance).\n *\n * @param value - The value to check\n * @returns True if the value is a plain object\n */\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Checks if a key could cause prototype pollution.\n * These keys are dangerous when used in object merging operations.\n *\n * @param key - The key to check\n * @returns True if the key is a prototype pollution vector\n *\n * @internal\n */\nexport function isPrototypePollutionKey(key: string): boolean {\n return key === '__proto__' || key === 'constructor' || key === 'prototype';\n}\n\n/**\n * Creates a deep clone using structuredClone if available, otherwise fallback to JSON.\n *\n * @template T - The type of value being cloned\n * @param value - The value to clone\n * @returns A deep copy of the value\n *\n * @remarks\n * When `structuredClone` is available (modern browsers, Node 17+, Bun), this function\n * provides full deep cloning including circular references, Date, Map, Set, ArrayBuffer, etc.\n *\n * **JSON fallback limitations** (older environments without `structuredClone`):\n * - **Throws** on circular references\n * - **Drops** functions, `undefined`, and Symbol properties\n * - **Transforms** Date → ISO string, Map/Set → empty object, BigInt → throws\n * - **Loses** prototype chains and non-enumerable properties\n *\n * For guaranteed safe cloning of arbitrary data, ensure your environment supports\n * `structuredClone` or pre-validate your data structure.\n *\n * @example\n * ```ts\n * const original = { nested: { value: 1 } };\n * const copy = clone(original);\n * copy.nested.value = 2;\n * console.log(original.nested.value); // 1\n * ```\n */\nexport function clone<T>(value: T): T {\n if (typeof structuredClone === 'function') {\n return structuredClone(value);\n }\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\n/**\n * Deep-merges plain objects into a new object.\n * Later sources override earlier ones for primitive values.\n * Objects are recursively merged.\n *\n * @param sources - Objects to merge\n * @returns A new object with all sources merged as an intersection type\n *\n * @remarks\n * This function uses overloads to provide accurate intersection types for up to 5 sources.\n * For more than 5 sources, the return type falls back to `Record<string, unknown>`.\n *\n * Note that deep merging creates a shallow intersection at the type level. Nested objects\n * are merged at runtime, but TypeScript sees them as intersected types which may not\n * perfectly represent the merged structure for deeply nested conflicting types.\n *\n * @example\n * ```ts\n * const result = merge(\n * { a: 1, nested: { x: 1 } },\n * { b: 2, nested: { y: 2 } }\n * );\n * // Result: { a: 1, b: 2, nested: { x: 1, y: 2 } }\n * // Type: { a: number; nested: { x: number } } & { b: number; nested: { y: number } }\n * ```\n *\n * @security This method is protected against prototype pollution attacks.\n * Keys like `__proto__`, `constructor`, and `prototype` are ignored.\n */\nexport function merge<T1 extends Record<string, unknown>>(source1: T1): T1;\nexport function merge<T1 extends Record<string, unknown>, T2 extends Record<string, unknown>>(\n source1: T1,\n source2: T2\n): T1 & T2;\nexport function merge<\n T1 extends Record<string, unknown>,\n T2 extends Record<string, unknown>,\n T3 extends Record<string, unknown>,\n>(source1: T1, source2: T2, source3: T3): T1 & T2 & T3;\nexport function merge<\n T1 extends Record<string, unknown>,\n T2 extends Record<string, unknown>,\n T3 extends Record<string, unknown>,\n T4 extends Record<string, unknown>,\n>(source1: T1, source2: T2, source3: T3, source4: T4): T1 & T2 & T3 & T4;\nexport function merge<\n T1 extends Record<string, unknown>,\n T2 extends Record<string, unknown>,\n T3 extends Record<string, unknown>,\n T4 extends Record<string, unknown>,\n T5 extends Record<string, unknown>,\n>(source1: T1, source2: T2, source3: T3, source4: T4, source5: T5): T1 & T2 & T3 & T4 & T5;\nexport function merge(...sources: Record<string, unknown>[]): Record<string, unknown>;\nexport function merge(...sources: Record<string, unknown>[]): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isPrototypePollutionKey(key)) continue;\n\n if (isPlainObject(value) && isPlainObject(result[key])) {\n result[key] = merge(\n result[key] as Record<string, unknown>,\n value as Record<string, unknown>\n );\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n/**\n * Picks specified keys from an object.\n *\n * @template T - The object type\n * @template K - The key type\n * @param obj - The source object\n * @param keys - Keys to pick\n * @returns A new object with only the specified keys\n *\n * @example\n * ```ts\n * const user = { name: 'John', age: 30, email: 'john@example.com' };\n * pick(user, ['name', 'email']); // { name: 'John', email: 'john@example.com' }\n * ```\n */\nexport function pick<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Pick<T, K> {\n const result = {} as Pick<T, K>;\n for (const key of keys) {\n if (key in obj) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n\n/**\n * Omits specified keys from an object.\n *\n * @template T - The object type\n * @template K - The key type\n * @param obj - The source object\n * @param keys - Keys to omit\n * @returns A new object without the specified keys\n *\n * @example\n * ```ts\n * const user = { name: 'John', age: 30, password: 'secret' };\n * omit(user, ['password']); // { name: 'John', age: 30 }\n * ```\n */\nexport function omit<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Omit<T, K> {\n const result = { ...obj };\n for (const key of keys) {\n delete result[key];\n }\n return result as Omit<T, K>;\n}\n\n/**\n * Checks if an object has a given own property.\n *\n * @template T - The object type\n * @param obj - The object to check\n * @param key - The property key\n * @returns True if the property exists on the object\n *\n * @example\n * ```ts\n * hasOwn({ a: 1 }, 'a'); // true\n * ```\n */\nexport function hasOwn<T extends object>(obj: T, key: PropertyKey): key is keyof T {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n","/**\n * String-focused utility helpers.\n *\n * @module bquery/core/utils/string\n */\n\n/**\n * Capitalizes the first letter of a string.\n *\n * @param str - The string to capitalize\n * @returns The capitalized string\n *\n * @example\n * ```ts\n * capitalize('hello'); // 'Hello'\n * ```\n */\nexport function capitalize(str: string): string {\n if (!str) return str;\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Converts a string to kebab-case.\n *\n * @param str - The string to convert\n * @returns The kebab-cased string\n *\n * @example\n * ```ts\n * toKebabCase('myVariableName'); // 'my-variable-name'\n * ```\n */\nexport function toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .toLowerCase();\n}\n\n/**\n * Converts a string to camelCase.\n *\n * @param str - The string to convert\n * @returns The camelCased string\n *\n * @example\n * ```ts\n * toCamelCase('my-variable-name'); // 'myVariableName'\n * ```\n */\nexport function toCamelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, char) => (char ? char.toUpperCase() : ''))\n .replace(/^[A-Z]/, (char) => char.toLowerCase());\n}\n\n/**\n * Truncates a string to a maximum length.\n *\n * @param str - The string to truncate\n * @param maxLength - The maximum length\n * @param suffix - The suffix to append when truncating (default: '…')\n * @returns The truncated string\n *\n * @example\n * ```ts\n * truncate('Hello world', 8); // 'Hello w…'\n * ```\n */\nexport function truncate(str: string, maxLength: number, suffix = '…'): string {\n if (maxLength <= 0) return '';\n if (str.length <= maxLength) return str;\n const sliceLength = Math.max(0, maxLength - suffix.length);\n return `${str.slice(0, sliceLength)}${suffix}`;\n}\n\n/**\n * Converts a string to a URL-friendly slug.\n *\n * @param str - The string to slugify\n * @returns The slugified string\n *\n * @example\n * ```ts\n * slugify('Hello, World!'); // 'hello-world'\n * ```\n */\nexport function slugify(str: string): string {\n return str\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .replace(/[^\\w\\s-]/g, '')\n .trim()\n .replace(/[\\s_-]+/g, '-')\n .toLowerCase();\n}\n\n/**\n * Escapes a string for safe usage inside a RegExp.\n *\n * @param str - The string to escape\n * @returns The escaped string\n *\n * @example\n * ```ts\n * escapeRegExp('[a-z]+'); // '\\\\[a-z\\\\]+'\n * ```\n */\nexport function escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","/**\n * Type guard helpers.\n *\n * @module bquery/core/utils/type-guards\n */\n\n/**\n * Checks if a value is a DOM Element.\n *\n * @param value - The value to check\n * @returns True if the value is an Element\n */\nexport function isElement(value: unknown): value is Element {\n return typeof Element !== 'undefined' && value instanceof Element;\n}\n\n/**\n * Checks if a value is a BQueryCollection-like object.\n *\n * @param value - The value to check\n * @returns True if the value has an elements array property\n */\nexport function isCollection(value: unknown): value is { elements: Element[] } {\n return Boolean(value && typeof value === 'object' && 'elements' in (value as object));\n}\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check\n * @returns True if the value is a function\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check\n * @returns True if the value is a string\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Checks if a value is a number (excluding NaN).\n *\n * @param value - The value to check\n * @returns True if the value is a valid number\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value);\n}\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check\n * @returns True if the value is a boolean\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if a value is an array.\n *\n * @template T - The type of array elements\n * @param value - The value to check\n * @returns True if the value is an array\n */\nexport function isArray<T = unknown>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Checks if a value is a Date instance.\n *\n * @param value - The value to check\n * @returns True if the value is a Date\n */\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\n/**\n * Checks if a value is a Promise-like object.\n *\n * @param value - The value to check\n * @returns True if the value is a Promise-like object\n */\nexport function isPromise<T = unknown>(value: unknown): value is Promise<T> {\n return Boolean(\n value &&\n (value instanceof Promise ||\n (typeof value === 'object' &&\n 'then' in (value as object) &&\n typeof (value as { then?: unknown }).then === 'function'))\n );\n}\n\n/**\n * Checks if a value is a non-null object.\n *\n * @param value - The value to check\n * @returns True if the value is an object\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n","/**\n * Utility helpers used across the framework.\n * These are intentionally small and framework-agnostic to keep the core tiny.\n *\n * @module bquery/core/utils\n */\n\nexport * from './array';\nexport * from './function';\nexport * from './misc';\nexport * from './number';\nexport * from './object';\nexport * from './string';\nexport * from './type-guards';\n\nimport { chunk, compact, ensureArray, flatten, unique } from './array';\nimport { debounce, noop, once, throttle } from './function';\nimport { isEmpty, parseJson, sleep, uid } from './misc';\nimport { clamp, inRange, randomInt, toNumber } from './number';\nimport { clone, hasOwn, isPlainObject, merge, omit, pick } from './object';\nimport { capitalize, escapeRegExp, slugify, toCamelCase, toKebabCase, truncate } from './string';\nimport {\n isArray,\n isBoolean,\n isCollection,\n isDate,\n isElement,\n isFunction,\n isNumber,\n isObject,\n isPromise,\n isString,\n} from './type-guards';\n\n/**\n * Utility object containing common helper functions.\n * All utilities are designed to be tree-shakeable and have zero dependencies.\n *\n * Note: `isPrototypePollutionKey` is intentionally excluded from this namespace\n * as it is an internal security helper. It remains available as a named export\n * for internal framework use.\n */\nexport const utils = {\n clone,\n merge,\n pick,\n omit,\n hasOwn,\n debounce,\n throttle,\n once,\n noop,\n uid,\n isElement,\n isCollection,\n isEmpty,\n isPlainObject,\n isFunction,\n isString,\n isNumber,\n isBoolean,\n isArray,\n isDate,\n isPromise,\n isObject,\n parseJson,\n sleep,\n randomInt,\n clamp,\n inRange,\n toNumber,\n capitalize,\n toKebabCase,\n toCamelCase,\n truncate,\n slugify,\n escapeRegExp,\n ensureArray,\n unique,\n chunk,\n compact,\n flatten,\n};\n"],"names":["toElementList","input","applyAll","elements","action","el","sanitizeContent","html","sanitizeHtml","setHtml","element","createElementFromHtml","template","insertContent","target","content","position","orderedElements","BQueryElement","classNames","className","force","name","value","hasAttr","key","match","property","val","wrapper","wrapperEl","parent","newEl","options","deep","selector","child","event","handler","detail","e","handlers","display","isHidden","newValue","form","result","formData","existing","params","BQueryCollection","index","callback","predicate","initialValue","sanitized","parents","grandParent","replacements","replacement","elementHandlers","nodes","node","$","$$","ensureArray","unique","items","chunk","size","i","compact","flatten","item","debounce","fn","delayMs","timeoutId","args","throttle","intervalMs","lastRun","now","once","hasRun","noop","uid","prefix","sleep","ms","resolve","parseJson","json","fallback","isEmpty","randomInt","min","max","clamp","inRange","inclusive","toNumber","parsed","isPlainObject","isPrototypePollutionKey","clone","merge","sources","source","pick","obj","keys","omit","hasOwn","capitalize","str","toKebabCase","toCamelCase","_","char","truncate","maxLength","suffix","sliceLength","slugify","escapeRegExp","isElement","isCollection","isFunction","isString","isNumber","isBoolean","isArray","isDate","isPromise","isObject","utils"],"mappings":";AAKO,MAAMA,IAAgB,CAACC,MAC5B,MAAM,QAAQA,CAAK,IAAIA,IAAQ,CAACA,CAAK,GAE1BC,IAAW,CAACC,GAAuBC,MAAkC;AAChF,aAAWC,KAAMF;AACf,IAAAC,EAAOC,CAAE;AAEb,GCPaC,IAAkB,CAACC,MAAyBC,EAAaD,CAAI,GAE7DE,IAAU,CAACC,GAAkBH,MAAuB;AAC/D,EAAAG,EAAQ,YAAYF,EAAaD,CAAI;AAC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EACA,cAAAC;AAAA,EACA,SAAAjC;AAAA,EACA,eAAAS;AAAA,EACA,YAAAyB;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAA5C;AAAA,EACA,OAAAH;AAAA,EACA,WAAAO;AAAA,EACA,OAAAG;AAAA,EACA,SAAAC;AAAA,EACA,UAAAE;AAAA,EACA,YAAAa;AAAA,EACA,aAAAE;AAAA,EACA,aAAAC;AAAA,EACA,UAAAG;AAAA,EACA,SAAAI;AAAA,EACA,cAAAC;AAAA,EACA,aAAA5D;AAAA,EACA,QAAAC;AAAA,EACA,OAAAE;AAAA,EACA,SAAAG;AAAA,EACA,SAAAC;AACF;"}
1
+ {"version":3,"file":"core.es.mjs","sources":["../src/core/shared.ts","../src/core/dom.ts","../src/core/element.ts","../src/core/collection.ts","../src/core/selector.ts","../src/core/utils/array.ts","../src/core/utils/function.ts","../src/core/utils/misc.ts","../src/core/utils/number.ts","../src/core/utils/object.ts","../src/core/utils/string.ts","../src/core/utils/type-guards.ts","../src/core/utils/index.ts"],"sourcesContent":["/**\n * Shared helpers for element wrappers.\n */\nexport type ElementList = Element[];\n\nexport const toElementList = (input: Element | ElementList): ElementList =>\n Array.isArray(input) ? input : [input];\n\nexport const applyAll = (elements: ElementList, action: (el: Element) => void) => {\n for (const el of elements) {\n action(el);\n }\n};\n","import { sanitizeHtml } from '../security/sanitize';\nimport { applyAll, toElementList } from './shared';\n\nexport type InsertableContent = string | Element | Element[];\n\nexport const sanitizeContent = (html: string): string => sanitizeHtml(html);\n\nexport const setHtml = (element: Element, html: string): void => {\n element.innerHTML = sanitizeHtml(html);\n};\n\nexport const createElementFromHtml = (html: string): Element => {\n const template = document.createElement('template');\n template.innerHTML = sanitizeHtml(html);\n return template.content.firstElementChild ?? document.createElement('div');\n};\n\nexport const insertContent = (\n target: Element,\n content: InsertableContent,\n position: InsertPosition\n): void => {\n if (typeof content === 'string') {\n target.insertAdjacentHTML(position, sanitizeHtml(content));\n return;\n }\n\n const elements = toElementList(content);\n\n // For positions that insert at the beginning (afterbegin, afterend), reverse\n // the array to maintain the caller's order. For beforeend/beforebegin, keep order.\n const needsReverse = position === 'afterbegin' || position === 'afterend';\n const orderedElements = needsReverse ? elements.slice().reverse() : elements;\n\n applyAll(orderedElements, (el) => {\n target.insertAdjacentElement(position, el);\n });\n};\n","import { createElementFromHtml, insertContent, setHtml } from './dom';\r\n\r\n/**\r\n * Wrapper for a single DOM element.\r\n * Provides a chainable, jQuery-like API for DOM manipulation.\r\n *\r\n * This class encapsulates a DOM element and provides methods for:\r\n * - Class manipulation (addClass, removeClass, toggleClass)\r\n * - Attribute and property access (attr, prop, data)\r\n * - Content manipulation (text, html, append, prepend)\r\n * - Style manipulation (css)\r\n * - Event handling (on, off, once, trigger)\r\n * - DOM traversal (find, closest, parent, children, siblings)\r\n *\r\n * All mutating methods return `this` for method chaining.\r\n *\r\n * @example\r\n * ```ts\r\n * $('#button')\r\n * .addClass('active')\r\n * .css({ color: 'blue' })\r\n * .on('click', () => console.log('clicked'));\r\n * ```\r\n */\r\n/** Handler signature for delegated events */\r\ntype DelegatedHandler = (event: Event, target: Element) => void;\r\n\r\nexport class BQueryElement {\r\n /**\r\n * Stores delegated event handlers for cleanup via undelegate().\r\n * Key format: `${event}:${selector}`\r\n * @internal\r\n */\r\n private readonly delegatedHandlers = new Map<string, Map<DelegatedHandler, EventListener>>();\r\n\r\n /**\r\n * Creates a new BQueryElement wrapper.\r\n * @param element - The DOM element to wrap\r\n */\r\n constructor(private readonly element: Element) {}\r\n\r\n /**\r\n * Exposes the raw DOM element when direct access is needed.\r\n * Use sparingly; prefer the wrapper methods for consistency.\r\n */\r\n get raw(): Element {\r\n return this.element;\r\n }\r\n\r\n /**\r\n * Exposes the underlying DOM element.\r\n * Provided for spec compatibility and read-only access.\r\n */\r\n get node(): Element {\r\n return this.element;\r\n }\r\n\r\n /** Add one or more classes. */\r\n addClass(...classNames: string[]): this {\r\n this.element.classList.add(...classNames);\r\n return this;\r\n }\r\n\r\n /** Remove one or more classes. */\r\n removeClass(...classNames: string[]): this {\r\n this.element.classList.remove(...classNames);\r\n return this;\r\n }\r\n\r\n /** Toggle a class by name. */\r\n toggleClass(className: string, force?: boolean): this {\r\n this.element.classList.toggle(className, force);\r\n return this;\r\n }\r\n\r\n /** Get or set an attribute. */\r\n attr(name: string, value?: string): string | this {\r\n if (value === undefined) {\r\n return this.element.getAttribute(name) ?? '';\r\n }\r\n this.element.setAttribute(name, value);\r\n return this;\r\n }\r\n\r\n /** Remove an attribute. */\r\n removeAttr(name: string): this {\r\n this.element.removeAttribute(name);\r\n return this;\r\n }\r\n\r\n /** Toggle an attribute on/off. */\r\n toggleAttr(name: string, force?: boolean): this {\r\n const hasAttr = this.element.hasAttribute(name);\r\n const shouldAdd = force ?? !hasAttr;\r\n if (shouldAdd) {\r\n this.element.setAttribute(name, '');\r\n } else {\r\n this.element.removeAttribute(name);\r\n }\r\n return this;\r\n }\r\n\r\n /** Get or set a property. */\r\n prop<T extends keyof Element>(name: T, value?: Element[T]): Element[T] | this {\r\n if (value === undefined) {\r\n return this.element[name];\r\n }\r\n this.element[name] = value;\r\n return this;\r\n }\r\n\r\n /** Read or write data attributes in camelCase. */\r\n data(name: string, value?: string): string | this {\r\n const key = name.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\r\n if (value === undefined) {\r\n return this.element.getAttribute(`data-${key}`) ?? '';\r\n }\r\n this.element.setAttribute(`data-${key}`, value);\r\n return this;\r\n }\r\n\r\n /** Get or set text content. */\r\n text(value?: string): string | this {\r\n if (value === undefined) {\r\n return this.element.textContent ?? '';\r\n }\r\n this.element.textContent = value;\r\n return this;\r\n }\r\n\r\n /** Set HTML content using a sanitized string. */\r\n /**\r\n * Sets sanitized HTML content on the element.\r\n * Uses the security module to sanitize input and prevent XSS attacks.\r\n *\r\n * @param value - The HTML string to set (will be sanitized)\r\n * @returns The instance for method chaining\r\n *\r\n * @example\r\n * ```ts\r\n * $('#content').html('<strong>Hello</strong>');\r\n * ```\r\n */\r\n html(value: string): this {\r\n setHtml(this.element, value);\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets HTML content without sanitization.\r\n * Use only when you trust the HTML source completely.\r\n *\r\n * @param value - The raw HTML string to set\r\n * @returns The instance for method chaining\r\n *\r\n * @warning This method bypasses XSS protection. Use with caution.\r\n */\r\n htmlUnsafe(value: string): this {\r\n this.element.innerHTML = value;\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets or sets CSS styles on the element.\r\n *\r\n * @param property - A CSS property name or an object of property-value pairs\r\n * @param value - The value when setting a single property\r\n * @returns The computed style value when getting a single property, or the instance for method chaining when setting\r\n *\r\n * @example\r\n * ```ts\r\n * // Get a computed style value\r\n * const color = $('#box').css('color');\r\n *\r\n * // Set a single property\r\n * $('#box').css('color', 'red');\r\n *\r\n * // Set multiple properties\r\n * $('#box').css({ color: 'red', 'font-size': '16px' });\r\n * ```\r\n */\r\n css(property: string): string;\r\n css(property: string, value: string): this;\r\n css(property: Record<string, string>): this;\r\n css(property: string | Record<string, string>, value?: string): string | this {\r\n if (typeof property === 'string') {\r\n if (value !== undefined) {\r\n (this.element as HTMLElement).style.setProperty(property, value);\r\n return this;\r\n }\r\n const view = this.element.ownerDocument?.defaultView;\r\n if (!view || typeof view.getComputedStyle !== 'function') {\r\n return '';\r\n }\r\n return view.getComputedStyle(this.element).getPropertyValue(property);\r\n }\r\n\r\n for (const [key, val] of Object.entries(property)) {\r\n (this.element as HTMLElement).style.setProperty(key, val);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Appends HTML or elements to the end of the element.\r\n *\r\n * @param content - HTML string or element(s) to append\r\n * @returns The instance for method chaining\r\n */\r\n append(content: string | Element | Element[]): this {\r\n this.insertContent(content, 'beforeend');\r\n return this;\r\n }\r\n\r\n /**\r\n * Prepends HTML or elements to the beginning of the element.\r\n *\r\n * @param content - HTML string or element(s) to prepend\r\n * @returns The instance for method chaining\r\n */\r\n prepend(content: string | Element | Element[]): this {\r\n this.insertContent(content, 'afterbegin');\r\n return this;\r\n }\r\n\r\n /**\r\n * Inserts content before this element.\r\n *\r\n * @param content - HTML string or element(s) to insert\r\n * @returns The instance for method chaining\r\n */\r\n before(content: string | Element | Element[]): this {\r\n this.insertContent(content, 'beforebegin');\r\n return this;\r\n }\r\n\r\n /**\r\n * Inserts content after this element.\r\n *\r\n * @param content - HTML string or element(s) to insert\r\n * @returns The instance for method chaining\r\n */\r\n after(content: string | Element | Element[]): this {\r\n this.insertContent(content, 'afterend');\r\n return this;\r\n }\r\n\r\n /**\r\n * Wraps the element with the specified wrapper element or tag.\r\n *\r\n * @param wrapper - Tag name string or Element to wrap with\r\n * @returns The instance for method chaining\r\n *\r\n * @example\r\n * ```ts\r\n * $('#content').wrap('div'); // Wraps with <div>\r\n * $('#content').wrap(document.createElement('section'));\r\n * ```\r\n */\r\n wrap(wrapper: string | Element): this {\r\n const wrapperEl = typeof wrapper === 'string' ? document.createElement(wrapper) : wrapper;\r\n this.element.parentNode?.insertBefore(wrapperEl, this.element);\r\n wrapperEl.appendChild(this.element);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes the parent element, keeping this element in its place.\r\n * Essentially the opposite of wrap().\r\n *\r\n * **Important**: This method only moves the current element out of its parent\r\n * before removing the parent. Any sibling elements will be removed along with\r\n * the parent. For unwrapping multiple siblings, use a collection: `$$(siblings).unwrap()`.\r\n *\r\n * @returns The instance for method chaining\r\n *\r\n * @example\r\n * ```ts\r\n * // Before: <div><span id=\"text\">Hello</span></div>\r\n * $('#text').unwrap();\r\n * // After: <span id=\"text\">Hello</span>\r\n * ```\r\n */\r\n unwrap(): this {\r\n const parent = this.element.parentElement;\r\n if (parent && parent.parentNode) {\r\n parent.parentNode.insertBefore(this.element, parent);\r\n parent.remove();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Replaces this element with new content.\r\n *\r\n * @param content - HTML string (sanitized) or Element to replace with\r\n * @returns A new BQueryElement wrapping the replacement element\r\n *\r\n * @example\r\n * ```ts\r\n * const newEl = $('#old').replaceWith('<div id=\"new\">Replaced</div>');\r\n * ```\r\n */\r\n replaceWith(content: string | Element): BQueryElement {\r\n const newEl = typeof content === 'string' ? createElementFromHtml(content) : content;\r\n this.element.replaceWith(newEl);\r\n return new BQueryElement(newEl);\r\n }\r\n\r\n /**\r\n * Scrolls the element into view with configurable behavior.\r\n *\r\n * @param options - ScrollIntoView options or boolean for legacy behavior\r\n * @returns The instance for method chaining\r\n *\r\n * @example\r\n * ```ts\r\n * $('#section').scrollTo(); // Smooth scroll\r\n * $('#section').scrollTo({ behavior: 'instant', block: 'start' });\r\n * ```\r\n */\r\n scrollTo(options: ScrollIntoViewOptions | boolean = { behavior: 'smooth' }): this {\r\n this.element.scrollIntoView(options);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes the element from the DOM.\r\n *\r\n * @returns The instance for method chaining (though element is now detached)\r\n */\r\n remove(): this {\r\n this.element.remove();\r\n return this;\r\n }\r\n\r\n /**\r\n * Clears all child nodes from the element.\r\n *\r\n * @returns The instance for method chaining\r\n */\r\n empty(): this {\r\n this.element.innerHTML = '';\r\n return this;\r\n }\r\n\r\n /**\r\n * Clones the element, optionally with all descendants.\r\n *\r\n * @param deep - If true, clone all descendants (default: true)\r\n * @returns A new BQueryElement wrapping the cloned element\r\n */\r\n clone(deep: boolean = true): BQueryElement {\r\n return new BQueryElement(this.element.cloneNode(deep) as Element);\r\n }\r\n\r\n /**\r\n * Finds all descendant elements matching the selector.\r\n *\r\n * @param selector - CSS selector to match\r\n * @returns Array of matching elements\r\n */\r\n find(selector: string): Element[] {\r\n return Array.from(this.element.querySelectorAll(selector));\r\n }\r\n\r\n /**\r\n * Finds the first descendant element matching the selector.\r\n *\r\n * @param selector - CSS selector to match\r\n * @returns The first matching element or null\r\n */\r\n findOne(selector: string): Element | null {\r\n return this.element.querySelector(selector);\r\n }\r\n\r\n /**\r\n * Finds the closest ancestor matching the selector.\r\n *\r\n * @param selector - CSS selector to match\r\n * @returns The matching ancestor or null\r\n */\r\n closest(selector: string): Element | null {\r\n return this.element.closest(selector);\r\n }\r\n\r\n /**\r\n * Gets the parent element.\r\n *\r\n * @returns The parent element or null\r\n */\r\n parent(): Element | null {\r\n return this.element.parentElement;\r\n }\r\n\r\n /**\r\n * Gets all child elements.\r\n *\r\n * @returns Array of child elements\r\n */\r\n children(): Element[] {\r\n return Array.from(this.element.children);\r\n }\r\n\r\n /**\r\n * Gets all sibling elements.\r\n *\r\n * @returns Array of sibling elements (excluding this element)\r\n */\r\n siblings(): Element[] {\r\n const parent = this.element.parentElement;\r\n if (!parent) return [];\r\n return Array.from(parent.children).filter((child) => child !== this.element);\r\n }\r\n\r\n /**\r\n * Gets the next sibling element.\r\n *\r\n * @returns The next sibling element or null\r\n */\r\n next(): Element | null {\r\n return this.element.nextElementSibling;\r\n }\r\n\r\n /**\r\n * Gets the previous sibling element.\r\n *\r\n * @returns The previous sibling element or null\r\n */\r\n prev(): Element | null {\r\n return this.element.previousElementSibling;\r\n }\r\n\r\n /**\r\n * Adds an event listener.\r\n *\r\n * @param event - Event type to listen for\r\n * @param handler - Event handler function\r\n * @returns The instance for method chaining\r\n */\r\n on(event: string, handler: EventListenerOrEventListenerObject): this {\r\n this.element.addEventListener(event, handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a one-time event listener that removes itself after firing.\r\n *\r\n * @param event - Event type to listen for\r\n * @param handler - Event handler function\r\n * @returns The instance for method chaining\r\n */\r\n once(event: string, handler: EventListener): this {\r\n this.element.addEventListener(event, handler, { once: true });\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes an event listener.\r\n *\r\n * @param event - Event type\r\n * @param handler - The handler to remove\r\n * @returns The instance for method chaining\r\n */\r\n off(event: string, handler: EventListenerOrEventListenerObject): this {\r\n this.element.removeEventListener(event, handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Triggers a custom event on the element.\r\n *\r\n * @param event - Event type to trigger\r\n * @param detail - Optional detail data to include with the event\r\n * @returns The instance for method chaining\r\n */\r\n trigger(event: string, detail?: unknown): this {\r\n this.element.dispatchEvent(new CustomEvent(event, { detail, bubbles: true, cancelable: true }));\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a delegated event listener that only triggers for matching descendants.\r\n * More efficient than adding listeners to many elements individually.\r\n *\r\n * Use `undelegate()` to remove the listener later.\r\n *\r\n * @param event - Event type to listen for\r\n * @param selector - CSS selector to match against event targets\r\n * @param handler - Event handler function, receives the matched element as context\r\n * @returns The instance for method chaining\r\n *\r\n * @example\r\n * ```ts\r\n * // Instead of adding listeners to each button:\r\n * const handler = (e, target) => console.log('Clicked:', target.textContent);\r\n * $('#list').delegate('click', '.item', handler);\r\n *\r\n * // Later, remove the delegated listener:\r\n * $('#list').undelegate('click', '.item', handler);\r\n * ```\r\n */\r\n delegate(\r\n event: string,\r\n selector: string,\r\n handler: (event: Event, target: Element) => void\r\n ): this {\r\n const key = `${event}:${selector}`;\r\n const wrapper: EventListener = (e: Event) => {\r\n const target = (e.target as Element).closest(selector);\r\n if (target && this.element.contains(target)) {\r\n handler(e, target);\r\n }\r\n };\r\n\r\n // Store the wrapper so it can be removed later\r\n if (!this.delegatedHandlers.has(key)) {\r\n this.delegatedHandlers.set(key, new Map());\r\n }\r\n this.delegatedHandlers.get(key)!.set(handler, wrapper);\r\n\r\n this.element.addEventListener(event, wrapper);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a delegated event listener previously added with `delegate()`.\r\n *\r\n * @param event - Event type that was registered\r\n * @param selector - CSS selector that was used\r\n * @param handler - The original handler function passed to delegate()\r\n * @returns The instance for method chaining\r\n *\r\n * @example\r\n * ```ts\r\n * const handler = (e, target) => console.log('Clicked:', target.textContent);\r\n * $('#list').delegate('click', '.item', handler);\r\n *\r\n * // Remove the delegated listener:\r\n * $('#list').undelegate('click', '.item', handler);\r\n * ```\r\n */\r\n undelegate(\r\n event: string,\r\n selector: string,\r\n handler: (event: Event, target: Element) => void\r\n ): this {\r\n const key = `${event}:${selector}`;\r\n const handlers = this.delegatedHandlers.get(key);\r\n\r\n if (handlers) {\r\n const wrapper = handlers.get(handler);\r\n if (wrapper) {\r\n this.element.removeEventListener(event, wrapper);\r\n handlers.delete(handler);\r\n\r\n // Clean up empty maps\r\n if (handlers.size === 0) {\r\n this.delegatedHandlers.delete(key);\r\n }\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Checks if the element matches a CSS selector.\r\n *\r\n * @param selector - CSS selector to match against\r\n * @returns True if the element matches the selector\r\n */\r\n matches(selector: string): boolean {\r\n return this.element.matches(selector);\r\n }\r\n\r\n /**\r\n * Alias for `matches()`. Checks if the element matches a CSS selector.\r\n *\r\n * @param selector - CSS selector to match against\r\n * @returns True if the element matches the selector\r\n *\r\n * @example\r\n * ```ts\r\n * if ($('#el').is('.active')) {\r\n * console.log('Element is active');\r\n * }\r\n * ```\r\n */\r\n is(selector: string): boolean {\r\n return this.matches(selector);\r\n }\r\n\r\n /**\r\n * Checks if the element has a specific class.\r\n *\r\n * @param className - Class name to check\r\n * @returns True if the element has the class\r\n */\r\n hasClass(className: string): boolean {\r\n return this.element.classList.contains(className);\r\n }\r\n\r\n /**\r\n * Shows the element by removing the hidden attribute and setting display.\r\n *\r\n * @param display - Optional display value (default: '')\r\n * @returns The instance for method chaining\r\n */\r\n show(display: string = ''): this {\r\n this.element.removeAttribute('hidden');\r\n (this.element as HTMLElement).style.display = display;\r\n return this;\r\n }\r\n\r\n /**\r\n * Hides the element by setting display to 'none'.\r\n *\r\n * @returns The instance for method chaining\r\n */\r\n hide(): this {\r\n (this.element as HTMLElement).style.display = 'none';\r\n return this;\r\n }\r\n\r\n /**\r\n * Toggles the visibility of the element.\r\n *\r\n * @param force - Optional force show (true) or hide (false)\r\n * @returns The instance for method chaining\r\n */\r\n toggle(force?: boolean): this {\r\n const isHidden = (this.element as HTMLElement).style.display === 'none';\r\n const shouldShow = force ?? isHidden;\r\n return shouldShow ? this.show() : this.hide();\r\n }\r\n\r\n /**\r\n * Focuses the element.\r\n *\r\n * @returns The instance for method chaining\r\n */\r\n focus(): this {\r\n (this.element as HTMLElement).focus();\r\n return this;\r\n }\r\n\r\n /**\r\n * Blurs (unfocuses) the element.\r\n *\r\n * @returns The instance for method chaining\r\n */\r\n blur(): this {\r\n (this.element as HTMLElement).blur();\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets or sets the value of form elements.\r\n *\r\n * @param newValue - Optional value to set\r\n * @returns The current value when getting, or the instance when setting\r\n */\r\n val(newValue?: string): string | this {\r\n const input = this.element as HTMLInputElement;\r\n if (newValue === undefined) {\r\n return input.value ?? '';\r\n }\r\n input.value = newValue;\r\n return this;\r\n }\r\n\r\n /**\r\n * Serializes form data to a plain object.\r\n * Only works on form elements; returns empty object for non-forms.\r\n *\r\n * @returns Object with form field names as keys and values\r\n *\r\n * @example\r\n * ```ts\r\n * // For a form with <input name=\"email\" value=\"test@example.com\">\r\n * const data = $('#myForm').serialize();\r\n * // { email: 'test@example.com' }\r\n * ```\r\n */\r\n serialize(): Record<string, string | string[]> {\r\n const form = this.element as HTMLFormElement;\r\n if (form.tagName.toLowerCase() !== 'form') {\r\n return {};\r\n }\r\n\r\n const result: Record<string, string | string[]> = {};\r\n const formData = new FormData(form);\r\n\r\n for (const [key, value] of formData.entries()) {\r\n if (typeof value !== 'string') continue; // Skip File objects\r\n\r\n if (key in result) {\r\n // Handle multiple values (e.g., checkboxes)\r\n const existing = result[key];\r\n if (Array.isArray(existing)) {\r\n existing.push(value);\r\n } else {\r\n result[key] = [existing, value];\r\n }\r\n } else {\r\n result[key] = value;\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Serializes form data to a URL-encoded query string.\r\n *\r\n * @returns URL-encoded string suitable for form submission\r\n *\r\n * @example\r\n * ```ts\r\n * const queryString = $('#myForm').serializeString();\r\n * // 'email=test%40example.com&name=John'\r\n * ```\r\n */\r\n serializeString(): string {\r\n const form = this.element as HTMLFormElement;\r\n if (form.tagName.toLowerCase() !== 'form') {\r\n return '';\r\n }\r\n\r\n const formData = new FormData(form);\r\n const params = new URLSearchParams();\r\n\r\n for (const [key, value] of formData.entries()) {\r\n if (typeof value === 'string') {\r\n params.append(key, value);\r\n }\r\n }\r\n\r\n return params.toString();\r\n }\r\n\r\n /**\r\n * Gets the bounding client rectangle of the element.\r\n *\r\n * @returns The element's bounding rectangle\r\n */\r\n rect(): DOMRect {\r\n return this.element.getBoundingClientRect();\r\n }\r\n\r\n /**\r\n * Gets the offset dimensions (width, height, top, left).\r\n *\r\n * @returns Object with offset dimensions\r\n */\r\n offset(): { width: number; height: number; top: number; left: number } {\r\n const el = this.element as HTMLElement;\r\n return {\r\n width: el.offsetWidth,\r\n height: el.offsetHeight,\r\n top: el.offsetTop,\r\n left: el.offsetLeft,\r\n };\r\n }\r\n\r\n /**\r\n * Internal method to insert content at a specified position.\r\n * @internal\r\n */\r\n private insertContent(content: string | Element | Element[], position: InsertPosition) {\r\n insertContent(this.element, content, position);\r\n }\r\n}\r\n","import {\r\n createElementFromHtml,\r\n insertContent,\r\n sanitizeContent,\r\n type InsertableContent,\r\n} from './dom';\r\nimport { BQueryElement } from './element';\r\nimport { applyAll, toElementList } from './shared';\r\n\r\n/** Handler signature for delegated events */\r\ntype DelegatedHandler = (event: Event, target: Element) => void;\r\n\r\n/**\r\n * Wrapper for multiple DOM elements.\r\n * Provides batch operations on a collection of elements with chainable API.\r\n *\r\n * This class enables jQuery-like operations across multiple elements:\r\n * - All mutating methods apply to every element in the collection\r\n * - Getter methods return data from the first element\r\n * - Supports iteration via forEach, map, filter, and reduce\r\n *\r\n * @example\r\n * ```ts\r\n * $$('.items')\r\n * .addClass('highlight')\r\n * .css({ opacity: '0.8' })\r\n * .on('click', () => console.log('clicked'));\r\n * ```\r\n */\r\nexport class BQueryCollection {\r\n /**\r\n * Stores delegated event handlers for cleanup via undelegate().\r\n * Outer map: element -> (key -> (handler -> wrapper))\r\n * Key format: `${event}:${selector}`\r\n * @internal\r\n */\r\n private readonly delegatedHandlers = new WeakMap<\r\n Element,\r\n Map<string, Map<DelegatedHandler, EventListener>>\r\n >();\r\n\r\n /**\r\n * Creates a new collection wrapper.\r\n * @param elements - Array of DOM elements to wrap\r\n */\r\n constructor(public readonly elements: Element[]) {}\r\n\r\n /**\r\n * Gets the number of elements in the collection.\r\n */\r\n get length(): number {\r\n return this.elements.length;\r\n }\r\n\r\n /**\r\n * Gets the first element in the collection, if any.\r\n * @internal\r\n */\r\n private first(): Element | undefined {\r\n return this.elements[0];\r\n }\r\n\r\n /**\r\n * Gets a single element as a BQueryElement wrapper.\r\n *\r\n * @param index - Zero-based index of the element\r\n * @returns BQueryElement wrapper or undefined if out of range\r\n */\r\n eq(index: number): BQueryElement | undefined {\r\n const el = this.elements[index];\r\n return el ? new BQueryElement(el) : undefined;\r\n }\r\n\r\n /**\r\n * Gets the first element as a BQueryElement wrapper.\r\n *\r\n * @returns BQueryElement wrapper or undefined if empty\r\n */\r\n firstEl(): BQueryElement | undefined {\r\n return this.eq(0);\r\n }\r\n\r\n /**\r\n * Gets the last element as a BQueryElement wrapper.\r\n *\r\n * @returns BQueryElement wrapper or undefined if empty\r\n */\r\n lastEl(): BQueryElement | undefined {\r\n return this.eq(this.elements.length - 1);\r\n }\r\n\r\n /**\r\n * Iterates over each element in the collection.\r\n *\r\n * @param callback - Function to call for each wrapped element\r\n * @returns The instance for method chaining\r\n */\r\n each(callback: (element: BQueryElement, index: number) => void): this {\r\n this.elements.forEach((element, index) => {\r\n callback(new BQueryElement(element), index);\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps each element to a new value.\r\n *\r\n * @param callback - Function to transform each element\r\n * @returns Array of transformed values\r\n */\r\n map<T>(callback: (element: Element, index: number) => T): T[] {\r\n return this.elements.map(callback);\r\n }\r\n\r\n /**\r\n * Filters elements based on a predicate.\r\n *\r\n * @param predicate - Function to test each element\r\n * @returns New BQueryCollection with matching elements\r\n */\r\n filter(predicate: (element: Element, index: number) => boolean): BQueryCollection {\r\n return new BQueryCollection(this.elements.filter(predicate));\r\n }\r\n\r\n /**\r\n * Reduces the collection to a single value.\r\n *\r\n * @param callback - Reducer function\r\n * @param initialValue - Initial accumulator value\r\n * @returns Accumulated result\r\n */\r\n reduce<T>(callback: (accumulator: T, element: Element, index: number) => T, initialValue: T): T {\r\n return this.elements.reduce(callback, initialValue);\r\n }\r\n\r\n /**\r\n * Converts the collection to an array of BQueryElement wrappers.\r\n *\r\n * @returns Array of BQueryElement instances\r\n */\r\n toArray(): BQueryElement[] {\r\n return this.elements.map((el) => new BQueryElement(el));\r\n }\r\n\r\n /** Add one or more classes to all elements. */\r\n addClass(...classNames: string[]): this {\r\n applyAll(this.elements, (el) => el.classList.add(...classNames));\r\n return this;\r\n }\r\n\r\n /** Remove one or more classes from all elements. */\r\n removeClass(...classNames: string[]): this {\r\n applyAll(this.elements, (el) => el.classList.remove(...classNames));\r\n return this;\r\n }\r\n\r\n /** Toggle a class on all elements. */\r\n toggleClass(className: string, force?: boolean): this {\r\n applyAll(this.elements, (el) => el.classList.toggle(className, force));\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets an attribute on all elements or gets from first.\r\n *\r\n * @param name - Attribute name\r\n * @param value - Value to set (optional)\r\n * @returns Attribute value when getting, instance when setting\r\n */\r\n attr(name: string, value?: string): string | this {\r\n if (value === undefined) {\r\n return this.first()?.getAttribute(name) ?? '';\r\n }\r\n applyAll(this.elements, (el) => el.setAttribute(name, value));\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes an attribute from all elements.\r\n *\r\n * @param name - Attribute name to remove\r\n * @returns The instance for method chaining\r\n */\r\n removeAttr(name: string): this {\r\n applyAll(this.elements, (el) => el.removeAttribute(name));\r\n return this;\r\n }\r\n\r\n /** Toggle an attribute on all elements. */\r\n toggleAttr(name: string, force?: boolean): this {\r\n applyAll(this.elements, (el) => {\r\n const hasAttr = el.hasAttribute(name);\r\n const shouldAdd = force ?? !hasAttr;\r\n if (shouldAdd) {\r\n el.setAttribute(name, '');\r\n } else {\r\n el.removeAttribute(name);\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets text content on all elements or gets from first.\r\n *\r\n * @param value - Text to set (optional)\r\n * @returns Text content when getting, instance when setting\r\n */\r\n text(value?: string): string | this {\r\n if (value === undefined) {\r\n return this.first()?.textContent ?? '';\r\n }\r\n applyAll(this.elements, (el) => {\r\n el.textContent = value;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets sanitized HTML on all elements or gets from first.\r\n *\r\n * @param value - HTML to set (optional, will be sanitized)\r\n * @returns HTML content when getting, instance when setting\r\n */\r\n html(value?: string): string | this {\r\n if (value === undefined) {\r\n return this.first()?.innerHTML ?? '';\r\n }\r\n const sanitized = sanitizeContent(value);\r\n applyAll(this.elements, (el) => {\r\n el.innerHTML = sanitized;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets HTML on all elements without sanitization.\r\n *\r\n * @param value - Raw HTML to set\r\n * @returns The instance for method chaining\r\n * @warning Bypasses XSS protection\r\n */\r\n htmlUnsafe(value: string): this {\r\n applyAll(this.elements, (el) => {\r\n el.innerHTML = value;\r\n });\r\n return this;\r\n }\r\n\r\n /** Append content to all elements. */\r\n append(content: InsertableContent): this {\r\n this.insertAll(content, 'beforeend');\r\n return this;\r\n }\r\n\r\n /** Prepend content to all elements. */\r\n prepend(content: InsertableContent): this {\r\n this.insertAll(content, 'afterbegin');\r\n return this;\r\n }\r\n\r\n /** Insert content before all elements. */\r\n before(content: InsertableContent): this {\r\n this.insertAll(content, 'beforebegin');\r\n return this;\r\n }\r\n\r\n /** Insert content after all elements. */\r\n after(content: InsertableContent): this {\r\n this.insertAll(content, 'afterend');\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets or sets CSS styles on all elements.\r\n * When getting, returns the computed style value from the first element.\r\n *\r\n * @param property - Property name or object of properties\r\n * @param value - Value when setting single property\r\n * @returns The computed style value when getting, instance when setting\r\n */\r\n css(property: string): string;\r\n css(property: string, value: string): this;\r\n css(property: Record<string, string>): this;\r\n css(property: string | Record<string, string>, value?: string): string | this {\r\n if (typeof property === 'string') {\r\n if (value !== undefined) {\r\n applyAll(this.elements, (el) => {\r\n (el as HTMLElement).style.setProperty(property, value);\r\n });\r\n return this;\r\n }\r\n const first = this.first();\r\n if (!first) {\r\n return '';\r\n }\r\n const view = first.ownerDocument?.defaultView;\r\n if (!view || typeof view.getComputedStyle !== 'function') {\r\n return '';\r\n }\r\n return view.getComputedStyle(first).getPropertyValue(property);\r\n }\r\n\r\n applyAll(this.elements, (el) => {\r\n for (const [key, val] of Object.entries(property)) {\r\n (el as HTMLElement).style.setProperty(key, val);\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /** Wrap each element with a wrapper element or tag. */\r\n wrap(wrapper: string | Element): this {\r\n this.elements.forEach((el, index) => {\r\n const wrapperEl =\r\n typeof wrapper === 'string'\r\n ? document.createElement(wrapper)\r\n : index === 0\r\n ? wrapper\r\n : (wrapper.cloneNode(true) as Element);\r\n el.parentNode?.insertBefore(wrapperEl, el);\r\n wrapperEl.appendChild(el);\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Remove the parent element of each element, keeping the elements in place.\r\n *\r\n * **Important**: This method unwraps ALL children of each parent element,\r\n * not just the elements in the collection. If you call `unwrap()` on a\r\n * collection containing only some children of a parent, all siblings will\r\n * also be unwrapped. This behavior is consistent with jQuery's `.unwrap()`.\r\n *\r\n * @returns The collection for chaining\r\n *\r\n * @example\r\n * ```ts\r\n * // HTML: <div><section><span>A</span><span>B</span></section></div>\r\n * const spans = $$('span');\r\n * spans.unwrap(); // Removes <section>, both spans move to <div>\r\n * // Result: <div><span>A</span><span>B</span></div>\r\n * ```\r\n */\r\n unwrap(): this {\r\n // Collect unique parent elements to avoid removing the same parent multiple times.\r\n const parents = new Set<Element>();\r\n for (const el of this.elements) {\r\n if (el.parentElement) {\r\n parents.add(el.parentElement);\r\n }\r\n }\r\n\r\n // Unwrap each parent once: move all children out, then remove the wrapper.\r\n parents.forEach((parent) => {\r\n const grandParent = parent.parentNode;\r\n if (!grandParent) return;\r\n\r\n while (parent.firstChild) {\r\n grandParent.insertBefore(parent.firstChild, parent);\r\n }\r\n\r\n parent.remove();\r\n });\r\n return this;\r\n }\r\n\r\n /** Replace each element with provided content. */\r\n replaceWith(content: string | Element): BQueryCollection {\r\n const replacements: Element[] = [];\r\n this.elements.forEach((el, index) => {\r\n const replacement =\r\n typeof content === 'string'\r\n ? createElementFromHtml(content)\r\n : index === 0\r\n ? content\r\n : (content.cloneNode(true) as Element);\r\n el.replaceWith(replacement);\r\n replacements.push(replacement);\r\n });\r\n return new BQueryCollection(replacements);\r\n }\r\n\r\n /**\r\n * Shows all elements.\r\n *\r\n * @param display - Optional display value (default: '')\r\n * @returns The instance for method chaining\r\n */\r\n show(display: string = ''): this {\r\n applyAll(this.elements, (el) => {\r\n el.removeAttribute('hidden');\r\n (el as HTMLElement).style.display = display;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Hides all elements.\r\n *\r\n * @returns The instance for method chaining\r\n */\r\n hide(): this {\r\n applyAll(this.elements, (el) => {\r\n (el as HTMLElement).style.display = 'none';\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds an event listener to all elements.\r\n *\r\n * @param event - Event type\r\n * @param handler - Event handler\r\n * @returns The instance for method chaining\r\n */\r\n on(event: string, handler: EventListenerOrEventListenerObject): this {\r\n applyAll(this.elements, (el) => el.addEventListener(event, handler));\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a one-time event listener to all elements.\r\n *\r\n * @param event - Event type\r\n * @param handler - Event handler\r\n * @returns The instance for method chaining\r\n */\r\n once(event: string, handler: EventListener): this {\r\n applyAll(this.elements, (el) => el.addEventListener(event, handler, { once: true }));\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes an event listener from all elements.\r\n *\r\n * @param event - Event type\r\n * @param handler - The handler to remove\r\n * @returns The instance for method chaining\r\n */\r\n off(event: string, handler: EventListenerOrEventListenerObject): this {\r\n applyAll(this.elements, (el) => el.removeEventListener(event, handler));\r\n return this;\r\n }\r\n\r\n /**\r\n * Triggers a custom event on all elements.\r\n *\r\n * @param event - Event type\r\n * @param detail - Optional event detail\r\n * @returns The instance for method chaining\r\n */\r\n trigger(event: string, detail?: unknown): this {\r\n applyAll(this.elements, (el) => {\r\n el.dispatchEvent(new CustomEvent(event, { detail, bubbles: true, cancelable: true }));\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a delegated event listener to all elements.\r\n * Events are delegated to matching descendants.\r\n *\r\n * Use `undelegate()` to remove the listener later.\r\n *\r\n * @param event - Event type to listen for\r\n * @param selector - CSS selector to match against event targets\r\n * @param handler - Event handler function\r\n * @returns The instance for method chaining\r\n *\r\n * @example\r\n * ```ts\r\n * const handler = (e, target) => console.log('Clicked:', target.textContent);\r\n * $$('.container').delegate('click', '.item', handler);\r\n *\r\n * // Later, remove the delegated listener:\r\n * $$('.container').undelegate('click', '.item', handler);\r\n * ```\r\n */\r\n delegate(\r\n event: string,\r\n selector: string,\r\n handler: (event: Event, target: Element) => void\r\n ): this {\r\n const key = `${event}:${selector}`;\r\n\r\n applyAll(this.elements, (el) => {\r\n const wrapper: EventListener = (e: Event) => {\r\n const target = (e.target as Element).closest(selector);\r\n if (target && el.contains(target)) {\r\n handler(e, target);\r\n }\r\n };\r\n\r\n // Get or create the handler maps for this element\r\n if (!this.delegatedHandlers.has(el)) {\r\n this.delegatedHandlers.set(el, new Map());\r\n }\r\n const elementHandlers = this.delegatedHandlers.get(el)!;\r\n\r\n if (!elementHandlers.has(key)) {\r\n elementHandlers.set(key, new Map());\r\n }\r\n elementHandlers.get(key)!.set(handler, wrapper);\r\n\r\n el.addEventListener(event, wrapper);\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a delegated event listener previously added with `delegate()`.\r\n *\r\n * @param event - Event type that was registered\r\n * @param selector - CSS selector that was used\r\n * @param handler - The original handler function passed to delegate()\r\n * @returns The instance for method chaining\r\n *\r\n * @example\r\n * ```ts\r\n * const handler = (e, target) => console.log('Clicked:', target.textContent);\r\n * $$('.container').delegate('click', '.item', handler);\r\n *\r\n * // Remove the delegated listener:\r\n * $$('.container').undelegate('click', '.item', handler);\r\n * ```\r\n */\r\n undelegate(\r\n event: string,\r\n selector: string,\r\n handler: (event: Event, target: Element) => void\r\n ): this {\r\n const key = `${event}:${selector}`;\r\n\r\n applyAll(this.elements, (el) => {\r\n const elementHandlers = this.delegatedHandlers.get(el);\r\n if (!elementHandlers) return;\r\n\r\n const handlers = elementHandlers.get(key);\r\n if (!handlers) return;\r\n\r\n const wrapper = handlers.get(handler);\r\n if (wrapper) {\r\n el.removeEventListener(event, wrapper);\r\n handlers.delete(handler);\r\n\r\n // Clean up empty maps\r\n if (handlers.size === 0) {\r\n elementHandlers.delete(key);\r\n }\r\n if (elementHandlers.size === 0) {\r\n this.delegatedHandlers.delete(el);\r\n }\r\n }\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Finds all descendant elements matching the selector across all elements\r\n * in the collection. Returns a new BQueryCollection with the results.\r\n *\r\n * @param selector - CSS selector to match\r\n * @returns A new BQueryCollection with all matching descendants\r\n *\r\n * @example\r\n * ```ts\r\n * $$('.container').find('.item').addClass('highlight');\r\n * ```\r\n */\r\n find(selector: string): BQueryCollection {\r\n const seen = new Set<Element>();\r\n const results: Element[] = [];\r\n for (const el of this.elements) {\r\n const found = el.querySelectorAll(selector);\r\n for (let i = 0; i < found.length; i++) {\r\n if (!seen.has(found[i])) {\r\n seen.add(found[i]);\r\n results.push(found[i]);\r\n }\r\n }\r\n }\r\n return new BQueryCollection(results);\r\n }\r\n\r\n /**\r\n * Removes all elements from the DOM.\r\n *\r\n * @returns The instance for method chaining\r\n */\r\n remove(): this {\r\n applyAll(this.elements, (el) => el.remove());\r\n return this;\r\n }\r\n\r\n /**\r\n * Clears all child nodes from all elements.\r\n *\r\n * @returns The instance for method chaining\r\n */\r\n empty(): this {\r\n applyAll(this.elements, (el) => {\r\n el.innerHTML = '';\r\n });\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private insertAll(content: InsertableContent, position: InsertPosition): void {\r\n if (typeof content === 'string') {\r\n // Sanitize once and reuse for all elements\r\n const sanitized = sanitizeContent(content);\r\n applyAll(this.elements, (el) => {\r\n el.insertAdjacentHTML(position, sanitized);\r\n });\r\n return;\r\n }\r\n\r\n const elements = toElementList(content);\r\n this.elements.forEach((el, index) => {\r\n const nodes =\r\n index === 0 ? elements : elements.map((node) => node.cloneNode(true) as Element);\r\n insertContent(el, nodes, position);\r\n });\r\n }\r\n}\r\n","import { BQueryCollection } from './collection';\nimport { BQueryElement } from './element';\n\n/**\n * Select a single element. Returns a wrapper for chainable operations.\n */\nexport const $ = (selector: string | Element): BQueryElement => {\n if (typeof selector !== 'string') {\n return new BQueryElement(selector);\n }\n const element = document.querySelector(selector);\n if (!element) {\n throw new Error(`bQuery: element not found for selector \"${selector}\"`);\n }\n return new BQueryElement(element);\n};\n\n/**\n * Select multiple elements. Returns a collection wrapper.\n */\nexport const $$ = (selector: string | Element[] | NodeListOf<Element>): BQueryCollection => {\n if (Array.isArray(selector)) {\n return new BQueryCollection(selector);\n }\n if (selector instanceof NodeList) {\n return new BQueryCollection(Array.from(selector));\n }\n return new BQueryCollection(Array.from(document.querySelectorAll(selector)));\n};\n","/**\n * Array-focused utility helpers.\n *\n * @module bquery/core/utils/array\n */\n\n/**\n * Ensures the input is always returned as an array.\n *\n * @template T - The item type\n * @param value - A single value, array, or nullish value\n * @returns An array (empty if nullish)\n *\n * @example\n * ```ts\n * ensureArray('a'); // ['a']\n * ensureArray(['a', 'b']); // ['a', 'b']\n * ensureArray(null); // []\n * ```\n */\nexport function ensureArray<T>(value: T | T[] | null | undefined): T[] {\n if (value == null) return [];\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Removes duplicate entries from an array.\n *\n * @template T - The item type\n * @param items - The array to deduplicate\n * @returns A new array with unique items\n *\n * @example\n * ```ts\n * unique([1, 2, 2, 3]); // [1, 2, 3]\n * ```\n */\nexport function unique<T>(items: T[]): T[] {\n return Array.from(new Set(items));\n}\n\n/**\n * Splits an array into chunks of a given size.\n *\n * @template T - The item type\n * @param items - The array to chunk\n * @param size - The maximum size of each chunk\n * @returns An array of chunks\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]]\n * ```\n */\nexport function chunk<T>(items: T[], size: number): T[][] {\n if (size <= 0) return [];\n const result: T[][] = [];\n for (let i = 0; i < items.length; i += size) {\n result.push(items.slice(i, i + size));\n }\n return result;\n}\n\n/**\n * Removes falsy values from an array.\n *\n * @template T - The item type\n * @param items - The array to compact\n * @returns A new array without falsy values\n *\n * @example\n * ```ts\n * compact([0, 1, '', 'ok', null]); // [1, 'ok']\n * ```\n */\nexport function compact<T>(items: Array<T | null | undefined | false | 0 | ''>): T[] {\n return items.filter(Boolean) as T[];\n}\n\n/**\n * Flattens a single level of nested arrays.\n *\n * @template T - The item type\n * @param items - The array to flatten\n * @returns A new flattened array\n *\n * @example\n * ```ts\n * flatten([1, [2, 3], 4]); // [1, 2, 3, 4]\n * ```\n */\nexport function flatten<T>(items: Array<T | T[]>): T[] {\n const result: T[] = [];\n for (const item of items) {\n if (Array.isArray(item)) {\n result.push(...item);\n } else {\n result.push(item);\n }\n }\n return result;\n}\n","/**\r\n * Function-focused utility helpers.\r\n *\r\n * @module bquery/core/utils/function\r\n */\r\n\r\n/** A debounced function with a cancel method to clear the pending timeout. */\r\nexport interface DebouncedFn<TArgs extends unknown[]> {\r\n (...args: TArgs): void;\r\n /** Cancels the pending debounced invocation. */\r\n cancel(): void;\r\n}\r\n\r\n/** A throttled function with a cancel method to reset the throttle timer. */\r\nexport interface ThrottledFn<TArgs extends unknown[]> {\r\n (...args: TArgs): void;\r\n /** Resets the throttle timer, allowing the next call to execute immediately. */\r\n cancel(): void;\r\n}\r\n\r\n/**\r\n * Creates a debounced function that delays execution until after\r\n * the specified delay has elapsed since the last call.\r\n *\r\n * @template TArgs - The argument types of the function\r\n * @param fn - The function to debounce\r\n * @param delayMs - Delay in milliseconds\r\n * @returns A debounced version of the function with a `cancel()` method\r\n *\r\n * @example\r\n * ```ts\r\n * const search = debounce((query: string) => {\r\n * console.log('Searching:', query);\r\n * }, 300);\r\n *\r\n * search('h');\r\n * search('he');\r\n * search('hello'); // Only this call executes after 300ms\r\n *\r\n * search('cancel me');\r\n * search.cancel(); // Cancels the pending invocation\r\n * ```\r\n */\r\nexport function debounce<TArgs extends unknown[]>(\r\n fn: (...args: TArgs) => void,\r\n delayMs: number\r\n): DebouncedFn<TArgs> {\r\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\r\n const debounced: DebouncedFn<TArgs> = Object.assign(\r\n (...args: TArgs) => {\r\n if (timeoutId !== undefined) {\r\n clearTimeout(timeoutId);\r\n }\r\n timeoutId = setTimeout(() => {\r\n timeoutId = undefined;\r\n fn(...args);\r\n }, delayMs);\r\n },\r\n {\r\n cancel: () => {\r\n if (timeoutId !== undefined) {\r\n clearTimeout(timeoutId);\r\n timeoutId = undefined;\r\n }\r\n },\r\n }\r\n );\r\n return debounced;\r\n}\r\n\r\n/**\r\n * Creates a throttled function that runs at most once per interval.\r\n *\r\n * @template TArgs - The argument types of the function\r\n * @param fn - The function to throttle\r\n * @param intervalMs - Minimum interval between calls in milliseconds\r\n * @returns A throttled version of the function with a `cancel()` method\r\n *\r\n * @example\r\n * ```ts\r\n * const handleScroll = throttle(() => {\r\n * console.log('Scroll position:', window.scrollY);\r\n * }, 100);\r\n *\r\n * window.addEventListener('scroll', handleScroll);\r\n *\r\n * handleScroll.cancel(); // Resets throttle, next call executes immediately\r\n * ```\r\n */\r\nexport function throttle<TArgs extends unknown[]>(\r\n fn: (...args: TArgs) => void,\r\n intervalMs: number\r\n): ThrottledFn<TArgs> {\r\n let lastRun = 0;\r\n const throttled: ThrottledFn<TArgs> = Object.assign(\r\n (...args: TArgs) => {\r\n const now = Date.now();\r\n if (now - lastRun >= intervalMs) {\r\n lastRun = now;\r\n fn(...args);\r\n }\r\n },\r\n {\r\n cancel: () => {\r\n lastRun = 0;\r\n },\r\n }\r\n );\r\n return throttled;\r\n}\r\n\r\n/**\r\n * Ensures a function only runs once. Subsequent calls return the first result.\r\n *\r\n * @template TArgs - The argument types of the function\r\n * @template TResult - The return type of the function\r\n * @param fn - The function to wrap\r\n * @returns A function that only runs once\r\n *\r\n * @example\r\n * ```ts\r\n * const init = once(() => ({ ready: true }));\r\n * init();\r\n * init(); // only runs once\r\n * ```\r\n */\r\nexport function once<TArgs extends unknown[], TResult>(\r\n fn: (...args: TArgs) => TResult\r\n): (...args: TArgs) => TResult {\r\n let hasRun = false;\r\n let result!: TResult;\r\n return (...args: TArgs) => {\r\n if (!hasRun) {\r\n result = fn(...args);\r\n hasRun = true;\r\n }\r\n return result;\r\n };\r\n}\r\n\r\n/**\r\n * A no-operation function.\r\n *\r\n * @example\r\n * ```ts\r\n * noop();\r\n * ```\r\n */\r\nexport function noop(): void {\r\n // Intentionally empty\r\n}\r\n","/**\n * Miscellaneous utility helpers.\n *\n * @module bquery/core/utils/misc\n */\n\n/**\n * Creates a stable unique ID for DOM usage.\n *\n * @param prefix - Optional prefix for the ID (default: 'bQuery')\n * @returns A unique identifier string\n *\n * @example\n * ```ts\n * const id = uid('modal'); // 'modal_x7k2m9p'\n * ```\n */\nexport function uid(prefix = 'bQuery'): string {\n return `${prefix}_${Math.random().toString(36).slice(2, 9)}`;\n}\n\n/**\n * Delays execution for a specified number of milliseconds.\n *\n * @param ms - Milliseconds to delay\n * @returns A promise that resolves after the delay\n *\n * @example\n * ```ts\n * await sleep(1000); // Wait 1 second\n * console.log('Done!');\n * ```\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Safely parses a JSON string, returning a default value on error.\n *\n * @template T - The expected type of the parsed value\n * @param json - The JSON string to parse\n * @param fallback - The default value if parsing fails\n * @returns The parsed value or the fallback\n *\n * @example\n * ```ts\n * parseJson('{\"name\":\"bQuery\"}', {}); // { name: 'bQuery' }\n * parseJson('invalid', {}); // {}\n * ```\n */\nexport function parseJson<T>(json: string, fallback: T): T {\n try {\n return JSON.parse(json) as T;\n } catch {\n return fallback;\n }\n}\n\n/**\n * Checks for emptiness across common value types.\n *\n * @param value - The value to check\n * @returns True if the value is empty (null, undefined, empty string, empty array, or empty object)\n *\n * @example\n * ```ts\n * isEmpty(''); // true\n * isEmpty([]); // true\n * isEmpty({}); // true\n * isEmpty(null); // true\n * isEmpty('hello'); // false\n * isEmpty([1, 2]); // false\n * ```\n */\nexport function isEmpty(value: unknown): boolean {\n if (value == null) return true;\n if (typeof value === 'string') return value.trim().length === 0;\n if (Array.isArray(value)) return value.length === 0;\n if (typeof value === 'object') return Object.keys(value as object).length === 0;\n return false;\n}\n","/**\n * Number-focused utility helpers.\n *\n * @module bquery/core/utils/number\n */\n\n/**\n * Generates a random integer between min and max (inclusive).\n *\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns A random integer in the range [min, max]\n *\n * @example\n * ```ts\n * const roll = randomInt(1, 6); // Random dice roll\n * ```\n */\nexport function randomInt(min: number, max: number): number {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\n/**\n * Clamps a number between a minimum and maximum value.\n *\n * @param value - The value to clamp\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns The clamped value\n *\n * @example\n * ```ts\n * clamp(150, 0, 100); // 100\n * clamp(-10, 0, 100); // 0\n * clamp(50, 0, 100); // 50\n * ```\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Checks if a number is within a range.\n *\n * @param value - The value to check\n * @param min - Minimum value\n * @param max - Maximum value\n * @param inclusive - Whether the range is inclusive (default: true)\n * @returns True if the value is within the range\n *\n * @example\n * ```ts\n * inRange(5, 1, 10); // true\n * inRange(10, 1, 10, false); // false\n * ```\n */\nexport function inRange(value: number, min: number, max: number, inclusive = true): boolean {\n if (inclusive) return value >= min && value <= max;\n return value > min && value < max;\n}\n\n/**\n * Converts a value to a number with a fallback on NaN.\n *\n * @param value - The value to convert\n * @param fallback - The fallback value if conversion fails (default: 0)\n * @returns The parsed number or the fallback\n *\n * @example\n * ```ts\n * toNumber('42'); // 42\n * toNumber('nope', 10); // 10\n * ```\n */\nexport function toNumber(value: unknown, fallback = 0): number {\n const parsed = typeof value === 'number' ? value : Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n}\n","/**\n * Object-focused utility helpers.\n *\n * @module bquery/core/utils/object\n */\n\n/**\n * Checks if a value is a plain object (not null, array, or class instance).\n *\n * @param value - The value to check\n * @returns True if the value is a plain object\n */\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Checks if a key could cause prototype pollution.\n * These keys are dangerous when used in object merging operations.\n *\n * @param key - The key to check\n * @returns True if the key is a prototype pollution vector\n *\n * @internal\n */\nexport function isPrototypePollutionKey(key: string): boolean {\n return key === '__proto__' || key === 'constructor' || key === 'prototype';\n}\n\n/**\n * Creates a deep clone using structuredClone if available, otherwise fallback to JSON.\n *\n * @template T - The type of value being cloned\n * @param value - The value to clone\n * @returns A deep copy of the value\n *\n * @remarks\n * When `structuredClone` is available (modern browsers, Node 17+, Bun), this function\n * provides full deep cloning including circular references, Date, Map, Set, ArrayBuffer, etc.\n *\n * **JSON fallback limitations** (older environments without `structuredClone`):\n * - **Throws** on circular references\n * - **Drops** functions, `undefined`, and Symbol properties\n * - **Transforms** Date → ISO string, Map/Set → empty object, BigInt → throws\n * - **Loses** prototype chains and non-enumerable properties\n *\n * For guaranteed safe cloning of arbitrary data, ensure your environment supports\n * `structuredClone` or pre-validate your data structure.\n *\n * @example\n * ```ts\n * const original = { nested: { value: 1 } };\n * const copy = clone(original);\n * copy.nested.value = 2;\n * console.log(original.nested.value); // 1\n * ```\n */\nexport function clone<T>(value: T): T {\n if (typeof structuredClone === 'function') {\n return structuredClone(value);\n }\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\n/**\n * Deep-merges plain objects into a new object.\n * Later sources override earlier ones for primitive values.\n * Objects are recursively merged.\n *\n * @param sources - Objects to merge\n * @returns A new object with all sources merged as an intersection type\n *\n * @remarks\n * This function uses overloads to provide accurate intersection types for up to 5 sources.\n * For more than 5 sources, the return type falls back to `Record<string, unknown>`.\n *\n * Note that deep merging creates a shallow intersection at the type level. Nested objects\n * are merged at runtime, but TypeScript sees them as intersected types which may not\n * perfectly represent the merged structure for deeply nested conflicting types.\n *\n * @example\n * ```ts\n * const result = merge(\n * { a: 1, nested: { x: 1 } },\n * { b: 2, nested: { y: 2 } }\n * );\n * // Result: { a: 1, b: 2, nested: { x: 1, y: 2 } }\n * // Type: { a: number; nested: { x: number } } & { b: number; nested: { y: number } }\n * ```\n *\n * @security This method is protected against prototype pollution attacks.\n * Keys like `__proto__`, `constructor`, and `prototype` are ignored.\n */\nexport function merge<T1 extends Record<string, unknown>>(source1: T1): T1;\nexport function merge<T1 extends Record<string, unknown>, T2 extends Record<string, unknown>>(\n source1: T1,\n source2: T2\n): T1 & T2;\nexport function merge<\n T1 extends Record<string, unknown>,\n T2 extends Record<string, unknown>,\n T3 extends Record<string, unknown>,\n>(source1: T1, source2: T2, source3: T3): T1 & T2 & T3;\nexport function merge<\n T1 extends Record<string, unknown>,\n T2 extends Record<string, unknown>,\n T3 extends Record<string, unknown>,\n T4 extends Record<string, unknown>,\n>(source1: T1, source2: T2, source3: T3, source4: T4): T1 & T2 & T3 & T4;\nexport function merge<\n T1 extends Record<string, unknown>,\n T2 extends Record<string, unknown>,\n T3 extends Record<string, unknown>,\n T4 extends Record<string, unknown>,\n T5 extends Record<string, unknown>,\n>(source1: T1, source2: T2, source3: T3, source4: T4, source5: T5): T1 & T2 & T3 & T4 & T5;\nexport function merge(...sources: Record<string, unknown>[]): Record<string, unknown>;\nexport function merge(...sources: Record<string, unknown>[]): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source)) {\n if (isPrototypePollutionKey(key)) continue;\n\n if (isPlainObject(value) && isPlainObject(result[key])) {\n result[key] = merge(\n result[key] as Record<string, unknown>,\n value as Record<string, unknown>\n );\n } else {\n result[key] = value;\n }\n }\n }\n return result;\n}\n\n/**\n * Picks specified keys from an object.\n *\n * @template T - The object type\n * @template K - The key type\n * @param obj - The source object\n * @param keys - Keys to pick\n * @returns A new object with only the specified keys\n *\n * @example\n * ```ts\n * const user = { name: 'John', age: 30, email: 'john@example.com' };\n * pick(user, ['name', 'email']); // { name: 'John', email: 'john@example.com' }\n * ```\n */\nexport function pick<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Pick<T, K> {\n const result = {} as Pick<T, K>;\n for (const key of keys) {\n if (key in obj) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n\n/**\n * Omits specified keys from an object.\n *\n * @template T - The object type\n * @template K - The key type\n * @param obj - The source object\n * @param keys - Keys to omit\n * @returns A new object without the specified keys\n *\n * @example\n * ```ts\n * const user = { name: 'John', age: 30, password: 'secret' };\n * omit(user, ['password']); // { name: 'John', age: 30 }\n * ```\n */\nexport function omit<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Omit<T, K> {\n const result = { ...obj };\n for (const key of keys) {\n delete result[key];\n }\n return result as Omit<T, K>;\n}\n\n/**\n * Checks if an object has a given own property.\n *\n * @template T - The object type\n * @param obj - The object to check\n * @param key - The property key\n * @returns True if the property exists on the object\n *\n * @example\n * ```ts\n * hasOwn({ a: 1 }, 'a'); // true\n * ```\n */\nexport function hasOwn<T extends object>(obj: T, key: PropertyKey): key is keyof T {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n","/**\n * String-focused utility helpers.\n *\n * @module bquery/core/utils/string\n */\n\n/**\n * Capitalizes the first letter of a string.\n *\n * @param str - The string to capitalize\n * @returns The capitalized string\n *\n * @example\n * ```ts\n * capitalize('hello'); // 'Hello'\n * ```\n */\nexport function capitalize(str: string): string {\n if (!str) return str;\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Converts a string to kebab-case.\n *\n * @param str - The string to convert\n * @returns The kebab-cased string\n *\n * @example\n * ```ts\n * toKebabCase('myVariableName'); // 'my-variable-name'\n * ```\n */\nexport function toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .toLowerCase();\n}\n\n/**\n * Converts a string to camelCase.\n *\n * @param str - The string to convert\n * @returns The camelCased string\n *\n * @example\n * ```ts\n * toCamelCase('my-variable-name'); // 'myVariableName'\n * ```\n */\nexport function toCamelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, char) => (char ? char.toUpperCase() : ''))\n .replace(/^[A-Z]/, (char) => char.toLowerCase());\n}\n\n/**\n * Truncates a string to a maximum length.\n *\n * @param str - The string to truncate\n * @param maxLength - The maximum length\n * @param suffix - The suffix to append when truncating (default: '…')\n * @returns The truncated string\n *\n * @example\n * ```ts\n * truncate('Hello world', 8); // 'Hello w…'\n * ```\n */\nexport function truncate(str: string, maxLength: number, suffix = '…'): string {\n if (maxLength <= 0) return '';\n if (str.length <= maxLength) return str;\n const sliceLength = Math.max(0, maxLength - suffix.length);\n return `${str.slice(0, sliceLength)}${suffix}`;\n}\n\n/**\n * Converts a string to a URL-friendly slug.\n *\n * @param str - The string to slugify\n * @returns The slugified string\n *\n * @example\n * ```ts\n * slugify('Hello, World!'); // 'hello-world'\n * ```\n */\nexport function slugify(str: string): string {\n return str\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .replace(/[^\\w\\s-]/g, '')\n .trim()\n .replace(/[\\s_-]+/g, '-')\n .toLowerCase();\n}\n\n/**\n * Escapes a string for safe usage inside a RegExp.\n *\n * @param str - The string to escape\n * @returns The escaped string\n *\n * @example\n * ```ts\n * escapeRegExp('[a-z]+'); // '\\\\[a-z\\\\]+'\n * ```\n */\nexport function escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","/**\n * Type guard helpers.\n *\n * @module bquery/core/utils/type-guards\n */\n\n/**\n * Checks if a value is a DOM Element.\n *\n * @param value - The value to check\n * @returns True if the value is an Element\n */\nexport function isElement(value: unknown): value is Element {\n return typeof Element !== 'undefined' && value instanceof Element;\n}\n\n/**\n * Checks if a value is a BQueryCollection-like object.\n *\n * @param value - The value to check\n * @returns True if the value has an elements array property\n */\nexport function isCollection(value: unknown): value is { elements: Element[] } {\n return Boolean(value && typeof value === 'object' && 'elements' in (value as object));\n}\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check\n * @returns True if the value is a function\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check\n * @returns True if the value is a string\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Checks if a value is a number (excluding NaN).\n *\n * @param value - The value to check\n * @returns True if the value is a valid number\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value);\n}\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check\n * @returns True if the value is a boolean\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if a value is an array.\n *\n * @template T - The type of array elements\n * @param value - The value to check\n * @returns True if the value is an array\n */\nexport function isArray<T = unknown>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Checks if a value is a Date instance.\n *\n * @param value - The value to check\n * @returns True if the value is a Date\n */\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\n/**\n * Checks if a value is a Promise-like object.\n *\n * @param value - The value to check\n * @returns True if the value is a Promise-like object\n */\nexport function isPromise<T = unknown>(value: unknown): value is Promise<T> {\n return Boolean(\n value &&\n (value instanceof Promise ||\n (typeof value === 'object' &&\n 'then' in (value as object) &&\n typeof (value as { then?: unknown }).then === 'function'))\n );\n}\n\n/**\n * Checks if a value is a non-null object.\n *\n * @param value - The value to check\n * @returns True if the value is an object\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n","/**\n * Utility helpers used across the framework.\n * These are intentionally small and framework-agnostic to keep the core tiny.\n *\n * @module bquery/core/utils\n */\n\nexport * from './array';\nexport * from './function';\nexport * from './misc';\nexport * from './number';\nexport * from './object';\nexport * from './string';\nexport * from './type-guards';\n\nimport { chunk, compact, ensureArray, flatten, unique } from './array';\nimport { debounce, noop, once, throttle } from './function';\nimport { isEmpty, parseJson, sleep, uid } from './misc';\nimport { clamp, inRange, randomInt, toNumber } from './number';\nimport { clone, hasOwn, isPlainObject, merge, omit, pick } from './object';\nimport { capitalize, escapeRegExp, slugify, toCamelCase, toKebabCase, truncate } from './string';\nimport {\n isArray,\n isBoolean,\n isCollection,\n isDate,\n isElement,\n isFunction,\n isNumber,\n isObject,\n isPromise,\n isString,\n} from './type-guards';\n\n/**\n * Utility object containing common helper functions.\n * All utilities are designed to be tree-shakeable and have zero dependencies.\n *\n * Note: `isPrototypePollutionKey` is intentionally excluded from this namespace\n * as it is an internal security helper. It remains available as a named export\n * for internal framework use.\n */\nexport const utils = {\n clone,\n merge,\n pick,\n omit,\n hasOwn,\n debounce,\n throttle,\n once,\n noop,\n uid,\n isElement,\n isCollection,\n isEmpty,\n isPlainObject,\n isFunction,\n isString,\n isNumber,\n isBoolean,\n isArray,\n isDate,\n isPromise,\n isObject,\n parseJson,\n sleep,\n randomInt,\n clamp,\n inRange,\n toNumber,\n capitalize,\n toKebabCase,\n toCamelCase,\n truncate,\n slugify,\n escapeRegExp,\n ensureArray,\n unique,\n chunk,\n compact,\n flatten,\n};\n"],"names":["toElementList","input","applyAll","elements","action","el","sanitizeContent","html","sanitizeHtml","setHtml","element","createElementFromHtml","template","insertContent","target","content","position","orderedElements","BQueryElement","classNames","className","force","name","value","hasAttr","key","match","property","view","val","wrapper","wrapperEl","parent","newEl","options","deep","selector","child","event","handler","detail","e","handlers","display","isHidden","newValue","form","result","formData","existing","params","BQueryCollection","index","callback","predicate","initialValue","sanitized","first","parents","grandParent","replacements","replacement","elementHandlers","seen","results","found","i","nodes","node","$","$$","ensureArray","unique","items","chunk","size","compact","flatten","item","debounce","fn","delayMs","timeoutId","args","throttle","intervalMs","lastRun","now","once","hasRun","noop","uid","prefix","sleep","ms","resolve","parseJson","json","fallback","isEmpty","randomInt","min","max","clamp","inRange","inclusive","toNumber","parsed","isPlainObject","isPrototypePollutionKey","clone","merge","sources","source","pick","obj","keys","omit","hasOwn","capitalize","str","toKebabCase","toCamelCase","_","char","truncate","maxLength","suffix","sliceLength","slugify","escapeRegExp","isElement","isCollection","isFunction","isString","isNumber","isBoolean","isArray","isDate","isPromise","isObject","utils"],"mappings":";AAKO,MAAMA,IAAgB,CAACC,MAC5B,MAAM,QAAQA,CAAK,IAAIA,IAAQ,CAACA,CAAK,GAE1BC,IAAW,CAACC,GAAuBC,MAAkC;AAChF,aAAWC,KAAMF;AACf,IAAAC,EAAOC,CAAE;AAEb,GCPaC,IAAkB,CAACC,MAAyBC,EAAaD,CAAI,GAE7DE,IAAU,CAACC,GAAkBH,MAAuB;AAC/D,EAAAG,EAAQ,YAAYF,EAAaD,CAAI;AACvC,GAEaI,IAAwB,CAACJ,MAA0B;AAC9D,QAAMK,IAAW,SAAS,cAAc,UAAU;AAClD,SAAAA,EAAS,YAAYJ,EAAaD,CAAI,GAC/BK,EAAS,QAAQ,qBAAqB,SAAS,cAAc,KAAK;AAC3E,GAEaC,IAAgB,CAC3BC,GACAC,GACAC,MACS;AACT,MAAI,OAAOD,KAAY,UAAU;AAC/B,IAAAD,EAAO,mBAAmBE,GAAUR,EAAa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AAAa;AAAA,EACA,aAAAE;AAAA,EACA,aAAAC;AAAA,EACA,UAAAG;AAAA,EACA,SAAAI;AAAA,EACA,cAAAC;AAAA,EACA,aAAA3D;AAAA,EACA,QAAAC;AAAA,EACA,OAAAE;AAAA,EACA,SAAAE;AAAA,EACA,SAAAC;AACF;"}
package/dist/full.es.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  import { $ as s, $$ as a, BQueryCollection as r, BQueryElement as o, utils as i } from "./core.es.mjs";
2
- import { C as p, S as c, c as m, s as u } from "./core-COenAZjD.js";
3
- import { b as f } from "./batch-4LAvfLE7.js";
4
- import { e as d, i as x, a as S } from "./type-guards-DRma3-Kc.js";
5
- import { p as y, r as C, w as P } from "./watch-CXyaBC_9.js";
6
- import { u as T } from "./untrack-BuEQKH7_.js";
2
+ import { C as p, S as c, c as m, s as u } from "./core-BhpuvPhy.js";
3
+ import { b as f } from "./batch-x7b2eZST.js";
4
+ import { e as d, i as x, a as S } from "./type-guards-BdKlYYlS.js";
5
+ import { p as y, r as C, w as P } from "./watch-DXXv3iAI.js";
6
+ import { u as T } from "./untrack-DNnnqdlR.js";
7
7
  import { component as h, html as v, safeHtml as Q } from "./component.es.mjs";
8
8
  import { animate as H, capturePosition as I, easeInCubic as w, easeInOutCubic as B, easeInOutQuad as E, easeInQuad as R, easeOutBack as $, easeOutCubic as z, easeOutExpo as L, easeOutQuad as q, easingPresets as D, flip as M, flipElements as N, flipList as j, keyframePresets as F, linear as G, prefersReducedMotion as J, scrollAnimate as K, sequence as U, spring as V, springPresets as W, stagger as X, timeline as Y, transition as Z } from "./motion.es.mjs";
9
9
  import { createTrustedHtml as ee, generateNonce as te, getTrustedTypesPolicy as se, hasCSPDirective as ae, isTrustedTypesSupported as re } from "./security.es.mjs";
10
- import { e as ie, s as ne, s as pe, a as ce } from "./sanitize-1FBEPAFH.js";
10
+ import { e as ie, s as ne, s as pe, a as ce } from "./sanitize-Cxvxa-DX.js";
11
11
  import { buckets as ue, cache as le, notifications as fe, storage as ge } from "./platform.es.mjs";
12
12
  import { back as xe, createRouter as Se, currentRoute as be, forward as ye, interceptLinks as Ce, isActive as Pe, isActiveSignal as ke, link as Te, navigate as Oe, resolve as he } from "./router.es.mjs";
13
- import { c as Qe, a as Ae, d as He, g as Ie, l as we, m as Be, b as Ee, r as Re } from "./persisted-Dz_ryNuC.js";
13
+ import { c as Qe, a as Ae, d as He, g as Ie, l as we, m as Be, b as Ee, r as Re } from "./persisted-DHoi3uEs.js";
14
14
  import { createTemplate as ze, mount as Le } from "./view.es.mjs";
15
15
  export {
16
16
  s as $,