{
  "version": 3,
  "sources": ["/cdn/shop/t/1/assets/morph.js?v=182601902166245204061787334881"],
  "sourcesContent": ["import { Component } from '@theme/component';\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [childrenOnly] - Only update children\n * @property {(node: Node | undefined) => string|number|undefined} [getNodeKey] - Get node key for matching\n * @property {(oldNode: Node, newNode: Node) => void} [onBeforeUpdate] - Pre-update hook\n * @property {(node: Node) => void} [onAfterUpdate] - Post-update hook\n * @property {(oldNode: Node, newNode: Node) => boolean} [reject] - Reject a node from being morphed\n * @property {boolean} [hydrationMode] - If true, only morph subtrees whose elements have `data-hydration-key=\"<non-empty>\"`, matched by that value\n */\n\nconst HYDRATION_KEY_ATTRIBUTE = 'data-hydration-key';\n\n// onBeforeUpdate runs for every node pair, so keep these off its hot path.\nconst PRESERVED_ATTRIBUTES = [\n  'product-grid-view',\n  'data-current-checked',\n  'data-previous-checked',\n  'cart-summary-sticky',\n];\nconst PRESERVED_ATTRIBUTES_SET = new Set(PRESERVED_ATTRIBUTES);\n\n/**\n * The options for the morph\n * @type {Options}\n */\nexport const MORPH_OPTIONS = {\n  childrenOnly: true,\n  hydrationMode: false,\n  reject(oldNode, newNode) {\n    if (newNode.nodeType === Node.TEXT_NODE && newNode.nodeValue?.trim() === '') {\n      return true;\n    }\n\n    if (\n      newNode instanceof HTMLTemplateElement &&\n      newNode.shadowRootMode === 'open' &&\n      oldNode.parentElement &&\n      newNode.parentElement &&\n      oldNode.parentElement.tagName === newNode.parentElement.tagName &&\n      oldNode.parentElement?.shadowRoot != null\n    ) {\n      // Ignore template elements of components that are already initialized\n      return true;\n    }\n\n    if (newNode.nodeType === Node.COMMENT_NODE && newNode.nodeValue === 'shopify:rendered_by_section_api') {\n      // Remove a comment node injected by the Section Rendering API in the Theme Editor\n      return true;\n    }\n\n    return false;\n  },\n  onBeforeUpdate(oldNode, newNode) {\n    if (!(oldNode instanceof Element) || !(newNode instanceof Element)) return;\n\n    // Elements usually carry fewer attributes than the preserved list, so scan the\n    // element's own attributes rather than probing each preserved name.\n    const oldAttrs = oldNode.attributes;\n    for (let i = 0; i < oldAttrs.length; i++) {\n      const attr = /** @type {Attr} */ (oldAttrs[i]);\n      if (PRESERVED_ATTRIBUTES_SET.has(attr.name)) {\n        const oldValue = attr.value;\n        if (oldValue && oldValue !== newNode.getAttribute(attr.name)) {\n          newNode.setAttribute(attr.name, oldValue);\n        }\n      }\n    }\n\n    // These elements carry runtime-applied inline styles that the re-render doesn't\n    // include, so copy the old style across before it's overwritten.\n    const tagName = oldNode.tagName;\n    if (tagName === 'FLOATING-PANEL-COMPONENT' || tagName === 'FIELDSET') {\n      const isFloating = tagName === 'FLOATING-PANEL-COMPONENT';\n      const matchesOld = isFloating || oldNode.classList.contains('variant-option');\n      if (matchesOld && newNode.tagName === tagName) {\n        const matchesNew = isFloating || newNode.classList.contains('variant-option');\n        if (matchesNew) {\n          const oldStyle = oldNode.getAttribute('style');\n          if (oldStyle) newNode.setAttribute('style', oldStyle);\n        }\n      }\n    }\n\n    // Preserve temporary view transition name\n    if (oldNode instanceof HTMLElement && newNode instanceof HTMLElement && oldNode.style.viewTransitionName) {\n      newNode.style.viewTransitionName = oldNode.style.viewTransitionName;\n    }\n  },\n  onAfterUpdate(node) {\n    if (node instanceof Component) {\n      queueMicrotask(() => node.updatedCallback());\n    }\n  },\n};\n\n/**\n * Morphs one DOM tree into another by comparing nodes and applying minimal changes\n * @param {Node} oldTree - The existing DOM tree\n * @param {Node | string} newTree - The new DOM tree to morph to\n * @param {Options} [options] - Configuration options\n * @returns {Node} The morphed DOM tree\n */\nexport function morph(oldTree, newTree, options = MORPH_OPTIONS) {\n  if (!oldTree || !newTree) {\n    throw new Error('Both oldTree and newTree must be provided');\n  }\n\n  if (typeof newTree === 'string') {\n    const parsedNewTree = new DOMParser().parseFromString(newTree, 'text/html').body.firstChild;\n    if (!parsedNewTree) {\n      throw new Error('newTree string is not valid HTML');\n    }\n    newTree = parsedNewTree;\n  }\n\n  if (options.hydrationMode && oldTree instanceof Element && newTree instanceof Element) {\n    morphHydrationByKey(oldTree, newTree, options);\n    return oldTree;\n  }\n\n  let result;\n  if (options.childrenOnly) {\n    updateChildren(newTree, oldTree, options);\n    result = oldTree;\n  } else if (newTree.nodeType === 11) {\n    throw new Error('newTree should have one root node (not a DocumentFragment)');\n  } else {\n    result = walk(newTree, oldTree, options);\n  }\n\n  // Recreate once for the whole tree, not per updateChildren recursion, so scripts aren't re-created repeatedly.\n  if (result instanceof Element) {\n    recreateAppBlockScripts(result);\n  }\n  return result;\n}\n\n/**\n * Collect targets under a root element that have a non-empty key for the attribute.\n * Includes the root itself if it matches.\n *\n * @param {Element} root\n * @returns {Element[]}\n */\nfunction collectHydrationTargets(root) {\n  const targets = [];\n  if (root.hasAttribute(HYDRATION_KEY_ATTRIBUTE)) targets.push(root);\n  targets.push(...root.querySelectorAll(`[${HYDRATION_KEY_ATTRIBUTE}]`));\n  return targets;\n}\n\n/**\n * Morph only keyed targets from `newRoot` into `oldRoot` (a.k.a. \"keyed lazy hydration\").\n *\n * Philosophy:\n * - This updates the *contents* of pre-existing targets. We intentionally do NOT insert new targets (or remove missing ones).\n * - By requiring targets to already exist in `oldRoot`, we preserve runtime state that may already\n *   be attached to the existing DOM (custom elements, listeners, focus, transient UI state) and preserve the layout and UI behavior.\n * - Intended use-case: avoid expensive server-side rendering operations in the initial render, and hydrate targeted sections after page load. e.g. Querying all product and collection drops in off-screen menus.\n *\n * Contract:\n * - An element is eligible only if it has `data-hydration-key=\"<non-empty>\"`.\n * - Matching uses ONLY that key value (no fallbacks) to avoid accidental cross-updates.\n * - Once a target is matched, we run a normal morph *within that target* (attributes + children).\n *\n * @param {Element} oldRoot\n * @param {Element} newRoot\n * @param {Options} options\n */\nfunction morphHydrationByKey(oldRoot, newRoot, options) {\n  const oldTargets = collectHydrationTargets(oldRoot);\n  const newTargets = collectHydrationTargets(newRoot);\n\n  /** @type {Map<string, Element[]>} */\n  const oldTargetsByKey = new Map();\n\n  for (const oldTarget of oldTargets) {\n    const key = oldTarget.getAttribute(HYDRATION_KEY_ATTRIBUTE);\n    if (key == null || key === '') continue;\n\n    const existing = oldTargetsByKey.get(key) ?? [];\n    existing.push(oldTarget);\n    oldTargetsByKey.set(key, existing);\n  }\n\n  for (const newTarget of newTargets) {\n    const key = newTarget.getAttribute(HYDRATION_KEY_ATTRIBUTE);\n    if (key == null || key === '') continue;\n\n    const matches = oldTargetsByKey.get(key);\n    const oldTarget = matches?.shift();\n    if (!oldTarget) continue;\n\n    // For keyed targets we want attribute updates as well, regardless of the caller's childrenOnly default.\n    morph(oldTarget, newTarget, {\n      ...options,\n      hydrationMode: false,\n      childrenOnly: false,\n    });\n  }\n}\n\n/**\n * Walk and morph a dom tree\n * @param {Node} newNode - The new node to morph to\n * @param {Node} oldNode - The old node to morph from\n * @param {Options} options - The options object\n * @returns {Node} The new node or the morphed old node\n */\nfunction walk(newNode, oldNode, options) {\n  // Skip morphing if there is no old or new node\n  if (!oldNode) return newNode;\n  if (!newNode) return oldNode;\n\n  if (newNode === oldNode) return oldNode;\n\n  const newType = newNode.nodeType;\n  if (newType !== oldNode.nodeType) return newNode;\n\n  if (newType === 1 /* ELEMENT_NODE */) {\n    // newType === 1 guarantees both are Elements; cast rather than re-checking with instanceof.\n    const oldEl = /** @type {Element} */ (oldNode);\n    const newEl = /** @type {Element} */ (newNode);\n    // Skip morphing if the node is shopify-accelerated-checkout-cart https://shopify.dev/docs/storefronts/themes/pricing-payments/accelerated-checkout#implement-accelerated-checkout-buttons-on-cart\n    if (oldEl.tagName === 'SHOPIFY-ACCELERATED-CHECKOUT-CART') return oldNode;\n    if (newEl.tagName !== oldEl.tagName) return newNode;\n\n    // isEqualNode compares serialized markup, so it's blind to live form state (input\n    // value/checked, option selected, textarea value). Replay that sync across the subtree, then\n    // return the untouched DOM. Skipping also avoids updatedCallback on the subtree, which is\n    // safe: it only rebuilds a component's refs from its own subtree, unchanged here.\n    // syncFormControlsInSubtree honors data-skip-node-update, so the guard below stays correct\n    // even though this fast path runs ahead of it.\n    if (oldNode.isEqualNode(newNode)) {\n      syncFormControlsInSubtree(newEl, oldEl);\n      return oldNode;\n    }\n\n    // Only check keys for elements, and only if both nodes have keys\n    const newKey = getNodeKey(newNode, options);\n    const oldKey = getNodeKey(oldNode, options);\n    if (newKey && oldKey && newKey !== oldKey) return newNode;\n\n    // For elements we already know both are Elements; collapse the second instanceof\n    // pair from the original code into a single nodeType-gated branch.\n    if (oldEl.hasAttribute('data-skip-node-update') && newEl.hasAttribute('data-skip-node-update')) {\n      // Special case: don't morph this node, but recurse into its children.\n      updateChildren(newNode, oldNode, options);\n    } else {\n      updateNode(newNode, oldNode, options);\n      updateChildren(newNode, oldNode, options);\n    }\n  } else {\n    // Text and comment nodes are leaves, so there are no children to reconcile.\n    updateNode(newNode, oldNode, options);\n  }\n\n  options.onAfterUpdate?.(newNode);\n\n  return oldNode;\n}\n\n/**\n * Core morphing function that updates attributes and special elements\n * @param {Node} newNode - Source node with desired state\n * @param {Node} oldNode - Target node to update\n * @param {Options} options - The options object\n */\nfunction updateNode(newNode, oldNode, options) {\n  options.onBeforeUpdate?.(oldNode, newNode);\n\n  const newType = newNode.nodeType;\n\n  if (newType === 1 /* ELEMENT_NODE */) {\n    const oldEl = /** @type {Element} */ (oldNode);\n    const newEl = /** @type {Element} */ (newNode);\n    // Only reconcile attributes when they differ. A shallow compare is enough here;\n    // updateChildren recurses into the subtree separately.\n    if (!attributesEqual(oldEl, newEl)) {\n      // The open/slot/sizes preservations below act on attributes, so they're only\n      // meaningful when attributes differ.\n      if (\n        (newNode instanceof HTMLDetailsElement && oldNode instanceof HTMLDetailsElement) ||\n        (newNode instanceof HTMLDialogElement && oldNode instanceof HTMLDialogElement)\n      ) {\n        if (!newNode.hasAttribute('declarative-open')) {\n          newNode.open = oldNode.open;\n        }\n      }\n\n      if (oldNode instanceof HTMLElement && newNode instanceof HTMLElement) {\n        // Preserve slot/sizes on the new node before copyAttributes overwrites them.\n        for (const attr of ['slot', 'sizes']) {\n          const oldValue = oldNode.getAttribute(attr);\n          const newValue = newNode.getAttribute(attr);\n          if (oldValue !== newValue) {\n            oldValue == null ? newNode.removeAttribute(attr) : newNode.setAttribute(attr, oldValue);\n          }\n        }\n      }\n\n      copyAttributes(newEl, oldEl);\n    }\n\n    // value/checked/selected/textarea aren't always reflected as content attributes, so this\n    // runs regardless of attributesEqual. walk's subtree-skip replays the same sync.\n    syncFormControlState(newNode, oldNode);\n  } else if (newType === 3 /* TEXT_NODE */ || newType === 8 /* COMMENT_NODE */) {\n    if (oldNode.nodeValue !== newNode.nodeValue) {\n      oldNode.nodeValue = newNode.nodeValue;\n    }\n  }\n}\n\n/**\n * Syncs live form-control state that serialized markup doesn't carry: input\n * value/checked/indeterminate, option selected, and textarea value. updateNode runs this\n * regardless of attribute equality, and walk's isEqualNode subtree-skip replays it across the\n * subtree (syncFormControlsInSubtree), so both paths share one definition of which elements\n * need it. instanceof is the gate.\n * @param {Node} newNode\n * @param {Node} oldNode\n */\nfunction syncFormControlState(newNode, oldNode) {\n  if (newNode instanceof HTMLInputElement && oldNode instanceof HTMLInputElement) {\n    updateInput(newNode, oldNode);\n  } else if (newNode instanceof HTMLOptionElement && oldNode instanceof HTMLOptionElement) {\n    updateAttribute(newNode, oldNode, 'selected');\n  } else if (newNode instanceof HTMLTextAreaElement && oldNode instanceof HTMLTextAreaElement) {\n    updateTextarea(newNode, oldNode);\n  }\n}\n\n/**\n * True when both nodes opt out of morphing via data-skip-node-update, matching walk's guard.\n * Such controls must keep their live state (e.g. a cart note or discount code the shopper\n * typed), so the subtree-skip must not reconcile them back to the server-parsed value.\n * @param {Element} newNode\n * @param {Element} oldNode\n * @returns {boolean}\n */\nfunction skipsNodeUpdate(newNode, oldNode) {\n  return newNode.hasAttribute('data-skip-node-update') && oldNode.hasAttribute('data-skip-node-update');\n}\n\n/**\n * Replays syncFormControlState across an element and its descendants. walk uses this when\n * isEqualNode reports a subtree unchanged: that comparison is blind to live form state, so a\n * dirty control (e.g. a quantity a shopper typed) would otherwise keep stale state after a\n * re-render. isEqualNode guarantees identical structure, so the old/new control lists line up\n * by index. Controls flagged data-skip-node-update are left untouched, mirroring walk's guard.\n * @param {Element} newNode\n * @param {Element} oldNode\n */\nfunction syncFormControlsInSubtree(newNode, oldNode) {\n  if (!skipsNodeUpdate(newNode, oldNode)) {\n    syncFormControlState(newNode, oldNode);\n  }\n  const newControls = newNode.querySelectorAll('input, option, textarea');\n  if (newControls.length === 0) return;\n  const oldControls = oldNode.querySelectorAll('input, option, textarea');\n  for (let i = 0; i < newControls.length; i++) {\n    const newControl = /** @type {Element} */ (newControls[i]);\n    const oldControl = /** @type {Element} */ (oldControls[i]);\n    if (skipsNodeUpdate(newControl, oldControl)) continue;\n    syncFormControlState(newControl, oldControl);\n  }\n}\n\n/**\n * True when both elements have identical attribute sets (names, values, namespaces). Gates\n * copyAttributes. Deliberately shallow: isEqualNode would re-walk the subtree that\n * updateChildren already recurses into.\n *\n * @param {Element} a\n * @param {Element} b\n * @returns {boolean}\n */\nfunction attributesEqual(a, b) {\n  const aAttrs = a.attributes;\n  const bAttrs = b.attributes;\n  const len = aAttrs.length;\n  if (len !== bAttrs.length) return false;\n  // Same-template re-renders emit attributes in the same order, so compare positionally.\n  // A different order only yields a false-unequal (falls through to copyAttributes), never a false-equal.\n  for (let i = 0; i < len; i++) {\n    const aAttr = /** @type {Attr} */ (aAttrs[i]);\n    const bAttr = /** @type {Attr} */ (bAttrs[i]);\n    if (!aAttr.isEqualNode(bAttr)) return false;\n  }\n  return true;\n}\n\n/**\n * Gets a node's key using the getNodeKey option if provided\n * @param {Node | undefined} node - The node to get the key from\n * @param {Options} [options] - The options object that may contain getNodeKey\n * @returns {string|number|undefined} The node's key if one exists\n */\nfunction getNodeKey(node, options) {\n  return options?.getNodeKey?.(node) ?? (node instanceof Element ? node.id : undefined);\n}\n\n/**\n * Updates a boolean attribute and its corresponding property on an element\n * @param {any} newNode - The new element\n * @param {any} oldNode - The existing element to update\n * @param {string} name - The name of the attribute/property to update\n */\nfunction updateAttribute(newNode, oldNode, name) {\n  if (newNode[name] !== oldNode[name]) {\n    oldNode[name] = newNode[name];\n    if (newNode[name] != null) {\n      oldNode.setAttribute(name, '');\n    } else {\n      oldNode.removeAttribute(name);\n    }\n  }\n}\n\n/**\n * Copies attributes from a new node to an old node, handling namespaced attributes\n * @param {Element} newNode - The new node to copy attributes from\n * @param {Element} oldNode - The existing node to update attributes on\n */\nfunction copyAttributes(newNode, oldNode) {\n  const oldAttrs = oldNode.attributes;\n  const newAttrs = newNode.attributes;\n\n  // Update or add new attributes\n  for (const attr of Array.from(newAttrs)) {\n    const { name: attrName, namespaceURI: attrNamespaceURI, value: attrValue } = attr;\n    const localName = attr.localName || attrName;\n\n    if (attrName === 'src' || attrName === 'href' || attrName === 'srcset' || attrName === 'poster') {\n      // Skip updating resource attributes when the value hasn't changed\n      // to prevent unnecessary network requests\n      if (oldNode.getAttribute(attrName) === attrValue) continue;\n    }\n\n    if (attrNamespaceURI) {\n      const fromValue = oldNode.getAttributeNS(attrNamespaceURI, localName);\n      if (fromValue !== attrValue) {\n        oldNode.setAttributeNS(attrNamespaceURI, localName, attrValue);\n      }\n    } else {\n      if (!oldNode.hasAttribute(attrName)) {\n        oldNode.setAttribute(attrName, attrValue);\n      } else {\n        const fromValue = oldNode.getAttribute(attrName);\n        if (fromValue !== attrValue) {\n          if (attrValue === 'null' || attrValue === 'undefined') {\n            oldNode.removeAttribute(attrName);\n          } else {\n            oldNode.setAttribute(attrName, attrValue);\n          }\n        }\n      }\n    }\n  }\n\n  // Remove old attributes not present in new node\n  for (const attr of Array.from(oldAttrs)) {\n    if (attr.specified === false) continue;\n\n    const { name: attrName, namespaceURI: attrNamespaceURI } = attr;\n    const localName = attr.localName || attrName;\n\n    if (attrNamespaceURI) {\n      if (!newNode.hasAttributeNS(attrNamespaceURI, localName)) {\n        oldNode.removeAttributeNS(attrNamespaceURI, localName);\n      }\n    } else if (!newNode.hasAttribute(attrName)) {\n      oldNode.removeAttribute(attrName);\n    }\n  }\n}\n\n/**\n * Updates special properties and attributes on input elements\n * Handles checked, disabled, indeterminate states and value\n * @param {HTMLInputElement} newNode - The new input element\n * @param {HTMLInputElement} oldNode - The existing input element to update\n */\nfunction updateInput(newNode, oldNode) {\n  const newValue = newNode.value;\n\n  updateAttribute(newNode, oldNode, 'checked');\n  updateAttribute(newNode, oldNode, 'disabled');\n\n  // Handle indeterminate state (cannot be set via HTML attribute)\n  if (newNode.indeterminate !== oldNode.indeterminate) {\n    oldNode.indeterminate = newNode.indeterminate;\n  }\n\n  // Skip file inputs since they can't be changed programmatically\n  if (oldNode.type === 'file') return;\n\n  if (newValue !== oldNode.value) {\n    oldNode.setAttribute('value', newValue);\n    oldNode.value = newValue;\n  }\n\n  if (newValue === 'null') {\n    oldNode.value = '';\n    oldNode.removeAttribute('value');\n  }\n\n  if (!newNode.hasAttributeNS(null, 'value')) {\n    oldNode.removeAttribute('value');\n  } else if (oldNode.type === 'range') {\n    // Update range input UI\n    oldNode.value = newValue;\n  }\n}\n\n/**\n * Updates the value of a textarea element\n * @param {HTMLTextAreaElement} newNode - The new textarea element\n * @param {HTMLTextAreaElement} oldNode - The existing textarea element to update\n */\nfunction updateTextarea(newNode, oldNode) {\n  const newValue = newNode.value;\n  if (newValue !== oldNode.value) {\n    oldNode.value = newValue;\n  }\n\n  const firstChild = oldNode.firstChild;\n  if (firstChild?.nodeType === Node.TEXT_NODE) {\n    if (newValue === '' && firstChild.nodeValue === oldNode.placeholder) {\n      return;\n    }\n    firstChild.nodeValue = newValue;\n  }\n}\n\n/**\n * If app scripts store references to the DOM on initialization, they will be invalidated by the morph because browsers don't re-execute them.\n * This function removes and recreates them to force re-execution.\n * @param {Element} container - The container element to search for app block scripts\n */\nfunction recreateAppBlockScripts(container) {\n  const scripts = container.querySelectorAll('.shopify-app-block script[src]');\n\n  for (const script of scripts) {\n    if (!(script instanceof HTMLScriptElement)) continue;\n\n    const parent = script.parentElement;\n    if (!parent) continue;\n\n    const newScript = document.createElement('script');\n    for (const attr of Array.from(script.attributes)) {\n      newScript.setAttribute(attr.name, attr.value);\n    }\n    if (script.textContent) {\n      newScript.textContent = script.textContent;\n    }\n\n    script.remove();\n    parent.appendChild(newScript);\n  }\n}\n\n/**\n * Update the children of elements\n * @param {Node} newNode - The new node to update children on\n * @param {Node} oldNode - The existing node to update children on\n * @param {Options} options - The options object\n */\nfunction updateChildren(newNode, oldNode, options) {\n  if (\n    oldNode instanceof Element &&\n    oldNode.hasAttribute('data-skip-subtree-update') &&\n    newNode instanceof Element &&\n    newNode.hasAttribute('data-skip-subtree-update')\n  ) {\n    return;\n  }\n\n  const oldChildren = oldNode.childNodes;\n  const newChildren = newNode.childNodes;\n  const reject = options.reject;\n\n  let oldChild, newChild, morphed, oldMatch;\n  let offset = 0;\n\n  for (let i = 0; ; i++) {\n    oldChild = oldChildren[i];\n    newChild = newChildren[i - offset];\n\n    // Both nodes are empty, do nothing\n    if (!oldChild && !newChild) {\n      break;\n    }\n\n    // There is no new child, remove old\n    if (!newChild) {\n      oldChild && oldNode.removeChild(oldChild);\n      i--;\n      continue;\n    }\n\n    // There is no old child, add new\n    if (!oldChild) {\n      oldNode.appendChild(newChild);\n      offset++;\n      continue;\n    }\n\n    // Both nodes are the same, morph\n    if (same(newChild, oldChild, options)) {\n      morphed = walk(newChild, oldChild, options);\n      if (morphed !== oldChild) {\n        oldNode.replaceChild(morphed, oldChild);\n        offset++;\n      }\n      continue;\n    }\n\n    if (reject !== undefined && reject(oldChild, newChild)) {\n      newNode.removeChild(newChild);\n      i--;\n      continue;\n    }\n\n    // Scan the remaining old children for one matching newChild, to reorder rather than replace.\n    oldMatch = null;\n    const oldChildrenLen = oldChildren.length;\n    for (let j = i; j < oldChildrenLen; j++) {\n      const potentialOldNode = oldChildren[j];\n      if (potentialOldNode && same(potentialOldNode, newChild, options)) {\n        oldMatch = potentialOldNode;\n        break;\n      }\n    }\n\n    if (oldMatch) {\n      morphed = walk(newChild, oldMatch, options);\n      if (morphed !== oldMatch) offset++;\n      oldNode.insertBefore(morphed, oldChild);\n    } else if (!getNodeKey(newChild, options) && !getNodeKey(oldChild, options)) {\n      morphed = walk(newChild, oldChild, options);\n      if (morphed !== oldChild) {\n        oldNode.replaceChild(morphed, oldChild);\n        offset++;\n      }\n    } else {\n      oldNode.insertBefore(newChild, oldChild);\n      offset++;\n    }\n  }\n}\n\n/**\n * Check if two nodes are the same\n * @param {Node} a - The first node\n * @param {Node} b - The second node\n * @param {Options} options - The options object\n * @returns {boolean} True if the nodes are the same, false otherwise\n */\nfunction same(a, b, options) {\n  const aType = a.nodeType;\n  const bType = b.nodeType;\n  // If node types don't match, they're not the same\n  if (aType !== bType) return false;\n\n  // For elements, check tag name first\n  if (aType === Node.ELEMENT_NODE) {\n    if (a instanceof Element && b instanceof Element && a.tagName !== b.tagName) return false;\n\n    // Only compare keys if both nodes have them\n    const aKey = getNodeKey(a, options);\n    const bKey = getNodeKey(b, options);\n    if (aKey && bKey && aKey !== bKey) return false;\n  }\n\n  // For text nodes, match exactly first and only fall back to a trimmed compare when\n  // the raw values differ, so the common path doesn't allocate.\n  if (aType === Node.TEXT_NODE && bType === Node.TEXT_NODE) {\n    const av = a.nodeValue;\n    const bv = b.nodeValue;\n    return av === bv || av?.trim() === bv?.trim();\n  }\n  if (aType === Node.COMMENT_NODE && bType === Node.COMMENT_NODE) return a.nodeValue === b.nodeValue;\n\n  // If we get here and nodes are elements with same tag (and compatible keys), they're the same\n  return true;\n}\n"],
  "mappings": "AAAA,OAAS,cAAiB,mBAY1B,MAAM,wBAA0B,qBAG1B,qBAAuB,CAC3B,oBACA,uBACA,wBACA,qBACF,EACM,yBAA2B,IAAI,IAAI,oBAAoB,EAMtD,aAAM,cAAgB,CAC3B,aAAc,GACd,cAAe,GACf,OAAO,QAAS,QAAS,CAiBvB,MAhBI,WAAQ,WAAa,KAAK,WAAa,QAAQ,WAAW,KAAK,IAAM,IAKvE,mBAAmB,qBACnB,Q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