: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
}).observe(document, {childList: true, subtree: true});
processScriptsAndPreloads();
if (document.readyState === 'complete') {
readyStateCompleteCheck();
async function readyListener() {
processScriptsAndPreloads();
if (document.readyState === 'complete') {
readyStateCompleteCheck();
document.removeEventListener('readystatechange', readyListener);
document.addEventListener('readystatechange', readyListener);
let importMapPromise = initPromise;
let firstPolyfillLoad = true;
let acceptingImportMaps = true;
async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
acceptingImportMaps = false;
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
// early analysis opt-out - no need to even fetch if we have feature support
if (!shimMode && baselinePassthrough) {
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
await lastStaticLoadPromise;
return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
const load = getOrCreateLoad(url, fetchOpts, null, source);
await loadAll(load, seen);
await lastStaticLoadPromise;
if (source && !shimMode && !load.n) {
if (nativelyLoaded) return;
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
return await dynamicImport(createBlob(source), { errUrl: source });
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
firstPolyfillLoad = false;
const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
// if the top-level load is a shell, run its update function
(await dynamicImport(load.s)).u$_(module);
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
// when tla is supported, this should return the tla promise as an actual handle
// so readystate can still correspond to the sync subgraph exec completions
function revokeObjectURLs(registryKeys) {
const keysLength = registryKeys.length;
const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
const batchStartIndex = batch * 100;
if (batchStartIndex > keysLength) return
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
const load = registry[key];
if (load) URL.revokeObjectURL(load.b);
function urlJsString (url) {
return `'${url.replace(/'/g, "\\'")}'`;
function resolveDeps (load, seen) {
if (load.b || !seen[load.u])
for (const dep of load.d)
const [imports, exports] = load.a;
// edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
// once all deps have loaded we can inline the dependency resolution blobs
let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
function pushStringTo (originalIndex) {
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
const dynamicImportEnd = dynamicImportEndStack.pop();
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
lastIndex = dynamicImportEnd;
resolvedSource += source.slice(lastIndex, originalIndex);
lastIndex = originalIndex;
for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
// dependency source replacements
if (dynamicImportIndex === -1) {
let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
// circular shell creation
if (!(blobUrl = depLoad.s)) {
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
depLoad.a[1].map(({ s, e }, i) => {
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
}}\n//# sourceURL=${depLoad.r}?cycle`);
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
// circular shell execution
if (!cycleShell && depLoad.s) {
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
lastIndex = statementEnd;
else if (dynamicImportIndex === -2) {
load.m = { url: load.r, resolve: metaResolve };
metaHook(load.m, load.u);
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
lastIndex = statementEnd;
pushStringTo(statementStart + 6);
resolvedSource += `Shim(`;
dynamicImportEndStack.push(statementEnd - 1);
// support progressive cycle binding updates (try statement avoids tdz errors)
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports.filter(e => e.ln).map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`).join(',')}})}catch(_){};\n`;
function pushSourceURL (commentPrefix, commentStart) {
const urlStart = commentStart + commentPrefix.length;
const commentEnd = source.indexOf('\n', urlStart);
const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
resolvedSource += new URL(source.slice(urlStart, urlEnd), load.r).href;
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
// ignore sourceMap comments before already spliced code
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
// sourceURL first / only
if (sourceURLCommentStart !== -1 && (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)) {
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
if (sourceMapURLCommentStart !== -1) {
pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
if (sourceURLCommentStart !== -1 && (sourceURLCommentStart > sourceMapURLCommentStart))
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
pushStringTo(source.length);
if (sourceURLCommentStart === -1)
resolvedSource += sourceURLCommentPrefix + load.r;
load.b = lastLoad = createBlob(resolvedSource);
const sourceURLCommentPrefix = '\n//# sourceURL=';
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
const wasmContentType = /^(application)\/wasm(;|$)/;
const jsonContentType = /^(text|application)\/json(;|$)/;
const cssContentType = /^(text|application)\/css(;|$)/;
const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
// restrict in-flight fetches to a pool of 100
function pushFetchPool () {
return new Promise(r => p.push(r));
function popFetchPool () {
async function doFetch (url, fetchOpts, parent) {
if (enforceIntegrity && !fetchOpts.integrity)
throw Error(`No integrity for ${url}${fromParent(parent)}.`);
const poolQueue = pushFetchPool();
if (poolQueue) await poolQueue;
var res = await fetchHook(url, fetchOpts);
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
const error = new TypeError(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
async function fetchModule (url, fetchOpts, parent) {
const res = await doFetch(url, fetchOpts, parent);
const contentType = res.headers.get('content-type');
if (jsContentType.test(contentType))
return { r: res.url, s: await res.text(), t: 'js' };
else if (wasmContentType.test(contentType)) {
const module = importShim._w[url] = await WebAssembly.compileStreaming(res);
let s = '', i = 0, importObj = '';
for (const impt of WebAssembly.Module.imports(module)) {
s += `import * as impt${i} from '${impt.module}';\n`;
importObj += `'${impt.module}':impt${i++},`;
s += `const instance = await WebAssembly.instantiate(importShim._w['${url}'], {${importObj}});\n`;
for (const expt of WebAssembly.Module.exports(module)) {
s += `const expt${i} = instance['${expt.name}'];\n`;
s += `export { expt${i++} as "${expt.name}" };\n`;
return { r: res.url, s, t: 'wasm' };
else if (jsonContentType.test(contentType))
return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
else if (cssContentType.test(contentType)) {
return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
});export default s;`, t: 'css' };
throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
function getOrCreateLoad (url, fetchOpts, parent, source) {
let load = registry[url];
r: source ? url : undefined,
while (registry[load.u + ++i]);
// preload fetch options override fetch options (race)
({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
load.a = parse(source, load.u);
load.a = [[], [], false];
load.L = load.f.then(async () => {
let childFetchOpts = fetchOpts;
load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
if (d !== -1 || !n) return;
const { r, b } = await resolve(n, load.r || load.u);
if (b && (!supportsImportMaps || importMapSrcOrLazy))
if (skip && skip(r)) return { b: r };
if (childFetchOpts.integrity)
childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
return getOrCreateLoad(r, childFetchOpts, load.r).f;
function processScriptsAndPreloads (mapsOnly = false) {
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
for (const script of document.querySelectorAll(shimMode ? 'script[type=importmap-shim]' : 'script[type=importmap]'))
processImportMap(script);
for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
function getFetchOpts (script) {
fetchOpts.integrity = script.integrity;
if (script.referrerPolicy)
fetchOpts.referrerPolicy = script.referrerPolicy;
if (script.crossOrigin === 'use-credentials')
fetchOpts.credentials = 'include';
else if (script.crossOrigin === 'anonymous')
fetchOpts.credentials = 'omit';
fetchOpts.credentials = 'same-origin';
let lastStaticLoadPromise = Promise.resolve();
let domContentLoadedCnt = 1;
function domContentLoadedCheck () {
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
document.dispatchEvent(new Event('DOMContentLoaded'));
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
document.addEventListener('DOMContentLoaded', async () => {
let readyStateCompleteCnt = 1;
function readyStateCompleteCheck () {
if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
document.dispatchEvent(new Event('readystatechange'));
const hasNext = script => script.nextSibling || script.parentNode && hasNext(script.parentNode);
const epCheck = (script, ready) => script.ep || !ready && (!script.src && !script.innerHTML || !hasNext(script)) || script.getAttribute('noshim') !== null || !(script.ep = true);
function processImportMap (script, ready = readyStateCompleteCnt > 0) {
if (epCheck(script, ready)) return;
// we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
if (acceptingImportMaps) {
importMapPromise = importMapPromise
importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
if (e instanceof SyntaxError)
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
acceptingImportMaps = false;
function processScript (script, ready = readyStateCompleteCnt > 0) {
if (epCheck(script, ready)) return;
// does this load block readystate complete
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
// does this load block DOMContentLoaded
const isDomContentLoadedScript = domContentLoadedCnt > 0;
if (isBlockingReadyScript) readyStateCompleteCnt++;
if (isDomContentLoadedScript) domContentLoadedCnt++;
const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isBlockingReadyScript && lastStaticLoadPromise)
// if the type of the script tag "module-shim", browser does not dispatch a "load" event
// see https://github.com/guybedford/es-module-shims/issues/346
script.dispatchEvent(new Event('load'));
if (isBlockingReadyScript)
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
if (isDomContentLoadedScript)
loadPromise.then(domContentLoadedCheck);
function processPreload (link) {
if (fetchCache[link.href])
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));