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GpB,QAAQ,IACb,EAAY,KAAI,SAAU,GACxB,OAAO,EAAK,EAAK,GAAS,MAAK,SAAU,GACvC,EAAY,EAAU,OAAO,EAC/B,GACF,KACA,MAAK,WACL,OAAO,CACT,GACF","file":"/npm/doloreexplicabo@1.16.1/src/inline.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/doloreexplicabo@1.16.1/src/inline.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n\nvar util = require(\"./util\"),\n  inlineImage = require(\"./inlineImage\"),\n  inlineScript = require(\"./inlineScript\"),\n  inlineCss = require(\"./inlineCss\"),\n  cssSupport = require(\"./cssSupport\");\n\nvar getUrlBasePath = function (url) {\n  return util.joinUrl(url, \".\");\n};\n\nvar parameterHashFunction = function (params) {\n  // HACK JSON.stringify is poor man's hashing;\n  // same objects might not receive same result as key order is not guaranteed\n  var a = params.map(function (param, idx) {\n    // Only include options relevant for method\n    if (idx === params.length - 1) {\n      param = {\n        // Two different HTML pages on the same path level have the same base path, but a different URL\n        baseUrl: getUrlBasePath(param.baseUrl),\n      };\n    }\n    return JSON.stringify(param);\n  });\n  return a;\n};\n\nvar memoizeFunctionOnCaching = function (func, options) {\n  if (\n    options.cache !== false &&\n    options.cache !== \"none\" &&\n    options.cacheBucket\n  ) {\n    return util.memoize(func, parameterHashFunction, options.cacheBucket);\n  } else {\n    return func;\n  }\n};\n\n/* Style inlining */\n\nvar requestExternalsForStylesheet = function (\n  styleContent,\n  alreadyLoadedCssUrls,\n  options\n) {\n  var cssRules = cssSupport.rulesForCssText(styleContent);\n\n  return inlineCss\n    .loadCSSImportsForRules(cssRules, alreadyLoadedCssUrls, options)\n    .then(function (cssImportResult) {\n      return inlineCss\n        .loadAndInlineCSSResourcesForRules(cssRules, options)\n        .then(function (cssResourcesResult) {\n          var errors = cssImportResult.errors.concat(cssResourcesResult.errors),\n            hasChanges =\n              cssImportResult.hasChanges || cssResourcesResult.hasChanges;\n\n          if (hasChanges) {\n            styleContent = cssSupport.cssRulesToText(cssRules);\n          }\n\n          return {\n            hasChanges: hasChanges,\n            content: styleContent,\n            errors: errors,\n          };\n        });\n    });\n};\n\nvar loadAndInlineCssForStyle = function (style, options, alreadyLoadedCssUrls) {\n  var styleContent = style.textContent,\n    processExternals = memoizeFunctionOnCaching(\n      requestExternalsForStylesheet,\n      options\n    );\n\n  return processExternals(styleContent, alreadyLoadedCssUrls, options).then(\n    function (result) {\n      if (result.hasChanges) {\n        style.childNodes[0].nodeValue = result.content;\n      }\n\n      return util.cloneArray(result.errors);\n    }\n  );\n};\n\nvar getCssStyleElements = function (doc) {\n  var styles = doc.getElementsByTagName(\"style\");\n\n  return Array.prototype.filter.call(styles, function (style) {\n    return !style.attributes.type || style.attributes.type.value === \"text/css\";\n  });\n};\n\nexports.loadAndInlineStyles = function (doc, options) {\n  var styles = getCssStyleElements(doc),\n    allErrors = [],\n    alreadyLoadedCssUrls = [],\n    inlineOptions;\n\n  inlineOptions = util.clone(options);\n  inlineOptions.baseUrl = inlineOptions.baseUrl || util.getDocumentBaseUrl(doc);\n\n  return Promise.all(\n    styles.map(function (style) {\n      return loadAndInlineCssForStyle(\n        style,\n        inlineOptions,\n        alreadyLoadedCssUrls\n      ).then(function (errors) {\n        allErrors = allErrors.concat(errors);\n      });\n    })\n  ).then(function () {\n    return allErrors;\n  });\n};\n\n/* CSS link inlining */\n\nvar substituteLinkWithInlineStyle = function (oldLinkNode, styleContent) {\n  var parent = oldLinkNode.parentNode,\n    styleNode;\n\n  styleContent = styleContent.trim();\n  if (styleContent) {\n    styleNode = oldLinkNode.ownerDocument.createElement(\"style\");\n    styleNode.type = \"text/css\";\n    styleNode.appendChild(\n      oldLinkNode.ownerDocument.createTextNode(styleContent)\n    );\n\n    parent.insertBefore(styleNode, oldLinkNode);\n  }\n\n  parent.removeChild(oldLinkNode);\n};\n\nvar requestStylesheetAndInlineResources = function (url, options) {\n  return util\n    .ajax(url, options)\n    .then(function (content) {\n      var cssRules = cssSupport.rulesForCssText(content);\n\n      return {\n        content: content,\n        cssRules: cssRules,\n      };\n    })\n    .then(function (result) {\n      var hasChangesFromPathAdjustment = inlineCss.adjustPathsOfCssResources(\n        url,\n        result.cssRules\n      );\n\n      return {\n        content: result.content,\n        cssRules: result.cssRules,\n        hasChanges: hasChangesFromPathAdjustment,\n      };\n    })\n    .then(function (result) {\n      return inlineCss\n        .loadCSSImportsForRules(result.cssRules, [], options)\n        .then(function (cssImportResult) {\n          return {\n            content: result.content,\n            cssRules: result.cssRules,\n            hasChanges: result.hasChanges || cssImportResult.hasChanges,\n            errors: cssImportResult.errors,\n          };\n        });\n    })\n    .then(function (result) {\n      return inlineCss\n        .loadAndInlineCSSResourcesForRules(result.cssRules, options)\n        .then(function (cssResourcesResult) {\n          return {\n            content: result.content,\n            cssRules: result.cssRules,\n            hasChanges: result.hasChanges || cssResourcesResult.hasChanges,\n            errors: result.errors.concat(cssResourcesResult.errors),\n          };\n        });\n    })\n    .then(function (result) {\n      var content = result.content;\n      if (result.hasChanges) {\n        content = cssSupport.cssRulesToText(result.cssRules);\n      }\n      return {\n        content: content,\n        errors: result.errors,\n      };\n    });\n};\n\nvar loadLinkedCSS = function (link, options) {\n  var cssHref = link.attributes.href.value,\n    documentBaseUrl = util.getDocumentBaseUrl(link.ownerDocument),\n    ajaxOptions = util.clone(options);\n\n  if (!ajaxOptions.baseUrl && documentBaseUrl) {\n    ajaxOptions.baseUrl = documentBaseUrl;\n  }\n\n  var processStylesheet = memoizeFunctionOnCaching(\n    requestStylesheetAndInlineResources,\n    options\n  );\n\n  return processStylesheet(cssHref, ajaxOptions).then(function (result) {\n    return {\n      content: result.content,\n      errors: util.cloneArray(result.errors),\n    };\n  });\n};\n\nvar getCssStylesheetLinks = function (doc) {\n  var links = doc.getElementsByTagName(\"link\");\n\n  return Array.prototype.filter.call(links, function (link) {\n    return (\n      link.attributes.rel &&\n      link.attributes.rel.value === \"stylesheet\" &&\n      (!link.attributes.type || link.attributes.type.value === \"text/css\")\n    );\n  });\n};\n\nexports.loadAndInlineCssLinks = function (doc, options) {\n  var links = getCssStylesheetLinks(doc),\n    errors = [];\n\n  return Promise.all(\n    links.map(function (link) {\n      return loadLinkedCSS(link, options).then(\n        function (result) {\n          substituteLinkWithInlineStyle(link, result.content + \"\\n\");\n\n          errors = errors.concat(result.errors);\n        },\n        function (e) {\n          errors.push({\n            resourceType: \"stylesheet\",\n            url: e.url,\n            msg: \"Unable to load stylesheet \" + e.url,\n          });\n        }\n      );\n    })\n  ).then(function () {\n    return errors;\n  });\n};\n\n/* Main */\n\nexports.loadAndInlineImages = inlineImage.inline;\nexports.loadAndInlineScript = inlineScript.inline;\n\nexports.inlineReferences = function (doc, options) {\n  var allErrors = [],\n    inlineFuncs = [\n      exports.loadAndInlineImages,\n      exports.loadAndInlineStyles,\n      exports.loadAndInlineCssLinks,\n    ];\n\n  if (options.inlineScripts !== false) {\n    inlineFuncs.push(exports.loadAndInlineScript);\n  }\n\n  return Promise.all(\n    inlineFuncs.map(function (func) {\n      return func(doc, options).then(function (errors) {\n        allErrors = allErrors.concat(errors);\n      });\n    })\n  ).then(function () {\n    return allErrors;\n  });\n};\n"]}