{"ast":null,"code":"\"use strict\";\n\nexports.__esModule = true;\nexports.default = initHeadManager;\nexports.DOMAttributeNames = void 0;\nconst DOMAttributeNames = {\n  acceptCharset: 'accept-charset',\n  className: 'class',\n  htmlFor: 'for',\n  httpEquiv: 'http-equiv',\n  noModule: 'noModule'\n};\nexports.DOMAttributeNames = DOMAttributeNames;\n\nfunction reactElementToDOM({\n  type,\n  props\n}) {\n  const el = document.createElement(type);\n\n  for (const p in props) {\n    if (!props.hasOwnProperty(p)) continue;\n    if (p === 'children' || p === 'dangerouslySetInnerHTML') continue; // we don't render undefined props to the DOM\n\n    if (props[p] === undefined) continue;\n    const attr = DOMAttributeNames[p] || p.toLowerCase();\n\n    if (type === 'script' && (attr === 'async' || attr === 'defer' || attr === 'noModule')) {\n      ;\n      el[attr] = !!props[p];\n    } else {\n      el.setAttribute(attr, props[p]);\n    }\n  }\n\n  const {\n    children,\n    dangerouslySetInnerHTML\n  } = props;\n\n  if (dangerouslySetInnerHTML) {\n    el.innerHTML = dangerouslySetInnerHTML.__html || '';\n  } else if (children) {\n    el.textContent = typeof children === 'string' ? children : Array.isArray(children) ? children.join('') : '';\n  }\n\n  return el;\n}\n\nfunction updateElements(type, components) {\n  const headEl = document.getElementsByTagName('head')[0];\n  const headCountEl = headEl.querySelector('meta[name=next-head-count]');\n\n  if (false) {\n    if (!headCountEl) {\n      console.error('Warning: next-head-count is missing. https://err.sh/next.js/next-head-count-missing');\n      return;\n    }\n  }\n\n  const headCount = Number(headCountEl.content);\n  const oldTags = [];\n\n  for (let i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {\n    if (j.tagName.toLowerCase() === type) {\n      oldTags.push(j);\n    }\n  }\n\n  const newTags = components.map(reactElementToDOM).filter(newTag => {\n    for (let k = 0, len = oldTags.length; k < len; k++) {\n      const oldTag = oldTags[k];\n\n      if (oldTag.isEqualNode(newTag)) {\n        oldTags.splice(k, 1);\n        return false;\n      }\n    }\n\n    return true;\n  });\n  oldTags.forEach(t => t.parentNode.removeChild(t));\n  newTags.forEach(t => headEl.insertBefore(t, headCountEl));\n  headCountEl.content = (headCount - oldTags.length + newTags.length).toString();\n}\n\nfunction initHeadManager() {\n  let updatePromise = null;\n  return {\n    mountedInstances: new Set(),\n    updateHead: head => {\n      const promise = updatePromise = Promise.resolve().then(() => {\n        if (promise !== updatePromise) return;\n        updatePromise = null;\n        const tags = {};\n        head.forEach(h => {\n          const components = tags[h.type] || [];\n          components.push(h);\n          tags[h.type] = components;\n        });\n        const titleComponent = tags.title ? tags.title[0] : null;\n        let title = '';\n\n        if (titleComponent) {\n          const {\n            children\n          } = titleComponent.props;\n          title = typeof children === 'string' ? children : Array.isArray(children) ? children.join('') : '';\n        }\n\n        if (title !== document.title) document.title = title;\n        ['meta', 'base', 'link', 'style', 'script'].forEach(type => {\n          updateElements(type, tags[type] || []);\n        });\n      });\n    }\n  };\n}","map":null,"metadata":{},"sourceType":"script"}