{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["const clientReferenceType = Symbol.for(\"srv-jsx.client-reference\");\nconst nodeMarker = Symbol.for(\"srv-jsx.node\");\n\nconst voidElementNames = \" area base br col embed hr img input link meta param source track wbr \";\nconst hoistableHeadElementNames = \" base link meta title \";\nconst headMarkerName = \"srv-jsx-head\";\nconst attributeNamePattern = /^[A-Za-z_:][A-Za-z0-9:_.-]*$/;\nconst svgDashCaseAttributeNames =\n  \" accentHeight alignmentBaseline arabicForm baselineShift capHeight clipPath clipRule colorInterpolation colorInterpolationFilters colorProfile colorRendering dominantBaseline enableBackground fillOpacity fillRule floodColor floodOpacity fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight glyphName glyphOrientationHorizontal glyphOrientationVertical horizAdvX horizOriginX imageRendering letterSpacing lightingColor markerEnd markerMid markerStart overlinePosition overlineThickness paintOrder stopColor stopOpacity strikethroughPosition strikethroughThickness strokeDasharray strokeDashoffset strokeLinecap strokeLinejoin strokeMiterlimit strokeOpacity strokeWidth textAnchor textDecoration textRendering underlinePosition underlineThickness unicodeBidi unicodeRange unitsPerEm vAlphabetic vHanging vIdeographic vMathematical vectorEffect vertAdvY vertOriginX vertOriginY wordSpacing writingMode xHeight \";\nconst svgColonAttributeNames =\n  \" xlinkActuate xlinkArcrole xlinkHref xlinkRole xlinkShow xlinkTitle xlinkType xmlBase xmlLang xmlSpace xmlnsXlink \";\n\nexport const Fragment = Symbol.for(\"srv-jsx.fragment\");\n\n/** A callable-typed symbol so `<Marker />` type-checks as a JSX component. */\nexport const Marker: (props: MarkerProps) => JSXElement = Symbol.for(\n  \"srv-jsx.marker\",\n) as unknown as (props: MarkerProps) => JSXElement;\n\ndeclare const clientReferenceMarker: unique symbol;\n\ndeclare global {\n  interface GlobalEventHandlersEventMap {}\n}\n\nexport type AttributeValue = string | number | boolean | null | undefined;\nexport type Component<P extends Record<any, any> = any> = (props: P) => JSXChild;\nexport type ClientReferenceValue<Argument = unknown> = {\n  bind(_this: unknown, ...bound: readonly unknown[]): ClientReferenceValue<Argument>;\n  readonly [clientReferenceMarker]: {\n    bivarianceHack(value: Argument): void;\n  }[\"bivarianceHack\"];\n};\ntype EventAttributeValue<EventType extends Event = Event> =\n  | ClientReferenceValue<EventType>\n  | { bivarianceHack(this: EventTarget, event: EventType): void }[\"bivarianceHack\"]\n  | {\n      handleEvent(event: EventType): void;\n    };\ntype RefAttributeValue<ElementType extends Element = Element> =\n  | ClientReferenceValue<ElementType>\n  | { bivarianceHack(ref: ElementType): void }[\"bivarianceHack\"];\ntype KnownEventName = Extract<keyof GlobalEventHandlersEventMap, string>;\ntype KnownEventAttributes = {\n  [EventName in KnownEventName as `on${EventName}`]?:\n    | AttributeValue\n    | EventAttributeValue<GlobalEventHandlersEventMap[EventName]>\n    | JSXChild;\n};\ntype KnownIntrinsicElementName = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap;\ntype IntrinsicElementFor<Name extends string> = Name extends keyof HTMLElementTagNameMap\n  ? Name extends keyof SVGElementTagNameMap\n    ? HTMLElementTagNameMap[Name] | SVGElementTagNameMap[Name]\n    : HTMLElementTagNameMap[Name]\n  : Name extends keyof SVGElementTagNameMap\n    ? SVGElementTagNameMap[Name]\n    : Element;\ntype KnownIntrinsicElements = {\n  [Name in KnownIntrinsicElementName]: JSXProps<IntrinsicElementFor<Name>>;\n};\nexport type JSXChild =\n  | JSXElement\n  | string\n  | number\n  | boolean\n  | null\n  | undefined\n  | PromiseLike<unknown>\n  | readonly JSXChild[];\n\nexport interface JSXProps<RefElement extends Element = Element> extends KnownEventAttributes {\n  children?: JSXChild;\n  innerHTML?: string;\n  ref?: RefAttributeValue<RefElement>;\n  [property: `on${string}`]: AttributeValue | EventAttributeValue | JSXChild;\n  [property: string]: AttributeValue | EventAttributeValue | RefAttributeValue | JSXChild;\n}\n\nexport interface MarkerProps {\n  children?: JSXChild;\n  name: string;\n}\n\nexport interface SuspenseProps {\n  children?: JSXChild;\n  fallback?: JSXChild;\n}\n\nexport interface ErrorBoundaryProps {\n  children?: JSXChild;\n  fallback?: JSXChild;\n}\n\nexport interface ClientEvent {\n  readonly event: string;\n  readonly reference: unknown;\n}\n\nexport interface RenderOptions {\n  bootstrapModules?: readonly string[];\n  bootstrapScripts?: readonly string[];\n  encodeLoadReference?: (reference: ClientReference) => string;\n  idPrefix?: string;\n  nonce?: string;\n  onError?: (error: unknown) => void;\n  prerender?: boolean;\n  signal?: AbortSignal;\n}\n\nexport type RenderReadableStream = ReadableStream<Uint8Array>;\n\ntype ClientReferenceDefinition = {\n  readonly bound?: readonly unknown[];\n  readonly deps: readonly string[];\n  readonly id: string;\n  readonly mod: string;\n  readonly name: string;\n};\n\ninterface ClientReference {\n  bind(_this: unknown, ...bound: readonly unknown[]): ClientReference;\n  readonly bound?: readonly unknown[];\n  readonly deps: readonly string[];\n  readonly id: string;\n  readonly mod: string;\n  readonly name: string;\n  readonly type: typeof clientReferenceType;\n}\n\ntype InternalClientEffect =\n  | {\n      readonly event: string;\n      readonly kind: \"event\";\n      readonly reference: ClientReference;\n    }\n  | {\n      readonly kind: \"ref\";\n      readonly reference: ClientReference;\n    };\n\ninterface ComponentNode {\n  readonly [nodeMarker]: true;\n  readonly kind: \"component\";\n  readonly props: JSXProps;\n  readonly type: Component;\n}\n\ninterface ElementNode {\n  readonly [nodeMarker]: true;\n  readonly kind: \"element\";\n  readonly props: JSXProps;\n  readonly tagName: string;\n}\n\ninterface ErrorBoundaryNode {\n  readonly [nodeMarker]: true;\n  readonly children: JSXChild;\n  readonly fallback: JSXChild;\n  readonly kind: \"error-boundary\";\n}\n\ninterface SuspenseNode {\n  readonly [nodeMarker]: true;\n  readonly children: JSXChild;\n  readonly fallback: JSXChild;\n  readonly kind: \"suspense\";\n}\n\ninterface MarkerNode {\n  readonly [nodeMarker]: true;\n  readonly children: JSXChild;\n  readonly name: string;\n  readonly kind: \"marker\";\n}\n\nexport type JSXElement =\n  | ComponentNode\n  | ElementNode\n  | ErrorBoundaryNode\n  | SuspenseNode\n  | MarkerNode;\n\ninterface BoundaryResult {\n  error?: unknown;\n  html: string;\n  task: BoundaryTask;\n}\n\ninterface ErrorHandler {\n  fallback: JSXChild;\n  name: string;\n  path: string;\n  state: RenderState;\n}\n\ninterface BoundaryTask {\n  handler: ErrorHandler | undefined;\n}\n\ninterface Writer {\n  flush?(): void;\n  readonly length?: number;\n  write(chunk: string): void;\n}\n\ninterface BufferedWriter extends Writer {\n  html: string;\n}\n\ninterface ChunkQueueItem {\n  done: boolean;\n  value?: string;\n}\n\ninterface HeadScope {\n  chunks: string[];\n  kind: \"root\" | \"template\";\n  /** Writer offsets of the held chunks, for restoring them inline when no <head> is seen. */\n  positions: number[];\n  /** Writer offset just after the `<html>` opening tag, for synthesizing a `<head>`. */\n  htmlPosition?: number;\n}\n\ntype RenderNamespace = \"html\" | \"svg\";\ntype SuspenseRenderMode = \"prerender\" | \"streaming\";\n\ninterface RenderState {\n  deferHead: boolean;\n  doc: boolean;\n  head: HeadScope;\n  inHead: boolean;\n  /** True while rendering output of a Suspense boundary (fallback or template). */\n  inSuspense: boolean;\n  ns: RenderNamespace;\n}\n\n/**\n * Buffers complete tree strings and only materializes chunks at explicit\n * flush points. `write()` must only ever receive COMPLETE trees (the whole\n * shell, a whole Suspense/error template) — never partial tags — so every\n * emitted chunk is an entire `<tag>...</tag>` unit.\n */\n\nclass ChunkQueue implements Writer {\n  private buffer = \"\";\n  private readonly chunks: string[] = [];\n  private closed = false;\n  private waiter: PromiseWithResolvers<void> | undefined;\n\n  close() {\n    if (this.closed) {\n      return;\n    }\n\n    this.flush();\n    this.closed = true;\n    this.resolveWaiter();\n  }\n\n  async next(): Promise<ChunkQueueItem> {\n    const value = this.chunks.shift();\n\n    if (value !== undefined) {\n      return { done: false, value };\n    }\n\n    if (this.closed) {\n      return { done: true };\n    }\n\n    const waiter = Promise.withResolvers<void>();\n\n    this.waiter = waiter;\n    await waiter.promise;\n\n    return this.next();\n  }\n\n  flush() {\n    if (this.buffer.length > 0 && !this.closed) {\n      this.chunks.push(this.buffer);\n      this.buffer = \"\";\n      this.resolveWaiter();\n      return;\n    }\n\n    this.resolveWaiter();\n  }\n\n  write(chunk: string) {\n    if (chunk.length === 0 || this.closed) {\n      return;\n    }\n\n    this.buffer += chunk;\n  }\n\n  private resolveWaiter() {\n    const waiter = this.waiter;\n\n    if (waiter === undefined) {\n      return;\n    }\n\n    this.waiter = undefined;\n    waiter.resolve();\n  }\n}\n\nclass RenderContext {\n  private abort: (() => void) | undefined;\n  private aborted: Promise<never>;\n  private rejectBoundary: ((error: unknown) => void) | undefined;\n  private resolveBoundary: ((result: BoundaryResult) => void) | undefined;\n  public boundaries: BoundaryResult[] = [];\n  private flushedHead = false;\n  private shellDone = false;\n  readonly pending = new Set<BoundaryTask>();\n  private readonly handlers: ErrorHandler[] = [];\n\n  constructor(\n    readonly encodeLoadReference: (reference: ClientReference) => string,\n    private readonly prefix: string,\n    private readonly nonce: string | undefined,\n    private readonly onError: ((error: unknown) => void) | undefined,\n    private readonly signal: AbortSignal,\n    private readonly shellReady: PromiseWithResolvers<void>,\n    readonly suspenseMode: SuspenseRenderMode,\n  ) {\n    let rejectAbortPromise!: (error: unknown) => void;\n    this.aborted = new Promise<never>((_resolve, reject) => {\n      rejectAbortPromise = reject;\n    });\n    this.aborted.catch(() => {});\n\n    this.abort = () => {\n      const reason = getAbortReason(signal);\n      rejectAbortPromise(reason);\n      this.rejectBoundary?.(reason);\n    };\n\n    if (signal.aborted) {\n      this.abort();\n    } else {\n      signal.addEventListener(\"abort\", this.abort, { once: true });\n    }\n  }\n\n  boundaryName(path: string) {\n    return `${this.prefix}${hashBoundaryPath(path)}`;\n  }\n\n  createRootRenderState(): RenderState {\n    return {\n      deferHead: false,\n      doc: true,\n      head: { chunks: [], kind: \"root\", positions: [] },\n      inHead: false,\n      inSuspense: false,\n      ns: \"html\",\n    };\n  }\n\n  createTemplateRenderState(parentState?: RenderState): RenderState {\n    return {\n      deferHead: false,\n      doc: parentState?.doc ?? true,\n      head: { chunks: [], kind: \"template\", positions: [] },\n      inHead: false,\n      inSuspense: true,\n      ns: parentState?.ns ?? \"html\",\n    };\n  }\n\n  hasFlushedHead() {\n    return this.flushedHead;\n  }\n\n  hasShellReady() {\n    return this.shellDone;\n  }\n\n  flushHead(state: RenderState) {\n    this.flushedHead = true;\n    const html = `${state.head.chunks.join(\"\")}${renderHeadMarker()}`;\n    state.head.chunks = [];\n    state.head.positions = [];\n    return html;\n  }\n\n  renderHeadTemplate(html: string) {\n    return `<template for=\"${headMarkerName}\">${html}${renderHeadMarker()}</template>`;\n  }\n\n  renderNonceAttribute() {\n    return this.nonce === undefined ? \"\" : ` nonce=\"${escapeAttribute(this.nonce)}\"`;\n  }\n\n  renderBootstrapScripts(\n    scripts: readonly string[] | undefined,\n    modules: readonly string[] | undefined,\n  ) {\n    let html = \"\";\n\n    if (scripts !== undefined) {\n      for (const src of scripts) {\n        html += `<script src=\"${escapeAttribute(src)}\"${this.renderNonceAttribute()} async></script>`;\n      }\n    }\n\n    if (modules !== undefined) {\n      for (const src of modules) {\n        html += `<script type=\"module\" src=\"${escapeAttribute(src)}\"${this.renderNonceAttribute()} async></script>`;\n      }\n    }\n\n    return html;\n  }\n\n  renderScript(content: string) {\n    return `<script${this.renderNonceAttribute()}>${escapeScriptContent(content)}</script>`;\n  }\n\n  reportError(error: unknown) {\n    if (this.onError === undefined || this.isAbortError(error)) {\n      return;\n    }\n\n    try {\n      this.onError(error);\n    } catch {\n      // Logging failures should not affect rendering.\n    }\n  }\n\n  scheduleTemplate(name: string, children: JSXChild, path: string, parentState: RenderState) {\n    const task: BoundaryTask = { handler: this.currentErrorHandler() };\n\n    this.pending.add(task);\n\n    void (async () => {\n      try {\n        const state = this.createTemplateRenderState(parentState);\n        const html = await renderToBufferedString(children, this, path, state);\n\n        this.completeBoundary({\n          html: `<template for=\"${escapeAttribute(name)}\">${html}</template>`,\n          task,\n        });\n      } catch (error) {\n        this.completeBoundary({ error, html: \"\", task });\n      }\n    })();\n  }\n\n  async nextBoundaryResult() {\n    const result = this.boundaries.shift();\n\n    if (result !== undefined) {\n      return result;\n    }\n\n    this.throwIfAborted();\n\n    return new Promise<BoundaryResult>((resolve, reject) => {\n      this.resolveBoundary = (boundaryResult) => {\n        this.rejectBoundary = undefined;\n        this.resolveBoundary = undefined;\n        resolve(boundaryResult);\n      };\n      this.rejectBoundary = (error) => {\n        this.rejectBoundary = undefined;\n        this.resolveBoundary = undefined;\n        reject(error);\n      };\n    });\n  }\n\n  throwIfAborted() {\n    throwIfAborted(this.signal);\n  }\n\n  async waitFor<T>(value: PromiseLike<T>) {\n    this.throwIfAborted();\n    return Promise.race([value, this.aborted]);\n  }\n\n  async withErrorHandler<T>(handler: ErrorHandler, run: () => Promise<T>): Promise<T> {\n    this.handlers.push(handler);\n\n    try {\n      return await run();\n    } finally {\n      this.handlers.pop();\n    }\n  }\n\n  isAbortError(error: unknown) {\n    return this.signal.aborted && Object.is(error, getAbortReason(this.signal));\n  }\n\n  markShellReady() {\n    if (this.shellDone) {\n      return;\n    }\n\n    this.shellDone = true;\n    this.shellReady.resolve();\n  }\n\n  rejectShellReady(error: unknown) {\n    if (this.shellDone) {\n      return;\n    }\n\n    this.shellDone = true;\n    this.shellReady.reject(error);\n  }\n\n  dispose() {\n    if (this.abort !== undefined) {\n      this.signal.removeEventListener(\"abort\", this.abort);\n      this.abort = undefined;\n    }\n  }\n\n  private completeBoundary(result: BoundaryResult) {\n    if (this.resolveBoundary !== undefined) {\n      this.resolveBoundary(result);\n      return;\n    }\n\n    this.boundaries.push(result);\n  }\n\n  private currentErrorHandler() {\n    return this.handlers.at(-1);\n  }\n}\n\nexport function defineClientReference(reference: ClientReferenceDefinition): ClientReferenceValue {\n  return {\n    bind(_this: unknown, ...bound: readonly unknown[]) {\n      return defineClientReference({\n        ...reference,\n        bound: [...(reference.bound ?? []), ...bound],\n      });\n    },\n    bound: reference.bound,\n    deps: reference.deps,\n    id: reference.id,\n    mod: reference.mod,\n    name: reference.name,\n    type: clientReferenceType,\n  } as unknown as ClientReferenceValue;\n}\n\nexport function jsx(\n  type: string | typeof Fragment | typeof Marker | Component,\n  props: JSXProps | null,\n): JSXChild {\n  const resolvedProps = props ?? {};\n\n  if (type === Fragment) {\n    return resolvedProps.children;\n  }\n\n  if (type === Marker) {\n    return createMarkerNode(resolvedProps as unknown as MarkerProps);\n  }\n\n  if (type === Suspense) {\n    return createSuspenseNode(resolvedProps as SuspenseProps);\n  }\n\n  if (type === ErrorBoundary) {\n    return createErrorBoundaryNode(resolvedProps as ErrorBoundaryProps);\n  }\n\n  if (typeof type === \"function\") {\n    return {\n      [nodeMarker]: true,\n      kind: \"component\",\n      props: resolvedProps,\n      type,\n    };\n  }\n\n  if (typeof type !== \"string\" || type.length === 0) {\n    throw new TypeError(\"JSX element names must be non-empty strings.\");\n  }\n\n  return {\n    [nodeMarker]: true,\n    kind: \"element\",\n    props: resolvedProps,\n    tagName: type,\n  };\n}\n\nexport const jsxs = jsx;\n\nexport function Suspense(props: SuspenseProps): JSXElement {\n  return createSuspenseNode(props);\n}\n\nexport function ErrorBoundary(props: ErrorBoundaryProps): JSXElement {\n  return createErrorBoundaryNode(props);\n}\n\nexport async function renderToReadableStream(\n  value: JSXChild,\n  options: RenderOptions = {},\n): Promise<RenderReadableStream> {\n  const abortController = new AbortController();\n  const unlinkSignal = linkAbortSignal(options.signal, abortController);\n  const shellReady = Promise.withResolvers<void>();\n  shellReady.promise.catch(() => {});\n  const context = new RenderContext(\n    options.encodeLoadReference ?? defaultEncodeLoadReference,\n    options.idPrefix ?? \"srv-jsx-\",\n    options.nonce,\n    options.onError,\n    abortController.signal,\n    shellReady,\n    options.prerender === true ? \"prerender\" : \"streaming\",\n  );\n  const queue = new ChunkQueue();\n\n  void (async () => {\n    try {\n      // Render the entire shell (including Suspense fallbacks and their\n      // `<?start>/<?end>` markers) into a single complete string before\n      // touching the queue, so the queue only ever receives whole trees —\n      // never partial `<tag>` fragments.\n      const state = context.createRootRenderState();\n      const writer = createStringWriter();\n      await renderValue(value, context, writer, \"0\", state);\n      const shellHtml = renderShellHead(writer.html, state.head);\n      queue.write(shellHtml);\n      queue.write(\n        context.renderBootstrapScripts(options.bootstrapScripts, options.bootstrapModules),\n      );\n\n      // Yield to allow any sync-completing boundaries to finish\n      // before we lock in the shell.\n      await new Promise((resolve) => setTimeout(resolve, 0));\n\n      queue.flush();\n      context.markShellReady();\n      await drainPending(context, queue);\n    } catch (error) {\n      if (context.hasShellReady()) {\n        context.reportError(error);\n      } else {\n        context.rejectShellReady(error);\n      }\n    } finally {\n      queue.close();\n      unlinkSignal();\n      context.dispose();\n    }\n  })();\n\n  await shellReady.promise;\n\n  const encoder = new TextEncoder();\n  let canceled = false;\n  const stream = new ReadableStream<Uint8Array>(\n    {\n      async pull(controller) {\n        const next = await queue.next();\n\n        if (canceled) {\n          return;\n        }\n\n        if (next.done) {\n          controller.close();\n          unlinkSignal();\n          return;\n        }\n\n        controller.enqueue(encoder.encode(next.value ?? \"\"));\n      },\n      cancel(reason) {\n        canceled = true;\n        abortController.abort(reason);\n        unlinkSignal();\n      },\n    },\n    { highWaterMark: 0 },\n  );\n\n  return stream;\n}\n\nasync function drainPending(context: RenderContext, writer: Writer) {\n  while (context.pending.size > 0) {\n    const result = await context.nextBoundaryResult();\n\n    context.pending.delete(result.task);\n\n    if (result.error !== undefined) {\n      if (context.isAbortError(result.error)) {\n        throw result.error;\n      }\n\n      if (result.task.handler === undefined) {\n        throw result.error;\n      }\n\n      const fallbackHtml = await renderErrorFallbackTemplate(result.task.handler, context);\n      context.reportError(result.error);\n      writer.write(fallbackHtml);\n    } else {\n      writer.write(result.html);\n    }\n\n    // Batching: drain any other boundaries that completed while we\n    // were await-ing above, without flushing between each one.\n    while (context.boundaries.length > 0) {\n      const next = context.boundaries.shift()!;\n      context.pending.delete(next.task);\n\n      if (next.error !== undefined) {\n        const fallbackHtml = await renderErrorFallbackTemplate(next.task.handler!, context);\n        context.reportError(next.error);\n        writer.write(fallbackHtml);\n      } else {\n        writer.write(next.html);\n      }\n    }\n\n    // Single flush for the whole batch.\n    writer.flush?.();\n  }\n}\n\nasync function renderValue(\n  value: JSXChild,\n  context: RenderContext,\n  writer: Writer,\n  path: string,\n  state: RenderState,\n): Promise<void> {\n  context.throwIfAborted();\n\n  if (value === null || value === undefined || typeof value === \"boolean\") {\n    return;\n  }\n\n  if (typeof value === \"string\") {\n    writer.write(escapeText(value));\n    return;\n  }\n\n  if (typeof value === \"number\") {\n    writer.write(escapeText(value.toString()));\n    return;\n  }\n\n  if (isPromiseLike(value)) {\n    const resolvedValue = await context.waitFor(value);\n    await renderValue(resolvedValue as JSXChild, context, writer, path, state);\n    return;\n  }\n\n  if (Array.isArray(value)) {\n    for (const [index, child] of value.entries()) {\n      await renderValue(child, context, writer, `${path}-${index}`, state);\n    }\n\n    return;\n  }\n\n  if (!isNode(value)) {\n    throw new TypeError(`Unsupported JSX child value: ${describeValue(value)}.`);\n  }\n\n  if (value.kind === \"component\") {\n    await renderValue(value.type(value.props), context, writer, path, state);\n    return;\n  }\n\n  if (value.kind === \"error-boundary\") {\n    await renderErrorBoundary(value, context, writer, path, state);\n    return;\n  }\n\n  if (value.kind === \"suspense\") {\n    await renderSuspense(value, context, writer, path, state);\n    return;\n  }\n\n  if (value.kind === \"marker\") {\n    await renderMarker(value, context, writer, path, state);\n    return;\n  }\n\n  await renderElement(value, context, writer, path, state);\n}\n\nasync function renderElement(\n  node: ElementNode,\n  context: RenderContext,\n  writer: Writer,\n  path: string,\n  state: RenderState,\n) {\n  assertValidElementName(node.tagName);\n  const namespace = elementNamespace(state.ns, node.tagName);\n  const documentHtml = state.doc && namespace === \"html\";\n\n  if (documentHtml && !state.inHead && !state.inSuspense && isHoistableHeadElement(node.tagName)) {\n    await renderDetachedHeadElement(node, context, writer, path, state);\n    return;\n  }\n\n  let attributes = \"\";\n  const clientEffects: InternalClientEffect[] = [];\n\n  for (const [name, value] of Object.entries(node.props)) {\n    if (isClientRefAttribute(name, value)) {\n      clientEffects.push({ kind: \"ref\", reference: value });\n      continue;\n    }\n\n    if (isClientEventAttribute(name, value)) {\n      clientEffects.push({ event: name.slice(2), kind: \"event\", reference: value });\n      continue;\n    }\n\n    attributes += renderAttribute(name, value, namespace);\n  }\n\n  const hasInnerHTML = node.props.innerHTML !== null && node.props.innerHTML !== undefined;\n  const hasChildren = hasRenderableChildren(node.props.children);\n\n  if (documentHtml && node.tagName === \"html\") {\n    writer.write(\"<!DOCTYPE html>\");\n  }\n\n  if (namespace === \"html\" && isVoidElement(node.tagName)) {\n    if (hasInnerHTML || hasChildren) {\n      throw new TypeError(`Void element <${node.tagName}> cannot have children or innerHTML.`);\n    }\n\n    writer.write(`<${node.tagName}${attributes}>`);\n    await renderClientEffectScripts(clientEffects, context, writer);\n    return;\n  }\n\n  writer.write(`<${node.tagName}${attributes}>`);\n  if (documentHtml && node.tagName === \"html\" && state.head.kind === \"root\") {\n    // Remember where the <html> element opened so we can synthesize a <head>\n    // at the end of the shell when the tree never rendered one explicitly.\n    state.head.htmlPosition = writer.length ?? 0;\n  }\n\n  if (hasInnerHTML) {\n    if (typeof node.props.innerHTML !== \"string\") {\n      throw new TypeError(`innerHTML for <${node.tagName}> must be a string.`);\n    }\n\n    if (hasChildren) {\n      throw new TypeError(`<${node.tagName}> cannot use both innerHTML and children.`);\n    }\n\n    writer.write(node.props.innerHTML);\n    if (documentHtml && node.tagName === \"head\" && state.head.kind === \"root\") {\n      writer.write(context.flushHead(state));\n    }\n    writer.write(`</${node.tagName}>`);\n    await renderClientEffectScripts(clientEffects, context, writer);\n    return;\n  }\n\n  await renderValue(\n    node.props.children,\n    context,\n    writer,\n    `${path}-0`,\n    childRenderState(state, namespace, node.tagName),\n  );\n  if (documentHtml && node.tagName === \"head\" && state.head.kind === \"root\") {\n    writer.write(context.flushHead(state));\n  }\n  writer.write(`</${node.tagName}>`);\n  await renderClientEffectScripts(clientEffects, context, writer);\n}\n\nasync function renderErrorBoundary(\n  node: ErrorBoundaryNode,\n  context: RenderContext,\n  writer: Writer,\n  path: string,\n  state: RenderState,\n) {\n  const name = context.boundaryName(path);\n  const handler: ErrorHandler = { fallback: node.fallback, name, path: `${path}-f`, state };\n\n  writer.write(`<?start name=\"${escapeAttribute(name)}\">`);\n\n  await context.withErrorHandler(handler, async () => {\n    const childState = createChildHeadState(state);\n\n    try {\n      await renderValue(node.children, context, writer, `${path}-0`, childState);\n      await emitDetachedHeadHtml(childState.head.chunks.join(\"\"), context, writer, state);\n      writer.write(\"<?end>\");\n    } catch (error) {\n      if (context.isAbortError(error)) {\n        throw error;\n      }\n\n      writer.write(\"<?end>\");\n      const fallbackHtml = await renderErrorFallbackTemplate(handler, context);\n      context.reportError(error);\n      writer.write(fallbackHtml);\n    }\n  });\n}\n\nasync function renderErrorFallbackTemplate(handler: ErrorHandler, context: RenderContext) {\n  const state = context.createTemplateRenderState(handler.state);\n  const html = await renderToBufferedString(handler.fallback, context, handler.path, state);\n  return `<template for=\"${escapeAttribute(handler.name)}\">${html}</template>`;\n}\n\nasync function renderMarker(\n  node: MarkerNode,\n  context: RenderContext,\n  writer: Writer,\n  path: string,\n  state: RenderState,\n) {\n  if (!node.children) {\n    writer.write(`<?marker name=\"${escapeAttribute(node.name)}\">`);\n    return;\n  }\n\n  writer.write(`<?start name=\"${escapeAttribute(node.name)}\">`);\n  await renderValue(node.children, context, writer, `${path}-0`, { ...state, inSuspense: true });\n  writer.write(\"<?end>\");\n}\n\nasync function renderSuspense(\n  node: SuspenseNode,\n  context: RenderContext,\n  writer: Writer,\n  path: string,\n  state: RenderState,\n) {\n  if (context.suspenseMode === \"prerender\") {\n    await renderValue(node.children, context, writer, `${path}-0`, state);\n    return;\n  }\n\n  // REACT-LIKE RULE: Try synchronous render first.\n  // If the entire subtree can render without promises, inline it.\n  const syncWriter = createStringWriter();\n  const canSync = tryRenderSync(node.children, context, syncWriter, `${path}-0`, state);\n\n  if (canSync) {\n    // Children rendered synchronously — no fallback needed.\n    writer.write(syncWriter.html);\n    return;\n  }\n\n  // Truly async — render fallback in the shell and stream the content later.\n  const name = context.boundaryName(path);\n  context.scheduleTemplate(name, node.children, `${path}-0`, state);\n  writer.write(`<?start name=\"${escapeAttribute(name)}\">`);\n  await renderValue(node.fallback, context, writer, `${path}-f`, { ...state, inSuspense: true });\n  writer.write(\"<?end>\");\n}\n\nasync function renderToBufferedString(\n  value: JSXChild,\n  context: RenderContext,\n  path: string,\n  state: RenderState,\n) {\n  const writer = createStringWriter();\n  await renderValue(value, context, writer, path, state);\n  return writer.html;\n}\n\n/**\n * Renders the final shell head: held head chunks are either hoisted into a\n * synthesized `<head>` when a `<html>` element was rendered without one, or\n * restored inline at their original writer offsets when there is no document\n * structure to hoist into. Without this, held elements would be dropped.\n */\nfunction renderShellHead(html: string, head: HeadScope) {\n  if (head.chunks.length === 0) {\n    return html;\n  }\n\n  // A <html> element was rendered without an explicit <head>: synthesize one\n  // as its first child and hoist the held elements into it.\n  if (head.htmlPosition !== undefined) {\n    const headHtml = `<head>${head.chunks.join(\"\")}${renderHeadMarker()}</head>`;\n    return `${html.slice(0, head.htmlPosition)}${headHtml}${html.slice(head.htmlPosition)}`;\n  }\n\n  // No <html> and no <head> — restore held elements inline where they appeared.\n  let restored = html;\n\n  // Splice in reverse order so earlier positions stay valid while later\n  // positions shift forward.\n  for (let index = head.chunks.length - 1; index >= 0; index -= 1) {\n    const position = head.positions[index] ?? 0;\n    restored = `${restored.slice(0, position)}${head.chunks[index]}${restored.slice(position)}`;\n  }\n\n  return restored;\n}\n\nasync function renderDetachedHeadElement(\n  node: ElementNode,\n  context: RenderContext,\n  writer: Writer,\n  path: string,\n  state: RenderState,\n) {\n  const html = await renderToBufferedElementString(node, context, path, {\n    ...state,\n    inHead: true,\n  });\n\n  await emitDetachedHeadHtml(html, context, writer, state);\n}\n\nasync function emitDetachedHeadHtml(\n  html: string,\n  context: RenderContext,\n  writer: Writer,\n  state: RenderState,\n) {\n  if (html.length === 0) {\n    return;\n  }\n\n  if (state.deferHead || state.head.kind === \"template\" || !context.hasFlushedHead()) {\n    if (state.head.kind === \"root\" && !state.deferHead) {\n      state.head.positions.push(writer.length ?? 0);\n    }\n    state.head.chunks.push(html);\n    return;\n  }\n\n  writer.write(context.renderHeadTemplate(html));\n}\n\nfunction createChildHeadState(state: RenderState): RenderState {\n  return {\n    ...state,\n    deferHead: true,\n    head: {\n      chunks: [],\n      kind: state.head.kind,\n      positions: [],\n    },\n  };\n}\n\nfunction childRenderState(\n  state: RenderState,\n  namespace: RenderNamespace,\n  tagName: string,\n): RenderState {\n  const childNamespace = childNamespaceFor(namespace, tagName);\n  const documentHtml = state.doc && childNamespace === \"html\";\n\n  return {\n    ...state,\n    doc: documentHtml,\n    inHead: documentHtml && (state.inHead || tagName === \"head\"),\n    ns: childNamespace,\n  };\n}\n\nfunction elementNamespace(parentNamespace: RenderNamespace, tagName: string): RenderNamespace {\n  if (parentNamespace === \"html\" && tagName === \"svg\") {\n    return \"svg\";\n  }\n\n  return parentNamespace;\n}\n\nfunction childNamespaceFor(namespace: RenderNamespace, tagName: string): RenderNamespace {\n  if (namespace === \"svg\" && tagName === \"foreignObject\") {\n    return \"html\";\n  }\n\n  return namespace;\n}\n\nasync function renderToBufferedElementString(\n  node: ElementNode,\n  context: RenderContext,\n  path: string,\n  state: RenderState,\n) {\n  const writer = createStringWriter();\n  await renderElement(node, context, writer, path, state);\n  return writer.html;\n}\n\nfunction createStringWriter(): BufferedWriter {\n  let length = 0;\n  const writer: BufferedWriter = {\n    html: \"\",\n    get length() {\n      return length;\n    },\n    write(chunk) {\n      writer.html += chunk;\n      length += chunk.length;\n    },\n  };\n  return writer;\n}\n\nasync function renderClientEffectScripts(\n  effects: readonly InternalClientEffect[],\n  context: RenderContext,\n  writer: Writer,\n) {\n  for (const effect of effects) {\n    writer.write(\n      context.renderScript(\n        `(() => {let e = document.currentScript.previousElementSibling;(${context.encodeLoadReference(\n          effect.reference,\n        )})(${renderClientEffectCallback(effect)})})();document.currentScript.remove();`,\n      ),\n    );\n  }\n}\n\nfunction renderClientEffectCallback(effect: InternalClientEffect) {\n  if (effect.kind === \"ref\") {\n    return \"(r) => r(e)\";\n  }\n\n  return `(r) => e.addEventListener(${JSON.stringify(effect.event)}, r)`;\n}\n\nfunction createMarkerNode(props: MarkerProps): JSXElement {\n  return {\n    [nodeMarker]: true,\n    children: props.children,\n    name: props.name,\n    kind: \"marker\",\n  };\n}\n\nfunction createSuspenseNode(props: SuspenseProps): JSXElement {\n  return {\n    [nodeMarker]: true,\n    children: props.children,\n    fallback: props.fallback,\n    kind: \"suspense\",\n  };\n}\n\nfunction createErrorBoundaryNode(props: ErrorBoundaryProps): JSXElement {\n  return {\n    [nodeMarker]: true,\n    children: props.children,\n    fallback: props.fallback,\n    kind: \"error-boundary\",\n  };\n}\n\nfunction renderAttribute(name: string, value: unknown, namespace: RenderNamespace) {\n  if (name === \"children\" || name === \"innerHTML\" || name === \"key\") {\n    return \"\";\n  }\n\n  if (value === null || value === undefined || (namespace === \"html\" && value === false)) {\n    return \"\";\n  }\n\n  const attributeName = normalizeAttributeName(name, namespace);\n  assertValidAttributeName(attributeName);\n\n  if (isClientReference(value)) {\n    throw new TypeError(\n      `Attribute \"${attributeName}\" received a client reference. Client references can only be passed to event or ref attributes.`,\n    );\n  }\n\n  if (value === true) {\n    if (namespace === \"svg\") {\n      return ` ${attributeName}=\"true\"`;\n    }\n\n    return ` ${attributeName}`;\n  }\n\n  if (value === false) {\n    return ` ${attributeName}=\"false\"`;\n  }\n\n  if (typeof value === \"string\") {\n    return ` ${attributeName}=\"${escapeAttribute(value)}\"`;\n  }\n\n  if (typeof value === \"number\") {\n    return ` ${attributeName}=\"${escapeAttribute(value.toString())}\"`;\n  }\n\n  if (typeof value === \"function\") {\n    throw new TypeError(\n      `Attribute \"${attributeName}\" received a function; event callbacks must be transformed to client references.`,\n    );\n  }\n\n  if (typeof value === \"object\") {\n    throw new TypeError(`Attribute \"${attributeName}\" must be a string, number, or boolean.`);\n  }\n\n  throw new TypeError(`Attribute \"${attributeName}\" cannot render value ${describeValue(value)}.`);\n}\n\nfunction normalizeAttributeName(name: string, namespace: RenderNamespace) {\n  if (name === \"className\") {\n    return \"class\";\n  }\n\n  if (name === \"htmlFor\") {\n    return \"for\";\n  }\n\n  if (namespace === \"svg\" && isSvgAttributeAlias(name)) {\n    return normalizeSvgAttributeName(name);\n  }\n\n  return name;\n}\n\nfunction normalizeSvgAttributeName(name: string) {\n  if (name === \"xmlnsXlink\") {\n    return \"xmlns:xlink\";\n  }\n\n  if (name.startsWith(\"xlink\")) {\n    return `xlink:${name[5]?.toLowerCase() ?? \"\"}${name.slice(6)}`;\n  }\n\n  if (name.startsWith(\"xml\")) {\n    return `xml:${name[3]?.toLowerCase() ?? \"\"}${name.slice(4)}`;\n  }\n\n  return name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\nfunction isSvgAttributeAlias(name: string) {\n  return (\n    svgDashCaseAttributeNames.includes(` ${name} `) || svgColonAttributeNames.includes(` ${name} `)\n  );\n}\n\nfunction isVoidElement(name: string) {\n  return voidElementNames.includes(` ${name} `);\n}\n\nfunction isHoistableHeadElement(name: string) {\n  return hoistableHeadElementNames.includes(` ${name} `);\n}\n\nfunction hasRenderableChildren(value: JSXChild): boolean {\n  if (value === null || value === undefined || typeof value === \"boolean\") {\n    return false;\n  }\n\n  if (Array.isArray(value)) {\n    return value.some(hasRenderableChildren);\n  }\n\n  return true;\n}\n\nfunction isClientEventAttribute(name: string, value: unknown): value is ClientReference {\n  return name.startsWith(\"on\") && name.length > 2 && isClientReference(value);\n}\n\nfunction isClientRefAttribute(name: string, value: unknown): value is ClientReference {\n  return name === \"ref\" && isClientReference(value);\n}\n\nfunction isClientReference(value: unknown): value is ClientReference {\n  return (\n    typeof value === \"object\" &&\n    value !== null &&\n    (value as ClientReference).type === clientReferenceType\n  );\n}\n\nfunction isNode(value: unknown): value is JSXElement {\n  return typeof value === \"object\" && value !== null && nodeMarker in value;\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n  return (\n    typeof value === \"object\" &&\n    value !== null &&\n    \"then\" in value &&\n    typeof (value as Record<string, unknown>).then === \"function\"\n  );\n}\n\n/**\n * Attempts to render a JSX subtree synchronously.\n * Returns `true` if the entire subtree rendered without hitting a Promise.\n * Returns `false` immediately if any Promise is encountered.\n */\nfunction tryRenderSync(\n  value: JSXChild,\n  context: RenderContext,\n  writer: Writer,\n  path: string,\n  state: RenderState,\n): boolean {\n  if (value === null || value === undefined || typeof value === \"boolean\") {\n    return true;\n  }\n  if (typeof value === \"string\") {\n    writer.write(escapeText(value));\n    return true;\n  }\n  if (typeof value === \"number\") {\n    writer.write(escapeText(value.toString()));\n    return true;\n  }\n  if (isPromiseLike(value)) {\n    return false; // Would require async — boundary must suspend\n  }\n  if (Array.isArray(value)) {\n    for (const [index, child] of value.entries()) {\n      if (!tryRenderSync(child, context, writer, `${path}-${index}`, state)) {\n        return false;\n      }\n    }\n    return true;\n  }\n  if (!isNode(value)) {\n    throw new TypeError(`Unsupported JSX child value: ${describeValue(value)}.`);\n  }\n\n  if (value.kind === \"component\") {\n    return tryRenderSync(value.type(value.props), context, writer, path, state);\n  }\n\n  if (value.kind === \"error-boundary\") {\n    // For sync probing, treat error-boundary children like normal children.\n    // If they suspend, the boundary suspends.\n    return tryRenderSync(value.children, context, writer, `${path}-0`, state);\n  }\n\n  if (value.kind === \"suspense\") {\n    // Nested Suspense: try the inner children first.\n    // If they can render sync, great. If not, this outer boundary suspends.\n    return tryRenderSync(value.children, context, writer, `${path}-0`, state);\n  }\n\n  // Element node — render tag, attributes, then children\n  const node = value as ElementNode;\n  assertValidElementName(node.tagName);\n  const namespace = elementNamespace(state.ns, node.tagName);\n  const documentHtml = state.doc && namespace === \"html\";\n\n  if (documentHtml && !state.inHead && !state.inSuspense && isHoistableHeadElement(node.tagName)) {\n    // Pre-suspense head-hoistable elements in the body must be hoisted into\n    // the document head, and a sync probe has no head scope to hoist into —\n    // force the streaming path so the template render handles them inline.\n    return false;\n  }\n\n  let attributes = \"\";\n  for (const [name, propValue] of Object.entries(node.props)) {\n    if (isClientRefAttribute(name, propValue)) continue;\n    if (isClientEventAttribute(name, propValue)) continue;\n    attributes += renderAttribute(name, propValue, namespace);\n  }\n\n  const hasInnerHTML = node.props.innerHTML !== null && node.props.innerHTML !== undefined;\n  const hasChildren = hasRenderableChildren(node.props.children);\n\n  if (namespace === \"html\" && isVoidElement(node.tagName)) {\n    if (hasInnerHTML || hasChildren) {\n      throw new TypeError(`Void element <${node.tagName}> cannot have children or innerHTML.`);\n    }\n    writer.write(`<${node.tagName}${attributes}>`);\n    return true;\n  }\n\n  writer.write(`<${node.tagName}${attributes}>`);\n\n  if (hasInnerHTML) {\n    if (typeof node.props.innerHTML !== \"string\") {\n      throw new TypeError(`innerHTML for <${node.tagName}> must be a string.`);\n    }\n    if (hasChildren) {\n      throw new TypeError(`<${node.tagName}> cannot use both innerHTML and children.`);\n    }\n    writer.write(node.props.innerHTML);\n    if (documentHtml && node.tagName === \"head\" && state.head.kind === \"root\") {\n      writer.write(context.flushHead(state));\n    }\n    writer.write(`</${node.tagName}>`);\n    return true;\n  }\n\n  const childState = childRenderState(state, namespace, node.tagName);\n  if (!tryRenderSync(node.props.children, context, writer, `${path}-0`, childState)) {\n    return false;\n  }\n\n  if (documentHtml && node.tagName === \"head\" && state.head.kind === \"root\") {\n    writer.write(context.flushHead(state));\n  }\n  writer.write(`</${node.tagName}>`);\n  return true;\n}\n\nfunction describeValue(value: unknown) {\n  if (value === null) {\n    return \"null\";\n  }\n\n  if (Array.isArray(value)) {\n    return \"array\";\n  }\n\n  return typeof value;\n}\n\nfunction assertValidElementName(name: string) {\n  if (!attributeNamePattern.test(name)) {\n    throw new Error(`Invalid JSX element name \"${name}\".`);\n  }\n}\n\nfunction assertValidAttributeName(name: string) {\n  if (!attributeNamePattern.test(name)) {\n    throw new Error(`Invalid JSX attribute name \"${name}\".`);\n  }\n}\n\nfunction linkAbortSignal(signal: AbortSignal | undefined, controller: AbortController) {\n  if (signal === undefined) {\n    return () => {};\n  }\n\n  if (signal.aborted) {\n    controller.abort(getAbortReason(signal));\n    return () => {};\n  }\n\n  const abort = () => {\n    controller.abort(getAbortReason(signal));\n  };\n\n  signal.addEventListener(\"abort\", abort, { once: true });\n\n  return () => {\n    signal.removeEventListener(\"abort\", abort);\n  };\n}\n\nfunction throwIfAborted(signal: AbortSignal) {\n  if (signal.aborted) {\n    throw getAbortReason(signal);\n  }\n}\n\nfunction getAbortReason(signal: AbortSignal) {\n  return signal.reason;\n}\n\nfunction escapeText(value: string) {\n  return escapeHtml(value, false);\n}\n\nfunction escapeAttribute(value: string) {\n  return escapeHtml(value, true);\n}\n\nfunction escapeHtml(value: string, attribute: boolean) {\n  let escaped = \"\";\n  let lastIndex = 0;\n\n  for (let index = 0; index < value.length; index += 1) {\n    let entity: string | undefined;\n\n    switch (value.charCodeAt(index)) {\n      case 34:\n        if (attribute) {\n          entity = \"&quot;\";\n        }\n        break;\n      case 38:\n        entity = \"&amp;\";\n        break;\n      case 60:\n        entity = \"&lt;\";\n        break;\n      case 62:\n        entity = \"&gt;\";\n        break;\n    }\n\n    if (entity === undefined) {\n      continue;\n    }\n\n    escaped += value.slice(lastIndex, index) + entity;\n    lastIndex = index + 1;\n  }\n\n  if (lastIndex === 0) {\n    return value;\n  }\n\n  return escaped + value.slice(lastIndex);\n}\n\nfunction escapeScriptContent(value: string) {\n  return value.replaceAll(/<\\/script/gi, \"<\\\\/script\");\n}\n\nfunction defaultEncodeLoadReference(reference: ClientReference) {\n  return [\n    \"(c)=>\",\n    `import(${JSON.stringify(reference.mod)})`,\n    `.then(m=>c(m[${JSON.stringify(reference.name)}].bind(null,...${JSON.stringify(\n      reference.bound ?? [],\n    )})))`,\n  ].join(\"\");\n}\n\nfunction renderHeadMarker() {\n  return `<?marker name=\"${headMarkerName}\">`;\n}\n\nfunction hashBoundaryPath(path: string) {\n  let hash = 0xcbf29ce484222325n;\n\n  for (const char of path) {\n    hash ^= BigInt(char.codePointAt(0) ?? 0);\n    hash = BigInt.asUintN(64, hash * 0x100000001b3n);\n  }\n\n  return (hash % 36n ** 6n).toString(36).padStart(6, \"0\");\n}\n\nexport namespace JSX {\n  export type Element = JSXElement;\n  export type ElementType = string | typeof Fragment | Component;\n\n  export interface ElementChildrenAttribute {\n    children: {};\n  }\n\n  export interface IntrinsicAttributes {\n    key?: string;\n  }\n\n  export interface IntrinsicElements extends KnownIntrinsicElements {\n    [elementName: string]: JSXProps;\n  }\n}\n"],"mappings":"AAAA,MAAM,EAAsB,OAAO,IAAI,0BAA0B,EAC3D,EAAa,OAAO,IAAI,cAAc,EAItC,EAAiB,eACjB,EAAuB,+BAMhB,EAAW,OAAO,IAAI,kBAAkB,EAGxC,EAA6C,OAAO,IAC/D,gBACF,EAkOA,IAAM,EAAN,KAAmC,CACjC,OAAiB,GACjB,OAAoC,CAAC,EACrC,OAAiB,GACjB,OAEA,OAAQ,CACF,KAAK,SAIT,KAAK,MAAM,EACX,KAAK,OAAS,GACd,KAAK,cAAc,EACrB,CAEA,MAAM,MAAgC,CACpC,IAAM,EAAQ,KAAK,OAAO,MAAM,EAEhC,GAAI,IAAU,IAAA,GACZ,MAAO,CAAE,KAAM,GAAO,OAAM,EAG9B,GAAI,KAAK,OACP,MAAO,CAAE,KAAM,EAAK,EAGtB,IAAM,EAAS,QAAQ,cAAoB,EAK3C,MAHA,MAAK,OAAS,EACd,MAAM,EAAO,QAEN,KAAK,KAAK,CACnB,CAEA,OAAQ,CACN,GAAI,KAAK,OAAO,OAAS,GAAK,CAAC,KAAK,OAAQ,CAC1C,KAAK,OAAO,KAAK,KAAK,MAAM,EAC5B,KAAK,OAAS,GACd,KAAK,cAAc,EACnB,MACF,CAEA,KAAK,cAAc,CACrB,CAEA,MAAM,EAAe,CACf,EAAM,SAAW,GAAK,KAAK,SAI/B,KAAK,QAAU,EACjB,CAEA,eAAwB,CACtB,IAAM,EAAS,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