importmap-rails 0.7.5 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +79 -20
- data/app/assets/javascripts/es-module-shims.js +67 -57
- data/app/assets/javascripts/es-module-shims.min.js +1 -0
- data/app/helpers/importmap/importmap_tags_helper.rb +3 -3
- data/lib/importmap/commands.rb +23 -7
- data/lib/importmap/engine.rb +12 -2
- data/lib/importmap/map.rb +13 -5
- data/lib/importmap/packager.rb +84 -9
- data/lib/importmap/version.rb +1 -1
- data/lib/install/config/importmap.rb +2 -5
- data/lib/install/install.rb +6 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 176d828b6f6ec7ca4699eac705589d6bcc9f2803869c1306af59e4fe7af4cb9e
|
4
|
+
data.tar.gz: 4c134d49d6b55ae72a9d4400d04cbb83c821d4725f51f330cdd5eab0c1e2fd2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cb81efd8cf84fc38ed74902df4dfd3af0be117681cae3d257fcd33ac0a4c2c8a2aa48e3554d14c2116480c281814f0d04c58281970e3b51578d4e83e8226b6d
|
7
|
+
data.tar.gz: 17412608ef53d81037e8fadac329e3d068eb3afebfd727f5f5af8afb5353d6ed842f277ab8726707619b4c2825766d188be950624bfe6306e816b6ac25ff8b24
|
data/README.md
CHANGED
@@ -17,6 +17,42 @@ Importmap for Rails is automatically included in Rails 7+ for new applications,
|
|
17
17
|
|
18
18
|
Note: In order to use JavaScript from Rails frameworks like Action Cable, Action Text, and Active Storage, you must be running Rails 7.0+. This was the first version that shipped with ESM compatible builds of these libraries.
|
19
19
|
|
20
|
+
## How do importmaps work?
|
21
|
+
|
22
|
+
At their core, importmaps are essentially a string substitution for what are referred to as "bare module specifiers". A "bare module specifier" looks like this: `import React from "react"`. This is not compatible with the ES Module loader spec. Instead, to be ESM compatible, you must provide 1 of the 3 following types of specifiers:
|
23
|
+
|
24
|
+
- Absolute path:
|
25
|
+
```js
|
26
|
+
import React from "/Users/DHH/projects/basecamp/node_modules/react"
|
27
|
+
```
|
28
|
+
|
29
|
+
- Relative path:
|
30
|
+
```js
|
31
|
+
import React from "./node_modules/react"
|
32
|
+
```
|
33
|
+
|
34
|
+
- HTTP path:
|
35
|
+
```js
|
36
|
+
import React from "https://ga.jspm.io/npm:react@17.0.1/index.js"
|
37
|
+
```
|
38
|
+
|
39
|
+
Importmap-rails provides a clean API for mapping "bare module specifiers" like `"react"`
|
40
|
+
to 1 of the 3 viable ways of loading ES Module javascript packages.
|
41
|
+
|
42
|
+
For example:
|
43
|
+
|
44
|
+
```rb
|
45
|
+
# config/importmaps.rb
|
46
|
+
pin "react" to "https://ga.jspm.io/npm:react@17.0.2/index.js"
|
47
|
+
```
|
48
|
+
|
49
|
+
means "everytime you see `import React from "react"`
|
50
|
+
change it to `import React from "https://ga.jspm.io/npm:react@17.0.2/index.js"`"
|
51
|
+
|
52
|
+
```js
|
53
|
+
import React from "react"
|
54
|
+
// => import React from "https://ga.jspm.io/npm:react@17.0.2/index.js"
|
55
|
+
```
|
20
56
|
|
21
57
|
## Usage
|
22
58
|
|
@@ -29,11 +65,11 @@ It's in `app/javascript/application.js` you setup your application by importing
|
|
29
65
|
It makes sense to use logical names that match the package names used by npm, such that if you later want to start transpiling or bundling your code, you won't have to change any module imports.
|
30
66
|
|
31
67
|
|
32
|
-
## Using
|
68
|
+
## Using npm packages via JavaScript CDNs
|
33
69
|
|
34
|
-
Importmap for Rails is designed to be used with JavaScript CDNs for your
|
70
|
+
Importmap for Rails is designed to be used with JavaScript CDNs for your npm package dependencies. The CDNs provide pre-compiled distribution versions ready to use, and offer a fast, efficient way of serving them.
|
35
71
|
|
36
|
-
You can use the `./bin/importmap` command that's added as part of the install to pin, unpin, or update
|
72
|
+
You can use the `./bin/importmap` command that's added as part of the install to pin, unpin, or update npm packages in your import map. This command uses an API from [JSPM.org](https://jspm.org) to resolve your package dependencies efficiently, and then add the pins to your `config/importmap.rb` file. It can resolve these dependencies from JSPM itself, but also from other CDNs, like [unpkg.com](https://unpkg.com) and [jsdelivr.com](https://www.jsdelivr.com).
|
37
73
|
|
38
74
|
It works like so:
|
39
75
|
|
@@ -110,28 +146,46 @@ pin "react", to: "https://cdn.skypack.dev/react"
|
|
110
146
|
```
|
111
147
|
|
112
148
|
|
113
|
-
##
|
149
|
+
## Downloading vendor files from the JavaScript CDN
|
114
150
|
|
115
|
-
|
151
|
+
If you don't want to use a JavaScript CDN in production, you can also download vendored files from the CDN when you're setting up your pins:
|
152
|
+
|
153
|
+
```bash
|
154
|
+
./bin/importmap pin react --download
|
155
|
+
Pinning "react" to vendor/react.js via download from https://ga.jspm.io/npm:react@17.0.2/index.js
|
156
|
+
Pinning "object-assign" to vendor/object-assign.js via download from https://ga.jspm.io/npm:object-assign@4.1.1/index.js
|
157
|
+
```
|
158
|
+
|
159
|
+
This will produce pins in your `config/importmap.rb` like so:
|
116
160
|
|
117
161
|
```ruby
|
118
|
-
#
|
119
|
-
pin "
|
162
|
+
pin "react" # https://ga.jspm.io/npm:react@17.0.2/index.js
|
163
|
+
pin "object-assign" # https://ga.jspm.io/npm:object-assign@4.1.1/index.js
|
164
|
+
```
|
165
|
+
|
166
|
+
The packages are downloaded to `vendor/javascript`, which you can check into your source control, and they'll be available through your application's own asset pipeline serving.
|
167
|
+
|
168
|
+
If you later wish to remove a downloaded pin, you again pass `--download`:
|
169
|
+
|
170
|
+
```bash
|
171
|
+
./bin/importmap unpin react --download
|
172
|
+
Unpinning and removing "react"
|
173
|
+
Unpinning and removing "object-assign"
|
120
174
|
```
|
121
175
|
|
122
|
-
|
176
|
+
Just like with a normal pin, you can also update a pin by running the `pin --download` command again.
|
123
177
|
|
124
178
|
|
125
179
|
## Preloading pinned modules
|
126
180
|
|
127
|
-
To avoid the waterfall effect where the browser has to load one file after another before it can get to the deepest nested import,
|
181
|
+
To avoid the waterfall effect where the browser has to load one file after another before it can get to the deepest nested import, importmap-rails supports [modulepreload links](https://developers.google.com/web/updates/2017/12/modulepreload). Pinned modules can be preloaded by appending `preload: true` to the pin.
|
128
182
|
|
129
183
|
Example:
|
130
184
|
|
131
185
|
```ruby
|
132
186
|
# config/importmap.rb
|
133
|
-
pin "@github/hotkey", to: "https://ga.jspm.io/npm:@github/hotkey@1.4.4/dist/index.js"
|
134
|
-
pin "md5", to: "https://cdn.jsdelivr.net/npm/md5@2.3.0/md5.js"
|
187
|
+
pin "@github/hotkey", to: "https://ga.jspm.io/npm:@github/hotkey@1.4.4/dist/index.js", preload: true
|
188
|
+
pin "md5", to: "https://cdn.jsdelivr.net/npm/md5@2.3.0/md5.js"
|
135
189
|
|
136
190
|
# app/views/layouts/application.html.erb
|
137
191
|
<%= javascript_importmap_tags %>
|
@@ -153,8 +207,8 @@ You can combine multiple import maps by drawing their definitions onto the `Rail
|
|
153
207
|
module MyEngine
|
154
208
|
class Engine < ::Rails::Engine
|
155
209
|
# ...
|
156
|
-
initializer "my-engine.importmap" do |app|
|
157
|
-
app.
|
210
|
+
initializer "my-engine.importmap", after: "importmap" do |app|
|
211
|
+
app.importmap.draw(Engine.root.join("config/importmap.rb"))
|
158
212
|
end
|
159
213
|
end
|
160
214
|
end
|
@@ -182,24 +236,29 @@ end
|
|
182
236
|
|
183
237
|
## Sweeping the cache in development and test
|
184
238
|
|
185
|
-
Generating the import map json and modulepreloads may require resolving hundreds of assets. This can take a while, so these operations are cached, but in development and test, we watch for changes to both `config/importmap.rb` and files in `app/javascript` to clear this cache. This feature can be controlled in an environment configuration file via the boolean `config.importmap.sweep_cache`.
|
239
|
+
Generating the import map json and modulepreloads may require resolving hundreds of assets. This can take a while, so these operations are cached, but in development and test, we watch for changes to both `config/importmap.rb` and files in `app/javascript` to clear this cache. This feature can be controlled in an environment configuration file via the boolean `config.importmap.sweep_cache`.
|
240
|
+
|
241
|
+
If you're pinning local files from outside of `app/javascript`, you'll need to add them to the cache sweeper configuration or restart your development server upon changes to those external files. To add them to the configuration to clear the cache on changes, for instance when locally developing an engine, use an initializer like the following sample `config/initializers/importmap-caching.rb`:
|
186
242
|
|
243
|
+
```ruby
|
244
|
+
if Rails.env.development?
|
245
|
+
Rails.application.importmap.cache_sweeper watches: [
|
246
|
+
Rails.application.root.join("app/javascript"),
|
247
|
+
MyEngine::Engine.root.join("app/assets/javascripts"),
|
248
|
+
]
|
249
|
+
end
|
250
|
+
```
|
187
251
|
|
188
252
|
## Expected errors from using the es-module-shim
|
189
253
|
|
190
254
|
While import maps are native in Chrome and Edge, they need a shim in other browsers that'll produce a JavaScript console error like `TypeError: Module specifier, 'application' does not start with "/", "./", or "../".`. This error is normal and does not have any user-facing consequences.
|
191
255
|
|
256
|
+
In Firefox. when opening the browser console, the asm.js module lexer build will run in unoptimized mode due to the debugger attaching. This gives a warning message `"asm.js type error: Disabled because no suitable wasm compiler is available"` which is as expected. When the console is closed again, the asm.js optimizations are fully applied, and this can even be verified with the console open by disabling the debugger in `about:config` and reloading the page.
|
192
257
|
|
193
258
|
## Turning off the shim
|
194
259
|
|
195
260
|
Under certain circumstances, like running system tests using chromedriver under CI (which may be resource constrained and trigger errors in certain cases), you may want to explicitly turn off including the shim. You can do this by calling the bulk tag helper with `javascript_importmap_tags("application", shim: false)`. Thus you can pass in something like `shim: !ENV["CI"]`. If you want, and are sure you're not doing any full-page caching, you can also connect this directive to a user agent check (using a gem like `useragent`) to check whether the browser is chrome/edge 89+. But you really shouldn't have to, as the shim is designed to gracefully work with natively compatible drivers.
|
196
261
|
|
197
|
-
|
198
|
-
## A note about browser extensions
|
199
|
-
|
200
|
-
Certain extensions that also load JavaScript modules may block import maps from being loaded (for instance, the Apollo Client Devtools extension). If you see a console message like `An import map is added after module script load was triggered`, browser extensions are likely the culprit.
|
201
|
-
|
202
|
-
|
203
262
|
## License
|
204
263
|
|
205
264
|
Importmap for Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* ES Module Shims 1.0
|
1
|
+
/* ES Module Shims 1.3.0 */
|
2
2
|
(function () {
|
3
3
|
|
4
4
|
const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
|
@@ -129,6 +129,9 @@
|
|
129
129
|
function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
|
130
130
|
for (let p in packages) {
|
131
131
|
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
132
|
+
if (outPackages[resolvedLhs]) {
|
133
|
+
throw new Error(`Dynamic import map rejected: Overrides entry "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
|
134
|
+
}
|
132
135
|
let target = packages[p];
|
133
136
|
if (typeof target !== 'string')
|
134
137
|
continue;
|
@@ -199,7 +202,7 @@
|
|
199
202
|
const esmsInitOptions$1 = optionsScript ? JSON.parse(optionsScript.innerHTML) : self.esmsInitOptions ? self.esmsInitOptions : {};
|
200
203
|
|
201
204
|
let shimMode = !!esmsInitOptions$1.shimMode;
|
202
|
-
const resolveHook = shimMode && esmsInitOptions$1.resolve;
|
205
|
+
const resolveHook = globalHook(shimMode && esmsInitOptions$1.resolve);
|
203
206
|
|
204
207
|
const skip = esmsInitOptions$1.skip ? new RegExp(esmsInitOptions$1.skip) : null;
|
205
208
|
|
@@ -211,12 +214,16 @@
|
|
211
214
|
nonce = nonceElement.getAttribute('nonce');
|
212
215
|
}
|
213
216
|
|
214
|
-
const
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
217
|
+
const onerror = globalHook(esmsInitOptions$1.onerror || noop);
|
218
|
+
const onpolyfill = globalHook(esmsInitOptions$1.onpolyfill || noop);
|
219
|
+
|
220
|
+
const { revokeBlobURLs, noLoadEventRetriggers } = esmsInitOptions$1;
|
221
|
+
|
222
|
+
const fetchHook = esmsInitOptions$1.fetch ? globalHook(esmsInitOptions$1.fetch) : fetch;
|
223
|
+
|
224
|
+
function globalHook (name) {
|
225
|
+
return typeof name === 'string' ? self[name] : name;
|
226
|
+
}
|
220
227
|
|
221
228
|
const enable = Array.isArray(esmsInitOptions$1.polyfillEnable) ? esmsInitOptions$1.polyfillEnable : [];
|
222
229
|
const cssModulesEnabled = enable.includes('css-modules');
|
@@ -239,14 +246,14 @@
|
|
239
246
|
s.addEventListener('error', cb);
|
240
247
|
s.addEventListener('load', cb);
|
241
248
|
|
242
|
-
function cb () {
|
249
|
+
function cb (_err) {
|
243
250
|
document.head.removeChild(s);
|
244
251
|
if (self._esmsi) {
|
245
252
|
resolve(self._esmsi, baseUrl);
|
246
253
|
self._esmsi = undefined;
|
247
254
|
}
|
248
255
|
else {
|
249
|
-
reject(err.error || new Error(`Error loading or executing the graph of ${errUrl} (check the console for ${src}).`));
|
256
|
+
reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading or executing the graph of ${errUrl} (check the console for ${src}).`));
|
250
257
|
err = undefined;
|
251
258
|
}
|
252
259
|
}
|
@@ -283,21 +290,21 @@
|
|
283
290
|
jsonModulesEnabled && dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, noop),
|
284
291
|
new Promise(resolve => {
|
285
292
|
self._$s = v => {
|
286
|
-
document.
|
293
|
+
document.head.removeChild(iframe);
|
287
294
|
if (v) supportsImportMaps = true;
|
288
295
|
delete self._$s;
|
289
296
|
resolve();
|
290
297
|
};
|
291
298
|
const iframe = document.createElement('iframe');
|
292
299
|
iframe.style.display = 'none';
|
293
|
-
document.
|
300
|
+
document.head.appendChild(iframe);
|
294
301
|
// we use document.write here because eg Weixin built-in browser doesn't support setting srcdoc
|
295
302
|
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>`);
|
296
303
|
})
|
297
304
|
]);
|
298
305
|
});
|
299
306
|
|
300
|
-
let e,r;const a=1===new Uint8Array(new Uint16Array([1]).buffer)[0];let s,i;function parse(i,f="@"){s=i,e||(r=new ArrayBuffer(16777216),e=function(e,r,a){"use asm";var s=new e.Int8Array(a),i=new e.Int16Array(a),t=new e.Int32Array(a),c=new e.Uint8Array(a),n=new e.Uint16Array(a),f=816;function u(e){e=e|0;var r=0,a=0,c=0,u=0,l=0;l=f;f=f+14336|0;u=l;s[589]=1;i[291]=0;i[292]=0;i[293]=-1;t[15]=t[2];s[590]=0;t[14]=0;s[588]=0;t[16]=l+10240;t[17]=l+2048;s[591]=0;e=(t[3]|0)+-2|0;t[18]=e;r=e+(t[12]<<1)|0;t[19]=r;e:while(1){a=e+2|0;t[18]=a;if(e>>>0>=r>>>0){c=18;break}r:do{switch(i[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((i[292]|0)==0?T(a)|0:0)?j(e+4|0,120,112,111,114,116)|0:0)?(k(),(s[589]|0)==0):0){c=9;break e}else c=17;break}case 105:{if(T(a)|0?j(e+4|0,109,112,111,114,116)|0:0){b();c=17;}else c=17;break}case 59:{c=17;break}case 47:switch(i[e+4>>1]|0){case 47:{G();break r}case 42:{p(1);break r}default:{c=16;break e}}default:{c=16;break e}}}while(0);if((c|0)==17){c=0;t[15]=t[18];}e=t[18]|0;r=t[19]|0;}if((c|0)==9){e=t[18]|0;t[15]=e;c=19;}else if((c|0)==16){s[589]=0;t[18]=e;c=19;}else if((c|0)==18)if(!(s[588]|0)){e=a;c=19;}else e=0;do{if((c|0)==19){e:while(1){r=e+2|0;t[18]=r;a=r;if(e>>>0>=(t[19]|0)>>>0){c=75;break}r:do{switch(i[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((i[292]|0)==0?T(r)|0:0)?j(e+4|0,120,112,111,114,116)|0:0){k();c=74;}else c=74;break}case 105:{if(T(r)|0?j(e+4|0,109,112,111,114,116)|0:0){b();c=74;}else c=74;break}case 99:{if((T(r)|0?z(e+4|0,108,97,115,115)|0:0)?_(i[e+12>>1]|0)|0:0){s[591]=1;c=74;}else c=74;break}case 40:{r=t[15]|0;a=t[17]|0;c=i[292]|0;i[292]=c+1<<16>>16;t[a+((c&65535)<<2)>>2]=r;c=74;break}case 41:{e=i[292]|0;if(!(e<<16>>16)){c=36;break e}c=e+-1<<16>>16;i[292]=c;e=t[11]|0;if((e|0)!=0?(t[e+20>>2]|0)==(t[(t[17]|0)+((c&65535)<<2)>>2]|0):0){r=e+4|0;if(!(t[r>>2]|0))t[r>>2]=a;t[e+12>>2]=a;t[11]=0;c=74;}else c=74;break}case 123:{c=t[15]|0;a=t[8]|0;e=c;do{if((i[c>>1]|0)==41&(a|0)!=0?(t[a+4>>2]|0)==(c|0):0){r=t[9]|0;t[8]=r;if(!r){t[4]=0;break}else {t[r+28>>2]=0;break}}}while(0);r=i[292]|0;c=r&65535;s[u+c>>0]=s[591]|0;s[591]=0;a=t[17]|0;i[292]=r+1<<16>>16;t[a+(c<<2)>>2]=e;c=74;break}case 125:{e=i[292]|0;if(!(e<<16>>16)){c=49;break e}a=e+-1<<16>>16;i[292]=a;r=i[293]|0;if(e<<16>>16!=r<<16>>16)if(r<<16>>16!=-1&(a&65535)<(r&65535)){c=53;break e}else {c=74;break r}else {a=t[16]|0;c=(i[291]|0)+-1<<16>>16;i[291]=c;i[293]=i[a+((c&65535)<<1)>>1]|0;h();c=74;break r}}case 39:{d();c=74;break}case 34:{v();c=74;break}case 47:switch(i[e+4>>1]|0){case 47:{G();break r}case 42:{p(1);break r}default:{r=t[15]|0;a=i[r>>1]|0;a:do{if(!(E(a)|0)){switch(a<<16>>16){case 41:if(L(t[(t[17]|0)+(n[292]<<2)>>2]|0)|0){c=71;break a}else {c=68;break a}case 125:break;default:{c=68;break a}}e=n[292]|0;if(!(g(t[(t[17]|0)+(e<<2)>>2]|0)|0)?(s[u+e>>0]|0)==0:0)c=68;else c=71;}else switch(a<<16>>16){case 46:if(((i[r+-2>>1]|0)+-48&65535)<10){c=68;break a}else {c=71;break a}case 43:if((i[r+-2>>1]|0)==43){c=68;break a}else {c=71;break a}case 45:if((i[r+-2>>1]|0)==45){c=68;break a}else {c=71;break a}default:{c=71;break a}}}while(0);a:do{if((c|0)==68){c=0;if(!(o(r)|0)){switch(a<<16>>16){case 0:{c=71;break a}case 47:break;default:{e=1;break a}}if(!(s[590]|0))e=1;else c=71;}else c=71;}}while(0);if((c|0)==71){I();e=0;}s[590]=e;c=74;break r}}case 96:{h();c=74;break}default:c=74;}}while(0);if((c|0)==74){c=0;t[15]=t[18];}e=t[18]|0;}if((c|0)==36){Z();e=0;break}else if((c|0)==49){Z();e=0;break}else if((c|0)==53){Z();e=0;break}else if((c|0)==75){e=(i[293]|0)==-1&(i[292]|0)==0&(s[588]|0)==0;break}}}while(0);f=l;return e|0}function k(){var e=0,r=0,a=0,c=0,n=0,f=0;n=t[18]|0;f=n+12|0;t[18]=f;r=w(1)|0;e=t[18]|0;if(!((e|0)==(f|0)?!(U(r)|0):0))c=3;e:do{if((c|0)==3){r:do{switch(r<<16>>16){case 100:{J(e,e+14|0);break e}case 97:{t[18]=e+10;w(1)|0;e=t[18]|0;c=6;break}case 102:{c=6;break}case 99:{if(z(e+2|0,108,97,115,115)|0?(a=e+10|0,F(i[a>>1]|0)|0):0){t[18]=a;n=w(1)|0;f=t[18]|0;H(n)|0;J(f,t[18]|0);t[18]=(t[18]|0)+-2;break e}e=e+4|0;t[18]=e;c=13;break}case 108:case 118:{c=13;break}case 123:{t[18]=e+2;e=w(1)|0;a=t[18]|0;while(1){H(e)|0;e=t[18]|0;w(1)|0;e=$(a,e)|0;if(e<<16>>16==44){t[18]=(t[18]|0)+2;e=w(1)|0;}r=a;a=t[18]|0;if(e<<16>>16==125){c=29;break}if((a|0)==(r|0)){c=26;break}if(a>>>0>(t[19]|0)>>>0){c=28;break}}if((c|0)==26){Z();break e}else if((c|0)==28){Z();break e}else if((c|0)==29){t[18]=a+2;c=31;break r}break}case 42:{t[18]=e+2;w(1)|0;c=t[18]|0;$(c,c)|0;c=31;break}default:{}}}while(0);if((c|0)==6){t[18]=e+16;e=w(1)|0;if(e<<16>>16==42){t[18]=(t[18]|0)+2;e=w(1)|0;}f=t[18]|0;H(e)|0;J(f,t[18]|0);t[18]=(t[18]|0)+-2;break}else if((c|0)==13){e=e+4|0;t[18]=e;s[589]=0;r:while(1){t[18]=e+2;f=w(1)|0;e=t[18]|0;switch((H(f)|0)<<16>>16){case 91:case 123:{c=15;break r}default:{}}r=t[18]|0;if((r|0)==(e|0))break e;J(e,r);switch((w(1)|0)<<16>>16){case 61:{c=19;break r}case 44:break;default:{c=20;break r}}e=t[18]|0;}if((c|0)==15){t[18]=(t[18]|0)+-2;break}else if((c|0)==19){t[18]=(t[18]|0)+-2;break}else if((c|0)==20){t[18]=(t[18]|0)+-2;break}}else if((c|0)==31)r=w(1)|0;e=t[18]|0;if(r<<16>>16==102?K(e+2|0,114,111,109)|0:0){t[18]=e+8;l(n,w(1)|0);break}t[18]=e+-2;}}while(0);return}function b(){var e=0,r=0,a=0,c=0,n=0;n=t[18]|0;r=n+12|0;t[18]=r;e:do{switch((w(1)|0)<<16>>16){case 40:{r=t[17]|0;a=i[292]|0;i[292]=a+1<<16>>16;t[r+((a&65535)<<2)>>2]=n;if((i[t[15]>>1]|0)!=46){A(n,(t[18]|0)+2|0,0,n);t[11]=t[8];t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d();break}case 34:{v();break}default:{t[18]=(t[18]|0)+-2;break e}}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 44:{n=t[18]|0;t[(t[8]|0)+4>>2]=n;t[18]=n+2;w(1)|0;n=t[18]|0;a=t[8]|0;t[a+16>>2]=n;s[a+24>>0]=1;t[18]=n+-2;break e}case 41:{i[292]=(i[292]|0)+-1<<16>>16;a=t[18]|0;n=t[8]|0;t[n+4>>2]=a;t[n+12>>2]=a;s[n+24>>0]=1;break e}default:{t[18]=(t[18]|0)+-2;break e}}}break}case 46:{t[18]=(t[18]|0)+2;if(((w(1)|0)<<16>>16==109?(e=t[18]|0,K(e+2|0,101,116,97)|0):0)?(i[t[15]>>1]|0)!=46:0)A(n,n,e+8|0,2);break}case 42:case 123:case 39:case 34:{c=16;break}default:if((t[18]|0)!=(r|0))c=16;}}while(0);do{if((c|0)==16){if(i[292]|0){t[18]=(t[18]|0)+-2;break}e=t[19]|0;r=t[18]|0;e:while(1){if(r>>>0>=e>>>0){c=23;break}a=i[r>>1]|0;switch(a<<16>>16){case 34:case 39:{c=21;break e}default:{}}c=r+2|0;t[18]=c;r=c;}if((c|0)==21){l(n,a);break}else if((c|0)==23){Z();break}}}while(0);return}function l(e,r){e=e|0;r=r|0;var a=0,s=0;a=(t[18]|0)+2|0;switch(r<<16>>16){case 39:{d();s=5;break}case 34:{v();s=5;break}default:Z();}do{if((s|0)==5){A(e,a,t[18]|0,1);t[18]=(t[18]|0)+2;s=(w(0)|0)<<16>>16==97;r=t[18]|0;if(s?j(r+2|0,115,115,101,114,116)|0:0){t[18]=r+12;if((w(1)|0)<<16>>16!=123){t[18]=r;break}e=t[18]|0;a=e;e:while(1){t[18]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{d();t[18]=(t[18]|0)+2;a=w(1)|0;break}case 34:{v();t[18]=(t[18]|0)+2;a=w(1)|0;break}default:a=H(a)|0;}if(a<<16>>16!=58){s=16;break}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d();break}case 34:{v();break}default:{s=20;break e}}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 125:{s=25;break e}case 44:break;default:{s=24;break e}}t[18]=(t[18]|0)+2;if((w(1)|0)<<16>>16==125){s=25;break}a=t[18]|0;}if((s|0)==16){t[18]=r;break}else if((s|0)==20){t[18]=r;break}else if((s|0)==24){t[18]=r;break}else if((s|0)==25){s=t[8]|0;t[s+16>>2]=e;t[s+12>>2]=(t[18]|0)+2;break}}t[18]=r+-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=q(e+-4|0,118,111)|0;break e}case 108:{e=P(e+-4|0,121,105,101)|0;break e}default:{e=0;break e}}case 101:{switch(i[e+-2>>1]|0){case 115:break;case 116:{e=B(e+-4|0,100,101,108,101)|0;break e}default:{e=0;break e}}switch(i[e+-4>>1]|0){case 108:{e=D(e+-6|0,101)|0;break e}case 97:{e=D(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=m(e+-8|0,105,110,115,116,97,110)|0;break e}case 112:{e=q(e+-8|0,116,121)|0;break e}default:{e=0;break e}}else e=0;break}case 110:{e=e+-2|0;if(D(e,105)|0)e=1;else e=O(e,114,101,116,117,114)|0;break}case 111:{e=D(e+-2|0,100)|0;break}case 114:{e=S(e+-2|0,100,101,98,117,103,103,101)|0;break}case 116:{e=B(e+-2|0,97,119,97,105)|0;break}case 119:switch(i[e+-2>>1]|0){case 101:{e=D(e+-4|0,110)|0;break e}case 111:{e=P(e+-4|0,116,104,114)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function h(){var e=0,r=0,a=0;r=t[19]|0;a=t[18]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){r=8;break}switch(i[e>>1]|0){case 96:{r=9;break e}case 36:{if((i[a+4>>1]|0)==123){r=6;break e}break}case 92:{e=a+4|0;break}default:{}}a=e;}if((r|0)==6){t[18]=a+4;e=i[293]|0;r=t[16]|0;a=i[291]|0;i[291]=a+1<<16>>16;i[r+((a&65535)<<1)>>1]=e;a=(i[292]|0)+1<<16>>16;i[292]=a;i[293]=a;}else if((r|0)==8){t[18]=e;Z();}else if((r|0)==9)t[18]=e;return}function w(e){e=e|0;var r=0,a=0,s=0;a=t[18]|0;e:do{r=i[a>>1]|0;r:do{if(r<<16>>16!=47)if(e)if(_(r)|0)break;else break e;else if(Q(r)|0)break;else break e;else switch(i[a+2>>1]|0){case 47:{G();break r}case 42:{p(e);break r}default:{r=47;break e}}}while(0);s=t[18]|0;a=s+2|0;t[18]=a;}while(s>>>0<(t[19]|0)>>>0);return r|0}function d(){var e=0,r=0,a=0,s=0;s=t[19]|0;e=t[18]|0;e:while(1){a=e+2|0;if(e>>>0>=s>>>0){e=8;break}r=i[a>>1]|0;switch(r<<16>>16){case 39:{e=9;break e}case 92:{r=e+4|0;if((i[r>>1]|0)==13){e=e+6|0;e=(i[e>>1]|0)==10?e:r;}else e=r;break}default:if(ae(r)|0){e=8;break e}else e=a;}}if((e|0)==8){t[18]=a;Z();}else if((e|0)==9)t[18]=a;return}function v(){var e=0,r=0,a=0,s=0;s=t[19]|0;e=t[18]|0;e:while(1){a=e+2|0;if(e>>>0>=s>>>0){e=8;break}r=i[a>>1]|0;switch(r<<16>>16){case 34:{e=9;break e}case 92:{r=e+4|0;if((i[r>>1]|0)==13){e=e+6|0;e=(i[e>>1]|0)==10?e:r;}else e=r;break}default:if(ae(r)|0){e=8;break e}else e=a;}}if((e|0)==8){t[18]=a;Z();}else if((e|0)==9)t[18]=a;return}function A(e,r,a,i){e=e|0;r=r|0;a=a|0;i=i|0;var c=0,n=0;c=t[13]|0;t[13]=c+32;n=t[8]|0;t[((n|0)==0?16:n+28|0)>>2]=c;t[9]=n;t[8]=c;t[c+8>>2]=e;do{if(2!=(i|0))if(1==(i|0)){t[c+12>>2]=a+2;break}else {t[c+12>>2]=t[3];break}else t[c+12>>2]=a;}while(0);t[c>>2]=r;t[c+4>>2]=a;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 y(){var e=0,r=0,a=0;a=t[19]|0;r=t[18]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){r=6;break}switch(i[e>>1]|0){case 13:case 10:{r=6;break e}case 93:{r=7;break e}case 92:{e=r+4|0;break}default:{}}r=e;}if((r|0)==6){t[18]=e;Z();e=0;}else if((r|0)==7){t[18]=e;e=93;}return e|0}function C(e,r,a,s,t,c,n,f){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;c=c|0;n=n|0;f=f|0;if((((((i[e+12>>1]|0)==f<<16>>16?(i[e+10>>1]|0)==n<<16>>16:0)?(i[e+8>>1]|0)==c<<16>>16:0)?(i[e+6>>1]|0)==t<<16>>16:0)?(i[e+4>>1]|0)==s<<16>>16:0)?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function g(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=B(e+-2|0,99,97,116,99)|0;break}case 121:{e=m(e+-2|0,102,105,110,97,108,108)|0;break}case 101:{e=P(e+-2|0,101,108,115)|0;break}default:e=0;}return e|0}function I(){var e=0,r=0,a=0;e:while(1){e=t[18]|0;r=e+2|0;t[18]=r;if(e>>>0>=(t[19]|0)>>>0){a=7;break}switch(i[r>>1]|0){case 13:case 10:{a=7;break e}case 47:break e;case 91:{y()|0;break}case 92:{t[18]=e+4;break}default:{}}}if((a|0)==7)Z();return}function p(e){e=e|0;var r=0,a=0,s=0,c=0,n=0;c=(t[18]|0)+2|0;t[18]=c;a=t[19]|0;while(1){r=c+2|0;if(c>>>0>=a>>>0)break;s=i[r>>1]|0;if(!e?ae(s)|0:0)break;if(s<<16>>16==42?(i[c+4>>1]|0)==47:0){n=8;break}c=r;}if((n|0)==8){t[18]=r;r=c+4|0;}t[18]=r;return}function x(e,r,a,s,t,c,n){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;c=c|0;n=n|0;if(((((i[e+10>>1]|0)==n<<16>>16?(i[e+8>>1]|0)==c<<16>>16:0)?(i[e+6>>1]|0)==t<<16>>16:0)?(i[e+4>>1]|0)==s<<16>>16:0)?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function S(e,r,a,s,c,n,f,u){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;n=n|0;f=f|0;u=u|0;var k=0,b=0;b=e+-12|0;k=t[3]|0;if(b>>>0>=k>>>0?C(b,r,a,s,c,n,f,u)|0:0)if((b|0)==(k|0))k=1;else k=F(i[e+-14>>1]|0)|0;else k=0;return k|0}function U(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 E(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 m(e,r,a,s,c,n,f){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;n=n|0;f=f|0;var u=0,k=0;k=e+-10|0;u=t[3]|0;if(k>>>0>=u>>>0?x(k,r,a,s,c,n,f)|0:0)if((k|0)==(u|0))u=1;else u=F(i[e+-12>>1]|0)|0;else u=0;return u|0}function O(e,r,a,s,c,n){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;n=n|0;var f=0,u=0;u=e+-8|0;f=t[3]|0;if(u>>>0>=f>>>0?j(u,r,a,s,c,n)|0:0)if((u|0)==(f|0))f=1;else f=F(i[e+-10>>1]|0)|0;else f=0;return f|0}function $(e,r){e=e|0;r=r|0;var a=0,s=0;a=t[18]|0;s=i[a>>1]|0;if(s<<16>>16==97){t[18]=a+4;r=w(1)|0;e=t[18]|0;H(r)|0;r=t[18]|0;s=w(1)|0;a=t[18]|0;}if((a|0)!=(e|0))J(e,r);return s|0}function R(e){e=e|0;var r=0,a=0,s=0,c=0;a=f;f=f+16|0;s=a;t[s>>2]=0;t[12]=e;r=t[3]|0;c=r+(e<<1)|0;e=c+2|0;i[c>>1]=0;t[s>>2]=e;t[13]=e;t[4]=0;t[8]=0;t[6]=0;t[5]=0;t[10]=0;t[7]=0;f=a;return r|0}function j(e,r,a,s,t,c){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;c=c|0;if((((i[e+8>>1]|0)==c<<16>>16?(i[e+6>>1]|0)==t<<16>>16:0)?(i[e+4>>1]|0)==s<<16>>16:0)?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function B(e,r,a,s,c){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;var n=0,f=0;f=e+-6|0;n=t[3]|0;if(f>>>0>=n>>>0?z(f,r,a,s,c)|0:0)if((f|0)==(n|0))n=1;else n=F(i[e+-8>>1]|0)|0;else n=0;return n|0}function P(e,r,a,s){e=e|0;r=r|0;a=a|0;s=s|0;var c=0,n=0;n=e+-4|0;c=t[3]|0;if(n>>>0>=c>>>0?K(n,r,a,s)|0:0)if((n|0)==(c|0))c=1;else c=F(i[e+-6>>1]|0)|0;else c=0;return c|0}function q(e,r,a){e=e|0;r=r|0;a=a|0;var s=0,c=0;c=e+-2|0;s=t[3]|0;if(c>>>0>=s>>>0?N(c,r,a)|0:0)if((c|0)==(s|0))s=1;else s=F(i[e+-4>>1]|0)|0;else s=0;return s|0}function z(e,r,a,s,t){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;if(((i[e+6>>1]|0)==t<<16>>16?(i[e+4>>1]|0)==s<<16>>16:0)?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function D(e,r){e=e|0;r=r|0;var a=0;a=t[3]|0;if(a>>>0<=e>>>0?(i[e>>1]|0)==r<<16>>16:0)if((a|0)==(e|0))a=1;else a=F(i[e+-2>>1]|0)|0;else a=0;return a|0}function F(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&(U(e)|0);}}while(0);return e|0}function G(){var e=0,r=0,a=0;e=t[19]|0;a=t[18]|0;e:while(1){r=a+2|0;if(a>>>0>=e>>>0)break;switch(i[r>>1]|0){case 13:case 10:break e;default:a=r;}}t[18]=r;return}function H(e){e=e|0;while(1){if(_(e)|0)break;if(U(e)|0)break;e=(t[18]|0)+2|0;t[18]=e;e=i[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function J(e,r){e=e|0;r=r|0;var a=0,s=0;a=t[13]|0;t[13]=a+12;s=t[10]|0;t[((s|0)==0?20:s+8|0)>>2]=a;t[10]=a;t[a>>2]=e;t[a+4>>2]=r;t[a+8>>2]=0;return}function K(e,r,a,s){e=e|0;r=r|0;a=a|0;s=s|0;if((i[e+4>>1]|0)==s<<16>>16?(i[e+2>>1]|0)==a<<16>>16:0)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function L(e){e=e|0;if(!(O(e,119,104,105,108,101)|0)?!(P(e,102,111,114)|0):0)e=q(e,105,102)|0;else e=1;return e|0}function M(){var e=0;e=t[(t[6]|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 N(e,r,a){e=e|0;r=r|0;a=a|0;if((i[e+2>>1]|0)==a<<16>>16)r=(i[e>>1]|0)==r<<16>>16;else r=0;return r|0}function Q(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 T(e){e=e|0;if((t[3]|0)==(e|0))e=1;else e=F(i[e+-2>>1]|0)|0;return e|0}function V(){var e=0;e=t[(t[6]|0)+16>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function W(){var e=0;e=t[6]|0;e=t[((e|0)==0?16:e+28|0)>>2]|0;t[6]=e;return (e|0)!=0|0}function X(){var e=0;e=t[7]|0;e=t[((e|0)==0?20:e+8|0)>>2]|0;t[7]=e;return (e|0)!=0|0}function Y(e){e=e|0;var r=0;r=f;f=f+e|0;f=f+15&-16;return r|0}function Z(){s[588]=1;t[14]=(t[18]|0)-(t[3]|0)>>1;t[18]=(t[19]|0)+2;return}function _(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function ee(){return (t[(t[6]|0)+12>>2]|0)-(t[3]|0)>>1|0}function re(){return (t[(t[6]|0)+8>>2]|0)-(t[3]|0)>>1|0}function ae(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function se(){return (t[(t[6]|0)+4>>2]|0)-(t[3]|0)>>1|0}function ie(){return (t[(t[7]|0)+4>>2]|0)-(t[3]|0)>>1|0}function te(){return (t[t[6]>>2]|0)-(t[3]|0)>>1|0}function ce(){return (t[t[7]>>2]|0)-(t[3]|0)>>1|0}function ne(){return c[(t[6]|0)+24>>0]|0|0}function fe(e){e=e|0;t[3]=e;return}function ue(e){e=e|0;f=e;}function ke(){return (s[589]|0)!=0|0}function be(){return f|0}function le(){return t[14]|0}return {ai:V,e:le,ee:ie,es:ce,f:ke,id:M,ie:se,ip:ne,is:te,parse:u,re:X,ri:W,sa:R,se:ee,setSource:fe,ss:re,stackAlloc:Y,stackRestore:ue,stackSave:be}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},{},r));const u=s.length+1,k=e.stackSave(),b=e.stackAlloc(2*s.length*4);if(e.setSource(b),e.sa(u-1),(a?c$1:t)(s,new Uint16Array(r,b,u)),!e.parse())throw Object.assign(new Error(`Parse error ${f}:${s.slice(0,e.e()).split("\n").length}:${e.e()-s.lastIndexOf("\n",e.e()-1)}`),{idx:e.e()});const l=[],o=[];for(;e.ri();){const r=e.is(),a=e.ie(),i=e.ai(),t=e.id(),c=e.ss(),f=e.se();let u;e.ip()&&(u=n(-1===t?r:r+1,s.charCodeAt(-1===t?r-1:r))),l.push({n:u,s:r,e:a,ss:c,se:f,d:t,a:i});}for(;e.re();)o.push(s.slice(e.es(),e.ee()));return e.stackRestore(k),[l,o,!!e.f()]}function t(e,r){const a=e.length;let s=0;for(;s<a;){const a=e.charCodeAt(s);r[s++]=(255&a)<<8|a>>>8;}}function c$1(e,r){const a=e.length;let s=0;for(;s<a;)r[s]=e.charCodeAt(s++);}function n(e,r){i=e;let a="",t=i;for(;;){i>=s.length&&syntaxError();const e=s.charCodeAt(i);if(e===r)break;92===e?(a+=s.slice(t,i),a+=f(),t=i):(8232===e||8233===e||k(e)&&syntaxError(),++i);}return a+=s.slice(t,i++),a}function f(){let e=s.charCodeAt(++i);switch(++i,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(u(2));case 117:return function(){let e;123===s.charCodeAt(i)?(++i,e=u(s.indexOf("}",i)-i),++i,e>1114111&&syntaxError()):e=u(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===s.charCodeAt(i)&&++i;case 10:return "";case 56:case 57:syntaxError();default:if(e>=48&&e<=55){let r=s.substr(i-1,3).match(/^[0-7]+/)[0],a=parseInt(r,8);return a>255&&(r=r.slice(0,-1),a=parseInt(r,8)),i+=r.length-1,e=s.charCodeAt(i),"0"===r&&56!==e&&57!==e||syntaxError(),String.fromCharCode(a)}return k(e)?"":String.fromCharCode(e)}}function u(e){const r=i;let a=0,t=0;for(let r=0;r<e;++r,++i){let e,c=s.charCodeAt(i);if(95!==c){if(c>=97)e=c-97+10;else if(c>=65)e=c-65+10;else {if(!(c>=48&&c<=57))break;e=c-48;}if(e>=16)break;t=c,a=16*a+e;}else 95!==t&&0!==r||syntaxError(),t=c;}return 95!==t&&i-r===e||syntaxError(),a}function k(e){return 13===e||10===e}
|
307
|
+
let e,r,a,i=4194304;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0];let t,f,c$1;function parse(k,l="@"){if(t=k,f=l,t.length>i||!e){for(;t.length>i;)i*=2;r=new ArrayBuffer(4*i),e=function(e,r,a){"use asm";var i=new e.Int8Array(a),s=new e.Int16Array(a),t=new e.Int32Array(a),f=new e.Uint8Array(a),c=new e.Uint16Array(a),n=816;function b(e){e=e|0;var r=0,a=0,f=0,b=0,l=0;l=n;n=n+14336|0;b=l;i[589]=1;s[291]=0;s[292]=0;s[293]=-1;t[15]=t[2];i[590]=0;t[14]=0;i[588]=0;t[16]=l+10240;t[17]=l+2048;i[591]=0;e=(t[3]|0)+-2|0;t[18]=e;r=e+(t[12]<<1)|0;t[19]=r;e:while(1){a=e+2|0;t[18]=a;if(e>>>0>=r>>>0){f=18;break}r:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[292]|0)==0?R(a)|0:0)?B(e+4|0,120,112,111,114,116)|0:0)?(u(),(i[589]|0)==0):0){f=9;break e}else f=17;break}case 105:{if(R(a)|0?B(e+4|0,109,112,111,114,116)|0:0){k();f=17;}else f=17;break}case 59:{f=17;break}case 47:switch(s[e+4>>1]|0){case 47:{G();break r}case 42:{p(1);break r}default:{f=16;break e}}default:{f=16;break e}}}while(0);if((f|0)==17){f=0;t[15]=t[18];}e=t[18]|0;r=t[19]|0;}if((f|0)==9){e=t[18]|0;t[15]=e;f=19;}else if((f|0)==16){i[589]=0;t[18]=e;f=19;}else if((f|0)==18)if(!(i[588]|0)){e=a;f=19;}else e=0;do{if((f|0)==19){e:while(1){r=e+2|0;t[18]=r;a=r;if(e>>>0>=(t[19]|0)>>>0){f=75;break}r:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[292]|0)==0?R(r)|0:0)?B(e+4|0,120,112,111,114,116)|0:0){u();f=74;}else f=74;break}case 105:{if(R(r)|0?B(e+4|0,109,112,111,114,116)|0:0){k();f=74;}else f=74;break}case 99:{if((R(r)|0?z(e+4|0,108,97,115,115)|0:0)?Z(s[e+12>>1]|0)|0:0){i[591]=1;f=74;}else f=74;break}case 40:{r=t[15]|0;a=t[17]|0;f=s[292]|0;s[292]=f+1<<16>>16;t[a+((f&65535)<<2)>>2]=r;f=74;break}case 41:{e=s[292]|0;if(!(e<<16>>16)){f=36;break e}f=e+-1<<16>>16;s[292]=f;e=t[11]|0;if((e|0)!=0?(t[e+20>>2]|0)==(t[(t[17]|0)+((f&65535)<<2)>>2]|0):0){r=e+4|0;if(!(t[r>>2]|0))t[r>>2]=a;t[e+12>>2]=a;t[11]=0;f=74;}else f=74;break}case 123:{f=t[15]|0;a=t[8]|0;e=f;do{if((s[f>>1]|0)==41&(a|0)!=0?(t[a+4>>2]|0)==(f|0):0){r=t[9]|0;t[8]=r;if(!r){t[4]=0;break}else {t[r+28>>2]=0;break}}}while(0);r=s[292]|0;f=r&65535;i[b+f>>0]=i[591]|0;i[591]=0;a=t[17]|0;s[292]=r+1<<16>>16;t[a+(f<<2)>>2]=e;f=74;break}case 125:{e=s[292]|0;if(!(e<<16>>16)){f=49;break e}a=e+-1<<16>>16;s[292]=a;r=s[293]|0;if(e<<16>>16!=r<<16>>16)if(r<<16>>16!=-1&(a&65535)<(r&65535)){f=53;break e}else {f=74;break r}else {a=t[16]|0;f=(s[291]|0)+-1<<16>>16;s[291]=f;s[293]=s[a+((f&65535)<<1)>>1]|0;h();f=74;break r}}case 39:{d(39);f=74;break}case 34:{d(34);f=74;break}case 47:switch(s[e+4>>1]|0){case 47:{G();break r}case 42:{p(1);break r}default:{r=t[15]|0;a=s[r>>1]|0;a:do{if(!(x(a)|0)){switch(a<<16>>16){case 41:if(L(t[(t[17]|0)+(c[292]<<2)>>2]|0)|0){f=71;break a}else {f=68;break a}case 125:break;default:{f=68;break a}}e=c[292]|0;if(!(y(t[(t[17]|0)+(e<<2)>>2]|0)|0)?(i[b+e>>0]|0)==0:0)f=68;else f=71;}else switch(a<<16>>16){case 46:if(((s[r+-2>>1]|0)+-48&65535)<10){f=68;break a}else {f=71;break a}case 43:if((s[r+-2>>1]|0)==43){f=68;break a}else {f=71;break a}case 45:if((s[r+-2>>1]|0)==45){f=68;break a}else {f=71;break a}default:{f=71;break a}}}while(0);a:do{if((f|0)==68){f=0;if(!(o(r)|0)){switch(a<<16>>16){case 0:{f=71;break a}case 47:break;default:{e=1;break a}}if(!(i[590]|0))e=1;else f=71;}else f=71;}}while(0);if((f|0)==71){I();e=0;}i[590]=e;f=74;break r}}case 96:{h();f=74;break}default:f=74;}}while(0);if((f|0)==74){f=0;t[15]=t[18];}e=t[18]|0;}if((f|0)==36){Y();e=0;break}else if((f|0)==49){Y();e=0;break}else if((f|0)==53){Y();e=0;break}else if((f|0)==75){e=(s[293]|0)==-1&(s[292]|0)==0&(i[588]|0)==0;break}}}while(0);n=l;return e|0}function u(){var e=0,r=0,a=0,f=0,c=0,n=0;c=t[18]|0;n=c+12|0;t[18]=n;r=w(1)|0;e=t[18]|0;if(!((e|0)==(n|0)?!(S(r)|0):0))f=3;e:do{if((f|0)==3){r:do{switch(r<<16>>16){case 100:{J(e,e+14|0);break e}case 97:{t[18]=e+10;w(1)|0;e=t[18]|0;f=6;break}case 102:{f=6;break}case 99:{if(z(e+2|0,108,97,115,115)|0?(a=e+10|0,F(s[a>>1]|0)|0):0){t[18]=a;c=w(1)|0;n=t[18]|0;H(c)|0;J(n,t[18]|0);t[18]=(t[18]|0)+-2;break e}e=e+4|0;t[18]=e;f=13;break}case 108:case 118:{f=13;break}case 123:{t[18]=e+2;e=w(1)|0;a=t[18]|0;while(1){if(_(e)|0){d(e);e=(t[18]|0)+2|0;t[18]=e;}else {H(e)|0;e=t[18]|0;}w(1)|0;e=g(a,e)|0;if(e<<16>>16==44){t[18]=(t[18]|0)+2;e=w(1)|0;}r=a;a=t[18]|0;if(e<<16>>16==125){f=32;break}if((a|0)==(r|0)){f=29;break}if(a>>>0>(t[19]|0)>>>0){f=31;break}}if((f|0)==29){Y();break e}else if((f|0)==31){Y();break e}else if((f|0)==32){t[18]=a+2;f=34;break r}break}case 42:{t[18]=e+2;w(1)|0;f=t[18]|0;g(f,f)|0;f=34;break}default:{}}}while(0);if((f|0)==6){t[18]=e+16;e=w(1)|0;if(e<<16>>16==42){t[18]=(t[18]|0)+2;e=w(1)|0;}n=t[18]|0;H(e)|0;J(n,t[18]|0);t[18]=(t[18]|0)+-2;break}else if((f|0)==13){e=e+4|0;t[18]=e;i[589]=0;r:while(1){t[18]=e+2;n=w(1)|0;e=t[18]|0;switch((H(n)|0)<<16>>16){case 91:case 123:{f=15;break r}default:{}}r=t[18]|0;if((r|0)==(e|0))break e;J(e,r);switch((w(1)|0)<<16>>16){case 61:{f=19;break r}case 44:break;default:{f=20;break r}}e=t[18]|0;}if((f|0)==15){t[18]=(t[18]|0)+-2;break}else if((f|0)==19){t[18]=(t[18]|0)+-2;break}else if((f|0)==20){t[18]=(t[18]|0)+-2;break}}else if((f|0)==34)r=w(1)|0;e=t[18]|0;if(r<<16>>16==102?K(e+2|0,114,111,109)|0:0){t[18]=e+8;l(c,w(1)|0);break}t[18]=e+-2;}}while(0);return}function k(){var e=0,r=0,a=0,f=0,c=0;c=t[18]|0;r=c+12|0;t[18]=r;e:do{switch((w(1)|0)<<16>>16){case 40:{r=t[17]|0;a=s[292]|0;s[292]=a+1<<16>>16;t[r+((a&65535)<<2)>>2]=c;if((s[t[15]>>1]|0)!=46){v(c,(t[18]|0)+2|0,0,c);t[11]=t[8];t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{t[18]=(t[18]|0)+-2;break e}}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 44:{c=t[18]|0;t[(t[8]|0)+4>>2]=c;t[18]=c+2;w(1)|0;c=t[18]|0;a=t[8]|0;t[a+16>>2]=c;i[a+24>>0]=1;t[18]=c+-2;break e}case 41:{s[292]=(s[292]|0)+-1<<16>>16;a=t[18]|0;c=t[8]|0;t[c+4>>2]=a;t[c+12>>2]=a;i[c+24>>0]=1;break e}default:{t[18]=(t[18]|0)+-2;break e}}}break}case 46:{t[18]=(t[18]|0)+2;if(((w(1)|0)<<16>>16==109?(e=t[18]|0,K(e+2|0,101,116,97)|0):0)?(s[t[15]>>1]|0)!=46:0)v(c,c,e+8|0,2);break}case 42:case 39:case 34:{f=16;break}case 123:{e=t[18]|0;if(s[292]|0){t[18]=e+-2;break e}while(1){if(e>>>0>=(t[19]|0)>>>0)break;e=w(1)|0;if(!(_(e)|0)){if(e<<16>>16==125){f=31;break}}else d(e);e=(t[18]|0)+2|0;t[18]=e;}if((f|0)==31)t[18]=(t[18]|0)+2;w(1)|0;e=t[18]|0;if(!(z(e,102,114,111,109)|0)){Y();break e}t[18]=e+8;e=w(1)|0;if(_(e)|0){l(c,e);break e}else {Y();break e}}default:if((t[18]|0)!=(r|0))f=16;}}while(0);do{if((f|0)==16){if(s[292]|0){t[18]=(t[18]|0)+-2;break}e=t[19]|0;r=t[18]|0;while(1){if(r>>>0>=e>>>0){f=23;break}a=s[r>>1]|0;if(_(a)|0){f=21;break}f=r+2|0;t[18]=f;r=f;}if((f|0)==21){l(c,a);break}else if((f|0)==23){Y();break}}}while(0);return}function l(e,r){e=e|0;r=r|0;var a=0,i=0;a=(t[18]|0)+2|0;switch(r<<16>>16){case 39:{d(39);i=5;break}case 34:{d(34);i=5;break}default:Y();}do{if((i|0)==5){v(e,a,t[18]|0,1);t[18]=(t[18]|0)+2;i=(w(0)|0)<<16>>16==97;r=t[18]|0;if(i?B(r+2|0,115,115,101,114,116)|0:0){t[18]=r+12;if((w(1)|0)<<16>>16!=123){t[18]=r;break}e=t[18]|0;a=e;e:while(1){t[18]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{d(39);t[18]=(t[18]|0)+2;a=w(1)|0;break}case 34:{d(34);t[18]=(t[18]|0)+2;a=w(1)|0;break}default:a=H(a)|0;}if(a<<16>>16!=58){i=16;break}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{i=20;break e}}t[18]=(t[18]|0)+2;switch((w(1)|0)<<16>>16){case 125:{i=25;break e}case 44:break;default:{i=24;break e}}t[18]=(t[18]|0)+2;if((w(1)|0)<<16>>16==125){i=25;break}a=t[18]|0;}if((i|0)==16){t[18]=r;break}else if((i|0)==20){t[18]=r;break}else if((i|0)==24){t[18]=r;break}else if((i|0)==25){i=t[8]|0;t[i+16>>2]=e;t[i+12>>2]=(t[18]|0)+2;break}}t[18]=r+-2;}}while(0);return}function o(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=q(e+-4|0,118,111)|0;break e}case 108:{e=P(e+-4|0,121,105,101)|0;break e}default:{e=0;break e}}case 101:{switch(s[e+-2>>1]|0){case 115:break;case 116:{e=E(e+-4|0,100,101,108,101)|0;break e}default:{e=0;break e}}switch(s[e+-4>>1]|0){case 108:{e=D(e+-6|0,101)|0;break e}case 97:{e=D(e+-6|0,99)|0;break e}default:{e=0;break e}}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=O(e+-8|0,105,110,115,116,97,110)|0;break e}case 112:{e=q(e+-8|0,116,121)|0;break e}default:{e=0;break e}}else e=0;break}case 110:{e=e+-2|0;if(D(e,105)|0)e=1;else e=$(e,114,101,116,117,114)|0;break}case 111:{e=D(e+-2|0,100)|0;break}case 114:{e=m(e+-2|0,100,101,98,117,103,103,101)|0;break}case 116:{e=E(e+-2|0,97,119,97,105)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=D(e+-4|0,110)|0;break e}case 111:{e=P(e+-4|0,116,104,114)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function h(){var e=0,r=0,a=0;r=t[19]|0;a=t[18]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){r=8;break}switch(s[e>>1]|0){case 96:{r=9;break e}case 36:{if((s[a+4>>1]|0)==123){r=6;break e}break}case 92:{e=a+4|0;break}default:{}}a=e;}if((r|0)==6){t[18]=a+4;e=s[293]|0;r=t[16]|0;a=s[291]|0;s[291]=a+1<<16>>16;s[r+((a&65535)<<1)>>1]=e;a=(s[292]|0)+1<<16>>16;s[292]=a;s[293]=a;}else if((r|0)==8){t[18]=e;Y();}else if((r|0)==9)t[18]=e;return}function w(e){e=e|0;var r=0,a=0,i=0;a=t[18]|0;e:do{r=s[a>>1]|0;r:do{if(r<<16>>16!=47)if(e)if(Z(r)|0)break;else break e;else if(Q(r)|0)break;else break e;else switch(s[a+2>>1]|0){case 47:{G();break r}case 42:{p(e);break r}default:{r=47;break e}}}while(0);i=t[18]|0;a=i+2|0;t[18]=a;}while(i>>>0<(t[19]|0)>>>0);return r|0}function d(e){e=e|0;var r=0,a=0,i=0,f=0;f=t[19]|0;r=t[18]|0;while(1){i=r+2|0;if(r>>>0>=f>>>0){r=9;break}a=s[i>>1]|0;if(a<<16>>16==e<<16>>16){r=10;break}if(a<<16>>16==92){a=r+4|0;if((s[a>>1]|0)==13){r=r+6|0;r=(s[r>>1]|0)==10?r:a;}else r=a;}else if(ae(a)|0){r=9;break}else r=i;}if((r|0)==9){t[18]=i;Y();}else if((r|0)==10)t[18]=i;return}function v(e,r,a,s){e=e|0;r=r|0;a=a|0;s=s|0;var f=0,c=0;f=t[13]|0;t[13]=f+32;c=t[8]|0;t[((c|0)==0?16:c+28|0)>>2]=f;t[9]=c;t[8]=f;t[f+8>>2]=e;do{if(2!=(s|0))if(1==(s|0)){t[f+12>>2]=a+2;break}else {t[f+12>>2]=t[3];break}else t[f+12>>2]=a;}while(0);t[f>>2]=r;t[f+4>>2]=a;t[f+16>>2]=0;t[f+20>>2]=s;i[f+24>>0]=1==(s|0)&1;t[f+28>>2]=0;return}function A(){var e=0,r=0,a=0;a=t[19]|0;r=t[18]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){r=6;break}switch(s[e>>1]|0){case 13:case 10:{r=6;break e}case 93:{r=7;break e}case 92:{e=r+4|0;break}default:{}}r=e;}if((r|0)==6){t[18]=e;Y();e=0;}else if((r|0)==7){t[18]=e;e=93;}return e|0}function C(e,r,a,i,t,f,c,n){e=e|0;r=r|0;a=a|0;i=i|0;t=t|0;f=f|0;c=c|0;n=n|0;if((((((s[e+12>>1]|0)==n<<16>>16?(s[e+10>>1]|0)==c<<16>>16:0)?(s[e+8>>1]|0)==f<<16>>16:0)?(s[e+6>>1]|0)==t<<16>>16:0)?(s[e+4>>1]|0)==i<<16>>16:0)?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function y(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=E(e+-2|0,99,97,116,99)|0;break}case 121:{e=O(e+-2|0,102,105,110,97,108,108)|0;break}case 101:{e=P(e+-2|0,101,108,115)|0;break}default:e=0;}return e|0}function g(e,r){e=e|0;r=r|0;var a=0,i=0;a=t[18]|0;i=s[a>>1]|0;if(i<<16>>16==97){t[18]=a+4;a=w(1)|0;e=t[18]|0;if(_(a)|0){d(a);r=(t[18]|0)+2|0;t[18]=r;}else {H(a)|0;r=t[18]|0;}i=w(1)|0;a=t[18]|0;}if((a|0)!=(e|0))J(e,r);return i|0}function I(){var e=0,r=0,a=0;e:while(1){e=t[18]|0;r=e+2|0;t[18]=r;if(e>>>0>=(t[19]|0)>>>0){a=7;break}switch(s[r>>1]|0){case 13:case 10:{a=7;break e}case 47:break e;case 91:{A()|0;break}case 92:{t[18]=e+4;break}default:{}}}if((a|0)==7)Y();return}function p(e){e=e|0;var r=0,a=0,i=0,f=0,c=0;f=(t[18]|0)+2|0;t[18]=f;a=t[19]|0;while(1){r=f+2|0;if(f>>>0>=a>>>0)break;i=s[r>>1]|0;if(!e?ae(i)|0:0)break;if(i<<16>>16==42?(s[f+4>>1]|0)==47:0){c=8;break}f=r;}if((c|0)==8){t[18]=r;r=f+4|0;}t[18]=r;return}function U(e,r,a,i,t,f,c){e=e|0;r=r|0;a=a|0;i=i|0;t=t|0;f=f|0;c=c|0;if(((((s[e+10>>1]|0)==c<<16>>16?(s[e+8>>1]|0)==f<<16>>16:0)?(s[e+6>>1]|0)==t<<16>>16:0)?(s[e+4>>1]|0)==i<<16>>16:0)?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function m(e,r,a,i,f,c,n,b){e=e|0;r=r|0;a=a|0;i=i|0;f=f|0;c=c|0;n=n|0;b=b|0;var u=0,k=0;k=e+-12|0;u=t[3]|0;if(k>>>0>=u>>>0?C(k,r,a,i,f,c,n,b)|0:0)if((k|0)==(u|0))u=1;else u=F(s[e+-14>>1]|0)|0;else u=0;return u|0}function S(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 x(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 O(e,r,a,i,f,c,n){e=e|0;r=r|0;a=a|0;i=i|0;f=f|0;c=c|0;n=n|0;var b=0,u=0;u=e+-10|0;b=t[3]|0;if(u>>>0>=b>>>0?U(u,r,a,i,f,c,n)|0:0)if((u|0)==(b|0))b=1;else b=F(s[e+-12>>1]|0)|0;else b=0;return b|0}function $(e,r,a,i,f,c){e=e|0;r=r|0;a=a|0;i=i|0;f=f|0;c=c|0;var n=0,b=0;b=e+-8|0;n=t[3]|0;if(b>>>0>=n>>>0?B(b,r,a,i,f,c)|0:0)if((b|0)==(n|0))n=1;else n=F(s[e+-10>>1]|0)|0;else n=0;return n|0}function j(e){e=e|0;var r=0,a=0,i=0,f=0;a=n;n=n+16|0;i=a;t[i>>2]=0;t[12]=e;r=t[3]|0;f=r+(e<<1)|0;e=f+2|0;s[f>>1]=0;t[i>>2]=e;t[13]=e;t[4]=0;t[8]=0;t[6]=0;t[5]=0;t[10]=0;t[7]=0;n=a;return r|0}function B(e,r,a,i,t,f){e=e|0;r=r|0;a=a|0;i=i|0;t=t|0;f=f|0;if((((s[e+8>>1]|0)==f<<16>>16?(s[e+6>>1]|0)==t<<16>>16:0)?(s[e+4>>1]|0)==i<<16>>16:0)?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function E(e,r,a,i,f){e=e|0;r=r|0;a=a|0;i=i|0;f=f|0;var c=0,n=0;n=e+-6|0;c=t[3]|0;if(n>>>0>=c>>>0?z(n,r,a,i,f)|0:0)if((n|0)==(c|0))c=1;else c=F(s[e+-8>>1]|0)|0;else c=0;return c|0}function P(e,r,a,i){e=e|0;r=r|0;a=a|0;i=i|0;var f=0,c=0;c=e+-4|0;f=t[3]|0;if(c>>>0>=f>>>0?K(c,r,a,i)|0:0)if((c|0)==(f|0))f=1;else f=F(s[e+-6>>1]|0)|0;else f=0;return f|0}function q(e,r,a){e=e|0;r=r|0;a=a|0;var i=0,f=0;f=e+-2|0;i=t[3]|0;if(f>>>0>=i>>>0?N(f,r,a)|0:0)if((f|0)==(i|0))i=1;else i=F(s[e+-4>>1]|0)|0;else i=0;return i|0}function z(e,r,a,i,t){e=e|0;r=r|0;a=a|0;i=i|0;t=t|0;if(((s[e+6>>1]|0)==t<<16>>16?(s[e+4>>1]|0)==i<<16>>16:0)?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function D(e,r){e=e|0;r=r|0;var a=0;a=t[3]|0;if(a>>>0<=e>>>0?(s[e>>1]|0)==r<<16>>16:0)if((a|0)==(e|0))a=1;else a=F(s[e+-2>>1]|0)|0;else a=0;return a|0}function F(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&(S(e)|0);}}while(0);return e|0}function G(){var e=0,r=0,a=0;e=t[19]|0;a=t[18]|0;e:while(1){r=a+2|0;if(a>>>0>=e>>>0)break;switch(s[r>>1]|0){case 13:case 10:break e;default:a=r;}}t[18]=r;return}function H(e){e=e|0;while(1){if(Z(e)|0)break;if(S(e)|0)break;e=(t[18]|0)+2|0;t[18]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function J(e,r){e=e|0;r=r|0;var a=0,i=0;a=t[13]|0;t[13]=a+12;i=t[10]|0;t[((i|0)==0?20:i+8|0)>>2]=a;t[10]=a;t[a>>2]=e;t[a+4>>2]=r;t[a+8>>2]=0;return}function K(e,r,a,i){e=e|0;r=r|0;a=a|0;i=i|0;if((s[e+4>>1]|0)==i<<16>>16?(s[e+2>>1]|0)==a<<16>>16:0)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function L(e){e=e|0;if(!($(e,119,104,105,108,101)|0)?!(P(e,102,111,114)|0):0)e=q(e,105,102)|0;else e=1;return e|0}function M(){var e=0;e=t[(t[6]|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 N(e,r,a){e=e|0;r=r|0;a=a|0;if((s[e+2>>1]|0)==a<<16>>16)r=(s[e>>1]|0)==r<<16>>16;else r=0;return r|0}function Q(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 R(e){e=e|0;if((t[3]|0)==(e|0))e=1;else e=F(s[e+-2>>1]|0)|0;return e|0}function T(){var e=0;e=t[(t[6]|0)+16>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function V(){var e=0;e=t[6]|0;e=t[((e|0)==0?16:e+28|0)>>2]|0;t[6]=e;return (e|0)!=0|0}function W(){var e=0;e=t[7]|0;e=t[((e|0)==0?20:e+8|0)>>2]|0;t[7]=e;return (e|0)!=0|0}function X(e){e=e|0;var r=0;r=n;n=n+e|0;n=n+15&-16;return r|0}function Y(){i[588]=1;t[14]=(t[18]|0)-(t[3]|0)>>1;t[18]=(t[19]|0)+2;return}function Z(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function _(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function ee(){return (t[(t[6]|0)+12>>2]|0)-(t[3]|0)>>1|0}function re(){return (t[(t[6]|0)+8>>2]|0)-(t[3]|0)>>1|0}function ae(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function ie(){return (t[(t[6]|0)+4>>2]|0)-(t[3]|0)>>1|0}function se(){return (t[(t[7]|0)+4>>2]|0)-(t[3]|0)>>1|0}function te(){return (t[t[6]>>2]|0)-(t[3]|0)>>1|0}function fe(){return (t[t[7]>>2]|0)-(t[3]|0)>>1|0}function ce(){return f[(t[6]|0)+24>>0]|0|0}function ne(e){e=e|0;t[3]=e;return}function be(){return (i[589]|0)!=0|0}function ue(){return t[14]|0}return {ai:T,e:ue,ee:se,es:fe,f:be,id:M,ie:ie,ip:ce,is:te,p:b,re:W,ri:V,sa:j,se:ee,ses:ne,ss:re,sta:X}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},{},r),a=e.sta(2*i);}const o=t.length+1;e.ses(a),e.sa(o-1),(s?b:n)(t,new Uint16Array(r,a,o)),e.p()||(c$1=e.e(),h());const w=[],d=[];for(;e.ri();){const r=e.is(),a=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),c=e.se();let n;e.ip()&&(n=u(-1===s?r:r+1,t.charCodeAt(-1===s?r-1:r))),w.push({n:n,s:r,e:a,ss:f,se:c,d:s,a:i});}for(;e.re();){const r=e.es(),a=t.charCodeAt(r);d.push(34===a||39===a?u(r+1,a):t.slice(e.es(),e.ee()));}return [w,d,!!e.f()]}function n(e,r){const a=e.length;let i=0;for(;i<a;){const a=e.charCodeAt(i);r[i++]=(255&a)<<8|a>>>8;}}function b(e,r){const a=e.length;let i=0;for(;i<a;)r[i]=e.charCodeAt(i++);}function u(e,r){c$1=e;let a="",i=c$1;for(;;){c$1>=t.length&&h();const e=t.charCodeAt(c$1);if(e===r)break;92===e?(a+=t.slice(i,c$1),a+=k(),i=c$1):(8232===e||8233===e||o(e)&&h(),++c$1);}return a+=t.slice(i,c$1++),a}function k(){let e=t.charCodeAt(++c$1);switch(++c$1,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(l(2));case 117:return function(){let e;123===t.charCodeAt(c$1)?(++c$1,e=l(t.indexOf("}",c$1)-c$1),++c$1,e>1114111&&h()):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===t.charCodeAt(c$1)&&++c$1;case 10:return "";case 56:case 57:h();default:if(e>=48&&e<=55){let r=t.substr(c$1-1,3).match(/^[0-7]+/)[0],a=parseInt(r,8);return a>255&&(r=r.slice(0,-1),a=parseInt(r,8)),c$1+=r.length-1,e=t.charCodeAt(c$1),"0"===r&&56!==e&&57!==e||h(),String.fromCharCode(a)}return o(e)?"":String.fromCharCode(e)}}function l(e){const r=c$1;let a=0,i=0;for(let r=0;r<e;++r,++c$1){let e,s=t.charCodeAt(c$1);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,a=16*a+e;}else 95!==i&&0!==r||h(),i=s;}return 95!==i&&c$1-r===e||h(),a}function o(e){return 13===e||10===e}function h(){throw Object.assign(new Error(`Parse error ${f}:${t.slice(0,c$1).split("\n").length}:${c$1-t.lastIndexOf("\n",c$1-1)}`),{idx:c$1})}
|
301
308
|
|
302
309
|
async function defaultResolve (id, parentUrl) {
|
303
310
|
return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl);
|
@@ -332,10 +339,24 @@
|
|
332
339
|
let baselinePassthrough;
|
333
340
|
|
334
341
|
const initPromise = featureDetectionPromise.then(() => {
|
335
|
-
baselinePassthrough = supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false;
|
336
342
|
// shim mode is determined on initialization, no late shim mode
|
337
|
-
if (!shimMode
|
338
|
-
|
343
|
+
if (!shimMode) {
|
344
|
+
let seenScript = false;
|
345
|
+
for (const script of document.querySelectorAll('script[type="module-shim"],script[type="importmap-shim"],script[type="module"],script[type="importmap"]')) {
|
346
|
+
if (!seenScript && script.type === 'module')
|
347
|
+
seenScript = true;
|
348
|
+
if (script.type.endsWith('-shim')) {
|
349
|
+
setShimMode();
|
350
|
+
break;
|
351
|
+
}
|
352
|
+
if (seenScript && script.type === 'importmap') {
|
353
|
+
importMapSrcOrLazy = true;
|
354
|
+
break;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
}
|
358
|
+
baselinePassthrough = supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false;
|
359
|
+
if (!baselinePassthrough) onpolyfill();
|
339
360
|
if (shimMode || !baselinePassthrough) {
|
340
361
|
new MutationObserver(mutations => {
|
341
362
|
for (const mutation of mutations) {
|
@@ -360,16 +381,9 @@
|
|
360
381
|
let importMapPromise = initPromise;
|
361
382
|
|
362
383
|
let acceptingImportMaps = true;
|
363
|
-
let nativeAcceptingImportMaps = true;
|
364
384
|
async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
|
365
|
-
if (
|
366
|
-
|
367
|
-
acceptingImportMaps = false;
|
368
|
-
}
|
369
|
-
else {
|
370
|
-
nativeAcceptingImportMaps = false;
|
371
|
-
}
|
372
|
-
}
|
385
|
+
if (!shimMode)
|
386
|
+
acceptingImportMaps = false;
|
373
387
|
await importMapPromise;
|
374
388
|
// early analysis opt-out - no need to even fetch if we have feature support
|
375
389
|
if (!shimMode && baselinePassthrough) {
|
@@ -390,7 +404,7 @@
|
|
390
404
|
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
391
405
|
return module;
|
392
406
|
}
|
393
|
-
const module = await dynamicImport(load.b, { errUrl: load.u });
|
407
|
+
const module = await dynamicImport((shimMode || load.n) ? load.b : load.u, { errUrl: load.u });
|
394
408
|
// if the top-level load is a shell, run its update function
|
395
409
|
if (load.s)
|
396
410
|
(await dynamicImport(load.s)).u$_(module);
|
@@ -422,12 +436,8 @@
|
|
422
436
|
await initPromise;
|
423
437
|
if (acceptingImportMaps || shimMode || !baselinePassthrough) {
|
424
438
|
processImportMaps();
|
425
|
-
if (!shimMode)
|
439
|
+
if (!shimMode)
|
426
440
|
acceptingImportMaps = false;
|
427
|
-
}
|
428
|
-
else {
|
429
|
-
nativeAcceptingImportMaps = false;
|
430
|
-
}
|
431
441
|
}
|
432
442
|
await importMapPromise;
|
433
443
|
return topLevelLoad((await resolve(id, parentUrl)).r || throwUnresolved(id, parentUrl), { credentials: 'same-origin' });
|
@@ -435,6 +445,10 @@
|
|
435
445
|
|
436
446
|
self.importShim = importShim;
|
437
447
|
|
448
|
+
if (shimMode) {
|
449
|
+
importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
|
450
|
+
}
|
451
|
+
|
438
452
|
const meta = {};
|
439
453
|
|
440
454
|
async function importMetaResolve (id, parentUrl = this.url) {
|
@@ -456,14 +470,6 @@
|
|
456
470
|
for (const dep of load.d)
|
457
471
|
resolveDeps(dep, seen);
|
458
472
|
|
459
|
-
// use direct native execution when possible
|
460
|
-
// load.n is therefore conservative
|
461
|
-
if (!shimMode && !load.n) {
|
462
|
-
load.b = lastLoad = load.u;
|
463
|
-
load.S = undefined;
|
464
|
-
return;
|
465
|
-
}
|
466
|
-
|
467
473
|
const [imports] = load.a;
|
468
474
|
|
469
475
|
// "execution"
|
@@ -575,7 +581,7 @@
|
|
575
581
|
JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes, relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
|
576
582
|
});export default s;`, t: 'css' };
|
577
583
|
else if (wasmContentType.test(contentType))
|
578
|
-
throw new Error('WASM modules not
|
584
|
+
throw new Error('WASM modules not supported');
|
579
585
|
else
|
580
586
|
throw new Error(`Unknown Content-Type "${contentType}"`);
|
581
587
|
}
|
@@ -617,7 +623,7 @@
|
|
617
623
|
({ r: load.r, s: source, t } = await (fetchCache[url] || doFetch(url, fetchOpts)));
|
618
624
|
if (t && !shimMode) {
|
619
625
|
if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
|
620
|
-
throw new Error(`${t}-modules
|
626
|
+
throw new Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
|
621
627
|
if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
|
622
628
|
load.n = true;
|
623
629
|
}
|
@@ -640,7 +646,7 @@
|
|
640
646
|
load.n = true;
|
641
647
|
if (!n) return;
|
642
648
|
const { r, b } = await resolve(n, load.r || load.u);
|
643
|
-
if (b && !supportsImportMaps)
|
649
|
+
if (b && (!supportsImportMaps || importMapSrcOrLazy))
|
644
650
|
load.n = true;
|
645
651
|
if (d !== -1) return;
|
646
652
|
if (!r)
|
@@ -700,21 +706,22 @@
|
|
700
706
|
});
|
701
707
|
|
702
708
|
let readyStateCompleteCnt = 1;
|
703
|
-
if (document.readyState === 'complete')
|
709
|
+
if (document.readyState === 'complete') {
|
704
710
|
readyStateCompleteCheck();
|
705
|
-
|
711
|
+
}
|
712
|
+
else {
|
706
713
|
document.addEventListener('readystatechange', async () => {
|
714
|
+
processImportMaps();
|
707
715
|
await initPromise;
|
708
716
|
readyStateCompleteCheck();
|
709
717
|
});
|
718
|
+
}
|
710
719
|
function readyStateCompleteCheck () {
|
711
720
|
if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
|
712
721
|
document.dispatchEvent(new Event('readystatechange'));
|
713
722
|
}
|
714
723
|
|
715
724
|
function processImportMap (script) {
|
716
|
-
if (!acceptingImportMaps)
|
717
|
-
return;
|
718
725
|
if (script.ep) // ep marker = script processed
|
719
726
|
return;
|
720
727
|
// empty inline scripts sometimes show before domready
|
@@ -722,20 +729,20 @@
|
|
722
729
|
return;
|
723
730
|
script.ep = true;
|
724
731
|
// we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
|
725
|
-
if (script.src
|
732
|
+
if (script.src) {
|
726
733
|
if (!shimMode)
|
727
734
|
return;
|
728
735
|
importMapSrcOrLazy = true;
|
729
736
|
}
|
730
|
-
if (
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
737
|
+
if (acceptingImportMaps) {
|
738
|
+
importMapPromise = importMapPromise
|
739
|
+
.then(async () => {
|
740
|
+
importMap = resolveAndComposeImportMap(script.src ? await (await fetchHook(script.src)).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
|
741
|
+
})
|
742
|
+
.catch(error => setTimeout(() => { throw error }));
|
743
|
+
if (!shimMode)
|
744
|
+
acceptingImportMaps = false;
|
735
745
|
}
|
736
|
-
importMapPromise = importMapPromise.then(async () => {
|
737
|
-
importMap = resolveAndComposeImportMap(script.src ? await (await fetchHook(script.src)).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
|
738
|
-
});
|
739
746
|
}
|
740
747
|
|
741
748
|
function processScript (script) {
|
@@ -753,7 +760,10 @@
|
|
753
760
|
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
754
761
|
if (isReadyScript) readyStateCompleteCnt++;
|
755
762
|
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
756
|
-
const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isReadyScript && lastStaticLoadPromise).catch(
|
763
|
+
const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isReadyScript && lastStaticLoadPromise).catch(e => {
|
764
|
+
setTimeout(() => { throw e });
|
765
|
+
onerror(e);
|
766
|
+
});
|
757
767
|
if (isReadyScript)
|
758
768
|
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
759
769
|
if (isDomContentLoadedScript)
|
@@ -774,4 +784,4 @@
|
|
774
784
|
throw Error("Unable to resolve specifier '" + id + (parentUrl ? "' from " + parentUrl : "'"));
|
775
785
|
}
|
776
786
|
|
777
|
-
}()
|
787
|
+
})();
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(){const e=navigator.userAgent.match(/Edge\/\d\d\.\d+$/);let t;function createBlob(e,t="text/javascript"){return URL.createObjectURL(new Blob([e],{type:t}))}const noop=()=>{};const r=document.querySelector("base[href]");r&&(t=r.href);if(!t&&"undefined"!==typeof location){t=location.href.split("#")[0].split("?")[0];const e=t.lastIndexOf("/");-1!==e&&(t=t.slice(0,e+1))}function isURL(e){try{new URL(e);return true}catch{return false}}const s=/\\/g;function resolveIfNotPlainOrUrl(e,t){t=t&&t.split("#")[0].split("?")[0];-1!==e.indexOf("\\")&&(e=e.replace(s,"/"));if("/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let s;if("/"===t[r.length+1])if("file:"!==r){s=t.slice(r.length+2);s=s.slice(s.indexOf("/")+1)}else s=t.slice(8);else s=t.slice(r.length+("/"===t[r.length]));if("/"===e[0])return t.slice(0,t.length-s.length-1)+e;const a=s.slice(0,s.lastIndexOf("/")+1)+e;const i=[];let c=-1;for(let e=0;e<a.length;e++)if(-1!==c){if("/"===a[e]){i.push(a.slice(c,e+1));c=-1}}else if("."===a[e])if("."!==a[e+1]||"/"!==a[e+2]&&e+2!==a.length)"/"===a[e+1]||e+1===a.length?e+=1:c=e;else{i.pop();e+=2}else c=e;-1!==c&&i.push(a.slice(c));return t.slice(0,t.length-s.length)+i.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(-1!==e.indexOf(":")?e:resolveIfNotPlainOrUrl("./"+e,t))}function resolveAndComposePackages(e,t,r,s){for(let a in e){const i=resolveIfNotPlainOrUrl(a,r)||a;if(t[i])throw new Error(`Dynamic import map rejected: Overrides entry "${i}" from ${t[i]} to ${e[i]}.`);let c=e[a];if("string"!==typeof c)continue;const f=resolveImportMap(s,resolveIfNotPlainOrUrl(c,r)||c,r);f?t[i]=f:targetWarning(a,e[a],"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r){const s={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes)};e.imports&&resolveAndComposePackages(e.imports,s.imports,t,r);if(e.scopes)for(let a in e.scopes){const i=resolveUrl(a,t);resolveAndComposePackages(e.scopes[a],s.scopes[i]||(s.scopes[i]={}),t,r)}return s}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const s=e.slice(0,r+1);if(s in t)return s}while(-1!==(r=e.lastIndexOf("/",r-1)))}function applyPackages(e,t){const r=getMatch(e,t);if(r){const s=t[r];if(null===s)return;if(!(e.length>r.length&&"/"!==s[s.length-1]))return s+e.slice(r.length);targetWarning(r,s,"should have a trailing '/'")}}function targetWarning(e,t,r){console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function resolveImportMap(e,t,r){let s=r&&getMatch(r,e.scopes);while(s){const r=applyPackages(t,e.scopes[s]);if(r)return r;s=getMatch(s.slice(0,s.lastIndexOf("/")),e.scopes)}return applyPackages(t,e.imports)||-1!==t.indexOf(":")&&t}const a=document.querySelector("script[type=esms-options]");const i=a?JSON.parse(a.innerHTML):self.esmsInitOptions?self.esmsInitOptions:{};let c=!!i.shimMode;const f=globalHook(c&&i.resolve);const oe=i.skip?new RegExp(i.skip):null;let le=i.nonce;if(!le){const e=document.querySelector("script[nonce]");e&&(le=e.getAttribute("nonce"))}const de=globalHook(i.onerror||noop);const pe=globalHook(i.onpolyfill||noop);const{revokeBlobURLs:he,noLoadEventRetriggers:ke}=i;const me=i.fetch?globalHook(i.fetch):fetch;function globalHook(e){return"string"===typeof e?self[e]:e}const we=Array.isArray(i.polyfillEnable)?i.polyfillEnable:[];const ve=we.includes("css-modules");const ge=we.includes("json-modules");function setShimMode(){c=true}let ye;window.addEventListener("error",(e=>ye=e));function dynamicImportScript(e,{errUrl:r=e}={}){ye=void 0;const s=createBlob(`import*as m from'${e}';self._esmsi=m`);const a=Object.assign(document.createElement("script"),{type:"module",src:s});a.setAttribute("nonce",le);a.setAttribute("noshim","");const i=new Promise(((e,i)=>{a.addEventListener("error",cb);a.addEventListener("load",cb);function cb(c){document.head.removeChild(a);if(self._esmsi){e(self._esmsi,t);self._esmsi=void 0}else{i(!(c instanceof Event)&&c||ye&&ye.error||new Error(`Error loading or executing the graph of ${r} (check the console for ${s}).`));ye=void 0}}}));document.head.appendChild(a);return i}let $e=dynamicImportScript;const Se=dynamicImportScript(createBlob("export default u=>import(u)")).then((e=>{e&&($e=e.default);return!!e}),noop);let Ae=false;let Ce=false;let Oe=false;let Ie=false;let Le=false;const Ue=Promise.resolve(Se).then((e=>{if(e){Le=true;return Promise.all([$e(createBlob("import.meta")).then((()=>Oe=true),noop),ve&&$e(createBlob('import"data:text/css,{}"assert{type:"css"}')).then((()=>Ce=true),noop),ge&&$e(createBlob('import"data:text/json,{}"assert{type:"json"}')).then((()=>Ae=true),noop),new Promise((e=>{self._$s=r=>{document.head.removeChild(t);r&&(Ie=true);delete self._$s;e()};const t=document.createElement("iframe");t.style.display="none";document.head.appendChild(t);t.contentWindow.document.write(`<script type=importmap nonce="${le}">{"imports":{"x":"data:text/javascript,"}}<\/script><script nonce="${le}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<\/script>`)}))])}}));let Pe,xe,Me,Ee=4194304;const je=1===new Uint8Array(new Uint16Array([1]).buffer)[0];let Re,_e,Fe;function parse(e,t="@"){if(Re=e,_e=t,Re.length>Ee||!Pe){for(;Re.length>Ee;)Ee*=2;xe=new ArrayBuffer(4*Ee),Pe=function(e,t,r){"use asm";var s=new e.Int8Array(r),a=new e.Int16Array(r),i=new e.Int32Array(r),c=new e.Uint8Array(r),f=new e.Uint16Array(r),oe=816;function b(e){e=e|0;var t=0,r=0,c=0,le=0,de=0;de=oe;oe=oe+14336|0;le=de;s[589]=1;a[291]=0;a[292]=0;a[293]=-1;i[15]=i[2];s[590]=0;i[14]=0;s[588]=0;i[16]=de+10240;i[17]=de+2048;s[591]=0;e=(i[3]|0)+-2|0;i[18]=e;t=e+(i[12]<<1)|0;i[19]=t;e:while(1){r=e+2|0;i[18]=r;if(e>>>0>=t>>>0){c=18;break}t:do{switch(a[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((a[292]|0)==0?R(r)|0:0)?B(e+4|0,120,112,111,114,116)|0:0)?(u(),(s[589]|0)==0):0){c=9;break e}else c=17;break}case 105:{if(R(r)|0?B(e+4|0,109,112,111,114,116)|0:0){k();c=17}else c=17;break}case 59:{c=17;break}case 47:switch(a[e+4>>1]|0){case 47:{G();break t}case 42:{p(1);break t}default:{c=16;break e}}default:{c=16;break e}}}while(0);if((c|0)==17){c=0;i[15]=i[18]}e=i[18]|0;t=i[19]|0}if((c|0)==9){e=i[18]|0;i[15]=e;c=19}else if((c|0)==16){s[589]=0;i[18]=e;c=19}else if((c|0)==18)if(!(s[588]|0)){e=r;c=19}else e=0;do{if((c|0)==19){e:while(1){t=e+2|0;i[18]=t;r=t;if(e>>>0>=(i[19]|0)>>>0){c=75;break}t:do{switch(a[t>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((a[292]|0)==0?R(t)|0:0)?B(e+4|0,120,112,111,114,116)|0:0){u();c=74}else c=74;break}case 105:{if(R(t)|0?B(e+4|0,109,112,111,114,116)|0:0){k();c=74}else c=74;break}case 99:{if((R(t)|0?z(e+4|0,108,97,115,115)|0:0)?Z(a[e+12>>1]|0)|0:0){s[591]=1;c=74}else c=74;break}case 40:{t=i[15]|0;r=i[17]|0;c=a[292]|0;a[292]=c+1<<16>>16;i[r+((c&65535)<<2)>>2]=t;c=74;break}case 41:{e=a[292]|0;if(!(e<<16>>16)){c=36;break e}c=e+-1<<16>>16;a[292]=c;e=i[11]|0;if((e|0)!=0?(i[e+20>>2]|0)==(i[(i[17]|0)+((c&65535)<<2)>>2]|0):0){t=e+4|0;if(!(i[t>>2]|0))i[t>>2]=r;i[e+12>>2]=r;i[11]=0;c=74}else c=74;break}case 123:{c=i[15]|0;r=i[8]|0;e=c;do{if((a[c>>1]|0)==41&(r|0)!=0?(i[r+4>>2]|0)==(c|0):0){t=i[9]|0;i[8]=t;if(!t){i[4]=0;break}else{i[t+28>>2]=0;break}}}while(0);t=a[292]|0;c=t&65535;s[le+c>>0]=s[591]|0;s[591]=0;r=i[17]|0;a[292]=t+1<<16>>16;i[r+(c<<2)>>2]=e;c=74;break}case 125:{e=a[292]|0;if(!(e<<16>>16)){c=49;break e}r=e+-1<<16>>16;a[292]=r;t=a[293]|0;if(e<<16>>16!=t<<16>>16)if(t<<16>>16!=-1&(r&65535)<(t&65535)){c=53;break e}else{c=74;break t}else{r=i[16]|0;c=(a[291]|0)+-1<<16>>16;a[291]=c;a[293]=a[r+((c&65535)<<1)>>1]|0;h();c=74;break t}}case 39:{d(39);c=74;break}case 34:{d(34);c=74;break}case 47:switch(a[e+4>>1]|0){case 47:{G();break t}case 42:{p(1);break t}default:{t=i[15]|0;r=a[t>>1]|0;r:do{if(!(x(r)|0)){switch(r<<16>>16){case 41:if(L(i[(i[17]|0)+(f[292]<<2)>>2]|0)|0){c=71;break r}else{c=68;break r}case 125:break;default:{c=68;break r}}e=f[292]|0;if(!(y(i[(i[17]|0)+(e<<2)>>2]|0)|0)?(s[le+e>>0]|0)==0:0)c=68;else c=71}else switch(r<<16>>16){case 46:if(((a[t+-2>>1]|0)+-48&65535)<10){c=68;break r}else{c=71;break r}case 43:if((a[t+-2>>1]|0)==43){c=68;break r}else{c=71;break r}case 45:if((a[t+-2>>1]|0)==45){c=68;break r}else{c=71;break r}default:{c=71;break r}}}while(0);r:do{if((c|0)==68){c=0;if(!(o(t)|0)){switch(r<<16>>16){case 0:{c=71;break r}case 47:break;default:{e=1;break r}}if(!(s[590]|0))e=1;else c=71}else c=71}}while(0);if((c|0)==71){I();e=0}s[590]=e;c=74;break t}}case 96:{h();c=74;break}default:c=74}}while(0);if((c|0)==74){c=0;i[15]=i[18]}e=i[18]|0}if((c|0)==36){Y();e=0;break}else if((c|0)==49){Y();e=0;break}else if((c|0)==53){Y();e=0;break}else if((c|0)==75){e=(a[293]|0)==-1&(a[292]|0)==0&(s[588]|0)==0;break}}}while(0);oe=de;return e|0}function u(){var e=0,t=0,r=0,c=0,f=0,oe=0;f=i[18]|0;oe=f+12|0;i[18]=oe;t=w(1)|0;e=i[18]|0;if(!((e|0)==(oe|0)?!(S(t)|0):0))c=3;e:do{if((c|0)==3){t:do{switch(t<<16>>16){case 100:{J(e,e+14|0);break e}case 97:{i[18]=e+10;w(1)|0;e=i[18]|0;c=6;break}case 102:{c=6;break}case 99:{if(z(e+2|0,108,97,115,115)|0?(r=e+10|0,F(a[r>>1]|0)|0):0){i[18]=r;f=w(1)|0;oe=i[18]|0;H(f)|0;J(oe,i[18]|0);i[18]=(i[18]|0)+-2;break e}e=e+4|0;i[18]=e;c=13;break}case 108:case 118:{c=13;break}case 123:{i[18]=e+2;e=w(1)|0;r=i[18]|0;while(1){if(_(e)|0){d(e);e=(i[18]|0)+2|0;i[18]=e}else{H(e)|0;e=i[18]|0}w(1)|0;e=g(r,e)|0;if(e<<16>>16==44){i[18]=(i[18]|0)+2;e=w(1)|0}t=r;r=i[18]|0;if(e<<16>>16==125){c=32;break}if((r|0)==(t|0)){c=29;break}if(r>>>0>(i[19]|0)>>>0){c=31;break}}if((c|0)==29){Y();break e}else if((c|0)==31){Y();break e}else if((c|0)==32){i[18]=r+2;c=34;break t}break}case 42:{i[18]=e+2;w(1)|0;c=i[18]|0;g(c,c)|0;c=34;break}default:{}}}while(0);if((c|0)==6){i[18]=e+16;e=w(1)|0;if(e<<16>>16==42){i[18]=(i[18]|0)+2;e=w(1)|0}oe=i[18]|0;H(e)|0;J(oe,i[18]|0);i[18]=(i[18]|0)+-2;break}else if((c|0)==13){e=e+4|0;i[18]=e;s[589]=0;t:while(1){i[18]=e+2;oe=w(1)|0;e=i[18]|0;switch((H(oe)|0)<<16>>16){case 91:case 123:{c=15;break t}default:{}}t=i[18]|0;if((t|0)==(e|0))break e;J(e,t);switch((w(1)|0)<<16>>16){case 61:{c=19;break t}case 44:break;default:{c=20;break t}}e=i[18]|0}if((c|0)==15){i[18]=(i[18]|0)+-2;break}else if((c|0)==19){i[18]=(i[18]|0)+-2;break}else if((c|0)==20){i[18]=(i[18]|0)+-2;break}}else if((c|0)==34)t=w(1)|0;e=i[18]|0;if(t<<16>>16==102?K(e+2|0,114,111,109)|0:0){i[18]=e+8;l(f,w(1)|0);break}i[18]=e+-2}}while(0);return}function k(){var e=0,t=0,r=0,c=0,f=0;f=i[18]|0;t=f+12|0;i[18]=t;e:do{switch((w(1)|0)<<16>>16){case 40:{t=i[17]|0;r=a[292]|0;a[292]=r+1<<16>>16;i[t+((r&65535)<<2)>>2]=f;if((a[i[15]>>1]|0)!=46){v(f,(i[18]|0)+2|0,0,f);i[11]=i[8];i[18]=(i[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{i[18]=(i[18]|0)+-2;break e}}i[18]=(i[18]|0)+2;switch((w(1)|0)<<16>>16){case 44:{f=i[18]|0;i[(i[8]|0)+4>>2]=f;i[18]=f+2;w(1)|0;f=i[18]|0;r=i[8]|0;i[r+16>>2]=f;s[r+24>>0]=1;i[18]=f+-2;break e}case 41:{a[292]=(a[292]|0)+-1<<16>>16;r=i[18]|0;f=i[8]|0;i[f+4>>2]=r;i[f+12>>2]=r;s[f+24>>0]=1;break e}default:{i[18]=(i[18]|0)+-2;break e}}}break}case 46:{i[18]=(i[18]|0)+2;if(((w(1)|0)<<16>>16==109?(e=i[18]|0,K(e+2|0,101,116,97)|0):0)?(a[i[15]>>1]|0)!=46:0)v(f,f,e+8|0,2);break}case 42:case 39:case 34:{c=16;break}case 123:{e=i[18]|0;if(a[292]|0){i[18]=e+-2;break e}while(1){if(e>>>0>=(i[19]|0)>>>0)break;e=w(1)|0;if(!(_(e)|0)){if(e<<16>>16==125){c=31;break}}else d(e);e=(i[18]|0)+2|0;i[18]=e}if((c|0)==31)i[18]=(i[18]|0)+2;w(1)|0;e=i[18]|0;if(!(z(e,102,114,111,109)|0)){Y();break e}i[18]=e+8;e=w(1)|0;if(_(e)|0){l(f,e);break e}else{Y();break e}}default:if((i[18]|0)!=(t|0))c=16}}while(0);do{if((c|0)==16){if(a[292]|0){i[18]=(i[18]|0)+-2;break}e=i[19]|0;t=i[18]|0;while(1){if(t>>>0>=e>>>0){c=23;break}r=a[t>>1]|0;if(_(r)|0){c=21;break}c=t+2|0;i[18]=c;t=c}if((c|0)==21){l(f,r);break}else if((c|0)==23){Y();break}}}while(0);return}function l(e,t){e=e|0;t=t|0;var r=0,s=0;r=(i[18]|0)+2|0;switch(t<<16>>16){case 39:{d(39);s=5;break}case 34:{d(34);s=5;break}default:Y()}do{if((s|0)==5){v(e,r,i[18]|0,1);i[18]=(i[18]|0)+2;s=(w(0)|0)<<16>>16==97;t=i[18]|0;if(s?B(t+2|0,115,115,101,114,116)|0:0){i[18]=t+12;if((w(1)|0)<<16>>16!=123){i[18]=t;break}e=i[18]|0;r=e;e:while(1){i[18]=r+2;r=w(1)|0;switch(r<<16>>16){case 39:{d(39);i[18]=(i[18]|0)+2;r=w(1)|0;break}case 34:{d(34);i[18]=(i[18]|0)+2;r=w(1)|0;break}default:r=H(r)|0}if(r<<16>>16!=58){s=16;break}i[18]=(i[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{s=20;break e}}i[18]=(i[18]|0)+2;switch((w(1)|0)<<16>>16){case 125:{s=25;break e}case 44:break;default:{s=24;break e}}i[18]=(i[18]|0)+2;if((w(1)|0)<<16>>16==125){s=25;break}r=i[18]|0}if((s|0)==16){i[18]=t;break}else if((s|0)==20){i[18]=t;break}else if((s|0)==24){i[18]=t;break}else if((s|0)==25){s=i[8]|0;i[s+16>>2]=e;i[s+12>>2]=(i[18]|0)+2;break}}i[18]=t+-2}}while(0);return}function o(e){e=e|0;e:do{switch(a[e>>1]|0){case 100:switch(a[e+-2>>1]|0){case 105:{e=q(e+-4|0,118,111)|0;break e}case 108:{e=P(e+-4|0,121,105,101)|0;break e}default:{e=0;break e}}case 101:{switch(a[e+-2>>1]|0){case 115:break;case 116:{e=E(e+-4|0,100,101,108,101)|0;break e}default:{e=0;break e}}switch(a[e+-4>>1]|0){case 108:{e=D(e+-6|0,101)|0;break e}case 97:{e=D(e+-6|0,99)|0;break e}default:{e=0;break e}}}case 102:{if((a[e+-2>>1]|0)==111?(a[e+-4>>1]|0)==101:0)switch(a[e+-6>>1]|0){case 99:{e=O(e+-8|0,105,110,115,116,97,110)|0;break e}case 112:{e=q(e+-8|0,116,121)|0;break e}default:{e=0;break e}}else e=0;break}case 110:{e=e+-2|0;if(D(e,105)|0)e=1;else e=$(e,114,101,116,117,114)|0;break}case 111:{e=D(e+-2|0,100)|0;break}case 114:{e=m(e+-2|0,100,101,98,117,103,103,101)|0;break}case 116:{e=E(e+-2|0,97,119,97,105)|0;break}case 119:switch(a[e+-2>>1]|0){case 101:{e=D(e+-4|0,110)|0;break e}case 111:{e=P(e+-4|0,116,104,114)|0;break e}default:{e=0;break e}}default:e=0}}while(0);return e|0}function h(){var e=0,t=0,r=0;t=i[19]|0;r=i[18]|0;e:while(1){e=r+2|0;if(r>>>0>=t>>>0){t=8;break}switch(a[e>>1]|0){case 96:{t=9;break e}case 36:{if((a[r+4>>1]|0)==123){t=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e}if((t|0)==6){i[18]=r+4;e=a[293]|0;t=i[16]|0;r=a[291]|0;a[291]=r+1<<16>>16;a[t+((r&65535)<<1)>>1]=e;r=(a[292]|0)+1<<16>>16;a[292]=r;a[293]=r}else if((t|0)==8){i[18]=e;Y()}else if((t|0)==9)i[18]=e;return}function w(e){e=e|0;var t=0,r=0,s=0;r=i[18]|0;e:do{t=a[r>>1]|0;t:do{if(t<<16>>16!=47)if(e)if(Z(t)|0)break;else break e;else if(Q(t)|0)break;else break e;else switch(a[r+2>>1]|0){case 47:{G();break t}case 42:{p(e);break t}default:{t=47;break e}}}while(0);s=i[18]|0;r=s+2|0;i[18]=r}while(s>>>0<(i[19]|0)>>>0);return t|0}function d(e){e=e|0;var t=0,r=0,s=0,c=0;c=i[19]|0;t=i[18]|0;while(1){s=t+2|0;if(t>>>0>=c>>>0){t=9;break}r=a[s>>1]|0;if(r<<16>>16==e<<16>>16){t=10;break}if(r<<16>>16==92){r=t+4|0;if((a[r>>1]|0)==13){t=t+6|0;t=(a[t>>1]|0)==10?t:r}else t=r}else if(ae(r)|0){t=9;break}else t=s}if((t|0)==9){i[18]=s;Y()}else if((t|0)==10)i[18]=s;return}function v(e,t,r,a){e=e|0;t=t|0;r=r|0;a=a|0;var c=0,f=0;c=i[13]|0;i[13]=c+32;f=i[8]|0;i[((f|0)==0?16:f+28|0)>>2]=c;i[9]=f;i[8]=c;i[c+8>>2]=e;do{if(2!=(a|0))if(1==(a|0)){i[c+12>>2]=r+2;break}else{i[c+12>>2]=i[3];break}else i[c+12>>2]=r}while(0);i[c>>2]=t;i[c+4>>2]=r;i[c+16>>2]=0;i[c+20>>2]=a;s[c+24>>0]=1==(a|0)&1;i[c+28>>2]=0;return}function A(){var e=0,t=0,r=0;r=i[19]|0;t=i[18]|0;e:while(1){e=t+2|0;if(t>>>0>=r>>>0){t=6;break}switch(a[e>>1]|0){case 13:case 10:{t=6;break e}case 93:{t=7;break e}case 92:{e=t+4|0;break}default:{}}t=e}if((t|0)==6){i[18]=e;Y();e=0}else if((t|0)==7){i[18]=e;e=93}return e|0}function C(e,t,r,s,i,c,f,oe){e=e|0;t=t|0;r=r|0;s=s|0;i=i|0;c=c|0;f=f|0;oe=oe|0;if((((((a[e+12>>1]|0)==oe<<16>>16?(a[e+10>>1]|0)==f<<16>>16:0)?(a[e+8>>1]|0)==c<<16>>16:0)?(a[e+6>>1]|0)==i<<16>>16:0)?(a[e+4>>1]|0)==s<<16>>16:0)?(a[e+2>>1]|0)==r<<16>>16:0)t=(a[e>>1]|0)==t<<16>>16;else t=0;return t|0}function y(e){e=e|0;switch(a[e>>1]|0){case 62:{e=(a[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=E(e+-2|0,99,97,116,99)|0;break}case 121:{e=O(e+-2|0,102,105,110,97,108,108)|0;break}case 101:{e=P(e+-2|0,101,108,115)|0;break}default:e=0}return e|0}function g(e,t){e=e|0;t=t|0;var r=0,s=0;r=i[18]|0;s=a[r>>1]|0;if(s<<16>>16==97){i[18]=r+4;r=w(1)|0;e=i[18]|0;if(_(r)|0){d(r);t=(i[18]|0)+2|0;i[18]=t}else{H(r)|0;t=i[18]|0}s=w(1)|0;r=i[18]|0}if((r|0)!=(e|0))J(e,t);return s|0}function I(){var e=0,t=0,r=0;e:while(1){e=i[18]|0;t=e+2|0;i[18]=t;if(e>>>0>=(i[19]|0)>>>0){r=7;break}switch(a[t>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{A()|0;break}case 92:{i[18]=e+4;break}default:{}}}if((r|0)==7)Y();return}function p(e){e=e|0;var t=0,r=0,s=0,c=0,f=0;c=(i[18]|0)+2|0;i[18]=c;r=i[19]|0;while(1){t=c+2|0;if(c>>>0>=r>>>0)break;s=a[t>>1]|0;if(!e?ae(s)|0:0)break;if(s<<16>>16==42?(a[c+4>>1]|0)==47:0){f=8;break}c=t}if((f|0)==8){i[18]=t;t=c+4|0}i[18]=t;return}function U(e,t,r,s,i,c,f){e=e|0;t=t|0;r=r|0;s=s|0;i=i|0;c=c|0;f=f|0;if(((((a[e+10>>1]|0)==f<<16>>16?(a[e+8>>1]|0)==c<<16>>16:0)?(a[e+6>>1]|0)==i<<16>>16:0)?(a[e+4>>1]|0)==s<<16>>16:0)?(a[e+2>>1]|0)==r<<16>>16:0)t=(a[e>>1]|0)==t<<16>>16;else t=0;return t|0}function m(e,t,r,s,c,f,oe,le){e=e|0;t=t|0;r=r|0;s=s|0;c=c|0;f=f|0;oe=oe|0;le=le|0;var de=0,pe=0;pe=e+-12|0;de=i[3]|0;if(pe>>>0>=de>>>0?C(pe,t,r,s,c,f,oe,le)|0:0)if((pe|0)==(de|0))de=1;else de=F(a[e+-14>>1]|0)|0;else de=0;return de|0}function S(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 x(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 O(e,t,r,s,c,f,oe){e=e|0;t=t|0;r=r|0;s=s|0;c=c|0;f=f|0;oe=oe|0;var le=0,de=0;de=e+-10|0;le=i[3]|0;if(de>>>0>=le>>>0?U(de,t,r,s,c,f,oe)|0:0)if((de|0)==(le|0))le=1;else le=F(a[e+-12>>1]|0)|0;else le=0;return le|0}function $(e,t,r,s,c,f){e=e|0;t=t|0;r=r|0;s=s|0;c=c|0;f=f|0;var oe=0,le=0;le=e+-8|0;oe=i[3]|0;if(le>>>0>=oe>>>0?B(le,t,r,s,c,f)|0:0)if((le|0)==(oe|0))oe=1;else oe=F(a[e+-10>>1]|0)|0;else oe=0;return oe|0}function j(e){e=e|0;var t=0,r=0,s=0,c=0;r=oe;oe=oe+16|0;s=r;i[s>>2]=0;i[12]=e;t=i[3]|0;c=t+(e<<1)|0;e=c+2|0;a[c>>1]=0;i[s>>2]=e;i[13]=e;i[4]=0;i[8]=0;i[6]=0;i[5]=0;i[10]=0;i[7]=0;oe=r;return t|0}function B(e,t,r,s,i,c){e=e|0;t=t|0;r=r|0;s=s|0;i=i|0;c=c|0;if((((a[e+8>>1]|0)==c<<16>>16?(a[e+6>>1]|0)==i<<16>>16:0)?(a[e+4>>1]|0)==s<<16>>16:0)?(a[e+2>>1]|0)==r<<16>>16:0)t=(a[e>>1]|0)==t<<16>>16;else t=0;return t|0}function E(e,t,r,s,c){e=e|0;t=t|0;r=r|0;s=s|0;c=c|0;var f=0,oe=0;oe=e+-6|0;f=i[3]|0;if(oe>>>0>=f>>>0?z(oe,t,r,s,c)|0:0)if((oe|0)==(f|0))f=1;else f=F(a[e+-8>>1]|0)|0;else f=0;return f|0}function P(e,t,r,s){e=e|0;t=t|0;r=r|0;s=s|0;var c=0,f=0;f=e+-4|0;c=i[3]|0;if(f>>>0>=c>>>0?K(f,t,r,s)|0:0)if((f|0)==(c|0))c=1;else c=F(a[e+-6>>1]|0)|0;else c=0;return c|0}function q(e,t,r){e=e|0;t=t|0;r=r|0;var s=0,c=0;c=e+-2|0;s=i[3]|0;if(c>>>0>=s>>>0?N(c,t,r)|0:0)if((c|0)==(s|0))s=1;else s=F(a[e+-4>>1]|0)|0;else s=0;return s|0}function z(e,t,r,s,i){e=e|0;t=t|0;r=r|0;s=s|0;i=i|0;if(((a[e+6>>1]|0)==i<<16>>16?(a[e+4>>1]|0)==s<<16>>16:0)?(a[e+2>>1]|0)==r<<16>>16:0)t=(a[e>>1]|0)==t<<16>>16;else t=0;return t|0}function D(e,t){e=e|0;t=t|0;var r=0;r=i[3]|0;if(r>>>0<=e>>>0?(a[e>>1]|0)==t<<16>>16:0)if((r|0)==(e|0))r=1;else r=F(a[e+-2>>1]|0)|0;else r=0;return r|0}function F(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&(S(e)|0)}}while(0);return e|0}function G(){var e=0,t=0,r=0;e=i[19]|0;r=i[18]|0;e:while(1){t=r+2|0;if(r>>>0>=e>>>0)break;switch(a[t>>1]|0){case 13:case 10:break e;default:r=t}}i[18]=t;return}function H(e){e=e|0;while(1){if(Z(e)|0)break;if(S(e)|0)break;e=(i[18]|0)+2|0;i[18]=e;e=a[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function J(e,t){e=e|0;t=t|0;var r=0,s=0;r=i[13]|0;i[13]=r+12;s=i[10]|0;i[((s|0)==0?20:s+8|0)>>2]=r;i[10]=r;i[r>>2]=e;i[r+4>>2]=t;i[r+8>>2]=0;return}function K(e,t,r,s){e=e|0;t=t|0;r=r|0;s=s|0;if((a[e+4>>1]|0)==s<<16>>16?(a[e+2>>1]|0)==r<<16>>16:0)t=(a[e>>1]|0)==t<<16>>16;else t=0;return t|0}function L(e){e=e|0;if(!($(e,119,104,105,108,101)|0)?!(P(e,102,111,114)|0):0)e=q(e,105,102)|0;else e=1;return e|0}function M(){var e=0;e=i[(i[6]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(i[3]|0)>>1}return e|0}function N(e,t,r){e=e|0;t=t|0;r=r|0;if((a[e+2>>1]|0)==r<<16>>16)t=(a[e>>1]|0)==t<<16>>16;else t=0;return t|0}function Q(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 R(e){e=e|0;if((i[3]|0)==(e|0))e=1;else e=F(a[e+-2>>1]|0)|0;return e|0}function T(){var e=0;e=i[(i[6]|0)+16>>2]|0;if(!e)e=-1;else e=e-(i[3]|0)>>1;return e|0}function V(){var e=0;e=i[6]|0;e=i[((e|0)==0?16:e+28|0)>>2]|0;i[6]=e;return(e|0)!=0|0}function W(){var e=0;e=i[7]|0;e=i[((e|0)==0?20:e+8|0)>>2]|0;i[7]=e;return(e|0)!=0|0}function X(e){e=e|0;var t=0;t=oe;oe=oe+e|0;oe=oe+15&-16;return t|0}function Y(){s[588]=1;i[14]=(i[18]|0)-(i[3]|0)>>1;i[18]=(i[19]|0)+2;return}function Z(e){e=e|0;return(e|128)<<16>>16==160|(e+-9&65535)<5|0}function _(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function ee(){return(i[(i[6]|0)+12>>2]|0)-(i[3]|0)>>1|0}function re(){return(i[(i[6]|0)+8>>2]|0)-(i[3]|0)>>1|0}function ae(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function ie(){return(i[(i[6]|0)+4>>2]|0)-(i[3]|0)>>1|0}function se(){return(i[(i[7]|0)+4>>2]|0)-(i[3]|0)>>1|0}function te(){return(i[i[6]>>2]|0)-(i[3]|0)>>1|0}function fe(){return(i[i[7]>>2]|0)-(i[3]|0)>>1|0}function ce(){return c[(i[6]|0)+24>>0]|0|0}function ne(e){e=e|0;i[3]=e;return}function be(){return(s[589]|0)!=0|0}function ue(){return i[14]|0}return{ai:T,e:ue,ee:se,es:fe,f:be,id:M,ie:ie,ip:ce,is:te,p:b,re:W,ri:V,sa:j,se:ee,ses:ne,ss:re,sta:X}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},{},xe),Me=Pe.sta(2*Ee)}const r=Re.length+1;Pe.ses(Me),Pe.sa(r-1),(je?b:n)(Re,new Uint16Array(xe,Me,r)),Pe.p()||(Fe=Pe.e(),h());const s=[],a=[];for(;Pe.ri();){const e=Pe.is(),t=Pe.ie(),r=Pe.ai(),a=Pe.id(),i=Pe.ss(),c=Pe.se();let f;Pe.ip()&&(f=u(-1===a?e:e+1,Re.charCodeAt(-1===a?e-1:e))),s.push({n:f,s:e,e:t,ss:i,se:c,d:a,a:r})}for(;Pe.re();){const e=Pe.es(),t=Re.charCodeAt(e);a.push(34===t||39===t?u(e+1,t):Re.slice(Pe.es(),Pe.ee()))}return[s,a,!!Pe.f()]}function n(e,t){const r=e.length;let s=0;for(;s<r;){const r=e.charCodeAt(s);t[s++]=(255&r)<<8|r>>>8}}function b(e,t){const r=e.length;let s=0;for(;s<r;)t[s]=e.charCodeAt(s++)}function u(e,t){Fe=e;let r="",s=Fe;for(;;){Fe>=Re.length&&h();const e=Re.charCodeAt(Fe);if(e===t)break;92===e?(r+=Re.slice(s,Fe),r+=k(),s=Fe):(8232===e||8233===e||o(e)&&h(),++Fe)}return r+=Re.slice(s,Fe++),r}function k(){let e=Re.charCodeAt(++Fe);switch(++Fe,e){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(l(2));case 117:return function(){let e;123===Re.charCodeAt(Fe)?(++Fe,e=l(Re.indexOf("}",Fe)-Fe),++Fe,e>1114111&&h()):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===Re.charCodeAt(Fe)&&++Fe;case 10:return"";case 56:case 57:h();default:if(e>=48&&e<=55){let t=Re.substr(Fe-1,3).match(/^[0-7]+/)[0],r=parseInt(t,8);return r>255&&(t=t.slice(0,-1),r=parseInt(t,8)),Fe+=t.length-1,e=Re.charCodeAt(Fe),"0"===t&&56!==e&&57!==e||h(),String.fromCharCode(r)}return o(e)?"":String.fromCharCode(e)}}function l(e){const t=Fe;let r=0,s=0;for(let t=0;t<e;++t,++Fe){let e,a=Re.charCodeAt(Fe);if(95!==a){if(a>=97)e=a-97+10;else if(a>=65)e=a-65+10;else{if(!(a>=48&&a<=57))break;e=a-48}if(e>=16)break;s=a,r=16*r+e}else 95!==s&&0!==t||h(),s=a}return 95!==s&&Fe-t===e||h(),r}function o(e){return 13===e||10===e}function h(){throw Object.assign(new Error(`Parse error ${_e}:${Re.slice(0,Fe).split("\n").length}:${Fe-Re.lastIndexOf("\n",Fe-1)}`),{idx:Fe})}async function defaultResolve(e,t){return resolveImportMap(Je,resolveIfNotPlainOrUrl(e,t)||e,t)}async function _resolve(e,t){const r=resolveIfNotPlainOrUrl(e,t);return{r:resolveImportMap(Je,r||e,t),b:!r&&!isURL(e)}}const Be=f?async(e,t)=>({r:await esmsInitOptions.resolve(e,t,defaultResolve),b:false}):_resolve;let Ne=0;const He={};async function loadAll(e,t){if(!e.b&&!t[e.u]){t[e.u]=1;await e.L;await Promise.all(e.d.map((e=>loadAll(e,t))));e.n||(e.n=e.d.some((e=>e.n)))}}let Je={imports:{},scopes:{}};let qe=false;let Ye;const De=Ue.then((()=>{if(!c){let e=false;for(const t of document.querySelectorAll('script[type="module-shim"],script[type="importmap-shim"],script[type="module"],script[type="importmap"]')){e||"module"!==t.type||(e=true);if(t.type.endsWith("-shim")){setShimMode();break}if(e&&"importmap"===t.type){qe=true;break}}}Ye=Le&&Oe&&Ie&&(!ge||Ae)&&(!ve||Ce)&&!qe&&true;Ye||pe();if(!c&&Ye);else{new MutationObserver((e=>{for(const t of e)if("childList"===t.type)for(const e of t.addedNodes)if("SCRIPT"===e.tagName){(!c&&"module"===e.type||c&&"module-shim"===e.type)&&processScript(e);(!c&&"importmap"===e.type||c&&"importmap-shim"===e.type)&&processImportMap(e)}else"LINK"===e.tagName&&"modulepreload"===e.rel&&processPreload(e)})).observe(document,{childList:true,subtree:true});processImportMaps();processScriptsAndPreloads()}}));let Te=De;let We=true;async function topLevelLoad(e,t,r,s,a){c||(We=false);await Te;if(!c&&Ye){if(s)return null;await a;return $e(r?createBlob(r):e,{errUrl:e||r})}const i=getOrCreateLoad(e,t,r);const f={};await loadAll(i,f);Ke=void 0;resolveDeps(i,f);await a;if(r&&!c&&!i.n&&true){const e=await $e(createBlob(r),{errUrl:r});he&&revokeObjectURLs(Object.keys(f));return e}const oe=await $e(c||i.n?i.b:i.u,{errUrl:i.u});i.s&&(await $e(i.s)).u$_(oe);he&&revokeObjectURLs(Object.keys(f));return oe}function revokeObjectURLs(e){let t=0;const r=e.length;const s=self.requestIdleCallback?self.requestIdleCallback:self.requestAnimationFrame;s(cleanup);function cleanup(){const a=100*t;if(!(a>r)){for(const t of e.slice(a,a+100)){const e=He[t];e&&URL.revokeObjectURL(e.b)}t++;s(cleanup)}}}async function importShim(e,r=t,s){await De;if(We||c||!Ye){processImportMaps();c||(We=false)}await Te;return topLevelLoad((await Be(e,r)).r||throwUnresolved(e,r),{credentials:"same-origin"})}self.importShim=importShim;c&&(importShim.getImportMap=()=>JSON.parse(JSON.stringify(Je)));const ze={};async function importMetaResolve(e,t=this.url){return(await Be(e,`${t}`)).r||throwUnresolved(e,t)}self._esmsm=ze;function urlJsString(e){return`'${e.replace(/'/g,"\\'")}'`}let Ke;function resolveDeps(t,r){if(t.b||!r[t.u])return;r[t.u]=0;for(const e of t.d)resolveDeps(e,r);const[s]=t.a;const a=t.S;let i=e&&Ke?`import '${Ke}';`:"";if(s.length){let e=0,r=0;for(const{s:c,se:f,d:oe}of s)if(-1===oe){const s=t.d[r++];let oe=s.b;if(oe){if(s.s){i+=`${a.slice(e,c-1)}/*${a.slice(c-1,f)}*/${urlJsString(oe)};import*as m$_${r} from'${s.b}';import{u$_ as u$_${r}}from'${s.s}';u$_${r}(m$_${r})`;e=f;s.s=void 0;continue}}else(oe=s.s)||(oe=s.s=createBlob(`export function u$_(m){${s.a[1].map((e=>"default"===e?"$_default=m.default":`${e}=m.${e}`)).join(",")}}${s.a[1].map((e=>"default"===e?"let $_default;export{$_default as default}":`export let ${e}`)).join(";")}\n//# sourceURL=${s.r}?cycle`));i+=`${a.slice(e,c-1)}/*${a.slice(c-1,f)}*/${urlJsString(oe)}`;e=f}else if(-2===oe){ze[t.r]={url:t.r,resolve:importMetaResolve};i+=`${a.slice(e,c)}self._esmsm[${urlJsString(t.r)}]`;e=f}else{i+=`${a.slice(e,oe+6)}Shim(${a.slice(c,f)}, ${t.r&&urlJsString(t.r)}`;e=f}i+=a.slice(e)}else i+=a;i=i.replace(/\/\/# sourceMappingURL=(.*)\s*$/,((e,r)=>e.replace(r,(()=>new URL(r,t.r)))));let c=false;i=i.replace(/\/\/# sourceURL=(.*)\s*$/,((e,r)=>(c=true,e.replace(r,(()=>new URL(r,t.r))))));c||(i+="\n//# sourceURL="+t.r);t.b=Ke=createBlob(i);t.S=void 0}const Ge=/^(text|application)\/(x-)?javascript(;|$)/;const Ze=/^(text|application)\/json(;|$)/;const Qe=/^(text|application)\/css(;|$)/;const Ve=/^application\/wasm(;|$)/;const Xe=/url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;let et=[];let tt=0;function pushFetchPool(){if(++tt>100)return new Promise((e=>et.push(e)))}function popFetchPool(){tt--;et.length&&et.shift()()}async function doFetch(e,t){const r=pushFetchPool();r&&await r;try{var s=await me(e,t)}finally{popFetchPool()}if(!s.ok)throw new Error(`${s.status} ${s.statusText} ${s.url}`);const a=s.headers.get("content-type");if(Ge.test(a))return{r:s.url,s:await s.text(),t:"js"};if(Ze.test(a))return{r:s.url,s:`export default ${await s.text()}`,t:"json"};if(Qe.test(a))return{r:s.url,s:`var s=new CSSStyleSheet();s.replaceSync(${JSON.stringify((await s.text()).replace(Xe,((t,r,s,a)=>`url(${r}${resolveUrl(s||a,e)}${r})`)))});export default s;`,t:"css"};throw Ve.test(a)?new Error("WASM modules not supported"):new Error(`Unknown Content-Type "${a}"`)}function getOrCreateLoad(e,t,r){let s=He[e];if(s)return s;s=He[e]={u:e,r:void 0,f:void 0,S:void 0,L:void 0,a:void 0,d:void 0,b:void 0,s:void 0,n:false,t:null};s.f=(async()=>{if(!r){let a;({r:s.r,s:r,t:a}=await(nt[e]||doFetch(e,t)));if(a&&!c){if("css"===a&&!ve||"json"===a&&!ge)throw new Error(`${a}-modules require <script type="esms-options">{ "polyfillEnable": ["${a}-modules"] }<\/script>`);("css"===a&&!Ce||"json"===a&&!Ae)&&(s.n=true)}}try{s.a=parse(r,s.u)}catch(e){console.warn(e);s.a=[[],[]]}s.S=r;return s})();s.L=s.f.then((async()=>{let e=t;s.d=(await Promise.all(s.a[0].map((async({n:t,d:r})=>{(r>=0&&!Le||2===r&&!Oe)&&(s.n=true);if(!t)return;const{r:a,b:i}=await Be(t,s.r||s.u);!i||Ie&&!qe||(s.n=true);if(-1===r){a||throwUnresolved(t,s.r||s.u);if(oe&&oe.test(a))return{b:a};e.integrity&&(e=Object.assign({},e,{integrity:void 0}));return getOrCreateLoad(a,e).f}})))).filter((e=>e))}));return s}function processScriptsAndPreloads(){for(const e of document.querySelectorAll(c?'script[type="module-shim"]':'script[type="module"]'))processScript(e);for(const e of document.querySelectorAll('link[rel="modulepreload"]'))processPreload(e)}function processImportMaps(){for(const e of document.querySelectorAll(c?'script[type="importmap-shim"]':'script[type="importmap"]'))processImportMap(e)}function getFetchOpts(e){const t={};e.integrity&&(t.integrity=e.integrity);e.referrerpolicy&&(t.referrerPolicy=e.referrerpolicy);"use-credentials"===e.crossorigin?t.credentials="include":"anonymous"===e.crossorigin?t.credentials="omit":t.credentials="same-origin";return t}let rt=Promise.resolve();let st=1;function domContentLoadedCheck(){0!==--st||ke||document.dispatchEvent(new Event("DOMContentLoaded"))}document.addEventListener("DOMContentLoaded",(async()=>{await De;domContentLoadedCheck();if(c||!Ye){processImportMaps();processScriptsAndPreloads()}}));let at=1;"complete"===document.readyState?readyStateCompleteCheck():document.addEventListener("readystatechange",(async()=>{processImportMaps();await De;readyStateCompleteCheck()}));function readyStateCompleteCheck(){0!==--at||ke||document.dispatchEvent(new Event("readystatechange"))}function processImportMap(e){if(!e.ep&&(e.src||e.innerHTML)){e.ep=true;if(e.src){if(!c)return;qe=true}if(We){Te=Te.then((async()=>{Je=resolveAndComposeImportMap(e.src?await(await me(e.src)).json():JSON.parse(e.innerHTML),e.src||t,Je)})).catch((e=>setTimeout((()=>{throw e}))));c||(We=false)}}}function processScript(e){if(e.ep)return;if(null!==e.getAttribute("noshim"))return;if(!e.src&&!e.innerHTML)return;e.ep=true;const r=at>0;const s=st>0;r&&at++;s&&st++;const a=topLevelLoad(e.src||`${t}?${Ne++}`,getFetchOpts(e),!e.src&&e.innerHTML,!c,r&&rt).catch((e=>{setTimeout((()=>{throw e}));de(e)}));r&&(rt=a.then(readyStateCompleteCheck));s&&a.then(domContentLoadedCheck)}const nt={};function processPreload(e){if(!e.ep){e.ep=true;nt[e.href]||(nt[e.href]=doFetch(e.href,getFetchOpts(e)))}}function throwUnresolved(e,t){throw Error("Unable to resolve specifier '"+e+(t?"' from "+t:"'"))}})();
|
@@ -26,9 +26,9 @@ module Importmap::ImportmapTagsHelper
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Include the es-modules-shim needed to make importmaps work in browsers without native support (like Firefox + Safari).
|
29
|
-
def javascript_importmap_shim_tag
|
30
|
-
javascript_include_tag "es-module-shims"
|
31
|
-
nonce: content_security_policy_nonce
|
29
|
+
def javascript_importmap_shim_tag(minimized: true)
|
30
|
+
javascript_include_tag minimized ? "es-module-shims.min.js" : "es-module-shims.js",
|
31
|
+
async: true, "data-turbo-track": "reload", nonce: content_security_policy_nonce
|
32
32
|
end
|
33
33
|
|
34
34
|
# Import a named JavaScript module(s) using a script-module tag.
|
data/lib/importmap/commands.rb
CHANGED
@@ -3,16 +3,26 @@ require "importmap/packager"
|
|
3
3
|
|
4
4
|
class Importmap::Commands < Thor
|
5
5
|
include Thor::Actions
|
6
|
+
|
7
|
+
def self.exit_on_failure?
|
8
|
+
false
|
9
|
+
end
|
6
10
|
|
7
11
|
desc "pin [*PACKAGES]", "Pin new packages"
|
8
12
|
option :env, type: :string, aliases: :e, default: "production"
|
9
13
|
option :from, type: :string, aliases: :f, default: "jspm"
|
14
|
+
option :download, type: :boolean, aliases: :d, default: false
|
10
15
|
def pin(*packages)
|
11
16
|
if imports = packager.import(*packages, env: options[:env], from: options[:from])
|
12
17
|
imports.each do |package, url|
|
13
|
-
|
14
|
-
|
15
|
-
|
18
|
+
if options[:download]
|
19
|
+
puts %(Pinning "#{package}" to #{packager.vendor_path}/#{package}.js via download from #{url})
|
20
|
+
packager.download(package, url)
|
21
|
+
pin = packager.vendored_pin_for(package, url)
|
22
|
+
else
|
23
|
+
puts %(Pinning "#{package}" to #{url})
|
24
|
+
pin = packager.pin_for(package, url)
|
25
|
+
end
|
16
26
|
|
17
27
|
if packager.packaged?(package)
|
18
28
|
gsub_file("config/importmap.rb", /^pin "#{package}".*$/, pin, verbose: false)
|
@@ -21,23 +31,29 @@ class Importmap::Commands < Thor
|
|
21
31
|
end
|
22
32
|
end
|
23
33
|
else
|
24
|
-
puts "Couldn't find any packages in #{packages.inspect} on #{options[:
|
34
|
+
puts "Couldn't find any packages in #{packages.inspect} on #{options[:from]}"
|
25
35
|
end
|
26
36
|
end
|
27
37
|
|
28
38
|
desc "unpin [*PACKAGES]", "Unpin existing packages"
|
29
39
|
option :env, type: :string, aliases: :e, default: "production"
|
30
40
|
option :from, type: :string, aliases: :f, default: "jspm"
|
41
|
+
option :download, type: :boolean, aliases: :d, default: false
|
31
42
|
def unpin(*packages)
|
32
43
|
if imports = packager.import(*packages, env: options[:env], from: options[:from])
|
33
44
|
imports.each do |package, url|
|
34
45
|
if packager.packaged?(package)
|
35
|
-
|
36
|
-
|
46
|
+
if options[:download]
|
47
|
+
puts %(Unpinning and removing "#{package}")
|
48
|
+
else
|
49
|
+
puts %(Unpinning "#{package}")
|
50
|
+
end
|
51
|
+
|
52
|
+
packager.remove(package)
|
37
53
|
end
|
38
54
|
end
|
39
55
|
else
|
40
|
-
puts "Couldn't find any packages in #{packages.inspect} on #{options[:
|
56
|
+
puts "Couldn't find any packages in #{packages.inspect} on #{options[:from]}"
|
41
57
|
end
|
42
58
|
end
|
43
59
|
|
data/lib/importmap/engine.rb
CHANGED
@@ -7,6 +7,7 @@ module Importmap
|
|
7
7
|
class Engine < ::Rails::Engine
|
8
8
|
config.importmap = ActiveSupport::OrderedOptions.new
|
9
9
|
config.importmap.sweep_cache = Rails.env.development? || Rails.env.test?
|
10
|
+
config.importmap.rescuable_asset_errors = []
|
10
11
|
|
11
12
|
config.autoload_once_paths = %W( #{root}/app/helpers )
|
12
13
|
|
@@ -26,7 +27,9 @@ module Importmap
|
|
26
27
|
|
27
28
|
initializer "importmap.cache_sweeper" do |app|
|
28
29
|
if app.config.importmap.sweep_cache
|
29
|
-
app.importmap.cache_sweeper watches:
|
30
|
+
app.importmap.cache_sweeper watches: [
|
31
|
+
app.root.join("app/javascript"), app.root.join("vendor/javascript")
|
32
|
+
]
|
30
33
|
|
31
34
|
ActiveSupport.on_load(:action_controller_base) do
|
32
35
|
before_action { Rails.application.importmap.cache_sweeper.execute_if_updated }
|
@@ -36,8 +39,9 @@ module Importmap
|
|
36
39
|
|
37
40
|
initializer "importmap.assets" do
|
38
41
|
if Rails.application.config.respond_to?(:assets)
|
39
|
-
Rails.application.config.assets.precompile += %w( es-module-shims.js )
|
42
|
+
Rails.application.config.assets.precompile += %w( es-module-shims.js es-module-shims.min.js )
|
40
43
|
Rails.application.config.assets.paths << Rails.root.join("app/javascript")
|
44
|
+
Rails.application.config.assets.paths << Rails.root.join("vendor/javascript")
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
@@ -46,5 +50,11 @@ module Importmap
|
|
46
50
|
helper Importmap::ImportmapTagsHelper
|
47
51
|
end
|
48
52
|
end
|
53
|
+
|
54
|
+
initializer 'importmap.rescuable_asset_errors' do |app|
|
55
|
+
if defined?(Sprockets::Rails)
|
56
|
+
app.config.importmap.rescuable_asset_errors << Sprockets::Rails::Helper::AssetNotFound
|
57
|
+
end
|
58
|
+
end
|
49
59
|
end
|
50
60
|
end
|
data/lib/importmap/map.rb
CHANGED
@@ -22,12 +22,12 @@ class Importmap::Map
|
|
22
22
|
self
|
23
23
|
end
|
24
24
|
|
25
|
-
def pin(name, to: nil, preload:
|
25
|
+
def pin(name, to: nil, preload: false)
|
26
26
|
clear_cache
|
27
27
|
@packages[name] = MappedFile.new(name: name, path: to || "#{name}.js", preload: preload)
|
28
28
|
end
|
29
29
|
|
30
|
-
def pin_all_from(dir, under: nil, to: nil, preload:
|
30
|
+
def pin_all_from(dir, under: nil, to: nil, preload: false)
|
31
31
|
clear_cache
|
32
32
|
@directories[dir] = MappedDir.new(dir: dir, under: under, path: to, preload: preload)
|
33
33
|
end
|
@@ -87,13 +87,21 @@ class Importmap::Map
|
|
87
87
|
@cached_preloaded_module_paths = nil
|
88
88
|
end
|
89
89
|
|
90
|
+
def rescuable_asset_error?(error)
|
91
|
+
Rails.application.config.importmap.rescuable_asset_errors.any? { |e| error.is_a?(e) }
|
92
|
+
end
|
93
|
+
|
90
94
|
def resolve_asset_paths(paths, resolver:)
|
91
95
|
paths.transform_values do |mapping|
|
92
96
|
begin
|
93
97
|
resolver.asset_path(mapping.path)
|
94
|
-
rescue
|
95
|
-
|
96
|
-
|
98
|
+
rescue => e
|
99
|
+
if rescuable_asset_error?(e)
|
100
|
+
Rails.logger.warn "Importmap skipped missing path: #{mapping.path}"
|
101
|
+
nil
|
102
|
+
else
|
103
|
+
raise e
|
104
|
+
end
|
97
105
|
end
|
98
106
|
end.compact
|
99
107
|
end
|
data/lib/importmap/packager.rb
CHANGED
@@ -10,8 +10,11 @@ class Importmap::Packager
|
|
10
10
|
singleton_class.attr_accessor :endpoint
|
11
11
|
self.endpoint = URI("https://api.jspm.io/generate")
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
attr_reader :vendor_path
|
14
|
+
|
15
|
+
def initialize(importmap_path = "config/importmap.rb", vendor_path: "vendor/javascript")
|
16
|
+
@importmap_path = Pathname.new(importmap_path)
|
17
|
+
@vendor_path = Pathname.new(vendor_path)
|
15
18
|
end
|
16
19
|
|
17
20
|
def import(*packages, env: "production", from: "jspm")
|
@@ -33,15 +36,43 @@ class Importmap::Packager
|
|
33
36
|
%(pin "#{package}", to: "#{url}")
|
34
37
|
end
|
35
38
|
|
39
|
+
def vendored_pin_for(package, url)
|
40
|
+
filename = package_filename(package)
|
41
|
+
version = extract_package_version_from(url)
|
42
|
+
|
43
|
+
if "#{package}.js" == filename
|
44
|
+
%(pin "#{package}" # #{version})
|
45
|
+
else
|
46
|
+
%(pin "#{package}", to: "#{filename}" # #{version})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
36
50
|
def packaged?(package)
|
37
51
|
importmap.match(/^pin "#{package}".*$/)
|
38
52
|
end
|
39
53
|
|
54
|
+
def download(package, url)
|
55
|
+
ensure_vendor_directory_exists
|
56
|
+
remove_existing_package_file(package)
|
57
|
+
download_package_file(package, url)
|
58
|
+
end
|
59
|
+
|
60
|
+
def remove(package)
|
61
|
+
remove_existing_package_file(package)
|
62
|
+
remove_package_from_importmap(package)
|
63
|
+
end
|
64
|
+
|
40
65
|
private
|
66
|
+
def post_json(body)
|
67
|
+
Net::HTTP.post(self.class.endpoint, body.to_json, "Content-Type" => "application/json")
|
68
|
+
rescue => error
|
69
|
+
raise HTTPError, "Unexpected transport error (#{error.class}: #{error.message})"
|
70
|
+
end
|
71
|
+
|
41
72
|
def extract_parsed_imports(response)
|
42
73
|
JSON.parse(response.body).dig("map", "imports")
|
43
74
|
end
|
44
|
-
|
75
|
+
|
45
76
|
def handle_failure_response(response)
|
46
77
|
if error_message = parse_service_error(response)
|
47
78
|
raise ServiceError, error_message
|
@@ -56,13 +87,57 @@ class Importmap::Packager
|
|
56
87
|
nil
|
57
88
|
end
|
58
89
|
|
59
|
-
def post_json(body)
|
60
|
-
Net::HTTP.post(self.class.endpoint, body.to_json, { "Content-Type" => "application/json" })
|
61
|
-
rescue => error
|
62
|
-
raise HTTPError, "Unexpected transport error (#{error.class}: #{error.message})"
|
63
|
-
end
|
64
|
-
|
65
90
|
def importmap
|
66
91
|
@importmap ||= File.read(@importmap_path)
|
67
92
|
end
|
93
|
+
|
94
|
+
|
95
|
+
def ensure_vendor_directory_exists
|
96
|
+
FileUtils.mkdir_p @vendor_path
|
97
|
+
end
|
98
|
+
|
99
|
+
def remove_existing_package_file(package)
|
100
|
+
FileUtils.rm_rf vendored_package_path(package)
|
101
|
+
end
|
102
|
+
|
103
|
+
def remove_package_from_importmap(package)
|
104
|
+
all_lines = File.readlines(@importmap_path)
|
105
|
+
with_lines_removed = all_lines.select { |line| line !~ /pin "#{package}"/ }
|
106
|
+
|
107
|
+
File.open(@importmap_path, "w") do |file|
|
108
|
+
with_lines_removed.each { |line| file.write(line) }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def download_package_file(package, url)
|
113
|
+
response = Net::HTTP.get_response(URI(url))
|
114
|
+
|
115
|
+
if response.code == "200"
|
116
|
+
save_vendored_package(package, response.body)
|
117
|
+
else
|
118
|
+
handle_failure_response(response)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def save_vendored_package(package, source)
|
123
|
+
File.open(vendored_package_path(package), "w+") do |vendored_package|
|
124
|
+
vendored_package.write remove_sourcemap_comment_from(source).force_encoding("UTF-8")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def remove_sourcemap_comment_from(source)
|
129
|
+
source.gsub(/^\/\/# sourceMappingURL=.*/, "")
|
130
|
+
end
|
131
|
+
|
132
|
+
def vendored_package_path(package)
|
133
|
+
@vendor_path.join(package_filename(package))
|
134
|
+
end
|
135
|
+
|
136
|
+
def package_filename(package)
|
137
|
+
package.gsub("/", "--") + ".js"
|
138
|
+
end
|
139
|
+
|
140
|
+
def extract_package_version_from(url)
|
141
|
+
url.match(/@\d+\.\d+\.\d+/)&.to_a&.first
|
142
|
+
end
|
68
143
|
end
|
data/lib/importmap/version.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
#
|
2
|
-
# pin "@rails/activestorage", to: "activestorage.esm.js"
|
1
|
+
# Pin npm packages by running ./bin/importmap
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
pin "application"
|
3
|
+
pin "application", preload: true
|
data/lib/install/install.rb
CHANGED
@@ -14,9 +14,14 @@ create_file Rails.root.join("app/javascript/application.js") do <<-JS
|
|
14
14
|
JS
|
15
15
|
end
|
16
16
|
|
17
|
+
say "Use vendor/javascript for downloaded pins"
|
18
|
+
empty_directory "vendor/javascript"
|
19
|
+
keep_file "vendor/javascript"
|
20
|
+
|
17
21
|
if (sprockets_manifest_path = Rails.root.join("app/assets/config/manifest.js")).exist?
|
18
22
|
say "Ensure JavaScript files are in the Sprocket manifest"
|
19
|
-
append_to_file sprockets_manifest_path,
|
23
|
+
append_to_file sprockets_manifest_path,
|
24
|
+
%(//= link_tree ../../javascript .js\n//= link_tree ../../../vendor/javascript .js\n)
|
20
25
|
end
|
21
26
|
|
22
27
|
say "Configure importmap paths in config/importmap.rb"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: importmap-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 6.0.0
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email: david@loudthinking.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- README.md
|
35
35
|
- Rakefile
|
36
36
|
- app/assets/javascripts/es-module-shims.js
|
37
|
+
- app/assets/javascripts/es-module-shims.min.js
|
37
38
|
- app/helpers/importmap/importmap_tags_helper.rb
|
38
39
|
- lib/importmap-rails.rb
|
39
40
|
- lib/importmap/commands.rb
|
@@ -53,7 +54,7 @@ licenses:
|
|
53
54
|
metadata:
|
54
55
|
homepage_uri: https://github.com/rails/importmap-rails
|
55
56
|
source_code_uri: https://github.com/rails/importmap-rails
|
56
|
-
post_install_message:
|
57
|
+
post_install_message:
|
57
58
|
rdoc_options: []
|
58
59
|
require_paths:
|
59
60
|
- lib
|
@@ -61,15 +62,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
62
|
requirements:
|
62
63
|
- - ">="
|
63
64
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
65
|
+
version: 2.7.0
|
65
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
67
|
requirements:
|
67
68
|
- - ">="
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: '0'
|
70
71
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
72
|
-
signing_key:
|
72
|
+
rubygems_version: 3.2.22
|
73
|
+
signing_key:
|
73
74
|
specification_version: 4
|
74
75
|
summary: Use ESM with importmap to manage modern JavaScript in Rails without transpiling
|
75
76
|
or bundling.
|