importmap-rails 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,847 +1,872 @@
1
- /* ES Module Shims 1.5.6 */
1
+ /* ES Module Shims 1.5.8 */
2
2
  (function () {
3
3
 
4
- const noop = () => {};
5
-
6
- const optionsScript = document.querySelector('script[type=esms-options]');
7
-
8
- const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
9
- Object.assign(esmsInitOptions, self.esmsInitOptions || {});
10
-
11
- let shimMode = !!esmsInitOptions.shimMode;
12
-
13
- const importHook = globalHook(shimMode && esmsInitOptions.onimport);
14
- const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
15
- let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
16
- const metaHook = esmsInitOptions.meta ? globalHook(shimModule && esmsInitOptions.meta) : noop;
17
-
18
- const skip = esmsInitOptions.skip ? new RegExp(esmsInitOptions.skip) : null;
19
-
20
- let nonce = esmsInitOptions.nonce;
21
-
22
- const mapOverrides = esmsInitOptions.mapOverrides;
23
-
24
- if (!nonce) {
25
- const nonceElement = document.querySelector('script[nonce]');
26
- if (nonceElement)
27
- nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
28
- }
29
-
30
- const onerror = globalHook(esmsInitOptions.onerror || noop);
31
- const onpolyfill = esmsInitOptions.onpolyfill ? globalHook(esmsInitOptions.onpolyfill) : () => {
32
- console.log('%c^^ Module TypeError above is polyfilled and can be ignored ^^', 'font-weight:900;color:#391');
33
- };
34
-
35
- const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
36
-
37
- function globalHook (name) {
38
- return typeof name === 'string' ? self[name] : name;
39
- }
40
-
41
- const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
42
- const cssModulesEnabled = enable.includes('css-modules');
43
- const jsonModulesEnabled = enable.includes('json-modules');
44
-
45
- function setShimMode () {
46
- shimMode = true;
47
- }
48
-
49
- const edge = !navigator.userAgentData && !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
50
-
51
- const baseUrl = document.baseURI;
52
-
53
- function createBlob (source, type = 'text/javascript') {
54
- return URL.createObjectURL(new Blob([source], { type }));
55
- }
56
-
57
- const eoop = err => setTimeout(() => { throw err });
58
-
59
- const throwError = err => { (window.reportError || window.safari && console.error || eoop)(err), void onerror(err); };
60
-
61
- function fromParent (parent) {
62
- return parent ? ` imported from ${parent}` : '';
63
- }
64
-
65
- const backslashRegEx = /\\/g;
66
-
67
- function isURL (url) {
68
- if (url.indexOf(':') === -1) return false;
69
- try {
70
- new URL(url);
71
- return true;
72
- }
73
- catch (_) {
74
- return false;
75
- }
76
- }
77
-
78
- /*
79
- * Import maps implementation
80
- *
81
- * To make lookups fast we pre-resolve the entire import map
82
- * and then match based on backtracked hash lookups
83
- *
84
- */
85
- function resolveUrl (relUrl, parentUrl) {
86
- return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
87
- }
88
-
89
- function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
90
- // strip off any trailing query params or hashes
91
- const queryHashIndex = parentUrl.indexOf('?', parentUrl.indexOf('#') === -1 ? parentUrl.indexOf('#') : parentUrl.length);
92
- if (queryHashIndex !== -1)
93
- parentUrl = parentUrl.slice(0, queryHashIndex);
94
- if (relUrl.indexOf('\\') !== -1)
95
- relUrl = relUrl.replace(backslashRegEx, '/');
96
- // protocol-relative
97
- if (relUrl[0] === '/' && relUrl[1] === '/') {
98
- return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
99
- }
100
- // relative-url
101
- else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
102
- relUrl.length === 1 && (relUrl += '/')) ||
103
- relUrl[0] === '/') {
104
- const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
105
- // Disabled, but these cases will give inconsistent results for deep backtracking
106
- //if (parentUrl[parentProtocol.length] !== '/')
107
- // throw new Error('Cannot resolve');
108
- // read pathname from parent URL
109
- // pathname taken to be part after leading "/"
110
- let pathname;
111
- if (parentUrl[parentProtocol.length + 1] === '/') {
112
- // resolving to a :// so we need to read out the auth and host
113
- if (parentProtocol !== 'file:') {
114
- pathname = parentUrl.slice(parentProtocol.length + 2);
115
- pathname = pathname.slice(pathname.indexOf('/') + 1);
116
- }
117
- else {
118
- pathname = parentUrl.slice(8);
119
- }
120
- }
121
- else {
122
- // resolving to :/ so pathname is the /... part
123
- pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
124
- }
125
-
126
- if (relUrl[0] === '/')
127
- return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
128
-
129
- // join together and split for removal of .. and . segments
130
- // looping the string instead of anything fancy for perf reasons
131
- // '../../../../../z' resolved to 'x/y' is just 'z'
132
- const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
133
-
134
- const output = [];
135
- let segmentIndex = -1;
136
- for (let i = 0; i < segmented.length; i++) {
137
- // busy reading a segment - only terminate on '/'
138
- if (segmentIndex !== -1) {
139
- if (segmented[i] === '/') {
140
- output.push(segmented.slice(segmentIndex, i + 1));
141
- segmentIndex = -1;
142
- }
143
- continue;
144
- }
145
- // new segment - check if it is relative
146
- else if (segmented[i] === '.') {
147
- // ../ segment
148
- if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
149
- output.pop();
150
- i += 2;
151
- continue;
152
- }
153
- // ./ segment
154
- else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
155
- i += 1;
156
- continue;
157
- }
158
- }
159
- // it is the start of a new segment
160
- while (segmented[i] === '/') i++;
161
- segmentIndex = i;
162
- }
163
- // finish reading out the last segment
164
- if (segmentIndex !== -1)
165
- output.push(segmented.slice(segmentIndex));
166
- return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
167
- }
168
- }
169
-
170
- function resolveAndComposeImportMap (json, baseUrl, parentMap) {
171
- const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
172
-
173
- if (json.imports)
174
- resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
175
-
176
- if (json.scopes)
177
- for (let s in json.scopes) {
178
- const resolvedScope = resolveUrl(s, baseUrl);
179
- resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
180
- }
181
-
182
- return outMap;
183
- }
184
-
185
- function getMatch (path, matchObj) {
186
- if (matchObj[path])
187
- return path;
188
- let sepIndex = path.length;
189
- do {
190
- const segment = path.slice(0, sepIndex + 1);
191
- if (segment in matchObj)
192
- return segment;
193
- } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
194
- }
195
-
196
- function applyPackages (id, packages) {
197
- const pkgName = getMatch(id, packages);
198
- if (pkgName) {
199
- const pkg = packages[pkgName];
200
- if (pkg === null) return;
201
- return pkg + id.slice(pkgName.length);
202
- }
203
- }
204
-
205
-
206
- function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
207
- let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
208
- while (scopeUrl) {
209
- const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
210
- if (packageResolution)
211
- return packageResolution;
212
- scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
213
- }
214
- return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
215
- }
216
-
217
- function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
218
- for (let p in packages) {
219
- const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
220
- if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
221
- throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
222
- }
223
- let target = packages[p];
224
- if (typeof target !== 'string')
225
- continue;
226
- const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
227
- if (mapped) {
228
- outPackages[resolvedLhs] = mapped;
229
- continue;
230
- }
231
- console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
232
- }
233
- }
234
-
235
- let err;
236
- window.addEventListener('error', _err => err = _err);
237
- function dynamicImportScript (url, { errUrl = url } = {}) {
238
- err = undefined;
239
- const src = createBlob(`import*as m from'${url}';self._esmsi=m`);
240
- const s = Object.assign(document.createElement('script'), { type: 'module', src });
241
- s.setAttribute('nonce', nonce);
242
- s.setAttribute('noshim', '');
243
- const p = new Promise((resolve, reject) => {
244
- // Safari is unique in supporting module script error events
245
- s.addEventListener('error', cb);
246
- s.addEventListener('load', cb);
247
-
248
- function cb (_err) {
249
- document.head.removeChild(s);
250
- if (self._esmsi) {
251
- resolve(self._esmsi, baseUrl);
252
- self._esmsi = undefined;
253
- }
254
- else {
255
- reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading or executing the graph of ${errUrl} (check the console for ${src}).`));
256
- err = undefined;
257
- }
258
- }
259
- });
260
- document.head.appendChild(s);
261
- return p;
262
- }
263
-
264
- let dynamicImport = dynamicImportScript;
265
-
266
- const supportsDynamicImportCheck = dynamicImportScript(createBlob('export default u=>import(u)')).then(_dynamicImport => {
267
- if (_dynamicImport)
268
- dynamicImport = _dynamicImport.default;
269
- return !!_dynamicImport;
4
+ const hasWindow = typeof window !== 'undefined';
5
+ const hasDocument = typeof document !== 'undefined';
6
+
7
+ const noop = () => {};
8
+
9
+ const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
10
+
11
+ const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
12
+ Object.assign(esmsInitOptions, self.esmsInitOptions || {});
13
+
14
+ let shimMode = hasDocument ? !!esmsInitOptions.shimMode : true;
15
+
16
+ const importHook = globalHook(shimMode && esmsInitOptions.onimport);
17
+ const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
18
+ let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
19
+ const metaHook = esmsInitOptions.meta ? globalHook(shimModule && esmsInitOptions.meta) : noop;
20
+
21
+ const skip = esmsInitOptions.skip ? new RegExp(esmsInitOptions.skip) : null;
22
+
23
+ const mapOverrides = esmsInitOptions.mapOverrides;
24
+
25
+ let nonce = esmsInitOptions.nonce;
26
+ if (!nonce && hasDocument) {
27
+ const nonceElement = document.querySelector('script[nonce]');
28
+ if (nonceElement)
29
+ nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
30
+ }
31
+
32
+ const onerror = globalHook(esmsInitOptions.onerror || noop);
33
+ const onpolyfill = esmsInitOptions.onpolyfill ? globalHook(esmsInitOptions.onpolyfill) : () => {
34
+ console.log('%c^^ Module TypeError above is polyfilled and can be ignored ^^', 'font-weight:900;color:#391');
35
+ };
36
+
37
+ const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
38
+
39
+ function globalHook (name) {
40
+ return typeof name === 'string' ? self[name] : name;
41
+ }
42
+
43
+ const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
44
+ const cssModulesEnabled = enable.includes('css-modules');
45
+ const jsonModulesEnabled = enable.includes('json-modules');
46
+
47
+ function setShimMode () {
48
+ shimMode = true;
49
+ }
50
+
51
+ const edge = !navigator.userAgentData && !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
52
+
53
+ const baseUrl = hasDocument
54
+ ? document.baseURI
55
+ : `${location.protocol}//${location.host}${location.pathname.includes('/')
56
+ ? location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
57
+ : location.pathname}`;
58
+
59
+ function createBlob (source, type = 'text/javascript') {
60
+ return URL.createObjectURL(new Blob([source], { type }));
61
+ }
62
+
63
+ const eoop = err => setTimeout(() => { throw err });
64
+
65
+ const throwError = err => { (self.reportError || hasWindow && window.safari && console.error || eoop)(err), void onerror(err); };
66
+
67
+ function fromParent (parent) {
68
+ return parent ? ` imported from ${parent}` : '';
69
+ }
70
+
71
+ const backslashRegEx = /\\/g;
72
+
73
+ function isURL (url) {
74
+ if (url.indexOf(':') === -1) return false;
75
+ try {
76
+ new URL(url);
77
+ return true;
78
+ }
79
+ catch (_) {
80
+ return false;
81
+ }
82
+ }
83
+
84
+ /*
85
+ * Import maps implementation
86
+ *
87
+ * To make lookups fast we pre-resolve the entire import map
88
+ * and then match based on backtracked hash lookups
89
+ *
90
+ */
91
+ function resolveUrl (relUrl, parentUrl) {
92
+ return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
93
+ }
94
+
95
+ function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
96
+ // strip off any trailing query params or hashes
97
+ const queryHashIndex = parentUrl.indexOf('?', parentUrl.indexOf('#') === -1 ? parentUrl.indexOf('#') : parentUrl.length);
98
+ if (queryHashIndex !== -1)
99
+ parentUrl = parentUrl.slice(0, queryHashIndex);
100
+ if (relUrl.indexOf('\\') !== -1)
101
+ relUrl = relUrl.replace(backslashRegEx, '/');
102
+ // protocol-relative
103
+ if (relUrl[0] === '/' && relUrl[1] === '/') {
104
+ return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
105
+ }
106
+ // relative-url
107
+ else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
108
+ relUrl.length === 1 && (relUrl += '/')) ||
109
+ relUrl[0] === '/') {
110
+ const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
111
+ // Disabled, but these cases will give inconsistent results for deep backtracking
112
+ //if (parentUrl[parentProtocol.length] !== '/')
113
+ // throw new Error('Cannot resolve');
114
+ // read pathname from parent URL
115
+ // pathname taken to be part after leading "/"
116
+ let pathname;
117
+ if (parentUrl[parentProtocol.length + 1] === '/') {
118
+ // resolving to a :// so we need to read out the auth and host
119
+ if (parentProtocol !== 'file:') {
120
+ pathname = parentUrl.slice(parentProtocol.length + 2);
121
+ pathname = pathname.slice(pathname.indexOf('/') + 1);
122
+ }
123
+ else {
124
+ pathname = parentUrl.slice(8);
125
+ }
126
+ }
127
+ else {
128
+ // resolving to :/ so pathname is the /... part
129
+ pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
130
+ }
131
+
132
+ if (relUrl[0] === '/')
133
+ return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
134
+
135
+ // join together and split for removal of .. and . segments
136
+ // looping the string instead of anything fancy for perf reasons
137
+ // '../../../../../z' resolved to 'x/y' is just 'z'
138
+ const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
139
+
140
+ const output = [];
141
+ let segmentIndex = -1;
142
+ for (let i = 0; i < segmented.length; i++) {
143
+ // busy reading a segment - only terminate on '/'
144
+ if (segmentIndex !== -1) {
145
+ if (segmented[i] === '/') {
146
+ output.push(segmented.slice(segmentIndex, i + 1));
147
+ segmentIndex = -1;
148
+ }
149
+ continue;
150
+ }
151
+ // new segment - check if it is relative
152
+ else if (segmented[i] === '.') {
153
+ // ../ segment
154
+ if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
155
+ output.pop();
156
+ i += 2;
157
+ continue;
158
+ }
159
+ // ./ segment
160
+ else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
161
+ i += 1;
162
+ continue;
163
+ }
164
+ }
165
+ // it is the start of a new segment
166
+ while (segmented[i] === '/') i++;
167
+ segmentIndex = i;
168
+ }
169
+ // finish reading out the last segment
170
+ if (segmentIndex !== -1)
171
+ output.push(segmented.slice(segmentIndex));
172
+ return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
173
+ }
174
+ }
175
+
176
+ function resolveAndComposeImportMap (json, baseUrl, parentMap) {
177
+ const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
178
+
179
+ if (json.imports)
180
+ resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
181
+
182
+ if (json.scopes)
183
+ for (let s in json.scopes) {
184
+ const resolvedScope = resolveUrl(s, baseUrl);
185
+ resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
186
+ }
187
+
188
+ return outMap;
189
+ }
190
+
191
+ function getMatch (path, matchObj) {
192
+ if (matchObj[path])
193
+ return path;
194
+ let sepIndex = path.length;
195
+ do {
196
+ const segment = path.slice(0, sepIndex + 1);
197
+ if (segment in matchObj)
198
+ return segment;
199
+ } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
200
+ }
201
+
202
+ function applyPackages (id, packages) {
203
+ const pkgName = getMatch(id, packages);
204
+ if (pkgName) {
205
+ const pkg = packages[pkgName];
206
+ if (pkg === null) return;
207
+ return pkg + id.slice(pkgName.length);
208
+ }
209
+ }
210
+
211
+
212
+ function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
213
+ let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
214
+ while (scopeUrl) {
215
+ const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
216
+ if (packageResolution)
217
+ return packageResolution;
218
+ scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
219
+ }
220
+ return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
221
+ }
222
+
223
+ function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
224
+ for (let p in packages) {
225
+ const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
226
+ if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
227
+ throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
228
+ }
229
+ let target = packages[p];
230
+ if (typeof target !== 'string')
231
+ continue;
232
+ const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
233
+ if (mapped) {
234
+ outPackages[resolvedLhs] = mapped;
235
+ continue;
236
+ }
237
+ console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
238
+ }
239
+ }
240
+
241
+ let err;
242
+ window.addEventListener('error', _err => err = _err);
243
+ function dynamicImportScript (url, { errUrl = url } = {}) {
244
+ err = undefined;
245
+ const src = createBlob(`import*as m from'${url}';self._esmsi=m`);
246
+ const s = Object.assign(document.createElement('script'), { type: 'module', src });
247
+ s.setAttribute('nonce', nonce);
248
+ s.setAttribute('noshim', '');
249
+ const p = new Promise((resolve, reject) => {
250
+ // Safari is unique in supporting module script error events
251
+ s.addEventListener('error', cb);
252
+ s.addEventListener('load', cb);
253
+
254
+ function cb (_err) {
255
+ document.head.removeChild(s);
256
+ if (self._esmsi) {
257
+ resolve(self._esmsi, baseUrl);
258
+ self._esmsi = undefined;
259
+ }
260
+ else {
261
+ reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading or executing the graph of ${errUrl} (check the console for ${src}).`));
262
+ err = undefined;
263
+ }
264
+ }
265
+ });
266
+ document.head.appendChild(s);
267
+ return p;
268
+ }
269
+
270
+ let dynamicImport = dynamicImportScript;
271
+
272
+ const supportsDynamicImportCheck = dynamicImportScript(createBlob('export default u=>import(u)')).then(_dynamicImport => {
273
+ if (_dynamicImport)
274
+ dynamicImport = _dynamicImport.default;
275
+ return !!_dynamicImport;
270
276
  }, noop);
271
277
 
272
- // support browsers without dynamic import support (eg Firefox 6x)
273
- let supportsJsonAssertions = false;
274
- let supportsCssAssertions = false;
275
-
276
- let supportsImportMaps = HTMLScriptElement.supports ? HTMLScriptElement.supports('importmap') : false;
277
- let supportsImportMeta = supportsImportMaps;
278
- let supportsDynamicImport = false;
279
-
280
- const featureDetectionPromise = Promise.resolve(supportsImportMaps || supportsDynamicImportCheck).then(_supportsDynamicImport => {
281
- if (!_supportsDynamicImport)
282
- return;
283
- supportsDynamicImport = true;
284
-
285
- return Promise.all([
286
- supportsImportMaps || dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
287
- cssModulesEnabled && dynamicImport(createBlob('import"data:text/css,{}"assert{type:"css"}')).then(() => supportsCssAssertions = true, noop),
288
- jsonModulesEnabled && dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, noop),
289
- supportsImportMaps || new Promise(resolve => {
290
- self._$s = v => {
291
- document.head.removeChild(iframe);
292
- if (v) supportsImportMaps = true;
293
- delete self._$s;
294
- resolve();
295
- };
296
- const iframe = document.createElement('iframe');
297
- iframe.style.display = 'none';
298
- iframe.setAttribute('nonce', nonce);
299
- document.head.appendChild(iframe);
300
- // we use document.write here because eg Weixin built-in browser doesn't support setting srcdoc
301
- // setting src to a blob URL results in a navigation event in webviews
302
- // setting srcdoc is not supported in React native webviews on iOS
303
- iframe.contentWindow.document.write(`<script type=importmap nonce="${nonce}">{"imports":{"x":"data:text/javascript,"}}<${''}/script><script nonce="${nonce}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`);
304
- })
305
- ]);
278
+ // support browsers without dynamic import support (eg Firefox 6x)
279
+ let supportsJsonAssertions = false;
280
+ let supportsCssAssertions = false;
281
+
282
+ let supportsImportMaps = hasDocument && HTMLScriptElement.supports ? HTMLScriptElement.supports('importmap') : false;
283
+ let supportsImportMeta = supportsImportMaps;
284
+ let supportsDynamicImport = false;
285
+
286
+ const featureDetectionPromise = Promise.resolve(supportsImportMaps || supportsDynamicImportCheck).then(_supportsDynamicImport => {
287
+ if (!_supportsDynamicImport)
288
+ return;
289
+ supportsDynamicImport = true;
290
+
291
+ return Promise.all([
292
+ supportsImportMaps || dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
293
+ cssModulesEnabled && dynamicImport(createBlob(`import"${createBlob('', 'text/css')}"assert{type:"css"}`)).then(() => supportsCssAssertions = true, noop),
294
+ jsonModulesEnabled && dynamicImport(createBlob(`import"${createBlob('{}', 'text/json')}"assert{type:"json"}`)).then(() => supportsJsonAssertions = true, noop),
295
+ supportsImportMaps || hasDocument && (HTMLScriptElement.supports || new Promise(resolve => {
296
+ const iframe = document.createElement('iframe');
297
+ iframe.style.display = 'none';
298
+ iframe.setAttribute('nonce', nonce);
299
+ // setting src to a blob URL results in a navigation event in webviews
300
+ // setting srcdoc is not supported in React native webviews on iOS
301
+ // therefore, we need to first feature detect srcdoc support
302
+ iframe.srcdoc = `<!doctype html><script nonce="${nonce}"><${''}/script>`;
303
+ document.head.appendChild(iframe);
304
+ iframe.onload = () => {
305
+ self._$s = v => {
306
+ document.head.removeChild(iframe);
307
+ supportsImportMaps = v;
308
+ delete self._$s;
309
+ resolve();
310
+ };
311
+ const supportsSrcDoc = iframe.contentDocument.head.childNodes.length > 0;
312
+ const importMapTest = `<!doctype html><script type=importmap nonce="${nonce}">{"imports":{"x":"${createBlob('')}"}<${''}/script><script nonce="${nonce}">import('x').catch(() => {}).then(v=>parent._$s(!!v))<${''}/script>`;
313
+ if (supportsSrcDoc)
314
+ iframe.srcdoc = importMapTest;
315
+ else
316
+ iframe.contentDocument.write(importMapTest);
317
+ };
318
+ }))
319
+ ]);
306
320
  });
307
321
 
308
322
  /* es-module-lexer 0.10.5 */
309
323
  let e,a,r,s=2<<19;const i=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let s=0;for(;s<r;)a[s]=e.charCodeAt(s++);}:function(e,a){const r=e.length;let s=0;for(;s<r;){const r=e.charCodeAt(s);a[s++]=(255&r)<<8|r>>>8;}},t="xportmportlassetafromssertvoyiedeleinstantyreturdebuggeawaithrwhileforifcatcfinallels";let c$1,f,n;function parse(k,l="@"){c$1=k,f=l;const u=2*c$1.length+(2<<18);if(u>s||!e){for(;u>s;)s*=2;a=new ArrayBuffer(s),i(t,new Uint16Array(a,16,85)),e=function(e,a,r){"use asm";var s=new e.Int8Array(r),i=new e.Int16Array(r),t=new e.Int32Array(r),c=new e.Uint8Array(r),f=new e.Uint16Array(r),n=992;function b(e){e=e|0;var a=0,r=0,c=0,b=0,u=0,w=0,v=0;v=n;n=n+11520|0;u=v+2048|0;s[763]=1;i[377]=0;i[378]=0;i[379]=0;i[380]=-1;t[57]=t[2];s[764]=0;t[56]=0;s[762]=0;t[58]=v+10496;t[59]=v+2304;t[60]=v;s[765]=0;e=(t[3]|0)+-2|0;t[61]=e;a=e+(t[54]<<1)|0;t[62]=a;e:while(1){r=e+2|0;t[61]=r;if(e>>>0>=a>>>0){b=18;break}a:do{switch(i[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((i[379]|0)==0?D(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(k(),(s[763]|0)==0):0){b=9;break e}else b=17;break}case 105:{if(D(r)|0?(m(e+4|0,26,10)|0)==0:0){l();b=17;}else b=17;break}case 59:{b=17;break}case 47:switch(i[e+4>>1]|0){case 47:{j();break a}case 42:{y(1);break a}default:{b=16;break e}}default:{b=16;break e}}}while(0);if((b|0)==17){b=0;t[57]=t[61];}e=t[61]|0;a=t[62]|0;}if((b|0)==9){e=t[61]|0;t[57]=e;b=19;}else if((b|0)==16){s[763]=0;t[61]=e;b=19;}else if((b|0)==18)if(!(s[762]|0)){e=r;b=19;}else e=0;do{if((b|0)==19){e:while(1){a=e+2|0;t[61]=a;c=a;if(e>>>0>=(t[62]|0)>>>0){b=75;break}a:do{switch(i[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((i[379]|0)==0?D(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){k();b=74;}else b=74;break}case 105:{if(D(a)|0?(m(e+4|0,26,10)|0)==0:0){l();b=74;}else b=74;break}case 99:{if((D(a)|0?(m(e+4|0,36,8)|0)==0:0)?M(i[e+12>>1]|0)|0:0){s[765]=1;b=74;}else b=74;break}case 40:{r=t[57]|0;c=t[59]|0;b=i[379]|0;i[379]=b+1<<16>>16;t[c+((b&65535)<<2)>>2]=r;b=74;break}case 41:{a=i[379]|0;if(!(a<<16>>16)){b=36;break e}a=a+-1<<16>>16;i[379]=a;r=i[378]|0;if(r<<16>>16!=0?(w=t[(t[60]|0)+((r&65535)+-1<<2)>>2]|0,(t[w+20>>2]|0)==(t[(t[59]|0)+((a&65535)<<2)>>2]|0)):0){a=w+4|0;if(!(t[a>>2]|0))t[a>>2]=c;t[w+12>>2]=e+4;i[378]=r+-1<<16>>16;b=74;}else b=74;break}case 123:{b=t[57]|0;c=t[51]|0;e=b;do{if((i[b>>1]|0)==41&(c|0)!=0?(t[c+4>>2]|0)==(b|0):0){a=t[52]|0;t[51]=a;if(!a){t[47]=0;break}else {t[a+28>>2]=0;break}}}while(0);r=i[379]|0;b=r&65535;s[u+b>>0]=s[765]|0;s[765]=0;c=t[59]|0;i[379]=r+1<<16>>16;t[c+(b<<2)>>2]=e;b=74;break}case 125:{e=i[379]|0;if(!(e<<16>>16)){b=49;break e}r=e+-1<<16>>16;i[379]=r;a=i[380]|0;if(e<<16>>16!=a<<16>>16)if(a<<16>>16!=-1&(r&65535)<(a&65535)){b=53;break e}else {b=74;break a}else {c=t[58]|0;b=(i[377]|0)+-1<<16>>16;i[377]=b;i[380]=i[c+((b&65535)<<1)>>1]|0;h();b=74;break a}}case 39:{d(39);b=74;break}case 34:{d(34);b=74;break}case 47:switch(i[e+4>>1]|0){case 47:{j();break a}case 42:{y(1);break a}default:{a=t[57]|0;r=i[a>>1]|0;r:do{if(!(U(r)|0)){switch(r<<16>>16){case 41:if(q(t[(t[59]|0)+(f[379]<<2)>>2]|0)|0){b=71;break r}else {b=68;break r}case 125:break;default:{b=68;break r}}e=f[379]|0;if(!(p(t[(t[59]|0)+(e<<2)>>2]|0)|0)?(s[u+e>>0]|0)==0:0)b=68;else b=71;}else switch(r<<16>>16){case 46:if(((i[a+-2>>1]|0)+-48&65535)<10){b=68;break r}else {b=71;break r}case 43:if((i[a+-2>>1]|0)==43){b=68;break r}else {b=71;break r}case 45:if((i[a+-2>>1]|0)==45){b=68;break r}else {b=71;break r}default:{b=71;break r}}}while(0);r:do{if((b|0)==68){b=0;if(!(o(a)|0)){switch(r<<16>>16){case 0:{b=71;break r}case 47:break;default:{e=1;break r}}if(!(s[764]|0))e=1;else b=71;}else b=71;}}while(0);if((b|0)==71){g();e=0;}s[764]=e;b=74;break a}}case 96:{h();b=74;break}default:b=74;}}while(0);if((b|0)==74){b=0;t[57]=t[61];}e=t[61]|0;}if((b|0)==36){L();e=0;break}else if((b|0)==49){L();e=0;break}else if((b|0)==53){L();e=0;break}else if((b|0)==75){e=(i[380]|0)==-1&(i[379]|0)==0&(s[762]|0)==0&(i[378]|0)==0;break}}}while(0);n=v;return e|0}function k(){var e=0,a=0,r=0,c=0,f=0,n=0;f=t[61]|0;n=f+12|0;t[61]=n;a=w(1)|0;e=t[61]|0;if(!((e|0)==(n|0)?!(I(a)|0):0))c=3;e:do{if((c|0)==3){a:do{switch(a<<16>>16){case 100:{B(e,e+14|0);break e}case 97:{t[61]=e+10;w(1)|0;e=t[61]|0;c=6;break}case 102:{c=6;break}case 99:{if((m(e+2|0,36,8)|0)==0?(r=e+10|0,$(i[r>>1]|0)|0):0){t[61]=r;f=w(1)|0;n=t[61]|0;E(f)|0;B(n,t[61]|0);t[61]=(t[61]|0)+-2;break e}e=e+4|0;t[61]=e;c=13;break}case 108:case 118:{c=13;break}case 123:{t[61]=e+2;e=w(1)|0;r=t[61]|0;while(1){if(N(e)|0){d(e);e=(t[61]|0)+2|0;t[61]=e;}else {E(e)|0;e=t[61]|0;}w(1)|0;e=C(r,e)|0;if(e<<16>>16==44){t[61]=(t[61]|0)+2;e=w(1)|0;}a=r;r=t[61]|0;if(e<<16>>16==125){c=32;break}if((r|0)==(a|0)){c=29;break}if(r>>>0>(t[62]|0)>>>0){c=31;break}}if((c|0)==29){L();break e}else if((c|0)==31){L();break e}else if((c|0)==32){t[61]=r+2;c=34;break a}break}case 42:{t[61]=e+2;w(1)|0;c=t[61]|0;C(c,c)|0;c=34;break}default:{}}}while(0);if((c|0)==6){t[61]=e+16;e=w(1)|0;if(e<<16>>16==42){t[61]=(t[61]|0)+2;e=w(1)|0;}n=t[61]|0;E(e)|0;B(n,t[61]|0);t[61]=(t[61]|0)+-2;break}else if((c|0)==13){e=e+4|0;t[61]=e;s[763]=0;a:while(1){t[61]=e+2;n=w(1)|0;e=t[61]|0;switch((E(n)|0)<<16>>16){case 91:case 123:{c=15;break a}default:{}}a=t[61]|0;if((a|0)==(e|0))break e;B(e,a);switch((w(1)|0)<<16>>16){case 61:{c=19;break a}case 44:break;default:{c=20;break a}}e=t[61]|0;}if((c|0)==15){t[61]=(t[61]|0)+-2;break}else if((c|0)==19){t[61]=(t[61]|0)+-2;break}else if((c|0)==20){t[61]=(t[61]|0)+-2;break}}else if((c|0)==34)a=w(1)|0;e=t[61]|0;if(a<<16>>16==102?(m(e+2|0,52,6)|0)==0:0){t[61]=e+8;u(f,w(1)|0);break}t[61]=e+-2;}}while(0);return}function l(){var e=0,a=0,r=0,c=0,f=0;f=t[61]|0;a=f+12|0;t[61]=a;e:do{switch((w(1)|0)<<16>>16){case 40:{e=t[61]|0;a=t[59]|0;r=i[379]|0;i[379]=r+1<<16>>16;t[a+((r&65535)<<2)>>2]=e;if((i[t[57]>>1]|0)!=46){e=t[61]|0;t[61]=e+2;r=w(1)|0;v(f,t[61]|0,0,e);e=t[51]|0;a=t[60]|0;f=i[378]|0;i[378]=f+1<<16>>16;t[a+((f&65535)<<2)>>2]=e;switch(r<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{t[61]=(t[61]|0)+-2;break e}}e=(t[61]|0)+2|0;t[61]=e;switch((w(1)|0)<<16>>16){case 44:{t[61]=(t[61]|0)+2;w(1)|0;r=t[51]|0;t[r+4>>2]=e;f=t[61]|0;t[r+16>>2]=f;s[r+24>>0]=1;t[61]=f+-2;break e}case 41:{i[379]=(i[379]|0)+-1<<16>>16;f=t[51]|0;t[f+4>>2]=e;t[f+12>>2]=(t[61]|0)+2;s[f+24>>0]=1;i[378]=(i[378]|0)+-1<<16>>16;break e}default:{t[61]=(t[61]|0)+-2;break e}}}break}case 46:{t[61]=(t[61]|0)+2;if(((w(1)|0)<<16>>16==109?(e=t[61]|0,(m(e+2|0,44,6)|0)==0):0)?(i[t[57]>>1]|0)!=46:0)v(f,f,e+8|0,2);break}case 42:case 39:case 34:{c=16;break}case 123:{e=t[61]|0;if(i[379]|0){t[61]=e+-2;break e}while(1){if(e>>>0>=(t[62]|0)>>>0)break;e=w(1)|0;if(!(N(e)|0)){if(e<<16>>16==125){c=31;break}}else d(e);e=(t[61]|0)+2|0;t[61]=e;}if((c|0)==31)t[61]=(t[61]|0)+2;w(1)|0;e=t[61]|0;if(m(e,50,8)|0){L();break e}t[61]=e+8;e=w(1)|0;if(N(e)|0){u(f,e);break e}else {L();break e}}default:if((t[61]|0)!=(a|0))c=16;}}while(0);do{if((c|0)==16){if(i[379]|0){t[61]=(t[61]|0)+-2;break}e=t[62]|0;a=t[61]|0;while(1){if(a>>>0>=e>>>0){c=23;break}r=i[a>>1]|0;if(N(r)|0){c=21;break}c=a+2|0;t[61]=c;a=c;}if((c|0)==21){u(f,r);break}else if((c|0)==23){L();break}}}while(0);return}function u(e,a){e=e|0;a=a|0;var r=0,s=0;r=(t[61]|0)+2|0;switch(a<<16>>16){case 39:{d(39);s=5;break}case 34:{d(34);s=5;break}default:L();}do{if((s|0)==5){v(e,r,t[61]|0,1);t[61]=(t[61]|0)+2;s=(w(0)|0)<<16>>16==97;a=t[61]|0;if(s?(m(a+2|0,58,10)|0)==0:0){t[61]=a+12;if((w(1)|0)<<16>>16!=123){t[61]=a;break}e=t[61]|0;r=e;e:while(1){t[61]=r+2;r=w(1)|0;switch(r<<16>>16){case 39:{d(39);t[61]=(t[61]|0)+2;r=w(1)|0;break}case 34:{d(34);t[61]=(t[61]|0)+2;r=w(1)|0;break}default:r=E(r)|0;}if(r<<16>>16!=58){s=16;break}t[61]=(t[61]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{s=20;break e}}t[61]=(t[61]|0)+2;switch((w(1)|0)<<16>>16){case 125:{s=25;break e}case 44:break;default:{s=24;break e}}t[61]=(t[61]|0)+2;if((w(1)|0)<<16>>16==125){s=25;break}r=t[61]|0;}if((s|0)==16){t[61]=a;break}else if((s|0)==20){t[61]=a;break}else if((s|0)==24){t[61]=a;break}else if((s|0)==25){s=t[51]|0;t[s+16>>2]=e;t[s+12>>2]=(t[61]|0)+2;break}}t[61]=a+-2;}}while(0);return}function o(e){e=e|0;e:do{switch(i[e>>1]|0){case 100:switch(i[e+-2>>1]|0){case 105:{e=S(e+-4|0,68,2)|0;break e}case 108:{e=S(e+-4|0,72,3)|0;break e}default:{e=0;break e}}case 101:{switch(i[e+-2>>1]|0){case 115:break;case 116:{e=S(e+-4|0,78,4)|0;break e}default:{e=0;break e}}switch(i[e+-4>>1]|0){case 108:{e=O(e+-6|0,101)|0;break e}case 97:{e=O(e+-6|0,99)|0;break e}default:{e=0;break e}}}case 102:{if((i[e+-2>>1]|0)==111?(i[e+-4>>1]|0)==101:0)switch(i[e+-6>>1]|0){case 99:{e=S(e+-8|0,86,6)|0;break e}case 112:{e=S(e+-8|0,98,2)|0;break e}default:{e=0;break e}}else e=0;break}case 110:{e=e+-2|0;if(O(e,105)|0)e=1;else e=S(e,102,5)|0;break}case 111:{e=O(e+-2|0,100)|0;break}case 114:{e=S(e+-2|0,112,7)|0;break}case 116:{e=S(e+-2|0,126,4)|0;break}case 119:switch(i[e+-2>>1]|0){case 101:{e=O(e+-4|0,110)|0;break e}case 111:{e=S(e+-4|0,134,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;a=t[62]|0;r=t[61]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=8;break}switch(i[e>>1]|0){case 96:{a=9;break e}case 36:{if((i[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){t[61]=r+4;e=i[380]|0;a=t[58]|0;r=i[377]|0;i[377]=r+1<<16>>16;i[a+((r&65535)<<1)>>1]=e;r=(i[379]|0)+1<<16>>16;i[379]=r;i[380]=r;}else if((a|0)==8){t[61]=e;L();}else if((a|0)==9)t[61]=e;return}function w(e){e=e|0;var a=0,r=0,s=0;r=t[61]|0;e:do{a=i[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(M(a)|0)break;else break e;else if(z(a)|0)break;else break e;else switch(i[r+2>>1]|0){case 47:{j();break a}case 42:{y(e);break a}default:{a=47;break e}}}while(0);s=t[61]|0;r=s+2|0;t[61]=r;}while(s>>>0<(t[62]|0)>>>0);return a|0}function d(e){e=e|0;var a=0,r=0,s=0,c=0;c=t[62]|0;a=t[61]|0;while(1){s=a+2|0;if(a>>>0>=c>>>0){a=9;break}r=i[s>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((i[r>>1]|0)==13){a=a+6|0;a=(i[a>>1]|0)==10?a:r;}else a=r;}else if(T(r)|0){a=9;break}else a=s;}if((a|0)==9){t[61]=s;L();}else if((a|0)==10)t[61]=s;return}function v(e,a,r,i){e=e|0;a=a|0;r=r|0;i=i|0;var c=0,f=0;c=t[55]|0;t[55]=c+32;f=t[51]|0;t[((f|0)==0?188:f+28|0)>>2]=c;t[52]=f;t[51]=c;t[c+8>>2]=e;if(2==(i|0))e=r;else e=1==(i|0)?r+2|0:0;t[c+12>>2]=e;t[c>>2]=a;t[c+4>>2]=r;t[c+16>>2]=0;t[c+20>>2]=i;s[c+24>>0]=1==(i|0)&1;t[c+28>>2]=0;return}function A(){var e=0,a=0,r=0;r=t[62]|0;a=t[61]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(i[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){t[61]=e;L();e=0;}else if((a|0)==7){t[61]=e;e=93;}return e|0}function C(e,a){e=e|0;a=a|0;var r=0,s=0;r=t[61]|0;s=i[r>>1]|0;if(s<<16>>16==97){t[61]=r+4;r=w(1)|0;e=t[61]|0;if(N(r)|0){d(r);a=(t[61]|0)+2|0;t[61]=a;}else {E(r)|0;a=t[61]|0;}s=w(1)|0;r=t[61]|0;}if((r|0)!=(e|0))B(e,a);return s|0}function g(){var e=0,a=0,r=0;e:while(1){e=t[61]|0;a=e+2|0;t[61]=a;if(e>>>0>=(t[62]|0)>>>0){r=7;break}switch(i[a>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{A()|0;break}case 92:{t[61]=e+4;break}default:{}}}if((r|0)==7)L();return}function p(e){e=e|0;switch(i[e>>1]|0){case 62:{e=(i[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=S(e+-2|0,160,4)|0;break}case 121:{e=S(e+-2|0,168,6)|0;break}case 101:{e=S(e+-2|0,180,3)|0;break}default:e=0;}return e|0}function y(e){e=e|0;var a=0,r=0,s=0,c=0,f=0;c=(t[61]|0)+2|0;t[61]=c;r=t[62]|0;while(1){a=c+2|0;if(c>>>0>=r>>>0)break;s=i[a>>1]|0;if(!e?T(s)|0:0)break;if(s<<16>>16==42?(i[c+4>>1]|0)==47:0){f=8;break}c=a;}if((f|0)==8){t[61]=a;a=c+4|0;}t[61]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,t=0;e:do{if(!r)e=0;else {while(1){i=s[e>>0]|0;t=s[a>>0]|0;if(i<<24>>24!=t<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(i&255)-(t&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,r=0,s=0,c=0;r=n;n=n+16|0;s=r;t[s>>2]=0;t[54]=e;a=t[3]|0;c=a+(e<<1)|0;e=c+2|0;i[c>>1]=0;t[s>>2]=e;t[55]=e;t[47]=0;t[51]=0;t[49]=0;t[48]=0;t[53]=0;t[50]=0;n=r;return a|0}function S(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,c=0;s=e+(0-r<<1)|0;c=s+2|0;e=t[3]|0;if(c>>>0>=e>>>0?(m(c,a,r<<1)|0)==0:0)if((c|0)==(e|0))e=1;else e=$(i[s>>1]|0)|0;else e=0;return e|0}function O(e,a){e=e|0;a=a|0;var r=0;r=t[3]|0;if(r>>>0<=e>>>0?(i[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=$(i[e+-2>>1]|0)|0;else r=0;return r|0}function $(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 j(){var e=0,a=0,r=0;e=t[62]|0;r=t[61]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(i[a>>1]|0){case 13:case 10:break e;default:r=a;}}t[61]=a;return}function B(e,a){e=e|0;a=a|0;var r=0,s=0;r=t[55]|0;t[55]=r+12;s=t[53]|0;t[((s|0)==0?192:s+8|0)>>2]=r;t[53]=r;t[r>>2]=e;t[r+4>>2]=a;t[r+8>>2]=0;return}function E(e){e=e|0;while(1){if(M(e)|0)break;if(I(e)|0)break;e=(t[61]|0)+2|0;t[61]=e;e=i[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function P(){var e=0;e=t[(t[49]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(t[3]|0)>>1;}return e|0}function q(e){e=e|0;if(!(S(e,140,5)|0)?!(S(e,150,3)|0):0)e=S(e,156,2)|0;else e=1;return e|0}function z(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 D(e){e=e|0;if((t[3]|0)==(e|0))e=1;else e=$(i[e+-2>>1]|0)|0;return e|0}function F(){var e=0;e=t[(t[49]|0)+12>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function G(){var e=0;e=t[(t[49]|0)+16>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function H(){var e=0;e=t[(t[49]|0)+4>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function J(){var e=0;e=t[49]|0;e=t[((e|0)==0?188:e+28|0)>>2]|0;t[49]=e;return (e|0)!=0|0}function K(){var e=0;e=t[50]|0;e=t[((e|0)==0?192:e+8|0)>>2]|0;t[50]=e;return (e|0)!=0|0}function L(){s[762]=1;t[56]=(t[61]|0)-(t[3]|0)>>1;t[61]=(t[62]|0)+2;return}function M(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function N(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function Q(){return (t[(t[49]|0)+8>>2]|0)-(t[3]|0)>>1|0}function R(){return (t[(t[50]|0)+4>>2]|0)-(t[3]|0)>>1|0}function T(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function V(){return (t[t[49]>>2]|0)-(t[3]|0)>>1|0}function W(){return (t[t[50]>>2]|0)-(t[3]|0)>>1|0}function X(){return c[(t[49]|0)+24>>0]|0|0}function Y(e){e=e|0;t[3]=e;return}function Z(){return (s[763]|0)!=0|0}function _(){return t[56]|0}function ee(e){e=e|0;n=e+992+15&-16;return 992}return {su:ee,ai:G,e:_,ee:R,es:W,f:Z,id:P,ie:H,ip:X,is:V,p:b,re:K,ri:J,sa:x,se:F,ses:Y,ss:Q}}("undefined"!=typeof self?self:global,{},a),r=e.su(s-(2<<17));}const h=c$1.length+1;e.ses(r),e.sa(h-1),i(c$1,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),s=e.ai(),i=e.id(),t=e.ss(),f=e.se();let n;e.ip()&&(n=b(-1===i?a:a+1,c$1.charCodeAt(-1===i?a-1:a))),w.push({n:n,s:a,e:r,ss:t,se:f,d:i,a:s});}for(;e.re();){const a=e.es(),r=c$1.charCodeAt(a);d.push(34===r||39===r?b(a+1,r):c$1.slice(e.es(),e.ee()));}return [w,d,!!e.f()]}function b(e,a){n=e;let r="",s=n;for(;;){n>=c$1.length&&o();const e=c$1.charCodeAt(n);if(e===a)break;92===e?(r+=c$1.slice(s,n),r+=k(),s=n):(8232===e||8233===e||u(e)&&o(),++n);}return r+=c$1.slice(s,n++),r}function k(){let e=c$1.charCodeAt(++n);switch(++n,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(l(2));case 117:return function(){let e;123===c$1.charCodeAt(n)?(++n,e=l(c$1.indexOf("}",n)-n),++n,e>1114111&&o()):e=l(4);return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}();case 116:return "\t";case 98:return "\b";case 118:return "\v";case 102:return "\f";case 13:10===c$1.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=c$1.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=c$1.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,s=0;for(let a=0;a<e;++a,++n){let e,i=c$1.charCodeAt(n);if(95!==i){if(i>=97)e=i-97+10;else if(i>=65)e=i-65+10;else {if(!(i>=48&&i<=57))break;e=i-48;}if(e>=16)break;s=i,r=16*r+e;}else 95!==s&&0!==a||o(),s=i;}return 95!==s&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(`Parse error ${f}:${c$1.slice(0,n).split("\n").length}:${n-c$1.lastIndexOf("\n",n-1)}`),{idx:n})}
310
324
 
311
- async function _resolve (id, parentUrl) {
312
- const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
313
- return {
314
- r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl),
315
- // b = bare specifier
316
- b: !urlResolved && !isURL(id)
317
- };
318
- }
319
-
320
- const resolve = resolveHook ? async (id, parentUrl) => {
321
- let result = resolveHook(id, parentUrl, defaultResolve);
322
- // will be deprecated in next major
323
- if (result && result.then)
324
- result = await result;
325
- return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !isURL(id) } : _resolve(id, parentUrl);
326
- } : _resolve;
327
-
328
- // importShim('mod');
329
- // importShim('mod', { opts });
330
- // importShim('mod', { opts }, parentUrl);
331
- // importShim('mod', parentUrl);
332
- async function importShim (id, ...args) {
333
- // parentUrl if present will be the last argument
334
- let parentUrl = args[args.length - 1];
335
- if (typeof parentUrl !== 'string')
336
- parentUrl = baseUrl;
337
- // needed for shim check
338
- await initPromise;
339
- if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
340
- if (acceptingImportMaps || shimMode || !baselinePassthrough) {
341
- processImportMaps();
342
- if (!shimMode)
343
- acceptingImportMaps = false;
344
- }
345
- await importMapPromise;
346
- return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' });
347
- }
348
-
349
- self.importShim = importShim;
350
-
351
- function defaultResolve (id, parentUrl) {
352
- return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
353
- }
354
-
355
- function throwUnresolved (id, parentUrl) {
356
- throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
357
- }
358
-
359
- const resolveSync = (id, parentUrl = baseUrl) => {
360
- parentUrl = `${parentUrl}`;
361
- const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
362
- return result && !result.then ? result : defaultResolve(id, parentUrl);
363
- };
364
-
365
- function metaResolve (id, parentUrl = this.url) {
366
- return resolveSync(id, parentUrl);
367
- }
368
-
369
- importShim.resolve = resolveSync;
370
- importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
371
-
372
- const registry = importShim._r = {};
373
-
374
- async function loadAll (load, seen) {
375
- if (load.b || seen[load.u])
376
- return;
377
- seen[load.u] = 1;
378
- await load.L;
379
- await Promise.all(load.d.map(dep => loadAll(dep, seen)));
380
- if (!load.n)
381
- load.n = load.d.some(dep => dep.n);
382
- }
383
-
384
- let importMap = { imports: {}, scopes: {} };
385
- let importMapSrcOrLazy = false;
386
- let baselinePassthrough;
387
-
388
- const initPromise = featureDetectionPromise.then(() => {
389
- // shim mode is determined on initialization, no late shim mode
390
- if (!shimMode) {
391
- if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
392
- setShimMode();
393
- }
394
- else {
395
- let seenScript = false;
396
- for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
397
- if (!seenScript) {
398
- if (script.type === 'module')
399
- seenScript = true;
400
- }
401
- else if (script.type === 'importmap') {
402
- importMapSrcOrLazy = true;
403
- break;
404
- }
405
- }
406
- }
407
- }
408
- baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false;
409
- if (!supportsImportMaps) {
410
- const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
411
- HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
412
- }
413
- if (shimMode || !baselinePassthrough) {
414
- new MutationObserver(mutations => {
415
- for (const mutation of mutations) {
416
- if (mutation.type !== 'childList') continue;
417
- for (const node of mutation.addedNodes) {
418
- if (node.tagName === 'SCRIPT') {
419
- if (node.type === (shimMode ? 'module-shim' : 'module'))
420
- processScript(node);
421
- if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
422
- processImportMap(node);
423
- }
424
- else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload'))
425
- processPreload(node);
426
- }
427
- }
428
- }).observe(document, { childList: true, subtree: true });
429
- processImportMaps();
430
- processScriptsAndPreloads();
431
- if (document.readyState === 'complete') {
432
- readyStateCompleteCheck();
433
- }
434
- else {
435
- async function readyListener () {
436
- await initPromise;
437
- processImportMaps();
438
- if (document.readyState === 'complete') {
439
- readyStateCompleteCheck();
440
- document.removeEventListener('readystatechange', readyListener);
441
- }
442
- }
443
- document.addEventListener('readystatechange', readyListener);
444
- }
445
- return undefined;
446
- }
447
- });
448
- let importMapPromise = initPromise;
449
- let firstPolyfillLoad = true;
450
- let acceptingImportMaps = true;
451
-
452
- async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
453
- if (!shimMode)
454
- acceptingImportMaps = false;
455
- await importMapPromise;
456
- if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
457
- // early analysis opt-out - no need to even fetch if we have feature support
458
- if (!shimMode && baselinePassthrough) {
459
- // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
460
- if (nativelyLoaded)
461
- return null;
462
- await lastStaticLoadPromise;
463
- return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
464
- }
465
- const load = getOrCreateLoad(url, fetchOpts, null, source);
466
- const seen = {};
467
- await loadAll(load, seen);
468
- lastLoad = undefined;
469
- resolveDeps(load, seen);
470
- await lastStaticLoadPromise;
471
- if (source && !shimMode && !load.n && !false) {
472
- const module = await dynamicImport(createBlob(source), { errUrl: source });
473
- if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
474
- return module;
475
- }
476
- if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
477
- onpolyfill();
478
- firstPolyfillLoad = false;
479
- }
480
- const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
481
- // if the top-level load is a shell, run its update function
482
- if (load.s)
483
- (await dynamicImport(load.s)).u$_(module);
484
- if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
485
- // when tla is supported, this should return the tla promise as an actual handle
486
- // so readystate can still correspond to the sync subgraph exec completions
487
- return module;
488
- }
489
-
490
- function revokeObjectURLs(registryKeys) {
491
- let batch = 0;
492
- const keysLength = registryKeys.length;
493
- const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
494
- schedule(cleanup);
495
- function cleanup() {
496
- const batchStartIndex = batch * 100;
497
- if (batchStartIndex > keysLength) return
498
- for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
499
- const load = registry[key];
500
- if (load) URL.revokeObjectURL(load.b);
501
- }
502
- batch++;
503
- schedule(cleanup);
504
- }
505
- }
506
-
507
- function urlJsString (url) {
508
- return `'${url.replace(/'/g, "\\'")}'`;
509
- }
510
-
511
- let lastLoad;
512
- function resolveDeps (load, seen) {
513
- if (load.b || !seen[load.u])
514
- return;
515
- seen[load.u] = 0;
516
-
517
- for (const dep of load.d)
518
- resolveDeps(dep, seen);
519
-
520
- const [imports] = load.a;
521
-
522
- // "execution"
523
- const source = load.S;
524
-
525
- // edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
526
- let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
527
-
528
- if (!imports.length) {
529
- resolvedSource += source;
530
- }
531
- else {
532
- // once all deps have loaded we can inline the dependency resolution blobs
533
- // and define this blob
534
- let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
535
- function pushStringTo (originalIndex) {
536
- while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
537
- const dynamicImportEnd = dynamicImportEndStack.pop();
538
- resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
539
- lastIndex = dynamicImportEnd;
540
- }
541
- resolvedSource += source.slice(lastIndex, originalIndex);
542
- lastIndex = originalIndex;
543
- }
544
- for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
545
- // dependency source replacements
546
- if (dynamicImportIndex === -1) {
547
- let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
548
- if (cycleShell) {
549
- // circular shell creation
550
- if (!(blobUrl = depLoad.s)) {
551
- blobUrl = depLoad.s = createBlob(`export function u$_(m){${
552
- depLoad.a[1].map(
553
- name => name === 'default' ? `d$_=m.default` : `${name}=m.${name}`
554
- ).join(',')
555
- }}${
556
- depLoad.a[1].map(name =>
557
- name === 'default' ? `let d$_;export{d$_ as default}` : `export let ${name}`
558
- ).join(';')
559
- }\n//# sourceURL=${depLoad.r}?cycle`);
560
- }
561
- }
562
-
563
- pushStringTo(start - 1);
564
- resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
565
-
566
- // circular shell execution
567
- if (!cycleShell && depLoad.s) {
568
- resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
569
- depLoad.s = undefined;
570
- }
571
- lastIndex = statementEnd;
572
- }
573
- // import.meta
574
- else if (dynamicImportIndex === -2) {
575
- load.m = { url: load.r, resolve: metaResolve };
576
- metaHook(load.m, load.u);
577
- pushStringTo(start);
578
- resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
579
- lastIndex = statementEnd;
580
- }
581
- // dynamic import
582
- else {
583
- pushStringTo(statementStart + 6);
584
- resolvedSource += `Shim(`;
585
- dynamicImportEndStack.push(statementEnd - 1);
586
- lastIndex = start;
587
- }
588
- }
589
-
590
- pushStringTo(source.length);
591
- }
592
-
593
- let hasSourceURL = false;
594
- resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
595
- if (!hasSourceURL)
596
- resolvedSource += '\n//# sourceURL=' + load.r;
597
-
598
- load.b = lastLoad = createBlob(resolvedSource);
599
- load.S = undefined;
600
- }
601
-
602
- // ; and // trailer support added for Ruby on Rails 7 source maps compatibility
603
- // https://github.com/guybedford/es-module-shims/issues/228
604
- const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
605
-
606
- const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
607
- const jsonContentType = /^(text|application)\/json(;|$)/;
608
- const cssContentType = /^(text|application)\/css(;|$)/;
609
-
610
- const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
611
-
612
- // restrict in-flight fetches to a pool of 100
613
- let p = [];
614
- let c = 0;
615
- function pushFetchPool () {
616
- if (++c > 100)
617
- return new Promise(r => p.push(r));
618
- }
619
- function popFetchPool () {
620
- c--;
621
- if (p.length)
622
- p.shift()();
623
- }
624
-
625
- async function doFetch (url, fetchOpts, parent) {
626
- if (enforceIntegrity && !fetchOpts.integrity)
627
- throw Error(`No integrity for ${url}${fromParent(parent)}.`);
628
- const poolQueue = pushFetchPool();
629
- if (poolQueue) await poolQueue;
630
- try {
631
- var res = await fetchHook(url, fetchOpts);
632
- }
633
- catch (e) {
634
- e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
635
- throw e;
636
- }
637
- finally {
638
- popFetchPool();
639
- }
640
- if (!res.ok)
641
- throw Error(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
642
- return res;
643
- }
644
-
645
- async function fetchModule (url, fetchOpts, parent) {
646
- const res = await doFetch(url, fetchOpts, parent);
647
- const contentType = res.headers.get('content-type');
648
- if (jsContentType.test(contentType))
649
- return { r: res.url, s: await res.text(), t: 'js' };
650
- else if (jsonContentType.test(contentType))
651
- return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
652
- else if (cssContentType.test(contentType)) {
653
- return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
654
- JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
655
- });export default s;`, t: 'css' };
656
- }
657
- else
658
- throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
659
- }
660
-
661
- function getOrCreateLoad (url, fetchOpts, parent, source) {
662
- let load = registry[url];
663
- if (load && !source)
664
- return load;
665
-
666
- load = {
667
- // url
668
- u: url,
669
- // response url
670
- r: source ? url : undefined,
671
- // fetchPromise
672
- f: undefined,
673
- // source
674
- S: undefined,
675
- // linkPromise
676
- L: undefined,
677
- // analysis
678
- a: undefined,
679
- // deps
680
- d: undefined,
681
- // blobUrl
682
- b: undefined,
683
- // shellUrl
684
- s: undefined,
685
- // needsShim
686
- n: false,
687
- // type
688
- t: null,
689
- // meta
690
- m: null
691
- };
692
- if (registry[url]) {
693
- let i = 0;
694
- while (registry[load.u + ++i]);
695
- load.u += i;
696
- }
697
- registry[load.u] = load;
698
-
699
- load.f = (async () => {
700
- if (!source) {
701
- // preload fetch options override fetch options (race)
702
- let t;
703
- ({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
704
- if (t && !shimMode) {
705
- if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
706
- throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
707
- if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
708
- load.n = true;
709
- }
710
- }
711
- try {
712
- load.a = parse(source, load.u);
713
- }
714
- catch (e) {
715
- throwError(e);
716
- load.a = [[], [], false];
717
- }
718
- load.S = source;
719
- return load;
720
- })();
721
-
722
- load.L = load.f.then(async () => {
723
- let childFetchOpts = fetchOpts;
724
- load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
725
- if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
726
- load.n = true;
727
- if (d !== -1 || !n) return;
728
- const { r, b } = await resolve(n, load.r || load.u);
729
- if (b && (!supportsImportMaps || importMapSrcOrLazy))
730
- load.n = true;
731
- if (skip && skip.test(r)) return { b: r };
732
- if (childFetchOpts.integrity)
733
- childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
734
- return getOrCreateLoad(r, childFetchOpts, load.r).f;
735
- }))).filter(l => l);
736
- });
737
-
738
- return load;
739
- }
740
-
741
- function processScriptsAndPreloads () {
742
- for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
743
- processScript(script);
744
- for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
745
- processPreload(link);
746
- }
747
-
748
- function processImportMaps () {
749
- for (const script of document.querySelectorAll(shimMode ? 'script[type="importmap-shim"]' : 'script[type="importmap"]'))
750
- processImportMap(script);
751
- }
752
-
753
- function getFetchOpts (script) {
754
- const fetchOpts = {};
755
- if (script.integrity)
756
- fetchOpts.integrity = script.integrity;
757
- if (script.referrerpolicy)
758
- fetchOpts.referrerPolicy = script.referrerpolicy;
759
- if (script.crossorigin === 'use-credentials')
760
- fetchOpts.credentials = 'include';
761
- else if (script.crossorigin === 'anonymous')
762
- fetchOpts.credentials = 'omit';
763
- else
764
- fetchOpts.credentials = 'same-origin';
765
- return fetchOpts;
766
- }
767
-
768
- let lastStaticLoadPromise = Promise.resolve();
769
-
770
- let domContentLoadedCnt = 1;
771
- function domContentLoadedCheck () {
772
- if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers)
773
- document.dispatchEvent(new Event('DOMContentLoaded'));
774
- }
775
- // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
776
- document.addEventListener('DOMContentLoaded', async () => {
777
- await initPromise;
778
- domContentLoadedCheck();
779
- if (shimMode || !baselinePassthrough) {
780
- processImportMaps();
781
- processScriptsAndPreloads();
782
- }
783
- });
784
-
785
- let readyStateCompleteCnt = 1;
786
- function readyStateCompleteCheck () {
787
- if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
788
- document.dispatchEvent(new Event('readystatechange'));
789
- }
790
-
791
- function processImportMap (script) {
792
- if (script.ep) // ep marker = script processed
793
- return;
794
- // empty inline scripts sometimes show before domready
795
- if (!script.src && !script.innerHTML)
796
- return;
797
- script.ep = true;
798
- // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
799
- if (script.src) {
800
- if (!shimMode)
801
- return;
802
- importMapSrcOrLazy = true;
803
- }
804
- if (acceptingImportMaps) {
805
- importMapPromise = importMapPromise
806
- .then(async () => {
807
- importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
808
- })
809
- .catch(throwError);
810
- if (!shimMode)
811
- acceptingImportMaps = false;
812
- }
813
- }
814
-
815
- function processScript (script) {
816
- if (script.ep) // ep marker = script processed
817
- return;
818
- if (script.getAttribute('noshim') !== null)
819
- return;
820
- // empty inline scripts sometimes show before domready
821
- if (!script.src && !script.innerHTML)
822
- return;
823
- script.ep = true;
824
- // does this load block readystate complete
825
- const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
826
- // does this load block DOMContentLoaded
827
- const isDomContentLoadedScript = domContentLoadedCnt > 0;
828
- if (isBlockingReadyScript) readyStateCompleteCnt++;
829
- if (isDomContentLoadedScript) domContentLoadedCnt++;
830
- const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isBlockingReadyScript && lastStaticLoadPromise).catch(throwError);
831
- if (isBlockingReadyScript)
832
- lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
833
- if (isDomContentLoadedScript)
834
- loadPromise.then(domContentLoadedCheck);
835
- }
836
-
837
- const fetchCache = {};
838
- function processPreload (link) {
839
- if (link.ep) // ep marker = processed
840
- return;
841
- link.ep = true;
842
- if (fetchCache[link.href])
843
- return;
844
- fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
325
+ async function _resolve (id, parentUrl) {
326
+ const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
327
+ return {
328
+ r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl),
329
+ // b = bare specifier
330
+ b: !urlResolved && !isURL(id)
331
+ };
332
+ }
333
+
334
+ const resolve = resolveHook ? async (id, parentUrl) => {
335
+ let result = resolveHook(id, parentUrl, defaultResolve);
336
+ // will be deprecated in next major
337
+ if (result && result.then)
338
+ result = await result;
339
+ return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !isURL(id) } : _resolve(id, parentUrl);
340
+ } : _resolve;
341
+
342
+ // importShim('mod');
343
+ // importShim('mod', { opts });
344
+ // importShim('mod', { opts }, parentUrl);
345
+ // importShim('mod', parentUrl);
346
+ async function importShim (id, ...args) {
347
+ // parentUrl if present will be the last argument
348
+ let parentUrl = args[args.length - 1];
349
+ if (typeof parentUrl !== 'string')
350
+ parentUrl = baseUrl;
351
+ // needed for shim check
352
+ await initPromise;
353
+ if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
354
+ if (acceptingImportMaps || shimMode || !baselinePassthrough) {
355
+ if (hasDocument)
356
+ processImportMaps();
357
+
358
+ if (!shimMode)
359
+ acceptingImportMaps = false;
360
+ }
361
+ await importMapPromise;
362
+ return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' });
363
+ }
364
+
365
+ self.importShim = importShim;
366
+
367
+ function defaultResolve (id, parentUrl) {
368
+ return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
369
+ }
370
+
371
+ function throwUnresolved (id, parentUrl) {
372
+ throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
373
+ }
374
+
375
+ const resolveSync = (id, parentUrl = baseUrl) => {
376
+ parentUrl = `${parentUrl}`;
377
+ const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
378
+ return result && !result.then ? result : defaultResolve(id, parentUrl);
379
+ };
380
+
381
+ function metaResolve (id, parentUrl = this.url) {
382
+ return resolveSync(id, parentUrl);
383
+ }
384
+
385
+ importShim.resolve = resolveSync;
386
+ importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
387
+ importShim.addImportMap = importMapIn => {
388
+ if (!shimMode) throw new Error('Unsupported in polyfill mode.');
389
+ importMap = resolveAndComposeImportMap(importMapIn, baseUrl, importMap);
390
+ };
391
+
392
+ const registry = importShim._r = {};
393
+
394
+ async function loadAll (load, seen) {
395
+ if (load.b || seen[load.u])
396
+ return;
397
+ seen[load.u] = 1;
398
+ await load.L;
399
+ await Promise.all(load.d.map(dep => loadAll(dep, seen)));
400
+ if (!load.n)
401
+ load.n = load.d.some(dep => dep.n);
402
+ }
403
+
404
+ let importMap = { imports: {}, scopes: {} };
405
+ let importMapSrcOrLazy = false;
406
+ let baselinePassthrough;
407
+
408
+ const initPromise = featureDetectionPromise.then(() => {
409
+ // shim mode is determined on initialization, no late shim mode
410
+ if (!shimMode) {
411
+ if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
412
+ setShimMode();
413
+ }
414
+ else {
415
+ let seenScript = false;
416
+ for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
417
+ if (!seenScript) {
418
+ if (script.type === 'module')
419
+ seenScript = true;
420
+ }
421
+ else if (script.type === 'importmap') {
422
+ importMapSrcOrLazy = true;
423
+ break;
424
+ }
425
+ }
426
+ }
427
+ }
428
+ baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false;
429
+ if (hasDocument) {
430
+ if (!supportsImportMaps) {
431
+ const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
432
+ HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
433
+ }
434
+
435
+ if (shimMode || !baselinePassthrough) {
436
+ new MutationObserver(mutations => {
437
+ for (const mutation of mutations) {
438
+ if (mutation.type !== 'childList') continue;
439
+ for (const node of mutation.addedNodes) {
440
+ if (node.tagName === 'SCRIPT') {
441
+ if (node.type === (shimMode ? 'module-shim' : 'module'))
442
+ processScript(node);
443
+ if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
444
+ processImportMap(node);
445
+ }
446
+ else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload'))
447
+ processPreload(node);
448
+ }
449
+ }
450
+ }).observe(document, {childList: true, subtree: true});
451
+ processImportMaps();
452
+ processScriptsAndPreloads();
453
+ if (document.readyState === 'complete') {
454
+ readyStateCompleteCheck();
455
+ }
456
+ else {
457
+ async function readyListener() {
458
+ await initPromise;
459
+ processImportMaps();
460
+ if (document.readyState === 'complete') {
461
+ readyStateCompleteCheck();
462
+ document.removeEventListener('readystatechange', readyListener);
463
+ }
464
+ }
465
+ document.addEventListener('readystatechange', readyListener);
466
+ }
467
+ }
468
+ }
469
+ return undefined;
470
+ });
471
+ let importMapPromise = initPromise;
472
+ let firstPolyfillLoad = true;
473
+ let acceptingImportMaps = true;
474
+
475
+ async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
476
+ if (!shimMode)
477
+ acceptingImportMaps = false;
478
+ await importMapPromise;
479
+ if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
480
+ // early analysis opt-out - no need to even fetch if we have feature support
481
+ if (!shimMode && baselinePassthrough) {
482
+ // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
483
+ if (nativelyLoaded)
484
+ return null;
485
+ await lastStaticLoadPromise;
486
+ return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
487
+ }
488
+ const load = getOrCreateLoad(url, fetchOpts, null, source);
489
+ const seen = {};
490
+ await loadAll(load, seen);
491
+ lastLoad = undefined;
492
+ resolveDeps(load, seen);
493
+ await lastStaticLoadPromise;
494
+ if (source && !shimMode && !load.n && !false) {
495
+ const module = await dynamicImport(createBlob(source), { errUrl: source });
496
+ if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
497
+ return module;
498
+ }
499
+ if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
500
+ onpolyfill();
501
+ firstPolyfillLoad = false;
502
+ }
503
+ const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
504
+ // if the top-level load is a shell, run its update function
505
+ if (load.s)
506
+ (await dynamicImport(load.s)).u$_(module);
507
+ if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
508
+ // when tla is supported, this should return the tla promise as an actual handle
509
+ // so readystate can still correspond to the sync subgraph exec completions
510
+ return module;
511
+ }
512
+
513
+ function revokeObjectURLs(registryKeys) {
514
+ let batch = 0;
515
+ const keysLength = registryKeys.length;
516
+ const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
517
+ schedule(cleanup);
518
+ function cleanup() {
519
+ const batchStartIndex = batch * 100;
520
+ if (batchStartIndex > keysLength) return
521
+ for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
522
+ const load = registry[key];
523
+ if (load) URL.revokeObjectURL(load.b);
524
+ }
525
+ batch++;
526
+ schedule(cleanup);
527
+ }
528
+ }
529
+
530
+ function urlJsString (url) {
531
+ return `'${url.replace(/'/g, "\\'")}'`;
532
+ }
533
+
534
+ let lastLoad;
535
+ function resolveDeps (load, seen) {
536
+ if (load.b || !seen[load.u])
537
+ return;
538
+ seen[load.u] = 0;
539
+
540
+ for (const dep of load.d)
541
+ resolveDeps(dep, seen);
542
+
543
+ const [imports] = load.a;
544
+
545
+ // "execution"
546
+ const source = load.S;
547
+
548
+ // edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
549
+ let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
550
+
551
+ if (!imports.length) {
552
+ resolvedSource += source;
553
+ }
554
+ else {
555
+ // once all deps have loaded we can inline the dependency resolution blobs
556
+ // and define this blob
557
+ let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
558
+ function pushStringTo (originalIndex) {
559
+ while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
560
+ const dynamicImportEnd = dynamicImportEndStack.pop();
561
+ resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
562
+ lastIndex = dynamicImportEnd;
563
+ }
564
+ resolvedSource += source.slice(lastIndex, originalIndex);
565
+ lastIndex = originalIndex;
566
+ }
567
+ for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
568
+ // dependency source replacements
569
+ if (dynamicImportIndex === -1) {
570
+ let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
571
+ if (cycleShell) {
572
+ // circular shell creation
573
+ if (!(blobUrl = depLoad.s)) {
574
+ blobUrl = depLoad.s = createBlob(`export function u$_(m){${
575
+ depLoad.a[1].map(
576
+ name => name === 'default' ? `d$_=m.default` : `${name}=m.${name}`
577
+ ).join(',')
578
+ }}${
579
+ depLoad.a[1].map(name =>
580
+ name === 'default' ? `let d$_;export{d$_ as default}` : `export let ${name}`
581
+ ).join(';')
582
+ }\n//# sourceURL=${depLoad.r}?cycle`);
583
+ }
584
+ }
585
+
586
+ pushStringTo(start - 1);
587
+ resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
588
+
589
+ // circular shell execution
590
+ if (!cycleShell && depLoad.s) {
591
+ resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
592
+ depLoad.s = undefined;
593
+ }
594
+ lastIndex = statementEnd;
595
+ }
596
+ // import.meta
597
+ else if (dynamicImportIndex === -2) {
598
+ load.m = { url: load.r, resolve: metaResolve };
599
+ metaHook(load.m, load.u);
600
+ pushStringTo(start);
601
+ resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
602
+ lastIndex = statementEnd;
603
+ }
604
+ // dynamic import
605
+ else {
606
+ pushStringTo(statementStart + 6);
607
+ resolvedSource += `Shim(`;
608
+ dynamicImportEndStack.push(statementEnd - 1);
609
+ lastIndex = start;
610
+ }
611
+ }
612
+
613
+ pushStringTo(source.length);
614
+ }
615
+
616
+ let hasSourceURL = false;
617
+ resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
618
+ if (!hasSourceURL)
619
+ resolvedSource += '\n//# sourceURL=' + load.r;
620
+
621
+ load.b = lastLoad = createBlob(resolvedSource);
622
+ load.S = undefined;
623
+ }
624
+
625
+ // ; and // trailer support added for Ruby on Rails 7 source maps compatibility
626
+ // https://github.com/guybedford/es-module-shims/issues/228
627
+ const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
628
+
629
+ const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
630
+ const jsonContentType = /^(text|application)\/json(;|$)/;
631
+ const cssContentType = /^(text|application)\/css(;|$)/;
632
+
633
+ const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
634
+
635
+ // restrict in-flight fetches to a pool of 100
636
+ let p = [];
637
+ let c = 0;
638
+ function pushFetchPool () {
639
+ if (++c > 100)
640
+ return new Promise(r => p.push(r));
641
+ }
642
+ function popFetchPool () {
643
+ c--;
644
+ if (p.length)
645
+ p.shift()();
646
+ }
647
+
648
+ async function doFetch (url, fetchOpts, parent) {
649
+ if (enforceIntegrity && !fetchOpts.integrity)
650
+ throw Error(`No integrity for ${url}${fromParent(parent)}.`);
651
+ const poolQueue = pushFetchPool();
652
+ if (poolQueue) await poolQueue;
653
+ try {
654
+ var res = await fetchHook(url, fetchOpts);
655
+ }
656
+ catch (e) {
657
+ e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
658
+ throw e;
659
+ }
660
+ finally {
661
+ popFetchPool();
662
+ }
663
+ if (!res.ok)
664
+ throw Error(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
665
+ return res;
666
+ }
667
+
668
+ async function fetchModule (url, fetchOpts, parent) {
669
+ const res = await doFetch(url, fetchOpts, parent);
670
+ const contentType = res.headers.get('content-type');
671
+ if (jsContentType.test(contentType))
672
+ return { r: res.url, s: await res.text(), t: 'js' };
673
+ else if (jsonContentType.test(contentType))
674
+ return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
675
+ else if (cssContentType.test(contentType)) {
676
+ return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
677
+ JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
678
+ });export default s;`, t: 'css' };
679
+ }
680
+ else
681
+ throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
682
+ }
683
+
684
+ function getOrCreateLoad (url, fetchOpts, parent, source) {
685
+ let load = registry[url];
686
+ if (load && !source)
687
+ return load;
688
+
689
+ load = {
690
+ // url
691
+ u: url,
692
+ // response url
693
+ r: source ? url : undefined,
694
+ // fetchPromise
695
+ f: undefined,
696
+ // source
697
+ S: undefined,
698
+ // linkPromise
699
+ L: undefined,
700
+ // analysis
701
+ a: undefined,
702
+ // deps
703
+ d: undefined,
704
+ // blobUrl
705
+ b: undefined,
706
+ // shellUrl
707
+ s: undefined,
708
+ // needsShim
709
+ n: false,
710
+ // type
711
+ t: null,
712
+ // meta
713
+ m: null
714
+ };
715
+ if (registry[url]) {
716
+ let i = 0;
717
+ while (registry[load.u + ++i]);
718
+ load.u += i;
719
+ }
720
+ registry[load.u] = load;
721
+
722
+ load.f = (async () => {
723
+ if (!source) {
724
+ // preload fetch options override fetch options (race)
725
+ let t;
726
+ ({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
727
+ if (t && !shimMode) {
728
+ if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
729
+ throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
730
+ if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
731
+ load.n = true;
732
+ }
733
+ }
734
+ try {
735
+ load.a = parse(source, load.u);
736
+ }
737
+ catch (e) {
738
+ throwError(e);
739
+ load.a = [[], [], false];
740
+ }
741
+ load.S = source;
742
+ return load;
743
+ })();
744
+
745
+ load.L = load.f.then(async () => {
746
+ let childFetchOpts = fetchOpts;
747
+ load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
748
+ if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
749
+ load.n = true;
750
+ if (d !== -1 || !n) return;
751
+ const { r, b } = await resolve(n, load.r || load.u);
752
+ if (b && (!supportsImportMaps || importMapSrcOrLazy))
753
+ load.n = true;
754
+ if (skip && skip.test(r)) return { b: r };
755
+ if (childFetchOpts.integrity)
756
+ childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
757
+ return getOrCreateLoad(r, childFetchOpts, load.r).f;
758
+ }))).filter(l => l);
759
+ });
760
+
761
+ return load;
762
+ }
763
+
764
+ function processScriptsAndPreloads () {
765
+ for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
766
+ processScript(script);
767
+ for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
768
+ processPreload(link);
769
+ }
770
+
771
+ function processImportMaps () {
772
+ for (const script of document.querySelectorAll(shimMode ? 'script[type="importmap-shim"]' : 'script[type="importmap"]'))
773
+ processImportMap(script);
774
+ }
775
+
776
+ function getFetchOpts (script) {
777
+ const fetchOpts = {};
778
+ if (script.integrity)
779
+ fetchOpts.integrity = script.integrity;
780
+ if (script.referrerpolicy)
781
+ fetchOpts.referrerPolicy = script.referrerpolicy;
782
+ if (script.crossorigin === 'use-credentials')
783
+ fetchOpts.credentials = 'include';
784
+ else if (script.crossorigin === 'anonymous')
785
+ fetchOpts.credentials = 'omit';
786
+ else
787
+ fetchOpts.credentials = 'same-origin';
788
+ return fetchOpts;
789
+ }
790
+
791
+ let lastStaticLoadPromise = Promise.resolve();
792
+
793
+ let domContentLoadedCnt = 1;
794
+ function domContentLoadedCheck () {
795
+ if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers)
796
+ document.dispatchEvent(new Event('DOMContentLoaded'));
797
+ }
798
+ // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
799
+ if (hasDocument) {
800
+ document.addEventListener('DOMContentLoaded', async () => {
801
+ await initPromise;
802
+ domContentLoadedCheck();
803
+ if (shimMode || !baselinePassthrough) {
804
+ processImportMaps();
805
+ processScriptsAndPreloads();
806
+ }
807
+ });
808
+ }
809
+
810
+ let readyStateCompleteCnt = 1;
811
+ function readyStateCompleteCheck () {
812
+ if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
813
+ document.dispatchEvent(new Event('readystatechange'));
814
+ }
815
+
816
+ function processImportMap (script) {
817
+ if (script.ep) // ep marker = script processed
818
+ return;
819
+ // empty inline scripts sometimes show before domready
820
+ if (!script.src && !script.innerHTML)
821
+ return;
822
+ script.ep = true;
823
+ // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
824
+ if (script.src) {
825
+ if (!shimMode)
826
+ return;
827
+ importMapSrcOrLazy = true;
828
+ }
829
+ if (acceptingImportMaps) {
830
+ importMapPromise = importMapPromise
831
+ .then(async () => {
832
+ importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
833
+ })
834
+ .catch(throwError);
835
+ if (!shimMode)
836
+ acceptingImportMaps = false;
837
+ }
838
+ }
839
+
840
+ function processScript (script) {
841
+ if (script.ep) // ep marker = script processed
842
+ return;
843
+ if (script.getAttribute('noshim') !== null)
844
+ return;
845
+ // empty inline scripts sometimes show before domready
846
+ if (!script.src && !script.innerHTML)
847
+ return;
848
+ script.ep = true;
849
+ // does this load block readystate complete
850
+ const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
851
+ // does this load block DOMContentLoaded
852
+ const isDomContentLoadedScript = domContentLoadedCnt > 0;
853
+ if (isBlockingReadyScript) readyStateCompleteCnt++;
854
+ if (isDomContentLoadedScript) domContentLoadedCnt++;
855
+ const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isBlockingReadyScript && lastStaticLoadPromise).catch(throwError);
856
+ if (isBlockingReadyScript)
857
+ lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
858
+ if (isDomContentLoadedScript)
859
+ loadPromise.then(domContentLoadedCheck);
860
+ }
861
+
862
+ const fetchCache = {};
863
+ function processPreload (link) {
864
+ if (link.ep) // ep marker = processed
865
+ return;
866
+ link.ep = true;
867
+ if (fetchCache[link.href])
868
+ return;
869
+ fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
845
870
  }
846
871
 
847
872
  })();