@micro-lc/preview 0.5.0-rc6 → 0.5.0-rc8

Sign up to get free protection for your applications and to get access to all the features.
@@ -4958,8 +4958,29 @@ function parse(input, context, preserveUnknown = false) {
4958
4958
  return acc;
4959
4959
  }
4960
4960
  const compileObject = (obj, context) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, parse(value, context)]));
4961
+ var DebugMessage = /* @__PURE__ */ ((DebugMessage2) => {
4962
+ DebugMessage2[DebugMessage2["Default"] = 0] = "Default";
4963
+ DebugMessage2[DebugMessage2["Skip"] = 1] = "Skip";
4964
+ return DebugMessage2;
4965
+ })(DebugMessage || {});
4961
4966
  const MIA_PREVIEW_ID = "__mia_preview_id";
4962
4967
  const OVERLAY_Z_INDEX = 1e6;
4968
+ const keys = {
4969
+ "click-element": 0,
4970
+ "ctrl-space": 0,
4971
+ "focus-element": 0,
4972
+ mousedown: 0,
4973
+ mousemove: 1,
4974
+ "new-configuration": 0,
4975
+ notification: 0,
4976
+ options: 0,
4977
+ "request-resource": 0,
4978
+ "set-source-map": 0,
4979
+ "tag-info": 0,
4980
+ update: 0,
4981
+ updated: 0
4982
+ /* Default */
4983
+ };
4963
4984
  var t;
4964
4985
  const i = window, s = i.trustedTypes, e = s ? s.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o = "$lit$", n = `lit$${(Math.random() + "").slice(9)}$`, l = "?" + n, h = `<${l}>`, r = document, d = () => r.createComment(""), u = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _ = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^
4965
4986
  \f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false), P = (t2, i2) => {
@@ -5764,8 +5785,8 @@ var PostChannel = class {
5764
5785
  this.__instance = instance;
5765
5786
  const color = generateDarkColorHex();
5766
5787
  this.__colors = {
5767
- bg: color,
5768
- fg: `${color}22`
5788
+ bg: `${color}22`,
5789
+ fg: color
5769
5790
  };
5770
5791
  this.__receiver = to;
5771
5792
  this.__connect(
@@ -5985,7 +6006,25 @@ const parentMakeListener = (self2, channels) => (message) => {
5985
6006
  }
5986
6007
  }
5987
6008
  };
5988
- const registerParent = (self2, channels) => new src_default(parentMakeListener(self2, channels), self2, fromWindowToReceiver(self2.parent));
6009
+ const registerParent = (self2, channels) => new src_default(
6010
+ parentMakeListener(self2, channels),
6011
+ self2,
6012
+ fromWindowToReceiver(self2.parent),
6013
+ {
6014
+ log(message) {
6015
+ {
6016
+ console.assert(self2.parent !== self2);
6017
+ }
6018
+ if (keys[message.type] !== DebugMessage.Skip) {
6019
+ const style = { background: this.colors.bg, color: this.colors.fg };
6020
+ console.groupCollapsed(`%c Msg from ${self2.origin} (inner) `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
6021
+ console.info(`window '${self2.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
6022
+ console.log(message.content);
6023
+ console.groupEnd();
6024
+ }
6025
+ }
6026
+ }
6027
+ );
5989
6028
  const ctrlSpaceFactory = (channels) => {
5990
6029
  return (evt) => {
5991
6030
  if (evt.ctrlKey && evt.key === " ") {
@@ -6676,6 +6715,7 @@ function registerCleanups(window2, fns) {
6676
6715
  parentWindowSenderCleanup,
6677
6716
  serviceWorkerSenderCleanup,
6678
6717
  () => parentWindowRegistration.disconnect(),
6718
+ () => swRegistration.send({ content: {}, type: "unload-client" }),
6679
6719
  () => swRegistration.disconnect()
6680
6720
  ]
6681
6721
  );
@@ -17,7 +17,7 @@
17
17
  </style>
18
18
  <script src="https://unpkg.com/zone.js"></script>
19
19
 
20
- <script type="module" crossorigin src="./assets/index-62118151.js"></script>
20
+ <script type="module" crossorigin src="./assets/index-49595118.js"></script>
21
21
  </head>
22
22
  <body></body>
23
23
  </html>
@@ -8,7 +8,7 @@
8
8
  "dynamicImports": [
9
9
  "../../.yarn/__virtual__/@micro-lc-composer-virtual-1e9d239e46/0/cache/@micro-lc-composer-npm-2.0.3-7d85cea61f-88452090ec.zip/node_modules/@micro-lc/composer/dist/lib/logger/errors.js"
10
10
  ],
11
- "file": "assets/index-62118151.js",
11
+ "file": "assets/index-49595118.js",
12
12
  "isEntry": true,
13
13
  "src": "index.html"
14
14
  }
@@ -1438,7 +1438,7 @@
1438
1438
  }
1439
1439
  function fromAsyncIterable(asyncIterable) {
1440
1440
  return new Observable(function(subscriber) {
1441
- process(asyncIterable, subscriber).catch(function(err) {
1441
+ process2(asyncIterable, subscriber).catch(function(err) {
1442
1442
  return subscriber.error(err);
1443
1443
  });
1444
1444
  });
@@ -1446,7 +1446,7 @@
1446
1446
  function fromReadableStreamLike(readableStream) {
1447
1447
  return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
1448
1448
  }
1449
- function process(asyncIterable, subscriber) {
1449
+ function process2(asyncIterable, subscriber) {
1450
1450
  var asyncIterable_1, asyncIterable_1_1;
1451
1451
  var e_2, _a;
1452
1452
  return __awaiter(this, void 0, void 0, function() {
@@ -1925,8 +1925,8 @@
1925
1925
  this.__instance = instance;
1926
1926
  const color = generateDarkColorHex();
1927
1927
  this.__colors = {
1928
- bg: color,
1929
- fg: `${color}22`
1928
+ bg: `${color}22`,
1929
+ fg: color
1930
1930
  };
1931
1931
  this.__receiver = to;
1932
1932
  this.__connect(
@@ -2007,8 +2007,9 @@
2007
2007
  const { content } = workerMessageData;
2008
2008
  const clientMaps = Object.entries(content).reduce((maps, [key, value]) => {
2009
2009
  const { clientSourceMap, clientTosMap } = maps;
2010
- if (Object.keys(value.headers).length > 0) {
2011
- clientTosMap.set(encodeURI(value.to), value.headers);
2010
+ const { headers = {} } = value;
2011
+ if (Object.keys(headers).length > 0) {
2012
+ clientTosMap.set(encodeURI(value.to), headers);
2012
2013
  }
2013
2014
  clientSourceMap.set(encodeURI(key), value);
2014
2015
  return maps;
@@ -2018,6 +2019,8 @@
2018
2019
  break;
2019
2020
  }
2020
2021
  case "unload-client": {
2022
+ sourceMap.delete(clientId);
2023
+ tosMap.delete(clientId);
2021
2024
  openChannels.delete(clientId);
2022
2025
  this.disconnect();
2023
2026
  break;
@@ -2080,14 +2083,14 @@
2080
2083
  let extraQuery = {};
2081
2084
  if (key !== void 0) {
2082
2085
  const value = clientSourceMap.get(key)?.to;
2083
- const extraHeaders = clientSourceMap.get(key)?.headers;
2086
+ const extraHeaders = clientSourceMap.get(key)?.headers ?? {};
2084
2087
  const rest = url.substring(key.length);
2085
- extraQuery = clientSourceMap.get(key)?.query;
2088
+ extraQuery = clientSourceMap.get(key)?.query ?? {};
2086
2089
  url = `${value}${rest}`;
2087
2090
  Object.entries(extraHeaders).forEach(([headerKey, headerValue]) => headers.set(headerKey, headerValue));
2088
2091
  }
2089
2092
  if (to !== void 0) {
2090
- const extraHeaders = clientTosMap.get(to);
2093
+ const extraHeaders = clientTosMap.get(to) ?? {};
2091
2094
  Object.entries(extraHeaders).forEach(([headerKey, headerValue]) => headers.set(headerKey, headerValue));
2092
2095
  }
2093
2096
  let finalUrl;
@@ -2098,7 +2101,14 @@
2098
2101
  } catch {
2099
2102
  finalUrl = url;
2100
2103
  }
2101
- console.log({ clientId, clientSourceMap, finalUrl });
2104
+ const channel = openChannels.get(clientId)?.channel;
2105
+ if (channel !== void 0 && true) {
2106
+ const style = { background: channel.colors.bg, color: channel.colors.fg };
2107
+ console.groupCollapsed(`%c Fetch from Service Worker `, Object.entries(style).map(([styleKey, styleValue]) => `${styleKey}: ${styleValue}`).join("; "));
2108
+ console.info(`sw is fetching %c ${finalUrl}`, "background: lightgreen; color: darkgreen");
2109
+ console.log({ clientId, clientSourceMap, request: event.request });
2110
+ console.groupEnd();
2111
+ }
2102
2112
  event.respondWith(
2103
2113
  self.fetch(finalUrl, { ...event.request, headers }).catch((error) => {
2104
2114
  console.error(error);
@@ -17,7 +17,7 @@
17
17
  </style>
18
18
  <script src="https://unpkg.com/zone.js"></script>
19
19
 
20
- <script type="module" crossorigin src="./assets/index-d846d55b.js"></script>
20
+ <script type="module" crossorigin src="./assets/index-11acce20.js"></script>
21
21
  </head>
22
22
  <body></body>
23
23
  </html>
@@ -8,7 +8,7 @@
8
8
  "dynamicImports": [
9
9
  "../../.yarn/__virtual__/@micro-lc-composer-virtual-1e9d239e46/0/cache/@micro-lc-composer-npm-2.0.3-7d85cea61f-88452090ec.zip/node_modules/@micro-lc/composer/dist/lib/logger/errors.js"
10
10
  ],
11
- "file": "assets/index-d846d55b.js",
11
+ "file": "assets/index-11acce20.js",
12
12
  "isEntry": true,
13
13
  "src": "index.html"
14
14
  }
@@ -1,3 +1,3 @@
1
- "use strict";(()=>{var Q=function(r,t){return Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])},Q(r,t)};function v(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Q(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function mr(r,t,e,o){function n(i){return i instanceof e?i:new e(function(s){s(i)})}return new(e||(e=Promise))(function(i,s){function a(u){try{c(o.next(u))}catch(h){s(h)}}function f(u){try{c(o.throw(u))}catch(h){s(h)}}function c(u){u.done?i(u.value):n(u.value).then(a,f)}c((o=o.apply(r,t||[])).next())})}function B(r,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return f([c,u])}}function f(c){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(e=0)),e;)try{if(o=1,n&&(i=c[0]&2?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,n=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){e.label=c[1];break}if(c[0]===6&&e.label<i[1]){e.label=i[1],i=c;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(c);break}i[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(r,e)}catch(u){c=[6,u],n=0}finally{o=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function E(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],o=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&o>=r.length&&(r=void 0),{value:r&&r[o++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function y(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var o=e.call(r),n,i=[],s;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(e=o.return)&&e.call(o)}finally{if(s)throw s.error}}return i}function _(r,t,e){if(e||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return r.concat(i||Array.prototype.slice.call(t))}function I(r){return this instanceof I?(this.v=r,this):new I(r)}function hr(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=e.apply(r,t||[]),n,i=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(l){o[l]&&(n[l]=function(d){return new Promise(function(x,m){i.push([l,d,x,m])>1||a(l,d)})})}function a(l,d){try{f(o[l](d))}catch(x){h(i[0][3],x)}}function f(l){l.value instanceof I?Promise.resolve(l.value.v).then(c,u):h(i[0][2],l)}function c(l){a("next",l)}function u(l){a("throw",l)}function h(l,d){l(d),i.shift(),i.length&&a(i[0][0],i[0][1])}}function dr(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof E=="function"?E(r):r[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(i){e[i]=r[i]&&function(s){return new Promise(function(a,f){s=r[i](s),n(a,f,s.done,s.value)})}}function n(i,s,a,f){Promise.resolve(f).then(function(c){i({value:c,done:a})},s)}}function p(r){return typeof r=="function"}function j(r){var t=function(o){Error.call(o),o.stack=new Error().stack},e=r(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var N=j(function(r){return function(e){r(this),this.message=e?e.length+` errors occurred during unsubscription:
1
+ "use strict";(()=>{var X=function(r,t){return X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])},X(r,t)};function v(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");X(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function hr(r,t,e,o){function n(i){return i instanceof e?i:new e(function(s){s(i)})}return new(e||(e=Promise))(function(i,s){function a(u){try{c(o.next(u))}catch(m){s(m)}}function f(u){try{c(o.throw(u))}catch(m){s(m)}}function c(u){u.done?i(u.value):n(u.value).then(a,f)}c((o=o.apply(r,t||[])).next())})}function B(r,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return f([c,u])}}function f(c){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(e=0)),e;)try{if(o=1,n&&(i=c[0]&2?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,n=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){e.label=c[1];break}if(c[0]===6&&e.label<i[1]){e.label=i[1],i=c;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(c);break}i[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(r,e)}catch(u){c=[6,u],n=0}finally{o=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function E(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],o=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&o>=r.length&&(r=void 0),{value:r&&r[o++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function y(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var o=e.call(r),n,i=[],s;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(e=o.return)&&e.call(o)}finally{if(s)throw s.error}}return i}function _(r,t,e){if(e||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return r.concat(i||Array.prototype.slice.call(t))}function P(r){return this instanceof P?(this.v=r,this):new P(r)}function vr(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=e.apply(r,t||[]),n,i=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(l){o[l]&&(n[l]=function(d){return new Promise(function(x,h){i.push([l,d,x,h])>1||a(l,d)})})}function a(l,d){try{f(o[l](d))}catch(x){m(i[0][3],x)}}function f(l){l.value instanceof P?Promise.resolve(l.value.v).then(c,u):m(i[0][2],l)}function c(l){a("next",l)}function u(l){a("throw",l)}function m(l,d){l(d),i.shift(),i.length&&a(i[0][0],i[0][1])}}function br(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof E=="function"?E(r):r[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(i){e[i]=r[i]&&function(s){return new Promise(function(a,f){s=r[i](s),n(a,f,s.done,s.value)})}}function n(i,s,a,f){Promise.resolve(f).then(function(c){i({value:c,done:a})},s)}}function p(r){return typeof r=="function"}function j(r){var t=function(o){Error.call(o),o.stack=new Error().stack},e=r(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var N=j(function(r){return function(e){r(this),this.message=e?e.length+` errors occurred during unsubscription:
2
2
  `+e.map(function(o,n){return n+1+") "+o.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function P(r,t){if(r){var e=r.indexOf(t);0<=e&&r.splice(e,1)}}var g=function(){function r(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var t,e,o,n,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=E(s),f=a.next();!f.done;f=a.next()){var c=f.value;c.remove(this)}}catch(m){t={error:m}}finally{try{f&&!f.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else s.remove(this);var u=this.initialTeardown;if(p(u))try{u()}catch(m){i=m instanceof N?m.errors:[m]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var l=E(h),d=l.next();!d.done;d=l.next()){var x=d.value;try{vr(x)}catch(m){i=i??[],m instanceof N?i=_(_([],y(i)),y(m.errors)):i.push(m)}}}catch(m){o={error:m}}finally{try{d&&!d.done&&(n=l.return)&&n.call(l)}finally{if(o)throw o.error}}}if(i)throw new N(i)}},r.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)vr(t);else{if(t instanceof r){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},r.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},r.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},r.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&P(e,t)},r.prototype.remove=function(t){var e=this._finalizers;e&&P(e,t),t instanceof r&&t._removeParent(this)},r.EMPTY=function(){var t=new r;return t.closed=!0,t}(),r}();var X=g.EMPTY;function z(r){return r instanceof g||r&&"closed"in r&&p(r.remove)&&p(r.add)&&p(r.unsubscribe)}function vr(r){p(r)?r():r.unsubscribe()}var w={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var C={setTimeout:function(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];var n=C.delegate;return n?.setTimeout?n.setTimeout.apply(n,_([r,t],y(e))):setTimeout.apply(void 0,_([r,t],y(e)))},clearTimeout:function(r){var t=C.delegate;return(t?.clearTimeout||clearTimeout)(r)},delegate:void 0};function G(r){C.setTimeout(function(){var t=w.onUnhandledError;if(t)t(r);else throw r})}function Z(){}var br=function(){return rr("C",void 0,void 0)}();function yr(r){return rr("E",void 0,r)}function xr(r){return rr("N",r,void 0)}function rr(r,t,e){return{kind:r,value:t,error:e}}var A=null;function k(r){if(w.useDeprecatedSynchronousErrorHandling){var t=!A;if(t&&(A={errorThrown:!1,error:null}),r(),t){var e=A,o=e.errorThrown,n=e.error;if(A=null,o)throw n}}else r()}function _r(r){w.useDeprecatedSynchronousErrorHandling&&A&&(A.errorThrown=!0,A.error=r)}var $=function(r){v(t,r);function t(e){var o=r.call(this)||this;return o.isStopped=!1,e?(o.destination=e,z(e)&&e.add(o)):o.destination=oe,o}return t.create=function(e,o,n){return new R(e,o,n)},t.prototype.next=function(e){this.isStopped?tr(xr(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?tr(yr(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?tr(br,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(g);var re=Function.prototype.bind;function er(r,t){return re.call(r,t)}var ee=function(){function r(t){this.partialObserver=t}return r.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(o){K(o)}},r.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(o){K(o)}else K(t)},r.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){K(e)}},r}(),R=function(r){v(t,r);function t(e,o,n){var i=r.call(this)||this,s;if(p(e)||!e)s={next:e??void 0,error:o??void 0,complete:n??void 0};else{var a;i&&w.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return i.unsubscribe()},s={next:e.next&&er(e.next,a),error:e.error&&er(e.error,a),complete:e.complete&&er(e.complete,a)}):s=e}return i.destination=new ee(s),i}return t}($);function K(r){w.useDeprecatedSynchronousErrorHandling?_r(r):G(r)}function te(r){throw r}function tr(r,t){var e=w.onStoppedNotification;e&&C.setTimeout(function(){return e(r,t)})}var oe={closed:!0,next:Z,error:te,complete:Z};var W=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function gr(r){return r}function wr(r){return r.length===0?gr:r.length===1?r[0]:function(e){return r.reduce(function(o,n){return n(o)},e)}}var b=function(){function r(t){t&&(this._subscribe=t)}return r.prototype.lift=function(t){var e=new r;return e.source=this,e.operator=t,e},r.prototype.subscribe=function(t,e,o){var n=this,i=ie(t)?t:new R(t,e,o);return k(function(){var s=n,a=s.operator,f=s.source;i.add(a?a.call(i,f):f?n._subscribe(i):n._trySubscribe(i))}),i},r.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},r.prototype.forEach=function(t,e){var o=this;return e=Sr(e),new e(function(n,i){var s=new R({next:function(a){try{t(a)}catch(f){i(f),s.unsubscribe()}},error:i,complete:n});o.subscribe(s)})},r.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},r.prototype[W]=function(){return this},r.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return wr(t)(this)},r.prototype.toPromise=function(t){var e=this;return t=Sr(t),new t(function(o,n){var i;e.subscribe(function(s){return i=s},function(s){return n(s)},function(){return o(i)})})},r.create=function(t){return new r(t)},r}();function Sr(r){var t;return(t=r??w.Promise)!==null&&t!==void 0?t:Promise}function ne(r){return r&&p(r.next)&&p(r.error)&&p(r.complete)}function ie(r){return r&&r instanceof $||ne(r)&&z(r)}function se(r){return p(r?.lift)}function M(r){return function(t){if(se(t))return t.lift(function(e){try{return r(e,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function O(r,t,e,o,n){return new ae(r,t,e,o,n)}var ae=function(r){v(t,r);function t(e,o,n,i,s,a){var f=r.call(this,e)||this;return f.onFinalize=s,f.shouldUnsubscribe=a,f._next=o?function(c){try{o(c)}catch(u){e.error(u)}}:r.prototype._next,f._error=i?function(c){try{i(c)}catch(u){e.error(u)}finally{this.unsubscribe()}}:r.prototype._error,f._complete=n?function(){try{n()}catch(c){e.error(c)}finally{this.unsubscribe()}}:r.prototype._complete,f}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;r.prototype.unsubscribe.call(this),!o&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}($);var Er=j(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var or=function(r){v(t,r);function t(){var e=r.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var o=new Or(this,this);return o.operator=e,o},t.prototype._throwIfClosed=function(){if(this.closed)throw new Er},t.prototype.next=function(e){var o=this;k(function(){var n,i;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var s=E(o.currentObservers),a=s.next();!a.done;a=s.next()){var f=a.value;f.next(e)}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var o=this;k(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=e;for(var n=o.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;k(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var o=e.observers;o.length;)o.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var o=this,n=this,i=n.hasError,s=n.isStopped,a=n.observers;return i||s?X:(this.currentObservers=null,a.push(e),new g(function(){o.currentObservers=null,P(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var o=this,n=o.hasError,i=o.thrownError,s=o.isStopped;n?e.error(i):s&&e.complete()},t.prototype.asObservable=function(){var e=new b;return e.source=this,e},t.create=function(e,o){return new Or(e,o)},t}(b);var Or=function(r){v(t,r);function t(e,o){var n=r.call(this)||this;return n.destination=e,n.source=o,n}return t.prototype.next=function(e){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.next)===null||n===void 0||n.call(o,e)},t.prototype.error=function(e){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.error)===null||n===void 0||n.call(o,e)},t.prototype.complete=function(){var e,o;(o=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||o===void 0||o.call(e)},t.prototype._subscribe=function(e){var o,n;return(n=(o=this.source)===null||o===void 0?void 0:o.subscribe(e))!==null&&n!==void 0?n:X},t}(or);var q={now:function(){return(q.delegate||Date).now()},delegate:void 0};var F=function(r){v(t,r);function t(e,o,n){e===void 0&&(e=1/0),o===void 0&&(o=1/0),n===void 0&&(n=q);var i=r.call(this)||this;return i._bufferSize=e,i._windowTime=o,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=o===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,o),i}return t.prototype.next=function(e){var o=this,n=o.isStopped,i=o._buffer,s=o._infiniteTimeWindow,a=o._timestampProvider,f=o._windowTime;n||(i.push(e),!s&&i.push(a.now()+f)),this._trimBuffer(),r.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var o=this._innerSubscribe(e),n=this,i=n._infiniteTimeWindow,s=n._buffer,a=s.slice(),f=0;f<a.length&&!e.closed;f+=i?1:2)e.next(a[f]);return this._checkFinalizedStatuses(e),o},t.prototype._trimBuffer=function(){var e=this,o=e._bufferSize,n=e._timestampProvider,i=e._buffer,s=e._infiniteTimeWindow,a=(s?1:2)*o;if(o<1/0&&a<i.length&&i.splice(0,i.length-a),!s){for(var f=n.now(),c=0,u=1;u<i.length&&i[u]<=f;u+=2)c=u;c&&i.splice(0,c+1)}},t}(or);var Tr=function(r){v(t,r);function t(e,o){return r.call(this)||this}return t.prototype.schedule=function(e,o){return o===void 0&&(o=0),this},t}(g);var V={setInterval:function(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];var n=V.delegate;return n?.setInterval?n.setInterval.apply(n,_([r,t],y(e))):setInterval.apply(void 0,_([r,t],y(e)))},clearInterval:function(r){var t=V.delegate;return(t?.clearInterval||clearInterval)(r)},delegate:void 0};var Mr=function(r){v(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n.pending=!1,n}return t.prototype.schedule=function(e,o){var n;if(o===void 0&&(o=0),this.closed)return this;this.state=e;var i=this.id,s=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(s,i,o)),this.pending=!0,this.delay=o,this.id=(n=this.id)!==null&&n!==void 0?n:this.requestAsyncId(s,this.id,o),this},t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),V.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,o,n){if(n===void 0&&(n=0),n!=null&&this.delay===n&&this.pending===!1)return o;o!=null&&V.clearInterval(o)},t.prototype.execute=function(e,o){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,o);if(n)return n;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,o){var n=!1,i;try{this.work(e)}catch(s){n=!0,i=s||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,o=e.id,n=e.scheduler,i=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,P(i,this),o!=null&&(this.id=this.recycleAsyncId(n,o,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},t}(Tr);var nr=function(){function r(t,e){e===void 0&&(e=r.now),this.schedulerActionCtor=t,this.now=e}return r.prototype.schedule=function(t,e,o){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(o,e)},r.now=q.now,r}();var Ir=function(r){v(t,r);function t(e,o){o===void 0&&(o=nr.now);var n=r.call(this,e,o)||this;return n.actions=[],n._active=!1,n}return t.prototype.flush=function(e){var o=this.actions;if(this._active){o.push(e);return}var n;this._active=!0;do if(n=e.execute(e.state,e.delay))break;while(e=o.shift());if(this._active=!1,n){for(;e=o.shift();)e.unsubscribe();throw n}},t}(nr);var ir=new Ir(Mr),Pr=ir;var Ar=new b(function(r){return r.complete()});function jr(r){return r&&p(r.schedule)}var J=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function Cr(r){return p(r?.then)}function kr(r){return p(r[W])}function Rr(r){return Symbol.asyncIterator&&p(r?.[Symbol.asyncIterator])}function Wr(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ce(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Fr=ce();function Ur(r){return p(r?.[Fr])}function Lr(r){return hr(this,arguments,function(){var e,o,n,i;return B(this,function(s){switch(s.label){case 0:e=r.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,I(e.read())];case 3:return o=s.sent(),n=o.value,i=o.done,i?[4,I(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,I(n)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Dr(r){return p(r?.getReader)}function U(r){if(r instanceof b)return r;if(r!=null){if(kr(r))return fe(r);if(J(r))return ue(r);if(Cr(r))return pe(r);if(Rr(r))return $r(r);if(Ur(r))return le(r);if(Dr(r))return me(r)}throw Wr(r)}function fe(r){return new b(function(t){var e=r[W]();if(p(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ue(r){return new b(function(t){for(var e=0;e<r.length&&!t.closed;e++)t.next(r[e]);t.complete()})}function pe(r){return new b(function(t){r.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,G)})}function le(r){return new b(function(t){var e,o;try{for(var n=E(r),i=n.next();!i.done;i=n.next()){var s=i.value;if(t.next(s),t.closed)return}}catch(a){e={error:a}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(e)throw e.error}}t.complete()})}function $r(r){return new b(function(t){he(r,t).catch(function(e){return t.error(e)})})}function me(r){return $r(Lr(r))}function he(r,t){var e,o,n,i;return mr(this,void 0,void 0,function(){var s,a;return B(this,function(f){switch(f.label){case 0:f.trys.push([0,5,6,11]),e=dr(r),f.label=1;case 1:return[4,e.next()];case 2:if(o=f.sent(),!!o.done)return[3,4];if(s=o.value,t.next(s),t.closed)return[2];f.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=f.sent(),n={error:a},[3,11];case 6:return f.trys.push([6,,9,10]),o&&!o.done&&(i=e.return)?[4,i.call(e)]:[3,8];case 7:f.sent(),f.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function qr(r,t,e,o,n){o===void 0&&(o=0),n===void 0&&(n=!1);var i=t.schedule(function(){e(),n?r.add(this.schedule(null,o)):this.unsubscribe()},o);if(r.add(i),!n)return i}var Vr=j(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function sr(r,t){var e=typeof t=="object";return new Promise(function(o,n){var i=new R({next:function(s){o(s),i.unsubscribe()},error:n,complete:function(){e?o(t.defaultValue):n(new Vr)}});r.subscribe(i)})}function Hr(r){return r instanceof Date&&!isNaN(r)}function T(r,t){return M(function(e,o){var n=0;e.subscribe(O(o,function(i){o.next(r.call(t,i,n++))}))})}var de=Array.isArray;function ve(r,t){return de(t)?r.apply(void 0,_([],y(t))):r(t)}function Yr(r){return T(function(t){return ve(r,t)})}function Br(r,t,e,o,n,i,s,a){var f=[],c=0,u=0,h=!1,l=function(){h&&!f.length&&!c&&t.complete()},d=function(m){return c<o?x(m):f.push(m)},x=function(m){i&&t.next(m),c++;var lr=!1;U(e(m,u++)).subscribe(O(t,function(D){n?.(D),i?d(D):t.next(D)},function(){lr=!0},void 0,function(){if(lr)try{c--;for(var D=function(){var Y=f.shift();s?qr(t,s,function(){return x(Y)}):x(Y)};f.length&&c<o;)D();l()}catch(Y){t.error(Y)}}))};return r.subscribe(O(t,d,function(){h=!0,l()})),function(){a?.()}}function ar(r,t,e){return e===void 0&&(e=1/0),p(t)?ar(function(o,n){return T(function(i,s){return t(o,i,n,s)})(U(r(o,n)))},e):(typeof t=="number"&&(e=t),M(function(o,n){return Br(o,n,r,e)}))}var be=["addListener","removeListener"],ye=["addEventListener","removeEventListener"],xe=["on","off"];function H(r,t,e,o){if(p(e)&&(o=e,e=void 0),o)return H(r,t,e).pipe(Yr(o));var n=y(we(r)?ye.map(function(a){return function(f){return r[a](t,f,e)}}):_e(r)?be.map(Nr(r,t)):ge(r)?xe.map(Nr(r,t)):[],2),i=n[0],s=n[1];if(!i&&J(r))return ar(function(a){return H(a,t,e)})(U(r));if(!i)throw new TypeError("Invalid event target");return new b(function(a){var f=function(){for(var c=[],u=0;u<arguments.length;u++)c[u]=arguments[u];return a.next(1<c.length?c:c[0])};return i(f),function(){return s(f)}})}function Nr(r,t){return function(e){return function(o){return r[e](t,o)}}}function _e(r){return p(r.addListener)&&p(r.removeListener)}function ge(r){return p(r.on)&&p(r.off)}function we(r){return p(r.addEventListener)&&p(r.removeEventListener)}function zr(r,t,e){r===void 0&&(r=0),e===void 0&&(e=Pr);var o=-1;return t!=null&&(jr(t)?e=t:o=t),new b(function(n){var i=Hr(r)?+r-e.now():r;i<0&&(i=0);var s=0;return e.schedule(function(){n.closed||(n.next(s++),0<=o?this.schedule(void 0,o):n.complete())},i)})}function cr(r,t){return r===void 0&&(r=0),t===void 0&&(t=ir),r<0&&(r=0),zr(r,r,t)}function S(r,t){return M(function(e,o){var n=0;e.subscribe(O(o,function(i){return r.call(t,i,n++)&&o.next(i)}))})}function L(r){return r<=0?function(){return Ar}:M(function(t,e){var o=0;t.subscribe(O(e,function(n){++o<=r&&(e.next(n),r<=o&&e.complete())}))})}var Gr=(r,t)=>e=>({postMessage:o=>{let{errorCatcher:n=()=>()=>{},...i}=t??{};r.clients.get(e).then(s=>s?.postMessage(o,i)).catch(n(e,o))}});var Kr=(r=>(r.Ack="ack",r.Syn="syn",r))(Kr||{}),Se=Object.values(Kr),fr=r=>r.data,ur=r=>t=>t.type===r.toString(),Ee=r=>{let t=r.data;return typeof t=="object"&&t!==null&&"type"in t&&typeof t.type=="string"&&"instance"in t&&typeof t.instance=="string"&&"content"in t},Oe=()=>{let r="#";for(let t=0;t<3;t++)r+=`0${Math.floor(Math.random()*Math.pow(16,2)/2).toString(16)}`.slice(-2);return r},Te=class{__generateId;__instance;__colors;__listener;__log;__receiver;__subscription;__okToWrite;__write$;__recv$;__connect(r,t){let e=cr(t).subscribe(()=>this.__receiver.postMessage({content:r,instance:r,type:"syn".toString()}));this.__subscription.add(e),this.__subscription.add(this.__recv$.pipe(T(fr),S(ur("ack")),S(({content:o})=>o===r),L(1)).subscribe(({instance:o})=>{this.__okToWrite.next(0),this.__subscription.add(this.__recv$.pipe(S(({data:{type:n,instance:i}})=>!Se.includes(n)&&i===o)).subscribe(n=>{this.__listener(n);let{data:i}=n;i._id!==void 0&&this.__receiver.postMessage({...i,content:i,instance:r,type:"ack"})})),e.unsubscribe()})),this.__subscription.add(this.__recv$.pipe(T(fr),S(ur("syn")),S(({instance:o})=>o!==r),L(1)).subscribe(({content:o})=>{this.__receiver.postMessage({content:o,instance:r,type:"ack"})}))}__write(r,t){let e={};t!==void 0&&(e._id=t),this.__subscription.add(this.__write$.subscribe(()=>{let o=Object.assign(r,{instance:this.__instance,...e});this.__receiver.postMessage(o),this.__log?.(o)}))}constructor(r,t,e,o){this.__generateId=()=>globalThis.crypto.randomUUID();let n=this.__generateId(),i=new F,s=H(t,"message").pipe(S(Ee)).subscribe(i);this.__subscription=new g,this.__subscription.add(s),this.__okToWrite=new F(1),this.__write$=this.__okToWrite.pipe(L(1)),this.__recv$=i.asObservable(),this.__listener=r,this.__log=o?.log&&o.log.bind(this),this.__instance=n;let a=Oe();this.__colors={bg:a,fg:`${a}22`},this.__receiver=e,this.__connect(n,o?.period?o.period:10)}disconnect(){this.__subscription.unsubscribe()}send(r){this.__write(r)}ackSend(r){let t,e=new Promise(n=>{t=n}),o=this.__generateId();return this.__subscription.add(this.__recv$.pipe(T(fr),S(ur("ack")),S(({_id:n})=>n===o),L(1)).subscribe(()=>t())),this.__write(r,o),e}get instance(){return this.__instance}get colors(){return this.__colors}get ready(){return sr(this.__write$).then(()=>{})}},Jr=Te;var pr=new Map,Xr=new Map,Zr=new Map,Qr=(r,t)=>{let e=t.keys(),o,{done:n=!1,value:i}=e.next();for(;!n&&o===void 0;){i!==void 0&&r.startsWith(i)&&(o=i,n=!0);let{value:s,done:a=!1}=e.next();n=a,i=s}return o},Me=r=>r!==null&&"id"in r,Ie=r=>t=>console.error(`[SW]: error on ${r} - ${String(t)}`),Pe=Gr(self,{errorCatcher:Ie}),Ae=r=>function({data:e}){let o=e;switch(o.type){case"set-source-map":{let{content:n}=o,i=Object.entries(n).reduce((s,[a,f])=>{let{clientSourceMap:c,clientTosMap:u}=s;return Object.keys(f.headers).length>0&&u.set(encodeURI(f.to),f.headers),c.set(encodeURI(a),f),s},{clientSourceMap:new Map,clientTosMap:new Map});Xr.set(r,i.clientSourceMap),Zr.set(r,i.clientTosMap);break}case"unload-client":{pr.delete(r),this.disconnect();break}default:break}},je=r=>{let t=new Map,e=new F,o={addEventListener(n,i){t.set(i,e.subscribe(s=>i(s)))},removeEventListener(n,i){t.get(i)?.unsubscribe(),t.delete(i)}};return{buffer:e,channel:new Jr(Ae(r),o,Pe(r))}},Ce=r=>{let t=pr.get(r);return t||(t=je(r),pr.set(r,t)),t};self.addEventListener("install",()=>{self.skipWaiting().catch(r=>console.error(`[SW] error while skipWaiting - ${String(r)}`))});self.addEventListener("activate",r=>{r.waitUntil(self.clients.claim())});self.addEventListener("message",r=>{let{source:t}=r;if(!Me(t))return;let{id:e}=t;Ce(e).buffer.next(r)});self.addEventListener("fetch",r=>{let t=r.clientId!==""?r.clientId:r.resultingClientId,e=Xr.get(t);if(!e)return r.respondWith(self.fetch(r.request));let o=Zr.get(t),{request:{url:n}}=r,i=Qr(n,e),s=Qr(n,o),a=new Headers(r.request.headers),f={};if(i!==void 0){let u=e.get(i)?.to,h=e.get(i)?.headers,l=n.substring(i.length);f=e.get(i)?.query,n=`${u}${l}`,Object.entries(h).forEach(([d,x])=>a.set(d,x))}if(s!==void 0){let u=o.get(s);Object.entries(u).forEach(([h,l])=>a.set(h,l))}let c;try{let u=new URL(n);Object.entries(f).forEach(([h,l])=>u.searchParams.set(h,l)),c=u.href}catch{c=n}console.log({clientId:t,clientSourceMap:e,finalUrl:c}),r.respondWith(self.fetch(c,{...r.request,headers:a}).catch(u=>(console.error(u),Promise.reject(u))))});})();
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function I(r,t){if(r){var e=r.indexOf(t);0<=e&&r.splice(e,1)}}var g=function(){function r(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var t,e,o,n,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=E(s),f=a.next();!f.done;f=a.next()){var c=f.value;c.remove(this)}}catch(h){t={error:h}}finally{try{f&&!f.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else s.remove(this);var u=this.initialTeardown;if(p(u))try{u()}catch(h){i=h instanceof N?h.errors:[h]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var l=E(m),d=l.next();!d.done;d=l.next()){var x=d.value;try{yr(x)}catch(h){i=i??[],h instanceof N?i=_(_([],y(i)),y(h.errors)):i.push(h)}}}catch(h){o={error:h}}finally{try{d&&!d.done&&(n=l.return)&&n.call(l)}finally{if(o)throw o.error}}}if(i)throw new N(i)}},r.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)yr(t);else{if(t instanceof r){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},r.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},r.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},r.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&I(e,t)},r.prototype.remove=function(t){var e=this._finalizers;e&&I(e,t),t instanceof r&&t._removeParent(this)},r.EMPTY=function(){var t=new r;return t.closed=!0,t}(),r}();var Z=g.EMPTY;function z(r){return r instanceof g||r&&"closed"in r&&p(r.remove)&&p(r.add)&&p(r.unsubscribe)}function yr(r){p(r)?r():r.unsubscribe()}var w={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var k={setTimeout:function(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];var n=k.delegate;return n?.setTimeout?n.setTimeout.apply(n,_([r,t],y(e))):setTimeout.apply(void 0,_([r,t],y(e)))},clearTimeout:function(r){var t=k.delegate;return(t?.clearTimeout||clearTimeout)(r)},delegate:void 0};function G(r){k.setTimeout(function(){var t=w.onUnhandledError;if(t)t(r);else throw r})}function rr(){}var xr=function(){return er("C",void 0,void 0)}();function _r(r){return er("E",void 0,r)}function gr(r){return er("N",r,void 0)}function er(r,t,e){return{kind:r,value:t,error:e}}var A=null;function C(r){if(w.useDeprecatedSynchronousErrorHandling){var t=!A;if(t&&(A={errorThrown:!1,error:null}),r(),t){var e=A,o=e.errorThrown,n=e.error;if(A=null,o)throw n}}else r()}function wr(r){w.useDeprecatedSynchronousErrorHandling&&A&&(A.errorThrown=!0,A.error=r)}var $=function(r){v(t,r);function t(e){var o=r.call(this)||this;return o.isStopped=!1,e?(o.destination=e,z(e)&&e.add(o)):o.destination=oe,o}return t.create=function(e,o,n){return new R(e,o,n)},t.prototype.next=function(e){this.isStopped?or(gr(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?or(_r(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?or(xr,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(g);var re=Function.prototype.bind;function tr(r,t){return re.call(r,t)}var ee=function(){function r(t){this.partialObserver=t}return r.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(o){K(o)}},r.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(o){K(o)}else K(t)},r.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){K(e)}},r}(),R=function(r){v(t,r);function t(e,o,n){var i=r.call(this)||this,s;if(p(e)||!e)s={next:e??void 0,error:o??void 0,complete:n??void 0};else{var a;i&&w.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return i.unsubscribe()},s={next:e.next&&tr(e.next,a),error:e.error&&tr(e.error,a),complete:e.complete&&tr(e.complete,a)}):s=e}return i.destination=new ee(s),i}return t}($);function K(r){w.useDeprecatedSynchronousErrorHandling?wr(r):G(r)}function te(r){throw r}function or(r,t){var e=w.onStoppedNotification;e&&k.setTimeout(function(){return e(r,t)})}var oe={closed:!0,next:rr,error:te,complete:rr};var W=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Sr(r){return r}function Er(r){return r.length===0?Sr:r.length===1?r[0]:function(e){return r.reduce(function(o,n){return n(o)},e)}}var b=function(){function r(t){t&&(this._subscribe=t)}return r.prototype.lift=function(t){var e=new r;return e.source=this,e.operator=t,e},r.prototype.subscribe=function(t,e,o){var n=this,i=ie(t)?t:new R(t,e,o);return C(function(){var s=n,a=s.operator,f=s.source;i.add(a?a.call(i,f):f?n._subscribe(i):n._trySubscribe(i))}),i},r.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},r.prototype.forEach=function(t,e){var o=this;return e=Or(e),new e(function(n,i){var s=new R({next:function(a){try{t(a)}catch(f){i(f),s.unsubscribe()}},error:i,complete:n});o.subscribe(s)})},r.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},r.prototype[W]=function(){return this},r.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Er(t)(this)},r.prototype.toPromise=function(t){var e=this;return t=Or(t),new t(function(o,n){var i;e.subscribe(function(s){return i=s},function(s){return n(s)},function(){return o(i)})})},r.create=function(t){return new r(t)},r}();function Or(r){var t;return(t=r??w.Promise)!==null&&t!==void 0?t:Promise}function ne(r){return r&&p(r.next)&&p(r.error)&&p(r.complete)}function ie(r){return r&&r instanceof $||ne(r)&&z(r)}function se(r){return p(r?.lift)}function M(r){return function(t){if(se(t))return t.lift(function(e){try{return r(e,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function O(r,t,e,o,n){return new ae(r,t,e,o,n)}var ae=function(r){v(t,r);function t(e,o,n,i,s,a){var f=r.call(this,e)||this;return f.onFinalize=s,f.shouldUnsubscribe=a,f._next=o?function(c){try{o(c)}catch(u){e.error(u)}}:r.prototype._next,f._error=i?function(c){try{i(c)}catch(u){e.error(u)}finally{this.unsubscribe()}}:r.prototype._error,f._complete=n?function(){try{n()}catch(c){e.error(c)}finally{this.unsubscribe()}}:r.prototype._complete,f}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;r.prototype.unsubscribe.call(this),!o&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}($);var Tr=j(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var nr=function(r){v(t,r);function t(){var e=r.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var o=new Mr(this,this);return o.operator=e,o},t.prototype._throwIfClosed=function(){if(this.closed)throw new Tr},t.prototype.next=function(e){var o=this;C(function(){var n,i;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var s=E(o.currentObservers),a=s.next();!a.done;a=s.next()){var f=a.value;f.next(e)}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var o=this;C(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=e;for(var n=o.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;C(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var o=e.observers;o.length;)o.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var o=this,n=this,i=n.hasError,s=n.isStopped,a=n.observers;return i||s?Z:(this.currentObservers=null,a.push(e),new g(function(){o.currentObservers=null,I(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var o=this,n=o.hasError,i=o.thrownError,s=o.isStopped;n?e.error(i):s&&e.complete()},t.prototype.asObservable=function(){var e=new b;return e.source=this,e},t.create=function(e,o){return new Mr(e,o)},t}(b);var Mr=function(r){v(t,r);function t(e,o){var n=r.call(this)||this;return n.destination=e,n.source=o,n}return t.prototype.next=function(e){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.next)===null||n===void 0||n.call(o,e)},t.prototype.error=function(e){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.error)===null||n===void 0||n.call(o,e)},t.prototype.complete=function(){var e,o;(o=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||o===void 0||o.call(e)},t.prototype._subscribe=function(e){var o,n;return(n=(o=this.source)===null||o===void 0?void 0:o.subscribe(e))!==null&&n!==void 0?n:Z},t}(nr);var q={now:function(){return(q.delegate||Date).now()},delegate:void 0};var F=function(r){v(t,r);function t(e,o,n){e===void 0&&(e=1/0),o===void 0&&(o=1/0),n===void 0&&(n=q);var i=r.call(this)||this;return i._bufferSize=e,i._windowTime=o,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=o===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,o),i}return t.prototype.next=function(e){var o=this,n=o.isStopped,i=o._buffer,s=o._infiniteTimeWindow,a=o._timestampProvider,f=o._windowTime;n||(i.push(e),!s&&i.push(a.now()+f)),this._trimBuffer(),r.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var o=this._innerSubscribe(e),n=this,i=n._infiniteTimeWindow,s=n._buffer,a=s.slice(),f=0;f<a.length&&!e.closed;f+=i?1:2)e.next(a[f]);return this._checkFinalizedStatuses(e),o},t.prototype._trimBuffer=function(){var e=this,o=e._bufferSize,n=e._timestampProvider,i=e._buffer,s=e._infiniteTimeWindow,a=(s?1:2)*o;if(o<1/0&&a<i.length&&i.splice(0,i.length-a),!s){for(var f=n.now(),c=0,u=1;u<i.length&&i[u]<=f;u+=2)c=u;c&&i.splice(0,c+1)}},t}(nr);var Pr=function(r){v(t,r);function t(e,o){return r.call(this)||this}return t.prototype.schedule=function(e,o){return o===void 0&&(o=0),this},t}(g);var V={setInterval:function(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];var n=V.delegate;return n?.setInterval?n.setInterval.apply(n,_([r,t],y(e))):setInterval.apply(void 0,_([r,t],y(e)))},clearInterval:function(r){var t=V.delegate;return(t?.clearInterval||clearInterval)(r)},delegate:void 0};var Ir=function(r){v(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n.pending=!1,n}return t.prototype.schedule=function(e,o){var n;if(o===void 0&&(o=0),this.closed)return this;this.state=e;var i=this.id,s=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(s,i,o)),this.pending=!0,this.delay=o,this.id=(n=this.id)!==null&&n!==void 0?n:this.requestAsyncId(s,this.id,o),this},t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),V.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,o,n){if(n===void 0&&(n=0),n!=null&&this.delay===n&&this.pending===!1)return o;o!=null&&V.clearInterval(o)},t.prototype.execute=function(e,o){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,o);if(n)return n;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,o){var n=!1,i;try{this.work(e)}catch(s){n=!0,i=s||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,o=e.id,n=e.scheduler,i=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,I(i,this),o!=null&&(this.id=this.recycleAsyncId(n,o,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},t}(Pr);var ir=function(){function r(t,e){e===void 0&&(e=r.now),this.schedulerActionCtor=t,this.now=e}return r.prototype.schedule=function(t,e,o){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(o,e)},r.now=q.now,r}();var Ar=function(r){v(t,r);function t(e,o){o===void 0&&(o=ir.now);var n=r.call(this,e,o)||this;return n.actions=[],n._active=!1,n}return t.prototype.flush=function(e){var o=this.actions;if(this._active){o.push(e);return}var n;this._active=!0;do if(n=e.execute(e.state,e.delay))break;while(e=o.shift());if(this._active=!1,n){for(;e=o.shift();)e.unsubscribe();throw n}},t}(ir);var sr=new Ar(Ir),jr=sr;var kr=new b(function(r){return r.complete()});function Cr(r){return r&&p(r.schedule)}var J=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function Rr(r){return p(r?.then)}function Wr(r){return p(r[W])}function Fr(r){return Symbol.asyncIterator&&p(r?.[Symbol.asyncIterator])}function Ur(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ce(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Lr=ce();function Dr(r){return p(r?.[Lr])}function $r(r){return vr(this,arguments,function(){var e,o,n,i;return B(this,function(s){switch(s.label){case 0:e=r.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,P(e.read())];case 3:return o=s.sent(),n=o.value,i=o.done,i?[4,P(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,P(n)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function qr(r){return p(r?.getReader)}function U(r){if(r instanceof b)return r;if(r!=null){if(Wr(r))return fe(r);if(J(r))return ue(r);if(Rr(r))return pe(r);if(Fr(r))return Vr(r);if(Dr(r))return le(r);if(qr(r))return me(r)}throw Ur(r)}function fe(r){return new b(function(t){var e=r[W]();if(p(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ue(r){return new b(function(t){for(var e=0;e<r.length&&!t.closed;e++)t.next(r[e]);t.complete()})}function pe(r){return new b(function(t){r.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,G)})}function le(r){return new b(function(t){var e,o;try{for(var n=E(r),i=n.next();!i.done;i=n.next()){var s=i.value;if(t.next(s),t.closed)return}}catch(a){e={error:a}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(e)throw e.error}}t.complete()})}function Vr(r){return new b(function(t){de(r,t).catch(function(e){return t.error(e)})})}function me(r){return Vr($r(r))}function de(r,t){var e,o,n,i;return hr(this,void 0,void 0,function(){var s,a;return B(this,function(f){switch(f.label){case 0:f.trys.push([0,5,6,11]),e=br(r),f.label=1;case 1:return[4,e.next()];case 2:if(o=f.sent(),!!o.done)return[3,4];if(s=o.value,t.next(s),t.closed)return[2];f.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=f.sent(),n={error:a},[3,11];case 6:return f.trys.push([6,,9,10]),o&&!o.done&&(i=e.return)?[4,i.call(e)]:[3,8];case 7:f.sent(),f.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Hr(r,t,e,o,n){o===void 0&&(o=0),n===void 0&&(n=!1);var i=t.schedule(function(){e(),n?r.add(this.schedule(null,o)):this.unsubscribe()},o);if(r.add(i),!n)return i}var Yr=j(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function ar(r,t){var e=typeof t=="object";return new Promise(function(o,n){var i=new R({next:function(s){o(s),i.unsubscribe()},error:n,complete:function(){e?o(t.defaultValue):n(new Yr)}});r.subscribe(i)})}function Br(r){return r instanceof Date&&!isNaN(r)}function T(r,t){return M(function(e,o){var n=0;e.subscribe(O(o,function(i){o.next(r.call(t,i,n++))}))})}var he=Array.isArray;function ve(r,t){return he(t)?r.apply(void 0,_([],y(t))):r(t)}function Nr(r){return T(function(t){return ve(r,t)})}function zr(r,t,e,o,n,i,s,a){var f=[],c=0,u=0,m=!1,l=function(){m&&!f.length&&!c&&t.complete()},d=function(h){return c<o?x(h):f.push(h)},x=function(h){i&&t.next(h),c++;var dr=!1;U(e(h,u++)).subscribe(O(t,function(D){n?.(D),i?d(D):t.next(D)},function(){dr=!0},void 0,function(){if(dr)try{c--;for(var D=function(){var Y=f.shift();s?Hr(t,s,function(){return x(Y)}):x(Y)};f.length&&c<o;)D();l()}catch(Y){t.error(Y)}}))};return r.subscribe(O(t,d,function(){m=!0,l()})),function(){a?.()}}function cr(r,t,e){return e===void 0&&(e=1/0),p(t)?cr(function(o,n){return T(function(i,s){return t(o,i,n,s)})(U(r(o,n)))},e):(typeof t=="number"&&(e=t),M(function(o,n){return zr(o,n,r,e)}))}var be=["addListener","removeListener"],ye=["addEventListener","removeEventListener"],xe=["on","off"];function H(r,t,e,o){if(p(e)&&(o=e,e=void 0),o)return H(r,t,e).pipe(Nr(o));var n=y(we(r)?ye.map(function(a){return function(f){return r[a](t,f,e)}}):_e(r)?be.map(Gr(r,t)):ge(r)?xe.map(Gr(r,t)):[],2),i=n[0],s=n[1];if(!i&&J(r))return cr(function(a){return H(a,t,e)})(U(r));if(!i)throw new TypeError("Invalid event target");return new b(function(a){var f=function(){for(var c=[],u=0;u<arguments.length;u++)c[u]=arguments[u];return a.next(1<c.length?c:c[0])};return i(f),function(){return s(f)}})}function Gr(r,t){return function(e){return function(o){return r[e](t,o)}}}function _e(r){return p(r.addListener)&&p(r.removeListener)}function ge(r){return p(r.on)&&p(r.off)}function we(r){return p(r.addEventListener)&&p(r.removeEventListener)}function Kr(r,t,e){r===void 0&&(r=0),e===void 0&&(e=jr);var o=-1;return t!=null&&(Cr(t)?e=t:o=t),new b(function(n){var i=Br(r)?+r-e.now():r;i<0&&(i=0);var s=0;return e.schedule(function(){n.closed||(n.next(s++),0<=o?this.schedule(void 0,o):n.complete())},i)})}function fr(r,t){return r===void 0&&(r=0),t===void 0&&(t=sr),r<0&&(r=0),Kr(r,r,t)}function S(r,t){return M(function(e,o){var n=0;e.subscribe(O(o,function(i){return r.call(t,i,n++)&&o.next(i)}))})}function L(r){return r<=0?function(){return kr}:M(function(t,e){var o=0;t.subscribe(O(e,function(n){++o<=r&&(e.next(n),r<=o&&e.complete())}))})}var Jr=(r,t)=>e=>({postMessage:o=>{let{errorCatcher:n=()=>()=>{},...i}=t??{};r.clients.get(e).then(s=>s?.postMessage(o,i)).catch(n(e,o))}});var Qr=(r=>(r.Ack="ack",r.Syn="syn",r))(Qr||{}),Se=Object.values(Qr),ur=r=>r.data,pr=r=>t=>t.type===r.toString(),Ee=r=>{let t=r.data;return typeof t=="object"&&t!==null&&"type"in t&&typeof t.type=="string"&&"instance"in t&&typeof t.instance=="string"&&"content"in t},Oe=()=>{let r="#";for(let t=0;t<3;t++)r+=`0${Math.floor(Math.random()*Math.pow(16,2)/2).toString(16)}`.slice(-2);return r},Te=class{__generateId;__instance;__colors;__listener;__log;__receiver;__subscription;__okToWrite;__write$;__recv$;__connect(r,t){let e=fr(t).subscribe(()=>this.__receiver.postMessage({content:r,instance:r,type:"syn".toString()}));this.__subscription.add(e),this.__subscription.add(this.__recv$.pipe(T(ur),S(pr("ack")),S(({content:o})=>o===r),L(1)).subscribe(({instance:o})=>{this.__okToWrite.next(0),this.__subscription.add(this.__recv$.pipe(S(({data:{type:n,instance:i}})=>!Se.includes(n)&&i===o)).subscribe(n=>{this.__listener(n);let{data:i}=n;i._id!==void 0&&this.__receiver.postMessage({...i,content:i,instance:r,type:"ack"})})),e.unsubscribe()})),this.__subscription.add(this.__recv$.pipe(T(ur),S(pr("syn")),S(({instance:o})=>o!==r),L(1)).subscribe(({content:o})=>{this.__receiver.postMessage({content:o,instance:r,type:"ack"})}))}__write(r,t){let e={};t!==void 0&&(e._id=t),this.__subscription.add(this.__write$.subscribe(()=>{let o=Object.assign(r,{instance:this.__instance,...e});this.__receiver.postMessage(o),this.__log?.(o)}))}constructor(r,t,e,o){this.__generateId=()=>globalThis.crypto.randomUUID();let n=this.__generateId(),i=new F,s=H(t,"message").pipe(S(Ee)).subscribe(i);this.__subscription=new g,this.__subscription.add(s),this.__okToWrite=new F(1),this.__write$=this.__okToWrite.pipe(L(1)),this.__recv$=i.asObservable(),this.__listener=r,this.__log=o?.log&&o.log.bind(this),this.__instance=n;let a=Oe();this.__colors={bg:`${a}22`,fg:a},this.__receiver=e,this.__connect(n,o?.period?o.period:10)}disconnect(){this.__subscription.unsubscribe()}send(r){this.__write(r)}ackSend(r){let t,e=new Promise(n=>{t=n}),o=this.__generateId();return this.__subscription.add(this.__recv$.pipe(T(ur),S(pr("ack")),S(({_id:n})=>n===o),L(1)).subscribe(()=>t())),this.__write(r,o),e}get instance(){return this.__instance}get colors(){return this.__colors}get ready(){return ar(this.__write$).then(()=>{})}},Xr=Te;var Q=new Map,lr=new Map,mr=new Map,Zr=(r,t)=>{let e=t.keys(),o,{done:n=!1,value:i}=e.next();for(;!n&&o===void 0;){i!==void 0&&r.startsWith(i)&&(o=i,n=!0);let{value:s,done:a=!1}=e.next();n=a,i=s}return o},Me=r=>r!==null&&"id"in r,Pe=r=>t=>console.error(`[SW]: error on ${r} - ${String(t)}`),Ie=Jr(self,{errorCatcher:Pe}),Ae=r=>function({data:e}){let o=e;switch(o.type){case"set-source-map":{let{content:n}=o,i=Object.entries(n).reduce((s,[a,f])=>{let{clientSourceMap:c,clientTosMap:u}=s,{headers:m={}}=f;return Object.keys(m).length>0&&u.set(encodeURI(f.to),m),c.set(encodeURI(a),f),s},{clientSourceMap:new Map,clientTosMap:new Map});lr.set(r,i.clientSourceMap),mr.set(r,i.clientTosMap);break}case"unload-client":{lr.delete(r),mr.delete(r),Q.delete(r),this.disconnect();break}default:break}},je=r=>{let t=new Map,e=new F,o={addEventListener(n,i){t.set(i,e.subscribe(s=>i(s)))},removeEventListener(n,i){t.get(i)?.unsubscribe(),t.delete(i)}};return{buffer:e,channel:new Xr(Ae(r),o,Ie(r))}},ke=r=>{let t=Q.get(r);return t||(t=je(r),Q.set(r,t)),t};self.addEventListener("install",()=>{self.skipWaiting().catch(r=>console.error(`[SW] error while skipWaiting - ${String(r)}`))});self.addEventListener("activate",r=>{r.waitUntil(self.clients.claim())});self.addEventListener("message",r=>{let{source:t}=r;if(!Me(t))return;let{id:e}=t;ke(e).buffer.next(r)});self.addEventListener("fetch",r=>{let t=r.clientId!==""?r.clientId:r.resultingClientId,e=lr.get(t);if(!e)return r.respondWith(self.fetch(r.request));let o=mr.get(t),{request:{url:n}}=r,i=Zr(n,e),s=Zr(n,o),a=new Headers(r.request.headers),f={};if(i!==void 0){let m=e.get(i)?.to,l=e.get(i)?.headers??{},d=n.substring(i.length);f=e.get(i)?.query??{},n=`${m}${d}`,Object.entries(l).forEach(([x,h])=>a.set(x,h))}if(s!==void 0){let m=o.get(s)??{};Object.entries(m).forEach(([l,d])=>a.set(l,d))}let c;try{let m=new URL(n);Object.entries(f).forEach(([l,d])=>m.searchParams.set(l,d)),c=m.href}catch{c=n}let u=Q.get(t)?.channel;if(u!==void 0&&process.env.MODE==="development"){let m={background:u.colors.bg,color:u.colors.fg};console.groupCollapsed("%c Fetch from Service Worker ",Object.entries(m).map(([l,d])=>`${l}: ${d}`).join("; ")),console.info(`sw is fetching %c ${c}`,"background: lightgreen; color: darkgreen"),console.log({clientId:t,clientSourceMap:e,request:r.request}),console.groupEnd()}r.respondWith(self.fetch(c,{...r.request,headers:a}).catch(m=>(console.error(m),Promise.reject(m))))});})();
@@ -1,16 +0,0 @@
1
- /// <reference lib="webworker" />
2
- interface UrlMatchPair {
3
- headers: Record<string, string>;
4
- originalFrom: `${string}/`;
5
- query: Record<string, string>;
6
- to: `${string}/`;
7
- }
8
- type SourceMapItems = Record<`${string}/`, UrlMatchPair>;
9
- type IncomingWorkerMessage = {
10
- content: SourceMapItems;
11
- type: 'set-source-map';
12
- } | {
13
- content: Record<string, never>;
14
- type: 'unload-client';
15
- };
16
- export type { IncomingWorkerMessage, SourceMapItems, UrlMatchPair, };
@@ -1,146 +0,0 @@
1
- import PostChannel, { fromServiceWorkerToReceiver } from '@micro-lc/post-channel';
2
- import { ReplaySubject } from 'rxjs';
3
- // every sw client opens a dedicated channel
4
- // this map collects, per client, a buffer and the communication channel itself
5
- const openChannels = new Map();
6
- // source maps can be stored by unique
7
- // key which is either the scope or the clientId
8
- const sourceMap = new Map();
9
- // reverse map
10
- const tosMap = new Map();
11
- const isAvailable = (key, map) => {
12
- const iter = map.keys();
13
- let matchingKey;
14
- let { done = false, value } = iter.next();
15
- while (!done && matchingKey === undefined) {
16
- if (value !== undefined && key.startsWith(value)) {
17
- matchingKey = value;
18
- done = true;
19
- }
20
- const { value: nextValue, done: nextDone = false } = iter.next();
21
- done = nextDone;
22
- value = nextValue;
23
- }
24
- return matchingKey;
25
- };
26
- const isWindowClient = (source) => source !== null && 'id' in source;
27
- const errorCatcher = (clientId) => (error) => console.error(`[SW]: error on ${clientId} - ${String(error)}`);
28
- const getReceiver = fromServiceWorkerToReceiver(self, { errorCatcher });
29
- const makeListener = (clientId) => {
30
- return function listener({ data }) {
31
- // todo: missing validation
32
- const workerMessageData = data;
33
- switch (workerMessageData.type) {
34
- case 'set-source-map': {
35
- const { content } = workerMessageData;
36
- const clientMaps = Object.entries(content).reduce((maps, [key, value]) => {
37
- const { clientSourceMap, clientTosMap } = maps;
38
- if (Object.keys(value.headers).length > 0) {
39
- clientTosMap.set(encodeURI(value.to), value.headers);
40
- }
41
- clientSourceMap.set(encodeURI(key), value);
42
- return maps;
43
- }, { clientSourceMap: new Map(), clientTosMap: new Map() });
44
- sourceMap.set(clientId, clientMaps.clientSourceMap);
45
- tosMap.set(clientId, clientMaps.clientTosMap);
46
- break;
47
- }
48
- case 'unload-client': {
49
- openChannels.delete(clientId);
50
- this.disconnect();
51
- break;
52
- }
53
- default:
54
- break;
55
- }
56
- };
57
- };
58
- const createChannel = (clientId) => {
59
- const listenerToSubscription = new Map();
60
- const buffer = new ReplaySubject();
61
- const sender = {
62
- addEventListener(_, listener) {
63
- listenerToSubscription.set(listener, buffer.subscribe((msg) => listener(msg)));
64
- },
65
- removeEventListener(_, listener) {
66
- listenerToSubscription.get(listener)?.unsubscribe();
67
- listenerToSubscription.delete(listener);
68
- },
69
- };
70
- return {
71
- buffer,
72
- channel: new PostChannel(makeListener(clientId), sender, getReceiver(clientId)),
73
- };
74
- };
75
- const getCachedOpenChannel = (clientId) => {
76
- let ch = openChannels.get(clientId);
77
- if (!ch) {
78
- ch = createChannel(clientId);
79
- openChannels.set(clientId, ch);
80
- }
81
- return ch;
82
- };
83
- self.addEventListener('install', () => {
84
- // on service-worker.js update => immediate kill switch and update
85
- // https://whatwebcando.today/articles/handling-service-worker-updates/
86
- // https://stackoverflow.com/questions/33986976/how-can-i-remove-a-buggy-service-worker-or-implement-a-kill-switch/38980776#38980776
87
- self.skipWaiting()
88
- .catch((err) => console.error(`[SW] error while skipWaiting - ${String(err)}`));
89
- });
90
- self.addEventListener('activate', (event) => {
91
- // all fetch events should be handled by the
92
- // service worker as soon as active
93
- event.waitUntil(self.clients.claim());
94
- });
95
- self.addEventListener('message', (message) => {
96
- // messages allowed are `set-source-map` which replies with an
97
- // acknowledgment `source-map-ack` that informs the client
98
- // all is set to reverse proxy their fetch calls
99
- const { source } = message;
100
- if (!isWindowClient(source)) {
101
- return;
102
- }
103
- const { id: clientId } = source;
104
- getCachedOpenChannel(clientId).buffer.next(message);
105
- });
106
- self.addEventListener('fetch', (event) => {
107
- const clientId = event.clientId !== '' ? event.clientId : event.resultingClientId;
108
- const clientSourceMap = sourceMap.get(clientId);
109
- if (!clientSourceMap) {
110
- return event.respondWith(self.fetch(event.request));
111
- }
112
- // there must be a tosMap is clientSourceMap ain't undefined
113
- const clientTosMap = tosMap.get(clientId);
114
- let { request: { url } } = event;
115
- const key = isAvailable(url, clientSourceMap);
116
- const to = isAvailable(url, clientTosMap);
117
- const headers = new Headers(event.request.headers);
118
- let extraQuery = {};
119
- if (key !== undefined) {
120
- const value = clientSourceMap.get(key)?.to;
121
- const extraHeaders = clientSourceMap.get(key)?.headers;
122
- const rest = url.substring(key.length);
123
- extraQuery = clientSourceMap.get(key)?.query;
124
- url = `${value}${rest}`;
125
- Object.entries(extraHeaders).forEach(([headerKey, headerValue]) => headers.set(headerKey, headerValue));
126
- }
127
- if (to !== undefined) {
128
- const extraHeaders = clientTosMap.get(to);
129
- Object.entries(extraHeaders).forEach(([headerKey, headerValue]) => headers.set(headerKey, headerValue));
130
- }
131
- let finalUrl;
132
- try {
133
- const urlInstance = new URL(url);
134
- Object.entries(extraQuery).forEach(([qk, qv]) => urlInstance.searchParams.set(qk, qv));
135
- finalUrl = urlInstance.href;
136
- }
137
- catch {
138
- finalUrl = url;
139
- }
140
- console.log({ clientId, clientSourceMap, finalUrl });
141
- event.respondWith(self.fetch(finalUrl, { ...event.request, headers })
142
- .catch((error) => {
143
- console.error(error);
144
- return Promise.reject(error);
145
- }));
146
- });
@@ -1,2 +0,0 @@
1
- export declare function parse(input: string, context: Record<string, unknown>, preserveUnknown?: boolean): string;
2
- export declare const compileObject: <T extends Record<string, string>>(obj: T, context: Record<string, unknown>) => T;
@@ -1,130 +0,0 @@
1
- var LexerState;
2
- (function (LexerState) {
3
- LexerState[LexerState["Literal"] = 0] = "Literal";
4
- LexerState[LexerState["Normal"] = 1] = "Normal";
5
- })(LexerState || (LexerState = {}));
6
- class Lexer {
7
- _input;
8
- _length;
9
- _idx = 0;
10
- _mode = LexerState.Literal;
11
- _literals = [];
12
- _variables = [];
13
- _braketCount = 0;
14
- _done = false;
15
- constructor(input) {
16
- this._input = input;
17
- this._length = input.length;
18
- }
19
- concatToLastLiteral(concat) {
20
- // SAFETY: _literals here is always at least long 1
21
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
- this._literals.push(this._literals.pop().concat(concat));
23
- }
24
- concatToLastVariable(concat) {
25
- // SAFETY: _variables here is always at least long 1
26
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
27
- this._variables.push(this._variables.pop().concat(concat));
28
- }
29
- get() {
30
- const rawLiterals = [...this._literals];
31
- const literals = Object.assign([], rawLiterals);
32
- Object.defineProperty(literals, 'raw', { value: rawLiterals, writable: false });
33
- return {
34
- literals: literals,
35
- variables: this._variables,
36
- };
37
- }
38
- run() {
39
- if (this._length === 0) {
40
- this._literals.push('');
41
- }
42
- while (this._idx < this._length) {
43
- const char = this._input.charAt(this._idx);
44
- switch (this._mode) {
45
- case LexerState.Literal: {
46
- if (this._literals.length === 0) {
47
- this._literals.push('');
48
- }
49
- if (char === '{'
50
- && this._idx + 1 !== this._length
51
- && this._input.charAt(this._idx + 1) === '{') {
52
- this._literals.push('');
53
- this._variables.push('');
54
- this._mode = LexerState.Normal;
55
- this._idx += 1;
56
- }
57
- else {
58
- this.concatToLastLiteral(char);
59
- }
60
- break;
61
- }
62
- case LexerState.Normal:
63
- if (char === '}' && this._input.charAt(this._idx + 1) === '}') {
64
- this._mode = LexerState.Literal;
65
- this._idx += 1;
66
- }
67
- else {
68
- this.concatToLastVariable(char);
69
- }
70
- break;
71
- default:
72
- break;
73
- }
74
- this._idx += 1;
75
- }
76
- if (this._mode === LexerState.Normal) {
77
- this._literals.pop();
78
- // SAFETY: _variables here is always at least long 1
79
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
80
- this.concatToLastLiteral(`{{${this._variables.pop()}`);
81
- }
82
- this._done = true;
83
- }
84
- }
85
- const isSquareBrakets = (field) => {
86
- const trimmed = field.trim();
87
- if (!(trimmed.startsWith('[') && trimmed.endsWith(']'))) {
88
- return false;
89
- }
90
- const inner = trimmed.slice(1).slice(0, -1).trim();
91
- if (Number.parseInt(inner).toString(10) !== inner) {
92
- return false;
93
- }
94
- return true;
95
- };
96
- const getNumber = (field) => {
97
- return Number.parseInt(field.trim().slice(1).slice(0, -1)
98
- .trim());
99
- };
100
- function interpolate(context, path, preserveUnknown) {
101
- if (!path.trim()) {
102
- return preserveUnknown ? `{{${path}}}` : '';
103
- }
104
- const result = path.trim().split('.').reduce((superctx, field) => {
105
- if (Array.isArray(superctx) && isSquareBrakets(field)) {
106
- return superctx[getNumber(field)];
107
- }
108
- if (typeof superctx === 'object' && superctx !== null && field in superctx) {
109
- return superctx[field];
110
- }
111
- return undefined;
112
- }, { ...context });
113
- if (typeof result === 'string') {
114
- return result;
115
- }
116
- return preserveUnknown ? `{{${path}}}` : '';
117
- }
118
- export function parse(input, context, preserveUnknown = false) {
119
- const lexer = new Lexer(input);
120
- lexer.run();
121
- const template = lexer.get();
122
- let [acc] = template.literals;
123
- for (let i = 0; i < template.variables.length; i++) {
124
- acc = acc
125
- .concat(interpolate(context, template.variables[i], preserveUnknown))
126
- .concat(template.literals[i + 1]);
127
- }
128
- return acc;
129
- }
130
- export const compileObject = (obj, context) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, parse(value, context)]));