@lifeready/core 9.0.1 → 9.0.2
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 +12 -4
- 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/api/types/lr-graphql.types.js +13 -5
- package/fesm2015/lifeready-core.js +12 -4
- package/fesm2015/lifeready-core.js.map +1 -1
- package/lib/api/types/lr-graphql.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("node-jose"),require("@aws-amplify/auth/lib-esm/Auth"),require("graphql-tag"),require("moment"),require("lodash/cloneDeep"),require("lodash/isEqual"),require("lodash/keyBy"),require("lodash/omit"),require("@apollo/client/core"),require("@apollo/client/link/context"),require("@apollo/client/link/retry"),require("ngx-cookie-service"),require("graphql/language/printer"),require("@angular/common/http"),require("@aws-amplify/core"),require("@ng-idle/core"),require("@ng-idle/keepalive"),require("slip39"),require("@aws-amplify/auth")):"function"==typeof define&&define.amd?define("@lifeready/core",["exports","@angular/core","apollo-angular","@dagrejs/graphlib","node-jose","@aws-amplify/auth/lib-esm/Auth","graphql-tag","moment","lodash/cloneDeep","lodash/isEqual","lodash/keyBy","lodash/omit","@apollo/client/core","@apollo/client/link/context","@apollo/client/link/retry","ngx-cookie-service","graphql/language/printer","@angular/common/http","@aws-amplify/core","@ng-idle/core","@ng-idle/keepalive","slip39","@aws-amplify/auth"],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["node-jose"],e["@aws-amplify/auth/lib-esm/Auth"],e["graphql-tag"],e.moment,e["lodash/cloneDeep"],e["lodash/isEqual"],null,e["lodash/omit"],e["@apollo/client/core"],e["@apollo/client/link/context"],e["@apollo/client/link/retry"],e["ngx-cookie-service"],e["graphql/language/printer"],e.ng.common.http,e["@aws-amplify/core"],e["@ng-idle/core"],e["@ng-idle/keepalive"],e.slip39,e["@aws-amplify/auth"])}(this,(function(e,t,n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I){"use strict";function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function K(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 P=w(r),k=w(s),R=K(o),D=w(c),E=w(u),A=w(d),M=w(I),O=function(e,t){return(O=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 T(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}O(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function j(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 N(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 F(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 _(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 $(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 L(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 U(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(L(arguments[t]));return e}function x(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var q,J,G;Object.create;function Q(e){if(e&&e.length){var t=e.map((function(e){return new B({code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,data:e.extensions&&A.default(e.extensions,["code","source"]),message:e.message,debug:{locations:e.locations,path:e.path}})}));throw new(V.bind.apply(V,U([void 0],t)))}}!function(e){e.Key="key",e.PassKey="passKey"}(q||(q={})),function(e){e.KeyLink="keyLink",e.PassKeyLink="passKeyLink"}(J||(J={})),function(e){e.JSON="JSON",e.UINT_8_ARRAY="UINT_8_ARRAY"}(G||(G={}));var W,B=function(e){this._type="KcError",this.code=e.code,this.source=e.source,this.data=e.data,this.message=e.message,this.debug=e.debug},V=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}();(W=e.KcErrorCode||(e.KcErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",W.BAD_ARGUMENT="BAD_ARGUMENT",W.BAD_SIGNATURE="BAD_SIGNATURE",W.BAD_STATE="BAD_STATE",W.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",W.CONCURRENT_ACCESS="CONCURRENT_ACCESS",W.CONFIG_ERROR="CONFIG_ERROR",W.CYCLE_DETECTED="CYCLE_DETECTED",W.EXPIRED="EXPIRED",W.INVALID_TOKEN="INVALID_TOKEN",W.INTERNAL_ERROR="INTERNAL_ERROR",W.JSON_DECODE_ERROR="JSON_DECODE_ERROR",W.KEY_MISMATCH="KEY_MISMATCH",W.LIMIT_REACHED="LIMIT_REACHED",W.LOCKED="LOCKED",W.LOGIC_ERROR="LOGIC_ERROR",W.LR_DEBUG_ONLY="LR_DEBUG_ONLY",W.MIN_DELAY="MIN_DELAY",W.MISSING_FIELD="MISSING_FIELD",W.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",W.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",W.NOT_IMPLEMENTED="NOT_IMPLEMENTED",W.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",W.OBJECT_EXISTS="OBJECT_EXISTS",W.RANGE_ERROR="RANGE_ERROR",W.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",W.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",W.USER_NOT_FOUND="USER_NOT_FOUND",W.VERSION_MISMATCH="VERSION_MISMATCH",W.WRONG_PERMISSIONS="WRONG_PERMISSIONS",W.AUTH="AUTH",W.BAD_LOGIC="BAD_LOGIC",W.BAD_REQUEST="BAD_REQUEST",W.BAD_TIME_SYNC="BAD_TIME_SYNC",W.CODE_MISMATCH="CODE_MISMATCH",W.ENCRYPTION="ENCRYPTION",W.NOT_FOUND="NOT_FOUND",W.SUSPICIOUS_OPERATION="SUSPICIOUS_OPERATION",W.UNSUPPORTED="UNSUPPORTED";var Z=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.AUTH,message:n}))||this}return T(n,t),n}(V),H=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_ARGUMENT,message:n}))||this}return T(n,t),n}(V),Y=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_LOGIC,message:n}))||this}return T(n,t),n}(V),X=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_REQUEST,message:n}))||this}return T(n,t),n}(V),z=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_SIGNATURE,message:n}))||this}return T(n,t),n}(V),ee=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_STATE,message:n}))||this}return T(n,t),n}(V),te=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_TIME_SYNC,message:n}))||this}return T(n,t),n}(V),ne=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.CODE_MISMATCH,message:n}))||this}return T(n,t),n}(V),re=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.CONCURRENT_ACCESS,message:n}))||this}return T(n,t),n}(V),ie=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.ENCRYPTION,message:n}))||this}return T(n,t),n}(V),ae=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.INTERNAL_ERROR,message:n}))||this}return T(n,t),n}(V),se=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.LOCKED,message:n}))||this}return T(n,t),n}(V),oe=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.NOT_FOUND,message:n}))||this}return T(n,t),n}(V),ce=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.SUSPICIOUS_OPERATION,message:n}))||this}return T(n,t),n}(V),ue=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.UNSUPPORTED,message:n}))||this}return T(n,t),n}(V);function pe(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 de(e,t){var n,r,i={};try{for(var a=$(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=L(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 le(e,t){var n=pe(Object.entries(e).map((function(n){var r=L(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return de(e,t)})):de(e,n)}function he(e){return F(this,void 0,void 0,(function(){return _(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 ye,fe,ve=R,me=k.default(ye||(ye=x(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),ge=function(){function e(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=ve.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return e.prototype.verifyCognito=function(){return F(this,void 0,void 0,(function(){var e,t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return[4,he(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=ve(t.headers.get("Date")).valueOf(),i=n+this.offsetMs,Math.abs(i-r)>this.MAX_DIFF_MSEC)throw new te("Server time does not match independent source. ServerTime: "+i+", Cognito time: "+r);return this.verified=!0,[2]}}))}))},e.prototype.refresh=function(){return F(this,void 0,void 0,(function(){var e,t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:me}).toPromise()];case 1:return t=a.sent(),n=Date.now(),Q(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 F(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,he(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}();ge.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ge(t.ɵɵinject(a.AuthClass),t.ɵɵinject(n.Apollo))},token:ge,providedIn:"root"}),ge.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ge.ctorParameters=function(){return[{type:a.AuthClass},{type:n.Apollo}]},function(e){e.JSON="JSON",e.COMPACT="COMPACT"}(fe||(fe={}));var Se={payloadType:G.JSON,returnOnlyPayload:!0},Ce={payloadType:G.JSON,returnOnlyPayload:!0,serializations:[fe.JSON]};var be=function(){function e(e){this.timeService=e}return e.prototype.decrypt=function(e,t,n){return F(this,void 0,void 0,(function(){var r,a;return _(this,(function(s){switch(s.label){case 0:if(r={algorithms:["dir","A*GCM","RSA-OAEP-*"]},n=Object.assign(Object.assign({},Ce),n),e.jwk&&(e=e.jwk),"string"==typeof t&&n.serializations.includes(fe.JSON))try{t=JSON.parse(t)}catch(e){if(!n.serializations.includes(fe.COMPACT))throw e;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,i.JWE.createDecrypt(e,r).decrypt(t)];case 1:return(a=s.sent()).payload=this.decodePayload(n.payloadType,a.payload),n.returnOnlyPayload?[2,a.payload]:[2,a]}}))}))},e.prototype.encryptToString=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){var n,r,a,s;return _(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=i.JWE).createEncrypt,a={contentAlg:"A256GCM"},s={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(a.fields=(s.timestamp=o.sent(),s),a),e]).update(t).final()]}}))}))},e.prototype.sign=function(e,t){return F(this,void 0,void 0,(function(){var n,r,a,s,o;return _(this,(function(c){switch(c.label){case 0:return a=(r=i.JWS).createSign,s={},o={},[4,this.timeService.serverNow()];case 1:return n=a.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 F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){var r,a,s;return _(this,(function(o){switch(o.label){case 0:r={algorithms:["RS*"]},n=Object.assign(Object.assign({},Se),n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i.JWS.createVerify(e,r).verify(t)];case 2:return(a=o.sent()).payload=this.decodePayload(n.payloadType,a.payload),n.returnOnlyPayload?[2,a.payload]:[2,a];case 3:throw s=o.sent(),new z("Bad signature: "+s);case 4:return[2]}}))}))},e.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return F(this,void 0,void 0,(function(){var e,i,a,s;return _(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 G.JSON:return JSON.parse((new TextDecoder).decode(t));case G.UINT_8_ARRAY:return t;default:throw new H("Unknown payloadType: "+e)}},e}();be.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new be(t.ɵɵinject(ge))},token:be,providedIn:"root"}),be.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],be.ctorParameters=function(){return[{type:ge}]};var Ie=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 F(this,void 0,void 0,(function(){var n,r,i;return _(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}();Ie.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ie},token:Ie,providedIn:"root"}),Ie.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var we=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 i.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new H("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 H("array.length <= 0");if(t<=0)throw new H("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 F(this,void 0,void 0,(function(){var t,n;return _(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 F(this,void 0,void 0,(function(){var t,n;return _(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 F(this,void 0,void 0,(function(){var t,n;return _(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 F(this,void 0,void 0,(function(){var t,n;return _(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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var t,s;return _(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 F(this,void 0,void 0,(function(){return _(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new ce("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 F(this,void 0,void 0,(function(){return _(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new ce("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 F(this,void 0,void 0,(function(){return _(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new ce("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 F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return F(this,void 0,void 0,(function(){var e;return _(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 F(this,void 0,void 0,(function(){var e;return _(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}();we.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new we(t.ɵɵinject(Ie))},token:we,providedIn:"root"}),we.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],we.ctorParameters=function(){return[{type:Ie}]};var Ke=new t.InjectionToken("KC_CONFIG"),Pe=[e.KcErrorCode.CONCURRENT_ACCESS];function ke(e,t){var n,r;return F(this,void 0,void 0,(function(){var i,a,s;return _(this,(function(o){switch(o.label){case 0:return[4,he(e)];case 1:return i=o.sent(),a=null===(n=t.debug)||void 0===n?void 0:n.username,s=null===(r=t.debug)||void 0===r?void 0:r.rbacCacheMode,[2,{withCredentials:!0,headers:Object.assign(Object.assign(Object.assign({},i&&{authorization:"Bearer "+i}),a&&{"x-kc-dev-user":a}),s&&{"x-kc-dev-rbac-cache-mode":s})}]}}))}))}var Re=function(e,t){var n=h.setContext((function(n,r){var i=r.headers;return F(void 0,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return[4,ke(t,e)];case 1:return n=r.sent(),[2,Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},i),n.headers)})]}}))}))})),r=new y.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 Pe.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 T(t,e),t}(Error),a=new l.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return Pe.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new i(e.errors);return e}))})),s=l.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:l.from([r,a,n,s]),cache:new l.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{fetchPolicy:"no-cache",errorPolicy:"all"}}},e.apolloConfig)},De=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 H("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 F(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return _(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 F(this,void 0,void 0,(function(){var t,n,r;return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(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,we.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}();De.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new De(t.ɵɵinject(we),t.ɵɵinject(f.CookieService),t.ɵɵinject(be),t.ɵɵinject(t.INJECTOR))},token:De,providedIn:"root"}),De.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],De.ctorParameters=function(){return[{type:we},{type:f.CookieService},{type:be},{type:t.Injector}]};var Ee=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 F(this,void 0,void 0,(function(){var n;return _(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 F(this,void 0,void 0,(function(){var t;return _(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 oe("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 F(this,void 0,void 0,(function(){var t,n;return _(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 oe("Could not find masterKey in persisted storage");if(t.id!==e)throw new oe("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,we.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();Ee.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ee(t.ɵɵinject(Ke),t.ɵɵinject(De))},token:Ee,providedIn:"root"}),Ee.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ee.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:De}]};var Ae=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 F(this,void 0,void 0,(function(){var t,n,r;return _(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 oe("Key graphs does not contain key id: "+e);if(n.type!==t)throw new ee("Key with id "+e+" is not of type "+t);return n.data},e.prototype.key=function(e){return this.getNode(e,q.Key)},e.prototype.passKey=function(e){return this.getNode(e,q.PassKey)},e.prototype.addKeys=function(e){var t,n,r,i,a,s;if(e.keys)try{for(var o=$(e.keys),c=o.next();!c.done;c=o.next()){var u=c.value;if(!this.graph.hasNode(u.id)){var p={type:q.Key,data:D.default(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=$(e.keyLinks),l=d.next();!l.done;l=d.next()){var h=l.value;if(!this.graph.hasEdge(h.wrappingKeyId,h.keyId)){var y={type:J.KeyLink,data:D.default(h)};this.graph.setEdge(h.wrappingKeyId,h.keyId,y)}}}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=$(e.passKeyLinks),v=f.next();!v.done;v=f.next()){var m=v.value;if(!this.graph.hasEdge(m.passKeyId,m.keyId)){y={type:J.PassKeyLink,data:D.default(m)};this.graph.setEdge(m.passKeyId,m.keyId,y)}}}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 ie("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new ie("Param keyId wrong format: "+t);var n=P.default.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},e.prototype.getJwkKey=function(e,t){return F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.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:if(r=a.sent(),null!=n&&n!=r)throw new Y("Requested keyId is not in the key cache, so an API request was made to populate the key cache.But the key returned by the API does NOT match the requested keyId.This is a programming logic error.");n=r,a.label=2;case 2:return(i=this.key(n)).jwk?[2,i]:[2,this.unwrapKey(this.keyService.currentMasterKey.id,n)]}}))}))},e.prototype._unwrapLink=function(e,t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h;return _(this,(function(y){switch(y.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=y.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=y.sent(),y.label=4;case 4:if(t.type!=J.KeyLink)return[3,13];if(!(a=t.data).nestedWrappingKeyIds)return[3,13];y.label=5;case 5:y.trys.push([5,11,12,13]),s=$(a.nestedWrappingKeyIds),o=s.next(),y.label=6;case 6:return o.done?[3,10]:(c=o.value,[4,this.getKey(c)]);case 7:return u=y.sent(),[4,this.encryptionService.decrypt(u.jwk,i)];case 8:i=y.sent(),y.label=9;case 9:return o=s.next(),[3,6];case 10:return[3,13];case 11:return p=y.sent(),l={error:p},[3,13];case 12:try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(l)throw l.error}return[7];case 13:return d=n,[4,we.asKey(i)];case 14:return d.jwk=y.sent(),n.task=null,[2]}}))}))},e.prototype._unwrap=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return _(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=$(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 F(this,void 0,void 0,(function(){var r,i;return _(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 F(this,void 0,void 0,(function(){var n,r,i;return _(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 F(this,void 0,void 0,(function(){var r;return _(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 F(this,void 0,void 0,(function(){var n;return _(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:G.UINT_8_ARRAY})];case 2:return[2,r.sent()]}}))}))},e.prototype.encryptToString=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){return _(this,(function(n){if(!function(e){return"oct"===e.kty}(t))throw new H("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},e.prototype.encryptWithNewKey=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i;return _(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}();Ae.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ae(t.ɵɵinject(be),t.ɵɵinject(Ee),t.ɵɵinject(we))},token:Ae,providedIn:"root"}),Ae.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ae.ctorParameters=function(){return[{type:be},{type:Ee},{type:we}]};var Me=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 F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return Q((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return Q((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();function Oe(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new Y("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function Te(e){return Oe(e,"query")}function je(e){return Oe(e,"mutation")}function Ne(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Fe(e){return{kind:"Name",value:e}}function _e(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function $e(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return k.default.apply(void 0,U([e],t))}Me.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Me(t.ɵɵinject(n.Apollo),t.ɵɵinject(Ae))},token:Me,providedIn:"root"}),Me.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Me.ctorParameters=function(){return[{type:n.Apollo},{type:Ae}]};var Le,Ue,xe="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n nestedWrappingKeyIds\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",qe=k.default(Le||(Le=x(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),xe),Je="keyGraph "+xe,Ge="keyGraph: fetchKeyGraph "+xe,Qe=k.default(Ue||(Ue=x(["\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=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function Be(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 Y("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=U(a,We),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 Ve={hasKeys:!0};function Ze(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s=this;return _(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 F(s,void 0,void 0,(function(){var n,r,i,a;return _(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)]))]}}))}))}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 F(t,void 0,void 0,(function(){var t,n,s,o,c;return _(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),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 F(t,void 0,void 0,(function(){var t,n,i,a,s,u;return _(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 Y("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(Ae))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:t.NgZone},{type:Ae}]},e.CommonProcessorsService=N([Be({ngZoneName:"ngZone"})],e.CommonProcessorsService);var He=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUser=function(e){var t;return F(this,void 0,void 0,(function(){var n,r,i,a,s=this;return _(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 F(this,void 0,void 0,(function(){var n,r;return _(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 F(e,void 0,void 0,(function(){var e,t;return _(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new X('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 F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return _(this,(function(h){switch(h.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,Ze(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=h.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=h.sent(),h.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return _(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,Ze(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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,e]}))}))},e}();function Ye(e,t){return Object.assign(Object.assign({},e),{path:U(e.path,[t])})}He.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new He(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ae))},token:He,providedIn:"root"}),He.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],He.ctorParameters=function(){return[{type:t.NgZone},{type:Ae}]},He=N([Be({ngZoneName:"ngZone"})],He),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("SharedScenarioReceiverDirectoryNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverFileNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("SharedScenarioReceiverFileNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("SharedScenarioReceiverNode",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"})])),this.registerProcessor("DirectoryShareNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"})])),this.registerProcessor("FileShareNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"})]))}return e.prototype.processQuery=function(e,t){return F(this,void 0,void 0,(function(){var n=this;return _(this,(function(r){return t=Object.assign(Object.assign({},Ve),t),[2,le(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 F(this,void 0,void 0,(function(){var e,i,a,s=this;return _(this,(function(o){if(null==t?void 0:t.then)throw new Y("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?le(e,(function(e,t){return s.processField({field:e,context:Ye(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=pe(t.map((function(e,t){return s.processField({field:e,context:Ye(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new Y("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(Ee),t.ɵɵinject(e.CommonProcessorsService),t.ɵɵinject(He))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:t.NgZone},{type:Ee},{type:e.CommonProcessorsService},{type:He}]},e.QueryProcessorService=N([Be({ngZoneName:"ngZone"})],e.QueryProcessorService);var Xe,ze,et,tt=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}(),nt=Te(k.default(Xe||(Xe=x(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],rt=function(){function e(){this._executed=!1,this.deferredPromise=new tt}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 ee("Already executed");this._executed=!0},e}(),it=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return T(t,e),t.prototype.select=function(e){var n=D.default(this.mutation),r=je(n),i={};Ne(e).forEach((function(e){i[e.name.value.split("_")[0]]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=_e(t),r=i[n];r&&(t.selectionSet.selections=[Object.assign(Object.assign({},nt),{name:Fe(r.name.value)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:U(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(rt),at={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},st=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 T(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 Y("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 it)n(e);else{if(!(e instanceof t))throw new ue("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:Fe(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:Fe(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+_e(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:Fe(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:Fe(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={},i=[],a=[];this.lrMutations.forEach((function(s,o){var c,u;if(!(s instanceof rt))throw new Y("An mutation in the array is not of type LrMutationBase.");var p=s.lrMutationData,d=p.mutation,l=p.variables,h=je(d),y="item"+o+"_";h.name&&(y+=h.name.value+"_"),a.push(y),t=U(t,e.renameVariableDefinitions(h.variableDefinitions,y)),n=U(n,e.renameSelections(h.selectionSet.selections,y));try{for(var f=$(Object.keys(l)),v=f.next();!v.done;v=f.next()){var m=v.value;r[y+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=Ne(d);i=U(i,e.renameFragmentDefinitions(g,y))}));var s=D.default(at),o=je(s);return o.selectionSet.selections=n,o.variableDefinitions=t,s.definitions=U(s.definitions,i),{mutation:s,variables:r,prefixes:a}},t}(rt),ot=Te(k.default(ze||(ze=x(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Je)).selectionSet.selections[0],ct=Te(k.default(et||(et=x(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Ge)).selectionSet.selections[0];e.ɵg=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 F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return e=D.default(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Te(e.query)).selectionSet.selections=U(t.selectionSet.selections,[ot])),e.name&&((t=Te(e.query)).name={kind:"Name",value:e.name}),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,Q(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 F(this,void 0,void 0,(function(){return _(this,(function(n){if(null==t?void 0:t.variables)throw new ue('Unsupported field: "options.variables"');if(e.executed)throw new ee("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 F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:D.default(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=je(e.mutation)).selectionSet.selections=U(t.selectionSet.selections,[ct])),e.name&&((t=je(e.mutation)).name={kind:"Name",value:e.name}),e.mutation=k.default(v.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,Q(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return D.default(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 F(this,void 0,void 0,(function(){var n,r,i,a;return _(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=st).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.ɵg.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵg(t.ɵɵinject(t.NgZone),t.ɵɵinject(n.Apollo),t.ɵɵinject(Ae),t.ɵɵinject(e.QueryProcessorService))},token:e.ɵg,providedIn:"root"}),e.ɵg.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵg.ctorParameters=function(){return[{type:t.NgZone},{type:n.Apollo},{type:Ae},{type:e.QueryProcessorService}]},e.ɵg=N([Be({ngZoneName:"ngZone"})],e.ɵg);var ut,pt,dt,lt,ht,yt,ft,vt,mt,gt,St,Ct,bt,It,wt,Kt,Pt,kt,Rt,Dt,Et,At=function(){function t(t){this.lrGraphQL=t.get(e.ɵg)}return t.prototype.mutate=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();function Mt(e){return e.edges.map((function(e){return e.node}))}(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED",(ut=e.PlanState||(e.PlanState={})).ENABLED="ENABLED",ut.DISABLED="DISABLED",(pt=e.ShareTypeChoice||(e.ShareTypeChoice={})).TP="TP",pt.DETACHED="DETACHED",(dt=e.DetachedShareStateChoice||(e.DetachedShareStateChoice={})).IN_PROGRESS="IN_PROGRESS",dt.COMPLETED="COMPLETED",(lt=e.AccessRoleChoice||(e.AccessRoleChoice={})).READER="READER",lt.WRITER="WRITER",lt.ADMIN="ADMIN",lt.CUSTODIAN="CUSTODIAN",lt.DENY="DENY",lt.OWNER="OWNER",(ht=e.AccessRoleChoiceOrder||(e.AccessRoleChoiceOrder={}))[ht.READER=0]="READER",ht[ht.WRITER=1]="WRITER",ht[ht.ADMIN=2]="ADMIN",ht[ht.CUSTODIAN=3]="CUSTODIAN",ht[ht.DENY=4]="DENY",ht[ht.CONFIDENTIAL=5]="CONFIDENTIAL",ht[ht.OWNER=6]="OWNER",(yt=e.AccessRoleMethodChoice||(e.AccessRoleMethodChoice={})).INHERITED="INHERITED",yt.DIRECT="DIRECT",(ft=e.PermissionChoice||(e.PermissionChoice={})).CREATE="CREATE",ft.READ="READ",ft.UPDATE="UPDATE",ft.DELETE="DELETE",ft.SHARE="SHARE",ft.ARCHIVE="ARCHIVE",ft.ACCESS_ARCHIVED="ACCESS_ARCHIVED",ft.UNARCHIVE="UNARCHIVE",ft.SET_CONFIDENTIAL="SET_CONFIDENTIAL",(vt=e.FileOperationField||(e.FileOperationField={})).CREATE="CREATE",vt.READ="READ",vt.UPDATE="UPDATE",vt.REVERT="REVERT",vt.DELETE="DELETE",(mt=e.KeyExchangeOtkState||(e.KeyExchangeOtkState={})).OTK_INITIATED="OTK_INITIATED",mt.OTK_ACCEPTED="OTK_ACCEPTED",mt.OTK_COMPLETED="OTK_COMPLETED",(gt=e.KeyExchangeState||(e.KeyExchangeState={})).IN_PROGRESS="IN_PROGRESS",gt.COMPLETED="COMPLETED",gt.DECLINED="DECLINED",gt.CANCELLED="CANCELLED",gt.DELETED="DELETED",(e.KeyExchangeMode||(e.KeyExchangeMode={})).OTK="OTK",(St=e.TpAssemblyState||(e.TpAssemblyState={})).DISABLED="DISABLED",St.ENABLED="ENABLED",St.CLAIMED="CLAIMED",St.APPROVED="APPROVED",St.REJECTED="REJECTED",St.EXPIRED="EXPIRED",St.CANCELLED="CANCELLED",St.RESET="RESET",(Ct=e.TpClaimState||(e.TpClaimState={})).CLAIMED="CLAIMED",Ct.APPROVED="APPROVED",Ct.REJECTED="REJECTED",Ct.EXPIRED="EXPIRED",Ct.CANCELLED="CANCELLED",Ct.RESET="RESET",(bt=e.TpClaimApproverState||(e.TpClaimApproverState={})).CLAIMED="CLAIMED",bt.APPROVED="APPROVED",bt.REJECTED="REJECTED",(It=e.LockState||(e.LockState={})).UNLOCKED="UNLOCKED",It.MUTEX_LOCKED="MUTEX_LOCKED",(wt=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",wt.ENABLED="ENABLED",wt.CLAIMED="CLAIMED",wt.APPROVED="APPROVED",(Kt=e.ClaimState||(e.ClaimState={})).CLAIMED="CLAIMED",Kt.EXPIRED="EXPIRED",Kt.APPROVED="APPROVED",Kt.REJECTED="REJECTED",Kt.CANCELLED="CANCELLED",Kt.RESET="RESET",(Pt=e.ClaimApproverState||(e.ClaimApproverState={})).CLAIMED="CLAIMED",Pt.APPROVED="APPROVED",Pt.REJECTED="REJECTED",(kt=e.ScenarioLastClaimState||(e.ScenarioLastClaimState={})).CLAIMED="CLAIMED",kt.APPROVED="APPROVED",kt.REJECTED="REJECTED",kt.EXPIRED="EXPIRED",kt.CANCELLED="CANCELLED",kt.RESET="RESET",(Rt=e.LinkTypeField||(e.LinkTypeField={})).HARD="HARD",Rt.SOFT="SOFT",Rt.REFERENCE="REFERENCE",(Dt=e.BillingPeriodField||(e.BillingPeriodField={})).MONTHLY="MONTHLY",Dt.ANNUAL="ANNUAL",(Et=e.PlanStateField||(e.PlanStateField={})).TRIALLING="TRIALLING",Et.ACTIVE="ACTIVE",Et.CANCELLED="CANCELLED",Et.EXPIRED="EXPIRED";var Ot,Tt=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()}},jt=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=Tt(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}};(Ot=e.Config||(e.Config={}))[Ot.TIMEOUT=.01]="TIMEOUT",Ot[Ot.IDLE=1200]="IDLE",Ot[Ot.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var Nt=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 ee("Call IdleService.init() first.")},t.prototype.init=function(t){return F(this,void 0,void 0,(function(){var n,r=this;return _(this,(function(i){switch(i.label){case 0:if(this.initCalled)throw new ee("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 H("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(S.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 F(r,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout({onInit:!1}))];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({onInit:!0}))]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return F(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return t=(e=this.http).post,n=[this.config.authUrl+"auth/keepalive/",null],[4,ke(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 F(this,void 0,void 0,(function(){var t;return _(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(),[2]}}))}))},t.prototype.onPing=function(){return F(this,void 0,void 0,(function(){var e;return _(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 F(this,void 0,void 0,(function(){return _(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}();Nt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Nt(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(S.Idle),t.ɵɵinject(C.Keepalive),t.ɵɵinject(Ee),t.ɵɵinject(a.AuthClass))},token:Nt,providedIn:"root"}),Nt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Nt.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:S.Idle},{type:C.Keepalive},{type:Ee},{type:a.AuthClass}]};var Ft,_t,$t,Lt,Ut,xt,qt,Jt="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",Gt=(k.default(Ft||(Ft=x(["\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}"])),Jt,Je),k.default(_t||(_t=x(['\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}"])),Jt,Je),k.default($t||($t=x(['\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}"])),Jt,Je)),Qt=(k.default(Lt||(Lt=x(["\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}"])),Jt),k.default(Ut||(Ut=x(["\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}"])),Jt),k.default(xt||(xt=x(["\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"])))),Wt=$e(qt||(qt=x(["\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"]))),Bt=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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return _(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 F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return _(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 F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h=this;return _(this,(function(y){switch(y.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=y.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return F(h,void 0,void 0,(function(){var t,r,i,a;return _(this,(function(s){switch(s.label){case 0:return[4,this.getDirectoryKeyId(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=y.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,[y.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},y.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,[y.sent()]),[3,8];case 7:p=null,y.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o;return _(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.getDirectoryKeyId=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Wt,variables:{id:e}})];case 1:return t=r.sent().directory,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();Bt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Bt(t.ɵɵinject(be),t.ɵɵinject(Ae),t.ɵɵinject(Me),t.ɵɵinject(Ee),t.ɵɵinject(we))},token:Bt,providedIn:"root"}),Bt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Bt.ctorParameters=function(){return[{type:be},{type:Ae},{type:Me},{type:Ee},{type:we}]};var Vt,Zt,Ht,Yt,Xt,zt,en,tn,nn,rn="\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",an="\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",sn=$e(Vt||(Vt=x(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ","\n }\n }\n }\n}\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ","\n }\n }\n }\n}\n"])),rn),on=$e(Zt||(Zt=x(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ","\n }\n}\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ","\n }\n}\n"])),rn),cn=$e(Ht||(Ht=x(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ","\n }\n}\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ","\n }\n}\n"])),rn),un=$e(Yt||(Yt=x(["\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"]))),pn=$e(Xt||(Xt=x(["\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"]))),dn=$e(zt||(zt=x(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n }\n}\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n }\n}\n"])),rn),ln=$e(en||(en=x(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"])),rn,an),hn=$e(tn||(tn=x(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"])),rn,an),yn=$e(nn||(nn=x(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\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 ","\n }\n }\n}\n"])),an);(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var fn,vn=function(){},mn=function(){},gn=function(){},Sn=function(){},Cn=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},bn=function(){},In=function(){},wn=function(){},Kn=function(){},Pn=function(){},kn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t}(Pn),Rn=function(){},Dn=function(){};(fn=e.TrustedPartyType||(e.TrustedPartyType={})).User="user",fn.Organisation="organisation";var En,An=function(){},Mn="\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",On=k.default(En||(En=x(["\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}"])),Mn),Tn=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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var t,n,r;return _(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 F(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,h,y;return _(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 Cn(r.name)},y=(h=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 5:return l=y.apply(h,[f.sent()]),[4,this.lrApollo.mutate({mutation:On,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}();Tn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Tn(t.ɵɵinject(Ee),t.ɵɵinject(Me),t.ɵɵinject(Ae),t.ɵɵinject(be))},token:Tn,providedIn:"root"}),Tn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Tn.ctorParameters=function(){return[{type:Ee},{type:Me},{type:Ae},{type:be}]};var jn,Nn,Fn,_n,$n,Ln="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+Mn+"\n }\n myContactCard {\n "+Mn+"\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 "+rn+"\n }\n "+an+"\n }\n }",Un=k.default(jn||(jn=x(['\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),xn=k.default(Nn||(Nn=x(["\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"]))),qn=k.default(Fn||(Fn=x(["\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"]))),Jn=$e(_n||(_n=x(["\nquery TrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n}"],["\nquery TrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n}"])),Ln),Gn=$e($n||($n=x(['\nquery ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n cipherData\n key {\n id\n }\n }\n }\n }\n}\n'],['\nquery ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n cipherData\n key {\n id\n }\n }\n }\n }\n}\n']))),Qn=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.getCurrentUser=function(){return F(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Un})];case 1:return e=i.sent(),t=e.currentUser,n=e.contactCards,r=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:r}]}}))}))},e.prototype.decryptContactCard=function(e){return F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var r;return _(this,(function(i){switch(i.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r=i.sent(),[2,{fields:n,id:r.id,keyId:r.key.id}]}}))}))},e.prototype.prepareContactCardInput=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return _(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 Cn(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 F(this,void 0,void 0,(function(){var t,n,r,i;return _(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:xn,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 F(this,void 0,void 0,(function(){var r,i;return _(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:qn,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 F(this,void 0,void 0,(function(){var t=this;return _(this,(function(n){return[2,Promise.all(e.map((function(e){return F(t,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Gt})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Qt,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return F(this,void 0,void 0,(function(){return _(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}();Qn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Qn(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(Me),t.ɵɵinject(Ee),t.ɵɵinject(Bt),t.ɵɵinject(Ae),t.ɵɵinject(be))},token:Qn,providedIn:"root"}),Qn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Qn.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:Me},{type:Ee},{type:Bt},{type:Ae},{type:be}]};var Wn,Bn,Vn,Zn=k.default(Wn||(Wn=x(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"]))),Hn=k.default(Bn||(Bn=x(["\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"]))),Yn=k.default(Vn||(Vn=x(["\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"]))),Xn=R,zn=function(){},er=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 F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Xn.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i;return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(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 F(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Xn(e.authTime),n=Xn(e.serverTime),r=Xn.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a;return _(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,ke(this.auth,this.config)];case 1:return[2,i.apply(r,a.concat([s.sent()])).toPromise()]}}))}))},e.prototype.getVerifierPrK=function(e,t){return F(this,void 0,void 0,(function(){var n;return _(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,we.asKey(n)];case 2:throw r.sent(),new Z("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s;return _(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:Zn,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 F(this,void 0,void 0,(function(){var i;return _(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Hn,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 F(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:Yn})];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}();er.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new er(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(Me),t.ɵɵinject(a.AuthClass),t.ɵɵinject(Qn),t.ɵɵinject(we),t.ɵɵinject(be),t.ɵɵinject(Ae),t.ɵɵinject(Ie))},token:er,providedIn:"root"}),er.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],er.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:Me},{type:a.AuthClass},{type:Qn},{type:we},{type:be},{type:Ae},{type:Ie}]};var tr="lifeready",nr=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},rr=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}(),ir=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}(),ar=(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 F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return _(this,(function(d){switch(d.label){case 0:r=btoa(e),r=b.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=$(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,b.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 nr(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=$(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=b.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 h=$(s.values()),y=h.next();!y.done;y=h.next()){var f;if(!((f=y.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{y&&!y.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return d},e.prototype.recoverSecret=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,b.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=b.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}());ar.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ar},token:ar,providedIn:"root"}),ar.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var sr,or=$e(sr||(sr=x(["\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}"]))),cr=function(){function t(t){this.keyFactory=t.get(we),this.keyService=t.get(Ee),this.encryptionService=t.get(be),this.keyGraph=t.get(Ae),this.slip39Service=t.get(ar),this.lrGraphQl=t.get(e.ɵg)}return t.prototype.recoverAssemblyKey=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(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 ee("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,we.asKey(Object.assign(Object.assign({},t),{k:r}))];case 2:return[2,i.sent()]}}))}))},t.prototype.prepareTpWrappingKey=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.keyGraph.getKey(e.wrappingKeyId)]}))}))},t.prototype.prepareAssembly=function(e){var t=e.subjectKey,n=e.rootKey;return F(this,void 0,void 0,(function(){var e,r,i,a,s,o,c,u,p;return _(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=j(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 F(this,void 0,void 0,(function(){var e=this;return _(this,(function(a){return[2,Promise.all(t.map((function(t,a){return F(e,void 0,void 0,(function(){var e,s,o=this;return _(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 F(o,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var e=this;return _(this,(function(s){if(r.length!==t.length)throw new H("The slipSubAssemblies must be the same length as the input");return[2,Promise.all(t.map((function(t,s){return F(e,void 0,void 0,(function(){var e,o,c,u,p,d,l=this;return _(this,(function(h){switch(h.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=h.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 F(l,void 0,void 0,(function(){return _(this,(function(e){return[2,this.prepareApprover({tp:r,approverIndex:t,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return d.createApprovers=h.sent(),[4,Promise.all(u.map((function(e,t){var r=e.tp,a=e.approverId;return F(l,void 0,void 0,(function(){return _(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=h.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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,h,y;return _(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=j(i,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),[4,this.prepareSlip39(e.createSubAssemblies,e.quorum,s)];case 4:return u=f.sent(),p=this.getInputApprovers(e.createSubAssemblies),l=Mt,[4,this.lrGraphQl.query({query:or,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 h=f.sent(),[4,this.encryptionService.encryptToString(n,e.subjectCipherDataClearJson||"")];case 7:return y=f.sent(),[2,{assemblyKey:a,mutationInput:Object.assign(Object.assign({},c),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:y,createSubAssemblies:h,rootKeyId:t.id,rootKeyWrappedSubjectKey:r})}]}}))}))},t.prototype.getAssemblyApprovers=function(e){var t=[];return Mt(e.subAssemblies).map((function(e){Mt(e.approvers).forEach((function(e){return t.push(e.tp.id)}))})),t},t.prototype.prepareUpdate=function(e,t){var n;return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b;return _(this,(function(I){switch(I.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 H("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=I.sent(),[4,this.prepareAssembly({rootKey:s.jwk,subjectKey:o.jwk})];case 2:return c=I.sent(),u=c.assemblyKey,p=c.rawAssemblyKey,d=c.assemblyKeyParams,l=j(c,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),h=this.getAssemblyApprovers(t).concat(this.getInputApprovers(r),this.getInputApprovers(i)),f=Mt,[4,this.lrGraphQl.query({query:or,variables:{ids:h}})];case 3:y=f.apply(void 0,[I.sent().tps]),Mt(t.subAssemblies).forEach((function(e){if(!a.includes(e.id)&&!i.some((function(t){return t.id===e.id}))){var t=Mt(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,y),this.fillWrappingKeyId(i,y),I.label=4;case 4:return I.trys.push([4,6,,7]),[4,this.prepareSlip39((r||[]).concat(i||[]),e.quorum,p)];case 5:return v=I.sent(),[3,7];case 6:return m=I.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=I.sent(),[4,this.prepareUpdateSubAssemblies(Object.assign(Object.assign({},g),{input:i,slipSubAssemblies:v.subAssemblies.slice(r.length),subAssemblies:t.subAssemblies}))];case 9:return C=I.sent(),[4,this.encryptionService.encryptToString(o.jwk,null!==(n=e.subjectCipherDataClearJson)&&void 0!==n?n:t.subjectCipherDataClearJson)];case 10:return b=I.sent(),[2,{assemblyKey:u,mutationInput:Object.assign(Object.assign({},l),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:b,subjectKeyId:o.id,createSubAssemblies:S,updateSubAssemblies:C})}]}}))}))},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 F(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y;return _(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 h=f.sent(),[4,this.encryptionService.encryptToString(o,d)];case 7:return y=f.sent(),[2,{tpWrappingKeyId:e.id,tpWrappedSharedKey:c,subjectKeyWrappedSharedKey:u,sharedCipherData:l,sharedCipherApprovalData:h,sharedCipherPartialAssemblyKey:y,approverId:t||void 0,tpId:t?void 0:n.tpId}]}}))}))},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=$(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 H(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 F(this,void 0,void 0,(function(){var r;return _(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new H("Not enough sub assemblies to meet quorum");return r=new ir(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new rr(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=tr,r}return T(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.mkSharedKey.id},t}(cr),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=N([Be({ngZoneName:"ngZone"})],e.ɵi);var ur,pr,dr,lr,hr,yr,fr,vr,mr,gr,Sr,Cr,br,Ir,wr,Kr,Pr=$e(ur||(ur=x(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),kr=$e(pr||(pr=x(["\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}"]))),Rr=$e(dr||(dr=x(["\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}"]))),Dr=$e(lr||(lr=x(["\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}"]))),Er=$e(hr||(hr=x(["\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}"]))),Ar=$e(yr||(yr=x(["\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}"]))),Mr=$e(fr||(fr=x(["\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}"]))),Or=$e(vr||(vr=x(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),Tr=$e(mr||(mr=x(["\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}"]))),jr=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}(),Nr=$e(gr||(gr=x(["\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),Fr=$e(Sr||(Sr=x(["\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}"]))),_r=$e(Cr||(Cr=x(["\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"])));(br=e.RecoveryStatus||(e.RecoveryStatus={})).NONE="NONE",br.NEW_PASSWORD="NEW_PASSWORD",br.OLD_PASSWORD="OLD_PASSWORD",(Ir=e.PasswordChangeStatus||(e.PasswordChangeStatus={})).IN_PROGRESS="IN_PROGRESS",Ir.RECOVERY="RECOVERY",(wr=e.CognitoChallengeName||(e.CognitoChallengeName={})).NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",wr.SMS_MFA="SMS_MFA",wr.SOFTWARE_TOKEN_MFA="SOFTWARE_TOKEN_MFA",wr.MFA_SETUP="MFA_SETUP",e.AuthService=Kr=function(n){function r(e,r,i,a,s,o,c,u,p,d,l,h,y,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=h,v.assemblyController=y,v.kcConfig=f,v.logoutListeners=new Set,v.password=null,!t.isDevMode()&&null!=v.kcConfig.debug)throw new X('In production mode, "KcConfig.debug" must be set to null');return v}return T(r,n),r.prototype.importPassword=function(e){return this.keyFactoryService.importPassword(e)},r.prototype.logout=function(){var e;return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,Promise.all(U(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 F(this,void 0,void 0,(function(){var r;return _(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return(r=a.sent()).challenge?(this.password=new jr(n,Kr.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(t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o;return _(this,(function(c){switch(c.label){case 0:if(n=t.challenge,r=t.code,i=t.rememberMe,!(a=[e.CognitoChallengeName.SMS_MFA,e.CognitoChallengeName.SOFTWARE_TOKEN_MFA]).includes(n.cognitoUser.challengeName))throw new X("challengeName must be one of "+a);return[4,this.cognito.confirmSignIn(n.cognitoUser,r,n.cognitoUser.challengeName)];case 1:return s=c.sent(),[4,this.handlePostAuth(n.recoveryStatus)];case 2:return c.sent(),[4,this.loadUser(s,this.password.pop())];case 3:return o=c.sent(),this.password=null,i&&s.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,{user:o}]}}))}))},r.prototype.getUser=function(){return F(this,void 0,void 0,(function(){var e;return _(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 F(this,void 0,void 0,(function(){var e,t;return _(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 F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Nr,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().currentUser]}}))}))},r.prototype.fetchResetUser=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Fr,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().tpPasswordResetUser]}}))}))},r.prototype.kcLogout=function(){return F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(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(t,n){return F(this,void 0,void 0,(function(){var r;return _(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(t,n)];case 2:return r=i.sent(),[e.CognitoChallengeName.SMS_MFA,e.CognitoChallengeName.SOFTWARE_TOKEN_MFA].includes(r.cognitoUser.challengeName)?[2,{challenge:{cognitoUser:r.cognitoUser,recoveryStatus:r.recoveryStatus}}]:[4,this.handlePostAuth(r.recoveryStatus)];case 3:return i.sent(),[4,this.loadUser(r.cognitoUser,n)];case 4:return[2,{user:i.sent()}]}}))}))},r.prototype.loginIdp=function(t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l;return _(this,(function(h){switch(h.label){case 0:return[4,this.fetchPassIdpParams(t)];case 1:if((r=h.sent()).passwordChangeStatus===e.PasswordChangeStatus.IN_PROGRESS)throw new re("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.RECOVERY)return[3,8];console.log("In recovery mode."),h.label=2;case 2:return h.trys.push([2,4,,5]),a={},[4,this.loginIdpImpl(t,n,r.newPassIdpParams)];case 3:return a.cognitoUser=h.sent(),a.recoveryStatus=e.RecoveryStatus.NEW_PASSWORD,i=a,console.log("New password works!"),[2,i];case 4:if("NotAuthorizedException"!==(s=h.sent()).code)throw s;return[3,5];case 5:return h.trys.push([5,7,,8]),c={},[4,this.loginIdpImpl(t,n,r.currentPassIdpParams)];case 6:return c.cognitoUser=h.sent(),c.recoveryStatus=e.RecoveryStatus.OLD_PASSWORD,o=c,console.log("Old password works!"),[2,o];case 7:throw"NotAuthorizedException"===(u=h.sent()).code?new X("The password change request was interrupted, please try to login with both your new and old password"):u;case 8:if(!r.tpPasswordReset)return[3,12];h.label=9;case 9:return h.trys.push([9,11,,12]),p=r.tpPasswordReset,d={},[4,this.loginIdpImpl(p.resetUsername,n,p.passIdpParams)];case 10:return d.cognitoUser=h.sent(),d.recoveryStatus=e.RecoveryStatus.NONE,[2,d];case 11:return h.sent(),[3,12];case 12:return l={},[4,this.loginIdpImpl(t,n,r.currentPassIdpParams)];case 13:return l.cognitoUser=h.sent(),l.recoveryStatus=e.RecoveryStatus.NONE,[2,l]}}))}))},r.prototype.loginIdpImpl=function(e,t,n){return F(this,void 0,void 0,(function(){var r;return _(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 F(this,void 0,void 0,(function(){return _(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(t){return F(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return t===e.RecoveryStatus.NONE?[3,2]:[4,this.passwordService.changePasswordComplete({useNewPassword:t===e.RecoveryStatus.NEW_PASSWORD})];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},r.prototype.handleSessionEncryptionKey=function(){return F(this,void 0,void 0,(function(){var e,n;return _(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 ae(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 it({mutation:_r,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 F(this,void 0,void 0,(function(){var t,n,r,a,s,o,c,u;return _(this,(function(p){switch(p.label){case 0:return t=e.userKeys,n=e.password,(r=e.sessionEncryptionKey)?(s=(a=this.persistService).setServerSessionEncryptionKey,[4,i.JWK.asKey(r)]):[3,2];case 1:s.apply(a,[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 F(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){switch(i.label){case 0:return e.getUsername().endsWith(".tp_password_reset")?(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 F(this,void 0,void 0,(function(){var n,r,i,a;return _(this,(function(s){switch(s.label){case 0:return[4,this.fetchCurrentUser()];case 1:return n=s.sent(),[4,this.loadUserKeys({userKeys:n.currentUserKey,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return s.sent(),[4,this.keyGraphService.populateKeys(n.currentUserKey)];case 3:return s.sent(),r=n.id,i=n.username,[4,this.cognito.userAttributes(e)];case 4:return a=s.sent(),[2,{id:r,username:i,sub:this.getCognitoUserAttribute("sub",a),loginEmail:this.getCognitoUserAttribute("email",a),resetUser:null}]}}))}))},r.prototype.loadResetUser=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a;return _(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 F(this,void 0,void 0,(function(){var t,n,r=this;return _(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 F(this,void 0,void 0,(function(){var n,r,a,s,o,c,u,p,d,l,h,y,f,v,m=this;return _(this,(function(S){switch(S.label){case 0:return[4,this.fetchResetUser()];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new ee("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 a=S.sent().rootKey,[4,i.JWK.asKey(a)];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 it({mutation:kr,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 h=S.sent(),[4,this.lrGraphQL.lrMutate(new it({mutation:Rr,variables:{input:{signedChallenge:JSON.stringify(h)}}}),{includeKeyGraph:!1})];case 11:return y=S.sent().preCompleteTpPasswordResetRequest.idpPassword,f=new Promise((function(e){var t=function(r){return F(m,void 0,void 0,(function(){return _(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(g.Hub.remove("auth",t),[4,this.cognito.signIn(n.username,p)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new it({mutation:Dr,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};g.Hub.listen("auth",t)})),[4,this.cognito.signIn(n.username,y,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(v=S.sent()).challengeName)throw new ae("Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.");return[4,this.cognito.completeNewPassword(v,p,{})];case 13:return v=S.sent(),[2,f]}}))}))},r.prototype.debugLogin=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return this.kcConfig.debug.username=e,this.kcConfig.debug.rbacCacheMode=null,[4,this.http.get(this.kcConfig.authUrl+"debug_only/users/login/?username="+encodeURIComponent(e)).toPromise()];case 1:return n.sent(),[2,this.debugLoadUser(t)]}}))}))},r.prototype.debugLoadUser=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(this,(function(o){switch(o.label){case 0:return[4,this.fetchCurrentUser()];case 1:return t=o.sent(),n=t.id,r=t.username,i=t.currentUserKey,[4,this.keyFactoryService.derivePassKey(Object.assign({password:e},i.passKey.passKeyParams))];case 2:return a=o.sent().jwk,[4,this.keyGraphService.unwrapWithPassKey(i.passKey.id,a,i.masterKey.id)];case 3:return s=o.sent(),[4,this.idleService.persistMasterKey(s)];case 4:return o.sent(),[4,this.keyGraphService.populateKeys(i)];case 5:return o.sent(),this.user={id:n,username:r,resetUser:null,sub:"DEBUG_MODE",loginEmail:"DEBUG_MODE"},[2,this.user]}}))}))},r.prototype.debugClearUser=function(){this.user=null},r.prototype.getCurrentUserAttributes=function(){return F(this,void 0,void 0,(function(){var e;return _(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.prototype.debugRetainRbacCache=function(e){this.kcConfig.debug.rbacCacheMode=e?"retain":null},r}(At),e.AuthService.CHALLENGE_TIMEOUT=3e5,e.AuthService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.AuthService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(m.HttpClient),t.ɵɵinject(a.AuthClass),t.ɵɵinject(e.ɵg),t.ɵɵinject(Ee),t.ɵɵinject(Ae),t.ɵɵinject(we),t.ɵɵinject(er),t.ɵɵinject(Nt),t.ɵɵinject(De),t.ɵɵinject(be),t.ɵɵinject(e.ɵi),t.ɵɵinject(Ke))},token:e.AuthService,providedIn:"root"}),e.AuthService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.AuthService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:m.HttpClient},{type:a.AuthClass},{type:e.ɵg},{type:Ee},{type:Ae},{type:we},{type:er},{type:Nt},{type:De},{type:be},{type:e.ɵi},{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]}]},e.AuthService=Kr=N([Be({ngZoneName:"ngZone"})],e.AuthService);var $r,Lr,Ur,xr=$e($r||($r=x(["\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"]))),qr=$e(Lr||(Lr=x(["\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"]))),Jr=$e(Ur||(Ur=x(["\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"]))),Gr=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 F(this,void 0,void 0,(function(){var t,n,r,i,a;return _(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 it({mutation:xr,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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 it({mutation:qr,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new it({mutation:Jr,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return _(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(we),t.ɵɵinject(Ee),t.ɵɵinject(be),t.ɵɵinject(Ae),t.ɵɵinject(Bt),t.ɵɵinject(t.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:we},{type:Ee},{type:be},{type:Ae},{type:Bt},{type:t.NgZone}]},e.ContactCard2Service=N([Be({ngZoneName:"ngZone"})],e.ContactCard2Service);var Qr=function(){function e(e,t,n){this.config=e,this.http=t,this.auth=n}return e.prototype.downloadEncryptedFileJson=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return _(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,ke(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(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,ke(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}();Qr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Qr(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(a.AuthClass))},token:Qr,providedIn:"root"}),Qr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Qr.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:a.AuthClass}]};var Wr,Br,Vr,Zr,Hr,Yr,Xr,zr,ei,ti,ni,ri,ii,ai,si,oi,ci,ui,pi,di,li,hi=$e(Wr||(Wr=x(["\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"]))),yi=$e(Br||(Br=x(["\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"]))),fi=$e(Vr||(Vr=x(["\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"]))),vi=$e(Zr||(Zr=x(["\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"]))),mi=$e(Hr||(Hr=x(["\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"]))),gi=$e(Yr||(Yr=x(["\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"]))),Si=$e(Xr||(Xr=x(["\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"]))),Ci=$e(zr||(zr=x(["\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"]))),bi=$e(ei||(ei=x(["\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"]))),Ii=$e(ti||(ti=x(["\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"]))),wi=$e(ni||(ni=x(["\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"]))),Ki=$e(ri||(ri=x(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"],["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"]))),Pi=$e(ii||(ii=x(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"],["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"]))),ki=$e(ai||(ai=x(["\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"]))),Ri=$e(si||(si=x(['\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']))),Di=$e(oi||(oi=x(["\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"]))),Ei=$e(ci||(ci=x(["\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"]))),Ai=$e(ui||(ui=x(["\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}"]))),Mi=$e(pi||(pi=x(["\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"])),Ai),Oi=$e(di||(di=x(["\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"])),Ai),Ti=$e(li||(li=x(["\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"])),Ai);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return T(t,e),t.prototype.updateLockMutation=function(e){return new it({mutation:Mi,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t.prototype.acquireLockMutation=function(e){return new it({mutation:Oi,variables:{input:{resourceId:e.resourceId,timeoutMs:e.timeoutMs}}})},t.prototype.releaseLockMutation=function(e){return new it({mutation:Ti,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=N([Be({ngZoneName:"ngZone"})],e.LockService);var ji,Ni,Fi,_i,$i,Li,Ui=$e(ji||(ji=x(["\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"]))),xi=$e(Ni||(Ni=x(["\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"]))),qi=$e(Fi||(Fi=x(["\nquery DirectoryKeyFromDirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"],["\nquery DirectoryKeyFromDirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"]))),Ji=$e(_i||(_i=x(["\nquery FileKeyFromFileShareQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"],["\nquery FileKeyFromFileShareQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"]))),Gi=$e($i||($i=x(["\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.ItemService=Li=function(t){function n(e,n,r,i,a,s,o,c){var u=t.call(this,n)||this;return u.ngZone=e,u.injector=n,u.fileUploadService=r,u.keyService=i,u.keyFactory=a,u.keyGraph=s,u.lockService=o,u.authService=c,u.tempDirectory=null,u.authService.addLogoutListener((function(){return u.onLogout()})),u}return T(n,t),n.prototype.downloadFileContent=function(e){return F(this,void 0,void 0,(function(){var t,n,r=this;return _(this,(function(i){switch(i.label){case 0:return[4,this.fileUploadService.downloadEncryptedFile(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:G.UINT_8_ARRAY})]}}))}))},n.prototype.getDirectoryKeyId=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Ui,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},n.prototype.getFileKeyId=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:xi,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},n.prototype.getDirectoryKeyIdFromDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:qi,variables:{id:e}})];case 1:return[2,t.sent().directoryShare.item.keyId]}}))}))},n.prototype.getFileKeyIdFromFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Ji,variables:{id:e}})];case 1:return[2,t.sent().fileShare.item.keyId]}}))}))},n.prototype.getDirectoryKey=function(e,t){return F(this,void 0,void 0,(function(){var n=this;return _(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},n.prototype.getFileKey=function(e,t){return F(this,void 0,void 0,(function(){var n=this;return _(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},n.prototype.createDirectory=function(e){return this.mutate(this.createDirectoryMutation(e))},n.prototype.createDirectoryMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:hi},r={},[4,this.prepareCreateDirectory(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.updateDirectory=function(e){return this.mutate(this.updateDirectoryMutation(e))},n.prototype.updateDirectoryMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:yi},r={},[4,this.prepareUpdateDirectory(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.deleteDirectory=function(e){return this.mutate(this.deleteDirectoryMutation(e))},n.prototype.deleteDirectoryMutation=function(e){return new it({mutation:fi,variables:{input:{directoryId:e}}})},n.prototype.createFile=function(e){return this.mutate(this.createFileMutation(e))},n.prototype.createFileMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:vi},r={},[4,this.prepareCreateFile(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.updateFile=function(e){return this.mutate(this.updateFileMutation(e))},n.prototype.updateFileMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:mi},r={},[4,this.prepareUpdateFile(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.revertFile=function(e){return this.mutate(this.revertFileMutation(e))},n.prototype.revertFileMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:gi,variables:{input:e}})]}))}))},n.prototype.deleteFile=function(e){return this.mutate(this.deleteFileMutation(e))},n.prototype.deleteFileMutation=function(e){return new it({mutation:Si,variables:{input:{fileId:e}}})},n.prototype.archiveDirectory=function(e,t){return this.mutate(this.archiveDirectoryMutation(e,t))},n.prototype.archiveDirectoryMutation=function(e,t){return new it({mutation:Ci,variables:{input:{directoryId:e,recursive:t.recursive}}})},n.prototype.archiveFile=function(e){return this.mutate(this.archiveFileMutation(e))},n.prototype.archiveFileMutation=function(e){return new it({mutation:bi,variables:{input:{fileId:e}}})},n.prototype.unarchiveDirectory=function(e,t){return this.mutate(this.unarchiveDirectoryMutation(e,t))},n.prototype.unarchiveDirectoryMutation=function(e,t){return new it({mutation:Ii,variables:{input:{directoryId:e,recursive:t.recursive}}})},n.prototype.unarchiveFile=function(e){return this.mutate(this.unarchiveFileMutation(e))},n.prototype.unarchiveFileMutation=function(e){return new it({mutation:wi,variables:{input:{fileId:e}}})},n.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},n.prototype.changeDirectoryParentsMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:Ki},r={},[4,this.prepareChangeDirectoryParents(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.changeFileParents=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},n.prototype.changeFileParentsMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:Pi},r={},[4,this.prepareChangeFileParents(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.beginDeleteChildItemLinksWindow=function(e){return this.mutate(this.beginDeleteChildItemLinksWindowMutation(e))},n.prototype.beginDeleteChildItemLinksWindowMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:ki,variables:{input:e}})]}))}))},n.prototype.ensureTempDirectory=function(){var e;return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return _(this,(function(p){switch(p.label){case 0:return this.tempDirectory?[2,this.tempDirectory]:[4,this.query({query:Ri,variables:{plainMeta:Li.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: "+Li.TEMP_DIRECTORY_PLAIN_META_FILTER+")"),0!==t.rootDirectories.edges.length?[3,4]:[4,this.createDirectoryMutation({asRootDirectory:!0,plainMetaJson:Li.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=L.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]}}))}))},n.prototype.createDirectoryWithStaging=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createDirectoryWithStagingMutation(e))]}))}))},n.prototype.createDirectoryWithStagingMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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.createDirectory({cipherMetaClearJson:e.cipherMetaClearJson,parentDirectories:[{directory:t}],plainMetaJson:e.plainMetaJson})];case 3:return n=r.sent().createDirectory.directory,[4,e.onCreatedInStaging({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})]}}))}))},n.prototype.createFileWithStaging=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createFileWithStagingMutation(e))]}))}))},n.prototype.createFileWithStagingMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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.createFile(Object.assign(Object.assign({},e),{parentDirectories:[{directory:t}]}))];case 3:return n=r.sent().createFile.file,[4,e.onCreatedInStaging({id:n.id,keyId:n.keyId})];case 4:return r.sent(),[2,this.changeFileParentsMutation({file:n,parentsToRemove:[t.id],parentsToAdd:e.parentDirectories})]}}))}))},n.prototype.setFileConfidential=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.setFileConfidentialMutation(e))]}))}))},n.prototype.setFileConfidentialMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:Di,variables:{input:{fileId:e.fileId,confidential:e.confidential}}})]}))}))},n.prototype.setDirectoryConfidential=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.setDirectoryConfidentialMutation(e))]}))}))},n.prototype.setDirectoryConfidentialMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:Ei,variables:{input:{directoryId:e.directoryId,confidential:e.confidential}}})]}))}))},n.prototype.prepareParentDirectory=function(t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c;return _(this,(function(u){switch(u.label){case 0:return r=t.directoryId,i=t.wrappingKeyId,a=t.linkType,s=t.directory||{id:r,keyId:i},a!=e.LinkTypeField.REFERENCE?[3,1]:[2,{directoryId:s.id,linkType:a}];case 1:return[4,this.getDirectoryKey(s.id,s.keyId)];case 2:return o=u.sent(),c={directoryId:s.id,wrappingKeyId:o.id},[4,this.keyGraph.wrapKey(o,n)];case 3:return[2,(c.wrappedKey=u.sent(),c.linkType=a,c)]}}))}))},n.prototype.getFileStateKeyId=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Gi,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},n.prototype.prepareCreateFileState=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h;return _(this,(function(y){switch(y.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=y.sent(),(i=t.file)?[4,this.fileUploadService.loadFile(t.file)]:[3,3];case 2:i=y.sent(),y.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,8];case 4:return s=y.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=y.sent(),[3,8];case 6:return[4,this.fileUploadService.uploadEncryptedFile({encryptedContent:s})];case 7:a=y.sent(),y.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([y.sent()]))],h={},[4,this.keyGraph.wrapKey(e,n)];case 10:return[2,c.apply(o,l.concat([(h.wrappedStateKey=y.sent(),h.contentResource=a,h)]))]}}))}))},n.prototype.prepareChangeItemParents=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i=this;return _(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}]}}))}))},n.prototype.prepareItem=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a;return _(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)]}}))}))},n.prototype.prepareCreateDirectory=function(e){var t,n,r;return F(this,void 0,void 0,(function(){var i,a,s,o,c,u,p=this;return _(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 H("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 H("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})]}}))}))},n.prototype.prepareUpdateDirectory=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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})]}}))}))},n.prototype.prepareCreateFile=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i=this;return _(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 i.prepareParentDirectory(e,t)})))];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})]}}))}))},n.prototype.prepareUpdateFile=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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})]}}))}))},n.prototype.prepareChangeDirectoryParents=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=e.directory||{id:e.directoryId,keyId:e.directoryKeyId},[4,this.getDirectoryKey(t.id,t.keyId)];case 1:return n=i.sent(),[4,this.prepareChangeItemParents(e,n.jwk)];case 2:return r=i.sent(),[2,Object.assign(Object.assign({},r),{directoryId:t.id})]}}))}))},n.prototype.prepareChangeFileParents=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=e.file||{id:e.fileId,keyId:e.fileKeyId},[4,this.getFileKey(t.id,t.keyId)];case 1:return n=i.sent(),[4,this.prepareChangeItemParents(e,n.jwk)];case 2:return r=i.sent(),[2,Object.assign(Object.assign({},r),{fileId:t.id})]}}))}))},n.prototype.onLogout=function(){this.tempDirectory=null},n}(At),e.ItemService.TEMP_DIRECTORY_PLAIN_META={kcType:"temp"},e.ItemService.TEMP_DIRECTORY_PLAIN_META_FILTER=JSON.stringify({filter:[{contains:Li.TEMP_DIRECTORY_PLAIN_META}]}),e.ItemService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ItemService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Qr),t.ɵɵinject(Ee),t.ɵɵinject(we),t.ɵɵinject(Ae),t.ɵɵinject(e.LockService),t.ɵɵinject(e.AuthService))},token:e.ItemService,providedIn:"root"}),e.ItemService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ItemService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Qr},{type:Ee},{type:we},{type:Ae},{type:e.LockService},{type:e.AuthService}]},e.ItemService=Li=N([Be({ngZoneName:"ngZone"})],e.ItemService),e.KeyExchangeService=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 T(t,e),t.prototype.getOtKey=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){switch(i.label){case 0:return t?[4,we.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:[fe.COMPACT]})]);case 3:return(r=i.sent()).otKey?[4,we.asKey(r.otKey)]:[3,5];case 4:return[2,i.sent()];case 5:return[2,null]}}))}))},t.prototype.decryptOtk=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o;return _(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 F(this,void 0,void 0,(function(){var r;return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return _(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,we.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,we.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 F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},t.prototype.decryptKeyExchange=function(e,t){return F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var e,n=this;return _(this,(function(r){switch(r.label){case 0:return[4,this.query({query:sn,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 F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.query({query:i?cn:on,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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.query({query:yn,variables:{username:e.username,userId:e.userId}})]}))}))},t.prototype.cancelKeyExchange=function(e){return this.mutate(this.cancelKeyExchangeMutation(e))},t.prototype.cancelKeyExchangeMutation=function(e){return new it({mutation:un,variables:{input:{id:e}}})},t.prototype.declineKeyExchange=function(e,t){return this.mutate(this.declineKeyExchangeMutation(e,t))},t.prototype.declineKeyExchangeMutation=function(e,t){return new it({mutation:pn,variables:{input:{id:e,token:t}}})},t.prototype.initiateOtk=function(e){return void 0===e&&(e={}),F(this,void 0,void 0,(function(){var t;return _(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.initiateOtkMutation=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return F(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,h,y,f,v;return _(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(),h={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},y=this.keyService.currentRootKey,[4,this.keyGraph.encryptToString(y.jwk,h)];case 6:return f=m.sent(),v=e.toJSON(!0).k,[2,{lrMutation:new it({mutation:dn,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.respondOtk=function(e){return this.mutate(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 F(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I,w,K,P,k,R,D,E,A,M,O,T,j,N,F,$,L,U,x,q,J,G,Q,W,B,V,Z,H,Y,X,z,ee;return _(this,(function(_){switch(_.label){case 0:return e=this.keyService.currentRootKey,o=this.keyService.currentMasterKey,[4,this.keyFactory.createKey()];case 1:return c=_.sent(),[4,this.keyFactory.createKey()];case 2:return u=_.sent(),[4,this.encryptionService.encrypt(e.jwk,c.toJSON(!0))];case 3:return p=_.sent(),[4,this.encryptionService.encrypt(o.jwk,u.toJSON(!0))];case 4:return d=_.sent(),[4,we.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 5:return l=_.sent(),[4,we.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 6:return h=_.sent(),[4,we.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 7:return y=_.sent(),f=this.keyService.currentPxk,v=this.keyService.currentSigPxk,[4,this.encryptionService.sign(v.jwk,h.toJSON())];case 8:return m=_.sent(),[4,this.encryptionService.sign(v.jwk,y.toJSON())];case 9:return g=_.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?(b=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,19];case 10:return I=_.sent(),[4,this.keyFactory.createKey()];case 11:return F=_.sent(),$=this.keyService.currentSigPxk,w={},P=(K=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,I.toJSON(!0))];case 12:return w.receiverWrappedKey=P.apply(K,[_.sent()]),w.receiverWrappingKeyId=e.id,a?(D=(R=JSON).stringify,[4,this.encryptionService.encrypt(I,a.receiverCipherDataClearJson)]):[3,14];case 13:return k=D.apply(R,[_.sent()]),[3,15];case 14:k="",_.label=15;case 15:return w.receiverCipherData=k,A=(E=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 16:return w.sharedWrappedKey=A.apply(E,[_.sent()]),C=w,[4,this.encryptionService.encrypt(F,b)];case 17:return B=_.sent(),M=C,T=(O=JSON).stringify,[4,this.encryptionService.sign($.jwk,B)];case 18:M.sharedCipherDataSig=T.apply(O,[_.sent()]),C.sigPxkId=$.id,S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherKey:F.toJSON(!0)}),_.label=19;case 19:return s?[4,this.keyFactory.createKey()]:[3,31];case 20:return N=_.sent(),[4,this.keyFactory.createKey()];case 21:return F=_.sent(),$=this.keyService.currentSigPxk,L={},x=(U=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,N.toJSON(!0))];case 22:return L.ownerWrappedKey=x.apply(U,[_.sent()]),L.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(G=(J=JSON).stringify,[4,this.encryptionService.encrypt(N,s.ownerCipherDataClearJson)]):[3,24];case 23:return q=G.apply(J,[_.sent()]),[3,25];case 24:q="",_.label=25;case 25:return L.ownerCipherData=q,W=(Q=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 26:return L.sharedWrappedKey=W.apply(Q,[_.sent()]),j=L,[4,this.encryptionService.encrypt(F,s.sharedCipherDataClearJson)];case 27:return B=_.sent(),V=j,H=(Z=JSON).stringify,[4,this.encryptionService.sign($.jwk,B)];case 28:return V.sharedCipherDataSig=H.apply(Z,[_.sent()]),j.sigPxkId=$.id,s.ownerPlainDataJson?(Y=j,z=(X=JSON).stringify,[4,this.encryptionService.sign(v.jwk,s.ownerPlainDataJson)]):[3,30];case 29:Y.ownerPlainDataSig=z.apply(X,[_.sent()]),_.label=30;case 30:S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),_.label=31;case 31:return[4,this.encryptionService.encrypt(l,S)];case 32:return ee=_.sent(),[4,this.encryptionService.encrypt(r.otKey,ee)];case 33:return ee=_.sent(),[2,new it({mutation:ln,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:C,responderContactCard:j}}})]}}))}))},t.prototype.completeOtk=function(e){return this.mutate(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 F(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I,w,K,P,k,R,D,E,A,M,O,T,j,N,F,$,L,U,x,q;return _(this,(function(_){switch(_.label){case 0:return e=this.keyService.currentRootKey,s=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(e.jwk,n)];case 1:return o=_.sent(),u=this.decryptResponseCipher,[4,we.asKey(o.otKey)];case 2:return p=[_.sent()],[4,we.asKey(o.oneTimePrk)];case 3:return[4,u.apply(this,p.concat([_.sent(),r]))];case 4:if(c=_.sent(),o.nonce!==c.nonce)throw new ne("The nonce returned by responder does not match with the one created by the initiator.");return d=this.keyService.currentSigPxk,[4,we.asKey(c.responder.sigPbk)];case 5:return l=_.sent(),[4,we.asKey(c.responder.pbk)];case 6:return h=_.sent(),[4,this.encryptionService.sign(d.jwk,h.toJSON())];case 7:return y=_.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 8:return f=_.sent(),[4,we.asKey(c.sharedKey)];case 9:return v=_.sent(),[4,this.encryptionService.encrypt(e.jwk,v.toJSON(!0))];case 10:return m=_.sent(),[4,we.asKey(c.mkSharedKey)];case 11:return g=_.sent(),[4,this.encryptionService.encrypt(s.jwk,g.toJSON(!0))];case 12:return S=_.sent(),i?[4,this.keyFactory.createKey()]:[3,16];case 13:return b=_.sent(),I={},K=(w=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,b.toJSON(!0))];case 14:return I.receiverWrappedKey=K.apply(w,[_.sent()]),I.receiverWrappingKeyId=e.id,k=(P=JSON).stringify,[4,this.encryptionService.encrypt(b,i.receiverCipherDataClearJson)];case 15:I.receiverCipherData=k.apply(P,[_.sent()]),C=I,_.label=16;case 16:return o.initiatorContactCard?(E=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,25];case 17:return A=_.sent(),[4,we.asKey(c.responder.contactCard.sharedCipherKey)];case 18:return M=_.sent(),j=(T=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,A.toJSON(!0))];case 19:return O=j.apply(T,[_.sent()]),(N=(null==a?void 0:a.ownerCipherDataClearJson)||E.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(A,N)]:[3,21];case 20:return $=_.sent(),[3,22];case 21:$="",_.label=22;case 22:return F=$,R={ownerWrappedKey:O,ownerWrappingKeyId:e.id,ownerCipherData:F},D={sigPxkId:d.id},[4,this.encryptionService.encrypt(M,E.sharedCipherDataClearJson)];case 23:return L=_.sent(),U=D,q=(x=JSON).stringify,[4,this.encryptionService.sign(d.jwk,L)];case 24:U.sharedCipherDataSig=q.apply(x,[_.sent()]),_.label=25;case 25:return[2,new it({mutation:hn,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(f),rkWrappedSharedKey:JSON.stringify(m),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:C,initiatorContactCardCipher:R,initiatorContactCardSharedCipher:D}}})]}}))}))},t}(At),e.KeyExchangeService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.KeyExchangeService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(we),t.ɵɵinject(Ee),t.ɵɵinject(be),t.ɵɵinject(Ae))},token:e.KeyExchangeService,providedIn:"root"}),e.KeyExchangeService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.KeyExchangeService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:we},{type:Ee},{type:be},{type:Ae}]},e.KeyExchangeService=N([Be({ngZoneName:"ngZone"})],e.KeyExchangeService);var Qi="LBOP";(e.KcLbopErrorCode||(e.KcLbopErrorCode={})).INVALID_PASSPHRASE="INVALID_PASSPHRASE";var Wi,Bi,Vi,Zi,Hi,Yi=k.default(Wi||(Wi=x(["\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"]))),Xi=k.default(Bi||(Bi=x(["\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"]))),zi=k.default(Vi||(Vi=x(["\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"]))),ea=k.default(Zi||(Zi=x(["\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"]))),ta=k.default(Hi||(Hi=x(["\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"]))),na=function(){function t(e,t,n,r,i,a,s,o){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.keyFactory=i,this.keyService=a,this.encryptionService=s,this.passwordService=o,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 F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Xi,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 F(this,void 0,void 0,(function(){var e,r,i;return _(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:zi,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 3:return[2,a.sent().updateLbop]}}))}))},t.prototype.get=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:ea,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 F(this,void 0,void 0,(function(){var e,t,n=this;return _(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:ta})];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 F(n,void 0,void 0,(function(){var n;return _(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 F(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g;return _(this,(function(S){switch(S.label){case 0:if(1024!==b.Slip39Helper.WORD_LIST.length)throw new Y("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=S.sent(),r=function(){n=i.keyFactory.randomChoices(b.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 h=S.sent(),y=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(s,y.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(y.jwk,v)];case 8:return m=S.sent(),[4,this.lrApollo.mutate({mutation:Yi,variables:{input:{cipherMeta:JSON.stringify(m),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(l.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(h),masterKeyId:y.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 F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g;return _(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.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 h=S.sent(),y=t.challenge.serverNonce,[4,this.encryptionService.sign(h,{serverNonce:y,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 V(new B({source:Qi,code:e.KcLbopErrorCode.INVALID_PASSPHRASE,message:"Invalid passphrase."}))}}))}))},t.prototype.verifyContact=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},t.prototype.confirmContact=function(e){return F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return _(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=we).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 F(this,void 0,void 0,(function(){var t,n,r,i;return _(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 ae("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}();na.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new na(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(Me),t.ɵɵinject(a.AuthClass),t.ɵɵinject(we),t.ɵɵinject(Ee),t.ɵɵinject(be),t.ɵɵinject(er))},token:na,providedIn:"root"}),na.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],na.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:Me},{type:a.AuthClass},{type:we},{type:Ee},{type:be},{type:er}]};var ra=function(){function e(){}return e.forRoot=function(r){return{ngModule:e,providers:[{provide:Ke,useValue:r},{provide:a.AuthClass,useValue:M.default},{provide:t.APP_INITIALIZER,useFactory:jt,deps:[Ke,a.AuthClass],multi:!0},{provide:n.APOLLO_OPTIONS,useFactory:Re,deps:[Ke,a.AuthClass]}]}},e}();ra.decorators=[{type:t.NgModule,args:[{imports:[m.HttpClientModule,C.NgIdleKeepaliveModule.forRoot()]}]}];var ia,aa,sa,oa,ca,ua=$e(ia||(ia=x(["\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"]))),pa=$e(aa||(aa=x(["\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"]))),da=$e(sa||(sa=x(["\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"]))),la=$e(oa||(oa=x(["\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"]))),ha=$e(ca||(ca=x(["\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 T(t,e),t.prototype.updateNotification=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateNotificationMutation(e))]}))}))},t.prototype.updateNotificationMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:ua,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.updateAllNotificationsReadState=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateAllNotificationsReadStateMutation(e))]}))}))},t.prototype.updateAllNotificationsReadStateMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:pa,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.debugCreateNotification=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.debugCreateNotificationMutation(e))]}))}))},t.prototype.debugCreateNotificationMutation=function(e){var t;return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,new it({mutation:da,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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.debugDeleteAllNotificationsMutation(e))]}))}))},t.prototype.debugDeleteAllNotificationsMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:la,variables:{input:{receiverId:e.receiverId}}})]}))}))},t.prototype.updateNotificationFeatureState=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateNotificationFeatureStateMutation(e))]}))}))},t.prototype.updateNotificationFeatureStateMutation=function(e){var t;return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,new it({mutation:ha,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=N([Be({ngZoneName:"ngZone"})],e.NotificationService);var ya,fa,va,ma,ga,Sa,Ca,ba,Ia,wa,Ka=$e(ya||(ya=x(["\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"]))),Pa=$e(fa||(fa=x(["\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"]))),ka=$e(va||(va=x(["\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"]))),Ra=$e(ma||(ma=x(["\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"]))),Da=$e(ga||(ga=x(["\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"]))),Ea=$e(Sa||(Sa=x(["\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"]))),Aa=$e(Ca||(Ca=x(["\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"]))),Ma=$e(ba||(ba=x(["\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"]))),Oa=$e(Ia||(Ia=x(["\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.PlanService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return T(t,e),t.prototype.initiateStripePaymentMethodCapture=function(){return this.mutate(this.initiateStripePaymentMethodCaptureMutation())},t.prototype.initiateStripePaymentMethodCaptureMutation=function(){return new it({mutation:Ka,variables:{input:{}}})},t.prototype.completeStripePaymentMethodCapture=function(e){return this.mutate(this.completeStripePaymentMethodCaptureMutation(e))},t.prototype.completeStripePaymentMethodCaptureMutation=function(e){return new it({mutation:Pa,variables:{input:{stripeIntentId:e}}})},t.prototype.setDefaultPaymentMethod=function(e){return this.mutate(this.setDefaultPaymentMethodMutation(e))},t.prototype.setDefaultPaymentMethodMutation=function(e){return new it({mutation:Ra,variables:{input:{paymentMethodId:e}}})},t.prototype.removeDefaultPaymentMethod=function(){return this.mutate(this.removeDefaultPaymentMethodMutation())},t.prototype.removeDefaultPaymentMethodMutation=function(){return new it({mutation:Da,variables:{input:{}}})},t.prototype.issuePlan=function(e){return this.mutate(this.issuePlanMutation(e))},t.prototype.issuePlanMutation=function(e){return new it({mutation:Ea,variables:{input:e}})},t.prototype.removePaymentMethod=function(e){return this.mutate(this.removePaymentMethodMutation(e))},t.prototype.removePaymentMethodMutation=function(e){return new it({mutation:ka,variables:{input:{paymentMethodId:e}}})},t.prototype.cancelPlan=function(e){return this.mutate(this.cancelPlanMutation(e))},t.prototype.cancelPlanMutation=function(e){return new it({mutation:Aa,variables:{input:e}})},t.prototype.changePriceOption=function(e){return this.mutate(this.changePriceOptionMutation(e))},t.prototype.changePriceOptionMutation=function(e){return new it({mutation:Ma,variables:{input:e}})},t.prototype.reactivatePlan=function(e){return this.mutate(this.reactivatePlanMutation(e))},t.prototype.reactivatePlanMutation=function(e){return new it({mutation:Oa,variables:{input:{planId:e}}})},t}(At),e.PlanService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.PlanService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.PlanService,providedIn:"root"}),e.PlanService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.PlanService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.PlanService=N([Be({ngZoneName:"ngZone"})],e.PlanService),function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(wa||(wa={}));var Ta=[wa.Name,wa.Email,wa.Image,wa.Phone,wa.Address],ja=function(){function t(e,t,n){this.sharedContactCardService=e,this.profileService=t,this.api=n}return t.prototype.updateDetails=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return console.log("updateDetails()"),[4,this.fetchMainContactCard()];case 1:return t=r.sent(),[4,this.profileService.updateDetails(null==t?void 0:t.id,null==t?void 0:t.keyId,e)];case 2:return n=r.sent(),[4,this.synchronizeContactCards(e,null==t?void 0:t.fields)];case 3:return r.sent(),[2,n]}}))}))},t.prototype.updateTrustedPartyDetails=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=j(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]}}))}))},t.prototype.synchronizeSharedDetails=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,h;return _(this,(function(y){switch(y.label){case 0:return t=!1,[4,this.fetchMainContactCard()];case 1:if(n=y.sent(),e.name&&(u=this.checkField(e.name,n.fields.name))&&(n.fields.name=u,t=!0),e.email&&(u=this.checkField(e.email,n.fields.email))&&(n.fields.email=u,t=!0),e.image&&(u=this.checkField(e.image,n.fields.image))&&(n.fields.image=u,t=!0),e.phones&&e.phones.length)try{for(r=$(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,n.fields.phone,a.label))&&(n.fields.phone=u,t=!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=$(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,n.fields.address,c.label))&&(n.fields.address=u,t=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(l)throw l.error}}return t?[4,this.profileService.updateDetails(n.id,n.keyId,n.fields)]:[3,3];case 2:y.sent(),y.label=3;case 3:return[2]}}))}))},t.prototype.fetchMainContactCard=function(){var e;return F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.api.query({query:Gn})];case 1:return[2,(t=null===(e=n.sent().contactCards.edges[0])||void 0===e?void 0:e.node)?{id:t.id,keyId:t.key.id,fields:t.cipherDataClearJson}:null]}}))}))},t.prototype.getTrustedParties=function(){return F(this,void 0,void 0,(function(){var e=this;return _(this,(function(t){switch(t.label){case 0:return[4,this.api.query({query:Jn})];case 1:return[2,Mt(t.sent().tps).map((function(t){return e.mapTrustedParty(t)}))]}}))}))},t.prototype.mapTrustedParty=function(t){var n,r,i=t.sharedContactCard.sharedCipherDataClearJson,a=Object.assign(Object.assign({},t.myContactCard.sharedCipherDataClearJson),{id:t.myContactCard.id,ownedKeyId:t.myContactCard.ownerKey.id,sharedKeyId:t.myContactCard.sharedKey.id});return{id:t.id,type:e.TrustedPartyType.User,hasScenarios:!!t.sharedScenarios.edges.length,hasSharedVault:!!t.theirItems.directories.edges.length,name:null===(n=null==i?void 0:i.name)||void 0===n?void 0:n.name,details:i,mySharedDetails:a,userSharedKey:t.currentUserSharedKey.userSharedKey,username:t.other.username,features:{sharedVault:{hasAccess:"access"===((null===(r=t.other.features)||void 0===r?void 0:r.shareVault)||["noaccess"])[0]}}}},t.prototype.synchronizeContactCards=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return _(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.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=$(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]}}))}))},t.prototype.getChanges=function(e,t){var n,r,i,a,s,o=[];try{for(var c=$(Ta),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?E.default(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 h=(i=void 0,$(d.values)),y=h.next();!y.done;y=h.next()){l(y.value)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=h.return)&&a.call(h)}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},t.prototype.synchronizeSharedContactCard=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return _(this,(function(h){switch(h.label){case 0:n=!1,r=function(t){switch(t.field){case wa.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case wa.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];E.default(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=$(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=j(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:h.sent(),h.label=2;case 2:return[2]}}))}))},t.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!E.default(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},t}();ja.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ja(t.ɵɵinject(Tn),t.ɵɵinject(Qn),t.ɵɵinject(e.ɵg))},token:ja,providedIn:"root"}),ja.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ja.ctorParameters=function(){return[{type:Tn},{type:Qn},{type:e.ɵg}]};var Na=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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(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"),F(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,h,y,f,v,m;return _(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 h=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:h}).toPromise()];case 10:return y=g.sent(),f={},y.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(y.id),user_pre_sign_up_token:String(y.pre_sign_up_token)}})];case 11:return[2,{username:(m=g.sent()).user.getUsername(),userId:y.id,preSignUpToken:y.pre_sign_up_token,userSub:m.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return F(this,void 0,void 0,(function(){var t;return _(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}();Na.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Na(t.ɵɵinject(Ke),t.ɵɵinject(a.AuthClass),t.ɵɵinject(m.HttpClient),t.ɵɵinject(we),t.ɵɵinject(be),t.ɵɵinject(er))},token:Na,providedIn:"root"}),Na.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Na.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:a.AuthClass},{type:m.HttpClient},{type:we},{type:be},{type:er}]};var Fa,_a,$a,La=function(){},Ua=$e(Fa||(Fa=x(["\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"]))),xa=$e(_a||(_a=x(["\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"]))),qa=$e($a||($a=x(["\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 T(t,e),t.prototype.createReminder=function(e){return this.mutate(this.createReminderMutation(e))},t.prototype.createReminderMutation=function(e){var t;return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,new it({mutation:Ua,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 F(this,void 0,void 0,(function(){return _(this,(function(r){return[2,new it({mutation:xa,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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:qa,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=N([Be({ngZoneName:"ngZone"})],e.ReminderService);var Ja,Ga,Qa,Wa,Ba,Va,Za,Ha,Ya,Xa,za=$e(Ja||(Ja=x(["\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"]))),es=$e(Ga||(Ga=x(["\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"]))),ts=$e(Qa||(Qa=x(["\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"]))),ns=$e(Wa||(Wa=x(["\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"]))),rs=$e(Ba||(Ba=x(["\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"]))),is=$e(Va||(Va=x(["\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"]))),as=$e(Za||(Za=x(["\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"]))),ss=$e(Ha||(Ha=x(["\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"]))),os=$e(Ya||(Ya=x(["\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"]))),cs=$e(Xa||(Xa=x(["\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"])));e.ɵm=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 T(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.sharedKey.id},t}(cr),e.ɵm.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵm(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵm,providedIn:"root"}),e.ɵm.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵm.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵm=N([Be({ngZoneName:"ngZone"})],e.ɵm);var us,ps,ds=$e(us||(us=x(["\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 receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\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 file {\n id\n keyId\n }\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 receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\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 file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),ls=$e(ps||(ps=x(["\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 receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n }\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 assemblyKeyId\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 receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n }\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 assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));function hs(){throw new H("claimId does not match with the current claimId of the scenario")}function ys(){throw new ee("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.itemService=i,o.assemblyController=a,o.encryptionService=s,o.prepareAddReceiverDirectory=o.prepareReceiverDirectory,o.prepareUpdateReceiverDirectory=o.prepareReceiverDirectory,o.prepareAddReceiverFile=o.prepareReceiverFile,o.prepareUpdateReceiverFile=o.prepareReceiverFile,o}return T(n,t),n.prototype.createScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createScenarioMutation(e))]}))}))},n.prototype.createScenarioMutation=function(e){return F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.prepareCreateScenarioMutation(e)];case 1:return t=n.sent(),[2,new it({mutation:za,variables:{input:t}})]}}))}))},n.prototype.updateScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateScenarioMutation(e))]}))}))},n.prototype.updateScenarioMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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 it({mutation:es,variables:{input:n}})]}}))}))},n.prototype.resetScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.resetScenarioMutation(e))]}))}))},n.prototype.resetScenarioMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i;return _(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=Mt(n.subAssemblies).map((function(e){var t=Mt(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 it({mutation:es,variables:{input:i}})]}}))}))},n.prototype.deleteScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.lrGraphQL.lrMutate(this.deleteScenarioMutation(e))]}))}))},n.prototype.deleteScenarioMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:ts,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.createClaim=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createClaimMutation(e))]}))}))},n.prototype.createClaimMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:ns,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.cancelClaim=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.cancelClaimMutation(e))]}))}))},n.prototype.cancelClaimMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:rs,variables:{input:{claimId:e}}})]}))}))},n.prototype.rejectClaim=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.mutate(this.rejectClaimMutation(e,t))]}))}))},n.prototype.rejectClaimMutation=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return[4,this.prepareRejectClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=st).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.approveClaim=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.mutate(this.approveClaimMutation(e,t))]}))}))},n.prototype.approveClaimMutation=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return[4,this.prepareApproveClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=st).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.receiveClaim=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.mutate(this.receiveClaim2Mutation(e,t))]}))}))},n.prototype.receiveClaim2Mutation=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return n=it.bind,r={mutation:ss},i={},[4,this.prepareReceiveClaim2(e,t)];case 1:return[2,new(n.apply(it,[void 0,(r.variables=(i.input=a.sent(),i),r)]))]}}))}))},n.prototype.debugExpireClaim=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.debugExpireClaimMutation(e))]}))}))},n.prototype.debugExpireClaimMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:os,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.getScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.query({query:ds,variables:{scenarioId:e}})]}))}))},n.prototype.getSharedScenario=function(e,t){return F(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return[4,this.query({query:ls,variables:{scenarioId:e}})];case 1:return n=r.sent(),t&&n.sharedScenario.sharedClaim.id!==t&&hs(),[2,n]}}))}))},n.prototype.getParticipantTpsKeys=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=e.map((function(e){return e.tpId})),n=Mt,[4,this.lrGraphQL.query({query:or,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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p=this;return _(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,inactiveSeconds:e.inactiveSeconds,createAssembly:r,createReceivers:c,createClaimants:u}]}}))}))},n.prototype.prepareUpdateScenario=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I=this;return _(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,F(I,void 0,void 0,(function(){var r;return _(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 I.prepareCreateReceiver(e,n)})))]:[3,7];case 6:p=w.sent(),w.label=7;case 7:return u=p,d=Mt(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 I.prepareUpdateReceiver(e,n,t)})))]:[3,9];case 8:return h=w.sent(),[3,10];case 9:h=[],w.label=10;case 10:return l=h,e.updateAssembly?(y=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(y,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 I.prepareCreateClaimant(e)})))]:[3,14];case 13:g=w.sent(),w.label=14;case 14:return m=g,S=Mt(t.claimants),(b=e.updateClaimants)?[4,Promise.all(e.updateClaimants.map((function(e){var t=S.find((function(t){return t.tp.id===e.tpId}));return I.prepareUpdateClaimant(e,t.sharedKey.id)})))]:[3,16];case 15:b=w.sent(),w.label=16;case 16:return C=b,[2,{scenarioId:e.scenarioId,enabled:e.enabled,inactiveSeconds:e.inactiveSeconds,updateAssembly:r,createReceivers:u,updateReceivers:l,deleteReceivers:e.deleteReceivers,createClaimants:m,updateClaimants:C,deleteClaimants:e.deleteClaimants}]}}))}))},n.prototype.prepareReceiverItem=function(t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d;return _(this,(function(l){switch(l.label){case 0:return n=t.receiverItemOptions,r=t.receiverSharedKey,i=t.assemblyKey,a=t.directory,s=t.file,function(e){var t=Object.keys(e);if(t.length<2)throw new Y("You must provide 2 or more fields in the argument.");if(1!=t.filter((function(t){return null!=e[t]})).length)throw new Y("You must provide exactly one argument that != null.")}({directory:a,file:s}),(o=n.accessRole)!=e.AccessRoleChoice.DENY?[3,1]:(d={accessRole:o,itemKeyId:null,wrappedItemKey:null,sharedCipherData:null},a?[2,Object.assign(Object.assign({},d),{directoryId:a.id})]:[2,Object.assign(Object.assign({},d),{fileId:s.id})]);case 1:return c=void 0,a?[4,this.itemService.getDirectoryKey(a.id,a.keyId)]:[3,3];case 2:return c=l.sent(),[3,5];case 3:return[4,this.itemService.getFileKey(s.id,s.keyId)];case 4:c=l.sent(),l.label=5;case 5:return[4,this.keyGraph.encryptToString(r,c.jwk.toJSON(!0))];case 6:return u=l.sent(),[4,this.keyGraph.encryptToString(r,n.sharedCipherDataClearJson||"")];case 7:return p=l.sent(),[4,this.keyGraph.encryptToString(i,u)];case 8:return u=l.sent(),d={accessRole:o,itemKeyId:c.id,wrappedItemKey:u,sharedCipherData:p},a?[2,Object.assign(Object.assign({},d),{directoryId:a.id})]:[2,Object.assign(Object.assign({},d),{fileId:s.id})];case 9:return[2]}}))}))},n.prototype.prepareReceiverDirectory=function(e,t,n){return F(this,void 0,void 0,(function(){return _(this,(function(r){return[2,this.prepareReceiverItem({receiverItemOptions:e,receiverSharedKey:t,assemblyKey:n,directory:{id:e.directoryId,keyId:e.directoryKeyId}})]}))}))},n.prototype.prepareReceiverFile=function(e,t,n){return F(this,void 0,void 0,(function(){return _(this,(function(r){return[2,this.prepareReceiverItem({receiverItemOptions:e,receiverSharedKey:t,assemblyKey:n,file:{id:e.fileId,keyId:e.fileKeyId}})]}))}))},n.prototype.prepareCreateReceiver=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u=this;return _(this,(function(p){switch(p.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return n=p.sent(),r=n.sharedKey,i=n.mutationInput,(s=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return u.prepareAddReceiverDirectory(e,r.key,t)})))]:[3,3];case 2:s=p.sent(),p.label=3;case 3:return a=s,(c=e.addFiles)?[4,Promise.all(e.addFiles.map((function(e){return u.prepareAddReceiverFile(e,r.key,t)})))]:[3,5];case 4:c=p.sent(),p.label=5;case 5:return o=c,[2,Object.assign(Object.assign({},i),{addDirectories:a,addFiles:o})]}}))}))},n.prototype.prepareUpdateReceiver=function(e,t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m=this;return _(this,(function(g){switch(g.label){case 0:return r=n.sharedKey.id,i=e.deleteDirectories||[],a=e.updateDirectories||[],s=e.deleteFiles||[],o=e.updateFiles||[],Mt(n.receiverItems.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,directoryKeyId:e.directory.keyId,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),Mt(n.receiverItems.receiverFiles).forEach((function(e){s.includes(e.file.id)||o.find((function(t){return t.fileId===e.file.id}))||o.push({accessRole:e.accessRole,fileId:e.file.id,fileKeyId:e.file.keyId,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),[4,this.prepareUpdateParticipant(e,r)];case 1:return c=g.sent(),u=c.sharedKey,p=c.mutationInput,(l=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return m.prepareAddReceiverDirectory(e,u,t)})))]:[3,3];case 2:l=g.sent(),g.label=3;case 3:return d=l,(y=e.addFiles)?[4,Promise.all(e.addFiles.map((function(e){return m.prepareAddReceiverFile(e,u,t)})))]:[3,5];case 4:y=g.sent(),g.label=5;case 5:return h=y,[4,Promise.all(a.map((function(e){return m.prepareUpdateReceiverDirectory(e,u,t)})))];case 6:return f=g.sent(),[4,Promise.all(o.map((function(e){return m.prepareUpdateReceiverFile(e,u,t)})))];case 7:return v=g.sent(),[2,Object.assign(Object.assign({},p),{addDirectories:d,addFiles:h,updateDirectories:f,updateFiles:v,deleteDirectories:e.deleteDirectories,deleteFiles:e.deleteFiles})]}}))}))},n.prototype.prepareExistingReceiver=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){return n=Mt(e.receiverItems.receiverDirectories).map((function(e){var t=e.accessRole,n=e.sharedCipherDataClearJson,r=e.directory;return{accessRole:t,sharedCipherDataClearJson:n,directoryId:r.id,directoryKeyId:r.keyId}})),r=Mt(e.receiverItems.receiverFiles).map((function(e){var t=e.accessRole,n=e.sharedCipherDataClearJson,r=e.file;return{accessRole:t,sharedCipherDataClearJson:n,fileId:r.id,fileKeyId:r.keyId}})),[2,this.prepareUpdateReceiver({tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,updateDirectories:n,updateFiles:r},t,e)]}))}))},n.prototype.prepareExistingReceivers=function(e,t){return F(this,void 0,void 0,(function(){var n=this;return _(this,(function(r){return[2,Promise.all(e.map((function(e){return n.prepareExistingReceiver(e,t)})))]}))}))},n.prototype.prepareCreateParticipant=function(e){return F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this.prepareUpdateParticipant(e,t)];case 1:return[2,n.sent().mutationInput]}}))}))},n.prototype.prepareReceiveClaim2=function(t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o;return _(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&&ys(),i=Mt(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),[4,this.keyGraph.getKey(r.asReceiver.sharedKey.id)];case 3:return s=c.sent(),[4,this.keyGraph.encryptToString(s,a.toJSON(!0))];case 4:return o=c.sent(),[2,{scenarioClaimId:n,sharedKeyWrappedAssemblyKey:o,sharedKeyId:s.id,assemblyKeyId:r.sharedClaim.asClaimReceiver.assemblyKeyId}]}}))}))},n.prototype.recoverAssemblyKey=function(e){return F(this,void 0,void 0,(function(){var t,n=this;return _(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 F(this,void 0,void 0,(function(){return _(this,(function(r){switch(r.label){case 0:return[4,this.getSharedScenario(e,t)];case 1:return[2,Mt(r.sent().sharedScenario.sharedClaim.claim.asClaimApprovers).filter((function(e){return e.state===n}))]}}))}))},n.prototype.prepareApproveClaimMutations=function(t,n){return F(this,void 0,void 0,(function(){var r=this;return _(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 F(r,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:as},r={},[4,this.prepareApproveClaim(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))}))]}}))}))},n.prototype.prepareApproveClaim=function(e){return F(this,void 0,void 0,(function(){var t,n=this;return _(this,(function(r){switch(r.label){case 0:return[4,Promise.all(Mt(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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var r=this;return _(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 F(r,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:is,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(Ae),t.ɵɵinject(e.ItemService),t.ɵɵinject(e.ɵm),t.ɵɵinject(be))},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:Ae},{type:e.ItemService},{type:e.ɵm},{type:be}]},e.ScenarioService=N([Be({ngZoneName:"ngZone"})],e.ScenarioService);var fs,vs=$e(fs||(fs=x(["\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 T(t,e),t.prototype.getConfig=function(){return F(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return null!=this.serverConfig?[3,2]:(e=this,[4,this.query({query:vs,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=N([Be({ngZoneName:"ngZone"})],e.ServerConfigService);var ms,gs,Ss,Cs,bs=$e(ms||(ms=x(["\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}"]))),Is=$e(gs||(gs=x(["\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}"]))),ws=$e(Ss||(Ss=x(["\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}"]))),Ks=$e(Cs||(Cs=x(["\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 F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:ws,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Ks,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 F(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y,f,v,m;return _(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(),h=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 9:return d=h.apply(l,[g.sent()]),v=(f=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 10:return y=v.apply(f,[g.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 11:return m=g.sent(),[2,new it({mutation:bs,variables:{input:{id:t,ownerCipherData:m,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:y}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return F(this,void 0,void 0,(function(){var e,i,a=this;return _(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 it({mutation:Is,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(Ee),t.ɵɵinject(Ae),t.ɵɵinject(be),t.ɵɵinject(e.ɵg))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:t.NgZone},{type:Ee},{type:Ae},{type:be},{type:e.ɵg}]},e.SharedContactCard2Service=N([Be({ngZoneName:"ngZone"})],e.SharedContactCard2Service);var Ps,ks,Rs,Ds,Es,As=$e(Ps||(Ps=x(["\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}"]))),Ms=$e(ks||(ks=x(["\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"])),As),Os=$e(Rs||(Rs=x(["\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"])),As),Ts=($e(Ds||(Ds=x(["\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}"]))),$e(Es||(Es=x(["\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}"]))));e.ɵn=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return T(t,e),t.prototype.getReset=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Ts})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.getSharedResets=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Ms})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},t.prototype.getSharedReset=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Os,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},t}(At),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=N([Be({ngZoneName:"ngZone"})],e.ɵn),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 T(n,t),n.prototype.activeRequestOrRaise=function(t){var n=t.sharedRequest.claim.state;if(n!==e.TpAssemblyState.CLAIMED)throw new ee("Claim is already in "+n+" state.")},n.prototype.rejectRequest=function(e){return this.mutate(this.rejectRequestMutation(e))},n.prototype.rejectRequestMutation=function(t){return F(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=r.sent(),this.activeRequestOrRaise(n),[2,st.create(n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})).map((function(e){return new it({mutation:Ar,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},n.prototype.approveRequest=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){var n,r,a,s,o,c=this;return _(this,(function(u){switch(u.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=u.sent(),this.activeRequestOrRaise(n),[4,i.JWK.asKey(JSON.parse(n.sharedRequest.pxk.pbk))];case 2:return r=u.sent(),a=n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})),o=(s=st).create,[4,Promise.all(a.map((function(e){return F(c,void 0,void 0,(function(){var t,n,i=this;return _(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 F(i,void 0,void 0,(function(){var n,i;return _(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 it({mutation:Er,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(be),t.ɵɵinject(e.ɵn))},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:be},{type:e.ɵn}]},e.TpPasswordResetRequestService=N([Be({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService);function js(){!function(e){if(!e)throw new H("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 T(t,e),t.prototype.verifyEmailContact=function(e){return F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return _(this,(function(p){switch(p.label){case 0:return js(),[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(Ke),t.ɵɵinject(we),t.ɵɵinject(be),t.ɵɵinject(er),t.ɵɵinject(m.HttpClient),t.ɵɵinject(a.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:[Ke]}]},{type:we},{type:be},{type:er},{type:m.HttpClient},{type:a.AuthClass}]},e.TpPasswordResetUserService=N([Be({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=tr,a}return T(t,e),t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new it({mutation:Pr})},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new it({mutation:Or})},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 F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.assemblyController.prepareCreate(e)];case 1:return t=n.sent().mutationInput,[2,new it({mutation:Mr,variables:{input:{assembly:Object.assign({},t)}}})]}}))}))},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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 it({mutation:Tr,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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:cs,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.ɵn),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.ɵn},{type:e.ɵi}]},e.TpPasswordResetService=N([Be({ngZoneName:"ngZone"})],e.TpPasswordResetService);var Ns,Fs,_s,$s,Ls,Us,xs,qs,Js,Gs,Qs,Ws,Bs,Vs,Zs,Hs=$e(Ns||(Ns=x(["\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"]))),Ys=$e(Fs||(Fs=x(["\nmutation CreateDirectoryShareMutation($input: CreateDirectoryShareInput!) {\n createDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation CreateDirectoryShareMutation($input: CreateDirectoryShareInput!) {\n createDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),Xs=$e(_s||(_s=x(["\nmutation CreateFileShareMutation($input: CreateFileShareInput!) {\n createFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation CreateFileShareMutation($input: CreateFileShareInput!) {\n createFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),zs=$e($s||($s=x(["\nmutation UpdateDirectoryShareMutation($input: UpdateDirectoryShareInput!) {\n updateDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation UpdateDirectoryShareMutation($input: UpdateDirectoryShareInput!) {\n updateDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),eo=$e(Ls||(Ls=x(["\nmutation UpdateFileShareMutation($input: UpdateFileShareInput!) {\n updateFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation UpdateFileShareMutation($input: UpdateFileShareInput!) {\n updateFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),to=$e(Us||(Us=x(["\nmutation DeleteDirectoryShareMutation($input: DeleteDirectoryShareInput!) {\n deleteDirectoryShare(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteDirectoryShareMutation($input: DeleteDirectoryShareInput!) {\n deleteDirectoryShare(input: $input) {\n id\n }\n}\n"]))),no=$e(xs||(xs=x(["\nmutation DeleteFileShareMutation($input: DeleteFileShareInput!) {\n deleteFileShare(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteFileShareMutation($input: DeleteFileShareInput!) {\n deleteFileShare(input: $input) {\n id\n }\n}\n"]))),ro=$e(qs||(qs=x(["\nmutation CompleteDetachedDirectoryShareMutation($input: CompleteDetachedDirectoryShareInput!) {\n completeDetachedDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation CompleteDetachedDirectoryShareMutation($input: CompleteDetachedDirectoryShareInput!) {\n completeDetachedDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),io=$e(Js||(Js=x(["\nmutation CompleteDetachedFileShareMutation($input: CompleteDetachedFileShareInput!) {\n completeDetachedFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation CompleteDetachedFileShareMutation($input: CompleteDetachedFileShareInput!) {\n completeDetachedFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),ao=$e(Gs||(Gs=x(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),so=$e(Qs||(Qs=x(["\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"]))),oo=$e(Ws||(Ws=x(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"]))),co=$e(Bs||(Bs=x(["\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"]))),uo=$e(Vs||(Vs=x(["\nquery DirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n shareType\n }\n}\n"],["\nquery DirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n shareType\n }\n}\n"]))),po=$e(Zs||(Zs=x(["\nquery FileShareItemIdQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n shareType\n }\n}\n"],["\nquery FileShareItemIdQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n shareType\n }\n}\n"])));e.TrustedPartyService=function(t){function n(e,n,r,i,a,s,o){var c=t.call(this,n)||this;return c.ngZone=e,c.injector=n,c.keyGraph=r,c.itemService=i,c.keyService=a,c.keyFactory=s,c.encryptionService=o,c}return T(n,t),n.prototype.deleteTp=function(e){return this.mutate(this.deleteTpMutation(e))},n.prototype.deleteTpMutation=function(e){return new it({mutation:Hs,variables:{input:{id:e}}})},n.prototype.createDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createDirectoryShareMutation(e))]}))}))},n.prototype.createDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:Ys},[4,this.prepareCreateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.createFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createFileShareMutation(e))]}))}))},n.prototype.createFileShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:Xs},[4,this.prepareCreateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.prepareCreateItemShareMutation=function(t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h,y,f=this;return _(this,(function(v){switch(v.label){case 0:if(n=t.itemId,r=t.itemKeyId,i=t.tpId,a=t.tpSharedKeyId,s=t.accessRole,o=t.isDirectory,c=t.shareType,u=t.plainMetaJson,p=t.item||{id:n,keyId:r},d=u&&JSON.stringify(u),s==e.AccessRoleChoice.DENY){if(p.keyId||a)throw new H("If accessRole is AccessRoleChoice.DENY, must not specify any of itemId, itemKeyId, or tpSharedKeyId parameters");return[2,{input:{itemId:p.id,tpId:i,accessRole:s,itemKeyId:null,wrappingKeyId:null,wrappedItemKey:null,shareType:c,plainMeta:d}}]}return[4,this.keyGraph.getKey(p.keyId,(function(){return o?f.itemService.getDirectoryKeyId(p.id):f.itemService.getFileKeyId(p.id)}))];case 1:return l=v.sent(),[4,this.keyGraph.getKey(a,(function(){return f.getTpCurrentUserSharedKey(i).then((function(e){return e.sharedKey.id}))}))];case 2:return h=v.sent(),[4,this.keyGraph.wrapKey(h,l.jwk)];case 3:return y=v.sent(),[2,{input:{itemId:p.id,tpId:i,accessRole:s,itemKeyId:l.id,wrappingKeyId:h.id,wrappedItemKey:y,shareType:c,plainMeta:d}}]}}))}))},n.prototype.updateDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateDirectoryShareMutation(e))]}))}))},n.prototype.updateDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:zs},[4,this.prepareUpdateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.updateDetachedDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateDetachedDirectoryShareMutation(e))]}))}))},n.prototype.updateDetachedDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:zs},[4,this.prepareUpdateDetachedItemShareMutation(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.updateFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateFileShareMutation(e))]}))}))},n.prototype.updateFileShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:eo},[4,this.prepareUpdateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.updateDetachedFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateDetachedFileShareMutation(e))]}))}))},n.prototype.updateDetachedFileShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:eo},[4,this.prepareUpdateDetachedItemShareMutation(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.getDirectoryShare=function(e){return this.lrGraphQL.query({query:uo,variables:{id:e}})},n.prototype.getFileShare=function(e){return this.lrGraphQL.query({query:po,variables:{id:e}})},n.prototype.prepareUpdateItemShareMutation=function(t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m=this;return _(this,(function(g){switch(g.label){case 0:if(n=t.itemShareId,r=t.accessRole,i=t.isDirectory,a=t.itemId,s=t.itemKeyId,o=t.tpId,c=t.tpSharedKeyId,u=t.plainMetaJson,p=t.item||{id:a,keyId:s},d=u&&JSON.stringify(u),null==r||r==e.AccessRoleChoice.DENY){if(p.id||p.keyId||o||c)throw new H("If accessRole is AccessRoleChoice.DENY, must not specify any of itemId, itemKeyId, tpId, or tpSharedKeyId parameters");return[2,{input:{id:n,accessRole:r,plainMeta:d}}]}return h=function(){return F(m,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return l?[3,5]:i?[4,this.getDirectoryShare(n)]:[3,2];case 1:return l=t.sent().directoryShare,[3,4];case 2:return[4,this.getFileShare(n)];case 3:l=t.sent().fileShare,t.label=4;case 4:if(l.shareType==e.ShareTypeChoice.DETACHED)throw new H("Use updateDetachedDirectoryShare() or updateDetachedFileShare() to updated DETACHED shares.");t.label=5;case 5:return[2,l]}}))}))},[4,this.keyGraph.getKey(p.keyId,(function(){return F(m,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return(t=p.id)?[3,2]:[4,h()];case 1:t=n.sent().item.id,n.label=2;case 2:return e=t,i?[2,this.itemService.getDirectoryKeyId(e)]:[2,this.itemService.getFileKeyId(e)]}}))}))}))];case 1:return y=g.sent(),[4,this.keyGraph.getKey(c,(function(){return F(m,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return(t=o)?[3,2]:[4,h()];case 1:t=n.sent().tp.id,n.label=2;case 2:return e=t,[4,this.getTpCurrentUserSharedKey(e)];case 3:return[2,n.sent().sharedKey.id]}}))}))}))];case 2:return f=g.sent(),[4,this.keyGraph.wrapKey(f,y.jwk)];case 3:return v=g.sent(),[2,{input:{id:n,accessRole:r,itemKeyId:y.id,wrappingKeyId:f.id,wrappedItemKey:v,plainMeta:d}}]}}))}))},n.prototype.prepareUpdateDetachedItemShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){return t=e.itemShareId,n=e.accessRole,r=e.plainMetaJson,[2,{input:{id:t,accessRole:n,plainMeta:r&&JSON.stringify(r)}}]}))}))},n.prototype.deleteDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.deleteDirectoryShareMutation(e))]}))}))},n.prototype.deleteDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:to,variables:{input:{id:e}}})]}))}))},n.prototype.deleteFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.deleteFileShareMutation(e))]}))}))},n.prototype.deleteFileShareMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:no,variables:{input:{id:e}}})]}))}))},n.prototype.completeDetachedDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.completeDetachedDirectoryShareMutation(e))]}))}))},n.prototype.completeDetachedDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:ro},[4,this.prepareCompleteDetachedItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.completeDetachedFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.completeDetachedFileShareMutation(e))]}))}))},n.prototype.completeDetachedFileShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:io},[4,this.prepareCompleteDetachedItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.prepareCompleteDetachedItemShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return _(this,(function(c){switch(c.label){case 0:return t=e.itemShareId,n=e.itemKeyId,r=e.isDirectory,[4,this.keyGraph.getKey(n,(function(){return r?o.itemService.getDirectoryKeyIdFromDirectoryShare(t):o.itemService.getFileKeyIdFromFileShare(t)}))];case 1:return i=c.sent(),a=this.keyService.currentRootKey,[4,this.keyGraph.wrapKey(a,i.jwk)];case 2:return s=c.sent(),[2,{input:{id:t,keyId:i.id,wrappingKeyId:a.id,wrappedKey:s}}]}}))}))},n.prototype.requestMkReshareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(this,(function(o){switch(o.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if((t=o.sent()).mkSharedKey)throw new ee("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 it({mutation:ao,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()]}}))}))},n.prototype.respondMkReshare=function(e){return F(this,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,p,d;return _(this,(function(l){switch(l.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if(!(t=l.sent()).mkSharedKey)throw new ee("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,i.JWK.asKey(r.pbk)];case 4:return a=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=[a],[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 it({mutation:so,variables:{input:{tpId:e,mkSharedKeyId:s.id,mkReshareResponseCipher:c}}})]}}))}))},n.prototype.completeMkReshare=function(e){return F(this,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,p,d,l;return _(this,(function(h){switch(h.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=h.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=h.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=h.sent(),o=(s=this.encryptionService).decrypt,c=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,o.apply(s,c.concat([h.sent()]))];case 5:return a=h.sent(),p={id:a.mkSharedKey.id},[4,i.JWK.asKey(a.mkSharedKey.jwk)];case 6:return p.jwk=h.sent(),u=p,d=this.keyService.currentMasterKey,[4,this.encryptionService.encryptToString(d.jwk,u.jwk.toJSON(!0))];case 7:return l=h.sent(),[2,new it({mutation:oo,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:u.id,mkWrappedMkSharedKey:l}}})]}}))}))},n.prototype.getTpCurrentUserSharedKey=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:co,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},n}(At),e.TrustedPartyService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TrustedPartyService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Ae),t.ɵɵinject(e.ItemService),t.ɵɵinject(Ee),t.ɵɵinject(we),t.ɵɵinject(be))},token:e.TrustedPartyService,providedIn:"root"}),e.TrustedPartyService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TrustedPartyService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Ae},{type:e.ItemService},{type:Ee},{type:we},{type:be}]},e.TrustedPartyService=N([Be({ngZoneName:"ngZone"})],e.TrustedPartyService);var lo=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return F(this,void 0,void 0,(function(){var e;return _(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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var e,t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=L.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 H("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return F(this,void 0,void 0,(function(){var t;return _(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}();lo.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new lo(t.ɵɵinject(a.AuthClass))},token:lo,providedIn:"root"}),lo.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],lo.ctorParameters=function(){return[{type:a.AuthClass}]};var ho,yo,fo,vo=k.default(ho||(ho=x(["\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"]))),mo=k.default(yo||(yo=x(["\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"]))),go=k.default(fo||(fo=x(["\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"]))),So=function(){function e(e){this.lrApollo=e}return e.prototype.requestUserDelete=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:vo,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:mo,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),F(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:go,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();So.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new So(t.ɵɵinject(Me))},token:So,providedIn:"root"}),So.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],So.ctorParameters=function(){return[{type:Me}]},e.ApiContactCard=Sn,e.ApiCurrentUser=gn,e.ApproveScenarioClaimMutation=as,e.ApproveTpPasswordResetRequestMutation=Er,e.ArchiveDirectoryMutation=Ci,e.ArchiveFileMutation=bi,e.BeginDeleteChildItemLinksWindowMutation=ki,e.CancelKeyExchangeMutation=un,e.CancelScenarioClaimMutation=rs,e.CancelTpPasswordResetRequestMutation=Pr,e.CancelUserDeleteMutation=mo,e.ChangeDirectoryParentsMutation=Ki,e.ChangeFileParentsMutation=Pi,e.CompleteKeyExchangeOtkMutation=hn,e.CompleteTpPasswordResetRequestMutation=Dr,e.ContactCardAddress=bn,e.ContactCardName=Cn,e.ContactCardsQuery=Gn,e.CreateContactCardMutation=xn,e.CreateDirectoryMutation=hi,e.CreateFileMutation=vi,e.CreateLbopQuery=Yi,e.CreateScenarioClaimMutation=ns,e.CreateScenarioMutation=za,e.CreateTpAssemblyKeyChallengeMutation=kr,e.CreateTpPasswordResetMutation=Mr,e.CurrentUserKey=mn,e.CurrentUserQuery=Un,e.CurrentUserSharedKeyQuery2=yn,e.DebugExpireScenarioClaimMutation=os,e.DebugExpireTpPasswordResetRequestMutation=cs,e.DeclineKeyExchangeMutation=pn,e.DefaultProcessorOptions=Ve,e.DeleteDirectoryMutation=fi,e.DeleteFileMutation=Si,e.DeleteLbopQuery=Xi,e.DeleteScenarioMutation=ts,e.DeleteTpPasswordResetMutation=Or,e.DirectoryQuery=Qe,e.ERROR_SOURCE=Qi,e.Features=vn,e.FetchKeyGraphField=Ge,e.FileUploadService=Qr,e.GetOwnedContactCardKeyIdsQuery=ws,e.GetReceivedContactCardKeyIdQuery=Ks,e.IdleService=Nt,e.InitiateKeyExchangeOtkMutation=dn,e.KC_CONFIG=Ke,e.KcAuthException=Z,e.KcBadArgumentException=H,e.KcBadLogicException=Y,e.KcBadRequestException=X,e.KcBadSignatureException=z,e.KcBadStateException=ee,e.KcBadTimeSyncException=te,e.KcCodeMismatchException=ne,e.KcConcurrentAccessException=re,e.KcEncryptionException=ie,e.KcError=B,e.KcException=V,e.KcInternalErrorException=ae,e.KcLockedException=se,e.KcNotFoundException=oe,e.KcSuspiciousOperationException=ce,e.KcUnsupportedException=ue,e.KeyExchangeFields=rn,e.KeyExchangeQuery2=on,e.KeyExchangeTokenQuery2=cn,e.KeyExchangesQuery2=sn,e.KeyGraphField=Je,e.KeyGraphFragment=qe,e.LbopQuery=ea,e.LbopService=na,e.LbopsQuery=ta,e.LifeReadyModule=ra,e.LoginHistoryQuery=go,e.LrApolloService=Me,e.LrGraphQLService=e.ɵg,e.LrMergedMutation=st,e.LrMutation=it,e.LrMutationBase=rt,e.LrService=At,e.MainContactCardFields=wn,e.MainContactCardPlainFields=Kn,e.MainContactCardProperty=In,e.OwnerPlainDataJson=Gr,e.PasswordCheck=zn,e.PasswordService=er,e.PersistService=De,e.PreCompleteTpPasswordResetRequestMutation=Rr,e.ProfileDetailsService=ja,e.ProfileService=Qn,e.ReceiveScenarioClaimMutation=ss,e.RegisterResult=La,e.RegisterService=Na,e.RejectScenarioClaimMutation=is,e.RejectTpPasswordResetRequestMutation=Ar,e.RequestUserDeleteMutation=vo,e.RespondKeyExchangeOtkMutation=ln,e.RevertFileMutation=gi,e.ServerTimeQuery=me,e.SetDirectoryConfidentialMutation=Ei,e.SetFileConfidentialMutation=Di,e.SharedTrustedPartyDetails=kn,e.SharedVaultFeature=Dn,e.TPFeatures=Rn,e.TempDirectoryQuery=Ri,e.TimeService=ge,e.TrustedPartiesQuery=Jn,e.TrustedParty=An,e.TrustedPartyDetails=Pn,e.TrustedPartyProperties=Ln,e.TwoFactorService=lo,e.UnarchiveDirectoryMutation=Ii,e.UnarchiveFileMutation=wi,e.UpdateContactCardMutation=qn,e.UpdateDirectoryMutation=yi,e.UpdateFileMutation=mi,e.UpdateLbopQuery=zi,e.UpdateOwnedContactCardMutation=bs,e.UpdateReceivedContactCardMutation=Is,e.UpdateScenarioMutation=es,e.UpdateTpPasswordResetMutation=Tr,e.UserService=So,e.UserSharedKeyFields=an,e.WebCryptoService=Ie,e.awsFetch=Tt,e.configureAmplifyAuth=jt,e.configureApollo=Re,e.fragmentSpreadAstSelection=nt,e.gqlTyped=$e,e.handleApolloError=Q,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.httpOptions=ke,e.mapEdges=Mt,e.processConnection=Ze,e.throwClaimIdMismatch=hs,e.throwClaimNotApproved=ys,e.toIdKeyPair=function(e){return{id:e.id,keyId:e.keyId}},e.ɵa=Ae,e.ɵb=be,e.ɵc=Ee,e.ɵd=we,e.ɵe=At,e.ɵf=Be,e.ɵh=Bt,e.ɵj=cr,e.ɵk=Mn,e.ɵl=Tn,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("node-jose"),require("@aws-amplify/auth/lib-esm/Auth"),require("graphql-tag"),require("moment"),require("lodash/cloneDeep"),require("lodash/isEqual"),require("lodash/keyBy"),require("lodash/omit"),require("@apollo/client/core"),require("@apollo/client/link/context"),require("@apollo/client/link/retry"),require("ngx-cookie-service"),require("graphql/language/printer"),require("@angular/common/http"),require("@aws-amplify/core"),require("@ng-idle/core"),require("@ng-idle/keepalive"),require("slip39"),require("@aws-amplify/auth")):"function"==typeof define&&define.amd?define("@lifeready/core",["exports","@angular/core","apollo-angular","@dagrejs/graphlib","node-jose","@aws-amplify/auth/lib-esm/Auth","graphql-tag","moment","lodash/cloneDeep","lodash/isEqual","lodash/keyBy","lodash/omit","@apollo/client/core","@apollo/client/link/context","@apollo/client/link/retry","ngx-cookie-service","graphql/language/printer","@angular/common/http","@aws-amplify/core","@ng-idle/core","@ng-idle/keepalive","slip39","@aws-amplify/auth"],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["node-jose"],e["@aws-amplify/auth/lib-esm/Auth"],e["graphql-tag"],e.moment,e["lodash/cloneDeep"],e["lodash/isEqual"],null,e["lodash/omit"],e["@apollo/client/core"],e["@apollo/client/link/context"],e["@apollo/client/link/retry"],e["ngx-cookie-service"],e["graphql/language/printer"],e.ng.common.http,e["@aws-amplify/core"],e["@ng-idle/core"],e["@ng-idle/keepalive"],e.slip39,e["@aws-amplify/auth"])}(this,(function(e,t,n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I){"use strict";function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function K(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 P=w(r),k=w(s),R=K(o),D=w(c),E=w(u),A=w(d),M=w(I),O=function(e,t){return(O=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 T(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}O(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function j(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 N(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 F(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 _(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 $(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 L(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 U(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(L(arguments[t]));return e}function x(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var q,J,G;Object.create;function Q(e){if(e&&e.length){var t=e.map((function(e){return new B({code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,data:e.extensions&&A.default(e.extensions,["code","source"]),message:e.message,debug:{locations:e.locations,path:e.path}})}));throw new(V.bind.apply(V,U([void 0],t)))}}!function(e){e.Key="key",e.PassKey="passKey"}(q||(q={})),function(e){e.KeyLink="keyLink",e.PassKeyLink="passKeyLink"}(J||(J={})),function(e){e.JSON="JSON",e.UINT_8_ARRAY="UINT_8_ARRAY"}(G||(G={}));var W,B=function(e){this._type="KcError",this.code=e.code,this.source=e.source,this.data=e.data,this.message=e.message,this.debug=e.debug},V=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}();(W=e.KcErrorCode||(e.KcErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",W.BAD_ARGUMENT="BAD_ARGUMENT",W.BAD_SIGNATURE="BAD_SIGNATURE",W.BAD_STATE="BAD_STATE",W.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",W.CONCURRENT_ACCESS="CONCURRENT_ACCESS",W.CONFIG_ERROR="CONFIG_ERROR",W.CYCLE_DETECTED="CYCLE_DETECTED",W.EXPIRED="EXPIRED",W.INVALID_TOKEN="INVALID_TOKEN",W.INTERNAL_ERROR="INTERNAL_ERROR",W.JSON_DECODE_ERROR="JSON_DECODE_ERROR",W.KEY_MISMATCH="KEY_MISMATCH",W.LIMIT_REACHED="LIMIT_REACHED",W.LOCKED="LOCKED",W.LOGIC_ERROR="LOGIC_ERROR",W.LR_DEBUG_ONLY="LR_DEBUG_ONLY",W.MIN_DELAY="MIN_DELAY",W.MISSING_FIELD="MISSING_FIELD",W.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",W.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",W.NOT_IMPLEMENTED="NOT_IMPLEMENTED",W.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",W.OBJECT_EXISTS="OBJECT_EXISTS",W.RANGE_ERROR="RANGE_ERROR",W.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",W.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",W.USER_NOT_FOUND="USER_NOT_FOUND",W.VERSION_MISMATCH="VERSION_MISMATCH",W.WRONG_PERMISSIONS="WRONG_PERMISSIONS",W.AUTH="AUTH",W.BAD_LOGIC="BAD_LOGIC",W.BAD_REQUEST="BAD_REQUEST",W.BAD_TIME_SYNC="BAD_TIME_SYNC",W.CODE_MISMATCH="CODE_MISMATCH",W.ENCRYPTION="ENCRYPTION",W.NOT_FOUND="NOT_FOUND",W.SUSPICIOUS_OPERATION="SUSPICIOUS_OPERATION",W.UNSUPPORTED="UNSUPPORTED";var Z=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.AUTH,message:n}))||this}return T(n,t),n}(V),H=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_ARGUMENT,message:n}))||this}return T(n,t),n}(V),Y=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_LOGIC,message:n}))||this}return T(n,t),n}(V),X=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_REQUEST,message:n}))||this}return T(n,t),n}(V),z=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_SIGNATURE,message:n}))||this}return T(n,t),n}(V),ee=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_STATE,message:n}))||this}return T(n,t),n}(V),te=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.BAD_TIME_SYNC,message:n}))||this}return T(n,t),n}(V),ne=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.CODE_MISMATCH,message:n}))||this}return T(n,t),n}(V),re=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.CONCURRENT_ACCESS,message:n}))||this}return T(n,t),n}(V),ie=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.ENCRYPTION,message:n}))||this}return T(n,t),n}(V),ae=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.INTERNAL_ERROR,message:n}))||this}return T(n,t),n}(V),se=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.LOCKED,message:n}))||this}return T(n,t),n}(V),oe=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.NOT_FOUND,message:n}))||this}return T(n,t),n}(V),ce=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.SUSPICIOUS_OPERATION,message:n}))||this}return T(n,t),n}(V),ue=function(t){function n(n){return t.call(this,new B({code:e.KcErrorCode.UNSUPPORTED,message:n}))||this}return T(n,t),n}(V);function pe(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 de(e,t){var n,r,i={};try{for(var a=$(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=L(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 le(e,t){var n=pe(Object.entries(e).map((function(n){var r=L(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return de(e,t)})):de(e,n)}function he(e){return F(this,void 0,void 0,(function(){return _(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 ye,fe,ve=R,me=k.default(ye||(ye=x(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),ge=function(){function e(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=ve.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return e.prototype.verifyCognito=function(){return F(this,void 0,void 0,(function(){var e,t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return[4,he(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=ve(t.headers.get("Date")).valueOf(),i=n+this.offsetMs,Math.abs(i-r)>this.MAX_DIFF_MSEC)throw new te("Server time does not match independent source. ServerTime: "+i+", Cognito time: "+r);return this.verified=!0,[2]}}))}))},e.prototype.refresh=function(){return F(this,void 0,void 0,(function(){var e,t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:me}).toPromise()];case 1:return t=a.sent(),n=Date.now(),Q(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 F(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,he(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}();ge.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ge(t.ɵɵinject(a.AuthClass),t.ɵɵinject(n.Apollo))},token:ge,providedIn:"root"}),ge.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ge.ctorParameters=function(){return[{type:a.AuthClass},{type:n.Apollo}]},function(e){e.JSON="JSON",e.COMPACT="COMPACT"}(fe||(fe={}));var Se={payloadType:G.JSON,returnOnlyPayload:!0},Ce={payloadType:G.JSON,returnOnlyPayload:!0,serializations:[fe.JSON]};var be=function(){function e(e){this.timeService=e}return e.prototype.decrypt=function(e,t,n){return F(this,void 0,void 0,(function(){var r,a;return _(this,(function(s){switch(s.label){case 0:if(r={algorithms:["dir","A*GCM","RSA-OAEP-*"]},n=Object.assign(Object.assign({},Ce),n),e.jwk&&(e=e.jwk),"string"==typeof t&&n.serializations.includes(fe.JSON))try{t=JSON.parse(t)}catch(e){if(!n.serializations.includes(fe.COMPACT))throw e;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,i.JWE.createDecrypt(e,r).decrypt(t)];case 1:return(a=s.sent()).payload=this.decodePayload(n.payloadType,a.payload),n.returnOnlyPayload?[2,a.payload]:[2,a]}}))}))},e.prototype.encryptToString=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){var n,r,a,s;return _(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=i.JWE).createEncrypt,a={contentAlg:"A256GCM"},s={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(a.fields=(s.timestamp=o.sent(),s),a),e]).update(t).final()]}}))}))},e.prototype.sign=function(e,t){return F(this,void 0,void 0,(function(){var n,r,a,s,o;return _(this,(function(c){switch(c.label){case 0:return a=(r=i.JWS).createSign,s={},o={},[4,this.timeService.serverNow()];case 1:return n=a.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 F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){var r,a,s;return _(this,(function(o){switch(o.label){case 0:r={algorithms:["RS*"]},n=Object.assign(Object.assign({},Se),n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i.JWS.createVerify(e,r).verify(t)];case 2:return(a=o.sent()).payload=this.decodePayload(n.payloadType,a.payload),n.returnOnlyPayload?[2,a.payload]:[2,a];case 3:throw s=o.sent(),new z("Bad signature: "+s);case 4:return[2]}}))}))},e.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return F(this,void 0,void 0,(function(){var e,i,a,s;return _(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 G.JSON:return JSON.parse((new TextDecoder).decode(t));case G.UINT_8_ARRAY:return t;default:throw new H("Unknown payloadType: "+e)}},e}();be.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new be(t.ɵɵinject(ge))},token:be,providedIn:"root"}),be.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],be.ctorParameters=function(){return[{type:ge}]};var Ie=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 F(this,void 0,void 0,(function(){var n,r,i;return _(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}();Ie.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ie},token:Ie,providedIn:"root"}),Ie.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var we=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 i.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new H("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 H("array.length <= 0");if(t<=0)throw new H("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 F(this,void 0,void 0,(function(){var t,n;return _(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 F(this,void 0,void 0,(function(){var t,n;return _(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 F(this,void 0,void 0,(function(){var t,n;return _(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 F(this,void 0,void 0,(function(){var t,n;return _(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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var t,s;return _(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 F(this,void 0,void 0,(function(){return _(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new ce("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 F(this,void 0,void 0,(function(){return _(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new ce("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 F(this,void 0,void 0,(function(){return _(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new ce("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 F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return F(this,void 0,void 0,(function(){var e;return _(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 F(this,void 0,void 0,(function(){var e;return _(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}();we.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new we(t.ɵɵinject(Ie))},token:we,providedIn:"root"}),we.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],we.ctorParameters=function(){return[{type:Ie}]};var Ke=new t.InjectionToken("KC_CONFIG"),Pe=[e.KcErrorCode.CONCURRENT_ACCESS];function ke(e,t){var n,r;return F(this,void 0,void 0,(function(){var i,a,s;return _(this,(function(o){switch(o.label){case 0:return[4,he(e)];case 1:return i=o.sent(),a=null===(n=t.debug)||void 0===n?void 0:n.username,s=null===(r=t.debug)||void 0===r?void 0:r.rbacCacheMode,[2,{withCredentials:!0,headers:Object.assign(Object.assign(Object.assign({},i&&{authorization:"Bearer "+i}),a&&{"x-kc-dev-user":a}),s&&{"x-kc-dev-rbac-cache-mode":s})}]}}))}))}var Re=function(e,t){var n=h.setContext((function(n,r){var i=r.headers;return F(void 0,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return[4,ke(t,e)];case 1:return n=r.sent(),[2,Object.assign(Object.assign({},n),{headers:Object.assign(Object.assign({},i),n.headers)})]}}))}))})),r=new y.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 Pe.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 T(t,e),t}(Error),a=new l.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return Pe.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new i(e.errors);return e}))})),s=l.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:l.from([r,a,n,s]),cache:new l.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{fetchPolicy:"no-cache",errorPolicy:"all"}}},e.apolloConfig)},De=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 H("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 F(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return _(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 F(this,void 0,void 0,(function(){var t,n,r;return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(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,we.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}();De.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new De(t.ɵɵinject(we),t.ɵɵinject(f.CookieService),t.ɵɵinject(be),t.ɵɵinject(t.INJECTOR))},token:De,providedIn:"root"}),De.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],De.ctorParameters=function(){return[{type:we},{type:f.CookieService},{type:be},{type:t.Injector}]};var Ee=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 F(this,void 0,void 0,(function(){var n;return _(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 F(this,void 0,void 0,(function(){var t;return _(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 oe("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 F(this,void 0,void 0,(function(){var t,n;return _(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 oe("Could not find masterKey in persisted storage");if(t.id!==e)throw new oe("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,we.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();Ee.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ee(t.ɵɵinject(Ke),t.ɵɵinject(De))},token:Ee,providedIn:"root"}),Ee.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ee.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:De}]};var Ae=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 F(this,void 0,void 0,(function(){var t,n,r;return _(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 oe("Key graphs does not contain key id: "+e);if(n.type!==t)throw new ee("Key with id "+e+" is not of type "+t);return n.data},e.prototype.key=function(e){return this.getNode(e,q.Key)},e.prototype.passKey=function(e){return this.getNode(e,q.PassKey)},e.prototype.addKeys=function(e){var t,n,r,i,a,s;if(e.keys)try{for(var o=$(e.keys),c=o.next();!c.done;c=o.next()){var u=c.value;if(!this.graph.hasNode(u.id)){var p={type:q.Key,data:D.default(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=$(e.keyLinks),l=d.next();!l.done;l=d.next()){var h=l.value;if(!this.graph.hasEdge(h.wrappingKeyId,h.keyId)){var y={type:J.KeyLink,data:D.default(h)};this.graph.setEdge(h.wrappingKeyId,h.keyId,y)}}}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=$(e.passKeyLinks),v=f.next();!v.done;v=f.next()){var m=v.value;if(!this.graph.hasEdge(m.passKeyId,m.keyId)){y={type:J.PassKeyLink,data:D.default(m)};this.graph.setEdge(m.passKeyId,m.keyId,y)}}}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 ie("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new ie("Param keyId wrong format: "+t);var n=P.default.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},e.prototype.getJwkKey=function(e,t){return F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.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:if(r=a.sent(),null!=n&&n!=r)throw new Y("Requested keyId is not in the key cache, so an API request was made to populate the key cache.But the key returned by the API does NOT match the requested keyId.This is a programming logic error.");n=r,a.label=2;case 2:return(i=this.key(n)).jwk?[2,i]:[2,this.unwrapKey(this.keyService.currentMasterKey.id,n)]}}))}))},e.prototype._unwrapLink=function(e,t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h;return _(this,(function(y){switch(y.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=y.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=y.sent(),y.label=4;case 4:if(t.type!=J.KeyLink)return[3,13];if(!(a=t.data).nestedWrappingKeyIds)return[3,13];y.label=5;case 5:y.trys.push([5,11,12,13]),s=$(a.nestedWrappingKeyIds),o=s.next(),y.label=6;case 6:return o.done?[3,10]:(c=o.value,[4,this.getKey(c)]);case 7:return u=y.sent(),[4,this.encryptionService.decrypt(u.jwk,i)];case 8:i=y.sent(),y.label=9;case 9:return o=s.next(),[3,6];case 10:return[3,13];case 11:return p=y.sent(),l={error:p},[3,13];case 12:try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(l)throw l.error}return[7];case 13:return d=n,[4,we.asKey(i)];case 14:return d.jwk=y.sent(),n.task=null,[2]}}))}))},e.prototype._unwrap=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return _(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=$(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 F(this,void 0,void 0,(function(){var r,i;return _(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 F(this,void 0,void 0,(function(){var n,r,i;return _(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 F(this,void 0,void 0,(function(){var r;return _(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 F(this,void 0,void 0,(function(){var n;return _(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:G.UINT_8_ARRAY})];case 2:return[2,r.sent()]}}))}))},e.prototype.encryptToString=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){return _(this,(function(n){if(!function(e){return"oct"===e.kty}(t))throw new H("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},e.prototype.encryptWithNewKey=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i;return _(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}();Ae.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Ae(t.ɵɵinject(be),t.ɵɵinject(Ee),t.ɵɵinject(we))},token:Ae,providedIn:"root"}),Ae.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Ae.ctorParameters=function(){return[{type:be},{type:Ee},{type:we}]};var Me=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 F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return Q((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return Q((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();function Oe(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new Y("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function Te(e){return Oe(e,"query")}function je(e){return Oe(e,"mutation")}function Ne(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Fe(e){return{kind:"Name",value:e}}function _e(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function $e(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return k.default.apply(void 0,U([e],t))}Me.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Me(t.ɵɵinject(n.Apollo),t.ɵɵinject(Ae))},token:Me,providedIn:"root"}),Me.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Me.ctorParameters=function(){return[{type:n.Apollo},{type:Ae}]};var Le,Ue,xe="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n nestedWrappingKeyIds\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",qe=k.default(Le||(Le=x(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),xe),Je="keyGraph "+xe,Ge="keyGraph: fetchKeyGraph "+xe,Qe=k.default(Ue||(Ue=x(["\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=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function Be(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 Y("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=U(a,We),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 Ve={hasKeys:!0};function Ze(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s=this;return _(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 F(s,void 0,void 0,(function(){var n,r,i,a;return _(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)]))]}}))}))}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 F(t,void 0,void 0,(function(){var t,n,s,o,c;return _(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),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 F(t,void 0,void 0,(function(){var t,n,i,a,s,u;return _(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 Y("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(Ae))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:t.NgZone},{type:Ae}]},e.CommonProcessorsService=N([Be({ngZoneName:"ngZone"})],e.CommonProcessorsService);var He=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUser=function(e){var t;return F(this,void 0,void 0,(function(){var n,r,i,a,s=this;return _(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 F(this,void 0,void 0,(function(){var n,r;return _(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 F(e,void 0,void 0,(function(){var e,t;return _(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new X('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 F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return _(this,(function(h){switch(h.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,Ze(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=h.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=h.sent(),h.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return _(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,Ze(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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,e]}))}))},e}();function Ye(e,t){return Object.assign(Object.assign({},e),{path:U(e.path,[t])})}He.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new He(t.ɵɵinject(t.NgZone),t.ɵɵinject(Ae))},token:He,providedIn:"root"}),He.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],He.ctorParameters=function(){return[{type:t.NgZone},{type:Ae}]},He=N([Be({ngZoneName:"ngZone"})],He),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("SharedScenarioReceiverDirectoryNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverFileNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("SharedScenarioReceiverFileNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("SharedScenarioReceiverNode",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"})])),this.registerProcessor("DirectoryShareNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"})])),this.registerProcessor("FileShareNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"})]))}return e.prototype.processQuery=function(e,t){return F(this,void 0,void 0,(function(){var n=this;return _(this,(function(r){return t=Object.assign(Object.assign({},Ve),t),[2,le(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 F(this,void 0,void 0,(function(){var e,i,a,s=this;return _(this,(function(o){if(null==t?void 0:t.then)throw new Y("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?le(e,(function(e,t){return s.processField({field:e,context:Ye(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=pe(t.map((function(e,t){return s.processField({field:e,context:Ye(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new Y("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(Ee),t.ɵɵinject(e.CommonProcessorsService),t.ɵɵinject(He))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:t.NgZone},{type:Ee},{type:e.CommonProcessorsService},{type:He}]},e.QueryProcessorService=N([Be({ngZoneName:"ngZone"})],e.QueryProcessorService);var Xe,ze,et,tt=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}(),nt=Te(k.default(Xe||(Xe=x(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],rt=function(){function e(){this._executed=!1,this.deferredPromise=new tt}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 ee("Already executed");this._executed=!0},e}(),it=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return T(t,e),t.prototype.select=function(e){var n=D.default(this.mutation),r=je(n),i={};Ne(e).forEach((function(e){i[e.name.value.split("_")[0]]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=_e(t),r=i[n];r&&(t.selectionSet.selections=[Object.assign(Object.assign({},nt),{name:Fe(r.name.value)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:U(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(rt),at={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},st=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 T(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 Y("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 it)n(e);else{if(!(e instanceof t))throw new ue("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:Fe(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:Fe(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+_e(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:Fe(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:Fe(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={},i=[],a=[];this.lrMutations.forEach((function(s,o){var c,u;if(!(s instanceof rt))throw new Y("An mutation in the array is not of type LrMutationBase.");var p=s.lrMutationData,d=p.mutation,l=p.variables,h=je(d),y="item"+o+"_";h.name&&(y+=h.name.value+"_"),a.push(y),t=U(t,e.renameVariableDefinitions(h.variableDefinitions,y)),n=U(n,e.renameSelections(h.selectionSet.selections,y));try{for(var f=$(Object.keys(l)),v=f.next();!v.done;v=f.next()){var m=v.value;r[y+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=Ne(d);i=U(i,e.renameFragmentDefinitions(g,y))}));var s=D.default(at),o=je(s);return o.selectionSet.selections=n,o.variableDefinitions=t,s.definitions=U(s.definitions,i),{mutation:s,variables:r,prefixes:a}},t}(rt),ot=Te(k.default(ze||(ze=x(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Je)).selectionSet.selections[0],ct=Te(k.default(et||(et=x(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Ge)).selectionSet.selections[0];e.ɵg=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 F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return e=D.default(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Te(e.query)).selectionSet.selections=U(t.selectionSet.selections,[ot])),e.name&&((t=Te(e.query)).name={kind:"Name",value:e.name}),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,Q(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 F(this,void 0,void 0,(function(){return _(this,(function(n){if(null==t?void 0:t.variables)throw new ue('Unsupported field: "options.variables"');if(e.executed)throw new ee("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 F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:D.default(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=je(e.mutation)).selectionSet.selections=U(t.selectionSet.selections,[ct])),e.name&&((t=je(e.mutation)).name={kind:"Name",value:e.name}),e.mutation=k.default(v.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,Q(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return D.default(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 F(this,void 0,void 0,(function(){var n,r,i,a;return _(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=st).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.ɵg.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵg(t.ɵɵinject(t.NgZone),t.ɵɵinject(n.Apollo),t.ɵɵinject(Ae),t.ɵɵinject(e.QueryProcessorService))},token:e.ɵg,providedIn:"root"}),e.ɵg.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵg.ctorParameters=function(){return[{type:t.NgZone},{type:n.Apollo},{type:Ae},{type:e.QueryProcessorService}]},e.ɵg=N([Be({ngZoneName:"ngZone"})],e.ɵg);var ut,pt,dt,lt,ht,yt,ft,vt,mt,gt,St,Ct,bt,It,wt,Kt,Pt,kt,Rt,Dt,Et,At=function(){function t(t){this.lrGraphQL=t.get(e.ɵg)}return t.prototype.mutate=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();function Mt(e){return e.edges.map((function(e){return e.node}))}(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED",(ut=e.PlanState||(e.PlanState={})).ENABLED="ENABLED",ut.DISABLED="DISABLED",(pt=e.ShareTypeChoice||(e.ShareTypeChoice={})).TP="TP",pt.DETACHED="DETACHED",(dt=e.DetachedShareStateChoice||(e.DetachedShareStateChoice={})).IN_PROGRESS="IN_PROGRESS",dt.COMPLETED="COMPLETED",(lt=e.AccessRoleChoice||(e.AccessRoleChoice={})).READER="READER",lt.WRITER="WRITER",lt.ADMIN="ADMIN",lt.CUSTODIAN="CUSTODIAN",lt.DENY="DENY",lt.OWNER="OWNER",(ht=e.AccessRoleChoiceOrder||(e.AccessRoleChoiceOrder={}))[ht.READER=0]="READER",ht[ht.WRITER=1]="WRITER",ht[ht.ADMIN=2]="ADMIN",ht[ht.CUSTODIAN=3]="CUSTODIAN",ht[ht.DENY=4]="DENY",ht[ht.CONFIDENTIAL=5]="CONFIDENTIAL",ht[ht.OWNER=6]="OWNER",(yt=e.AccessRoleMethodChoice||(e.AccessRoleMethodChoice={})).INHERITED="INHERITED",yt.DIRECT="DIRECT",(ft=e.PermissionChoice||(e.PermissionChoice={})).CREATE="CREATE",ft.READ="READ",ft.UPDATE="UPDATE",ft.DELETE="DELETE",ft.SHARE="SHARE",ft.ARCHIVE="ARCHIVE",ft.ACCESS_ARCHIVED="ACCESS_ARCHIVED",ft.UNARCHIVE="UNARCHIVE",ft.SET_CONFIDENTIAL="SET_CONFIDENTIAL",(vt=e.FileOperationField||(e.FileOperationField={})).CREATE="CREATE",vt.READ="READ",vt.UPDATE="UPDATE",vt.REVERT="REVERT",vt.DELETE="DELETE",(mt=e.KeyExchangeOtkState||(e.KeyExchangeOtkState={})).OTK_INITIATED="OTK_INITIATED",mt.OTK_ACCEPTED="OTK_ACCEPTED",mt.OTK_COMPLETED="OTK_COMPLETED",(gt=e.KeyExchangeState||(e.KeyExchangeState={})).IN_PROGRESS="IN_PROGRESS",gt.COMPLETED="COMPLETED",gt.DECLINED="DECLINED",gt.CANCELLED="CANCELLED",gt.DELETED="DELETED",(e.KeyExchangeMode||(e.KeyExchangeMode={})).OTK="OTK",(St=e.TpAssemblyState||(e.TpAssemblyState={})).DISABLED="DISABLED",St.ENABLED="ENABLED",St.CLAIMED="CLAIMED",St.APPROVED="APPROVED",St.REJECTED="REJECTED",St.EXPIRED="EXPIRED",St.CANCELLED="CANCELLED",St.RESET="RESET",(Ct=e.TpClaimState||(e.TpClaimState={})).CLAIMED="CLAIMED",Ct.APPROVED="APPROVED",Ct.REJECTED="REJECTED",Ct.EXPIRED="EXPIRED",Ct.CANCELLED="CANCELLED",Ct.RESET="RESET",(bt=e.TpClaimApproverState||(e.TpClaimApproverState={})).CLAIMED="CLAIMED",bt.APPROVED="APPROVED",bt.REJECTED="REJECTED",(It=e.LockState||(e.LockState={})).UNLOCKED="UNLOCKED",It.MUTEX_LOCKED="MUTEX_LOCKED",(wt=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",wt.ENABLED="ENABLED",wt.CLAIMED="CLAIMED",wt.APPROVED="APPROVED",(Kt=e.ClaimState||(e.ClaimState={})).CLAIMED="CLAIMED",Kt.EXPIRED="EXPIRED",Kt.APPROVED="APPROVED",Kt.REJECTED="REJECTED",Kt.CANCELLED="CANCELLED",Kt.RESET="RESET",(Pt=e.ClaimApproverState||(e.ClaimApproverState={})).CLAIMED="CLAIMED",Pt.APPROVED="APPROVED",Pt.REJECTED="REJECTED",(kt=e.ScenarioLastClaimState||(e.ScenarioLastClaimState={})).CLAIMED="CLAIMED",kt.APPROVED="APPROVED",kt.REJECTED="REJECTED",kt.EXPIRED="EXPIRED",kt.CANCELLED="CANCELLED",kt.RESET="RESET",(Rt=e.LinkTypeField||(e.LinkTypeField={})).HARD="HARD",Rt.SOFT="SOFT",Rt.REFERENCE="REFERENCE",(Dt=e.BillingPeriodField||(e.BillingPeriodField={})).MONTHLY="MONTHLY",Dt.ANNUAL="ANNUAL",(Et=e.PlanStateField||(e.PlanStateField={})).TRIALLING="TRIALLING",Et.ACTIVE="ACTIVE",Et.CANCELLED="CANCELLED",Et.EXPIRED="EXPIRED";var Ot,Tt=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()}},jt=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=Tt(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}};(Ot=e.Config||(e.Config={}))[Ot.TIMEOUT=.01]="TIMEOUT",Ot[Ot.IDLE=1200]="IDLE",Ot[Ot.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var Nt=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 ee("Call IdleService.init() first.")},t.prototype.init=function(t){return F(this,void 0,void 0,(function(){var n,r=this;return _(this,(function(i){switch(i.label){case 0:if(this.initCalled)throw new ee("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 H("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(S.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 F(r,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout({onInit:!1}))];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({onInit:!0}))]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return F(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return t=(e=this.http).post,n=[this.config.authUrl+"auth/keepalive/",null],[4,ke(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 F(this,void 0,void 0,(function(){var t;return _(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(),[2]}}))}))},t.prototype.onPing=function(){return F(this,void 0,void 0,(function(){var e;return _(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 F(this,void 0,void 0,(function(){return _(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}();Nt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Nt(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(S.Idle),t.ɵɵinject(C.Keepalive),t.ɵɵinject(Ee),t.ɵɵinject(a.AuthClass))},token:Nt,providedIn:"root"}),Nt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Nt.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:S.Idle},{type:C.Keepalive},{type:Ee},{type:a.AuthClass}]};var Ft,_t,$t,Lt,Ut,xt,qt,Jt="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",Gt=(k.default(Ft||(Ft=x(["\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}"])),Jt,Je),k.default(_t||(_t=x(['\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}"])),Jt,Je),k.default($t||($t=x(['\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}"])),Jt,Je)),Qt=(k.default(Lt||(Lt=x(["\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}"])),Jt),k.default(Ut||(Ut=x(["\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}"])),Jt),k.default(xt||(xt=x(["\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"])))),Wt=$e(qt||(qt=x(["\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"]))),Bt=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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return _(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 F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return _(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 F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h=this;return _(this,(function(y){switch(y.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=y.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return F(h,void 0,void 0,(function(){var t,r,i,a;return _(this,(function(s){switch(s.label){case 0:return[4,this.getDirectoryKeyId(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=y.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,[y.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},y.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,[y.sent()]),[3,8];case 7:p=null,y.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o;return _(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.getDirectoryKeyId=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Wt,variables:{id:e}})];case 1:return t=r.sent().directory,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();Bt.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Bt(t.ɵɵinject(be),t.ɵɵinject(Ae),t.ɵɵinject(Me),t.ɵɵinject(Ee),t.ɵɵinject(we))},token:Bt,providedIn:"root"}),Bt.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Bt.ctorParameters=function(){return[{type:be},{type:Ae},{type:Me},{type:Ee},{type:we}]};var Vt,Zt,Ht,Yt,Xt,zt,en,tn,nn,rn="\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",an="\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",sn=$e(Vt||(Vt=x(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ","\n }\n }\n }\n}\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ","\n }\n }\n }\n}\n"])),rn),on=$e(Zt||(Zt=x(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ","\n }\n}\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ","\n }\n}\n"])),rn),cn=$e(Ht||(Ht=x(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ","\n }\n}\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ","\n }\n}\n"])),rn),un=$e(Yt||(Yt=x(["\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"]))),pn=$e(Xt||(Xt=x(["\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"]))),dn=$e(zt||(zt=x(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n }\n}\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n }\n}\n"])),rn),ln=$e(en||(en=x(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"])),rn,an),hn=$e(tn||(tn=x(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n user {\n config\n }\n }\n }\n}\n"])),rn,an),yn=$e(nn||(nn=x(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\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 ","\n }\n }\n}\n"])),an);(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var fn,vn=function(){},mn=function(){},gn=function(){},Sn=function(){},Cn=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},bn=function(){},In=function(){},wn=function(){},Kn=function(){},Pn=function(){},kn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t}(Pn),Rn=function(){},Dn=function(){};(fn=e.TrustedPartyType||(e.TrustedPartyType={})).User="user",fn.Organisation="organisation";var En,An=function(){},Mn="\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",On=k.default(En||(En=x(["\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}"])),Mn),Tn=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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var t,n,r;return _(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 F(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,h,y;return _(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 Cn(r.name)},y=(h=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 5:return l=y.apply(h,[f.sent()]),[4,this.lrApollo.mutate({mutation:On,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}();Tn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Tn(t.ɵɵinject(Ee),t.ɵɵinject(Me),t.ɵɵinject(Ae),t.ɵɵinject(be))},token:Tn,providedIn:"root"}),Tn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Tn.ctorParameters=function(){return[{type:Ee},{type:Me},{type:Ae},{type:be}]};var jn,Nn,Fn,_n,$n,Ln="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+Mn+"\n }\n myContactCard {\n "+Mn+"\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 "+rn+"\n }\n "+an+"\n }\n }",Un=k.default(jn||(jn=x(['\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),xn=k.default(Nn||(Nn=x(["\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"]))),qn=k.default(Fn||(Fn=x(["\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"]))),Jn=$e(_n||(_n=x(["\nquery TrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n}"],["\nquery TrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n}"])),Ln),Gn=$e($n||($n=x(['\nquery ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n cipherData\n key {\n id\n }\n }\n }\n }\n}\n'],['\nquery ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n id\n cipherData\n key {\n id\n }\n }\n }\n }\n}\n']))),Qn=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.getCurrentUser=function(){return F(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Un})];case 1:return e=i.sent(),t=e.currentUser,n=e.contactCards,r=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:r}]}}))}))},e.prototype.decryptContactCard=function(e){return F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var r;return _(this,(function(i){switch(i.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r=i.sent(),[2,{fields:n,id:r.id,keyId:r.key.id}]}}))}))},e.prototype.prepareContactCardInput=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return _(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 Cn(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 F(this,void 0,void 0,(function(){var t,n,r,i;return _(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:xn,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 F(this,void 0,void 0,(function(){var r,i;return _(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:qn,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 F(this,void 0,void 0,(function(){var t=this;return _(this,(function(n){return[2,Promise.all(e.map((function(e){return F(t,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Gt})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Qt,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return F(this,void 0,void 0,(function(){return _(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}();Qn.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Qn(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(Me),t.ɵɵinject(Ee),t.ɵɵinject(Bt),t.ɵɵinject(Ae),t.ɵɵinject(be))},token:Qn,providedIn:"root"}),Qn.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Qn.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:Me},{type:Ee},{type:Bt},{type:Ae},{type:be}]};var Wn,Bn,Vn,Zn=k.default(Wn||(Wn=x(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"]))),Hn=k.default(Bn||(Bn=x(["\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"]))),Yn=k.default(Vn||(Vn=x(["\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"]))),Xn=R,zn=function(){},er=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 F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Xn.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i;return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(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 F(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Xn(e.authTime),n=Xn(e.serverTime),r=Xn.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a;return _(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,ke(this.auth,this.config)];case 1:return[2,i.apply(r,a.concat([s.sent()])).toPromise()]}}))}))},e.prototype.getVerifierPrK=function(e,t){return F(this,void 0,void 0,(function(){var n;return _(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,we.asKey(n)];case 2:throw r.sent(),new Z("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s;return _(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:Zn,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 F(this,void 0,void 0,(function(){var i;return _(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Hn,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 F(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:Yn})];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}();er.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new er(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(Me),t.ɵɵinject(a.AuthClass),t.ɵɵinject(Qn),t.ɵɵinject(we),t.ɵɵinject(be),t.ɵɵinject(Ae),t.ɵɵinject(Ie))},token:er,providedIn:"root"}),er.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],er.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:Me},{type:a.AuthClass},{type:Qn},{type:we},{type:be},{type:Ae},{type:Ie}]};var tr="lifeready",nr=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},rr=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}(),ir=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}(),ar=(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 F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return _(this,(function(d){switch(d.label){case 0:r=btoa(e),r=b.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=$(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,b.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 nr(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=$(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=b.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 h=$(s.values()),y=h.next();!y.done;y=h.next()){var f;if(!((f=y.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{y&&!y.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return d},e.prototype.recoverSecret=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,b.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=b.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}());ar.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ar},token:ar,providedIn:"root"}),ar.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var sr,or=$e(sr||(sr=x(["\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}"]))),cr=function(){function t(t){this.keyFactory=t.get(we),this.keyService=t.get(Ee),this.encryptionService=t.get(be),this.keyGraph=t.get(Ae),this.slip39Service=t.get(ar),this.lrGraphQl=t.get(e.ɵg)}return t.prototype.recoverAssemblyKey=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(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 ee("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,we.asKey(Object.assign(Object.assign({},t),{k:r}))];case 2:return[2,i.sent()]}}))}))},t.prototype.prepareTpWrappingKey=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.keyGraph.getKey(e.wrappingKeyId)]}))}))},t.prototype.prepareAssembly=function(e){var t=e.subjectKey,n=e.rootKey;return F(this,void 0,void 0,(function(){var e,r,i,a,s,o,c,u,p;return _(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=j(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 F(this,void 0,void 0,(function(){var e=this;return _(this,(function(a){return[2,Promise.all(t.map((function(t,a){return F(e,void 0,void 0,(function(){var e,s,o=this;return _(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 F(o,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var e=this;return _(this,(function(s){if(r.length!==t.length)throw new H("The slipSubAssemblies must be the same length as the input");return[2,Promise.all(t.map((function(t,s){return F(e,void 0,void 0,(function(){var e,o,c,u,p,d,l=this;return _(this,(function(h){switch(h.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=h.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 F(l,void 0,void 0,(function(){return _(this,(function(e){return[2,this.prepareApprover({tp:r,approverIndex:t,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return d.createApprovers=h.sent(),[4,Promise.all(u.map((function(e,t){var r=e.tp,a=e.approverId;return F(l,void 0,void 0,(function(){return _(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=h.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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,h,y;return _(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=j(i,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),[4,this.prepareSlip39(e.createSubAssemblies,e.quorum,s)];case 4:return u=f.sent(),p=this.getInputApprovers(e.createSubAssemblies),l=Mt,[4,this.lrGraphQl.query({query:or,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 h=f.sent(),[4,this.encryptionService.encryptToString(n,e.subjectCipherDataClearJson||"")];case 7:return y=f.sent(),[2,{assemblyKey:a,mutationInput:Object.assign(Object.assign({},c),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:y,createSubAssemblies:h,rootKeyId:t.id,rootKeyWrappedSubjectKey:r})}]}}))}))},t.prototype.getAssemblyApprovers=function(e){var t=[];return Mt(e.subAssemblies).map((function(e){Mt(e.approvers).forEach((function(e){return t.push(e.tp.id)}))})),t},t.prototype.prepareUpdate=function(e,t){var n;return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b;return _(this,(function(I){switch(I.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 H("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=I.sent(),[4,this.prepareAssembly({rootKey:s.jwk,subjectKey:o.jwk})];case 2:return c=I.sent(),u=c.assemblyKey,p=c.rawAssemblyKey,d=c.assemblyKeyParams,l=j(c,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),h=this.getAssemblyApprovers(t).concat(this.getInputApprovers(r),this.getInputApprovers(i)),f=Mt,[4,this.lrGraphQl.query({query:or,variables:{ids:h}})];case 3:y=f.apply(void 0,[I.sent().tps]),Mt(t.subAssemblies).forEach((function(e){if(!a.includes(e.id)&&!i.some((function(t){return t.id===e.id}))){var t=Mt(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,y),this.fillWrappingKeyId(i,y),I.label=4;case 4:return I.trys.push([4,6,,7]),[4,this.prepareSlip39((r||[]).concat(i||[]),e.quorum,p)];case 5:return v=I.sent(),[3,7];case 6:return m=I.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=I.sent(),[4,this.prepareUpdateSubAssemblies(Object.assign(Object.assign({},g),{input:i,slipSubAssemblies:v.subAssemblies.slice(r.length),subAssemblies:t.subAssemblies}))];case 9:return C=I.sent(),[4,this.encryptionService.encryptToString(o.jwk,null!==(n=e.subjectCipherDataClearJson)&&void 0!==n?n:t.subjectCipherDataClearJson)];case 10:return b=I.sent(),[2,{assemblyKey:u,mutationInput:Object.assign(Object.assign({},l),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:b,subjectKeyId:o.id,createSubAssemblies:S,updateSubAssemblies:C})}]}}))}))},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 F(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y;return _(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 h=f.sent(),[4,this.encryptionService.encryptToString(o,d)];case 7:return y=f.sent(),[2,{tpWrappingKeyId:e.id,tpWrappedSharedKey:c,subjectKeyWrappedSharedKey:u,sharedCipherData:l,sharedCipherApprovalData:h,sharedCipherPartialAssemblyKey:y,approverId:t||void 0,tpId:t?void 0:n.tpId}]}}))}))},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=$(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 H(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 F(this,void 0,void 0,(function(){var r;return _(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new H("Not enough sub assemblies to meet quorum");return r=new ir(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new rr(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=tr,r}return T(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.mkSharedKey.id},t}(cr),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=N([Be({ngZoneName:"ngZone"})],e.ɵi);var ur,pr,dr,lr,hr,yr,fr,vr,mr,gr,Sr,Cr,br,Ir,wr,Kr,Pr=$e(ur||(ur=x(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),kr=$e(pr||(pr=x(["\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}"]))),Rr=$e(dr||(dr=x(["\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}"]))),Dr=$e(lr||(lr=x(["\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}"]))),Er=$e(hr||(hr=x(["\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}"]))),Ar=$e(yr||(yr=x(["\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}"]))),Mr=$e(fr||(fr=x(["\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}"]))),Or=$e(vr||(vr=x(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),Tr=$e(mr||(mr=x(["\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}"]))),jr=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}(),Nr=$e(gr||(gr=x(["\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),Fr=$e(Sr||(Sr=x(["\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}"]))),_r=$e(Cr||(Cr=x(["\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"])));(br=e.RecoveryStatus||(e.RecoveryStatus={})).NONE="NONE",br.NEW_PASSWORD="NEW_PASSWORD",br.OLD_PASSWORD="OLD_PASSWORD",(Ir=e.PasswordChangeStatus||(e.PasswordChangeStatus={})).IN_PROGRESS="IN_PROGRESS",Ir.RECOVERY="RECOVERY",(wr=e.CognitoChallengeName||(e.CognitoChallengeName={})).NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",wr.SMS_MFA="SMS_MFA",wr.SOFTWARE_TOKEN_MFA="SOFTWARE_TOKEN_MFA",wr.MFA_SETUP="MFA_SETUP",e.AuthService=Kr=function(n){function r(e,r,i,a,s,o,c,u,p,d,l,h,y,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=h,v.assemblyController=y,v.kcConfig=f,v.logoutListeners=new Set,v.password=null,!t.isDevMode()&&null!=v.kcConfig.debug)throw new X('In production mode, "KcConfig.debug" must be set to null');return v}return T(r,n),r.prototype.importPassword=function(e){return this.keyFactoryService.importPassword(e)},r.prototype.logout=function(){var e;return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,Promise.all(U(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 F(this,void 0,void 0,(function(){var r;return _(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return(r=a.sent()).challenge?(this.password=new jr(n,Kr.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(t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o;return _(this,(function(c){switch(c.label){case 0:if(n=t.challenge,r=t.code,i=t.rememberMe,!(a=[e.CognitoChallengeName.SMS_MFA,e.CognitoChallengeName.SOFTWARE_TOKEN_MFA]).includes(n.cognitoUser.challengeName))throw new X("challengeName must be one of "+a);return[4,this.cognito.confirmSignIn(n.cognitoUser,r,n.cognitoUser.challengeName)];case 1:return s=c.sent(),[4,this.handlePostAuth(n.recoveryStatus)];case 2:return c.sent(),[4,this.loadUser(s,this.password.pop())];case 3:return o=c.sent(),this.password=null,i&&s.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,{user:o}]}}))}))},r.prototype.getUser=function(){return F(this,void 0,void 0,(function(){var e;return _(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 F(this,void 0,void 0,(function(){var e,t;return _(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 F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Nr,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().currentUser]}}))}))},r.prototype.fetchResetUser=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.api.query({query:Fr,processorOptions:{hasKeys:!1}})];case 1:return[2,e.sent().tpPasswordResetUser]}}))}))},r.prototype.kcLogout=function(){return F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(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(t,n){return F(this,void 0,void 0,(function(){var r;return _(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(t,n)];case 2:return r=i.sent(),[e.CognitoChallengeName.SMS_MFA,e.CognitoChallengeName.SOFTWARE_TOKEN_MFA].includes(r.cognitoUser.challengeName)?[2,{challenge:{cognitoUser:r.cognitoUser,recoveryStatus:r.recoveryStatus}}]:[4,this.handlePostAuth(r.recoveryStatus)];case 3:return i.sent(),[4,this.loadUser(r.cognitoUser,n)];case 4:return[2,{user:i.sent()}]}}))}))},r.prototype.loginIdp=function(t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l;return _(this,(function(h){switch(h.label){case 0:return[4,this.fetchPassIdpParams(t)];case 1:if((r=h.sent()).passwordChangeStatus===e.PasswordChangeStatus.IN_PROGRESS)throw new re("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.RECOVERY)return[3,8];console.log("In recovery mode."),h.label=2;case 2:return h.trys.push([2,4,,5]),a={},[4,this.loginIdpImpl(t,n,r.newPassIdpParams)];case 3:return a.cognitoUser=h.sent(),a.recoveryStatus=e.RecoveryStatus.NEW_PASSWORD,i=a,console.log("New password works!"),[2,i];case 4:if("NotAuthorizedException"!==(s=h.sent()).code)throw s;return[3,5];case 5:return h.trys.push([5,7,,8]),c={},[4,this.loginIdpImpl(t,n,r.currentPassIdpParams)];case 6:return c.cognitoUser=h.sent(),c.recoveryStatus=e.RecoveryStatus.OLD_PASSWORD,o=c,console.log("Old password works!"),[2,o];case 7:throw"NotAuthorizedException"===(u=h.sent()).code?new X("The password change request was interrupted, please try to login with both your new and old password"):u;case 8:if(!r.tpPasswordReset)return[3,12];h.label=9;case 9:return h.trys.push([9,11,,12]),p=r.tpPasswordReset,d={},[4,this.loginIdpImpl(p.resetUsername,n,p.passIdpParams)];case 10:return d.cognitoUser=h.sent(),d.recoveryStatus=e.RecoveryStatus.NONE,[2,d];case 11:return h.sent(),[3,12];case 12:return l={},[4,this.loginIdpImpl(t,n,r.currentPassIdpParams)];case 13:return l.cognitoUser=h.sent(),l.recoveryStatus=e.RecoveryStatus.NONE,[2,l]}}))}))},r.prototype.loginIdpImpl=function(e,t,n){return F(this,void 0,void 0,(function(){var r;return _(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 F(this,void 0,void 0,(function(){return _(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(t){return F(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return t===e.RecoveryStatus.NONE?[3,2]:[4,this.passwordService.changePasswordComplete({useNewPassword:t===e.RecoveryStatus.NEW_PASSWORD})];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},r.prototype.handleSessionEncryptionKey=function(){return F(this,void 0,void 0,(function(){var e,n;return _(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 ae(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 it({mutation:_r,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 F(this,void 0,void 0,(function(){var t,n,r,a,s,o,c,u;return _(this,(function(p){switch(p.label){case 0:return t=e.userKeys,n=e.password,(r=e.sessionEncryptionKey)?(s=(a=this.persistService).setServerSessionEncryptionKey,[4,i.JWK.asKey(r)]):[3,2];case 1:s.apply(a,[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 F(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){switch(i.label){case 0:return e.getUsername().endsWith(".tp_password_reset")?(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 F(this,void 0,void 0,(function(){var n,r,i,a;return _(this,(function(s){switch(s.label){case 0:return[4,this.fetchCurrentUser()];case 1:return n=s.sent(),[4,this.loadUserKeys({userKeys:n.currentUserKey,password:t,sessionEncryptionKey:n.sessionEncryptionKey})];case 2:return s.sent(),[4,this.keyGraphService.populateKeys(n.currentUserKey)];case 3:return s.sent(),r=n.id,i=n.username,[4,this.cognito.userAttributes(e)];case 4:return a=s.sent(),[2,{id:r,username:i,sub:this.getCognitoUserAttribute("sub",a),loginEmail:this.getCognitoUserAttribute("email",a),resetUser:null}]}}))}))},r.prototype.loadResetUser=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a;return _(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 F(this,void 0,void 0,(function(){var t,n,r=this;return _(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 F(this,void 0,void 0,(function(){var n,r,a,s,o,c,u,p,d,l,h,y,f,v,m=this;return _(this,(function(S){switch(S.label){case 0:return[4,this.fetchResetUser()];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new ee("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 a=S.sent().rootKey,[4,i.JWK.asKey(a)];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 it({mutation:kr,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 h=S.sent(),[4,this.lrGraphQL.lrMutate(new it({mutation:Rr,variables:{input:{signedChallenge:JSON.stringify(h)}}}),{includeKeyGraph:!1})];case 11:return y=S.sent().preCompleteTpPasswordResetRequest.idpPassword,f=new Promise((function(e){var t=function(r){return F(m,void 0,void 0,(function(){return _(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(g.Hub.remove("auth",t),[4,this.cognito.signIn(n.username,p)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new it({mutation:Dr,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};g.Hub.listen("auth",t)})),[4,this.cognito.signIn(n.username,y,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(v=S.sent()).challengeName)throw new ae("Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation.");return[4,this.cognito.completeNewPassword(v,p,{})];case 13:return v=S.sent(),[2,f]}}))}))},r.prototype.debugLogin=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return this.kcConfig.debug.username=e,this.kcConfig.debug.rbacCacheMode=null,[4,this.http.get(this.kcConfig.authUrl+"debug_only/users/login/?username="+encodeURIComponent(e)).toPromise()];case 1:return n.sent(),[2,this.debugLoadUser(t)]}}))}))},r.prototype.debugLoadUser=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(this,(function(o){switch(o.label){case 0:return[4,this.fetchCurrentUser()];case 1:return t=o.sent(),n=t.id,r=t.username,i=t.currentUserKey,[4,this.keyFactoryService.derivePassKey(Object.assign({password:e},i.passKey.passKeyParams))];case 2:return a=o.sent().jwk,[4,this.keyGraphService.unwrapWithPassKey(i.passKey.id,a,i.masterKey.id)];case 3:return s=o.sent(),[4,this.idleService.persistMasterKey(s)];case 4:return o.sent(),[4,this.keyGraphService.populateKeys(i)];case 5:return o.sent(),this.user={id:n,username:r,resetUser:null,sub:"DEBUG_MODE",loginEmail:"DEBUG_MODE"},[2,this.user]}}))}))},r.prototype.debugClearUser=function(){this.user=null},r.prototype.getCurrentUserAttributes=function(){return F(this,void 0,void 0,(function(){var e;return _(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.prototype.debugRetainRbacCache=function(e){this.kcConfig.debug.rbacCacheMode=e?"retain":null},r}(At),e.AuthService.CHALLENGE_TIMEOUT=3e5,e.AuthService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.AuthService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(m.HttpClient),t.ɵɵinject(a.AuthClass),t.ɵɵinject(e.ɵg),t.ɵɵinject(Ee),t.ɵɵinject(Ae),t.ɵɵinject(we),t.ɵɵinject(er),t.ɵɵinject(Nt),t.ɵɵinject(De),t.ɵɵinject(be),t.ɵɵinject(e.ɵi),t.ɵɵinject(Ke))},token:e.AuthService,providedIn:"root"}),e.AuthService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.AuthService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:m.HttpClient},{type:a.AuthClass},{type:e.ɵg},{type:Ee},{type:Ae},{type:we},{type:er},{type:Nt},{type:De},{type:be},{type:e.ɵi},{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]}]},e.AuthService=Kr=N([Be({ngZoneName:"ngZone"})],e.AuthService);var $r,Lr,Ur,xr=$e($r||($r=x(["\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"]))),qr=$e(Lr||(Lr=x(["\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"]))),Jr=$e(Ur||(Ur=x(["\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"]))),Gr=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 F(this,void 0,void 0,(function(){var t,n,r,i,a;return _(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 it({mutation:xr,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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 it({mutation:qr,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new it({mutation:Jr,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return _(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(we),t.ɵɵinject(Ee),t.ɵɵinject(be),t.ɵɵinject(Ae),t.ɵɵinject(Bt),t.ɵɵinject(t.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:we},{type:Ee},{type:be},{type:Ae},{type:Bt},{type:t.NgZone}]},e.ContactCard2Service=N([Be({ngZoneName:"ngZone"})],e.ContactCard2Service);var Qr=function(){function e(e,t,n){this.config=e,this.http=t,this.auth=n}return e.prototype.downloadEncryptedFileJson=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return _(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,ke(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(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,ke(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}();Qr.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Qr(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(a.AuthClass))},token:Qr,providedIn:"root"}),Qr.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Qr.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:a.AuthClass}]};var Wr,Br,Vr,Zr,Hr,Yr,Xr,zr,ei,ti,ni,ri,ii,ai,si,oi,ci,ui,pi,di,li,hi=$e(Wr||(Wr=x(["\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"]))),yi=$e(Br||(Br=x(["\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"]))),fi=$e(Vr||(Vr=x(["\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"]))),vi=$e(Zr||(Zr=x(["\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"]))),mi=$e(Hr||(Hr=x(["\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"]))),gi=$e(Yr||(Yr=x(["\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"]))),Si=$e(Xr||(Xr=x(["\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"]))),Ci=$e(zr||(zr=x(["\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"]))),bi=$e(ei||(ei=x(["\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"]))),Ii=$e(ti||(ti=x(["\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"]))),wi=$e(ni||(ni=x(["\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"]))),Ki=$e(ri||(ri=x(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"],["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n keyId\n }\n }\n}\n"]))),Pi=$e(ii||(ii=x(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"],["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n keyId\n }\n }\n}\n"]))),ki=$e(ai||(ai=x(["\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"]))),Ri=$e(si||(si=x(['\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']))),Di=$e(oi||(oi=x(["\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"]))),Ei=$e(ci||(ci=x(["\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"]))),Ai=$e(ui||(ui=x(["\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}"]))),Mi=$e(pi||(pi=x(["\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"])),Ai),Oi=$e(di||(di=x(["\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"])),Ai),Ti=$e(li||(li=x(["\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"])),Ai);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return T(t,e),t.prototype.updateLockMutation=function(e){return new it({mutation:Mi,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t.prototype.acquireLockMutation=function(e){return new it({mutation:Oi,variables:{input:{resourceId:e.resourceId,timeoutMs:e.timeoutMs}}})},t.prototype.releaseLockMutation=function(e){return new it({mutation:Ti,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=N([Be({ngZoneName:"ngZone"})],e.LockService);var ji,Ni,Fi,_i,$i,Li,Ui=$e(ji||(ji=x(["\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"]))),xi=$e(Ni||(Ni=x(["\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"]))),qi=$e(Fi||(Fi=x(["\nquery DirectoryKeyFromDirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"],["\nquery DirectoryKeyFromDirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"]))),Ji=$e(_i||(_i=x(["\nquery FileKeyFromFileShareQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"],["\nquery FileKeyFromFileShareQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n keyId\n }\n }\n}\n"]))),Gi=$e($i||($i=x(["\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.ItemService=Li=function(t){function n(e,n,r,i,a,s,o,c){var u=t.call(this,n)||this;return u.ngZone=e,u.injector=n,u.fileUploadService=r,u.keyService=i,u.keyFactory=a,u.keyGraph=s,u.lockService=o,u.authService=c,u.tempDirectory=null,u.authService.addLogoutListener((function(){return u.onLogout()})),u}return T(n,t),n.prototype.downloadFileContent=function(e){return F(this,void 0,void 0,(function(){var t,n,r=this;return _(this,(function(i){switch(i.label){case 0:return[4,this.fileUploadService.downloadEncryptedFile(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:G.UINT_8_ARRAY})]}}))}))},n.prototype.getDirectoryKeyId=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Ui,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},n.prototype.getFileKeyId=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:xi,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},n.prototype.getDirectoryKeyIdFromDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:qi,variables:{id:e}})];case 1:return[2,t.sent().directoryShare.item.keyId]}}))}))},n.prototype.getFileKeyIdFromFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Ji,variables:{id:e}})];case 1:return[2,t.sent().fileShare.item.keyId]}}))}))},n.prototype.getDirectoryKey=function(e,t){return F(this,void 0,void 0,(function(){var n=this;return _(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},n.prototype.getFileKey=function(e,t){return F(this,void 0,void 0,(function(){var n=this;return _(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},n.prototype.createDirectory=function(e){return this.mutate(this.createDirectoryMutation(e))},n.prototype.createDirectoryMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:hi},r={},[4,this.prepareCreateDirectory(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.updateDirectory=function(e){return this.mutate(this.updateDirectoryMutation(e))},n.prototype.updateDirectoryMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:yi},r={},[4,this.prepareUpdateDirectory(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.deleteDirectory=function(e){return this.mutate(this.deleteDirectoryMutation(e))},n.prototype.deleteDirectoryMutation=function(e){return new it({mutation:fi,variables:{input:{directoryId:e}}})},n.prototype.createFile=function(e){return this.mutate(this.createFileMutation(e))},n.prototype.createFileMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:vi},r={},[4,this.prepareCreateFile(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.updateFile=function(e){return this.mutate(this.updateFileMutation(e))},n.prototype.updateFileMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:mi},r={},[4,this.prepareUpdateFile(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.revertFile=function(e){return this.mutate(this.revertFileMutation(e))},n.prototype.revertFileMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:gi,variables:{input:e}})]}))}))},n.prototype.deleteFile=function(e){return this.mutate(this.deleteFileMutation(e))},n.prototype.deleteFileMutation=function(e){return new it({mutation:Si,variables:{input:{fileId:e}}})},n.prototype.archiveDirectory=function(e,t){return this.mutate(this.archiveDirectoryMutation(e,t))},n.prototype.archiveDirectoryMutation=function(e,t){return new it({mutation:Ci,variables:{input:{directoryId:e,recursive:t.recursive}}})},n.prototype.archiveFile=function(e){return this.mutate(this.archiveFileMutation(e))},n.prototype.archiveFileMutation=function(e){return new it({mutation:bi,variables:{input:{fileId:e}}})},n.prototype.unarchiveDirectory=function(e,t){return this.mutate(this.unarchiveDirectoryMutation(e,t))},n.prototype.unarchiveDirectoryMutation=function(e,t){return new it({mutation:Ii,variables:{input:{directoryId:e,recursive:t.recursive}}})},n.prototype.unarchiveFile=function(e){return this.mutate(this.unarchiveFileMutation(e))},n.prototype.unarchiveFileMutation=function(e){return new it({mutation:wi,variables:{input:{fileId:e}}})},n.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},n.prototype.changeDirectoryParentsMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:Ki},r={},[4,this.prepareChangeDirectoryParents(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.changeFileParents=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},n.prototype.changeFileParentsMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:Pi},r={},[4,this.prepareChangeFileParents(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},n.prototype.beginDeleteChildItemLinksWindow=function(e){return this.mutate(this.beginDeleteChildItemLinksWindowMutation(e))},n.prototype.beginDeleteChildItemLinksWindowMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:ki,variables:{input:e}})]}))}))},n.prototype.ensureTempDirectory=function(){var e;return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return _(this,(function(p){switch(p.label){case 0:return this.tempDirectory?[2,this.tempDirectory]:[4,this.query({query:Ri,variables:{plainMeta:Li.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: "+Li.TEMP_DIRECTORY_PLAIN_META_FILTER+")"),0!==t.rootDirectories.edges.length?[3,4]:[4,this.createDirectoryMutation({asRootDirectory:!0,plainMetaJson:Li.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=L.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]}}))}))},n.prototype.createDirectoryWithStaging=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createDirectoryWithStagingMutation(e))]}))}))},n.prototype.createDirectoryWithStagingMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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.createDirectory({cipherMetaClearJson:e.cipherMetaClearJson,parentDirectories:[{directory:t}],plainMetaJson:e.plainMetaJson})];case 3:return n=r.sent().createDirectory.directory,[4,e.onCreatedInStaging({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})]}}))}))},n.prototype.createFileWithStaging=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createFileWithStagingMutation(e))]}))}))},n.prototype.createFileWithStagingMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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.createFile(Object.assign(Object.assign({},e),{parentDirectories:[{directory:t}]}))];case 3:return n=r.sent().createFile.file,[4,e.onCreatedInStaging({id:n.id,keyId:n.keyId})];case 4:return r.sent(),[2,this.changeFileParentsMutation({file:n,parentsToRemove:[t.id],parentsToAdd:e.parentDirectories})]}}))}))},n.prototype.setFileConfidential=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.setFileConfidentialMutation(e))]}))}))},n.prototype.setFileConfidentialMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:Di,variables:{input:{fileId:e.fileId,confidential:e.confidential}}})]}))}))},n.prototype.setDirectoryConfidential=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.setDirectoryConfidentialMutation(e))]}))}))},n.prototype.setDirectoryConfidentialMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:Ei,variables:{input:{directoryId:e.directoryId,confidential:e.confidential}}})]}))}))},n.prototype.prepareParentDirectory=function(t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c;return _(this,(function(u){switch(u.label){case 0:return r=t.directoryId,i=t.wrappingKeyId,a=t.linkType,s=t.directory||{id:r,keyId:i},a!=e.LinkTypeField.REFERENCE?[3,1]:[2,{directoryId:s.id,linkType:a}];case 1:return[4,this.getDirectoryKey(s.id,s.keyId)];case 2:return o=u.sent(),c={directoryId:s.id,wrappingKeyId:o.id},[4,this.keyGraph.wrapKey(o,n)];case 3:return[2,(c.wrappedKey=u.sent(),c.linkType=a,c)]}}))}))},n.prototype.getFileStateKeyId=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Gi,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},n.prototype.prepareCreateFileState=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h;return _(this,(function(y){switch(y.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=y.sent(),(i=t.file)?[4,this.fileUploadService.loadFile(t.file)]:[3,3];case 2:i=y.sent(),y.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,8];case 4:return s=y.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=y.sent(),[3,8];case 6:return[4,this.fileUploadService.uploadEncryptedFile({encryptedContent:s})];case 7:a=y.sent(),y.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([y.sent()]))],h={},[4,this.keyGraph.wrapKey(e,n)];case 10:return[2,c.apply(o,l.concat([(h.wrappedStateKey=y.sent(),h.contentResource=a,h)]))]}}))}))},n.prototype.prepareChangeItemParents=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i=this;return _(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}]}}))}))},n.prototype.prepareItem=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a;return _(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)]}}))}))},n.prototype.prepareCreateDirectory=function(e){var t,n,r;return F(this,void 0,void 0,(function(){var i,a,s,o,c,u,p=this;return _(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 H("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 H("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})]}}))}))},n.prototype.prepareUpdateDirectory=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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})]}}))}))},n.prototype.prepareCreateFile=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i=this;return _(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 i.prepareParentDirectory(e,t)})))];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})]}}))}))},n.prototype.prepareUpdateFile=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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})]}}))}))},n.prototype.prepareChangeDirectoryParents=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=e.directory||{id:e.directoryId,keyId:e.directoryKeyId},[4,this.getDirectoryKey(t.id,t.keyId)];case 1:return n=i.sent(),[4,this.prepareChangeItemParents(e,n.jwk)];case 2:return r=i.sent(),[2,Object.assign(Object.assign({},r),{directoryId:t.id})]}}))}))},n.prototype.prepareChangeFileParents=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=e.file||{id:e.fileId,keyId:e.fileKeyId},[4,this.getFileKey(t.id,t.keyId)];case 1:return n=i.sent(),[4,this.prepareChangeItemParents(e,n.jwk)];case 2:return r=i.sent(),[2,Object.assign(Object.assign({},r),{fileId:t.id})]}}))}))},n.prototype.onLogout=function(){this.tempDirectory=null},n}(At),e.ItemService.TEMP_DIRECTORY_PLAIN_META={kcType:"temp"},e.ItemService.TEMP_DIRECTORY_PLAIN_META_FILTER=JSON.stringify({filter:[{contains:Li.TEMP_DIRECTORY_PLAIN_META}]}),e.ItemService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ItemService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Qr),t.ɵɵinject(Ee),t.ɵɵinject(we),t.ɵɵinject(Ae),t.ɵɵinject(e.LockService),t.ɵɵinject(e.AuthService))},token:e.ItemService,providedIn:"root"}),e.ItemService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ItemService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Qr},{type:Ee},{type:we},{type:Ae},{type:e.LockService},{type:e.AuthService}]},e.ItemService=Li=N([Be({ngZoneName:"ngZone"})],e.ItemService),e.KeyExchangeService=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 T(t,e),t.prototype.getOtKey=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){switch(i.label){case 0:return t?[4,we.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:[fe.COMPACT]})]);case 3:return(r=i.sent()).otKey?[4,we.asKey(r.otKey)]:[3,5];case 4:return[2,i.sent()];case 5:return[2,null]}}))}))},t.prototype.decryptOtk=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o;return _(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 F(this,void 0,void 0,(function(){var r;return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return _(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,we.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,we.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 F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},t.prototype.decryptKeyExchange=function(e,t){return F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var e,n=this;return _(this,(function(r){switch(r.label){case 0:return[4,this.query({query:sn,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 F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.query({query:i?cn:on,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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.query({query:yn,variables:{username:e.username,userId:e.userId}})]}))}))},t.prototype.cancelKeyExchange=function(e){return this.mutate(this.cancelKeyExchangeMutation(e))},t.prototype.cancelKeyExchangeMutation=function(e){return new it({mutation:un,variables:{input:{id:e}}})},t.prototype.declineKeyExchange=function(e,t){return this.mutate(this.declineKeyExchangeMutation(e,t))},t.prototype.declineKeyExchangeMutation=function(e,t){return new it({mutation:pn,variables:{input:{id:e,token:t}}})},t.prototype.initiateOtk=function(e){return void 0===e&&(e={}),F(this,void 0,void 0,(function(){var t;return _(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.initiateOtkMutation=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return F(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,h,y,f,v;return _(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(),h={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},y=this.keyService.currentRootKey,[4,this.keyGraph.encryptToString(y.jwk,h)];case 6:return f=m.sent(),v=e.toJSON(!0).k,[2,{lrMutation:new it({mutation:dn,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.respondOtk=function(e){return this.mutate(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 F(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I,w,K,P,k,R,D,E,A,M,O,T,j,N,F,$,L,U,x,q,J,G,Q,W,B,V,Z,H,Y,X,z,ee;return _(this,(function(_){switch(_.label){case 0:return e=this.keyService.currentRootKey,o=this.keyService.currentMasterKey,[4,this.keyFactory.createKey()];case 1:return c=_.sent(),[4,this.keyFactory.createKey()];case 2:return u=_.sent(),[4,this.encryptionService.encrypt(e.jwk,c.toJSON(!0))];case 3:return p=_.sent(),[4,this.encryptionService.encrypt(o.jwk,u.toJSON(!0))];case 4:return d=_.sent(),[4,we.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 5:return l=_.sent(),[4,we.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 6:return h=_.sent(),[4,we.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 7:return y=_.sent(),f=this.keyService.currentPxk,v=this.keyService.currentSigPxk,[4,this.encryptionService.sign(v.jwk,h.toJSON())];case 8:return m=_.sent(),[4,this.encryptionService.sign(v.jwk,y.toJSON())];case 9:return g=_.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?(b=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,19];case 10:return I=_.sent(),[4,this.keyFactory.createKey()];case 11:return F=_.sent(),$=this.keyService.currentSigPxk,w={},P=(K=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,I.toJSON(!0))];case 12:return w.receiverWrappedKey=P.apply(K,[_.sent()]),w.receiverWrappingKeyId=e.id,a?(D=(R=JSON).stringify,[4,this.encryptionService.encrypt(I,a.receiverCipherDataClearJson)]):[3,14];case 13:return k=D.apply(R,[_.sent()]),[3,15];case 14:k="",_.label=15;case 15:return w.receiverCipherData=k,A=(E=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 16:return w.sharedWrappedKey=A.apply(E,[_.sent()]),C=w,[4,this.encryptionService.encrypt(F,b)];case 17:return B=_.sent(),M=C,T=(O=JSON).stringify,[4,this.encryptionService.sign($.jwk,B)];case 18:M.sharedCipherDataSig=T.apply(O,[_.sent()]),C.sigPxkId=$.id,S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherKey:F.toJSON(!0)}),_.label=19;case 19:return s?[4,this.keyFactory.createKey()]:[3,31];case 20:return N=_.sent(),[4,this.keyFactory.createKey()];case 21:return F=_.sent(),$=this.keyService.currentSigPxk,L={},x=(U=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,N.toJSON(!0))];case 22:return L.ownerWrappedKey=x.apply(U,[_.sent()]),L.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(G=(J=JSON).stringify,[4,this.encryptionService.encrypt(N,s.ownerCipherDataClearJson)]):[3,24];case 23:return q=G.apply(J,[_.sent()]),[3,25];case 24:q="",_.label=25;case 25:return L.ownerCipherData=q,W=(Q=JSON).stringify,[4,this.encryptionService.encrypt(c,F.toJSON(!0))];case 26:return L.sharedWrappedKey=W.apply(Q,[_.sent()]),j=L,[4,this.encryptionService.encrypt(F,s.sharedCipherDataClearJson)];case 27:return B=_.sent(),V=j,H=(Z=JSON).stringify,[4,this.encryptionService.sign($.jwk,B)];case 28:return V.sharedCipherDataSig=H.apply(Z,[_.sent()]),j.sigPxkId=$.id,s.ownerPlainDataJson?(Y=j,z=(X=JSON).stringify,[4,this.encryptionService.sign(v.jwk,s.ownerPlainDataJson)]):[3,30];case 29:Y.ownerPlainDataSig=z.apply(X,[_.sent()]),_.label=30;case 30:S.responder.contactCard=Object.assign(Object.assign({},S.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),_.label=31;case 31:return[4,this.encryptionService.encrypt(l,S)];case 32:return ee=_.sent(),[4,this.encryptionService.encrypt(r.otKey,ee)];case 33:return ee=_.sent(),[2,new it({mutation:ln,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:C,responderContactCard:j}}})]}}))}))},t.prototype.completeOtk=function(e){return this.mutate(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 F(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I,w,K,P,k,R,D,E,A,M,O,T,j,N,F,$,L,U,x,q;return _(this,(function(_){switch(_.label){case 0:return e=this.keyService.currentRootKey,s=this.keyService.currentMasterKey,[4,this.encryptionService.decrypt(e.jwk,n)];case 1:return o=_.sent(),u=this.decryptResponseCipher,[4,we.asKey(o.otKey)];case 2:return p=[_.sent()],[4,we.asKey(o.oneTimePrk)];case 3:return[4,u.apply(this,p.concat([_.sent(),r]))];case 4:if(c=_.sent(),o.nonce!==c.nonce)throw new ne("The nonce returned by responder does not match with the one created by the initiator.");return d=this.keyService.currentSigPxk,[4,we.asKey(c.responder.sigPbk)];case 5:return l=_.sent(),[4,we.asKey(c.responder.pbk)];case 6:return h=_.sent(),[4,this.encryptionService.sign(d.jwk,h.toJSON())];case 7:return y=_.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 8:return f=_.sent(),[4,we.asKey(c.sharedKey)];case 9:return v=_.sent(),[4,this.encryptionService.encrypt(e.jwk,v.toJSON(!0))];case 10:return m=_.sent(),[4,we.asKey(c.mkSharedKey)];case 11:return g=_.sent(),[4,this.encryptionService.encrypt(s.jwk,g.toJSON(!0))];case 12:return S=_.sent(),i?[4,this.keyFactory.createKey()]:[3,16];case 13:return b=_.sent(),I={},K=(w=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,b.toJSON(!0))];case 14:return I.receiverWrappedKey=K.apply(w,[_.sent()]),I.receiverWrappingKeyId=e.id,k=(P=JSON).stringify,[4,this.encryptionService.encrypt(b,i.receiverCipherDataClearJson)];case 15:I.receiverCipherData=k.apply(P,[_.sent()]),C=I,_.label=16;case 16:return o.initiatorContactCard?(E=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,25];case 17:return A=_.sent(),[4,we.asKey(c.responder.contactCard.sharedCipherKey)];case 18:return M=_.sent(),j=(T=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,A.toJSON(!0))];case 19:return O=j.apply(T,[_.sent()]),(N=(null==a?void 0:a.ownerCipherDataClearJson)||E.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(A,N)]:[3,21];case 20:return $=_.sent(),[3,22];case 21:$="",_.label=22;case 22:return F=$,R={ownerWrappedKey:O,ownerWrappingKeyId:e.id,ownerCipherData:F},D={sigPxkId:d.id},[4,this.encryptionService.encrypt(M,E.sharedCipherDataClearJson)];case 23:return L=_.sent(),U=D,q=(x=JSON).stringify,[4,this.encryptionService.sign(d.jwk,L)];case 24:U.sharedCipherDataSig=q.apply(x,[_.sent()]),_.label=25;case 25:return[2,new it({mutation:hn,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(f),rkWrappedSharedKey:JSON.stringify(m),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:C,initiatorContactCardCipher:R,initiatorContactCardSharedCipher:D}}})]}}))}))},t}(At),e.KeyExchangeService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.KeyExchangeService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(we),t.ɵɵinject(Ee),t.ɵɵinject(be),t.ɵɵinject(Ae))},token:e.KeyExchangeService,providedIn:"root"}),e.KeyExchangeService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.KeyExchangeService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:we},{type:Ee},{type:be},{type:Ae}]},e.KeyExchangeService=N([Be({ngZoneName:"ngZone"})],e.KeyExchangeService);var Qi="LBOP";(e.KcLbopErrorCode||(e.KcLbopErrorCode={})).INVALID_PASSPHRASE="INVALID_PASSPHRASE";var Wi,Bi,Vi,Zi,Hi,Yi=k.default(Wi||(Wi=x(["\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"]))),Xi=k.default(Bi||(Bi=x(["\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"]))),zi=k.default(Vi||(Vi=x(["\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"]))),ea=k.default(Zi||(Zi=x(["\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"]))),ta=k.default(Hi||(Hi=x(["\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"]))),na=function(){function t(e,t,n,r,i,a,s,o){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.keyFactory=i,this.keyService=a,this.encryptionService=s,this.passwordService=o,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 F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Xi,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 F(this,void 0,void 0,(function(){var e,r,i;return _(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:zi,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 3:return[2,a.sent().updateLbop]}}))}))},t.prototype.get=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:ea,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 F(this,void 0,void 0,(function(){var e,t,n=this;return _(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:ta})];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 F(n,void 0,void 0,(function(){var n;return _(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 F(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g;return _(this,(function(S){switch(S.label){case 0:if(1024!==b.Slip39Helper.WORD_LIST.length)throw new Y("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=S.sent(),r=function(){n=i.keyFactory.randomChoices(b.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 h=S.sent(),y=this.keyService.currentMasterKey,[4,this.encryptionService.encrypt(s,y.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(y.jwk,v)];case 8:return m=S.sent(),[4,this.lrApollo.mutate({mutation:Yi,variables:{input:{cipherMeta:JSON.stringify(m),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(l.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(h),masterKeyId:y.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 F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g;return _(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.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 h=S.sent(),y=t.challenge.serverNonce,[4,this.encryptionService.sign(h,{serverNonce:y,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 V(new B({source:Qi,code:e.KcLbopErrorCode.INVALID_PASSPHRASE,message:"Invalid passphrase."}))}}))}))},t.prototype.verifyContact=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},t.prototype.confirmContact=function(e){return F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return _(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=we).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 F(this,void 0,void 0,(function(){var t,n,r,i;return _(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 ae("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}();na.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new na(t.ɵɵinject(Ke),t.ɵɵinject(m.HttpClient),t.ɵɵinject(Me),t.ɵɵinject(a.AuthClass),t.ɵɵinject(we),t.ɵɵinject(Ee),t.ɵɵinject(be),t.ɵɵinject(er))},token:na,providedIn:"root"}),na.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],na.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:m.HttpClient},{type:Me},{type:a.AuthClass},{type:we},{type:Ee},{type:be},{type:er}]};var ra=function(){function e(){}return e.forRoot=function(r){return{ngModule:e,providers:[{provide:Ke,useValue:r},{provide:a.AuthClass,useValue:M.default},{provide:t.APP_INITIALIZER,useFactory:jt,deps:[Ke,a.AuthClass],multi:!0},{provide:n.APOLLO_OPTIONS,useFactory:Re,deps:[Ke,a.AuthClass]}]}},e}();ra.decorators=[{type:t.NgModule,args:[{imports:[m.HttpClientModule,C.NgIdleKeepaliveModule.forRoot()]}]}];var ia,aa,sa,oa,ca,ua=$e(ia||(ia=x(["\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"]))),pa=$e(aa||(aa=x(["\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"]))),da=$e(sa||(sa=x(["\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"]))),la=$e(oa||(oa=x(["\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"]))),ha=$e(ca||(ca=x(["\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 T(t,e),t.prototype.updateNotification=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateNotificationMutation(e))]}))}))},t.prototype.updateNotificationMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:ua,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.updateAllNotificationsReadState=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateAllNotificationsReadStateMutation(e))]}))}))},t.prototype.updateAllNotificationsReadStateMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:pa,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.debugCreateNotification=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.debugCreateNotificationMutation(e))]}))}))},t.prototype.debugCreateNotificationMutation=function(e){var t;return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,new it({mutation:da,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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.debugDeleteAllNotificationsMutation(e))]}))}))},t.prototype.debugDeleteAllNotificationsMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:la,variables:{input:{receiverId:e.receiverId}}})]}))}))},t.prototype.updateNotificationFeatureState=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateNotificationFeatureStateMutation(e))]}))}))},t.prototype.updateNotificationFeatureStateMutation=function(e){var t;return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,new it({mutation:ha,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=N([Be({ngZoneName:"ngZone"})],e.NotificationService);var ya,fa,va,ma,ga,Sa,Ca,ba,Ia,wa,Ka=$e(ya||(ya=x(["\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"]))),Pa=$e(fa||(fa=x(["\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"]))),ka=$e(va||(va=x(["\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"]))),Ra=$e(ma||(ma=x(["\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"]))),Da=$e(ga||(ga=x(["\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"]))),Ea=$e(Sa||(Sa=x(["\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"]))),Aa=$e(Ca||(Ca=x(["\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"]))),Ma=$e(ba||(ba=x(["\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"]))),Oa=$e(Ia||(Ia=x(["\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.PlanService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return T(t,e),t.prototype.initiateStripePaymentMethodCapture=function(){return this.mutate(this.initiateStripePaymentMethodCaptureMutation())},t.prototype.initiateStripePaymentMethodCaptureMutation=function(){return new it({mutation:Ka,variables:{input:{}}})},t.prototype.completeStripePaymentMethodCapture=function(e){return this.mutate(this.completeStripePaymentMethodCaptureMutation(e))},t.prototype.completeStripePaymentMethodCaptureMutation=function(e){return new it({mutation:Pa,variables:{input:{stripeIntentId:e}}})},t.prototype.setDefaultPaymentMethod=function(e){return this.mutate(this.setDefaultPaymentMethodMutation(e))},t.prototype.setDefaultPaymentMethodMutation=function(e){return new it({mutation:Ra,variables:{input:{paymentMethodId:e}}})},t.prototype.removeDefaultPaymentMethod=function(){return this.mutate(this.removeDefaultPaymentMethodMutation())},t.prototype.removeDefaultPaymentMethodMutation=function(){return new it({mutation:Da,variables:{input:{}}})},t.prototype.issuePlan=function(e){return this.mutate(this.issuePlanMutation(e))},t.prototype.issuePlanMutation=function(e){return new it({mutation:Ea,variables:{input:e}})},t.prototype.removePaymentMethod=function(e){return this.mutate(this.removePaymentMethodMutation(e))},t.prototype.removePaymentMethodMutation=function(e){return new it({mutation:ka,variables:{input:{paymentMethodId:e}}})},t.prototype.cancelPlan=function(e){return this.mutate(this.cancelPlanMutation(e))},t.prototype.cancelPlanMutation=function(e){return new it({mutation:Aa,variables:{input:e}})},t.prototype.changePriceOption=function(e){return this.mutate(this.changePriceOptionMutation(e))},t.prototype.changePriceOptionMutation=function(e){return new it({mutation:Ma,variables:{input:e}})},t.prototype.reactivatePlan=function(e){return this.mutate(this.reactivatePlanMutation(e))},t.prototype.reactivatePlanMutation=function(e){return new it({mutation:Oa,variables:{input:{planId:e}}})},t}(At),e.PlanService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.PlanService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.PlanService,providedIn:"root"}),e.PlanService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.PlanService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.PlanService=N([Be({ngZoneName:"ngZone"})],e.PlanService),function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(wa||(wa={}));var Ta=[wa.Name,wa.Email,wa.Image,wa.Phone,wa.Address],ja=function(){function t(e,t,n){this.sharedContactCardService=e,this.profileService=t,this.api=n}return t.prototype.updateDetails=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return console.log("updateDetails()"),[4,this.fetchMainContactCard()];case 1:return t=r.sent(),[4,this.profileService.updateDetails(null==t?void 0:t.id,null==t?void 0:t.keyId,e)];case 2:return n=r.sent(),[4,this.synchronizeContactCards(e,null==t?void 0:t.fields)];case 3:return r.sent(),[2,n]}}))}))},t.prototype.updateTrustedPartyDetails=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=j(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]}}))}))},t.prototype.synchronizeSharedDetails=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,h;return _(this,(function(y){switch(y.label){case 0:return t=!1,[4,this.fetchMainContactCard()];case 1:if(n=y.sent(),e.name&&(u=this.checkField(e.name,n.fields.name))&&(n.fields.name=u,t=!0),e.email&&(u=this.checkField(e.email,n.fields.email))&&(n.fields.email=u,t=!0),e.image&&(u=this.checkField(e.image,n.fields.image))&&(n.fields.image=u,t=!0),e.phones&&e.phones.length)try{for(r=$(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,n.fields.phone,a.label))&&(n.fields.phone=u,t=!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=$(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,n.fields.address,c.label))&&(n.fields.address=u,t=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(h=s.return)&&h.call(s)}finally{if(l)throw l.error}}return t?[4,this.profileService.updateDetails(n.id,n.keyId,n.fields)]:[3,3];case 2:y.sent(),y.label=3;case 3:return[2]}}))}))},t.prototype.fetchMainContactCard=function(){var e;return F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.api.query({query:Gn})];case 1:return[2,(t=null===(e=n.sent().contactCards.edges[0])||void 0===e?void 0:e.node)?{id:t.id,keyId:t.key.id,fields:t.cipherDataClearJson}:null]}}))}))},t.prototype.getTrustedParties=function(){return F(this,void 0,void 0,(function(){var e=this;return _(this,(function(t){switch(t.label){case 0:return[4,this.api.query({query:Jn})];case 1:return[2,Mt(t.sent().tps).map((function(t){return e.mapTrustedParty(t)}))]}}))}))},t.prototype.mapTrustedParty=function(t){var n,r,i=t.sharedContactCard.sharedCipherDataClearJson,a=Object.assign(Object.assign({},t.myContactCard.sharedCipherDataClearJson),{id:t.myContactCard.id,ownedKeyId:t.myContactCard.ownerKey.id,sharedKeyId:t.myContactCard.sharedKey.id});return{id:t.id,type:e.TrustedPartyType.User,hasScenarios:!!t.sharedScenarios.edges.length,hasSharedVault:!!t.theirItems.directories.edges.length,name:null===(n=null==i?void 0:i.name)||void 0===n?void 0:n.name,details:i,mySharedDetails:a,userSharedKey:t.currentUserSharedKey.userSharedKey,username:t.other.username,features:{sharedVault:{hasAccess:"access"===((null===(r=t.other.features)||void 0===r?void 0:r.shareVault)||["noaccess"])[0]}}}},t.prototype.synchronizeContactCards=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return _(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.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=$(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]}}))}))},t.prototype.getChanges=function(e,t){var n,r,i,a,s,o=[];try{for(var c=$(Ta),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?E.default(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 h=(i=void 0,$(d.values)),y=h.next();!y.done;y=h.next()){l(y.value)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=h.return)&&a.call(h)}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},t.prototype.synchronizeSharedContactCard=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return _(this,(function(h){switch(h.label){case 0:n=!1,r=function(t){switch(t.field){case wa.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case wa.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];E.default(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=$(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=j(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:h.sent(),h.label=2;case 2:return[2]}}))}))},t.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!E.default(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},t}();ja.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new ja(t.ɵɵinject(Tn),t.ɵɵinject(Qn),t.ɵɵinject(e.ɵg))},token:ja,providedIn:"root"}),ja.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],ja.ctorParameters=function(){return[{type:Tn},{type:Qn},{type:e.ɵg}]};var Na=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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(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"),F(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,h,y,f,v,m;return _(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 h=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:h}).toPromise()];case 10:return y=g.sent(),f={},y.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(y.id),user_pre_sign_up_token:String(y.pre_sign_up_token)}})];case 11:return[2,{username:(m=g.sent()).user.getUsername(),userId:y.id,preSignUpToken:y.pre_sign_up_token,userSub:m.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return F(this,void 0,void 0,(function(){var t;return _(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}();Na.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new Na(t.ɵɵinject(Ke),t.ɵɵinject(a.AuthClass),t.ɵɵinject(m.HttpClient),t.ɵɵinject(we),t.ɵɵinject(be),t.ɵɵinject(er))},token:Na,providedIn:"root"}),Na.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],Na.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[Ke]}]},{type:a.AuthClass},{type:m.HttpClient},{type:we},{type:be},{type:er}]};var Fa,_a,$a,La=function(){},Ua=$e(Fa||(Fa=x(["\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"]))),xa=$e(_a||(_a=x(["\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"]))),qa=$e($a||($a=x(["\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 T(t,e),t.prototype.createReminder=function(e){return this.mutate(this.createReminderMutation(e))},t.prototype.createReminderMutation=function(e){var t;return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,new it({mutation:Ua,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 F(this,void 0,void 0,(function(){return _(this,(function(r){return[2,new it({mutation:xa,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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:qa,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=N([Be({ngZoneName:"ngZone"})],e.ReminderService);var Ja,Ga,Qa,Wa,Ba,Va,Za,Ha,Ya,Xa,za=$e(Ja||(Ja=x(["\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"]))),es=$e(Ga||(Ga=x(["\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"]))),ts=$e(Qa||(Qa=x(["\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"]))),ns=$e(Wa||(Wa=x(["\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"]))),rs=$e(Ba||(Ba=x(["\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"]))),is=$e(Va||(Va=x(["\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"]))),as=$e(Za||(Za=x(["\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"]))),ss=$e(Ha||(Ha=x(["\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"]))),os=$e(Ya||(Ya=x(["\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"]))),cs=$e(Xa||(Xa=x(["\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"])));e.ɵm=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 T(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.sharedKey.id},t}(cr),e.ɵm.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.ɵm(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR))},token:e.ɵm,providedIn:"root"}),e.ɵm.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵm.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector}]},e.ɵm=N([Be({ngZoneName:"ngZone"})],e.ɵm);var us,ps,ds=$e(us||(us=x(["\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 receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\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 file {\n id\n keyId\n }\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 receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\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 file {\n id\n keyId\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),ls=$e(ps||(ps=x(["\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 receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n }\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 assemblyKeyId\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 receiverItems {\n receiverDirectories {\n edges {\n node {\n id\n }\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 assemblyKeyId\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));function hs(){throw new H("claimId does not match with the current claimId of the scenario")}function ys(){throw new ee("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.itemService=i,o.assemblyController=a,o.encryptionService=s,o.prepareAddReceiverDirectory=o.prepareReceiverDirectory,o.prepareUpdateReceiverDirectory=o.prepareReceiverDirectory,o.prepareAddReceiverFile=o.prepareReceiverFile,o.prepareUpdateReceiverFile=o.prepareReceiverFile,o}return T(n,t),n.prototype.createScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createScenarioMutation(e))]}))}))},n.prototype.createScenarioMutation=function(e){return F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.prepareCreateScenarioMutation(e)];case 1:return t=n.sent(),[2,new it({mutation:za,variables:{input:t}})]}}))}))},n.prototype.updateScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateScenarioMutation(e))]}))}))},n.prototype.updateScenarioMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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 it({mutation:es,variables:{input:n}})]}}))}))},n.prototype.resetScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.resetScenarioMutation(e))]}))}))},n.prototype.resetScenarioMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i;return _(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=Mt(n.subAssemblies).map((function(e){var t=Mt(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 it({mutation:es,variables:{input:i}})]}}))}))},n.prototype.deleteScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.lrGraphQL.lrMutate(this.deleteScenarioMutation(e))]}))}))},n.prototype.deleteScenarioMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:ts,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.createClaim=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createClaimMutation(e))]}))}))},n.prototype.createClaimMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:ns,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.cancelClaim=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.cancelClaimMutation(e))]}))}))},n.prototype.cancelClaimMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:rs,variables:{input:{claimId:e}}})]}))}))},n.prototype.rejectClaim=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.mutate(this.rejectClaimMutation(e,t))]}))}))},n.prototype.rejectClaimMutation=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return[4,this.prepareRejectClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=st).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.approveClaim=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.mutate(this.approveClaimMutation(e,t))]}))}))},n.prototype.approveClaimMutation=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return[4,this.prepareApproveClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=st).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.receiveClaim=function(e,t){return F(this,void 0,void 0,(function(){return _(this,(function(n){return[2,this.mutate(this.receiveClaim2Mutation(e,t))]}))}))},n.prototype.receiveClaim2Mutation=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return n=it.bind,r={mutation:ss},i={},[4,this.prepareReceiveClaim2(e,t)];case 1:return[2,new(n.apply(it,[void 0,(r.variables=(i.input=a.sent(),i),r)]))]}}))}))},n.prototype.debugExpireClaim=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.debugExpireClaimMutation(e))]}))}))},n.prototype.debugExpireClaimMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:os,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.getScenario=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.query({query:ds,variables:{scenarioId:e}})]}))}))},n.prototype.getSharedScenario=function(e,t){return F(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return[4,this.query({query:ls,variables:{scenarioId:e}})];case 1:return n=r.sent(),t&&n.sharedScenario.sharedClaim.id!==t&&hs(),[2,n]}}))}))},n.prototype.getParticipantTpsKeys=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=e.map((function(e){return e.tpId})),n=Mt,[4,this.lrGraphQL.query({query:or,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 F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p=this;return _(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,inactiveSeconds:e.inactiveSeconds,createAssembly:r,createReceivers:c,createClaimants:u}]}}))}))},n.prototype.prepareUpdateScenario=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m,g,S,C,b,I=this;return _(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,F(I,void 0,void 0,(function(){var r;return _(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 I.prepareCreateReceiver(e,n)})))]:[3,7];case 6:p=w.sent(),w.label=7;case 7:return u=p,d=Mt(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 I.prepareUpdateReceiver(e,n,t)})))]:[3,9];case 8:return h=w.sent(),[3,10];case 9:h=[],w.label=10;case 10:return l=h,e.updateAssembly?(y=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(y,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 I.prepareCreateClaimant(e)})))]:[3,14];case 13:g=w.sent(),w.label=14;case 14:return m=g,S=Mt(t.claimants),(b=e.updateClaimants)?[4,Promise.all(e.updateClaimants.map((function(e){var t=S.find((function(t){return t.tp.id===e.tpId}));return I.prepareUpdateClaimant(e,t.sharedKey.id)})))]:[3,16];case 15:b=w.sent(),w.label=16;case 16:return C=b,[2,{scenarioId:e.scenarioId,enabled:e.enabled,inactiveSeconds:e.inactiveSeconds,updateAssembly:r,createReceivers:u,updateReceivers:l,deleteReceivers:e.deleteReceivers,createClaimants:m,updateClaimants:C,deleteClaimants:e.deleteClaimants}]}}))}))},n.prototype.prepareReceiverItem=function(t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d;return _(this,(function(l){switch(l.label){case 0:return n=t.receiverItemOptions,r=t.receiverSharedKey,i=t.assemblyKey,a=t.directory,s=t.file,function(e){var t=Object.keys(e);if(t.length<2)throw new Y("You must provide 2 or more fields in the argument.");if(1!=t.filter((function(t){return null!=e[t]})).length)throw new Y("You must provide exactly one argument that != null.")}({directory:a,file:s}),(o=n.accessRole)!=e.AccessRoleChoice.DENY?[3,1]:(d={accessRole:o,itemKeyId:null,wrappedItemKey:null,sharedCipherData:null},a?[2,Object.assign(Object.assign({},d),{directoryId:a.id})]:[2,Object.assign(Object.assign({},d),{fileId:s.id})]);case 1:return c=void 0,a?[4,this.itemService.getDirectoryKey(a.id,a.keyId)]:[3,3];case 2:return c=l.sent(),[3,5];case 3:return[4,this.itemService.getFileKey(s.id,s.keyId)];case 4:c=l.sent(),l.label=5;case 5:return[4,this.keyGraph.encryptToString(r,c.jwk.toJSON(!0))];case 6:return u=l.sent(),[4,this.keyGraph.encryptToString(r,n.sharedCipherDataClearJson||"")];case 7:return p=l.sent(),[4,this.keyGraph.encryptToString(i,u)];case 8:return u=l.sent(),d={accessRole:o,itemKeyId:c.id,wrappedItemKey:u,sharedCipherData:p},a?[2,Object.assign(Object.assign({},d),{directoryId:a.id})]:[2,Object.assign(Object.assign({},d),{fileId:s.id})];case 9:return[2]}}))}))},n.prototype.prepareReceiverDirectory=function(e,t,n){return F(this,void 0,void 0,(function(){return _(this,(function(r){return[2,this.prepareReceiverItem({receiverItemOptions:e,receiverSharedKey:t,assemblyKey:n,directory:{id:e.directoryId,keyId:e.directoryKeyId}})]}))}))},n.prototype.prepareReceiverFile=function(e,t,n){return F(this,void 0,void 0,(function(){return _(this,(function(r){return[2,this.prepareReceiverItem({receiverItemOptions:e,receiverSharedKey:t,assemblyKey:n,file:{id:e.fileId,keyId:e.fileKeyId}})]}))}))},n.prototype.prepareCreateReceiver=function(e,t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u=this;return _(this,(function(p){switch(p.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return n=p.sent(),r=n.sharedKey,i=n.mutationInput,(s=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return u.prepareAddReceiverDirectory(e,r.key,t)})))]:[3,3];case 2:s=p.sent(),p.label=3;case 3:return a=s,(c=e.addFiles)?[4,Promise.all(e.addFiles.map((function(e){return u.prepareAddReceiverFile(e,r.key,t)})))]:[3,5];case 4:c=p.sent(),p.label=5;case 5:return o=c,[2,Object.assign(Object.assign({},i),{addDirectories:a,addFiles:o})]}}))}))},n.prototype.prepareUpdateReceiver=function(e,t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,h,y,f,v,m=this;return _(this,(function(g){switch(g.label){case 0:return r=n.sharedKey.id,i=e.deleteDirectories||[],a=e.updateDirectories||[],s=e.deleteFiles||[],o=e.updateFiles||[],Mt(n.receiverItems.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,directoryKeyId:e.directory.keyId,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),Mt(n.receiverItems.receiverFiles).forEach((function(e){s.includes(e.file.id)||o.find((function(t){return t.fileId===e.file.id}))||o.push({accessRole:e.accessRole,fileId:e.file.id,fileKeyId:e.file.keyId,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),[4,this.prepareUpdateParticipant(e,r)];case 1:return c=g.sent(),u=c.sharedKey,p=c.mutationInput,(l=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return m.prepareAddReceiverDirectory(e,u,t)})))]:[3,3];case 2:l=g.sent(),g.label=3;case 3:return d=l,(y=e.addFiles)?[4,Promise.all(e.addFiles.map((function(e){return m.prepareAddReceiverFile(e,u,t)})))]:[3,5];case 4:y=g.sent(),g.label=5;case 5:return h=y,[4,Promise.all(a.map((function(e){return m.prepareUpdateReceiverDirectory(e,u,t)})))];case 6:return f=g.sent(),[4,Promise.all(o.map((function(e){return m.prepareUpdateReceiverFile(e,u,t)})))];case 7:return v=g.sent(),[2,Object.assign(Object.assign({},p),{addDirectories:d,addFiles:h,updateDirectories:f,updateFiles:v,deleteDirectories:e.deleteDirectories,deleteFiles:e.deleteFiles})]}}))}))},n.prototype.prepareExistingReceiver=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(this,(function(i){return n=Mt(e.receiverItems.receiverDirectories).map((function(e){var t=e.accessRole,n=e.sharedCipherDataClearJson,r=e.directory;return{accessRole:t,sharedCipherDataClearJson:n,directoryId:r.id,directoryKeyId:r.keyId}})),r=Mt(e.receiverItems.receiverFiles).map((function(e){var t=e.accessRole,n=e.sharedCipherDataClearJson,r=e.file;return{accessRole:t,sharedCipherDataClearJson:n,fileId:r.id,fileKeyId:r.keyId}})),[2,this.prepareUpdateReceiver({tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,updateDirectories:n,updateFiles:r},t,e)]}))}))},n.prototype.prepareExistingReceivers=function(e,t){return F(this,void 0,void 0,(function(){var n=this;return _(this,(function(r){return[2,Promise.all(e.map((function(e){return n.prepareExistingReceiver(e,t)})))]}))}))},n.prototype.prepareCreateParticipant=function(e){return F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this.prepareUpdateParticipant(e,t)];case 1:return[2,n.sent().mutationInput]}}))}))},n.prototype.prepareReceiveClaim2=function(t,n){return F(this,void 0,void 0,(function(){var r,i,a,s,o;return _(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&&ys(),i=Mt(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),[4,this.keyGraph.getKey(r.asReceiver.sharedKey.id)];case 3:return s=c.sent(),[4,this.keyGraph.encryptToString(s,a.toJSON(!0))];case 4:return o=c.sent(),[2,{scenarioClaimId:n,sharedKeyWrappedAssemblyKey:o,sharedKeyId:s.id,assemblyKeyId:r.sharedClaim.asClaimReceiver.assemblyKeyId}]}}))}))},n.prototype.recoverAssemblyKey=function(e){return F(this,void 0,void 0,(function(){var t,n=this;return _(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 F(this,void 0,void 0,(function(){return _(this,(function(r){switch(r.label){case 0:return[4,this.getSharedScenario(e,t)];case 1:return[2,Mt(r.sent().sharedScenario.sharedClaim.claim.asClaimApprovers).filter((function(e){return e.state===n}))]}}))}))},n.prototype.prepareApproveClaimMutations=function(t,n){return F(this,void 0,void 0,(function(){var r=this;return _(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 F(r,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=it.bind,n={mutation:as},r={},[4,this.prepareApproveClaim(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))}))]}}))}))},n.prototype.prepareApproveClaim=function(e){return F(this,void 0,void 0,(function(){var t,n=this;return _(this,(function(r){switch(r.label){case 0:return[4,Promise.all(Mt(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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var r=this;return _(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 F(r,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:is,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(Ae),t.ɵɵinject(e.ItemService),t.ɵɵinject(e.ɵm),t.ɵɵinject(be))},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:Ae},{type:e.ItemService},{type:e.ɵm},{type:be}]},e.ScenarioService=N([Be({ngZoneName:"ngZone"})],e.ScenarioService);var fs,vs=$e(fs||(fs=x(["\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 T(t,e),t.prototype.getConfig=function(){return F(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return null!=this.serverConfig?[3,2]:(e=this,[4,this.query({query:vs,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=N([Be({ngZoneName:"ngZone"})],e.ServerConfigService);var ms,gs,Ss,Cs,bs=$e(ms||(ms=x(["\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}"]))),Is=$e(gs||(gs=x(["\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}"]))),ws=$e(Ss||(Ss=x(["\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}"]))),Ks=$e(Cs||(Cs=x(["\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 F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:ws,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Ks,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 F(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,h,y,f,v,m;return _(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(),h=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 9:return d=h.apply(l,[g.sent()]),v=(f=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 10:return y=v.apply(f,[g.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 11:return m=g.sent(),[2,new it({mutation:bs,variables:{input:{id:t,ownerCipherData:m,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:y}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return F(this,void 0,void 0,(function(){var e,i,a=this;return _(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 it({mutation:Is,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(Ee),t.ɵɵinject(Ae),t.ɵɵinject(be),t.ɵɵinject(e.ɵg))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:t.NgZone},{type:Ee},{type:Ae},{type:be},{type:e.ɵg}]},e.SharedContactCard2Service=N([Be({ngZoneName:"ngZone"})],e.SharedContactCard2Service);var Ps,ks,Rs,Ds,Es,As=$e(Ps||(Ps=x(["\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}"]))),Ms=$e(ks||(ks=x(["\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"])),As),Os=$e(Rs||(Rs=x(["\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"])),As),Ts=($e(Ds||(Ds=x(["\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}"]))),$e(Es||(Es=x(["\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}"]))));e.ɵn=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return T(t,e),t.prototype.getReset=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Ts})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.getSharedResets=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.query({query:Ms})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},t.prototype.getSharedReset=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Os,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},t}(At),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=N([Be({ngZoneName:"ngZone"})],e.ɵn),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 T(n,t),n.prototype.activeRequestOrRaise=function(t){var n=t.sharedRequest.claim.state;if(n!==e.TpAssemblyState.CLAIMED)throw new ee("Claim is already in "+n+" state.")},n.prototype.rejectRequest=function(e){return this.mutate(this.rejectRequestMutation(e))},n.prototype.rejectRequestMutation=function(t){return F(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=r.sent(),this.activeRequestOrRaise(n),[2,st.create(n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})).map((function(e){return new it({mutation:Ar,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},n.prototype.approveRequest=function(e,t){return F(this,void 0,void 0,(function(){var n,r;return _(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 F(this,void 0,void 0,(function(){var n,r,a,s,o,c=this;return _(this,(function(u){switch(u.label){case 0:return[4,this.privateService.getSharedReset(t)];case 1:return n=u.sent(),this.activeRequestOrRaise(n),[4,i.JWK.asKey(JSON.parse(n.sharedRequest.pxk.pbk))];case 2:return r=u.sent(),a=n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})),o=(s=st).create,[4,Promise.all(a.map((function(e){return F(c,void 0,void 0,(function(){var t,n,i=this;return _(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 F(i,void 0,void 0,(function(){var n,i;return _(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 it({mutation:Er,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(be),t.ɵɵinject(e.ɵn))},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:be},{type:e.ɵn}]},e.TpPasswordResetRequestService=N([Be({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService);function js(){!function(e){if(!e)throw new H("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 T(t,e),t.prototype.verifyEmailContact=function(e){return F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return _(this,(function(p){switch(p.label){case 0:return js(),[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(Ke),t.ɵɵinject(we),t.ɵɵinject(be),t.ɵɵinject(er),t.ɵɵinject(m.HttpClient),t.ɵɵinject(a.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:[Ke]}]},{type:we},{type:be},{type:er},{type:m.HttpClient},{type:a.AuthClass}]},e.TpPasswordResetUserService=N([Be({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=tr,a}return T(t,e),t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new it({mutation:Pr})},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new it({mutation:Or})},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 F(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,this.assemblyController.prepareCreate(e)];case 1:return t=n.sent().mutationInput,[2,new it({mutation:Mr,variables:{input:{assembly:Object.assign({},t)}}})]}}))}))},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(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 it({mutation:Tr,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 F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:cs,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.ɵn),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.ɵn},{type:e.ɵi}]},e.TpPasswordResetService=N([Be({ngZoneName:"ngZone"})],e.TpPasswordResetService);var Ns,Fs,_s,$s,Ls,Us,xs,qs,Js,Gs,Qs,Ws,Bs,Vs,Zs,Hs=$e(Ns||(Ns=x(["\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"]))),Ys=$e(Fs||(Fs=x(["\nmutation CreateDirectoryShareMutation($input: CreateDirectoryShareInput!) {\n createDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation CreateDirectoryShareMutation($input: CreateDirectoryShareInput!) {\n createDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),Xs=$e(_s||(_s=x(["\nmutation CreateFileShareMutation($input: CreateFileShareInput!) {\n createFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation CreateFileShareMutation($input: CreateFileShareInput!) {\n createFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),zs=$e($s||($s=x(["\nmutation UpdateDirectoryShareMutation($input: UpdateDirectoryShareInput!) {\n updateDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation UpdateDirectoryShareMutation($input: UpdateDirectoryShareInput!) {\n updateDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),eo=$e(Ls||(Ls=x(["\nmutation UpdateFileShareMutation($input: UpdateFileShareInput!) {\n updateFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation UpdateFileShareMutation($input: UpdateFileShareInput!) {\n updateFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),to=$e(Us||(Us=x(["\nmutation DeleteDirectoryShareMutation($input: DeleteDirectoryShareInput!) {\n deleteDirectoryShare(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteDirectoryShareMutation($input: DeleteDirectoryShareInput!) {\n deleteDirectoryShare(input: $input) {\n id\n }\n}\n"]))),no=$e(xs||(xs=x(["\nmutation DeleteFileShareMutation($input: DeleteFileShareInput!) {\n deleteFileShare(input: $input) {\n id\n }\n}\n"],["\nmutation DeleteFileShareMutation($input: DeleteFileShareInput!) {\n deleteFileShare(input: $input) {\n id\n }\n}\n"]))),ro=$e(qs||(qs=x(["\nmutation CompleteDetachedDirectoryShareMutation($input: CompleteDetachedDirectoryShareInput!) {\n completeDetachedDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"],["\nmutation CompleteDetachedDirectoryShareMutation($input: CompleteDetachedDirectoryShareInput!) {\n completeDetachedDirectoryShare(input: $input) {\n directoryShare {\n id\n }\n }\n}\n"]))),io=$e(Js||(Js=x(["\nmutation CompleteDetachedFileShareMutation($input: CompleteDetachedFileShareInput!) {\n completeDetachedFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"],["\nmutation CompleteDetachedFileShareMutation($input: CompleteDetachedFileShareInput!) {\n completeDetachedFileShare(input: $input) {\n fileShare {\n id\n }\n }\n}\n"]))),ao=$e(Gs||(Gs=x(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),so=$e(Qs||(Qs=x(["\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"]))),oo=$e(Ws||(Ws=x(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"]))),co=$e(Bs||(Bs=x(["\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"]))),uo=$e(Vs||(Vs=x(["\nquery DirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n shareType\n }\n}\n"],["\nquery DirectoryShareQuery($id: LrRelayIdInput!) {\n directoryShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n shareType\n }\n}\n"]))),po=$e(Zs||(Zs=x(["\nquery FileShareItemIdQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n shareType\n }\n}\n"],["\nquery FileShareItemIdQuery($id: LrRelayIdInput!) {\n fileShare(id: $id) {\n item {\n id\n }\n tp {\n id\n }\n shareType\n }\n}\n"])));e.TrustedPartyService=function(t){function n(e,n,r,i,a,s,o){var c=t.call(this,n)||this;return c.ngZone=e,c.injector=n,c.keyGraph=r,c.itemService=i,c.keyService=a,c.keyFactory=s,c.encryptionService=o,c}return T(n,t),n.prototype.deleteTp=function(e){return this.mutate(this.deleteTpMutation(e))},n.prototype.deleteTpMutation=function(e){return new it({mutation:Hs,variables:{input:{id:e}}})},n.prototype.createDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createDirectoryShareMutation(e))]}))}))},n.prototype.createDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:Ys},[4,this.prepareCreateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.createFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.createFileShareMutation(e))]}))}))},n.prototype.createFileShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:Xs},[4,this.prepareCreateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.prepareCreateItemShareMutation=function(t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h,y,f=this;return _(this,(function(v){switch(v.label){case 0:if(n=t.itemId,r=t.itemKeyId,i=t.tpId,a=t.tpSharedKeyId,s=t.accessRole,o=t.isDirectory,c=t.shareType,u=t.plainMetaJson,p=t.item||{id:n,keyId:r},d=u&&JSON.stringify(u),s==e.AccessRoleChoice.DENY){if(p.keyId||a)throw new H("If accessRole is AccessRoleChoice.DENY, must not specify any of itemId, itemKeyId, or tpSharedKeyId parameters");return[2,{input:{itemId:p.id,tpId:i,accessRole:s,itemKeyId:null,wrappingKeyId:null,wrappedItemKey:null,shareType:c,plainMeta:d}}]}return[4,this.keyGraph.getKey(p.keyId,(function(){return o?f.itemService.getDirectoryKeyId(p.id):f.itemService.getFileKeyId(p.id)}))];case 1:return l=v.sent(),[4,this.keyGraph.getKey(a,(function(){return f.getTpCurrentUserSharedKey(i).then((function(e){return e.sharedKey.id}))}))];case 2:return h=v.sent(),[4,this.keyGraph.wrapKey(h,l.jwk)];case 3:return y=v.sent(),[2,{input:{itemId:p.id,tpId:i,accessRole:s,itemKeyId:l.id,wrappingKeyId:h.id,wrappedItemKey:y,shareType:c,plainMeta:d}}]}}))}))},n.prototype.updateDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateDirectoryShareMutation(e))]}))}))},n.prototype.updateDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:zs},[4,this.prepareUpdateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.updateDetachedDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateDetachedDirectoryShareMutation(e))]}))}))},n.prototype.updateDetachedDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:zs},[4,this.prepareUpdateDetachedItemShareMutation(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.updateFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateFileShareMutation(e))]}))}))},n.prototype.updateFileShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:eo},[4,this.prepareUpdateItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.updateDetachedFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.updateDetachedFileShareMutation(e))]}))}))},n.prototype.updateDetachedFileShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:eo},[4,this.prepareUpdateDetachedItemShareMutation(e)];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.getDirectoryShare=function(e){return this.lrGraphQL.query({query:uo,variables:{id:e}})},n.prototype.getFileShare=function(e){return this.lrGraphQL.query({query:po,variables:{id:e}})},n.prototype.prepareUpdateItemShareMutation=function(t){return F(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,h,y,f,v,m=this;return _(this,(function(g){switch(g.label){case 0:if(n=t.itemShareId,r=t.accessRole,i=t.isDirectory,a=t.itemId,s=t.itemKeyId,o=t.tpId,c=t.tpSharedKeyId,u=t.plainMetaJson,p=t.item||{id:a,keyId:s},d=u&&JSON.stringify(u),null==r||r==e.AccessRoleChoice.DENY){if(p.id||p.keyId||o||c)throw new H("If accessRole is AccessRoleChoice.DENY, must not specify any of itemId, itemKeyId, tpId, or tpSharedKeyId parameters");return[2,{input:{id:n,accessRole:r,plainMeta:d}}]}return h=function(){return F(m,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return l?[3,5]:i?[4,this.getDirectoryShare(n)]:[3,2];case 1:return l=t.sent().directoryShare,[3,4];case 2:return[4,this.getFileShare(n)];case 3:l=t.sent().fileShare,t.label=4;case 4:if(l.shareType==e.ShareTypeChoice.DETACHED)throw new H("Use updateDetachedDirectoryShare() or updateDetachedFileShare() to updated DETACHED shares.");t.label=5;case 5:return[2,l]}}))}))},[4,this.keyGraph.getKey(p.keyId,(function(){return F(m,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return(t=p.id)?[3,2]:[4,h()];case 1:t=n.sent().item.id,n.label=2;case 2:return e=t,i?[2,this.itemService.getDirectoryKeyId(e)]:[2,this.itemService.getFileKeyId(e)]}}))}))}))];case 1:return y=g.sent(),[4,this.keyGraph.getKey(c,(function(){return F(m,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return(t=o)?[3,2]:[4,h()];case 1:t=n.sent().tp.id,n.label=2;case 2:return e=t,[4,this.getTpCurrentUserSharedKey(e)];case 3:return[2,n.sent().sharedKey.id]}}))}))}))];case 2:return f=g.sent(),[4,this.keyGraph.wrapKey(f,y.jwk)];case 3:return v=g.sent(),[2,{input:{id:n,accessRole:r,itemKeyId:y.id,wrappingKeyId:f.id,wrappedItemKey:v,plainMeta:d}}]}}))}))},n.prototype.prepareUpdateDetachedItemShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){return t=e.itemShareId,n=e.accessRole,r=e.plainMetaJson,[2,{input:{id:t,accessRole:n,plainMeta:r&&JSON.stringify(r)}}]}))}))},n.prototype.deleteDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.deleteDirectoryShareMutation(e))]}))}))},n.prototype.deleteDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:to,variables:{input:{id:e}}})]}))}))},n.prototype.deleteFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.deleteFileShareMutation(e))]}))}))},n.prototype.deleteFileShareMutation=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,new it({mutation:no,variables:{input:{id:e}}})]}))}))},n.prototype.completeDetachedDirectoryShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.completeDetachedDirectoryShareMutation(e))]}))}))},n.prototype.completeDetachedDirectoryShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:ro},[4,this.prepareCompleteDetachedItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!0}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.completeDetachedFileShare=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){return[2,this.mutate(this.completeDetachedFileShareMutation(e))]}))}))},n.prototype.completeDetachedFileShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return t=it.bind,n={mutation:io},[4,this.prepareCompleteDetachedItemShareMutation(Object.assign(Object.assign({},e),{isDirectory:!1}))];case 1:return[2,new(t.apply(it,[void 0,(n.variables=r.sent(),n)]))]}}))}))},n.prototype.prepareCompleteDetachedItemShareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return _(this,(function(c){switch(c.label){case 0:return t=e.itemShareId,n=e.itemKeyId,r=e.isDirectory,[4,this.keyGraph.getKey(n,(function(){return r?o.itemService.getDirectoryKeyIdFromDirectoryShare(t):o.itemService.getFileKeyIdFromFileShare(t)}))];case 1:return i=c.sent(),a=this.keyService.currentRootKey,[4,this.keyGraph.wrapKey(a,i.jwk)];case 2:return s=c.sent(),[2,{input:{id:t,keyId:i.id,wrappingKeyId:a.id,wrappedKey:s}}]}}))}))},n.prototype.requestMkReshareMutation=function(e){return F(this,void 0,void 0,(function(){var t,n,r,i,a,s;return _(this,(function(o){switch(o.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if((t=o.sent()).mkSharedKey)throw new ee("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 it({mutation:ao,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()]}}))}))},n.prototype.respondMkReshare=function(e){return F(this,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,p,d;return _(this,(function(l){switch(l.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:if(!(t=l.sent()).mkSharedKey)throw new ee("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,i.JWK.asKey(r.pbk)];case 4:return a=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=[a],[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 it({mutation:so,variables:{input:{tpId:e,mkSharedKeyId:s.id,mkReshareResponseCipher:c}}})]}}))}))},n.prototype.completeMkReshare=function(e){return F(this,void 0,void 0,(function(){var t,n,r,a,s,o,c,u,p,d,l;return _(this,(function(h){switch(h.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=h.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=h.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=h.sent(),o=(s=this.encryptionService).decrypt,c=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,o.apply(s,c.concat([h.sent()]))];case 5:return a=h.sent(),p={id:a.mkSharedKey.id},[4,i.JWK.asKey(a.mkSharedKey.jwk)];case 6:return p.jwk=h.sent(),u=p,d=this.keyService.currentMasterKey,[4,this.encryptionService.encryptToString(d.jwk,u.jwk.toJSON(!0))];case 7:return l=h.sent(),[2,new it({mutation:oo,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:u.id,mkWrappedMkSharedKey:l}}})]}}))}))},n.prototype.getTpCurrentUserSharedKey=function(e){return F(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:co,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},n}(At),e.TrustedPartyService.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e.TrustedPartyService(t.ɵɵinject(t.NgZone),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(Ae),t.ɵɵinject(e.ItemService),t.ɵɵinject(Ee),t.ɵɵinject(we),t.ɵɵinject(be))},token:e.TrustedPartyService,providedIn:"root"}),e.TrustedPartyService.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.TrustedPartyService.ctorParameters=function(){return[{type:t.NgZone},{type:t.Injector},{type:Ae},{type:e.ItemService},{type:Ee},{type:we},{type:be}]},e.TrustedPartyService=N([Be({ngZoneName:"ngZone"})],e.TrustedPartyService);var lo=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return F(this,void 0,void 0,(function(){var e;return _(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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){var t;return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){return _(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 F(this,void 0,void 0,(function(){var e,t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=L.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 H("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return F(this,void 0,void 0,(function(){var t;return _(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}();lo.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new lo(t.ɵɵinject(a.AuthClass))},token:lo,providedIn:"root"}),lo.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],lo.ctorParameters=function(){return[{type:a.AuthClass}]};var ho,yo,fo,vo=k.default(ho||(ho=x(["\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"]))),mo=k.default(yo||(yo=x(["\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"]))),go=k.default(fo||(fo=x(["\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"]))),So=function(){function e(e){this.lrApollo=e}return e.prototype.requestUserDelete=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:vo,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return F(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:mo,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),F(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:go,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();So.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new So(t.ɵɵinject(Me))},token:So,providedIn:"root"}),So.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],So.ctorParameters=function(){return[{type:Me}]},e.ApiContactCard=Sn,e.ApiCurrentUser=gn,e.ApproveScenarioClaimMutation=as,e.ApproveTpPasswordResetRequestMutation=Er,e.ArchiveDirectoryMutation=Ci,e.ArchiveFileMutation=bi,e.BeginDeleteChildItemLinksWindowMutation=ki,e.CancelKeyExchangeMutation=un,e.CancelScenarioClaimMutation=rs,e.CancelTpPasswordResetRequestMutation=Pr,e.CancelUserDeleteMutation=mo,e.ChangeDirectoryParentsMutation=Ki,e.ChangeFileParentsMutation=Pi,e.CompleteKeyExchangeOtkMutation=hn,e.CompleteTpPasswordResetRequestMutation=Dr,e.ContactCardAddress=bn,e.ContactCardName=Cn,e.ContactCardsQuery=Gn,e.CreateContactCardMutation=xn,e.CreateDirectoryMutation=hi,e.CreateFileMutation=vi,e.CreateLbopQuery=Yi,e.CreateScenarioClaimMutation=ns,e.CreateScenarioMutation=za,e.CreateTpAssemblyKeyChallengeMutation=kr,e.CreateTpPasswordResetMutation=Mr,e.CurrentUserKey=mn,e.CurrentUserQuery=Un,e.CurrentUserSharedKeyQuery2=yn,e.DebugExpireScenarioClaimMutation=os,e.DebugExpireTpPasswordResetRequestMutation=cs,e.DeclineKeyExchangeMutation=pn,e.DefaultProcessorOptions=Ve,e.DeleteDirectoryMutation=fi,e.DeleteFileMutation=Si,e.DeleteLbopQuery=Xi,e.DeleteScenarioMutation=ts,e.DeleteTpPasswordResetMutation=Or,e.DirectoryQuery=Qe,e.ERROR_SOURCE=Qi,e.Features=vn,e.FetchKeyGraphField=Ge,e.FileUploadService=Qr,e.GetOwnedContactCardKeyIdsQuery=ws,e.GetReceivedContactCardKeyIdQuery=Ks,e.IdleService=Nt,e.InitiateKeyExchangeOtkMutation=dn,e.KC_CONFIG=Ke,e.KcAuthException=Z,e.KcBadArgumentException=H,e.KcBadLogicException=Y,e.KcBadRequestException=X,e.KcBadSignatureException=z,e.KcBadStateException=ee,e.KcBadTimeSyncException=te,e.KcCodeMismatchException=ne,e.KcConcurrentAccessException=re,e.KcEncryptionException=ie,e.KcError=B,e.KcException=V,e.KcInternalErrorException=ae,e.KcLockedException=se,e.KcNotFoundException=oe,e.KcSuspiciousOperationException=ce,e.KcUnsupportedException=ue,e.KeyExchangeFields=rn,e.KeyExchangeQuery2=on,e.KeyExchangeTokenQuery2=cn,e.KeyExchangesQuery2=sn,e.KeyGraphField=Je,e.KeyGraphFragment=qe,e.LbopQuery=ea,e.LbopService=na,e.LbopsQuery=ta,e.LifeReadyModule=ra,e.LoginHistoryQuery=go,e.LrApolloService=Me,e.LrGraphQLService=e.ɵg,e.LrMergedMutation=st,e.LrMutation=it,e.LrMutationBase=rt,e.LrService=At,e.MainContactCardFields=wn,e.MainContactCardPlainFields=Kn,e.MainContactCardProperty=In,e.OwnerPlainDataJson=Gr,e.PasswordCheck=zn,e.PasswordService=er,e.PersistService=De,e.PreCompleteTpPasswordResetRequestMutation=Rr,e.ProfileDetailsService=ja,e.ProfileService=Qn,e.ReceiveScenarioClaimMutation=ss,e.RegisterResult=La,e.RegisterService=Na,e.RejectScenarioClaimMutation=is,e.RejectTpPasswordResetRequestMutation=Ar,e.RequestUserDeleteMutation=vo,e.RespondKeyExchangeOtkMutation=ln,e.RevertFileMutation=gi,e.ServerTimeQuery=me,e.SetDirectoryConfidentialMutation=Ei,e.SetFileConfidentialMutation=Di,e.SharedTrustedPartyDetails=kn,e.SharedVaultFeature=Dn,e.TPFeatures=Rn,e.TempDirectoryQuery=Ri,e.TimeService=ge,e.TrustedPartiesQuery=Jn,e.TrustedParty=An,e.TrustedPartyDetails=Pn,e.TrustedPartyProperties=Ln,e.TwoFactorService=lo,e.UnarchiveDirectoryMutation=Ii,e.UnarchiveFileMutation=wi,e.UpdateContactCardMutation=qn,e.UpdateDirectoryMutation=yi,e.UpdateFileMutation=mi,e.UpdateLbopQuery=zi,e.UpdateOwnedContactCardMutation=bs,e.UpdateReceivedContactCardMutation=Is,e.UpdateScenarioMutation=es,e.UpdateTpPasswordResetMutation=Tr,e.UserService=So,e.UserSharedKeyFields=an,e.WebCryptoService=Ie,e.awsFetch=Tt,e.configureAmplifyAuth=jt,e.configureApollo=Re,e.fragmentSpreadAstSelection=nt,e.gqlTyped=$e,e.handleApolloError=Q,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.httpOptions=ke,e.mapEdges=Mt,e.processConnection=Ze,e.throwClaimIdMismatch=hs,e.throwClaimNotApproved=ys,e.toIdKeyPair=function(e){return void 0===e?void 0:null===e?null:{id:e.id,keyId:e.keyId}},e.ɵa=Ae,e.ɵb=be,e.ɵc=Ee,e.ɵd=we,e.ɵe=At,e.ɵf=Be,e.ɵh=Bt,e.ɵj=cr,e.ɵk=Mn,e.ɵl=Tn,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=lifeready-core.umd.min.js.map
|