@lifeready/core 6.0.4 → 6.0.5
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/bundles/lifeready-core.umd.js +14 -8
- package/bundles/lifeready-core.umd.js.map +1 -1
- package/bundles/lifeready-core.umd.min.js +1 -1
- package/bundles/lifeready-core.umd.min.js.map +1 -1
- package/esm2015/lib/file-upload/file-upload.service.js +14 -9
- package/esm2015/lib/item2/item2.types.js +1 -1
- package/fesm2015/lifeready-core.js +13 -8
- package/fesm2015/lifeready-core.js.map +1 -1
- package/lib/file-upload/file-upload.service.d.ts +1 -1
- package/lib/item2/item2.types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("apollo-angular"),require("@dagrejs/graphlib"),require("lodash"),require("node-jose"),require("@aws-amplify/auth/lib-esm/Auth"),require("graphql-tag"),require("moment"),require("@apollo/client/core"),require("@apollo/client/link/context"),require("@apollo/client/link/retry"),require("ngx-cookie-service"),require("graphql/language/printer"),require("@aws-amplify/auth"),require("@angular/common/http"),require("@aws-amplify/core"),require("rxjs"),require("@ng-idle/core"),require("@ng-idle/keepalive"),require("slip39")):"function"==typeof define&&define.amd?define("@lifeready/core",["exports","@angular/core","apollo-angular","@dagrejs/graphlib","lodash","node-jose","@aws-amplify/auth/lib-esm/Auth","graphql-tag","moment","@apollo/client/core","@apollo/client/link/context","@apollo/client/link/retry","ngx-cookie-service","graphql/language/printer","@aws-amplify/auth","@angular/common/http","@aws-amplify/core","rxjs","@ng-idle/core","@ng-idle/keepalive","slip39"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).lifeready=e.lifeready||{},e.lifeready.core={}),e.ng.core,e["apollo-angular"],e["@dagrejs/graphlib"],e.lodash,e["node-jose"],e["@aws-amplify/auth/lib-esm/Auth"],e["graphql-tag"],e.moment,e["@apollo/client/core"],e["@apollo/client/link/context"],e["@apollo/client/link/retry"],e["ngx-cookie-service"],e["graphql/language/printer"],e["@aws-amplify/auth"],e.ng.common.http,e["@aws-amplify/core"],e.rxjs,e["@ng-idle/core"],e["@ng-idle/keepalive"],e.slip39)}(this,(function(e,t,n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I){"use strict";function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var w=C(r),K=C(i),k=C(o),P=b(c),E=C(h),D=function(e,t){return(D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function R(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}D(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function M(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function O(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function A(e,t,n,r){return new(n||(n=Promise))((function(i,a){function s(e){try{c(r.next(e))}catch(e){a(e)}}function o(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}c((r=r.apply(e,t||[])).next())}))}function j(e,t){var n,r,i,a,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}Object.create;function T(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function N(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return s}function $(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(N(arguments[t]));return e}function F(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}Object.create;function U(e){if(e&&e.length){var t=e.map((function(e){return new x({code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,message:e.message,debug:{locations:e.locations,path:e.path}})}));throw new(_.bind.apply(_,$([void 0],t)))}}var L,x=function(e){this._type="KcError",this.code=e.code,this.source=e.source,this.message=e.message,this.debug=e.debug},_=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._type="KcException",this.errors=e}return e.prototype.toString=function(){return this.errors.map((function(e){return JSON.stringify(e,null,2)}))},e}();(L=e.KcErrorCode||(e.KcErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",L.BAD_ARGUMENT="BAD_ARGUMENT",L.BAD_SIGNATURE="BAD_SIGNATURE",L.BAD_STATE="BAD_STATE",L.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",L.CONCURRENT_ACCESS="CONCURRENT_ACCESS",L.CONFIG_ERROR="CONFIG_ERROR",L.CYCLE_DETECTED="CYCLE_DETECTED",L.EXPIRED="EXPIRED",L.INVALID_TOKEN="INVALID_TOKEN",L.INTERNAL_ERROR="INTERNAL_ERROR",L.JSON_DECODE_ERROR="JSON_DECODE_ERROR",L.KEY_MISMATCH="KEY_MISMATCH",L.LIMIT_REACHED="LIMIT_REACHED",L.LOCKED="LOCKED",L.LOGIC_ERROR="LOGIC_ERROR",L.LR_DEBUG_ONLY="LR_DEBUG_ONLY",L.MIN_DELAY="MIN_DELAY",L.MISSING_FIELD="MISSING_FIELD",L.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",L.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",L.NOT_IMPLEMENTED="NOT_IMPLEMENTED",L.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",L.OBJECT_EXISTS="OBJECT_EXISTS",L.RANGE_ERROR="RANGE_ERROR",L.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",L.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",L.USER_NOT_FOUND="USER_NOT_FOUND",L.VERSION_MISMATCH="VERSION_MISMATCH",L.WRONG_PERMISSIONS="WRONG_PERMISSIONS",L.AUTH="AUTH",L.BAD_LOGIC="BAD_LOGIC",L.BAD_REQUEST="BAD_REQUEST",L.BAD_TIME_SYNC="BAD_TIME_SYNC",L.CODE_MISMATCH="CODE_MISMATCH",L.ENCRYPTION="ENCRYPTION",L.NOT_FOUND="NOT_FOUND",L.SUSPICIOUS_OPERATION="SUSPICIOUS_OPERATION",L.UNSUPPORTED="UNSUPPORTED";var J=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.AUTH,message:n}))||this}return R(n,t),n}(_),q=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_ARGUMENT,message:n}))||this}return R(n,t),n}(_),G=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_LOGIC,message:n}))||this}return R(n,t),n}(_),V=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_REQUEST,message:n}))||this}return R(n,t),n}(_),B=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_SIGNATURE,message:n}))||this}return R(n,t),n}(_),Q=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_STATE,message:n}))||this}return R(n,t),n}(_),W=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_TIME_SYNC,message:n}))||this}return R(n,t),n}(_),Z=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.CODE_MISMATCH,message:n}))||this}return R(n,t),n}(_),H=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.CONCURRENT_ACCESS,message:n}))||this}return R(n,t),n}(_),Y=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.ENCRYPTION,message:n}))||this}return R(n,t),n}(_),z=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.INTERNAL_ERROR,message:n}))||this}return R(n,t),n}(_),X=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.LOCKED,message:n}))||this}return R(n,t),n}(_),ee=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.NOT_FOUND,message:n}))||this}return R(n,t),n}(_),te=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.SUSPICIOUS_OPERATION,message:n}))||this}return R(n,t),n}(_),ne=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.UNSUPPORTED,message:n}))||this}return R(n,t),n}(_);function re(e){if(!Array.isArray(e))throw new Error("not array");return e.some((function(e){return null==e?void 0:e.then}))?Promise.all(e):e}function ie(e,t){var n,r,i={};try{for(var a=T(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=N(s.value,2),c=o[0];i[o[1]]=t[c]}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i}function ae(e,t){var n=re(Object.entries(e).map((function(n){var r=N(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return ie(e,t)})):ie(e,n)}function se(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e.currentSession()];case 1:return[2,t.sent().getAccessToken().getJwtToken()];case 2:return t.sent(),[2,""];case 3:return[2]}}))}))}var oe,ce,ue=P,pe=k.default(oe||(oe=F(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),de=function(){function e(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=ue.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return e.prototype.verifyCognito=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,se(this.auth)];case 1:return(e=a.sent())?[4,fetch("https://cognito-idp.ap-southeast-2.amazonaws.com/",{method:"POST",mode:"cors",cache:"no-cache",headers:{"x-amz-target":"AWSCognitoIdentityProviderService.GetUser","x-amz-user-agent":"aws-amplify/0.1.x js","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({AccessToken:e})})]:[2];case 2:if(t=a.sent(),n=Date.now(),r=ue(t.headers.get("Date")).valueOf(),i=n+this.offsetMs,Math.abs(i-r)>this.MAX_DIFF_MSEC)throw new W("Server time does not match independent source. ServerTime: "+i+", Cognito time: "+r);return this.verified=!0,[2]}}))}))},e.prototype.refresh=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:pe}).toPromise()];case 1:return t=a.sent(),n=Date.now(),U(t.errors),r=parseInt(t.data.serverTime.timestamp,10),i=n-e,this.offsetMs=Math.round(r-(e+i/2)),this.VERIFY_ENABLED?[4,this.verifyCognito()]:[3,3];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},e.prototype.serverNow=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,se(this.auth)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:t&&(e=!0),n.label=3;case 3:return e?[4,this.refresh()]:[3,5];case 4:n.sent(),n.label=5;case 5:return[2,Date.now()+this.offsetMs]}}))}))},e.prototype.now=function(){return null===this.offsetMs?(console.error("Server time offset not known. You must await serverNow() first. Returning local clock instead."),Date.now()):Date.now()+this.offsetMs},e.prototype.date=function(){return new Date(this.now())},e}();de.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new de(t.ɵɵinject(s.AuthClass),t.ɵɵinject(n.Apollo))},token:de,providedIn:"root"}),de.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],de.ctorParameters=function(){return[{type:s.AuthClass},{type:n.Apollo}]},function(e){e.JSON="JSON",e.COMPACT="COMPACT"}(ce||(ce={}));var le={payloadType:"json",returnOnlyPayload:!0},ye={payloadType:"json",returnOnlyPayload:!0,serializations:[ce.JSON]};var he=function(){function e(e){this.timeService=e}return e.prototype.decrypt=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(s){switch(s.label){case 0:if(r={algorithms:["dir","A*GCM","RSA-OAEP-*"]},n=Object.assign(Object.assign({},ye),n),e.jwk&&(e=e.jwk),"string"==typeof t&&n.serializations.includes(ce.JSON))try{t=JSON.parse(t)}catch(e){if(!n.serializations.includes(ce.COMPACT))throw e;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,a.JWE.createDecrypt(e,r).decrypt(t)];case 1:return(i=s.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i]}}))}))},e.prototype.encryptToString=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return r=(n=JSON).stringify,[4,this.encrypt(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},e.prototype.encrypt=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s;return j(this,(function(o){switch(o.label){case 0:if(null==t)throw new Error("Encrypting null/undefined content.");return t instanceof ArrayBuffer||(t=(new TextEncoder).encode(JSON.stringify(t))),r=(n=a.JWE).createEncrypt,i={contentAlg:"A256GCM"},s={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(i.fields=(s.timestamp=o.sent(),s),i),e]).update(t).final()]}}))}))},e.prototype.sign=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,o;return j(this,(function(c){switch(c.label){case 0:return i=(r=a.JWS).createSign,s={},o={},[4,this.timeService.serverNow()];case 1:return n=i.apply(r,[(s.fields=(o.timestamp=c.sent(),o),s),e]),t instanceof Buffer?n.update(t):n.update(JSON.stringify(t),"utf8"),[2,n.final()]}}))}))},e.prototype.signToString=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return r=(n=JSON).stringify,[4,this.sign(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},e.prototype.verify=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,s;return j(this,(function(o){switch(o.label){case 0:r={algorithms:["RS*"]},n=Object.assign(Object.assign({},le),n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,a.JWS.createVerify(e,r).verify(t)];case 2:return(i=o.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i];case 3:throw s=o.sent(),new B("Bad signature: "+s);case 4:return[2]}}))}))},e.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return A(this,void 0,void 0,(function(){var e,i,a,s;return j(this,(function(o){switch(o.label){case 0:return a=(i=JSON).stringify,[4,this.encrypt(n,t)];case 1:return e=a.apply(i,[o.sent()]),[4,this.sign(r,e)];case 2:return delete(s=o.sent()).payload,[2,{cipher:e,sig:JSON.stringify(s)}]}}))}))},e.prototype.decodePayload=function(e,t){switch(e){case"json":return JSON.parse((new TextDecoder).decode(t));case"ArrayBuffer":return t;default:throw new q("Unknown payloadType: "+e)}},e}();he.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new he(t.ɵɵinject(de))},token:he,providedIn:"root"}),he.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],he.ctorParameters=function(){return[{type:de}]};var fe=function(){function e(){this.kcCrypto=window.crypto}return e.prototype.toHex=function(e){return Array.from(new Uint8Array(e)).map((function(e){return e.toString(16).padStart(2,"0")})).join("")},e.prototype.stringDigest=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return n=new TextEncoder,r=n.encode(t),[4,this.kcCrypto.subtle.digest(e,r)];case 1:return i=a.sent(),[2,this.toHex(i)]}}))}))},e}();fe.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new fe},token:fe,providedIn:"root"}),fe.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var ve=function(){function e(e){this.webCryptoService=e,this.MIN_PASS_IDP_PBKDF_ITER=1e5,this.MIN_PASS_KEY_PBKDF_ITER=1e5,this.MIN_LBOP_KEY_PBKDF_ITER=1e5,this.DEFAULT_PASS_IDP_PBKDF_ITER=this.MIN_PASS_IDP_PBKDF_ITER,this.DEFAULT_PASS_KEY_PBKDF_ITER=this.MIN_PASS_KEY_PBKDF_ITER,this.DEFAULT_LBOP_KEY_PBKDF_ITER=this.MIN_LBOP_KEY_PBKDF_ITER,this.kcCrypto=this.webCryptoService.kcCrypto}return e.asKey=function(e,t,n){return a.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new q("digits <= 0");var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e);return this.kcCrypto.getRandomValues(n),n=n.map((function(e){return t.charCodeAt(e%t.length)})),String.fromCharCode.apply(null,n)},e.prototype.randomDigitsNoZeros=function(e){return this.randomChoices([1,2,3,4,5,6,7,8,9],e).join("")},e.prototype.randomChoices=function(e,t){if(e.length<=1)throw new q("array.length <= 0");if(t<=0)throw new q("chooseN <= 0");var n=new Uint32Array(t);this.kcCrypto.getRandomValues(n);var r=[];return n.forEach((function(t){return r.push(e[t%e.length])})),r},e.prototype.createSalt=function(){return this.randomString(16)},e.prototype.createKey=function(){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return delete(n=r.sent()).ext,delete n.key_ops,[2,e.asKey(n)]}}))}))},e.prototype.createSignKey=function(){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"HMAC",hash:{name:"SHA-512"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.createPkcKey=function(){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.createPkcSignKey=function(){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.importPassword=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){return t=new TextEncoder,[2,this.kcCrypto.subtle.importKey("raw",t.encode(e),"PBKDF2",!1,["deriveKey"])]}))}))},e.prototype.deriveKey=function(t){var n=t.password,r=t.salt,i=t.iterations,a=t.kid;return A(this,void 0,void 0,(function(){var t,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.kcCrypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode(r),iterations:i,hash:"SHA-256"},n,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=o.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return s=o.sent(),a&&(s.kid=a),[4,e.asKey(s)];case 3:return[2,{jwk:o.sent()}]}}))}))},e.prototype.derivePassIdp=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new te("The number of PassIdp key derivation iterations sent from the server ("+e.iterations+") is lower than the minimum ("+this.MIN_PASS_IDP_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.derivePassKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new te("The number of PassKey key derivation iterations sent from the server("+e.iterations+") is lower than the minimum("+this.MIN_PASS_KEY_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.deriveLbopKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new te("The number of LbopKey key derivation iterations sent from the server("+e.iterations+") is lower than the minimum("+this.MIN_LBOP_KEY_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.createKid=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return e={salt:this.createSalt()},[4,this.createKid()];case 1:return[2,(e.kid=t.sent(),e.iterations=this.DEFAULT_PASS_KEY_PBKDF_ITER,e)]}}))}))},e.prototype.createLbopKeyParams=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return e={salt:this.createSalt()},[4,this.createKid()];case 1:return[2,(e.kid=t.sent(),e.iterations=this.DEFAULT_PASS_KEY_PBKDF_ITER,e)]}}))}))},e}();ve.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ve(t.ɵɵinject(fe))},token:ve,providedIn:"root"}),ve.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ve.ctorParameters=function(){return[{type:fe}]};var me=new t.InjectionToken("KC_CONFIG"),ge=[e.KcErrorCode.CONCURRENT_ACCESS];function Se(e,t){var n;return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return[4,se(e)];case 1:return r=a.sent(),i=null===(n=t.debug)||void 0===n?void 0:n.username,[2,{withCredentials:!0,headers:Object.assign(Object.assign({},r&&{authorization:"Bearer "+r}),i&&{"x-kc-dev-user":i})}]}}))}))}var Ie=function(e,t){var n=p.setContext((function(n,r){var i=r.headers;return A(void 0,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,Se(t,e)];case 1:return n=r.sent(),[2,Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},i),n.headers)})]}}))}))})),r=new d.RetryLink({delay:{initial:300,max:1/0,jitter:!0},attempts:{max:3,retryIf:function(e,t){return!!(e instanceof i&&e.errors.some((function(e){var t;return ge.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})))}}}),i=function(e){function t(t){var n=e.call(this,t.map((function(e){return e.message})).join(", "))||this;return n.errors=t,n}return R(t,e),t}(Error),a=new u.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return ge.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new i(e.errors);return e}))})),s=u.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:u.from([r,a,n,s]),cache:new u.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{fetchPolicy:"no-cache",errorPolicy:"all"}}},e.apolloConfig)},Ce=function(){function e(e,n,r,i){this.keyFactory=e,this.cookieService=n,this.encryptionService=r,this.injector=i,this.KEY_PREFIX="lrSession-",this.cookieSecure=!0,this.serverSessionEncryptionKey=null,t.isDevMode()&&this.setCookieSecure(!1)}return e.prototype.setServerSessionEncryptionKey=function(e){this.serverSessionEncryptionKey=e},e.prototype.clearServerSessionEncryptionKey=function(){this.serverSessionEncryptionKey=null},e.prototype.getCookieParams=function(){return{path:"/",domain:null,secure:this.cookieSecure,sameSite:"Lax"}},e.prototype.clear=function(){var e=this;Object.keys(this.cookieService.getAll()).forEach((function(t){t.startsWith(e.KEY_PREFIX)&&e.deletePrefixedName(t)})),Object.keys(localStorage).forEach((function(t){t.startsWith(e.KEY_PREFIX)&&e.deletePrefixedName(t)}))},e.prototype.setCookieSecure=function(e){if(this.cookieSecure=e,!e){if(!t.isDevMode())throw new q("Can not set PersistService cookie secure flag to false in production mode.");console.warn("The cookie secure flag in persistService has been set to false, set it to true in production mode")}},e.prototype.prefixName=function(e){return this.KEY_PREFIX+e},e.prototype.delete=function(e){this.deletePrefixedName(this.prefixName(e))},e.prototype.deletePrefixedName=function(e){var t=this.getCookieParams();this.cookieService.delete(e,t.path,t.domain,t.secure,t.sameSite),localStorage.removeItem(e)},e.prototype.set=function(e){var t=e.name,n=e.value,r=e.serverSession,i=e.expiry;return A(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return e=this.prefixName(t),r?(s={serverSession:!0},[4,this.encryptionService.encryptToString(this.serverSessionEncryptionKey,n)]):[3,2];case 1:return s.data=d.sent(),a=s,[3,3];case 2:a={data:n},d.label=3;case 3:return i?[4,this.keyFactory.createKey()]:[3,6];case 4:return o=d.sent(),a.expiry=i.toISOString(),c=a,[4,this.encryptionService.encryptToString(o,a.data)];case 5:c.data=d.sent(),u={key:o.toJSON(!0)},p=this.getCookieParams(),this.cookieService.set(e,JSON.stringify(u),i,p.path,p.domain,p.secure,p.sameSite),d.label=6;case 6:return localStorage.setItem(e,JSON.stringify(a)),[2]}}))}))},e.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:t=this.prefixName(e),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getImpl(t)];case 2:return null==(n=i.sent())&&this.deletePrefixedName(t),[2,n];case 3:throw r=i.sent(),this.deletePrefixedName(t),r;case 4:return[2]}}))}))},e.prototype.getImpl=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return(t=localStorage.getItem(e))?(n=JSON.parse(t)).expiry?(i=this.cookieService.get(e))?(a=JSON.parse(i),[4,ve.asKey(a.key)]):(console.log("No cookie."),[2,null]):[3,3]:[2,null];case 1:return s=o.sent(),[4,this.encryptionService.decrypt(s,n.data)];case 2:return r=o.sent(),[3,4];case 3:r=n.data,o.label=4;case 4:return n.serverSession?[4,this.encryptionService.decrypt(this.serverSessionEncryptionKey,r)]:[3,6];case 5:r=o.sent(),o.label=6;case 6:return[2,r]}}))}))},e}();Ce.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ce(t.ɵɵinject(ve),t.ɵɵinject(l.CookieService),t.ɵɵinject(he),t.ɵɵinject(t.INJECTOR))},token:Ce,providedIn:"root"}),Ce.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ce.ctorParameters=function(){return[{type:ve},{type:l.CookieService},{type:he},{type:t.Injector}]};var be,we,Ke=function(){function e(e,t){this.config=e,this.persistService=t,this.STORE_MASTER_KEY="masterKey",this.MIN_PASS_IDP_PBKDF_ITER=1e5,this.MIN_PASS_KEY_PBKDF_ITER=1e5,this.MIN_LBOP_KEY_PBKDF_ITER=1e5,this.DEFAULT_PASS_IDP_PBKDF_ITER=this.MIN_PASS_IDP_PBKDF_ITER,this.DEFAULT_PASS_KEY_PBKDF_ITER=this.MIN_PASS_KEY_PBKDF_ITER,this.DEFAULT_LBOP_KEY_PBKDF_ITER=this.MIN_LBOP_KEY_PBKDF_ITER,this.resetKeys()}return e.prototype.resetKeys=function(){this.keys=null,this.masterKey=null},e.prototype.purgeKeys=function(){this.resetKeys(),this.persistService.clear()},e.prototype.setKeys=function(e){this.keys=e},Object.defineProperty(e.prototype,"currentPassKey",{get:function(){return this.keys.passKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentMasterKey",{get:function(){return this.keys.masterKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRootKey",{get:function(){return this.keys.rootKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentPxk",{get:function(){return this.keys.pxk},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSigPxk",{get:function(){return this.keys.sigPxk},enumerable:!1,configurable:!0}),e.prototype.expiresAfter=function(e){return new Date(Date.now()+1e3*e)},e.prototype.persistMasterKey=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return n={id:e.id,jwk:e.jwk.toJSON(!0)},this.masterKey=e,[4,this.persistService.set({name:this.STORE_MASTER_KEY,value:n,expiry:this.expiresAfter(t),serverSession:!this.config.disableSessionEncryptionKey})];case 1:return r.sent(),[2]}}))}))},e.prototype.setMasterKeyExpiresAfterSeconds=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.persistService.get(this.STORE_MASTER_KEY)];case 1:if(null==(t=n.sent()))throw new ee("Can not find masterKey in persisted storage using name: "+this.STORE_MASTER_KEY);return[4,this.persistService.set({name:this.STORE_MASTER_KEY,value:t,expiry:this.expiresAfter(e),serverSession:!this.config.disableSessionEncryptionKey})];case 2:return n.sent(),[2]}}))}))},e.prototype.loadMasterKey=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return this.masterKey?[3,3]:[4,this.persistService.get(this.STORE_MASTER_KEY)];case 1:if(!(t=r.sent()))throw new ee("Could not find masterKey in persisted storage");if(t.id!==e)throw new ee("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,ve.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();Ke.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ke(t.ɵɵinject(me),t.ɵɵinject(Ce))},token:Ke,providedIn:"root"}),Ke.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ke.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:Ce}]},function(e){e.Key="key",e.PassKey="passKey"}(be||(be={})),function(e){e.KeyLink="keyLink",e.PassKeyLink="passKeyLink"}(we||(we={}));var ke=function(){function e(e,t,n){this.encryptionService=e,this.keyService=t,this.keyFactory=n,this.purgeKeys()}return e.prototype.purgeKeys=function(){this.graph=new r.Graph},e.prototype.populateKeys=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return n=(t=this.keyService).setKeys,r={passKey:e.passKey},[4,this.keyService.loadMasterKey(e.masterKey.id)];case 1:return r.masterKey=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.rootKey.id)];case 2:return r.rootKey=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.pxk.id)];case 3:return r.pxk=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.sigPxk.id)];case 4:return n.apply(t,[(r.sigPxk=i.sent(),r)]),[2]}}))}))},e.prototype.hasKey=function(e){return!!this.graph.node(e)},e.prototype.getNode=function(e,t){var n=this.graph.node(e);if(!n)throw new ee("Key graphs does not contain key id: "+e);if(n.type!==t)throw new Q("Key with id "+e+" is not of type "+t);return n.data},e.prototype.key=function(e){return this.getNode(e,be.Key)},e.prototype.passKey=function(e){return this.getNode(e,be.PassKey)},e.prototype.addKeys=function(e){var t,n,r,i,a,s;if(e.keys)try{for(var o=T(e.keys),c=o.next();!c.done;c=o.next()){var u=c.value;if(!this.graph.hasNode(u.id)){var p={type:be.Key,data:K.default.cloneDeep(u)};this.graph.setNode(u.id,p)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}if(e.keyLinks)try{for(var d=T(e.keyLinks),l=d.next();!l.done;l=d.next()){var y=l.value;if(!this.graph.hasEdge(y.wrappingKeyId,y.keyId)){var h={type:we.KeyLink,data:K.default.cloneDeep(y)};this.graph.setEdge(y.wrappingKeyId,y.keyId,h)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}if(e.passKeyLinks)try{for(var f=T(e.passKeyLinks),v=f.next();!v.done;v=f.next()){var m=v.value;if(!this.graph.hasEdge(m.passKeyId,m.keyId)){h={type:we.PassKeyLink,data:K.default.cloneDeep(m)};this.graph.setEdge(m.passKeyId,m.keyId,h)}}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}},e.prototype.tracePath=function(e,t){var n=[],r=t;if(!e[r].predecessor)return null;for(;e[r].predecessor;){var i=e[r].predecessor;n.push(this.graph.edge(i,r)),r=i}return n.reverse(),n},e.prototype.getPath=function(e,t){if(!e||"string"!=typeof e)throw new Y("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new Y("Param keyId wrong format: "+t);var n=w.default.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},e.prototype.getJwkKey=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.getKey(e,t)];case 1:return[2,n.sent().jwk]}}))}))},e.prototype.getKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return n="string"==typeof e?e:null==e?void 0:e.id,this.hasKey(n)||!t?[3,2]:[4,t()];case 1:n=i.sent(),i.label=2;case 2:return(r=this.key(n)).jwk?[2,r]:[2,this.unwrapKey(this.keyService.currentMasterKey.id,n)]}}))}))},e.prototype._unwrapLink=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a;return j(this,(function(s){switch(s.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=s.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=s.sent(),s.label=4;case 4:return a=n,[4,ve.asKey(i)];case 5:return a.jwk=s.sent(),n.task=null,[2]}}))}))},e.prototype._unwrap=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return j(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=T(t),r=n.next(),u.label=1;case 1:return r.done?[3,4]:(i=r.value,(a=this.key(i.data.keyId)).jwk?(e=a.jwk,[3,3]):(a.task||(a.task=this._unwrapLink(e,i,a)),[4,a.task]));case 2:u.sent(),e=a.jwk,u.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return s=u.sent(),o={error:s},[3,7];case 6:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 7:return[2,e]}}))}))},e.prototype.unwrapWithPassKey=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return r=this.getPath(e,n),i={id:n},[4,this._unwrap(t,r)];case 1:return[2,(i.jwk=a.sent(),i)]}}))}))},e.prototype.unwrapKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.keyService.loadMasterKey(e)];case 1:return n=a.sent(),e===t?[2,n]:(r=this.getPath(n.id,t),i={id:t},[4,this._unwrap(n.jwk,r)]);case 2:return[2,(i.jwk=a.sent(),i)]}}))}))},e.prototype.decryptFromString=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return t?[4,this.getJwkKey(e)]:[3,3];case 1:return r=i.sent(),[4,this.encryptionService.decrypt(r,JSON.parse(t),n)];case 2:return[2,i.sent()];case 3:return[2,null]}}))}))},e.prototype.decryptFile=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getJwkKey(e)];case 1:return n=r.sent(),[4,this.encryptionService.decrypt(n,t,{payloadType:"ArrayBuffer"})];case 2:return[2,r.sent()]}}))}))},e.prototype.encryptToString=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return null==t?[2,null]:(r=function(e){return e.id&&e.jwk?e.jwk:e.keystore&&e.length&&e.kty&&e.kid&&e.alg?e:null}(e))?[3,2]:[4,this.getJwkKey(e)];case 1:r=i.sent(),i.label=2;case 2:return n=r,[2,this.encryptionService.encryptToString(n,t)]}}))}))},e.prototype.wrapKey=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){if(!function(e){return"oct"===e.kty}(t))throw new q("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},e.prototype.encryptWithNewKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=a.sent(),[4,this.encryptToString(e,n.toJSON(!0))];case 2:return r=a.sent(),[4,this.encryptToString(n,t)];case 3:return i=a.sent(),[2,{key:n,wrappingKeyId:e,wrappedKey:r,cipher:i}]}}))}))},e}();ke.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ke(t.ɵɵinject(he),t.ɵɵinject(Ke),t.ɵɵinject(ve))},token:ke,providedIn:"root"}),ke.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ke.ctorParameters=function(){return[{type:he},{type:Ke},{type:ve}]};var Pe=function(){function e(e,t){this.apollo=e,this.keyGraph=t}return e.prototype.addKeys=function(e){e.data.keyGraph&&this.keyGraph.addKeys(e.data.keyGraph)},e.prototype.query=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return U((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return U((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();function Ee(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new G("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function De(e){return Ee(e,"query")}function Re(e){return Ee(e,"mutation")}function Me(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Oe(e){return{kind:"Name",value:e}}function Ae(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function je(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return k.default.apply(void 0,$([e],t))}Pe.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Pe(t.ɵɵinject(n.Apollo),t.ɵɵinject(ke))},token:Pe,providedIn:"root"}),Pe.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Pe.ctorParameters=function(){return[{type:n.Apollo},{type:ke}]};var Te,Ne,$e,Fe,Ue,Le,xe,_e,Je="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",qe=k.default(Te||(Te=F(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),Je),Ge="keyGraph "+Je,Ve="keyGraph: fetchKeyGraph "+Je,Be=k.default(Ne||(Ne=F(["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),qe),Qe=k.default($e||($e=F(["\n query Directory($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n directory(id: $id) {\n id\n keyId\n plainMeta\n cipherMeta\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query Directory($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n directory(id: $id) {\n id\n keyId\n plainMeta\n cipherMeta\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),qe),We=k.default(Fe||(Fe=F(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Ze=k.default(Ue||(Ue=F(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),He=k.default(Le||(Le=F(["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),Ye=k.default(xe||(xe=F(["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),ze=k.default(_e||(_e=F(["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),Xe=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function et(e){var t=e.ngZoneName,n=e.exceptLastPromise,r=void 0===n||n,i=e.excludeMethods,a=void 0===i?[]:i,s=e.patchSetters,o=void 0===s||s;return function(e){function n(n,i){var a=this;if(!this[t])throw new G("RunOutsideAngular decorator requires that "+e.name+" inject NgZone as "+t);var s=this[t].runOutsideAngular((function(){return n.apply(a,i)}));return r&&(null==s?void 0:s.then)?Promise.resolve(s):s}return a=$(a,Xe),Object.getOwnPropertyNames(e.prototype).filter((function(e){return!a.includes(e)})).forEach((function(t){if(o&&Object.getOwnPropertyDescriptor(e.prototype,t).set){var r=Object.getOwnPropertyDescriptor(e.prototype,t).set;Object.defineProperty(e.prototype,t,{set:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,[r,e])}})}if("function"==typeof e.prototype[t]){var i=e.prototype[t];e.prototype[t]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,[i,e])}}})),e}}var tt={hasKeys:!0};function nt(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s=this;return j(this,(function(o){switch(o.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,Promise.all(e.edges.map((function(e){return A(s,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,t(e.node)];case 1:return[2,r.apply(n,i.concat([(a.node=s.sent(),a)]))]}}))}))})))];case 1:return[2,r.apply(n,i.concat([(a.edges=o.sent(),a)]))]}}))}))}function rt(e,t){return Object.assign(Object.assign({},e),{path:$(e.path,[t])})}e.CommonProcessorsService=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.series=function(e){var t=this;return function(n){var r=n.field,i=n.context,a=n.options;return A(t,void 0,void 0,(function(){var t,n,s,o,c;return j(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),t=T(e),n=t.next(),u.label=1;case 1:return n.done?[3,4]:[4,(0,n.value)({field:r,context:i,options:a})];case 2:r=u.sent(),u.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return s=u.sent(),o={error:s},[3,7];case 6:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 7:return[2,r]}}))}))}},e.prototype.makeJsonParseProcessor=function(e){var t=void 0===e?{}:e,n=t.plainFieldName,r=t.jsonFieldSuffix,i=n+(void 0===r?"Json":r);return function(e){var t,r=e.field;if(null==r[n]||i in r)return r;try{return Object.assign(Object.assign({},r),((t={})[i]=JSON.parse(r[n]),t))}catch(e){return r}}},e.prototype.makeDecryptionProcessor=function(e){var t=this,n=void 0===e?{}:e,r=n.cipherFieldName,i=n.clearFieldSuffix,a=void 0===i?"ClearJson":i,s=n.getKeyId,o=void 0===s?null:s,c=r+a;return function(e){return A(t,void 0,void 0,(function(){var t,n,i,a,s,u;return j(this,(function(p){switch(p.label){case 0:return n=e.field,i=e.context,e.options.hasKeys?!(a=n[r])||c in n?[2,n]:o?[4,o(e)]:[3,2]:[2,n];case 1:return u=p.sent(),[3,3];case 2:u=n.keyId||(null===(t=n.key)||void 0===t?void 0:t.id),p.label=3;case 3:if(!(s=u))throw new G("Query response does not contain "+(o?"key-id":"keyId or key.id")+" field: "+i.path.join("."));return[2,this.keyGraph.decryptFromString(s,a).then((function(e){var t;return Object.assign(Object.assign({},n),((t={})[c]=e,t))}))]}}))}))}},e}(),e.CommonProcessorsService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.CommonProcessorsService(t.ɵɵinject(t.NgZone),t.ɵɵinject(ke))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:t.NgZone},{type:ke}]},e.CommonProcessorsService=O([et({ngZoneName:"ngZone"})],e.CommonProcessorsService),e.ɵg=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUserNode=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,a,s=this;return j(this,(function(o){switch(o.label){case 0:return(r=null===(t=e.pxk)||void 0===t?void 0:t.id)?[4,this.keyGraph.getKey(e.pxk.id)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return n=r,i=Object.assign({},e),n&&e.approvals?(a=i,[4,Promise.all(e.approvals.map((function(e){return s.processTpPasswordResetUserApprovalNode(e,n)})))]):[3,4];case 3:a.approvals=o.sent(),o.label=4;case 4:return[2,i]}}))}))},e.prototype.processTpPasswordResetUserApprovalNode=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return n=Object.assign({},e),e.receiverCipher&&(n.receiverCipherClearJson=this.keyGraph.decryptFromString(t,e.receiverCipher)),e.receiverCipherPartialAssemblyKey?(r=n,[4,this.keyGraph.decryptFromString(t,e.receiverCipherPartialAssemblyKey)]):[3,2];case 1:r.receiverCipherPartialAssemblyKeyClearJson=i.sent(),i.label=2;case 2:return[2,n]}}))}))},e.prototype.makeTpPasswordResetNodeProcessor=function(){var e=this;return function(t){var n=t.field;return A(e,void 0,void 0,(function(){var e,t;return j(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new V('If you request for field "assembly" in the TpPasswordResetNode, then you must also request the "applied" field');return t=e,[4,this.processTpAssemblyNode(n.assembly,n.applied)];case 1:t.assembly=r.sent(),r.label=2;case 2:return[2,e]}}))}))}},e.prototype.processTpAssemblyNode=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return j(this,(function(y){switch(y.label){case 0:return n=e.subjectKey,r=e.assemblyKey,i=e.assemblyCipherData,a=e.subAssemblies,c=(o=Object).assign,u=[Object.assign({},e)],p={},[4,nt(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=y.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=y.sent(),y.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return j(this,(function(l){switch(l.label){case 0:return r=e.subjectCipherData,i=e.approvers,o=(s=Object).assign,c=[Object.assign({},e)],u={},[4,nt(i,(function(e){return d.processTpAssemblyApproverNode(e,n)}))];case 1:return a=o.apply(s,c.concat([(u.approvers=l.sent(),u)])),n?[3,3]:r?(p=a,[4,this.keyGraph.decryptFromString(t,r)]):[3,3];case 2:p.subjectCipherDataClearJson=l.sent(),l.label=3;case 3:return[2,a]}}))}))},e.prototype.processTpAssemblyApproverNode=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,e]}))}))},e}(),e.ɵg.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵg(t.ɵɵinject(t.NgZone),t.ɵɵinject(ke))},token:e.ɵg,providedIn:"root"}),e.ɵg.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵg.ctorParameters=function(){return[{type:t.NgZone},{type:ke}]},e.ɵg=O([et({ngZoneName:"ngZone"})],e.ɵg),e.QueryProcessorService=function(){function e(e,t,n,r){this.ngZone=e,this.keyService=t,this.common=n,this.tpprProcessor=r,this.TYPENAME="__typename",this.processors={},this.registerProcessor("DirectoryNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("FileStateNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("ContactCardNode",n.makeDecryptionProcessor({cipherFieldName:"cipherData"})),this.registerProcessor("SharedContactCardNode",n.series([n.makeJsonParseProcessor({plainFieldName:"ownerPlainData"}),n.makeDecryptionProcessor({cipherFieldName:"ownerCipherData",getKeyId:function(e){return e.field.ownerKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"receiverCipherData",getKeyId:function(e){return e.field.receiverKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpPasswordResetNode",this.tpprProcessor.makeTpPasswordResetNodeProcessor()),this.registerProcessor("SharedTpClaimApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyAsApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioReceiverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverDirectoryNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioApproverAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"assemblyCipherData",getKeyId:function(e){return e.field.assemblyKey.id}})])),this.registerProcessor("ScenarioApproverSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioClaimantNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("TpSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("NotificationNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeJsonParseProcessor({plainFieldName:"plainData"})])),this.registerProcessor("UserNode",n.series([n.makeJsonParseProcessor({plainFieldName:"config"})])),this.registerProcessor("ReminderNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plain"})]))}return e.prototype.processQuery=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){return t=Object.assign(Object.assign({},tt),t),[2,ae(e,(function(e,r){return n.processField({field:e,context:{path:[r],processChildren:!0},options:t})}))]}))}))},e.prototype.processField=function(e){var t=e.field,n=e.context,r=e.options;return A(this,void 0,void 0,(function(){var e,i,a,s=this;return j(this,(function(o){if(null==t?void 0:t.then)throw new G("processField() should not receive thenable.");return null==t?[2,null]:(e={field:t,context:Object.assign(Object.assign({},n),{processChildren:!0}),options:r},t[this.TYPENAME]?((i=this.processors[t[this.TYPENAME]])&&(t=i(e)),a=function(e){return n.processChildren&&null!==e&&"object"==typeof e?ae(e,(function(e,t){return s.processField({field:e,context:rt(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=re(t.map((function(e,t){return s.processField({field:e,context:rt(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new G("Processor for field "+e+" already exists.");this.processors[e]=t},e}(),e.QueryProcessorService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.QueryProcessorService(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ke),t.ɵɵinject(e.CommonProcessorsService),t.ɵɵinject(e.ɵg))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:t.NgZone},{type:Ke},{type:e.CommonProcessorsService},{type:e.ɵg}]},e.QueryProcessorService=O([et({ngZoneName:"ngZone"})],e.QueryProcessorService);var it,at,st,ot=function(){function e(){var e=this;this._fulfilled=!1,this.promise=new Promise((function(t,n){e._resolve=t,e._reject=n})).finally((function(){e._fulfilled=!0}))}return Object.defineProperty(e.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fulfilled",{get:function(){return this._fulfilled},enumerable:!1,configurable:!0}),e}(),ct=De(k.default(it||(it=F(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],ut=function(){function e(){this._executed=!1,this.deferredPromise=new ot}return Object.defineProperty(e.prototype,"promise",{get:function(){return this.deferredPromise.promise},enumerable:!1,configurable:!0}),e.prototype.resolve=function(e){this.deferredPromise.resolve(e)},e.prototype.reject=function(e){this.deferredPromise.reject(e)},Object.defineProperty(e.prototype,"lrMutationData",{get:function(){return{mutation:this.mutation,variables:this.variables}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"executed",{get:function(){return this._executed},enumerable:!1,configurable:!0}),e.prototype.setExecuted=function(){if(this._executed)throw new Q("Already executed");this._executed=!0},e}(),pt=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return R(t,e),t.prototype.select=function(e){var n=i.cloneDeep(this.mutation),r=Re(n),a={};Me(e).forEach((function(e){a[e.name.value]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=Ae(t);a[n]&&(t.selectionSet.selections=[Object.assign(Object.assign({},ct),{name:Oe(n)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:$(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(ut),dt={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},lt=function(e){function t(t){var n=e.call(this)||this;n.lrMutations=t;var r=n.merge(),i=r.mutation,a=r.variables,s=r.prefixes;return n.mutation=i,n.variables=a,n.prefixes=s,n.descendants=n.getDescendants(),n}return R(t,e),t.create=function(e){return new t(e)},t.prototype.getDescendants=function(){var e=new Set,n=function(t){if(e.has(t))throw new G("Classes that are derived from LrMutationBase can not be used more than once in a merged mutation.");e.add(t)};return this.lrMutations.forEach((function(e){if(e instanceof pt)n(e);else{if(!(e instanceof t))throw new ne("LrMergeMutation can not handle class: "+e.constructor.name);e.descendants.forEach((function(e){return n(e)}))}})),e},t.prototype.resolve=function(t){for(var n=this,r=0;r<this.lrMutations.length;++r){var i=this.prefixes[r],a={};for(var s in t){if(s.startsWith(i))a[s.slice(i.length)]=t[s]}this.lrMutations[r].resolve(a)}Promise.all(this.lrMutations.map((function(e){return e.promise}))).then((function(t){e.prototype.resolve.call(n,t)}))},t.prototype.reject=function(t){e.prototype.reject.call(this,t),this.lrMutations.forEach((function(e){return e.reject(t)}))},t.prototype.setExecuted=function(){e.prototype.setExecuted.call(this),this.lrMutations.forEach((function(e){return e.setExecuted()}))},t.prototype.renameVariableDefinition=function(e,t){return Object.assign(Object.assign({},e),{variable:Object.assign(Object.assign({},e.variable),{name:Oe(t+e.variable.name.value)})})},t.prototype.renameVariableDefinitions=function(e,t){var n=this;return e.map((function(e){return n.renameVariableDefinition(e,t)}))},t.prototype.renameArgument=function(e,t){return"Variable"!==e.value.kind?e:Object.assign(Object.assign({},e),{value:Object.assign(Object.assign({},e.value),{name:Oe(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+Ae(e),i=e.arguments.map((function(e){return n.renameArgument(e,t)}));return Object.assign(Object.assign({},e),{alias:{kind:"Name",value:r},arguments:i})},t.prototype.renameFragmentSpread=function(e,t){return Object.assign(Object.assign({},e),{name:Oe(t+e.name.value)})},t.prototype.processSelection=function(e,t){switch(e.kind){case"FragmentSpread":return this.renameFragmentSpread(e,t);case"Field":return e.selectionSet?Object.assign(Object.assign({},e),{selectionSet:this.processSelectionSet(e.selectionSet,t)}):e;default:return e}},t.prototype.processSelectionSet=function(e,t){var n=this;return Object.assign(Object.assign({},e),{selections:e.selections.map((function(e){return n.processSelection(e,t)}))})},t.prototype.renameSelections=function(e,t){var n=this;return e.map((function(e){switch(e.kind){case"Field":return n.processSelection(n.renameField(e,t),t);default:return e}}))},t.prototype.renameFragmentDefinition=function(e,t){var n=Object.assign(Object.assign({},e),{name:Oe(t+e.name.value)});return e.selectionSet&&(n.selectionSet=this.processSelectionSet(e.selectionSet,t)),n},t.prototype.renameFragmentDefinitions=function(e,t){var n=this;return e.map((function(e){return n.renameFragmentDefinition(e,t)}))},t.prototype.merge=function(){var e=this,t=[],n=[],r={},a=[],s=[];this.lrMutations.forEach((function(i,o){var c,u;if(!(i instanceof ut))throw new G("An mutation in the array is not of type LrMutationBase.");var p=i.lrMutationData,d=p.mutation,l=p.variables,y=Re(d),h="item"+o+"_";y.name&&(h+=y.name.value+"_"),s.push(h),t=$(t,e.renameVariableDefinitions(y.variableDefinitions,h)),n=$(n,e.renameSelections(y.selectionSet.selections,h));try{for(var f=T(Object.keys(l)),v=f.next();!v.done;v=f.next()){var m=v.value;r[h+m]=l[m]}}catch(e){c={error:e}}finally{try{v&&!v.done&&(u=f.return)&&u.call(f)}finally{if(c)throw c.error}}var g=Me(d);a=$(a,e.renameFragmentDefinitions(g,h))}));var o=i.cloneDeep(dt),c=Re(o);return c.selectionSet.selections=n,c.variableDefinitions=t,o.definitions=$(o.definitions,a),{mutation:o,variables:r,prefixes:s}},t}(ut),yt=De(k.default(at||(at=F(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Ge)).selectionSet.selections[0],ht=De(k.default(st||(st=F(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Ve)).selectionSet.selections[0];e.ɵf=function(){function e(e,t,n,r){this.ngZone=e,this.apollo=t,this.keyGraph=n,this.queryProcessor=r,this.stats={queryCount:0,mutationCount:0}}return e.prototype.query=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return e=i.cloneDeep(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=De(e.query)).selectionSet.selections=$(t.selectionSet.selections,[yt])),e.name&&((t=De(e.query)).name={kind:"Name",value:e.name}),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,U(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.lrMutateImpl=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){if(null==t?void 0:t.variables)throw new ne('Unsupported field: "options.variables"');if(e.executed)throw new Q("LrMutation has already executed. LrMutation can only be used once in a lrMutate() call. Create new instances of LrMutation.");return e.setExecuted(),[2,this.apolloMutate(Object.assign(Object.assign({},t),e.lrMutationData)).then((function(t){return e.resolve(t),t})).catch((function(t){throw e.reject(t),t}))]}))}))},e.prototype.apolloMutate=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:i.cloneDeep(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Re(e.mutation)).selectionSet.selections=$(t.selectionSet.selections,[ht])),e.name&&((t=Re(e.mutation)).name={kind:"Name",value:e.name}),e.mutation=k.default(y.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,U(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return i.cloneDeep(this.stats)},e.prototype.addKeys=function(e){e.data.keyGraph&&(this.keyGraph.addKeys(e.data.keyGraph),delete e.data.keyGraph)},e.prototype.isIncludeKeyGraph=function(e){return null==e},e.prototype.lrMutate=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=lt).create,[4,Promise.all(e)]):[3,3];case 1:return n=i.apply(r,[s.sent()]),[4,this.lrMutateImpl(n,t)];case 2:return s.sent(),[2,n.promise];case 3:return[4,e];case 4:return a=s.sent(),[4,this.lrMutateImpl(a,t)];case 5:return s.sent(),[2,a.promise]}}))}))},e}(),e.ɵf.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵf(t.ɵɵinject(t.NgZone),t.ɵɵinject(n.Apollo),t.ɵɵinject(ke),t.ɵɵinject(e.QueryProcessorService))},token:e.ɵf,providedIn:"root"}),e.ɵf.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵf.ctorParameters=function(){return[{type:t.NgZone},{type:n.Apollo},{type:ke},{type:e.QueryProcessorService}]},e.ɵf=O([et({ngZoneName:"ngZone"})],e.ɵf);var ft,vt,mt,gt,St,It,Ct,bt,wt,Kt,kt,Pt,Et,Dt,Rt,Mt,Ot,At=function(){function t(t){this.lrGraphQL=t.get(e.ɵf)}return t.prototype.mutate=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();function jt(e){return e.edges.map((function(e){return e.node}))}(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED",(ft=e.PlanState||(e.PlanState={})).ENABLED="ENABLED",ft.DISABLED="DISABLED",(vt=e.AccessRoleChoice||(e.AccessRoleChoice={})).READER="READER",vt.WRITER="WRITER",vt.ADMIN="ADMIN",vt.DENY="DENY",vt.OWNER="OWNER",(mt=e.AccessRoleMethodChoice||(e.AccessRoleMethodChoice={})).INHERITED="INHERITED",mt.DIRECT="DIRECT",(gt=e.PermissionChoice||(e.PermissionChoice={})).CREATE="CREATE",gt.READ="READ",gt.UPDATE="UPDATE",gt.DELETE="DELETE",gt.SHARE="SHARE",gt.ARCHIVE="ARCHIVE",gt.ACCESS_ARCHIVED="ACCESS_ARCHIVED",gt.UNARCHIVE="UNARCHIVE",gt.SET_CONFIDENTIAL="SET_CONFIDENTIAL",(St=e.FileOperationField||(e.FileOperationField={})).CREATE="CREATE",St.READ="READ",St.UPDATE="UPDATE",St.REVERT="REVERT",St.DELETE="DELETE",(It=e.KeyExchangeOtkState||(e.KeyExchangeOtkState={})).OTK_INITIATED="OTK_INITIATED",It.OTK_ACCEPTED="OTK_ACCEPTED",It.OTK_COMPLETED="OTK_COMPLETED",(Ct=e.KeyExchangeState||(e.KeyExchangeState={})).IN_PROGRESS="IN_PROGRESS",Ct.COMPLETED="COMPLETED",Ct.DECLINED="DECLINED",Ct.CANCELLED="CANCELLED",Ct.DELETED="DELETED",(e.KeyExchangeMode||(e.KeyExchangeMode={})).OTK="OTK",(bt=e.TpAssemblyState||(e.TpAssemblyState={})).DISABLED="DISABLED",bt.ENABLED="ENABLED",bt.CLAIMED="CLAIMED",bt.APPROVED="APPROVED",bt.REJECTED="REJECTED",bt.EXPIRED="EXPIRED",bt.CANCELLED="CANCELLED",bt.RESET="RESET",(wt=e.TpClaimState||(e.TpClaimState={})).CLAIMED="CLAIMED",wt.APPROVED="APPROVED",wt.REJECTED="REJECTED",wt.EXPIRED="EXPIRED",wt.CANCELLED="CANCELLED",wt.RESET="RESET",(Kt=e.TpClaimApproverState||(e.TpClaimApproverState={})).CLAIMED="CLAIMED",Kt.APPROVED="APPROVED",Kt.REJECTED="REJECTED",(kt=e.LockState||(e.LockState={})).UNLOCKED="UNLOCKED",kt.MUTEX_LOCKED="MUTEX_LOCKED",(Pt=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",Pt.ENABLED="ENABLED",Pt.CLAIMED="CLAIMED",Pt.APPROVED="APPROVED",(Et=e.ClaimState||(e.ClaimState={})).CLAIMED="CLAIMED",Et.EXPIRED="EXPIRED",Et.APPROVED="APPROVED",Et.REJECTED="REJECTED",Et.CANCELLED="CANCELLED",Et.RESET="RESET",(Dt=e.ClaimApproverState||(e.ClaimApproverState={})).CLAIMED="CLAIMED",Dt.APPROVED="APPROVED",Dt.REJECTED="REJECTED",(Rt=e.ScenarioLastClaimState||(e.ScenarioLastClaimState={})).CLAIMED="CLAIMED",Rt.APPROVED="APPROVED",Rt.REJECTED="REJECTED",Rt.EXPIRED="EXPIRED",Rt.CANCELLED="CANCELLED",Rt.RESET="RESET",(Mt=e.LinkTypeField||(e.LinkTypeField={})).HARD="HARD",Mt.SOFT="SOFT",(Ot=e.PlanStateField||(e.PlanStateField={})).TRIALLING="TRIALLING",Ot.ACTIVE="ACTIVE",Ot.CANCELLED="CANCELLED",Ot.EXPIRED="EXPIRED";var Tt,Nt=function(e){var t=window.fetch;return function(n,r){var i=function(){return t(n,r)};if(!r||!r.headers||!r.headers["X-Amz-Target"])return i();var a=r.headers["X-Amz-Target"].split(".");if(a.length<2||"AWSCognitoIdentityProviderService"!==a[0])return i();var s=JSON.parse(r.body);if(s&&s.ClientMetadata&&"true"===s.ClientMetadata.noProxy)return i();var o=!1;if("RespondToAuthChallenge"===a[1]){if(s&&"NEW_PASSWORD_REQUIRED"===s.ChallengeName)return i();o=!0}else"InitiateAuth"===a[1]&&"REFRESH_TOKEN_AUTH"===s.AuthFlow&&(o=!0);return o?t(e+"auth/proxy/",Object.assign(Object.assign({},r),{credentials:"include"})):i()}},$t=function(e,t){var n=e.authUrl,r=e.userPoolId,i=e.userPoolWebClientId;return function(){var e=r.split("_");if(e.length<2)throw new Error("userPoolId should have this format: {aws-region}_xxxxx");window.fetch=Nt(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}},Ft=function(e){function t(){var t=e.apply(this,$(arguments))||this;return t.isTpPasswordResetUser=!1,t}return R(t,e),t}(h.CognitoUser),Ut=function(){},Lt=function(){};!function(e){e.NONE="none",e.NEW_PASSWORD="new-password",e.OLD_PASSWORD="old-password"}(e.RecoveryStatus||(e.RecoveryStatus={})),(Tt=e.Config||(e.Config={}))[Tt.TIMEOUT=.01]="TIMEOUT",Tt[Tt.IDLE=1200]="IDLE",Tt[Tt.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var xt=function(){function t(e,t,n,r,i,a){this.config=e,this.http=t,this.idle=n,this.keepalive=r,this.keyService=i,this.auth=a,this.IDLE_EXPIRY_KEY="ng2Idle.main.expiry",this.IDLING_KEY="ng2Idle.main.idling",this.initCalled=!1}return t.prototype.assertInit=function(){if(!this.initCalled)throw new Q("Call IdleService.init() first.")},t.prototype.init=function(t){return A(this,void 0,void 0,(function(){var n,r=this;return j(this,(function(i){switch(i.label){case 0:if(this.initCalled)throw new Q("IdleService.init() can only be called once. IdleService.start() calls init() with default values if init() has not been called yet.");if(this.initCalled=!0,(t=Object.assign({onTimeout:null,onKeepalive:null,idleSec:e.Config.IDLE,timeoutSec:e.Config.TIMEOUT,keepAliveIntervalSec:e.Config.KEEP_ALIVE_INTERVAL},t)).timeoutSec<.01)throw new q("Minimum value for IdleService.init({ timeoutSec }) is 0.01");return this.onTimeout=t.onTimeout,this.onKeepalive=t.onKeepalive,this.idle.setIdle(t.idleSec),this.idle.setTimeout(t.timeoutSec),this.idle.setInterrupts(g.DEFAULT_INTERRUPTSOURCES),this.idle.onIdleEnd.subscribe((function(){return console.log("Idle stopped")})),this.idle.onIdleStart.subscribe((function(){return console.log("Idle started")})),this.idle.onTimeout.subscribe((function(){return A(r,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())];case 1:return e.sent(),[2]}}))}))})),this.idle.onTimeoutWarning.subscribe((function(e){return console.log("Will timeout in "+e+" seconds!")})),this.keepalive.interval(t.keepAliveIntervalSec),console.log("Keep alive interval set at: "+e.Config.KEEP_ALIVE_INTERVAL+" seconds"),this.keepalive.onPing.subscribe((function(){return r.onPing()})),(n=localStorage.getItem(this.IDLE_EXPIRY_KEY))&&parseInt(n,10)+1e3*this.idle.getTimeout()<Date.now()?(this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return A(this,void 0,void 0,(function(){var e,t,n;return j(this,(function(r){switch(r.label){case 0:return t=(e=this.http).post,n=[this.config.authUrl+"auth/keepalive/",null],[4,Se(this.auth,this.config)];case 1:return[4,t.apply(e,n.concat([r.sent()])).toPromise()];case 2:return[2,{keepaliveResult:r.sent(),expiresAfterSeconds:this.idle.getIdle()+this.idle.getTimeout()+this.keepalive.interval()}]}}))}))},t.prototype.persistMasterKey=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.keepalivePost()];case 1:return t=n.sent().expiresAfterSeconds,[4,this.keyService.persistMasterKey(e,t)];case 2:return n.sent(),console.log("setMasterKey() done"),[2]}}))}))},t.prototype.onPing=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return console.log("Keep alive triggered at time: "+Date.now()+". Interval set at: "+this.keepalive.interval()+" seconds"),[4,this.keepalivePost()];case 1:return e=t.sent().expiresAfterSeconds,[4,this.keyService.setMasterKeyExpiresAfterSeconds(e)];case 2:return t.sent(),[4,Promise.resolve(this.onKeepalive&&this.onKeepalive())];case 3:return t.sent(),[2]}}))}))},t.prototype.start=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return this.initCalled?[3,2]:[4,this.init()];case 1:e.sent(),e.label=2;case 2:return this.idle.isRunning()?[2]:[4,this.onPing()];case 3:return e.sent(),this.idle.watch(),[2]}}))}))},t.prototype.stop=function(){this.idle.stop(),this.reset()},t.prototype.reset=function(){localStorage.removeItem(this.IDLE_EXPIRY_KEY),localStorage.removeItem(this.IDLING_KEY)},t}();xt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new xt(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(g.Idle),t.ɵɵinject(S.Keepalive),t.ɵɵinject(Ke),t.ɵɵinject(s.AuthClass))},token:xt,providedIn:"root"}),xt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],xt.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:g.Idle},{type:S.Keepalive},{type:Ke},{type:s.AuthClass}]};var _t,Jt,qt,Gt,Vt,Bt,Qt,Wt="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",Zt=(k.default(_t||(_t=F(["\nquery ContactCardQuery(\n$id: LrRelayIdInput!\n) {\ncontactCard (\n id: $id\n) {\n ","\n}\n","\n}"],["\nquery ContactCardQuery(\n$id: LrRelayIdInput!\n) {\ncontactCard (\n id: $id\n) {\n ","\n}\n","\n}"])),Wt,Ge),k.default(Jt||(Jt=F(['\nquery SearchContactCardQuery(\n $publicSearchable: LrJSONFilter!\n) {\n searchContactCards(\n publicSearchable: $publicSearchable\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],['\nquery SearchContactCardQuery(\n $publicSearchable: LrJSONFilter!\n) {\n searchContactCards(\n publicSearchable: $publicSearchable\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),Wt,Ge),k.default(qt||(qt=F(['\nquery ContactCardListQuery {\n contactCards(\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],['\nquery ContactCardListQuery {\n contactCards(\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),Wt,Ge)),Ht=(k.default(Gt||(Gt=F(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"],["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"])),Wt),k.default(Vt||(Vt=F(["\nmutation UpdateContactCardMutation(\n $input: UpdateContactCardInput!\n) {\n updateContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"],["\nmutation UpdateContactCardMutation(\n $input: UpdateContactCardInput!\n) {\n updateContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"])),Wt),k.default(Bt||(Bt=F(["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"]))));(Qt=e.DirectoryType||(e.DirectoryType={})).Vault="vault",Qt.Category="category",Qt.Record="record";var Yt,zt,Xt,en,tn,nn,rn,an,sn,on,cn,un,pn,dn=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Vault,default:!0}}]}),ln=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Category}}]}),yn=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Record}}]}),hn="\ndescendantDirectories(depth: 5, plainMeta: $categoryFilter, archived: false) {\n recordsCount: directoriesCount(plainMeta: $recordFilter, archived: false)\n}\n",fn="\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+hn+"\n",vn="\n id\n keyId\n plainMeta\n cipherMeta\n",mn=k.default(Yt||(Yt=F(["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),gn=k.default(zt||(zt=F(['\nquery GetCategoriesQuery($vaultDirectoryId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean)\n{\n directory(id: $vaultDirectoryId) {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetCategoriesQuery($vaultDirectoryId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean)\n{\n directory(id: $vaultDirectoryId) {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),fn,qe),Sn=k.default(Xt||(Xt=F(['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),vn,qe),In=k.default(en||(en=F(['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n theirItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n',"\n"],['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n theirItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n',"\n"])),fn,qe),Cn=k.default(tn||(tn=F(['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n',"\n"],['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n',"\n"])),fn,qe),bn=function(e){return void 0===e&&(e=5),e?"\nparentCategories: parentDirectoryLinks(plainMeta: $categoryFilter) {\n edges {\n node {\n parentDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+bn(e-1)+"\n }\n }\n }\n}\n":""},wn=function(e){return void 0===e&&(e=5),k.default(nn||(nn=F(["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n'," "],["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n'," "])),hn,bn(e),fn,qe)},Kn=k.default(rn||(rn=F(["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),qe),kn=k.default(an||(an=F(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),Pn=k.default(sn||(sn=F(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"]))),En=k.default(on||(on=F(["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Dn=k.default(cn||(cn=F(["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"],["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"]))),Rn=k.default(un||(un=F(["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Mn=k.default(pn||(pn=F(["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),On=function(){function e(e,t,n,r,i){this.encryptionService=e,this.keyGraph=t,this.lrApollo=n,this.keyService=r,this.keyFactory=i}return e.prototype.decryptMeta=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return e.cipherMeta?[4,this.keyGraph.getJwkKey(e.keyId)]:[3,3];case 1:return t=n.sent(),[4,this.encryptionService.decrypt(t,JSON.parse(e.cipherMeta))];case 2:return[2,n.sent()];case 3:return[2,null]}}))}))},e.prototype.doubleWrapContent=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return[4,this.keyFactory.createKey()];case 1:return r=l.sent(),[4,this.wrapContent(r.toJSON(!0),t)];case 2:return i=l.sent(),a={rootKey:i.rootKey,wrappedKeys:i.wrappedKeys,doubleWrappedKey:i.cipherMeta},e?(c=(o=JSON).stringify,[4,this.encryptionService.encrypt(r,e)]):[3,4];case 3:return s=c.apply(o,[l.sent()]),[3,5];case 4:s=null,l.label=5;case 5:return a.cipherMeta=s,n?(d=(p=JSON).stringify,[4,this.encryptionService.encrypt(r,n)]):[3,7];case 6:return u=d.apply(p,[l.sent()]),[3,8];case 7:u=null,l.label=8;case 8:return[2,(a.cipherFileContent=u,a)]}}))}))},e.prototype.reWrapContent=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getJwkKey(e)];case 1:return n=p.sent(),[4,this.keyFactory.createKey()];case 2:return r=p.sent(),i={},s=(a=JSON).stringify,[4,this.encryptionService.encrypt(n,r.toJSON(!0))];case 3:return i.doubleWrappedKey=s.apply(a,[p.sent()]),t?(u=(c=JSON).stringify,[4,this.encryptionService.encrypt(r,t)]):[3,5];case 4:return o=u.apply(c,[p.sent()]),[3,6];case 5:o=null,p.label=6;case 6:return[2,(i.cipherMeta=o,i)]}}))}))},e.prototype.wrapContent=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y=this;return j(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return A(y,void 0,void 0,(function(){var t,r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.getCategoryKeyId(e)];case 1:return t=s.sent(),a=(i=JSON).stringify,[4,this.encryptionService.encrypt(t.key,n.toJSON(!0))];case 2:return r=a.apply(i,[s.sent()]),[2,{directoryId:e,wrappingKeyId:t.keyId,wrappedKey:r}]}}))}))})))]:[3,3];case 2:return r=h.sent(),[3,5];case 3:return a=this.keyService.currentRootKey,c=(o=JSON).stringify,[4,this.encryptionService.encrypt(a.jwk,n.toJSON(!0))];case 4:s=c.apply(o,[h.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},h.label=5;case 5:return u={key:n,rootKey:i,wrappedKeys:r},e?(l=(d=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,7];case 6:return p=l.apply(d,[h.sent()]),[3,8];case 7:p=null,h.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o;return j(this,(function(c){switch(c.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=c.sent(),[4,this.keyGraph.encryptToString(t,n.toJSON(!0))];case 2:return r=c.sent(),i={key:n,rootKey:{wrappingKeyId:t,wrappedKey:r}},e?(o=(s=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,4];case 3:return a=o.apply(s,[c.sent()]),[3,5];case 4:a=null,c.label=5;case 5:return[2,(i.cipherMeta=a,i)]}}))}))},e.prototype.getCategoryKeyId=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Kn,variables:{id:e}})];case 1:return t=r.sent().category,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();On.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new On(t.ɵɵinject(he),t.ɵɵinject(ke),t.ɵɵinject(Pe),t.ɵɵinject(Ke),t.ɵɵinject(ve))},token:On,providedIn:"root"}),On.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],On.ctorParameters=function(){return[{type:he},{type:ke},{type:Pe},{type:Ke},{type:ve}]};var An,jn,Tn,Nn,$n,Fn,Un,Ln,xn,_n,Jn=k.default(An||(An=F(["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"],["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"]))),qn=k.default(jn||(jn=F(["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"],["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"]))),Gn="\n name\n data\n state\n",Vn=k.default(Tn||(Tn=F(["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"],["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"])),Gn),Bn=k.default(Nn||(Nn=F(["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"]))),Qn=k.default($n||($n=F(["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"],["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"])),Gn),Wn=k.default(Fn||(Fn=F(["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),Zn=k.default(Un||(Un=F(["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"],["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"])),Gn),Hn=k.default(Ln||(Ln=F(["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"],["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"])),Gn),Yn=k.default(xn||(xn=F(["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"],["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"])),Gn),zn=k.default(_n||(_n=F(["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"],["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"])));function Xn(e){return e.map((function(e){var t;return Object.assign(Object.assign({},e),{periodEnd:e.periodEnd&&new Date(e.periodEnd),subscription:{id:null===(t=e.stripe)||void 0===t?void 0:t.subscriptionId}})}))}var er=function(){function e(e){this.lrApollo=e}return e.prototype.createStripeCheckoutSession=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Jn,variables:Object.assign({},e)})];case 1:return[2,{id:t.sent().createStripeCheckoutSession.sessionId}]}}))}))},e.prototype.createStripeBillingPortalSession=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:qn,variables:{returnUrl:e}})];case 1:return[2,{url:t.sent().createStripeBillingPortalSession.sessionUrl}]}}))}))},e.prototype.getUserIssuablePlans=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:Qn})];case 1:return[2,e.sent().userIssuablePlans]}}))}))},e.prototype.createUserIssuedPlan=function(e){var t=e.planName,n=e.tokenExpiryTime,r=e.planPeriodEnd,i=e.planPeriodEndAfterSeconds;return A(this,void 0,void 0,(function(){var e,a;return j(this,(function(s){switch(s.label){case 0:if(null==r&&null==i)throw new q('Must specify either "planPeriodEnd" or "planPeriodEndAfterSeconds"');return[4,this.lrApollo.mutate({mutation:Vn,variables:{input:{planName:t,tokenExpiryTime:n.toISOString(),planPeriodEnd:r&&r.toISOString(),planPeriodEndAfterSeconds:i}}})];case 1:return e=s.sent().createUserIssuedPlan,a=e.userIssuedPlan,[2,Object.assign(Object.assign({},a),{tokenExpiryTime:new Date(a.tokenExpiryTime),planPeriodEnd:new Date(a.planPeriodEnd)})]}}))}))},e.prototype.deleteUserIssuedPlan=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Bn,variables:{input:{id:e}}})];case 1:return[2,t.sent()]}}))}))},e.prototype.getUserIssuedPlans=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:Wn})];case 1:return[2,e.sent().userIssuedPlans.edges.map((function(e){return e.node}))]}}))}))},e.prototype.getUserIssuedPlan=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Zn,variables:{id:e,token:t}})];case 1:return[2,n.sent().userIssuedPlan]}}))}))},e.prototype.associateUserIssuedPlan=function(e){var t=e.id,n=e.token;return A(this,void 0,void 0,(function(){var e,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Hn,variables:{input:{id:t,token:n}}})];case 1:return e=i.sent().associateUserIssuedPlan,r=e.userPlan,[2,Object.assign(Object.assign({},r),{periodEnd:new Date(r.periodEnd)})]}}))}))},e.prototype.getUserPlans=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:Yn})];case 1:return[2,Xn(e.sent().userPlans)]}}))}))},e.prototype.getPlanType=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.getStripe()];case 1:return[2,t.sent().customer.subscriptions.data.filter((function(t){return t.id===e}))[0].items.data[0].plan.interval]}}))}))},e.prototype.getStripe=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:zn})];case 1:return[2,e.sent().stripe]}}))}))},e}();er.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new er(t.ɵɵinject(Pe))},token:er,providedIn:"root"}),er.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],er.ctorParameters=function(){return[{type:Pe}]};var tr,nr,rr,ir=k.default(tr||(tr=F(['\n query {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n userDelete {\n id\n created\n state\n }\n features {\n myVault\n tpVault\n shareVault\n }\n sessionEncryptionKey\n dateJoined\n }\n userPlans {\n id\n stripe {\n subscriptionId\n }\n plan {\n name\n data\n state\n }\n periodEnd\n }\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n key {\n id\n }\n cipherData\n plainData\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"],['\n query {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n userDelete {\n id\n created\n state\n }\n features {\n myVault\n tpVault\n shareVault\n }\n sessionEncryptionKey\n dateJoined\n }\n userPlans {\n id\n stripe {\n subscriptionId\n }\n plan {\n name\n data\n state\n }\n periodEnd\n }\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n key {\n id\n }\n cipherData\n plainData\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"])),qe),ar=k.default(nr||(nr=F(["\n mutation CreateContactCardMutation($input: CreateContactCardInput!) {\n createContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"],["\n mutation CreateContactCardMutation($input: CreateContactCardInput!) {\n createContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"]))),sr=k.default(rr||(rr=F(["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"],["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"])));(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var or=function(){},cr=function(){},ur=function(){},pr=function(){},dr=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},lr=function(){},yr=function(){},hr=function(){},fr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),t}(hr),vr=function(){};!function(e){e.InProgress="IN_PROGRESS",e.Recovery="RECOVERY"}(e.PasswordChangeStatus||(e.PasswordChangeStatus={}));var mr=function(){},gr=function(){},Sr=function(){function e(e,t,n,r,i,a,s){this.config=e,this.http=t,this.lrApollo=n,this.keyService=r,this.keyMetaService=i,this.keyGraph=a,this.encryptionService=s}return e.prototype.getPassIdpParams=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.config.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},e.prototype.getCurrentUser=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:ir})];case 1:return e=a.sent(),t=e.currentUser,n=e.contactCards,r=e.userPlans,i=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:i,userPlans:Xn(r)}]}}))}))},e.prototype.decryptContactCard=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return e?[4,this.keyGraph.decryptFromString(e.key.id,e.cipherData)]:[2,null];case 1:return t=n.sent(),[2,Object.assign({id:e.id,keyId:e.key.id},t)]}}))}))},e.prototype.updateDetails=function(e,t,n){return A(this,void 0,void 0,(function(){return j(this,(function(r){switch(r.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r.sent(),[2]}}))}))},e.prototype.prepareContactCardInput=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return t=this.keyService.currentSigPxk,i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 1:return n=i.apply(r,[l.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 2:return a=o.apply(s,[l.sent()]),c={name:new dr(e.name.value)},d=(p=JSON).stringify,[4,this.encryptionService.sign(t.jwk,c)];case 3:return u=d.apply(p,[l.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:u}]}}))}))},e.prototype.createContactCard=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.prepareContactCardInput(e)];case 1:return t=a.sent(),[4,this.keyMetaService.wrapContent(e)];case 2:return n=a.sent(),r=n.rootKey,i=n.cipherMeta,[4,this.lrApollo.mutate({mutation:ar,variables:{input:Object.assign(Object.assign({},t),{cipherData:i,wrappingKeyId:r.wrappingKeyId,wrappedKey:r.wrappedKey,default:!0})}})];case 3:return[2,a.sent().createContactCard.contactCard]}}))}))},e.prototype.updateContactCard=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.prepareContactCardInput(n)];case 1:return r=a.sent(),[4,this.keyGraph.encryptToString(t,n)];case 2:return i=a.sent(),[4,this.lrApollo.mutate({mutation:sr,variables:{input:Object.assign(Object.assign({},r),{id:e,cipherData:i})}})];case 3:return[2,a.sent().updateContactCard.contactCard]}}))}))},e.prototype.decryptContactCardEdges=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){return[2,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t=e.node,[4,this.decryptContactCard(t)];case 1:return[2,n.sent()]}}))}))})))]}))}))},e.prototype.getContactCards=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Zt})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ht,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.http.post(this.config.authUrl+"auth/sign-out/",null,{withCredentials:!0,responseType:"text"}).toPromise()];case 1:return e.sent(),[2]}}))}))},e}();Sr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Sr(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(Pe),t.ɵɵinject(Ke),t.ɵɵinject(On),t.ɵɵinject(ke),t.ɵɵinject(he))},token:Sr,providedIn:"root"}),Sr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Sr.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:Pe},{type:Ke},{type:On},{type:ke},{type:he}]};var Ir,Cr,br,wr=k.default(Ir||(Ir=F(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"]))),Kr=k.default(Cr||(Cr=F(["\n mutation PasswordChange($input: PasswordChangeInput!) {\n passwordChange(input: $input) {\n token\n newPassKey {\n id\n }\n }\n }\n"],["\n mutation PasswordChange($input: PasswordChangeInput!) {\n passwordChange(input: $input) {\n token\n newPassKey {\n id\n }\n }\n }\n"]))),kr=k.default(br||(br=F(["\n query PasswordChangeConfigQuery {\n passwordChangeConfig {\n maxAuthAgeSeconds\n authTime\n serverTime\n }\n }\n"],["\n query PasswordChangeConfigQuery {\n passwordChangeConfig {\n maxAuthAgeSeconds\n authTime\n serverTime\n }\n }\n"]))),Pr=P,Er=function(){},Dr=function(){function e(e,t,n,r,i,a,s,o,c){this.config=e,this.http=t,this.apollo=n,this.auth=r,this.profileService=i,this.keyFactory=a,this.encryptionService=s,this.keyGraph=o,this.webCryptoService=c,this.CLIENT_NONCE_LENGTH=32}return e.prototype.checkPassword=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Pr.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.webCryptoService.stringDigest("SHA-1",e)];case 1:return t=a.sent(),n=t.substring(0,5),[4,this.http.get("https://api.pwnedpasswords.com/range/"+n,{responseType:"text"}).toPromise()];case 2:return r=a.sent(),(i=new RegExp("^(?:"+t.substring(5)+":)(?<count>\\d+)$","im").exec(r))?[2,+i.groups.count]:[2,0]}}))}))},e.prototype.getPassIdpString=function(e){return e.toJSON(!0).k},e.prototype.createPassKeyBundle=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.keyFactory.createPassIdpParams()];case 1:return t=o.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t))];case 2:return n=o.sent().jwk,[4,this.keyFactory.createPassKeyParams()];case 3:return r=o.sent(),[4,this.keyFactory.derivePassKey(Object.assign({password:e},r))];case 4:return i=o.sent().jwk,[4,this.keyFactory.createPkcSignKey()];case 5:return a=o.sent(),[4,this.encryptionService.encrypt(i,a.toJSON(!0))];case 6:return s=o.sent(),[2,{passKeyParams:r,passKey:i,passIdpParams:t,passIdp:n,passIdpVerifier:a,wrappedPassIdpVerifierPrk:s}]}}))}))},e.prototype.isLoginRequired=function(){return A(this,void 0,void 0,(function(){var e,t,n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Pr(e.authTime),n=Pr(e.serverTime),r=Pr.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return n=d.sent(),[4,this.profileService.getCurrentUser()];case 2:return r=d.sent().currentUser,[4,this.verifyPassword(e,r)];case 3:return i=d.sent(),a=i.passIdp,s=i.signedChallenge,[4,this.createPassKeyBundle(t)];case 4:return o=d.sent(),[4,this.keyGraph.getKey(r.currentUserKey.masterKey.id)];case 5:return c=d.sent(),[4,this.encryptionService.encrypt(o.passKey,c.jwk.toJSON(!0))];case 6:return u=d.sent(),[4,this.changePasswordMutation(s,r.currentUserKey.masterKey.id,u,o)];case 7:return p=d.sent().token,[4,this.auth.changePassword(n,this.getPassIdpString(a),this.getPassIdpString(o.passIdp))];case 8:return d.sent(),[4,this.changePasswordComplete({useNewPassword:!0,token:p})];case 9:return d.sent(),[2]}}))}))},e.prototype.changePasswordComplete=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return t=e.useNewPassword,n=e.token,i=(r=this.http).post,a=[this.config.authUrl+"users/password-change-complete/",Object.assign({use_new_password:t},n&&{token:n})],[4,Se(this.auth,this.config)];case 1:return[2,i.apply(r,a.concat([s.sent()])).toPromise()]}}))}))},e.prototype.getVerifierPrK=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,t)];case 1:return n=r.sent(),[2,ve.asKey(n)];case 2:throw r.sent(),new J("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:wr,variables:{}})];case 1:return n=o.sent(),[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.currentUserKey.passKey.passKeyParams))];case 2:return r=o.sent(),[4,this.getVerifierPrK(r.jwk,t.currentUserKey.passKey.wrappedPassIdpVerifierPrk)];case 3:return i=o.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.encryptionService.sign(i,{serverNonce:n.passwordChangeRequest.challenge.serverNonce,clientNonce:a})];case 4:return s=o.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t.currentUserKey.passKey.passIdpParams))];case 5:return[2,{passIdp:o.sent().jwk,signedChallenge:s}]}}))}))},e.prototype.changePasswordMutation=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i;return j(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Kr,variables:{input:{signedChallenge:JSON.stringify(e),masterKeyId:t,newWrappedMasterKey:JSON.stringify(n),newPassKey:{passIdpParams:JSON.stringify(r.passIdpParams),passIdpVerifierPbk:JSON.stringify(r.passIdpVerifier.toJSON()),wrappedPassIdpVerifierPrk:JSON.stringify(r.wrappedPassIdpVerifierPrk),passKeyParams:JSON.stringify(r.passKeyParams)}}}})];case 1:return[2,{token:(i=a.sent()).passwordChange.token,newPassKeyId:i.passwordChange.newPassKey.id}]}}))}))},e.prototype.getChangePasswordConfig=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:kr})];case 1:return e=n.sent(),(t=e.passwordChangeConfig).authTime=new Date(t.authTime),t.serverTime=new Date(t.serverTime),[2,t]}}))}))},e.prototype.passwordStrength=function(e){function t(e,t){return((e||"").match(t)||[]).length}var n=t(e,/[A-Z]/g),r=t(e,/[a-z]/g),i=t(e,/[0-9]/g),a=0;if(n&&(a+=26),r&&(a+=26),i&&(a+=10),e.length-n-r-i&&(a+=30),0===e.length)return{years:0,bits:0};var s=Math.pow(a,e.length);return{years:54e3*s/Math.pow(62,12),bits:Math.round(Math.log2(s))}},e}();Dr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Dr(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(Pe),t.ɵɵinject(s.AuthClass),t.ɵɵinject(Sr),t.ɵɵinject(ve),t.ɵɵinject(he),t.ɵɵinject(ke),t.ɵɵinject(fe))},token:Dr,providedIn:"root"}),Dr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Dr.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:Pe},{type:s.AuthClass},{type:Sr},{type:ve},{type:he},{type:ke},{type:fe}]};var Rr="lifeready",Mr=".tp_password_reset",Or=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),this.assembly=e,this.subAssembly=t,this.mnemonics=n},Ar=function(){function e(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0),this.index=e,this.threshold=t,this.size=n,this.clearShares()}return e.prototype.clearShares=function(){this.shares=[]},e.prototype.addShare=function(e){this.shares.push(e)},e}(),jr=function(){function e(e){void 0===e&&(e=0),this.threshold=e,this.clearSubAssemblies()}return e.prototype.size=function(){return this.subAssemblies.length},e.prototype.clearSubAssemblies=function(){this.subAssemblies=[]},e.prototype.addSubAssembly=function(e){this.subAssemblies.push(e)},e}(),Tr=(function(){function e(e){this.subAssemblyIndex=e,this.clearShares()}e.prototype.clearShares=function(){this.shares=[]},e.prototype.addShare=function(e){this.shares.push(e)}}(),function(){function e(){this.clearSubQuora()}e.prototype.clearSubQuora=function(){this.subQuora=[]},e.prototype.addSubQuorum=function(e){this.subQuora.push(e)},e.prototype.serialiseShares=function(){var e=[];return this.subQuora.forEach((function(t){e=e.concat(t.shares)})),e}}(),function(){function e(){}return e.prototype.generateShares=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:r=btoa(e),r=I.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=T(n.subAssemblies),s=a.next();!s.done;s=a.next())o=s.value,i.push([o.threshold,o.size])}catch(e){u={error:e}}finally{try{s&&!s.done&&(p=a.return)&&p.call(a)}finally{if(u)throw u.error}}return[4,I.Slip39.fromArray(r,{passphrase:t,threshold:n.threshold,groups:i,title:""})];case 1:return c=d.sent(),n.subAssemblies.forEach((function(e,t){e.clearShares();for(var n=0;n<e.size;n++){var r="r/"+t.toString().padStart(2,"0")+"/"+n.toString().padStart(2,"0"),i=c.fromPath(r).mnemonics[0],a=new Or(t,n,i);e.addShare(a)}})),[2]}}))}))},e.prototype.minimalSet=function(e){var t,n,r,i,a=null,s=new Map;try{for(var o=T(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=I.Slip39Helper.decodeMnemonic(u);if(a&&a!==p.groupThreshold)throw new Error("groupThreshold is different in mnemonics");a=p.groupThreshold,null==(f=s.get(p.groupIndex))&&(f={memberThreshold:p.memberThreshold,members:[]},s.set(p.groupIndex,f)),f.members.push({mnemonic:u,decoded:p})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=[],l=0;try{for(var y=T(s.values()),h=y.next();!h.done;h=y.next()){var f;if(!((f=h.value).members.length<f.memberThreshold)&&(f.members.slice(0,f.memberThreshold).forEach((function(e){d.push(e.mnemonic)})),++l>=a))break}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}return d},e.prototype.recoverSecret=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,I.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=I.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}());Tr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Tr},token:Tr,providedIn:"root"}),Tr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var Nr,$r=je(Nr||(Nr=F(["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"],["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"]))),Fr=function(){function t(t){this.keyFactory=t.get(ve),this.keyService=t.get(Ke),this.encryptionService=t.get(he),this.keyGraph=t.get(ke),this.slip39Service=t.get(Tr),this.lrGraphQl=t.get(e.ɵf)}return t.prototype.recoverAssemblyKey=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return n=e.map((function(e){if(t){if(JSON.stringify(t)!==JSON.stringify(e.assemblyKeyParams))throw new Q("The assembly key parameters are different between the approvals.")}else t=e.assemblyKeyParams;return e.slip39.share.mnemonics})),[4,this.slip39Service.recoverSecret(n,this.slip39Passphrase)];case 1:return r=i.sent(),[4,ve.asKey(Object.assign(Object.assign({},t),{k:r}))];case 2:return[2,i.sent()]}}))}))},t.prototype.prepareTpWrappingKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.keyGraph.getKey(e.wrappingKeyId)]}))}))},t.prototype.prepareAssembly=function(e){var t=e.subjectKey,n=e.rootKey;return A(this,void 0,void 0,(function(){var e,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=d.sent(),r=e.toJSON(!0),i=r.k,a=M(r,["k"]),[4,this.keyFactory.createPkcSignKey()];case 2:return s=d.sent(),[4,this.encryptionService.encryptToString(e,s.toJSON(!0))];case 3:return o=d.sent(),c=JSON.stringify(s.toJSON()),[4,this.encryptionService.encryptToString(t,e.toJSON(!0))];case 4:return u=d.sent(),[4,this.encryptionService.encryptToString(e,{rootKey:n.toJSON(!0)})];case 5:return p=d.sent(),[2,{assemblyKey:e,rawAssemblyKey:i,assemblyKeyParams:a,subjectKeyWrappedAssemblyKey:u,assemblyCipherData:p,assemblyKeyVerifierPbk:c,wrappedAssemblyKeyVerifierPrk:o}]}}))}))},t.prototype.prepareCreateSubAssemblies=function(e){var t=e.input,n=e.subjectKey,r=e.slipSubAssemblies,i=e.assemblyKeyParams;return A(this,void 0,void 0,(function(){var e=this;return j(this,(function(a){return[2,Promise.all(t.map((function(t,a){return A(e,void 0,void 0,(function(){var e,s,o=this;return j(this,(function(c){switch(c.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=c.sent(),[4,Promise.all(t.approverTps.map((function(e,t){return A(o,void 0,void 0,(function(){return j(this,(function(s){return[2,this.prepareApprover({tp:e,approverIndex:t,slipSubAssembly:r[a],assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return s=c.sent(),[2,{singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e,createApprovers:s}]}}))}))})))]}))}))},t.prototype.prepareUpdateSubAssemblies=function(e){var t=e.input,n=e.subjectKey,r=e.slipSubAssemblies,i=e.assemblyKeyParams,a=e.subAssemblies;return A(this,void 0,void 0,(function(){var e=this;return j(this,(function(s){if(r.length!==t.length)throw new q("The slipSubAssemblies must be the same length as the input");return[2,Promise.all(t.map((function(t,s){return A(e,void 0,void 0,(function(){var e,o,c,u,p,d,l=this;return j(this,(function(y){switch(y.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=y.sent(),o=a.edges.find((function(e){return e.node.id===t.id})).node,c=[],u=[],t.approverTps.forEach((function(e){var t,n=null===(t=o.approvers.edges.find((function(t){return t.node.tp.id===e.tpId})))||void 0===t?void 0:t.node;n?u.push({tp:e,approverId:n.id}):c.push({tp:e})})),p=r[s],d={subAssemblyId:t.id,singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e},[4,Promise.all(c.map((function(e,t){var r=e.tp;return A(l,void 0,void 0,(function(){return j(this,(function(e){return[2,this.prepareApprover({tp:r,approverIndex:t,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return d.createApprovers=y.sent(),[4,Promise.all(u.map((function(e,t){var r=e.tp,a=e.approverId;return A(l,void 0,void 0,(function(){return j(this,(function(e){return[2,this.prepareApprover({approverId:a,tp:r,approverIndex:t+c.length,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 3:return[2,(d.updateApprovers=y.sent(),d)]}}))}))})))]}))}))},t.prototype.fillWrappingKeyId=function(e,t){var n=this;e.forEach((function(e){e.approverTps.forEach((function(e){if(!e.wrappingKeyId){var r=t.find((function(t){return t.id===e.tpId}));e.wrappingKeyId=n.getTpWrappingKeyId(r)}}))}))},t.prototype.getInputApprovers=function(e){var t=[];return e.forEach((function(e){e.approverTps.forEach((function(e){t.push(e.tpId)}))})),t},t.prototype.prepareCreate=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y,h;return j(this,(function(f){switch(f.label){case 0:return t=this.keyService.currentRootKey,[4,this.keyFactory.createKey()];case 1:return n=f.sent(),[4,this.keyGraph.wrapKey(t,n)];case 2:return r=f.sent(),[4,this.prepareAssembly({rootKey:t.jwk,subjectKey:n})];case 3:return i=f.sent(),a=i.assemblyKey,s=i.rawAssemblyKey,o=i.assemblyKeyParams,c=M(i,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),[4,this.prepareSlip39(e.createSubAssemblies,e.quorum,s)];case 4:return u=f.sent(),p=this.getInputApprovers(e.createSubAssemblies),l=jt,[4,this.lrGraphQl.query({query:$r,variables:{ids:p}})];case 5:return d=l.apply(void 0,[f.sent().tps]),this.fillWrappingKeyId(e.createSubAssemblies,d),[4,this.prepareCreateSubAssemblies({input:e.createSubAssemblies,assemblyKeyParams:o,slipSubAssemblies:u.subAssemblies,subjectKey:n})];case 6:return y=f.sent(),[4,this.encryptionService.encryptToString(n,e.subjectCipherDataClearJson||"")];case 7:return h=f.sent(),[2,{assemblyKey:a,mutationInput:Object.assign(Object.assign({},c),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:h,createSubAssemblies:y,rootKeyId:t.id,rootKeyWrappedSubjectKey:r})}]}}))}))},t.prototype.getAssemblyApprovers=function(e){var t=[];return jt(e.subAssemblies).map((function(e){jt(e.approvers).forEach((function(e){return t.push(e.tp.id)}))})),t},t.prototype.prepareUpdate=function(e,t){var n;return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C;return j(this,(function(b){switch(b.label){case 0:if(e=Object.assign({createSubAssemblies:[]},e),r=e.createSubAssemblies||[],i=e.updateSubAssemblies||[],a=e.deleteSubAssemblies||[],0===r.length&&0===i.length&&0===a.length)throw new q("Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]");return s=this.keyService.currentRootKey,[4,this.keyGraph.getKey(t.subjectKey.id)];case 1:return o=b.sent(),[4,this.prepareAssembly({rootKey:s.jwk,subjectKey:o.jwk})];case 2:return c=b.sent(),u=c.assemblyKey,p=c.rawAssemblyKey,d=c.assemblyKeyParams,l=M(c,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),y=this.getAssemblyApprovers(t).concat(this.getInputApprovers(r),this.getInputApprovers(i)),f=jt,[4,this.lrGraphQl.query({query:$r,variables:{ids:y}})];case 3:h=f.apply(void 0,[b.sent().tps]),jt(t.subAssemblies).forEach((function(e){if(!a.includes(e.id)&&!i.some((function(t){return t.id===e.id}))){var t=jt(e.approvers).map((function(e){return{tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,sharedCipherApprovalDataClearJson:e.sharedCipherApprovalDataClearJson}}));i.push({id:e.id,quorum:e.quorum,singleReject:e.singleReject,approverTps:t,subjectCipherDataClearJson:e.subjectCipherDataClearJson})}})),this.fillWrappingKeyId(r,h),this.fillWrappingKeyId(i,h),b.label=4;case 4:return b.trys.push([4,6,,7]),[4,this.prepareSlip39((r||[]).concat(i||[]),e.quorum,p)];case 5:return v=b.sent(),[3,7];case 6:return m=b.sent(),console.log("Error while creating slip assembly",m),[3,7];case 7:return g={assemblyKeyParams:d,subjectKey:o.jwk},[4,this.prepareCreateSubAssemblies(Object.assign(Object.assign({},g),{input:r,slipSubAssemblies:v.subAssemblies.slice(0,r.length)}))];case 8:return S=b.sent(),[4,this.prepareUpdateSubAssemblies(Object.assign(Object.assign({},g),{input:i,slipSubAssemblies:v.subAssemblies.slice(r.length),subAssemblies:t.subAssemblies}))];case 9:return I=b.sent(),[4,this.encryptionService.encryptToString(o.jwk,null!==(n=e.subjectCipherDataClearJson)&&void 0!==n?n:t.subjectCipherDataClearJson)];case 10:return C=b.sent(),[2,{assemblyKey:u,mutationInput:Object.assign(Object.assign({},l),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:C,subjectKeyId:o.id,createSubAssemblies:S,updateSubAssemblies:I})}]}}))}))},t.prototype.prepareApprover=function(e){var t=e.approverId,n=e.tp,r=e.approverIndex,i=e.slipSubAssembly,a=e.assemblyKeyParams,s=e.subjectKey;return A(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h;return j(this,(function(f){switch(f.label){case 0:return[4,this.prepareTpWrappingKey(n)];case 1:return e=f.sent(),[4,this.keyFactory.createKey()];case 2:return o=f.sent(),[4,this.encryptionService.encryptToString(e.jwk,o.toJSON(!0))];case 3:return c=f.sent(),[4,this.encryptionService.encryptToString(s,o.toJSON(!0))];case 4:return u=f.sent(),p=1===i.threshold?i.shares[0]:i.shares[r],d={slip39:{share:p,subAssembly:{quorum:i.threshold,size:i.size}},assemblyKeyParams:a},[4,this.encryptionService.encryptToString(o,n.sharedCipherDataClearJson||"")];case 5:return l=f.sent(),[4,this.encryptionService.encryptToString(o,n.sharedCipherApprovalDataClearJson||"")];case 6:return y=f.sent(),[4,this.encryptionService.encryptToString(o,d)];case 7:return h=f.sent(),[2,{tpWrappingKeyId:e.id,tpWrappedSharedKey:c,subjectKeyWrappedSharedKey:u,sharedCipherData:l,sharedCipherApprovalData:y,sharedCipherPartialAssemblyKey:h,approverId:t||void 0,tpId:t?void 0:n.tpId}]}}))}))},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=T(e),i=r.next();!i.done;i=r.next()){var a=i.value;if(!a.currentUserSharedKey.userSharedKey.mkSharedKey){var s="tp "+a.other.username+" does not have mkSharedKey";throw console.log(s),new q(s)}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},t.prototype.prepareSlip39=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new q("Not enough sub assemblies to meet quorum");return r=new jr(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new Ar(t,e.quorum,n))})),[4,this.slip39Service.generateShares(n,this.slip39Passphrase,r)];case 1:return i.sent(),[2,r]}}))}))},t}();e.ɵi=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase=Rr,r}return R(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.mkSharedKey.id},t}(Fr),e.ɵi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵi(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵi,providedIn:"root"}),e.ɵi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵi.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵi=O([et({ngZoneName:"ngZone"})],e.ɵi);var Ur,Lr,xr,_r,Jr,qr,Gr,Vr,Br,Qr,Wr,Zr,Hr,Yr,zr,Xr,ei=je(Ur||(Ur=F(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),ti=je(Lr||(Lr=F(["\nmutation CreateTpAssemblyKeyChallengeMutation(\n $input: CreateTpAssemblyKeyChallengeInput!\n) {\n createTpAssemblyKeyChallenge(input: $input) {\n challenge\n }\n}"],["\nmutation CreateTpAssemblyKeyChallengeMutation(\n $input: CreateTpAssemblyKeyChallengeInput!\n) {\n createTpAssemblyKeyChallenge(input: $input) {\n challenge\n }\n}"]))),ni=je(xr||(xr=F(["\nmutation PreCompleteTpPasswordResetRequestMutation(\n $input: PreCompleteTpPasswordResetRequestInput!\n) {\n preCompleteTpPasswordResetRequest(input: $input) {\n idpPassword\n }\n}"],["\nmutation PreCompleteTpPasswordResetRequestMutation(\n $input: PreCompleteTpPasswordResetRequestInput!\n) {\n preCompleteTpPasswordResetRequest(input: $input) {\n idpPassword\n }\n}"]))),ri=je(_r||(_r=F(["\nmutation CompleteTpPasswordResetRequestMutation(\n $input: CompleteTpPasswordResetRequestInput!\n) {\n completeTpPasswordResetRequest(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpPasswordResetRequestMutation(\n $input: CompleteTpPasswordResetRequestInput!\n) {\n completeTpPasswordResetRequest(input: $input) {\n id\n }\n}"]))),ii=je(Jr||(Jr=F(["\nmutation ApproveTpPasswordResetRequestMutation(\n $input: ApproveTpPasswordResetRequestInput!\n) {\n approveTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"],["\nmutation ApproveTpPasswordResetRequestMutation(\n $input: ApproveTpPasswordResetRequestInput!\n) {\n approveTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"]))),ai=je(qr||(qr=F(["\nmutation RejectTpPasswordResetRequestMutation(\n $input: RejectTpPasswordResetRequestInput!\n) {\n rejectTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"],["\nmutation RejectTpPasswordResetRequestMutation(\n $input: RejectTpPasswordResetRequestInput!\n) {\n rejectTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"]))),si=je(Gr||(Gr=F(["\nmutation CreateTpPasswordResetMutation($input: CreateTpPasswordResetInput!) {\n createTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"],["\nmutation CreateTpPasswordResetMutation($input: CreateTpPasswordResetInput!) {\n createTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"]))),oi=je(Vr||(Vr=F(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),ci=je(Br||(Br=F(["\nmutation UpdateTpPasswordResetMutation($input: UpdateTpPasswordResetInput!) {\n updateTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"],["\nmutation UpdateTpPasswordResetMutation($input: UpdateTpPasswordResetInput!) {\n updateTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"]))),ui=je(Qr||(Qr=F(["\nfragment SharedTpPasswordResetFragment on SharedTpPasswordResetNode {\n id\n tp {\n id\n other {\n username\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedRequest {\n id\n pxk {\n id\n pbk\n }\n claim {\n id\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nfragment SharedTpPasswordResetFragment on SharedTpPasswordResetNode {\n id\n tp {\n id\n other {\n username\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedRequest {\n id\n pxk {\n id\n pbk\n }\n claim {\n id\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),pi=je(Wr||(Wr=F(["\nquery SharedTpPasswordResetsQuery {\n sharedTpPasswordResets {\n edges {\n node {\n ...SharedTpPasswordResetFragment\n }\n }\n }\n}\n","\n"],["\nquery SharedTpPasswordResetsQuery {\n sharedTpPasswordResets {\n edges {\n node {\n ...SharedTpPasswordResetFragment\n }\n }\n }\n}\n","\n"])),ui),di=je(Zr||(Zr=F(["\nquery SharedTpPasswordResetQuery($id: LrRelayIdInput!) {\n sharedTpPasswordReset(id: $id) {\n ...SharedTpPasswordResetFragment\n }\n}\n","\n"],["\nquery SharedTpPasswordResetQuery($id: LrRelayIdInput!) {\n sharedTpPasswordReset(id: $id) {\n ...SharedTpPasswordResetFragment\n }\n}\n","\n"])),ui),li=je(Hr||(Hr=F(["\nquery TpPasswordResetUserQuery {\n tpPasswordResetUser {\n username\n resetUsername\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n sessionEncryptionKey\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n requestAgainAfter\n }\n}"],["\nquery TpPasswordResetUserQuery {\n tpPasswordResetUser {\n username\n resetUsername\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n sessionEncryptionKey\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n requestAgainAfter\n }\n}"]))),yi=je(Yr||(Yr=F(["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\n canMeetQuorum\n subjectCipherData\n subjectKey {\n id\n }\n assemblyKey {\n id\n }\n assemblyCipherData\n subAssemblies {\n edges {\n node {\n id\n singleReject\n quorum\n subjectCipherData\n subjectKey {\n id\n }\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\n canMeetQuorum\n subjectCipherData\n subjectKey {\n id\n }\n assemblyKey {\n id\n }\n assemblyCipherData\n subAssemblies {\n edges {\n node {\n id\n singleReject\n quorum\n subjectCipherData\n subjectKey {\n id\n }\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),hi=je(zr||(zr=F(["\nmutation SetSessionEncryptionKeyMutation($input: SetSessionEncryptionKeyInput!) {\n setSessionEncryptionKey(input: $input) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation SetSessionEncryptionKeyMutation($input: SetSessionEncryptionKeyInput!) {\n setSessionEncryptionKey(input: $input) {\n sessionEncryptionKey\n }\n}\n"]))),fi=(je(Xr||(Xr=F(["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"]))),function(e){return function(){return e.initialise()}}),vi=function(){function n(e,n,r,i,a,s,o,c,u,p,d,l,y,h){if(this.config=e,this.auth=n,this.keyFactory=r,this.keyService=i,this.profileService=a,this.keyGraphService=s,this.passwordService=o,this.idleService=c,this.lrGraphQL=u,this.tpPasswordResetProcessorService=p,this.persistService=d,this.encryptionService=l,this.assemblyController=y,this.http=h,this.hubSubject=new m.ReplaySubject(1),this.logoutListeners=new Set,!t.isDevMode()&&null!=this.config.debug)throw new V('In production mode, "config.debug" must be set to null')}return n.prototype.initialise=function(){return A(this,void 0,void 0,(function(){var e=this;return j(this,(function(t){return v.Hub.listen("auth",(function(t){return e.hubSubject.next(t.payload)})),[2]}))}))},n.prototype.debugLogin=function(e,t){return this.config.debug.username=e,this.debugLoadUser(t)},n.prototype.debugLoginUsingSession=function(e){return this.http.get(this.config.apiUrl+"debug_only/users/login/?username="+encodeURIComponent(e),{withCredentials:!0}).toPromise()},n.prototype.debugLoadUser=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return[4,this.profileService.getCurrentUser()];case 1:return t=d.sent(),n=t.currentUser,r=t.contactCard,i=t.userPlans,[4,this.keyFactory.derivePassKey(Object.assign({password:e},n.currentUserKey.passKey.passKeyParams))];case 2:return a=d.sent().jwk,[4,this.keyGraphService.unwrapWithPassKey(n.currentUserKey.passKey.id,a,n.currentUserKey.masterKey.id)];case 3:return s=d.sent(),[4,this.idleService.persistMasterKey(s)];case 4:return d.sent(),[4,this.keyGraphService.populateKeys(n.currentUserKey)];case 5:return d.sent(),o={id:n.id,sub:"DEBUG_MODE",username:n.username,currentUserKey:n.currentUserKey,email:"DEBUG_MODE",emailVerified:!1,phone:"DEBUG_MODE",phoneVerified:!1},u=(c=Object).assign,p=[{}],[4,this.profileService.decryptContactCard(r)];case 6:return[2,(o.contactCard=u.apply(c,p.concat([d.sent()])),o.userDelete=n.userDelete,o.userPlans=i,o.hasTPVaultAccess=this.mapTPVaultAccess(n.features),o.features=n.features,o.sessionEncryptionKey=n.sessionEncryptionKey,o.dateJoined=n.dateJoined,o)]}}))}))},n.prototype.getAccessJwtToken=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){return[2,se(this.auth)]}))}))},n.prototype.importPassword=function(e){return this.keyFactory.importPassword(e)},n.prototype.addLogoutListener=function(e){this.logoutListeners.add(e)},n.prototype.removeLogoutListener=function(e){this.logoutListeners.delete(e)},n.prototype.loginIdpImpl=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n))];case 1:return i=s.sent(),[4,this.auth.signIn(e,this.passwordService.getPassIdpString(i.jwk))];case 2:return(a=s.sent()).recoveryStatus=r,[2,a]}}))}))},n.prototype.loginIdp=function(t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c;return j(this,(function(u){switch(u.label){case 0:return[4,this.profileService.getPassIdpParams(t)];case 1:if((r=u.sent()).passwordChangeStatus===e.PasswordChangeStatus.InProgress)throw new H("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.Recovery)return[3,8];console.log("In recovery mode."),u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.loginIdpImpl(t,n,r.newPassIdpParams,e.RecoveryStatus.NEW_PASSWORD)];case 3:return a=u.sent(),console.log("New password works!"),[2,a];case 4:if("NotAuthorizedException"!==(i=u.sent()).code)throw i;return[3,5];case 5:return u.trys.push([5,7,,8]),[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.OLD_PASSWORD)];case 6:return a=u.sent(),console.log("Old password works!"),[2,a];case 7:throw"NotAuthorizedException"===(s=u.sent()).code?new V("The password change request was interrupted, please try to login with both your new and old password"):s;case 8:if(!r.tpPasswordReset)return[3,12];u.label=9;case 9:return u.trys.push([9,11,,12]),o=r.tpPasswordReset,[4,this.loginIdpImpl(o.resetUsername,n,o.passIdpParams,e.RecoveryStatus.NONE)];case 10:return(c=u.sent()).isTpPasswordResetUser=!0,[2,c];case 11:return u.sent(),[3,12];case 12:return[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.NONE)];case 13:return[2,u.sent()]}}))}))},n.prototype.handleSessionEncryptionKey=function(){return A(this,void 0,void 0,(function(){var e,n;return j(this,(function(r){switch(r.label){case 0:if(!this.config.disableSessionEncryptionKey)return[3,1];if(!t.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new Error(e);return console.warn("You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode."),[3,4];case 1:return[4,this.keyFactory.createKey()];case 2:return n=r.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:hi,variables:{input:{sessionEncryptionKey:JSON.stringify(n.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(n),r.label=4;case 4:return[2]}}))}))},n.prototype.handlePostAuth=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.handlePasswordRecovery(e)];case 1:return t.sent(),[4,this.handleSessionEncryptionKey()];case 2:return t.sent(),[2]}}))}))},n.prototype.login=function(t,n,r){var i,a=(void 0===r?{}:r).tpPasswordResetAutoComplete,s=void 0===a||a;return A(this,void 0,void 0,(function(){var r;return j(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return r=a.sent(),s&&(null===(i=r.resetUser)||void 0===i?void 0:i.state)===e.TpClaimState.APPROVED?[4,this.completeRequest(n)]:[3,4];case 2:return a.sent(),[4,this.loginImpl(t,n)];case 3:r=a.sent(),a.label=4;case 4:return[2,r]}}))}))},n.prototype.loginImpl=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(e,t)];case 2:return n=i.sent(),["SMS_MFA","SOFTWARE_TOKEN_MFA"].includes(n.challengeName)?[2,{hasChallenge:!0,challenge:n}]:[4,this.handlePostAuth(n)];case 3:return i.sent(),n.isTpPasswordResetUser?[4,this.loadResetUser(t)]:[3,5];case 4:return[2,{hasChallenge:!1,resetUser:i.sent()}];case 5:return[4,this.loadUser(n,t)];case 6:return r=i.sent(),[4,this.idleService.start()];case 7:return i.sent(),[2,{hasChallenge:!1,user:r}]}}))}))},n.prototype.verifyLogin=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.auth.confirmSignIn(e,r,e.challengeName)];case 1:return s.sent(),[4,this.auth.currentAuthenticatedUser()];case 2:return i=s.sent(),[4,this.handlePostAuth(e)];case 3:return s.sent(),[4,this.loadUser(i,t)];case 4:return a=s.sent(),n&&i.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,a]}}))}))},n.prototype.handlePasswordRecovery=function(t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return t.recoveryStatus===e.RecoveryStatus.NONE?[3,2]:[4,this.passwordService.changePasswordComplete({useNewPassword:t.recoveryStatus===e.RecoveryStatus.NEW_PASSWORD})];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.getUserOrResetUser=function(e){return void 0===e&&(e=!1),A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t.sent().getUsername().endsWith(Mr)?[2,this.getResetUser(e)]:[2,this.getUser(e)]}}))}))},n.prototype.getResetUser=function(e){return void 0===e&&(e=!1),A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return!e&&this.currentResetUser?[2,this.currentResetUser]:(t=this,[4,this.loadResetUser()]);case 1:return t.currentResetUser=n.sent(),[4,this.idleService.start()];case 2:return n.sent(),[2,this.currentResetUser]}}))}))},n.prototype.getUser=function(e){return void 0===e&&(e=!1),A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return!e&&this.currentUser?[2,this.currentUser]:(t=this,n=this.loadUser,[4,this.auth.currentAuthenticatedUser()]);case 1:return[4,n.apply(this,[r.sent()])];case 2:return t.currentUser=r.sent(),console.log("Starting idle service."),[4,this.idleService.start()];case 3:return r.sent(),[2,this.currentUser]}}))}))},n.prototype.mapTPVaultAccess=function(e){var t=null==e?void 0:e.tpVault;return(null==t?void 0:t.length)>0&&t.some((function(e){return"ACCESS"===e.toUpperCase()}))},n.prototype.loadUser=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,o,c,u,p,d,l,y,h,f,v;return j(this,(function(m){switch(m.label){case 0:return[4,this.profileService.getCurrentUser()];case 1:return n=m.sent(),r=n.currentUser,i=n.contactCard,s=n.userPlans,r.sessionEncryptionKey?(c=(o=this.persistService).setServerSessionEncryptionKey,[4,a.JWK.asKey(r.sessionEncryptionKey)]):[3,3];case 2:c.apply(o,[m.sent()]),m.label=3;case 3:return[4,this.auth.userAttributes(e)];case 4:return u=m.sent(),t?[4,this.keyFactory.derivePassKey(Object.assign({password:t},r.currentUserKey.passKey.passKeyParams))]:[3,8];case 5:return p=m.sent().jwk,l=(d=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(r.currentUserKey.passKey.id,p,r.currentUserKey.masterKey.id)];case 6:return[4,l.apply(d,[m.sent()])];case 7:m.sent(),m.label=8;case 8:return[4,this.keyGraphService.populateKeys(r.currentUserKey)];case 9:return m.sent(),y={id:r.id,sub:this.getUserAttribute("sub",u),username:r.username,currentUserKey:r.currentUserKey,email:this.getUserAttribute("email",u),emailVerified:"true"===this.getUserAttribute("email_verified",u),phone:this.getUserAttribute("phone_number",u),phoneVerified:"true"===this.getUserAttribute("phone_number_verified",u)},f=(h=Object).assign,v=[{}],[4,this.profileService.decryptContactCard(i)];case 10:return[2,(y.contactCard=f.apply(h,v.concat([m.sent()])),y.userDelete=r.userDelete,y.userPlans=s,y.hasTPVaultAccess=this.mapTPVaultAccess(r.features),y.features=r.features,y.sessionEncryptionKey=r.sessionEncryptionKey,y.dateJoined=r.dateJoined,y)]}}))}))},n.prototype.watchAuth=function(){return this.hubSubject},n.prototype.logout=function(){var e;return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,Promise.all($(this.logoutListeners).map((function(e){return e()})))];case 1:return t.sent(),this.currentUser=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.auth.signOut(),this.profileService.signOut()])];case 2:return t.sent(),(null===(e=this.config.debug)||void 0===e?void 0:e.username)&&(this.config.debug.username=null),[2]}}))}))},n.prototype.getUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},n.prototype.loadResetUser=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d,l,y,h,f,v;return j(this,(function(m){switch(m.label){case 0:return[4,this.lrGraphQL.query({query:li})];case 1:return(t=m.sent().tpPasswordResetUser).sessionEncryptionKey?(r=(n=this.persistService).setServerSessionEncryptionKey,[4,a.JWK.asKey(t.sessionEncryptionKey)]):[3,3];case 2:r.apply(n,[m.sent()]),m.label=3;case 3:return e?[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.passKey.passKeyParams))]:[3,7];case 4:return i=m.sent().jwk,o=(s=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,i,t.masterKey.id)];case 5:return[4,o.apply(s,[m.sent()])];case 6:m.sent(),m.label=7;case 7:return this.keyService.setKeys({passKey:{id:t.passKey.id},masterKey:{id:t.masterKey.id}}),p=(u=this.auth).userAttributes,[4,this.auth.currentAuthenticatedUser()];case 8:return[4,p.apply(u,[m.sent()])];case 9:return c=m.sent(),d=this.getUserAttribute("sub",c),y=(l=Object).assign,f=(h=Object).assign,v=[{}],[4,this.tpPasswordResetProcessorService.processTpPasswordResetUserNode(t)];case 10:return[2,y.apply(l,[f.apply(h,v.concat([m.sent()])),{sub:d}])]}}))}))},n.prototype.refreshAccessToken=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),[2,new Promise((function(n,r){e.refreshSession(t,(function(e){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete"),n(0))}))}))]}}))}))},n.prototype.completeRequest=function(t){return A(this,void 0,void 0,(function(){var n,r,i,s,o,c,u,p,d,l,y,h,f,m,g=this;return j(this,(function(S){switch(S.label){case 0:return[4,this.getResetUser(!0)];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new Q("Password reset request has not been approved.");return[4,this.recoverAssemblyKey(n)];case 2:return r=S.sent(),[4,this.encryptionService.decrypt(r,n.assemblyCipherData)];case 3:return i=S.sent().rootKey,[4,a.JWK.asKey(i)];case 4:return s=S.sent(),[4,this.keyGraphService.getKey(n.masterKey.id)];case 5:return o=S.sent(),[4,this.encryptionService.encryptToString(o.jwk,s.toJSON(!0))];case 6:return c=S.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n.passKey.passIdpParams))];case 7:return u=S.sent(),p=this.passwordService.getPassIdpString(u.jwk),[4,this.lrGraphQL.lrMutate(new pt({mutation:ti,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return(d=S.sent().createTpAssemblyKeyChallenge.challenge).clientNonce=this.keyFactory.randomString(32),[4,this.encryptionService.decrypt(r,n.wrappedAssemblyKeyVerifierPrk)];case 9:return l=S.sent(),[4,this.encryptionService.sign(l,d)];case 10:return y=S.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:ni,variables:{input:{signedChallenge:JSON.stringify(y)}}}),{includeKeyGraph:!1})];case 11:return h=S.sent().preCompleteTpPasswordResetRequest.idpPassword,f=new Promise((function(e){var t=function(r){return A(g,void 0,void 0,(function(){return j(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(v.Hub.remove("auth",t),[4,this.auth.signIn(n.username,p)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:ri,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};v.Hub.listen("auth",t)})),[4,this.auth.signIn(n.username,h,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(m=S.sent()).challengeName)throw new z("Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.");return[4,this.auth.completeNewPassword(m,p,{})];case 13:return m=S.sent(),[2,f]}}))}))},n.prototype.recoverAssemblyKey=function(e){return A(this,void 0,void 0,(function(){var t,n,r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyGraphService.getKey(e.pxk.id)];case 1:return t=i.sent(),[4,Promise.all(e.approvals.filter((function(e){return!!e.receiverCipherPartialAssemblyKey})).map((function(e){return r.encryptionService.decrypt(t,e.receiverCipherPartialAssemblyKey)})))];case 2:return n=i.sent(),[2,this.assemblyController.recoverAssemblyKey(n)]}}))}))},n}();vi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new vi(t.ɵɵinject(me),t.ɵɵinject(s.AuthClass),t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(Sr),t.ɵɵinject(ke),t.ɵɵinject(Dr),t.ɵɵinject(xt),t.ɵɵinject(e.ɵf),t.ɵɵinject(e.ɵg),t.ɵɵinject(Ce),t.ɵɵinject(he),t.ɵɵinject(e.ɵi),t.ɵɵinject(f.HttpClient))},token:vi,providedIn:"root"}),vi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],vi.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:s.AuthClass},{type:ve},{type:Ke},{type:Sr},{type:ke},{type:Dr},{type:xt},{type:e.ɵf},{type:e.ɵg},{type:Ce},{type:he},{type:e.ɵi},{type:f.HttpClient}]};var mi,gi,Si,Ii,Ci,bi=function(){function e(e,t){var n=this;this._key=e,this.timer=setTimeout((function(){n._key=null}),t)}return Object.defineProperty(e.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),e.prototype.pop=function(){var e=this._key;return this._key=null,this.timer&&(clearTimeout(this.timer),this.timer=null),e},e}(),wi=je(mi||(mi=F(["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),qe),Ki=je(gi||(gi=F(["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"],["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"])));!function(e){e.NONE="NONE",e.NEW_PASSWORD="NEW_PASSWORD",e.OLD_PASSWORD="OLD_PASSWORD"}(Si||(Si={})),function(e){e.IN_PROGRESS="IN_PROGRESS",e.RECOVERY="RECOVERY"}(Ii||(Ii={})),function(e){e.NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",e.SMS_MFA="SMS_MFA",e.SOFTWARE_TOKEN_MFA="SOFTWARE_TOKEN_MFA",e.MFA_SETUP="MFA_SETUP"}(Ci||(Ci={}));var ki,Pi,Ei=Object.freeze({__proto__:null,get RecoveryStatus(){return Si},get PasswordChangeStatus(){return Ii},get CognitoChallengeName(){return Ci}});e.Auth2Service=ki=function(n){function r(e,r,i,a,s,o,c,u,p,d,l,y,h,f){var v=n.call(this,r)||this;if(v.ngZone=e,v.injector=r,v.http=i,v.cognito=a,v.api=s,v.keyService=o,v.keyGraphService=c,v.keyFactoryService=u,v.passwordService=p,v.idleService=d,v.persistService=l,v.encryptionService=y,v.assemblyController=h,v.kcConfig=f,v.logoutListeners=new Set,v.password=null,!t.isDevMode()&&null!=v.kcConfig.debug)throw new V('In production mode, "KcConfig.debug" must be set to null');return v}return R(r,n),r.prototype.importPassword=function(e){return this.keyFactoryService.importPassword(e)},r.prototype.logout=function(){var e;return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,Promise.all($(this.logoutListeners).map((function(e){return e()})))];case 1:return t.sent(),this.user=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.cognito.signOut(),this.kcLogout()])];case 2:return t.sent(),(null===(e=this.kcConfig.debug)||void 0===e?void 0:e.username)&&(this.kcConfig.debug.username=null),[2]}}))}))},r.prototype.addLogoutListener=function(e){this.logoutListeners.add(e)},r.prototype.removeLogoutListener=function(e){this.logoutListeners.delete(e)},r.prototype.login=function(t,n,r){var i,a=(void 0===r?{}:r).tpPasswordResetAutoComplete,s=void 0===a||a;return A(this,void 0,void 0,(function(){var r;return j(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return(r=a.sent()).challenge?(this.password=new bi(n,ki.CHALLENGE_TIMEOUT),[2,r]):s&&(null===(i=r.user.resetUser)||void 0===i?void 0:i.state)===e.TpClaimState.APPROVED?[4,this.completeResetRequest(n)]:[3,4];case 2:return a.sent(),[4,this.loginImpl(t,n)];case 3:r=a.sent(),a.label=4;case 4:return[2,r]}}))}))},r.prototype.verifyLogin=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:if(t=e.challenge,n=e.code,r=e.rememberMe,!(i=[Ci.SMS_MFA,Ci.SOFTWARE_TOKEN_MFA]).includes(t.cognitoUser.challengeName))throw new V("challengeName must be one of "+i);return[4,this.cognito.confirmSignIn(t.cognitoUser,n,t.cognitoUser.challengeName)];case 1:return a=o.sent(),[4,this.handlePostAuth(t.recoveryStatus)];case 2:return o.sent(),[4,this.loadUser(a,this.password.pop())];case 3:return s=o.sent(),this.password=null,r&&a.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,{user:s}]}}))}))},r.prototype.getUser=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return this.user?[2,this.user]:[4,this.cognito.currentAuthenticatedUser()];case 1:return e=t.sent(),[2,this.loadUser(e)]}}))}))},r.prototype.refreshAccessToken=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return[4,this.cognito.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),console.log("Token refresh..."),[2,new Promise((function(n,r){e.refreshSession(t,(function(e){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete"),n(0))}))}))]}}))}))},r.prototype.fetchCurrentUser=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:wi,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().currentUser]}}))}))},r.prototype.fetchResetUser=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Ki,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().tpPasswordResetUser]}}))}))},r.prototype.kcLogout=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.http.post(this.kcConfig.authUrl+"auth/sign-out/",null,{withCredentials:!0,responseType:"text"}).toPromise()];case 1:return e.sent(),[2]}}))}))},r.prototype.fetchPassIdpParams=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.kcConfig.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},r.prototype.loginImpl=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.logout()];case 1:return r.sent(),[4,this.loginIdp(e,t)];case 2:return n=r.sent(),[Ci.SMS_MFA,Ci.SOFTWARE_TOKEN_MFA].includes(n.cognitoUser.challengeName)?[2,{challenge:{cognitoUser:n.cognitoUser,recoveryStatus:n.recoveryStatus}}]:[4,this.handlePostAuth(n.recoveryStatus)];case 3:return r.sent(),[4,this.loadUser(n.cognitoUser,t)];case 4:return[2,{user:r.sent()}]}}))}))},r.prototype.loginIdp=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return[4,this.fetchPassIdpParams(e)];case 1:if((n=l.sent()).passwordChangeStatus===Ii.IN_PROGRESS)throw new H("A password change is in progress");if(n.passwordChangeStatus!==Ii.RECOVERY)return[3,8];console.log("In recovery mode."),l.label=2;case 2:return l.trys.push([2,4,,5]),i={},[4,this.loginIdpImpl(e,t,n.newPassIdpParams)];case 3:return i.cognitoUser=l.sent(),i.recoveryStatus=Si.NEW_PASSWORD,r=i,console.log("New password works!"),[2,r];case 4:if("NotAuthorizedException"!==(a=l.sent()).code)throw a;return[3,5];case 5:return l.trys.push([5,7,,8]),o={},[4,this.loginIdpImpl(e,t,n.currentPassIdpParams)];case 6:return o.cognitoUser=l.sent(),o.recoveryStatus=Si.OLD_PASSWORD,s=o,console.log("Old password works!"),[2,s];case 7:throw"NotAuthorizedException"===(c=l.sent()).code?new V("The password change request was interrupted, please try to login with both your new and old password"):c;case 8:if(!n.tpPasswordReset)return[3,12];l.label=9;case 9:return l.trys.push([9,11,,12]),u=n.tpPasswordReset,p={},[4,this.loginIdpImpl(u.resetUsername,t,u.passIdpParams)];case 10:return p.cognitoUser=l.sent(),p.recoveryStatus=Si.NONE,[2,p];case 11:return l.sent(),[3,12];case 12:return d={},[4,this.loginIdpImpl(e,t,n.currentPassIdpParams)];case 13:return d.cognitoUser=l.sent(),d.recoveryStatus=Si.NONE,[2,d]}}))}))},r.prototype.loginIdpImpl=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyFactoryService.derivePassIdp(Object.assign({password:t},n))];case 1:return r=i.sent(),[2,this.cognito.signIn(e,this.passwordService.getPassIdpString(r.jwk))]}}))}))},r.prototype.handlePostAuth=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.handlePasswordRecovery(e)];case 1:return t.sent(),[4,this.handleSessionEncryptionKey()];case 2:return t.sent(),[2]}}))}))},r.prototype.handlePasswordRecovery=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return e===Si.NONE?[3,2]:[4,this.passwordService.changePasswordComplete({useNewPassword:e===Si.NEW_PASSWORD})];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},r.prototype.handleSessionEncryptionKey=function(){return A(this,void 0,void 0,(function(){var e,n;return j(this,(function(r){switch(r.label){case 0:if(!this.kcConfig.disableSessionEncryptionKey)return[3,1];if(!t.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new z(e);return console.warn("You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode."),[3,4];case 1:return[4,this.keyFactoryService.createKey()];case 2:return n=r.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:hi,variables:{input:{sessionEncryptionKey:JSON.stringify(n.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(n),r.label=4;case 4:return[2]}}))}))},r.prototype.getCognitoUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},r.prototype.loadUserKeys=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return t=e.userKeys,n=e.password,(r=e.sessionEncryptionKey)?(s=(i=this.persistService).setServerSessionEncryptionKey,[4,a.JWK.asKey(r)]):[3,2];case 1:s.apply(i,[p.sent()]),p.label=2;case 2:return n?[4,this.keyFactoryService.derivePassKey(Object.assign({password:n},t.passKey.passKeyParams))]:[3,6];case 3:return o=p.sent().jwk,u=(c=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,o,t.masterKey.id)];case 4:return[4,u.apply(c,[p.sent()])];case 5:p.sent(),p.label=6;case 6:return[2]}}))}))},r.prototype.loadUser=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return e.getUsername().endsWith(Mr)?(n=this,[4,this.loadResetUser(e,t)]):[3,2];case 1:return n.user=i.sent(),[3,4];case 2:return r=this,[4,this.loadRegularUser(e,t)];case 3:r.user=i.sent(),i.label=4;case 4:return[4,this.idleService.start()];case 5:return i.sent(),[2,this.user]}}))}))},r.prototype.loadRegularUser=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.fetchCurrentUser()];case 1:return n=a.sent(),[4,this.loadUserKeys({userKeys:n.currentUserKey,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return a.sent(),[4,this.keyGraphService.populateKeys(n.currentUserKey)];case 3:return a.sent(),r=n.username,[4,this.cognito.userAttributes(e)];case 4:return i=a.sent(),[2,{username:r,sub:this.getCognitoUserAttribute("sub",i),loginEmail:this.getCognitoUserAttribute("email",i),resetUser:null}]}}))}))},r.prototype.loadResetUser=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.fetchResetUser()];case 1:return n=s.sent(),r={passKey:{id:n.passKey.id,passKeyParams:n.passKey.passKeyParams},masterKey:{id:n.masterKey.id}},[4,this.loadUserKeys({userKeys:r,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return s.sent(),[4,this.keyService.setKeys(r)];case 3:return s.sent(),i=n.username,[4,this.cognito.userAttributes(e)];case 4:return a=s.sent(),[2,{username:i,sub:this.getCognitoUserAttribute("sub",a),loginEmail:this.getCognitoUserAttribute("email",a),resetUser:{state:n.state}}]}}))}))},r.prototype.recoverAssemblyKey=function(e){return A(this,void 0,void 0,(function(){var t,n,r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyGraphService.getKey(e.pxk.id)];case 1:return t=i.sent(),[4,Promise.all(e.approvals.filter((function(e){return!!e.receiverCipherPartialAssemblyKey})).map((function(e){return r.encryptionService.decrypt(t,e.receiverCipherPartialAssemblyKey)})))];case 2:return n=i.sent(),[2,this.assemblyController.recoverAssemblyKey(n)]}}))}))},r.prototype.completeResetRequest=function(t){return A(this,void 0,void 0,(function(){var n,r,i,s,o,c,u,p,d,l,y,h,f,m,g=this;return j(this,(function(S){switch(S.label){case 0:return[4,this.fetchResetUser()];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new Q("Password reset request has not been approved.");return[4,this.recoverAssemblyKey(n)];case 2:return r=S.sent(),[4,this.encryptionService.decrypt(r,n.assemblyCipherData)];case 3:return i=S.sent().rootKey,[4,a.JWK.asKey(i)];case 4:return s=S.sent(),[4,this.keyGraphService.getKey(n.masterKey.id)];case 5:return o=S.sent(),[4,this.encryptionService.encryptToString(o.jwk,s.toJSON(!0))];case 6:return c=S.sent(),[4,this.keyFactoryService.derivePassIdp(Object.assign({password:t},n.passKey.passIdpParams))];case 7:return u=S.sent(),p=this.passwordService.getPassIdpString(u.jwk),[4,this.lrGraphQL.lrMutate(new pt({mutation:ti,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return(d=S.sent().createTpAssemblyKeyChallenge.challenge).clientNonce=this.keyFactoryService.randomString(32),[4,this.encryptionService.decrypt(r,n.wrappedAssemblyKeyVerifierPrk)];case 9:return l=S.sent(),[4,this.encryptionService.sign(l,d)];case 10:return y=S.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:ni,variables:{input:{signedChallenge:JSON.stringify(y)}}}),{includeKeyGraph:!1})];case 11:return h=S.sent().preCompleteTpPasswordResetRequest.idpPassword,f=new Promise((function(e){var t=function(r){return A(g,void 0,void 0,(function(){return j(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(v.Hub.remove("auth",t),[4,this.cognito.signIn(n.username,p)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:ri,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};v.Hub.listen("auth",t)})),[4,this.cognito.signIn(n.username,h,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(m=S.sent()).challengeName)throw new z("Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.");return[4,this.cognito.completeNewPassword(m,p,{})];case 13:return m=S.sent(),[2,f]}}))}))},r.prototype.debugLogin=function(e,t){return this.kcConfig.debug.username=e,this.debugLoadUser(t)},r.prototype.debugLoadUser=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.fetchCurrentUser()];case 1:return t=s.sent(),n=t.username,r=t.currentUserKey,[4,this.keyFactoryService.derivePassKey(Object.assign({password:e},r.passKey.passKeyParams))];case 2:return i=s.sent().jwk,[4,this.keyGraphService.unwrapWithPassKey(r.passKey.id,i,r.masterKey.id)];case 3:return a=s.sent(),[4,this.idleService.persistMasterKey(a)];case 4:return s.sent(),[4,this.keyGraphService.populateKeys(r)];case 5:return s.sent(),this.user={username:n,resetUser:null,sub:"DEBUG_MODE",loginEmail:"DEBUG_MODE"},[2,this.user]}}))}))},r.prototype.debugClearUser=function(){this.user=null},r.prototype.getCurrentUserAttibutes=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return[4,this.cognito.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.cognito.userAttributes(e)];case 2:return[2,t.sent()]}}))}))},r}(At),e.Auth2Service.CHALLENGE_TIMEOUT=3e5,e.Auth2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.Auth2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(f.HttpClient),t.ɵɵinject(s.AuthClass),t.ɵɵinject(e.ɵf),t.ɵɵinject(Ke),t.ɵɵinject(ke),t.ɵɵinject(ve),t.ɵɵinject(Dr),t.ɵɵinject(xt),t.ɵɵinject(Ce),t.ɵɵinject(he),t.ɵɵinject(e.ɵi),t.ɵɵinject(me))},token:e.Auth2Service,providedIn:"root"}),e.Auth2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.Auth2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:f.HttpClient},{type:s.AuthClass},{type:e.ɵf},{type:Ke},{type:ke},{type:ve},{type:Dr},{type:xt},{type:Ce},{type:he},{type:e.ɵi},{type:void 0,decorators:[{type:t.Inject,args:[me]}]}]},e.Auth2Service=ki=O([et({ngZoneName:"ngZone"})],e.Auth2Service),(Pi=e.FileType||(e.FileType={})).RecordContent="record-content",Pi.RecordAttachment="record-attachment";var Di,Ri,Mi,Oi,Ai,ji,Ti,Ni,$i=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordContent}}]}),Fi=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordAttachment}}]}),Ui=function(e){return void 0===e&&(e=5),k.default(Di||(Di=F(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n confidentiality {\n isConfidential\n method\n }\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n confidentiality {\n isConfidential\n method\n }\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),bn(e),qe)},Li=k.default(Ri||(Ri=F(["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),xi=k.default(Mi||(Mi=F(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),_i=k.default(Oi||(Oi=F(["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Ji=k.default(Ai||(Ai=F(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),qi=k.default(ji||(ji=F(["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"],["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"]))),Gi=k.default(Ti||(Ti=F(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Vi=k.default(Ni||(Ni=F(["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"],["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"]))),Bi=function(){function t(e,t,n){this.lrApollo=e,this.keyMetaService=t,this.keyGraph=n}return t.prototype.getRootDirectoryIds=function(e){return void 0===e&&(e=null),A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:mn,variables:{archived:e&&e.archived}})];case 1:return[2,t.sent().rootDirectories.edges.map((function(e){return e.node.id}))]}}))}))},t.prototype.getDefaultVault=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Sn,variables:{plainMetaFilter:dn}})];case 1:return e=n.sent().list,[4,this.mapVaults(e)];case 2:if((t=n.sent()).length>1)throw new Q("There are more than one default vaults");return[2,t[0]||null]}}))}))},t.prototype.getCategories=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return(r=null==e?void 0:e.vaultDirectoryId)?[3,2]:[4,this.getDefaultVault()];case 1:r=null===(t=a.sent())||void 0===t?void 0:t.id,a.label=2;case 2:return(n=r)?[4,this.lrApollo.query({query:gn,variables:{vaultDirectoryId:n,categoryFilter:ln,recordFilter:yn,archived:null==e?void 0:e.archived}})]:(console.error("There is no default vault."),[2,[]]);case 3:return i=a.sent(),[2,this.mapCategories(i.directory.childDirectoryLinks)]}}))}))},t.prototype.getTrustedPartyCategories=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:In,variables:{trustedPartyId:e,categoryFilter:ln,recordFilter:yn,contentFilter:$i}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.theirItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.theirItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getMySharedCategories=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Cn,variables:{trustedPartyId:e,categoryFilter:ln,recordFilter:yn,contentFilter:$i}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.myItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.myItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getCategory=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return[4,this.lrApollo.query({query:wn(),variables:{id:e,categoryFilter:ln,recordFilter:yn,contentFilter:$i}})];case 1:return t=p.sent().category,n={},i=(r=Object).assign,s=(a=Object).assign,o=[{}],[4,this.mapCategory(t)];case 2:return c=[s.apply(a,o.concat([p.sent()]))],u={},[4,this.mapParentCategories(t)];case 3:return n.category=i.apply(r,c.concat([(u.parents=p.sent(),u)])),[4,this.mapCategories(t.subCategories)];case 4:return n.subCategories=p.sent(),[4,this.mapRecords(t.records)];case 5:return[2,(n.records=p.sent(),n)]}}))}))},t.prototype.mapVaults=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){return[2,Promise.all(e.edges.map((function(e){return t.mapVault(e.node)})))]}))}))},t.prototype.mapCategories=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapCategory(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.mapRecords=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapRecord(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.createDefaultVault=function(){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return"",[4,this.keyMetaService.wrapContent("")];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:Pn,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Vault,default:!0}),cipherMeta:t.cipherMeta,parentRootDirectory:t.rootKey}})];case 2:return[2,n.sent().new.vault.id]}}))}))},t.prototype.createCategory=function(t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return n={name:t.name,code:t.code,isCustom:t.isCustom,allowRecords:t.allowRecords,allowCustomCategories:t.allowCustomCategories},[4,this.keyMetaService.wrapContent(n,t.categoryIds)];case 1:return r=i.sent(),[4,this.lrApollo.mutate({mutation:kn,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:!1}),cipherMeta:r.cipherMeta,parentDirectories:r.wrappedKeys,parentRootDirectory:r.rootKey}})];case 2:return[2,i.sent().new.category.id]}}))}))},t.prototype.updateCategory=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return r={name:n.name,code:n.code,isCustom:n.isCustom,allowRecords:n.allowRecords,allowCustomCategories:n.allowCustomCategories},[4,this.keyGraph.encryptToString(t,r)];case 1:return i=a.sent(),[4,this.lrApollo.mutate({mutation:En,variables:{input:{directoryId:e,cipherMeta:i}}})];case 2:return a.sent(),[2]}}))}))},t.prototype.setCategoryVisibility=function(t,n){return A(this,void 0,void 0,(function(){return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.mutate({mutation:En,variables:{input:{directoryId:t,plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:n})}}})];case 1:return r.sent(),[2]}}))}))},t.prototype.deleteCategory=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Dn,variables:{categoryId:e}})];case 1:return t.sent(),[2]}}))}))},t.prototype.archiveCategory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.archiveDirectory(e,t)]}))}))},t.prototype.unarchiveCategory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.unarchiveDirectory(e,t)]}))}))},t.prototype.archiveDirectory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Rn,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.unarchiveDirectory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Mn,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapVault=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(e)];case 1:return t=(r.sent()||{}).name,[2,{id:e.id,keyId:e.keyId,name:t}];case 2:return n=r.sent(),console.error("Failed to decrypt Vault.",n,e),[2,null];case 3:return[2]}}))}))},t.prototype.mapParentCategories=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return e.parentCategories&&e.parentCategories.edges&&e.parentCategories.edges.length?(t=e.parentCategories.edges[0].node.parentDirectory,[4,this.mapParentCategories(t)]):[2,[]];case 1:return n=[r.sent()],[4,this.mapCategory(t)];case 2:return[2,$.apply(void 0,n.concat([[r.sent()]]))]}}))}))},t.prototype.mapCategory=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return p.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(e)];case 1:return n=p.sent()||{},r=n.name,i=n.isCustom,a=n.allowRecords,s=n.allowCustomCategories,o=n.code,c=(e.plainMeta&&JSON.parse(e.plainMeta)||{}).isHidden,[2,{id:e.id,keyId:e.keyId,code:o,name:r,isHidden:!!c,isCustom:!!i,isArchived:!!e.archived,allowRecords:!!a,allowCustomCategories:!!s,isEmpty:e.descendantDirectories?0===e.descendantDirectories.recordsCount:null,allRecordsCount:null===(t=e.descendantDirectories)||void 0===t?void 0:t.recordsCount}];case 2:return u=p.sent(),console.error("Failed to decrypt Category.",u,e),[2,null];case 3:return[2]}}))}))},t.prototype.mapRecord=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=e.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(t.currentVersion.state)];case 1:return n=s.sent()||{},r=n.name,i=n.recordType,[2,{id:e.id,keyId:e.keyId,name:r,recordType:i,isArchived:!!e.archived,createdOn:e.created,lastModified:new Date(e.modified)>new Date(t.currentVersion.state.modified)?e.modified:t.currentVersion.state.modified}];case 2:return a=s.sent(),console.error("Failed to decrypt Record.",a),[2,null];case 3:return[2]}}))}))},t}();Bi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Bi(t.ɵɵinject(Pe),t.ɵɵinject(On),t.ɵɵinject(ke))},token:Bi,providedIn:"root"}),Bi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Bi.ctorParameters=function(){return[{type:Pe},{type:On},{type:ke}]};var Qi,Wi=function(){},Zi=function(){function e(e,t){this.http=e,this.categoryService=t}return e.prototype.getCoreCategories=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return this.categories?[3,2]:(e=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 1:e.categories=t.sent(),t.label=2;case 2:return[2,Promise.resolve(this.categories)]}}))}))},e.prototype.loadCategories=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p=this;return j(this,(function(d){switch(d.label){case 0:return n?[4,this.categoryService.getTrustedPartyCategories(n)]:[3,2];case 1:return i=d.sent().categories,[3,4];case 2:return[4,this.categoryService.getCategories()];case 3:i=d.sent(),d.label=4;case 4:return r=i,t?[4,this.categoryService.getCategory(t)]:[3,6];case 5:return s=d.sent(),[3,7];case 6:s=null,d.label=7;case 7:return a=s,o=e.map((function(e){return A(p,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t={categoryTree:e},[4,this.loadCategory($(e),r,a)];case 1:return[2,(t.category=n.sent(),t)]}}))}))})),[4,Promise.all(o)];case 8:return c=d.sent(),u={categories:[],missingCategories:[]},c.forEach((function(e){return e.category?u.categories.push(e.category):u.missingCategories.push(e.categoryTree)})),[2,u]}}))}))},e.prototype.loadCategoriesForRole=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,this.categoryService.getCategories()];case 1:return t=r.sent(),[4,Promise.all(e.map((function(e){return A(n,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return n={},[4,this.loadCategory($(e.category),t)];case 1:return[2,(n.category=r.sent(),n.accessLevel=e.accessLevel,n)]}}))}))})))];case 2:return[2,r.sent()]}}))}))},e.prototype.loadCategory=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return r=e.shift(),(i=t.find((function(e){return e.code===r&&!e.isCustom})))?e.length?[4,this.categoryService.getCategory(i.id)]:[3,2]:[3,5];case 1:return a=o.sent().subCategories,[2,this.loadCategory(e,a,n)];case 2:return[4,this.categoryService.getCategory(i.id)];case 3:return s=o.sent().category,n&&n.category.parents.some((function(e){return e.id===s.id}))?[2,n.category]:[2,s];case 4:return[3,6];case 5:return e.length?[2,this.loadCategory(e,t,n)]:[2,null];case 6:return[2]}}))}))},e}();Zi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Zi(t.ɵɵinject(f.HttpClient),t.ɵɵinject(Bi))},token:Zi,providedIn:"root"}),Zi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Zi.ctorParameters=function(){return[{type:f.HttpClient},{type:Bi}]},(Qi=e.AccessLevel||(e.AccessLevel={})).Owner="OWNER",Qi.Admin="ADMIN",Qi.Writer="WRITER",Qi.Reader="READER",Qi.Deny="DENY";var Hi,Yi,zi,Xi=function(){},ea=function(){},ta=function(){},na=function(){},ra=function(){},ia=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),t}(ra),aa=function(){},sa=function(){},oa=function(){},ca=function(){},ua=je(Hi||(Hi=F(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"],["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"]))),pa=je(Yi||(Yi=F(["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"],["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"]))),da=je(zi||(zi=F(["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"]))),la=function(){};e.ContactCard2Service=function(){function e(e,t,n,r,i,a){this.keyFactory=e,this.keyService=t,this.encryptionService=n,this.keyGraph=r,this.keyMetaService=i,this.ngZone=a}return e.prototype.createContactCard=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return t=this.keyService.currentRootKey,[4,this.keyFactory.createKey()];case 1:return n=s.sent(),[4,this.keyGraph.encryptToString(t.jwk,n.toJSON(!0))];case 2:return r=s.sent(),[4,this.keyGraph.encryptToString(n,e.plainCipherDataJson)];case 3:return i=s.sent(),[4,this.prepareContactCardInput(e)];case 4:return a=s.sent(),[2,new pt({mutation:ua,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.keyGraph.encryptToString(e.keyId,e.plainCipherDataJson)];case 1:return t=r.sent(),[4,this.prepareContactCardInput(e)];case 2:return n=r.sent(),[2,new pt({mutation:pa,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new pt({mutation:da,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return t=this.keyService.currentSigPxk,i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicDataJson)];case 1:return n=i.apply(r,[d.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicSearchableJson)];case 2:return a=o.apply(s,[d.sent()]),p=(u=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.plainDataJson)];case 3:return c=p.apply(u,[d.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:c}]}}))}))},e}(),e.ContactCard2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ContactCard2Service(t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(he),t.ɵɵinject(ke),t.ɵɵinject(On),t.ɵɵinject(t.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:ve},{type:Ke},{type:he},{type:ke},{type:On},{type:t.NgZone}]},e.ContactCard2Service=O([et({ngZoneName:"ngZone"})],e.ContactCard2Service);var ya=function(){function e(e,t,n){this.config=e,this.http=t,this.auth=n}return e.prototype.downloadEncryptedFile=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile2(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile2=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return t=this.config.apiUrl+"files/download/?file_state_node_id="+e,r=(n=this.http).get,i=[t],s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,Se(this.auth,this.config)];case 1:return[4,r.apply(n,i.concat([s.apply(a,[c.apply(o,u.concat([p.sent()])),{responseType:"text"}])])).toPromise()];case 2:return[2,p.sent()]}}))}))},e.prototype.loadFile=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new Promise((function(t){var n=new FileReader;n.onload=function(){t(n.result)},n.readAsArrayBuffer(e)}))]}))}))},e.prototype.uploadEncryptedFile=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return t=e.encryptedContent,n=e.fileName,(r=new FormData).append("content",new Blob([t]),n),a=(i=this.http).post,s=[this.config.apiUrl+"files/upload/",r],[4,Se(this.auth,this.config)];case 1:return[4,a.apply(i,s.concat([o.sent()])).toPromise()];case 2:return[2,o.sent().content_resource]}}))}))},e}();ya.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ya(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(s.AuthClass))},token:ya,providedIn:"root"}),ya.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ya.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:s.AuthClass}]};var ha,fa,va,ma,ga=je(ha||(ha=F(["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"],["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"]))),Sa=je(fa||(fa=F(["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),ga),Ia=je(va||(va=F(["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),ga),Ca=je(ma||(ma=F(["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),ga);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.updateLockMutation=function(e){return new pt({mutation:Sa,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t.prototype.acquireLockMutation=function(e){return new pt({mutation:Ia,variables:{input:{resourceId:e.resourceId,timeoutMs:e.timeoutMs}}})},t.prototype.releaseLockMutation=function(e){return new pt({mutation:Ca,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t}(At),e.LockService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.LockService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.LockService,providedIn:"root"}),e.LockService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.LockService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.LockService=O([et({ngZoneName:"ngZone"})],e.LockService);var ba,wa,Ka,ka,Pa,Ea,Da,Ra,Ma,Oa,Aa,ja,Ta,Na,$a,Fa,Ua,La,xa,_a,Ja,qa=je(ba||(ba=F(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"],["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"]))),Ga=je(wa||(wa=F(["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"],["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"]))),Va=je(Ka||(Ka=F(["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"]))),Ba=je(ka||(ka=F(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"],["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"]))),Qa=je(Pa||(Pa=F(["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),Wa=je(Ea||(Ea=F(["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),Za=je(Da||(Da=F(["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"]))),Ha=je(Ra||(Ra=F(["\nmutation ArchiveDirectoryMutation($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ArchiveDirectoryMutation($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),Ya=je(Ma||(Ma=F(["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),za=je(Oa||(Oa=F(["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),Xa=je(Aa||(Aa=F(["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),es=je(ja||(ja=F(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),ts=je(Ta||(Ta=F(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"]))),ns=je(Na||(Na=F(["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"],["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"]))),rs=je($a||($a=F(['\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: "created") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n'],['\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: "created") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n']))),is=je(Fa||(Fa=F(["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"]))),as=je(Ua||(Ua=F(["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),ss=je(La||(La=F(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"],["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"]))),os=je(xa||(xa=F(["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"],["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"]))),cs=je(_a||(_a=F(["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"],["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"])));e.Item2Service=Ja=function(e){function t(t,n,r,i,a,s,o,c){var u=e.call(this,n)||this;return u.ngZone=t,u.injector=n,u.fileUploadService=r,u.keyService=i,u.keyFactory=a,u.keyGraph=s,u.lockService=o,u.auth2Service=c,u.tempDirectory=null,u.auth2Service.addLogoutListener((function(){return u.onLogout()})),u}return R(t,e),t.prototype.downloadFileContent=function(e){return A(this,void 0,void 0,(function(){var t,n,r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.fileUploadService.downloadEncryptedFile2(e.fileStateNodeId)];case 1:return t=i.sent(),[4,this.keyGraph.getKey(e.fileStateKeyId,(function(){return r.getFileStateKeyId(e.fileStateNodeId)}))];case 2:return n=i.sent(),[2,this.keyGraph.decryptFromString(n,t,{payloadType:"ArrayBuffer"})]}}))}))},t.prototype.getDirectoryKeyId=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.query({query:ss,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},t.prototype.getFileKeyId=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.query({query:os,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},t.prototype.getDirectoryKey=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},t.prototype.getFileKey=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},t.prototype.createDirectoryExec=function(e){return this.mutate(this.createDirectoryMutation(e))},t.prototype.createDirectory=function(e){return this.createDirectoryMutation(e)},t.prototype.createDirectoryMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:qa},r={},[4,this.prepareCreateDirectory(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.updateDirectoryExec=function(e){return this.mutate(this.updateDirectoryMutation(e))},t.prototype.updateDirectory=function(e){return this.updateDirectoryMutation(e)},t.prototype.updateDirectoryMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:Ga},r={},[4,this.prepareUpdateDirectory(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.deleteDirectoryExec=function(e){return this.mutate(this.deleteDirectoryMutation(e))},t.prototype.deleteDirectory=function(e){return this.deleteDirectoryMutation(e)},t.prototype.deleteDirectoryMutation=function(e){return new pt({mutation:Va,variables:{input:{directoryId:e}}})},t.prototype.createFileExec=function(e){return this.mutate(this.createFileMutation(e))},t.prototype.createFile=function(e){return this.createFileMutation(e)},t.prototype.createFileMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:Ba},r={},[4,this.prepareCreateFile(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.updateFileExec=function(e){return this.mutate(this.updateFileMutation(e))},t.prototype.updateFile=function(e){return this.updateFileMutation(e)},t.prototype.updateFileMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:Qa},r={},[4,this.prepareUpdateFile(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.revertFileExec=function(e){return this.mutate(this.revertFileMutation(e))},t.prototype.revertFile=function(e){return this.revertFileMutation(e)},t.prototype.revertFileMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:Wa,variables:{input:e}})]}))}))},t.prototype.deleteFileExec=function(e){return this.mutate(this.deleteFileMutation(e))},t.prototype.deleteFile=function(e){return this.deleteFileMutation(e)},t.prototype.deleteFileMutation=function(e){return new pt({mutation:Za,variables:{input:{fileId:e}}})},t.prototype.archiveDirectoryExec=function(e,t){return this.mutate(this.archiveDirectoryMutation(e,t))},t.prototype.archiveDirectory=function(e,t){return this.archiveDirectoryMutation(e,t)},t.prototype.archiveDirectoryMutation=function(e,t){return new pt({mutation:Ha,variables:{input:{directoryId:e,recursive:t.recursive}}})},t.prototype.archiveFileExec=function(e){return this.mutate(this.archiveFileMutation(e))},t.prototype.archiveFileMutation=function(e){return new pt({mutation:Ya,variables:{input:{fileId:e}}})},t.prototype.unarchiveDirectoryExec=function(e,t){return this.mutate(this.unarchiveDirectoryMutation(e,t))},t.prototype.unarchiveDirectory=function(e,t){return this.unarchiveDirectoryMutation(e,t)},t.prototype.unarchiveDirectoryMutation=function(e,t){return new pt({mutation:za,variables:{input:{directoryId:e,recursive:t.recursive}}})},t.prototype.unarchiveFileExec=function(e){return this.mutate(this.unarchiveFileMutation(e))},t.prototype.unarchiveFile=function(e){return this.unarchiveFileMutation(e)},t.prototype.unarchiveFileMutation=function(e){return new pt({mutation:Xa,variables:{input:{fileId:e}}})},t.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},t.prototype.changeDirectoryParentsMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:es},r={},[4,this.prepareChangeDirectoryParents(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.changeFileParents=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},t.prototype.changeFileParentsMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:ts},r={},[4,this.prepareChangeFileParents(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.beginDeleteChildItemLinksWindow=function(e){return this.mutate(this.beginDeleteChildItemLinksWindowMutation(e))},t.prototype.beginDeleteChildItemLinksWindowMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:ns,variables:{input:e}})]}))}))},t.prototype.ensureTempDirectory=function(){var e;return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return this.tempDirectory?[2,this.tempDirectory]:[4,this.query({query:rs,variables:{plainMeta:Ja.TEMP_DIRECTORY_PLAIN_META_FILTER}})];case 1:return(t=p.sent()).rootDirectories.edges.length>1&&console.error("There is more than 1 temp directory (plainMeta filter: "+Ja.TEMP_DIRECTORY_PLAIN_META_FILTER+")"),0!==t.rootDirectories.edges.length?[3,4]:[4,this.createDirectory({asRootDirectory:!0,plainMetaJson:Ja.TEMP_DIRECTORY_PLAIN_META})];case 2:return n=p.sent(),r=this.lockService.updateLockMutation({version:null===(e=t.lock)||void 0===e?void 0:e.version}),[4,this.lrGraphQL.lrMutate([n,r])];case 3:return i=N.apply(void 0,[p.sent(),1]),a=i[0],s=a.createDirectory.directory,c=s.id,u=s.keyId,this.tempDirectory={id:c,keyId:u},[3,5];case 4:o=t.rootDirectories.edges[0].node,c=o.id,u=o.keyId,this.tempDirectory={id:c,keyId:u},p.label=5;case 5:return[2,this.tempDirectory]}}))}))},t.prototype.createDirectoryTree=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.createDirectoryTreeMutation(e))]}))}))},t.prototype.createDirectoryTreeMutation=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.ensureTempDirectory()];case 1:return t=r.sent(),[4,this.beginDeleteChildItemLinksWindow({directoryId:t.id,requestWindowMs:e.requestWindowMs})];case 2:return r.sent(),[4,this.createDirectoryExec({cipherMetaClearJson:e.cipherMetaClearJson,parentDirectories:[{directoryId:t.id,wrappingKeyId:t.keyId}],plainMetaJson:e.plainMetaJson})];case 3:return n=r.sent().createDirectory.directory,[4,e.createContent({id:n.id,keyId:n.keyId})];case 4:return r.sent(),[2,this.changeDirectoryParentsMutation({directoryId:n.id,directoryKeyId:n.keyId,parentsToRemove:[t.id],parentsToAdd:e.parentDirectories})]}}))}))},t.prototype.setFileConfidential=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.setFileConfidentialMutation(e))]}))}))},t.prototype.setFileConfidentialMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:is,variables:{input:{fileId:e.fileId,confidential:e.confidential}}})]}))}))},t.prototype.setDirectoryConfidential=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.setDirectoryConfidentialMutation(e))]}))}))},t.prototype.setDirectoryConfidentialMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:as,variables:{input:{directoryId:e.directoryId,confidential:e.confidential}}})]}))}))},t.prototype.prepareParentDirectory=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.wrappingKeyId)];case 1:return n=i.sent(),r={directoryId:e.directoryId,wrappingKeyId:n.id},[4,this.keyGraph.wrapKey(n,t)];case 2:return[2,(r.wrappedKey=i.sent(),r.linkType=e.linkType,r)]}}))}))},t.prototype.getFileStateKeyId=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.query({query:cs,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},t.prototype.prepareCreateFileState=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y;return j(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),(i=t.file)?[4,this.fileUploadService.loadFile(t.file)]:[3,3];case 2:i=h.sent(),h.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,8];case 4:return s=h.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=h.sent(),[3,8];case 6:return[4,this.fileUploadService.uploadEncryptedFile({encryptedContent:s})];case 7:a=h.sent(),h.label=8;case 8:return c=(o=Object).assign,p=(u=Object).assign,d=[{}],[4,this.prepareItem(n,t)];case 9:return l=[p.apply(u,d.concat([h.sent()]))],y={},[4,this.keyGraph.wrapKey(e,n)];case 10:return[2,c.apply(o,l.concat([(y.wrappedStateKey=h.sent(),y.contentResource=a,y)]))]}}))}))},t.prototype.prepareChangeItemParents=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i=this;return j(this,(function(a){switch(a.label){case 0:return e.parentsToAdd?[4,Promise.all(e.parentsToAdd.map((function(e){return i.prepareParentDirectory(e,t)})))]:[3,2];case 1:return r=a.sent(),[3,3];case 2:r=[],a.label=3;case 3:return n=r,[2,{directoriesToRemove:e.parentsToRemove||[],directoriesToAdd:n}]}}))}))},t.prototype.prepareItem=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return n=t.plainMetaJson,r=t.cipherMetaClearJson,i={plainMeta:n&&JSON.stringify(n)},(a=r)?[4,this.keyGraph.encryptToString(e,r)]:[3,2];case 1:a=s.sent(),s.label=2;case 2:return[2,(i.cipherMeta=a,i)]}}))}))},t.prototype.prepareCreateDirectory=function(e){var t,n,r;return A(this,void 0,void 0,(function(){var i,a,s,o,c,u,p=this;return j(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:if(i=d.sent(),e.parentDirectories=e.parentDirectories||[],!e.asRootDirectory&&!(null===(t=e.parentDirectories)||void 0===t?void 0:t.length))throw new q("A new directory must be either a root directory or a sub-directory. So you must provide either parentDirectories or asRootDirectory parameter.");if(e.asRootDirectory&&(null===(n=e.parentDirectories)||void 0===n?void 0:n.length))throw new q("A new directory must be either a root directory or a sub-directory. So you can only provide either parentDirectories or asRootDirectory parameter.");return[4,Promise.all(null===(r=e.parentDirectories)||void 0===r?void 0:r.map((function(e){return p.prepareParentDirectory(e,i)})))];case 2:return a=d.sent(),e.asRootDirectory?(o=this.keyService.currentRootKey,c={wrappingKeyId:o.id},[4,this.keyGraph.wrapKey(o,i)]):[3,4];case 3:c.wrappedKey=d.sent(),s=c,d.label=4;case 4:return[4,this.prepareItem(i,e)];case 5:return u=d.sent(),[2,Object.assign(Object.assign({},u),{parentDirectories:a,parentRootDirectory:s})]}}))}))},t.prototype.prepareUpdateDirectory=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareItem(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},t.prototype.prepareCreateFile=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i=this;return j(this,(function(a){switch(a.label){case 0:return[4,this.keyFactory.createKey()];case 1:return t=a.sent(),[4,Promise.all(e.parentDirectories.map((function(e){return A(i,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.prepareParentDirectory(e,t)];case 1:return n=s.sent(),r=n.directoryId,i=n.wrappingKeyId,a=n.wrappedKey,[2,{directoryId:r,wrappingKeyId:i,wrappedFileKey:a}]}}))}))})))];case 2:return n=a.sent(),[4,this.prepareCreateFileState(t,e)];case 3:return r=a.sent(),[2,Object.assign(Object.assign({},r),{parentDirectories:n})]}}))}))},t.prototype.prepareUpdateFile=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareCreateFileState(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},t.prototype.prepareChangeDirectoryParents=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},t.prototype.prepareChangeFileParents=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},t.prototype.onLogout=function(){this.tempDirectory=null},t}(At),e.Item2Service.TEMP_DIRECTORY_PLAIN_META={kcType:"temp"},e.Item2Service.TEMP_DIRECTORY_PLAIN_META_FILTER=JSON.stringify({filter:[{contains:Ja.TEMP_DIRECTORY_PLAIN_META}]}),e.Item2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.Item2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ya),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(ke),t.ɵɵinject(e.LockService),t.ɵɵinject(e.Auth2Service))},token:e.Item2Service,providedIn:"root"}),e.Item2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.Item2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ya},{type:Ke},{type:ve},{type:ke},{type:e.LockService},{type:e.Auth2Service}]},e.Item2Service=Ja=O([et({ngZoneName:"ngZone"})],e.Item2Service);var us,ps,ds,ls,ys,hs,fs,vs,ms="\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n}",gs="\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n pbk\n }\n mkReshareRequestCipher\n mkReshareResponseCipher\n mkReshareRequestSent\n mkReshareResponseSent\n",Ss=k.default(us||(us=F(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""],["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""])),gs,qe),Is=k.default(ps||(ps=F(["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"],["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"])),ms,qe),Cs=k.default(ds||(ds=F(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),ms,qe),bs=k.default(ls||(ls=F(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"])),ms),ws=k.default(ys||(ys=F(["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"],["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"])),ms,Ve),Ks=k.default(hs||(hs=F(["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),ms,gs),ks=k.default(fs||(fs=F(["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),ms,gs);(vs=e.OtkState||(e.OtkState={})).OTK_INITIATED="OTK_INITIATED",vs.OTK_ACCEPTED="OTK_ACCEPTED",vs.OTK_COMPLETED="OTK_COMPLETED";var Ps=function(){function t(e,t,n,r,i){this.keyFactory=e,this.keyService=t,this.lrApollo=n,this.encryptionService=r,this.auth2Service=i,this.CLIENT_NONCE_LENGTH=32}return t.prototype.getKeyExchangeList=function(e){return void 0===e&&(e={}),A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Is,variables:Object.assign({},e)})];case 1:return[2,t.sent().keyExchanges]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:i?bs:Cs,variables:{id:e,token:i}})];case 1:return t=n.sent().keyExchange,[4,this.decryptKeyExchange(t,r)];case 2:return[2,n.sent()]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,n)];case 1:return n=i.sent(),[3,3];case 2:if("no key found"!==(r=i.sent()).message)throw r;return[3,3];case 3:return[4,this.encryptionService.decrypt(t,n)];case 4:return[2,i.sent()]}}))}))},t.prototype.decryptKeyExchange=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return e.isInitiator?(n=this.keyService.currentRootKey,[4,this.encryptionService.decrypt(n.jwk,e.initiatorRootKeyCipher)]):[3,7];case 1:return r=d.sent(),e.otk.initiatorOneTimePbkCipher?(s=this.decryptResponseCipher,[4,ve.asKey(r.otKey)]):[3,5];case 2:return o=[d.sent()],[4,ve.asKey(r.oneTimePrk)];case 3:return[4,s.apply(this,o.concat([d.sent(),e.otk.initiatorOneTimePbkCipher]))];case 4:return a=d.sent(),[3,6];case 5:a=null,d.label=6;case 6:return c=(i=a)&&i.responder,p=r&&r.initiator,[2,Object.assign(Object.assign({},e),{message:c?c.message:null,contactCard:c&&c.contactCard?c.contactCard.plainSharedCipherDataJson:null,myContactCard:p&&p.contactCard?p.contactCard.plainSharedCipherDataJson:null,myMessage:p&&p.message})];case 7:return[4,this.decryptOtk(e,t)];case 8:return u=d.sent(),p=u&&u.plainOtKeyCipher.initiator,[2,Object.assign(Object.assign({},e),{decryptedOtk:u,message:p&&p.message,contactCard:p&&p.contactCard&&p.contactCard.plainSharedCipherDataJson})]}}))}))},t.prototype.decryptOtk=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.getOtKey(e,t)];case 1:return(n=a.sent())&&e.otk.otKeyCipher?(i={},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:return i.plainOtKeyCipher=a.sent(),i.otKey=n,r=i,[3,4];case 3:r=null,a.label=4;case 4:return[2,r]}}))}))},t.prototype.getOtKey=function(t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return n?[4,ve.asKey(Object.assign(Object.assign({},JSON.parse(t.otk.otKeyParams)),{k:n}))]:[3,2];case 1:return[2,a.sent()];case 2:return t.otk.state!==e.OtkState.OTK_INITIATED||t.isInitiator||!t.otk.responderPbkCipher?[3,5]:(r=this.keyService.currentPxk,[4,this.encryptionService.decrypt(r.jwk,JSON.parse(t.otk.responderPbkCipher),{serializations:[ce.COMPACT]})]);case 3:return(i=a.sent()).otKey?[4,ve.asKey(i.otKey)]:[3,5];case 4:return[2,a.sent()];case 5:return[2,null]}}))}))},t.prototype.initiateOtk=function(e){var t=e.message,n=e.email,r=e.contactCard,i=e.upgrade;return A(this,void 0,void 0,(function(){var e,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S;return j(this,(function(I){switch(I.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=I.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.auth2Service.getUser()];case 2:return s=I.sent(),[4,this.keyFactory.createPkcKey()];case 3:return o=I.sent(),c=this.keyService.currentPxk,u=this.keyService.currentSigPxk,p=null,r&&r.ownerPlainData?(l=(d=JSON).stringify,[4,this.encryptionService.sign(u.jwk,r.ownerPlainData)]):[3,5];case 4:p=l.apply(d,[I.sent()]),I.label=5;case 5:return y={message:t,contactCard:r?{plainSharedCipherDataJson:r.plainSharedCipherDataJson}:null},h={nonce:a,initiator:Object.assign(Object.assign({},y),{oneTimePbk:o.toJSON(),pbk:c.jwk.toJSON(),sigPbk:u.jwk.toJSON(),profile:{username:s.username}})},[4,this.encryptionService.encrypt(e,h)];case 6:return f=I.sent(),v={nonce:a,oneTimePrk:o.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:r,initiator:y},m=this.keyService.currentRootKey,[4,this.encryptionService.encrypt(m.jwk,v)];case 7:return g=I.sent(),S=e.toJSON(!0).k,[4,this.lrApollo.mutate({mutation:ws,variables:{input:{initiatorRootKeyCipher:JSON.stringify(g),initiatorPxkId:c.id,initiatorSigPxkId:u.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:JSON.stringify(f),sendEmail:n?{email:n,rawOtKey:S}:null,createTp:!0,initiatorPlainDataSig:p,upgrade:i}}})];case 8:return[2,{keyExchange:I.sent().initiateKeyExchangeOtk.keyExchange,otKeyK:S}]}}))}))},t.prototype.respondOtk=function(e){var t=e.id,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return A(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b,w,K,k,P,E,D,R,M,O,A,T,N,$,F,U,L,x,_,J,q,G,V,B,Q,W,Z,H,Y,z,X,ee,te,ne;return j(this,(function(j){switch(j.label){case 0:return[4,this.auth2Service.getUser()];case 1:return e=j.sent(),o=this.keyService.currentRootKey,c=this.keyService.currentMasterKey,[4,this.keyFactory.createKey()];case 2:return u=j.sent(),[4,this.keyFactory.createKey()];case 3:return p=j.sent(),[4,this.encryptionService.encrypt(o.jwk,u.toJSON(!0))];case 4:return d=j.sent(),[4,this.encryptionService.encrypt(c.jwk,p.toJSON(!0))];case 5:return l=j.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.oneTimePbk)];case 6:return y=j.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.pbk)];case 7:return h=j.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.sigPbk)];case 8:return f=j.sent(),v=this.keyService.currentPxk,m=this.keyService.currentSigPxk,[4,this.encryptionService.sign(m.jwk,h.toJSON())];case 9:return g=j.sent(),[4,this.encryptionService.sign(m.jwk,f.toJSON())];case 10:return S=j.sent(),I={nonce:r.plainOtKeyCipher.nonce,sharedKey:u.toJSON(!0),mkSharedKey:p.toJSON(!0),responder:{pbk:v.jwk.toJSON(),sigPbk:m.jwk.toJSON(),profile:{username:e.username},message:i}},r.plainOtKeyCipher.initiator.contactCard?(b=r.plainOtKeyCipher.initiator.contactCard.plainSharedCipherDataJson,[4,this.keyFactory.createKey()]):[3,20];case 11:return w=j.sent(),[4,this.keyFactory.createKey()];case 12:return U=j.sent(),L=this.keyService.currentSigPxk,K={},P=(k=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,w.toJSON(!0))];case 13:return K.receiverWrappedKey=P.apply(k,[j.sent()]),K.receiverWrappingKeyId=o.id,a?(R=(D=JSON).stringify,[4,this.encryptionService.encrypt(w,a.plainReceiverCipherDataJson)]):[3,15];case 14:return E=R.apply(D,[j.sent()]),[3,16];case 15:E="",j.label=16;case 16:return K.receiverCipherData=E,O=(M=JSON).stringify,[4,this.encryptionService.encrypt(u,U.toJSON(!0))];case 17:return K.sharedWrappedKey=O.apply(M,[j.sent()]),C=K,[4,this.encryptionService.encrypt(U,b)];case 18:return W=j.sent(),A=C,N=(T=JSON).stringify,[4,this.encryptionService.sign(L.jwk,W)];case 19:A.sharedCipherDataSig=N.apply(T,[j.sent()]),C.sigPxkId=L.id,I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherKey:U.toJSON(!0)}),j.label=20;case 20:return s?[4,this.keyFactory.createKey()]:[3,32];case 21:return F=j.sent(),[4,this.keyFactory.createKey()];case 22:return U=j.sent(),L=this.keyService.currentSigPxk,x={},J=(_=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,F.toJSON(!0))];case 23:return x.ownerWrappedKey=J.apply(_,[j.sent()]),x.ownerWrappingKeyId=o.id,s.plainOwnerCipherDataJson?(V=(G=JSON).stringify,[4,this.encryptionService.encrypt(F,s.plainOwnerCipherDataJson)]):[3,25];case 24:return q=V.apply(G,[j.sent()]),[3,26];case 25:q="",j.label=26;case 26:return x.ownerCipherData=q,Q=(B=JSON).stringify,[4,this.encryptionService.encrypt(u,U.toJSON(!0))];case 27:return x.sharedWrappedKey=Q.apply(B,[j.sent()]),$=x,[4,this.encryptionService.encrypt(U,s.plainSharedCipherDataJson)];case 28:return W=j.sent(),Z=$,Y=(H=JSON).stringify,[4,this.encryptionService.sign(L.jwk,W)];case 29:return Z.sharedCipherDataSig=Y.apply(H,[j.sent()]),$.sigPxkId=L.id,s.ownerPlainData?(z=$,ee=(X=JSON).stringify,[4,this.encryptionService.sign(m.jwk,s.ownerPlainData)]):[3,31];case 30:z.ownerPlainDataSig=ee.apply(X,[j.sent()]),j.label=31;case 31:I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{plainSharedCipherDataJson:s.plainSharedCipherDataJson}),j.label=32;case 32:return[4,this.encryptionService.encrypt(y,I)];case 33:return te=j.sent(),[4,this.encryptionService.encrypt(r.otKey,te)];case 34:return te=j.sent(),[4,this.lrApollo.mutate({mutation:Ks,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:o.id,masterKeyId:c.id,responderPxkId:v.id,responderSigPxkId:m.id,signedInitiatorPbk:JSON.stringify(g),signedInitiatorSigPbk:JSON.stringify(S),rkWrappedSharedKey:JSON.stringify(d),mkWrappedMkSharedKey:JSON.stringify(l),initiatorOneTimePbkCipher:JSON.stringify(te),initiatorContactCard:C,responderContactCard:$}}})];case 35:return[2,{keyExchange:(ne=j.sent().respondKeyExchangeOtk).keyExchange,userSharedKey:ne.userSharedKey,tp:ne.tp}]}}))}))},t.prototype.completeOtk=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b,w,K,k,P,E,D,R,M,O,A,T,N,$,F,U,L,x,_,J;return j(this,(function(j){switch(j.label){case 0:return i=this.keyService.currentRootKey,a=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(i.jwk,t)];case 1:return s=j.sent(),c=this.decryptResponseCipher,[4,ve.asKey(s.otKey)];case 2:return u=[j.sent()],[4,ve.asKey(s.oneTimePrk)];case 3:return[4,c.apply(this,u.concat([j.sent(),n]))];case 4:if(o=j.sent(),s.nonce!==o.nonce)throw new Z("The nonce returned by responder does not match with the one created by the initiator.");return p=this.keyService.currentSigPxk,[4,ve.asKey(o.responder.sigPbk)];case 5:return d=j.sent(),[4,ve.asKey(o.responder.pbk)];case 6:return l=j.sent(),[4,this.encryptionService.sign(p.jwk,l.toJSON())];case 7:return y=j.sent(),[4,this.encryptionService.sign(p.jwk,d.toJSON())];case 8:return h=j.sent(),[4,ve.asKey(o.sharedKey)];case 9:return f=j.sent(),[4,this.encryptionService.encrypt(i.jwk,f.toJSON(!0))];case 10:return v=j.sent(),[4,ve.asKey(o.mkSharedKey)];case 11:return m=j.sent(),[4,this.encryptionService.encrypt(a.jwk,m.toJSON(!0))];case 12:return g=j.sent(),r?[4,this.keyFactory.createKey()]:[3,16];case 13:return I=j.sent(),C={},w=(b=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,I.toJSON(!0))];case 14:return C.receiverWrappedKey=w.apply(b,[j.sent()]),C.receiverWrappingKeyId=i.id,k=(K=JSON).stringify,[4,this.encryptionService.encrypt(I,r)];case 15:C.receiverCipherData=k.apply(K,[j.sent()]),S=C,j.label=16;case 16:return s.initiatorContactCard?(D=s.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,25];case 17:return R=j.sent(),[4,ve.asKey(o.responder.contactCard.sharedCipherKey)];case 18:return M=j.sent(),T=(A=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,R.toJSON(!0))];case 19:return O=T.apply(A,[j.sent()]),D.plainOwnerCipherDataJson?(U=(F=JSON).stringify,[4,this.encryptionService.encrypt(R,D.plainOwnerCipherDataJson)]):[3,21];case 20:return $=U.apply(F,[j.sent()]),[3,22];case 21:$="",j.label=22;case 22:return N=$,P={ownerWrappedKey:O,ownerWrappingKeyId:i.id,ownerCipherData:N},E={sigPxkId:p.id},[4,this.encryptionService.encrypt(M,D.plainSharedCipherDataJson)];case 23:return L=j.sent(),x=E,J=(_=JSON).stringify,[4,this.encryptionService.sign(p.jwk,L)];case 24:x.sharedCipherDataSig=J.apply(_,[j.sent()]),j.label=25;case 25:return[4,this.lrApollo.mutate({mutation:ks,variables:{input:{keyExchangeId:e,rootKeyId:i.id,masterKeyId:a.id,initiatorSigPxkId:p.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(h),rkWrappedSharedKey:JSON.stringify(v),mkWrappedMkSharedKey:JSON.stringify(g),responderContactCardCipher:S,initiatorContactCardCipher:P,initiatorContactCardSharedCipher:E}}})];case 26:return[2,j.sent().completeKeyExchangeOtk]}}))}))},t.prototype.currentUserSharedKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Ss,variables:{username:e.username,userId:e.userId}})];case 1:return[2,t.sent().currentUserSharedKey.userSharedKey]}}))}))},t}();Ps.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ps(t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(Pe),t.ɵɵinject(he),t.ɵɵinject(e.Auth2Service))},token:Ps,providedIn:"root"}),Ps.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ps.ctorParameters=function(){return[{type:ve},{type:Ke},{type:Pe},{type:he},{type:e.Auth2Service}]};var Es,Ds,Rs,Ms,Os,As,js,Ts,Ns,$s,Fs,Us=je(Es||(Es=F(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n config\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"],["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n config\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"]))),Ls=je(Ds||(Ds=F(["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"],["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"]))),xs=je(Rs||(Rs=F(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"])),Us),_s=je(Ms||(Ms=F(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),Us),Js=je(Os||(Os=F(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),Us),qs=je(As||(As=F(["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"],["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"]))),Gs=je(js||(js=F(["\nmutation DeclineKeyExchangeMutation($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"],["\nmutation DeclineKeyExchangeMutation($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"]))),Vs=je(Ts||(Ts=F(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"])),Us),Bs=je(Ns||(Ns=F(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),Us,Ls),Qs=je($s||($s=F(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),Us,Ls),Ws=je(Fs||(Fs=F(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n","\n"],["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n","\n"])),Ls);e.KeyExchange2Service=function(e){function t(t,n,r,i,a,s){var o=e.call(this,n)||this;return o.ngZone=t,o.injector=n,o.keyFactory=r,o.keyService=i,o.encryptionService=a,o.keyGraph=s,o.CLIENT_NONCE_LENGTH=32,o}return R(t,e),t.prototype.getOtKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return t?[4,ve.asKey(Object.assign(Object.assign({},JSON.parse(e.otk.otKeyParams)),{k:t}))]:[3,2];case 1:return[2,i.sent()];case 2:return"OTK_INITIATED"!==e.otk.state||e.isInitiator||!e.otk.responderPbkCipher?[3,5]:(n=this.keyService.currentPxk,[4,this.encryptionService.decrypt(n.jwk,JSON.parse(e.otk.responderPbkCipher),{serializations:[ce.COMPACT]})]);case 3:return(r=i.sent()).otKey?[4,ve.asKey(r.otKey)]:[3,5];case 4:return[2,i.sent()];case 5:return[2,null]}}))}))},t.prototype.decryptOtk=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o;return j(this,(function(c){switch(c.label){case 0:return[4,this.getOtKey(e,t)];case 1:return n=c.sent(),r=e.otk,n&&r.otKeyCipher?(a=(i=Object).assign,s=[Object.assign({},r)],o={otKey:n},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:r=a.apply(i,s.concat([(o.otKeyCipherClearJson=c.sent(),o)])),c.label=3;case 3:return[2,Object.assign(Object.assign({},e),{otk:r})]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,n)];case 1:return n=i.sent(),[3,3];case 2:if("no key found"!==(r=i.sent()).message)throw r;return[3,3];case 3:return[4,this.encryptionService.decrypt(t,n)];case 4:return[2,i.sent()]}}))}))},t.prototype.decryptKeyExchangeAsInitiator=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return t=this.keyService.currentRootKey,[4,this.encryptionService.decrypt(t.jwk,e.initiatorRootKeyCipher)];case 1:return n=l.sent(),[4,ve.asKey(n.otKey)];case 2:return r=l.sent(),e=Object.assign(Object.assign({},e),{initiatorRootKeyCipherClearJson:n}),(i=e.otk).initiatorOneTimePbkCipher?(s=(a=Object).assign,o=[Object.assign({},i)],c={},u=this.decryptResponseCipher,p=[r],[4,ve.asKey(n.oneTimePrk)]):[3,5];case 3:return[4,u.apply(this,p.concat([l.sent(),i.initiatorOneTimePbkCipher]))];case 4:i=s.apply(a,o.concat([(c.initiatorOneTimePbkCipherClearJson=l.sent(),c)])),l.label=5;case 5:return i.otKeyCipher?(d=i,[4,this.encryptionService.decrypt(r,i.otKeyCipher)]):[3,7];case 6:d.otKeyCipherClearJson=l.sent(),l.label=7;case 7:return[2,Object.assign(Object.assign({},e),{otk:i})]}}))}))},t.prototype.decryptKeyExchangeAsResponder=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},t.prototype.decryptKeyExchange=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return e.isInitiator?[2,this.decryptKeyExchangeAsInitiator(e)]:[2,this.decryptKeyExchangeAsResponder(e,t)]}))}))},t.prototype.getKeyExchanges=function(e){var t=(void 0===e?{}:e).state;return A(this,void 0,void 0,(function(){var e,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,this.query({query:xs,variables:{state:t}})];case 1:return e=r.sent().keyExchanges,[2,Promise.all(e.edges.map((function(e){return n.decryptKeyExchange(e.node)})))]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.query({query:i?Js:_s,variables:{id:e,token:i},includeKeyGraph:!i})];case 1:return t=n.sent(),[2,this.decryptKeyExchange(t.keyExchange,r)]}}))}))},t.prototype.getCurrentUserSharedKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.query({query:Ws,variables:{username:e.username,userId:e.userId}})]}))}))},t.prototype.cancelKeyExchange=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.cancelKeyExchangeMutation(e)]}))}))},t.prototype.cancelKeyExchangeMutation=function(e){return new pt({mutation:qs,variables:{input:{id:e}}})},t.prototype.declineKeyExchangeExec=function(e,t){return this.mutate(this.declineKeyExchangeMutation(e,t))},t.prototype.declineKeyExchange=function(e,t){return this.declineKeyExchangeMutation(e,t)},t.prototype.declineKeyExchangeMutation=function(e,t){return new pt({mutation:Gs,variables:{input:{id:e,token:t}}})},t.prototype.initiateOtkExec=function(e){return void 0===e&&(e={}),A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t=this.mutate,[4,this.initiateOtkMutation(e)];case 1:return[2,t.apply(this,[n.sent().lrMutation])]}}))}))},t.prototype.initiateOtk=function(e){return void 0===e&&(e={}),this.initiateOtkMutation(e)},t.prototype.initiateOtkMutation=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return A(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,y,h,f,v;return j(this,(function(m){switch(m.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=m.sent(),t=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.keyFactory.createPkcKey()];case 2:return s=m.sent(),o=this.keyService.currentPxk,c=this.keyService.currentSigPxk,u=null,i&&i.ownerPlainDataJson?[4,this.encryptionService.signToString(c.jwk,i.ownerPlainDataJson)]:[3,4];case 3:u=m.sent(),m.label=4;case 4:return p={message:n,contactCard:i&&{sharedCipherDataClearJson:i.sharedCipherDataClearJson}},d={nonce:t,initiator:Object.assign(Object.assign({},p),{oneTimePbk:s.toJSON(),pbk:o.jwk.toJSON(),sigPbk:c.jwk.toJSON()})},[4,this.keyGraph.encryptToString(e,d)];case 5:return l=m.sent(),y={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},h=this.keyService.currentRootKey,[4,this.keyGraph.encryptToString(h.jwk,y)];case 6:return f=m.sent(),v=e.toJSON(!0).k,[2,{lrMutation:new pt({mutation:Vs,variables:{input:{initiatorRootKeyCipher:f,initiatorPxkId:o.id,initiatorSigPxkId:c.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:l,sendEmail:r&&{email:r,rawOtKey:v},createTp:!0,initiatorPlainDataSig:u,upgrade:a}}}),otKeyK:v}]}}))}))},t.prototype.respondOtkExec=function(e){return this.mutate(this.respondOtkMutation(e))},t.prototype.respondOtk=function(e){return this.respondOtkMutation(e)},t.prototype.respondOtkMutation=function(e){var t=e.keyExchangeId,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return A(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b,w,K,k,P,E,D,R,M,O,A,T,N,$,F,U,L,x,_,J,q,G,V,B,Q,W,Z,H,Y,z,X,ee;return j(this,(function(j){switch(j.label){case 0:return e=this.keyService.currentRootKey,o=this.keyService.currentMasterKey,[4,this.keyFactory.createKey()];case 1:return c=j.sent(),[4,this.keyFactory.createKey()];case 2:return u=j.sent(),[4,this.encryptionService.encrypt(e.jwk,c.toJSON(!0))];case 3:return p=j.sent(),[4,this.encryptionService.encrypt(o.jwk,u.toJSON(!0))];case 4:return d=j.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 5:return l=j.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 6:return y=j.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 7:return h=j.sent(),f=this.keyService.currentPxk,v=this.keyService.currentSigPxk,[4,this.encryptionService.sign(v.jwk,y.toJSON())];case 8:return m=j.sent(),[4,this.encryptionService.sign(v.jwk,h.toJSON())];case 9:return g=j.sent(),S={nonce:r.otKeyCipherClearJson.nonce,sharedKey:c.toJSON(!0),mkSharedKey:u.toJSON(!0),responder:{pbk:f.jwk.toJSON(),sigPbk:v.jwk.toJSON(),message:i}},r.otKeyCipherClearJson.initiator.contactCard?(C=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,19];case 10:return b=j.sent(),[4,this.keyFactory.createKey()];case 11:return F=j.sent(),U=this.keyService.currentSigPxk,w={},k=(K=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,b.toJSON(!0))];case 12:return w.receiverWrappedKey=k.apply(K,[j.sent()]),w.receiverWrappingKeyId=e.id,a?(D=(E=JSON).stringify,[4,this.encryptionService.encrypt(b,a.receiverCipherDataClearJson)]):[3,14];case 13:return P=D.apply(E,[j.sent()]),[3,15];case 14:P="",j.label=15;case 15:return w.receiverCipherData=P,M=(R=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 16:return w.sharedWrappedKey=M.apply(R,[j.sent()]),I=w,[4,this.encryptionService.encrypt(F,C)];case 17:return Q=j.sent(),O=I,T=(A=JSON).stringify,[4,this.encryptionService.sign(U.jwk,Q)];case 18:O.sharedCipherDataSig=T.apply(A,[j.sent()]),I.sigPxkId=U.id,S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherKey:F.toJSON(!0)}),j.label=19;case 19:return s?[4,this.keyFactory.createKey()]:[3,31];case 20:return $=j.sent(),[4,this.keyFactory.createKey()];case 21:return F=j.sent(),U=this.keyService.currentSigPxk,L={},_=(x=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,$.toJSON(!0))];case 22:return L.ownerWrappedKey=_.apply(x,[j.sent()]),L.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(G=(q=JSON).stringify,[4,this.encryptionService.encrypt($,s.ownerCipherDataClearJson)]):[3,24];case 23:return J=G.apply(q,[j.sent()]),[3,25];case 24:J="",j.label=25;case 25:return L.ownerCipherData=J,B=(V=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 26:return L.sharedWrappedKey=B.apply(V,[j.sent()]),N=L,[4,this.encryptionService.encrypt(F,s.sharedCipherDataClearJson)];case 27:return Q=j.sent(),W=N,H=(Z=JSON).stringify,[4,this.encryptionService.sign(U.jwk,Q)];case 28:return W.sharedCipherDataSig=H.apply(Z,[j.sent()]),N.sigPxkId=U.id,s.ownerPlainDataJson?(Y=N,X=(z=JSON).stringify,[4,this.encryptionService.sign(v.jwk,s.ownerPlainDataJson)]):[3,30];case 29:Y.ownerPlainDataSig=X.apply(z,[j.sent()]),j.label=30;case 30:S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),j.label=31;case 31:return[4,this.encryptionService.encrypt(l,S)];case 32:return ee=j.sent(),[4,this.encryptionService.encrypt(r.otKey,ee)];case 33:return ee=j.sent(),[2,new pt({mutation:Bs,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:e.id,masterKeyId:o.id,responderPxkId:f.id,responderSigPxkId:v.id,signedInitiatorPbk:JSON.stringify(m),signedInitiatorSigPbk:JSON.stringify(g),rkWrappedSharedKey:JSON.stringify(p),mkWrappedMkSharedKey:JSON.stringify(d),initiatorOneTimePbkCipher:JSON.stringify(ee),initiatorContactCard:I,responderContactCard:N}}})]}}))}))},t.prototype.completeOtkExec=function(e){return this.mutate(this.completeOtkMutation(e))},t.prototype.completeOtk=function(e){return this.completeOtkMutation(e)},t.prototype.completeOtkMutation=function(e){var t=e.keyExchangeId,n=e.initiatorRootKeyCipher,r=e.initiatorOneTimePbkCipher,i=e.responderContactCard,a=e.initiatorContactCard;return A(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b,w,K,k,P,E,D,R,M,O,A,T,N,$,F,U,L,x,_,J;return j(this,(function(j){switch(j.label){case 0:return e=this.keyService.currentRootKey,s=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(e.jwk,n)];case 1:return o=j.sent(),u=this.decryptResponseCipher,[4,ve.asKey(o.otKey)];case 2:return p=[j.sent()],[4,ve.asKey(o.oneTimePrk)];case 3:return[4,u.apply(this,p.concat([j.sent(),r]))];case 4:if(c=j.sent(),o.nonce!==c.nonce)throw new Z("The nonce returned by responder does not match with the one created by the initiator.");return d=this.keyService.currentSigPxk,[4,ve.asKey(c.responder.sigPbk)];case 5:return l=j.sent(),[4,ve.asKey(c.responder.pbk)];case 6:return y=j.sent(),[4,this.encryptionService.sign(d.jwk,y.toJSON())];case 7:return h=j.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 8:return f=j.sent(),[4,ve.asKey(c.sharedKey)];case 9:return v=j.sent(),[4,this.encryptionService.encrypt(e.jwk,v.toJSON(!0))];case 10:return m=j.sent(),[4,ve.asKey(c.mkSharedKey)];case 11:return g=j.sent(),[4,this.encryptionService.encrypt(s.jwk,g.toJSON(!0))];case 12:return S=j.sent(),i?[4,this.keyFactory.createKey()]:[3,16];case 13:return C=j.sent(),b={},K=(w=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,C.toJSON(!0))];case 14:return b.receiverWrappedKey=K.apply(w,[j.sent()]),b.receiverWrappingKeyId=e.id,P=(k=JSON).stringify,[4,this.encryptionService.encrypt(C,i.receiverCipherDataClearJson)];case 15:b.receiverCipherData=P.apply(k,[j.sent()]),I=b,j.label=16;case 16:return o.initiatorContactCard?(R=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,25];case 17:return M=j.sent(),[4,ve.asKey(c.responder.contactCard.sharedCipherKey)];case 18:return O=j.sent(),N=(T=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,M.toJSON(!0))];case 19:return A=N.apply(T,[j.sent()]),($=(null==a?void 0:a.ownerCipherDataClearJson)||R.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(M,$)]:[3,21];case 20:return U=j.sent(),[3,22];case 21:U="",j.label=22;case 22:return F=U,E={ownerWrappedKey:A,ownerWrappingKeyId:e.id,ownerCipherData:F},D={sigPxkId:d.id},[4,this.encryptionService.encrypt(O,R.sharedCipherDataClearJson)];case 23:return L=j.sent(),x=D,J=(_=JSON).stringify,[4,this.encryptionService.sign(d.jwk,L)];case 24:x.sharedCipherDataSig=J.apply(_,[j.sent()]),j.label=25;case 25:return[2,new pt({mutation:Qs,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(h),signedResponderSigPbk:JSON.stringify(f),rkWrappedSharedKey:JSON.stringify(m),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:I,initiatorContactCardCipher:E,initiatorContactCardSharedCipher:D}}})]}}))}))},t}(At),e.KeyExchange2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.KeyExchange2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(he),t.ɵɵinject(ke))},token:e.KeyExchange2Service,providedIn:"root"}),e.KeyExchange2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.KeyExchange2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ve},{type:Ke},{type:he},{type:ke}]},e.KeyExchange2Service=O([et({ngZoneName:"ngZone"})],e.KeyExchange2Service);var Zs="LBOP";(e.KcLbopErrorCode||(e.KcLbopErrorCode={})).INVALID_PASSPHRASE="INVALID_PASSPHRASE";var Hs,Ys,zs,Xs,eo,to=k.default(Hs||(Hs=F(["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"],["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"]))),no=k.default(Ys||(Ys=F(["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"]))),ro=k.default(zs||(zs=F(["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"],["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"]))),io=k.default(Xs||(Xs=F(["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"],["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"]))),ao=k.default(eo||(eo=F(["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"],["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"]))),so=function(){function t(e,t,n,r,i,a,s,o,c,u){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.auth2Service=i,this.keyFactory=a,this.keyService=s,this.encryptionService=o,this.keyGraph=c,this.passwordService=u,this.CLIENT_NONCE_LENGTH=32,this.LBOP_WORDS=25}return t.prototype.getPartial=function(e){return e.split(" ")[0]},t.prototype.remove=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:no,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteLbop.id]}}))}))},t.prototype.update=function(e){var t=e.id,n=e.name;return A(this,void 0,void 0,(function(){var e,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.get(t)];case 1:return(e=a.sent()).name=n,r=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(r.jwk,e)];case 2:return i=a.sent(),[4,this.lrApollo.mutate({mutation:ro,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 3:return[2,a.sent().updateLbop]}}))}))},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:io,variables:{id:e}})];case 1:return t=i.sent(),n=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(n.jwk,JSON.parse(t.lbop.cipherMeta))];case 2:return r=i.sent(),[2,Object.assign({id:t.id},r)]}}))}))},t.prototype.list=function(){return A(this,void 0,void 0,(function(){var e,t,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:ao})];case 1:return e=r.sent(),[4,this.keyService.currentMasterKey];case 2:return t=r.sent(),[2,Promise.all(e.lbops.edges.map((function(e){return A(n,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.encryptionService.decrypt(t.jwk,JSON.parse(e.node.cipherMeta))];case 1:return n=r.sent(),[2,Object.assign({id:e.node.id},n)]}}))}))})))]}}))}))},t.prototype.create=function(e){var t=e.name;return A(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g;return j(this,(function(S){switch(S.label){case 0:if(1024!==I.Slip39Helper.WORD_LIST.length)throw new G("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=S.sent(),r=function(){n=i.keyFactory.randomChoices(I.Slip39Helper.WORD_LIST,i.LBOP_WORDS).join(" ");var t=i.getPartial(n);if(!e.some((function(e){return e.partial===t})))return"break"},i=this;"break"!==r(););return[4,this.keyFactory.createLbopKeyParams()];case 2:return a=S.sent(),c=(o=this.keyFactory).deriveLbopKey,p=(u=Object).assign,d={},[4,this.keyFactory.importPassword(n)];case 3:return[4,c.apply(o,[p.apply(u,[(d.password=S.sent(),d),a])])];case 4:return s=S.sent().jwk,[4,this.keyFactory.createSignKey()];case 5:return l=S.sent(),[4,this.encryptionService.encrypt(s,l.toJSON(!0))];case 6:return y=S.sent(),h=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(s,h.jwk.toJSON(!0))];case 7:return f=S.sent(),v=Object.assign(Object.assign({},t&&{name:t}),{partial:this.getPartial(n)}),[4,this.encryptionService.encrypt(h.jwk,v)];case 8:return m=S.sent(),[4,this.lrApollo.mutate({mutation:to,variables:{input:{cipherMeta:JSON.stringify(m),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(l.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(y),masterKeyId:h.id,wrappedMasterKey:JSON.stringify(f)}}})];case 9:return g=S.sent(),[2,Object.assign(Object.assign({},g.createLbop.lbop),{lbopString:n})]}}))}))},t.prototype.verifyLbops=function(t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g;return j(this,(function(S){switch(S.label){case 0:r=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),S.label=1;case 1:S.trys.push([1,11,12,13]),i=T(t.lbops),a=i.next(),S.label=2;case 2:return a.done?[3,10]:(s=a.value,u=(c=this.keyFactory).deriveLbopKey,d=(p=Object).assign,l={},[4,this.keyFactory.importPassword(n)]);case 3:return[4,u.apply(c,[d.apply(p,[(l.password=S.sent(),l),s.lbopKeyParams])])];case 4:o=S.sent().jwk,S.label=5;case 5:return S.trys.push([5,8,,9]),[4,this.encryptionService.decrypt(o,s.wrappedLbopKeyVerifier)];case 6:return y=S.sent(),h=t.challenge.serverNonce,[4,this.encryptionService.sign(y,{serverNonce:h,clientNonce:r})];case 7:return f=S.sent(),[2,{lbop:s,signedChallenge:f,lbopKey:o}];case 8:return S.sent(),[3,9];case 9:return a=i.next(),[3,2];case 10:return[3,13];case 11:return v=S.sent(),m={error:v},[3,13];case 12:try{a&&!a.done&&(g=i.return)&&g.call(i)}finally{if(m)throw m.error}return[7];case 13:throw new _(new x({source:Zs,code:e.KcLbopErrorCode.INVALID_PASSPHRASE,message:"Invalid passphrase."}))}}))}))},t.prototype.verifyContact=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},t.prototype.confirmContact=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e.claimId,v_code:e.vCode}).toPromise()]}))}))},t.prototype.verify=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return[4,this.http.post(this.config.authUrl+"users/lbop-reset/get-challenge/",{claimId:e.claimId,claimToken:e.claimToken}).toPromise()];case 1:return t=p.sent(),[4,this.verifyLbops(t,e.lbop)];case 2:return n=p.sent(),r=n.signedChallenge,i=n.lbop,a=n.lbopKey,[4,this.http.post(this.config.authUrl+"users/lbop-reset/verify-challenge/",{lbopId:i.lbopId,signedChallenge:r}).toPromise()];case 3:return s=p.sent(),o={lbopId:i.lbopId,verifiedToken:s.verifiedToken,masterKeyId:s.masterKeyId},u=(c=ve).asKey,[4,this.encryptionService.decrypt(a,s.wrappedMasterKey)];case 4:return[4,u.apply(c,[p.sent()])];case 5:return[2,(o.masterKey=p.sent(),o)]}}))}))},t.prototype.setPassword=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.passwordService.createPassKeyBundle(e.newPassword)];case 1:return t=a.sent(),[4,this.encryptionService.encrypt(t.passKey,e.masterKey.toJSON(!0))];case 2:return n=a.sent(),[4,this.http.post(this.config.authUrl+"users/lbop-reset/set-password/",{lbopId:e.lbopId,verifiedToken:e.verifiedToken,masterKeyId:e.masterKeyId,newWrappedMasterKey:n,newPassKey:{passKeyParams:t.passKeyParams,passIdpParams:t.passIdpParams,passIdpVerifierPbk:t.passIdpVerifier.toJSON(),wrappedPassIdpVerifierPrk:t.wrappedPassIdpVerifierPrk}}).toPromise()];case 3:return r=a.sent(),[4,this.auth.signIn(r.username,r.idpPassword,{noProxy:"true"})];case 4:if("NEW_PASSWORD_REQUIRED"!==(i=a.sent()).challengeName)throw new z("Expecting Cognito to have done a password reset.");return[4,this.auth.completeNewPassword(i,this.passwordService.getPassIdpString(t.passIdp),{})];case 5:return i=a.sent(),[4,this.auth.signOut()];case 6:return a.sent(),[4,this.http.post(this.config.authUrl+"users/lbop-reset/complete/",{lbopId:e.lbopId,setPasswordToken:r.setPasswordToken}).toPromise()];case 7:return[2,a.sent()]}}))}))},t}();so.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new so(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(Pe),t.ɵɵinject(s.AuthClass),t.ɵɵinject(e.Auth2Service),t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(he),t.ɵɵinject(ke),t.ɵɵinject(Dr))},token:so,providedIn:"root"}),so.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],so.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:Pe},{type:s.AuthClass},{type:e.Auth2Service},{type:ve},{type:Ke},{type:he},{type:ke},{type:Dr}]};var oo=function(){function e(){}return e.forRoot=function(r){return{ngModule:e,providers:[{provide:me,useValue:r},{provide:s.AuthClass,useValue:E.default},{provide:t.APP_INITIALIZER,useFactory:$t,deps:[me,s.AuthClass],multi:!0},{provide:t.APP_INITIALIZER,useFactory:fi,deps:[vi],multi:!0},{provide:n.APOLLO_OPTIONS,useFactory:Ie,deps:[me,s.AuthClass]}]}},e}();oo.decorators=[{type:t.NgModule,args:[{imports:[f.HttpClientModule,S.NgIdleKeepaliveModule.forRoot()]}]}];var co,uo,po=je(co||(co=F(["\nmutation SendMessageMutation($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n}\n"],["\nmutation SendMessageMutation($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n}\n"]))),lo=je(uo||(uo=F(["\nquery MessageQuery($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n}\n"],["\nquery MessageQuery($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n}\n"])));e.MessageService=function(e){function t(t,n,r,i,a){var s=e.call(this,n)||this;return s.ngZone=t,s.injector=n,s.keyGraph=r,s.encryptionService=i,s.keyExchangeService=a,s.encrypt=s.encryptionService.encrypt.bind(s.encryptionService),s.decrypt=s.encryptionService.decrypt.bind(s.encryptionService),s.sign=s.encryptionService.sign.bind(s.encryptionService),s.verify=s.encryptionService.verify.bind(s.encryptionService),s}return R(t,e),t.prototype.sendMessage=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.sendMessageMutation(e))]}))}))},t.prototype.sendMessageMutation=function(e){var t=e.username,n=e.userId,r=e.plainMessageJson,i=e.plainCipherMessageJson;return A(this,void 0,void 0,(function(){var e,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return[4,this.keyExchangeService.currentUserSharedKey({username:t,userId:n})];case 1:return e=l.sent(),i?[4,this.keyGraph.getJwkKey(e.sharedKey.id)]:[3,6];case 2:return s=l.sent(),[4,this.encrypt(s,i)];case 3:return o=l.sent(),[4,this.keyGraph.getJwkKey(e.userSigPrk.id)];case 4:return c=l.sent(),p=(u=JSON).stringify,[4,this.sign(c,o)];case 5:a=p.apply(u,[l.sent()]),l.label=6;case 6:return r&&(d=JSON.stringify(r)),[2,new pt({mutation:po,variables:{input:{receiverUsername:t,receiverId:n,sharedKeyId:e.sharedKey.id,senderSigPbkId:e.userSigPrk.id,signedCipherMessage:a,plainMessage:d}}})]}}))}))},t.prototype.decryptMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.verify(t.senderSigPbk,JSON.parse(e.signedCipherMessage))];case 1:return n=i.sent(),r=e,[4,this.decrypt(t.sharedKey,n)];case 2:return r.signedCipherMessageClearJson=i.sent(),[2]}}))}))},t.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.query({query:lo,variables:{id:e}})];case 1:return t=a.sent(),n=t.message,[4,this.keyGraph.getJwkKey(n.sharedKey.id)];case 2:return r=a.sent(),[4,this.keyGraph.getJwkKey(n.senderSigPbk.id)];case 3:return i=a.sent(),[4,this.decryptMessage(n,{sharedKey:r,senderSigPbk:i})];case 4:return a.sent(),n.plainMessage&&(n.plainMessageJson=JSON.parse(n.plainMessage)),[2,t.message]}}))}))},t}(At),e.MessageService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.MessageService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ke),t.ɵɵinject(he),t.ɵɵinject(Ps))},token:e.MessageService,providedIn:"root"}),e.MessageService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.MessageService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ke},{type:he},{type:Ps}]},e.MessageService=O([et({ngZoneName:"ngZone"})],e.MessageService);var yo,ho,fo,vo,mo,go=je(yo||(yo=F(["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"],["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"]))),So=je(ho||(ho=F(["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"],["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"]))),Io=je(fo||(fo=F(["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"],["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"]))),Co=je(vo||(vo=F(["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"],["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"]))),bo=je(mo||(mo=F(["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"],["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"])));e.NotificationService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.updateNotification=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.updateNotificationMutation(e))]}))}))},t.prototype.updateNotificationMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:go,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.updateAllNotificationsReadState=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.updateAllNotificationsReadStateMutation(e))]}))}))},t.prototype.updateAllNotificationsReadStateMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:So,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.debugCreateNotification=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.debugCreateNotificationMutation(e))]}))}))},t.prototype.debugCreateNotificationMutation=function(e){var t;return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,new pt({mutation:Io,variables:{input:{receiverId:e.receiverId,hasBeenRead:e.hasBeenRead,timeRead:null===(t=e.timeRead)||void 0===t?void 0:t.toISOString(),plainData:JSON.stringify(e.plainData),plainMeta:JSON.stringify(e.plainMeta)}}})]}))}))},t.prototype.debugDeleteAllNotifications=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.debugDeleteAllNotificationsMutation(e))]}))}))},t.prototype.debugDeleteAllNotificationsMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:Co,variables:{input:{receiverId:e.receiverId}}})]}))}))},t.prototype.updateNotificationFeatureState=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.updateNotificationFeatureStateMutation(e))]}))}))},t.prototype.updateNotificationFeatureStateMutation=function(e){var t;return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,new pt({mutation:bo,variables:{input:{lastViewed:null===(t=e.lastViewed)||void 0===t?void 0:t.toISOString(),clearLastViewed:null==e.lastViewed||void 0}}})]}))}))},t}(At),e.NotificationService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.NotificationService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.NotificationService,providedIn:"root"}),e.NotificationService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.NotificationService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.NotificationService=O([et({ngZoneName:"ngZone"})],e.NotificationService);var wo,Ko,ko,Po,Eo,Do,Ro,Mo,Oo,Ao=function(){},jo=function(){},To=function(){},No=function(){},$o=function(){},Fo=je(wo||(wo=F(["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"],["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"]))),Uo=je(Ko||(Ko=F(["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"],["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"]))),Lo=je(ko||(ko=F(["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"],["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"]))),xo=je(Po||(Po=F(["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"],["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"]))),_o=je(Eo||(Eo=F(["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"],["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"]))),Jo=je(Do||(Do=F(["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"]))),qo=je(Ro||(Ro=F(["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"],["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"]))),Go=je(Mo||(Mo=F(["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"]))),Vo=je(Oo||(Oo=F(["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"])));e.Plan2Service=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.initiateStripePaymentMethodCapture=function(){return this.mutate(this.initiateStripePaymentMethodCaptureMutation())},t.prototype.initiateStripePaymentMethodCaptureMutation=function(){return new pt({mutation:Fo,variables:{input:{}}})},t.prototype.completeStripePaymentMethodCapture=function(e){return this.mutate(this.completeStripePaymentMethodCaptureMutation(e))},t.prototype.completeStripePaymentMethodCaptureMutation=function(e){return new pt({mutation:Uo,variables:{input:{stripeIntentId:e}}})},t.prototype.setDefaultPaymentMethod=function(e){return this.mutate(this.setDefaultPaymentMethodMutation(e))},t.prototype.setDefaultPaymentMethodMutation=function(e){return new pt({mutation:xo,variables:{input:{paymentMethodId:e}}})},t.prototype.removeDefaultPaymentMethod=function(){return this.mutate(this.removeDefaultPaymentMethodMutation())},t.prototype.removeDefaultPaymentMethodMutation=function(){return new pt({mutation:_o,variables:{input:{}}})},t.prototype.issuePlan=function(e){return this.mutate(this.issuePlanMutation(e))},t.prototype.issuePlanMutation=function(e){return new pt({mutation:Jo,variables:{input:e}})},t.prototype.removePaymentMethod=function(e){return this.mutate(this.removePaymentMethodMutation(e))},t.prototype.removePaymentMethodMutation=function(e){return new pt({mutation:Lo,variables:{input:{paymentMethodId:e}}})},t.prototype.cancelPlan=function(e){return this.mutate(this.cancelPlanMutation(e))},t.prototype.cancelPlanMutation=function(e){return new pt({mutation:qo,variables:{input:e}})},t.prototype.changePriceOption=function(e){return this.mutate(this.changePriceOptionMutation(e))},t.prototype.changePriceOptionMutation=function(e){return new pt({mutation:Go,variables:{input:e}})},t.prototype.reactivatePlan=function(e){return this.mutate(this.reactivatePlanMutation(e))},t.prototype.reactivatePlanMutation=function(e){return new pt({mutation:Vo,variables:{input:{planId:e}}})},t}(At),e.Plan2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.Plan2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.Plan2Service,providedIn:"root"}),e.Plan2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.Plan2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.Plan2Service=O([et({ngZoneName:"ngZone"})],e.Plan2Service);var Bo,Qo="\n id\n owner {\n id\n username\n }\n ownerKey {\n id\n }\n ownerCipherData\n receiver {\n id\n username\n }\n receiverKey {\n id\n }\n receiverCipherData\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherDataSig\n sharedCipherDataSigPxk {\n id\n }\n",Wo=k.default(Bo||(Bo=F(["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ","\n }\n }\n}"],["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ","\n }\n }\n}"])),Qo),Zo=function(){function e(e,t,n,r){this.keyService=e,this.lrApollo=t,this.keyGraph=n,this.encryptionService=r}return e.prototype.decryptSharedTrustedPartyDetails=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.decryptTrustedPartyDetails(e)];case 1:return t=n.sent(),[2,Object.assign({id:e.id,ownedKeyId:e.ownerKey.id,sharedKeyId:e.sharedKey.id},t)]}}))}))},e.prototype.decryptTrustedPartyDetails=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:if(!(e&&e.sharedKey&&e.sharedCipherData))return[3,5];i.label=1;case 1:return i.trys.push([1,4,,5]),n=(t=this.encryptionService).decrypt,[4,this.keyGraph.getJwkKey(e.sharedKey.id)];case 2:return[4,n.apply(t,[i.sent(),e.sharedCipherData])];case 3:return[2,i.sent()];case 4:return r=i.sent(),console.error("Cannot decrypt trusted party details",r),[3,5];case 5:return[2,null]}}))}))},e.prototype.updateMySharedContactCard=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h;return j(this,(function(f){switch(f.label){case 0:return[4,this.keyGraph.getKey(t)];case 1:return i=f.sent(),[4,this.keyGraph.getKey(n)];case 2:return a=f.sent(),s=this.keyService.currentSigPxk,[4,this.encryptionService.encrypt(a.jwk,r)];case 3:return o=f.sent(),p=(u=JSON).stringify,[4,this.encryptionService.sign(s.jwk,o)];case 4:return c=p.apply(u,[f.sent()]),d={name:new dr(r.name)},h=(y=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 5:return l=h.apply(y,[f.sent()]),[4,this.lrApollo.mutate({mutation:Wo,variables:{input:{id:e,ownerCipherData:"",ownerKeyId:i.id,sharedCipherDataSig:c,sharedKeyId:a.id,sigPxkId:s.id,ownerPlainDataSig:l}}})];case 6:return f.sent(),[2]}}))}))},e}();Zo.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Zo(t.ɵɵinject(Ke),t.ɵɵinject(Pe),t.ɵɵinject(ke),t.ɵɵinject(he))},token:Zo,providedIn:"root"}),Zo.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Zo.ctorParameters=function(){return[{type:Ke},{type:Pe},{type:ke},{type:he}]};var Ho,Yo,zo,Xo=k.default(Ho||(Ho=F(["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"],["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"]))),ec=k.default(Yo||(Yo=F(["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"],["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"]))),tc=k.default(zo||(zo=F(["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"],["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"]))),nc=function(){function e(e){this.lrApollo=e}return e.prototype.requestUserDelete=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:Xo,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:ec,variables:{input:{}}})];case 1:return[2,e.sent().cancelUserDelete.id]}}))}))},e.prototype.loginHistory=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=null),A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:tc,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();nc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new nc(t.ɵɵinject(Pe))},token:nc,providedIn:"root"}),nc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],nc.ctorParameters=function(){return[{type:Pe}]};var rc,ic,ac,sc,oc,cc,uc,pc,dc,lc,yc,hc="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+Qo+"\n }\n myContactCard {\n "+Qo+"\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n theirItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n "+ms+"\n }\n "+gs+"\n }\n }",fc=k.default(rc||(rc=F(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"],["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"])),hc,Ge),vc=k.default(ic||(ic=F(["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),hc,ms,ms,Ge),mc=k.default(ac||(ac=F(["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"],["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"])),hc,Ge),gc=k.default(sc||(sc=F(["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Sc=k.default(oc||(oc=F(["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Ic=k.default(cc||(cc=F(["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"]))),Cc=k.default(uc||(uc=F(["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"]))),bc=k.default(pc||(pc=F(["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"])));!function(e){e.General="general",e.Scenario="scenario"}(dc||(dc={})),function(e){e.User="user",e.Organisation="organisation"}(lc||(lc={})),function(e){e.Invited="IN_PROGRESS",e.Cancelled="CANCELLED",e.Declined="DECLINED",e.Completed="COMPLETED"}(yc||(yc={}));!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}R(t,e)}(gr);var wc,Kc=function(){function e(e,t,n,r,i,a,s,o,c,u){this.http=e,this.lrApollo=t,this.sharedContactCardService=n,this.userService=r,this.authService=i,this.keyExchangeService=a,this.keyGraphService=s,this.keyService=o,this.keyFactory=c,this.encryptionService=u}return e.prototype.getTrustedParties=function(){return A(this,void 0,void 0,(function(){var e,t=this;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:fc})];case 1:return e=n.sent().tps,[4,Promise.all(e.edges.map((function(e){return t.mapTrustedParty(e.node)})))];case 2:return[2,n.sent()]}}))}))},e.prototype.getAllTrustedParties=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i,a,s=this;return j(this,(function(o){switch(o.label){case 0:return[4,this.authService.getUser()];case 1:return e=o.sent(),[4,this.lrApollo.query({query:vc,variables:{userId:e.id,isExpired:!1}})];case 2:return t=o.sent(),n=t.tps,r=t.invites,i=t.sentInvites,a={},[4,Promise.all(n.edges.map((function(e){return s.mapTrustedParty(e.node)})))];case 3:return a.parties=o.sent().filter((function(e){return e})),[4,Promise.all(r.edges.map((function(e){return A(s,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 4:return a.invites=o.sent().filter((function(e){return e.status!==yc.Completed})).filter((function(e){return e.status!==yc.Invited||e.actionRequired})),[4,Promise.all(i.edges.map((function(e){return A(s,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 5:return[2,(a.sentInvites=o.sent().filter((function(e){return e.status!==yc.Completed})),a)]}}))}))},e.prototype.getTrustedParty=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:mc,variables:{partyId:e}})];case 1:return t=n.sent().tp,[4,this.mapTrustedParty(t)];case 2:return[2,n.sent()]}}))}))},e.prototype.getTrustedPartyRoles=function(e){return void 0===e&&(e=dc.General),A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return this.trustedPartyRoles?[3,2]:(t=this,[4,this.http.get("/assets/meta/trusted-party-roles.json").toPromise()]);case 1:t.trustedPartyRoles=n.sent(),n.label=2;case 2:return[2,Promise.resolve(this.trustedPartyRoles.filter((function(t){return t.roleType===e})))]}}))}))},e.prototype.inviteTrustedParty=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t={responderUsername:e.party.username,email:e.party.email,message:{name:e.party.name,email:e.party.email,message:e.party.message,permissions:e.permissions},contactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new dr(e.mySharedDetails.name)}}},[4,this.keyExchangeService.initiateOtk(t)];case 1:return n.sent(),[2]}}))}))},e.prototype.cancelInvitation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Sc,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},e.prototype.getInvitation=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyExchangeService.getKeyExchange(e,{token:t,otKeyK:n})];case 1:return r=i.sent(),[2,this.mapInvite(r)]}}))}))},e.prototype.acceptInvitation=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t={id:e.inviteId,token:e.inviteToken,decryptedOtk:e.decryptedOtk,initiatorContactCard:null,responderContactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new dr(e.mySharedDetails.name)}}},[4,this.keyExchangeService.respondOtk(t)];case 1:return[2,n.sent().tp.id]}}))}))},e.prototype.declineInvitation=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:gc,variables:{input:{id:e,token:t}}})];case 1:return n.sent(),[2]}}))}))},e.prototype.confirmInvitation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.keyExchangeService.completeOtk(e.inviteId,e.initiatorRootKeyCipher,e.initiatorOneTimePbkCipher,null)];case 1:return[2,t.sent().tp.id]}}))}))},e.prototype.removeTrustedParty=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ic,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},e.prototype.setCategoryAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},e.prototype.setRecordAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},e.prototype.shareDirectory=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.keyGraphService.getKey(t)];case 1:return i=o.sent(),[4,this.keyGraphService.getKey(n.userSharedKey.sharedKey.id)];case 2:return a=o.sent(),[4,this.encryptionService.encrypt(a.jwk,i.jwk.toJSON(!0))];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:Cc,variables:{input:{id:e,tpId:n.id,accessRole:r,keyId:i.id,wrappingKeyId:a.id,wrappedKey:JSON.stringify(s)}}})];case 4:return o.sent(),[2]}}))}))},e.prototype.unshareDirectory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:bc,variables:{input:{id:e,tpId:t}}})];case 1:return n.sent(),[2]}}))}))},e.prototype.mapTrustedParty=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),(r=e.sharedContactCard)?[4,this.sharedContactCardService.decryptTrustedPartyDetails(e.sharedContactCard)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return n=r,(a=e.myContactCard)?[4,this.sharedContactCardService.decryptSharedTrustedPartyDetails(e.myContactCard)]:[3,4];case 3:a=o.sent(),o.label=4;case 4:return i=a,[2,{id:e.id,type:lc.User,hasScenarios:!!e.sharedScenarios.edges.length,hasSharedVault:!!e.theirItems.directories.edges.length,name:n&&n.name&&n.name.name,details:n,mySharedDetails:i,userSharedKey:e.currentUserSharedKey.userSharedKey,username:e.other.username,features:{sharedVault:{hasAccess:"access"===((null===(t=e.other.features)||void 0===t?void 0:t.shareVault)||["noaccess"])[0]}}}];case 5:return s=o.sent(),console.error("Failed to decrypt Trusted Party.",s,e),[2,null];case 6:return[2]}}))}))},e.prototype.mapInvite=function(e){var t,n;return A(this,void 0,void 0,(function(){var r,i,a;return j(this,(function(s){return r=e.contactCard,i=e.isInitiator?null===(t=e.myMessage)||void 0===t?void 0:t.name:r&&r.name&&r.name.name,a=e.isInitiator?null===(n=e.myMessage)||void 0===n?void 0:n.email:r&&r.email||e.responderEmailAddress,[2,{id:e.id,type:lc.User,status:e.state,token:e.token,tokenExpiry:e.tokenExpiryTime,decryptedOtk:e.decryptedOtk,name:i,email:a,isSender:e.isInitiator,actionRequired:e.isInitiator?e.initiatorActionRequired:e.responderActionRequired,rootKeyCipher:e.initiatorRootKeyCipher,pbkCipher:e.otk.initiatorOneTimePbkCipher,isExpired:e.isExpired,details:r,message:e.message,mySharedDetails:e.myContactCard,mySharedMessage:e.myMessage}]}))}))},e}();Kc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Kc(t.ɵɵinject(f.HttpClient),t.ɵɵinject(Pe),t.ɵɵinject(Zo),t.ɵɵinject(nc),t.ɵɵinject(vi),t.ɵɵinject(Ps),t.ɵɵinject(ke),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(he))},token:Kc,providedIn:"root"}),Kc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Kc.ctorParameters=function(){return[{type:f.HttpClient},{type:Pe},{type:Zo},{type:nc},{type:vi},{type:Ps},{type:ke},{type:Ke},{type:ve},{type:he}]},function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(wc||(wc={}));var kc=[wc.Name,wc.Email,wc.Image,wc.Phone,wc.Address],Pc=function(){function e(e,t,n,r){this.sharedContactCardService=e,this.trustedPartyService=t,this.profileService=n,this.authService=r}return e.prototype.updateDetails=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.authService.getUser()];case 1:return t=n.sent(),[4,this.profileService.updateDetails(t.contactCard.id,t.contactCard.keyId,e)];case 2:return n.sent(),[4,this.synchronizeContactCards(e,t.contactCard)];case 3:return n.sent(),[4,this.authService.getUser(!0)];case 4:return[2,n.sent()]}}))}))},e.prototype.synchronizeContactCards=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.trustedPartyService.getTrustedParties()]:[2];case 1:if(0===(r=p.sent()).length)return[2];p.label=2;case 2:p.trys.push([2,7,8,9]),i=T(r.map((function(e){return e.mySharedDetails}))),a=i.next(),p.label=3;case 3:return a.done?[3,6]:(s=a.value,[4,this.synchronizeSharedContactCard(s,n)]);case 4:p.sent(),p.label=5;case 5:return a=i.next(),[3,3];case 6:return[3,9];case 7:return o=p.sent(),c={error:o},[3,9];case 8:try{a&&!a.done&&(u=i.return)&&u.call(i)}finally{if(c)throw c.error}return[7];case 9:return[2]}}))}))},e.prototype.getChanges=function(e,t){var n,r,i,a,s,o=[];try{for(var c=T(kc),u=c.next();!u.done;u=c.next()){var p=u.value,d=t[p];if(d&&d.values){var l=function(t){var n=null===(s=e[p].values)||void 0===s?void 0:s.find((function(e){return e.id===t.id}));n?K.default.isEqual(n.value,t.value)||o.push({field:p,id:t.id,label:t.label,oldValue:t.value,newValue:n.value}):o.push({field:p,id:t.id,label:t.label,oldValue:t.value})};try{for(var y=(i=void 0,T(d.values)),h=y.next();!h.done;h=y.next()){l(h.value)}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=y.return)&&a.call(y)}finally{if(i)throw i.error}}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return o},e.prototype.synchronizeSharedContactCard=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return j(this,(function(y){switch(y.label){case 0:n=!1,r=function(t){switch(t.field){case wc.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case wc.Address:(r=e.addresses&&e.addresses.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;default:var r=e[t.field];K.default.isEqual(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=T(t),a=i.next();!a.done;a=i.next())s=a.value,r(s)}catch(e){d={error:e}}finally{try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(d)throw d.error}}return n?(o=e.id,c=e.ownedKeyId,u=e.sharedKeyId,p=M(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},e.prototype.updateTrustedPartyDetails=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=M(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(t,n,r,i)];case 1:return a.sent(),[4,this.synchronizeSharedDetails(e)];case 2:return a.sent(),[2]}}))}))},e.prototype.synchronizeSharedDetails=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y;return j(this,(function(h){switch(h.label){case 0:return[4,this.authService.getUser()];case 1:if(t=h.sent().contactCard,n=!1,t=Object.assign({},t),e.name&&(u=this.checkField(e.name,t.name))&&(t.name=u,n=!0),e.email&&(u=this.checkField(e.email,t.email))&&(t.email=u,n=!0),e.image&&(u=this.checkField(e.image,t.image))&&(t.image=u,n=!0),e.phones&&e.phones.length)try{for(r=T(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,t.phone,a.label))&&(t.phone=u,n=!0)}catch(e){p={error:e}}finally{try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(p)throw p.error}}if(e.addresses&&e.addresses.length)try{for(s=T(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,t.address,c.label))&&(t.address=u,n=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(y=s.return)&&y.call(s)}finally{if(l)throw l.error}}return n?[4,this.profileService.updateDetails(t.id,t.keyId,t)]:[3,3];case 2:h.sent(),h.label=3;case 3:return[2]}}))}))},e.prototype.checkField=function(e,t,n){return void 0===n&&(n=null),(t=t||{value:e,hasMultiple:!1}).values=t.values||[],0===t.values.length||t.values.every((function(t){return!K.default.isEqual(e,t.value)}))?(t.values.push({id:n+"-"+(new Date).getTime(),label:n,value:e}),t.hasMultiple=t.values.length>1,t.value=t.value||e,t):null},e}();Pc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Pc(t.ɵɵinject(Zo),t.ɵɵinject(Kc),t.ɵɵinject(Sr),t.ɵɵinject(vi))},token:Pc,providedIn:"root"}),Pc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Pc.ctorParameters=function(){return[{type:Zo},{type:Kc},{type:Sr},{type:vi}]};var Ec,Dc=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0},Rc=Dc,Mc=function(){function e(e){this.http=e}return e.prototype.getRecordTypes=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i=this;return j(this,(function(a){switch(a.label){case 0:return this.recordTypes?[3,2]:(e=this,[4,this.http.get("/assets/meta/record-types.json").toPromise()]);case 1:e.recordTypes=a.sent(),a.label=2;case 2:return this.categories?[3,4]:(t=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 3:t.categories=a.sent(),a.label=4;case 4:return n=this.categories.map((function(e){return e.subCategories})).reduce((function(e,t){return $(e,t)}),[]),r=this.recordTypes.map((function(e){return Object.assign(Object.assign({},e),{categoryNames:e.categories.map((function(e){return e.map((function(e){var t=n.find((function(t){return t.code===e}));return t?t.name:i.categories.find((function(t){return t.code===e})).name}))}))})})),[2,Promise.resolve(r)]}}))}))},e.prototype.getRecordType=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().find((function(t){return t.id===e}))]}}))}))},e.prototype.getRecordTypesForCategory=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().filter((function(t){return t.categories.some((function(t){return Dc(t,e)}))}))]}}))}))},e}();Mc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Mc(t.ɵɵinject(f.HttpClient))},token:Mc,providedIn:"root"}),Mc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Mc.ctorParameters=function(){return[{type:f.HttpClient}]},(Ec=e.RecordFieldType||(e.RecordFieldType={})).Text="text",Ec.Email="email",Ec.Url="url",Ec.Phone="phone",Ec.Date="date",Ec.Password="password",Ec.TextArea="textArea",Ec.Select="select",Ec.SingleChoice="singleChoice",Ec.MultiChoice="multiChoice",Ec.File="file",Ec.MultiFile="multiFile",Ec.Record="record",Ec.MultiRecord="multiRecord",Ec.Group="group",Ec.Custom="custom";var Oc=function(){},Ac=function(){},jc=function(){},Tc=function(){},Nc=function(){function t(e,t,n,r){this.fileUploadService=e,this.lrApollo=t,this.keyMetaService=n,this.keyGraph=r}return t.prototype.downloadAttachment=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.fileUploadService.downloadEncryptedFile(e)];case 1:return n=r.sent(),[4,this.keyGraph.decryptFile(t,n)];case 2:return[2,r.sent()]}}))}))},t.prototype.uploadAttachments=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){switch(r.label){case 0:return[4,Promise.all((t||[]).map((function(t){return A(n,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return t.fileId?t.isDeleted?[4,this.deleteAttachment(t.fileId)]:[3,2]:[3,4];case 1:return n.sent(),[2,null];case 2:return[2,t.fileId];case 3:return[3,6];case 4:return[4,this.addAttachment(e,t)];case 5:return[2,n.sent()];case 6:return[2]}}))}))})))];case 1:return[2,r.sent().filter((function(e){return e}))]}}))}))},t.prototype.addAttachment=function(t,n){return A(this,void 0,void 0,(function(){var r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return r={name:n.name,fieldId:n.fieldId,fileType:n.file.type,fileSize:n.file.size,lastModified:n.file.lastModified},[4,this.fileUploadService.loadFile(n.file)];case 1:return i=o.sent(),[4,this.keyMetaService.doubleWrapContent(r,[t],i)];case 2:return a=o.sent(),[4,this.fileUploadService.uploadEncryptedFile({encryptedContent:a.cipherFileContent,fileName:n.name})];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:Gi,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordAttachment}),wrappedStateKey:a.doubleWrappedKey,cipherMeta:a.cipherMeta,parentDirectories:a.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}})),contentResource:s}}})];case 4:return[2,o.sent().createFile.file.id]}}))}))},t.prototype.deleteAttachment=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Vi,variables:{fileId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Nc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Nc(t.ɵɵinject(ya),t.ɵɵinject(Pe),t.ɵɵinject(On),t.ɵɵinject(ke))},token:Nc,providedIn:"root"}),Nc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Nc.ctorParameters=function(){return[{type:ya},{type:Pe},{type:On},{type:ke}]};var $c=function(){function t(e,t,n,r){this.lrApollo=e,this.keyMetaService=t,this.categoryService=n,this.recordAttachmentService=r}return t.prototype.getRecord=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p=this;return j(this,(function(d){switch(d.label){case 0:return[4,this.lrApollo.query({query:Ui(),variables:{id:e,categoryFilter:ln,contentFilter:$i,attachmentsFilter:Fi}})];case 1:return n=d.sent().record,r=n.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(r.currentVersion.state)];case 2:return i=d.sent()||{},a=i.name,s=i.recordType,o=i.fields,[4,Promise.all(n.parentCategories.edges.map((function(e){return A(p,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.categoryService.mapParentCategories(e.node.parentDirectory)];case 1:return t=[n.sent()],[4,this.categoryService.mapCategory(e.node.parentDirectory)];case 2:return[2,$.apply(void 0,t.concat([[n.sent()]]))]}}))}))})))];case 3:return c=d.sent(),[4,this.mapAttachments(n.attachments.edges)];case 4:return u=d.sent(),[2,{id:n.id,keyId:n.keyId,updateKeyId:r.keyId,updateId:r.id,name:a,recordType:s,fields:o,categories:c,attachments:u,isArchived:!!n.archived,isConfidential:!!(null===(t=n.confidentiality)||void 0===t?void 0:t.isConfidential),createdOn:n.created,lastModified:new Date(n.modified)>new Date(r.currentVersion.state.modified)?n.modified:r.currentVersion.state.modified}]}}))}))},t.prototype.mapAttachments=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return e.node.childFile})).map((function(e){return A(t,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.keyMetaService.decryptMeta(e.currentVersion.state)];case 1:return t=o.sent()||{},n=t.name,r=t.fieldId,i=t.fileType,a=t.fileSize,s=t.lastModified,[2,{fileId:e.id,keyId:e.currentVersion.state.keyId,contentId:e.currentVersion.state.id,fieldId:r,name:n,fileType:i,fileSize:a,lastModified:s}]}}))}))})))];case 1:return[2,n.sent()]}}))}))},t.prototype.createRecord=function(t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o;return j(this,(function(c){switch(c.label){case 0:return[4,this.keyMetaService.wrapContent(null,t.categoryIds)];case 1:return n=c.sent(),[4,this.lrApollo.mutate({mutation:Li,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Record,isHidden:!1}),parentDirectories:n.wrappedKeys,parentRootDirectory:n.rootKey}})];case 2:return r=c.sent(),i=r.new.category.id,a={name:t.name,recordType:t.recordType,fields:t.fields},[4,this.keyMetaService.doubleWrapContent(a,[i])];case 3:return s=c.sent(),[4,this.lrApollo.mutate({mutation:xi,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta,parentDirectories:s.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}}))}}})];case 4:c.sent(),c.label=5;case 5:return c.trys.push([5,7,,8]),[4,this.recordAttachmentService.uploadAttachments(i,t.attachments)];case 6:return c.sent(),[3,8];case 7:return o=c.sent(),console.error(o),[2,{recordId:i,attachmentError:o}];case 8:return[2,{recordId:i}]}}))}))},t.prototype.updateRecord=function(t,n,r,i){return A(this,void 0,void 0,(function(){var a,s,o;return j(this,(function(c){switch(c.label){case 0:return a={name:i.name,recordType:i.recordType,fields:i.fields},[4,this.keyMetaService.reWrapContent(r,a)];case 1:return s=c.sent(),[4,this.lrApollo.mutate({mutation:Ji,variables:{input:{fileId:n,plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta}}})];case 2:c.sent(),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,this.recordAttachmentService.uploadAttachments(t,i.attachments)];case 4:return c.sent(),[3,6];case 5:return o=c.sent(),console.error(o),[2,{recordId:t,attachmentError:o}];case 6:return[2,{recordId:t}]}}))}))},t.prototype.archiveRecord=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.categoryService.archiveDirectory(e,!0)]}))}))},t.prototype.unarchiveRecord=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.categoryService.unarchiveDirectory(e,!0)]}))}))},t.prototype.deleteRecord=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:qi,variables:{recordId:e}})];case 1:return t.sent(),[2]}}))}))},t}();$c.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new $c(t.ɵɵinject(Pe),t.ɵɵinject(On),t.ɵɵinject(Bi),t.ɵɵinject(Nc))},token:$c,providedIn:"root"}),$c.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],$c.ctorParameters=function(){return[{type:Pe},{type:On},{type:Bi},{type:Nc}]};var Fc=function(){},Uc=function(){},Lc=function(){},xc=function(){},_c=function(){},Jc=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),t}(xc),qc=function(){},Gc=function(){function e(e,t,n,r,i,a){this.config=e,this.auth=t,this.http=n,this.keyFactory=r,this.encryptionService=i,this.passwordService=a}return e.prototype.verifyEmail=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/claim/email/",{address:e,context:"signup"}).toPromise()];case 1:return[2,t.sent().claim_id]}}))}))},e.prototype.verifyPhone=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/claim/sms/",{address:e,context:"signup"}).toPromise()];case 1:return[2,t.sent().claim_id]}}))}))},e.prototype.confirmVerificationCode=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},e.prototype.register=function(e,t,n,r,i){return void 0===i&&(i="email"),A(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,y,h,f,v,m;return j(this,(function(g){switch(g.label){case 0:return[4,this.passwordService.createPassKeyBundle(t)];case 1:return a=g.sent(),[4,this.keyFactory.createKey()];case 2:return s=g.sent(),[4,this.encryptionService.encrypt(a.passKey,s.toJSON(!0))];case 3:return o=g.sent(),[4,this.keyFactory.createKey()];case 4:return c=g.sent(),[4,this.encryptionService.encrypt(s,c.toJSON(!0))];case 5:return u=g.sent(),[4,this.keyFactory.createPkcKey()];case 6:return p=g.sent(),[4,this.encryptionService.encrypt(c,p.toJSON(!0))];case 7:return d=g.sent(),[4,this.keyFactory.createPkcSignKey()];case 8:return l=g.sent(),[4,this.encryptionService.encrypt(c,l.toJSON(!0))];case 9:return y=g.sent(),[4,this.http.post(this.config.authUrl+"users/",{claims:[{type:i,token:r,claim_id:n}],pass_idp_params:a.passIdpParams,pass_idp_verifier_pbk:a.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:a.wrappedPassIdpVerifierPrk,pass_key_params:a.passKeyParams,wrapped_master_key:o,wrapped_root_key:u,pbk:p.toJSON(),wrapped_prk:d,sig_pbk:l.toJSON(),wrapped_sig_prk:y}).toPromise()];case 10:return h=g.sent(),f={},h.claims.forEach((function(e){f[e.type]=e.value})),v=this.keyFactory.randomDigitsNoZeros(4),[4,this.auth.signUp({username:e.split("@")[0]+"."+v,password:this.passwordService.getPassIdpString(a.passIdp),attributes:f,clientMetadata:{user_id:String(h.id),user_pre_sign_up_token:String(h.pre_sign_up_token)}})];case 11:return[2,{username:(m=g.sent()).user.getUsername(),userId:h.id,preSignUpToken:h.pre_sign_up_token,userSub:m.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.http.get(this.config.authUrl+"users/hibp/breachedaccount/"+e+"/?truncateResponse=false").toPromise()];case 1:return[2,n.sent()];case 2:if(404===(t=n.sent()).status)return[2,null];throw t;case 3:return[2]}}))}))},e}();Gc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Gc(t.ɵɵinject(me),t.ɵɵinject(s.AuthClass),t.ɵɵinject(f.HttpClient),t.ɵɵinject(ve),t.ɵɵinject(he),t.ɵɵinject(Dr))},token:Gc,providedIn:"root"}),Gc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Gc.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:s.AuthClass},{type:f.HttpClient},{type:ve},{type:he},{type:Dr}]};var Vc,Bc,Qc,Wc=je(Vc||(Vc=F(["\nmutation CreateReminderMutation($input: CreateReminderInput!) {\n createReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"],["\nmutation CreateReminderMutation($input: CreateReminderInput!) {\n createReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"]))),Zc=je(Bc||(Bc=F(["\nmutation UpdateReminderMutation($input: UpdateReminderInput!) {\n updateReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"],["\nmutation UpdateReminderMutation($input: UpdateReminderInput!) {\n updateReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"]))),Hc=je(Qc||(Qc=F(["\nmutation DeleteReminderMutation($input: DeleteReminderInput!) {\n deleteReminder(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteReminderMutation($input: DeleteReminderInput!) {\n deleteReminder(input: $input) {\n id\n }\n}\n"])));e.ReminderService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.createReminder=function(e){return this.mutate(this.createReminderMutation(e))},t.prototype.createReminderMutation=function(e){var t;return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,new pt({mutation:Wc,variables:{input:{directoryId:e.directoryId,firstEvent:e.firstEvent.toISOString(),plain:JSON.stringify(e.plainJson),notifyAheadSeconds:null!==(t=e.notifyAheadSeconds)&&void 0!==t?t:0}}})]}))}))},t.prototype.updateReminder=function(e){return this.mutate(this.updateReminderMutation(e))},t.prototype.updateReminderMutation=function(e){var t,n;return A(this,void 0,void 0,(function(){return j(this,(function(r){return[2,new pt({mutation:Zc,variables:{input:{id:e.id,firstEvent:null===(t=e.firstEvent)||void 0===t?void 0:t.toISOString(),plain:JSON.stringify(null!==(n=e.plainJson)&&void 0!==n?n:void 0),notifyAheadSeconds:e.notifyAheadSeconds}}})]}))}))},t.prototype.deleteReminder=function(e){return this.mutate(this.deleteReminderMutation(e))},t.prototype.deleteReminderMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:Hc,variables:{input:{id:e}}})]}))}))},t}(At),e.ReminderService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ReminderService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ReminderService,providedIn:"root"}),e.ReminderService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ReminderService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ReminderService=O([et({ngZoneName:"ngZone"})],e.ReminderService);e.ɵn=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase="lifeready",r}return R(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.sharedKey.id},t}(Fr),e.ɵn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵn(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵn,providedIn:"root"}),e.ɵn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵn.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵn=O([et({ngZoneName:"ngZone"})],e.ɵn);var Yc,zc,Xc,eu,tu,nu,ru,iu,au,su,ou,cu,uu=je(Yc||(Yc=F(["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"],["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"]))),pu=je(zc||(zc=F(["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"],["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"]))),du=je(Xc||(Xc=F(["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"]))),lu=je(eu||(eu=F(["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),yu=je(tu||(tu=F(["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),hu=je(nu||(nu=F(["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"],["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"]))),fu=je(ru||(ru=F(["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"],["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"]))),vu=je(iu||(iu=F(["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),mu=je(au||(au=F(["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"],["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"]))),gu=je(su||(su=F(["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"],["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"]))),Su=je(ou||(ou=F(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),Iu=je(cu||(cu=F(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"],["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));function Cu(){throw new q("claimId does not match with the current claimId of the scenario")}function bu(){throw new Q("Scenario claim has not been approved")}e.ScenarioService=function(t){function n(e,n,r,i,a,s){var o=t.call(this,n)||this;return o.ngZone=e,o.injector=n,o.keyGraph=r,o.item2Service=i,o.assemblyController=a,o.encryptionService=s,o.prepareAddReceiverDirectory=o.prepareReceiverDirectory,o.prepareUpdateReceiverDirectory=o.prepareReceiverDirectory,o}return R(n,t),n.prototype.createScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.createScenarioMutation(e))]}))}))},n.prototype.createScenarioMutation=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.prepareCreateScenarioMutation(e)];case 1:return t=n.sent(),[2,new pt({mutation:uu,variables:{input:t}})]}}))}))},n.prototype.updateScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.updateScenarioMutation(e))]}))}))},n.prototype.updateScenarioMutation=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getScenario(e.scenarioId)];case 1:return t=r.sent().scenario,[4,this.prepareUpdateScenario(e,t)];case 2:return n=r.sent(),[2,new pt({mutation:pu,variables:{input:n}})]}}))}))},n.prototype.resetScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.resetScenarioMutation(e))]}))}))},n.prototype.resetScenarioMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.getScenario(e.scenarioId)];case 1:return t=a.sent().scenario,n=t.assembly,r=jt(n.subAssemblies).map((function(e){var t=jt(e.approvers).map((function(e){return{tpId:e.tp.id}}));return{id:e.id,quorum:e.quorum,singleReject:e.singleReject,subjectCipherDataClearJson:e.subjectCipherDataClearJson,approverTps:t}})),[4,this.prepareUpdateScenario({scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:{quorum:n.quorum,singleReject:n.singleReject,updateSubAssemblies:r}},t)];case 2:return i=a.sent(),[2,new pt({mutation:pu,variables:{input:i}})]}}))}))},n.prototype.deleteScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.lrGraphQL.lrMutate(this.deleteScenarioMutation(e))]}))}))},n.prototype.deleteScenarioMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:du,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.createClaim=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.createClaimMutation(e))]}))}))},n.prototype.createClaimMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:lu,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.cancelClaim=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.cancelClaimMutation(e))]}))}))},n.prototype.cancelClaimMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:yu,variables:{input:{claimId:e}}})]}))}))},n.prototype.rejectClaim=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.mutate(this.rejectClaimMutation(e,t))]}))}))},n.prototype.rejectClaimMutation=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.prepareRejectClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=lt).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.approveClaim=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.mutate(this.approveClaimMutation(e,t))]}))}))},n.prototype.approveClaimMutation=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.prepareApproveClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=lt).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.receiveClaim=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.mutate(this.receiveClaimMutation(e,t))]}))}))},n.prototype.receiveClaimMutation=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return n=pt.bind,r={mutation:vu},i={},[4,this.prepareClaim(e,t)];case 1:return[2,new(n.apply(pt,[void 0,(r.variables=(i.input=a.sent(),i),r)]))]}}))}))},n.prototype.debugExpireClaim=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.debugExpireClaimMutation(e))]}))}))},n.prototype.debugExpireClaimMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:mu,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.getScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.query({query:Su,variables:{scenarioId:e}})]}))}))},n.prototype.getSharedScenario=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.query({query:Iu,variables:{scenarioId:e}})];case 1:return n=r.sent(),t&&n.sharedScenario.sharedClaim.id!==t&&Cu(),[2,n]}}))}))},n.prototype.getParticipantTpsKeys=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return t=e.map((function(e){return e.tpId})),n=jt,[4,this.lrGraphQL.query({query:$r,variables:{ids:t}})];case 1:return[2,n.apply(void 0,[r.sent().tps])]}}))}))},n.prototype.fillTpSharedKeyId=function(e,t){e.forEach((function(e){if(!e.tpSharedKeyId){var n=t.find((function(t){return t.id===e.tpId}));e.tpSharedKeyId=n.currentUserSharedKey.userSharedKey.sharedKey.id}}))},n.prototype.prepareCreateScenarioMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p=this;return j(this,(function(d){switch(d.label){case 0:return[4,this.assemblyController.prepareCreate(e.createAssembly)];case 1:return t=d.sent(),n=t.assemblyKey,r=t.mutationInput,i=e.createReceivers||[],a=e.createClaimants||[],s=i.concat(a),[4,this.getParticipantTpsKeys(s)];case 2:return o=d.sent(),this.fillTpSharedKeyId(s,o),[4,Promise.all(i.map((function(e){return p.prepareCreateReceiver(e,n)})))];case 3:return c=d.sent(),[4,Promise.all(a.map((function(e){return p.prepareCreateClaimant(e)})))];case 4:return u=d.sent(),[2,{enabled:e.enabled,createAssembly:r,createReceivers:c,createClaimants:u}]}}))}))},n.prototype.prepareUpdateScenario=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b=this;return j(this,(function(w){switch(w.label){case 0:return[4,this.keyGraph.getJwkKey(t.assembly.assemblyKey.id)];case 1:return n=w.sent(),e.updateAssembly?[4,A(b,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return[4,this.assemblyController.prepareUpdate(e.updateAssembly,t.assembly)];case 1:return r=i.sent(),n=r.assemblyKey,[2,r.mutationInput]}}))}))]:[3,3];case 2:return i=w.sent(),[3,4];case 3:i=void 0,w.label=4;case 4:return r=i,a=e.createReceivers||[],s=e.createClaimants||[],o=a.concat(s),[4,this.getParticipantTpsKeys(o)];case 5:return c=w.sent(),this.fillTpSharedKeyId(o,c),(p=e.createReceivers)?[4,Promise.all(e.createReceivers.map((function(e){return b.prepareCreateReceiver(e,n)})))]:[3,7];case 6:p=w.sent(),w.label=7;case 7:return u=p,d=jt(t.receivers),e.updateReceivers?[4,Promise.all(e.updateReceivers.map((function(e){var t=d.find((function(t){return t.tp.id===e.tpId}));return b.prepareUpdateReceiver(e,n,t)})))]:[3,9];case 8:return y=w.sent(),[3,10];case 9:y=[],w.label=10;case 10:return l=y,e.updateAssembly?(h=d.filter((function(t){return!(e.deleteReceivers||[]).includes(t.tp.id)&&!l.some((function(e){return e.tpId===t.tp.id}))})),v=(f=l).concat,[4,this.prepareExistingReceivers(h,n)]):[3,12];case 11:l=v.apply(f,[w.sent()]),w.label=12;case 12:return(g=e.createClaimants)?[4,Promise.all(e.createClaimants.map((function(e){return b.prepareCreateClaimant(e)})))]:[3,14];case 13:g=w.sent(),w.label=14;case 14:return m=g,S=jt(t.claimants),(C=e.updateClaimants)?[4,Promise.all(e.updateClaimants.map((function(e){var t=S.find((function(t){return t.tp.id===e.tpId}));return b.prepareUpdateClaimant(e,t.sharedKey.id)})))]:[3,16];case 15:C=w.sent(),w.label=16;case 16:return I=C,[2,{scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:r,createReceivers:u,updateReceivers:l,deleteReceivers:e.deleteReceivers,createClaimants:m,updateClaimants:I,deleteClaimants:e.deleteClaimants}]}}))}))},n.prototype.prepareReceiverDirectory=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.item2Service.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return r=s.sent(),[4,this.keyGraph.encryptToString(t,e.sharedCipherDataClearJson||"")];case 2:return i=s.sent(),[4,this.keyGraph.encryptToString(t,r.jwk.toJSON(!0))];case 3:return a=s.sent(),[4,this.keyGraph.encryptToString(n,a)];case 4:return a=s.sent(),[2,{directoryId:e.directoryId,wrappedItemKey:a,accessRole:e.accessRole,sharedCipherData:i}]}}))}))},n.prototype.prepareCreateReceiver=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o=this;return j(this,(function(c){switch(c.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return n=c.sent(),r=n.sharedKey,i=n.mutationInput,(s=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return o.prepareAddReceiverDirectory(e,r.key,t)})))]:[3,3];case 2:s=c.sent(),c.label=3;case 3:return a=s,[2,Object.assign(Object.assign({},i),{addDirectories:a})]}}))}))},n.prototype.prepareUpdateReceiver=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l=this;return j(this,(function(y){switch(y.label){case 0:return r=n.sharedKey.id,i=e.deleteDirectories||[],a=e.updateDirectories||[],jt(n.receiverDirectories).forEach((function(e){i.includes(e.directory.id)||a.find((function(t){return t.directoryId===e.directory.id}))||a.push({accessRole:e.accessRole,directoryId:e.directory.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),[4,this.prepareUpdateParticipant(e,r)];case 1:return s=y.sent(),o=s.sharedKey,c=s.mutationInput,(p=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return l.prepareAddReceiverDirectory(e,o,t)})))]:[3,3];case 2:p=y.sent(),y.label=3;case 3:return u=p,[4,Promise.all(a.map((function(e){return l.prepareUpdateReceiverDirectory(e,o,t)})))];case 4:return d=y.sent(),[2,Object.assign(Object.assign({},c),{addDirectories:u,updateDirectories:d,deleteDirectories:e.deleteDirectories})]}}))}))},n.prototype.prepareExistingReceiver=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){return n=jt(e.receiverDirectories).map((function(e){return{directoryId:e.directory.id,directoryKeyId:e.directory.keyId,accessRole:e.accessRole,sharedCipherDataClearJson:e.sharedCipherDataClearJson}})),[2,this.prepareUpdateReceiver({tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,updateDirectories:n},t,e)]}))}))},n.prototype.prepareExistingReceivers=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){return[2,Promise.all(e.map((function(e){return n.prepareExistingReceiver(e,t)})))]}))}))},n.prototype.prepareCreateParticipant=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.keyGraph.encryptWithNewKey(e.tpSharedKeyId,e.sharedCipherDataClearJson||"")];case 1:return[2,{sharedKey:t=n.sent(),mutationInput:{tpId:e.tpId,tpSharedKeyId:e.tpSharedKeyId,tpSharedKeyWrappedSharedKey:t.wrappedKey,sharedCipherData:t.cipher}}]}}))}))},n.prototype.prepareUpdateParticipant=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyGraph.getJwkKey(t)];case 1:return n=i.sent(),[4,this.keyGraph.encryptToString(n,e.sharedCipherDataClearJson||"")];case 2:return r=i.sent(),[2,{sharedKey:n,mutationInput:{tpId:e.tpId,sharedKeyId:t,sharedCipherData:r}}]}}))}))},n.prototype.prepareCreateClaimant=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return[2,t.sent().mutationInput]}}))}))},n.prototype.prepareUpdateClaimant=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.prepareUpdateParticipant(e,t)];case 1:return[2,n.sent().mutationInput]}}))}))},n.prototype.prepareClaim=function(t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o=this;return j(this,(function(c){switch(c.label){case 0:return[4,this.getSharedScenario(t,n)];case 1:return(r=c.sent().sharedScenario).state!==e.ScenarioState.APPROVED&&bu(),i=jt(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),[4,Promise.all(r.asReceiver.receiverDirectories.edges.map((function(e){return e.node})).map((function(e){return A(o,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.encryptionService.decrypt(a,e.wrappedItemKey)];case 1:return t=n.sent(),[2,{receiverDirectoryId:e.id,receiverSharedKeyWrappedItemKey:t}]}}))}))})))];case 3:return s=c.sent(),[2,{scenarioClaimId:n,receiverDirectories:s}]}}))}))},n.prototype.recoverAssemblyKey=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return n.keyGraph.decryptFromString(e.pxk.id,e.receiverCipherPartialAssemblyKey)})))];case 1:return t=r.sent(),[2,this.assemblyController.recoverAssemblyKey(t)]}}))}))},n.prototype.asClaimApprovers=function(e,t,n){return A(this,void 0,void 0,(function(){return j(this,(function(r){switch(r.label){case 0:return[4,this.getSharedScenario(e,t)];case 1:return[2,jt(r.sent().sharedScenario.sharedClaim.claim.asClaimApprovers).filter((function(e){return e.state===n}))]}}))}))},n.prototype.prepareApproveClaimMutations=function(t,n){return A(this,void 0,void 0,(function(){var r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.asClaimApprovers(t,n,e.TpClaimApproverState.CLAIMED)];case 1:return[2,i.sent().map((function(e){return A(r,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:fu},r={},[4,this.prepareApproveClaim(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))}))]}}))}))},n.prototype.prepareApproveClaim=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,Promise.all(jt(e.receiverApprovals).map((function(t){return n.prepareReceiverApproval({receiverApprovalId:t.id,receiverApprovalPxkId:t.pxk.id,sharedCipherPartialAssemblyKeyClearJson:e.sharedCipherPartialAssemblyKeyClearJson})})))];case 1:return t=r.sent(),[2,{claimApproverId:e.id,receiverApprovals:t}]}}))}))},n.prototype.prepareReceiverApproval=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t={receiverApprovalId:e.receiverApprovalId,receiverCipher:""},[4,this.keyGraph.encryptToString(e.receiverApprovalPxkId,e.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(t.receiverCipherPartialAssemblyKey=n.sent(),t)]}}))}))},n.prototype.prepareRejectClaimMutations=function(t,n){return A(this,void 0,void 0,(function(){var r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.asClaimApprovers(t,n,e.TpClaimApproverState.CLAIMED)];case 1:return[2,i.sent().map((function(e){return A(r,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:hu,variables:{input:{claimApproverId:e.id}}})]}))}))}))]}}))}))},n}(At),e.ScenarioService.SLIP39_PASSPHRASE="lifeready",e.ScenarioService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ScenarioService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ke),t.ɵɵinject(e.Item2Service),t.ɵɵinject(e.ɵn),t.ɵɵinject(he))},token:e.ScenarioService,providedIn:"root"}),e.ScenarioService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ScenarioService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ke},{type:e.Item2Service},{type:e.ɵn},{type:he}]},e.ScenarioService=O([et({ngZoneName:"ngZone"})],e.ScenarioService);var wu,Ku=je(wu||(wu=F(["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"],["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"])));e.ServerConfigService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.getConfig=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return null!=this.serverConfig?[3,2]:(e=this,[4,this.query({query:Ku,includeKeyGraph:!1})]);case 1:e.serverConfig=t.sent().serverConfig,t.label=2;case 2:return[2,this.serverConfig]}}))}))},t}(At),e.ServerConfigService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ServerConfigService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ServerConfigService,providedIn:"root"}),e.ServerConfigService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ServerConfigService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ServerConfigService=O([et({ngZoneName:"ngZone"})],e.ServerConfigService);var ku,Pu,Eu,Du,Ru=je(ku||(ku=F(["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"],["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"]))),Mu=je(Pu||(Pu=F(["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"],["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"]))),Ou=je(Eu||(Eu=F(["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"],["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"]))),Au=je(Du||(Du=F(["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"],["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"])));e.SharedContactCard2Service=function(){function e(e,t,n,r,i){this.ngZone=e,this.keyService=t,this.keyGraph=n,this.encryptionService=r,this.lrGraphQL=i}return e.prototype.getOwnedContactCardKeyIds=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:Ou,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Au,variables:{id:e}})];case 1:return[2,t.sent().receivedContactCard.receiverKey.id]}}))}))},e.prototype.updateOwnedContactCard=function(e){var t=e.id,n=e.ownerKeyId,r=e.sharedKeyId,i=e.ownerPlainDataJson,a=e.ownerCipherDataClearJson,s=e.sharedCipherDataClearJson;return A(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,m;return j(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,7]),[4,this.keyGraph.getKey(n)];case 1:return e=g.sent(),[4,this.keyGraph.getKey(r)];case 2:return o=g.sent(),[3,7];case 3:return g.sent(),[4,this.getOwnedContactCardKeyIds(t)];case 4:return c=g.sent(),[4,this.keyGraph.getKey(c.ownerKeyId)];case 5:return e=g.sent(),[4,this.keyGraph.getKey(c.sharedKeyId)];case 6:return o=g.sent(),[3,7];case 7:return u=this.keyService.currentSigPxk,[4,this.encryptionService.encrypt(o.jwk,s)];case 8:return p=g.sent(),y=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 9:return d=y.apply(l,[g.sent()]),v=(f=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 10:return h=v.apply(f,[g.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 11:return m=g.sent(),[2,new pt({mutation:Ru,variables:{input:{id:t,ownerCipherData:m,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:h}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return A(this,void 0,void 0,(function(){var e,i,a=this;return j(this,(function(s){switch(s.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return a.getReceivedContactCardKeyId(t)}))];case 1:return e=s.sent(),[4,this.encryptionService.encryptToString(e.jwk,r)];case 2:return i=s.sent(),[2,new pt({mutation:Mu,variables:{input:{id:t,receiverCipherData:i,receiverKeyId:e.id}}})]}}))}))},e}(),e.SharedContactCard2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.SharedContactCard2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ke),t.ɵɵinject(ke),t.ɵɵinject(he),t.ɵɵinject(e.ɵf))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:t.NgZone},{type:Ke},{type:ke},{type:he},{type:e.ɵf}]},e.SharedContactCard2Service=O([et({ngZoneName:"ngZone"})],e.SharedContactCard2Service),e.ɵo=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.getReset=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.query({query:yi})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.getSharedResets=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.query({query:pi})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},t.prototype.getSharedReset=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.query({query:di,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},t}(At),e.ɵo.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵo(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵo,providedIn:"root"}),e.ɵo.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵo.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵo=O([et({ngZoneName:"ngZone"})],e.ɵo),e.TpPasswordResetRequestService=function(t){function n(e,n,r,i){var a=t.call(this,n)||this;return a.ngZone=e,a.injector=n,a.encryptionService=r,a.privateService=i,a}return R(n,t),n.prototype.activeRequestOrRaise=function(t){var n=t.sharedRequest.claim.state;if(n!==e.TpAssemblyState.CLAIMED)throw new Q("Claim is already in "+n+" state.")},n.prototype.rejectRequest=function(e){return this.mutate(this.rejectRequestMutation(e))},n.prototype.rejectRequestMutation=function(t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=r.sent(),this.activeRequestOrRaise(n),[2,lt.create(n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})).map((function(e){return new pt({mutation:ai,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},n.prototype.approveRequest=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return r=(n=this.lrGraphQL).lrMutate,[4,this.approveRequestMutation(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},n.prototype.approveRequestMutation=function(t,n){return A(this,void 0,void 0,(function(){var n,r,i,s,o,c=this;return j(this,(function(u){switch(u.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=u.sent(),this.activeRequestOrRaise(n),[4,a.JWK.asKey(JSON.parse(n.sharedRequest.pxk.pbk))];case 2:return r=u.sent(),i=n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})),o=(s=lt).create,[4,Promise.all(i.map((function(e){return A(c,void 0,void 0,(function(){var t,n,i=this;return j(this,(function(a){switch(a.label){case 0:return t=e.node,n={claimApproverId:t.id},[4,Promise.all(t.receiverApprovals.edges.map((function(e){return A(i,void 0,void 0,(function(){var n,i;return j(this,(function(a){switch(a.label){case 0:return n=e.node,i={receiverApprovalId:n.id,receiverCipher:""},[4,this.encryptionService.encryptToString(r,t.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(i.receiverCipherPartialAssemblyKey=a.sent(),i)]}}))}))})))];case 1:return n.receiverApprovals=a.sent(),[2,new pt({mutation:ii,variables:{input:n}})]}}))}))})))];case 3:return[2,o.apply(s,[u.sent()])]}}))}))},n}(At),e.TpPasswordResetRequestService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetRequestService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(he),t.ɵɵinject(e.ɵo))},token:e.TpPasswordResetRequestService,providedIn:"root"}),e.TpPasswordResetRequestService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetRequestService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:he},{type:e.ɵo}]},e.TpPasswordResetRequestService=O([et({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService);function ju(){!function(e){if(!e)throw new q("You must specify a non empty prefix.");Object.keys(localStorage).forEach((function(t){t.startsWith(e)&&localStorage.removeItem(t)}))}("CognitoIdentityServiceProvider")}e.TpPasswordResetUserService=function(e){function t(t,n,r,i,a,s,o,c){var u=e.call(this,n)||this;return u.ngZone=t,u.injector=n,u.config=r,u.keyFactory=i,u.encryptionService=a,u.passwordService=s,u.http=o,u.auth=c,u}return R(t,e),t.prototype.verifyEmailContact=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){return t={email:e},[2,this.http.post(this.config.authUrl+"tp/password-reset/verify-contact/",t).toPromise()]}))}))},t.prototype.verifyContactRespond=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},t.prototype.requestReset=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return ju(),[4,this.passwordService.createPassKeyBundle(e)];case 1:return r=p.sent(),[4,this.keyFactory.createKey()];case 2:return i=p.sent(),[4,this.encryptionService.encrypt(r.passKey,i.toJSON(!0))];case 3:return a=p.sent(),[4,this.keyFactory.createPkcKey()];case 4:return s=p.sent(),[4,this.encryptionService.encrypt(i,s.toJSON(!0))];case 5:return o=p.sent(),[4,this.http.post(this.config.authUrl+"tp/password-reset/request/",{claimId:t,claimToken:n,pass_key_params:r.passKeyParams,pass_idp_params:r.passIdpParams,pass_idp_verifier_pbk:r.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:r.wrappedPassIdpVerifierPrk,wrapped_master_key:a,pbk:s.toJSON(),master_key_wrapped_prk:o}).toPromise()];case 6:return c=p.sent(),console.log("Using new password"),[4,this.auth.signUp({username:c.reset_username,password:this.passwordService.getPassIdpString(r.passIdp),clientMetadata:{tp_password_reset_request:JSON.stringify({id:c.id,associate_reset_user_token:c.associate_reset_user_token})}})];case 7:return u=p.sent(),console.log("requestRest done"),[2,{requestResetResult:c,signUpResult:u}]}}))}))},t}(At),e.TpPasswordResetUserService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetUserService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(me),t.ɵɵinject(ve),t.ɵɵinject(he),t.ɵɵinject(Dr),t.ɵɵinject(f.HttpClient),t.ɵɵinject(s.AuthClass))},token:e.TpPasswordResetUserService,providedIn:"root"}),e.TpPasswordResetUserService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetUserService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:ve},{type:he},{type:Dr},{type:f.HttpClient},{type:s.AuthClass}]},e.TpPasswordResetUserService=O([et({ngZoneName:"ngZone"})],e.TpPasswordResetUserService),e.TpPasswordResetService=function(e){function t(t,n,r,i){var a=e.call(this,n)||this;return a.ngZone=t,a.injector=n,a.privateService=r,a.assemblyController=i,a.slip39Passphrase=Rr,a}return R(t,e),t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new pt({mutation:ei})},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new pt({mutation:oi})},t.prototype.validateApprovers=function(e){return this.assemblyController.validateApprovers(e)},t.prototype.createReset=function(e){return this.mutate(this.createResetMutation(e))},t.prototype.createResetMutation=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.assemblyController.prepareCreate(e)];case 1:return t=n.sent().mutationInput,[2,new pt({mutation:si,variables:{input:{assembly:Object.assign({},t)}}})]}}))}))},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getReset()];case 1:return t=r.sent(),[4,this.assemblyController.prepareUpdate(e,t.assembly)];case 2:return n=r.sent().mutationInput,[2,new pt({mutation:ci,variables:{input:{assembly:Object.assign({},n)}}})]}}))}))},t.prototype.debugExpireResetRequest=function(e){return this.mutate(this.debugExpireResetRequestMutation(e),{includeKeyGraph:!1})},t.prototype.debugExpireResetRequestMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:gu,variables:{input:{username:e}}})]}))}))},t}(At),e.TpPasswordResetService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(e.ɵo),t.ɵɵinject(e.ɵi))},token:e.TpPasswordResetService,providedIn:"root"}),e.TpPasswordResetService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:e.ɵo},{type:e.ɵi}]},e.TpPasswordResetService=O([et({ngZoneName:"ngZone"})],e.TpPasswordResetService);var Tu,Nu,$u,Fu,Uu,Lu,xu,_u,Ju,qu=je(Tu||(Tu=F(["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"]))),Gu=je(Nu||(Nu=F(["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"],["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"]))),Vu=je($u||($u=F(["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"],["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"]))),Bu=je(Fu||(Fu=F(["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"],["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"]))),Qu=je(Uu||(Uu=F(["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"],["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"]))),Wu=je(Lu||(Lu=F(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),Zu=je(xu||(xu=F(["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"],["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"]))),Hu=je(_u||(_u=F(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"]))),Yu=je(Ju||(Ju=F(["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"],["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"])));e.TrustedParty2Service=function(e){function t(t,n,r,i,a,s,o){var c=e.call(this,n)||this;return c.ngZone=t,c.injector=n,c.keyGraph=r,c.item2Service=i,c.keyService=a,c.keyFactory=s,c.encryptionService=o,c}return R(t,e),t.prototype.deleteTpExec=function(e){return this.mutate(this.deleteTpMutation(e))},t.prototype.deleteTp=function(e){return this.deleteTpMutation(e)},t.prototype.deleteTpMutation=function(e){return new pt({mutation:qu,variables:{input:{id:e}}})},t.prototype.shareDirectory=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.shareDirectoryMutation(e))]}))}))},t.prototype.shareDirectoryMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.shareItemMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},t.prototype.shareFile=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.shareFileMutation(e))]}))}))},t.prototype.shareFileMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.shareItemMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},t.prototype.shareItemMutation=function(e){var t=e.itemId,n=e.itemKeyId,r=e.tpId,i=e.tpSharedKeyId,a=e.accessRole,s=e.isDirectory;return A(this,void 0,void 0,(function(){var e,o,c,u=this;return j(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return s?u.item2Service.getDirectoryKeyId(t):u.item2Service.getFileKeyId(t)}))];case 1:return e=p.sent(),[4,this.keyGraph.getKey(i,(function(){return u.getTpCurrentUserSharedKey(r).then((function(e){return e.sharedKey.id}))}))];case 2:return o=p.sent(),[4,this.keyGraph.wrapKey(o,e.jwk)];case 3:return c=p.sent(),[2,new pt({mutation:s?Gu:Bu,variables:{input:{id:t,tpId:r,accessRole:a,keyId:e.id,wrappingKeyId:o.id,wrappedKey:c}}})]}}))}))},t.prototype.unshareDirectory=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.unshareDirectoryMutation(e))]}))}))},t.prototype.unshareDirectoryMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.unshareItemMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},t.prototype.unshareFile=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.unshareFileMutation(e))]}))}))},t.prototype.unshareFileMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.unshareItemMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},t.prototype.unshareItemMutation=function(e){var t=e.itemId,n=e.tpId,r=e.isDirectory;return A(this,void 0,void 0,(function(){return j(this,(function(e){return[2,new pt({mutation:r?Vu:Qu,variables:{input:{id:t,tpId:n}}})]}))}))},t.prototype.requestMkReshare=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if((t=o.sent()).mkSharedKey)throw new Q("TP already has mkSharedKey");return n=this.keyService.currentMasterKey,[4,this.keyFactory.createPkcKey()];case 2:return r=o.sent(),[4,this.encryptionService.encryptToString(n.jwk,r.toJSON(!0))];case 3:return i=o.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 4:return a=o.sent(),[4,this.encryptionService.encryptToString(a.jwk,{pbk:r.toJSON()})];case 5:return s=o.sent(),[4,new pt({mutation:Wu,variables:{input:{tpId:e,masterKeyId:n.id,mkPbk:JSON.stringify(r.toJSON()),mkWrappedMkPrk:i,sharedKeyId:a.id,mkReshareRequestCipher:s}}})];case 6:return[2,o.sent()]}}))}))},t.prototype.respondMkReshare=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if(!(t=l.sent()).mkSharedKey)throw new Q("No access to the mkSharedKey so cannot reshare it with TP");return[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=l.sent(),[4,this.encryptionService.decrypt(n,t.mkReshareRequestCipher)];case 3:return r=l.sent(),[4,a.JWK.asKey(r.pbk)];case 4:return i=l.sent(),[4,this.keyGraph.getKey(t.mkSharedKey.id)];case 5:return s=l.sent(),o={mkSharedKey:{id:s.id,jwk:s.jwk.toJSON(!0)}},p=(u=this.encryptionService).encryptToString,d=[i],[4,this.encryptionService.encryptToString(n.jwk,o)];case 6:return[4,p.apply(u,d.concat([l.sent()]))];case 7:return c=l.sent(),[2,new pt({mutation:Zu,variables:{input:{tpId:e,mkSharedKeyId:s.id,mkReshareResponseCipher:c}}})]}}))}))},t.prototype.completeMkReshare=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d,l;return j(this,(function(y){switch(y.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=y.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=y.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=y.sent(),o=(s=this.encryptionService).decrypt,c=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,o.apply(s,c.concat([y.sent()]))];case 5:return i=y.sent(),p={id:i.mkSharedKey.id},[4,a.JWK.asKey(i.mkSharedKey.jwk)];case 6:return p.jwk=y.sent(),u=p,d=this.keyService.currentMasterKey,[4,this.encryptionService.encryptToString(d.jwk,u.jwk.toJSON(!0))];case 7:return l=y.sent(),[2,new pt({mutation:Hu,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:u.id,mkWrappedMkSharedKey:l}}})]}}))}))},t.prototype.getTpCurrentUserSharedKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Yu,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},t}(At),e.TrustedParty2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TrustedParty2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ke),t.ɵɵinject(e.Item2Service),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(he))},token:e.TrustedParty2Service,providedIn:"root"}),e.TrustedParty2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TrustedParty2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ke},{type:e.Item2Service},{type:Ke},{type:ve},{type:he}]},e.TrustedParty2Service=O([et({ngZoneName:"ngZone"})],e.TrustedParty2Service);var zu=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.auth.getPreferredMFA(e)];case 2:return[2,t.sent()]}}))}))},e.prototype.setPreferredMFA=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.setPreferredMFA(t,e)];case 2:return n.sent(),[2]}}))}))},e.prototype.setPhoneNumber=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.updateUserAttributes(t,{phone_number:e})];case 2:return n.sent(),[2]}}))}))},e.prototype.getSMSCode=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.auth.verifyCurrentUserAttribute("phone_number")];case 1:return e.sent(),[2]}}))}))},e.prototype.verifySMSCode=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.auth.verifyCurrentUserAttributeSubmit("phone_number",e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getSoftwareToken=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=N.apply(void 0,[a.sent(),2]),t=e[0],n=e[1],[4,this.auth.setupTOTP(t)];case 2:if(r=a.sent(),!(i=n.attributes.email))throw new q("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.verifyTotpToken(t,e)];case 2:return n.sent(),[2]}}))}))},e}();zu.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new zu(t.ɵɵinject(s.AuthClass))},token:zu,providedIn:"root"}),zu.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],zu.ctorParameters=function(){return[{type:s.AuthClass}]},e.ApiContactCard=pr,e.ApiCurrentUser=ur,e.ArchiveDirectoryMutation=Rn,e.AuthTypes=Ei,e.CancelUserDeleteMutation=ec,e.Category=ra,e.CategoryFields=fn,e.CategoryFilter=ln,e.CategoryMetaService=Zi,e.CategoryService=Bi,e.CognitoChallengeUser=Ft,e.CompleteOtkMutation=ks,e.ContactCardAddress=lr,e.ContactCardName=dr,e.CreateCategoryMutation=kn,e.CreateContactCardMutation=ar,e.CreateFileMutation=Gi,e.CreateFileQuery=We,e.CreateLbopQuery=to,e.CreateRecordContainerMutation=Li,e.CreateRecordMutation=xi,e.CreateVaultMutation=Pn,e.CurrentCategory=ia,e.CurrentUser=Ut,e.CurrentUserKey=cr,e.CurrentUserQuery=ir,e.CurrentUserSharedKeyQuery=Ss,e.DEFAULT_BREADCRUMB_DEPTH=5,e.DEFAULT_DESCENDANTS_DEPTH=5,e.DefaultCategory=ea,e.DefaultProcessorOptions=tt,e.DefaultVaultFilter=dn,e.DeleteCategoryMutation=Dn,e.DeleteFileMutation=Vi,e.DeleteLbopQuery=no,e.DeleteRecordMutation=qi,e.DirectoryQuery=Qe,e.ERROR_SOURCE=Zs,e.Features=or,e.FetchKeyGraphField=Ve,e.FileQuery=Be,e.FileUploadService=ya,e.GetCategoriesQuery=gn,e.GetCategoryKeyIdQuery=Kn,e.GetCategoryQuery=wn,e.GetMySharedCategoriesQuery=Cn,e.GetRecordQuery=Ui,e.GetRootDirectoryIdsQuery=mn,e.GetTrustedPartyCategoriesQuery=In,e.GetVaultsQuery=Sn,e.IdleService=xt,e.InitiateOtkMutation=ws,e.KC_CONFIG=me,e.KcAuthException=J,e.KcBadArgumentException=q,e.KcBadLogicException=G,e.KcBadRequestException=V,e.KcBadSignatureException=B,e.KcBadStateException=Q,e.KcBadTimeSyncException=W,e.KcCodeMismatchException=Z,e.KcConcurrentAccessException=H,e.KcEncryptionException=Y,e.KcError=x,e.KcException=_,e.KcInternalErrorException=z,e.KcLockedException=X,e.KcNotFoundException=ee,e.KcSuspiciousOperationException=te,e.KcUnsupportedException=ne,e.KeyExchangeFields=ms,e.KeyExchangeQuery=Cs,e.KeyExchangeService=Ps,e.KeyExchangeTokenQuery=bs,e.KeyExchangesQuery=Is,e.KeyGraphField=Ge,e.KeyGraphFragment=qe,e.LbopQuery=io,e.LbopService=so,e.LbopsQuery=ao,e.LifeReadyAuthService=vi,e.LifeReadyModule=oo,e.LoadedCategoryTree=Wi,e.LoginHistoryQuery=tc,e.LoginResult=Lt,e.LrApolloService=Pe,e.LrGraphQLService=e.ɵf,e.LrMergedMutation=lt,e.LrMutation=pt,e.LrMutationBase=ut,e.LrRecord=Lc,e.LrService=At,e.MainContactCard=fr,e.MainContactCardFields=hr,e.MainContactCardPlainFields=vr,e.MainContactCardProperty=yr,e.MoveDirectoryQuery=ze,e.MoveFileQuery=Ye,e.NewAttachment=xc,e.NewCategory=sa,e.NewOrUpdatedAttachment=Jc,e.NewRecord=_c,e.OwnerPlainDataJson=la,e.PassIdpApiResult=mr,e.PasswordCheck=Er,e.PasswordService=Dr,e.PersistService=Ce,e.Plan=Ao,e.PlanService=er,e.ProfileDetailsService=Pc,e.ProfileService=Sr,e.RecordAttachment=Uc,e.RecordAttachmentFilter=Fi,e.RecordAttachmentService=Nc,e.RecordContentFilter=$i,e.RecordField=Fc,e.RecordFilter=yn,e.RecordService=$c,e.RecordType=Oc,e.RecordTypeField=jc,e.RecordTypeFieldOption=Ac,e.RecordTypeService=Mc,e.RecordTypeSummary=Tc,e.RegisterService=Gc,e.RequestUserDeleteMutation=Xo,e.RespondOtkMutation=Ks,e.RevertFileQuery=He,e.ServerTimeQuery=pe,e.SharedAccess=Xi,e.StripeBillingPortalSession=$o,e.StripeCheckoutSession=No,e.Subscription=jo,e.TimeService=de,e.TrustedPartyDetails=gr,e.TwoFactorService=zu,e.UnarchiveDirectoryMutation=Mn,e.UpdateCategoryMutation=En,e.UpdateContactCardMutation=sr,e.UpdateFileQuery=Ze,e.UpdateLbopQuery=ro,e.UpdateRecordContainerMutation=_i,e.UpdateRecordMutation=Ji,e.UpdatedCategory=oa,e.UpdatedRecord=qc,e.UserPlan=To,e.UserService=nc,e.UserSharedKeyFields=gs,e.Vault=ca,e.VaultCategory=aa,e.VaultFields=vn,e.VaultRecord=na,e.VaultRecordType=ta,e.WebCryptoService=fe,e.awsFetch=Nt,e.configureAmplifyAuth=$t,e.configureApollo=Ie,e.fragmentSpreadAstSelection=ct,e.gqlTyped=je,e.handleApolloError=U,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.httpOptions=Se,e.initialiseAuth=fi,e.mapEdges=jt,e.mapUserPlans=Xn,e.parentCategoriesField=bn,e.processConnection=nt,e.throwClaimIdMismatch=Cu,e.throwClaimNotApproved=bu,e.ɵ0=Rc,e.ɵa=ke,e.ɵb=he,e.ɵc=Ke,e.ɵd=ve,e.ɵe=On,e.ɵh=et,e.ɵj=Fr,e.ɵk=At,e.ɵl=Zo,e.ɵm=Kc,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("apollo-angular"),require("@dagrejs/graphlib"),require("lodash"),require("node-jose"),require("@aws-amplify/auth/lib-esm/Auth"),require("graphql-tag"),require("moment"),require("@apollo/client/core"),require("@apollo/client/link/context"),require("@apollo/client/link/retry"),require("ngx-cookie-service"),require("graphql/language/printer"),require("@aws-amplify/auth"),require("@angular/common/http"),require("@aws-amplify/core"),require("rxjs"),require("@ng-idle/core"),require("@ng-idle/keepalive"),require("slip39")):"function"==typeof define&&define.amd?define("@lifeready/core",["exports","@angular/core","apollo-angular","@dagrejs/graphlib","lodash","node-jose","@aws-amplify/auth/lib-esm/Auth","graphql-tag","moment","@apollo/client/core","@apollo/client/link/context","@apollo/client/link/retry","ngx-cookie-service","graphql/language/printer","@aws-amplify/auth","@angular/common/http","@aws-amplify/core","rxjs","@ng-idle/core","@ng-idle/keepalive","slip39"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).lifeready=e.lifeready||{},e.lifeready.core={}),e.ng.core,e["apollo-angular"],e["@dagrejs/graphlib"],e.lodash,e["node-jose"],e["@aws-amplify/auth/lib-esm/Auth"],e["graphql-tag"],e.moment,e["@apollo/client/core"],e["@apollo/client/link/context"],e["@apollo/client/link/retry"],e["ngx-cookie-service"],e["graphql/language/printer"],e["@aws-amplify/auth"],e.ng.common.http,e["@aws-amplify/core"],e.rxjs,e["@ng-idle/core"],e["@ng-idle/keepalive"],e.slip39)}(this,(function(e,t,n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I){"use strict";function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var w=C(r),K=C(i),k=C(o),P=b(c),E=C(h),D=function(e,t){return(D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function R(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}D(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function M(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function O(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function A(e,t,n,r){return new(n||(n=Promise))((function(i,a){function s(e){try{c(r.next(e))}catch(e){a(e)}}function o(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}c((r=r.apply(e,t||[])).next())}))}function j(e,t){var n,r,i,a,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}Object.create;function T(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function N(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return s}function $(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(N(arguments[t]));return e}function F(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}Object.create;function U(e){if(e&&e.length){var t=e.map((function(e){return new x({code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,message:e.message,debug:{locations:e.locations,path:e.path}})}));throw new(_.bind.apply(_,$([void 0],t)))}}var L,x=function(e){this._type="KcError",this.code=e.code,this.source=e.source,this.message=e.message,this.debug=e.debug},_=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._type="KcException",this.errors=e}return e.prototype.toString=function(){return this.errors.map((function(e){return JSON.stringify(e,null,2)}))},e}();(L=e.KcErrorCode||(e.KcErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",L.BAD_ARGUMENT="BAD_ARGUMENT",L.BAD_SIGNATURE="BAD_SIGNATURE",L.BAD_STATE="BAD_STATE",L.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",L.CONCURRENT_ACCESS="CONCURRENT_ACCESS",L.CONFIG_ERROR="CONFIG_ERROR",L.CYCLE_DETECTED="CYCLE_DETECTED",L.EXPIRED="EXPIRED",L.INVALID_TOKEN="INVALID_TOKEN",L.INTERNAL_ERROR="INTERNAL_ERROR",L.JSON_DECODE_ERROR="JSON_DECODE_ERROR",L.KEY_MISMATCH="KEY_MISMATCH",L.LIMIT_REACHED="LIMIT_REACHED",L.LOCKED="LOCKED",L.LOGIC_ERROR="LOGIC_ERROR",L.LR_DEBUG_ONLY="LR_DEBUG_ONLY",L.MIN_DELAY="MIN_DELAY",L.MISSING_FIELD="MISSING_FIELD",L.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",L.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",L.NOT_IMPLEMENTED="NOT_IMPLEMENTED",L.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",L.OBJECT_EXISTS="OBJECT_EXISTS",L.RANGE_ERROR="RANGE_ERROR",L.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",L.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",L.USER_NOT_FOUND="USER_NOT_FOUND",L.VERSION_MISMATCH="VERSION_MISMATCH",L.WRONG_PERMISSIONS="WRONG_PERMISSIONS",L.AUTH="AUTH",L.BAD_LOGIC="BAD_LOGIC",L.BAD_REQUEST="BAD_REQUEST",L.BAD_TIME_SYNC="BAD_TIME_SYNC",L.CODE_MISMATCH="CODE_MISMATCH",L.ENCRYPTION="ENCRYPTION",L.NOT_FOUND="NOT_FOUND",L.SUSPICIOUS_OPERATION="SUSPICIOUS_OPERATION",L.UNSUPPORTED="UNSUPPORTED";var J=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.AUTH,message:n}))||this}return R(n,t),n}(_),q=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_ARGUMENT,message:n}))||this}return R(n,t),n}(_),G=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_LOGIC,message:n}))||this}return R(n,t),n}(_),V=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_REQUEST,message:n}))||this}return R(n,t),n}(_),B=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_SIGNATURE,message:n}))||this}return R(n,t),n}(_),Q=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_STATE,message:n}))||this}return R(n,t),n}(_),W=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.BAD_TIME_SYNC,message:n}))||this}return R(n,t),n}(_),Z=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.CODE_MISMATCH,message:n}))||this}return R(n,t),n}(_),H=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.CONCURRENT_ACCESS,message:n}))||this}return R(n,t),n}(_),Y=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.ENCRYPTION,message:n}))||this}return R(n,t),n}(_),z=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.INTERNAL_ERROR,message:n}))||this}return R(n,t),n}(_),X=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.LOCKED,message:n}))||this}return R(n,t),n}(_),ee=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.NOT_FOUND,message:n}))||this}return R(n,t),n}(_),te=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.SUSPICIOUS_OPERATION,message:n}))||this}return R(n,t),n}(_),ne=function(t){function n(n){return t.call(this,new x({code:e.KcErrorCode.UNSUPPORTED,message:n}))||this}return R(n,t),n}(_);function re(e){if(!Array.isArray(e))throw new Error("not array");return e.some((function(e){return null==e?void 0:e.then}))?Promise.all(e):e}function ie(e,t){var n,r,i={};try{for(var a=T(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=N(s.value,2),c=o[0];i[o[1]]=t[c]}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i}function ae(e,t){var n=re(Object.entries(e).map((function(n){var r=N(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return ie(e,t)})):ie(e,n)}function se(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e.currentSession()];case 1:return[2,t.sent().getAccessToken().getJwtToken()];case 2:return t.sent(),[2,""];case 3:return[2]}}))}))}var oe,ce,ue=P,pe=k.default(oe||(oe=F(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),de=function(){function e(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=ue.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return e.prototype.verifyCognito=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,se(this.auth)];case 1:return(e=a.sent())?[4,fetch("https://cognito-idp.ap-southeast-2.amazonaws.com/",{method:"POST",mode:"cors",cache:"no-cache",headers:{"x-amz-target":"AWSCognitoIdentityProviderService.GetUser","x-amz-user-agent":"aws-amplify/0.1.x js","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({AccessToken:e})})]:[2];case 2:if(t=a.sent(),n=Date.now(),r=ue(t.headers.get("Date")).valueOf(),i=n+this.offsetMs,Math.abs(i-r)>this.MAX_DIFF_MSEC)throw new W("Server time does not match independent source. ServerTime: "+i+", Cognito time: "+r);return this.verified=!0,[2]}}))}))},e.prototype.refresh=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:pe}).toPromise()];case 1:return t=a.sent(),n=Date.now(),U(t.errors),r=parseInt(t.data.serverTime.timestamp,10),i=n-e,this.offsetMs=Math.round(r-(e+i/2)),this.VERIFY_ENABLED?[4,this.verifyCognito()]:[3,3];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},e.prototype.serverNow=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,se(this.auth)]:[3,2]:[3,3];case 1:t=n.sent(),n.label=2;case 2:t&&(e=!0),n.label=3;case 3:return e?[4,this.refresh()]:[3,5];case 4:n.sent(),n.label=5;case 5:return[2,Date.now()+this.offsetMs]}}))}))},e.prototype.now=function(){return null===this.offsetMs?(console.error("Server time offset not known. You must await serverNow() first. Returning local clock instead."),Date.now()):Date.now()+this.offsetMs},e.prototype.date=function(){return new Date(this.now())},e}();de.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new de(t.ɵɵinject(s.AuthClass),t.ɵɵinject(n.Apollo))},token:de,providedIn:"root"}),de.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],de.ctorParameters=function(){return[{type:s.AuthClass},{type:n.Apollo}]},function(e){e.JSON="JSON",e.COMPACT="COMPACT"}(ce||(ce={}));var le={payloadType:"json",returnOnlyPayload:!0},ye={payloadType:"json",returnOnlyPayload:!0,serializations:[ce.JSON]};var he=function(){function e(e){this.timeService=e}return e.prototype.decrypt=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(s){switch(s.label){case 0:if(r={algorithms:["dir","A*GCM","RSA-OAEP-*"]},n=Object.assign(Object.assign({},ye),n),e.jwk&&(e=e.jwk),"string"==typeof t&&n.serializations.includes(ce.JSON))try{t=JSON.parse(t)}catch(e){if(!n.serializations.includes(ce.COMPACT))throw e;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,a.JWE.createDecrypt(e,r).decrypt(t)];case 1:return(i=s.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i]}}))}))},e.prototype.encryptToString=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return r=(n=JSON).stringify,[4,this.encrypt(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},e.prototype.encrypt=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s;return j(this,(function(o){switch(o.label){case 0:if(null==t)throw new Error("Encrypting null/undefined content.");return t instanceof ArrayBuffer||(t=(new TextEncoder).encode(JSON.stringify(t))),r=(n=a.JWE).createEncrypt,i={contentAlg:"A256GCM"},s={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(i.fields=(s.timestamp=o.sent(),s),i),e]).update(t).final()]}}))}))},e.prototype.sign=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,o;return j(this,(function(c){switch(c.label){case 0:return i=(r=a.JWS).createSign,s={},o={},[4,this.timeService.serverNow()];case 1:return n=i.apply(r,[(s.fields=(o.timestamp=c.sent(),o),s),e]),t instanceof Buffer?n.update(t):n.update(JSON.stringify(t),"utf8"),[2,n.final()]}}))}))},e.prototype.signToString=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return r=(n=JSON).stringify,[4,this.sign(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},e.prototype.verify=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,s;return j(this,(function(o){switch(o.label){case 0:r={algorithms:["RS*"]},n=Object.assign(Object.assign({},le),n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,a.JWS.createVerify(e,r).verify(t)];case 2:return(i=o.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i];case 3:throw s=o.sent(),new B("Bad signature: "+s);case 4:return[2]}}))}))},e.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return A(this,void 0,void 0,(function(){var e,i,a,s;return j(this,(function(o){switch(o.label){case 0:return a=(i=JSON).stringify,[4,this.encrypt(n,t)];case 1:return e=a.apply(i,[o.sent()]),[4,this.sign(r,e)];case 2:return delete(s=o.sent()).payload,[2,{cipher:e,sig:JSON.stringify(s)}]}}))}))},e.prototype.decodePayload=function(e,t){switch(e){case"json":return JSON.parse((new TextDecoder).decode(t));case"ArrayBuffer":return t;default:throw new q("Unknown payloadType: "+e)}},e}();he.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new he(t.ɵɵinject(de))},token:he,providedIn:"root"}),he.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],he.ctorParameters=function(){return[{type:de}]};var fe=function(){function e(){this.kcCrypto=window.crypto}return e.prototype.toHex=function(e){return Array.from(new Uint8Array(e)).map((function(e){return e.toString(16).padStart(2,"0")})).join("")},e.prototype.stringDigest=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return n=new TextEncoder,r=n.encode(t),[4,this.kcCrypto.subtle.digest(e,r)];case 1:return i=a.sent(),[2,this.toHex(i)]}}))}))},e}();fe.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new fe},token:fe,providedIn:"root"}),fe.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var ve=function(){function e(e){this.webCryptoService=e,this.MIN_PASS_IDP_PBKDF_ITER=1e5,this.MIN_PASS_KEY_PBKDF_ITER=1e5,this.MIN_LBOP_KEY_PBKDF_ITER=1e5,this.DEFAULT_PASS_IDP_PBKDF_ITER=this.MIN_PASS_IDP_PBKDF_ITER,this.DEFAULT_PASS_KEY_PBKDF_ITER=this.MIN_PASS_KEY_PBKDF_ITER,this.DEFAULT_LBOP_KEY_PBKDF_ITER=this.MIN_LBOP_KEY_PBKDF_ITER,this.kcCrypto=this.webCryptoService.kcCrypto}return e.asKey=function(e,t,n){return a.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new q("digits <= 0");var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e);return this.kcCrypto.getRandomValues(n),n=n.map((function(e){return t.charCodeAt(e%t.length)})),String.fromCharCode.apply(null,n)},e.prototype.randomDigitsNoZeros=function(e){return this.randomChoices([1,2,3,4,5,6,7,8,9],e).join("")},e.prototype.randomChoices=function(e,t){if(e.length<=1)throw new q("array.length <= 0");if(t<=0)throw new q("chooseN <= 0");var n=new Uint32Array(t);this.kcCrypto.getRandomValues(n);var r=[];return n.forEach((function(t){return r.push(e[t%e.length])})),r},e.prototype.createSalt=function(){return this.randomString(16)},e.prototype.createKey=function(){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return delete(n=r.sent()).ext,delete n.key_ops,[2,e.asKey(n)]}}))}))},e.prototype.createSignKey=function(){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"HMAC",hash:{name:"SHA-512"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.createPkcKey=function(){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.createPkcSignKey=function(){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.kcCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.importPassword=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){return t=new TextEncoder,[2,this.kcCrypto.subtle.importKey("raw",t.encode(e),"PBKDF2",!1,["deriveKey"])]}))}))},e.prototype.deriveKey=function(t){var n=t.password,r=t.salt,i=t.iterations,a=t.kid;return A(this,void 0,void 0,(function(){var t,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.kcCrypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode(r),iterations:i,hash:"SHA-256"},n,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=o.sent(),[4,this.kcCrypto.subtle.exportKey("jwk",t)];case 2:return s=o.sent(),a&&(s.kid=a),[4,e.asKey(s)];case 3:return[2,{jwk:o.sent()}]}}))}))},e.prototype.derivePassIdp=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new te("The number of PassIdp key derivation iterations sent from the server ("+e.iterations+") is lower than the minimum ("+this.MIN_PASS_IDP_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.derivePassKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new te("The number of PassKey key derivation iterations sent from the server("+e.iterations+") is lower than the minimum("+this.MIN_PASS_KEY_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.deriveLbopKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new te("The number of LbopKey key derivation iterations sent from the server("+e.iterations+") is lower than the minimum("+this.MIN_LBOP_KEY_PBKDF_ITER+")");return[2,this.deriveKey(e)]}))}))},e.prototype.createKid=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return e={salt:this.createSalt()},[4,this.createKid()];case 1:return[2,(e.kid=t.sent(),e.iterations=this.DEFAULT_PASS_KEY_PBKDF_ITER,e)]}}))}))},e.prototype.createLbopKeyParams=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return e={salt:this.createSalt()},[4,this.createKid()];case 1:return[2,(e.kid=t.sent(),e.iterations=this.DEFAULT_PASS_KEY_PBKDF_ITER,e)]}}))}))},e}();ve.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ve(t.ɵɵinject(fe))},token:ve,providedIn:"root"}),ve.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ve.ctorParameters=function(){return[{type:fe}]};var me=new t.InjectionToken("KC_CONFIG"),ge=[e.KcErrorCode.CONCURRENT_ACCESS];function Se(e,t){var n;return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return[4,se(e)];case 1:return r=a.sent(),i=null===(n=t.debug)||void 0===n?void 0:n.username,[2,{withCredentials:!0,headers:Object.assign(Object.assign({},r&&{authorization:"Bearer "+r}),i&&{"x-kc-dev-user":i})}]}}))}))}var Ie=function(e,t){var n=p.setContext((function(n,r){var i=r.headers;return A(void 0,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,Se(t,e)];case 1:return n=r.sent(),[2,Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},i),n.headers)})]}}))}))})),r=new d.RetryLink({delay:{initial:300,max:1/0,jitter:!0},attempts:{max:3,retryIf:function(e,t){return!!(e instanceof i&&e.errors.some((function(e){var t;return ge.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})))}}}),i=function(e){function t(t){var n=e.call(this,t.map((function(e){return e.message})).join(", "))||this;return n.errors=t,n}return R(t,e),t}(Error),a=new u.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return ge.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new i(e.errors);return e}))})),s=u.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:u.from([r,a,n,s]),cache:new u.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{fetchPolicy:"no-cache",errorPolicy:"all"}}},e.apolloConfig)},Ce=function(){function e(e,n,r,i){this.keyFactory=e,this.cookieService=n,this.encryptionService=r,this.injector=i,this.KEY_PREFIX="lrSession-",this.cookieSecure=!0,this.serverSessionEncryptionKey=null,t.isDevMode()&&this.setCookieSecure(!1)}return e.prototype.setServerSessionEncryptionKey=function(e){this.serverSessionEncryptionKey=e},e.prototype.clearServerSessionEncryptionKey=function(){this.serverSessionEncryptionKey=null},e.prototype.getCookieParams=function(){return{path:"/",domain:null,secure:this.cookieSecure,sameSite:"Lax"}},e.prototype.clear=function(){var e=this;Object.keys(this.cookieService.getAll()).forEach((function(t){t.startsWith(e.KEY_PREFIX)&&e.deletePrefixedName(t)})),Object.keys(localStorage).forEach((function(t){t.startsWith(e.KEY_PREFIX)&&e.deletePrefixedName(t)}))},e.prototype.setCookieSecure=function(e){if(this.cookieSecure=e,!e){if(!t.isDevMode())throw new q("Can not set PersistService cookie secure flag to false in production mode.");console.warn("The cookie secure flag in persistService has been set to false, set it to true in production mode")}},e.prototype.prefixName=function(e){return this.KEY_PREFIX+e},e.prototype.delete=function(e){this.deletePrefixedName(this.prefixName(e))},e.prototype.deletePrefixedName=function(e){var t=this.getCookieParams();this.cookieService.delete(e,t.path,t.domain,t.secure,t.sameSite),localStorage.removeItem(e)},e.prototype.set=function(e){var t=e.name,n=e.value,r=e.serverSession,i=e.expiry;return A(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return e=this.prefixName(t),r?(s={serverSession:!0},[4,this.encryptionService.encryptToString(this.serverSessionEncryptionKey,n)]):[3,2];case 1:return s.data=d.sent(),a=s,[3,3];case 2:a={data:n},d.label=3;case 3:return i?[4,this.keyFactory.createKey()]:[3,6];case 4:return o=d.sent(),a.expiry=i.toISOString(),c=a,[4,this.encryptionService.encryptToString(o,a.data)];case 5:c.data=d.sent(),u={key:o.toJSON(!0)},p=this.getCookieParams(),this.cookieService.set(e,JSON.stringify(u),i,p.path,p.domain,p.secure,p.sameSite),d.label=6;case 6:return localStorage.setItem(e,JSON.stringify(a)),[2]}}))}))},e.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:t=this.prefixName(e),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getImpl(t)];case 2:return null==(n=i.sent())&&this.deletePrefixedName(t),[2,n];case 3:throw r=i.sent(),this.deletePrefixedName(t),r;case 4:return[2]}}))}))},e.prototype.getImpl=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return(t=localStorage.getItem(e))?(n=JSON.parse(t)).expiry?(i=this.cookieService.get(e))?(a=JSON.parse(i),[4,ve.asKey(a.key)]):(console.log("No cookie."),[2,null]):[3,3]:[2,null];case 1:return s=o.sent(),[4,this.encryptionService.decrypt(s,n.data)];case 2:return r=o.sent(),[3,4];case 3:r=n.data,o.label=4;case 4:return n.serverSession?[4,this.encryptionService.decrypt(this.serverSessionEncryptionKey,r)]:[3,6];case 5:r=o.sent(),o.label=6;case 6:return[2,r]}}))}))},e}();Ce.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ce(t.ɵɵinject(ve),t.ɵɵinject(l.CookieService),t.ɵɵinject(he),t.ɵɵinject(t.INJECTOR))},token:Ce,providedIn:"root"}),Ce.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ce.ctorParameters=function(){return[{type:ve},{type:l.CookieService},{type:he},{type:t.Injector}]};var be,we,Ke=function(){function e(e,t){this.config=e,this.persistService=t,this.STORE_MASTER_KEY="masterKey",this.MIN_PASS_IDP_PBKDF_ITER=1e5,this.MIN_PASS_KEY_PBKDF_ITER=1e5,this.MIN_LBOP_KEY_PBKDF_ITER=1e5,this.DEFAULT_PASS_IDP_PBKDF_ITER=this.MIN_PASS_IDP_PBKDF_ITER,this.DEFAULT_PASS_KEY_PBKDF_ITER=this.MIN_PASS_KEY_PBKDF_ITER,this.DEFAULT_LBOP_KEY_PBKDF_ITER=this.MIN_LBOP_KEY_PBKDF_ITER,this.resetKeys()}return e.prototype.resetKeys=function(){this.keys=null,this.masterKey=null},e.prototype.purgeKeys=function(){this.resetKeys(),this.persistService.clear()},e.prototype.setKeys=function(e){this.keys=e},Object.defineProperty(e.prototype,"currentPassKey",{get:function(){return this.keys.passKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentMasterKey",{get:function(){return this.keys.masterKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRootKey",{get:function(){return this.keys.rootKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentPxk",{get:function(){return this.keys.pxk},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSigPxk",{get:function(){return this.keys.sigPxk},enumerable:!1,configurable:!0}),e.prototype.expiresAfter=function(e){return new Date(Date.now()+1e3*e)},e.prototype.persistMasterKey=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return n={id:e.id,jwk:e.jwk.toJSON(!0)},this.masterKey=e,[4,this.persistService.set({name:this.STORE_MASTER_KEY,value:n,expiry:this.expiresAfter(t),serverSession:!this.config.disableSessionEncryptionKey})];case 1:return r.sent(),[2]}}))}))},e.prototype.setMasterKeyExpiresAfterSeconds=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.persistService.get(this.STORE_MASTER_KEY)];case 1:if(null==(t=n.sent()))throw new ee("Can not find masterKey in persisted storage using name: "+this.STORE_MASTER_KEY);return[4,this.persistService.set({name:this.STORE_MASTER_KEY,value:t,expiry:this.expiresAfter(e),serverSession:!this.config.disableSessionEncryptionKey})];case 2:return n.sent(),[2]}}))}))},e.prototype.loadMasterKey=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return this.masterKey?[3,3]:[4,this.persistService.get(this.STORE_MASTER_KEY)];case 1:if(!(t=r.sent()))throw new ee("Could not find masterKey in persisted storage");if(t.id!==e)throw new ee("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,ve.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();Ke.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ke(t.ɵɵinject(me),t.ɵɵinject(Ce))},token:Ke,providedIn:"root"}),Ke.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ke.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:Ce}]},function(e){e.Key="key",e.PassKey="passKey"}(be||(be={})),function(e){e.KeyLink="keyLink",e.PassKeyLink="passKeyLink"}(we||(we={}));var ke=function(){function e(e,t,n){this.encryptionService=e,this.keyService=t,this.keyFactory=n,this.purgeKeys()}return e.prototype.purgeKeys=function(){this.graph=new r.Graph},e.prototype.populateKeys=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return n=(t=this.keyService).setKeys,r={passKey:e.passKey},[4,this.keyService.loadMasterKey(e.masterKey.id)];case 1:return r.masterKey=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.rootKey.id)];case 2:return r.rootKey=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.pxk.id)];case 3:return r.pxk=i.sent(),[4,this.unwrapKey(e.masterKey.id,e.sigPxk.id)];case 4:return n.apply(t,[(r.sigPxk=i.sent(),r)]),[2]}}))}))},e.prototype.hasKey=function(e){return!!this.graph.node(e)},e.prototype.getNode=function(e,t){var n=this.graph.node(e);if(!n)throw new ee("Key graphs does not contain key id: "+e);if(n.type!==t)throw new Q("Key with id "+e+" is not of type "+t);return n.data},e.prototype.key=function(e){return this.getNode(e,be.Key)},e.prototype.passKey=function(e){return this.getNode(e,be.PassKey)},e.prototype.addKeys=function(e){var t,n,r,i,a,s;if(e.keys)try{for(var o=T(e.keys),c=o.next();!c.done;c=o.next()){var u=c.value;if(!this.graph.hasNode(u.id)){var p={type:be.Key,data:K.default.cloneDeep(u)};this.graph.setNode(u.id,p)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}if(e.keyLinks)try{for(var d=T(e.keyLinks),l=d.next();!l.done;l=d.next()){var y=l.value;if(!this.graph.hasEdge(y.wrappingKeyId,y.keyId)){var h={type:we.KeyLink,data:K.default.cloneDeep(y)};this.graph.setEdge(y.wrappingKeyId,y.keyId,h)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}if(e.passKeyLinks)try{for(var f=T(e.passKeyLinks),v=f.next();!v.done;v=f.next()){var m=v.value;if(!this.graph.hasEdge(m.passKeyId,m.keyId)){h={type:we.PassKeyLink,data:K.default.cloneDeep(m)};this.graph.setEdge(m.passKeyId,m.keyId,h)}}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}},e.prototype.tracePath=function(e,t){var n=[],r=t;if(!e[r].predecessor)return null;for(;e[r].predecessor;){var i=e[r].predecessor;n.push(this.graph.edge(i,r)),r=i}return n.reverse(),n},e.prototype.getPath=function(e,t){if(!e||"string"!=typeof e)throw new Y("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new Y("Param keyId wrong format: "+t);var n=w.default.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},e.prototype.getJwkKey=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.getKey(e,t)];case 1:return[2,n.sent().jwk]}}))}))},e.prototype.getKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return n="string"==typeof e?e:null==e?void 0:e.id,this.hasKey(n)||!t?[3,2]:[4,t()];case 1:n=i.sent(),i.label=2;case 2:return(r=this.key(n)).jwk?[2,r]:[2,this.unwrapKey(this.keyService.currentMasterKey.id,n)]}}))}))},e.prototype._unwrapLink=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a;return j(this,(function(s){switch(s.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=s.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=s.sent(),s.label=4;case 4:return a=n,[4,ve.asKey(i)];case 5:return a.jwk=s.sent(),n.task=null,[2]}}))}))},e.prototype._unwrap=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return j(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=T(t),r=n.next(),u.label=1;case 1:return r.done?[3,4]:(i=r.value,(a=this.key(i.data.keyId)).jwk?(e=a.jwk,[3,3]):(a.task||(a.task=this._unwrapLink(e,i,a)),[4,a.task]));case 2:u.sent(),e=a.jwk,u.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return s=u.sent(),o={error:s},[3,7];case 6:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 7:return[2,e]}}))}))},e.prototype.unwrapWithPassKey=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return r=this.getPath(e,n),i={id:n},[4,this._unwrap(t,r)];case 1:return[2,(i.jwk=a.sent(),i)]}}))}))},e.prototype.unwrapKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.keyService.loadMasterKey(e)];case 1:return n=a.sent(),e===t?[2,n]:(r=this.getPath(n.id,t),i={id:t},[4,this._unwrap(n.jwk,r)]);case 2:return[2,(i.jwk=a.sent(),i)]}}))}))},e.prototype.decryptFromString=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return t?[4,this.getJwkKey(e)]:[3,3];case 1:return r=i.sent(),[4,this.encryptionService.decrypt(r,JSON.parse(t),n)];case 2:return[2,i.sent()];case 3:return[2,null]}}))}))},e.prototype.decryptFile=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getJwkKey(e)];case 1:return n=r.sent(),[4,this.encryptionService.decrypt(n,t,{payloadType:"ArrayBuffer"})];case 2:return[2,r.sent()]}}))}))},e.prototype.encryptToString=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return null==t?[2,null]:(r=function(e){return e.id&&e.jwk?e.jwk:e.keystore&&e.length&&e.kty&&e.kid&&e.alg?e:null}(e))?[3,2]:[4,this.getJwkKey(e)];case 1:r=i.sent(),i.label=2;case 2:return n=r,[2,this.encryptionService.encryptToString(n,t)]}}))}))},e.prototype.wrapKey=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){if(!function(e){return"oct"===e.kty}(t))throw new q("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},e.prototype.encryptWithNewKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=a.sent(),[4,this.encryptToString(e,n.toJSON(!0))];case 2:return r=a.sent(),[4,this.encryptToString(n,t)];case 3:return i=a.sent(),[2,{key:n,wrappingKeyId:e,wrappedKey:r,cipher:i}]}}))}))},e}();ke.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ke(t.ɵɵinject(he),t.ɵɵinject(Ke),t.ɵɵinject(ve))},token:ke,providedIn:"root"}),ke.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ke.ctorParameters=function(){return[{type:he},{type:Ke},{type:ve}]};var Pe=function(){function e(e,t){this.apollo=e,this.keyGraph=t}return e.prototype.addKeys=function(e){e.data.keyGraph&&this.keyGraph.addKeys(e.data.keyGraph)},e.prototype.query=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return U((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return U((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();function Ee(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new G("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function De(e){return Ee(e,"query")}function Re(e){return Ee(e,"mutation")}function Me(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Oe(e){return{kind:"Name",value:e}}function Ae(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function je(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return k.default.apply(void 0,$([e],t))}Pe.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Pe(t.ɵɵinject(n.Apollo),t.ɵɵinject(ke))},token:Pe,providedIn:"root"}),Pe.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Pe.ctorParameters=function(){return[{type:n.Apollo},{type:ke}]};var Te,Ne,$e,Fe,Ue,Le,xe,_e,Je="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",qe=k.default(Te||(Te=F(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),Je),Ge="keyGraph "+Je,Ve="keyGraph: fetchKeyGraph "+Je,Be=k.default(Ne||(Ne=F(["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),qe),Qe=k.default($e||($e=F(["\n query Directory($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n directory(id: $id) {\n id\n keyId\n plainMeta\n cipherMeta\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query Directory($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n directory(id: $id) {\n id\n keyId\n plainMeta\n cipherMeta\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),qe),We=k.default(Fe||(Fe=F(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Ze=k.default(Ue||(Ue=F(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),He=k.default(Le||(Le=F(["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),Ye=k.default(xe||(xe=F(["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),ze=k.default(_e||(_e=F(["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),Xe=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function et(e){var t=e.ngZoneName,n=e.exceptLastPromise,r=void 0===n||n,i=e.excludeMethods,a=void 0===i?[]:i,s=e.patchSetters,o=void 0===s||s;return function(e){function n(n,i){var a=this;if(!this[t])throw new G("RunOutsideAngular decorator requires that "+e.name+" inject NgZone as "+t);var s=this[t].runOutsideAngular((function(){return n.apply(a,i)}));return r&&(null==s?void 0:s.then)?Promise.resolve(s):s}return a=$(a,Xe),Object.getOwnPropertyNames(e.prototype).filter((function(e){return!a.includes(e)})).forEach((function(t){if(o&&Object.getOwnPropertyDescriptor(e.prototype,t).set){var r=Object.getOwnPropertyDescriptor(e.prototype,t).set;Object.defineProperty(e.prototype,t,{set:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,[r,e])}})}if("function"==typeof e.prototype[t]){var i=e.prototype[t];e.prototype[t]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,[i,e])}}})),e}}var tt={hasKeys:!0};function nt(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s=this;return j(this,(function(o){switch(o.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,Promise.all(e.edges.map((function(e){return A(s,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,t(e.node)];case 1:return[2,r.apply(n,i.concat([(a.node=s.sent(),a)]))]}}))}))})))];case 1:return[2,r.apply(n,i.concat([(a.edges=o.sent(),a)]))]}}))}))}function rt(e,t){return Object.assign(Object.assign({},e),{path:$(e.path,[t])})}e.CommonProcessorsService=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.series=function(e){var t=this;return function(n){var r=n.field,i=n.context,a=n.options;return A(t,void 0,void 0,(function(){var t,n,s,o,c;return j(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),t=T(e),n=t.next(),u.label=1;case 1:return n.done?[3,4]:[4,(0,n.value)({field:r,context:i,options:a})];case 2:r=u.sent(),u.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return s=u.sent(),o={error:s},[3,7];case 6:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 7:return[2,r]}}))}))}},e.prototype.makeJsonParseProcessor=function(e){var t=void 0===e?{}:e,n=t.plainFieldName,r=t.jsonFieldSuffix,i=n+(void 0===r?"Json":r);return function(e){var t,r=e.field;if(null==r[n]||i in r)return r;try{return Object.assign(Object.assign({},r),((t={})[i]=JSON.parse(r[n]),t))}catch(e){return r}}},e.prototype.makeDecryptionProcessor=function(e){var t=this,n=void 0===e?{}:e,r=n.cipherFieldName,i=n.clearFieldSuffix,a=void 0===i?"ClearJson":i,s=n.getKeyId,o=void 0===s?null:s,c=r+a;return function(e){return A(t,void 0,void 0,(function(){var t,n,i,a,s,u;return j(this,(function(p){switch(p.label){case 0:return n=e.field,i=e.context,e.options.hasKeys?!(a=n[r])||c in n?[2,n]:o?[4,o(e)]:[3,2]:[2,n];case 1:return u=p.sent(),[3,3];case 2:u=n.keyId||(null===(t=n.key)||void 0===t?void 0:t.id),p.label=3;case 3:if(!(s=u))throw new G("Query response does not contain "+(o?"key-id":"keyId or key.id")+" field: "+i.path.join("."));return[2,this.keyGraph.decryptFromString(s,a).then((function(e){var t;return Object.assign(Object.assign({},n),((t={})[c]=e,t))}))]}}))}))}},e}(),e.CommonProcessorsService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.CommonProcessorsService(t.ɵɵinject(t.NgZone),t.ɵɵinject(ke))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:t.NgZone},{type:ke}]},e.CommonProcessorsService=O([et({ngZoneName:"ngZone"})],e.CommonProcessorsService),e.ɵg=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUserNode=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,a,s=this;return j(this,(function(o){switch(o.label){case 0:return(r=null===(t=e.pxk)||void 0===t?void 0:t.id)?[4,this.keyGraph.getKey(e.pxk.id)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return n=r,i=Object.assign({},e),n&&e.approvals?(a=i,[4,Promise.all(e.approvals.map((function(e){return s.processTpPasswordResetUserApprovalNode(e,n)})))]):[3,4];case 3:a.approvals=o.sent(),o.label=4;case 4:return[2,i]}}))}))},e.prototype.processTpPasswordResetUserApprovalNode=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return n=Object.assign({},e),e.receiverCipher&&(n.receiverCipherClearJson=this.keyGraph.decryptFromString(t,e.receiverCipher)),e.receiverCipherPartialAssemblyKey?(r=n,[4,this.keyGraph.decryptFromString(t,e.receiverCipherPartialAssemblyKey)]):[3,2];case 1:r.receiverCipherPartialAssemblyKeyClearJson=i.sent(),i.label=2;case 2:return[2,n]}}))}))},e.prototype.makeTpPasswordResetNodeProcessor=function(){var e=this;return function(t){var n=t.field;return A(e,void 0,void 0,(function(){var e,t;return j(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new V('If you request for field "assembly" in the TpPasswordResetNode, then you must also request the "applied" field');return t=e,[4,this.processTpAssemblyNode(n.assembly,n.applied)];case 1:t.assembly=r.sent(),r.label=2;case 2:return[2,e]}}))}))}},e.prototype.processTpAssemblyNode=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return j(this,(function(y){switch(y.label){case 0:return n=e.subjectKey,r=e.assemblyKey,i=e.assemblyCipherData,a=e.subAssemblies,c=(o=Object).assign,u=[Object.assign({},e)],p={},[4,nt(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=y.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=y.sent(),y.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return j(this,(function(l){switch(l.label){case 0:return r=e.subjectCipherData,i=e.approvers,o=(s=Object).assign,c=[Object.assign({},e)],u={},[4,nt(i,(function(e){return d.processTpAssemblyApproverNode(e,n)}))];case 1:return a=o.apply(s,c.concat([(u.approvers=l.sent(),u)])),n?[3,3]:r?(p=a,[4,this.keyGraph.decryptFromString(t,r)]):[3,3];case 2:p.subjectCipherDataClearJson=l.sent(),l.label=3;case 3:return[2,a]}}))}))},e.prototype.processTpAssemblyApproverNode=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,e]}))}))},e}(),e.ɵg.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵg(t.ɵɵinject(t.NgZone),t.ɵɵinject(ke))},token:e.ɵg,providedIn:"root"}),e.ɵg.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵg.ctorParameters=function(){return[{type:t.NgZone},{type:ke}]},e.ɵg=O([et({ngZoneName:"ngZone"})],e.ɵg),e.QueryProcessorService=function(){function e(e,t,n,r){this.ngZone=e,this.keyService=t,this.common=n,this.tpprProcessor=r,this.TYPENAME="__typename",this.processors={},this.registerProcessor("DirectoryNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("FileStateNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("ContactCardNode",n.makeDecryptionProcessor({cipherFieldName:"cipherData"})),this.registerProcessor("SharedContactCardNode",n.series([n.makeJsonParseProcessor({plainFieldName:"ownerPlainData"}),n.makeDecryptionProcessor({cipherFieldName:"ownerCipherData",getKeyId:function(e){return e.field.ownerKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"receiverCipherData",getKeyId:function(e){return e.field.receiverKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpPasswordResetNode",this.tpprProcessor.makeTpPasswordResetNodeProcessor()),this.registerProcessor("SharedTpClaimApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyAsApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioReceiverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverDirectoryNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioApproverAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"assemblyCipherData",getKeyId:function(e){return e.field.assemblyKey.id}})])),this.registerProcessor("ScenarioApproverSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioClaimantNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("TpSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("NotificationNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeJsonParseProcessor({plainFieldName:"plainData"})])),this.registerProcessor("UserNode",n.series([n.makeJsonParseProcessor({plainFieldName:"config"})])),this.registerProcessor("ReminderNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plain"})]))}return e.prototype.processQuery=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){return t=Object.assign(Object.assign({},tt),t),[2,ae(e,(function(e,r){return n.processField({field:e,context:{path:[r],processChildren:!0},options:t})}))]}))}))},e.prototype.processField=function(e){var t=e.field,n=e.context,r=e.options;return A(this,void 0,void 0,(function(){var e,i,a,s=this;return j(this,(function(o){if(null==t?void 0:t.then)throw new G("processField() should not receive thenable.");return null==t?[2,null]:(e={field:t,context:Object.assign(Object.assign({},n),{processChildren:!0}),options:r},t[this.TYPENAME]?((i=this.processors[t[this.TYPENAME]])&&(t=i(e)),a=function(e){return n.processChildren&&null!==e&&"object"==typeof e?ae(e,(function(e,t){return s.processField({field:e,context:rt(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=re(t.map((function(e,t){return s.processField({field:e,context:rt(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new G("Processor for field "+e+" already exists.");this.processors[e]=t},e}(),e.QueryProcessorService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.QueryProcessorService(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ke),t.ɵɵinject(e.CommonProcessorsService),t.ɵɵinject(e.ɵg))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:t.NgZone},{type:Ke},{type:e.CommonProcessorsService},{type:e.ɵg}]},e.QueryProcessorService=O([et({ngZoneName:"ngZone"})],e.QueryProcessorService);var it,at,st,ot=function(){function e(){var e=this;this._fulfilled=!1,this.promise=new Promise((function(t,n){e._resolve=t,e._reject=n})).finally((function(){e._fulfilled=!0}))}return Object.defineProperty(e.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fulfilled",{get:function(){return this._fulfilled},enumerable:!1,configurable:!0}),e}(),ct=De(k.default(it||(it=F(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],ut=function(){function e(){this._executed=!1,this.deferredPromise=new ot}return Object.defineProperty(e.prototype,"promise",{get:function(){return this.deferredPromise.promise},enumerable:!1,configurable:!0}),e.prototype.resolve=function(e){this.deferredPromise.resolve(e)},e.prototype.reject=function(e){this.deferredPromise.reject(e)},Object.defineProperty(e.prototype,"lrMutationData",{get:function(){return{mutation:this.mutation,variables:this.variables}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"executed",{get:function(){return this._executed},enumerable:!1,configurable:!0}),e.prototype.setExecuted=function(){if(this._executed)throw new Q("Already executed");this._executed=!0},e}(),pt=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return R(t,e),t.prototype.select=function(e){var n=i.cloneDeep(this.mutation),r=Re(n),a={};Me(e).forEach((function(e){a[e.name.value]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=Ae(t);a[n]&&(t.selectionSet.selections=[Object.assign(Object.assign({},ct),{name:Oe(n)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:$(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(ut),dt={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},lt=function(e){function t(t){var n=e.call(this)||this;n.lrMutations=t;var r=n.merge(),i=r.mutation,a=r.variables,s=r.prefixes;return n.mutation=i,n.variables=a,n.prefixes=s,n.descendants=n.getDescendants(),n}return R(t,e),t.create=function(e){return new t(e)},t.prototype.getDescendants=function(){var e=new Set,n=function(t){if(e.has(t))throw new G("Classes that are derived from LrMutationBase can not be used more than once in a merged mutation.");e.add(t)};return this.lrMutations.forEach((function(e){if(e instanceof pt)n(e);else{if(!(e instanceof t))throw new ne("LrMergeMutation can not handle class: "+e.constructor.name);e.descendants.forEach((function(e){return n(e)}))}})),e},t.prototype.resolve=function(t){for(var n=this,r=0;r<this.lrMutations.length;++r){var i=this.prefixes[r],a={};for(var s in t){if(s.startsWith(i))a[s.slice(i.length)]=t[s]}this.lrMutations[r].resolve(a)}Promise.all(this.lrMutations.map((function(e){return e.promise}))).then((function(t){e.prototype.resolve.call(n,t)}))},t.prototype.reject=function(t){e.prototype.reject.call(this,t),this.lrMutations.forEach((function(e){return e.reject(t)}))},t.prototype.setExecuted=function(){e.prototype.setExecuted.call(this),this.lrMutations.forEach((function(e){return e.setExecuted()}))},t.prototype.renameVariableDefinition=function(e,t){return Object.assign(Object.assign({},e),{variable:Object.assign(Object.assign({},e.variable),{name:Oe(t+e.variable.name.value)})})},t.prototype.renameVariableDefinitions=function(e,t){var n=this;return e.map((function(e){return n.renameVariableDefinition(e,t)}))},t.prototype.renameArgument=function(e,t){return"Variable"!==e.value.kind?e:Object.assign(Object.assign({},e),{value:Object.assign(Object.assign({},e.value),{name:Oe(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+Ae(e),i=e.arguments.map((function(e){return n.renameArgument(e,t)}));return Object.assign(Object.assign({},e),{alias:{kind:"Name",value:r},arguments:i})},t.prototype.renameFragmentSpread=function(e,t){return Object.assign(Object.assign({},e),{name:Oe(t+e.name.value)})},t.prototype.processSelection=function(e,t){switch(e.kind){case"FragmentSpread":return this.renameFragmentSpread(e,t);case"Field":return e.selectionSet?Object.assign(Object.assign({},e),{selectionSet:this.processSelectionSet(e.selectionSet,t)}):e;default:return e}},t.prototype.processSelectionSet=function(e,t){var n=this;return Object.assign(Object.assign({},e),{selections:e.selections.map((function(e){return n.processSelection(e,t)}))})},t.prototype.renameSelections=function(e,t){var n=this;return e.map((function(e){switch(e.kind){case"Field":return n.processSelection(n.renameField(e,t),t);default:return e}}))},t.prototype.renameFragmentDefinition=function(e,t){var n=Object.assign(Object.assign({},e),{name:Oe(t+e.name.value)});return e.selectionSet&&(n.selectionSet=this.processSelectionSet(e.selectionSet,t)),n},t.prototype.renameFragmentDefinitions=function(e,t){var n=this;return e.map((function(e){return n.renameFragmentDefinition(e,t)}))},t.prototype.merge=function(){var e=this,t=[],n=[],r={},a=[],s=[];this.lrMutations.forEach((function(i,o){var c,u;if(!(i instanceof ut))throw new G("An mutation in the array is not of type LrMutationBase.");var p=i.lrMutationData,d=p.mutation,l=p.variables,y=Re(d),h="item"+o+"_";y.name&&(h+=y.name.value+"_"),s.push(h),t=$(t,e.renameVariableDefinitions(y.variableDefinitions,h)),n=$(n,e.renameSelections(y.selectionSet.selections,h));try{for(var f=T(Object.keys(l)),v=f.next();!v.done;v=f.next()){var m=v.value;r[h+m]=l[m]}}catch(e){c={error:e}}finally{try{v&&!v.done&&(u=f.return)&&u.call(f)}finally{if(c)throw c.error}}var g=Me(d);a=$(a,e.renameFragmentDefinitions(g,h))}));var o=i.cloneDeep(dt),c=Re(o);return c.selectionSet.selections=n,c.variableDefinitions=t,o.definitions=$(o.definitions,a),{mutation:o,variables:r,prefixes:s}},t}(ut),yt=De(k.default(at||(at=F(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Ge)).selectionSet.selections[0],ht=De(k.default(st||(st=F(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Ve)).selectionSet.selections[0];e.ɵf=function(){function e(e,t,n,r){this.ngZone=e,this.apollo=t,this.keyGraph=n,this.queryProcessor=r,this.stats={queryCount:0,mutationCount:0}}return e.prototype.query=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return e=i.cloneDeep(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=De(e.query)).selectionSet.selections=$(t.selectionSet.selections,[yt])),e.name&&((t=De(e.query)).name={kind:"Name",value:e.name}),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,U(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.lrMutateImpl=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){if(null==t?void 0:t.variables)throw new ne('Unsupported field: "options.variables"');if(e.executed)throw new Q("LrMutation has already executed. LrMutation can only be used once in a lrMutate() call. Create new instances of LrMutation.");return e.setExecuted(),[2,this.apolloMutate(Object.assign(Object.assign({},t),e.lrMutationData)).then((function(t){return e.resolve(t),t})).catch((function(t){throw e.reject(t),t}))]}))}))},e.prototype.apolloMutate=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:i.cloneDeep(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Re(e.mutation)).selectionSet.selections=$(t.selectionSet.selections,[ht])),e.name&&((t=Re(e.mutation)).name={kind:"Name",value:e.name}),e.mutation=k.default(y.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,U(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return i.cloneDeep(this.stats)},e.prototype.addKeys=function(e){e.data.keyGraph&&(this.keyGraph.addKeys(e.data.keyGraph),delete e.data.keyGraph)},e.prototype.isIncludeKeyGraph=function(e){return null==e},e.prototype.lrMutate=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=lt).create,[4,Promise.all(e)]):[3,3];case 1:return n=i.apply(r,[s.sent()]),[4,this.lrMutateImpl(n,t)];case 2:return s.sent(),[2,n.promise];case 3:return[4,e];case 4:return a=s.sent(),[4,this.lrMutateImpl(a,t)];case 5:return s.sent(),[2,a.promise]}}))}))},e}(),e.ɵf.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵf(t.ɵɵinject(t.NgZone),t.ɵɵinject(n.Apollo),t.ɵɵinject(ke),t.ɵɵinject(e.QueryProcessorService))},token:e.ɵf,providedIn:"root"}),e.ɵf.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵf.ctorParameters=function(){return[{type:t.NgZone},{type:n.Apollo},{type:ke},{type:e.QueryProcessorService}]},e.ɵf=O([et({ngZoneName:"ngZone"})],e.ɵf);var ft,vt,mt,gt,St,It,Ct,bt,wt,Kt,kt,Pt,Et,Dt,Rt,Mt,Ot,At=function(){function t(t){this.lrGraphQL=t.get(e.ɵf)}return t.prototype.mutate=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();function jt(e){return e.edges.map((function(e){return e.node}))}(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED",(ft=e.PlanState||(e.PlanState={})).ENABLED="ENABLED",ft.DISABLED="DISABLED",(vt=e.AccessRoleChoice||(e.AccessRoleChoice={})).READER="READER",vt.WRITER="WRITER",vt.ADMIN="ADMIN",vt.DENY="DENY",vt.OWNER="OWNER",(mt=e.AccessRoleMethodChoice||(e.AccessRoleMethodChoice={})).INHERITED="INHERITED",mt.DIRECT="DIRECT",(gt=e.PermissionChoice||(e.PermissionChoice={})).CREATE="CREATE",gt.READ="READ",gt.UPDATE="UPDATE",gt.DELETE="DELETE",gt.SHARE="SHARE",gt.ARCHIVE="ARCHIVE",gt.ACCESS_ARCHIVED="ACCESS_ARCHIVED",gt.UNARCHIVE="UNARCHIVE",gt.SET_CONFIDENTIAL="SET_CONFIDENTIAL",(St=e.FileOperationField||(e.FileOperationField={})).CREATE="CREATE",St.READ="READ",St.UPDATE="UPDATE",St.REVERT="REVERT",St.DELETE="DELETE",(It=e.KeyExchangeOtkState||(e.KeyExchangeOtkState={})).OTK_INITIATED="OTK_INITIATED",It.OTK_ACCEPTED="OTK_ACCEPTED",It.OTK_COMPLETED="OTK_COMPLETED",(Ct=e.KeyExchangeState||(e.KeyExchangeState={})).IN_PROGRESS="IN_PROGRESS",Ct.COMPLETED="COMPLETED",Ct.DECLINED="DECLINED",Ct.CANCELLED="CANCELLED",Ct.DELETED="DELETED",(e.KeyExchangeMode||(e.KeyExchangeMode={})).OTK="OTK",(bt=e.TpAssemblyState||(e.TpAssemblyState={})).DISABLED="DISABLED",bt.ENABLED="ENABLED",bt.CLAIMED="CLAIMED",bt.APPROVED="APPROVED",bt.REJECTED="REJECTED",bt.EXPIRED="EXPIRED",bt.CANCELLED="CANCELLED",bt.RESET="RESET",(wt=e.TpClaimState||(e.TpClaimState={})).CLAIMED="CLAIMED",wt.APPROVED="APPROVED",wt.REJECTED="REJECTED",wt.EXPIRED="EXPIRED",wt.CANCELLED="CANCELLED",wt.RESET="RESET",(Kt=e.TpClaimApproverState||(e.TpClaimApproverState={})).CLAIMED="CLAIMED",Kt.APPROVED="APPROVED",Kt.REJECTED="REJECTED",(kt=e.LockState||(e.LockState={})).UNLOCKED="UNLOCKED",kt.MUTEX_LOCKED="MUTEX_LOCKED",(Pt=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",Pt.ENABLED="ENABLED",Pt.CLAIMED="CLAIMED",Pt.APPROVED="APPROVED",(Et=e.ClaimState||(e.ClaimState={})).CLAIMED="CLAIMED",Et.EXPIRED="EXPIRED",Et.APPROVED="APPROVED",Et.REJECTED="REJECTED",Et.CANCELLED="CANCELLED",Et.RESET="RESET",(Dt=e.ClaimApproverState||(e.ClaimApproverState={})).CLAIMED="CLAIMED",Dt.APPROVED="APPROVED",Dt.REJECTED="REJECTED",(Rt=e.ScenarioLastClaimState||(e.ScenarioLastClaimState={})).CLAIMED="CLAIMED",Rt.APPROVED="APPROVED",Rt.REJECTED="REJECTED",Rt.EXPIRED="EXPIRED",Rt.CANCELLED="CANCELLED",Rt.RESET="RESET",(Mt=e.LinkTypeField||(e.LinkTypeField={})).HARD="HARD",Mt.SOFT="SOFT",(Ot=e.PlanStateField||(e.PlanStateField={})).TRIALLING="TRIALLING",Ot.ACTIVE="ACTIVE",Ot.CANCELLED="CANCELLED",Ot.EXPIRED="EXPIRED";var Tt,Nt=function(e){var t=window.fetch;return function(n,r){var i=function(){return t(n,r)};if(!r||!r.headers||!r.headers["X-Amz-Target"])return i();var a=r.headers["X-Amz-Target"].split(".");if(a.length<2||"AWSCognitoIdentityProviderService"!==a[0])return i();var s=JSON.parse(r.body);if(s&&s.ClientMetadata&&"true"===s.ClientMetadata.noProxy)return i();var o=!1;if("RespondToAuthChallenge"===a[1]){if(s&&"NEW_PASSWORD_REQUIRED"===s.ChallengeName)return i();o=!0}else"InitiateAuth"===a[1]&&"REFRESH_TOKEN_AUTH"===s.AuthFlow&&(o=!0);return o?t(e+"auth/proxy/",Object.assign(Object.assign({},r),{credentials:"include"})):i()}},$t=function(e,t){var n=e.authUrl,r=e.userPoolId,i=e.userPoolWebClientId;return function(){var e=r.split("_");if(e.length<2)throw new Error("userPoolId should have this format: {aws-region}_xxxxx");window.fetch=Nt(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}},Ft=function(e){function t(){var t=e.apply(this,$(arguments))||this;return t.isTpPasswordResetUser=!1,t}return R(t,e),t}(h.CognitoUser),Ut=function(){},Lt=function(){};!function(e){e.NONE="none",e.NEW_PASSWORD="new-password",e.OLD_PASSWORD="old-password"}(e.RecoveryStatus||(e.RecoveryStatus={})),(Tt=e.Config||(e.Config={}))[Tt.TIMEOUT=.01]="TIMEOUT",Tt[Tt.IDLE=1200]="IDLE",Tt[Tt.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var xt=function(){function t(e,t,n,r,i,a){this.config=e,this.http=t,this.idle=n,this.keepalive=r,this.keyService=i,this.auth=a,this.IDLE_EXPIRY_KEY="ng2Idle.main.expiry",this.IDLING_KEY="ng2Idle.main.idling",this.initCalled=!1}return t.prototype.assertInit=function(){if(!this.initCalled)throw new Q("Call IdleService.init() first.")},t.prototype.init=function(t){return A(this,void 0,void 0,(function(){var n,r=this;return j(this,(function(i){switch(i.label){case 0:if(this.initCalled)throw new Q("IdleService.init() can only be called once. IdleService.start() calls init() with default values if init() has not been called yet.");if(this.initCalled=!0,(t=Object.assign({onTimeout:null,onKeepalive:null,idleSec:e.Config.IDLE,timeoutSec:e.Config.TIMEOUT,keepAliveIntervalSec:e.Config.KEEP_ALIVE_INTERVAL},t)).timeoutSec<.01)throw new q("Minimum value for IdleService.init({ timeoutSec }) is 0.01");return this.onTimeout=t.onTimeout,this.onKeepalive=t.onKeepalive,this.idle.setIdle(t.idleSec),this.idle.setTimeout(t.timeoutSec),this.idle.setInterrupts(g.DEFAULT_INTERRUPTSOURCES),this.idle.onIdleEnd.subscribe((function(){return console.log("Idle stopped")})),this.idle.onIdleStart.subscribe((function(){return console.log("Idle started")})),this.idle.onTimeout.subscribe((function(){return A(r,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())];case 1:return e.sent(),[2]}}))}))})),this.idle.onTimeoutWarning.subscribe((function(e){return console.log("Will timeout in "+e+" seconds!")})),this.keepalive.interval(t.keepAliveIntervalSec),console.log("Keep alive interval set at: "+e.Config.KEEP_ALIVE_INTERVAL+" seconds"),this.keepalive.onPing.subscribe((function(){return r.onPing()})),(n=localStorage.getItem(this.IDLE_EXPIRY_KEY))&&parseInt(n,10)+1e3*this.idle.getTimeout()<Date.now()?(this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return A(this,void 0,void 0,(function(){var e,t,n;return j(this,(function(r){switch(r.label){case 0:return t=(e=this.http).post,n=[this.config.authUrl+"auth/keepalive/",null],[4,Se(this.auth,this.config)];case 1:return[4,t.apply(e,n.concat([r.sent()])).toPromise()];case 2:return[2,{keepaliveResult:r.sent(),expiresAfterSeconds:this.idle.getIdle()+this.idle.getTimeout()+this.keepalive.interval()}]}}))}))},t.prototype.persistMasterKey=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.keepalivePost()];case 1:return t=n.sent().expiresAfterSeconds,[4,this.keyService.persistMasterKey(e,t)];case 2:return n.sent(),console.log("setMasterKey() done"),[2]}}))}))},t.prototype.onPing=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return console.log("Keep alive triggered at time: "+Date.now()+". Interval set at: "+this.keepalive.interval()+" seconds"),[4,this.keepalivePost()];case 1:return e=t.sent().expiresAfterSeconds,[4,this.keyService.setMasterKeyExpiresAfterSeconds(e)];case 2:return t.sent(),[4,Promise.resolve(this.onKeepalive&&this.onKeepalive())];case 3:return t.sent(),[2]}}))}))},t.prototype.start=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return this.initCalled?[3,2]:[4,this.init()];case 1:e.sent(),e.label=2;case 2:return this.idle.isRunning()?[2]:[4,this.onPing()];case 3:return e.sent(),this.idle.watch(),[2]}}))}))},t.prototype.stop=function(){this.idle.stop(),this.reset()},t.prototype.reset=function(){localStorage.removeItem(this.IDLE_EXPIRY_KEY),localStorage.removeItem(this.IDLING_KEY)},t}();xt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new xt(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(g.Idle),t.ɵɵinject(S.Keepalive),t.ɵɵinject(Ke),t.ɵɵinject(s.AuthClass))},token:xt,providedIn:"root"}),xt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],xt.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:g.Idle},{type:S.Keepalive},{type:Ke},{type:s.AuthClass}]};var _t,Jt,qt,Gt,Vt,Bt,Qt,Wt="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",Zt=(k.default(_t||(_t=F(["\nquery ContactCardQuery(\n$id: LrRelayIdInput!\n) {\ncontactCard (\n id: $id\n) {\n ","\n}\n","\n}"],["\nquery ContactCardQuery(\n$id: LrRelayIdInput!\n) {\ncontactCard (\n id: $id\n) {\n ","\n}\n","\n}"])),Wt,Ge),k.default(Jt||(Jt=F(['\nquery SearchContactCardQuery(\n $publicSearchable: LrJSONFilter!\n) {\n searchContactCards(\n publicSearchable: $publicSearchable\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],['\nquery SearchContactCardQuery(\n $publicSearchable: LrJSONFilter!\n) {\n searchContactCards(\n publicSearchable: $publicSearchable\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),Wt,Ge),k.default(qt||(qt=F(['\nquery ContactCardListQuery {\n contactCards(\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],['\nquery ContactCardListQuery {\n contactCards(\n orderBy: "created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),Wt,Ge)),Ht=(k.default(Gt||(Gt=F(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"],["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"])),Wt),k.default(Vt||(Vt=F(["\nmutation UpdateContactCardMutation(\n $input: UpdateContactCardInput!\n) {\n updateContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"],["\nmutation UpdateContactCardMutation(\n $input: UpdateContactCardInput!\n) {\n updateContactCard(input: $input) {\n contactCard {\n ","\n }\n }\n}"])),Wt),k.default(Bt||(Bt=F(["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n }\n"]))));(Qt=e.DirectoryType||(e.DirectoryType={})).Vault="vault",Qt.Category="category",Qt.Record="record";var Yt,zt,Xt,en,tn,nn,rn,an,sn,on,cn,un,pn,dn=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Vault,default:!0}}]}),ln=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Category}}]}),yn=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Record}}]}),hn="\ndescendantDirectories(depth: 5, plainMeta: $categoryFilter, archived: false) {\n recordsCount: directoriesCount(plainMeta: $recordFilter, archived: false)\n}\n",fn="\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+hn+"\n",vn="\n id\n keyId\n plainMeta\n cipherMeta\n",mn=k.default(Yt||(Yt=F(["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),gn=k.default(zt||(zt=F(['\nquery GetCategoriesQuery($vaultDirectoryId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean)\n{\n directory(id: $vaultDirectoryId) {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetCategoriesQuery($vaultDirectoryId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean)\n{\n directory(id: $vaultDirectoryId) {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),fn,qe),Sn=k.default(Xt||(Xt=F(['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),vn,qe),In=k.default(en||(en=F(['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n theirItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n',"\n"],['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n theirItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n',"\n"])),fn,qe),Cn=k.default(tn||(tn=F(['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n',"\n"],['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n',"\n"])),fn,qe),bn=function(e){return void 0===e&&(e=5),e?"\nparentCategories: parentDirectoryLinks(plainMeta: $categoryFilter) {\n edges {\n node {\n parentDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+bn(e-1)+"\n }\n }\n }\n}\n":""},wn=function(e){return void 0===e&&(e=5),k.default(nn||(nn=F(["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n'," "],["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n'," "])),hn,bn(e),fn,qe)},Kn=k.default(rn||(rn=F(["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),qe),kn=k.default(an||(an=F(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),Pn=k.default(sn||(sn=F(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"]))),En=k.default(on||(on=F(["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Dn=k.default(cn||(cn=F(["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"],["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"]))),Rn=k.default(un||(un=F(["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Mn=k.default(pn||(pn=F(["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),On=function(){function e(e,t,n,r,i){this.encryptionService=e,this.keyGraph=t,this.lrApollo=n,this.keyService=r,this.keyFactory=i}return e.prototype.decryptMeta=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return e.cipherMeta?[4,this.keyGraph.getJwkKey(e.keyId)]:[3,3];case 1:return t=n.sent(),[4,this.encryptionService.decrypt(t,JSON.parse(e.cipherMeta))];case 2:return[2,n.sent()];case 3:return[2,null]}}))}))},e.prototype.doubleWrapContent=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return[4,this.keyFactory.createKey()];case 1:return r=l.sent(),[4,this.wrapContent(r.toJSON(!0),t)];case 2:return i=l.sent(),a={rootKey:i.rootKey,wrappedKeys:i.wrappedKeys,doubleWrappedKey:i.cipherMeta},e?(c=(o=JSON).stringify,[4,this.encryptionService.encrypt(r,e)]):[3,4];case 3:return s=c.apply(o,[l.sent()]),[3,5];case 4:s=null,l.label=5;case 5:return a.cipherMeta=s,n?(d=(p=JSON).stringify,[4,this.encryptionService.encrypt(r,n)]):[3,7];case 6:return u=d.apply(p,[l.sent()]),[3,8];case 7:u=null,l.label=8;case 8:return[2,(a.cipherFileContent=u,a)]}}))}))},e.prototype.reWrapContent=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getJwkKey(e)];case 1:return n=p.sent(),[4,this.keyFactory.createKey()];case 2:return r=p.sent(),i={},s=(a=JSON).stringify,[4,this.encryptionService.encrypt(n,r.toJSON(!0))];case 3:return i.doubleWrappedKey=s.apply(a,[p.sent()]),t?(u=(c=JSON).stringify,[4,this.encryptionService.encrypt(r,t)]):[3,5];case 4:return o=u.apply(c,[p.sent()]),[3,6];case 5:o=null,p.label=6;case 6:return[2,(i.cipherMeta=o,i)]}}))}))},e.prototype.wrapContent=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y=this;return j(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return A(y,void 0,void 0,(function(){var t,r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.getCategoryKeyId(e)];case 1:return t=s.sent(),a=(i=JSON).stringify,[4,this.encryptionService.encrypt(t.key,n.toJSON(!0))];case 2:return r=a.apply(i,[s.sent()]),[2,{directoryId:e,wrappingKeyId:t.keyId,wrappedKey:r}]}}))}))})))]:[3,3];case 2:return r=h.sent(),[3,5];case 3:return a=this.keyService.currentRootKey,c=(o=JSON).stringify,[4,this.encryptionService.encrypt(a.jwk,n.toJSON(!0))];case 4:s=c.apply(o,[h.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},h.label=5;case 5:return u={key:n,rootKey:i,wrappedKeys:r},e?(l=(d=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,7];case 6:return p=l.apply(d,[h.sent()]),[3,8];case 7:p=null,h.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o;return j(this,(function(c){switch(c.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=c.sent(),[4,this.keyGraph.encryptToString(t,n.toJSON(!0))];case 2:return r=c.sent(),i={key:n,rootKey:{wrappingKeyId:t,wrappedKey:r}},e?(o=(s=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,4];case 3:return a=o.apply(s,[c.sent()]),[3,5];case 4:a=null,c.label=5;case 5:return[2,(i.cipherMeta=a,i)]}}))}))},e.prototype.getCategoryKeyId=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Kn,variables:{id:e}})];case 1:return t=r.sent().category,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();On.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new On(t.ɵɵinject(he),t.ɵɵinject(ke),t.ɵɵinject(Pe),t.ɵɵinject(Ke),t.ɵɵinject(ve))},token:On,providedIn:"root"}),On.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],On.ctorParameters=function(){return[{type:he},{type:ke},{type:Pe},{type:Ke},{type:ve}]};var An,jn,Tn,Nn,$n,Fn,Un,Ln,xn,_n,Jn=k.default(An||(An=F(["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"],["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"]))),qn=k.default(jn||(jn=F(["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"],["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"]))),Gn="\n name\n data\n state\n",Vn=k.default(Tn||(Tn=F(["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"],["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"])),Gn),Bn=k.default(Nn||(Nn=F(["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"]))),Qn=k.default($n||($n=F(["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"],["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"])),Gn),Wn=k.default(Fn||(Fn=F(["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),Zn=k.default(Un||(Un=F(["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"],["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"])),Gn),Hn=k.default(Ln||(Ln=F(["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"],["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"])),Gn),Yn=k.default(xn||(xn=F(["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"],["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"])),Gn),zn=k.default(_n||(_n=F(["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"],["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"])));function Xn(e){return e.map((function(e){var t;return Object.assign(Object.assign({},e),{periodEnd:e.periodEnd&&new Date(e.periodEnd),subscription:{id:null===(t=e.stripe)||void 0===t?void 0:t.subscriptionId}})}))}var er=function(){function e(e){this.lrApollo=e}return e.prototype.createStripeCheckoutSession=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Jn,variables:Object.assign({},e)})];case 1:return[2,{id:t.sent().createStripeCheckoutSession.sessionId}]}}))}))},e.prototype.createStripeBillingPortalSession=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:qn,variables:{returnUrl:e}})];case 1:return[2,{url:t.sent().createStripeBillingPortalSession.sessionUrl}]}}))}))},e.prototype.getUserIssuablePlans=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:Qn})];case 1:return[2,e.sent().userIssuablePlans]}}))}))},e.prototype.createUserIssuedPlan=function(e){var t=e.planName,n=e.tokenExpiryTime,r=e.planPeriodEnd,i=e.planPeriodEndAfterSeconds;return A(this,void 0,void 0,(function(){var e,a;return j(this,(function(s){switch(s.label){case 0:if(null==r&&null==i)throw new q('Must specify either "planPeriodEnd" or "planPeriodEndAfterSeconds"');return[4,this.lrApollo.mutate({mutation:Vn,variables:{input:{planName:t,tokenExpiryTime:n.toISOString(),planPeriodEnd:r&&r.toISOString(),planPeriodEndAfterSeconds:i}}})];case 1:return e=s.sent().createUserIssuedPlan,a=e.userIssuedPlan,[2,Object.assign(Object.assign({},a),{tokenExpiryTime:new Date(a.tokenExpiryTime),planPeriodEnd:new Date(a.planPeriodEnd)})]}}))}))},e.prototype.deleteUserIssuedPlan=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Bn,variables:{input:{id:e}}})];case 1:return[2,t.sent()]}}))}))},e.prototype.getUserIssuedPlans=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:Wn})];case 1:return[2,e.sent().userIssuedPlans.edges.map((function(e){return e.node}))]}}))}))},e.prototype.getUserIssuedPlan=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Zn,variables:{id:e,token:t}})];case 1:return[2,n.sent().userIssuedPlan]}}))}))},e.prototype.associateUserIssuedPlan=function(e){var t=e.id,n=e.token;return A(this,void 0,void 0,(function(){var e,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Hn,variables:{input:{id:t,token:n}}})];case 1:return e=i.sent().associateUserIssuedPlan,r=e.userPlan,[2,Object.assign(Object.assign({},r),{periodEnd:new Date(r.periodEnd)})]}}))}))},e.prototype.getUserPlans=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:Yn})];case 1:return[2,Xn(e.sent().userPlans)]}}))}))},e.prototype.getPlanType=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.getStripe()];case 1:return[2,t.sent().customer.subscriptions.data.filter((function(t){return t.id===e}))[0].items.data[0].plan.interval]}}))}))},e.prototype.getStripe=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:zn})];case 1:return[2,e.sent().stripe]}}))}))},e}();er.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new er(t.ɵɵinject(Pe))},token:er,providedIn:"root"}),er.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],er.ctorParameters=function(){return[{type:Pe}]};var tr,nr,rr,ir=k.default(tr||(tr=F(['\n query {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n userDelete {\n id\n created\n state\n }\n features {\n myVault\n tpVault\n shareVault\n }\n sessionEncryptionKey\n dateJoined\n }\n userPlans {\n id\n stripe {\n subscriptionId\n }\n plan {\n name\n data\n state\n }\n periodEnd\n }\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n key {\n id\n }\n cipherData\n plainData\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"],['\n query {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n userDelete {\n id\n created\n state\n }\n features {\n myVault\n tpVault\n shareVault\n }\n sessionEncryptionKey\n dateJoined\n }\n userPlans {\n id\n stripe {\n subscriptionId\n }\n plan {\n name\n data\n state\n }\n periodEnd\n }\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n key {\n id\n }\n cipherData\n plainData\n }\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ',"\n"])),qe),ar=k.default(nr||(nr=F(["\n mutation CreateContactCardMutation($input: CreateContactCardInput!) {\n createContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"],["\n mutation CreateContactCardMutation($input: CreateContactCardInput!) {\n createContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"]))),sr=k.default(rr||(rr=F(["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"],["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n key {\n id\n }\n cipherData\n }\n }\n }\n"])));(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var or=function(){},cr=function(){},ur=function(){},pr=function(){},dr=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},lr=function(){},yr=function(){},hr=function(){},fr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),t}(hr),vr=function(){};!function(e){e.InProgress="IN_PROGRESS",e.Recovery="RECOVERY"}(e.PasswordChangeStatus||(e.PasswordChangeStatus={}));var mr=function(){},gr=function(){},Sr=function(){function e(e,t,n,r,i,a,s){this.config=e,this.http=t,this.lrApollo=n,this.keyService=r,this.keyMetaService=i,this.keyGraph=a,this.encryptionService=s}return e.prototype.getPassIdpParams=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.config.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},e.prototype.getCurrentUser=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:ir})];case 1:return e=a.sent(),t=e.currentUser,n=e.contactCards,r=e.userPlans,i=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:i,userPlans:Xn(r)}]}}))}))},e.prototype.decryptContactCard=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return e?[4,this.keyGraph.decryptFromString(e.key.id,e.cipherData)]:[2,null];case 1:return t=n.sent(),[2,Object.assign({id:e.id,keyId:e.key.id},t)]}}))}))},e.prototype.updateDetails=function(e,t,n){return A(this,void 0,void 0,(function(){return j(this,(function(r){switch(r.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r.sent(),[2]}}))}))},e.prototype.prepareContactCardInput=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return t=this.keyService.currentSigPxk,i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 1:return n=i.apply(r,[l.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 2:return a=o.apply(s,[l.sent()]),c={name:new dr(e.name.value)},d=(p=JSON).stringify,[4,this.encryptionService.sign(t.jwk,c)];case 3:return u=d.apply(p,[l.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:u}]}}))}))},e.prototype.createContactCard=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.prepareContactCardInput(e)];case 1:return t=a.sent(),[4,this.keyMetaService.wrapContent(e)];case 2:return n=a.sent(),r=n.rootKey,i=n.cipherMeta,[4,this.lrApollo.mutate({mutation:ar,variables:{input:Object.assign(Object.assign({},t),{cipherData:i,wrappingKeyId:r.wrappingKeyId,wrappedKey:r.wrappedKey,default:!0})}})];case 3:return[2,a.sent().createContactCard.contactCard]}}))}))},e.prototype.updateContactCard=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.prepareContactCardInput(n)];case 1:return r=a.sent(),[4,this.keyGraph.encryptToString(t,n)];case 2:return i=a.sent(),[4,this.lrApollo.mutate({mutation:sr,variables:{input:Object.assign(Object.assign({},r),{id:e,cipherData:i})}})];case 3:return[2,a.sent().updateContactCard.contactCard]}}))}))},e.prototype.decryptContactCardEdges=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){return[2,Promise.all(e.map((function(e){return A(t,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t=e.node,[4,this.decryptContactCard(t)];case 1:return[2,n.sent()]}}))}))})))]}))}))},e.prototype.getContactCards=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Zt})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ht,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.http.post(this.config.authUrl+"auth/sign-out/",null,{withCredentials:!0,responseType:"text"}).toPromise()];case 1:return e.sent(),[2]}}))}))},e}();Sr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Sr(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(Pe),t.ɵɵinject(Ke),t.ɵɵinject(On),t.ɵɵinject(ke),t.ɵɵinject(he))},token:Sr,providedIn:"root"}),Sr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Sr.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:Pe},{type:Ke},{type:On},{type:ke},{type:he}]};var Ir,Cr,br,wr=k.default(Ir||(Ir=F(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"]))),Kr=k.default(Cr||(Cr=F(["\n mutation PasswordChange($input: PasswordChangeInput!) {\n passwordChange(input: $input) {\n token\n newPassKey {\n id\n }\n }\n }\n"],["\n mutation PasswordChange($input: PasswordChangeInput!) {\n passwordChange(input: $input) {\n token\n newPassKey {\n id\n }\n }\n }\n"]))),kr=k.default(br||(br=F(["\n query PasswordChangeConfigQuery {\n passwordChangeConfig {\n maxAuthAgeSeconds\n authTime\n serverTime\n }\n }\n"],["\n query PasswordChangeConfigQuery {\n passwordChangeConfig {\n maxAuthAgeSeconds\n authTime\n serverTime\n }\n }\n"]))),Pr=P,Er=function(){},Dr=function(){function e(e,t,n,r,i,a,s,o,c){this.config=e,this.http=t,this.apollo=n,this.auth=r,this.profileService=i,this.keyFactory=a,this.encryptionService=s,this.keyGraph=o,this.webCryptoService=c,this.CLIENT_NONCE_LENGTH=32}return e.prototype.checkPassword=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Pr.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.webCryptoService.stringDigest("SHA-1",e)];case 1:return t=a.sent(),n=t.substring(0,5),[4,this.http.get("https://api.pwnedpasswords.com/range/"+n,{responseType:"text"}).toPromise()];case 2:return r=a.sent(),(i=new RegExp("^(?:"+t.substring(5)+":)(?<count>\\d+)$","im").exec(r))?[2,+i.groups.count]:[2,0]}}))}))},e.prototype.getPassIdpString=function(e){return e.toJSON(!0).k},e.prototype.createPassKeyBundle=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.keyFactory.createPassIdpParams()];case 1:return t=o.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t))];case 2:return n=o.sent().jwk,[4,this.keyFactory.createPassKeyParams()];case 3:return r=o.sent(),[4,this.keyFactory.derivePassKey(Object.assign({password:e},r))];case 4:return i=o.sent().jwk,[4,this.keyFactory.createPkcSignKey()];case 5:return a=o.sent(),[4,this.encryptionService.encrypt(i,a.toJSON(!0))];case 6:return s=o.sent(),[2,{passKeyParams:r,passKey:i,passIdpParams:t,passIdp:n,passIdpVerifier:a,wrappedPassIdpVerifierPrk:s}]}}))}))},e.prototype.isLoginRequired=function(){return A(this,void 0,void 0,(function(){var e,t,n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Pr(e.authTime),n=Pr(e.serverTime),r=Pr.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return n=d.sent(),[4,this.profileService.getCurrentUser()];case 2:return r=d.sent().currentUser,[4,this.verifyPassword(e,r)];case 3:return i=d.sent(),a=i.passIdp,s=i.signedChallenge,[4,this.createPassKeyBundle(t)];case 4:return o=d.sent(),[4,this.keyGraph.getKey(r.currentUserKey.masterKey.id)];case 5:return c=d.sent(),[4,this.encryptionService.encrypt(o.passKey,c.jwk.toJSON(!0))];case 6:return u=d.sent(),[4,this.changePasswordMutation(s,r.currentUserKey.masterKey.id,u,o)];case 7:return p=d.sent().token,[4,this.auth.changePassword(n,this.getPassIdpString(a),this.getPassIdpString(o.passIdp))];case 8:return d.sent(),[4,this.changePasswordComplete({useNewPassword:!0,token:p})];case 9:return d.sent(),[2]}}))}))},e.prototype.changePasswordComplete=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return t=e.useNewPassword,n=e.token,i=(r=this.http).post,a=[this.config.authUrl+"users/password-change-complete/",Object.assign({use_new_password:t},n&&{token:n})],[4,Se(this.auth,this.config)];case 1:return[2,i.apply(r,a.concat([s.sent()])).toPromise()]}}))}))},e.prototype.getVerifierPrK=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,t)];case 1:return n=r.sent(),[2,ve.asKey(n)];case 2:throw r.sent(),new J("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:wr,variables:{}})];case 1:return n=o.sent(),[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.currentUserKey.passKey.passKeyParams))];case 2:return r=o.sent(),[4,this.getVerifierPrK(r.jwk,t.currentUserKey.passKey.wrappedPassIdpVerifierPrk)];case 3:return i=o.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.encryptionService.sign(i,{serverNonce:n.passwordChangeRequest.challenge.serverNonce,clientNonce:a})];case 4:return s=o.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:e},t.currentUserKey.passKey.passIdpParams))];case 5:return[2,{passIdp:o.sent().jwk,signedChallenge:s}]}}))}))},e.prototype.changePasswordMutation=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i;return j(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Kr,variables:{input:{signedChallenge:JSON.stringify(e),masterKeyId:t,newWrappedMasterKey:JSON.stringify(n),newPassKey:{passIdpParams:JSON.stringify(r.passIdpParams),passIdpVerifierPbk:JSON.stringify(r.passIdpVerifier.toJSON()),wrappedPassIdpVerifierPrk:JSON.stringify(r.wrappedPassIdpVerifierPrk),passKeyParams:JSON.stringify(r.passKeyParams)}}}})];case 1:return[2,{token:(i=a.sent()).passwordChange.token,newPassKeyId:i.passwordChange.newPassKey.id}]}}))}))},e.prototype.getChangePasswordConfig=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:kr})];case 1:return e=n.sent(),(t=e.passwordChangeConfig).authTime=new Date(t.authTime),t.serverTime=new Date(t.serverTime),[2,t]}}))}))},e.prototype.passwordStrength=function(e){function t(e,t){return((e||"").match(t)||[]).length}var n=t(e,/[A-Z]/g),r=t(e,/[a-z]/g),i=t(e,/[0-9]/g),a=0;if(n&&(a+=26),r&&(a+=26),i&&(a+=10),e.length-n-r-i&&(a+=30),0===e.length)return{years:0,bits:0};var s=Math.pow(a,e.length);return{years:54e3*s/Math.pow(62,12),bits:Math.round(Math.log2(s))}},e}();Dr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Dr(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(Pe),t.ɵɵinject(s.AuthClass),t.ɵɵinject(Sr),t.ɵɵinject(ve),t.ɵɵinject(he),t.ɵɵinject(ke),t.ɵɵinject(fe))},token:Dr,providedIn:"root"}),Dr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Dr.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:Pe},{type:s.AuthClass},{type:Sr},{type:ve},{type:he},{type:ke},{type:fe}]};var Rr="lifeready",Mr=".tp_password_reset",Or=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),this.assembly=e,this.subAssembly=t,this.mnemonics=n},Ar=function(){function e(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0),this.index=e,this.threshold=t,this.size=n,this.clearShares()}return e.prototype.clearShares=function(){this.shares=[]},e.prototype.addShare=function(e){this.shares.push(e)},e}(),jr=function(){function e(e){void 0===e&&(e=0),this.threshold=e,this.clearSubAssemblies()}return e.prototype.size=function(){return this.subAssemblies.length},e.prototype.clearSubAssemblies=function(){this.subAssemblies=[]},e.prototype.addSubAssembly=function(e){this.subAssemblies.push(e)},e}(),Tr=(function(){function e(e){this.subAssemblyIndex=e,this.clearShares()}e.prototype.clearShares=function(){this.shares=[]},e.prototype.addShare=function(e){this.shares.push(e)}}(),function(){function e(){this.clearSubQuora()}e.prototype.clearSubQuora=function(){this.subQuora=[]},e.prototype.addSubQuorum=function(e){this.subQuora.push(e)},e.prototype.serialiseShares=function(){var e=[];return this.subQuora.forEach((function(t){e=e.concat(t.shares)})),e}}(),function(){function e(){}return e.prototype.generateShares=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:r=btoa(e),r=I.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=T(n.subAssemblies),s=a.next();!s.done;s=a.next())o=s.value,i.push([o.threshold,o.size])}catch(e){u={error:e}}finally{try{s&&!s.done&&(p=a.return)&&p.call(a)}finally{if(u)throw u.error}}return[4,I.Slip39.fromArray(r,{passphrase:t,threshold:n.threshold,groups:i,title:""})];case 1:return c=d.sent(),n.subAssemblies.forEach((function(e,t){e.clearShares();for(var n=0;n<e.size;n++){var r="r/"+t.toString().padStart(2,"0")+"/"+n.toString().padStart(2,"0"),i=c.fromPath(r).mnemonics[0],a=new Or(t,n,i);e.addShare(a)}})),[2]}}))}))},e.prototype.minimalSet=function(e){var t,n,r,i,a=null,s=new Map;try{for(var o=T(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=I.Slip39Helper.decodeMnemonic(u);if(a&&a!==p.groupThreshold)throw new Error("groupThreshold is different in mnemonics");a=p.groupThreshold,null==(f=s.get(p.groupIndex))&&(f={memberThreshold:p.memberThreshold,members:[]},s.set(p.groupIndex,f)),f.members.push({mnemonic:u,decoded:p})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=[],l=0;try{for(var y=T(s.values()),h=y.next();!h.done;h=y.next()){var f;if(!((f=h.value).members.length<f.memberThreshold)&&(f.members.slice(0,f.memberThreshold).forEach((function(e){d.push(e.mnemonic)})),++l>=a))break}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}return d},e.prototype.recoverSecret=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,I.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=I.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}());Tr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Tr},token:Tr,providedIn:"root"}),Tr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var Nr,$r=je(Nr||(Nr=F(["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"],["\nquery TpsKeysQuery($ids: [ID]) {\n tps(id_In: $ids) {\n edges {\n node {\n id\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n }\n }\n }\n }\n }\n}"]))),Fr=function(){function t(t){this.keyFactory=t.get(ve),this.keyService=t.get(Ke),this.encryptionService=t.get(he),this.keyGraph=t.get(ke),this.slip39Service=t.get(Tr),this.lrGraphQl=t.get(e.ɵf)}return t.prototype.recoverAssemblyKey=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return n=e.map((function(e){if(t){if(JSON.stringify(t)!==JSON.stringify(e.assemblyKeyParams))throw new Q("The assembly key parameters are different between the approvals.")}else t=e.assemblyKeyParams;return e.slip39.share.mnemonics})),[4,this.slip39Service.recoverSecret(n,this.slip39Passphrase)];case 1:return r=i.sent(),[4,ve.asKey(Object.assign(Object.assign({},t),{k:r}))];case 2:return[2,i.sent()]}}))}))},t.prototype.prepareTpWrappingKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.keyGraph.getKey(e.wrappingKeyId)]}))}))},t.prototype.prepareAssembly=function(e){var t=e.subjectKey,n=e.rootKey;return A(this,void 0,void 0,(function(){var e,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=d.sent(),r=e.toJSON(!0),i=r.k,a=M(r,["k"]),[4,this.keyFactory.createPkcSignKey()];case 2:return s=d.sent(),[4,this.encryptionService.encryptToString(e,s.toJSON(!0))];case 3:return o=d.sent(),c=JSON.stringify(s.toJSON()),[4,this.encryptionService.encryptToString(t,e.toJSON(!0))];case 4:return u=d.sent(),[4,this.encryptionService.encryptToString(e,{rootKey:n.toJSON(!0)})];case 5:return p=d.sent(),[2,{assemblyKey:e,rawAssemblyKey:i,assemblyKeyParams:a,subjectKeyWrappedAssemblyKey:u,assemblyCipherData:p,assemblyKeyVerifierPbk:c,wrappedAssemblyKeyVerifierPrk:o}]}}))}))},t.prototype.prepareCreateSubAssemblies=function(e){var t=e.input,n=e.subjectKey,r=e.slipSubAssemblies,i=e.assemblyKeyParams;return A(this,void 0,void 0,(function(){var e=this;return j(this,(function(a){return[2,Promise.all(t.map((function(t,a){return A(e,void 0,void 0,(function(){var e,s,o=this;return j(this,(function(c){switch(c.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=c.sent(),[4,Promise.all(t.approverTps.map((function(e,t){return A(o,void 0,void 0,(function(){return j(this,(function(s){return[2,this.prepareApprover({tp:e,approverIndex:t,slipSubAssembly:r[a],assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return s=c.sent(),[2,{singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e,createApprovers:s}]}}))}))})))]}))}))},t.prototype.prepareUpdateSubAssemblies=function(e){var t=e.input,n=e.subjectKey,r=e.slipSubAssemblies,i=e.assemblyKeyParams,a=e.subAssemblies;return A(this,void 0,void 0,(function(){var e=this;return j(this,(function(s){if(r.length!==t.length)throw new q("The slipSubAssemblies must be the same length as the input");return[2,Promise.all(t.map((function(t,s){return A(e,void 0,void 0,(function(){var e,o,c,u,p,d,l=this;return j(this,(function(y){switch(y.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=y.sent(),o=a.edges.find((function(e){return e.node.id===t.id})).node,c=[],u=[],t.approverTps.forEach((function(e){var t,n=null===(t=o.approvers.edges.find((function(t){return t.node.tp.id===e.tpId})))||void 0===t?void 0:t.node;n?u.push({tp:e,approverId:n.id}):c.push({tp:e})})),p=r[s],d={subAssemblyId:t.id,singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e},[4,Promise.all(c.map((function(e,t){var r=e.tp;return A(l,void 0,void 0,(function(){return j(this,(function(e){return[2,this.prepareApprover({tp:r,approverIndex:t,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return d.createApprovers=y.sent(),[4,Promise.all(u.map((function(e,t){var r=e.tp,a=e.approverId;return A(l,void 0,void 0,(function(){return j(this,(function(e){return[2,this.prepareApprover({approverId:a,tp:r,approverIndex:t+c.length,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 3:return[2,(d.updateApprovers=y.sent(),d)]}}))}))})))]}))}))},t.prototype.fillWrappingKeyId=function(e,t){var n=this;e.forEach((function(e){e.approverTps.forEach((function(e){if(!e.wrappingKeyId){var r=t.find((function(t){return t.id===e.tpId}));e.wrappingKeyId=n.getTpWrappingKeyId(r)}}))}))},t.prototype.getInputApprovers=function(e){var t=[];return e.forEach((function(e){e.approverTps.forEach((function(e){t.push(e.tpId)}))})),t},t.prototype.prepareCreate=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y,h;return j(this,(function(f){switch(f.label){case 0:return t=this.keyService.currentRootKey,[4,this.keyFactory.createKey()];case 1:return n=f.sent(),[4,this.keyGraph.wrapKey(t,n)];case 2:return r=f.sent(),[4,this.prepareAssembly({rootKey:t.jwk,subjectKey:n})];case 3:return i=f.sent(),a=i.assemblyKey,s=i.rawAssemblyKey,o=i.assemblyKeyParams,c=M(i,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),[4,this.prepareSlip39(e.createSubAssemblies,e.quorum,s)];case 4:return u=f.sent(),p=this.getInputApprovers(e.createSubAssemblies),l=jt,[4,this.lrGraphQl.query({query:$r,variables:{ids:p}})];case 5:return d=l.apply(void 0,[f.sent().tps]),this.fillWrappingKeyId(e.createSubAssemblies,d),[4,this.prepareCreateSubAssemblies({input:e.createSubAssemblies,assemblyKeyParams:o,slipSubAssemblies:u.subAssemblies,subjectKey:n})];case 6:return y=f.sent(),[4,this.encryptionService.encryptToString(n,e.subjectCipherDataClearJson||"")];case 7:return h=f.sent(),[2,{assemblyKey:a,mutationInput:Object.assign(Object.assign({},c),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:h,createSubAssemblies:y,rootKeyId:t.id,rootKeyWrappedSubjectKey:r})}]}}))}))},t.prototype.getAssemblyApprovers=function(e){var t=[];return jt(e.subAssemblies).map((function(e){jt(e.approvers).forEach((function(e){return t.push(e.tp.id)}))})),t},t.prototype.prepareUpdate=function(e,t){var n;return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C;return j(this,(function(b){switch(b.label){case 0:if(e=Object.assign({createSubAssemblies:[]},e),r=e.createSubAssemblies||[],i=e.updateSubAssemblies||[],a=e.deleteSubAssemblies||[],0===r.length&&0===i.length&&0===a.length)throw new q("Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]");return s=this.keyService.currentRootKey,[4,this.keyGraph.getKey(t.subjectKey.id)];case 1:return o=b.sent(),[4,this.prepareAssembly({rootKey:s.jwk,subjectKey:o.jwk})];case 2:return c=b.sent(),u=c.assemblyKey,p=c.rawAssemblyKey,d=c.assemblyKeyParams,l=M(c,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),y=this.getAssemblyApprovers(t).concat(this.getInputApprovers(r),this.getInputApprovers(i)),f=jt,[4,this.lrGraphQl.query({query:$r,variables:{ids:y}})];case 3:h=f.apply(void 0,[b.sent().tps]),jt(t.subAssemblies).forEach((function(e){if(!a.includes(e.id)&&!i.some((function(t){return t.id===e.id}))){var t=jt(e.approvers).map((function(e){return{tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,sharedCipherApprovalDataClearJson:e.sharedCipherApprovalDataClearJson}}));i.push({id:e.id,quorum:e.quorum,singleReject:e.singleReject,approverTps:t,subjectCipherDataClearJson:e.subjectCipherDataClearJson})}})),this.fillWrappingKeyId(r,h),this.fillWrappingKeyId(i,h),b.label=4;case 4:return b.trys.push([4,6,,7]),[4,this.prepareSlip39((r||[]).concat(i||[]),e.quorum,p)];case 5:return v=b.sent(),[3,7];case 6:return m=b.sent(),console.log("Error while creating slip assembly",m),[3,7];case 7:return g={assemblyKeyParams:d,subjectKey:o.jwk},[4,this.prepareCreateSubAssemblies(Object.assign(Object.assign({},g),{input:r,slipSubAssemblies:v.subAssemblies.slice(0,r.length)}))];case 8:return S=b.sent(),[4,this.prepareUpdateSubAssemblies(Object.assign(Object.assign({},g),{input:i,slipSubAssemblies:v.subAssemblies.slice(r.length),subAssemblies:t.subAssemblies}))];case 9:return I=b.sent(),[4,this.encryptionService.encryptToString(o.jwk,null!==(n=e.subjectCipherDataClearJson)&&void 0!==n?n:t.subjectCipherDataClearJson)];case 10:return C=b.sent(),[2,{assemblyKey:u,mutationInput:Object.assign(Object.assign({},l),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:C,subjectKeyId:o.id,createSubAssemblies:S,updateSubAssemblies:I})}]}}))}))},t.prototype.prepareApprover=function(e){var t=e.approverId,n=e.tp,r=e.approverIndex,i=e.slipSubAssembly,a=e.assemblyKeyParams,s=e.subjectKey;return A(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h;return j(this,(function(f){switch(f.label){case 0:return[4,this.prepareTpWrappingKey(n)];case 1:return e=f.sent(),[4,this.keyFactory.createKey()];case 2:return o=f.sent(),[4,this.encryptionService.encryptToString(e.jwk,o.toJSON(!0))];case 3:return c=f.sent(),[4,this.encryptionService.encryptToString(s,o.toJSON(!0))];case 4:return u=f.sent(),p=1===i.threshold?i.shares[0]:i.shares[r],d={slip39:{share:p,subAssembly:{quorum:i.threshold,size:i.size}},assemblyKeyParams:a},[4,this.encryptionService.encryptToString(o,n.sharedCipherDataClearJson||"")];case 5:return l=f.sent(),[4,this.encryptionService.encryptToString(o,n.sharedCipherApprovalDataClearJson||"")];case 6:return y=f.sent(),[4,this.encryptionService.encryptToString(o,d)];case 7:return h=f.sent(),[2,{tpWrappingKeyId:e.id,tpWrappedSharedKey:c,subjectKeyWrappedSharedKey:u,sharedCipherData:l,sharedCipherApprovalData:y,sharedCipherPartialAssemblyKey:h,approverId:t||void 0,tpId:t?void 0:n.tpId}]}}))}))},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=T(e),i=r.next();!i.done;i=r.next()){var a=i.value;if(!a.currentUserSharedKey.userSharedKey.mkSharedKey){var s="tp "+a.other.username+" does not have mkSharedKey";throw console.log(s),new q(s)}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},t.prototype.prepareSlip39=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new q("Not enough sub assemblies to meet quorum");return r=new jr(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new Ar(t,e.quorum,n))})),[4,this.slip39Service.generateShares(n,this.slip39Passphrase,r)];case 1:return i.sent(),[2,r]}}))}))},t}();e.ɵi=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase=Rr,r}return R(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.mkSharedKey.id},t}(Fr),e.ɵi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵi(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵi,providedIn:"root"}),e.ɵi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵi.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵi=O([et({ngZoneName:"ngZone"})],e.ɵi);var Ur,Lr,xr,_r,Jr,qr,Gr,Vr,Br,Qr,Wr,Zr,Hr,Yr,zr,Xr,ei=je(Ur||(Ur=F(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),ti=je(Lr||(Lr=F(["\nmutation CreateTpAssemblyKeyChallengeMutation(\n $input: CreateTpAssemblyKeyChallengeInput!\n) {\n createTpAssemblyKeyChallenge(input: $input) {\n challenge\n }\n}"],["\nmutation CreateTpAssemblyKeyChallengeMutation(\n $input: CreateTpAssemblyKeyChallengeInput!\n) {\n createTpAssemblyKeyChallenge(input: $input) {\n challenge\n }\n}"]))),ni=je(xr||(xr=F(["\nmutation PreCompleteTpPasswordResetRequestMutation(\n $input: PreCompleteTpPasswordResetRequestInput!\n) {\n preCompleteTpPasswordResetRequest(input: $input) {\n idpPassword\n }\n}"],["\nmutation PreCompleteTpPasswordResetRequestMutation(\n $input: PreCompleteTpPasswordResetRequestInput!\n) {\n preCompleteTpPasswordResetRequest(input: $input) {\n idpPassword\n }\n}"]))),ri=je(_r||(_r=F(["\nmutation CompleteTpPasswordResetRequestMutation(\n $input: CompleteTpPasswordResetRequestInput!\n) {\n completeTpPasswordResetRequest(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpPasswordResetRequestMutation(\n $input: CompleteTpPasswordResetRequestInput!\n) {\n completeTpPasswordResetRequest(input: $input) {\n id\n }\n}"]))),ii=je(Jr||(Jr=F(["\nmutation ApproveTpPasswordResetRequestMutation(\n $input: ApproveTpPasswordResetRequestInput!\n) {\n approveTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"],["\nmutation ApproveTpPasswordResetRequestMutation(\n $input: ApproveTpPasswordResetRequestInput!\n) {\n approveTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"]))),ai=je(qr||(qr=F(["\nmutation RejectTpPasswordResetRequestMutation(\n $input: RejectTpPasswordResetRequestInput!\n) {\n rejectTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"],["\nmutation RejectTpPasswordResetRequestMutation(\n $input: RejectTpPasswordResetRequestInput!\n) {\n rejectTpPasswordResetRequest(input: $input) {\n claimApprover {\n id\n }\n }\n}"]))),si=je(Gr||(Gr=F(["\nmutation CreateTpPasswordResetMutation($input: CreateTpPasswordResetInput!) {\n createTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"],["\nmutation CreateTpPasswordResetMutation($input: CreateTpPasswordResetInput!) {\n createTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"]))),oi=je(Vr||(Vr=F(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),ci=je(Br||(Br=F(["\nmutation UpdateTpPasswordResetMutation($input: UpdateTpPasswordResetInput!) {\n updateTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"],["\nmutation UpdateTpPasswordResetMutation($input: UpdateTpPasswordResetInput!) {\n updateTpPasswordReset(input: $input) {\n tpPasswordReset {\n id\n }\n }\n}"]))),ui=je(Qr||(Qr=F(["\nfragment SharedTpPasswordResetFragment on SharedTpPasswordResetNode {\n id\n tp {\n id\n other {\n username\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedRequest {\n id\n pxk {\n id\n pbk\n }\n claim {\n id\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nfragment SharedTpPasswordResetFragment on SharedTpPasswordResetNode {\n id\n tp {\n id\n other {\n username\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedRequest {\n id\n pxk {\n id\n pbk\n }\n claim {\n id\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),pi=je(Wr||(Wr=F(["\nquery SharedTpPasswordResetsQuery {\n sharedTpPasswordResets {\n edges {\n node {\n ...SharedTpPasswordResetFragment\n }\n }\n }\n}\n","\n"],["\nquery SharedTpPasswordResetsQuery {\n sharedTpPasswordResets {\n edges {\n node {\n ...SharedTpPasswordResetFragment\n }\n }\n }\n}\n","\n"])),ui),di=je(Zr||(Zr=F(["\nquery SharedTpPasswordResetQuery($id: LrRelayIdInput!) {\n sharedTpPasswordReset(id: $id) {\n ...SharedTpPasswordResetFragment\n }\n}\n","\n"],["\nquery SharedTpPasswordResetQuery($id: LrRelayIdInput!) {\n sharedTpPasswordReset(id: $id) {\n ...SharedTpPasswordResetFragment\n }\n}\n","\n"])),ui),li=je(Hr||(Hr=F(["\nquery TpPasswordResetUserQuery {\n tpPasswordResetUser {\n username\n resetUsername\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n sessionEncryptionKey\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n requestAgainAfter\n }\n}"],["\nquery TpPasswordResetUserQuery {\n tpPasswordResetUser {\n username\n resetUsername\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n sessionEncryptionKey\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n requestAgainAfter\n }\n}"]))),yi=je(Yr||(Yr=F(["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\n canMeetQuorum\n subjectCipherData\n subjectKey {\n id\n }\n assemblyKey {\n id\n }\n assemblyCipherData\n subAssemblies {\n edges {\n node {\n id\n singleReject\n quorum\n subjectCipherData\n subjectKey {\n id\n }\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery TpPasswordResetQuery {\n tpPasswordReset {\n id\n applied\n assembly {\n singleReject\n quorum\n canMeetQuorum\n subjectCipherData\n subjectKey {\n id\n }\n assemblyKey {\n id\n }\n assemblyCipherData\n subAssemblies {\n edges {\n node {\n id\n singleReject\n quorum\n subjectCipherData\n subjectKey {\n id\n }\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),hi=je(zr||(zr=F(["\nmutation SetSessionEncryptionKeyMutation($input: SetSessionEncryptionKeyInput!) {\n setSessionEncryptionKey(input: $input) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation SetSessionEncryptionKeyMutation($input: SetSessionEncryptionKeyInput!) {\n setSessionEncryptionKey(input: $input) {\n sessionEncryptionKey\n }\n}\n"]))),fi=(je(Xr||(Xr=F(["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"]))),function(e){return function(){return e.initialise()}}),vi=function(){function n(e,n,r,i,a,s,o,c,u,p,d,l,y,h){if(this.config=e,this.auth=n,this.keyFactory=r,this.keyService=i,this.profileService=a,this.keyGraphService=s,this.passwordService=o,this.idleService=c,this.lrGraphQL=u,this.tpPasswordResetProcessorService=p,this.persistService=d,this.encryptionService=l,this.assemblyController=y,this.http=h,this.hubSubject=new m.ReplaySubject(1),this.logoutListeners=new Set,!t.isDevMode()&&null!=this.config.debug)throw new V('In production mode, "config.debug" must be set to null')}return n.prototype.initialise=function(){return A(this,void 0,void 0,(function(){var e=this;return j(this,(function(t){return v.Hub.listen("auth",(function(t){return e.hubSubject.next(t.payload)})),[2]}))}))},n.prototype.debugLogin=function(e,t){return this.config.debug.username=e,this.debugLoadUser(t)},n.prototype.debugLoginUsingSession=function(e){return this.http.get(this.config.apiUrl+"debug_only/users/login/?username="+encodeURIComponent(e),{withCredentials:!0}).toPromise()},n.prototype.debugLoadUser=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return[4,this.profileService.getCurrentUser()];case 1:return t=d.sent(),n=t.currentUser,r=t.contactCard,i=t.userPlans,[4,this.keyFactory.derivePassKey(Object.assign({password:e},n.currentUserKey.passKey.passKeyParams))];case 2:return a=d.sent().jwk,[4,this.keyGraphService.unwrapWithPassKey(n.currentUserKey.passKey.id,a,n.currentUserKey.masterKey.id)];case 3:return s=d.sent(),[4,this.idleService.persistMasterKey(s)];case 4:return d.sent(),[4,this.keyGraphService.populateKeys(n.currentUserKey)];case 5:return d.sent(),o={id:n.id,sub:"DEBUG_MODE",username:n.username,currentUserKey:n.currentUserKey,email:"DEBUG_MODE",emailVerified:!1,phone:"DEBUG_MODE",phoneVerified:!1},u=(c=Object).assign,p=[{}],[4,this.profileService.decryptContactCard(r)];case 6:return[2,(o.contactCard=u.apply(c,p.concat([d.sent()])),o.userDelete=n.userDelete,o.userPlans=i,o.hasTPVaultAccess=this.mapTPVaultAccess(n.features),o.features=n.features,o.sessionEncryptionKey=n.sessionEncryptionKey,o.dateJoined=n.dateJoined,o)]}}))}))},n.prototype.getAccessJwtToken=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){return[2,se(this.auth)]}))}))},n.prototype.importPassword=function(e){return this.keyFactory.importPassword(e)},n.prototype.addLogoutListener=function(e){this.logoutListeners.add(e)},n.prototype.removeLogoutListener=function(e){this.logoutListeners.delete(e)},n.prototype.loginIdpImpl=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n))];case 1:return i=s.sent(),[4,this.auth.signIn(e,this.passwordService.getPassIdpString(i.jwk))];case 2:return(a=s.sent()).recoveryStatus=r,[2,a]}}))}))},n.prototype.loginIdp=function(t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c;return j(this,(function(u){switch(u.label){case 0:return[4,this.profileService.getPassIdpParams(t)];case 1:if((r=u.sent()).passwordChangeStatus===e.PasswordChangeStatus.InProgress)throw new H("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.Recovery)return[3,8];console.log("In recovery mode."),u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.loginIdpImpl(t,n,r.newPassIdpParams,e.RecoveryStatus.NEW_PASSWORD)];case 3:return a=u.sent(),console.log("New password works!"),[2,a];case 4:if("NotAuthorizedException"!==(i=u.sent()).code)throw i;return[3,5];case 5:return u.trys.push([5,7,,8]),[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.OLD_PASSWORD)];case 6:return a=u.sent(),console.log("Old password works!"),[2,a];case 7:throw"NotAuthorizedException"===(s=u.sent()).code?new V("The password change request was interrupted, please try to login with both your new and old password"):s;case 8:if(!r.tpPasswordReset)return[3,12];u.label=9;case 9:return u.trys.push([9,11,,12]),o=r.tpPasswordReset,[4,this.loginIdpImpl(o.resetUsername,n,o.passIdpParams,e.RecoveryStatus.NONE)];case 10:return(c=u.sent()).isTpPasswordResetUser=!0,[2,c];case 11:return u.sent(),[3,12];case 12:return[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.NONE)];case 13:return[2,u.sent()]}}))}))},n.prototype.handleSessionEncryptionKey=function(){return A(this,void 0,void 0,(function(){var e,n;return j(this,(function(r){switch(r.label){case 0:if(!this.config.disableSessionEncryptionKey)return[3,1];if(!t.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new Error(e);return console.warn("You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode."),[3,4];case 1:return[4,this.keyFactory.createKey()];case 2:return n=r.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:hi,variables:{input:{sessionEncryptionKey:JSON.stringify(n.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(n),r.label=4;case 4:return[2]}}))}))},n.prototype.handlePostAuth=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.handlePasswordRecovery(e)];case 1:return t.sent(),[4,this.handleSessionEncryptionKey()];case 2:return t.sent(),[2]}}))}))},n.prototype.login=function(t,n,r){var i,a=(void 0===r?{}:r).tpPasswordResetAutoComplete,s=void 0===a||a;return A(this,void 0,void 0,(function(){var r;return j(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return r=a.sent(),s&&(null===(i=r.resetUser)||void 0===i?void 0:i.state)===e.TpClaimState.APPROVED?[4,this.completeRequest(n)]:[3,4];case 2:return a.sent(),[4,this.loginImpl(t,n)];case 3:r=a.sent(),a.label=4;case 4:return[2,r]}}))}))},n.prototype.loginImpl=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(e,t)];case 2:return n=i.sent(),["SMS_MFA","SOFTWARE_TOKEN_MFA"].includes(n.challengeName)?[2,{hasChallenge:!0,challenge:n}]:[4,this.handlePostAuth(n)];case 3:return i.sent(),n.isTpPasswordResetUser?[4,this.loadResetUser(t)]:[3,5];case 4:return[2,{hasChallenge:!1,resetUser:i.sent()}];case 5:return[4,this.loadUser(n,t)];case 6:return r=i.sent(),[4,this.idleService.start()];case 7:return i.sent(),[2,{hasChallenge:!1,user:r}]}}))}))},n.prototype.verifyLogin=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.auth.confirmSignIn(e,r,e.challengeName)];case 1:return s.sent(),[4,this.auth.currentAuthenticatedUser()];case 2:return i=s.sent(),[4,this.handlePostAuth(e)];case 3:return s.sent(),[4,this.loadUser(i,t)];case 4:return a=s.sent(),n&&i.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,a]}}))}))},n.prototype.handlePasswordRecovery=function(t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return t.recoveryStatus===e.RecoveryStatus.NONE?[3,2]:[4,this.passwordService.changePasswordComplete({useNewPassword:t.recoveryStatus===e.RecoveryStatus.NEW_PASSWORD})];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.getUserOrResetUser=function(e){return void 0===e&&(e=!1),A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t.sent().getUsername().endsWith(Mr)?[2,this.getResetUser(e)]:[2,this.getUser(e)]}}))}))},n.prototype.getResetUser=function(e){return void 0===e&&(e=!1),A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return!e&&this.currentResetUser?[2,this.currentResetUser]:(t=this,[4,this.loadResetUser()]);case 1:return t.currentResetUser=n.sent(),[4,this.idleService.start()];case 2:return n.sent(),[2,this.currentResetUser]}}))}))},n.prototype.getUser=function(e){return void 0===e&&(e=!1),A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return!e&&this.currentUser?[2,this.currentUser]:(t=this,n=this.loadUser,[4,this.auth.currentAuthenticatedUser()]);case 1:return[4,n.apply(this,[r.sent()])];case 2:return t.currentUser=r.sent(),console.log("Starting idle service."),[4,this.idleService.start()];case 3:return r.sent(),[2,this.currentUser]}}))}))},n.prototype.mapTPVaultAccess=function(e){var t=null==e?void 0:e.tpVault;return(null==t?void 0:t.length)>0&&t.some((function(e){return"ACCESS"===e.toUpperCase()}))},n.prototype.loadUser=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,s,o,c,u,p,d,l,y,h,f,v;return j(this,(function(m){switch(m.label){case 0:return[4,this.profileService.getCurrentUser()];case 1:return n=m.sent(),r=n.currentUser,i=n.contactCard,s=n.userPlans,r.sessionEncryptionKey?(c=(o=this.persistService).setServerSessionEncryptionKey,[4,a.JWK.asKey(r.sessionEncryptionKey)]):[3,3];case 2:c.apply(o,[m.sent()]),m.label=3;case 3:return[4,this.auth.userAttributes(e)];case 4:return u=m.sent(),t?[4,this.keyFactory.derivePassKey(Object.assign({password:t},r.currentUserKey.passKey.passKeyParams))]:[3,8];case 5:return p=m.sent().jwk,l=(d=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(r.currentUserKey.passKey.id,p,r.currentUserKey.masterKey.id)];case 6:return[4,l.apply(d,[m.sent()])];case 7:m.sent(),m.label=8;case 8:return[4,this.keyGraphService.populateKeys(r.currentUserKey)];case 9:return m.sent(),y={id:r.id,sub:this.getUserAttribute("sub",u),username:r.username,currentUserKey:r.currentUserKey,email:this.getUserAttribute("email",u),emailVerified:"true"===this.getUserAttribute("email_verified",u),phone:this.getUserAttribute("phone_number",u),phoneVerified:"true"===this.getUserAttribute("phone_number_verified",u)},f=(h=Object).assign,v=[{}],[4,this.profileService.decryptContactCard(i)];case 10:return[2,(y.contactCard=f.apply(h,v.concat([m.sent()])),y.userDelete=r.userDelete,y.userPlans=s,y.hasTPVaultAccess=this.mapTPVaultAccess(r.features),y.features=r.features,y.sessionEncryptionKey=r.sessionEncryptionKey,y.dateJoined=r.dateJoined,y)]}}))}))},n.prototype.watchAuth=function(){return this.hubSubject},n.prototype.logout=function(){var e;return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,Promise.all($(this.logoutListeners).map((function(e){return e()})))];case 1:return t.sent(),this.currentUser=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.auth.signOut(),this.profileService.signOut()])];case 2:return t.sent(),(null===(e=this.config.debug)||void 0===e?void 0:e.username)&&(this.config.debug.username=null),[2]}}))}))},n.prototype.getUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},n.prototype.loadResetUser=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d,l,y,h,f,v;return j(this,(function(m){switch(m.label){case 0:return[4,this.lrGraphQL.query({query:li})];case 1:return(t=m.sent().tpPasswordResetUser).sessionEncryptionKey?(r=(n=this.persistService).setServerSessionEncryptionKey,[4,a.JWK.asKey(t.sessionEncryptionKey)]):[3,3];case 2:r.apply(n,[m.sent()]),m.label=3;case 3:return e?[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.passKey.passKeyParams))]:[3,7];case 4:return i=m.sent().jwk,o=(s=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,i,t.masterKey.id)];case 5:return[4,o.apply(s,[m.sent()])];case 6:m.sent(),m.label=7;case 7:return this.keyService.setKeys({passKey:{id:t.passKey.id},masterKey:{id:t.masterKey.id}}),p=(u=this.auth).userAttributes,[4,this.auth.currentAuthenticatedUser()];case 8:return[4,p.apply(u,[m.sent()])];case 9:return c=m.sent(),d=this.getUserAttribute("sub",c),y=(l=Object).assign,f=(h=Object).assign,v=[{}],[4,this.tpPasswordResetProcessorService.processTpPasswordResetUserNode(t)];case 10:return[2,y.apply(l,[f.apply(h,v.concat([m.sent()])),{sub:d}])]}}))}))},n.prototype.refreshAccessToken=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),[2,new Promise((function(n,r){e.refreshSession(t,(function(e){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete"),n(0))}))}))]}}))}))},n.prototype.completeRequest=function(t){return A(this,void 0,void 0,(function(){var n,r,i,s,o,c,u,p,d,l,y,h,f,m,g=this;return j(this,(function(S){switch(S.label){case 0:return[4,this.getResetUser(!0)];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new Q("Password reset request has not been approved.");return[4,this.recoverAssemblyKey(n)];case 2:return r=S.sent(),[4,this.encryptionService.decrypt(r,n.assemblyCipherData)];case 3:return i=S.sent().rootKey,[4,a.JWK.asKey(i)];case 4:return s=S.sent(),[4,this.keyGraphService.getKey(n.masterKey.id)];case 5:return o=S.sent(),[4,this.encryptionService.encryptToString(o.jwk,s.toJSON(!0))];case 6:return c=S.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n.passKey.passIdpParams))];case 7:return u=S.sent(),p=this.passwordService.getPassIdpString(u.jwk),[4,this.lrGraphQL.lrMutate(new pt({mutation:ti,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return(d=S.sent().createTpAssemblyKeyChallenge.challenge).clientNonce=this.keyFactory.randomString(32),[4,this.encryptionService.decrypt(r,n.wrappedAssemblyKeyVerifierPrk)];case 9:return l=S.sent(),[4,this.encryptionService.sign(l,d)];case 10:return y=S.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:ni,variables:{input:{signedChallenge:JSON.stringify(y)}}}),{includeKeyGraph:!1})];case 11:return h=S.sent().preCompleteTpPasswordResetRequest.idpPassword,f=new Promise((function(e){var t=function(r){return A(g,void 0,void 0,(function(){return j(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(v.Hub.remove("auth",t),[4,this.auth.signIn(n.username,p)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:ri,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};v.Hub.listen("auth",t)})),[4,this.auth.signIn(n.username,h,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(m=S.sent()).challengeName)throw new z("Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.");return[4,this.auth.completeNewPassword(m,p,{})];case 13:return m=S.sent(),[2,f]}}))}))},n.prototype.recoverAssemblyKey=function(e){return A(this,void 0,void 0,(function(){var t,n,r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyGraphService.getKey(e.pxk.id)];case 1:return t=i.sent(),[4,Promise.all(e.approvals.filter((function(e){return!!e.receiverCipherPartialAssemblyKey})).map((function(e){return r.encryptionService.decrypt(t,e.receiverCipherPartialAssemblyKey)})))];case 2:return n=i.sent(),[2,this.assemblyController.recoverAssemblyKey(n)]}}))}))},n}();vi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new vi(t.ɵɵinject(me),t.ɵɵinject(s.AuthClass),t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(Sr),t.ɵɵinject(ke),t.ɵɵinject(Dr),t.ɵɵinject(xt),t.ɵɵinject(e.ɵf),t.ɵɵinject(e.ɵg),t.ɵɵinject(Ce),t.ɵɵinject(he),t.ɵɵinject(e.ɵi),t.ɵɵinject(f.HttpClient))},token:vi,providedIn:"root"}),vi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],vi.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:s.AuthClass},{type:ve},{type:Ke},{type:Sr},{type:ke},{type:Dr},{type:xt},{type:e.ɵf},{type:e.ɵg},{type:Ce},{type:he},{type:e.ɵi},{type:f.HttpClient}]};var mi,gi,Si,Ii,Ci,bi=function(){function e(e,t){var n=this;this._key=e,this.timer=setTimeout((function(){n._key=null}),t)}return Object.defineProperty(e.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),e.prototype.pop=function(){var e=this._key;return this._key=null,this.timer&&(clearTimeout(this.timer),this.timer=null),e},e}(),wi=je(mi||(mi=F(["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery {\n currentUser {\n id\n username\n currentUserKey {\n passKey {\n id\n passKeyParams\n passIdpParams\n wrappedPassIdpVerifierPrk\n created\n }\n masterKey {\n id\n }\n rootKey {\n id\n }\n pxk {\n id\n }\n sigPxk {\n id\n }\n }\n sessionEncryptionKey\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),qe),Ki=je(gi||(gi=F(["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"],["\nquery ResetUserQuery {\n tpPasswordResetUser {\n username\n sessionEncryptionKey\n state\n passKey {\n id\n passKeyParams\n passIdpParams\n }\n masterKey {\n id\n }\n pxk {\n id\n }\n assembly {\n singleReject\n quorum\n subAssemblies {\n singleReject\n quorum\n approvers {\n name\n email\n state\n }\n }\n }\n approvals {\n id\n modified\n approverEmail\n receiverCipher\n receiverCipherPartialAssemblyKey\n }\n assemblyCipherData\n wrappedAssemblyKeyVerifierPrk\n }\n}"])));!function(e){e.NONE="NONE",e.NEW_PASSWORD="NEW_PASSWORD",e.OLD_PASSWORD="OLD_PASSWORD"}(Si||(Si={})),function(e){e.IN_PROGRESS="IN_PROGRESS",e.RECOVERY="RECOVERY"}(Ii||(Ii={})),function(e){e.NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",e.SMS_MFA="SMS_MFA",e.SOFTWARE_TOKEN_MFA="SOFTWARE_TOKEN_MFA",e.MFA_SETUP="MFA_SETUP"}(Ci||(Ci={}));var ki,Pi,Ei=Object.freeze({__proto__:null,get RecoveryStatus(){return Si},get PasswordChangeStatus(){return Ii},get CognitoChallengeName(){return Ci}});e.Auth2Service=ki=function(n){function r(e,r,i,a,s,o,c,u,p,d,l,y,h,f){var v=n.call(this,r)||this;if(v.ngZone=e,v.injector=r,v.http=i,v.cognito=a,v.api=s,v.keyService=o,v.keyGraphService=c,v.keyFactoryService=u,v.passwordService=p,v.idleService=d,v.persistService=l,v.encryptionService=y,v.assemblyController=h,v.kcConfig=f,v.logoutListeners=new Set,v.password=null,!t.isDevMode()&&null!=v.kcConfig.debug)throw new V('In production mode, "KcConfig.debug" must be set to null');return v}return R(r,n),r.prototype.importPassword=function(e){return this.keyFactoryService.importPassword(e)},r.prototype.logout=function(){var e;return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,Promise.all($(this.logoutListeners).map((function(e){return e()})))];case 1:return t.sent(),this.user=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.cognito.signOut(),this.kcLogout()])];case 2:return t.sent(),(null===(e=this.kcConfig.debug)||void 0===e?void 0:e.username)&&(this.kcConfig.debug.username=null),[2]}}))}))},r.prototype.addLogoutListener=function(e){this.logoutListeners.add(e)},r.prototype.removeLogoutListener=function(e){this.logoutListeners.delete(e)},r.prototype.login=function(t,n,r){var i,a=(void 0===r?{}:r).tpPasswordResetAutoComplete,s=void 0===a||a;return A(this,void 0,void 0,(function(){var r;return j(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return(r=a.sent()).challenge?(this.password=new bi(n,ki.CHALLENGE_TIMEOUT),[2,r]):s&&(null===(i=r.user.resetUser)||void 0===i?void 0:i.state)===e.TpClaimState.APPROVED?[4,this.completeResetRequest(n)]:[3,4];case 2:return a.sent(),[4,this.loginImpl(t,n)];case 3:r=a.sent(),a.label=4;case 4:return[2,r]}}))}))},r.prototype.verifyLogin=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:if(t=e.challenge,n=e.code,r=e.rememberMe,!(i=[Ci.SMS_MFA,Ci.SOFTWARE_TOKEN_MFA]).includes(t.cognitoUser.challengeName))throw new V("challengeName must be one of "+i);return[4,this.cognito.confirmSignIn(t.cognitoUser,n,t.cognitoUser.challengeName)];case 1:return a=o.sent(),[4,this.handlePostAuth(t.recoveryStatus)];case 2:return o.sent(),[4,this.loadUser(a,this.password.pop())];case 3:return s=o.sent(),this.password=null,r&&a.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,{user:s}]}}))}))},r.prototype.getUser=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return this.user?[2,this.user]:[4,this.cognito.currentAuthenticatedUser()];case 1:return e=t.sent(),[2,this.loadUser(e)]}}))}))},r.prototype.refreshAccessToken=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return[4,this.cognito.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),console.log("Token refresh..."),[2,new Promise((function(n,r){e.refreshSession(t,(function(e){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete"),n(0))}))}))]}}))}))},r.prototype.fetchCurrentUser=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:wi,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().currentUser]}}))}))},r.prototype.fetchResetUser=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Ki,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().tpPasswordResetUser]}}))}))},r.prototype.kcLogout=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.http.post(this.kcConfig.authUrl+"auth/sign-out/",null,{withCredentials:!0,responseType:"text"}).toPromise()];case 1:return e.sent(),[2]}}))}))},r.prototype.fetchPassIdpParams=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.kcConfig.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},r.prototype.loginImpl=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.logout()];case 1:return r.sent(),[4,this.loginIdp(e,t)];case 2:return n=r.sent(),[Ci.SMS_MFA,Ci.SOFTWARE_TOKEN_MFA].includes(n.cognitoUser.challengeName)?[2,{challenge:{cognitoUser:n.cognitoUser,recoveryStatus:n.recoveryStatus}}]:[4,this.handlePostAuth(n.recoveryStatus)];case 3:return r.sent(),[4,this.loadUser(n.cognitoUser,t)];case 4:return[2,{user:r.sent()}]}}))}))},r.prototype.loginIdp=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return[4,this.fetchPassIdpParams(e)];case 1:if((n=l.sent()).passwordChangeStatus===Ii.IN_PROGRESS)throw new H("A password change is in progress");if(n.passwordChangeStatus!==Ii.RECOVERY)return[3,8];console.log("In recovery mode."),l.label=2;case 2:return l.trys.push([2,4,,5]),i={},[4,this.loginIdpImpl(e,t,n.newPassIdpParams)];case 3:return i.cognitoUser=l.sent(),i.recoveryStatus=Si.NEW_PASSWORD,r=i,console.log("New password works!"),[2,r];case 4:if("NotAuthorizedException"!==(a=l.sent()).code)throw a;return[3,5];case 5:return l.trys.push([5,7,,8]),o={},[4,this.loginIdpImpl(e,t,n.currentPassIdpParams)];case 6:return o.cognitoUser=l.sent(),o.recoveryStatus=Si.OLD_PASSWORD,s=o,console.log("Old password works!"),[2,s];case 7:throw"NotAuthorizedException"===(c=l.sent()).code?new V("The password change request was interrupted, please try to login with both your new and old password"):c;case 8:if(!n.tpPasswordReset)return[3,12];l.label=9;case 9:return l.trys.push([9,11,,12]),u=n.tpPasswordReset,p={},[4,this.loginIdpImpl(u.resetUsername,t,u.passIdpParams)];case 10:return p.cognitoUser=l.sent(),p.recoveryStatus=Si.NONE,[2,p];case 11:return l.sent(),[3,12];case 12:return d={},[4,this.loginIdpImpl(e,t,n.currentPassIdpParams)];case 13:return d.cognitoUser=l.sent(),d.recoveryStatus=Si.NONE,[2,d]}}))}))},r.prototype.loginIdpImpl=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyFactoryService.derivePassIdp(Object.assign({password:t},n))];case 1:return r=i.sent(),[2,this.cognito.signIn(e,this.passwordService.getPassIdpString(r.jwk))]}}))}))},r.prototype.handlePostAuth=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.handlePasswordRecovery(e)];case 1:return t.sent(),[4,this.handleSessionEncryptionKey()];case 2:return t.sent(),[2]}}))}))},r.prototype.handlePasswordRecovery=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return e===Si.NONE?[3,2]:[4,this.passwordService.changePasswordComplete({useNewPassword:e===Si.NEW_PASSWORD})];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},r.prototype.handleSessionEncryptionKey=function(){return A(this,void 0,void 0,(function(){var e,n;return j(this,(function(r){switch(r.label){case 0:if(!this.kcConfig.disableSessionEncryptionKey)return[3,1];if(!t.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new z(e);return console.warn("You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode."),[3,4];case 1:return[4,this.keyFactoryService.createKey()];case 2:return n=r.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:hi,variables:{input:{sessionEncryptionKey:JSON.stringify(n.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(n),r.label=4;case 4:return[2]}}))}))},r.prototype.getCognitoUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},r.prototype.loadUserKeys=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return t=e.userKeys,n=e.password,(r=e.sessionEncryptionKey)?(s=(i=this.persistService).setServerSessionEncryptionKey,[4,a.JWK.asKey(r)]):[3,2];case 1:s.apply(i,[p.sent()]),p.label=2;case 2:return n?[4,this.keyFactoryService.derivePassKey(Object.assign({password:n},t.passKey.passKeyParams))]:[3,6];case 3:return o=p.sent().jwk,u=(c=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,o,t.masterKey.id)];case 4:return[4,u.apply(c,[p.sent()])];case 5:p.sent(),p.label=6;case 6:return[2]}}))}))},r.prototype.loadUser=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return e.getUsername().endsWith(Mr)?(n=this,[4,this.loadResetUser(e,t)]):[3,2];case 1:return n.user=i.sent(),[3,4];case 2:return r=this,[4,this.loadRegularUser(e,t)];case 3:r.user=i.sent(),i.label=4;case 4:return[4,this.idleService.start()];case 5:return i.sent(),[2,this.user]}}))}))},r.prototype.loadRegularUser=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.fetchCurrentUser()];case 1:return n=a.sent(),[4,this.loadUserKeys({userKeys:n.currentUserKey,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return a.sent(),[4,this.keyGraphService.populateKeys(n.currentUserKey)];case 3:return a.sent(),r=n.username,[4,this.cognito.userAttributes(e)];case 4:return i=a.sent(),[2,{username:r,sub:this.getCognitoUserAttribute("sub",i),loginEmail:this.getCognitoUserAttribute("email",i),resetUser:null}]}}))}))},r.prototype.loadResetUser=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.fetchResetUser()];case 1:return n=s.sent(),r={passKey:{id:n.passKey.id,passKeyParams:n.passKey.passKeyParams},masterKey:{id:n.masterKey.id}},[4,this.loadUserKeys({userKeys:r,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return s.sent(),[4,this.keyService.setKeys(r)];case 3:return s.sent(),i=n.username,[4,this.cognito.userAttributes(e)];case 4:return a=s.sent(),[2,{username:i,sub:this.getCognitoUserAttribute("sub",a),loginEmail:this.getCognitoUserAttribute("email",a),resetUser:{state:n.state}}]}}))}))},r.prototype.recoverAssemblyKey=function(e){return A(this,void 0,void 0,(function(){var t,n,r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyGraphService.getKey(e.pxk.id)];case 1:return t=i.sent(),[4,Promise.all(e.approvals.filter((function(e){return!!e.receiverCipherPartialAssemblyKey})).map((function(e){return r.encryptionService.decrypt(t,e.receiverCipherPartialAssemblyKey)})))];case 2:return n=i.sent(),[2,this.assemblyController.recoverAssemblyKey(n)]}}))}))},r.prototype.completeResetRequest=function(t){return A(this,void 0,void 0,(function(){var n,r,i,s,o,c,u,p,d,l,y,h,f,m,g=this;return j(this,(function(S){switch(S.label){case 0:return[4,this.fetchResetUser()];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new Q("Password reset request has not been approved.");return[4,this.recoverAssemblyKey(n)];case 2:return r=S.sent(),[4,this.encryptionService.decrypt(r,n.assemblyCipherData)];case 3:return i=S.sent().rootKey,[4,a.JWK.asKey(i)];case 4:return s=S.sent(),[4,this.keyGraphService.getKey(n.masterKey.id)];case 5:return o=S.sent(),[4,this.encryptionService.encryptToString(o.jwk,s.toJSON(!0))];case 6:return c=S.sent(),[4,this.keyFactoryService.derivePassIdp(Object.assign({password:t},n.passKey.passIdpParams))];case 7:return u=S.sent(),p=this.passwordService.getPassIdpString(u.jwk),[4,this.lrGraphQL.lrMutate(new pt({mutation:ti,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return(d=S.sent().createTpAssemblyKeyChallenge.challenge).clientNonce=this.keyFactoryService.randomString(32),[4,this.encryptionService.decrypt(r,n.wrappedAssemblyKeyVerifierPrk)];case 9:return l=S.sent(),[4,this.encryptionService.sign(l,d)];case 10:return y=S.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:ni,variables:{input:{signedChallenge:JSON.stringify(y)}}}),{includeKeyGraph:!1})];case 11:return h=S.sent().preCompleteTpPasswordResetRequest.idpPassword,f=new Promise((function(e){var t=function(r){return A(g,void 0,void 0,(function(){return j(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(v.Hub.remove("auth",t),[4,this.cognito.signIn(n.username,p)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new pt({mutation:ri,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};v.Hub.listen("auth",t)})),[4,this.cognito.signIn(n.username,h,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(m=S.sent()).challengeName)throw new z("Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.");return[4,this.cognito.completeNewPassword(m,p,{})];case 13:return m=S.sent(),[2,f]}}))}))},r.prototype.debugLogin=function(e,t){return this.kcConfig.debug.username=e,this.debugLoadUser(t)},r.prototype.debugLoadUser=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.fetchCurrentUser()];case 1:return t=s.sent(),n=t.username,r=t.currentUserKey,[4,this.keyFactoryService.derivePassKey(Object.assign({password:e},r.passKey.passKeyParams))];case 2:return i=s.sent().jwk,[4,this.keyGraphService.unwrapWithPassKey(r.passKey.id,i,r.masterKey.id)];case 3:return a=s.sent(),[4,this.idleService.persistMasterKey(a)];case 4:return s.sent(),[4,this.keyGraphService.populateKeys(r)];case 5:return s.sent(),this.user={username:n,resetUser:null,sub:"DEBUG_MODE",loginEmail:"DEBUG_MODE"},[2,this.user]}}))}))},r.prototype.debugClearUser=function(){this.user=null},r.prototype.getCurrentUserAttibutes=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return[4,this.cognito.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.cognito.userAttributes(e)];case 2:return[2,t.sent()]}}))}))},r}(At),e.Auth2Service.CHALLENGE_TIMEOUT=3e5,e.Auth2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.Auth2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(f.HttpClient),t.ɵɵinject(s.AuthClass),t.ɵɵinject(e.ɵf),t.ɵɵinject(Ke),t.ɵɵinject(ke),t.ɵɵinject(ve),t.ɵɵinject(Dr),t.ɵɵinject(xt),t.ɵɵinject(Ce),t.ɵɵinject(he),t.ɵɵinject(e.ɵi),t.ɵɵinject(me))},token:e.Auth2Service,providedIn:"root"}),e.Auth2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.Auth2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:f.HttpClient},{type:s.AuthClass},{type:e.ɵf},{type:Ke},{type:ke},{type:ve},{type:Dr},{type:xt},{type:Ce},{type:he},{type:e.ɵi},{type:void 0,decorators:[{type:t.Inject,args:[me]}]}]},e.Auth2Service=ki=O([et({ngZoneName:"ngZone"})],e.Auth2Service),(Pi=e.FileType||(e.FileType={})).RecordContent="record-content",Pi.RecordAttachment="record-attachment";var Di,Ri,Mi,Oi,Ai,ji,Ti,Ni,$i=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordContent}}]}),Fi=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordAttachment}}]}),Ui=function(e){return void 0===e&&(e=5),k.default(Di||(Di=F(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n confidentiality {\n isConfidential\n method\n }\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n confidentiality {\n isConfidential\n method\n }\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),bn(e),qe)},Li=k.default(Ri||(Ri=F(["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),xi=k.default(Mi||(Mi=F(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),_i=k.default(Oi||(Oi=F(["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Ji=k.default(Ai||(Ai=F(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),qi=k.default(ji||(ji=F(["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"],["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"]))),Gi=k.default(Ti||(Ti=F(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Vi=k.default(Ni||(Ni=F(["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"],["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"]))),Bi=function(){function t(e,t,n){this.lrApollo=e,this.keyMetaService=t,this.keyGraph=n}return t.prototype.getRootDirectoryIds=function(e){return void 0===e&&(e=null),A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:mn,variables:{archived:e&&e.archived}})];case 1:return[2,t.sent().rootDirectories.edges.map((function(e){return e.node.id}))]}}))}))},t.prototype.getDefaultVault=function(){return A(this,void 0,void 0,(function(){var e,t;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Sn,variables:{plainMetaFilter:dn}})];case 1:return e=n.sent().list,[4,this.mapVaults(e)];case 2:if((t=n.sent()).length>1)throw new Q("There are more than one default vaults");return[2,t[0]||null]}}))}))},t.prototype.getCategories=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return(r=null==e?void 0:e.vaultDirectoryId)?[3,2]:[4,this.getDefaultVault()];case 1:r=null===(t=a.sent())||void 0===t?void 0:t.id,a.label=2;case 2:return(n=r)?[4,this.lrApollo.query({query:gn,variables:{vaultDirectoryId:n,categoryFilter:ln,recordFilter:yn,archived:null==e?void 0:e.archived}})]:(console.error("There is no default vault."),[2,[]]);case 3:return i=a.sent(),[2,this.mapCategories(i.directory.childDirectoryLinks)]}}))}))},t.prototype.getTrustedPartyCategories=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:In,variables:{trustedPartyId:e,categoryFilter:ln,recordFilter:yn,contentFilter:$i}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.theirItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.theirItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getMySharedCategories=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Cn,variables:{trustedPartyId:e,categoryFilter:ln,recordFilter:yn,contentFilter:$i}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.myItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.myItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getCategory=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return[4,this.lrApollo.query({query:wn(),variables:{id:e,categoryFilter:ln,recordFilter:yn,contentFilter:$i}})];case 1:return t=p.sent().category,n={},i=(r=Object).assign,s=(a=Object).assign,o=[{}],[4,this.mapCategory(t)];case 2:return c=[s.apply(a,o.concat([p.sent()]))],u={},[4,this.mapParentCategories(t)];case 3:return n.category=i.apply(r,c.concat([(u.parents=p.sent(),u)])),[4,this.mapCategories(t.subCategories)];case 4:return n.subCategories=p.sent(),[4,this.mapRecords(t.records)];case 5:return[2,(n.records=p.sent(),n)]}}))}))},t.prototype.mapVaults=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){return[2,Promise.all(e.edges.map((function(e){return t.mapVault(e.node)})))]}))}))},t.prototype.mapCategories=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapCategory(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.mapRecords=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapRecord(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.createDefaultVault=function(){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return"",[4,this.keyMetaService.wrapContent("")];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:Pn,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Vault,default:!0}),cipherMeta:t.cipherMeta,parentRootDirectory:t.rootKey}})];case 2:return[2,n.sent().new.vault.id]}}))}))},t.prototype.createCategory=function(t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return n={name:t.name,code:t.code,isCustom:t.isCustom,allowRecords:t.allowRecords,allowCustomCategories:t.allowCustomCategories},[4,this.keyMetaService.wrapContent(n,t.categoryIds)];case 1:return r=i.sent(),[4,this.lrApollo.mutate({mutation:kn,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:!1}),cipherMeta:r.cipherMeta,parentDirectories:r.wrappedKeys,parentRootDirectory:r.rootKey}})];case 2:return[2,i.sent().new.category.id]}}))}))},t.prototype.updateCategory=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return r={name:n.name,code:n.code,isCustom:n.isCustom,allowRecords:n.allowRecords,allowCustomCategories:n.allowCustomCategories},[4,this.keyGraph.encryptToString(t,r)];case 1:return i=a.sent(),[4,this.lrApollo.mutate({mutation:En,variables:{input:{directoryId:e,cipherMeta:i}}})];case 2:return a.sent(),[2]}}))}))},t.prototype.setCategoryVisibility=function(t,n){return A(this,void 0,void 0,(function(){return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.mutate({mutation:En,variables:{input:{directoryId:t,plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:n})}}})];case 1:return r.sent(),[2]}}))}))},t.prototype.deleteCategory=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Dn,variables:{categoryId:e}})];case 1:return t.sent(),[2]}}))}))},t.prototype.archiveCategory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.archiveDirectory(e,t)]}))}))},t.prototype.unarchiveCategory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.unarchiveDirectory(e,t)]}))}))},t.prototype.archiveDirectory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Rn,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.unarchiveDirectory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Mn,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapVault=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(e)];case 1:return t=(r.sent()||{}).name,[2,{id:e.id,keyId:e.keyId,name:t}];case 2:return n=r.sent(),console.error("Failed to decrypt Vault.",n,e),[2,null];case 3:return[2]}}))}))},t.prototype.mapParentCategories=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return e.parentCategories&&e.parentCategories.edges&&e.parentCategories.edges.length?(t=e.parentCategories.edges[0].node.parentDirectory,[4,this.mapParentCategories(t)]):[2,[]];case 1:return n=[r.sent()],[4,this.mapCategory(t)];case 2:return[2,$.apply(void 0,n.concat([[r.sent()]]))]}}))}))},t.prototype.mapCategory=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return p.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(e)];case 1:return n=p.sent()||{},r=n.name,i=n.isCustom,a=n.allowRecords,s=n.allowCustomCategories,o=n.code,c=(e.plainMeta&&JSON.parse(e.plainMeta)||{}).isHidden,[2,{id:e.id,keyId:e.keyId,code:o,name:r,isHidden:!!c,isCustom:!!i,isArchived:!!e.archived,allowRecords:!!a,allowCustomCategories:!!s,isEmpty:e.descendantDirectories?0===e.descendantDirectories.recordsCount:null,allRecordsCount:null===(t=e.descendantDirectories)||void 0===t?void 0:t.recordsCount}];case 2:return u=p.sent(),console.error("Failed to decrypt Category.",u,e),[2,null];case 3:return[2]}}))}))},t.prototype.mapRecord=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=e.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(t.currentVersion.state)];case 1:return n=s.sent()||{},r=n.name,i=n.recordType,[2,{id:e.id,keyId:e.keyId,name:r,recordType:i,isArchived:!!e.archived,createdOn:e.created,lastModified:new Date(e.modified)>new Date(t.currentVersion.state.modified)?e.modified:t.currentVersion.state.modified}];case 2:return a=s.sent(),console.error("Failed to decrypt Record.",a),[2,null];case 3:return[2]}}))}))},t}();Bi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Bi(t.ɵɵinject(Pe),t.ɵɵinject(On),t.ɵɵinject(ke))},token:Bi,providedIn:"root"}),Bi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Bi.ctorParameters=function(){return[{type:Pe},{type:On},{type:ke}]};var Qi,Wi=function(){},Zi=function(){function e(e,t){this.http=e,this.categoryService=t}return e.prototype.getCoreCategories=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return this.categories?[3,2]:(e=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 1:e.categories=t.sent(),t.label=2;case 2:return[2,Promise.resolve(this.categories)]}}))}))},e.prototype.loadCategories=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p=this;return j(this,(function(d){switch(d.label){case 0:return n?[4,this.categoryService.getTrustedPartyCategories(n)]:[3,2];case 1:return i=d.sent().categories,[3,4];case 2:return[4,this.categoryService.getCategories()];case 3:i=d.sent(),d.label=4;case 4:return r=i,t?[4,this.categoryService.getCategory(t)]:[3,6];case 5:return s=d.sent(),[3,7];case 6:s=null,d.label=7;case 7:return a=s,o=e.map((function(e){return A(p,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t={categoryTree:e},[4,this.loadCategory($(e),r,a)];case 1:return[2,(t.category=n.sent(),t)]}}))}))})),[4,Promise.all(o)];case 8:return c=d.sent(),u={categories:[],missingCategories:[]},c.forEach((function(e){return e.category?u.categories.push(e.category):u.missingCategories.push(e.categoryTree)})),[2,u]}}))}))},e.prototype.loadCategoriesForRole=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,this.categoryService.getCategories()];case 1:return t=r.sent(),[4,Promise.all(e.map((function(e){return A(n,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return n={},[4,this.loadCategory($(e.category),t)];case 1:return[2,(n.category=r.sent(),n.accessLevel=e.accessLevel,n)]}}))}))})))];case 2:return[2,r.sent()]}}))}))},e.prototype.loadCategory=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return r=e.shift(),(i=t.find((function(e){return e.code===r&&!e.isCustom})))?e.length?[4,this.categoryService.getCategory(i.id)]:[3,2]:[3,5];case 1:return a=o.sent().subCategories,[2,this.loadCategory(e,a,n)];case 2:return[4,this.categoryService.getCategory(i.id)];case 3:return s=o.sent().category,n&&n.category.parents.some((function(e){return e.id===s.id}))?[2,n.category]:[2,s];case 4:return[3,6];case 5:return e.length?[2,this.loadCategory(e,t,n)]:[2,null];case 6:return[2]}}))}))},e}();Zi.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Zi(t.ɵɵinject(f.HttpClient),t.ɵɵinject(Bi))},token:Zi,providedIn:"root"}),Zi.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Zi.ctorParameters=function(){return[{type:f.HttpClient},{type:Bi}]},(Qi=e.AccessLevel||(e.AccessLevel={})).Owner="OWNER",Qi.Admin="ADMIN",Qi.Writer="WRITER",Qi.Reader="READER",Qi.Deny="DENY";var Hi,Yi,zi,Xi=function(){},ea=function(){},ta=function(){},na=function(){},ra=function(){},ia=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),t}(ra),aa=function(){},sa=function(){},oa=function(){},ca=function(){},ua=je(Hi||(Hi=F(["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"],["\nmutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"]))),pa=je(Yi||(Yi=F(["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"],["\nmutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n}\n"]))),da=je(zi||(zi=F(["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteContactCardMutation($input: DeleteContactCardInput!) {\n deleteContactCard(input: $input) {\n id\n }\n}\n"]))),la=function(){};e.ContactCard2Service=function(){function e(e,t,n,r,i,a){this.keyFactory=e,this.keyService=t,this.encryptionService=n,this.keyGraph=r,this.keyMetaService=i,this.ngZone=a}return e.prototype.createContactCard=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return t=this.keyService.currentRootKey,[4,this.keyFactory.createKey()];case 1:return n=s.sent(),[4,this.keyGraph.encryptToString(t.jwk,n.toJSON(!0))];case 2:return r=s.sent(),[4,this.keyGraph.encryptToString(n,e.plainCipherDataJson)];case 3:return i=s.sent(),[4,this.prepareContactCardInput(e)];case 4:return a=s.sent(),[2,new pt({mutation:ua,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.keyGraph.encryptToString(e.keyId,e.plainCipherDataJson)];case 1:return t=r.sent(),[4,this.prepareContactCardInput(e)];case 2:return n=r.sent(),[2,new pt({mutation:pa,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new pt({mutation:da,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return t=this.keyService.currentSigPxk,i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicDataJson)];case 1:return n=i.apply(r,[d.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicSearchableJson)];case 2:return a=o.apply(s,[d.sent()]),p=(u=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.plainDataJson)];case 3:return c=p.apply(u,[d.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:c}]}}))}))},e}(),e.ContactCard2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ContactCard2Service(t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(he),t.ɵɵinject(ke),t.ɵɵinject(On),t.ɵɵinject(t.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:ve},{type:Ke},{type:he},{type:ke},{type:On},{type:t.NgZone}]},e.ContactCard2Service=O([et({ngZoneName:"ngZone"})],e.ContactCard2Service);var ya=function(){function e(e,t,n){this.config=e,this.http=t,this.auth=n}return e.prototype.downloadEncryptedFile=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile2(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile2=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return t=this.config.apiUrl+"files/download/?file_state_node_id="+e,r=(n=this.http).get,i=[t],s=(a=Object).assign,c=(o=Object).assign,u=[{}],[4,Se(this.auth,this.config)];case 1:return[4,r.apply(n,i.concat([s.apply(a,[c.apply(o,u.concat([p.sent()])),{responseType:"text"}])])).toPromise()];case 2:return[2,p.sent()]}}))}))},e.prototype.loadFile=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return e instanceof ArrayBuffer?[2,e]:[2,new Promise((function(t){var n=new FileReader;n.onload=function(){t(n.result)},n.readAsArrayBuffer(e)}))]}))}))},e.prototype.uploadEncryptedFile=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return t=e.encryptedContent,n=e.fileName,(r=new FormData).append("content",new Blob([t]),n),a=(i=this.http).post,s=[this.config.apiUrl+"files/upload/",r],[4,Se(this.auth,this.config)];case 1:return[4,a.apply(i,s.concat([o.sent()])).toPromise()];case 2:return[2,o.sent().content_resource]}}))}))},e}();ya.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ya(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(s.AuthClass))},token:ya,providedIn:"root"}),ya.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ya.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:s.AuthClass}]};var ha,fa,va,ma,ga=je(ha||(ha=F(["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"],["\nfragment LockFragment on LockField {\n created\n modified\n version\n expiryTime\n state\n}"]))),Sa=je(fa||(fa=F(["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation UpdateLockMutation($input: UpdateLockInput!) {\n updateLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),ga),Ia=je(va||(va=F(["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation AcquireLockMutation($input: AcquireLockInput!) {\n acquireLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),ga),Ca=je(ma||(ma=F(["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"],["\nmutation ReleaseLockMutation($input: ReleaseLockInput!) {\n releaseLock(input: $input) {\n lock {\n ...LockFragment\n }\n }\n}\n","\n"])),ga);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.updateLockMutation=function(e){return new pt({mutation:Sa,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t.prototype.acquireLockMutation=function(e){return new pt({mutation:Ia,variables:{input:{resourceId:e.resourceId,timeoutMs:e.timeoutMs}}})},t.prototype.releaseLockMutation=function(e){return new pt({mutation:Ca,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t}(At),e.LockService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.LockService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.LockService,providedIn:"root"}),e.LockService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.LockService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.LockService=O([et({ngZoneName:"ngZone"})],e.LockService);var ba,wa,Ka,ka,Pa,Ea,Da,Ra,Ma,Oa,Aa,ja,Ta,Na,$a,Fa,Ua,La,xa,_a,Ja,qa=je(ba||(ba=F(["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"],["\nmutation CreateDirectoryMutation($input: CreateDirectoryInput!) {\n createDirectory(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"]))),Ga=je(wa||(wa=F(["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"],["\nmutation UpdateDirectoryMutation($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n modified\n }\n }\n}\n"]))),Va=je(Ka||(Ka=F(["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteDirectoryMutation($input: DeleteDirectoryInput!) {\n deleteDirectory(input: $input) {\n id\n }\n}\n"]))),Ba=je(ka||(ka=F(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"],["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"]))),Qa=je(Pa||(Pa=F(["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation UpdateFileMutation($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),Wa=je(Ea||(Ea=F(["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation RevertFileMutation($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),Za=je(Da||(Da=F(["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteFileMutation($input: DeleteFileInput!) {\n deleteFile(input: $input) {\n id\n }\n}\n"]))),Ha=je(Ra||(Ra=F(["\nmutation ArchiveDirectoryMutation($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ArchiveDirectoryMutation($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),Ya=je(Ma||(Ma=F(["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ArchiveFileMutation($input: ArchiveFileInput!) {\n archiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),za=je(Oa||(Oa=F(["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation UnarchiveDirectoryMutation($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),Xa=je(Aa||(Aa=F(["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation UnarchiveFileMutation($input: UnarchiveFileInput!) {\n unarchiveFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),es=je(ja||(ja=F(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),ts=je(Ta||(Ta=F(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"]))),ns=je(Na||(Na=F(["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"],["\nmutation BeginDeleteChildItemLinksWindowMutation($input: BeginDeleteChildItemLinksWindowInput!) {\n beginDeleteChildItemLinksWindow(input: $input) {\n begin\n end\n scheduled\n windowMs\n directory {\n id\n }\n }\n}\n"]))),rs=je($a||($a=F(['\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: "created") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n'],['\nquery TempDirectoryQuery($plainMeta: LrJSONFilter!) {\n rootDirectories(plainMeta: $plainMeta, first: 2, orderBy: "created") {\n edges {\n node {\n id\n keyId\n }\n }\n }\n lock {\n version\n }\n}\n']))),is=je(Fa||(Fa=F(["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation SetFileConfidentialMutation($input: SetFileConfidentialInput!) {\n setFileConfidential(input: $input) {\n file {\n id\n }\n }\n}\n"]))),as=je(Ua||(Ua=F(["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation SetDirectoryConfidentialMutation($input: SetDirectoryConfidentialInput!) {\n setDirectoryConfidential(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),ss=je(La||(La=F(["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"],["\nquery DirectoryKeyQuery($id: LrRelayIdInput!) {\n directory(id: $id) {\n keyId\n }\n}\n"]))),os=je(xa||(xa=F(["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"],["\nquery FileKeyQuery($id: LrRelayIdInput!) {\n file(id: $id) {\n keyId\n }\n}\n"]))),cs=je(_a||(_a=F(["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"],["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"])));e.Item2Service=Ja=function(e){function t(t,n,r,i,a,s,o,c){var u=e.call(this,n)||this;return u.ngZone=t,u.injector=n,u.fileUploadService=r,u.keyService=i,u.keyFactory=a,u.keyGraph=s,u.lockService=o,u.auth2Service=c,u.tempDirectory=null,u.auth2Service.addLogoutListener((function(){return u.onLogout()})),u}return R(t,e),t.prototype.downloadFileContent=function(e){return A(this,void 0,void 0,(function(){var t,n,r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.fileUploadService.downloadEncryptedFile2(e.fileStateNodeId)];case 1:return t=i.sent(),[4,this.keyGraph.getKey(e.fileStateKeyId,(function(){return r.getFileStateKeyId(e.fileStateNodeId)}))];case 2:return n=i.sent(),[2,this.keyGraph.decryptFromString(n,t,{payloadType:"ArrayBuffer"})]}}))}))},t.prototype.getDirectoryKeyId=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.query({query:ss,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},t.prototype.getFileKeyId=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.query({query:os,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},t.prototype.getDirectoryKey=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},t.prototype.getFileKey=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},t.prototype.createDirectoryExec=function(e){return this.mutate(this.createDirectoryMutation(e))},t.prototype.createDirectory=function(e){return this.createDirectoryMutation(e)},t.prototype.createDirectoryMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:qa},r={},[4,this.prepareCreateDirectory(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.updateDirectoryExec=function(e){return this.mutate(this.updateDirectoryMutation(e))},t.prototype.updateDirectory=function(e){return this.updateDirectoryMutation(e)},t.prototype.updateDirectoryMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:Ga},r={},[4,this.prepareUpdateDirectory(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.deleteDirectoryExec=function(e){return this.mutate(this.deleteDirectoryMutation(e))},t.prototype.deleteDirectory=function(e){return this.deleteDirectoryMutation(e)},t.prototype.deleteDirectoryMutation=function(e){return new pt({mutation:Va,variables:{input:{directoryId:e}}})},t.prototype.createFileExec=function(e){return this.mutate(this.createFileMutation(e))},t.prototype.createFile=function(e){return this.createFileMutation(e)},t.prototype.createFileMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:Ba},r={},[4,this.prepareCreateFile(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.updateFileExec=function(e){return this.mutate(this.updateFileMutation(e))},t.prototype.updateFile=function(e){return this.updateFileMutation(e)},t.prototype.updateFileMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:Qa},r={},[4,this.prepareUpdateFile(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.revertFileExec=function(e){return this.mutate(this.revertFileMutation(e))},t.prototype.revertFile=function(e){return this.revertFileMutation(e)},t.prototype.revertFileMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:Wa,variables:{input:e}})]}))}))},t.prototype.deleteFileExec=function(e){return this.mutate(this.deleteFileMutation(e))},t.prototype.deleteFile=function(e){return this.deleteFileMutation(e)},t.prototype.deleteFileMutation=function(e){return new pt({mutation:Za,variables:{input:{fileId:e}}})},t.prototype.archiveDirectoryExec=function(e,t){return this.mutate(this.archiveDirectoryMutation(e,t))},t.prototype.archiveDirectory=function(e,t){return this.archiveDirectoryMutation(e,t)},t.prototype.archiveDirectoryMutation=function(e,t){return new pt({mutation:Ha,variables:{input:{directoryId:e,recursive:t.recursive}}})},t.prototype.archiveFileExec=function(e){return this.mutate(this.archiveFileMutation(e))},t.prototype.archiveFileMutation=function(e){return new pt({mutation:Ya,variables:{input:{fileId:e}}})},t.prototype.unarchiveDirectoryExec=function(e,t){return this.mutate(this.unarchiveDirectoryMutation(e,t))},t.prototype.unarchiveDirectory=function(e,t){return this.unarchiveDirectoryMutation(e,t)},t.prototype.unarchiveDirectoryMutation=function(e,t){return new pt({mutation:za,variables:{input:{directoryId:e,recursive:t.recursive}}})},t.prototype.unarchiveFileExec=function(e){return this.mutate(this.unarchiveFileMutation(e))},t.prototype.unarchiveFile=function(e){return this.unarchiveFileMutation(e)},t.prototype.unarchiveFileMutation=function(e){return new pt({mutation:Xa,variables:{input:{fileId:e}}})},t.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},t.prototype.changeDirectoryParentsMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:es},r={},[4,this.prepareChangeDirectoryParents(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.changeFileParents=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},t.prototype.changeFileParentsMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:ts},r={},[4,this.prepareChangeFileParents(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.beginDeleteChildItemLinksWindow=function(e){return this.mutate(this.beginDeleteChildItemLinksWindowMutation(e))},t.prototype.beginDeleteChildItemLinksWindowMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:ns,variables:{input:e}})]}))}))},t.prototype.ensureTempDirectory=function(){var e;return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return this.tempDirectory?[2,this.tempDirectory]:[4,this.query({query:rs,variables:{plainMeta:Ja.TEMP_DIRECTORY_PLAIN_META_FILTER}})];case 1:return(t=p.sent()).rootDirectories.edges.length>1&&console.error("There is more than 1 temp directory (plainMeta filter: "+Ja.TEMP_DIRECTORY_PLAIN_META_FILTER+")"),0!==t.rootDirectories.edges.length?[3,4]:[4,this.createDirectory({asRootDirectory:!0,plainMetaJson:Ja.TEMP_DIRECTORY_PLAIN_META})];case 2:return n=p.sent(),r=this.lockService.updateLockMutation({version:null===(e=t.lock)||void 0===e?void 0:e.version}),[4,this.lrGraphQL.lrMutate([n,r])];case 3:return i=N.apply(void 0,[p.sent(),1]),a=i[0],s=a.createDirectory.directory,c=s.id,u=s.keyId,this.tempDirectory={id:c,keyId:u},[3,5];case 4:o=t.rootDirectories.edges[0].node,c=o.id,u=o.keyId,this.tempDirectory={id:c,keyId:u},p.label=5;case 5:return[2,this.tempDirectory]}}))}))},t.prototype.createDirectoryTree=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.createDirectoryTreeMutation(e))]}))}))},t.prototype.createDirectoryTreeMutation=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.ensureTempDirectory()];case 1:return t=r.sent(),[4,this.beginDeleteChildItemLinksWindow({directoryId:t.id,requestWindowMs:e.requestWindowMs})];case 2:return r.sent(),[4,this.createDirectoryExec({cipherMetaClearJson:e.cipherMetaClearJson,parentDirectories:[{directoryId:t.id,wrappingKeyId:t.keyId}],plainMetaJson:e.plainMetaJson})];case 3:return n=r.sent().createDirectory.directory,[4,e.createContent({id:n.id,keyId:n.keyId})];case 4:return r.sent(),[2,this.changeDirectoryParentsMutation({directoryId:n.id,directoryKeyId:n.keyId,parentsToRemove:[t.id],parentsToAdd:e.parentDirectories})]}}))}))},t.prototype.setFileConfidential=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.setFileConfidentialMutation(e))]}))}))},t.prototype.setFileConfidentialMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:is,variables:{input:{fileId:e.fileId,confidential:e.confidential}}})]}))}))},t.prototype.setDirectoryConfidential=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.setDirectoryConfidentialMutation(e))]}))}))},t.prototype.setDirectoryConfidentialMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:as,variables:{input:{directoryId:e.directoryId,confidential:e.confidential}}})]}))}))},t.prototype.prepareParentDirectory=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.wrappingKeyId)];case 1:return n=i.sent(),r={directoryId:e.directoryId,wrappingKeyId:n.id},[4,this.keyGraph.wrapKey(n,t)];case 2:return[2,(r.wrappedKey=i.sent(),r.linkType=e.linkType,r)]}}))}))},t.prototype.getFileStateKeyId=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.query({query:cs,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},t.prototype.prepareCreateFileState=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y;return j(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),(i=t.file)?[4,this.fileUploadService.loadFile(t.file)]:[3,3];case 2:i=h.sent(),h.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,8];case 4:return s=h.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=h.sent(),[3,8];case 6:return[4,this.fileUploadService.uploadEncryptedFile({encryptedContent:s})];case 7:a=h.sent(),h.label=8;case 8:return c=(o=Object).assign,p=(u=Object).assign,d=[{}],[4,this.prepareItem(n,t)];case 9:return l=[p.apply(u,d.concat([h.sent()]))],y={},[4,this.keyGraph.wrapKey(e,n)];case 10:return[2,c.apply(o,l.concat([(y.wrappedStateKey=h.sent(),y.contentResource=a,y)]))]}}))}))},t.prototype.prepareChangeItemParents=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i=this;return j(this,(function(a){switch(a.label){case 0:return e.parentsToAdd?[4,Promise.all(e.parentsToAdd.map((function(e){return i.prepareParentDirectory(e,t)})))]:[3,2];case 1:return r=a.sent(),[3,3];case 2:r=[],a.label=3;case 3:return n=r,[2,{directoriesToRemove:e.parentsToRemove||[],directoriesToAdd:n}]}}))}))},t.prototype.prepareItem=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return n=t.plainMetaJson,r=t.cipherMetaClearJson,i={plainMeta:n&&JSON.stringify(n)},(a=r)?[4,this.keyGraph.encryptToString(e,r)]:[3,2];case 1:a=s.sent(),s.label=2;case 2:return[2,(i.cipherMeta=a,i)]}}))}))},t.prototype.prepareCreateDirectory=function(e){var t,n,r;return A(this,void 0,void 0,(function(){var i,a,s,o,c,u,p=this;return j(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:if(i=d.sent(),e.parentDirectories=e.parentDirectories||[],!e.asRootDirectory&&!(null===(t=e.parentDirectories)||void 0===t?void 0:t.length))throw new q("A new directory must be either a root directory or a sub-directory. So you must provide either parentDirectories or asRootDirectory parameter.");if(e.asRootDirectory&&(null===(n=e.parentDirectories)||void 0===n?void 0:n.length))throw new q("A new directory must be either a root directory or a sub-directory. So you can only provide either parentDirectories or asRootDirectory parameter.");return[4,Promise.all(null===(r=e.parentDirectories)||void 0===r?void 0:r.map((function(e){return p.prepareParentDirectory(e,i)})))];case 2:return a=d.sent(),e.asRootDirectory?(o=this.keyService.currentRootKey,c={wrappingKeyId:o.id},[4,this.keyGraph.wrapKey(o,i)]):[3,4];case 3:c.wrappedKey=d.sent(),s=c,d.label=4;case 4:return[4,this.prepareItem(i,e)];case 5:return u=d.sent(),[2,Object.assign(Object.assign({},u),{parentDirectories:a,parentRootDirectory:s})]}}))}))},t.prototype.prepareUpdateDirectory=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareItem(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},t.prototype.prepareCreateFile=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i=this;return j(this,(function(a){switch(a.label){case 0:return[4,this.keyFactory.createKey()];case 1:return t=a.sent(),[4,Promise.all(e.parentDirectories.map((function(e){return A(i,void 0,void 0,(function(){var n,r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.prepareParentDirectory(e,t)];case 1:return n=s.sent(),r=n.directoryId,i=n.wrappingKeyId,a=n.wrappedKey,[2,{directoryId:r,wrappingKeyId:i,wrappedFileKey:a}]}}))}))})))];case 2:return n=a.sent(),[4,this.prepareCreateFileState(t,e)];case 3:return r=a.sent(),[2,Object.assign(Object.assign({},r),{parentDirectories:n})]}}))}))},t.prototype.prepareUpdateFile=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareCreateFileState(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},t.prototype.prepareChangeDirectoryParents=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},t.prototype.prepareChangeFileParents=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},t.prototype.onLogout=function(){this.tempDirectory=null},t}(At),e.Item2Service.TEMP_DIRECTORY_PLAIN_META={kcType:"temp"},e.Item2Service.TEMP_DIRECTORY_PLAIN_META_FILTER=JSON.stringify({filter:[{contains:Ja.TEMP_DIRECTORY_PLAIN_META}]}),e.Item2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.Item2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ya),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(ke),t.ɵɵinject(e.LockService),t.ɵɵinject(e.Auth2Service))},token:e.Item2Service,providedIn:"root"}),e.Item2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.Item2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ya},{type:Ke},{type:ve},{type:ke},{type:e.LockService},{type:e.Auth2Service}]},e.Item2Service=Ja=O([et({ngZoneName:"ngZone"})],e.Item2Service);var us,ps,ds,ls,ys,hs,fs,vs,ms="\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n}",gs="\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n pbk\n }\n mkReshareRequestCipher\n mkReshareResponseCipher\n mkReshareRequestSent\n mkReshareResponseSent\n",Ss=k.default(us||(us=F(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""],["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""])),gs,qe),Is=k.default(ps||(ps=F(["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"],["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"])),ms,qe),Cs=k.default(ds||(ds=F(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),ms,qe),bs=k.default(ls||(ls=F(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"])),ms),ws=k.default(ys||(ys=F(["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"],["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"])),ms,Ve),Ks=k.default(hs||(hs=F(["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),ms,gs),ks=k.default(fs||(fs=F(["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),ms,gs);(vs=e.OtkState||(e.OtkState={})).OTK_INITIATED="OTK_INITIATED",vs.OTK_ACCEPTED="OTK_ACCEPTED",vs.OTK_COMPLETED="OTK_COMPLETED";var Ps=function(){function t(e,t,n,r,i){this.keyFactory=e,this.keyService=t,this.lrApollo=n,this.encryptionService=r,this.auth2Service=i,this.CLIENT_NONCE_LENGTH=32}return t.prototype.getKeyExchangeList=function(e){return void 0===e&&(e={}),A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Is,variables:Object.assign({},e)})];case 1:return[2,t.sent().keyExchanges]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:i?bs:Cs,variables:{id:e,token:i}})];case 1:return t=n.sent().keyExchange,[4,this.decryptKeyExchange(t,r)];case 2:return[2,n.sent()]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,n)];case 1:return n=i.sent(),[3,3];case 2:if("no key found"!==(r=i.sent()).message)throw r;return[3,3];case 3:return[4,this.encryptionService.decrypt(t,n)];case 4:return[2,i.sent()]}}))}))},t.prototype.decryptKeyExchange=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return j(this,(function(d){switch(d.label){case 0:return e.isInitiator?(n=this.keyService.currentRootKey,[4,this.encryptionService.decrypt(n.jwk,e.initiatorRootKeyCipher)]):[3,7];case 1:return r=d.sent(),e.otk.initiatorOneTimePbkCipher?(s=this.decryptResponseCipher,[4,ve.asKey(r.otKey)]):[3,5];case 2:return o=[d.sent()],[4,ve.asKey(r.oneTimePrk)];case 3:return[4,s.apply(this,o.concat([d.sent(),e.otk.initiatorOneTimePbkCipher]))];case 4:return a=d.sent(),[3,6];case 5:a=null,d.label=6;case 6:return c=(i=a)&&i.responder,p=r&&r.initiator,[2,Object.assign(Object.assign({},e),{message:c?c.message:null,contactCard:c&&c.contactCard?c.contactCard.plainSharedCipherDataJson:null,myContactCard:p&&p.contactCard?p.contactCard.plainSharedCipherDataJson:null,myMessage:p&&p.message})];case 7:return[4,this.decryptOtk(e,t)];case 8:return u=d.sent(),p=u&&u.plainOtKeyCipher.initiator,[2,Object.assign(Object.assign({},e),{decryptedOtk:u,message:p&&p.message,contactCard:p&&p.contactCard&&p.contactCard.plainSharedCipherDataJson})]}}))}))},t.prototype.decryptOtk=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.getOtKey(e,t)];case 1:return(n=a.sent())&&e.otk.otKeyCipher?(i={},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:return i.plainOtKeyCipher=a.sent(),i.otKey=n,r=i,[3,4];case 3:r=null,a.label=4;case 4:return[2,r]}}))}))},t.prototype.getOtKey=function(t,n){return A(this,void 0,void 0,(function(){var r,i;return j(this,(function(a){switch(a.label){case 0:return n?[4,ve.asKey(Object.assign(Object.assign({},JSON.parse(t.otk.otKeyParams)),{k:n}))]:[3,2];case 1:return[2,a.sent()];case 2:return t.otk.state!==e.OtkState.OTK_INITIATED||t.isInitiator||!t.otk.responderPbkCipher?[3,5]:(r=this.keyService.currentPxk,[4,this.encryptionService.decrypt(r.jwk,JSON.parse(t.otk.responderPbkCipher),{serializations:[ce.COMPACT]})]);case 3:return(i=a.sent()).otKey?[4,ve.asKey(i.otKey)]:[3,5];case 4:return[2,a.sent()];case 5:return[2,null]}}))}))},t.prototype.initiateOtk=function(e){var t=e.message,n=e.email,r=e.contactCard,i=e.upgrade;return A(this,void 0,void 0,(function(){var e,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S;return j(this,(function(I){switch(I.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=I.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.auth2Service.getUser()];case 2:return s=I.sent(),[4,this.keyFactory.createPkcKey()];case 3:return o=I.sent(),c=this.keyService.currentPxk,u=this.keyService.currentSigPxk,p=null,r&&r.ownerPlainData?(l=(d=JSON).stringify,[4,this.encryptionService.sign(u.jwk,r.ownerPlainData)]):[3,5];case 4:p=l.apply(d,[I.sent()]),I.label=5;case 5:return y={message:t,contactCard:r?{plainSharedCipherDataJson:r.plainSharedCipherDataJson}:null},h={nonce:a,initiator:Object.assign(Object.assign({},y),{oneTimePbk:o.toJSON(),pbk:c.jwk.toJSON(),sigPbk:u.jwk.toJSON(),profile:{username:s.username}})},[4,this.encryptionService.encrypt(e,h)];case 6:return f=I.sent(),v={nonce:a,oneTimePrk:o.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:r,initiator:y},m=this.keyService.currentRootKey,[4,this.encryptionService.encrypt(m.jwk,v)];case 7:return g=I.sent(),S=e.toJSON(!0).k,[4,this.lrApollo.mutate({mutation:ws,variables:{input:{initiatorRootKeyCipher:JSON.stringify(g),initiatorPxkId:c.id,initiatorSigPxkId:u.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:JSON.stringify(f),sendEmail:n?{email:n,rawOtKey:S}:null,createTp:!0,initiatorPlainDataSig:p,upgrade:i}}})];case 8:return[2,{keyExchange:I.sent().initiateKeyExchangeOtk.keyExchange,otKeyK:S}]}}))}))},t.prototype.respondOtk=function(e){var t=e.id,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return A(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b,w,K,k,P,E,D,R,M,O,A,T,N,$,F,U,L,x,_,J,q,G,V,B,Q,W,Z,H,Y,z,X,ee,te,ne;return j(this,(function(j){switch(j.label){case 0:return[4,this.auth2Service.getUser()];case 1:return e=j.sent(),o=this.keyService.currentRootKey,c=this.keyService.currentMasterKey,[4,this.keyFactory.createKey()];case 2:return u=j.sent(),[4,this.keyFactory.createKey()];case 3:return p=j.sent(),[4,this.encryptionService.encrypt(o.jwk,u.toJSON(!0))];case 4:return d=j.sent(),[4,this.encryptionService.encrypt(c.jwk,p.toJSON(!0))];case 5:return l=j.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.oneTimePbk)];case 6:return y=j.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.pbk)];case 7:return h=j.sent(),[4,ve.asKey(r.plainOtKeyCipher.initiator.sigPbk)];case 8:return f=j.sent(),v=this.keyService.currentPxk,m=this.keyService.currentSigPxk,[4,this.encryptionService.sign(m.jwk,h.toJSON())];case 9:return g=j.sent(),[4,this.encryptionService.sign(m.jwk,f.toJSON())];case 10:return S=j.sent(),I={nonce:r.plainOtKeyCipher.nonce,sharedKey:u.toJSON(!0),mkSharedKey:p.toJSON(!0),responder:{pbk:v.jwk.toJSON(),sigPbk:m.jwk.toJSON(),profile:{username:e.username},message:i}},r.plainOtKeyCipher.initiator.contactCard?(b=r.plainOtKeyCipher.initiator.contactCard.plainSharedCipherDataJson,[4,this.keyFactory.createKey()]):[3,20];case 11:return w=j.sent(),[4,this.keyFactory.createKey()];case 12:return U=j.sent(),L=this.keyService.currentSigPxk,K={},P=(k=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,w.toJSON(!0))];case 13:return K.receiverWrappedKey=P.apply(k,[j.sent()]),K.receiverWrappingKeyId=o.id,a?(R=(D=JSON).stringify,[4,this.encryptionService.encrypt(w,a.plainReceiverCipherDataJson)]):[3,15];case 14:return E=R.apply(D,[j.sent()]),[3,16];case 15:E="",j.label=16;case 16:return K.receiverCipherData=E,O=(M=JSON).stringify,[4,this.encryptionService.encrypt(u,U.toJSON(!0))];case 17:return K.sharedWrappedKey=O.apply(M,[j.sent()]),C=K,[4,this.encryptionService.encrypt(U,b)];case 18:return W=j.sent(),A=C,N=(T=JSON).stringify,[4,this.encryptionService.sign(L.jwk,W)];case 19:A.sharedCipherDataSig=N.apply(T,[j.sent()]),C.sigPxkId=L.id,I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherKey:U.toJSON(!0)}),j.label=20;case 20:return s?[4,this.keyFactory.createKey()]:[3,32];case 21:return F=j.sent(),[4,this.keyFactory.createKey()];case 22:return U=j.sent(),L=this.keyService.currentSigPxk,x={},J=(_=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,F.toJSON(!0))];case 23:return x.ownerWrappedKey=J.apply(_,[j.sent()]),x.ownerWrappingKeyId=o.id,s.plainOwnerCipherDataJson?(V=(G=JSON).stringify,[4,this.encryptionService.encrypt(F,s.plainOwnerCipherDataJson)]):[3,25];case 24:return q=V.apply(G,[j.sent()]),[3,26];case 25:q="",j.label=26;case 26:return x.ownerCipherData=q,Q=(B=JSON).stringify,[4,this.encryptionService.encrypt(u,U.toJSON(!0))];case 27:return x.sharedWrappedKey=Q.apply(B,[j.sent()]),$=x,[4,this.encryptionService.encrypt(U,s.plainSharedCipherDataJson)];case 28:return W=j.sent(),Z=$,Y=(H=JSON).stringify,[4,this.encryptionService.sign(L.jwk,W)];case 29:return Z.sharedCipherDataSig=Y.apply(H,[j.sent()]),$.sigPxkId=L.id,s.ownerPlainData?(z=$,ee=(X=JSON).stringify,[4,this.encryptionService.sign(m.jwk,s.ownerPlainData)]):[3,31];case 30:z.ownerPlainDataSig=ee.apply(X,[j.sent()]),j.label=31;case 31:I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{plainSharedCipherDataJson:s.plainSharedCipherDataJson}),j.label=32;case 32:return[4,this.encryptionService.encrypt(y,I)];case 33:return te=j.sent(),[4,this.encryptionService.encrypt(r.otKey,te)];case 34:return te=j.sent(),[4,this.lrApollo.mutate({mutation:Ks,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:o.id,masterKeyId:c.id,responderPxkId:v.id,responderSigPxkId:m.id,signedInitiatorPbk:JSON.stringify(g),signedInitiatorSigPbk:JSON.stringify(S),rkWrappedSharedKey:JSON.stringify(d),mkWrappedMkSharedKey:JSON.stringify(l),initiatorOneTimePbkCipher:JSON.stringify(te),initiatorContactCard:C,responderContactCard:$}}})];case 35:return[2,{keyExchange:(ne=j.sent().respondKeyExchangeOtk).keyExchange,userSharedKey:ne.userSharedKey,tp:ne.tp}]}}))}))},t.prototype.completeOtk=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b,w,K,k,P,E,D,R,M,O,A,T,N,$,F,U,L,x,_,J;return j(this,(function(j){switch(j.label){case 0:return i=this.keyService.currentRootKey,a=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(i.jwk,t)];case 1:return s=j.sent(),c=this.decryptResponseCipher,[4,ve.asKey(s.otKey)];case 2:return u=[j.sent()],[4,ve.asKey(s.oneTimePrk)];case 3:return[4,c.apply(this,u.concat([j.sent(),n]))];case 4:if(o=j.sent(),s.nonce!==o.nonce)throw new Z("The nonce returned by responder does not match with the one created by the initiator.");return p=this.keyService.currentSigPxk,[4,ve.asKey(o.responder.sigPbk)];case 5:return d=j.sent(),[4,ve.asKey(o.responder.pbk)];case 6:return l=j.sent(),[4,this.encryptionService.sign(p.jwk,l.toJSON())];case 7:return y=j.sent(),[4,this.encryptionService.sign(p.jwk,d.toJSON())];case 8:return h=j.sent(),[4,ve.asKey(o.sharedKey)];case 9:return f=j.sent(),[4,this.encryptionService.encrypt(i.jwk,f.toJSON(!0))];case 10:return v=j.sent(),[4,ve.asKey(o.mkSharedKey)];case 11:return m=j.sent(),[4,this.encryptionService.encrypt(a.jwk,m.toJSON(!0))];case 12:return g=j.sent(),r?[4,this.keyFactory.createKey()]:[3,16];case 13:return I=j.sent(),C={},w=(b=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,I.toJSON(!0))];case 14:return C.receiverWrappedKey=w.apply(b,[j.sent()]),C.receiverWrappingKeyId=i.id,k=(K=JSON).stringify,[4,this.encryptionService.encrypt(I,r)];case 15:C.receiverCipherData=k.apply(K,[j.sent()]),S=C,j.label=16;case 16:return s.initiatorContactCard?(D=s.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,25];case 17:return R=j.sent(),[4,ve.asKey(o.responder.contactCard.sharedCipherKey)];case 18:return M=j.sent(),T=(A=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,R.toJSON(!0))];case 19:return O=T.apply(A,[j.sent()]),D.plainOwnerCipherDataJson?(U=(F=JSON).stringify,[4,this.encryptionService.encrypt(R,D.plainOwnerCipherDataJson)]):[3,21];case 20:return $=U.apply(F,[j.sent()]),[3,22];case 21:$="",j.label=22;case 22:return N=$,P={ownerWrappedKey:O,ownerWrappingKeyId:i.id,ownerCipherData:N},E={sigPxkId:p.id},[4,this.encryptionService.encrypt(M,D.plainSharedCipherDataJson)];case 23:return L=j.sent(),x=E,J=(_=JSON).stringify,[4,this.encryptionService.sign(p.jwk,L)];case 24:x.sharedCipherDataSig=J.apply(_,[j.sent()]),j.label=25;case 25:return[4,this.lrApollo.mutate({mutation:ks,variables:{input:{keyExchangeId:e,rootKeyId:i.id,masterKeyId:a.id,initiatorSigPxkId:p.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(h),rkWrappedSharedKey:JSON.stringify(v),mkWrappedMkSharedKey:JSON.stringify(g),responderContactCardCipher:S,initiatorContactCardCipher:P,initiatorContactCardSharedCipher:E}}})];case 26:return[2,j.sent().completeKeyExchangeOtk]}}))}))},t.prototype.currentUserSharedKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Ss,variables:{username:e.username,userId:e.userId}})];case 1:return[2,t.sent().currentUserSharedKey.userSharedKey]}}))}))},t}();Ps.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ps(t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(Pe),t.ɵɵinject(he),t.ɵɵinject(e.Auth2Service))},token:Ps,providedIn:"root"}),Ps.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ps.ctorParameters=function(){return[{type:ve},{type:Ke},{type:Pe},{type:he},{type:e.Auth2Service}]};var Es,Ds,Rs,Ms,Os,As,js,Ts,Ns,$s,Fs,Us=je(Es||(Es=F(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n config\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"],["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n config\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"]))),Ls=je(Ds||(Ds=F(["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"],["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"]))),xs=je(Rs||(Rs=F(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"])),Us),_s=je(Ms||(Ms=F(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),Us),Js=je(Os||(Os=F(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),Us),qs=je(As||(As=F(["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"],["\nmutation CancelKeyExchangeMutation($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"]))),Gs=je(js||(js=F(["\nmutation DeclineKeyExchangeMutation($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"],["\nmutation DeclineKeyExchangeMutation($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n}\n"]))),Vs=je(Ts||(Ts=F(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"])),Us),Bs=je(Ns||(Ns=F(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),Us,Ls),Qs=je($s||($s=F(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),Us,Ls),Ws=je(Fs||(Fs=F(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n","\n"],["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n","\n"])),Ls);e.KeyExchange2Service=function(e){function t(t,n,r,i,a,s){var o=e.call(this,n)||this;return o.ngZone=t,o.injector=n,o.keyFactory=r,o.keyService=i,o.encryptionService=a,o.keyGraph=s,o.CLIENT_NONCE_LENGTH=32,o}return R(t,e),t.prototype.getOtKey=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return t?[4,ve.asKey(Object.assign(Object.assign({},JSON.parse(e.otk.otKeyParams)),{k:t}))]:[3,2];case 1:return[2,i.sent()];case 2:return"OTK_INITIATED"!==e.otk.state||e.isInitiator||!e.otk.responderPbkCipher?[3,5]:(n=this.keyService.currentPxk,[4,this.encryptionService.decrypt(n.jwk,JSON.parse(e.otk.responderPbkCipher),{serializations:[ce.COMPACT]})]);case 3:return(r=i.sent()).otKey?[4,ve.asKey(r.otKey)]:[3,5];case 4:return[2,i.sent()];case 5:return[2,null]}}))}))},t.prototype.decryptOtk=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o;return j(this,(function(c){switch(c.label){case 0:return[4,this.getOtKey(e,t)];case 1:return n=c.sent(),r=e.otk,n&&r.otKeyCipher?(a=(i=Object).assign,s=[Object.assign({},r)],o={otKey:n},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:r=a.apply(i,s.concat([(o.otKeyCipherClearJson=c.sent(),o)])),c.label=3;case 3:return[2,Object.assign(Object.assign({},e),{otk:r})]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,n)];case 1:return n=i.sent(),[3,3];case 2:if("no key found"!==(r=i.sent()).message)throw r;return[3,3];case 3:return[4,this.encryptionService.decrypt(t,n)];case 4:return[2,i.sent()]}}))}))},t.prototype.decryptKeyExchangeAsInitiator=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return t=this.keyService.currentRootKey,[4,this.encryptionService.decrypt(t.jwk,e.initiatorRootKeyCipher)];case 1:return n=l.sent(),[4,ve.asKey(n.otKey)];case 2:return r=l.sent(),e=Object.assign(Object.assign({},e),{initiatorRootKeyCipherClearJson:n}),(i=e.otk).initiatorOneTimePbkCipher?(s=(a=Object).assign,o=[Object.assign({},i)],c={},u=this.decryptResponseCipher,p=[r],[4,ve.asKey(n.oneTimePrk)]):[3,5];case 3:return[4,u.apply(this,p.concat([l.sent(),i.initiatorOneTimePbkCipher]))];case 4:i=s.apply(a,o.concat([(c.initiatorOneTimePbkCipherClearJson=l.sent(),c)])),l.label=5;case 5:return i.otKeyCipher?(d=i,[4,this.encryptionService.decrypt(r,i.otKeyCipher)]):[3,7];case 6:d.otKeyCipherClearJson=l.sent(),l.label=7;case 7:return[2,Object.assign(Object.assign({},e),{otk:i})]}}))}))},t.prototype.decryptKeyExchangeAsResponder=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},t.prototype.decryptKeyExchange=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return e.isInitiator?[2,this.decryptKeyExchangeAsInitiator(e)]:[2,this.decryptKeyExchangeAsResponder(e,t)]}))}))},t.prototype.getKeyExchanges=function(e){var t=(void 0===e?{}:e).state;return A(this,void 0,void 0,(function(){var e,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,this.query({query:xs,variables:{state:t}})];case 1:return e=r.sent().keyExchanges,[2,Promise.all(e.edges.map((function(e){return n.decryptKeyExchange(e.node)})))]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.query({query:i?Js:_s,variables:{id:e,token:i},includeKeyGraph:!i})];case 1:return t=n.sent(),[2,this.decryptKeyExchange(t.keyExchange,r)]}}))}))},t.prototype.getCurrentUserSharedKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.query({query:Ws,variables:{username:e.username,userId:e.userId}})]}))}))},t.prototype.cancelKeyExchange=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.cancelKeyExchangeMutation(e)]}))}))},t.prototype.cancelKeyExchangeMutation=function(e){return new pt({mutation:qs,variables:{input:{id:e}}})},t.prototype.declineKeyExchangeExec=function(e,t){return this.mutate(this.declineKeyExchangeMutation(e,t))},t.prototype.declineKeyExchange=function(e,t){return this.declineKeyExchangeMutation(e,t)},t.prototype.declineKeyExchangeMutation=function(e,t){return new pt({mutation:Gs,variables:{input:{id:e,token:t}}})},t.prototype.initiateOtkExec=function(e){return void 0===e&&(e={}),A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t=this.mutate,[4,this.initiateOtkMutation(e)];case 1:return[2,t.apply(this,[n.sent().lrMutation])]}}))}))},t.prototype.initiateOtk=function(e){return void 0===e&&(e={}),this.initiateOtkMutation(e)},t.prototype.initiateOtkMutation=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return A(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,y,h,f,v;return j(this,(function(m){switch(m.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=m.sent(),t=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.keyFactory.createPkcKey()];case 2:return s=m.sent(),o=this.keyService.currentPxk,c=this.keyService.currentSigPxk,u=null,i&&i.ownerPlainDataJson?[4,this.encryptionService.signToString(c.jwk,i.ownerPlainDataJson)]:[3,4];case 3:u=m.sent(),m.label=4;case 4:return p={message:n,contactCard:i&&{sharedCipherDataClearJson:i.sharedCipherDataClearJson}},d={nonce:t,initiator:Object.assign(Object.assign({},p),{oneTimePbk:s.toJSON(),pbk:o.jwk.toJSON(),sigPbk:c.jwk.toJSON()})},[4,this.keyGraph.encryptToString(e,d)];case 5:return l=m.sent(),y={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},h=this.keyService.currentRootKey,[4,this.keyGraph.encryptToString(h.jwk,y)];case 6:return f=m.sent(),v=e.toJSON(!0).k,[2,{lrMutation:new pt({mutation:Vs,variables:{input:{initiatorRootKeyCipher:f,initiatorPxkId:o.id,initiatorSigPxkId:c.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:l,sendEmail:r&&{email:r,rawOtKey:v},createTp:!0,initiatorPlainDataSig:u,upgrade:a}}}),otKeyK:v}]}}))}))},t.prototype.respondOtkExec=function(e){return this.mutate(this.respondOtkMutation(e))},t.prototype.respondOtk=function(e){return this.respondOtkMutation(e)},t.prototype.respondOtkMutation=function(e){var t=e.keyExchangeId,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return A(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b,w,K,k,P,E,D,R,M,O,A,T,N,$,F,U,L,x,_,J,q,G,V,B,Q,W,Z,H,Y,z,X,ee;return j(this,(function(j){switch(j.label){case 0:return e=this.keyService.currentRootKey,o=this.keyService.currentMasterKey,[4,this.keyFactory.createKey()];case 1:return c=j.sent(),[4,this.keyFactory.createKey()];case 2:return u=j.sent(),[4,this.encryptionService.encrypt(e.jwk,c.toJSON(!0))];case 3:return p=j.sent(),[4,this.encryptionService.encrypt(o.jwk,u.toJSON(!0))];case 4:return d=j.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 5:return l=j.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 6:return y=j.sent(),[4,ve.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 7:return h=j.sent(),f=this.keyService.currentPxk,v=this.keyService.currentSigPxk,[4,this.encryptionService.sign(v.jwk,y.toJSON())];case 8:return m=j.sent(),[4,this.encryptionService.sign(v.jwk,h.toJSON())];case 9:return g=j.sent(),S={nonce:r.otKeyCipherClearJson.nonce,sharedKey:c.toJSON(!0),mkSharedKey:u.toJSON(!0),responder:{pbk:f.jwk.toJSON(),sigPbk:v.jwk.toJSON(),message:i}},r.otKeyCipherClearJson.initiator.contactCard?(C=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,19];case 10:return b=j.sent(),[4,this.keyFactory.createKey()];case 11:return F=j.sent(),U=this.keyService.currentSigPxk,w={},k=(K=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,b.toJSON(!0))];case 12:return w.receiverWrappedKey=k.apply(K,[j.sent()]),w.receiverWrappingKeyId=e.id,a?(D=(E=JSON).stringify,[4,this.encryptionService.encrypt(b,a.receiverCipherDataClearJson)]):[3,14];case 13:return P=D.apply(E,[j.sent()]),[3,15];case 14:P="",j.label=15;case 15:return w.receiverCipherData=P,M=(R=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 16:return w.sharedWrappedKey=M.apply(R,[j.sent()]),I=w,[4,this.encryptionService.encrypt(F,C)];case 17:return Q=j.sent(),O=I,T=(A=JSON).stringify,[4,this.encryptionService.sign(U.jwk,Q)];case 18:O.sharedCipherDataSig=T.apply(A,[j.sent()]),I.sigPxkId=U.id,S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherKey:F.toJSON(!0)}),j.label=19;case 19:return s?[4,this.keyFactory.createKey()]:[3,31];case 20:return $=j.sent(),[4,this.keyFactory.createKey()];case 21:return F=j.sent(),U=this.keyService.currentSigPxk,L={},_=(x=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,$.toJSON(!0))];case 22:return L.ownerWrappedKey=_.apply(x,[j.sent()]),L.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(G=(q=JSON).stringify,[4,this.encryptionService.encrypt($,s.ownerCipherDataClearJson)]):[3,24];case 23:return J=G.apply(q,[j.sent()]),[3,25];case 24:J="",j.label=25;case 25:return L.ownerCipherData=J,B=(V=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 26:return L.sharedWrappedKey=B.apply(V,[j.sent()]),N=L,[4,this.encryptionService.encrypt(F,s.sharedCipherDataClearJson)];case 27:return Q=j.sent(),W=N,H=(Z=JSON).stringify,[4,this.encryptionService.sign(U.jwk,Q)];case 28:return W.sharedCipherDataSig=H.apply(Z,[j.sent()]),N.sigPxkId=U.id,s.ownerPlainDataJson?(Y=N,X=(z=JSON).stringify,[4,this.encryptionService.sign(v.jwk,s.ownerPlainDataJson)]):[3,30];case 29:Y.ownerPlainDataSig=X.apply(z,[j.sent()]),j.label=30;case 30:S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),j.label=31;case 31:return[4,this.encryptionService.encrypt(l,S)];case 32:return ee=j.sent(),[4,this.encryptionService.encrypt(r.otKey,ee)];case 33:return ee=j.sent(),[2,new pt({mutation:Bs,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:e.id,masterKeyId:o.id,responderPxkId:f.id,responderSigPxkId:v.id,signedInitiatorPbk:JSON.stringify(m),signedInitiatorSigPbk:JSON.stringify(g),rkWrappedSharedKey:JSON.stringify(p),mkWrappedMkSharedKey:JSON.stringify(d),initiatorOneTimePbkCipher:JSON.stringify(ee),initiatorContactCard:I,responderContactCard:N}}})]}}))}))},t.prototype.completeOtkExec=function(e){return this.mutate(this.completeOtkMutation(e))},t.prototype.completeOtk=function(e){return this.completeOtkMutation(e)},t.prototype.completeOtkMutation=function(e){var t=e.keyExchangeId,n=e.initiatorRootKeyCipher,r=e.initiatorOneTimePbkCipher,i=e.responderContactCard,a=e.initiatorContactCard;return A(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b,w,K,k,P,E,D,R,M,O,A,T,N,$,F,U,L,x,_,J;return j(this,(function(j){switch(j.label){case 0:return e=this.keyService.currentRootKey,s=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(e.jwk,n)];case 1:return o=j.sent(),u=this.decryptResponseCipher,[4,ve.asKey(o.otKey)];case 2:return p=[j.sent()],[4,ve.asKey(o.oneTimePrk)];case 3:return[4,u.apply(this,p.concat([j.sent(),r]))];case 4:if(c=j.sent(),o.nonce!==c.nonce)throw new Z("The nonce returned by responder does not match with the one created by the initiator.");return d=this.keyService.currentSigPxk,[4,ve.asKey(c.responder.sigPbk)];case 5:return l=j.sent(),[4,ve.asKey(c.responder.pbk)];case 6:return y=j.sent(),[4,this.encryptionService.sign(d.jwk,y.toJSON())];case 7:return h=j.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 8:return f=j.sent(),[4,ve.asKey(c.sharedKey)];case 9:return v=j.sent(),[4,this.encryptionService.encrypt(e.jwk,v.toJSON(!0))];case 10:return m=j.sent(),[4,ve.asKey(c.mkSharedKey)];case 11:return g=j.sent(),[4,this.encryptionService.encrypt(s.jwk,g.toJSON(!0))];case 12:return S=j.sent(),i?[4,this.keyFactory.createKey()]:[3,16];case 13:return C=j.sent(),b={},K=(w=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,C.toJSON(!0))];case 14:return b.receiverWrappedKey=K.apply(w,[j.sent()]),b.receiverWrappingKeyId=e.id,P=(k=JSON).stringify,[4,this.encryptionService.encrypt(C,i.receiverCipherDataClearJson)];case 15:b.receiverCipherData=P.apply(k,[j.sent()]),I=b,j.label=16;case 16:return o.initiatorContactCard?(R=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,25];case 17:return M=j.sent(),[4,ve.asKey(c.responder.contactCard.sharedCipherKey)];case 18:return O=j.sent(),N=(T=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,M.toJSON(!0))];case 19:return A=N.apply(T,[j.sent()]),($=(null==a?void 0:a.ownerCipherDataClearJson)||R.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(M,$)]:[3,21];case 20:return U=j.sent(),[3,22];case 21:U="",j.label=22;case 22:return F=U,E={ownerWrappedKey:A,ownerWrappingKeyId:e.id,ownerCipherData:F},D={sigPxkId:d.id},[4,this.encryptionService.encrypt(O,R.sharedCipherDataClearJson)];case 23:return L=j.sent(),x=D,J=(_=JSON).stringify,[4,this.encryptionService.sign(d.jwk,L)];case 24:x.sharedCipherDataSig=J.apply(_,[j.sent()]),j.label=25;case 25:return[2,new pt({mutation:Qs,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(h),signedResponderSigPbk:JSON.stringify(f),rkWrappedSharedKey:JSON.stringify(m),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:I,initiatorContactCardCipher:E,initiatorContactCardSharedCipher:D}}})]}}))}))},t}(At),e.KeyExchange2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.KeyExchange2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(he),t.ɵɵinject(ke))},token:e.KeyExchange2Service,providedIn:"root"}),e.KeyExchange2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.KeyExchange2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ve},{type:Ke},{type:he},{type:ke}]},e.KeyExchange2Service=O([et({ngZoneName:"ngZone"})],e.KeyExchange2Service);var Zs="LBOP";(e.KcLbopErrorCode||(e.KcLbopErrorCode={})).INVALID_PASSPHRASE="INVALID_PASSPHRASE";var Hs,Ys,zs,Xs,eo,to=k.default(Hs||(Hs=F(["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"],["\n mutation CreateLbop($input: CreateLbopInput!) {\n createLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"]))),no=k.default(Ys||(Ys=F(["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteLbop($input: DeleteLbopInput!) {\n deleteLbop(input: $input) {\n id\n }\n }\n"]))),ro=k.default(zs||(zs=F(["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"],["\n mutation UpdateLbop($input: UpdateLbopInput!) {\n updateLbop(input: $input) {\n lbop {\n id\n }\n }\n }\n"]))),io=k.default(Xs||(Xs=F(["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"],["\n query Lbop($id: LrRelayIdInput!) {\n lbop(id: $id) {\n id\n cipherMeta\n }\n }\n"]))),ao=k.default(eo||(eo=F(["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"],["\n query Lbops {\n lbops {\n edges {\n node {\n id\n cipherMeta\n }\n }\n }\n }\n"]))),so=function(){function t(e,t,n,r,i,a,s,o,c,u){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.auth2Service=i,this.keyFactory=a,this.keyService=s,this.encryptionService=o,this.keyGraph=c,this.passwordService=u,this.CLIENT_NONCE_LENGTH=32,this.LBOP_WORDS=25}return t.prototype.getPartial=function(e){return e.split(" ")[0]},t.prototype.remove=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:no,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteLbop.id]}}))}))},t.prototype.update=function(e){var t=e.id,n=e.name;return A(this,void 0,void 0,(function(){var e,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.get(t)];case 1:return(e=a.sent()).name=n,r=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(r.jwk,e)];case 2:return i=a.sent(),[4,this.lrApollo.mutate({mutation:ro,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 3:return[2,a.sent().updateLbop]}}))}))},t.prototype.get=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:io,variables:{id:e}})];case 1:return t=i.sent(),n=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(n.jwk,JSON.parse(t.lbop.cipherMeta))];case 2:return r=i.sent(),[2,Object.assign({id:t.id},r)]}}))}))},t.prototype.list=function(){return A(this,void 0,void 0,(function(){var e,t,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:ao})];case 1:return e=r.sent(),[4,this.keyService.currentMasterKey];case 2:return t=r.sent(),[2,Promise.all(e.lbops.edges.map((function(e){return A(n,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.encryptionService.decrypt(t.jwk,JSON.parse(e.node.cipherMeta))];case 1:return n=r.sent(),[2,Object.assign({id:e.node.id},n)]}}))}))})))]}}))}))},t.prototype.create=function(e){var t=e.name;return A(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g;return j(this,(function(S){switch(S.label){case 0:if(1024!==I.Slip39Helper.WORD_LIST.length)throw new G("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=S.sent(),r=function(){n=i.keyFactory.randomChoices(I.Slip39Helper.WORD_LIST,i.LBOP_WORDS).join(" ");var t=i.getPartial(n);if(!e.some((function(e){return e.partial===t})))return"break"},i=this;"break"!==r(););return[4,this.keyFactory.createLbopKeyParams()];case 2:return a=S.sent(),c=(o=this.keyFactory).deriveLbopKey,p=(u=Object).assign,d={},[4,this.keyFactory.importPassword(n)];case 3:return[4,c.apply(o,[p.apply(u,[(d.password=S.sent(),d),a])])];case 4:return s=S.sent().jwk,[4,this.keyFactory.createSignKey()];case 5:return l=S.sent(),[4,this.encryptionService.encrypt(s,l.toJSON(!0))];case 6:return y=S.sent(),h=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(s,h.jwk.toJSON(!0))];case 7:return f=S.sent(),v=Object.assign(Object.assign({},t&&{name:t}),{partial:this.getPartial(n)}),[4,this.encryptionService.encrypt(h.jwk,v)];case 8:return m=S.sent(),[4,this.lrApollo.mutate({mutation:to,variables:{input:{cipherMeta:JSON.stringify(m),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(l.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(y),masterKeyId:h.id,wrappedMasterKey:JSON.stringify(f)}}})];case 9:return g=S.sent(),[2,Object.assign(Object.assign({},g.createLbop.lbop),{lbopString:n})]}}))}))},t.prototype.verifyLbops=function(t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g;return j(this,(function(S){switch(S.label){case 0:r=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),S.label=1;case 1:S.trys.push([1,11,12,13]),i=T(t.lbops),a=i.next(),S.label=2;case 2:return a.done?[3,10]:(s=a.value,u=(c=this.keyFactory).deriveLbopKey,d=(p=Object).assign,l={},[4,this.keyFactory.importPassword(n)]);case 3:return[4,u.apply(c,[d.apply(p,[(l.password=S.sent(),l),s.lbopKeyParams])])];case 4:o=S.sent().jwk,S.label=5;case 5:return S.trys.push([5,8,,9]),[4,this.encryptionService.decrypt(o,s.wrappedLbopKeyVerifier)];case 6:return y=S.sent(),h=t.challenge.serverNonce,[4,this.encryptionService.sign(y,{serverNonce:h,clientNonce:r})];case 7:return f=S.sent(),[2,{lbop:s,signedChallenge:f,lbopKey:o}];case 8:return S.sent(),[3,9];case 9:return a=i.next(),[3,2];case 10:return[3,13];case 11:return v=S.sent(),m={error:v},[3,13];case 12:try{a&&!a.done&&(g=i.return)&&g.call(i)}finally{if(m)throw m.error}return[7];case 13:throw new _(new x({source:Zs,code:e.KcLbopErrorCode.INVALID_PASSPHRASE,message:"Invalid passphrase."}))}}))}))},t.prototype.verifyContact=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},t.prototype.confirmContact=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e.claimId,v_code:e.vCode}).toPromise()]}))}))},t.prototype.verify=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return[4,this.http.post(this.config.authUrl+"users/lbop-reset/get-challenge/",{claimId:e.claimId,claimToken:e.claimToken}).toPromise()];case 1:return t=p.sent(),[4,this.verifyLbops(t,e.lbop)];case 2:return n=p.sent(),r=n.signedChallenge,i=n.lbop,a=n.lbopKey,[4,this.http.post(this.config.authUrl+"users/lbop-reset/verify-challenge/",{lbopId:i.lbopId,signedChallenge:r}).toPromise()];case 3:return s=p.sent(),o={lbopId:i.lbopId,verifiedToken:s.verifiedToken,masterKeyId:s.masterKeyId},u=(c=ve).asKey,[4,this.encryptionService.decrypt(a,s.wrappedMasterKey)];case 4:return[4,u.apply(c,[p.sent()])];case 5:return[2,(o.masterKey=p.sent(),o)]}}))}))},t.prototype.setPassword=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.passwordService.createPassKeyBundle(e.newPassword)];case 1:return t=a.sent(),[4,this.encryptionService.encrypt(t.passKey,e.masterKey.toJSON(!0))];case 2:return n=a.sent(),[4,this.http.post(this.config.authUrl+"users/lbop-reset/set-password/",{lbopId:e.lbopId,verifiedToken:e.verifiedToken,masterKeyId:e.masterKeyId,newWrappedMasterKey:n,newPassKey:{passKeyParams:t.passKeyParams,passIdpParams:t.passIdpParams,passIdpVerifierPbk:t.passIdpVerifier.toJSON(),wrappedPassIdpVerifierPrk:t.wrappedPassIdpVerifierPrk}}).toPromise()];case 3:return r=a.sent(),[4,this.auth.signIn(r.username,r.idpPassword,{noProxy:"true"})];case 4:if("NEW_PASSWORD_REQUIRED"!==(i=a.sent()).challengeName)throw new z("Expecting Cognito to have done a password reset.");return[4,this.auth.completeNewPassword(i,this.passwordService.getPassIdpString(t.passIdp),{})];case 5:return i=a.sent(),[4,this.auth.signOut()];case 6:return a.sent(),[4,this.http.post(this.config.authUrl+"users/lbop-reset/complete/",{lbopId:e.lbopId,setPasswordToken:r.setPasswordToken}).toPromise()];case 7:return[2,a.sent()]}}))}))},t}();so.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new so(t.ɵɵinject(me),t.ɵɵinject(f.HttpClient),t.ɵɵinject(Pe),t.ɵɵinject(s.AuthClass),t.ɵɵinject(e.Auth2Service),t.ɵɵinject(ve),t.ɵɵinject(Ke),t.ɵɵinject(he),t.ɵɵinject(ke),t.ɵɵinject(Dr))},token:so,providedIn:"root"}),so.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],so.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:f.HttpClient},{type:Pe},{type:s.AuthClass},{type:e.Auth2Service},{type:ve},{type:Ke},{type:he},{type:ke},{type:Dr}]};var oo=function(){function e(){}return e.forRoot=function(r){return{ngModule:e,providers:[{provide:me,useValue:r},{provide:s.AuthClass,useValue:E.default},{provide:t.APP_INITIALIZER,useFactory:$t,deps:[me,s.AuthClass],multi:!0},{provide:t.APP_INITIALIZER,useFactory:fi,deps:[vi],multi:!0},{provide:n.APOLLO_OPTIONS,useFactory:Ie,deps:[me,s.AuthClass]}]}},e}();oo.decorators=[{type:t.NgModule,args:[{imports:[f.HttpClientModule,S.NgIdleKeepaliveModule.forRoot()]}]}];var co,uo,po=je(co||(co=F(["\nmutation SendMessageMutation($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n}\n"],["\nmutation SendMessageMutation($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n}\n"]))),lo=je(uo||(uo=F(["\nquery MessageQuery($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n}\n"],["\nquery MessageQuery($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n}\n"])));e.MessageService=function(e){function t(t,n,r,i,a){var s=e.call(this,n)||this;return s.ngZone=t,s.injector=n,s.keyGraph=r,s.encryptionService=i,s.keyExchangeService=a,s.encrypt=s.encryptionService.encrypt.bind(s.encryptionService),s.decrypt=s.encryptionService.decrypt.bind(s.encryptionService),s.sign=s.encryptionService.sign.bind(s.encryptionService),s.verify=s.encryptionService.verify.bind(s.encryptionService),s}return R(t,e),t.prototype.sendMessage=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.sendMessageMutation(e))]}))}))},t.prototype.sendMessageMutation=function(e){var t=e.username,n=e.userId,r=e.plainMessageJson,i=e.plainCipherMessageJson;return A(this,void 0,void 0,(function(){var e,a,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return[4,this.keyExchangeService.currentUserSharedKey({username:t,userId:n})];case 1:return e=l.sent(),i?[4,this.keyGraph.getJwkKey(e.sharedKey.id)]:[3,6];case 2:return s=l.sent(),[4,this.encrypt(s,i)];case 3:return o=l.sent(),[4,this.keyGraph.getJwkKey(e.userSigPrk.id)];case 4:return c=l.sent(),p=(u=JSON).stringify,[4,this.sign(c,o)];case 5:a=p.apply(u,[l.sent()]),l.label=6;case 6:return r&&(d=JSON.stringify(r)),[2,new pt({mutation:po,variables:{input:{receiverUsername:t,receiverId:n,sharedKeyId:e.sharedKey.id,senderSigPbkId:e.userSigPrk.id,signedCipherMessage:a,plainMessage:d}}})]}}))}))},t.prototype.decryptMessage=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.verify(t.senderSigPbk,JSON.parse(e.signedCipherMessage))];case 1:return n=i.sent(),r=e,[4,this.decrypt(t.sharedKey,n)];case 2:return r.signedCipherMessageClearJson=i.sent(),[2]}}))}))},t.prototype.getMessage=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.query({query:lo,variables:{id:e}})];case 1:return t=a.sent(),n=t.message,[4,this.keyGraph.getJwkKey(n.sharedKey.id)];case 2:return r=a.sent(),[4,this.keyGraph.getJwkKey(n.senderSigPbk.id)];case 3:return i=a.sent(),[4,this.decryptMessage(n,{sharedKey:r,senderSigPbk:i})];case 4:return a.sent(),n.plainMessage&&(n.plainMessageJson=JSON.parse(n.plainMessage)),[2,t.message]}}))}))},t}(At),e.MessageService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.MessageService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ke),t.ɵɵinject(he),t.ɵɵinject(Ps))},token:e.MessageService,providedIn:"root"}),e.MessageService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.MessageService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ke},{type:he},{type:Ps}]},e.MessageService=O([et({ngZoneName:"ngZone"})],e.MessageService);var yo,ho,fo,vo,mo,go=je(yo||(yo=F(["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"],["\nmutation UpdateNotificationMutation($input: UpdateNotificationInput!) {\n updateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"]))),So=je(ho||(ho=F(["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"],["\nmutation UpdateAllNotificationsReadStateMutation($input: UpdateAllNotificationsReadStateInput!) {\n updateAllNotificationsReadState(input: $input) {\n count\n }\n}\n"]))),Io=je(fo||(fo=F(["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"],["\nmutation DebugCreateNotificationMutation($input: DebugCreateNotificationInput!) {\n debugCreateNotification(input: $input) {\n notification {\n id\n }\n }\n}\n"]))),Co=je(vo||(vo=F(["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"],["\nmutation DebugDeleteAllNotificationsMutation($input: DebugDeleteAllNotificationsInput!) {\n debugDeleteAllNotifications(input: $input) {\n count\n }\n}\n"]))),bo=je(mo||(mo=F(["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"],["\nmutation UpdateNotificationFeatureStateMutation($input: UpdateNotificationFeatureStateInput!) {\n updateNotificationFeatureState(input: $input) {\n featureState {\n notificationsLastViewed\n\t\t}\n }\n}\n"])));e.NotificationService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.updateNotification=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.updateNotificationMutation(e))]}))}))},t.prototype.updateNotificationMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:go,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.updateAllNotificationsReadState=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.updateAllNotificationsReadStateMutation(e))]}))}))},t.prototype.updateAllNotificationsReadStateMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:So,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.debugCreateNotification=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.debugCreateNotificationMutation(e))]}))}))},t.prototype.debugCreateNotificationMutation=function(e){var t;return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,new pt({mutation:Io,variables:{input:{receiverId:e.receiverId,hasBeenRead:e.hasBeenRead,timeRead:null===(t=e.timeRead)||void 0===t?void 0:t.toISOString(),plainData:JSON.stringify(e.plainData),plainMeta:JSON.stringify(e.plainMeta)}}})]}))}))},t.prototype.debugDeleteAllNotifications=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.debugDeleteAllNotificationsMutation(e))]}))}))},t.prototype.debugDeleteAllNotificationsMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:Co,variables:{input:{receiverId:e.receiverId}}})]}))}))},t.prototype.updateNotificationFeatureState=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.updateNotificationFeatureStateMutation(e))]}))}))},t.prototype.updateNotificationFeatureStateMutation=function(e){var t;return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,new pt({mutation:bo,variables:{input:{lastViewed:null===(t=e.lastViewed)||void 0===t?void 0:t.toISOString(),clearLastViewed:null==e.lastViewed||void 0}}})]}))}))},t}(At),e.NotificationService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.NotificationService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.NotificationService,providedIn:"root"}),e.NotificationService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.NotificationService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.NotificationService=O([et({ngZoneName:"ngZone"})],e.NotificationService);var wo,Ko,ko,Po,Eo,Do,Ro,Mo,Oo,Ao=function(){},jo=function(){},To=function(){},No=function(){},$o=function(){},Fo=je(wo||(wo=F(["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"],["\nmutation InitiateStripePaymentMethodCaptureMutation {\n initiateStripePaymentMethodCapture(input: {}) {\n paymentCapture {\n stripeIntentId\n stripeClientSecret\n }\n }\n}\n"]))),Uo=je(Ko||(Ko=F(["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"],["\nmutation CompleteStripePaymentMethodCaptureMutation($input: CompleteStripePaymentMethodCaptureInput!) {\n completeStripePaymentMethodCapture(input: $input) {\n paymentMethod {\n id\n created\n modified\n card {\n brand\n lastFourDigits\n expiryYear\n expiryMonth\n }\n isDefault \n }\n }\n}\n"]))),Lo=je(ko||(ko=F(["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"],["\nmutation RemovePaymentMethodMutation($input: RemovePaymentMethodInput!) {\n removePaymentMethod(input: $input) {\n id\n }\n}\n"]))),xo=je(Po||(Po=F(["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"],["\nmutation SetDefaultPaymentMethodMutation($input: SetDefaultPaymentMethodInput!) {\n setDefaultPaymentMethod(input: $input) {\n paymentMethod {\n id\n } \n }\n}\n"]))),_o=je(Eo||(Eo=F(["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"],["\nmutation RemoveDefaultPaymentMethodMutation {\n removeDefaultPaymentMethod(input: {}) {\n paymentMethod {\n id\n } \n }\n}\n"]))),Jo=je(Do||(Do=F(["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation IssuePlanMutation($input: IssuePlanInput!) {\n issuePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"]))),qo=je(Ro||(Ro=F(["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"],["\nmutation CancelPlanMutation($input: CancelPlanInput!) {\n cancelPlan(input: $input) {\n plan {\n id\n } \n }\n}\n"]))),Go=je(Mo||(Mo=F(["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation ChangePriceOptionMutation($input: ChangePriceOptionInput!) {\n changePriceOption(input: $input) {\n plan {\n id\n }\n }\n}\n"]))),Vo=je(Oo||(Oo=F(["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"],["\nmutation ReactivatePlanMutation($input: ReactivatePlanInput!) {\n reactivatePlan(input: $input) {\n plan {\n id\n }\n }\n}\n"])));e.Plan2Service=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.initiateStripePaymentMethodCapture=function(){return this.mutate(this.initiateStripePaymentMethodCaptureMutation())},t.prototype.initiateStripePaymentMethodCaptureMutation=function(){return new pt({mutation:Fo,variables:{input:{}}})},t.prototype.completeStripePaymentMethodCapture=function(e){return this.mutate(this.completeStripePaymentMethodCaptureMutation(e))},t.prototype.completeStripePaymentMethodCaptureMutation=function(e){return new pt({mutation:Uo,variables:{input:{stripeIntentId:e}}})},t.prototype.setDefaultPaymentMethod=function(e){return this.mutate(this.setDefaultPaymentMethodMutation(e))},t.prototype.setDefaultPaymentMethodMutation=function(e){return new pt({mutation:xo,variables:{input:{paymentMethodId:e}}})},t.prototype.removeDefaultPaymentMethod=function(){return this.mutate(this.removeDefaultPaymentMethodMutation())},t.prototype.removeDefaultPaymentMethodMutation=function(){return new pt({mutation:_o,variables:{input:{}}})},t.prototype.issuePlan=function(e){return this.mutate(this.issuePlanMutation(e))},t.prototype.issuePlanMutation=function(e){return new pt({mutation:Jo,variables:{input:e}})},t.prototype.removePaymentMethod=function(e){return this.mutate(this.removePaymentMethodMutation(e))},t.prototype.removePaymentMethodMutation=function(e){return new pt({mutation:Lo,variables:{input:{paymentMethodId:e}}})},t.prototype.cancelPlan=function(e){return this.mutate(this.cancelPlanMutation(e))},t.prototype.cancelPlanMutation=function(e){return new pt({mutation:qo,variables:{input:e}})},t.prototype.changePriceOption=function(e){return this.mutate(this.changePriceOptionMutation(e))},t.prototype.changePriceOptionMutation=function(e){return new pt({mutation:Go,variables:{input:e}})},t.prototype.reactivatePlan=function(e){return this.mutate(this.reactivatePlanMutation(e))},t.prototype.reactivatePlanMutation=function(e){return new pt({mutation:Vo,variables:{input:{planId:e}}})},t}(At),e.Plan2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.Plan2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.Plan2Service,providedIn:"root"}),e.Plan2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.Plan2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.Plan2Service=O([et({ngZoneName:"ngZone"})],e.Plan2Service);var Bo,Qo="\n id\n owner {\n id\n username\n }\n ownerKey {\n id\n }\n ownerCipherData\n receiver {\n id\n username\n }\n receiverKey {\n id\n }\n receiverCipherData\n sharedKey {\n id\n }\n sharedCipherData\n sharedCipherDataSig\n sharedCipherDataSigPxk {\n id\n }\n",Wo=k.default(Bo||(Bo=F(["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ","\n }\n }\n}"],["\nmutation UpdateOwnedContactCard(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(\n input: $input\n ) {\n ownedContactCard {\n ","\n }\n }\n}"])),Qo),Zo=function(){function e(e,t,n,r){this.keyService=e,this.lrApollo=t,this.keyGraph=n,this.encryptionService=r}return e.prototype.decryptSharedTrustedPartyDetails=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.decryptTrustedPartyDetails(e)];case 1:return t=n.sent(),[2,Object.assign({id:e.id,ownedKeyId:e.ownerKey.id,sharedKeyId:e.sharedKey.id},t)]}}))}))},e.prototype.decryptTrustedPartyDetails=function(e){return A(this,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:if(!(e&&e.sharedKey&&e.sharedCipherData))return[3,5];i.label=1;case 1:return i.trys.push([1,4,,5]),n=(t=this.encryptionService).decrypt,[4,this.keyGraph.getJwkKey(e.sharedKey.id)];case 2:return[4,n.apply(t,[i.sent(),e.sharedCipherData])];case 3:return[2,i.sent()];case 4:return r=i.sent(),console.error("Cannot decrypt trusted party details",r),[3,5];case 5:return[2,null]}}))}))},e.prototype.updateMySharedContactCard=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h;return j(this,(function(f){switch(f.label){case 0:return[4,this.keyGraph.getKey(t)];case 1:return i=f.sent(),[4,this.keyGraph.getKey(n)];case 2:return a=f.sent(),s=this.keyService.currentSigPxk,[4,this.encryptionService.encrypt(a.jwk,r)];case 3:return o=f.sent(),p=(u=JSON).stringify,[4,this.encryptionService.sign(s.jwk,o)];case 4:return c=p.apply(u,[f.sent()]),d={name:new dr(r.name)},h=(y=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 5:return l=h.apply(y,[f.sent()]),[4,this.lrApollo.mutate({mutation:Wo,variables:{input:{id:e,ownerCipherData:"",ownerKeyId:i.id,sharedCipherDataSig:c,sharedKeyId:a.id,sigPxkId:s.id,ownerPlainDataSig:l}}})];case 6:return f.sent(),[2]}}))}))},e}();Zo.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Zo(t.ɵɵinject(Ke),t.ɵɵinject(Pe),t.ɵɵinject(ke),t.ɵɵinject(he))},token:Zo,providedIn:"root"}),Zo.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Zo.ctorParameters=function(){return[{type:Ke},{type:Pe},{type:ke},{type:he}]};var Ho,Yo,zo,Xo=k.default(Ho||(Ho=F(["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"],["\n mutation RequestUserDelete($input: RequestUserDeleteInput!) {\n requestUserDelete(input: $input) {\n userDelete {\n state\n created\n }\n }\n }\n"]))),ec=k.default(Yo||(Yo=F(["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"],["\n mutation CancelUserDelete($input: CancelUserDeleteInput!) {\n cancelUserDelete(input: $input) {\n id\n }\n }\n"]))),tc=k.default(zo||(zo=F(["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"],["\n query LoginHistory($first: Int, $after: String) {\n loginHistory(first: $first, after: $after) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n events\n }\n }\n"]))),nc=function(){function e(e){this.lrApollo=e}return e.prototype.requestUserDelete=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:Xo,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:ec,variables:{input:{}}})];case 1:return[2,e.sent().cancelUserDelete.id]}}))}))},e.prototype.loginHistory=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=null),A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:tc,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();nc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new nc(t.ɵɵinject(Pe))},token:nc,providedIn:"root"}),nc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],nc.ctorParameters=function(){return[{type:Pe}]};var rc,ic,ac,sc,oc,cc,uc,pc,dc,lc,yc,hc="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+Qo+"\n }\n myContactCard {\n "+Qo+"\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n theirItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n "+ms+"\n }\n "+gs+"\n }\n }",fc=k.default(rc||(rc=F(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"],["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"])),hc,Ge),vc=k.default(ic||(ic=F(["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),hc,ms,ms,Ge),mc=k.default(ac||(ac=F(["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"],["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"])),hc,Ge),gc=k.default(sc||(sc=F(["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Sc=k.default(oc||(oc=F(["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Ic=k.default(cc||(cc=F(["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"]))),Cc=k.default(uc||(uc=F(["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"]))),bc=k.default(pc||(pc=F(["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"])));!function(e){e.General="general",e.Scenario="scenario"}(dc||(dc={})),function(e){e.User="user",e.Organisation="organisation"}(lc||(lc={})),function(e){e.Invited="IN_PROGRESS",e.Cancelled="CANCELLED",e.Declined="DECLINED",e.Completed="COMPLETED"}(yc||(yc={}));!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}R(t,e)}(gr);var wc,Kc=function(){function e(e,t,n,r,i,a,s,o,c,u){this.http=e,this.lrApollo=t,this.sharedContactCardService=n,this.userService=r,this.authService=i,this.keyExchangeService=a,this.keyGraphService=s,this.keyService=o,this.keyFactory=c,this.encryptionService=u}return e.prototype.getTrustedParties=function(){return A(this,void 0,void 0,(function(){var e,t=this;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:fc})];case 1:return e=n.sent().tps,[4,Promise.all(e.edges.map((function(e){return t.mapTrustedParty(e.node)})))];case 2:return[2,n.sent()]}}))}))},e.prototype.getAllTrustedParties=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i,a,s=this;return j(this,(function(o){switch(o.label){case 0:return[4,this.authService.getUser()];case 1:return e=o.sent(),[4,this.lrApollo.query({query:vc,variables:{userId:e.id,isExpired:!1}})];case 2:return t=o.sent(),n=t.tps,r=t.invites,i=t.sentInvites,a={},[4,Promise.all(n.edges.map((function(e){return s.mapTrustedParty(e.node)})))];case 3:return a.parties=o.sent().filter((function(e){return e})),[4,Promise.all(r.edges.map((function(e){return A(s,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 4:return a.invites=o.sent().filter((function(e){return e.status!==yc.Completed})).filter((function(e){return e.status!==yc.Invited||e.actionRequired})),[4,Promise.all(i.edges.map((function(e){return A(s,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 5:return[2,(a.sentInvites=o.sent().filter((function(e){return e.status!==yc.Completed})),a)]}}))}))},e.prototype.getTrustedParty=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:mc,variables:{partyId:e}})];case 1:return t=n.sent().tp,[4,this.mapTrustedParty(t)];case 2:return[2,n.sent()]}}))}))},e.prototype.getTrustedPartyRoles=function(e){return void 0===e&&(e=dc.General),A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return this.trustedPartyRoles?[3,2]:(t=this,[4,this.http.get("/assets/meta/trusted-party-roles.json").toPromise()]);case 1:t.trustedPartyRoles=n.sent(),n.label=2;case 2:return[2,Promise.resolve(this.trustedPartyRoles.filter((function(t){return t.roleType===e})))]}}))}))},e.prototype.inviteTrustedParty=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t={responderUsername:e.party.username,email:e.party.email,message:{name:e.party.name,email:e.party.email,message:e.party.message,permissions:e.permissions},contactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new dr(e.mySharedDetails.name)}}},[4,this.keyExchangeService.initiateOtk(t)];case 1:return n.sent(),[2]}}))}))},e.prototype.cancelInvitation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Sc,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},e.prototype.getInvitation=function(e,t,n){return A(this,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyExchangeService.getKeyExchange(e,{token:t,otKeyK:n})];case 1:return r=i.sent(),[2,this.mapInvite(r)]}}))}))},e.prototype.acceptInvitation=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t={id:e.inviteId,token:e.inviteToken,decryptedOtk:e.decryptedOtk,initiatorContactCard:null,responderContactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new dr(e.mySharedDetails.name)}}},[4,this.keyExchangeService.respondOtk(t)];case 1:return[2,n.sent().tp.id]}}))}))},e.prototype.declineInvitation=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:gc,variables:{input:{id:e,token:t}}})];case 1:return n.sent(),[2]}}))}))},e.prototype.confirmInvitation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.keyExchangeService.completeOtk(e.inviteId,e.initiatorRootKeyCipher,e.initiatorOneTimePbkCipher,null)];case 1:return[2,t.sent().tp.id]}}))}))},e.prototype.removeTrustedParty=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ic,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},e.prototype.setCategoryAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},e.prototype.setRecordAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},e.prototype.shareDirectory=function(e,t,n,r){return A(this,void 0,void 0,(function(){var i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.keyGraphService.getKey(t)];case 1:return i=o.sent(),[4,this.keyGraphService.getKey(n.userSharedKey.sharedKey.id)];case 2:return a=o.sent(),[4,this.encryptionService.encrypt(a.jwk,i.jwk.toJSON(!0))];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:Cc,variables:{input:{id:e,tpId:n.id,accessRole:r,keyId:i.id,wrappingKeyId:a.id,wrappedKey:JSON.stringify(s)}}})];case 4:return o.sent(),[2]}}))}))},e.prototype.unshareDirectory=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:bc,variables:{input:{id:e,tpId:t}}})];case 1:return n.sent(),[2]}}))}))},e.prototype.mapTrustedParty=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),(r=e.sharedContactCard)?[4,this.sharedContactCardService.decryptTrustedPartyDetails(e.sharedContactCard)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return n=r,(a=e.myContactCard)?[4,this.sharedContactCardService.decryptSharedTrustedPartyDetails(e.myContactCard)]:[3,4];case 3:a=o.sent(),o.label=4;case 4:return i=a,[2,{id:e.id,type:lc.User,hasScenarios:!!e.sharedScenarios.edges.length,hasSharedVault:!!e.theirItems.directories.edges.length,name:n&&n.name&&n.name.name,details:n,mySharedDetails:i,userSharedKey:e.currentUserSharedKey.userSharedKey,username:e.other.username,features:{sharedVault:{hasAccess:"access"===((null===(t=e.other.features)||void 0===t?void 0:t.shareVault)||["noaccess"])[0]}}}];case 5:return s=o.sent(),console.error("Failed to decrypt Trusted Party.",s,e),[2,null];case 6:return[2]}}))}))},e.prototype.mapInvite=function(e){var t,n;return A(this,void 0,void 0,(function(){var r,i,a;return j(this,(function(s){return r=e.contactCard,i=e.isInitiator?null===(t=e.myMessage)||void 0===t?void 0:t.name:r&&r.name&&r.name.name,a=e.isInitiator?null===(n=e.myMessage)||void 0===n?void 0:n.email:r&&r.email||e.responderEmailAddress,[2,{id:e.id,type:lc.User,status:e.state,token:e.token,tokenExpiry:e.tokenExpiryTime,decryptedOtk:e.decryptedOtk,name:i,email:a,isSender:e.isInitiator,actionRequired:e.isInitiator?e.initiatorActionRequired:e.responderActionRequired,rootKeyCipher:e.initiatorRootKeyCipher,pbkCipher:e.otk.initiatorOneTimePbkCipher,isExpired:e.isExpired,details:r,message:e.message,mySharedDetails:e.myContactCard,mySharedMessage:e.myMessage}]}))}))},e}();Kc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Kc(t.ɵɵinject(f.HttpClient),t.ɵɵinject(Pe),t.ɵɵinject(Zo),t.ɵɵinject(nc),t.ɵɵinject(vi),t.ɵɵinject(Ps),t.ɵɵinject(ke),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(he))},token:Kc,providedIn:"root"}),Kc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Kc.ctorParameters=function(){return[{type:f.HttpClient},{type:Pe},{type:Zo},{type:nc},{type:vi},{type:Ps},{type:ke},{type:Ke},{type:ve},{type:he}]},function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(wc||(wc={}));var kc=[wc.Name,wc.Email,wc.Image,wc.Phone,wc.Address],Pc=function(){function e(e,t,n,r){this.sharedContactCardService=e,this.trustedPartyService=t,this.profileService=n,this.authService=r}return e.prototype.updateDetails=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.authService.getUser()];case 1:return t=n.sent(),[4,this.profileService.updateDetails(t.contactCard.id,t.contactCard.keyId,e)];case 2:return n.sent(),[4,this.synchronizeContactCards(e,t.contactCard)];case 3:return n.sent(),[4,this.authService.getUser(!0)];case 4:return[2,n.sent()]}}))}))},e.prototype.synchronizeContactCards=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.trustedPartyService.getTrustedParties()]:[2];case 1:if(0===(r=p.sent()).length)return[2];p.label=2;case 2:p.trys.push([2,7,8,9]),i=T(r.map((function(e){return e.mySharedDetails}))),a=i.next(),p.label=3;case 3:return a.done?[3,6]:(s=a.value,[4,this.synchronizeSharedContactCard(s,n)]);case 4:p.sent(),p.label=5;case 5:return a=i.next(),[3,3];case 6:return[3,9];case 7:return o=p.sent(),c={error:o},[3,9];case 8:try{a&&!a.done&&(u=i.return)&&u.call(i)}finally{if(c)throw c.error}return[7];case 9:return[2]}}))}))},e.prototype.getChanges=function(e,t){var n,r,i,a,s,o=[];try{for(var c=T(kc),u=c.next();!u.done;u=c.next()){var p=u.value,d=t[p];if(d&&d.values){var l=function(t){var n=null===(s=e[p].values)||void 0===s?void 0:s.find((function(e){return e.id===t.id}));n?K.default.isEqual(n.value,t.value)||o.push({field:p,id:t.id,label:t.label,oldValue:t.value,newValue:n.value}):o.push({field:p,id:t.id,label:t.label,oldValue:t.value})};try{for(var y=(i=void 0,T(d.values)),h=y.next();!h.done;h=y.next()){l(h.value)}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=y.return)&&a.call(y)}finally{if(i)throw i.error}}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return o},e.prototype.synchronizeSharedContactCard=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return j(this,(function(y){switch(y.label){case 0:n=!1,r=function(t){switch(t.field){case wc.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case wc.Address:(r=e.addresses&&e.addresses.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;default:var r=e[t.field];K.default.isEqual(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=T(t),a=i.next();!a.done;a=i.next())s=a.value,r(s)}catch(e){d={error:e}}finally{try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(d)throw d.error}}return n?(o=e.id,c=e.ownedKeyId,u=e.sharedKeyId,p=M(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},e.prototype.updateTrustedPartyDetails=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=M(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(t,n,r,i)];case 1:return a.sent(),[4,this.synchronizeSharedDetails(e)];case 2:return a.sent(),[2]}}))}))},e.prototype.synchronizeSharedDetails=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y;return j(this,(function(h){switch(h.label){case 0:return[4,this.authService.getUser()];case 1:if(t=h.sent().contactCard,n=!1,t=Object.assign({},t),e.name&&(u=this.checkField(e.name,t.name))&&(t.name=u,n=!0),e.email&&(u=this.checkField(e.email,t.email))&&(t.email=u,n=!0),e.image&&(u=this.checkField(e.image,t.image))&&(t.image=u,n=!0),e.phones&&e.phones.length)try{for(r=T(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,t.phone,a.label))&&(t.phone=u,n=!0)}catch(e){p={error:e}}finally{try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(p)throw p.error}}if(e.addresses&&e.addresses.length)try{for(s=T(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,t.address,c.label))&&(t.address=u,n=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(y=s.return)&&y.call(s)}finally{if(l)throw l.error}}return n?[4,this.profileService.updateDetails(t.id,t.keyId,t)]:[3,3];case 2:h.sent(),h.label=3;case 3:return[2]}}))}))},e.prototype.checkField=function(e,t,n){return void 0===n&&(n=null),(t=t||{value:e,hasMultiple:!1}).values=t.values||[],0===t.values.length||t.values.every((function(t){return!K.default.isEqual(e,t.value)}))?(t.values.push({id:n+"-"+(new Date).getTime(),label:n,value:e}),t.hasMultiple=t.values.length>1,t.value=t.value||e,t):null},e}();Pc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Pc(t.ɵɵinject(Zo),t.ɵɵinject(Kc),t.ɵɵinject(Sr),t.ɵɵinject(vi))},token:Pc,providedIn:"root"}),Pc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Pc.ctorParameters=function(){return[{type:Zo},{type:Kc},{type:Sr},{type:vi}]};var Ec,Dc=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0},Rc=Dc,Mc=function(){function e(e){this.http=e}return e.prototype.getRecordTypes=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i=this;return j(this,(function(a){switch(a.label){case 0:return this.recordTypes?[3,2]:(e=this,[4,this.http.get("/assets/meta/record-types.json").toPromise()]);case 1:e.recordTypes=a.sent(),a.label=2;case 2:return this.categories?[3,4]:(t=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 3:t.categories=a.sent(),a.label=4;case 4:return n=this.categories.map((function(e){return e.subCategories})).reduce((function(e,t){return $(e,t)}),[]),r=this.recordTypes.map((function(e){return Object.assign(Object.assign({},e),{categoryNames:e.categories.map((function(e){return e.map((function(e){var t=n.find((function(t){return t.code===e}));return t?t.name:i.categories.find((function(t){return t.code===e})).name}))}))})})),[2,Promise.resolve(r)]}}))}))},e.prototype.getRecordType=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().find((function(t){return t.id===e}))]}}))}))},e.prototype.getRecordTypesForCategory=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().filter((function(t){return t.categories.some((function(t){return Dc(t,e)}))}))]}}))}))},e}();Mc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Mc(t.ɵɵinject(f.HttpClient))},token:Mc,providedIn:"root"}),Mc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Mc.ctorParameters=function(){return[{type:f.HttpClient}]},(Ec=e.RecordFieldType||(e.RecordFieldType={})).Text="text",Ec.Email="email",Ec.Url="url",Ec.Phone="phone",Ec.Date="date",Ec.Password="password",Ec.TextArea="textArea",Ec.Select="select",Ec.SingleChoice="singleChoice",Ec.MultiChoice="multiChoice",Ec.File="file",Ec.MultiFile="multiFile",Ec.Record="record",Ec.MultiRecord="multiRecord",Ec.Group="group",Ec.Custom="custom";var Oc=function(){},Ac=function(){},jc=function(){},Tc=function(){},Nc=function(){function t(e,t,n,r){this.fileUploadService=e,this.lrApollo=t,this.keyMetaService=n,this.keyGraph=r}return t.prototype.downloadAttachment=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.fileUploadService.downloadEncryptedFile(e)];case 1:return n=r.sent(),[4,this.keyGraph.decryptFile(t,n)];case 2:return[2,r.sent()]}}))}))},t.prototype.uploadAttachments=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){switch(r.label){case 0:return[4,Promise.all((t||[]).map((function(t){return A(n,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return t.fileId?t.isDeleted?[4,this.deleteAttachment(t.fileId)]:[3,2]:[3,4];case 1:return n.sent(),[2,null];case 2:return[2,t.fileId];case 3:return[3,6];case 4:return[4,this.addAttachment(e,t)];case 5:return[2,n.sent()];case 6:return[2]}}))}))})))];case 1:return[2,r.sent().filter((function(e){return e}))]}}))}))},t.prototype.addAttachment=function(t,n){return A(this,void 0,void 0,(function(){var r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return r={name:n.name,fieldId:n.fieldId,fileType:n.file.type,fileSize:n.file.size,lastModified:n.file.lastModified},[4,this.fileUploadService.loadFile(n.file)];case 1:return i=o.sent(),[4,this.keyMetaService.doubleWrapContent(r,[t],i)];case 2:return a=o.sent(),[4,this.fileUploadService.uploadEncryptedFile({encryptedContent:a.cipherFileContent,fileName:n.name})];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:Gi,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordAttachment}),wrappedStateKey:a.doubleWrappedKey,cipherMeta:a.cipherMeta,parentDirectories:a.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}})),contentResource:s}}})];case 4:return[2,o.sent().createFile.file.id]}}))}))},t.prototype.deleteAttachment=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Vi,variables:{fileId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Nc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Nc(t.ɵɵinject(ya),t.ɵɵinject(Pe),t.ɵɵinject(On),t.ɵɵinject(ke))},token:Nc,providedIn:"root"}),Nc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Nc.ctorParameters=function(){return[{type:ya},{type:Pe},{type:On},{type:ke}]};var $c=function(){function t(e,t,n,r){this.lrApollo=e,this.keyMetaService=t,this.categoryService=n,this.recordAttachmentService=r}return t.prototype.getRecord=function(e){var t;return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p=this;return j(this,(function(d){switch(d.label){case 0:return[4,this.lrApollo.query({query:Ui(),variables:{id:e,categoryFilter:ln,contentFilter:$i,attachmentsFilter:Fi}})];case 1:return n=d.sent().record,r=n.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(r.currentVersion.state)];case 2:return i=d.sent()||{},a=i.name,s=i.recordType,o=i.fields,[4,Promise.all(n.parentCategories.edges.map((function(e){return A(p,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.categoryService.mapParentCategories(e.node.parentDirectory)];case 1:return t=[n.sent()],[4,this.categoryService.mapCategory(e.node.parentDirectory)];case 2:return[2,$.apply(void 0,t.concat([[n.sent()]]))]}}))}))})))];case 3:return c=d.sent(),[4,this.mapAttachments(n.attachments.edges)];case 4:return u=d.sent(),[2,{id:n.id,keyId:n.keyId,updateKeyId:r.keyId,updateId:r.id,name:a,recordType:s,fields:o,categories:c,attachments:u,isArchived:!!n.archived,isConfidential:!!(null===(t=n.confidentiality)||void 0===t?void 0:t.isConfidential),createdOn:n.created,lastModified:new Date(n.modified)>new Date(r.currentVersion.state.modified)?n.modified:r.currentVersion.state.modified}]}}))}))},t.prototype.mapAttachments=function(e){return A(this,void 0,void 0,(function(){var t=this;return j(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return e.node.childFile})).map((function(e){return A(t,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.keyMetaService.decryptMeta(e.currentVersion.state)];case 1:return t=o.sent()||{},n=t.name,r=t.fieldId,i=t.fileType,a=t.fileSize,s=t.lastModified,[2,{fileId:e.id,keyId:e.currentVersion.state.keyId,contentId:e.currentVersion.state.id,fieldId:r,name:n,fileType:i,fileSize:a,lastModified:s}]}}))}))})))];case 1:return[2,n.sent()]}}))}))},t.prototype.createRecord=function(t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o;return j(this,(function(c){switch(c.label){case 0:return[4,this.keyMetaService.wrapContent(null,t.categoryIds)];case 1:return n=c.sent(),[4,this.lrApollo.mutate({mutation:Li,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Record,isHidden:!1}),parentDirectories:n.wrappedKeys,parentRootDirectory:n.rootKey}})];case 2:return r=c.sent(),i=r.new.category.id,a={name:t.name,recordType:t.recordType,fields:t.fields},[4,this.keyMetaService.doubleWrapContent(a,[i])];case 3:return s=c.sent(),[4,this.lrApollo.mutate({mutation:xi,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta,parentDirectories:s.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}}))}}})];case 4:c.sent(),c.label=5;case 5:return c.trys.push([5,7,,8]),[4,this.recordAttachmentService.uploadAttachments(i,t.attachments)];case 6:return c.sent(),[3,8];case 7:return o=c.sent(),console.error(o),[2,{recordId:i,attachmentError:o}];case 8:return[2,{recordId:i}]}}))}))},t.prototype.updateRecord=function(t,n,r,i){return A(this,void 0,void 0,(function(){var a,s,o;return j(this,(function(c){switch(c.label){case 0:return a={name:i.name,recordType:i.recordType,fields:i.fields},[4,this.keyMetaService.reWrapContent(r,a)];case 1:return s=c.sent(),[4,this.lrApollo.mutate({mutation:Ji,variables:{input:{fileId:n,plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta}}})];case 2:c.sent(),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,this.recordAttachmentService.uploadAttachments(t,i.attachments)];case 4:return c.sent(),[3,6];case 5:return o=c.sent(),console.error(o),[2,{recordId:t,attachmentError:o}];case 6:return[2,{recordId:t}]}}))}))},t.prototype.archiveRecord=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.categoryService.archiveDirectory(e,!0)]}))}))},t.prototype.unarchiveRecord=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.categoryService.unarchiveDirectory(e,!0)]}))}))},t.prototype.deleteRecord=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:qi,variables:{recordId:e}})];case 1:return t.sent(),[2]}}))}))},t}();$c.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new $c(t.ɵɵinject(Pe),t.ɵɵinject(On),t.ɵɵinject(Bi),t.ɵɵinject(Nc))},token:$c,providedIn:"root"}),$c.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],$c.ctorParameters=function(){return[{type:Pe},{type:On},{type:Bi},{type:Nc}]};var Fc=function(){},Uc=function(){},Lc=function(){},xc=function(){},_c=function(){},Jc=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),t}(xc),qc=function(){},Gc=function(){function e(e,t,n,r,i,a){this.config=e,this.auth=t,this.http=n,this.keyFactory=r,this.encryptionService=i,this.passwordService=a}return e.prototype.verifyEmail=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/claim/email/",{address:e,context:"signup"}).toPromise()];case 1:return[2,t.sent().claim_id]}}))}))},e.prototype.verifyPhone=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/claim/sms/",{address:e,context:"signup"}).toPromise()];case 1:return[2,t.sent().claim_id]}}))}))},e.prototype.confirmVerificationCode=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},e.prototype.register=function(e,t,n,r,i){return void 0===i&&(i="email"),A(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,y,h,f,v,m;return j(this,(function(g){switch(g.label){case 0:return[4,this.passwordService.createPassKeyBundle(t)];case 1:return a=g.sent(),[4,this.keyFactory.createKey()];case 2:return s=g.sent(),[4,this.encryptionService.encrypt(a.passKey,s.toJSON(!0))];case 3:return o=g.sent(),[4,this.keyFactory.createKey()];case 4:return c=g.sent(),[4,this.encryptionService.encrypt(s,c.toJSON(!0))];case 5:return u=g.sent(),[4,this.keyFactory.createPkcKey()];case 6:return p=g.sent(),[4,this.encryptionService.encrypt(c,p.toJSON(!0))];case 7:return d=g.sent(),[4,this.keyFactory.createPkcSignKey()];case 8:return l=g.sent(),[4,this.encryptionService.encrypt(c,l.toJSON(!0))];case 9:return y=g.sent(),[4,this.http.post(this.config.authUrl+"users/",{claims:[{type:i,token:r,claim_id:n}],pass_idp_params:a.passIdpParams,pass_idp_verifier_pbk:a.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:a.wrappedPassIdpVerifierPrk,pass_key_params:a.passKeyParams,wrapped_master_key:o,wrapped_root_key:u,pbk:p.toJSON(),wrapped_prk:d,sig_pbk:l.toJSON(),wrapped_sig_prk:y}).toPromise()];case 10:return h=g.sent(),f={},h.claims.forEach((function(e){f[e.type]=e.value})),v=this.keyFactory.randomDigitsNoZeros(4),[4,this.auth.signUp({username:e.split("@")[0]+"."+v,password:this.passwordService.getPassIdpString(a.passIdp),attributes:f,clientMetadata:{user_id:String(h.id),user_pre_sign_up_token:String(h.pre_sign_up_token)}})];case 11:return[2,{username:(m=g.sent()).user.getUsername(),userId:h.id,preSignUpToken:h.pre_sign_up_token,userSub:m.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.http.get(this.config.authUrl+"users/hibp/breachedaccount/"+e+"/?truncateResponse=false").toPromise()];case 1:return[2,n.sent()];case 2:if(404===(t=n.sent()).status)return[2,null];throw t;case 3:return[2]}}))}))},e}();Gc.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Gc(t.ɵɵinject(me),t.ɵɵinject(s.AuthClass),t.ɵɵinject(f.HttpClient),t.ɵɵinject(ve),t.ɵɵinject(he),t.ɵɵinject(Dr))},token:Gc,providedIn:"root"}),Gc.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Gc.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:s.AuthClass},{type:f.HttpClient},{type:ve},{type:he},{type:Dr}]};var Vc,Bc,Qc,Wc=je(Vc||(Vc=F(["\nmutation CreateReminderMutation($input: CreateReminderInput!) {\n createReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"],["\nmutation CreateReminderMutation($input: CreateReminderInput!) {\n createReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"]))),Zc=je(Bc||(Bc=F(["\nmutation UpdateReminderMutation($input: UpdateReminderInput!) {\n updateReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"],["\nmutation UpdateReminderMutation($input: UpdateReminderInput!) {\n updateReminder(input: $input) {\n reminder {\n id\n }\n }\n}\n"]))),Hc=je(Qc||(Qc=F(["\nmutation DeleteReminderMutation($input: DeleteReminderInput!) {\n deleteReminder(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteReminderMutation($input: DeleteReminderInput!) {\n deleteReminder(input: $input) {\n id\n }\n}\n"])));e.ReminderService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.createReminder=function(e){return this.mutate(this.createReminderMutation(e))},t.prototype.createReminderMutation=function(e){var t;return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,new pt({mutation:Wc,variables:{input:{directoryId:e.directoryId,firstEvent:e.firstEvent.toISOString(),plain:JSON.stringify(e.plainJson),notifyAheadSeconds:null!==(t=e.notifyAheadSeconds)&&void 0!==t?t:0}}})]}))}))},t.prototype.updateReminder=function(e){return this.mutate(this.updateReminderMutation(e))},t.prototype.updateReminderMutation=function(e){var t,n;return A(this,void 0,void 0,(function(){return j(this,(function(r){return[2,new pt({mutation:Zc,variables:{input:{id:e.id,firstEvent:null===(t=e.firstEvent)||void 0===t?void 0:t.toISOString(),plain:JSON.stringify(null!==(n=e.plainJson)&&void 0!==n?n:void 0),notifyAheadSeconds:e.notifyAheadSeconds}}})]}))}))},t.prototype.deleteReminder=function(e){return this.mutate(this.deleteReminderMutation(e))},t.prototype.deleteReminderMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:Hc,variables:{input:{id:e}}})]}))}))},t}(At),e.ReminderService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ReminderService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ReminderService,providedIn:"root"}),e.ReminderService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ReminderService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ReminderService=O([et({ngZoneName:"ngZone"})],e.ReminderService);e.ɵn=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase="lifeready",r}return R(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.sharedKey.id},t}(Fr),e.ɵn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵn(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵn,providedIn:"root"}),e.ɵn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵn.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵn=O([et({ngZoneName:"ngZone"})],e.ɵn);var Yc,zc,Xc,eu,tu,nu,ru,iu,au,su,ou,cu,uu=je(Yc||(Yc=F(["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"],["\nmutation CreateScenarioMutation($input: CreateScenarioInput!) {\n createScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"]))),pu=je(zc||(zc=F(["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"],["\nmutation UpdateScenarioMutation($input: UpdateScenarioInput!) {\n updateScenario(input: $input) {\n scenario {\n id\n }\n }\n}\n"]))),du=je(Xc||(Xc=F(["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteScenarioMutation($input: DeleteScenarioInput!) {\n deleteScenario(input: $input) {\n id\n }\n}\n"]))),lu=je(eu||(eu=F(["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation CreateScenarioClaimMutation($input: CreateScenarioClaimInput!) {\n createScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),yu=je(tu||(tu=F(["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation CancelScenarioClaimMutation($input: CancelScenarioClaimInput!) {\n cancelScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),hu=je(nu||(nu=F(["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"],["\nmutation RejectScenarioClaimMutation($input: RejectScenarioClaimInput!) {\n rejectScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"]))),fu=je(ru||(ru=F(["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"],["\nmutation ApproveScenarioClaimMutation($input: ApproveScenarioClaimInput!) {\n approveScenarioClaim(input: $input) {\n claimApprover {\n id\n }\n }\n}\n"]))),vu=je(iu||(iu=F(["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"],["\nmutation ReceiveScenarioClaimMutation($input: ReceiveScenarioClaimInput!) {\n receiveScenarioClaim(input: $input) {\n sharedClaim {\n id\n }\n }\n}\n"]))),mu=je(au||(au=F(["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"],["\nmutation DebugExpireScenarioClaimMutation($input: DebugExpireScenarioClaimInput!) {\n debugExpireScenarioClaim(input: $input) {\n scenarioClaim {\n id\n }\n }\n}\n"]))),gu=je(su||(su=F(["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"],["\nmutation DebugExpireTpPasswordResetRequestMutation($input: DebugExpireTpPasswordResetRequestInput!) {\n debugExpireTpPasswordResetRequest(input: $input) {\n passwordResetRequest {\n id\n }\n }\n}\n"]))),Su=je(ou||(ou=F(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),Iu=je(cu||(cu=F(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"],["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));function Cu(){throw new q("claimId does not match with the current claimId of the scenario")}function bu(){throw new Q("Scenario claim has not been approved")}e.ScenarioService=function(t){function n(e,n,r,i,a,s){var o=t.call(this,n)||this;return o.ngZone=e,o.injector=n,o.keyGraph=r,o.item2Service=i,o.assemblyController=a,o.encryptionService=s,o.prepareAddReceiverDirectory=o.prepareReceiverDirectory,o.prepareUpdateReceiverDirectory=o.prepareReceiverDirectory,o}return R(n,t),n.prototype.createScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.createScenarioMutation(e))]}))}))},n.prototype.createScenarioMutation=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.prepareCreateScenarioMutation(e)];case 1:return t=n.sent(),[2,new pt({mutation:uu,variables:{input:t}})]}}))}))},n.prototype.updateScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.updateScenarioMutation(e))]}))}))},n.prototype.updateScenarioMutation=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.getScenario(e.scenarioId)];case 1:return t=r.sent().scenario,[4,this.prepareUpdateScenario(e,t)];case 2:return n=r.sent(),[2,new pt({mutation:pu,variables:{input:n}})]}}))}))},n.prototype.resetScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.resetScenarioMutation(e))]}))}))},n.prototype.resetScenarioMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.getScenario(e.scenarioId)];case 1:return t=a.sent().scenario,n=t.assembly,r=jt(n.subAssemblies).map((function(e){var t=jt(e.approvers).map((function(e){return{tpId:e.tp.id}}));return{id:e.id,quorum:e.quorum,singleReject:e.singleReject,subjectCipherDataClearJson:e.subjectCipherDataClearJson,approverTps:t}})),[4,this.prepareUpdateScenario({scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:{quorum:n.quorum,singleReject:n.singleReject,updateSubAssemblies:r}},t)];case 2:return i=a.sent(),[2,new pt({mutation:pu,variables:{input:i}})]}}))}))},n.prototype.deleteScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.lrGraphQL.lrMutate(this.deleteScenarioMutation(e))]}))}))},n.prototype.deleteScenarioMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:du,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.createClaim=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.createClaimMutation(e))]}))}))},n.prototype.createClaimMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:lu,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.cancelClaim=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.cancelClaimMutation(e))]}))}))},n.prototype.cancelClaimMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:yu,variables:{input:{claimId:e}}})]}))}))},n.prototype.rejectClaim=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.mutate(this.rejectClaimMutation(e,t))]}))}))},n.prototype.rejectClaimMutation=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.prepareRejectClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=lt).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.approveClaim=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.mutate(this.approveClaimMutation(e,t))]}))}))},n.prototype.approveClaimMutation=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,this.prepareApproveClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=lt).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.receiveClaim=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){return[2,this.mutate(this.receiveClaimMutation(e,t))]}))}))},n.prototype.receiveClaimMutation=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i;return j(this,(function(a){switch(a.label){case 0:return n=pt.bind,r={mutation:vu},i={},[4,this.prepareClaim(e,t)];case 1:return[2,new(n.apply(pt,[void 0,(r.variables=(i.input=a.sent(),i),r)]))]}}))}))},n.prototype.debugExpireClaim=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.debugExpireClaimMutation(e))]}))}))},n.prototype.debugExpireClaimMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:mu,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.getScenario=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.query({query:Su,variables:{scenarioId:e}})]}))}))},n.prototype.getSharedScenario=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.query({query:Iu,variables:{scenarioId:e}})];case 1:return n=r.sent(),t&&n.sharedScenario.sharedClaim.id!==t&&Cu(),[2,n]}}))}))},n.prototype.getParticipantTpsKeys=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return t=e.map((function(e){return e.tpId})),n=jt,[4,this.lrGraphQL.query({query:$r,variables:{ids:t}})];case 1:return[2,n.apply(void 0,[r.sent().tps])]}}))}))},n.prototype.fillTpSharedKeyId=function(e,t){e.forEach((function(e){if(!e.tpSharedKeyId){var n=t.find((function(t){return t.id===e.tpId}));e.tpSharedKeyId=n.currentUserSharedKey.userSharedKey.sharedKey.id}}))},n.prototype.prepareCreateScenarioMutation=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p=this;return j(this,(function(d){switch(d.label){case 0:return[4,this.assemblyController.prepareCreate(e.createAssembly)];case 1:return t=d.sent(),n=t.assemblyKey,r=t.mutationInput,i=e.createReceivers||[],a=e.createClaimants||[],s=i.concat(a),[4,this.getParticipantTpsKeys(s)];case 2:return o=d.sent(),this.fillTpSharedKeyId(s,o),[4,Promise.all(i.map((function(e){return p.prepareCreateReceiver(e,n)})))];case 3:return c=d.sent(),[4,Promise.all(a.map((function(e){return p.prepareCreateClaimant(e)})))];case 4:return u=d.sent(),[2,{enabled:e.enabled,createAssembly:r,createReceivers:c,createClaimants:u}]}}))}))},n.prototype.prepareUpdateScenario=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,m,g,S,I,C,b=this;return j(this,(function(w){switch(w.label){case 0:return[4,this.keyGraph.getJwkKey(t.assembly.assemblyKey.id)];case 1:return n=w.sent(),e.updateAssembly?[4,A(b,void 0,void 0,(function(){var r;return j(this,(function(i){switch(i.label){case 0:return[4,this.assemblyController.prepareUpdate(e.updateAssembly,t.assembly)];case 1:return r=i.sent(),n=r.assemblyKey,[2,r.mutationInput]}}))}))]:[3,3];case 2:return i=w.sent(),[3,4];case 3:i=void 0,w.label=4;case 4:return r=i,a=e.createReceivers||[],s=e.createClaimants||[],o=a.concat(s),[4,this.getParticipantTpsKeys(o)];case 5:return c=w.sent(),this.fillTpSharedKeyId(o,c),(p=e.createReceivers)?[4,Promise.all(e.createReceivers.map((function(e){return b.prepareCreateReceiver(e,n)})))]:[3,7];case 6:p=w.sent(),w.label=7;case 7:return u=p,d=jt(t.receivers),e.updateReceivers?[4,Promise.all(e.updateReceivers.map((function(e){var t=d.find((function(t){return t.tp.id===e.tpId}));return b.prepareUpdateReceiver(e,n,t)})))]:[3,9];case 8:return y=w.sent(),[3,10];case 9:y=[],w.label=10;case 10:return l=y,e.updateAssembly?(h=d.filter((function(t){return!(e.deleteReceivers||[]).includes(t.tp.id)&&!l.some((function(e){return e.tpId===t.tp.id}))})),v=(f=l).concat,[4,this.prepareExistingReceivers(h,n)]):[3,12];case 11:l=v.apply(f,[w.sent()]),w.label=12;case 12:return(g=e.createClaimants)?[4,Promise.all(e.createClaimants.map((function(e){return b.prepareCreateClaimant(e)})))]:[3,14];case 13:g=w.sent(),w.label=14;case 14:return m=g,S=jt(t.claimants),(C=e.updateClaimants)?[4,Promise.all(e.updateClaimants.map((function(e){var t=S.find((function(t){return t.tp.id===e.tpId}));return b.prepareUpdateClaimant(e,t.sharedKey.id)})))]:[3,16];case 15:C=w.sent(),w.label=16;case 16:return I=C,[2,{scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:r,createReceivers:u,updateReceivers:l,deleteReceivers:e.deleteReceivers,createClaimants:m,updateClaimants:I,deleteClaimants:e.deleteClaimants}]}}))}))},n.prototype.prepareReceiverDirectory=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a;return j(this,(function(s){switch(s.label){case 0:return[4,this.item2Service.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return r=s.sent(),[4,this.keyGraph.encryptToString(t,e.sharedCipherDataClearJson||"")];case 2:return i=s.sent(),[4,this.keyGraph.encryptToString(t,r.jwk.toJSON(!0))];case 3:return a=s.sent(),[4,this.keyGraph.encryptToString(n,a)];case 4:return a=s.sent(),[2,{directoryId:e.directoryId,wrappedItemKey:a,accessRole:e.accessRole,sharedCipherData:i}]}}))}))},n.prototype.prepareCreateReceiver=function(e,t){return A(this,void 0,void 0,(function(){var n,r,i,a,s,o=this;return j(this,(function(c){switch(c.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return n=c.sent(),r=n.sharedKey,i=n.mutationInput,(s=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return o.prepareAddReceiverDirectory(e,r.key,t)})))]:[3,3];case 2:s=c.sent(),c.label=3;case 3:return a=s,[2,Object.assign(Object.assign({},i),{addDirectories:a})]}}))}))},n.prototype.prepareUpdateReceiver=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l=this;return j(this,(function(y){switch(y.label){case 0:return r=n.sharedKey.id,i=e.deleteDirectories||[],a=e.updateDirectories||[],jt(n.receiverDirectories).forEach((function(e){i.includes(e.directory.id)||a.find((function(t){return t.directoryId===e.directory.id}))||a.push({accessRole:e.accessRole,directoryId:e.directory.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),[4,this.prepareUpdateParticipant(e,r)];case 1:return s=y.sent(),o=s.sharedKey,c=s.mutationInput,(p=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return l.prepareAddReceiverDirectory(e,o,t)})))]:[3,3];case 2:p=y.sent(),y.label=3;case 3:return u=p,[4,Promise.all(a.map((function(e){return l.prepareUpdateReceiverDirectory(e,o,t)})))];case 4:return d=y.sent(),[2,Object.assign(Object.assign({},c),{addDirectories:u,updateDirectories:d,deleteDirectories:e.deleteDirectories})]}}))}))},n.prototype.prepareExistingReceiver=function(e,t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){return n=jt(e.receiverDirectories).map((function(e){return{directoryId:e.directory.id,directoryKeyId:e.directory.keyId,accessRole:e.accessRole,sharedCipherDataClearJson:e.sharedCipherDataClearJson}})),[2,this.prepareUpdateReceiver({tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,updateDirectories:n},t,e)]}))}))},n.prototype.prepareExistingReceivers=function(e,t){return A(this,void 0,void 0,(function(){var n=this;return j(this,(function(r){return[2,Promise.all(e.map((function(e){return n.prepareExistingReceiver(e,t)})))]}))}))},n.prototype.prepareCreateParticipant=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.keyGraph.encryptWithNewKey(e.tpSharedKeyId,e.sharedCipherDataClearJson||"")];case 1:return[2,{sharedKey:t=n.sent(),mutationInput:{tpId:e.tpId,tpSharedKeyId:e.tpSharedKeyId,tpSharedKeyWrappedSharedKey:t.wrappedKey,sharedCipherData:t.cipher}}]}}))}))},n.prototype.prepareUpdateParticipant=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return[4,this.keyGraph.getJwkKey(t)];case 1:return n=i.sent(),[4,this.keyGraph.encryptToString(n,e.sharedCipherDataClearJson||"")];case 2:return r=i.sent(),[2,{sharedKey:n,mutationInput:{tpId:e.tpId,sharedKeyId:t,sharedCipherData:r}}]}}))}))},n.prototype.prepareCreateClaimant=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return[2,t.sent().mutationInput]}}))}))},n.prototype.prepareUpdateClaimant=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.prepareUpdateParticipant(e,t)];case 1:return[2,n.sent().mutationInput]}}))}))},n.prototype.prepareClaim=function(t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o=this;return j(this,(function(c){switch(c.label){case 0:return[4,this.getSharedScenario(t,n)];case 1:return(r=c.sent().sharedScenario).state!==e.ScenarioState.APPROVED&&bu(),i=jt(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),[4,Promise.all(r.asReceiver.receiverDirectories.edges.map((function(e){return e.node})).map((function(e){return A(o,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.encryptionService.decrypt(a,e.wrappedItemKey)];case 1:return t=n.sent(),[2,{receiverDirectoryId:e.id,receiverSharedKeyWrappedItemKey:t}]}}))}))})))];case 3:return s=c.sent(),[2,{scenarioClaimId:n,receiverDirectories:s}]}}))}))},n.prototype.recoverAssemblyKey=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return n.keyGraph.decryptFromString(e.pxk.id,e.receiverCipherPartialAssemblyKey)})))];case 1:return t=r.sent(),[2,this.assemblyController.recoverAssemblyKey(t)]}}))}))},n.prototype.asClaimApprovers=function(e,t,n){return A(this,void 0,void 0,(function(){return j(this,(function(r){switch(r.label){case 0:return[4,this.getSharedScenario(e,t)];case 1:return[2,jt(r.sent().sharedScenario.sharedClaim.claim.asClaimApprovers).filter((function(e){return e.state===n}))]}}))}))},n.prototype.prepareApproveClaimMutations=function(t,n){return A(this,void 0,void 0,(function(){var r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.asClaimApprovers(t,n,e.TpClaimApproverState.CLAIMED)];case 1:return[2,i.sent().map((function(e){return A(r,void 0,void 0,(function(){var t,n,r;return j(this,(function(i){switch(i.label){case 0:return t=pt.bind,n={mutation:fu},r={},[4,this.prepareApproveClaim(e)];case 1:return[2,new(t.apply(pt,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))}))]}}))}))},n.prototype.prepareApproveClaim=function(e){return A(this,void 0,void 0,(function(){var t,n=this;return j(this,(function(r){switch(r.label){case 0:return[4,Promise.all(jt(e.receiverApprovals).map((function(t){return n.prepareReceiverApproval({receiverApprovalId:t.id,receiverApprovalPxkId:t.pxk.id,sharedCipherPartialAssemblyKeyClearJson:e.sharedCipherPartialAssemblyKeyClearJson})})))];case 1:return t=r.sent(),[2,{claimApproverId:e.id,receiverApprovals:t}]}}))}))},n.prototype.prepareReceiverApproval=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return t={receiverApprovalId:e.receiverApprovalId,receiverCipher:""},[4,this.keyGraph.encryptToString(e.receiverApprovalPxkId,e.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(t.receiverCipherPartialAssemblyKey=n.sent(),t)]}}))}))},n.prototype.prepareRejectClaimMutations=function(t,n){return A(this,void 0,void 0,(function(){var r=this;return j(this,(function(i){switch(i.label){case 0:return[4,this.asClaimApprovers(t,n,e.TpClaimApproverState.CLAIMED)];case 1:return[2,i.sent().map((function(e){return A(r,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:hu,variables:{input:{claimApproverId:e.id}}})]}))}))}))]}}))}))},n}(At),e.ScenarioService.SLIP39_PASSPHRASE="lifeready",e.ScenarioService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ScenarioService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ke),t.ɵɵinject(e.Item2Service),t.ɵɵinject(e.ɵn),t.ɵɵinject(he))},token:e.ScenarioService,providedIn:"root"}),e.ScenarioService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ScenarioService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ke},{type:e.Item2Service},{type:e.ɵn},{type:he}]},e.ScenarioService=O([et({ngZoneName:"ngZone"})],e.ScenarioService);var wu,Ku=je(wu||(wu=F(["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"],["\nquery ServerConfigQuery {\n serverConfig {\n relayConnectionMaxLimit\n }\n}\n"])));e.ServerConfigService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.getConfig=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return null!=this.serverConfig?[3,2]:(e=this,[4,this.query({query:Ku,includeKeyGraph:!1})]);case 1:e.serverConfig=t.sent().serverConfig,t.label=2;case 2:return[2,this.serverConfig]}}))}))},t}(At),e.ServerConfigService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ServerConfigService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ServerConfigService,providedIn:"root"}),e.ServerConfigService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ServerConfigService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ServerConfigService=O([et({ngZoneName:"ngZone"})],e.ServerConfigService);var ku,Pu,Eu,Du,Ru=je(ku||(ku=F(["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"],["\nmutation UpdateOwnedContactCardMutation(\n $input: UpdateOwnedContactCardInput!\n) {\n updateOwnedContactCard(input: $input) {\n ownedContactCard {\n id\n }\n }\n}"]))),Mu=je(Pu||(Pu=F(["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"],["\nmutation UpdateReceivedContactCardMutation(\n $input: UpdateReceivedContactCardInput!\n) {\n updateReceivedContactCard(input: $input) {\n receivedContactCard {\n id\n }\n }\n}"]))),Ou=je(Eu||(Eu=F(["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"],["\nquery GetOwnedContactCardKeyIdsQuery($id: LrRelayIdInput!) {\n ownedContactCard(id: $id) {\n sharedKey {\n id\n }\n ownerKey {\n id\n }\n }\n}"]))),Au=je(Du||(Du=F(["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"],["\nquery GetReceivedContactCardKeyIdQuery($id: LrRelayIdInput!) {\n receivedContactCard(id: $id) {\n receiverKey {\n id\n }\n }\n}"])));e.SharedContactCard2Service=function(){function e(e,t,n,r,i){this.ngZone=e,this.keyService=t,this.keyGraph=n,this.encryptionService=r,this.lrGraphQL=i}return e.prototype.getOwnedContactCardKeyIds=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:Ou,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Au,variables:{id:e}})];case 1:return[2,t.sent().receivedContactCard.receiverKey.id]}}))}))},e.prototype.updateOwnedContactCard=function(e){var t=e.id,n=e.ownerKeyId,r=e.sharedKeyId,i=e.ownerPlainDataJson,a=e.ownerCipherDataClearJson,s=e.sharedCipherDataClearJson;return A(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,m;return j(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,7]),[4,this.keyGraph.getKey(n)];case 1:return e=g.sent(),[4,this.keyGraph.getKey(r)];case 2:return o=g.sent(),[3,7];case 3:return g.sent(),[4,this.getOwnedContactCardKeyIds(t)];case 4:return c=g.sent(),[4,this.keyGraph.getKey(c.ownerKeyId)];case 5:return e=g.sent(),[4,this.keyGraph.getKey(c.sharedKeyId)];case 6:return o=g.sent(),[3,7];case 7:return u=this.keyService.currentSigPxk,[4,this.encryptionService.encrypt(o.jwk,s)];case 8:return p=g.sent(),y=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 9:return d=y.apply(l,[g.sent()]),v=(f=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 10:return h=v.apply(f,[g.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 11:return m=g.sent(),[2,new pt({mutation:Ru,variables:{input:{id:t,ownerCipherData:m,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:h}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return A(this,void 0,void 0,(function(){var e,i,a=this;return j(this,(function(s){switch(s.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return a.getReceivedContactCardKeyId(t)}))];case 1:return e=s.sent(),[4,this.encryptionService.encryptToString(e.jwk,r)];case 2:return i=s.sent(),[2,new pt({mutation:Mu,variables:{input:{id:t,receiverCipherData:i,receiverKeyId:e.id}}})]}}))}))},e}(),e.SharedContactCard2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.SharedContactCard2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ke),t.ɵɵinject(ke),t.ɵɵinject(he),t.ɵɵinject(e.ɵf))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:t.NgZone},{type:Ke},{type:ke},{type:he},{type:e.ɵf}]},e.SharedContactCard2Service=O([et({ngZoneName:"ngZone"})],e.SharedContactCard2Service),e.ɵo=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return R(t,e),t.prototype.getReset=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.query({query:yi})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.getSharedResets=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.query({query:pi})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},t.prototype.getSharedReset=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.query({query:di,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},t}(At),e.ɵo.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵo(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵo,providedIn:"root"}),e.ɵo.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵo.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵo=O([et({ngZoneName:"ngZone"})],e.ɵo),e.TpPasswordResetRequestService=function(t){function n(e,n,r,i){var a=t.call(this,n)||this;return a.ngZone=e,a.injector=n,a.encryptionService=r,a.privateService=i,a}return R(n,t),n.prototype.activeRequestOrRaise=function(t){var n=t.sharedRequest.claim.state;if(n!==e.TpAssemblyState.CLAIMED)throw new Q("Claim is already in "+n+" state.")},n.prototype.rejectRequest=function(e){return this.mutate(this.rejectRequestMutation(e))},n.prototype.rejectRequestMutation=function(t){return A(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=r.sent(),this.activeRequestOrRaise(n),[2,lt.create(n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})).map((function(e){return new pt({mutation:ai,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},n.prototype.approveRequest=function(e,t){return A(this,void 0,void 0,(function(){var n,r;return j(this,(function(i){switch(i.label){case 0:return r=(n=this.lrGraphQL).lrMutate,[4,this.approveRequestMutation(e,t)];case 1:return[2,r.apply(n,[i.sent()])]}}))}))},n.prototype.approveRequestMutation=function(t,n){return A(this,void 0,void 0,(function(){var n,r,i,s,o,c=this;return j(this,(function(u){switch(u.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=u.sent(),this.activeRequestOrRaise(n),[4,a.JWK.asKey(JSON.parse(n.sharedRequest.pxk.pbk))];case 2:return r=u.sent(),i=n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})),o=(s=lt).create,[4,Promise.all(i.map((function(e){return A(c,void 0,void 0,(function(){var t,n,i=this;return j(this,(function(a){switch(a.label){case 0:return t=e.node,n={claimApproverId:t.id},[4,Promise.all(t.receiverApprovals.edges.map((function(e){return A(i,void 0,void 0,(function(){var n,i;return j(this,(function(a){switch(a.label){case 0:return n=e.node,i={receiverApprovalId:n.id,receiverCipher:""},[4,this.encryptionService.encryptToString(r,t.sharedCipherPartialAssemblyKeyClearJson)];case 1:return[2,(i.receiverCipherPartialAssemblyKey=a.sent(),i)]}}))}))})))];case 1:return n.receiverApprovals=a.sent(),[2,new pt({mutation:ii,variables:{input:n}})]}}))}))})))];case 3:return[2,o.apply(s,[u.sent()])]}}))}))},n}(At),e.TpPasswordResetRequestService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetRequestService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(he),t.ɵɵinject(e.ɵo))},token:e.TpPasswordResetRequestService,providedIn:"root"}),e.TpPasswordResetRequestService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetRequestService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:he},{type:e.ɵo}]},e.TpPasswordResetRequestService=O([et({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService);function ju(){!function(e){if(!e)throw new q("You must specify a non empty prefix.");Object.keys(localStorage).forEach((function(t){t.startsWith(e)&&localStorage.removeItem(t)}))}("CognitoIdentityServiceProvider")}e.TpPasswordResetUserService=function(e){function t(t,n,r,i,a,s,o,c){var u=e.call(this,n)||this;return u.ngZone=t,u.injector=n,u.config=r,u.keyFactory=i,u.encryptionService=a,u.passwordService=s,u.http=o,u.auth=c,u}return R(t,e),t.prototype.verifyEmailContact=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){return t={email:e},[2,this.http.post(this.config.authUrl+"tp/password-reset/verify-contact/",t).toPromise()]}))}))},t.prototype.verifyContactRespond=function(e,t){return A(this,void 0,void 0,(function(){return j(this,(function(n){switch(n.label){case 0:return[4,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e,v_code:t}).toPromise()];case 1:return[2,n.sent().token]}}))}))},t.prototype.requestReset=function(e,t,n){return A(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return j(this,(function(p){switch(p.label){case 0:return ju(),[4,this.passwordService.createPassKeyBundle(e)];case 1:return r=p.sent(),[4,this.keyFactory.createKey()];case 2:return i=p.sent(),[4,this.encryptionService.encrypt(r.passKey,i.toJSON(!0))];case 3:return a=p.sent(),[4,this.keyFactory.createPkcKey()];case 4:return s=p.sent(),[4,this.encryptionService.encrypt(i,s.toJSON(!0))];case 5:return o=p.sent(),[4,this.http.post(this.config.authUrl+"tp/password-reset/request/",{claimId:t,claimToken:n,pass_key_params:r.passKeyParams,pass_idp_params:r.passIdpParams,pass_idp_verifier_pbk:r.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:r.wrappedPassIdpVerifierPrk,wrapped_master_key:a,pbk:s.toJSON(),master_key_wrapped_prk:o}).toPromise()];case 6:return c=p.sent(),console.log("Using new password"),[4,this.auth.signUp({username:c.reset_username,password:this.passwordService.getPassIdpString(r.passIdp),clientMetadata:{tp_password_reset_request:JSON.stringify({id:c.id,associate_reset_user_token:c.associate_reset_user_token})}})];case 7:return u=p.sent(),console.log("requestRest done"),[2,{requestResetResult:c,signUpResult:u}]}}))}))},t}(At),e.TpPasswordResetUserService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetUserService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(me),t.ɵɵinject(ve),t.ɵɵinject(he),t.ɵɵinject(Dr),t.ɵɵinject(f.HttpClient),t.ɵɵinject(s.AuthClass))},token:e.TpPasswordResetUserService,providedIn:"root"}),e.TpPasswordResetUserService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetUserService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:void 0,decorators:[{type:t.Inject,args:[me]}]},{type:ve},{type:he},{type:Dr},{type:f.HttpClient},{type:s.AuthClass}]},e.TpPasswordResetUserService=O([et({ngZoneName:"ngZone"})],e.TpPasswordResetUserService),e.TpPasswordResetService=function(e){function t(t,n,r,i){var a=e.call(this,n)||this;return a.ngZone=t,a.injector=n,a.privateService=r,a.assemblyController=i,a.slip39Passphrase=Rr,a}return R(t,e),t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new pt({mutation:ei})},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new pt({mutation:oi})},t.prototype.validateApprovers=function(e){return this.assemblyController.validateApprovers(e)},t.prototype.createReset=function(e){return this.mutate(this.createResetMutation(e))},t.prototype.createResetMutation=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.assemblyController.prepareCreate(e)];case 1:return t=n.sent().mutationInput,[2,new pt({mutation:si,variables:{input:{assembly:Object.assign({},t)}}})]}}))}))},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return A(this,void 0,void 0,(function(){var t,n;return j(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getReset()];case 1:return t=r.sent(),[4,this.assemblyController.prepareUpdate(e,t.assembly)];case 2:return n=r.sent().mutationInput,[2,new pt({mutation:ci,variables:{input:{assembly:Object.assign({},n)}}})]}}))}))},t.prototype.debugExpireResetRequest=function(e){return this.mutate(this.debugExpireResetRequestMutation(e),{includeKeyGraph:!1})},t.prototype.debugExpireResetRequestMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,new pt({mutation:gu,variables:{input:{username:e}}})]}))}))},t}(At),e.TpPasswordResetService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(e.ɵo),t.ɵɵinject(e.ɵi))},token:e.TpPasswordResetService,providedIn:"root"}),e.TpPasswordResetService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:e.ɵo},{type:e.ɵi}]},e.TpPasswordResetService=O([et({ngZoneName:"ngZone"})],e.TpPasswordResetService);var Tu,Nu,$u,Fu,Uu,Lu,xu,_u,Ju,qu=je(Tu||(Tu=F(["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n}\n"]))),Gu=je(Nu||(Nu=F(["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"],["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"]))),Vu=je($u||($u=F(["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"],["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpSharedDirectory {\n id\n }\n }\n }\n"]))),Bu=je(Fu||(Fu=F(["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"],["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"]))),Qu=je(Uu||(Uu=F(["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"],["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpSharedFile {\n id\n }\n }\n }\n"]))),Wu=je(Lu||(Lu=F(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),Zu=je(xu||(xu=F(["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"],["\n mutation RespondTpMkReshareMutation($input: RespondTpMkReshareInput!) {\n respondTpMkReshare(input: $input) {\n id\n }\n }\n"]))),Hu=je(_u||(_u=F(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"]))),Yu=je(Ju||(Ju=F(["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"],["\nquery TpCurrentUserSharedKeyQuery($id: LrRelayIdInput!) {\n tp(id: $id){\n currentUserSharedKey {\n userSharedKey {\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n mkPxk {\n id\n }\n mkReshareRequestCipher\n mkReshareRequestSent\n mkReshareResponseCipher\n mkReshareResponseSent\n }\n }\n }\n}\n"])));e.TrustedParty2Service=function(e){function t(t,n,r,i,a,s,o){var c=e.call(this,n)||this;return c.ngZone=t,c.injector=n,c.keyGraph=r,c.item2Service=i,c.keyService=a,c.keyFactory=s,c.encryptionService=o,c}return R(t,e),t.prototype.deleteTpExec=function(e){return this.mutate(this.deleteTpMutation(e))},t.prototype.deleteTp=function(e){return this.deleteTpMutation(e)},t.prototype.deleteTpMutation=function(e){return new pt({mutation:qu,variables:{input:{id:e}}})},t.prototype.shareDirectory=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.shareDirectoryMutation(e))]}))}))},t.prototype.shareDirectoryMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.shareItemMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},t.prototype.shareFile=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.shareFileMutation(e))]}))}))},t.prototype.shareFileMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.shareItemMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},t.prototype.shareItemMutation=function(e){var t=e.itemId,n=e.itemKeyId,r=e.tpId,i=e.tpSharedKeyId,a=e.accessRole,s=e.isDirectory;return A(this,void 0,void 0,(function(){var e,o,c,u=this;return j(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return s?u.item2Service.getDirectoryKeyId(t):u.item2Service.getFileKeyId(t)}))];case 1:return e=p.sent(),[4,this.keyGraph.getKey(i,(function(){return u.getTpCurrentUserSharedKey(r).then((function(e){return e.sharedKey.id}))}))];case 2:return o=p.sent(),[4,this.keyGraph.wrapKey(o,e.jwk)];case 3:return c=p.sent(),[2,new pt({mutation:s?Gu:Bu,variables:{input:{id:t,tpId:r,accessRole:a,keyId:e.id,wrappingKeyId:o.id,wrappedKey:c}}})]}}))}))},t.prototype.unshareDirectory=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.unshareDirectoryMutation(e))]}))}))},t.prototype.unshareDirectoryMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.unshareItemMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},t.prototype.unshareFile=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.mutate(this.unshareFileMutation(e))]}))}))},t.prototype.unshareFileMutation=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){return[2,this.unshareItemMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},t.prototype.unshareItemMutation=function(e){var t=e.itemId,n=e.tpId,r=e.isDirectory;return A(this,void 0,void 0,(function(){return j(this,(function(e){return[2,new pt({mutation:r?Vu:Qu,variables:{input:{id:t,tpId:n}}})]}))}))},t.prototype.requestMkReshare=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,a,s;return j(this,(function(o){switch(o.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if((t=o.sent()).mkSharedKey)throw new Q("TP already has mkSharedKey");return n=this.keyService.currentMasterKey,[4,this.keyFactory.createPkcKey()];case 2:return r=o.sent(),[4,this.encryptionService.encryptToString(n.jwk,r.toJSON(!0))];case 3:return i=o.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 4:return a=o.sent(),[4,this.encryptionService.encryptToString(a.jwk,{pbk:r.toJSON()})];case 5:return s=o.sent(),[4,new pt({mutation:Wu,variables:{input:{tpId:e,masterKeyId:n.id,mkPbk:JSON.stringify(r.toJSON()),mkWrappedMkPrk:i,sharedKeyId:a.id,mkReshareRequestCipher:s}}})];case 6:return[2,o.sent()]}}))}))},t.prototype.respondMkReshare=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d;return j(this,(function(l){switch(l.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if(!(t=l.sent()).mkSharedKey)throw new Q("No access to the mkSharedKey so cannot reshare it with TP");return[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=l.sent(),[4,this.encryptionService.decrypt(n,t.mkReshareRequestCipher)];case 3:return r=l.sent(),[4,a.JWK.asKey(r.pbk)];case 4:return i=l.sent(),[4,this.keyGraph.getKey(t.mkSharedKey.id)];case 5:return s=l.sent(),o={mkSharedKey:{id:s.id,jwk:s.jwk.toJSON(!0)}},p=(u=this.encryptionService).encryptToString,d=[i],[4,this.encryptionService.encryptToString(n.jwk,o)];case 6:return[4,p.apply(u,d.concat([l.sent()]))];case 7:return c=l.sent(),[2,new pt({mutation:Zu,variables:{input:{tpId:e,mkSharedKeyId:s.id,mkReshareResponseCipher:c}}})]}}))}))},t.prototype.completeMkReshare=function(e){return A(this,void 0,void 0,(function(){var t,n,r,i,s,o,c,u,p,d,l;return j(this,(function(y){switch(y.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=y.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=y.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=y.sent(),o=(s=this.encryptionService).decrypt,c=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,o.apply(s,c.concat([y.sent()]))];case 5:return i=y.sent(),p={id:i.mkSharedKey.id},[4,a.JWK.asKey(i.mkSharedKey.jwk)];case 6:return p.jwk=y.sent(),u=p,d=this.keyService.currentMasterKey,[4,this.encryptionService.encryptToString(d.jwk,u.jwk.toJSON(!0))];case 7:return l=y.sent(),[2,new pt({mutation:Hu,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:u.id,mkWrappedMkSharedKey:l}}})]}}))}))},t.prototype.getTpCurrentUserSharedKey=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Yu,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},t}(At),e.TrustedParty2Service.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TrustedParty2Service(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(ke),t.ɵɵinject(e.Item2Service),t.ɵɵinject(Ke),t.ɵɵinject(ve),t.ɵɵinject(he))},token:e.TrustedParty2Service,providedIn:"root"}),e.TrustedParty2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TrustedParty2Service.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:ke},{type:e.Item2Service},{type:Ke},{type:ve},{type:he}]},e.TrustedParty2Service=O([et({ngZoneName:"ngZone"})],e.TrustedParty2Service);var zu=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return A(this,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.auth.getPreferredMFA(e)];case 2:return[2,t.sent()]}}))}))},e.prototype.setPreferredMFA=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.setPreferredMFA(t,e)];case 2:return n.sent(),[2]}}))}))},e.prototype.setPhoneNumber=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.updateUserAttributes(t,{phone_number:e})];case 2:return n.sent(),[2]}}))}))},e.prototype.getSMSCode=function(){return A(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.auth.verifyCurrentUserAttribute("phone_number")];case 1:return e.sent(),[2]}}))}))},e.prototype.verifySMSCode=function(e){return A(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.auth.verifyCurrentUserAttributeSubmit("phone_number",e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getSoftwareToken=function(){return A(this,void 0,void 0,(function(){var e,t,n,r,i;return j(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=N.apply(void 0,[a.sent(),2]),t=e[0],n=e[1],[4,this.auth.setupTOTP(t)];case 2:if(r=a.sent(),!(i=n.attributes.email))throw new q("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return A(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t=n.sent(),[4,this.auth.verifyTotpToken(t,e)];case 2:return n.sent(),[2]}}))}))},e}();zu.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new zu(t.ɵɵinject(s.AuthClass))},token:zu,providedIn:"root"}),zu.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],zu.ctorParameters=function(){return[{type:s.AuthClass}]},e.ApiContactCard=pr,e.ApiCurrentUser=ur,e.ArchiveDirectoryMutation=Rn,e.AuthTypes=Ei,e.CancelUserDeleteMutation=ec,e.Category=ra,e.CategoryFields=fn,e.CategoryFilter=ln,e.CategoryMetaService=Zi,e.CategoryService=Bi,e.CognitoChallengeUser=Ft,e.CompleteOtkMutation=ks,e.ContactCardAddress=lr,e.ContactCardName=dr,e.CreateCategoryMutation=kn,e.CreateContactCardMutation=ar,e.CreateFileMutation=Gi,e.CreateFileQuery=We,e.CreateLbopQuery=to,e.CreateRecordContainerMutation=Li,e.CreateRecordMutation=xi,e.CreateVaultMutation=Pn,e.CurrentCategory=ia,e.CurrentUser=Ut,e.CurrentUserKey=cr,e.CurrentUserQuery=ir,e.CurrentUserSharedKeyQuery=Ss,e.DEFAULT_BREADCRUMB_DEPTH=5,e.DEFAULT_DESCENDANTS_DEPTH=5,e.DefaultCategory=ea,e.DefaultProcessorOptions=tt,e.DefaultVaultFilter=dn,e.DeleteCategoryMutation=Dn,e.DeleteFileMutation=Vi,e.DeleteLbopQuery=no,e.DeleteRecordMutation=qi,e.DirectoryQuery=Qe,e.ERROR_SOURCE=Zs,e.Features=or,e.FetchKeyGraphField=Ve,e.FileQuery=Be,e.FileUploadService=ya,e.GetCategoriesQuery=gn,e.GetCategoryKeyIdQuery=Kn,e.GetCategoryQuery=wn,e.GetMySharedCategoriesQuery=Cn,e.GetRecordQuery=Ui,e.GetRootDirectoryIdsQuery=mn,e.GetTrustedPartyCategoriesQuery=In,e.GetVaultsQuery=Sn,e.IdleService=xt,e.InitiateOtkMutation=ws,e.KC_CONFIG=me,e.KcAuthException=J,e.KcBadArgumentException=q,e.KcBadLogicException=G,e.KcBadRequestException=V,e.KcBadSignatureException=B,e.KcBadStateException=Q,e.KcBadTimeSyncException=W,e.KcCodeMismatchException=Z,e.KcConcurrentAccessException=H,e.KcEncryptionException=Y,e.KcError=x,e.KcException=_,e.KcInternalErrorException=z,e.KcLockedException=X,e.KcNotFoundException=ee,e.KcSuspiciousOperationException=te,e.KcUnsupportedException=ne,e.KeyExchangeFields=ms,e.KeyExchangeQuery=Cs,e.KeyExchangeService=Ps,e.KeyExchangeTokenQuery=bs,e.KeyExchangesQuery=Is,e.KeyGraphField=Ge,e.KeyGraphFragment=qe,e.LbopQuery=io,e.LbopService=so,e.LbopsQuery=ao,e.LifeReadyAuthService=vi,e.LifeReadyModule=oo,e.LoadedCategoryTree=Wi,e.LoginHistoryQuery=tc,e.LoginResult=Lt,e.LrApolloService=Pe,e.LrGraphQLService=e.ɵf,e.LrMergedMutation=lt,e.LrMutation=pt,e.LrMutationBase=ut,e.LrRecord=Lc,e.LrService=At,e.MainContactCard=fr,e.MainContactCardFields=hr,e.MainContactCardPlainFields=vr,e.MainContactCardProperty=yr,e.MoveDirectoryQuery=ze,e.MoveFileQuery=Ye,e.NewAttachment=xc,e.NewCategory=sa,e.NewOrUpdatedAttachment=Jc,e.NewRecord=_c,e.OwnerPlainDataJson=la,e.PassIdpApiResult=mr,e.PasswordCheck=Er,e.PasswordService=Dr,e.PersistService=Ce,e.Plan=Ao,e.PlanService=er,e.ProfileDetailsService=Pc,e.ProfileService=Sr,e.RecordAttachment=Uc,e.RecordAttachmentFilter=Fi,e.RecordAttachmentService=Nc,e.RecordContentFilter=$i,e.RecordField=Fc,e.RecordFilter=yn,e.RecordService=$c,e.RecordType=Oc,e.RecordTypeField=jc,e.RecordTypeFieldOption=Ac,e.RecordTypeService=Mc,e.RecordTypeSummary=Tc,e.RegisterService=Gc,e.RequestUserDeleteMutation=Xo,e.RespondOtkMutation=Ks,e.RevertFileQuery=He,e.ServerTimeQuery=pe,e.SharedAccess=Xi,e.StripeBillingPortalSession=$o,e.StripeCheckoutSession=No,e.Subscription=jo,e.TimeService=de,e.TrustedPartyDetails=gr,e.TwoFactorService=zu,e.UnarchiveDirectoryMutation=Mn,e.UpdateCategoryMutation=En,e.UpdateContactCardMutation=sr,e.UpdateFileQuery=Ze,e.UpdateLbopQuery=ro,e.UpdateRecordContainerMutation=_i,e.UpdateRecordMutation=Ji,e.UpdatedCategory=oa,e.UpdatedRecord=qc,e.UserPlan=To,e.UserService=nc,e.UserSharedKeyFields=gs,e.Vault=ca,e.VaultCategory=aa,e.VaultFields=vn,e.VaultRecord=na,e.VaultRecordType=ta,e.WebCryptoService=fe,e.awsFetch=Nt,e.configureAmplifyAuth=$t,e.configureApollo=Ie,e.fragmentSpreadAstSelection=ct,e.gqlTyped=je,e.handleApolloError=U,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.httpOptions=Se,e.initialiseAuth=fi,e.mapEdges=jt,e.mapUserPlans=Xn,e.parentCategoriesField=bn,e.processConnection=nt,e.throwClaimIdMismatch=Cu,e.throwClaimNotApproved=bu,e.ɵ0=Rc,e.ɵa=ke,e.ɵb=he,e.ɵc=Ke,e.ɵd=ve,e.ɵe=On,e.ɵh=et,e.ɵj=Fr,e.ɵk=At,e.ɵl=Zo,e.ɵm=Kc,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=lifeready-core.umd.min.js.map
|