(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-vendors~253ae210"],{"1ed7":function(e,t,s){"use strict";s("94bf")},"239f":function(e,t,s){var i=s("51f3");function n(e,t){var s=new i(e,t);return function(e){return s.convert(e)}}n.BIN="01",n.OCT="01234567",n.DEC="0123456789",n.HEX="0123456789abcdef",e.exports=n},3014:function(e,t,s){"use strict";s("8788")},"378c":function(e,t,s){"use strict";s("945c")},"4c44":function(e,t,s){"use strict";s.d(t,"a",(function(){return i})),s.d(t,"b",(function(){return we})),s.d(t,"c",(function(){return Ae})),s.d(t,"d",(function(){return De})),s.d(t,"e",(function(){return Oe})),s.d(t,"f",(function(){return Pe})),s.d(t,"g",(function(){return Ge})),s.d(t,"h",(function(){return Te})),s.d(t,"i",(function(){return Qe}));
/*!
 * Copyright 2016 Amazon.com,
 * Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Amazon Software License (the "License").
 * You may not use this file except in compliance with the
 * License. A copy of the License is located at
 *
 *     http://aws.amazon.com/asl/
 *
 * or in the "license" file accompanying this file. This file is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, express or implied. See the License
 * for the specific language governing permissions and
 * limitations under the License.
 */
var i=function(){function e(e){var t=e||{},s=t.ValidationData,i=t.Username,n=t.Password,r=t.AuthParameters,o=t.ClientMetadata;this.validationData=s||{},this.authParameters=r||{},this.clientMetadata=o||{},this.username=i,this.password=n}var t=e.prototype;return t.getUsername=function(){return this.username},t.getPassword=function(){return this.password},t.getValidationData=function(){return this.validationData},t.getAuthParameters=function(){return this.authParameters},t.getClientMetadata=function(){return this.clientMetadata},e}(),n=s("b639"),r=s("21bf"),o=s.n(r),a=(s("17e1"),s("94f8")),l=s.n(a),c=s("ed53"),u=s.n(c),h=s("e706");function d(e){for(var t=e.words,s=e.sigBytes,i=[],n=0;n<s;n++){var r=t[n>>>2]>>>24-n%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")}var f,p=function(){function e(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length}var t=e.prototype;return t.random=function(t){for(var s=[],i=0;i<t;i+=4)s.push(Object(h["a"])());return new e(s,t)},t.toString=function(){return d(this)},e}(),g=m;function m(e,t){null!=e&&this.fromString(e,t)}function v(){return new m(null)}var C=0xdeadbeefcafe,w=15715070==(16777215&C);function S(e,t,s,i,n,r){while(--r>=0){var o=t*this[e++]+s[i]+n;n=Math.floor(o/67108864),s[i++]=67108863&o}return n}function y(e,t,s,i,n,r){var o=32767&t,a=t>>15;while(--r>=0){var l=32767&this[e],c=this[e++]>>15,u=a*l+c*o;l=o*l+((32767&u)<<15)+s[i]+(1073741823&n),n=(l>>>30)+(u>>>15)+a*c+(n>>>30),s[i++]=1073741823&l}return n}function A(e,t,s,i,n,r){var o=16383&t,a=t>>14;while(--r>=0){var l=16383&this[e],c=this[e++]>>14,u=a*l+c*o;l=o*l+((16383&u)<<14)+s[i]+n,n=(l>>28)+(u>>14)+a*c,s[i++]=268435455&l}return n}var D="undefined"!==typeof navigator;D&&w&&"Microsoft Internet Explorer"==navigator.appName?(m.prototype.am=y,f=30):D&&w&&"Netscape"!=navigator.appName?(m.prototype.am=S,f=26):(m.prototype.am=A,f=28),m.prototype.DB=f,m.prototype.DM=(1<<f)-1,m.prototype.DV=1<<f;var U=52;m.prototype.FV=Math.pow(2,U),m.prototype.F1=U-f,m.prototype.F2=2*f-U;var b,T,I="0123456789abcdefghijklmnopqrstuvwxyz",E=new Array;for(b="0".charCodeAt(0),T=0;T<=9;++T)E[b++]=T;for(b="a".charCodeAt(0),T=10;T<36;++T)E[b++]=T;for(b="A".charCodeAt(0),T=10;T<36;++T)E[b++]=T;function k(e){return I.charAt(e)}function P(e,t){var s=E[e.charCodeAt(t)];return null==s?-1:s}function F(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function R(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}function x(e){var t=v();return t.fromInt(e),t}function _(e,t){var s;if(16==t)s=4;else if(8==t)s=3;else if(2==t)s=1;else if(32==t)s=5;else{if(4!=t)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");s=2}this.t=0,this.s=0;var i=e.length,n=!1,r=0;while(--i>=0){var o=P(e,i);o<0?"-"==e.charAt(i)&&(n=!0):(n=!1,0==r?this[this.t++]=o:r+s>this.DB?(this[this.t-1]|=(o&(1<<this.DB-r)-1)<<r,this[this.t++]=o>>this.DB-r):this[this.t-1]|=o<<r,r+=s,r>=this.DB&&(r-=this.DB))}this.clamp(),n&&m.ZERO.subTo(this,this)}function M(){var e=this.s&this.DM;while(this.t>0&&this[this.t-1]==e)--this.t}function O(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");t=2}var s,i=(1<<t)-1,n=!1,r="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0){a<this.DB&&(s=this[o]>>a)>0&&(n=!0,r=k(s));while(o>=0)a<t?(s=(this[o]&(1<<a)-1)<<t-a,s|=this[--o]>>(a+=this.DB-t)):(s=this[o]>>(a-=t)&i,a<=0&&(a+=this.DB,--o)),s>0&&(n=!0),n&&(r+=k(s))}return n?r:"0"}function N(){var e=v();return m.ZERO.subTo(this,e),e}function B(){return this.s<0?this.negate():this}function V(e){var t=this.s-e.s;if(0!=t)return t;var s=this.t;if(t=s-e.t,0!=t)return this.s<0?-t:t;while(--s>=0)if(0!=(t=this[s]-e[s]))return t;return 0}function K(e){var t,s=1;return 0!=(t=e>>>16)&&(e=t,s+=16),0!=(t=e>>8)&&(e=t,s+=8),0!=(t=e>>4)&&(e=t,s+=4),0!=(t=e>>2)&&(e=t,s+=2),0!=(t=e>>1)&&(e=t,s+=1),s}function L(){return this.t<=0?0:this.DB*(this.t-1)+K(this[this.t-1]^this.s&this.DM)}function q(e,t){var s;for(s=this.t-1;s>=0;--s)t[s+e]=this[s];for(s=e-1;s>=0;--s)t[s]=0;t.t=this.t+e,t.s=this.s}function $(e,t){for(var s=e;s<this.t;++s)t[s-e]=this[s];t.t=Math.max(this.t-e,0),t.s=this.s}function W(e,t){var s,i=e%this.DB,n=this.DB-i,r=(1<<n)-1,o=Math.floor(e/this.DB),a=this.s<<i&this.DM;for(s=this.t-1;s>=0;--s)t[s+o+1]=this[s]>>n|a,a=(this[s]&r)<<i;for(s=o-1;s>=0;--s)t[s]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()}function H(e,t){t.s=this.s;var s=Math.floor(e/this.DB);if(s>=this.t)t.t=0;else{var i=e%this.DB,n=this.DB-i,r=(1<<i)-1;t[0]=this[s]>>i;for(var o=s+1;o<this.t;++o)t[o-s-1]|=(this[o]&r)<<n,t[o-s]=this[o]>>i;i>0&&(t[this.t-s-1]|=(this.s&r)<<n),t.t=this.t-s,t.clamp()}}function j(e,t){var s=0,i=0,n=Math.min(e.t,this.t);while(s<n)i+=this[s]-e[s],t[s++]=i&this.DM,i>>=this.DB;if(e.t<this.t){i-=e.s;while(s<this.t)i+=this[s],t[s++]=i&this.DM,i>>=this.DB;i+=this.s}else{i+=this.s;while(s<e.t)i-=e[s],t[s++]=i&this.DM,i>>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t[s++]=this.DV+i:i>0&&(t[s++]=i),t.t=s,t.clamp()}function z(e,t){var s=this.abs(),i=e.abs(),n=s.t;t.t=n+i.t;while(--n>=0)t[n]=0;for(n=0;n<i.t;++n)t[n+s.t]=s.am(0,i[n],t,n,0,s.t);t.s=0,t.clamp(),this.s!=e.s&&m.ZERO.subTo(t,t)}function G(e){var t=this.abs(),s=e.t=2*t.t;while(--s>=0)e[s]=0;for(s=0;s<t.t-1;++s){var i=t.am(s,t[s],e,2*s,0,1);(e[s+t.t]+=t.am(s+1,2*t[s],e,2*s+1,i,t.t-s-1))>=t.DV&&(e[s+t.t]-=t.DV,e[s+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(s,t[s],e,2*s,0,1)),e.s=0,e.clamp()}function J(e,t,s){var i=e.abs();if(!(i.t<=0)){var n=this.abs();if(n.t<i.t)return null!=t&&t.fromInt(0),void(null!=s&&this.copyTo(s));null==s&&(s=v());var r=v(),o=this.s,a=e.s,l=this.DB-K(i[i.t-1]);l>0?(i.lShiftTo(l,r),n.lShiftTo(l,s)):(i.copyTo(r),n.copyTo(s));var c=r.t,u=r[c-1];if(0!=u){var h=u*(1<<this.F1)+(c>1?r[c-2]>>this.F2:0),d=this.FV/h,f=(1<<this.F1)/h,p=1<<this.F2,g=s.t,C=g-c,w=null==t?v():t;r.dlShiftTo(C,w),s.compareTo(w)>=0&&(s[s.t++]=1,s.subTo(w,s)),m.ONE.dlShiftTo(c,w),w.subTo(r,r);while(r.t<c)r[r.t++]=0;while(--C>=0){var S=s[--g]==u?this.DM:Math.floor(s[g]*d+(s[g-1]+p)*f);if((s[g]+=r.am(0,S,s,C,0,c))<S){r.dlShiftTo(C,w),s.subTo(w,s);while(s[g]<--S)s.subTo(w,s)}}null!=t&&(s.drShiftTo(c,t),o!=a&&m.ZERO.subTo(t,t)),s.t=c,s.clamp(),l>0&&s.rShiftTo(l,s),o<0&&m.ZERO.subTo(s,s)}}}function Q(e){var t=v();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(m.ZERO)>0&&e.subTo(t,t),t}function Y(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return t=t*(2-(15&e)*t)&15,t=t*(2-(255&e)*t)&255,t=t*(2-((65535&e)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Z(e){return 0==this.compareTo(e)}function X(e,t){var s=0,i=0,n=Math.min(e.t,this.t);while(s<n)i+=this[s]+e[s],t[s++]=i&this.DM,i>>=this.DB;if(e.t<this.t){i+=e.s;while(s<this.t)i+=this[s],t[s++]=i&this.DM,i>>=this.DB;i+=this.s}else{i+=this.s;while(s<e.t)i+=e[s],t[s++]=i&this.DM,i>>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t[s++]=i:i<-1&&(t[s++]=this.DV+i),t.t=s,t.clamp()}function ee(e){var t=v();return this.addTo(e,t),t}function te(e){var t=v();return this.subTo(e,t),t}function se(e){var t=v();return this.multiplyTo(e,t),t}function ie(e){var t=v();return this.divRemTo(e,t,null),t}function ne(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function re(e){var t=v();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(m.ZERO)>0&&this.m.subTo(t,t),t}function oe(e){var t=v();return e.copyTo(t),this.reduce(t),t}function ae(e){while(e.t<=this.mt2)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var s=32767&e[t],i=s*this.mpl+((s*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;s=t+this.m.t,e[s]+=this.m.am(0,i,e,t,0,this.m.t);while(e[s]>=e.DV)e[s]-=e.DV,e[++s]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function le(e,t){e.squareTo(t),this.reduce(t)}function ce(e,t,s){e.multiplyTo(t,s),this.reduce(s)}function ue(e,t,s){var i,n=e.bitLength(),r=x(1),o=new ne(t);if(n<=0)return r;i=n<18?1:n<48?3:n<144?4:n<768?5:6;var a=new Array,l=3,c=i-1,u=(1<<i)-1;if(a[1]=o.convert(this),i>1){var h=v();o.sqrTo(a[1],h);while(l<=u)a[l]=v(),o.mulTo(h,a[l-2],a[l]),l+=2}var d,f,p=e.t-1,g=!0,m=v();n=K(e[p])-1;while(p>=0){n>=c?d=e[p]>>n-c&u:(d=(e[p]&(1<<n+1)-1)<<c-n,p>0&&(d|=e[p-1]>>this.DB+n-c)),l=i;while(0==(1&d))d>>=1,--l;if((n-=l)<0&&(n+=this.DB,--p),g)a[d].copyTo(r),g=!1;else{while(l>1)o.sqrTo(r,m),o.sqrTo(m,r),l-=2;l>0?o.sqrTo(r,m):(f=r,r=m,m=f),o.mulTo(m,a[d],r)}while(p>=0&&0==(e[p]&1<<n))o.sqrTo(r,m),f=r,r=m,m=f,--n<0&&(n=this.DB-1,--p)}var C=o.revert(r);return s(null,C),C}
/*!
 * Copyright 2016 Amazon.com,
 * Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Amazon Software License (the "License").
 * You may not use this file except in compliance with the
 * License. A copy of the License is located at
 *
 *     http://aws.amazon.com/asl/
 *
 * or in the "license" file accompanying this file. This file is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, express or implied. See the License
 * for the specific language governing permissions and
 * limitations under the License.
 */
function he(e){return n["Buffer"].from((new p).random(e).toString(),"hex")}ne.prototype.convert=re,ne.prototype.revert=oe,ne.prototype.reduce=ae,ne.prototype.mulTo=ce,ne.prototype.sqrTo=le,m.prototype.copyTo=F,m.prototype.fromInt=R,m.prototype.fromString=_,m.prototype.clamp=M,m.prototype.dlShiftTo=q,m.prototype.drShiftTo=$,m.prototype.lShiftTo=W,m.prototype.rShiftTo=H,m.prototype.subTo=j,m.prototype.multiplyTo=z,m.prototype.squareTo=G,m.prototype.divRemTo=J,m.prototype.invDigit=Y,m.prototype.addTo=X,m.prototype.toString=O,m.prototype.negate=N,m.prototype.abs=B,m.prototype.compareTo=V,m.prototype.bitLength=L,m.prototype.mod=Q,m.prototype.equals=Z,m.prototype.add=ee,m.prototype.subtract=te,m.prototype.multiply=se,m.prototype.divide=ie,m.prototype.modPow=ue,m.ZERO=x(0),m.ONE=x(1);var de=/^[89a-f]/i,fe="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",pe="userAttributes.",ge=function(){function e(e){this.N=new g(fe,16),this.g=new g("2",16),this.k=new g(this.hexHash(""+this.padHex(this.N)+this.padHex(this.g)),16),this.smallAValue=this.generateRandomSmallA(),this.getLargeAValue((function(){})),this.infoBits=n["Buffer"].from("Caldera Derived Key","utf8"),this.poolName=e}var t=e.prototype;return t.getSmallAValue=function(){return this.smallAValue},t.getLargeAValue=function(e){var t=this;this.largeAValue?e(null,this.largeAValue):this.calculateA(this.smallAValue,(function(s,i){s&&e(s,null),t.largeAValue=i,e(null,t.largeAValue)}))},t.generateRandomSmallA=function(){var e=he(128).toString("hex"),t=new g(e,16);return t},t.generateRandomString=function(){return he(40).toString("base64")},t.getRandomPassword=function(){return this.randomPassword},t.getSaltDevices=function(){return this.SaltToHashDevices},t.getVerifierDevices=function(){return this.verifierDevices},t.generateHashDevice=function(e,t,s){var i=this;this.randomPassword=this.generateRandomString();var n=""+e+t+":"+this.randomPassword,r=this.hash(n),o=he(16).toString("hex");this.SaltToHashDevices=this.padHex(new g(o,16)),this.g.modPow(new g(this.hexHash(this.SaltToHashDevices+r),16),this.N,(function(e,t){e&&s(e,null),i.verifierDevices=i.padHex(t),s(null,null)}))},t.calculateA=function(e,t){var s=this;this.g.modPow(e,this.N,(function(e,i){e&&t(e,null),i.mod(s.N).equals(g.ZERO)&&t(new Error("Illegal paramater. A mod N cannot be 0."),null),t(null,i)}))},t.calculateU=function(e,t){this.UHexHash=this.hexHash(this.padHex(e)+this.padHex(t));var s=new g(this.UHexHash,16);return s},t.hash=function(e){var t=e instanceof n["Buffer"]?o.a.lib.WordArray.create(e):e,s=l()(t).toString();return new Array(64-s.length).join("0")+s},t.hexHash=function(e){return this.hash(n["Buffer"].from(e,"hex"))},t.computehkdf=function(e,t){var s=o.a.lib.WordArray.create(n["Buffer"].concat([this.infoBits,n["Buffer"].from(String.fromCharCode(1),"utf8")])),i=e instanceof n["Buffer"]?o.a.lib.WordArray.create(e):e,r=t instanceof n["Buffer"]?o.a.lib.WordArray.create(t):t,a=u()(i,r),l=u()(s,a);return n["Buffer"].from(l.toString(),"hex").slice(0,16)},t.getPasswordAuthenticationKey=function(e,t,s,i,r){var o=this;if(s.mod(this.N).equals(g.ZERO))throw new Error("B cannot be zero.");if(this.UValue=this.calculateU(this.largeAValue,s),this.UValue.equals(g.ZERO))throw new Error("U cannot be zero.");var a=""+this.poolName+e+":"+t,l=this.hash(a),c=new g(this.hexHash(this.padHex(i)+l),16);this.calculateS(c,s,(function(e,t){e&&r(e,null);var s=o.computehkdf(n["Buffer"].from(o.padHex(t),"hex"),n["Buffer"].from(o.padHex(o.UValue),"hex"));r(null,s)}))},t.calculateS=function(e,t,s){var i=this;this.g.modPow(e,this.N,(function(n,r){n&&s(n,null);var o=t.subtract(i.k.multiply(r));o.modPow(i.smallAValue.add(i.UValue.multiply(e)),i.N,(function(e,t){e&&s(e,null),s(null,t.mod(i.N))}))}))},t.getNewPasswordRequiredChallengeUserAttributePrefix=function(){return pe},t.padHex=function(e){if(!(e instanceof g))throw new Error("Not a BigInteger");var t=e.compareTo(g.ZERO)<0,s=e.abs().toString(16);if(s=s.length%2!==0?"0"+s:s,s=de.test(s)?"00"+s:s,t){var i=s.split("").map((function(e){var t=15&~parseInt(e,16);return"0123456789ABCDEF".charAt(t)})).join(""),n=new g(i,16).add(g.ONE);s=n.toString(16),s.toUpperCase().startsWith("FF8")&&(s=s.substring(2))}return s},e}(),me=function(){function e(e){this.jwtToken=e||"",this.payload=this.decodePayload()}var t=e.prototype;return t.getJwtToken=function(){return this.jwtToken},t.getExpiration=function(){return this.payload.exp},t.getIssuedAt=function(){return this.payload.iat},t.decodePayload=function(){var e=this.jwtToken.split(".")[1];try{return JSON.parse(n["Buffer"].from(e,"base64").toString("utf8"))}catch(t){return{}}},e}();function ve(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Ce(e,t)}function Ce(e,t){return Ce=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ce(e,t)}var we=function(e){function t(t){var s=void 0===t?{}:t,i=s.AccessToken;return e.call(this,i||"")||this}return ve(t,e),t}(me);function Se(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ye(e,t)}function ye(e,t){return ye=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ye(e,t)}
/*!
 * Copyright 2016 Amazon.com,
 * Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Amazon Software License (the "License").
 * You may not use this file except in compliance with the
 * License. A copy of the License is located at
 *
 *     http://aws.amazon.com/asl/
 *
 * or in the "license" file accompanying this file. This file is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, express or implied. See the License
 * for the specific language governing permissions and
 * limitations under the License.
 */var Ae=function(e){function t(t){var s=void 0===t?{}:t,i=s.IdToken;return e.call(this,i||"")||this}return Se(t,e),t}(me),De=function(){function e(e){var t=void 0===e?{}:e,s=t.RefreshToken;this.token=s||""}var t=e.prototype;return t.getToken=function(){return this.token},e}(),Ue=s("1132"),be=s.n(Ue),Te=function(){function e(e){var t=void 0===e?{}:e,s=t.IdToken,i=t.RefreshToken,n=t.AccessToken,r=t.ClockDrift;if(null==n||null==s)throw new Error("Id token and Access Token must be present.");this.idToken=s,this.refreshToken=i,this.accessToken=n,this.clockDrift=void 0===r?this.calculateClockDrift():r}var t=e.prototype;return t.getIdToken=function(){return this.idToken},t.getRefreshToken=function(){return this.refreshToken},t.getAccessToken=function(){return this.accessToken},t.getClockDrift=function(){return this.clockDrift},t.calculateClockDrift=function(){var e=Math.floor(new Date/1e3),t=Math.min(this.accessToken.getIssuedAt(),this.idToken.getIssuedAt());return e-t},t.isValid=function(){var e=Math.floor(new Date/1e3),t=e-this.clockDrift;return t<this.accessToken.getExpiration()&&t<this.idToken.getExpiration()},e}(),Ie=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ee=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ke=function(){function e(){}var t=e.prototype;return t.getNowString=function(){var e=new Date,t=Ee[e.getUTCDay()],s=Ie[e.getUTCMonth()],i=e.getUTCDate(),n=e.getUTCHours();n<10&&(n="0"+n);var r=e.getUTCMinutes();r<10&&(r="0"+r);var o=e.getUTCSeconds();o<10&&(o="0"+o);var a=e.getUTCFullYear(),l=t+" "+s+" "+i+" "+n+":"+r+":"+o+" UTC "+a;return l},e}(),Pe=function(){function e(e){var t=void 0===e?{}:e,s=t.Name,i=t.Value;this.Name=s||"",this.Value=i||""}var t=e.prototype;return t.getValue=function(){return this.Value},t.setValue=function(e){return this.Value=e,this},t.getName=function(){return this.Name},t.setName=function(e){return this.Name=e,this},t.toString=function(){return JSON.stringify(this)},t.toJSON=function(){return{Name:this.Name,Value:this.Value}},e}(),Fe={},Re=function(){function e(){}return e.setItem=function(e,t){return Fe[e]=t,Fe[e]},e.getItem=function(e){return Object.prototype.hasOwnProperty.call(Fe,e)?Fe[e]:void 0},e.removeItem=function(e){return delete Fe[e]},e.clear=function(){return Fe={},Fe},e}(),xe=function(){function e(){try{this.storageWindow=window.localStorage,this.storageWindow.setItem("aws.cognito.test-ls",1),this.storageWindow.removeItem("aws.cognito.test-ls")}catch(e){this.storageWindow=Re}}var t=e.prototype;return t.getStorage=function(){return this.storageWindow},e}(),_e="undefined"!==typeof navigator,Me=_e?navigator.userAgent:"nodejs",Oe=function(){function e(e){if(null==e||null==e.Username||null==e.Pool)throw new Error("Username and Pool information are required.");this.username=e.Username||"",this.pool=e.Pool,this.Session=null,this.client=e.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=e.Storage||(new xe).getStorage(),this.keyPrefix="CognitoIdentityServiceProvider."+this.pool.getClientId(),this.userDataKey=this.keyPrefix+"."+this.username+".userData"}var t=e.prototype;return t.setSignInUserSession=function(e){this.clearCachedUserData(),this.signInUserSession=e,this.cacheTokens()},t.getSignInUserSession=function(){return this.signInUserSession},t.getUsername=function(){return this.username},t.getAuthenticationFlowType=function(){return this.authenticationFlowType},t.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},t.initiateAuth=function(e,t){var s=this,i=e.getAuthParameters();i.USERNAME=this.username;var n=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),r={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:i,ClientMetadata:n};this.getUserContextData()&&(r.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",r,(function(e,i){if(e)return t.onFailure(e);var n=i.ChallengeName,r=i.ChallengeParameters;return"CUSTOM_CHALLENGE"===n?(s.Session=i.Session,t.customChallenge(r)):(s.signInUserSession=s.getCognitoUserSession(i.AuthenticationResult),s.cacheTokens(),t.onSuccess(s.signInUserSession))}))},t.authenticateUser=function(e,t){return"USER_PASSWORD_AUTH"===this.authenticationFlowType?this.authenticateUserPlainUsernamePassword(e,t):"USER_SRP_AUTH"===this.authenticationFlowType||"CUSTOM_AUTH"===this.authenticationFlowType?this.authenticateUserDefaultAuth(e,t):t.onFailure(new Error("Authentication flow type is invalid."))},t.authenticateUserDefaultAuth=function(e,t){var s,i,r=this,a=new ge(this.pool.getUserPoolId().split("_")[1]),l=new ke,c={};null!=this.deviceKey&&(c.DEVICE_KEY=this.deviceKey),c.USERNAME=this.username,a.getLargeAValue((function(h,d){h&&t.onFailure(h),c.SRP_A=d.toString(16),"CUSTOM_AUTH"===r.authenticationFlowType&&(c.CHALLENGE_NAME="SRP_A");var f=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),p={AuthFlow:r.authenticationFlowType,ClientId:r.pool.getClientId(),AuthParameters:c,ClientMetadata:f};r.getUserContextData(r.username)&&(p.UserContextData=r.getUserContextData(r.username)),r.client.request("InitiateAuth",p,(function(c,h){if(c)return t.onFailure(c);var d=h.ChallengeParameters;r.username=d.USER_ID_FOR_SRP,r.userDataKey=r.keyPrefix+"."+r.username+".userData",s=new g(d.SRP_B,16),i=new g(d.SALT,16),r.getCachedDeviceKeyAndPassword(),a.getPasswordAuthenticationKey(r.username,e.getPassword(),s,i,(function(e,s){e&&t.onFailure(e);var i=l.getNowString(),c=o.a.lib.WordArray.create(n["Buffer"].concat([n["Buffer"].from(r.pool.getUserPoolId().split("_")[1],"utf8"),n["Buffer"].from(r.username,"utf8"),n["Buffer"].from(d.SECRET_BLOCK,"base64"),n["Buffer"].from(i,"utf8")])),p=o.a.lib.WordArray.create(s),g=be.a.stringify(u()(c,p)),m={};m.USERNAME=r.username,m.PASSWORD_CLAIM_SECRET_BLOCK=d.SECRET_BLOCK,m.TIMESTAMP=i,m.PASSWORD_CLAIM_SIGNATURE=g,null!=r.deviceKey&&(m.DEVICE_KEY=r.deviceKey);var v=function e(t,s){return r.client.request("RespondToAuthChallenge",t,(function(i,n){return i&&"ResourceNotFoundException"===i.code&&-1!==i.message.toLowerCase().indexOf("device")?(m.DEVICE_KEY=null,r.deviceKey=null,r.randomPassword=null,r.deviceGroupKey=null,r.clearCachedDeviceKeyAndPassword(),e(t,s)):s(i,n)}))},C={ChallengeName:"PASSWORD_VERIFIER",ClientId:r.pool.getClientId(),ChallengeResponses:m,Session:h.Session,ClientMetadata:f};r.getUserContextData()&&(C.UserContextData=r.getUserContextData()),v(C,(function(e,s){return e?t.onFailure(e):r.authenticateUserInternal(s,a,t)}))}))}))}))},t.authenticateUserPlainUsernamePassword=function(e,t){var s=this,i={};if(i.USERNAME=this.username,i.PASSWORD=e.getPassword(),i.PASSWORD){var n=new ge(this.pool.getUserPoolId().split("_")[1]);this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(i.DEVICE_KEY=this.deviceKey);var r=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),o={AuthFlow:"USER_PASSWORD_AUTH",ClientId:this.pool.getClientId(),AuthParameters:i,ClientMetadata:r};this.getUserContextData(this.username)&&(o.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",o,(function(e,i){return e?t.onFailure(e):s.authenticateUserInternal(i,n,t)}))}else t.onFailure(new Error("PASSWORD parameter is required"))},t.authenticateUserInternal=function(e,t,s){var i=this,r=e.ChallengeName,o=e.ChallengeParameters;if("SMS_MFA"===r)return this.Session=e.Session,s.mfaRequired(r,o);if("SELECT_MFA_TYPE"===r)return this.Session=e.Session,s.selectMFAType(r,o);if("MFA_SETUP"===r)return this.Session=e.Session,s.mfaSetup(r,o);if("SOFTWARE_TOKEN_MFA"===r)return this.Session=e.Session,s.totpRequired(r,o);if("CUSTOM_CHALLENGE"===r)return this.Session=e.Session,s.customChallenge(o);if("NEW_PASSWORD_REQUIRED"===r){this.Session=e.Session;var a=null,l=null,c=[],u=t.getNewPasswordRequiredChallengeUserAttributePrefix();if(o&&(a=JSON.parse(e.ChallengeParameters.userAttributes),l=JSON.parse(e.ChallengeParameters.requiredAttributes)),l)for(var h=0;h<l.length;h++)c[h]=l[h].substr(u.length);return s.newPasswordRequired(a,c)}if("DEVICE_SRP_AUTH"!==r){this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=r,this.cacheTokens();var d=e.AuthenticationResult.NewDeviceMetadata;if(null==d)return s.onSuccess(this.signInUserSession);t.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(r){if(r)return s.onFailure(r);var o={Salt:n["Buffer"].from(t.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:n["Buffer"].from(t.getVerifierDevices(),"hex").toString("base64")};i.verifierDevices=o.PasswordVerifier,i.deviceGroupKey=d.DeviceGroupKey,i.randomPassword=t.getRandomPassword(),i.client.request("ConfirmDevice",{DeviceKey:d.DeviceKey,AccessToken:i.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:Me},(function(t,n){return t?s.onFailure(t):(i.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,i.cacheDeviceKeyAndPassword(),!0===n.UserConfirmationNecessary?s.onSuccess(i.signInUserSession,n.UserConfirmationNecessary):s.onSuccess(i.signInUserSession))}))}))}else this.getDeviceResponse(s)},t.completeNewPasswordChallenge=function(e,t,s,i){var n=this;if(!e)return s.onFailure(new Error("New password is required."));var r=new ge(this.pool.getUserPoolId().split("_")[1]),o=r.getNewPasswordRequiredChallengeUserAttributePrefix(),a={};t&&Object.keys(t).forEach((function(e){a[o+e]=t[e]})),a.NEW_PASSWORD=e,a.USERNAME=this.username;var l={ChallengeName:"NEW_PASSWORD_REQUIRED",ClientId:this.pool.getClientId(),ChallengeResponses:a,Session:this.Session,ClientMetadata:i};this.getUserContextData()&&(l.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",l,(function(e,t){return e?s.onFailure(e):n.authenticateUserInternal(t,r,s)}))},t.getDeviceResponse=function(e,t){var s=this,i=new ge(this.deviceGroupKey),r=new ke,a={};a.USERNAME=this.username,a.DEVICE_KEY=this.deviceKey,i.getLargeAValue((function(l,c){l&&e.onFailure(l),a.SRP_A=c.toString(16);var h={ChallengeName:"DEVICE_SRP_AUTH",ClientId:s.pool.getClientId(),ChallengeResponses:a,ClientMetadata:t};s.getUserContextData()&&(h.UserContextData=s.getUserContextData()),s.client.request("RespondToAuthChallenge",h,(function(t,a){if(t)return e.onFailure(t);var l=a.ChallengeParameters,c=new g(l.SRP_B,16),h=new g(l.SALT,16);i.getPasswordAuthenticationKey(s.deviceKey,s.randomPassword,c,h,(function(t,i){if(t)return e.onFailure(t);var c=r.getNowString(),h=o.a.lib.WordArray.create(n["Buffer"].concat([n["Buffer"].from(s.deviceGroupKey,"utf8"),n["Buffer"].from(s.deviceKey,"utf8"),n["Buffer"].from(l.SECRET_BLOCK,"base64"),n["Buffer"].from(c,"utf8")])),d=o.a.lib.WordArray.create(i),f=be.a.stringify(u()(h,d)),p={};p.USERNAME=s.username,p.PASSWORD_CLAIM_SECRET_BLOCK=l.SECRET_BLOCK,p.TIMESTAMP=c,p.PASSWORD_CLAIM_SIGNATURE=f,p.DEVICE_KEY=s.deviceKey;var g={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:p,Session:a.Session};s.getUserContextData()&&(g.UserContextData=s.getUserContextData()),s.client.request("RespondToAuthChallenge",g,(function(t,i){return t?e.onFailure(t):(s.signInUserSession=s.getCognitoUserSession(i.AuthenticationResult),s.cacheTokens(),e.onSuccess(s.signInUserSession))}))}))}))}))},t.confirmRegistration=function(e,t,s,i){var n={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:t,ClientMetadata:i};this.getUserContextData()&&(n.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",n,(function(e){return e?s(e,null):s(null,"SUCCESS")}))},t.sendCustomChallengeAnswer=function(e,t,s){var i=this,n={};n.USERNAME=this.username,n.ANSWER=e;var r=new ge(this.pool.getUserPoolId().split("_")[1]);this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(n.DEVICE_KEY=this.deviceKey);var o={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:n,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:s};this.getUserContextData()&&(o.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",o,(function(e,s){return e?t.onFailure(e):i.authenticateUserInternal(s,r,t)}))},t.sendMFACode=function(e,t,s,i){var r=this,o={};o.USERNAME=this.username,o.SMS_MFA_CODE=e;var a=s||"SMS_MFA";"SOFTWARE_TOKEN_MFA"===a&&(o.SOFTWARE_TOKEN_MFA_CODE=e),null!=this.deviceKey&&(o.DEVICE_KEY=this.deviceKey);var l={ChallengeName:a,ChallengeResponses:o,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:i};this.getUserContextData()&&(l.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",l,(function(e,s){if(e)return t.onFailure(e);var i=s.ChallengeName;if("DEVICE_SRP_AUTH"!==i){if(r.signInUserSession=r.getCognitoUserSession(s.AuthenticationResult),r.cacheTokens(),null==s.AuthenticationResult.NewDeviceMetadata)return t.onSuccess(r.signInUserSession);var o=new ge(r.pool.getUserPoolId().split("_")[1]);o.generateHashDevice(s.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,s.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(e){if(e)return t.onFailure(e);var i={Salt:n["Buffer"].from(o.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:n["Buffer"].from(o.getVerifierDevices(),"hex").toString("base64")};r.verifierDevices=i.PasswordVerifier,r.deviceGroupKey=s.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,r.randomPassword=o.getRandomPassword(),r.client.request("ConfirmDevice",{DeviceKey:s.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:r.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:i,DeviceName:Me},(function(e,i){return e?t.onFailure(e):(r.deviceKey=s.AuthenticationResult.NewDeviceMetadata.DeviceKey,r.cacheDeviceKeyAndPassword(),!0===i.UserConfirmationNecessary?t.onSuccess(r.signInUserSession,i.UserConfirmationNecessary):t.onSuccess(r.signInUserSession))}))}))}else r.getDeviceResponse(t)}))},t.changePassword=function(e,t,s,i){if(null==this.signInUserSession||!this.signInUserSession.isValid())return s(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:i},(function(e){return e?s(e,null):s(null,"SUCCESS")}))},t.enableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var t=[],s={DeliveryMedium:"SMS",AttributeName:"phone_number"};t.push(s),this.client.request("SetUserSettings",{MFAOptions:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.setUserMfaPreference=function(e,t,s){if(null==this.signInUserSession||!this.signInUserSession.isValid())return s(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?s(e,null):s(null,"SUCCESS")}))},t.disableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var t=[];this.client.request("SetUserSettings",{MFAOptions:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.deleteUser=function(e,t){var s=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("DeleteUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:t},(function(t){return t?e(t,null):(s.clearCachedUser(),e(null,"SUCCESS"))}))},t.updateAttributes=function(e,t,s){var i=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("UpdateUserAttributes",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserAttributes:e,ClientMetadata:s},(function(e){return e?t(e,null):i.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.getUserAttributes=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,s){if(t)return e(t,null);for(var i=[],n=0;n<s.UserAttributes.length;n++){var r={Name:s.UserAttributes[n].Name,Value:s.UserAttributes[n].Value},o=new Pe(r);i.push(o)}return e(null,i)}))},t.getMFAOptions=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,s){return t?e(t,null):e(null,s.MFAOptions)}))},t.createGetUserRequest=function(){return this.client.promisifyRequest("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()})},t.refreshSessionIfPossible=function(e){var t=this;return void 0===e&&(e={}),new Promise((function(s){var i=t.signInUserSession.getRefreshToken();i&&i.getToken()?t.refreshSession(i,s,e.clientMetadata):s()}))},t.getUserData=function(e,t){var s=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var i=this.getUserDataFromCache();if(i)if(this.isFetchUserDataAndTokenRequired(t))this.fetchUserData().then((function(e){return s.refreshSessionIfPossible(t).then((function(){return e}))})).then((function(t){return e(null,t)}))["catch"](e);else try{return void e(null,JSON.parse(i))}catch(n){return this.clearCachedUserData(),void e(n,null)}else this.fetchUserData().then((function(t){e(null,t)}))["catch"](e)},t.getUserDataFromCache=function(){var e=this.storage.getItem(this.userDataKey);return e},t.isFetchUserDataAndTokenRequired=function(e){var t=e||{},s=t.bypassCache,i=void 0!==s&&s;return i},t.fetchUserData=function(){var e=this;return this.createGetUserRequest().then((function(t){return e.cacheUserData(t),t}))},t.deleteAttributes=function(e,t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("DeleteUserAttributes",{UserAttributeNames:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?t(e,null):t(null,"SUCCESS")}))},t.resendConfirmationCode=function(e,t){var s={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.client.request("ResendConfirmationCode",s,(function(t,s){return t?e(t,null):e(null,s)}))},t.getSession=function(e,t){if(void 0===t&&(t={}),null==this.username)return e(new Error("Username is null. Cannot retrieve a new session"),null);if(null!=this.signInUserSession&&this.signInUserSession.isValid())return e(null,this.signInUserSession);var s="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,i=s+".idToken",n=s+".accessToken",r=s+".refreshToken",o=s+".clockDrift";if(this.storage.getItem(i)){var a=new Ae({IdToken:this.storage.getItem(i)}),l=new we({AccessToken:this.storage.getItem(n)}),c=new De({RefreshToken:this.storage.getItem(r)}),u=parseInt(this.storage.getItem(o),0)||0,h={IdToken:a,AccessToken:l,RefreshToken:c,ClockDrift:u},d=new Te(h);if(d.isValid())return this.signInUserSession=d,e(null,this.signInUserSession);if(!c.getToken())return e(new Error("Cannot retrieve a new session. Please authenticate."),null);this.refreshSession(c,e,t.clientMetadata)}else e(new Error("Local storage is missing an ID Token, Please authenticate"),null)},t.refreshSession=function(e,t,s){var i=this,n=this.pool.wrapRefreshSessionCallback?this.pool.wrapRefreshSessionCallback(t):t,r={};r.REFRESH_TOKEN=e.getToken();var o="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=o+".LastAuthUser";if(this.storage.getItem(a)){this.username=this.storage.getItem(a);var l=o+"."+this.username+".deviceKey";this.deviceKey=this.storage.getItem(l),r.DEVICE_KEY=this.deviceKey}var c={ClientId:this.pool.getClientId(),AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:r,ClientMetadata:s};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",c,(function(t,s){if(t)return"NotAuthorizedException"===t.code&&i.clearCachedUser(),n(t,null);if(s){var r=s.AuthenticationResult;return Object.prototype.hasOwnProperty.call(r,"RefreshToken")||(r.RefreshToken=e.getToken()),i.signInUserSession=i.getCognitoUserSession(r),i.cacheTokens(),n(null,i.signInUserSession)}}))},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",s=e+"."+this.username+".accessToken",i=e+"."+this.username+".refreshToken",n=e+"."+this.username+".clockDrift",r=e+".LastAuthUser";this.storage.setItem(t,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(s,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(i,this.signInUserSession.getRefreshToken().getToken()),this.storage.setItem(n,""+this.signInUserSession.getClockDrift()),this.storage.setItem(r,this.username)},t.cacheUserData=function(e){this.storage.setItem(this.userDataKey,JSON.stringify(e))},t.clearCachedUserData=function(){this.storage.removeItem(this.userDataKey)},t.clearCachedUser=function(){this.clearCachedTokens(),this.clearCachedUserData()},t.cacheDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",s=e+".randomPasswordKey",i=e+".deviceGroupKey";this.storage.setItem(t,this.deviceKey),this.storage.setItem(s,this.randomPassword),this.storage.setItem(i,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",s=e+".randomPasswordKey",i=e+".deviceGroupKey";this.storage.getItem(t)&&(this.deviceKey=this.storage.getItem(t),this.randomPassword=this.storage.getItem(s),this.deviceGroupKey=this.storage.getItem(i))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",s=e+".randomPasswordKey",i=e+".deviceGroupKey";this.storage.removeItem(t),this.storage.removeItem(s),this.storage.removeItem(i)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",s=e+"."+this.username+".accessToken",i=e+"."+this.username+".refreshToken",n=e+".LastAuthUser",r=e+"."+this.username+".clockDrift";this.storage.removeItem(t),this.storage.removeItem(s),this.storage.removeItem(i),this.storage.removeItem(n),this.storage.removeItem(r)},t.getCognitoUserSession=function(e){var t=new Ae(e),s=new we(e),i=new De(e),n={IdToken:t,AccessToken:s,RefreshToken:i};return new Te(n)},t.forgotPassword=function(e,t){var s={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",s,(function(t,s){return t?e.onFailure(t):"function"===typeof e.inputVerificationCode?e.inputVerificationCode(s):e.onSuccess(s)}))},t.confirmPassword=function(e,t,s,i){var n={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:t,ClientMetadata:i};this.getUserContextData()&&(n.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",n,(function(e){return e?s.onFailure(e):s.onSuccess()}))},t.getAttributeVerificationCode=function(e,t,s){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("GetUserAttributeVerificationCode",{AttributeName:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:s},(function(e,s){return e?t.onFailure(e):"function"===typeof t.inputVerificationCode?t.inputVerificationCode(s):t.onSuccess()}))},t.verifyAttribute=function(e,t,s){if(null==this.signInUserSession||!this.signInUserSession.isValid())return s.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?s.onFailure(e):s.onSuccess("SUCCESS")}))},t.getDevice=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey},(function(t,s){return t?e.onFailure(t):e.onSuccess(s)}))},t.forgetSpecificDevice=function(e,t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("ForgetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:e},(function(e){return e?t.onFailure(e):t.onSuccess("SUCCESS")}))},t.forgetDevice=function(e){var t=this;this.forgetSpecificDevice(this.deviceKey,{onFailure:e.onFailure,onSuccess:function(s){return t.deviceKey=null,t.deviceGroupKey=null,t.randomPassword=null,t.clearCachedDeviceKeyAndPassword(),e.onSuccess(s)}})},t.setDeviceStatusRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.setDeviceStatusNotRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"not_remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.listDevices=function(e,t,s){if(null==this.signInUserSession||!this.signInUserSession.isValid())return s.onFailure(new Error("User is not authenticated"));var i={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};t&&(i.PaginationToken=t),this.client.request("ListDevices",i,(function(e,t){return e?s.onFailure(e):s.onSuccess(t)}))},t.globalSignOut=function(e){var t=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GlobalSignOut",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(s){return s?e.onFailure(s):(t.clearCachedUser(),e.onSuccess("SUCCESS"))}))},t.signOut=function(){this.signInUserSession=null,this.clearCachedUser()},t.sendMFASelectionAnswer=function(e,t){var s=this,i={};i.USERNAME=this.username,i.ANSWER=e;var n={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:i,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(n.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",n,(function(i,n){return i?t.onFailure(i):(s.Session=n.Session,"SMS_MFA"===e?t.mfaRequired(n.ChallengeName,n.ChallengeParameters):"SOFTWARE_TOKEN_MFA"===e?t.totpRequired(n.ChallengeName,n.ChallengeParameters):void 0)}))},t.getUserContextData=function(){var e=this.pool;return e.getUserContextData(this.username)},t.associateSoftwareToken=function(e){var t=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("AssociateSoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,s){return t?e.onFailure(t):e.associateSecretCode(s.SecretCode)})):this.client.request("AssociateSoftwareToken",{Session:this.Session},(function(s,i){return s?e.onFailure(s):(t.Session=i.Session,e.associateSecretCode(i.SecretCode))}))},t.verifySoftwareToken=function(e,t,s){var i=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("VerifySoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserCode:e,FriendlyDeviceName:t},(function(e,t){return e?s.onFailure(e):s.onSuccess(t)})):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:t},(function(e,t){if(e)return s.onFailure(e);i.Session=t.Session;var n={};n.USERNAME=i.username;var r={ChallengeName:"MFA_SETUP",ClientId:i.pool.getClientId(),ChallengeResponses:n,Session:i.Session};i.getUserContextData()&&(r.UserContextData=i.getUserContextData()),i.client.request("RespondToAuthChallenge",r,(function(e,t){return e?s.onFailure(e):(i.signInUserSession=i.getCognitoUserSession(t.AuthenticationResult),i.cacheTokens(),s.onSuccess(i.signInUserSession))}))}))},e}();
/*!
 * Copyright 2016 Amazon.com,
 * Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Amazon Software License (the "License").
 * You may not use this file except in compliance with the
 * License. A copy of the License is located at
 *
 *     http://aws.amazon.com/asl/
 *
 * or in the "license" file accompanying this file. This file is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, express or implied. See the License
 * for the specific language governing permissions and
 * limitations under the License.
 */s("ce08");function Ne(){}Ne.prototype.userAgent="aws-amplify/0.1.x js";var Be=Ne;function Ve(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,We(e,t)}function Ke(e){var t="function"===typeof Map?new Map:void 0;return Ke=function(e){if(null===e||!$e(e))return e;if("function"!==typeof e)throw new TypeError("Super expression must either be null or a function");if("undefined"!==typeof t){if(t.has(e))return t.get(e);t.set(e,s)}function s(){return Le(e,arguments,He(this).constructor)}return s.prototype=Object.create(e.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),We(s,e)},Ke(e)}function Le(e,t,s){return Le=qe()?Reflect.construct:function(e,t,s){var i=[null];i.push.apply(i,t);var n=Function.bind.apply(e,i),r=new n;return s&&We(r,s.prototype),r},Le.apply(null,arguments)}function qe(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function $e(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function We(e,t){return We=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},We(e,t)}function He(e){return He=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},He(e)}var je=function(e){function t(t,s,i,n){var r;return r=e.call(this,t)||this,r.code=s,r.name=i,r.statusCode=n,r}return Ve(t,e),t}(Ke(Error)),ze=function(){function e(e,t,s){this.endpoint=t||"https://cognito-idp."+e+".amazonaws.com/";var i=s||{},n=i.credentials;this.fetchOptions=n?{credentials:n}:{}}var t=e.prototype;return t.promisifyRequest=function(e,t){var s=this;return new Promise((function(i,n){s.request(e,t,(function(e,t){e?n(new je(e.message,e.code,e.name,e.statusCode)):i(t)}))}))},t.request=function(e,t,s){var i,n={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":Be.prototype.userAgent},r=Object.assign({},this.fetchOptions,{headers:n,method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify(t)});fetch(this.endpoint,r).then((function(e){return i=e,e}),(function(e){if(e instanceof TypeError)throw new Error("Network error");throw e})).then((function(e){return e.json()["catch"]((function(){return{}}))})).then((function(e){if(i.ok)return s(null,e);e;var t=(e.__type||e.code).split("#").pop(),n={code:t,name:t,message:e.message||e.Message||null};return s(n)}))["catch"]((function(e){if(!(i&&i.headers&&i.headers.get("x-amzn-errortype"))){if(e instanceof Error&&"Network error"===e.message){var t={code:"NetworkError",name:e.name,message:e.message};return s(t)}return s(e)}try{var n=i.headers.get("x-amzn-errortype").split(":")[0],r={code:n,name:n,statusCode:i.status,message:i.status?i.status.toString():null};return s(r)}catch(o){return s(e)}}))},e}(),Ge=function(){function e(e,t){var s=e||{},i=s.UserPoolId,n=s.ClientId,r=s.endpoint,o=s.fetchOptions,a=s.AdvancedSecurityDataCollectionFlag;if(!i||!n)throw new Error("Both UserPoolId and ClientId are required.");if(!/^[\w-]+_.+$/.test(i))throw new Error("Invalid UserPoolId format.");var l=i.split("_")[0];this.userPoolId=i,this.clientId=n,this.client=new ze(l,r,o),this.advancedSecurityDataCollectionFlag=!1!==a,this.storage=e.Storage||(new xe).getStorage(),t&&(this.wrapRefreshSessionCallback=t)}var t=e.prototype;return t.getUserPoolId=function(){return this.userPoolId},t.getClientId=function(){return this.clientId},t.signUp=function(e,t,s,i,n,r){var o=this,a={ClientId:this.clientId,Username:e,Password:t,UserAttributes:s,ValidationData:i,ClientMetadata:r};this.getUserContextData(e)&&(a.UserContextData=this.getUserContextData(e)),this.client.request("SignUp",a,(function(t,s){if(t)return n(t,null);var i={Username:e,Pool:o,Storage:o.storage},r={user:new Oe(i),userConfirmed:s.UserConfirmed,userSub:s.UserSub,codeDeliveryDetails:s.CodeDeliveryDetails};return n(null,r)}))},t.getCurrentUser=function(){var e="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",t=this.storage.getItem(e);if(t){var s={Username:t,Pool:this,Storage:this.storage};return new Oe(s)}return null},t.getUserContextData=function(e){if("undefined"!==typeof AmazonCognitoAdvancedSecurityData){var t=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var s=t.getData(e,this.userPoolId,this.clientId);if(s){var i={EncodedData:s};return i}}return{}}},e}(),Je=s("a78e"),Qe=function(){function e(e){if(!e.domain)throw new Error("The domain of cookieStorage can not be undefined.");if(this.domain=e.domain,e.path?this.path=e.path:this.path="/",Object.prototype.hasOwnProperty.call(e,"expires")?this.expires=e.expires:this.expires=365,Object.prototype.hasOwnProperty.call(e,"secure")?this.secure=e.secure:this.secure=!0,Object.prototype.hasOwnProperty.call(e,"sameSite")){if(!["strict","lax","none"].includes(e.sameSite))throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');if("none"===e.sameSite&&!this.secure)throw new Error("sameSite = None requires the Secure attribute in latest browser versions.");this.sameSite=e.sameSite}else this.sameSite=null}var t=e.prototype;return t.setItem=function(e,t){var s={path:this.path,expires:this.expires,domain:this.domain,secure:this.secure};return this.sameSite&&(s.sameSite=this.sameSite),Je["set"](e,t,s),Je["get"](e)},t.getItem=function(e){return Je["get"](e)},t.removeItem=function(e){var t={path:this.path,expires:this.expires,domain:this.domain,secure:this.secure};return this.sameSite&&(t.sameSite=this.sameSite),Je["remove"](e,t)},t.clear=function(){for(var e=Je["get"](),t=Object.keys(e).length,s=0;s<t;++s)this.removeItem(Object.keys(e)[s]);return{}},e}()},"51f3":function(e,t,s){"use strict";function i(e,t){if(!e||!t||!e.length||!t.length)throw new Error("Bad alphabet");this.srcAlphabet=e,this.dstAlphabet=t}i.prototype.convert=function(e){var t,s,i,n={},r=this.srcAlphabet.length,o=this.dstAlphabet.length,a=e.length,l="string"===typeof e?"":[];if(!this.isValid(e))throw new Error('Number "'+e+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return e;for(t=0;t<a;t++)n[t]=this.srcAlphabet.indexOf(e[t]);do{for(s=0,i=0,t=0;t<a;t++)s=s*r+n[t],s>=o?(n[i++]=parseInt(s/o,10),s%=o):i>0&&(n[i++]=0);a=i,l=this.dstAlphabet.slice(s,s+1).concat(l)}while(0!==i);return l},i.prototype.isValid=function(e){for(var t=0;t<e.length;++t)if(-1===this.srcAlphabet.indexOf(e[t]))return!1;return!0},e.exports=i},"573e":function(e,t,s){},6634:function(e,t,s){"use strict";s("d9e2"),s("1e70"),s("79a4"),s("c1a1"),s("8b00"),s("a4e7"),s("1e5a"),s("72c3"),s("498a"),s("ddb0");var i=s("bc3a"),n=s.n(i);class r{constructor(){this.csvUrl="https://raw.githubusercontent.com/thanakijwanavit/villaMasterSchema/master/shipping/nationwideRate.csv",this.validPostalCodes=new Set,this.isInitialized=!1,this.isLoading=!1,this.hasError=!1}async loadPostalCodes(){if(!this.isInitialized){this.isLoading=!0,this.hasError=!1;try{const e=await n.a.get(this.csvUrl);if(200!==e.status)throw this.hasError=!0,new Error("Failed to load postal codes: "+e.status);{const t=e.data.split("\n");for(let e=1;e<t.length;e++){const s=t[e].trim();if(s){const e=s.split(",");if(e.length>0){const t=e[0].trim();t&&this.validPostalCodes.add(t)}}}this.isInitialized=!0}}catch(e){throw this.hasError=!0,e}finally{this.isLoading=!1}}}isPostalCodeValid(e){return!(!this.isInitialized||!e)&&this.validPostalCodes.has(e.trim())}async isPostalCodeValidAsync(e){return this.isInitialized||await this.loadPostalCodes(),this.isPostalCodeValid(e)}getValidPostalCodes(){return Array.from(this.validPostalCodes)}}t["a"]=new r},7964:function(e,t,s){"use strict";s.r(t);var i=function(){var e=this,t=e._self._c;return t("div",{attrs:{id:"map"}})},n=[];s("e9f5"),s("ab43"),s("ddb0");class r{constructor(e=null,t={}){if(this.apiKey=e,this.options=t,"undefined"===typeof window)throw new Error("google-maps is supported only in browser environment")}load(){return"undefined"!==typeof this.api?Promise.resolve(this.api):"undefined"!==typeof this.loader?this.loader:(window[r.CALLBACK_NAME]=()=>{if(this.api=window["google"],"undefined"===typeof this.resolve)throw new Error("Should not happen");this.resolve(this.api)},window["gm_authFailure"]=()=>{if("undefined"===typeof this.reject)throw new Error("Should not happen");this.reject(new Error("google-maps: authentication error"))},this.loader=new Promise((e,t)=>{this.resolve=e,this.reject=t;const s=document.createElement("script");s.src=this.createUrl(),s.async=!0,s.onerror=e=>t(e),document.head.appendChild(s)}))}createUrl(){const e=["callback="+r.CALLBACK_NAME];this.apiKey&&e.push("key="+this.apiKey);for(let t in this.options)if(this.options.hasOwnProperty(t)){let s=this.options[t];"version"===t&&(t="v"),"libraries"===t&&(s=s.join(",")),e.push(`${t}=${s}`)}return"https://maps.googleapis.com/maps/api/js?"+e.join("&")}}r.CALLBACK_NAME="_dk_google_maps_loader_cb";var o=s("ee57"),a=s("d8af"),l=s("bc3a"),c=s.n(l),u=s("5a0c"),h=s.n(u);let d=s("5ccb"),f="M17.402,0H5.643C2.526,0,0,3.467,0,6.584v34.804c0,3.116,2.526,5.644,5.643,5.644h11.759c3.116,0,5.644-2.527,5.644-5.644 V6.584C23.044,3.467,20.518,0,17.402,0z M22.057,14.188v11.665l-2.729,0.351v-4.806L22.057,14.188z M20.625,10.773 c-1.016,3.9-2.219,8.51-2.219,8.51H4.638l-2.222-8.51C2.417,10.773,11.3,7.755,20.625,10.773z M3.748,21.713v4.492l-2.73-0.349 V14.502L3.748,21.713z M1.018,37.938V27.579l2.73,0.343v8.196L1.018,37.938z M2.575,40.882l2.218-3.336h13.771l2.219,3.336H2.575z M19.328,35.805v-7.872l2.729-0.355v10.048L19.328,35.805z",p={path:f,scale:.7,strokeColor:"white",strokeWeight:.1,fillOpacity:1,fillColor:"#2c2a74",offset:"5%",rotation:0,anchor:""};const g=new r("AIzaSyBJgo2v7sBi70ptQatOBHCIAmUb8rRUWU4");let m,v;var C={name:"MapTracking",data(){return{map:"",origin:{lat:13.7451179,lng:100.5638973},destination:{lat:13.7305691,lng:100.5406135},markerOrigin:null,markerDesination:null,markerRider:null,riderPosition:null,orderDetail:null,infowindow:null,directionsService:null,pooling:null,center:null,autoupdateCenter:!0}},async mounted(){m=await g.load();const{id:e}=this.$router.currentRoute.params;this.initMap(),setInterval(()=>{this.getOrderDetail(e)},5e3)},methods:{customInfoWindow(e){return`<div style="align-items: center;display: flex;flex-direction: column;">\n      <img src="${d}"/>\n      <p style="font-size:16px;margin: 10px 0;font-weight: 900;color: #2d2b74;">OrderId #${e.id}</p>\n      <div style="text-align:left;width: 100%;">\n        <p style="font-size:14px;margin: 0;">\n          <span style="font-size: 15px;font-weight: bold;">origin:\n          </span> ${e.origin}\n        </p>\n         <p style="font-size:14px;margin: 0;">\n          <span style="font-size: 15px;font-weight: bold;">destination:\n          </span> ${e.destination}\n        </p>\n          <p style="font-size:14px;margin: 0;">\n          <span style="font-size: 15px;font-weight: bold;">time:\n          </span> ${e.time}\n        </p>\n          <p style="font-size:14px;margin: 0;">\n          <span style="font-size: 15px;font-weight: bold;">distance:\n          </span> ${e.distance}\n        </p>\n      </div>\n      <div style="width: 100%;text-align: right;font-size: 9px;">\n       <p style="margin: 0;">\n          <span style="font-weight: bold;">GPS Latest update:\n          </span> ${h()(e.Positions.items[0].createdAt).format("HH:mm:ss DD/MM/YYYY")}\n        </p>\n      </div>\n      </div>`},async initMap(){this.directionsService=new m.maps.DirectionsService,v=new m.maps.DirectionsRenderer;var e={zoom:12,center:this.getCenter(this.origin,this.destination),styles:[{featureType:"administrative.land_parcel",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"poi",elementType:"labels.text",stylers:[{visibility:"off"}]},{featureType:"poi.business",stylers:[{visibility:"off"}]},{featureType:"road",elementType:"labels.icon",stylers:[{visibility:"off"}]},{featureType:"road.local",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"transit",stylers:[{visibility:"off"}]}],disableDefaultUI:!0};this.map=new m.maps.Map(document.getElementById("map"),e),v.setMap(this.map);const{id:t}=this.$router.currentRoute.params;await this.getOrderDetail(t),this.infowindow=new m.maps.InfoWindow({content:this.customInfoWindow(this.orderDetail),disableAutoPan:!0}),this.infowindow.open(this.map,this.markerRider)},createMarker(e,t){let s=this.map;if(t){const i=new m.maps.Marker({position:e,icon:t,map:s});return i}{const t=new m.maps.Marker({position:e,map:s});return t}},async calcRoute(e,t){const s=this;var i={origin:String([null===e||void 0===e?void 0:e.lat(),null===e||void 0===e?void 0:e.lng()]),destination:t,travelMode:"DRIVING",avoidHighways:!0,avoidTolls:!0,provideRouteAlternatives:!0};try{var n;let e=await this.$store.dispatch("villaMap/Route",i);e.request=i;let t=m.maps.geometry.encoding.decodePath(e.routes[0].overview_polyline.points);e.routes[0].overview_path=t;const r=(null===(n=e.routes)||void 0===n?void 0:n.map(e=>(e.legs=e.legs.map(e=>(e.steps=e.steps.map(e=>{const t=m.maps.geometry.encoding.decodePath(e.polyline.points);return e.path=t,e})||[],e))||[],e)))||[];e.routes=r,v.setDirections(e),v.setOptions({polylineOptions:{strokeColor:"#2c2a74",strokeOpacity:.8,strokeWeight:6},suppressMarkers:!0,preserveViewport:!0});let o=e.routes[0].overview_path;s.markerDesination||(s.markerDesination=s.createMarker(o[o.length-1],null));const a=s.getCenter(o[0],o[0]);s.autoupdateCenter&&(s.map.setOptions({zoom:15,center:a}),s.autoupdateCenter=!1)}catch(r){}},async getOrderDetail(e){var t;const{data:s}=await c.a.get(o["a"]+"/getOrderDetail",{params:{id:e}}),i=s.data.Positions.items[0],n=new m.maps.LatLng(i);if(this.orderDetail=s.data,this.destination=s.data.destination,s.data.destinationLocation&&(this.destination=`${s.data.destinationLocation.lat}, ${s.data.destinationLocation.lng}`),this.calcRoute(n,this.destination),this.markerRider){var r;let e=this.markerRider.getIcon();e.rotation=i.heading,this.markerRider.setIcon(e),this.markerRider.setPosition(i),null===(r=this.infowindow)||void 0===r||r.setContent(this.customInfoWindow(this.orderDetail))}else p.anchor=new m.maps.Point(10,25),p.fillColor="#30a566",p.rotation=i.heading,this.markerRider=this.createMarker(i,p);const[l,u]=null===(t=Object(a["c"])(s.data.brcode))||void 0===t?void 0:t.latlng;this.origin={lat:l,lng:u},this.markerOrigin=this.createMarker(this.origin,d)},getCenter(e,t){let s=new m.maps.LatLngBounds;return s.extend(new m.maps.LatLng(e)),s.extend(new m.maps.LatLng(t)),s.getCenter()}}},w=C,S=(s("378c"),s("2877")),y=Object(S["a"])(w,i,n,!1,null,"5a1f216c",null);t["default"]=y.exports},"7e93":function(e,t,s){"use strict";s.r(t);s("e01a"),s("498a");var i=function(){var e=this,t=e._self._c;return t("div",{staticClass:"add-address-dialog tw-bg-white tw-p-8"},[t("div",{staticClass:"tw-font-bold tw-text-primary tw-text-lg tw-pb-2"},[e._v(" "+e._s(e.$t("Add address"))+" ")]),t("q-form",{staticClass:"tw-py-2",on:{submit:function(t){return t.preventDefault(),e.onSubmit.apply(null,arguments)}}},[t("div",{staticClass:"input-group"},[t("q-input",{staticStyle:{"grid-column":"span 2 / span 2"},attrs:{label:e.$t("Full name"),"hide-bottom-space":"",outlined:"",dense:"",rules:[t=>t&&t.trim().length>0||e.$t("Please enter name"),e=>/^[a-zA-Z0-9\s]*$/.test(e)||"Please enter valid name"]},model:{value:e.local.name,callback:function(t){e.$set(e.local,"name",t)},expression:"local.name"}}),t("VuePhoneNumberInput",{ref:"promptPhone",staticStyle:{"grid-column":"span 2 / span 2"},attrs:{"default-country-code":"TH","preferred-countries":["TH","US","GB"],error:e.promptPhone.phoneDummyError,"error-color":"#C10015"},on:{update:e.onUpdatePromptPhone},model:{value:e.promptPhone.phoneDummy,callback:function(t){e.$set(e.promptPhone,"phoneDummy",t)},expression:"promptPhone.phoneDummy"}}),t("q-input",{staticStyle:{"grid-column":"span 2 / span 2"},attrs:{label:e.$t("Email"),"hide-bottom-space":"",outlined:"",dense:"",type:"email",rules:[t=>t&&t.trim().length>0||e.$t("Please enter email"),t=>/.+@.+\..+/.test(t)||e.$t("Please enter valid email")]},model:{value:e.address.email,callback:function(t){e.$set(e.address,"email",t)},expression:"address.email"}}),t("q-input",{staticStyle:{"grid-column":"span 2 / span 2"},attrs:{dense:"",label:e.$t("Address details"),placeholder:"house no., building, village, street","hide-bottom-space":"",type:"textarea",autogrow:"",outlined:"",clearable:"",rules:[t=>t&&t.length>0||e.$t("Please enter address details")]},model:{value:e.moreAddressInfo,callback:function(t){e.moreAddressInfo="string"===typeof t?t.trim():t},expression:"moreAddressInfo"}}),t("q-select",{ref:"select_province",attrs:{dense:"","hide-bottom-space":"",disable:e.provinceList.length<=0,options:e.provinceList,label:e.$t("Province *"),outlined:"",rules:[t=>t&&t.length>0||e.$t("Please enter province details")]},model:{value:e.address.province,callback:function(t){e.$set(e.address,"province",t)},expression:"address.province"}}),t("q-select",{ref:"select_district",attrs:{"hide-bottom-space":"",dense:"",disable:e.districtList.length<=0,options:e.districtList,label:e.$t("District *"),outlined:"",rules:[t=>t&&t.length>0||e.$t("Please enter district details")]},model:{value:e.address.district,callback:function(t){e.$set(e.address,"district",t)},expression:"address.district"}}),t("q-select",{ref:"select_sub_district",attrs:{dense:"","hide-bottom-space":"",disable:e.subDistrictList.length<=0,options:e.subDistrictList,label:e.$t("Subdistrict *"),outlined:"",rules:[t=>t&&t.length>0||e.$t("Please enter sub district details")]},model:{value:e.address.subDistrict,callback:function(t){e.$set(e.address,"subDistrict",t)},expression:"address.subDistrict"}}),t("q-select",{ref:"select_post_code",attrs:{dense:"","hide-bottom-space":"",disable:e.postalCodeList.length<=0,options:e.postalCodeList,outlined:"",label:e.$t("Postal code *"),rules:[t=>t&&t.length>0||e.$t("Please enter postal code")]},model:{value:e.address.postcode,callback:function(t){e.$set(e.address,"postcode",t)},expression:"address.postcode"}})],1),t("q-separator",{staticStyle:{margin:"1rem 0"}}),t("div",{staticClass:"tw-font-bold tw-text-primary tw-text-lg tw-pb-2"},[e._v(" "+e._s(e.$t("Identify your location"))+" ")]),t("p",{staticStyle:{"font-size":"12px","padding-bottom":"0.5rem",color:"#f97316"}},[e._v(" "+e._s(e.$t("Find nearby locations by entering your address or landmark in the input field. Drag the marker on the map to set your shipping address."))+" ")]),t("q-input",{attrs:{dense:"",disable:!e.address.postcode,label:e.$t("Search for closest places"),type:"textarea",placeholder:e.$t("Input your address or nearby place"),autogrow:"",clearable:"",outlined:""},on:{input:function(t){return e.onQuery(e.address.address)}},model:{value:e.address.address,callback:function(t){e.$set(e.address,"address",t)},expression:"address.address"}}),t("div",{staticClass:"dropdown-box"},[e.predictions.length>0?t("div",{staticClass:"dropdown-content tw-bg-white"},[t("q-list",{staticClass:"tw-bg-white",attrs:{bordered:"",separator:""}},e._l(e.predictions,(function(s){return t("q-item",{key:s.description,staticClass:"tw-bg-white",attrs:{dense:"",clickable:""},on:{click:function(t){return e.onSelectPredictedItem(s)}}},[t("q-item-section",[e._v(e._s(s.description))])],1)})),1)],1):e._e()]),e.warning.show?t("div",{staticClass:"warning-box tw-p-2",class:{"warning-box-warn":"warn"===e.warning.type,"warning-box-error":"error"===e.warning.type}},[t("div",{staticClass:"title"},[e._v(e._s(e.warning.title))]),t("div",{staticClass:"tw-text-xs"},[e._v(e._s(e.warning.message))])]):e._e(),t("div",{ref:"dummymap",staticClass:"dummymap"}),t("div",{staticClass:"map-box tw-w-full tw-h-full"},[t("GmapMap",{ref:"mapRef",staticClass:"tw-w-10rem tw-h-10rem",staticStyle:{width:"100%",height:"200px"},attrs:{center:e.mapCenter,zoom:15,"map-type-id":"roadmap",options:{zoomControl:e.showMarker,mapTypeControl:!1,scaleControl:!1,streetViewControl:!1,rotateControl:!1,fullscreenControl:!1,disableDefaultUi:!0,clickableIcons:!1,draggable:!1}}},[e.showMarker?t("GmapMarker",{ref:"markerRef",attrs:{position:e.mapCenter,clickable:!0,draggable:!1},on:{click:e.onClickMarker,drag:e.onDragMarker}}):e._e()],1),t("div",{directives:[{name:"show",rawName:"v-show",value:e.isMapOverlay,expression:"isMapOverlay"}],staticClass:"map-box-overlay"}),e.userAddressCenter?t("div",{staticClass:"map-option-box"},[t("q-btn",{attrs:{color:"dark",label:"Edit"},on:{click:e.onEditMarker}})],1):e._e()],1),t("AddressTagPicker",{attrs:{disable:!e.canEditTag},model:{value:e.local.tag,callback:function(t){e.$set(e.local,"tag",t)},expression:"local.tag"}}),t("div",{staticClass:"footer tw-pt-4 tw-w-full tw-flex tw-flex-row tw-justify-end tw-items-center tw-gap-4"},[t("q-btn",{attrs:{type:"button",flat:"",color:"primary"},on:{click:e.onClose}},[e._v(e._s(e.$t("Close")))]),t("q-btn",{attrs:{type:"submit",disable:!e.allowConfirm,loading:e.addAddressLoading,color:"primary"}},[e._v(e._s(e.$t("Confirm")))])],1)],1),t("q-dialog",{attrs:{persistent:"",maximized:e.isMobile},model:{value:e.editLocationDialog,callback:function(t){e.editLocationDialog=t},expression:"editLocationDialog"}},[t("LocationEditor",{attrs:{currentLocation:e.userAddressCenter,address:e.address},on:{confirm:e.onUpdateLocation,close:function(t){e.editLocationDialog=!1}}})],1),t("q-dialog",{attrs:{persistent:""},model:{value:e.outOfServiceDialog,callback:function(t){e.outOfServiceDialog=t},expression:"outOfServiceDialog"}},[t("q-card",{staticClass:"tw-p-6",staticStyle:{"min-width":"300px"}},[t("q-card-section",{staticClass:"tw-p-0"},[t("div",{staticClass:"tw-text-lg tw-font-bold tw-text-red-600 tw-pb-2"},[e._v(" "+e._s(e.$t("Out of Service Area"))+" ")]),t("div",{staticClass:"tw-text-sm"},[e._v(" "+e._s(e.$t("Sorry, we cannot deliver to the postal code you entered. This area is currently outside our nationwide delivery service coverage."))+" ")]),t("div",{staticClass:"tw-text-sm tw-pt-2 tw-text-gray-600"},[e._v(" "+e._s(e.$t("Postal code"))+": "),t("strong",[e._v(e._s(e.address.postcode))])])]),t("q-card-actions",{staticClass:"tw-pt-4",attrs:{align:"right"}},[t("q-btn",{directives:[{name:"close-popup",rawName:"v-close-popup"}],attrs:{flat:"",label:e.$t("OK"),color:"primary"},on:{click:function(t){e.outOfServiceDialog=!1}}})],1)],1)],1)],1)},n=[],r=(s("14d9"),s("e9f5"),s("910d"),s("7d54"),s("ab43"),s("a732"),s("e9c4"),s("1e70"),s("79a4"),s("c1a1"),s("8b00"),s("a4e7"),s("1e5a"),s("72c3"),s("5087"),s("ddb0"),s("2b0e")),o=s("755e"),a=s("58a7"),l=s("b012"),c=function(){var e=this,t=e._self._c;return t("div",{staticClass:"address-tag-picker"},[e.disable?t("div",{staticClass:"address-tag-overlay"}):e._e(),t("div",{staticClass:"address-tag-title"},[e._v(e._s(e.$t("Address tag")))]),t("div",{staticClass:"address-tag-options"},e._l(e.tags,(function(s){return t("button",{key:s,attrs:{type:"button"},on:{click:function(t){return e.onSelectItem(s)}}},[t("AddressTagItem",{attrs:{title:s,active:s===e.value}})],1)})),0)])},u=[];const h=["Home","Office"];var d={name:"AddressTagPicker",props:{value:{type:String},disable:{type:Boolean}},components:{AddressTagItem:()=>s.e("chunk-vendors~cfbf0a2e").then(s.bind(null,"dba0"))},data(){return{tags:h}},methods:{onSelectItem(e){this.$emit("input",e)}}},f=d,p=(s("3014"),s("2877")),g=Object(p["a"])(f,c,u,!1,null,"0e3ae0da",null),m=g.exports,v=s("7bec"),C=s.n(v),w=s("bf2e"),S=s("2ba5"),y=s("2f62"),A=s("6634"),D=s("0378"),U=s("ddd8"),b=s("27f9"),T=s("eb85"),I=s("3b73"),E=s("1c1c"),k=s("66e5"),P=s("4074"),F=s("24e8"),R=s("f09f"),x=s("a370"),_=s("4b7e");r["default"].use(o,{load:{key:a["a"],libraries:"places",region:"th",language:"th"}});const M={QForm:D["a"],QSelect:U["a"],QInput:b["a"],QSeparator:T["a"],QExpansionItem:I["a"],QList:E["a"],QItem:k["a"],QItemSection:P["a"],QDialog:F["a"],QCard:R["a"],QCardSection:x["a"],QCardActions:_["a"]};var O={name:"AddAddressDialog",components:{...M,AddressTagPicker:m,VuePhoneNumberInput:C.a,LocationEditor:()=>s.e("chunk-vendors~fdc6512a").then(s.bind(null,"c1a7"))},mixins:[S["a"]],data(){return{promptPhone:{show:!1,phone:void 0,phoneDummy:void 0,phoneDummyError:!1,verify:!1,verifyLoading:!1,verificationCode:void 0,confirm:!1,confirmLoading:!1},local:{name:null,tag:null},address:{name:null,firstname:null,lastname:null,address:null,subDistrict:null,district:null,province:null,postcode:null,email:null,phone:null,location:null},moreAddressInfo:null,predictions:[],selectedPrediction:null,mapCenter:{lat:13.736717,lng:100.523186},userAddressCenter:null,expanded:!0,warning:{show:!1,title:null,message:null,type:null},mapHover:!1,addAddressLoading:!1,editLocationDialog:!1,outOfServiceDialog:!1}},computed:{...Object(y["b"])("user",["shippingAddressList","user"]),provinceList(){let e=w.map(e=>e.ProvinceEng)||[];return[...new Set(e)].sort()},districtList(){if(this.address.province){let e=w.filter(e=>e.ProvinceEng===this.address.province.trim()).map(e=>e.DistrictEng);return[...new Set(e)].sort()}return[]},subDistrictList(){if(this.address.district){let e=w.filter(e=>e.DistrictEng===this.address.district.trim()).map(e=>e.TambonEng);return[...new Set(e)].sort()}return[]},postalCodeList(){if(this.address.subDistrict){let e=w.filter(e=>e.TambonEng===this.address.subDistrict.trim()).map(e=>e.PostCodeMain);return[...new Set(e)].sort()}return[]},isMapOverlay(){return!this.userAddressCenter},showMarker(){return!!this.userAddressCenter},canEditTag(){return null!==this.userAddressCenter},allowConfirm(){return!!this.address.address&&(!!(this.address.name||this.local.name||this.local.tag)&&(!!this.address.postcode&&(!!this.address.subDistrict&&(!!this.address.district&&(!!this.address.province&&(!!this.address.location&&"error"!==this.warning.type))))))},isMobile(){return this.$q.screen.width<600}},async mounted(){await this.loadUser(),this.user.firstName?(this.local.name=this.user.firstName,this.user.lastName&&(this.local.name=this.local.name+" "+this.user.lastName)):user.name&&(this.local.name=user.name),this.user.phone_number&&(this.address.phone=this.user.phone_number),this.user.email&&(this.address.email=this.user.email)},watch:{"address.province":{handler:async function(){this.address.district=null,this.address.subDistrict=null,this.address.postcode=null,this.address.name=null,await this.$nextTick(()=>{let e=this.$refs["select_district"];e&&e.focus()}),this.userAddressCenter&&await this.computeAddressWarning(this.userAddressCenter)}},"address.district":{handler:async function(){this.address.subDistrict=null,this.address.postcode=null,this.address.name=null,await this.$nextTick(()=>{let e=this.$refs["select_sub_district"];e&&e.focus()}),this.userAddressCenter&&await this.computeAddressWarning(this.userAddressCenter)}},"address.subDistrict":{handler:async function(){this.address.postcode=this.postalCodeList[0]||null,this.address.name=null,await this.$nextTick(()=>{let e=this.$refs["select_post_code"];e&&e.focus()}),this.userAddressCenter&&await this.computeAddressWarning(this.userAddressCenter)}},"address.postcode":{handler:async function(){this.userAddressCenter&&await this.computeAddressWarning(this.userAddressCenter)}},"address.address":{handler:async function(e){}},userAddressCenter:{handler:function(e){null==e&&this.clearWarning()}}},methods:{async onSubmit(){try{var e,t,s;if(this.promptPhone.phoneDummyError)return void this.$nextTick(()=>{const e=document.getElementById("MazPhoneNumberInput-155_phone_number");e&&(e.scrollIntoView(),e.focus())});this.addAddressLoading=!0,await this.loadUser();const i=this.$store.getters["user/user"];this.local.tag?this.address.name=this.local.tag:this.local.name&&(this.address.name=this.local.name.split(" ")[0]),this.address.firstname=null!==(e=this.local.name.split(" ")[0])&&void 0!==e?e:"-",this.address.lastname=null!==(t=this.local.name.split(" ")[1])&&void 0!==t?t:"-",!i.email&&this.address.email&&await this.$store.dispatch("user/UpdateUserInfo",{email:this.address.email}),this.userAddressCenter&&(this.address.location=this.userAddressCenter);let n=!0;const r=await this.$store.dispatch("delivery/GetDeliveryFee",this.address.location);if(r&&(null===(s=r.top5)||void 0===s?void 0:s.length)>0&&(n=!1),n){const e=await A["a"].isPostalCodeValidAsync(this.address.postcode);if(!e)return this.outOfServiceDialog=!0,void(this.addAddressLoading=!1)}let o=JSON.parse(JSON.stringify(this.address));this.moreAddressInfo&&(o.address=this.moreAddressInfo);const a=[...this.shippingAddressList,o];await this.$store.dispatch("user/AddAddress",a),this.$emit("close")}catch(i){}finally{this.addAddressLoading=!1}},onClose(){this.$emit("close")},onQuery:Object(l["debounce"])((async function(e){if(!e)return this.userAddressCenter=null,void(this.address.location=null);const t={input:e,location:String([13.736717,100.523186]),radius:8e5,language:"Thai"};this.$store.dispatch("villaMap/GetPlaceList",t).then(async e=>{e?(this.predictions=e,this.clearWarning()):(this.predictions=[],this.warning.show=!0,this.warning.title="Can't find your location on the map.",this.warning.message="We will deliver the goods to the pinned location. Please click on the map to pin your location.",await this.otherSearch())}).catch(e=>{})}),300),async otherSearch(){const e={input:`${this.address.subDistrict} ${this.address.district} ${this.address.province}`,location:String([13.736717,100.523186]),radius:8e5,language:"Thai"};await this.$store.dispatch("villaMap/GetPlaceList",e).then(async e=>{e.length>0&&await this.getLocationDetail(e[0].place_id,!1)}).catch(e=>{})},onClickMarker(){this.editLocationDialog=!0},onDragMarker(){this.editLocationDialog=!0},async onSelectPredictedItem(e){this.selectedPrediction=e,this.address.address=e.terms[0].value+" "+e.terms[1].value,this.predictions=[],await this.getLocationDetail(e.place_id,!0)},async getLocationDetail(e,t){const s={placeId:e,fields:["address_components","geometry","formatted_address"]};this.$store.dispatch("villaMap/GetDetails",s).then(async e=>{this.userAddressCenter={lat:e.geometry.location.lat,lng:e.geometry.location.lng},this.sync(),await this.computeAddressWarning(this.userAddressCenter)})},async computeAddressWarning(e){if(!this.address.postcode)return;const t=await this.getGmapPostalCode(e);t.includes(this.address.postcode.trim()),this.warning.type="warn",this.warning.title="Pin your location",this.warning.message="We will deliver the goods to the pinned location. Please check your pin location. If the pins do not match Please click on the edit button.",this.warning.show=!0},sync(){this.mapCenter=this.userAddressCenter,this.address={...this.address,location:{lat:this.userAddressCenter.lat,lng:this.userAddressCenter.lng}}},onEditMarker(){this.editLocationDialog=!0},clearWarning(){this.warning.show=!1,this.warning.title=null,this.warning.message=null},onUpdateLocation(e){this.address.location=e,this.userAddressCenter=null,this.userAddressCenter=e,this.$refs.mapRef.$mapPromise.then(t=>{t.panTo(e)}),this.$refs.markerRef.$markerPromise.then(t=>{t.setPosition(e)}),this.editLocationDialog=!1},validatePhoneNumber(e){if(!e)return!1;var t=/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im;return!!e.match(t)},async getGmapPostalCode(e){const t={location:String([e.lat,e.lng])};let s=new Promise((e,s)=>{try{this.$store.dispatch("villaMap/Geocode",t).then(t=>{let s=[];t.forEach(e=>{e.address_components.forEach(e=>{e.types.some(e=>"postal_code"===e)&&s.push(e.short_name)})}),e([...new Set(s)])})}catch(i){e([])}});return s},onUpdatePromptPhone(e){this.promptPhone.phone=e.formattedNumber,this.address.phone=e.formattedNumber,e.isValid?this.promptPhone.phoneDummyError=!1:this.promptPhone.phoneDummyError=!0}}},N=O,B=(s("1ed7"),Object(p["a"])(N,i,n,!1,null,"a6797c62",null));t["default"]=B.exports},8788:function(e,t,s){},"945c":function(e,t,s){},"94bf":function(e,t,s){},e54f:function(e,t,s){},e706:function(e,t,s){"use strict";(function(e){var i;if(s.d(t,"a",(function(){return n})),"undefined"!==typeof window&&window.crypto&&(i=window.crypto),!i&&"undefined"!==typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&"undefined"!==typeof e&&e.crypto&&(i=e.crypto),!i)try{i=s(2)}catch(r){}function n(){if(i){if("function"===typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(r){}if("function"===typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(r){}}throw new Error("Native crypto module could not be used to get secure random number.")}}).call(this,s("c8ba"))}}]);