importmap-rails 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6bef1930a7817f62361604877196991706c6dd6ac589d41fb615bb3cd21cdb6
4
- data.tar.gz: 7cd5da364f95e8ea04104e57d22c42e9fe1351451a51d22fa1247456dda6fa10
3
+ metadata.gz: 5ff9e12c3e3daaf05a7de52415d5147fc030efd2ad0cd170eb60a13c0227bb72
4
+ data.tar.gz: '09d07386cd7f80d6f34d369e530276125e6a5361577896bc847d7968a9f158a6'
5
5
  SHA512:
6
- metadata.gz: e3e7e6e12f99afc8d69756142f5c1fa8945d541489d5950cdf36adeb8b7f6dcf5c8b7924b64b8a4d003bcef16bf2522fb435da54b3c74afdd4d2db88c838c54e
7
- data.tar.gz: b8c8b2ab0472abb4c7eac50ad4c2a858d4210939438e095b367608323ae72b08e514075e12846282020ae98f1664d61e2e826c214441d442cecfda9b6c10b765
6
+ metadata.gz: 5be65a22e79a2d7bff6b317d1a162dbdc9be2f0fb05449c7675a6c9583a2b578e2e07265bf9fefa1a404a92053dd02f019d705b5b2793184f5e35f28b48a1235
7
+ data.tar.gz: 32875269eb69d4b1fed15d6d93831dae419354b13e46b2a0edb26b041b403f6e77f4f95169955aa8cda540c8d3d253f49ab0fd2a1a6b8b43e8313a947943ae12
data/README.md CHANGED
@@ -29,11 +29,11 @@ It's in `app/javascript/application.js` you setup your application by importing
29
29
  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
30
 
31
31
 
32
- ## Using node modules via JavaScript CDNs
32
+ ## Using npm packages via JavaScript CDNs
33
33
 
34
- Importmap for Rails is designed to be used with JavaScript CDNs for your node package dependencies. The CDNs provide pre-compiled distribution versions ready to use, and offer a fast, efficient way of serving them.
34
+ 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
35
 
36
- You can use the `./bin/importmap` command that's added as part of the install to pin, unpin, or update node 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).
36
+ 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
37
 
38
38
  It works like so:
39
39
 
@@ -48,7 +48,7 @@ Pinning "scheduler" to https://ga.jspm.io/npm:scheduler@0.20.2/index.js
48
48
 
49
49
  {
50
50
  "imports": {
51
- "application": "/application.js",
51
+ "application": "/assets/application-37f365cbecf1fa2810a8303f4b6571676fa1f9c56c248528bc14ddb857531b95.js",
52
52
  "react": "https://ga.jspm.io/npm:react@17.0.2/index.js",
53
53
  "react-dom": "https://ga.jspm.io/npm:react-dom@17.0.2/index.js",
54
54
  "object-assign": "https://ga.jspm.io/npm:object-assign@4.1.1/index.js",
@@ -110,28 +110,46 @@ pin "react", to: "https://cdn.skypack.dev/react"
110
110
  ```
111
111
 
112
112
 
113
- ## What if I don't like to use a JavaScript CDN?
113
+ ## Downloading vendor files from the JavaScript CDN
114
114
 
115
- You always have the option to simply download the compiled JavaScript packages from the CDNs, and saving them locally in your application. You can put such files in app/javascript/vendor, and then reference them with local pins, like:
115
+ 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:
116
+
117
+ ```bash
118
+ ./bin/importmap pin react --download
119
+ Pinning "react" to vendor/react.js via download from https://ga.jspm.io/npm:react@17.0.2/index.js
120
+ Pinning "object-assign" to vendor/object-assign.js via download from https://ga.jspm.io/npm:object-assign@4.1.1/index.js
121
+ ```
122
+
123
+ This will produce pins in your `config/importmap.rb` like so:
116
124
 
117
125
  ```ruby
118
- # config/importmap.rb
119
- pin "react", to: "vendor/react@17.0.2.js"
126
+ pin "react", to: "vendor/react.js" # https://ga.jspm.io/npm:react@17.0.2/index.js
127
+ pin "object-assign", to: "vendor/object-assign.js" # https://ga.jspm.io/npm:object-assign@4.1.1/index.js
128
+ ```
129
+
130
+ The packages are downloaded to `app/javascript/vendor`, which you can check into your source control, and they'll be available through your application's own asset pipeline serving.
131
+
132
+ If you later wish to remove a downloaded pin, you again pass `--download`:
133
+
134
+ ```bash
135
+ ./bin/importmap unpin react --download
136
+ Unpinning and removing "react"
137
+ Unpinning and removing "object-assign"
120
138
  ```
121
139
 
122
- But using a JavaScript CDN is fast, secure, and easier to deal with. Start there.
140
+ Just like with a normal pin, you can also update a pin by running the `pin --download` command again.
123
141
 
124
142
 
125
143
  ## Preloading pinned modules
126
144
 
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, we use [modulepreload links](https://developers.google.com/web/updates/2017/12/modulepreload). Pinned modules are preloaded by default, but you can turn this off with `preload: false`.
145
+ 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
146
 
129
147
  Example:
130
148
 
131
149
  ```ruby
132
150
  # 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", preload: false
151
+ pin "@github/hotkey", to: "https://ga.jspm.io/npm:@github/hotkey@1.4.4/dist/index.js", preload: true
152
+ pin "md5", to: "https://cdn.jsdelivr.net/npm/md5@2.3.0/md5.js"
135
153
 
136
154
  # app/views/layouts/application.html.erb
137
155
  <%= javascript_importmap_tags %>
@@ -153,8 +171,8 @@ You can combine multiple import maps by drawing their definitions onto the `Rail
153
171
  module MyEngine
154
172
  class Engine < ::Rails::Engine
155
173
  # ...
156
- initializer "my-engine.importmap" do |app|
157
- app.config.importmap.draw(Engine.root.join("config/importmap.rb"))
174
+ initializer "my-engine.importmap", after: "importmap" do |app|
175
+ app.importmap.draw(Engine.root.join("config/importmap.rb"))
158
176
  end
159
177
  end
160
178
  end
@@ -169,9 +187,9 @@ pin_all_from File.expand_path("../app/assets/javascripts", __dir__)
169
187
  ```
170
188
 
171
189
 
172
- ## Include a digest of the import map in your etag
190
+ ## Include a digest of the import map in your ETag
173
191
 
174
- If you're using etags generated by Rails helpers like `stale?` or `fresh_when`, you need to include the digest of the import map into this calculation. Otherwise your application will return 302 cache responses even when your JavaScript assets have changed. You can avoid this with something like:
192
+ If you're using [ETags](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) generated by Rails helpers like `stale?` or `fresh_when`, you need to include the digest of the import map into this calculation. Otherwise your application will return 302 cache responses even when your JavaScript assets have changed. You can avoid this with something like:
175
193
 
176
194
  ```ruby
177
195
  class ApplicationController < ActionController::Base
@@ -182,23 +200,28 @@ end
182
200
 
183
201
  ## Sweeping the cache in development and test
184
202
 
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`. If you're pinning local files from outside of `app/javascript`, you'll need to restart your development server upon changes.
203
+ 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`.
204
+
205
+ 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
206
 
207
+ ```ruby
208
+ if Rails.env.development?
209
+ Rails.application.importmap.cache_sweeper watches: [
210
+ Rails.application.root.join("app/javascript"),
211
+ MyEngine::Engine.root.join("app/assets/javascripts"),
212
+ ]
213
+ end
214
+ ```
187
215
 
188
216
  ## Expected errors from using the es-module-shim
189
217
 
190
218
  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
219
 
220
+ 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
221
 
193
222
  ## Turning off the shim
194
223
 
195
- 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. If 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
-
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
-
224
+ 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.
202
225
 
203
226
  ## License
204
227
 
@@ -1,4 +1,4 @@
1
- /* ES Module Shims 1.0.0 */
1
+ /* ES Module Shims 1.2.0 */
2
2
  (function () {
3
3
 
4
4
  const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
@@ -199,9 +199,9 @@
199
199
  const esmsInitOptions$1 = optionsScript ? JSON.parse(optionsScript.innerHTML) : self.esmsInitOptions ? self.esmsInitOptions : {};
200
200
 
201
201
  let shimMode = !!esmsInitOptions$1.shimMode;
202
- const resolveHook = shimMode && esmsInitOptions$1.resolve;
202
+ const resolveHook = globalHook(shimMode && esmsInitOptions$1.resolve);
203
203
 
204
- const skip = esmsInitOptions$1.skip ? new RegExp(esmsInitOptions$1.skip) : /^https:\/\/(cdn\.skypack\.dev|jspm\.dev)\//;
204
+ const skip = esmsInitOptions$1.skip ? new RegExp(esmsInitOptions$1.skip) : null;
205
205
 
206
206
  let nonce = esmsInitOptions$1.nonce;
207
207
 
@@ -211,12 +211,16 @@
211
211
  nonce = nonceElement.getAttribute('nonce');
212
212
  }
213
213
 
214
- const {
215
- fetchHook = fetch,
216
- onerror = noop,
217
- revokeBlobURLs,
218
- noLoadEventRetriggers,
219
- } = esmsInitOptions$1;
214
+ const onerror = globalHook(esmsInitOptions$1.onerror || noop);
215
+ const onpolyfill = globalHook(esmsInitOptions$1.onpolyfill || noop);
216
+
217
+ const { revokeBlobURLs, noLoadEventRetriggers } = esmsInitOptions$1;
218
+
219
+ const fetchHook = esmsInitOptions$1.fetch ? globalHook(esmsInitOptions$1.fetch) : fetch;
220
+
221
+ function globalHook (name) {
222
+ return typeof name === 'string' ? self[name] : name;
223
+ }
220
224
 
221
225
  const enable = Array.isArray(esmsInitOptions$1.polyfillEnable) ? esmsInitOptions$1.polyfillEnable : [];
222
226
  const cssModulesEnabled = enable.includes('css-modules');
@@ -283,21 +287,21 @@
283
287
  jsonModulesEnabled && dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, noop),
284
288
  new Promise(resolve => {
285
289
  self._$s = v => {
286
- document.body.removeChild(iframe);
290
+ document.head.removeChild(iframe);
287
291
  if (v) supportsImportMaps = true;
288
292
  delete self._$s;
289
293
  resolve();
290
294
  };
291
295
  const iframe = document.createElement('iframe');
292
296
  iframe.style.display = 'none';
293
- document.body.appendChild(iframe);
297
+ document.head.appendChild(iframe);
294
298
  // we use document.write here because eg Weixin built-in browser doesn't support setting srcdoc
295
299
  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
300
  })
297
301
  ]);
298
302
  });
299
303
 
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}
304
+ let e,r,a,s=4194304;const i=1===new Uint8Array(new Uint16Array([1]).buffer)[0];let t,c$1;function parse(c,b="@"){if(t=c,t.length>s||!e){for(;t.length>s;)s*=2;r=new ArrayBuffer(4*s),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),f=new e.Uint16Array(a),n=816;function u(e){e=e|0;var r=0,a=0,c=0,u=0,l=0;l=n;n=n+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)?B(e+4|0,120,112,111,114,116)|0:0)?(b(),(s[589]|0)==0):0){c=9;break e}else c=17;break}case 105:{if(T(a)|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(i[e+4>>1]|0){case 47:{H();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)?B(e+4|0,120,112,111,114,116)|0:0){b();c=74;}else c=74;break}case 105:{if(T(r)|0?B(e+4|0,109,112,111,114,116)|0:0){k();c=74;}else c=74;break}case 99:{if((T(r)|0?D(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:{H();break r}case 42:{p(1);break r}default:{r=t[15]|0;a=i[r>>1]|0;a:do{if(!(m(a)|0)){switch(a<<16>>16){case 41:if(M(t[(t[17]|0)+(f[292]<<2)>>2]|0)|0){c=71;break a}else {c=68;break a}case 125:break;default:{c=68;break a}}e=f[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);n=l;return e|0}function b(){var e=0,r=0,a=0,c=0,f=0,n=0;f=t[18]|0;n=f+12|0;t[18]=n;r=w(1)|0;e=t[18]|0;if(!((e|0)==(n|0)?!(E(r)|0):0))c=3;e:do{if((c|0)==3){r:do{switch(r<<16>>16){case 100:{K(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(D(e+2|0,108,97,115,115)|0?(a=e+10|0,G(i[a>>1]|0)|0):0){t[18]=a;f=w(1)|0;n=t[18]|0;J(f)|0;K(n,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){J(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;}n=t[18]|0;J(e)|0;K(n,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;n=w(1)|0;e=t[18]|0;switch((J(n)|0)<<16>>16){case 91:case 123:{c=15;break r}default:{}}r=t[18]|0;if((r|0)==(e|0))break e;K(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?L(e+2|0,114,111,109)|0:0){t[18]=e+8;l(f,w(1)|0);break}t[18]=e+-2;}}while(0);return}function k(){var e=0,r=0,a=0,c=0,f=0;f=t[18]|0;r=f+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]=f;if((i[t[15]>>1]|0)!=46){A(f,(t[18]|0)+2|0,0,f);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:{f=t[18]|0;t[(t[8]|0)+4>>2]=f;t[18]=f+2;w(1)|0;f=t[18]|0;a=t[8]|0;t[a+16>>2]=f;s[a+24>>0]=1;t[18]=f+-2;break e}case 41:{i[292]=(i[292]|0)+-1<<16>>16;a=t[18]|0;f=t[8]|0;t[f+4>>2]=a;t[f+12>>2]=a;s[f+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,L(e+2|0,101,116,97)|0):0)?(i[t[15]>>1]|0)!=46:0)A(f,f,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(f,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?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();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=J(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=z(e+-4|0,118,111)|0;break e}case 108:{e=q(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=P(e+-4|0,100,101,108,101)|0;break e}default:{e=0;break e}}switch(i[e+-4>>1]|0){case 108:{e=F(e+-6|0,101)|0;break e}case 97:{e=F(e+-6|0,99)|0;break e}default:{e=0;break e}}}case 102:{if((i[e+-2>>1]|0)==111?(i[e+-4>>1]|0)==101:0)switch(i[e+-6>>1]|0){case 99:{e=S(e+-8|0,105,110,115,116,97,110)|0;break e}case 112:{e=z(e+-8|0,116,121)|0;break e}default:{e=0;break e}}else e=0;break}case 110:{e=e+-2|0;if(F(e,105)|0)e=1;else e=O(e,114,101,116,117,114)|0;break}case 111:{e=F(e+-2|0,100)|0;break}case 114:{e=U(e+-2|0,100,101,98,117,103,103,101)|0;break}case 116:{e=P(e+-2|0,97,119,97,105)|0;break}case 119:switch(i[e+-2>>1]|0){case 101:{e=F(e+-4|0,110)|0;break e}case 111:{e=q(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(R(r)|0)break;else break e;else switch(i[a+2>>1]|0){case 47:{H();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,f=0;c=t[13]|0;t[13]=c+32;f=t[8]|0;t[((f|0)==0?16:f+28|0)>>2]=c;t[9]=f;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,f,n){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;c=c|0;f=f|0;n=n|0;if((((((i[e+12>>1]|0)==n<<16>>16?(i[e+10>>1]|0)==f<<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=P(e+-2|0,99,97,116,99)|0;break}case 121:{e=S(e+-2|0,102,105,110,97,108,108)|0;break}case 101:{e=q(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,f=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){f=8;break}c=r;}if((f|0)==8){t[18]=r;r=c+4|0;}t[18]=r;return}function x(e,r,a,s,t,c,f){e=e|0;r=r|0;a=a|0;s=s|0;t=t|0;c=c|0;f=f|0;if(((((i[e+10>>1]|0)==f<<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 U(e,r,a,s,c,f,n,u){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;f=f|0;n=n|0;u=u|0;var b=0,k=0;k=e+-12|0;b=t[3]|0;if(k>>>0>=b>>>0?C(k,r,a,s,c,f,n,u)|0:0)if((k|0)==(b|0))b=1;else b=G(i[e+-14>>1]|0)|0;else b=0;return b|0}function E(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 m(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 S(e,r,a,s,c,f,n){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;f=f|0;n=n|0;var u=0,b=0;b=e+-10|0;u=t[3]|0;if(b>>>0>=u>>>0?x(b,r,a,s,c,f,n)|0:0)if((b|0)==(u|0))u=1;else u=G(i[e+-12>>1]|0)|0;else u=0;return u|0}function O(e,r,a,s,c,f){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;f=f|0;var n=0,u=0;u=e+-8|0;n=t[3]|0;if(u>>>0>=n>>>0?B(u,r,a,s,c,f)|0:0)if((u|0)==(n|0))n=1;else n=G(i[e+-10>>1]|0)|0;else n=0;return n|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;J(r)|0;r=t[18]|0;s=w(1)|0;a=t[18]|0;}if((a|0)!=(e|0))K(e,r);return s|0}function j(e){e=e|0;var r=0,a=0,s=0,c=0;a=n;n=n+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;n=a;return r|0}function B(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 P(e,r,a,s,c){e=e|0;r=r|0;a=a|0;s=s|0;c=c|0;var f=0,n=0;n=e+-6|0;f=t[3]|0;if(n>>>0>=f>>>0?D(n,r,a,s,c)|0:0)if((n|0)==(f|0))f=1;else f=G(i[e+-8>>1]|0)|0;else f=0;return f|0}function q(e,r,a,s){e=e|0;r=r|0;a=a|0;s=s|0;var c=0,f=0;f=e+-4|0;c=t[3]|0;if(f>>>0>=c>>>0?L(f,r,a,s)|0:0)if((f|0)==(c|0))c=1;else c=G(i[e+-6>>1]|0)|0;else c=0;return c|0}function z(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?Q(c,r,a)|0:0)if((c|0)==(s|0))s=1;else s=G(i[e+-4>>1]|0)|0;else s=0;return s|0}function D(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 F(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=G(i[e+-2>>1]|0)|0;else a=0;return a|0}function G(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&(E(e)|0);}}while(0);return e|0}function H(){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 J(e){e=e|0;while(1){if(_(e)|0)break;if(E(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 K(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 L(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 M(e){e=e|0;if(!(O(e,119,104,105,108,101)|0)?!(q(e,102,111,114)|0):0)e=z(e,105,102)|0;else e=1;return e|0}function N(){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 Q(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 R(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=G(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=n;n=n+e|0;n=n+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 fe(){return c[(t[6]|0)+24>>0]|0|0}function ne(e){e=e|0;t[3]=e;return}function ue(){return (s[589]|0)!=0|0}function be(){return t[14]|0}return {ai:V,e:be,ee:ie,es:ce,f:ue,id:N,ie:se,ip:fe,is:te,p:u,re:X,ri:W,sa:j,se:ee,ses:ne,ss:re,sta:Y}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},{},r),a=e.sta(2*s);}const k=t.length+1;if(e.ses(a),e.sa(k-1),(i?n:f)(t,new Uint16Array(r,a,k)),!e.p())throw Object.assign(new Error(`Parse error ${b}:${t.slice(0,e.e()).split("\n").length}:${e.e()-t.lastIndexOf("\n",e.e()-1)}`),{idx:e.e()});const l=[],o=[];for(;e.ri();){const r=e.is(),a=e.ie(),s=e.ai(),i=e.id(),c=e.ss(),f=e.se();let n;e.ip()&&(n=u(-1===i?r:r+1,t.charCodeAt(-1===i?r-1:r))),l.push({n:n,s:r,e:a,ss:c,se:f,d:i,a:s});}for(;e.re();)o.push(t.slice(e.es(),e.ee()));return [l,o,!!e.f()]}function f(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 n(e,r){const a=e.length;let s=0;for(;s<a;)r[s]=e.charCodeAt(s++);}function u(e,r){c$1=e;let a="",s=c$1;for(;;){c$1>=t.length&&syntaxError();const e=t.charCodeAt(c$1);if(e===r)break;92===e?(a+=t.slice(s,c$1),a+=b(),s=c$1):(8232===e||8233===e||l(e)&&syntaxError(),++c$1);}return a+=t.slice(s,c$1++),a}function b(){let e=t.charCodeAt(++c$1);switch(++c$1,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(k(2));case 117:return function(){let e;123===t.charCodeAt(c$1)?(++c$1,e=k(t.indexOf("}",c$1)-c$1),++c$1,e>1114111&&syntaxError()):e=k(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:syntaxError();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||syntaxError(),String.fromCharCode(a)}return l(e)?"":String.fromCharCode(e)}}function k(e){const r=c$1;let a=0,s=0;for(let r=0;r<e;++r,++c$1){let e,i=t.charCodeAt(c$1);if(95!==i){if(i>=97)e=i-97+10;else if(i>=65)e=i-65+10;else {if(!(i>=48&&i<=57))break;e=i-48;}if(e>=16)break;s=i,a=16*a+e;}else 95!==s&&0!==r||syntaxError(),s=i;}return 95!==s&&c$1-r===e||syntaxError(),a}function l(e){return 13===e||10===e}
301
305
 
302
306
  async function defaultResolve (id, parentUrl) {
303
307
  return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl);
@@ -329,22 +333,57 @@
329
333
 
330
334
  let importMap = { imports: {}, scopes: {} };
331
335
  let importMapSrcOrLazy = false;
332
- let importMapPromise = featureDetectionPromise.then(() => undefined);
336
+ let baselinePassthrough;
333
337
 
334
- let acceptingImportMaps = true;
335
- let nativeAcceptingImportMaps = true;
336
- async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
337
- if (acceptingImportMaps) {
338
- if (!shimMode) {
339
- acceptingImportMaps = false;
340
- }
341
- else {
342
- nativeAcceptingImportMaps = false;
338
+ const initPromise = featureDetectionPromise.then(() => {
339
+ // shim mode is determined on initialization, no late shim mode
340
+ if (!shimMode) {
341
+ let seenScript = false;
342
+ for (const script of document.querySelectorAll('script[type="module-shim"],script[type="importmap-shim"],script[type="module"],script[type="importmap"]')) {
343
+ if (!seenScript && script.type === 'module')
344
+ seenScript = true;
345
+ if (script.type.endsWith('-shim')) {
346
+ setShimMode();
347
+ break;
348
+ }
349
+ if (seenScript && script.type === 'importmap') {
350
+ importMapSrcOrLazy = true;
351
+ break;
352
+ }
343
353
  }
344
354
  }
355
+ baselinePassthrough = supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false;
356
+ if (!baselinePassthrough) onpolyfill();
357
+ if (shimMode || !baselinePassthrough) {
358
+ new MutationObserver(mutations => {
359
+ for (const mutation of mutations) {
360
+ if (mutation.type !== 'childList') continue;
361
+ for (const node of mutation.addedNodes) {
362
+ if (node.tagName === 'SCRIPT') {
363
+ if (!shimMode && node.type === 'module' || shimMode && node.type === 'module-shim')
364
+ processScript(node);
365
+ if (!shimMode && node.type === 'importmap' || shimMode && node.type === 'importmap-shim')
366
+ processImportMap(node);
367
+ }
368
+ else if (node.tagName === 'LINK' && node.rel === 'modulepreload')
369
+ processPreload(node);
370
+ }
371
+ }
372
+ }).observe(document, { childList: true, subtree: true });
373
+ processImportMaps();
374
+ processScriptsAndPreloads();
375
+ return undefined;
376
+ }
377
+ });
378
+ let importMapPromise = initPromise;
379
+
380
+ let acceptingImportMaps = true;
381
+ async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
382
+ if (!shimMode)
383
+ acceptingImportMaps = false;
345
384
  await importMapPromise;
346
385
  // early analysis opt-out - no need to even fetch if we have feature support
347
- if (!shimMode && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false) {
386
+ if (!shimMode && baselinePassthrough) {
348
387
  // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
349
388
  if (nativelyLoaded)
350
389
  return null;
@@ -390,7 +429,13 @@
390
429
  }
391
430
 
392
431
  async function importShim (id, parentUrl = baseUrl, _assertion) {
393
- processScripts();
432
+ // needed for shim check
433
+ await initPromise;
434
+ if (acceptingImportMaps || shimMode || !baselinePassthrough) {
435
+ processImportMaps();
436
+ if (!shimMode)
437
+ acceptingImportMaps = false;
438
+ }
394
439
  await importMapPromise;
395
440
  return topLevelLoad((await resolve(id, parentUrl)).r || throwUnresolved(id, parentUrl), { credentials: 'same-origin' });
396
441
  }
@@ -400,7 +445,6 @@
400
445
  const meta = {};
401
446
 
402
447
  async function importMetaResolve (id, parentUrl = this.url) {
403
- await importMapPromise;
404
448
  return (await resolve(id, `${parentUrl}`)).r || throwUnresolved(id, parentUrl);
405
449
  }
406
450
 
@@ -603,12 +647,12 @@
603
647
  load.n = true;
604
648
  if (!n) return;
605
649
  const { r, b } = await resolve(n, load.r || load.u);
606
- if (b && !supportsImportMaps)
650
+ if (b && (!supportsImportMaps || importMapSrcOrLazy))
607
651
  load.n = true;
608
652
  if (d !== -1) return;
609
653
  if (!r)
610
654
  throwUnresolved(n, load.r || load.u);
611
- if (skip.test(r)) return { b: r };
655
+ if (skip && skip.test(r)) return { b: r };
612
656
  if (childFetchOpts.integrity)
613
657
  childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
614
658
  return getOrCreateLoad(r, childFetchOpts).f;
@@ -618,19 +662,16 @@
618
662
  return load;
619
663
  }
620
664
 
621
- function processScripts () {
665
+ function processScriptsAndPreloads () {
666
+ for (const script of document.querySelectorAll(shimMode ? 'script[type="module-shim"]' : 'script[type="module"]'))
667
+ processScript(script);
622
668
  for (const link of document.querySelectorAll('link[rel="modulepreload"]'))
623
669
  processPreload(link);
624
- const scripts = document.querySelectorAll('script[type="module-shim"],script[type="importmap-shim"],script[type="module"],script[type="importmap"]');
625
- // early shim mode opt-in
626
- if (!shimMode) {
627
- for (const script of scripts) {
628
- if (script.type.endsWith('-shim'))
629
- setShimMode();
630
- }
631
- }
632
- for (const script of scripts)
633
- processScript(script);
670
+ }
671
+
672
+ function processImportMaps () {
673
+ for (const script of document.querySelectorAll(shimMode ? 'script[type="importmap-shim"]' : 'script[type="importmap"]'))
674
+ processImportMap(script);
634
675
  }
635
676
 
636
677
  function getFetchOpts (script) {
@@ -656,73 +697,76 @@
656
697
  document.dispatchEvent(new Event('DOMContentLoaded'));
657
698
  }
658
699
  // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
659
- document.addEventListener('DOMContentLoaded', domContentLoadedCheck);
700
+ document.addEventListener('DOMContentLoaded', async () => {
701
+ await initPromise;
702
+ domContentLoadedCheck();
703
+ if (shimMode || !baselinePassthrough) {
704
+ processImportMaps();
705
+ processScriptsAndPreloads();
706
+ }
707
+ });
660
708
 
661
709
  let readyStateCompleteCnt = 1;
662
- if (document.readyState === 'complete')
710
+ if (document.readyState === 'complete') {
663
711
  readyStateCompleteCheck();
664
- else
665
- document.addEventListener('readystatechange', readyStateCompleteCheck);
712
+ }
713
+ else {
714
+ document.addEventListener('readystatechange', async () => {
715
+ processImportMaps();
716
+ await initPromise;
717
+ readyStateCompleteCheck();
718
+ });
719
+ }
666
720
  function readyStateCompleteCheck () {
667
721
  if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
668
722
  document.dispatchEvent(new Event('readystatechange'));
669
723
  }
670
724
 
671
- function processScript (script) {
725
+ function processImportMap (script) {
672
726
  if (script.ep) // ep marker = script processed
673
727
  return;
674
- const shim = script.type.endsWith('-shim');
675
- if (shim && !shimMode) setShimMode();
676
- const type = shimMode ? script.type.slice(0, -5) : script.type;
677
- // dont process module scripts in shim mode or noshim module scripts in polyfill mode
678
- if (!shim && shimMode || script.getAttribute('noshim') !== null)
679
- return;
680
728
  // empty inline scripts sometimes show before domready
681
729
  if (!script.src && !script.innerHTML)
682
730
  return;
683
731
  script.ep = true;
684
- if (type === 'module') {
685
- // does this load block readystate complete
686
- const isReadyScript = readyStateCompleteCnt > 0;
687
- // does this load block DOMContentLoaded
688
- const isDomContentLoadedScript = domContentLoadedCnt > 0;
689
- if (isReadyScript) readyStateCompleteCnt++;
690
- if (isDomContentLoadedScript) domContentLoadedCnt++;
691
- const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isReadyScript && lastStaticLoadPromise).then(() => {
692
- if (!noLoadEventRetriggers)
693
- triggerLoadEvent(script);
694
- }).catch(e => {
695
- if (!noLoadEventRetriggers)
696
- triggerLoadEvent(script);
697
- // setTimeout(() => { throw e; });
698
- onerror(e);
699
- });
700
- if (isReadyScript)
701
- lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
702
- if (isDomContentLoadedScript)
703
- loadPromise.then(domContentLoadedCheck);
732
+ // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
733
+ if (script.src) {
734
+ if (!shimMode)
735
+ return;
736
+ importMapSrcOrLazy = true;
704
737
  }
705
- else if (acceptingImportMaps && type === 'importmap') {
706
- // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
707
- if (script.src || !nativeAcceptingImportMaps) {
708
- if (!shimMode)
709
- return;
710
- importMapSrcOrLazy = true;
711
- }
712
- if (!shimMode) {
713
- acceptingImportMaps = false;
714
- }
715
- else {
716
- nativeAcceptingImportMaps = false;
717
- }
738
+ if (acceptingImportMaps) {
718
739
  importMapPromise = importMapPromise.then(async () => {
719
740
  importMap = resolveAndComposeImportMap(script.src ? await (await fetchHook(script.src)).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
720
741
  });
742
+ if (!shimMode)
743
+ acceptingImportMaps = false;
721
744
  }
722
745
  }
723
746
 
724
- function triggerLoadEvent (script) {
725
- script.dispatchEvent(new Event('load'));
747
+ function processScript (script) {
748
+ if (script.ep) // ep marker = script processed
749
+ return;
750
+ if (script.getAttribute('noshim') !== null)
751
+ return;
752
+ // empty inline scripts sometimes show before domready
753
+ if (!script.src && !script.innerHTML)
754
+ return;
755
+ script.ep = true;
756
+ // does this load block readystate complete
757
+ const isReadyScript = readyStateCompleteCnt > 0;
758
+ // does this load block DOMContentLoaded
759
+ const isDomContentLoadedScript = domContentLoadedCnt > 0;
760
+ if (isReadyScript) readyStateCompleteCnt++;
761
+ if (isDomContentLoadedScript) domContentLoadedCnt++;
762
+ const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isReadyScript && lastStaticLoadPromise).catch(e => {
763
+ setTimeout(() => { throw e });
764
+ onerror(e);
765
+ });
766
+ if (isReadyScript)
767
+ lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
768
+ if (isDomContentLoadedScript)
769
+ loadPromise.then(domContentLoadedCheck);
726
770
  }
727
771
 
728
772
  const fetchCache = {};
@@ -735,22 +779,8 @@
735
779
  fetchCache[link.href] = doFetch(link.href, getFetchOpts(link));
736
780
  }
737
781
 
738
- new MutationObserver(mutations => {
739
- for (const mutation of mutations) {
740
- if (mutation.type !== 'childList') continue;
741
- for (const node of mutation.addedNodes) {
742
- if (node.tagName === 'SCRIPT' && node.type)
743
- processScript(node);
744
- else if (node.tagName === 'LINK' && node.rel === 'modulepreload')
745
- processPreload(node);
746
- }
747
- }
748
- }).observe(document, { childList: true, subtree: true });
749
-
750
782
  function throwUnresolved (id, parentUrl) {
751
783
  throw Error("Unable to resolve specifier '" + id + (parentUrl ? "' from " + parentUrl : "'"));
752
784
  }
753
785
 
754
- processScripts();
755
-
756
- }());
786
+ }());
@@ -0,0 +1 @@
1
+ (function(){const e=navigator.userAgent.match(/Edge\/\d\d\.\d+$/);let r;function createBlob(e,r="text/javascript"){return URL.createObjectURL(new Blob([e],{type:r}))}const noop=()=>{};const t=document.querySelector("base[href]");t&&(r=t.href);if(!r&&"undefined"!==typeof location){r=location.href.split("#")[0].split("?")[0];const e=r.lastIndexOf("/");-1!==e&&(r=r.slice(0,e+1))}function isURL(e){try{new URL(e);return true}catch{return false}}const s=/\\/g;function resolveIfNotPlainOrUrl(e,r){r=r&&r.split("#")[0].split("?")[0];-1!==e.indexOf("\\")&&(e=e.replace(s,"/"));if("/"===e[0]&&"/"===e[1])return r.slice(0,r.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const t=r.slice(0,r.indexOf(":")+1);let s;if("/"===r[t.length+1])if("file:"!==t){s=r.slice(t.length+2);s=s.slice(s.indexOf("/")+1)}else s=r.slice(8);else s=r.slice(t.length+("/"===r[t.length]));if("/"===e[0])return r.slice(0,r.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 r.slice(0,r.length-s.length)+i.join("")}}function resolveUrl(e,r){return resolveIfNotPlainOrUrl(e,r)||(-1!==e.indexOf(":")?e:resolveIfNotPlainOrUrl("./"+e,r))}function resolveAndComposePackages(e,r,t,s){for(let a in e){const i=resolveIfNotPlainOrUrl(a,t)||a;let c=e[a];if("string"!==typeof c)continue;const oe=resolveImportMap(s,resolveIfNotPlainOrUrl(c,t)||c,t);oe?r[i]=oe:targetWarning(a,e[a],"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,r,t){const s={imports:Object.assign({},t.imports),scopes:Object.assign({},t.scopes)};e.imports&&resolveAndComposePackages(e.imports,s.imports,r,t);if(e.scopes)for(let a in e.scopes){const i=resolveUrl(a,r);resolveAndComposePackages(e.scopes[a],s.scopes[i]||(s.scopes[i]={}),r,t)}return s}function getMatch(e,r){if(r[e])return e;let t=e.length;do{const s=e.slice(0,t+1);if(s in r)return s}while(-1!==(t=e.lastIndexOf("/",t-1)))}function applyPackages(e,r){const t=getMatch(e,r);if(t){const s=r[t];if(null===s)return;if(!(e.length>t.length&&"/"!==s[s.length-1]))return s+e.slice(t.length);targetWarning(t,s,"should have a trailing '/'")}}function targetWarning(e,r,t){console.warn("Package target "+t+", resolving target '"+r+"' for "+e)}function resolveImportMap(e,r,t){let s=t&&getMatch(t,e.scopes);while(s){const t=applyPackages(r,e.scopes[s]);if(t)return t;s=getMatch(s.slice(0,s.lastIndexOf("/")),e.scopes)}return applyPackages(r,e.imports)||-1!==r.indexOf(":")&&r}const a=document.querySelector("script[type=esms-options]");const i=a?JSON.parse(a.innerHTML):self.esmsInitOptions?self.esmsInitOptions:{};let c=!!i.shimMode;const oe=globalHook(c&&i.resolve);const le=i.skip?new RegExp(i.skip):null;let de=i.nonce;if(!de){const e=document.querySelector("script[nonce]");e&&(de=e.getAttribute("nonce"))}const pe=globalHook(i.onerror||noop);const he=globalHook(i.onpolyfill||noop);const{revokeBlobURLs:ke,noLoadEventRetriggers:me}=i;const we=i.fetch?globalHook(i.fetch):fetch;function globalHook(e){return"string"===typeof e?self[e]:e}const ve=Array.isArray(i.polyfillEnable)?i.polyfillEnable:[];const ye=ve.includes("css-modules");const ge=ve.includes("json-modules");function setShimMode(){c=true}let $e;window.addEventListener("error",(e=>$e=e));function dynamicImportScript(e,{errUrl:t=e}={}){$e=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",de);a.setAttribute("noshim","");const i=new Promise(((e,i)=>{a.addEventListener("error",cb);a.addEventListener("load",cb);function cb(){document.head.removeChild(a);if(self._esmsi){e(self._esmsi,r);self._esmsi=void 0}else{i($e.error||new Error(`Error loading or executing the graph of ${t} (check the console for ${s}).`));$e=void 0}}}));document.head.appendChild(a);return i}let Ae=dynamicImportScript;const Se=dynamicImportScript(createBlob("export default u=>import(u)")).then((e=>{e&&(Ae=e.default);return!!e}),noop);let Ce=false;let Le=false;let Ie=false;let Oe=false;let Ue=false;const xe=Promise.resolve(Se).then((e=>{if(e){Ue=true;return Promise.all([Ae(createBlob("import.meta")).then((()=>Ie=true),noop),ye&&Ae(createBlob('import"data:text/css,{}"assert{type:"css"}')).then((()=>Le=true),noop),ge&&Ae(createBlob('import"data:text/json,{}"assert{type:"json"}')).then((()=>Ce=true),noop),new Promise((e=>{self._$s=t=>{document.head.removeChild(r);t&&(Oe=true);delete self._$s;e()};const r=document.createElement("iframe");r.style.display="none";document.head.appendChild(r);r.contentWindow.document.write(`<script type=importmap nonce="${de}">{"imports":{"x":"data:text/javascript,"}}<\/script><script nonce="${de}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<\/script>`)}))])}}));let Pe,Ee,Me,je=4194304;const Re=1===new Uint8Array(new Uint16Array([1]).buffer)[0];let _e,Be;function parse(e,r="@"){if(_e=e,_e.length>je||!Pe){for(;_e.length>je;)je*=2;Ee=new ArrayBuffer(4*je),Pe=function(e,r,t){"use asm";var s=new e.Int8Array(t),a=new e.Int16Array(t),i=new e.Int32Array(t),c=new e.Uint8Array(t),oe=new e.Uint16Array(t),le=816;function u(e){e=e|0;var r=0,t=0,c=0,de=0,pe=0;pe=le;le=le+14336|0;de=pe;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]=pe+10240;i[17]=pe+2048;s[591]=0;e=(i[3]|0)+-2|0;i[18]=e;r=e+(i[12]<<1)|0;i[19]=r;e:while(1){t=e+2|0;i[18]=t;if(e>>>0>=r>>>0){c=18;break}r: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?T(t)|0:0)?B(e+4|0,120,112,111,114,116)|0:0)?(b(),(s[589]|0)==0):0){c=9;break e}else c=17;break}case 105:{if(T(t)|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:{H();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;i[15]=i[18]}e=i[18]|0;r=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=t;c=19}else e=0;do{if((c|0)==19){e:while(1){r=e+2|0;i[18]=r;t=r;if(e>>>0>=(i[19]|0)>>>0){c=75;break}r: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?T(r)|0:0)?B(e+4|0,120,112,111,114,116)|0:0){b();c=74}else c=74;break}case 105:{if(T(r)|0?B(e+4|0,109,112,111,114,116)|0:0){k();c=74}else c=74;break}case 99:{if((T(r)|0?D(e+4|0,108,97,115,115)|0:0)?_(a[e+12>>1]|0)|0:0){s[591]=1;c=74}else c=74;break}case 40:{r=i[15]|0;t=i[17]|0;c=a[292]|0;a[292]=c+1<<16>>16;i[t+((c&65535)<<2)>>2]=r;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){r=e+4|0;if(!(i[r>>2]|0))i[r>>2]=t;i[e+12>>2]=t;i[11]=0;c=74}else c=74;break}case 123:{c=i[15]|0;t=i[8]|0;e=c;do{if((a[c>>1]|0)==41&(t|0)!=0?(i[t+4>>2]|0)==(c|0):0){r=i[9]|0;i[8]=r;if(!r){i[4]=0;break}else{i[r+28>>2]=0;break}}}while(0);r=a[292]|0;c=r&65535;s[de+c>>0]=s[591]|0;s[591]=0;t=i[17]|0;a[292]=r+1<<16>>16;i[t+(c<<2)>>2]=e;c=74;break}case 125:{e=a[292]|0;if(!(e<<16>>16)){c=49;break e}t=e+-1<<16>>16;a[292]=t;r=a[293]|0;if(e<<16>>16!=r<<16>>16)if(r<<16>>16!=-1&(t&65535)<(r&65535)){c=53;break e}else{c=74;break r}else{t=i[16]|0;c=(a[291]|0)+-1<<16>>16;a[291]=c;a[293]=a[t+((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(a[e+4>>1]|0){case 47:{H();break r}case 42:{p(1);break r}default:{r=i[15]|0;t=a[r>>1]|0;t:do{if(!(m(t)|0)){switch(t<<16>>16){case 41:if(M(i[(i[17]|0)+(oe[292]<<2)>>2]|0)|0){c=71;break t}else{c=68;break t}case 125:break;default:{c=68;break t}}e=oe[292]|0;if(!(g(i[(i[17]|0)+(e<<2)>>2]|0)|0)?(s[de+e>>0]|0)==0:0)c=68;else c=71}else switch(t<<16>>16){case 46:if(((a[r+-2>>1]|0)+-48&65535)<10){c=68;break t}else{c=71;break t}case 43:if((a[r+-2>>1]|0)==43){c=68;break t}else{c=71;break t}case 45:if((a[r+-2>>1]|0)==45){c=68;break t}else{c=71;break t}default:{c=71;break t}}}while(0);t:do{if((c|0)==68){c=0;if(!(o(r)|0)){switch(t<<16>>16){case 0:{c=71;break t}case 47:break;default:{e=1;break t}}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;i[15]=i[18]}e=i[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=(a[293]|0)==-1&(a[292]|0)==0&(s[588]|0)==0;break}}}while(0);le=pe;return e|0}function b(){var e=0,r=0,t=0,c=0,oe=0,le=0;oe=i[18]|0;le=oe+12|0;i[18]=le;r=w(1)|0;e=i[18]|0;if(!((e|0)==(le|0)?!(E(r)|0):0))c=3;e:do{if((c|0)==3){r:do{switch(r<<16>>16){case 100:{K(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(D(e+2|0,108,97,115,115)|0?(t=e+10|0,G(a[t>>1]|0)|0):0){i[18]=t;oe=w(1)|0;le=i[18]|0;J(oe)|0;K(le,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;t=i[18]|0;while(1){J(e)|0;e=i[18]|0;w(1)|0;e=$(t,e)|0;if(e<<16>>16==44){i[18]=(i[18]|0)+2;e=w(1)|0}r=t;t=i[18]|0;if(e<<16>>16==125){c=29;break}if((t|0)==(r|0)){c=26;break}if(t>>>0>(i[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){i[18]=t+2;c=31;break r}break}case 42:{i[18]=e+2;w(1)|0;c=i[18]|0;$(c,c)|0;c=31;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}le=i[18]|0;J(e)|0;K(le,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;r:while(1){i[18]=e+2;le=w(1)|0;e=i[18]|0;switch((J(le)|0)<<16>>16){case 91:case 123:{c=15;break r}default:{}}r=i[18]|0;if((r|0)==(e|0))break e;K(e,r);switch((w(1)|0)<<16>>16){case 61:{c=19;break r}case 44:break;default:{c=20;break r}}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)==31)r=w(1)|0;e=i[18]|0;if(r<<16>>16==102?L(e+2|0,114,111,109)|0:0){i[18]=e+8;l(oe,w(1)|0);break}i[18]=e+-2}}while(0);return}function k(){var e=0,r=0,t=0,c=0,oe=0;oe=i[18]|0;r=oe+12|0;i[18]=r;e:do{switch((w(1)|0)<<16>>16){case 40:{r=i[17]|0;t=a[292]|0;a[292]=t+1<<16>>16;i[r+((t&65535)<<2)>>2]=oe;if((a[i[15]>>1]|0)!=46){A(oe,(i[18]|0)+2|0,0,oe);i[11]=i[8];i[18]=(i[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d();break}case 34:{v();break}default:{i[18]=(i[18]|0)+-2;break e}}i[18]=(i[18]|0)+2;switch((w(1)|0)<<16>>16){case 44:{oe=i[18]|0;i[(i[8]|0)+4>>2]=oe;i[18]=oe+2;w(1)|0;oe=i[18]|0;t=i[8]|0;i[t+16>>2]=oe;s[t+24>>0]=1;i[18]=oe+-2;break e}case 41:{a[292]=(a[292]|0)+-1<<16>>16;t=i[18]|0;oe=i[8]|0;i[oe+4>>2]=t;i[oe+12>>2]=t;s[oe+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,L(e+2|0,101,116,97)|0):0)?(a[i[15]>>1]|0)!=46:0)A(oe,oe,e+8|0,2);break}case 42:case 123:case 39:case 34:{c=16;break}default:if((i[18]|0)!=(r|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;r=i[18]|0;e:while(1){if(r>>>0>=e>>>0){c=23;break}t=a[r>>1]|0;switch(t<<16>>16){case 34:case 39:{c=21;break e}default:{}}c=r+2|0;i[18]=c;r=c}if((c|0)==21){l(oe,t);break}else if((c|0)==23){Z();break}}}while(0);return}function l(e,r){e=e|0;r=r|0;var t=0,s=0;t=(i[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,t,i[18]|0,1);i[18]=(i[18]|0)+2;s=(w(0)|0)<<16>>16==97;r=i[18]|0;if(s?B(r+2|0,115,115,101,114,116)|0:0){i[18]=r+12;if((w(1)|0)<<16>>16!=123){i[18]=r;break}e=i[18]|0;t=e;e:while(1){i[18]=t+2;t=w(1)|0;switch(t<<16>>16){case 39:{d();i[18]=(i[18]|0)+2;t=w(1)|0;break}case 34:{v();i[18]=(i[18]|0)+2;t=w(1)|0;break}default:t=J(t)|0}if(t<<16>>16!=58){s=16;break}i[18]=(i[18]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d();break}case 34:{v();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}t=i[18]|0}if((s|0)==16){i[18]=r;break}else if((s|0)==20){i[18]=r;break}else if((s|0)==24){i[18]=r;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]=r+-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=z(e+-4|0,118,111)|0;break e}case 108:{e=q(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=P(e+-4|0,100,101,108,101)|0;break e}default:{e=0;break e}}switch(a[e+-4>>1]|0){case 108:{e=F(e+-6|0,101)|0;break e}case 97:{e=F(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=S(e+-8|0,105,110,115,116,97,110)|0;break e}case 112:{e=z(e+-8|0,116,121)|0;break e}default:{e=0;break e}}else e=0;break}case 110:{e=e+-2|0;if(F(e,105)|0)e=1;else e=O(e,114,101,116,117,114)|0;break}case 111:{e=F(e+-2|0,100)|0;break}case 114:{e=U(e+-2|0,100,101,98,117,103,103,101)|0;break}case 116:{e=P(e+-2|0,97,119,97,105)|0;break}case 119:switch(a[e+-2>>1]|0){case 101:{e=F(e+-4|0,110)|0;break e}case 111:{e=q(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,t=0;r=i[19]|0;t=i[18]|0;e:while(1){e=t+2|0;if(t>>>0>=r>>>0){r=8;break}switch(a[e>>1]|0){case 96:{r=9;break e}case 36:{if((a[t+4>>1]|0)==123){r=6;break e}break}case 92:{e=t+4|0;break}default:{}}t=e}if((r|0)==6){i[18]=t+4;e=a[293]|0;r=i[16]|0;t=a[291]|0;a[291]=t+1<<16>>16;a[r+((t&65535)<<1)>>1]=e;t=(a[292]|0)+1<<16>>16;a[292]=t;a[293]=t}else if((r|0)==8){i[18]=e;Z()}else if((r|0)==9)i[18]=e;return}function w(e){e=e|0;var r=0,t=0,s=0;t=i[18]|0;e:do{r=a[t>>1]|0;r:do{if(r<<16>>16!=47)if(e)if(_(r)|0)break;else break e;else if(R(r)|0)break;else break e;else switch(a[t+2>>1]|0){case 47:{H();break r}case 42:{p(e);break r}default:{r=47;break e}}}while(0);s=i[18]|0;t=s+2|0;i[18]=t}while(s>>>0<(i[19]|0)>>>0);return r|0}function d(){var e=0,r=0,t=0,s=0;s=i[19]|0;e=i[18]|0;e:while(1){t=e+2|0;if(e>>>0>=s>>>0){e=8;break}r=a[t>>1]|0;switch(r<<16>>16){case 39:{e=9;break e}case 92:{r=e+4|0;if((a[r>>1]|0)==13){e=e+6|0;e=(a[e>>1]|0)==10?e:r}else e=r;break}default:if(ae(r)|0){e=8;break e}else e=t}}if((e|0)==8){i[18]=t;Z()}else if((e|0)==9)i[18]=t;return}function v(){var e=0,r=0,t=0,s=0;s=i[19]|0;e=i[18]|0;e:while(1){t=e+2|0;if(e>>>0>=s>>>0){e=8;break}r=a[t>>1]|0;switch(r<<16>>16){case 34:{e=9;break e}case 92:{r=e+4|0;if((a[r>>1]|0)==13){e=e+6|0;e=(a[e>>1]|0)==10?e:r}else e=r;break}default:if(ae(r)|0){e=8;break e}else e=t}}if((e|0)==8){i[18]=t;Z()}else if((e|0)==9)i[18]=t;return}function A(e,r,t,a){e=e|0;r=r|0;t=t|0;a=a|0;var c=0,oe=0;c=i[13]|0;i[13]=c+32;oe=i[8]|0;i[((oe|0)==0?16:oe+28|0)>>2]=c;i[9]=oe;i[8]=c;i[c+8>>2]=e;do{if(2!=(a|0))if(1==(a|0)){i[c+12>>2]=t+2;break}else{i[c+12>>2]=i[3];break}else i[c+12>>2]=t}while(0);i[c>>2]=r;i[c+4>>2]=t;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 y(){var e=0,r=0,t=0;t=i[19]|0;r=i[18]|0;e:while(1){e=r+2|0;if(r>>>0>=t>>>0){r=6;break}switch(a[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){i[18]=e;Z();e=0}else if((r|0)==7){i[18]=e;e=93}return e|0}function C(e,r,t,s,i,c,oe,le){e=e|0;r=r|0;t=t|0;s=s|0;i=i|0;c=c|0;oe=oe|0;le=le|0;if((((((a[e+12>>1]|0)==le<<16>>16?(a[e+10>>1]|0)==oe<<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)==t<<16>>16:0)r=(a[e>>1]|0)==r<<16>>16;else r=0;return r|0}function g(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=P(e+-2|0,99,97,116,99)|0;break}case 121:{e=S(e+-2|0,102,105,110,97,108,108)|0;break}case 101:{e=q(e+-2|0,101,108,115)|0;break}default:e=0}return e|0}function I(){var e=0,r=0,t=0;e:while(1){e=i[18]|0;r=e+2|0;i[18]=r;if(e>>>0>=(i[19]|0)>>>0){t=7;break}switch(a[r>>1]|0){case 13:case 10:{t=7;break e}case 47:break e;case 91:{y()|0;break}case 92:{i[18]=e+4;break}default:{}}}if((t|0)==7)Z();return}function p(e){e=e|0;var r=0,t=0,s=0,c=0,oe=0;c=(i[18]|0)+2|0;i[18]=c;t=i[19]|0;while(1){r=c+2|0;if(c>>>0>=t>>>0)break;s=a[r>>1]|0;if(!e?ae(s)|0:0)break;if(s<<16>>16==42?(a[c+4>>1]|0)==47:0){oe=8;break}c=r}if((oe|0)==8){i[18]=r;r=c+4|0}i[18]=r;return}function x(e,r,t,s,i,c,oe){e=e|0;r=r|0;t=t|0;s=s|0;i=i|0;c=c|0;oe=oe|0;if(((((a[e+10>>1]|0)==oe<<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)==t<<16>>16:0)r=(a[e>>1]|0)==r<<16>>16;else r=0;return r|0}function U(e,r,t,s,c,oe,le,de){e=e|0;r=r|0;t=t|0;s=s|0;c=c|0;oe=oe|0;le=le|0;de=de|0;var pe=0,he=0;he=e+-12|0;pe=i[3]|0;if(he>>>0>=pe>>>0?C(he,r,t,s,c,oe,le,de)|0:0)if((he|0)==(pe|0))pe=1;else pe=G(a[e+-14>>1]|0)|0;else pe=0;return pe|0}function E(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 m(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 S(e,r,t,s,c,oe,le){e=e|0;r=r|0;t=t|0;s=s|0;c=c|0;oe=oe|0;le=le|0;var de=0,pe=0;pe=e+-10|0;de=i[3]|0;if(pe>>>0>=de>>>0?x(pe,r,t,s,c,oe,le)|0:0)if((pe|0)==(de|0))de=1;else de=G(a[e+-12>>1]|0)|0;else de=0;return de|0}function O(e,r,t,s,c,oe){e=e|0;r=r|0;t=t|0;s=s|0;c=c|0;oe=oe|0;var le=0,de=0;de=e+-8|0;le=i[3]|0;if(de>>>0>=le>>>0?B(de,r,t,s,c,oe)|0:0)if((de|0)==(le|0))le=1;else le=G(a[e+-10>>1]|0)|0;else le=0;return le|0}function $(e,r){e=e|0;r=r|0;var t=0,s=0;t=i[18]|0;s=a[t>>1]|0;if(s<<16>>16==97){i[18]=t+4;r=w(1)|0;e=i[18]|0;J(r)|0;r=i[18]|0;s=w(1)|0;t=i[18]|0}if((t|0)!=(e|0))K(e,r);return s|0}function j(e){e=e|0;var r=0,t=0,s=0,c=0;t=le;le=le+16|0;s=t;i[s>>2]=0;i[12]=e;r=i[3]|0;c=r+(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;le=t;return r|0}function B(e,r,t,s,i,c){e=e|0;r=r|0;t=t|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)==t<<16>>16:0)r=(a[e>>1]|0)==r<<16>>16;else r=0;return r|0}function P(e,r,t,s,c){e=e|0;r=r|0;t=t|0;s=s|0;c=c|0;var oe=0,le=0;le=e+-6|0;oe=i[3]|0;if(le>>>0>=oe>>>0?D(le,r,t,s,c)|0:0)if((le|0)==(oe|0))oe=1;else oe=G(a[e+-8>>1]|0)|0;else oe=0;return oe|0}function q(e,r,t,s){e=e|0;r=r|0;t=t|0;s=s|0;var c=0,oe=0;oe=e+-4|0;c=i[3]|0;if(oe>>>0>=c>>>0?L(oe,r,t,s)|0:0)if((oe|0)==(c|0))c=1;else c=G(a[e+-6>>1]|0)|0;else c=0;return c|0}function z(e,r,t){e=e|0;r=r|0;t=t|0;var s=0,c=0;c=e+-2|0;s=i[3]|0;if(c>>>0>=s>>>0?Q(c,r,t)|0:0)if((c|0)==(s|0))s=1;else s=G(a[e+-4>>1]|0)|0;else s=0;return s|0}function D(e,r,t,s,i){e=e|0;r=r|0;t=t|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)==t<<16>>16:0)r=(a[e>>1]|0)==r<<16>>16;else r=0;return r|0}function F(e,r){e=e|0;r=r|0;var t=0;t=i[3]|0;if(t>>>0<=e>>>0?(a[e>>1]|0)==r<<16>>16:0)if((t|0)==(e|0))t=1;else t=G(a[e+-2>>1]|0)|0;else t=0;return t|0}function G(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&(E(e)|0)}}while(0);return e|0}function H(){var e=0,r=0,t=0;e=i[19]|0;t=i[18]|0;e:while(1){r=t+2|0;if(t>>>0>=e>>>0)break;switch(a[r>>1]|0){case 13:case 10:break e;default:t=r}}i[18]=r;return}function J(e){e=e|0;while(1){if(_(e)|0)break;if(E(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 K(e,r){e=e|0;r=r|0;var t=0,s=0;t=i[13]|0;i[13]=t+12;s=i[10]|0;i[((s|0)==0?20:s+8|0)>>2]=t;i[10]=t;i[t>>2]=e;i[t+4>>2]=r;i[t+8>>2]=0;return}function L(e,r,t,s){e=e|0;r=r|0;t=t|0;s=s|0;if((a[e+4>>1]|0)==s<<16>>16?(a[e+2>>1]|0)==t<<16>>16:0)r=(a[e>>1]|0)==r<<16>>16;else r=0;return r|0}function M(e){e=e|0;if(!(O(e,119,104,105,108,101)|0)?!(q(e,102,111,114)|0):0)e=z(e,105,102)|0;else e=1;return e|0}function N(){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 Q(e,r,t){e=e|0;r=r|0;t=t|0;if((a[e+2>>1]|0)==t<<16>>16)r=(a[e>>1]|0)==r<<16>>16;else r=0;return r|0}function R(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((i[3]|0)==(e|0))e=1;else e=G(a[e+-2>>1]|0)|0;return e|0}function V(){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 W(){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 X(){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 Y(e){e=e|0;var r=0;r=le;le=le+e|0;le=le+15&-16;return r|0}function Z(){s[588]=1;i[14]=(i[18]|0)-(i[3]|0)>>1;i[18]=(i[19]|0)+2;return}function _(e){e=e|0;return(e|128)<<16>>16==160|(e+-9&65535)<5|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 se(){return(i[(i[6]|0)+4>>2]|0)-(i[3]|0)>>1|0}function ie(){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 ce(){return(i[i[7]>>2]|0)-(i[3]|0)>>1|0}function fe(){return c[(i[6]|0)+24>>0]|0|0}function ne(e){e=e|0;i[3]=e;return}function ue(){return(s[589]|0)!=0|0}function be(){return i[14]|0}return{ai:V,e:be,ee:ie,es:ce,f:ue,id:N,ie:se,ip:fe,is:te,p:u,re:X,ri:W,sa:j,se:ee,ses:ne,ss:re,sta:Y}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},{},Ee),Me=Pe.sta(2*je)}const t=_e.length+1;if(Pe.ses(Me),Pe.sa(t-1),(Re?n:f)(_e,new Uint16Array(Ee,Me,t)),!Pe.p())throw Object.assign(new Error(`Parse error ${r}:${_e.slice(0,Pe.e()).split("\n").length}:${Pe.e()-_e.lastIndexOf("\n",Pe.e()-1)}`),{idx:Pe.e()});const s=[],a=[];for(;Pe.ri();){const e=Pe.is(),r=Pe.ie(),t=Pe.ai(),a=Pe.id(),i=Pe.ss(),c=Pe.se();let oe;Pe.ip()&&(oe=u(-1===a?e:e+1,_e.charCodeAt(-1===a?e-1:e))),s.push({n:oe,s:e,e:r,ss:i,se:c,d:a,a:t})}for(;Pe.re();)a.push(_e.slice(Pe.es(),Pe.ee()));return[s,a,!!Pe.f()]}function f(e,r){const t=e.length;let s=0;for(;s<t;){const t=e.charCodeAt(s);r[s++]=(255&t)<<8|t>>>8}}function n(e,r){const t=e.length;let s=0;for(;s<t;)r[s]=e.charCodeAt(s++)}function u(e,r){Be=e;let t="",s=Be;for(;;){Be>=_e.length&&syntaxError();const e=_e.charCodeAt(Be);if(e===r)break;92===e?(t+=_e.slice(s,Be),t+=b(),s=Be):(8232===e||8233===e||l(e)&&syntaxError(),++Be)}return t+=_e.slice(s,Be++),t}function b(){let e=_e.charCodeAt(++Be);switch(++Be,e){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(k(2));case 117:return function(){let e;123===_e.charCodeAt(Be)?(++Be,e=k(_e.indexOf("}",Be)-Be),++Be,e>1114111&&syntaxError()):e=k(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===_e.charCodeAt(Be)&&++Be;case 10:return"";case 56:case 57:syntaxError();default:if(e>=48&&e<=55){let r=_e.substr(Be-1,3).match(/^[0-7]+/)[0],t=parseInt(r,8);return t>255&&(r=r.slice(0,-1),t=parseInt(r,8)),Be+=r.length-1,e=_e.charCodeAt(Be),"0"===r&&56!==e&&57!==e||syntaxError(),String.fromCharCode(t)}return l(e)?"":String.fromCharCode(e)}}function k(e){const r=Be;let t=0,s=0;for(let r=0;r<e;++r,++Be){let e,a=_e.charCodeAt(Be);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,t=16*t+e}else 95!==s&&0!==r||syntaxError(),s=a}return 95!==s&&Be-r===e||syntaxError(),t}function l(e){return 13===e||10===e}async function defaultResolve(e,r){return resolveImportMap(Je,resolveIfNotPlainOrUrl(e,r)||e,r)}async function _resolve(e,r){const t=resolveIfNotPlainOrUrl(e,r);return{r:resolveImportMap(Je,t||e,r),b:!t&&!isURL(e)}}const Fe=oe?async(e,r)=>({r:await esmsInitOptions.resolve(e,r,defaultResolve),b:false}):_resolve;let Ne=0;const qe={};async function loadAll(e,r){if(!e.b&&!r[e.u]){r[e.u]=1;await e.L;await Promise.all(e.d.map((e=>loadAll(e,r))));e.n||(e.n=e.d.some((e=>e.n)))}}let Je={imports:{},scopes:{}};let Te=false;let He;const Ze=xe.then((()=>{if(!c){let e=false;for(const r of document.querySelectorAll('script[type="module-shim"],script[type="importmap-shim"],script[type="module"],script[type="importmap"]')){e||"module"!==r.type||(e=true);if(r.type.endsWith("-shim")){setShimMode();break}if(e&&"importmap"===r.type){Te=true;break}}}He=Ue&&Ie&&Oe&&(!ge||Ce)&&(!ye||Le)&&!Te&&true;He||he();if(!c&&He);else{new MutationObserver((e=>{for(const r of e)if("childList"===r.type)for(const e of r.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 Ge=Ze;let De=true;async function topLevelLoad(e,r,t,s,a){c||(De=false);await Ge;if(!c&&He){if(s)return null;await a;return Ae(t?createBlob(t):e,{errUrl:e||t})}const i=getOrCreateLoad(e,r,t);const oe={};await loadAll(i,oe);Ke=void 0;resolveDeps(i,oe);await a;if(t&&!c&&!i.n&&true){const e=await Ae(createBlob(t),{errUrl:t});ke&&revokeObjectURLs(Object.keys(oe));return e}const le=await Ae(i.b,{errUrl:i.u});i.s&&(await Ae(i.s)).u$_(le);ke&&revokeObjectURLs(Object.keys(oe));return le}function revokeObjectURLs(e){let r=0;const t=e.length;const s=self.requestIdleCallback?self.requestIdleCallback:self.requestAnimationFrame;s(cleanup);function cleanup(){const a=100*r;if(!(a>t)){for(const r of e.slice(a,a+100)){const e=qe[r];e&&URL.revokeObjectURL(e.b)}r++;s(cleanup)}}}async function importShim(e,t=r,s){await Ze;if(De||c||!He){processImportMaps();c||(De=false)}await Ge;return topLevelLoad((await Fe(e,t)).r||throwUnresolved(e,t),{credentials:"same-origin"})}self.importShim=importShim;const We={};async function importMetaResolve(e,r=this.url){return(await Fe(e,`${r}`)).r||throwUnresolved(e,r)}self._esmsm=We;function urlJsString(e){return`'${e.replace(/'/g,"\\'")}'`}let Ke;function resolveDeps(r,t){if(r.b||!t[r.u])return;t[r.u]=0;for(const e of r.d)resolveDeps(e,t);if(!c&&!r.n){r.b=Ke=r.u;r.S=void 0;return}const[s]=r.a;const a=r.S;let i=e&&Ke?`import '${Ke}';`:"";if(s.length){let e=0,t=0;for(const{s:c,se:oe,d:le}of s)if(-1===le){const s=r.d[t++];let le=s.b;if(le){if(s.s){i+=`${a.slice(e,c-1)}/*${a.slice(c-1,oe)}*/${urlJsString(le)};import*as m$_${t} from'${s.b}';import{u$_ as u$_${t}}from'${s.s}';u$_${t}(m$_${t})`;e=oe;s.s=void 0;continue}}else(le=s.s)||(le=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,oe)}*/${urlJsString(le)}`;e=oe}else if(-2===le){We[r.r]={url:r.r,resolve:importMetaResolve};i+=`${a.slice(e,c)}self._esmsm[${urlJsString(r.r)}]`;e=oe}else{i+=`${a.slice(e,le+6)}Shim(${a.slice(c,oe)}, ${r.r&&urlJsString(r.r)}`;e=oe}i+=a.slice(e)}else i+=a;i=i.replace(/\/\/# sourceMappingURL=(.*)\s*$/,((e,t)=>e.replace(t,(()=>new URL(t,r.r)))));let oe=false;i=i.replace(/\/\/# sourceURL=(.*)\s*$/,((e,t)=>(oe=true,e.replace(t,(()=>new URL(t,r.r))))));oe||(i+="\n//# sourceURL="+r.r);r.b=Ke=createBlob(i);r.S=void 0}const ze=/^(text|application)\/(x-)?javascript(;|$)/;const Qe=/^(text|application)\/json(;|$)/;const Ve=/^(text|application)\/css(;|$)/;const Xe=/^application\/wasm(;|$)/;const Ye=/url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;let er=[];let rr=0;function pushFetchPool(){if(++rr>100)return new Promise((e=>er.push(e)))}function popFetchPool(){rr--;er.length&&er.shift()()}async function doFetch(e,r){const t=pushFetchPool();t&&await t;try{var s=await we(e,r)}finally{popFetchPool()}if(!s.ok)throw new Error(`${s.status} ${s.statusText} ${s.url}`);const a=s.headers.get("content-type");if(ze.test(a))return{r:s.url,s:await s.text(),t:"js"};if(Qe.test(a))return{r:s.url,s:`export default ${await s.text()}`,t:"json"};if(Ve.test(a))return{r:s.url,s:`var s=new CSSStyleSheet();s.replaceSync(${JSON.stringify((await s.text()).replace(Ye,((r,t,s,a)=>`url(${t}${resolveUrl(s||a,e)}${t})`)))});export default s;`,t:"css"};throw Xe.test(a)?new Error("WASM modules not yet supported"):new Error(`Unknown Content-Type "${a}"`)}function getOrCreateLoad(e,r,t){let s=qe[e];if(s)return s;s=qe[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(!t){let a;({r:s.r,s:t,t:a}=await(nr[e]||doFetch(e,r)));if(a&&!c){if("css"===a&&!ye||"json"===a&&!ge)throw new Error(`${a}-modules must be enabled to polyfill via: window.esmsInitOptions = { polyfillEnable: ['${a}-modules'] }`);("css"===a&&!Le||"json"===a&&!Ce)&&(s.n=true)}}try{s.a=parse(t,s.u)}catch(e){console.warn(e);s.a=[[],[]]}s.S=t;return s})();s.L=s.f.then((async()=>{let e=r;s.d=(await Promise.all(s.a[0].map((async({n:r,d:t})=>{(t>=0&&!Ue||2===t&&!Ie)&&(s.n=true);if(!r)return;const{r:a,b:i}=await Fe(r,s.r||s.u);!i||Oe&&!Te||(s.n=true);if(-1===t){a||throwUnresolved(r,s.r||s.u);if(le&&le.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 r={};e.integrity&&(r.integrity=e.integrity);e.referrerpolicy&&(r.referrerPolicy=e.referrerpolicy);"use-credentials"===e.crossorigin?r.credentials="include":"anonymous"===e.crossorigin?r.credentials="omit":r.credentials="same-origin";return r}let tr=Promise.resolve();let sr=1;function domContentLoadedCheck(){0!==--sr||me||document.dispatchEvent(new Event("DOMContentLoaded"))}document.addEventListener("DOMContentLoaded",(async()=>{await Ze;domContentLoadedCheck();if(c||!He){processImportMaps();processScriptsAndPreloads()}}));let ar=1;"complete"===document.readyState?readyStateCompleteCheck():document.addEventListener("readystatechange",(async()=>{processImportMaps();await Ze;readyStateCompleteCheck()}));function readyStateCompleteCheck(){0!==--ar||me||document.dispatchEvent(new Event("readystatechange"))}function processImportMap(e){if(!e.ep&&(e.src||e.innerHTML)){e.ep=true;if(e.src){if(!c)return;Te=true}if(De){Ge=Ge.then((async()=>{Je=resolveAndComposeImportMap(e.src?await(await we(e.src)).json():JSON.parse(e.innerHTML),e.src||r,Je)}));c||(De=false)}}}function processScript(e){if(e.ep)return;if(null!==e.getAttribute("noshim"))return;if(!e.src&&!e.innerHTML)return;e.ep=true;const t=ar>0;const s=sr>0;t&&ar++;s&&sr++;const a=topLevelLoad(e.src||`${r}?${Ne++}`,getFetchOpts(e),!e.src&&e.innerHTML,!c,t&&tr).catch((e=>{setTimeout((()=>{throw e}));pe(e)}));t&&(tr=a.then(readyStateCompleteCheck));s&&a.then(domContentLoadedCheck)}const nr={};function processPreload(e){if(!e.ep){e.ep=true;nr[e.href]||(nr[e.href]=doFetch(e.href,getFetchOpts(e)))}}function throwUnresolved(e,r){throw Error("Unable to resolve specifier '"+e+(r?"' from "+r:"'"))}})();
@@ -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", async: true, "data-turbo-track": "reload",
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.
@@ -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
- puts %(Pinning "#{package}" to #{url})
14
-
15
- pin = packager.pin_for(package, url)
18
+ if options[:download]
19
+ puts %(Pinning "#{package}" to vendor/#{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)
@@ -28,12 +38,18 @@ class Importmap::Commands < Thor
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
- puts %(Unpinning "#{package}")
36
- remove_line_from_file "config/importmap.rb", /pin "#{package}"/
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
@@ -43,6 +59,7 @@ class Importmap::Commands < Thor
43
59
 
44
60
  desc "json", "Show the full importmap in json"
45
61
  def json
62
+ require Rails.root.join("config/environment")
46
63
  puts Rails.application.importmap.to_json(resolver: ActionController::Base.helpers)
47
64
  end
48
65
 
@@ -26,7 +26,9 @@ module Importmap
26
26
 
27
27
  initializer "importmap.cache_sweeper" do |app|
28
28
  if app.config.importmap.sweep_cache
29
- app.importmap.cache_sweeper watches: app.root.join("app/javascript")
29
+ app.importmap.cache_sweeper watches: [
30
+ app.root.join("app/javascript"), app.root.join("vendor/javascript")
31
+ ]
30
32
 
31
33
  ActiveSupport.on_load(:action_controller_base) do
32
34
  before_action { Rails.application.importmap.cache_sweeper.execute_if_updated }
@@ -36,8 +38,9 @@ module Importmap
36
38
 
37
39
  initializer "importmap.assets" do
38
40
  if Rails.application.config.respond_to?(:assets)
39
- Rails.application.config.assets.precompile += %w( es-module-shims.js )
41
+ Rails.application.config.assets.precompile += %w( es-module-shims.js es-module-shims.min.js )
40
42
  Rails.application.config.assets.paths << Rails.root.join("app/javascript")
43
+ Rails.application.config.assets.paths << Rails.root.join("vendor/javascript")
41
44
  end
42
45
  end
43
46
 
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: true)
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: true)
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
@@ -10,8 +10,9 @@ class Importmap::Packager
10
10
  singleton_class.attr_accessor :endpoint
11
11
  self.endpoint = URI("https://api.jspm.io/generate")
12
12
 
13
- def initialize(importmap_path = "config/importmap.rb")
14
- @importmap_path = importmap_path
13
+ def initialize(importmap_path = "config/importmap.rb", vendor_path: "vendor/javascript")
14
+ @importmap_path = Pathname.new(importmap_path)
15
+ @vendor_path = Pathname.new(vendor_path)
15
16
  end
16
17
 
17
18
  def import(*packages, env: "production", from: "jspm")
@@ -33,15 +34,43 @@ class Importmap::Packager
33
34
  %(pin "#{package}", to: "#{url}")
34
35
  end
35
36
 
37
+ def vendored_pin_for(package, url)
38
+ filename = package_filename(package)
39
+ version = extract_package_version_from(url)
40
+
41
+ if "#{package}.js" == filename
42
+ %(pin "#{package}" # #{version})
43
+ else
44
+ %(pin "#{package}", to: "#{filename}" # #{version})
45
+ end
46
+ end
47
+
36
48
  def packaged?(package)
37
49
  importmap.match(/^pin "#{package}".*$/)
38
50
  end
39
51
 
52
+ def download(package, url)
53
+ ensure_vendor_directory_exists
54
+ remove_existing_package_file(package)
55
+ download_package_file(package, url)
56
+ end
57
+
58
+ def remove(package)
59
+ remove_existing_package_file(package)
60
+ remove_package_from_importmap(package)
61
+ end
62
+
40
63
  private
64
+ def post_json(body)
65
+ Net::HTTP.post(self.class.endpoint, body.to_json, "Content-Type" => "application/json")
66
+ rescue => error
67
+ raise HTTPError, "Unexpected transport error (#{error.class}: #{error.message})"
68
+ end
69
+
41
70
  def extract_parsed_imports(response)
42
71
  JSON.parse(response.body).dig("map", "imports")
43
72
  end
44
-
73
+
45
74
  def handle_failure_response(response)
46
75
  if error_message = parse_service_error(response)
47
76
  raise ServiceError, error_message
@@ -56,13 +85,57 @@ class Importmap::Packager
56
85
  nil
57
86
  end
58
87
 
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
88
  def importmap
66
89
  @importmap ||= File.read(@importmap_path)
67
90
  end
91
+
92
+
93
+ def ensure_vendor_directory_exists
94
+ FileUtils.mkdir_p @vendor_path
95
+ end
96
+
97
+ def remove_existing_package_file(package)
98
+ FileUtils.rm_rf vendored_package_path(package)
99
+ end
100
+
101
+ def remove_package_from_importmap(package)
102
+ all_lines = File.readlines(@importmap_path)
103
+ with_lines_removed = all_lines.select { |line| line !~ /pin "#{package}"/ }
104
+
105
+ File.open(@importmap_path, "w") do |file|
106
+ with_lines_removed.each { |line| file.write(line) }
107
+ end
108
+ end
109
+
110
+ def download_package_file(package, url)
111
+ response = Net::HTTP.get_response(URI(url))
112
+
113
+ if response.code == "200"
114
+ save_vendored_package(package, response.body)
115
+ else
116
+ handle_failure_response(response)
117
+ end
118
+ end
119
+
120
+ def save_vendored_package(package, source)
121
+ File.open(vendored_package_path(package), "w+") do |vendored_package|
122
+ vendored_package.write remove_sourcemap_comment_from(source).force_encoding("UTF-8")
123
+ end
124
+ end
125
+
126
+ def remove_sourcemap_comment_from(source)
127
+ source.gsub(/^\/\/# sourceMappingURL=.*/, "")
128
+ end
129
+
130
+ def vendored_package_path(package)
131
+ @vendor_path.join(package_filename(package))
132
+ end
133
+
134
+ def package_filename(package)
135
+ package.gsub("/", "--") + ".js"
136
+ end
137
+
138
+ def extract_package_version_from(url)
139
+ url.match(/@\d+\.\d+\.\d+/)&.to_a&.first
140
+ end
68
141
  end
@@ -1,3 +1,3 @@
1
1
  module Importmap
2
- VERSION = "0.7.3"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -1,6 +1,3 @@
1
- # Use direct uploads for Active Storage (remember to import "@rails/activestorage" in your application.js)
2
- # pin "@rails/activestorage", to: "activestorage.esm.js"
1
+ # Pin npm packages by running ./bin/importmap
3
2
 
4
- # Use node modules from a JavaScript CDN by running ./bin/importmap
5
-
6
- pin "application"
3
+ pin "application", preload: true
@@ -16,7 +16,8 @@ end
16
16
 
17
17
  if (sprockets_manifest_path = Rails.root.join("app/assets/config/manifest.js")).exist?
18
18
  say "Ensure JavaScript files are in the Sprocket manifest"
19
- append_to_file sprockets_manifest_path, %(//= link_tree ../../javascript .js\n)
19
+ append_to_file sprockets_manifest_path,
20
+ %(//= link_tree ../../javascript .js\n//= link_tree ../../../vendor/javascript .js\n)
20
21
  end
21
22
 
22
23
  say "Configure importmap paths in config/importmap.rb"
@@ -3,10 +3,4 @@ namespace :importmap do
3
3
  task :install do
4
4
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb", __dir__)}"
5
5
  end
6
-
7
- desc "Show the importmap"
8
- task :pins do
9
- require Rails.root.join("config/environment")
10
- puts Rails.application.importmap.to_json(resolver: ActionController::Base.helpers)
11
- end
12
6
  end
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.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -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
@@ -61,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
62
  requirements:
62
63
  - - ">="
63
64
  - !ruby/object:Gem::Version
64
- version: '0'
65
+ version: 2.7.0
65
66
  required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  requirements:
67
68
  - - ">="