var runtime=function(a){"use strict";var c,e=Object.prototype,u=e.hasOwnProperty,t="function"==typeof Symbol?Symbol:{},i=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",r=t.toStringTag||"@@toStringTag";function o(e,t,n,r){var i=t&&t.prototype instanceof s?t:s,a=Object.create(i.prototype),o=new A(r||[]);return a._invoke=function(a,o,s){var c=d;return function(e,t){if(c===h)throw new Error("Generator is already running");if(c===p){if("throw"===e)throw t;return I()}for(s.method=e,s.arg=t;;){var n=s.delegate;if(n){var r=S(n,s);if(r){if(r===v)continue;return r}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if(c===d)throw c=p,s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);c=h;var i=l(a,o,s);if("normal"===i.type){if(c=s.done?p:f,i.arg===v)continue;return{value:i.arg,done:s.done}}"throw"===i.type&&(c=p,s.method="throw",s.arg=i.arg)}}}(e,n,o),a}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}a.wrap=o;var d="suspendedStart",f="suspendedYield",h="executing",p="completed",v={};function s(){}function m(){}function g(){}var y={};y[i]=function(){return this};var b=Object.getPrototypeOf,k=b&&b(b(_([])));k&&k!==e&&u.call(k,i)&&(y=k);var w=g.prototype=s.prototype=Object.create(y);function $(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function x(c){var t;this._invoke=function(n,r){function e(){return new Promise(function(e,t){!function t(e,n,r,i){var a=l(c[e],c,n);if("throw"!==a.type){var o=a.arg,s=o.value;return s&&"object"==typeof s&&u.call(s,"__await")?Promise.resolve(s.__await).then(function(e){t("next",e,r,i)},function(e){t("throw",e,r,i)}):Promise.resolve(s).then(function(e){o.value=e,r(o)},function(e){return t("throw",e,r,i)})}i(a.arg)}(n,r,e,t)})}return t=t?t.then(e,e):e()}}function S(e,t){var n=e.iterator[t.method];if(n===c){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=c,S(e,t),"throw"===t.method))return v;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var r=l(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,v;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=c),t.delegate=null,v):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function M(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(M,this),this.reset(!0)}function _(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,o=0;o<4&&i+.75*o>>6*(3-o)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;!(r=n.charAt(64))||-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,a=0;a>>6-a%4*2;r[i>>>2]|=(o|s)<<24-i%4*8,i++}return c.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(a){function x(e,t,n,r,i,a,o){return((e=e+(t&n|~t&r)+i+o)<>>32-a)+t}function S(e,t,n,r,i,a,o){return((e=e+(t&r|n&~r)+i+o)<>>32-a)+t}function M(e,t,n,r,i,a,o){return((e=e+(t^n^r)+i+o)<>>32-a)+t}function C(e,t,n,r,i,a,o){return((e=e+(n^(t|~r))+i+o)<>>32-a)+t}for(var e=I,t=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,A=[],i=0;i<64;i++)A[i]=4294967296*a.abs(a.sin(i+1))|0;r=r.MD5=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=e[o=t+n];e[o]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}n=this._hash.words;var i,a,o=e[t+0],s=(r=e[t+1],e[t+2]),c=e[t+3],u=e[t+4],l=e[t+5],d=e[t+6],f=e[t+7],h=e[t+8],p=e[t+9],v=e[t+10],m=e[t+11],g=e[t+12],y=e[t+13],b=e[t+14],k=e[t+15],w=n[0],$=C($=C($=C($=C($=M($=M($=M($=M($=S($=S($=S($=S($=x($=x($=x($=x($=n[1],a=x(a=n[2],i=x(i=n[3],w=x(w,$,a,i,o,7,A[0]),$,a,r,12,A[1]),w,$,s,17,A[2]),i,w,c,22,A[3]),a=x(a,i=x(i,w=x(w,$,a,i,u,7,A[4]),$,a,l,12,A[5]),w,$,d,17,A[6]),i,w,f,22,A[7]),a=x(a,i=x(i,w=x(w,$,a,i,h,7,A[8]),$,a,p,12,A[9]),w,$,v,17,A[10]),i,w,m,22,A[11]),a=x(a,i=x(i,w=x(w,$,a,i,g,7,A[12]),$,a,y,12,A[13]),w,$,b,17,A[14]),i,w,k,22,A[15]),a=S(a,i=S(i,w=S(w,$,a,i,r,5,A[16]),$,a,d,9,A[17]),w,$,m,14,A[18]),i,w,o,20,A[19]),a=S(a,i=S(i,w=S(w,$,a,i,l,5,A[20]),$,a,v,9,A[21]),w,$,k,14,A[22]),i,w,u,20,A[23]),a=S(a,i=S(i,w=S(w,$,a,i,p,5,A[24]),$,a,b,9,A[25]),w,$,c,14,A[26]),i,w,h,20,A[27]),a=S(a,i=S(i,w=S(w,$,a,i,y,5,A[28]),$,a,s,9,A[29]),w,$,f,14,A[30]),i,w,g,20,A[31]),a=M(a,i=M(i,w=M(w,$,a,i,l,4,A[32]),$,a,h,11,A[33]),w,$,m,16,A[34]),i,w,b,23,A[35]),a=M(a,i=M(i,w=M(w,$,a,i,r,4,A[36]),$,a,u,11,A[37]),w,$,f,16,A[38]),i,w,v,23,A[39]),a=M(a,i=M(i,w=M(w,$,a,i,y,4,A[40]),$,a,o,11,A[41]),w,$,c,16,A[42]),i,w,d,23,A[43]),a=M(a,i=M(i,w=M(w,$,a,i,p,4,A[44]),$,a,g,11,A[45]),w,$,k,16,A[46]),i,w,s,23,A[47]),a=C(a,i=C(i,w=C(w,$,a,i,o,6,A[48]),$,a,f,10,A[49]),w,$,b,15,A[50]),i,w,l,21,A[51]),a=C(a,i=C(i,w=C(w,$,a,i,g,6,A[52]),$,a,c,10,A[53]),w,$,v,15,A[54]),i,w,r,21,A[55]),a=C(a,i=C(i,w=C(w,$,a,i,h,6,A[56]),$,a,k,10,A[57]),w,$,d,15,A[58]),i,w,y,21,A[59]),a=C(a,i=C(i,w=C(w,$,a,i,u,6,A[60]),$,a,m,10,A[61]),w,$,s,15,A[62]),i,w,p,21,A[63]);n[0]=n[0]+w|0,n[1]=n[1]+$|0,n[2]=n[2]+a|0,n[3]=n[3]+i|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32;var i=a.floor(n/4294967296);for(t[15+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(t.length+1),this._process(),t=(e=this._hash).words,n=0;n<4;n++)r=t[n],t[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}}),e.MD5=n._createHelper(r),e.HmacMD5=n._createHmacHelper(r)}(Math),i=(n=(r=I).lib).Base,u=n.WordArray,a=(n=r.algo).EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:n.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(o=this.cfg).hasher.create(),r=u.create(),i=r.words,a=o.keySize,o=o.iterations;i.length>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:c,padding:u}),reset:function(){a.reset.call(this);var e=(t=this.cfg).iv,t=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=t.createEncryptor;else n=t.createDecryptor,this._minBufferSize=1;this._mode=n.call(t,this,e&&e.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var l=e.CipherParams=t.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),d=(c=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?o.create([1398893684,1701076831]).concat(e).concat(t):t).toString(r)},parse:function(e){var t=(e=r.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=o.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return l.create({ciphertext:e,salt:n})}},e.SerializableCipher=t.extend({cfg:t.extend({format:c}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,l.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,r){return r=r||o.random(8),e=i.create({keySize:t+n}).compute(e,r),n=o.create(e.words.slice(t),4*n),e.sigBytes=4*t,l.create({key:e,iv:n,salt:r})}},h=e.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=d.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=I,t=e.lib.BlockCipher,n=e.algo,o=[],r=[],i=[],a=[],s=[],c=[],u=[],l=[],d=[],f=[],h=[],p=0;p<256;p++)h[p]=p<128?p<<1:p<<1^283;var v=0,m=0;for(p=0;p<256;p++){var g=(g=m^m<<1^m<<2^m<<3^m<<4)>>>8^255&g^99;o[v]=g;var y=h[r[g]=v],b=h[y],k=h[b],w=257*h[g]^16843008*g;i[v]=w<<24|w>>>8,a[v]=w<<16|w>>>16,s[v]=w<<8|w>>>24,c[v]=w,w=16843009*k^65537*b^257*y^16843008*v,u[g]=w<<24|w>>>8,l[g]=w<<16|w>>>16,d[g]=w<<8|w>>>24,f[g]=w,v?(v=y^h[h[h[k^y]]],m^=h[h[m]]):v=m=1}var $=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),r=this._keySchedule=[],i=0;i>>24]<<24|o[a>>>16&255]<<16|o[a>>>8&255]<<8|o[255&a]):(a=o[(a=a<<8|a>>>24)>>>24]<<24|o[a>>>16&255]<<16|o[a>>>8&255]<<8|o[255&a],a^=$[i/t|0]<<24),r[i]=r[i-t]^a}for(e=this._invKeySchedule=[],t=0;t>>24]]^l[o[a>>>16&255]]^d[o[a>>>8&255]]^f[o[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,c,o)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,u,l,d,f,r),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,a,o,s){for(var c=this._nRounds,u=e[t]^n[0],l=e[t+1]^n[1],d=e[t+2]^n[2],f=e[t+3]^n[3],h=4,p=1;p>>24]^i[l>>>16&255]^a[d>>>8&255]^o[255&f]^n[h++],m=r[l>>>24]^i[d>>>16&255]^a[f>>>8&255]^o[255&u]^n[h++],g=r[d>>>24]^i[f>>>16&255]^a[u>>>8&255]^o[255&l]^n[h++];f=r[f>>>24]^i[u>>>16&255]^a[l>>>8&255]^o[255&d]^n[h++],u=v,l=m,d=g}v=(s[u>>>24]<<24|s[l>>>16&255]<<16|s[d>>>8&255]<<8|s[255&f])^n[h++],m=(s[l>>>24]<<24|s[d>>>16&255]<<16|s[f>>>8&255]<<8|s[255&u])^n[h++],g=(s[d>>>24]<<24|s[f>>>16&255]<<16|s[u>>>8&255]<<8|s[255&l])^n[h++],f=(s[f>>>24]<<24|s[u>>>16&255]<<16|s[l>>>8&255]<<8|s[255&d])^n[h++],e[t]=v,e[t+1]=m,e[t+2]=g,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}();var o,l;I=I||function(s){function n(){}var e={},t=e.lib={},r=t.Base={extend:function(e){n.prototype=this;var t=new n;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),(t.init.prototype=t).$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=t.WordArray=r.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>7)^(f<<14|f>>>18)^f>>>3)+v[d-7]+((h<<15|h>>>17)^(h<<13|h>>>19)^h>>>10)+v[d-16]}f=l+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&c^~s&u)+p[d]+v[d],h=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&a^i&a),l=u,u=c,c=s,s=o+f|0,o=a,a=i,i=r,r=f+h|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0,n[5]=n[5]+c|0,n[6]=n[6]+u|0,n[7]=n[7]+l|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=i.floor(n/4294967296),t[15+(64+r>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(a),t.HmacSHA256=r._createHmacHelper(a)}(Math),l=(o=I).enc.Utf8,o.algo.HMAC=o.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=l.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),o=i.words,s=a.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>1|(K=z.low)<<31)^(q>>>8|K<<24)^q>>>7;var K=(K>>>1|q<<31)^(K>>>8|q<<24)^(K>>>7|q<<25),W=((q=(W=ne[H-2]).high)>>>19|(J=W.low)<<13)^(q<<3|J>>>29)^q>>>6,J=(J>>>19|q<<13)^(J<<3|q>>>29)^(J>>>6|q<<26),G=(q=ne[H-7]).high,Y=(Z=ne[H-16]).high,Z=Z.low;z=(z=(z=z+G+((q=K+q.low)>>>0>>0?1:0))+W+((q=q+J)>>>0>>0?1:0))+Y+((q=q+Z)>>>0>>0?1:0);V.high=z,V.low=q}G=P&N^~P&L,Z=O&F^~O&j,V=C&_^C&D^_&D;var X=A&I^A&E^I&E,Q=(K=(C>>>28|A<<4)^(C<<30|A>>>2)^(C<<25|A>>>7),W=(A>>>28|C<<4)^(A<<30|C>>>2)^(A<<25|C>>>7),(J=te[H]).high),ee=J.low;Y=U+((P>>>14|O<<18)^(P>>>18|O<<14)^(P<<23|O>>>9))+((J=B+((O>>>14|P<<18)^(O>>>18|P<<14)^(O<<23|P>>>9)))>>>0>>0?1:0),U=L,B=j,L=N,j=F,N=P,F=O,P=T+(Y=(Y=(Y=Y+G+((J=J+Z)>>>0>>0?1:0))+Q+((J=J+ee)>>>0>>0?1:0))+z+((J=J+q)>>>0>>0?1:0))+((O=R+J|0)>>>0>>0?1:0)|0,T=D,R=E,D=_,E=I,_=C,I=A,C=Y+(V=K+V+((q=W+X)>>>0>>0?1:0))+((A=J+q|0)>>>0>>0?1:0)|0}d=n.low=d+A,n.high=l+C+(d>>>0>>0?1:0),h=r.low=h+I,r.high=f+_+(h>>>0>>0?1:0),v=i.low=v+E,i.high=p+D+(v>>>0>>0?1:0),g=a.low=g+R,a.high=m+T+(g>>>0>>0?1:0),b=o.low=b+O,o.high=y+P+(b>>>0>>0?1:0),w=s.low=w+F,s.high=k+N+(w>>>0>>0?1:0),x=c.low=x+j,c.high=$+L+(x>>>0>>0?1:0),M=u.low=M+B,u.high=S+U+(M>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(128+r>>>10<<5)]=Math.floor(n/4294967296),t[31+(128+r>>>10<<5)]=n,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32}),t.SHA512=n._createHelper(a),t.HmacSHA512=n._createHmacHelper(a)}(),v=(p=I).enc.Utf8,p.algo.HMAC=p.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=v.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),o=i.words,s=a.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>31}u=(r<<5|r>>>27)+s+b[c],u=c<20?u+(1518500249+(i&a|~i&o)):c<40?u+(1859775393+(i^a^o)):c<60?u+((i&a|i&o|a&o)-1894007588):u+((i^a^o)-899497514),s=o,o=a,a=i<<30|i>>>2,i=r,r=u}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=Math.floor(n/4294967296),t[15+(64+r>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=y.clone.call(this);return e._hash=this._hash.clone(),e}}),m.SHA1=y._createHelper(k),m.HmacSHA1=y._createHmacHelper(k),$=(w=I).enc.Utf8,w.algo.HMAC=w.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=$.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),o=i.words,s=a.words,c=0;c>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=s.ceil(t/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},o=i.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(o.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return o.parse(unescape(encodeURIComponent(e)))}},l=t.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,r=t.sigBytes,i=this.blockSize,a=r/(4*i);if(e=(a=e?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,r=s.min(4*e,r),e){for(var o=0;o>>31}u=(r<<5|r>>>27)+s+P[c],u=c<20?u+(1518500249+(i&a|~i&o)):c<40?u+(1859775393+(i^a^o)):c<60?u+((i&a|i&o|a&o)-1894007588):u+((i^a^o)-899497514),s=o,o=a,a=i<<30|i>>>2,i=r,r=u}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(64+r>>>9<<4)]=Math.floor(n/4294967296),t[15+(64+r>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=R.clone.call(this);return e._hash=this._hash.clone(),e}}),E.SHA1=R._createHelper(O),E.HmacSHA1=R._createHmacHelper(O),Object.defineProperty(Te,"__esModule",{value:!0}),Te.StandardNotes=Te.SFItemTransformer=Te.SFCryptoWeb=Te.SFCryptoJS=Te.SFAbstractCrypto=Te.SNTheme=Te.SNSmartTag=Te.SFItemHistoryEntry=Te.SFItemHistory=Te.SFHistorySession=Te.SNServerExtension=Te.SNMfa=Te.SFPrivileges=Te.SNEncryptedStorage=Te.SNTag=Te.SNNote=Te.SNExtension=Te.Action=Te.SNEditor=Te.SNComponent=Te.SFPredicate=Te.SFItemParams=Te.SFItem=Te.SFSyncManager=Te.SFStorageManager=Te.SFSingletonManager=Te.SFSessionHistoryManager=Te.SFPrivilegesManager=Te.SFModelManager=Te.SFMigrationManager=Te.SFHttpManager=Te.SNComponentManager=Te.SFAuthManager=Te.SFAlertManager=void 0;var K=function(){function e(){V(this,e)}return q(e,[{key:"alert",value:function(n){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,t){window.alert(n.text),e()}));case 1:case"end":return e.stop()}})}},{key:"confirm",value:function(n){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,t){window.confirm(n.text)?e():t()}));case 1:case"end":return e.stop()}})}}]),e}();Te.SFAlertManager=K;var W=function(){function y(e,t,n,r){V(this,y),y.DidSignOutEvent="DidSignOutEvent",y.WillSignInEvent="WillSignInEvent",y.DidSignInEvent="DidSignInEvent",this.httpManager=t,this.storageManager=e,this.alertManager=n||new K,this.$timeout=r||setTimeout.bind(window),this.eventHandlers=[]}return q(y,[{key:"addEventHandler",value:function(e){return this.eventHandlers.push(e),e}},{key:"removeEventHandler",value:function(e){_.pull(this.eventHandlers,e)}},{key:"notifyEvent",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.eventHandlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){(0,a.value)(e,t||{})}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}},{key:"saveKeys",value:function(t){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this._keys=t,e.next=3,regeneratorRuntime.awrap(this.storageManager.setItem("mk",t.mk));case 3:return e.next=5,regeneratorRuntime.awrap(this.storageManager.setItem("ak",t.ak));case 5:case"end":return e.stop()}},null,this)}},{key:"signout",value:function(t){var n=this;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._keys=null,this._authParams=null,t)return e.abrupt("return",this.storageManager.clearAllData().then(function(){n.notifyEvent(y.DidSignOutEvent)}));e.next=6;break;case 6:this.notifyEvent(y.DidSignOutEvent);case 7:case"end":return e.stop()}},null,this)}},{key:"keys",value:function(){var t;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._keys){e.next=11;break}return e.next=3,regeneratorRuntime.awrap(this.storageManager.getItem("mk"));case 3:if(t=e.sent){e.next=6;break}return e.abrupt("return",null);case 6:return e.t0=t,e.next=9,regeneratorRuntime.awrap(this.storageManager.getItem("ak"));case 9:e.t1=e.sent,this._keys={mk:e.t0,ak:e.t1};case 11:return e.abrupt("return",this._keys);case 12:case"end":return e.stop()}},null,this)}},{key:"getAuthParams",value:function(){var t;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._authParams){e.next=5;break}return e.next=3,regeneratorRuntime.awrap(this.storageManager.getItem("auth_params"));case 3:t=e.sent,this._authParams=JSON.parse(t);case 5:if(this._authParams&&!this._authParams.version)return e.next=8,regeneratorRuntime.awrap(this.defaultProtocolVersion());e.next=9;break;case 8:this._authParams.version=e.sent;case 9:return e.abrupt("return",this._authParams);case 10:case"end":return e.stop()}},null,this)}},{key:"defaultProtocolVersion",value:function(){var t;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(this.keys());case 2:if((t=e.sent)&&t.ak)return e.abrupt("return","002");e.next=7;break;case 7:return e.abrupt("return","001");case 8:case"end":return e.stop()}},null,this)}},{key:"protocolVersion",value:function(){var t;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(this.getAuthParams());case 2:if((t=e.sent)&&t.version)return e.abrupt("return",t.version);e.next=5;break;case 5:return e.abrupt("return",this.defaultProtocolVersion());case 6:case"end":return e.stop()}},null,this)}},{key:"getAuthParamsForEmail",value:function(r,t,n){var i,a=this;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return(i=_.merge({email:t},n)).api=Y.getApiVersion(),e.abrupt("return",new Promise(function(t,e){var n=r+"/auth/params";a.httpManager.getAbsolute(n,i,function(e){t(e)},function(e){console.error("Error getting auth params",e),"object"!==H(e)&&(e={error:{message:"A server error occurred while trying to sign in. Please try again."}}),t(e)})}));case 3:case"end":return e.stop()}})}},{key:"lock",value:function(){this.locked=!0}},{key:"unlock",value:function(){this.locked=!1}},{key:"isLocked",value:function(){return 1==this.locked}},{key:"unlockAndResolve",value:function(e,t){this.unlock(),e(t)}},{key:"login",value:function(f,h,p,v,m){var g=this;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(n){var r,t,i,a,o,s,c,u,l,d;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(g.keys());case 2:if(null!=e.sent)return n({error:{message:"Cannot log in because already signed in."}}),e.abrupt("return");e.next=6;break;case 6:if(g.isLocked())return n({error:{message:"Login already in progress."}}),e.abrupt("return");e.next=9;break;case 9:return g.lock(),g.notifyEvent(y.WillSignInEvent),e.next=13,regeneratorRuntime.awrap(g.getAuthParamsForEmail(f,h,m));case 13:if((r=e.sent).identifier=h,r.error)return g.unlockAndResolve(n,r),e.abrupt("return");e.next=18;break;case 18:if(r&&r.pw_cost){e.next=21;break}return g.unlockAndResolve(n,{error:{message:"Invalid email or password."}}),e.abrupt("return");case 21:if(SNJS.supportedVersions().includes(r.version)){e.next=25;break}return t=SNJS.isVersionNewerThanLibraryVersion(r.version)?"This version of the application does not support your newer account type. Please upgrade to the latest version of Standard Notes to sign in.":"The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.org/help/security for more information.",g.unlockAndResolve(n,{error:{message:t}}),e.abrupt("return");case 25:if(SNJS.isProtocolVersionOutdated(r.version))return i="The encryption version for your account, ".concat(r.version,", is outdated and requires upgrade. You may proceed with login, but are advised to perform a security update using the web or desktop application. Please visit standardnotes.org/help/security for more information."),a=!1,e.next=30,regeneratorRuntime.awrap(g.alertManager.confirm({title:"Update Needed",text:i,confirmButtonText:"Sign In"}).catch(function(){g.unlockAndResolve(n,{error:{}}),a=!0}));e.next=32;break;case 30:if(a)return e.abrupt("return");e.next=32;break;case 32:if(SNJS.supportsPasswordDerivationCost(r.pw_cost)){e.next=36;break}return"Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in.",g.unlockAndResolve(n,{error:{message:"Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in."}}),e.abrupt("return");case 36:if(o=SNJS.costMinimumForVersion(r.version),r.pw_costnew Date)return e.abrupt("return",!1);e.next=5;break;case 5:return e.next=7,regeneratorRuntime.awrap(this.netCredentialsForAction(t));case 7:return n=e.sent,e.abrupt("return",0=this.MaxDiscordanceBeforeOutOfSync&&(this.outOfSync||(this.outOfSync=!0,this.notifyEvent("enter-out-of-sync"))),e.abrupt("return",!1);e.next=13;break;case 13:return this.outOfSync&&(this.outOfSync=!1,this.notifyEvent("exit-out-of-sync")),this.syncDiscordance=0,e.abrupt("return",!0);case 16:case"end":return e.stop()}},null,this)}},{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"getServerURL",value:function(){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(this.storageManager.getItem("server"));case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=window._default_sf_server;case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},null,this)}},{key:"getSyncURL",value:function(){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(this.getServerURL());case 2:return e.t0=e.sent,e.abrupt("return",e.t0+"/items/sync");case 4:case"end":return e.stop()}},null,this)}},{key:"registerSyncStatusObserver",value:function(e){var t={key:new Date,callback:e};return this.syncStatusObservers.push(t),t}},{key:"removeSyncStatusObserver",value:function(e){_.pull(this.syncStatusObservers,e)}},{key:"syncStatusDidChange",value:function(){var t=this;this.syncStatusObservers.forEach(function(e){e.callback(t.syncStatus)})}},{key:"addEventHandler",value:function(e){return this.eventHandlers.push(e),e}},{key:"removeEventHandler",value:function(e){_.pull(this.eventHandlers,e)}},{key:"notifyEvent",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=this.eventHandlers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){(0,a.value)(e,t||{})}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}},{key:"setKeyRequestHandler",value:function(e){this.keyRequestHandler=e}},{key:"getActiveKeyInfo",value:function(t){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.keyRequestHandler(t));case 1:case"end":return e.stop()}},null,this)}},{key:"initialDataLoaded",value:function(){return!0===this._initialDataLoaded}},{key:"_sortLocalItems",value:function(e){var o=this;return e.sort(function(e,t){var n=new Date(t.updated_at)-new Date(e.updated_at),r=o.contentTypeLoadPriority,i=0,a=0;return r&&(i=r.indexOf(e.content_type),a=r.indexOf(t.content_type),-1==i&&(i=r.length),-1==a&&(a=r.length)),i==a?n:it.dirtiedDate})).length,o=0,s=[];return function n(){var t,r;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.slice(o,o+u),e.next=3,regeneratorRuntime.awrap(l.handleItemsResponse(t,null,X.MappingSourceLocalRetrieved,P.KeyRequestLoadLocal));case 3:if(r=e.sent,s.push(r),(o+=t.length)g.lastDirtyItemsSave}),e.next=5,regeneratorRuntime.awrap(g.getActiveKeyInfo(P.KeyRequestLoadSaveAccount));case 5:if(i=e.sent,a=g.syncStatus.syncOpInProgress,o=g.initialDataLoaded(),a||!o)return g.performSyncAgainOnCompletion=!0,g.lastDirtyItemsSave=new Date,e.next=13,regeneratorRuntime.awrap(g.writeItemsToLocalStorage(t,!1));e.next=16;break;case 13:return a&&(g.queuedCallbacks.push(n),g.loggingEnabled&&console.warn("Attempting to sync while existing sync is in progress.")),o||(g.loggingEnabled&&console.warn("(1) Attempting to perform online sync before local data has loaded"),n()),e.abrupt("return");case 16:if(g.syncStatus.syncOpInProgress=!0,i.offline)return e.abrupt("return",g.syncOffline(r).then(function(e){g.syncStatus.syncOpInProgress=!1,n(e)}).catch(function(e){g.notifyEvent("sync-exception",e)}));e.next=19;break;case 19:if(g.initialDataLoaded()){e.next=22;break}return console.error("Attempting to perform online sync before local data has loaded"),e.abrupt("return");case 22:return g.loggingEnabled&&console.log("Syncing online user."),s=g.syncStatus.needsMoreSync,g.syncStatus.syncStart=new Date,g.beginCheckingIfSyncIsTakingTooLong(),c=g.PerSyncItemUploadLimit,(u=r.slice(0,c)).lengthg.syncStatus.total&&(g.syncStatus.total=g.syncStatus.current),g.syncStatusDidChange(),e.next=34,regeneratorRuntime.awrap(g.writeItemsToLocalStorage(t,!1));case 34:return g.lastDirtyItemsSave=new Date,m.onPreSyncSave&&m.onPreSyncSave(),g.allRetreivedItems||(g.allRetreivedItems=[]),g.allSavedItems||(g.allSavedItems=[]),(l={}).limit=g.ServerItemDownloadLimit,m.performIntegrityCheck&&(l.compute_integrity=!0),e.prev=41,e.next=44,regeneratorRuntime.awrap(Promise.all(u.map(function(e){var t=new ue(e,i.keys,i.auth_params);return t.additionalFields=m.additionalFields,t.paramsForSync()})).then(function(e){l.items=e}));case 44:e.next=49;break;case 46:e.prev=46,e.t0=e.catch(41),g.notifyEvent("sync-exception",e.t0);case 49:for(f=!(d=!0),h=void 0,e.prev=52,p=u[Symbol.iterator]();!(d=(v=p.next()).done);d=!0)v.value.dirtyCount=0;e.next=60;break;case 56:e.prev=56,e.t1=e.catch(52),f=!0,h=e.t1;case 60:e.prev=60,e.prev=61,d||null==p.return||p.return();case 63:if(e.prev=63,f)throw h;e.next=66;break;case 66:return e.finish(63);case 67:return e.finish(60);case 68:return e.next=70,regeneratorRuntime.awrap(g.getSyncToken());case 70:return l.sync_token=e.sent,e.next=73,regeneratorRuntime.awrap(g.getCursorToken());case 73:return l.cursor_token=e.sent,l.api=Y.getApiVersion(),g.loggingEnabled&&console.log("Syncing with params",l),e.prev=76,e.t2=g.httpManager,e.next=80,regeneratorRuntime.awrap(g.getSyncURL());case 80:e.t3=e.sent,e.t4=l,e.t5=function(e){g.handleSyncSuccess(u,e,m).then(function(){n(e)}).catch(function(t){console.log("Caught sync success exception:",t),g.handleSyncError(t,null,r).then(function(e){g.notifyEvent("sync-exception",t),n(e)})})},e.t6=function(e,t){g.handleSyncError(e,t,r).then(function(e){n(e)})},e.t2.postAuthenticatedAbsolute.call(e.t2,e.t3,e.t4,e.t5,e.t6),e.next=90;break;case 87:e.prev=87,e.t7=e.catch(76),console.log("Sync exception caught:",e.t7);case 90:case"end":return e.stop()}},null,null,[[41,46],[52,56,60,68],[61,,63,67],[76,87]])}));case 5:case"end":return e.stop()}},null,this)}},{key:"_awaitSleep",value:function(n){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return console.warn("Simulating high latency sync request",n),e.abrupt("return",new Promise(function(e,t){setTimeout(function(){e()},n)}));case 2:case"end":return e.stop()}})}},{key:"handleSyncSuccess",value:function(t,n,r){var i,a,o,s,c,u,l,d,f,h,p,v,m,g,y,b,k=this;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(r.simulateHighLatency)return i=r.simulatedLatency||1e3,e.next=4,regeneratorRuntime.awrap(this._awaitSleep(i));e.next=4;break;case 4:for(this.syncStatus.error=null,this.loggingEnabled&&console.log("Sync response",n),a=this.allSavedItems.map(function(e){return e.uuid}),o=n.saved_items.map(function(e){return e.uuid}),n.retrieved_items=n.retrieved_items.filter(function(e){var t=a.includes(e.uuid),n=o.includes(e.uuid);if(t||n)return!1;var r=k.modelManager.findItem(e.uuid);return!r||!r.dirty}),s=[],u=!(c=!0),l=void 0,e.prev=13,d=t[Symbol.iterator]();!(c=(f=d.next()).done);c=!0)0==(h=f.value).dirtyCount&&s.push(h);e.next=21;break;case 17:e.prev=17,e.t0=e.catch(13),u=!0,l=e.t0;case 21:e.prev=21,e.prev=22,c||null==d.return||d.return();case 24:if(e.prev=24,u)throw l;e.next=27;break;case 27:return e.finish(24);case 28:return e.finish(21);case 29:return this.modelManager.clearDirtyItems(s),e.next=32,regeneratorRuntime.awrap(this.handleItemsResponse(n.retrieved_items,null,X.MappingSourceRemoteRetrieved,P.KeyRequestLoadSaveAccount));case 32:return p=e.sent,this.allRetreivedItems=this.allRetreivedItems.concat(p),this.syncStatus.retrievedCount=this.allRetreivedItems.length,v=["content","auth_hash"],e.next=38,regeneratorRuntime.awrap(this.handleItemsResponse(n.saved_items,v,X.MappingSourceRemoteSaved,P.KeyRequestLoadSaveAccount));case 38:return m=e.sent,this.allSavedItems=this.allSavedItems.concat(m),g=n.unsaved,e.next=43,regeneratorRuntime.awrap(this.deprecated_handleUnsavedItemsResponse(g));case 43:return e.next=45,regeneratorRuntime.awrap(this.handleConflictsResponse(n.conflicts));case 45:if(y=e.sent,b=y&&0=this.majorDataChangeThreshold||m.length>=this.majorDataChangeThreshold||g&&g.length>=this.majorDataChangeThreshold||y&&y.length>=this.majorDataChangeThreshold)&&this.notifyEvent("major-data-change"),this.callQueuedCallbacks(n),this.notifyEvent("sync:completed",{retrievedItems:this.allRetreivedItems,savedItems:this.allSavedItems}),this.allRetreivedItems=[],this.allSavedItems=[],this.performSyncAgainOnCompletion&&(this.performSyncAgainOnCompletion=!1,setTimeout(function(){k.sync(r)},10)),e.abrupt("return",n);case 88:case"end":return e.stop()}},null,this,[[13,17,21,29],[22,,24,28]])}},{key:"handleSyncError",value:function(t,n,r){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Sync error: ",t),401==n&&this.notifyEvent("sync-session-invalid"),t?"string"==typeof t&&(t={error:{message:t}}):t={error:{message:"Could not connect to server."}},this.syncStatus.syncOpInProgress=!1,this.syncStatus.error=t.error,this.syncStatusDidChange(),this.writeItemsToLocalStorage(r,!1),this.modelManager.didSyncModelsOffline(r),this.stopCheckingIfSyncIsTakingTooLong(),this.notifyEvent("sync:error",t.error),this.callQueuedCallbacks({error:"Sync error"}),e.abrupt("return",t);case 12:case"end":return e.stop()}},null,this)}},{key:"handleItemsResponse",value:function(t,n,r,i){var a,o,s;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(this.getActiveKeyInfo(i));case 2:return a=e.sent.keys,e.next=5,regeneratorRuntime.awrap(SNJS.itemTransformer.decryptMultipleItems(t,a));case 5:return e.next=7,regeneratorRuntime.awrap(this.modelManager.mapResponseItemsToLocalModelsOmittingFields(t,n,r));case 7:return o=e.sent,0<(s=o.filter(function(e){var t=e.errorDecryptingValueChanged;return e.errorDecryptingValueChanged=!1,t})).length&&this.writeItemsToLocalStorage(s,!1),e.abrupt("return",o);case 11:case"end":return e.stop()}},null,this)}},{key:"refreshErroredItems",value:function(){var t;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(0<(t=this.modelManager.allNondummyItems.filter(function(e){return 1==e.errorDecrypting})).length)return e.abrupt("return",this.handleItemsResponse(t,null,X.MappingSourceLocalRetrieved,P.KeyRequestLoadSaveAccount));e.next=3;break;case 3:case"end":return e.stop()}},null,this)}},{key:"handleConflictsResponse",value:function(t){var n,r,i,a,o,s,c,u,l,d,f,h,p,v,m,g,y,b,k,w,$,x,S,M,C,A,_,I,D,E,T,R;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&0!=t.length){e.next=2;break}return e.abrupt("return");case 2:this.loggingEnabled&&console.log("Handle Conflicted Items:",t),n={},i=!(r=!0),a=void 0,e.prev=7,o=t[Symbol.iterator]();case 9:if(r=(s=o.next()).done){e.next=21;break}if(c=s.value,u=c.server_item||c.unsaved_item,l=this.modelManager.findItem(u.uuid)){e.next=16;break}return n[u.uuid]={},e.abrupt("continue",18);case 16:d=l.getContentCopy(),n[u.uuid]={frozenContent:d,itemRef:l};case 18:r=!0,e.next=9;break;case 21:e.next=27;break;case 23:e.prev=23,e.t0=e.catch(7),i=!0,a=e.t0;case 27:e.prev=27,e.prev=28,r||null==o.return||o.return();case 30:if(e.prev=30,i)throw a;e.next=33;break;case 33:return e.finish(30);case 34:return e.finish(27);case 35:f=[],p=!(h=!0),v=void 0,e.prev=39,m=t[Symbol.iterator]();case 41:if(h=(g=m.next()).done){e.next=93;break}return y=g.value,b=y.server_item||y.unsaved_item,e.t1=regeneratorRuntime,e.t2=SNJS.itemTransformer,e.t3=[b],e.next=49,regeneratorRuntime.awrap(this.getActiveKeyInfo(P.KeyRequestLoadSaveAccount));case 49:return e.t4=e.sent.keys,e.t5=e.t2.decryptMultipleItems.call(e.t2,e.t3,e.t4),e.next=53,e.t1.awrap.call(e.t1,e.t5);case 53:if(k=n[b.uuid],w=k.frozenContent,$=k.itemRef){e.next=56;break}return e.abrupt("continue",90);case 56:if(f.push($),"uuid_conflict"===y.type)return e.next=60,regeneratorRuntime.awrap(this.modelManager.alternateUUIDForItem($));e.next=64;break;case 60:x=e.sent,f.push(x),e.next=90;break;case 64:if("sync_conflict"===y.type)return e.next=67,regeneratorRuntime.awrap(this.modelManager.createDuplicateItemFromResponseItem(b));e.next=88;break;case 67:if(S=e.sent,M=this.modelManager.duplicateItemWithCustomContent({content:w,duplicateOf:$}),C=!M.isItemContentEqualWith(S),A=!$.isItemContentEqualWith(S),E=D=I=_=!1,b.deleted||$.deleted?E=!0:C?(20,(new Date-$.client_updated_at)/1e3<20?I=D=!0:E=_=!0):A?(T=!ce.AreItemContentsEqual({leftContent:$.content,rightContent:S.content,keysToIgnore:$.keysToIgnoreWhenCheckingContentEquality().concat(["references"]),appDataKeysToIgnore:$.appDataKeysToIgnoreWhenCheckingContentEquality()}),!T?D=!0:E=_=!0):E=!0,_)return e.next=79,regeneratorRuntime.awrap(this.modelManager.duplicateItemWithCustomContentAndAddAsConflict({content:w,duplicateOf:$}));e.next=81;break;case 79:R=e.sent,f.push(R);case 81:if(I&&(this.modelManager.addDuplicatedItemAsConflict({duplicate:S,duplicateOf:$}),f.push(S)),E)return e.next=85,regeneratorRuntime.awrap(this.modelManager.mapResponseItemsToLocalModelsOmittingFields([b],null,X.MappingSourceRemoteRetrieved));e.next=85;break;case 85:D&&($.updated_at=S.updated_at,$.setDirty(!0)),e.next=90;break;case 88:return console.error("Unsupported conflict type",y.type),e.abrupt("continue",90);case 90:h=!0,e.next=41;break;case 93:e.next=99;break;case 95:e.prev=95,e.t6=e.catch(39),p=!0,v=e.t6;case 99:e.prev=99,e.prev=100,h||null==m.return||m.return();case 102:if(e.prev=102,p)throw v;e.next=105;break;case 105:return e.finish(102);case 106:return e.finish(99);case 107:return e.abrupt("return",f);case 108:case"end":return e.stop()}},null,this,[[7,23,27,35],[28,,30,34],[39,95,99,107],[100,,102,106]])}},{key:"deprecated_handleUnsavedItemsResponse",value:function(t){var n,r,i,a,o,s,c,u,l,d;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&0!=t.length){e.next=2;break}return e.abrupt("return");case 2:this.loggingEnabled&&console.log("Handle Unsaved Items:",t),r=!(n=!0),i=void 0,e.prev=6,a=t[Symbol.iterator]();case 8:if(n=(o=a.next()).done){e.next=37;break}return s=o.value,c=s.item,e.t0=regeneratorRuntime,e.t1=SNJS.itemTransformer,e.t2=[c],e.next=16,regeneratorRuntime.awrap(this.getActiveKeyInfo(P.KeyRequestLoadSaveAccount));case 16:return e.t3=e.sent.keys,e.t4=e.t1.decryptMultipleItems.call(e.t1,e.t2,e.t3),e.next=20,e.t0.awrap.call(e.t0,e.t4);case 20:if(u=this.modelManager.findItem(c.uuid)){e.next=23;break}return e.abrupt("continue",34);case 23:if("uuid_conflict"===(l=s.error).tag)return e.next=27,regeneratorRuntime.awrap(this.modelManager.alternateUUIDForItem(u));e.next=29;break;case 27:e.next=34;break;case 29:if("sync_conflict"===l.tag)return e.next=32,regeneratorRuntime.awrap(this.modelManager.createDuplicateItemFromResponseItem(c));e.next=34;break;case 32:d=e.sent,c.deleted||u.isItemContentEqualWith(d)||this.modelManager.addDuplicatedItemAsConflict({duplicate:d,duplicateOf:u});case 34:n=!0,e.next=8;break;case 37:e.next=43;break;case 39:e.prev=39,e.t5=e.catch(6),r=!0,i=e.t5;case 43:e.prev=43,e.prev=44,n||null==a.return||a.return();case 46:if(e.prev=46,r)throw i;e.next=49;break;case 49:return e.finish(46);case 50:return e.finish(43);case 51:case"end":return e.stop()}},null,this,[[6,39,43,51],[44,,46,50]])}},{key:"stateless_downloadAllItems",value:function(e){var a=this,o=0"==t.operator?h="==t.operator?h<=p:"startsWith"==t.operator?p.startsWith(h):"in"==t.operator?-1!=h.indexOf(p):"includes"==t.operator?this.resolveIncludesPredicate(p,h):"matches"==t.operator&&new RegExp(h).test(p)}},{key:"resolveIncludesPredicate",value:function(e,t){if("string"==typeof t)return e.includes(t);var n;n=Array.isArray(t)?m.fromArray(t):t;var r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var c=o.value;if(this.ObjectSatisfiesPredicate(c,n))return!0}}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,t){return Array.isArray(t)&&(t=m.fromArray(t)),this.ObjectSatisfiesPredicate(e,t)}},{key:"ItemSatisfiesPredicates",value:function(e,t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(!this.ItemSatisfiesPredicate(e,s))return!1}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}return!0}},{key:"DateFromString",value:function(e){var t=e.split("."),n=t[1],r=new Date,i=parseInt(t[0]);return"days"==n?r.setDate(r.getDate()-i):"hours"==n&&r.setHours(r.getHours()-i),r}},{key:"IsRecursiveOperator",value:function(e){return["and","or"].includes(e)}}]),m}();Te.SFPredicate=le;var de=function(){function n(e){var t;return V(this,n),e.window=null,(t=N(this,L(n).call(this,e))).componentData||(t.componentData={}),t.disassociatedItemIds||(t.disassociatedItemIds=[]),t.associatedItemIds||(t.associatedItemIds=[]),t}return j(n,ce),q(n,[{key:"mapContentToLocalProperties",value:function(e){F(L(n.prototype),"mapContentToLocalProperties",this).call(this,e),e.hosted_url||(this.legacy_url=e.url),this.local_url=e.local_url,this.hosted_url=e.hosted_url||e.url,this.offlineOnly=e.offlineOnly,e.valid_until&&(this.valid_until=new Date(e.valid_until)),this.name=e.name,this.autoupdateDisabled=e.autoupdateDisabled,this.package_info=e.package_info,this.area=e.area,this.permissions=e.permissions,this.permissions||(this.permissions=[]),this.active=e.active,this.componentData=e.componentData||{},this.disassociatedItemIds=e.disassociatedItemIds||[],this.associatedItemIds=e.associatedItemIds||[]}},{key:"handleDeletedContent",value:function(){F(L(n.prototype),"handleDeletedContent",this).call(this),this.active=!1}},{key:"structureParams",value:function(){var e={legacy_url:this.legacy_url,hosted_url:this.hosted_url,local_url:this.local_url,valid_until:this.valid_until,offlineOnly:this.offlineOnly,name:this.name,area:this.area,package_info:this.package_info,permissions:this.permissions,active:this.active,autoupdateDisabled:this.autoupdateDisabled,componentData:this.componentData,disassociatedItemIds:this.disassociatedItemIds,associatedItemIds:this.associatedItemIds},t=F(L(n.prototype),"structureParams",this).call(this);return Object.assign(t,e),t}},{key:"isEditor",value:function(){return"editor-editor"==this.area}},{key:"isTheme",value:function(){return"SN|Theme"==this.content_type||"themes"==this.area}},{key:"isDefaultEditor",value:function(){return 1==this.getAppDataItem("defaultEditor")}},{key:"setLastSize",value:function(e){this.setAppDataItem("lastSize",e)}},{key:"getLastSize",value:function(){return this.getAppDataItem("lastSize")}},{key:"acceptsThemes",value:function(){return!(this.content.package_info&&"acceptsThemes"in this.content.package_info)||this.content.package_info.acceptsThemes}},{key:"getClientDataKey",value:function(){return this.legacy_url?this.legacy_url:this.uuid}},{key:"hasValidHostedUrl",value:function(){return this.hosted_url||this.legacy_url}},{key:"keysToIgnoreWhenCheckingContentEquality",value:function(){return["active","disassociatedItemIds","associatedItemIds"].concat(F(L(n.prototype),"keysToIgnoreWhenCheckingContentEquality",this).call(this))}},{key:"isAssociative",value:function(){return Component.associativeAreas().includes(this.area)}},{key:"associateWithItem",value:function(e){this.associatedItemIds.push(e.uuid)}},{key:"isExplicitlyEnabledForItem",value:function(e){return-1!==this.associatedItemIds.indexOf(e.uuid)}},{key:"isExplicitlyDisabledForItem",value:function(e){return-1!==this.disassociatedItemIds.indexOf(e.uuid)}},{key:"content_type",get:function(){return"SN|Component"}}],[{key:"associativeAreas",value:function(){return["editor-editor"]}}]),n}();Te.SNComponent=de;var fe=function(){function n(e){var t;return V(this,n),(t=N(this,L(n).call(this,e))).notes||(t.notes=[]),t.data||(t.data={}),t}return j(n,ce),q(n,[{key:"mapContentToLocalProperties",value:function(e){F(L(n.prototype),"mapContentToLocalProperties",this).call(this,e),this.url=e.url,this.name=e.name,this.data=e.data||{},this.default=e.default,this.systemEditor=e.systemEditor}},{key:"structureParams",value:function(){var e={url:this.url,name:this.name,data:this.data,default:this.default,systemEditor:this.systemEditor},t=F(L(n.prototype),"structureParams",this).call(this);return Object.assign(t,e),t}},{key:"referenceParams",value:function(){return _.map(this.notes,function(e){return{uuid:e.uuid,content_type:e.content_type}})}},{key:"addItemAsRelationship",value:function(e){"Note"==e.content_type&&(_.find(this.notes,e)||this.notes.push(e)),F(L(n.prototype),"addItemAsRelationship",this).call(this,e)}},{key:"removeItemAsRelationship",value:function(e){"Note"==e.content_type&&_.pull(this.notes,e),F(L(n.prototype),"removeItemAsRelationship",this).call(this,e)}},{key:"removeAndDirtyAllRelationships",value:function(){F(L(n.prototype),"removeAndDirtyAllRelationships",this).call(this),this.notes=[]}},{key:"removeReferencesNotPresentIn",value:function(e){F(L(n.prototype),"removeReferencesNotPresentIn",this).call(this,e);var t=e.map(function(e){return e.uuid});this.notes.forEach(function(e){t.includes(e.uuid)||_.remove(this.notes,{uuid:e.uuid})}.bind(this))}},{key:"potentialItemOfInterestHasChangedItsUUID",value:function(e,t){"Note"===e.content_type&&_.find(this.notes,{uuid:t})&&(_.remove(this.notes,{uuid:t}),this.notes.push(e))}},{key:"setData",value:function(e,t){return JSON.stringify(this.data[e])!==JSON.stringify(t)&&(this.data[e]=t,!0)}},{key:"dataForKey",value:function(e){return this.data[e]||{}}},{key:"content_type",get:function(){return"SN|Editor"}}]),n}();Te.SNEditor=fe;function he(e){V(this,he),_.merge(this,e),this.running=!1,this.error=!1,this.lastExecuted&&(this.lastExecuted=new Date(this.lastExecuted))}Te.Action=he;var pe=function(){function n(e){var t;return V(this,n),t=N(this,L(n).call(this,e)),e.actions&&(t.actions=e.actions.map(function(e){return new he(e)})),t.actions||(t.actions=[]),t}return j(n,ce),q(n,[{key:"actionsWithContextForItem",value:function(t){return this.actions.filter(function(e){return e.context==t.content_type||"Item"==e.context})}},{key:"mapContentToLocalProperties",value:function(e){F(L(n.prototype),"mapContentToLocalProperties",this).call(this,e),this.description=e.description,this.url=e.url,this.name=e.name,this.package_info=e.package_info,this.supported_types=e.supported_types,e.actions&&(this.actions=e.actions.map(function(e){return new he(e)}))}},{key:"structureParams",value:function(){var e={name:this.name,url:this.url,package_info:this.package_info,description:this.description,actions:this.actions.map(function(e){return _.omit(e,["subrows","subactions"])}),supported_types:this.supported_types},t=F(L(n.prototype),"structureParams",this).call(this);return Object.assign(t,e),t}},{key:"content_type",get:function(){return"Extension"}}]),n}();Te.SNExtension=pe;var ve=function(){function s(e){var t;return V(this,s),(t=N(this,L(s).call(this,e))).text||(t.text=""),t.tags||(t.tags=[]),t}return j(s,ce),q(s,[{key:"mapContentToLocalProperties",value:function(e){F(L(s.prototype),"mapContentToLocalProperties",this).call(this,e),this.title=e.title,this.text=e.text}},{key:"structureParams",value:function(){var e={title:this.title,text:this.text},t=F(L(s.prototype),"structureParams",this).call(this);return Object.assign(t,e),t}},{key:"addItemAsRelationship",value:function(e){"Tag"==e.content_type&&e.addItemAsRelationship(this),F(L(s.prototype),"addItemAsRelationship",this).call(this,e)}},{key:"setIsBeingReferencedBy",value:function(e){F(L(s.prototype),"setIsBeingReferencedBy",this).call(this,e),this.clearSavedTagsString()}},{key:"setIsNoLongerBeingReferencedBy",value:function(e){F(L(s.prototype),"setIsNoLongerBeingReferencedBy",this).call(this,e),this.clearSavedTagsString()}},{key:"isBeingRemovedLocally",value:function(){this.tags.forEach(function(e){_.remove(e.notes,{uuid:this.uuid})}.bind(this)),F(L(s.prototype),"isBeingRemovedLocally",this).call(this)}},{key:"informReferencesOfUUIDChange",value:function(e){F(L(s.prototype),"informReferencesOfUUIDChange",this).call(this);var t=!0,n=!1,r=void 0;try{for(var i,a=this.tags[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;_.remove(o.notes,{uuid:e}),o.notes.push(this)}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}}},{key:"tagDidFinishSyncing",value:function(){this.clearSavedTagsString()}},{key:"safeText",value:function(){return this.text||""}},{key:"safeTitle",value:function(){return this.title||""}},{key:"clearSavedTagsString",value:function(){this.savedTagsString=null}},{key:"tagsString",value:function(){return this.savedTagsString=me.arrayToDisplayString(this.tags),this.savedTagsString}},{key:"content_type",get:function(){return"Note"}},{key:"displayName",get:function(){return"Note"}}],[{key:"filterDummyNotes",value:function(e){return e.filter(function(e){return 0==e.dummy||null==e.dummy})}}]),s}();Te.SNNote=ve;var me=function(){function n(e){var t;return V(this,n),(t=N(this,L(n).call(this,e))).content_type||(t.content_type="Tag"),t.notes||(t.notes=[]),t}return j(n,ce),q(n,[{key:"mapContentToLocalProperties",value:function(e){F(L(n.prototype),"mapContentToLocalProperties",this).call(this,e),this.title=e.title}},{key:"structureParams",value:function(){var e={title:this.title},t=F(L(n.prototype),"structureParams",this).call(this);return Object.assign(t,e),t}},{key:"addItemAsRelationship",value:function(e){"Note"==e.content_type&&(_.find(this.notes,{uuid:e.uuid})||(this.notes.push(e),e.tags.push(this))),F(L(n.prototype),"addItemAsRelationship",this).call(this,e)}},{key:"removeItemAsRelationship",value:function(e){"Note"==e.content_type&&(_.remove(this.notes,{uuid:e.uuid}),_.remove(e.tags,{uuid:this.uuid})),F(L(n.prototype),"removeItemAsRelationship",this).call(this,e)}},{key:"updateLocalRelationships",value:function(){var t=this.content.references.map(function(e){return e.uuid});this.notes.slice().forEach(function(e){t.includes(e.uuid)||(_.remove(e.tags,{uuid:this.uuid}),_.remove(this.notes,{uuid:e.uuid}),e.setIsNoLongerBeingReferencedBy(this))}.bind(this))}},{key:"isBeingRemovedLocally",value:function(){var t=this;this.notes.forEach(function(e){_.remove(e.tags,{uuid:t.uuid}),e.setIsNoLongerBeingReferencedBy(t)}),this.notes.length=0,F(L(n.prototype),"isBeingRemovedLocally",this).call(this)}},{key:"informReferencesOfUUIDChange",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=this.notes[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;_.remove(o.tags,{uuid:e}),o.tags.push(this)}}catch(e){n=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw r}}}},{key:"didFinishSyncing",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,i=this.notes[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){r.value.tagDidFinishSyncing(this)}}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}}},{key:"isSmartTag",value:function(){return"SN|SmartTag"==this.content_type}},{key:"displayName",get:function(){return"Tag"}}],[{key:"arrayToDisplayString",value:function(e){return e.sort(function(e,t){return e.title>t.title}).map(function(e,t){return"#"+e.title}).join(" ")}}]),n}();Te.SNTag=me;var ge=function(){function t(){return V(this,t),N(this,L(t).apply(this,arguments))}return j(t,ce),q(t,[{key:"mapContentToLocalProperties",value:function(e){F(L(t.prototype),"mapContentToLocalProperties",this).call(this,e),this.storage=e.storage}},{key:"content_type",get:function(){return"SN|EncryptedStorage"}}]),t}();Te.SNEncryptedStorage=ge;var ye=function(){function n(e){var t;return V(this,n),(t=N(this,L(n).call(this,e))).content.desktopPrivileges||(t.content.desktopPrivileges={}),t}return j(n,ce),q(n,null,[{key:"contentType",value:function(){return"SN|Privileges"}}]),q(n,[{key:"setCredentialsForAction",value:function(e,t){this.content.desktopPrivileges[e]=t}},{key:"getCredentialsForAction",value:function(e){return this.content.desktopPrivileges[e]||[]}},{key:"toggleCredentialForAction",value:function(e,t){this.isCredentialRequiredForAction(e,t)?this.removeCredentialForAction(e,t):this.addCredentialForAction(e,t)}},{key:"removeCredentialForAction",value:function(e,t){_.pull(this.content.desktopPrivileges[e],t)}},{key:"addCredentialForAction",value:function(e,t){var n=this.getCredentialsForAction(e);n.push(t),this.setCredentialsForAction(e,n)}},{key:"isCredentialRequiredForAction",value:function(e,t){return this.getCredentialsForAction(e).includes(t)}}]),n}();Te.SFPrivileges=ye;var be=function(){function t(e){return V(this,t),N(this,L(t).call(this,e))}return j(t,ce),q(t,[{key:"doNotEncrypt",value:function(){return!0}},{key:"content_type",get:function(){return"SF|MFA"}}]),t}();Te.SNMfa=be;var ke=function(){function t(){return V(this,t),N(this,L(t).apply(this,arguments))}return j(t,ce),q(t,[{key:"mapContentToLocalProperties",value:function(e){F(L(t.prototype),"mapContentToLocalProperties",this).call(this,e),this.url=e.url}},{key:"doNotEncrypt",value:function(){return!0}},{key:"content_type",get:function(){return"SF|Extension"}}]),t}();Te.SNServerExtension=ke;var we=function(){function r(e){var n;return V(this,r),(n=N(this,L(r).call(this,e))).content.itemUUIDToItemHistoryMapping||(n.content.itemUUIDToItemHistoryMapping={}),Object.keys(n.content.itemUUIDToItemHistoryMapping).forEach(function(e){var t=n.content.itemUUIDToItemHistoryMapping[e];n.content.itemUUIDToItemHistoryMapping[e]=new $e(t)}),n}return j(r,ce),q(r,[{key:"addEntryForItem",value:function(e){return this.historyForItem(e).addHistoryEntryForItem(e)}},{key:"historyForItem",value:function(e){var t=this.content.itemUUIDToItemHistoryMapping[e.uuid];return t=t||(this.content.itemUUIDToItemHistoryMapping[e.uuid]=new $e)}},{key:"clearItemHistory",value:function(e){this.historyForItem(e).clear()}},{key:"clearAllHistory",value:function(){this.content.itemUUIDToItemHistoryMapping={}}},{key:"optimizeHistoryForItem",value:function(e){var t=this.historyForItem(e);t.entries.length>r.LargeItemEntryAmountThreshold&&t.optimize()}}]),r}();(Te.SFHistorySession=we).LargeItemEntryAmountThreshold=60;var $e=function(){function c(){var e=0c.LargeEntryDeltaThreshold}function r(e,t,n){if(n?o.push(e):-1!==(t=o.indexOf(e))&&o.splice(t,1),n&&i(e)&&-1==e.operationVector()){var r=a.entries[t-1];r&&o.push(r)}}var a=this,o=[];this.entries.forEach(function(e,t){if(0==t||t==a.entries.length-1)r(e,t,!0);else{var n=i(e);r(e,t,n)}}),this.entries=this.entries.filter(function(e,t){return-1!==o.indexOf(e)})}}]),c}();(Te.SFItemHistory=$e).LargeEntryDeltaThreshold=15;var xe=function(){function t(e){V(this,t),this.item=ce.deepMerge({},e),this.defaultContentKeyToDiffOn="text",this.textCharDiffLength=0,"string"==typeof this.item.updated_at&&(this.item.updated_at=new Date(this.item.updated_at))}return q(t,[{key:"setPreviousEntry",value:function(e){this.hasPreviousEntry=null!=e,this.item.content[this.defaultContentKeyToDiffOn]&&(this.textCharDiffLength=e?this.item.content[this.defaultContentKeyToDiffOn].length-e.item.content[this.defaultContentKeyToDiffOn].length:this.item.content[this.defaultContentKeyToDiffOn].length)}},{key:"operationVector",value:function(){return null!=this.textCharDiffLength?this.hasPreviousEntry&&0!=this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return null!=this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=new ce(this.item),n=new ce(e.item);return t.isItemContentEqualWith(n)}}]),t}();Te.SFItemHistoryEntry=xe;var Se=function(){function n(e){var t;return V(this,n),(t=N(this,L(n).call(this,e))).content_type="SN|SmartTag",t}return j(n,me),q(n,null,[{key:"systemSmartTags",value:function(){return[new n({uuid:n.SystemSmartTagIdAllNotes,dummy:!0,content:{title:"All notes",isSystemTag:!0,isAllTag:!0,predicate:new le.fromArray(["content_type","=","Note"])}}),new n({uuid:n.SystemSmartTagIdArchivedNotes,dummy:!0,content:{title:"Archived",isSystemTag:!0,isArchiveTag:!0,predicate:new le.fromArray(["archived","=",!0])}}),new n({uuid:n.SystemSmartTagIdTrashedNotes,dummy:!0,content:{title:"Trash",isSystemTag:!0,isTrashTag:!0,predicate:new le.fromArray(["content.trashed","=",!0])}})]}}]),n}();(Te.SNSmartTag=Se).SystemSmartTagIdAllNotes="all-notes",Se.SystemSmartTagIdArchivedNotes="archived-notes",Se.SystemSmartTagIdTrashedNotes="trashed-notes";var Me=function(){function n(e){var t;return V(this,n),(t=N(this,L(n).call(this,e))).area="themes",t}return j(n,de),q(n,[{key:"isLayerable",value:function(){return this.package_info&&this.package_info.layerable}},{key:"setMobileRules",value:function(e){this.setAppDataItem("mobileRules",e)}},{key:"getMobileRules",value:function(){return this.getAppDataItem("mobileRules")||{constants:{},rules:{}}}},{key:"hasMobileRules",value:function(){return this.getAppDataItem("mobileRules")}},{key:"setNotAvailOnMobile",value:function(e){this.setAppDataItem("notAvailableOnMobile",e)}},{key:"getNotAvailOnMobile",value:function(){return this.getAppDataItem("notAvailableOnMobile")}},{key:"setMobileActive",value:function(e){this.setAppDataItem("mobileActive",e)}},{key:"isMobileActive",value:function(){return this.getAppDataItem("mobileActive")}},{key:"content_type",get:function(){return"SN|Theme"}},{key:"displayName",get:function(){return"Theme"}}]),n}();Te.SNTheme=Me;G="undefined"!=typeof window?window:void 0!==e?e:null;var Ce=function(){function e(){V(this,e),this.DefaultPBKDF2Length=768}return q(e,[{key:"generateUUIDSync",value:function(){var e=G.crypto||G.msCrypto;if(e){var n=new Uint32Array(4);e.getRandomValues(n);var r=-1;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=n[++r>>3]>>r%8*4&15;return("x"==e?t:3&t|8).toString(16)})}var i=(new Date).getTime();return G.performance&&"function"==typeof G.performance.now&&(i+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(i+16*Math.random())%16|0;return i=Math.floor(i/16),("x"==e?t:3&t|8).toString(16)})}},{key:"generateUUID",value:function(){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.generateUUIDSync());case 1:case"end":return e.stop()}},null,this)}},{key:"timingSafeEqual",value:function(e,t){var n=String(e),r=String(t),i=n.length,a=0;i!==r.length&&(r=n,a=1);for(var o=0;oparseInt(t)}},{key:"isProtocolVersionOutdated",value:function(e){var t={"001":Date.parse("2018-01-01"),"002":Date.parse("2020-01-01")}[e];return!!t&&new Date>t}},{key:"costMinimumForVersion",value:function(e){return{"001":3e3,"002":3e3,"003":11e4}[e]}},{key:"defaultPasswordGenerationCost",value:function(){return this.costMinimumForVersion(this.version())}}]),t}();if(Te.StandardNotes=Ee,G)try{G.StandardNotes=Ee,G.SNJS=new Ee,G.SFCryptoWeb=Ie,G.SFCryptoJS=Ae,G.SFItemTransformer=De,G.SFModelManager=X,G.SFItem=ce,G.SFItemParams=ue,G.SFHttpManager=Y,G.SFStorageManager=ae,G.SFSyncManager=se,G.SFAuthManager=W,G.SFMigrationManager=Z,G.SFAlertManager=K,G.SFPredicate=le,G.SFHistorySession=we,G.SFSessionHistoryManager=re,G.SFItemHistory=$e,G.SFItemHistoryEntry=xe,G.SFPrivilegesManager=Q,G.SFPrivileges=ye,G.SFSingletonManager=ie,G.SNNote=ve,G.SNTag=me,G.SNSmartTag=Se,G.SNMfa=be,G.SNServerExtension=ke,G.SNComponent=de,G.SNEditor=fe,G.SNExtension=pe,G.SNTheme=Me,G.SNEncryptedStorage=ge,G.SNComponentManager=J}catch(e){console.log("Exception while exporting window variables",e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)});var Stylekit=function(n){var r={};function i(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}return i.m=n,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,n){"use strict";function r(e,t){for(var n=0;n\n
").concat(e.text,"
\n \n ")}(e,t)}).join("");return"\n
\n ".concat(e,"\n
\n ")}},{key:"templateString",value:function(){var e=this.buttonsString(),t=this.title?"
".concat(this.title,"
"):"",n=this.text?"

".concat(this.text,"

"):"";return'\n
\n
\n
\n
\n
\n
\n
\n '.concat(t,'\n\n
\n ').concat(n,"\n
\n\n
\n ").concat(e,"\n
\n
\n
\n
\n
\n
\n
\n ")}},{key:"dismiss",value:function(){this.onElement.removeChild(this.element),document.removeEventListener("keyup",this.keyupListener)}},{key:"primaryButton",value:function(){var e=this.buttons.find(function(e){return!0===e.primary});return e=e||this.buttons[this.buttons.length-1]}},{key:"present",value:function(e){var n=this,t=(0").append(e).html();try{return e[0].nodeType===He?pe(t):t.match(/^(<[^>]+>)/)[1].replace(/^<([\w-]+)/,function(e,t){return"<"+pe(t)})}catch(e){return pe(t)}}function G(e){try{return decodeURIComponent(e)}catch(e){}}function Y(e){var i={};return me((e||"").split("&"),function(e){var t,n,r;e&&(n=e=e.replace(/\+/g,"%20"),-1!==(t=e.indexOf("="))&&(n=e.substring(0,t),r=e.substring(t+1)),T(n=G(n))&&(r=!T(r)||G(r),he.call(i,n)?Se(i[n])?i[n].push(r):i[n]=[i[n],r]:i[n]=r))}),i}function Z(e){return X(e,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function X(e,t){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%20/g,t?"%20":"+")}var Q=["ng-","data-ng-","ng:","x-ng-"];var ee=function(n){var e=n.currentScript;if(!e)return!0;if(!(e instanceof le.HTMLScriptElement||e instanceof le.SVGScriptElement))return!1;var t=e.attributes;return[t.getNamedItem("src"),t.getNamedItem("href"),t.getNamedItem("xlink:href")].every(function(e){if(!e)return!0;if(!e.value)return!1;var t=n.createElement("a");if(t.href=e.value,n.location.origin===t.origin)return!0;switch(t.protocol){case"http:":case"https:":case"ftp:":case"blob:":case"file:":case"data:":return!0;default:return!1}})}(le.document);function te(r,e){var i,a,t={};if(me(Q,function(e){var t=e+"app";!i&&r.hasAttribute&&r.hasAttribute(t)&&(a=(i=r).getAttribute(t))}),me(Q,function(e){var t,n=e+"app";!i&&(t=r.querySelector("["+n.replace(":","\\:")+"]"))&&(a=(i=t).getAttribute(n))}),i){if(!ee)return void le.console.error("AngularJS: disabling automatic bootstrap.