{"ast":null,"code":"\"use strict\";\n\nexports.__esModule = true;\nexports[\"default\"] = initHeadManager;\nvar DOMAttributeNames = {\n  acceptCharset: 'accept-charset',\n  className: 'class',\n  htmlFor: 'for',\n  httpEquiv: 'http-equiv'\n};\n\nfunction reactElementToDOM(_ref) {\n  var type = _ref.type,\n      props = _ref.props;\n  var el = document.createElement(type);\n\n  for (var 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    var attr = DOMAttributeNames[p] || p.toLowerCase();\n    el.setAttribute(attr, props[p]);\n  }\n\n  var children = props.children,\n      dangerouslySetInnerHTML = props.dangerouslySetInnerHTML;\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  var headEl = document.getElementsByTagName('head')[0];\n  var 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  var headCount = Number(headCountEl.content);\n  var oldTags = [];\n\n  for (var 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  var newTags = components.map(reactElementToDOM).filter(function (newTag) {\n    for (var k = 0, len = oldTags.length; k < len; k++) {\n      var 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(function (t) {\n    return t.parentNode.removeChild(t);\n  });\n  newTags.forEach(function (t) {\n    return headEl.insertBefore(t, headCountEl);\n  });\n  headCountEl.content = (headCount - oldTags.length + newTags.length).toString();\n}\n\nfunction initHeadManager() {\n  var updatePromise = null;\n  return {\n    mountedInstances: new Set(),\n    updateHead: function updateHead(head) {\n      var promise = updatePromise = Promise.resolve().then(function () {\n        if (promise !== updatePromise) return;\n        updatePromise = null;\n        var tags = {};\n        head.forEach(function (h) {\n          var components = tags[h.type] || [];\n          components.push(h);\n          tags[h.type] = components;\n        });\n        var titleComponent = tags.title ? tags.title[0] : null;\n        var title = '';\n\n        if (titleComponent) {\n          var children = titleComponent.props.children;\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(function (type) {\n          updateElements(type, tags[type] || []);\n        });\n      });\n    }\n  };\n}","map":null,"metadata":{},"sourceType":"script"}