@skaldapp/runtime 3.0.22 → 3.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1482 @@
1
+ /** ES Module Shims @version 2.8.0 */
2
+ (function () {
3
+
4
+ const self_ = typeof globalThis !== 'undefined' ? globalThis : self;
5
+
6
+ let invalidate;
7
+ const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
8
+ const initHotReload = (topLevelLoad, importShim) => {
9
+ let _importHook = importHook,
10
+ _resolveHook = resolveHook,
11
+ _metaHook = metaHook;
12
+
13
+ let defaultResolve;
14
+ let hotResolveHook = (id, parent, _defaultResolve) => {
15
+ if (!defaultResolve) defaultResolve = _defaultResolve;
16
+ const originalParent = stripVersion(parent);
17
+ const url = stripVersion(defaultResolve(id, originalParent));
18
+ const hotState = getHotState(url);
19
+ const parents = hotState.p;
20
+ if (!parents.includes(originalParent)) parents.push(originalParent);
21
+ return toVersioned(url, hotState);
22
+ };
23
+ const hotImportHook = (url, _, __, source, sourceType) => {
24
+ const hotState = getHotState(url);
25
+ hotState.e = typeof source === 'string' ? source : true;
26
+ hotState.t = sourceType;
27
+ };
28
+ const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
29
+
30
+ const Hot = class Hot {
31
+ constructor(url) {
32
+ this.data = getHotState((this.url = stripVersion(url))).d;
33
+ }
34
+ accept(deps, cb) {
35
+ if (typeof deps === 'function') {
36
+ cb = deps;
37
+ deps = null;
38
+ }
39
+ const hotState = getHotState(this.url);
40
+ if (!hotState.A) return;
41
+ (hotState.a = hotState.a || []).push([
42
+ typeof deps === 'string' ? defaultResolve(deps, this.url)
43
+ : deps ? deps.map(d => defaultResolve(d, this.url))
44
+ : null,
45
+ cb
46
+ ]);
47
+ }
48
+ dispose(cb) {
49
+ getHotState(this.url).u = cb;
50
+ }
51
+ invalidate() {
52
+ const hotState = getHotState(this.url);
53
+ hotState.a = hotState.A = null;
54
+ const seen = [this.url];
55
+ hotState.p.forEach(p => invalidate(p, this.url, seen));
56
+ }
57
+ };
58
+
59
+ const versionedRegEx = /\?v=\d+$/;
60
+ const stripVersion = url => {
61
+ const versionMatch = url.match(versionedRegEx);
62
+ return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
63
+ };
64
+
65
+ const toVersioned = (url, hotState) => {
66
+ const { v } = hotState;
67
+ return url + (v ? '?v=' + v : '');
68
+ };
69
+
70
+ let hotRegistry = {},
71
+ curInvalidationRoots = new Set(),
72
+ curInvalidationInterval;
73
+ const getHotState = url =>
74
+ hotRegistry[url] ||
75
+ (hotRegistry[url] = {
76
+ // version
77
+ v: 0,
78
+ // accept list ([deps, cb] pairs)
79
+ a: null,
80
+ // accepting acceptors
81
+ A: true,
82
+ // unload callback
83
+ u: null,
84
+ // entry point or inline script source
85
+ e: false,
86
+ // hot data
87
+ d: {},
88
+ // parents
89
+ p: [],
90
+ // source type
91
+ t: undefined
92
+ });
93
+
94
+ invalidate = (url, fromUrl, seen = []) => {
95
+ const hotState = hotRegistry[url];
96
+ if (!hotState || seen.includes(url)) return false;
97
+ seen.push(url);
98
+ hotState.A = false;
99
+ if (
100
+ fromUrl &&
101
+ hotState.a &&
102
+ hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
103
+ ) {
104
+ curInvalidationRoots.add(fromUrl);
105
+ } else {
106
+ if (hotState.e || hotState.a) curInvalidationRoots.add(url);
107
+ hotState.v++;
108
+ if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
109
+ }
110
+ if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
111
+ return true;
112
+ };
113
+
114
+ const handleInvalidations = () => {
115
+ curInvalidationInterval = null;
116
+ const earlyRoots = new Set();
117
+ for (const root of curInvalidationRoots) {
118
+ const hotState = hotRegistry[root];
119
+ topLevelLoad(
120
+ toVersioned(root, hotState),
121
+ baseUrl,
122
+ defaultFetchOpts,
123
+ typeof hotState.e === 'string' ? hotState.e : undefined,
124
+ false,
125
+ undefined,
126
+ hotState.t
127
+ ).then(m => {
128
+ if (hotState.a) {
129
+ hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
130
+ // unload should be the latest unload handler from the just loaded module
131
+ if (hotState.u) {
132
+ hotState.u(hotState.d);
133
+ hotState.u = null;
134
+ }
135
+ }
136
+ hotState.p.forEach(p => {
137
+ const hotState = hotRegistry[p];
138
+ if (hotState && hotState.a)
139
+ hotState.a.forEach(
140
+ async ([d, c]) =>
141
+ d &&
142
+ !earlyRoots.has(c) &&
143
+ (typeof d === 'string' ?
144
+ d === root && c(m)
145
+ : c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
146
+ );
147
+ });
148
+ }, throwError);
149
+ }
150
+ curInvalidationRoots = new Set();
151
+ };
152
+
153
+ setHooks(
154
+ _importHook ? chain(_importHook, hotImportHook) : hotImportHook,
155
+ _resolveHook ?
156
+ (id, parent, defaultResolve) =>
157
+ hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
158
+ : hotResolveHook,
159
+ _metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
160
+ );
161
+ };
162
+
163
+ const hasDocument = typeof document !== 'undefined';
164
+
165
+ const noop = () => {};
166
+
167
+ const chain = (a, b) =>
168
+ function () {
169
+ a.apply(this, arguments);
170
+ b.apply(this, arguments);
171
+ };
172
+
173
+ const dynamicImport = (u, _errUrl) => import(u);
174
+
175
+ const defineValue = (obj, prop, value) =>
176
+ Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
177
+
178
+ const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
179
+
180
+ const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
181
+ Object.assign(esmsInitOptions, self_.esmsInitOptions || {});
182
+
183
+ const version = "2.8.0";
184
+
185
+ const r$1 = esmsInitOptions.version;
186
+ if (self_.importShim || (r$1 && r$1 !== version)) {
187
+ return;
188
+ }
189
+
190
+ // shim mode is determined on initialization, no late shim mode
191
+ const shimMode =
192
+ esmsInitOptions.shimMode ||
193
+ (hasDocument ?
194
+ document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
195
+ .length > 0
196
+ // Without a document, shim mode is always true as we cannot polyfill
197
+ : true);
198
+
199
+ let importHook,
200
+ resolveHook,
201
+ fetchHook = fetch,
202
+ sourceHook,
203
+ metaHook,
204
+ tsTransform =
205
+ esmsInitOptions.tsTransform ||
206
+ (hasDocument && document.currentScript && document.currentScript.src.replace(/(\.\w+)?\.js$/, '-typescript.js')) ||
207
+ './es-module-shims-typescript.js';
208
+
209
+ const defaultFetchOpts = { credentials: 'same-origin' };
210
+
211
+ const globalHook = name => (typeof name === 'string' ? self_[name] : name);
212
+
213
+ if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
214
+ if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
215
+ if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
216
+ if (esmsInitOptions.source) sourceHook = globalHook(esmsInitOptions.source);
217
+ if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
218
+
219
+ const hasCustomizationHooks = importHook || resolveHook || fetchHook !== fetch || sourceHook || metaHook;
220
+
221
+ const {
222
+ noLoadEventRetriggers,
223
+ enforceIntegrity,
224
+ hotReload,
225
+ hotReloadInterval = 100,
226
+ nativePassthrough = !hasCustomizationHooks && !hotReload
227
+ } = esmsInitOptions;
228
+
229
+ const setHooks = (importHook_, resolveHook_, metaHook_) => (
230
+ (importHook = importHook_),
231
+ (resolveHook = resolveHook_),
232
+ (metaHook = metaHook_)
233
+ );
234
+
235
+ const mapOverrides = esmsInitOptions.mapOverrides;
236
+
237
+ let nonce = esmsInitOptions.nonce;
238
+ if (!nonce && hasDocument) {
239
+ const nonceElement = document.querySelector('script[nonce]');
240
+ if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
241
+ }
242
+
243
+ const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
244
+
245
+ const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
246
+ const disable = Array.isArray(esmsInitOptions.polyfillDisable) ? esmsInitOptions.polyfillDisable : [];
247
+
248
+ const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
249
+ const wasmInstancePhaseEnabled =
250
+ enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
251
+ const wasmSourcePhaseEnabled =
252
+ enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
253
+ const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
254
+ const cssModulesEnabled = !disable.includes('css-modules');
255
+ const jsonModulesEnabled = !disable.includes('json-modules');
256
+
257
+ const onpolyfill =
258
+ esmsInitOptions.onpolyfill ?
259
+ globalHook(esmsInitOptions.onpolyfill)
260
+ : () => {
261
+ console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
262
+ };
263
+
264
+ const baseUrl =
265
+ hasDocument ? document.baseURI
266
+ : typeof location !== 'undefined' ?
267
+ `${location.protocol}//${location.host}${
268
+ location.pathname.includes('/') ?
269
+ location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
270
+ : location.pathname
271
+ }`
272
+ : 'about:blank';
273
+
274
+ const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
275
+ let { skip } = esmsInitOptions;
276
+ if (Array.isArray(skip)) {
277
+ const l = skip.map(s => new URL(s, baseUrl).href);
278
+ skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
279
+ } else if (typeof skip === 'string') {
280
+ const r = new RegExp(skip);
281
+ skip = s => r.test(s);
282
+ } else if (skip instanceof RegExp) {
283
+ skip = s => skip.test(s);
284
+ }
285
+
286
+ const dispatchError = error => self_.dispatchEvent(Object.assign(new Event('error'), { error }));
287
+
288
+ const throwError = err => {
289
+ (self_.reportError || dispatchError)(err);
290
+ onerror(err);
291
+ };
292
+
293
+ const fromParent = parent => (parent ? ` imported from ${parent}` : '');
294
+
295
+ const backslashRegEx = /\\/g;
296
+
297
+ const asURL = url => {
298
+ try {
299
+ if (url.indexOf(':') !== -1) return new URL(url).href;
300
+ } catch (_) {}
301
+ };
302
+
303
+ const resolveUrl = (relUrl, parentUrl) =>
304
+ resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
305
+
306
+ const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
307
+ const hIdx = parentUrl.indexOf('#'),
308
+ qIdx = parentUrl.indexOf('?');
309
+ if (hIdx + qIdx > -2)
310
+ parentUrl = parentUrl.slice(
311
+ 0,
312
+ hIdx === -1 ? qIdx
313
+ : qIdx === -1 || qIdx > hIdx ? hIdx
314
+ : qIdx
315
+ );
316
+ if (relUrl.indexOf('\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
317
+ // protocol-relative
318
+ if (relUrl[0] === '/' && relUrl[1] === '/') {
319
+ return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
320
+ }
321
+ // relative-url
322
+ else if (
323
+ (relUrl[0] === '.' &&
324
+ (relUrl[1] === '/' ||
325
+ (relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
326
+ (relUrl.length === 1 && (relUrl += '/')))) ||
327
+ relUrl[0] === '/'
328
+ ) {
329
+ const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
330
+ if (parentProtocol === 'blob:') {
331
+ throw new TypeError(
332
+ `Failed to resolve module specifier "${relUrl}". Invalid relative url or base scheme isn't hierarchical.`
333
+ );
334
+ }
335
+ // Disabled, but these cases will give inconsistent results for deep backtracking
336
+ //if (parentUrl[parentProtocol.length] !== '/')
337
+ // throw new Error('Cannot resolve');
338
+ // read pathname from parent URL
339
+ // pathname taken to be part after leading "/"
340
+ let pathname;
341
+ if (parentUrl[parentProtocol.length + 1] === '/') {
342
+ // resolving to a :// so we need to read out the auth and host
343
+ if (parentProtocol !== 'file:') {
344
+ pathname = parentUrl.slice(parentProtocol.length + 2);
345
+ pathname = pathname.slice(pathname.indexOf('/') + 1);
346
+ } else {
347
+ pathname = parentUrl.slice(8);
348
+ }
349
+ } else {
350
+ // resolving to :/ so pathname is the /... part
351
+ pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
352
+ }
353
+
354
+ if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
355
+
356
+ // join together and split for removal of .. and . segments
357
+ // looping the string instead of anything fancy for perf reasons
358
+ // '../../../../../z' resolved to 'x/y' is just 'z'
359
+ const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
360
+
361
+ const output = [];
362
+ let segmentIndex = -1;
363
+ for (let i = 0; i < segmented.length; i++) {
364
+ // busy reading a segment - only terminate on '/'
365
+ if (segmentIndex !== -1) {
366
+ if (segmented[i] === '/') {
367
+ output.push(segmented.slice(segmentIndex, i + 1));
368
+ segmentIndex = -1;
369
+ }
370
+ continue;
371
+ }
372
+ // new segment - check if it is relative
373
+ else if (segmented[i] === '.') {
374
+ // ../ segment
375
+ if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
376
+ output.pop();
377
+ i += 2;
378
+ continue;
379
+ }
380
+ // ./ segment
381
+ else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
382
+ i += 1;
383
+ continue;
384
+ }
385
+ }
386
+ // it is the start of a new segment
387
+ while (segmented[i] === '/') i++;
388
+ segmentIndex = i;
389
+ }
390
+ // finish reading out the last segment
391
+ if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
392
+ return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
393
+ }
394
+ };
395
+
396
+ const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
397
+ const outMap = {
398
+ imports: { ...parentMap.imports },
399
+ scopes: { ...parentMap.scopes },
400
+ integrity: { ...parentMap.integrity }
401
+ };
402
+
403
+ if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
404
+
405
+ if (json.scopes)
406
+ for (let s in json.scopes) {
407
+ const resolvedScope = resolveUrl(s, baseUrl);
408
+ resolveAndComposePackages(
409
+ json.scopes[s],
410
+ outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
411
+ baseUrl,
412
+ parentMap
413
+ );
414
+ }
415
+
416
+ if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
417
+
418
+ return outMap;
419
+ };
420
+
421
+ const getMatch = (path, matchObj) => {
422
+ if (matchObj[path]) return path;
423
+ let sepIndex = path.length;
424
+ do {
425
+ const segment = path.slice(0, sepIndex + 1);
426
+ if (segment in matchObj) return segment;
427
+ } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
428
+ };
429
+
430
+ const applyPackages = (id, packages) => {
431
+ const pkgName = getMatch(id, packages);
432
+ if (pkgName) {
433
+ const pkg = packages[pkgName];
434
+ if (pkg === null) return;
435
+ return pkg + id.slice(pkgName.length);
436
+ }
437
+ };
438
+
439
+ const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
440
+ let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
441
+ while (scopeUrl) {
442
+ const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
443
+ if (packageResolution) return packageResolution;
444
+ scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
445
+ }
446
+ return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
447
+ };
448
+
449
+ const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
450
+ for (let p in packages) {
451
+ const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
452
+ if (
453
+ (!shimMode || !mapOverrides) &&
454
+ outPackages[resolvedLhs] &&
455
+ outPackages[resolvedLhs] !== packages[resolvedLhs]
456
+ ) {
457
+ console.warn(
458
+ `es-module-shims: Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`
459
+ );
460
+ continue;
461
+ }
462
+ let target = packages[p];
463
+ if (typeof target !== 'string') continue;
464
+ const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
465
+ if (mapped) {
466
+ outPackages[resolvedLhs] = mapped;
467
+ continue;
468
+ }
469
+ console.warn(`es-module-shims: Mapping "${p}" -> "${packages[p]}" does not resolve`);
470
+ }
471
+ };
472
+
473
+ const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
474
+ for (let p in integrity) {
475
+ const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
476
+ if (
477
+ (!shimMode || !mapOverrides) &&
478
+ outIntegrity[resolvedLhs] &&
479
+ outIntegrity[resolvedLhs] !== integrity[resolvedLhs]
480
+ ) {
481
+ console.warn(
482
+ `es-module-shims: Rejected map integrity override "${resolvedLhs}" from ${outIntegrity[resolvedLhs]} to ${integrity[resolvedLhs]}.`
483
+ );
484
+ }
485
+ outIntegrity[resolvedLhs] = integrity[p];
486
+ }
487
+ };
488
+
489
+ let policy;
490
+ if (typeof window.trustedTypes !== 'undefined' || typeof window.TrustedTypes !== 'undefined') {
491
+ try {
492
+ policy = (window.trustedTypes || window.TrustedTypes).createPolicy('es-module-shims', {
493
+ createHTML: html => html,
494
+ createScript: script => script
495
+ });
496
+ } catch {}
497
+ }
498
+
499
+ function maybeTrustedInnerHTML(html) {
500
+ return policy ? policy.createHTML(html) : html;
501
+ }
502
+
503
+ function maybeTrustedScript(script) {
504
+ return policy ? policy.createScript(script) : script;
505
+ }
506
+
507
+ // support browsers without dynamic import support (eg Firefox 6x)
508
+ let supportsJsonType = false;
509
+ let supportsCssType = false;
510
+
511
+ const supports = hasDocument && HTMLScriptElement.supports;
512
+
513
+ let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
514
+ let supportsWasmInstancePhase = false;
515
+ let supportsWasmSourcePhase = false;
516
+ let supportsMultipleImportMaps = false;
517
+
518
+ const wasmBytes = [0, 97, 115, 109, 1, 0, 0, 0];
519
+
520
+ let featureDetectionPromise = (async function () {
521
+ if (!hasDocument)
522
+ return Promise.all([
523
+ import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
524
+ () => (
525
+ (supportsJsonType = true),
526
+ import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
527
+ () => (supportsCssType = true),
528
+ noop
529
+ )
530
+ ),
531
+ noop
532
+ ),
533
+ wasmInstancePhaseEnabled &&
534
+ import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
535
+ () => (supportsWasmInstancePhase = true),
536
+ noop
537
+ ),
538
+ wasmSourcePhaseEnabled &&
539
+ import(createBlob(`import source x from"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
540
+ () => (supportsWasmSourcePhase = true),
541
+ noop
542
+ )
543
+ ]);
544
+
545
+ const msgTag = `s${version}`;
546
+ return new Promise(resolve => {
547
+ const iframe = document.createElement('iframe');
548
+ iframe.style.display = 'none';
549
+ iframe.setAttribute('nonce', nonce);
550
+ function cb({ data }) {
551
+ const isFeatureDetectionMessage = Array.isArray(data) && data[0] === msgTag;
552
+ if (!isFeatureDetectionMessage) return;
553
+ [
554
+ ,
555
+ supportsImportMaps,
556
+ supportsMultipleImportMaps,
557
+ supportsJsonType,
558
+ supportsCssType,
559
+ supportsWasmSourcePhase,
560
+ supportsWasmInstancePhase
561
+ ] = data;
562
+ resolve();
563
+ document.head.removeChild(iframe);
564
+ window.removeEventListener('message', cb, false);
565
+ }
566
+ window.addEventListener('message', cb, false);
567
+ // Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. CSS gates on JSON feature check, Wasm instance phase gates on wasm source phase check.
568
+ const importMapTest = `<script nonce=${nonce || ''}>${
569
+ policy ? 't=(window.trustedTypes||window.TrustedTypes).createPolicy("es-module-shims",{createScript:s=>s});' : ''
570
+ }b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>${
571
+ policy ? 't.createScript(innerText=>' : ''
572
+ }document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText}))${
573
+ policy ? ')' : ''
574
+ };i(\`{"imports":{"x":"\${b('')}"}}\`);i(\`{"imports":{"y":"\${b('')}"}}\`);cm=${
575
+ supportsImportMaps && jsonModulesEnabled ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
576
+ };sp=${
577
+ supportsImportMaps && wasmSourcePhaseEnabled ?
578
+ `c(b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))`
579
+ : 'false'
580
+ };Promise.all([${supportsImportMaps ? 'true' : "c('x')"},${supportsImportMaps ? "c('y')" : false},cm,${
581
+ supportsImportMaps && cssModulesEnabled ?
582
+ `cm.then(s=>s?c(b(\`import"\${b('','text/css')\}"with{type:"css"}\`)):false)`
583
+ : 'false'
584
+ },sp,${
585
+ supportsImportMaps && wasmInstancePhaseEnabled ?
586
+ `${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))${wasmSourcePhaseEnabled ? ':false)' : ''}`
587
+ : 'false'
588
+ }]).then(a=>parent.postMessage(['${msgTag}'].concat(a),'*'))<${''}/script>`;
589
+
590
+ // Safari will call onload eagerly on head injection, but we don't want the Wechat
591
+ // path to trigger before setting srcdoc, therefore we track the timing
592
+ let readyForOnload = false,
593
+ onloadCalledWhileNotReady = false;
594
+ function doOnload() {
595
+ if (!readyForOnload) {
596
+ onloadCalledWhileNotReady = true;
597
+ return;
598
+ }
599
+ // WeChat browser doesn't support setting srcdoc scripts
600
+ // But iframe sandboxes don't support contentDocument so we do this as a fallback
601
+ const doc = iframe.contentDocument;
602
+ if (doc && doc.head.childNodes.length === 0) {
603
+ const s = doc.createElement('script');
604
+ if (nonce) s.setAttribute('nonce', nonce);
605
+ s.innerText = maybeTrustedScript(importMapTest.slice(15 + (nonce ? nonce.length : 0), -9));
606
+ doc.head.appendChild(s);
607
+ }
608
+ }
609
+
610
+ iframe.onload = doOnload;
611
+ // WeChat browser requires append before setting srcdoc
612
+ document.head.appendChild(iframe);
613
+
614
+ // setting srcdoc is not supported in React native webviews on iOS
615
+ // setting src to a blob URL results in a navigation event in webviews
616
+ // document.write gives usability warnings
617
+ readyForOnload = true;
618
+ if ('srcdoc' in iframe) iframe.srcdoc = maybeTrustedInnerHTML(importMapTest);
619
+ else iframe.contentDocument.write(importMapTest);
620
+ // retrigger onload for Safari only if necessary
621
+ if (onloadCalledWhileNotReady) doOnload();
622
+ });
623
+ })();
624
+
625
+ /* es-module-lexer 2.0.0 */
626
+ let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},f="xportmportlassforetaourceeferromsyncunctionvoyiedelecontininstantybreareturdebuggeawaithrwhileifcatcfinallels";let t,c$1,n;function parse(k,u="@"){t=k,c$1=u;const l=2*t.length+(2<<18);if(l>i||!e){for(;l>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,109)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),t=new e.Uint8Array(r),c=new e.Uint16Array(r),n=1040;function b(){var e=0,a=0,r=0,t=0,c=0,b=0,l=0;l=n;n=n+10240|0;i[808]=1;i[807]=0;s[401]=0;s[402]=0;f[70]=f[2];i[809]=0;f[68]=0;i[806]=0;f[71]=l+2048;f[72]=l;i[810]=0;e=(f[3]|0)+-2|0;f[73]=e;a=e+(f[66]<<1)|0;f[74]=a;e:while(1){r=e+2|0;f[73]=r;if(e>>>0>=a>>>0){t=18;break}a:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[402]|0)==0?H(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(k(),(i[808]|0)==0):0){t=9;break e}else t=17;break}case 105:{if(H(r)|0?(m(e+4|0,26,10)|0)==0:0){u();t=17;}else t=17;break}case 59:{t=17;break}case 47:switch(s[e+4>>1]|0){case 47:{E();break a}case 42:{y(1);break a}default:{t=16;break e}}default:{t=16;break e}}}while(0);if((t|0)==17){t=0;f[70]=f[73];}e=f[73]|0;a=f[74]|0;}if((t|0)==9){e=f[73]|0;f[70]=e;t=19;}else if((t|0)==16){i[808]=0;f[73]=e;t=19;}else if((t|0)==18)if(!(i[806]|0)){e=r;t=19;}else e=0;do{if((t|0)==19){e:while(1){a=e+2|0;f[73]=a;if(e>>>0>=(f[74]|0)>>>0){t=92;break}a:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[402]|0)==0?H(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){k();t=91;}else t=91;break}case 105:{if(H(a)|0?(m(e+4|0,26,10)|0)==0:0){u();t=91;}else t=91;break}case 99:{if((H(a)|0?(m(e+4|0,36,8)|0)==0:0)?W(s[e+12>>1]|0)|0:0){i[810]=1;t=91;}else t=91;break}case 40:{r=f[71]|0;e=s[402]|0;t=e&65535;f[r+(t<<3)>>2]=1;a=f[70]|0;s[402]=e+1<<16>>16;f[r+(t<<3)+4>>2]=a;t=91;break}case 41:{a=s[402]|0;if(!(a<<16>>16)){t=36;break e}r=a+-1<<16>>16;s[402]=r;t=s[401]|0;a=t&65535;if(t<<16>>16!=0?(f[(f[71]|0)+((r&65535)<<3)>>2]|0)==5:0){a=f[(f[72]|0)+(a+-1<<2)>>2]|0;r=a+4|0;if(!(f[r>>2]|0))f[r>>2]=(f[70]|0)+2;f[a+12>>2]=e+4;s[401]=t+-1<<16>>16;t=91;}else t=91;break}case 123:{t=f[70]|0;r=f[63]|0;e=t;do{if((s[t>>1]|0)==41&(r|0)!=0?(f[r+4>>2]|0)==(t|0):0){a=f[64]|0;f[63]=a;if(!a){f[59]=0;break}else {f[a+36>>2]=0;break}}}while(0);r=f[71]|0;a=s[402]|0;t=a&65535;f[r+(t<<3)>>2]=(i[810]|0)==0?2:6;s[402]=a+1<<16>>16;f[r+(t<<3)+4>>2]=e;i[810]=0;t=91;break}case 125:{e=s[402]|0;if(!(e<<16>>16)){t=49;break e}r=f[71]|0;t=e+-1<<16>>16;s[402]=t;if((f[r+((t&65535)<<3)>>2]|0)==4){h();t=91;}else t=91;break}case 39:{v(39);t=91;break}case 34:{v(34);t=91;break}case 47:switch(s[e+4>>1]|0){case 47:{E();break a}case 42:{y(1);break a}default:{e=f[70]|0;a=s[e>>1]|0;r:do{if(!(U(a)|0))if(a<<16>>16==41){r=s[402]|0;if(!(z(f[(f[71]|0)+((r&65535)<<3)+4>>2]|0)|0))t=65;}else t=64;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){t=64;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){t=64;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){t=64;break r}else break r;default:break r}}while(0);if((t|0)==64){r=s[402]|0;t=65;}r:do{if((t|0)==65){t=0;if(r<<16>>16!=0?(c=f[71]|0,b=(r&65535)+-1|0,a<<16>>16==102?(f[c+(b<<3)>>2]|0)==1:0):0){if((s[e+-2>>1]|0)==111?$(f[c+(b<<3)+4>>2]|0,44,3)|0:0)break}else t=69;if((t|0)==69?(0,a<<16>>16==125):0){t=f[71]|0;r=r&65535;if(p(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(o(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[809]|0)break r;break}default:{}}t=f[65]|0;if((t|0?e>>>0>=(f[t>>2]|0)>>>0:0)?e>>>0<=(f[t+4>>2]|0)>>>0:0){g();i[809]=0;t=91;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[70]=e;a=s[e>>1]|0;}while(!(B(a)|0));if(D(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[70]=e;}while(D(s[e>>1]|0)|0);if(T(e)|0){g();i[809]=0;t=91;break a}}i[809]=1;t=91;break a}}}while(0);g();i[809]=0;t=91;break a}}case 96:{r=f[71]|0;a=s[402]|0;t=a&65535;f[r+(t<<3)+4>>2]=f[70];s[402]=a+1<<16>>16;f[r+(t<<3)>>2]=3;h();t=91;break}default:t=91;}}while(0);if((t|0)==91){t=0;f[70]=f[73];}e=f[73]|0;}if((t|0)==36){V();e=0;break}else if((t|0)==49){V();e=0;break}else if((t|0)==92){e=(i[806]|0)==0?(s[401]|s[402])<<16>>16==0:0;break}}}while(0);n=l;return e|0}function k(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0,k=0,u=0,o=0,h=0,d=0,C=0,g=0;k=f[73]|0;u=f[65]|0;g=k+12|0;f[73]=g;r=w(1)|0;e=f[73]|0;if(!((e|0)==(g|0)?!(I(r)|0):0))C=3;e:do{if((C|0)==3){a:do{switch(r<<16>>16){case 123:{f[73]=e+2;e=w(1)|0;a=f[73]|0;while(1){if(X(e)|0){v(e);e=(f[73]|0)+2|0;f[73]=e;}else {P(e)|0;e=f[73]|0;}w(1)|0;e=A(a,e)|0;if(e<<16>>16==44){f[73]=(f[73]|0)+2;e=w(1)|0;}if(e<<16>>16==125){C=15;break}g=a;a=f[73]|0;if((a|0)==(g|0)){C=12;break}if(a>>>0>(f[74]|0)>>>0){C=14;break}}if((C|0)==12){V();break e}else if((C|0)==14){V();break e}else if((C|0)==15){i[807]=1;f[73]=(f[73]|0)+2;break a}break}case 42:{f[73]=e+2;w(1)|0;g=f[73]|0;A(g,g)|0;break}default:{i[808]=0;switch(r<<16>>16){case 100:{k=e+14|0;f[73]=k;switch((w(1)|0)<<16>>16){case 97:{a=f[73]|0;if((m(a+2|0,80,8)|0)==0?(c=a+10|0,D(s[c>>1]|0)|0):0){f[73]=c;w(0)|0;C=22;}break}case 102:{C=22;break}case 99:{a=f[73]|0;if(((m(a+2|0,36,8)|0)==0?(t=a+10|0,g=s[t>>1]|0,W(g)|0|g<<16>>16==123):0)?(f[73]=t,n=w(1)|0,n<<16>>16!=123):0){d=n;C=31;}break}default:{}}r:do{if((C|0)==22?(b=f[73]|0,(m(b+2|0,88,14)|0)==0):0){r=b+16|0;a=s[r>>1]|0;if(!(W(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[73]=r;a=w(1)|0;if(a<<16>>16==42){f[73]=(f[73]|0)+2;a=w(1)|0;}if(a<<16>>16!=40){d=a;C=31;}}}while(0);if((C|0)==31?(o=f[73]|0,P(d)|0,h=f[73]|0,h>>>0>o>>>0):0){O(e,k,o,h);f[73]=(f[73]|0)+-2;break e}O(e,k,0,0);f[73]=e+12;break e}case 97:{f[73]=e+10;w(0)|0;e=f[73]|0;C=35;break}case 102:{C=35;break}case 99:{if((m(e+2|0,36,8)|0)==0?(a=e+10|0,B(s[a>>1]|0)|0):0){f[73]=a;g=w(1)|0;C=f[73]|0;P(g)|0;g=f[73]|0;O(C,g,C,g);f[73]=(f[73]|0)+-2;break e}e=e+4|0;f[73]=e;break}case 108:case 118:break;default:break e}if((C|0)==35){f[73]=e+16;e=w(1)|0;if(e<<16>>16==42){f[73]=(f[73]|0)+2;e=w(1)|0;}C=f[73]|0;P(e)|0;g=f[73]|0;O(C,g,C,g);f[73]=(f[73]|0)+-2;break e}f[73]=e+6;i[808]=0;r=w(1)|0;e=f[73]|0;r=(P(r)|0|32)<<16>>16==123;t=f[73]|0;if(r){f[73]=t+2;g=w(1)|0;e=f[73]|0;P(g)|0;}r:while(1){a=f[73]|0;if((a|0)==(e|0))break;O(e,a,e,a);a=w(1)|0;if(r)switch(a<<16>>16){case 93:case 125:break e;default:{}}e=f[73]|0;if(a<<16>>16!=44){C=51;break}f[73]=e+2;a=w(1)|0;e=f[73]|0;switch(a<<16>>16){case 91:case 123:{C=51;break r}default:{}}P(a)|0;}if((C|0)==51)f[73]=e+-2;if(!r)break e;f[73]=t+-2;break e}}}while(0);g=(w(1)|0)<<16>>16==102;e=f[73]|0;if(g?(m(e+2|0,74,6)|0)==0:0){f[73]=e+8;l(k,w(1)|0,0);e=(u|0)==0?240:u+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0;}}f[73]=e+-2;}}while(0);return}function u(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0;b=f[73]|0;c=b+12|0;f[73]=c;e=w(1)|0;t=f[73]|0;e:do{if(e<<16>>16!=46){if(!(e<<16>>16==115&t>>>0>c>>>0)){if(!(e<<16>>16==100&t>>>0>(b+10|0)>>>0)){t=0;n=28;break}if(m(t+2|0,66,8)|0){a=t;e=100;t=0;n=59;break}e=t+10|0;if(!(W(s[e>>1]|0)|0)){a=t;e=100;t=0;n=59;break}f[73]=e;e=w(1)|0;if(e<<16>>16==42){e=42;t=2;n=61;break}f[73]=t;t=0;n=28;break}if((m(t+2|0,56,10)|0)==0?(r=t+12|0,W(s[r>>1]|0)|0):0){f[73]=r;e=w(1)|0;a=f[73]|0;if((a|0)!=(r|0)){if(e<<16>>16!=102){t=1;n=28;break}if(m(a+2|0,74,6)|0){e=102;t=1;n=59;break}if(!(B(s[a+8>>1]|0)|0)){e=102;t=1;n=59;break}}f[73]=t;t=0;n=28;}else {a=t;e=115;t=0;n=59;}}else {f[73]=t+2;switch((w(1)|0)<<16>>16){case 109:{e=f[73]|0;if(m(e+2|0,50,6)|0)break e;a=f[70]|0;if(!(F(a)|0)?(s[a>>1]|0)==46:0)break e;d(b,b,e+8|0,2);break e}case 115:{e=f[73]|0;if(m(e+2|0,56,10)|0)break e;a=f[70]|0;if(!(F(a)|0)?(s[a>>1]|0)==46:0)break e;f[73]=e+12;e=w(1)|0;t=1;n=28;break e}case 100:{e=f[73]|0;if(m(e+2|0,66,8)|0)break e;a=f[70]|0;if(!(F(a)|0)?(s[a>>1]|0)==46:0)break e;f[73]=e+10;e=w(1)|0;t=2;n=28;break e}default:break e}}}while(0);e:do{if((n|0)==28){if(e<<16>>16==40){r=f[71]|0;a=s[402]|0;c=a&65535;f[r+(c<<3)>>2]=5;e=f[73]|0;s[402]=a+1<<16>>16;f[r+(c<<3)+4>>2]=e;if((s[f[70]>>1]|0)==46)break;f[73]=e+2;a=w(1)|0;d(b,f[73]|0,0,e);if(!t)e=f[63]|0;else {e=f[63]|0;f[e+28>>2]=(t|0)==1?5:7;}c=f[72]|0;b=s[401]|0;s[401]=b+1<<16>>16;f[c+((b&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{f[73]=(f[73]|0)+-2;break e}}e=(f[73]|0)+2|0;f[73]=e;switch((w(1)|0)<<16>>16){case 44:{f[73]=(f[73]|0)+2;w(1)|0;c=f[63]|0;f[c+4>>2]=e;b=f[73]|0;f[c+16>>2]=b;i[c+24>>0]=1;f[73]=b+-2;break e}case 41:{s[402]=(s[402]|0)+-1<<16>>16;b=f[63]|0;f[b+4>>2]=e;f[b+12>>2]=(f[73]|0)+2;i[b+24>>0]=1;s[401]=(s[401]|0)+-1<<16>>16;break e}default:{f[73]=(f[73]|0)+-2;break e}}}if(!((t|0)==0&e<<16>>16==123)){switch(e<<16>>16){case 42:case 39:case 34:{n=61;break e}default:{}}a=f[73]|0;n=59;break}e=f[73]|0;if(s[402]|0){f[73]=e+-2;break}while(1){if(e>>>0>=(f[74]|0)>>>0)break;e=w(1)|0;if(!(X(e)|0)){if(e<<16>>16==125){n=49;break}}else v(e);e=(f[73]|0)+2|0;f[73]=e;}if((n|0)==49)f[73]=(f[73]|0)+2;c=(w(1)|0)<<16>>16==102;e=f[73]|0;if(c?m(e+2|0,74,6)|0:0){V();break}f[73]=e+8;e=w(1)|0;if(X(e)|0){l(b,e,0);break}else {V();break}}}while(0);if((n|0)==59)if((a|0)==(c|0))f[73]=b+10;else n=61;do{if((n|0)==61){if(!((e<<16>>16==42|(t|0)!=2)&(s[402]|0)==0)){f[73]=(f[73]|0)+-2;break}e=f[74]|0;a=f[73]|0;while(1){if(a>>>0>=e>>>0){n=68;break}r=s[a>>1]|0;if(X(r)|0){n=66;break}n=a+2|0;f[73]=n;a=n;}if((n|0)==66){l(b,r,t);break}else if((n|0)==68){V();break}}}while(0);return}function l(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,t=0,c=0,n=0,b=0;i=(f[73]|0)+2|0;switch(a<<16>>16){case 39:{v(39);t=5;break}case 34:{v(34);t=5;break}default:V();}do{if((t|0)==5){d(e,i,f[73]|0,1);if((r|0)>0)f[(f[63]|0)+28>>2]=(r|0)==1?4:6;f[73]=(f[73]|0)+2;n=(w(0)|0)<<16>>16==119;c=f[73]|0;if(((n?(s[c+2>>1]|0)==105:0)?(s[c+4>>1]|0)==116:0)?(s[c+6>>1]|0)==104:0){f[73]=c+8;if((w(1)|0)<<16>>16!=123){f[73]=c;break}n=f[73]|0;i=n;t=0;e:while(1){f[73]=i+2;i=w(1)|0;do{if(i<<16>>16!=39){a=f[73]|0;if(i<<16>>16==34){v(34);e=(f[73]|0)+2|0;f[73]=e;i=w(1)|0;break}else {i=P(i)|0;e=f[73]|0;break}}else {a=f[73]|0;v(39);e=(f[73]|0)+2|0;f[73]=e;i=w(1)|0;}}while(0);if(i<<16>>16!=58){t=21;break}f[73]=(f[73]|0)+2;switch((w(1)|0)<<16>>16){case 39:{i=f[73]|0;v(39);break}case 34:{i=f[73]|0;v(34);break}default:{t=25;break e}}b=(f[73]|0)+2|0;r=f[67]|0;f[67]=r+20;f[r>>2]=a;f[r+4>>2]=e;f[r+8>>2]=i;f[r+12>>2]=b;f[r+16>>2]=0;f[((t|0)==0?(f[63]|0)+32|0:t+16|0)>>2]=r;f[73]=(f[73]|0)+2;switch((w(1)|0)<<16>>16){case 125:{t=29;break e}case 44:break;default:{t=27;break e}}i=(f[73]|0)+2|0;f[73]=i;t=r;}if((t|0)==21){f[73]=c;break}else if((t|0)==25){f[73]=c;break}else if((t|0)==27){f[73]=c;break}else if((t|0)==29){b=f[63]|0;f[b+16>>2]=n;f[b+12>>2]=(f[73]|0)+2;break}}f[73]=c+-2;}}while(0);return}function o(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=$(e+-4|0,102,2)|0;break e}case 108:{e=$(e+-4|0,106,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=j(e+-6|0,101)|0;break e}case 97:{e=j(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=$(e+-4|0,112,4)|0;break e}case 117:{e=$(e+-4|0,120,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=$(e+-8|0,132,6)|0;break e}case 112:{e=$(e+-8|0,144,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=$(e+-2|0,148,4)|0;break}case 110:{e=e+-2|0;if(j(e,105)|0)e=1;else e=$(e,156,5)|0;break}case 111:{e=j(e+-2|0,100)|0;break}case 114:{e=$(e+-2|0,166,7)|0;break}case 116:{e=$(e+-2|0,180,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=j(e+-4|0,110)|0;break e}case 111:{e=$(e+-4|0,188,3)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function h(){var e=0,a=0,r=0,i=0;a=f[74]|0;r=f[73]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;f[73]=e;a=f[71]|0;i=s[402]|0;r=i&65535;f[a+(r<<3)>>2]=4;s[402]=i+1<<16>>16;f[a+(r<<3)+4>>2]=e;}else if((a|0)==7){f[73]=e;r=f[71]|0;i=(s[402]|0)+-1<<16>>16;s[402]=i;if((f[r+((i&65535)<<3)>>2]|0)!=3)V();}else if((a|0)==10){f[73]=e;V();}return}function w(e){e=e|0;var a=0,r=0,i=0;r=f[73]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(W(a)|0)break;else break e;else if(D(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{E();break a}case 42:{y(e);break a}default:{a=47;break e}}}while(0);i=f[73]|0;r=i+2|0;f[73]=r;}while(i>>>0<(f[74]|0)>>>0);return a|0}function d(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;c=f[67]|0;f[67]=c+40;t=f[63]|0;f[((t|0)==0?236:t+36|0)>>2]=c;f[64]=t;f[63]=c;f[c+8>>2]=e;if(2==(s|0)){e=3;t=r;}else {t=1==(s|0);e=t?1:2;t=t?r+2|0:0;}f[c+12>>2]=t;f[c+28>>2]=e;f[c>>2]=a;f[c+4>>2]=r;f[c+16>>2]=0;f[c+20>>2]=s;a=1==(s|0);i[c+24>>0]=a&1;f[c+32>>2]=0;f[c+36>>2]=0;if(a|2==(s|0))i[807]=1;return}function v(e){e=e|0;var a=0,r=0,i=0,t=0;t=f[74]|0;a=f[73]|0;while(1){i=a+2|0;if(a>>>0>=t>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(re(r)|0){a=9;break}else a=i;}if((a|0)==9){f[73]=i;V();}else if((a|0)==10)f[73]=i;return}function A(e,a){e=e|0;a=a|0;var r=0,i=0,t=0,c=0;r=f[73]|0;i=s[r>>1]|0;c=(e|0)==(a|0);t=c?0:e;c=c?0:a;if(i<<16>>16==97){f[73]=r+4;r=w(1)|0;e=f[73]|0;if(X(r)|0){v(r);a=(f[73]|0)+2|0;f[73]=a;}else {P(r)|0;a=f[73]|0;}i=w(1)|0;r=f[73]|0;}if((r|0)!=(e|0))O(e,a,t,c);return i|0}function C(){var e=0,a=0,r=0;r=f[74]|0;a=f[73]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){f[73]=e;V();e=0;}else if((a|0)==7){f[73]=e;e=93;}return e|0}function g(){var e=0,a=0,r=0;e:while(1){e=f[73]|0;a=e+2|0;f[73]=a;if(e>>>0>=(f[74]|0)>>>0){r=7;break}switch(s[a>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{C()|0;break}case 92:{f[73]=e+4;break}default:{}}}if((r|0)==7)V();return}function p(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=$(e+-2|0,208,4)|0;break}case 121:{e=$(e+-2|0,216,6)|0;break}case 101:{e=$(e+-2|0,228,3)|0;break}default:e=0;}return e|0}function y(e){e=e|0;var a=0,r=0,i=0,t=0,c=0;t=(f[73]|0)+2|0;f[73]=t;r=f[74]|0;while(1){a=t+2|0;if(t>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?re(i)|0:0)break;if(i<<16>>16==42?(s[t+4>>1]|0)==47:0){c=8;break}t=a;}if((c|0)==8){f[73]=a;a=t+4|0;}f[73]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(f&255)|0;}}while(0);return e|0}function I(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function U(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function x(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(I(a)|0)return a<<16>>16!=46|(F(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function S(e){e=e|0;var a=0,r=0,i=0,t=0;r=n;n=n+16|0;i=r;f[i>>2]=0;f[66]=e;a=f[3]|0;t=a+(e<<1)|0;e=t+2|0;s[t>>1]=0;f[i>>2]=e;f[67]=e;f[59]=0;f[63]=0;f[61]=0;f[60]=0;f[65]=0;f[62]=0;n=r;return a|0}function O(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;t=f[67]|0;f[67]=t+20;c=f[65]|0;f[((c|0)==0?240:c+16|0)>>2]=t;f[65]=t;f[t>>2]=e;f[t+4>>2]=a;f[t+8>>2]=r;f[t+12>>2]=s;f[t+16>>2]=0;i[807]=1;return}function $(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;i=e+(0-r<<1)|0;s=i+2|0;e=f[3]|0;if(s>>>0>=e>>>0?(m(s,a,r<<1)|0)==0:0)if((s|0)==(e|0))e=1;else e=x(i)|0;else e=0;return e|0}function T(e){e=e|0;switch(s[e>>1]|0){case 107:{e=$(e+-2|0,148,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=$(e+-4|0,120,6)|0;else e=0;break}default:e=0;}return e|0}function j(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=B(s[e+-2>>1]|0)|0;else r=0;return r|0}function B(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(I(e)|0);}}while(0);return e|0}function E(){var e=0,a=0,r=0;e=f[74]|0;r=f[73]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}f[73]=a;return}function P(e){e=e|0;while(1){if(W(e)|0)break;if(I(e)|0)break;e=(f[73]|0)+2|0;f[73]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function q(){var e=0;e=f[(f[61]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1;}return e|0}function z(e){e=e|0;if(!($(e,194,5)|0)?!($(e,44,3)|0):0)e=$(e,204,2)|0;else e=1;return e|0}function D(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function F(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function G(){var e=0;e=f[69]|0;e=f[((e|0)==0?(f[61]|0)+32|0:e+16|0)>>2]|0;f[69]=e;return (e|0)!=0|0}function H(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=x(e+-2|0)|0;return e|0}function J(){var e=0;e=f[(f[62]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function K(){var e=0;e=f[(f[61]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function L(){var e=0;e=f[(f[62]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function M(){var e=0;e=f[(f[61]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function N(){var e=0;e=f[(f[61]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Q(){var e=0;e=f[61]|0;e=f[((e|0)==0?236:e+36|0)>>2]|0;f[61]=e;return (e|0)!=0|0}function R(){var e=0;e=f[62]|0;e=f[((e|0)==0?240:e+16|0)>>2]|0;f[62]=e;return (e|0)!=0|0}function V(){i[806]=1;f[68]=(f[73]|0)-(f[3]|0)>>1;f[73]=(f[74]|0)+2;return}function W(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function X(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function Y(){return (f[(f[69]|0)+12>>2]|0)-(f[3]|0)>>1|0}function Z(){return (f[(f[69]|0)+8>>2]|0)-(f[3]|0)>>1|0}function _(){return (f[(f[69]|0)+4>>2]|0)-(f[3]|0)>>1|0}function ee(){return (f[(f[61]|0)+8>>2]|0)-(f[3]|0)>>1|0}function ae(){return (f[(f[62]|0)+4>>2]|0)-(f[3]|0)>>1|0}function re(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function ie(){return (f[f[69]>>2]|0)-(f[3]|0)>>1|0}function se(){return (f[f[61]>>2]|0)-(f[3]|0)>>1|0}function fe(){return (f[f[62]>>2]|0)-(f[3]|0)>>1|0}function te(){return t[(f[61]|0)+24>>0]|0|0}function ce(e){e=e|0;f[3]=e;return}function ne(){return f[(f[61]|0)+28>>2]|0}function be(){return (i[807]|0)!=0|0}function ke(){return (i[808]|0)!=0|0}function ue(){f[69]=0;return}function le(){return f[68]|0}function oe(e){e=e|0;n=e+992+15&-16;return 992}return {su:oe,ai:M,ake:_,aks:ie,ave:Y,avs:Z,e:le,ee:ae,ele:J,els:L,es:fe,f:ke,id:q,ie:N,ip:te,is:se,it:ne,ms:be,p:b,ra:G,re:R,ri:Q,rsa:ue,sa:S,se:K,ses:ce,ss:ee}}("undefined"!=typeof globalThis?globalThis:self,{},a),r=e.su(i-(2<<17));}const h=t.length+1;e.ses(r),e.sa(h-1),s(t,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),c=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,t.charCodeAt(-1===s?a-1:a)));const u=[];for(e.rsa();e.ra();){const a=e.aks(),r=e.ake(),i=e.avs(),s=e.ave(),f=v(a,r),t=v(i,s);u.push([f,t]);}w.push({t:n,n:k,s:a,e:r,ss:f,se:c,d:s,a:i,at:u.length>0?u:null});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=v(a,r),t=i<0?void 0:v(i,s);d.push({s:a,e:r,ls:i,le:s,n:f,ln:t});}return [w,d,!!e.f(),!!e.ms()];function v(e,a){const r=t.charCodeAt(e);return 34===r||39===r?b(e+1,r):t.slice(e,a)}}function b(e,a){n=e;let r="",i=n;for(;;){n>=t.length&&o();const e=t.charCodeAt(n);if(e===a)break;92===e?(r+=t.slice(i,n),r+=k(),i=n):(8232===e||8233===e||l(e)&&o(),++n);}return r+=t.slice(i,n++),r}function k(){let e=t.charCodeAt(++n);switch(++n,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(u(2));case 117:return function(){const e=t.charCodeAt(n);let a;123===e?(++n,a=u(t.indexOf("}",n)-n),++n,a>1114111&&o()):a=u(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\t";case 98:return "\b";case 118:return "\v";case 102:return "\f";case 13:10===t.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=t.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=t.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return l(e)?"":String.fromCharCode(e)}}function u(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=t.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function l(e){return 13===e||10===e}function o(){throw Object.assign(Error(`Parse error ${c$1}:${t.slice(0,n).split("\n").length}:${n-t.lastIndexOf("\n",n-1)}`),{idx:n})}
627
+
628
+ const _resolve = (id, parentUrl = baseUrl) => {
629
+ const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
630
+ const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
631
+ const composedResolved =
632
+ composedImportMap === firstImportMap ? firstResolved : (
633
+ resolveImportMap(composedImportMap, urlResolved || id, parentUrl)
634
+ );
635
+ const resolved = composedResolved || firstResolved || throwUnresolved(id, parentUrl);
636
+ // needsShim, shouldShim per load record to set on parent
637
+ let n = false,
638
+ N = false;
639
+ if (!supportsImportMaps) {
640
+ // bare specifier -> needs shim
641
+ if (!urlResolved) n = true;
642
+ // url mapping -> should shim
643
+ else if (urlResolved !== resolved) N = true;
644
+ } else if (!supportsMultipleImportMaps) {
645
+ // bare specifier and not resolved by first import map -> needs shim
646
+ if (!urlResolved && !firstResolved) n = true;
647
+ // resolution doesn't match first import map -> should shim
648
+ if (firstResolved && resolved !== firstResolved) N = true;
649
+ }
650
+ return { r: resolved, n, N };
651
+ };
652
+
653
+ const resolve = (id, parentUrl) => {
654
+ if (!resolveHook) return _resolve(id, parentUrl);
655
+ const result = resolveHook(id, parentUrl, defaultResolve);
656
+
657
+ return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
658
+ };
659
+
660
+ // import()
661
+ async function importShim(id, opts, parentUrl) {
662
+ if (typeof opts === 'string') {
663
+ parentUrl = opts;
664
+ opts = undefined;
665
+ }
666
+ await initPromise; // needed for shim check
667
+ if (shimMode || !baselineSupport) {
668
+ if (hasDocument) processScriptsAndPreloads();
669
+ legacyAcceptingImportMaps = false;
670
+ }
671
+ let sourceType = undefined;
672
+ if (typeof opts === 'object') {
673
+ if (opts.lang === 'ts') sourceType = 'ts';
674
+ if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
675
+ sourceType = opts.with.type;
676
+ }
677
+ }
678
+ return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
679
+ }
680
+
681
+ // import.source()
682
+ // (opts not currently supported as no use cases yet)
683
+ if (shimMode || wasmSourcePhaseEnabled)
684
+ importShim.source = async (id, opts, parentUrl) => {
685
+ if (typeof opts === 'string') {
686
+ parentUrl = opts;
687
+ opts = undefined;
688
+ }
689
+ await initPromise; // needed for shim check
690
+ if (shimMode || !baselineSupport) {
691
+ if (hasDocument) processScriptsAndPreloads();
692
+ legacyAcceptingImportMaps = false;
693
+ }
694
+ await importMapPromise;
695
+ const url = resolve(id, parentUrl || baseUrl).r;
696
+ const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
697
+ await load.f;
698
+ return importShim._s[load.r];
699
+ };
700
+
701
+ // import.defer() is just a proxy for import(), since we can't actually defer
702
+ if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
703
+
704
+ if (hotReload) {
705
+ initHotReload(topLevelLoad, importShim);
706
+ importShim.hotReload = hotReload$1;
707
+ }
708
+
709
+ const defaultResolve = (id, parentUrl) => {
710
+ return (
711
+ resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
712
+ throwUnresolved(id, parentUrl)
713
+ );
714
+ };
715
+
716
+ const throwUnresolved = (id, parentUrl) => {
717
+ throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
718
+ };
719
+
720
+ const metaResolve = function (id, parentUrl = this.url) {
721
+ return resolve(id, `${parentUrl}`).r;
722
+ };
723
+
724
+ importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
725
+ importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
726
+ importShim.addImportMap = importMapIn => {
727
+ if (!shimMode) throw new Error('Unsupported in polyfill mode.');
728
+ composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
729
+ };
730
+ importShim.version = version;
731
+
732
+ const registry = (importShim._r = {});
733
+ // Wasm caches
734
+ const sourceCache = (importShim._s = {});
735
+ /* const instanceCache = */ importShim._i = new WeakMap();
736
+
737
+ // Ensure this version is the only version
738
+ defineValue(self_, 'importShim', Object.freeze(importShim));
739
+ const shimModeOptions = { ...esmsInitOptions, shimMode: true };
740
+ if (optionsScript) optionsScript.innerText = maybeTrustedScript(JSON.stringify(shimModeOptions));
741
+ self_.esmsInitOptions = shimModeOptions;
742
+
743
+ const loadAll = async (load, seen) => {
744
+ seen[load.u] = 1;
745
+ await load.L;
746
+ await Promise.all(
747
+ load.d.map(({ l: dep, s: sourcePhase }) => {
748
+ if (dep.b || seen[dep.u]) return;
749
+ if (sourcePhase) return dep.f;
750
+ return loadAll(dep, seen);
751
+ })
752
+ );
753
+ };
754
+
755
+ let importMapSrc = false;
756
+ let multipleImportMaps = false;
757
+ let firstImportMap = null;
758
+ // To support polyfilling multiple import maps, we separately track the composed import map from the first import map
759
+ let composedImportMap = { imports: {}, scopes: {}, integrity: {} };
760
+ let baselineSupport;
761
+
762
+ const initPromise = featureDetectionPromise.then(() => {
763
+ baselineSupport =
764
+ supportsImportMaps &&
765
+ (!jsonModulesEnabled || supportsJsonType) &&
766
+ (!cssModulesEnabled || supportsCssType) &&
767
+ (!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
768
+ (!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
769
+ !deferPhaseEnabled &&
770
+ (!multipleImportMaps || supportsMultipleImportMaps) &&
771
+ !importMapSrc &&
772
+ !hasCustomizationHooks;
773
+ if (!shimMode && typeof WebAssembly !== 'undefined') {
774
+ if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
775
+ const s = Symbol();
776
+ const brand = m => defineValue(m, s, 'WebAssembly.Module');
777
+ class AbstractModuleSource {
778
+ get [Symbol.toStringTag]() {
779
+ if (this[s]) return this[s];
780
+ throw new TypeError('Not an AbstractModuleSource');
781
+ }
782
+ }
783
+ const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
784
+ WebAssembly.Module = Object.setPrototypeOf(
785
+ Object.assign(function Module(...args) {
786
+ return brand(new wasmModule(...args));
787
+ }, wasmModule),
788
+ AbstractModuleSource
789
+ );
790
+ WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
791
+ WebAssembly.compile = function compile(...args) {
792
+ return wasmCompile(...args).then(brand);
793
+ };
794
+ WebAssembly.compileStreaming = function compileStreaming(...args) {
795
+ return wasmCompileStreaming(...args).then(brand);
796
+ };
797
+ }
798
+ }
799
+ if (hasDocument) {
800
+ if (!supportsImportMaps) {
801
+ const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
802
+ HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
803
+ }
804
+ if (shimMode || !baselineSupport) {
805
+ attachMutationObserver();
806
+ if (document.readyState === 'complete') {
807
+ readyStateCompleteCheck();
808
+ } else {
809
+ document.addEventListener('readystatechange', readyListener);
810
+ }
811
+ }
812
+ processScriptsAndPreloads();
813
+ }
814
+ return undefined;
815
+ });
816
+
817
+ const attachMutationObserver = () => {
818
+ const observer = new MutationObserver(mutations => {
819
+ for (const mutation of mutations) {
820
+ if (mutation.type !== 'childList') continue;
821
+ for (const node of mutation.addedNodes) {
822
+ if (node.tagName === 'SCRIPT') {
823
+ if (node.type === (shimMode ? 'module-shim' : 'module') && !node.ep) processScript(node, true);
824
+ if (node.type === (shimMode ? 'importmap-shim' : 'importmap') && !node.ep) processImportMap(node, true);
825
+ } else if (
826
+ node.tagName === 'LINK' &&
827
+ node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload') &&
828
+ !node.ep
829
+ ) {
830
+ processPreload(node);
831
+ }
832
+ }
833
+ }
834
+ });
835
+ observer.observe(document, { childList: true });
836
+ observer.observe(document.head, { childList: true });
837
+ processScriptsAndPreloads();
838
+ };
839
+
840
+ let importMapPromise = initPromise;
841
+ let firstPolyfillLoad = true;
842
+ let legacyAcceptingImportMaps = true;
843
+
844
+ async function topLevelLoad(
845
+ url,
846
+ parentUrl,
847
+ fetchOpts,
848
+ source,
849
+ nativelyLoaded,
850
+ lastStaticLoadPromise,
851
+ sourceType
852
+ ) {
853
+ await initPromise;
854
+ await importMapPromise;
855
+ url = (await resolve(url, parentUrl)).r;
856
+
857
+ // we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
858
+ // because we can't syntactically pass through to dynamic import with a second argument
859
+ if (sourceType === 'css' || sourceType === 'json') {
860
+ // Direct reexport for hot reloading skipped due to Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=1965620
861
+ source = `import m from'${url}'with{type:"${sourceType}"};export default m;`;
862
+ url += '?entry';
863
+ }
864
+
865
+ if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
866
+ // early analysis opt-out - no need to even fetch if we have feature support
867
+ if (!shimMode && baselineSupport && nativePassthrough && sourceType !== 'ts') {
868
+ // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
869
+ if (nativelyLoaded) return null;
870
+ await lastStaticLoadPromise;
871
+ return dynamicImport(source ? createBlob(source) : url);
872
+ }
873
+ const load = getOrCreateLoad(url, fetchOpts, undefined, source);
874
+ linkLoad(load, fetchOpts);
875
+ const seen = {};
876
+ await loadAll(load, seen);
877
+ resolveDeps(load, seen);
878
+ await lastStaticLoadPromise;
879
+ if (!shimMode && !load.n) {
880
+ if (nativelyLoaded) {
881
+ return;
882
+ }
883
+ if (source) {
884
+ return await dynamicImport(createBlob(source));
885
+ }
886
+ }
887
+ if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
888
+ onpolyfill();
889
+ firstPolyfillLoad = false;
890
+ }
891
+ const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
892
+ dynamicImport(load.b, load.u)
893
+ : import(load.u));
894
+ // if the top-level load is a shell, run its update function
895
+ if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
896
+ revokeObjectURLs(Object.keys(seen));
897
+ return module;
898
+ }
899
+
900
+ const revokeObjectURLs = registryKeys => {
901
+ let curIdx = 0;
902
+ const handler = self_.requestIdleCallback || self_.requestAnimationFrame || (fn => setTimeout(fn, 0));
903
+ handler(cleanup);
904
+ function cleanup() {
905
+ for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
906
+ const load = registry[key];
907
+ if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
908
+ }
909
+ if (curIdx < registryKeys.length) handler(cleanup);
910
+ }
911
+ };
912
+
913
+ const urlJsString = url => `'${url.replace(/'/g, "\\'")}'`;
914
+
915
+ let resolvedSource, lastIndex;
916
+ const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
917
+ while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
918
+ const dynamicImportEnd = dynamicImportEndStack.pop();
919
+ resolvedSource += `${load.S.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
920
+ lastIndex = dynamicImportEnd;
921
+ }
922
+ resolvedSource += load.S.slice(lastIndex, originalIndex);
923
+ lastIndex = originalIndex;
924
+ };
925
+
926
+ const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
927
+ const urlStart = commentStart + commentPrefix.length;
928
+ const commentEnd = load.S.indexOf('\n', urlStart);
929
+ const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
930
+ let sourceUrl = load.S.slice(urlStart, urlEnd);
931
+ try {
932
+ sourceUrl = new URL(sourceUrl, load.r).href;
933
+ } catch (e) {}
934
+ pushStringTo(load, urlStart, dynamicImportEndStack);
935
+ resolvedSource += sourceUrl;
936
+ lastIndex = urlEnd;
937
+ };
938
+
939
+ const resolveDeps = (load, seen) => {
940
+ if (load.b || !seen[load.u]) return;
941
+ seen[load.u] = 0;
942
+
943
+ for (const { l: dep, s: sourcePhase } of load.d) {
944
+ if (!sourcePhase) resolveDeps(dep, seen);
945
+ }
946
+
947
+ if (!load.n) load.n = load.d.some(dep => dep.l.n);
948
+ if (!load.N) load.N = load.d.some(dep => dep.l.N);
949
+
950
+ // use native loader whenever possible (n = needs shim) via executable subgraph passthrough
951
+ // so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
952
+ if (nativePassthrough && !shimMode && !load.n && !load.N) {
953
+ load.b = load.u;
954
+ load.S = undefined;
955
+ return;
956
+ }
957
+
958
+ const [imports, exports] = load.a;
959
+
960
+ // "execution"
961
+ let source = load.S,
962
+ depIndex = 0,
963
+ dynamicImportEndStack = [];
964
+
965
+ // once all deps have loaded we can inline the dependency resolution blobs
966
+ // and define this blob
967
+ resolvedSource = '';
968
+ lastIndex = 0;
969
+
970
+ for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a, at } of imports) {
971
+ // source phase
972
+ if (t === 4) {
973
+ let { l: depLoad } = load.d[depIndex++];
974
+ pushStringTo(load, statementStart, dynamicImportEndStack);
975
+ resolvedSource += `${source.slice(statementStart, start - 1).replace('source', '')}/*${source.slice(start - 1, end + 1)}*/'${createBlob(`export default importShim._s[${urlJsString(depLoad.r)}]`)}'`;
976
+ lastIndex = end + 1;
977
+ }
978
+ // dependency source replacements
979
+ else if (dynamicImportIndex === -1) {
980
+ let keepAssertion = false;
981
+ if (a > 0 && !shimMode) {
982
+ // strip assertions only when unsupported in polyfill mode
983
+ keepAssertion =
984
+ nativePassthrough &&
985
+ ((supportsJsonType && at.some(([s, t]) => s === 'type' && t === 'json')) ||
986
+ (supportsCssType && at.some(([s, t]) => s === 'type' && t === 'css')));
987
+ }
988
+
989
+ // defer phase stripping
990
+ if (t === 6) {
991
+ pushStringTo(load, statementStart, dynamicImportEndStack);
992
+ resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
993
+ lastIndex = start;
994
+ }
995
+ let { l: depLoad } = load.d[depIndex++],
996
+ blobUrl = depLoad.b,
997
+ cycleShell = !blobUrl;
998
+ if (cycleShell) {
999
+ // circular shell creation
1000
+ if (!(blobUrl = depLoad.s)) {
1001
+ blobUrl = depLoad.s = createBlob(
1002
+ `export function u$_(m){${depLoad.a[1]
1003
+ .map(({ s, e }, i) => {
1004
+ const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
1005
+ return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
1006
+ })
1007
+ .join(',')}}${
1008
+ depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
1009
+ }export {${depLoad.a[1]
1010
+ .map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`)
1011
+ .join(',')}}\n//# sourceURL=${depLoad.r}?cycle`
1012
+ );
1013
+ }
1014
+ }
1015
+
1016
+ pushStringTo(load, start - 1, dynamicImportEndStack);
1017
+ resolvedSource += `/*${source.slice(start - 1, end + 1)}*/'${blobUrl}'`;
1018
+
1019
+ // circular shell execution
1020
+ if (!cycleShell && depLoad.s) {
1021
+ resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
1022
+ depLoad.s = undefined;
1023
+ }
1024
+ lastIndex = keepAssertion ? end + 1 : statementEnd;
1025
+ }
1026
+ // import.meta
1027
+ else if (dynamicImportIndex === -2) {
1028
+ load.m = { url: load.r, resolve: metaResolve };
1029
+ if (metaHook) metaHook(load.m, load.u);
1030
+ pushStringTo(load, start, dynamicImportEndStack);
1031
+ resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
1032
+ lastIndex = statementEnd;
1033
+ }
1034
+ // dynamic import
1035
+ else {
1036
+ pushStringTo(load, statementStart + 6, dynamicImportEndStack);
1037
+ resolvedSource += `Shim${t === 5 ? '.source' : ''}(`;
1038
+ dynamicImportEndStack.push(statementEnd - 1);
1039
+ lastIndex = start;
1040
+ }
1041
+ }
1042
+
1043
+ // support progressive cycle binding updates (try statement avoids tdz errors)
1044
+ if (load.s && (imports.length === 0 || imports[imports.length - 1].d === -1))
1045
+ resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports
1046
+ .filter(e => e.ln)
1047
+ .map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
1048
+ .join(',')}})}catch(_){};\n`;
1049
+
1050
+ let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
1051
+ let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
1052
+
1053
+ // ignore sourceMap comments before already spliced code
1054
+ if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
1055
+ if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
1056
+
1057
+ // sourceURL first / only
1058
+ if (
1059
+ sourceURLCommentStart !== -1 &&
1060
+ (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
1061
+ ) {
1062
+ pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
1063
+ }
1064
+ // sourceMappingURL
1065
+ if (sourceMapURLCommentStart !== -1) {
1066
+ pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
1067
+ // sourceURL last
1068
+ if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
1069
+ pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
1070
+ }
1071
+
1072
+ pushStringTo(load, source.length, dynamicImportEndStack);
1073
+
1074
+ if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
1075
+
1076
+ load.b = createBlob(resolvedSource);
1077
+ load.S = resolvedSource = undefined;
1078
+ };
1079
+
1080
+ const sourceURLCommentPrefix = '\n//# sourceURL=';
1081
+ const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
1082
+ const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
1083
+
1084
+ // restrict in-flight fetches to a pool of 100
1085
+ let p = [];
1086
+ let c = 0;
1087
+ const pushFetchPool = () => {
1088
+ if (++c > 100) return new Promise(r => p.push(r));
1089
+ };
1090
+ const popFetchPool = () => {
1091
+ c--;
1092
+ if (p.length) p.shift()();
1093
+ };
1094
+
1095
+ const doFetch = async (url, fetchOpts, parent) => {
1096
+ if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
1097
+ let res,
1098
+ poolQueue = pushFetchPool();
1099
+ if (poolQueue) await poolQueue;
1100
+ try {
1101
+ res = await fetchHook(url, fetchOpts);
1102
+ } catch (e) {
1103
+ e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
1104
+ throw e;
1105
+ } finally {
1106
+ popFetchPool();
1107
+ }
1108
+
1109
+ if (!res.ok) {
1110
+ const error = new TypeError(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
1111
+ error.response = res;
1112
+ throw error;
1113
+ }
1114
+ return res;
1115
+ };
1116
+
1117
+ let esmsTsTransform;
1118
+ const initTs = async () => {
1119
+ const m = await import(tsTransform);
1120
+ if (!esmsTsTransform) esmsTsTransform = m.transform;
1121
+ };
1122
+
1123
+ async function defaultSourceHook(url, fetchOpts, parent) {
1124
+ let res = await doFetch(url, fetchOpts, parent),
1125
+ contentType,
1126
+ [, json, type, jsts] =
1127
+ (contentType = res.headers.get('content-type') || '').match(
1128
+ /^(?:[^/;]+\/(?:[^/+;]+\+)?(json)|(?:text|application)\/(?:x-)?((java|type)script|wasm|css))(?:;|$)/
1129
+ ) || [];
1130
+ if (!(type = json || (jsts ? jsts[0] + 's' : type || (/\.m?ts(\?|#|$)/.test(url) && 'ts')))) {
1131
+ throw Error(
1132
+ `Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
1133
+ );
1134
+ }
1135
+ return {
1136
+ url: res.url,
1137
+ source: await (type > 'v' ? WebAssembly.compileStreaming(res) : res.text()),
1138
+ type
1139
+ };
1140
+ }
1141
+
1142
+ const hotPrefix = 'var h=import.meta.hot,';
1143
+ const fetchModule = async (reqUrl, fetchOpts, parent) => {
1144
+ const mapIntegrity = composedImportMap.integrity[reqUrl];
1145
+ fetchOpts = mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts;
1146
+ let {
1147
+ url = reqUrl,
1148
+ source,
1149
+ type
1150
+ } = (await (sourceHook || defaultSourceHook)(reqUrl, fetchOpts, parent, defaultSourceHook)) || {};
1151
+ if (type === 'wasm') {
1152
+ const exports = WebAssembly.Module.exports((sourceCache[url] = source));
1153
+ const imports = WebAssembly.Module.imports(source);
1154
+ const rStr = urlJsString(url);
1155
+ source = `import*as $_ns from${rStr};`;
1156
+ let i = 0,
1157
+ obj = '';
1158
+ for (const { module, kind } of imports) {
1159
+ const specifier = urlJsString(module);
1160
+ source += `import*as impt${i} from${specifier};\n`;
1161
+ obj += `${specifier}:${kind === 'global' ? `importShim._i.get(impt${i})||impt${i++}` : `impt${i++}`},`;
1162
+ }
1163
+ source += `${hotPrefix}i=await WebAssembly.instantiate(importShim._s[${rStr}],{${obj}});importShim._i.set($_ns,i);`;
1164
+ obj = '';
1165
+ for (const { name, kind } of exports) {
1166
+ source += `export let ${name}=i.exports['${name}'];`;
1167
+ if (kind === 'global') source += `try{${name}=${name}.value}catch(_){${name}=undefined}`;
1168
+ obj += `${name},`;
1169
+ }
1170
+ source += `if(h)h.accept(m=>({${obj}}=m))`;
1171
+ } else if (type === 'json') {
1172
+ source = `${hotPrefix}j=JSON.parse(${JSON.stringify(source)});export{j as default};if(h)h.accept(m=>j=m.default)`;
1173
+ } else if (type === 'css') {
1174
+ source = `${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify(
1175
+ source.replace(
1176
+ cssUrlRegEx,
1177
+ (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
1178
+ )
1179
+ )});if(h){h.data.s=s;h.accept(()=>{})}export default s`;
1180
+ } else if (type === 'ts') {
1181
+ if (!esmsTsTransform) await initTs();
1182
+ const transformed = esmsTsTransform(source, url);
1183
+ // even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
1184
+ // a valid JS MIME here, so we must still polyfill it
1185
+ source = transformed === undefined ? source : transformed;
1186
+ }
1187
+ return { url, source, type };
1188
+ };
1189
+
1190
+ const getOrCreateLoad = (url, fetchOpts, parent, source) => {
1191
+ if (source && registry[url]) {
1192
+ let i = 0;
1193
+ while (registry[url + '#' + ++i]);
1194
+ url += '#' + i;
1195
+ }
1196
+ let load = registry[url];
1197
+ if (load) return load;
1198
+ registry[url] = load = {
1199
+ // url
1200
+ u: url,
1201
+ // response url
1202
+ r: source ? url : undefined,
1203
+ // fetchPromise
1204
+ f: undefined,
1205
+ // source
1206
+ S: source,
1207
+ // linkPromise
1208
+ L: undefined,
1209
+ // analysis
1210
+ a: undefined,
1211
+ // deps
1212
+ d: undefined,
1213
+ // blobUrl
1214
+ b: undefined,
1215
+ // shellUrl
1216
+ s: undefined,
1217
+ // needsShim: does it fail execution in the current native loader?
1218
+ n: false,
1219
+ // shouldShim: does it need to be loaded by the polyfill loader?
1220
+ N: false,
1221
+ // type
1222
+ t: null,
1223
+ // meta
1224
+ m: null
1225
+ };
1226
+ load.f = (async () => {
1227
+ if (load.S === undefined) {
1228
+ // preload fetch options override fetch options (race)
1229
+ ({ url: load.r, source: load.S, type: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
1230
+ if (
1231
+ !load.n &&
1232
+ load.t !== 'js' &&
1233
+ !shimMode &&
1234
+ ((load.t === 'css' && !supportsCssType) ||
1235
+ (load.t === 'json' && !supportsJsonType) ||
1236
+ (load.t === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
1237
+ load.t === 'ts')
1238
+ ) {
1239
+ load.n = true;
1240
+ }
1241
+ }
1242
+ try {
1243
+ load.a = parse(load.S, load.u);
1244
+ } catch (e) {
1245
+ throwError(e);
1246
+ load.a = [[], [], false];
1247
+ }
1248
+ return load;
1249
+ })();
1250
+ return load;
1251
+ };
1252
+
1253
+ const featErr = feat =>
1254
+ Error(
1255
+ `${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`
1256
+ );
1257
+
1258
+ const linkLoad = (load, fetchOpts) => {
1259
+ if (load.L) return;
1260
+ load.L = load.f.then(() => {
1261
+ let childFetchOpts = fetchOpts;
1262
+ load.d = load.a[0]
1263
+ .map(({ n, d, t, a, se }) => {
1264
+ const phaseImport = t >= 4;
1265
+ const sourcePhase = phaseImport && t < 6;
1266
+ if (phaseImport) {
1267
+ if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
1268
+ throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
1269
+ if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
1270
+ }
1271
+ let source = undefined;
1272
+ if (a > 0 && !shimMode && nativePassthrough) {
1273
+ const assertion = load.S.slice(a, se - 1);
1274
+ // no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
1275
+ if (assertion.includes('json')) {
1276
+ if (supportsJsonType) source = '';
1277
+ else load.n = true;
1278
+ } else if (assertion.includes('css')) {
1279
+ if (supportsCssType) source = '';
1280
+ else load.n = true;
1281
+ }
1282
+ }
1283
+ if (d !== -1 || !n) return;
1284
+ const resolved = resolve(n, load.r || load.u);
1285
+ if (resolved.n || hasCustomizationHooks) load.n = true;
1286
+ if (d >= 0 || resolved.N) load.N = true;
1287
+ if (d !== -1) return;
1288
+ if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
1289
+ if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
1290
+ const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
1291
+ // assertion case -> inline the CSS / JSON URL directly
1292
+ if (source === '') child.l.b = child.l.u;
1293
+ if (!child.s) linkLoad(child.l, fetchOpts);
1294
+ // load, sourcePhase
1295
+ return child;
1296
+ })
1297
+ .filter(l => l);
1298
+ });
1299
+ };
1300
+
1301
+ const processScriptsAndPreloads = () => {
1302
+ for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
1303
+ if (!link.ep) processPreload(link);
1304
+ }
1305
+ for (const script of document.querySelectorAll('script[type]')) {
1306
+ if (script.type === 'importmap' + (shimMode ? '-shim' : '')) {
1307
+ if (!script.ep) processImportMap(script);
1308
+ } else if (script.type === 'module' + (shimMode ? '-shim' : '')) {
1309
+ legacyAcceptingImportMaps = false;
1310
+ if (!script.ep) processScript(script);
1311
+ }
1312
+ }
1313
+ };
1314
+
1315
+ const getFetchOpts = script => {
1316
+ const fetchOpts = {};
1317
+ if (script.integrity) fetchOpts.integrity = script.integrity;
1318
+ if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
1319
+ if (script.fetchPriority) fetchOpts.priority = script.fetchPriority;
1320
+ if (script.crossOrigin === 'use-credentials') fetchOpts.credentials = 'include';
1321
+ else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
1322
+ else fetchOpts.credentials = 'same-origin';
1323
+ return fetchOpts;
1324
+ };
1325
+
1326
+ let lastStaticLoadPromise = Promise.resolve();
1327
+
1328
+ let domContentLoaded = false;
1329
+ let domContentLoadedCnt = 1;
1330
+ const domContentLoadedCheck = m => {
1331
+ if (m === undefined) {
1332
+ if (domContentLoaded) return;
1333
+ domContentLoaded = true;
1334
+ domContentLoadedCnt--;
1335
+ }
1336
+ if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1337
+ document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
1338
+ document.dispatchEvent(new Event('DOMContentLoaded'));
1339
+ }
1340
+ };
1341
+ let loadCnt = 1;
1342
+ const loadCheck = () => {
1343
+ if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1344
+ window.removeEventListener('load', loadEvent);
1345
+ window.dispatchEvent(new Event('load'));
1346
+ }
1347
+ };
1348
+
1349
+ const domContentLoadedEvent = async () => {
1350
+ await initPromise;
1351
+ domContentLoadedCheck();
1352
+ };
1353
+ const loadEvent = async () => {
1354
+ await initPromise;
1355
+ domContentLoadedCheck();
1356
+ loadCheck();
1357
+ };
1358
+
1359
+ // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
1360
+ if (hasDocument) {
1361
+ document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
1362
+ window.addEventListener('load', loadEvent);
1363
+ }
1364
+
1365
+ const readyListener = async () => {
1366
+ await initPromise;
1367
+ processScriptsAndPreloads();
1368
+ if (document.readyState === 'complete') {
1369
+ readyStateCompleteCheck();
1370
+ }
1371
+ };
1372
+
1373
+ let readyStateCompleteCnt = 1;
1374
+ const readyStateCompleteCheck = () => {
1375
+ if (--readyStateCompleteCnt === 0) {
1376
+ domContentLoadedCheck();
1377
+ if (!noLoadEventRetriggers && (shimMode || !baselineSupport)) {
1378
+ document.removeEventListener('readystatechange', readyListener);
1379
+ document.dispatchEvent(new Event('readystatechange'));
1380
+ }
1381
+ }
1382
+ };
1383
+
1384
+ const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
1385
+ const epCheck = (script, ready) =>
1386
+ script.ep ||
1387
+ (!ready && ((!script.src && !script.innerHTML) || !hasNext(script))) ||
1388
+ script.getAttribute('noshim') !== null ||
1389
+ !(script.ep = true);
1390
+
1391
+ const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
1392
+ if (epCheck(script, ready)) return;
1393
+ // we dont currently support external import maps in polyfill mode to match native
1394
+ if (script.src) {
1395
+ if (!shimMode) return;
1396
+ importMapSrc = true;
1397
+ }
1398
+ importMapPromise = importMapPromise
1399
+ .then(async () => {
1400
+ composedImportMap = resolveAndComposeImportMap(
1401
+ script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML),
1402
+ script.src || baseUrl,
1403
+ composedImportMap
1404
+ );
1405
+ })
1406
+ .catch(e => {
1407
+ if (e instanceof SyntaxError)
1408
+ e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
1409
+ throwError(e);
1410
+ });
1411
+ if (!firstImportMap && legacyAcceptingImportMaps) importMapPromise.then(() => (firstImportMap = composedImportMap));
1412
+ if (!legacyAcceptingImportMaps && !multipleImportMaps) {
1413
+ multipleImportMaps = true;
1414
+ if (!shimMode && baselineSupport && !supportsMultipleImportMaps) {
1415
+ baselineSupport = false;
1416
+ if (hasDocument) attachMutationObserver();
1417
+ }
1418
+ }
1419
+ legacyAcceptingImportMaps = false;
1420
+ };
1421
+
1422
+ const processScript = (script, ready = readyStateCompleteCnt > 0) => {
1423
+ if (epCheck(script, ready)) return;
1424
+ // does this load block readystate complete
1425
+ const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
1426
+ // does this load block DOMContentLoaded
1427
+ const isDomContentLoadedScript = domContentLoadedCnt > 0;
1428
+ const isLoadScript = loadCnt > 0;
1429
+ if (isLoadScript) loadCnt++;
1430
+ if (isBlockingReadyScript) readyStateCompleteCnt++;
1431
+ if (isDomContentLoadedScript) domContentLoadedCnt++;
1432
+ let loadPromise;
1433
+ const ts = script.lang === 'ts';
1434
+ if (ts && !script.src) {
1435
+ loadPromise = Promise.resolve(esmsTsTransform || initTs())
1436
+ .then(() => {
1437
+ const transformed = esmsTsTransform(script.innerHTML, baseUrl);
1438
+ if (transformed !== undefined) {
1439
+ onpolyfill();
1440
+ firstPolyfillLoad = false;
1441
+ }
1442
+ return topLevelLoad(
1443
+ script.src || baseUrl,
1444
+ baseUrl,
1445
+ getFetchOpts(script),
1446
+ transformed === undefined ? script.innerHTML : transformed,
1447
+ !shimMode && transformed === undefined,
1448
+ isBlockingReadyScript && lastStaticLoadPromise,
1449
+ 'ts'
1450
+ );
1451
+ })
1452
+ .catch(throwError);
1453
+ } else {
1454
+ loadPromise = topLevelLoad(
1455
+ script.src || baseUrl,
1456
+ baseUrl,
1457
+ getFetchOpts(script),
1458
+ !script.src ? script.innerHTML : undefined,
1459
+ !shimMode,
1460
+ isBlockingReadyScript && lastStaticLoadPromise,
1461
+ ts ? 'ts' : undefined
1462
+ ).catch(throwError);
1463
+ }
1464
+ if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
1465
+ if (isBlockingReadyScript && !ts) {
1466
+ lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
1467
+ }
1468
+ if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
1469
+ if (isLoadScript) loadPromise.then(loadCheck);
1470
+ };
1471
+
1472
+ const fetchCache = {};
1473
+ const processPreload = link => {
1474
+ link.ep = true;
1475
+ initPromise.then(() => {
1476
+ if (baselineSupport && !shimMode) return;
1477
+ if (fetchCache[link.href]) return;
1478
+ fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
1479
+ });
1480
+ };
1481
+
1482
+ })();