{"version":3,"file":"es-module-shims.js","sources":["../dist/es-module-shims.js"],"sourcesContent":["/* ES Module Shims 2.0.10 */\n(function () {\n\n const hasDocument = typeof document !== 'undefined';\r\n\r\n const noop = () => {};\r\n\r\n const dynamicImport = (u, errUrl) => import(u);\r\n\r\n const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;\r\n\r\n const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};\r\n Object.assign(esmsInitOptions, self.esmsInitOptions || {});\r\n\r\n // shim mode is determined on initialization, no late shim mode\r\n const shimMode =\r\n hasDocument ?\r\n esmsInitOptions.shimMode ||\r\n document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')\r\n .length > 0\r\n : true;\r\n\r\n const importHook = globalHook(shimMode && esmsInitOptions.onimport);\r\n const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);\r\n let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;\r\n const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;\r\n const tsTransform =\r\n esmsInitOptions.tsTransform ||\r\n (hasDocument &&\r\n document.currentScript &&\r\n document.currentScript.src.replace(/\\.js$/, '-typescript.js')) ||\r\n './es-module-shims-typescript.js';\r\n\r\n const mapOverrides = esmsInitOptions.mapOverrides;\r\n\r\n let nonce = esmsInitOptions.nonce;\r\n if (!nonce && hasDocument) {\r\n const nonceElement = document.querySelector('script[nonce]');\r\n if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');\r\n }\r\n\r\n const onerror = globalHook(esmsInitOptions.onerror || noop);\r\n\r\n const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;\r\n\r\n function globalHook(name) {\r\n return typeof name === 'string' ? self[name] : name;\r\n }\r\n\r\n const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];\r\n const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');\r\n const enableLatest = esmsInitOptions.polyfillEnable === 'latest' || enable.includes('latest');\r\n const cssModulesEnabled = enable.includes('css-modules') || enableAll || enableLatest;\r\n const jsonModulesEnabled = enable.includes('json-modules') || enableAll || enableLatest;\r\n const wasmModulesEnabled = enable.includes('wasm-modules') || enableAll;\r\n const sourcePhaseEnabled = enable.includes('source-phase') || enableAll;\r\n const typescriptEnabled = enable.includes('typescript') || enableAll;\r\n\r\n const onpolyfill =\r\n esmsInitOptions.onpolyfill ?\r\n globalHook(esmsInitOptions.onpolyfill)\r\n : () => {\r\n console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');\r\n };\r\n\r\n const baseUrl =\r\n hasDocument ?\r\n document.baseURI\r\n : `${location.protocol}//${location.host}${\r\n location.pathname.includes('/') ?\r\n location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)\r\n : location.pathname\r\n }`;\r\n\r\n const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));\r\n let { skip } = esmsInitOptions;\r\n if (Array.isArray(skip)) {\r\n const l = skip.map(s => new URL(s, baseUrl).href);\r\n skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);\r\n } else if (typeof skip === 'string') {\r\n const r = new RegExp(skip);\r\n skip = s => r.test(s);\r\n } else if (skip instanceof RegExp) {\r\n skip = s => skip.test(s);\r\n }\r\n\r\n const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));\r\n\r\n const throwError = err => {\r\n (self.reportError || dispatchError)(err), void onerror(err);\r\n };\r\n\r\n function fromParent(parent) {\r\n return parent ? ` imported from ${parent}` : '';\r\n }\n\n const backslashRegEx = /\\\\/g;\n\n function asURL(url) {\n try {\n if (url.indexOf(':') !== -1) return new URL(url).href;\n } catch (_) {}\n }\n\n function resolveUrl(relUrl, parentUrl) {\n return resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);\n }\n\n function resolveIfNotPlainOrUrl(relUrl, parentUrl) {\n const hIdx = parentUrl.indexOf('#'),\n qIdx = parentUrl.indexOf('?');\n if (hIdx + qIdx > -2)\n parentUrl = parentUrl.slice(\n 0,\n hIdx === -1 ? qIdx\n : qIdx === -1 || qIdx > hIdx ? hIdx\n : qIdx\n );\n if (relUrl.indexOf('\\\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');\n // protocol-relative\n if (relUrl[0] === '/' && relUrl[1] === '/') {\n return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;\n }\n // relative-url\n else if (\n (relUrl[0] === '.' &&\n (relUrl[1] === '/' ||\n (relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||\n (relUrl.length === 1 && (relUrl += '/')))) ||\n relUrl[0] === '/'\n ) {\n const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);\n if (parentProtocol === 'blob:') {\n throw new TypeError(\n `Failed to resolve module specifier \"${relUrl}\". Invalid relative url or base scheme isn't hierarchical.`\n );\n }\n // Disabled, but these cases will give inconsistent results for deep backtracking\n //if (parentUrl[parentProtocol.length] !== '/')\n // throw new Error('Cannot resolve');\n // read pathname from parent URL\n // pathname taken to be part after leading \"/\"\n let pathname;\n if (parentUrl[parentProtocol.length + 1] === '/') {\n // resolving to a :// so we need to read out the auth and host\n if (parentProtocol !== 'file:') {\n pathname = parentUrl.slice(parentProtocol.length + 2);\n pathname = pathname.slice(pathname.indexOf('/') + 1);\n } else {\n pathname = parentUrl.slice(8);\n }\n } else {\n // resolving to :/ so pathname is the /... part\n pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));\n }\n\n if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;\n\n // join together and split for removal of .. and . segments\n // looping the string instead of anything fancy for perf reasons\n // '../../../../../z' resolved to 'x/y' is just 'z'\n const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;\n\n const output = [];\n let segmentIndex = -1;\n for (let i = 0; i < segmented.length; i++) {\n // busy reading a segment - only terminate on '/'\n if (segmentIndex !== -1) {\n if (segmented[i] === '/') {\n output.push(segmented.slice(segmentIndex, i + 1));\n segmentIndex = -1;\n }\n continue;\n }\n // new segment - check if it is relative\n else if (segmented[i] === '.') {\n // ../ segment\n if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {\n output.pop();\n i += 2;\n continue;\n }\n // ./ segment\n else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {\n i += 1;\n continue;\n }\n }\n // it is the start of a new segment\n while (segmented[i] === '/') i++;\n segmentIndex = i;\n }\n // finish reading out the last segment\n if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));\n return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');\n }\n }\n\n function resolveAndComposeImportMap(json, baseUrl, parentMap) {\n const outMap = {\n imports: Object.assign({}, parentMap.imports),\n scopes: Object.assign({}, parentMap.scopes),\n integrity: Object.assign({}, parentMap.integrity)\n };\n\n if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);\n\n if (json.scopes)\n for (let s in json.scopes) {\n const resolvedScope = resolveUrl(s, baseUrl);\n resolveAndComposePackages(\n json.scopes[s],\n outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),\n baseUrl,\n parentMap\n );\n }\n\n if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);\n\n return outMap;\n }\n\n function getMatch(path, matchObj) {\n if (matchObj[path]) return path;\n let sepIndex = path.length;\n do {\n const segment = path.slice(0, sepIndex + 1);\n if (segment in matchObj) return segment;\n } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);\n }\n\n function applyPackages(id, packages) {\n const pkgName = getMatch(id, packages);\n if (pkgName) {\n const pkg = packages[pkgName];\n if (pkg === null) return;\n return pkg + id.slice(pkgName.length);\n }\n }\n\n function resolveImportMap(importMap, resolvedOrPlain, parentUrl) {\n let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);\n while (scopeUrl) {\n const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);\n if (packageResolution) return packageResolution;\n scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);\n }\n return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);\n }\n\n function resolveAndComposePackages(packages, outPackages, baseUrl, parentMap) {\n for (let p in packages) {\n const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;\n if (\n (!shimMode || !mapOverrides) &&\n outPackages[resolvedLhs] &&\n outPackages[resolvedLhs] !== packages[resolvedLhs]\n ) {\n console.warn(\n `es-module-shims: Rejected map override \"${resolvedLhs}\" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`\n );\n continue;\n }\n let target = packages[p];\n if (typeof target !== 'string') continue;\n const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);\n if (mapped) {\n outPackages[resolvedLhs] = mapped;\n continue;\n }\n console.warn(`es-module-shims: Mapping \"${p}\" -> \"${packages[p]}\" does not resolve`);\n }\n }\n\n function resolveAndComposeIntegrity(integrity, outIntegrity, baseUrl) {\n for (let p in integrity) {\n const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;\n if (\n (!shimMode || !mapOverrides) &&\n outIntegrity[resolvedLhs] &&\n outIntegrity[resolvedLhs] !== integrity[resolvedLhs]\n ) {\n console.warn(\n `es-module-shims: Rejected map integrity override \"${resolvedLhs}\" from ${outIntegrity[resolvedLhs]} to ${integrity[resolvedLhs]}.`\n );\n }\n outIntegrity[resolvedLhs] = integrity[p];\n }\n }\n\n // support browsers without dynamic import support (eg Firefox 6x)\n let supportsJsonType = false;\n let supportsCssType = false;\n\n const supports = hasDocument && HTMLScriptElement.supports;\n\n let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');\n let supportsWasmModules = false;\n let supportsSourcePhase = false;\n let supportsMultipleImportMaps = false;\n\n const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];\n\n let featureDetectionPromise = (async function () {\n if (!hasDocument)\n return Promise.all([\n cssModulesEnabled &&\n import(createBlob(`import\"${createBlob('', 'text/css')}\"with{type:\"css\"}`)).then(\n () => (supportsCssType = true),\n noop\n ),\n jsonModulesEnabled &&\n import(createBlob(`import\"${createBlob('{}', 'text/json')}\"with{type:\"json\"}`)).then(\n () => (supportsJsonType = true),\n noop\n ),\n wasmModulesEnabled &&\n import(createBlob(`import\"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}\"`)).then(\n () => (supportsWasmModules = true),\n noop\n ),\n wasmModulesEnabled &&\n sourcePhaseEnabled &&\n import(createBlob(`import source x from\"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}\"`)).then(\n () => (supportsSourcePhase = true),\n noop\n )\n ]);\n\n return new Promise(resolve => {\n const iframe = document.createElement('iframe');\n iframe.style.display = 'none';\n iframe.setAttribute('nonce', nonce);\n function cb({ data }) {\n const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';\n if (!isFeatureDetectionMessage) return;\n [\n ,\n supportsImportMaps,\n supportsMultipleImportMaps,\n supportsCssType,\n supportsJsonType,\n supportsWasmModules,\n supportsSourcePhase\n ] = data;\n resolve();\n document.head.removeChild(iframe);\n window.removeEventListener('message', cb, false);\n }\n window.addEventListener('message', cb, false);\n\n const importMapTest = `