@amedia/user 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare const requestStorage: (namespaces: string[]) => void;
@@ -1,17 +1,28 @@
1
1
  import { Record, Unknown, Dictionary } from 'runtypes';
2
- import { UserAttributes } from '../types';
3
2
  export declare const EuropaSchema: Record<{
4
3
  namespaces: Dictionary<Unknown, string>;
5
4
  }, false>;
6
5
  export declare const clearLocalCache: () => Promise<void>;
7
6
  export declare const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
8
- export declare const getNamespaces: (namespaces: string[], options?: {
7
+ export declare const getNamespaces: <S extends {
8
+ [namespace: string]: {
9
+ [index: string]: unknown;
10
+ };
11
+ }, Namespaces extends (keyof S)[]>(namespaces: Namespaces, options?: {
9
12
  ignoreCache: boolean;
10
- }) => Promise<Pick<UserAttributes, 'storage'>>;
11
- export declare const saveNamespace: (namespace: string, data: Object) => Promise<Pick<UserAttributes, "storage">>;
13
+ }) => Promise<Pick<S, Namespaces[number]>>;
14
+ export declare const saveNamespace: (namespace: string, data: Object) => Promise<Pick<{
15
+ [namespace: string]: {
16
+ [index: string]: unknown;
17
+ };
18
+ }, string>>;
12
19
  export declare const getAllNamespaces: () => Promise<{
13
20
  namespaces: {
14
21
  [x: string]: unknown;
15
22
  };
16
23
  }>;
17
- export declare const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<UserAttributes, "storage">>;
24
+ export declare const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<{
25
+ [namespace: string]: {
26
+ [index: string]: unknown;
27
+ };
28
+ }, string>>;
@@ -1,14 +1,20 @@
1
1
  import { State, UserAttributes } from '../types';
2
2
  export declare enum AmediaUserEvents {
3
3
  REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
4
+ REQUEST_STORAGE_NAMESPACES = "amedia-user.request-storage-namespaces",
4
5
  ON_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated",
5
- ON_STATE_UPDATED = "amedia-user.on-state-updated"
6
+ ON_STATE_UPDATED = "amedia-user.on-state-updated",
7
+ ON_STORAGE_UPDATED = "amedia-user.on-storage-updated"
6
8
  }
7
9
  declare global {
8
10
  interface WindowEventMap {
9
11
  [AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
12
+ [AmediaUserEvents.REQUEST_STORAGE_NAMESPACES]: CustomEvent<Array<string>>;
10
13
  [AmediaUserEvents.ON_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
11
14
  [AmediaUserEvents.ON_STATE_UPDATED]: CustomEvent<State>;
15
+ [AmediaUserEvents.ON_STORAGE_UPDATED]: CustomEvent<{
16
+ [index: string]: unknown;
17
+ }>;
12
18
  }
13
19
  }
14
20
  export declare const listenForUserAttributeRequests: () => void;
package/dist/index.d.ts CHANGED
@@ -1,18 +1,14 @@
1
1
  import 'regenerator-runtime';
2
- import { State, UserAttributes } from './types';
2
+ import User from './lib/User';
3
3
  /**
4
4
  * Enables you to subscribe to the user attributes you care about and
5
5
  * get notified when something changes
6
6
  */
7
- export declare class User {
8
- private attributes;
9
- private namespaces;
10
- private extraData?;
11
- withAttributes(attributes: Array<keyof UserAttributes>): this;
12
- withStorage(namespaces: Array<string>): this;
13
- withExtraData(extraData?: Array<string>): this;
14
- subscribe(onUserUpdated: (attributes: UserAttributes) => void, onStateUpdated?: (state: State) => void): void;
15
- }
7
+ export declare const user: () => User<import("./types").UserAttributes, {
8
+ [index: string]: unknown;
9
+ }, (keyof import("./types").UserAttributes)[], string[], {
10
+ state: import("./types").State;
11
+ }>;
16
12
  /**
17
13
  * This will, if necessary, trigger a redirect to www.aid.no and return
18
14
  * to the requestedUrl if supplied or the current url before redirecting away if not.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.user=t():e.user=t()}(this,(function(){return(()=>{var e={651:(e,t,r)=>{var n,o,i;void 0===(o="function"==typeof(n=i=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(n){function o(){}function i(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var a=JSON.stringify(r);/^[\{\[]/.test(a)&&(r=a)}catch(e){}r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+r+c}}function a(e,r){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],a=0;a<i.length;a++){var c=i[a].split("="),u=c.slice(1).join("=");r||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var s=t(c[0]);if(u=(n.read||n)(u,s)||t(u),r)try{u=JSON.parse(u)}catch(e){}if(o[s]=u,e===s)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return a(e,!1)},o.getJSON=function(e){return a(e,!0)},o.remove=function(t,r){i(t,"",e(r,{expires:-1}))},o.defaults={},o.withConverter=r,o}((function(){}))})?n.call(t,r,t,e):n)||(e.exports=o),e.exports=i()},466:(e,t,r)=>{e.exports=function e(t,r,n){function o(a,c){if(!r[a]){if(!t[a]){if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=r[a]={exports:{}};t[a][0].call(s.exports,(function(e){return o(t[a][1][e]||e)}),s,s.exports,e,t,r,n)}return r[a].exports}for(var i=void 0,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(e,t,n){(function(e){"use strict";var r,n,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),c=e.document.createTextNode("");a.observe(c,{characterData:!0}),r=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var u=new e.MessageChannel;u.port1.onmessage=f,r=function(){u.port2.postMessage(0)}}var s=[];function f(){var e,t;n=!0;for(var r=s.length;r;){for(t=s,s=[],e=-1;++e<r;)t[e]();r=s.length}n=!1}t.exports=function(e){1!==s.push(e)||n||r()}}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){"use strict";var n=e(1);function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,e!==o&&v(this,e)}function f(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function l(e,t,r){n((function(){var n;try{n=t(r)}catch(t){return i.reject(e,t)}n===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,n)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function v(e,t){var r=!1;function n(t){r||(r=!0,i.reject(e,t))}function o(t){r||(r=!0,i.resolve(e,t))}var a=h((function(){t(o,n)}));"error"===a.status&&n(a.value)}function h(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this;var r=new this.constructor(o);return this.state!==u?l(r,this.state===c?e:t,this.outcome):this.queue.push(new f(r,e,t)),r},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var r=h(d,t);if("error"===r.status)return i.reject(e,r.value);var n=r.value;if(n)v(e,n);else{e.state=c,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},s.resolve=function(e){return e instanceof this?e:i.resolve(new this(o),e)},s.reject=function(e){var t=new this(o);return i.reject(t,e)},s.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var a=new Array(r),c=0,u=-1,s=new this(o);++u<r;)f(e[u],u);return s;function f(e,o){t.resolve(e).then((function(e){a[o]=e,++c!==r||n||(n=!0,i.resolve(s,a))}),(function(e){n||(n=!0,i.reject(s,e))}))}},s.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r,n=e.length,a=!1;if(!n)return this.resolve([]);for(var c=-1,u=new this(o);++c<n;)r=e[c],t.resolve(r).then((function(e){a||(a=!0,i.resolve(u,e))}),(function(e){a||(a=!0,i.reject(u,e))}));return u}},{1:1}],3:[function(e,t,n){(function(t){"use strict";"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function i(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var a=Promise;function c(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function u(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,v={},h=Object.prototype.toString,p="readonly",y="readwrite";function g(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),o=0;o<t;o++)n[o]=e.charCodeAt(o);return r}function m(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a((function(t){var r=e.transaction(l,y),n=i([""]);r.objectStore(l).put(n,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return d=e}))}function b(e){var t=v[e.name],r={};r.promise=new a((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function E(e){var t=v[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function _(e,t){var r=v[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function w(e,t){return new a((function(r,n){if(v[e.name]=v[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);b(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var a=o.open.apply(o,i);t&&(a.onupgradeneeded=function(t){var r=a.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(l)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),n(a.error)},a.onsuccess=function(){r(a.result),E(e)}}))}function S(e){return w(e,!1)}function R(e){return w(e,!0)}function I(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.version<e.db.version,o=e.version>e.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||r){if(r){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function O(e){return i([g(atob(e.data))],{type:e.type})}function C(e){return e&&e.__local_forage_encoded_blob}function T(e){var t=this,r=t._initReady().then((function(){var e=v[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return u(r,e,e),r}function N(e,t,r,n){void 0===n&&(n=1);try{var o=e.db.transaction(e.storeName,t);r(null,o)}catch(o){if(n>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),R(e)})).then((function(){return function(e){b(e);for(var t=v[e.name],r=t.forages,n=0;n<r.length;n++){var o=r[n];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,S(e).then((function(t){return e.db=t,I(e)?R(e):t})).then((function(n){e.db=t.db=n;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=n})).catch((function(t){throw _(e,t),t}))}(e).then((function(){N(e,t,r,n-1)}))})).catch(r);r(o)}}var A={_driver:"asyncStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]=e[n];var o=v[r.name];o||(o={forages:[],db:null,dbReady:null,deferredOperations:[]},v[r.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=T);var i=[];function c(){return a.resolve()}for(var u=0;u<o.forages.length;u++){var s=o.forages[u];s!==t&&i.push(s._initReady().catch(c))}var f=o.forages.slice(0);return a.all(i).then((function(){return r.db=o.db,S(r)})).then((function(e){return r.db=e,I(r,t._defaultConfig.version)?R(r):e})).then((function(e){r.db=o.db=e,t._dbInfo=r;for(var n=0;n<f.length;n++){var i=f[n];i!==t&&(i._dbInfo.db=r.db,i._dbInfo.version=r.version)}}))},_support:function(){try{if(!o||!o.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).openCursor(),c=1;a.onsuccess=function(){var r=a.result;if(r){var n=r.value;C(n)&&(n=O(n));var o=e(n,r.key,c++);void 0!==o?t(o):r.continue()}else t()},a.onerror=function(){n(a.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),C(e)&&(e=O(e)),t(e)},a.onerror=function(){n(a.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},setItem:function(e,t,r){var n=this;e=s(e);var o=new a((function(r,o){var i;n.ready().then((function(){return i=n._dbInfo,"[object Blob]"===h.call(t)?m(i.db).then((function(e){return e?t:(r=t,new a((function(e,t){var n=new FileReader;n.onerror=t,n.onloadend=function(t){var n=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:n,type:r.type})},n.readAsBinaryString(r)})));var r})):t})).then((function(t){N(n._dbInfo,y,(function(i,a){if(i)return o(i);try{var c=a.objectStore(n._dbInfo.storeName);null===t&&(t=void 0);var u=c.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),r(t)},a.onabort=a.onerror=function(){var e=u.error?u.error:u.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return c(o,r),o},removeItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,y,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){n(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},clear:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,y,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},length:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,p,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},key:function(e,t){var r=this,n=new a((function(t,n){e<0?t(null):r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName),c=!1,u=a.openKeyCursor();u.onsuccess=function(){var r=u.result;r?0===e||c?t(r.key):(c=!0,r.advance(e)):t(null)},u.onerror=function(){n(u.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},keys:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,p,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var t=i.result;t?(a.push(t.key),t.continue()):e(a)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},dropInstance:function(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,i=this;if(e.name){var u=e.name===r.name&&i._dbInfo.db?a.resolve(i._dbInfo.db):S(e).then((function(t){var r=v[e.name],n=r.forages;r.db=t;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=t;return t}));n=e.storeName?u.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var r=t.version+1;b(e);var n=v[e.name],i=n.forages;t.close();for(var c=0;c<i.length;c++){var u=i[c];u._dbInfo.db=null,u._dbInfo.version=r}return new a((function(t,n){var i=o.open(e.name,r);i.onerror=function(e){i.result.close(),n(e)},i.onupgradeneeded=function(){i.result.deleteObjectStore(e.storeName)},i.onsuccess=function(){var e=i.result;e.close(),t(e)}})).then((function(e){n.db=e;for(var t=0;t<i.length;t++){var r=i[t];r._dbInfo.db=e,E(r._dbInfo)}})).catch((function(t){throw(_(e,t)||a.resolve()).catch((function(){})),t}))}})):u.then((function(t){b(e);var r=v[e.name],n=r.forages;t.close();for(var i=0;i<n.length;i++)n[i]._dbInfo.db=null;return new a((function(t,r){var n=o.deleteDatabase(e.name);n.onerror=n.onblocked=function(e){var t=n.result;t&&t.close(),r(e)},n.onsuccess=function(){var e=n.result;e&&e.close(),t(e)}})).then((function(e){r.db=e;for(var t=0;t<n.length;t++)E(n[t]._dbInfo)})).catch((function(t){throw(_(e,t)||a.resolve()).catch((function(){})),t}))}))}else n=a.reject("Invalid arguments");return c(n,t),n}};var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=/^~~local_forage_type~([^~]+)~/,U="__lfsc__:",x=U.length,L="arbf",k="blob",F="si08",D="ui08",M="uic8",B="si16",V="si32",$="ur16",Y="ui32",K="fl32",G="fl64",z=x+L.length,q=Object.prototype.toString;function W(e){var t,r,n,o,i,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var s=new ArrayBuffer(a),f=new Uint8Array(s);for(t=0;t<c;t+=4)r=j.indexOf(e[t]),n=j.indexOf(e[t+1]),o=j.indexOf(e[t+2]),i=j.indexOf(e[t+3]),f[u++]=r<<2|n>>4,f[u++]=(15&n)<<4|o>>2,f[u++]=(3&o)<<6|63&i;return s}function H(e){var t,r=new Uint8Array(e),n="";for(t=0;t<r.length;t+=3)n+=j[r[t]>>2],n+=j[(3&r[t])<<4|r[t+1]>>4],n+=j[(15&r[t+1])<<2|r[t+2]>>6],n+=j[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var J={serialize:function(e,t){var r="";if(e&&(r=q.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===q.call(e.buffer))){var n,o=U;e instanceof ArrayBuffer?(n=e,o+=L):(n=e.buffer,"[object Int8Array]"===r?o+=F:"[object Uint8Array]"===r?o+=D:"[object Uint8ClampedArray]"===r?o+=M:"[object Int16Array]"===r?o+=B:"[object Uint16Array]"===r?o+=$:"[object Int32Array]"===r?o+=V:"[object Uint32Array]"===r?o+=Y:"[object Float32Array]"===r?o+=K:"[object Float64Array]"===r?o+=G:t(new Error("Failed to get type for BinaryArray"))),t(o+H(n))}else if("[object Blob]"===r){var i=new FileReader;i.onload=function(){var r="~~local_forage_type~"+e.type+"~"+H(this.result);t("__lfsc__:blob"+r)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,x)!==U)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(x,z);if(n===k&&P.test(r)){var o=r.match(P);t=o[1],r=r.substring(o[0].length)}var a=W(r);switch(n){case L:return a;case k:return i([a],{type:t});case F:return new Int8Array(a);case D:return new Uint8Array(a);case M:return new Uint8ClampedArray(a);case B:return new Int16Array(a);case $:return new Uint16Array(a);case V:return new Int32Array(a);case Y:return new Uint32Array(a);case K:return new Float32Array(a);case G:return new Float64Array(a);default:throw new Error("Unkown type: "+n)}},stringToBuffer:W,bufferToString:H};function Q(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function X(e,t,r,n,o,i){e.executeSql(r,n,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?i(e,a):Q(e,t,(function(){e.executeSql(r,n,o,i)}),i)}),i):i(e,a)}),i)}function Z(e,t,r,n){var o=this;e=s(e);var i=new a((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var c=t,u=o._dbInfo;u.serializer.serialize(t,(function(t,s){s?a(s):u.db.transaction((function(r){X(r,u,"INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(c)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(n>0)return void i(Z.apply(o,[e,c,r,n-1]));a(t)}}))}))})).catch(a)}));return c(i,r),i}function ee(e){return new a((function(t,r){e.transaction((function(n){n.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,n){for(var o=[],i=0;i<n.rows.length;i++)o.push(n.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){r(t)}))}),(function(e){r(e)}))}))}var te={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var o=new a((function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction((function(o){Q(o,r,(function(){t._dbInfo=r,e()}),(function(e,t){n(t)}))}),n)}));return r.serializer=J,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT * FROM "+o.storeName,[],(function(r,n){for(var i=n.rows,a=i.length,c=0;c<a;c++){var u=i.item(c),s=u.value;if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,u.key,c+1)))return void t(s)}t()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var n=r.rows.length?r.rows.item(0).value:null;n&&(n=o.serializer.deserialize(n)),t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},setItem:function(e,t,r){return Z.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},clear:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"DELETE FROM "+n.storeName,[],(function(){e()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},length:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],(function(t,r){var n=r.rows.item(0).c;e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},key:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},keys:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"SELECT key FROM "+n.storeName,[],(function(t,r){for(var n=[],o=0;o<r.rows.length;o++)n.push(r.rows.item(o).key);e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},dropInstance:function(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,o=this;return c(n=e.name?new a((function(t){var n;n=e.name===r.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:n,storeNames:[e.storeName]}):t(ee(n))})).then((function(e){return new a((function(t,r){e.db.transaction((function(n){function o(e){return new a((function(t,r){n.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){r(t)}))}))}for(var i=[],c=0,u=e.storeNames.length;c<u;c++)i.push(o(e.storeNames[c]));a.all(i).then((function(){t()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):a.reject("Invalid arguments"),t),n}};function re(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function ne(){return!function(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}()||localStorage.length>0}var oe={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=re(e,this._defaultConfig),ne()?(this._dbInfo=t,t.serializer=J,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then((function(){for(var t=r._dbInfo,n=t.keyPrefix,o=n.length,i=localStorage.length,a=1,c=0;c<i;c++){var u=localStorage.key(c);if(0===u.indexOf(n)){var s=localStorage.getItem(u);if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,u.substring(o),a++)))return s}}}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=r.ready().then((function(){var t=r._dbInfo,n=localStorage.getItem(t.keyPrefix+e);return n&&(n=t.serializer.deserialize(n)),n}));return c(n,t),n},setItem:function(e,t,r){var n=this;e=s(e);var o=n.ready().then((function(){void 0===t&&(t=null);var r=t;return new a((function(o,i){var a=n._dbInfo;a.serializer.serialize(t,(function(t,n){if(n)i(n);else try{localStorage.setItem(a.keyPrefix+e,t),o(r)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return c(o,r),o},removeItem:function(e,t){var r=this;e=s(e);var n=r.ready().then((function(){var t=r._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return c(n,t),n},clear:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}}));return c(r,e),r},length:function(e){var t=this.keys().then((function(e){return e.length}));return c(t,e),t},key:function(e,t){var r=this,n=r.ready().then((function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t}));return c(n,t),n},keys:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo,r=localStorage.length,n=[],o=0;o<r;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&n.push(i.substring(e.keyPrefix.length))}return n}));return c(r,e),r},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var n,o=this;return c(n=e.name?new a((function(t){e.storeName?t(re(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}})):a.reject("Invalid arguments"),t),n}},ie=function(e,t){for(var r=e.length,n=0;n<r;){if((o=e[n])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0;n++}var o,i;return!1},ae=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ce={},ue={},se={INDEXEDDB:A,WEBSQL:te,LOCALSTORAGE:oe},fe=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],le=["dropInstance"],de=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(le),ve={description:"",driver:fe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function he(e,t){e[t]=function(){var r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function pe(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(ae(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var ye=new(function(){function e(t){for(var r in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),se)if(se.hasOwnProperty(r)){var n=se[r],o=n._driver;this[r]=o,ce[o]||this.defineDriver(n)}this._defaultConfig=pe({},ve),this._config=pe({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":n(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,r){var n=new a((function(t,r){try{var n=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(o);for(var i=de.concat("_initStorage"),u=0,s=i.length;u<s;u++){var f=i[u];if((!ie(le,f)||e[f])&&"function"!=typeof e[f])return void r(o)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),r=a.reject(t);return c(r,arguments[arguments.length-1]),r}},r=0,n=le.length;r<n;r++){var o=le[r];e[o]||(e[o]=t(o))}}();var l=function(r){ce[n]&&console.info("Redefining LocalForage driver: "+n),ce[n]=e,ue[n]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(l,r):l(!!e._support):l(!0)}catch(e){r(e)}}));return u(n,t,r),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,r){var n=ce[e]?a.resolve(ce[e]):a.reject(new Error("Driver not found."));return u(n,t,r),n},e.prototype.getSerializer=function(e){var t=a.resolve(J);return u(t,e),t},e.prototype.ready=function(e){var t=this,r=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return u(r,e,e),r},e.prototype.setDriver=function(e,t,r){var n=this;ae(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){n._config.driver=n.driver()}function c(e){return n._extend(e),i(),n._ready=n._initStorage(n._config),n._ready}var s=null!==this._driverSet?this._driverSet.catch((function(){return a.resolve()})):a.resolve();return this._driverSet=s.then((function(){var e=o[0];return n._dbInfo=null,n._ready=null,n.getDriver(e).then((function(e){n._driver=e._driver,i(),n._wrapLibraryMethodsWithReady(),n._initDriver=function(e){return function(){var t=0;return function r(){for(;t<e.length;){var o=e[t];return t++,n._dbInfo=null,n._ready=null,n.getDriver(o).then(c).catch(r)}i();var u=new Error("No available storage method found.");return n._driverSet=a.reject(u),n._driverSet}()}}(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return n._driverSet=a.reject(e),n._driverSet})),u(this._driverSet,t,r),this._driverSet},e.prototype.supports=function(e){return!!ue[e]},e.prototype._extend=function(e){pe(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var o=e[r];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=de.length;e<t;e++)he(this,de[e])},e.prototype.createInstance=function(t){return new e(t)},e}());t.exports=ye},{3:3}]},{},[4])(4)},390:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof y?t:y,i=Object.create(o.prototype),a=new T(n||[]);return i._invoke=function(e,t,r){var n=l;return function(o,i){if(n===v)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return A()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=I(a,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=v;var u=f(e,t,r);if("normal"===u.type){if(n=r.done?h:d,u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=h,r.method="throw",r.arg=u.arg)}}}(e,r,a),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l="suspendedStart",d="suspendedYield",v="executing",h="completed",p={};function y(){}function g(){}function m(){}var b={};b[i]=function(){return this};var E=Object.getPrototypeOf,_=E&&E(E(N([])));_&&_!==r&&n.call(_,i)&&(b=_);var w=m.prototype=y.prototype=Object.create(b);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(o,i,a,c){var u=f(e[o],e,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,c)}))}c(u.arg)}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}}function I(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method))return p;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var o=f(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,p;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,p):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,p)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function N(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:A}}function A(){return{value:t,done:!0}}return g.prototype=w.constructor=m,m.constructor=g,g.displayName=u(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},S(R.prototype),R.prototype[a]=function(){return this},e.AsyncIterator=R,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new R(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(w),u(w,c,"Generator"),w[i]=function(){return this},w.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}},896:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncContract=void 0;var i=r(174),a=r(589);t.AsyncContract=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length-1,c=e.slice(0,r),u=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<c.length){var s="Expected "+c.length+" arguments but only received "+t.length,f=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(f)}for(var l=0;l<c.length;l++)c[l].check(t[l]);var d=e.apply(void 0,o([],n(t)));if(!(d instanceof Promise))throw s="Expected function to return a promise, but instead got "+d,f=a.FAILURE.RETURN_INCORRECT(s),new i.ValidationError(f);return d.then(u.check)}}}}},308:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Contract=void 0;var i=r(174),a=r(589);t.Contract=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length-1,c=e.slice(0,r),u=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<c.length){var s="Expected "+c.length+" arguments but only received "+t.length,f=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(f)}for(var l=0;l<c.length;l++)c[l].check(t[l]);return u.check(e.apply(void 0,o([],n(t))))}}}}},965:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checked=t.check=void 0;var n=r(174),o=r(589),i=new WeakMap;function a(e,t,r){var n=i.get(e),o=n&&n.get(t);if(o)return o;for(var a=[],c=0;c<r;c++)a.push(c);return a}t.check=function(e,t,r){var n=i.get(e)||new Map;i.set(e,n);var o=n.get(t)||[];n.set(t,o),o.push(r)},t.checked=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("No runtype provided to `@checked`. Please remove the decorator.");return function(t,r,i){var c=i.value,u=(t.name||t.constructor.name+".prototype")+("string"==typeof r?'["'+r+'"]':"["+String(r)+"]"),s=a(t,r,e.length);if(s.length!==e.length)throw new Error("Number of `@checked` runtypes and @check parameters not matched.");if(s.length>c.length)throw new Error("Number of `@checked` runtypes exceeds actual parameter length.");i.value=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.forEach((function(e,r){var i=s[r],a=e.validate(t[i]);if(!a.success){var c=u+", argument #"+i+": "+a.message,f=o.FAILURE.ARGUMENT_INCORRECT(c);throw new n.ValidationError(f)}})),c.apply(this,t)}}}},174:function(e,t){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationError=void 0;var o=function(e){function t(r){var n=e.call(this,r.message)||this;return n.name="ValidationError",n.code=r.code,void 0!==r.details&&(n.details=r.details),Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error);t.ValidationError=o},61:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceOf=t.Null=t.Undefined=t.Literal=void 0,o(r(350),t),o(r(205),t),o(r(308),t),o(r(896),t),o(r(339),t),o(r(174),t),o(r(615),t),o(r(551),t),o(r(362),t);var i=r(620);Object.defineProperty(t,"Literal",{enumerable:!0,get:function(){return i.Literal}}),Object.defineProperty(t,"Undefined",{enumerable:!0,get:function(){return i.Undefined}}),Object.defineProperty(t,"Null",{enumerable:!0,get:function(){return i.Null}}),o(r(643),t),o(r(422),t),o(r(172),t),o(r(856),t),o(r(59),t),o(r(669),t),o(r(941),t),o(r(489),t),o(r(745),t),o(r(219),t),o(r(617),t),o(r(979),t),o(r(548),t);var a=r(937);Object.defineProperty(t,"InstanceOf",{enumerable:!0,get:function(){return a.InstanceOf}}),o(r(813),t),o(r(277),t),o(r(550),t),o(r(965),t)},339:function(e,t){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(t,"__esModule",{value:!0}),t.match=void 0,t.match=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var o,i;try{for(var a=r(e),c=a.next();!c.done;c=a.next()){var u=n(c.value,2),s=u[0],f=u[1];if(s.guard(t))return f(t)}}catch(e){o={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}throw new Error("No alternatives were matched")}}},350:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},205:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Failcode=void 0,t.Failcode={TYPE_INCORRECT:"TYPE_INCORRECT",VALUE_INCORRECT:"VALUE_INCORRECT",KEY_INCORRECT:"KEY_INCORRECT",CONTENT_INCORRECT:"CONTENT_INCORRECT",ARGUMENT_INCORRECT:"ARGUMENT_INCORRECT",RETURN_INCORRECT:"RETURN_INCORRECT",CONSTRAINT_FAILED:"CONSTRAINT_FAILED",PROPERTY_MISSING:"PROPERTY_MISSING",PROPERTY_PRESENT:"PROPERTY_PRESENT",NOTHING_EXPECTED:"NOTHING_EXPECTED"}},705:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.innerValidate=t.create=void 0;var n=r(61),o=r(268),i=r(174),a=r(589);t.create=function(e,t){return t.check=r,t.assert=r,t._innerValidate=function(r,n){return n.has(r,t)?a.SUCCESS(r):e(r,n)},t.validate=function(e){return t._innerValidate(e,(r=new WeakMap,n=function(e,t){if(null!==e&&"object"==typeof e){var n=r.get(e);r.set(e,n?n.set(t,!0):(new WeakMap).set(t,!0))}},{has:function(e,t){var o=r.get(e),i=o&&o.get(t)||!1;return n(e,t),i}}));var r,n},t.guard=function(e){return t.validate(e).success},t.Or=function(e){return n.Union(t,e)},t.And=function(e){return n.Intersect(t,e)},t.optional=function(){return n.Optional(t)},t.nullable=function(){return n.Union(t,n.Null)},t.withConstraint=function(e,r){return n.Constraint(t,e,r)},t.withGuard=function(e,r){return n.Constraint(t,e,r)},t.withBrand=function(e){return n.Brand(e,t)},t.reflect=t,t.toString=function(){return"Runtype<"+o.default(t)+">"},t;function r(e){var r=t.validate(e);if(r.success)return r.value;throw new i.ValidationError(r)}},t.innerValidate=function(e,t,r){return e._innerValidate(t,r)}},268:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e,t){return function(o){var i=function(t){return e?"("+t+")":t};if(t.has(o))return i("CIRCULAR "+o.tag);t.add(o);try{switch(o.tag){case"unknown":case"never":case"void":case"boolean":case"number":case"bigint":case"string":case"symbol":case"function":return o.tag;case"literal":var a=o.value;return"string"==typeof a?'"'+a+'"':String(a);case"array":return""+n(o)+r(!0,t)(o.element)+"[]";case"dictionary":return"{ [_: "+o.key+"]: "+r(!1,t)(o.value)+" }";case"record":var c=Object.keys(o.fields);return c.length?"{ "+c.map((function(e){return""+n(o)+e+(a=e,c=(i=o).isPartial,u=i.fields,(c||void 0!==a&&"optional"===u[a].tag?"?":"")+": ")+("optional"===o.fields[e].tag?r(!1,t)(o.fields[e].underlying):r(!1,t)(o.fields[e]))+";";var i,a,c,u})).join(" ")+" }":"{}";case"tuple":return"["+o.components.map(r(!1,t)).join(", ")+"]";case"union":return i(""+o.alternatives.map(r(!0,t)).join(" | "));case"intersect":return i(""+o.intersectees.map(r(!0,t)).join(" & "));case"optional":return r(e,t)(o.underlying)+" | undefined";case"constraint":return o.name||r(e,t)(o.underlying);case"instanceof":return o.ctor.name;case"brand":return r(e,t)(o.entity)}}finally{t.delete(o)}throw Error("impossible")}};function n(e){return e.isReadonly?"readonly ":""}t.default=r(!1,new Set)},669:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Array=void 0;var n=r(705),o=r(589);function i(e,t){var r,a={tag:"array",isReadonly:t,element:e};return(r=n.create((function(t,r){if(!Array.isArray(t))return o.FAILURE.TYPE_INCORRECT(a,t);var i=o.enumerableKeysOf(t),c=i.map((function(o){return n.innerValidate(e,t[o],r)})),u=i.reduce((function(e,t){var r=c[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(u).length?o.FAILURE.CONTENT_INCORRECT(a,u):o.SUCCESS(t)}),a)).asReadonly=function(){return i(r.element,!0)},r}t.Array=function(e){return i(e,!1)}},172:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BigInt=void 0;var n=r(705),o=r(589),i={tag:"bigint"};t.BigInt=n.create((function(e){return"bigint"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},643:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Boolean=void 0;var n=r(705),o=r(589),i={tag:"boolean"};t.Boolean=n.create((function(e){return"boolean"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},550:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Brand=void 0;var n=r(705);t.Brand=function(e,t){var r={tag:"brand",brand:e,entity:t};return n.create((function(e){return t.validate(e)}),r)}},277:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Guard=t.Constraint=void 0;var n=r(705),o=r(589),i=r(615);t.Constraint=function(e,t,r){var i=r&&r.name,a=r&&r.args,c={tag:"constraint",underlying:e,constraint:t,name:i,args:a};return n.create((function(r){var n=e.validate(r);if(!n.success)return n;var i=t(n.value);return"string"==typeof i?o.FAILURE.CONSTRAINT_FAILED(c,i):i?o.SUCCESS(n.value):o.FAILURE.CONSTRAINT_FAILED(c)}),c)},t.Guard=function(e,t){return i.Unknown.withGuard(e,t)}},745:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Dictionary=void 0;var n=r(705),o=r(856),i=r(277),a=r(268),c=r(589),u=i.Constraint(o.String,(function(e){return!isNaN(+e)}),{name:"number"});t.Dictionary=function(e,t){var i=void 0===t||"string"===t?o.String:"number"===t?u:t,s=a.default(i),f={tag:"dictionary",key:s,value:e};return n.create((function(t,o){if(null==t||"object"!=typeof t)return c.FAILURE.TYPE_INCORRECT(f,t);if(Object.getPrototypeOf(t)!==Object.prototype&&(!Array.isArray(t)||"string"===s))return c.FAILURE.TYPE_INCORRECT(f,t);var a=/^(?:NaN|-?\d+(?:\.\d+)?)$/u,u=c.enumerableKeysOf(t),l=u.reduce((function(u,s){var l="string"==typeof s&&a.test(s),d=l?r.g.Number(s):s;return(l?i.guard(d)||i.guard(s):i.guard(d))?u[s]=n.innerValidate(e,t[s],o):u[s]=c.FAILURE.KEY_INCORRECT(f,i.reflect,d),u}),{}),d=u.reduce((function(e,t){var r=l[t];return r.success||(e[t]=r.details||r.message),e}),{});return 0!==c.enumerableKeysOf(d).length?c.FAILURE.CONTENT_INCORRECT(f,d):c.SUCCESS(t)}),f)}},548:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Function=void 0;var n=r(705),o=r(589),i={tag:"function"};t.Function=n.create((function(e){return"function"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},937:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceOf=void 0;var n=r(705),o=r(589);t.InstanceOf=function(e){var t={tag:"instanceof",ctor:e};return n.create((function(r){return r instanceof e?o.SUCCESS(r):o.FAILURE.TYPE_INCORRECT(t,r)}),t)}},617:function(e,t,r){"use strict";var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.Intersect=void 0;var o=r(705),i=r(589);t.Intersect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"intersect",intersectees:e};return o.create((function(t,r){var a,c;try{for(var u=n(e),s=u.next();!s.done;s=u.next()){var f=s.value,l=o.innerValidate(f,t,r);if(!l.success)return l}}catch(e){a={error:e}}finally{try{s&&!s.done&&(c=u.return)&&c.call(u)}finally{if(a)throw a.error}}return i.SUCCESS(t)}),r)}},813:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Lazy=void 0;var n=r(705);t.Lazy=function(e){var t,r={get tag(){return o().tag}};function o(){if(!t)for(var n in t=e())"tag"!==n&&(r[n]=t[n]);return t}return n.create((function(e){return o().validate(e)}),r)}},620:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Null=t.Undefined=t.Literal=void 0;var n=r(705),o=r(589);function i(e){return Array.isArray(e)?String(e.map(String)):"bigint"==typeof e?String(e)+"n":String(e)}function a(e){var t={tag:"literal",value:e};return n.create((function(t){return t===e?o.SUCCESS(t):o.FAILURE.VALUE_INCORRECT("literal","`"+i(e)+"`","`"+i(t)+"`")}),t)}t.Literal=a,t.Undefined=a(void 0),t.Null=a(null)},551:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Never=void 0;var n=r(705),o=r(589);t.Never=n.create(o.FAILURE.NOTHING_EXPECTED,{tag:"never"})},422:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Number=void 0;var n=r(705),o=r(589),i={tag:"number"};t.Number=n.create((function(e){return"number"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},979:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Optional=void 0;var n=r(705),o=r(589);t.Optional=function(e){var t={tag:"optional",underlying:e};return n.create((function(t){return void 0===t?o.SUCCESS(t):e.validate(t)}),t)}},489:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Partial=t.Record=t.InternalRecord=void 0;var i=r(705),a=r(589);function c(e,t,r){var u,s={tag:"record",isPartial:t,isReadonly:r,fields:e};return(u=i.create((function(r,c){if(null==r)return a.FAILURE.TYPE_INCORRECT(s,r);var u=a.enumerableKeysOf(e);if(0!==u.length&&"object"!=typeof r)return a.FAILURE.TYPE_INCORRECT(s,r);var f=o([],n(new Set(o(o([],n(u)),n(a.enumerableKeysOf(r)))))),l=f.reduce((function(n,o){var u=a.hasKey(o,e),s=a.hasKey(o,r);if(u){var f=e[o],l=t||"optional"===f.reflect.tag;if(s){var d=r[o];n[o]=l&&void 0===d?a.SUCCESS(d):i.innerValidate(f,d,c)}else n[o]=l?a.SUCCESS(void 0):a.FAILURE.PROPERTY_MISSING(f.reflect)}else{if(!s)throw new Error("impossible");d=r[o],n[o]=a.SUCCESS(d)}return n}),{}),d=f.reduce((function(e,t){var r=l[t];return r.success||(e[t]=r.details||r.message),e}),{});return 0!==a.enumerableKeysOf(d).length?a.FAILURE.CONTENT_INCORRECT(s,d):a.SUCCESS(r)}),s)).asPartial=function(){return c(u.fields,!0,u.isReadonly)},u.asReadonly=function(){return c(u.fields,u.isPartial,!0)},u.pick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return e.forEach((function(e){r[e]=u.fields[e]})),c(r,u.isPartial,u.isReadonly)},u.omit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return a.enumerableKeysOf(u.fields).forEach((function(t){e.includes(t)||(r[t]=u.fields[t])})),c(r,u.isPartial,u.isReadonly)},u}t.InternalRecord=c,t.Record=function(e){return c(e,!1,!1)},t.Partial=function(e){return c(e,!0,!1)}},856:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.String=void 0;var n=r(705),o=r(589),i={tag:"string"};t.String=n.create((function(e){return"string"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},59:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Symbol=void 0;var n=r(705),o=r(589),i={tag:"symbol"};t.Symbol=n.create((function(e){return"symbol"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),Object.assign((function(e){var t={tag:"symbol",key:e};return n.create((function(n){if("symbol"!=typeof n)return o.FAILURE.TYPE_INCORRECT(t,n);var i=r.g.Symbol.keyFor(n);return i!==e?o.FAILURE.VALUE_INCORRECT("symbol key",a(e),a(i)):o.SUCCESS(n)}),t)}),i));var a=function(e){return void 0===e?"undefined":'"'+e+'"'}},941:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tuple=void 0;var n=r(705),o=r(589);t.Tuple=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"tuple",components:e};return n.create((function(t,i){if(!Array.isArray(t))return o.FAILURE.TYPE_INCORRECT(r,t);if(t.length!==e.length)return o.FAILURE.CONSTRAINT_FAILED(r,"Expected length "+e.length+", but was "+t.length);var a=o.enumerableKeysOf(t),c=a.map((function(r){return n.innerValidate(e[r],t[r],i)})),u=a.reduce((function(e,t){var r=c[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(u).length?o.FAILURE.CONTENT_INCORRECT(r,u):o.SUCCESS(t)}),r)}},219:function(e,t,r){"use strict";var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.Union=void 0;var o=r(705),i=r(589);t.Union=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return function(r){for(var n=0;n<e.length;n++)if(e[n].guard(r))return t[n](r)}},a={tag:"union",alternatives:e,match:r};return o.create((function(t,r){var c,u,s,f,l,d,v,h;if("object"!=typeof t||null===t){try{for(var p=n(e),y=p.next();!y.done;y=p.next()){var g=y.value;if(o.innerValidate(g,t,r).success)return i.SUCCESS(t)}}catch(e){c={error:e}}finally{try{y&&!y.done&&(u=p.return)&&u.call(p)}finally{if(c)throw c.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}var m={};try{for(var b=n(e),E=b.next();!E.done;E=b.next())if("record"===(g=E.value).reflect.tag){var _=function(e){var t=g.reflect.fields[e];"literal"===t.tag&&(m[e]?m[e].every((function(e){return e!==t.value}))&&m[e].push(t.value):m[e]=[t.value])};for(var w in g.reflect.fields)_(w)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(f=b.return)&&f.call(b)}finally{if(s)throw s.error}}for(var w in m)if(m[w].length===e.length)try{for(var S=(l=void 0,n(e)),R=S.next();!R.done;R=S.next())if("record"===(g=R.value).reflect.tag){var I=g.reflect.fields[w];if("literal"===I.tag&&i.hasKey(w,t)&&t[w]===I.value)return o.innerValidate(g,t,r)}}catch(e){l={error:e}}finally{try{R&&!R.done&&(d=S.return)&&d.call(S)}finally{if(l)throw l.error}}try{for(var O=n(e),C=O.next();!C.done;C=O.next()){var T=C.value;if(o.innerValidate(T,t,r).success)return i.SUCCESS(t)}}catch(e){v={error:e}}finally{try{C&&!C.done&&(h=O.return)&&h.call(O)}finally{if(v)throw v.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}),a)}},615:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Unknown=void 0;var n=r(705),o=r(589);t.Unknown=n.create((function(e){return o.SUCCESS(e)}),{tag:"unknown"})},362:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Void=void 0;var n=r(615);t.Void=n.Unknown},589:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FAILURE=t.SUCCESS=t.enumerableKeysOf=t.typeOf=t.hasKey=void 0;var o=r(205),i=r(268);t.hasKey=function(e,t){return"object"==typeof t&&null!==t&&e in t},t.typeOf=function(e){return"object"==typeof e?null===e?"null":Array.isArray(e)?"array":"Object"===e.constructor.name?"object":e.constructor.name:typeof e},t.enumerableKeysOf=function(e){return"object"==typeof e&&null!==e?Reflect.ownKeys(e).filter((function(t){var r,n;return null===(n=null===(r=e.propertyIsEnumerable)||void 0===r?void 0:r.call(e,t))||void 0===n||n})):[]},t.SUCCESS=function(e){return{success:!0,value:e}},t.FAILURE=Object.assign((function(e,t,r){return n({success:!1,code:e,message:t},r?{details:r}:{})}),{TYPE_INCORRECT:function(e,r){var n="Expected "+i.default(e)+", but was "+t.typeOf(r);return t.FAILURE(o.Failcode.TYPE_INCORRECT,n)},VALUE_INCORRECT:function(e,r,n){return t.FAILURE(o.Failcode.VALUE_INCORRECT,"Expected "+e+" "+String(r)+", but was "+String(n))},KEY_INCORRECT:function(e,r,n){return t.FAILURE(o.Failcode.KEY_INCORRECT,"Expected "+i.default(e)+" key to be "+i.default(r)+", but was "+t.typeOf(n))},CONTENT_INCORRECT:function(e,r){var n="Expected "+i.default(e)+", but was incompatible";return t.FAILURE(o.Failcode.CONTENT_INCORRECT,n,r)},ARGUMENT_INCORRECT:function(e){return t.FAILURE(o.Failcode.ARGUMENT_INCORRECT,e)},RETURN_INCORRECT:function(e){return t.FAILURE(o.Failcode.RETURN_INCORRECT,e)},CONSTRAINT_FAILED:function(e,r){var n=r?": "+r:"";return t.FAILURE(o.Failcode.CONSTRAINT_FAILED,"Failed constraint check for "+i.default(e)+n)},PROPERTY_MISSING:function(e){var r="Expected "+i.default(e)+", but was missing";return t.FAILURE(o.Failcode.PROPERTY_MISSING,r)},PROPERTY_PRESENT:function(e){var r="Expected nothing, but was "+t.typeOf(e);return t.FAILURE(o.Failcode.PROPERTY_PRESENT,r)},NOTHING_EXPECTED:function(e){var r="Expected nothing, but was "+t.typeOf(e);return t.FAILURE(o.Failcode.NOTHING_EXPECTED,r)}})}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{User:()=>he,goToLoginPage:()=>pe,logout:()=>ye,tryActivateSubscriptionAccess:()=>ge}),r(390);var e=r(466),t=r(651);let o;const i="undefined"==typeof self?window:self,a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==i.msCrypto&&"function"==typeof i.msCrypto.getRandomValues&&i.msCrypto.getRandomValues.bind(i.msCrypto);if(a){const e=new Uint8Array(16);o=function(){return a(e),e}}else{const e=new Array(16);o=function(){for(let t,r=0;r<16;r+=1)0==(3&r)&&(t=4294967296*Math.random()),e[r]=t>>>((3&r)<<3)&255;return e}}const c=[];for(let e=0;e<256;++e)c[e]=(e+256).toString(16).substr(1);function u(){const e=o();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let r=0;const n=c;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}(e)}e.config({name:"aid:userdata"});const s=self.location.hostname.replace(/(.*\.)([^.]+\.\w+$)/,"$2");function f(r){return t.set("amedia:visitid",r,{expires:new Date(Date.now()+18e5),domain:s,sameSite:"strict"}),e.setItem("visitid",r).then((()=>r))}function l(){const e=Date.now();return f(`${u()}|${e}`)}function d(){return function(){const r=t.get("amedia:visitid");return r?Promise.resolve(r):e.getItem("visitid")}().then((e=>e||l())).then((e=>{const[t,r]=e.split("|");return!t||r&&Date.now()-18e5>r?l():f(`${t}|${Date.now()}`)})).catch((e=>console.error(e)))}"undefined"!=typeof window&&["mousedown","keydown","mousemove","focus","scroll","resize","seshat-video-active","touchmove","deviceorientation"].forEach((e=>window.addEventListener(e,function(e){let t=!1;return(...r)=>{t||(e.apply(this,r),t=!0,setTimeout((()=>{t=!1}),400))}}(d))));const v=()=>window.location.hostname,h=()=>v().replace(/\.[^.]+\.api\.no/,"");var p=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))};const y=(e,t,r)=>{!function(e,t){const r=new FormData;Object.keys(t).forEach((e=>r.append(e,t[e]))),fetch(e,{method:"POST",body:r,headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}}).then((e=>{if(!e.ok)throw new Error(`Error, status: ${e.status}, text: ${e.statusText}`)}))}(`//www.aid.no/api/mercury/v1/log/${e}`,Object.assign(Object.assign({},r),{message:t,url:window.location.href,domain:window.location.host}))},g=(e,t)=>y("error",e,t);class m extends Error{}const b={debug:console.debug,info:console.info,warn:console.warn,error:console.error};var E=r(61);const _={},w=e=>{const t=_[e];return t?(delete _[e],t):[]},S=()=>{const e="undefined"!=typeof window?window:r.g;return e.amediaUserCache||(e.amediaUserCache={})},R={get:e=>{const t=S()[e];return Promise.resolve(t)},set:(e,t,r)=>(S()[e]={key:e,data:t,expires:r},Promise.resolve()),remove:e=>(delete S()[e],Promise.resolve()),clear:()=>(("undefined"!=typeof window?window:r.g).amediaUserCache={},Promise.resolve())};const I=()=>R,O=e=>I().remove(e),C=(e,t)=>{return r=void 0,n=void 0,i=function*(){const r=yield I().get(e);if(!r)return Promise.resolve();if(Date.now()>r.expires)return O(e),Promise.resolve();try{return t.check(r.data)}catch(t){return t instanceof E.ValidationError?b.error("Failed validating data",{data:r.data,error:t.details}):b.error("Unknown error",t),O(e),Promise.resolve()}},new((o=void 0)||(o=Promise))((function(e,t){function a(e){try{u(i.next(e))}catch(e){t(e)}}function c(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(a,c)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i};function T(e,t,r,n){return new Promise(((o,i)=>{((e,t)=>{_[e]||(_[e]=[]),_[e].push(t)})(e,{resolve:o,reject:i}),(e=>{var t;return(null===(t=_[e])||void 0===t?void 0:t.length)||0})(e)>1||C(e,t).then((t=>{!t||n&&!n(t)?r().then((r=>{const n=t?((e,t)=>!e||Array.isArray(t)?t:t?"object"==typeof e&&"object"==typeof t?Object.assign(Object.assign({},e),t):t:e)(t,r.data):r.data;((e,t,r)=>{I().set(e,t,Date.now()+r)})(e,n,r.ttl),w(e).forEach((e=>{e.resolve(r.data)}))})).catch((()=>{w(e).forEach((e=>{e.reject()}))})):w(e).forEach((e=>{e.resolve(t)}))}))}))}const N={},A={},j=(e,t)=>{N[e]=Object.assign(Object.assign({},N[e]),t),(e=>{var t;null===(t=A[e])||void 0===t||t.forEach((t=>t(N[e])))})(e)},P=(e,t)=>{A[e]||(A[e]=[]),A[e].push(t)};var U=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))};const x=(0,E.Record)({user_name:E.String,tracking_key:E.String}),L=e=>({name:e.user_name,trackingKey:e.tracking_key}),k=()=>fetch("/api/pluto/v1/sessions/current").then((e=>e.ok?(j("state",{isLoggedIn:!0}),e.json()):403===e.status?(j("state",{isLoggedIn:!1}),{}):(b.error(`Unknown error (${e.status}: ${e.statusText}) when fetching current session`,{response:e}),Promise.reject()))).then((e=>{try{return{ttl:1e4,data:x.check(e)}}catch(e){throw b.error("Invalid schema",e),e}})),F=e=>U(void 0,void 0,void 0,(function*(){return fetch(`/api/pluto/v1/sessions/current?publication_domain=${e}`,{method:"DELETE"}).then((e=>{if(!e.ok){if(403===e.status)return;throw new Error(`Error, could not perform deleteRequest. Status: ${e.status} Text: ${e.statusText}`)}j("state",{isLoggedIn:!1})}))}));let D;const M=self||window,B="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==M.msCrypto&&"function"==typeof M.msCrypto.getRandomValues&&M.msCrypto.getRandomValues.bind(M.msCrypto);if(B){const e=new Uint8Array(16);D=function(){return B(e),e}}else{const e=new Array(16);D=function(){for(let t,r=0;r<16;r+=1)0==(3&r)&&(t=4294967296*Math.random()),e[r]=t>>>((3&r)<<3)&255;return e}}const V=[];for(let e=0;e<256;++e)V[e]=(e+256).toString(16).substr(1);function $(e,t){return(...r)=>{const{resolve:n,reject:o,promise:i}=function(){let e,t,r=!1;return{promise:new Promise(((n,o)=>{e=e=>{r||n(e),r=!0},t=e=>{r||o(e),r=!0}})),resolve:e,reject:t}}(),a=function(){const e=D();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let r=0;const n=V;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}(e)}(),c=new CustomEvent(`amedia-rpc-event:${e}:${t}`,{detail:{eventId:a,args:r}});if(self.dispatchEvent(c),self.amediaNativeBridge){const n=JSON.stringify(r);self.amediaNativeBridge.callNativeMethod(e,t,n,a)}return self.addEventListener(`amedia-rpc-event:${e}:${t}:${a}`,(e=>{e.detail||n();const{error:t,result:r}=e.detail;return t?o(t):n(r)})),i}}class Y{constructor({version:e,component:t,methods:r=[]}){this.component=t,this.version=e,this.queue=[],r.forEach((e=>this.addMethod(e))),this.boundLiveHandler=this.liveHandler.bind(this),self.addEventListener(`amedia-rpc-event:${t}:live`,this.boundLiveHandler),setTimeout((()=>self.dispatchEvent(new CustomEvent(`amedia-rpc-event:${t}:ready`))),0)}liveHandler(e){const[t,r]=e.detail.version.split(".").map((e=>parseInt(e,10))),[n,o]=this.version.split(".").map((e=>parseInt(e,10)));if(t!==n)throw new Error(`${this.component} version mismatch. Server version: ${t}. Client version: ${n}`);r<o&&console.warn(`${this.component} server version is on an earlier minor version (${r}) than the client (${o})`);const i=this.queue.slice(0);delete this.queue,i.forEach((e=>e())),self.removeEventListener(`amedia-rpc-event:${this.component}:live`,this.boundLiveHandler)}addMethod(e){if(this[e])throw new Error(`${e} already exists on the RPC interface.`);this[e]=(...t)=>{if(this.queue){let r,n;const o=new Promise(((e,t)=>{r=e,n=t}));return this.queue.push((()=>this[e](...t).then(r).catch(n))),o}return this[e]=$(this.component,e),this[e](...t)}}}let K;const G=(e,t)=>{const r=t.substring(e.length,t.length);return"{"===r.substring(0,1)?JSON.parse(r):"%7B"===r.substring(0,3)?JSON.parse(decodeURIComponent(r)):"undefined"!==r?""===r||"null"===r?null:r:void 0};function z(e){!function(e,t,r=Date.now(),n="/",o=!1){const i=new Date;let a=`${e}=`;t&&""!==t||(r=-1),a+=(e=>e&&""!==e?e instanceof Object?encodeURIComponent(JSON.stringify(e)):"number"==typeof e?e.toString(10):e:"")(t),a+=((e,t)=>t?t instanceof Date?`; expires=${t.toUTCString()}`:(e.setTime(e.getTime()+24*t*60*60*1e3),`; expires=${e.toUTCString()}`):"")(i,r),a+=`; path=${n}`,o&&(a+="; secure"),document.cookie=a,r&&-1!==r&&null===(e=>{const t=`${e}=`,r=document.cookie.split(";");for(let e=r.length-1;e>=0;e-=1){const n=r[e].trim();if(0===n.indexOf(t))return G(t,n)}return null})(e)&&(document.cookie=a.replace(/; expires=[^;]*/,""))}(e)}const q=()=>{return e=void 0,t=void 0,n=function*(){return Promise.all([F(h()),I().clear()]).then((()=>{(K||(K=new Y({version:"1.0.0",component:"userdata-session",methods:["userAuthenticated"]}),K)).userAuthenticated(!1),z("VSTOKEN"),z("aid.session"),z("aid_invitation_code"),z("aid-reload-article"),z("VSTOKEN2")})).catch((e=>{b.error("Failure while logging out",e)}))},new((r=void 0)||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}));var e,t,r,n},W=()=>U(void 0,void 0,void 0,(function*(){return T("getCurrentSession",x,k).then(L)})),H=(0,E.Record)({id:E.Number,domain:E.String}),J=(0,E.Record)({status:(0,E.Literal)("success"),access:(0,E.Union)((0,E.Literal)("granted"),(0,E.Literal)("denied")),publication:H,access_features:(0,E.Array)(E.String)}),Q=((0,E.Record)({status:(0,E.Literal)("success"),cookie:E.String,access_features:(0,E.Array)(E.String)}),(0,E.Record)({status:(0,E.Literal)("success"),vstoken_cookie:E.String,uuid:E.String,access_features:(0,E.Array)(E.String)}),e=>{try{return(e=>p(void 0,void 0,void 0,(function*(){return fetch(`/api/mercury/v2/access/activate?publication_wwwdomain=${h()}&access_features=${e.join(",")}`,{method:"post"}).then((e=>p(void 0,void 0,void 0,(function*(){let t;try{t=yield e.json()}catch(e){g("Body does not contain parsable json",e)}if(!e.ok){if(401===e.status&&"user_deactivated"===(null==t?void 0:t.status))throw new m;return!1}return"success"===(null==t?void 0:t.status)&&"granted"===(null==t?void 0:t.access)}))))})))(e)}catch(e){if(e instanceof m)return q(),Promise.resolve(!1);throw e}});const X=(0,E.Record)({namespaces:(0,E.Dictionary)(E.Unknown,E.String)}),Z=e=>({storage:e.namespaces}),ee=(e,t={ignoreCache:!1})=>{return r=void 0,n=void 0,i=function*(){if(0===e.length)throw new Error("namespaces array cannot be of length 0");return T("europa",X,(()=>((e,t="GET",r)=>fetch(e,{method:t,body:r&&JSON.stringify(r),headers:{"Content-Type":"application/json",Accept:"application/json"}}))(`/api/europa/v1/me/${e.join(",")}`).then((t=>t.ok?t.json():(b.error(`Could not get namespaces for: ${e}, status: ${t.status}, statusText: ${t.statusText}`,t),{namespaces:{}}))).then((e=>({ttl:3e5,data:e})))),(r=>!t.ignoreCache||0===Object.keys(r.namespaces).filter((t=>!Object.keys(e).includes(t))).length)).then(Z)},new((o=void 0)||(o=Promise))((function(e,t){function a(e){try{u(i.next(e))}catch(e){t(e)}}function c(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(a,c)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i};const te=(0,E.Record)({allowResearchUsage:E.Boolean,connectWithSurveys:E.Boolean,personalizedAds:E.Boolean,personalizedContent:E.Boolean}),re=e=>"true"===e||!0===e,ne=(0,E.Dictionary)(E.Unknown,E.String).And((0,E.Partial)({ad_segments:E.String,ad_segments_user:E.String,age:E.Number,age_user:E.Number,birth_year:E.String,birth_year_user:E.String,gender:E.String,gender_user:E.String,grunnkrets:E.String,grunnkrets_user:E.String,postcode:E.String,postcode_user:E.String,shared_account:E.Boolean,shared_account_user:E.Boolean,user_grouping_number:E.String,user_grouping_number_user:E.String})),oe=e=>({extraData:e}),ie={name:W,trackingKey:W,access:()=>{return e=h(),t=["newspaper"],T("checkForAccess",J,(()=>fetch(`/api/jupiter/v1/check_access_for_paper/${e}/?require=any&access_features=${t.join(",")}`).then((e=>{if(!e.ok)throw new Error(`Request not ok (${e.status}: ${e.statusText}).`);return e.json()})).then((e=>{try{const t=J.check(e);return{ttl:"granted"===t.access?1e4:0,data:t}}catch(e){throw b.error("Invalid schema",e),e}})))).then((e=>({access:e.access_features})));var e,t},extraData:()=>function(){let e=t.get("amedia:fpbid");return e||(e=u(),t.set("amedia:fpbid",e,{expires:3650,domain:s,sameSite:"strict"})),Promise.resolve(e)}().then((e=>{var t;return((e,t,r)=>T("getNebulaInfo",ne,(()=>((e,t,r)=>{const n=new URL("https://services.gcloud.api.no/api/nebula/v1/info");return n.searchParams.set("domain",e),n.searchParams.set("browser_id",t),r&&n.searchParams.set("user_key",r),fetch(n.toString()).then((e=>e.json())).then((e=>{try{return{ttl:18e6,data:ne.check(e)}}catch(e){throw b.error("Invalid schema",e),e}}))})(e,t,r))).then(oe))(window.location.hostname,e,null===(t=N["userAttributes"])||void 0===t?void 0:t.trackingKey)})),privacyPreferences:()=>{return e=void 0,t=void 0,n=function*(){return T("privacyPreferences",te,(()=>ee(["privacy_preferences"]).then((e=>{var t;const r=(null===(t=e.storage)||void 0===t?void 0:t.privacy_preferences)||{};return{ttl:3e5,data:{allowResearchUsage:re(r.allow_research_usage),connectWithSurveys:re(r.connect_with_surveys),personalizedAds:re(r.personalized_ads),personalizedContent:re(r.personalized_content)}}})))).then((e=>({privacyPreferences:e})))},new((r=void 0)||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}));var e,t,r,n}};let ae;var ce;"undefined"!=typeof window&&(ce=window,ae=ce);const ue=(e,t)=>{ae?ae.addEventListener(e,(e=>{e.stopImmediatePropagation(),t.apply(window,[e])})):b.error("No root element to bind event to!")},se=(e,t)=>{ae?ae.addEventListener(e,(e=>{t.apply(window,[e])})):b.error("No root element to bind event to!")},fe=e=>{ae?ae.dispatchEvent(e):b.error("No root element to dispatch event on!")};var le,de;!function(e){e.REQUEST_USER_ATTRIBUTES="amedia-user.request-user-attributes",e.ON_ATTRIBUTES_UPDATED="amedia-user.on-user-attributes-updated",e.ON_STATE_UPDATED="amedia-user.on-state-updated"}(le||(le={})),P("userAttributes",(e=>{fe(new CustomEvent(le.ON_ATTRIBUTES_UPDATED,{detail:e}))})),P("state",(e=>{fe(new CustomEvent(le.ON_STATE_UPDATED,{detail:e}))})),ue(le.REQUEST_USER_ATTRIBUTES,(e=>{(e=>{const t=[];for(e.forEach((e=>{const r=ie[e];r?t.includes(r)||t.push(r):b.warn("Unknown attribute was requested")}));t.length>0;){const e=t.pop();e&&e().then((e=>j("userAttributes",e))).catch((t=>{b.error("Call rejected",e,t)}))}})(e.detail)})),function(e){e.REQUEST_ACTIVATION="amedia-user.activation.request-activation",e.ON_ACTIVATION_COMPLETE="amedia-user.activation.on-activation-complete"}(de||(de={})),ue(de.REQUEST_ACTIVATION,(e=>{Q(e.detail.accessFeatures).then((e=>{fe(new CustomEvent(de.ON_ACTIVATION_COMPLETE,{detail:{hasAccess:e}}))}))}));const ve=(e,t)=>{if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r){if(!n.includes(o))return!1;if("function"==typeof e[o]||"function"==typeof t[o]){if(e[o].toString()!==t[o].toString())return!1}else if(!ve(e[o],t[o]))return!1}return!0};class he{constructor(){this.attributes=[],this.namespaces=[],this.extraData=[]}withAttributes(e){return this.attributes=e,this}withStorage(e){return this.namespaces=e,this}withExtraData(e){return this.extraData=e,this}subscribe(e,t){if(!this.attributes||0===this.attributes.length)throw new Error("You must subscribe to at least one attribute");let r;se(le.ON_ATTRIBUTES_UPDATED,(t=>{const n=t.detail,o=this.attributes.reduce(((e,t)=>(void 0!==n[t]&&(e[t]=n[t]),e)),{});ve(r,o)||(e(o),r=o)})),t&&se(le.ON_STATE_UPDATED,(e=>{t(e.detail)})),fe(new CustomEvent(le.REQUEST_USER_ATTRIBUTES,{detail:this.attributes}))}}const pe=e=>(e=>{const t=(()=>{const e=/^bed-([^.]+)\.api\.no$/.exec(v()),t=/\.([^.]+)\.api\.no/.exec(v());return e?e[1]:t?t[1]:null})(),r=new URL(`https://aid.no${t&&`.${t}.api.no`}/aid/logg_inn/`);r.searchParams.set("requestedUrl",e||window.location.href),window.location.href=r.href})(e||window.location.href),ye=()=>q(),ge=e=>new Promise((t=>{se(de.ON_ACTIVATION_COMPLETE,(e=>t(e.detail))),fe(new CustomEvent(de.REQUEST_ACTIVATION,{detail:{accessFeatures:e}}))}))})(),n})()}));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.user=t():e.user=t()}(this,(function(){return(()=>{var e={651:(e,t,r)=>{var n,o,i;void 0===(o="function"==typeof(n=i=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(n){function o(){}function i(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var a=JSON.stringify(r);/^[\{\[]/.test(a)&&(r=a)}catch(e){}r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+r+c}}function a(e,r){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],a=0;a<i.length;a++){var c=i[a].split("="),u=c.slice(1).join("=");r||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var s=t(c[0]);if(u=(n.read||n)(u,s)||t(u),r)try{u=JSON.parse(u)}catch(e){}if(o[s]=u,e===s)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return a(e,!1)},o.getJSON=function(e){return a(e,!0)},o.remove=function(t,r){i(t,"",e(r,{expires:-1}))},o.defaults={},o.withConverter=r,o}((function(){}))})?n.call(t,r,t,e):n)||(e.exports=o),e.exports=i()},466:(e,t,r)=>{e.exports=function e(t,r,n){function o(a,c){if(!r[a]){if(!t[a]){if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=r[a]={exports:{}};t[a][0].call(s.exports,(function(e){return o(t[a][1][e]||e)}),s,s.exports,e,t,r,n)}return r[a].exports}for(var i=void 0,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(e,t,n){(function(e){"use strict";var r,n,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),c=e.document.createTextNode("");a.observe(c,{characterData:!0}),r=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var u=new e.MessageChannel;u.port1.onmessage=f,r=function(){u.port2.postMessage(0)}}var s=[];function f(){var e,t;n=!0;for(var r=s.length;r;){for(t=s,s=[],e=-1;++e<r;)t[e]();r=s.length}n=!1}t.exports=function(e){1!==s.push(e)||n||r()}}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){"use strict";var n=e(1);function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,e!==o&&v(this,e)}function f(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function l(e,t,r){n((function(){var n;try{n=t(r)}catch(t){return i.reject(e,t)}n===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,n)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function v(e,t){var r=!1;function n(t){r||(r=!0,i.reject(e,t))}function o(t){r||(r=!0,i.resolve(e,t))}var a=h((function(){t(o,n)}));"error"===a.status&&n(a.value)}function h(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this;var r=new this.constructor(o);return this.state!==u?l(r,this.state===c?e:t,this.outcome):this.queue.push(new f(r,e,t)),r},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var r=h(d,t);if("error"===r.status)return i.reject(e,r.value);var n=r.value;if(n)v(e,n);else{e.state=c,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},s.resolve=function(e){return e instanceof this?e:i.resolve(new this(o),e)},s.reject=function(e){var t=new this(o);return i.reject(t,e)},s.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var a=new Array(r),c=0,u=-1,s=new this(o);++u<r;)f(e[u],u);return s;function f(e,o){t.resolve(e).then((function(e){a[o]=e,++c!==r||n||(n=!0,i.resolve(s,a))}),(function(e){n||(n=!0,i.reject(s,e))}))}},s.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r,n=e.length,a=!1;if(!n)return this.resolve([]);for(var c=-1,u=new this(o);++c<n;)r=e[c],t.resolve(r).then((function(e){a||(a=!0,i.resolve(u,e))}),(function(e){a||(a=!0,i.reject(u,e))}));return u}},{1:1}],3:[function(e,t,n){(function(t){"use strict";"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function i(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var a=Promise;function c(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function u(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,v={},h=Object.prototype.toString,p="readonly",y="readwrite";function g(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),o=0;o<t;o++)n[o]=e.charCodeAt(o);return r}function m(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a((function(t){var r=e.transaction(l,y),n=i([""]);r.objectStore(l).put(n,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return d=e}))}function b(e){var t=v[e.name],r={};r.promise=new a((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function E(e){var t=v[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function _(e,t){var r=v[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function w(e,t){return new a((function(r,n){if(v[e.name]=v[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);b(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var a=o.open.apply(o,i);t&&(a.onupgradeneeded=function(t){var r=a.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(l)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),n(a.error)},a.onsuccess=function(){r(a.result),E(e)}}))}function S(e){return w(e,!1)}function R(e){return w(e,!0)}function I(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.version<e.db.version,o=e.version>e.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||r){if(r){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function O(e){return i([g(atob(e.data))],{type:e.type})}function C(e){return e&&e.__local_forage_encoded_blob}function T(e){var t=this,r=t._initReady().then((function(){var e=v[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return u(r,e,e),r}function N(e,t,r,n){void 0===n&&(n=1);try{var o=e.db.transaction(e.storeName,t);r(null,o)}catch(o){if(n>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),R(e)})).then((function(){return function(e){b(e);for(var t=v[e.name],r=t.forages,n=0;n<r.length;n++){var o=r[n];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,S(e).then((function(t){return e.db=t,I(e)?R(e):t})).then((function(n){e.db=t.db=n;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=n})).catch((function(t){throw _(e,t),t}))}(e).then((function(){N(e,t,r,n-1)}))})).catch(r);r(o)}}var A={_driver:"asyncStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]=e[n];var o=v[r.name];o||(o={forages:[],db:null,dbReady:null,deferredOperations:[]},v[r.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=T);var i=[];function c(){return a.resolve()}for(var u=0;u<o.forages.length;u++){var s=o.forages[u];s!==t&&i.push(s._initReady().catch(c))}var f=o.forages.slice(0);return a.all(i).then((function(){return r.db=o.db,S(r)})).then((function(e){return r.db=e,I(r,t._defaultConfig.version)?R(r):e})).then((function(e){r.db=o.db=e,t._dbInfo=r;for(var n=0;n<f.length;n++){var i=f[n];i!==t&&(i._dbInfo.db=r.db,i._dbInfo.version=r.version)}}))},_support:function(){try{if(!o||!o.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).openCursor(),c=1;a.onsuccess=function(){var r=a.result;if(r){var n=r.value;C(n)&&(n=O(n));var o=e(n,r.key,c++);void 0!==o?t(o):r.continue()}else t()},a.onerror=function(){n(a.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),C(e)&&(e=O(e)),t(e)},a.onerror=function(){n(a.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},setItem:function(e,t,r){var n=this;e=s(e);var o=new a((function(r,o){var i;n.ready().then((function(){return i=n._dbInfo,"[object Blob]"===h.call(t)?m(i.db).then((function(e){return e?t:(r=t,new a((function(e,t){var n=new FileReader;n.onerror=t,n.onloadend=function(t){var n=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:n,type:r.type})},n.readAsBinaryString(r)})));var r})):t})).then((function(t){N(n._dbInfo,y,(function(i,a){if(i)return o(i);try{var c=a.objectStore(n._dbInfo.storeName);null===t&&(t=void 0);var u=c.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),r(t)},a.onabort=a.onerror=function(){var e=u.error?u.error:u.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return c(o,r),o},removeItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){N(r._dbInfo,y,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){n(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},clear:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,y,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},length:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,p,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},key:function(e,t){var r=this,n=new a((function(t,n){e<0?t(null):r.ready().then((function(){N(r._dbInfo,p,(function(o,i){if(o)return n(o);try{var a=i.objectStore(r._dbInfo.storeName),c=!1,u=a.openKeyCursor();u.onsuccess=function(){var r=u.result;r?0===e||c?t(r.key):(c=!0,r.advance(e)):t(null)},u.onerror=function(){n(u.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,t),n},keys:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){N(t._dbInfo,p,(function(n,o){if(n)return r(n);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var t=i.result;t?(a.push(t.key),t.continue()):e(a)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,e),r},dropInstance:function(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,i=this;if(e.name){var u=e.name===r.name&&i._dbInfo.db?a.resolve(i._dbInfo.db):S(e).then((function(t){var r=v[e.name],n=r.forages;r.db=t;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=t;return t}));n=e.storeName?u.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var r=t.version+1;b(e);var n=v[e.name],i=n.forages;t.close();for(var c=0;c<i.length;c++){var u=i[c];u._dbInfo.db=null,u._dbInfo.version=r}return new a((function(t,n){var i=o.open(e.name,r);i.onerror=function(e){i.result.close(),n(e)},i.onupgradeneeded=function(){i.result.deleteObjectStore(e.storeName)},i.onsuccess=function(){var e=i.result;e.close(),t(e)}})).then((function(e){n.db=e;for(var t=0;t<i.length;t++){var r=i[t];r._dbInfo.db=e,E(r._dbInfo)}})).catch((function(t){throw(_(e,t)||a.resolve()).catch((function(){})),t}))}})):u.then((function(t){b(e);var r=v[e.name],n=r.forages;t.close();for(var i=0;i<n.length;i++)n[i]._dbInfo.db=null;return new a((function(t,r){var n=o.deleteDatabase(e.name);n.onerror=n.onblocked=function(e){var t=n.result;t&&t.close(),r(e)},n.onsuccess=function(){var e=n.result;e&&e.close(),t(e)}})).then((function(e){r.db=e;for(var t=0;t<n.length;t++)E(n[t]._dbInfo)})).catch((function(t){throw(_(e,t)||a.resolve()).catch((function(){})),t}))}))}else n=a.reject("Invalid arguments");return c(n,t),n}};var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=/^~~local_forage_type~([^~]+)~/,U="__lfsc__:",x=U.length,L="arbf",k="blob",F="si08",D="ui08",M="uic8",B="si16",V="si32",$="ur16",G="ui32",Y="fl32",K="fl64",z=x+L.length,q=Object.prototype.toString;function W(e){var t,r,n,o,i,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var s=new ArrayBuffer(a),f=new Uint8Array(s);for(t=0;t<c;t+=4)r=j.indexOf(e[t]),n=j.indexOf(e[t+1]),o=j.indexOf(e[t+2]),i=j.indexOf(e[t+3]),f[u++]=r<<2|n>>4,f[u++]=(15&n)<<4|o>>2,f[u++]=(3&o)<<6|63&i;return s}function H(e){var t,r=new Uint8Array(e),n="";for(t=0;t<r.length;t+=3)n+=j[r[t]>>2],n+=j[(3&r[t])<<4|r[t+1]>>4],n+=j[(15&r[t+1])<<2|r[t+2]>>6],n+=j[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var Q={serialize:function(e,t){var r="";if(e&&(r=q.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===q.call(e.buffer))){var n,o=U;e instanceof ArrayBuffer?(n=e,o+=L):(n=e.buffer,"[object Int8Array]"===r?o+=F:"[object Uint8Array]"===r?o+=D:"[object Uint8ClampedArray]"===r?o+=M:"[object Int16Array]"===r?o+=B:"[object Uint16Array]"===r?o+=$:"[object Int32Array]"===r?o+=V:"[object Uint32Array]"===r?o+=G:"[object Float32Array]"===r?o+=Y:"[object Float64Array]"===r?o+=K:t(new Error("Failed to get type for BinaryArray"))),t(o+H(n))}else if("[object Blob]"===r){var i=new FileReader;i.onload=function(){var r="~~local_forage_type~"+e.type+"~"+H(this.result);t("__lfsc__:blob"+r)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,x)!==U)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(x,z);if(n===k&&P.test(r)){var o=r.match(P);t=o[1],r=r.substring(o[0].length)}var a=W(r);switch(n){case L:return a;case k:return i([a],{type:t});case F:return new Int8Array(a);case D:return new Uint8Array(a);case M:return new Uint8ClampedArray(a);case B:return new Int16Array(a);case $:return new Uint16Array(a);case V:return new Int32Array(a);case G:return new Uint32Array(a);case Y:return new Float32Array(a);case K:return new Float64Array(a);default:throw new Error("Unkown type: "+n)}},stringToBuffer:W,bufferToString:H};function J(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function X(e,t,r,n,o,i){e.executeSql(r,n,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?i(e,a):J(e,t,(function(){e.executeSql(r,n,o,i)}),i)}),i):i(e,a)}),i)}function Z(e,t,r,n){var o=this;e=s(e);var i=new a((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var c=t,u=o._dbInfo;u.serializer.serialize(t,(function(t,s){s?a(s):u.db.transaction((function(r){X(r,u,"INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(c)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(n>0)return void i(Z.apply(o,[e,c,r,n-1]));a(t)}}))}))})).catch(a)}));return c(i,r),i}function ee(e){return new a((function(t,r){e.transaction((function(n){n.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,n){for(var o=[],i=0;i<n.rows.length;i++)o.push(n.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){r(t)}))}),(function(e){r(e)}))}))}var te={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var o=new a((function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction((function(o){J(o,r,(function(){t._dbInfo=r,e()}),(function(e,t){n(t)}))}),n)}));return r.serializer=Q,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT * FROM "+o.storeName,[],(function(r,n){for(var i=n.rows,a=i.length,c=0;c<a;c++){var u=i.item(c),s=u.value;if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,u.key,c+1)))return void t(s)}t()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var n=r.rows.length?r.rows.item(0).value:null;n&&(n=o.serializer.deserialize(n)),t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},setItem:function(e,t,r){return Z.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=s(e);var n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},clear:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"DELETE FROM "+n.storeName,[],(function(){e()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},length:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],(function(t,r){var n=r.rows.item(0).c;e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},key:function(e,t){var r=this,n=new a((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){X(r,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,t),n},keys:function(e){var t=this,r=new a((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){X(t,n,"SELECT key FROM "+n.storeName,[],(function(t,r){for(var n=[],o=0;o<r.rows.length;o++)n.push(r.rows.item(o).key);e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,e),r},dropInstance:function(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,o=this;return c(n=e.name?new a((function(t){var n;n=e.name===r.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:n,storeNames:[e.storeName]}):t(ee(n))})).then((function(e){return new a((function(t,r){e.db.transaction((function(n){function o(e){return new a((function(t,r){n.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){r(t)}))}))}for(var i=[],c=0,u=e.storeNames.length;c<u;c++)i.push(o(e.storeNames[c]));a.all(i).then((function(){t()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):a.reject("Invalid arguments"),t),n}};function re(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function ne(){return!function(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}()||localStorage.length>0}var oe={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=re(e,this._defaultConfig),ne()?(this._dbInfo=t,t.serializer=Q,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then((function(){for(var t=r._dbInfo,n=t.keyPrefix,o=n.length,i=localStorage.length,a=1,c=0;c<i;c++){var u=localStorage.key(c);if(0===u.indexOf(n)){var s=localStorage.getItem(u);if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,u.substring(o),a++)))return s}}}));return c(n,t),n},getItem:function(e,t){var r=this;e=s(e);var n=r.ready().then((function(){var t=r._dbInfo,n=localStorage.getItem(t.keyPrefix+e);return n&&(n=t.serializer.deserialize(n)),n}));return c(n,t),n},setItem:function(e,t,r){var n=this;e=s(e);var o=n.ready().then((function(){void 0===t&&(t=null);var r=t;return new a((function(o,i){var a=n._dbInfo;a.serializer.serialize(t,(function(t,n){if(n)i(n);else try{localStorage.setItem(a.keyPrefix+e,t),o(r)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return c(o,r),o},removeItem:function(e,t){var r=this;e=s(e);var n=r.ready().then((function(){var t=r._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return c(n,t),n},clear:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}}));return c(r,e),r},length:function(e){var t=this.keys().then((function(e){return e.length}));return c(t,e),t},key:function(e,t){var r=this,n=r.ready().then((function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t}));return c(n,t),n},keys:function(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo,r=localStorage.length,n=[],o=0;o<r;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&n.push(i.substring(e.keyPrefix.length))}return n}));return c(r,e),r},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var n,o=this;return c(n=e.name?new a((function(t){e.storeName?t(re(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}})):a.reject("Invalid arguments"),t),n}},ie=function(e,t){for(var r=e.length,n=0;n<r;){if((o=e[n])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0;n++}var o,i;return!1},ae=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ce={},ue={},se={INDEXEDDB:A,WEBSQL:te,LOCALSTORAGE:oe},fe=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],le=["dropInstance"],de=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(le),ve={description:"",driver:fe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function he(e,t){e[t]=function(){var r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function pe(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(ae(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var ye=new(function(){function e(t){for(var r in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),se)if(se.hasOwnProperty(r)){var n=se[r],o=n._driver;this[r]=o,ce[o]||this.defineDriver(n)}this._defaultConfig=pe({},ve),this._config=pe({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":n(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,r){var n=new a((function(t,r){try{var n=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(o);for(var i=de.concat("_initStorage"),u=0,s=i.length;u<s;u++){var f=i[u];if((!ie(le,f)||e[f])&&"function"!=typeof e[f])return void r(o)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),r=a.reject(t);return c(r,arguments[arguments.length-1]),r}},r=0,n=le.length;r<n;r++){var o=le[r];e[o]||(e[o]=t(o))}}();var l=function(r){ce[n]&&console.info("Redefining LocalForage driver: "+n),ce[n]=e,ue[n]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(l,r):l(!!e._support):l(!0)}catch(e){r(e)}}));return u(n,t,r),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,r){var n=ce[e]?a.resolve(ce[e]):a.reject(new Error("Driver not found."));return u(n,t,r),n},e.prototype.getSerializer=function(e){var t=a.resolve(Q);return u(t,e),t},e.prototype.ready=function(e){var t=this,r=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return u(r,e,e),r},e.prototype.setDriver=function(e,t,r){var n=this;ae(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){n._config.driver=n.driver()}function c(e){return n._extend(e),i(),n._ready=n._initStorage(n._config),n._ready}var s=null!==this._driverSet?this._driverSet.catch((function(){return a.resolve()})):a.resolve();return this._driverSet=s.then((function(){var e=o[0];return n._dbInfo=null,n._ready=null,n.getDriver(e).then((function(e){n._driver=e._driver,i(),n._wrapLibraryMethodsWithReady(),n._initDriver=function(e){return function(){var t=0;return function r(){for(;t<e.length;){var o=e[t];return t++,n._dbInfo=null,n._ready=null,n.getDriver(o).then(c).catch(r)}i();var u=new Error("No available storage method found.");return n._driverSet=a.reject(u),n._driverSet}()}}(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return n._driverSet=a.reject(e),n._driverSet})),u(this._driverSet,t,r),this._driverSet},e.prototype.supports=function(e){return!!ue[e]},e.prototype._extend=function(e){pe(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var o=e[r];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=de.length;e<t;e++)he(this,de[e])},e.prototype.createInstance=function(t){return new e(t)},e}());t.exports=ye},{3:3}]},{},[4])(4)},390:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof y?t:y,i=Object.create(o.prototype),a=new T(n||[]);return i._invoke=function(e,t,r){var n=l;return function(o,i){if(n===v)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return A()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=I(a,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=v;var u=f(e,t,r);if("normal"===u.type){if(n=r.done?h:d,u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=h,r.method="throw",r.arg=u.arg)}}}(e,r,a),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l="suspendedStart",d="suspendedYield",v="executing",h="completed",p={};function y(){}function g(){}function m(){}var b={};b[i]=function(){return this};var E=Object.getPrototypeOf,_=E&&E(E(N([])));_&&_!==r&&n.call(_,i)&&(b=_);var w=m.prototype=y.prototype=Object.create(b);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(o,i,a,c){var u=f(e[o],e,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,c)}))}c(u.arg)}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}}function I(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method))return p;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var o=f(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,p;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,p):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,p)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function N(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:A}}function A(){return{value:t,done:!0}}return g.prototype=w.constructor=m,m.constructor=g,g.displayName=u(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},S(R.prototype),R.prototype[a]=function(){return this},e.AsyncIterator=R,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new R(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(w),u(w,c,"Generator"),w[i]=function(){return this},w.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}},896:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncContract=void 0;var i=r(174),a=r(589);t.AsyncContract=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length-1,c=e.slice(0,r),u=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<c.length){var s="Expected "+c.length+" arguments but only received "+t.length,f=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(f)}for(var l=0;l<c.length;l++)c[l].check(t[l]);var d=e.apply(void 0,o([],n(t)));if(!(d instanceof Promise))throw s="Expected function to return a promise, but instead got "+d,f=a.FAILURE.RETURN_INCORRECT(s),new i.ValidationError(f);return d.then(u.check)}}}}},308:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Contract=void 0;var i=r(174),a=r(589);t.Contract=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length-1,c=e.slice(0,r),u=e[r];return{enforce:function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(t.length<c.length){var s="Expected "+c.length+" arguments but only received "+t.length,f=a.FAILURE.ARGUMENT_INCORRECT(s);throw new i.ValidationError(f)}for(var l=0;l<c.length;l++)c[l].check(t[l]);return u.check(e.apply(void 0,o([],n(t))))}}}}},965:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checked=t.check=void 0;var n=r(174),o=r(589),i=new WeakMap;function a(e,t,r){var n=i.get(e),o=n&&n.get(t);if(o)return o;for(var a=[],c=0;c<r;c++)a.push(c);return a}t.check=function(e,t,r){var n=i.get(e)||new Map;i.set(e,n);var o=n.get(t)||[];n.set(t,o),o.push(r)},t.checked=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("No runtype provided to `@checked`. Please remove the decorator.");return function(t,r,i){var c=i.value,u=(t.name||t.constructor.name+".prototype")+("string"==typeof r?'["'+r+'"]':"["+String(r)+"]"),s=a(t,r,e.length);if(s.length!==e.length)throw new Error("Number of `@checked` runtypes and @check parameters not matched.");if(s.length>c.length)throw new Error("Number of `@checked` runtypes exceeds actual parameter length.");i.value=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.forEach((function(e,r){var i=s[r],a=e.validate(t[i]);if(!a.success){var c=u+", argument #"+i+": "+a.message,f=o.FAILURE.ARGUMENT_INCORRECT(c);throw new n.ValidationError(f)}})),c.apply(this,t)}}}},174:function(e,t){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationError=void 0;var o=function(e){function t(r){var n=e.call(this,r.message)||this;return n.name="ValidationError",n.code=r.code,void 0!==r.details&&(n.details=r.details),Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error);t.ValidationError=o},61:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceOf=t.Null=t.Undefined=t.Literal=void 0,o(r(350),t),o(r(205),t),o(r(308),t),o(r(896),t),o(r(339),t),o(r(174),t),o(r(615),t),o(r(551),t),o(r(362),t);var i=r(620);Object.defineProperty(t,"Literal",{enumerable:!0,get:function(){return i.Literal}}),Object.defineProperty(t,"Undefined",{enumerable:!0,get:function(){return i.Undefined}}),Object.defineProperty(t,"Null",{enumerable:!0,get:function(){return i.Null}}),o(r(643),t),o(r(422),t),o(r(172),t),o(r(856),t),o(r(59),t),o(r(669),t),o(r(941),t),o(r(489),t),o(r(745),t),o(r(219),t),o(r(617),t),o(r(979),t),o(r(548),t);var a=r(937);Object.defineProperty(t,"InstanceOf",{enumerable:!0,get:function(){return a.InstanceOf}}),o(r(813),t),o(r(277),t),o(r(550),t),o(r(965),t)},339:function(e,t){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a};Object.defineProperty(t,"__esModule",{value:!0}),t.match=void 0,t.match=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var o,i;try{for(var a=r(e),c=a.next();!c.done;c=a.next()){var u=n(c.value,2),s=u[0],f=u[1];if(s.guard(t))return f(t)}}catch(e){o={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}throw new Error("No alternatives were matched")}}},350:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},205:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Failcode=void 0,t.Failcode={TYPE_INCORRECT:"TYPE_INCORRECT",VALUE_INCORRECT:"VALUE_INCORRECT",KEY_INCORRECT:"KEY_INCORRECT",CONTENT_INCORRECT:"CONTENT_INCORRECT",ARGUMENT_INCORRECT:"ARGUMENT_INCORRECT",RETURN_INCORRECT:"RETURN_INCORRECT",CONSTRAINT_FAILED:"CONSTRAINT_FAILED",PROPERTY_MISSING:"PROPERTY_MISSING",PROPERTY_PRESENT:"PROPERTY_PRESENT",NOTHING_EXPECTED:"NOTHING_EXPECTED"}},705:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.innerValidate=t.create=void 0;var n=r(61),o=r(268),i=r(174),a=r(589);t.create=function(e,t){return t.check=r,t.assert=r,t._innerValidate=function(r,n){return n.has(r,t)?a.SUCCESS(r):e(r,n)},t.validate=function(e){return t._innerValidate(e,(r=new WeakMap,n=function(e,t){if(null!==e&&"object"==typeof e){var n=r.get(e);r.set(e,n?n.set(t,!0):(new WeakMap).set(t,!0))}},{has:function(e,t){var o=r.get(e),i=o&&o.get(t)||!1;return n(e,t),i}}));var r,n},t.guard=function(e){return t.validate(e).success},t.Or=function(e){return n.Union(t,e)},t.And=function(e){return n.Intersect(t,e)},t.optional=function(){return n.Optional(t)},t.nullable=function(){return n.Union(t,n.Null)},t.withConstraint=function(e,r){return n.Constraint(t,e,r)},t.withGuard=function(e,r){return n.Constraint(t,e,r)},t.withBrand=function(e){return n.Brand(e,t)},t.reflect=t,t.toString=function(){return"Runtype<"+o.default(t)+">"},t;function r(e){var r=t.validate(e);if(r.success)return r.value;throw new i.ValidationError(r)}},t.innerValidate=function(e,t,r){return e._innerValidate(t,r)}},268:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e,t){return function(o){var i=function(t){return e?"("+t+")":t};if(t.has(o))return i("CIRCULAR "+o.tag);t.add(o);try{switch(o.tag){case"unknown":case"never":case"void":case"boolean":case"number":case"bigint":case"string":case"symbol":case"function":return o.tag;case"literal":var a=o.value;return"string"==typeof a?'"'+a+'"':String(a);case"array":return""+n(o)+r(!0,t)(o.element)+"[]";case"dictionary":return"{ [_: "+o.key+"]: "+r(!1,t)(o.value)+" }";case"record":var c=Object.keys(o.fields);return c.length?"{ "+c.map((function(e){return""+n(o)+e+(a=e,c=(i=o).isPartial,u=i.fields,(c||void 0!==a&&"optional"===u[a].tag?"?":"")+": ")+("optional"===o.fields[e].tag?r(!1,t)(o.fields[e].underlying):r(!1,t)(o.fields[e]))+";";var i,a,c,u})).join(" ")+" }":"{}";case"tuple":return"["+o.components.map(r(!1,t)).join(", ")+"]";case"union":return i(""+o.alternatives.map(r(!0,t)).join(" | "));case"intersect":return i(""+o.intersectees.map(r(!0,t)).join(" & "));case"optional":return r(e,t)(o.underlying)+" | undefined";case"constraint":return o.name||r(e,t)(o.underlying);case"instanceof":return o.ctor.name;case"brand":return r(e,t)(o.entity)}}finally{t.delete(o)}throw Error("impossible")}};function n(e){return e.isReadonly?"readonly ":""}t.default=r(!1,new Set)},669:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Array=void 0;var n=r(705),o=r(589);function i(e,t){var r,a={tag:"array",isReadonly:t,element:e};return(r=n.create((function(t,r){if(!Array.isArray(t))return o.FAILURE.TYPE_INCORRECT(a,t);var i=o.enumerableKeysOf(t),c=i.map((function(o){return n.innerValidate(e,t[o],r)})),u=i.reduce((function(e,t){var r=c[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(u).length?o.FAILURE.CONTENT_INCORRECT(a,u):o.SUCCESS(t)}),a)).asReadonly=function(){return i(r.element,!0)},r}t.Array=function(e){return i(e,!1)}},172:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BigInt=void 0;var n=r(705),o=r(589),i={tag:"bigint"};t.BigInt=n.create((function(e){return"bigint"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},643:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Boolean=void 0;var n=r(705),o=r(589),i={tag:"boolean"};t.Boolean=n.create((function(e){return"boolean"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},550:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Brand=void 0;var n=r(705);t.Brand=function(e,t){var r={tag:"brand",brand:e,entity:t};return n.create((function(e){return t.validate(e)}),r)}},277:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Guard=t.Constraint=void 0;var n=r(705),o=r(589),i=r(615);t.Constraint=function(e,t,r){var i=r&&r.name,a=r&&r.args,c={tag:"constraint",underlying:e,constraint:t,name:i,args:a};return n.create((function(r){var n=e.validate(r);if(!n.success)return n;var i=t(n.value);return"string"==typeof i?o.FAILURE.CONSTRAINT_FAILED(c,i):i?o.SUCCESS(n.value):o.FAILURE.CONSTRAINT_FAILED(c)}),c)},t.Guard=function(e,t){return i.Unknown.withGuard(e,t)}},745:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Dictionary=void 0;var n=r(705),o=r(856),i=r(277),a=r(268),c=r(589),u=i.Constraint(o.String,(function(e){return!isNaN(+e)}),{name:"number"});t.Dictionary=function(e,t){var i=void 0===t||"string"===t?o.String:"number"===t?u:t,s=a.default(i),f={tag:"dictionary",key:s,value:e};return n.create((function(t,o){if(null==t||"object"!=typeof t)return c.FAILURE.TYPE_INCORRECT(f,t);if(Object.getPrototypeOf(t)!==Object.prototype&&(!Array.isArray(t)||"string"===s))return c.FAILURE.TYPE_INCORRECT(f,t);var a=/^(?:NaN|-?\d+(?:\.\d+)?)$/u,u=c.enumerableKeysOf(t),l=u.reduce((function(u,s){var l="string"==typeof s&&a.test(s),d=l?r.g.Number(s):s;return(l?i.guard(d)||i.guard(s):i.guard(d))?u[s]=n.innerValidate(e,t[s],o):u[s]=c.FAILURE.KEY_INCORRECT(f,i.reflect,d),u}),{}),d=u.reduce((function(e,t){var r=l[t];return r.success||(e[t]=r.details||r.message),e}),{});return 0!==c.enumerableKeysOf(d).length?c.FAILURE.CONTENT_INCORRECT(f,d):c.SUCCESS(t)}),f)}},548:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Function=void 0;var n=r(705),o=r(589),i={tag:"function"};t.Function=n.create((function(e){return"function"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},937:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceOf=void 0;var n=r(705),o=r(589);t.InstanceOf=function(e){var t={tag:"instanceof",ctor:e};return n.create((function(r){return r instanceof e?o.SUCCESS(r):o.FAILURE.TYPE_INCORRECT(t,r)}),t)}},617:function(e,t,r){"use strict";var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.Intersect=void 0;var o=r(705),i=r(589);t.Intersect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"intersect",intersectees:e};return o.create((function(t,r){var a,c;try{for(var u=n(e),s=u.next();!s.done;s=u.next()){var f=s.value,l=o.innerValidate(f,t,r);if(!l.success)return l}}catch(e){a={error:e}}finally{try{s&&!s.done&&(c=u.return)&&c.call(u)}finally{if(a)throw a.error}}return i.SUCCESS(t)}),r)}},813:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Lazy=void 0;var n=r(705);t.Lazy=function(e){var t,r={get tag(){return o().tag}};function o(){if(!t)for(var n in t=e())"tag"!==n&&(r[n]=t[n]);return t}return n.create((function(e){return o().validate(e)}),r)}},620:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Null=t.Undefined=t.Literal=void 0;var n=r(705),o=r(589);function i(e){return Array.isArray(e)?String(e.map(String)):"bigint"==typeof e?String(e)+"n":String(e)}function a(e){var t={tag:"literal",value:e};return n.create((function(t){return t===e?o.SUCCESS(t):o.FAILURE.VALUE_INCORRECT("literal","`"+i(e)+"`","`"+i(t)+"`")}),t)}t.Literal=a,t.Undefined=a(void 0),t.Null=a(null)},551:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Never=void 0;var n=r(705),o=r(589);t.Never=n.create(o.FAILURE.NOTHING_EXPECTED,{tag:"never"})},422:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Number=void 0;var n=r(705),o=r(589),i={tag:"number"};t.Number=n.create((function(e){return"number"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},979:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Optional=void 0;var n=r(705),o=r(589);t.Optional=function(e){var t={tag:"optional",underlying:e};return n.create((function(t){return void 0===t?o.SUCCESS(t):e.validate(t)}),t)}},489:function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Partial=t.Record=t.InternalRecord=void 0;var i=r(705),a=r(589);function c(e,t,r){var u,s={tag:"record",isPartial:t,isReadonly:r,fields:e};return(u=i.create((function(r,c){if(null==r)return a.FAILURE.TYPE_INCORRECT(s,r);var u=a.enumerableKeysOf(e);if(0!==u.length&&"object"!=typeof r)return a.FAILURE.TYPE_INCORRECT(s,r);var f=o([],n(new Set(o(o([],n(u)),n(a.enumerableKeysOf(r)))))),l=f.reduce((function(n,o){var u=a.hasKey(o,e),s=a.hasKey(o,r);if(u){var f=e[o],l=t||"optional"===f.reflect.tag;if(s){var d=r[o];n[o]=l&&void 0===d?a.SUCCESS(d):i.innerValidate(f,d,c)}else n[o]=l?a.SUCCESS(void 0):a.FAILURE.PROPERTY_MISSING(f.reflect)}else{if(!s)throw new Error("impossible");d=r[o],n[o]=a.SUCCESS(d)}return n}),{}),d=f.reduce((function(e,t){var r=l[t];return r.success||(e[t]=r.details||r.message),e}),{});return 0!==a.enumerableKeysOf(d).length?a.FAILURE.CONTENT_INCORRECT(s,d):a.SUCCESS(r)}),s)).asPartial=function(){return c(u.fields,!0,u.isReadonly)},u.asReadonly=function(){return c(u.fields,u.isPartial,!0)},u.pick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return e.forEach((function(e){r[e]=u.fields[e]})),c(r,u.isPartial,u.isReadonly)},u.omit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={};return a.enumerableKeysOf(u.fields).forEach((function(t){e.includes(t)||(r[t]=u.fields[t])})),c(r,u.isPartial,u.isReadonly)},u}t.InternalRecord=c,t.Record=function(e){return c(e,!1,!1)},t.Partial=function(e){return c(e,!0,!1)}},856:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.String=void 0;var n=r(705),o=r(589),i={tag:"string"};t.String=n.create((function(e){return"string"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},59:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Symbol=void 0;var n=r(705),o=r(589),i={tag:"symbol"};t.Symbol=n.create((function(e){return"symbol"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),Object.assign((function(e){var t={tag:"symbol",key:e};return n.create((function(n){if("symbol"!=typeof n)return o.FAILURE.TYPE_INCORRECT(t,n);var i=r.g.Symbol.keyFor(n);return i!==e?o.FAILURE.VALUE_INCORRECT("symbol key",a(e),a(i)):o.SUCCESS(n)}),t)}),i));var a=function(e){return void 0===e?"undefined":'"'+e+'"'}},941:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tuple=void 0;var n=r(705),o=r(589);t.Tuple=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"tuple",components:e};return n.create((function(t,i){if(!Array.isArray(t))return o.FAILURE.TYPE_INCORRECT(r,t);if(t.length!==e.length)return o.FAILURE.CONSTRAINT_FAILED(r,"Expected length "+e.length+", but was "+t.length);var a=o.enumerableKeysOf(t),c=a.map((function(r){return n.innerValidate(e[r],t[r],i)})),u=a.reduce((function(e,t){var r=c[t];return r.success||(e[t]=r.details||r.message),e}),[]);return 0!==o.enumerableKeysOf(u).length?o.FAILURE.CONTENT_INCORRECT(r,u):o.SUCCESS(t)}),r)}},219:function(e,t,r){"use strict";var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.Union=void 0;var o=r(705),i=r(589);t.Union=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return function(r){for(var n=0;n<e.length;n++)if(e[n].guard(r))return t[n](r)}},a={tag:"union",alternatives:e,match:r};return o.create((function(t,r){var c,u,s,f,l,d,v,h;if("object"!=typeof t||null===t){try{for(var p=n(e),y=p.next();!y.done;y=p.next()){var g=y.value;if(o.innerValidate(g,t,r).success)return i.SUCCESS(t)}}catch(e){c={error:e}}finally{try{y&&!y.done&&(u=p.return)&&u.call(p)}finally{if(c)throw c.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}var m={};try{for(var b=n(e),E=b.next();!E.done;E=b.next())if("record"===(g=E.value).reflect.tag){var _=function(e){var t=g.reflect.fields[e];"literal"===t.tag&&(m[e]?m[e].every((function(e){return e!==t.value}))&&m[e].push(t.value):m[e]=[t.value])};for(var w in g.reflect.fields)_(w)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(f=b.return)&&f.call(b)}finally{if(s)throw s.error}}for(var w in m)if(m[w].length===e.length)try{for(var S=(l=void 0,n(e)),R=S.next();!R.done;R=S.next())if("record"===(g=R.value).reflect.tag){var I=g.reflect.fields[w];if("literal"===I.tag&&i.hasKey(w,t)&&t[w]===I.value)return o.innerValidate(g,t,r)}}catch(e){l={error:e}}finally{try{R&&!R.done&&(d=S.return)&&d.call(S)}finally{if(l)throw l.error}}try{for(var O=n(e),C=O.next();!C.done;C=O.next()){var T=C.value;if(o.innerValidate(T,t,r).success)return i.SUCCESS(t)}}catch(e){v={error:e}}finally{try{C&&!C.done&&(h=O.return)&&h.call(O)}finally{if(v)throw v.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}),a)}},615:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Unknown=void 0;var n=r(705),o=r(589);t.Unknown=n.create((function(e){return o.SUCCESS(e)}),{tag:"unknown"})},362:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Void=void 0;var n=r(615);t.Void=n.Unknown},589:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FAILURE=t.SUCCESS=t.enumerableKeysOf=t.typeOf=t.hasKey=void 0;var o=r(205),i=r(268);t.hasKey=function(e,t){return"object"==typeof t&&null!==t&&e in t},t.typeOf=function(e){return"object"==typeof e?null===e?"null":Array.isArray(e)?"array":"Object"===e.constructor.name?"object":e.constructor.name:typeof e},t.enumerableKeysOf=function(e){return"object"==typeof e&&null!==e?Reflect.ownKeys(e).filter((function(t){var r,n;return null===(n=null===(r=e.propertyIsEnumerable)||void 0===r?void 0:r.call(e,t))||void 0===n||n})):[]},t.SUCCESS=function(e){return{success:!0,value:e}},t.FAILURE=Object.assign((function(e,t,r){return n({success:!1,code:e,message:t},r?{details:r}:{})}),{TYPE_INCORRECT:function(e,r){var n="Expected "+i.default(e)+", but was "+t.typeOf(r);return t.FAILURE(o.Failcode.TYPE_INCORRECT,n)},VALUE_INCORRECT:function(e,r,n){return t.FAILURE(o.Failcode.VALUE_INCORRECT,"Expected "+e+" "+String(r)+", but was "+String(n))},KEY_INCORRECT:function(e,r,n){return t.FAILURE(o.Failcode.KEY_INCORRECT,"Expected "+i.default(e)+" key to be "+i.default(r)+", but was "+t.typeOf(n))},CONTENT_INCORRECT:function(e,r){var n="Expected "+i.default(e)+", but was incompatible";return t.FAILURE(o.Failcode.CONTENT_INCORRECT,n,r)},ARGUMENT_INCORRECT:function(e){return t.FAILURE(o.Failcode.ARGUMENT_INCORRECT,e)},RETURN_INCORRECT:function(e){return t.FAILURE(o.Failcode.RETURN_INCORRECT,e)},CONSTRAINT_FAILED:function(e,r){var n=r?": "+r:"";return t.FAILURE(o.Failcode.CONSTRAINT_FAILED,"Failed constraint check for "+i.default(e)+n)},PROPERTY_MISSING:function(e){var r="Expected "+i.default(e)+", but was missing";return t.FAILURE(o.Failcode.PROPERTY_MISSING,r)},PROPERTY_PRESENT:function(e){var r="Expected nothing, but was "+t.typeOf(e);return t.FAILURE(o.Failcode.PROPERTY_PRESENT,r)},NOTHING_EXPECTED:function(e){var r="Expected nothing, but was "+t.typeOf(e);return t.FAILURE(o.Failcode.NOTHING_EXPECTED,r)}})}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{goToLoginPage:()=>pe,logout:()=>ye,tryActivateSubscriptionAccess:()=>ge,user:()=>he}),r(390);const e=()=>window.location.hostname,t=()=>e().replace(/\.[^.]+\.api\.no/,"");var o=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))};const i=(e,t,r)=>{!function(e,t){const r=new FormData;Object.keys(t).forEach((e=>r.append(e,t[e]))),fetch(e,{method:"POST",body:r,headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}}).then((e=>{if(!e.ok)throw new Error(`Error, status: ${e.status}, text: ${e.statusText}`)}))}(`//www.aid.no/api/mercury/v1/log/${e}`,Object.assign(Object.assign({},r),{message:t,url:window.location.href,domain:window.location.host}))},a=(e,t)=>i("error",e,t);class c extends Error{}const u={debug:console.debug,info:console.info,warn:console.warn,error:console.error};let s;var f;"undefined"!=typeof window&&(f=window,s=f);const l=(e,t)=>{s?s.addEventListener(e,(e=>{e.stopImmediatePropagation(),t.apply(s,[e])})):u.error("No root element to bind event to!")},d=(e,t)=>{s?s.addEventListener(e,(e=>{t.apply(s,[e])})):u.error("No root element to bind event to!")},v=e=>{s?s.dispatchEvent(e):u.error("No root element to dispatch event on!")};var h=r(61);const p={},y=e=>{const t=p[e];return t?(delete p[e],t):[]},g=()=>{const e="undefined"!=typeof window?window:r.g;return e.amediaUserCache||(e.amediaUserCache={})},m={get:e=>{const t=g()[e];return Promise.resolve(t)},set:(e,t,r)=>(g()[e]={key:e,data:t,expires:r},Promise.resolve()),remove:e=>(delete g()[e],Promise.resolve()),clear:()=>(("undefined"!=typeof window?window:r.g).amediaUserCache={},Promise.resolve())};const b=()=>m,E=e=>b().remove(e),_=(e,t)=>{return r=void 0,n=void 0,i=function*(){const r=yield b().get(e);if(!r)return Promise.resolve();if(Date.now()>r.expires)return E(e),Promise.resolve();try{return t.check(r.data)}catch(t){return t instanceof h.ValidationError?u.error("Failed validating data",{data:r.data,error:t.details}):u.error("Unknown error",t),E(e),Promise.resolve()}},new((o=void 0)||(o=Promise))((function(e,t){function a(e){try{u(i.next(e))}catch(e){t(e)}}function c(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(a,c)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i};function w(e,t,r,n){return new Promise(((o,i)=>{((e,t)=>{p[e]||(p[e]=[]),p[e].push(t)})(e,{resolve:o,reject:i}),(e=>{var t;return(null===(t=p[e])||void 0===t?void 0:t.length)||0})(e)>1||_(e,t).then((t=>{!t||n&&!n(t)?r().then((r=>{const n=t?((e,t)=>!e||Array.isArray(t)?t:t?"object"==typeof e&&"object"==typeof t?Object.assign(Object.assign({},e),t):t:e)(t,r.data):r.data;((e,t,r)=>{b().set(e,t,Date.now()+r)})(e,n,r.ttl),y(e).forEach((e=>{e.resolve(r.data)}))})).catch((()=>{y(e).forEach((e=>{e.reject()}))})):y(e).forEach((e=>{e.resolve(t)}))}))}))}const S=(0,h.Record)({id:h.Number,domain:h.String}),R=(0,h.Record)({status:(0,h.Literal)("success"),access:(0,h.Union)((0,h.Literal)("granted"),(0,h.Literal)("denied")),publication:S,access_features:(0,h.Array)(h.String)}),I=((0,h.Record)({status:(0,h.Literal)("success"),cookie:h.String,access_features:(0,h.Array)(h.String)}),(0,h.Record)({status:(0,h.Literal)("success"),vstoken_cookie:h.String,uuid:h.String,access_features:(0,h.Array)(h.String)}),{}),O={},C=(e,t)=>{I[e]=Object.assign(Object.assign({},I[e]),t),(e=>{var t;null===(t=O[e])||void 0===t||t.forEach((t=>t(I[e])))})(e)},T=(e,t)=>{O[e]||(O[e]=[]),O[e].push(t)};var N=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))};const A=(0,h.Record)({user_name:h.String,tracking_key:h.String}),j=e=>({name:e.user_name,trackingKey:e.tracking_key}),P=()=>fetch("/api/pluto/v1/sessions/current").then((e=>e.ok?(C("state",{isLoggedIn:!0}),e.json()):403===e.status?(C("state",{isLoggedIn:!1}),{}):(u.error(`Unknown error (${e.status}: ${e.statusText}) when fetching current session`,{response:e}),Promise.reject()))).then((e=>{try{return{ttl:1e4,data:A.check(e)}}catch(e){throw u.error("Invalid schema",e),e}})),U=e=>N(void 0,void 0,void 0,(function*(){return fetch(`/api/pluto/v1/sessions/current?publication_domain=${e}`,{method:"DELETE"}).then((e=>{if(!e.ok){if(403===e.status)return;throw new Error(`Error, could not perform deleteRequest. Status: ${e.status} Text: ${e.statusText}`)}C("state",{isLoggedIn:!1})}))}));let x;const L=self||window,k="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==L.msCrypto&&"function"==typeof L.msCrypto.getRandomValues&&L.msCrypto.getRandomValues.bind(L.msCrypto);if(k){const e=new Uint8Array(16);x=function(){return k(e),e}}else{const e=new Array(16);x=function(){for(let t,r=0;r<16;r+=1)0==(3&r)&&(t=4294967296*Math.random()),e[r]=t>>>((3&r)<<3)&255;return e}}const F=[];for(let e=0;e<256;++e)F[e]=(e+256).toString(16).substr(1);function D(e,t){return(...r)=>{const{resolve:n,reject:o,promise:i}=function(){let e,t,r=!1;return{promise:new Promise(((n,o)=>{e=e=>{r||n(e),r=!0},t=e=>{r||o(e),r=!0}})),resolve:e,reject:t}}(),a=function(){const e=x();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let r=0;const n=F;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}(e)}(),c=new CustomEvent(`amedia-rpc-event:${e}:${t}`,{detail:{eventId:a,args:r}});if(self.dispatchEvent(c),self.amediaNativeBridge){const n=JSON.stringify(r);self.amediaNativeBridge.callNativeMethod(e,t,n,a)}return self.addEventListener(`amedia-rpc-event:${e}:${t}:${a}`,(e=>{e.detail||n();const{error:t,result:r}=e.detail;return t?o(t):n(r)})),i}}class M{constructor({version:e,component:t,methods:r=[]}){this.component=t,this.version=e,this.queue=[],r.forEach((e=>this.addMethod(e))),this.boundLiveHandler=this.liveHandler.bind(this),self.addEventListener(`amedia-rpc-event:${t}:live`,this.boundLiveHandler),setTimeout((()=>self.dispatchEvent(new CustomEvent(`amedia-rpc-event:${t}:ready`))),0)}liveHandler(e){const[t,r]=e.detail.version.split(".").map((e=>parseInt(e,10))),[n,o]=this.version.split(".").map((e=>parseInt(e,10)));if(t!==n)throw new Error(`${this.component} version mismatch. Server version: ${t}. Client version: ${n}`);r<o&&console.warn(`${this.component} server version is on an earlier minor version (${r}) than the client (${o})`);const i=this.queue.slice(0);delete this.queue,i.forEach((e=>e())),self.removeEventListener(`amedia-rpc-event:${this.component}:live`,this.boundLiveHandler)}addMethod(e){if(this[e])throw new Error(`${e} already exists on the RPC interface.`);this[e]=(...t)=>{if(this.queue){let r,n;const o=new Promise(((e,t)=>{r=e,n=t}));return this.queue.push((()=>this[e](...t).then(r).catch(n))),o}return this[e]=D(this.component,e),this[e](...t)}}}let B;const V=(e,t)=>{const r=t.substring(e.length,t.length);return"{"===r.substring(0,1)?JSON.parse(r):"%7B"===r.substring(0,3)?JSON.parse(decodeURIComponent(r)):"undefined"!==r?""===r||"null"===r?null:r:void 0};function $(e){!function(e,t,r=Date.now(),n="/",o=!1){const i=new Date;let a=`${e}=`;t&&""!==t||(r=-1),a+=(e=>e&&""!==e?e instanceof Object?encodeURIComponent(JSON.stringify(e)):"number"==typeof e?e.toString(10):e:"")(t),a+=((e,t)=>t?t instanceof Date?`; expires=${t.toUTCString()}`:(e.setTime(e.getTime()+24*t*60*60*1e3),`; expires=${e.toUTCString()}`):"")(i,r),a+=`; path=${n}`,o&&(a+="; secure"),document.cookie=a,r&&-1!==r&&null===(e=>{const t=`${e}=`,r=document.cookie.split(";");for(let e=r.length-1;e>=0;e-=1){const n=r[e].trim();if(0===n.indexOf(t))return V(t,n)}return null})(e)&&(document.cookie=a.replace(/; expires=[^;]*/,""))}(e)}const G=()=>{return e=void 0,r=void 0,o=function*(){return Promise.all([U(t()),b().clear()]).then((()=>{(B||(B=new M({version:"1.0.0",component:"userdata-session",methods:["userAuthenticated"]}),B)).userAuthenticated(!1),$("VSTOKEN"),$("aid.session"),$("aid_invitation_code"),$("aid-reload-article"),$("VSTOKEN2")})).catch((e=>{u.error("Failure while logging out",e)}))},new((n=void 0)||(n=Promise))((function(t,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function c(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,c)}u((o=o.apply(e,r||[])).next())}));var e,r,n,o},Y=()=>N(void 0,void 0,void 0,(function*(){return w("getCurrentSession",A,P).then(j)}));var K;!function(e){e.REQUEST_ACTIVATION="amedia-user.activation.request-activation",e.ON_ACTIVATION_COMPLETE="amedia-user.activation.on-activation-complete"}(K||(K={})),l(K.REQUEST_ACTIVATION,(e=>{(e=>{try{return(e=>o(void 0,void 0,void 0,(function*(){return fetch(`/api/mercury/v2/access/activate?publication_wwwdomain=${t()}&access_features=${e.join(",")}`,{method:"post"}).then((e=>o(void 0,void 0,void 0,(function*(){let t;try{t=yield e.json()}catch(e){a("Body does not contain parsable json",e)}if(!e.ok){if(401===e.status&&"user_deactivated"===(null==t?void 0:t.status))throw new c;return!1}return"success"===(null==t?void 0:t.status)&&"granted"===(null==t?void 0:t.access)}))))})))(e)}catch(e){if(e instanceof c)return G(),Promise.resolve(!1);throw e}})(e.detail.accessFeatures).then((e=>{v(new CustomEvent(K.ON_ACTIVATION_COMPLETE,{detail:{hasAccess:e}}))}))}));var z=r(466),q=r(651);let W;const H="undefined"==typeof self?window:self,Q="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==H.msCrypto&&"function"==typeof H.msCrypto.getRandomValues&&H.msCrypto.getRandomValues.bind(H.msCrypto);if(Q){const e=new Uint8Array(16);W=function(){return Q(e),e}}else{const e=new Array(16);W=function(){for(let t,r=0;r<16;r+=1)0==(3&r)&&(t=4294967296*Math.random()),e[r]=t>>>((3&r)<<3)&255;return e}}const J=[];for(let e=0;e<256;++e)J[e]=(e+256).toString(16).substr(1);function X(){const e=W();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let r=0;const n=J;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}(e)}z.config({name:"aid:userdata"});const Z=self.location.hostname.replace(/(.*\.)([^.]+\.\w+$)/,"$2");function ee(e){return q.set("amedia:visitid",e,{expires:new Date(Date.now()+18e5),domain:Z,sameSite:"strict"}),z.setItem("visitid",e).then((()=>e))}function te(){const e=Date.now();return ee(`${X()}|${e}`)}function re(){return function(){const e=q.get("amedia:visitid");return e?Promise.resolve(e):z.getItem("visitid")}().then((e=>e||te())).then((e=>{const[t,r]=e.split("|");return!t||r&&Date.now()-18e5>r?te():ee(`${t}|${Date.now()}`)})).catch((e=>console.error(e)))}"undefined"!=typeof window&&["mousedown","keydown","mousemove","focus","scroll","resize","seshat-video-active","touchmove","deviceorientation"].forEach((e=>window.addEventListener(e,function(e){let t=!1;return(...r)=>{t||(e.apply(this,r),t=!0,setTimeout((()=>{t=!1}),400))}}(re))));const ne=(0,h.Record)({namespaces:(0,h.Dictionary)(h.Unknown,h.String)}),oe=(e,t={ignoreCache:!1})=>{return r=void 0,n=void 0,i=function*(){if(0===e.length)throw new Error("namespaces array cannot be of length 0");return w("europa",ne,(()=>((e,t="GET",r)=>fetch(e,{method:t,body:r&&JSON.stringify(r),headers:{"Content-Type":"application/json",Accept:"application/json"}}))(`/api/europa/v1/me/${e.join(",")}`).then((t=>t.ok?t.json():(u.error(`Could not get namespaces for: ${e}, status: ${t.status}, statusText: ${t.statusText}`,t),{namespaces:{}}))).then((e=>({ttl:3e5,data:e})))),(r=>!t.ignoreCache||0===Object.keys(r.namespaces).filter((t=>!Object.keys(e).includes(t))).length)).then((e=>e.namespaces))},new((o=void 0)||(o=Promise))((function(e,t){function a(e){try{u(i.next(e))}catch(e){t(e)}}function c(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(a,c)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i};const ie=(0,h.Record)({allowResearchUsage:h.Boolean,connectWithSurveys:h.Boolean,personalizedAds:h.Boolean,personalizedContent:h.Boolean}),ae=e=>"true"===e||!0===e,ce=(0,h.Dictionary)(h.Unknown,h.String).And((0,h.Partial)({ad_segments:h.String,ad_segments_user:h.String,age:h.Number,age_user:h.Number,birth_year:h.String,birth_year_user:h.String,gender:h.String,gender_user:h.String,grunnkrets:h.String,grunnkrets_user:h.String,postcode:h.String,postcode_user:h.String,shared_account:h.Boolean,shared_account_user:h.Boolean,user_grouping_number:h.String,user_grouping_number_user:h.String})),ue=e=>({extraData:e}),se={name:Y,trackingKey:Y,access:()=>{return e=t(),r=["newspaper"],w("checkForAccess",R,(()=>fetch(`/api/jupiter/v1/check_access_for_paper/${e}/?require=any&access_features=${r.join(",")}`).then((e=>{if(!e.ok)throw new Error(`Request not ok (${e.status}: ${e.statusText}).`);return e.json()})).then((e=>{try{const t=R.check(e);return{ttl:"granted"===t.access?1e4:0,data:t}}catch(e){throw u.error("Invalid schema",e),e}})))).then((e=>({access:e.access_features})));var e,r},extraData:()=>function(){let e=q.get("amedia:fpbid");return e||(e=X(),q.set("amedia:fpbid",e,{expires:3650,domain:Z,sameSite:"strict"})),Promise.resolve(e)}().then((e=>{var t;return((e,t,r)=>w("getNebulaInfo",ce,(()=>((e,t,r)=>{const n=new URL("https://services.gcloud.api.no/api/nebula/v1/info");return n.searchParams.set("domain",e),n.searchParams.set("browser_id",t),r&&n.searchParams.set("user_key",r),fetch(n.toString()).then((e=>e.json())).then((e=>{try{return{ttl:18e6,data:ce.check(e)}}catch(e){throw u.error("Invalid schema",e),e}}))})(e,t,r))).then(ue))(window.location.hostname,e,null===(t=I["userAttributes"])||void 0===t?void 0:t.trackingKey)})),privacyPreferences:()=>{return e=void 0,t=void 0,n=function*(){return w("privacyPreferences",ie,(()=>oe(["privacy_preferences"]).then((e=>{const t=e.privacy_preferences;return{ttl:3e5,data:{allowResearchUsage:ae(t.allow_research_usage),connectWithSurveys:ae(t.connect_with_surveys),personalizedAds:ae(t.personalized_ads),personalizedContent:ae(t.personalized_content)}}})))).then((e=>({privacyPreferences:e})))},new((r=void 0)||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}));var e,t,r,n}};var fe;!function(e){e.REQUEST_USER_ATTRIBUTES="amedia-user.request-user-attributes",e.REQUEST_STORAGE_NAMESPACES="amedia-user.request-storage-namespaces",e.ON_ATTRIBUTES_UPDATED="amedia-user.on-user-attributes-updated",e.ON_STATE_UPDATED="amedia-user.on-state-updated",e.ON_STORAGE_UPDATED="amedia-user.on-storage-updated"}(fe||(fe={})),T("userAttributes",(e=>{v(new CustomEvent(fe.ON_ATTRIBUTES_UPDATED,{detail:e}))})),T("state",(e=>{v(new CustomEvent(fe.ON_STATE_UPDATED,{detail:e}))})),T("storage",(e=>{v(new CustomEvent(fe.ON_STORAGE_UPDATED,{detail:e}))})),l(fe.REQUEST_USER_ATTRIBUTES,(e=>{(e=>{const t=[];for(e.forEach((e=>{const r=se[e];r?t.includes(r)||t.push(r):u.warn("Unknown attribute was requested")}));t.length>0;){const e=t.pop();e&&e().then((e=>C("userAttributes",e))).catch((t=>{u.error("Call rejected",e,t)}))}})(e.detail)})),l(fe.REQUEST_STORAGE_NAMESPACES,(e=>{var t;t=e.detail,oe(t).then((e=>{C("storage",e)}))}));const le=(e,t)=>{if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r){if(!n.includes(o))return!1;if("function"==typeof e[o]||"function"==typeof t[o]){if(e[o].toString()!==t[o].toString())return!1}else if(!le(e[o],t[o]))return!1}return!0};class de{constructor(e,t){this.attributes=e,this.namespaces=t}withAttributes(...e){return new de([...this.attributes||[],...e],this.namespaces)}withStorage(...e){return new de(this.attributes,[...this.namespaces||[],...e])}subscribe(e){let t=this.setupLocalCache();d(fe.ON_STATE_UPDATED,(r=>{const n=r.detail;Object.keys(t.state).length>0&&le(t.state,n)||(t=Object.assign(Object.assign({},t),{state:n}),e(t))})),Array.isArray(this.attributes)&&this.attributes.length>0&&(d(fe.ON_ATTRIBUTES_UPDATED,(r=>{const n=this.processUserAttributesEvent(r);Object.keys(t.attributes).length>0&&le(t.attributes,n)||(t=Object.assign(Object.assign({},t),{attributes:n}),e(t))})),v(new CustomEvent(fe.REQUEST_USER_ATTRIBUTES,{detail:this.attributes}))),Array.isArray(this.namespaces)&&this.namespaces.length>0&&(d(fe.ON_STORAGE_UPDATED,(r=>{const n=this.processStorageEvent(r);le(t.storage,n)||(t=Object.assign(Object.assign({},t),{storage:n}),e(t))})),v(new CustomEvent(fe.REQUEST_STORAGE_NAMESPACES,{detail:this.namespaces})))}processUserAttributesEvent(e){const t=e.detail;return this.attributes.reduce(((e,r)=>(void 0!==t[r]&&(e[r]=t[r]),e)),{})}processStorageEvent(e){const t=e.detail;return this.namespaces.reduce(((e,r)=>(void 0!==t[r]&&(e[r]=t[r]),e)),{})}setupLocalCache(){const e={state:{}};return this.attributes&&this.attributes.length>0&&(e.attributes={}),this.namespaces&&this.namespaces.length>0&&(e.storage={}),e}}const ve=de,he=()=>new ve,pe=t=>(t=>{const r=(()=>{const t=/^bed-([^.]+)\.api\.no$/.exec(e()),r=/\.([^.]+)\.api\.no/.exec(e());return t?t[1]:r?r[1]:null})(),n=new URL(`https://aid.no${r&&`.${r}.api.no`}/aid/logg_inn/`);n.searchParams.set("requestedUrl",t||window.location.href),window.location.href=n.href})(t||window.location.href),ye=()=>G(),ge=e=>new Promise((t=>{d(K.ON_ACTIVATION_COMPLETE,(e=>t(e.detail))),v(new CustomEvent(K.REQUEST_ACTIVATION,{detail:{accessFeatures:e}}))}))})(),n})()}));
@@ -0,0 +1,21 @@
1
+ import { State, UserAttributes } from '../types';
2
+ declare class User<UA extends UserAttributes, S extends {
3
+ [index: string]: unknown;
4
+ }, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends {} = {
5
+ state: State;
6
+ }> {
7
+ private attributes?;
8
+ private namespaces?;
9
+ constructor(attributes?: Attributes | undefined, namespaces?: Namespaces | undefined);
10
+ withAttributes<NewAttributes extends Array<keyof UA>>(...attribute: NewAttributes): User<UA, S, (Attributes[number] & NewAttributes[number])[], Namespaces, SubscribeResponse & {
11
+ attributes: Pick<UA, Attributes[number] & NewAttributes[number]>;
12
+ }>;
13
+ withStorage<NewNamespaces extends Array<string>>(...namespace: NewNamespaces): User<UA, S, Attributes, (Namespaces[number] & NewNamespaces[number])[], SubscribeResponse & {
14
+ storage: Pick<S, Namespaces[number] & NewNamespaces[number]>;
15
+ }>;
16
+ subscribe(onData: (data: SubscribeResponse) => void): void;
17
+ private processUserAttributesEvent;
18
+ private processStorageEvent;
19
+ private setupLocalCache;
20
+ }
21
+ export default User;
@@ -2,10 +2,19 @@ import { State, UserAttributes } from '../types';
2
2
  declare type StoreDataMap = {
3
3
  userAttributes: UserAttributes;
4
4
  state: State;
5
+ storage: {
6
+ [namespace: string]: {
7
+ [index: string]: unknown;
8
+ };
9
+ };
5
10
  };
6
11
  declare type Listener<T> = (data: T) => void;
7
12
  declare const _default: {
8
- set: (key: keyof StoreDataMap, value: UserAttributes | State) => void;
13
+ set: (key: keyof StoreDataMap, value: UserAttributes | State | {
14
+ [namespace: string]: {
15
+ [index: string]: unknown;
16
+ };
17
+ }) => void;
9
18
  get: <K extends keyof StoreDataMap, T = StoreDataMap[K]>(key: K) => T | undefined;
10
19
  on: <K_1 extends keyof StoreDataMap, T_1 = StoreDataMap[K_1]>(key: K_1, listener: Listener<T_1>) => void;
11
20
  clear: () => void;
package/dist/types.d.ts CHANGED
@@ -8,20 +8,14 @@ export declare type UserAttributes = {
8
8
  };
9
9
  access?: string[];
10
10
  privacyPreferences?: PrivacyPreferences;
11
- storage?: {
12
- [index: string]: unknown;
13
- };
14
11
  };
15
12
  export declare type State = {
16
13
  isLoggedIn: boolean;
17
14
  emergencyMode?: string[];
18
15
  };
19
- export declare type AnonymousAttributes = {
20
- age: number;
21
- };
22
16
  export declare type PrivacyPreferences = {
23
- allowResearchUsage: Boolean;
24
- connectWithSurveys: Boolean;
25
- personalizedAds: Boolean;
26
- personalizedContent: Boolean;
17
+ allowResearchUsage: boolean;
18
+ connectWithSurveys: boolean;
19
+ personalizedAds: boolean;
20
+ personalizedContent: boolean;
27
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amedia/user",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Client lib for working with aID user and associated data",
5
5
  "repository": "https://github.com/amedia/amedia-user-js",
6
6
  "author": "Amedia Utvikling (ID og data)",
@@ -19,8 +19,8 @@ export const getPrivacyPreferences = async (): Promise<
19
19
  Pick<UserAttributes, 'privacyPreferences'>
20
20
  > =>
21
21
  getOrUpdate(PRIVACY_PREFERENCES_CACHE_KEY, PrivacyPreferencesSchema, () =>
22
- getNamespaces(['privacy_preferences']).then((user) => {
23
- const privacyPreferences: any = user.storage?.privacy_preferences || {};
22
+ getNamespaces(['privacy_preferences']).then((namespaces) => {
23
+ const privacyPreferences: any = namespaces.privacy_preferences;
24
24
 
25
25
  return {
26
26
  ttl: CACHE_DURATION,
@@ -0,0 +1,8 @@
1
+ import { getNamespaces } from '../clients/europa';
2
+ import store from '../store';
3
+
4
+ export const requestStorage = (namespaces: string[]) => {
5
+ getNamespaces(namespaces).then((storage) => {
6
+ store.set('storage', storage);
7
+ });
8
+ };