@amedia/user 0.13.14 → 0.13.16

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.
package/dist/index.js CHANGED
@@ -1,2 +1,15 @@
1
- /*! For license information please see index.js.LICENSE.txt */
2
- var e={808:(e,t,n)=>{var r,o,i;void 0===(o="function"==typeof(r=i=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function o(){}function i(t,n,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(n);/^[\{\[]/.test(a)&&(n=a)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).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 s="";for(var c in i)i[c]&&(s+="; "+c,!0!==i[c]&&(s+="="+i[c].split(";")[0]));return document.cookie=t+"="+n+s}}function a(e,n){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],a=0;a<i.length;a++){var s=i[a].split("="),c=s.slice(1).join("=");n||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var u=t(s[0]);if(c=(r.read||r)(c,u)||t(c),n)try{c=JSON.parse(c)}catch(e){}if(o[u]=c,e===u)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,n){i(t,"",e(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}((function(){}))})?r.call(t,n,t,e):r)||(e.exports=o),e.exports=i()},483:(e,t,n)=>{e.exports=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};t[a][0].call(u.exports,(function(e){return o(t[a][1][e]||e)}),u,u.exports,e,t,n,r)}return n[a].exports}for(var i=void 0,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,r){(function(e){var n,r,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),s=e.document.createTextNode("");a.observe(s,{characterData:!0}),n=function(){s.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="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 c=new e.MessageChannel;c.port1.onmessage=f,n=function(){c.port2.postMessage(0)}}var u=[];function f(){var e,t;r=!0;for(var n=u.length;n;){for(t=u,u=[],e=-1;++e<n;)t[e]();n=u.length}r=!1}t.exports=function(e){1!==u.push(e)||r||n()}}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var r=e(1);function o(){}var i={},a=["REJECTED"],s=["FULFILLED"],c=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==o&&v(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r((function(){var r;try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)}))}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 n=!1;function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=h((function(){t(o,r)}));"error"===a.status&&r(a.value)}function h(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=u,u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===s||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(o);return this.state!==c?l(n,this.state===s?e:t,this.outcome):this.queue.push(new f(n,e,t)),n},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 n=h(d,t);if("error"===n.status)return i.reject(e,n.value);var r=n.value;if(r)v(e,r);else{e.state=s,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 n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},u.resolve=function(e){return e instanceof this?e:i.resolve(new this(o),e)},u.reject=function(e){var t=new this(o);return i.reject(t,e)},u.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),s=0,c=-1,u=new this(o);++c<n;)f(e[c],c);return u;function f(e,o){t.resolve(e).then((function(e){a[o]=e,++s!==n||r||(r=!0,i.resolve(u,a))}),(function(e){r||(r=!0,i.reject(u,e))}))}},u.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n,r=e.length,a=!1;if(!r)return this.resolve([]);for(var s=-1,c=new this(o);++s<r;)n=e[s],t.resolve(n).then((function(e){a||(a=!0,i.resolve(c,e))}),(function(e){a||(a=!0,i.reject(c,e))}));return c}},{1:1}],3:[function(e,t,r){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){var r="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 n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var a=Promise;function s(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function c(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function u(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,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function m(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a((function(t){var n=e.transaction(l,y),r=i([""]);n.objectStore(l).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!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],n={};n.promise=new a((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function E(e){var t=v[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function _(e,t){var n=v[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function w(e,t){return new a((function(n,r){if(v[e.name]=v[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(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 n=a.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(l)}catch(n){if("ConstraintError"!==n.name)throw n;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(),r(a.error)},a.onsuccess=function(){n(a.result),E(e)}}))}function S(e){return w(e,!1)}function R(e){return w(e,!0)}function O(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version;if(r&&(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||n){if(n){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function T(e){return i([g(atob(e.data))],{type:e.type})}function C(e){return e&&e.__local_forage_encoded_blob}function I(e){var t=this,n=t._initReady().then((function(){var e=v[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return c(n,e,e),n}function A(e,t,n,r){void 0===r&&(r=1);try{var o=e.db.transaction(e.storeName,t);n(null,o)}catch(o){if(r>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],n=t.forages,r=0;r<n.length;r++){var o=n[r];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,S(e).then((function(t){return e.db=t,O(e)?R(e):t})).then((function(r){e.db=t.db=r;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r})).catch((function(t){throw _(e,t),t}))}(e).then((function(){A(e,t,n,r-1)}))})).catch(n);n(o)}}var N={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var o=v[n.name];o||(o={forages:[],db:null,dbReady:null,deferredOperations:[]},v[n.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=I);var i=[];function s(){return a.resolve()}for(var c=0;c<o.forages.length;c++){var u=o.forages[c];u!==t&&i.push(u._initReady().catch(s))}var f=o.forages.slice(0);return a.all(i).then((function(){return n.db=o.db,S(n)})).then((function(e){return n.db=e,O(n,t._defaultConfig.version)?R(n):e})).then((function(e){n.db=o.db=e,t._dbInfo=n;for(var r=0;r<f.length;r++){var i=f[r];i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.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 n=this,r=new a((function(t,r){n.ready().then((function(){A(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).openCursor(),s=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;C(r)&&(r=T(r));var o=e(r,n.key,s++);void 0!==o?t(o):n.continue()}else t()},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return s(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){A(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),C(e)&&(e=T(e)),t(e)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return s(r,t),r},setItem:function(e,t,n){var r=this;e=u(e);var o=new a((function(n,o){var i;r.ready().then((function(){return i=r._dbInfo,"[object Blob]"===h.call(t)?m(i.db).then((function(e){return e?t:(n=t,new a((function(e,t){var r=new FileReader;r.onerror=t,r.onloadend=function(t){var r=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:r,type:n.type})},r.readAsBinaryString(n)})));var n})):t})).then((function(t){A(r._dbInfo,y,(function(i,a){if(i)return o(i);try{var s=a.objectStore(r._dbInfo.storeName);null===t&&(t=void 0);var c=s.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=c.error?c.error:c.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return s(o,n),o},removeItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){A(n._dbInfo,y,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){r(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return s(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){A(t._dbInfo,y,(function(r,o){if(r)return n(r);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;n(e)}}catch(e){n(e)}}))})).catch(n)}));return s(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){A(t._dbInfo,p,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return s(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){e<0?t(null):n.ready().then((function(){A(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName),s=!1,c=a.openKeyCursor();c.onsuccess=function(){var n=c.result;n?0===e||s?t(n.key):(s=!0,n.advance(e)):t(null)},c.onerror=function(){r(c.error)}}catch(e){r(e)}}))})).catch(r)}));return s(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){A(t._dbInfo,p,(function(r,o){if(r)return n(r);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(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return s(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,i=this;if(e.name){var c=e.name===n.name&&i._dbInfo.db?a.resolve(i._dbInfo.db):S(e).then((function(t){var n=v[e.name],r=n.forages;n.db=t;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t;return t}));r=e.storeName?c.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;b(e);var r=v[e.name],i=r.forages;t.close();for(var s=0;s<i.length;s++){var c=i[s];c._dbInfo.db=null,c._dbInfo.version=n}return new a((function(t,r){var i=o.open(e.name,n);i.onerror=function(e){i.result.close(),r(e)},i.onupgradeneeded=function(){i.result.deleteObjectStore(e.storeName)},i.onsuccess=function(){var e=i.result;e.close(),t(e)}})).then((function(e){r.db=e;for(var t=0;t<i.length;t++){var n=i[t];n._dbInfo.db=e,E(n._dbInfo)}})).catch((function(t){throw(_(e,t)||a.resolve()).catch((function(){})),t}))}})):c.then((function(t){b(e);var n=v[e.name],r=n.forages;t.close();for(var i=0;i<r.length;i++)r[i]._dbInfo.db=null;return new a((function(t,n){var r=o.deleteDatabase(e.name);r.onerror=r.onblocked=function(e){var t=r.result;t&&t.close(),n(e)},r.onsuccess=function(){var e=r.result;e&&e.close(),t(e)}})).then((function(e){n.db=e;for(var t=0;t<r.length;t++)E(r[t]._dbInfo)})).catch((function(t){throw(_(e,t)||a.resolve()).catch((function(){})),t}))}))}else r=a.reject("Invalid arguments");return s(r,t),r}};var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=/^~~local_forage_type~([^~]+)~/,U="__lfsc__:",k=U.length,x="arbf",L="blob",F="si08",D="ui08",M="uic8",B="si16",$="si32",V="ur16",q="ui32",G="fl32",K="fl64",Y=k+x.length,z=Object.prototype.toString;function H(e){var t,n,r,o,i,a=.75*e.length,s=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),f=new Uint8Array(u);for(t=0;t<s;t+=4)n=j.indexOf(e[t]),r=j.indexOf(e[t+1]),o=j.indexOf(e[t+2]),i=j.indexOf(e[t+3]),f[c++]=n<<2|r>>4,f[c++]=(15&r)<<4|o>>2,f[c++]=(3&o)<<6|63&i;return u}function W(e){var t,n=new Uint8Array(e),r="";for(t=0;t<n.length;t+=3)r+=j[n[t]>>2],r+=j[(3&n[t])<<4|n[t+1]>>4],r+=j[(15&n[t+1])<<2|n[t+2]>>6],r+=j[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var Q={serialize:function(e,t){var n="";if(e&&(n=z.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===z.call(e.buffer))){var r,o=U;e instanceof ArrayBuffer?(r=e,o+=x):(r=e.buffer,"[object Int8Array]"===n?o+=F:"[object Uint8Array]"===n?o+=D:"[object Uint8ClampedArray]"===n?o+=M:"[object Int16Array]"===n?o+=B:"[object Uint16Array]"===n?o+=V:"[object Int32Array]"===n?o+=$:"[object Uint32Array]"===n?o+=q:"[object Float32Array]"===n?o+=G:"[object Float64Array]"===n?o+=K:t(new Error("Failed to get type for BinaryArray"))),t(o+W(r))}else if("[object Blob]"===n){var i=new FileReader;i.onload=function(){var n="~~local_forage_type~"+e.type+"~"+W(this.result);t("__lfsc__:blob"+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,k)!==U)return JSON.parse(e);var t,n=e.substring(Y),r=e.substring(k,Y);if(r===L&&P.test(n)){var o=n.match(P);t=o[1],n=n.substring(o[0].length)}var a=H(n);switch(r){case x:return a;case L: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 V:return new Uint16Array(a);case $:return new Int32Array(a);case q:return new Uint32Array(a);case G:return new Float32Array(a);case K:return new Float64Array(a);default:throw new Error("Unkown type: "+r)}},stringToBuffer:H,bufferToString:W};function J(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function X(e,t,n,r,o,i){e.executeSql(n,r,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,s){s.rows.length?i(e,a):J(e,t,(function(){e.executeSql(n,r,o,i)}),i)}),i):i(e,a)}),i)}function Z(e,t,n,r){var o=this;e=u(e);var i=new a((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var s=t,c=o._dbInfo;c.serializer.serialize(t,(function(t,u){u?a(u):c.db.transaction((function(n){X(n,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(s)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void i(Z.apply(o,[e,s,n,r-1]));a(t)}}))}))})).catch(a)}));return s(i,n),i}function ee(e){return new a((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var o=[],i=0;i<r.rows.length;i++)o.push(r.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}var te={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var o=new a((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction((function(o){J(o,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=Q,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){X(n,o,"SELECT * FROM "+o.storeName,[],(function(n,r){for(var i=r.rows,a=i.length,s=0;s<a;s++){var c=i.item(s),u=c.value;if(u&&(u=o.serializer.deserialize(u)),void 0!==(u=e(u,c.key,s+1)))return void t(u)}t()}),(function(e,t){r(t)}))}))})).catch(r)}));return s(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){X(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=o.serializer.deserialize(r)),t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return s(r,t),r},setItem:function(e,t,n){return Z.apply(this,[e,t,n,1])},removeItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){X(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){r(t)}))}))})).catch(r)}));return s(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){X(t,r,"DELETE FROM "+r.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return s(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){X(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(t,n){var r=n.rows.item(0).c;e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return s(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){X(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return s(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){X(t,r,"SELECT key FROM "+r.storeName,[],(function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key);e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return s(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;return s(r=e.name?new a((function(t){var r;r=e.name===n.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:r,storeNames:[e.storeName]}):t(ee(r))})).then((function(e){return new a((function(t,n){e.db.transaction((function(r){function o(e){return new a((function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var i=[],s=0,c=e.storeNames.length;s<c;s++)i.push(o(e.storeNames[s]));a.all(i).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):a.reject("Invalid arguments"),t),r}};function ne(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function re(){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 n in e)t[n]=e[n];return t.keyPrefix=ne(e,this._defaultConfig),re()?(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 n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,s=0;s<i;s++){var c=localStorage.key(s);if(0===c.indexOf(r)){var u=localStorage.getItem(c);if(u&&(u=t.serializer.deserialize(u)),void 0!==(u=e(u,c.substring(o),a++)))return u}}}));return s(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=n.ready().then((function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&(r=t.serializer.deserialize(r)),r}));return s(r,t),r},setItem:function(e,t,n){var r=this;e=u(e);var o=r.ready().then((function(){void 0===t&&(t=null);var n=t;return new a((function(o,i){var a=r._dbInfo;a.serializer.serialize(t,(function(t,r){if(r)i(r);else try{localStorage.setItem(a.keyPrefix+e,t),o(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return s(o,n),o},removeItem:function(e,t){var n=this;e=u(e);var r=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return s(r,t),r},clear:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return s(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return s(t,e),t},key:function(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return s(r,t),r},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o<n;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&r.push(i.substring(e.keyPrefix.length))}return r}));return s(n,e),n},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,o=this;return s(r=e.name?new a((function(t){e.storeName?t(ne(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):a.reject("Invalid arguments"),t),r}},ie=function(e,t){for(var n=e.length,r=0;r<n;){if((o=e[r])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0;r++}var o,i;return!1},ae=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},se={},ce={},ue={INDEXEDDB:N,WEBSQL:te,LOCALSTORAGE:oe},fe=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.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 n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function pe(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(ae(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var ye=new(function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue)if(ue.hasOwnProperty(n)){var r=ue[n],o=r._driver;this[n]=o,se[o]||this.defineDriver(r)}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":r(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,n){var r=new a((function(t,n){try{var r=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(o);for(var i=de.concat("_initStorage"),c=0,u=i.length;c<u;c++){var f=i[c];if((!ie(le,f)||e[f])&&"function"!=typeof e[f])return void n(o)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=a.reject(t);return s(n,arguments[arguments.length-1]),n}},n=0,r=le.length;n<r;n++){var o=le[n];e[o]||(e[o]=t(o))}}();var l=function(n){se[r]&&console.info("Redefining LocalForage driver: "+r),se[r]=e,ce[r]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(l,n):l(!!e._support):l(!0)}catch(e){n(e)}}));return c(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=se[e]?a.resolve(se[e]):a.reject(new Error("Driver not found."));return c(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(Q);return c(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return c(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this;ae(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){r._config.driver=r.driver()}function s(e){return r._extend(e),i(),r._ready=r._initStorage(r._config),r._ready}var u=null!==this._driverSet?this._driverSet.catch((function(){return a.resolve()})):a.resolve();return this._driverSet=u.then((function(){var e=o[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then((function(e){r._driver=e._driver,i(),r._wrapLibraryMethodsWithReady(),r._initDriver=function(e){return function(){var t=0;return function n(){for(;t<e.length;){var o=e[t];return t++,r._dbInfo=null,r._ready=null,r.getDriver(o).then(s).catch(n)}i();var c=new Error("No available storage method found.");return r._driverSet=a.reject(c),r._driverSet}()}}(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return r._driverSet=a.reject(e),r._driverSet})),c(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!ce[e]},e.prototype._extend=function(e){pe(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n];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)},36:function(e,t,n){var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncContract=void 0;var i=n(888),a=n(611);t.AsyncContract=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.length-1,s=e.slice(0,n),c=e[n];return{enforce:function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(t.length<s.length){var u="Expected "+s.length+" arguments but only received "+t.length,f=a.FAILURE.ARGUMENT_INCORRECT(u);throw new i.ValidationError(f)}for(var l=0;l<s.length;l++)s[l].check(t[l]);var d=e.apply(void 0,o([],r(t)));if(!(d instanceof Promise))throw u="Expected function to return a promise, but instead got "+d,f=a.FAILURE.RETURN_INCORRECT(u),new i.ValidationError(f);return d.then(c.check)}}}}},361:function(e,t,n){var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Contract=void 0;var i=n(888),a=n(611);t.Contract=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.length-1,s=e.slice(0,n),c=e[n];return{enforce:function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(t.length<s.length){var u="Expected "+s.length+" arguments but only received "+t.length,f=a.FAILURE.ARGUMENT_INCORRECT(u);throw new i.ValidationError(f)}for(var l=0;l<s.length;l++)s[l].check(t[l]);return c.check(e.apply(void 0,o([],r(t))))}}}}},316:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checked=t.check=void 0;var r=n(888),o=n(611),i=new WeakMap;function a(e,t,n){var r=i.get(e),o=r&&r.get(t);if(o)return o;for(var a=[],s=0;s<n;s++)a.push(s);return a}t.check=function(e,t,n){var r=i.get(e)||new Map;i.set(e,r);var o=r.get(t)||[];r.set(t,o),o.push(n)},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,n,i){var s=i.value,c=(t.name||t.constructor.name+".prototype")+("string"==typeof n?'["'+n+'"]':"["+String(n)+"]"),u=a(t,n,e.length);if(u.length!==e.length)throw new Error("Number of `@checked` runtypes and @check parameters not matched.");if(u.length>s.length)throw new Error("Number of `@checked` runtypes exceeds actual parameter length.");i.value=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.forEach((function(e,n){var i=u[n],a=e.validate(t[i]);if(!a.success){var s=c+", argument #"+i+": "+a.message,f=o.FAILURE.ARGUMENT_INCORRECT(s);throw new r.ValidationError(f)}})),s.apply(this,t)}}}},888:function(e,t){var n,r=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(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 r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationError=void 0;var o=function(e){function t(n){var r=e.call(this,n.message)||this;return r.name="ValidationError",r.code=n.code,void 0!==n.details&&(r.details=n.details),Object.setPrototypeOf(r,t.prototype),r}return r(t,e),t}(Error);t.ValidationError=o},529:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceOf=t.Null=t.Undefined=t.Literal=void 0,o(n(550),t),o(n(691),t),o(n(361),t),o(n(36),t),o(n(74),t),o(n(888),t),o(n(101),t),o(n(913),t),o(n(203),t);var i=n(275);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(n(19),t),o(n(257),t),o(n(481),t),o(n(304),t),o(n(333),t),o(n(380),t),o(n(226),t),o(n(695),t),o(n(132),t),o(n(724),t),o(n(239),t),o(n(209),t),o(n(559),t);var a=n(867);Object.defineProperty(t,"InstanceOf",{enumerable:!0,get:function(){return a.InstanceOf}}),o(n(802),t),o(n(845),t),o(n(111),t),o(n(316),t)},74:function(e,t){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.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=n(e),s=a.next();!s.done;s=a.next()){var c=r(s.value,2),u=c[0],f=c[1];if(u.guard(t))return f(t)}}catch(e){o={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}throw new Error("No alternatives were matched")}}},550:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},691:(e,t)=>{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"}},732:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.innerValidate=t.create=void 0;var r=n(529),o=n(233),i=n(888),a=n(611);t.create=function(e,t){return t.check=n,t.assert=n,t._innerValidate=function(n,r){return r.has(n,t)?a.SUCCESS(n):e(n,r)},t.validate=function(e){return t._innerValidate(e,(n=new WeakMap,r=function(e,t){if(null!==e&&"object"==typeof e){var r=n.get(e);n.set(e,r?r.set(t,!0):(new WeakMap).set(t,!0))}},{has:function(e,t){var o=n.get(e),i=o&&o.get(t)||!1;return r(e,t),i}}));var n,r},t.guard=function(e){return t.validate(e).success},t.Or=function(e){return r.Union(t,e)},t.And=function(e){return r.Intersect(t,e)},t.optional=function(){return r.Optional(t)},t.nullable=function(){return r.Union(t,r.Null)},t.withConstraint=function(e,n){return r.Constraint(t,e,n)},t.withGuard=function(e,n){return r.Constraint(t,e,n)},t.withBrand=function(e){return r.Brand(e,t)},t.reflect=t,t.toString=function(){return"Runtype<"+o.default(t)+">"},t;function n(e){var n=t.validate(e);if(n.success)return n.value;throw new i.ValidationError(n)}},t.innerValidate=function(e,t,n){return e._innerValidate(t,n)}},233:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=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""+r(o)+n(!0,t)(o.element)+"[]";case"dictionary":return"{ [_: "+o.key+"]: "+n(!1,t)(o.value)+" }";case"record":var s=Object.keys(o.fields);return s.length?"{ "+s.map((function(e){return""+r(o)+e+(a=e,s=(i=o).isPartial,c=i.fields,(s||void 0!==a&&"optional"===c[a].tag?"?":"")+": ")+("optional"===o.fields[e].tag?n(!1,t)(o.fields[e].underlying):n(!1,t)(o.fields[e]))+";";var i,a,s,c})).join(" ")+" }":"{}";case"tuple":return"["+o.components.map(n(!1,t)).join(", ")+"]";case"union":return i(""+o.alternatives.map(n(!0,t)).join(" | "));case"intersect":return i(""+o.intersectees.map(n(!0,t)).join(" & "));case"optional":return n(e,t)(o.underlying)+" | undefined";case"constraint":return o.name||n(e,t)(o.underlying);case"instanceof":return o.ctor.name;case"brand":return n(e,t)(o.entity)}}finally{t.delete(o)}throw Error("impossible")}};function r(e){return e.isReadonly?"readonly ":""}t.default=n(!1,new Set)},380:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Array=void 0;var r=n(732),o=n(611);function i(e,t){var n,a={tag:"array",isReadonly:t,element:e};return(n=r.create((function(t,n){if(!Array.isArray(t))return o.FAILURE.TYPE_INCORRECT(a,t);var i=o.enumerableKeysOf(t),s=i.map((function(o){return r.innerValidate(e,t[o],n)})),c=i.reduce((function(e,t){var n=s[t];return n.success||(e[t]=n.details||n.message),e}),[]);return 0!==o.enumerableKeysOf(c).length?o.FAILURE.CONTENT_INCORRECT(a,c):o.SUCCESS(t)}),a)).asReadonly=function(){return i(n.element,!0)},n}t.Array=function(e){return i(e,!1)}},481:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BigInt=void 0;var r=n(732),o=n(611),i={tag:"bigint"};t.BigInt=r.create((function(e){return"bigint"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},19:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Boolean=void 0;var r=n(732),o=n(611),i={tag:"boolean"};t.Boolean=r.create((function(e){return"boolean"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},111:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Brand=void 0;var r=n(732);t.Brand=function(e,t){var n={tag:"brand",brand:e,entity:t};return r.create((function(e){return t.validate(e)}),n)}},845:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Guard=t.Constraint=void 0;var r=n(732),o=n(611),i=n(101);t.Constraint=function(e,t,n){var i=n&&n.name,a=n&&n.args,s={tag:"constraint",underlying:e,constraint:t,name:i,args:a};return r.create((function(n){var r=e.validate(n);if(!r.success)return r;var i=t(r.value);return"string"==typeof i?o.FAILURE.CONSTRAINT_FAILED(s,i):i?o.SUCCESS(r.value):o.FAILURE.CONSTRAINT_FAILED(s)}),s)},t.Guard=function(e,t){return i.Unknown.withGuard(e,t)}},132:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Dictionary=void 0;var r=n(732),o=n(304),i=n(845),a=n(233),s=n(611),c=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?c:t,u=a.default(i),f={tag:"dictionary",key:u,value:e};return r.create((function(t,o){if(null==t||"object"!=typeof t)return s.FAILURE.TYPE_INCORRECT(f,t);if(Object.getPrototypeOf(t)!==Object.prototype&&(!Array.isArray(t)||"string"===u))return s.FAILURE.TYPE_INCORRECT(f,t);var a=/^(?:NaN|-?\d+(?:\.\d+)?)$/u,c=s.enumerableKeysOf(t),l=c.reduce((function(c,u){var l="string"==typeof u&&a.test(u),d=l?n.g.Number(u):u;return(l?i.guard(d)||i.guard(u):i.guard(d))?c[u]=r.innerValidate(e,t[u],o):c[u]=s.FAILURE.KEY_INCORRECT(f,i.reflect,d),c}),{}),d=c.reduce((function(e,t){var n=l[t];return n.success||(e[t]=n.details||n.message),e}),{});return 0!==s.enumerableKeysOf(d).length?s.FAILURE.CONTENT_INCORRECT(f,d):s.SUCCESS(t)}),f)}},559:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Function=void 0;var r=n(732),o=n(611),i={tag:"function"};t.Function=r.create((function(e){return"function"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},867:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceOf=void 0;var r=n(732),o=n(611);t.InstanceOf=function(e){var t={tag:"instanceof",ctor:e};return r.create((function(n){return n instanceof e?o.SUCCESS(n):o.FAILURE.TYPE_INCORRECT(t,n)}),t)}},239:function(e,t,n){var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],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=n(732),i=n(611);t.Intersect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={tag:"intersect",intersectees:e};return o.create((function(t,n){var a,s;try{for(var c=r(e),u=c.next();!u.done;u=c.next()){var f=u.value,l=o.innerValidate(f,t,n);if(!l.success)return l}}catch(e){a={error:e}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(a)throw a.error}}return i.SUCCESS(t)}),n)}},802:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Lazy=void 0;var r=n(732);t.Lazy=function(e){var t,n={get tag(){return o().tag}};function o(){if(!t)for(var r in t=e())"tag"!==r&&(n[r]=t[r]);return t}return r.create((function(e){return o().validate(e)}),n)}},275:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Null=t.Undefined=t.Literal=void 0;var r=n(732),o=n(611);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 r.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)},913:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Never=void 0;var r=n(732),o=n(611);t.Never=r.create(o.FAILURE.NOTHING_EXPECTED,{tag:"never"})},257:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Number=void 0;var r=n(732),o=n(611),i={tag:"number"};t.Number=r.create((function(e){return"number"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},209:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Optional=void 0;var r=n(732),o=n(611);t.Optional=function(e){var t={tag:"optional",underlying:e};return r.create((function(t){return void 0===t?o.SUCCESS(t):e.validate(t)}),t)}},695:function(e,t,n){var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Partial=t.Record=t.InternalRecord=void 0;var i=n(732),a=n(611);function s(e,t,n){var c,u={tag:"record",isPartial:t,isReadonly:n,fields:e};return(c=i.create((function(n,s){if(null==n)return a.FAILURE.TYPE_INCORRECT(u,n);var c=a.enumerableKeysOf(e);if(0!==c.length&&"object"!=typeof n)return a.FAILURE.TYPE_INCORRECT(u,n);var f=o([],r(new Set(o(o([],r(c)),r(a.enumerableKeysOf(n)))))),l=f.reduce((function(r,o){var c=a.hasKey(o,e),u=a.hasKey(o,n);if(c){var f=e[o],l=t||"optional"===f.reflect.tag;if(u){var d=n[o];r[o]=l&&void 0===d?a.SUCCESS(d):i.innerValidate(f,d,s)}else r[o]=l?a.SUCCESS(void 0):a.FAILURE.PROPERTY_MISSING(f.reflect)}else{if(!u)throw new Error("impossible");d=n[o],r[o]=a.SUCCESS(d)}return r}),{}),d=f.reduce((function(e,t){var n=l[t];return n.success||(e[t]=n.details||n.message),e}),{});return 0!==a.enumerableKeysOf(d).length?a.FAILURE.CONTENT_INCORRECT(u,d):a.SUCCESS(n)}),u)).asPartial=function(){return s(c.fields,!0,c.isReadonly)},c.asReadonly=function(){return s(c.fields,c.isPartial,!0)},c.pick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={};return e.forEach((function(e){n[e]=c.fields[e]})),s(n,c.isPartial,c.isReadonly)},c.omit=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={};return a.enumerableKeysOf(c.fields).forEach((function(t){e.includes(t)||(n[t]=c.fields[t])})),s(n,c.isPartial,c.isReadonly)},c}t.InternalRecord=s,t.Record=function(e){return s(e,!1,!1)},t.Partial=function(e){return s(e,!0,!1)}},304:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.String=void 0;var r=n(732),o=n(611),i={tag:"string"};t.String=r.create((function(e){return"string"==typeof e?o.SUCCESS(e):o.FAILURE.TYPE_INCORRECT(i,e)}),i)},333:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Symbol=void 0;var r=n(732),o=n(611),i={tag:"symbol"};t.Symbol=r.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 r.create((function(r){if("symbol"!=typeof r)return o.FAILURE.TYPE_INCORRECT(t,r);var i=n.g.Symbol.keyFor(r);return i!==e?o.FAILURE.VALUE_INCORRECT("symbol key",a(e),a(i)):o.SUCCESS(r)}),t)}),i));var a=function(e){return void 0===e?"undefined":'"'+e+'"'}},226:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Tuple=void 0;var r=n(732),o=n(611);t.Tuple=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={tag:"tuple",components:e};return r.create((function(t,i){if(!Array.isArray(t))return o.FAILURE.TYPE_INCORRECT(n,t);if(t.length!==e.length)return o.FAILURE.CONSTRAINT_FAILED(n,"Expected length "+e.length+", but was "+t.length);var a=o.enumerableKeysOf(t),s=a.map((function(n){return r.innerValidate(e[n],t[n],i)})),c=a.reduce((function(e,t){var n=s[t];return n.success||(e[t]=n.details||n.message),e}),[]);return 0!==o.enumerableKeysOf(c).length?o.FAILURE.CONTENT_INCORRECT(n,c):o.SUCCESS(t)}),n)}},724:function(e,t,n){var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],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=n(732),i=n(611);t.Union=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return function(n){for(var r=0;r<e.length;r++)if(e[r].guard(n))return t[r](n)}},a={tag:"union",alternatives:e,match:n};return o.create((function(t,n){var s,c,u,f,l,d,v,h;if("object"!=typeof t||null===t){try{for(var p=r(e),y=p.next();!y.done;y=p.next()){var g=y.value;if(o.innerValidate(g,t,n).success)return i.SUCCESS(t)}}catch(e){s={error:e}}finally{try{y&&!y.done&&(c=p.return)&&c.call(p)}finally{if(s)throw s.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}var m={};try{for(var b=r(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){u={error:e}}finally{try{E&&!E.done&&(f=b.return)&&f.call(b)}finally{if(u)throw u.error}}for(var w in m)if(m[w].length===e.length)try{for(var S=(l=void 0,r(e)),R=S.next();!R.done;R=S.next())if("record"===(g=R.value).reflect.tag){var O=g.reflect.fields[w];if("literal"===O.tag&&i.hasKey(w,t)&&t[w]===O.value)return o.innerValidate(g,t,n)}}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 T=r(e),C=T.next();!C.done;C=T.next()){var I=C.value;if(o.innerValidate(I,t,n).success)return i.SUCCESS(t)}}catch(e){v={error:e}}finally{try{C&&!C.done&&(h=T.return)&&h.call(T)}finally{if(v)throw v.error}}return i.FAILURE.TYPE_INCORRECT(a,t)}),a)}},101:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Unknown=void 0;var r=n(732),o=n(611);t.Unknown=r.create((function(e){return o.SUCCESS(e)}),{tag:"unknown"})},203:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Void=void 0;var r=n(101);t.Void=r.Unknown},611:function(e,t,n){var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])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=n(691),i=n(233);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 n,r;return null===(r=null===(n=e.propertyIsEnumerable)||void 0===n?void 0:n.call(e,t))||void 0===r||r})):[]},t.SUCCESS=function(e){return{success:!0,value:e}},t.FAILURE=Object.assign((function(e,t,n){return r({success:!1,code:e,message:t},n?{details:n}:{})}),{TYPE_INCORRECT:function(e,n){var r="Expected "+i.default(e)+", but was "+t.typeOf(n);return t.FAILURE(o.Failcode.TYPE_INCORRECT,r)},VALUE_INCORRECT:function(e,n,r){return t.FAILURE(o.Failcode.VALUE_INCORRECT,"Expected "+e+" "+String(n)+", but was "+String(r))},KEY_INCORRECT:function(e,n,r){return t.FAILURE(o.Failcode.KEY_INCORRECT,"Expected "+i.default(e)+" key to be "+i.default(n)+", but was "+t.typeOf(r))},CONTENT_INCORRECT:function(e,n){var r="Expected "+i.default(e)+", but was incompatible";return t.FAILURE(o.Failcode.CONTENT_INCORRECT,r,n)},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,n){var r=n?": "+n:"";return t.FAILURE(o.Failcode.CONSTRAINT_FAILED,"Failed constraint check for "+i.default(e)+r)},PROPERTY_MISSING:function(e){var n="Expected "+i.default(e)+", but was missing";return t.FAILURE(o.Failcode.PROPERTY_MISSING,n)},PROPERTY_PRESENT:function(e){var n="Expected nothing, but was "+t.typeOf(e);return t.FAILURE(o.Failcode.PROPERTY_PRESENT,n)},NOTHING_EXPECTED:function(e){var n="Expected nothing, but was "+t.typeOf(e);return t.FAILURE(o.Failcode.NOTHING_EXPECTED,n)}})},905:(e,t)=>{var n=function(e){if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1},r=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce((function(e,t){return Object.keys(t).forEach((function(o){Array.isArray(e[o])&&Array.isArray(t[o])?e[o]=Array.from(new Set(e[o].concat(t[o]))):n(e[o])&&n(t[o])?e[o]=r(e[o],t[o]):e[o]=t[o]})),e}),{})};t.Z=r}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};(()=>{n.d(r,{Hr:()=>dt,vg:()=>Re,EX:()=>vt,kS:()=>ht,Lk:()=>pt,Hc:()=>yt});const e=()=>window.location.hostname,t=()=>window.location.href,o=()=>e().replace(/\.[^.]+\.api\.no/,""),i=()=>{const t=(()=>{const t=/^bed-([^.]+)\.api\.no$/.exec(e()),n=/\.([^.]+)\.api\.no/.exec(e());return t?t[1]:n?n[1]:null})();let n="www.aid.no";return"localhost"===t?n="www.aid.no.localhost.api.no":t&&(n=`www-${t}.aid.no`),n},a=(n,r,o)=>{const i={};Object.keys(o).forEach((e=>{if(["string","number","boolean"].includes(typeof o[e]))i[e]=o[e];else try{i[e]=JSON.stringify(o[e])}catch(t){i[e]=o[e]}})),function(e,t){const n=new FormData;Object.keys(t).forEach((e=>n.append(e,t[e]))),fetch(e,{method:"POST",body:n,headers:{Accept:"application/json"}}).then((e=>{if(!e.ok)throw new Error(`Error, status: ${e.status}, text: ${e.statusText}`)}))}(`/api/mercury/v1/log/${n}`,Object.assign(Object.assign({},i),{message:r,url:t(),domain:e()}))},s={error:(e,t)=>a("error",e,t),warn:(e,t)=>a("warn",e,t),info:(e,t)=>a("info",e,t),debug:(e,t)=>a("debug",e,t)};var c=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};const u=e=>{const t={message:e.message};return Object.getOwnPropertyNames(e).forEach((n=>{t[n]=e[n]})),t},f=e=>c(void 0,void 0,void 0,(function*(){const t=e.bodyUsed?"Response body not available for logging":yield e.text(),n={url:e.url,status:e.status,statusText:e.statusText,body:t};return Object.getOwnPropertyNames(e).forEach((t=>{n[t]=e[t]})),n})),l=(e,t,n)=>{((e,t={})=>c(void 0,void 0,void 0,(function*(){let n=e,r=t||{};if(n instanceof Error){const e=u(n);n=e.message,r=Object.assign(Object.assign({},r),{error:e})}if(r=Object.assign(Object.assign({},r),{origin:"@amedia/user"}),t instanceof Error){const e=u(t);r=Object.assign(Object.assign({},r),{[Object.keys(r).includes("error")?"contextError":"error"]:e})}else if(r instanceof Response){const e=yield f(r);r=Object.assign(Object.assign({},r),{response:e})}else for(const e of Object.keys(r))if(r[e]instanceof Error)r[e]=u(r[e]);else if(r[e]instanceof Response){const t=yield f(r[e]);r[e]=t}return{message:n,context:r}})))(t,n).then((({message:t,context:n})=>s[e](t,n)))},d=(e,t)=>l("warn",e,t),v=(e,t)=>l("error",e,t);let h;var p;"undefined"!=typeof window&&(p=window,h=p);const y=(e,t)=>{h?h.addEventListener(e,(e=>{e.stopImmediatePropagation(),t.apply(h,[e])})):v("No root element to bind event to!")},g=(e,t)=>{h?h.addEventListener(e,(e=>{t.apply(h,[e])})):v("No root element to bind event to!")},m=e=>{h?h.dispatchEvent(e):v("No root element to dispatch event on!")};var b=n(529);const E={},_=e=>{const t=E[e];return t?(delete E[e],t):[]},w=()=>{const e="undefined"!=typeof window?window:n.g;return e.amediaUserCache||(e.amediaUserCache={})},S={get:e=>{const t=w()[e];return Promise.resolve(t)},set:(e,t,n)=>(w()[e]={key:e,data:t,expires:n},Promise.resolve()),remove:e=>(delete w()[e],Promise.resolve()),clear:()=>(("undefined"!=typeof window?window:n.g).amediaUserCache={},Promise.resolve())};const R=()=>S,O=e=>R().remove(e),T=(e,t)=>{return n=void 0,r=void 0,i=function*(){const n=yield R().get(e);if(!n)return Promise.resolve();if(Date.now()>n.expires)return O(e),Promise.resolve();try{return t.check(n.data)}catch(t){return v(t,{cacheData:n.data}),O(e),Promise.resolve()}},new((o=void 0)||(o=Promise))((function(e,t){function a(e){try{c(i.next(e))}catch(e){t(e)}}function s(e){try{c(i.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(a,s)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},C=(e,t,n)=>R().set(e,t,Date.now()+n);function I(e,t,n,r){return new Promise(((o,i)=>{((e,t)=>{E[e]||(E[e]=[]),E[e].push(t)})(e,{resolve:o,reject:i}),(e=>{var t;return(null===(t=E[e])||void 0===t?void 0:t.length)||0})(e)>1||T(e,t).then((t=>{!t||r&&!r(t)?n().then((n=>{const r=t?((e,t)=>!e||Array.isArray(t)?t:t?"object"==typeof e&&"object"==typeof t?Object.assign(Object.assign({},e),t):t:e)(t,n.data):n.data;C(e,r,n.ttl),_(e).forEach((e=>{e.resolve(n.data)}))})).catch((()=>{_(e).forEach((e=>{e.reject()}))})):_(e).forEach((e=>{e.resolve(t)}))}))}))}const A=(0,b.Record)({id:b.Number,domain:b.String}),N=(0,b.Record)({status:(0,b.Literal)("success"),access:(0,b.Union)((0,b.Literal)("granted"),(0,b.Literal)("denied")),publication:A,access_features:(0,b.Array)(b.String)}),j=(0,b.Record)({status:(0,b.Literal)("success"),cookie:b.String,access_features:(0,b.Array)(b.String)}),P=(0,b.Record)({status:(0,b.Literal)("success"),vstoken_cookie:b.String,uuid:b.String,access_features:(0,b.Array)(b.String)});var U=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};class k extends Error{}const x=["no_session_found","subscription_not_found"];var L=n(905);const F={},D={},M=(e,t)=>{F[e]=t,(e=>{var t;null===(t=D[e])||void 0===t||t.forEach((t=>t(F[e])))})(e)},B=(e,t)=>{M(e,(0,L.Z)(F[e]||{},t))},$=M,V=e=>F[e],q=(e,t)=>{D[e]||(D[e]=[]),D[e].push(t)},G=["avbrutt","kansellert","cancelled","aborted","failed to fetch","abgebrochen","the operation was aborted."];var K=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};const Y=(0,b.Partial)({user_uuid:b.String,user_name:b.String,tracking_key:b.String}),z=(0,b.Record)({code:b.String}),H=(0,b.Record)({errors:(0,b.Array)(z)}),W=["session.not_found","session.not_specified","user.deactivated"],Q=["session.invalid_for_domain","user.not_found"],J=e=>K(void 0,void 0,void 0,(function*(){let t;const n=e.clone();try{[t]=H.check(yield e.json()).errors}catch(e){return r=null==e?void 0:e.message,G.includes(r.toLowerCase().trim())?Promise.resolve():(d("Unable to parse error body from pluto",{error:e,response:n}),Promise.reject(e))}var r;return W.includes(null==t?void 0:t.code)?Promise.resolve():Q.includes(null==t?void 0:t.code)?(d(`Pluto responded with HTTP/${e.status}: (${t.code}) while fetching current session`,{error:t,response:e}),Promise.resolve()):(v(`Pluto responded with HTTP/${e.status}: ${e.statusText}) when fetching current session`,{error:t,response:e}),Promise.reject())})),X=()=>fetch("/api/pluto/v1/sessions/current").then((e=>e.ok?e.json():J(e).then((()=>({}))))).then((e=>{const t={ttl:-1,data:e};if(0===Object.keys(e).length)return t;try{return{ttl:1e4,data:Y.check(e)}}catch(n){return v(n,{json:e}),t}})),Z=e=>K(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}`)}B("state",{isLoggedIn:!1})}))}));let ee;const te=self||window,ne="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==te.msCrypto&&"function"==typeof te.msCrypto.getRandomValues&&te.msCrypto.getRandomValues.bind(te.msCrypto);if(ne){const e=new Uint8Array(16);ee=function(){return ne(e),e}}else{const e=new Array(16);ee=function(){for(let t,n=0;n<16;n+=1)0==(3&n)&&(t=4294967296*Math.random()),e[n]=t>>>((3&n)<<3)&255;return e}}const re=[];for(let e=0;e<256;++e)re[e]=(e+256).toString(16).substr(1);function oe(e,t){return(...n)=>{const{resolve:r,reject:o,promise:i}=function(){let e,t,n=!1;return{promise:new Promise(((r,o)=>{e=e=>{n||r(e),n=!0},t=e=>{n||o(e),n=!0}})),resolve:e,reject:t}}(),a=function(){const e=ee();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let n=0;const r=re;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}(e)}(),s=new CustomEvent(`amedia-rpc-event:${e}:${t}`,{detail:{eventId:a,args:n}});if(self.dispatchEvent(s),self.amediaNativeBridge){const r=JSON.stringify(n);self.amediaNativeBridge.callNativeMethod(e,t,r,a)}return self.addEventListener(`amedia-rpc-event:${e}:${t}:${a}`,(e=>{e.detail||r();const{error:t,result:n}=e.detail;return t?o(t):r(n)})),i}}class ie{constructor({version:e,component:t,methods:n=[]}){this.component=t,this.version=e,this.queue=[],n.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,n]=e.detail.version.split(".").map((e=>parseInt(e,10))),[r,o]=this.version.split(".").map((e=>parseInt(e,10)));if(t!==r)throw new Error(`${this.component} version mismatch. Server version: ${t}. Client version: ${r}`);n<o&&console.warn(`${this.component} server version is on an earlier minor version (${n}) 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 n,r;const o=new Promise(((e,t)=>{n=e,r=t}));return this.queue.push((()=>this[e](...t).then(n).catch(r))),o}return this[e]=oe(this.component,e),this[e](...t)}}}let ae;const se=(e,t)=>{const n=t.substring(e.length,t.length);return"{"===n.substring(0,1)?JSON.parse(n):"%7B"===n.substring(0,3)?JSON.parse(decodeURIComponent(n)):"undefined"!==n?""===n||"null"===n?null:n:void 0},ce=e=>{const t=`${e}=`,n=document.cookie.split(";");for(let e=n.length-1;e>=0;e-=1){const r=n[e].trim();if(0===r.indexOf(t))return se(t,r)}return null};function ue(e,t,n=Date.now(),r="/",o=!1){const i=new Date;let a=`${e}=`;return t&&""!==t||(n=-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,n),a+=`; path=${r}`,o&&(a+="; secure"),document.cookie=a,n&&-1!==n&&null===ce(e)&&(document.cookie=a.replace(/; expires=[^;]*/,"")),a}function fe(e){ue(e)}const le=e=>{window.location.href=e};const de=()=>{return e=void 0,t=void 0,r=function*(){return Promise.all([Z(o()),R().clear()]).then((()=>{(ae||(ae=new ie({version:"1.0.0",component:"userdata-session",methods:["userAuthenticated"]}),ae)).userAuthenticated(!1),fe("VSTOKEN"),fe("aid.session"),fe("aid_invitation_code"),fe("aid-reload-article"),fe("VSTOKEN2")})).catch((e=>{v("Failure while logging out",e)}))},new((n=void 0)||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}));var e,t,n,r},ve=()=>K(void 0,void 0,void 0,(function*(){return I("getCurrentSession",Y,X).then((e=>{return B("state",{isLoggedIn:void 0!==e.user_uuid}),{uuid:(t=e).user_uuid,name:t.user_name,trackingKey:t.tracking_key};var t}))}));var he=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};const pe=e=>he(void 0,void 0,void 0,(function*(){try{return yield(e=>U(void 0,void 0,void 0,(function*(){return fetch(`/api/mercury/v2/access/activate?publication_wwwdomain=${o()}&access_features=${e.join(",")}`,{method:"post"}).then((t=>U(void 0,void 0,void 0,(function*(){const n=yield t.text();let r;try{r=JSON.parse(n)}catch(r){v(`Activate subscription failed. Mercury (HTTP/${t.status}: ${n})`,{error:r,response:t,accessFeatures:e,body:n})}if(!t.ok){if("user_deactivated"===(null==r?void 0:r.status))throw new k;return x.includes(null==r?void 0:r.status)||v(`Activate subscription failed. Mercury (HTTP/${t.status}: ${n})`,{response:t,accessFeatures:e,body:n}),[]}return null==r?void 0:r.access_features}))))})))(e)}catch(e){if(e instanceof k)return yield de(),[];throw e}})),ye=(e,t)=>t.length<1||t.filter((t=>e.includes(t))).length>0,ge=e=>he(void 0,void 0,void 0,(function*(){const t=yield(e=>fetch(`/api/jupiter/v1/get_vstoken/${e}`,{method:"post"}).then((e=>{if(!e.ok)throw new Error(`Request not ok (${e.status}: ${e.statusText}).`);return e.json()})).then((e=>{try{return j.check(e)}catch(t){throw v(t,{json:e}),t}})))(e);return"success"===t.status&&ue("VSTOKEN",t.cookie,365,"/"),{success:"success"===t.status,accessFeatures:t.access_features}})),me=e=>he(void 0,void 0,void 0,(function*(){const t=yield(e=>fetch(`/api/jupiter/v1/non_user_access/${e}`,{method:"post"}).then((e=>{if(!e.ok)throw new Error(`Request not ok (${e.status}: ${e.statusText}).`);return e.json()})).then((e=>{try{return P.check(e)}catch(t){throw v(t,{json:e}),t}})))(e);return"success"===t.status&&ue("VSTOKEN2",t.vstoken_cookie,1,"/"),{success:"success"===t.status,accessFeatures:t.access_features}}));var be,Ee;!function(e){e.REQUEST_ACTIVATION="amedia-user.activation.request-activation",e.ON_ACTIVATION_COMPLETE="amedia-user.activation.on-activation-complete"}(be||(be={})),y(be.REQUEST_ACTIVATION,(e=>{pe(e.detail.accessFeatures).then((e=>{m(new CustomEvent(be.ON_ACTIVATION_COMPLETE,{detail:{accessFeatures:e}}))}))})),function(e){e.REQUEST_STATE="amedia-user.request-state",e.REQUEST_USER_ATTRIBUTES="amedia-user.request-user-attributes",e.REQUEST_STORAGE_NAMESPACES="amedia-user.request-storage-namespaces",e.UPDATE_STORAGE="amedua-user.update-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"}(Ee||(Ee={}));const _e=(e,t)=>{if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!r.includes(o))return!1;if("function"==typeof e[o]||"function"==typeof t[o]){if(e[o].toString()!==t[o].toString())return!1}else if(!_e(e[o],t[o]))return!1}return!0};function we(e,t){return!!(e&&e.length>0)&&(!(t&&Object.keys(t).length>0)||e.filter((e=>!Object.keys(t).includes(e))).length>0)}class Se{constructor(e,t){this.attributes=e,this.namespaces=t}withAttributes(e){return new Se([...this.attributes||[],...e],this.namespaces)}withStorage(e){return new Se(this.attributes,[...this.namespaces||[],...e])}subscribe(e){let t=this.setupLocalCache();g(Ee.ON_STATE_UPDATED,(n=>{const r=n.detail;Object.keys(t.state).length>0&&_e(t.state,r)||(t=Object.assign(Object.assign({},t),{state:r}),e(t))})),m(new CustomEvent(Ee.REQUEST_STATE)),Array.isArray(this.attributes)&&this.attributes.length>0&&(g(Ee.ON_ATTRIBUTES_UPDATED,(n=>{const r=this.processUserAttributesEvent(n);Object.keys(t.attributes).length>0&&_e(t.attributes,r)||(t=Object.assign(Object.assign({},t),{attributes:r}),e(t))})),m(new CustomEvent(Ee.REQUEST_USER_ATTRIBUTES,{detail:this.attributes}))),Array.isArray(this.namespaces)&&this.namespaces.length>0&&(g(Ee.ON_STORAGE_UPDATED,(n=>{const r=this.processStorageEvent(n);_e(t.storage,r)||(t=Object.assign(Object.assign({},t),{storage:r}),e(t))})),m(new CustomEvent(Ee.REQUEST_STORAGE_NAMESPACES,{detail:this.namespaces})))}fetch(){return new Promise((e=>{this.subscribe((t=>{void 0!==t.state.isLoggedIn&&(!1!==t.state.isLoggedIn&&(we(this.attributes,t.attributes)||we(this.namespaces,t.storage))||e(t))}))}))}processUserAttributesEvent(e){const t=e.detail;return this.attributes.reduce(((e,n)=>(void 0!==t[n]&&(e[n]=t[n]),e)),{})}processStorageEvent(e){const t=e.detail;return this.namespaces&&this.namespaces.reduce(((e,n)=>(void 0!==t[n]&&(e[n]=t[n]),e)),{})}setupLocalCache(){const e={state:{}};return this.attributes&&this.attributes.length>0&&(e.attributes={}),this.namespaces&&this.namespaces.length>0&&(e.storage={}),e}}const Re=Se;var Oe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};const Te="jupiter";function Ce(){return Oe(this,void 0,void 0,(function*(){const e="VSTOKEN",t=o(),n=ce(e);let r=!1;(new Re).withAttributes(["uuid"]).subscribe((({attributes:o,state:i})=>Oe(this,void 0,void 0,(function*(){if(!1===i.isLoggedIn)return void("string"==typeof n&&fe(e));if(!o.uuid||void 0===i.isLoggedIn||r)return;if(r=!0,"string"!=typeof n)return void(yield ge(t));const a=n.split(":"),s=new Date(1e3*parseInt(a[1],10));s.setDate(s.getDate()-1),s.getTime()>Date.now()&&a[3]===o.uuid&&t.includes(a[4])&&a[5]===Te||(yield ge(t))}))))}))}function Ie(){const e="VSTOKEN2",t=o(),n=ce(e);(new Re).fetch().then((({state:{isLoggedIn:r}})=>Oe(this,void 0,void 0,(function*(){if(r){if("string"!=typeof n)return void(yield me(t));const e=n.split(":"),r=new Date(1e3*parseInt(e[1],10));if(r.setMinutes(r.getMinutes()-30),r.getTime()>Date.now()&&t.includes(e[4])&&e[5]===Te)return;yield me(t)}else fe(e)})))).then((()=>{}))}const Ae="haveTriedThirdPartyLoginCheck",Ne=(0,b.Record)({user_name:b.String,tracking_key:b.String});function je(){return e=this,t=void 0,r=function*(){return!(yield T(Ae,b.Boolean))&&(yield C(Ae,!0,36e5),!!(yield fetch(`https://${i()}/api/pluto/v1/sessions/current`,{mode:"cors",credentials:"include"}).then((e=>e.ok?e.json():J(e).then((()=>null)).catch((()=>null)))).then((e=>{if(!e)return null;try{return Ne.check(e)}catch(t){return v(t,{data:e}),null}}))))},new((n=void 0)||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}));var e,t,n,r}var Pe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};const Ue="has-tried-autologin";function ke(){const e=ce(Ue);if(e&&"object"!=typeof e)try{if(Date.now()-parseInt(e,10)<6e4)return!0}catch(e){fe(Ue)}return ue(Ue,Date.now(),Date.now()+6e4),!1}const xe=e=>Pe(void 0,void 0,void 0,(function*(){if(function(){try{return window.self!==window.top}catch(e){return!0}}())return;const{state:{isLoggedIn:n}}=yield(new Re).fetch();if(!n)for(const n of e)if(!(yield n.handler().then((e=>{if(e){if(ke())return!1;const e=new URL(`https://${i()}/aid/logg_inn/auto`);return e.searchParams.set("context",`auto_login_${n.name}`),e.searchParams.set("requestedUrl",t()),le(e.href),!1}return!0}))))return}));var Le=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};const Fe=[()=>Pe(void 0,void 0,void 0,(function*(){return xe([{name:"third_party",handler:je}])})),function(){return Promise.all([Ce(),Ie()])},function(){(new Re).subscribe((({state:e})=>{!1===e.isLoggedIn&&($("userAttributes",{}),$("storage",{}))}))}];var De;!function(e){e.LOADED="amedia-user.janitor.loaded"}(De||(De={}));var Me=n(483),Be=n(808);let $e;const Ve="undefined"==typeof self?window:self,qe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||void 0!==Ve.msCrypto&&"function"==typeof Ve.msCrypto.getRandomValues&&Ve.msCrypto.getRandomValues.bind(Ve.msCrypto);if(qe){const e=new Uint8Array(16);$e=function(){return qe(e),e}}else{const e=new Array(16);$e=function(){for(let t,n=0;n<16;n+=1)0==(3&n)&&(t=4294967296*Math.random()),e[n]=t>>>((3&n)<<3)&255;return e}}const Ge=[];for(let e=0;e<256;++e)Ge[e]=(e+256).toString(16).substr(1);function Ke(){const e=$e();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e,t){let n=0;const r=Ge;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}(e)}Me.config({name:"aid:userdata"});const Ye=self.location.hostname.replace(/(.*\.)([^.]+\.\w+$)/,"$2");function ze(){let e=Be.get("amedia:fpbid");return e||(e=Ke(),Be.set("amedia:fpbid",e,{expires:3650,domain:Ye,sameSite:"strict"})),Promise.resolve(e)}function He(e){return Be.set("amedia:visitid",e,{expires:new Date(Date.now()+18e5),domain:Ye,sameSite:"strict"}),Me.setItem("visitid",e).then((()=>e))}function We(){const e=Date.now();return He(`${Ke()}|${e}`)}function Qe(){return function(){const e=Be.get("amedia:visitid");return e?Promise.resolve(e):Me.getItem("visitid")}().then((e=>e||We())).then((e=>{const[t,n]=e.split("|");return!t||n&&Date.now()-18e5>n?We():He(`${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(...n)=>{t||(e.apply(this,n),t=!0,setTimeout((()=>{t=!1}),400))}}(Qe))));var Je=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};const Xe=3e5,Ze=(0,b.Record)({namespaces:(0,b.Dictionary)(b.Unknown,b.String)}),et=(e,t="GET",n)=>fetch(e,{method:t,body:n&&JSON.stringify(n),headers:{"Content-Type":"application/json",Accept:"application/json"}}),tt=(e,t={ignoreCache:!1})=>Je(void 0,void 0,void 0,(function*(){if(0===e.length)throw new Error("namespaces array cannot be of length 0");return I("europa",Ze,(()=>et(`/api/europa/v1/me/${e.join(",")}`).then((t=>Je(void 0,void 0,void 0,(function*(){const n=yield t.text();return t.ok?JSON.parse(n):(400!==t.status&&v(`Could not get namespaces for: ${e}, status: ${t.status}`,{response:t,body:n}),{namespaces:{}})})))).then((e=>({ttl:Xe,data:e})))),(n=>!t.ignoreCache||0===Object.keys(n.namespaces).filter((t=>!Object.keys(e).includes(t))).length)).then((e=>e.namespaces))}));const nt=(0,b.Record)({allowResearchUsage:b.Boolean,connectWithSurveys:b.Boolean,personalizedAds:b.Boolean,personalizedContent:b.Boolean}),rt=e=>"true"===e||!0===e,ot=(0,b.Dictionary)(b.Unknown,b.String).And((0,b.Partial)({ad_segments:b.String,ad_segments_user:b.String,amedia_employee:b.Boolean,amedia_employee_user:b.Boolean,age:b.Number,age_user:b.Number,birth_year:b.String,birth_year_user:b.String,gender:b.String,gender_user:b.String,grunnkrets:b.String,grunnkrets_user:b.String,postcode:b.String,postcode_user:b.String,shared_account:b.Boolean,shared_account_user:b.Boolean,user_grouping_number:b.String,user_grouping_number_user:b.String})),it=e=>({extraData:e}),at=()=>new Promise((e=>{var t;const n=null===(t=V("state"))||void 0===t?void 0:t.isLoggedIn;!1!==n&&!0!==n?q("state",(({isLoggedIn:t})=>{!1!==t&&!0!==t||e(t)})):e(n)})),st=()=>new Promise((e=>at().then((t=>{t&&e()})))),ct={uuid:ve,name:ve,trackingKey:ve,access:()=>st().then((()=>((e=["newspaper"])=>((e,t)=>I("checkForAccess",N,(()=>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=N.check(e);return{ttl:"granted"===t.access?1e4:0,data:t}}catch(t){throw v(t,{json:e}),t}})))).then((e=>({access:e.access_features}))))(o(),e))())),extraData:()=>Promise.all([ze(),at()]).then((([e,t])=>{var n;return((e,t,n)=>I("getNebulaInfo",ot,(()=>((e,t,n)=>{const r=new URL("https://services.gcloud.api.no/api/nebula/v1/info");return r.searchParams.set("domain",e),r.searchParams.set("browser_id",t),n&&r.searchParams.set("user_key",n),fetch(r.href).then((e=>e.json())).then((e=>{try{return{ttl:18e6,data:ot.check(e)}}catch(t){throw v(t,{json:e}),t}}))})(e,t,n))).then(it))(window.location.hostname,e,t?null===(n=V("userAttributes"))||void 0===n?void 0:n.trackingKey:void 0)})),privacyPreferences:()=>st().then((()=>{return e=void 0,t=void 0,r=function*(){return I("privacyPreferences",nt,(()=>tt(["privacy_preferences"]).then((e=>{const t=e.privacy_preferences;return{ttl:3e5,data:{allowResearchUsage:rt(t.allow_research_usage),connectWithSurveys:rt(t.connect_with_surveys),personalizedAds:rt(t.personalized_ads),personalizedContent:rt(t.personalized_content)}}})))).then((e=>({privacyPreferences:e})))},new((n=void 0)||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}));var e,t,n,r}))};class ut extends Error{constructor(e,t){super(e),this.code=t}}ut.ERROR_RELOADED_NO_ACCESS="RELOADED_NO_ACCESS",ut.ERROR_ENABLING_ACCESS_FAILED="ENABLING_ACCESS_FAILED",ut.ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES="NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES";const ft=ut;var lt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};const dt=class{constructor(){this.requestedAccessFeatures=["newspaper"],this.reload=!1}withAccessFeatures(e){return this.requestedAccessFeatures=e,this}reloadOnAccess(){return this.reload=!0,this}redirectOnAccess(e){return this.requestedUrl=e,this}tryUnlock(){return lt(this,void 0,void 0,(function*(){const{state:{isLoggedIn:e}}=yield(new Re).withAttributes(["name"]).fetch();if(!e)return yield Pe(void 0,void 0,void 0,(function*(){return xe([{name:"paywall",handler:()=>Promise.resolve(!0)}])})),{isLoggedIn:!1,hasAccess:!1,accessFeatures:[]};let n=yield this.setAccessCookiesAndGetAccessFeatures(this.requestedAccessFeatures);if(n.denied){if(n=yield this.activateAccess(this.requestedAccessFeatures),n.denied)return{isLoggedIn:!0,hasAccess:!1,accessFeatures:n.accessFeatures};if(n=yield this.setAccessCookiesAndGetAccessFeatures(this.requestedAccessFeatures),n.denied)throw new ft("New subscription was attached and checked successfully, but internal systems disagree about current newspaper access.",ft.ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES)}if(this.reload||this.requestedUrl){if(r=this.requestedUrl,ce("aid-paywall-reload-performed")===(r||t()))throw new ft("Unlock check already performed.",ft.ERROR_RELOADED_NO_ACCESS);(e=>{const n=new Date;n.setTime(n.getTime()+12e4),ue("aid-paywall-reload-performed",e||t(),n)})(this.requestedUrl),this.reload&&window.location.reload(),this.requestedUrl&&(e=>{window.location.replace(e)})(this.requestedUrl)}var r;return{isLoggedIn:!0,hasAccess:!0,accessFeatures:n.accessFeatures}}))}setAccessCookiesAndGetAccessFeatures(e){return(t=o(),he(void 0,void 0,void 0,(function*(){const e=[];return e.push(ge(t).catch((()=>Promise.resolve({success:!1,accessFeatures:[]})))),e.push(me(t).catch((()=>Promise.resolve({success:!1,accessFeatures:[]})))),Promise.all(e).then((e=>e.reduce(((e,t)=>({success:e.success&&t.success,accessFeatures:e.accessFeatures.concat(t.accessFeatures).filter(((e,t,n)=>n.indexOf(e)===t)).sort()})),{success:!0,accessFeatures:[]})))}))).then((t=>{const n=!ye(t.accessFeatures,e);if(!t.success&&n)throw new ft("Could not set access cookies",ft.ERROR_ENABLING_ACCESS_FAILED);return{denied:n,accessFeatures:t.accessFeatures}}));var t}activateAccess(e){return lt(this,void 0,void 0,(function*(){const t=yield pe(this.requestedAccessFeatures);return{denied:!ye(t,e),accessFeatures:t}}))}},vt=e=>(e=>{const t=new URL(`https://${i()}/aid/logg_inn/${o()}/`);t.searchParams.set("requestedUrl",e instanceof URL?e.href:e),le(t.href)})(e||t()),ht=()=>de(),pt=e=>new Promise((t=>{g(be.ON_ACTIVATION_COMPLETE,(n=>{const r=n.detail.accessFeatures;t({hasAccess:ye(r,e),accessFeatures:r})})),m(new CustomEvent(be.REQUEST_ACTIVATION,{detail:{accessFeatures:e}}))})),yt=e=>{m(new CustomEvent(Ee.UPDATE_STORAGE,{detail:e}))};"undefined"==typeof process&&(y(Ee.REQUEST_STATE,(()=>{const e=V("state");e&&Object.keys(e).length>0&&m(new CustomEvent(Ee.ON_STATE_UPDATED,{detail:e})),q("state",(e=>{m(new CustomEvent(Ee.ON_STATE_UPDATED,{detail:e}))}))})),q("userAttributes",(e=>{m(new CustomEvent(Ee.ON_ATTRIBUTES_UPDATED,{detail:e}))})),y(Ee.REQUEST_USER_ATTRIBUTES,(e=>{const t=e.detail,n=V("userAttributes")||{};Object.keys(n).length>0&&m(new CustomEvent(Ee.ON_ATTRIBUTES_UPDATED,{detail:n}));const r=t.filter((e=>void 0===n[e]));r.length>0&&(e=>{const t=[];e.forEach((e=>{const n=ct[e];n?t.includes(n)||t.push(n):d(`Unknown attribute ${e} was requested`)}));const n=[];t.forEach((e=>{n.push(e().then((e=>{B("userAttributes",e)})).catch((t=>{d(`User attribute call failed (${e.toString()})`,t)})))})),Promise.all(n).then((()=>{}))})(r)})),q("storage",(e=>{m(new CustomEvent(Ee.ON_STORAGE_UPDATED,{detail:e}))})),y(Ee.REQUEST_STORAGE_NAMESPACES,(e=>{st().then((()=>{const t=e.detail,n=V("storage")||{};Object.keys(n).length>0&&m(new CustomEvent(Ee.ON_STORAGE_UPDATED,{detail:n}));const r=t.filter((e=>void 0===n[e]));r.length>0&&tt(r).then((e=>{B("storage",e)}))}))})),y(Ee.UPDATE_STORAGE,(e=>{st().then((()=>{var t;t=e.detail,Object.keys(t).forEach((e=>((e,t)=>Je(void 0,void 0,void 0,(function*(){const n=yield et(`/api/europa/v1/me/${e}`,"PATCH",t);return n.ok?((e,t)=>Je(void 0,void 0,void 0,(function*(){const n=yield T("europa",Ze),r=n?Object.assign(Object.assign({},n),{namespaces:Object.assign(Object.assign({},n.namespaces),{[e]:t})}):{namespaces:{[e]:t}};return C("europa",r,Date.now()+Xe)})))(e,t):(v(`Could not get namespace: ${e}, status: ${n.status}, statusText: ${n.statusText}`,n),{})})))(e,t[e])))}))})),Le(void 0,void 0,void 0,(function*(){let e=!1;y(De.LOADED,(()=>{e||(e=!0,function(){Le(this,void 0,void 0,(function*(){for(const e of Fe)yield e()}))}())})),m(new CustomEvent(De.LOADED))})))})();var o=r.Hr,i=r.vg,a=r.EX,s=r.kS,c=r.Lk,u=r.Hc;export{o as PaywallUnlockRequest,i as UserDataRequest,a as goToLoginPage,s as logout,c as tryActivateSubscriptionAccess,u as updateStorage};
1
+ (()=>{var Es=Object.create;var dt=Object.defineProperty,bs=Object.defineProperties,_s=Object.getOwnPropertyDescriptor,Ss=Object.getOwnPropertyDescriptors,ws=Object.getOwnPropertyNames,mn=Object.getOwnPropertySymbols,Rs=Object.getPrototypeOf,vn=Object.prototype.hasOwnProperty,Cs=Object.prototype.propertyIsEnumerable;var hn=(e,t,r)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ne=(e,t)=>{for(var r in t||(t={}))vn.call(t,r)&&hn(e,r,t[r]);if(mn)for(var r of mn(t))Cs.call(t,r)&&hn(e,r,t[r]);return e},ce=(e,t)=>bs(e,Ss(t)),As=e=>dt(e,"__esModule",{value:!0}),n=(e,t)=>dt(e,"name",{value:t,configurable:!0}),pt=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ts=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ws(t))!vn.call(e,o)&&o!=="default"&&dt(e,o,{get:()=>t[o],enumerable:!(r=_s(t,o))||r.enumerable});return e},we=e=>Ts(As(dt(e!=null?Es(Rs(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var O=(e,t,r)=>new Promise((o,a)=>{var d=g=>{try{m(r.next(g))}catch(S){a(S)}},p=g=>{try{m(r.throw(g))}catch(S){a(S)}},m=g=>g.done?o(g.value):Promise.resolve(g.value).then(d,p);m((r=r.apply(e,t)).next())});var bn=D(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0})});var _r=D(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.Failcode=void 0;Ot.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"}});var ze=D(He=>{"use strict";var Fs=He&&He.__extends||function(){var e=n(function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,a){o.__proto__=a}||function(o,a){for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&(o[d]=a[d])},e(t,r)},"extendStatics");return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function o(){this.constructor=t}n(o,"__"),t.prototype=r===null?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(He,"__esModule",{value:!0});He.ValidationError=void 0;var ks=function(e){Fs(t,e);function t(r){var o=e.call(this,r.message)||this;return o.name="ValidationError",o.code=r.code,r.details!==void 0&&(o.details=r.details),Object.setPrototypeOf(o,t.prototype),o}return n(t,"ValidationError"),t}(Error);He.ValidationError=ks});var It=D(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});var he=n(function(e,t){return function(r){var o=n(function(p){return e?"("+p+")":p},"parenthesize");if(t.has(r))return o("CIRCULAR "+r.tag);t.add(r);try{switch(r.tag){case"unknown":case"never":case"void":case"boolean":case"number":case"bigint":case"string":case"symbol":case"function":return r.tag;case"literal":{var a=r.value;return typeof a=="string"?'"'+a+'"':String(a)}case"array":return""+_n(r)+he(!0,t)(r.element)+"[]";case"dictionary":return"{ [_: "+r.key+"]: "+he(!1,t)(r.value)+" }";case"record":{var d=Object.keys(r.fields);return d.length?"{ "+d.map(function(p){return""+_n(r)+p+js(r,p)+": "+(r.fields[p].tag==="optional"?he(!1,t)(r.fields[p].underlying):he(!1,t)(r.fields[p]))+";"}).join(" ")+" }":"{}"}case"tuple":return"["+r.components.map(he(!1,t)).join(", ")+"]";case"union":return o(""+r.alternatives.map(he(!0,t)).join(" | "));case"intersect":return o(""+r.intersectees.map(he(!0,t)).join(" & "));case"optional":return he(e,t)(r.underlying)+" | undefined";case"constraint":return r.name||he(e,t)(r.underlying);case"instanceof":return r.ctor.name;case"brand":return he(e,t)(r.entity)}}finally{t.delete(r)}throw Error("impossible")}},"show");Sr.default=he(!1,new Set);function js(e,t){var r=e.isPartial,o=e.fields;return r||t!==void 0&&o[t].tag==="optional"?"?":""}n(js,"partialTag");function _n(e){var t=e.isReadonly;return t?"readonly ":""}n(_n,"readonlyTag")});var z=D(M=>{"use strict";var wr=M&&M.__assign||function(){return wr=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},wr.apply(this,arguments)};Object.defineProperty(M,"__esModule",{value:!0});M.FAILURE=M.SUCCESS=M.enumerableKeysOf=M.typeOf=M.hasKey=void 0;var be=_r(),Qe=It();function qs(e,t){return typeof t=="object"&&t!==null&&e in t}n(qs,"hasKey");M.hasKey=qs;var Ms=n(function(e){var t,r,o;return typeof e=="object"?e===null?"null":Array.isArray(e)?"array":((t=e.constructor)===null||t===void 0?void 0:t.name)==="Object"?"object":(o=(r=e.constructor)===null||r===void 0?void 0:r.name)!==null&&o!==void 0?o:typeof e:typeof e},"typeOf");M.typeOf=Ms;var Bs=n(function(e){return typeof e=="object"&&e!==null?Reflect.ownKeys(e).filter(function(t){var r,o;return(o=(r=e.propertyIsEnumerable)===null||r===void 0?void 0:r.call(e,t))!==null&&o!==void 0?o:!0}):[]},"enumerableKeysOf");M.enumerableKeysOf=Bs;function $s(e){return{success:!0,value:e}}n($s,"SUCCESS");M.SUCCESS=$s;M.FAILURE=Object.assign(function(e,t,r){return wr({success:!1,code:e,message:t},r?{details:r}:{})},{TYPE_INCORRECT:function(e,t){var r="Expected "+Qe.default(e)+", but was "+M.typeOf(t);return M.FAILURE(be.Failcode.TYPE_INCORRECT,r)},VALUE_INCORRECT:function(e,t,r){return M.FAILURE(be.Failcode.VALUE_INCORRECT,"Expected "+e+" "+String(t)+", but was "+String(r))},KEY_INCORRECT:function(e,t,r){return M.FAILURE(be.Failcode.KEY_INCORRECT,"Expected "+Qe.default(e)+" key to be "+Qe.default(t)+", but was "+M.typeOf(r))},CONTENT_INCORRECT:function(e,t){var r="Expected "+Qe.default(e)+", but was incompatible";return M.FAILURE(be.Failcode.CONTENT_INCORRECT,r,t)},ARGUMENT_INCORRECT:function(e){return M.FAILURE(be.Failcode.ARGUMENT_INCORRECT,e)},RETURN_INCORRECT:function(e){return M.FAILURE(be.Failcode.RETURN_INCORRECT,e)},CONSTRAINT_FAILED:function(e,t){var r=t?": "+t:"";return M.FAILURE(be.Failcode.CONSTRAINT_FAILED,"Failed constraint check for "+Qe.default(e)+r)},PROPERTY_MISSING:function(e){var t="Expected "+Qe.default(e)+", but was missing";return M.FAILURE(be.Failcode.PROPERTY_MISSING,t)},PROPERTY_PRESENT:function(e){var t="Expected nothing, but was "+M.typeOf(e);return M.FAILURE(be.Failcode.PROPERTY_PRESENT,t)},NOTHING_EXPECTED:function(e){var t="Expected nothing, but was "+M.typeOf(e);return M.FAILURE(be.Failcode.NOTHING_EXPECTED,t)}})});var Sn=D(Oe=>{"use strict";var Vs=Oe&&Oe.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),a,d=[],p;try{for(;(t===void 0||t-- >0)&&!(a=o.next()).done;)d.push(a.value)}catch(m){p={error:m}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(p)throw p.error}}return d},Gs=Oe&&Oe.__spreadArray||function(e,t){for(var r=0,o=t.length,a=e.length;r<o;r++,a++)e[a]=t[r];return e};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.Contract=void 0;var Ys=ze(),Ws=z();function Ks(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length-1,o=e.slice(0,r),a=e[r];return{enforce:function(d){return function(){for(var p=[],m=0;m<arguments.length;m++)p[m]=arguments[m];if(p.length<o.length){var g="Expected "+o.length+" arguments but only received "+p.length,S=Ws.FAILURE.ARGUMENT_INCORRECT(g);throw new Ys.ValidationError(S)}for(var w=0;w<o.length;w++)o[w].check(p[w]);return a.check(d.apply(void 0,Gs([],Vs(p))))}}}}n(Ks,"Contract");Oe.Contract=Ks});var Cn=D(Ie=>{"use strict";var Hs=Ie&&Ie.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),a,d=[],p;try{for(;(t===void 0||t-- >0)&&!(a=o.next()).done;)d.push(a.value)}catch(m){p={error:m}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(p)throw p.error}}return d},zs=Ie&&Ie.__spreadArray||function(e,t){for(var r=0,o=t.length,a=e.length;r<o;r++,a++)e[a]=t[r];return e};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.AsyncContract=void 0;var wn=ze(),Rn=z();function Qs(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length-1,o=e.slice(0,r),a=e[r];return{enforce:function(d){return function(){for(var p=[],m=0;m<arguments.length;m++)p[m]=arguments[m];if(p.length<o.length){var g="Expected "+o.length+" arguments but only received "+p.length,S=Rn.FAILURE.ARGUMENT_INCORRECT(g);throw new wn.ValidationError(S)}for(var w=0;w<o.length;w++)o[w].check(p[w]);var C=d.apply(void 0,zs([],Hs(p)));if(!(C instanceof Promise)){var g="Expected function to return a promise, but instead got "+C,S=Rn.FAILURE.RETURN_INCORRECT(g);throw new wn.ValidationError(S)}return C.then(a.check)}}}}n(Qs,"AsyncContract");Ie.AsyncContract=Qs});var An=D(Ne=>{"use strict";var Js=Ne&&Ne.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Xs=Ne&&Ne.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),a,d=[],p;try{for(;(t===void 0||t-- >0)&&!(a=o.next()).done;)d.push(a.value)}catch(m){p={error:m}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(p)throw p.error}}return d};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.match=void 0;function Zs(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(r){var o,a;try{for(var d=Js(e),p=d.next();!p.done;p=d.next()){var m=Xs(p.value,2),g=m[0],S=m[1];if(g.guard(r))return S(r)}}catch(w){o={error:w}}finally{try{p&&!p.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}throw new Error("No alternatives were matched")}}n(Zs,"match");Ne.match=Zs});var J=D(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.innerValidate=Je.create=void 0;var Pe=Ue(),ea=It(),ta=ze(),ra=z();function na(e,t){return t.check=r,t.assert=r,t._innerValidate=function(C,h){return h.has(C,t)?ra.SUCCESS(C):e(C,h)},t.validate=function(C){return t._innerValidate(C,ia())},t.guard=o,t.Or=a,t.And=d,t.optional=p,t.nullable=m,t.withConstraint=g,t.withGuard=S,t.withBrand=w,t.reflect=t,t.toString=function(){return"Runtype<"+ea.default(t)+">"},t;function r(C){var h=t.validate(C);if(h.success)return h.value;throw new ta.ValidationError(h)}n(r,"check");function o(C){return t.validate(C).success}n(o,"guard");function a(C){return Pe.Union(t,C)}n(a,"Or");function d(C){return Pe.Intersect(t,C)}n(d,"And");function p(){return Pe.Optional(t)}n(p,"optional");function m(){return Pe.Union(t,Pe.Null)}n(m,"nullable");function g(C,h){return Pe.Constraint(t,C,h)}n(g,"withConstraint");function S(C,h){return Pe.Constraint(t,C,h)}n(S,"withGuard");function w(C){return Pe.Brand(C,t)}n(w,"withBrand")}n(na,"create");Je.create=na;function oa(e,t,r){return e._innerValidate(t,r)}n(oa,"innerValidate");Je.innerValidate=oa;function ia(){var e=new WeakMap,t=n(function(o,a){if(!(o===null||typeof o!="object")){var d=e.get(o);e.set(o,d?d.set(a,!0):new WeakMap().set(a,!0))}},"add"),r=n(function(o,a){var d=e.get(o),p=d&&d.get(a)||!1;return t(o,a),p},"has");return{has:r}}n(ia,"VisitedState")});var Pt=D(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.Unknown=void 0;var sa=J(),aa=z(),ua={tag:"unknown"};Nt.Unknown=sa.create(function(e){return aa.SUCCESS(e)},ua)});var Tn=D(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.Never=void 0;var ca=J(),fa=z(),la={tag:"never"};Ut.Never=ca.create(fa.FAILURE.NOTHING_EXPECTED,la)});var On=D(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.Void=void 0;var da=Pt();xt.Void=da.Unknown});var Rr=D(Xe=>{"use strict";var Dt=Xe&&Xe.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Xe,"__esModule",{value:!0});Xe.Union=void 0;var Lt=J(),vt=z();function pa(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n(function(){for(var a=[],d=0;d<arguments.length;d++)a[d]=arguments[d];return function(p){for(var m=0;m<e.length;m++)if(e[m].guard(p))return a[m](p)}},"match"),o={tag:"union",alternatives:e,match:r};return Lt.create(function(a,d){var p,m,g,S,w,C,h,A;if(typeof a!="object"||a===null){try{for(var P=Dt(e),L=P.next();!L.done;L=P.next()){var $=L.value;if(Lt.innerValidate($,a,d).success)return vt.SUCCESS(a)}}catch(re){p={error:re}}finally{try{L&&!L.done&&(m=P.return)&&m.call(P)}finally{if(p)throw p.error}}return vt.FAILURE.TYPE_INCORRECT(o,a)}var G={};try{for(var se=Dt(e),W=se.next();!W.done;W=se.next()){var $=W.value;if($.reflect.tag==="record"){var ct=n(function(X){var ue=$.reflect.fields[X];ue.tag==="literal"&&(G[X]?G[X].every(function(Fe){return Fe!==ue.value})&&G[X].push(ue.value):G[X]=[ue.value])},"_loop_1");for(var ae in $.reflect.fields)ct(ae)}}}catch(re){g={error:re}}finally{try{W&&!W.done&&(S=se.return)&&S.call(se)}finally{if(g)throw g.error}}for(var ae in G)if(G[ae].length===e.length)try{for(var R=(w=void 0,Dt(e)),x=R.next();!x.done;x=R.next()){var $=x.value;if($.reflect.tag==="record"){var N=$.reflect.fields[ae];if(N.tag==="literal"&&vt.hasKey(ae,a)&&a[ae]===N.value)return Lt.innerValidate($,a,d)}}}catch(X){w={error:X}}finally{try{x&&!x.done&&(C=R.return)&&C.call(R)}finally{if(w)throw w.error}}try{for(var F=Dt(e),H=F.next();!H.done;H=F.next()){var oe=H.value;if(Lt.innerValidate(oe,a,d).success)return vt.SUCCESS(a)}}catch(re){h={error:re}}finally{try{H&&!H.done&&(A=F.return)&&A.call(F)}finally{if(h)throw h.error}}return vt.FAILURE.TYPE_INCORRECT(o,a)},o)}n(pa,"Union");Xe.Union=pa});var Pn=D(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.Nullish=de.Null=de.Undefined=de.Literal=void 0;var ma=J(),In=z(),va=Rr();function Nn(e){return Array.isArray(e)?String(e.map(String)):typeof e=="bigint"?String(e)+"n":String(e)}n(Nn,"literal");function Cr(e){var t={tag:"literal",value:e};return ma.create(function(r){return r===e?In.SUCCESS(r):In.FAILURE.VALUE_INCORRECT("literal","`"+Nn(e)+"`","`"+Nn(r)+"`")},t)}n(Cr,"Literal");de.Literal=Cr;de.Undefined=Cr(void 0);de.Null=Cr(null);de.Nullish=va.Union(de.Null,de.Undefined)});var Dn=D(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.Boolean=void 0;var ha=J(),Un=z(),xn={tag:"boolean"};Ft.Boolean=ha.create(function(e){return typeof e=="boolean"?Un.SUCCESS(e):Un.FAILURE.TYPE_INCORRECT(xn,e)},xn)});var kn=D(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.Number=void 0;var ga=J(),Ln=z(),Fn={tag:"number"};kt.Number=ga.create(function(e){return typeof e=="number"?Ln.SUCCESS(e):Ln.FAILURE.TYPE_INCORRECT(Fn,e)},Fn)});var Mn=D(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.BigInt=void 0;var ya=J(),jn=z(),qn={tag:"bigint"};jt.BigInt=ya.create(function(e){return typeof e=="bigint"?jn.SUCCESS(e):jn.FAILURE.TYPE_INCORRECT(qn,e)},qn)});var Ar=D(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.String=void 0;var Ea=J(),Bn=z(),$n={tag:"string"};qt.String=Ea.create(function(e){return typeof e=="string"?Bn.SUCCESS(e):Bn.FAILURE.TYPE_INCORRECT($n,e)},$n)});var Wn=D(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.Symbol=void 0;var Vn=J(),ht=z(),ba=n(function(e){var t={tag:"symbol",key:e};return Vn.create(function(r){if(typeof r!="symbol")return ht.FAILURE.TYPE_INCORRECT(t,r);var o=globalThis.Symbol.keyFor(r);return o!==e?ht.FAILURE.VALUE_INCORRECT("symbol key",Yn(e),Yn(o)):ht.SUCCESS(r)},t)},"f"),Gn={tag:"symbol"};Mt.Symbol=Vn.create(function(e){return typeof e=="symbol"?ht.SUCCESS(e):ht.FAILURE.TYPE_INCORRECT(Gn,e)},Object.assign(ba,Gn));var Yn=n(function(e){return e===void 0?"undefined":'"'+e+'"'},"quoteIfPresent")});var zn=D(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.Array=void 0;var Kn=J(),gt=z();function Hn(e,t){var r={tag:"array",isReadonly:t,element:e};return Sa(Kn.create(function(o,a){if(!Array.isArray(o))return gt.FAILURE.TYPE_INCORRECT(r,o);var d=gt.enumerableKeysOf(o),p=d.map(function(g){return Kn.innerValidate(e,o[g],a)}),m=d.reduce(function(g,S){var w=p[S];return w.success||(g[S]=w.details||w.message),g},[]);return gt.enumerableKeysOf(m).length!==0?gt.FAILURE.CONTENT_INCORRECT(r,m):gt.SUCCESS(o)},r))}n(Hn,"InternalArr");function _a(e){return Hn(e,!1)}n(_a,"Arr");Bt.Array=_a;function Sa(e){return e.asReadonly=t,e;function t(){return Hn(e.element,!0)}n(t,"asReadonly")}n(Sa,"withExtraModifierFuncs")});var Jn=D($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.Tuple=void 0;var Qn=J(),Ze=z();function wa(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"tuple",components:e};return Qn.create(function(o,a){if(!Array.isArray(o))return Ze.FAILURE.TYPE_INCORRECT(r,o);if(o.length!==e.length)return Ze.FAILURE.CONSTRAINT_FAILED(r,"Expected length "+e.length+", but was "+o.length);var d=Ze.enumerableKeysOf(o),p=d.map(function(g){return Qn.innerValidate(e[g],o[g],a)}),m=d.reduce(function(g,S){var w=p[S];return w.success||(g[S]=w.details||w.message),g},[]);return Ze.enumerableKeysOf(m).length!==0?Ze.FAILURE.CONTENT_INCORRECT(r,m):Ze.SUCCESS(o)},r)}n(wa,"Tuple");$t.Tuple=wa});var Zn=D(pe=>{"use strict";var Tr=pe&&pe.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),a,d=[],p;try{for(;(t===void 0||t-- >0)&&!(a=o.next()).done;)d.push(a.value)}catch(m){p={error:m}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(p)throw p.error}}return d},Or=pe&&pe.__spreadArray||function(e,t){for(var r=0,o=t.length,a=e.length;r<o;r++,a++)e[a]=t[r];return e};Object.defineProperty(pe,"__esModule",{value:!0});pe.Partial=pe.Record=pe.InternalRecord=void 0;var Xn=J(),fe=z();function xe(e,t,r){var o={tag:"record",isPartial:t,isReadonly:r,fields:e};return Aa(Xn.create(function(a,d){if(a==null)return fe.FAILURE.TYPE_INCORRECT(o,a);var p=fe.enumerableKeysOf(e);if(p.length!==0&&typeof a!="object")return fe.FAILURE.TYPE_INCORRECT(o,a);var m=Or([],Tr(new Set(Or(Or([],Tr(p)),Tr(fe.enumerableKeysOf(a)))))),g=m.reduce(function(w,C){var h=fe.hasKey(C,e),A=fe.hasKey(C,a);if(h){var P=e[C],L=t||P.reflect.tag==="optional";if(A){var $=a[C];L&&$===void 0?w[C]=fe.SUCCESS($):w[C]=Xn.innerValidate(P,$,d)}else L?w[C]=fe.SUCCESS(void 0):w[C]=fe.FAILURE.PROPERTY_MISSING(P.reflect)}else if(A){var $=a[C];w[C]=fe.SUCCESS($)}else throw new Error("impossible");return w},{}),S=m.reduce(function(w,C){var h=g[C];return h.success||(w[C]=h.details||h.message),w},{});return fe.enumerableKeysOf(S).length!==0?fe.FAILURE.CONTENT_INCORRECT(o,S):fe.SUCCESS(a)},o))}n(xe,"InternalRecord");pe.InternalRecord=xe;function Ra(e){return xe(e,!1,!1)}n(Ra,"Record");pe.Record=Ra;function Ca(e){return xe(e,!0,!1)}n(Ca,"Partial");pe.Partial=Ca;function Aa(e){return e.asPartial=t,e.asReadonly=r,e.pick=o,e.omit=a,e.extend=d,e;function t(){return xe(e.fields,!0,e.isReadonly)}n(t,"asPartial");function r(){return xe(e.fields,e.isPartial,!0)}n(r,"asReadonly");function o(){for(var p=[],m=0;m<arguments.length;m++)p[m]=arguments[m];var g={};return p.forEach(function(S){g[S]=e.fields[S]}),xe(g,e.isPartial,e.isReadonly)}n(o,"pick");function a(){for(var p=[],m=0;m<arguments.length;m++)p[m]=arguments[m];var g={},S=fe.enumerableKeysOf(e.fields);return S.forEach(function(w){p.includes(w)||(g[w]=e.fields[w])}),xe(g,e.isPartial,e.isReadonly)}n(a,"omit");function d(p){return xe(Object.assign({},e.fields,p),e.isPartial,e.isReadonly)}n(d,"extend")}n(Aa,"withExtraModifierFuncs")});var Nr=D(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.Guard=et.Constraint=void 0;var Ta=J(),Ir=z(),Oa=Pt();function Ia(e,t,r){var o=r&&r.name,a=r&&r.args,d={tag:"constraint",underlying:e,constraint:t,name:o,args:a};return Ta.create(function(p){var m=e.validate(p);if(!m.success)return m;var g=t(m.value);return typeof g=="string"?Ir.FAILURE.CONSTRAINT_FAILED(d,g):g?Ir.SUCCESS(m.value):Ir.FAILURE.CONSTRAINT_FAILED(d)},d)}n(Ia,"Constraint");et.Constraint=Ia;var Na=n(function(e,t){return Oa.Unknown.withGuard(e,t)},"Guard");et.Guard=Na});var to=D(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.Dictionary=void 0;var eo=J(),Pr=Ar(),Pa=Nr(),Ua=It(),ke=z(),xa=Pa.Constraint(Pr.String,function(e){return!isNaN(+e)},{name:"number"});function Da(e,t){var r=t===void 0||t==="string"?Pr.String:t==="number"?xa:t,o=Ua.default(r),a={tag:"dictionary",key:o,value:e};return eo.create(function(d,p){if(d==null||typeof d!="object"||Object.getPrototypeOf(d)!==Object.prototype&&(!Array.isArray(d)||o==="string"))return ke.FAILURE.TYPE_INCORRECT(a,d);var m=/^(?:NaN|-?\d+(?:\.\d+)?)$/,g=ke.enumerableKeysOf(d),S=g.reduce(function(C,h){var A=typeof h=="string"&&m.test(h),P=A?globalThis.Number(h):h;return(A?!r.guard(P)&&!r.guard(h):!r.guard(P))?C[h]=ke.FAILURE.KEY_INCORRECT(a,r.reflect,P):C[h]=eo.innerValidate(e,d[h],p),C},{}),w=g.reduce(function(C,h){var A=S[h];return A.success||(C[h]=A.details||A.message),C},{});return ke.enumerableKeysOf(w).length!==0?ke.FAILURE.CONTENT_INCORRECT(a,w):ke.SUCCESS(d)},a)}n(Da,"Dictionary");Vt.Dictionary=Da});var no=D(tt=>{"use strict";var La=tt&&tt.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(tt,"__esModule",{value:!0});tt.Intersect=void 0;var ro=J(),Fa=z();function ka(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"intersect",intersectees:e};return ro.create(function(o,a){var d,p;try{for(var m=La(e),g=m.next();!g.done;g=m.next()){var S=g.value,w=ro.innerValidate(S,o,a);if(!w.success)return w}}catch(C){d={error:C}}finally{try{g&&!g.done&&(p=m.return)&&p.call(m)}finally{if(d)throw d.error}}return Fa.SUCCESS(o)},r)}n(ka,"Intersect");tt.Intersect=ka});var oo=D(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Optional=void 0;var ja=J(),qa=z();function Ma(e){var t={tag:"optional",underlying:e};return ja.create(function(r){return r===void 0?qa.SUCCESS(r):e.validate(r)},t)}n(Ma,"Optional");Gt.Optional=Ma});var ao=D(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.Function=void 0;var Ba=J(),io=z(),so={tag:"function"};Yt.Function=Ba.create(function(e){return typeof e=="function"?io.SUCCESS(e):io.FAILURE.TYPE_INCORRECT(so,e)},so)});var co=D(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.InstanceOf=void 0;var $a=J(),uo=z();function Va(e){var t={tag:"instanceof",ctor:e};return $a.create(function(r){return r instanceof e?uo.SUCCESS(r):uo.FAILURE.TYPE_INCORRECT(t,r)},t)}n(Va,"InstanceOf");Wt.InstanceOf=Va});var fo=D(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.Lazy=void 0;var Ga=J();function Ya(e){var t={get tag(){return o().tag}},r;function o(){if(!r){r=e();for(var a in r)a!=="tag"&&(t[a]=r[a])}return r}return n(o,"getWrapped"),Ga.create(function(a){return o().validate(a)},t)}n(Ya,"Lazy");Kt.Lazy=Ya});var lo=D(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.Brand=void 0;var Wa=J();function Ka(e,t){var r={tag:"brand",brand:e,entity:t};return Wa.create(function(o){return t.validate(o)},r)}n(Ka,"Brand");Ht.Brand=Ka});var po=D(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.checked=rt.check=void 0;var Ha=ze(),za=z(),Ur=new WeakMap;function Qa(e,t,r){var o=Ur.get(e)||new Map;Ur.set(e,o);var a=o.get(t)||[];o.set(t,a),a.push(r)}n(Qa,"check");rt.check=Qa;function Ja(e,t,r){var o=Ur.get(e),a=o&&o.get(t);if(a)return a;for(var d=[],p=0;p<r;p++)d.push(p);return d}n(Ja,"getValidParameterIndices");function Xa(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(e.length===0)throw new Error("No runtype provided to `@checked`. Please remove the decorator.");return function(r,o,a){var d=a.value,p=(r.name||r.constructor.name+".prototype")+(typeof o=="string"?'["'+o+'"]':"["+String(o)+"]"),m=Ja(r,o,e.length);if(m.length!==e.length)throw new Error("Number of `@checked` runtypes and @check parameters not matched.");if(m.length>d.length)throw new Error("Number of `@checked` runtypes exceeds actual parameter length.");a.value=function(){for(var g=[],S=0;S<arguments.length;S++)g[S]=arguments[S];return e.forEach(function(w,C){var h=m[C],A=w.validate(g[h]);if(!A.success){var P=p+", argument #"+h+": "+A.message,L=za.FAILURE.ARGUMENT_INCORRECT(P);throw new Ha.ValidationError(L)}}),d.apply(this,g)}}}n(Xa,"checked");rt.checked=Xa});var Ue=D(I=>{"use strict";var Za=I&&I.__createBinding||(Object.create?function(e,t,r,o){o===void 0&&(o=r),Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,o){o===void 0&&(o=r),e[o]=t[r]}),Y=I&&I.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Za(t,e,r)};Object.defineProperty(I,"__esModule",{value:!0});I.InstanceOf=I.Nullish=I.Null=I.Undefined=I.Literal=void 0;Y(bn(),I);Y(_r(),I);Y(Sn(),I);Y(Cn(),I);Y(An(),I);Y(ze(),I);Y(Pt(),I);Y(Tn(),I);Y(On(),I);var zt=Pn();Object.defineProperty(I,"Literal",{enumerable:!0,get:function(){return zt.Literal}});Object.defineProperty(I,"Undefined",{enumerable:!0,get:function(){return zt.Undefined}});Object.defineProperty(I,"Null",{enumerable:!0,get:function(){return zt.Null}});Object.defineProperty(I,"Nullish",{enumerable:!0,get:function(){return zt.Nullish}});Y(Dn(),I);Y(kn(),I);Y(Mn(),I);Y(Ar(),I);Y(Wn(),I);Y(zn(),I);Y(Jn(),I);Y(Zn(),I);Y(to(),I);Y(Rr(),I);Y(no(),I);Y(oo(),I);Y(ao(),I);var eu=co();Object.defineProperty(I,"InstanceOf",{enumerable:!0,get:function(){return eu.InstanceOf}});Y(fo(),I);Y(Nr(),I);Y(lo(),I);Y(po(),I)});var So=D(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});var bo=n(function(e){if(typeof e=="object"&&e!==null){if(typeof Object.getPrototypeOf=="function"){var t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}return Object.prototype.toString.call(e)==="[object Object]"}return!1},"isObject"),_o=n(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce(function(r,o){return Object.keys(o).forEach(function(a){Array.isArray(r[a])&&Array.isArray(o[a])?r[a]=Array.from(new Set(r[a].concat(o[a]))):bo(r[a])&&bo(o[a])?r[a]=_o(r[a],o[a]):r[a]=o[a]}),r},{})},"merge");Lr.default=_o});var Jo=D((Qo,Br)=>{(function(e){if(typeof Qo=="object"&&typeof Br!="undefined")Br.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return n(function o(a,d,p){function m(w,C){if(!d[w]){if(!a[w]){var h=typeof pt=="function"&&pt;if(!C&&h)return h(w,!0);if(g)return g(w,!0);var A=new Error("Cannot find module '"+w+"'");throw A.code="MODULE_NOT_FOUND",A}var P=d[w]={exports:{}};a[w][0].call(P.exports,function(L){var $=a[w][1][L];return m($||L)},P,P.exports,o,a,d,p)}return d[w].exports}n(m,"s");for(var g=typeof pt=="function"&&pt,S=0;S<p.length;S++)m(p[S]);return m},"e")({1:[function(o,a,d){(function(p){"use strict";var m=p.MutationObserver||p.WebKitMutationObserver,g;if(m){var S=0,w=new m(L),C=p.document.createTextNode("");w.observe(C,{characterData:!0}),g=n(function(){C.data=S=++S%2},"scheduleDrain")}else if(!p.setImmediate&&typeof p.MessageChannel!="undefined"){var h=new p.MessageChannel;h.port1.onmessage=L,g=n(function(){h.port2.postMessage(0)},"scheduleDrain")}else"document"in p&&"onreadystatechange"in p.document.createElement("script")?g=n(function(){var G=p.document.createElement("script");G.onreadystatechange=function(){L(),G.onreadystatechange=null,G.parentNode.removeChild(G),G=null},p.document.documentElement.appendChild(G)},"scheduleDrain"):g=n(function(){setTimeout(L,0)},"scheduleDrain");var A,P=[];function L(){A=!0;for(var G,se,W=P.length;W;){for(se=P,P=[],G=-1;++G<W;)se[G]();W=P.length}A=!1}n(L,"nextTick"),a.exports=$;function $(G){P.push(G)===1&&!A&&g()}n($,"immediate")}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(o,a,d){"use strict";var p=o(1);function m(){}n(m,"INTERNAL");var g={},S=["REJECTED"],w=["FULFILLED"],C=["PENDING"];a.exports=h;function h(R){if(typeof R!="function")throw new TypeError("resolver must be a function");this.state=C,this.queue=[],this.outcome=void 0,R!==m&&$(this,R)}n(h,"Promise"),h.prototype.catch=function(R){return this.then(null,R)},h.prototype.then=function(R,x){if(typeof R!="function"&&this.state===w||typeof x!="function"&&this.state===S)return this;var N=new this.constructor(m);if(this.state!==C){var F=this.state===w?R:x;P(N,F,this.outcome)}else this.queue.push(new A(N,R,x));return N};function A(R,x,N){this.promise=R,typeof x=="function"&&(this.onFulfilled=x,this.callFulfilled=this.otherCallFulfilled),typeof N=="function"&&(this.onRejected=N,this.callRejected=this.otherCallRejected)}n(A,"QueueItem"),A.prototype.callFulfilled=function(R){g.resolve(this.promise,R)},A.prototype.otherCallFulfilled=function(R){P(this.promise,this.onFulfilled,R)},A.prototype.callRejected=function(R){g.reject(this.promise,R)},A.prototype.otherCallRejected=function(R){P(this.promise,this.onRejected,R)};function P(R,x,N){p(function(){var F;try{F=x(N)}catch(H){return g.reject(R,H)}F===R?g.reject(R,new TypeError("Cannot resolve promise with itself")):g.resolve(R,F)})}n(P,"unwrap"),g.resolve=function(R,x){var N=G(L,x);if(N.status==="error")return g.reject(R,N.value);var F=N.value;if(F)$(R,F);else{R.state=w,R.outcome=x;for(var H=-1,oe=R.queue.length;++H<oe;)R.queue[H].callFulfilled(x)}return R},g.reject=function(R,x){R.state=S,R.outcome=x;for(var N=-1,F=R.queue.length;++N<F;)R.queue[N].callRejected(x);return R};function L(R){var x=R&&R.then;if(R&&(typeof R=="object"||typeof R=="function")&&typeof x=="function")return n(function(){x.apply(R,arguments)},"appyThen")}n(L,"getThen");function $(R,x){var N=!1;function F(X){N||(N=!0,g.reject(R,X))}n(F,"onError");function H(X){N||(N=!0,g.resolve(R,X))}n(H,"onSuccess");function oe(){x(H,F)}n(oe,"tryToUnwrap");var re=G(oe);re.status==="error"&&F(re.value)}n($,"safelyResolveThenable");function G(R,x){var N={};try{N.value=R(x),N.status="success"}catch(F){N.status="error",N.value=F}return N}n(G,"tryCatch"),h.resolve=se;function se(R){return R instanceof this?R:g.resolve(new this(m),R)}n(se,"resolve"),h.reject=W;function W(R){var x=new this(m);return g.reject(x,R)}n(W,"reject"),h.all=ct;function ct(R){var x=this;if(Object.prototype.toString.call(R)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=R.length,F=!1;if(!N)return this.resolve([]);for(var H=new Array(N),oe=0,re=-1,X=new this(m);++re<N;)ue(R[re],re);return X;function ue(Fe,wt){x.resolve(Fe).then(fr,function(Ge){F||(F=!0,g.reject(X,Ge))});function fr(Ge){H[wt]=Ge,++oe===N&&!F&&(F=!0,g.resolve(X,H))}n(fr,"resolveFromAll")}}n(ct,"all"),h.race=ae;function ae(R){var x=this;if(Object.prototype.toString.call(R)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=R.length,F=!1;if(!N)return this.resolve([]);for(var H=-1,oe=new this(m);++H<N;)re(R[H]);return oe;function re(X){x.resolve(X).then(function(ue){F||(F=!0,g.resolve(oe,ue))},function(ue){F||(F=!0,g.reject(oe,ue))})}}n(ae,"race")},{"1":1}],3:[function(o,a,d){(function(p){"use strict";typeof p.Promise!="function"&&(p.Promise=o(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"2":2}],4:[function(o,a,d){"use strict";var p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i};function m(i,u){if(!(i instanceof u))throw new TypeError("Cannot call a class as a function")}n(m,"_classCallCheck");function g(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(i){return}}n(g,"getIDB");var S=g();function w(){try{if(!S||!S.open)return!1;var i=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),u=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!i||u)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(s){return!1}}n(w,"isIndexedDBValid");function C(i,u){i=i||[],u=u||{};try{return new Blob(i,u)}catch(c){if(c.name!=="TypeError")throw c;for(var s=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,f=new s,l=0;l<i.length;l+=1)f.append(i[l]);return f.getBlob(u.type)}}n(C,"createBlob"),typeof Promise=="undefined"&&o(3);var h=Promise;function A(i,u){u&&i.then(function(s){u(null,s)},function(s){u(s)})}n(A,"executeCallback");function P(i,u,s){typeof u=="function"&&i.then(u),typeof s=="function"&&i.catch(s)}n(P,"executeTwoCallbacks");function L(i){return typeof i!="string"&&(console.warn(i+" used as a key, but it is not a string."),i=String(i)),i}n(L,"normalizeKey");function $(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}n($,"getCallback");var G="local-forage-detect-blob-support",se=void 0,W={},ct=Object.prototype.toString,ae="readonly",R="readwrite";function x(i){for(var u=i.length,s=new ArrayBuffer(u),f=new Uint8Array(s),l=0;l<u;l++)f[l]=i.charCodeAt(l);return s}n(x,"_binStringToArrayBuffer");function N(i){return new h(function(u){var s=i.transaction(G,R),f=C([""]);s.objectStore(G).put(f,"key"),s.onabort=function(l){l.preventDefault(),l.stopPropagation(),u(!1)},s.oncomplete=function(){var l=navigator.userAgent.match(/Chrome\/(\d+)/),c=navigator.userAgent.match(/Edge\//);u(c||!l||parseInt(l[1],10)>=43)}}).catch(function(){return!1})}n(N,"_checkBlobSupportWithoutCaching");function F(i){return typeof se=="boolean"?h.resolve(se):N(i).then(function(u){return se=u,se})}n(F,"_checkBlobSupport");function H(i){var u=W[i.name],s={};s.promise=new h(function(f,l){s.resolve=f,s.reject=l}),u.deferredOperations.push(s),u.dbReady?u.dbReady=u.dbReady.then(function(){return s.promise}):u.dbReady=s.promise}n(H,"_deferReadiness");function oe(i){var u=W[i.name],s=u.deferredOperations.pop();if(s)return s.resolve(),s.promise}n(oe,"_advanceReadiness");function re(i,u){var s=W[i.name],f=s.deferredOperations.pop();if(f)return f.reject(u),f.promise}n(re,"_rejectReadiness");function X(i,u){return new h(function(s,f){if(W[i.name]=W[i.name]||Kr(),i.db)if(u)H(i),i.db.close();else return s(i.db);var l=[i.name];u&&l.push(i.version);var c=S.open.apply(S,l);u&&(c.onupgradeneeded=function(v){var y=c.result;try{y.createObjectStore(i.storeName),v.oldVersion<=1&&y.createObjectStore(G)}catch(E){if(E.name==="ConstraintError")console.warn('The database "'+i.name+'" has been upgraded from version '+v.oldVersion+" to version "+v.newVersion+', but the storage "'+i.storeName+'" already exists.');else throw E}}),c.onerror=function(v){v.preventDefault(),f(c.error)},c.onsuccess=function(){s(c.result),oe(i)}})}n(X,"_getConnection");function ue(i){return X(i,!1)}n(ue,"_getOriginalConnection");function Fe(i){return X(i,!0)}n(Fe,"_getUpgradedConnection");function wt(i,u){if(!i.db)return!0;var s=!i.db.objectStoreNames.contains(i.storeName),f=i.version<i.db.version,l=i.version>i.db.version;if(f&&(i.version!==u&&console.warn('The database "'+i.name+`" can't be downgraded from version `+i.db.version+" to version "+i.version+"."),i.version=i.db.version),l||s){if(s){var c=i.db.version+1;c>i.version&&(i.version=c)}return!0}return!1}n(wt,"_isUpgradeNeeded");function fr(i){return new h(function(u,s){var f=new FileReader;f.onerror=s,f.onloadend=function(l){var c=btoa(l.target.result||"");u({__local_forage_encoded_blob:!0,data:c,type:i.type})},f.readAsBinaryString(i)})}n(fr,"_encodeBlob");function Ge(i){var u=x(atob(i.data));return C([u],{type:i.type})}n(Ge,"_decodeBlob");function Wr(i){return i&&i.__local_forage_encoded_blob}n(Wr,"_isEncodedBlob");function bi(i){var u=this,s=u._initReady().then(function(){var f=W[u._dbInfo.name];if(f&&f.dbReady)return f.dbReady});return P(s,i,i),s}n(bi,"_fullyReady");function _i(i){H(i);for(var u=W[i.name],s=u.forages,f=0;f<s.length;f++){var l=s[f];l._dbInfo.db&&(l._dbInfo.db.close(),l._dbInfo.db=null)}return i.db=null,ue(i).then(function(c){return i.db=c,wt(i)?Fe(i):c}).then(function(c){i.db=u.db=c;for(var v=0;v<s.length;v++)s[v]._dbInfo.db=c}).catch(function(c){throw re(i,c),c})}n(_i,"_tryReconnect");function Se(i,u,s,f){f===void 0&&(f=1);try{var l=i.db.transaction(i.storeName,u);s(null,l)}catch(c){if(f>0&&(!i.db||c.name==="InvalidStateError"||c.name==="NotFoundError"))return h.resolve().then(function(){if(!i.db||c.name==="NotFoundError"&&!i.db.objectStoreNames.contains(i.storeName)&&i.version<=i.db.version)return i.db&&(i.version=i.db.version+1),Fe(i)}).then(function(){return _i(i).then(function(){Se(i,u,s,f-1)})}).catch(s);s(c)}}n(Se,"createTransaction");function Kr(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}n(Kr,"createDbContext");function Si(i){var u=this,s={db:null};if(i)for(var f in i)s[f]=i[f];var l=W[s.name];l||(l=Kr(),W[s.name]=l),l.forages.push(u),u._initReady||(u._initReady=u.ready,u.ready=bi);var c=[];function v(){return h.resolve()}n(v,"ignoreErrors");for(var y=0;y<l.forages.length;y++){var E=l.forages[y];E!==u&&c.push(E._initReady().catch(v))}var b=l.forages.slice(0);return h.all(c).then(function(){return s.db=l.db,ue(s)}).then(function(_){return s.db=_,wt(s,u._defaultConfig.version)?Fe(s):_}).then(function(_){s.db=l.db=_,u._dbInfo=s;for(var T=0;T<b.length;T++){var U=b[T];U!==u&&(U._dbInfo.db=s.db,U._dbInfo.version=s.version)}})}n(Si,"_initStorage");function wi(i,u){var s=this;i=L(i);var f=new h(function(l,c){s.ready().then(function(){Se(s._dbInfo,ae,function(v,y){if(v)return c(v);try{var E=y.objectStore(s._dbInfo.storeName),b=E.get(i);b.onsuccess=function(){var _=b.result;_===void 0&&(_=null),Wr(_)&&(_=Ge(_)),l(_)},b.onerror=function(){c(b.error)}}catch(_){c(_)}})}).catch(c)});return A(f,u),f}n(wi,"getItem");function Ri(i,u){var s=this,f=new h(function(l,c){s.ready().then(function(){Se(s._dbInfo,ae,function(v,y){if(v)return c(v);try{var E=y.objectStore(s._dbInfo.storeName),b=E.openCursor(),_=1;b.onsuccess=function(){var T=b.result;if(T){var U=T.value;Wr(U)&&(U=Ge(U));var k=i(U,T.key,_++);k!==void 0?l(k):T.continue()}else l()},b.onerror=function(){c(b.error)}}catch(T){c(T)}})}).catch(c)});return A(f,u),f}n(Ri,"iterate");function Ci(i,u,s){var f=this;i=L(i);var l=new h(function(c,v){var y;f.ready().then(function(){return y=f._dbInfo,ct.call(u)==="[object Blob]"?F(y.db).then(function(E){return E?u:fr(u)}):u}).then(function(E){Se(f._dbInfo,R,function(b,_){if(b)return v(b);try{var T=_.objectStore(f._dbInfo.storeName);E===null&&(E=void 0);var U=T.put(E,i);_.oncomplete=function(){E===void 0&&(E=null),c(E)},_.onabort=_.onerror=function(){var k=U.error?U.error:U.transaction.error;v(k)}}catch(k){v(k)}})}).catch(v)});return A(l,s),l}n(Ci,"setItem");function Ai(i,u){var s=this;i=L(i);var f=new h(function(l,c){s.ready().then(function(){Se(s._dbInfo,R,function(v,y){if(v)return c(v);try{var E=y.objectStore(s._dbInfo.storeName),b=E.delete(i);y.oncomplete=function(){l()},y.onerror=function(){c(b.error)},y.onabort=function(){var _=b.error?b.error:b.transaction.error;c(_)}}catch(_){c(_)}})}).catch(c)});return A(f,u),f}n(Ai,"removeItem");function Ti(i){var u=this,s=new h(function(f,l){u.ready().then(function(){Se(u._dbInfo,R,function(c,v){if(c)return l(c);try{var y=v.objectStore(u._dbInfo.storeName),E=y.clear();v.oncomplete=function(){f()},v.onabort=v.onerror=function(){var b=E.error?E.error:E.transaction.error;l(b)}}catch(b){l(b)}})}).catch(l)});return A(s,i),s}n(Ti,"clear");function Oi(i){var u=this,s=new h(function(f,l){u.ready().then(function(){Se(u._dbInfo,ae,function(c,v){if(c)return l(c);try{var y=v.objectStore(u._dbInfo.storeName),E=y.count();E.onsuccess=function(){f(E.result)},E.onerror=function(){l(E.error)}}catch(b){l(b)}})}).catch(l)});return A(s,i),s}n(Oi,"length");function Ii(i,u){var s=this,f=new h(function(l,c){if(i<0){l(null);return}s.ready().then(function(){Se(s._dbInfo,ae,function(v,y){if(v)return c(v);try{var E=y.objectStore(s._dbInfo.storeName),b=!1,_=E.openKeyCursor();_.onsuccess=function(){var T=_.result;if(!T){l(null);return}i===0||b?l(T.key):(b=!0,T.advance(i))},_.onerror=function(){c(_.error)}}catch(T){c(T)}})}).catch(c)});return A(f,u),f}n(Ii,"key");function Ni(i){var u=this,s=new h(function(f,l){u.ready().then(function(){Se(u._dbInfo,ae,function(c,v){if(c)return l(c);try{var y=v.objectStore(u._dbInfo.storeName),E=y.openKeyCursor(),b=[];E.onsuccess=function(){var _=E.result;if(!_){f(b);return}b.push(_.key),_.continue()},E.onerror=function(){l(E.error)}}catch(_){l(_)}})}).catch(l)});return A(s,i),s}n(Ni,"keys");function Pi(i,u){u=$.apply(this,arguments);var s=this.config();i=typeof i!="function"&&i||{},i.name||(i.name=i.name||s.name,i.storeName=i.storeName||s.storeName);var f=this,l;if(!i.name)l=h.reject("Invalid arguments");else{var c=i.name===s.name&&f._dbInfo.db,v=c?h.resolve(f._dbInfo.db):ue(i).then(function(y){var E=W[i.name],b=E.forages;E.db=y;for(var _=0;_<b.length;_++)b[_]._dbInfo.db=y;return y});i.storeName?l=v.then(function(y){if(!!y.objectStoreNames.contains(i.storeName)){var E=y.version+1;H(i);var b=W[i.name],_=b.forages;y.close();for(var T=0;T<_.length;T++){var U=_[T];U._dbInfo.db=null,U._dbInfo.version=E}var k=new h(function(q,te){var Z=S.open(i.name,E);Z.onerror=function(ie){var lt=Z.result;lt.close(),te(ie)},Z.onupgradeneeded=function(){var ie=Z.result;ie.deleteObjectStore(i.storeName)},Z.onsuccess=function(){var ie=Z.result;ie.close(),q(ie)}});return k.then(function(q){b.db=q;for(var te=0;te<_.length;te++){var Z=_[te];Z._dbInfo.db=q,oe(Z._dbInfo)}}).catch(function(q){throw(re(i,q)||h.resolve()).catch(function(){}),q})}}):l=v.then(function(y){H(i);var E=W[i.name],b=E.forages;y.close();for(var _=0;_<b.length;_++){var T=b[_];T._dbInfo.db=null}var U=new h(function(k,q){var te=S.deleteDatabase(i.name);te.onerror=te.onblocked=function(Z){var ie=te.result;ie&&ie.close(),q(Z)},te.onsuccess=function(){var Z=te.result;Z&&Z.close(),k(Z)}});return U.then(function(k){E.db=k;for(var q=0;q<b.length;q++){var te=b[q];oe(te._dbInfo)}}).catch(function(k){throw(re(i,k)||h.resolve()).catch(function(){}),k})})}return A(l,u),l}n(Pi,"dropInstance");var Ui={_driver:"asyncStorage",_initStorage:Si,_support:w(),iterate:Ri,getItem:wi,setItem:Ci,removeItem:Ai,clear:Ti,length:Oi,key:Ii,keys:Ni,dropInstance:Pi};function xi(){return typeof openDatabase=="function"}n(xi,"isWebSQLValid");var Ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Di="~~local_forage_type~",Hr=/^~~local_forage_type~([^~]+)~/,Rt="__lfsc__:",lr=Rt.length,dr="arbf",pr="blob",zr="si08",Qr="ui08",Jr="uic8",Xr="si16",Zr="si32",en="ur16",tn="ui32",rn="fl32",nn="fl64",on=lr+dr.length,sn=Object.prototype.toString;function an(i){var u=i.length*.75,s=i.length,f,l=0,c,v,y,E;i[i.length-1]==="="&&(u--,i[i.length-2]==="="&&u--);var b=new ArrayBuffer(u),_=new Uint8Array(b);for(f=0;f<s;f+=4)c=Ae.indexOf(i[f]),v=Ae.indexOf(i[f+1]),y=Ae.indexOf(i[f+2]),E=Ae.indexOf(i[f+3]),_[l++]=c<<2|v>>4,_[l++]=(v&15)<<4|y>>2,_[l++]=(y&3)<<6|E&63;return b}n(an,"stringToBuffer");function mr(i){var u=new Uint8Array(i),s="",f;for(f=0;f<u.length;f+=3)s+=Ae[u[f]>>2],s+=Ae[(u[f]&3)<<4|u[f+1]>>4],s+=Ae[(u[f+1]&15)<<2|u[f+2]>>6],s+=Ae[u[f+2]&63];return u.length%3==2?s=s.substring(0,s.length-1)+"=":u.length%3==1&&(s=s.substring(0,s.length-2)+"=="),s}n(mr,"bufferToString");function Li(i,u){var s="";if(i&&(s=sn.call(i)),i&&(s==="[object ArrayBuffer]"||i.buffer&&sn.call(i.buffer)==="[object ArrayBuffer]")){var f,l=Rt;i instanceof ArrayBuffer?(f=i,l+=dr):(f=i.buffer,s==="[object Int8Array]"?l+=zr:s==="[object Uint8Array]"?l+=Qr:s==="[object Uint8ClampedArray]"?l+=Jr:s==="[object Int16Array]"?l+=Xr:s==="[object Uint16Array]"?l+=en:s==="[object Int32Array]"?l+=Zr:s==="[object Uint32Array]"?l+=tn:s==="[object Float32Array]"?l+=rn:s==="[object Float64Array]"?l+=nn:u(new Error("Failed to get type for BinaryArray"))),u(l+mr(f))}else if(s==="[object Blob]"){var c=new FileReader;c.onload=function(){var v=Di+i.type+"~"+mr(this.result);u(Rt+pr+v)},c.readAsArrayBuffer(i)}else try{u(JSON.stringify(i))}catch(v){console.error("Couldn't convert value into a JSON string: ",i),u(null,v)}}n(Li,"serialize");function Fi(i){if(i.substring(0,lr)!==Rt)return JSON.parse(i);var u=i.substring(on),s=i.substring(lr,on),f;if(s===pr&&Hr.test(u)){var l=u.match(Hr);f=l[1],u=u.substring(l[0].length)}var c=an(u);switch(s){case dr:return c;case pr:return C([c],{type:f});case zr:return new Int8Array(c);case Qr:return new Uint8Array(c);case Jr:return new Uint8ClampedArray(c);case Xr:return new Int16Array(c);case en:return new Uint16Array(c);case Zr:return new Int32Array(c);case tn:return new Uint32Array(c);case rn:return new Float32Array(c);case nn:return new Float64Array(c);default:throw new Error("Unkown type: "+s)}}n(Fi,"deserialize");var vr={serialize:Li,deserialize:Fi,stringToBuffer:an,bufferToString:mr};function un(i,u,s,f){i.executeSql("CREATE TABLE IF NOT EXISTS "+u.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],s,f)}n(un,"createDbTable");function ki(i){var u=this,s={db:null};if(i)for(var f in i)s[f]=typeof i[f]!="string"?i[f].toString():i[f];var l=new h(function(c,v){try{s.db=openDatabase(s.name,String(s.version),s.description,s.size)}catch(y){return v(y)}s.db.transaction(function(y){un(y,s,function(){u._dbInfo=s,c()},function(E,b){v(b)})},v)});return s.serializer=vr,l}n(ki,"_initStorage$1");function Te(i,u,s,f,l,c){i.executeSql(s,f,l,function(v,y){y.code===y.SYNTAX_ERR?v.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[u.storeName],function(E,b){b.rows.length?c(E,y):un(E,u,function(){E.executeSql(s,f,l,c)},c)},c):c(v,y)},c)}n(Te,"tryExecuteSql");function ji(i,u){var s=this;i=L(i);var f=new h(function(l,c){s.ready().then(function(){var v=s._dbInfo;v.db.transaction(function(y){Te(y,v,"SELECT * FROM "+v.storeName+" WHERE key = ? LIMIT 1",[i],function(E,b){var _=b.rows.length?b.rows.item(0).value:null;_&&(_=v.serializer.deserialize(_)),l(_)},function(E,b){c(b)})})}).catch(c)});return A(f,u),f}n(ji,"getItem$1");function qi(i,u){var s=this,f=new h(function(l,c){s.ready().then(function(){var v=s._dbInfo;v.db.transaction(function(y){Te(y,v,"SELECT * FROM "+v.storeName,[],function(E,b){for(var _=b.rows,T=_.length,U=0;U<T;U++){var k=_.item(U),q=k.value;if(q&&(q=v.serializer.deserialize(q)),q=i(q,k.key,U+1),q!==void 0){l(q);return}}l()},function(E,b){c(b)})})}).catch(c)});return A(f,u),f}n(qi,"iterate$1");function cn(i,u,s,f){var l=this;i=L(i);var c=new h(function(v,y){l.ready().then(function(){u===void 0&&(u=null);var E=u,b=l._dbInfo;b.serializer.serialize(u,function(_,T){T?y(T):b.db.transaction(function(U){Te(U,b,"INSERT OR REPLACE INTO "+b.storeName+" (key, value) VALUES (?, ?)",[i,_],function(){v(E)},function(k,q){y(q)})},function(U){if(U.code===U.QUOTA_ERR){if(f>0){v(cn.apply(l,[i,E,s,f-1]));return}y(U)}})})}).catch(y)});return A(c,s),c}n(cn,"_setItem");function Mi(i,u,s){return cn.apply(this,[i,u,s,1])}n(Mi,"setItem$1");function Bi(i,u){var s=this;i=L(i);var f=new h(function(l,c){s.ready().then(function(){var v=s._dbInfo;v.db.transaction(function(y){Te(y,v,"DELETE FROM "+v.storeName+" WHERE key = ?",[i],function(){l()},function(E,b){c(b)})})}).catch(c)});return A(f,u),f}n(Bi,"removeItem$1");function $i(i){var u=this,s=new h(function(f,l){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(v){Te(v,c,"DELETE FROM "+c.storeName,[],function(){f()},function(y,E){l(E)})})}).catch(l)});return A(s,i),s}n($i,"clear$1");function Vi(i){var u=this,s=new h(function(f,l){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(v){Te(v,c,"SELECT COUNT(key) as c FROM "+c.storeName,[],function(y,E){var b=E.rows.item(0).c;f(b)},function(y,E){l(E)})})}).catch(l)});return A(s,i),s}n(Vi,"length$1");function Gi(i,u){var s=this,f=new h(function(l,c){s.ready().then(function(){var v=s._dbInfo;v.db.transaction(function(y){Te(y,v,"SELECT key FROM "+v.storeName+" WHERE id = ? LIMIT 1",[i+1],function(E,b){var _=b.rows.length?b.rows.item(0).key:null;l(_)},function(E,b){c(b)})})}).catch(c)});return A(f,u),f}n(Gi,"key$1");function Yi(i){var u=this,s=new h(function(f,l){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(v){Te(v,c,"SELECT key FROM "+c.storeName,[],function(y,E){for(var b=[],_=0;_<E.rows.length;_++)b.push(E.rows.item(_).key);f(b)},function(y,E){l(E)})})}).catch(l)});return A(s,i),s}n(Yi,"keys$1");function Wi(i){return new h(function(u,s){i.transaction(function(f){f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(l,c){for(var v=[],y=0;y<c.rows.length;y++)v.push(c.rows.item(y).name);u({db:i,storeNames:v})},function(l,c){s(c)})},function(f){s(f)})})}n(Wi,"getAllStoreNames");function Ki(i,u){u=$.apply(this,arguments);var s=this.config();i=typeof i!="function"&&i||{},i.name||(i.name=i.name||s.name,i.storeName=i.storeName||s.storeName);var f=this,l;return i.name?l=new h(function(c){var v;i.name===s.name?v=f._dbInfo.db:v=openDatabase(i.name,"","",0),i.storeName?c({db:v,storeNames:[i.storeName]}):c(Wi(v))}).then(function(c){return new h(function(v,y){c.db.transaction(function(E){function b(k){return new h(function(q,te){E.executeSql("DROP TABLE IF EXISTS "+k,[],function(){q()},function(Z,ie){te(ie)})})}n(b,"dropTable");for(var _=[],T=0,U=c.storeNames.length;T<U;T++)_.push(b(c.storeNames[T]));h.all(_).then(function(){v()}).catch(function(k){y(k)})},function(E){y(E)})})}):l=h.reject("Invalid arguments"),A(l,u),l}n(Ki,"dropInstance$1");var Hi={_driver:"webSQLStorage",_initStorage:ki,_support:xi(),iterate:qi,getItem:ji,setItem:Mi,removeItem:Bi,clear:$i,length:Vi,key:Gi,keys:Yi,dropInstance:Ki};function zi(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(i){return!1}}n(zi,"isLocalStorageValid");function fn(i,u){var s=i.name+"/";return i.storeName!==u.storeName&&(s+=i.storeName+"/"),s}n(fn,"_getKeyPrefix");function Qi(){var i="_localforage_support_test";try{return localStorage.setItem(i,!0),localStorage.removeItem(i),!1}catch(u){return!0}}n(Qi,"checkIfLocalStorageThrows");function Ji(){return!Qi()||localStorage.length>0}n(Ji,"_isLocalStorageUsable");function Xi(i){var u=this,s={};if(i)for(var f in i)s[f]=i[f];return s.keyPrefix=fn(i,u._defaultConfig),Ji()?(u._dbInfo=s,s.serializer=vr,h.resolve()):h.reject()}n(Xi,"_initStorage$2");function Zi(i){var u=this,s=u.ready().then(function(){for(var f=u._dbInfo.keyPrefix,l=localStorage.length-1;l>=0;l--){var c=localStorage.key(l);c.indexOf(f)===0&&localStorage.removeItem(c)}});return A(s,i),s}n(Zi,"clear$2");function es(i,u){var s=this;i=L(i);var f=s.ready().then(function(){var l=s._dbInfo,c=localStorage.getItem(l.keyPrefix+i);return c&&(c=l.serializer.deserialize(c)),c});return A(f,u),f}n(es,"getItem$2");function ts(i,u){var s=this,f=s.ready().then(function(){for(var l=s._dbInfo,c=l.keyPrefix,v=c.length,y=localStorage.length,E=1,b=0;b<y;b++){var _=localStorage.key(b);if(_.indexOf(c)===0){var T=localStorage.getItem(_);if(T&&(T=l.serializer.deserialize(T)),T=i(T,_.substring(v),E++),T!==void 0)return T}}});return A(f,u),f}n(ts,"iterate$2");function rs(i,u){var s=this,f=s.ready().then(function(){var l=s._dbInfo,c;try{c=localStorage.key(i)}catch(v){c=null}return c&&(c=c.substring(l.keyPrefix.length)),c});return A(f,u),f}n(rs,"key$2");function ns(i){var u=this,s=u.ready().then(function(){for(var f=u._dbInfo,l=localStorage.length,c=[],v=0;v<l;v++){var y=localStorage.key(v);y.indexOf(f.keyPrefix)===0&&c.push(y.substring(f.keyPrefix.length))}return c});return A(s,i),s}n(ns,"keys$2");function os(i){var u=this,s=u.keys().then(function(f){return f.length});return A(s,i),s}n(os,"length$2");function is(i,u){var s=this;i=L(i);var f=s.ready().then(function(){var l=s._dbInfo;localStorage.removeItem(l.keyPrefix+i)});return A(f,u),f}n(is,"removeItem$2");function ss(i,u,s){var f=this;i=L(i);var l=f.ready().then(function(){u===void 0&&(u=null);var c=u;return new h(function(v,y){var E=f._dbInfo;E.serializer.serialize(u,function(b,_){if(_)y(_);else try{localStorage.setItem(E.keyPrefix+i,b),v(c)}catch(T){(T.name==="QuotaExceededError"||T.name==="NS_ERROR_DOM_QUOTA_REACHED")&&y(T),y(T)}})})});return A(l,s),l}n(ss,"setItem$2");function as(i,u){if(u=$.apply(this,arguments),i=typeof i!="function"&&i||{},!i.name){var s=this.config();i.name=i.name||s.name,i.storeName=i.storeName||s.storeName}var f=this,l;return i.name?l=new h(function(c){i.storeName?c(fn(i,f._defaultConfig)):c(i.name+"/")}).then(function(c){for(var v=localStorage.length-1;v>=0;v--){var y=localStorage.key(v);y.indexOf(c)===0&&localStorage.removeItem(y)}}):l=h.reject("Invalid arguments"),A(l,u),l}n(as,"dropInstance$2");var us={_driver:"localStorageWrapper",_initStorage:Xi,_support:zi(),iterate:ts,getItem:es,setItem:ss,removeItem:is,clear:Zi,length:os,key:rs,keys:ns,dropInstance:as},cs=n(function(u,s){return u===s||typeof u=="number"&&typeof s=="number"&&isNaN(u)&&isNaN(s)},"sameValue"),fs=n(function(u,s){for(var f=u.length,l=0;l<f;){if(cs(u[l],s))return!0;l++}return!1},"includes"),ln=Array.isArray||function(i){return Object.prototype.toString.call(i)==="[object Array]"},ft={},dn={},Ye={INDEXEDDB:Ui,WEBSQL:Hi,LOCALSTORAGE:us},ls=[Ye.INDEXEDDB._driver,Ye.WEBSQL._driver,Ye.LOCALSTORAGE._driver],Ct=["dropInstance"],hr=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Ct),ds={description:"",driver:ls.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ps(i,u){i[u]=function(){var s=arguments;return i.ready().then(function(){return i[u].apply(i,s)})}}n(ps,"callWhenReady");function gr(){for(var i=1;i<arguments.length;i++){var u=arguments[i];if(u)for(var s in u)u.hasOwnProperty(s)&&(ln(u[s])?arguments[0][s]=u[s].slice():arguments[0][s]=u[s])}return arguments[0]}n(gr,"extend");var ms=function(){function i(u){m(this,i);for(var s in Ye)if(Ye.hasOwnProperty(s)){var f=Ye[s],l=f._driver;this[s]=l,ft[l]||this.defineDriver(f)}this._defaultConfig=gr({},ds),this._config=gr({},this._defaultConfig,u),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return n(i,"LocalForage"),i.prototype.config=n(function(s){if((typeof s=="undefined"?"undefined":p(s))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var f in s){if(f==="storeName"&&(s[f]=s[f].replace(/\W/g,"_")),f==="version"&&typeof s[f]!="number")return new Error("Database version must be a number.");this._config[f]=s[f]}return"driver"in s&&s.driver?this.setDriver(this._config.driver):!0}else return typeof s=="string"?this._config[s]:this._config},"config"),i.prototype.defineDriver=n(function(s,f,l){var c=new h(function(v,y){try{var E=s._driver,b=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!s._driver){y(b);return}for(var _=hr.concat("_initStorage"),T=0,U=_.length;T<U;T++){var k=_[T],q=!fs(Ct,k);if((q||s[k])&&typeof s[k]!="function"){y(b);return}}var te=n(function(){for(var lt=n(function(gs){return function(){var ys=new Error("Method "+gs+" is not implemented by the current driver"),pn=h.reject(ys);return A(pn,arguments[arguments.length-1]),pn}},"methodNotImplementedFactory"),yr=0,hs=Ct.length;yr<hs;yr++){var Er=Ct[yr];s[Er]||(s[Er]=lt(Er))}},"configureMissingMethods");te();var Z=n(function(lt){ft[E]&&console.info("Redefining LocalForage driver: "+E),ft[E]=s,dn[E]=lt,v()},"setDriverSupport");"_support"in s?s._support&&typeof s._support=="function"?s._support().then(Z,y):Z(!!s._support):Z(!0)}catch(ie){y(ie)}});return P(c,f,l),c},"defineDriver"),i.prototype.driver=n(function(){return this._driver||null},"driver"),i.prototype.getDriver=n(function(s,f,l){var c=ft[s]?h.resolve(ft[s]):h.reject(new Error("Driver not found."));return P(c,f,l),c},"getDriver"),i.prototype.getSerializer=n(function(s){var f=h.resolve(vr);return P(f,s),f},"getSerializer"),i.prototype.ready=n(function(s){var f=this,l=f._driverSet.then(function(){return f._ready===null&&(f._ready=f._initDriver()),f._ready});return P(l,s,s),l},"ready"),i.prototype.setDriver=n(function(s,f,l){var c=this;ln(s)||(s=[s]);var v=this._getSupportedDrivers(s);function y(){c._config.driver=c.driver()}n(y,"setDriverToConfig");function E(T){return c._extend(T),y(),c._ready=c._initStorage(c._config),c._ready}n(E,"extendSelfWithDriver");function b(T){return function(){var U=0;function k(){for(;U<T.length;){var q=T[U];return U++,c._dbInfo=null,c._ready=null,c.getDriver(q).then(E).catch(k)}y();var te=new Error("No available storage method found.");return c._driverSet=h.reject(te),c._driverSet}return n(k,"driverPromiseLoop"),k()}}n(b,"initDriver");var _=this._driverSet!==null?this._driverSet.catch(function(){return h.resolve()}):h.resolve();return this._driverSet=_.then(function(){var T=v[0];return c._dbInfo=null,c._ready=null,c.getDriver(T).then(function(U){c._driver=U._driver,y(),c._wrapLibraryMethodsWithReady(),c._initDriver=b(v)})}).catch(function(){y();var T=new Error("No available storage method found.");return c._driverSet=h.reject(T),c._driverSet}),P(this._driverSet,f,l),this._driverSet},"setDriver"),i.prototype.supports=n(function(s){return!!dn[s]},"supports"),i.prototype._extend=n(function(s){gr(this,s)},"_extend"),i.prototype._getSupportedDrivers=n(function(s){for(var f=[],l=0,c=s.length;l<c;l++){var v=s[l];this.supports(v)&&f.push(v)}return f},"_getSupportedDrivers"),i.prototype._wrapLibraryMethodsWithReady=n(function(){for(var s=0,f=hr.length;s<f;s++)ps(this,hr[s])},"_wrapLibraryMethodsWithReady"),i.prototype.createInstance=n(function(s){return new i(s)},"createInstance"),i}(),vs=new ms;a.exports=vs},{"3":3}]},{},[4])(4)})});var ei=D((Xo,Zo)=>{(function(e){var t;if(typeof define=="function"&&define.amd&&(define(e),t=!0),typeof Xo=="object"&&(Zo.exports=e(),t=!0),!t){var r=window.Cookies,o=window.Cookies=e();o.noConflict=function(){return window.Cookies=r,o}}})(function(){function e(){for(var o=0,a={};o<arguments.length;o++){var d=arguments[o];for(var p in d)a[p]=d[p]}return a}n(e,"extend");function t(o){return o.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}n(t,"decode");function r(o){function a(){}n(a,"api");function d(m,g,S){if(typeof document!="undefined"){S=e({path:"/"},a.defaults,S),typeof S.expires=="number"&&(S.expires=new Date(new Date*1+S.expires*864e5)),S.expires=S.expires?S.expires.toUTCString():"";try{var w=JSON.stringify(g);/^[\{\[]/.test(w)&&(g=w)}catch(A){}g=o.write?o.write(g,m):encodeURIComponent(String(g)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),m=encodeURIComponent(String(m)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var C="";for(var h in S)!S[h]||(C+="; "+h,S[h]!==!0&&(C+="="+S[h].split(";")[0]));return document.cookie=m+"="+g+C}}n(d,"set");function p(m,g){if(typeof document!="undefined"){for(var S={},w=document.cookie?document.cookie.split("; "):[],C=0;C<w.length;C++){var h=w[C].split("="),A=h.slice(1).join("=");!g&&A.charAt(0)==='"'&&(A=A.slice(1,-1));try{var P=t(h[0]);if(A=(o.read||o)(A,P)||t(A),g)try{A=JSON.parse(A)}catch(L){}if(S[P]=A,m===P)break}catch(L){}}return m?S[m]:S}}return n(p,"get"),a.set=d,a.get=function(m){return p(m,!1)},a.getJSON=function(m){return p(m,!0)},a.remove=function(m,g){d(m,"",e(g,{expires:-1}))},a.defaults={},a.withConverter=r,a}return n(r,"init"),r(function(){})})});var Os;var mt=n(()=>Os||window.location.hostname,"getCurrentHostname"),Re=n(()=>window.location.href,"getCurrentUrl"),Is=n(()=>{let e=/^bed-([^.]+)\.api\.no$/.exec(mt()),t=/\.([^.]+)\.api\.no/.exec(mt());return e?e[1]:t?t[1]:null},"getCurrentEnvironment"),le=n(()=>mt().replace(/\.[^.]+\.api\.no/,""),"getCurrentPublicationDomain"),We=n(()=>{let e=Is(),t="www.aid.no";return e==="localhost"?t="www.aid.no.localhost.api.no":e&&(t=`www-${e}.aid.no`),t},"getAidDomain");function Ns(e,t){let r=new FormData;Object.keys(t).forEach(a=>r.append(a,t[a])),fetch(e,{method:"POST",body:r,headers:{Accept:"application/json"}}).then(a=>{if(!a.ok)throw new Error(`Error, status: ${a.status}, text: ${a.statusText}`)})}n(Ns,"postLog");var At=n((e,t,r)=>{let o={};Object.keys(r).forEach(d=>{if(["string","number","boolean"].includes(typeof r[d])){o[d]=r[d];return}try{o[d]=JSON.stringify(r[d])}catch(p){o[d]=r[d]}});let a=ce(ne({},o),{message:t,url:Re(),domain:mt()});Ns(`/api/mercury/v1/log/${e}`,a)},"backendLog"),Ps={error:(e,t)=>At("error",e,t),warn:(e,t)=>At("warn",e,t),info:(e,t)=>At("info",e,t),debug:(e,t)=>At("debug",e,t)},gn=Ps;var Us;var xs=n(()=>Us||gn,"getLogger"),br=n(e=>{let t={message:e.message};return Object.getOwnPropertyNames(e).forEach(r=>{t[r]=e[r]}),t},"rewriteErrorObject"),yn=n(e=>O(void 0,null,function*(){let t=e.bodyUsed?"Response body not available for logging":yield e.text(),r={url:e.url,status:e.status,statusText:e.statusText,body:t};return Object.getOwnPropertyNames(e).forEach(o=>{r[o]=e[o]}),r}),"rewriteResponseObject"),Ds=n((r,...o)=>O(void 0,[r,...o],function*(e,t={}){let a=e,d=t||{};if(a instanceof Error){let p=br(a);a=p.message,d=ce(ne({},d),{error:p})}if(d=ce(ne({},d),{origin:"@amedia/user"}),t instanceof Error){let p=br(t);d=ce(ne({},d),{[Object.keys(d).includes("error")?"contextError":"error"]:p})}else if(d instanceof Response){let p=yield yn(d);d=ce(ne({},d),{response:p})}else for(let p of Object.keys(d))if(d[p]instanceof Error)d[p]=br(d[p]);else if(d[p]instanceof Response){let m=yield yn(d[p]);d[p]=m}return{message:a,context:d}}),"processIncomingLogData"),Tt=n((e,t,r)=>{Ds(t,r).then(({message:o,context:a})=>xs()[e](o,a))},"processAndLog"),j={debug:(e,t)=>Tt("debug",e,t),info:(e,t)=>Tt("info",e,t),warn:(e,t)=>Tt("warn",e,t),error:(e,t)=>Tt("error",e,t)};var Ce,Ls=n(e=>{Ce=e},"setRootElement");typeof window!="undefined"&&Ls(window);var ve=n((e,t)=>{if(!Ce){j.error("No root element to bind event to!");return}Ce.addEventListener(e,r=>{r.stopImmediatePropagation(),t.apply(Ce,[r])})},"listenWithExclusivity"),Ke=n((e,t)=>{if(!Ce){j.error("No root element to bind event to!");return}Ce.addEventListener(e,r=>{t.apply(Ce,[r])})},"listenForAllEvents"),ee=n(e=>{if(!Ce){j.error("No root element to dispatch event on!");return}Ce.dispatchEvent(e)},"dispatch");var V=we(Ue());var nt={},tu=n((e,t)=>{nt[e]||(nt[e]=[]),nt[e].push(t)},"add"),ru=n(e=>{let t=nt[e];return t?(delete nt[e],t):[]},"getAll"),nu=n(e=>{var t;return((t=nt[e])==null?void 0:t.length)||0},"peekQueueSize"),ot={add:tu,getAll:ru,peekQueueSize:nu};var xr=n(()=>{let e=typeof window!="undefined"?window:global;return e.amediaUserCache||(e.amediaUserCache={})},"getStorage"),ou=n(e=>{let t=xr()[e];return Promise.resolve(t)},"get"),iu=n((e,t,r)=>(xr()[e]={key:e,data:t,expires:r},Promise.resolve()),"set"),su=n(e=>(delete xr()[e],Promise.resolve()),"remove"),au=n(()=>((typeof window!="undefined"?window:global).amediaUserCache={},Promise.resolve()),"clear"),mo={get:ou,set:iu,remove:su,clear:au};var uu;var Qt=n(()=>uu||mo,"getCacheEngine"),cu=n((e,t,r)=>Qt().set(e,t,Date.now()+r),"set"),Dr=n(e=>Qt().remove(e),"remove"),fu=n((e,t)=>O(void 0,null,function*(){let r=yield Qt().get(e);if(!r)return Promise.resolve();if(Date.now()>r.expires)return Dr(e),Promise.resolve();try{return t.check(r.data)}catch(o){return j.error(o,{cacheData:r.data}),Dr(e),Promise.resolve()}}),"get"),lu=n(()=>Qt().clear(),"clear"),ge={get:fu,set:cu,remove:Dr,clear:lu};var du=n((e,t)=>!e||Array.isArray(t)?t:t?typeof e=="object"&&typeof t=="object"?ne(ne({},e),t):t:e,"mergeCache");function ye(e,t,r,o){return new Promise((a,d)=>{ot.add(e,{resolve:a,reject:d}),!(ot.peekQueueSize(e)>1)&&ge.get(e,t).then(p=>{if(p&&(!o||o(p))){ot.getAll(e).forEach(m=>{m.resolve(p)});return}r().then(m=>{let g=p?du(p,m.data):m.data;ge.set(e,g,m.ttl),ot.getAll(e).forEach(S=>{S.resolve(m.data)})}).catch(()=>{ot.getAll(e).forEach(m=>{m.reject()})})})})}n(ye,"getOrUpdate");var pu=(0,V.Record)({id:V.Number,domain:V.String}),vo=(0,V.Record)({status:(0,V.Literal)("success"),access:(0,V.Union)((0,V.Literal)("granted"),(0,V.Literal)("denied")),publication:pu,access_features:(0,V.Array)(V.String)}),mu=(0,V.Record)({status:(0,V.Literal)("success"),cookie:V.String,access_features:(0,V.Array)(V.String)}),vu=(0,V.Record)({status:(0,V.Literal)("success"),vstoken_cookie:V.String,uuid:V.String,access_features:(0,V.Array)(V.String)}),ho=n((e,t)=>ye("checkForAccess",vo,()=>fetch(`/api/jupiter/v1/check_access_for_paper/${e}/?require=any&access_features=${t.join(",")}`).then(r=>{if(!r.ok)throw new Error(`Request not ok (${r.status}: ${r.statusText}).`);return r.json()}).then(r=>{try{let o=vo.check(r);return{ttl:o.access==="granted"?1e3*10:0,data:o}}catch(o){throw j.error(o,{json:r}),o}})).then(r=>({access:r.access_features})),"checkForAccess"),go=n(e=>fetch(`/api/jupiter/v1/get_vstoken/${e}`,{method:"post"}).then(t=>{if(!t.ok)throw new Error(`Request not ok (${t.status}: ${t.statusText}).`);return t.json()}).then(t=>{try{return mu.check(t)}catch(r){throw j.error(r,{json:t}),r}}),"getUserAccess"),yo=n(e=>fetch(`/api/jupiter/v1/non_user_access/${e}`,{method:"post"}).then(t=>{if(!t.ok)throw new Error(`Request not ok (${t.status}: ${t.statusText}).`);return t.json()}).then(t=>{try{return vu.check(t)}catch(r){throw j.error(r,{json:t}),r}}),"getNonUserAccess");var yt=class extends Error{};n(yt,"UserDeactivatedError");var hu=["no_session_found","subscription_not_found"],Eo=n(e=>O(void 0,null,function*(){return fetch(`/api/mercury/v2/access/activate?publication_wwwdomain=${le()}&access_features=${e.join(",")}`,{method:"post"}).then(t=>O(void 0,null,function*(){let r=yield t.text(),o;try{o=JSON.parse(r)}catch(a){j.error(`Activate subscription failed. Mercury (HTTP/${t.status}: ${r})`,{error:a,response:t,accessFeatures:e,body:r})}if(!t.ok){if((o==null?void 0:o.status)==="user_deactivated")throw new yt;return hu.includes(o==null?void 0:o.status)?[]:(j.error(`Activate subscription failed. Mercury (HTTP/${t.status}: ${r})`,{response:t,accessFeatures:e,body:r}),[])}return o==null?void 0:o.access_features}))}),"activateSubscription");var me=we(Ue());var wo=we(So()),je={},it={},gu=n(e=>{var t;(t=it[e])==null||t.forEach(r=>r(je[e]))},"emit"),yu=n((e,t)=>{it[e]||(it[e]=[]),it[e].push(t)},"on"),Ro=n((e,t)=>{je[e]=t,gu(e)},"set"),Eu=n((e,t)=>{Ro(e,(0,wo.default)(je[e]||{},t))},"merge"),bu=n(e=>je[e],"get"),_u=n(()=>{je.state=void 0,je.userAttributes=void 0,je.storage=void 0,Object.keys(it).forEach(e=>{it[e]=[]})},"clear"),Q={merge:Eu,set:Ro,get:bu,on:yu,clear:_u};var Su=["avbrutt","kansellert","cancelled","aborted","failed to fetch","abgebrochen","the operation was aborted."],Co=n(e=>Su.includes(e.toLowerCase().trim()),"isAbortedNetworkError");var Ao=(0,me.Partial)({user_uuid:me.String,user_name:me.String,tracking_key:me.String}),wu=n(e=>({uuid:e.user_uuid,name:e.user_name,trackingKey:e.tracking_key}),"mapSessionToUserAttributes"),Ru=(0,me.Record)({code:me.String}),Cu=(0,me.Record)({errors:(0,me.Array)(Ru)}),Au=["session.not_found","session.not_specified","user.deactivated"],Tu=["session.invalid_for_domain","user.not_found"],Fr=n(e=>O(void 0,null,function*(){let t,r=e.clone();try{[t]=Cu.check(yield e.json()).errors}catch(o){return Co(o==null?void 0:o.message)?Promise.resolve():(j.warn("Unable to parse error body from pluto",{error:o,response:r}),Promise.reject(o))}return Au.includes(t==null?void 0:t.code)?Promise.resolve():Tu.includes(t==null?void 0:t.code)?(j.warn(`Pluto responded with HTTP/${e.status}: (${t.code}) while fetching current session`,{error:t,response:e}),Promise.resolve()):(j.error(`Pluto responded with HTTP/${e.status}: ${e.statusText}) when fetching current session`,{error:t,response:e}),Promise.reject())}),"resolveBadPlutoResponse"),Ou=n(()=>fetch("/api/pluto/v1/sessions/current").then(e=>e.ok?e.json():Fr(e).then(()=>({}))).then(e=>{let t={ttl:-1,data:e};if(Object.keys(e).length===0)return t;try{return{ttl:1e4,data:Ao.check(e)}}catch(r){return j.error(r,{json:e}),t}}),"fetchCurrentSession"),To=n(()=>O(void 0,null,function*(){return ye("getCurrentSession",Ao,Ou).then(e=>(Q.merge("state",{isLoggedIn:e.user_uuid!==void 0}),wu(e)))}),"getCurrentSession"),Oo=n(e=>O(void 0,null,function*(){return fetch(`/api/pluto/v1/sessions/current?publication_domain=${e}`,{method:"DELETE"}).then(t=>{if(!t.ok){if(t.status===403)return;throw new Error(`Error, could not perform deleteRequest. Status: ${t.status} Text: ${t.statusText}`)}Q.merge("state",{isLoggedIn:!1})})}),"removeSession");var kr,Jt=self||window,Io=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof Jt.msCrypto!="undefined"&&typeof Jt.msCrypto.getRandomValues=="function"&&Jt.msCrypto.getRandomValues.bind(Jt.msCrypto);if(Io){let e=new Uint8Array(16);kr=n(function(){return Io(e),e},"whatwgRNG")}else{let e=new Array(16);kr=n(function(){for(let r=0,o;r<16;r+=1)(r&3)==0&&(o=Math.random()*4294967296),e[r]=o>>>((r&3)<<3)&255;return e},"mathRNG")}var No=[];for(let e=0;e<256;++e)No[e]=(e+256).toString(16).substr(1);function Iu(e,t){let r=t||0,o=No;return[o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]]].join("")}n(Iu,"bytesToUuid");function Po(){let e=kr();return e[6]=e[6]&15|64,e[8]=e[8]&63|128,Iu(e)}n(Po,"uuid");function Nu(){let e,t,r=!1;return{promise:new Promise((a,d)=>{e=n(p=>{r||a(p),r=!0},"resolve"),t=n(p=>{r||d(p),r=!0},"reject")}),resolve:e,reject:t}}n(Nu,"createPromise");function Pu(e,t){return(...r)=>{let{resolve:o,reject:a,promise:d}=Nu(),p=Po(),m={eventId:p,args:r},g=new CustomEvent(`amedia-rpc-event:${e}:${t}`,{detail:m});if(self.dispatchEvent(g),self.amediaNativeBridge){let S=JSON.stringify(r);self.amediaNativeBridge.callNativeMethod(e,t,S,p)}return self.addEventListener(`amedia-rpc-event:${e}:${t}:${p}`,S=>{S.detail||o();let{error:w,result:C}=S.detail;return w?a(w):o(C)}),d}}n(Pu,"createMethod");var Et=class{constructor({version:t,component:r,methods:o=[]}){this.component=r,this.version=t,this.queue=[],o.forEach(a=>this.addMethod(a)),this.boundLiveHandler=this.liveHandler.bind(this),self.addEventListener(`amedia-rpc-event:${r}:live`,this.boundLiveHandler),setTimeout(()=>self.dispatchEvent(new CustomEvent(`amedia-rpc-event:${r}:ready`)),0)}liveHandler(t){let[r,o]=t.detail.version.split(".").map(m=>parseInt(m,10)),[a,d]=this.version.split(".").map(m=>parseInt(m,10));if(r!==a)throw new Error(`${this.component} version mismatch. Server version: ${r}. Client version: ${a}`);o<d&&console.warn(`${this.component} server version is on an earlier minor version (${o}) than the client (${d})`);let p=this.queue.slice(0);delete this.queue,p.forEach(m=>m()),self.removeEventListener(`amedia-rpc-event:${this.component}:live`,this.boundLiveHandler)}addMethod(t){if(this[t])throw new Error(`${t} already exists on the RPC interface.`);this[t]=(...r)=>{if(this.queue){let o,a,d=new Promise((p,m)=>{o=p,a=m});return this.queue.push(()=>this[t](...r).then(o).catch(a)),d}return this[t]=Pu(this.component,t),this[t](...r)}}};n(Et,"RPCclient");var Xt,Uo=n(()=>Xt||(Xt=new Et({version:"1.0.0",component:"userdata-session",methods:["userAuthenticated"]}),Xt),"getRPCClient");var Uu=n((e,t)=>{let r=t.substring(e.length,t.length);if(r.substring(0,1)==="{")return JSON.parse(r);if(r.substring(0,3)==="%7B")return JSON.parse(decodeURIComponent(r));if(r!=="undefined")return r===""||r==="null"?null:r},"getCookieValue"),De=n(e=>{let t=`${e}=`,r=document.cookie.split(";");for(let o=r.length-1;o>=0;o-=1){let a=r[o].trim();if(a.indexOf(t)===0)return Uu(t,a)}return null},"getCookie"),xu=n((e,t)=>t?t instanceof Date?`; expires=${t.toUTCString()}`:(e.setTime(e.getTime()+t*24*60*60*1e3),`; expires=${e.toUTCString()}`):"","setValidTime"),Du=n(e=>!e||e===""?"":e instanceof Object?encodeURIComponent(JSON.stringify(e)):typeof e=="number"?e.toString(10):e,"setValue");function qe(e,t,r=Date.now(),o="/",a=!1){let d=new Date,p=`${e}=`;return(!t||t==="")&&(r=-1),p+=Du(t),p+=xu(d,r),p+=`; path=${o}`,a&&(p+="; secure"),document.cookie=p,r&&r!==-1&&De(e)===null&&(document.cookie=p.replace(/; expires=[^;]*/,"")),p}n(qe,"setCookie");function Ee(e){qe(e)}n(Ee,"removeCookie");var xo=n(()=>window.location.reload(),"reload"),Do=n(e=>window.location.replace(e),"replace"),Zt=n(e=>{window.location.href=e},"navigateTo");var Lo=n(e=>{let t=new URL(`https://${We()}/aid/logg_inn/${le()}/`);t.searchParams.set("requestedUrl",e instanceof URL?e.href:e),Zt(t.href)},"login");function Lu(){Ee("VSTOKEN"),Ee("aid.session"),Ee("aid_invitation_code"),Ee("aid-reload-article")}n(Lu,"clearCookies");var er=n(()=>O(void 0,null,function*(){return Promise.all([Oo(le()),ge.clear()]).then(()=>{Uo().userAuthenticated(!1),Lu(),Ee("VSTOKEN2")}).catch(e=>{j.error("Failure while logging out",e)})}),"logout"),tr=n(()=>To(),"getSession");var Fo=n((e=["newspaper"])=>ho(le(),e),"getAccess"),rr=n(e=>O(void 0,null,function*(){try{return yield Eo(e)}catch(t){if(t instanceof yt)return yield er(),[];throw t}}),"activate"),bt=n((e,t)=>t.length<1||t.filter(r=>e.includes(r)).length>0,"hasAccess"),nr=n(e=>O(void 0,null,function*(){let t=yield go(e);return t.status==="success"&&qe("VSTOKEN",t.cookie,365,"/"),{success:t.status==="success",accessFeatures:t.access_features}}),"setUserAccessCookie"),or=n(e=>O(void 0,null,function*(){let t=yield yo(e);return t.status==="success"&&qe("VSTOKEN2",t.vstoken_cookie,1,"/"),{success:t.status==="success",accessFeatures:t.access_features}}),"setNonUserAccessCookie"),ko=n(e=>O(void 0,null,function*(){let t=[];return t.push(nr(e).catch(()=>Promise.resolve({success:!1,accessFeatures:[]}))),t.push(or(e).catch(()=>Promise.resolve({success:!1,accessFeatures:[]}))),Promise.all(t).then(r=>r.reduce((o,a)=>({success:o.success&&a.success,accessFeatures:o.accessFeatures.concat(a.accessFeatures).filter((d,p,m)=>m.indexOf(d)===p).sort()}),{success:!0,accessFeatures:[]}))}),"setAccessCookies"),jo=n(e=>{let t=new Date;t.setTime(t.getTime()+2*60*1e3),qe("aid-paywall-reload-performed",e||Re(),t)},"setHasPerformedPaywallReload"),qo=n(e=>De("aid-paywall-reload-performed")===(e||Re()),"hasRecentlyPerformedPaywallReload");var Me;(function(r){r.REQUEST_ACTIVATION="amedia-user.activation.request-activation",r.ON_ACTIVATION_COMPLETE="amedia-user.activation.on-activation-complete"})(Me||(Me={}));var Fu=n(()=>{ve(Me.REQUEST_ACTIVATION,e=>{rr(e.detail.accessFeatures).then(t=>{ee(new CustomEvent(Me.ON_ACTIVATION_COMPLETE,{detail:{accessFeatures:t}}))})})},"listenForActivationRequests");Fu();var K;(function(m){m.REQUEST_STATE="amedia-user.request-state",m.REQUEST_USER_ATTRIBUTES="amedia-user.request-user-attributes",m.REQUEST_STORAGE_NAMESPACES="amedia-user.request-storage-namespaces",m.UPDATE_STORAGE="amedua-user.update-storage-namespaces",m.ON_ATTRIBUTES_UPDATED="amedia-user.on-user-attributes-updated",m.ON_STATE_UPDATED="amedia-user.on-state-updated",m.ON_STORAGE_UPDATED="amedia-user.on-storage-updated"})(K||(K={}));var _t=n((e,t)=>{if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let a of r){if(!o.includes(a))return!1;if(typeof e[a]=="function"||typeof t[a]=="function"){if(e[a].toString()!==t[a].toString())return!1}else if(!_t(e[a],t[a]))return!1}return!0},"deepEquals");function Mo(e,t){return e&&e.length>0?t&&Object.keys(t).length>0?e.filter(r=>!Object.keys(t).includes(r)).length>0:!0:!1}n(Mo,"isMissingData");var st=class{constructor(t,r){this.attributes=t;this.namespaces=r}withAttributes(t){return new st([...this.attributes||[],...t],this.namespaces)}withStorage(t){return new st(this.attributes,[...this.namespaces||[],...t])}subscribe(t){let r=this.setupLocalCache();Ke(K.ON_STATE_UPDATED,o=>{let a=o.detail;Object.keys(r.state).length>0&&_t(r.state,a)||(r=ce(ne({},r),{state:a}),t(r))}),ee(new CustomEvent(K.REQUEST_STATE)),Array.isArray(this.attributes)&&this.attributes.length>0&&(Ke(K.ON_ATTRIBUTES_UPDATED,o=>{let a=this.processUserAttributesEvent(o);Object.keys(r.attributes).length>0&&_t(r.attributes,a)||(r=ce(ne({},r),{attributes:a}),t(r))}),ee(new CustomEvent(K.REQUEST_USER_ATTRIBUTES,{detail:this.attributes}))),Array.isArray(this.namespaces)&&this.namespaces.length>0&&(Ke(K.ON_STORAGE_UPDATED,o=>{let a=this.processStorageEvent(o);_t(r.storage,a)||(r=ce(ne({},r),{storage:a}),t(r))}),ee(new CustomEvent(K.REQUEST_STORAGE_NAMESPACES,{detail:this.namespaces})))}fetch(){return new Promise(t=>{this.subscribe(r=>{if(typeof r.state.isLoggedIn!="undefined"){if(r.state.isLoggedIn===!1){t(r);return}Mo(this.attributes,r.attributes)||Mo(this.namespaces,r.storage)||t(r)}})})}processUserAttributesEvent(t){let r=t.detail;return this.attributes.reduce((a,d)=>(r[d]!==void 0&&(a[d]=r[d]),a),{})}processStorageEvent(t){let r=t.detail;return this.namespaces&&this.namespaces.reduce((o,a)=>(r[a]!==void 0&&(o[a]=r[a]),o),{})}setupLocalCache(){let t={state:{}};return this.attributes&&this.attributes.length>0&&(t.attributes={}),this.namespaces&&this.namespaces.length>0&&(t.storage={}),t}};n(st,"UserDataRequest");var _e=st;var Bo="jupiter";function ku(){return O(this,null,function*(){let e="VSTOKEN",t=le(),r=De(e),o=!1;new _e().withAttributes(["uuid"]).subscribe(p=>O(this,[p],function*({attributes:a,state:d}){if(d.isLoggedIn===!1){typeof r=="string"&&Ee(e);return}if(!a.uuid||d.isLoggedIn===void 0||o)return;if(o=!0,typeof r!="string"){yield nr(t);return}let m=r.split(":"),g=new Date(parseInt(m[1],10)*1e3);g.setDate(g.getDate()-1),!(g.getTime()>Date.now()&&m[3]===a.uuid&&t.includes(m[4])&&m[5]===Bo)&&(yield nr(t))}))})}n(ku,"verifyAndSetUserAccessCookie");function ju(){let e="VSTOKEN2",t=le(),r=De(e);new _e().fetch().then(a=>O(this,[a],function*({state:{isLoggedIn:o}}){if(o){if(typeof r!="string"){yield or(t);return}let d=r.split(":"),p=new Date(parseInt(d[1],10)*1e3);if(p.setMinutes(p.getMinutes()-30),p.getTime()>Date.now()&&t.includes(d[4])&&d[5]===Bo)return;yield or(t)}else Ee(e)})).then(()=>{})}n(ju,"verifyAndSetNonUserAccessCookie");function jr(){return Promise.all([ku(),ju()])}n(jr,"accessCookieRefresher");function $o(){new _e().subscribe(({state:e})=>{e.isLoggedIn===!1&&(Q.set("userAttributes",{}),Q.set("storage",{}))})}n($o,"removeUserStorage");var Be=we(Ue());var Vo="haveTriedThirdPartyLoginCheck",qu=60*60*1e3,Mu=(0,Be.Record)({user_name:Be.String,tracking_key:Be.String}),Bu=n(()=>fetch(`https://${We()}/api/pluto/v1/sessions/current`,{mode:"cors",credentials:"include"}).then(e=>e.ok?e.json():Fr(e).then(()=>null).catch(()=>null)).then(e=>{if(!e)return null;try{return Mu.check(e)}catch(t){return j.error(t,{data:e}),null}}),"getAidSession");function qr(){return O(this,null,function*(){return(yield ge.get(Vo,Be.Boolean))?!1:(yield ge.set(Vo,!0,qu),!!(yield Bu()))})}n(qr,"thirdPartyCookie");var Mr="has-tried-autologin",Go=6e4;function $u(){try{return window.self!==window.top}catch(e){return!0}}n($u,"inIframe");function Vu(){let e=De(Mr);if(e&&typeof e!="object")try{if(Date.now()-parseInt(e,10)<Go)return!0}catch(t){Ee(Mr)}return qe(Mr,Date.now(),Date.now()+Go),!1}n(Vu,"hasAlreadyAttemptedAutoLogin");var Yo=n(e=>O(void 0,null,function*(){if($u())return;let{state:{isLoggedIn:t}}=yield new _e().fetch();if(!t){for(let r of e)if(!(yield r.handler().then(a=>{if(a){if(Vu())return!1;let d=new URL(`https://${We()}/aid/logg_inn/auto`);return d.searchParams.set("context",`auto_login_${r.name}`),d.searchParams.set("requestedUrl",Re()),Zt(d.href),!1}return!0})))return}}),"attemptAutologin"),Wo=n(()=>O(void 0,null,function*(){return Yo([{name:"third_party",handler:qr}])}),"attemptAutoLoginJob"),Ko=n(()=>O(void 0,null,function*(){return Yo([{name:"paywall",handler:()=>Promise.resolve(!0)}])}),"attemptPaywallAutoLogin");var Gu=[Wo,jr,$o];function Yu(){return O(this,null,function*(){for(let e of Gu)yield e()})}n(Yu,"performJobs");var ir;(function(t){t.LOADED="amedia-user.janitor.loaded"})(ir||(ir={}));var Ho=n(()=>O(void 0,null,function*(){let e=!1;ve(ir.LOADED,()=>{e||(e=!0,Yu())}),ee(new CustomEvent(ir.LOADED))}),"runJanitor");var zo=n(()=>{ve(K.REQUEST_STATE,()=>{let e=Q.get("state");e&&Object.keys(e).length>0&&ee(new CustomEvent(K.ON_STATE_UPDATED,{detail:e})),Q.on("state",t=>{ee(new CustomEvent(K.ON_STATE_UPDATED,{detail:t}))})})},"listenForStateRequests");var ar=we(Jo()),St=we(ei());var $r,sr=typeof self=="undefined"?window:self,ti=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof sr.msCrypto!="undefined"&&typeof sr.msCrypto.getRandomValues=="function"&&sr.msCrypto.getRandomValues.bind(sr.msCrypto);if(ti){let e=new Uint8Array(16);$r=n(function(){return ti(e),e},"whatwgRNG")}else{let e=new Array(16);$r=n(function(){for(let r=0,o;r<16;r+=1)(r&3)==0&&(o=Math.random()*4294967296),e[r]=o>>>((r&3)<<3)&255;return e},"mathRNG")}var ri=[];for(let e=0;e<256;++e)ri[e]=(e+256).toString(16).substr(1);function Wu(e,t){let r=t||0,o=ri;return[o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]]].join("")}n(Wu,"bytesToUuid");function Vr(){let e=$r();return e[6]=e[6]&15|64,e[8]=e[8]&63|128,Wu(e)}n(Vr,"uuid");function ni(e){let t=!1;return(...r)=>{t||(e.apply(this,r),t=!0,setTimeout(()=>{t=!1},400))}}n(ni,"throttle");ar.default.config({name:"aid:userdata"});var oi=self.location.hostname.replace(/(.*\.)([^.]+\.\w+$)/,"$2");function ii(){let e=St.default.get("amedia:fpbid");return e||(e=Vr(),St.default.set("amedia:fpbid",e,{expires:365*10,domain:oi,sameSite:"strict"})),Promise.resolve(e)}n(ii,"getBrowserId");function Ku(){let e=St.default.get("amedia:visitid");return e?Promise.resolve(e):ar.default.getItem("visitid")}n(Ku,"getVisitIdFromStorage");function si(e){return St.default.set("amedia:visitid",e,{expires:new Date(Date.now()+18e5),domain:oi,sameSite:"strict"}),ar.default.setItem("visitid",e).then(()=>e)}n(si,"storeVisitId");function ai(){let e=Date.now(),t=`${Vr()}|${e}`;return si(t)}n(ai,"createVisitId");function Hu(){return Ku().then(e=>e||ai()).then(e=>{let[t,r]=e.split("|");return!t||r&&Date.now()-18e5>r?ai():si(`${t}|${Date.now()}`)}).catch(e=>console.error(e))}n(Hu,"refreshVisitId");typeof window!="undefined"&&["mousedown","keydown","mousemove","focus","scroll","resize","seshat-video-active","touchmove","deviceorientation"].forEach(e=>window.addEventListener(e,ni(Hu)));var $e=we(Ue());var Le=we(Ue());var ui=5*6e4,ci=(0,Le.Record)({namespaces:(0,Le.Dictionary)(Le.Unknown,Le.String)});var fi=n((e,t="GET",r)=>fetch(e,{method:t,body:r&&JSON.stringify(r),headers:{"Content-Type":"application/json",Accept:"application/json"}}),"doFetch"),zu=n((e,t)=>O(void 0,null,function*(){let r=yield ge.get("europa",ci),o=r?ce(ne({},r),{namespaces:ce(ne({},r.namespaces),{[e]:t})}):{namespaces:{[e]:t}};return ge.set("europa",o,Date.now()+ui)}),"updateNamespaceInCache"),li=n((e,t)=>O(void 0,null,function*(){let r=yield fi(`/api/europa/v1/me/${e}`,"PATCH",t);return r.ok?zu(e,t):(j.error(`Could not get namespace: ${e}, status: ${r.status}, statusText: ${r.statusText}`,r),{})}),"updateNamespace"),ur=n((r,...o)=>O(void 0,[r,...o],function*(e,t={ignoreCache:!1}){if(e.length===0)throw new Error("namespaces array cannot be of length 0");return ye("europa",ci,()=>fi(`/api/europa/v1/me/${e.join(",")}`).then(a=>O(void 0,null,function*(){let d=yield a.text();return a.ok?JSON.parse(d):(a.status!==400&&j.error(`Could not get namespaces for: ${e}, status: ${a.status}`,{response:a,body:d}),{namespaces:{}})})).then(a=>({ttl:ui,data:a})),a=>!t.ignoreCache||Object.keys(a.namespaces).filter(d=>!Object.keys(e).includes(d)).length===0).then(a=>a.namespaces)}),"getNamespaces");var Qu=5*6e4,Ju="privacyPreferences",Xu=(0,$e.Record)({allowResearchUsage:$e.Boolean,connectWithSurveys:$e.Boolean,personalizedAds:$e.Boolean,personalizedContent:$e.Boolean}),cr=n(e=>e==="true"||e===!0,"toBoolean"),di=n(()=>O(void 0,null,function*(){return ye(Ju,Xu,()=>ur(["privacy_preferences"]).then(e=>{let t=e.privacy_preferences;return{ttl:Qu,data:{allowResearchUsage:cr(t.allow_research_usage),connectWithSurveys:cr(t.connect_with_surveys),personalizedAds:cr(t.personalized_ads),personalizedContent:cr(t.personalized_content)}}})).then(e=>({privacyPreferences:e}))}),"getPrivacyPreferences");var B=we(Ue());var pi=(0,B.Dictionary)(B.Unknown,B.String).And((0,B.Partial)({ad_segments:B.String,ad_segments_user:B.String,amedia_employee:B.Boolean,amedia_employee_user:B.Boolean,age:B.Number,age_user:B.Number,birth_year:B.String,birth_year_user:B.String,gender:B.String,gender_user:B.String,grunnkrets:B.String,grunnkrets_user:B.String,postcode:B.String,postcode_user:B.String,shared_account:B.Boolean,shared_account_user:B.Boolean,user_grouping_number:B.String,user_grouping_number_user:B.String})),Zu=n((e,t,r)=>{let o=new URL("https://services.gcloud.api.no/api/nebula/v1/info");return o.searchParams.set("domain",e),o.searchParams.set("browser_id",t),r&&o.searchParams.set("user_key",r),fetch(o.href).then(a=>a.json()).then(a=>{try{return{ttl:1e3*60*60*5,data:pi.check(a)}}catch(d){throw j.error(d,{json:a}),d}})},"getNebulaData"),ec=n(e=>({extraData:e}),"mapNebulaToUserData"),mi=n((e,t,r)=>ye("getNebulaInfo",pi,()=>Zu(e,t,r)).then(ec),"getInfo");var Gr=n(()=>new Promise(e=>{var r;let t=(r=Q.get("state"))==null?void 0:r.isLoggedIn;if(t===!1||t===!0){e(t);return}Q.on("state",({isLoggedIn:o})=>{(o===!1||o===!0)&&e(o)})}),"whenLoginStateResolved"),at=n(()=>new Promise(e=>Gr().then(t=>{t&&e()})),"whenIsLoggedIn");var tc=n(()=>Promise.all([ii(),Gr()]).then(([e,t])=>{var r;return mi(window.location.hostname,e,t?(r=Q.get("userAttributes"))==null?void 0:r.trackingKey:void 0)}),"getExtraData"),rc={uuid:tr,name:tr,trackingKey:tr,access:()=>at().then(()=>Fo()),extraData:tc,privacyPreferences:()=>at().then(()=>di())},vi=n(e=>{let t=[];e.forEach(o=>{let a=rc[o];if(!a){j.warn(`Unknown attribute ${o} was requested`);return}t.includes(a)||t.push(a)});let r=[];return t.forEach(o=>{r.push(o().then(a=>{Q.merge("userAttributes",a)}).catch(a=>{j.warn(`User attribute call failed (${o.toString()})`,a)}))}),Promise.all(r).then(()=>{})},"requestAttributes");var hi=n(()=>{Q.on("userAttributes",e=>{ee(new CustomEvent(K.ON_ATTRIBUTES_UPDATED,{detail:e}))}),ve(K.REQUEST_USER_ATTRIBUTES,e=>{let t=e.detail,r=Q.get("userAttributes")||{};Object.keys(r).length>0&&ee(new CustomEvent(K.ON_ATTRIBUTES_UPDATED,{detail:r}));let o=t.filter(a=>r[a]===void 0);o.length>0&&vi(o)})},"listenForUserAttributeRequests");var gi=n(e=>{ur(e).then(t=>{Q.merge("storage",t)})},"requestStorage"),yi=n(e=>Object.keys(e).forEach(t=>li(t,e[t])),"updateStorage");var Ei=n(()=>{Q.on("storage",e=>{ee(new CustomEvent(K.ON_STORAGE_UPDATED,{detail:e}))}),ve(K.REQUEST_STORAGE_NAMESPACES,e=>{at().then(()=>{let t=e.detail,r=Q.get("storage")||{};Object.keys(r).length>0&&ee(new CustomEvent(K.ON_STORAGE_UPDATED,{detail:r}));let o=t.filter(a=>r[a]===void 0);o.length>0&&gi(o)})}),ve(K.UPDATE_STORAGE,e=>{at().then(()=>{yi(e.detail)})})},"listenForStorageRequests");var ut=class extends Error{constructor(t,r){super(t);this.code=r}};n(ut,"PaywallError"),ut.ERROR_RELOADED_NO_ACCESS="RELOADED_NO_ACCESS",ut.ERROR_ENABLING_ACCESS_FAILED="ENABLING_ACCESS_FAILED",ut.ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES="NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES";var Ve=ut;var Yr=class{constructor(){this.requestedAccessFeatures=["newspaper"];this.reload=!1}withAccessFeatures(t){return this.requestedAccessFeatures=t,this}reloadOnAccess(){return this.reload=!0,this}redirectOnAccess(t){return this.requestedUrl=t,this}tryUnlock(){return O(this,null,function*(){let{state:{isLoggedIn:t}}=yield new _e().withAttributes(["name"]).fetch();if(!t)return yield Ko(),{isLoggedIn:!1,hasAccess:!1,accessFeatures:[]};let r=yield this.setAccessCookiesAndGetAccessFeatures(this.requestedAccessFeatures);if(r.denied){if(r=yield this.activateAccess(this.requestedAccessFeatures),r.denied)return{isLoggedIn:!0,hasAccess:!1,accessFeatures:r.accessFeatures};if(r=yield this.setAccessCookiesAndGetAccessFeatures(this.requestedAccessFeatures),r.denied)throw new Ve("New subscription was attached and checked successfully, but internal systems disagree about current newspaper access.",Ve.ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES)}if(this.reload||this.requestedUrl){if(qo(this.requestedUrl))throw new Ve("Unlock check already performed.",Ve.ERROR_RELOADED_NO_ACCESS);jo(this.requestedUrl),this.reload&&xo(),this.requestedUrl&&Do(this.requestedUrl)}return{isLoggedIn:!0,hasAccess:!0,accessFeatures:r.accessFeatures}})}setAccessCookiesAndGetAccessFeatures(t){return ko(le()).then(r=>{let o=!bt(r.accessFeatures,t);if(!r.success&&o)throw new Ve("Could not set access cookies",Ve.ERROR_ENABLING_ACCESS_FAILED);return{denied:o,accessFeatures:r.accessFeatures}})}activateAccess(t){return O(this,null,function*(){let r=yield rr(this.requestedAccessFeatures);return{denied:!bt(r,t),accessFeatures:r}})}};n(Yr,"PaywallUnlockRequest");var nc=Yr;var Dd=n(e=>Lo(e||Re()),"goToLoginPage"),Ld=n(()=>er(),"logout"),Fd=n(e=>new Promise(t=>{Ke(Me.ON_ACTIVATION_COMPLETE,r=>{let o=r.detail.accessFeatures;t({hasAccess:bt(o,e),accessFeatures:o})}),ee(new CustomEvent(Me.REQUEST_ACTIVATION,{detail:{accessFeatures:e}}))}),"tryActivateSubscriptionAccess"),kd=n(e=>{ee(new CustomEvent(K.UPDATE_STORAGE,{detail:e}))},"updateStorage");typeof process=="undefined"&&(zo(),hi(),Ei(),Ho());})();
2
+ /*!
3
+ localForage -- Offline Storage, Improved
4
+ Version 1.9.0
5
+ https://localforage.github.io/localForage
6
+ (c) 2013-2017 Mozilla, Apache License 2.0
7
+ */
8
+ /*!
9
+ * JavaScript Cookie v2.2.1
10
+ * https://github.com/js-cookie/js-cookie
11
+ *
12
+ * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
13
+ * Released under the MIT license
14
+ */
15
+ //# sourceMappingURL=index.js.map