@lifeready/core 1.0.19 → 1.0.21

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.
Files changed (30) hide show
  1. package/bundles/lifeready-core.umd.js +157 -128
  2. package/bundles/lifeready-core.umd.js.map +1 -1
  3. package/bundles/lifeready-core.umd.min.js +1 -1
  4. package/bundles/lifeready-core.umd.min.js.map +1 -1
  5. package/esm2015/lib/api/key-exchange.types.js +1 -1
  6. package/esm2015/lib/api/message.service.js +1 -1
  7. package/esm2015/lib/api/types/lr-graphql.types.js +18 -9
  8. package/esm2015/lib/auth/auth.gql.js +1 -6
  9. package/esm2015/lib/auth/password.service.js +3 -8
  10. package/esm2015/lib/items2/item2.gql.js +10 -22
  11. package/esm2015/lib/items2/item2.gql.private.js +23 -0
  12. package/esm2015/lib/items2/item2.service.js +19 -2
  13. package/esm2015/lib/items2/item2.types.js +1 -1
  14. package/esm2015/lib/scenario/scenario.service.js +1 -2
  15. package/esm2015/lib/trusted-parties/tp-assembly.js +8 -5
  16. package/esm2015/lib/trusted-parties/tp-assembly.types.js +1 -1
  17. package/esm2015/lib/trusted-parties/tp-password-reset.service.js +1 -1
  18. package/fesm2015/lifeready-core.js +73 -46
  19. package/fesm2015/lifeready-core.js.map +1 -1
  20. package/lib/api/key-exchange.types.d.ts +2 -2
  21. package/lib/api/message.service.d.ts +5 -4
  22. package/lib/api/types/lr-graphql.types.d.ts +18 -2
  23. package/lib/items2/item2.gql.d.ts +8 -18
  24. package/lib/items2/item2.gql.private.d.ts +19 -0
  25. package/lib/items2/item2.service.d.ts +8 -1
  26. package/lib/items2/item2.types.d.ts +9 -5
  27. package/lib/trusted-parties/tp-assembly.types.d.ts +5 -3
  28. package/lib/trusted-parties/tp-password-reset.service.d.ts +3 -3
  29. package/lifeready-core.metadata.json +1 -1
  30. package/package.json +1 -1
@@ -12,5 +12,5 @@
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */function w(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}K(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function P(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 D(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 R(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(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 A(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 O(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 T(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(O(arguments[t]));return e}function M(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}Object.create;function j(e){if(e&&e.length){var t=e.map((function(e){return{code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,message:e.message,debug:{locations:e.locations,path:e.path}}}));throw new(L.bind.apply(L,T([void 0],t)))}}var $,N,F=function(){},L=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.errors=e}return e.prototype.toString=function(){return this.errors.map((function(e){return JSON.stringify(e,null,2)}))},e}();($=e.LrApiErrorCode||(e.LrApiErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",$.BAD_ARGUMENT="BAD_ARGUMENT",$.BAD_SIGNATURE="BAD_SIGNATURE",$.BAD_STATE="BAD_STATE",$.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",$.CONCURRENT_ACCESS="CONCURRENT_ACCESS",$.CONFIG_ERROR="CONFIG_ERROR",$.CYCLE_DETECTED="CYCLE_DETECTED",$.EXPIRED="EXPIRED",$.INVALID_TOKEN="INVALID_TOKEN",$.INTERNAL_ERROR="INTERNAL_ERROR",$.JSON_DECODE_ERROR="JSON_DECODE_ERROR",$.KEY_MISMATCH="KEY_MISMATCH",$.LIMIT_REACHED="LIMIT_REACHED",$.LOCKED="LOCKED",$.LOGIC_ERROR="LOGIC_ERROR",$.LR_DEBUG_ONLY="LR_DEBUG_ONLY",$.MIN_DELAY="MIN_DELAY",$.MISSING_FIELD="MISSING_FIELD",$.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",$.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",$.NOT_IMPLEMENTED="NOT_IMPLEMENTED",$.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",$.OBJECT_EXISTS="OBJECT_EXISTS",$.RANGE_ERROR="RANGE_ERROR",$.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",$.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",$.USER_NOT_FOUND="USER_NOT_FOUND",$.VERSION_MISMATCH="VERSION_MISMATCH",$.WRONG_PERMISSIONS="WRONG_PERMISSIONS",(N=e.LrErrorCode||(e.LrErrorCode={})).BadTimeSync="LrBadTimeSync",N.ReceiveClaimMismatch="LrReceiveClaimMismatch",N.BadState="LrBadState",N.BadSignature="LrBadSignature",N.Auth="LrAuth",N.BadArgument="LrBadArgument",N.SuspiciousException="LrSuspiciousException",N.NotFound="LrNotFound",N.BadLogic="LrBadLogicException",N.CodeMismatch="LrCodeMismatchException",N.ConcurrentAccess="LrConcurrentAccessException",N.BadRequest="LrBadRequestException",N.Encryption="LrEncryptionGoBad",N.Locked="LrLockedException";var x,U,J=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadArgument,message:n})||this}return w(n,t),n}(L),_=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadArgument,message:n})||this}return w(n,t),n}(L),q=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.NotFound,message:n})||this}return w(n,t),n}(L),G=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadLogic,message:n})||this}return w(n,t),n}(L),B=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.CodeMismatch,message:n})||this}return w(n,t),n}(L),V=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.ConcurrentAccess,message:n})||this}return w(n,t),n}(L),Q=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Locked,message:n})||this}return w(n,t),n}(L),W=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadRequest,message:n})||this}return w(n,t),n}(L),Z=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Auth,message:n})||this}return w(n,t),n}(L),H=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Encryption,message:n})||this}return w(n,t),n}(L),Y=function(e){function t(t){return e.call(this,{code:"LrUnsupportedException",message:t})||this}return w(t,e),t}(L),z=function(e){function t(t){return e.call(this,{code:"LrExpiredCodeException",message:t})||this}return w(t,e),t}(L),X=function(e){function t(t){return e.call(this,{code:"LrExpiredException",message:t})||this}return w(t,e),t}(L),ee=function(e){function t(t){return e.call(this,{code:"LrBadStateException",message:t})||this}return w(t,e),t}(L),te=new n.InjectionToken("LR.AUTH"),ne=[e.LrApiErrorCode.CONCURRENT_ACCESS],re=function(e,t){var n=i.setContext((function(e,n){var r=n.headers;return R(void 0,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:e=null,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.currentSession()];case 2:return e=n.sent().getAccessToken(),[3,4];case 3:return n.sent(),console.log("User not signed in"),[3,4];case 4:return[2,{headers:Object.assign(Object.assign({},r),{authorization:e?"Bearer "+e.jwtToken:""})}]}}))}))})),s=new a.RetryLink({delay:{initial:300,max:1/0,jitter:!0},attempts:{max:3,retryIf:function(e,t){return!!(e instanceof o&&e.errors.some((function(e){var t;return ne.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})))}}}),o=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 w(t,e),t}(Error),c=new r.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return ne.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new o(e.errors);return e}))})),u=r.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:r.from([s,c,n,u]),cache:new r.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{errorPolicy:"all"}}},e.apolloConfig)};!function(e){e.Key="key",e.PassKey="passKey"}(x||(x={})),function(e){e.KeyLink="keyLink",e.PassKeyLink="passKeyLink"}(U||(U={}));var ie,ae,se=h,oe=y(ie||(ie=M(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),ce=function(){function t(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=se.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return t.prototype.getAccessToken=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.auth.currentAuthenticatedUser()];case 1:return[2,e.sent().getSignInUserSession().getAccessToken().getJwtToken()];case 2:return e.sent(),[2,""];case 3:return[2]}}))}))},t.prototype.verifyCognito=function(){return R(this,void 0,void 0,(function(){var t,n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.getAccessToken()];case 1:return(t=s.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:t})})]:[2];case 2:if(n=s.sent(),r=Date.now(),i=se(n.headers.get("Date")).valueOf(),a=r+this.offsetMs,Math.abs(a-i)>this.MAX_DIFF_MSEC)throw new L({code:e.LrErrorCode.BadTimeSync,message:"Server time does not match independent source. ServerTime: "+a+", Cognito time: "+i});return this.verified=!0,[2]}}))}))},t.prototype.refresh=function(){return R(this,void 0,void 0,(function(){var e,t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:oe}).toPromise()];case 1:return t=a.sent(),n=Date.now(),j(t.errors),r=parseInt(t.data.serverTime.timestamp,10),i=n-e,this.offsetMs=r-(e+i/2),this.VERIFY_ENABLED?[4,this.verifyCognito()]:[3,3];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},t.prototype.serverNow=function(){return R(this,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,this.getAccessToken()]:[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]}}))}))},t}();ce.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ce(n.ɵɵinject(d.AuthClass),n.ɵɵinject(l.Apollo))},token:ce,providedIn:"root"}),ce.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ce.ctorParameters=function(){return[{type:d.AuthClass},{type:l.Apollo}]},function(e){e.JSON="JSON",e.COMPACT="COMPACT"}(ae||(ae={}));var ue={payloadType:"json",returnOnlyPayload:!0},pe={payloadType:"json",returnOnlyPayload:!0,serializations:[ae.JSON]};var de=function(){function t(e){this.timeService=e}return t.prototype.decrypt=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i;return E(this,(function(a){switch(a.label){case 0:if(r={algorithms:["dir","A*GCM","RSA-OAEP-*"]},n=Object.assign(Object.assign({},pe),n),e.jwk&&(e=e.jwk),"string"==typeof t&&n.serializations.includes(ae.JSON))try{t=JSON.parse(t)}catch(e){if(!n.serializations.includes(ae.COMPACT))throw e;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,p.JWE.createDecrypt(e,r).decrypt(t)];case 1:return(i=a.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i]}}))}))},t.prototype.encryptToString=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(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()])]}}))}))},t.prototype.encrypt=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.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=p.JWE).createEncrypt,i={contentAlg:"A256GCM"},a={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(i.fields=(a.timestamp=s.sent(),a),i),e]).update(t).final()]}}))}))},t.prototype.sign=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return i=(r=p.JWS).createSign,a={},s={},[4,this.timeService.serverNow()];case 1:return n=i.apply(r,[(a.fields=(s.timestamp=o.sent(),s),a),e]),t instanceof Buffer?n.update(t):n.update(JSON.stringify(t),"utf8"),[2,n.final()]}}))}))},t.prototype.signToString=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(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()])]}}))}))},t.prototype.verify=function(t,n,r){return R(this,void 0,void 0,(function(){var i,a,s;return E(this,(function(o){switch(o.label){case 0:i={algorithms:["RS*"]},r=Object.assign(Object.assign({},ue),r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,p.JWS.createVerify(t,i).verify(n)];case 2:return(a=o.sent()).payload=this.decodePayload(r.payloadType,a.payload),r.returnOnlyPayload?[2,a.payload]:[2,a];case 3:throw s=o.sent(),new L({code:e.LrErrorCode.BadSignature,message:"Bad signature: "+s});case 4:return[2]}}))}))},t.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return R(this,void 0,void 0,(function(){var e,i,a,s;return E(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)}]}}))}))},t.prototype.decodePayload=function(e,t){switch(e){case"json":return JSON.parse((new TextDecoder).decode(t));case"ArrayBuffer":return t;default:throw new J("Unknown payloadType: "+e)}},t}();de.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new de(n.ɵɵinject(ce))},token:de,providedIn:"root"}),de.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],de.ctorParameters=function(){return[{type:ce}]};var le=function(){function e(){this.crypto=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 R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return n=new TextEncoder,r=n.encode(t),[4,this.crypto.subtle.digest(e,r)];case 1:return i=a.sent(),[2,this.toHex(i)]}}))}))},e}();le.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new le},token:le,providedIn:"root"}),le.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}];var ye=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.crypto=this.webCryptoService.crypto}return e.asKey=function(e,t,n){return p.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new J("digits <= 0");var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e);return this.crypto.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 J("array.length <= 0");if(t<=0)throw new J("chooseN <= 0");var n=new Uint32Array(t);this.crypto.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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.crypto.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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.crypto.subtle.generateKey({name:"HMAC",hash:{name:"SHA-512"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.crypto.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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.crypto.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.crypto.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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.crypto.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.crypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.deriveKey=function(t){var n=t.password,r=t.salt,i=t.iterations,a=t.kid;return R(this,void 0,void 0,(function(){var t,s,o,c;return E(this,(function(u){switch(u.label){case 0:return t=new TextEncoder,[4,this.crypto.subtle.importKey("raw",t.encode(n),"PBKDF2",!1,["deriveBits","deriveKey"])];case 1:return s=u.sent(),[4,crypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode(r),iterations:i,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 2:return o=u.sent(),[4,crypto.subtle.exportKey("jwk",o)];case 3:return c=u.sent(),a&&(c.kid=a),[4,e.asKey(c)];case 4:return[2,{jwk:u.sent()}]}}))}))},e.prototype.derivePassIdp=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new _("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 R(this,void 0,void 0,(function(){return E(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new _("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 R(this,void 0,void 0,(function(){return E(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new _("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 R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return R(this,void 0,void 0,(function(){var e;return E(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 R(this,void 0,void 0,(function(){var e;return E(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}();ye.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ye(n.ɵɵinject(le))},token:ye,providedIn:"root"}),ye.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ye.ctorParameters=function(){return[{type:le}]};var he=function(){function e(e,t,r,i){this.keyFactory=e,this.cookieService=t,this.encryptionService=r,this.injector=i,this.KEY_PREFIX="lrSession-",this.cookieSecure=!0,this.serverSessionEncryptionKey=null,n.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(!n.isDevMode())throw new J("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 R(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return E(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 R(this,void 0,void 0,(function(){var t,n,r;return E(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 R(this,void 0,void 0,(function(){var t,n,r,i,a,s;return E(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,ye.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}();he.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new he(n.ɵɵinject(ye),n.ɵɵinject(f.CookieService),n.ɵɵinject(de),n.ɵɵinject(n.INJECTOR))},token:he,providedIn:"root"}),he.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],he.ctorParameters=function(){return[{type:ye},{type:f.CookieService},{type:de},{type:n.Injector}]};var fe=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.populateKeys=function(e){this.keys=e},e.prototype.getCurrentPassKey=function(){return this.keys.passKey},e.prototype.getCurrentMasterKey=function(){return this.keys.masterKey},e.prototype.getCurrentRootKey=function(){return this.keys.rootKey},e.prototype.getCurrentPxk=function(){return this.keys.pxk},e.prototype.getCurrentSigPxk=function(){return this.keys.sigPxk},e.prototype.expiresAfter=function(e){return new Date(Date.now()+1e3*e)},e.prototype.persistMasterKey=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(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 R(this,void 0,void 0,(function(){var t;return E(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 q("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 R(this,void 0,void 0,(function(){var t,n;return E(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 q("Could not find masterKey in persisted storage");if(t.id!==e)throw new q("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,ye.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();fe.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new fe(n.ɵɵinject(te),n.ɵɵinject(he))},token:fe,providedIn:"root"}),fe.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],fe.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:he}]};var ve=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 c.Graph},e.prototype.populateKeys=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return n=(t=this.keyService).populateKeys,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 q("Key graphs does not contain key id: "+e);if(n.type!==t)throw new L({message:"Key with id "+e+" is not of type "+t});return n.data},e.prototype.key=function(e){return this.getNode(e,x.Key)},e.prototype.passKey=function(e){return this.getNode(e,x.PassKey)},e.prototype.addKeys=function(e){var t,n,r,i,a,s;if(e.keys)try{for(var o=A(e.keys),c=o.next();!c.done;c=o.next()){var u=c.value;if(!this.graph.hasNode(u.id)){var p={type:x.Key,data:b.cloneDeep(u)};this.graph.setNode(u.id,p)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}if(e.keyLinks)try{for(var d=A(e.keyLinks),l=d.next();!l.done;l=d.next()){var y=l.value;if(!this.graph.hasEdge(y.wrappingKeyId,y.keyId)){var h={type:U.KeyLink,data:b.cloneDeep(y)};this.graph.setEdge(y.wrappingKeyId,y.keyId,h)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}if(e.passKeyLinks)try{for(var f=A(e.passKeyLinks),v=f.next();!v.done;v=f.next()){var g=v.value;if(!this.graph.hasEdge(g.passKeyId,g.keyId)){h={type:U.PassKeyLink,data:b.cloneDeep(g)};this.graph.setEdge(g.passKeyId,g.keyId,h)}}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}},e.prototype.tracePath=function(e,t){var n=[],r=t;if(!e[r].predecessor)return null;for(;e[r].predecessor;){var i=e[r].predecessor;n.push(this.graph.edge(i,r)),r=i}return n.reverse(),n},e.prototype.getPath=function(e,t){if(!e||"string"!=typeof e)throw new H("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new H("Param keyId wrong format: "+t);var n=C.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},e.prototype.getJwkKey=function(e,t){return R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return n="string"==typeof e?e:null==e?void 0:e.id,this.hasKey(n)||!t?[3,2]:[4,t()];case 1:n=i.sent(),i.label=2;case 2:return(r=this.key(n)).jwk?[2,r]:[2,this.unwrapKey(this.keyService.getCurrentMasterKey().id,n)]}}))}))},e.prototype._unwrapLink=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a;return E(this,(function(s){switch(s.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=s.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=s.sent(),s.label=4;case 4:return a=n,[4,ye.asKey(i)];case 5:return a.jwk=s.sent(),n.task=null,[2]}}))}))},e.prototype._unwrap=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return E(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=A(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 R(this,void 0,void 0,(function(){var r,i;return E(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 R(this,void 0,void 0,(function(){var n,r,i;return E(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 R(this,void 0,void 0,(function(){var r;return E(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 R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getJwkKey(e)];case 1:return n=r.sent(),[4,this.encryptionService.decrypt(n,t,{payloadType:"ArrayBuffer"})];case 2:return[2,r.sent()]}}))}))},e.prototype.encryptToString=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(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 R(this,void 0,void 0,(function(){return E(this,(function(n){if(!function(e){return"oct"===e.kty}(t))throw new J("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},e.prototype.encryptWithNewKey=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(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}();ve.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ve(n.ɵɵinject(de),n.ɵɵinject(fe),n.ɵɵinject(ye))},token:ve,providedIn:"root"}),ve.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ve.ctorParameters=function(){return[{type:de},{type:fe},{type:ye}]};var ge=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 R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return j((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return j((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();ge.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ge(n.ɵɵinject(l.Apollo),n.ɵɵinject(ve))},token:ge,providedIn:"root"}),ge.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ge.ctorParameters=function(){return[{type:l.Apollo},{type:ve}]};var me,Se,Ie,Ce,be,ke,Ke,we,Pe,De,Re,Ee,Ae="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",Oe=y(me||(me=M(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),Ae),Te="keyGraph "+Ae,Me="keyGraph: fetchKeyGraph "+Ae,je=y(Se||(Se=M(["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Oe),$e=y(Ie||(Ie=M(["\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"])),Oe),Ne=y(Ce||(Ce=M(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Fe=y(be||(be=M(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),Le=y(ke||(ke=M(["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),xe=y(Ke||(Ke=M(["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),Ue=y(we||(we=M(["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),Je=y(Pe||(Pe=M(['\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 }\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 }\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"])),Oe),_e=y(De||(De=M(["\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"]))),qe=y(Re||(Re=M(["\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"]))),Ge=function(){},Be=function(){},Ve=function(){},Qe=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},We=function(){},Ze=function(){},He=function(){},Ye=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(He),ze=function(){};(Ee=e.PasswordChangeStatus||(e.PasswordChangeStatus={})).InProgress="IN_PROGRESS",Ee.Recovery="RECOVERY";var Xe,et=function(){},tt=function(){};(Xe=e.DirectoryType||(e.DirectoryType={})).Vault="vault",Xe.Category="category",Xe.Record="record";var nt,rt,it,at,st,ot,ct,ut,pt,dt,lt,yt,ht,ft=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Vault,default:!0}}]}),vt=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Category}}]}),gt=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Record}}]}),mt="\naccessRoles {\n role\n method\n inheritedFrom {\n id\n }\n trustedParty {\n id\n }\n isIssuer\n}",St="\ndescendantDirectories(depth: 5, plainMeta: $categoryFilter, archived: false) {\n recordsCount: directoriesCount(plainMeta: $recordFilter, archived: false)\n}\n",It="\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+mt+"\n "+St+"\n",Ct="\n id\n keyId\n plainMeta\n cipherMeta\n",bt=y(nt||(nt=M(["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),kt=y(rt||(rt=M(['\nquery GetCategories($vaultFilter: LrJSONFilter!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean, $cachedKeyIds: [LrRelayIdInput!])\n{\n vaults: rootDirectories(plainMeta: $vaultFilter) {\n edges {\n node {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetCategories($vaultFilter: LrJSONFilter!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean, $cachedKeyIds: [LrRelayIdInput!])\n{\n vaults: rootDirectories(plainMeta: $vaultFilter) {\n edges {\n node {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),It,Oe),Kt=y(it||(it=M(['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),Ct,Oe),wt=y(at||(at=M(['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n sharedItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n sharedItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),It,mt,Oe),Pt=y(st||(st=M(['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),It,mt,Oe),Dt=function(e){return void 0===e&&(e=5),e?"\nparentCategories: parentDirectoryLinks(plainMeta: $categoryFilter) {\n edges {\n node {\n parentDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+Dt(e-1)+"\n "+mt+"\n }\n }\n }\n}\n":""},Rt=function(e){return void 0===e&&(e=5),y(ot||(ot=M(["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n"," "],["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n"," "])),mt,St,Dt(e),It,mt,Oe)},Et=y(ct||(ct=M(["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Oe),At=y(ut||(ut=M(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),Ot=y(pt||(pt=M(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"]))),Tt=y(dt||(dt=M(["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Mt=y(lt||(lt=M(["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"],["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"]))),jt=y(yt||(yt=M(["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),$t=y(ht||(ht=M(["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Nt=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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return E(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 R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return E(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 R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y=this;return E(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return R(y,void 0,void 0,(function(){var t,r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.getCategoryKeyId(e)];case 1:return t=s.sent(),a=(i=JSON).stringify,[4,this.encryptionService.encrypt(t.key,n.toJSON(!0))];case 2:return r=a.apply(i,[s.sent()]),[2,{directoryId:e,wrappingKeyId:t.keyId,wrappedKey:r}]}}))}))})))]:[3,3];case 2:return r=h.sent(),[3,5];case 3:return a=this.keyService.getCurrentRootKey(),c=(o=JSON).stringify,[4,this.encryptionService.encrypt(a.jwk,n.toJSON(!0))];case 4:s=c.apply(o,[h.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},h.label=5;case 5:return u={key:n,rootKey:i,wrappedKeys:r},e?(l=(d=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,7];case 6:return p=l.apply(d,[h.sent()]),[3,8];case 7:p=null,h.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=c.sent(),[4,this.keyGraph.encryptToString(t,n.toJSON(!0))];case 2:return r=c.sent(),i={key:n,rootKey:{wrappingKeyId:t,wrappedKey:r}},e?(o=(s=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,4];case 3:return a=o.apply(s,[c.sent()]),[3,5];case 4:a=null,c.label=5;case 5:return[2,(i.cipherMeta=a,i)]}}))}))},e.prototype.getCategoryKeyId=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Et,variables:{id:e}})];case 1:return t=r.sent().category,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();Nt.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Nt(n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(ge),n.ɵɵinject(fe),n.ɵɵinject(ye))},token:Nt,providedIn:"root"}),Nt.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Nt.ctorParameters=function(){return[{type:de},{type:ve},{type:ge},{type:fe},{type:ye}]};var Ft,Lt,xt,Ut,Jt,_t,qt,Gt,Bt,Vt,Qt,Wt,Zt,Ht,Yt,zt,Xt="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",en=(y(Ft||(Ft=M(["\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}"])),Xt,Te),y(Lt||(Lt=M(['\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}"])),Xt,Te),y(xt||(xt=M(['\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}"])),Xt,Te)),tn=(y(Ut||(Ut=M(["\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}"])),Xt),y(Jt||(Jt=M(["\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}"])),Xt),y(_t||(_t=M(["\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"])))),nn=y(qt||(qt=M(["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"],["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"]))),rn=y(Gt||(Gt=M(["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"],["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"]))),an="\n name\n data\n state\n",sn=y(Bt||(Bt=M(["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"],["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"])),an),on=y(Vt||(Vt=M(["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"]))),cn=y(Qt||(Qt=M(["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"],["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"])),an),un=y(Wt||(Wt=M(["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),pn=y(Zt||(Zt=M(["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"],["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"])),an),dn=y(Ht||(Ht=M(["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"],["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"])),an),ln=y(Yt||(Yt=M(["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"],["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"])),an),yn=y(zt||(zt=M(["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"],["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"])));function hn(e){return e.map((function(e){var t;return Object.assign(Object.assign({},e),{periodEnd:e.periodEnd&&new Date(e.periodEnd),subscription:{id:null===(t=e.stripe)||void 0===t?void 0:t.subscriptionId}})}))}var fn=function(){function e(e){this.lrApollo=e}return e.prototype.createStripeCheckoutSession=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:nn,variables:Object.assign({},e)})];case 1:return[2,{id:t.sent().createStripeCheckoutSession.sessionId}]}}))}))},e.prototype.createStripeBillingPortalSession=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:rn,variables:{returnUrl:e}})];case 1:return[2,{url:t.sent().createStripeBillingPortalSession.sessionUrl}]}}))}))},e.prototype.getUserIssuablePlans=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:cn})];case 1:return[2,e.sent().userIssuablePlans]}}))}))},e.prototype.createUserIssuedPlan=function(e){var t=e.planName,n=e.tokenExpiryTime,r=e.planPeriodEnd,i=e.planPeriodEndAfterSeconds;return R(this,void 0,void 0,(function(){var e,a;return E(this,(function(s){switch(s.label){case 0:if(null==r&&null==i)throw new J('Must specify either "planPeriodEnd" or "planPeriodEndAfterSeconds"');return[4,this.lrApollo.mutate({mutation:sn,variables:{input:{planName:t,tokenExpiryTime:n.toISOString(),planPeriodEnd:r&&r.toISOString(),planPeriodEndAfterSeconds:i}}})];case 1:return e=s.sent().createUserIssuedPlan,a=e.userIssuedPlan,[2,Object.assign(Object.assign({},a),{tokenExpiryTime:new Date(a.tokenExpiryTime),planPeriodEnd:new Date(a.planPeriodEnd)})]}}))}))},e.prototype.deleteUserIssuedPlan=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:on,variables:{input:{id:e}}})];case 1:return[2,t.sent()]}}))}))},e.prototype.getUserIssuedPlans=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:un})];case 1:return[2,e.sent().userIssuedPlans.edges.map((function(e){return e.node}))]}}))}))},e.prototype.getUserIssuedPlan=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:pn,variables:{id:e,token:t}})];case 1:return[2,n.sent().userIssuedPlan]}}))}))},e.prototype.associateUserIssuedPlan=function(e){var t=e.id,n=e.token;return R(this,void 0,void 0,(function(){var e,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:dn,variables:{input:{id:t,token:n}}})];case 1:return e=i.sent().associateUserIssuedPlan,r=e.userPlan,[2,Object.assign(Object.assign({},r),{periodEnd:new Date(r.periodEnd)})]}}))}))},e.prototype.getUserPlans=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:ln})];case 1:return[2,hn(e.sent().userPlans)]}}))}))},e.prototype.getPlanType=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.getStripe()];case 1:return[2,t.sent().customer.subscriptions.data.filter((function(t){return t.id===e}))[0].items.data[0].plan.interval]}}))}))},e.prototype.getStripe=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:yn})];case 1:return[2,e.sent().stripe]}}))}))},e}();fn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new fn(n.ɵɵinject(ge))},token:fn,providedIn:"root"}),fn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],fn.ctorParameters=function(){return[{type:ge}]};var vn=function(){function e(e,t,n,r,i,a,s){this.config=e,this.http=t,this.lrApollo=n,this.keyService=r,this.keyMetaService=i,this.keyGraph=a,this.encryptionService=s}return e.prototype.getPassIdpParams=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.config.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},e.prototype.getCurrentUser=function(){return R(this,void 0,void 0,(function(){var e,t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:Je})];case 1:return e=a.sent(),t=e.currentUser,n=e.contactCards,r=e.userPlans,i=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:i,userPlans:hn(r)}]}}))}))},e.prototype.decryptContactCard=function(e){return R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){return E(this,(function(r){switch(r.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r.sent(),[2]}}))}))},e.prototype.prepareContactCardInput=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return E(this,(function(l){switch(l.label){case 0:return[4,this.keyService.getCurrentSigPxk()];case 1:return t=l.sent(),i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 2:return n=i.apply(r,[l.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 3:return a=o.apply(s,[l.sent()]),c={name:new Qe(e.name.value)},d=(p=JSON).stringify,[4,this.encryptionService.sign(t.jwk,c)];case 4:return u=d.apply(p,[l.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:u}]}}))}))},e.prototype.createContactCard=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(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:_e,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 R(this,void 0,void 0,(function(){var r,i;return E(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:qe,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 R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){return[2,Promise.all(e.map((function(e){return R(t,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var e;return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:en})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:tn,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return R(this,void 0,void 0,(function(){return E(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}();vn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new vn(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ge),n.ɵɵinject(fe),n.ɵɵinject(Nt),n.ɵɵinject(ve),n.ɵɵinject(de))},token:vn,providedIn:"root"}),vn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],vn.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:ge},{type:fe},{type:Nt},{type:ve},{type:de}]};var gn=function(e){function t(){var t=e.apply(this,T(arguments))||this;return t.isTpPasswordResetUser=!1,t}return w(t,e),t}(v.CognitoUser);(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var mn,Sn=function(){},In=function(){},Cn=function(){},bn=function(){};function kn(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new G("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function Kn(e){return kn(e,"query")}function wn(e){return kn(e,"mutation")}function Pn(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Dn(e){return{kind:"Name",value:e}}function Rn(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function En(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return y.apply(void 0,T([e],t))}(mn=e.RecoveryStatus||(e.RecoveryStatus={})).NONE="none",mn.NEW_PASSWORD="new-password",mn.OLD_PASSWORD="old-password";var An,On,Tn,Mn,jn,$n,Nn=y(An||(An=M(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n passKeys {\n id\n passIdpParams\n wrappedPassIdpVerifierPrk\n }\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n passKeys {\n id\n passIdpParams\n wrappedPassIdpVerifierPrk\n }\n }\n }\n"]))),Fn=y(On||(On=M(["\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"]))),Ln=y(Tn||(Tn=M(["\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=En(Mn||(Mn=M(["\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"])));En(jn||(jn=M(["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"])));($n=e.Config||(e.Config={}))[$n.TIMEOUT=.01]="TIMEOUT",$n[$n.IDLE=1200]="IDLE",$n[$n.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var Un=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 R(this,void 0,void 0,(function(){var n,r=this;return E(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 J("Minimum value for IdleService.init({ timeoutSec }) is 0.01");return this.onTimeout=t.onTimeout,this.onKeepalive=t.onKeepalive,this.idle.setIdle(t.idleSec),this.idle.setTimeout(t.timeoutSec),this.idle.setInterrupts(g.DEFAULT_INTERRUPTSOURCES),this.idle.onIdleEnd.subscribe((function(){return console.log("Idle stopped")})),this.idle.onIdleStart.subscribe((function(){return console.log("Idle started")})),this.idle.onTimeout.subscribe((function(){return R(r,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())];case 1:return e.sent(),[2]}}))}))})),this.idle.onTimeoutWarning.subscribe((function(e){return console.log("Will timeout in "+e+" seconds!")})),this.keepalive.interval(t.keepAliveIntervalSec),console.log("Keep alive interval set at: "+e.Config.KEEP_ALIVE_INTERVAL+" seconds"),this.keepalive.onPing.subscribe((function(){return r.onPing()})),(n=localStorage.getItem(this.IDLE_EXPIRY_KEY))&&parseInt(n,10)+1e3*this.idle.getTimeout()<Date.now()?(this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return R(this,void 0,void 0,(function(){var e;return E(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.http.post(this.config.authUrl+"auth/keepalive/",null,{withCredentials:!0,headers:{Authorization:"Bearer "+e.getSignInUserSession().getAccessToken().getJwtToken()}}).toPromise()];case 2:return[2,{keepaliveResult:t.sent(),expiresAfterSeconds:this.idle.getIdle()+this.idle.getTimeout()+this.keepalive.interval()}]}}))}))},t.prototype.persistMasterKey=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.keepalivePost()];case 1:return t=n.sent().expiresAfterSeconds,[4,this.keyService.persistMasterKey(e,t)];case 2:return n.sent(),console.log("setMasterKey() done"),[2]}}))}))},t.prototype.onPing=function(){return R(this,void 0,void 0,(function(){var e;return E(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 R(this,void 0,void 0,(function(){return E(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}();Un.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Un(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(g.Idle),n.ɵɵinject(m.Keepalive),n.ɵɵinject(fe),n.ɵɵinject(d.AuthClass))},token:Un,providedIn:"root"}),Un.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Un.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:g.Idle},{type:m.Keepalive},{type:fe},{type:d.AuthClass}]};var Jn=h,_n=function(){},qn=function(){function e(e,t,n,r,i,a,s,o,c,u){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.idleService=u,this.CLIENT_NONCE_LENGTH=32}return e.prototype.checkPassword=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Jn.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(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 R(this,void 0,void 0,(function(){var t,n,r,i,a,s;return E(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 R(this,void 0,void 0,(function(){var e,t,n,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Jn(e.authTime),n=Jn(e.serverTime),r=Jn.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d;return E(this,(function(l){switch(l.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:if(n=l.sent(),e===t)throw new J("New password is the same as the current one.");return[4,this.profileService.getCurrentUser()];case 2:return r=l.sent().currentUser,[4,this.verifyPassword(e,r)];case 3:return i=l.sent(),a=i.passIdp,s=i.signedChallenge,[4,this.createPassKeyBundle(t)];case 4:return o=l.sent(),[4,this.keyGraph.getKey(r.currentUserKey.masterKey.id)];case 5:return c=l.sent(),[4,this.encryptionService.encrypt(o.passKey,c.jwk.toJSON(!0))];case 6:return u=l.sent(),[4,this.changePasswordMutation(s,r.currentUserKey.masterKey.id,u,o)];case 7:return p=l.sent(),d=p.token,p.newPassKeyId,[4,this.auth.changePassword(n,this.getPassIdpString(a),this.getPassIdpString(o.passIdp))];case 8:return l.sent(),[4,this.changePasswordComplete(n.getSignInUserSession().getAccessToken().getJwtToken(),!0,d)];case 9:return l.sent(),[2]}}))}))},e.prototype.changePasswordComplete=function(e,t,n){return void 0===n&&(n=null),R(this,void 0,void 0,(function(){return E(this,(function(r){return[2,this.http.post(this.config.authUrl+"users/password-change-complete/",Object.assign({use_new_password:t},n&&{token:n}),{headers:{Authorization:"Bearer "+e}}).toPromise()]}))}))},e.prototype.getVerifierPrK=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(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,ye.asKey(n)];case 2:throw r.sent(),new Z("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:Nn,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 R(this,void 0,void 0,(function(){var i;return E(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Fn,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 R(this,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:Ln})];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}();qn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new qn(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ge),n.ɵɵinject(d.AuthClass),n.ɵɵinject(vn),n.ɵɵinject(ye),n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(le),n.ɵɵinject(Un))},token:qn,providedIn:"root"}),qn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],qn.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:ge},{type:d.AuthClass},{type:vn},{type:ye},{type:de},{type:ve},{type:le},{type:Un}]};var Gn,Bn,Vn,Qn,Wn,Zn,Hn,Yn,zn,Xn,er,tr,nr,rr,ir=En(Gn||(Gn=M(["\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}"]))),ar=En(Bn||(Bn=M(["\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"])),ir),sr=En(Vn||(Vn=M(["\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"])),ir),or=En(Qn||(Qn=M(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),cr=En(Wn||(Wn=M(["\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}"]))),ur=En(Zn||(Zn=M(["\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}"]))),pr=En(Hn||(Hn=M(["\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}"]))),dr=En(Yn||(Yn=M(["\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}"]))),lr=En(zn||(zn=M(["\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}"]))),yr=En(Xn||(Xn=M(["\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 }\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 }\n}"]))),hr=En(er||(er=M(["\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}"]))),fr=En(tr||(tr=M(["\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}"]))),vr=En(nr||(nr=M(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),gr=En(rr||(rr=M(["\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}"])));function mr(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 Sr(e,t){var n,r,i={};try{for(var a=A(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=O(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 Ir(e,t){var n=mr(Object.entries(e).map((function(n){var r=O(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return Sr(e,t)})):Sr(e,n)}var Cr=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function br(e){var t=e.ngZoneName,n=e.exceptLastPromise,r=void 0===n||n,i=e.excludeMethods,a=void 0===i?[]:i,s=e.patchSetters,o=void 0===s||s;return function(e){function n(n,i){var a=this;if(!this[t])throw new G("RunOutsideAngular decorator requires that "+e.name+" inject NgZone as "+t);var s=this[t].runOutsideAngular((function(){return n.apply(a,i)}));return r&&(null==s?void 0:s.then)?Promise.resolve(s):s}return a=T(a,Cr),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 kr={hasKeys:!0};function Kr(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s=this;return E(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 R(s,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,t(e.node)];case 1:return[2,r.apply(n,i.concat([(a.node=s.sent(),a)]))]}}))}))})))];case 1:return[2,r.apply(n,i.concat([(a.edges=o.sent(),a)]))]}}))}))}function wr(e,t){return Object.assign(Object.assign({},e),{path:T(e.path,[t])})}e.CommonProcessorsService=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.series=function(e){var t=this;return function(n){var r=n.field,i=n.context,a=n.options;return R(t,void 0,void 0,(function(){var t,n,s,o,c;return E(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),t=A(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 R(t,void 0,void 0,(function(){var t,n,i,a,s,u;return E(this,(function(p){switch(p.label){case 0:return n=e.field,i=e.context,e.options.hasKeys?!(a=n[r])||c in n?[2,n]:o?[4,o(e)]:[3,2]:[2,n];case 1:return u=p.sent(),[3,3];case 2:u=n.keyId||(null===(t=n.key)||void 0===t?void 0:t.id),p.label=3;case 3:if(!(s=u))throw new G("Query response does not contain "+(o?"key-id":"keyId or key.id")+" field: "+i.path.join("."));return[2,this.keyGraph.decryptFromString(s,a).then((function(e){var t;return Object.assign(Object.assign({},n),((t={})[c]=e,t))}))]}}))}))}},e}(),e.CommonProcessorsService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.CommonProcessorsService(n.ɵɵinject(n.NgZone),n.ɵɵinject(ve))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:n.NgZone},{type:ve}]},e.CommonProcessorsService=D([br({ngZoneName:"ngZone"})],e.CommonProcessorsService),e.ɵi=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUserNode=function(e){var t;return R(this,void 0,void 0,(function(){var n,r,i,a,s=this;return E(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 R(this,void 0,void 0,(function(){var n,r;return E(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 R(e,void 0,void 0,(function(){var e,t;return E(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new W('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 R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return E(this,(function(y){switch(y.label){case 0:return n=e.subjectKey,r=e.assemblyKey,i=e.assemblyCipherData,a=e.subAssemblies,c=(o=Object).assign,u=[Object.assign({},e)],p={},[4,Kr(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=y.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=y.sent(),y.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return E(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,Kr(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 R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,e]}))}))},e}(),e.ɵi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵi(n.ɵɵinject(n.NgZone),n.ɵɵinject(ve))},token:e.ɵi,providedIn:"root"}),e.ɵi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵi.ctorParameters=function(){return[{type:n.NgZone},{type:ve}]},e.ɵi=D([br({ngZoneName:"ngZone"})],e.ɵi),e.QueryProcessorService=function(){function e(e,t,n,r){this.ngZone=e,this.keyService=t,this.common=n,this.tpprProcessor=r,this.TYPENAME="__typename",this.processors={},this.registerProcessor("DirectoryNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("FileStateNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("ContactCardNode",n.makeDecryptionProcessor({cipherFieldName:"cipherData"})),this.registerProcessor("SharedContactCardNode",n.series([n.makeJsonParseProcessor({plainFieldName:"ownerPlainData"}),n.makeDecryptionProcessor({cipherFieldName:"ownerCipherData",getKeyId:function(e){return e.field.ownerKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"receiverCipherData",getKeyId:function(e){return e.field.receiverKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpPasswordResetNode",this.tpprProcessor.makeTpPasswordResetNodeProcessor()),this.registerProcessor("SharedTpClaimApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyAsApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioReceiverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverDirectoryNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioApproverAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"assemblyCipherData",getKeyId:function(e){return e.field.assemblyKey.id}})])),this.registerProcessor("ScenarioApproverSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioClaimantNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("TpSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("NotificationNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeJsonParseProcessor({plainFieldName:"plainData"})]))}return e.prototype.processQuery=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){return t=Object.assign(Object.assign({},kr),t),[2,Ir(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 R(this,void 0,void 0,(function(){var e,i,a,s=this;return E(this,(function(o){if(null==t?void 0:t.then)throw new G("processField() should not receive thenable.");return null==t?[2,null]:(e={field:t,context:Object.assign(Object.assign({},n),{processChildren:!0}),options:r},t[this.TYPENAME]?((i=this.processors[t[this.TYPENAME]])&&(t=i(e)),a=function(e){return n.processChildren&&null!==e&&"object"==typeof e?Ir(e,(function(e,t){return s.processField({field:e,context:wr(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=mr(t.map((function(e,t){return s.processField({field:e,context:wr(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new G("Processor for field "+e+" already exists.");this.processors[e]=t},e}(),e.QueryProcessorService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.QueryProcessorService(n.ɵɵinject(n.NgZone),n.ɵɵinject(fe),n.ɵɵinject(e.CommonProcessorsService),n.ɵɵinject(e.ɵi))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:n.NgZone},{type:fe},{type:e.CommonProcessorsService},{type:e.ɵi}]},e.QueryProcessorService=D([br({ngZoneName:"ngZone"})],e.QueryProcessorService);var Pr,Dr,Rr,Er=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}(),Ar=Kn(y(Pr||(Pr=M(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],Or=function(){function e(){this._executed=!1,this.deferredPromise=new Er}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}(),Tr=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return w(t,e),t.prototype.select=function(e){var n=u.cloneDeep(this.mutation),r=wn(n),i={};Pn(e).forEach((function(e){i[e.name.value]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=Rn(t);i[n]&&(t.selectionSet.selections=[Object.assign(Object.assign({},Ar),{name:Dn(n)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:T(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(Or),Mr={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},jr=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 w(t,e),t.create=function(e){return new t(e)},t.prototype.getDescendants=function(){var e=new Set,n=function(t){if(e.has(t))throw new G("Classes that are derived from LrMutationBase can not be used more than once in a merged mutation.");e.add(t)};return this.lrMutations.forEach((function(e){if(e instanceof Tr)n(e);else{if(!(e instanceof t))throw new Y("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:Dn(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:Dn(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+Rn(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:Dn(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":var r=n.renameField(e,t);return n.processSelection(r,t);default:return e}}))},t.prototype.renameFragmentDefinition=function(e,t){var n=Object.assign(Object.assign({},e),{name:Dn(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,p=s.lrMutationData,d=p.mutation,l=p.variables,y=wn(d),h="item"+o+"_";y.name&&(h+=y.name.value+"_"),a.push(h),t=T(t,e.renameVariableDefinitions(y.variableDefinitions,h)),n=T(n,e.renameSelections(y.selectionSet.selections,h));try{for(var f=A(Object.keys(l)),v=f.next();!v.done;v=f.next()){var g=v.value;r[h+g]=l[g]}}catch(e){c={error:e}}finally{try{v&&!v.done&&(u=f.return)&&u.call(f)}finally{if(c)throw c.error}}var m=Pn(d);i=T(i,e.renameFragmentDefinitions(m,h))}));var s=u.cloneDeep(Mr),o=wn(s);return o.selectionSet.selections=n,o.variableDefinitions=t,s.definitions=T(s.definitions,i),{mutation:s,variables:r,prefixes:a}},t}(Or),$r=Kn(y(Dr||(Dr=M(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Te)).selectionSet.selections[0],Nr=Kn(y(Rr||(Rr=M(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Me)).selectionSet.selections[0];e.ɵh=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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return e=u.cloneDeep(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Kn(e.query)).selectionSet.selections=T(t.selectionSet.selections,[$r])),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,j(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 R(this,void 0,void 0,(function(){return E(this,(function(n){if(null==t?void 0:t.variables)throw new Y('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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:u.cloneDeep(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=wn(e.mutation)).selectionSet.selections=T(t.selectionSet.selections,[Nr])),e.mutation=y(S.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,j(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return u.cloneDeep(this.stats)},e.prototype.addKeys=function(e){e.data.keyGraph&&(this.keyGraph.addKeys(e.data.keyGraph),delete e.data.keyGraph)},e.prototype.isIncludeKeyGraph=function(e){return null==e},e.prototype.lrMutate=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=jr).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.ɵh.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵh(n.ɵɵinject(n.NgZone),n.ɵɵinject(l.Apollo),n.ɵɵinject(ve),n.ɵɵinject(e.QueryProcessorService))},token:e.ɵh,providedIn:"root"}),e.ɵh.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵh.ctorParameters=function(){return[{type:n.NgZone},{type:l.Apollo},{type:ve},{type:e.QueryProcessorService}]},e.ɵh=D([br({ngZoneName:"ngZone"})],e.ɵh);var Fr,Lr,xr,Ur,Jr,_r,qr,Gr,Br,Vr,Qr,Wr,Zr,Hr,Yr=function(){function t(t){this.lrGraphQL=t.get(e.ɵh)}return t.prototype.mutate=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();function zr(e){return e.edges.map((function(e){return e.node}))}(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED",(Fr=e.PlanState||(e.PlanState={})).ENABLED="ENABLED",Fr.DISABLED="DISABLED",(Lr=e.AccessRoleChoice||(e.AccessRoleChoice={})).READER="READER",Lr.WRITER="WRITER",Lr.ADMIN="ADMIN",Lr.DENY="DENY",Lr.OWNER="OWNER",(xr=e.AccessRoleMethod||(e.AccessRoleMethod={})).inherited="inherited",xr.direct="direct",(Ur=e.FileVersionOperation||(e.FileVersionOperation={})).CREATE="CREATE",Ur.READ="READ",Ur.UPDATE="UPDATE",Ur.REVERT="REVERT",Ur.DELETE="DELETE",(Jr=e.KeyExchangeOtkState||(e.KeyExchangeOtkState={})).OTK_INITIATED="OTK_INITIATED",Jr.OTK_ACCEPTED="OTK_ACCEPTED",Jr.OTK_COMPLETED="OTK_COMPLETED",(_r=e.KeyExchangeState||(e.KeyExchangeState={})).IN_PROGRESS="IN_PROGRESS",_r.COMPLETED="COMPLETED",_r.DECLINED="DECLINED",_r.CANCELLED="CANCELLED",_r.DELETED="DELETED",(e.KeyExchangeMode||(e.KeyExchangeMode={})).OTK="OTK",(qr=e.TpAssemblyState||(e.TpAssemblyState={})).DISABLED="DISABLED",qr.ENABLED="ENABLED",qr.CLAIMED="CLAIMED",qr.APPROVED="APPROVED",qr.REJECTED="REJECTED",qr.EXPIRED="EXPIRED",qr.CANCELLED="CANCELLED",qr.RESET="RESET",(Gr=e.TpClaimState||(e.TpClaimState={})).CLAIMED="CLAIMED",Gr.APPROVED="APPROVED",Gr.REJECTED="REJECTED",Gr.EXPIRED="EXPIRED",Gr.CANCELLED="CANCELLED",Gr.RESET="RESET",(Br=e.TpClaimApproverState||(e.TpClaimApproverState={})).CLAIMED="CLAIMED",Br.APPROVED="APPROVED",Br.REJECTED="REJECTED",(Vr=e.LockState||(e.LockState={})).UNLOCKED="UNLOCKED",Vr.MUTEX_LOCKED="MUTEX_LOCKED",(Qr=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",Qr.ENABLED="ENABLED",Qr.CLAIMED="CLAIMED",Qr.APPROVED="APPROVED",(Wr=e.ClaimState||(e.ClaimState={})).CLAIMED="CLAIMED",Wr.EXPIRED="EXPIRED",Wr.APPROVED="APPROVED",Wr.REJECTED="REJECTED",Wr.CANCELLED="CANCELLED",Wr.RESET="RESET",(Zr=e.ClaimApproverState||(e.ClaimApproverState={})).CLAIMED="CLAIMED",Zr.APPROVED="APPROVED",Zr.REJECTED="REJECTED",(Hr=e.LinkTypeField||(e.LinkTypeField={})).HARD="HARD",Hr.SOFT="SOFT";var Xr=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},ei=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=Array()},e.prototype.addShare=function(e){this.shares.push(e)},e}(),ti=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=new Array},e.prototype.addSubAssembly=function(e){this.subAssemblies.push(e)},e}(),ni=(function(){function e(e){this.subAssemblyIndex=e,this.clearShares()}e.prototype.clearShares=function(){this.shares=new Array},e.prototype.addShare=function(e){this.shares.push(e)}}(),function(){function e(){this.clearSubQuora()}e.prototype.clearSubQuora=function(){this.subQuora=new Array},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 R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return E(this,(function(d){switch(d.label){case 0:r=btoa(e),r=I.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=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,I.Slip39.fromArray(r,{passphrase:t,threshold:n.threshold,groups:i,title:""})];case 1:return c=d.sent(),n.subAssemblies.forEach((function(e,t){e.clearShares();for(var n=0;n<e.size;n++){var r="r/"+t.toString().padStart(2,"0")+"/"+n.toString().padStart(2,"0"),i=c.fromPath(r).mnemonics[0],a=new Xr(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=A(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=I.Slip39Helper.decodeMnemonic(u);if(a&&a!==p.groupThreshold)throw new Error("groupThreshold is different in mnemonics");a=p.groupThreshold,null==(f=s.get(p.groupIndex))&&(f={memberThreshold:p.memberThreshold,members:[]},s.set(p.groupIndex,f)),f.members.push({mnemonic:u,decoded:p})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=[],l=0;try{for(var y=A(s.values()),h=y.next();!h.done;h=y.next()){var f;if(!((f=h.value).members.length<f.memberThreshold)&&(f.members.slice(0,f.memberThreshold).forEach((function(e){d.push(e.mnemonic)})),++l>=a))break}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}return d},e.prototype.recoverSecret=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,I.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=I.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}());ni.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ni},token:ni,providedIn:"root"}),ni.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ni.ctorParameters=function(){return[]};var ri,ii="lifeready",ai=En(ri||(ri=M(["\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}"]))),si=function(){function t(t){this.keyFactory=t.get(ye),this.keyService=t.get(fe),this.encryptionService=t.get(de),this.keyGraph=t.get(ve),this.slip39Service=t.get(ni),this.lrGraphQl=t.get(e.ɵh)}return t.prototype.recoverAssemblyKey=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(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,ye.asKey(Object.assign(Object.assign({},t),{k:r}))];case 2:return[2,i.sent()]}}))}))},t.prototype.prepareTpWrappingKey=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.keyGraph.getKey(e.wrappingKeyId)]}))}))},t.prototype.prepareAssembly=function(e){var t=e.subjectKey,n=e.rootKey;return R(this,void 0,void 0,(function(){var e,r,i,a,s,o,c,u,p;return E(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=d.sent(),console.log("prepareAssembly assemblyKey",e),r=e.toJSON(!0),i=r.k,a=P(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 R(this,void 0,void 0,(function(){var e=this;return E(this,(function(a){return[2,Promise.all(t.map((function(t,a){return R(e,void 0,void 0,(function(){var e,s,o=this;return E(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 R(o,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){var e=this;return E(this,(function(s){if(r.length!==t.length)throw new J("The slipSubAssemblies must be the same length as the input");return[2,Promise.all(t.map((function(t,s){return R(e,void 0,void 0,(function(){var e,o,c,u,p,d,l=this;return E(this,(function(y){switch(y.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=y.sent(),o=a.edges.find((function(e){return e.node.id===t.id})).node,c=[],u=[],t.approverTps.forEach((function(e){var t,n=null===(t=o.approvers.edges.find((function(t){return t.node.tp.id===e.tpId})))||void 0===t?void 0:t.node;n?u.push({tp:e,approverId:n.id}):c.push({tp:e})})),p=r[s],d={subAssemblyId:t.id,singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e},[4,Promise.all(c.map((function(e,t){var r=e.tp;return R(l,void 0,void 0,(function(){return E(this,(function(e){return[2,this.prepareApprover({tp:r,approverIndex:t,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return d.createApprovers=y.sent(),[4,Promise.all(u.map((function(e,t){var r=e.tp,a=e.approverId;return R(l,void 0,void 0,(function(){return E(this,(function(e){return[2,this.prepareApprover({approverId:a,tp:r,approverIndex:t+c.length,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 3:return[2,(d.updateApprovers=y.sent(),d)]}}))}))})))]}))}))},t.prototype.fillWrappingKeyId=function(e,t){var n=this;e.forEach((function(e){e.approverTps.forEach((function(e){if(!e.wrappingKeyId){var r=t.find((function(t){return t.id===e.tpId}));e.wrappingKeyId=n.getTpWrappingKeyId(r)}}))}))},t.prototype.getInputApprovers=function(e){var t=[];return e.forEach((function(e){e.approverTps.forEach((function(e){t.push(e.tpId)}))})),t},t.prototype.prepareCreate=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y;return E(this,(function(h){switch(h.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=h.sent(),[4,this.keyFactory.createKey()];case 2:return n=h.sent(),[4,this.keyGraph.wrapKey(t,n)];case 3:return r=h.sent(),[4,this.prepareAssembly({rootKey:t.jwk,subjectKey:n})];case 4:return i=h.sent(),a=i.assemblyKey,s=i.rawAssemblyKey,o=i.assemblyKeyParams,c=P(i,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),[4,this.prepareSlip39(e.createSubAssemblies,e.quorum,s)];case 5:return u=h.sent(),p=this.getInputApprovers(e.createSubAssemblies),l=zr,[4,this.lrGraphQl.query({query:ai,variables:{ids:p}})];case 6:return d=l.apply(void 0,[h.sent().tps]),this.fillWrappingKeyId(e.createSubAssemblies,d),[4,this.prepareCreateSubAssemblies({input:e.createSubAssemblies,assemblyKeyParams:o,slipSubAssemblies:u.subAssemblies,subjectKey:n})];case 7:return y=h.sent(),[2,{assemblyKey:a,mutationInput:Object.assign(Object.assign({},c),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:"",createSubAssemblies:y,rootKeyId:t.id,rootKeyWrappedSubjectKey:r})}]}}))}))},t.prototype.getAssemblyApprovers=function(e){var t=[];return zr(e.subAssemblies).map((function(e){zr(e.approvers).forEach((function(e){return t.push(e.tp.id)}))})),t},t.prototype.prepareUpdate=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,g,m,S;return E(this,(function(I){switch(I.label){case 0:if(e=Object.assign({createSubAssemblies:[]},e),n=e.createSubAssemblies||[],r=e.updateSubAssemblies||[],i=e.deleteSubAssemblies||[],0===n.length&&0===r.length&&0===i.length)throw new J("Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]");return[4,this.keyService.getCurrentRootKey()];case 1:return a=I.sent(),[4,this.keyGraph.getKey(t.subjectKey.id)];case 2:return s=I.sent(),[4,this.prepareAssembly({rootKey:a.jwk,subjectKey:s.jwk})];case 3:return o=I.sent(),c=o.assemblyKey,u=o.rawAssemblyKey,p=o.assemblyKeyParams,d=P(o,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),l=this.getAssemblyApprovers(t).concat(this.getInputApprovers(n),this.getInputApprovers(r)),h=zr,[4,this.lrGraphQl.query({query:ai,variables:{ids:l}})];case 4:y=h.apply(void 0,[I.sent().tps]),zr(t.subAssemblies).forEach((function(e){if(!i.includes(e.id)&&!r.some((function(t){return t.id===e.id}))){var t=zr(e.approvers).map((function(e){return{tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,sharedCipherApprovalDataClearJson:e.sharedCipherApprovalDataClearJson}}));r.push({id:e.id,quorum:e.quorum,singleReject:e.singleReject,approverTps:t,subjectCipherDataClearJson:e.subjectCipherDataClearJson})}})),this.fillWrappingKeyId(n,y),this.fillWrappingKeyId(r,y),I.label=5;case 5:return I.trys.push([5,7,,8]),[4,this.prepareSlip39((n||[]).concat(r||[]),e.quorum,u)];case 6:return f=I.sent(),[3,8];case 7:return v=I.sent(),console.log("Error while creating slip assembly",v),[3,8];case 8:return g={assemblyKeyParams:p,subjectKey:s.jwk},[4,this.prepareCreateSubAssemblies(Object.assign(Object.assign({},g),{input:n,slipSubAssemblies:f.subAssemblies.slice(0,n.length)}))];case 9:return m=I.sent(),[4,this.prepareUpdateSubAssemblies(Object.assign(Object.assign({},g),{input:r,slipSubAssemblies:f.subAssemblies.slice(n.length),subAssemblies:t.subAssemblies}))];case 10:return S=I.sent(),[2,{assemblyKey:c,mutationInput:Object.assign(Object.assign({},d),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:"",subjectKeyId:s.id,createSubAssemblies:m,updateSubAssemblies:S})}]}}))}))},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 R(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h;return E(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},console.log("partialAssemblyKey",d),[4,this.encryptionService.encryptToString(o,n.sharedCipherDataClearJson||"")];case 5:return l=f.sent(),[4,this.encryptionService.encryptToString(o,n.sharedCipherApprovalDataClearJson||"")];case 6:return y=f.sent(),[4,this.encryptionService.encryptToString(o,d)];case 7:return h=f.sent(),[2,{tpWrappingKeyId:e.id,tpWrappedSharedKey:c,subjectKeyWrappedSharedKey:u,sharedCipherData:l,sharedCipherApprovalData:y,sharedCipherPartialAssemblyKey:h,approverId:t||void 0,tpId:t?void 0:n.tpId}]}}))}))},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=A(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 J(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 R(this,void 0,void 0,(function(){var r;return E(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new J("Not enough sub assemblies to meet quorum");return r=new ti(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new ei(t,e.quorum,n))})),[4,this.slip39Service.generateShares(n,this.slip39Passphrase,r)];case 1:return i.sent(),[2,r]}}))}))},t}();e.ɵl=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase=ii,r}return w(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.mkSharedKey.id},t}(si),e.ɵl.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵl(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR))},token:e.ɵl,providedIn:"root"}),e.ɵl.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵl.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.ɵl=D([br({ngZoneName:"ngZone"})],e.ɵl);var oi=function(e){return function(){return e.initialise()}},ci=function(){function t(e,t,n,r,i,a,s,c,u,p,d,l,y,h){this.config=e,this.auth=t,this.keyFactory=n,this.keyService=r,this.profileService=i,this.keyGraphService=a,this.passwordService=s,this.idleService=c,this.lrGraphQL=u,this.tpPasswordResetProcessorService=p,this.persistService=d,this.encryptionService=l,this.slip39Service=y,this.assemblyController=h,this.hubSubject=new o.ReplaySubject(1)}return t.prototype.initialise=function(){return R(this,void 0,void 0,(function(){var e=this;return E(this,(function(t){return s.Hub.listen("auth",(function(t){return e.hubSubject.next(t.payload)})),[2]}))}))},t.prototype.loginIdpImpl=function(e,t,n,r){return R(this,void 0,void 0,(function(){var i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n))];case 1:return i=s.sent(),[4,this.auth.signIn(e,this.passwordService.getPassIdpString(i.jwk))];case 2:return(a=s.sent()).recoveryStatus=r,[2,a]}}))}))},t.prototype.loginIdp=function(t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o,c;return E(this,(function(u){switch(u.label){case 0:return[4,this.profileService.getPassIdpParams(t)];case 1:if((r=u.sent()).passwordChangeStatus===e.PasswordChangeStatus.InProgress)throw new V("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.Recovery)return[3,8];console.log("In recovery mode."),u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.loginIdpImpl(t,n,r.newPassIdpParams,e.RecoveryStatus.NEW_PASSWORD)];case 3:return a=u.sent(),console.log("New password works!"),[2,a];case 4:if("NotAuthorizedException"!==(i=u.sent()).code)throw i;return[3,5];case 5:return u.trys.push([5,7,,8]),[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.OLD_PASSWORD)];case 6:return a=u.sent(),console.log("Old password works!"),[2,a];case 7:throw"NotAuthorizedException"===(s=u.sent()).code?new W("The password change request was interrupted, please try to login with both your new and old password"):s;case 8:if(!r.tpPasswordReset)return[3,12];u.label=9;case 9:return u.trys.push([9,11,,12]),o=r.tpPasswordReset,[4,this.loginIdpImpl(o.resetUsername,n,o.passIdpParams,e.RecoveryStatus.NONE)];case 10:return(c=u.sent()).isTpPasswordResetUser=!0,[2,c];case 11:return u.sent(),[3,12];case 12:return[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.NONE)];case 13:return[2,u.sent()]}}))}))},t.prototype.handleSessionEncryptionKey=function(){return R(this,void 0,void 0,(function(){var e,t;return E(this,(function(r){switch(r.label){case 0:if(!this.config.disableSessionEncryptionKey)return[3,1];if(!n.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new Error(e);return console.warn("You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode."),[3,4];case 1:return[4,this.keyFactory.createKey()];case 2:return t=r.sent(),[4,this.lrGraphQL.lrMutate(new Tr({mutation:xn,variables:{input:{sessionEncryptionKey:JSON.stringify(t.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(t),r.label=4;case 4:return[2]}}))}))},t.prototype.handlePostAuth=function(e){return R(this,void 0,void 0,(function(){return E(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]}}))}))},t.prototype.login=function(t,n,r){var i,a=(void 0===r?{}:r).tpPasswordResetAutoComplete,s=void 0===a||a;return R(this,void 0,void 0,(function(){var r;return E(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return r=a.sent(),s&&(null===(i=r.resetUser)||void 0===i?void 0:i.state)===e.TpClaimState.APPROVED?[4,this.completeRequest(n)]:[3,4];case 2:return a.sent(),[4,this.loginImpl(t,n)];case 3:r=a.sent(),a.label=4;case 4:return[2,r]}}))}))},t.prototype.loginImpl=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(e,t)];case 2:return n=i.sent(),["SMS_MFA","SOFTWARE_TOKEN_MFA"].includes(n.challengeName)?[2,{hasChallenge:!0,challenge:n}]:[4,this.handlePostAuth(n)];case 3:return i.sent(),n.isTpPasswordResetUser?[4,this.loadResetUser(t)]:[3,5];case 4:return[2,{hasChallenge:!1,resetUser:i.sent()}];case 5:return[4,this.loadUser(n,t)];case 6:return r=i.sent(),[4,this.idleService.start()];case 7:return i.sent(),[2,{hasChallenge:!1,user:r}]}}))}))},t.prototype.verifyLogin=function(e,t,n,r){return R(this,void 0,void 0,(function(){var i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.auth.confirmSignIn(e,r,e.challengeName)];case 1:return s.sent(),[4,this.auth.currentAuthenticatedUser()];case 2:return i=s.sent(),[4,this.handlePostAuth(e)];case 3:return s.sent(),[4,this.loadUser(i,t)];case 4:return a=s.sent(),n&&i.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,a]}}))}))},t.prototype.handlePasswordRecovery=function(t){return R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return t.recoveryStatus===e.RecoveryStatus.NONE?[3,2]:(n=t.getSignInUserSession().getAccessToken().getJwtToken(),[4,this.passwordService.changePasswordComplete(n,t.recoveryStatus===e.RecoveryStatus.NEW_PASSWORD)]);case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.getUserOrResetUser=function(e){return void 0===e&&(e=!1),R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t.sent().getUsername().endsWith(".tp_password_reset")?[2,this.getResetUser(e)]:[2,this.getUser(e)]}}))}))},t.prototype.getResetUser=function(e){return void 0===e&&(e=!1),R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return!e&&this.currentResetUser?[2,this.currentResetUser]:(t=this,[4,this.loadResetUser()]);case 1:return t.currentResetUser=n.sent(),[4,this.idleService.start()];case 2:return n.sent(),[2,this.currentResetUser]}}))}))},t.prototype.getUser=function(e){return void 0===e&&(e=!1),R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return!e&&this.currentUser?[2,this.currentUser]:(t=this,n=this.loadUser,[4,this.auth.currentAuthenticatedUser()]);case 1:return[4,n.apply(this,[r.sent()])];case 2:return t.currentUser=r.sent(),console.log("Starting idle service."),[4,this.idleService.start()];case 3:return r.sent(),[2,this.currentUser]}}))}))},t.prototype.mapTPVaultAccess=function(e){var t=null==e?void 0:e.tpVault;return(null==t?void 0:t.length)>0&&t.some((function(e){return"ACCESS"===e.toUpperCase()}))},t.prototype.loadUser=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,l,y,h,f,v;return E(this,(function(g){switch(g.label){case 0:return[4,this.profileService.getCurrentUser()];case 1:return n=g.sent(),r=n.currentUser,i=n.contactCard,a=n.userPlans,r.sessionEncryptionKey?(o=(s=this.persistService).setServerSessionEncryptionKey,[4,p.JWK.asKey(r.sessionEncryptionKey)]):[3,3];case 2:o.apply(s,[g.sent()]),g.label=3;case 3:return[4,this.auth.userAttributes(e)];case 4:return c=g.sent(),t?[4,this.keyFactory.derivePassKey(Object.assign({password:t},r.currentUserKey.passKey.passKeyParams))]:[3,8];case 5:return u=g.sent().jwk,l=(d=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(r.currentUserKey.passKey.id,u,r.currentUserKey.masterKey.id)];case 6:return[4,l.apply(d,[g.sent()])];case 7:g.sent(),g.label=8;case 8:return[4,this.keyGraphService.populateKeys(r.currentUserKey)];case 9:return g.sent(),y={id:r.id,sub:this.getUserAttribute("sub",c),username:r.username,currentUserKey:r.currentUserKey,getAccessJwtToken:function(){return e.getSignInUserSession().getAccessToken().getJwtToken()},email:this.getUserAttribute("email",c),emailVerified:"true"===this.getUserAttribute("email_verified",c),phone:this.getUserAttribute("phone_number",c),phoneVerified:"true"===this.getUserAttribute("phone_number_verified",c)},f=(h=Object).assign,v=[{}],[4,this.profileService.decryptContactCard(i)];case 10:return[2,(y.contactCard=f.apply(h,v.concat([g.sent()])),y.userDelete=r.userDelete,y.userPlans=a,y.hasTPVaultAccess=this.mapTPVaultAccess(r.features),y.features=r.features,y.sessionEncryptionKey=r.sessionEncryptionKey,y)]}}))}))},t.prototype.watchAuth=function(){return this.hubSubject},t.prototype.logout=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.auth.signOut(),this.profileService.signOut()])];case 1:return e.sent(),[2]}}))}))},t.prototype.getUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},t.prototype.loadResetUser=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,l,y,h,f,v;return E(this,(function(g){switch(g.label){case 0:return[4,this.lrGraphQL.query({query:yr})];case 1:return(t=g.sent().tpPasswordResetUser).sessionEncryptionKey?(r=(n=this.persistService).setServerSessionEncryptionKey,[4,p.JWK.asKey(t.sessionEncryptionKey)]):[3,3];case 2:r.apply(n,[g.sent()]),g.label=3;case 3:return e?[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.passKey.passKeyParams))]:[3,7];case 4:return i=g.sent().jwk,s=(a=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,i,t.masterKey.id)];case 5:return[4,s.apply(a,[g.sent()])];case 6:g.sent(),g.label=7;case 7:return this.keyService.populateKeys({passKey:{id:t.passKey.id},masterKey:{id:t.masterKey.id}}),u=(c=this.auth).userAttributes,[4,this.auth.currentAuthenticatedUser()];case 8:return[4,u.apply(c,[g.sent()])];case 9:return o=g.sent(),d=this.getUserAttribute("sub",o),y=(l=Object).assign,f=(h=Object).assign,v=[{}],[4,this.tpPasswordResetProcessorService.processTpPasswordResetUserNode(t)];case 10:return[2,y.apply(l,[f.apply(h,v.concat([g.sent()])),{sub:d}])]}}))}))},t.prototype.refreshAccessToken=function(){return R(this,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),[2,new Promise((function(n,r){e.refreshSession(t,(function(e,t){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete: ",t),n(0))}))}))]}}))}))},t.prototype.completeRequest=function(t){return R(this,void 0,void 0,(function(){var n,r,i,a,o,c,u,d,l,y,h,f,v,g,m=this;return E(this,(function(S){switch(S.label){case 0:return[4,this.getResetUser(!0)];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new 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 i=S.sent().rootKey,console.log(i),[4,p.JWK.asKey(i)];case 4:return a=S.sent(),[4,this.keyGraphService.getKey(n.masterKey.id)];case 5:return o=S.sent(),[4,this.encryptionService.encryptToString(o.jwk,a.toJSON(!0))];case 6:return c=S.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n.passKey.passIdpParams))];case 7:return u=S.sent(),d=this.passwordService.getPassIdpString(u.jwk),[4,this.lrGraphQL.lrMutate(new Tr({mutation:cr,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return l=S.sent().createTpAssemblyKeyChallenge.challenge,console.log(l),l.clientNonce=this.keyFactory.randomString(32),console.log(l),[4,this.encryptionService.decrypt(r,n.wrappedAssemblyKeyVerifierPrk)];case 9:return y=S.sent(),[4,this.encryptionService.sign(y,l)];case 10:return h=S.sent(),[4,this.lrGraphQL.lrMutate(new Tr({mutation:ur,variables:{input:{signedChallenge:JSON.stringify(h)}}}),{includeKeyGraph:!1})];case 11:return f=S.sent().preCompleteTpPasswordResetRequest.idpPassword,v=new Promise((function(e){var t=function(r){return R(m,void 0,void 0,(function(){return E(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(s.Hub.remove("auth",t),console.log(r.payload),[4,this.auth.signIn(n.username,d)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new Tr({mutation:pr,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};s.Hub.listen("auth",t)})),[4,this.auth.signIn(n.username,f,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(g=S.sent()).challengeName)throw new L({message:"Internal error. Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation."});return[4,this.auth.completeNewPassword(g,d,{})];case 13:return g=S.sent(),[2,v]}}))}))},t.prototype.recoverAssemblyKey=function(e){return R(this,void 0,void 0,(function(){var t,n,r=this;return E(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)]}}))}))},t}();ci.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ci(n.ɵɵinject(te),n.ɵɵinject(d.AuthClass),n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(vn),n.ɵɵinject(ve),n.ɵɵinject(qn),n.ɵɵinject(Un),n.ɵɵinject(e.ɵh),n.ɵɵinject(e.ɵi),n.ɵɵinject(he),n.ɵɵinject(de),n.ɵɵinject(ni),n.ɵɵinject(e.ɵl))},token:ci,providedIn:"root"}),ci.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ci.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:d.AuthClass},{type:ye},{type:fe},{type:vn},{type:ve},{type:qn},{type:Un},{type:e.ɵh},{type:e.ɵi},{type:he},{type:de},{type:ni},{type:e.ɵl}]};var ui=function(){function e(e,t,n){this.config=e,this.http=t,this.lrAuth=n}return e.prototype.downloadEncryptedFile=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile2(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile2=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return t=this.config.apiUrl+"files/download/?file_state_node_id="+e,r=(n=this.http).get,i=[t],a={responseType:"text"},s={},o="Bearer ",[4,this.lrAuth.getUser()];case 1:return[4,r.apply(n,i.concat([(a.headers=(s.Authorization=o+c.sent().getAccessJwtToken(),s),a)])).toPromise()];case 2:return[2,c.sent()]}}))}))},e.prototype.loadFile=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.readAsArrayBuffer(e)}))]}))}))},e.prototype.uploadEncryptedFile=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return E(this,(function(p){switch(p.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],o={},c={},u="Bearer ",[4,this.lrAuth.getUser()];case 1:return[4,a.apply(i,s.concat([(o.headers=(c.Authorization=u+p.sent().getAccessJwtToken(),c),o)])).toPromise()];case 2:return[2,p.sent().content_resource]}}))}))},e}();ui.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ui(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ci))},token:ui,providedIn:"root"}),ui.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ui.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:ci}]};var pi,di,li,yi,hi=y(pi||(pi=M(["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"],["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"]))),fi=y(di||(di=M(["\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"]))),vi=y(li||(li=M(["\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"]))),gi=y(yi||(yi=M(["\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"]))),mi=function(){function e(e){this.lrApollo=e}return e.prototype.getUserByEmail=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.getUser({email:e})]}))}))},e.prototype.getUserByUsername=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.getUser({username:e})]}))}))},e.prototype.getUser=function(e){var t=e.email,n=e.username;return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:hi,variables:{email:t,username:n}})];case 1:return[2,e.sent().user]}}))}))},e.prototype.requestUserDelete=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:fi,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:vi,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),R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:gi,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();mi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new mi(n.ɵɵinject(ge))},token:mi,providedIn:"root"}),mi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],mi.ctorParameters=function(){return[{type:ge}]};var Si,Ii,Ci,bi,ki,Ki,wi,Pi,Di="\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n}",Ri="\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",Ei=y(Si||(Si=M(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""],["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""])),Ri,Oe),Ai=y(Ii||(Ii=M(["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"],["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"])),Di,Oe),Oi=y(Ci||(Ci=M(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),Di,Oe),Ti=y(bi||(bi=M(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"])),Di),Mi=y(ki||(ki=M(["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"],["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"])),Di,Me),ji=y(Ki||(Ki=M(["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),Di,Ri),$i=y(wi||(wi=M(["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),Di,Ri);(Pi=e.OtkState||(e.OtkState={})).OTK_INITIATED="OTK_INITIATED",Pi.OTK_ACCEPTED="OTK_ACCEPTED",Pi.OTK_COMPLETED="OTK_COMPLETED";var Ni=function(){function t(e,t,n,r,i,a){this.keyFactory=e,this.keyService=t,this.lrApollo=n,this.encryptionService=r,this.authService=i,this.userService=a,this.CLIENT_NONCE_LENGTH=32}return t.prototype.getKeyExchangeList=function(e){return void 0===e&&(e={}),R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Ai,variables:Object.assign({},e)})];case 1:return[2,t.sent().keyExchanges]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:i?Ti:Oi,variables:{id:e,token:i}})];case 1:return t=n.sent().keyExchange,[4,this.decryptKeyExchange(t,r)];case 2:return[2,n.sent()]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return R(this,void 0,void 0,(function(){var r;return E(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,n)];case 1:return n=i.sent(),[3,3];case 2:if("no key found"!==(r=i.sent()).message)throw r;return[3,3];case 3:return[4,this.encryptionService.decrypt(t,n)];case 4:return[2,i.sent()]}}))}))},t.prototype.decryptKeyExchange=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return E(this,(function(d){switch(d.label){case 0:return e.isInitiator?[4,this.keyService.getCurrentRootKey()]:[3,8];case 1:return n=d.sent(),[4,this.encryptionService.decrypt(n.jwk,e.initiatorRootKeyCipher)];case 2:return r=d.sent(),e.otk.initiatorOneTimePbkCipher?(s=this.decryptResponseCipher,[4,ye.asKey(r.otKey)]):[3,6];case 3:return o=[d.sent()],[4,ye.asKey(r.oneTimePrk)];case 4:return[4,s.apply(this,o.concat([d.sent(),e.otk.initiatorOneTimePbkCipher]))];case 5:return a=d.sent(),[3,7];case 6:a=null,d.label=7;case 7:return c=(i=a)&&i.responder,p=r&&r.initiator,[2,Object.assign(Object.assign({},e),{message:c?c.message:null,contactCard:c&&c.contactCard?c.contactCard.plainSharedCipherDataJson:null,myContactCard:p&&p.contactCard?p.contactCard.plainSharedCipherDataJson:null,myMessage:p&&p.message})];case 8:return[4,this.decryptOtk(e,t)];case 9:return u=d.sent(),p=u&&u.plainOtKeyCipher.initiator,[2,Object.assign(Object.assign({},e),{decryptedOtk:u,message:p&&p.message,contactCard:p&&p.contactCard&&p.contactCard.plainSharedCipherDataJson})]}}))}))},t.prototype.decryptOtk=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.getOtKey(e,t)];case 1:return(n=a.sent())&&e.otk.otKeyCipher?(i={},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:return i.plainOtKeyCipher=a.sent(),i.otKey=n,r=i,[3,4];case 3:r=null,a.label=4;case 4:return[2,r]}}))}))},t.prototype.getOtKey=function(t,n){return R(this,void 0,void 0,(function(){var r,i;return E(this,(function(a){switch(a.label){case 0:return n?[4,ye.asKey(Object.assign(Object.assign({},JSON.parse(t.otk.otKeyParams)),{k:n}))]:[3,2];case 1:return[2,a.sent()];case 2:return t.otk.state!==e.OtkState.OTK_INITIATED||t.isInitiator||!t.otk.responderPbkCipher?[3,6]:[4,this.keyService.getCurrentPxk()];case 3:return r=a.sent(),[4,this.encryptionService.decrypt(r.jwk,JSON.parse(t.otk.responderPbkCipher),{serializations:[ae.COMPACT]})];case 4:return(i=a.sent()).otKey?[4,ye.asKey(i.otKey)]:[3,6];case 5:return[2,a.sent()];case 6:return[2,null]}}))}))},t.prototype.initiateOtk=function(e){var t=e.message,n=e.email,r=e.contactCard,i=e.upgrade;return R(this,void 0,void 0,(function(){var e,a,s,o,c,u,p,d,l,y,h,f,v,g,m,S;return E(this,(function(I){switch(I.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=I.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.authService.getUser()];case 2:return s=I.sent(),[4,this.keyFactory.createPkcKey()];case 3:return o=I.sent(),[4,this.keyService.getCurrentPxk()];case 4:return c=I.sent(),[4,this.keyService.getCurrentSigPxk()];case 5:return u=I.sent(),p=null,r&&r.ownerPlainData?(l=(d=JSON).stringify,[4,this.encryptionService.sign(u.jwk,r.ownerPlainData)]):[3,7];case 6:p=l.apply(d,[I.sent()]),I.label=7;case 7:return y={message:t,contactCard:r?{plainSharedCipherDataJson:r.plainSharedCipherDataJson}:null},h={nonce:a,initiator:Object.assign(Object.assign({},y),{oneTimePbk:o.toJSON(),pbk:c.jwk.toJSON(),sigPbk:u.jwk.toJSON(),profile:{username:s.username}})},[4,this.encryptionService.encrypt(e,h)];case 8:return f=I.sent(),v={nonce:a,oneTimePrk:o.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:r,initiator:y},[4,this.keyService.getCurrentRootKey()];case 9:return g=I.sent(),[4,this.encryptionService.encrypt(g.jwk,v)];case 10:return m=I.sent(),S=e.toJSON(!0).k,[4,this.lrApollo.mutate({mutation:Mi,variables:{input:{initiatorRootKeyCipher:JSON.stringify(m),initiatorPxkId:c.id,initiatorSigPxkId:u.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:JSON.stringify(f),sendEmail:n?{email:n,rawOtKey:S}:null,createTp:!0,initiatorPlainDataSig:p,upgrade:i}}})];case 11:return[2,{keyExchange:I.sent().initiateKeyExchangeOtk.keyExchange,otKeyK:S}]}}))}))},t.prototype.respondOtk=function(e){var t=e.id,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return R(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b,k,K,w,P,D,R,A,O,T,M,j,$,N,F,L,x,U,J,_,q,G,B,V,Q,W,Z,H,Y,z,X,ee,te,ne,re;return E(this,(function(E){switch(E.label){case 0:return[4,this.authService.getUser()];case 1:return e=E.sent(),[4,this.keyService.getCurrentRootKey()];case 2:return o=E.sent(),c=this.keyService.getCurrentMasterKey().id,[4,this.keyService.getCurrentMasterKey()];case 3:return u=E.sent(),[4,this.keyFactory.createKey()];case 4:return p=E.sent(),[4,this.keyFactory.createKey()];case 5:return d=E.sent(),[4,this.encryptionService.encrypt(o.jwk,p.toJSON(!0))];case 6:return l=E.sent(),[4,this.encryptionService.encrypt(u.jwk,d.toJSON(!0))];case 7:return y=E.sent(),[4,ye.asKey(r.plainOtKeyCipher.initiator.oneTimePbk)];case 8:return h=E.sent(),[4,ye.asKey(r.plainOtKeyCipher.initiator.pbk)];case 9:return f=E.sent(),[4,ye.asKey(r.plainOtKeyCipher.initiator.sigPbk)];case 10:return v=E.sent(),[4,this.keyService.getCurrentPxk()];case 11:return g=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 12:return m=E.sent(),[4,this.encryptionService.sign(m.jwk,f.toJSON())];case 13:return S=E.sent(),[4,this.encryptionService.sign(m.jwk,v.toJSON())];case 14:return I=E.sent(),C={nonce:r.plainOtKeyCipher.nonce,sharedKey:p.toJSON(!0),mkSharedKey:d.toJSON(!0),responder:{pbk:g.jwk.toJSON(),sigPbk:m.jwk.toJSON(),profile:{username:e.username},message:i}},r.plainOtKeyCipher.initiator.contactCard?(k=r.plainOtKeyCipher.initiator.contactCard.plainSharedCipherDataJson,[4,this.keyFactory.createKey()]):[3,25];case 15:return K=E.sent(),[4,this.keyFactory.createKey()];case 16:return x=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 17:return U=E.sent(),w={},D=(P=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,K.toJSON(!0))];case 18:return w.receiverWrappedKey=D.apply(P,[E.sent()]),w.receiverWrappingKeyId=o.id,a?(O=(A=JSON).stringify,[4,this.encryptionService.encrypt(K,a.plainReceiverCipherDataJson)]):[3,20];case 19:return R=O.apply(A,[E.sent()]),[3,21];case 20:R="",E.label=21;case 21:return w.receiverCipherData=R,M=(T=JSON).stringify,[4,this.encryptionService.encrypt(p,x.toJSON(!0))];case 22:return w.sharedWrappedKey=M.apply(T,[E.sent()]),b=w,[4,this.encryptionService.encrypt(x,k)];case 23:return Z=E.sent(),j=b,N=($=JSON).stringify,[4,this.encryptionService.sign(U.jwk,Z)];case 24:j.sharedCipherDataSig=N.apply($,[E.sent()]),b.sigPxkId=U.id,C.responder.contactCard=Object.assign(Object.assign({},C.responder.contactCard),{sharedCipherKey:x.toJSON(!0)}),E.label=25;case 25:return s?[4,this.keyFactory.createKey()]:[3,38];case 26:return L=E.sent(),[4,this.keyFactory.createKey()];case 27:return x=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 28:return U=E.sent(),J={},q=(_=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,L.toJSON(!0))];case 29:return J.ownerWrappedKey=q.apply(_,[E.sent()]),J.ownerWrappingKeyId=o.id,s.plainOwnerCipherDataJson?(V=(B=JSON).stringify,[4,this.encryptionService.encrypt(L,s.plainOwnerCipherDataJson)]):[3,31];case 30:return G=V.apply(B,[E.sent()]),[3,32];case 31:G="",E.label=32;case 32:return J.ownerCipherData=G,W=(Q=JSON).stringify,[4,this.encryptionService.encrypt(p,x.toJSON(!0))];case 33:return J.sharedWrappedKey=W.apply(Q,[E.sent()]),F=J,[4,this.encryptionService.encrypt(x,s.plainSharedCipherDataJson)];case 34:return Z=E.sent(),H=F,z=(Y=JSON).stringify,[4,this.encryptionService.sign(U.jwk,Z)];case 35:return H.sharedCipherDataSig=z.apply(Y,[E.sent()]),F.sigPxkId=U.id,s.ownerPlainData?(X=F,te=(ee=JSON).stringify,[4,this.encryptionService.sign(m.jwk,s.ownerPlainData)]):[3,37];case 36:X.ownerPlainDataSig=te.apply(ee,[E.sent()]),E.label=37;case 37:C.responder.contactCard=Object.assign(Object.assign({},C.responder.contactCard),{plainSharedCipherDataJson:s.plainSharedCipherDataJson}),E.label=38;case 38:return[4,this.encryptionService.encrypt(h,C)];case 39:return ne=E.sent(),[4,this.encryptionService.encrypt(r.otKey,ne)];case 40:return ne=E.sent(),[4,this.lrApollo.mutate({mutation:ji,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:o.id,masterKeyId:c,responderPxkId:g.id,responderSigPxkId:m.id,signedInitiatorPbk:JSON.stringify(S),signedInitiatorSigPbk:JSON.stringify(I),rkWrappedSharedKey:JSON.stringify(l),mkWrappedMkSharedKey:JSON.stringify(y),initiatorOneTimePbkCipher:JSON.stringify(ne),initiatorContactCard:b,responderContactCard:F}}})];case 41:return[2,{keyExchange:(re=E.sent().respondKeyExchangeOtk).keyExchange,userSharedKey:re.userSharedKey,tp:re.tp}]}}))}))},t.prototype.completeOtk=function(e,t,n,r){return R(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b,k,K,w,P,D,R,A,O,T,M,j,$,N,F,L,x,U,J,_;return E(this,(function(E){switch(E.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return i=E.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return a=E.sent(),[4,this.encryptionService.decrypt(i.jwk,t)];case 3:return s=E.sent(),c=this.decryptResponseCipher,[4,ye.asKey(s.otKey)];case 4:return u=[E.sent()],[4,ye.asKey(s.oneTimePrk)];case 5:return[4,c.apply(this,u.concat([E.sent(),n]))];case 6:if(o=E.sent(),s.nonce!==o.nonce)throw new B("The nonce returned by responder does not match with the one created by the initiator.");return[4,this.keyService.getCurrentSigPxk()];case 7:return p=E.sent(),[4,ye.asKey(o.responder.sigPbk)];case 8:return d=E.sent(),[4,ye.asKey(o.responder.pbk)];case 9:return l=E.sent(),[4,this.encryptionService.sign(p.jwk,l.toJSON())];case 10:return y=E.sent(),[4,this.encryptionService.sign(p.jwk,d.toJSON())];case 11:return h=E.sent(),[4,ye.asKey(o.sharedKey)];case 12:return f=E.sent(),[4,this.encryptionService.encrypt(i.jwk,f.toJSON(!0))];case 13:return v=E.sent(),[4,ye.asKey(o.mkSharedKey)];case 14:return g=E.sent(),[4,this.encryptionService.encrypt(a.jwk,g.toJSON(!0))];case 15:return m=E.sent(),r?[4,this.keyFactory.createKey()]:[3,19];case 16:return I=E.sent(),C={},k=(b=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,I.toJSON(!0))];case 17:return C.receiverWrappedKey=k.apply(b,[E.sent()]),C.receiverWrappingKeyId=i.id,w=(K=JSON).stringify,[4,this.encryptionService.encrypt(I,r)];case 18:C.receiverCipherData=w.apply(K,[E.sent()]),S=C,E.label=19;case 19:return s.initiatorContactCard?(R=s.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,28];case 20:return A=E.sent(),[4,ye.asKey(o.responder.contactCard.sharedCipherKey)];case 21:return O=E.sent(),j=(M=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,A.toJSON(!0))];case 22:return T=j.apply(M,[E.sent()]),R.plainOwnerCipherDataJson?(L=(F=JSON).stringify,[4,this.encryptionService.encrypt(A,R.plainOwnerCipherDataJson)]):[3,24];case 23:return N=L.apply(F,[E.sent()]),[3,25];case 24:N="",E.label=25;case 25:return $=N,P={ownerWrappedKey:T,ownerWrappingKeyId:i.id,ownerCipherData:$},D={sigPxkId:p.id},[4,this.encryptionService.encrypt(O,R.plainSharedCipherDataJson)];case 26:return x=E.sent(),U=D,_=(J=JSON).stringify,[4,this.encryptionService.sign(p.jwk,x)];case 27:U.sharedCipherDataSig=_.apply(J,[E.sent()]),E.label=28;case 28:return[4,this.lrApollo.mutate({mutation:$i,variables:{input:{keyExchangeId:e,rootKeyId:i.id,masterKeyId:a.id,initiatorSigPxkId:p.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(h),rkWrappedSharedKey:JSON.stringify(v),mkWrappedMkSharedKey:JSON.stringify(m),responderContactCardCipher:S,initiatorContactCardCipher:P,initiatorContactCardSharedCipher:D}}})];case 29:return[2,E.sent().completeKeyExchangeOtk]}}))}))},t.prototype.currentUserSharedKey=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Ei,variables:{username:e.username,userId:e.userId}})];case 1:return[2,t.sent().currentUserSharedKey.userSharedKey]}}))}))},t}();Ni.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ni(n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(ge),n.ɵɵinject(de),n.ɵɵinject(ci),n.ɵɵinject(mi))},token:Ni,providedIn:"root"}),Ni.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ni.ctorParameters=function(){return[{type:ye},{type:fe},{type:ge},{type:de},{type:ci},{type:mi}]};var Fi,Li,xi=y(Fi||(Fi=M(["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"],["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"]))),Ui=y(Li||(Li=M(["\n query Message($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query Message($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Oe),Ji=function(){function e(e,t,n,r){this.lrApollo=e,this.keyGraph=t,this.encryptionService=n,this.keyExchangeService=r,this.encrypt=this.encryptionService.encrypt.bind(this.encryptionService),this.decrypt=this.encryptionService.decrypt.bind(this.encryptionService),this.sign=this.encryptionService.sign.bind(this.encryptionService),this.verify=this.encryptionService.verify.bind(this.encryptionService)}return e.prototype.sendMessage=function(e){var t=e.username,n=e.userId,r=e.plainMessageJson,i=e.plainCipherMessageJson;return R(this,void 0,void 0,(function(){var e,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return[4,this.keyExchangeService.currentUserSharedKey({username:t,userId:n})];case 1:return e=p.sent(),a={receiverUsername:t,receiverId:n,sharedKeyId:e.sharedKey.id,senderSigPbkId:e.userSigPrk.id},i?[4,this.keyGraph.getJwkKey(e.sharedKey.id)]:[3,6];case 2:return s=p.sent(),[4,this.encrypt(s,i)];case 3:return o=p.sent(),[4,this.keyGraph.getJwkKey(e.userSigPrk.id)];case 4:return c=p.sent(),[4,this.sign(c,o)];case 5:u=p.sent(),a.signedCipherMessage=JSON.stringify(u),p.label=6;case 6:return r&&(a.plainMessage=JSON.stringify(r)),[4,this.lrApollo.query({query:xi,variables:{input:a}})];case 7:return[2,p.sent().sendMessage]}}))}))},e.prototype.decryptMessage=function(e,t){var n=t.sharedKey,r=t.senderSigPbk;return R(this,void 0,void 0,(function(){var t,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.verify(r,JSON.parse(e.signedCipherMessage))];case 1:return t=a.sent(),i=e,[4,this.decrypt(n,t)];case 2:return i.plainSignedCipherMessageJson=a.sent(),[2]}}))}))},e.prototype.getMessage=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:Ui,variables:{id:e}})];case 1:return t=a.sent(),this.keyGraph.addKeys(t.keyGraph),n=t.message,[4,this.keyGraph.getJwkKey(n.sharedKey.id)];case 2:return r=a.sent(),[4,this.keyGraph.getJwkKey(n.senderSigPbk.id)];case 3:return i=a.sent(),[4,this.decryptMessage(n,{sharedKey:r,senderSigPbk:i})];case 4:return a.sent(),n.plainMessage&&(n.plainMessageJson=JSON.parse(n.plainMessage)),[2,t.message]}}))}))},e}();Ji.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ji(n.ɵɵinject(ge),n.ɵɵinject(ve),n.ɵɵinject(de),n.ɵɵinject(Ni))},token:Ji,providedIn:"root"}),Ji.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ji.ctorParameters=function(){return[{type:ge},{type:ve},{type:de},{type:Ni}]};var _i,qi,Gi,Bi,Vi,Qi=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()}},Wi=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=Qi(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}},Zi=y(_i||(_i=M(["\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"]))),Hi=y(qi||(qi=M(["\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"]))),Yi=y(Gi||(Gi=M(["\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"]))),zi=y(Bi||(Bi=M(["\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"]))),Xi=y(Vi||(Vi=M(["\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"]))),ea=function(){function e(e,t,n,r,i,a,s,o,c,u){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.authService=i,this.keyFactory=a,this.keyService=s,this.encryptionService=o,this.keyGraph=c,this.passwordService=u,this.CLIENT_NONCE_LENGTH=32,this.LBOP_WORDS=25}return e.prototype.getPartial=function(e){return e.split(" ")[0]},e.prototype.remove=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Hi,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteLbop.id]}}))}))},e.prototype.update=function(e){var t=e.id,n=e.name;return R(this,void 0,void 0,(function(){var e,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.get(t)];case 1:return(e=a.sent()).name=n,[4,this.keyService.getCurrentMasterKey()];case 2:return r=a.sent(),[4,this.encryptionService.encrypt(r.jwk,e)];case 3:return i=a.sent(),[4,this.lrApollo.mutate({mutation:Yi,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 4:return[2,a.sent().updateLbop]}}))}))},e.prototype.get=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:zi,variables:{id:e}})];case 1:return t=i.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return n=i.sent(),[4,this.encryptionService.decrypt(n.jwk,JSON.parse(t.lbop.cipherMeta))];case 3:return r=i.sent(),[2,Object.assign({id:t.id},r)]}}))}))},e.prototype.list=function(){return R(this,void 0,void 0,(function(){var e,t,n=this;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Xi})];case 1:return e=r.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return t=r.sent(),[2,Promise.all(e.lbops.edges.map((function(e){return R(n,void 0,void 0,(function(){var n;return E(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)]}}))}))})))]}}))}))},e.prototype.create=function(e){var t=e.name;return R(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,y,h;return E(this,(function(f){switch(f.label){case 0:if(1024!==I.Slip39Helper.WORD_LIST.length)throw new G("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=f.sent(),r=function(){n=i.keyFactory.randomChoices(I.Slip39Helper.WORD_LIST,i.LBOP_WORDS).join(" ");var t=i.getPartial(n);if(!e.some((function(e){return e.partial===t})))return"break"},i=this;"break"!==r(););return[4,this.keyFactory.createLbopKeyParams()];case 2:return a=f.sent(),[4,this.keyFactory.deriveLbopKey(Object.assign({password:n},a))];case 3:return s=f.sent().jwk,[4,this.keyFactory.createSignKey()];case 4:return o=f.sent(),[4,this.encryptionService.encrypt(s,o.toJSON(!0))];case 5:return c=f.sent(),[4,this.authService.getUser()];case 6:return u=f.sent(),[4,this.keyGraph.getKey(u.currentUserKey.masterKey.id)];case 7:return p=f.sent(),[4,this.encryptionService.encrypt(s,p.jwk.toJSON(!0))];case 8:return d=f.sent(),l=Object.assign(Object.assign({},t&&{name:t}),{partial:this.getPartial(n)}),[4,this.encryptionService.encrypt(p.jwk,l)];case 9:return y=f.sent(),[4,this.lrApollo.mutate({mutation:Zi,variables:{input:{cipherMeta:JSON.stringify(y),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(o.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(c),masterKeyId:u.currentUserKey.masterKey.id,wrappedMasterKey:JSON.stringify(d)}}})];case 10:return h=f.sent(),[2,Object.assign(Object.assign({},h.createLbop.lbop),{lbopString:n})]}}))}))},e.prototype.verifyLbops=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return E(this,(function(y){switch(y.label){case 0:n=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),y.label=1;case 1:y.trys.push([1,10,11,12]),r=A(e.lbops),i=r.next(),y.label=2;case 2:return i.done?[3,9]:(a=i.value,[4,this.keyFactory.deriveLbopKey(Object.assign({password:t},a.lbopKeyParams))]);case 3:s=y.sent().jwk,y.label=4;case 4:return y.trys.push([4,7,,8]),[4,this.encryptionService.decrypt(s,a.wrappedLbopKeyVerifier)];case 5:return o=y.sent(),c=e.challenge.serverNonce,[4,this.encryptionService.sign(o,{serverNonce:c,clientNonce:n})];case 6:return u=y.sent(),[2,{lbop:a,signedChallenge:u,lbopKey:s}];case 7:return y.sent(),[3,8];case 8:return i=r.next(),[3,2];case 9:return[3,12];case 10:return p=y.sent(),d={error:p},[3,12];case 11:try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(d)throw d.error}return[7];case 12:throw new L({source:"LBOP",code:"INVALID_PASSPHRASE",message:"Invalid passphrase."})}}))}))},e.prototype.verifyContact=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},e.prototype.confirmContact=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e.claimId,v_code:e.vCode}).toPromise()]}))}))},e.prototype.verify=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return E(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=ye).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)]}}))}))},e.prototype.setPassword=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(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 L({message:"Internal error. 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()]}}))}))},e}();ea.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ea(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ge),n.ɵɵinject(d.AuthClass),n.ɵɵinject(ci),n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(qn))},token:ea,providedIn:"root"}),ea.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ea.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:ge},{type:d.AuthClass},{type:ci},{type:ye},{type:fe},{type:de},{type:ve},{type:qn}]};var ta=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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){return E(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"),R(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,y,h,f,v,g;return E(this,(function(m){switch(m.label){case 0:return[4,this.passwordService.createPassKeyBundle(t)];case 1:return a=m.sent(),[4,this.keyFactory.createKey()];case 2:return s=m.sent(),[4,this.encryptionService.encrypt(a.passKey,s.toJSON(!0))];case 3:return o=m.sent(),[4,this.keyFactory.createKey()];case 4:return c=m.sent(),[4,this.encryptionService.encrypt(s,c.toJSON(!0))];case 5:return u=m.sent(),[4,this.keyFactory.createPkcKey()];case 6:return p=m.sent(),[4,this.encryptionService.encrypt(c,p.toJSON(!0))];case 7:return d=m.sent(),[4,this.keyFactory.createPkcSignKey()];case 8:return l=m.sent(),[4,this.encryptionService.encrypt(c,l.toJSON(!0))];case 9:return y=m.sent(),[4,this.http.post(this.config.authUrl+"users/",{claims:[{type:i,token:r,claim_id:n}],pass_idp_params:a.passIdpParams,pass_idp_verifier_pbk:a.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:a.wrappedPassIdpVerifierPrk,pass_key_params:a.passKeyParams,wrapped_master_key:o,wrapped_root_key:u,pbk:p.toJSON(),wrapped_prk:d,sig_pbk:l.toJSON(),wrapped_sig_prk:y}).toPromise()];case 10:return h=m.sent(),f={},h.claims.forEach((function(e){f[e.type]=e.value})),v=this.keyFactory.randomDigitsNoZeros(4),[4,this.auth.signUp({username:e.split("@")[0]+"."+v,password:this.passwordService.getPassIdpString(a.passIdp),attributes:f,clientMetadata:{user_id:String(h.id),user_pre_sign_up_token:String(h.pre_sign_up_token)}})];case 11:return[2,{username:(g=m.sent()).user.getUsername(),userId:h.id,preSignUpToken:h.pre_sign_up_token,userSub:g.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return R(this,void 0,void 0,(function(){var t;return E(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}();ta.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ta(n.ɵɵinject(te),n.ɵɵinject(d.AuthClass),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ye),n.ɵɵinject(de),n.ɵɵinject(qn))},token:ta,providedIn:"root"}),ta.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ta.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:d.AuthClass},{type:t.HttpClient},{type:ye},{type:de},{type:qn}]};var na,ra=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return R(this,void 0,void 0,(function(){var e;return E(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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){var e,t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=O.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 J("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return R(this,void 0,void 0,(function(){var t;return E(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}();ra.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ra(n.ɵɵinject(d.AuthClass))},token:ra,providedIn:"root"}),ra.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ra.ctorParameters=function(){return[{type:d.AuthClass}]},(na=e.FileType||(e.FileType={})).RecordContent="record-content",na.RecordAttachment="record-attachment";var ia,aa,sa,oa,ca,ua,pa,da,la,ya=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordContent}}]}),ha=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordAttachment}}]}),fa=function(e){return void 0===e&&(e=5),y(ia||(ia=M(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ","\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ","\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),mt,Dt(e),Oe)},va=y(aa||(aa=M(["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),ga=y(sa||(sa=M(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),ma=y(oa||(oa=M(["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Sa=y(ca||(ca=M(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Ia=y(ua||(ua=M(["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"],["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"]))),Ca=y(pa||(pa=M(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),ba=y(da||(da=M(["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"],["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"])));(la=e.AccessLevel||(e.AccessLevel={})).Owner="OWNER",la.Admin="ADMIN",la.Writer="WRITER",la.Reader="READER",la.Deny="DENY";var ka=function(){},Ka=function(){},wa=function(){},Pa=function(){},Da=function(){},Ra=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(Da),Ea=function(){},Aa=function(){},Oa=function(){},Ta=function(){},Ma=function(){function t(e,t,n){this.lrApollo=e,this.keyMetaService=t,this.keyGraph=n}return t.prototype.getRootDirectoryIds=function(e){return void 0===e&&(e=null),R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:bt,variables:{archived:e&&e.archived}})];case 1:return[2,t.sent().rootDirectories.edges.map((function(e){return e.node.id}))]}}))}))},t.prototype.getDefaultVault=function(){return R(this,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Kt,variables:{plainMetaFilter:ft}})];case 1:return e=n.sent().list,[4,this.mapVaults(e)];case 2:if((t=n.sent()).length>1)throw new ee("There are more than one default vaults");return[2,t[0]||null]}}))}))},t.prototype.getCategories=function(e){return void 0===e&&(e=null),R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:kt,variables:{vaultFilter:ft,categoryFilter:vt,recordFilter:gt,archived:e&&e.archived}})];case 1:if(!((t=n.sent()).vaults.edges.length>1))return[3,2];throw new ee("There is more than one default vault");case 2:return t.vaults.edges.length<1?(console.error("There is no default vault."),[2,[]]):[3,3];case 3:return[4,this.mapCategories(t.vaults.edges[0].node.childDirectoryLinks)];case 4:return[2,n.sent()]}}))}))},t.prototype.getTrustedPartyCategories=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:wt,variables:{trustedPartyId:e,categoryFilter:vt,recordFilter:gt,contentFilter:ya}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.sharedItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.sharedItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getMySharedCategories=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Pt,variables:{trustedPartyId:e,categoryFilter:vt,recordFilter:gt,contentFilter:ya}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.myItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.myItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getCategory=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return[4,this.lrApollo.query({query:Rt(),variables:{id:e,categoryFilter:vt,recordFilter:gt,contentFilter:ya}})];case 1:return t=p.sent().category,n={},i=(r=Object).assign,s=(a=Object).assign,o=[{}],[4,this.mapCategory(t)];case 2:return c=[s.apply(a,o.concat([p.sent()]))],u={},[4,this.mapParentCategories(t)];case 3:return n.category=i.apply(r,c.concat([(u.parents=p.sent(),u)])),[4,this.mapCategories(t.subCategories)];case 4:return n.subCategories=p.sent(),[4,this.mapRecords(t.records)];case 5:return[2,(n.records=p.sent(),n)]}}))}))},t.prototype.mapVaults=function(e){return R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){return[2,Promise.all(e.edges.map((function(e){return t.mapVault(e.node)})))]}))}))},t.prototype.mapCategories=function(e){return R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapCategory(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.mapRecords=function(e){return R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapRecord(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.createDefaultVault=function(){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return"",[4,this.keyMetaService.wrapContent("")];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:Ot,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Vault,default:!0}),cipherMeta:t.cipherMeta,parentRootDirectory:t.rootKey}})];case 2:return[2,n.sent().new.vault.id]}}))}))},t.prototype.createCategory=function(t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return n={name:t.name,code:t.code,isCustom:t.isCustom,allowRecords:t.allowRecords,allowCustomCategories:t.allowCustomCategories},[4,this.keyMetaService.wrapContent(n,t.categoryIds)];case 1:return r=i.sent(),[4,this.lrApollo.mutate({mutation:At,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:!1}),cipherMeta:r.cipherMeta,parentDirectories:r.wrappedKeys,parentRootDirectory:r.rootKey}})];case 2:return[2,i.sent().new.category.id]}}))}))},t.prototype.updateCategory=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i;return E(this,(function(a){switch(a.label){case 0:return r={name:n.name,code:n.code,isCustom:n.isCustom,allowRecords:n.allowRecords,allowCustomCategories:n.allowCustomCategories},[4,this.keyGraph.encryptToString(t,r)];case 1:return i=a.sent(),[4,this.lrApollo.mutate({mutation:Tt,variables:{input:{directoryId:e,cipherMeta:i}}})];case 2:return a.sent(),[2]}}))}))},t.prototype.setCategoryVisibility=function(t,n){return R(this,void 0,void 0,(function(){return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.mutate({mutation:Tt,variables:{input:{directoryId:t,plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:n})}}})];case 1:return r.sent(),[2]}}))}))},t.prototype.deleteCategory=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Mt,variables:{categoryId:e}})];case 1:return t.sent(),[2]}}))}))},t.prototype.archiveCategory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.archiveDirectory(e,t)]}))}))},t.prototype.unarchiveCategory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.unarchiveDirectory(e,t)]}))}))},t.prototype.archiveDirectory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:jt,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.unarchiveDirectory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:$t,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapVault=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(e)];case 1:return t=(r.sent()||{}).name,[2,{id:e.id,keyId:e.keyId,name:t}];case 2:return n=r.sent(),console.error("Failed to decrypt Vault.",n,e),[2,null];case 3:return[2]}}))}))},t.prototype.mapParentCategories=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return e.parentCategories&&e.parentCategories.edges&&e.parentCategories.edges.length?(t=e.parentCategories.edges[0].node.parentDirectory,[4,this.mapParentCategories(t)]):[2,[]];case 1:return n=[r.sent()],[4,this.mapCategory(t)];case 2:return[2,T.apply(void 0,n.concat([[r.sent()]]))]}}))}))},t.prototype.mapCategory=function(t){var n;return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return E(this,(function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(t)];case 1:return r=l.sent()||{},i=r.name,a=r.isCustom,s=r.allowRecords,o=r.allowCustomCategories,c=r.code,u=(t.plainMeta&&JSON.parse(t.plainMeta)||{}).isHidden,p=t.accessRoles&&t.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:t.id,keyId:t.keyId,code:c,name:i,isHidden:!!u,isCustom:!!a,isArchived:!!t.archived,allowRecords:!!s,allowCustomCategories:!!o,isEmpty:t.descendantDirectories?0===t.descendantDirectories.recordsCount:null,allRecordsCount:null===(n=t.descendantDirectories)||void 0===n?void 0:n.recordsCount,myAccessLevel:p?e.AccessLevel.Owner:t.accessRoles[0].role,sharedAccess:p?t.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[]}];case 2:return d=l.sent(),console.error("Failed to decrypt Category.",d,t),[2,null];case 3:return[2]}}))}))},t.prototype.mapRecord=function(t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),n=t.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(n.currentVersion.state)];case 1:return r=c.sent()||{},i=r.name,a=r.recordType,s=t.accessRoles&&t.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:t.id,keyId:t.keyId,name:i,recordType:a,isArchived:!!t.archived,createdOn:t.created,lastModified:new Date(t.modified)>new Date(n.currentVersion.state.modified)?t.modified:n.currentVersion.state.modified,myAccessLevel:s?e.AccessLevel.Owner:t.accessRoles[0].role,sharedAccess:s?t.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[]}];case 2:return o=c.sent(),console.error("Failed to decrypt Record.",o),[2,null];case 3:return[2]}}))}))},t}();Ma.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ma(n.ɵɵinject(ge),n.ɵɵinject(Nt),n.ɵɵinject(ve))},token:Ma,providedIn:"root"}),Ma.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ma.ctorParameters=function(){return[{type:ge},{type:Nt},{type:ve}]};var ja=function(){},$a=function(){function e(e,t){this.http=e,this.categoryService=t}return e.prototype.getCoreCategories=function(){return R(this,void 0,void 0,(function(){var e;return E(this,(function(t){switch(t.label){case 0:return this.categories?[3,2]:(e=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 1:e.categories=t.sent(),t.label=2;case 2:return[2,Promise.resolve(this.categories)]}}))}))},e.prototype.loadCategories=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p=this;return E(this,(function(d){switch(d.label){case 0:return n?[4,this.categoryService.getTrustedPartyCategories(n)]:[3,2];case 1:return i=d.sent().categories,[3,4];case 2:return[4,this.categoryService.getCategories()];case 3:i=d.sent(),d.label=4;case 4:return r=i,t?[4,this.categoryService.getCategory(t)]:[3,6];case 5:return s=d.sent(),[3,7];case 6:s=null,d.label=7;case 7:return a=s,o=e.map((function(e){return R(p,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t={categoryTree:e},[4,this.loadCategory(T(e),r,a)];case 1:return[2,(t.category=n.sent(),t)]}}))}))})),[4,Promise.all(o)];case 8:return c=d.sent(),u={categories:[],missingCategories:[]},c.forEach((function(e){return e.category?u.categories.push(e.category):u.missingCategories.push(e.categoryTree)})),[2,u]}}))}))},e.prototype.loadCategoriesForRole=function(e){return R(this,void 0,void 0,(function(){var t,n=this;return E(this,(function(r){switch(r.label){case 0:return[4,this.categoryService.getCategories()];case 1:return t=r.sent(),[4,Promise.all(e.map((function(e){return R(n,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return n={},[4,this.loadCategory(T(e.category),t)];case 1:return[2,(n.category=r.sent(),n.accessLevel=e.accessLevel,n)]}}))}))})))];case 2:return[2,r.sent()]}}))}))},e.prototype.loadCategory=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return r=e.shift(),(i=t.find((function(e){return e.code===r&&!e.isCustom})))?e.length?[4,this.categoryService.getCategory(i.id)]:[3,2]:[3,5];case 1:return a=o.sent().subCategories,[2,this.loadCategory(e,a,n)];case 2:return[4,this.categoryService.getCategory(i.id)];case 3:return s=o.sent().category,n&&n.category.parents.some((function(e){return e.id===s.id}))?[2,n.category]:[2,s];case 4:return[3,6];case 5:return e.length?[2,this.loadCategory(e,t,n)]:[2,null];case 6:return[2]}}))}))},e}();$a.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new $a(n.ɵɵinject(t.HttpClient),n.ɵɵinject(Ma))},token:$a,providedIn:"root"}),$a.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],$a.ctorParameters=function(){return[{type:t.HttpClient},{type:Ma}]};var Na=function(){function t(e,t,n,r){this.fileService=e,this.lrApollo=t,this.keyMetaService=n,this.keyGraph=r}return t.prototype.downloadAttachment=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return[4,this.fileService.downloadEncryptedFile(e)];case 1:return n=r.sent(),[4,this.keyGraph.decryptFile(t,n)];case 2:return[2,r.sent()]}}))}))},t.prototype.uploadAttachments=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){switch(r.label){case 0:return[4,Promise.all((t||[]).map((function(t){return R(n,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return t.fileId?t.isDeleted?[4,this.deleteAttachment(t.fileId)]:[3,2]:[3,4];case 1:return n.sent(),[2,null];case 2:return[2,t.fileId];case 3:return[3,6];case 4:return[4,this.addAttachment(e,t)];case 5:return[2,n.sent()];case 6:return[2]}}))}))})))];case 1:return[2,r.sent().filter((function(e){return e}))]}}))}))},t.prototype.addAttachment=function(t,n){return R(this,void 0,void 0,(function(){var r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return r={name:n.name,fieldId:n.fieldId,fileType:n.file.type,fileSize:n.file.size,lastModified:n.file.lastModified},[4,this.fileService.loadFile(n.file)];case 1:return i=o.sent(),[4,this.keyMetaService.doubleWrapContent(r,[t],i)];case 2:return a=o.sent(),[4,this.fileService.uploadEncryptedFile({encryptedContent:a.cipherFileContent,fileName:n.name})];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:Ca,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordAttachment}),wrappedStateKey:a.doubleWrappedKey,cipherMeta:a.cipherMeta,parentDirectories:a.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}})),contentResource:s}}})];case 4:return[2,o.sent().createFile.file.id]}}))}))},t.prototype.deleteAttachment=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:ba,variables:{fileId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Na.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Na(n.ɵɵinject(ui),n.ɵɵinject(ge),n.ɵɵinject(Nt),n.ɵɵinject(ve))},token:Na,providedIn:"root"}),Na.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Na.ctorParameters=function(){return[{type:ui},{type:ge},{type:Nt},{type:ve}]};var Fa,La=function(){},xa=function(){},Ua=function(){},Ja=function(){},_a=function(){},qa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(Ja),Ga=function(){},Ba=function(){function t(e,t,n,r){this.lrApollo=e,this.keyMetaService=t,this.categoryService=n,this.recordAttachmentService=r}return t.prototype.getRecord=function(t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d=this;return E(this,(function(l){switch(l.label){case 0:return[4,this.lrApollo.query({query:fa(),variables:{id:t,categoryFilter:vt,contentFilter:ya,attachmentsFilter:ha}})];case 1:return n=l.sent().record,r=n.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(r.currentVersion.state)];case 2:return i=l.sent()||{},a=i.name,s=i.recordType,o=i.fields,[4,Promise.all(n.parentCategories.edges.map((function(e){return R(d,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.categoryService.mapParentCategories(e.node.parentDirectory)];case 1:return t=[n.sent()],[4,this.categoryService.mapCategory(e.node.parentDirectory)];case 2:return[2,T.apply(void 0,t.concat([[n.sent()]]))]}}))}))})))];case 3:return c=l.sent(),[4,this.mapAttachments(n.attachments.edges)];case 4:return u=l.sent(),p=n.accessRoles&&n.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:n.id,keyId:n.keyId,updateKeyId:r.keyId,updateId:r.id,name:a,recordType:s,fields:o,categories:c,attachments:u,myAccessLevel:p?e.AccessLevel.Owner:n.accessRoles[0].role,sharedAccess:p?n.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[],isArchived:!!n.archived,createdOn:n.created,lastModified:new Date(n.modified)>new Date(r.currentVersion.state.modified)?n.modified:r.currentVersion.state.modified}]}}))}))},t.prototype.mapAttachments=function(e){return R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return e.node.childFile})).map((function(e){return R(t,void 0,void 0,(function(){var t,n,r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return[4,this.keyMetaService.decryptMeta(e.currentVersion.state)];case 1:return t=o.sent()||{},n=t.name,r=t.fieldId,i=t.fileType,a=t.fileSize,s=t.lastModified,[2,{fileId:e.id,keyId:e.currentVersion.state.keyId,contentId:e.currentVersion.state.id,fieldId:r,name:n,fileType:i,fileSize:a,lastModified:s}]}}))}))})))];case 1:return[2,n.sent()]}}))}))},t.prototype.createRecord=function(t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return[4,this.keyMetaService.wrapContent(null,t.categoryIds)];case 1:return n=c.sent(),[4,this.lrApollo.mutate({mutation:va,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Record,isHidden:!1}),parentDirectories:n.wrappedKeys,parentRootDirectory:n.rootKey}})];case 2:return r=c.sent(),i=r.new.category.id,a={name:t.name,recordType:t.recordType,fields:t.fields},[4,this.keyMetaService.doubleWrapContent(a,[i])];case 3:return s=c.sent(),[4,this.lrApollo.mutate({mutation:ga,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta,parentDirectories:s.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}}))}}})];case 4:c.sent(),c.label=5;case 5:return c.trys.push([5,7,,8]),[4,this.recordAttachmentService.uploadAttachments(i,t.attachments)];case 6:return c.sent(),[3,8];case 7:return o=c.sent(),console.error(o),[2,{recordId:i,attachmentError:o}];case 8:return[2,{recordId:i}]}}))}))},t.prototype.updateRecord=function(t,n,r,i){return R(this,void 0,void 0,(function(){var a,s,o;return E(this,(function(c){switch(c.label){case 0:return a={name:i.name,recordType:i.recordType,fields:i.fields},[4,this.keyMetaService.reWrapContent(r,a)];case 1:return s=c.sent(),[4,this.lrApollo.mutate({mutation:Sa,variables:{input:{fileId:n,plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta}}})];case 2:c.sent(),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,this.recordAttachmentService.uploadAttachments(t,i.attachments)];case 4:return c.sent(),[3,6];case 5:return o=c.sent(),console.error(o),[2,{recordId:t,attachmentError:o}];case 6:return[2,{recordId:t}]}}))}))},t.prototype.archiveRecord=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.categoryService.archiveDirectory(e,!0)]}))}))},t.prototype.unarchiveRecord=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.categoryService.unarchiveDirectory(e,!0)]}))}))},t.prototype.deleteRecord=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ia,variables:{recordId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Ba.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ba(n.ɵɵinject(ge),n.ɵɵinject(Nt),n.ɵɵinject(Ma),n.ɵɵinject(Na))},token:Ba,providedIn:"root"}),Ba.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ba.ctorParameters=function(){return[{type:ge},{type:Nt},{type:Ma},{type:Na}]},(Fa=e.RecordFieldType||(e.RecordFieldType={})).Text="text",Fa.Email="email",Fa.Url="url",Fa.Phone="phone",Fa.Date="date",Fa.Password="password",Fa.TextArea="textArea",Fa.Select="select",Fa.SingleChoice="singleChoice",Fa.MultiChoice="multiChoice",Fa.File="file",Fa.MultiFile="multiFile",Fa.Record="record",Fa.MultiRecord="multiRecord",Fa.Group="group",Fa.Custom="custom";var Va=function(){},Qa=function(){},Wa=function(){},Za=function(){},Ha=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0},Ya=Ha,za=function(){function e(e){this.http=e}return e.prototype.getRecordTypes=function(){return R(this,void 0,void 0,(function(){var e,t,n,r,i=this;return E(this,(function(a){switch(a.label){case 0:return this.recordTypes?[3,2]:(e=this,[4,this.http.get("/assets/meta/record-types.json").toPromise()]);case 1:e.recordTypes=a.sent(),a.label=2;case 2:return this.categories?[3,4]:(t=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 3:t.categories=a.sent(),a.label=4;case 4:return n=this.categories.map((function(e){return e.subCategories})).reduce((function(e,t){return T(e,t)}),[]),r=this.recordTypes.map((function(e){return Object.assign(Object.assign({},e),{categoryNames:e.categories.map((function(e){return e.map((function(e){var t=n.find((function(t){return t.code===e}));return t?t.name:i.categories.find((function(t){return t.code===e})).name}))}))})})),[2,Promise.resolve(r)]}}))}))},e.prototype.getRecordType=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().find((function(t){return t.id===e}))]}}))}))},e.prototype.getRecordTypesForCategory=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().filter((function(t){return t.categories.some((function(t){return Ha(t,e)}))}))]}}))}))},e}();za.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new za(n.ɵɵinject(t.HttpClient))},token:za,providedIn:"root"}),za.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],za.ctorParameters=function(){return[{type:t.HttpClient}]};var Xa,es,ts,ns=function(){};(Xa=e.TrustedPartyRoleType||(e.TrustedPartyRoleType={})).General="general",Xa.Scenario="scenario",(es=e.TrustedPartyType||(e.TrustedPartyType={})).User="user",es.Organisation="organisation",(ts=e.TrustedPartyInviteStatus||(e.TrustedPartyInviteStatus={})).Invited="IN_PROGRESS",ts.Cancelled="CANCELLED",ts.Declined="DECLINED",ts.Completed="COMPLETED";var rs,is=function(){},as=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(tt),ss=function(){},os=function(){},cs=function(){},us=function(){},ps=function(){},ds=function(){},ls=function(){},ys=function(){},hs="\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",fs=y(rs||(rs=M(["\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}"])),hs),vs=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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var t,n,r;return E(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 R(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h;return E(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(),[4,this.keyService.getCurrentSigPxk()];case 3:return s=f.sent(),[4,this.encryptionService.encrypt(a.jwk,r)];case 4:return o=f.sent(),p=(u=JSON).stringify,[4,this.encryptionService.sign(s.jwk,o)];case 5:return c=p.apply(u,[f.sent()]),d={name:new Qe(r.name)},h=(y=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 6:return l=h.apply(y,[f.sent()]),[4,this.lrApollo.mutate({mutation:fs,variables:{input:{id:e,ownerCipherData:"",ownerKeyId:i.id,sharedCipherDataSig:c,sharedKeyId:a.id,sigPxkId:s.id,ownerPlainDataSig:l}}})];case 7:return f.sent(),[2]}}))}))},e}();vs.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new vs(n.ɵɵinject(fe),n.ɵɵinject(ge),n.ɵɵinject(ve),n.ɵɵinject(de))},token:vs,providedIn:"root"}),vs.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],vs.ctorParameters=function(){return[{type:fe},{type:ge},{type:ve},{type:de}]};var gs,ms,Ss,Is,Cs,bs,ks,Ks,ws,Ps="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+hs+"\n }\n myContactCard {\n "+hs+"\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n sharedItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n "+Di+"\n }\n "+Ri+"\n }\n }",Ds=y(gs||(gs=M(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"],["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"])),Ps,Te),Rs=y(ms||(ms=M(["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),Ps,Di,Di,Te),Es=y(Ss||(Ss=M(["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"],["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"])),Ps,Te),As=y(Is||(Is=M(["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Os=y(Cs||(Cs=M(["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Ts=y(bs||(bs=M(["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"]))),Ms=y(ks||(ks=M(["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"]))),js=y(Ks||(Ks=M(["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"]))),$s=function(){function t(e,t,n,r,i,a,s,o,c,u){this.http=e,this.lrApollo=t,this.sharedContactCardService=n,this.userService=r,this.authService=i,this.keyExchangeService=a,this.keyGraphService=s,this.keyService=o,this.keyFactory=c,this.encryptionService=u}return t.prototype.getTrustedParties=function(){return R(this,void 0,void 0,(function(){var e,t=this;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Ds})];case 1:return e=n.sent().tps,[4,Promise.all(e.edges.map((function(e){return t.mapTrustedParty(e.node)})))];case 2:return[2,n.sent()]}}))}))},t.prototype.getAllTrustedParties=function(){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return E(this,(function(c){switch(c.label){case 0:return[4,this.authService.getUser()];case 1:return t=c.sent(),[4,this.lrApollo.query({query:Rs,variables:{userId:t.id,isExpired:!1}})];case 2:return n=c.sent(),r=n.tps,i=n.invites,a=n.sentInvites,s={},[4,Promise.all(r.edges.map((function(e){return o.mapTrustedParty(e.node)})))];case 3:return s.parties=c.sent().filter((function(e){return e})),[4,Promise.all(i.edges.map((function(e){return R(o,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 4:return s.invites=c.sent().filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Completed})).filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Invited||t.actionRequired})),[4,Promise.all(a.edges.map((function(e){return R(o,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 5:return[2,(s.sentInvites=c.sent().filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Completed})),s)]}}))}))},t.prototype.getTrustedParty=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Es,variables:{partyId:e}})];case 1:return t=n.sent().tp,[4,this.mapTrustedParty(t)];case 2:return[2,n.sent()]}}))}))},t.prototype.getTrustedPartyRoles=function(t){return void 0===t&&(t=e.TrustedPartyRoleType.General),R(this,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return this.trustedPartyRoles?[3,2]:(e=this,[4,this.http.get("/assets/meta/trusted-party-roles.json").toPromise()]);case 1:e.trustedPartyRoles=n.sent(),n.label=2;case 2:return[2,Promise.resolve(this.trustedPartyRoles.filter((function(e){return e.roleType===t})))]}}))}))},t.prototype.findByEmail=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.userService.getUserByEmail(e)];case 1:return[2,(t=n.sent())?{id:t.id,email:e,username:t.username,isTrustedParty:t.haveTp,isMe:t.isCurrentUser}:null];case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.inviteTrustedParty=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t={responderUsername:e.party.username,email:e.party.email,message:{name:e.party.name,email:e.party.email,message:e.party.message,permissions:e.permissions},contactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new Qe(e.mySharedDetails.name)}}},[4,this.keyExchangeService.initiateOtk(t)];case 1:return n.sent(),[2]}}))}))},t.prototype.cancelInvitation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Os,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.getInvitation=function(e,t,n){return R(this,void 0,void 0,(function(){var r;return E(this,(function(i){switch(i.label){case 0:return[4,this.keyExchangeService.getKeyExchange(e,{token:t,otKeyK:n})];case 1:return r=i.sent(),[2,this.mapInvite(r)]}}))}))},t.prototype.acceptInvitation=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t={id:e.inviteId,token:e.inviteToken,decryptedOtk:e.decryptedOtk,initiatorContactCard:null,responderContactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new Qe(e.mySharedDetails.name)}}},[4,this.keyExchangeService.respondOtk(t)];case 1:return[2,n.sent().tp.id]}}))}))},t.prototype.declineInvitation=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:As,variables:{input:{id:e,token:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.confirmInvitation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.keyExchangeService.completeOtk(e.inviteId,e.initiatorRootKeyCipher,e.initiatorOneTimePbkCipher,null)];case 1:return[2,t.sent().tp.id]}}))}))},t.prototype.removeTrustedParty=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ts,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.setCategoryAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},t.prototype.setRecordAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},t.prototype.shareDirectory=function(e,t,n,r){return R(this,void 0,void 0,(function(){var i,a,s;return E(this,(function(o){switch(o.label){case 0:return[4,this.keyGraphService.getKey(t)];case 1:return i=o.sent(),[4,this.keyGraphService.getKey(n.userSharedKey.sharedKey.id)];case 2:return a=o.sent(),[4,this.encryptionService.encrypt(a.jwk,i.jwk.toJSON(!0))];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:Ms,variables:{input:{id:e,tpId:n.id,accessRole:r,keyId:i.id,wrappingKeyId:a.id,wrappedKey:JSON.stringify(s)}}})];case 4:return o.sent(),[2]}}))}))},t.prototype.unshareDirectory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:js,variables:{input:{id:e,tpId:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapTrustedParty=function(t){var n;return R(this,void 0,void 0,(function(){var r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),(i=t.sharedContactCard)?[4,this.sharedContactCardService.decryptTrustedPartyDetails(t.sharedContactCard)]:[3,2];case 1:i=c.sent(),c.label=2;case 2:return r=i,(s=t.myContactCard)?[4,this.sharedContactCardService.decryptSharedTrustedPartyDetails(t.myContactCard)]:[3,4];case 3:s=c.sent(),c.label=4;case 4:return a=s,[2,{id:t.id,type:e.TrustedPartyType.User,hasScenarios:!!t.sharedScenarios.edges.length,hasSharedVault:!!t.sharedItems.directories.edges.length,name:r&&r.name&&r.name.name,details:r,mySharedDetails:a,userSharedKey:t.currentUserSharedKey.userSharedKey,username:t.other.username,features:{sharedVault:{hasAccess:"access"===((null===(n=t.other.features)||void 0===n?void 0:n.shareVault)||["noaccess"])[0]}}}];case 5:return o=c.sent(),console.error("Failed to decrypt Trusted Party.",o,t),[2,null];case 6:return[2]}}))}))},t.prototype.mapInvite=function(t){var n,r;return R(this,void 0,void 0,(function(){var i,a,s;return E(this,(function(o){return i=t.contactCard,a=t.isInitiator?null===(n=t.myMessage)||void 0===n?void 0:n.name:i&&i.name&&i.name.name,s=t.isInitiator?null===(r=t.myMessage)||void 0===r?void 0:r.email:i&&i.email||t.responderEmailAddress,[2,{id:t.id,type:e.TrustedPartyType.User,status:t.state,token:t.token,tokenExpiry:t.tokenExpiryTime,decryptedOtk:t.decryptedOtk,name:a,email:s,isSender:t.isInitiator,actionRequired:t.isInitiator?t.initiatorActionRequired:t.responderActionRequired,rootKeyCipher:t.initiatorRootKeyCipher,pbkCipher:t.otk.initiatorOneTimePbkCipher,isExpired:t.isExpired,details:i,message:t.message,mySharedDetails:t.myContactCard,mySharedMessage:t.myMessage}]}))}))},t}();$s.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new $s(n.ɵɵinject(t.HttpClient),n.ɵɵinject(ge),n.ɵɵinject(vs),n.ɵɵinject(mi),n.ɵɵinject(ci),n.ɵɵinject(Ni),n.ɵɵinject(ve),n.ɵɵinject(fe),n.ɵɵinject(ye),n.ɵɵinject(de))},token:$s,providedIn:"root"}),$s.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],$s.ctorParameters=function(){return[{type:t.HttpClient},{type:ge},{type:vs},{type:mi},{type:ci},{type:Ni},{type:ve},{type:fe},{type:ye},{type:de}]},function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(ws||(ws={}));var Ns=[ws.Name,ws.Email,ws.Image,ws.Phone,ws.Address],Fs=function(){function e(e,t,n,r){this.sharedContactCardService=e,this.trustedPartyService=t,this.profileService=n,this.authService=r}return e.prototype.updateDetails=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.authService.getUser()];case 1:return t=n.sent(),[4,this.profileService.updateDetails(t.contactCard.id,t.contactCard.keyId,e)];case 2:return n.sent(),[4,this.synchronizeContactCards(e,t.contactCard)];case 3:return n.sent(),[4,this.authService.getUser(!0)];case 4:return[2,n.sent()]}}))}))},e.prototype.synchronizeContactCards=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.trustedPartyService.getTrustedParties()]:[2];case 1:if(0===(r=p.sent()).length)return[2];p.label=2;case 2:p.trys.push([2,7,8,9]),i=A(r.map((function(e){return e.mySharedDetails}))),a=i.next(),p.label=3;case 3:return a.done?[3,6]:(s=a.value,[4,this.synchronizeSharedContactCard(s,n)]);case 4:p.sent(),p.label=5;case 5:return a=i.next(),[3,3];case 6:return[3,9];case 7:return o=p.sent(),c={error:o},[3,9];case 8:try{a&&!a.done&&(u=i.return)&&u.call(i)}finally{if(c)throw c.error}return[7];case 9:return[2]}}))}))},e.prototype.getChanges=function(e,t){var n,r,i,a,s=[];try{for(var o=A(Ns),c=o.next();!c.done;c=o.next()){var u=c.value,p=t[u];if(p&&p.values){var d=function(t){var n=e[u].values.find((function(e){return e.id===t.id}));n?b.isEqual(n.value,t.value)||s.push({field:u,id:t.id,label:t.label,oldValue:t.value,newValue:n.value}):s.push({field:u,id:t.id,label:t.label,oldValue:t.value})};try{for(var l=(i=void 0,A(p.values)),y=l.next();!y.done;y=l.next()){d(y.value)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=l.return)&&a.call(l)}finally{if(i)throw i.error}}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},e.prototype.synchronizeSharedContactCard=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return E(this,(function(y){switch(y.label){case 0:n=!1,r=function(t){switch(t.field){case ws.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case ws.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];b.isEqual(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=A(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=P(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},e.prototype.updateTrustedPartyDetails=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=P(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(t,n,r,i)];case 1:return a.sent(),[4,this.synchronizeSharedDetails(e)];case 2:return a.sent(),[2]}}))}))},e.prototype.synchronizeSharedDetails=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y;return E(this,(function(h){switch(h.label){case 0:return[4,this.authService.getUser()];case 1:if(t=h.sent().contactCard,n=!1,t=Object.assign({},t),e.name&&(u=this.checkField(e.name,t.name))&&(t.name=u,n=!0),e.email&&(u=this.checkField(e.email,t.email))&&(t.email=u,n=!0),e.image&&(u=this.checkField(e.image,t.image))&&(t.image=u,n=!0),e.phones&&e.phones.length)try{for(r=A(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,t.phone,a.label))&&(t.phone=u,n=!0)}catch(e){p={error:e}}finally{try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(p)throw p.error}}if(e.addresses&&e.addresses.length)try{for(s=A(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,t.address,c.label))&&(t.address=u,n=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(y=s.return)&&y.call(s)}finally{if(l)throw l.error}}return n?[4,this.profileService.updateDetails(t.id,t.keyId,t)]:[3,3];case 2:h.sent(),h.label=3;case 3:return[2]}}))}))},e.prototype.checkField=function(e,t,n){return void 0===n&&(n=null),(t=t||{value:e,hasMultiple:!1}).values=t.values||[],0===t.values.length||t.values.every((function(t){return!b.isEqual(e,t.value)}))?(t.values.push({id:n+"-"+(new Date).getTime(),label:n,value:e}),t.hasMultiple=t.values.length>1,t.value=t.value||e,t):null},e}();Fs.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Fs(n.ɵɵinject(vs),n.ɵɵinject($s),n.ɵɵinject(vn),n.ɵɵinject(ci))},token:Fs,providedIn:"root"}),Fs.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Fs.ctorParameters=function(){return[{type:vs},{type:$s},{type:vn},{type:ci}]};var Ls=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:te,useValue:t},{provide:d.AuthClass,useValue:k},{provide:n.APP_INITIALIZER,useFactory:Wi,deps:[te,d.AuthClass],multi:!0},{provide:n.APP_INITIALIZER,useFactory:oi,deps:[ci],multi:!0},{provide:l.APOLLO_OPTIONS,useFactory:re,deps:[te,d.AuthClass]}]}},e}();Ls.decorators=[{type:n.NgModule,args:[{imports:[t.HttpClientModule,m.NgIdleKeepaliveModule.forRoot()],providers:[f.CookieService,ce,ui,vn,ta,ci,qn,le,de,ve,fe,ye]}]}];var xs,Us,Js,_s,qs,Gs,Bs=function(){},Vs=function(){},Qs=function(){},Ws=function(){},Zs=function(){},Hs=En(xs||(xs=M(["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"],["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"]))),Ys=En(Us||(Us=M(["\n mutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n ) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"],["\n mutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n ) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"]))),zs=En(Js||(Js=M(["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"],["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"]))),Xs=En(_s||(_s=M(["\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"]))),eo=(En(qs||(qs=M(['\n query ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n ...ContactCardFragment\n }\n }\n }\n }\n ',"\n"],['\n query ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n ...ContactCardFragment\n }\n }\n }\n }\n ',"\n"])),Hs),En(Gs||(Gs=M(["\n query ContactCardQuery($id: LrRelayIdInput!) {\n contactCard(id: $id) {\n ...ContactCardFragment\n }\n }\n ","\n"],["\n query ContactCardQuery($id: LrRelayIdInput!) {\n contactCard(id: $id) {\n ...ContactCardFragment\n }\n }\n ","\n"])),Hs),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 R(this,void 0,void 0,(function(){var t,n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=s.sent(),[4,this.keyFactory.createKey()];case 2:return n=s.sent(),[4,this.keyGraph.encryptToString(t.jwk,n.toJSON(!0))];case 3:return r=s.sent(),[4,this.keyGraph.encryptToString(n,e.plainCipherDataJson)];case 4:return i=s.sent(),[4,this.prepareContactCardInput(e)];case 5:return a=s.sent(),[2,new Tr({mutation:Ys,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(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 Tr({mutation:zs,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new Tr({mutation:Xs,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return E(this,(function(d){switch(d.label){case 0:return[4,this.keyService.getCurrentSigPxk()];case 1:return t=d.sent(),i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicDataJson)];case 2:return n=i.apply(r,[d.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicSearchableJson)];case 3:return a=o.apply(s,[d.sent()]),p=(u=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.plainDataJson)];case 4:return c=p.apply(u,[d.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:c}]}}))}))},e}(),e.ContactCard2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ContactCard2Service(n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(Nt),n.ɵɵinject(n.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:ye},{type:fe},{type:de},{type:ve},{type:Nt},{type:n.NgZone}]},e.ContactCard2Service=D([br({ngZoneName:"ngZone"})],e.ContactCard2Service);var to,no,ro,io,ao,so,oo,co,uo,po,lo,yo=En(to||(to=M(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"],["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"]))),ho=En(no||(no=M(["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"],["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"]))),fo=En(ro||(ro=M(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"])),yo),vo=En(io||(io=M(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),yo),go=En(ao||(ao=M(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),yo),mo=En(so||(so=M(["\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"]))),So=En(oo||(oo=M(["\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"]))),Io=En(co||(co=M(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"])),yo),Co=En(uo||(uo=M(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),yo,ho),bo=En(po||(po=M(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),yo,ho),ko=En(lo||(lo=M(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n","\n"],["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n","\n"])),ho);e.KeyExchange2Service=function(){function e(e,t,n,r,i,a,s){this.ngZone=e,this.keyFactory=t,this.keyService=n,this.encryptionService=r,this.userService=i,this.keyGraph=a,this.lrGraphQL=s,this.CLIENT_NONCE_LENGTH=32}return e.prototype.getOtKey=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return t?[4,ye.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,6]:[4,this.keyService.getCurrentPxk()];case 3:return n=i.sent(),[4,this.encryptionService.decrypt(n.jwk,JSON.parse(e.otk.responderPbkCipher),{serializations:[ae.COMPACT]})];case 4:return(r=i.sent()).otKey?[4,ye.asKey(r.otKey)]:[3,6];case 5:return[2,i.sent()];case 6:return[2,null]}}))}))},e.prototype.decryptOtk=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o;return E(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})]}}))}))},e.prototype.decryptResponseCipher=function(e,t,n){return R(this,void 0,void 0,(function(){var r;return E(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()]}}))}))},e.prototype.decryptKeyExchangeAsInitiator=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return E(this,(function(l){switch(l.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=l.sent(),[4,this.encryptionService.decrypt(t.jwk,e.initiatorRootKeyCipher)];case 2:return n=l.sent(),[4,ye.asKey(n.otKey)];case 3: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,ye.asKey(n.oneTimePrk)]):[3,6];case 4:return[4,u.apply(this,p.concat([l.sent(),i.initiatorOneTimePbkCipher]))];case 5:i=s.apply(a,o.concat([(c.initiatorOneTimePbkCipherClearJson=l.sent(),c)])),l.label=6;case 6:return i.otKeyCipher?(d=i,[4,this.encryptionService.decrypt(r,i.otKeyCipher)]):[3,8];case 7:d.otKeyCipherClearJson=l.sent(),l.label=8;case 8:return[2,Object.assign(Object.assign({},e),{otk:i})]}}))}))},e.prototype.decryptKeyExchangeAsResponder=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},e.prototype.decryptKeyExchange=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return e.isInitiator?[2,this.decryptKeyExchangeAsInitiator(e)]:[2,this.decryptKeyExchangeAsResponder(e,t)]}))}))},e.prototype.getKeyExchanges=function(e){var t=(void 0===e?{}:e).state;return R(this,void 0,void 0,(function(){var e,n=this;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrGraphQL.query({query:fo,variables:{state:t}})];case 1:return e=r.sent().keyExchanges,[2,Promise.all(e.edges.map((function(e){return n.decryptKeyExchange(e.node)})))]}}))}))},e.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:i?go:vo,variables:{id:e,token:i},includeKeyGraph:!i})];case 1:return t=n.sent(),[2,this.decryptKeyExchange(t.keyExchange,r)]}}))}))},e.prototype.getCurrentUserSharedKey=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.lrGraphQL.query({query:ko,variables:{username:e.username,userId:e.userId}})]}))}))},e.prototype.cancelKeyExchange=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.cancelKeyExchangeMutation(e)]}))}))},e.prototype.cancelKeyExchangeMutation=function(e){return new Tr({mutation:mo,variables:{input:{id:e}}})},e.prototype.declineKeyExchange=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.declineKeyExchangeMutation(e,t)]}))}))},e.prototype.declineKeyExchangeMutation=function(e,t){return new Tr({mutation:So,variables:{input:{id:e,token:t}}})},e.prototype.initiateOtk=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return R(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,y,h,f,v;return E(this,(function(g){switch(g.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=g.sent(),t=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.keyFactory.createPkcKey()];case 2:return s=g.sent(),[4,this.keyService.getCurrentPxk()];case 3:return o=g.sent(),[4,this.keyService.getCurrentSigPxk()];case 4:return c=g.sent(),u=null,i&&i.ownerPlainDataJson?[4,this.encryptionService.signToString(c.jwk,i.ownerPlainDataJson)]:[3,6];case 5:u=g.sent(),g.label=6;case 6: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 7:return l=g.sent(),y={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},[4,this.keyService.getCurrentRootKey()];case 8:return h=g.sent(),[4,this.keyGraph.encryptToString(h.jwk,y)];case 9:return f=g.sent(),v=e.toJSON(!0).k,[2,{lrMutation:new Tr({mutation:Io,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}]}}))}))},e.prototype.respondOtk=function(e){var t=e.keyExchangeId,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return R(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b,k,K,w,P,D,R,A,O,T,M,j,$,N,F,L,x,U,J,_,q,G,B,V,Q,W,Z,H,Y,z,X,ee,te;return E(this,(function(E){switch(E.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return e=E.sent(),o=this.keyService.getCurrentMasterKey().id,[4,this.keyService.getCurrentMasterKey()];case 2:return c=E.sent(),[4,this.keyFactory.createKey()];case 3:return u=E.sent(),[4,this.keyFactory.createKey()];case 4:return p=E.sent(),[4,this.encryptionService.encrypt(e.jwk,u.toJSON(!0))];case 5:return d=E.sent(),[4,this.encryptionService.encrypt(c.jwk,p.toJSON(!0))];case 6:return l=E.sent(),[4,ye.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 7:return y=E.sent(),[4,ye.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 8:return h=E.sent(),[4,ye.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 9:return f=E.sent(),[4,this.keyService.getCurrentPxk()];case 10:return v=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 11:return g=E.sent(),[4,this.encryptionService.sign(g.jwk,h.toJSON())];case 12:return m=E.sent(),[4,this.encryptionService.sign(g.jwk,f.toJSON())];case 13:return S=E.sent(),I={nonce:r.otKeyCipherClearJson.nonce,sharedKey:u.toJSON(!0),mkSharedKey:p.toJSON(!0),responder:{pbk:v.jwk.toJSON(),sigPbk:g.jwk.toJSON(),message:i}},r.otKeyCipherClearJson.initiator.contactCard?(b=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,24];case 14:return k=E.sent(),[4,this.keyFactory.createKey()];case 15:return L=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 16:return x=E.sent(),K={},P=(w=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,k.toJSON(!0))];case 17:return K.receiverWrappedKey=P.apply(w,[E.sent()]),K.receiverWrappingKeyId=e.id,a?(A=(R=JSON).stringify,[4,this.encryptionService.encrypt(k,a.receiverCipherDataClearJson)]):[3,19];case 18:return D=A.apply(R,[E.sent()]),[3,20];case 19:D="",E.label=20;case 20:return K.receiverCipherData=D,T=(O=JSON).stringify,[4,this.encryptionService.encrypt(u,L.toJSON(!0))];case 21:return K.sharedWrappedKey=T.apply(O,[E.sent()]),C=K,[4,this.encryptionService.encrypt(L,b)];case 22:return W=E.sent(),M=C,$=(j=JSON).stringify,[4,this.encryptionService.sign(x.jwk,W)];case 23:M.sharedCipherDataSig=$.apply(j,[E.sent()]),C.sigPxkId=x.id,I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherKey:L.toJSON(!0)}),E.label=24;case 24:return s?[4,this.keyFactory.createKey()]:[3,37];case 25:return F=E.sent(),[4,this.keyFactory.createKey()];case 26:return L=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 27:return x=E.sent(),U={},_=(J=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,F.toJSON(!0))];case 28:return U.ownerWrappedKey=_.apply(J,[E.sent()]),U.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(B=(G=JSON).stringify,[4,this.encryptionService.encrypt(F,s.ownerCipherDataClearJson)]):[3,30];case 29:return q=B.apply(G,[E.sent()]),[3,31];case 30:q="",E.label=31;case 31:return U.ownerCipherData=q,Q=(V=JSON).stringify,[4,this.encryptionService.encrypt(u,L.toJSON(!0))];case 32:return U.sharedWrappedKey=Q.apply(V,[E.sent()]),N=U,[4,this.encryptionService.encrypt(L,s.sharedCipherDataClearJson)];case 33:return W=E.sent(),Z=N,Y=(H=JSON).stringify,[4,this.encryptionService.sign(x.jwk,W)];case 34:return Z.sharedCipherDataSig=Y.apply(H,[E.sent()]),N.sigPxkId=x.id,s.ownerPlainDataJson?(z=N,ee=(X=JSON).stringify,[4,this.encryptionService.sign(g.jwk,s.ownerPlainDataJson)]):[3,36];case 35:z.ownerPlainDataSig=ee.apply(X,[E.sent()]),E.label=36;case 36:I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),E.label=37;case 37:return[4,this.encryptionService.encrypt(y,I)];case 38:return te=E.sent(),[4,this.encryptionService.encrypt(r.otKey,te)];case 39:return te=E.sent(),[2,new Tr({mutation:Co,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:e.id,masterKeyId:o,responderPxkId:v.id,responderSigPxkId:g.id,signedInitiatorPbk:JSON.stringify(m),signedInitiatorSigPbk:JSON.stringify(S),rkWrappedSharedKey:JSON.stringify(d),mkWrappedMkSharedKey:JSON.stringify(l),initiatorOneTimePbkCipher:JSON.stringify(te),initiatorContactCard:C,responderContactCard:N}}})]}}))}))},e.prototype.completeOtk=function(e){var t=e.keyExchangeId,n=e.initiatorRootKeyCipher,r=e.initiatorOneTimePbkCipher,i=e.responderContactCard,a=e.initiatorContactCard;return R(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b,k,K,w,P,D,R,A,O,T,M,j,$,N,F,L,x,U,J,_;return E(this,(function(E){switch(E.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return e=E.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return s=E.sent(),[4,this.encryptionService.decrypt(e.jwk,n)];case 3:return o=E.sent(),u=this.decryptResponseCipher,[4,ye.asKey(o.otKey)];case 4:return p=[E.sent()],[4,ye.asKey(o.oneTimePrk)];case 5:return[4,u.apply(this,p.concat([E.sent(),r]))];case 6:if(c=E.sent(),o.nonce!==c.nonce)throw new B("The nonce returned by responder does not match with the one created by the initiator.");return[4,this.keyService.getCurrentSigPxk()];case 7:return d=E.sent(),[4,ye.asKey(c.responder.sigPbk)];case 8:return l=E.sent(),[4,ye.asKey(c.responder.pbk)];case 9:return y=E.sent(),[4,this.encryptionService.sign(d.jwk,y.toJSON())];case 10:return h=E.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 11:return f=E.sent(),[4,ye.asKey(c.sharedKey)];case 12:return v=E.sent(),[4,this.encryptionService.encrypt(e.jwk,v.toJSON(!0))];case 13:return g=E.sent(),[4,ye.asKey(c.mkSharedKey)];case 14:return m=E.sent(),[4,this.encryptionService.encrypt(s.jwk,m.toJSON(!0))];case 15:return S=E.sent(),i?[4,this.keyFactory.createKey()]:[3,19];case 16:return C=E.sent(),b={},K=(k=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,C.toJSON(!0))];case 17:return b.receiverWrappedKey=K.apply(k,[E.sent()]),b.receiverWrappingKeyId=e.id,P=(w=JSON).stringify,[4,this.encryptionService.encrypt(C,i.receiverCipherDataClearJson)];case 18:b.receiverCipherData=P.apply(w,[E.sent()]),I=b,E.label=19;case 19:return o.initiatorContactCard?(A=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,28];case 20:return O=E.sent(),[4,ye.asKey(c.responder.contactCard.sharedCipherKey)];case 21:return T=E.sent(),$=(j=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,O.toJSON(!0))];case 22:return M=$.apply(j,[E.sent()]),(N=(null==a?void 0:a.ownerCipherDataClearJson)||A.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(O,N)]:[3,24];case 23:return L=E.sent(),[3,25];case 24:L="",E.label=25;case 25:return F=L,D={ownerWrappedKey:M,ownerWrappingKeyId:e.id,ownerCipherData:F},R={sigPxkId:d.id},[4,this.encryptionService.encrypt(T,A.sharedCipherDataClearJson)];case 26:return x=E.sent(),U=R,_=(J=JSON).stringify,[4,this.encryptionService.sign(d.jwk,x)];case 27:U.sharedCipherDataSig=_.apply(J,[E.sent()]),E.label=28;case 28:return[2,new Tr({mutation:bo,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(h),signedResponderSigPbk:JSON.stringify(f),rkWrappedSharedKey:JSON.stringify(g),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:I,initiatorContactCardCipher:D,initiatorContactCardSharedCipher:R}}})]}}))}))},e}(),e.KeyExchange2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.KeyExchange2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(de),n.ɵɵinject(mi),n.ɵɵinject(ve),n.ɵɵinject(e.ɵh))},token:e.KeyExchange2Service,providedIn:"root"}),e.KeyExchange2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.KeyExchange2Service.ctorParameters=function(){return[{type:n.NgZone},{type:ye},{type:fe},{type:de},{type:mi},{type:ve},{type:e.ɵh}]},e.KeyExchange2Service=D([br({ngZoneName:"ngZone"})],e.KeyExchange2Service);var Ko,wo,Po,Do,Ro=En(Ko||(Ko=M(["\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}"]))),Eo=En(wo||(wo=M(["\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}"]))),Ao=En(Po||(Po=M(["\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}"]))),Oo=En(Do||(Do=M(["\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 R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:Ao,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Oo,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 R(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,g;return E(this,(function(m){switch(m.label){case 0:return m.trys.push([0,3,,7]),[4,this.keyGraph.getKey(n)];case 1:return e=m.sent(),[4,this.keyGraph.getKey(r)];case 2:return o=m.sent(),[3,7];case 3:return m.sent(),[4,this.getOwnedContactCardKeyIds(t)];case 4:return c=m.sent(),[4,this.keyGraph.getKey(c.ownerKeyId)];case 5:return e=m.sent(),[4,this.keyGraph.getKey(c.sharedKeyId)];case 6:return o=m.sent(),[3,7];case 7:return[4,this.keyService.getCurrentSigPxk()];case 8:return u=m.sent(),[4,this.encryptionService.encrypt(o.jwk,s)];case 9:return p=m.sent(),y=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 10:return d=y.apply(l,[m.sent()]),v=(f=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 11:return h=v.apply(f,[m.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 12:return g=m.sent(),[2,new Tr({mutation:Ro,variables:{input:{id:t,ownerCipherData:g,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:h}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return R(this,void 0,void 0,(function(){var e,i,a=this;return E(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 Tr({mutation:Eo,variables:{input:{id:t,receiverCipherData:i,receiverKeyId:e.id}}})]}}))}))},e}(),e.SharedContactCard2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.SharedContactCard2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(fe),n.ɵɵinject(ve),n.ɵɵinject(de),n.ɵɵinject(e.ɵh))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:n.NgZone},{type:fe},{type:ve},{type:de},{type:e.ɵh}]},e.SharedContactCard2Service=D([br({ngZoneName:"ngZone"})],e.SharedContactCard2Service);var To,Mo,jo,$o,No=En(To||(To=M(["\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}"]))),Fo=En(Mo||(Mo=M(["\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"])),No),Lo=En(jo||(jo=M(["\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"])),No),xo=En($o||($o=M(["\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"])),No);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return w(t,e),t.prototype.updateLockMutation=function(e){return new Tr({mutation:Fo,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t.prototype.acquireLockMutation=function(e){return new Tr({mutation:Lo,variables:{input:{resourceId:e.resourceId,timeoutMs:e.timeoutMs}}})},t.prototype.releaseLockMutation=function(e){return new Tr({mutation:xo,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t}(Yr),e.LockService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.LockService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR))},token:e.LockService,providedIn:"root"}),e.LockService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.LockService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.LockService=D([br({ngZoneName:"ngZone"})],e.LockService);var Uo,Jo,_o,qo,Go,Bo,Vo,Qo,Wo,Zo,Ho,Yo,zo,Xo,ec,tc,nc=En(Uo||(Uo=M(["\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"]))),rc=En(Jo||(Jo=M(["\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"]))),ic=En(_o||(_o=M(["\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"]))),ac=En(qo||(qo=M(["\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"]))),sc=En(Go||(Go=M(["\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"]))),oc=En(Bo||(Bo=M(["\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"]))),cc=En(Vo||(Vo=M(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),uc=En(Qo||(Qo=M(["\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"]))),pc=En(Wo||(Wo=M(["\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"]))),dc=En(Zo||(Zo=M(["\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"]))),lc=En(Ho||(Ho=M(["\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"]))),yc=En(Yo||(Yo=M(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),hc=En(zo||(zo=M(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"]))),fc=En(Xo||(Xo=M(["\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"]))),vc=En(ec||(ec=M(['\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'])));e.Item2Service=tc=function(e){function t(t,n,r,i,a,s,o){var c=e.call(this,n)||this;return c.ngZone=t,c.injector=n,c.fileService=r,c.keyService=i,c.keyFactory=a,c.keyGraph=s,c.lockService=o,c}return w(t,e),t.prototype.downloadFileContent=function(e){return R(this,void 0,void 0,(function(){var t,n,r=this;return E(this,(function(i){switch(i.label){case 0:return[4,this.fileService.downloadEncryptedFile2(e.fileStateNodeId)];case 1:return t=i.sent(),[4,this.keyGraph.getKey(e.fileStateKeyId,(function(){return r.getFileStateKeyId(e.fileStateNodeId)}))];case 2:return n=i.sent(),[2,this.keyGraph.decryptFromString(n,t,{payloadType:"ArrayBuffer"})]}}))}))},t.prototype.getDirectoryKeyId=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.query({query:nc,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},t.prototype.getFileKeyId=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.query({query:rc,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},t.prototype.getDirectoryKey=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},t.prototype.getFileKey=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},t.prototype.createDirectoryExec=function(e){return this.mutate(this.createDirectoryMutation(e))},t.prototype.createDirectory=function(e){return this.createDirectoryMutation(e)},t.prototype.createDirectoryMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:ac},r={},[4,this.prepareCreateDirectory(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.updateDirectoryExec=function(e){return this.mutate(this.updateDirectoryMutation(e))},t.prototype.updateDirectory=function(e){return this.updateDirectoryMutation(e)},t.prototype.updateDirectoryMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:sc},r={},[4,this.prepareUpdateDirectory(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.deleteDirectoryExec=function(e){return this.mutate(this.deleteDirectoryMutation(e))},t.prototype.deleteDirectory=function(e){return this.deleteDirectoryMutation(e)},t.prototype.deleteDirectoryMutation=function(e){return new Tr({mutation:oc,variables:{input:{directoryId:e}}})},t.prototype.createFileExec=function(e){return this.mutate(this.createFileMutation(e))},t.prototype.createFile=function(e){return this.createFileMutation(e)},t.prototype.createFileMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:cc},r={},[4,this.prepareCreateFile(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.updateFileExec=function(e){return this.mutate(this.updateFileMutation(e))},t.prototype.updateFile=function(e){return this.updateFileMutation(e)},t.prototype.updateFileMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:uc},r={},[4,this.prepareUpdateFile(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.deleteFileExec=function(e){return this.mutate(this.deleteFileMutation(e))},t.prototype.deleteFile=function(e){return this.deleteFileMutation(e)},t.prototype.deleteFileMutation=function(e){return new Tr({mutation:pc,variables:{input:{fileId:e}}})},t.prototype.archiveDirectoryExec=function(e,t){return this.mutate(this.archiveDirectoryMutation(e,t))},t.prototype.archiveDirectory=function(e,t){return this.archiveDirectoryMutation(e,t)},t.prototype.archiveDirectoryMutation=function(e,t){return new Tr({mutation:dc,variables:{input:{directoryId:e,recursive:t}}})},t.prototype.unarchiveDirectoryExec=function(e,t){return this.mutate(this.unarchiveDirectoryMutation(e,t))},t.prototype.unarchiveDirectory=function(e,t){return this.unarchiveDirectoryMutation(e,t)},t.prototype.unarchiveDirectoryMutation=function(e,t){return new Tr({mutation:lc,variables:{input:{directoryId:e,recursive:t}}})},t.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},t.prototype.changeDirectoryParentsMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:yc},r={},[4,this.prepareChangeDirectoryParents(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.changeFileParents=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},t.prototype.changeFileParentsMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:hc},r={},[4,this.prepareChangeFileParents(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.beginDeleteChildItemLinksWindow=function(e){return this.mutate(this.beginDeleteChildItemLinksWindowMutation(e))},t.prototype.beginDeleteChildItemLinksWindowMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:fc,variables:{input:e}})]}))}))},t.prototype.ensureTempDirectory=function(){var e;return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return[4,this.query({query:vc,variables:{plainMeta:tc.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: "+tc.TEMP_DIRECTORY_PLAIN_META_FILTER+")"),0!==t.rootDirectories.edges.length?[3,4]:[4,this.createDirectory({asRootDirectory:!0,plainMetaJson:tc.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(jr.create([n,r]))];case 3:return i=O.apply(void 0,[p.sent(),2]),a=i[0],i[1],s=a.createDirectory.directory,c=s.id,u=s.keyId,[2,{id:c,keyId:u}];case 4:return o=t.rootDirectories.edges[0].node,c=o.id,u=o.keyId,[2,{id:c,keyId:u}]}}))}))},t.prototype.createDirectoryTree=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.createDirectoryTreeMutation(e))]}))}))},t.prototype.createDirectoryTreeMutation=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.ensureTempDirectory()];case 1:return t=r.sent(),[4,this.beginDeleteChildItemLinksWindow({directoryId:t.id,requestWindowMs:e.requestWindowMs})];case 2:return r.sent(),[4,this.createDirectoryExec({cipherMetaClearJson:e.cipherMetaClearJson,parentDirectories:[{directoryId:t.id,wrappingKeyId:t.keyId}],plainMetaJson:e.plainMetaJson})];case 3:return n=r.sent().createDirectory.directory.id,[4,e.createContent(n)];case 4:return r.sent(),[2,this.changeDirectoryParentsMutation({directoryId:n,parentsToRemove:[t.id],parentsToAdd:e.parentDirectories})]}}))}))},t.prototype.prepareParentDirectory=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.wrappingKeyId)];case 1:return n=i.sent(),r={directoryId:e.directoryId,wrappingKeyId:n.id},[4,this.keyGraph.wrapKey(n,t)];case 2:return[2,(r.wrappedKey=i.sent(),r.linkType=e.linkType,r)]}}))}))},t.prototype.getFileStateKeyId=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.query({query:ic,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},t.prototype.prepareCreateFileState=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y;return E(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),(i=t.file)?[4,this.fileService.loadFile(t.file)]:[3,3];case 2:i=h.sent(),h.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,9];case 4:return s=h.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=h.sent(),[3,8];case 6:return[4,this.fileService.uploadEncryptedFile({encryptedContent:s})];case 7:a=h.sent(),h.label=8;case 8:console.log("contentResource",a),h.label=9;case 9:return c=(o=Object).assign,p=(u=Object).assign,d=[{}],[4,this.prepareItem(n,t)];case 10:return l=[p.apply(u,d.concat([h.sent()]))],y={},[4,this.keyGraph.wrapKey(e,n)];case 11:return[2,c.apply(o,l.concat([(y.wrappedStateKey=h.sent(),y.contentResource=a,y)]))]}}))}))},t.prototype.prepareChangeItemParents=function(e,t){return R(this,void 0,void 0,(function(){var n,r=this;return E(this,(function(i){switch(i.label){case 0:return[4,Promise.all(e.parentsToAdd.map((function(e){return r.prepareParentDirectory(e,t)})))];case 1:return n=i.sent(),[2,{directoriesToRemove:e.parentsToRemove,directoriesToAdd:n}]}}))}))},t.prototype.prepareItem=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return n=t.plainMetaJson,r=t.cipherMetaClearJson,i={plainMeta:n&&JSON.stringify(n)},(a=r)?[4,this.keyGraph.encryptToString(e,r)]:[3,2];case 1:a=s.sent(),s.label=2;case 2:return[2,(i.cipherMeta=a,i)]}}))}))},t.prototype.prepareCreateDirectory=function(e){var t,n;return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u=this;return E(this,(function(p){switch(p.label){case 0:return[4,this.keyFactory.createKey()];case 1:if(r=p.sent(),e.parentDirectories=e.parentDirectories||[],!e.asRootDirectory&&!(null===(t=e.parentDirectories)||void 0===t?void 0:t.length))throw new J("A new directory must be either a root directory or a sub-directory. So you must provide either parentDirectories and/or asRootDirectory parameter.");return[4,Promise.all(null===(n=e.parentDirectories)||void 0===n?void 0:n.map((function(e){return u.prepareParentDirectory(e,r)})))];case 2:return i=p.sent(),e.asRootDirectory?(s=this.keyService.getCurrentRootKey(),o={wrappingKeyId:s.id},[4,this.keyGraph.wrapKey(s,r)]):[3,4];case 3:o.wrappedKey=p.sent(),a=o,p.label=4;case 4:return[4,this.prepareItem(r,e)];case 5:return c=p.sent(),[2,Object.assign(Object.assign({},c),{parentDirectories:i,parentRootDirectory:a})]}}))}))},t.prototype.prepareUpdateDirectory=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareItem(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},t.prototype.prepareCreateFile=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i=this;return E(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 R(i,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.prepareParentDirectory(e,t)];case 1:return n=s.sent(),r=n.directoryId,i=n.wrappingKeyId,a=n.wrappedKey,[2,{directoryId:r,wrappingKeyId:i,wrappedFileKey:a}]}}))}))})))];case 2:return n=a.sent(),[4,this.prepareCreateFileState(t,e)];case 3:return r=a.sent(),[2,Object.assign(Object.assign({},r),{parentDirectories:n})]}}))}))},t.prototype.prepareUpdateFile=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareCreateFileState(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},t.prototype.prepareChangeDirectoryParents=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},t.prototype.prepareChangeFileParents=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},t}(Yr),e.Item2Service.TEMP_DIRECTORY_PLAIN_META={kcType:"temp"},e.Item2Service.TEMP_DIRECTORY_PLAIN_META_FILTER=JSON.stringify({filter:[{contains:tc.TEMP_DIRECTORY_PLAIN_META}]}),e.Item2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.Item2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(ui),n.ɵɵinject(fe),n.ɵɵinject(ye),n.ɵɵinject(ve),n.ɵɵinject(e.LockService))},token:e.Item2Service,providedIn:"root"}),e.Item2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.Item2Service.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:ui},{type:fe},{type:ye},{type:ve},{type:e.LockService}]},e.Item2Service=tc=D([br({ngZoneName:"ngZone"})],e.Item2Service);var gc,mc,Sc,Ic,Cc,bc,kc,Kc,wc,Pc=En(gc||(gc=M(["\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"]))),Dc=En(mc||(mc=M(["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"],["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"]))),Rc=En(Sc||(Sc=M(["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"],["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"]))),Ec=En(Ic||(Ic=M(["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"],["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"]))),Ac=En(Cc||(Cc=M(["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"],["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"]))),Oc=En(bc||(bc=M(["\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"]))),Tc=En(kc||(kc=M(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),Mc=En(Kc||(Kc=M(["\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"]))),jc=En(wc||(wc=M(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"])));e.TrustedParty2Service=function(e){function t(t,n,r,i,a,s,o){var c=e.call(this,n)||this;return c.ngZone=t,c.injector=n,c.keyGraph=r,c.item2Service=i,c.keyService=a,c.keyFactory=s,c.encryptionService=o,c}return w(t,e),t.prototype.deleteTpExec=function(e){return this.mutate(this.deleteTpMutation(e))},t.prototype.deleteTp=function(e){return this.deleteTpMutation(e)},t.prototype.deleteTpMutation=function(e){return new Tr({mutation:Pc,variables:{input:{id:e}}})},t.prototype.getTpCurrentUserSharedKey=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:Oc,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},t.prototype.shareDirectory=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.shareItem(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},t.prototype.shareFile=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.shareItem(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},t.prototype.shareItem=function(e){var t=e.itemId,n=e.itemKeyId,r=e.tpId,i=e.tpSharedKeyId,a=e.accessRole,s=e.isDirectory;return R(this,void 0,void 0,(function(){var e,o,c,u=this;return E(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return s?u.item2Service.getDirectoryKeyId(t):u.item2Service.getFileKeyId(t)}))];case 1:return e=p.sent(),[4,this.keyGraph.getKey(i,(function(){return u.getTpCurrentUserSharedKey(r).then((function(e){return e.sharedKey.id}))}))];case 2:return o=p.sent(),[4,this.keyGraph.wrapKey(o,e.jwk)];case 3:return c=p.sent(),[2,new Tr({mutation:s?Dc:Ec,variables:{input:{id:t,tpId:r,accessRole:a,keyId:e.id,wrappingKeyId:o.id,wrappedKey:c}}})]}}))}))},t.prototype.unshareDirectory=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.unshareItem(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},t.prototype.unshareFile=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.unshareItem(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},t.prototype.unshareItem=function(e){var t=e.itemId,n=e.tpId,r=e.isDirectory;return R(this,void 0,void 0,(function(){return E(this,(function(e){return[2,new Tr({mutation:r?Rc:Ac,variables:{input:{id:t,tpId:n}}})]}))}))},t.prototype.requestMkReshare=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s;return E(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[4,this.keyService.getCurrentMasterKey()];case 2:return n=o.sent(),[4,this.keyFactory.createPkcKey()];case 3:return r=o.sent(),[4,this.encryptionService.encryptToString(n.jwk,r.toJSON(!0))];case 4:return i=o.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 5:return a=o.sent(),[4,this.encryptionService.encryptToString(a.jwk,{pbk:r.toJSON()})];case 6:return s=o.sent(),[4,new Tr({mutation:Tc,variables:{input:{tpId:e,masterKeyId:n.id,mkPbk:JSON.stringify(r.toJSON()),mkWrappedMkPrk:i,sharedKeyId:a.id,mkReshareRequestCipher:s}}})];case 7:return[2,o.sent()]}}))}))},t.prototype.respondMkReshare=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d;return E(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,p.JWK.asKey(r.pbk)];case 4:return i=l.sent(),[4,this.keyGraph.getKey(t.mkSharedKey.id)];case 5:return a=l.sent(),s={mkSharedKey:{id:a.id,jwk:a.jwk.toJSON(!0)}},u=(c=this.encryptionService).encryptToString,d=[i],[4,this.encryptionService.encryptToString(n.jwk,s)];case 6:return[4,u.apply(c,d.concat([l.sent()]))];case 7:return o=l.sent(),[2,new Tr({mutation:Mc,variables:{input:{tpId:e,mkSharedKeyId:a.id,mkReshareResponseCipher:o}}})]}}))}))},t.prototype.completeMkReshare=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,l;return E(this,(function(y){switch(y.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=y.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=y.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=y.sent(),s=(a=this.encryptionService).decrypt,o=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,s.apply(a,o.concat([y.sent()]))];case 5:return i=y.sent(),u={id:i.mkSharedKey.id},[4,p.JWK.asKey(i.mkSharedKey.jwk)];case 6:return u.jwk=y.sent(),c=u,[4,this.keyService.getCurrentMasterKey()];case 7:return d=y.sent(),[4,this.encryptionService.encryptToString(d.jwk,c.jwk.toJSON(!0))];case 8:return l=y.sent(),[2,new Tr({mutation:jc,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:c.id,mkWrappedMkSharedKey:l}}})]}}))}))},t}(Yr),e.TrustedParty2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TrustedParty2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(ve),n.ɵɵinject(e.Item2Service),n.ɵɵinject(fe),n.ɵɵinject(ye),n.ɵɵinject(de))},token:e.TrustedParty2Service,providedIn:"root"}),e.TrustedParty2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TrustedParty2Service.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:ve},{type:e.Item2Service},{type:fe},{type:ye},{type:de}]},e.TrustedParty2Service=D([br({ngZoneName:"ngZone"})],e.TrustedParty2Service),e.TpPasswordResetService=function(e){function t(t,n,r){var i=e.call(this,n)||this;return i.ngZone=t,i.injector=n,i.assemblyController=r,i.slip39Passphrase=ii,i}return w(t,e),t.prototype.getReset=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.query({query:hr})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new Tr({mutation:or})},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new Tr({mutation:vr})},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 R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.assemblyController.prepareCreate(e)];case 1:return t=n.sent().mutationInput,[2,new Tr({mutation:fr,variables:{input:{assembly:Object.assign({},t)}}})]}}))}))},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getReset()];case 1:return t=r.sent(),[4,this.assemblyController.prepareUpdate(e,t.assembly)];case 2:return n=r.sent().mutationInput,[2,new Tr({mutation:gr,variables:{input:{assembly:Object.assign({},n)}}})]}}))}))},t}(Yr),e.TpPasswordResetService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(e.ɵl))},token:e.TpPasswordResetService,providedIn:"root"}),e.TpPasswordResetService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:e.ɵl}]},e.TpPasswordResetService=D([br({ngZoneName:"ngZone"})],e.TpPasswordResetService),e.TpPasswordResetUserService=function(e){function t(t,n,r,i,a,s,o,c,u,p,d){var l=e.call(this,n)||this;return l.ngZone=t,l.injector=n,l.config=r,l.keyFactory=i,l.encryptionService=a,l.keyGraphService=s,l.slip39Service=o,l.passwordService=c,l.http=u,l.auth=p,l.lrAuth=d,l}return w(t,e),t.prototype.verifyEmailContact=function(e){return R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return[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(c),console.log("Using new password: ",this.passwordService.getPassIdpString(r.passIdp)),[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: ",u),[2,{requestResetResult:c,signUpResult:u}]}}))}))},t}(Yr),e.TpPasswordResetUserService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetUserService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(te),n.ɵɵinject(ye),n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(ni),n.ɵɵinject(qn),n.ɵɵinject(t.HttpClient),n.ɵɵinject(d.AuthClass),n.ɵɵinject(ci))},token:e.TpPasswordResetUserService,providedIn:"root"}),e.TpPasswordResetUserService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetUserService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:ye},{type:de},{type:ve},{type:ni},{type:qn},{type:t.HttpClient},{type:d.AuthClass},{type:ci}]},e.TpPasswordResetUserService=D([br({ngZoneName:"ngZone"})],e.TpPasswordResetUserService),e.TpPasswordResetRequestService=function(t){function n(e,n,r){var i=t.call(this,n)||this;return i.ngZone=e,i.injector=n,i.encryptionService=r,i}return w(n,t),n.prototype.getSharedResets=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.query({query:ar})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},n.prototype.getSharedReset=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.query({query:sr,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},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 R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getSharedReset(t)];case 1:return n=r.sent(),this.activeRequestOrRaise(n),[2,jr.create(n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})).map((function(e){return new Tr({mutation:lr,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},n.prototype.approveRequest=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(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 R(this,void 0,void 0,(function(){var n,r,i,a,s,o=this;return E(this,(function(c){switch(c.label){case 0:return[4,this.getSharedReset(t)];case 1:return n=c.sent(),this.activeRequestOrRaise(n),[4,p.JWK.asKey(JSON.parse(n.sharedRequest.pxk.pbk))];case 2:return r=c.sent(),console.log(r.toJSON()),i=n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})),s=(a=jr).create,[4,Promise.all(i.map((function(e){return R(o,void 0,void 0,(function(){var t,n,i,a=this;return E(this,(function(s){switch(s.label){case 0:return t=e.node,i={claimApproverId:t.id},[4,Promise.all(t.receiverApprovals.edges.map((function(e){return R(a,void 0,void 0,(function(){var n,i;return E(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 i.receiverApprovals=s.sent(),n=i,console.log(n),[2,new Tr({mutation:dr,variables:{input:n}})]}}))}))})))];case 3:return[2,s.apply(a,[c.sent()])]}}))}))},n}(Yr),e.TpPasswordResetRequestService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetRequestService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(de))},token:e.TpPasswordResetRequestService,providedIn:"root"}),e.TpPasswordResetRequestService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetRequestService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:de}]},e.TpPasswordResetRequestService=D([br({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService);var $c,Nc,Fc,Lc,xc,Uc=En($c||($c=M(["\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"]))),Jc=En(Nc||(Nc=M(["\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"]))),_c=En(Fc||(Fc=M(["\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"]))),qc=En(Lc||(Lc=M(["\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"]))),Gc=En(xc||(xc=M(["\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 w(t,e),t.prototype.updateNotification=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.updateNotificationMutation(e))]}))}))},t.prototype.updateNotificationMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:Uc,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.updateAllNotificationsReadState=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.updateAllNotificationsReadStateMutation(e))]}))}))},t.prototype.updateAllNotificationsReadStateMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:Jc,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.debugCreateNotification=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.debugCreateNotificationMutation(e))]}))}))},t.prototype.debugCreateNotificationMutation=function(e){var t;return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,new Tr({mutation:_c,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 R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.debugDeleteAllNotificationsMutation(e))]}))}))},t.prototype.debugDeleteAllNotificationsMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:qc,variables:{input:{receiverId:e.receiverId}}})]}))}))},t.prototype.updateNotificationFeatureState=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.updateNotificationFeatureStateMutation(e))]}))}))},t.prototype.updateNotificationFeatureStateMutation=function(e){var t;return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,new Tr({mutation:Gc,variables:{input:{lastViewed:null===(t=e.lastViewed)||void 0===t?void 0:t.toISOString(),clearLastViewed:null==e.lastViewed||void 0}}})]}))}))},t}(Yr),e.NotificationService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.NotificationService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR))},token:e.NotificationService,providedIn:"root"}),e.NotificationService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.NotificationService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.NotificationService=D([br({ngZoneName:"ngZone"})],e.NotificationService);var Bc,Vc,Qc,Wc,Zc,Hc,Yc,zc,Xc=En(Bc||(Bc=M(["\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"]))),eu=En(Vc||(Vc=M(["\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"]))),tu=En(Qc||(Qc=M(["\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"]))),nu=En(Wc||(Wc=M(["\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"]))),ru=En(Zc||(Zc=M(["\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"]))),iu=En(Hc||(Hc=M(["\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"]))),au=En(Yc||(Yc=M(["\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"]))),su=En(zc||(zc=M(["\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"])));e.ɵq=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 w(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.sharedKey.id},t}(si),e.ɵq.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵq(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR))},token:e.ɵq,providedIn:"root"}),e.ɵq.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵq.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.ɵq=D([br({ngZoneName:"ngZone"})],e.ɵq);var ou,cu,uu=En(ou||(ou=M(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),pu=En(cu||(cu=M(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"],["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));function du(){throw new J("claimId does not match with the current claimId of the scenario")}function lu(){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.item2Service=i,o.assemblyController=a,o.encryptionService=s,o.prepareAddReceiverDirectory=o.prepareReceiverDirectory,o.prepareUpdateReceiverDirectory=o.prepareReceiverDirectory,o}return w(n,t),n.prototype.createScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.createScenarioMutation(e))]}))}))},n.prototype.createScenarioMutation=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.prepareCreateScenarioMutation(e)];case 1:return t=n.sent(),[2,new Tr({mutation:Xc,variables:{input:t}})]}}))}))},n.prototype.updateScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.updateScenarioMutation(e))]}))}))},n.prototype.updateScenarioMutation=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(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 Tr({mutation:eu,variables:{input:n}})]}}))}))},n.prototype.resetScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.resetScenarioMutation(e))]}))}))},n.prototype.resetScenarioMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(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=zr(n.subAssemblies).map((function(e){var t=zr(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 Tr({mutation:eu,variables:{input:i}})]}}))}))},n.prototype.deleteScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.lrGraphQL.lrMutate(this.deleteScenarioMutation(e))]}))}))},n.prototype.deleteScenarioMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:tu,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.createClaim=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.createClaimMutation(e))]}))}))},n.prototype.createClaimMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:nu,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.cancelClaim=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.cancelClaimMutation(e))]}))}))},n.prototype.cancelClaimMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:ru,variables:{input:{claimId:e}}})]}))}))},n.prototype.rejectClaim=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.mutate(this.rejectClaimMutation(e,t))]}))}))},n.prototype.rejectClaimMutation=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.prepareRejectClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=jr).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.approveClaim=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.mutate(this.approveClaimMutation(e,t))]}))}))},n.prototype.approveClaimMutation=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.prepareApproveClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=jr).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.receiveClaim=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.mutate(this.receiveClaimMutation(e,t))]}))}))},n.prototype.receiveClaimMutation=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return n=Tr.bind,r={mutation:su},i={},[4,this.prepareClaim(e,t)];case 1:return[2,new(n.apply(Tr,[void 0,(r.variables=(i.input=a.sent(),i),r)]))]}}))}))},n.prototype.getScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.query({query:uu,variables:{scenarioId:e}})]}))}))},n.prototype.getSharedScenario=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return[4,this.query({query:pu,variables:{scenarioId:e}})];case 1:return n=r.sent(),t&&n.sharedScenario.sharedClaim.id!==t&&du(),[2,n]}}))}))},n.prototype.getParticipantTpsKeys=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return t=e.map((function(e){return e.tpId})),n=zr,[4,this.lrGraphQL.query({query:ai,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 R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p=this;return E(this,(function(d){switch(d.label){case 0:return[4,this.assemblyController.prepareCreate(e.createAssembly)];case 1:return t=d.sent(),n=t.assemblyKey,r=t.mutationInput,i=e.createReceivers||[],a=e.createClaimants||[],s=i.concat(a),[4,this.getParticipantTpsKeys(s)];case 2:return o=d.sent(),this.fillTpSharedKeyId(s,o),[4,Promise.all(i.map((function(e){return p.prepareCreateReceiver(e,n)})))];case 3:return c=d.sent(),[4,Promise.all(a.map((function(e){return p.prepareCreateClaimant(e)})))];case 4:return u=d.sent(),[2,{enabled:e.enabled,createAssembly:r,createReceivers:c,createClaimants:u}]}}))}))},n.prototype.prepareUpdateScenario=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b=this;return E(this,(function(k){switch(k.label){case 0:return[4,this.keyGraph.getJwkKey(t.assembly.assemblyKey.id)];case 1:return n=k.sent(),e.updateAssembly?[4,this.assemblyController.prepareUpdate(e.updateAssembly,t.assembly)]:[3,3];case 2:i=k.sent(),r=i.mutationInput,n=i.assemblyKey,k.label=3;case 3:return a=e.createReceivers||[],s=e.createClaimants||[],o=a.concat(s),[4,this.getParticipantTpsKeys(o)];case 4:return c=k.sent(),this.fillTpSharedKeyId(o,c),(p=e.createReceivers)?[4,Promise.all(e.createReceivers.map((function(e){return b.prepareCreateReceiver(e,n)})))]:[3,6];case 5:p=k.sent(),k.label=6;case 6:return u=p,d=zr(t.receivers),e.updateReceivers?[4,Promise.all(e.updateReceivers.map((function(e){var t=d.find((function(t){return t.tp.id===e.tpId}));return b.prepareUpdateReceiver(e,n,t)})))]:[3,8];case 7:return y=k.sent(),[3,9];case 8:y=[],k.label=9;case 9:return l=y,e.updateAssembly?(h=d.filter((function(t){return!(e.deleteReceivers||[]).includes(t.tp.id)&&!l.some((function(e){return e.tpId===t.tp.id}))})),v=(f=l).concat,[4,this.prepareExistingReceivers(h,n)]):[3,11];case 10:l=v.apply(f,[k.sent()]),k.label=11;case 11:return(m=e.createClaimants)?[4,Promise.all(e.createClaimants.map((function(e){return b.prepareCreateClaimant(e)})))]:[3,13];case 12:m=k.sent(),k.label=13;case 13:return g=m,S=zr(t.claimants),(C=e.updateClaimants)?[4,Promise.all(e.updateClaimants.map((function(e){var t=S.find((function(t){return t.tp.id===e.tpId}));return b.prepareUpdateClaimant(e,t.sharedKey.id)})))]:[3,15];case 14:C=k.sent(),k.label=15;case 15:return I=C,[2,{scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:r,createReceivers:u,updateReceivers:l,deleteReceivers:e.deleteReceivers,createClaimants:g,updateClaimants:I,deleteClaimants:e.deleteClaimants}]}}))}))},n.prototype.prepareReceiverDirectory=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.item2Service.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return r=s.sent(),[4,this.keyGraph.encryptToString(t,e.sharedCipherDataClearJson)];case 2:return i=s.sent(),[4,this.keyGraph.encryptToString(t,r.jwk.toJSON(!0))];case 3:return a=s.sent(),[4,this.keyGraph.encryptToString(n,a)];case 4:return a=s.sent(),[2,{directoryId:e.directoryId,wrappedItemKey:a,accessRole:e.accessRole,sharedCipherData:i}]}}))}))},n.prototype.prepareCreateReceiver=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o=this;return E(this,(function(c){switch(c.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return n=c.sent(),r=n.sharedKey,i=n.mutationInput,(s=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return o.prepareAddReceiverDirectory(e,r.key,t)})))]:[3,3];case 2:s=c.sent(),c.label=3;case 3:return a=s,[2,Object.assign(Object.assign({},i),{addDirectories:a})]}}))}))},n.prototype.prepareUpdateReceiver=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l=this;return E(this,(function(y){switch(y.label){case 0:return r=n.sharedKey.id,i=e.deleteDirectories||[],a=e.updateDirectories||[],zr(n.receiverDirectories).forEach((function(e){i.includes(e.directory.id)||a.find((function(t){return t.directoryId===e.directory.id}))||a.push({accessRole:e.accessRole,directoryId:e.directory.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),[4,this.prepareUpdateParticipant(e,r)];case 1:return s=y.sent(),o=s.sharedKey,c=s.mutationInput,(p=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return l.prepareAddReceiverDirectory(e,o,t)})))]:[3,3];case 2:p=y.sent(),y.label=3;case 3:return u=p,[4,Promise.all(a.map((function(e){return l.prepareUpdateReceiverDirectory(e,o,t)})))];case 4:return d=y.sent(),[2,Object.assign(Object.assign({},c),{addDirectories:u,updateDirectories:d,deleteDirectories:e.deleteDirectories})]}}))}))},n.prototype.prepareExistingReceiver=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(this,(function(r){return n=zr(e.receiverDirectories).map((function(e){return{directoryId:e.directory.id,directoryKeyId:e.directory.keyId,accessRole:e.accessRole,sharedCipherDataClearJson:e.sharedCipherDataClearJson}})),[2,this.prepareUpdateReceiver({tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,updateDirectories:n},t,e)]}))}))},n.prototype.prepareExistingReceivers=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){return[2,Promise.all(e.map((function(e){return n.prepareExistingReceiver(e,t)})))]}))}))},n.prototype.prepareCreateParticipant=function(e){return R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var n,r;return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.prepareUpdateParticipant(e,t)];case 1:return[2,n.sent().mutationInput]}}))}))},n.prototype.prepareClaim=function(t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o=this;return E(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&&lu(),i=zr(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),console.log("receiveClaimMutation assemblyKey",a),[4,Promise.all(r.asReceiver.receiverDirectories.edges.map((function(e){return e.node})).map((function(e){return R(o,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.encryptionService.decrypt(a,e.wrappedItemKey)];case 1:return t=n.sent(),[2,{receiverDirectoryId:e.id,receiverSharedKeyWrappedItemKey:t}]}}))}))})))];case 3:return s=c.sent(),[2,{scenarioClaimId:n,receiverDirectories:s}]}}))}))},n.prototype.recoverAssemblyKey=function(e){return R(this,void 0,void 0,(function(){var t,n=this;return E(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 R(this,void 0,void 0,(function(){return E(this,(function(r){switch(r.label){case 0:return[4,this.getSharedScenario(e,t)];case 1:return[2,zr(r.sent().sharedScenario.sharedClaim.claim.asClaimApprovers).filter((function(e){return e.state===n}))]}}))}))},n.prototype.prepareApproveClaimMutations=function(t,n){return R(this,void 0,void 0,(function(){var r=this;return E(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 R(r,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:au},r={},[4,this.prepareApproveClaim(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))}))]}}))}))},n.prototype.prepareApproveClaim=function(e){return R(this,void 0,void 0,(function(){var t,n=this;return E(this,(function(r){switch(r.label){case 0:return[4,Promise.all(zr(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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var r=this;return E(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 R(r,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:iu,variables:{input:{claimApproverId:e.id}}})]}))}))}))]}}))}))},n}(Yr),e.ScenarioService.SLIP39_PASSPHRASE="lifeready",e.ScenarioService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ScenarioService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(ve),n.ɵɵinject(e.Item2Service),n.ɵɵinject(e.ɵq),n.ɵɵinject(de))},token:e.ScenarioService,providedIn:"root"}),e.ScenarioService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ScenarioService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:ve},{type:e.Item2Service},{type:e.ɵq},{type:de}]},e.ScenarioService=D([br({ngZoneName:"ngZone"})],e.ScenarioService),e.AcceptTrustedPartyInvite=ls,e.AccessFields=mt,e.ApiContactCard=Ve,e.ApiCurrentUser=Be,e.ArchiveDirectoryMutation=jt,e.CancelTrustedPartyInvitationMutation=Os,e.CancelUserDeleteMutation=vi,e.Category=Da,e.CategoryFields=It,e.CategoryFilter=vt,e.CategoryMetaService=$a,e.CategoryService=Ma,e.CognitoChallengeUser=gn,e.CompleteOtkMutation=$i,e.ConfirmTrustedPartyInvite=ys,e.ContactCardAddress=We,e.ContactCardName=Qe,e.CreateCategoryMutation=At,e.CreateContactCardMutation=_e,e.CreateFileMutation=Ca,e.CreateFileQuery=Ne,e.CreateLbopQuery=Zi,e.CreateRecordContainerMutation=va,e.CreateRecordMutation=ga,e.CreateVaultMutation=Ot,e.CurrentCategory=Ra,e.CurrentUser=In,e.CurrentUserKey=Ge,e.CurrentUserQuery=Je,e.CurrentUserSharedKeyQuery=Ei,e.DEFAULT_BREADCRUMB_DEPTH=5,e.DEFAULT_DESCENDANTS_DEPTH=5,e.DeclineTrustedPartyInvitationMutation=As,e.DefaultCategory=Ka,e.DefaultProcessorOptions=kr,e.DefaultVaultFilter=ft,e.DeleteCategoryMutation=Mt,e.DeleteFileMutation=ba,e.DeleteLbopQuery=Hi,e.DeleteRecordMutation=Ia,e.DeleteTrustedPartyMutation=Ts,e.DirectoryQuery=$e,e.Features=Sn,e.FetchKeyGraphField=Me,e.FileQuery=je,e.FileService=ui,e.FoundTrustedParty=ps,e.GetAllTrustedPartiesQuery=Rs,e.GetCategoriesQuery=kt,e.GetCategoryKeyIdQuery=Et,e.GetCategoryQuery=Rt,e.GetMySharedCategoriesQuery=Pt,e.GetRecordQuery=fa,e.GetRootDirectoryIdsQuery=bt,e.GetTrustedPartiesQuery=Ds,e.GetTrustedPartyCategoriesQuery=wt,e.GetTrustedPartyQuery=Es,e.GetVaultsQuery=Kt,e.IdleService=Un,e.InitiateOtkMutation=Mi,e.InviteTrustedParty=ds,e.KeyExchangeFields=Di,e.KeyExchangeQuery=Oi,e.KeyExchangeService=Ni,e.KeyExchangeTokenQuery=Ti,e.KeyExchangesQuery=Ai,e.KeyGraphField=Te,e.KeyGraphFragment=Oe,e.LR_CONFIG=te,e.LbopQuery=zi,e.LbopService=ea,e.LbopsQuery=Xi,e.LifeReadyAuthService=ci,e.LifeReadyModule=Ls,e.LoadedCategoryTree=ja,e.LoginHistoryQuery=gi,e.LoginResult=Cn,e.LrApolloService=ge,e.LrAuthException=Z,e.LrBadArgumentException=J,e.LrBadLogicException=G,e.LrBadRequestException=W,e.LrBadStateException=ee,e.LrCodeMismatchException=B,e.LrConcurrentAccessException=V,e.LrEncryptionException=H,e.LrError=F,e.LrException=L,e.LrExpiredCodeException=z,e.LrExpiredException=X,e.LrGraphQLService=e.ɵh,e.LrLockedException=Q,e.LrMergedMutation=jr,e.LrMutation=Tr,e.LrMutationBase=Or,e.LrNotFoundException=q,e.LrRecord=Ua,e.LrService=Yr,e.LrSuspiciousException=_,e.LrUnsupportedException=Y,e.MainContactCard=Ye,e.MainContactCardFields=He,e.MainContactCardPlainFields=ze,e.MainContactCardProperty=Ze,e.MessageQuery=Ui,e.MessageService=Ji,e.MoveDirectoryQuery=Ue,e.MoveFileQuery=xe,e.NewAttachment=Ja,e.NewCategory=Aa,e.NewOrUpdatedAttachment=qa,e.NewRecord=_a,e.OwnerPlainDataJson=eo,e.PassIdpApiResult=et,e.PasswordCheck=_n,e.PasswordService=qn,e.PersistService=he,e.Plan=Bs,e.PlanService=fn,e.ProfileDetailsService=Fs,e.ProfileService=vn,e.RecordAttachment=xa,e.RecordAttachmentFilter=ha,e.RecordAttachmentService=Na,e.RecordContentFilter=ya,e.RecordField=La,e.RecordFilter=gt,e.RecordService=Ba,e.RecordType=Va,e.RecordTypeField=Wa,e.RecordTypeFieldOption=Qa,e.RecordTypeService=za,e.RecordTypeSummary=Za,e.RegisterResult=bn,e.RegisterService=ta,e.RequestUserDeleteMutation=fi,e.RespondOtkMutation=ji,e.RevertFileQuery=Le,e.SendMessageMutation=xi,e.ShareCategoryMutation=Ms,e.SharedAccess=ka,e.SharedTrustedPartyDetails=as,e.SharedVaultFeature=cs,e.StripeBillingPortalSession=Zs,e.StripeCheckoutSession=Ws,e.Subscription=Vs,e.TPFeatures=os,e.TrustedParties=is,e.TrustedParty=us,e.TrustedPartyDetails=tt,e.TrustedPartyInvite=ss,e.TrustedPartyProperties=Ps,e.TrustedPartyRole=ns,e.TrustedPartyService=$s,e.TwoFactorService=ra,e.UnarchiveDirectoryMutation=$t,e.UnshareCategoryMutation=js,e.UpdateCategoryMutation=Tt,e.UpdateContactCardMutation=qe,e.UpdateFileQuery=Fe,e.UpdateLbopQuery=Yi,e.UpdateRecordContainerMutation=ma,e.UpdateRecordMutation=Sa,e.UpdatedCategory=Oa,e.UpdatedRecord=Ga,e.UserPlan=Qs,e.UserQuery=hi,e.UserService=mi,e.UserSharedKeyFields=Ri,e.Vault=Ta,e.VaultCategory=Ea,e.VaultFields=Ct,e.VaultRecord=Pa,e.VaultRecordType=wa,e.awsFetch=Qi,e.configureAmplifyAuth=Wi,e.configureApollo=re,e.fragmentSpreadAstSelection=Ar,e.gqlTyped=En,e.handleApolloError=j,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.initialiseAuth=oi,e.mapEdges=zr,e.mapUserPlans=hn,e.parentCategoriesField=Dt,e.processConnection=Kr,e.throwClaimIdMismatch=du,e.throwClaimNotApproved=lu,e.ɵ0=Ya,e.ɵa=ye,e.ɵb=le,e.ɵc=fe,e.ɵd=de,e.ɵe=ce,e.ɵf=ve,e.ɵg=Nt,e.ɵj=br,e.ɵk=ni,e.ɵm=si,e.ɵn=hs,e.ɵo=vs,e.ɵp=Yr,Object.defineProperty(e,"__esModule",{value:!0})}));
15
+ ***************************************************************************** */function w(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}K(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function P(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 D(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 R(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(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 A(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 O(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 T(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(O(arguments[t]));return e}function M(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}Object.create;function j(e){if(e&&e.length){var t=e.map((function(e){return{code:e.extensions&&e.extensions.code,source:e.extensions&&e.extensions.source,message:e.message,debug:{locations:e.locations,path:e.path}}}));throw new(L.bind.apply(L,T([void 0],t)))}}var $,N,F=function(){},L=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.errors=e}return e.prototype.toString=function(){return this.errors.map((function(e){return JSON.stringify(e,null,2)}))},e}();($=e.LrApiErrorCode||(e.LrApiErrorCode={})).ARCHIVED_RESOURCE="ARCHIVED_RESOURCE",$.BAD_ARGUMENT="BAD_ARGUMENT",$.BAD_SIGNATURE="BAD_SIGNATURE",$.BAD_STATE="BAD_STATE",$.CHANGED_PERMISSIONS="CHANGED_PERMISSIONS",$.CONCURRENT_ACCESS="CONCURRENT_ACCESS",$.CONFIG_ERROR="CONFIG_ERROR",$.CYCLE_DETECTED="CYCLE_DETECTED",$.EXPIRED="EXPIRED",$.INVALID_TOKEN="INVALID_TOKEN",$.INTERNAL_ERROR="INTERNAL_ERROR",$.JSON_DECODE_ERROR="JSON_DECODE_ERROR",$.KEY_MISMATCH="KEY_MISMATCH",$.LIMIT_REACHED="LIMIT_REACHED",$.LOCKED="LOCKED",$.LOGIC_ERROR="LOGIC_ERROR",$.LR_DEBUG_ONLY="LR_DEBUG_ONLY",$.MIN_DELAY="MIN_DELAY",$.MISSING_FIELD="MISSING_FIELD",$.MISSING_FIELD_VALUE="MISSING_FIELD_VALUE",$.MISSING_QUERY_PARAM="MISSING_QUERY_PARAM",$.NOT_IMPLEMENTED="NOT_IMPLEMENTED",$.OBJECT_DOES_NOT_EXIST="OBJECT_DOES_NOT_EXIST",$.OBJECT_EXISTS="OBJECT_EXISTS",$.RANGE_ERROR="RANGE_ERROR",$.TRUSTED_PARTY_NOT_FOUND="TRUSTED_PARTY_NOT_FOUND",$.UNAUTHENTICATED_USER="UNAUTHENTICATED_USER",$.USER_NOT_FOUND="USER_NOT_FOUND",$.VERSION_MISMATCH="VERSION_MISMATCH",$.WRONG_PERMISSIONS="WRONG_PERMISSIONS",(N=e.LrErrorCode||(e.LrErrorCode={})).BadTimeSync="LrBadTimeSync",N.ReceiveClaimMismatch="LrReceiveClaimMismatch",N.BadState="LrBadState",N.BadSignature="LrBadSignature",N.Auth="LrAuth",N.BadArgument="LrBadArgument",N.SuspiciousException="LrSuspiciousException",N.NotFound="LrNotFound",N.BadLogic="LrBadLogicException",N.CodeMismatch="LrCodeMismatchException",N.ConcurrentAccess="LrConcurrentAccessException",N.BadRequest="LrBadRequestException",N.Encryption="LrEncryptionGoBad",N.Locked="LrLockedException";var x,U,J=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadArgument,message:n})||this}return w(n,t),n}(L),_=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadArgument,message:n})||this}return w(n,t),n}(L),q=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.NotFound,message:n})||this}return w(n,t),n}(L),G=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadLogic,message:n})||this}return w(n,t),n}(L),B=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.CodeMismatch,message:n})||this}return w(n,t),n}(L),Q=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.ConcurrentAccess,message:n})||this}return w(n,t),n}(L),V=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Locked,message:n})||this}return w(n,t),n}(L),W=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.BadRequest,message:n})||this}return w(n,t),n}(L),Z=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Auth,message:n})||this}return w(n,t),n}(L),H=function(t){function n(n){return t.call(this,{code:e.LrErrorCode.Encryption,message:n})||this}return w(n,t),n}(L),Y=function(e){function t(t){return e.call(this,{code:"LrUnsupportedException",message:t})||this}return w(t,e),t}(L),z=function(e){function t(t){return e.call(this,{code:"LrExpiredCodeException",message:t})||this}return w(t,e),t}(L),X=function(e){function t(t){return e.call(this,{code:"LrExpiredException",message:t})||this}return w(t,e),t}(L),ee=function(e){function t(t){return e.call(this,{code:"LrBadStateException",message:t})||this}return w(t,e),t}(L),te=new n.InjectionToken("LR.AUTH"),ne=[e.LrApiErrorCode.CONCURRENT_ACCESS],re=function(e,t){var n=i.setContext((function(e,n){var r=n.headers;return R(void 0,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:e=null,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.currentSession()];case 2:return e=n.sent().getAccessToken(),[3,4];case 3:return n.sent(),console.log("User not signed in"),[3,4];case 4:return[2,{headers:Object.assign(Object.assign({},r),{authorization:e?"Bearer "+e.jwtToken:""})}]}}))}))})),s=new a.RetryLink({delay:{initial:300,max:1/0,jitter:!0},attempts:{max:3,retryIf:function(e,t){return!!(e instanceof o&&e.errors.some((function(e){var t;return ne.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})))}}}),o=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 w(t,e),t}(Error),c=new r.ApolloLink((function(e,t){return t(e).map((function(e){if(e&&e.errors&&e.errors.filter((function(e){var t;return ne.includes(null===(t=e.extensions)||void 0===t?void 0:t.code)})).length>0)throw new o(e.errors);return e}))})),u=r.createHttpLink({uri:e.apolloUrl,credentials:"include"});return Object.assign({link:r.from([s,c,n,u]),cache:new r.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{errorPolicy:"all"}}},e.apolloConfig)};!function(e){e.Key="key",e.PassKey="passKey"}(x||(x={})),function(e){e.KeyLink="keyLink",e.PassKeyLink="passKeyLink"}(U||(U={}));var ie,ae,se=h,oe=y(ie||(ie=M(["\n query {\n serverTime {\n timestamp\n }\n }\n"],["\n query {\n serverTime {\n timestamp\n }\n }\n"]))),ce=function(){function t(e,t){this.auth=e,this.apollo=t,this.VERIFY_ENABLED=!0,this.MAX_DIFF_MSEC=se.duration({seconds:30}).asMilliseconds(),this.offsetMs=null,this.verified=!1}return t.prototype.getAccessToken=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.auth.currentAuthenticatedUser()];case 1:return[2,e.sent().getSignInUserSession().getAccessToken().getJwtToken()];case 2:return e.sent(),[2,""];case 3:return[2]}}))}))},t.prototype.verifyCognito=function(){return R(this,void 0,void 0,(function(){var t,n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.getAccessToken()];case 1:return(t=s.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:t})})]:[2];case 2:if(n=s.sent(),r=Date.now(),i=se(n.headers.get("Date")).valueOf(),a=r+this.offsetMs,Math.abs(a-i)>this.MAX_DIFF_MSEC)throw new L({code:e.LrErrorCode.BadTimeSync,message:"Server time does not match independent source. ServerTime: "+a+", Cognito time: "+i});return this.verified=!0,[2]}}))}))},t.prototype.refresh=function(){return R(this,void 0,void 0,(function(){var e,t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return e=Date.now(),[4,this.apollo.query({query:oe}).toPromise()];case 1:return t=a.sent(),n=Date.now(),j(t.errors),r=parseInt(t.data.serverTime.timestamp,10),i=n-e,this.offsetMs=r-(e+i/2),this.VERIFY_ENABLED?[4,this.verifyCognito()]:[3,3];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},t.prototype.serverNow=function(){return R(this,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:return e=!1,null===this.offsetMs&&(e=!0),this.VERIFY_ENABLED?(t=!this.verified)?[4,this.getAccessToken()]:[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]}}))}))},t}();ce.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ce(n.ɵɵinject(d.AuthClass),n.ɵɵinject(l.Apollo))},token:ce,providedIn:"root"}),ce.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ce.ctorParameters=function(){return[{type:d.AuthClass},{type:l.Apollo}]},function(e){e.JSON="JSON",e.COMPACT="COMPACT"}(ae||(ae={}));var ue={payloadType:"json",returnOnlyPayload:!0},pe={payloadType:"json",returnOnlyPayload:!0,serializations:[ae.JSON]};var de=function(){function t(e){this.timeService=e}return t.prototype.decrypt=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i;return E(this,(function(a){switch(a.label){case 0:if(r={algorithms:["dir","A*GCM","RSA-OAEP-*"]},n=Object.assign(Object.assign({},pe),n),e.jwk&&(e=e.jwk),"string"==typeof t&&n.serializations.includes(ae.JSON))try{t=JSON.parse(t)}catch(e){if(!n.serializations.includes(ae.COMPACT))throw e;console.log("Not a JSON-formatted JWE, it maybe compact serialisation format.")}return[4,p.JWE.createDecrypt(e,r).decrypt(t)];case 1:return(i=a.sent()).payload=this.decodePayload(n.payloadType,i.payload),n.returnOnlyPayload?[2,i.payload]:[2,i]}}))}))},t.prototype.encryptToString=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(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()])]}}))}))},t.prototype.encrypt=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.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=p.JWE).createEncrypt,i={contentAlg:"A256GCM"},a={},[4,this.timeService.serverNow()];case 1:return[2,r.apply(n,[(i.fields=(a.timestamp=s.sent(),a),i),e]).update(t).final()]}}))}))},t.prototype.sign=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return i=(r=p.JWS).createSign,a={},s={},[4,this.timeService.serverNow()];case 1:return n=i.apply(r,[(a.fields=(s.timestamp=o.sent(),s),a),e]),t instanceof Buffer?n.update(t):n.update(JSON.stringify(t),"utf8"),[2,n.final()]}}))}))},t.prototype.signToString=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(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()])]}}))}))},t.prototype.verify=function(t,n,r){return R(this,void 0,void 0,(function(){var i,a,s;return E(this,(function(o){switch(o.label){case 0:i={algorithms:["RS*"]},r=Object.assign(Object.assign({},ue),r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,p.JWS.createVerify(t,i).verify(n)];case 2:return(a=o.sent()).payload=this.decodePayload(r.payloadType,a.payload),r.returnOnlyPayload?[2,a.payload]:[2,a];case 3:throw s=o.sent(),new L({code:e.LrErrorCode.BadSignature,message:"Bad signature: "+s});case 4:return[2]}}))}))},t.prototype.encryptThenSign=function(e,t){var n=e.key,r=e.sigPrk;return R(this,void 0,void 0,(function(){var e,i,a,s;return E(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)}]}}))}))},t.prototype.decodePayload=function(e,t){switch(e){case"json":return JSON.parse((new TextDecoder).decode(t));case"ArrayBuffer":return t;default:throw new J("Unknown payloadType: "+e)}},t}();de.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new de(n.ɵɵinject(ce))},token:de,providedIn:"root"}),de.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],de.ctorParameters=function(){return[{type:ce}]};var le=function(){function e(){this.crypto=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 R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return n=new TextEncoder,r=n.encode(t),[4,this.crypto.subtle.digest(e,r)];case 1:return i=a.sent(),[2,this.toHex(i)]}}))}))},e}();le.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new le},token:le,providedIn:"root"}),le.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}];var ye=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.crypto=this.webCryptoService.crypto}return e.asKey=function(e,t,n){return p.JWK.asKey(e,t,n)},e.prototype.randomString=function(e){if(e<=0)throw new J("digits <= 0");var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint32Array(e);return this.crypto.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 J("array.length <= 0");if(t<=0)throw new J("chooseN <= 0");var n=new Uint32Array(t);this.crypto.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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 1:return t=r.sent(),[4,this.crypto.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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.crypto.subtle.generateKey({name:"HMAC",hash:{name:"SHA-512"}},!0,["sign","verify"])];case 1:return t=r.sent(),[4,this.crypto.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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.crypto.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.crypto.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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.crypto.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.crypto.subtle.exportKey("jwk",t.privateKey)];case 2:return delete(n=r.sent()).key_ops,delete n.ext,[2,e.asKey(n)]}}))}))},e.prototype.deriveKey=function(t){var n=t.password,r=t.salt,i=t.iterations,a=t.kid;return R(this,void 0,void 0,(function(){var t,s,o,c;return E(this,(function(u){switch(u.label){case 0:return t=new TextEncoder,[4,this.crypto.subtle.importKey("raw",t.encode(n),"PBKDF2",!1,["deriveBits","deriveKey"])];case 1:return s=u.sent(),[4,crypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode(r),iterations:i,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])];case 2:return o=u.sent(),[4,crypto.subtle.exportKey("jwk",o)];case 3:return c=u.sent(),a&&(c.kid=a),[4,e.asKey(c)];case 4:return[2,{jwk:u.sent()}]}}))}))},e.prototype.derivePassIdp=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){if(e.iterations<this.MIN_PASS_IDP_PBKDF_ITER)throw new _("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 R(this,void 0,void 0,(function(){return E(this,(function(t){if(e.iterations<this.MIN_PASS_KEY_PBKDF_ITER)throw new _("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 R(this,void 0,void 0,(function(){return E(this,(function(t){if(e.iterations<this.MIN_LBOP_KEY_PBKDF_ITER)throw new _("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 R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.createKey()];case 1:return[2,e.sent().kid]}}))}))},e.prototype.createPassIdpParams=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){return[2,{salt:this.createSalt(),iterations:this.DEFAULT_PASS_IDP_PBKDF_ITER}]}))}))},e.prototype.createPassKeyParams=function(){return R(this,void 0,void 0,(function(){var e;return E(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 R(this,void 0,void 0,(function(){var e;return E(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}();ye.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ye(n.ɵɵinject(le))},token:ye,providedIn:"root"}),ye.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ye.ctorParameters=function(){return[{type:le}]};var he=function(){function e(e,t,r,i){this.keyFactory=e,this.cookieService=t,this.encryptionService=r,this.injector=i,this.KEY_PREFIX="lrSession-",this.cookieSecure=!0,this.serverSessionEncryptionKey=null,n.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(!n.isDevMode())throw new J("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 R(this,void 0,void 0,(function(){var e,a,s,o,c,u,p;return E(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 R(this,void 0,void 0,(function(){var t,n,r;return E(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 R(this,void 0,void 0,(function(){var t,n,r,i,a,s;return E(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,ye.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}();he.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new he(n.ɵɵinject(ye),n.ɵɵinject(f.CookieService),n.ɵɵinject(de),n.ɵɵinject(n.INJECTOR))},token:he,providedIn:"root"}),he.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],he.ctorParameters=function(){return[{type:ye},{type:f.CookieService},{type:de},{type:n.Injector}]};var fe=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.populateKeys=function(e){this.keys=e},e.prototype.getCurrentPassKey=function(){return this.keys.passKey},e.prototype.getCurrentMasterKey=function(){return this.keys.masterKey},e.prototype.getCurrentRootKey=function(){return this.keys.rootKey},e.prototype.getCurrentPxk=function(){return this.keys.pxk},e.prototype.getCurrentSigPxk=function(){return this.keys.sigPxk},e.prototype.expiresAfter=function(e){return new Date(Date.now()+1e3*e)},e.prototype.persistMasterKey=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(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 R(this,void 0,void 0,(function(){var t;return E(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 q("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 R(this,void 0,void 0,(function(){var t,n;return E(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 q("Could not find masterKey in persisted storage");if(t.id!==e)throw new q("masterKeyId "+t.id+" in persisted storage does not match the one requested "+e);return n=t,[4,ye.asKey(t.jwk)];case 2:n.jwk=r.sent(),this.masterKey=t,r.label=3;case 3:return[2,this.masterKey]}}))}))},e}();fe.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new fe(n.ɵɵinject(te),n.ɵɵinject(he))},token:fe,providedIn:"root"}),fe.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],fe.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:he}]};var ve=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 c.Graph},e.prototype.populateKeys=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return n=(t=this.keyService).populateKeys,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 q("Key graphs does not contain key id: "+e);if(n.type!==t)throw new L({message:"Key with id "+e+" is not of type "+t});return n.data},e.prototype.key=function(e){return this.getNode(e,x.Key)},e.prototype.passKey=function(e){return this.getNode(e,x.PassKey)},e.prototype.addKeys=function(e){var t,n,r,i,a,s;if(e.keys)try{for(var o=A(e.keys),c=o.next();!c.done;c=o.next()){var u=c.value;if(!this.graph.hasNode(u.id)){var p={type:x.Key,data:b.cloneDeep(u)};this.graph.setNode(u.id,p)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}if(e.keyLinks)try{for(var d=A(e.keyLinks),l=d.next();!l.done;l=d.next()){var y=l.value;if(!this.graph.hasEdge(y.wrappingKeyId,y.keyId)){var h={type:U.KeyLink,data:b.cloneDeep(y)};this.graph.setEdge(y.wrappingKeyId,y.keyId,h)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}if(e.passKeyLinks)try{for(var f=A(e.passKeyLinks),v=f.next();!v.done;v=f.next()){var g=v.value;if(!this.graph.hasEdge(g.passKeyId,g.keyId)){h={type:U.PassKeyLink,data:b.cloneDeep(g)};this.graph.setEdge(g.passKeyId,g.keyId,h)}}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}},e.prototype.tracePath=function(e,t){var n=[],r=t;if(!e[r].predecessor)return null;for(;e[r].predecessor;){var i=e[r].predecessor;n.push(this.graph.edge(i,r)),r=i}return n.reverse(),n},e.prototype.getPath=function(e,t){if(!e||"string"!=typeof e)throw new H("Param knownKeyId wrong format: "+e);if(!t||"string"!=typeof t)throw new H("Param keyId wrong format: "+t);var n=C.alg.dijkstra(this.graph,e);return this.tracePath(n,t)},e.prototype.getJwkKey=function(e,t){return R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return n="string"==typeof e?e:null==e?void 0:e.id,this.hasKey(n)||!t?[3,2]:[4,t()];case 1:n=i.sent(),i.label=2;case 2:return(r=this.key(n)).jwk?[2,r]:[2,this.unwrapKey(this.keyService.getCurrentMasterKey().id,n)]}}))}))},e.prototype._unwrapLink=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a;return E(this,(function(s){switch(s.label){case 0:return(r=JSON.parse(t.data.wrappedKey)).signatures?[4,this.encryptionService.verify(e,r)]:[3,2];case 1:return i=s.sent(),[3,4];case 2:return[4,this.encryptionService.decrypt(e,r)];case 3:i=s.sent(),s.label=4;case 4:return a=n,[4,ye.asKey(i)];case 5:return a.jwk=s.sent(),n.task=null,[2]}}))}))},e.prototype._unwrap=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c;return E(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=A(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 R(this,void 0,void 0,(function(){var r,i;return E(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 R(this,void 0,void 0,(function(){var n,r,i;return E(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 R(this,void 0,void 0,(function(){var r;return E(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 R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getJwkKey(e)];case 1:return n=r.sent(),[4,this.encryptionService.decrypt(n,t,{payloadType:"ArrayBuffer"})];case 2:return[2,r.sent()]}}))}))},e.prototype.encryptToString=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(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 R(this,void 0,void 0,(function(){return E(this,(function(n){if(!function(e){return"oct"===e.kty}(t))throw new J("Only allowing wrapping of symmetric keys.");return[2,this.encryptToString(e,t.toJSON(!0))]}))}))},e.prototype.encryptWithNewKey=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(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}();ve.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ve(n.ɵɵinject(de),n.ɵɵinject(fe),n.ɵɵinject(ye))},token:ve,providedIn:"root"}),ve.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ve.ctorParameters=function(){return[{type:de},{type:fe},{type:ye}]};var ge=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 R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query(e).toPromise()];case 1:return j((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e.prototype.mutate=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.apollo.mutate(e).toPromise()];case 1:return j((t=n.sent()).errors),this.addKeys(t),[2,t.data]}}))}))},e}();ge.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ge(n.ɵɵinject(l.Apollo),n.ɵɵinject(ve))},token:ge,providedIn:"root"}),ge.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ge.ctorParameters=function(){return[{type:l.Apollo},{type:ve}]};var me,Se,Ie,Ce,be,ke,Ke,we,Pe,De,Re,Ee,Ae="\n{\n keys {\n id\n }\n keyLinks {\n keyId\n wrappingKeyId\n wrappedKey\n }\n passKeys {\n id\n }\n passKeyLinks {\n keyId\n passKeyId\n wrappedKey\n }\n __typename\n}\n",Oe=y(me||(me=M(["\nfragment KeyGraphFragment on KeyGraphType ","\n"],["\nfragment KeyGraphFragment on KeyGraphType ","\n"])),Ae),Te="keyGraph "+Ae,Me="keyGraph: fetchKeyGraph "+Ae,je=y(Se||(Se=M(["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query File($id: LrRelayIdInput!, $cachedKeyIds: [LrRelayIdInput!]) {\n file(id: $id) {\n id\n keyId\n currentVersion {\n id\n operation\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n id\n state {\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n }\n }\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n id\n plainMeta\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Oe),$e=y(Ie||(Ie=M(["\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"])),Oe),Ne=y(Ce||(Ce=M(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Fe=y(be||(be=M(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),Le=y(ke||(ke=M(["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"],["\n mutation RevertFile($input: RevertFileInput!) {\n revertFile(input: $input) {\n file {\n id\n currentVersion {\n id\n state {\n id\n }\n }\n }\n }\n }\n"]))),xe=y(Ke||(Ke=M(["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveFile(\n $fileId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput!\n $toParentDirectoryId: LrRelayIdInput!\n $wrappingKeyId: LrRelayIdInput!\n $wrappedKey: String!\n ) {\n moveFile(\n input: {\n fileId: $fileId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappingKeyId: $wrappingKeyId\n wrappedKey: $wrappedKey\n }\n ) {\n file {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),Ue=y(we||(we=M(["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"],["\n mutation MoveDirectory(\n $directoryId: LrRelayIdInput!\n $fromParentDirectoryId: LrRelayIdInput\n $toParentDirectoryId: LrRelayIdInput!\n $wrappedKey: String!\n $wrappingKeyId: LrRelayIdInput!\n ) {\n moveDirectory(\n input: {\n directoryId: $directoryId\n fromParentDirectoryId: $fromParentDirectoryId\n toParentDirectoryId: $toParentDirectoryId\n wrappedKey: $wrappedKey\n wrappingKeyId: $wrappingKeyId\n }\n ) {\n directory {\n id\n parentDirectoryLinks {\n edges {\n node {\n parentDirectory {\n plainMeta\n }\n }\n }\n }\n }\n }\n }\n"]))),Je=y(Pe||(Pe=M(['\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 }\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 }\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"])),Oe),_e=y(De||(De=M(["\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"]))),qe=y(Re||(Re=M(["\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"]))),Ge=function(){},Be=function(){},Qe=function(){},Ve=function(e){this.name=e.name,this.title=e.title,this.firstName=e.firstName,this.lastName=e.lastName},We=function(){},Ze=function(){},He=function(){},Ye=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(He),ze=function(){};(Ee=e.PasswordChangeStatus||(e.PasswordChangeStatus={})).InProgress="IN_PROGRESS",Ee.Recovery="RECOVERY";var Xe,et=function(){},tt=function(){};(Xe=e.DirectoryType||(e.DirectoryType={})).Vault="vault",Xe.Category="category",Xe.Record="record";var nt,rt,it,at,st,ot,ct,ut,pt,dt,lt,yt,ht,ft=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Vault,default:!0}}]}),vt=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Category}}]}),gt=JSON.stringify({filter:[{contains:{directoryType:e.DirectoryType.Record}}]}),mt="\naccessRoles {\n role\n method\n inheritedFrom {\n id\n }\n trustedParty {\n id\n }\n isIssuer\n}",St="\ndescendantDirectories(depth: 5, plainMeta: $categoryFilter, archived: false) {\n recordsCount: directoriesCount(plainMeta: $recordFilter, archived: false)\n}\n",It="\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+mt+"\n "+St+"\n",Ct="\n id\n keyId\n plainMeta\n cipherMeta\n",bt=y(nt||(nt=M(["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query GetRootDirectoryIdsQuery($archived: Boolean) {\n rootDirectories(archived: $archived) {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),kt=y(rt||(rt=M(['\nquery GetCategories($vaultFilter: LrJSONFilter!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean, $cachedKeyIds: [LrRelayIdInput!])\n{\n vaults: rootDirectories(plainMeta: $vaultFilter) {\n edges {\n node {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetCategories($vaultFilter: LrJSONFilter!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $archived: Boolean, $cachedKeyIds: [LrRelayIdInput!])\n{\n vaults: rootDirectories(plainMeta: $vaultFilter) {\n edges {\n node {\n childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created", archived: $archived) {\n edges {\n node {\n childDirectory {\n ',"\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),It,Oe),Kt=y(it||(it=M(['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetVaults($plainMetaFilter: LrJSONFilter!, $cachedKeyIds: [LrRelayIdInput!])\n{\n list: rootDirectories(plainMeta: $plainMetaFilter, orderBy: "created") {\n edges {\n node {\n ',"\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),Ct,Oe),wt=y(at||(at=M(['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n sharedItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetTrustedPartyCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n sharedItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),It,mt,Oe),Pt=y(st||(st=M(['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],['\nquery GetMySharedCategoriesQuery($trustedPartyId: LrRelayIdInput!, $categoryFilter: LrJSONFilter!, $recordFilter: LrJSONFilter!, $contentFilter: LrJSONFilter, $cachedKeyIds: [LrRelayIdInput!])\n{\n tp(id: $trustedPartyId) {\n myItems {\n list: directories(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n ','\n }\n }\n }\n records: directories(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),It,mt,Oe),Dt=function(e){return void 0===e&&(e=5),e?"\nparentCategories: parentDirectoryLinks(plainMeta: $categoryFilter) {\n edges {\n node {\n parentDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n "+Dt(e-1)+"\n "+mt+"\n }\n }\n }\n}\n":""},Rt=function(e){return void 0===e&&(e=5),y(ot||(ot=M(["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n"," "],["\nquery GetCategory(\n $id: LrRelayIdInput!,\n $categoryFilter: LrJSONFilter!,\n $recordFilter: LrJSONFilter!,\n $contentFilter: LrJSONFilter,\n $cachedKeyIds: [LrRelayIdInput!]) {\n category: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n ","\n ","\n ",'\n subCategories: childDirectoryLinks(plainMeta: $categoryFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n ','\n }\n }\n }\n }\n records: childDirectoryLinks(plainMeta: $recordFilter, orderBy: "created") {\n edges {\n node {\n childDirectory {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ',"\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n archived\n currentVersion {\n state {\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n"," "])),mt,St,Dt(e),It,mt,Oe)},Et=y(ct||(ct=M(["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query GetCategoryKeyIdQuery(\n $id: LrRelayIdInput!\n $cachedKeyIds: [LrRelayIdInput!]\n ) {\n category: directory(id: $id) {\n keyId\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Oe),At=y(ut||(ut=M(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),Ot=y(pt||(pt=M(["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateCategory(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n vault: directory {\n id\n keyId\n }\n }\n }\n"]))),Tt=y(dt||(dt=M(["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateCategory($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Mt=y(lt||(lt=M(["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"],["\n mutation DeleteCategory($categoryId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $categoryId }) {\n id\n }\n }\n"]))),jt=y(yt||(yt=M(["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation ArchiveDirectory($input: ArchiveDirectoryInput!) {\n archiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),$t=y(ht||(ht=M(["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UnarchiveDirectory($input: UnarchiveDirectoryInput!) {\n unarchiveDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Nt=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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return E(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 R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return E(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 R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y=this;return E(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),t&&t.length?[4,Promise.all(t.map((function(e){return R(y,void 0,void 0,(function(){var t,r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.getCategoryKeyId(e)];case 1:return t=s.sent(),a=(i=JSON).stringify,[4,this.encryptionService.encrypt(t.key,n.toJSON(!0))];case 2:return r=a.apply(i,[s.sent()]),[2,{directoryId:e,wrappingKeyId:t.keyId,wrappedKey:r}]}}))}))})))]:[3,3];case 2:return r=h.sent(),[3,5];case 3:return a=this.keyService.getCurrentRootKey(),c=(o=JSON).stringify,[4,this.encryptionService.encrypt(a.jwk,n.toJSON(!0))];case 4:s=c.apply(o,[h.sent()]),i={wrappingKeyId:a.id,wrappedKey:s},h.label=5;case 5:return u={key:n,rootKey:i,wrappedKeys:r},e?(l=(d=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,7];case 6:return p=l.apply(d,[h.sent()]),[3,8];case 7:p=null,h.label=8;case 8:return[2,(u.cipherMeta=p,u)]}}))}))},e.prototype.wrapContentWithKey=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=c.sent(),[4,this.keyGraph.encryptToString(t,n.toJSON(!0))];case 2:return r=c.sent(),i={key:n,rootKey:{wrappingKeyId:t,wrappedKey:r}},e?(o=(s=JSON).stringify,[4,this.encryptionService.encrypt(n,e)]):[3,4];case 3:return a=o.apply(s,[c.sent()]),[3,5];case 4:a=null,c.label=5;case 5:return[2,(i.cipherMeta=a,i)]}}))}))},e.prototype.getCategoryKeyId=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Et,variables:{id:e}})];case 1:return t=r.sent().category,n={keyId:t.keyId},[4,this.keyGraph.getJwkKey(t.keyId)];case 2:return[2,(n.key=r.sent(),n)]}}))}))},e}();Nt.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Nt(n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(ge),n.ɵɵinject(fe),n.ɵɵinject(ye))},token:Nt,providedIn:"root"}),Nt.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Nt.ctorParameters=function(){return[{type:de},{type:ve},{type:ge},{type:fe},{type:ye}]};var Ft,Lt,xt,Ut,Jt,_t,qt,Gt,Bt,Qt,Vt,Wt,Zt,Ht,Yt,zt,Xt="\nid\npublicData\npublicSearchable\ncipherData\nkey {\n id\n}\n",en=(y(Ft||(Ft=M(["\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}"])),Xt,Te),y(Lt||(Lt=M(['\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}"])),Xt,Te),y(xt||(xt=M(['\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}"])),Xt,Te)),tn=(y(Ut||(Ut=M(["\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}"])),Xt),y(Jt||(Jt=M(["\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}"])),Xt),y(_t||(_t=M(["\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"])))),nn=y(qt||(qt=M(["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"],["\n mutation CreateStripeCheckoutSession(\n $priceId: String!\n $successUrl: String!\n $cancelUrl: String!\n ) {\n createStripeCheckoutSession(\n input: {\n priceId: $priceId\n successUrl: $successUrl\n cancelUrl: $cancelUrl\n }\n ) {\n sessionId\n }\n }\n"]))),rn=y(Gt||(Gt=M(["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"],["\n mutation CreateStripeBillingPortalSession($returnUrl: String!) {\n createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {\n sessionUrl\n }\n }\n"]))),an="\n name\n data\n state\n",sn=y(Bt||(Bt=M(["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"],["\nmutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){\n createUserIssuedPlan(input: $input) {\n userIssuedPlan {\n id\n plan {\n ","\n }\n token\n tokenExpiryTime\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n }\n}"])),an),on=y(Qt||(Qt=M(["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {\n deleteUserIssuedPlan(input: $input) {\n id\n }\n }\n"]))),cn=y(Vt||(Vt=M(["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"],["\nquery UserIssuablePlans {\n userIssuablePlans {\n plan {\n ","\n }\n }\n}\n"])),an),un=y(Wt||(Wt=M(["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"],["\n query UserIssuedPlans {\n userIssuedPlans {\n edges {\n node {\n id\n }\n }\n }\n }\n"]))),pn=y(Zt||(Zt=M(["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"],["\nquery UserIssuedPlan(\n $id: LrRelayIdInput!\n $token: String\n) {\n userIssuedPlan(\n id: $id\n token: $token\n ) {\n id\n plan {\n ","\n }\n planPeriodEnd\n planPeriodEndAfterSeconds\n }\n}\n"])),an),dn=y(Ht||(Ht=M(["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"],["\nmutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){\n associateUserIssuedPlan(input: $input) {\n userPlan {\n id\n plan {\n ","\n }\n periodEnd\n }\n }\n}"])),an),ln=y(Yt||(Yt=M(["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"],["\nquery UserPlans {\n userPlans {\n id\n periodEnd\n plan {\n ","\n }\n }\n}\n"])),an),yn=y(zt||(zt=M(["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"],["\n query Stripe {\n stripe {\n id\n customer\n }\n }\n"])));function hn(e){return e.map((function(e){var t;return Object.assign(Object.assign({},e),{periodEnd:e.periodEnd&&new Date(e.periodEnd),subscription:{id:null===(t=e.stripe)||void 0===t?void 0:t.subscriptionId}})}))}var fn=function(){function e(e){this.lrApollo=e}return e.prototype.createStripeCheckoutSession=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:nn,variables:Object.assign({},e)})];case 1:return[2,{id:t.sent().createStripeCheckoutSession.sessionId}]}}))}))},e.prototype.createStripeBillingPortalSession=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:rn,variables:{returnUrl:e}})];case 1:return[2,{url:t.sent().createStripeBillingPortalSession.sessionUrl}]}}))}))},e.prototype.getUserIssuablePlans=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:cn})];case 1:return[2,e.sent().userIssuablePlans]}}))}))},e.prototype.createUserIssuedPlan=function(e){var t=e.planName,n=e.tokenExpiryTime,r=e.planPeriodEnd,i=e.planPeriodEndAfterSeconds;return R(this,void 0,void 0,(function(){var e,a;return E(this,(function(s){switch(s.label){case 0:if(null==r&&null==i)throw new J('Must specify either "planPeriodEnd" or "planPeriodEndAfterSeconds"');return[4,this.lrApollo.mutate({mutation:sn,variables:{input:{planName:t,tokenExpiryTime:n.toISOString(),planPeriodEnd:r&&r.toISOString(),planPeriodEndAfterSeconds:i}}})];case 1:return e=s.sent().createUserIssuedPlan,a=e.userIssuedPlan,[2,Object.assign(Object.assign({},a),{tokenExpiryTime:new Date(a.tokenExpiryTime),planPeriodEnd:new Date(a.planPeriodEnd)})]}}))}))},e.prototype.deleteUserIssuedPlan=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:on,variables:{input:{id:e}}})];case 1:return[2,t.sent()]}}))}))},e.prototype.getUserIssuedPlans=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:un})];case 1:return[2,e.sent().userIssuedPlans.edges.map((function(e){return e.node}))]}}))}))},e.prototype.getUserIssuedPlan=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:pn,variables:{id:e,token:t}})];case 1:return[2,n.sent().userIssuedPlan]}}))}))},e.prototype.associateUserIssuedPlan=function(e){var t=e.id,n=e.token;return R(this,void 0,void 0,(function(){var e,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:dn,variables:{input:{id:t,token:n}}})];case 1:return e=i.sent().associateUserIssuedPlan,r=e.userPlan,[2,Object.assign(Object.assign({},r),{periodEnd:new Date(r.periodEnd)})]}}))}))},e.prototype.getUserPlans=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:ln})];case 1:return[2,hn(e.sent().userPlans)]}}))}))},e.prototype.getPlanType=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.getStripe()];case 1:return[2,t.sent().customer.subscriptions.data.filter((function(t){return t.id===e}))[0].items.data[0].plan.interval]}}))}))},e.prototype.getStripe=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:yn})];case 1:return[2,e.sent().stripe]}}))}))},e}();fn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new fn(n.ɵɵinject(ge))},token:fn,providedIn:"root"}),fn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],fn.ctorParameters=function(){return[{type:ge}]};var vn=function(){function e(e,t,n,r,i,a,s){this.config=e,this.http=t,this.lrApollo=n,this.keyService=r,this.keyMetaService=i,this.keyGraph=a,this.encryptionService=s}return e.prototype.getPassIdpParams=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.http.get(this.config.authUrl+"users/pass-idp-params/?login_name="+encodeURIComponent(e)).toPromise()];case 1:return[2,t.sent()]}}))}))},e.prototype.getCurrentUser=function(){return R(this,void 0,void 0,(function(){var e,t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:Je})];case 1:return e=a.sent(),t=e.currentUser,n=e.contactCards,r=e.userPlans,i=n.edges.map((function(e){return e.node}))[0],[2,{currentUser:t,contactCard:i,userPlans:hn(r)}]}}))}))},e.prototype.decryptContactCard=function(e){return R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){return E(this,(function(r){switch(r.label){case 0:return[4,e?this.updateContactCard(e,t,n):this.createContactCard(n)];case 1:return r.sent(),[2]}}))}))},e.prototype.prepareContactCardInput=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return E(this,(function(l){switch(l.label){case 0:return[4,this.keyService.getCurrentSigPxk()];case 1:return t=l.sent(),i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 2:return n=i.apply(r,[l.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,"")];case 3:return a=o.apply(s,[l.sent()]),c={name:new Ve(e.name.value)},d=(p=JSON).stringify,[4,this.encryptionService.sign(t.jwk,c)];case 4:return u=d.apply(p,[l.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:u}]}}))}))},e.prototype.createContactCard=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(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:_e,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 R(this,void 0,void 0,(function(){var r,i;return E(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:qe,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 R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){return[2,Promise.all(e.map((function(e){return R(t,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var e;return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:en})];case 1:return e=t.sent(),[4,this.decryptContactCardEdges(e.contactCards.edges)];case 2:return[2,t.sent()]}}))}))},e.prototype.deleteContactCard=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:tn,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteContactCard.id]}}))}))},e.prototype.signOut=function(){return R(this,void 0,void 0,(function(){return E(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}();vn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new vn(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ge),n.ɵɵinject(fe),n.ɵɵinject(Nt),n.ɵɵinject(ve),n.ɵɵinject(de))},token:vn,providedIn:"root"}),vn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],vn.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:ge},{type:fe},{type:Nt},{type:ve},{type:de}]};var gn=function(e){function t(){var t=e.apply(this,T(arguments))||this;return t.isTpPasswordResetUser=!1,t}return w(t,e),t}(v.CognitoUser);(e.FeatureAction||(e.FeatureAction={})).ACCESS="access";var mn,Sn=function(){},In=function(){},Cn=function(){},bn=function(){};function kn(e,t){var n=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));if(n.length>1)throw new G("There can be only one '"+t+"' operation, instead there are "+n.length);return n[0]}function Kn(e){return kn(e,"query")}function wn(e){return kn(e,"mutation")}function Pn(e){return e.definitions.filter((function(e){return"FragmentDefinition"===e.kind}))}function Dn(e){return{kind:"Name",value:e}}function Rn(e){var t;return(null===(t=e.alias)||void 0===t?void 0:t.value)||e.name.value}function En(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return y.apply(void 0,T([e],t))}(mn=e.RecoveryStatus||(e.RecoveryStatus={})).NONE="none",mn.NEW_PASSWORD="new-password",mn.OLD_PASSWORD="old-password";var An,On,Tn,Mn,jn,$n,Nn=y(An||(An=M(["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"],["\n mutation {\n passwordChangeRequest(input: {}) {\n challenge\n }\n }\n"]))),Fn=y(On||(On=M(["\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"]))),Ln=y(Tn||(Tn=M(["\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=En(Mn||(Mn=M(["\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"])));En(jn||(jn=M(["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"],["\nmutation ClearSessionEncryptionKeyMutation {\n clearSessionEncryptionKey(input: {}) {\n sessionEncryptionKey\n }\n}\n"])));($n=e.Config||(e.Config={}))[$n.TIMEOUT=.01]="TIMEOUT",$n[$n.IDLE=1200]="IDLE",$n[$n.KEEP_ALIVE_INTERVAL=60]="KEEP_ALIVE_INTERVAL";var Un=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 R(this,void 0,void 0,(function(){var n,r=this;return E(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 J("Minimum value for IdleService.init({ timeoutSec }) is 0.01");return this.onTimeout=t.onTimeout,this.onKeepalive=t.onKeepalive,this.idle.setIdle(t.idleSec),this.idle.setTimeout(t.timeoutSec),this.idle.setInterrupts(g.DEFAULT_INTERRUPTSOURCES),this.idle.onIdleEnd.subscribe((function(){return console.log("Idle stopped")})),this.idle.onIdleStart.subscribe((function(){return console.log("Idle started")})),this.idle.onTimeout.subscribe((function(){return R(r,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return console.log("Idle timed out"),this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())];case 1:return e.sent(),[2]}}))}))})),this.idle.onTimeoutWarning.subscribe((function(e){return console.log("Will timeout in "+e+" seconds!")})),this.keepalive.interval(t.keepAliveIntervalSec),console.log("Keep alive interval set at: "+e.Config.KEEP_ALIVE_INTERVAL+" seconds"),this.keepalive.onPing.subscribe((function(){return r.onPing()})),(n=localStorage.getItem(this.IDLE_EXPIRY_KEY))&&parseInt(n,10)+1e3*this.idle.getTimeout()<Date.now()?(this.reset(),[4,Promise.resolve(this.onTimeout&&this.onTimeout())]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.keepalivePost=function(){return R(this,void 0,void 0,(function(){var e;return E(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=t.sent(),[4,this.http.post(this.config.authUrl+"auth/keepalive/",null,{withCredentials:!0,headers:{Authorization:"Bearer "+e.getSignInUserSession().getAccessToken().getJwtToken()}}).toPromise()];case 2:return[2,{keepaliveResult:t.sent(),expiresAfterSeconds:this.idle.getIdle()+this.idle.getTimeout()+this.keepalive.interval()}]}}))}))},t.prototype.persistMasterKey=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.keepalivePost()];case 1:return t=n.sent().expiresAfterSeconds,[4,this.keyService.persistMasterKey(e,t)];case 2:return n.sent(),console.log("setMasterKey() done"),[2]}}))}))},t.prototype.onPing=function(){return R(this,void 0,void 0,(function(){var e;return E(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 R(this,void 0,void 0,(function(){return E(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}();Un.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Un(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(g.Idle),n.ɵɵinject(m.Keepalive),n.ɵɵinject(fe),n.ɵɵinject(d.AuthClass))},token:Un,providedIn:"root"}),Un.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Un.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:g.Idle},{type:m.Keepalive},{type:fe},{type:d.AuthClass}]};var Jn=h,_n=function(){},qn=function(){function e(e,t,n,r,i,a,s,o,c,u){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.idleService=u,this.CLIENT_NONCE_LENGTH=32}return e.prototype.checkPassword=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return t=this.passwordStrength(e).years,n={length:e.length,timeToCrack:Jn.duration({years:t})},[4,this.getExposureCount(e)];case 1:return[2,(n.passwordExposed=r.sent(),n)]}}))}))},e.prototype.getExposureCount=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(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 R(this,void 0,void 0,(function(){var t,n,r,i,a,s;return E(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 R(this,void 0,void 0,(function(){var e,t,n,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.getChangePasswordConfig()];case 1:return e=i.sent(),t=Jn(e.authTime),n=Jn(e.serverTime),r=Jn.duration(n.diff(t)),r.asSeconds()>e.maxAuthAgeSeconds?[2,!0]:[2,!1]}}))}))},e.prototype.changePassword=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d;return E(this,(function(l){switch(l.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return n=l.sent(),[4,this.profileService.getCurrentUser()];case 2:return r=l.sent().currentUser,[4,this.verifyPassword(e,r)];case 3:return i=l.sent(),a=i.passIdp,s=i.signedChallenge,[4,this.createPassKeyBundle(t)];case 4:return o=l.sent(),[4,this.keyGraph.getKey(r.currentUserKey.masterKey.id)];case 5:return c=l.sent(),[4,this.encryptionService.encrypt(o.passKey,c.jwk.toJSON(!0))];case 6:return u=l.sent(),[4,this.changePasswordMutation(s,r.currentUserKey.masterKey.id,u,o)];case 7:return p=l.sent(),d=p.token,p.newPassKeyId,[4,this.auth.changePassword(n,this.getPassIdpString(a),this.getPassIdpString(o.passIdp))];case 8:return l.sent(),[4,this.changePasswordComplete(n.getSignInUserSession().getAccessToken().getJwtToken(),!0,d)];case 9:return l.sent(),[2]}}))}))},e.prototype.changePasswordComplete=function(e,t,n){return void 0===n&&(n=null),R(this,void 0,void 0,(function(){return E(this,(function(r){return[2,this.http.post(this.config.authUrl+"users/password-change-complete/",Object.assign({use_new_password:t},n&&{token:n}),{headers:{Authorization:"Bearer "+e}}).toPromise()]}))}))},e.prototype.getVerifierPrK=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(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,ye.asKey(n)];case 2:throw r.sent(),new Z("Wrong current password");case 3:return[2]}}))}))},e.prototype.verifyPassword=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return[4,this.apollo.mutate({mutation:Nn,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 R(this,void 0,void 0,(function(){var i;return E(this,(function(a){switch(a.label){case 0:return[4,this.apollo.mutate({mutation:Fn,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 R(this,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:return[4,this.apollo.query({query:Ln})];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}();qn.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new qn(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ge),n.ɵɵinject(d.AuthClass),n.ɵɵinject(vn),n.ɵɵinject(ye),n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(le),n.ɵɵinject(Un))},token:qn,providedIn:"root"}),qn.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],qn.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:ge},{type:d.AuthClass},{type:vn},{type:ye},{type:de},{type:ve},{type:le},{type:Un}]};var Gn,Bn,Qn,Vn,Wn,Zn,Hn,Yn,zn,Xn,er,tr,nr,rr,ir=En(Gn||(Gn=M(["\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}"]))),ar=En(Bn||(Bn=M(["\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"])),ir),sr=En(Qn||(Qn=M(["\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"])),ir),or=En(Vn||(Vn=M(["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"],["\nmutation CancelTpPasswordResetRequestMutation {\n cancelTpPasswordResetRequest(input: {}) {\n id\n }\n}"]))),cr=En(Wn||(Wn=M(["\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}"]))),ur=En(Zn||(Zn=M(["\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}"]))),pr=En(Hn||(Hn=M(["\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}"]))),dr=En(Yn||(Yn=M(["\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}"]))),lr=En(zn||(zn=M(["\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}"]))),yr=En(Xn||(Xn=M(["\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 }\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 }\n}"]))),hr=En(er||(er=M(["\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}"]))),fr=En(tr||(tr=M(["\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}"]))),vr=En(nr||(nr=M(["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"],["\nmutation DeleteTpPasswordResetMutation {\n deleteTpPasswordReset(input: {}) {\n id\n }\n}"]))),gr=En(rr||(rr=M(["\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}"])));function mr(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 Sr(e,t){var n,r,i={};try{for(var a=A(Object.keys(e).entries()),s=a.next();!s.done;s=a.next()){var o=O(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 Ir(e,t){var n=mr(Object.entries(e).map((function(n){var r=O(n,2),i=r[0],a=r[1];return t(a,i,e)})));return n.then?n.then((function(t){return Sr(e,t)})):Sr(e,n)}var Cr=["constructor","ngOnChanges","ngOnInit","ngDoCheck","ngAfterContentInit","ngAfterContentChecked","ngAfterViewInit","ngAfterViewChecked","ngOnDestroy"];function br(e){var t=e.ngZoneName,n=e.exceptLastPromise,r=void 0===n||n,i=e.excludeMethods,a=void 0===i?[]:i,s=e.patchSetters,o=void 0===s||s;return function(e){function n(n,i){var a=this;if(!this[t])throw new G("RunOutsideAngular decorator requires that "+e.name+" inject NgZone as "+t);var s=this[t].runOutsideAngular((function(){return n.apply(a,i)}));return r&&(null==s?void 0:s.then)?Promise.resolve(s):s}return a=T(a,Cr),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 kr={hasKeys:!0};function Kr(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s=this;return E(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 R(s,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return r=(n=Object).assign,i=[Object.assign({},e)],a={},[4,t(e.node)];case 1:return[2,r.apply(n,i.concat([(a.node=s.sent(),a)]))]}}))}))})))];case 1:return[2,r.apply(n,i.concat([(a.edges=o.sent(),a)]))]}}))}))}function wr(e,t){return Object.assign(Object.assign({},e),{path:T(e.path,[t])})}e.CommonProcessorsService=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.series=function(e){var t=this;return function(n){var r=n.field,i=n.context,a=n.options;return R(t,void 0,void 0,(function(){var t,n,s,o,c;return E(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),t=A(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 R(t,void 0,void 0,(function(){var t,n,i,a,s,u;return E(this,(function(p){switch(p.label){case 0:return n=e.field,i=e.context,e.options.hasKeys?!(a=n[r])||c in n?[2,n]:o?[4,o(e)]:[3,2]:[2,n];case 1:return u=p.sent(),[3,3];case 2:u=n.keyId||(null===(t=n.key)||void 0===t?void 0:t.id),p.label=3;case 3:if(!(s=u))throw new G("Query response does not contain "+(o?"key-id":"keyId or key.id")+" field: "+i.path.join("."));return[2,this.keyGraph.decryptFromString(s,a).then((function(e){var t;return Object.assign(Object.assign({},n),((t={})[c]=e,t))}))]}}))}))}},e}(),e.CommonProcessorsService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.CommonProcessorsService(n.ɵɵinject(n.NgZone),n.ɵɵinject(ve))},token:e.CommonProcessorsService,providedIn:"root"}),e.CommonProcessorsService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.CommonProcessorsService.ctorParameters=function(){return[{type:n.NgZone},{type:ve}]},e.CommonProcessorsService=D([br({ngZoneName:"ngZone"})],e.CommonProcessorsService),e.ɵi=function(){function e(e,t){this.ngZone=e,this.keyGraph=t}return e.prototype.processTpPasswordResetUserNode=function(e){var t;return R(this,void 0,void 0,(function(){var n,r,i,a,s=this;return E(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 R(this,void 0,void 0,(function(){var n,r;return E(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 R(e,void 0,void 0,(function(){var e,t;return E(this,(function(r){switch(r.label){case 0:if(e=Object.assign({},n),!n.assembly)return[3,2];if(null==n.applied)throw new W('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 R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l=this;return E(this,(function(y){switch(y.label){case 0:return n=e.subjectKey,r=e.assemblyKey,i=e.assemblyCipherData,a=e.subAssemblies,c=(o=Object).assign,u=[Object.assign({},e)],p={},[4,Kr(a,(function(e){return l.processTpSubAssemblyNode(e,n.id,t)}))];case 1:return s=c.apply(o,u.concat([(p.subAssemblies=y.sent(),p)])),t?[3,3]:i?(d=s,[4,this.keyGraph.decryptFromString(r.id,i)]):[3,3];case 2:d.assemblyCipherDataClearJson=y.sent(),y.label=3;case 3:return[2,s]}}))}))},e.prototype.processTpSubAssemblyNode=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d=this;return E(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,Kr(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 R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,e]}))}))},e}(),e.ɵi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵi(n.ɵɵinject(n.NgZone),n.ɵɵinject(ve))},token:e.ɵi,providedIn:"root"}),e.ɵi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵi.ctorParameters=function(){return[{type:n.NgZone},{type:ve}]},e.ɵi=D([br({ngZoneName:"ngZone"})],e.ɵi),e.QueryProcessorService=function(){function e(e,t,n,r){this.ngZone=e,this.keyService=t,this.common=n,this.tpprProcessor=r,this.TYPENAME="__typename",this.processors={},this.registerProcessor("DirectoryNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("FileStateNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeDecryptionProcessor({cipherFieldName:"cipherMeta"})])),this.registerProcessor("ContactCardNode",n.makeDecryptionProcessor({cipherFieldName:"cipherData"})),this.registerProcessor("SharedContactCardNode",n.series([n.makeJsonParseProcessor({plainFieldName:"ownerPlainData"}),n.makeDecryptionProcessor({cipherFieldName:"ownerCipherData",getKeyId:function(e){return e.field.ownerKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"receiverCipherData",getKeyId:function(e){return e.field.receiverKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpPasswordResetNode",this.tpprProcessor.makeTpPasswordResetNodeProcessor()),this.registerProcessor("SharedTpClaimApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyAsApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioReceiverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioReceiverDirectoryNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioApproverAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"assemblyCipherData",getKeyId:function(e){return e.field.assemblyKey.id}})])),this.registerProcessor("ScenarioApproverSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("ScenarioApproverNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherApprovalData",getKeyId:function(e){return e.field.sharedKey.id}}),n.makeDecryptionProcessor({cipherFieldName:"sharedCipherPartialAssemblyKey",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("ScenarioClaimantNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"sharedCipherData",getKeyId:function(e){return e.field.sharedKey.id}})])),this.registerProcessor("TpAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("TpSubAssemblyNode",n.series([n.makeDecryptionProcessor({cipherFieldName:"subjectCipherData",getKeyId:function(e){return e.field.subjectKey.id}})])),this.registerProcessor("NotificationNode",n.series([n.makeJsonParseProcessor({plainFieldName:"plainMeta"}),n.makeJsonParseProcessor({plainFieldName:"plainData"})]))}return e.prototype.processQuery=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){return t=Object.assign(Object.assign({},kr),t),[2,Ir(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 R(this,void 0,void 0,(function(){var e,i,a,s=this;return E(this,(function(o){if(null==t?void 0:t.then)throw new G("processField() should not receive thenable.");return null==t?[2,null]:(e={field:t,context:Object.assign(Object.assign({},n),{processChildren:!0}),options:r},t[this.TYPENAME]?((i=this.processors[t[this.TYPENAME]])&&(t=i(e)),a=function(e){return n.processChildren&&null!==e&&"object"==typeof e?Ir(e,(function(e,t){return s.processField({field:e,context:wr(n,t),options:r})})):e},t=t.then?t.then((function(e){return a(e)})):a(t)):n.processChildren&&Array.isArray(t)&&(t=mr(t.map((function(e,t){return s.processField({field:e,context:wr(n,t.toString()),options:r})})))),[2,t])}))}))},e.prototype.registerProcessor=function(e,t){if(this.processors[e])throw new G("Processor for field "+e+" already exists.");this.processors[e]=t},e}(),e.QueryProcessorService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.QueryProcessorService(n.ɵɵinject(n.NgZone),n.ɵɵinject(fe),n.ɵɵinject(e.CommonProcessorsService),n.ɵɵinject(e.ɵi))},token:e.QueryProcessorService,providedIn:"root"}),e.QueryProcessorService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.QueryProcessorService.ctorParameters=function(){return[{type:n.NgZone},{type:fe},{type:e.CommonProcessorsService},{type:e.ɵi}]},e.QueryProcessorService=D([br({ngZoneName:"ngZone"})],e.QueryProcessorService);var Pr,Dr,Rr,Er=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}(),Ar=Kn(y(Pr||(Pr=M(["\n query {\n ...FragmentName\n }\n"],["\n query {\n ...FragmentName\n }\n"])))).selectionSet.selections[0],Or=function(){function e(){this._executed=!1,this.deferredPromise=new Er}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}(),Tr=function(e){function t(t){var n=e.call(this)||this;return n.mutation=t.mutation,n.variables=t.variables,n}return w(t,e),t.prototype.select=function(e){var n=u.cloneDeep(this.mutation),r=wn(n),i={};Pn(e).forEach((function(e){i[e.name.value]=e}));return r.selectionSet.selections.forEach((function(e){"Field"===e.kind&&function(e){var t=e,n=Rn(t);i[n]&&(t.selectionSet.selections=[Object.assign(Object.assign({},Ar),{name:Dn(n)})])}(e)})),new t({mutation:Object.assign(Object.assign({},n),{definitions:T(n.definitions.filter((function(e){return"FragmentDefinition"!==e.kind})),e.definitions)}),variables:this.variables})},t}(Or),Mr={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"lrMergedMutation"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[]}}]},jr=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 w(t,e),t.create=function(e){return new t(e)},t.prototype.getDescendants=function(){var e=new Set,n=function(t){if(e.has(t))throw new G("Classes that are derived from LrMutationBase can not be used more than once in a merged mutation.");e.add(t)};return this.lrMutations.forEach((function(e){if(e instanceof Tr)n(e);else{if(!(e instanceof t))throw new Y("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:Dn(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:Dn(t+e.value.name.value)})})},t.prototype.renameField=function(e,t){var n=this;if("Field"!==e.kind)return e;var r=t+Rn(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:Dn(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":var r=n.renameField(e,t);return n.processSelection(r,t);default:return e}}))},t.prototype.renameFragmentDefinition=function(e,t){var n=Object.assign(Object.assign({},e),{name:Dn(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,p=s.lrMutationData,d=p.mutation,l=p.variables,y=wn(d),h="item"+o+"_";y.name&&(h+=y.name.value+"_"),a.push(h),t=T(t,e.renameVariableDefinitions(y.variableDefinitions,h)),n=T(n,e.renameSelections(y.selectionSet.selections,h));try{for(var f=A(Object.keys(l)),v=f.next();!v.done;v=f.next()){var g=v.value;r[h+g]=l[g]}}catch(e){c={error:e}}finally{try{v&&!v.done&&(u=f.return)&&u.call(f)}finally{if(c)throw c.error}}var m=Pn(d);i=T(i,e.renameFragmentDefinitions(m,h))}));var s=u.cloneDeep(Mr),o=wn(s);return o.selectionSet.selections=n,o.variableDefinitions=t,s.definitions=T(s.definitions,i),{mutation:s,variables:r,prefixes:a}},t}(Or),$r=Kn(y(Dr||(Dr=M(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Te)).selectionSet.selections[0],Nr=Kn(y(Rr||(Rr=M(["\nquery {\n ","\n}\n"],["\nquery {\n ","\n}\n"])),Me)).selectionSet.selections[0];e.ɵh=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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return e=u.cloneDeep(e),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=Kn(e.query)).selectionSet.selections=T(t.selectionSet.selections,[$r])),[4,this.apollo.query(e).toPromise()];case 1:return n=r.sent(),this.stats.queryCount++,j(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 R(this,void 0,void 0,(function(){return E(this,(function(n){if(null==t?void 0:t.variables)throw new Y('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 R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return e=Object.assign(Object.assign({},e),{mutation:u.cloneDeep(e.mutation)}),this.isIncludeKeyGraph(e.includeKeyGraph)&&((t=wn(e.mutation)).selectionSet.selections=T(t.selectionSet.selections,[Nr])),e.mutation=y(S.print(e.mutation)),[4,this.apollo.mutate(e).toPromise()];case 1:return n=r.sent(),this.stats.mutationCount++,j(n.errors),this.addKeys(n),[4,this.queryProcessor.processQuery(n.data,e.processorOptions)];case 2:return[2,r.sent()]}}))}))},e.prototype.statsSnapshot=function(){return u.cloneDeep(this.stats)},e.prototype.addKeys=function(e){e.data.keyGraph&&(this.keyGraph.addKeys(e.data.keyGraph),delete e.data.keyGraph)},e.prototype.isIncludeKeyGraph=function(e){return null==e},e.prototype.lrMutate=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return e instanceof Array?(i=(r=jr).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.ɵh.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵh(n.ɵɵinject(n.NgZone),n.ɵɵinject(l.Apollo),n.ɵɵinject(ve),n.ɵɵinject(e.QueryProcessorService))},token:e.ɵh,providedIn:"root"}),e.ɵh.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵh.ctorParameters=function(){return[{type:n.NgZone},{type:l.Apollo},{type:ve},{type:e.QueryProcessorService}]},e.ɵh=D([br({ngZoneName:"ngZone"})],e.ɵh);var Fr,Lr,xr,Ur,Jr,_r,qr,Gr,Br,Qr,Vr,Wr,Zr,Hr,Yr,zr=function(){function t(t){this.lrGraphQL=t.get(e.ɵh)}return t.prototype.mutate=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.lrGraphQL.lrMutate(e,t)]}))}))},t.prototype.query=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.lrGraphQL.query(e)]}))}))},t}();function Xr(e){return e.edges.map((function(e){return e.node}))}(e.UserDeleteState||(e.UserDeleteState={})).REQUESTED="REQUESTED",(Fr=e.PlanState||(e.PlanState={})).ENABLED="ENABLED",Fr.DISABLED="DISABLED",(Lr=e.AccessRoleChoice||(e.AccessRoleChoice={})).READER="READER",Lr.WRITER="WRITER",Lr.ADMIN="ADMIN",Lr.DENY="DENY",Lr.OWNER="OWNER",(xr=e.AccessRoleMethod||(e.AccessRoleMethod={})).inherited="inherited",xr.direct="direct",(Ur=e.FileOperationField||(e.FileOperationField={})).CREATE="CREATE",Ur.READ="READ",Ur.UPDATE="UPDATE",Ur.REVERT="REVERT",Ur.DELETE="DELETE",(Jr=e.KeyExchangeOtkState||(e.KeyExchangeOtkState={})).OTK_INITIATED="OTK_INITIATED",Jr.OTK_ACCEPTED="OTK_ACCEPTED",Jr.OTK_COMPLETED="OTK_COMPLETED",(_r=e.KeyExchangeState||(e.KeyExchangeState={})).IN_PROGRESS="IN_PROGRESS",_r.COMPLETED="COMPLETED",_r.DECLINED="DECLINED",_r.CANCELLED="CANCELLED",_r.DELETED="DELETED",(e.KeyExchangeMode||(e.KeyExchangeMode={})).OTK="OTK",(qr=e.TpAssemblyState||(e.TpAssemblyState={})).DISABLED="DISABLED",qr.ENABLED="ENABLED",qr.CLAIMED="CLAIMED",qr.APPROVED="APPROVED",qr.REJECTED="REJECTED",qr.EXPIRED="EXPIRED",qr.CANCELLED="CANCELLED",qr.RESET="RESET",(Gr=e.TpClaimState||(e.TpClaimState={})).CLAIMED="CLAIMED",Gr.APPROVED="APPROVED",Gr.REJECTED="REJECTED",Gr.EXPIRED="EXPIRED",Gr.CANCELLED="CANCELLED",Gr.RESET="RESET",(Br=e.TpClaimApproverState||(e.TpClaimApproverState={})).CLAIMED="CLAIMED",Br.APPROVED="APPROVED",Br.REJECTED="REJECTED",(Qr=e.LockState||(e.LockState={})).UNLOCKED="UNLOCKED",Qr.MUTEX_LOCKED="MUTEX_LOCKED",(Vr=e.ScenarioState||(e.ScenarioState={})).DISABLED="DISABLED",Vr.ENABLED="ENABLED",Vr.CLAIMED="CLAIMED",Vr.APPROVED="APPROVED",(Wr=e.ClaimState||(e.ClaimState={})).CLAIMED="CLAIMED",Wr.EXPIRED="EXPIRED",Wr.APPROVED="APPROVED",Wr.REJECTED="REJECTED",Wr.CANCELLED="CANCELLED",Wr.RESET="RESET",(Zr=e.ClaimApproverState||(e.ClaimApproverState={})).CLAIMED="CLAIMED",Zr.APPROVED="APPROVED",Zr.REJECTED="REJECTED",(Hr=e.ScenarioLastClaimState||(e.ScenarioLastClaimState={})).CLAIMED="CLAIMED",Hr.APPROVED="APPROVED",Hr.REJECTED="REJECTED",Hr.EXPIRED="EXPIRED",Hr.CANCELLED="CANCELLED",Hr.RESET="RESET",(Yr=e.LinkTypeField||(e.LinkTypeField={})).HARD="HARD",Yr.SOFT="SOFT";var ei=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},ti=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=Array()},e.prototype.addShare=function(e){this.shares.push(e)},e}(),ni=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=new Array},e.prototype.addSubAssembly=function(e){this.subAssemblies.push(e)},e}(),ri=(function(){function e(e){this.subAssemblyIndex=e,this.clearShares()}e.prototype.clearShares=function(){this.shares=new Array},e.prototype.addShare=function(e){this.shares.push(e)}}(),function(){function e(){this.clearSubQuora()}e.prototype.clearSubQuora=function(){this.subQuora=new Array},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 R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p;return E(this,(function(d){switch(d.label){case 0:r=btoa(e),r=I.Slip39Helper.slip39EncodeHex(r),i=[];try{for(a=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,I.Slip39.fromArray(r,{passphrase:t,threshold:n.threshold,groups:i,title:""})];case 1:return c=d.sent(),n.subAssemblies.forEach((function(e,t){e.clearShares();for(var n=0;n<e.size;n++){var r="r/"+t.toString().padStart(2,"0")+"/"+n.toString().padStart(2,"0"),i=c.fromPath(r).mnemonics[0],a=new ei(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=A(e),c=o.next();!c.done;c=o.next()){var u=c.value,p=I.Slip39Helper.decodeMnemonic(u);if(a&&a!==p.groupThreshold)throw new Error("groupThreshold is different in mnemonics");a=p.groupThreshold,null==(f=s.get(p.groupIndex))&&(f={memberThreshold:p.memberThreshold,members:[]},s.set(p.groupIndex,f)),f.members.push({mnemonic:u,decoded:p})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=[],l=0;try{for(var y=A(s.values()),h=y.next();!h.done;h=y.next()){var f;if(!((f=h.value).members.length<f.memberThreshold)&&(f.members.slice(0,f.memberThreshold).forEach((function(e){d.push(e.mnemonic)})),++l>=a))break}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}return d},e.prototype.recoverSecret=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return e=this.minimalSet(e),[4,I.Slip39.recoverSecret(e,t)];case 1:return n=i.sent(),r=I.Slip39Helper.slip39DecodeHex(n),[2,atob(r)]}}))}))},e}());ri.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ri},token:ri,providedIn:"root"}),ri.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ri.ctorParameters=function(){return[]};var ii,ai="lifeready",si=En(ii||(ii=M(["\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}"]))),oi=function(){function t(t){this.keyFactory=t.get(ye),this.keyService=t.get(fe),this.encryptionService=t.get(de),this.keyGraph=t.get(ve),this.slip39Service=t.get(ri),this.lrGraphQl=t.get(e.ɵh)}return t.prototype.recoverAssemblyKey=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(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,ye.asKey(Object.assign(Object.assign({},t),{k:r}))];case 2:return[2,i.sent()]}}))}))},t.prototype.prepareTpWrappingKey=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.keyGraph.getKey(e.wrappingKeyId)]}))}))},t.prototype.prepareAssembly=function(e){var t=e.subjectKey,n=e.rootKey;return R(this,void 0,void 0,(function(){var e,r,i,a,s,o,c,u,p;return E(this,(function(d){switch(d.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=d.sent(),console.log("prepareAssembly assemblyKey",e),r=e.toJSON(!0),i=r.k,a=P(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 R(this,void 0,void 0,(function(){var e=this;return E(this,(function(a){return[2,Promise.all(t.map((function(t,a){return R(e,void 0,void 0,(function(){var e,s,o=this;return E(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 R(o,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){var e=this;return E(this,(function(s){if(r.length!==t.length)throw new J("The slipSubAssemblies must be the same length as the input");return[2,Promise.all(t.map((function(t,s){return R(e,void 0,void 0,(function(){var e,o,c,u,p,d,l=this;return E(this,(function(y){switch(y.label){case 0:return[4,this.encryptionService.encryptToString(n,t.subjectCipherDataClearJson||"")];case 1:return e=y.sent(),o=a.edges.find((function(e){return e.node.id===t.id})).node,c=[],u=[],t.approverTps.forEach((function(e){var t,n=null===(t=o.approvers.edges.find((function(t){return t.node.tp.id===e.tpId})))||void 0===t?void 0:t.node;n?u.push({tp:e,approverId:n.id}):c.push({tp:e})})),p=r[s],d={subAssemblyId:t.id,singleReject:t.singleReject,quorum:t.quorum,subjectCipherData:e},[4,Promise.all(c.map((function(e,t){var r=e.tp;return R(l,void 0,void 0,(function(){return E(this,(function(e){return[2,this.prepareApprover({tp:r,approverIndex:t,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 2:return d.createApprovers=y.sent(),[4,Promise.all(u.map((function(e,t){var r=e.tp,a=e.approverId;return R(l,void 0,void 0,(function(){return E(this,(function(e){return[2,this.prepareApprover({approverId:a,tp:r,approverIndex:t+c.length,slipSubAssembly:p,assemblyKeyParams:i,subjectKey:n})]}))}))})))];case 3:return[2,(d.updateApprovers=y.sent(),d)]}}))}))})))]}))}))},t.prototype.fillWrappingKeyId=function(e,t){var n=this;e.forEach((function(e){e.approverTps.forEach((function(e){if(!e.wrappingKeyId){var r=t.find((function(t){return t.id===e.tpId}));e.wrappingKeyId=n.getTpWrappingKeyId(r)}}))}))},t.prototype.getInputApprovers=function(e){var t=[];return e.forEach((function(e){e.approverTps.forEach((function(e){t.push(e.tpId)}))})),t},t.prototype.prepareCreate=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y,h;return E(this,(function(f){switch(f.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=f.sent(),[4,this.keyFactory.createKey()];case 2:return n=f.sent(),[4,this.keyGraph.wrapKey(t,n)];case 3:return r=f.sent(),[4,this.prepareAssembly({rootKey:t.jwk,subjectKey:n})];case 4:return i=f.sent(),a=i.assemblyKey,s=i.rawAssemblyKey,o=i.assemblyKeyParams,c=P(i,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),[4,this.prepareSlip39(e.createSubAssemblies,e.quorum,s)];case 5:return u=f.sent(),p=this.getInputApprovers(e.createSubAssemblies),l=Xr,[4,this.lrGraphQl.query({query:si,variables:{ids:p}})];case 6: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 7:return y=f.sent(),[4,this.encryptionService.encryptToString(n,e.subjectCipherDataClearJson||"")];case 8:return h=f.sent(),[2,{assemblyKey:a,mutationInput:Object.assign(Object.assign({},c),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:h,createSubAssemblies:y,rootKeyId:t.id,rootKeyWrappedSubjectKey:r})}]}}))}))},t.prototype.getAssemblyApprovers=function(e){var t=[];return Xr(e.subAssemblies).map((function(e){Xr(e.approvers).forEach((function(e){return t.push(e.tp.id)}))})),t},t.prototype.prepareUpdate=function(e,t){var n;return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C;return E(this,(function(b){switch(b.label){case 0:if(e=Object.assign({createSubAssemblies:[]},e),r=e.createSubAssemblies||[],i=e.updateSubAssemblies||[],a=e.deleteSubAssemblies||[],0===r.length&&0===i.length&&0===a.length)throw new J("Must specify at least one of: [createSubAssemblies, updateSubAssemblies, deleteSubAssemblies]");return[4,this.keyService.getCurrentRootKey()];case 1:return s=b.sent(),[4,this.keyGraph.getKey(t.subjectKey.id)];case 2:return o=b.sent(),[4,this.prepareAssembly({rootKey:s.jwk,subjectKey:o.jwk})];case 3:return c=b.sent(),u=c.assemblyKey,p=c.rawAssemblyKey,d=c.assemblyKeyParams,l=P(c,["assemblyKey","rawAssemblyKey","assemblyKeyParams"]),y=this.getAssemblyApprovers(t).concat(this.getInputApprovers(r),this.getInputApprovers(i)),f=Xr,[4,this.lrGraphQl.query({query:si,variables:{ids:y}})];case 4:h=f.apply(void 0,[b.sent().tps]),Xr(t.subAssemblies).forEach((function(e){if(!a.includes(e.id)&&!i.some((function(t){return t.id===e.id}))){var t=Xr(e.approvers).map((function(e){return{tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,sharedCipherApprovalDataClearJson:e.sharedCipherApprovalDataClearJson}}));i.push({id:e.id,quorum:e.quorum,singleReject:e.singleReject,approverTps:t,subjectCipherDataClearJson:e.subjectCipherDataClearJson})}})),this.fillWrappingKeyId(r,h),this.fillWrappingKeyId(i,h),b.label=5;case 5:return b.trys.push([5,7,,8]),[4,this.prepareSlip39((r||[]).concat(i||[]),e.quorum,p)];case 6:return v=b.sent(),[3,8];case 7:return g=b.sent(),console.log("Error while creating slip assembly",g),[3,8];case 8:return m={assemblyKeyParams:d,subjectKey:o.jwk},[4,this.prepareCreateSubAssemblies(Object.assign(Object.assign({},m),{input:r,slipSubAssemblies:v.subAssemblies.slice(0,r.length)}))];case 9:return S=b.sent(),[4,this.prepareUpdateSubAssemblies(Object.assign(Object.assign({},m),{input:i,slipSubAssemblies:v.subAssemblies.slice(r.length),subAssemblies:t.subAssemblies}))];case 10:return I=b.sent(),[4,this.encryptionService.encryptToString(o.jwk,null!==(n=e.subjectCipherDataClearJson)&&void 0!==n?n:t.subjectCipherDataClearJson)];case 11:return C=b.sent(),[2,{assemblyKey:u,mutationInput:Object.assign(Object.assign({},l),{singleReject:e.singleReject,quorum:e.quorum,subjectCipherData:C,subjectKeyId:o.id,createSubAssemblies:S,updateSubAssemblies:I})}]}}))}))},t.prototype.prepareApprover=function(e){var t=e.approverId,n=e.tp,r=e.approverIndex,i=e.slipSubAssembly,a=e.assemblyKeyParams,s=e.subjectKey;return R(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h;return E(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},console.log("partialAssemblyKey",d),[4,this.encryptionService.encryptToString(o,n.sharedCipherDataClearJson||"")];case 5:return l=f.sent(),[4,this.encryptionService.encryptToString(o,n.sharedCipherApprovalDataClearJson||"")];case 6:return y=f.sent(),[4,this.encryptionService.encryptToString(o,d)];case 7:return h=f.sent(),[2,{tpWrappingKeyId:e.id,tpWrappedSharedKey:c,subjectKeyWrappedSharedKey:u,sharedCipherData:l,sharedCipherApprovalData:y,sharedCipherPartialAssemblyKey:h,approverId:t||void 0,tpId:t?void 0:n.tpId}]}}))}))},t.prototype.validateApprovers=function(e){var t,n;try{for(var r=A(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 J(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 R(this,void 0,void 0,(function(){var r;return E(this,(function(i){switch(i.label){case 0:if(e.length<t)throw new J("Not enough sub assemblies to meet quorum");return r=new ni(t),e.forEach((function(e,t){var n=e.approverTps.length;1===e.quorum&&(n=1),r.addSubAssembly(new ti(t,e.quorum,n))})),[4,this.slip39Service.generateShares(n,this.slip39Passphrase,r)];case 1:return i.sent(),[2,r]}}))}))},t}();e.ɵl=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r.slip39Passphrase=ai,r}return w(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.mkSharedKey.id},t}(oi),e.ɵl.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵl(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR))},token:e.ɵl,providedIn:"root"}),e.ɵl.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵl.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.ɵl=D([br({ngZoneName:"ngZone"})],e.ɵl);var ci=function(e){return function(){return e.initialise()}},ui=function(){function t(e,t,n,r,i,a,s,c,u,p,d,l,y,h){this.config=e,this.auth=t,this.keyFactory=n,this.keyService=r,this.profileService=i,this.keyGraphService=a,this.passwordService=s,this.idleService=c,this.lrGraphQL=u,this.tpPasswordResetProcessorService=p,this.persistService=d,this.encryptionService=l,this.slip39Service=y,this.assemblyController=h,this.hubSubject=new o.ReplaySubject(1)}return t.prototype.initialise=function(){return R(this,void 0,void 0,(function(){var e=this;return E(this,(function(t){return s.Hub.listen("auth",(function(t){return e.hubSubject.next(t.payload)})),[2]}))}))},t.prototype.loginIdpImpl=function(e,t,n,r){return R(this,void 0,void 0,(function(){var i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n))];case 1:return i=s.sent(),[4,this.auth.signIn(e,this.passwordService.getPassIdpString(i.jwk))];case 2:return(a=s.sent()).recoveryStatus=r,[2,a]}}))}))},t.prototype.loginIdp=function(t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o,c;return E(this,(function(u){switch(u.label){case 0:return[4,this.profileService.getPassIdpParams(t)];case 1:if((r=u.sent()).passwordChangeStatus===e.PasswordChangeStatus.InProgress)throw new Q("A password change is in progress");if(r.passwordChangeStatus!==e.PasswordChangeStatus.Recovery)return[3,8];console.log("In recovery mode."),u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.loginIdpImpl(t,n,r.newPassIdpParams,e.RecoveryStatus.NEW_PASSWORD)];case 3:return a=u.sent(),console.log("New password works!"),[2,a];case 4:if("NotAuthorizedException"!==(i=u.sent()).code)throw i;return[3,5];case 5:return u.trys.push([5,7,,8]),[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.OLD_PASSWORD)];case 6:return a=u.sent(),console.log("Old password works!"),[2,a];case 7:throw"NotAuthorizedException"===(s=u.sent()).code?new W("The password change request was interrupted, please try to login with both your new and old password"):s;case 8:if(!r.tpPasswordReset)return[3,12];u.label=9;case 9:return u.trys.push([9,11,,12]),o=r.tpPasswordReset,[4,this.loginIdpImpl(o.resetUsername,n,o.passIdpParams,e.RecoveryStatus.NONE)];case 10:return(c=u.sent()).isTpPasswordResetUser=!0,[2,c];case 11:return u.sent(),[3,12];case 12:return[4,this.loginIdpImpl(t,n,r.currentPassIdpParams,e.RecoveryStatus.NONE)];case 13:return[2,u.sent()]}}))}))},t.prototype.handleSessionEncryptionKey=function(){return R(this,void 0,void 0,(function(){var e,t;return E(this,(function(r){switch(r.label){case 0:if(!this.config.disableSessionEncryptionKey)return[3,1];if(!n.isDevMode())throw e="You should not set disableSessionEncryptionKey=True in mode prod. It defaults to false.",console.error(e),new Error(e);return console.warn("You have set disableSessionEncryptionKey=True. Make sure not to do this in prod mode."),[3,4];case 1:return[4,this.keyFactory.createKey()];case 2:return t=r.sent(),[4,this.lrGraphQL.lrMutate(new Tr({mutation:xn,variables:{input:{sessionEncryptionKey:JSON.stringify(t.toJSON(!0))}}}),{includeKeyGraph:!1})];case 3:r.sent(),this.persistService.setServerSessionEncryptionKey(t),r.label=4;case 4:return[2]}}))}))},t.prototype.handlePostAuth=function(e){return R(this,void 0,void 0,(function(){return E(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]}}))}))},t.prototype.login=function(t,n,r){var i,a=(void 0===r?{}:r).tpPasswordResetAutoComplete,s=void 0===a||a;return R(this,void 0,void 0,(function(){var r;return E(this,(function(a){switch(a.label){case 0:return[4,this.loginImpl(t,n)];case 1:return r=a.sent(),s&&(null===(i=r.resetUser)||void 0===i?void 0:i.state)===e.TpClaimState.APPROVED?[4,this.completeRequest(n)]:[3,4];case 2:return a.sent(),[4,this.loginImpl(t,n)];case 3:r=a.sent(),a.label=4;case 4:return[2,r]}}))}))},t.prototype.loginImpl=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.logout()];case 1:return i.sent(),[4,this.loginIdp(e,t)];case 2:return n=i.sent(),["SMS_MFA","SOFTWARE_TOKEN_MFA"].includes(n.challengeName)?[2,{hasChallenge:!0,challenge:n}]:[4,this.handlePostAuth(n)];case 3:return i.sent(),n.isTpPasswordResetUser?[4,this.loadResetUser(t)]:[3,5];case 4:return[2,{hasChallenge:!1,resetUser:i.sent()}];case 5:return[4,this.loadUser(n,t)];case 6:return r=i.sent(),[4,this.idleService.start()];case 7:return i.sent(),[2,{hasChallenge:!1,user:r}]}}))}))},t.prototype.verifyLogin=function(e,t,n,r){return R(this,void 0,void 0,(function(){var i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.auth.confirmSignIn(e,r,e.challengeName)];case 1:return s.sent(),[4,this.auth.currentAuthenticatedUser()];case 2:return i=s.sent(),[4,this.handlePostAuth(e)];case 3:return s.sent(),[4,this.loadUser(i,t)];case 4:return a=s.sent(),n&&i.setDeviceStatusRemembered({onSuccess:function(){},onFailure:function(e){return console.error(e)}}),[2,a]}}))}))},t.prototype.handlePasswordRecovery=function(t){return R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return t.recoveryStatus===e.RecoveryStatus.NONE?[3,2]:(n=t.getSignInUserSession().getAccessToken().getJwtToken(),[4,this.passwordService.changePasswordComplete(n,t.recoveryStatus===e.RecoveryStatus.NEW_PASSWORD)]);case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.getUserOrResetUser=function(e){return void 0===e&&(e=!1),R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return t.sent().getUsername().endsWith(".tp_password_reset")?[2,this.getResetUser(e)]:[2,this.getUser(e)]}}))}))},t.prototype.getResetUser=function(e){return void 0===e&&(e=!1),R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return!e&&this.currentResetUser?[2,this.currentResetUser]:(t=this,[4,this.loadResetUser()]);case 1:return t.currentResetUser=n.sent(),[4,this.idleService.start()];case 2:return n.sent(),[2,this.currentResetUser]}}))}))},t.prototype.getUser=function(e){return void 0===e&&(e=!1),R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return!e&&this.currentUser?[2,this.currentUser]:(t=this,n=this.loadUser,[4,this.auth.currentAuthenticatedUser()]);case 1:return[4,n.apply(this,[r.sent()])];case 2:return t.currentUser=r.sent(),console.log("Starting idle service."),[4,this.idleService.start()];case 3:return r.sent(),[2,this.currentUser]}}))}))},t.prototype.mapTPVaultAccess=function(e){var t=null==e?void 0:e.tpVault;return(null==t?void 0:t.length)>0&&t.some((function(e){return"ACCESS"===e.toUpperCase()}))},t.prototype.loadUser=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,d,l,y,h,f,v;return E(this,(function(g){switch(g.label){case 0:return[4,this.profileService.getCurrentUser()];case 1:return n=g.sent(),r=n.currentUser,i=n.contactCard,a=n.userPlans,r.sessionEncryptionKey?(o=(s=this.persistService).setServerSessionEncryptionKey,[4,p.JWK.asKey(r.sessionEncryptionKey)]):[3,3];case 2:o.apply(s,[g.sent()]),g.label=3;case 3:return[4,this.auth.userAttributes(e)];case 4:return c=g.sent(),t?[4,this.keyFactory.derivePassKey(Object.assign({password:t},r.currentUserKey.passKey.passKeyParams))]:[3,8];case 5:return u=g.sent().jwk,l=(d=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(r.currentUserKey.passKey.id,u,r.currentUserKey.masterKey.id)];case 6:return[4,l.apply(d,[g.sent()])];case 7:g.sent(),g.label=8;case 8:return[4,this.keyGraphService.populateKeys(r.currentUserKey)];case 9:return g.sent(),y={id:r.id,sub:this.getUserAttribute("sub",c),username:r.username,currentUserKey:r.currentUserKey,getAccessJwtToken:function(){return e.getSignInUserSession().getAccessToken().getJwtToken()},email:this.getUserAttribute("email",c),emailVerified:"true"===this.getUserAttribute("email_verified",c),phone:this.getUserAttribute("phone_number",c),phoneVerified:"true"===this.getUserAttribute("phone_number_verified",c)},f=(h=Object).assign,v=[{}],[4,this.profileService.decryptContactCard(i)];case 10:return[2,(y.contactCard=f.apply(h,v.concat([g.sent()])),y.userDelete=r.userDelete,y.userPlans=a,y.hasTPVaultAccess=this.mapTPVaultAccess(r.features),y.features=r.features,y.sessionEncryptionKey=r.sessionEncryptionKey,y)]}}))}))},t.prototype.watchAuth=function(){return this.hubSubject},t.prototype.logout=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.keyService.purgeKeys(),this.keyGraphService.purgeKeys(),[4,Promise.all([this.auth.signOut(),this.profileService.signOut()])];case 1:return e.sent(),[2]}}))}))},t.prototype.getUserAttribute=function(e,t){var n=t.find((function(t){return t.getName()===e}));return n?n.getValue():null},t.prototype.loadResetUser=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,l,y,h,f,v;return E(this,(function(g){switch(g.label){case 0:return[4,this.lrGraphQL.query({query:yr})];case 1:return(t=g.sent().tpPasswordResetUser).sessionEncryptionKey?(r=(n=this.persistService).setServerSessionEncryptionKey,[4,p.JWK.asKey(t.sessionEncryptionKey)]):[3,3];case 2:r.apply(n,[g.sent()]),g.label=3;case 3:return e?[4,this.keyFactory.derivePassKey(Object.assign({password:e},t.passKey.passKeyParams))]:[3,7];case 4:return i=g.sent().jwk,s=(a=this.idleService).persistMasterKey,[4,this.keyGraphService.unwrapWithPassKey(t.passKey.id,i,t.masterKey.id)];case 5:return[4,s.apply(a,[g.sent()])];case 6:g.sent(),g.label=7;case 7:return this.keyService.populateKeys({passKey:{id:t.passKey.id},masterKey:{id:t.masterKey.id}}),u=(c=this.auth).userAttributes,[4,this.auth.currentAuthenticatedUser()];case 8:return[4,u.apply(c,[g.sent()])];case 9:return o=g.sent(),d=this.getUserAttribute("sub",o),y=(l=Object).assign,f=(h=Object).assign,v=[{}],[4,this.tpPasswordResetProcessorService.processTpPasswordResetUserNode(t)];case 10:return[2,y.apply(l,[f.apply(h,v.concat([g.sent()])),{sub:d}])]}}))}))},t.prototype.refreshAccessToken=function(){return R(this,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:return[4,this.auth.currentAuthenticatedUser()];case 1:return e=n.sent(),t=e.getSignInUserSession().getRefreshToken(),[2,new Promise((function(n,r){e.refreshSession(t,(function(e,t){e?(console.error("Error refreshing token: ",e),r(e)):(console.log("Token refresh complete: ",t),n(0))}))}))]}}))}))},t.prototype.completeRequest=function(t){return R(this,void 0,void 0,(function(){var n,r,i,a,o,c,u,d,l,y,h,f,v,g,m=this;return E(this,(function(S){switch(S.label){case 0:return[4,this.getResetUser(!0)];case 1:if((n=S.sent()).state!==e.TpClaimState.APPROVED)throw new 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 i=S.sent().rootKey,console.log(i),[4,p.JWK.asKey(i)];case 4:return a=S.sent(),[4,this.keyGraphService.getKey(n.masterKey.id)];case 5:return o=S.sent(),[4,this.encryptionService.encryptToString(o.jwk,a.toJSON(!0))];case 6:return c=S.sent(),[4,this.keyFactory.derivePassIdp(Object.assign({password:t},n.passKey.passIdpParams))];case 7:return u=S.sent(),d=this.passwordService.getPassIdpString(u.jwk),[4,this.lrGraphQL.lrMutate(new Tr({mutation:cr,variables:{input:{}}}),{includeKeyGraph:!1})];case 8:return l=S.sent().createTpAssemblyKeyChallenge.challenge,console.log(l),l.clientNonce=this.keyFactory.randomString(32),console.log(l),[4,this.encryptionService.decrypt(r,n.wrappedAssemblyKeyVerifierPrk)];case 9:return y=S.sent(),[4,this.encryptionService.sign(y,l)];case 10:return h=S.sent(),[4,this.lrGraphQL.lrMutate(new Tr({mutation:ur,variables:{input:{signedChallenge:JSON.stringify(h)}}}),{includeKeyGraph:!1})];case 11:return f=S.sent().preCompleteTpPasswordResetRequest.idpPassword,v=new Promise((function(e){var t=function(r){return R(m,void 0,void 0,(function(){return E(this,(function(i){switch(i.label){case 0:return"signIn"!==r.payload.event?[2]:(s.Hub.remove("auth",t),console.log(r.payload),[4,this.auth.signIn(n.username,d)]);case 1:return i.sent(),[4,this.lrGraphQL.lrMutate(new Tr({mutation:pr,variables:{input:{masterKeyWrappedRootKey:c,masterKeyId:o.id}}}))];case 2:return i.sent(),e(),[2]}}))}))};s.Hub.listen("auth",t)})),[4,this.auth.signIn(n.username,f,{noProxy:"true"})];case 12:if("NEW_PASSWORD_REQUIRED"!==(g=S.sent()).challengeName)throw new L({message:"Internal error. Expecting Cognito to have done a password reset after call to PreCompleteTpPasswordResetRequestMutation."});return[4,this.auth.completeNewPassword(g,d,{})];case 13:return g=S.sent(),[2,v]}}))}))},t.prototype.recoverAssemblyKey=function(e){return R(this,void 0,void 0,(function(){var t,n,r=this;return E(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)]}}))}))},t}();ui.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ui(n.ɵɵinject(te),n.ɵɵinject(d.AuthClass),n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(vn),n.ɵɵinject(ve),n.ɵɵinject(qn),n.ɵɵinject(Un),n.ɵɵinject(e.ɵh),n.ɵɵinject(e.ɵi),n.ɵɵinject(he),n.ɵɵinject(de),n.ɵɵinject(ri),n.ɵɵinject(e.ɵl))},token:ui,providedIn:"root"}),ui.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ui.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:d.AuthClass},{type:ye},{type:fe},{type:vn},{type:ve},{type:qn},{type:Un},{type:e.ɵh},{type:e.ɵi},{type:he},{type:de},{type:ri},{type:e.ɵl}]};var pi=function(){function e(e,t,n){this.config=e,this.http=t,this.lrAuth=n}return e.prototype.downloadEncryptedFile=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return n=(t=JSON).parse,[4,this.downloadEncryptedFile2(e)];case 1:return[2,n.apply(t,[r.sent()])]}}))}))},e.prototype.downloadEncryptedFile2=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return t=this.config.apiUrl+"files/download/?file_state_node_id="+e,r=(n=this.http).get,i=[t],a={responseType:"text"},s={},o="Bearer ",[4,this.lrAuth.getUser()];case 1:return[4,r.apply(n,i.concat([(a.headers=(s.Authorization=o+c.sent().getAccessJwtToken(),s),a)])).toPromise()];case 2:return[2,c.sent()]}}))}))},e.prototype.loadFile=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.readAsArrayBuffer(e)}))]}))}))},e.prototype.uploadEncryptedFile=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return E(this,(function(p){switch(p.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],o={},c={},u="Bearer ",[4,this.lrAuth.getUser()];case 1:return[4,a.apply(i,s.concat([(o.headers=(c.Authorization=u+p.sent().getAccessJwtToken(),c),o)])).toPromise()];case 2:return[2,p.sent().content_resource]}}))}))},e}();pi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new pi(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ui))},token:pi,providedIn:"root"}),pi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],pi.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:ui}]};var di,li,yi,hi,fi=y(di||(di=M(["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"],["\n query UserQuery($email: LrEmail, $username: String) {\n user(email: $email, username: $username) {\n id\n username\n haveTp\n isCurrentUser\n contactCards {\n edges {\n node {\n publicData\n publicSearchable\n }\n }\n }\n currentUserKey {\n sigPxk {\n id\n pbk\n }\n pxk {\n id\n pbk\n }\n }\n }\n }\n"]))),vi=y(li||(li=M(["\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"]))),gi=y(yi||(yi=M(["\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"]))),mi=y(hi||(hi=M(["\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"]))),Si=function(){function e(e){this.lrApollo=e}return e.prototype.getUserByEmail=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.getUser({email:e})]}))}))},e.prototype.getUserByUsername=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.getUser({username:e})]}))}))},e.prototype.getUser=function(e){var t=e.email,n=e.username;return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.query({query:fi,variables:{email:t,username:n}})];case 1:return[2,e.sent().user]}}))}))},e.prototype.requestUserDelete=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:vi,variables:{input:{}}})];case 1:return[2,e.sent().requestUserDelete.userDelete]}}))}))},e.prototype.cancelUserDelete=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.lrApollo.mutate({mutation:gi,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),R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:mi,variables:{first:e,after:t}})];case 1:return[2,n.sent().loginHistory]}}))}))},e}();Si.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Si(n.ɵɵinject(ge))},token:Si,providedIn:"root"}),Si.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Si.ctorParameters=function(){return[{type:ge}]};var Ii,Ci,bi,ki,Ki,wi,Pi,Di,Ri="\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n}",Ei="\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",Ai=y(Ii||(Ii=M(["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""],["\nquery CurrentUserSharedKeyQuery(\n $username: String\n $userId: LrRelayIdInput\n $cachedKeyIds: [LrRelayIdInput!]\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ","\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n",""])),Ei,Oe),Oi=y(Ci||(Ci=M(["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"],["\nquery KeyExchangeQuery(\n$orderBy: String\n$isExpired: Boolean\n$initiatorActionRequired: Boolean\n$responderActionRequired: Boolean\n$initiator: ID\n$responder: ID\n$state: String\n) {\nkeyExchanges(\n orderBy: $orderBy\n isExpired: $isExpired\n initiatorActionRequired: $initiatorActionRequired\n responderActionRequired: $responderActionRequired\n initiator: $initiator\n responder: $responder\n state: $state\n) {\n edges {\n node {\n ","\n }\n }\n}\nkeyGraph {\n ...KeyGraphFragment\n}\n}\n","\n"])),Ri,Oe),Ti=y(bi||(bi=M(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n) {\n keyExchange(\n id: $id\n ) {\n ","\n }\n keyGraph {\n ...KeyGraphFragment\n }\n}\n","\n"])),Ri,Oe),Mi=y(ki||(ki=M(["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"],["\nquery KeyExchangeQuery(\n $id: LrRelayIdInput!\n $token: String\n) {\n keyExchange(\n id: $id\n token: $token\n ) {\n ","\n }\n}"])),Ri),ji=y(Ki||(Ki=M(["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"],["\nmutation InitiateKeyExchangeOtk(\n$input: InitiateKeyExchangeOtkInput!\n) {\ninitiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n}\n","\n}"])),Ri,Me),$i=y(wi||(wi=M(["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation RespondKeyExchangeOtk(\n $input: RespondKeyExchangeOtkInput!\n) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),Ri,Ei),Ni=y(Pi||(Pi=M(["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"],["\nmutation CompleteKeyExchangeOtk(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ","\n }\n userSharedKey {\n ","\n }\n tp {\n id\n }\n }\n}"])),Ri,Ei);(Di=e.OtkState||(e.OtkState={})).OTK_INITIATED="OTK_INITIATED",Di.OTK_ACCEPTED="OTK_ACCEPTED",Di.OTK_COMPLETED="OTK_COMPLETED";var Fi=function(){function t(e,t,n,r,i,a){this.keyFactory=e,this.keyService=t,this.lrApollo=n,this.encryptionService=r,this.authService=i,this.userService=a,this.CLIENT_NONCE_LENGTH=32}return t.prototype.getKeyExchangeList=function(e){return void 0===e&&(e={}),R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Oi,variables:Object.assign({},e)})];case 1:return[2,t.sent().keyExchanges]}}))}))},t.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:i?Mi:Ti,variables:{id:e,token:i}})];case 1:return t=n.sent().keyExchange,[4,this.decryptKeyExchange(t,r)];case 2:return[2,n.sent()]}}))}))},t.prototype.decryptResponseCipher=function(e,t,n){return R(this,void 0,void 0,(function(){var r;return E(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.encryptionService.decrypt(e,n)];case 1:return n=i.sent(),[3,3];case 2:if("no key found"!==(r=i.sent()).message)throw r;return[3,3];case 3:return[4,this.encryptionService.decrypt(t,n)];case 4:return[2,i.sent()]}}))}))},t.prototype.decryptKeyExchange=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p;return E(this,(function(d){switch(d.label){case 0:return e.isInitiator?[4,this.keyService.getCurrentRootKey()]:[3,8];case 1:return n=d.sent(),[4,this.encryptionService.decrypt(n.jwk,e.initiatorRootKeyCipher)];case 2:return r=d.sent(),e.otk.initiatorOneTimePbkCipher?(s=this.decryptResponseCipher,[4,ye.asKey(r.otKey)]):[3,6];case 3:return o=[d.sent()],[4,ye.asKey(r.oneTimePrk)];case 4:return[4,s.apply(this,o.concat([d.sent(),e.otk.initiatorOneTimePbkCipher]))];case 5:return a=d.sent(),[3,7];case 6:a=null,d.label=7;case 7:return c=(i=a)&&i.responder,p=r&&r.initiator,[2,Object.assign(Object.assign({},e),{message:c?c.message:null,contactCard:c&&c.contactCard?c.contactCard.plainSharedCipherDataJson:null,myContactCard:p&&p.contactCard?p.contactCard.plainSharedCipherDataJson:null,myMessage:p&&p.message})];case 8:return[4,this.decryptOtk(e,t)];case 9:return u=d.sent(),p=u&&u.plainOtKeyCipher.initiator,[2,Object.assign(Object.assign({},e),{decryptedOtk:u,message:p&&p.message,contactCard:p&&p.contactCard&&p.contactCard.plainSharedCipherDataJson})]}}))}))},t.prototype.decryptOtk=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.getOtKey(e,t)];case 1:return(n=a.sent())&&e.otk.otKeyCipher?(i={},[4,this.encryptionService.decrypt(n,e.otk.otKeyCipher)]):[3,3];case 2:return i.plainOtKeyCipher=a.sent(),i.otKey=n,r=i,[3,4];case 3:r=null,a.label=4;case 4:return[2,r]}}))}))},t.prototype.getOtKey=function(t,n){return R(this,void 0,void 0,(function(){var r,i;return E(this,(function(a){switch(a.label){case 0:return n?[4,ye.asKey(Object.assign(Object.assign({},JSON.parse(t.otk.otKeyParams)),{k:n}))]:[3,2];case 1:return[2,a.sent()];case 2:return t.otk.state!==e.OtkState.OTK_INITIATED||t.isInitiator||!t.otk.responderPbkCipher?[3,6]:[4,this.keyService.getCurrentPxk()];case 3:return r=a.sent(),[4,this.encryptionService.decrypt(r.jwk,JSON.parse(t.otk.responderPbkCipher),{serializations:[ae.COMPACT]})];case 4:return(i=a.sent()).otKey?[4,ye.asKey(i.otKey)]:[3,6];case 5:return[2,a.sent()];case 6:return[2,null]}}))}))},t.prototype.initiateOtk=function(e){var t=e.message,n=e.email,r=e.contactCard,i=e.upgrade;return R(this,void 0,void 0,(function(){var e,a,s,o,c,u,p,d,l,y,h,f,v,g,m,S;return E(this,(function(I){switch(I.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=I.sent(),a=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.authService.getUser()];case 2:return s=I.sent(),[4,this.keyFactory.createPkcKey()];case 3:return o=I.sent(),[4,this.keyService.getCurrentPxk()];case 4:return c=I.sent(),[4,this.keyService.getCurrentSigPxk()];case 5:return u=I.sent(),p=null,r&&r.ownerPlainData?(l=(d=JSON).stringify,[4,this.encryptionService.sign(u.jwk,r.ownerPlainData)]):[3,7];case 6:p=l.apply(d,[I.sent()]),I.label=7;case 7:return y={message:t,contactCard:r?{plainSharedCipherDataJson:r.plainSharedCipherDataJson}:null},h={nonce:a,initiator:Object.assign(Object.assign({},y),{oneTimePbk:o.toJSON(),pbk:c.jwk.toJSON(),sigPbk:u.jwk.toJSON(),profile:{username:s.username}})},[4,this.encryptionService.encrypt(e,h)];case 8:return f=I.sent(),v={nonce:a,oneTimePrk:o.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:r,initiator:y},[4,this.keyService.getCurrentRootKey()];case 9:return g=I.sent(),[4,this.encryptionService.encrypt(g.jwk,v)];case 10:return m=I.sent(),S=e.toJSON(!0).k,[4,this.lrApollo.mutate({mutation:ji,variables:{input:{initiatorRootKeyCipher:JSON.stringify(m),initiatorPxkId:c.id,initiatorSigPxkId:u.id,otKeyParams:JSON.stringify(e.toJSON()),otKeyCipher:JSON.stringify(f),sendEmail:n?{email:n,rawOtKey:S}:null,createTp:!0,initiatorPlainDataSig:p,upgrade:i}}})];case 11:return[2,{keyExchange:I.sent().initiateKeyExchangeOtk.keyExchange,otKeyK:S}]}}))}))},t.prototype.respondOtk=function(e){var t=e.id,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return R(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b,k,K,w,P,D,R,A,O,T,M,j,$,N,F,L,x,U,J,_,q,G,B,Q,V,W,Z,H,Y,z,X,ee,te,ne,re;return E(this,(function(E){switch(E.label){case 0:return[4,this.authService.getUser()];case 1:return e=E.sent(),[4,this.keyService.getCurrentRootKey()];case 2:return o=E.sent(),c=this.keyService.getCurrentMasterKey().id,[4,this.keyService.getCurrentMasterKey()];case 3:return u=E.sent(),[4,this.keyFactory.createKey()];case 4:return p=E.sent(),[4,this.keyFactory.createKey()];case 5:return d=E.sent(),[4,this.encryptionService.encrypt(o.jwk,p.toJSON(!0))];case 6:return l=E.sent(),[4,this.encryptionService.encrypt(u.jwk,d.toJSON(!0))];case 7:return y=E.sent(),[4,ye.asKey(r.plainOtKeyCipher.initiator.oneTimePbk)];case 8:return h=E.sent(),[4,ye.asKey(r.plainOtKeyCipher.initiator.pbk)];case 9:return f=E.sent(),[4,ye.asKey(r.plainOtKeyCipher.initiator.sigPbk)];case 10:return v=E.sent(),[4,this.keyService.getCurrentPxk()];case 11:return g=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 12:return m=E.sent(),[4,this.encryptionService.sign(m.jwk,f.toJSON())];case 13:return S=E.sent(),[4,this.encryptionService.sign(m.jwk,v.toJSON())];case 14:return I=E.sent(),C={nonce:r.plainOtKeyCipher.nonce,sharedKey:p.toJSON(!0),mkSharedKey:d.toJSON(!0),responder:{pbk:g.jwk.toJSON(),sigPbk:m.jwk.toJSON(),profile:{username:e.username},message:i}},r.plainOtKeyCipher.initiator.contactCard?(k=r.plainOtKeyCipher.initiator.contactCard.plainSharedCipherDataJson,[4,this.keyFactory.createKey()]):[3,25];case 15:return K=E.sent(),[4,this.keyFactory.createKey()];case 16:return x=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 17:return U=E.sent(),w={},D=(P=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,K.toJSON(!0))];case 18:return w.receiverWrappedKey=D.apply(P,[E.sent()]),w.receiverWrappingKeyId=o.id,a?(O=(A=JSON).stringify,[4,this.encryptionService.encrypt(K,a.plainReceiverCipherDataJson)]):[3,20];case 19:return R=O.apply(A,[E.sent()]),[3,21];case 20:R="",E.label=21;case 21:return w.receiverCipherData=R,M=(T=JSON).stringify,[4,this.encryptionService.encrypt(p,x.toJSON(!0))];case 22:return w.sharedWrappedKey=M.apply(T,[E.sent()]),b=w,[4,this.encryptionService.encrypt(x,k)];case 23:return Z=E.sent(),j=b,N=($=JSON).stringify,[4,this.encryptionService.sign(U.jwk,Z)];case 24:j.sharedCipherDataSig=N.apply($,[E.sent()]),b.sigPxkId=U.id,C.responder.contactCard=Object.assign(Object.assign({},C.responder.contactCard),{sharedCipherKey:x.toJSON(!0)}),E.label=25;case 25:return s?[4,this.keyFactory.createKey()]:[3,38];case 26:return L=E.sent(),[4,this.keyFactory.createKey()];case 27:return x=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 28:return U=E.sent(),J={},q=(_=JSON).stringify,[4,this.encryptionService.encrypt(o.jwk,L.toJSON(!0))];case 29:return J.ownerWrappedKey=q.apply(_,[E.sent()]),J.ownerWrappingKeyId=o.id,s.plainOwnerCipherDataJson?(Q=(B=JSON).stringify,[4,this.encryptionService.encrypt(L,s.plainOwnerCipherDataJson)]):[3,31];case 30:return G=Q.apply(B,[E.sent()]),[3,32];case 31:G="",E.label=32;case 32:return J.ownerCipherData=G,W=(V=JSON).stringify,[4,this.encryptionService.encrypt(p,x.toJSON(!0))];case 33:return J.sharedWrappedKey=W.apply(V,[E.sent()]),F=J,[4,this.encryptionService.encrypt(x,s.plainSharedCipherDataJson)];case 34:return Z=E.sent(),H=F,z=(Y=JSON).stringify,[4,this.encryptionService.sign(U.jwk,Z)];case 35:return H.sharedCipherDataSig=z.apply(Y,[E.sent()]),F.sigPxkId=U.id,s.ownerPlainData?(X=F,te=(ee=JSON).stringify,[4,this.encryptionService.sign(m.jwk,s.ownerPlainData)]):[3,37];case 36:X.ownerPlainDataSig=te.apply(ee,[E.sent()]),E.label=37;case 37:C.responder.contactCard=Object.assign(Object.assign({},C.responder.contactCard),{plainSharedCipherDataJson:s.plainSharedCipherDataJson}),E.label=38;case 38:return[4,this.encryptionService.encrypt(h,C)];case 39:return ne=E.sent(),[4,this.encryptionService.encrypt(r.otKey,ne)];case 40:return ne=E.sent(),[4,this.lrApollo.mutate({mutation:$i,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:o.id,masterKeyId:c,responderPxkId:g.id,responderSigPxkId:m.id,signedInitiatorPbk:JSON.stringify(S),signedInitiatorSigPbk:JSON.stringify(I),rkWrappedSharedKey:JSON.stringify(l),mkWrappedMkSharedKey:JSON.stringify(y),initiatorOneTimePbkCipher:JSON.stringify(ne),initiatorContactCard:b,responderContactCard:F}}})];case 41:return[2,{keyExchange:(re=E.sent().respondKeyExchangeOtk).keyExchange,userSharedKey:re.userSharedKey,tp:re.tp}]}}))}))},t.prototype.completeOtk=function(e,t,n,r){return R(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b,k,K,w,P,D,R,A,O,T,M,j,$,N,F,L,x,U,J,_;return E(this,(function(E){switch(E.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return i=E.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return a=E.sent(),[4,this.encryptionService.decrypt(i.jwk,t)];case 3:return s=E.sent(),c=this.decryptResponseCipher,[4,ye.asKey(s.otKey)];case 4:return u=[E.sent()],[4,ye.asKey(s.oneTimePrk)];case 5:return[4,c.apply(this,u.concat([E.sent(),n]))];case 6:if(o=E.sent(),s.nonce!==o.nonce)throw new B("The nonce returned by responder does not match with the one created by the initiator.");return[4,this.keyService.getCurrentSigPxk()];case 7:return p=E.sent(),[4,ye.asKey(o.responder.sigPbk)];case 8:return d=E.sent(),[4,ye.asKey(o.responder.pbk)];case 9:return l=E.sent(),[4,this.encryptionService.sign(p.jwk,l.toJSON())];case 10:return y=E.sent(),[4,this.encryptionService.sign(p.jwk,d.toJSON())];case 11:return h=E.sent(),[4,ye.asKey(o.sharedKey)];case 12:return f=E.sent(),[4,this.encryptionService.encrypt(i.jwk,f.toJSON(!0))];case 13:return v=E.sent(),[4,ye.asKey(o.mkSharedKey)];case 14:return g=E.sent(),[4,this.encryptionService.encrypt(a.jwk,g.toJSON(!0))];case 15:return m=E.sent(),r?[4,this.keyFactory.createKey()]:[3,19];case 16:return I=E.sent(),C={},k=(b=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,I.toJSON(!0))];case 17:return C.receiverWrappedKey=k.apply(b,[E.sent()]),C.receiverWrappingKeyId=i.id,w=(K=JSON).stringify,[4,this.encryptionService.encrypt(I,r)];case 18:C.receiverCipherData=w.apply(K,[E.sent()]),S=C,E.label=19;case 19:return s.initiatorContactCard?(R=s.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,28];case 20:return A=E.sent(),[4,ye.asKey(o.responder.contactCard.sharedCipherKey)];case 21:return O=E.sent(),j=(M=JSON).stringify,[4,this.encryptionService.encrypt(i.jwk,A.toJSON(!0))];case 22:return T=j.apply(M,[E.sent()]),R.plainOwnerCipherDataJson?(L=(F=JSON).stringify,[4,this.encryptionService.encrypt(A,R.plainOwnerCipherDataJson)]):[3,24];case 23:return N=L.apply(F,[E.sent()]),[3,25];case 24:N="",E.label=25;case 25:return $=N,P={ownerWrappedKey:T,ownerWrappingKeyId:i.id,ownerCipherData:$},D={sigPxkId:p.id},[4,this.encryptionService.encrypt(O,R.plainSharedCipherDataJson)];case 26:return x=E.sent(),U=D,_=(J=JSON).stringify,[4,this.encryptionService.sign(p.jwk,x)];case 27:U.sharedCipherDataSig=_.apply(J,[E.sent()]),E.label=28;case 28:return[4,this.lrApollo.mutate({mutation:Ni,variables:{input:{keyExchangeId:e,rootKeyId:i.id,masterKeyId:a.id,initiatorSigPxkId:p.id,signedResponderPbk:JSON.stringify(y),signedResponderSigPbk:JSON.stringify(h),rkWrappedSharedKey:JSON.stringify(v),mkWrappedMkSharedKey:JSON.stringify(m),responderContactCardCipher:S,initiatorContactCardCipher:P,initiatorContactCardSharedCipher:D}}})];case 29:return[2,E.sent().completeKeyExchangeOtk]}}))}))},t.prototype.currentUserSharedKey=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:Ai,variables:{username:e.username,userId:e.userId}})];case 1:return[2,t.sent().currentUserSharedKey.userSharedKey]}}))}))},t}();Fi.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Fi(n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(ge),n.ɵɵinject(de),n.ɵɵinject(ui),n.ɵɵinject(Si))},token:Fi,providedIn:"root"}),Fi.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Fi.ctorParameters=function(){return[{type:ye},{type:fe},{type:ge},{type:de},{type:ui},{type:Si}]};var Li,xi,Ui=y(Li||(Li=M(["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"],["\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message {\n id\n }\n }\n }\n"]))),Ji=y(xi||(xi=M(["\n query Message($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ","\n"],["\n query Message($id: LrRelayIdInput!) {\n message(id: $id) {\n id\n sender {\n username\n }\n receiver {\n username\n }\n plainMessage\n signedCipherMessage\n sharedKey {\n id\n }\n senderSigPbk {\n id\n }\n }\n keyGraph {\n ...KeyGraphFragment\n }\n }\n ","\n"])),Oe),_i=function(){function e(e,t,n,r){this.lrApollo=e,this.keyGraph=t,this.encryptionService=n,this.keyExchangeService=r,this.encrypt=this.encryptionService.encrypt.bind(this.encryptionService),this.decrypt=this.encryptionService.decrypt.bind(this.encryptionService),this.sign=this.encryptionService.sign.bind(this.encryptionService),this.verify=this.encryptionService.verify.bind(this.encryptionService)}return e.prototype.sendMessage=function(e){var t=e.username,n=e.userId,r=e.plainMessageJson,i=e.plainCipherMessageJson;return R(this,void 0,void 0,(function(){var e,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return[4,this.keyExchangeService.currentUserSharedKey({username:t,userId:n})];case 1:return e=p.sent(),a={receiverUsername:t,receiverId:n,sharedKeyId:e.sharedKey.id,senderSigPbkId:e.userSigPrk.id},i?[4,this.keyGraph.getJwkKey(e.sharedKey.id)]:[3,6];case 2:return s=p.sent(),[4,this.encrypt(s,i)];case 3:return o=p.sent(),[4,this.keyGraph.getJwkKey(e.userSigPrk.id)];case 4:return c=p.sent(),[4,this.sign(c,o)];case 5:u=p.sent(),a.signedCipherMessage=JSON.stringify(u),p.label=6;case 6:return r&&(a.plainMessage=JSON.stringify(r)),[4,this.lrApollo.query({query:Ui,variables:{input:a}})];case 7:return[2,p.sent().sendMessage]}}))}))},e.prototype.decryptMessage=function(e,t){var n=t.sharedKey,r=t.senderSigPbk;return R(this,void 0,void 0,(function(){var t,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.verify(r,JSON.parse(e.signedCipherMessage))];case 1:return t=a.sent(),i=e,[4,this.decrypt(n,t)];case 2:return i.plainSignedCipherMessageJson=a.sent(),[2]}}))}))},e.prototype.getMessage=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.lrApollo.query({query:Ji,variables:{id:e}})];case 1:return t=a.sent(),this.keyGraph.addKeys(t.keyGraph),n=t.message,[4,this.keyGraph.getJwkKey(n.sharedKey.id)];case 2:return r=a.sent(),[4,this.keyGraph.getJwkKey(n.senderSigPbk.id)];case 3:return i=a.sent(),[4,this.decryptMessage(n,{sharedKey:r,senderSigPbk:i})];case 4:return a.sent(),n.plainMessage&&(n.plainMessageJson=JSON.parse(n.plainMessage)),[2,t.message]}}))}))},e}();_i.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new _i(n.ɵɵinject(ge),n.ɵɵinject(ve),n.ɵɵinject(de),n.ɵɵinject(Fi))},token:_i,providedIn:"root"}),_i.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],_i.ctorParameters=function(){return[{type:ge},{type:ve},{type:de},{type:Fi}]};var qi,Gi,Bi,Qi,Vi,Wi=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()}},Zi=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=Wi(n),t.configure({region:e[0],userPoolId:r,userPoolWebClientId:i,mandatorySignIn:!1})}},Hi=y(qi||(qi=M(["\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"]))),Yi=y(Gi||(Gi=M(["\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=y(Bi||(Bi=M(["\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"]))),Xi=y(Qi||(Qi=M(["\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"]))),ea=y(Vi||(Vi=M(["\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"]))),ta=function(){function e(e,t,n,r,i,a,s,o,c,u){this.config=e,this.http=t,this.lrApollo=n,this.auth=r,this.authService=i,this.keyFactory=a,this.keyService=s,this.encryptionService=o,this.keyGraph=c,this.passwordService=u,this.CLIENT_NONCE_LENGTH=32,this.LBOP_WORDS=25}return e.prototype.getPartial=function(e){return e.split(" ")[0]},e.prototype.remove=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Yi,variables:{input:{id:e}}})];case 1:return[2,t.sent().deleteLbop.id]}}))}))},e.prototype.update=function(e){var t=e.id,n=e.name;return R(this,void 0,void 0,(function(){var e,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.get(t)];case 1:return(e=a.sent()).name=n,[4,this.keyService.getCurrentMasterKey()];case 2:return r=a.sent(),[4,this.encryptionService.encrypt(r.jwk,e)];case 3:return i=a.sent(),[4,this.lrApollo.mutate({mutation:zi,variables:{input:{id:t,cipherMeta:JSON.stringify(i)}}})];case 4:return[2,a.sent().updateLbop]}}))}))},e.prototype.get=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.lrApollo.query({query:Xi,variables:{id:e}})];case 1:return t=i.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return n=i.sent(),[4,this.encryptionService.decrypt(n.jwk,JSON.parse(t.lbop.cipherMeta))];case 3:return r=i.sent(),[2,Object.assign({id:t.id},r)]}}))}))},e.prototype.list=function(){return R(this,void 0,void 0,(function(){var e,t,n=this;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:ea})];case 1:return e=r.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return t=r.sent(),[2,Promise.all(e.lbops.edges.map((function(e){return R(n,void 0,void 0,(function(){var n;return E(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)]}}))}))})))]}}))}))},e.prototype.create=function(e){var t=e.name;return R(this,void 0,void 0,(function(){var e,n,r,i,a,s,o,c,u,p,d,l,y,h;return E(this,(function(f){switch(f.label){case 0:if(1024!==I.Slip39Helper.WORD_LIST.length)throw new G("Slip39Helper.WORD_LIST.length != 1024");return[4,this.list()];case 1:for(e=f.sent(),r=function(){n=i.keyFactory.randomChoices(I.Slip39Helper.WORD_LIST,i.LBOP_WORDS).join(" ");var t=i.getPartial(n);if(!e.some((function(e){return e.partial===t})))return"break"},i=this;"break"!==r(););return[4,this.keyFactory.createLbopKeyParams()];case 2:return a=f.sent(),[4,this.keyFactory.deriveLbopKey(Object.assign({password:n},a))];case 3:return s=f.sent().jwk,[4,this.keyFactory.createSignKey()];case 4:return o=f.sent(),[4,this.encryptionService.encrypt(s,o.toJSON(!0))];case 5:return c=f.sent(),[4,this.authService.getUser()];case 6:return u=f.sent(),[4,this.keyGraph.getKey(u.currentUserKey.masterKey.id)];case 7:return p=f.sent(),[4,this.encryptionService.encrypt(s,p.jwk.toJSON(!0))];case 8:return d=f.sent(),l=Object.assign(Object.assign({},t&&{name:t}),{partial:this.getPartial(n)}),[4,this.encryptionService.encrypt(p.jwk,l)];case 9:return y=f.sent(),[4,this.lrApollo.mutate({mutation:Hi,variables:{input:{cipherMeta:JSON.stringify(y),lbopKeyParams:JSON.stringify(a),lbopKeyVerifier:JSON.stringify(o.toJSON(!0)),wrappedLbopKeyVerifier:JSON.stringify(c),masterKeyId:u.currentUserKey.masterKey.id,wrappedMasterKey:JSON.stringify(d)}}})];case 10:return h=f.sent(),[2,Object.assign(Object.assign({},h.createLbop.lbop),{lbopString:n})]}}))}))},e.prototype.verifyLbops=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return E(this,(function(y){switch(y.label){case 0:n=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),y.label=1;case 1:y.trys.push([1,10,11,12]),r=A(e.lbops),i=r.next(),y.label=2;case 2:return i.done?[3,9]:(a=i.value,[4,this.keyFactory.deriveLbopKey(Object.assign({password:t},a.lbopKeyParams))]);case 3:s=y.sent().jwk,y.label=4;case 4:return y.trys.push([4,7,,8]),[4,this.encryptionService.decrypt(s,a.wrappedLbopKeyVerifier)];case 5:return o=y.sent(),c=e.challenge.serverNonce,[4,this.encryptionService.sign(o,{serverNonce:c,clientNonce:n})];case 6:return u=y.sent(),[2,{lbop:a,signedChallenge:u,lbopKey:s}];case 7:return y.sent(),[3,8];case 8:return i=r.next(),[3,2];case 9:return[3,12];case 10:return p=y.sent(),d={error:p},[3,12];case 11:try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(d)throw d.error}return[7];case 12:throw new L({source:"LBOP",code:"INVALID_PASSPHRASE",message:"Invalid passphrase."})}}))}))},e.prototype.verifyContact=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.http.post(this.config.authUrl+"users/lbop-reset/verify-contact/",e).toPromise()]}))}))},e.prototype.confirmContact=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.http.post(this.config.authUrl+"cove/respond/",{claim_id:e.claimId,v_code:e.vCode}).toPromise()]}))}))},e.prototype.verify=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return E(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=ye).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)]}}))}))},e.prototype.setPassword=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(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 L({message:"Internal error. 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()]}}))}))},e}();ta.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ta(n.ɵɵinject(te),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ge),n.ɵɵinject(d.AuthClass),n.ɵɵinject(ui),n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(qn))},token:ta,providedIn:"root"}),ta.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ta.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:t.HttpClient},{type:ge},{type:d.AuthClass},{type:ui},{type:ye},{type:fe},{type:de},{type:ve},{type:qn}]};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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){return E(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"),R(this,void 0,void 0,(function(){var a,s,o,c,u,p,d,l,y,h,f,v,g;return E(this,(function(m){switch(m.label){case 0:return[4,this.passwordService.createPassKeyBundle(t)];case 1:return a=m.sent(),[4,this.keyFactory.createKey()];case 2:return s=m.sent(),[4,this.encryptionService.encrypt(a.passKey,s.toJSON(!0))];case 3:return o=m.sent(),[4,this.keyFactory.createKey()];case 4:return c=m.sent(),[4,this.encryptionService.encrypt(s,c.toJSON(!0))];case 5:return u=m.sent(),[4,this.keyFactory.createPkcKey()];case 6:return p=m.sent(),[4,this.encryptionService.encrypt(c,p.toJSON(!0))];case 7:return d=m.sent(),[4,this.keyFactory.createPkcSignKey()];case 8:return l=m.sent(),[4,this.encryptionService.encrypt(c,l.toJSON(!0))];case 9:return y=m.sent(),[4,this.http.post(this.config.authUrl+"users/",{claims:[{type:i,token:r,claim_id:n}],pass_idp_params:a.passIdpParams,pass_idp_verifier_pbk:a.passIdpVerifier.toJSON(),wrapped_pass_idp_verifier_prk:a.wrappedPassIdpVerifierPrk,pass_key_params:a.passKeyParams,wrapped_master_key:o,wrapped_root_key:u,pbk:p.toJSON(),wrapped_prk:d,sig_pbk:l.toJSON(),wrapped_sig_prk:y}).toPromise()];case 10:return h=m.sent(),f={},h.claims.forEach((function(e){f[e.type]=e.value})),v=this.keyFactory.randomDigitsNoZeros(4),[4,this.auth.signUp({username:e.split("@")[0]+"."+v,password:this.passwordService.getPassIdpString(a.passIdp),attributes:f,clientMetadata:{user_id:String(h.id),user_pre_sign_up_token:String(h.pre_sign_up_token)}})];case 11:return[2,{username:(g=m.sent()).user.getUsername(),userId:h.id,preSignUpToken:h.pre_sign_up_token,userSub:g.userSub}]}}))}))},e.prototype.hibpBreachedAccounts=function(e){return R(this,void 0,void 0,(function(){var t;return E(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=n.ɵɵdefineInjectable({factory:function(){return new na(n.ɵɵinject(te),n.ɵɵinject(d.AuthClass),n.ɵɵinject(t.HttpClient),n.ɵɵinject(ye),n.ɵɵinject(de),n.ɵɵinject(qn))},token:na,providedIn:"root"}),na.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],na.ctorParameters=function(){return[{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:d.AuthClass},{type:t.HttpClient},{type:ye},{type:de},{type:qn}]};var ra,ia=function(){function e(e){this.auth=e}return e.prototype.getPreferredMFA=function(){return R(this,void 0,void 0,(function(){var e;return E(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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){var e,t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,Promise.all([this.auth.currentAuthenticatedUser(),this.auth.currentUserInfo()])];case 1:return e=O.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 J("No email associated with user.");return[2,{code:r,codeUri:"otpauth://totp/"+i+"?secret="+r+"&issuer=LifeReady"}]}}))}))},e.prototype.verifySoftwareToken=function(e){return R(this,void 0,void 0,(function(){var t;return E(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}();ia.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ia(n.ɵɵinject(d.AuthClass))},token:ia,providedIn:"root"}),ia.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ia.ctorParameters=function(){return[{type:d.AuthClass}]},(ra=e.FileType||(e.FileType={})).RecordContent="record-content",ra.RecordAttachment="record-attachment";var aa,sa,oa,ca,ua,pa,da,la,ya,ha=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordContent}}]}),fa=JSON.stringify({filter:[{contains:{fileType:e.FileType.RecordAttachment}}]}),va=function(e){return void 0===e&&(e=5),y(aa||(aa=M(["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ","\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"],["\nquery Record(\n $id: LrRelayIdInput!,\n $cachedKeyIds: [LrRelayIdInput!],\n $categoryFilter: LrJSONFilter,\n $contentFilter: LrJSONFilter,\n $attachmentsFilter: LrJSONFilter,\n) {\n record: directory(id: $id) {\n id\n keyId\n archived\n plainMeta\n cipherMeta\n created\n modified\n ","\n ","\n content: childFileLinks(plainMeta: $contentFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n created\n modified\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n attachments: childFileLinks(plainMeta: $attachmentsFilter) {\n edges {\n node {\n childFile {\n id\n keyId\n archived\n currentVersion {\n state {\n id\n keyId\n plainMeta\n cipherMeta\n contentResource\n }\n }\n versions {\n edges {\n node {\n operation\n }\n }\n }\n }\n }\n }\n }\n }\n keyGraph(cachedKeyIds: $cachedKeyIds) {\n ...KeyGraphFragment\n }\n}\n","\n"])),mt,Dt(e),Oe)},ga=y(sa||(sa=M(["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"],["\n mutation CreateRecordContainer(\n $plainMeta: LrJSONString\n $cipherMeta: String\n $parentDirectories: [ParentDirectoryInput!]\n $parentRootDirectory: ParentRootDirectoryInput\n ) {\n new: createDirectory(\n input: {\n plainMeta: $plainMeta\n cipherMeta: $cipherMeta\n parentDirectories: $parentDirectories\n parentRootDirectory: $parentRootDirectory\n }\n ) {\n category: directory {\n id\n keyId\n }\n }\n }\n"]))),ma=y(oa||(oa=M(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Sa=y(ca||(ca=M(["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"],["\n mutation UpdateRecord($input: UpdateDirectoryInput!) {\n updateDirectory(input: $input) {\n directory {\n id\n }\n }\n }\n"]))),Ia=y(ua||(ua=M(["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation UpdateFile($input: UpdateFileInput!) {\n updateFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),Ca=y(pa||(pa=M(["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"],["\n mutation DeleteRecord($recordId: LrRelayIdInput!) {\n deleteDirectory(input: { directoryId: $recordId }) {\n id\n }\n }\n"]))),ba=y(da||(da=M(["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"],["\n mutation CreateFile($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n }\n"]))),ka=y(la||(la=M(["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"],["\n mutation DeleteFile($fileId: LrRelayIdInput!) {\n deleteFile(input: { fileId: $fileId }) {\n id\n }\n }\n"])));(ya=e.AccessLevel||(e.AccessLevel={})).Owner="OWNER",ya.Admin="ADMIN",ya.Writer="WRITER",ya.Reader="READER",ya.Deny="DENY";var Ka=function(){},wa=function(){},Pa=function(){},Da=function(){},Ra=function(){},Ea=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(Ra),Aa=function(){},Oa=function(){},Ta=function(){},Ma=function(){},ja=function(){function t(e,t,n){this.lrApollo=e,this.keyMetaService=t,this.keyGraph=n}return t.prototype.getRootDirectoryIds=function(e){return void 0===e&&(e=null),R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.query({query:bt,variables:{archived:e&&e.archived}})];case 1:return[2,t.sent().rootDirectories.edges.map((function(e){return e.node.id}))]}}))}))},t.prototype.getDefaultVault=function(){return R(this,void 0,void 0,(function(){var e,t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Kt,variables:{plainMetaFilter:ft}})];case 1:return e=n.sent().list,[4,this.mapVaults(e)];case 2:if((t=n.sent()).length>1)throw new ee("There are more than one default vaults");return[2,t[0]||null]}}))}))},t.prototype.getCategories=function(e){return void 0===e&&(e=null),R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:kt,variables:{vaultFilter:ft,categoryFilter:vt,recordFilter:gt,archived:e&&e.archived}})];case 1:if(!((t=n.sent()).vaults.edges.length>1))return[3,2];throw new ee("There is more than one default vault");case 2:return t.vaults.edges.length<1?(console.error("There is no default vault."),[2,[]]):[3,3];case 3:return[4,this.mapCategories(t.vaults.edges[0].node.childDirectoryLinks)];case 4:return[2,n.sent()]}}))}))},t.prototype.getTrustedPartyCategories=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:wt,variables:{trustedPartyId:e,categoryFilter:vt,recordFilter:gt,contentFilter:ha}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.sharedItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.sharedItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getMySharedCategories=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.query({query:Pt,variables:{trustedPartyId:e,categoryFilter:vt,recordFilter:gt,contentFilter:ha}})];case 1:return t=r.sent().tp,n={},[4,this.mapCategories(t.myItems.list)];case 2:return n.categories=r.sent(),[4,this.mapRecords(t.myItems.records)];case 3:return[2,(n.records=r.sent(),n)]}}))}))},t.prototype.getCategory=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return[4,this.lrApollo.query({query:Rt(),variables:{id:e,categoryFilter:vt,recordFilter:gt,contentFilter:ha}})];case 1:return t=p.sent().category,n={},i=(r=Object).assign,s=(a=Object).assign,o=[{}],[4,this.mapCategory(t)];case 2:return c=[s.apply(a,o.concat([p.sent()]))],u={},[4,this.mapParentCategories(t)];case 3:return n.category=i.apply(r,c.concat([(u.parents=p.sent(),u)])),[4,this.mapCategories(t.subCategories)];case 4:return n.subCategories=p.sent(),[4,this.mapRecords(t.records)];case 5:return[2,(n.records=p.sent(),n)]}}))}))},t.prototype.mapVaults=function(e){return R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){return[2,Promise.all(e.edges.map((function(e){return t.mapVault(e.node)})))]}))}))},t.prototype.mapCategories=function(e){return R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapCategory(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.mapRecords=function(e){return R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.edges.map((function(e){return e.node})).map((function(e){return e.childDirectory||e})).map((function(e){return t.mapRecord(e)})))];case 1:return[2,n.sent().filter((function(e){return e})).sort((function(e,t){return e.name===t.name?0:e.name>t.name?1:-1}))]}}))}))},t.prototype.createDefaultVault=function(){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return"",[4,this.keyMetaService.wrapContent("")];case 1:return t=n.sent(),[4,this.lrApollo.mutate({mutation:Ot,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Vault,default:!0}),cipherMeta:t.cipherMeta,parentRootDirectory:t.rootKey}})];case 2:return[2,n.sent().new.vault.id]}}))}))},t.prototype.createCategory=function(t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return n={name:t.name,code:t.code,isCustom:t.isCustom,allowRecords:t.allowRecords,allowCustomCategories:t.allowCustomCategories},[4,this.keyMetaService.wrapContent(n,t.categoryIds)];case 1:return r=i.sent(),[4,this.lrApollo.mutate({mutation:At,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:!1}),cipherMeta:r.cipherMeta,parentDirectories:r.wrappedKeys,parentRootDirectory:r.rootKey}})];case 2:return[2,i.sent().new.category.id]}}))}))},t.prototype.updateCategory=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i;return E(this,(function(a){switch(a.label){case 0:return r={name:n.name,code:n.code,isCustom:n.isCustom,allowRecords:n.allowRecords,allowCustomCategories:n.allowCustomCategories},[4,this.keyGraph.encryptToString(t,r)];case 1:return i=a.sent(),[4,this.lrApollo.mutate({mutation:Tt,variables:{input:{directoryId:e,cipherMeta:i}}})];case 2:return a.sent(),[2]}}))}))},t.prototype.setCategoryVisibility=function(t,n){return R(this,void 0,void 0,(function(){return E(this,(function(r){switch(r.label){case 0:return[4,this.lrApollo.mutate({mutation:Tt,variables:{input:{directoryId:t,plainMeta:JSON.stringify({directoryType:e.DirectoryType.Category,isHidden:n})}}})];case 1:return r.sent(),[2]}}))}))},t.prototype.deleteCategory=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Mt,variables:{categoryId:e}})];case 1:return t.sent(),[2]}}))}))},t.prototype.archiveCategory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.archiveDirectory(e,t)]}))}))},t.prototype.unarchiveCategory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.unarchiveDirectory(e,t)]}))}))},t.prototype.archiveDirectory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:jt,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.unarchiveDirectory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:$t,variables:{input:{directoryId:e,recursive:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapVault=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(e)];case 1:return t=(r.sent()||{}).name,[2,{id:e.id,keyId:e.keyId,name:t}];case 2:return n=r.sent(),console.error("Failed to decrypt Vault.",n,e),[2,null];case 3:return[2]}}))}))},t.prototype.mapParentCategories=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return e.parentCategories&&e.parentCategories.edges&&e.parentCategories.edges.length?(t=e.parentCategories.edges[0].node.parentDirectory,[4,this.mapParentCategories(t)]):[2,[]];case 1:return n=[r.sent()],[4,this.mapCategory(t)];case 2:return[2,T.apply(void 0,n.concat([[r.sent()]]))]}}))}))},t.prototype.mapCategory=function(t){var n;return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d;return E(this,(function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),[4,this.keyMetaService.decryptMeta(t)];case 1:return r=l.sent()||{},i=r.name,a=r.isCustom,s=r.allowRecords,o=r.allowCustomCategories,c=r.code,u=(t.plainMeta&&JSON.parse(t.plainMeta)||{}).isHidden,p=t.accessRoles&&t.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:t.id,keyId:t.keyId,code:c,name:i,isHidden:!!u,isCustom:!!a,isArchived:!!t.archived,allowRecords:!!s,allowCustomCategories:!!o,isEmpty:t.descendantDirectories?0===t.descendantDirectories.recordsCount:null,allRecordsCount:null===(n=t.descendantDirectories)||void 0===n?void 0:n.recordsCount,myAccessLevel:p?e.AccessLevel.Owner:t.accessRoles[0].role,sharedAccess:p?t.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[]}];case 2:return d=l.sent(),console.error("Failed to decrypt Category.",d,t),[2,null];case 3:return[2]}}))}))},t.prototype.mapRecord=function(t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),n=t.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(n.currentVersion.state)];case 1:return r=c.sent()||{},i=r.name,a=r.recordType,s=t.accessRoles&&t.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:t.id,keyId:t.keyId,name:i,recordType:a,isArchived:!!t.archived,createdOn:t.created,lastModified:new Date(t.modified)>new Date(n.currentVersion.state.modified)?t.modified:n.currentVersion.state.modified,myAccessLevel:s?e.AccessLevel.Owner:t.accessRoles[0].role,sharedAccess:s?t.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[]}];case 2:return o=c.sent(),console.error("Failed to decrypt Record.",o),[2,null];case 3:return[2]}}))}))},t}();ja.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new ja(n.ɵɵinject(ge),n.ɵɵinject(Nt),n.ɵɵinject(ve))},token:ja,providedIn:"root"}),ja.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],ja.ctorParameters=function(){return[{type:ge},{type:Nt},{type:ve}]};var $a=function(){},Na=function(){function e(e,t){this.http=e,this.categoryService=t}return e.prototype.getCoreCategories=function(){return R(this,void 0,void 0,(function(){var e;return E(this,(function(t){switch(t.label){case 0:return this.categories?[3,2]:(e=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 1:e.categories=t.sent(),t.label=2;case 2:return[2,Promise.resolve(this.categories)]}}))}))},e.prototype.loadCategories=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p=this;return E(this,(function(d){switch(d.label){case 0:return n?[4,this.categoryService.getTrustedPartyCategories(n)]:[3,2];case 1:return i=d.sent().categories,[3,4];case 2:return[4,this.categoryService.getCategories()];case 3:i=d.sent(),d.label=4;case 4:return r=i,t?[4,this.categoryService.getCategory(t)]:[3,6];case 5:return s=d.sent(),[3,7];case 6:s=null,d.label=7;case 7:return a=s,o=e.map((function(e){return R(p,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t={categoryTree:e},[4,this.loadCategory(T(e),r,a)];case 1:return[2,(t.category=n.sent(),t)]}}))}))})),[4,Promise.all(o)];case 8:return c=d.sent(),u={categories:[],missingCategories:[]},c.forEach((function(e){return e.category?u.categories.push(e.category):u.missingCategories.push(e.categoryTree)})),[2,u]}}))}))},e.prototype.loadCategoriesForRole=function(e){return R(this,void 0,void 0,(function(){var t,n=this;return E(this,(function(r){switch(r.label){case 0:return[4,this.categoryService.getCategories()];case 1:return t=r.sent(),[4,Promise.all(e.map((function(e){return R(n,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return n={},[4,this.loadCategory(T(e.category),t)];case 1:return[2,(n.category=r.sent(),n.accessLevel=e.accessLevel,n)]}}))}))})))];case 2:return[2,r.sent()]}}))}))},e.prototype.loadCategory=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return r=e.shift(),(i=t.find((function(e){return e.code===r&&!e.isCustom})))?e.length?[4,this.categoryService.getCategory(i.id)]:[3,2]:[3,5];case 1:return a=o.sent().subCategories,[2,this.loadCategory(e,a,n)];case 2:return[4,this.categoryService.getCategory(i.id)];case 3:return s=o.sent().category,n&&n.category.parents.some((function(e){return e.id===s.id}))?[2,n.category]:[2,s];case 4:return[3,6];case 5:return e.length?[2,this.loadCategory(e,t,n)]:[2,null];case 6:return[2]}}))}))},e}();Na.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Na(n.ɵɵinject(t.HttpClient),n.ɵɵinject(ja))},token:Na,providedIn:"root"}),Na.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Na.ctorParameters=function(){return[{type:t.HttpClient},{type:ja}]};var Fa=function(){function t(e,t,n,r){this.fileService=e,this.lrApollo=t,this.keyMetaService=n,this.keyGraph=r}return t.prototype.downloadAttachment=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return[4,this.fileService.downloadEncryptedFile(e)];case 1:return n=r.sent(),[4,this.keyGraph.decryptFile(t,n)];case 2:return[2,r.sent()]}}))}))},t.prototype.uploadAttachments=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){switch(r.label){case 0:return[4,Promise.all((t||[]).map((function(t){return R(n,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return t.fileId?t.isDeleted?[4,this.deleteAttachment(t.fileId)]:[3,2]:[3,4];case 1:return n.sent(),[2,null];case 2:return[2,t.fileId];case 3:return[3,6];case 4:return[4,this.addAttachment(e,t)];case 5:return[2,n.sent()];case 6:return[2]}}))}))})))];case 1:return[2,r.sent().filter((function(e){return e}))]}}))}))},t.prototype.addAttachment=function(t,n){return R(this,void 0,void 0,(function(){var r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return r={name:n.name,fieldId:n.fieldId,fileType:n.file.type,fileSize:n.file.size,lastModified:n.file.lastModified},[4,this.fileService.loadFile(n.file)];case 1:return i=o.sent(),[4,this.keyMetaService.doubleWrapContent(r,[t],i)];case 2:return a=o.sent(),[4,this.fileService.uploadEncryptedFile({encryptedContent:a.cipherFileContent,fileName:n.name})];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:ba,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordAttachment}),wrappedStateKey:a.doubleWrappedKey,cipherMeta:a.cipherMeta,parentDirectories:a.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}})),contentResource:s}}})];case 4:return[2,o.sent().createFile.file.id]}}))}))},t.prototype.deleteAttachment=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:ka,variables:{fileId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Fa.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Fa(n.ɵɵinject(pi),n.ɵɵinject(ge),n.ɵɵinject(Nt),n.ɵɵinject(ve))},token:Fa,providedIn:"root"}),Fa.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Fa.ctorParameters=function(){return[{type:pi},{type:ge},{type:Nt},{type:ve}]};var La,xa=function(){},Ua=function(){},Ja=function(){},_a=function(){},qa=function(){},Ga=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(_a),Ba=function(){},Qa=function(){function t(e,t,n,r){this.lrApollo=e,this.keyMetaService=t,this.categoryService=n,this.recordAttachmentService=r}return t.prototype.getRecord=function(t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d=this;return E(this,(function(l){switch(l.label){case 0:return[4,this.lrApollo.query({query:va(),variables:{id:t,categoryFilter:vt,contentFilter:ha,attachmentsFilter:fa}})];case 1:return n=l.sent().record,r=n.content.edges[0].node.childFile,[4,this.keyMetaService.decryptMeta(r.currentVersion.state)];case 2:return i=l.sent()||{},a=i.name,s=i.recordType,o=i.fields,[4,Promise.all(n.parentCategories.edges.map((function(e){return R(d,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.categoryService.mapParentCategories(e.node.parentDirectory)];case 1:return t=[n.sent()],[4,this.categoryService.mapCategory(e.node.parentDirectory)];case 2:return[2,T.apply(void 0,t.concat([[n.sent()]]))]}}))}))})))];case 3:return c=l.sent(),[4,this.mapAttachments(n.attachments.edges)];case 4:return u=l.sent(),p=n.accessRoles&&n.accessRoles.some((function(t){return t.role===e.AccessLevel.Owner})),[2,{id:n.id,keyId:n.keyId,updateKeyId:r.keyId,updateId:r.id,name:a,recordType:s,fields:o,categories:c,attachments:u,myAccessLevel:p?e.AccessLevel.Owner:n.accessRoles[0].role,sharedAccess:p?n.accessRoles.filter((function(t){return t.role!==e.AccessLevel.Owner})).map((function(e){return{trustedPartyId:e.trustedParty&&e.trustedParty.id,accessLevel:e.role,isInherited:"inherited"===e.method,inheritedFrom:e.inheritedFrom&&e.inheritedFrom.id}})):[],isArchived:!!n.archived,createdOn:n.created,lastModified:new Date(n.modified)>new Date(r.currentVersion.state.modified)?n.modified:r.currentVersion.state.modified}]}}))}))},t.prototype.mapAttachments=function(e){return R(this,void 0,void 0,(function(){var t=this;return E(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return e.node.childFile})).map((function(e){return R(t,void 0,void 0,(function(){var t,n,r,i,a,s;return E(this,(function(o){switch(o.label){case 0:return[4,this.keyMetaService.decryptMeta(e.currentVersion.state)];case 1:return t=o.sent()||{},n=t.name,r=t.fieldId,i=t.fileType,a=t.fileSize,s=t.lastModified,[2,{fileId:e.id,keyId:e.currentVersion.state.keyId,contentId:e.currentVersion.state.id,fieldId:r,name:n,fileType:i,fileSize:a,lastModified:s}]}}))}))})))];case 1:return[2,n.sent()]}}))}))},t.prototype.createRecord=function(t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return[4,this.keyMetaService.wrapContent(null,t.categoryIds)];case 1:return n=c.sent(),[4,this.lrApollo.mutate({mutation:ga,variables:{plainMeta:JSON.stringify({directoryType:e.DirectoryType.Record,isHidden:!1}),parentDirectories:n.wrappedKeys,parentRootDirectory:n.rootKey}})];case 2:return r=c.sent(),i=r.new.category.id,a={name:t.name,recordType:t.recordType,fields:t.fields},[4,this.keyMetaService.doubleWrapContent(a,[i])];case 3:return s=c.sent(),[4,this.lrApollo.mutate({mutation:ma,variables:{input:{plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta,parentDirectories:s.wrappedKeys.map((function(e){return{directoryId:e.directoryId,wrappingKeyId:e.wrappingKeyId,wrappedFileKey:e.wrappedKey}}))}}})];case 4:c.sent(),c.label=5;case 5:return c.trys.push([5,7,,8]),[4,this.recordAttachmentService.uploadAttachments(i,t.attachments)];case 6:return c.sent(),[3,8];case 7:return o=c.sent(),console.error(o),[2,{recordId:i,attachmentError:o}];case 8:return[2,{recordId:i}]}}))}))},t.prototype.updateRecord=function(t,n,r,i){return R(this,void 0,void 0,(function(){var a,s,o;return E(this,(function(c){switch(c.label){case 0:return a={name:i.name,recordType:i.recordType,fields:i.fields},[4,this.keyMetaService.reWrapContent(r,a)];case 1:return s=c.sent(),[4,this.lrApollo.mutate({mutation:Ia,variables:{input:{fileId:n,plainMeta:JSON.stringify({fileType:e.FileType.RecordContent}),wrappedStateKey:s.doubleWrappedKey,cipherMeta:s.cipherMeta}}})];case 2:c.sent(),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,this.recordAttachmentService.uploadAttachments(t,i.attachments)];case 4:return c.sent(),[3,6];case 5:return o=c.sent(),console.error(o),[2,{recordId:t,attachmentError:o}];case 6:return[2,{recordId:t}]}}))}))},t.prototype.archiveRecord=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.categoryService.archiveDirectory(e,!0)]}))}))},t.prototype.unarchiveRecord=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.categoryService.unarchiveDirectory(e,!0)]}))}))},t.prototype.deleteRecord=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ca,variables:{recordId:e}})];case 1:return t.sent(),[2]}}))}))},t}();Qa.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Qa(n.ɵɵinject(ge),n.ɵɵinject(Nt),n.ɵɵinject(ja),n.ɵɵinject(Fa))},token:Qa,providedIn:"root"}),Qa.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Qa.ctorParameters=function(){return[{type:ge},{type:Nt},{type:ja},{type:Fa}]},(La=e.RecordFieldType||(e.RecordFieldType={})).Text="text",La.Email="email",La.Url="url",La.Phone="phone",La.Date="date",La.Password="password",La.TextArea="textArea",La.Select="select",La.SingleChoice="singleChoice",La.MultiChoice="multiChoice",La.File="file",La.MultiFile="multiFile",La.Record="record",La.MultiRecord="multiRecord",La.Group="group",La.Custom="custom";var Va=function(){},Wa=function(){},Za=function(){},Ha=function(){},Ya=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0},za=Ya,Xa=function(){function e(e){this.http=e}return e.prototype.getRecordTypes=function(){return R(this,void 0,void 0,(function(){var e,t,n,r,i=this;return E(this,(function(a){switch(a.label){case 0:return this.recordTypes?[3,2]:(e=this,[4,this.http.get("/assets/meta/record-types.json").toPromise()]);case 1:e.recordTypes=a.sent(),a.label=2;case 2:return this.categories?[3,4]:(t=this,[4,this.http.get("/assets/meta/categories.json").toPromise()]);case 3:t.categories=a.sent(),a.label=4;case 4:return n=this.categories.map((function(e){return e.subCategories})).reduce((function(e,t){return T(e,t)}),[]),r=this.recordTypes.map((function(e){return Object.assign(Object.assign({},e),{categoryNames:e.categories.map((function(e){return e.map((function(e){var t=n.find((function(t){return t.code===e}));return t?t.name:i.categories.find((function(t){return t.code===e})).name}))}))})})),[2,Promise.resolve(r)]}}))}))},e.prototype.getRecordType=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().find((function(t){return t.id===e}))]}}))}))},e.prototype.getRecordTypesForCategory=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.getRecordTypes()];case 1:return[2,t.sent().filter((function(t){return t.categories.some((function(t){return Ya(t,e)}))}))]}}))}))},e}();Xa.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Xa(n.ɵɵinject(t.HttpClient))},token:Xa,providedIn:"root"}),Xa.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Xa.ctorParameters=function(){return[{type:t.HttpClient}]};var es,ts,ns,rs=function(){};(es=e.TrustedPartyRoleType||(e.TrustedPartyRoleType={})).General="general",es.Scenario="scenario",(ts=e.TrustedPartyType||(e.TrustedPartyType={})).User="user",ts.Organisation="organisation",(ns=e.TrustedPartyInviteStatus||(e.TrustedPartyInviteStatus={})).Invited="IN_PROGRESS",ns.Cancelled="CANCELLED",ns.Declined="DECLINED",ns.Completed="COMPLETED";var is,as=function(){},ss=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(tt),os=function(){},cs=function(){},us=function(){},ps=function(){},ds=function(){},ls=function(){},ys=function(){},hs=function(){},fs="\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",vs=y(is||(is=M(["\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}"])),fs),gs=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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var t,n,r;return E(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 R(this,void 0,void 0,(function(){var i,a,s,o,c,u,p,d,l,y,h;return E(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(),[4,this.keyService.getCurrentSigPxk()];case 3:return s=f.sent(),[4,this.encryptionService.encrypt(a.jwk,r)];case 4:return o=f.sent(),p=(u=JSON).stringify,[4,this.encryptionService.sign(s.jwk,o)];case 5:return c=p.apply(u,[f.sent()]),d={name:new Ve(r.name)},h=(y=JSON).stringify,[4,this.encryptionService.sign(s.jwk,d)];case 6:return l=h.apply(y,[f.sent()]),[4,this.lrApollo.mutate({mutation:vs,variables:{input:{id:e,ownerCipherData:"",ownerKeyId:i.id,sharedCipherDataSig:c,sharedKeyId:a.id,sigPxkId:s.id,ownerPlainDataSig:l}}})];case 7:return f.sent(),[2]}}))}))},e}();gs.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new gs(n.ɵɵinject(fe),n.ɵɵinject(ge),n.ɵɵinject(ve),n.ɵɵinject(de))},token:gs,providedIn:"root"}),gs.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],gs.ctorParameters=function(){return[{type:fe},{type:ge},{type:ve},{type:de}]};var ms,Ss,Is,Cs,bs,ks,Ks,ws,Ps,Ds="\n id\n user {\n id\n username\n }\n other{\n id\n username,\n features {\n shareVault\n }\n }\n sharedContactCard {\n "+fs+"\n }\n myContactCard {\n "+fs+"\n }\n sharedScenarios {\n edges {\n node {\n id\n }\n }\n }\n sharedItems {\n directories {\n edges {\n node {\n id\n }\n }\n }\n }\n currentUserSharedKey {\n userSharedKey {\n keyExchange {\n "+Ri+"\n }\n "+Ei+"\n }\n }",Rs=y(ms||(ms=M(["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"],["\nquery GetTrustedPartiesQuery {\n tps {\n edges {\n node {\n ","\n }\n }\n }\n ","\n}"])),Ds,Te),Es=y(Ss||(Ss=M(["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"],["\nquery GetAllTrustedPartiesQuery($userId: ID, $isExpired: Boolean, $inviteState: String, $sentInviteState: String) {\n tps {\n edges {\n node {\n ",'\n }\n }\n }\n invites: keyExchanges(\n responder: $userId\n isExpired: $isExpired\n state: $inviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ','\n }\n }\n }\n sentInvites: keyExchanges(\n initiator: $userId\n isExpired: $isExpired\n state: $sentInviteState\n orderBy: "state,-created"\n ) {\n edges {\n node {\n ',"\n }\n }\n }\n ","\n}"])),Ds,Ri,Ri,Te),As=y(Is||(Is=M(["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"],["\nquery GetTrustedPartyQuery($partyId: LrRelayIdInput!) {\n tp(id: $partyId) {\n ","\n }\n ","\n}"])),Ds,Te),Os=y(Cs||(Cs=M(["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation DeclineKeyExchange($input: DeclineKeyExchangeInput!) {\n declineKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Ts=y(bs||(bs=M(["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"],["\n mutation CancelKeyExchange($input: CancelKeyExchangeInput!) {\n cancelKeyExchange(input: $input) {\n keyExchange {\n id\n }\n }\n }\n"]))),Ms=y(ks||(ks=M(["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"],["\n mutation DeleteTpMutation($input: DeleteTpInput!) {\n deleteTp(input: $input) {\n id\n }\n }\n"]))),js=y(Ks||(Ks=M(["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation ShareDirectory($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"]))),$s=y(ws||(ws=M(["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"],["\n mutation UnshareDirectory($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n item {\n plainMeta\n }\n }\n }\n }\n"]))),Ns=function(){function t(e,t,n,r,i,a,s,o,c,u){this.http=e,this.lrApollo=t,this.sharedContactCardService=n,this.userService=r,this.authService=i,this.keyExchangeService=a,this.keyGraphService=s,this.keyService=o,this.keyFactory=c,this.encryptionService=u}return t.prototype.getTrustedParties=function(){return R(this,void 0,void 0,(function(){var e,t=this;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:Rs})];case 1:return e=n.sent().tps,[4,Promise.all(e.edges.map((function(e){return t.mapTrustedParty(e.node)})))];case 2:return[2,n.sent()]}}))}))},t.prototype.getAllTrustedParties=function(){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o=this;return E(this,(function(c){switch(c.label){case 0:return[4,this.authService.getUser()];case 1:return t=c.sent(),[4,this.lrApollo.query({query:Es,variables:{userId:t.id,isExpired:!1}})];case 2:return n=c.sent(),r=n.tps,i=n.invites,a=n.sentInvites,s={},[4,Promise.all(r.edges.map((function(e){return o.mapTrustedParty(e.node)})))];case 3:return s.parties=c.sent().filter((function(e){return e})),[4,Promise.all(i.edges.map((function(e){return R(o,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 4:return s.invites=c.sent().filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Completed})).filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Invited||t.actionRequired})),[4,Promise.all(a.edges.map((function(e){return R(o,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t=this.mapInvite,[4,this.keyExchangeService.decryptKeyExchange(e.node)];case 1:return[2,t.apply(this,[n.sent()])]}}))}))})))];case 5:return[2,(s.sentInvites=c.sent().filter((function(t){return t.status!==e.TrustedPartyInviteStatus.Completed})),s)]}}))}))},t.prototype.getTrustedParty=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.query({query:As,variables:{partyId:e}})];case 1:return t=n.sent().tp,[4,this.mapTrustedParty(t)];case 2:return[2,n.sent()]}}))}))},t.prototype.getTrustedPartyRoles=function(t){return void 0===t&&(t=e.TrustedPartyRoleType.General),R(this,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return this.trustedPartyRoles?[3,2]:(e=this,[4,this.http.get("/assets/meta/trusted-party-roles.json").toPromise()]);case 1:e.trustedPartyRoles=n.sent(),n.label=2;case 2:return[2,Promise.resolve(this.trustedPartyRoles.filter((function(e){return e.roleType===t})))]}}))}))},t.prototype.findByEmail=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.userService.getUserByEmail(e)];case 1:return[2,(t=n.sent())?{id:t.id,email:e,username:t.username,isTrustedParty:t.haveTp,isMe:t.isCurrentUser}:null];case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.inviteTrustedParty=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t={responderUsername:e.party.username,email:e.party.email,message:{name:e.party.name,email:e.party.email,message:e.party.message,permissions:e.permissions},contactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new Ve(e.mySharedDetails.name)}}},[4,this.keyExchangeService.initiateOtk(t)];case 1:return n.sent(),[2]}}))}))},t.prototype.cancelInvitation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ts,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.getInvitation=function(e,t,n){return R(this,void 0,void 0,(function(){var r;return E(this,(function(i){switch(i.label){case 0:return[4,this.keyExchangeService.getKeyExchange(e,{token:t,otKeyK:n})];case 1:return r=i.sent(),[2,this.mapInvite(r)]}}))}))},t.prototype.acceptInvitation=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return t={id:e.inviteId,token:e.inviteToken,decryptedOtk:e.decryptedOtk,initiatorContactCard:null,responderContactCard:{plainOwnerCipherDataJson:null,plainSharedCipherDataJson:e.mySharedDetails,ownerPlainData:{name:new Ve(e.mySharedDetails.name)}}},[4,this.keyExchangeService.respondOtk(t)];case 1:return[2,n.sent().tp.id]}}))}))},t.prototype.declineInvitation=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:Os,variables:{input:{id:e,token:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.confirmInvitation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.keyExchangeService.completeOtk(e.inviteId,e.initiatorRootKeyCipher,e.initiatorOneTimePbkCipher,null)];case 1:return[2,t.sent().tp.id]}}))}))},t.prototype.removeTrustedParty=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrApollo.mutate({mutation:Ms,variables:{input:{id:e}}})];case 1:return t.sent(),[2]}}))}))},t.prototype.setCategoryAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},t.prototype.setRecordAccessLevel=function(e,t,n,r){return r?this.shareDirectory(e,t,n,r):this.unshareDirectory(e,n.id)},t.prototype.shareDirectory=function(e,t,n,r){return R(this,void 0,void 0,(function(){var i,a,s;return E(this,(function(o){switch(o.label){case 0:return[4,this.keyGraphService.getKey(t)];case 1:return i=o.sent(),[4,this.keyGraphService.getKey(n.userSharedKey.sharedKey.id)];case 2:return a=o.sent(),[4,this.encryptionService.encrypt(a.jwk,i.jwk.toJSON(!0))];case 3:return s=o.sent(),[4,this.lrApollo.mutate({mutation:js,variables:{input:{id:e,tpId:n.id,accessRole:r,keyId:i.id,wrappingKeyId:a.id,wrappedKey:JSON.stringify(s)}}})];case 4:return o.sent(),[2]}}))}))},t.prototype.unshareDirectory=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.lrApollo.mutate({mutation:$s,variables:{input:{id:e,tpId:t}}})];case 1:return n.sent(),[2]}}))}))},t.prototype.mapTrustedParty=function(t){var n;return R(this,void 0,void 0,(function(){var r,i,a,s,o;return E(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),(i=t.sharedContactCard)?[4,this.sharedContactCardService.decryptTrustedPartyDetails(t.sharedContactCard)]:[3,2];case 1:i=c.sent(),c.label=2;case 2:return r=i,(s=t.myContactCard)?[4,this.sharedContactCardService.decryptSharedTrustedPartyDetails(t.myContactCard)]:[3,4];case 3:s=c.sent(),c.label=4;case 4:return a=s,[2,{id:t.id,type:e.TrustedPartyType.User,hasScenarios:!!t.sharedScenarios.edges.length,hasSharedVault:!!t.sharedItems.directories.edges.length,name:r&&r.name&&r.name.name,details:r,mySharedDetails:a,userSharedKey:t.currentUserSharedKey.userSharedKey,username:t.other.username,features:{sharedVault:{hasAccess:"access"===((null===(n=t.other.features)||void 0===n?void 0:n.shareVault)||["noaccess"])[0]}}}];case 5:return o=c.sent(),console.error("Failed to decrypt Trusted Party.",o,t),[2,null];case 6:return[2]}}))}))},t.prototype.mapInvite=function(t){var n,r;return R(this,void 0,void 0,(function(){var i,a,s;return E(this,(function(o){return i=t.contactCard,a=t.isInitiator?null===(n=t.myMessage)||void 0===n?void 0:n.name:i&&i.name&&i.name.name,s=t.isInitiator?null===(r=t.myMessage)||void 0===r?void 0:r.email:i&&i.email||t.responderEmailAddress,[2,{id:t.id,type:e.TrustedPartyType.User,status:t.state,token:t.token,tokenExpiry:t.tokenExpiryTime,decryptedOtk:t.decryptedOtk,name:a,email:s,isSender:t.isInitiator,actionRequired:t.isInitiator?t.initiatorActionRequired:t.responderActionRequired,rootKeyCipher:t.initiatorRootKeyCipher,pbkCipher:t.otk.initiatorOneTimePbkCipher,isExpired:t.isExpired,details:i,message:t.message,mySharedDetails:t.myContactCard,mySharedMessage:t.myMessage}]}))}))},t}();Ns.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ns(n.ɵɵinject(t.HttpClient),n.ɵɵinject(ge),n.ɵɵinject(gs),n.ɵɵinject(Si),n.ɵɵinject(ui),n.ɵɵinject(Fi),n.ɵɵinject(ve),n.ɵɵinject(fe),n.ɵɵinject(ye),n.ɵɵinject(de))},token:Ns,providedIn:"root"}),Ns.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ns.ctorParameters=function(){return[{type:t.HttpClient},{type:ge},{type:gs},{type:Si},{type:ui},{type:Fi},{type:ve},{type:fe},{type:ye},{type:de}]},function(e){e.Name="name",e.Email="email",e.Image="image",e.Phone="phone",e.Address="address"}(Ps||(Ps={}));var Fs=[Ps.Name,Ps.Email,Ps.Image,Ps.Phone,Ps.Address],Ls=function(){function e(e,t,n,r){this.sharedContactCardService=e,this.trustedPartyService=t,this.profileService=n,this.authService=r}return e.prototype.updateDetails=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.authService.getUser()];case 1:return t=n.sent(),[4,this.profileService.updateDetails(t.contactCard.id,t.contactCard.keyId,e)];case 2:return n.sent(),[4,this.synchronizeContactCards(e,t.contactCard)];case 3:return n.sent(),[4,this.authService.getUser(!0)];case 4:return[2,n.sent()]}}))}))},e.prototype.synchronizeContactCards=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return t?0===(n=this.getChanges(e,t)).length?[2]:[4,this.trustedPartyService.getTrustedParties()]:[2];case 1:if(0===(r=p.sent()).length)return[2];p.label=2;case 2:p.trys.push([2,7,8,9]),i=A(r.map((function(e){return e.mySharedDetails}))),a=i.next(),p.label=3;case 3:return a.done?[3,6]:(s=a.value,[4,this.synchronizeSharedContactCard(s,n)]);case 4:p.sent(),p.label=5;case 5:return a=i.next(),[3,3];case 6:return[3,9];case 7:return o=p.sent(),c={error:o},[3,9];case 8:try{a&&!a.done&&(u=i.return)&&u.call(i)}finally{if(c)throw c.error}return[7];case 9:return[2]}}))}))},e.prototype.getChanges=function(e,t){var n,r,i,a,s=[];try{for(var o=A(Fs),c=o.next();!c.done;c=o.next()){var u=c.value,p=t[u];if(p&&p.values){var d=function(t){var n=e[u].values.find((function(e){return e.id===t.id}));n?b.isEqual(n.value,t.value)||s.push({field:u,id:t.id,label:t.label,oldValue:t.value,newValue:n.value}):s.push({field:u,id:t.id,label:t.label,oldValue:t.value})};try{for(var l=(i=void 0,A(p.values)),y=l.next();!y.done;y=l.next()){d(y.value)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=l.return)&&a.call(l)}finally{if(i)throw i.error}}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},e.prototype.synchronizeSharedContactCard=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l;return E(this,(function(y){switch(y.label){case 0:n=!1,r=function(t){switch(t.field){case Ps.Phone:(r=e.phones&&e.phones.find((function(e){return e.label===t.label})))&&(n=!0,r.value=t.newValue);break;case Ps.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];b.isEqual(r,t.oldValue)&&(n=!0,e[t.field]=t.newValue)}};try{for(i=A(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=P(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(o,c,u,p)]):[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},e.prototype.updateTrustedPartyDetails=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(this,(function(a){switch(a.label){case 0:return t=e.id,n=e.ownedKeyId,r=e.sharedKeyId,i=P(e,["id","ownedKeyId","sharedKeyId"]),[4,this.sharedContactCardService.updateMySharedContactCard(t,n,r,i)];case 1:return a.sent(),[4,this.synchronizeSharedDetails(e)];case 2:return a.sent(),[2]}}))}))},e.prototype.synchronizeSharedDetails=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d,l,y;return E(this,(function(h){switch(h.label){case 0:return[4,this.authService.getUser()];case 1:if(t=h.sent().contactCard,n=!1,t=Object.assign({},t),e.name&&(u=this.checkField(e.name,t.name))&&(t.name=u,n=!0),e.email&&(u=this.checkField(e.email,t.email))&&(t.email=u,n=!0),e.image&&(u=this.checkField(e.image,t.image))&&(t.image=u,n=!0),e.phones&&e.phones.length)try{for(r=A(e.phones),i=r.next();!i.done;i=r.next())a=i.value,(u=this.checkField(a.value,t.phone,a.label))&&(t.phone=u,n=!0)}catch(e){p={error:e}}finally{try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(p)throw p.error}}if(e.addresses&&e.addresses.length)try{for(s=A(e.addresses),o=s.next();!o.done;o=s.next())c=o.value,(u=this.checkField(c.value,t.address,c.label))&&(t.address=u,n=!0)}catch(e){l={error:e}}finally{try{o&&!o.done&&(y=s.return)&&y.call(s)}finally{if(l)throw l.error}}return n?[4,this.profileService.updateDetails(t.id,t.keyId,t)]:[3,3];case 2:h.sent(),h.label=3;case 3:return[2]}}))}))},e.prototype.checkField=function(e,t,n){return void 0===n&&(n=null),(t=t||{value:e,hasMultiple:!1}).values=t.values||[],0===t.values.length||t.values.every((function(t){return!b.isEqual(e,t.value)}))?(t.values.push({id:n+"-"+(new Date).getTime(),label:n,value:e}),t.hasMultiple=t.values.length>1,t.value=t.value||e,t):null},e}();Ls.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new Ls(n.ɵɵinject(gs),n.ɵɵinject(Ns),n.ɵɵinject(vn),n.ɵɵinject(ui))},token:Ls,providedIn:"root"}),Ls.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],Ls.ctorParameters=function(){return[{type:gs},{type:Ns},{type:vn},{type:ui}]};var xs=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:te,useValue:t},{provide:d.AuthClass,useValue:k},{provide:n.APP_INITIALIZER,useFactory:Zi,deps:[te,d.AuthClass],multi:!0},{provide:n.APP_INITIALIZER,useFactory:ci,deps:[ui],multi:!0},{provide:l.APOLLO_OPTIONS,useFactory:re,deps:[te,d.AuthClass]}]}},e}();xs.decorators=[{type:n.NgModule,args:[{imports:[t.HttpClientModule,m.NgIdleKeepaliveModule.forRoot()],providers:[f.CookieService,ce,pi,vn,na,ui,qn,le,de,ve,fe,ye]}]}];var Us,Js,_s,qs,Gs,Bs,Qs=function(){},Vs=function(){},Ws=function(){},Zs=function(){},Hs=function(){},Ys=En(Us||(Us=M(["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"],["\n fragment ContactCardFragment on ContactCardNode {\n id\n publicData\n publicSearchable\n cipherData\n key {\n id\n }\n }\n"]))),zs=En(Js||(Js=M(["\n mutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n ) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"],["\n mutation CreateContactCardMutation(\n $input: CreateContactCardInput!\n ) {\n createContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"]))),Xs=En(_s||(_s=M(["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"],["\n mutation UpdateContactCardMutation($input: UpdateContactCardInput!) {\n updateContactCard(input: $input) {\n contactCard {\n id\n }\n }\n }\n"]))),eo=En(qs||(qs=M(["\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"]))),to=(En(Gs||(Gs=M(['\n query ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n ...ContactCardFragment\n }\n }\n }\n }\n ',"\n"],['\n query ContactCardsQuery {\n contactCards(orderBy: "created") {\n edges {\n node {\n ...ContactCardFragment\n }\n }\n }\n }\n ',"\n"])),Ys),En(Bs||(Bs=M(["\n query ContactCardQuery($id: LrRelayIdInput!) {\n contactCard(id: $id) {\n ...ContactCardFragment\n }\n }\n ","\n"],["\n query ContactCardQuery($id: LrRelayIdInput!) {\n contactCard(id: $id) {\n ...ContactCardFragment\n }\n }\n ","\n"])),Ys),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 R(this,void 0,void 0,(function(){var t,n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=s.sent(),[4,this.keyFactory.createKey()];case 2:return n=s.sent(),[4,this.keyGraph.encryptToString(t.jwk,n.toJSON(!0))];case 3:return r=s.sent(),[4,this.keyGraph.encryptToString(n,e.plainCipherDataJson)];case 4:return i=s.sent(),[4,this.prepareContactCardInput(e)];case 5:return a=s.sent(),[2,new Tr({mutation:zs,variables:{input:Object.assign(Object.assign({},a),{wrappingKeyId:t.id,wrappedKey:r,cipherData:i})}})]}}))}))},e.prototype.updateContactCard=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(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 Tr({mutation:Xs,variables:{input:Object.assign(Object.assign({},n),{id:e.id,cipherData:t})}})]}}))}))},e.prototype.deleteContactCard=function(e){return new Tr({mutation:eo,variables:{input:{id:e}}})},e.prototype.prepareContactCardInput=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p;return E(this,(function(d){switch(d.label){case 0:return[4,this.keyService.getCurrentSigPxk()];case 1:return t=d.sent(),i=(r=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicDataJson)];case 2:return n=i.apply(r,[d.sent()]),o=(s=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.publicSearchableJson)];case 3:return a=o.apply(s,[d.sent()]),p=(u=JSON).stringify,[4,this.encryptionService.sign(t.jwk,e.plainDataJson)];case 4:return c=p.apply(u,[d.sent()]),[2,{sigPxkId:t.id,publicDataSig:n,publicSearchableSig:a,plainDataSig:c}]}}))}))},e}(),e.ContactCard2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ContactCard2Service(n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(Nt),n.ɵɵinject(n.NgZone))},token:e.ContactCard2Service,providedIn:"root"}),e.ContactCard2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ContactCard2Service.ctorParameters=function(){return[{type:ye},{type:fe},{type:de},{type:ve},{type:Nt},{type:n.NgZone}]},e.ContactCard2Service=D([br({ngZoneName:"ngZone"})],e.ContactCard2Service);var no,ro,io,ao,so,oo,co,uo,po,lo,yo,ho=En(no||(no=M(["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"],["\nfragment KeyExchangeFragment on KeyExchangeNode {\n id\n token\n state\n mode\n isInitiator\n initiator {\n id\n username\n }\n responder {\n id\n username\n }\n created\n modified\n tokenExpiryTime\n isExpired\n initiatorRootKeyCipher\n initiatorActionRequired\n responderActionRequired\n responderEmailAddress\n otk {\n state\n otKeyParams\n otKeyCipher\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n initiatorSigPxk {\n id\n }\n responderSigPxk {\n id\n }\n initiatorOneTimePbkCipher\n responderPbkCipher\n }\n}\n"]))),fo=En(ro||(ro=M(["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"],["\nfragment UserSharedKeyFragment on UserSharedKeyNode {\n userSigPrk {\n id\n }\n otherSigPbk {\n id\n }\n sharedKey {\n id\n }\n mkSharedKey {\n id\n }\n}"]))),vo=En(io||(io=M(["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"],["\nquery KeyExchangesQuery2($state: String) {\n keyExchanges(state: $state) {\n edges {\n node {\n ...KeyExchangeFragment\n }\n }\n }\n}\n","\n"])),ho),go=En(ao||(ao=M(["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeQuery2($id: LrRelayIdInput!) {\n keyExchange(id: $id) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),ho),mo=En(so||(so=M(["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"],["\nquery KeyExchangeTokenQuery2($id: LrRelayIdInput!, $token: String) {\n keyExchange(id: $id, token: $token) {\n ...KeyExchangeFragment\n }\n}\n","\n"])),ho),So=En(oo||(oo=M(["\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"]))),Io=En(co||(co=M(["\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"]))),Co=En(uo||(uo=M(["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"],["\nmutation InitiateKeyExchangeOtkMutation(\n $input: InitiateKeyExchangeOtkInput!\n) {\n initiateKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n }\n}\n","\n"])),ho),bo=En(po||(po=M(["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation RespondKeyExchangeOtkMutation($input: RespondKeyExchangeOtkInput!) {\n respondKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),ho,fo),ko=En(lo||(lo=M(["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"],["\nmutation CompleteKeyExchangeOtkMutation(\n $input: CompleteKeyExchangeOtkInput!\n) {\n completeKeyExchangeOtk(input: $input) {\n keyExchange {\n ...KeyExchangeFragment\n }\n userSharedKey {\n ...UserSharedKeyFragment\n }\n tp {\n id\n }\n }\n}\n","\n","\n"])),ho,fo),Ko=En(yo||(yo=M(["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n","\n"],["\nquery CurrentUserSharedKeyQuery2(\n $username: String\n $userId: LrRelayIdInput\n) {\n currentUserSharedKey(\n username: $username\n userId: $userId\n ) {\n userSharedKey {\n ...UserSharedKeyFragment\n }\n }\n}\n","\n"])),fo);e.KeyExchange2Service=function(){function e(e,t,n,r,i,a,s){this.ngZone=e,this.keyFactory=t,this.keyService=n,this.encryptionService=r,this.userService=i,this.keyGraph=a,this.lrGraphQL=s,this.CLIENT_NONCE_LENGTH=32}return e.prototype.getOtKey=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return t?[4,ye.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,6]:[4,this.keyService.getCurrentPxk()];case 3:return n=i.sent(),[4,this.encryptionService.decrypt(n.jwk,JSON.parse(e.otk.responderPbkCipher),{serializations:[ae.COMPACT]})];case 4:return(r=i.sent()).otKey?[4,ye.asKey(r.otKey)]:[3,6];case 5:return[2,i.sent()];case 6:return[2,null]}}))}))},e.prototype.decryptOtk=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o;return E(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})]}}))}))},e.prototype.decryptResponseCipher=function(e,t,n){return R(this,void 0,void 0,(function(){var r;return E(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()]}}))}))},e.prototype.decryptKeyExchangeAsInitiator=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p,d;return E(this,(function(l){switch(l.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return t=l.sent(),[4,this.encryptionService.decrypt(t.jwk,e.initiatorRootKeyCipher)];case 2:return n=l.sent(),[4,ye.asKey(n.otKey)];case 3: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,ye.asKey(n.oneTimePrk)]):[3,6];case 4:return[4,u.apply(this,p.concat([l.sent(),i.initiatorOneTimePbkCipher]))];case 5:i=s.apply(a,o.concat([(c.initiatorOneTimePbkCipherClearJson=l.sent(),c)])),l.label=6;case 6:return i.otKeyCipher?(d=i,[4,this.encryptionService.decrypt(r,i.otKeyCipher)]):[3,8];case 7:d.otKeyCipherClearJson=l.sent(),l.label=8;case 8:return[2,Object.assign(Object.assign({},e),{otk:i})]}}))}))},e.prototype.decryptKeyExchangeAsResponder=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.decryptOtk(e,t)]}))}))},e.prototype.decryptKeyExchange=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return e.isInitiator?[2,this.decryptKeyExchangeAsInitiator(e)]:[2,this.decryptKeyExchangeAsResponder(e,t)]}))}))},e.prototype.getKeyExchanges=function(e){var t=(void 0===e?{}:e).state;return R(this,void 0,void 0,(function(){var e,n=this;return E(this,(function(r){switch(r.label){case 0:return[4,this.lrGraphQL.query({query:vo,variables:{state:t}})];case 1:return e=r.sent().keyExchanges,[2,Promise.all(e.edges.map((function(e){return n.decryptKeyExchange(e.node)})))]}}))}))},e.prototype.getKeyExchange=function(e,t){var n=void 0===t?{}:t,r=n.otKeyK,i=n.token;return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:i?mo:go,variables:{id:e,token:i},includeKeyGraph:!i})];case 1:return t=n.sent(),[2,this.decryptKeyExchange(t.keyExchange,r)]}}))}))},e.prototype.getCurrentUserSharedKey=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.lrGraphQL.query({query:Ko,variables:{username:e.username,userId:e.userId}})]}))}))},e.prototype.cancelKeyExchange=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.cancelKeyExchangeMutation(e)]}))}))},e.prototype.cancelKeyExchangeMutation=function(e){return new Tr({mutation:So,variables:{input:{id:e}}})},e.prototype.declineKeyExchange=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.declineKeyExchangeMutation(e,t)]}))}))},e.prototype.declineKeyExchangeMutation=function(e,t){return new Tr({mutation:Io,variables:{input:{id:e,token:t}}})},e.prototype.initiateOtk=function(e){var t=void 0===e?{}:e,n=t.message,r=t.email,i=t.contactCard,a=t.upgrade;return R(this,void 0,void 0,(function(){var e,t,s,o,c,u,p,d,l,y,h,f,v;return E(this,(function(g){switch(g.label){case 0:return[4,this.keyFactory.createKey()];case 1:return e=g.sent(),t=this.keyFactory.randomString(this.CLIENT_NONCE_LENGTH),[4,this.keyFactory.createPkcKey()];case 2:return s=g.sent(),[4,this.keyService.getCurrentPxk()];case 3:return o=g.sent(),[4,this.keyService.getCurrentSigPxk()];case 4:return c=g.sent(),u=null,i&&i.ownerPlainDataJson?[4,this.encryptionService.signToString(c.jwk,i.ownerPlainDataJson)]:[3,6];case 5:u=g.sent(),g.label=6;case 6: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 7:return l=g.sent(),y={nonce:t,oneTimePrk:s.toJSON(!0),otKey:e.toJSON(!0),initiatorContactCard:i,initiator:p},[4,this.keyService.getCurrentRootKey()];case 8:return h=g.sent(),[4,this.keyGraph.encryptToString(h.jwk,y)];case 9:return f=g.sent(),v=e.toJSON(!0).k,[2,{lrMutation:new Tr({mutation:Co,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}]}}))}))},e.prototype.respondOtk=function(e){var t=e.keyExchangeId,n=e.token,r=e.decryptedOtk,i=e.message,a=e.initiatorContactCard,s=e.responderContactCard;return R(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b,k,K,w,P,D,R,A,O,T,M,j,$,N,F,L,x,U,J,_,q,G,B,Q,V,W,Z,H,Y,z,X,ee,te;return E(this,(function(E){switch(E.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return e=E.sent(),o=this.keyService.getCurrentMasterKey().id,[4,this.keyService.getCurrentMasterKey()];case 2:return c=E.sent(),[4,this.keyFactory.createKey()];case 3:return u=E.sent(),[4,this.keyFactory.createKey()];case 4:return p=E.sent(),[4,this.encryptionService.encrypt(e.jwk,u.toJSON(!0))];case 5:return d=E.sent(),[4,this.encryptionService.encrypt(c.jwk,p.toJSON(!0))];case 6:return l=E.sent(),[4,ye.asKey(r.otKeyCipherClearJson.initiator.oneTimePbk)];case 7:return y=E.sent(),[4,ye.asKey(r.otKeyCipherClearJson.initiator.pbk)];case 8:return h=E.sent(),[4,ye.asKey(r.otKeyCipherClearJson.initiator.sigPbk)];case 9:return f=E.sent(),[4,this.keyService.getCurrentPxk()];case 10:return v=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 11:return g=E.sent(),[4,this.encryptionService.sign(g.jwk,h.toJSON())];case 12:return m=E.sent(),[4,this.encryptionService.sign(g.jwk,f.toJSON())];case 13:return S=E.sent(),I={nonce:r.otKeyCipherClearJson.nonce,sharedKey:u.toJSON(!0),mkSharedKey:p.toJSON(!0),responder:{pbk:v.jwk.toJSON(),sigPbk:g.jwk.toJSON(),message:i}},r.otKeyCipherClearJson.initiator.contactCard?(b=r.otKeyCipherClearJson.initiator.contactCard.sharedCipherDataClearJson,[4,this.keyFactory.createKey()]):[3,24];case 14:return k=E.sent(),[4,this.keyFactory.createKey()];case 15:return L=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 16:return x=E.sent(),K={},P=(w=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,k.toJSON(!0))];case 17:return K.receiverWrappedKey=P.apply(w,[E.sent()]),K.receiverWrappingKeyId=e.id,a?(A=(R=JSON).stringify,[4,this.encryptionService.encrypt(k,a.receiverCipherDataClearJson)]):[3,19];case 18:return D=A.apply(R,[E.sent()]),[3,20];case 19:D="",E.label=20;case 20:return K.receiverCipherData=D,T=(O=JSON).stringify,[4,this.encryptionService.encrypt(u,L.toJSON(!0))];case 21:return K.sharedWrappedKey=T.apply(O,[E.sent()]),C=K,[4,this.encryptionService.encrypt(L,b)];case 22:return W=E.sent(),M=C,$=(j=JSON).stringify,[4,this.encryptionService.sign(x.jwk,W)];case 23:M.sharedCipherDataSig=$.apply(j,[E.sent()]),C.sigPxkId=x.id,I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherKey:L.toJSON(!0)}),E.label=24;case 24:return s?[4,this.keyFactory.createKey()]:[3,37];case 25:return F=E.sent(),[4,this.keyFactory.createKey()];case 26:return L=E.sent(),[4,this.keyService.getCurrentSigPxk()];case 27:return x=E.sent(),U={},_=(J=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,F.toJSON(!0))];case 28:return U.ownerWrappedKey=_.apply(J,[E.sent()]),U.ownerWrappingKeyId=e.id,s.ownerCipherDataClearJson?(B=(G=JSON).stringify,[4,this.encryptionService.encrypt(F,s.ownerCipherDataClearJson)]):[3,30];case 29:return q=B.apply(G,[E.sent()]),[3,31];case 30:q="",E.label=31;case 31:return U.ownerCipherData=q,V=(Q=JSON).stringify,[4,this.encryptionService.encrypt(u,L.toJSON(!0))];case 32:return U.sharedWrappedKey=V.apply(Q,[E.sent()]),N=U,[4,this.encryptionService.encrypt(L,s.sharedCipherDataClearJson)];case 33:return W=E.sent(),Z=N,Y=(H=JSON).stringify,[4,this.encryptionService.sign(x.jwk,W)];case 34:return Z.sharedCipherDataSig=Y.apply(H,[E.sent()]),N.sigPxkId=x.id,s.ownerPlainDataJson?(z=N,ee=(X=JSON).stringify,[4,this.encryptionService.sign(g.jwk,s.ownerPlainDataJson)]):[3,36];case 35:z.ownerPlainDataSig=ee.apply(X,[E.sent()]),E.label=36;case 36:I.responder.contactCard=Object.assign(Object.assign({},I.responder.contactCard),{sharedCipherDataClearJson:s.sharedCipherDataClearJson}),E.label=37;case 37:return[4,this.encryptionService.encrypt(y,I)];case 38:return te=E.sent(),[4,this.encryptionService.encrypt(r.otKey,te)];case 39:return te=E.sent(),[2,new Tr({mutation:bo,variables:{input:{keyExchangeId:t,keyExchangeToken:n,rootKeyId:e.id,masterKeyId:o,responderPxkId:v.id,responderSigPxkId:g.id,signedInitiatorPbk:JSON.stringify(m),signedInitiatorSigPbk:JSON.stringify(S),rkWrappedSharedKey:JSON.stringify(d),mkWrappedMkSharedKey:JSON.stringify(l),initiatorOneTimePbkCipher:JSON.stringify(te),initiatorContactCard:C,responderContactCard:N}}})]}}))}))},e.prototype.completeOtk=function(e){var t=e.keyExchangeId,n=e.initiatorRootKeyCipher,r=e.initiatorOneTimePbkCipher,i=e.responderContactCard,a=e.initiatorContactCard;return R(this,void 0,void 0,(function(){var e,s,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b,k,K,w,P,D,R,A,O,T,M,j,$,N,F,L,x,U,J,_;return E(this,(function(E){switch(E.label){case 0:return[4,this.keyService.getCurrentRootKey()];case 1:return e=E.sent(),[4,this.keyService.getCurrentMasterKey()];case 2:return s=E.sent(),[4,this.encryptionService.decrypt(e.jwk,n)];case 3:return o=E.sent(),u=this.decryptResponseCipher,[4,ye.asKey(o.otKey)];case 4:return p=[E.sent()],[4,ye.asKey(o.oneTimePrk)];case 5:return[4,u.apply(this,p.concat([E.sent(),r]))];case 6:if(c=E.sent(),o.nonce!==c.nonce)throw new B("The nonce returned by responder does not match with the one created by the initiator.");return[4,this.keyService.getCurrentSigPxk()];case 7:return d=E.sent(),[4,ye.asKey(c.responder.sigPbk)];case 8:return l=E.sent(),[4,ye.asKey(c.responder.pbk)];case 9:return y=E.sent(),[4,this.encryptionService.sign(d.jwk,y.toJSON())];case 10:return h=E.sent(),[4,this.encryptionService.sign(d.jwk,l.toJSON())];case 11:return f=E.sent(),[4,ye.asKey(c.sharedKey)];case 12:return v=E.sent(),[4,this.encryptionService.encrypt(e.jwk,v.toJSON(!0))];case 13:return g=E.sent(),[4,ye.asKey(c.mkSharedKey)];case 14:return m=E.sent(),[4,this.encryptionService.encrypt(s.jwk,m.toJSON(!0))];case 15:return S=E.sent(),i?[4,this.keyFactory.createKey()]:[3,19];case 16:return C=E.sent(),b={},K=(k=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,C.toJSON(!0))];case 17:return b.receiverWrappedKey=K.apply(k,[E.sent()]),b.receiverWrappingKeyId=e.id,P=(w=JSON).stringify,[4,this.encryptionService.encrypt(C,i.receiverCipherDataClearJson)];case 18:b.receiverCipherData=P.apply(w,[E.sent()]),I=b,E.label=19;case 19:return o.initiatorContactCard?(A=o.initiatorContactCard,[4,this.keyFactory.createKey()]):[3,28];case 20:return O=E.sent(),[4,ye.asKey(c.responder.contactCard.sharedCipherKey)];case 21:return T=E.sent(),$=(j=JSON).stringify,[4,this.encryptionService.encrypt(e.jwk,O.toJSON(!0))];case 22:return M=$.apply(j,[E.sent()]),(N=(null==a?void 0:a.ownerCipherDataClearJson)||A.ownerCipherDataClearJson)?[4,this.keyGraph.encryptToString(O,N)]:[3,24];case 23:return L=E.sent(),[3,25];case 24:L="",E.label=25;case 25:return F=L,D={ownerWrappedKey:M,ownerWrappingKeyId:e.id,ownerCipherData:F},R={sigPxkId:d.id},[4,this.encryptionService.encrypt(T,A.sharedCipherDataClearJson)];case 26:return x=E.sent(),U=R,_=(J=JSON).stringify,[4,this.encryptionService.sign(d.jwk,x)];case 27:U.sharedCipherDataSig=_.apply(J,[E.sent()]),E.label=28;case 28:return[2,new Tr({mutation:ko,variables:{input:{keyExchangeId:t,rootKeyId:e.id,masterKeyId:s.id,initiatorSigPxkId:d.id,signedResponderPbk:JSON.stringify(h),signedResponderSigPbk:JSON.stringify(f),rkWrappedSharedKey:JSON.stringify(g),mkWrappedMkSharedKey:JSON.stringify(S),responderContactCardCipher:I,initiatorContactCardCipher:D,initiatorContactCardSharedCipher:R}}})]}}))}))},e}(),e.KeyExchange2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.KeyExchange2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(ye),n.ɵɵinject(fe),n.ɵɵinject(de),n.ɵɵinject(Si),n.ɵɵinject(ve),n.ɵɵinject(e.ɵh))},token:e.KeyExchange2Service,providedIn:"root"}),e.KeyExchange2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.KeyExchange2Service.ctorParameters=function(){return[{type:n.NgZone},{type:ye},{type:fe},{type:de},{type:Si},{type:ve},{type:e.ɵh}]},e.KeyExchange2Service=D([br({ngZoneName:"ngZone"})],e.KeyExchange2Service);var wo,Po,Do,Ro,Eo=En(wo||(wo=M(["\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}"]))),Ao=En(Po||(Po=M(["\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}"]))),Oo=En(Do||(Do=M(["\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}"]))),To=En(Ro||(Ro=M(["\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 R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.lrGraphQL.query({query:Oo,variables:{id:e}})];case 1:return[2,{sharedKeyId:(t=n.sent().ownedContactCard).sharedKey.id,ownerKeyId:t.ownerKey.id}]}}))}))},e.prototype.getReceivedContactCardKeyId=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:To,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 R(this,void 0,void 0,(function(){var e,o,c,u,p,d,l,y,h,f,v,g;return E(this,(function(m){switch(m.label){case 0:return m.trys.push([0,3,,7]),[4,this.keyGraph.getKey(n)];case 1:return e=m.sent(),[4,this.keyGraph.getKey(r)];case 2:return o=m.sent(),[3,7];case 3:return m.sent(),[4,this.getOwnedContactCardKeyIds(t)];case 4:return c=m.sent(),[4,this.keyGraph.getKey(c.ownerKeyId)];case 5:return e=m.sent(),[4,this.keyGraph.getKey(c.sharedKeyId)];case 6:return o=m.sent(),[3,7];case 7:return[4,this.keyService.getCurrentSigPxk()];case 8:return u=m.sent(),[4,this.encryptionService.encrypt(o.jwk,s)];case 9:return p=m.sent(),y=(l=JSON).stringify,[4,this.encryptionService.sign(u.jwk,p)];case 10:return d=y.apply(l,[m.sent()]),v=(f=JSON).stringify,[4,this.encryptionService.sign(u.jwk,i)];case 11:return h=v.apply(f,[m.sent()]),[4,this.encryptionService.encryptToString(e.jwk,a)];case 12:return g=m.sent(),[2,new Tr({mutation:Eo,variables:{input:{id:t,ownerCipherData:g,ownerKeyId:e.id,sharedCipherDataSig:d,sharedKeyId:o.id,sigPxkId:u.id,ownerPlainDataSig:h}}})]}}))}))},e.prototype.updateReceivedContactCard=function(e){var t=e.id,n=e.receiverKeyId,r=e.receiverCipherDataClearJson;return R(this,void 0,void 0,(function(){var e,i,a=this;return E(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 Tr({mutation:Ao,variables:{input:{id:t,receiverCipherData:i,receiverKeyId:e.id}}})]}}))}))},e}(),e.SharedContactCard2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.SharedContactCard2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(fe),n.ɵɵinject(ve),n.ɵɵinject(de),n.ɵɵinject(e.ɵh))},token:e.SharedContactCard2Service,providedIn:"root"}),e.SharedContactCard2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.SharedContactCard2Service.ctorParameters=function(){return[{type:n.NgZone},{type:fe},{type:ve},{type:de},{type:e.ɵh}]},e.SharedContactCard2Service=D([br({ngZoneName:"ngZone"})],e.SharedContactCard2Service);var Mo,jo,$o,No,Fo=En(Mo||(Mo=M(["\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}"]))),Lo=En(jo||(jo=M(["\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"])),Fo),xo=En($o||($o=M(["\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"])),Fo),Uo=En(No||(No=M(["\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"])),Fo);e.LockService=function(e){function t(t,n){var r=e.call(this,n)||this;return r.ngZone=t,r.injector=n,r}return w(t,e),t.prototype.updateLockMutation=function(e){return new Tr({mutation:Lo,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t.prototype.acquireLockMutation=function(e){return new Tr({mutation:xo,variables:{input:{resourceId:e.resourceId,timeoutMs:e.timeoutMs}}})},t.prototype.releaseLockMutation=function(e){return new Tr({mutation:Uo,variables:{input:{resourceId:e.resourceId,version:e.version}}})},t}(zr),e.LockService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.LockService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR))},token:e.LockService,providedIn:"root"}),e.LockService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.LockService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.LockService=D([br({ngZoneName:"ngZone"})],e.LockService);var Jo,_o,qo,Go,Bo,Qo,Vo,Wo,Zo,Ho,Yo,zo,Xo,ec,tc,nc,rc,ic=En(Jo||(Jo=M(["\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"]))),ac=En(_o||(_o=M(["\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"]))),sc=En(qo||(qo=M(["\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"]))),oc=En(Go||(Go=M(["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation CreateFileMutation($input: CreateFileInput!) {\n createFile(input: $input) {\n file {\n id\n }\n }\n}\n"]))),cc=En(Bo||(Bo=M(["\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"]))),uc=En(Qo||(Qo=M(["\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"]))),pc=En(Vo||(Vo=M(["\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"]))),dc=En(Wo||(Wo=M(["\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"]))),lc=En(Zo||(Zo=M(["\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"]))),yc=En(Ho||(Ho=M(["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"],["\nmutation ChangeDirectoryParentsMutation($input: ChangeDirectoryParentsInput!) {\n changeDirectoryParents(input: $input) {\n directory {\n id\n }\n }\n}\n"]))),hc=En(Yo||(Yo=M(["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"],["\nmutation ChangeFileParentsMutation($input: ChangeFileParentsInput!) {\n changeFileParents(input: $input) {\n file {\n id\n }\n }\n}\n"]))),fc=En(zo||(zo=M(["\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"]))),vc=En(Xo||(Xo=M(['\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']))),gc=En(ec||(ec=M(["\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"]))),mc=En(tc||(tc=M(["\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"]))),Sc=En(nc||(nc=M(["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"],["\nquery FileStateKeyQuery($id: LrRelayIdInput!) {\n fileState(id: $id) {\n keyId\n }\n}\n"])));e.Item2Service=rc=function(e){function t(t,n,r,i,a,s,o){var c=e.call(this,n)||this;return c.ngZone=t,c.injector=n,c.fileService=r,c.keyService=i,c.keyFactory=a,c.keyGraph=s,c.lockService=o,c}return w(t,e),t.prototype.downloadFileContent=function(e){return R(this,void 0,void 0,(function(){var t,n,r=this;return E(this,(function(i){switch(i.label){case 0:return[4,this.fileService.downloadEncryptedFile2(e.fileStateNodeId)];case 1:return t=i.sent(),[4,this.keyGraph.getKey(e.fileStateKeyId,(function(){return r.getFileStateKeyId(e.fileStateNodeId)}))];case 2:return n=i.sent(),[2,this.keyGraph.decryptFromString(n,t,{payloadType:"ArrayBuffer"})]}}))}))},t.prototype.getDirectoryKeyId=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.query({query:gc,variables:{id:e}})];case 1:return[2,t.sent().directory.keyId]}}))}))},t.prototype.getFileKeyId=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.query({query:mc,variables:{id:e}})];case 1:return[2,t.sent().file.keyId]}}))}))},t.prototype.getDirectoryKey=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getDirectoryKeyId(e)}))]}))}))},t.prototype.getFileKey=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){return[2,this.keyGraph.getKey(t,(function(){return n.getFileKeyId(e)}))]}))}))},t.prototype.createDirectoryExec=function(e){return this.mutate(this.createDirectoryMutation(e))},t.prototype.createDirectory=function(e){return this.createDirectoryMutation(e)},t.prototype.createDirectoryMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:ic},r={},[4,this.prepareCreateDirectory(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.updateDirectoryExec=function(e){return this.mutate(this.updateDirectoryMutation(e))},t.prototype.updateDirectory=function(e){return this.updateDirectoryMutation(e)},t.prototype.updateDirectoryMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:ac},r={},[4,this.prepareUpdateDirectory(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.deleteDirectoryExec=function(e){return this.mutate(this.deleteDirectoryMutation(e))},t.prototype.deleteDirectory=function(e){return this.deleteDirectoryMutation(e)},t.prototype.deleteDirectoryMutation=function(e){return new Tr({mutation:sc,variables:{input:{directoryId:e}}})},t.prototype.createFileExec=function(e){return this.mutate(this.createFileMutation(e))},t.prototype.createFile=function(e){return this.createFileMutation(e)},t.prototype.createFileMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:oc},r={},[4,this.prepareCreateFile(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.updateFileExec=function(e){return this.mutate(this.updateFileMutation(e))},t.prototype.updateFile=function(e){return this.updateFileMutation(e)},t.prototype.updateFileMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:cc},r={},[4,this.prepareUpdateFile(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.revertFileExec=function(e){return this.mutate(this.revertFileMutation(e))},t.prototype.revertFile=function(e){return this.revertFileMutation(e)},t.prototype.revertFileMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:uc,variables:{input:e}})]}))}))},t.prototype.deleteFileExec=function(e){return this.mutate(this.deleteFileMutation(e))},t.prototype.deleteFile=function(e){return this.deleteFileMutation(e)},t.prototype.deleteFileMutation=function(e){return new Tr({mutation:pc,variables:{input:{fileId:e}}})},t.prototype.archiveDirectoryExec=function(e,t){return this.mutate(this.archiveDirectoryMutation(e,t))},t.prototype.archiveDirectory=function(e,t){return this.archiveDirectoryMutation(e,t)},t.prototype.archiveDirectoryMutation=function(e,t){return new Tr({mutation:dc,variables:{input:{directoryId:e,recursive:t}}})},t.prototype.unarchiveDirectoryExec=function(e,t){return this.mutate(this.unarchiveDirectoryMutation(e,t))},t.prototype.unarchiveDirectory=function(e,t){return this.unarchiveDirectoryMutation(e,t)},t.prototype.unarchiveDirectoryMutation=function(e,t){return new Tr({mutation:lc,variables:{input:{directoryId:e,recursive:t}}})},t.prototype.changeDirectoryParents=function(e){return this.mutate(this.changeDirectoryParentsMutation(e))},t.prototype.changeDirectoryParentsMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:yc},r={},[4,this.prepareChangeDirectoryParents(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.changeFileParents=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.changeFileParentsMutation(e))]}))}))},t.prototype.changeFileParentsMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:hc},r={},[4,this.prepareChangeFileParents(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))},t.prototype.beginDeleteChildItemLinksWindow=function(e){return this.mutate(this.beginDeleteChildItemLinksWindowMutation(e))},t.prototype.beginDeleteChildItemLinksWindowMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:fc,variables:{input:e}})]}))}))},t.prototype.ensureTempDirectory=function(){var e;return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return[4,this.query({query:vc,variables:{plainMeta:rc.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: "+rc.TEMP_DIRECTORY_PLAIN_META_FILTER+")"),0!==t.rootDirectories.edges.length?[3,4]:[4,this.createDirectory({asRootDirectory:!0,plainMetaJson:rc.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(jr.create([n,r]))];case 3:return i=O.apply(void 0,[p.sent(),2]),a=i[0],i[1],s=a.createDirectory.directory,c=s.id,u=s.keyId,[2,{id:c,keyId:u}];case 4:return o=t.rootDirectories.edges[0].node,c=o.id,u=o.keyId,[2,{id:c,keyId:u}]}}))}))},t.prototype.createDirectoryTree=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.createDirectoryTreeMutation(e))]}))}))},t.prototype.createDirectoryTreeMutation=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.ensureTempDirectory()];case 1:return t=r.sent(),[4,this.beginDeleteChildItemLinksWindow({directoryId:t.id,requestWindowMs:e.requestWindowMs})];case 2:return r.sent(),[4,this.createDirectoryExec({cipherMetaClearJson:e.cipherMetaClearJson,parentDirectories:[{directoryId:t.id,wrappingKeyId:t.keyId}],plainMetaJson:e.plainMetaJson})];case 3:return n=r.sent().createDirectory.directory.id,[4,e.createContent(n)];case 4:return r.sent(),[2,this.changeDirectoryParentsMutation({directoryId:n,parentsToRemove:[t.id],parentsToAdd:e.parentDirectories})]}}))}))},t.prototype.prepareParentDirectory=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(this,(function(i){switch(i.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.wrappingKeyId)];case 1:return n=i.sent(),r={directoryId:e.directoryId,wrappingKeyId:n.id},[4,this.keyGraph.wrapKey(n,t)];case 2:return[2,(r.wrappedKey=i.sent(),r.linkType=e.linkType,r)]}}))}))},t.prototype.getFileStateKeyId=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.query({query:Sc,variables:{id:e}})];case 1:return[2,t.sent().fileState.keyId]}}))}))},t.prototype.prepareCreateFileState=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y;return E(this,(function(h){switch(h.label){case 0:return[4,this.keyFactory.createKey()];case 1:return n=h.sent(),(i=t.file)?[4,this.fileService.loadFile(t.file)]:[3,3];case 2:i=h.sent(),h.label=3;case 3:return(r=i)?[4,this.keyGraph.encryptToString(n,r)]:[3,9];case 4:return s=h.sent(),t.upload?[4,t.upload(s)]:[3,6];case 5:return a=h.sent(),[3,8];case 6:return[4,this.fileService.uploadEncryptedFile({encryptedContent:s})];case 7:a=h.sent(),h.label=8;case 8:console.log("contentResource",a),h.label=9;case 9:return c=(o=Object).assign,p=(u=Object).assign,d=[{}],[4,this.prepareItem(n,t)];case 10:return l=[p.apply(u,d.concat([h.sent()]))],y={},[4,this.keyGraph.wrapKey(e,n)];case 11:return[2,c.apply(o,l.concat([(y.wrappedStateKey=h.sent(),y.contentResource=a,y)]))]}}))}))},t.prototype.prepareChangeItemParents=function(e,t){return R(this,void 0,void 0,(function(){var n,r=this;return E(this,(function(i){switch(i.label){case 0:return[4,Promise.all(e.parentsToAdd.map((function(e){return r.prepareParentDirectory(e,t)})))];case 1:return n=i.sent(),[2,{directoriesToRemove:e.parentsToRemove,directoriesToAdd:n}]}}))}))},t.prototype.prepareItem=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return n=t.plainMetaJson,r=t.cipherMetaClearJson,i={plainMeta:n&&JSON.stringify(n)},(a=r)?[4,this.keyGraph.encryptToString(e,r)]:[3,2];case 1:a=s.sent(),s.label=2;case 2:return[2,(i.cipherMeta=a,i)]}}))}))},t.prototype.prepareCreateDirectory=function(e){var t,n;return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u=this;return E(this,(function(p){switch(p.label){case 0:return[4,this.keyFactory.createKey()];case 1:if(r=p.sent(),e.parentDirectories=e.parentDirectories||[],!e.asRootDirectory&&!(null===(t=e.parentDirectories)||void 0===t?void 0:t.length))throw new J("A new directory must be either a root directory or a sub-directory. So you must provide either parentDirectories and/or asRootDirectory parameter.");return[4,Promise.all(null===(n=e.parentDirectories)||void 0===n?void 0:n.map((function(e){return u.prepareParentDirectory(e,r)})))];case 2:return i=p.sent(),e.asRootDirectory?(s=this.keyService.getCurrentRootKey(),o={wrappingKeyId:s.id},[4,this.keyGraph.wrapKey(s,r)]):[3,4];case 3:o.wrappedKey=p.sent(),a=o,p.label=4;case 4:return[4,this.prepareItem(r,e)];case 5:return c=p.sent(),[2,Object.assign(Object.assign({},c),{parentDirectories:i,parentRootDirectory:a})]}}))}))},t.prototype.prepareUpdateDirectory=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareItem(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},t.prototype.prepareCreateFile=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i=this;return E(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 R(i,void 0,void 0,(function(){var n,r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.prepareParentDirectory(e,t)];case 1:return n=s.sent(),r=n.directoryId,i=n.wrappingKeyId,a=n.wrappedKey,[2,{directoryId:r,wrappingKeyId:i,wrappedFileKey:a}]}}))}))})))];case 2:return n=a.sent(),[4,this.prepareCreateFileState(t,e)];case 3:return r=a.sent(),[2,Object.assign(Object.assign({},r),{parentDirectories:n})]}}))}))},t.prototype.prepareUpdateFile=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareCreateFileState(t.jwk,e)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},t.prototype.prepareChangeDirectoryParents=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{directoryId:e.directoryId})]}}))}))},t.prototype.prepareChangeFileParents=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getFileKey(e.fileId,e.fileKeyId)];case 1:return t=r.sent(),[4,this.prepareChangeItemParents(e,t.jwk)];case 2:return n=r.sent(),[2,Object.assign(Object.assign({},n),{fileId:e.fileId})]}}))}))},t}(zr),e.Item2Service.TEMP_DIRECTORY_PLAIN_META={kcType:"temp"},e.Item2Service.TEMP_DIRECTORY_PLAIN_META_FILTER=JSON.stringify({filter:[{contains:rc.TEMP_DIRECTORY_PLAIN_META}]}),e.Item2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.Item2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(pi),n.ɵɵinject(fe),n.ɵɵinject(ye),n.ɵɵinject(ve),n.ɵɵinject(e.LockService))},token:e.Item2Service,providedIn:"root"}),e.Item2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.Item2Service.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:pi},{type:fe},{type:ye},{type:ve},{type:e.LockService}]},e.Item2Service=rc=D([br({ngZoneName:"ngZone"})],e.Item2Service);var Ic,Cc,bc,kc,Kc,wc,Pc,Dc,Rc,Ec=En(Ic||(Ic=M(["\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"]))),Ac=En(Cc||(Cc=M(["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"],["\n mutation ShareDirectoryMutation($input: ShareDirectoryInput!) {\n shareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"]))),Oc=En(bc||(bc=M(["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"],["\n mutation UnshareDirectoryMutation($input: UnshareDirectoryInput!) {\n unshareDirectory(input: $input) {\n tpDirectory {\n id\n }\n }\n }\n"]))),Tc=En(kc||(kc=M(["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"],["\n mutation ShareFileMutation($input: ShareFileInput!) {\n shareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"]))),Mc=En(Kc||(Kc=M(["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"],["\n mutation UnshareFileMutation($input: UnshareFileInput!) {\n unshareFile(input: $input) {\n tpFile {\n id\n }\n }\n }\n"]))),jc=En(wc||(wc=M(["\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"]))),$c=En(Pc||(Pc=M(["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation RequestTpMkReshareMutation($input: RequestTpMkReshareInput!) {\n requestTpMkReshare(input: $input) {\n id\n }\n}"]))),Nc=En(Dc||(Dc=M(["\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"]))),Fc=En(Rc||(Rc=M(["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"],["\nmutation CompleteTpMkReshareMutation($input: CompleteTpMkReshareInput!) {\n completeTpMkReshare(input: $input) {\n id\n }\n}"])));e.TrustedParty2Service=function(e){function t(t,n,r,i,a,s,o){var c=e.call(this,n)||this;return c.ngZone=t,c.injector=n,c.keyGraph=r,c.item2Service=i,c.keyService=a,c.keyFactory=s,c.encryptionService=o,c}return w(t,e),t.prototype.deleteTpExec=function(e){return this.mutate(this.deleteTpMutation(e))},t.prototype.deleteTp=function(e){return this.deleteTpMutation(e)},t.prototype.deleteTpMutation=function(e){return new Tr({mutation:Ec,variables:{input:{id:e}}})},t.prototype.getTpCurrentUserSharedKey=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.lrGraphQL.query({query:jc,variables:{id:e}})];case 1:return[2,t.sent().tp.currentUserSharedKey.userSharedKey]}}))}))},t.prototype.shareDirectory=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.shareItem(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},t.prototype.shareFile=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.shareItem(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},t.prototype.shareItem=function(e){var t=e.itemId,n=e.itemKeyId,r=e.tpId,i=e.tpSharedKeyId,a=e.accessRole,s=e.isDirectory;return R(this,void 0,void 0,(function(){var e,o,c,u=this;return E(this,(function(p){switch(p.label){case 0:return[4,this.keyGraph.getKey(n,(function(){return s?u.item2Service.getDirectoryKeyId(t):u.item2Service.getFileKeyId(t)}))];case 1:return e=p.sent(),[4,this.keyGraph.getKey(i,(function(){return u.getTpCurrentUserSharedKey(r).then((function(e){return e.sharedKey.id}))}))];case 2:return o=p.sent(),[4,this.keyGraph.wrapKey(o,e.jwk)];case 3:return c=p.sent(),[2,new Tr({mutation:s?Ac:Tc,variables:{input:{id:t,tpId:r,accessRole:a,keyId:e.id,wrappingKeyId:o.id,wrappedKey:c}}})]}}))}))},t.prototype.unshareDirectory=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.unshareItem(Object.assign(Object.assign({},e),{isDirectory:!0}))]}))}))},t.prototype.unshareFile=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.unshareItem(Object.assign(Object.assign({},e),{isDirectory:!1}))]}))}))},t.prototype.unshareItem=function(e){var t=e.itemId,n=e.tpId,r=e.isDirectory;return R(this,void 0,void 0,(function(){return E(this,(function(e){return[2,new Tr({mutation:r?Oc:Mc,variables:{input:{id:t,tpId:n}}})]}))}))},t.prototype.requestMkReshare=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s;return E(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[4,this.keyService.getCurrentMasterKey()];case 2:return n=o.sent(),[4,this.keyFactory.createPkcKey()];case 3:return r=o.sent(),[4,this.encryptionService.encryptToString(n.jwk,r.toJSON(!0))];case 4:return i=o.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 5:return a=o.sent(),[4,this.encryptionService.encryptToString(a.jwk,{pbk:r.toJSON()})];case 6:return s=o.sent(),[4,new Tr({mutation:$c,variables:{input:{tpId:e,masterKeyId:n.id,mkPbk:JSON.stringify(r.toJSON()),mkWrappedMkPrk:i,sharedKeyId:a.id,mkReshareRequestCipher:s}}})];case 7:return[2,o.sent()]}}))}))},t.prototype.respondMkReshare=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d;return E(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,p.JWK.asKey(r.pbk)];case 4:return i=l.sent(),[4,this.keyGraph.getKey(t.mkSharedKey.id)];case 5:return a=l.sent(),s={mkSharedKey:{id:a.id,jwk:a.jwk.toJSON(!0)}},u=(c=this.encryptionService).encryptToString,d=[i],[4,this.encryptionService.encryptToString(n.jwk,s)];case 6:return[4,u.apply(c,d.concat([l.sent()]))];case 7:return o=l.sent(),[2,new Tr({mutation:Nc,variables:{input:{tpId:e,mkSharedKeyId:a.id,mkReshareResponseCipher:o}}})]}}))}))},t.prototype.completeMkReshare=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,d,l;return E(this,(function(y){switch(y.label){case 0:return[4,this.getTpCurrentUserSharedKey(e)];case 1:return t=y.sent(),[4,this.keyGraph.getKey(t.sharedKey.id)];case 2:return n=y.sent(),[4,this.keyGraph.getKey(t.mkPxk.id)];case 3:return r=y.sent(),s=(a=this.encryptionService).decrypt,o=[n],[4,this.encryptionService.decrypt(r,t.mkReshareResponseCipher)];case 4:return[4,s.apply(a,o.concat([y.sent()]))];case 5:return i=y.sent(),u={id:i.mkSharedKey.id},[4,p.JWK.asKey(i.mkSharedKey.jwk)];case 6:return u.jwk=y.sent(),c=u,[4,this.keyService.getCurrentMasterKey()];case 7:return d=y.sent(),[4,this.encryptionService.encryptToString(d.jwk,c.jwk.toJSON(!0))];case 8:return l=y.sent(),[2,new Tr({mutation:Fc,variables:{input:{tpId:e,masterKeyId:d.id,mkSharedKeyId:c.id,mkWrappedMkSharedKey:l}}})]}}))}))},t}(zr),e.TrustedParty2Service.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TrustedParty2Service(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(ve),n.ɵɵinject(e.Item2Service),n.ɵɵinject(fe),n.ɵɵinject(ye),n.ɵɵinject(de))},token:e.TrustedParty2Service,providedIn:"root"}),e.TrustedParty2Service.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TrustedParty2Service.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:ve},{type:e.Item2Service},{type:fe},{type:ye},{type:de}]},e.TrustedParty2Service=D([br({ngZoneName:"ngZone"})],e.TrustedParty2Service),e.TpPasswordResetService=function(e){function t(t,n,r){var i=e.call(this,n)||this;return i.ngZone=t,i.injector=n,i.assemblyController=r,i.slip39Passphrase=ai,i}return w(t,e),t.prototype.getReset=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.query({query:hr})];case 1:return[2,e.sent().tpPasswordReset]}}))}))},t.prototype.cancelResetRequest=function(){return this.mutate(this.cancelResetRequestMutation())},t.prototype.cancelResetRequestMutation=function(){return new Tr({mutation:or})},t.prototype.deleteReset=function(){return this.mutate(this.deleteResetMutation())},t.prototype.deleteResetMutation=function(){return new Tr({mutation:vr})},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 R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.assemblyController.prepareCreate(e)];case 1:return t=n.sent().mutationInput,[2,new Tr({mutation:fr,variables:{input:{assembly:Object.assign({},t)}}})]}}))}))},t.prototype.updateReset=function(e){return this.mutate(this.updateResetMutation(e))},t.prototype.updateResetMutation=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getReset()];case 1:return t=r.sent(),[4,this.assemblyController.prepareUpdate(e,t.assembly)];case 2:return n=r.sent().mutationInput,[2,new Tr({mutation:gr,variables:{input:{assembly:Object.assign({},n)}}})]}}))}))},t}(zr),e.TpPasswordResetService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(e.ɵl))},token:e.TpPasswordResetService,providedIn:"root"}),e.TpPasswordResetService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:e.ɵl}]},e.TpPasswordResetService=D([br({ngZoneName:"ngZone"})],e.TpPasswordResetService),e.TpPasswordResetUserService=function(e){function t(t,n,r,i,a,s,o,c,u,p,d){var l=e.call(this,n)||this;return l.ngZone=t,l.injector=n,l.config=r,l.keyFactory=i,l.encryptionService=a,l.keyGraphService=s,l.slip39Service=o,l.passwordService=c,l.http=u,l.auth=p,l.lrAuth=d,l}return w(t,e),t.prototype.verifyEmailContact=function(e){return R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u;return E(this,(function(p){switch(p.label){case 0:return[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(c),console.log("Using new password: ",this.passwordService.getPassIdpString(r.passIdp)),[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: ",u),[2,{requestResetResult:c,signUpResult:u}]}}))}))},t}(zr),e.TpPasswordResetUserService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetUserService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(te),n.ɵɵinject(ye),n.ɵɵinject(de),n.ɵɵinject(ve),n.ɵɵinject(ri),n.ɵɵinject(qn),n.ɵɵinject(t.HttpClient),n.ɵɵinject(d.AuthClass),n.ɵɵinject(ui))},token:e.TpPasswordResetUserService,providedIn:"root"}),e.TpPasswordResetUserService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetUserService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:void 0,decorators:[{type:n.Inject,args:[te]}]},{type:ye},{type:de},{type:ve},{type:ri},{type:qn},{type:t.HttpClient},{type:d.AuthClass},{type:ui}]},e.TpPasswordResetUserService=D([br({ngZoneName:"ngZone"})],e.TpPasswordResetUserService),e.TpPasswordResetRequestService=function(t){function n(e,n,r){var i=t.call(this,n)||this;return i.ngZone=e,i.injector=n,i.encryptionService=r,i}return w(n,t),n.prototype.getSharedResets=function(){return R(this,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return[4,this.query({query:ar})];case 1:return[2,e.sent().sharedTpPasswordResets]}}))}))},n.prototype.getSharedReset=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:return[4,this.query({query:sr,variables:{id:e}})];case 1:return[2,t.sent().sharedTpPasswordReset]}}))}))},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 R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return[4,this.getSharedReset(t)];case 1:return n=r.sent(),this.activeRequestOrRaise(n),[2,jr.create(n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})).map((function(e){return new Tr({mutation:lr,variables:{input:{claimApproverId:e.node.id}}})})))]}}))}))},n.prototype.approveRequest=function(e,t){return R(this,void 0,void 0,(function(){var n,r;return E(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 R(this,void 0,void 0,(function(){var n,r,i,a,s,o=this;return E(this,(function(c){switch(c.label){case 0:return[4,this.getSharedReset(t)];case 1:return n=c.sent(),this.activeRequestOrRaise(n),[4,p.JWK.asKey(JSON.parse(n.sharedRequest.pxk.pbk))];case 2:return r=c.sent(),console.log(r.toJSON()),i=n.sharedRequest.claim.asClaimApprovers.edges.filter((function(t){return t.node.state===e.TpClaimApproverState.CLAIMED})),s=(a=jr).create,[4,Promise.all(i.map((function(e){return R(o,void 0,void 0,(function(){var t,n,i,a=this;return E(this,(function(s){switch(s.label){case 0:return t=e.node,i={claimApproverId:t.id},[4,Promise.all(t.receiverApprovals.edges.map((function(e){return R(a,void 0,void 0,(function(){var n,i;return E(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 i.receiverApprovals=s.sent(),n=i,console.log(n),[2,new Tr({mutation:dr,variables:{input:n}})]}}))}))})))];case 3:return[2,s.apply(a,[c.sent()])]}}))}))},n}(zr),e.TpPasswordResetRequestService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.TpPasswordResetRequestService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(de))},token:e.TpPasswordResetRequestService,providedIn:"root"}),e.TpPasswordResetRequestService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.TpPasswordResetRequestService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:de}]},e.TpPasswordResetRequestService=D([br({ngZoneName:"ngZone"})],e.TpPasswordResetRequestService);var Lc,xc,Uc,Jc,_c,qc=En(Lc||(Lc=M(["\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"]))),Gc=En(xc||(xc=M(["\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"]))),Bc=En(Uc||(Uc=M(["\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"]))),Qc=En(Jc||(Jc=M(["\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"]))),Vc=En(_c||(_c=M(["\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 w(t,e),t.prototype.updateNotification=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.updateNotificationMutation(e))]}))}))},t.prototype.updateNotificationMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:qc,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.updateAllNotificationsReadState=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.updateAllNotificationsReadStateMutation(e))]}))}))},t.prototype.updateAllNotificationsReadStateMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:Gc,variables:{input:Object.assign({},e)}})]}))}))},t.prototype.debugCreateNotification=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.debugCreateNotificationMutation(e))]}))}))},t.prototype.debugCreateNotificationMutation=function(e){var t;return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,new Tr({mutation:Bc,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 R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.debugDeleteAllNotificationsMutation(e))]}))}))},t.prototype.debugDeleteAllNotificationsMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:Qc,variables:{input:{receiverId:e.receiverId}}})]}))}))},t.prototype.updateNotificationFeatureState=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.updateNotificationFeatureStateMutation(e))]}))}))},t.prototype.updateNotificationFeatureStateMutation=function(e){var t;return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,new Tr({mutation:Vc,variables:{input:{lastViewed:null===(t=e.lastViewed)||void 0===t?void 0:t.toISOString(),clearLastViewed:null==e.lastViewed||void 0}}})]}))}))},t}(zr),e.NotificationService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.NotificationService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR))},token:e.NotificationService,providedIn:"root"}),e.NotificationService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.NotificationService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.NotificationService=D([br({ngZoneName:"ngZone"})],e.NotificationService);var Wc,Zc,Hc,Yc,zc,Xc,eu,tu,nu=En(Wc||(Wc=M(["\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"]))),ru=En(Zc||(Zc=M(["\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"]))),iu=En(Hc||(Hc=M(["\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"]))),au=En(Yc||(Yc=M(["\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"]))),su=En(zc||(zc=M(["\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"]))),ou=En(Xc||(Xc=M(["\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"]))),cu=En(eu||(eu=M(["\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"]))),uu=En(tu||(tu=M(["\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"])));e.ɵq=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 w(t,e),t.prototype.getTpWrappingKeyId=function(e){return e.currentUserSharedKey.userSharedKey.sharedKey.id},t}(oi),e.ɵq.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ɵq(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR))},token:e.ɵq,providedIn:"root"}),e.ɵq.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ɵq.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector}]},e.ɵq=D([br({ngZoneName:"ngZone"})],e.ɵq);var pu,du,lu=En(pu||(pu=M(["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"],["\nquery ScenarioQuery(\n $scenarioId: LrRelayIdInput!\n) {\n scenario(id: $scenarioId) {\n id\n state\n assembly {\n quorum\n singleReject\n assemblyKey {\n id\n }\n subjectKey {\n id\n }\n subjectCipherData\n subAssemblies {\n edges {\n node {\n id\n subjectKey {\n id\n }\n subjectCipherData\n quorum\n singleReject\n approvers {\n edges {\n node {\n id\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n claimants {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n }\n }\n }\n receivers {\n edges {\n node {\n tp {\n id\n }\n sharedKey {\n id\n }\n sharedCipherData\n receiverDirectories {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n directory {\n id\n keyId\n }\n }\n }\n }\n receiverFiles {\n edges {\n node {\n id\n sharedCipherData\n sharedKey {\n id\n }\n accessRole\n itemKey {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}"]))),yu=En(du||(du=M(["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"],["\nquery SharedScenarioQuery($scenarioId: LrRelayIdInput!) {\n sharedScenario(id: $scenarioId) {\n id\n state\n tp {\n id\n }\n asClaimant {\n sharedKey {\n id\n }\n sharedCipherData\n }\n asReceiver {\n sharedKey {\n id\n }\n sharedCipherData\n pbk {\n id\n }\n receiverDirectories {\n edges {\n node {\n id\n wrappedItemKey\n }\n }\n }\n }\n assembly {\n asApprovers {\n edges {\n node {\n id\n sharedKey {\n id\n }\n sharedCipherData\n }\n }\n }\n }\n sharedClaim {\n\t \t\tid\n isClaimant\n claim {\n state\n asClaimApprovers {\n edges {\n node {\n id\n state\n sharedKey {\n id\n }\n sharedCipherApprovalData\n sharedCipherPartialAssemblyKey\n receiverApprovals {\n edges {\n node {\n id\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n asClaimReceiver {\n received\n approvals {\n edges {\n node {\n receiverCipher\n receiverCipherPartialAssemblyKey\n pxk {\n id\n }\n }\n }\n }\n }\n }\n }\n}\n"])));function hu(){throw new J("claimId does not match with the current claimId of the scenario")}function fu(){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.item2Service=i,o.assemblyController=a,o.encryptionService=s,o.prepareAddReceiverDirectory=o.prepareReceiverDirectory,o.prepareUpdateReceiverDirectory=o.prepareReceiverDirectory,o}return w(n,t),n.prototype.createScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.createScenarioMutation(e))]}))}))},n.prototype.createScenarioMutation=function(e){return R(this,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.prepareCreateScenarioMutation(e)];case 1:return t=n.sent(),[2,new Tr({mutation:nu,variables:{input:t}})]}}))}))},n.prototype.updateScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.updateScenarioMutation(e))]}))}))},n.prototype.updateScenarioMutation=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(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 Tr({mutation:ru,variables:{input:n}})]}}))}))},n.prototype.resetScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.resetScenarioMutation(e))]}))}))},n.prototype.resetScenarioMutation=function(e){return R(this,void 0,void 0,(function(){var t,n,r,i;return E(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=Xr(n.subAssemblies).map((function(e){var t=Xr(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 Tr({mutation:ru,variables:{input:i}})]}}))}))},n.prototype.deleteScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.lrGraphQL.lrMutate(this.deleteScenarioMutation(e))]}))}))},n.prototype.deleteScenarioMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:iu,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.createClaim=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.createClaimMutation(e))]}))}))},n.prototype.createClaimMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:au,variables:{input:{scenarioId:e}}})]}))}))},n.prototype.cancelClaim=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.mutate(this.cancelClaimMutation(e))]}))}))},n.prototype.cancelClaimMutation=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:su,variables:{input:{claimId:e}}})]}))}))},n.prototype.rejectClaim=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.mutate(this.rejectClaimMutation(e,t))]}))}))},n.prototype.rejectClaimMutation=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.prepareRejectClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=jr).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.approveClaim=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.mutate(this.approveClaimMutation(e,t))]}))}))},n.prototype.approveClaimMutation=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return[4,this.prepareApproveClaimMutations(e,t)];case 1:return n=a.sent(),i=(r=jr).create,[4,Promise.all(n)];case 2:return[2,i.apply(r,[a.sent()])]}}))}))},n.prototype.receiveClaim=function(e,t){return R(this,void 0,void 0,(function(){return E(this,(function(n){return[2,this.mutate(this.receiveClaimMutation(e,t))]}))}))},n.prototype.receiveClaimMutation=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i;return E(this,(function(a){switch(a.label){case 0:return n=Tr.bind,r={mutation:uu},i={},[4,this.prepareClaim(e,t)];case 1:return[2,new(n.apply(Tr,[void 0,(r.variables=(i.input=a.sent(),i),r)]))]}}))}))},n.prototype.getScenario=function(e){return R(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.query({query:lu,variables:{scenarioId:e}})]}))}))},n.prototype.getSharedScenario=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(this,(function(r){switch(r.label){case 0:return[4,this.query({query:yu,variables:{scenarioId:e}})];case 1:return n=r.sent(),t&&n.sharedScenario.sharedClaim.id!==t&&hu(),[2,n]}}))}))},n.prototype.getParticipantTpsKeys=function(e){return R(this,void 0,void 0,(function(){var t,n;return E(this,(function(r){switch(r.label){case 0:return t=e.map((function(e){return e.tpId})),n=Xr,[4,this.lrGraphQL.query({query:si,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 R(this,void 0,void 0,(function(){var t,n,r,i,a,s,o,c,u,p=this;return E(this,(function(d){switch(d.label){case 0:return[4,this.assemblyController.prepareCreate(e.createAssembly)];case 1:return t=d.sent(),n=t.assemblyKey,r=t.mutationInput,i=e.createReceivers||[],a=e.createClaimants||[],s=i.concat(a),[4,this.getParticipantTpsKeys(s)];case 2:return o=d.sent(),this.fillTpSharedKeyId(s,o),[4,Promise.all(i.map((function(e){return p.prepareCreateReceiver(e,n)})))];case 3:return c=d.sent(),[4,Promise.all(a.map((function(e){return p.prepareCreateClaimant(e)})))];case 4:return u=d.sent(),[2,{enabled:e.enabled,createAssembly:r,createReceivers:c,createClaimants:u}]}}))}))},n.prototype.prepareUpdateScenario=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o,c,u,p,d,l,y,h,f,v,g,m,S,I,C,b=this;return E(this,(function(k){switch(k.label){case 0:return[4,this.keyGraph.getJwkKey(t.assembly.assemblyKey.id)];case 1:return n=k.sent(),e.updateAssembly?[4,this.assemblyController.prepareUpdate(e.updateAssembly,t.assembly)]:[3,3];case 2:i=k.sent(),r=i.mutationInput,n=i.assemblyKey,k.label=3;case 3:return a=e.createReceivers||[],s=e.createClaimants||[],o=a.concat(s),[4,this.getParticipantTpsKeys(o)];case 4:return c=k.sent(),this.fillTpSharedKeyId(o,c),(p=e.createReceivers)?[4,Promise.all(e.createReceivers.map((function(e){return b.prepareCreateReceiver(e,n)})))]:[3,6];case 5:p=k.sent(),k.label=6;case 6:return u=p,d=Xr(t.receivers),e.updateReceivers?[4,Promise.all(e.updateReceivers.map((function(e){var t=d.find((function(t){return t.tp.id===e.tpId}));return b.prepareUpdateReceiver(e,n,t)})))]:[3,8];case 7:return y=k.sent(),[3,9];case 8:y=[],k.label=9;case 9:return l=y,e.updateAssembly?(h=d.filter((function(t){return!(e.deleteReceivers||[]).includes(t.tp.id)&&!l.some((function(e){return e.tpId===t.tp.id}))})),v=(f=l).concat,[4,this.prepareExistingReceivers(h,n)]):[3,11];case 10:l=v.apply(f,[k.sent()]),k.label=11;case 11:return(m=e.createClaimants)?[4,Promise.all(e.createClaimants.map((function(e){return b.prepareCreateClaimant(e)})))]:[3,13];case 12:m=k.sent(),k.label=13;case 13:return g=m,S=Xr(t.claimants),(C=e.updateClaimants)?[4,Promise.all(e.updateClaimants.map((function(e){var t=S.find((function(t){return t.tp.id===e.tpId}));return b.prepareUpdateClaimant(e,t.sharedKey.id)})))]:[3,15];case 14:C=k.sent(),k.label=15;case 15:return I=C,[2,{scenarioId:e.scenarioId,enabled:e.enabled,updateAssembly:r,createReceivers:u,updateReceivers:l,deleteReceivers:e.deleteReceivers,createClaimants:g,updateClaimants:I,deleteClaimants:e.deleteClaimants}]}}))}))},n.prototype.prepareReceiverDirectory=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a;return E(this,(function(s){switch(s.label){case 0:return[4,this.item2Service.getDirectoryKey(e.directoryId,e.directoryKeyId)];case 1:return r=s.sent(),[4,this.keyGraph.encryptToString(t,e.sharedCipherDataClearJson)];case 2:return i=s.sent(),[4,this.keyGraph.encryptToString(t,r.jwk.toJSON(!0))];case 3:return a=s.sent(),[4,this.keyGraph.encryptToString(n,a)];case 4:return a=s.sent(),[2,{directoryId:e.directoryId,wrappedItemKey:a,accessRole:e.accessRole,sharedCipherData:i}]}}))}))},n.prototype.prepareCreateReceiver=function(e,t){return R(this,void 0,void 0,(function(){var n,r,i,a,s,o=this;return E(this,(function(c){switch(c.label){case 0:return[4,this.prepareCreateParticipant(e)];case 1:return n=c.sent(),r=n.sharedKey,i=n.mutationInput,(s=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return o.prepareAddReceiverDirectory(e,r.key,t)})))]:[3,3];case 2:s=c.sent(),c.label=3;case 3:return a=s,[2,Object.assign(Object.assign({},i),{addDirectories:a})]}}))}))},n.prototype.prepareUpdateReceiver=function(e,t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,p,d,l=this;return E(this,(function(y){switch(y.label){case 0:return r=n.sharedKey.id,i=e.deleteDirectories||[],a=e.updateDirectories||[],Xr(n.receiverDirectories).forEach((function(e){i.includes(e.directory.id)||a.find((function(t){return t.directoryId===e.directory.id}))||a.push({accessRole:e.accessRole,directoryId:e.directory.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson})})),[4,this.prepareUpdateParticipant(e,r)];case 1:return s=y.sent(),o=s.sharedKey,c=s.mutationInput,(p=e.addDirectories)?[4,Promise.all(e.addDirectories.map((function(e){return l.prepareAddReceiverDirectory(e,o,t)})))]:[3,3];case 2:p=y.sent(),y.label=3;case 3:return u=p,[4,Promise.all(a.map((function(e){return l.prepareUpdateReceiverDirectory(e,o,t)})))];case 4:return d=y.sent(),[2,Object.assign(Object.assign({},c),{addDirectories:u,updateDirectories:d,deleteDirectories:e.deleteDirectories})]}}))}))},n.prototype.prepareExistingReceiver=function(e,t){return R(this,void 0,void 0,(function(){var n;return E(this,(function(r){return n=Xr(e.receiverDirectories).map((function(e){return{directoryId:e.directory.id,directoryKeyId:e.directory.keyId,accessRole:e.accessRole,sharedCipherDataClearJson:e.sharedCipherDataClearJson}})),[2,this.prepareUpdateReceiver({tpId:e.tp.id,sharedCipherDataClearJson:e.sharedCipherDataClearJson,updateDirectories:n},t,e)]}))}))},n.prototype.prepareExistingReceivers=function(e,t){return R(this,void 0,void 0,(function(){var n=this;return E(this,(function(r){return[2,Promise.all(e.map((function(e){return n.prepareExistingReceiver(e,t)})))]}))}))},n.prototype.prepareCreateParticipant=function(e){return R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var n,r;return E(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 R(this,void 0,void 0,(function(){return E(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 R(this,void 0,void 0,(function(){return E(this,(function(n){switch(n.label){case 0:return[4,this.prepareUpdateParticipant(e,t)];case 1:return[2,n.sent().mutationInput]}}))}))},n.prototype.prepareClaim=function(t,n){return R(this,void 0,void 0,(function(){var r,i,a,s,o=this;return E(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&&fu(),i=Xr(r.sharedClaim.asClaimReceiver.approvals),[4,this.recoverAssemblyKey(i)];case 2:return a=c.sent(),console.log("receiveClaimMutation assemblyKey",a),[4,Promise.all(r.asReceiver.receiverDirectories.edges.map((function(e){return e.node})).map((function(e){return R(o,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return[4,this.encryptionService.decrypt(a,e.wrappedItemKey)];case 1:return t=n.sent(),[2,{receiverDirectoryId:e.id,receiverSharedKeyWrappedItemKey:t}]}}))}))})))];case 3:return s=c.sent(),[2,{scenarioClaimId:n,receiverDirectories:s}]}}))}))},n.prototype.recoverAssemblyKey=function(e){return R(this,void 0,void 0,(function(){var t,n=this;return E(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 R(this,void 0,void 0,(function(){return E(this,(function(r){switch(r.label){case 0:return[4,this.getSharedScenario(e,t)];case 1:return[2,Xr(r.sent().sharedScenario.sharedClaim.claim.asClaimApprovers).filter((function(e){return e.state===n}))]}}))}))},n.prototype.prepareApproveClaimMutations=function(t,n){return R(this,void 0,void 0,(function(){var r=this;return E(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 R(r,void 0,void 0,(function(){var t,n,r;return E(this,(function(i){switch(i.label){case 0:return t=Tr.bind,n={mutation:cu},r={},[4,this.prepareApproveClaim(e)];case 1:return[2,new(t.apply(Tr,[void 0,(n.variables=(r.input=i.sent(),r),n)]))]}}))}))}))]}}))}))},n.prototype.prepareApproveClaim=function(e){return R(this,void 0,void 0,(function(){var t,n=this;return E(this,(function(r){switch(r.label){case 0:return[4,Promise.all(Xr(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 R(this,void 0,void 0,(function(){var t;return E(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 R(this,void 0,void 0,(function(){var r=this;return E(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 R(r,void 0,void 0,(function(){return E(this,(function(t){return[2,new Tr({mutation:ou,variables:{input:{claimApproverId:e.id}}})]}))}))}))]}}))}))},n}(zr),e.ScenarioService.SLIP39_PASSPHRASE="lifeready",e.ScenarioService.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new e.ScenarioService(n.ɵɵinject(n.NgZone),n.ɵɵinject(n.INJECTOR),n.ɵɵinject(ve),n.ɵɵinject(e.Item2Service),n.ɵɵinject(e.ɵq),n.ɵɵinject(de))},token:e.ScenarioService,providedIn:"root"}),e.ScenarioService.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ScenarioService.ctorParameters=function(){return[{type:n.NgZone},{type:n.Injector},{type:ve},{type:e.Item2Service},{type:e.ɵq},{type:de}]},e.ScenarioService=D([br({ngZoneName:"ngZone"})],e.ScenarioService),e.AcceptTrustedPartyInvite=ys,e.AccessFields=mt,e.ApiContactCard=Qe,e.ApiCurrentUser=Be,e.ArchiveDirectoryMutation=jt,e.CancelTrustedPartyInvitationMutation=Ts,e.CancelUserDeleteMutation=gi,e.Category=Ra,e.CategoryFields=It,e.CategoryFilter=vt,e.CategoryMetaService=Na,e.CategoryService=ja,e.CognitoChallengeUser=gn,e.CompleteOtkMutation=Ni,e.ConfirmTrustedPartyInvite=hs,e.ContactCardAddress=We,e.ContactCardName=Ve,e.CreateCategoryMutation=At,e.CreateContactCardMutation=_e,e.CreateFileMutation=ba,e.CreateFileQuery=Ne,e.CreateLbopQuery=Hi,e.CreateRecordContainerMutation=ga,e.CreateRecordMutation=ma,e.CreateVaultMutation=Ot,e.CurrentCategory=Ea,e.CurrentUser=In,e.CurrentUserKey=Ge,e.CurrentUserQuery=Je,e.CurrentUserSharedKeyQuery=Ai,e.DEFAULT_BREADCRUMB_DEPTH=5,e.DEFAULT_DESCENDANTS_DEPTH=5,e.DeclineTrustedPartyInvitationMutation=Os,e.DefaultCategory=wa,e.DefaultProcessorOptions=kr,e.DefaultVaultFilter=ft,e.DeleteCategoryMutation=Mt,e.DeleteFileMutation=ka,e.DeleteLbopQuery=Yi,e.DeleteRecordMutation=Ca,e.DeleteTrustedPartyMutation=Ms,e.DirectoryQuery=$e,e.Features=Sn,e.FetchKeyGraphField=Me,e.FileQuery=je,e.FileService=pi,e.FoundTrustedParty=ds,e.GetAllTrustedPartiesQuery=Es,e.GetCategoriesQuery=kt,e.GetCategoryKeyIdQuery=Et,e.GetCategoryQuery=Rt,e.GetMySharedCategoriesQuery=Pt,e.GetRecordQuery=va,e.GetRootDirectoryIdsQuery=bt,e.GetTrustedPartiesQuery=Rs,e.GetTrustedPartyCategoriesQuery=wt,e.GetTrustedPartyQuery=As,e.GetVaultsQuery=Kt,e.IdleService=Un,e.InitiateOtkMutation=ji,e.InviteTrustedParty=ls,e.KeyExchangeFields=Ri,e.KeyExchangeQuery=Ti,e.KeyExchangeService=Fi,e.KeyExchangeTokenQuery=Mi,e.KeyExchangesQuery=Oi,e.KeyGraphField=Te,e.KeyGraphFragment=Oe,e.LR_CONFIG=te,e.LbopQuery=Xi,e.LbopService=ta,e.LbopsQuery=ea,e.LifeReadyAuthService=ui,e.LifeReadyModule=xs,e.LoadedCategoryTree=$a,e.LoginHistoryQuery=mi,e.LoginResult=Cn,e.LrApolloService=ge,e.LrAuthException=Z,e.LrBadArgumentException=J,e.LrBadLogicException=G,e.LrBadRequestException=W,e.LrBadStateException=ee,e.LrCodeMismatchException=B,e.LrConcurrentAccessException=Q,e.LrEncryptionException=H,e.LrError=F,e.LrException=L,e.LrExpiredCodeException=z,e.LrExpiredException=X,e.LrGraphQLService=e.ɵh,e.LrLockedException=V,e.LrMergedMutation=jr,e.LrMutation=Tr,e.LrMutationBase=Or,e.LrNotFoundException=q,e.LrRecord=Ja,e.LrService=zr,e.LrSuspiciousException=_,e.LrUnsupportedException=Y,e.MainContactCard=Ye,e.MainContactCardFields=He,e.MainContactCardPlainFields=ze,e.MainContactCardProperty=Ze,e.MessageQuery=Ji,e.MessageService=_i,e.MoveDirectoryQuery=Ue,e.MoveFileQuery=xe,e.NewAttachment=_a,e.NewCategory=Oa,e.NewOrUpdatedAttachment=Ga,e.NewRecord=qa,e.OwnerPlainDataJson=to,e.PassIdpApiResult=et,e.PasswordCheck=_n,e.PasswordService=qn,e.PersistService=he,e.Plan=Qs,e.PlanService=fn,e.ProfileDetailsService=Ls,e.ProfileService=vn,e.RecordAttachment=Ua,e.RecordAttachmentFilter=fa,e.RecordAttachmentService=Fa,e.RecordContentFilter=ha,e.RecordField=xa,e.RecordFilter=gt,e.RecordService=Qa,e.RecordType=Va,e.RecordTypeField=Za,e.RecordTypeFieldOption=Wa,e.RecordTypeService=Xa,e.RecordTypeSummary=Ha,e.RegisterResult=bn,e.RegisterService=na,e.RequestUserDeleteMutation=vi,e.RespondOtkMutation=$i,e.RevertFileQuery=Le,e.SendMessageMutation=Ui,e.ShareCategoryMutation=js,e.SharedAccess=Ka,e.SharedTrustedPartyDetails=ss,e.SharedVaultFeature=us,e.StripeBillingPortalSession=Hs,e.StripeCheckoutSession=Zs,e.Subscription=Vs,e.TPFeatures=cs,e.TrustedParties=as,e.TrustedParty=ps,e.TrustedPartyDetails=tt,e.TrustedPartyInvite=os,e.TrustedPartyProperties=Ds,e.TrustedPartyRole=rs,e.TrustedPartyService=Ns,e.TwoFactorService=ia,e.UnarchiveDirectoryMutation=$t,e.UnshareCategoryMutation=$s,e.UpdateCategoryMutation=Tt,e.UpdateContactCardMutation=qe,e.UpdateFileQuery=Fe,e.UpdateLbopQuery=zi,e.UpdateRecordContainerMutation=Sa,e.UpdateRecordMutation=Ia,e.UpdatedCategory=Ta,e.UpdatedRecord=Ba,e.UserPlan=Ws,e.UserQuery=fi,e.UserService=Si,e.UserSharedKeyFields=Ei,e.Vault=Ma,e.VaultCategory=Aa,e.VaultFields=Ct,e.VaultRecord=Da,e.VaultRecordType=Pa,e.awsFetch=Wi,e.configureAmplifyAuth=Zi,e.configureApollo=re,e.fragmentSpreadAstSelection=Ar,e.gqlTyped=En,e.handleApolloError=j,e.handleCognitoCallback=function(e){return new Promise((function(t,n){return e((function(e,r){return e?n(e):t(r)}))}))},e.initialiseAuth=ci,e.mapEdges=Xr,e.mapUserPlans=hn,e.parentCategoriesField=Dt,e.processConnection=Kr,e.throwClaimIdMismatch=hu,e.throwClaimNotApproved=fu,e.ɵ0=za,e.ɵa=ye,e.ɵb=le,e.ɵc=fe,e.ɵd=de,e.ɵe=ce,e.ɵf=ve,e.ɵg=Nt,e.ɵj=br,e.ɵk=ri,e.ɵm=oi,e.ɵn=fs,e.ɵo=gs,e.ɵp=zr,Object.defineProperty(e,"__esModule",{value:!0})}));
16
16
  //# sourceMappingURL=lifeready-core.umd.min.js.map