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O,KAAAC,EAAM,QAAAC,EAAS,cAAAC,EAAe,KAAAd,EAAI,EAAKe,GAAUL,CAAA,EAC5DC,EACF,QAAQ,KAAKA,EAAOH,CAAA,EAEX,OAAO,KAAKM,CAAA,GAAmB,WACxC,QAAQ,KAAK,GAAG,KAAK,SAAS,YAAW,CAAA,IAAMA,CAAA,6BACfN,CAAA,EAEhCnB,GAAO,IAAA,CAEL,IAAM2B,EAAM,KAAKF,CAAA,EAAc,GAAId,EAAA,EAC/BY,IAAS,SAAWC,EAEtBL,EAAG,UAAUQ,EAAM,MAAQ,QAAA,EAAUH,CAAA,EAC5BD,IAAS,SAAWC,EAG7BL,EAAGK,CAAA,EAAW,KAAKC,CAAA,EACVF,IAAS,cAAgBC,EAE9BG,IAAQ,KACVR,EAAG,gBAAgBK,CAAA,EAEnBL,EAAG,aAAaK,EAASG,CAAA,EAElBH,EAGTL,EAAGI,CAAA,EAAMC,CAAA,EAAWG,EACXJ,IAAS,YAElBV,EAAec,CAAA,EAAK,KAAKC,IAAA,CACvBT,EAAGI,CAAA,EAAQK,GACXX,EAAyBE,CAAA,CAC3B,CAAA,EAIAA,EAAGI,CAAA,EAAQI,CAEf,CAAA,CAEJ,CAGN,EACAV,EAAyB,KAAK,YAAc,IAAI,CAClD,CAAA,CACF,CAAA,EACF,CAEA,sBAAwB,CACtB,KAAKd,KAAQ,CACf,CACF,EAEMiB,GAA8B,CAACF,EAA8BC,IAAA,CACjE,IAAIU,EAAIV,EAAG,cACX,KAAOU,GAAKA,IAAMX,GAAQ,CACxB,GAAIW,EAAE,SAAS,SAAS,GAAA,EACtB,MAAO,GAETA,EAAIA,EAAE,aACR,CACF","names":["SCOPE","scheduledEffects","runningEffects","currentScope","currentObserver","currentObservers","currentObserversIndex","effects","defaultContext","NOOP","STATE_CLEAN","STATE_CHECK","STATE_DIRTY","STATE_DISPOSED","flushEffects","runEffects","i","runTop","node","ancestors","SCOPE","updateCheck","root","init","scope","createScope","compute","dispose","onDispose","disposable","currentScope","NOOP","node","STATE_DISPOSED","isFunction","dispose","self","i","parent","SCOPE","disposeNode","emptyDisposal","removeSourceObservers","defaultContext","scope","callable","error","handleError","compute","compute2","observer","prevScope","prevObserver","currentObserver","len","currentError","error2","read","currentObservers","currentObserversIndex","updateCheck","write","newValue","value","notify","STATE_DIRTY","ScopeNode","ScopeProto","child","createScope","ComputeNode","initialValue","options","STATE_CLEAN","ComputeProto","isNotEqual","createComputation","a","b","STATE_CHECK","update","cleanup","prevObservers","prevObserversIndex","result","updateObservers","source","state","effects","scheduledEffects","flushEffects","index","swap","signal","initialValue","options","node","createComputation","signal2","read","SCOPE","write","computed","compute","options","node","createComputation","signal2","read","SCOPE","effect","effect2","effectResult","isFunction","onDispose","update","dispose","fs","vscodeExtensionFs","sep","html","strings","params","output","insideTag","i","str","unsafeInnerHtml","nrOf","p","endsWithEq","renderToString","node","s","renderToStream","stack","n","isAsyncIterable","escape","nextUp","value","done","current","iterator","escapeForAttribute","escapeForHtml","st","val","prev","char","parseBind","bind","parts","lhs","rhs","prop","subprop","fieldOrMethod","rawArgs","args","parseArgs","a","n","computed","effect","signal","ReactiveElement","#dispose","#eventNames","eventName","e","target","value","methodName","rawArgs","args","parseArgs","renderToString","attr","root","dispose","registerRenderingEffects","rootEl","el","isChildOfOtherCustomElement","bind","error","prop","subprop","fieldOrMethod","parseBind","val","v","p"],"sources":["../esm/npm/@jsr/mastrojs__reactive@0.4.0/node_modules/@maverick-js/signals/dist/prod/symbols.js","../esm/npm/@jsr/mastrojs__reactive@0.4.0/node_modules/@maverick-js/signals/dist/prod/core.js","../esm/npm/@jsr/mastrojs__reactive@0.4.0/node_modules/@maverick-js/signals/dist/prod/signals.js","../esm/npm/@jsr/mastrojs__reactive@0.4.0/node_modules/@jsr/mastrojs__mastro/src/core/fs.ts","../esm/npm/@jsr/mastrojs__reactive@0.4.0/node_modules/@jsr/mastrojs__mastro/src/core/html.ts","../esm/npm/@jsr/mastrojs__reactive@0.4.0/node_modules/@jsr/mastrojs__mastro/src/routers/common.ts","../esm/npm/@jsr/mastrojs__reactive@0.4.0/node_modules/@jsr/mastrojs__reactive/reactive.util.ts","../esm/npm/@jsr/mastrojs__reactive@0.4.0/node_modules/@jsr/mastrojs__reactive/reactive.ts"],"sourcesContent":["const SCOPE = Symbol(0);\n\nexport { SCOPE };\n","import { SCOPE } from './symbols.js';\n\nlet scheduledEffects = false, runningEffects = false, currentScope = null, currentObserver = null, currentObservers = null, currentObserversIndex = 0, effects = [], defaultContext = {};\nconst NOOP = () =\u003e {\n}, STATE_CLEAN = 0, STATE_CHECK = 1, STATE_DIRTY = 2, STATE_DISPOSED = 3;\nfunction flushEffects() {\n  scheduledEffects = true;\n  queueMicrotask(runEffects);\n}\nfunction runEffects() {\n  if (!effects.length) {\n    scheduledEffects = false;\n    return;\n  }\n  runningEffects = true;\n  for (let i = 0; i \u003c effects.length; i++) {\n    if (effects[i].$st !== STATE_CLEAN)\n      runTop(effects[i]);\n  }\n  effects = [];\n  scheduledEffects = false;\n  runningEffects = false;\n}\nfunction runTop(node) {\n  let ancestors = [node];\n  while (node = node[SCOPE]) {\n    if (node.$e \u0026\u0026 node.$st !== STATE_CLEAN)\n      ancestors.push(node);\n  }\n  for (let i = ancestors.length - 1; i \u003e= 0; i--) {\n    updateCheck(ancestors[i]);\n  }\n}\nfunction root(init) {\n  const scope = createScope();\n  return compute(scope, !init.length ? init : init.bind(null, dispose.bind(scope)), null);\n}\nfunction peek(fn) {\n  return compute(currentScope, fn, null);\n}\nfunction untrack(fn) {\n  return compute(null, fn, null);\n}\nfunction tick() {\n  if (!runningEffects)\n    runEffects();\n}\nfunction getScope() {\n  return currentScope;\n}\nfunction scoped(run, scope) {\n  try {\n    return compute(scope, run, null);\n  } catch (error) {\n    handleError(scope, error);\n    return;\n  }\n}\nfunction getContext(key, scope = currentScope) {\n  return scope?.$cx[key];\n}\nfunction setContext(key, value, scope = currentScope) {\n  if (scope)\n    scope.$cx = { ...scope.$cx, [key]: value };\n}\nfunction onError(handler) {\n  if (!currentScope)\n    return;\n  currentScope.$eh = currentScope.$eh ? [handler, ...currentScope.$eh] : [handler];\n}\nfunction onDispose(disposable) {\n  if (!disposable || !currentScope)\n    return disposable || NOOP;\n  const node = currentScope;\n  if (!node.$d) {\n    node.$d = disposable;\n  } else if (Array.isArray(node.$d)) {\n    node.$d.push(disposable);\n  } else {\n    node.$d = [node.$d, disposable];\n  }\n  return function removeDispose() {\n    if (node.$st === STATE_DISPOSED)\n      return;\n    disposable.call(null);\n    if (isFunction(node.$d)) {\n      node.$d = null;\n    } else if (Array.isArray(node.$d)) {\n      node.$d.splice(node.$d.indexOf(disposable), 1);\n    }\n  };\n}\nfunction dispose(self = true) {\n  if (this.$st === STATE_DISPOSED)\n    return;\n  if (this.$h) {\n    if (Array.isArray(this.$h)) {\n      for (let i = this.$h.length - 1; i \u003e= 0; i--) {\n        dispose.call(this.$h[i]);\n      }\n    } else {\n      dispose.call(this.$h);\n    }\n  }\n  if (self) {\n    const parent = this[SCOPE];\n    if (parent) {\n      if (Array.isArray(parent.$h)) {\n        parent.$h.splice(parent.$h.indexOf(this), 1);\n      } else {\n        parent.$h = null;\n      }\n    }\n    disposeNode(this);\n  }\n}\nfunction disposeNode(node) {\n  node.$st = STATE_DISPOSED;\n  if (node.$d)\n    emptyDisposal(node);\n  if (node.$s)\n    removeSourceObservers(node, 0);\n  node[SCOPE] = null;\n  node.$s = null;\n  node.$o = null;\n  node.$h = null;\n  node.$cx = defaultContext;\n  node.$eh = null;\n}\nfunction emptyDisposal(scope) {\n  try {\n    if (Array.isArray(scope.$d)) {\n      for (let i = scope.$d.length - 1; i \u003e= 0; i--) {\n        const callable = scope.$d[i];\n        callable.call(callable);\n      }\n    } else {\n      scope.$d.call(scope.$d);\n    }\n    scope.$d = null;\n  } catch (error) {\n    handleError(scope, error);\n  }\n}\nfunction compute(scope, compute2, observer) {\n  const prevScope = currentScope, prevObserver = currentObserver;\n  currentScope = scope;\n  currentObserver = observer;\n  try {\n    return compute2.call(scope);\n  } finally {\n    currentScope = prevScope;\n    currentObserver = prevObserver;\n  }\n}\nfunction handleError(scope, error) {\n  if (!scope || !scope.$eh)\n    throw error;\n  let i = 0, len = scope.$eh.length, currentError = error;\n  for (i = 0; i \u003c len; i++) {\n    try {\n      scope.$eh[i](currentError);\n      break;\n    } catch (error2) {\n      currentError = error2;\n    }\n  }\n  if (i === len)\n    throw currentError;\n}\nfunction read() {\n  if (this.$st === STATE_DISPOSED)\n    return this.$v;\n  if (currentObserver \u0026\u0026 !this.$e) {\n    if (!currentObservers \u0026\u0026 currentObserver.$s \u0026\u0026 currentObserver.$s[currentObserversIndex] == this) {\n      currentObserversIndex++;\n    } else if (!currentObservers)\n      currentObservers = [this];\n    else\n      currentObservers.push(this);\n  }\n  if (this.$c)\n    updateCheck(this);\n  return this.$v;\n}\nfunction write(newValue) {\n  const value = isFunction(newValue) ? newValue(this.$v) : newValue;\n  if (this.$ch(this.$v, value)) {\n    this.$v = value;\n    if (this.$o) {\n      for (let i = 0; i \u003c this.$o.length; i++) {\n        notify(this.$o[i], STATE_DIRTY);\n      }\n    }\n  }\n  return this.$v;\n}\nconst ScopeNode = function Scope() {\n  this[SCOPE] = null;\n  this.$h = null;\n  if (currentScope)\n    currentScope.append(this);\n};\nconst ScopeProto = ScopeNode.prototype;\nScopeProto.$cx = defaultContext;\nScopeProto.$eh = null;\nScopeProto.$c = null;\nScopeProto.$d = null;\nScopeProto.append = function(child) {\n  child[SCOPE] = this;\n  if (!this.$h) {\n    this.$h = child;\n  } else if (Array.isArray(this.$h)) {\n    this.$h.push(child);\n  } else {\n    this.$h = [this.$h, child];\n  }\n  child.$cx = child.$cx === defaultContext ? this.$cx : { ...this.$cx, ...child.$cx };\n  if (this.$eh) {\n    child.$eh = !child.$eh ? this.$eh : [...child.$eh, ...this.$eh];\n  }\n};\nScopeProto.dispose = function() {\n  dispose.call(this);\n};\nfunction createScope() {\n  return new ScopeNode();\n}\nconst ComputeNode = function Computation(initialValue, compute2, options) {\n  ScopeNode.call(this);\n  this.$st = compute2 ? STATE_DIRTY : STATE_CLEAN;\n  this.$i = false;\n  this.$e = false;\n  this.$s = null;\n  this.$o = null;\n  this.$v = initialValue;\n  if (compute2)\n    this.$c = compute2;\n  if (options \u0026\u0026 options.dirty)\n    this.$ch = options.dirty;\n};\nconst ComputeProto = ComputeNode.prototype;\nObject.setPrototypeOf(ComputeProto, ScopeProto);\nComputeProto.$ch = isNotEqual;\nComputeProto.call = read;\nfunction createComputation(initialValue, compute2, options) {\n  return new ComputeNode(initialValue, compute2, options);\n}\nfunction isNotEqual(a, b) {\n  return a !== b;\n}\nfunction isFunction(value) {\n  return typeof value === \"function\";\n}\nfunction updateCheck(node) {\n  if (node.$st === STATE_CHECK) {\n    for (let i = 0; i \u003c node.$s.length; i++) {\n      updateCheck(node.$s[i]);\n      if (node.$st === STATE_DIRTY) {\n        break;\n      }\n    }\n  }\n  if (node.$st === STATE_DIRTY)\n    update(node);\n  else\n    node.$st = STATE_CLEAN;\n}\nfunction cleanup(node) {\n  if (node.$h)\n    dispose.call(node, false);\n  if (node.$d)\n    emptyDisposal(node);\n  node.$eh = node[SCOPE] ? node[SCOPE].$eh : null;\n}\nfunction update(node) {\n  let prevObservers = currentObservers, prevObserversIndex = currentObserversIndex;\n  currentObservers = null;\n  currentObserversIndex = 0;\n  try {\n    cleanup(node);\n    const result = compute(node, node.$c, node);\n    updateObservers(node);\n    if (!node.$e \u0026\u0026 node.$i) {\n      write.call(node, result);\n    } else {\n      node.$v = result;\n      node.$i = true;\n    }\n  } catch (error) {\n    updateObservers(node);\n    handleError(node, error);\n  } finally {\n    currentObservers = prevObservers;\n    currentObserversIndex = prevObserversIndex;\n    node.$st = STATE_CLEAN;\n  }\n}\nfunction updateObservers(node) {\n  if (currentObservers) {\n    if (node.$s)\n      removeSourceObservers(node, currentObserversIndex);\n    if (node.$s \u0026\u0026 currentObserversIndex \u003e 0) {\n      node.$s.length = currentObserversIndex + currentObservers.length;\n      for (let i = 0; i \u003c currentObservers.length; i++) {\n        node.$s[currentObserversIndex + i] = currentObservers[i];\n      }\n    } else {\n      node.$s = currentObservers;\n    }\n    let source;\n    for (let i = currentObserversIndex; i \u003c node.$s.length; i++) {\n      source = node.$s[i];\n      if (!source.$o)\n        source.$o = [node];\n      else\n        source.$o.push(node);\n    }\n  } else if (node.$s \u0026\u0026 currentObserversIndex \u003c node.$s.length) {\n    removeSourceObservers(node, currentObserversIndex);\n    node.$s.length = currentObserversIndex;\n  }\n}\nfunction notify(node, state) {\n  if (node.$st \u003e= state)\n    return;\n  if (node.$e \u0026\u0026 node.$st === STATE_CLEAN) {\n    effects.push(node);\n    if (!scheduledEffects)\n      flushEffects();\n  }\n  node.$st = state;\n  if (node.$o) {\n    for (let i = 0; i \u003c node.$o.length; i++) {\n      notify(node.$o[i], STATE_CHECK);\n    }\n  }\n}\nfunction removeSourceObservers(node, index) {\n  let source, swap;\n  for (let i = index; i \u003c node.$s.length; i++) {\n    source = node.$s[i];\n    if (source.$o) {\n      swap = source.$o.indexOf(node);\n      source.$o[swap] = source.$o[source.$o.length - 1];\n      source.$o.pop();\n    }\n  }\n}\n\nexport { compute, createComputation, createScope, dispose, getContext, getScope, isFunction, isNotEqual, onDispose, onError, peek, read, root, scoped, setContext, tick, untrack, update, write };\n","import { createComputation, read, write, isFunction, update, dispose, onDispose } from './core.js';\nimport { SCOPE } from './symbols.js';\n\nfunction signal(initialValue, options) {\n  const node = createComputation(initialValue, null, options), signal2 = read.bind(node);\n  signal2[SCOPE] = true;\n  signal2.set = write.bind(node);\n  return signal2;\n}\nfunction isReadSignal(fn) {\n  return isFunction(fn) \u0026\u0026 SCOPE in fn;\n}\nfunction computed(compute, options) {\n  const node = createComputation(\n    options?.initial,\n    compute,\n    options\n  ), signal2 = read.bind(node);\n  signal2[SCOPE] = true;\n  return signal2;\n}\nfunction effect(effect2, options) {\n  const signal2 = createComputation(\n    null,\n    function runEffect() {\n      let effectResult = effect2();\n      isFunction(effectResult) \u0026\u0026 onDispose(effectResult);\n      return null;\n    },\n    void 0\n  );\n  signal2.$e = true;\n  update(signal2);\n  return dispose.bind(signal2, true);\n}\nfunction readonly(signal2) {\n  const readonly2 = () =\u003e signal2();\n  readonly2[SCOPE] = true;\n  return readonly2;\n}\nfunction isWriteSignal(fn) {\n  return isReadSignal(fn) \u0026\u0026 \"set\" in fn;\n}\n\nexport { computed, effect, isReadSignal, isWriteSignal, readonly, signal };\n","const fs = typeof document === \"object\"\n  ? undefined\n  : await import(\"node:fs/promises\");\n\n// we use document.fs because dnt would add a shim for window https://github.com/denoland/dnt/issues/454\nconst vscodeExtensionFs = typeof document === \"object\"\n  ? (document as any).fs\n  : undefined;\n\n/**\n * Path separator: `\\` on Windows, `/` everywhere else.\n */\nexport const sep: \"/\" | \"\\\\\" = typeof document === \"object\" ? \"/\" : (await import(\"node:path\")).sep;\n\n/**\n * Read the directory on the local file system and return its files,\n * non-recursive and ignoring symlinks.\n *\n * Input path needs to be relative to project root.\n */\nexport const readDir = (path: string): Promise\u003cstring[]\u003e =\u003e\n  fs\n    ? fs.readdir(noLeadingSep(path), { withFileTypes: true })\n      .then((files) =\u003e\n        files.flatMap((file) =\u003e\n          file.isSymbolicLink() || file.isDirectory() || file.name[0] === \".\" ? [] : file.name\n        )\n      )\n    : vscodeExtensionFs.readDir(leadingSep(path));\n\n/**\n * Return the contents of a text file on the local file system as a string.\n *\n * Input path needs to be relative to project root.\n */\nexport const readTextFile = (path: string): Promise\u003cstring\u003e =\u003e\n  fs\n    ? fs.readFile(noLeadingSep(path), { encoding: \"utf8\" })\n    : vscodeExtensionFs.readTextFile(leadingSep(path));\n\n/**\n * Return the contents of a binary file on the local file system.\n *\n * Input path needs to be relative to project root.\n */\nexport const readFile = (path: string): Promise\u003cUint8Array\u003cArrayBufferLike\u003e\u003e =\u003e\n  fs\n    ? fs.readFile(noLeadingSep(path))\n    : vscodeExtensionFs.readFile(leadingSep(path));\n\n/**\n * Return the file paths on the local file system,\n * expanding glob patterns like `*` and `**`.\n *\n * Supported patterns depend on the platform:\n *\n * - [VSCode for the Web](https://code.visualstudio.com/api/references/vscode-api#GlobPattern)\n *   (although currently [broken](https://github.com/microsoft/vscode/issues/249197))\n * - [others](https://nodejs.org/api/fs.html#fspromisesglobpattern-options)\n */\nexport const findFiles = async (pattern: string): Promise\u003cstring[]\u003e =\u003e {\n  pattern = pattern.startsWith(\"/\") ? pattern.slice(1) : pattern;\n  if (fs) {\n    const paths = [];\n    // @ts-expect-error no type definitions for Bun\n    if (typeof Bun === \"object\") {\n      const { basename } = await import(\"node:path\");\n      // until https://github.com/oven-sh/bun/issues/22018 is fixed\n      for await (const file of fs.glob(pattern)) {\n        const entry = await fs.lstat(file);\n        if (entry.isFile() \u0026\u0026 !entry.isSymbolicLink() \u0026\u0026 basename(file)[0] !== \".\") {\n          paths.push(sep + file)\n        }\n      }\n    } else {\n      for await (const entry of fs.glob(pattern, { withFileTypes: true })) {\n        if (entry.isFile() \u0026\u0026 !entry.isSymbolicLink() \u0026\u0026 entry.name[0] !== \".\") {\n          const path = entry.parentPath + sep + entry.name;\n          const relativeToProjectRoot = path.slice(process.cwd().length);\n          paths.push(relativeToProjectRoot);\n        }\n      }\n    }\n    return paths;\n  } else {\n    return vscodeExtensionFs.findFiles(pattern);\n  }\n};\n\nconst leadingSep = (path: string) =\u003e\n  path.startsWith(sep) ? path : \"/\" + path;\nconst noLeadingSep = (path: string) =\u003e\n  path.startsWith(sep) ? path.slice(1) : path;\n","/**\n * This module contains a simple, selfcontained way to construct and properly escape\n * HTML using JavaScript tagged template literals.\n * It is exported separately for use in `@mastrojs/reactive`\n * @module\n */\n\n/**\n * HTML primitive values like strings and numbers.\n *\n * Note that we use [`String` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)\n * to store already properly escaped HTML.\n */\n// deno-lint-ignore ban-types\nexport type HtmlPrimitive = String | string | number | undefined | null | false;\n\n/**\n * An `Html` node – i.e. what can be used with `html` tagged templates.\n */\nexport type Html =\n  | HtmlPrimitive\n  | Html[]\n  | AsyncIterable\u003cHtml\u003e\n  | Promise\u003cHtmlPrimitive\u003e\n  | Promise\u003cHtml[]\u003e;\n\n/**\n * Tagged template literal to construct `Html` nodes.\n * This makes sure things are properly escaped (unless `unsafeInnerHtml` is used).\n *\n * ```ts\n * import { html, renderToString } from \"@mastrojs/mastro\";\n *\n * const myName = \"World\";\n * const myClass = \"hero\";\n *\n * const str = await renderToString(\n *   html`\u003ch1 class=${myClass}\u003eHello ${myName}\u003c/h1\u003e`\n * );\n * ```\n */\nexport const html = (strings: TemplateStringsArray, ...params: Html[]): Html[] =\u003e {\n  const output: Html[] = [];\n  let insideTag = false;\n  for (let i = 0; i \u003c strings.length; i++) {\n    const str = strings[i];\n    output.push(unsafeInnerHtml(str));\n    insideTag = (insideTag ? 1 : 0) + nrOf(str, \"\u003c\") - nrOf(str, \"\u003e\") === 1;\n    if (i \u003c params.length) {\n      const p = params[i];\n      if (Array.isArray(p)) {\n        output.push(...p);\n      } else if (insideTag \u0026\u0026 endsWithEq(output.at(-1))) {\n        // add quotes around attribute for e.g. html`\u003cdiv class=${'my class'}\u003e\u003c/div\u003e`\n        output.push(unsafeInnerHtml('\"'), p, unsafeInnerHtml('\"'));\n      } else {\n        output.push(p);\n      }\n    }\n  }\n  return output;\n};\n\n/**\n * Mark a string as already properly escaped HTML. Do not use this on an untrusted/user-supplied string!\n *\n * This is similar to the DOM's [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#replacing_the_contents_of_an_element)\n * or React's `dangerouslySetInnerHTML`.\n */\nexport const unsafeInnerHtml = (str: string): Html =\u003e\n  // Alternatively, we could also use a plain object like `{ type: 'html', str }`\n  // but the String object's `.toString()` and `.valueOf()` behaviour are handy.\n  new String(str);\n\n/**\n * Convert an `Html` node to a properly escaped `Promise\u003cstring\u003e`.\n *\n * See `renderToStream` for a more efficient but less ergonomic alternative.\n */\nexport const renderToString = async (node: Html): Promise\u003cstring\u003e =\u003e {\n  const s = renderToStream(node);\n  return typeof s === \"string\" ? s : (await Array.fromAsync(s)).join(\"\");\n}\n\n/**\n * Convert an `Html` node to a properly escaped stream.\n * Returns an `AsyncIterable\u003cstring\u003e` if there are Promises or AsyncIterables in the input,\n * otherwise returns a `string`.\n *\n * The string case is a lot more efficient – especially when then passed to\n * Mastro's `htmlResponse`, to construct a `Response`.\n */\nexport const renderToStream = (node: Html): string | AsyncIterable\u003cstring\u003e =\u003e {\n  let stack: Array\u003cHtml | AsyncIterator\u003cHtml\u003e\u003e = [node];\n  if (Array.isArray(node)) {\n    stack = node.flat(Infinity as 1);\n    if (!(stack.some((n) =\u003e n instanceof Promise || isAsyncIterable(n)))) {\n      // if there is nothing async, we can speed things up by an order of magnitude like this\n      let str = \"\";\n      for (let i = 0; i \u003c stack.length; i++) {\n        // in my limited testing, this is faster than `stack.map(escape).join(\"\")`\n        str += escape(stack[i] as HtmlPrimitive);\n      }\n      return str;\n    }\n  }\n\n  // reversing and using pop() is faster than using shift().\n  // However, we could investigate whether keeping a manual index would be better,\n  // but garbage collection would probably suffer.\n  stack.reverse();\n  return {\n    [Symbol.asyncIterator]() {\n      return {\n        next: async () =\u003e {\n          while (stack.length \u003e 0) {\n            const nextUp = stack[stack.length - 1];\n            if (typeof nextUp === \"object\" \u0026\u0026 nextUp !== null \u0026\u0026 \"next\" in nextUp) {\n              // If an iterator is on top of the stack, consume its next element.\n              // But only pop the iterator itself from the stack when it's done.\n              const { value, done } = await nextUp.next();\n              if (done) {\n                stack.pop();\n              } else {\n                stack.push(value);\n              }\n            } else {\n              const current = await stack.pop();\n              if (Array.isArray(current)) {\n                for (let i = current.length - 1; i \u003e= 0; i--) {\n                  stack.push(current[i]);\n                }\n              } else if (isAsyncIterable(current)) {\n                // push iterator on stack for future consumption\n                const iterator = current[Symbol.asyncIterator]();\n                stack.push(iterator);\n              } else {\n                return { value: escape(current as HtmlPrimitive), done: false };\n              }\n            }\n          }\n          return { value: undefined, done: true };\n        },\n      };\n    },\n  };\n};\n\nconst escape = (n: HtmlPrimitive): string =\u003e\n  typeof n === \"string\"\n    ? escapeForAttribute(n)\n    : (n || typeof n === \"number\") ? n.toString() : \"\";\n\nconst escapeForHtml = (st: string) =\u003e\n  st.replaceAll(\"\u0026\", \"\u0026amp;\")\n    .replaceAll(\"\u003c\", \"\u0026lt;\")\n    .replaceAll(\"\u003e\", \"\u0026gt;\");\n\nconst escapeForAttribute = (str: string) =\u003e\n  escapeForHtml(str)\n    .replaceAll(\"'\", \"\u0026#39;\")\n    .replaceAll('\"', \"\u0026quot;\");\n\nconst isAsyncIterable = \u003cT\u003e(val: any): val is AsyncIterable\u003cT\u003e =\u003e\n  val \u0026\u0026 typeof val[Symbol.asyncIterator] === \"function\";\n\nconst endsWithEq = (prev: Html) =\u003e\n  typeof prev === \"object\" \u0026\u0026\n  typeof (prev as string)?.endsWith === \"function\" \u0026\u0026\n  (prev as string).endsWith(\"=\");\n\n/**\n * `nrOf(str, char)` returns the number of times `char` occurs in `str`\n */\nconst nrOf = (str: string, char: string) =\u003e str.split(char).length - 1;\n","// @ts-ignore: Bun doesn't implement URLPattern: https://github.com/oven-sh/bun/issues/2286\nif (typeof Bun === \"object\" \u0026\u0026 !globalThis.URLPattern) {\n  // use variable to prevent esbuild from trying to bundle the import\n  const polyfill = \"urlpattern-polyfill\";\n  await import(polyfill);\n}\n\n/** Supported HTTP methods */\nexport const httpMethods = [\"GET\", \"HEAD\", \"POST\", \"PUT\", \"DELETE\", \"OPTIONS\", \"PATCH\"] as const;\n\n/** Supported HTTP methods */\nexport type HttpMethod = (typeof httpMethods)[number];\n\n/** A fetch handler that takes a standard `Request` and returns a standard `Response` */\nexport type Handler = (req: Request) =\u003e Promise\u003cResponse\u003e | Response;\n\n/**\n * A Mastro Route\n */\nexport interface Route {\n  /**\n   * Name of the route for error messages etc.\n   * For file-based routes the `filePath`, e.g. `/routes/index.server.ts`\n   */\n  name: string;\n  /** Fetch handler */\n  handler: Handler;\n  /** HTTP method, or \"all\" if the route should match any HTTP method. */\n  method: \"all\" | HttpMethod;\n  /** `URLPattern` with `pathname` set */\n  pattern: URLPattern;\n  /** Called by the static site generator on routes with route parameters in the pattern. */\n  getStaticPaths?: () =\u003e Promise\u003cstring[]\u003e | string[];\n  /** When running a server, set this to `true` to still build this route statically. */\n  pregenerate?: true;\n}\n","export const parseBind = (bind: string) =\u003e {\n  const parts = bind.split('=')\n  const [lhs, rhs] = parts.length === 2\n    ? [parts[0].trim(), parts[1].trim()]\n    : ['innerHTML', bind.trim()]\n\n  const [prop, subprop] = lhs.split('.') as Array\u003cstring | undefined\u003e\n  if (!prop) {\n    return { error: 'Found invalid data-bind value', args: [] }\n  }\n\n  const [fieldOrMethod, rawArgs] = rhs.split('(')\n  const args = parseArgs(rawArgs)\n  return { prop, subprop, fieldOrMethod, args }\n}\n\nexport const parseArgs = (rawArgs: string | undefined) =\u003e {\n  if (!rawArgs) return []\n  if (rawArgs.endsWith(')')) {\n    rawArgs = rawArgs.slice(0, -1)\n  }\n  return rawArgs.split(',').map(a =\u003e a.trim())\n    .map(a =\u003e {\n      if (a.startsWith(\"'\") \u0026\u0026 a.endsWith(\"'\")) {\n       return a.slice(1, -1)\n      } else if (a === 'true') {\n        return true\n      } else if (a === 'false') {\n        return false\n      } else {\n        const n = parseFloat(a)\n        return isNaN(n) ? a : n\n      }\n    })\n}\n","/**\n * This module contains [Reactive Mastro](https://mastrojs.github.io/reactive/)\n * – a tiny reactive GUI library that runs in your browser.\n * @module\n */\n\nimport * as signals from '@maverick-js/signals'\nimport { renderToString } from '@jsr/mastrojs__mastro'\nimport { parseArgs, parseBind } from \"./reactive.util.js\";\n\nexport {\n  type Html,\n  type HtmlPrimitive,\n  html,\n  renderToStream,\n  renderToString,\n  unsafeInnerHtml,\n} from '@jsr/mastrojs__mastro'\n\n/**\n * Creates a new signal whose value is computed and returned by the given function.\n * The given compute function is only re-run when one of its dependencies are updated.\n *\n * See [@maverick-js/signals#computed](https://github.com/maverick-js/signals#computed)\n */\nexport const computed = signals.computed\n\n/**\n * Invokes the given function each time any of the signals that are read inside are updated (i.e., their value changes)\n *\n * See [@maverick-js/signals#computed](https://github.com/maverick-js/signals#effect)\n */\nexport const effect = signals.effect\n\n/**\n * Wraps the given value into a signal.\n *\n * See [@maverick-js/signals#computed](https://github.com/maverick-js/signals#signal)\n */\nexport const signal = signals.signal\n\nif (typeof HTMLElement !== \"function\") {\n  // if this module happens to get imported server-side,\n  // this hack avoids it from crashing on import\n  globalThis.HTMLElement = class Foo {} as any\n}\n\n/**\n * Base class for reactive elements. Extends [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements).\n * For usage, see the [Reactive Mastro website](https://mastrojs.github.io/reactive/).\n */\nexport class ReactiveElement extends HTMLElement {\n  #dispose?: signals.Dispose\n  /** override this field in your class constructor as necessary */\n  #eventNames = ['click', 'change', 'input', 'submit']\n\n  async connectedCallback () {\n    if (this.#dispose) {\n      // connectedCallback is also called when custom element is moved,\n      // but we want to run the setup only once\n      return\n    }\n\n    this.#eventNames.forEach(eventName =\u003e\n      // to support events on elements that are added after custom element creation,\n      // we add a listener to the custom element for each common event name and let the event bubble up there\n      (this.shadowRoot || this).addEventListener(eventName, e =\u003e {\n        const { target } = e\n        const value = target \u0026\u0026 target instanceof HTMLElement\n          ? target.dataset['on' + eventName]\n          : undefined\n        if (value) {\n          e.stopPropagation()\n          const [methodName, rawArgs] = value.split('(')\n          const args = parseArgs(rawArgs)\n          // @ts-ignore noImplicitAny\n          if (typeof this[methodName] === 'function') {\n            // @ts-ignore noImplicitAny\n            this[methodName](...args, e)\n          } else {\n            console.warn(`${this.nodeName.toLowerCase()}#${methodName.toString()} is not a function`)\n          }\n        }\n      })\n    )\n\n    // @ts-ignore key initialHtml does not exist\n    if (typeof this.initialHtml === 'function' \u0026\u0026 !this.innerHTML.trim()) {\n      (this.shadowRoot || this).innerHTML = await renderToString(\n        // @ts-ignore key initialHtml does not exist\n        this.initialHtml()\n      )\n    }\n\n    for (const attr of this.attributes) {\n      if (!attr.name.startsWith('data-')) {\n        // in order to have a uniform interface for component props,\n        // we create signals from static attributes and assign them to fields\n        // @ts-ignore noImplicitAny\n        this[attr.name] = () =\u003e attr.value\n      }\n    }\n\n    setTimeout(() =\u003e {\n      signals.root(dispose =\u003e {\n        this.#dispose = dispose\n\n        const registerRenderingEffects = (rootEl: Element | ShadowRoot) =\u003e {\n          for (const el of rootEl.querySelectorAll(`[data-bind]`)) {\n            if (el instanceof HTMLElement \u0026\u0026 !isChildOfOtherCustomElement(rootEl, el)) {\n              for (const bind of el.dataset.bind?.split(';') || []) {\n                const { error, prop, subprop, fieldOrMethod, args } = parseBind(bind)\n                if (error) {\n                  console.warn(error, el)\n                // @ts-ignore noImplicitAny\n                } else if (typeof this[fieldOrMethod] !== 'function') {\n                  console.warn(`${this.nodeName.toLowerCase()}#${fieldOrMethod\n                    } is not a signal or method`, el)\n                } else {\n                  effect(() =\u003e {\n                    // @ts-ignore noImplicitAny\n                    const val = this[fieldOrMethod](...args)\n                    if (prop === 'class' \u0026\u0026 subprop) {\n                      // e.g. data-bind=\"class.myClass = myField\"\n                      el.classList[val ? 'add' : 'remove'](subprop)\n                    } else if (prop === 'props' \u0026\u0026 subprop) {\n                      // e.g. data-bind=\"props.myChildField = myParentField\"\n                      // @ts-ignore noImplicitAny\n                      el[subprop] = this[fieldOrMethod]\n                    } else if (prop === 'attributes' \u0026\u0026 subprop) {\n                      // e.g. data-bind=\"attributes.myKey = myField\"\n                      if (val === null) {\n                        el.removeAttribute(subprop)\n                      } else {\n                        el.setAttribute(subprop, val)\n                      }\n                    } else if (subprop) {\n                      // e.g. data-bind=\"dataset.myKey = myField\"\n                      // @ts-ignore noImplicitAny\n                      el[prop][subprop] = val\n                    } else if (prop === 'innerHTML') {\n                      // e.g. data-bind=\"myField\"\n                      renderToString(val).then(v =\u003e {\n                        el[prop] = v\n                        registerRenderingEffects(el)\n                      })\n                    } else {\n                      // e.g. data-bind=\"required = myField\"\n                      // @ts-ignore noImplicitAny\n                      el[prop] = val\n                    }\n                  })\n                }\n              }\n            }\n          }\n        }\n        registerRenderingEffects(this.shadowRoot || this)\n      })\n    })\n  }\n\n  disconnectedCallback () {\n    this.#dispose?.()\n  }\n}\n\nconst isChildOfOtherCustomElement = (rootEl: Element | ShadowRoot, el: Element) =\u003e {\n  let p = el.parentElement\n  while (p \u0026\u0026 p !== rootEl) {\n    if (p.nodeName.includes('-')) {\n      return true\n    }\n    p = p.parentElement\n  }\n}\n"],"version":3}
