{"version":3,"file":"hybrids-helpers.umd.cjs","sources":["../src/events.ts","../src/utils.ts","../src/factories/disposable.ts","../src/factories/effect.ts","../src/factories/mo.ts","../src/factories/mouse.ts","../src/factories/reflect.ts","../src/factories/ro.ts","../src/refs/ref.ts","../src/refs/slotted.ts","../src/template/alpine/x-host.ts","../src/template/alpine/x-prop.ts","../src/template/alpine/alpine.ts","../src/template/hy.ts","../src/template/set.ts","../src/build.ts","../src/connect/connect.ts","../src/connect/listen.ts","../src/factories/getset.ts","../src/observe.ts","../src/template/light.ts","../src/template/render.ts"],"sourcesContent":["/**\n * dispatch a CustomEvent from the host element which bubbles and is composed\n * @category Events\n * @param host the host element\n * @param event the event name\n * @param detail the CustomEvent detail\n * @param init CustomEventInit options to override the defaults (bubbles, composed)\n * @returns void\n */\nexport function emit<T>(host: Element, event: string, detail?: T, init: CustomEventInit<any> = {}) {\n  const eventInit = { bubbles: true, composed: true, ...init }\n  if (detail) {\n    eventInit.detail = detail\n  }\n  host.dispatchEvent(new CustomEvent<T>(event, eventInit))\n}\n\n/**\n * wrap an event handler to stop propagation\n * @category Events\n * @param handler - the event handler to wrap\n * @returns a new event handler that stops propagation\n */\nexport const stop = <H extends HTMLElement, T = any>(handler: (host: H, e: CustomEvent<T>) => void) => {\n  return (host: H & HTMLElement, e: CustomEvent<T>) => {\n    e.stopPropagation()\n    handler(host, e)\n  }\n}\n\n/**\n * wrap an event handler to prevent the default action\n * @category Events\n * @param handler - the event handler to wrap\n * @returns a new event handler that prevents the default action\n */\nexport const prevent = <H, T = any>(handler: (host: H, e: CustomEvent<T>) => void) => {\n  return (host: H & HTMLElement, e: CustomEvent<T>) => {\n    e.preventDefault()\n    handler(host, e)\n  }\n}\n","import { Component, Descriptor, Property } from 'hybrids'\nexport type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\nexport type Mixin<T> = Optional<Component<T>, 'tag'>\nexport type Invalidate<E, K extends keyof E> = Parameters<Descriptor<E, E[K]>['connect']>[2]\n\n/**\n * Check if a function is a class.\n * @category Utils\n * @param fn a function\n * @returns true if the function is a class\n */\nexport const isClass = (fn) => typeof fn === 'function' && /^class\\s/.test(Function.prototype.toString.call(fn))\n\n/**\n * Convert a Hybrids property to a Hybrids Descriptor\n * @category Utils\n * @param property a Hybrids property\n * @returns a Hybrids Descriptor\n */\nexport const propertyToDescriptor = <E, V>(property: Property<E, V>): Descriptor<E, V> => {\n  return typeof property === 'function'\n    ? { value: property }\n    : typeof property === 'object'\n    ? property\n    : { value: property }\n}\n","import { isClass } from '../utils.js'\nimport { Descriptor, Property } from 'hybrids'\n\nexport interface Type<T> extends Function {\n  new (...args: any[]): T\n}\n\nexport type Fn<T> = (...args: any[]) => T\n\nexport interface Disposable {\n  dispose: () => void\n}\n\n/**\n * A factory handling a Disposable object. The disposed return value is assigned when removed from the DOM.\n * ```\n * define<any>({\n *   disposableClass: disposable(MyClass),\n *   disposableFunction: disposable(BarFoo),\n * })\n *\n * class MyClass implements Disposable { ... }\n *\n * function BarFoo(host, key, invalidate) {\n *   return { dispose: ... }\n * }\n * ```\n * @category Factories\n * @typeParam E - host element type\n * @typeParam V - property type which extends Disposable\n * @param Ctor a Disposable constructor or function which returns a Disposable.\n * @returns a disposable handler Hybrids property\n * @see /interfaces/Disposable.html\n */\nexport const disposable = <E, V extends Disposable = Disposable>(\n  Ctor: Type<Disposable> | Fn<Disposable>\n): Property<E, V> => ({\n  value: undefined,\n  connect: (host, key, invalidate) => {\n    const instance = isClass(Ctor)\n      ? new (<Type<Disposable>>Ctor)(host, key, invalidate)\n      : (<Fn<Disposable>>Ctor)(host, key, invalidate)\n    host[key] = instance as V\n    return () => {\n      host[key].dispose()\n    }\n  },\n})\n","import { Descriptor, Property } from 'hybrids'\nimport { propertyToDescriptor } from '@src/index.js'\n\n/**\n * Run one or more effects when the property changes\n * @category Factories\n * @param property any Hybrids property\n * @param effects one or more observe functions to execute when the property value changes\n * @returns the resulting Hybrids property\n */\nexport const effect = <E, V = any>(\n  property: Property<E, V>,\n  ...effects: Descriptor<E, V>['observe'][]\n): Property<E, V> => {\n  const descriptor = propertyToDescriptor(property)\n  return {\n    ...descriptor,\n    observe: (host, val, last) => {\n      descriptor.observe?.(host, val, last)\n      effects.forEach((observe) => observe(host, val, last))\n    },\n  }\n}\n","import { Descriptor, Property } from 'hybrids'\nimport { propertyToDescriptor } from '../utils.js'\n\nexport interface HostedMutationCallback<E extends HTMLElement = HTMLElement> {\n  (host: E, mutations: MutationRecord[], observer: MutationObserver): void\n}\n\n/**\n * Wrap a Property with a mutation observer which will invalidate on mutation.\n * @category Factories\n * @param prop any Hybrids property\n * @param init the mutation observer init options\n * @returns a dscriptor which will invalidate on mutation\n */\nexport function mo<V = any, E extends HTMLElement = HTMLElement>(\n  prop: Property<E, V>,\n  init: MutationObserverInit & {\n    callback?: HostedMutationCallback<E>\n  }\n): Descriptor<E, V> {\n  const descriptor = propertyToDescriptor(prop)\n  const connect = (host, key, invalidate) => {\n    const disconnect = descriptor.connect?.(host, key, invalidate)\n    const mo = new MutationObserver((mutations, observer) => {\n      invalidate()\n      init?.callback?.(host, mutations, observer)\n    })\n    mo.observe(host, init)\n    return () => {\n      mo.disconnect()\n      disconnect && disconnect()\n    }\n  }\n  return {\n    ...descriptor,\n    connect,\n  }\n}\n","import { Descriptor } from 'hybrids'\n\n/**\n * Track the mouse position relative to the target element.\n * @category Factories\n * @param options mouse tracking options\n * @param options.target target element to track mouse position. defaults to the host element\n * @param options.clamp whether to clamp the mouse position to the target element's bounding box\n * @returns A Descriptor which tracks the mouse position relative to the target element\n */\nexport function mouse<E>({\n  target,\n  clamp,\n}: {\n  target?: Element\n  clamp?: boolean\n} = {}): Descriptor<E, { x: number; y: number }> {\n  return {\n    value: { x: 0, y: 0 },\n    connect: (host: E & HTMLElement, key, invalidate) => {\n      if (clamp == null) {\n        clamp = true\n      }\n      if (target == null) {\n        target = host\n      }\n\n      function track(e) {\n        host[key] = relativePosition(host, e, clamp)\n        invalidate()\n      }\n\n      target.addEventListener('mousemove', track)\n      return () => {\n        target.removeEventListener('mousemove', track)\n      }\n    },\n  }\n}\n\nfunction relativePosition(h: HTMLElement, e: MouseEvent, clamp = false) {\n  const bbox = h.getBoundingClientRect()\n  let x = e.clientX - bbox.x\n  let y = e.clientY - bbox.y\n  if (clamp) {\n    x = Math.floor(Math.max(0, Math.min(bbox.width, x)))\n    y = Math.floor(Math.max(0, Math.min(bbox.height, y)))\n  }\n  return { x, y }\n}\n","import { Property } from 'hybrids'\nimport { propertyToDescriptor } from '../utils.js'\n\n/**\n * Reflect any property to an attribute on the host\n * @category Factories\n * @param prop the property to reflect\n * @param bidirectional if true, sets the property when the attribute changes\n * @returns a Hybrids Descriptor with the reflection side-effect\n */\nexport const reflect = <E extends HTMLElement, V>(prop: Property<E, V>, bidirectional = false) => {\n  const descriptor = propertyToDescriptor(prop)\n  const computed = typeof descriptor.value === 'function'\n  return {\n    ...descriptor,\n    reflect: true,\n    connect(host, key, invalidate) {\n      const disconnect = descriptor.connect?.(host, key, invalidate)\n\n      let ob\n      if (bidirectional) {\n        ob = new MutationObserver(() => {\n          if (!computed) host[key] = host.getAttribute(key)\n        })\n        ob.observe(host, { attributes: true, attributeFilter: [key] })\n      }\n\n      return () => {\n        if (ob?.disconnect) ob.disconnect()\n        if (disconnect) disconnect()\n      }\n    },\n  }\n}\n","import { Descriptor, Property } from 'hybrids'\nimport { propertyToDescriptor } from '@src/utils.js'\n\n/**\n * Wrap a Property with a resize observer which will invalidate on resize.\n * @category Factories\n * @param prop any Hybrids property\n * @param options the resize observer options\n * @returns a descriptor which will invalidate on resize\n */\nexport function ro<V = any, E extends HTMLElement = HTMLElement>(\n  prop: Property<E, V>,\n  options?: ResizeObserverOptions\n): Descriptor<E, V> {\n  const descriptor = propertyToDescriptor(prop)\n  const connect = (host, key, invalidate) => {\n    const disconnect = descriptor.connect?.(host, key, invalidate)\n    const ro = new ResizeObserver(() => {\n      invalidate()\n    })\n    ro.observe(host, options)\n    return () => {\n      ro.disconnect()\n      disconnect && disconnect()\n    }\n  }\n  return {\n    ...descriptor,\n    connect,\n  }\n}\n","import { Descriptor } from 'hybrids'\n\n/**\n * Gets a reference to an element in the shadowDOM. This property cannot be used during render to prevent circular references.\n * ```\n * define({\n *   canvas: ref('canvas.container'),\n *   render: () => html`\n *     <canvas class=\"container\"></canvas>\n *   `,\n * })\n * ```\n * @category Ref\n * @param query the querySelector query\n * @returns a reference to an element in the shadowDOM\n */\nexport const ref = <T extends Element = Element>(query: string): Descriptor<unknown, T> => ({\n  value: (host: { render: () => ShadowRoot } & HTMLElement) => host.render().querySelector(query) as T,\n})\n\n/**\n * Gets all references to elements in the shadowDOM. This property cannot be used during render to prevent circular references.\n * ```\n * define({\n *  children: refs('div.child'),\n *  render: () => html`\n *    <div class=\"child\"></div>\n *    <div class=\"child\"></div>\n *  `,\n * })\n * ```\n * @category Ref\n * @param queryAll the querySelectorAll query\n * @returns references to all elements in the shadowDOM\n */\nexport const refs = <T extends Element = Element>(queryAll: string): Descriptor<unknown, T[]> => ({\n  value: ({ render }: HTMLElement & { render: () => ShadowRoot }) => {\n    const nodeList = render().querySelectorAll(queryAll)\n    return Array.from(nodeList) as T[]\n  },\n})\n","import { mo } from '@auzmartist/hybrids-helpers'\nimport { Descriptor } from 'hybrids'\n\n/**\n * Get a reference to a slotted light-DOM node\n * ```\n * define({\n *   tag: 'my-component',\n *   content: slotted(),\n *   named: slotted('named-slot'),\n *   render: () => html`\n *     <slot></slot>\n *     <slot name=\"named-slot\"></slot>\n *   `\n * })\n *\n * <my-component>\n *   <div>Default slot</div>\n *   <div slot=\"named-slot\">Named slot</div>\n * </my-component>\n * ```\n * @category Ref\n * @param name the slot name to select. If not provided, selects the default slotted nodes.\n * @returns a hybrid descriptor binding a slotted node to the host\n */\nexport function slotted(name?: string): Descriptor<unknown, Element | null> {\n  return mo(\n    {\n      value: (host: HTMLElement) => host.querySelector(name ? `*[slot=\"${name}\"]` : '*:not([slot])'),\n    },\n    { childList: true }\n  )\n}\n","import { propertyToDescriptor } from '@src/utils.js'\nimport { Property } from 'hybrids'\nconst XHOST = '_x_host_proxy_'\n\n/**\n * Alpine directive which binds select properties to the existing Alpine data scope.\n * @category Alpine\n */\nexport function xHost(el, { expression }, { Alpine, evaluate }) {\n  const host = getNearestHybridsHost(el)\n  if (host.constructor.name !== 'HybridsElement') {\n    throw new Error('x-host directive must only be used inside a HybridsElement')\n  }\n  const props = expression ? evaluate(expression) : null\n  host[XHOST] = hostData(host, props, Alpine.reactive({}), Alpine)\n  Alpine.addScopeToNode(el, host[XHOST])\n}\n\n// get the nearest host element OR if not shadow DOM, the nearest HybridsElement\nfunction getNearestHybridsHost(el) {\n  if (el.host) return el.host\n  else if (el.constructor.name === 'HybridsElement') return el\n  if (el.parentNode) return getNearestHybridsHost(el.parentNode)\n  return null\n}\n\nconst ignore = {\n  _x_marker: true,\n}\n\nfunction hostData(el, props: string[], seed: object, Alpine) {\n  for (const key in el) {\n    // ignore native HTMLElement properties\n    if ((props?.length == null && key in HTMLElement.prototype) || key === 'render') continue\n    // only bind selected properties (if provided)\n    if (props?.length != null && !props.includes(key)) continue\n    // ignore Alpine properties\n    if (key in ignore) continue\n\n    addToReactive(seed, el, key, Alpine)\n  }\n  return seed\n}\n\n/**\n * @param data reactive data object\n * @param el element with a property to add to reactive data\n * @param key the property name to add\n */\nfunction addToReactive<E extends HTMLElement>(data: Record<string, any>, el: E, key: keyof E, Alpine) {\n  const keyStr = key.toString()\n  const desc = Object.getOwnPropertyDescriptor(el.constructor.prototype, key)\n  if (desc && desc.get) {\n    // bind Hybrids updates to Alpine data scope\n    Object.defineProperty(el, key, {\n      get() {\n        const next = desc.get.call(this)\n        if (next !== data[keyStr]) {\n          data[keyStr] = next\n        }\n        return next\n      },\n      set: desc.set\n        ? function (value) {\n            if (value !== data[keyStr]) {\n              data[keyStr] = value\n            }\n            return desc.set.call(this, data[keyStr])\n          }\n        : undefined,\n      configurable: true,\n      enumerable: true,\n    })\n    data[keyStr] = el[key]\n\n    // update host properties when Alpine data changes\n    if (desc.set) {\n      Alpine.effect(() => {\n        el[keyStr] = data[keyStr]\n      })\n    }\n  } else {\n    console.warn('x-host: Property', key, 'has no getter.')\n  }\n}\n\n/**\n * Bind a computed property to the Alpine data scope on update.\n * @category Alpine\n * @param property any Hybrids property\n */\nexport const xhost = <E, V>(property: Property<E, V>) => {\n  const descriptor = propertyToDescriptor(property as Property<E, V>)\n  let key\n  return {\n    ...descriptor,\n    connect(host, _key) {\n      key = _key\n      // alpine needs to render once first before we can check for x-host\n      requestAnimationFrame(() => {\n        if (!host[XHOST]) {\n          console.warn('Element does not use the x-host Alpine directive.')\n        }\n      })\n    },\n    observe(host, value, last) {\n      if (value !== last && host[XHOST]) {\n        host[XHOST][key] = value\n      }\n    },\n  }\n}\n","/**\n * Pass data to components with the x-prop directive.\n * @category Alpine\n * @example <div x-data=\"{ foo: 'bar' }\" x-prop=\"{foo}\"></div> // div.foo = 'bar'\n * @example <div x-data=\"{ foo: 'bar' }\" x-prop.foo=\"foo\"></div> // div.foo = 'bar'\n */\nexport function xProp(el, { modifiers, expression }, { evaluateLater, effect }) {\n  const evaluate = evaluateLater(expression)\n  const [propertyName] = modifiers ?? []\n\n  effect(() =>\n    evaluate((result) => {\n      if (propertyName == null && typeof result === 'object' && !Array.isArray(result)) {\n        Object.entries(result).forEach(([key, value]) => {\n          el[key] = value\n        })\n      } else {\n        el[propertyName] = result\n      }\n    })\n  )\n}\n","import Alpine, { DirectiveCallback } from 'alpinejs'\nimport { html, UpdateFunctionWithMethods } from 'hybrids'\nimport { xHost } from './x-host.js'\nimport { xProp } from './x-prop.js'\nexport let _Alpine\n\n/**\n * Render a Hybrids template powered by Alpine.\n * @category Alpine\n * @returns the html template function with the Alpine engine.\n *\n * @example ```\n * import {alpine} from '@auzmartist/hybrids-helpers'\n * alpine.config(Alpine)\n *\n * define({\n *   tag: 'my-component',\n *   render: alpine`\n *     <div x-data=\"{ open: false }\" :class=\"open ? '' : 'hidden'\">\n *       <button @click=\"open = !open\">Toggle</button>\n *       <div x-show=\"open\">Hello</div>\n *     </div>\n *   `,\n * })\n * ```\n */\nexport function alpine<H>(string, ...parts): UpdateFunctionWithMethods<H> {\n  if (!_Alpine) {\n    throw new Error('Alpine.config must be called first.')\n  }\n\n  const updateFn = html<H>(string, ...parts)\n\n  return new Proxy(updateFn, {\n    apply(target, thisArg, args: [H & HTMLElement, (ShadowRoot | Text | H)?]) {\n      target.apply(thisArg, args)\n      const [host] = args\n      _Alpine.initTree(host.shadowRoot ?? host)\n    },\n  })\n}\n\n/**\n * Alpine engine version (alpinejs_x.x.x)\n * @category Alpine\n */\nalpine.engine = _Alpine?.version\n\n/**\n * apply Hybrids html helpers to the Alpine template engine\n */\nalpine.resolve = html.resolve.bind(html)\nalpine.set = html.set.bind(html)\nalpine.transition = html.transition.bind(html)\n\n/**\n * The special Alpine host directive for interop between Hybrids getters and Alpine data\n */\nalpine.host = xHost\nalpine.prop = xProp\n\n/**\n * Configure the Alpine engine\n * @function\n * @category Alpine\n * @param Alp An instance of the Alpine engine\n * @param directives A record of custom Alpine directives to use with Hybrids. Default: {host: xHost, prop: xProp}\n *\n * @example ```\n *   import { alpine } from '@auzmartist/hybrids-helpers'\n *   alpine.config(Alpine)\n * ```\n */\nalpine.config = function (\n  Alp: typeof Alpine,\n  directives: Record<string, DirectiveCallback> = {\n    host: xHost,\n    prop: xProp,\n  }\n) {\n  if (!!_Alpine) {\n    console.warn('Alpine.config should only be called once.')\n  }\n  // register custom hybrids directives\n  for (const [name, callback] of Object.entries(directives)) {\n    Alp.directive(name, callback)\n  }\n  _Alpine = Alp\n\n  alpine.engine = `alpinejs_${_Alpine?.version}`\n}\n","import { UpdateFunctionWithMethods, html } from 'hybrids'\n\n/**\n * A collection of helpers for creating Hybrids templates.\n * @category Template\n */\nexport const hy = {\n  print: (data: any, space?: string | number) => html`<pre>${JSON.stringify(data, null, space)}</pre>`,\n  if: <E>(\n    condition: boolean | (() => boolean),\n    frag: UpdateFunctionWithMethods<E>,\n    fallback?: UpdateFunctionWithMethods<E>\n  ) => {\n    return (typeof condition === 'function' ? condition() : condition) ? frag : fallback ? fallback : html``\n  },\n  // prettier-ignore\n  regex: <E, R extends RegExp>(\n    regexp: R,\n    frag: (match: RegExpExecArray) => UpdateFunctionWithMethods<E>,\n    fallback?: UpdateFunctionWithMethods<E>\n  ) => (value: string) => {\n    const result = regexp.exec(value)\n    return result?.[0] ? frag(result) : fallback ? fallback : html``\n  },\n  map: <E, T>(\n    items: T[] | ((...args: any[]) => T[]),\n    predicate: (item: T, i: number, arr: T[]) => UpdateFunctionWithMethods<E>\n  ) => {\n    return (typeof items === 'function' ? items() : items).map(predicate)\n  },\n  case: <E, T extends number | string | symbol>(\n    value: T,\n    cases: Record<T, UpdateFunctionWithMethods<E>> & { default?: UpdateFunctionWithMethods<E> }\n  ) => {\n    return cases[value] ? cases[value] : cases.default ? cases.default : html``\n  },\n  keyvalue: <E>(record: Record<any, any>, template: (key: any, value: any) => UpdateFunctionWithMethods<E>) => {\n    return Object.entries(record).map(([key, value]) => template(key, value))\n  },\n}\n","/**\n * Set a property on the host element from an event.\n * @category Events\n * @param property the property to assign the extracted value\n * @param extractor a function to extract the value from the event. Defaults reasonably.\n * @returns the event handler\n */\nexport function set<E extends HTMLElement>(\n  property: keyof E,\n  extractor: (e: Event) => E[typeof property] = extractEventValue\n) {\n  return (host: E, e: Event) => (host[property] = extractor(e))\n}\n\n/**\n * Extract the value from an event heuristically.\n * @param e event\n * @returns the presumed value of the event\n */\nfunction extractEventValue(e: Event) {\n  if (e instanceof CustomEvent) {\n    return e.detail\n  }\n  if (e.target instanceof HTMLInputElement && (e.target.type === 'checkbox' || e.target.type === 'radio')) {\n    return e.target.checked\n  } else {\n    return (<any>e.target).value\n  }\n}\n","import {\n  Component,\n  Descriptor as Desc,\n  Descriptor,\n  html,\n  define as hy_define,\n  Property as Prop,\n  RenderFunction,\n} from 'hybrids'\nimport { emit, prevent, stop } from './events.js'\nimport { Disposable as Disp, disposable, Fn, Type } from './factories/disposable.js'\nimport { effect } from './factories/effect.js'\nimport { HostedMutationCallback, mo } from './factories/mo.js'\nimport { mouse } from './factories/mouse.js'\nimport { reflect } from './factories/reflect.js'\nimport { ro } from './factories/ro.js'\nimport { ref, refs } from './refs/ref.js'\nimport { slotted } from './refs/slotted.js'\nimport { _Alpine, alpine } from './template/alpine/alpine.js'\nimport { xhost } from './template/alpine/x-host.js'\nimport { hy } from './template/hy.js'\nimport { set } from './template/set.js'\ntype Connect<E, V = undefined> = Descriptor<E, V>['connect']\n\n/**\n * Create a type-curried builder for Hybrid components.\n * @category Define\n * @typeParam E - host element type\n * @returns type-curried helpers for building Hybrid components.\n */\nexport const HybridBuilder = <E extends HTMLElement>() => ({\n  prop: <V = any>(property: Prop<E, V>) => property,\n  be: <V = any>(value: Desc<E, V>['value']) => ({ value } as Desc<E, V>),\n\n  // extensions of hybrids-helpers\n  disposable: <V extends Disp = Disp>(Ctor: Type<Disp> | Fn<Disp>) => disposable<E, V>(Ctor),\n  effect: <V = any>(property: Prop<E, V>, ...effects: Desc<E, V>['observe'][]) => effect<E, V>(property, ...effects),\n  mo: <V = any>(prop: Prop<E, V>, init: MutationObserverInit & { callback?: HostedMutationCallback<E> }) =>\n    mo<V, E>(prop, init),\n  mouse: mouse<E>,\n  reflect: <V = any>(prop: Prop<E, V>, bidirectional = false) => reflect<E, V>(prop, bidirectional),\n  ro: <V = any>(prop: Prop<E, V>) => ro(prop),\n\n  // refs\n  ref: ref<E>,\n  refs: refs<E>,\n  slotted,\n\n  render: (renderer: RenderFunction<E>) => renderer,\n  shadow: (value: RenderFunction<E>) => ({ value, shadow: true }),\n  alpine: _Alpine ? alpine<E> : <E>(_: E) => console.warn('alpine.config must be called first.'),\n  html: _Alpine ? alpine<E> : html<E>,\n  // Alpine bindings\n  xhost: <V = any>(prop: Prop<E, V>) => xhost<E, V>(prop),\n\n  // template helpers\n  hy,\n  // events\n  emit,\n  // template event handlers\n  set: <Ev extends Event = Event>(property: keyof E, extractor?: (e: Ev) => E[typeof property]) =>\n    set<E>(property, extractor),\n  stop: <T = any>(handler: (host: E, e: CustomEvent<T>) => void) => stop(handler),\n  prevent: <T = any>(handler: (host: E, e: CustomEvent<T>) => void) => prevent(handler),\n\n  // transient host type to render and safe define\n  define: safeDefine<E>,\n  // transient host type to render and safe compile\n  compile: hy_define.compile<E>,\n})\n\nfunction safeDefine<E extends HTMLElement>(component: Component<E>) {\n  if (!window.customElements.get(component.tag)) {\n    return hy_define(component)\n  } else {\n    console.warn(`Custom Element '${component.tag}' already defined.`)\n    return null\n  }\n}\n\n/**\n * Build and define a web component with helpers.\n * @function\n * @category Define\n * @param factory a function which returns a component definition.\n * @typeParam E - host element type\n * @returns the defined component or null if the tag is already defined.\n */\nexport function build<E extends HTMLElement>(\n  factory: (\n    builder: ReturnType<typeof HybridBuilder<E>> & {\n      onconnect: (...connectors: Connect<E>[]) => void\n      ondisconnect: (...disconnectors: Connect<E>[]) => void\n    }\n  ) => Component<E>\n): Component<E> | null {\n  const builder = HybridBuilder<E>()\n\n  // orphan connect and disconnect callbacks\n  const connectCallbacks = []\n  const disconnectCallbacks = []\n  const onconnect = (...connectors: Connect<E>[]) => connectCallbacks.push(...connectors)\n  const ondisconnect = (...disconnectors: Connect<E>[]) => disconnectCallbacks.push(...disconnectors)\n\n  const component = factory({ ...builder, onconnect, ondisconnect })\n  if (connectCallbacks.length > 0 || disconnectCallbacks.length > 0) {\n    component['__builder_connect__'] = {\n      value: undefined,\n      connect(host: E, key: string, invalidate) {\n        const disconnectors = connectCallbacks.map((connector) => connector(host, key, invalidate))\n        return () => {\n          disconnectors.forEach((disconnect) => disconnect())\n          disconnectCallbacks.forEach((disconnector) => disconnector(host, key, invalidate))\n        }\n      },\n    }\n  }\n\n  // analyze the component for custom elements manifest\n  return builder.define(component)\n}\n\n/**\n * Build and compile a web component with helpers.\n * The component is not defined in the custom elements registry.\n * To define the component you can run `customElements.define(tag, component)`.\n * @category Define\n * @param factory a function which returns a component definition.\n * @returns the defined comoonent or null if the tag is already defined.\n */\nbuild.compile = <E extends HTMLElement>(factory: (builder: ReturnType<typeof HybridBuilder<E>>) => Component<E>) => {\n  const builder = HybridBuilder<E>()\n  const component = factory(builder)\n  return builder.compile(component)\n}\n","import { Descriptor } from 'hybrids'\n\n/**\n * Shorthand factory for a blank value with connector.\n * @param connect connect function\n * @returns A Descriptor with only a connect function\n */\nexport function connect<E, V = undefined>(connect: Descriptor<E, V>['connect']): Descriptor<E, V> {\n  return {\n    value: undefined,\n    connect,\n  }\n}\n","import { Descriptor } from 'hybrids'\n\n/**\n * Listen to a map of events. Handles listener registration and deregistration.\n * ```\n * define<any>({\n *   foo: 0,\n *   incrementFoo: (host) => (e) => host.foo++,\n *   _connect: {\n *     value: undefined,\n *     connect: listen((host: any, key, invalidate) => ({\n *      'foo': host.incrementFoo,\n *      'click': invalidate,\n *   }\n * })\n * ```\n * @category Connectors\n * @typeParam E - host element type\n * @param eventMapFn a connect function returning a record of events and bound functions to listen to\n * @param element optional element to bind the listeners to\n * @returns A Descriptor['connect'] function\n */\nexport function listen<E>(\n  eventMapFn: (\n    host: E,\n    key: '__property_key__',\n    invalidate: (options?: { force?: boolean }) => void\n  ) => Record<string, (e: Event) => void>,\n  element?: Element\n): NonNullable<Descriptor<E, any>['connect']> {\n  return (host: E & HTMLElement, key: '__property_key__', invalidate: (options?: { force?: boolean }) => void) => {\n    const eventMap = eventMapFn(host, key, invalidate)\n    const target = element ?? host\n    Object.entries(eventMap).forEach(([event, callback]) => {\n      target.addEventListener(event, (e) => callback(e))\n    })\n    return () => {\n      Object.entries(eventMap).forEach(([event, callback]) => {\n        target.removeEventListener(event, callback)\n      })\n    }\n  }\n}\n","import { Descriptor } from 'hybrids'\n\n/**\n * @deprecated use 'value' instead\n * Create a readable/writable property without attribute reflection. Can be helpful for managing exposed attributes or creating properties with complex data types.\n * ```\n * define({\n *   array: getset([]),\n * })\n * ```\n * @category Factories\n * @typeParam E - host element type\n * @typeParam V - property value type\n * @param defaultValue the default value\n * @returns a Hybrids Descriptor\n * @see https://hybrids.js.org/#/component-model/structure?id=get-amp-set\n */\nexport const getset = <E, V = any>(value: V = undefined): Descriptor<E, V> => ({\n  value,\n})\n","import { Descriptor } from 'hybrids'\n\n/**\n * An observer executing each passed observer in sequence\n * ```\n * define<MyElement>({\n *   color: {\n *     value: 'red',\n *     observe: forEach(\n *       cssVar('--my-element-color'),\n *       cssVar('--my-element-color-complement', (val, host) => complementaryColor(value)),\n *     ),\n *   },\n * })\n * ```\n * @category Descriptor:Observe\n * @typeParam E - host element type\n * @typeParam V - property value type\n * @param observers a list of 'observe' Descriptor functions to execute\n * @returns An 'observe' Descriptor function\n */\nexport const forEach =\n  <E, V>(...observers: Descriptor<E, V>['observe'][]): NonNullable<Descriptor<E, V>['observe']> =>\n  (host: E & HTMLElement, val: V, last: V) =>\n    observers.forEach((observe) => observe(host, val, last))\n\n/**\n * An observer which reflects the current property value to a custom CSS property on the host element.\n * ```\n * define<MyElement>({\n *   color: { value: 'red', observe: cssVar('--my-element-color') },\n * })\n * ```\n * @category Descriptor:Observe\n * @typeParam E - host element type\n * @typeParam V - property value type\n * @param customProperty CSS custom property name\n * @param transform am optional function converting the JS to CSS value\n * @returns An 'observe' Descriptor function\n */\nexport const cssVar =\n  <E, V>(\n    customProperty: string,\n    transform: (val: V, host: E) => any = (val) => val\n  ): NonNullable<Descriptor<E, V>['observe']> =>\n  (host: E & HTMLElement, val: V) => {\n    host.style.setProperty(customProperty, transform(val, host))\n  }\n\n/**\n * Runs the observe function only when the current value is non-nullish.\n * ```\n * define({\n *   property: {\n *     ...getset(undefined),\n *     observe: nnull(cssVar(--custom-property)),\n *   },\n * })\n * ```\n * @category Descriptor:Observe\n * @typeParam E - host element type\n * @typeParam V - property value type\n * @param observe 'observe' function to execute when the value is not null or undefined\n * @param nullCallback optional 'observe' function when the value is nullish\n * @returns an 'observe' Descriptor\n */\nexport function nnull<E, V>(\n  observe: Descriptor<E, V>['observe'],\n  nullCallback?: Descriptor<E, V>['observe']\n): NonNullable<Descriptor<E, V>['observe']> {\n  return (host: E & HTMLElement, value: V, last: V | undefined) => {\n    if (value != null) {\n      observe(host, value, last)\n    } else {\n      nullCallback?.(host, value, last)\n    }\n  }\n}\n\n/**\n * Runs the observe function only when the current value is truthy.\n * ```\n * define({\n *   property: {\n *     ...getset(''), // will not run on initial set\n *     observe: truthy(cssVar(--custom-property)),\n *   },\n * })\n * ```\n * @category Descriptor:Observe\n * @typeParam E - host element type\n * @typeParam V - property value type\n * @param observe 'observe' function to execute when the value is truthy\n * @param nullCallback optional 'observe' function when the value is falsy\n * @returns an 'observe' Descriptor\n */\nexport function truthy<E, V>(\n  observe: Descriptor<E, V>['observe'],\n  nullCallback?: Descriptor<E, V>['observe']\n): NonNullable<Descriptor<E, V>['observe']> {\n  return (host: E & HTMLElement, value: V, last: V | undefined) => {\n    if (value) {\n      observe(host, value, last)\n    } else {\n      nullCallback?.(host, value, last)\n    }\n  }\n}\n","import { RenderDescriptor, RenderFunction } from 'hybrids'\n\n/**\n * Create a render descriptor for a light DOM element.\n * @category Template\n * @param value the render function\n * @returns a rendder descriptor\n */\nexport function light<E extends HTMLElement = HTMLElement>(value: RenderFunction<E>): RenderDescriptor<E> {\n  return {\n    value,\n    shadow: false,\n  }\n}\n","import { Descriptor, RenderDescriptor, UpdateFunctionWithMethods } from 'hybrids'\n/**\n * A direct port of the old Hybrids 6.1 render factory\n * https://hybrids.js.org/#/migration?id=render-factory\n * @category Render\n * @param desc the render descriptor\n */\nexport function render6<E>(fn: (host: E & HTMLElement) => UpdateFunctionWithMethods<E>, customOptions = {}) {\n  if (typeof fn !== 'function') {\n    throw TypeError(`The first argument must be a function: ${typeof fn}`)\n  }\n\n  const options = { shadowRoot: true, ...customOptions }\n  const shadowRootInit = { mode: 'open' }\n\n  if (typeof options.shadowRoot === 'object') {\n    Object.assign(shadowRootInit, options.shadowRoot)\n  }\n\n  const getTarget = options.shadowRoot ? (host) => host.shadowRoot || host.attachShadow(shadowRootInit) : (host) => host\n\n  return {\n    get(host) {\n      const update = fn(host)\n      const target = getTarget(host)\n\n      return function flush() {\n        update(host, target)\n        return target\n      }\n    },\n    observe(host, flush) {\n      flush()\n    },\n  }\n}\n\n/**\n * A direct port of the old Hybrids 9 render factory\n * https://hybrids.js.org/#/migration?id=render-factory\n * @category Render\n * @param desc the render descriptor\n * @returns a Hybrids descriptor\n * @throws TypeError if the 'reflect' option is used\n * @throws TypeError if the 'render' value is not a function\n */\nexport function render<E>(desc: RenderDescriptor<E>) {\n  if (desc.reflect) {\n    throw TypeError(`'reflect' option is not supported for 'render' property`)\n  }\n\n  const { value: fn, connect, observe } = desc\n\n  if (typeof fn !== 'function') {\n    throw TypeError(`Value for 'render' property must be a function: ${typeof fn}`)\n  }\n\n  const result = {\n    connect,\n    observe: observe\n      ? (host, flush, lastFlush) => {\n          observe(host, flush(), lastFlush)\n        }\n      : (host, flush) => {\n          flush()\n        },\n  } as Descriptor<E, any>\n\n  const shadow = desc.shadow\n    ? {\n        mode: (<ShadowRootInit>desc.shadow).mode || 'open',\n        delegatesFocus: (<ShadowRootInit>desc.shadow).delegatesFocus || false,\n      }\n    : desc.shadow\n\n  if (shadow) {\n    result.value = (host) => {\n      const target = host.shadowRoot || host.attachShadow(<ShadowRootInit>shadow)\n      const update = fn(host)\n\n      return () => {\n        update(host, target)\n        return target\n      }\n    }\n  } else if (shadow === false) {\n    result.value = (host) => {\n      const update = fn(host)\n      return () => {\n        update(host, host)\n        return host\n      }\n    }\n  } else {\n    result.value = (host) => {\n      const update = fn(host)\n      return () => update(host)\n    }\n  }\n\n  return result\n}\n"],"names":["_a","connect","mo","ro","render","effect","_Alpine","html","hy_define"],"mappings":";;;;;AASO,WAAS,KAAQ,MAAe,OAAe,QAAY,OAA6B,CAAA,GAAI;AACjG,UAAM,YAAY,EAAE,SAAS,MAAM,UAAU,MAAM,GAAG,KAAK;AAC3D,QAAI,QAAQ;AACV,gBAAU,SA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