es-module-shims 2.1.2 → 2.3.0

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.
@@ -1,115 +1,279 @@
1
- /* ES Module Shims Wasm 2.1.2 */
1
+ /** ES Module Shims Wasm 2.3.0 */
2
2
  (function () {
3
3
 
4
- const hasDocument = typeof document !== 'undefined';
5
-
6
- const noop = () => {};
7
-
8
- const dynamicImport = (u, errUrl) => import(u);
9
-
10
- const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
11
-
12
- const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
13
- Object.assign(esmsInitOptions, self.esmsInitOptions || {});
14
-
15
- // shim mode is determined on initialization, no late shim mode
16
- const shimMode =
17
- hasDocument ?
18
- esmsInitOptions.shimMode ||
19
- document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
20
- .length > 0
21
- : true;
22
-
23
- const importHook = globalHook(shimMode && esmsInitOptions.onimport);
24
- const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
25
- let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
26
- const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
27
- const tsTransform =
28
- esmsInitOptions.tsTransform ||
29
- (hasDocument &&
30
- document.currentScript &&
31
- document.currentScript.src.replace(/\.js$/, '-typescript.js')) ||
32
- './es-module-shims-typescript.js';
33
-
34
- const mapOverrides = esmsInitOptions.mapOverrides;
35
-
36
- let nonce = esmsInitOptions.nonce;
37
- if (!nonce && hasDocument) {
38
- const nonceElement = document.querySelector('script[nonce]');
39
- if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
40
- }
41
-
42
- const onerror = globalHook(esmsInitOptions.onerror || noop);
43
-
44
- const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
45
-
46
- function globalHook(name) {
47
- return typeof name === 'string' ? self[name] : name;
48
- }
49
-
50
- const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
51
- const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
52
- const enableLatest = esmsInitOptions.polyfillEnable === 'latest' || enable.includes('latest');
53
- const cssModulesEnabled = enable.includes('css-modules') || enableAll || enableLatest;
54
- const jsonModulesEnabled = enable.includes('json-modules') || enableAll || enableLatest;
55
- const wasmInstancePhaseEnabled =
56
- enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
57
- const wasmSourcePhaseEnabled =
58
- enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
59
- const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
60
- const typescriptEnabled = enable.includes('typescript') || enableAll;
61
-
62
- const onpolyfill =
63
- esmsInitOptions.onpolyfill ?
64
- globalHook(esmsInitOptions.onpolyfill)
65
- : () => {
66
- console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
67
- };
68
-
69
- const baseUrl =
70
- hasDocument ?
71
- document.baseURI
72
- : `${location.protocol}//${location.host}${
73
- location.pathname.includes('/') ?
74
- location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
75
- : location.pathname
76
- }`;
77
-
78
- const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
79
- let { skip } = esmsInitOptions;
80
- if (Array.isArray(skip)) {
81
- const l = skip.map(s => new URL(s, baseUrl).href);
82
- skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
83
- } else if (typeof skip === 'string') {
84
- const r = new RegExp(skip);
85
- skip = s => r.test(s);
86
- } else if (skip instanceof RegExp) {
87
- skip = s => skip.test(s);
88
- }
89
-
90
- const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
91
-
92
- const throwError = err => {
93
- (self.reportError || dispatchError)(err), void onerror(err);
94
- };
95
-
96
- function fromParent(parent) {
97
- return parent ? ` imported from ${parent}` : '';
4
+ let invalidate;
5
+ const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
6
+ const initHotReload = () => {
7
+ let _importHook = importHook,
8
+ _resolveHook = resolveHook,
9
+ _metaHook = metaHook;
10
+
11
+ let defaultResolve;
12
+ let hotResolveHook = (id, parent, _defaultResolve) => {
13
+ if (!defaultResolve) defaultResolve = _defaultResolve;
14
+ const originalParent = stripVersion(parent);
15
+ const url = stripVersion(defaultResolve(id, originalParent));
16
+ const parents = getHotState(url).p;
17
+ if (!parents.includes(originalParent)) parents.push(originalParent);
18
+ return toVersioned(url);
19
+ };
20
+ const hotImportHook = url => {
21
+ getHotState(url).e = true;
22
+ };
23
+ const hotMetaHook = (metaObj, url) => {
24
+ metaObj.hot = new Hot(url);
25
+ };
26
+
27
+ const Hot = class Hot {
28
+ constructor(url) {
29
+ this.data = getHotState((this.url = stripVersion(url))).d;
30
+ }
31
+ accept(deps, cb) {
32
+ if (typeof deps === 'function') {
33
+ cb = deps;
34
+ deps = null;
35
+ }
36
+ const hotState = getHotState(this.url);
37
+ if (!hotState.A) return;
38
+ (hotState.a = hotState.a || []).push([
39
+ typeof deps === 'string' ? defaultResolve(deps, this.url)
40
+ : deps ? deps.map(d => defaultResolve(d, this.url))
41
+ : null,
42
+ cb
43
+ ]);
44
+ }
45
+ dispose(cb) {
46
+ getHotState(this.url).u = cb;
47
+ }
48
+ invalidate() {
49
+ const hotState = getHotState(this.url);
50
+ hotState.a = null;
51
+ hotState.A = true;
52
+ const seen = [this.url];
53
+ for (const p of hotState.p) invalidate(p, this.url, seen);
54
+ }
55
+ };
56
+
57
+ const versionedRegEx = /\?v=\d+$/;
58
+ const stripVersion = url => {
59
+ const versionMatch = url.match(versionedRegEx);
60
+ return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
61
+ };
62
+
63
+ const toVersioned = url => {
64
+ const v = getHotState(url).v;
65
+ return url + (v ? '?v=' + v : '');
66
+ };
67
+
68
+ let hotRegistry = {},
69
+ curInvalidationRoots = new Set(),
70
+ curInvalidationInterval;
71
+ const getHotState = url =>
72
+ hotRegistry[url] ||
73
+ (hotRegistry[url] = {
74
+ // version
75
+ v: 0,
76
+ // accept list ([deps, cb] pairs)
77
+ a: null,
78
+ // accepting acceptors
79
+ A: true,
80
+ // unload callback
81
+ u: null,
82
+ // entry point
83
+ e: false,
84
+ // hot data
85
+ d: {},
86
+ // parents
87
+ p: []
88
+ });
89
+
90
+ invalidate = (url, fromUrl, seen = []) => {
91
+ if (!seen.includes(url)) {
92
+ seen.push(url);
93
+ const hotState = hotRegistry[url];
94
+ if (hotState) {
95
+ hotState.A = false;
96
+ if (
97
+ hotState.a &&
98
+ hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
99
+ ) {
100
+ curInvalidationRoots.add(fromUrl);
101
+ } else {
102
+ if (hotState.e || hotState.a) curInvalidationRoots.add(url);
103
+ hotState.v++;
104
+ if (!hotState.a) for (const parent of hotState.p) invalidate(parent, url, seen);
105
+ }
106
+ }
107
+ }
108
+ if (!curInvalidationInterval)
109
+ curInvalidationInterval = setTimeout(() => {
110
+ curInvalidationInterval = null;
111
+ const earlyRoots = new Set();
112
+ for (const root of curInvalidationRoots) {
113
+ const hotState = hotRegistry[root];
114
+ importShim(toVersioned(root)).then(m => {
115
+ if (hotState.a) {
116
+ hotState.a.every(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
117
+ // unload should be the latest unload handler from the just loaded module
118
+ if (hotState.u) {
119
+ hotState.u(hotState.d);
120
+ hotState.u = null;
121
+ }
122
+ }
123
+ for (const parent of hotState.p) {
124
+ const hotState = hotRegistry[parent];
125
+ if (hotState && hotState.a)
126
+ hotState.a.every(async ([d, c]) => {
127
+ return (
128
+ d &&
129
+ !earlyRoots.has(c) &&
130
+ (typeof d === 'string' ?
131
+ d === root && c(m)
132
+ : c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d)))))))
133
+ );
134
+ });
135
+ }
136
+ }, noop);
137
+ }
138
+ curInvalidationRoots = new Set();
139
+ }, hotReloadInterval);
140
+ };
141
+
142
+ return [
143
+ _importHook ?
144
+ (url, opts, parentUrl) => {
145
+ _importHook(url, opts, parentUrl);
146
+ hotImportHook(url);
147
+ }
148
+ : hotImportHook,
149
+ _resolveHook ?
150
+ (id, parent, defaultResolve) =>
151
+ hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
152
+ : hotResolveHook,
153
+ _metaHook ?
154
+ (metaObj, url) => {
155
+ _metaHook(metaObj, url);
156
+ hotMetaHook(metaObj, url);
157
+ }
158
+ : hotMetaHook
159
+ ];
160
+ };
161
+
162
+ if (self.importShim) {
163
+ return;
164
+ }
165
+
166
+ const hasDocument = typeof document !== 'undefined';
167
+
168
+ const noop = () => {};
169
+
170
+ const dynamicImport = (u, errUrl) => import(u);
171
+
172
+ const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
173
+
174
+ const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
175
+ Object.assign(esmsInitOptions, self.esmsInitOptions || {});
176
+
177
+ // shim mode is determined on initialization, no late shim mode
178
+ const shimMode =
179
+ esmsInitOptions.shimMode ||
180
+ (hasDocument &&
181
+ document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
182
+ .length > 0);
183
+
184
+ let importHook,
185
+ resolveHook,
186
+ fetchHook = fetch,
187
+ metaHook = noop,
188
+ tsTransform =
189
+ (hasDocument && document.currentScript && document.currentScript.src.replace(/(\.\w+)?\.js$/, '-typescript.js')) ||
190
+ './es-module-shims-typescript.js';
191
+
192
+ const {
193
+ revokeBlobURLs,
194
+ noLoadEventRetriggers,
195
+ enforceIntegrity,
196
+ hotReload,
197
+ hotReloadInterval = 100,
198
+ nativePassthrough = !hotReload
199
+ } = esmsInitOptions;
200
+
201
+ const globalHook = name => (typeof name === 'string' ? self[name] : name);
202
+
203
+ if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
204
+ if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
205
+ if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
206
+ if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
207
+ if (esmsInitOptions.tsTransform) tsTransform = globalHook(esmsInitOptions.tsTransform);
208
+
209
+ if (hotReload) [importHook, resolveHook, metaHook] = initHotReload();
210
+
211
+ const mapOverrides = esmsInitOptions.mapOverrides;
212
+
213
+ let nonce = esmsInitOptions.nonce;
214
+ if (!nonce && hasDocument) {
215
+ const nonceElement = document.querySelector('script[nonce]');
216
+ if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
98
217
  }
99
218
 
219
+ const onerror = globalHook(esmsInitOptions.onerror || noop);
220
+
221
+ const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
222
+ const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
223
+ const wasmInstancePhaseEnabled =
224
+ enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
225
+ const wasmSourcePhaseEnabled =
226
+ enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
227
+ const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
228
+
229
+ const onpolyfill =
230
+ esmsInitOptions.onpolyfill ?
231
+ globalHook(esmsInitOptions.onpolyfill)
232
+ : () => {
233
+ console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
234
+ };
235
+
236
+ const baseUrl =
237
+ hasDocument ?
238
+ document.baseURI
239
+ : `${location.protocol}//${location.host}${
240
+ location.pathname.includes('/') ?
241
+ location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
242
+ : location.pathname
243
+ }`;
244
+
245
+ const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
246
+ let { skip } = esmsInitOptions;
247
+ if (Array.isArray(skip)) {
248
+ const l = skip.map(s => new URL(s, baseUrl).href);
249
+ skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
250
+ } else if (typeof skip === 'string') {
251
+ const r = new RegExp(skip);
252
+ skip = s => r.test(s);
253
+ } else if (skip instanceof RegExp) {
254
+ skip = s => skip.test(s);
255
+ }
256
+
257
+ const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
258
+
259
+ const throwError = err => {
260
+ (self.reportError || dispatchError)(err), void onerror(err);
261
+ };
262
+
263
+ const fromParent = parent => (parent ? ` imported from ${parent}` : '');
264
+
100
265
  const backslashRegEx = /\\/g;
101
266
 
102
- function asURL(url) {
267
+ const asURL = url => {
103
268
  try {
104
269
  if (url.indexOf(':') !== -1) return new URL(url).href;
105
270
  } catch (_) {}
106
- }
271
+ };
107
272
 
108
- function resolveUrl(relUrl, parentUrl) {
109
- return resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
110
- }
273
+ const resolveUrl = (relUrl, parentUrl) =>
274
+ resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
111
275
 
112
- function resolveIfNotPlainOrUrl(relUrl, parentUrl) {
276
+ const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
113
277
  const hIdx = parentUrl.indexOf('#'),
114
278
  qIdx = parentUrl.indexOf('?');
115
279
  if (hIdx + qIdx > -2)
@@ -197,9 +361,9 @@
197
361
  if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
198
362
  return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
199
363
  }
200
- }
364
+ };
201
365
 
202
- function resolveAndComposeImportMap(json, baseUrl, parentMap) {
366
+ const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
203
367
  const outMap = {
204
368
  imports: Object.assign({}, parentMap.imports),
205
369
  scopes: Object.assign({}, parentMap.scopes),
@@ -222,27 +386,27 @@
222
386
  if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
223
387
 
224
388
  return outMap;
225
- }
389
+ };
226
390
 
227
- function getMatch(path, matchObj) {
391
+ const getMatch = (path, matchObj) => {
228
392
  if (matchObj[path]) return path;
229
393
  let sepIndex = path.length;
230
394
  do {
231
395
  const segment = path.slice(0, sepIndex + 1);
232
396
  if (segment in matchObj) return segment;
233
397
  } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
234
- }
398
+ };
235
399
 
236
- function applyPackages(id, packages) {
400
+ const applyPackages = (id, packages) => {
237
401
  const pkgName = getMatch(id, packages);
238
402
  if (pkgName) {
239
403
  const pkg = packages[pkgName];
240
404
  if (pkg === null) return;
241
405
  return pkg + id.slice(pkgName.length);
242
406
  }
243
- }
407
+ };
244
408
 
245
- function resolveImportMap(importMap, resolvedOrPlain, parentUrl) {
409
+ const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
246
410
  let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
247
411
  while (scopeUrl) {
248
412
  const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
@@ -250,9 +414,9 @@
250
414
  scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
251
415
  }
252
416
  return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
253
- }
417
+ };
254
418
 
255
- function resolveAndComposePackages(packages, outPackages, baseUrl, parentMap) {
419
+ const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
256
420
  for (let p in packages) {
257
421
  const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
258
422
  if (
@@ -274,9 +438,9 @@
274
438
  }
275
439
  console.warn(`es-module-shims: Mapping "${p}" -> "${packages[p]}" does not resolve`);
276
440
  }
277
- }
441
+ };
278
442
 
279
- function resolveAndComposeIntegrity(integrity, outIntegrity, baseUrl) {
443
+ const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
280
444
  for (let p in integrity) {
281
445
  const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
282
446
  if (
@@ -290,7 +454,7 @@
290
454
  }
291
455
  outIntegrity[resolvedLhs] = integrity[p];
292
456
  }
293
- }
457
+ };
294
458
 
295
459
  // support browsers without dynamic import support (eg Firefox 6x)
296
460
  let supportsJsonType = false;
@@ -308,16 +472,16 @@
308
472
  let featureDetectionPromise = (async function () {
309
473
  if (!hasDocument)
310
474
  return Promise.all([
311
- cssModulesEnabled &&
312
- import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
313
- () => (supportsCssType = true),
314
- noop
315
- ),
316
- jsonModulesEnabled &&
317
- import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
318
- () => (supportsJsonType = true),
319
- noop
475
+ import(createBlob(`import"${createBlob('{}', 'text/json')}"with{type:"json"}`)).then(
476
+ () => (
477
+ (supportsJsonType = true),
478
+ import(createBlob(`import"${createBlob('', 'text/css')}"with{type:"css"}`)).then(
479
+ () => (supportsCssType = true),
480
+ noop
481
+ )
320
482
  ),
483
+ noop
484
+ ),
321
485
  wasmInstancePhaseEnabled &&
322
486
  import(createBlob(`import"${createBlob(new Uint8Array(wasmBytes), 'application/wasm')}"`)).then(
323
487
  () => (supportsWasmInstancePhase = true),
@@ -341,8 +505,8 @@
341
505
  ,
342
506
  supportsImportMaps,
343
507
  supportsMultipleImportMaps,
344
- supportsCssType,
345
508
  supportsJsonType,
509
+ supportsCssType,
346
510
  supportsWasmSourcePhase,
347
511
  supportsWasmInstancePhase
348
512
  ] = data;
@@ -352,17 +516,15 @@
352
516
  }
353
517
  window.addEventListener('message', cb, false);
354
518
 
355
- // Feature checking with careful avoidance of unnecessary work - all gated on initial import map supports check. JSON gates on CSS feature check, Wasm instance phase gates on wasm source phase check.
519
+ // 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.
356
520
  const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));c=u=>import(u).then(()=>true,()=>false);i=innerText=>document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText}));i(\`{"imports":{"x":"\${b('')}"}}\`);i(\`{"imports":{"y":"\${b('')}"}}\`);cm=${
357
- supportsImportMaps && cssModulesEnabled ? `c(b(\`import"\${b('','text/css')}"with{type:"css"}\`))` : 'false'
521
+ supportsImportMaps ? `c(b(\`import"\${b('{}','text/json')}"with{type:"json"}\`))` : 'false'
358
522
  };sp=${
359
523
  supportsImportMaps && wasmSourcePhaseEnabled ?
360
524
  `c(b(\`import source x from "\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))`
361
525
  : 'false'
362
526
  };Promise.all([${supportsImportMaps ? 'true' : "c('x')"},${supportsImportMaps ? "c('y')" : false},cm,${
363
- supportsImportMaps && jsonModulesEnabled ?
364
- `${cssModulesEnabled ? 'cm.then(s=>s?' : ''}c(b(\`import"\${b('{}','text/json')\}"with{type:"json"}\`))${cssModulesEnabled ? ':false)' : ''}`
365
- : 'false'
527
+ supportsImportMaps ? `cm.then(s=>s?c(b(\`import"\${b('','text/css')\}"with{type:"css"}\`)):false)` : 'false'
366
528
  },sp,${
367
529
  supportsImportMaps && wasmInstancePhaseEnabled ?
368
530
  `${wasmSourcePhaseEnabled ? 'sp.then(s=>s?' : ''}c(b(\`import"\${b(new Uint8Array(${JSON.stringify(wasmBytes)}),'application/wasm')\}"\`))${wasmSourcePhaseEnabled ? ':false)' : ''}`
@@ -407,7 +569,7 @@
407
569
  /* es-module-lexer 1.7.0 */
408
570
  var ImportType;!function(A){A[A.Static=1]="Static",A[A.Dynamic=2]="Dynamic",A[A.ImportMeta=3]="ImportMeta",A[A.StaticSourcePhase=4]="StaticSourcePhase",A[A.DynamicSourcePhase=5]="DynamicSourcePhase",A[A.StaticDeferPhase=6]="StaticDeferPhase",A[A.DynamicDeferPhase=7]="DynamicDeferPhase";}(ImportType||(ImportType={}));const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,w=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;w>0&&C.memory.grow(Math.ceil(w/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const o=[],D=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.it(),g=C.ai(),I=C.id(),w=C.ss(),K=C.se();let D;C.ip()&&(D=k(E.slice(-1===I?A-1:A,-1===I?Q+1:Q))),o.push({n:D,t:B,s:A,e:Q,ss:w,se:K,d:I,a:g});}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),w=I[0],K=B<0?void 0:E.slice(B,g),o=K?K[0]:"";D.push({s:A,e:Q,ls:B,le:g,n:'"'===w||"'"===w?k(I):I,ln:'"'===o||"'"===o?k(K):K});}function k(A){try{return (0,eval)(A)}catch(A){}}return [o,D,!!C.f(),!!C.ms()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const E=()=>{return A="AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/A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GcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABB0AkLEAEAAAACAAAAAAQAAEA5AAA=","undefined"!=typeof Buffer?Buffer.from(A,"base64"):Uint8Array.from(atob(A),(A=>A.charCodeAt(0)));var A;};const init=WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({exports:A})=>{C=A;}));
409
571
 
410
- function _resolve(id, parentUrl = baseUrl) {
572
+ const _resolve = (id, parentUrl = baseUrl) => {
411
573
  const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl) || asURL(id);
412
574
  const firstResolved = firstImportMap && resolveImportMap(firstImportMap, urlResolved || id, parentUrl);
413
575
  const composedResolved =
@@ -430,93 +592,103 @@
430
592
  if (firstResolved && resolved !== firstResolved) N = true;
431
593
  }
432
594
  return { r: resolved, n, N };
433
- }
595
+ };
434
596
 
435
- const resolve =
436
- resolveHook ?
437
- (id, parentUrl = baseUrl) => {
438
- const result = resolveHook(id, parentUrl, defaultResolve);
439
- return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
440
- }
441
- : _resolve;
597
+ const resolve = (id, parentUrl) => {
598
+ if (!resolveHook) return _resolve(id, parentUrl);
599
+ const result = resolveHook(id, parentUrl, defaultResolve);
442
600
 
443
- async function importHandler(id, opts, parentUrl = baseUrl, sourcePhase) {
444
- await initPromise; // needed for shim check
445
- if (importHook) await importHook(id, opts, parentUrl);
446
- if (shimMode || !baselinePassthrough) {
447
- if (hasDocument) processScriptsAndPreloads();
448
- legacyAcceptingImportMaps = false;
449
- }
450
- await importMapPromise;
451
- return resolve(id, parentUrl).r;
452
- }
601
+ return result ? { r: result, n: true, N: true } : _resolve(id, parentUrl);
602
+ };
453
603
 
454
604
  // import()
455
- async function importShim(id, opts, parentUrl) {
605
+ async function importShim$1(id, opts, parentUrl) {
456
606
  if (typeof opts === 'string') {
457
607
  parentUrl = opts;
458
608
  opts = undefined;
459
609
  }
460
- // we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
461
- // because we can't syntactically pass through to dynamic import with a second argument
462
- let url = await importHandler(id, opts, parentUrl);
463
- let source = null;
464
- if (typeof opts === 'object' && typeof opts.with === 'object' && typeof opts.with.type === 'string') {
465
- source = `export{default}from'${url}'with{type:"${opts.with.type}"}`;
466
- url += '?entry';
610
+ await initPromise; // needed for shim check
611
+ if (shimMode || !baselinePassthrough) {
612
+ if (hasDocument) processScriptsAndPreloads();
613
+ legacyAcceptingImportMaps = false;
467
614
  }
468
- return topLevelLoad(url, { credentials: 'same-origin' }, source, undefined, undefined);
615
+ let sourceType = undefined;
616
+ if (typeof opts === 'object') {
617
+ if (opts.lang === 'ts') sourceType = 'ts';
618
+ if (typeof opts.with === 'object' && typeof opts.with.type === 'string') {
619
+ sourceType = opts.with.type;
620
+ }
621
+ }
622
+ return topLevelLoad(
623
+ id,
624
+ parentUrl || baseUrl,
625
+ { credentials: 'same-origin' },
626
+ undefined,
627
+ undefined,
628
+ undefined,
629
+ sourceType
630
+ );
469
631
  }
470
632
 
471
633
  // import.source()
472
634
  // (opts not currently supported as no use cases yet)
473
635
  if (shimMode || wasmSourcePhaseEnabled)
474
- importShim.source = async function (specifier, opts, parentUrl) {
636
+ importShim$1.source = async (id, opts, parentUrl) => {
475
637
  if (typeof opts === 'string') {
476
638
  parentUrl = opts;
477
639
  opts = undefined;
478
640
  }
479
- const url = await importHandler(specifier, opts, parentUrl);
480
- const load = getOrCreateLoad(url, { credentials: 'same-origin' }, null, null);
641
+ await initPromise; // needed for shim check
642
+ if (shimMode || !baselinePassthrough) {
643
+ if (hasDocument) processScriptsAndPreloads();
644
+ legacyAcceptingImportMaps = false;
645
+ }
646
+ await importMapPromise;
647
+ const url = resolve(id, parentUrl || baseUrl).r;
648
+ const load = getOrCreateLoad(url, { credentials: 'same-origin' }, undefined, undefined);
481
649
  if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
482
650
  onpolyfill();
483
651
  firstPolyfillLoad = false;
484
652
  }
485
653
  await load.f;
486
- return importShim._s[load.r];
654
+ return importShim$1._s[load.r];
487
655
  };
488
656
 
489
657
  // import.defer() is just a proxy for import(), since we can't actually defer
490
- if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
658
+ if (shimMode || deferPhaseEnabled) importShim$1.defer = importShim$1;
659
+
660
+ if (hotReload) importShim$1.hotReload = hotReload$1;
491
661
 
492
- self.importShim = importShim;
662
+ self.importShim = importShim$1;
493
663
 
494
- function defaultResolve(id, parentUrl) {
664
+ const defaultResolve = (id, parentUrl) => {
495
665
  return (
496
666
  resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
497
667
  throwUnresolved(id, parentUrl)
498
668
  );
499
- }
669
+ };
500
670
 
501
- function throwUnresolved(id, parentUrl) {
671
+ const throwUnresolved = (id, parentUrl) => {
502
672
  throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
503
- }
673
+ };
504
674
 
505
- function metaResolve(id, parentUrl = this.url) {
675
+ const metaResolve = function (id, parentUrl = this.url) {
506
676
  return resolve(id, `${parentUrl}`).r;
507
- }
677
+ };
508
678
 
509
- importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
510
- importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
511
- importShim.addImportMap = importMapIn => {
679
+ importShim$1.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
680
+ importShim$1.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
681
+ importShim$1.addImportMap = importMapIn => {
512
682
  if (!shimMode) throw new Error('Unsupported in polyfill mode.');
513
683
  composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
514
684
  };
515
685
 
516
- const registry = (importShim._r = {});
517
- const sourceCache = (importShim._s = {});
686
+ const registry = (importShim$1._r = {});
687
+ // Wasm caches
688
+ const sourceCache = (importShim$1._s = {});
689
+ (importShim$1._i = new WeakMap());
518
690
 
519
- async function loadAll(load, seen) {
691
+ const loadAll = async (load, seen) => {
520
692
  seen[load.u] = 1;
521
693
  await load.L;
522
694
  await Promise.all(
@@ -526,7 +698,7 @@
526
698
  return loadAll(dep, seen);
527
699
  })
528
700
  );
529
- }
701
+ };
530
702
 
531
703
  let importMapSrc = false;
532
704
  let multipleImportMaps = false;
@@ -539,43 +711,39 @@
539
711
  baselinePassthrough =
540
712
  esmsInitOptions.polyfillEnable !== true &&
541
713
  supportsImportMaps &&
542
- (!jsonModulesEnabled || supportsJsonType) &&
543
- (!cssModulesEnabled || supportsCssType) &&
714
+ supportsJsonType &&
715
+ supportsCssType &&
544
716
  (!wasmInstancePhaseEnabled || supportsWasmInstancePhase) &&
545
717
  (!wasmSourcePhaseEnabled || supportsWasmSourcePhase) &&
546
718
  !deferPhaseEnabled &&
547
719
  (!multipleImportMaps || supportsMultipleImportMaps) &&
548
- !importMapSrc &&
549
- !typescriptEnabled;
550
- if (
551
- !shimMode &&
552
- wasmSourcePhaseEnabled &&
553
- typeof WebAssembly !== 'undefined' &&
554
- !Object.getPrototypeOf(WebAssembly.Module).name
555
- ) {
556
- const s = Symbol();
557
- const brand = m =>
558
- Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
559
- class AbstractModuleSource {
560
- get [Symbol.toStringTag]() {
561
- if (this[s]) return this[s];
562
- throw new TypeError('Not an AbstractModuleSource');
720
+ !importMapSrc;
721
+ if (!shimMode && typeof WebAssembly !== 'undefined') {
722
+ if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
723
+ const s = Symbol();
724
+ const brand = m =>
725
+ Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
726
+ class AbstractModuleSource {
727
+ get [Symbol.toStringTag]() {
728
+ if (this[s]) return this[s];
729
+ throw new TypeError('Not an AbstractModuleSource');
730
+ }
563
731
  }
732
+ const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
733
+ WebAssembly.Module = Object.setPrototypeOf(
734
+ Object.assign(function Module(...args) {
735
+ return brand(new wasmModule(...args));
736
+ }, wasmModule),
737
+ AbstractModuleSource
738
+ );
739
+ WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
740
+ WebAssembly.compile = function compile(...args) {
741
+ return wasmCompile(...args).then(brand);
742
+ };
743
+ WebAssembly.compileStreaming = function compileStreaming(...args) {
744
+ return wasmCompileStreaming(...args).then(brand);
745
+ };
564
746
  }
565
- const { Module: wasmModule, compile: wasmCompile, compileStreaming: wasmCompileStreaming } = WebAssembly;
566
- WebAssembly.Module = Object.setPrototypeOf(
567
- Object.assign(function Module(...args) {
568
- return brand(new wasmModule(...args));
569
- }, wasmModule),
570
- AbstractModuleSource
571
- );
572
- WebAssembly.Module.prototype = Object.setPrototypeOf(wasmModule.prototype, AbstractModuleSource.prototype);
573
- WebAssembly.compile = function compile(...args) {
574
- return wasmCompile(...args).then(brand);
575
- };
576
- WebAssembly.compileStreaming = function compileStreaming(...args) {
577
- return wasmCompileStreaming(...args).then(brand);
578
- };
579
747
  }
580
748
  if (hasDocument) {
581
749
  if (!supportsImportMaps) {
@@ -587,14 +755,6 @@
587
755
  if (document.readyState === 'complete') {
588
756
  readyStateCompleteCheck();
589
757
  } else {
590
- async function readyListener() {
591
- await initPromise;
592
- processScriptsAndPreloads();
593
- if (document.readyState === 'complete') {
594
- readyStateCompleteCheck();
595
- document.removeEventListener('readystatechange', readyListener);
596
- }
597
- }
598
758
  document.addEventListener('readystatechange', readyListener);
599
759
  }
600
760
  }
@@ -603,7 +763,7 @@
603
763
  return init;
604
764
  });
605
765
 
606
- function attachMutationObserver() {
766
+ const attachMutationObserver = () => {
607
767
  const observer = new MutationObserver(mutations => {
608
768
  for (const mutation of mutations) {
609
769
  if (mutation.type !== 'childList') continue;
@@ -624,25 +784,33 @@
624
784
  observer.observe(document, { childList: true });
625
785
  observer.observe(document.head, { childList: true });
626
786
  processScriptsAndPreloads();
627
- }
787
+ };
628
788
 
629
789
  let importMapPromise = initPromise;
630
790
  let firstPolyfillLoad = true;
631
791
  let legacyAcceptingImportMaps = true;
632
792
 
633
- async function topLevelLoad(url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
634
- legacyAcceptingImportMaps = false;
793
+ const topLevelLoad = async (url, parentUrl, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise, sourceType) => {
635
794
  await initPromise;
636
795
  await importMapPromise;
637
- if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
796
+ url = (await resolve(url, parentUrl)).r;
797
+
798
+ // we mock import('./x.css', { with: { type: 'css' }}) support via an inline static reexport
799
+ // because we can't syntactically pass through to dynamic import with a second argument
800
+ if (sourceType === 'css' || sourceType === 'json') {
801
+ source = `export{default}from'${url}'with{type:"${sourceType}"}`;
802
+ url += '?entry';
803
+ }
804
+
805
+ if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl);
638
806
  // early analysis opt-out - no need to even fetch if we have feature support
639
- if (!shimMode && baselinePassthrough) {
807
+ if (!shimMode && baselinePassthrough && nativePassthrough && sourceType !== 'ts') {
640
808
  // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
641
809
  if (nativelyLoaded) return null;
642
810
  await lastStaticLoadPromise;
643
811
  return dynamicImport(source ? createBlob(source) : url);
644
812
  }
645
- const load = getOrCreateLoad(url, fetchOpts, null, source);
813
+ const load = getOrCreateLoad(url, fetchOpts, undefined, source);
646
814
  linkLoad(load, fetchOpts);
647
815
  const seen = {};
648
816
  await loadAll(load, seen);
@@ -660,37 +828,55 @@
660
828
  onpolyfill();
661
829
  firstPolyfillLoad = false;
662
830
  }
663
- const module = await (!shimMode && !load.n && !load.N ? import(load.u) : dynamicImport(load.b, load.u));
831
+ const module = await (shimMode || load.n || load.N || !nativePassthrough || (!nativelyLoaded && source) ?
832
+ dynamicImport(load.b, load.u)
833
+ : import(load.u));
664
834
  // if the top-level load is a shell, run its update function
665
835
  if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
666
836
  if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
667
- // when tla is supported, this should return the tla promise as an actual handle
668
- // so readystate can still correspond to the sync subgraph exec completions
669
837
  return module;
670
- }
838
+ };
671
839
 
672
- function revokeObjectURLs(registryKeys) {
673
- let batch = 0;
674
- const keysLength = registryKeys.length;
675
- const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
676
- schedule(cleanup);
840
+ const revokeObjectURLs = registryKeys => {
841
+ let curIdx = 0;
842
+ const handler = self.requestIdleCallback || self.requestAnimationFrame;
843
+ handler(cleanup);
677
844
  function cleanup() {
678
- const batchStartIndex = batch * 100;
679
- if (batchStartIndex > keysLength) return;
680
- for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
845
+ for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
681
846
  const load = registry[key];
682
- if (load && load.b) URL.revokeObjectURL(load.b);
847
+ if (load && load.b && load.b !== load.u) URL.revokeObjectURL(load.b);
683
848
  }
684
- batch++;
685
- schedule(cleanup);
849
+ if (curIdx < registryKeys.length) handler(cleanup);
686
850
  }
687
- }
851
+ };
688
852
 
689
- function urlJsString(url) {
690
- return `'${url.replace(/'/g, "\\'")}'`;
691
- }
853
+ const urlJsString = url => `'${url.replace(/'/g, "\\'")}'`;
854
+
855
+ let resolvedSource, lastIndex;
856
+ const pushStringTo = (load, originalIndex, dynamicImportEndStack) => {
857
+ while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
858
+ const dynamicImportEnd = dynamicImportEndStack.pop();
859
+ resolvedSource += `${load.S.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
860
+ lastIndex = dynamicImportEnd;
861
+ }
862
+ resolvedSource += load.S.slice(lastIndex, originalIndex);
863
+ lastIndex = originalIndex;
864
+ };
865
+
866
+ const pushSourceURL = (load, commentPrefix, commentStart, dynamicImportEndStack) => {
867
+ const urlStart = commentStart + commentPrefix.length;
868
+ const commentEnd = load.S.indexOf('\n', urlStart);
869
+ const urlEnd = commentEnd !== -1 ? commentEnd : load.S.length;
870
+ let sourceUrl = load.S.slice(urlStart, urlEnd);
871
+ try {
872
+ sourceUrl = new URL(sourceUrl, load.r).href;
873
+ } catch {}
874
+ pushStringTo(load, urlStart, dynamicImportEndStack);
875
+ resolvedSource += sourceUrl;
876
+ lastIndex = urlEnd;
877
+ };
692
878
 
693
- function resolveDeps(load, seen) {
879
+ const resolveDeps = (load, seen) => {
694
880
  if (load.b || !seen[load.u]) return;
695
881
  seen[load.u] = 0;
696
882
 
@@ -703,7 +889,7 @@
703
889
 
704
890
  // use native loader whenever possible (n = needs shim) via executable subgraph passthrough
705
891
  // so long as the module doesn't use dynamic import or unsupported URL mappings (N = should shim)
706
- if (!shimMode && !load.n && !load.N) {
892
+ if (nativePassthrough && !shimMode && !load.n && !load.N) {
707
893
  load.b = load.u;
708
894
  load.S = undefined;
709
895
  return;
@@ -712,38 +898,36 @@
712
898
  const [imports, exports] = load.a;
713
899
 
714
900
  // "execution"
715
- const source = load.S;
716
-
717
- let resolvedSource = '';
901
+ let source = load.S,
902
+ depIndex = 0,
903
+ dynamicImportEndStack = [];
718
904
 
719
905
  // once all deps have loaded we can inline the dependency resolution blobs
720
906
  // and define this blob
721
- let lastIndex = 0,
722
- depIndex = 0,
723
- dynamicImportEndStack = [];
724
- function pushStringTo(originalIndex) {
725
- while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
726
- const dynamicImportEnd = dynamicImportEndStack.pop();
727
- resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
728
- lastIndex = dynamicImportEnd;
729
- }
730
- resolvedSource += source.slice(lastIndex, originalIndex);
731
- lastIndex = originalIndex;
732
- }
907
+ (resolvedSource = ''), (lastIndex = 0);
733
908
 
734
909
  for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
735
910
  // source phase
736
911
  if (t === 4) {
737
912
  let { l: depLoad } = load.d[depIndex++];
738
- pushStringTo(statementStart);
913
+ pushStringTo(load, statementStart, dynamicImportEndStack);
739
914
  resolvedSource += `${source.slice(statementStart, start - 1).replace('source', '')}/*${source.slice(start - 1, end + 1)}*/'${createBlob(`export default importShim._s[${urlJsString(depLoad.r)}]`)}'`;
740
915
  lastIndex = end + 1;
741
916
  }
742
917
  // dependency source replacements
743
918
  else if (dynamicImportIndex === -1) {
919
+ let keepAssertion = false;
920
+ if (a > 0 && !shimMode) {
921
+ const assertion = source.slice(a, statementEnd - 1);
922
+ // strip assertions only when unsupported in polyfill mode
923
+ keepAssertion =
924
+ nativePassthrough &&
925
+ ((supportsJsonType && assertion.includes('json')) || (supportsCssType && assertion.includes('css')));
926
+ }
927
+
744
928
  // defer phase stripping
745
929
  if (t === 6) {
746
- pushStringTo(statementStart);
930
+ pushStringTo(load, statementStart, dynamicImportEndStack);
747
931
  resolvedSource += source.slice(statementStart, start - 1).replace('defer', '');
748
932
  lastIndex = start;
749
933
  }
@@ -768,10 +952,7 @@
768
952
  }
769
953
  }
770
954
 
771
- // strip import assertions unless we support them
772
- const stripAssertion = (!supportsCssType && !supportsJsonType) || !(a > 0);
773
-
774
- pushStringTo(start - 1);
955
+ pushStringTo(load, start - 1, dynamicImportEndStack);
775
956
  resolvedSource += `/*${source.slice(start - 1, end + 1)}*/'${blobUrl}'`;
776
957
 
777
958
  // circular shell execution
@@ -779,19 +960,19 @@
779
960
  resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
780
961
  depLoad.s = undefined;
781
962
  }
782
- lastIndex = stripAssertion ? statementEnd : end + 1;
963
+ lastIndex = keepAssertion ? end + 1 : statementEnd;
783
964
  }
784
965
  // import.meta
785
966
  else if (dynamicImportIndex === -2) {
786
967
  load.m = { url: load.r, resolve: metaResolve };
787
- metaHook(load.m, load.u);
788
- pushStringTo(start);
968
+ if (metaHook) metaHook(load.m, load.u);
969
+ pushStringTo(load, start, dynamicImportEndStack);
789
970
  resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
790
971
  lastIndex = statementEnd;
791
972
  }
792
973
  // dynamic import
793
974
  else {
794
- pushStringTo(statementStart + 6);
975
+ pushStringTo(load, statementStart + 6, dynamicImportEndStack);
795
976
  resolvedSource += `Shim${t === 5 ? '.source' : ''}(`;
796
977
  dynamicImportEndStack.push(statementEnd - 1);
797
978
  lastIndex = start;
@@ -805,19 +986,6 @@
805
986
  .map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`)
806
987
  .join(',')}})}catch(_){};\n`;
807
988
 
808
- function pushSourceURL(commentPrefix, commentStart) {
809
- const urlStart = commentStart + commentPrefix.length;
810
- const commentEnd = source.indexOf('\n', urlStart);
811
- const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
812
- let sourceUrl = source.slice(urlStart, urlEnd);
813
- try {
814
- sourceUrl = new URL(sourceUrl, load.r).href;
815
- } catch {}
816
- pushStringTo(urlStart);
817
- resolvedSource += sourceUrl;
818
- lastIndex = urlEnd;
819
- }
820
-
821
989
  let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
822
990
  let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
823
991
 
@@ -830,23 +998,23 @@
830
998
  sourceURLCommentStart !== -1 &&
831
999
  (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)
832
1000
  ) {
833
- pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
1001
+ pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
834
1002
  }
835
1003
  // sourceMappingURL
836
1004
  if (sourceMapURLCommentStart !== -1) {
837
- pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
1005
+ pushSourceURL(load, sourceMapURLCommentPrefix, sourceMapURLCommentStart, dynamicImportEndStack);
838
1006
  // sourceURL last
839
1007
  if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
840
- pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
1008
+ pushSourceURL(load, sourceURLCommentPrefix, sourceURLCommentStart, dynamicImportEndStack);
841
1009
  }
842
1010
 
843
- pushStringTo(source.length);
1011
+ pushStringTo(load, source.length, dynamicImportEndStack);
844
1012
 
845
1013
  if (sourceURLCommentStart === -1) resolvedSource += sourceURLCommentPrefix + load.r;
846
1014
 
847
1015
  load.b = createBlob(resolvedSource);
848
- load.S = undefined;
849
- }
1016
+ load.S = resolvedSource = undefined;
1017
+ };
850
1018
 
851
1019
  const sourceURLCommentPrefix = '\n//# sourceURL=';
852
1020
  const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
@@ -862,15 +1030,15 @@
862
1030
  // restrict in-flight fetches to a pool of 100
863
1031
  let p = [];
864
1032
  let c = 0;
865
- function pushFetchPool() {
1033
+ const pushFetchPool = () => {
866
1034
  if (++c > 100) return new Promise(r => p.push(r));
867
- }
868
- function popFetchPool() {
1035
+ };
1036
+ const popFetchPool = () => {
869
1037
  c--;
870
1038
  if (p.length) p.shift()();
871
- }
1039
+ };
872
1040
 
873
- async function doFetch(url, fetchOpts, parent) {
1041
+ const doFetch = async (url, fetchOpts, parent) => {
874
1042
  if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
875
1043
  const poolQueue = pushFetchPool();
876
1044
  if (poolQueue) await poolQueue;
@@ -889,15 +1057,16 @@
889
1057
  throw error;
890
1058
  }
891
1059
  return res;
892
- }
1060
+ };
893
1061
 
894
1062
  let esmsTsTransform;
895
- async function initTs() {
1063
+ const initTs = async () => {
896
1064
  const m = await import(tsTransform);
897
1065
  if (!esmsTsTransform) esmsTsTransform = m.transform;
898
- }
1066
+ };
899
1067
 
900
- async function fetchModule(url, fetchOpts, parent) {
1068
+ const hotPrefix = 'var h=import.meta.hot,';
1069
+ const fetchModule = async (url, fetchOpts, parent) => {
901
1070
  const mapIntegrity = composedImportMap.integrity[url];
902
1071
  const res = await doFetch(
903
1072
  url,
@@ -908,69 +1077,68 @@
908
1077
  const contentType = res.headers.get('content-type');
909
1078
  if (jsContentType.test(contentType)) return { r, s: await res.text(), t: 'js' };
910
1079
  else if (wasmContentType.test(contentType)) {
911
- const module = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
912
- sourceCache[r] = module;
913
- let s = '',
1080
+ const wasmModule = await (sourceCache[r] || (sourceCache[r] = WebAssembly.compileStreaming(res)));
1081
+ const exports = WebAssembly.Module.exports(wasmModule);
1082
+ sourceCache[r] = wasmModule;
1083
+ const rStr = urlJsString(r);
1084
+ let s = `import*as $_ns from${rStr};`,
914
1085
  i = 0,
915
- importObj = '';
916
- for (const impt of WebAssembly.Module.imports(module)) {
917
- const specifier = urlJsString(impt.module);
918
- s += `import * as impt${i} from ${specifier};\n`;
919
- importObj += `${specifier}:impt${i++},`;
1086
+ obj = '';
1087
+ for (const { module, kind } of WebAssembly.Module.imports(wasmModule)) {
1088
+ const specifier = urlJsString(module);
1089
+ s += `import*as impt${i} from${specifier};\n`;
1090
+ obj += `${specifier}:${kind === 'global' ? `importShim._i.get(impt${i})||impt${i++}` : `impt${i++}`},`;
920
1091
  }
921
- i = 0;
922
- s += `const instance = await WebAssembly.instantiate(importShim._s[${urlJsString(r)}], {${importObj}});\n`;
923
- for (const expt of WebAssembly.Module.exports(module)) {
924
- s += `export const ${expt.name} = instance.exports['${expt.name}'];\n`;
1092
+ s += `${hotPrefix}i=await WebAssembly.instantiate(importShim._s[${rStr}],{${obj}});importShim._i.set($_ns,i);`;
1093
+ obj = '';
1094
+ for (const { name, kind } of exports) {
1095
+ s += `export let ${name}=i.exports['${name}'];`;
1096
+ if (kind === 'global') s += `try{${name}=${name}.value}catch{${name}=undefined}`;
1097
+ obj += `${name},`;
925
1098
  }
1099
+ s += `if(h)h.accept(m=>({${obj}}=m))`;
926
1100
  return { r, s, t: 'wasm' };
927
- } else if (jsonContentType.test(contentType)) return { r, s: `export default ${await res.text()}`, t: 'json' };
1101
+ } else if (jsonContentType.test(contentType))
1102
+ return { r, s: `${hotPrefix}j=${await res.text()};export{j as default};if(h)h.accept(m=>j=m.default)`, t: 'json' };
928
1103
  else if (cssContentType.test(contentType)) {
929
1104
  return {
930
1105
  r,
931
- s: `var s=new CSSStyleSheet();s.replaceSync(${JSON.stringify(
1106
+ s: `${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify(
932
1107
  (await res.text()).replace(
933
1108
  cssUrlRegEx,
934
1109
  (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`
935
1110
  )
936
- )});export default s;`,
1111
+ )});if(h){h.data.s=s;h.accept(()=>{})}export default s`,
937
1112
  t: 'css'
938
1113
  };
939
- } else if (
940
- (shimMode || typescriptEnabled) &&
941
- (tsContentType.test(contentType) || url.endsWith('.ts') || url.endsWith('.mts'))
942
- ) {
1114
+ } else if (tsContentType.test(contentType) || url.endsWith('.ts') || url.endsWith('.mts')) {
943
1115
  const source = await res.text();
944
1116
  if (!esmsTsTransform) await initTs();
945
1117
  const transformed = esmsTsTransform(source, url);
946
- return { r, s: transformed === undefined ? source : transformed, t: transformed !== undefined ? 'ts' : 'js' };
1118
+ // even if the TypeScript is valid JavaScript, unless it was a top-level inline source, it wasn't served with
1119
+ // a valid JS MIME here, so we must still polyfill it
1120
+ return { r, s: transformed === undefined ? source : transformed, t: 'ts' };
947
1121
  } else
948
1122
  throw Error(
949
1123
  `Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
950
1124
  );
951
- }
1125
+ };
952
1126
 
953
- function isUnsupportedType(type) {
954
- if (
955
- (type === 'css' && !cssModulesEnabled) ||
956
- (type === 'json' && !jsonModulesEnabled) ||
957
- (type === 'wasm' && !wasmInstancePhaseEnabled && !wasmSourcePhaseEnabled) ||
958
- (type === 'ts' && !typescriptEnabled)
959
- )
960
- throw featErr(`${type}-modules`);
1127
+ const isUnsupportedType = type => {
1128
+ if (type === 'wasm' && !wasmInstancePhaseEnabled && !wasmSourcePhaseEnabled) throw featErr(`wasm-modules`);
961
1129
  return (
962
1130
  (type === 'css' && !supportsCssType) ||
963
1131
  (type === 'json' && !supportsJsonType) ||
964
1132
  (type === 'wasm' && !supportsWasmInstancePhase && !supportsWasmSourcePhase) ||
965
1133
  type === 'ts'
966
1134
  );
967
- }
1135
+ };
968
1136
 
969
- function getOrCreateLoad(url, fetchOpts, parent, source) {
1137
+ const getOrCreateLoad = (url, fetchOpts, parent, source) => {
970
1138
  if (source && registry[url]) {
971
1139
  let i = 0;
972
- while (registry[url + ++i]);
973
- url += i;
1140
+ while (registry[url + '?' + ++i]);
1141
+ url += '?' + i;
974
1142
  }
975
1143
  let load = registry[url];
976
1144
  if (load) return load;
@@ -993,9 +1161,9 @@
993
1161
  b: undefined,
994
1162
  // shellUrl
995
1163
  s: undefined,
996
- // needsShim
1164
+ // needsShim: does it fail execution in the current native loader?
997
1165
  n: false,
998
- // shouldShim
1166
+ // shouldShim: does it need to be loaded by the polyfill loader?
999
1167
  N: false,
1000
1168
  // type
1001
1169
  t: null,
@@ -1003,7 +1171,7 @@
1003
1171
  m: null
1004
1172
  };
1005
1173
  load.f = (async () => {
1006
- if (!load.S) {
1174
+ if (load.S === undefined) {
1007
1175
  // preload fetch options override fetch options (race)
1008
1176
  ({ r: load.r, s: load.S, t: load.t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
1009
1177
  if (!load.n && load.t !== 'js' && !shimMode && isUnsupportedType(load.t)) {
@@ -1019,29 +1187,37 @@
1019
1187
  return load;
1020
1188
  })();
1021
1189
  return load;
1022
- }
1190
+ };
1023
1191
 
1024
1192
  const featErr = feat =>
1025
1193
  Error(
1026
1194
  `${feat} feature must be enabled via <script type="esms-options">{ "polyfillEnable": ["${feat}"] }<${''}/script>`
1027
1195
  );
1028
1196
 
1029
- function linkLoad(load, fetchOpts) {
1197
+ const linkLoad = (load, fetchOpts) => {
1030
1198
  if (load.L) return;
1031
1199
  load.L = load.f.then(async () => {
1032
1200
  let childFetchOpts = fetchOpts;
1033
1201
  load.d = load.a[0]
1034
- .map(({ n, d, t, a }) => {
1202
+ .map(({ n, d, t, a, se }) => {
1035
1203
  const phaseImport = t >= 4;
1036
1204
  const sourcePhase = phaseImport && t < 6;
1037
1205
  if (phaseImport) {
1038
1206
  if (!shimMode && (sourcePhase ? !wasmSourcePhaseEnabled : !deferPhaseEnabled))
1039
- throw featErr(sourcePhase ? 'source-phase' : 'defer-phase');
1207
+ throw featErr(sourcePhase ? 'wasm-module-sources' : 'import-defer');
1040
1208
  if (!sourcePhase || !supportsWasmSourcePhase) load.n = true;
1041
1209
  }
1042
- if (a > 0) {
1043
- if (!shimMode && !cssModulesEnabled && !jsonModulesEnabled) throw featErr('css-modules / json-modules');
1044
- if (!supportsCssType && !supportsJsonType) load.n = true;
1210
+ let source = undefined;
1211
+ if (a > 0 && !shimMode && nativePassthrough) {
1212
+ const assertion = load.S.slice(a, se - 1);
1213
+ // no need to fetch JSON/CSS if supported, since it's a leaf node, we'll just strip the assertion syntax
1214
+ if (assertion.includes('json')) {
1215
+ if (supportsJsonType) source = '';
1216
+ else load.n = true;
1217
+ } else if (assertion.includes('css')) {
1218
+ if (supportsCssType) source = '';
1219
+ else load.n = true;
1220
+ }
1045
1221
  }
1046
1222
  if (d !== -1 || !n) return;
1047
1223
  const resolved = resolve(n, load.r || load.u);
@@ -1050,16 +1226,18 @@
1050
1226
  if (d !== -1) return;
1051
1227
  if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
1052
1228
  if (childFetchOpts.integrity) childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
1053
- const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, null), s: sourcePhase };
1229
+ const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
1230
+ // assertion case -> inline the CSS / JSON URL directly
1231
+ if (source === '') child.l.b = child.l.u;
1054
1232
  if (!child.s) linkLoad(child.l, fetchOpts);
1055
1233
  // load, sourcePhase
1056
1234
  return child;
1057
1235
  })
1058
1236
  .filter(l => l);
1059
1237
  });
1060
- }
1238
+ };
1061
1239
 
1062
- function processScriptsAndPreloads() {
1240
+ const processScriptsAndPreloads = () => {
1063
1241
  for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]')) {
1064
1242
  if (!link.ep) processPreload(link);
1065
1243
  }
@@ -1071,9 +1249,9 @@
1071
1249
  if (!script.ep) processScript(script);
1072
1250
  }
1073
1251
  }
1074
- }
1252
+ };
1075
1253
 
1076
- function getFetchOpts(script) {
1254
+ const getFetchOpts = script => {
1077
1255
  const fetchOpts = {};
1078
1256
  if (script.integrity) fetchOpts.integrity = script.integrity;
1079
1257
  if (script.referrerPolicy) fetchOpts.referrerPolicy = script.referrerPolicy;
@@ -1082,40 +1260,65 @@
1082
1260
  else if (script.crossOrigin === 'anonymous') fetchOpts.credentials = 'omit';
1083
1261
  else fetchOpts.credentials = 'same-origin';
1084
1262
  return fetchOpts;
1085
- }
1263
+ };
1086
1264
 
1087
1265
  let lastStaticLoadPromise = Promise.resolve();
1088
1266
 
1267
+ let domContentLoaded = false;
1089
1268
  let domContentLoadedCnt = 1;
1090
- function domContentLoadedCheck() {
1269
+ const domContentLoadedCheck = m => {
1270
+ if (m === undefined) {
1271
+ if (domContentLoaded) return;
1272
+ domContentLoaded = true;
1273
+ domContentLoadedCnt--;
1274
+ }
1091
1275
  if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
1276
+ document.removeEventListener('DOMContentLoaded', domContentLoadedEvent);
1092
1277
  document.dispatchEvent(new Event('DOMContentLoaded'));
1093
1278
  }
1094
- }
1279
+ };
1095
1280
  let loadCnt = 1;
1096
- function loadCheck() {
1281
+ const loadCheck = () => {
1097
1282
  if (--loadCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
1283
+ window.removeEventListener('load', loadEvent);
1098
1284
  window.dispatchEvent(new Event('load'));
1099
1285
  }
1100
- }
1286
+ };
1287
+
1288
+ const domContentLoadedEvent = async () => {
1289
+ await initPromise;
1290
+ domContentLoadedCheck();
1291
+ };
1292
+ const loadEvent = async () => {
1293
+ await initPromise;
1294
+ domContentLoadedCheck();
1295
+ loadCheck();
1296
+ };
1297
+
1101
1298
  // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
1102
1299
  if (hasDocument) {
1103
- document.addEventListener('DOMContentLoaded', async () => {
1104
- await initPromise;
1105
- domContentLoadedCheck();
1106
- });
1107
- window.addEventListener('load', async () => {
1108
- await initPromise;
1109
- loadCheck();
1110
- });
1300
+ document.addEventListener('DOMContentLoaded', domContentLoadedEvent);
1301
+ window.addEventListener('load', loadEvent);
1111
1302
  }
1112
1303
 
1304
+ const readyListener = async () => {
1305
+ await initPromise;
1306
+ processScriptsAndPreloads();
1307
+ if (document.readyState === 'complete') {
1308
+ readyStateCompleteCheck();
1309
+ }
1310
+ };
1311
+
1113
1312
  let readyStateCompleteCnt = 1;
1114
- function readyStateCompleteCheck() {
1115
- if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
1116
- document.dispatchEvent(new Event('readystatechange'));
1313
+ const readyStateCompleteCheck = () => {
1314
+ if (--readyStateCompleteCnt === 0) {
1315
+ domContentLoadedCheck();
1316
+ if (!noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
1317
+ document.removeEventListener('readystatechange', readyListener);
1318
+ document.dispatchEvent(new Event('readystatechange'));
1319
+ }
1117
1320
  }
1118
- }
1321
+ };
1119
1322
 
1120
1323
  const hasNext = script => script.nextSibling || (script.parentNode && hasNext(script.parentNode));
1121
1324
  const epCheck = (script, ready) =>
@@ -1124,7 +1327,7 @@
1124
1327
  script.getAttribute('noshim') !== null ||
1125
1328
  !(script.ep = true);
1126
1329
 
1127
- function processImportMap(script, ready = readyStateCompleteCnt > 0) {
1330
+ const processImportMap = (script, ready = readyStateCompleteCnt > 0) => {
1128
1331
  if (epCheck(script, ready)) return;
1129
1332
  // we dont currently support external import maps in polyfill mode to match native
1130
1333
  if (script.src) {
@@ -1153,55 +1356,63 @@
1153
1356
  }
1154
1357
  }
1155
1358
  legacyAcceptingImportMaps = false;
1156
- }
1359
+ };
1157
1360
 
1158
- function processScript(script, ready = readyStateCompleteCnt > 0) {
1361
+ const processScript = (script, ready = readyStateCompleteCnt > 0) => {
1159
1362
  if (epCheck(script, ready)) return;
1160
- if (script.lang === 'ts' && !script.src) {
1161
- const source = script.innerHTML;
1162
- return initTs()
1363
+ // does this load block readystate complete
1364
+ const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
1365
+ // does this load block DOMContentLoaded
1366
+ const isDomContentLoadedScript = domContentLoadedCnt > 0;
1367
+ const isLoadScript = loadCnt > 0;
1368
+ if (isLoadScript) loadCnt++;
1369
+ if (isBlockingReadyScript) readyStateCompleteCnt++;
1370
+ if (isDomContentLoadedScript) domContentLoadedCnt++;
1371
+ let loadPromise;
1372
+ const ts = script.lang === 'ts';
1373
+ if (ts && !script.src) {
1374
+ loadPromise = Promise.resolve(esmsTsTransform || initTs())
1163
1375
  .then(() => {
1164
- const transformed = esmsTsTransform(source, baseUrl);
1376
+ const transformed = esmsTsTransform(script.innerHTML, baseUrl);
1165
1377
  if (transformed !== undefined) {
1166
1378
  onpolyfill();
1167
1379
  firstPolyfillLoad = false;
1168
1380
  }
1169
1381
  return topLevelLoad(
1382
+ script.src || baseUrl,
1170
1383
  baseUrl,
1171
1384
  getFetchOpts(script),
1172
- transformed === undefined ? source : transformed,
1173
- transformed === undefined,
1174
- undefined
1385
+ transformed === undefined ? script.innerHTML : transformed,
1386
+ !shimMode && transformed === undefined,
1387
+ isBlockingReadyScript && lastStaticLoadPromise,
1388
+ 'ts'
1175
1389
  );
1176
1390
  })
1177
1391
  .catch(throwError);
1392
+ } else {
1393
+ loadPromise = topLevelLoad(
1394
+ script.src || baseUrl,
1395
+ baseUrl,
1396
+ getFetchOpts(script),
1397
+ !script.src ? script.innerHTML : undefined,
1398
+ !shimMode,
1399
+ isBlockingReadyScript && lastStaticLoadPromise,
1400
+ 'ts'
1401
+ ).catch(throwError);
1178
1402
  }
1179
- // does this load block readystate complete
1180
- const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
1181
- // does this load block DOMContentLoaded
1182
- const isDomContentLoadedScript = domContentLoadedCnt > 0;
1183
- const isLoadScript = loadCnt > 0;
1184
- if (isLoadScript) loadCnt++;
1185
- if (isBlockingReadyScript) readyStateCompleteCnt++;
1186
- if (isDomContentLoadedScript) domContentLoadedCnt++;
1187
- const loadPromise = topLevelLoad(
1188
- script.src || baseUrl,
1189
- getFetchOpts(script),
1190
- !script.src && script.innerHTML,
1191
- !shimMode,
1192
- isBlockingReadyScript && lastStaticLoadPromise
1193
- ).catch(throwError);
1194
1403
  if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
1195
- if (isBlockingReadyScript) lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
1404
+ if (isBlockingReadyScript && !ts) {
1405
+ lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
1406
+ }
1196
1407
  if (isDomContentLoadedScript) loadPromise.then(domContentLoadedCheck);
1197
1408
  if (isLoadScript) loadPromise.then(loadCheck);
1198
- }
1409
+ };
1199
1410
 
1200
1411
  const fetchCache = {};
1201
- function processPreload(link) {
1412
+ const processPreload = link => {
1202
1413
  link.ep = true;
1203
1414
  if (fetchCache[link.href]) return;
1204
1415
  fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
1205
- }
1416
+ };
1206
1417
 
1207
1418
  })();