@amedia/user 0.13.42 → 0.14.1
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/README.md +13 -3
- package/dist/user.js +23 -15
- package/package.json +6 -5
- package/src/autologin/index.spec.ts +13 -0
- package/src/autologin/index.ts +10 -0
- package/src/clients/pluto.spec.ts +96 -1
- package/src/clients/pluto.ts +8 -0
- package/dist/user.cjs +0 -15
- package/dist/user.cjs.map +0 -7
- package/dist/user.js.map +0 -7
package/README.md
CHANGED
|
@@ -10,10 +10,12 @@ normal way to load the module from Eik is through import maps.
|
|
|
10
10
|
|
|
11
11
|
# Usage
|
|
12
12
|
|
|
13
|
+
Please be advised that you are required to use ESM in order to use this module.
|
|
14
|
+
|
|
13
15
|
## Importing the module
|
|
14
16
|
|
|
15
|
-
Add this module to your project by running `npm install -d @amedia/user`. This will allow
|
|
16
|
-
|
|
17
|
+
Add this module to your project by running `npm install -d @amedia/user`. This will allow for type-hinting, but will not include any code.
|
|
18
|
+
This means you must also set up import maps for loading the actual code. Just point `@amedia/user` to
|
|
17
19
|
`https://assets.acdn.no/pkg/@amedia/user/v0/user.js`.
|
|
18
20
|
|
|
19
21
|
See Ego, Bacchus or Saturn for examples on how to use this module through Eik.
|
|
@@ -37,6 +39,14 @@ different versions of this module, which in time will cause incompatibilities an
|
|
|
37
39
|
|
|
38
40
|
You can read more about Eik on [Slite](https://amedia.slite.com/app/channels/hOlqx3Miez/notes/iexhL4MZn3).
|
|
39
41
|
|
|
42
|
+
## Contributing to @amedia/user
|
|
43
|
+
|
|
44
|
+
Hey, thanks! :)
|
|
45
|
+
|
|
46
|
+
It's often nice to do development while testing on a real app. You may do so using `npm link`. When you run then `npm run build` this will expose actual code, letting you develop faster. This is because we still export user.js from the package, but replaces it content with an error if used directly.
|
|
47
|
+
|
|
48
|
+
PS: Remember to comment-out the module in import maps ;-)
|
|
49
|
+
|
|
40
50
|
## Getting user data
|
|
41
51
|
|
|
42
52
|
The most common use case for aID on newspapers is to get some kind of data about a user, this could be the user's name,
|
|
@@ -397,4 +407,4 @@ To publish a new version do the following:
|
|
|
397
407
|
- Update version number in `eik.json` to the same version as in `package.json`
|
|
398
408
|
- Run `npm run eik:package` (no publishing will be done unless packages passes lint, typings, tests and builds successfully)
|
|
399
409
|
- Run `npx eik package-alias @amedia/user <version from eik.json> <Alias version>`
|
|
400
|
-
Example: `npx eik package-alias @amedia/user 0.13.31 0`
|
|
410
|
+
Example: `npx eik package-alias @amedia/user 0.13.31 0`
|
package/dist/user.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
var ks=Object.create;var ft=Object.defineProperty,Fs=Object.defineProperties,js=Object.getOwnPropertyDescriptor,qs=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertyNames,Rn=Object.getOwnPropertySymbols,Bs=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty,$s=Object.prototype.propertyIsEnumerable;var Cn=(e,t,r)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,J=(e,t)=>{for(var r in t||(t={}))Tn.call(t,r)&&Cn(e,r,t[r]);if(Rn)for(var r of Rn(t))$s.call(t,r)&&Cn(e,r,t[r]);return e},ne=(e,t)=>Fs(e,qs(t)),Vs=e=>ft(e,"__esModule",{value:!0}),n=(e,t)=>ft(e,"name",{value:t,configurable:!0}),lt=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Gs=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ms(t))!Tn.call(e,o)&&o!=="default"&&ft(e,o,{get:()=>t[o],enumerable:!(r=js(t,o))||r.enumerable});return e},be=e=>Gs(Vs(ft(e!=null?ks(Bs(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 p=h=>{try{m(r.next(h))}catch(S){a(S)}},l=h=>{try{m(r.throw(h))}catch(S){a(S)}},m=h=>h.done?o(h.value):Promise.resolve(h.value).then(p,l);m((r=r.apply(e,t)).next())});var Un=L(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0})});var Tr=L(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.Failcode=void 0;Nt.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 He=L(We=>{"use strict";var ra=We&&We.__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 p in a)Object.prototype.hasOwnProperty.call(a,p)&&(o[p]=a[p])},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(We,"__esModule",{value:!0});We.ValidationError=void 0;var na=function(e){ra(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);We.ValidationError=na});var xt=L(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});var Ee=n(function(e,t){return function(r){var o=n(function(l){return e?"("+l+")":l},"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""+Dn(r)+Ee(!0,t)(r.element)+"[]";case"dictionary":return"{ [_: "+r.key+"]: "+Ee(!1,t)(r.value)+" }";case"record":{var p=Object.keys(r.fields);return p.length?"{ "+p.map(function(l){return""+Dn(r)+l+oa(r,l)+": "+(r.fields[l].tag==="optional"?Ee(!1,t)(r.fields[l].underlying):Ee(!1,t)(r.fields[l]))+";"}).join(" ")+" }":"{}"}case"tuple":return"["+r.components.map(Ee(!1,t)).join(", ")+"]";case"union":return o(""+r.alternatives.map(Ee(!0,t)).join(" | "));case"intersect":return o(""+r.intersectees.map(Ee(!0,t)).join(" & "));case"optional":return Ee(e,t)(r.underlying)+" | undefined";case"constraint":return r.name||Ee(e,t)(r.underlying);case"instanceof":return r.ctor.name;case"brand":return Ee(e,t)(r.entity)}}finally{t.delete(r)}throw Error("impossible")}},"show");Cr.default=Ee(!1,new Set);function oa(e,t){var r=e.isPartial,o=e.fields;return r||t!==void 0&&o[t].tag==="optional"?"?":""}n(oa,"partialTag");function Dn(e){var t=e.isReadonly;return t?"readonly ":""}n(Dn,"readonlyTag")});var z=L(M=>{"use strict";var Ar=M&&M.__assign||function(){return Ar=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},Ar.apply(this,arguments)};Object.defineProperty(M,"__esModule",{value:!0});M.FAILURE=M.SUCCESS=M.enumerableKeysOf=M.typeOf=M.hasKey=void 0;var Se=Tr(),ze=xt();function ia(e,t){return typeof t=="object"&&t!==null&&e in t}n(ia,"hasKey");M.hasKey=ia;var sa=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=sa;var aa=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=aa;function ua(e){return{success:!0,value:e}}n(ua,"SUCCESS");M.SUCCESS=ua;M.FAILURE=Object.assign(function(e,t,r){return Ar({success:!1,code:e,message:t},r?{details:r}:{})},{TYPE_INCORRECT:function(e,t){var r="Expected "+ze.default(e)+", but was "+M.typeOf(t);return M.FAILURE(Se.Failcode.TYPE_INCORRECT,r)},VALUE_INCORRECT:function(e,t,r){return M.FAILURE(Se.Failcode.VALUE_INCORRECT,"Expected "+e+" "+String(t)+", but was "+String(r))},KEY_INCORRECT:function(e,t,r){return M.FAILURE(Se.Failcode.KEY_INCORRECT,"Expected "+ze.default(e)+" key to be "+ze.default(t)+", but was "+M.typeOf(r))},CONTENT_INCORRECT:function(e,t){var r="Expected "+ze.default(e)+", but was incompatible";return M.FAILURE(Se.Failcode.CONTENT_INCORRECT,r,t)},ARGUMENT_INCORRECT:function(e){return M.FAILURE(Se.Failcode.ARGUMENT_INCORRECT,e)},RETURN_INCORRECT:function(e){return M.FAILURE(Se.Failcode.RETURN_INCORRECT,e)},CONSTRAINT_FAILED:function(e,t){var r=t?": "+t:"";return M.FAILURE(Se.Failcode.CONSTRAINT_FAILED,"Failed constraint check for "+ze.default(e)+r)},PROPERTY_MISSING:function(e){var t="Expected "+ze.default(e)+", but was missing";return M.FAILURE(Se.Failcode.PROPERTY_MISSING,t)},PROPERTY_PRESENT:function(e){var t="Expected nothing, but was "+M.typeOf(e);return M.FAILURE(Se.Failcode.PROPERTY_PRESENT,t)},NOTHING_EXPECTED:function(e){var t="Expected nothing, but was "+M.typeOf(e);return M.FAILURE(Se.Failcode.NOTHING_EXPECTED,t)}})});var Ln=L(Pe=>{"use strict";var ca=Pe&&Pe.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),a,p=[],l;try{for(;(t===void 0||t-- >0)&&!(a=o.next()).done;)p.push(a.value)}catch(m){l={error:m}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(l)throw l.error}}return p},fa=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.Contract=void 0;var la=He(),da=z();function pa(){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(p){return function(){for(var l=[],m=0;m<arguments.length;m++)l[m]=arguments[m];if(l.length<o.length){var h="Expected "+o.length+" arguments but only received "+l.length,S=da.FAILURE.ARGUMENT_INCORRECT(h);throw new la.ValidationError(S)}for(var w=0;w<o.length;w++)o[w].check(l[w]);return a.check(p.apply(void 0,fa([],ca(l))))}}}}n(pa,"Contract");Pe.Contract=pa});var jn=L(Ne=>{"use strict";var ma=Ne&&Ne.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),a,p=[],l;try{for(;(t===void 0||t-- >0)&&!(a=o.next()).done;)p.push(a.value)}catch(m){l={error:m}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(l)throw l.error}}return p},ha=Ne&&Ne.__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(Ne,"__esModule",{value:!0});Ne.AsyncContract=void 0;var kn=He(),Fn=z();function va(){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(p){return function(){for(var l=[],m=0;m<arguments.length;m++)l[m]=arguments[m];if(l.length<o.length){var h="Expected "+o.length+" arguments but only received "+l.length,S=Fn.FAILURE.ARGUMENT_INCORRECT(h);throw new kn.ValidationError(S)}for(var w=0;w<o.length;w++)o[w].check(l[w]);var T=p.apply(void 0,ha([],ma(l)));if(!(T instanceof Promise)){var h="Expected function to return a promise, but instead got "+T,S=Fn.FAILURE.RETURN_INCORRECT(h);throw new kn.ValidationError(S)}return T.then(a.check)}}}}n(va,"AsyncContract");Ne.AsyncContract=va});var qn=L(xe=>{"use strict";var ga=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.")},ya=xe&&xe.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),a,p=[],l;try{for(;(t===void 0||t-- >0)&&!(a=o.next()).done;)p.push(a.value)}catch(m){l={error:m}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(l)throw l.error}}return p};Object.defineProperty(xe,"__esModule",{value:!0});xe.match=void 0;function Ea(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(r){var o,a;try{for(var p=ga(e),l=p.next();!l.done;l=p.next()){var m=ya(l.value,2),h=m[0],S=m[1];if(h.guard(r))return S(r)}}catch(w){o={error:w}}finally{try{l&&!l.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}throw new Error("No alternatives were matched")}}n(Ea,"match");xe.match=Ea});var X=L(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.innerValidate=Qe.create=void 0;var Ue=De(),ba=xt(),_a=He(),Sa=z();function wa(e,t){return t.check=r,t.assert=r,t._innerValidate=function(T,g){return g.has(T,t)?Sa.SUCCESS(T):e(T,g)},t.validate=function(T){return t._innerValidate(T,Ta())},t.guard=o,t.Or=a,t.And=p,t.optional=l,t.nullable=m,t.withConstraint=h,t.withGuard=S,t.withBrand=w,t.reflect=t,t.toString=function(){return"Runtype<"+ba.default(t)+">"},t;function r(T){var g=t.validate(T);if(g.success)return g.value;throw new _a.ValidationError(g)}n(r,"check");function o(T){return t.validate(T).success}n(o,"guard");function a(T){return Ue.Union(t,T)}n(a,"Or");function p(T){return Ue.Intersect(t,T)}n(p,"And");function l(){return Ue.Optional(t)}n(l,"optional");function m(){return Ue.Union(t,Ue.Null)}n(m,"nullable");function h(T,g){return Ue.Constraint(t,T,g)}n(h,"withConstraint");function S(T,g){return Ue.Constraint(t,T,g)}n(S,"withGuard");function w(T){return Ue.Brand(T,t)}n(w,"withBrand")}n(wa,"create");Qe.create=wa;function Ra(e,t,r){return e._innerValidate(t,r)}n(Ra,"innerValidate");Qe.innerValidate=Ra;function Ta(){var e=new WeakMap,t=n(function(o,a){if(!(o===null||typeof o!="object")){var p=e.get(o);e.set(o,p?p.set(a,!0):new WeakMap().set(a,!0))}},"add"),r=n(function(o,a){var p=e.get(o),l=p&&p.get(a)||!1;return t(o,a),l},"has");return{has:r}}n(Ta,"VisitedState")});var Dt=L(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.Unknown=void 0;var Ca=X(),Aa=z(),Oa={tag:"unknown"};Ut.Unknown=Ca.create(function(e){return Aa.SUCCESS(e)},Oa)});var Mn=L(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.Never=void 0;var Ia=X(),Pa=z(),Na={tag:"never"};Lt.Never=Ia.create(Pa.FAILURE.NOTHING_EXPECTED,Na)});var Bn=L(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.Void=void 0;var xa=Dt();kt.Void=xa.Unknown});var Or=L(Je=>{"use strict";var Ft=Je&&Je.__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(Je,"__esModule",{value:!0});Je.Union=void 0;var jt=X(),mt=z();function Ua(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n(function(){for(var a=[],p=0;p<arguments.length;p++)a[p]=arguments[p];return function(l){for(var m=0;m<e.length;m++)if(e[m].guard(l))return a[m](l)}},"match"),o={tag:"union",alternatives:e,match:r};return jt.create(function(a,p){var l,m,h,S,w,T,g,C;if(typeof a!="object"||a===null){try{for(var x=Ft(e),k=x.next();!k.done;k=x.next()){var $=k.value;if(jt.innerValidate($,a,p).success)return mt.SUCCESS(a)}}catch(re){l={error:re}}finally{try{k&&!k.done&&(m=x.return)&&m.call(x)}finally{if(l)throw l.error}}return mt.FAILURE.TYPE_INCORRECT(o,a)}var G={};try{for(var ae=Ft(e),W=ae.next();!W.done;W=ae.next()){var $=W.value;if($.reflect.tag==="record"){var at=n(function(Z){var ce=$.reflect.fields[Z];ce.tag==="literal"&&(G[Z]?G[Z].every(function(Fe){return Fe!==ce.value})&&G[Z].push(ce.value):G[Z]=[ce.value])},"_loop_1");for(var ue in $.reflect.fields)at(ue)}}}catch(re){h={error:re}}finally{try{W&&!W.done&&(S=ae.return)&&S.call(ae)}finally{if(h)throw h.error}}for(var ue in G)if(G[ue].length===e.length)try{for(var R=(w=void 0,Ft(e)),D=R.next();!D.done;D=R.next()){var $=D.value;if($.reflect.tag==="record"){var N=$.reflect.fields[ue];if(N.tag==="literal"&&mt.hasKey(ue,a)&&a[ue]===N.value)return jt.innerValidate($,a,p)}}}catch(Z){w={error:Z}}finally{try{D&&!D.done&&(T=R.return)&&T.call(R)}finally{if(w)throw w.error}}try{for(var F=Ft(e),H=F.next();!H.done;H=F.next()){var ie=H.value;if(jt.innerValidate(ie,a,p).success)return mt.SUCCESS(a)}}catch(re){g={error:re}}finally{try{H&&!H.done&&(C=F.return)&&C.call(F)}finally{if(g)throw g.error}}return mt.FAILURE.TYPE_INCORRECT(o,a)},o)}n(Ua,"Union");Je.Union=Ua});var Gn=L(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.Nullish=me.Null=me.Undefined=me.Literal=void 0;var Da=X(),$n=z(),La=Or();function Vn(e){return Array.isArray(e)?String(e.map(String)):typeof e=="bigint"?String(e)+"n":String(e)}n(Vn,"literal");function Ir(e){var t={tag:"literal",value:e};return Da.create(function(r){return r===e?$n.SUCCESS(r):$n.FAILURE.VALUE_INCORRECT("literal","`"+Vn(e)+"`","`"+Vn(r)+"`")},t)}n(Ir,"Literal");me.Literal=Ir;me.Undefined=Ir(void 0);me.Null=Ir(null);me.Nullish=La.Union(me.Null,me.Undefined)});var Wn=L(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.Boolean=void 0;var ka=X(),Yn=z(),Kn={tag:"boolean"};qt.Boolean=ka.create(function(e){return typeof e=="boolean"?Yn.SUCCESS(e):Yn.FAILURE.TYPE_INCORRECT(Kn,e)},Kn)});var Qn=L(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.Number=void 0;var Fa=X(),Hn=z(),zn={tag:"number"};Mt.Number=Fa.create(function(e){return typeof e=="number"?Hn.SUCCESS(e):Hn.FAILURE.TYPE_INCORRECT(zn,e)},zn)});var Zn=L(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.BigInt=void 0;var ja=X(),Jn=z(),Xn={tag:"bigint"};Bt.BigInt=ja.create(function(e){return typeof e=="bigint"?Jn.SUCCESS(e):Jn.FAILURE.TYPE_INCORRECT(Xn,e)},Xn)});var Pr=L($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.String=void 0;var qa=X(),eo=z(),to={tag:"string"};$t.String=qa.create(function(e){return typeof e=="string"?eo.SUCCESS(e):eo.FAILURE.TYPE_INCORRECT(to,e)},to)});var io=L(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.Symbol=void 0;var ro=X(),ht=z(),Ma=n(function(e){var t={tag:"symbol",key:e};return ro.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",oo(e),oo(o)):ht.SUCCESS(r)},t)},"f"),no={tag:"symbol"};Vt.Symbol=ro.create(function(e){return typeof e=="symbol"?ht.SUCCESS(e):ht.FAILURE.TYPE_INCORRECT(no,e)},Object.assign(Ma,no));var oo=n(function(e){return e===void 0?"undefined":'"'+e+'"'},"quoteIfPresent")});var uo=L(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Array=void 0;var so=X(),vt=z();function ao(e,t){var r={tag:"array",isReadonly:t,element:e};return $a(so.create(function(o,a){if(!Array.isArray(o))return vt.FAILURE.TYPE_INCORRECT(r,o);var p=vt.enumerableKeysOf(o),l=p.map(function(h){return so.innerValidate(e,o[h],a)}),m=p.reduce(function(h,S){var w=l[S];return w.success||(h[S]=w.details||w.message),h},[]);return vt.enumerableKeysOf(m).length!==0?vt.FAILURE.CONTENT_INCORRECT(r,m):vt.SUCCESS(o)},r))}n(ao,"InternalArr");function Ba(e){return ao(e,!1)}n(Ba,"Arr");Gt.Array=Ba;function $a(e){return e.asReadonly=t,e;function t(){return ao(e.element,!0)}n(t,"asReadonly")}n($a,"withExtraModifierFuncs")});var fo=L(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.Tuple=void 0;var co=X(),Xe=z();function Va(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"tuple",components:e};return co.create(function(o,a){if(!Array.isArray(o))return Xe.FAILURE.TYPE_INCORRECT(r,o);if(o.length!==e.length)return Xe.FAILURE.CONSTRAINT_FAILED(r,"Expected length "+e.length+", but was "+o.length);var p=Xe.enumerableKeysOf(o),l=p.map(function(h){return co.innerValidate(e[h],o[h],a)}),m=p.reduce(function(h,S){var w=l[S];return w.success||(h[S]=w.details||w.message),h},[]);return Xe.enumerableKeysOf(m).length!==0?Xe.FAILURE.CONTENT_INCORRECT(r,m):Xe.SUCCESS(o)},r)}n(Va,"Tuple");Yt.Tuple=Va});var po=L(he=>{"use strict";var Nr=he&&he.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),a,p=[],l;try{for(;(t===void 0||t-- >0)&&!(a=o.next()).done;)p.push(a.value)}catch(m){l={error:m}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(l)throw l.error}}return p},xr=he&&he.__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(he,"__esModule",{value:!0});he.Partial=he.Record=he.InternalRecord=void 0;var lo=X(),de=z();function Le(e,t,r){var o={tag:"record",isPartial:t,isReadonly:r,fields:e};return Ka(lo.create(function(a,p){if(a==null)return de.FAILURE.TYPE_INCORRECT(o,a);var l=de.enumerableKeysOf(e);if(l.length!==0&&typeof a!="object")return de.FAILURE.TYPE_INCORRECT(o,a);var m=xr([],Nr(new Set(xr(xr([],Nr(l)),Nr(de.enumerableKeysOf(a)))))),h=m.reduce(function(w,T){var g=de.hasKey(T,e),C=de.hasKey(T,a);if(g){var x=e[T],k=t||x.reflect.tag==="optional";if(C){var $=a[T];k&&$===void 0?w[T]=de.SUCCESS($):w[T]=lo.innerValidate(x,$,p)}else k?w[T]=de.SUCCESS(void 0):w[T]=de.FAILURE.PROPERTY_MISSING(x.reflect)}else if(C){var $=a[T];w[T]=de.SUCCESS($)}else throw new Error("impossible");return w},{}),S=m.reduce(function(w,T){var g=h[T];return g.success||(w[T]=g.details||g.message),w},{});return de.enumerableKeysOf(S).length!==0?de.FAILURE.CONTENT_INCORRECT(o,S):de.SUCCESS(a)},o))}n(Le,"InternalRecord");he.InternalRecord=Le;function Ga(e){return Le(e,!1,!1)}n(Ga,"Record");he.Record=Ga;function Ya(e){return Le(e,!0,!1)}n(Ya,"Partial");he.Partial=Ya;function Ka(e){return e.asPartial=t,e.asReadonly=r,e.pick=o,e.omit=a,e.extend=p,e;function t(){return Le(e.fields,!0,e.isReadonly)}n(t,"asPartial");function r(){return Le(e.fields,e.isPartial,!0)}n(r,"asReadonly");function o(){for(var l=[],m=0;m<arguments.length;m++)l[m]=arguments[m];var h={};return l.forEach(function(S){h[S]=e.fields[S]}),Le(h,e.isPartial,e.isReadonly)}n(o,"pick");function a(){for(var l=[],m=0;m<arguments.length;m++)l[m]=arguments[m];var h={},S=de.enumerableKeysOf(e.fields);return S.forEach(function(w){l.includes(w)||(h[w]=e.fields[w])}),Le(h,e.isPartial,e.isReadonly)}n(a,"omit");function p(l){return Le(Object.assign({},e.fields,l),e.isPartial,e.isReadonly)}n(p,"extend")}n(Ka,"withExtraModifierFuncs")});var Dr=L(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.Guard=Ze.Constraint=void 0;var Wa=X(),Ur=z(),Ha=Dt();function za(e,t,r){var o=r&&r.name,a=r&&r.args,p={tag:"constraint",underlying:e,constraint:t,name:o,args:a};return Wa.create(function(l){var m=e.validate(l);if(!m.success)return m;var h=t(m.value);return typeof h=="string"?Ur.FAILURE.CONSTRAINT_FAILED(p,h):h?Ur.SUCCESS(m.value):Ur.FAILURE.CONSTRAINT_FAILED(p)},p)}n(za,"Constraint");Ze.Constraint=za;var Qa=n(function(e,t){return Ha.Unknown.withGuard(e,t)},"Guard");Ze.Guard=Qa});var ho=L(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.Dictionary=void 0;var mo=X(),Lr=Pr(),Ja=Dr(),Xa=xt(),je=z(),Za=Ja.Constraint(Lr.String,function(e){return!isNaN(+e)},{name:"number"});function eu(e,t){var r=t===void 0||t==="string"?Lr.String:t==="number"?Za:t,o=Xa.default(r),a={tag:"dictionary",key:o,value:e};return mo.create(function(p,l){if(p==null||typeof p!="object"||Object.getPrototypeOf(p)!==Object.prototype&&(!Array.isArray(p)||o==="string"))return je.FAILURE.TYPE_INCORRECT(a,p);var m=/^(?:NaN|-?\d+(?:\.\d+)?)$/,h=je.enumerableKeysOf(p),S=h.reduce(function(T,g){var C=typeof g=="string"&&m.test(g),x=C?globalThis.Number(g):g;return(C?!r.guard(x)&&!r.guard(g):!r.guard(x))?T[g]=je.FAILURE.KEY_INCORRECT(a,r.reflect,x):T[g]=mo.innerValidate(e,p[g],l),T},{}),w=h.reduce(function(T,g){var C=S[g];return C.success||(T[g]=C.details||C.message),T},{});return je.enumerableKeysOf(w).length!==0?je.FAILURE.CONTENT_INCORRECT(a,w):je.SUCCESS(p)},a)}n(eu,"Dictionary");Kt.Dictionary=eu});var go=L(et=>{"use strict";var tu=et&&et.__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(et,"__esModule",{value:!0});et.Intersect=void 0;var vo=X(),ru=z();function nu(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r={tag:"intersect",intersectees:e};return vo.create(function(o,a){var p,l;try{for(var m=tu(e),h=m.next();!h.done;h=m.next()){var S=h.value,w=vo.innerValidate(S,o,a);if(!w.success)return w}}catch(T){p={error:T}}finally{try{h&&!h.done&&(l=m.return)&&l.call(m)}finally{if(p)throw p.error}}return ru.SUCCESS(o)},r)}n(nu,"Intersect");et.Intersect=nu});var yo=L(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.Optional=void 0;var ou=X(),iu=z();function su(e){var t={tag:"optional",underlying:e};return ou.create(function(r){return r===void 0?iu.SUCCESS(r):e.validate(r)},t)}n(su,"Optional");Wt.Optional=su});var _o=L(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.Function=void 0;var au=X(),Eo=z(),bo={tag:"function"};Ht.Function=au.create(function(e){return typeof e=="function"?Eo.SUCCESS(e):Eo.FAILURE.TYPE_INCORRECT(bo,e)},bo)});var wo=L(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.InstanceOf=void 0;var uu=X(),So=z();function cu(e){var t={tag:"instanceof",ctor:e};return uu.create(function(r){return r instanceof e?So.SUCCESS(r):So.FAILURE.TYPE_INCORRECT(t,r)},t)}n(cu,"InstanceOf");zt.InstanceOf=cu});var Ro=L(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.Lazy=void 0;var fu=X();function lu(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"),fu.create(function(a){return o().validate(a)},t)}n(lu,"Lazy");Qt.Lazy=lu});var To=L(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.Brand=void 0;var du=X();function pu(e,t){var r={tag:"brand",brand:e,entity:t};return du.create(function(o){return t.validate(o)},r)}n(pu,"Brand");Jt.Brand=pu});var Co=L(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.checked=tt.check=void 0;var mu=He(),hu=z(),kr=new WeakMap;function vu(e,t,r){var o=kr.get(e)||new Map;kr.set(e,o);var a=o.get(t)||[];o.set(t,a),a.push(r)}n(vu,"check");tt.check=vu;function gu(e,t,r){var o=kr.get(e),a=o&&o.get(t);if(a)return a;for(var p=[],l=0;l<r;l++)p.push(l);return p}n(gu,"getValidParameterIndices");function yu(){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 p=a.value,l=(r.name||r.constructor.name+".prototype")+(typeof o=="string"?'["'+o+'"]':"["+String(o)+"]"),m=gu(r,o,e.length);if(m.length!==e.length)throw new Error("Number of `@checked` runtypes and @check parameters not matched.");if(m.length>p.length)throw new Error("Number of `@checked` runtypes exceeds actual parameter length.");a.value=function(){for(var h=[],S=0;S<arguments.length;S++)h[S]=arguments[S];return e.forEach(function(w,T){var g=m[T],C=w.validate(h[g]);if(!C.success){var x=l+", argument #"+g+": "+C.message,k=hu.FAILURE.ARGUMENT_INCORRECT(x);throw new mu.ValidationError(k)}}),p.apply(this,h)}}}n(yu,"checked");tt.checked=yu});var De=L(P=>{"use strict";var Eu=P&&P.__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=P&&P.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Eu(t,e,r)};Object.defineProperty(P,"__esModule",{value:!0});P.InstanceOf=P.Nullish=P.Null=P.Undefined=P.Literal=void 0;Y(Un(),P);Y(Tr(),P);Y(Ln(),P);Y(jn(),P);Y(qn(),P);Y(He(),P);Y(Dt(),P);Y(Mn(),P);Y(Bn(),P);var Xt=Gn();Object.defineProperty(P,"Literal",{enumerable:!0,get:function(){return Xt.Literal}});Object.defineProperty(P,"Undefined",{enumerable:!0,get:function(){return Xt.Undefined}});Object.defineProperty(P,"Null",{enumerable:!0,get:function(){return Xt.Null}});Object.defineProperty(P,"Nullish",{enumerable:!0,get:function(){return Xt.Nullish}});Y(Wn(),P);Y(Qn(),P);Y(Zn(),P);Y(Pr(),P);Y(io(),P);Y(uo(),P);Y(fo(),P);Y(po(),P);Y(ho(),P);Y(Or(),P);Y(go(),P);Y(yo(),P);Y(_o(),P);var bu=wo();Object.defineProperty(P,"InstanceOf",{enumerable:!0,get:function(){return bu.InstanceOf}});Y(Ro(),P);Y(Dr(),P);Y(To(),P);Y(Co(),P)});var Mr=L(qr=>{"use strict";Object.defineProperty(qr,"__esModule",{value:!0});var Oo=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"),Io=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]))):Oo(r[a])&&Oo(o[a])?r[a]=Io(r[a],o[a]):r[a]=o[a]}),r},{})},"merge");qr.default=Io});var li=L((fi,Hr)=>{(function(e){if(typeof fi=="object"&&typeof Hr!="undefined")Hr.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,p,l){function m(w,T){if(!p[w]){if(!a[w]){var g=typeof lt=="function"&<if(!T&&g)return g(w,!0);if(h)return h(w,!0);var C=new Error("Cannot find module '"+w+"'");throw C.code="MODULE_NOT_FOUND",C}var x=p[w]={exports:{}};a[w][0].call(x.exports,function(k){var $=a[w][1][k];return m($||k)},x,x.exports,o,a,p,l)}return p[w].exports}n(m,"s");for(var h=typeof lt=="function"&<,S=0;S<l.length;S++)m(l[S]);return m},"e")({1:[function(o,a,p){(function(l){"use strict";var m=l.MutationObserver||l.WebKitMutationObserver,h;if(m){var S=0,w=new m(k),T=l.document.createTextNode("");w.observe(T,{characterData:!0}),h=n(function(){T.data=S=++S%2},"scheduleDrain")}else if(!l.setImmediate&&typeof l.MessageChannel!="undefined"){var g=new l.MessageChannel;g.port1.onmessage=k,h=n(function(){g.port2.postMessage(0)},"scheduleDrain")}else"document"in l&&"onreadystatechange"in l.document.createElement("script")?h=n(function(){var G=l.document.createElement("script");G.onreadystatechange=function(){k(),G.onreadystatechange=null,G.parentNode.removeChild(G),G=null},l.document.documentElement.appendChild(G)},"scheduleDrain"):h=n(function(){setTimeout(k,0)},"scheduleDrain");var C,x=[];function k(){C=!0;for(var G,ae,W=x.length;W;){for(ae=x,x=[],G=-1;++G<W;)ae[G]();W=x.length}C=!1}n(k,"nextTick"),a.exports=$;function $(G){x.push(G)===1&&!C&&h()}n($,"immediate")}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(o,a,p){"use strict";var l=o(1);function m(){}n(m,"INTERNAL");var h={},S=["REJECTED"],w=["FULFILLED"],T=["PENDING"];a.exports=g;function g(R){if(typeof R!="function")throw new TypeError("resolver must be a function");this.state=T,this.queue=[],this.outcome=void 0,R!==m&&$(this,R)}n(g,"Promise"),g.prototype.catch=function(R){return this.then(null,R)},g.prototype.then=function(R,D){if(typeof R!="function"&&this.state===w||typeof D!="function"&&this.state===S)return this;var N=new this.constructor(m);if(this.state!==T){var F=this.state===w?R:D;x(N,F,this.outcome)}else this.queue.push(new C(N,R,D));return N};function C(R,D,N){this.promise=R,typeof D=="function"&&(this.onFulfilled=D,this.callFulfilled=this.otherCallFulfilled),typeof N=="function"&&(this.onRejected=N,this.callRejected=this.otherCallRejected)}n(C,"QueueItem"),C.prototype.callFulfilled=function(R){h.resolve(this.promise,R)},C.prototype.otherCallFulfilled=function(R){x(this.promise,this.onFulfilled,R)},C.prototype.callRejected=function(R){h.reject(this.promise,R)},C.prototype.otherCallRejected=function(R){x(this.promise,this.onRejected,R)};function x(R,D,N){l(function(){var F;try{F=D(N)}catch(H){return h.reject(R,H)}F===R?h.reject(R,new TypeError("Cannot resolve promise with itself")):h.resolve(R,F)})}n(x,"unwrap"),h.resolve=function(R,D){var N=G(k,D);if(N.status==="error")return h.reject(R,N.value);var F=N.value;if(F)$(R,F);else{R.state=w,R.outcome=D;for(var H=-1,ie=R.queue.length;++H<ie;)R.queue[H].callFulfilled(D)}return R},h.reject=function(R,D){R.state=S,R.outcome=D;for(var N=-1,F=R.queue.length;++N<F;)R.queue[N].callRejected(D);return R};function k(R){var D=R&&R.then;if(R&&(typeof R=="object"||typeof R=="function")&&typeof D=="function")return n(function(){D.apply(R,arguments)},"appyThen")}n(k,"getThen");function $(R,D){var N=!1;function F(Z){N||(N=!0,h.reject(R,Z))}n(F,"onError");function H(Z){N||(N=!0,h.resolve(R,Z))}n(H,"onSuccess");function ie(){D(H,F)}n(ie,"tryToUnwrap");var re=G(ie);re.status==="error"&&F(re.value)}n($,"safelyResolveThenable");function G(R,D){var N={};try{N.value=R(D),N.status="success"}catch(F){N.status="error",N.value=F}return N}n(G,"tryCatch"),g.resolve=ae;function ae(R){return R instanceof this?R:h.resolve(new this(m),R)}n(ae,"resolve"),g.reject=W;function W(R){var D=new this(m);return h.reject(D,R)}n(W,"reject"),g.all=at;function at(R){var D=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),ie=0,re=-1,Z=new this(m);++re<N;)ce(R[re],re);return Z;function ce(Fe,Tt){D.resolve(Fe).then(pr,function(Ge){F||(F=!0,h.reject(Z,Ge))});function pr(Ge){H[Tt]=Ge,++ie===N&&!F&&(F=!0,h.resolve(Z,H))}n(pr,"resolveFromAll")}}n(at,"all"),g.race=ue;function ue(R){var D=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,ie=new this(m);++H<N;)re(R[H]);return ie;function re(Z){D.resolve(Z).then(function(ce){F||(F=!0,h.resolve(ie,ce))},function(ce){F||(F=!0,h.reject(ie,ce))})}}n(ue,"race")},{"1":1}],3:[function(o,a,p){(function(l){"use strict";typeof l.Promise!="function"&&(l.Promise=o(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"2":2}],4:[function(o,a,p){"use strict";var l=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 h(){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(h,"getIDB");var S=h();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 T(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,d=0;d<i.length;d+=1)f.append(i[d]);return f.getBlob(u.type)}}n(T,"createBlob"),typeof Promise=="undefined"&&o(3);var g=Promise;function C(i,u){u&&i.then(function(s){u(null,s)},function(s){u(s)})}n(C,"executeCallback");function x(i,u,s){typeof u=="function"&&i.then(u),typeof s=="function"&&i.catch(s)}n(x,"executeTwoCallbacks");function k(i){return typeof i!="string"&&(console.warn(i+" used as a key, but it is not a string."),i=String(i)),i}n(k,"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",ae=void 0,W={},at=Object.prototype.toString,ue="readonly",R="readwrite";function D(i){for(var u=i.length,s=new ArrayBuffer(u),f=new Uint8Array(s),d=0;d<u;d++)f[d]=i.charCodeAt(d);return s}n(D,"_binStringToArrayBuffer");function N(i){return new g(function(u){var s=i.transaction(G,R),f=T([""]);s.objectStore(G).put(f,"key"),s.onabort=function(d){d.preventDefault(),d.stopPropagation(),u(!1)},s.oncomplete=function(){var d=navigator.userAgent.match(/Chrome\/(\d+)/),c=navigator.userAgent.match(/Edge\//);u(c||!d||parseInt(d[1],10)>=43)}}).catch(function(){return!1})}n(N,"_checkBlobSupportWithoutCaching");function F(i){return typeof ae=="boolean"?g.resolve(ae):N(i).then(function(u){return ae=u,ae})}n(F,"_checkBlobSupport");function H(i){var u=W[i.name],s={};s.promise=new g(function(f,d){s.resolve=f,s.reject=d}),u.deferredOperations.push(s),u.dbReady?u.dbReady=u.dbReady.then(function(){return s.promise}):u.dbReady=s.promise}n(H,"_deferReadiness");function ie(i){var u=W[i.name],s=u.deferredOperations.pop();if(s)return s.resolve(),s.promise}n(ie,"_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 Z(i,u){return new g(function(s,f){if(W[i.name]=W[i.name]||nn(),i.db)if(u)H(i),i.db.close();else return s(i.db);var d=[i.name];u&&d.push(i.version);var c=S.open.apply(S,d);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),ie(i)}})}n(Z,"_getConnection");function ce(i){return Z(i,!1)}n(ce,"_getOriginalConnection");function Fe(i){return Z(i,!0)}n(Fe,"_getUpgradedConnection");function Tt(i,u){if(!i.db)return!0;var s=!i.db.objectStoreNames.contains(i.storeName),f=i.version<i.db.version,d=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),d||s){if(s){var c=i.db.version+1;c>i.version&&(i.version=c)}return!0}return!1}n(Tt,"_isUpgradeNeeded");function pr(i){return new g(function(u,s){var f=new FileReader;f.onerror=s,f.onloadend=function(d){var c=btoa(d.target.result||"");u({__local_forage_encoded_blob:!0,data:c,type:i.type})},f.readAsBinaryString(i)})}n(pr,"_encodeBlob");function Ge(i){var u=D(atob(i.data));return T([u],{type:i.type})}n(Ge,"_decodeBlob");function rn(i){return i&&i.__local_forage_encoded_blob}n(rn,"_isEncodedBlob");function Fi(i){var u=this,s=u._initReady().then(function(){var f=W[u._dbInfo.name];if(f&&f.dbReady)return f.dbReady});return x(s,i,i),s}n(Fi,"_fullyReady");function ji(i){H(i);for(var u=W[i.name],s=u.forages,f=0;f<s.length;f++){var d=s[f];d._dbInfo.db&&(d._dbInfo.db.close(),d._dbInfo.db=null)}return i.db=null,ce(i).then(function(c){return i.db=c,Tt(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(ji,"_tryReconnect");function Re(i,u,s,f){f===void 0&&(f=1);try{var d=i.db.transaction(i.storeName,u);s(null,d)}catch(c){if(f>0&&(!i.db||c.name==="InvalidStateError"||c.name==="NotFoundError"))return g.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 ji(i).then(function(){Re(i,u,s,f-1)})}).catch(s);s(c)}}n(Re,"createTransaction");function nn(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}n(nn,"createDbContext");function qi(i){var u=this,s={db:null};if(i)for(var f in i)s[f]=i[f];var d=W[s.name];d||(d=nn(),W[s.name]=d),d.forages.push(u),u._initReady||(u._initReady=u.ready,u.ready=Fi);var c=[];function v(){return g.resolve()}n(v,"ignoreErrors");for(var y=0;y<d.forages.length;y++){var E=d.forages[y];E!==u&&c.push(E._initReady().catch(v))}var b=d.forages.slice(0);return g.all(c).then(function(){return s.db=d.db,ce(s)}).then(function(_){return s.db=_,Tt(s,u._defaultConfig.version)?Fe(s):_}).then(function(_){s.db=d.db=_,u._dbInfo=s;for(var A=0;A<b.length;A++){var U=b[A];U!==u&&(U._dbInfo.db=s.db,U._dbInfo.version=s.version)}})}n(qi,"_initStorage");function Mi(i,u){var s=this;i=k(i);var f=new g(function(d,c){s.ready().then(function(){Re(s._dbInfo,ue,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),rn(_)&&(_=Ge(_)),d(_)},b.onerror=function(){c(b.error)}}catch(_){c(_)}})}).catch(c)});return C(f,u),f}n(Mi,"getItem");function Bi(i,u){var s=this,f=new g(function(d,c){s.ready().then(function(){Re(s._dbInfo,ue,function(v,y){if(v)return c(v);try{var E=y.objectStore(s._dbInfo.storeName),b=E.openCursor(),_=1;b.onsuccess=function(){var A=b.result;if(A){var U=A.value;rn(U)&&(U=Ge(U));var j=i(U,A.key,_++);j!==void 0?d(j):A.continue()}else d()},b.onerror=function(){c(b.error)}}catch(A){c(A)}})}).catch(c)});return C(f,u),f}n(Bi,"iterate");function $i(i,u,s){var f=this;i=k(i);var d=new g(function(c,v){var y;f.ready().then(function(){return y=f._dbInfo,at.call(u)==="[object Blob]"?F(y.db).then(function(E){return E?u:pr(u)}):u}).then(function(E){Re(f._dbInfo,R,function(b,_){if(b)return v(b);try{var A=_.objectStore(f._dbInfo.storeName);E===null&&(E=void 0);var U=A.put(E,i);_.oncomplete=function(){E===void 0&&(E=null),c(E)},_.onabort=_.onerror=function(){var j=U.error?U.error:U.transaction.error;v(j)}}catch(j){v(j)}})}).catch(v)});return C(d,s),d}n($i,"setItem");function Vi(i,u){var s=this;i=k(i);var f=new g(function(d,c){s.ready().then(function(){Re(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(){d()},y.onerror=function(){c(b.error)},y.onabort=function(){var _=b.error?b.error:b.transaction.error;c(_)}}catch(_){c(_)}})}).catch(c)});return C(f,u),f}n(Vi,"removeItem");function Gi(i){var u=this,s=new g(function(f,d){u.ready().then(function(){Re(u._dbInfo,R,function(c,v){if(c)return d(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;d(b)}}catch(b){d(b)}})}).catch(d)});return C(s,i),s}n(Gi,"clear");function Yi(i){var u=this,s=new g(function(f,d){u.ready().then(function(){Re(u._dbInfo,ue,function(c,v){if(c)return d(c);try{var y=v.objectStore(u._dbInfo.storeName),E=y.count();E.onsuccess=function(){f(E.result)},E.onerror=function(){d(E.error)}}catch(b){d(b)}})}).catch(d)});return C(s,i),s}n(Yi,"length");function Ki(i,u){var s=this,f=new g(function(d,c){if(i<0){d(null);return}s.ready().then(function(){Re(s._dbInfo,ue,function(v,y){if(v)return c(v);try{var E=y.objectStore(s._dbInfo.storeName),b=!1,_=E.openKeyCursor();_.onsuccess=function(){var A=_.result;if(!A){d(null);return}i===0||b?d(A.key):(b=!0,A.advance(i))},_.onerror=function(){c(_.error)}}catch(A){c(A)}})}).catch(c)});return C(f,u),f}n(Ki,"key");function Wi(i){var u=this,s=new g(function(f,d){u.ready().then(function(){Re(u._dbInfo,ue,function(c,v){if(c)return d(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(){d(E.error)}}catch(_){d(_)}})}).catch(d)});return C(s,i),s}n(Wi,"keys");function Hi(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,d;if(!i.name)d=g.reject("Invalid arguments");else{var c=i.name===s.name&&f._dbInfo.db,v=c?g.resolve(f._dbInfo.db):ce(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?d=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 A=0;A<_.length;A++){var U=_[A];U._dbInfo.db=null,U._dbInfo.version=E}var j=new g(function(q,te){var ee=S.open(i.name,E);ee.onerror=function(se){var ct=ee.result;ct.close(),te(se)},ee.onupgradeneeded=function(){var se=ee.result;se.deleteObjectStore(i.storeName)},ee.onsuccess=function(){var se=ee.result;se.close(),q(se)}});return j.then(function(q){b.db=q;for(var te=0;te<_.length;te++){var ee=_[te];ee._dbInfo.db=q,ie(ee._dbInfo)}}).catch(function(q){throw(re(i,q)||g.resolve()).catch(function(){}),q})}}):d=v.then(function(y){H(i);var E=W[i.name],b=E.forages;y.close();for(var _=0;_<b.length;_++){var A=b[_];A._dbInfo.db=null}var U=new g(function(j,q){var te=S.deleteDatabase(i.name);te.onerror=te.onblocked=function(ee){var se=te.result;se&&se.close(),q(ee)},te.onsuccess=function(){var ee=te.result;ee&&ee.close(),j(ee)}});return U.then(function(j){E.db=j;for(var q=0;q<b.length;q++){var te=b[q];ie(te._dbInfo)}}).catch(function(j){throw(re(i,j)||g.resolve()).catch(function(){}),j})})}return C(d,u),d}n(Hi,"dropInstance");var zi={_driver:"asyncStorage",_initStorage:qi,_support:w(),iterate:Bi,getItem:Mi,setItem:$i,removeItem:Vi,clear:Gi,length:Yi,key:Ki,keys:Wi,dropInstance:Hi};function Qi(){return typeof openDatabase=="function"}n(Qi,"isWebSQLValid");var Oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ji="~~local_forage_type~",on=/^~~local_forage_type~([^~]+)~/,Ct="__lfsc__:",mr=Ct.length,hr="arbf",vr="blob",sn="si08",an="ui08",un="uic8",cn="si16",fn="si32",ln="ur16",dn="ui32",pn="fl32",mn="fl64",hn=mr+hr.length,vn=Object.prototype.toString;function gn(i){var u=i.length*.75,s=i.length,f,d=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=Oe.indexOf(i[f]),v=Oe.indexOf(i[f+1]),y=Oe.indexOf(i[f+2]),E=Oe.indexOf(i[f+3]),_[d++]=c<<2|v>>4,_[d++]=(v&15)<<4|y>>2,_[d++]=(y&3)<<6|E&63;return b}n(gn,"stringToBuffer");function gr(i){var u=new Uint8Array(i),s="",f;for(f=0;f<u.length;f+=3)s+=Oe[u[f]>>2],s+=Oe[(u[f]&3)<<4|u[f+1]>>4],s+=Oe[(u[f+1]&15)<<2|u[f+2]>>6],s+=Oe[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(gr,"bufferToString");function Xi(i,u){var s="";if(i&&(s=vn.call(i)),i&&(s==="[object ArrayBuffer]"||i.buffer&&vn.call(i.buffer)==="[object ArrayBuffer]")){var f,d=Ct;i instanceof ArrayBuffer?(f=i,d+=hr):(f=i.buffer,s==="[object Int8Array]"?d+=sn:s==="[object Uint8Array]"?d+=an:s==="[object Uint8ClampedArray]"?d+=un:s==="[object Int16Array]"?d+=cn:s==="[object Uint16Array]"?d+=ln:s==="[object Int32Array]"?d+=fn:s==="[object Uint32Array]"?d+=dn:s==="[object Float32Array]"?d+=pn:s==="[object Float64Array]"?d+=mn:u(new Error("Failed to get type for BinaryArray"))),u(d+gr(f))}else if(s==="[object Blob]"){var c=new FileReader;c.onload=function(){var v=Ji+i.type+"~"+gr(this.result);u(Ct+vr+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(Xi,"serialize");function Zi(i){if(i.substring(0,mr)!==Ct)return JSON.parse(i);var u=i.substring(hn),s=i.substring(mr,hn),f;if(s===vr&&on.test(u)){var d=u.match(on);f=d[1],u=u.substring(d[0].length)}var c=gn(u);switch(s){case hr:return c;case vr:return T([c],{type:f});case sn:return new Int8Array(c);case an:return new Uint8Array(c);case un:return new Uint8ClampedArray(c);case cn:return new Int16Array(c);case ln:return new Uint16Array(c);case fn:return new Int32Array(c);case dn:return new Uint32Array(c);case pn:return new Float32Array(c);case mn:return new Float64Array(c);default:throw new Error("Unkown type: "+s)}}n(Zi,"deserialize");var yr={serialize:Xi,deserialize:Zi,stringToBuffer:gn,bufferToString:gr};function yn(i,u,s,f){i.executeSql("CREATE TABLE IF NOT EXISTS "+u.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],s,f)}n(yn,"createDbTable");function es(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 d=new g(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){yn(y,s,function(){u._dbInfo=s,c()},function(E,b){v(b)})},v)});return s.serializer=yr,d}n(es,"_initStorage$1");function Ie(i,u,s,f,d,c){i.executeSql(s,f,d,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):yn(E,u,function(){E.executeSql(s,f,d,c)},c)},c):c(v,y)},c)}n(Ie,"tryExecuteSql");function ts(i,u){var s=this;i=k(i);var f=new g(function(d,c){s.ready().then(function(){var v=s._dbInfo;v.db.transaction(function(y){Ie(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(_)),d(_)},function(E,b){c(b)})})}).catch(c)});return C(f,u),f}n(ts,"getItem$1");function rs(i,u){var s=this,f=new g(function(d,c){s.ready().then(function(){var v=s._dbInfo;v.db.transaction(function(y){Ie(y,v,"SELECT * FROM "+v.storeName,[],function(E,b){for(var _=b.rows,A=_.length,U=0;U<A;U++){var j=_.item(U),q=j.value;if(q&&(q=v.serializer.deserialize(q)),q=i(q,j.key,U+1),q!==void 0){d(q);return}}d()},function(E,b){c(b)})})}).catch(c)});return C(f,u),f}n(rs,"iterate$1");function En(i,u,s,f){var d=this;i=k(i);var c=new g(function(v,y){d.ready().then(function(){u===void 0&&(u=null);var E=u,b=d._dbInfo;b.serializer.serialize(u,function(_,A){A?y(A):b.db.transaction(function(U){Ie(U,b,"INSERT OR REPLACE INTO "+b.storeName+" (key, value) VALUES (?, ?)",[i,_],function(){v(E)},function(j,q){y(q)})},function(U){if(U.code===U.QUOTA_ERR){if(f>0){v(En.apply(d,[i,E,s,f-1]));return}y(U)}})})}).catch(y)});return C(c,s),c}n(En,"_setItem");function ns(i,u,s){return En.apply(this,[i,u,s,1])}n(ns,"setItem$1");function os(i,u){var s=this;i=k(i);var f=new g(function(d,c){s.ready().then(function(){var v=s._dbInfo;v.db.transaction(function(y){Ie(y,v,"DELETE FROM "+v.storeName+" WHERE key = ?",[i],function(){d()},function(E,b){c(b)})})}).catch(c)});return C(f,u),f}n(os,"removeItem$1");function is(i){var u=this,s=new g(function(f,d){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(v){Ie(v,c,"DELETE FROM "+c.storeName,[],function(){f()},function(y,E){d(E)})})}).catch(d)});return C(s,i),s}n(is,"clear$1");function ss(i){var u=this,s=new g(function(f,d){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(v){Ie(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){d(E)})})}).catch(d)});return C(s,i),s}n(ss,"length$1");function as(i,u){var s=this,f=new g(function(d,c){s.ready().then(function(){var v=s._dbInfo;v.db.transaction(function(y){Ie(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;d(_)},function(E,b){c(b)})})}).catch(c)});return C(f,u),f}n(as,"key$1");function us(i){var u=this,s=new g(function(f,d){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(v){Ie(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){d(E)})})}).catch(d)});return C(s,i),s}n(us,"keys$1");function cs(i){return new g(function(u,s){i.transaction(function(f){f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(d,c){for(var v=[],y=0;y<c.rows.length;y++)v.push(c.rows.item(y).name);u({db:i,storeNames:v})},function(d,c){s(c)})},function(f){s(f)})})}n(cs,"getAllStoreNames");function fs(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,d;return i.name?d=new g(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(cs(v))}).then(function(c){return new g(function(v,y){c.db.transaction(function(E){function b(j){return new g(function(q,te){E.executeSql("DROP TABLE IF EXISTS "+j,[],function(){q()},function(ee,se){te(se)})})}n(b,"dropTable");for(var _=[],A=0,U=c.storeNames.length;A<U;A++)_.push(b(c.storeNames[A]));g.all(_).then(function(){v()}).catch(function(j){y(j)})},function(E){y(E)})})}):d=g.reject("Invalid arguments"),C(d,u),d}n(fs,"dropInstance$1");var ls={_driver:"webSQLStorage",_initStorage:es,_support:Qi(),iterate:rs,getItem:ts,setItem:ns,removeItem:os,clear:is,length:ss,key:as,keys:us,dropInstance:fs};function ds(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(i){return!1}}n(ds,"isLocalStorageValid");function bn(i,u){var s=i.name+"/";return i.storeName!==u.storeName&&(s+=i.storeName+"/"),s}n(bn,"_getKeyPrefix");function ps(){var i="_localforage_support_test";try{return localStorage.setItem(i,!0),localStorage.removeItem(i),!1}catch(u){return!0}}n(ps,"checkIfLocalStorageThrows");function ms(){return!ps()||localStorage.length>0}n(ms,"_isLocalStorageUsable");function hs(i){var u=this,s={};if(i)for(var f in i)s[f]=i[f];return s.keyPrefix=bn(i,u._defaultConfig),ms()?(u._dbInfo=s,s.serializer=yr,g.resolve()):g.reject()}n(hs,"_initStorage$2");function vs(i){var u=this,s=u.ready().then(function(){for(var f=u._dbInfo.keyPrefix,d=localStorage.length-1;d>=0;d--){var c=localStorage.key(d);c.indexOf(f)===0&&localStorage.removeItem(c)}});return C(s,i),s}n(vs,"clear$2");function gs(i,u){var s=this;i=k(i);var f=s.ready().then(function(){var d=s._dbInfo,c=localStorage.getItem(d.keyPrefix+i);return c&&(c=d.serializer.deserialize(c)),c});return C(f,u),f}n(gs,"getItem$2");function ys(i,u){var s=this,f=s.ready().then(function(){for(var d=s._dbInfo,c=d.keyPrefix,v=c.length,y=localStorage.length,E=1,b=0;b<y;b++){var _=localStorage.key(b);if(_.indexOf(c)===0){var A=localStorage.getItem(_);if(A&&(A=d.serializer.deserialize(A)),A=i(A,_.substring(v),E++),A!==void 0)return A}}});return C(f,u),f}n(ys,"iterate$2");function Es(i,u){var s=this,f=s.ready().then(function(){var d=s._dbInfo,c;try{c=localStorage.key(i)}catch(v){c=null}return c&&(c=c.substring(d.keyPrefix.length)),c});return C(f,u),f}n(Es,"key$2");function bs(i){var u=this,s=u.ready().then(function(){for(var f=u._dbInfo,d=localStorage.length,c=[],v=0;v<d;v++){var y=localStorage.key(v);y.indexOf(f.keyPrefix)===0&&c.push(y.substring(f.keyPrefix.length))}return c});return C(s,i),s}n(bs,"keys$2");function _s(i){var u=this,s=u.keys().then(function(f){return f.length});return C(s,i),s}n(_s,"length$2");function Ss(i,u){var s=this;i=k(i);var f=s.ready().then(function(){var d=s._dbInfo;localStorage.removeItem(d.keyPrefix+i)});return C(f,u),f}n(Ss,"removeItem$2");function ws(i,u,s){var f=this;i=k(i);var d=f.ready().then(function(){u===void 0&&(u=null);var c=u;return new g(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(A){(A.name==="QuotaExceededError"||A.name==="NS_ERROR_DOM_QUOTA_REACHED")&&y(A),y(A)}})})});return C(d,s),d}n(ws,"setItem$2");function Rs(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,d;return i.name?d=new g(function(c){i.storeName?c(bn(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)}}):d=g.reject("Invalid arguments"),C(d,u),d}n(Rs,"dropInstance$2");var Ts={_driver:"localStorageWrapper",_initStorage:hs,_support:ds(),iterate:ys,getItem:gs,setItem:ws,removeItem:Ss,clear:vs,length:_s,key:Es,keys:bs,dropInstance:Rs},Cs=n(function(u,s){return u===s||typeof u=="number"&&typeof s=="number"&&isNaN(u)&&isNaN(s)},"sameValue"),As=n(function(u,s){for(var f=u.length,d=0;d<f;){if(Cs(u[d],s))return!0;d++}return!1},"includes"),_n=Array.isArray||function(i){return Object.prototype.toString.call(i)==="[object Array]"},ut={},Sn={},Ye={INDEXEDDB:zi,WEBSQL:ls,LOCALSTORAGE:Ts},Os=[Ye.INDEXEDDB._driver,Ye.WEBSQL._driver,Ye.LOCALSTORAGE._driver],At=["dropInstance"],Er=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(At),Is={description:"",driver:Os.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 br(){for(var i=1;i<arguments.length;i++){var u=arguments[i];if(u)for(var s in u)u.hasOwnProperty(s)&&(_n(u[s])?arguments[0][s]=u[s].slice():arguments[0][s]=u[s])}return arguments[0]}n(br,"extend");var Ns=function(){function i(u){m(this,i);for(var s in Ye)if(Ye.hasOwnProperty(s)){var f=Ye[s],d=f._driver;this[s]=d,ut[d]||this.defineDriver(f)}this._defaultConfig=br({},Is),this._config=br({},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":l(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,d){var c=new g(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 _=Er.concat("_initStorage"),A=0,U=_.length;A<U;A++){var j=_[A],q=!As(At,j);if((q||s[j])&&typeof s[j]!="function"){y(b);return}}var te=n(function(){for(var ct=n(function(Ds){return function(){var Ls=new Error("Method "+Ds+" is not implemented by the current driver"),wn=g.reject(Ls);return C(wn,arguments[arguments.length-1]),wn}},"methodNotImplementedFactory"),_r=0,Us=At.length;_r<Us;_r++){var Sr=At[_r];s[Sr]||(s[Sr]=ct(Sr))}},"configureMissingMethods");te();var ee=n(function(ct){ut[E]&&console.info("Redefining LocalForage driver: "+E),ut[E]=s,Sn[E]=ct,v()},"setDriverSupport");"_support"in s?s._support&&typeof s._support=="function"?s._support().then(ee,y):ee(!!s._support):ee(!0)}catch(se){y(se)}});return x(c,f,d),c},"defineDriver"),i.prototype.driver=n(function(){return this._driver||null},"driver"),i.prototype.getDriver=n(function(s,f,d){var c=ut[s]?g.resolve(ut[s]):g.reject(new Error("Driver not found."));return x(c,f,d),c},"getDriver"),i.prototype.getSerializer=n(function(s){var f=g.resolve(yr);return x(f,s),f},"getSerializer"),i.prototype.ready=n(function(s){var f=this,d=f._driverSet.then(function(){return f._ready===null&&(f._ready=f._initDriver()),f._ready});return x(d,s,s),d},"ready"),i.prototype.setDriver=n(function(s,f,d){var c=this;_n(s)||(s=[s]);var v=this._getSupportedDrivers(s);function y(){c._config.driver=c.driver()}n(y,"setDriverToConfig");function E(A){return c._extend(A),y(),c._ready=c._initStorage(c._config),c._ready}n(E,"extendSelfWithDriver");function b(A){return function(){var U=0;function j(){for(;U<A.length;){var q=A[U];return U++,c._dbInfo=null,c._ready=null,c.getDriver(q).then(E).catch(j)}y();var te=new Error("No available storage method found.");return c._driverSet=g.reject(te),c._driverSet}return n(j,"driverPromiseLoop"),j()}}n(b,"initDriver");var _=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=_.then(function(){var A=v[0];return c._dbInfo=null,c._ready=null,c.getDriver(A).then(function(U){c._driver=U._driver,y(),c._wrapLibraryMethodsWithReady(),c._initDriver=b(v)})}).catch(function(){y();var A=new Error("No available storage method found.");return c._driverSet=g.reject(A),c._driverSet}),x(this._driverSet,f,d),this._driverSet},"setDriver"),i.prototype.supports=n(function(s){return!!Sn[s]},"supports"),i.prototype._extend=n(function(s){br(this,s)},"_extend"),i.prototype._getSupportedDrivers=n(function(s){for(var f=[],d=0,c=s.length;d<c;d++){var v=s[d];this.supports(v)&&f.push(v)}return f},"_getSupportedDrivers"),i.prototype._wrapLibraryMethodsWithReady=n(function(){for(var s=0,f=Er.length;s<f;s++)Ps(this,Er[s])},"_wrapLibraryMethodsWithReady"),i.prototype.createInstance=n(function(s){return new i(s)},"createInstance"),i}(),xs=new Ns;a.exports=xs},{"3":3}]},{},[4])(4)})});var mi=L((di,pi)=>{(function(e){var t;if(typeof define=="function"&&define.amd&&(define(e),t=!0),typeof di=="object"&&(pi.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 p=arguments[o];for(var l in p)a[l]=p[l]}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 p(m,h,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(h);/^[\{\[]/.test(w)&&(h=w)}catch(C){}h=o.write?o.write(h,m):encodeURIComponent(String(h)).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 T="";for(var g in S)!S[g]||(T+="; "+g,S[g]!==!0&&(T+="="+S[g].split(";")[0]));return document.cookie=m+"="+h+T}}n(p,"set");function l(m,h){if(typeof document!="undefined"){for(var S={},w=document.cookie?document.cookie.split("; "):[],T=0;T<w.length;T++){var g=w[T].split("="),C=g.slice(1).join("=");!h&&C.charAt(0)==='"'&&(C=C.slice(1,-1));try{var x=t(g[0]);if(C=(o.read||o)(C,x)||t(C),h)try{C=JSON.parse(C)}catch(k){}if(S[x]=C,m===x)break}catch(k){}}return m?S[m]:S}}return n(l,"get"),a.set=p,a.get=function(m){return l(m,!1)},a.getJSON=function(m){return l(m,!0)},a.remove=function(m,h){p(m,"",e(h,{expires:-1}))},a.defaults={},a.withConverter=r,a}return n(r,"init"),r(function(){})})});var Ys=n(()=>{if(typeof globalThis!="undefined")return globalThis;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;if(typeof self!="undefined")return self;throw new Error("@amedia/user: Unable to acquire any variant of globalThis")},"getGlobalThis"),fe=Ys;var Ks;var dt=n(()=>Ks||fe().location.hostname,"getCurrentHostname"),Te=n(()=>fe().location.href,"getCurrentUrl"),Ws=n(()=>{let e=/^bed-([^.]+)\.api\.no$/.exec(dt()),t=/\.([^.]+)\.api\.no/.exec(dt());return e?e[1]:t?t[1]:null},"getCurrentEnvironment"),le=n(()=>dt().replace(/\.[^.]+\.api\.no/,""),"getCurrentPublicationDomain"),Ke=n(()=>{let e=Ws(),t="www.aid.no";return e==="localhost"?t="www.aid.no.localhost.api.no":e&&(t=`www-${e}.aid.no`),t},"getAidDomain");var pt=n(e=>!!e&&typeof e=="function","isFunction"),wr=n(e=>!!e&&typeof e=="object","isRecord");var An=n(e=>!!e&&typeof e=="string","isString"),On=n(e=>!!e&&typeof e=="number","isNumber"),In=n(e=>!!e&&typeof e=="boolean","isBoolean");function Hs(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=>{a.ok||console.error(`Failed to send log to backend: Error, status: ${a.status}, text: ${a.statusText}`)})}n(Hs,"postLog");var Ot=n((e,t,r)=>{let o={};Object.keys(r).forEach(p=>{let l=r[p];if(An(l)||On(l)||In(l)){o[p]=l;return}try{o[p]=JSON.stringify(l)}catch(m){o[p]=l}});let a=ne(J({},o),{message:t,url:Te(),domain:dt()});Hs(`/api/mercury/v1/log/${e}`,a)},"backendLog"),zs={error:(e,t)=>Ot("error",e,t),warn:(e,t)=>Ot("warn",e,t),info:(e,t)=>Ot("info",e,t),debug:(e,t)=>Ot("debug",e,t)},Pn=zs;var Qs;var Js=n(()=>Qs||Pn,"getLogger"),Rr=n(e=>{let t={message:e.message};return Object.getOwnPropertyNames(e).forEach(r=>{t[r]=e[r]}),t},"rewriteErrorObject"),Nn=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");function Xs(e){return e&&e instanceof Error}n(Xs,"isError");function Zs(e){return e&&e instanceof Response}n(Zs,"isResponse");var ea=n((r,...o)=>O(void 0,[r,...o],function*(e,t={}){let a=e,p=t||{};if(a instanceof Error){let l=Rr(a);a=l.message,p=ne(J({},p),{error:l})}if(p=ne(J({},p),{origin:"@amedia/user"}),t instanceof Error){let l=Rr(t);p=ne(J({},p),{[Object.keys(p).includes("error")?"contextError":"error"]:l})}else if(p instanceof Response){let l=yield Nn(p);p=ne(J({},p),{response:l})}else for(let l of Object.keys(p)){let m=p[l];if(Xs(m))p[l]=Rr(m);else if(Zs(m)){let h=yield Nn(m);p[l]=h}}return{message:a,context:p}}),"processIncomingLogData"),It=n((e,t,r)=>{ea(t,r).then(({message:o,context:a})=>Js()[e](o,a))},"processAndLog"),I={debug:(e,t)=>It("debug",e,t),info:(e,t)=>It("info",e,t),warn:(e,t)=>It("warn",e,t),error:(e,t)=>It("error",e,t)};var Ce,ta=n(e=>{Ce=e},"setRootElement");ta(fe());var _e=n((e,t)=>{if(!Ce){I.error("No root element to bind event to!");return}Ce.addEventListener(e,r=>{r.stopImmediatePropagation(),t.apply(Ce,[r])})},"listenWithExclusivity"),Pt=n((e,t)=>{if(!Ce){I.error("No root element to bind event to!");return}Ce.addEventListener(e,r=>{t.apply(Ce,[r])})},"listenForAllEvents"),oe=n(e=>{if(!Ce){I.error("No root element to dispatch event on!");return}Ce.dispatchEvent(e)},"dispatch");var ge=be(De());var rt={},_u=n((e,t)=>{rt[e]||(rt[e]=[]),rt[e].push(t)},"add"),Su=n(e=>{let t=rt[e];return t?(delete rt[e],t):[]},"getAll"),wu=n(e=>{var t;return((t=rt[e])==null?void 0:t.length)||0},"peekQueueSize"),nt={add:_u,getAll:Su,peekQueueSize:wu};var Fr=n(()=>{let e=fe();return e.amediaUserCache||(e.amediaUserCache={})},"getStorage"),Ru=n(e=>{let t=Fr()[e];return Promise.resolve(t)},"get"),Tu=n((e,t,r)=>(Fr()[e]={key:e,data:t,expires:r},Promise.resolve()),"set"),Cu=n(e=>(delete Fr()[e],Promise.resolve()),"remove"),Au=n(()=>(fe().amediaUserCache={},Promise.resolve()),"clear"),Ao={get:Ru,set:Tu,remove:Cu,clear:Au};var Ou;var Zt=n(()=>Ou||Ao,"getCacheEngine"),Iu=n((e,t,r)=>Zt().set(e,t,Date.now()+r),"set"),jr=n(e=>Zt().remove(e),"remove"),Pu=n((e,t)=>O(void 0,null,function*(){let r=yield Zt().get(e);if(!r)return Promise.resolve();if(Date.now()>r.expires)return jr(e),Promise.resolve();try{return t.check(r.data)}catch(o){return I.error(o,{cacheData:r.data}),jr(e),Promise.resolve()}}),"get"),Nu=n(()=>Zt().clear(),"clear"),ve={get:Pu,set:Iu,remove:jr,clear:Nu};var xu=n((e,t)=>!e||Array.isArray(t)?t:t?typeof e=="object"&&typeof t=="object"?J(J({},e),t):t:e,"mergeCache");function we(e,t,r,o){return new Promise((a,p)=>{nt.add(e,{resolve:a,reject:p}),!(nt.peekQueueSize(e)>1)&&ve.get(e,t).then(l=>{if(l&&(!o||o(l))){nt.getAll(e).forEach(m=>{m.resolve(l)});return}r().then(m=>{let h=l?xu(l,m.data):m.data;ve.set(e,h,m.ttl),nt.getAll(e).forEach(S=>{S.resolve(m.data)})}).catch(()=>{nt.getAll(e).forEach(m=>{m.reject()})})})})}n(we,"getOrUpdate");var Po=be(Mr()),qe={},ot={},Uu=n(e=>{var t;(t=ot[e])==null||t.forEach(r=>r(qe[e]))},"emit"),Du=n((e,t)=>{ot[e]||(ot[e]=[]),ot[e].push(t)},"on"),No=n((e,t)=>{qe[e]=t,Uu(e)},"set"),Lu=n((e,t)=>{No(e,(0,Po.default)(qe[e]||{},t))},"merge"),ku=n(e=>qe[e],"get"),Fu=n(()=>{qe.state=void 0,qe.userAttributes=void 0,qe.storage=void 0,Object.keys(ot).forEach(e=>{ot[e]=[]})},"clear"),Q={merge:Lu,set:No,get:ku,on:Du,clear:Fu};var ju=["avbrutt","kansellert","cancelled","aborted","failed to fetch","abgebrochen","the operation was aborted."],xo=n(e=>ju.includes(e.toLowerCase().trim()),"isAbortedNetworkError");var Uo=(0,ge.Partial)({user_uuid:ge.String,user_name:ge.String,tracking_key:ge.String}),qu=n(e=>({uuid:e.user_uuid||null,name:e.user_name||null,trackingKey:e.tracking_key||null}),"mapSessionToUserAttributes"),Mu=(0,ge.Record)({code:ge.String}),Bu=(0,ge.Record)({errors:(0,ge.Array)(Mu)}),$u=["session.not_found","session.not_specified","user.deactivated"],Vu=["session.invalid_for_domain","user.not_found"],Br=n(e=>O(void 0,null,function*(){let t,r=e.clone();try{[t]=Bu.check(yield e.json()).errors}catch(o){return xo(o==null?void 0:o.message)?Promise.resolve():(I.warn("Unable to parse error body from pluto",{error:o,response:r}),Promise.reject(o))}return $u.includes(t==null?void 0:t.code)?Promise.resolve():Vu.includes(t==null?void 0:t.code)?(I.warn(`Pluto responded with HTTP/${e.status}: (${t.code}) while fetching current session`,{error:t,response:e}),Promise.resolve()):(I.error(`Pluto responded with HTTP/${e.status}: ${e.statusText}) when fetching current session`,{error:t,response:e}),Promise.reject())}),"resolveBadPlutoResponse"),Gu=n(()=>fetch("/api/pluto/v1/sessions/current").then(e=>e.ok?e.json():Br(e).then(()=>({}))).then(e=>{let t={ttl:-1,data:e};if(Object.keys(e).length===0)return t;try{return{ttl:1e4,data:Uo.check(e)}}catch(r){return I.error(r,{json:e}),t}}),"fetchCurrentSession"),Do=n(()=>O(void 0,null,function*(){return we("getCurrentSession",Uo,Gu).then(e=>qu(e))}),"getCurrentSession"),Lo=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||t.status===404)return;throw new Error(`Error, could not perform deleteRequest. Status: ${t.status} Text: ${t.statusText}`)}Q.merge("state",{isLoggedIn:!1})})}),"removeSession");var $r,er=self||window,ko=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof er.msCrypto!="undefined"&&typeof er.msCrypto.getRandomValues=="function"&&er.msCrypto.getRandomValues.bind(er.msCrypto);if(ko){let e=new Uint8Array(16);$r=n(function(){return ko(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 Fo=[];for(let e=0;e<256;++e)Fo[e]=(e+256).toString(16).substr(1);function Yu(e,t){let r=t||0,o=Fo;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(Yu,"bytesToUuid");function jo(){let e=$r();return e[6]=e[6]&15|64,e[8]=e[8]&63|128,Yu(e)}n(jo,"uuid");function Ku(){let e,t,r=!1;return{promise:new Promise((a,p)=>{e=n(l=>{r||a(l),r=!0},"resolve"),t=n(l=>{r||p(l),r=!0},"reject")}),resolve:e,reject:t}}n(Ku,"createPromise");function Wu(e,t){return(...r)=>{let{resolve:o,reject:a,promise:p}=Ku(),l=jo(),m={eventId:l,args:r},h=new CustomEvent(`amedia-rpc-event:${e}:${t}`,{detail:m});if(self.dispatchEvent(h),self.amediaNativeBridge){let S=JSON.stringify(r);self.amediaNativeBridge.callNativeMethod(e,t,S,l)}return self.addEventListener(`amedia-rpc-event:${e}:${t}:${l}`,S=>{S.detail||o();let{error:w,result:T}=S.detail;return w?a(w):o(T)}),p}}n(Wu,"createMethod");var gt=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,p]=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<p&&console.warn(`${this.component} server version is on an earlier minor version (${o}) than the client (${p})`);let l=this.queue.slice(0);delete this.queue,l.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,p=new Promise((l,m)=>{o=l,a=m});return this.queue.push(()=>this[t](...r).then(o).catch(a)),p}return this[t]=Wu(this.component,t),this[t](...r)}}};n(gt,"RPCclient");var tr,qo=n(()=>tr||(tr=new gt({version:"1.0.0",component:"userdata-session",methods:["userAuthenticated"]}),tr),"getRPCClient");var Hu=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"),ke=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 Hu(t,a)}return null},"getCookie"),zu=n((e,t)=>t?t instanceof Date?`; expires=${t.toUTCString()}`:(e.setTime(e.getTime()+t*24*60*60*1e3),`; expires=${e.toUTCString()}`):"","setValidTime"),Qu=n(e=>!e||e===""?"":e instanceof Object?encodeURIComponent(JSON.stringify(e)):typeof e=="number"?e.toString(10):e,"setValue");function Ae(e,t,r=Date.now(),o="/",a=!1){let p=new Date,l=`${e}=`;return(!t||t==="")&&(r=-1),l+=Qu(t),l+=zu(p,r),l+=`; path=${o}`,a&&(l+="; secure"),document.cookie=l,r&&r!==-1&&ke(e)===null&&(document.cookie=l.replace(/; expires=[^;]*/,"")),l}n(Ae,"setCookie");function pe(e){Ae(e)}n(pe,"removeCookie");var Mo=n(()=>{if(typeof window=="undefined"){I.error("location.reload used in a context without window. Be careful not to use paywall logic etc. in workers and other settings.");return}window.location.reload()},"reload"),Bo=n(e=>{if(typeof window=="undefined"){I.error("location.replace used in a context without window. Be careful not to use paywall logic etc. in workers and other settings.");return}window.location.replace(e)},"replace"),rr=n(e=>{if(typeof window=="undefined"){I.error("location.navigateTo used in a context without window. Be careful not to use interactive UX code in workers and other settings.");return}window.location.href=e},"navigateTo");var $o=n(e=>{let t=new URL(`https://${Ke()}/aid/logg_inn/${le()}/`);t.searchParams.set("requestedUrl",e instanceof URL?e.href:e),rr(t.href)},"login");function Ju(){pe("VSTOKEN"),pe("aid.session"),pe("aid_invitation_code"),pe("aid-reload-article"),pe("daxsub")}n(Ju,"clearCookies");var nr=n(()=>O(void 0,null,function*(){return Promise.all([Lo(le()),ve.clear()]).then(()=>{qo().userAuthenticated(!1),Ju(),pe("VSTOKEN2")}).catch(e=>{I.error("Failure while logging out",e)})}),"logout"),or=n(()=>Do(),"getSession");var K;(function(h){h.REQUEST_STATE="amedia-user.request-state",h.REQUEST_USER_ATTRIBUTES="amedia-user.request-user-attributes",h.REQUEST_STORAGE_NAMESPACES="amedia-user.request-storage-namespaces",h.SAVE_STORAGE="amedia-user.save-storage-namespaces",h.UPDATE_STORAGE="amedia-user.update-storage-namespaces",h.ON_ATTRIBUTES_UPDATED="amedia-user.on-user-attributes-updated",h.ON_STATE_UPDATED="amedia-user.on-state-updated",h.ON_STORAGE_UPDATED="amedia-user.on-storage-updated"})(K||(K={}));var yt=n((e,t)=>{if(e===t)return!0;if(!wr(e)||!wr(t)||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;let p=e[a],l=t[a];if(pt(p)||pt(l))return pt(p)&&pt(l)?p.toString()!==l.toString():!1;if(!yt(p,l))return!1}return!0},"deepEquals");var Et=n(()=>fe().location.hostname==="localhost"?(I.error("@amedia/user cannot work on localhost."),!0):!1,"isRunningOnLocalhost");var bt=class extends Error{constructor(t,r){super(t);this.partialData=r}};n(bt,"FetchTimeoutError");function Vo(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(Vo,"isMissingData");var Go=n((e,t)=>e==null?void 0:e.filter(r=>!Object.keys(t||[]).includes(r)),"findMissingKeys"),_t=class{constructor(t,r){this.attributes=t;this.namespaces=r}withAttributes(t){return new _t([...this.attributes||[],...t],this.namespaces)}withStorage(t){return new _t(this.attributes,[...this.namespaces||[],...t])}subscribe(t){let r=this.setupLocalCache();if(Et()){t(r);return}Pt(K.ON_STATE_UPDATED,o=>{let a=o.detail;Object.keys(r.state).length>0&&yt(r.state,a)||(r=ne(J({},r),{state:a}),t(r))}),oe(new CustomEvent(K.REQUEST_STATE)),Array.isArray(this.attributes)&&this.attributes.length>0&&(Pt(K.ON_ATTRIBUTES_UPDATED,o=>{let a=this.processUserAttributesEvent(o);Object.keys(r.attributes).length>0&&yt(r.attributes,a)||(r=ne(J({},r),{attributes:a}),t(r))}),oe(new CustomEvent(K.REQUEST_USER_ATTRIBUTES,{detail:[...this.attributes,"uuid"]}))),Array.isArray(this.namespaces)&&this.namespaces.length>0&&(Pt(K.ON_STORAGE_UPDATED,o=>{let a=this.processStorageEvent(o);yt(r.storage,a)||(r=ne(J({},r),{storage:a}),t(r))}),oe(new CustomEvent(K.REQUEST_STORAGE_NAMESPACES,{detail:this.namespaces})))}fetch(t){return new Promise((r,o)=>{Et()&&o(new Error("@amedia/user cannot run on localhost")),this.startFetchTimeout(o,t==null?void 0:t.timeout),this.subscribe(a=>{var p;if(this.clearFetchTimeout(),this.startFetchTimeout(o,t==null?void 0:t.timeout),this.lastReceivedData=a,typeof a.state.isLoggedIn!="undefined"){if(a.state.isLoggedIn===!1){if(((p=this.attributes)==null?void 0:p.includes("extraData"))&&!Object.keys(a.attributes).includes("extraData"))return;r(a);return}Vo(this.attributes,a.attributes)||Vo(this.namespaces,a.storage)||r(a)}})}).then(r=>(this.clearFetchTimeout(),r))}clearFetchTimeout(){this.fetchTimeoutId&&clearTimeout(this.fetchTimeoutId)}startFetchTimeout(t,r){this.fetchTimeoutId=setTimeout(()=>{var o,a;t(new bt(`@amedia/user timed out while waiting for ${JSON.stringify({attributes:Go(this.attributes,(o=this.lastReceivedData)==null?void 0:o.attributes),namespaces:Go(this.namespaces,(a=this.lastReceivedData)==null?void 0:a.storage)})}`,this.lastReceivedData||{}))},r||_t.FETCH_TIMEOUT)}processUserAttributesEvent(t){let r=t.detail;return this.attributes.reduce((a,p)=>(r[p]!==void 0&&(a[p]=r[p]),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=ne(J({},t),{attributes:{}})),this.namespaces&&this.namespaces.length>0&&(t=ne(J({},t),{storage:{}})),t}},ir=_t;n(ir,"UserDataRequest"),ir.FETCH_TIMEOUT=1e4;var ye=ir;var V=be(De());var Xu=(0,V.Record)({id:V.Number,domain:V.String}),Yo=(0,V.Record)({status:(0,V.Literal)("success"),access:(0,V.Union)((0,V.Literal)("granted"),(0,V.Literal)("denied")),publication:Xu,access_features:(0,V.Array)(V.String)}),Zu=(0,V.Record)({status:(0,V.Literal)("success"),cookie:V.String,access_features:(0,V.Array)(V.String)}),ec=(0,V.Record)({status:(0,V.Literal)("success"),vstoken_cookie:V.String,uuid:V.String,access_features:(0,V.Array)(V.String)}),Ko=n((e,t)=>we("checkForAccess",Yo,()=>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=Yo.check(r);return{ttl:o.access==="granted"?1e3*10:0,data:o}}catch(o){throw I.error(o,{json:r}),o}})).then(r=>({access:r.access_features})),"checkForAccess"),Wo=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 Zu.check(t)}catch(r){throw I.error(r,{json:t}),r}}),"getUserAccess"),Ho=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 ec.check(t)}catch(r){throw I.error(r,{json:t}),r}}),"getNonUserAccess");var St=class extends Error{};n(St,"UserDeactivatedError");var tc=["no_session_found","subscription_not_found","publication_not_subscribable"],zo=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){I.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 St;return tc.includes(o==null?void 0:o.status)?[]:(I.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 Qo=n((e=["newspaper"])=>Ko(le(),e),"getAccess"),Jo=n(e=>O(void 0,null,function*(){try{return yield zo(e)}catch(t){if(t instanceof St)return yield nr(),[];throw t}}),"activate"),Vr=n((e,t)=>t.length<1||t.filter(r=>e.includes(r)).length>0,"hasAccess"),sr=n(e=>O(void 0,null,function*(){let t=yield Wo(e);return t.status==="success"&&Ae("VSTOKEN",t.cookie,365,"/"),{success:t.status==="success",accessFeatures:t.access_features}}),"setUserAccessCookie"),ar=n(e=>O(void 0,null,function*(){let t=yield Ho(e);return t.status==="success"&&Ae("VSTOKEN2",t.vstoken_cookie,1,"/"),{success:t.status==="success",accessFeatures:t.access_features}}),"setNonUserAccessCookie"),Xo=n(e=>O(void 0,null,function*(){let t=[];return t.push(sr(e).catch(()=>Promise.resolve({success:!1,accessFeatures:[]}))),t.push(ar(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((p,l,m)=>m.indexOf(p)===l).sort()}),{success:!0,accessFeatures:[]}))}),"setAccessCookies"),Zo=n(e=>{let t=new Date;t.setTime(t.getTime()+2*60*1e3),Ae("aid-paywall-reload-performed",e||Te(),t)},"setHasPerformedPaywallReload"),ei=n(e=>ke("aid-paywall-reload-performed")===(e||Te()),"hasRecentlyPerformedPaywallReload");var ti="jupiter";function rc(){return O(this,null,function*(){let e="VSTOKEN",t=le(),r=ke(e);new ye().withAttributes(["uuid"]).fetch().then(p=>O(this,[p],function*({attributes:o,state:a}){if(a.isLoggedIn===!1){typeof r=="string"&&pe(e);return}if(typeof r!="string"){yield sr(t);return}let l=r.split(":"),m=new Date(parseInt(l[1],10)*1e3);m.setDate(m.getDate()-1),!(m.getTime()>Date.now()&&l[3]===o.uuid&&t.includes(l[4])&&l[5]===ti)&&(yield sr(t))}))})}n(rc,"verifyAndSetUserAccessCookie");function nc(){let e="VSTOKEN2",t=le(),r=ke(e);new ye().fetch().then(a=>O(this,[a],function*({state:{isLoggedIn:o}}){if(o){if(typeof r!="string"){yield ar(t);return}let p=r.split(":"),l=new Date(parseInt(p[1],10)*1e3);if(l.setMinutes(l.getMinutes()-30),l.getTime()>Date.now()&&t.includes(p[4])&&p[5]===ti)return;yield ar(t)}else pe(e)})).then(()=>{})}n(nc,"verifyAndSetNonUserAccessCookie");function Gr(){return Promise.all([rc(),nc()])}n(Gr,"accessCookieRefresher");function ri(){new ye().subscribe(({state:e})=>{e.isLoggedIn===!1&&(Q.set("userAttributes",{}),Q.set("storage",{}))})}n(ri,"removeUserStorage");var Me=be(De());var ni="haveTriedThirdPartyLoginCheck",oc=60*60*1e3,ic=(0,Me.Record)({user_name:Me.String,tracking_key:Me.String}),sc=n(()=>fetch(`https://${Ke()}/api/pluto/v1/sessions/current`,{mode:"cors",credentials:"include"}).then(e=>e.ok?e.json():Br(e).then(()=>null).catch(()=>null)).then(e=>{if(!e)return null;try{return ic.check(e)}catch(t){return I.error(t,{data:e}),null}}),"getAidSession");function Yr(){return O(this,null,function*(){return(yield ve.get(ni,Me.Boolean))?!1:(yield ve.set(ni,!0,oc),!!(yield sc()))})}n(Yr,"thirdPartyCookie");var Kr="has-tried-autologin",oi=6e4;function ac(){try{return window.self!==window.top}catch(e){return!0}}n(ac,"inIframe");function uc(){let e=ke(Kr);if(e&&typeof e!="object")try{if(Date.now()-parseInt(e,10)<oi)return!0}catch(t){pe(Kr)}return Ae(Kr,Date.now(),Date.now()+oi),!1}n(uc,"hasAlreadyAttemptedAutoLogin");var ii=n(e=>O(void 0,null,function*(){if(typeof window=="undefined"||ac())return;let{state:{isLoggedIn:t}}=yield new ye().fetch();if(!t){for(let r of e)if(!(yield r.handler().then(a=>{if(a){if(uc())return!1;let p=new URL(`https://${Ke()}/aid/logg_inn/auto`);return p.searchParams.set("context",`auto_login_${r.name}`),p.searchParams.set("requestedUrl",Te()),rr(p.href),!1}return!0})))return}}),"attemptAutologin"),si=n(()=>O(void 0,null,function*(){return ii([{name:"third_party",handler:Yr}])}),"attemptAutoLoginJob"),ai=n(()=>O(void 0,null,function*(){return ii([{name:"paywall",handler:()=>Promise.resolve(!0)}])}),"attemptPaywallAutoLogin");function cc(e){var o;return`a_sub_status=${((o=e.extraData)==null?void 0:o.customer_keys)?"active":"null"}&a_user_key=${e.trackingKey}`}n(cc,"getCookieValue");function fc(e){let t="daxsub",r=cc(e),o=encodeURIComponent(r);Ae(t,o,1)}n(fc,"setDaxsubCookie");function Wr(){return new ye().withAttributes(["trackingKey","extraData"]).fetch({timeout:6e4}).then(({attributes:e,state:t})=>{if(!t.isLoggedIn){pe("daxsub");return}fc(e)}).catch(e=>{I.warn(`Setting daxsub cookie failed. Error: ${e.message}`,e)})}n(Wr,"daxSubCookieHandler");var lc=[si,Gr,Wr,ri];function dc(){return O(this,null,function*(){var e,t;if(typeof window!="undefined"){if(((t=(e=fe())==null?void 0:e.location)==null?void 0:t.hostname)==="localhost"){I.warn("@amedia/user started on localhost. In this scenario we have no way to resolve any login-, access- or userdata. Expect errors and/or redirects if you try.");return}for(let r of lc)yield r()}})}n(dc,"performJobs");var ur;(function(t){t.LOADED="amedia-user.janitor.loaded"})(ur||(ur={}));var ui=n(()=>O(void 0,null,function*(){let e=!1;_e(ur.LOADED,()=>{e||(e=!0,dc())}),oe(new CustomEvent(ur.LOADED))}),"runJanitor");var ci=n(()=>{_e(K.REQUEST_STATE,()=>{let e=Q.get("state");e&&Object.keys(e).length>0&&oe(new CustomEvent(K.ON_STATE_UPDATED,{detail:e})),Q.on("state",t=>{oe(new CustomEvent(K.ON_STATE_UPDATED,{detail:t}))})})},"listenForStateRequests");var fr=be(li()),wt=be(mi());var zr,cr=typeof self=="undefined"?window:self,hi=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof cr.msCrypto!="undefined"&&typeof cr.msCrypto.getRandomValues=="function"&&cr.msCrypto.getRandomValues.bind(cr.msCrypto);if(hi){let e=new Uint8Array(16);zr=n(function(){return hi(e),e},"whatwgRNG")}else{let e=new Array(16);zr=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 vi=[];for(let e=0;e<256;++e)vi[e]=(e+256).toString(16).substr(1);function pc(e,t){let r=t||0,o=vi;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(pc,"bytesToUuid");function Qr(){let e=zr();return e[6]=e[6]&15|64,e[8]=e[8]&63|128,pc(e)}n(Qr,"uuid");function gi(e){let t=!1;return(...r)=>{t||(e.apply(this,r),t=!0,setTimeout(()=>{t=!1},400))}}n(gi,"throttle");fr.default.config({name:"aid:userdata"});var yi=self.location.hostname.replace(/(.*\.)([^.]+\.\w+$)/,"$2");function Ei(){let e=wt.default.get("amedia:fpbid");return e||(e=Qr(),wt.default.set("amedia:fpbid",e,{expires:365*10,domain:yi,sameSite:"strict"})),Promise.resolve(e)}n(Ei,"getBrowserId");function mc(){let e=wt.default.get("amedia:visitid");return e?Promise.resolve(e):fr.default.getItem("visitid")}n(mc,"getVisitIdFromStorage");function bi(e){return wt.default.set("amedia:visitid",e,{expires:new Date(Date.now()+18e5),domain:yi,sameSite:"strict"}),fr.default.setItem("visitid",e).then(()=>e)}n(bi,"storeVisitId");function _i(){let e=Date.now(),t=`${Qr()}|${e}`;return bi(t)}n(_i,"createVisitId");function hc(){return mc().then(e=>e||_i()).then(e=>{let[t,r]=e.split("|");return!t||r&&Date.now()-18e5>r?_i():bi(`${t}|${Date.now()}`)}).catch(e=>console.error(e))}n(hc,"refreshVisitId");typeof window!="undefined"&&["mousedown","keydown","mousemove","focus","scroll","resize","seshat-video-active","touchmove","deviceorientation"].forEach(e=>window.addEventListener(e,gi(hc)));var Be=be(De());var it=be(De());var Si=be(Mr());function lr(e){return typeof e=="string"||e instanceof String?`${e}`:e instanceof Array?[...e].map(lr):Object.entries(e).reduce((t,[r,o])=>ne(J({},t),{[r]:lr(o)}),{})}n(lr,"deepCopy");var Jr=class{constructor(t,r,o,a){this.timeoutMs=t;this.defaultParams=r;this.paramAccumulator=o;this.workload=a;this.queue=[];this.params=lr(r)}perform(t){return new Promise((r,o)=>{this.timer&&clearTimeout(this.timer),this.params=this.paramAccumulator(this.params,t),this.queue.push({resolve:r,reject:o}),this.timer=setTimeout(()=>O(this,null,function*(){let a=lr(this.params),p=[...this.queue];this.params=this.defaultParams,this.queue=[],this.workload(a).then(l=>{p.forEach(m=>{m.resolve(l)})}).catch(l=>{p.forEach(m=>{m.reject(l)})})}),this.timeoutMs)})}static stringListParamsAccumulator(t,r){return r.forEach(o=>{t.includes(o)||t.push(o)}),t}static stringMapParamsAccumulator(t,r){return(0,Si.default)(t,r)}};n(Jr,"Debouncer");var Xr=Jr;var vc=5*6e4,gc=20,wi=(0,it.Dictionary)(it.Unknown,it.String);var Zr=n((e,t="GET",r)=>fetch(e,{method:t,body:r&&JSON.stringify(r),headers:{"Content-Type":"application/json",Accept:"application/json"}}),"doFetch");function Ri(e,t){return Object.entries(t).reduce((r,[o,a])=>ne(J({},r),{[o]:a}),e||{})}n(Ri,"mergeCache");var Ti=n((e,t)=>O(void 0,null,function*(){let r=yield ve.get("europa",wi),o=Ri(r,{[e]:t});return ve.set("europa",o,Date.now()+vc)}),"updateNamespaceInCache"),Ci=n((e,t)=>O(void 0,null,function*(){let r=yield Zr(`/api/europa/v1/me/${e}`,"PATCH",t);return r.ok?Ti(e,t):(I.error(`Could not get namespace: ${e}, status: ${r.status}, statusText: ${r.statusText}`,r),{})}),"updateNamespace"),yc=new Xr(gc,[],Xr.stringListParamsAccumulator,e=>Zr(`/api/europa/v1/me/${e.join(",")}`).then(t=>O(void 0,null,function*(){let r=yield t.text();return t.ok?JSON.parse(r).namespaces:(t.status===500||t.status===503?I.error(`Could not get namespaces for: ${e}, status: ${t.status}`,{response:t,body:r}):I.warn(`Could not get namespaces for: ${e}, status: ${t.status}`,{response:t,body:r}),{})}))),Rt=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");let a=e,p=(yield ve.get("europa",wi))||{namespaces:{}};if(!t.ignoreCache&&(a=p?e.filter(m=>!Object.keys(p).includes(m)):e,p&&a.length===0))return Promise.resolve(p);let l=yield yc.perform(a);return Object.entries(l).forEach(([m,h])=>Ti(m,h)),Promise.resolve(Object.entries(Ri(p,l)).filter(([m])=>e.includes(m)).reduce((m,[h,S])=>ne(J({},m),{[h]:S}),{}))}),"getNamespaces"),Ai=n((e,t)=>Zr(`/api/europa/v1/me/${e}`,"PUT",t).then(r=>(r.ok||I.error(`Could not get save namespace, namespace:${e} status: ${r.status}, statusText: ${r.statusText}`,r),{})).then(()=>Rt([e],{ignoreCache:!0})),"saveNamespace");var Ec=5*6e4,bc="privacyPreferences",_c=(0,Be.Record)({allowResearchUsage:Be.Boolean,connectWithSurveys:Be.Boolean,personalizedAds:Be.Boolean,personalizedContent:Be.Boolean}),dr=n(e=>e==="true"||e===!0,"toBoolean"),Oi=n(()=>O(void 0,null,function*(){return we(bc,_c,()=>Rt(["privacy_preferences"]).then(e=>{let t=e.privacy_preferences;return{ttl:Ec,data:{allowResearchUsage:dr(t.allow_research_usage),connectWithSurveys:dr(t.connect_with_surveys),personalizedAds:dr(t.personalized_ads),personalizedContent:dr(t.personalized_content)}}})).then(e=>({privacyPreferences:e}))}),"getPrivacyPreferences");var B=be(De());var Ii=(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})),Sc=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:Ii.check(a)}}catch(p){throw I.error(p,{json:a}),p}})},"getNebulaData"),wc=n(e=>({extraData:e}),"mapNebulaToUserData"),Pi=n((e,t,r)=>we("getNebulaInfo",Ii,()=>Sc(e,t,r)).then(wc),"getInfo");var en=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"),$e=n(()=>new Promise(e=>en().then(t=>{t&&e()})),"whenIsLoggedIn");var Rc=n(()=>Promise.all([Ei(),en()]).then(([e,t])=>{var r;return Pi(le(),e,t&&((r=Q.get("userAttributes"))==null?void 0:r.trackingKey)||void 0)}),"getExtraData"),Tc={uuid:or,name:or,trackingKey:or,access:()=>$e().then(()=>Qo()),extraData:Rc,privacyPreferences:()=>$e().then(()=>Oi())},Ni=n(e=>{let t=[];e.forEach(o=>{let a=Tc[o];if(!a){I.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),a.uuid!==void 0&&Q.merge("state",{isLoggedIn:a.uuid!==null})}).catch(a=>{I.warn(`User attribute call failed (${o.toString()})`,a)}))}),Promise.all(r).then(()=>{})},"requestAttributes");var xi=n(()=>{Q.on("userAttributes",e=>{oe(new CustomEvent(K.ON_ATTRIBUTES_UPDATED,{detail:e}))}),_e(K.REQUEST_USER_ATTRIBUTES,e=>{let t=e.detail,r=Q.get("userAttributes")||{};Object.keys(r).length>0&&oe(new CustomEvent(K.ON_ATTRIBUTES_UPDATED,{detail:r}));let o=t.filter(a=>r[a]===void 0);o.length>0&&Ni(o)})},"listenForUserAttributeRequests");var Ui=n(e=>{Rt(e).then(t=>{Q.merge("storage",t)})},"requestStorage"),Di=n(e=>Object.keys(e).forEach(t=>Ci(t,e[t])),"updateStorage"),Li=n(e=>Object.keys(e).forEach(t=>Ai(t,e[t])),"saveStorage");var ki=n(()=>{Q.on("storage",e=>{oe(new CustomEvent(K.ON_STORAGE_UPDATED,{detail:e}))}),_e(K.REQUEST_STORAGE_NAMESPACES,e=>{$e().then(()=>{let t=e.detail,r=Q.get("storage")||{};Object.keys(r).length>0&&oe(new CustomEvent(K.ON_STORAGE_UPDATED,{detail:r}));let o=t.filter(a=>r[a]===void 0);o.length>0&&Ui(o)})}),_e(K.UPDATE_STORAGE,e=>{$e().then(()=>{Di(e.detail)})}),_e(K.SAVE_STORAGE,e=>{$e().then(()=>{Li(e.detail)})})},"listenForStorageRequests");var st=class extends Error{constructor(t,r){super(t);this.code=r}};n(st,"PaywallError"),st.ERROR_RELOADED_NO_ACCESS="RELOADED_NO_ACCESS",st.ERROR_ENABLING_ACCESS_FAILED="ENABLING_ACCESS_FAILED",st.ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES="NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES";var Ve=st;var tn=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*(){if(Et())return Promise.reject(new Error("@amedia/user cannot unlock paywall on localhost"));let{state:{isLoggedIn:t}}=yield new ye().withAttributes(["name"]).fetch();if(!t)return yield ai(),{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(ei(this.requestedUrl))throw new Ve("Unlock check already performed.",Ve.ERROR_RELOADED_NO_ACCESS);Zo(this.requestedUrl),this.reload&&Mo(),this.requestedUrl&&Bo(this.requestedUrl)}return{isLoggedIn:!0,hasAccess:!0,accessFeatures:r.accessFeatures}})}setAccessCookiesAndGetAccessFeatures(t){return Xo(le()).then(r=>{let o=!Vr(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 Jo(this.requestedAccessFeatures);return{denied:!Vr(r,t),accessFeatures:r}})}};n(tn,"PaywallUnlockRequest");var Cc=tn;var Tp=n(e=>$o(e||Te()),"goToLoginPage"),Cp=n(()=>nr(),"logout"),Ap=n(e=>{oe(new CustomEvent(K.UPDATE_STORAGE,{detail:e}))},"updateStorage"),Op=n(e=>{oe(new CustomEvent(K.SAVE_STORAGE,{detail:e}))},"saveStorage");fe().amediaUserTestMode||(ci(),xi(),ki(),ui());export{Cc as PaywallUnlockRequest,ye as UserDataRequest,Tp as goToLoginPage,Cp as logout,Op as saveStorage,Ap as updateStorage};
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
const stub = () => {
|
|
2
|
+
throw new Error('You must use @amedia/user through Eik. Please read docs');
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export class UserDataRequest {
|
|
6
|
+
constructor() {
|
|
7
|
+
stub();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class PaywallUnlockRequest {
|
|
12
|
+
constructor() {
|
|
13
|
+
stub();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const goToLoginPage = stub;
|
|
18
|
+
export const logout = stub;
|
|
19
|
+
|
|
20
|
+
export const updateStorage = stub;
|
|
21
|
+
export const saveStorage = stub;
|
|
22
|
+
|
|
23
|
+
stub();
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amedia/user",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Client lib for working with aID user and associated data",
|
|
5
5
|
"repository": "https://github.com/amedia/amedia-user-js",
|
|
6
6
|
"author": "Amedia Utvikling (ID og data)",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "dist/user.cjs",
|
|
9
8
|
"module": "dist/user.js",
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
12
|
-
"require": "./dist/user.cjs",
|
|
13
11
|
"import": "./dist/user.js"
|
|
14
12
|
}
|
|
15
13
|
},
|
|
@@ -20,13 +18,15 @@
|
|
|
20
18
|
"typings": "dist/user.d.ts",
|
|
21
19
|
"scripts": {
|
|
22
20
|
"test": "jest --coverage",
|
|
21
|
+
"clean-dist": "rm -rf ./dist",
|
|
23
22
|
"lint": "eslint ./src --ext .ts",
|
|
24
23
|
"build": "npm install && node build.js",
|
|
25
24
|
"typings": "tsc --noEmit",
|
|
26
25
|
"checkVersion": "node --experimental-json-modules checkVersion.js",
|
|
26
|
+
"stub-npmjs-package": "find ./dist -type f ! -name '*.d.ts' -delete && cp -v stubs/* dist/.",
|
|
27
27
|
"eik:package": "run-p typings lint && npm run test && npm run build && eik package",
|
|
28
|
-
"prepublishOnly": "npm run checkVersion && run-p typings lint && npm run test && npm run build",
|
|
29
|
-
"postpublish": "eik package"
|
|
28
|
+
"prepublishOnly": "npm run checkVersion && run-p clean-dist typings lint && npm run test && npm run build && npm run stub-npmjs-package",
|
|
29
|
+
"postpublish": "npm run build && eik package"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@amedia/browserid": "^0.1.6",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@amedia/eslint-config-base": "^4.0.7",
|
|
39
39
|
"@amedia/eslint-config-typescript": "^4.0.10",
|
|
40
40
|
"@eik/cli": "^2.0.5",
|
|
41
|
+
"@eik/esbuild-plugin": "^1.0.4",
|
|
41
42
|
"@types/convict": "^6.1.1",
|
|
42
43
|
"@types/dexie": "^1.3.1",
|
|
43
44
|
"@types/jest": "^26.0.24",
|
|
@@ -148,6 +148,19 @@ describe('attemptAutoLoginJob', () => {
|
|
|
148
148
|
itShouldNotNavigateAway();
|
|
149
149
|
});
|
|
150
150
|
});
|
|
151
|
+
|
|
152
|
+
describe('when in aid emergency mode', () => {
|
|
153
|
+
beforeEach(async () => {
|
|
154
|
+
store.merge('state', {
|
|
155
|
+
emergencyMode: ['aid'],
|
|
156
|
+
});
|
|
157
|
+
await attemptAutoLoginJob();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should not try third party auto login', () => {
|
|
161
|
+
expect(thirdPartyCookie.default).not.toHaveBeenCalled();
|
|
162
|
+
});
|
|
163
|
+
});
|
|
151
164
|
});
|
|
152
165
|
});
|
|
153
166
|
|
package/src/autologin/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { getAidDomain, getCurrentUrl } from '../utils/url';
|
|
|
3
3
|
import { navigateTo } from '../utils/location';
|
|
4
4
|
import { getCookie, removeCookie, setCookie } from '../lib/cookie';
|
|
5
5
|
import UserDataRequest from '../lib/UserDataRequest';
|
|
6
|
+
import store from '../store';
|
|
6
7
|
|
|
7
8
|
export type Strategies = Array<{
|
|
8
9
|
name: string;
|
|
@@ -35,7 +36,16 @@ function hasAlreadyAttemptedAutoLogin() {
|
|
|
35
36
|
return false;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
function isInAidEmergencyMode() {
|
|
40
|
+
return store.get('state')?.emergencyMode?.includes('aid');
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
const attemptAutologin = async (strategies: Strategies) => {
|
|
44
|
+
if (isInAidEmergencyMode()) {
|
|
45
|
+
// Avoid auto-login if we are in aid emergency mode
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
if (typeof window === 'undefined' || inIframe()) {
|
|
40
50
|
// Avoid auto-login on preview for dr edition and in workers.
|
|
41
51
|
return;
|
|
@@ -4,6 +4,7 @@ import store from '../store';
|
|
|
4
4
|
import { getCurrentSession, removeSession } from './pluto';
|
|
5
5
|
import { Logger, setLogger } from '../utils/log';
|
|
6
6
|
import { UserAttributes } from '../types';
|
|
7
|
+
import anything = jasmine.anything;
|
|
7
8
|
|
|
8
9
|
beforeEach(async () => {
|
|
9
10
|
await cache.clear();
|
|
@@ -42,7 +43,7 @@ function itShouldNotHaveLoggedAnything() {
|
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
describe('Pluto
|
|
46
|
+
describe('Pluto client', () => {
|
|
46
47
|
describe('getCurrentSession()', () => {
|
|
47
48
|
beforeEach(() => {
|
|
48
49
|
jest.spyOn(store, 'merge');
|
|
@@ -66,6 +67,21 @@ describe('Pluto service', () => {
|
|
|
66
67
|
});
|
|
67
68
|
});
|
|
68
69
|
}
|
|
70
|
+
function itShouldNotSetEmergencyModeState() {
|
|
71
|
+
it('should not set emergency mode state', () => {
|
|
72
|
+
expect(store.merge).not.toHaveBeenCalledWith('state', {
|
|
73
|
+
emergencyMode: anything(),
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function itShouldSetEmergencyModeState(emergencyModes: string[]) {
|
|
79
|
+
it('should set emergency mode states', () => {
|
|
80
|
+
expect(store.merge).toHaveBeenCalledWith('state', {
|
|
81
|
+
emergencyMode: emergencyModes,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
69
85
|
|
|
70
86
|
describe('when user is logged in ', () => {
|
|
71
87
|
describe('When cache is empty', () => {
|
|
@@ -77,6 +93,7 @@ describe('Pluto service', () => {
|
|
|
77
93
|
expect(fetch).toHaveBeenCalledTimes(1);
|
|
78
94
|
});
|
|
79
95
|
itShouldReturnSessionData();
|
|
96
|
+
itShouldNotSetEmergencyModeState();
|
|
80
97
|
});
|
|
81
98
|
describe('When cache is not empty', () => {
|
|
82
99
|
beforeEach(async () => {
|
|
@@ -87,8 +104,46 @@ describe('Pluto service', () => {
|
|
|
87
104
|
expect(fetch).toHaveBeenCalledTimes(0);
|
|
88
105
|
});
|
|
89
106
|
itShouldReturnSessionData();
|
|
107
|
+
itShouldNotSetEmergencyModeState();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('when single emergency mode is set', () => {
|
|
111
|
+
beforeEach(async () => {
|
|
112
|
+
fetch.mockResponseOnce(() =>
|
|
113
|
+
Promise.resolve({
|
|
114
|
+
init: {
|
|
115
|
+
status: 200,
|
|
116
|
+
headers: {
|
|
117
|
+
'x-emergency-mode': 'aid',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
body: JSON.stringify(plutoLoggedInResponse),
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
currentSession = await getCurrentSession();
|
|
124
|
+
});
|
|
125
|
+
itShouldSetEmergencyModeState(['aid']);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('when multiple emergency modes is set', () => {
|
|
129
|
+
beforeEach(async () => {
|
|
130
|
+
fetch.mockResponseOnce(() =>
|
|
131
|
+
Promise.resolve({
|
|
132
|
+
init: {
|
|
133
|
+
status: 200,
|
|
134
|
+
headers: {
|
|
135
|
+
'x-emergency-mode': 'aid,paywall',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
body: JSON.stringify(plutoLoggedInResponse),
|
|
139
|
+
})
|
|
140
|
+
);
|
|
141
|
+
currentSession = await getCurrentSession();
|
|
142
|
+
});
|
|
143
|
+
itShouldSetEmergencyModeState(['aid', 'paywall']);
|
|
90
144
|
});
|
|
91
145
|
});
|
|
146
|
+
|
|
92
147
|
describe('when user is not logged in', () => {
|
|
93
148
|
describe('When cache is empty', () => {
|
|
94
149
|
beforeEach(async () => {
|
|
@@ -105,6 +160,7 @@ describe('Pluto service', () => {
|
|
|
105
160
|
});
|
|
106
161
|
itShouldNotHaveLoggedAnything();
|
|
107
162
|
itShouldReturnNoSessionData();
|
|
163
|
+
itShouldNotSetEmergencyModeState();
|
|
108
164
|
});
|
|
109
165
|
describe('When cache is not empty', () => {
|
|
110
166
|
beforeEach(async () => {
|
|
@@ -116,6 +172,7 @@ describe('Pluto service', () => {
|
|
|
116
172
|
});
|
|
117
173
|
itShouldNotHaveLoggedAnything();
|
|
118
174
|
itShouldReturnNoSessionData();
|
|
175
|
+
itShouldNotSetEmergencyModeState();
|
|
119
176
|
});
|
|
120
177
|
describe('when session is invalid for domain', () => {
|
|
121
178
|
beforeEach(async () => {
|
|
@@ -137,6 +194,7 @@ describe('Pluto service', () => {
|
|
|
137
194
|
}
|
|
138
195
|
);
|
|
139
196
|
});
|
|
197
|
+
itShouldNotSetEmergencyModeState();
|
|
140
198
|
});
|
|
141
199
|
describe('when session is no longer valid', () => {
|
|
142
200
|
beforeEach(async () => {
|
|
@@ -149,6 +207,43 @@ describe('Pluto service', () => {
|
|
|
149
207
|
currentSession = await getCurrentSession();
|
|
150
208
|
});
|
|
151
209
|
itShouldNotHaveLoggedAnything();
|
|
210
|
+
itShouldNotSetEmergencyModeState();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
describe('when single emergency mode is set', () => {
|
|
214
|
+
beforeEach(async () => {
|
|
215
|
+
fetch.mockResponseOnce(() =>
|
|
216
|
+
Promise.resolve({
|
|
217
|
+
init: {
|
|
218
|
+
status: 403,
|
|
219
|
+
headers: {
|
|
220
|
+
'x-emergency-mode': 'aid',
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
body: '{"errors": [{"code": "session.invalid_for_domain"}]}',
|
|
224
|
+
})
|
|
225
|
+
);
|
|
226
|
+
currentSession = await getCurrentSession();
|
|
227
|
+
});
|
|
228
|
+
itShouldSetEmergencyModeState(['aid']);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
describe('when multiple emergency modes is set', () => {
|
|
232
|
+
beforeEach(async () => {
|
|
233
|
+
fetch.mockResponseOnce(() =>
|
|
234
|
+
Promise.resolve({
|
|
235
|
+
init: {
|
|
236
|
+
status: 403,
|
|
237
|
+
headers: {
|
|
238
|
+
'x-emergency-mode': 'aid,paywall',
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
body: '{"errors": [{"code": "session.invalid_for_domain"}]}',
|
|
242
|
+
})
|
|
243
|
+
);
|
|
244
|
+
currentSession = await getCurrentSession();
|
|
245
|
+
});
|
|
246
|
+
itShouldSetEmergencyModeState(['aid', 'paywall']);
|
|
152
247
|
});
|
|
153
248
|
});
|
|
154
249
|
});
|
package/src/clients/pluto.ts
CHANGED
|
@@ -71,6 +71,14 @@ export const resolveBadPlutoResponse = async (response: Response) => {
|
|
|
71
71
|
const fetchCurrentSession = () =>
|
|
72
72
|
fetch(`/api/pluto/v1/sessions/current`)
|
|
73
73
|
.then((response) => {
|
|
74
|
+
const emergencyMode = response.headers
|
|
75
|
+
.get('x-emergency-mode')
|
|
76
|
+
?.split(',');
|
|
77
|
+
if (emergencyMode) {
|
|
78
|
+
store.merge('state', {
|
|
79
|
+
emergencyMode,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
74
82
|
if (!response.ok) {
|
|
75
83
|
return resolveBadPlutoResponse(response).then(() => ({}));
|
|
76
84
|
}
|